diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2018-10-10 23:39:40 +0200 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2018-10-11 00:35:40 +0200 |
commit | 02fb433a48e7db5a64d3364e57db7be4aae9f75c (patch) | |
tree | 67b6039cae534d30a0926fef830a8ff71d6f22e3 | |
parent | 955aa8d54b1ef6b9252e06b19d1d42a971c2b409 (diff) | |
download | gtk+-wip/carlosg/imwayland-serials.tar.gz |
imwayland: Use serial to prevent redundant outbound changeswip/carlosg/imwayland-serials
The serial was being used to silence away changes introduced by previous
commit calls. However the text_input protocol reads:
"When the client receives a done event with a serial different than the
number of past commit requests, it must proceed as normal, except it
should not change the current state of the zwp_text_input_v3 object."
It makes more sense to prevent the changes on the zwp_text_input object
itself, as those would be made redundant by more recent events. But the
effects of the .done calls should still take place.
Closes: https://gitlab.gnome.org/GNOME/gtk/issues/1365
-rw-r--r-- | modules/input/imwayland.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/modules/input/imwayland.c b/modules/input/imwayland.c index 05e8c0c3d7..f4eb527070 100644 --- a/modules/input/imwayland.c +++ b/modules/input/imwayland.c @@ -43,6 +43,7 @@ struct _GtkIMContextWaylandGlobal GtkIMContext *current; guint serial; + guint server_serial; }; struct _GtkIMContextWaylandClass @@ -207,11 +208,11 @@ text_input_commit (void *data, } static void -text_input_commit_apply (GtkIMContextWaylandGlobal *global, gboolean valid) +text_input_commit_apply (GtkIMContextWaylandGlobal *global) { GtkIMContextWayland *context; context = GTK_IM_CONTEXT_WAYLAND (global->current); - if (context->pending_commit && valid) + if (context->pending_commit) g_signal_emit_by_name (global->current, "commit", context->pending_commit); g_free (context->pending_commit); context->pending_commit = NULL; @@ -236,8 +237,7 @@ text_input_delete_surrounding_text (void *data, } static void -text_input_delete_surrounding_text_apply (GtkIMContextWaylandGlobal *global, - gboolean valid) +text_input_delete_surrounding_text_apply (GtkIMContextWaylandGlobal *global) { GtkIMContextWayland *context; gboolean retval; @@ -248,7 +248,7 @@ text_input_delete_surrounding_text_apply (GtkIMContextWaylandGlobal *global, len = context->pending_surrounding_delete.after_length + context->pending_surrounding_delete.before_length; - if (len > 0 && valid) + if (len > 0) g_signal_emit_by_name (global->current, "delete-surrounding", -context->pending_surrounding_delete.before_length, len, &retval); @@ -262,16 +262,16 @@ text_input_done (void *data, { GtkIMContextWaylandGlobal *global = data; gboolean result; - gboolean valid; - + + global->server_serial = serial; + if (!global->current) return; - valid = serial == global->serial; - text_input_delete_surrounding_text_apply(global, valid); - text_input_commit_apply(global, valid); + text_input_delete_surrounding_text_apply (global); + text_input_commit_apply (global); g_signal_emit_by_name (global->current, "retrieve-surrounding", &result); - text_input_preedit_apply(global); + text_input_preedit_apply (global); } static const struct zwp_text_input_v3_listener text_input_listener = { @@ -348,6 +348,8 @@ notify_surrounding_text (GtkIMContextWayland *context) return; if (!context->surrounding.text) return; + if (global->server_serial != global->serial) + return; zwp_text_input_v3_set_surrounding_text (global->text_input, context->surrounding.text, @@ -368,6 +370,8 @@ notify_cursor_location (GtkIMContextWayland *context) return; if (!context->window) return; + if (global->server_serial != global->serial) + return; rect = context->cursor_rect; gdk_window_get_root_coords (context->window, rect.x, rect.y, @@ -445,6 +449,8 @@ notify_content_type (GtkIMContextWayland *context) if (global->current != GTK_IM_CONTEXT (context)) return; + if (global->server_serial != global->serial) + return; g_object_get (context, "input-hints", &hints, |