Register hotkey with only modifiers in Linux

772 Views Asked by At

I'm using this sample to set hotkey in my program in Linux X11 graphic system. The problem is i don't understand how to set hotkey combinations like Ctrl+Alt and Ctrl+Shift, i.e. without any key, only modifers. I'm trying like this:

KeyCode key = XKeysymToKeycode(display, 0); //no key code
XGrabKey(display, key, ControlMask | ShiftMask, grabWin, true, GrabModeAsync, GrabModeAsync);

But it's not working. However, it is working like this (kind of):

 KeyCode key = XKeysymToKeycode(display, XK_Alt_L); //Alt key
 XGrabKey(display, key, ControlMask, grabWin, true, GrabModeAsync, GrabModeAsync);

I don't like this solution, because:

  1. Logically wrong
  2. It's only fires when Ctrl+Alt pressed, not Alt+Ctrl, i.e. pressing order is important
  3. It's blocking all other combinations in windows with Ctrl and Alt keys.

What am I doing wrong?

0

There are 0 best solutions below