summaryrefslogtreecommitdiffstats
path: root/src/gui_gtk_x11.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-05-16 14:01:51 +0200
committerBram Moolenaar <Bram@vim.org>2020-05-16 14:01:51 +0200
commitfd615a3c901f59abddca27c6a09940be552c0f4d (patch)
tree75fdd6532b664e0a7971b309c07242aac28d4571 /src/gui_gtk_x11.c
parenta6e67e4f41386c3e6eab7e047671c6d32f6cb0dc (diff)
patch 8.2.0765: In the GUI can't use all the modifiers.v8.2.0765
Problem: In the GUI can't use all the modifiers. (Andri Möll) Solution: Do not apply Alt/Meta early, do it later like with the terminal. Avoid the Motif test from crashing.
Diffstat (limited to 'src/gui_gtk_x11.c')
-rw-r--r--src/gui_gtk_x11.c107
1 files changed, 31 insertions, 76 deletions
diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c
index ea43c93850..02526b2726 100644
--- a/src/gui_gtk_x11.c
+++ b/src/gui_gtk_x11.c
@@ -1212,39 +1212,9 @@ key_press_event(GtkWidget *widget UNUSED,
return FALSE;
#endif
- // Check for Alt/Meta key (Mod1Mask), but not for a BS, DEL or character
- // that already has the 8th bit set.
- // Don't do this for <S-M-Tab>, that should become K_S_TAB with ALT.
- // Don't do this for double-byte encodings, it turns the char into a lead
- // byte.
- if (len == 1
- && ((state & GDK_MOD1_MASK)
-#if GTK_CHECK_VERSION(2,10,0)
- || (state & GDK_SUPER_MASK)
-#endif
- )
- && !(key_sym == GDK_BackSpace || key_sym == GDK_Delete)
- && (string[0] & 0x80) == 0
- && !(key_sym == GDK_Tab && (state & GDK_SHIFT_MASK))
- && !enc_dbcs
- )
- {
- string[0] |= 0x80;
- state &= ~GDK_MOD1_MASK; // don't use it again
- if (enc_utf8) // convert to utf-8
- {
- string[1] = string[0] & 0xbf;
- string[0] = ((unsigned)string[0] >> 6) + 0xc0;
- if (string[1] == CSI)
- {
- string[2] = KS_EXTRA;
- string[3] = (int)KE_CSI;
- len = 4;
- }
- else
- len = 2;
- }
- }
+ // We used to apply Alt/Meta to the key here (Mod1Mask), but that is now
+ // done later, the same as it happens for the terminal. Hopefully that
+ // works for everybody...
// Check for special keys. Also do this when len == 1 (key has an ASCII
// value) to detect backspace, delete and keypad keys.
@@ -1266,52 +1236,37 @@ key_press_event(GtkWidget *widget UNUSED,
if (len == 0) // Unrecognized key
return TRUE;
- // Special keys (and a few others) may have modifiers. Also when using a
- // double-byte encoding (can't set the 8th bit).
- if (len == -3 || key_sym == GDK_space || key_sym == GDK_Tab
- || key_sym == GDK_Return || key_sym == GDK_Linefeed
- || key_sym == GDK_Escape || key_sym == GDK_KP_Tab
- || key_sym == GDK_ISO_Enter || key_sym == GDK_3270_Enter
- || (enc_dbcs && len == 1 && ((state & GDK_MOD1_MASK)
-#if GTK_CHECK_VERSION(2,10,0)
- || (state & GDK_SUPER_MASK)
-#endif
- )))
- {
- modifiers = modifiers_gdk2vim(state);
+ // Handle modifiers.
+ modifiers = modifiers_gdk2vim(state);
- /*
- * For some keys a shift modifier is translated into another key
- * code.
- */
- if (len == -3)
- key = TO_SPECIAL(string[1], string[2]);
- else
- key = string[0];
+ // For some keys a shift modifier is translated into another key code.
+ if (len == -3)
+ key = TO_SPECIAL(string[1], string[2]);
+ else
+ key = string[0];
- key = simplify_key(key, &modifiers);
- if (key == CSI)
- key = K_CSI;
- if (IS_SPECIAL(key))
- {
- string[0] = CSI;
- string[1] = K_SECOND(key);
- string[2] = K_THIRD(key);
- len = 3;
- }
- else
- {
- string[0] = key;
- len = 1;
- }
+ key = simplify_key(key, &modifiers);
+ if (key == CSI)
+ key = K_CSI;
+ if (IS_SPECIAL(key))
+ {
+ string[0] = CSI;
+ string[1] = K_SECOND(key);
+ string[2] = K_THIRD(key);
+ len = 3;
+ }
+ else
+ {
+ string[0] = key;
+ len = 1;
+ }
- if (modifiers != 0)
- {
- string2[0] = CSI;
- string2[1] = KS_MODIFIER;
- string2[2] = modifiers;
- add_to_input_buf(string2, 3);
- }
+ if (modifiers != 0)
+ {
+ string2[0] = CSI;
+ string2[1] = KS_MODIFIER;
+ string2[2] = modifiers;
+ add_to_input_buf(string2, 3);
}
if (len == 1 && ((string[0] == Ctrl_C && ctrl_c_interrupts)