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
XSendEventto send anXClientMessageEvent. Create your own atom and set theAtommember of the event, so that other apps that might be watching forXClientMessageEventon the root window are not affected.In your event loop, check for this atom, and exit if you get it.