summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2022-04-11 19:27:07 +0800
committerPo Lu <luangruo@yahoo.com>2022-04-11 19:27:48 +0800
commit07ee24d83debfeb0570a596fa27e7203bf55a4b3 (patch)
tree5ecfd65e90dae55c793edb0d2c0ce84e354b60c8
parent11080420dd7f2c34bbebf797de6eb4d4a14dae35 (diff)
downloademacs-07ee24d83debfeb0570a596fa27e7203bf55a4b3.tar.gz
emacs-07ee24d83debfeb0570a596fa27e7203bf55a4b3.tar.bz2
emacs-07ee24d83debfeb0570a596fa27e7203bf55a4b3.zip
Fix event source attribution for GTK input methods
* src/gtkutil.c (xg_im_context_commit): Use pending keystroke source if it exists.
-rw-r--r--src/gtkutil.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 4fc0edf8ace..718da171f49 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -6274,6 +6274,10 @@ xg_im_context_commit (GtkIMContext *imc, gchar *str,
{
struct frame *f = user_data;
struct input_event ie;
+#ifdef HAVE_XINPUT2
+ struct xi_device_t *source;
+ struct x_display_info *dpyinfo;
+#endif
EVENT_INIT (ie);
/* This used to use g_utf8_to_ucs4_fast, which led to bad results
@@ -6292,6 +6296,22 @@ xg_im_context_commit (GtkIMContext *imc, gchar *str,
make_fixnum (SCHARS (ie.arg)),
Qcoding, Qt, ie.arg);
+#ifdef HAVE_XINPUT2
+ dpyinfo = FRAME_DISPLAY_INFO (f);
+
+ /* There is no timestamp associated with commit events, so use the
+ device that sent the last event to be filtered. */
+ if (dpyinfo->pending_keystroke_time)
+ {
+ dpyinfo->pending_keystroke_time = 0;
+ source = xi_device_from_id (dpyinfo,
+ dpyinfo->pending_keystroke_source);
+
+ if (source)
+ ie.device = source->name;
+ }
+#endif
+
XSETFRAME (ie.frame_or_window, f);
ie.modifiers = 0;
ie.timestamp = 0;