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 <nodir.temir@gmail.com>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
This commit is contained in:
Tor Arne Vestbø 2025-05-22 14:07:23 +02:00
parent f56ed53261
commit 26f92a333e

View File

@ -50,7 +50,10 @@ void QWindowsBackingStore::flush(QWindow *window, const QRegion &region,
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();