
Quoting Brandon Allbery
On Fri, Jun 29, 2012 at 3:16 PM,
wrote: Built with -threaded, a forkOS thread could do dbus calls and then establish its own Xlib connection and XSendEvent() or install a property on the root window to relay the result. This doesn't necessarily need to be a one-way connection, but nothing in the main thread can block to wait on a response from the dbus thread (instead, use handleEventHook).
My understanding is that if xmonad were built with -threaded, forkIO would be enough (forkOS would not be necessary). Safe foreign imports are run on their own (OS) thread by the threaded runtime anyway. For the same reason, I don't really think it's necessary to get at X's fd and tell the IO manager about it. (If there are blocking X calls that are imported unsafe, I consider that a bug, and would happily make a release of the X11 package fixing it.) The only annoyance left would be, as you say, communicating with the main thread -- which would have to roundtrip through X. Only an architectural change to xmonad can fix that. However, I wouldn't be surprised if there were other gotchas related to turning on -threaded. I vaguely recall that this was attempted in the past and had some issues. Perhaps it had something to do with asynchronous exceptions and xmonad's masking stuff...? ~d