From e3044e619e04971444f2ed8e68b7e2e2316ffc06 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Tue, 26 May 2020 10:52:16 +0100 Subject: [PATCH] Correctly align natural layout in present windows Summary: Present windows works as follows: - It moves all windows about until nothing is overlapping with any other window. - This doesn't resize anything so ultimately we end up with a new co-ordinate space that's bigger than the screen depending on the amount of overlap. - We then render this whole view transformed to the screen The rectangle "bounds" is in overviewpixels, with "scale" being the ratio to convert to screen pixels. When adjusting the new bounds there's an attempt to centre align things. As bounds is in "overviewpixels" we multiply references to the previous bounds by scale, and divide everything through at the end. bounds.x/y were missed. This is mostly unoticable except on massive super-ultra-wide monitors which will otherwise have a tendency to shift to the left. Test Plan: Kai created a whole new test framework for this code that copy pasted this algorithm then showed mock windows as rectangles Reviewers: #kwin, apol, broulik, zzag Reviewed By: #kwin, apol, broulik, zzag Subscribers: zzag, apol, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D29705 --- effects/presentwindows/presentwindows.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/effects/presentwindows/presentwindows.cpp b/effects/presentwindows/presentwindows.cpp index 2ae0454087..8a15d4c327 100644 --- a/effects/presentwindows/presentwindows.cpp +++ b/effects/presentwindows/presentwindows.cpp @@ -1347,8 +1347,8 @@ void PresentWindowsEffect::calculateWindowTransformationsNatural(EffectWindowLis scale = (area.height() - 20) / double(bounds.height()); // Make bounding rect fill the screen size for later steps bounds = QRect( - bounds.x() - (area.width() - 20 - bounds.width() * scale) / 2 - 10 / scale, - bounds.y() - (area.height() - 20 - bounds.height() * scale) / 2 - 10 / scale, + (bounds.x() * scale - (area.width() - 20 - bounds.width() * scale) / 2 - 10) / scale, + (bounds.y() * scale - (area.height() - 20 - bounds.height() * scale) / 2 - 10) / scale, area.width() / scale, area.height() / scale );