I'm trying to implement global hotkeys in Mono and X11. Unfortunately the application uses System.Windows.Forms
, so I can't use the GDK# event filter proposed in this question.
Using XGrabKey
works, but I've got a problem with the event loop. When closing the application, the thread handling the X11 event loop still hangs in XNextEvent
. Is there a way around that? I'd rather not resort to polling with XPending
. Can I somehow cancel XNextEvent
or send a dummy event?
I'm calling XGrabKey
on the root window, so unfortunately I don't get any events like DestroyNotify
or UnmapNotify
.
Use
XSendEvent
to send anXClientMessageEvent
. Create your own atom and set theAtom
member of the event, so that other apps that might be watching forXClientMessageEvent
on the root window are not affected.In your event loop, check for this atom, and exit if you get it.