fix(app): discard IME preedit and OS composition on window focus loss#3
Merged
Conversation
A live composition left open across a window focus loss (e.g. Cmd+Tab mid-conversion) kept keyboard_preedit_should_swallow_key returning true after refocus, silently swallowing every keypress until the IME happened to emit another event. Pane-level focus switches already guarded against this (focus_switch_plan), but the window-level Focused(false) path did not. On Focused(false), commit the focused pane's preedit, sync the auto-approve ime_preedit_active guard, drop the window's modal preedit, and toggle set_ime_allowed(false)/true so the AppKit-side marked text is discarded instead of replaying on refocus.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the intermittent "screen looks frozen and keyboard input stops" report. Leaving an IME composition open across a window focus loss (e.g. Cmd+Tab mid-変換) left
preeditnon-empty, sokeyboard_preedit_should_swallow_keyswallowed every keypress after refocus until the IME happened to emit another event. Pane-level focus switches already guarded against this (focus_switch_plan); the window-levelFocused(false)path did not.On
Focused(false), when a pane or modal preedit is active:ime_preedit_activeguardmodal_preeditset_ime_allowed(false)/trueso the AppKit-side marked text is discarded instead of replaying on refocus (same pattern asfocus_pane)Test plan
cargo test -p noa-app: 787 passed (new regression testime_commit_preedit_clears_composition_without_encoding_it)cargo clippy -p noa-app --all-targets: clean