From 000f1ee3604048f693f2a9425948a37ec45b4301 Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Sun, 24 Oct 2021 12:59:02 +0800 Subject: Windows QPA: Set SWP_NOCOPYBITS during resize to avoid jitter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allowing Windows to re-use parts of the client area when resizing might result in jitter. See discussion in: https://stackoverflow.com/questions/53000291/how-to-smooth-ugly-jitter-flicker-jumping-when-resizing-windows-especially-drag Fixes: QTBUG-97774 Pick-to: 6.2 Change-Id: Idc8f0d1953dd0a8b329312d8a9fd0509cc24d81f Reviewed-by: Oliver Wolff Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/windows/qwindowswindow.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 5988d1498d..c4a85ab21e 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -2481,6 +2481,11 @@ void QWindowsWindow::propagateSizeHints() bool QWindowsWindow::handleGeometryChangingMessage(MSG *message, const QWindow *qWindow, const QMargins &margins) { auto *windowPos = reinterpret_cast(message->lParam); + + // 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; + if ((windowPos->flags & SWP_NOZORDER) == 0) { if (QWindowsWindow *platformWindow = QWindowsWindow::windowsWindowOf(qWindow)) { QWindow *parentWindow = qWindow->parent(); @@ -2493,7 +2498,7 @@ bool QWindowsWindow::handleGeometryChangingMessage(MSG *message, const QWindow * } if (!qWindow->isTopLevel()) // Implement hasHeightForWidth(). return false; - if ((windowPos->flags & (SWP_NOCOPYBITS | SWP_NOSIZE))) + if (windowPos->flags & SWP_NOSIZE) return false; const QRect suggestedFrameGeometry(windowPos->x, windowPos->y, windowPos->cx, windowPos->cy); -- cgit v1.2.3