[mutter] MetaWaylandPointerConstraint: Fix effective region calculation
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] MetaWaylandPointerConstraint: Fix effective region calculation
- Date: Wed, 9 Mar 2016 06:32:25 +0000 (UTC)
commit 62ac9df43d11b166f991f24a58b7a95d4dfdac03
Author: Jonas Ådahl <jadahl gmail com>
Date: Tue Feb 23 21:26:52 2016 +0800
MetaWaylandPointerConstraint: Fix effective region calculation
The when surface->input_region is NULL, it should be interpreted as the
whole surface region. If not, the effective input region is the
intersection of the buffer region and the input region set by
wl_surface.set_input_region. Add
meta_wayland_surface_calculate_input_region() that does this
calculation.
https://bugzilla.gnome.org/show_bug.cgi?id=762661
src/wayland/meta-wayland-pointer-constraints.c | 4 ++--
src/wayland/meta-wayland-surface.c | 23 +++++++++++++++++++++++
src/wayland/meta-wayland-surface.h | 2 ++
3 files changed, 27 insertions(+), 2 deletions(-)
---
diff --git a/src/wayland/meta-wayland-pointer-constraints.c b/src/wayland/meta-wayland-pointer-constraints.c
index 5dc0476..e5b0f2c 100644
--- a/src/wayland/meta-wayland-pointer-constraints.c
+++ b/src/wayland/meta-wayland-pointer-constraints.c
@@ -237,7 +237,7 @@ is_within_constraint_region (MetaWaylandPointerConstraint *constraint,
gboolean is_within;
region = meta_wayland_pointer_constraint_calculate_effective_region (constraint);
- is_within = cairo_region_contains_point (constraint->region,
+ is_within = cairo_region_contains_point (region,
wl_fixed_to_int (sx),
wl_fixed_to_int (sy));
cairo_region_destroy (region);
@@ -330,7 +330,7 @@ meta_wayland_pointer_constraint_calculate_effective_region (MetaWaylandPointerCo
{
cairo_region_t *region;
- region = cairo_region_copy (constraint->surface->input_region);
+ region = meta_wayland_surface_calculate_input_region (constraint->surface);
cairo_region_intersect (region, constraint->region);
return region;
diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
index f3621a9..78c4735 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -2754,3 +2754,26 @@ meta_wayland_surface_role_subsurface_class_init (MetaWaylandSurfaceRoleSubsurfac
surface_role_class->commit = subsurface_surface_commit;
surface_role_class->is_on_output = actor_surface_is_on_output;
}
+
+cairo_region_t *
+meta_wayland_surface_calculate_input_region (MetaWaylandSurface *surface)
+{
+ cairo_region_t *region;
+ cairo_rectangle_int_t buffer_rect;
+ CoglTexture *texture;
+
+ if (!surface->buffer)
+ return NULL;
+
+ texture = surface->buffer->texture;
+ buffer_rect = (cairo_rectangle_int_t) {
+ .width = cogl_texture_get_width (texture) / surface->scale,
+ .height = cogl_texture_get_height (texture) / surface->scale,
+ };
+ region = cairo_region_create_rectangle (&buffer_rect);
+
+ if (surface->input_region)
+ cairo_region_intersect (region, surface->input_region);
+
+ return region;
+}
diff --git a/src/wayland/meta-wayland-surface.h b/src/wayland/meta-wayland-surface.h
index a153176..bc10276 100644
--- a/src/wayland/meta-wayland-surface.h
+++ b/src/wayland/meta-wayland-surface.h
@@ -287,4 +287,6 @@ void meta_wayland_surface_get_absolute_coordinates (MetaWaylandSu
MetaWaylandSurface * meta_wayland_surface_role_get_surface (MetaWaylandSurfaceRole *role);
+cairo_region_t * meta_wayland_surface_calculate_input_region (MetaWaylandSurface *surface);
+
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]