aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2022-01-08 20:42:10 +0800
committerPo Lu2022-01-08 20:44:47 +0800
commit2e60ca3713af49cd8b3bfe5cda9ad51f6be6046a (patch)
treec9b0a87fd0aa6247fed2371e34dcc97fd2e8dac9 /src
parent9652736b084a09133e983e204eaa29573c0359cc (diff)
downloademacs-2e60ca3713af49cd8b3bfe5cda9ad51f6be6046a.tar.gz
emacs-2e60ca3713af49cd8b3bfe5cda9ad51f6be6046a.zip
Correctly translate GDK virtual modifiers when using native input
* src/gtkutil.c (xg_virtual_mods_to_x): New function. (xg_widget_key_press_event_cb): Translate modifiers to X first.
Diffstat (limited to 'src')
-rw-r--r--src/gtkutil.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/gtkutil.c b/src/gtkutil.c
index f2362275147..aaa2933f86e 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -6024,6 +6024,27 @@ xg_add_virtual_mods (struct x_display_info *dpyinfo, GdkEventKey *key)
6024 key->state |= GDK_HYPER_MASK; 6024 key->state |= GDK_HYPER_MASK;
6025} 6025}
6026 6026
6027static unsigned int
6028xg_virtual_mods_to_x (struct x_display_info *dpyinfo, guint virtual)
6029{
6030 unsigned int modifiers = virtual & ~(GDK_SUPER_MASK
6031 | GDK_META_MASK
6032 | GDK_HYPER_MASK
6033 | GDK_MOD2_MASK
6034 | GDK_MOD3_MASK
6035 | GDK_MOD4_MASK
6036 | GDK_MOD5_MASK);
6037
6038 if (virtual & GDK_META_MASK)
6039 modifiers |= dpyinfo->meta_mod_mask;
6040 if (virtual & GDK_SUPER_MASK)
6041 modifiers |= dpyinfo->super_mod_mask;
6042 if (virtual & GDK_HYPER_MASK)
6043 modifiers |= dpyinfo->hyper_mod_mask;
6044
6045 return modifiers;
6046}
6047
6027static void 6048static void
6028xg_im_context_commit (GtkIMContext *imc, gchar *str, 6049xg_im_context_commit (GtkIMContext *imc, gchar *str,
6029 gpointer user_data) 6050 gpointer user_data)
@@ -6093,6 +6114,7 @@ xg_widget_key_press_event_cb (GtkWidget *widget, GdkEvent *event,
6093 struct frame *f = NULL; 6114 struct frame *f = NULL;
6094 union buffered_input_event inev; 6115 union buffered_input_event inev;
6095 guint keysym = event->key.keyval; 6116 guint keysym = event->key.keyval;
6117 unsigned int xstate;
6096 gunichar *cb; 6118 gunichar *cb;
6097 ptrdiff_t i; 6119 ptrdiff_t i;
6098 glong len; 6120 glong len;
@@ -6117,8 +6139,11 @@ xg_widget_key_press_event_cb (GtkWidget *widget, GdkEvent *event,
6117 EVENT_INIT (inev.ie); 6139 EVENT_INIT (inev.ie);
6118 XSETFRAME (inev.ie.frame_or_window, f); 6140 XSETFRAME (inev.ie.frame_or_window, f);
6119 6141
6120 inev.ie.modifiers |= x_x_to_emacs_modifiers (FRAME_DISPLAY_INFO (f), 6142 xstate = xg_virtual_mods_to_x (FRAME_DISPLAY_INFO (f),
6121 event->key.state); 6143 event->key.state);
6144
6145 inev.ie.modifiers
6146 |= x_x_to_emacs_modifiers (FRAME_DISPLAY_INFO (f), xstate);
6122 6147
6123 /* First deal with keysyms which have defined 6148 /* First deal with keysyms which have defined
6124 translations to characters. */ 6149 translations to characters. */