From f361e8032c12a6802358733e4acf3e183277619a Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 30 Apr 2022 13:51:28 +0200 Subject: [PATCH] wayland: Avoid repeated NULL preedit string updates Simply signal preedit string changes from/to NULL once, in order to avoid unwanted activity in the client side. We do still need to send the preedit once each .done event, if there is one, in order to behave according to the protocol when it matters the most. Part-of: --- src/wayland/meta-wayland-text-input.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/wayland/meta-wayland-text-input.c b/src/wayland/meta-wayland-text-input.c index 17e0b683e..cf40f0218 100644 --- a/src/wayland/meta-wayland-text-input.c +++ b/src/wayland/meta-wayland-text-input.c @@ -79,6 +79,7 @@ struct _MetaWaylandTextInput char *string; uint32_t cursor; uint32_t anchor; + gboolean changed; } preedit; guint done_idle_id; @@ -136,10 +137,15 @@ clutter_input_focus_send_done (ClutterInputFocus *focus) wl_resource_for_each (resource, &text_input->focus_resource_list) { - zwp_text_input_v3_send_preedit_string (resource, - text_input->preedit.string, - text_input->preedit.cursor, - text_input->preedit.anchor); + if (text_input->preedit.string || text_input->preedit.changed) + { + zwp_text_input_v3_send_preedit_string (resource, + text_input->preedit.string, + text_input->preedit.cursor, + text_input->preedit.anchor); + text_input->preedit.changed = FALSE; + } + zwp_text_input_v3_send_done (resource, lookup_serial (text_input, resource)); } @@ -260,6 +266,7 @@ meta_wayland_text_input_focus_set_preedit_text (ClutterInputFocus *focus, text_input->preedit.cursor = pos; text_input->preedit.anchor = pos; + text_input->preedit.changed = TRUE; meta_wayland_text_input_focus_defer_done (focus); }