From 71c1c16f7b97e2f69746d332fb637a1a4f81d948 Mon Sep 17 00:00:00 2001 From: Robert Lillack Date: Fri, 27 Feb 2026 22:18:53 +0100 Subject: [PATCH] Unfullscreen windows when switching away --- src/canoe/context.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/canoe/context.rs b/src/canoe/context.rs index 682a9d5..7096a50 100644 --- a/src/canoe/context.rs +++ b/src/canoe/context.rs @@ -260,6 +260,35 @@ impl Context { /// Focus a window pub fn focus(&mut self, window_id: WindowId) { + // Unfullscreen any fullscreen window when switching to a different window. + // We cannot rely on self.focused_window here because focus_preview (used + // during alt-tab) may have already changed it. + let fullscreen_ids: Vec = self + .windows + .iter() + .filter_map(|(&id, w)| { + if id != window_id + && !matches!(w.borrow().fullscreen, super::window::FullscreenState::None) + { + Some(id) + } else { + None + } + }) + .collect(); + if !fullscreen_ids.is_empty() { + for fs_id in &fullscreen_ids { + if let Some(window) = self.windows.get(fs_id) { + let mut w = window.borrow_mut(); + w.exit_fullscreen(); + w.pending_unfullscreen_restore = true; + } + } + if let Some(ref rwm) = self.rwm { + rwm.manage_dirty(); + } + } + // Move to front of focus stack self.focus_stack.retain(|&id| id != window_id); self.focus_stack.insert(0, window_id);