Skip to content

Preserve IME ordering: forwarded key presses create an outstanding re… - #9153

Open
daym wants to merge 1 commit into
swaywm:masterfrom
daym:ime-key-loss-fix
Open

Preserve IME ordering: forwarded key presses create an outstanding re…#9153
daym wants to merge 1 commit into
swaywm:masterfrom
daym:ime-key-loss-fix

Conversation

@daym

@daym daym commented May 18, 2026

Copy link
Copy Markdown

…sponse count; text-input state/done snapshots wait behind those keys; later keys wait behind queued state.

Previously, Sway was letting zwp_input_method_v2.done advance the IM serial while a key already forwarded through zwp_input_method_keyboard_grab_v2.key could still answer with a commit using the older serial. wlroots then (correctly) rejected that commit per protocol.

I had had programs lose some (like 10%) letters I typed when I typed fast. I had suspected my fingers, my keyboard hardware etcetc. But no, it was just an entirely predictable problem with message handling.

This fixes the problem by making Sway preserve the ordering between input-method keyboard grab keys and input-method done events. Forwarded key presses create an outstanding response count. Text-input state updates are snapshotted and queued behind outstanding key presses. If another key arrives while state is queued, the key is queued behind that state, so sequences such as K1, S1, K2, S2 are delivered to the input method as K1, then S1, then K2, then S2. A key response is considered observed when Sway receives either an input_method.commit or a same-client virtual-keyboard key press, which is the observable path used when the input method forwards an unhandled key instead of committing text.

See bug report #9154 , which this fixes.

…sponse count; text-input state/done snapshots wait behind those keys; later keys wait behind queued state.

Previously, Sway was letting zwp_input_method_v2.done advance the IM
serial while a key already forwarded through zwp_input_method_keyboard_grab_v2.key could still answer with a commit using the older serial.  wlroots then rejected that commit per protocol.
@daym
daym force-pushed the ime-key-loss-fix branch from 4e0dfbf to c7ccd0e Compare July 29, 2026 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant