Merge pull request #121 from mahkoh/jorth/input-region
tree: implement surface input regions
This commit is contained in:
commit
1540b4e90f
7 changed files with 58 additions and 33 deletions
|
|
@ -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>,
|
||||
|
|
@ -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
|
||||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -322,6 +322,10 @@ impl Node for Xwindow {
|
|||
seat.focus_toplevel(self.clone());
|
||||
}
|
||||
|
||||
fn node_active_changed(&self, active: bool) {
|
||||
self.toplevel_data.update_self_active(self, active);
|
||||
}
|
||||
|
||||
fn node_find_tree_at(&self, x: i32, y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
let rect = self.x.surface.buffer_abs_pos.get();
|
||||
if x < rect.width() && y < rect.height() {
|
||||
|
|
|
|||
|
|
@ -511,6 +511,10 @@ impl Node for XdgToplevel {
|
|||
seat.focus_toplevel(self.clone());
|
||||
}
|
||||
|
||||
fn node_active_changed(&self, active: bool) {
|
||||
self.toplevel_data.update_self_active(self, active);
|
||||
}
|
||||
|
||||
fn node_find_tree_at(&self, x: i32, y: i32, tree: &mut Vec<FoundNode>) -> FindTreeResult {
|
||||
self.xdg.find_tree_at(x, y, tree)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue