예제 #1
0
        public static WindowsVirtualKey LinuxToWindows(LinuxKeyCode key)
        {
            try
            {
                if (key == LinuxKeyCode.KPRETURN)
                {
                    key = LinuxKeyCode.Return;
                }
                else if (key == LinuxKeyCode.KPDELETE)
                {
                    key = LinuxKeyCode.Delete;
                }
                else if (key == LinuxKeyCode.KPSUBTRACT)
                {
                    key = LinuxKeyCode.Subtract;
                }
                else if (key == LinuxKeyCode.KPPLUS)
                {
                    key = LinuxKeyCode.Add;
                }

                return((WindowsVirtualKey)Enum.Parse(typeof(WindowsVirtualKey), key.ToString()));
            }catch (Exception ex)
            {
                ISLogger.Write("Failed to translate linux key {0}: {1}", key, ex.Message);
                return(0);
            }
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
 public static extern int XUngrabKey(IntPtr display, LinuxKeyCode key, LinuxKeyMask mask, IntPtr window);
예제 #5
0
 public static extern int XGrabKey(IntPtr display, LinuxKeyCode key, LinuxKeyMask mask, IntPtr window, bool owner_events, int pointerMode, int keyboardMode);