diff -Nru plymouth-24.004.60/debian/changelog plymouth-24.004.60/debian/changelog --- plymouth-24.004.60/debian/changelog 2024-02-29 15:50:42.000000000 +0800 +++ plymouth-24.004.60/debian/changelog 2024-03-08 16:20:32.000000000 +0800 @@ -1,3 +1,10 @@ +plymouth (24.004.60-1ubuntu5) noble; urgency=medium + + * Cherry-pick upstream fixes for consistent default scale selection + that matches what Mutter chooses on the login screen (LP: #2054769) + + -- Daniel van Vugt Fri, 08 Mar 2024 16:20:32 +0800 + plymouth (24.004.60-1ubuntu4) noble; urgency=medium * No-change rebuild against libpng16-16t64 diff -Nru plymouth-24.004.60/debian/patches/0016-ply-utils-Match-mutter-s-default-device-scale-choice.patch plymouth-24.004.60/debian/patches/0016-ply-utils-Match-mutter-s-default-device-scale-choice.patch --- plymouth-24.004.60/debian/patches/0016-ply-utils-Match-mutter-s-default-device-scale-choice.patch 1970-01-01 08:00:00.000000000 +0800 +++ plymouth-24.004.60/debian/patches/0016-ply-utils-Match-mutter-s-default-device-scale-choice.patch 2024-03-08 16:20:32.000000000 +0800 @@ -0,0 +1,98 @@ +From: Daniel van Vugt +Date: Tue, 27 Feb 2024 14:47:59 +0800 +Subject: ply-utils: Match mutter's default device scale choice + +Until now, laptops with a DPI between 192 and 202 would be given a +default scale of 2 by Plymouth, and 1 by Mutter for the login screen. +That made the visual transition a bit ugly so let's match Mutter's +default scale selection. This means the threshold for laptops is now +1.5 x 135 = 202 DPI instead of 192 DPI. And for desktop monitors it's +now 1.5 x 110 = 165 DPI instead of 192 DPI. + +Origin: Upstream commit acf97c73670b80a65329aaa35e40438d86fca3c6 +Bug-Ubuntu: https://bugs.launchpad.net/bugs/2054769 +Forwarded: not-needed +Last-Update: 2024-03-08 +--- + src/libply/ply-utils.c | 40 ++++++++++++++++++++++------------------ + 1 file changed, 22 insertions(+), 18 deletions(-) + +diff --git a/src/libply/ply-utils.c b/src/libply/ply-utils.c +index 463f61c..ad816f1 100644 +--- a/src/libply/ply-utils.c ++++ b/src/libply/ply-utils.c +@@ -29,6 +29,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -1001,8 +1002,6 @@ ply_set_device_scale (int device_scale) + ply_trace ("Device scale is set to %d", device_scale); + } + +-/* The minimum resolution at which we turn on a device-scale of 2 */ +-#define HIDPI_LIMIT 192 + #define HIDPI_MIN_HEIGHT 1200 + #define HIDPI_MIN_WIDTH 2560 /* For heuristic / guessed device-scale */ + +@@ -1019,8 +1018,8 @@ get_device_scale (uint32_t width, + uint32_t height_mm, + bool guess) + { +- int device_scale; +- double dpi_x, dpi_y; ++ int device_scale, target_dpi; ++ float diag_inches, diag_pixels, physical_dpi, perfect_scale; + const char *force_device_scale; + + device_scale = 1; +@@ -1031,11 +1030,10 @@ get_device_scale (uint32_t width, + if (overridden_device_scale != 0) + return overridden_device_scale; + +- if (height < HIDPI_MIN_HEIGHT) +- return 1; +- +- if (guess) +- return (width >= HIDPI_MIN_WIDTH) ? 2 : 1; ++ if (guess) { ++ return (width >= HIDPI_MIN_WIDTH && ++ height >= HIDPI_MIN_HEIGHT) ? 2 : 1; ++ } + + /* Somebody encoded the aspect ratio (16/9 or 16/10) + * instead of the physical size */ +@@ -1045,15 +1043,21 @@ get_device_scale (uint32_t width, + (width_mm == 16 && height_mm == 10)) + return 1; + +- if (width_mm > 0 && height_mm > 0) { +- dpi_x = (double) width / (width_mm / 25.4); +- dpi_y = (double) height / (height_mm / 25.4); +- /* We don't completely trust these values so both +- * must be high, and never pick higher ratio than +- * 2 automatically */ +- if (dpi_x > HIDPI_LIMIT && dpi_y > HIDPI_LIMIT) +- device_scale = 2; +- } ++ if (width_mm == 0 || height_mm == 0) ++ return 1; ++ ++ diag_inches = sqrtf (width_mm * width_mm + height_mm * height_mm) / ++ 25.4f; ++ diag_pixels = sqrtf (width * width + height * height); ++ physical_dpi = diag_pixels / diag_inches; ++ ++ /* These constants are copied from Mutter's meta-monitor.c in order ++ * to match the default scale choice of the login screen. ++ */ ++ target_dpi = (diag_inches >= 20.f) ? 110 : 135; ++ ++ perfect_scale = physical_dpi / target_dpi; ++ device_scale = (perfect_scale > 1.5f) ? 2 : 1; + + return device_scale; + } diff -Nru plymouth-24.004.60/debian/patches/0017-ply-utils-Only-choose-scale-2-when-the-perfect-scale.patch plymouth-24.004.60/debian/patches/0017-ply-utils-Only-choose-scale-2-when-the-perfect-scale.patch --- plymouth-24.004.60/debian/patches/0017-ply-utils-Only-choose-scale-2-when-the-perfect-scale.patch 1970-01-01 08:00:00.000000000 +0800 +++ plymouth-24.004.60/debian/patches/0017-ply-utils-Only-choose-scale-2-when-the-perfect-scale.patch 2024-03-08 16:20:32.000000000 +0800 @@ -0,0 +1,32 @@ +From: Daniel van Vugt +Date: Tue, 5 Mar 2024 17:51:11 +0800 +Subject: ply-utils: Only choose scale 2 when the perfect scale would be >= + 1.75 + +This is the intended design documented in: +https://gitlab.gnome.org/GNOME/mutter/-/commit/d03dce43786d + +And discussed in: +https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3616 + +Origin: Upstream commit 3b8e918479f47a845d4f88d281f7dfe412195628 +Improves: https://bugs.launchpad.net/bugs/2054769 +Forwarded: not-needed +Last-Update: 2024-03-08 +--- + src/libply/ply-utils.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/libply/ply-utils.c b/src/libply/ply-utils.c +index ad816f1..44a9309 100644 +--- a/src/libply/ply-utils.c ++++ b/src/libply/ply-utils.c +@@ -1057,7 +1057,7 @@ get_device_scale (uint32_t width, + target_dpi = (diag_inches >= 20.f) ? 110 : 135; + + perfect_scale = physical_dpi / target_dpi; +- device_scale = (perfect_scale > 1.5f) ? 2 : 1; ++ device_scale = (perfect_scale >= 1.75f) ? 2 : 1; + + return device_scale; + } diff -Nru plymouth-24.004.60/debian/patches/series plymouth-24.004.60/debian/patches/series --- plymouth-24.004.60/debian/patches/series 2024-02-07 18:47:47.000000000 +0800 +++ plymouth-24.004.60/debian/patches/series 2024-03-08 16:20:32.000000000 +0800 @@ -13,3 +13,5 @@ ubuntu-text.patch spinfinity-no-meson-symlink.patch renderers-Do-not-assume-all-keyboards-have-LEDs.patch +0016-ply-utils-Match-mutter-s-default-device-scale-choice.patch +0017-ply-utils-Only-choose-scale-2-when-the-perfect-scale.patch