linux x11 copy paste event code example
Example: 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.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 };
XChangeProperty( my_display, event.xselectionrequest.requestor,
propertyOfRequestorToSet,
XA_ATOM,
32,
PropModeReplace,
(unsigned char *) possibleTargets,
sizeof(possibleTargets)/sizeof(possibleTargets[0])
);
selEvent.property = propertyOfRequestorToSet;
}
else ... {
}
if ( 0 == XSendEvent( my_display, selEvent.requestor, False, 0L, (XEvent*)&selEvent ) ) {
printf("call to XSendEvent() failed\n");
}
}