shell: Allow moving groups between outputs

This commit is contained in:
Victoria Brekenfeld 2024-09-10 20:51:08 +02:00
parent b111c9ff48
commit 03430b76c5
3 changed files with 97 additions and 18 deletions

View file

@ -640,6 +640,7 @@ impl TilingLayout {
seat: &Seat<State>,
focus_stack: impl Iterator<Item = &'a CosmicMapped> + 'a,
desc: NodeDesc,
direction: Option<Direction>,
) -> Option<KeyboardFocusTarget> {
let this_handle = &desc.handle;
let mut this_tree = this.queue.trees.back().unwrap().0.copy_clone();
@ -678,7 +679,7 @@ impl TilingLayout {
}
mapped.set_tiled(true);
other.map(mapped.clone(), Some(focus_stack), None);
other.map(mapped.clone(), Some(focus_stack), direction);
return Some(KeyboardFocusTarget::Element(mapped));
}
None => {
@ -702,7 +703,12 @@ impl TilingLayout {
})
.map(|(id, _)| id)
.unwrap_or(other_tree.root_node_id().unwrap().clone());
let orientation = {
let orientation = if let Some(direction) = direction {
match direction {
Direction::Left | Direction::Right => Orientation::Vertical,
Direction::Up | Direction::Down => Orientation::Horizontal,
}
} else {
let window_size = other_tree
.get(&focused_node)
.unwrap()
@ -718,6 +724,15 @@ impl TilingLayout {
let id = other_tree.insert(node, InsertBehavior::AsRoot).unwrap();
TilingLayout::new_group(&mut other_tree, &focused_node, &id, orientation)
.unwrap();
other_tree
.make_nth_sibling(
&id,
match direction {
Some(Direction::Right) | Some(Direction::Down) => 0,
_ => 1,
},
)
.unwrap();
id
}
};
@ -3762,6 +3777,14 @@ impl TilingLayout {
})
}
pub fn element_for_node(&self, node: &NodeId) -> Option<&CosmicMapped> {
let tree = &self.queue.trees.back().unwrap().0;
tree.get(node).ok().and_then(|node| match node.data() {
Data::Mapped { mapped, .. } => Some(mapped),
_ => None,
})
}
pub fn has_node(&self, node: &NodeId) -> bool {
let tree = &self.queue.trees.back().unwrap().0;
tree.root_node_id()