diff --git a/src/wayland/meta-wayland-pointer-constraints.c b/src/wayland/meta-wayland-pointer-constraints.c index 5dc0476d9..e5b0f2c57 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 f3621a944..78c4735a1 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 a153176e7..bc1027646 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