summaryrefslogtreecommitdiff
path: root/src/w32inevt.c
diff options
context:
space:
mode:
authorJussi Lahdenniemi <jussi@aprikoodi.fi>2016-02-26 12:51:24 +0200
committerEli Zaretskii <eliz@gnu.org>2016-02-26 12:51:24 +0200
commit97d7a0b8db4ce32a8e489dec48634b7e85212eaa (patch)
treee1477561851991fe7be1213747d201d744794286 /src/w32inevt.c
parent22994735af588be9c2d6d438155b73328aaa0cf3 (diff)
downloademacs-97d7a0b8db4ce32a8e489dec48634b7e85212eaa.tar.gz
Improve the register-hotkey functionality on MS-Windows
* src/w32fns.c (_WIN32_WINNT): Define to 0x0600, needed for keyboard hook functionality. Include w32inevt.h, basetyps.h and unknwn.h. (VK_ANY, WM_WTSSESSION_CHANGE, WTS_SESSION_LOCK): New macros. (kbdhook): A new struct definition. (funhook, setup_w32_kbdhook, remove_w32_kbdhook, hook_w32_key) (check_w32_winkey_state, reset_w32_kbdhook_state): New functions. (modifier_set): Call check_w32_winkey_state if a Win key was pressed and the keyboard hook is active. (w32_wnd_proc): Don't handle Win key combinations if the keyboard hook is active. Only register/unregister the hotkeys if the keyboard hook is not active. When WM_CREATE is received, call setup_w32_kbdhook. When WM_DESTROY is received, call reset_w32_kbdhook_state. (lookup_vk_code): When the keyboard hook is active, map alphanumeric characters to themselves. (w32_parse_and_hook_hot_key): Renamed from w32_parse_hot_key. Map modified keys to VK_ANY if the keyboard hook is active. Register Alt-x and Win-x combinations. (Fw32_shell_execute): Update doc string to reflect new functionality. Bypass the code that posts the WM_EMACS_REGISTER_HOT_KEY message if the keyboard hook is active. (Fw32_unregister_hot_key): Bypass the code that posts the WM_EMACS_UNREGISTER_HOT_KEY message if the keyboard hook is active. (syms_of_w32fns) <w32-pass-lwindow-to-system> <w32-pass-rwindow-to-system, w32-phantom-key-code> <w32-lwindow-modifier, w32-rwindow-modifier>: Update doc strings to reflect the new functionality. * src/w32console.c (initialize_w32_display): Install the low-level keyboard hook. * src/w32inevt.c (key_event): Handle Win-x combinations only if the keyboard hook is not active. If the hook is active, use check_w32_winkey_state instead. * src/w32term.h (setup_w32_kbdhook, remove_w32_kbdhook) (check_w32_winkey_state): Add prototypes. (w32_kbdhook_active): New macro. * doc/emacs/msdos.texi (Windows Keyboard): Update to reflect the new functionality.
Diffstat (limited to 'src/w32inevt.c')
-rw-r--r--src/w32inevt.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/w32inevt.c b/src/w32inevt.c
index e714e27f4bc..c7246c7a8e2 100644
--- a/src/w32inevt.c
+++ b/src/w32inevt.c
@@ -41,6 +41,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "termchar.h" /* for Mouse_HLInfo, tty_display_info */
#include "w32term.h"
#include "w32inevt.h"
+#include "w32common.h"
/* stdin, from w32console.c */
extern HANDLE keyboard_handle;
@@ -148,10 +149,12 @@ key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev, int *isdead)
switch (event->wVirtualKeyCode)
{
case VK_LWIN:
- mod_key_state &= ~LEFT_WIN_PRESSED;
+ if (!w32_kbdhook_active)
+ mod_key_state &= ~LEFT_WIN_PRESSED;
break;
case VK_RWIN:
- mod_key_state &= ~RIGHT_WIN_PRESSED;
+ if (!w32_kbdhook_active)
+ mod_key_state &= ~RIGHT_WIN_PRESSED;
break;
case VK_APPS:
mod_key_state &= ~APPS_PRESSED;
@@ -185,7 +188,8 @@ key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev, int *isdead)
keybd_event (faked_key, (BYTE) MapVirtualKey (faked_key, 0), 0, 0);
}
}
- mod_key_state |= LEFT_WIN_PRESSED;
+ if (!w32_kbdhook_active)
+ mod_key_state |= LEFT_WIN_PRESSED;
if (!NILP (Vw32_lwindow_modifier))
return 0;
break;
@@ -201,7 +205,8 @@ key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev, int *isdead)
keybd_event (faked_key, (BYTE) MapVirtualKey (faked_key, 0), 0, 0);
}
}
- mod_key_state |= RIGHT_WIN_PRESSED;
+ if (!w32_kbdhook_active)
+ mod_key_state |= RIGHT_WIN_PRESSED;
if (!NILP (Vw32_rwindow_modifier))
return 0;
break;
@@ -267,6 +272,13 @@ key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev, int *isdead)
/* Recognize state of Windows and Apps keys. */
event->dwControlKeyState |= mod_key_state;
+ if (w32_kbdhook_active)
+ {
+ if (check_w32_winkey_state (VK_LWIN))
+ event->dwControlKeyState |= LEFT_WIN_PRESSED;
+ if (check_w32_winkey_state (VK_RWIN))
+ event->dwControlKeyState |= RIGHT_WIN_PRESSED;
+ }
/* Distinguish numeric keypad keys from extended keys. */
event->wVirtualKeyCode =