Some code:<div><br></div><div>This is called by thread B, window is the rood win id, eventMask is XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT</div><div><br></div><div><div><font class="Apple-style-span" face="'courier new', monospace">JNIEXPORT void JNICALL</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">Java_org_fusion_x11_nativeHelpers_NativeCalls_nativePropagateEvent(JNIEnv *env,</font></div><div><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" face="'courier new', monospace">                </font></span><font class="Apple-style-span" face="'courier new', monospace">jclass class, jlong display, jlong window, jlong eventMask) {</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" face="'courier new', monospace">        </font></span><font class="Apple-style-span" face="'courier new', monospace">const uint32_t values[] = { eventMask };</font></div>
<div><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" face="'courier new', monospace">        </font></span><font class="Apple-style-span" face="'courier new', monospace">xcb_void_cookie_t cookie = xcb_configure_window(</font></div>
<div><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" face="'courier new', monospace">                        </font></span><font class="Apple-style-span" face="'courier new', monospace">(xcb_connection_t*) display, (xcb_window_t) window,</font></div>
<div><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" face="'courier new', monospace">                        </font></span><font class="Apple-style-span" face="'courier new', monospace">XCB_CW_EVENT_MASK, values);</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" face="'courier new', monospace">        </font></span><font class="Apple-style-span" face="'courier new', monospace">xcb_generic_error_t *error = xcb_request_check((xcb_connection_t*) display,</font></div>
<div><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" face="'courier new', monospace">                        </font></span><font class="Apple-style-span" face="'courier new', monospace">cookie);</font></div>
<div><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" face="'courier new', monospace">        </font></span><font class="Apple-style-span" face="'courier new', monospace">checkError(error);</font></div>
<div><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" face="'courier new', monospace">        </font></span><font class="Apple-style-span" face="'courier new', monospace">xcb_flush((xcb_connection_t*) display);</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">}</font></div></div><div><br></div><div><br></div><div><br></div><div>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.</div>
<div><br></div><div><div><font class="Apple-style-span" face="'courier new', monospace">JNIEXPORT void JNICALL</font></div><div><font class="Apple-style-span" face="'courier new', monospace">Java_org_fusion_x11_nativeHelpers_NativeCalls_nativeGetNextEvent(JNIEnv *env,</font></div>
<div><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" face="'courier new', monospace">                </font></span><font class="Apple-style-span" face="'courier new', monospace">jclass class, jlong display, jobject resultByteBuffer) {</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" face="'courier new', monospace">        </font></span><font class="Apple-style-span" face="'courier new', monospace">xcb_flush((xcb_connection_t*) display);</font></div>
<div><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" face="'courier new', monospace">        </font></span><font class="Apple-style-span" face="'courier new', monospace">xcb_generic_event_t *ev = xcb_wait_for_event((xcb_connection_t*) display);</font></div>
<div><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" face="'courier new', monospace">        </font></span><font class="Apple-style-span" face="'courier new', monospace">char* resultBuffer = initResultHandling(env, &resultByteBuffer);</font></div>
<div><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" face="'courier new', monospace">        </font></span><font class="Apple-style-span" face="'courier new', monospace">writeToBuffer(0, resultBuffer, ev, sizeof(xcb_generic_event_t));</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace">}</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><br>
</font></div><div><font class="Apple-style-span" face="'courier new', monospace">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.</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace">Am I perhaps doing something wrong when setting the event mask?</font></div>
<br><div class="gmail_quote">On Mon, Apr 19, 2010 at 4:54 PM, Ian Osgood <span dir="ltr"><<a href="mailto:iano@quirkster.com">iano@quirkster.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="h5"><br>
On Apr 18, 2010, at 1:31 PM, Erik De Rijcke wrote:<br>
<br>
> Hi,<br>
><br>
> I have a fairly large program with a small part accessing xcb. It basically does the following:<br>
><br>
> thread A: open a display; spawn thread b; listen for events.<br>
> thread B: set event mask (substructure redirect mask on root window)<br>
><br>
> 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.<br>
><br>
> 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?<br>
</div></div><div class="im">> _______________________________________________<br>
> Xcb mailing list<br>
> <a href="mailto:Xcb@lists.freedesktop.org">Xcb@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/xcb" target="_blank">http://lists.freedesktop.org/mailman/listinfo/xcb</a><br>
<br>
</div>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.<br>
<br>
Further answers will only come if you post code.<br>
<font color="#888888"><br>
Ian<br>
</font></blockquote></div><br></div>