1
0
Fork 0
forked from wry/wry

autocommit 2022-02-20 22:56:26 CET

This commit is contained in:
Julian Orth 2022-02-20 22:56:26 +01:00
parent a8505be462
commit 7fecc0d1a4
5 changed files with 39 additions and 15 deletions

View file

@ -589,6 +589,14 @@ impl Node for ContainerNode {
}
}
fn is_contained_in(&self, other: NodeId) -> bool {
let parent = self.parent.get();
if parent.id() == other {
return true;
}
parent.is_contained_in(other)
}
fn child_title_changed(self: Rc<Self>, child: &dyn Node, title: &str) {
let child = match self.child_nodes.borrow_mut().get(&child.id()) {
Some(cn) => cn.to_ref(),
@ -621,6 +629,18 @@ impl Node for ContainerNode {
seat.focus_node(self);
}
fn do_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, direction: Direction) {
let node = match direction {
Direction::Left => self.children.last(),
Direction::Down => self.children.first(),
Direction::Up => self.children.last(),
Direction::Right => self.children.first(),
};
if let Some(node) = node {
node.node.clone().do_focus(seat, direction);
}
}
fn move_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, direction: Direction) {
if direction == Direction::Down {
self.do_focus(seat, direction);
@ -635,18 +655,6 @@ impl Node for ContainerNode {
self.parent.get().move_child(self, direction);
}
fn do_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, direction: Direction) {
let node = match direction {
Direction::Left => self.children.last(),
Direction::Down => self.children.first(),
Direction::Up => self.children.last(),
Direction::Right => self.children.first(),
};
if let Some(node) = node {
node.node.clone().do_focus(seat, direction);
}
}
fn move_focus_from_child(
&self,
seat: &Rc<WlSeatGlobal>,

View file

@ -73,6 +73,11 @@ pub trait Node {
fn visit(self: Rc<Self>, visitor: &mut dyn NodeVisitor);
fn visit_children(&self, visitor: &mut dyn NodeVisitor);
fn is_contained_in(&self, other: NodeId) -> bool {
let _ = other;
false
}
fn child_title_changed(self: Rc<Self>, child: &dyn Node, title: &str) {
let _ = child;
let _ = title;