fix(wm): check exhaustively for ws emptiness

This commit creates a new function for the workspaces to check if they
are empty or not.

This function properly accounts for maximized windows, monocle windows
and floating windows.

This should fix the cases where the WM was checking if the workspace was
empty to focus the desktop in order to loose focus from previously
focused window.

Previously it wasn't checking for floating windows so it cause continues
focus flickering when there were only floating windows on the workspace.
This commit is contained in:
alex-ds13
2024-10-10 15:48:23 +01:00
committed by LGUG2Z
parent a03a483185
commit 0b7d5a89b7
2 changed files with 8 additions and 1 deletions

View File

@@ -852,7 +852,7 @@ impl WindowManager {
}
}
} else {
if self.focused_workspace()?.containers().is_empty() {
if self.focused_workspace()?.is_empty() {
let desktop_window = Window::from(WindowsApi::desktop_window()?);
match WindowsApi::raise_and_focus_window(desktop_window.hwnd) {

View File

@@ -597,6 +597,13 @@ impl Workspace {
Ok(false)
}
pub fn is_empty(&self) -> bool {
self.containers().is_empty()
&& self.maximized_window().is_none()
&& self.monocle_container().is_none()
&& self.floating_windows().is_empty()
}
pub fn contains_window(&self, hwnd: isize) -> bool {
for container in self.containers() {
if container.contains_window(hwnd) {