Skip to content

Commit

Permalink
tree: implement surface input regions
Browse files Browse the repository at this point in the history
  • Loading branch information
mahkoh committed Mar 4, 2024
1 parent 1006de9 commit 516f8a8
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/ifs/wl_surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ pub struct WlSurface {
visible: Cell<bool>,
role: Cell<SurfaceRole>,
pending: PendingState,
input_region: Cell<Option<Rc<Region>>>,
input_region: CloneCell<Option<Rc<Region>>>,
opaque_region: Cell<Option<Rc<Region>>>,
buffer_points: RefCell<BufferPoints>,
pub buffer_points_norm: RefCell<SampleRect>,
Expand Down Expand Up @@ -894,13 +894,25 @@ impl WlSurface {
Ok(())
}

fn find_surface_at(self: &Rc<Self>, x: i32, y: i32) -> Option<(Rc<Self>, i32, i32)> {
fn accepts_input_at(&self, x: i32, y: i32) -> bool {
let rect = self.buffer_abs_pos.get().at_point(0, 0);
if !rect.contains(x, y) {
return false;
}
if let Some(ir) = self.input_region.get() {
if !ir.contains(x, y) {
return false;
}
}
true
}

fn find_surface_at(self: &Rc<Self>, x: i32, y: i32) -> Option<(Rc<Self>, i32, i32)> {
let children = self.children.borrow();
let children = match children.deref() {
Some(c) => c,
_ => {
return if rect.contains(x, y) {
return if self.accepts_input_at(x, y) {
Some((self.clone(), x, y))
} else {
None
Expand All @@ -925,7 +937,7 @@ impl WlSurface {
if let Some(res) = ss(&children.above) {
return Some(res);
}
if rect.contains(x, y) {
if self.accepts_input_at(x, y) {
return Some((self.clone(), x, y));
}
if let Some(res) = ss(&children.below) {
Expand Down

0 comments on commit 516f8a8

Please sign in to comment.