XInput2 -- Filtering and Replaying keyboard

Patrick Herbst paherbst at gmail.com
Wed Jun 17 22:53:32 UTC 2020


I'm working on some filtering code to filter out keyboard events from
a specific keyboard.

for an example, i'm just trying to capture 'a'

...
XIGrabKeycode(dpy, kbd_id, XKeysymToKeycode(dpy, XK_a),
DefaultRootWindow(dpy), GrabModeSync, GrabModeAsync, 0, &mask, 1,
&modifiers_inout);
....
XNextEvent(dpy, &evt);
printf("event: %d %x\n", evt.type, evt.xany.window);
if (XGetEventData(dpy, &evt.xcookie) &&
    evt.xcookie.extension == xi_opcode)
{
  dev_event=evt.xcookie.data;
  XIAllowEvents(
    dpy,
    kbd_id,
    XIReplayDevice,
    CurrentTime);
}

This captures 'a' just fine, but it doesn't replay it for the focus
window.  Am i missing something?

Similar code works fine when using legacy XGrabKey, but XInput2 isn't
working for me.

Thanks!


More information about the xorg mailing list