From 1080159e6896bfffd2fc3782fdd175f5f56aa3f0 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 20 Sep 2024 17:11:17 -0700 Subject: [PATCH] fix(wm): cross-border move direction awareness This commit ensures that when moving across a monitor boundary to the left, a container will be added to the back of the Ring of the target workspace, and when moving across a monitor boundary to the right, that it will be added to the front. --- justfile | 2 ++ komorebi/src/window_manager.rs | 28 ++++++++++++++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/justfile b/justfile index 6c9a7580..cb8961b8 100644 --- a/justfile +++ b/justfile @@ -19,6 +19,8 @@ install-target target: install: just install-target komorebic just install-target komorebic-no-console + just install-target komorebi-gui + just install-target komorebi-bar just install-target komorebi run: diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index f158f081..7ac5c702 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -1424,12 +1424,28 @@ impl WindowManager { // get a mutable ref to the focused workspace on the target monitor let target_workspace = self.focused_workspace_mut()?; - // insert the origin container into the focused workspace on the target monitor - // at the position where the currently focused container on that workspace is - target_workspace.insert_container_at_idx( - target_workspace.focused_container_idx(), - origin_container, - ); + match direction { + OperationDirection::Left => { + // insert the origin container into the focused workspace on the target monitor + // at the back if we are moving across a boundary to the left (back = right side + // of the target) + target_workspace.add_container_to_back(origin_container); + } + OperationDirection::Right => { + // insert the origin container into the focused workspace on the target monitor + // at the front if we are moving across a boundary to the right (front = left side + // of the target) + target_workspace.add_container_to_front(origin_container); + } + OperationDirection::Up | OperationDirection::Down => { + // insert the origin container into the focused workspace on the target monitor + // at the position where the currently focused container on that workspace is + target_workspace.insert_container_at_idx( + target_workspace.focused_container_idx(), + origin_container, + ); + } + }; // if there is only one container on the target workspace after the insertion // it means that there won't be one swapped back, so we have to decrement the