commit 051f514668ff7c412239d6ff44f2077db464aed4 Author: Peng Wu Date: Wed Apr 7 11:16:57 2021 +0800 imwayland: allow some range of serial numbers Some input method like ibus-m17n will send two consecutive events together with two done events. Then the first preedit_string and done request will increase the serial number locally, and send the commit request to mutter. But the second commit_string and done event will be ignored, because the serial number is changed locally. As the the data of text input protocol is sent over network, we can use the technique like the network sliding window protocol, the commit request will increase the window, the done event will shrink the window. Thus we allow some range of serial numbers in the text input protocol. diff --git a/modules/input/imwayland.c b/modules/input/imwayland.c index cf0b1e2144..3b380b8512 100644 --- a/modules/input/imwayland.c +++ b/modules/input/imwayland.c @@ -46,7 +46,8 @@ struct _GtkIMContextWaylandGlobal * so the context may not exist at the time. Same for leave and focus-out. */ gboolean focused; - guint serial; + guint serial_acked; + guint serial_committed; }; struct _GtkIMContextWaylandClass @@ -265,7 +266,8 @@ text_input_done (void *data, if (!global->current) return; - valid = serial == global->serial; + valid = global->serial_acked <= serial && serial <= global->serial_committed; + global->serial_acked = valid ? serial : global->serial_acked; text_input_delete_surrounding_text_apply(global, valid); text_input_commit_apply(global, valid); g_signal_emit_by_name (global->current, "retrieve-surrounding", &result); @@ -461,7 +463,7 @@ commit_state (GtkIMContextWayland *context) return; if (!context->enabled) return; - global->serial++; + global->serial_committed++; zwp_text_input_v3_commit (global->text_input); context->surrounding_change = ZWP_TEXT_INPUT_V3_CHANGE_CAUSE_INPUT_METHOD; } @@ -739,7 +741,8 @@ registry_handle_global (void *data, global->text_input = zwp_text_input_manager_v3_get_text_input (global->text_input_manager, gdk_wayland_seat_get_wl_seat (seat)); - global->serial = 0; + global->serial_acked = 0; + global->serial_committed = 0; zwp_text_input_v3_add_listener (global->text_input, &text_input_listener, global); }