linux(wayland): proactive text_input enable + fix infinite loop + deduplicate preedit events#17
Open
FurryR wants to merge 2 commits into
Open
linux(wayland): proactive text_input enable + fix infinite loop + deduplicate preedit events#17FurryR wants to merge 2 commits into
FurryR wants to merge 2 commits into
Conversation
Proactive enable (KWin compatibility):
- new_capability: register text_input with existing windows + enable if ime_allowed
- WlKeyboard::enter: send enable+commit on focus entry
- Window::new: pre-populate text_inputs from existing seats
- Enter handler: remove redundant enable+commit to avoid double-activation
Infinite loop fix:
- Only emit Ime::Preedit/Commit when the Done event carries actual content
- A commit-only or empty Done produces no events, breaking the
Preedit("") -> cursor update -> commit -> Done -> Preedit("") cycle
Author
|
I'm not sure if this change should be added to changelog. I'm now working on other issues so it may take a long while for me to respond. If possible you can directly modify CHANGELOG. Thanks for a lot! |
Author
|
Update: Chinese IME works while Japanese IME still causes crash. I'm marking this PR as a draft. |
4 tasks
fcitx5/KWin may send multiple identical done events per keystroke, each carrying the same preedit text. Forwarding all of them floods the application with redundant SetMarkedText dispatches, each triggering a re-render cycle (set_ime_cursor_area + commit) that can overwhelm the compositor. Adds a cached_preedit field to TextInputData. The Done handler now compares the incoming preedit against the last sent value and skips dispatching Ime::Preedit when unchanged, breaking the feedback loop while preserving responsiveness for real changes. Also fixes the missing ZwpTextInputV3Ext import in keyboard/mod.rs.
Author
|
Ready for review. |
Author
|
This seems irrelevant, but after applying the fix, I'm able to use FeatureFlag::ImeMarkedText on Linux (still need cargo run --feature . But after all this is out of my reach. I'm just testing and it works fine. |
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
This PR fixes three issues in the Wayland text-input (IME) handling path in winit:
zwp_text_input_v3.enable()to be sent *before* the compositor deliversenter. Winit now proactively enables text_input in three places: when a new text_input capability appears, whenWlKeyboard::enterfires, and when a new window is created.Ime::Preedit("")wheneverpending_preeditwasNone, creating a feedback loop:Preedit("")→SetMarkedText("")→set_ime_cursor_area→commit()→ another emptydone→ repeat. The fix consumespending_commitandpending_preeditbefore deciding what to emit, emitting nothing when neither is present.doneevents with identical preedit text per keystroke. Forwarding all of them floods the application withSetMarkedTextdispatches, each triggering a re-render +set_ime_cursor_area+commit()that can overwhelm the compositor. Track the last sent preedit and skip when unchanged.Changes
seat/mod.rsnew_capabilitywindow/mod.rstext_inputsfrom existing seats on window creationseat/keyboard/mod.rsenable()+commit()onWlKeyboard::enterseat/text_input/mod.rsenable/commitfromEnterhandler; add dedup tracking toDonehandlerTesting
Tested on KDE Wayland (Manjaro Linux) with fcitx5 IME. Both Chinese (pinyin) and Japanese (mozc) input work correctly with no crash, no infinite loop, and no broken pipe errors.