From 83f222fe8465e9dd0ceae614ade1c62fe869c0c3 Mon Sep 17 00:00:00 2001 From: alex-ds13 <145657253+alex-ds13@users.noreply.github.com> Date: Thu, 28 Nov 2024 11:13:39 +0000 Subject: [PATCH] fix(wm): correctly define moves across monitors Moves within the same workspace were being considered as moves across monitors when the workspace was floating (not tiled). This commit fixes this by changing the way we first define if a move was across monitor or not. We now search for the moved window on all workspaces and check if its monitor index is different from the target monitor index (the monitor where the move ended). --- komorebi/src/process_event.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index 128cc053..5b428707 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -485,8 +485,21 @@ impl WindowManager { // place across a monitor boundary to an empty workspace .unwrap_or(&Rect::default()); - // This will be true if we have moved to an empty workspace on another monitor - let mut moved_across_monitors = old_position == Rect::default(); + // This will be true if we have moved to another monitor + let mut moved_across_monitors = false; + + for (i, monitors) in self.monitors().iter().enumerate() { + for workspace in monitors.workspaces() { + if workspace.contains_window(window.hwnd) && i != target_monitor_idx { + moved_across_monitors = true; + break; + } + } + if moved_across_monitors { + break; + } + } + if let Some((origin_monitor_idx, origin_workspace_idx, _)) = pending { // If we didn't move to another monitor with an empty workspace, it is // still possible that we moved to another monitor with a populated workspace