From 6e09d507f9ef7be9f28b823aead9224a85b94950 Mon Sep 17 00:00:00 2001 From: Daniel McNab <36049421+DJMcNab@users.noreply.github.com> Date: Tue, 3 Dec 2024 16:16:56 +0000 Subject: [PATCH 1/2] Stop IME just before shutting down This works around a janky behaviour where IME content is transferred to new instances of the same app --- masonry/src/event_loop_runner.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/masonry/src/event_loop_runner.rs b/masonry/src/event_loop_runner.rs index af7f3a380..022a36e0b 100644 --- a/masonry/src/event_loop_runner.rs +++ b/masonry/src/event_loop_runner.rs @@ -471,7 +471,11 @@ impl MasonryState<'_> { }; accesskit_adapter.update_if_active(|| tree_update); } - WinitWindowEvent::CloseRequested => event_loop.exit(), + WinitWindowEvent::CloseRequested => { + // + window.set_ime_allowed(false); + event_loop.exit(); + } WinitWindowEvent::Resized(size) => { self.render_root .handle_window_event(WindowEvent::Resize(size)); From 0e73030d9bd5c39bc967d54312b4aaf90ba66bd0 Mon Sep 17 00:00:00 2001 From: Daniel McNab <36049421+DJMcNab@users.noreply.github.com> Date: Tue, 3 Dec 2024 16:46:22 +0000 Subject: [PATCH 2/2] Add an explanatory comment --- masonry/src/event_loop_runner.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/masonry/src/event_loop_runner.rs b/masonry/src/event_loop_runner.rs index 022a36e0b..c30efb576 100644 --- a/masonry/src/event_loop_runner.rs +++ b/masonry/src/event_loop_runner.rs @@ -472,7 +472,9 @@ impl MasonryState<'_> { accesskit_adapter.update_if_active(|| tree_update); } WinitWindowEvent::CloseRequested => { - // + // HACK: When we exit, on some systems (known to happen with Wayland on KDE), + // the IME state gets preserved until the app next opens. We work around this by force-deleting + // the IME state just before exiting. window.set_ime_allowed(false); event_loop.exit(); }