[mutter/wip/carlosg/committed-and-done: 2/3] wayland: Always update preedit with text_input.done()
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/committed-and-done: 2/3] wayland: Always update preedit with text_input.done()
- Date: Wed, 6 Apr 2022 13:59:08 +0000 (UTC)
commit 1e022778e470c0e7ec95892ef6841f2ffdff7de6
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Apr 6 13:28:46 2022 +0200
wayland: Always update preedit with text_input.done()
Compensate the protocol statelessness with our ClutterInputFocus
statefulness. This becomes more necessary now, since sending
consecutive .done() events is now considered acceptable behavior.
src/wayland/meta-wayland-text-input.c | 24 +++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)
---
diff --git a/src/wayland/meta-wayland-text-input.c b/src/wayland/meta-wayland-text-input.c
index 26d7052dd5..b29c62b87d 100644
--- a/src/wayland/meta-wayland-text-input.c
+++ b/src/wayland/meta-wayland-text-input.c
@@ -73,6 +73,13 @@ struct _MetaWaylandTextInput
uint32_t text_change_cause;
gboolean enabled;
+ struct
+ {
+ char *string;
+ uint32_t cursor;
+ uint32_t anchor;
+ } preedit;
+
guint done_idle_id;
};
@@ -128,6 +135,10 @@ 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);
zwp_text_input_v3_send_done (resource,
lookup_serial (text_input, resource));
}
@@ -233,7 +244,6 @@ meta_wayland_text_input_focus_set_preedit_text (ClutterInputFocus *focus,
guint cursor)
{
MetaWaylandTextInput *text_input;
- struct wl_resource *resource;
gsize pos = 0;
text_input = META_WAYLAND_TEXT_INPUT_FOCUS (focus)->text_input;
@@ -241,10 +251,14 @@ meta_wayland_text_input_focus_set_preedit_text (ClutterInputFocus *focus,
if (text)
pos = g_utf8_offset_to_pointer (text, cursor) - text;
- wl_resource_for_each (resource, &text_input->focus_resource_list)
- {
- zwp_text_input_v3_send_preedit_string (resource, text, pos, pos);
- }
+ g_clear_pointer (&text_input->preedit.string, g_free);
+ text_input->preedit.string = g_strdup (text);
+
+ if (text)
+ pos = g_utf8_offset_to_pointer (text, cursor) - text;
+
+ text_input->preedit.cursor = pos;
+ text_input->preedit.anchor = pos;
meta_wayland_text_input_focus_defer_done (focus);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]