emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master a6bfc3cb87: Fix IM event source attribution on GTK


From: Po Lu
Subject: master a6bfc3cb87: Fix IM event source attribution on GTK
Date: Mon, 11 Apr 2022 00:26:56 -0400 (EDT)

branch: master
commit a6bfc3cb87e91d37e0a7b67e9c68224fb432c989
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Fix IM event source attribution on GTK
    
    * src/xterm.c (handle_one_xevent): Set pending times on GTK as
    well.
    * src/gtkutil.c (xg_widget_key_press_event_cb): Respect pending
    keystroke time on XI2.
---
 src/gtkutil.c | 23 +++++++++++++++++++++++
 src/xterm.c   | 12 ++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/src/gtkutil.c b/src/gtkutil.c
index ec2864e34a..4fc0edf8ac 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -6347,6 +6347,10 @@ xg_widget_key_press_event_cb (GtkWidget *widget, 
GdkEvent *event,
   guint keysym = event->key.keyval;
   unsigned int xstate;
   gunichar uc;
+#ifdef HAVE_XINPUT2
+  Time pending_keystroke_time;
+  struct xi_device_t *source;
+#endif
 
   FOR_EACH_FRAME (tail, tem)
     {
@@ -6361,6 +6365,14 @@ xg_widget_key_press_event_cb (GtkWidget *widget, 
GdkEvent *event,
   if (!f)
     return true;
 
+#ifdef HAVE_XINPUT2
+  pending_keystroke_time
+    = FRAME_DISPLAY_INFO (f)->pending_keystroke_time;
+
+  if (event->key.time >= pending_keystroke_time)
+    FRAME_DISPLAY_INFO (f)->pending_keystroke_time = 0;
+#endif
+
   if (!x_gtk_use_native_input
       && !FRAME_DISPLAY_INFO (f)->prefer_native_input)
     return true;
@@ -6375,6 +6387,17 @@ xg_widget_key_press_event_cb (GtkWidget *widget, 
GdkEvent *event,
     |= x_x_to_emacs_modifiers (FRAME_DISPLAY_INFO (f), xstate);
   inev.ie.timestamp = event->key.time;
 
+#ifdef HAVE_XINPUT2
+  if (event->key.time == pending_keystroke_time)
+    {
+      source = xi_device_from_id (FRAME_DISPLAY_INFO (f),
+                                 FRAME_DISPLAY_INFO 
(f)->pending_keystroke_source);
+
+      if (source)
+       inev.ie.device = source->name;
+    }
+#endif
+
   if (event->key.is_modifier)
     goto done;
 
diff --git a/src/xterm.c b/src/xterm.c
index 94cfe63ba0..801a964105 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -17379,6 +17379,12 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                  || (x_gtk_use_native_input
                      && x_filter_event (dpyinfo, event)))
                {
+                 /* Try to attribute core key events from the input
+                    method to the input extension event that caused
+                    them.  */
+                 dpyinfo->pending_keystroke_time = xev->time;
+                 dpyinfo->pending_keystroke_source = xev->sourceid;
+
                  *finish = X_EVENT_DROP;
                  goto XI_OTHER;
                }
@@ -17400,6 +17406,12 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                   || dpyinfo->prefer_native_input)
                  && xg_filter_key (any, event))
                {
+                 /* Try to attribute core key events from the input
+                    method to the input extension event that caused
+                    them.  */
+                 dpyinfo->pending_keystroke_time = xev->time;
+                 dpyinfo->pending_keystroke_source = xev->sourceid;
+
                  *finish = X_EVENT_DROP;
                  goto XI_OTHER;
                }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]