From a5909552297ef265ff2c88bc73617c9296860fe5 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Tue, 18 Jan 2022 18:56:26 -0700 Subject: [PATCH] spawning a new tab didn't unfocus current pane This commit centralizes the focus-loss logic to the Window so that activating a new tab will deactivate the pane in the current window. Note that this cannot see overlays in the gui, but overlays shouldn't care about focus, so it should be ok. refs: https://github.com/wez/wezterm/discussions/796 --- mux/src/window.rs | 7 +++++++ wezterm-gui/src/termwindow/mod.rs | 4 ---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/mux/src/window.rs b/mux/src/window.rs index 4c0b9022d..f349fb8d3 100644 --- a/mux/src/window.rs +++ b/mux/src/window.rs @@ -186,6 +186,13 @@ impl Window { /// The saved tab id is not changed. pub fn set_active_without_saving(&mut self, idx: usize) { assert!(idx < self.tabs.len()); + if self.active != idx { + if let Some(tab) = self.tabs.get(self.active) { + if let Some(pane) = tab.get_active_pane() { + pane.focus_changed(false); + } + } + } self.active = idx; self.invalidate(); } diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rs index 49b288b2d..98f975755 100644 --- a/wezterm-gui/src/termwindow/mod.rs +++ b/wezterm-gui/src/termwindow/mod.rs @@ -1606,10 +1606,6 @@ impl TermWindow { } fn activate_tab(&mut self, tab_idx: isize) -> anyhow::Result<()> { - if let Some(tab) = self.get_active_pane_or_overlay() { - tab.focus_changed(false); - } - let mux = Mux::get().unwrap(); let mut window = mux .get_window_mut(self.mux_window_id)