From e9f790d3533ebaee1f782e91b6e13b2c6375c86a Mon Sep 17 00:00:00 2001
From: SineStriker <55847490+SineStriker@users.noreply.github.com>
Date: 周二, 11 2月 2025 23:06:01 +0800
Subject: [PATCH] AWC: fix window attribute handler

---
 src/core/shared/qwkwindowsextra_p.h |   42 +++++++++++++++++++++---------------------
 1 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/src/core/shared/qwkwindowsextra_p.h b/src/core/shared/qwkwindowsextra_p.h
index b56f2eb..8fdc86e 100644
--- a/src/core/shared/qwkwindowsextra_p.h
+++ b/src/core/shared/qwkwindowsextra_p.h
@@ -19,11 +19,13 @@
 #include <timeapi.h>
 
 #include <QWKCore/qwindowkit_windows.h>
-#include <QtCore/private/qsystemlibrary_p.h>
 
+#include <QtCore/QtMath>
 #include <QtGui/QGuiApplication>
 #include <QtGui/QStyleHints>
 #include <QtGui/QPalette>
+
+#include <QtCore/private/qsystemlibrary_p.h>
 
 // Don't include this header in any header files.
 
@@ -167,7 +169,6 @@
 
             DYNAMIC_API_DECLARE(DwmFlush);
             DYNAMIC_API_DECLARE(DwmIsCompositionEnabled);
-            DYNAMIC_API_DECLARE(DwmGetCompositionTimingInfo);
             DYNAMIC_API_DECLARE(DwmGetWindowAttribute);
             DYNAMIC_API_DECLARE(DwmSetWindowAttribute);
             DYNAMIC_API_DECLARE(DwmExtendFrameIntoClientArea);
@@ -176,9 +177,6 @@
             DYNAMIC_API_DECLARE(GetSystemMetricsForDpi);
             DYNAMIC_API_DECLARE(AdjustWindowRectExForDpi);
             DYNAMIC_API_DECLARE(GetDpiForMonitor);
-            DYNAMIC_API_DECLARE(timeGetDevCaps);
-            DYNAMIC_API_DECLARE(timeBeginPeriod);
-            DYNAMIC_API_DECLARE(timeEndPeriod);
 
 #undef DYNAMIC_API_DECLARE
 
@@ -206,16 +204,10 @@
                 QSystemLibrary dwmapi(QStringLiteral("dwmapi"));
                 DYNAMIC_API_RESOLVE(dwmapi, DwmFlush);
                 DYNAMIC_API_RESOLVE(dwmapi, DwmIsCompositionEnabled);
-                DYNAMIC_API_RESOLVE(dwmapi, DwmGetCompositionTimingInfo);
                 DYNAMIC_API_RESOLVE(dwmapi, DwmGetWindowAttribute);
                 DYNAMIC_API_RESOLVE(dwmapi, DwmSetWindowAttribute);
                 DYNAMIC_API_RESOLVE(dwmapi, DwmExtendFrameIntoClientArea);
                 DYNAMIC_API_RESOLVE(dwmapi, DwmEnableBlurBehindWindow);
-
-                QSystemLibrary winmm(QStringLiteral("winmm"));
-                DYNAMIC_API_RESOLVE(winmm, timeGetDevCaps);
-                DYNAMIC_API_RESOLVE(winmm, timeBeginPeriod);
-                DYNAMIC_API_RESOLVE(winmm, timeEndPeriod);
 
 #undef DYNAMIC_API_RESOLVE
 
@@ -345,8 +337,11 @@
         if (!registry.isValid()) {
             return false;
         }
-        auto value = registry.value<DWORD>(L"ColorPrevalence");
-        return value.value_or(false);
+        auto value = registry.dwordValue(L"ColorPrevalence");
+        if (!value.second) {
+            return false;
+        }
+        return value.first;
     }
 
     inline bool isHighContrastModeEnabled() {
@@ -368,8 +363,11 @@
         if (!registry.isValid()) {
             return false;
         }
-        auto value = registry.value<DWORD>(L"AppsUseLightTheme");
-        return value.value_or(false);
+        auto value = registry.dwordValue(L"AppsUseLightTheme");
+        if (!value.second) {
+            return false;
+        }
+        return !value.first;
 #endif
     }
 
@@ -379,8 +377,10 @@
         }
         BOOL enabled = FALSE;
         const DynamicApis &apis = DynamicApis::instance();
-        const auto attr = isWin1020H1OrGreater() ? _DWMWA_USE_IMMERSIVE_DARK_MODE : _DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1;
-        return SUCCEEDED(apis.pDwmGetWindowAttribute(hwnd, attr, &enabled, sizeof(enabled))) && enabled;
+        const auto attr = isWin1020H1OrGreater() ? _DWMWA_USE_IMMERSIVE_DARK_MODE
+                                                 : _DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1;
+        return SUCCEEDED(apis.pDwmGetWindowAttribute(hwnd, attr, &enabled, sizeof(enabled))) &&
+               enabled;
     }
 
     inline QColor getAccentColor() {
@@ -391,13 +391,13 @@
         if (!registry.isValid()) {
             return {};
         }
-        auto value = registry.value<DWORD>(L"AccentColor");
-        if (!value) {
+        auto value = registry.dwordValue(L"AccentColor");
+        if (!value.second) {
             return {};
         }
         // The retrieved value is in the #AABBGGRR format, we need to
         // convert it to the #AARRGGBB format which Qt expects.
-        QColor color = QColor::fromRgba(*value);
+        QColor color = QColor::fromRgba(value.first);
         if (!color.isValid()) {
             return {};
         }
@@ -407,7 +407,7 @@
 
     inline quint32 getDpiForWindow(HWND hwnd) {
         const DynamicApis &apis = DynamicApis::instance();
-        if (apis.pGetDpiForWindow) {         // Win10
+        if (apis.pGetDpiForWindow) { // Win10
             return apis.pGetDpiForWindow(hwnd);
         } else if (apis.pGetDpiForMonitor) { // Win8.1
             HMONITOR monitor = ::MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);

--
Gitblit v1.9.1