[Xcb] Preventing the X server from sending key events to a child window that is under the mouse

Uli Schlachter psychon at znc.in
Wed Apr 29 15:02:12 UTC 2020


Hi Nicholas,

On 28.04.20 21:01, Nicholas Allen wrote:
> It seems as though the X server is sending it to the plug-in child window
> that wants key events and is current under the mouse cursor. We would like
> to just always get the key events to our window as the plug-in APIs have
> ways of dispatching key press and release events to the plugins.

Here is the relevant part of the protocol specification that describes
how events are delivered:

> The source of the event is the window the pointer is in. The window the
> event is reported with respect to is called the event window. The event
> window is found by starting with the source window and looking up the
> hierarchy for the first window on which any client has selected interest
> in the event. [...] The actual window used for reporting can be modified> by active grabs [...]

https://www.x.org/releases/X11R7.6/doc/xproto/x11protocol.html#events:input

So, basically, the answer is a combination of "no" and "you need an
active grab".

One approach to get such a grab, but only when the pointer is inside of
your window, is to use EnterNotify and LeaveNotify event for grabbing
and ungrabbing. See the GrabPointer request.
I guess something similar is possible with FocusIn and FocusOut events
and the GrabKeyboard request. However, this means that all WM key
combinations would then stop working.

Cheers,
Uli
-- 
“I’m Olaf and I like warm hugs.”


More information about the Xcb mailing list