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

Nicholas Allen nick at bitwig.com
Thu Apr 30 07:07:24 UTC 2020

Thanks for your response. I've also been searching further and it seems the
correct thing to do is to support the XEmbed protocol. For the keyboard
input they suggest making an invisible child input only window 1x1 at -1,1
so that it is invisible and then calling xcb_set_input_focus on that child
window when focus in event happens on our window. The X server will not
send key events to the plugin window as it is not a child of the invisible
input window. This seems to solve the problem!



On Wed, Apr 29, 2020 at 5:02 PM Uli Schlachter <psychon at znc.in> wrote:

> 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.”
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/xcb/attachments/20200430/d0aff2d8/attachment.htm>

More information about the Xcb mailing list