tree: allow moving focus between containers on different outputs
This commit is contained in:
parent
f015ee0761
commit
bf8dcd1408
3 changed files with 32 additions and 8 deletions
|
|
@ -1607,7 +1607,7 @@ impl ConfigProxyHandler {
|
||||||
let source_output = self.get_output_node(connector)?;
|
let source_output = self.get_output_node(connector)?;
|
||||||
let connector = self
|
let connector = self
|
||||||
.state
|
.state
|
||||||
.find_connector_in_direction(&source_output, direction.into())
|
.find_output_in_direction(&source_output, direction.into())
|
||||||
.map(|o| Connector(o.global.connector.id.raw() as u64))
|
.map(|o| Connector(o.global.connector.id.raw() as u64))
|
||||||
.unwrap_or(Connector(0));
|
.unwrap_or(Connector(0));
|
||||||
self.respond(Response::GetConnectorInDirection { connector });
|
self.respond(Response::GetConnectorInDirection { connector });
|
||||||
|
|
|
||||||
|
|
@ -1560,11 +1560,15 @@ impl State {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn find_connector_in_direction(
|
pub fn find_output_in_direction(
|
||||||
&self,
|
&self,
|
||||||
source_output: &OutputNode,
|
source_output: &OutputNode,
|
||||||
direction: Direction,
|
direction: Direction,
|
||||||
) -> Option<Rc<OutputNode>> {
|
) -> Option<Rc<OutputNode>> {
|
||||||
|
if source_output.is_dummy {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
let outputs = self.root.outputs.lock();
|
let outputs = self.root.outputs.lock();
|
||||||
|
|
||||||
let ref_box = source_output.global.pos.get();
|
let ref_box = source_output.global.pos.get();
|
||||||
|
|
|
||||||
|
|
@ -976,6 +976,17 @@ impl ContainerNode {
|
||||||
.and_then(|p| p.node_into_container())
|
.and_then(|p| p.node_into_container())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn find_neighboring_output(&self, direction: Direction) -> Option<Rc<OutputNode>> {
|
||||||
|
if self.toplevel_data.parent.is_none() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
if self.toplevel_data.float.is_some() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
self.state
|
||||||
|
.find_output_in_direction(&self.workspace.get().output.get(), direction)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn move_focus_from_child(
|
pub fn move_focus_from_child(
|
||||||
self: Rc<Self>,
|
self: Rc<Self>,
|
||||||
seat: &Rc<WlSeatGlobal>,
|
seat: &Rc<WlSeatGlobal>,
|
||||||
|
|
@ -997,10 +1008,21 @@ impl ContainerNode {
|
||||||
ContainerSplit::Vertical => matches!(direction, Direction::Up | Direction::Down),
|
ContainerSplit::Vertical => matches!(direction, Direction::Up | Direction::Down),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if !in_line {
|
let focus_in_parent = || {
|
||||||
if let Some(c) = self.parent_container() {
|
if let Some(parent) = self.toplevel_data.parent.get() {
|
||||||
c.move_focus_from_child(seat, self.deref(), direction);
|
if let Some(c) = parent.node_into_container() {
|
||||||
|
c.move_focus_from_child(seat, self.deref(), direction);
|
||||||
|
} else if let Some(output) = self.find_neighboring_output(direction)
|
||||||
|
&& let Some(ws) = output.workspace.get()
|
||||||
|
&& let Some(c) = ws.container.get()
|
||||||
|
&& c.node_visible()
|
||||||
|
{
|
||||||
|
c.node_do_focus(seat, direction);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
if !in_line {
|
||||||
|
focus_in_parent();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let prev = match direction {
|
let prev = match direction {
|
||||||
|
|
@ -1017,9 +1039,7 @@ impl ContainerNode {
|
||||||
let sibling = match sibling {
|
let sibling = match sibling {
|
||||||
Some(s) => s,
|
Some(s) => s,
|
||||||
None => {
|
None => {
|
||||||
if let Some(c) = self.parent_container() {
|
focus_in_parent();
|
||||||
c.move_focus_from_child(seat, self.deref(), direction);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue