[Xcb] xcb_change_window_attributes vs. XSelectInput

Rémi Denis-Courmont remi at remlab.net
Thu Mar 6 12:22:15 PST 2014


Le vendredi 7 mars 2014, 04:02:16 Philip Rushik a écrit :
> I am trying to write a simple program that will receive mouse motion events
> from all windows. I found the following Xlib code and I have tested it and
> it works perfectly. So I did some research and tried to write an equivalent
> function in XCB. The Xlib code gets me events from all windows and
> everything works as usual (original windows still get the events as well).

AFAIK the X protocol does not allow more than one X client to capture either 
button or key events for a given window at a time. The first client to request 
them gets them, further clients will get an error. If no client requests them 
at all, they will be passed to the parent window automatically (and so on).

Note this does not apply to motion events, which any number of client can 
follow.

> However, the XCB code finds all the children correctly, but only gets
> events from the JWM desktop and none of the other children despite finding
> them correctly. In addition, while the XCB code is running, the JWM desktop
> no longer receives those events (clicking does not activate the menu).

Are you sure nobody else catches the events? Most GUI frameworks 
systematically catch input events no matter what, so you cannot easily steal 
input events from the window of other applications (except by grabbing).

> I can't figure out how the two are different, XSelectInput must be doing
> something more that I don't understand. Can anybody provide some insight?

At protocol level and thus at XCB level, you should not even need to modify 
the children windows mask anyway; you will inherit the events provided that no 
other X clients request them. I think.

-- 
Rémi Denis-Courmont
http://www.remlab.net/



More information about the Xcb mailing list