From 5359f39dcf17e98090385f498f66016ff480b346 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Mon, 31 May 2021 00:11:47 -0700 Subject: [PATCH] mux: fix an issue where auth window would linger before closing Same vein as 8931afba5cee07ab12990f06c2ff34d6f8426b19; the auth window could sometimes get stuck until an input event was sent to it. Wire up a mux event so that the window can close itself. --- mux/src/lib.rs | 2 ++ wezterm-gui/src/frontend.rs | 1 + wezterm-gui/src/termwindow/mod.rs | 8 +++++++- wezterm-mux-server-impl/src/dispatch.rs | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/mux/src/lib.rs b/mux/src/lib.rs index cfac22caf..ce0fa9a99 100644 --- a/mux/src/lib.rs +++ b/mux/src/lib.rs @@ -38,6 +38,7 @@ pub enum MuxNotification { PaneOutput(PaneId), PaneRemoved(PaneId), WindowCreated(WindowId), + WindowRemoved(WindowId), WindowInvalidated(WindowId), Alert { pane_id: PaneId, @@ -411,6 +412,7 @@ impl Mux { for tab in window.iter() { self.remove_tab_internal(tab.tab_id()); } + self.notify(MuxNotification::WindowRemoved(window_id)); } } diff --git a/wezterm-gui/src/frontend.rs b/wezterm-gui/src/frontend.rs index b4a4a06d2..bdb99b5ca 100644 --- a/wezterm-gui/src/frontend.rs +++ b/wezterm-gui/src/frontend.rs @@ -38,6 +38,7 @@ impl GuiFrontEnd { }) .detach(); } + MuxNotification::WindowRemoved(_) => {} MuxNotification::PaneRemoved(_) => {} MuxNotification::WindowInvalidated(_) => {} MuxNotification::PaneOutput(_) => {} diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rs index 0739d9ad1..46aee62c0 100644 --- a/wezterm-gui/src/termwindow/mod.rs +++ b/wezterm-gui/src/termwindow/mod.rs @@ -769,6 +769,11 @@ impl TermWindow { MuxNotification::WindowInvalidated(_) => { window.invalidate(); } + MuxNotification::WindowRemoved(window_id) => { + if window_id == self.mux_window_id { + window.close(); + } + } _ => {} }, TermWindowNotif::EmitStatusUpdate => { @@ -864,7 +869,8 @@ impl TermWindow { } let _ = pane_id; } - MuxNotification::WindowInvalidated(window_id) => { + MuxNotification::WindowRemoved(window_id) + | MuxNotification::WindowInvalidated(window_id) => { if window_id != mux_window_id { return true; } diff --git a/wezterm-mux-server-impl/src/dispatch.rs b/wezterm-mux-server-impl/src/dispatch.rs index 3aa7ef828..9a1683afe 100644 --- a/wezterm-mux-server-impl/src/dispatch.rs +++ b/wezterm-mux-server-impl/src/dispatch.rs @@ -95,6 +95,7 @@ where } handler.schedule_pane_push(pane_id); } + Ok(Item::Notif(MuxNotification::WindowRemoved(_window_id))) => {} Ok(Item::Notif(MuxNotification::WindowCreated(_window_id))) => {} Ok(Item::Notif(MuxNotification::WindowInvalidated(_window_id))) => {} Ok(Item::Notif(MuxNotification::Empty)) => {}