summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothée Keller <timothee.keller@qt.io>2023-08-14 13:27:46 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-10-18 06:10:41 +0000
commit8d7826442bf889364ab39cf54c6f4617891d0bd7 (patch)
tree816a4c12016023b5d86dcc30d35fc9bf26f577a1
parentf4580a86ea8ec5f5bfdb8348fcede480e9b4b50a (diff)
Windows QPA: remove SWP_NOCOPYBITS for plain moves
The SWP_NOCOPYBITS flag helps suppress some jittering during resizes. At the moment this is called even for plain moves with no window resizing. Make sure that the window geometry has changed before applying the SWP_NOCOPYBITS flag Fixes: QTBUG-115992 Change-Id: Ic0cb32d9eb3b557bf2b2ef5b6ba80d34e27c5c19 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Pavel Dubsky <pavel.dubsky@qt.io> (cherry picked from commit 9a64449cc353a35b37518ba4fcc62439877f6f10) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 5d292c44827d4c36370c47dda39cd2e14baa3005)
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 085604394b..116eda40bd 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -2709,10 +2709,17 @@ void QWindowsWindow::propagateSizeHints()
bool QWindowsWindow::handleGeometryChangingMessage(MSG *message, const QWindow *qWindow, const QMargins &margins)
{
auto *windowPos = reinterpret_cast<WINDOWPOS *>(message->lParam);
+ const QRect suggestedFrameGeometry(windowPos->x, windowPos->y,
+ windowPos->cx, windowPos->cy);
+ const QRect suggestedGeometry = suggestedFrameGeometry - margins;
// Tell Windows to discard the entire contents of the client area, as re-using
// parts of the client area would lead to jitter during resize.
- windowPos->flags |= SWP_NOCOPYBITS;
+ // Check the suggestedGeometry against the current one to only discard during
+ // resize, and not a plain move. We also look for SWP_NOSIZE since that, too,
+ // implies an identical size, and comparing QRects wouldn't work with null cx/cy
+ if (!(windowPos->flags & SWP_NOSIZE) && suggestedGeometry.size() != qWindow->geometry().size())
+ windowPos->flags |= SWP_NOCOPYBITS;
if ((windowPos->flags & SWP_NOZORDER) == 0) {
if (QWindowsWindow *platformWindow = QWindowsWindow::windowsWindowOf(qWindow)) {
@@ -2728,9 +2735,6 @@ bool QWindowsWindow::handleGeometryChangingMessage(MSG *message, const QWindow *
return false;
if (windowPos->flags & SWP_NOSIZE)
return false;
- const QRect suggestedFrameGeometry(windowPos->x, windowPos->y,
- windowPos->cx, windowPos->cy);
- const QRect suggestedGeometry = suggestedFrameGeometry - margins;
const QRectF correctedGeometryF = QPlatformWindow::closestAcceptableGeometry(qWindow, suggestedGeometry);
if (!correctedGeometryF.isValid())
return false;