[Xcb] Problem selecting event input from different threads.

Erik De Rijcke derijcke.erik at gmail.com
Mon Apr 19 09:12:56 PDT 2010

Some code:

This is called by thread B, window is the rood win id, eventMask is

jclass class, jlong display, jlong window, jlong eventMask) {

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

xcb_generic_error_t *error = xcb_request_check((xcb_connection_t*) display,
xcb_flush((xcb_connection_t*) display);

This is called from thread A inside a loop, received events are immediately
placed on a queue and read by thread B for further handling.

jclass class, jlong display, jobject resultByteBuffer) {

xcb_flush((xcb_connection_t*) display);
xcb_generic_event_t *ev = xcb_wait_for_event((xcb_connection_t*) display);
char* resultBuffer = initResultHandling(env, &resultByteBuffer);
writeToBuffer(0, resultBuffer, ev, sizeof(xcb_generic_event_t));


Because thread B handles the events and thread A runs in a tight loop, all
requests to the X server by thread B end with a flush.

Am I perhaps doing something wrong when setting the event mask?

On Mon, Apr 19, 2010 at 4:54 PM, Ian Osgood <iano at quirkster.com> wrote:

> On Apr 18, 2010, at 1:31 PM, Erik De Rijcke wrote:
> > Hi,
> >
> > I have a fairly large program with a small part accessing xcb. It
> basically does the following:
> >
> > thread A: open a display; spawn thread b; listen for events.
> > thread B: set event mask (substructure redirect mask on root window)
> >
> > What seems to happen is that thread A never gets any configure request
> events nor map requests. However when I replicate this exact code with Xlib
> with build in xcb backend, thread A does receive events.
> >
> > I'm guessing only the thread that sets the mask gets the events, is there
> a way to tell xcb to deliver the events to thread A or is this a possible
> bug?
> > _______________________________________________
> > Xcb mailing list
> > Xcb at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/xcb
> 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.
> Further answers will only come if you post code.
> Ian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/xcb/attachments/20100419/2262813f/attachment.html>

More information about the Xcb mailing list