From 405ec8edc22e0e4b0df0c66501b8ff0d689cf96b Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 27 Jul 2021 16:50:50 +0200 Subject: [PATCH] wayland: Forward button press / touch down to Wayland text-input impls These are ClutterInputFocus subclasses, so this will trigger reset of the input method. As the .done event is possibly deferred in the zwp_text_input_v3 implementation, ensure the changes caused by the reset are flushed immediately, before the button press is forwarded to the client by MetaWaylandPointer. Part-of: --- src/wayland/meta-wayland-seat.c | 8 ++++++++ src/wayland/meta-wayland-text-input.c | 10 +++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/wayland/meta-wayland-seat.c b/src/wayland/meta-wayland-seat.c index abc0b4dda..c6390dde7 100644 --- a/src/wayland/meta-wayland-seat.c +++ b/src/wayland/meta-wayland-seat.c @@ -387,6 +387,14 @@ meta_wayland_seat_handle_event (MetaWaylandSeat *seat, !event_from_supported_hardware_device (seat, event)) return FALSE; + if (event->type == CLUTTER_BUTTON_PRESS || + event->type == CLUTTER_TOUCH_BEGIN) + { + meta_wayland_text_input_handle_event (seat->text_input, event); + meta_wayland_gtk_text_input_handle_event (seat->gtk_text_input, + event); + } + switch (event->type) { case CLUTTER_MOTION: diff --git a/src/wayland/meta-wayland-text-input.c b/src/wayland/meta-wayland-text-input.c index b471e8e1a..c892ba752 100644 --- a/src/wayland/meta-wayland-text-input.c +++ b/src/wayland/meta-wayland-text-input.c @@ -753,6 +753,8 @@ gboolean meta_wayland_text_input_handle_event (MetaWaylandTextInput *text_input, const ClutterEvent *event) { + gboolean retval; + if (!text_input->surface || !clutter_input_focus_is_focused (text_input->input_focus)) return FALSE; @@ -762,5 +764,11 @@ meta_wayland_text_input_handle_event (MetaWaylandTextInput *text_input, clutter_event_get_flags (event) & CLUTTER_EVENT_FLAG_INPUT_METHOD) meta_wayland_text_input_focus_flush_done (text_input->input_focus); - return clutter_input_focus_filter_event (text_input->input_focus, event); + retval = clutter_input_focus_filter_event (text_input->input_focus, event); + + if (event->type == CLUTTER_BUTTON_PRESS || + event->type == CLUTTER_TOUCH_BEGIN) + meta_wayland_text_input_focus_flush_done (text_input->input_focus); + + return retval; }