protected override void OnHotkeyRemoved(Hotkey key) { LinuxKeyMask mask = ConvertMask(key.Modifiers); LinuxKeyCode lKey = KeyTranslator.WindowsToLinux(key.Key); XUngrabKey(xConnection.XDisplay, lKey, mask, xConnection.XRootWindow); XUngrabKey(xConnection.XDisplay, lKey, mask | LinuxKeyMask.NumLockMask, xConnection.XRootWindow); XUngrabKey(xConnection.XDisplay, lKey, mask | LinuxKeyMask.ScrollLockMask, xConnection.XRootWindow); }
protected override void OnHotkeyAdded(Hotkey key) { LinuxKeyMask mask = ConvertMask(key.Modifiers); LinuxKeyCode lKey = KeyTranslator.WindowsToLinux(key.Key); //We don't care if the num lock or scroll lock is on/off, so we need //to grab those seperate to ensure that we receive events regardless of the state of scroll/num lock XGrabKey(xConnection.XDisplay, lKey, mask, xConnection.XRootWindow, true, 1, 1); XGrabKey(xConnection.XDisplay, lKey, mask | LinuxKeyMask.NumLockMask, xConnection.XRootWindow, true, 1, 1); XGrabKey(xConnection.XDisplay, lKey, mask | LinuxKeyMask.ScrollLockMask, xConnection.XRootWindow, true, 1, 1); }
private LinuxKeyMask ConvertMask(HotkeyModifiers mods) { LinuxKeyMask mask = 0; if (mods.HasFlag(HotkeyModifiers.Alt)) { mask |= LinuxKeyMask.AltMask; } if (mods.HasFlag(HotkeyModifiers.Ctrl)) { mask |= LinuxKeyMask.ControlMask; } if (mods.HasFlag(HotkeyModifiers.Shift)) { mask |= LinuxKeyMask.ShiftMask; } if (mods.HasFlag(HotkeyModifiers.Windows)) { mask |= LinuxKeyMask.WindowsMask; } return(mask); }
public static extern int XUngrabKey(IntPtr display, LinuxKeyCode key, LinuxKeyMask mask, IntPtr window);
public static extern int XGrabKey(IntPtr display, LinuxKeyCode key, LinuxKeyMask mask, IntPtr window, bool owner_events, int pointerMode, int keyboardMode);