From ada8e40792baf952a6893e217dded7785d251e6d Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Mon, 20 Feb 2023 10:02:06 +0000 Subject: [PATCH] outputchangeset: Round passed scale Converting to wl_fixed is lossy. Especially for non-round values like 1.15. This causes various visual glitches and off sizes. Given we're using units of 120ths for the fractional scale protocol it makes sense to fix the passed values for anything else over the wayland protocol. BUG: 465850 Testing done: ran a 1920 screen at 1.15 scale, got a logical size of 1670 which matches what it should be --- src/wayland/outputmanagement_v2_interface.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/wayland/outputmanagement_v2_interface.cpp b/src/wayland/outputmanagement_v2_interface.cpp index 07e55c8a74..bed5dcd648 100644 --- a/src/wayland/outputmanagement_v2_interface.cpp +++ b/src/wayland/outputmanagement_v2_interface.cpp @@ -166,7 +166,12 @@ void OutputConfigurationV2Interface::kde_output_configuration_v2_scale(Resource if (invalid) { return; } - const qreal doubleScale = wl_fixed_to_double(scale); + qreal doubleScale = wl_fixed_to_double(scale); + + // the fractional scaling protocol only speaks in unit of 120ths + // using the same scale throughout makes that simpler + // this also eliminates most loss from wl_fixed + doubleScale = std::round(doubleScale * 120) / 120; if (doubleScale <= 0) { qCWarning(KWIN_CORE) << "Requested to scale output device to" << doubleScale << ", but I can't do that.";