diff options
author | Po Lu <luangruo@yahoo.com> | 2022-04-11 12:25:51 +0800 |
---|---|---|
committer | Po Lu <luangruo@yahoo.com> | 2022-04-11 12:25:51 +0800 |
commit | a6bfc3cb87e91d37e0a7b67e9c68224fb432c989 (patch) | |
tree | d47d67ca75e131eab95e628eec2e96e95fb897ef | |
parent | bdd7cd0d2ee006e95b10ef12151a5ff1bb4f8abd (diff) | |
download | emacs-a6bfc3cb87e91d37e0a7b67e9c68224fb432c989.tar.gz |
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.
-rw-r--r-- | src/gtkutil.c | 23 | ||||
-rw-r--r-- | src/xterm.c | 12 |
2 files changed, 35 insertions, 0 deletions
diff --git a/src/gtkutil.c b/src/gtkutil.c index ec2864e34a7..4fc0edf8ace 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 94cfe63ba0c..801a9641051 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; } |