Apply system background color for top level window
Repaint top level window with system background color when it shows up first time. The system background color will be affected by dark or light mode settings in windows Fixes: QTBUG-106583 Change-Id: I9205335540e74e90bb068e30fc3d4db037fd580f Reviewed-by: Yuhang Zhao <2546789017@qq.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 2991c66b75612dfb11dbba166dd08b2376b42102) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
13917772f0
commit
3ce2e00891
@ -33,6 +33,7 @@
|
||||
#include <private/qguiapplication_p.h>
|
||||
#include <private/qhighdpiscaling_p.h>
|
||||
#include <qpa/qwindowsysteminterface.h>
|
||||
#include <qpa/qplatformtheme.h>
|
||||
|
||||
#include <QtCore/qdebug.h>
|
||||
#include <QtCore/qlibraryinfo.h>
|
||||
@ -2303,9 +2304,22 @@ static inline bool isSoftwareGl()
|
||||
}
|
||||
|
||||
bool QWindowsWindow::handleWmPaint(HWND hwnd, UINT message,
|
||||
WPARAM, LPARAM, LRESULT *result)
|
||||
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);
|
||||
HBRUSH bgBrush = CreateSolidBrush(RGB(bgColor.red(), bgColor.green(), bgColor.blue()));
|
||||
// Fill rectangle with system background color
|
||||
RECT rc;
|
||||
auto hdc = reinterpret_cast<HDC>(wParam);
|
||||
GetClientRect(hwnd, &rc);
|
||||
FillRect(hdc, &rc, bgBrush);
|
||||
DeleteObject(bgBrush);
|
||||
// Brush the window with system background color only for first time
|
||||
m_firstBgDraw = true;
|
||||
}
|
||||
*result = 1;
|
||||
return true;
|
||||
}
|
||||
|
@ -377,6 +377,7 @@ private:
|
||||
HICON m_iconBig = nullptr;
|
||||
void *m_surface = nullptr;
|
||||
int m_savedDpi = 96;
|
||||
bool m_firstBgDraw = false;
|
||||
|
||||
static bool m_screenForGLInitialized;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user