From 626c1dce02d4f2e8d0822decf8b421eee00674b1 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Thu, 13 Jan 2022 17:56:55 +0800 Subject: [PATCH] Filter key release events through GTK when using native input * src/gtkutil.c (xg_filter_key): Set correct event type for key release events. * src/xterm.c (x_filter_event): Also filter release events. --- src/gtkutil.c | 7 ++++++- src/xterm.c | 6 ++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/gtkutil.c b/src/gtkutil.c index 7f635f8fe2b..36ed55bc039 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c @@ -6262,7 +6262,12 @@ xg_widget_key_press_event_cb (GtkWidget *widget, GdkEvent *event, bool xg_filter_key (struct frame *frame, XEvent *xkey) { - GdkEvent *xg_event = gdk_event_new (GDK_KEY_PRESS); + GdkEvent *xg_event = gdk_event_new ((xkey->type == ButtonPress +#ifdef HAVE_XINPUT2 + || (xkey->type == GenericEvent + && xkey->xgeneric.evtype == XI_KeyPress) +#endif + ) ? GDK_KEY_PRESS : GDK_KEY_RELEASE); GdkDisplay *dpy = gtk_widget_get_display (FRAME_GTK_WIDGET (frame)); GdkKeymap *keymap = gdk_keymap_get_for_display (dpy); GdkModifierType consumed; diff --git a/src/xterm.c b/src/xterm.c index 058c1dccc22..34097ebfd94 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -8284,8 +8284,10 @@ x_filter_event (struct x_display_info *dpyinfo, XEvent *event) && event->type == GenericEvent && (event->xgeneric.extension == dpyinfo->xi2_opcode) - && (event->xgeneric.evtype - == XI_KeyPress)) + && ((event->xgeneric.evtype + == XI_KeyPress) + || (event->xgeneric.evtype + == XI_KeyRelease))) { f1 = x_any_window_to_frame (dpyinfo, ((XIDeviceEvent *) -- 2.39.2