[gtk/wip/carlosg/im-wayland-serials] WIP: gtk/imwayland: Use serial to control outbound messages
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/carlosg/im-wayland-serials] WIP: gtk/imwayland: Use serial to control outbound messages
- Date: Tue, 18 Jan 2022 22:44:21 +0000 (UTC)
commit 4b960f9fd6258d9cee555f7d2c9d0173de39b3ae
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Jan 18 23:31:09 2022 +0100
WIP: gtk/imwayland: Use serial to control outbound messages
Following the text-input protocol changes at
https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/115,
use the serial number to have the client push changes to the
zwp_text_input_v3 object only after compositor/client states match.
This specifically is more lenient to compositors pushing multiple
.done events ahead of the client replying to them.
Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3641
gtk/gtkimcontextwayland.c | 28 +++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)
---
diff --git a/gtk/gtkimcontextwayland.c b/gtk/gtkimcontextwayland.c
index 8b372d048f..7384b45386 100644
--- a/gtk/gtkimcontextwayland.c
+++ b/gtk/gtkimcontextwayland.c
@@ -48,6 +48,7 @@ struct _GtkIMContextWaylandGlobal
gboolean focused;
guint serial;
+ guint done_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->done_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 void
@@ -288,6 +288,8 @@ notify_surrounding_text (GtkIMContextWayland *context)
global = gtk_im_context_wayland_get_global (context);
if (global == NULL)
return;
+ if (global->done_serial != global->serial)
+ return;
len = strlen (context->surrounding.text);
cursor = context->surrounding.cursor_idx;
@@ -362,6 +364,8 @@ notify_cursor_location (GtkIMContextWayland *context)
global = gtk_im_context_wayland_get_global (context);
if (global == NULL)
return;
+ if (global->done_serial != global->serial)
+ return;
rect = context->cursor_rect;
gtk_widget_translate_coordinates (context->widget,
@@ -449,6 +453,8 @@ notify_content_type (GtkIMContextWayland *context)
global = gtk_im_context_wayland_get_global (context);
if (global == NULL)
return;
+ if (global->done_serial != global->serial)
+ return;
g_object_get (context,
"input-hints", &hints,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]