From 2123f7b9c6d0982f8caf25d6e6d36cb3ce1ece35 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Thu, 6 Mar 2025 17:46:34 +0100 Subject: [PATCH] ply-utils: Use lower threshold for hiDPI scaling on 3:2 screens 3:2 screens are only used in mobile form factors, add a special case for this with a lower threshold to enable 2x hiDPI scaling. Also remove the HIDPI_MIN_* defines these were only used in one place and adding a second set for the 3:2 screens just makes things harder to read. Instead write the actual width/height thresholds directly in the code of the new get_device_scale_guess () helper. Signed-off-by: Hans de Goede --- src/libply/ply-utils.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/libply/ply-utils.c b/src/libply/ply-utils.c index 755a54cc..2de2e87c 100644 --- a/src/libply/ply-utils.c +++ b/src/libply/ply-utils.c @@ -1020,9 +1020,6 @@ ply_set_device_scale (int device_scale) ply_trace ("Device scale is set to %d", device_scale); } -#define HIDPI_MIN_HEIGHT 1200 -#define HIDPI_MIN_WIDTH 2560 /* For heuristic / guessed device-scale */ - /* * If we have guessed the scale once, keep guessing to avoid * changing the scale on simpledrm -> native driver switch. @@ -1033,6 +1030,8 @@ static int get_device_scale_guess (uint32_t width, uint32_t height) { + double aspect; + /* Swap width <-> height for portrait screens */ if (height > width) { uint32_t tmp = width; @@ -1040,8 +1039,17 @@ get_device_scale_guess (uint32_t width, height = tmp; } - return (width >= HIDPI_MIN_WIDTH && - height >= HIDPI_MIN_HEIGHT) ? 2 : 1; + /* + * Special case for 3:2 screens which are only used in mobile form + * factors, with a lower threshold to enable 2x hiDPI scaling. + */ + aspect = (double) width / height; + if (aspect == 1.5) + return (width >= 1800 && + height >= 1200) ? 2 : 1; + + return (width >= 2560 && + height >= 1200) ? 2 : 1; } static int -- 2.47.2