From 8ccabb79745f079417b3a049f52c4779d6efdf07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 26 Jun 2023 17:32:01 +0200 Subject: [PATCH] wayland: surface_scale(): implement fractional scaling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is done by setting the surface’s viewport destination --- wayland.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/wayland.c b/wayland.c index a45171ff..fce6a67f 100644 --- a/wayland.c +++ b/wayland.c @@ -1889,11 +1889,20 @@ wayl_surface_scale_explicit_width_height( const struct wayland *wayl, const struct wayl_surface *surf, int width, int height, float scale) { - LOG_WARN("scaling by a factor of %.2f (legacy)", scale); if (wayl_fractional_scaling(wayl)) { - BUG("not yet implemented"); +#if defined(HAVE_FRACTIONAL_SCALE) + LOG_DBG("scaling by a factor of %.2f (fractional scaling)", scale); + wp_viewport_set_destination( + surf->viewport, + round((float)width / scale), + round((float)height / scale)); +#else + BUG("wayl_fraction_scaling() returned true, " + "but fractional scaling was not available at compile time"). +#endif } else { + LOG_DBG("scaling by a factor of %.2f (legacy)", scale); wl_surface_set_buffer_scale(surf->surf, (int)scale); } }