From e71226b82bd535e0958b9389b08a3562a7967d20 Mon Sep 17 00:00:00 2001 From: Tarek Ismail Date: Wed, 27 Nov 2024 14:56:01 +0200 Subject: [PATCH] Prevent `pending_state` from being reset before usage. For some reason, we get a `reset` request between the state being set and it being used whenever we tab between the interval (number) and the text dropdown field to its right. This caused the pending state to be reset, which would stop the state from being comitted to the text hub handler, keeping the old state (number OSK) on a new field (text dropdown). --- src/server/frontend_wayland/text_input_v1.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/server/frontend_wayland/text_input_v1.cpp b/src/server/frontend_wayland/text_input_v1.cpp index 788f703db4..d19931e2d6 100644 --- a/src/server/frontend_wayland/text_input_v1.cpp +++ b/src/server/frontend_wayland/text_input_v1.cpp @@ -173,6 +173,7 @@ class TextInputV1 bool on_new_input_field{false}; /// nullopt if the state is inactive, otherwise holds the pending and/or committed state std::optional pending_state; + bool pending_state_used = false; struct SerialPair { @@ -361,6 +362,7 @@ void TextInputV1::activate(wl_resource *seat_resource, wl_resource *surface) { on_new_input_field = true; pending_state.emplace(); + pending_state_used = false; } } @@ -386,7 +388,8 @@ void TextInputV1::hide_input_panel() void TextInputV1::reset() { - pending_state.reset(); + if(pending_state_used) + pending_state.reset(); } void TextInputV1::set_surrounding_text(const std::string &text, uint32_t cursor, uint32_t anchor) @@ -427,6 +430,7 @@ void TextInputV1::commit_state(uint32_t client_serial) if (pending_state && current_surface) { auto const hub_serial = ctx->text_input_hub->set_handler_state(handler, on_new_input_field, *pending_state); + pending_state_used = true; state_serials.push_back({client_serial, hub_serial}); while (state_serials.size() > max_remembered_serials) {