Register hotkey with only modifiers in Linux

若如初见. 提交于 2019-12-22 08:28:51

问题


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?

来源:https://stackoverflow.com/questions/27171400/register-hotkey-with-only-modifiers-in-linux

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!