From 1b30561989e79beccac5ed459eca53912268d914 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 11 May 2024 16:47:42 -0700 Subject: [PATCH] fix(wm): update focused idx on cross-monitor moves This commit ensures that in situations where the last container on a monitor is moved to an adjacent monitor, the focused container index of the origin monitor will be appropriately decremented. --- komorebi/src/window_manager.rs | 2 ++ komorebi/src/workspace.rs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 860067b3..6ac5dc35 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -1366,6 +1366,8 @@ impl WindowManager { anyhow!("could not remove container at given origin index") })?; + self.focused_workspace_mut()?.focus_previous_container(); + // focus the target monitor self.focus_monitor(target_monitor_idx)?; diff --git a/komorebi/src/workspace.rs b/komorebi/src/workspace.rs index 1fb139a1..6b09b41e 100644 --- a/komorebi/src/workspace.rs +++ b/komorebi/src/workspace.rs @@ -1376,7 +1376,7 @@ impl Workspace { vec } - fn focus_previous_container(&mut self) { + pub fn focus_previous_container(&mut self) { let focused_idx = self.focused_container_idx(); if focused_idx != 0 {