/* ** ** To build: ** gcc -o selectiontest -Wall -Wextra -lXm -lXt -lX11 selectiontest.c */ #include #include #include static void getSelectionCB (Widget w, XtPointer clientData, Atom * selType, Atom * type, XtPointer value, unsigned long *length, int *format) { /* We don't really care about the value, here, it's just an example code */ XtFree ((char *) value); } static void cb_clicked (Widget w, XtPointer p, XtPointer cb) { static Atom targets[2] = { XA_STRING }; static int data = 0; static XtPointer clientData[2] = { (XtPointer) &data, (XtPointer) &data }; targets[1] = XInternAtom (XtDisplay (w), "DELETE", True); XtGetSelectionValues (w, XA_PRIMARY, targets, 2, getSelectionCB, clientData, CurrentTime); } int main (int argc, char *argv[]) { // Setup application. XtAppContext app = 0; Widget top = XtVaAppInitialize (&app, "SelectionTest", NULL, 0, &argc, argv, NULL, NULL); Widget button = XtVaCreateManagedWidget ("Click here", xmPushButtonWidgetClass, top, NULL); XtAddCallback (button, XmNactivateCallback, cb_clicked, top); XtRealizeWidget (top); // Main loop. XtAppMainLoop (app); return 0; }