From bc04fcb89ddbdaf2b3aa9e3aa3e89477d0e08817 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 7 Jun 2023 12:58:36 +0200 Subject: [PATCH] core: Change MetaWaylandTextInput event forwarding to IMs We need to juggle with some things here to keep key event ordering and accounting consistent. The keyboard internal state changes (and maybe modifier event emission) happening through meta_wayland_seat_update() should ideally happen from the same key events that reach the client through wl_keyboard.key, so that wl_keyboard.modifier events are emitted in the right relative order to other key events. In order to fix this, we need to decide at an earlier point whether the event will get processed through IM (and maybe be reinjected), thus ignored in wait of IM-postprocessed events. This means we pay less attention to whether events are first-hand hardware events for some things and go with the event that does eventually reach to us (hardware or IM). Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5890 Part-of: --- src/core/events.c | 15 +++++++++++++++ src/wayland/meta-wayland-seat.c | 3 --- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/core/events.c b/src/core/events.c index 78720cc41..7107e67c9 100644 --- a/src/core/events.c +++ b/src/core/events.c @@ -226,10 +226,16 @@ meta_display_handle_event (MetaDisplay *display, gboolean has_grab; #ifdef HAVE_WAYLAND MetaWaylandCompositor *wayland_compositor; + MetaWaylandTextInput *wayland_text_input = NULL; #endif #ifdef HAVE_WAYLAND wayland_compositor = meta_context_get_wayland_compositor (context); + if (wayland_compositor) + { + wayland_text_input = + meta_wayland_compositor_get_text_input (wayland_compositor); + } #endif COGL_TRACE_BEGIN_SCOPED (MetaDisplayHandleEvent, @@ -278,6 +284,15 @@ meta_display_handle_event (MetaDisplay *display, } #ifdef HAVE_WAYLAND + if (wayland_text_input && + !has_grab && + !meta_compositor_get_current_window_drag (compositor) && + meta_wayland_text_input_update (wayland_text_input, event)) + { + bypass_wayland = bypass_clutter = TRUE; + goto out; + } + if (wayland_compositor) meta_wayland_compositor_update (wayland_compositor, event); #endif diff --git a/src/wayland/meta-wayland-seat.c b/src/wayland/meta-wayland-seat.c index 8901454de..b673aa6c6 100644 --- a/src/wayland/meta-wayland-seat.c +++ b/src/wayland/meta-wayland-seat.c @@ -384,9 +384,6 @@ meta_wayland_seat_handle_event (MetaWaylandSeat *seat, break; case CLUTTER_KEY_PRESS: case CLUTTER_KEY_RELEASE: - if (meta_wayland_text_input_update (seat->text_input, event)) - return TRUE; - if (meta_wayland_seat_has_keyboard (seat)) return meta_wayland_keyboard_handle_event (seat->keyboard, (const ClutterKeyEvent *) event);