From 516f8a8f25eefc3d12457e743646d1332bb5ccd3 Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Mon, 4 Mar 2024 14:54:42 +0100 Subject: [PATCH] tree: implement surface input regions --- src/ifs/wl_surface.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/ifs/wl_surface.rs b/src/ifs/wl_surface.rs index fdc14f55..35f69d5b 100644 --- a/src/ifs/wl_surface.rs +++ b/src/ifs/wl_surface.rs @@ -134,7 +134,7 @@ pub struct WlSurface { visible: Cell, role: Cell, pending: PendingState, - input_region: Cell>>, + input_region: CloneCell>>, opaque_region: Cell>>, buffer_points: RefCell, pub buffer_points_norm: RefCell, @@ -894,13 +894,25 @@ impl WlSurface { Ok(()) } - fn find_surface_at(self: &Rc, x: i32, y: i32) -> Option<(Rc, 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, x: i32, y: i32) -> Option<(Rc, 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 @@ -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) {