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.
This commit is contained in:
LGUG2Z
2025-03-15 13:34:16 -07:00
parent bdea4821c3
commit f0ce8e8572

View File

@@ -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(())