win32: fix dark mode detection

global dark mode was first introduced in Win10 1607, not 1809
1809 was the first version that file explorer supported dark mode
really sorry for the wrong information

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2022-03-30 14:15:12 +08:00
parent 3104fd07d2
commit f13238312b
3 changed files with 11 additions and 13 deletions

View File

@ -57,7 +57,7 @@ FRAMELESSHELPER_CORE_API void moveWindowToDesktopCenter(
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin8OrGreater();
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin8Point1OrGreater();
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin10OrGreater();
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin101809OrGreater();
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin101607OrGreater();
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWin11OrGreater();
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isDwmCompositionEnabled();
FRAMELESSHELPER_CORE_API void triggerFrameChange(const WId windowId);

View File

@ -677,7 +677,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
}
}
const bool themeSettingChanged = [uMsg, wParam, lParam]() -> bool {
if (Utils::isWin10OrGreater()) {
if (Utils::isWin101607OrGreater()) {
if (uMsg == WM_SETTINGCHANGE) {
if ((wParam == 0) && (QString::fromWCharArray(reinterpret_cast<LPCWSTR>(lParam))
.compare(QU8Str(kThemeSettingChangeEventName), Qt::CaseInsensitive) == 0)) {

View File

@ -455,8 +455,8 @@ QColor Utils::getDwmColorizationColor()
bool Utils::shouldAppsUseDarkMode()
{
// The global dark mode was first introduced in Windows 10 1809.
if (!isWin101809OrGreater()) {
// The global dark mode was first introduced in Windows 10 1607.
if (!isWin101607OrGreater()) {
return false;
}
const auto resultFromRegistry = []() -> bool {
@ -684,14 +684,12 @@ void Utils::syncWmPaintWithDwm()
}
}
bool Utils::isWin101809OrGreater()
bool Utils::isWin101607OrGreater()
{
#if (QT_VERSION >= QT_VERSION_CHECK(6, 3, 0))
static const bool result = (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows10_1809);
#elif (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0))
static const bool result = (QOperatingSystemVersion::current() >= QOperatingSystemVersion(QOperatingSystemVersion::Windows, 10, 0, 17763));
#if (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0))
static const bool result = (QOperatingSystemVersion::current() >= QOperatingSystemVersion(QOperatingSystemVersion::Windows, 10, 0, 14393));
#else
static const bool result = isWindowsVersionOrGreater(10, 0, 17763);
static const bool result = isWindowsVersionOrGreater(10, 0, 14393);
#endif
return result;
}
@ -880,8 +878,8 @@ void Utils::updateWindowFrameBorderColor(const WId windowId, const bool dark)
if (!windowId) {
return;
}
// There's no global dark theme before Win10 1809.
if (!isWin101809OrGreater()) {
// There's no global dark theme before Win10 1607.
if (!isWin101607OrGreater()) {
return;
}
static const auto pDwmSetWindowAttribute =
@ -1188,7 +1186,7 @@ SystemTheme Utils::getSystemTheme()
if (isHighContrastModeEnabled()) {
return SystemTheme::HighContrast;
}
if (isWin101809OrGreater() && shouldAppsUseDarkMode()) {
if (isWin101607OrGreater() && shouldAppsUseDarkMode()) {
return SystemTheme::Dark;
}
return SystemTheme::Light;