diff options
author | Yuhang Zhao <[email protected]> | 2022-11-02 17:30:35 +0800 |
---|---|---|
committer | Volker Hilsheimer <[email protected]> | 2022-12-05 15:55:53 +0100 |
commit | 732d073351752530a7b6bda0bfe6c2ec264f4bd5 (patch) | |
tree | e854510bae5059ee67e0c7a43859f1fbdf2efc6e | |
parent | b3dbfdd59782e801fc5bb5e5df3ed71ae4ec2866 (diff) |
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 <[email protected]>
Reviewed-by: Volker Hilsheimer <[email protected]>
-rw-r--r-- | src/plugins/platforms/windows/qwindowscontext.cpp | 2 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowswindow.cpp | 7 |
2 files changed, 5 insertions, 4 deletions
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index e1c1e99a5a3..3e2cb79defb 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -541,7 +541,7 @@ QString QWindowsContext::registerWindowClass(const QWindow *w) if (icon) cname += "Icon"_L1; - return registerWindowClass(cname, qWindowsWndProc, style, GetSysColorBrush(COLOR_WINDOW), icon); + return registerWindowClass(cname, qWindowsWndProc, style, nullptr, icon); } QString QWindowsContext::registerWindowClass(QString cname, diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 325e2408891..b2e41dca24f 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; |