Question

My problem is similar to this: http://forum.winehq.org/viewtopic.php?t=14451

Gnome seems to call XGrabKey() for Alt-F2, but it's also a hotkey in my program. How to make my program receive this event instead of Gnome shell, when it's in foreground?

If I call XGrabKey(), it will return BadAccess. If I call XGrabKeyboard(), then my program will supress all other global hotkeys.

Was it helpful?

Solution

It is not possible. You do not receive the event. The root window receives the keypress and is owned by the window manager. The window manager then delegates the keypress. Global shortcuts take precedence.

An evil hack could be to alter Gnome's global shortcuts while the program is running. The users will burn your house down for this.

Another alternative is, as you mentioned to grab the keyboard. Then you receive the events instead of the root window. You could pull the evil hack of passing keypresses that you are not interested in (other global shortcuts) to the root window via the XTest extension. The users will burn your house down for this.

The users will probably be quite happy though if you change your shortcut.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top