From f0ce8e8572bd1be998de8bab1333a99302078bed Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 15 Mar 2025 13:34:16 -0700 Subject: [PATCH] fix(wm): focus when switching to ws with only floating windows This commit ensures that if a user switches from a workspace with managed windows to a workspace without any managed windows but only floating windows, the focused window from the previous workspace will lose focus as it should, and the first floating window on the new workspace will gain focus as it should. --- komorebi/src/window_manager.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index a6ba1181..0a335834 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -1387,6 +1387,17 @@ impl WindowManager { window.focus(self.mouse_follows_focus)?; } } + + // This is to correctly remove focus from the previous when changing focused workspace + // to a workspace which only contains floating windows and no other kind of managed window + if self.focused_workspace()?.containers().is_empty() + && self.focused_workspace()?.monocle_container().is_none() + && self.focused_workspace()?.maximized_window().is_none() + { + if let Some(window) = self.focused_workspace()?.floating_windows().first() { + window.focus(self.mouse_follows_focus)?; + } + } } Ok(())