aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorJussi Lahdenniemi2016-02-26 12:51:24 +0200
committerEli Zaretskii2016-02-26 12:51:24 +0200
commit97d7a0b8db4ce32a8e489dec48634b7e85212eaa (patch)
treee1477561851991fe7be1213747d201d744794286 /doc
parent22994735af588be9c2d6d438155b73328aaa0cf3 (diff)
downloademacs-97d7a0b8db4ce32a8e489dec48634b7e85212eaa.tar.gz
emacs-97d7a0b8db4ce32a8e489dec48634b7e85212eaa.zip
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 'doc')
-rw-r--r--doc/emacs/msdos.texi81
1 files changed, 54 insertions, 27 deletions
diff --git a/doc/emacs/msdos.texi b/doc/emacs/msdos.texi
index 6ad12d646a1..a87561ccf18 100644
--- a/doc/emacs/msdos.texi
+++ b/doc/emacs/msdos.texi
@@ -507,32 +507,64 @@ the variable @code{w32-alt-is-meta} to a @code{nil} value.
507@findex w32-register-hot-key 507@findex w32-register-hot-key
508@findex w32-unregister-hot-key 508@findex w32-unregister-hot-key
509 MS-Windows reserves certain key combinations, such as 509 MS-Windows reserves certain key combinations, such as
510@kbd{@key{Alt}-@key{TAB}}, for its own use. These key combinations are 510@kbd{@key{Alt}-@key{TAB}} and a number of Windows key combinations,
511intercepted by the system before Emacs can see them. You can use the 511for its own use. These key combinations are intercepted by the system
512@code{w32-register-hot-key} function to allow a key sequence to be 512before Emacs can see them. Also, on Windows 10, all Windows key
513seen by Emacs instead of being grabbed by Windows. This function 513combinations are reserved by the system in such a way that they are
514registers a key sequence as a @dfn{hot key}, overriding the special 514never propagated to applications, even if the system does not
515meaning of that key sequence for Windows. (MS-Windows is told that 515currently define a hotkey on the specific combination. You can use
516the key sequence is a hot key only when one of the Emacs windows has 516the @code{w32-register-hot-key} function to allow a key sequence to be
517focus, so that the special keys still have their usual meaning for 517seen by Emacs instead of being grabbed by Windows. When registered as
518other Windows applications.) 518a hot key, the key combination is pulled out of the system's input
519 519queue before it is handled by Windows, effectively overriding the
520 The argument to @code{w32-register-hot-key} must be a single key, 520special meaning of that key sequence for Windows. The override is
521with or without modifiers, in vector form that would be acceptable to 521only effective when Emacs is active; with other applications on the
522@code{define-key}. The meta modifier is interpreted as the @key{Alt} 522foreground the keys behave normally.
523key if @code{w32-alt-is-meta} is @code{t} (the default), and the hyper 523
524modifier is always interpreted as the Windows key (usually labeled 524 The argument to @code{w32-register-hot-key} must be a single key with a
525with @key{start} and the Windows logo). If the function succeeds in 525single modifier, in vector form that would be acceptable to
526registering the key sequence, it returns the hotkey ID, a number; 526@code{define-key}. The control and shift modifiers have no effect on the
527otherwise it returns @code{nil}. 527argument. The meta modifier is interpreted as the @key{Alt} key if
528@code{w32-alt-is-meta} is @code{t} (the default), and the super and hyper
529modifiers are interpreted according to the bindings of
530@code{w32-lwindow-modifier} and @code{w32-rwindow-modifier}. Additionally, a
531modifier with the trailing dash but with no key indicates that all
532Windows defined hotkeys for that modifier are to be overridden in the
533favor of Emacs.
528 534
529@kindex M-TAB@r{, (MS-Windows)} 535@kindex M-TAB@r{, (MS-Windows)}
530@cindex @kbd{M-@key{TAB}} vs @kbd{@key{Alt}-@key{TAB}} (MS-Windows) 536@cindex @kbd{M-@key{TAB}} vs @kbd{@key{Alt}-@key{TAB}} (MS-Windows)
531@cindex @kbd{@key{Alt}-@key{TAB}} vs @kbd{M-@key{TAB}} (MS-Windows) 537@cindex @kbd{@key{Alt}-@key{TAB}} vs @kbd{M-@key{TAB}} (MS-Windows)
532 For example, @code{(w32-register-hot-key [M-tab])} lets you use 538 For example, @code{(w32-register-hot-key [M-tab])} lets you use
533@kbd{M-@key{TAB}} normally in Emacs; for instance, to complete the word or 539@kbd{M-@key{TAB}} normally in Emacs; for instance, to complete the
534symbol at point at top level, or to complete the current search string 540word or symbol at point at top level, or to complete the current
535against previously sought strings during incremental search. 541search string against previously sought strings during incremental
542search. @code{(w32-register-hot-key [s-])} with
543@code{w32-lwindow-modifier} bound to @code{super} disables all the
544Windows' own Windows key based shortcuts.@footnote{There is one known
545exception: The combination @kbd{@key{Windows}-@key{L}} that locks the
546workstation is handled by the system on a lower level. For this
547reason, @code{w32-register-hot-key} cannot override this key
548combination - it always locks the computer.}
549
550 Note that @code{w32-register-hot-key} checks the
551@code{w32-[lr]window-modifier} values at the time of the function
552call. Thus, you can set @code{w32-lwindow-modifier} as @code{super},
553then call @code{(w32-register-hot-key [s-r])}, and finally set
554@code{w32-rwindow-modifier} as @code{super} as well. The result is
555that the left Windows key together with @key{R} invokes whichever
556function you have bound for the combination in Emacs, and the right
557Windows key and @key{R} opens the Windows @code{Run} dialog.
558
559 The hotkey registrations always also include all the shift and
560control modifier combinations for the given hotkey; that is,
561registering @kbd{s-@key{a}} as a hotkey gives you @kbd{S-s-@key{a}},
562@kbd{C-s-@key{a}} and @kbd{C-S-s-@key{a}} as well.
563
564 On Windows 98 and ME, the hotkey registration is more restricted.
565The desired hotkey must always be fully specified, and
566@code{w32-phantom-key-code} can be customized to achieve desired
567results.
536 568
537 The function @code{w32-unregister-hot-key} reverses the effect of 569 The function @code{w32-unregister-hot-key} reverses the effect of
538@code{w32-register-hot-key} for its argument key sequence. 570@code{w32-register-hot-key} for its argument key sequence.
@@ -607,12 +639,7 @@ keys are passed to Windows or swallowed by Emacs. If the value is
607otherwise it is passed to Windows. The default is @code{t} for both 639otherwise it is passed to Windows. The default is @code{t} for both
608of these variables. Passing each of these keys to Windows produces 640of these variables. Passing each of these keys to Windows produces
609its normal effect: for example, @kbd{@key{Lwindow}} opens the 641its normal effect: for example, @kbd{@key{Lwindow}} opens the
610@code{Start} menu, etc.@footnote{ 642@code{Start} menu, etc.
611Some combinations of the ``Windows'' keys with other keys are caught
612by Windows at a low level in a way that Emacs currently cannot prevent.
613For example, @kbd{@key{Lwindow} r} always pops up the Windows
614@samp{Run} dialog. Customizing the value of
615@code{w32-phantom-key-code} might help in some cases, though.}
616 643
617@vindex w32-recognize-altgr 644@vindex w32-recognize-altgr
618@kindex AltGr @r{(MS-Windows)} 645@kindex AltGr @r{(MS-Windows)}