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
This commit is contained in:
parent
0882bce989
commit
62ac9df43d
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user