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
|
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! |
|
Update: Chinese IME works while Japanese IME still causes crash. I'm marking this PR as a draft. |
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.
|
Ready for review. |
|
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. |
|
@acarl005 Hello. If appropriate please review the PR. We are still unable to use CJK IMEs on Warp. |
|
Was this bug reported (or fixed) upstream in rust-windowing/winit? |
Didn't see any. |
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.