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<Container> of
the target workspace, and when moving across a monitor boundary to the
right, that it will be added to the front.
This commit is contained in:
LGUG2Z
2024-09-20 17:11:17 -07:00
parent 360d0915a1
commit 1080159e68
2 changed files with 24 additions and 6 deletions

View File

@@ -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:

View File

@@ -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