From 732d073351752530a7b6bda0bfe6c2ec264f4bd5 Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Wed, 2 Nov 2022 17:30:35 +0800 Subject: Windows QPA: Always apply system background color for top level window This is a follow-up patch of commit 2991c66b75612dfb11dbba166dd08b2376b42102 We can unset the window background brush and always draw the background ourself. Qt always paint all pixels anyway when blt'ing the backingstore, so it should be safe to do this. Since a theme might not provide a palette (e.g. when desktop setting awareness is disabled), always use the default application palette. Change-Id: I4fdc2467b3cc3999dd1acfe9411cec077ca66bd3 Reviewed-by: Yuhang Zhao <2546789017@qq.com> Reviewed-by: Volker Hilsheimer --- src/plugins/platforms/windows/qwindowswindow.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/plugins/platforms/windows/qwindowswindow.cpp') diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 325e240889..b2e41dca24 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -2303,9 +2303,10 @@ bool QWindowsWindow::handleWmPaint(HWND hwnd, UINT message, WPARAM wParam, LPARAM, LRESULT *result) { if (message == WM_ERASEBKGND) { // Backing store - ignored. - if (!m_firstBgDraw && QWindowsIntegration::instance()->darkModeHandling().testFlag(QWindowsApplication::DarkModeStyle)) { - // Get system background color - const QColor bgColor = QGuiApplicationPrivate::platformTheme()->palette()->color(QPalette::Window); + if (!m_firstBgDraw) { + // Get window background from the default palette; this will + // usually be the system background color. + const QColor bgColor = QGuiApplication::palette().color(QPalette::Window); HBRUSH bgBrush = CreateSolidBrush(RGB(bgColor.red(), bgColor.green(), bgColor.blue())); // Fill rectangle with system background color RECT rc; -- cgit v1.2.3