[Xcb] xcb_change_window_attributes vs. XSelectInput

Jochen Keil jochen.keil at gmail.com
Thu Mar 6 12:03:42 PST 2014


Hello Philip,

On 06.03.2014 20:02, Philip Rushik wrote:
> 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).
> 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).
> 
> 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?

`xcb_change_attributes` produces an XCB_ACCESS error. You can find out
about this by either calling the `xcb_change_attributes_checked` variant
and using the `xcb_request_check` function or checking for an error in
the event loop (both flavors are demonstrated in the attached program).

The XCB_ACCESS error happens because you don't own any of those windows.
You'd need to set XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT on your root
window to do that. But in that case you are competing with your window
manager.

I remember that I read about this some time ago and why XSelectInput
behaves differently, but I don't remember the details.

Now you now what happens, but not why. Maybe someone else can fill the
void. :)

Best,
Jochen
-------------- next part --------------
A non-text attachment was scrubbed...
Name: snoop.c
Type: text/x-c
Size: 2927 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/xcb/attachments/20140306/228f69e2/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/xcb/attachments/20140306/228f69e2/attachment.pgp>


More information about the Xcb mailing list