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
This commit is contained in:
David Edmundson 2023-02-20 10:02:06 +00:00
parent 6d25104849
commit ada8e40792

View file

@ -166,7 +166,12 @@ void OutputConfigurationV2Interface::kde_output_configuration_v2_scale(Resource
if (invalid) { if (invalid) {
return; 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) { if (doubleScale <= 0) {
qCWarning(KWIN_CORE) << "Requested to scale output device to" << doubleScale << ", but I can't do that."; qCWarning(KWIN_CORE) << "Requested to scale output device to" << doubleScale << ", but I can't do that.";