Skip to content

Commit

Permalink
fix(wm): cross-border move direction awareness
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
LGUG2Z committed Sep 21, 2024
1 parent 360d091 commit 1080159
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
2 changes: 2 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
28 changes: 22 additions & 6 deletions komorebi/src/window_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1080159

Please sign in to comment.