From 19135feb0fc90133c39a779e309ca802e7eb61bb Mon Sep 17 00:00:00 2001 From: Piotr Kubaj Date: Sun, 22 Nov 2026 22:22:58 +0100 Subject: [PATCH] Display (Linux): fixes scale factor of rotated outputs on Wayland The scale factor is computed from the wl_output mode width and the zxdg_output_v1 logical width. The logical size is already transformed, but the mode is only swapped later in ffWaylandHandleRotation(), so a monitor rotated by 90 or 270 degrees compared its width with its logical height. A 1920x1200 monitor in portrait at scale 1 was reported as 1920 * 96 / 1200 = 153 dpi, shown as `@ 1.59x`. Compare with the mode height for 90 / 270 degree transforms instead. --- CHANGELOG.md | 1 + src/detection/displayserver/linux/wayland/global-output.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d13fcb3ef..3931b37f2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ Changes: Bugfixes: * Fixed libc version detection on FreeBSD without binutils installed, and on DragonFly BSD. (Libc, FreeBSD / DragonFly) * Fixed CPU cache detection failing entirely when any CPU is offline. (#2736, CPUCache, Linux) +* Fixed the scale factor of rotated monitors on Wayland, e.g. a 1920x1200 monitor rotated by 90 degrees at scale 1 being reported as `@ 1.59x`. (Display, Linux) # 2.71.0 diff --git a/src/detection/displayserver/linux/wayland/global-output.c b/src/detection/displayserver/linux/wayland/global-output.c index 6639a70c28..dcb394ccc9 100644 --- a/src/detection/displayserver/linux/wayland/global-output.c +++ b/src/detection/displayserver/linux/wayland/global-output.c @@ -48,9 +48,11 @@ static void waylandOutputGeometryListener(void* data, static void handleXdgLogicalSize(void* data, [[maybe_unused]] struct zxdg_output_v1* _, int32_t width, [[maybe_unused]] int32_t height) { WaylandDisplay* display = data; + // The logical size is already transformed, but the mode is not swapped until ffWaylandHandleRotation() + int32_t modeWidth = display->transform & WL_OUTPUT_TRANSFORM_90 ? display->height : display->width; // Seems the values are only useful when ractional scale is enabled - if (width < display->width) { - display->dpi = (uint32_t) (display->width * 96 / width); + if (width < modeWidth) { + display->dpi = (uint32_t) (modeWidth * 96 / width); } }