]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix IM event source attribution on GTK
authorPo Lu <luangruo@yahoo.com>
Mon, 11 Apr 2022 04:25:51 +0000 (12:25 +0800)
committerPo Lu <luangruo@yahoo.com>
Mon, 11 Apr 2022 04:25:51 +0000 (12:25 +0800)
* 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
src/xterm.c

index ec2864e34a7032151e9bfa7e2973fd0511cc9f45..4fc0edf8ace83d77d60750d9c9b0a9bab0c91ae7 100644 (file)
@@ -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;
 
index 94cfe63ba0cae62cf36ac1c5d61f3d72c60610ff..801a9641051b06937e4c979de8755b0002fc8bf0 100644 (file)
@@ -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;
                }