diff --git a/src/server/frontend_wayland/text_input_v1.cpp b/src/server/frontend_wayland/text_input_v1.cpp index 69eae34b40..9928e11883 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) {