From d001d8a7a67e4e3e7581bec25cfe2918a0ff42cc Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 19 Nov 2024 19:01:35 -0800 Subject: [PATCH] fix(wm): ensure focus restore on float + max hwnds This commit ensures that when switching to a workspace which contains a floating window or a maximized window, either the maximized window or the first floating window index will be focused. This is to prevent windows which have been hidden on the previous workspace from retaining keyboard focus. fix #1130 --- komorebi/src/workspace.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index d12de5dc..b47ffc39 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -246,6 +246,10 @@ impl Workspace { if let Some(window) = to_focus { if self.maximized_window().is_none() && self.floating_windows().is_empty() { window.focus(mouse_follows_focus)?; + } else if let Some(maximized_window) = self.maximized_window() { + maximized_window.focus(mouse_follows_focus)?; + } else if let Some(floating_window) = self.floating_windows().first() { + floating_window.focus(mouse_follows_focus)?; } }