[Xcb] Problem selecting event input from different threads.

Jamey Sharp jamey at minilop.net
Mon Apr 19 11:56:40 PDT 2010

On Mon, Apr 19, 2010 at 9:12 AM, Erik De Rijcke <derijcke.erik at gmail.com> wrote:
> Am I perhaps doing something wrong when setting the event mask?

I'm not actually an X protocol expert, but perhaps you meant to use
ChangeWindowAttributes rather than ConfigureWindow? Event-mask seems
to be a window attribute, and the protocol documentation for
ConfigureWindow says "Attempts to configure a root window have no

Your notes that KeymapNotify still arrives and that the
SubstructureRedirect didn't seem to have its expected side effect were
both good information.

Other changes you probably want:

> const uint32_t values[] = { eventMask };
> xcb_void_cookie_t cookie = xcb_configure_window(
> (xcb_connection_t*) display, (xcb_window_t) window,
> XCB_CW_EVENT_MASK, values);
> xcb_generic_error_t *error = xcb_request_check((xcb_connection_t*) display,
> cookie);

If you want to use xcb_request_check, you need to use the _checked
variant of the request, so in this case, call
xcb_configure_window_checked. It would certainly be nice to know if
you're getting an X error back from this request. :-)

Be aware that when you call xcb_request_check immediately after the
request, you'll have to wait for a round-trip to the server, so if you
care about speed here you'll want to combine it with other requests or
check for the error lazily. I'm guessing you don't care much about app
startup time or context switches, but just so you're aware...

> checkError(error);
> xcb_flush((xcb_connection_t*) display);

When xcb_request_check returns, you know that not only has the checked
request been flushed, but it has also been processed by the server,
and you've read any response it generated. So this xcb_flush is
redundant (but harmless).

> On Mon, Apr 19, 2010 at 4:54 PM, Ian Osgood <iano at quirkster.com> wrote:
>> One sanity check...  In your XCB code, are you calling xcb_flush() after
>> every sequence of xcb commands that you expect to generate events?  One big
>> difference between Xlib's XNextEvent and XCB's xcb_wait_for_event is the
>> lack of an hidden flush.

Thanks, Ian. That had definitely been my next question. :-)


More information about the Xcb mailing list