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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2395>
This commit is contained in:
Carlos Garnacho 2022-04-30 13:51:28 +02:00 committed by Marge Bot
parent b1be1e86e9
commit f361e8032c

View File

@ -79,6 +79,7 @@ struct _MetaWaylandTextInput
char *string;
uint32_t cursor;
uint32_t anchor;
gboolean changed;
} preedit;
guint done_idle_id;
@ -135,11 +136,16 @@ clutter_input_focus_send_done (ClutterInputFocus *focus)
text_input = META_WAYLAND_TEXT_INPUT_FOCUS (focus)->text_input;
wl_resource_for_each (resource, &text_input->focus_resource_list)
{
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);
}