Re: Preventing the X server from sending key events to a child window that is under the mouse

Uli Schlachter <[email protected]> Wed, 29 Apr 2020 17:02:12 +0200
Newsgroups gmane.comp.freedesktop.xcb
Message-ID <[email protected]>
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.ā€
_______________________________________________
Xcb mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/xcb