Mercurial > vim
comparison src/gui_w32.c @ 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 | 3fd992496509 |
children | 7fc67f9d84a7 |
comparison
equal
deleted
inserted
replaced
28638:26369a825c26 | 28639:8ea5468f9b5a |
---|---|
825 | 825 |
826 if (GetKeyState(VK_CONTROL) & 0x8000) | 826 if (GetKeyState(VK_CONTROL) & 0x8000) |
827 modifiers |= MOD_MASK_CTRL; | 827 modifiers |= MOD_MASK_CTRL; |
828 if (GetKeyState(VK_SHIFT) & 0x8000) | 828 if (GetKeyState(VK_SHIFT) & 0x8000) |
829 modifiers |= MOD_MASK_SHIFT; | 829 modifiers |= MOD_MASK_SHIFT; |
830 if (GetKeyState(VK_MENU) & 0x8000) | 830 // Windows handles Ctrl + Alt as AltGr and vice-versa. We can distinguish |
831 // the two cases by checking whether the left or the right Alt key is | |
832 // pressed. | |
833 if (GetKeyState(VK_LMENU) & 0x8000) | |
831 modifiers |= MOD_MASK_ALT; | 834 modifiers |= MOD_MASK_ALT; |
832 // Windows handles Ctrl + Alt as AltGr, in that case no modifier is actually | 835 if ((modifiers & MOD_MASK_CTRL) && (GetKeyState(VK_RMENU) & 0x8000)) |
833 // pressed. | 836 modifiers &= ~MOD_MASK_CTRL; |
834 if ((modifiers & (MOD_MASK_CTRL | MOD_MASK_ALT)) == | |
835 (MOD_MASK_CTRL | MOD_MASK_ALT)) | |
836 modifiers &= ~(MOD_MASK_CTRL | MOD_MASK_ALT); | |
837 | 837 |
838 return modifiers; | 838 return modifiers; |
839 } | 839 } |
840 | 840 |
841 /* | 841 /* |
953 | 953 |
954 if (keyFlags & MK_SHIFT) | 954 if (keyFlags & MK_SHIFT) |
955 vim_modifiers |= MOUSE_SHIFT; | 955 vim_modifiers |= MOUSE_SHIFT; |
956 if (keyFlags & MK_CONTROL) | 956 if (keyFlags & MK_CONTROL) |
957 vim_modifiers |= MOUSE_CTRL; | 957 vim_modifiers |= MOUSE_CTRL; |
958 if (GetKeyState(VK_MENU) & 0x8000) | 958 if (GetKeyState(VK_LMENU) & 0x8000) |
959 vim_modifiers |= MOUSE_ALT; | 959 vim_modifiers |= MOUSE_ALT; |
960 | 960 |
961 gui_send_mouse_event(button, x, y, repeated_click, vim_modifiers); | 961 gui_send_mouse_event(button, x, y, repeated_click, vim_modifiers); |
962 } | 962 } |
963 | 963 |
1720 gui_mch_haskey(char_u *name) | 1720 gui_mch_haskey(char_u *name) |
1721 { | 1721 { |
1722 int i; | 1722 int i; |
1723 | 1723 |
1724 for (i = 0; special_keys[i].vim_code1 != NUL; i++) | 1724 for (i = 0; special_keys[i].vim_code1 != NUL; i++) |
1725 if (name[0] == special_keys[i].vim_code0 && | 1725 if (name[0] == special_keys[i].vim_code0 |
1726 name[1] == special_keys[i].vim_code1) | 1726 && name[1] == special_keys[i].vim_code1) |
1727 return OK; | 1727 return OK; |
1728 return FAIL; | 1728 return FAIL; |
1729 } | 1729 } |
1730 | 1730 |
1731 void | 1731 void |
1970 | 1970 |
1971 for (i = 0; special_keys[i].key_sym != 0; i++) | 1971 for (i = 0; special_keys[i].key_sym != 0; i++) |
1972 { | 1972 { |
1973 // ignore VK_SPACE when ALT key pressed: system menu | 1973 // ignore VK_SPACE when ALT key pressed: system menu |
1974 if (special_keys[i].key_sym == vk | 1974 if (special_keys[i].key_sym == vk |
1975 && (vk != VK_SPACE || !(GetKeyState(VK_MENU) & 0x8000))) | 1975 && (vk != VK_SPACE || !(GetKeyState(VK_LMENU) & 0x8000))) |
1976 { | 1976 { |
1977 /* | 1977 /* |
1978 * Behave as expected if we have a dead key and the special key | 1978 * Behave as expected if we have a dead key and the special key |
1979 * is a key that would normally trigger the dead key nominal | 1979 * is a key that would normally trigger the dead key nominal |
1980 * character output (such as a NUMPAD printable character or | 1980 * character output (such as a NUMPAD printable character or |
2049 if (GetKeyState(VK_SHIFT) & 0x8000) | 2049 if (GetKeyState(VK_SHIFT) & 0x8000) |
2050 keyboard_state[VK_SHIFT] = 0x80; | 2050 keyboard_state[VK_SHIFT] = 0x80; |
2051 if (GetKeyState(VK_CAPITAL) & 0x0001) | 2051 if (GetKeyState(VK_CAPITAL) & 0x0001) |
2052 keyboard_state[VK_CAPITAL] = 0x01; | 2052 keyboard_state[VK_CAPITAL] = 0x01; |
2053 // Alt-Gr is synthesized as Alt + Ctrl. | 2053 // Alt-Gr is synthesized as Alt + Ctrl. |
2054 if ((GetKeyState(VK_MENU) & 0x8000) && | 2054 if ((GetKeyState(VK_RMENU) & 0x8000) |
2055 (GetKeyState(VK_CONTROL) & 0x8000)) | 2055 && (GetKeyState(VK_CONTROL) & 0x8000)) |
2056 { | 2056 { |
2057 keyboard_state[VK_MENU] = 0x80; | 2057 keyboard_state[VK_MENU] = 0x80; |
2058 keyboard_state[VK_CONTROL] = 0x80; | 2058 keyboard_state[VK_CONTROL] = 0x80; |
2059 } | 2059 } |
2060 | 2060 |