mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-04-23 17:18:40 +02:00
refacor(wm): use helper function on move to workspace
Use the same `add_container_with_direction` function on `move_container_to_workspace` as it is being used on `move_container_to_monitor` or `move_container_in_direction`. This way we bring parity between all methods and make it easier to change the way a container is added on a monitor workspace when taking the move direction into consideration.
This commit is contained in:
@@ -142,7 +142,7 @@ impl Monitor {
|
|||||||
/// Adds a container to this `Monitor` using the move direction to calculate if the container
|
/// Adds a container to this `Monitor` using the move direction to calculate if the container
|
||||||
/// should be added in front of all containers, in the back or in place of the focused
|
/// should be added in front of all containers, in the back or in place of the focused
|
||||||
/// container, moving the rest along. The move direction should be from the origin monitor
|
/// container, moving the rest along. The move direction should be from the origin monitor
|
||||||
/// towards the target monitor.
|
/// towards the target monitor or from the origin workspace towards the target workspace.
|
||||||
pub fn add_container_with_direction(
|
pub fn add_container_with_direction(
|
||||||
&mut self,
|
&mut self,
|
||||||
container: Container,
|
container: Container,
|
||||||
@@ -295,54 +295,14 @@ impl Monitor {
|
|||||||
Some(workspace) => workspace,
|
Some(workspace) => workspace,
|
||||||
};
|
};
|
||||||
|
|
||||||
match direction {
|
if let Some(direction) = direction {
|
||||||
Some(OperationDirection::Left) => match target_workspace.layout() {
|
self.add_container_with_direction(
|
||||||
Layout::Default(layout) => match layout {
|
container,
|
||||||
DefaultLayout::RightMainVerticalStack => {
|
Some(target_workspace_idx),
|
||||||
target_workspace.add_container_to_front(container);
|
direction,
|
||||||
}
|
)?;
|
||||||
DefaultLayout::UltrawideVerticalStack => {
|
} else {
|
||||||
if target_workspace.containers().len() == 1 {
|
target_workspace.add_container_to_back(container);
|
||||||
target_workspace.insert_container_at_idx(0, container);
|
|
||||||
} else {
|
|
||||||
target_workspace.add_container_to_back(container);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
target_workspace.add_container_to_back(container);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Layout::Custom(_) => {
|
|
||||||
target_workspace.add_container_to_back(container);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Some(OperationDirection::Right) => match target_workspace.layout() {
|
|
||||||
Layout::Default(layout) => {
|
|
||||||
let target_index =
|
|
||||||
layout.leftmost_index(target_workspace.containers().len());
|
|
||||||
|
|
||||||
match layout {
|
|
||||||
DefaultLayout::RightMainVerticalStack
|
|
||||||
| DefaultLayout::UltrawideVerticalStack => {
|
|
||||||
if target_workspace.containers().len() == 1 {
|
|
||||||
target_workspace.add_container_to_back(container);
|
|
||||||
} else {
|
|
||||||
target_workspace
|
|
||||||
.insert_container_at_idx(target_index, container);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
target_workspace.insert_container_at_idx(target_index, container);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Layout::Custom(_) => {
|
|
||||||
target_workspace.add_container_to_front(container);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
_ => {
|
|
||||||
target_workspace.add_container_to_back(container);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user