Capturing all events from a presentation remote while allowing all other events to be sent normally

Eric Sokolowsky esok127 at
Mon Apr 29 21:42:46 UTC 2019

I have an application that is used as a control system for a presentation,
under Linux and using X11. I have a USB presentation remote that acts as a
very miniature keyboard (four buttons: Page Up, Page Down, and two others)
which can be used to advance and go back in the presentation. I would like
to have my presentation application to receive all of the events from this
remote regardless of where the mouse focus is. But I would also like to be
able to receive the normal mouse and keyboard events if the current window
focus is on the presentation application. Using XIGrabDevice() I was able
to receive all events from the remote in the presentation application
regardless of the current focus but I was not able to receive any events
from the mouse or other keyboard while the grab was active. Is what I'm
trying to do possible?

Here's the code I'm using:

XIEventMask masks[1];
unsigned char mask[(XI_LASTEVENT+7)/8];
memset(mask, 0, sizeof(mask));
XISetMask(mask, XI_KeyPress);
masks[0].deviceid = XIAllMasterDevices;
masks[0].mask_len = sizeof(mask);
masks[0].mask = mask;
Status result = XIGrabDevice(dpy, deviceid, win, CurrentTime, None,
XIGrabModeAsync, XIGrabModeAsync, True, masks);

Any help would be appreciated. Thank you.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the xorg mailing list