#include #include void event_callback(XPointer priv, XRecordInterceptData *hook) { } int main (int argc, char **argv) { int major = 0; int minor = 0; XRecordRange *rr = NULL; XRecordClientSpec rcs; XRecordContext rc; Display *ctrl_disp = XOpenDisplay (NULL); Display *data_disp = XOpenDisplay (NULL); if (!ctrl_disp || !data_disp) return 2; if (!XRecordQueryVersion (ctrl_disp, &major, &minor)) return 2; if (!XRecordQueryVersion (data_disp, &major, &minor)) return 2; if (!(rr = XRecordAllocRange())) return 2; rr->device_events.first = KeyPress; rr->device_events.last = MotionNotify; rcs = XRecordAllClients; XSynchronize(ctrl_disp, True); if (!(rc = XRecordCreateContext (ctrl_disp, 0, &rcs, 1, &rr, 1))) return 2; if (!XRecordEnableContextAsync (data_disp, rc, event_callback, NULL)) return 2; XFlush(data_disp); /* XRecordEnableContextAsync request has now been sent to X server * because of the flush. It assumes that XRecordCreateContext * request has been sent previously. If the XCB synchronization * bug is present, XRecordCreateContext request hasn't been * flushed to the X server yet. This will lead to an X error and * return code of 1. */ XCloseDisplay (data_disp); XCloseDisplay (ctrl_disp); return 0; }