anvil: implement input region check

This commit is contained in:
Ivan Molodetskikh 2020-01-22 07:45:25 +03:00
parent 9cf5b415c6
commit fd50b45e61
No known key found for this signature in database
GPG Key ID: 02CE38DA47E9D691
1 changed files with 15 additions and 1 deletions

View File

@ -188,5 +188,19 @@ fn contains_point(attrs: &SurfaceAttributes, point: (f64, f64)) -> bool {
width: w, width: w,
height: h, height: h,
}; };
rect.contains((point.0 as i32, point.1 as i32))
let point = (point.0 as i32, point.1 as i32);
// The input region is always within the surface itself, so if the surface itself doesn't contain the
// point we can return false.
if !rect.contains(point) {
return false;
}
// If there's no input region, we're done.
if attrs.input_region.is_none() {
return true;
}
attrs.input_region.as_ref().unwrap().contains(point)
} }