[Xcb] Asking for help with xcb_wait_for_event function.

Peter Harris pharris at opentext.com
Fri Mar 11 08:02:33 PST 2011


On 2011-03-11 00:37, John Found wrote:
> So, the question is: How to make xcb_wait_for_event to not remove the event from
> the event queue, but symply to wait until event apears in the queue?

You don't.

There are a few different possible approaches here. Three of the more
obvious include:

- Write wrappers for wait/poll. Keep your own queue, and write an unget
function to put your event back in your own queue (this is how "ungetc"
works; <stdio> doesn't actually push any characters back to the OS), or
a wait_only type function.

- Use xcb_get_file_descriptor and select() on it instead of wait_for_ing
on the xcb connection. This has the disadvantage that select() doesn't
know about events already in the xcb queue, and (especially if you have
multiple threads) you might wind up waiting when you didn't need to.

- Since your native language isn't C, you can write your own libxasmb
that works exactly the way you want it to. XCB was designed to make this
easy (or, at least, far easier than it was in the Xlib days) by
providing an XML description of the X protocol. "Easy" is relative; this
is by far the hardest option of the three.

Peter Harris
-- 
               Open Text Connectivity Solutions Group
Peter Harris                    http://connectivity.opentext.com/
Research and Development        Phone: +1 905 762 6001
pharris at opentext.com            Toll Free: 1 877 359 4866


More information about the Xcb mailing list