Skip to content

Commit

Permalink
Prevent pending_state from being reset before usage.
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
tarek-y-ismail committed Nov 27, 2024
1 parent 805e206 commit ec03b88
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/server/frontend_wayland/text_input_v1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ms::TextInputState> pending_state;
bool pending_state_used = false;

struct SerialPair
{
Expand Down Expand Up @@ -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;
}
}

Expand All @@ -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)
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit ec03b88

Please sign in to comment.