summaryrefslogtreecommitdiff
path: root/src/xwidget.c
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2022-01-04 19:30:07 +0800
committerPo Lu <luangruo@yahoo.com>2022-01-04 19:30:07 +0800
commit377bf26ebe292d16b26043c566a7c00c452caf27 (patch)
tree8c2b24e1594ecf6e83f011aa4c01b860955deede /src/xwidget.c
parent4309679742a89fbd1b56a1bdf601e85887d1eadc (diff)
downloademacs-377bf26ebe292d16b26043c566a7c00c452caf27.tar.gz
Stop assuming X kbd state works with GDK when forwarding events to xwidgets
* src/xwidget.c (xw_translate_x_modifiers): New function. (Fxwidget_perform_lispy_event): Translate X modifiers to GDK modifiers before sending them to the xwidget.
Diffstat (limited to 'src/xwidget.c')
-rw-r--r--src/xwidget.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/xwidget.c b/src/xwidget.c
index 3df208034b8..bfb666e5654 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -222,6 +222,34 @@ xw_forward_event_from_view (GtkWidget *widget, GdkEvent *event,
}
#endif
+#ifdef HAVE_X_WINDOWS
+static guint
+xw_translate_x_modifiers (struct x_display_info *dpyinfo,
+ unsigned int modifiers)
+{
+ guint mods = 0;
+
+ if (modifiers & dpyinfo->meta_mod_mask)
+ {
+ /* GDK always assumes Mod1 is alt, but that's no reason for
+ us to make that mistake as well. */
+ if (!dpyinfo->alt_mod_mask)
+ mods |= GDK_MOD1_MASK;
+ else
+ mods |= GDK_META_MASK;
+ }
+
+ if (modifiers & dpyinfo->alt_mod_mask)
+ mods |= GDK_MOD1_MASK;
+ if (modifiers & dpyinfo->super_mod_mask)
+ mods |= GDK_SUPER_MASK;
+ if (modifiers & dpyinfo->hyper_mod_mask)
+ mods |= GDK_HYPER_MASK;
+
+ return mods;
+}
+#endif
+
DEFUN ("make-xwidget",
Fmake_xwidget, Smake_xwidget,
4, 7, 0,
@@ -563,7 +591,13 @@ selected frame is not an X-Windows frame. */)
keycode = gdk_unicode_to_keyval (character);
xg_event->key.keyval = keycode;
+#ifndef HAVE_X_WINDOWS
xg_event->key.state = modifiers;
+#else
+ if (f)
+ xg_event->key.state = xw_translate_x_modifiers (FRAME_DISPLAY_INFO (f),
+ modifiers);
+#endif
if (keycode > -1)
{