diff options
| author | Jussi Lahdenniemi | 2016-02-26 12:51:24 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2016-02-26 12:51:24 +0200 |
| commit | 97d7a0b8db4ce32a8e489dec48634b7e85212eaa (patch) | |
| tree | e1477561851991fe7be1213747d201d744794286 /doc | |
| parent | 22994735af588be9c2d6d438155b73328aaa0cf3 (diff) | |
| download | emacs-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.texi | 81 |
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, |
| 511 | intercepted by the system before Emacs can see them. You can use the | 511 | for 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 | 512 | before Emacs can see them. Also, on Windows 10, all Windows key |
| 513 | seen by Emacs instead of being grabbed by Windows. This function | 513 | combinations are reserved by the system in such a way that they are |
| 514 | registers a key sequence as a @dfn{hot key}, overriding the special | 514 | never propagated to applications, even if the system does not |
| 515 | meaning of that key sequence for Windows. (MS-Windows is told that | 515 | currently define a hotkey on the specific combination. You can use |
| 516 | the key sequence is a hot key only when one of the Emacs windows has | 516 | the @code{w32-register-hot-key} function to allow a key sequence to be |
| 517 | focus, so that the special keys still have their usual meaning for | 517 | seen by Emacs instead of being grabbed by Windows. When registered as |
| 518 | other Windows applications.) | 518 | a hot key, the key combination is pulled out of the system's input |
| 519 | 519 | queue before it is handled by Windows, effectively overriding the | |
| 520 | The argument to @code{w32-register-hot-key} must be a single key, | 520 | special meaning of that key sequence for Windows. The override is |
| 521 | with or without modifiers, in vector form that would be acceptable to | 521 | only effective when Emacs is active; with other applications on the |
| 522 | @code{define-key}. The meta modifier is interpreted as the @key{Alt} | 522 | foreground the keys behave normally. |
| 523 | key if @code{w32-alt-is-meta} is @code{t} (the default), and the hyper | 523 | |
| 524 | modifier 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 |
| 525 | with @key{start} and the Windows logo). If the function succeeds in | 525 | single modifier, in vector form that would be acceptable to |
| 526 | registering the key sequence, it returns the hotkey ID, a number; | 526 | @code{define-key}. The control and shift modifiers have no effect on the |
| 527 | otherwise it returns @code{nil}. | 527 | argument. 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 | ||
| 529 | modifiers are interpreted according to the bindings of | ||
| 530 | @code{w32-lwindow-modifier} and @code{w32-rwindow-modifier}. Additionally, a | ||
| 531 | modifier with the trailing dash but with no key indicates that all | ||
| 532 | Windows defined hotkeys for that modifier are to be overridden in the | ||
| 533 | favor 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 |
| 534 | symbol at point at top level, or to complete the current search string | 540 | word or symbol at point at top level, or to complete the current |
| 535 | against previously sought strings during incremental search. | 541 | search string against previously sought strings during incremental |
| 542 | search. @code{(w32-register-hot-key [s-])} with | ||
| 543 | @code{w32-lwindow-modifier} bound to @code{super} disables all the | ||
| 544 | Windows' own Windows key based shortcuts.@footnote{There is one known | ||
| 545 | exception: The combination @kbd{@key{Windows}-@key{L}} that locks the | ||
| 546 | workstation is handled by the system on a lower level. For this | ||
| 547 | reason, @code{w32-register-hot-key} cannot override this key | ||
| 548 | combination - 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 | ||
| 552 | call. Thus, you can set @code{w32-lwindow-modifier} as @code{super}, | ||
| 553 | then call @code{(w32-register-hot-key [s-r])}, and finally set | ||
| 554 | @code{w32-rwindow-modifier} as @code{super} as well. The result is | ||
| 555 | that the left Windows key together with @key{R} invokes whichever | ||
| 556 | function you have bound for the combination in Emacs, and the right | ||
| 557 | Windows key and @key{R} opens the Windows @code{Run} dialog. | ||
| 558 | |||
| 559 | The hotkey registrations always also include all the shift and | ||
| 560 | control modifier combinations for the given hotkey; that is, | ||
| 561 | registering @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. | ||
| 565 | The desired hotkey must always be fully specified, and | ||
| 566 | @code{w32-phantom-key-code} can be customized to achieve desired | ||
| 567 | results. | ||
| 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 | |||
| 607 | otherwise it is passed to Windows. The default is @code{t} for both | 639 | otherwise it is passed to Windows. The default is @code{t} for both |
| 608 | of these variables. Passing each of these keys to Windows produces | 640 | of these variables. Passing each of these keys to Windows produces |
| 609 | its normal effect: for example, @kbd{@key{Lwindow}} opens the | 641 | its normal effect: for example, @kbd{@key{Lwindow}} opens the |
| 610 | @code{Start} menu, etc.@footnote{ | 642 | @code{Start} menu, etc. |
| 611 | Some combinations of the ``Windows'' keys with other keys are caught | ||
| 612 | by Windows at a low level in a way that Emacs currently cannot prevent. | ||
| 613 | For 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)} |