outputchangeset: Round passed scale

wl_fixed is lossy even for values that are representable as perfect doubles, 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


(cherry picked from commit 3082133117c4360d4ac9bc7500f4d2338f86e8d0)
icc-effect-5.27.2
David Edmundson 2023-02-19 22:19:39 +00:00 committed by Vlad Zahorodnii
parent bbe2d4236c
commit aa700a13d6
1 changed files with 6 additions and 1 deletions

View File

@ -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.";