From 0cedc474f38dca024f77ebf1d7ac5bf22c19744a Mon Sep 17 00:00:00 2001
From: Zhao Yuhang <2546789017@qq.com>
Date: 周五, 22 12月 2023 20:51:50 +0800
Subject: [PATCH] fix compile error on win

---
 /dev/null                                |  242 ------------------------------------------------
 examples/mainwindow/mainwindow.cpp       |   18 +-
 src/core/contexts/win32windowcontext.cpp |   31 ++---
 3 files changed, 21 insertions(+), 270 deletions(-)

diff --git a/examples/mainwindow/mainwindow.cpp b/examples/mainwindow/mainwindow.cpp
index a394a19..7faf057 100644
--- a/examples/mainwindow/mainwindow.cpp
+++ b/examples/mainwindow/mainwindow.cpp
@@ -8,7 +8,11 @@
 #include <QtWidgets/QApplication>
 #include <QtWidgets/QStyle>
 #include <QtWidgets/QPushButton>
-#include <QtWidgets/QActionGroup>
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+#  include <QtGui/QActionGroup>
+#else
+#  include <QtWidgets/QActionGroup>
+#endif
 
 #include <QWKCore/styleagent.h>
 #include <QWKWidgets/widgetwindowagent.h>
@@ -139,8 +143,7 @@
         auto dwmBlurAction = new QAction(tr("Enable DWM blur"), menuBar);
         dwmBlurAction->setCheckable(true);
         connect(dwmBlurAction, &QAction::triggered, this, [this](bool checked) {
-            QWindow *w = windowHandle();
-            styleAgent->setWindowAttribute(w, QStringLiteral("dwm-blur"), checked);
+            windowAgent->setWindowAttribute(QStringLiteral("dwm-blur"), checked);
             setProperty("custom-style", checked);
             style()->polish(this);
         });
@@ -148,8 +151,7 @@
         auto acrylicAction = new QAction(tr("Enable acrylic material"), menuBar);
         acrylicAction->setCheckable(true);
         connect(acrylicAction, &QAction::triggered, this, [this](bool checked) {
-            QWindow *w = windowHandle();
-            styleAgent->setWindowAttribute(w, QStringLiteral("acrylic-material"), QColor());
+            windowAgent->setWindowAttribute(QStringLiteral("acrylic-material"), QColor::fromRgbF(1.f, 1.f, 1.f, 0.6f));
             setProperty("custom-style", checked);
             style()->polish(this);
         });
@@ -157,8 +159,7 @@
         auto micaAction = new QAction(tr("Enable mica"), menuBar);
         micaAction->setCheckable(true);
         connect(micaAction, &QAction::triggered, this, [this](bool checked) {
-            QWindow *w = windowHandle();
-            styleAgent->setWindowAttribute(w, QStringLiteral("mica"), checked);
+            windowAgent->setWindowAttribute(QStringLiteral("mica"), checked);
             setProperty("custom-style", checked);
             style()->polish(this);
         });
@@ -166,8 +167,7 @@
         auto micaAltAction = new QAction(tr("Enable mica alt"), menuBar);
         micaAltAction->setCheckable(true);
         connect(micaAltAction, &QAction::triggered, this, [this](bool checked) {
-            QWindow *w = windowHandle();
-            styleAgent->setWindowAttribute(w, QStringLiteral("mica-alt"), checked);
+            windowAgent->setWindowAttribute(QStringLiteral("mica-alt"), checked);
             setProperty("custom-style", checked);
             style()->polish(this);
         });
diff --git a/src/core/contexts/win32windowcontext.cpp b/src/core/contexts/win32windowcontext.cpp
index af84241..bcf91f3 100644
--- a/src/core/contexts/win32windowcontext.cpp
+++ b/src/core/contexts/win32windowcontext.cpp
@@ -789,8 +789,10 @@
 
     bool Win32WindowContext::windowAttributeChanged(const QString &key, const QVariant &attribute,
                                                     const QVariant &oldAttribute) {
-        const auto hwnd = reinterpret_cast<HWND>(window->winId());
+        const auto hwnd = reinterpret_cast<HWND>(m_windowHandle->winId());
         const DynamicApis &apis = DynamicApis::instance();
+        static constexpr const MARGINS extendMargins = {-1, -1, -1, -1};
+        static const auto defaultMargins = isWin10OrGreater() ? MARGINS{0, 0, 0, 0} : MARGINS{1, 1, 1, 1};
         if (key == QStringLiteral("mica")) {
             if (!isWin11OrGreater()) {
                 return false;
@@ -798,8 +800,7 @@
             if (attribute.toBool()) {
                 // We need to extend the window frame into the whole client area to be able
                 // to see the blurred window background.
-                static constexpr const MARGINS margins = {-1, -1, -1, -1};
-                apis.pDwmExtendFrameIntoClientArea(hwnd, &margins);
+                apis.pDwmExtendFrameIntoClientArea(hwnd, &extendMargins);
                 if (isWin1122H2OrGreater()) {
                     // Use official DWM API to enable Mica, available since Windows 11 22H2
                     // (10.0.22621).
@@ -821,8 +822,7 @@
                     const BOOL enable = FALSE;
                     apis.pDwmSetWindowAttribute(hwnd, _DWMWA_MICA_EFFECT, &enable, sizeof(enable));
                 }
-                static constexpr const MARGINS margins = {0, 0, 0, 0};
-                apis.pDwmExtendFrameIntoClientArea(hwnd, &margins);
+                apis.pDwmExtendFrameIntoClientArea(hwnd, &defaultMargins);
             }
             return true;
         } else if (key == QStringLiteral("mica-alt")) {
@@ -832,8 +832,7 @@
             if (attribute.toBool()) {
                 // We need to extend the window frame into the whole client area to be able
                 // to see the blurred window background.
-                static constexpr const MARGINS margins = {-1, -1, -1, -1};
-                apis.pDwmExtendFrameIntoClientArea(hwnd, &margins);
+                apis.pDwmExtendFrameIntoClientArea(hwnd, &extendMargins);
                 // Use official DWM API to enable Mica Alt, available since Windows 11 22H2
                 // (10.0.22621).
                 const _DWM_SYSTEMBACKDROP_TYPE backdropType = _DWMSBT_TABBEDWINDOW;
@@ -843,8 +842,7 @@
                 const _DWM_SYSTEMBACKDROP_TYPE backdropType = _DWMSBT_AUTO;
                 apis.pDwmSetWindowAttribute(hwnd, _DWMWA_SYSTEMBACKDROP_TYPE, &backdropType,
                                             sizeof(backdropType));
-                static constexpr const MARGINS margins = {0, 0, 0, 0};
-                apis.pDwmExtendFrameIntoClientArea(hwnd, &margins);
+                apis.pDwmExtendFrameIntoClientArea(hwnd, &defaultMargins);
             }
             return true;
         } else if (key == QStringLiteral("acrylic-material")) {
@@ -854,8 +852,7 @@
             if (attribute.userType() == QMetaType::QColor) {
                 // We need to extend the window frame into the whole client area to be able
                 // to see the blurred window background.
-                static constexpr const MARGINS margins = {-1, -1, -1, -1};
-                apis.pDwmExtendFrameIntoClientArea(hwnd, &margins);
+                apis.pDwmExtendFrameIntoClientArea(hwnd, &extendMargins);
                 if (isWin11OrGreater()) {
                     const _DWM_SYSTEMBACKDROP_TYPE backdropType = _DWMSBT_TRANSIENTWINDOW;
                     apis.pDwmSetWindowAttribute(hwnd, _DWMWA_SYSTEMBACKDROP_TYPE, &backdropType,
@@ -891,16 +888,14 @@
                     wcad.cbData = sizeof(policy);
                     apis.pSetWindowCompositionAttribute(hwnd, &wcad);
                 }
-                static constexpr const MARGINS margins = {0, 0, 0, 0};
-                apis.pDwmExtendFrameIntoClientArea(hwnd, &margins);
+                apis.pDwmExtendFrameIntoClientArea(hwnd, &defaultMargins);
             }
             return true;
         } else if (key == QStringLiteral("dwm-blur")) {
             if (attribute.toBool()) {
                 // We need to extend the window frame into the whole client area to be able
                 // to see the blurred window background.
-                static constexpr const MARGINS margins = {-1, -1, -1, -1};
-                apis.pDwmExtendFrameIntoClientArea(hwnd, &margins);
+                apis.pDwmExtendFrameIntoClientArea(hwnd, &extendMargins);
                 if (isWin8OrGreater()) {
                     ACCENT_POLICY policy{};
                     policy.dwAccentState = ACCENT_ENABLE_BLURBEHIND;
@@ -913,8 +908,7 @@
                 } else {
                     DWM_BLURBEHIND bb{};
                     bb.fEnable = TRUE;
-                    bb.fTransitionOnMaximized = TRUE;
-                    bb.dwFlags = DWM_BB_ENABLE | DWM_BB_TRANSITIONONMAXIMIZED;
+                    bb.dwFlags = DWM_BB_ENABLE;
                     apis.pDwmEnableBlurBehindWindow(hwnd, &bb);
                 }
             } else {
@@ -933,8 +927,7 @@
                     bb.dwFlags = DWM_BB_ENABLE;
                     apis.pDwmEnableBlurBehindWindow(hwnd, &bb);
                 }
-                static constexpr const MARGINS margins = {0, 0, 0, 0};
-                apis.pDwmExtendFrameIntoClientArea(hwnd, &margins);
+                apis.pDwmExtendFrameIntoClientArea(hwnd, &defaultMargins);
             }
             return true;
         }
diff --git a/src/stylesupport/CMakeLists.txt b/src/stylesupport/CMakeLists.txt
deleted file mode 100644
index 787fa8c..0000000
--- a/src/stylesupport/CMakeLists.txt
+++ /dev/null
@@ -1,49 +0,0 @@
-project(QWKStyleSupport
-    VERSION ${QWINDOWKIT_VERSION}
-    LANGUAGES CXX
-)
-
-set(_src
-    qwkstylesupportglobal.h
-    styleagent.h
-    styleagent_p.h
-    styleagent.cpp
-)
-
-set(_links_private)
-
-if(WIN32)
-    list(APPEND _src
-        styleagent_win.cpp
-    )
-elseif(APPLE)
-    list(APPEND _links_private
-        "-framework Foundation"
-        "-framework Cocoa"
-        "-framework AppKit"
-    )
-    list(APPEND _src
-        styleagent_mac.cpp
-    )
-else()
-    list(APPEND _src
-        styleagent_linux.cpp
-    )
-endif()
-
-qwk_add_library(${PROJECT_NAME} AUTOGEN
-    SOURCES ${_src}
-    LINKS QWKCore
-    LINKS_PRIVATE ${_links_private}
-    QT_LINKS Core Gui
-    QT_INCLUDE_PRIVATE Core Gui
-    PREFIX QWK_STYLESUPPORT
-)
-
-set_target_properties(${PROJECT_NAME} PROPERTIES
-    CXX_STANDARD 17
-    CXX_STANDARD_REQUIRED TRUE
-)
-
-set(QWINDOWKIT_ENABLED_TARGETS ${QWINDOWKIT_ENABLED_TARGETS} ${PROJECT_NAME} PARENT_SCOPE)
-set(QWINDOWKIT_ENABLED_SUBDIRECTORIES ${QWINDOWKIT_ENABLED_SUBDIRECTORIES} stylesupport PARENT_SCOPE)
\ No newline at end of file
diff --git a/src/stylesupport/qwkstylesupportglobal.h b/src/stylesupport/qwkstylesupportglobal.h
deleted file mode 100644
index 27f8e31..0000000
--- a/src/stylesupport/qwkstylesupportglobal.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef QWKSTYLESUPPORTGLOBAL_H
-#define QWKSTYLESUPPORTGLOBAL_H
-
-#include <QtCore/QtGlobal>
-
-#ifndef QWK_STYLESUPPORT_EXPORT
-#  ifdef QWK_STYLESUPPORT_STATIC
-#    define QWK_STYLESUPPORT_EXPORT
-#  else
-#    ifdef QWK_STYLESUPPORT_LIBRARY
-#      define QWK_STYLESUPPORT_EXPORT Q_DECL_EXPORT
-#    else
-#      define QWK_STYLESUPPORT_EXPORT Q_DECL_IMPORT
-#    endif
-#  endif
-#endif
-
-#endif // QWKSTYLESUPPORTGLOBAL_H
diff --git a/src/stylesupport/styleagent.cpp b/src/stylesupport/styleagent.cpp
deleted file mode 100644
index d24186f..0000000
--- a/src/stylesupport/styleagent.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-#include "styleagent.h"
-#include "styleagent_p.h"
-
-#include <QtCore/QVariant>
-
-namespace QWK {
-
-    StyleAgentPrivate::StyleAgentPrivate() {
-    }
-
-    StyleAgentPrivate::~StyleAgentPrivate() = default;
-
-    void StyleAgentPrivate::init() {
-    }
-
-    void StyleAgentPrivate::notifyThemeChanged(StyleAgent::SystemTheme theme) {
-        if (theme == systemTheme)
-            return;
-        systemTheme = theme;
-
-        Q_Q(StyleAgent);
-        Q_EMIT q->systemThemeChanged();
-    }
-
-    void StyleAgentPrivate::_q_windowDestroyed() {
-        windowAttributes.remove(static_cast<QWindow *>(sender()));
-    }
-
-    StyleAgent::StyleAgent(QObject *parent) : StyleAgent(*new StyleAgentPrivate(), parent) {
-        Q_D(StyleAgent);
-        d->setupSystemThemeHook();
-    }
-
-    StyleAgent::~StyleAgent() {
-        Q_D(StyleAgent);
-        d->removeSystemThemeHook();
-    }
-
-    StyleAgent::SystemTheme StyleAgent::systemTheme() const {
-        Q_D(const StyleAgent);
-        return d->systemTheme;
-    }
-
-    QVariant StyleAgent::windowAttribute(QWindow *window, const QString &key) const {
-        Q_D(const StyleAgent);
-        return d->windowAttributes.value(window).value(key);
-    }
-
-    bool StyleAgent::setWindowAttribute(QWindow *window, const QString &key,
-                                        const QVariant &attribute) {
-        Q_D(StyleAgent);
-        if (!window)
-            return false;
-
-        auto it = d->windowAttributes.find(window);
-        if (it == d->windowAttributes.end()) {
-            if (!attribute.isValid())
-                return true;
-            if (!d->updateWindowAttribute(window, key, attribute, {}))
-                return false;
-            connect(window, &QWindow::destroyed, d, &StyleAgentPrivate::_q_windowDestroyed);
-            d->windowAttributes.insert(window, QVariantHash{
-                                                   {key, attribute}
-            });
-        } else {
-            auto &attributes = it.value();
-            auto oldAttribute = attributes.value(key);
-            if (oldAttribute == attribute)
-                return true;
-            if (!d->updateWindowAttribute(window, key, attribute, oldAttribute))
-                return false;
-            attributes.insert(key, attribute);
-        }
-        return true;
-    }
-
-    StyleAgent::StyleAgent(StyleAgentPrivate &d, QObject *parent) : QObject(parent), d_ptr(&d) {
-        d.q_ptr = this;
-
-        d.init();
-    }
-
-}
diff --git a/src/stylesupport/styleagent.h b/src/stylesupport/styleagent.h
deleted file mode 100644
index 94afa33..0000000
--- a/src/stylesupport/styleagent.h
+++ /dev/null
@@ -1,47 +0,0 @@
-#ifndef STYLEAGENT_H
-#define STYLEAGENT_H
-
-#include <memory>
-
-#include <QtCore/QObject>
-#include <QtGui/QWindow>
-
-#include <QWKStyleSupport/qwkstylesupportglobal.h>
-
-namespace QWK {
-
-    class StyleAgentPrivate;
-
-    class QWK_STYLESUPPORT_EXPORT StyleAgent : public QObject {
-        Q_OBJECT
-        Q_DECLARE_PRIVATE(StyleAgent)
-    public:
-        explicit StyleAgent(QObject *parent = nullptr);
-        ~StyleAgent() override;
-
-        enum SystemTheme {
-            Unknown,
-            Light,
-            Dark,
-            HighContrast,
-        };
-        Q_ENUM(SystemTheme)
-
-    public:
-        SystemTheme systemTheme() const;
-
-        QVariant windowAttribute(QWindow *window, const QString &key) const;
-        bool setWindowAttribute(QWindow *window, const QString &key, const QVariant &attribute);
-
-    Q_SIGNALS:
-        void systemThemeChanged(); // Do we need wallpaper change notify?
-
-    protected:
-        StyleAgent(StyleAgentPrivate &d, QObject *parent = nullptr);
-
-        const std::unique_ptr<StyleAgentPrivate> d_ptr;
-    };
-
-}
-
-#endif // STYLEAGENT_H
\ No newline at end of file
diff --git a/src/stylesupport/styleagent_linux.cpp b/src/stylesupport/styleagent_linux.cpp
deleted file mode 100644
index 3c83589..0000000
--- a/src/stylesupport/styleagent_linux.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-#include "styleagent_p.h"
-
-#include <QtCore/QVariant>
-
-namespace QWK {
-
-    void StyleAgentPrivate::setupSystemThemeHook() {
-    }
-
-    void StyleAgentPrivate::removeSystemThemeHook() {
-    }
-
-    bool StyleAgentPrivate::updateWindowAttribute(QWindow *window, const QString &key,
-                                                  const QVariant &attribute,
-                                                  const QVariant &oldAttribute) {
-        Q_UNUSED(oldAttribute)
-        return false;
-    }
-
-}
\ No newline at end of file
diff --git a/src/stylesupport/styleagent_mac.mm b/src/stylesupport/styleagent_mac.mm
deleted file mode 100644
index 64cdf16..0000000
--- a/src/stylesupport/styleagent_mac.mm
+++ /dev/null
@@ -1,29 +0,0 @@
-#include "styleagent_p.h"
-
-#include <QtCore/QVariant>
-
-namespace QWK {
-
-    void StyleAgentPrivate::setupSystemThemeHook() {
-    }
-
-    void StyleAgentPrivate::removeSystemThemeHook() {
-    }
-
-    bool StyleAgentPrivate::updateWindowAttribute(QWindow *window, const QString &key,
-                                                  const QVariant &attribute,
-                                                  const QVariant &oldAttribute) {
-        Q_UNUSED(oldAttribute)
-
-        if (key == QStringLiteral("no-system-buttons")) {
-            if (attribute.toBool()) {
-                // TODO: set off
-            } else {
-                // TODO: set on
-            }
-            return true;
-        }
-        return false;
-    }
-
-}
\ No newline at end of file
diff --git a/src/stylesupport/styleagent_p.h b/src/stylesupport/styleagent_p.h
deleted file mode 100644
index 739a0b1..0000000
--- a/src/stylesupport/styleagent_p.h
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef STYLEAGENTPRIVATE_H
-#define STYLEAGENTPRIVATE_H
-
-//
-//  W A R N I N G !!!
-//  -----------------
-//
-// This file is not part of the QWindowKit API. It is used purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or may even be removed.
-//
-
-#include <QWKStyleSupport/styleagent.h>
-#include <QtCore/QHash>
-
-namespace QWK {
-
-    class StyleAgentPrivate : public QObject {
-        Q_DECLARE_PUBLIC(StyleAgent)
-    public:
-        StyleAgentPrivate();
-        ~StyleAgentPrivate() override;
-
-        void init();
-
-        StyleAgent *q_ptr;
-
-        StyleAgent::SystemTheme systemTheme = StyleAgent::Dark;
-        QHash<QWindow *, QVariantHash> windowAttributes;
-
-        virtual void setupSystemThemeHook();
-        virtual void removeSystemThemeHook();
-        virtual bool updateWindowAttribute(QWindow *window, const QString &key,
-                                           const QVariant &attribute, const QVariant &oldAttribute);
-
-        void notifyThemeChanged(StyleAgent::SystemTheme theme);
-
-    private:
-        void _q_windowDestroyed();
-    };
-
-}
-
-#endif // STYLEAGENTPRIVATE_H
\ No newline at end of file
diff --git a/src/stylesupport/styleagent_win.cpp b/src/stylesupport/styleagent_win.cpp
deleted file mode 100644
index 67b6532..0000000
--- a/src/stylesupport/styleagent_win.cpp
+++ /dev/null
@@ -1,242 +0,0 @@
-#include "styleagent_p.h"
-
-#include <QtCore/QSet>
-#include <QtCore/QVariant>
-#include <QtGui/QColor>
-
-#include <QWKCore/private/qwkwindowsextra_p.h>
-#include <QWKCore/private/nativeeventfilter_p.h>
-
-namespace QWK {
-
-    using StyleAgentSet = QSet<StyleAgentPrivate *>;
-    Q_GLOBAL_STATIC(StyleAgentSet, g_styleAgentSet)
-
-    class SystemSettingEventFilter : public AppNativeEventFilter {
-    public:
-        bool nativeEventFilter(const QByteArray &eventType, void *message,
-                               QT_NATIVE_EVENT_RESULT_TYPE *result) override {
-            Q_UNUSED(eventType)
-            if (!result) {
-                return false;
-            }
-
-            const auto msg = static_cast<const MSG *>(message);
-            switch (msg->message) {
-                case WM_THEMECHANGED:
-                case WM_SYSCOLORCHANGE:
-                case WM_DWMCOLORIZATIONCOLORCHANGED: {
-                    // TODO: walk through `g_styleAgentSet`
-                    break;
-                }
-
-                case WM_SETTINGCHANGE: {
-                    if (!msg->wParam && msg->lParam &&
-                        std::wcscmp(reinterpret_cast<LPCWSTR>(msg->lParam), L"ImmersiveColorSet") ==
-                            0) {
-                        // TODO: walk through `g_styleAgentSet`
-                    }
-                    break;
-                }
-
-                default:
-                    break;
-            }
-            return false;
-        }
-
-        static SystemSettingEventFilter *instance;
-
-        static inline void install() {
-            if (instance) {
-                return;
-            }
-            instance = new SystemSettingEventFilter();
-        }
-
-        static inline void uninstall() {
-            if (!instance) {
-                return;
-            }
-            delete instance;
-            instance = nullptr;
-        }
-    };
-
-    SystemSettingEventFilter *SystemSettingEventFilter::instance = nullptr;
-
-    void StyleAgentPrivate::setupSystemThemeHook() {
-        g_styleAgentSet->insert(this);
-        SystemSettingEventFilter::install();
-
-        // Initialize `systemTheme` variable
-    }
-
-    void StyleAgentPrivate::removeSystemThemeHook() {
-        if (!g_styleAgentSet->remove(this))
-            return;
-
-        if (g_styleAgentSet->isEmpty()) {
-            SystemSettingEventFilter::uninstall();
-        }
-    }
-
-    bool StyleAgentPrivate::updateWindowAttribute(QWindow *window, const QString &key,
-                                                  const QVariant &attribute,
-                                                  const QVariant &oldAttribute) {
-        Q_UNUSED(oldAttribute)
-
-        const auto hwnd = reinterpret_cast<HWND>(window->winId());
-        const DynamicApis &apis = DynamicApis::instance();
-
-        if (key == QStringLiteral("mica")) {
-            if (!isWin11OrGreater()) {
-                return false;
-            }
-            if (attribute.toBool()) {
-                // We need to extend the window frame into the whole client area to be able
-                // to see the blurred window background.
-                static constexpr const MARGINS margins = {-1, -1, -1, -1};
-                apis.pDwmExtendFrameIntoClientArea(hwnd, &margins);
-                if (isWin1122H2OrGreater()) {
-                    // Use official DWM API to enable Mica, available since Windows 11 22H2
-                    // (10.0.22621).
-                    const _DWM_SYSTEMBACKDROP_TYPE backdropType = _DWMSBT_MAINWINDOW;
-                    apis.pDwmSetWindowAttribute(hwnd, _DWMWA_SYSTEMBACKDROP_TYPE, &backdropType,
-                                                sizeof(backdropType));
-                } else {
-                    // Use undocumented DWM API to enable Mica, available since Windows 11
-                    // (10.0.22000).
-                    const BOOL enable = TRUE;
-                    apis.pDwmSetWindowAttribute(hwnd, _DWMWA_MICA_EFFECT, &enable, sizeof(enable));
-                }
-            } else {
-                if (isWin1122H2OrGreater()) {
-                    const _DWM_SYSTEMBACKDROP_TYPE backdropType = _DWMSBT_AUTO;
-                    apis.pDwmSetWindowAttribute(hwnd, _DWMWA_SYSTEMBACKDROP_TYPE, &backdropType,
-                                                sizeof(backdropType));
-                } else {
-                    const BOOL enable = FALSE;
-                    apis.pDwmSetWindowAttribute(hwnd, _DWMWA_MICA_EFFECT, &enable, sizeof(enable));
-                }
-                static constexpr const MARGINS margins = {0, 0, 0, 0};
-                apis.pDwmExtendFrameIntoClientArea(hwnd, &margins);
-            }
-            return true;
-        } else if (key == QStringLiteral("mica-alt")) {
-            if (!isWin1122H2OrGreater()) {
-                return false;
-            }
-            if (attribute.toBool()) {
-                // We need to extend the window frame into the whole client area to be able
-                // to see the blurred window background.
-                static constexpr const MARGINS margins = {-1, -1, -1, -1};
-                apis.pDwmExtendFrameIntoClientArea(hwnd, &margins);
-                // Use official DWM API to enable Mica Alt, available since Windows 11 22H2
-                // (10.0.22621).
-                const _DWM_SYSTEMBACKDROP_TYPE backdropType = _DWMSBT_TABBEDWINDOW;
-                apis.pDwmSetWindowAttribute(hwnd, _DWMWA_SYSTEMBACKDROP_TYPE, &backdropType,
-                                            sizeof(backdropType));
-            } else {
-                const _DWM_SYSTEMBACKDROP_TYPE backdropType = _DWMSBT_AUTO;
-                apis.pDwmSetWindowAttribute(hwnd, _DWMWA_SYSTEMBACKDROP_TYPE, &backdropType,
-                                            sizeof(backdropType));
-                static constexpr const MARGINS margins = {0, 0, 0, 0};
-                apis.pDwmExtendFrameIntoClientArea(hwnd, &margins);
-            }
-            return true;
-        } else if (key == QStringLiteral("acrylic-material")) {
-            if (!isWin10OrGreater()) {
-                return false;
-            }
-            if (attribute.userType() == QMetaType::QColor) {
-                // We need to extend the window frame into the whole client area to be able
-                // to see the blurred window background.
-                static constexpr const MARGINS margins = {-1, -1, -1, -1};
-                apis.pDwmExtendFrameIntoClientArea(hwnd, &margins);
-                if (isWin11OrGreater()) {
-                    const _DWM_SYSTEMBACKDROP_TYPE backdropType = _DWMSBT_TRANSIENTWINDOW;
-                    apis.pDwmSetWindowAttribute(hwnd, _DWMWA_SYSTEMBACKDROP_TYPE, &backdropType,
-                                                sizeof(backdropType));
-                } else {
-                    auto gradientColor = attribute.value<QColor>();
-
-                    ACCENT_POLICY policy{};
-                    policy.dwAccentState = ACCENT_ENABLE_ACRYLICBLURBEHIND;
-                    policy.dwAccentFlags = ACCENT_ENABLE_ACRYLIC_WITH_LUMINOSITY;
-                    // This API expects the #AABBGGRR format.
-                    policy.dwGradientColor =
-                        DWORD(qRgba(gradientColor.blue(), gradientColor.green(),
-                                    gradientColor.red(), gradientColor.alpha()));
-                    WINDOWCOMPOSITIONATTRIBDATA wcad{};
-                    wcad.Attrib = WCA_ACCENT_POLICY;
-                    wcad.pvData = &policy;
-                    wcad.cbData = sizeof(policy);
-                    apis.pSetWindowCompositionAttribute(hwnd, &wcad);
-                }
-            } else {
-                if (isWin11OrGreater()) {
-                    const _DWM_SYSTEMBACKDROP_TYPE backdropType = _DWMSBT_AUTO;
-                    apis.pDwmSetWindowAttribute(hwnd, _DWMWA_SYSTEMBACKDROP_TYPE, &backdropType,
-                                                sizeof(backdropType));
-                } else {
-                    ACCENT_POLICY policy{};
-                    policy.dwAccentState = ACCENT_DISABLED;
-                    policy.dwAccentFlags = ACCENT_NONE;
-                    WINDOWCOMPOSITIONATTRIBDATA wcad{};
-                    wcad.Attrib = WCA_ACCENT_POLICY;
-                    wcad.pvData = &policy;
-                    wcad.cbData = sizeof(policy);
-                    apis.pSetWindowCompositionAttribute(hwnd, &wcad);
-                }
-                static constexpr const MARGINS margins = {0, 0, 0, 0};
-                apis.pDwmExtendFrameIntoClientArea(hwnd, &margins);
-            }
-            return true;
-        } else if (key == QStringLiteral("dwm-blur")) {
-            if (attribute.toBool()) {
-                // We need to extend the window frame into the whole client area to be able
-                // to see the blurred window background.
-                static constexpr const MARGINS margins = {-1, -1, -1, -1};
-                apis.pDwmExtendFrameIntoClientArea(hwnd, &margins);
-                if (isWin8OrGreater()) {
-                    ACCENT_POLICY policy{};
-                    policy.dwAccentState = ACCENT_ENABLE_BLURBEHIND;
-                    policy.dwAccentFlags = ACCENT_NONE;
-                    WINDOWCOMPOSITIONATTRIBDATA wcad{};
-                    wcad.Attrib = WCA_ACCENT_POLICY;
-                    wcad.pvData = &policy;
-                    wcad.cbData = sizeof(policy);
-                    apis.pSetWindowCompositionAttribute(hwnd, &wcad);
-                } else {
-                    DWM_BLURBEHIND bb{};
-                    bb.fEnable = TRUE;
-                    bb.fTransitionOnMaximized = TRUE;
-                    bb.dwFlags = DWM_BB_ENABLE | DWM_BB_TRANSITIONONMAXIMIZED;
-                    apis.pDwmEnableBlurBehindWindow(hwnd, &bb);
-                }
-            } else {
-                if (isWin8OrGreater()) {
-                    ACCENT_POLICY policy{};
-                    policy.dwAccentState = ACCENT_DISABLED;
-                    policy.dwAccentFlags = ACCENT_NONE;
-                    WINDOWCOMPOSITIONATTRIBDATA wcad{};
-                    wcad.Attrib = WCA_ACCENT_POLICY;
-                    wcad.pvData = &policy;
-                    wcad.cbData = sizeof(policy);
-                    apis.pSetWindowCompositionAttribute(hwnd, &wcad);
-                } else {
-                    DWM_BLURBEHIND bb{};
-                    bb.fEnable = FALSE;
-                    bb.dwFlags = DWM_BB_ENABLE;
-                    apis.pDwmEnableBlurBehindWindow(hwnd, &bb);
-                }
-                static constexpr const MARGINS margins = {0, 0, 0, 0};
-                apis.pDwmExtendFrameIntoClientArea(hwnd, &margins);
-            }
-            return true;
-        }
-        return false;
-    }
-
-}
\ No newline at end of file

--
Gitblit v1.9.1