Okay, here’s what I’ve come up with:
Single events are pulled directly from the X11 queue, as demanded
by the main application thread.
Async notification: SIGIO on the X11 file descriptor (triggered on all X calls) SIGINT/SIGTERM from the user (sets quit_requested flag)
Single events are posted to the internal event queue by WinProc(),
as demanded by the main application thread. WinProc() is reeentrant.
Async notification: hooks are set up trapping mouse and keyboard events SIGINT from the user
A separate thread polls the mouse and keyboard, posting messages
to the internal queue. This is necessary to catch raw keyboard
events and mouse motion.
Async notification: Performed by event thread SIGINT from the user
The async notification should only be used as a hint that the application
may have events pending. The application may not have events pending even
if the async notification is triggered. The event queue should be polled
periodically to take care of events that do not trigger the notification.
Async notification is disabled by default.
The above hasn’t been implemented yet.
I’d love to hear feedback from everyone. Does this sound good?