diff --git a/komorebi/src/border_manager/mod.rs b/komorebi/src/border_manager/mod.rs index ff0d5b19f..51e40fa17 100644 --- a/komorebi/src/border_manager/mod.rs +++ b/komorebi/src/border_manager/mod.rs @@ -181,18 +181,6 @@ pub fn handle_notifications(wm: Arc>) -> color_eyre::Result // Handle the monocle container separately if let Some(monocle) = ws.monocle_container() { - let mut to_remove = vec![]; - for (id, border) in borders.iter() { - if borders_monitors.get(id).copied().unwrap_or_default() == monitor_idx { - border.destroy()?; - to_remove.push(id.clone()); - } - } - - for id in &to_remove { - borders.remove(id); - } - let border = match borders.entry(monocle.id().clone()) { Entry::Occupied(entry) => entry.into_mut(), Entry::Vacant(entry) => { @@ -223,6 +211,21 @@ pub fn handle_notifications(wm: Arc>) -> color_eyre::Result )?; border.update(&rect)?; + + let border_hwnd = border.hwnd; + let mut to_remove = vec![]; + for (id, b) in borders.iter() { + if borders_monitors.get(id).copied().unwrap_or_default() == monitor_idx + && border_hwnd != b.hwnd + { + b.destroy()?; + to_remove.push(id.clone()); + } + } + + for id in &to_remove { + borders.remove(id); + } continue 'monitors; } diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 1428d97f2..2ac3ba71a 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -1297,6 +1297,7 @@ impl WindowManager { if let Ok(focused_workspace) = self.focused_workspace() { if let Some(monocle) = focused_workspace.monocle_container() { if let Some(window) = monocle.focused_window() { + window.focus(self.mouse_follows_focus)?; WindowsApi::center_cursor_in_rect(&WindowsApi::window_rect( window.hwnd(), )?)?; @@ -1756,6 +1757,7 @@ impl WindowManager { for container in workspace.containers_mut() { container.set_stackbar_mode(StackbarMode::Never); + container.hide(None); } Ok(()) @@ -1773,6 +1775,7 @@ impl WindowManager { for container in workspace.containers_mut() { container.set_stackbar_mode(STACKBAR_MODE.load()); + container.restore(); } workspace.reintegrate_monocle_container() diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index 37bb78636..ed1e46033 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -179,6 +179,14 @@ impl Workspace { } pub fn restore(&mut self, mouse_follows_focus: bool) -> Result<()> { + if let Some(container) = self.monocle_container_mut() { + if let Some(window) = container.focused_window() { + container.restore(); + window.focus(mouse_follows_focus)?; + return Ok(()); + } + } + let idx = self.focused_container_idx(); let mut to_focus = None; @@ -196,10 +204,6 @@ impl Workspace { container.restore(); } - if let Some(container) = self.monocle_container_mut() { - container.restore(); - } - for window in self.floating_windows() { window.restore(); }