From ea9752d5e1d85dc62f356a7f3756e928abb3db77 Mon Sep 17 00:00:00 2001 From: alex-ds13 <145657253+alex-ds13@users.noreply.github.com> Date: Mon, 10 Mar 2025 12:03:46 +0000 Subject: [PATCH] fix(wm): focus correct window if monocled stack Previously if we had a stack on a monocle container and tried to cycle stack or move the window within the stack or even using the focus stack window from a bar it would focus the wrong window and temporarely show that wrong window. This commit fixes this. --- komorebi/src/process_command.rs | 3 --- komorebi/src/window_manager.rs | 12 ++++++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 320ff0c4..4b87b3c3 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -331,11 +331,9 @@ impl WindowManager { SocketMessage::UnstackAll => self.unstack_all()?, SocketMessage::CycleStack(direction) => { self.cycle_container_window_in_direction(direction)?; - self.focused_window()?.focus(self.mouse_follows_focus)?; } SocketMessage::CycleStackIndex(direction) => { self.cycle_container_window_index_in_direction(direction)?; - self.focused_window()?.focus(self.mouse_follows_focus)?; } SocketMessage::FocusStackWindow(idx) => { // In case you are using this command on a bar on a monitor @@ -346,7 +344,6 @@ impl WindowManager { self.focus_monitor(monitor_idx)?; } self.focus_container_window(idx)?; - self.focused_window()?.focus(self.mouse_follows_focus)?; } SocketMessage::ForceFocus => { let focused_window = self.focused_window()?; diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 87027694..e790d8a3 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -2535,6 +2535,10 @@ impl WindowManager { container.focus_window(next_idx); 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, true) } @@ -2568,6 +2572,10 @@ impl WindowManager { container.focus_window(next_idx); 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, true) } @@ -2598,6 +2606,10 @@ impl WindowManager { container.focus_window(idx); 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, true) }