From cb53f463aede382620a991ac9942d94b55bc118d Mon Sep 17 00:00:00 2001 From: alex-ds13 <145657253+alex-ds13@users.noreply.github.com> Date: Thu, 28 Nov 2024 12:50:41 +0000 Subject: [PATCH] fix(wm): avoid workspace load on command move across monitor If the move happens between the already focused workspaces of two monitors we shouldn't load the workspace, since it is already loaded and it will cause changes on focused windows, which might result on the window we just moved not being focused. --- komorebi/src/window_manager.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 4bfcc677..d35afe80 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -1437,8 +1437,12 @@ impl WindowManager { .get_mut(monitor_idx) .ok_or_else(|| anyhow!("there is no monitor"))?; + let mut should_load_workspace = false; if let Some(workspace_idx) = workspace_idx { - target_monitor.focus_workspace(workspace_idx)?; + if workspace_idx != target_monitor.focused_workspace_idx() { + target_monitor.focus_workspace(workspace_idx)?; + should_load_workspace = true; + } } let target_workspace = target_monitor .focused_workspace_mut() @@ -1469,7 +1473,9 @@ impl WindowManager { bail!("failed to find a window to move"); } - target_monitor.load_focused_workspace(mouse_follows_focus)?; + if should_load_workspace { + target_monitor.load_focused_workspace(mouse_follows_focus)?; + } target_monitor.update_focused_workspace(offset)?; // this second one is for DPI changes when the target is another monitor