Skip to content

Commit

Permalink
fix(wm): ensure removal of max + monocle windows
Browse files Browse the repository at this point in the history
Previously, the implementation of maximized and monocle windows assumed
that the only valid state for them to transition to would be to restore
them to the index that they were maximized/monocle-d from in their host
workspace.

This is not exclusively the case as it is also possible for them to be
closed when they are in a maximized or monocle state.

This commit updates the Workspace.remove_window() fn to also look for
the hwnd to be removed in the monocle container and maximized window, if
they exist.

fix #19
  • Loading branch information
LGUG2Z committed Aug 24, 2021
1 parent 5094001 commit 05777c3
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions komorebi/src/workspace.rs
Expand Up @@ -329,6 +329,33 @@ impl Workspace {
return Ok(());
}

if let Some(container) = self.monocle_container_mut() {
if let Some(window_idx) = container
.windows()
.iter()
.position(|window| window.hwnd == hwnd)
{
container
.remove_window_by_idx(window_idx)
.ok_or_else(|| anyhow!("there is no window"))?;

if container.windows().is_empty() {
self.set_monocle_container(None);
self.set_monocle_container_restore_idx(None);
}

return Ok(());
}
}

if let Some(window) = self.maximized_window() {
if window.hwnd == hwnd {
self.set_maximized_window(None);
self.set_maximized_window_restore_idx(None);
return Ok(());
}
}

let container_idx = self
.container_idx_for_window(hwnd)
.ok_or_else(|| anyhow!("there is no window"))?;
Expand Down

0 comments on commit 05777c3

Please sign in to comment.