autocommit 2022-02-20 22:56:26 CET
This commit is contained in:
parent
a8505be462
commit
7fecc0d1a4
5 changed files with 39 additions and 15 deletions
|
|
@ -189,9 +189,10 @@ impl WlSeatGlobal {
|
|||
self.pointer_stack.borrow().last().cloned()
|
||||
}
|
||||
|
||||
pub fn last_tiled_keyboard_toplevel(&self) -> Option<Rc<XdgToplevel>> {
|
||||
pub fn last_tiled_keyboard_toplevel(&self, new: &dyn Node) -> Option<Rc<XdgToplevel>> {
|
||||
let is_container = new.is_container();
|
||||
for tl in self.toplevel_focus_history.rev_iter() {
|
||||
if !tl.parent_is_float() {
|
||||
if !tl.parent_is_float() && (!is_container || !tl.is_contained_in(new.id())) {
|
||||
return Some(tl.deref().clone());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -417,6 +417,16 @@ impl Node for XdgToplevel {
|
|||
visitor.visit_surface(&self.xdg.surface);
|
||||
}
|
||||
|
||||
fn is_contained_in(&self, other: NodeId) -> bool {
|
||||
if let Some(parent) = self.parent_node.get() {
|
||||
if parent.id() == other {
|
||||
return true;
|
||||
}
|
||||
return parent.is_contained_in(other);
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
fn do_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, _direction: Direction) {
|
||||
seat.focus_toplevel(&self);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ impl State {
|
|||
pub fn map_tiled(self: &Rc<Self>, node: Rc<dyn Node>) {
|
||||
let seat = self.seat_queue.last();
|
||||
if let Some(seat) = seat {
|
||||
if let Some(prev) = seat.last_tiled_keyboard_toplevel() {
|
||||
if let Some(prev) = seat.last_tiled_keyboard_toplevel(&*node) {
|
||||
if let Some(container) = prev.parent_node.get() {
|
||||
if let Some(container) = container.into_container() {
|
||||
container.add_child_after(&*prev, node);
|
||||
|
|
|
|||
|
|
@ -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>,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue