It fixes #2279
Problem
On KWin + fcitx5, after several workspace/focus switches, foot can enter a state where
zwp_text_input_v3 is focused/enabled but no longer receives commit_string events.
At that point input falls back to plain keyboard/XKB path only.
Why this change is protocol-aligned
The text-input-v3 protocol requires re-enabling when focused text input changes, and
defines enable as a state reset point:
- "This request must be issued every time the focused text input changes"
- "This request resets all state associated with previous enable/disable/... state"
So recovering by forcing a fresh disable+enable cycle is consistent with protocol intent
when the IME pipeline gets stuck after focus transitions.
What this patch does
- Add a one-shot
rearm_pendingflag per seat. - Set it on
keyboard_enter, clear it onkeyboard_leave. - On the first post-focus
keyboard_modifiersevent, if IME focus is active:- call
ime_disable() - call
ime_enable() - clear
rearm_pending
- call
This keeps the workaround bounded to one rearm per focus session.
Why this is better than previous behavior
Previously, if KWin/fcitx5 ended up in a non-committing v3 state, foot stayed stuck
until another external state reset happened.
Now foot proactively performs a single local rearm at a stable post-focus point.
Related implementation notes
QtWayland follows a similar enter/leave state model for text-input-v3
(enter -> enable+state update, leave -> disable+commit), and also prefers v2 over v3
on KWin for compatibility reasons.