[Xcb] Asking for help with xcb_wait_for_event function.

Vincent Torri vtorri at univ-evry.fr
Thu Mar 10 22:46:56 PST 2011


Hey

> I am not so sure, here is the right place to ask for support,
> but as long as I didn't found another...
>
> Currently I am writing assembly language library with GUI toolkit.
> The Linux port uses XLib, but I want to try with XCB. The branch goes ok, but
> there is one problem, I can't find solution for.
>
> The main thread of the program looks following way:
>
> mainloop:
> 	ProcessSystemEvents;
> 	run_user_OnIdle_handler;
> 	WaitForSystemEvent;
> loop_to_mainloop;
>
> ProcessSystemEvents exits when the event queue is empty.
> The user OnIdle handler must be executed only once per cicle.
> WaitForEvent - simply put the thread in sleep until some event appears.
>
> I am using xcb_poll_for_event in ProcessSystemEvents and xcb_wait_for_event
> in WaitForSystemEvent. This way, as long as the xcb_wait_for_event removes
> the first event from the queue, I have to make very dirty hacks in order to
> process it - now I am using global variable where to store the pointer returned
> from xcb_wait_for_event.
>
> 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 can't. xcb_wait_for_event() or xcb_poll_for_event() always remove the 
event from the queue. What you do is what I also do in my event loop 
except that I use only xcb_poll_for_event().

Maybe others will have a better idea for a loop design

Vincent


More information about the Xcb mailing list