Howto process X11 events async'ly

Peter Quiring pquiring at geocities.com
Fri Jan 21 13:39:24 CST 2005


I'm developing my own library and I'm in the process of porting it over in 
Linux.  I can get X11 to display the graphics and process events, but the 
only problem I have is with processing events without wasting CPU power.

How do you process events without constantly polling?  What I've done is 
create a new thread that will call XNextEvent() which will block if there 
are no events waiting and this seems to work fine.  Except if the main 
thread wants to use the Window it too will deadlock until XNextEvent() 
returns an event.  I've even tried using XPutBackEvent() to wake-up the 
other thread, but it looks like X11 is not smart enough to handle this. 
Looking at Wine source it looks like they too have given up on X11 and do 
sync themselves.

But then how do you know when new events are waiting without constantly 
polling ?????  I've looked thru wine source but can't follow it.

Thanks in advance.  I've asked this question many times @ linuxforum.com but 
no one there understands the problem.

Peter Quiring






More information about the wine-devel mailing list