diff options
author | Matthias Clasen <mclasen@redhat.com> | 2023-04-02 18:09:26 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2023-04-02 18:09:26 +0000 |
commit | def6a78c8825088e7993a47752bc8c49304c8bd9 (patch) | |
tree | 9ad282a9efc6596d049b061450bdca629809e2a3 | |
parent | 80ccfd2138a002714add7432d4998dcafd8f01d5 (diff) | |
parent | 5e95c2284451f646ec6fd3ae286848d08f2b01f8 (diff) | |
download | gtk+-def6a78c8825088e7993a47752bc8c49304c8bd9.tar.gz |
Merge branch 'scale-factor-cleanup' into 'main'
wayland: Be more careful about scale-factor
See merge request GNOME/gtk!5775
-rw-r--r-- | gdk/gdksurface.c | 12 | ||||
-rw-r--r-- | gdk/wayland/gdksurface-wayland.c | 10 |
2 files changed, 16 insertions, 6 deletions
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c index b7e285f2ae..7120da78db 100644 --- a/gdk/gdksurface.c +++ b/gdk/gdksurface.c @@ -572,6 +572,9 @@ gdk_surface_class_init (GdkSurfaceClass *klass) * GdkSurface:scale-factor: (attributes org.gtk.Property.get=gdk_surface_get_scale_factor) * * The scale factor of the surface. + * + * The scale factor is the next larger integer, + * compared to [property@Gdk.Surface:scale]. */ properties[PROP_SCALE_FACTOR] = g_param_spec_int ("scale-factor", NULL, NULL, @@ -2622,7 +2625,7 @@ gdk_surface_get_frame_clock (GdkSurface *surface) * pixel-based data the scale value can be used to determine whether to * use a pixel resource with higher resolution data. * - * The scale may change during the lifetime of the surface. + * The scale factor may change during the lifetime of the surface. * * Returns: the scale factor */ @@ -2641,6 +2644,13 @@ gdk_surface_get_scale_factor (GdkSurface *surface) * Returns the internal scale that maps from surface coordinates * to the actual device pixels. * + * When the scale is bigger than 1, the windowing system prefers to get + * buffers with a resolution that is bigger than the surface size (e.g. + * to show the surface on a high-resolution display, or in a magnifier). + * + * Compare with [method@Gdk.Surface.get_scale_factor], which returns the + * next larger integer. + * * The scale may change during the lifetime of the surface. * * Returns: the scale diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c index ca27f65373..0cebc00474 100644 --- a/gdk/wayland/gdksurface-wayland.c +++ b/gdk/wayland/gdksurface-wayland.c @@ -261,11 +261,12 @@ gdk_wayland_surface_update_size (GdkSurface *surface, const GdkFractionalScale *scale) { GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface); - gboolean width_changed, height_changed, scale_changed; + gboolean width_changed, height_changed, scale_changed, scale_factor_changed; width_changed = surface->width != width; height_changed = surface->height != height; scale_changed = !gdk_fractional_scale_equal (&impl->scale, scale); + scale_factor_changed = gdk_fractional_scale_to_int (&impl->scale) != gdk_fractional_scale_to_int (scale); if (!width_changed && !height_changed && !scale_changed) return; @@ -295,10 +296,9 @@ gdk_wayland_surface_update_size (GdkSurface *surface, if (height_changed) g_object_notify (G_OBJECT (surface), "height"); if (scale_changed) - { - g_object_notify (G_OBJECT (surface), "scale-factor"); - g_object_notify (G_OBJECT (surface), "scale"); - } + g_object_notify (G_OBJECT (surface), "scale"); + if (scale_factor_changed) + g_object_notify (G_OBJECT (surface), "scale-factor"); _gdk_surface_update_size (surface); } |