Skip to content

Commit

Permalink
fix(wm): reap monocle and maximized windows
Browse files Browse the repository at this point in the history
This commit updates the orphan reaper to also reap orphan windows in the
monocle container and any tracked maximized windows that no longer
exist.
  • Loading branch information
LGUG2Z committed May 24, 2024
1 parent da7a939 commit 5cff90a
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions komorebi/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,28 @@ impl Workspace {
pub fn reap_orphans(&mut self) -> Result<(usize, usize)> {
let mut hwnds = vec![];
let mut floating_hwnds = vec![];
let mut remove_monocle = false;
let mut remove_maximized = false;

if let Some(monocle) = &self.monocle_container {
let window_count = monocle.windows().len();
let mut orphan_count = 0;
for window in monocle.windows() {
if !window.is_window() {
hwnds.push(window.hwnd);
orphan_count += 1;
}
}

remove_monocle = orphan_count == window_count;
}

if let Some(window) = &self.maximized_window {
if !window.is_window() {
hwnds.push(window.hwnd);
remove_maximized = true;
}
}

for window in self.visible_windows_mut().into_iter().flatten() {
if !window.is_window() {
Expand Down Expand Up @@ -431,6 +453,14 @@ impl Workspace {
self.containers_mut()
.retain(|c| !container_ids.contains(c.id()));

if remove_monocle {
self.set_monocle_container(None);
}

if remove_maximized {
self.set_maximized_window(None);
}

Ok((hwnds.len() + floating_hwnds.len(), container_ids.len()))
}

Expand Down

0 comments on commit 5cff90a

Please sign in to comment.