From 6e7f42be87128ccbd985a24796c9ff23784b4d1b Mon Sep 17 00:00:00 2001 From: alex-ds13 <145657253+alex-ds13@users.noreply.github.com> Date: Wed, 26 Feb 2025 13:17:03 +0000 Subject: [PATCH] fix(wm): allow stacking in all dirs, improve stack border rendering Previously the stacking logic would sometimes change the focused container without actually changing focus to said container. This resulted in the stack showing up with an unfocused border even though we had focus on one windows belonging to the stack (just not the right one). Also before it wasn't possible to stack windows on some directions when we were already on a stack. This commit fixes both issues. --- komorebi/src/window_manager.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index ea3c884d..074bca64 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -2681,12 +2681,16 @@ impl WindowManager { anyhow!("this is not a valid direction from the current position") })?; + let mut changed_focus = false; + let adjusted_new_index = if new_idx > current_container_idx && !matches!( workspace.layout(), Layout::Default(DefaultLayout::Grid) | Layout::Default(DefaultLayout::UltrawideVerticalStack) ) { + workspace.focus_container(new_idx); + changed_focus = true; new_idx.saturating_sub(1) } else { new_idx @@ -2703,12 +2707,22 @@ impl WindowManager { if let Some(current) = workspace.focused_container() { if current.windows().len() > 1 && !target_container_is_stack { workspace.focus_container(adjusted_new_index); + changed_focus = true; workspace.move_window_to_container(current_container_idx)?; } else { workspace.move_window_to_container(adjusted_new_index)?; } } + if changed_focus { + if let Some(container) = workspace.focused_container_mut() { + container.load_focused_window(); + if let Some(window) = container.focused_window() { + window.focus(self.mouse_follows_focus)?; + } + } + } + self.update_focused_workspace(self.mouse_follows_focus, false)?; }