From ccde353fb3015941f468acdce66cd0f2b2bd402a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Mon, 13 Jun 2022 10:25:02 +0200 Subject: [PATCH] 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: --- src/wayland/meta-pointer-confinement-wayland.c | 14 +++++++++++++- src/wayland/meta-wayland-surface.c | 11 +++++++++++ src/wayland/meta-wayland-surface.h | 2 ++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/wayland/meta-pointer-confinement-wayland.c b/src/wayland/meta-pointer-confinement-wayland.c index a54faf00c..01c7d3ff3 100644 --- a/src/wayland/meta-pointer-confinement-wayland.c +++ b/src/wayland/meta-pointer-confinement-wayland.c @@ -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); diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c index d7f198a1e..aad2dc35c 100644 --- a/src/wayland/meta-wayland-surface.c +++ b/src/wayland/meta-wayland-surface.c @@ -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); +} diff --git a/src/wayland/meta-wayland-surface.h b/src/wayland/meta-wayland-surface.h index 7986c21ea..54bea9d08 100644 --- a/src/wayland/meta-wayland-surface.h +++ b/src/wayland/meta-wayland-surface.h @@ -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) {