Thanks again to raph for pointing me at very interesting stuff. This time, I'm talking about this post by Jeff Darcy. I am experimenting with things he talks about, namely supporting both single- and multi-threaded, but starting from the single-threaded side, and queueing at the dispatcher's discretion.
I do wonder why he's saying that making timeouts (or any kind of time-based event) queueable events is a bad idea. One reason I like it is that it makes debugging and testing easier (one can record a stream of events and play them back quickly).
I have to see how Xlib event buffering works out regarding not calling its functions and just watching for ConnectionNumber(dpy)'s readability using (doing an XFlush first, of course!). I'm afraid that Xlib reads events from the stream as often as possible, so that I'll have to process X events for as long as XPending (?) is non-zero, so that it doesn't suck up newly appeared events from the stream while processing others (say XPending tells me there are two events, but while processing the first, a third one arrives, getting the second might get the third one from the stream, making the stream non-readable, thus making me not check for events). This is annoying, because getting many X events could make my loop starve out the other kinds of events.
Maybe I need some of that XCB stuff, but on the other hand, my problem also involves Qt, so it might be too much to ask.
If anyones has any idea of what I'm talking about and would have a hint, go ahead and mail me!