Skip to content

Wayland: IME keeps working after a seat loses a capability (winit#4747) - #672

Merged
echelon merged 2 commits into
storytold:mainfrom
cyfung1031:fix/winit-4747-wayland-ime-seat
Oct 10, 2026
Merged

echelon merged 2 commits into
storytold:mainfrom
cyfung1031:fix/winit-4747-wayland-ime-seat

Conversation

@cyfung1031

@cyfung1031 cyfung1031 commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

On Wayland, IME (fcitx5, IBus) stops working in a running PdfCraft after the seat loses any capability, for example when a touch screen or tablet is unplugged or a remote-desktop session (Sunshine) ends, and stays broken until PdfCraft is restarted. This keeps the seat's text input until the seat itself goes away.

Port of rust-windowing/winit#4747 (reviewed head 2060ab0f88) to the vendored winit 0.30.13. It is the same change, applied to 0.30's file layout.

PdfCraft impact

Every egui TextEdit (Search, form fields, the JavaScript console, comments, stamp and signature fields, the command palette) gets IME input on Wayland through winit's zwp_text_input_v3.

Root cause

vendor/winit/src/platform_impl/linux/wayland/seat/mod.rs: SeatHandler::remove_capability destroyed seat_state.text_input whichever capability was removed. The text input comes from zwp_text_input_manager_v3, not from a capability, and new_capability only recreates it when a capability is added. A seat that just loses one is left without a text input for the rest of the session. remove_seat dropped the seat state without destroying its text input.

Change

  • remove_capability no longer touches the text input.
  • remove_seat destroys it with the seat.

Nothing else in seat handling changes (the tablet handling next to it is left as it was, as upstream does).

Not included

Nothing else from winit master.

Verification

  • Upstream reproduced the bug and the fix at protocol level (WAYLAND_DEBUG=1: the unpatched client sends zwp_text_input_v3.destroy on a touch capability removal and never recreates it; the patched one only releases wl_touch) and end to end with fcitx5.
  • Not run here: this machine has no Wayland session. To check by hand: Wayland with fcitx5 or IBus, compose in Search, add then remove a touch or virtual input device (or connect and disconnect a Sunshine client), switch to another app and back, and compose again. Ime::Preedit/Ime::Commit must keep arriving.
  • apps/pdfcraft/tests/winit_wayland_text_input.rs fails if a re-vendored winit destroys the text input in remove_capability again, or stops destroying it in remove_seat.

Automated checks

  • The vendored winit built on its own for aarch64-apple-darwin, x86_64-pc-windows-msvc and x86_64-unknown-linux-musl (cargo clippy --lib, lints capped to warnings): the warnings are the same as on main for all three (the one existing clippy::iter_kv_map in linux/x11/event_processor.rs).
  • cargo check --locked -p winit inside the PdfCraft workspace, with PdfCraft's own Cargo.lock, on macOS and on the tree with all nine fixes merged: clean.
  • The new test was compiled and run against this branch (passes) and against main (fails); rustfmt --check and clippy -D warnings on it are clean.
  • Not run locally: the full cargo test --workspace and workspace clippy (the machine is short of disk space for a full build). CI runs them on Linux and Windows.

Risk

The text input now outlives capability changes, as the protocol intends. Removing the keyboard capability already sends on_keyboard_destroy, which drops the window's focus, so the compositor's text input leave and enter keep following focus.

Revert and removal

This change is independent of the other winit PRs and can be reverted on its own. Drop it, together with the test and README item (2), once PdfCraft uses a winit release that includes rust-windowing/winit#4747 or an equivalent fix.

Merging alongside the other winit PRs

This is one of nine fixes to vendor/winit sent together: #672 (Wayland IME after a capability change), #673 (Windows Korean IME caret), #674 (Windows maximized start-up), #675 (X11 input context focus), #676 (macOS IME commit state), #677 (macOS stale composition), and, building on #676, #678 (macOS emoji picker), #679 (macOS Korean double space), #680 (macOS first Korean key). Each adds one numbered item to the single winit row in vendor/README.md, so they conflict with each other on that one line, and nowhere else (each test is in its own file). The item numbers (2)–(10) are fixed in advance: to resolve, keep every item in numeric order. All nine were merged locally in one tree (only that line conflicted); the combined vendored winit builds for macOS, Windows and Linux with the same clippy output as main, and all nine tests pass on it.

🤖 Generated with Claude Code

winit 0.30.13 destroys a seat's zwp_text_input_v3 in
SeatHandler::remove_capability, whichever capability went away (a touch
screen or tablet unplugged, a remote-desktop session ending), and only
new_capability recreates it. A seat that loses a capability without gaining
one leaves PdfCraft without a text input: IME (fcitx5, IBus) stops working
until PdfCraft is restarted.

The text input belongs to the seat, so vendor/winit now destroys it in
remove_seat only, as rust-windowing/winit#4747 does on winit master. A test
fails if a re-vendored winit loses the patch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@echelon
echelon merged commit 60a0518 into storytold:main Oct 10, 2026
5 checks passed
@echelon

echelon commented Oct 10, 2026

Copy link
Copy Markdown
Member

Merged, thank you! Destroying a seat's text input in remove_seat rather than on capability loss (winit#4747) keeps Wayland IME working. Recorded as winit patch (2).

If you haven't already, come join us on Discord: https://discord.gg/artcraft

krichelj pushed a commit to krichelj/pdfcraft that referenced this pull request Oct 11, 2026
…7) (storytold#672)

winit 0.30.13 destroys a seat's zwp_text_input_v3 in
SeatHandler::remove_capability, whichever capability went away (a touch
screen or tablet unplugged, a remote-desktop session ending), and only
new_capability recreates it. A seat that loses a capability without gaining
one leaves PdfCraft without a text input: IME (fcitx5, IBus) stops working
until PdfCraft is restarted.

The text input belongs to the seat, so vendor/winit now destroys it in
remove_seat only, as rust-windowing/winit#4747 does on winit master. A test
fails if a re-vendored winit loses the patch.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Brandon Thomas <echelon@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants