return len;
}
+ static int
+get_active_modifiers(void)
+{
+ int modifiers = 0;
+
+ if (GetKeyState(VK_CONTROL) & 0x8000)
+ 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
+ // pressed.
+ if ((modifiers & (MOD_MASK_CTRL | MOD_MASK_ALT)) ==
+ (MOD_MASK_CTRL | MOD_MASK_ALT))
+ modifiers &= ~(MOD_MASK_CTRL | MOD_MASK_ALT);
+
+ return modifiers;
+}
+
/*
* Key hit, add it to the input buffer.
*/
{
char_u string[40];
int len = 0;
- int modifiers = 0;
+ int modifiers;
int ch = cch; // special keys are negative
dead_key = 0;
- if (GetKeyState(VK_SHIFT) & 0x8000)
- modifiers |= MOD_MASK_SHIFT;
- if (GetKeyState(VK_CONTROL) & 0x8000)
- modifiers |= MOD_MASK_CTRL;
+ modifiers = get_active_modifiers();
ch = simplify_key(ch, &modifiers);
// remove the SHIFT modifier for keys where it's already included, e.g.,
// ALT key pressed. Eg, if the user presses Alt-A, then ch == 'A'. Note
// that the system distinguishes Alt-a and Alt-A (Alt-Shift-a unless
// CAPSLOCK is pressed) at this point.
- modifiers = MOD_MASK_ALT;
- if (GetKeyState(VK_SHIFT) & 0x8000)
- modifiers |= MOD_MASK_SHIFT;
- if (GetKeyState(VK_CONTROL) & 0x8000)
- modifiers |= MOD_MASK_CTRL;
-
+ modifiers = get_active_modifiers();
ch = simplify_key(ch, &modifiers);
// remove the SHIFT modifier for keys where it's already included, e.g.,
// '(' and '*'
* VK_BACK, or VK_ESCAPE it means that he actually wants to deal
* with the dead char now, so do nothing special and let Windows
* handle it.
+ *
+ * Note that VK_SPACE combines with the dead_key's character and
+ * only one WM_CHAR will be generated by TranslateMessage(), in
+ * the two other cases two WM_CHAR will be generated: the dead
+ * char and VK_BACK or VK_ESCAPE. That is most likely what the
+ * user expects.
*/
if ((vk == VK_SPACE || vk == VK_BACK || vk == VK_ESCAPE))
{
dead_key = 0;
+ TranslateMessage(&msg);
+ return;
}
// In modes where we are not typing, dead keys should behave
// normally
NULL, NULL) == NULL)
break;
#endif
- if (GetKeyState(VK_SHIFT) & 0x8000)
- modifiers |= MOD_MASK_SHIFT;
- /*
- * Don't use caps-lock as shift, because these are special keys
- * being considered here, and we only want letters to get
- * shifted -- webb
- */
- /*
- if (GetKeyState(VK_CAPITAL) & 0x0001)
- modifiers ^= MOD_MASK_SHIFT;
- */
- if (GetKeyState(VK_CONTROL) & 0x8000)
- modifiers |= MOD_MASK_CTRL;
- if (GetKeyState(VK_MENU) & 0x8000)
- modifiers |= MOD_MASK_ALT;
+ modifiers = get_active_modifiers();
if (special_keys[i].vim_code1 == NUL)
key = special_keys[i].vim_code0;
int i;
UINT scan_code;
- if (GetKeyState(VK_SHIFT) & 0x8000)
- modifiers |= MOD_MASK_SHIFT;
- if (GetKeyState(VK_CONTROL) & 0x8000)
- modifiers |= MOD_MASK_CTRL;
- if (GetKeyState(VK_LMENU) & 0x8000)
- modifiers |= MOD_MASK_ALT;
-
// Construct the state table with only a few modifiers, we don't
// really care about the presence of Ctrl/Alt as those modifiers are
// handled by Vim separately.
keyboard_state[VK_SHIFT] = 0x80;
if (GetKeyState(VK_CAPITAL) & 0x0001)
keyboard_state[VK_CAPITAL] = 0x01;
- if (GetKeyState(VK_RMENU) & 0x8000)
+ // Alt-Gr is synthesized as Alt + Ctrl.
+ if ((GetKeyState(VK_MENU) & 0x8000) &&
+ (GetKeyState(VK_CONTROL) & 0x8000))
{
keyboard_state[VK_MENU] = 0x80;
keyboard_state[VK_CONTROL] = 0x80;
if (fnames != NULL)
{
- if ((GetKeyState(VK_SHIFT) & 0x8000) != 0)
+ int kbd_modifiers = get_active_modifiers();
+
+ if ((kbd_modifiers & MOD_MASK_SHIFT) != 0)
modifiers |= MOUSE_SHIFT;
- if ((GetKeyState(VK_CONTROL) & 0x8000) != 0)
+ if ((kbd_modifiers & MOD_MASK_CTRL) != 0)
modifiers |= MOUSE_CTRL;
- if ((GetKeyState(VK_MENU) & 0x8000) != 0)
+ if ((kbd_modifiers & MOD_MASK_ALT) != 0)
modifiers |= MOUSE_ALT;
gui_handle_drop(pt.x, pt.y, modifiers, fnames, cFiles);