1
0
Fork 0

wayland/pointer-confinement: Scale region with the geometry scale

Without applying the geometry scale, to both the region and the minimum
edge distance, the confinement area becomes too small and offset on
HiDPI setups.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2110
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2460>
This commit is contained in:
Jonas Ådahl 2022-06-13 10:25:02 +02:00 committed by Marge Bot
parent 6d46ffccbc
commit ccde353fb3
3 changed files with 26 additions and 1 deletions

View file

@ -41,6 +41,7 @@
#include "backends/meta-backend-private.h"
#include "backends/meta-pointer-constraint.h"
#include "compositor/region-utils.h"
#include "wayland/meta-wayland-pointer-constraints.h"
#include "wayland/meta-wayland-pointer.h"
#include "wayland/meta-wayland-seat.h"
@ -211,6 +212,7 @@ meta_pointer_confinement_wayland_create_constraint (MetaPointerConfinementWaylan
MetaPointerConstraint *constraint;
MetaWaylandSurface *surface;
cairo_region_t *region;
int geometry_scale;
float dx, dy;
double min_edge_distance;
@ -220,10 +222,20 @@ meta_pointer_confinement_wayland_create_constraint (MetaPointerConfinementWaylan
region =
meta_wayland_pointer_constraint_calculate_effective_region (priv->constraint);
geometry_scale = meta_wayland_surface_get_geometry_scale (surface);
if (geometry_scale != 1)
{
cairo_region_t *scaled_region;
scaled_region = meta_region_scale (region, geometry_scale);
cairo_region_destroy (region);
region = scaled_region;
}
meta_wayland_surface_get_absolute_coordinates (surface, 0, 0, &dx, &dy);
cairo_region_translate (region, dx, dy);
min_edge_distance = wl_fixed_to_double (1);
min_edge_distance = wl_fixed_to_double (1) * geometry_scale;
constraint = meta_pointer_constraint_new (region, min_edge_distance);
cairo_region_destroy (region);

View file

@ -2257,3 +2257,14 @@ meta_wayland_surface_can_scanout_untransformed (MetaWaylandSurface *surface,
return TRUE;
}
int
meta_wayland_surface_get_geometry_scale (MetaWaylandSurface *surface)
{
MetaWaylandActorSurface *actor_surface;
g_return_val_if_fail (META_IS_WAYLAND_ACTOR_SURFACE (surface->role), 1);
actor_surface = META_WAYLAND_ACTOR_SURFACE (surface->role);
return meta_wayland_actor_surface_get_geometry_scale (actor_surface);
}

View file

@ -374,6 +374,8 @@ meta_wayland_surface_can_scanout_untransformed (MetaWaylandSurface *surface,
MetaRendererView *view,
int geometry_scale);
int meta_wayland_surface_get_geometry_scale (MetaWaylandSurface *surface);
static inline GNode *
meta_get_next_subsurface_sibling (GNode *n)
{