All toolkits support this mode of operation.
You need to watch the X server connection socket in your own event engine. Once data is available, you do (in pseudocode)
while (PendingEvent())
ProcessEvent()
Each toolkit has its own version of ProcessEvent() and perhaps PendingEvent() too (but you can always use XPending(Display*)
for that). Namely,
- Gtk+ has
gtk_events_pending()
and gtk_main_iteration()
- Xt-based toolkits have
XtAppPending()
and XtDispatchEvent()
- (c++) wxWidgets has
wxApp::.Pending()
and wxApp::Dispatch()
- (c++) Qt has
QApplication::processEvents()
, you can also implement your own QAbstractEventDispatcher
and/or QEventLoop
class
There are not that many actively developed C toolkits, I think Gtk+ is the only reasonable choice.
Edit With GTK at least, this technique will not work with toolkit-added timeouts, i.e. blinking cursors won't blink unless there are some other toolkit events to process. Periodic calling of gtk_main_iteration_do(FALSE)
even without events pending kind of "fixes" this, but doing the toolkit loop in a different thread would be more robust.