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)) => {}