Mercurial > vim
changeset 28639:8ea5468f9b5a v8.2.4843
patch 8.2.4843: treating CTRL + ALT as AltGr is not backwards compatible
Commit: https://github.com/vim/vim/commit/202b4bd3a452898cfe3ed72facfbf7cb8199fa4b
Author: LemonBoy <thatlemon@gmail.com>
Date: Thu Apr 28 19:50:54 2022 +0100
patch 8.2.4843: treating CTRL + ALT as AltGr is not backwards compatible
Problem: Win32 GUI: Treating CTRL + ALT as AltGr is not backwards
compatible. (Axel Bender)
Solution: Make a difference between left and right menu keys.
(closes #10308)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 28 Apr 2022 21:00:04 +0200 |
parents | 26369a825c26 |
children | 952884eba10d |
files | src/gui_w32.c src/version.c |
diffstat | 2 files changed, 14 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gui_w32.c +++ b/src/gui_w32.c @@ -827,13 +827,13 @@ get_active_modifiers(void) modifiers |= MOD_MASK_CTRL; if (GetKeyState(VK_SHIFT) & 0x8000) modifiers |= MOD_MASK_SHIFT; - if (GetKeyState(VK_MENU) & 0x8000) - modifiers |= MOD_MASK_ALT; - // Windows handles Ctrl + Alt as AltGr, in that case no modifier is actually + // Windows handles Ctrl + Alt as AltGr and vice-versa. We can distinguish + // the two cases by checking whether the left or the right Alt key is // pressed. - if ((modifiers & (MOD_MASK_CTRL | MOD_MASK_ALT)) == - (MOD_MASK_CTRL | MOD_MASK_ALT)) - modifiers &= ~(MOD_MASK_CTRL | MOD_MASK_ALT); + if (GetKeyState(VK_LMENU) & 0x8000) + modifiers |= MOD_MASK_ALT; + if ((modifiers & MOD_MASK_CTRL) && (GetKeyState(VK_RMENU) & 0x8000)) + modifiers &= ~MOD_MASK_CTRL; return modifiers; } @@ -955,7 +955,7 @@ get_active_modifiers(void) vim_modifiers |= MOUSE_SHIFT; if (keyFlags & MK_CONTROL) vim_modifiers |= MOUSE_CTRL; - if (GetKeyState(VK_MENU) & 0x8000) + if (GetKeyState(VK_LMENU) & 0x8000) vim_modifiers |= MOUSE_ALT; gui_send_mouse_event(button, x, y, repeated_click, vim_modifiers); @@ -1722,8 +1722,8 @@ gui_mch_haskey(char_u *name) int i; for (i = 0; special_keys[i].vim_code1 != NUL; i++) - if (name[0] == special_keys[i].vim_code0 && - name[1] == special_keys[i].vim_code1) + if (name[0] == special_keys[i].vim_code0 + && name[1] == special_keys[i].vim_code1) return OK; return FAIL; } @@ -1972,7 +1972,7 @@ process_message(void) { // ignore VK_SPACE when ALT key pressed: system menu if (special_keys[i].key_sym == vk - && (vk != VK_SPACE || !(GetKeyState(VK_MENU) & 0x8000))) + && (vk != VK_SPACE || !(GetKeyState(VK_LMENU) & 0x8000))) { /* * Behave as expected if we have a dead key and the special key @@ -2051,8 +2051,8 @@ process_message(void) if (GetKeyState(VK_CAPITAL) & 0x0001) keyboard_state[VK_CAPITAL] = 0x01; // Alt-Gr is synthesized as Alt + Ctrl. - if ((GetKeyState(VK_MENU) & 0x8000) && - (GetKeyState(VK_CONTROL) & 0x8000)) + if ((GetKeyState(VK_RMENU) & 0x8000) + && (GetKeyState(VK_CONTROL) & 0x8000)) { keyboard_state[VK_MENU] = 0x80; keyboard_state[VK_CONTROL] = 0x80;