Search
 
SCRIPT & CODE EXAMPLE
 

CPP

linux x11 copy paste event

...
if ( event.type == SelectionRequest ) {
  Atom propertyOfRequestorToSet = event.xselectionrequest.property==None ? XA_PRIMARY : event.xselectionrequest.property;

  XSelectionEvent selEvent;
  selEvent.type = SelectionNotify;
  // selEvent.serial = event.xselectionrequest.serial; // I don't know if this is correct
  selEvent.send_event = True;
  selEvent.display = my_display;
  selEvent.requestor = event.xselectionrequest.requestor;
  selEvent.selection = event.xselectionrequest.selection;
  selEvent.target = event.xselectionrequest.target;
  selEvent.property = None;
  selEvent.time = event.xselectionrequest.time;

  if ( event.xselectionrequest.target == XA_TARGETS ) {

    Atom possibleTargets[] = { XA_UTF8_STRING, XA_STRING, XA_TEXT }; // [Note 2]

    // I checked, and this call returns 1
    XChangeProperty( my_display, event.xselectionrequest.requestor,
      propertyOfRequestorToSet,
      XA_ATOM,
      32, // 32 bits actually means long, according to what I've read // [Note 1]
      PropModeReplace,
      (unsigned char *) possibleTargets,
      sizeof(possibleTargets)/sizeof(possibleTargets[0])  // [Note 3]
    );

    selEvent.property = propertyOfRequestorToSet;
  }
  else ... {
  }

  if ( 0 == XSendEvent( my_display, selEvent.requestor, False, 0L, (XEvent*)&selEvent ) ) {
    printf("call to XSendEvent() failed
");
  }
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: Dfs program in c++ 
:: friend class c++ 
Cpp ::  
::  
C ::  
::  
:: terminal count files in directory 
::  
::  
C :: how to map one value to another in C 
:: execution time of c program 
::  
::  
::  
C :: graphics in c 
:: 0/1 knapsack problem in c 
::  
::  
::  
C ::  
::  
C ::  
C ::  
::  
C ::  
:: concatenate two strings without standard library in C 
::  
::  
C :: powershell list big files 
::  
ADD CONTENT
Topic
Content
Source link
Name
7+5 =