Zhao Yuhang
2023-12-22 0cedc474f38dca024f77ebf1d7ac5bf22c19744a
fix compile error on win
2个文件已修改
8个文件已删除
579 ■■■■■ 已修改文件
examples/mainwindow/mainwindow.cpp 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/core/contexts/win32windowcontext.cpp 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/stylesupport/CMakeLists.txt 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/stylesupport/qwkstylesupportglobal.h 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/stylesupport/styleagent.cpp 83 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/stylesupport/styleagent.h 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/stylesupport/styleagent_linux.cpp 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/stylesupport/styleagent_mac.mm 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/stylesupport/styleagent_p.h 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/stylesupport/styleagent_win.cpp 242 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
examples/mainwindow/mainwindow.cpp
@@ -8,7 +8,11 @@
#include <QtWidgets/QApplication>
#include <QtWidgets/QStyle>
#include <QtWidgets/QPushButton>
#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);
        });
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;
        }
src/stylesupport/CMakeLists.txt
File was deleted
src/stylesupport/qwkstylesupportglobal.h
File was deleted
src/stylesupport/styleagent.cpp
File was deleted
src/stylesupport/styleagent.h
File was deleted
src/stylesupport/styleagent_linux.cpp
File was deleted
src/stylesupport/styleagent_mac.mm
File was deleted
src/stylesupport/styleagent_p.h
File was deleted
src/stylesupport/styleagent_win.cpp
File was deleted