diff --git a/src/platform_impl/linux/wayland/seat/mod.rs b/src/platform_impl/linux/wayland/seat/mod.rs index eaecd93b..a9f9b62b 100644 --- a/src/platform_impl/linux/wayland/seat/mod.rs +++ b/src/platform_impl/linux/wayland/seat/mod.rs @@ -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, 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()); } }