From 26f92a333e3caf575e79058e42d0b091e7f10fe1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 22 May 2025 14:07:23 +0200 Subject: [PATCH] Windows: Only use UpdateLayeredWindowIndirect if window has an alpha We only call UpdateLayeredWindow in setWindowOpacity if the window has an alpha an no native frame, which means we need to use the same condition in the backingstore when choosing how to flush the window. Amends 9a45fea9d1f6e445fb488693b107cdec6e42cccd. As a follow-up we should refactor this code to avoid the duplicated logic that must always be kept in sync. Pick-to: 6.9 6.8 Change-Id: I2bd79bdc4a726339fc486d0892ff4e1960a5a10e Reviewed-by: Zhao Yuhang <2546789017@qq.com> Reviewed-by: Nodir Temirkhodjaev Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowsbackingstore.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/windows/qwindowsbackingstore.cpp b/src/plugins/platforms/windows/qwindowsbackingstore.cpp index d4e3cf3ccca..e580b0243d9 100644 --- a/src/plugins/platforms/windows/qwindowsbackingstore.cpp +++ b/src/plugins/platforms/windows/qwindowsbackingstore.cpp @@ -50,7 +50,10 @@ void QWindowsBackingStore::flush(QWindow *window, const QRegion ®ion, QWindowsWindow *rw = QWindowsWindow::windowsWindowOf(window); Q_ASSERT(rw); - if (rw->isLayered()) { + const bool hasAlpha = rw->format().hasAlpha(); + const Qt::WindowFlags flags = window->flags(); + // Note: This condition must be in sync with setWindowOpacity. FIXME: Improve this :) + if (rw->isLayered() && hasAlpha && QWindowsWindow::hasNoNativeFrame(rw->handle(), flags)) { // Windows with alpha: Use blend function to update. QRect r = QHighDpi::toNativePixels(window->frameGeometry(), window); QMargins frameMargins = rw->frameMargins();