]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
ply-utils: Use lower threshold for hiDPI scaling on 3:2 screens
authorHans de Goede <hdegoede@redhat.com>
Thu, 6 Mar 2025 16:46:34 +0000 (17:46 +0100)
committerHans de Goede <jwrdegoede@fedoraproject.org>
Tue, 6 May 2025 11:38:59 +0000 (11:38 +0000)
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 <hdegoede@redhat.com>
src/libply/ply-utils.c

index 755a54ccdd26cc555216941f2d7c7b7e76e88f22..2de2e87cebb85ad6096b43bee12b5efbd8a09ad7 100644 (file)
@@ -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