1
0
Fork 0
forked from wry/wry

state: add node_at helper

This commit is contained in:
Julian Orth 2025-07-01 08:23:16 +02:00
parent c5b7c44000
commit bae92d90d0
4 changed files with 34 additions and 41 deletions

View file

@ -547,21 +547,11 @@ impl PointerOwner for DndPointerOwner {
fn apply_changes(&self, seat: &Rc<WlSeatGlobal>) {
let (x, y) = seat.pointer_cursor.position();
let (x_int, y_int) = (x.round_down(), y.round_down());
let (node, x_int, y_int) = {
let mut found_tree = seat.found_tree.borrow_mut();
found_tree.push(FoundNode {
node: seat.state.root.clone(),
x: x_int,
y: y_int,
});
seat.state
.root
.node_find_tree_at(x_int, y_int, &mut found_tree, FindTreeUsecase::None);
let FoundNode { node, x, y } = found_tree.pop().unwrap();
found_tree.clear();
(node, x, y)
};
let FoundNode {
node,
x: x_int,
y: y_int,
} = seat.state.node_at(x.round_down(), y.round_down());
let (x, y) = (x.apply_fract(x_int), y.apply_fract(y_int));
let mut target = self.target.get();
if node.node_id() != target.node_id() {

View file

@ -2,7 +2,7 @@ use {
crate::{
fixed::Fixed,
ifs::wl_seat::WlSeatGlobal,
tree::{FindTreeUsecase, FoundNode, Node},
tree::Node,
utils::{clonecell::CloneCell, smallmap::SmallMap},
},
std::rc::Rc,
@ -69,29 +69,14 @@ trait TouchOwner {
impl TouchOwner for DefaultTouchOwner {
fn down(&self, seat: &Rc<WlSeatGlobal>, time_usec: u64, id: i32, x: Fixed, y: Fixed) {
let mut found_tree = seat.found_tree.borrow_mut();
let x_int = x.round_down();
let y_int = y.round_down();
found_tree.push(FoundNode {
node: seat.state.root.clone(),
x: x_int,
y: y_int,
let node = seat.state.node_at(x.round_down(), y.round_down());
node.node.node_seat_state().touch_begin(seat);
let owner = Rc::new(GrabTouchOwner {
node: node.node,
down_ids: Default::default(),
});
seat.state
.root
.node_find_tree_at(x_int, y_int, &mut found_tree, FindTreeUsecase::None);
let node = found_tree.pop();
found_tree.clear();
drop(found_tree);
if let Some(node) = node {
node.node.node_seat_state().touch_begin(seat);
let owner = Rc::new(GrabTouchOwner {
node: node.node,
down_ids: Default::default(),
});
seat.touch_owner.owner.set(owner.clone());
owner.down(seat, time_usec, id, x, y);
}
seat.touch_owner.owner.set(owner.clone());
owner.down(seat, time_usec, id, x, y);
}
fn up(&self, _seat: &Rc<WlSeatGlobal>, _time_usec: u64, _id: i32) {