Skip to content

Commit

Permalink
Windows QPA: remove SWP_NOCOPYBITS for plain moves
Browse files Browse the repository at this point in the history
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
Pick-to: 6.6 6.5
Change-Id: Ic0cb32d9eb3b557bf2b2ef5b6ba80d34e27c5c19
Reviewed-by: Oliver Wolff <[email protected]>
Reviewed-by: Pavel Dubsky <[email protected]>

Cherry-picked into adsk-contrib-maya-v6.5.3 by Keith Kyzivat
<[email protected]> on 20231219 to fix MAYA-131850

(cherry picked from commit 9a64449)
  • Loading branch information
Timothée Keller authored and keithel-qt committed Dec 19, 2023
1 parent a9b7395 commit c4af263
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/plugins/platforms/windows/qwindowswindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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;
Expand Down

0 comments on commit c4af263

Please sign in to comment.