diff --git a/src/config/handler.rs b/src/config/handler.rs index fa2da799..492eb358 100644 --- a/src/config/handler.rs +++ b/src/config/handler.rs @@ -1607,7 +1607,7 @@ impl ConfigProxyHandler { let source_output = self.get_output_node(connector)?; let connector = self .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)) .unwrap_or(Connector(0)); self.respond(Response::GetConnectorInDirection { connector }); diff --git a/src/state.rs b/src/state.rs index 23ccbd18..4a95b242 100644 --- a/src/state.rs +++ b/src/state.rs @@ -1560,11 +1560,15 @@ impl State { } } - pub fn find_connector_in_direction( + pub fn find_output_in_direction( &self, source_output: &OutputNode, direction: Direction, ) -> Option> { + if source_output.is_dummy { + return None; + } + let outputs = self.root.outputs.lock(); let ref_box = source_output.global.pos.get(); diff --git a/src/tree/container.rs b/src/tree/container.rs index c2df4a3b..e4a6652d 100644 --- a/src/tree/container.rs +++ b/src/tree/container.rs @@ -976,6 +976,17 @@ impl ContainerNode { .and_then(|p| p.node_into_container()) } + fn find_neighboring_output(&self, direction: Direction) -> Option> { + 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( self: Rc, seat: &Rc, @@ -997,10 +1008,21 @@ impl ContainerNode { ContainerSplit::Vertical => matches!(direction, Direction::Up | Direction::Down), } }; - if !in_line { - if let Some(c) = self.parent_container() { - c.move_focus_from_child(seat, self.deref(), direction); + let focus_in_parent = || { + if let Some(parent) = self.toplevel_data.parent.get() { + 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; } let prev = match direction { @@ -1017,9 +1039,7 @@ impl ContainerNode { let sibling = match sibling { Some(s) => s, None => { - if let Some(c) = self.parent_container() { - c.move_focus_from_child(seat, self.deref(), direction); - } + focus_in_parent(); return; } };