summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2024-05-02 17:16:58 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2024-05-03 14:04:51 +0200
commit2c5f5bf2e8843d8c88c3ece9bd93c567fd74d3ae (patch)
tree1ac09d9259013046657f1a75bd47791dec24d8d9
parenta1371783ac3b04df5b5275de49179a26a7c5112b (diff)
Windows: simplify setting the dark border
A round trip through querying the window attribute to avoid a call to the setter is overkill, we can assume that the setter won't do anything if the value of the attribute doesn't change. Also, don't check whether QWindowsIntegration::darkModeHandling is overridden before calling setDarkMode, which checks that flag already. The flag will be very rarely cleared (and we might want to remove support for this obscure mechanism soon). Task-number: QTBUG-124490 Change-Id: I7e027fd53f556200edfd127eaf5f2b97f027528e Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
-rw-r--r--src/plugins/platforms/windows/qwindowstheme.cpp6
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp13
2 files changed, 2 insertions, 17 deletions
diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp
index fb5874fd8b0..a2224b1eacb 100644
--- a/src/plugins/platforms/windows/qwindowstheme.cpp
+++ b/src/plugins/platforms/windows/qwindowstheme.cpp
@@ -564,10 +564,8 @@ void QWindowsTheme::handleSettingsChanged()
QWindowSystemInterface::handleThemeChange();
}
if (colorSchemeChanged) {
- if (integration->darkModeHandling().testFlag(QWindowsApplication::DarkModeWindowFrames)) {
- for (QWindowsWindow *w : std::as_const(QWindowsContext::instance()->windows()))
- w->setDarkBorder(s_colorScheme == Qt::ColorScheme::Dark);
- }
+ for (QWindowsWindow *w : std::as_const(QWindowsContext::instance()->windows()))
+ w->setDarkBorder(s_colorScheme == Qt::ColorScheme::Dark);
}
}
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 03c5d149a66..5d96d40af59 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -3286,17 +3286,6 @@ enum : WORD {
DwmwaUseImmersiveDarkModeBefore20h1 = 19
};
-static bool queryDarkBorder(HWND hwnd)
-{
- BOOL result = FALSE;
- const bool ok =
- SUCCEEDED(DwmGetWindowAttribute(hwnd, DwmwaUseImmersiveDarkMode, &result, sizeof(result)))
- || SUCCEEDED(DwmGetWindowAttribute(hwnd, DwmwaUseImmersiveDarkModeBefore20h1, &result, sizeof(result)));
- if (!ok)
- qCWarning(lcQpaWindow, "%s: Unable to retrieve dark window border setting.", __FUNCTION__);
- return result == TRUE;
-}
-
bool QWindowsWindow::setDarkBorderToWindow(HWND hwnd, bool d)
{
const BOOL darkBorder = d ? TRUE : FALSE;
@@ -3312,8 +3301,6 @@ void QWindowsWindow::setDarkBorder(bool d)
{
// respect explicit opt-out and incompatible palettes or styles
d = d && shouldApplyDarkFrame(window());
- if (queryDarkBorder(m_data.hwnd) == d)
- return;
setDarkBorderToWindow(m_data.hwnd, d);
}