1
0
Fork 0
forked from wry/wry

autocommit 2022-02-14 21:13:42 CET

This commit is contained in:
Julian Orth 2022-02-14 21:13:42 +01:00
parent 9b8e1ac29f
commit da6b29f138
44 changed files with 5903 additions and 364 deletions

View file

@ -1,7 +1,7 @@
use crate::backend::{KeyState, SeatId};
use crate::backend::{KeyState};
use crate::cursor::KnownCursor;
use crate::fixed::Fixed;
use crate::ifs::wl_seat::{NodeSeatState, WlSeatGlobal, BTN_LEFT};
use crate::ifs::wl_seat::{NodeSeatState, WlSeatGlobal, BTN_LEFT, SeatId};
use crate::rect::Rect;
use crate::render::Renderer;
use crate::tree::{FindTreeResult, FoundNode, Node, NodeId, WorkspaceNode};
@ -14,6 +14,7 @@ use std::fmt::{Debug, Formatter};
use std::mem;
use std::ops::DerefMut;
use std::rc::Rc;
use i4config::Direction;
#[allow(dead_code)]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
@ -421,6 +422,52 @@ impl Node for ContainerNode {
self.seat_state.destroy_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_from_child(&self, seat: &Rc<WlSeatGlobal>, child: &dyn Node, direction: Direction) {
let children = self.child_nodes.borrow_mut();
let child = match children.get(&child.id()) {
Some(c) => c,
_ => return,
};
let in_line = match self.split.get() {
ContainerSplit::Horizontal => matches!(direction, Direction::Left | Direction::Right),
ContainerSplit::Vertical => matches!(direction, Direction::Up | Direction::Down),
};
if !in_line {
self.parent.get().move_focus_from_child(seat, self, direction);
return;
}
let prev = match direction {
Direction::Left => true,
Direction::Down => false,
Direction::Up => true,
Direction::Right => false,
};
let sibling = match prev {
true => child.prev(),
false => child.next()
};
let sibling = match sibling {
Some(s) => s,
None => {
self.parent.get().move_focus_from_child(seat, self, direction);
return;
}
};
sibling.node.clone().do_focus(seat, direction);
}
fn absolute_position(&self) -> Rect {
Rect::new_sized(
self.abs_x1.get(),

View file

@ -17,6 +17,7 @@ use std::cell::{Cell, RefCell};
use std::fmt::{Debug, Display, Formatter};
use std::ops::Deref;
use std::rc::Rc;
use i4config::Direction;
pub use workspace::*;
mod container;
@ -66,6 +67,22 @@ pub trait Node {
fn seat_state(&self) -> &NodeSeatState;
fn destroy_node(&self, detach: bool);
fn do_focus(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, direction: Direction) {
let _ = seat;
let _ = direction;
}
fn move_focus(&self, seat: &Rc<WlSeatGlobal>, direction: Direction) {
let _ = seat;
let _ = direction;
}
fn move_focus_from_child(&self, seat: &Rc<WlSeatGlobal>, child: &dyn Node, direction: Direction) {
let _ = seat;
let _ = direction;
let _ = child;
}
fn absolute_position(&self) -> Rect {
Rect::new_empty(0, 0)
}
@ -78,10 +95,14 @@ pub trait Node {
let _ = active;
}
fn key(&self, seat: &WlSeatGlobal, key: u32, state: u32, mods: Option<ModifierState>) {
fn key(&self, seat: &WlSeatGlobal, key: u32, state: u32) {
let _ = seat;
let _ = key;
let _ = state;
}
fn mods(&self, seat: &WlSeatGlobal, mods: ModifierState) {
let _ = seat;
let _ = mods;
}