XInput2 raw events only for root window

Will Song incertia at incertia.net
Fri May 29 14:53:49 UTC 2020


The application is using xcb, but I thought the answer should be library
agnostic as it is my understanding that xorg-server would be handling
these requests, xcb and Xlib being libraries that merely forward them to
the server. I have pasted the relevant code sample below.

  // once for the raw data
  select_event.mask = XCB_INPUT_XI_EVENT_MASK_RAW_KEY_PRESS |
                      XCB_INPUT_XI_EVENT_MASK_RAW_KEY_RELEASE |
                      XCB_INPUT_XI_EVENT_MASK_RAW_BUTTON_PRESS |
                      XCB_INPUT_XI_EVENT_MASK_RAW_BUTTON_RELEASE |
                      XCB_INPUT_XI_EVENT_MASK_RAW_MOTION;

  select_event.header.deviceid = XCB_INPUT_DEVICE_ALL_MASTER;
  select_event.header.mask_len = 1;

  xcb_input_xi_select_events(xcb->con, window->screen->root, 1,
                             &select_event.header);

  // once more for the window data
  select_event.mask = XCB_INPUT_XI_EVENT_MASK_KEY_PRESS |
                      XCB_INPUT_XI_EVENT_MASK_KEY_RELEASE |
                      XCB_INPUT_XI_EVENT_MASK_BUTTON_PRESS |
                      XCB_INPUT_XI_EVENT_MASK_BUTTON_RELEASE |
                      XCB_INPUT_XI_EVENT_MASK_MOTION |
                      XCB_INPUT_XI_EVENT_MASK_FOCUS_IN |
                      XCB_INPUT_XI_EVENT_MASK_FOCUS_OUT |
                      XCB_INPUT_XI_EVENT_MASK_ENTER |
                      XCB_INPUT_XI_EVENT_MASK_LEAVE;

  select_event.header.deviceid = XCB_INPUT_DEVICE_ALL_MASTER;
  select_event.header.mask_len = 1;

  xcb_input_xi_select_events(xcb->con, window->window, 1,
                             &select_event.header);

Trying to select for a single raw event in the second call, e.g. by
adding XCB_INPUT_XI_EVENT_MASK_RAW_KEY_PRESS, causes it to fail,
detected by not getting any key press/key release events that would've
otherwise been received.

On Fri, May 29, 2020 at 07:47:28AM +0000, Walter Harms wrote:
> It would be helpful if you would be a bit more verbose.
> Your are using X11 ? Xlib ? Qt ?
> 
> Most people are aware of a whole plethora of libs and need to
> know so exactly as possible what you are doing, a small pseudo code
> or real code is also a good idea.
> 
> jm2c,
> wh
> ________________________________________
> Von: xorg <xorg-bounces at lists.x.org> im Auftrag von Will Song <incertia at incertia.net>
> Gesendet: Freitag, 29. Mai 2020 07:25:42
> An: xorg at lists.x.org
> Betreff: XInput2 raw events only for root window
> 
> Hey all. I am writing a small-ish application and when grabbing for keyboard
> events I noticed that it was not possible to select for raw key press/releasee
> events on the client window I created, and must be done on the screen root. Is
> this an intentional design in the xorg server or is it possible to do this
> generally in a non-root window? Thanks.
> 
> --
> Will Song
> _______________________________________________
> xorg at lists.x.org: X.Org support
> Archives: http://lists.freedesktop.org/archives/xorg
> Info: https://lists.x.org/mailman/listinfo/xorg
> Your subscription address: %(user_address)s

-- 
Will Song


More information about the xorg mailing list