W2: Wayland: destroy the seat text input only when the seat is removed

Port of rust-windowing/winit#4747 (merged on master).

Originally "M15.1: preserve Wayland winit text input" in storytold/wordcraft#787 (same change as storytold/pdfcraft vendor/winit).
This commit is contained in:
cyfung1031 authored and skylartaylor committed 2026-10-21 18:16:38 +02:00
1 parent b357a33287
commit 13ca693b1e
1 file changed
+10 -5
+10 -5
View File
@@ -158,10 +158,11 @@ impl SeatHandler for WinitState {
},
};
if let Some(text_input) = seat_state.text_input.take() {
text_input.destroy();
}
// WordCraft patch: the text input belongs to the seat, not to a capability, so it is
// destroyed in `remove_seat` instead (rust-windowing/winit#4747). Destroying it here
// whenever any capability went away (a touch screen or tablet unplugged, a remote-desktop
// session ending) left the window without IME until restart: `new_capability` only
// recreates it when a capability is added.
match capability {
SeatCapability::Touch => {
if let Some(touch) = seat_state.touch.take() {
@@ -214,7 +215,11 @@ impl SeatHandler for WinitState {
_queue_handle: &QueueHandle<Self>,
seat: WlSeat,
) {
let _ = self.seats.remove(&seat.id());
if let Some(mut seat_state) = self.seats.remove(&seat.id()) {
if let Some(text_input) = seat_state.text_input.take() {
text_input.destroy();
}
}
self.on_keyboard_destroy(&seat.id());
}
}