Windows QPA: Only refresh the window theme if it really changes
WM_SETTINGCHANGE may be triggered in many different reasons, we don't have to verify whether the system changes the global theme or not in all cases. Although not officially documented, there's a widely known and used technique to detect whether the user actually changes the personalize settings or not, that is when wParam is 0 and lParam is "ImmersiveColorSet", this combination indicates system's personalize settings has been changed. We can get rid of most unneeded verify of system theme by only execute the logic in this specific case. Change-Id: Iaf934c29975b3b2090fd692776f80b1125d3ddb3 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
This commit is contained in:
parent
9f9be33180
commit
1ed449e168
@ -1154,17 +1154,20 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
|
||||
return false;
|
||||
case QtWindows::SettingChangedEvent: {
|
||||
QWindowsWindow::settingsChanged();
|
||||
const bool darkMode = QWindowsTheme::queryDarkMode();
|
||||
if (darkMode != QWindowsContextPrivate::m_darkMode) {
|
||||
QWindowsContextPrivate::m_darkMode = darkMode;
|
||||
auto integration = QWindowsIntegration::instance();
|
||||
if (integration->darkModeHandling().testFlag(QWindowsApplication::DarkModeWindowFrames)) {
|
||||
for (QWindowsWindow *w : d->m_windows)
|
||||
w->setDarkBorder(QWindowsContextPrivate::m_darkMode);
|
||||
}
|
||||
if (integration->darkModeHandling().testFlag(QWindowsApplication::DarkModeStyle)) {
|
||||
QWindowsTheme::instance()->refresh();
|
||||
QWindowSystemInterface::handleThemeChange();
|
||||
// Only refresh the window theme if the user changes the personalize settings.
|
||||
if (wParam == 0 && wcscmp(reinterpret_cast<LPCWSTR>(lParam), L"ImmersiveColorSet") == 0) {
|
||||
const bool darkMode = QWindowsTheme::queryDarkMode();
|
||||
if (darkMode != QWindowsContextPrivate::m_darkMode) {
|
||||
QWindowsContextPrivate::m_darkMode = darkMode;
|
||||
auto integration = QWindowsIntegration::instance();
|
||||
if (integration->darkModeHandling().testFlag(QWindowsApplication::DarkModeWindowFrames)) {
|
||||
for (QWindowsWindow *w : d->m_windows)
|
||||
w->setDarkBorder(QWindowsContextPrivate::m_darkMode);
|
||||
}
|
||||
if (integration->darkModeHandling().testFlag(QWindowsApplication::DarkModeStyle)) {
|
||||
QWindowsTheme::instance()->refresh();
|
||||
QWindowSystemInterface::handleThemeChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
return d->m_screenManager.handleScreenChanges();
|
||||
|
Loading…
x
Reference in New Issue
Block a user