Sine Striker
2023-12-26 1740ed5e0e765ebd8676733243eb3eaa81f95df1
Fix window visibility inconsistency
8个文件已修改
18 ■■■■■ 已修改文件
src/core/contexts/abstractwindowcontext.cpp 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/core/contexts/win32windowcontext.cpp 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/core/windowitemdelegate_p.h 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/quick/quickitemdelegate.cpp 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/quick/quickitemdelegate_p.h 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/widgets/widgetitemdelegate.cpp 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/widgets/widgetitemdelegate_p.h 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/widgets/widgetwindowagent_win.cpp 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/core/contexts/abstractwindowcontext.cpp
@@ -211,6 +211,10 @@
            }
            case RaiseWindowHook: {
                if (!m_windowHandle)
                    return;
                m_delegate->setWindowVisible(m_host, true);
                Qt::WindowStates state = m_delegate->getWindowState(m_host);
                if (state & Qt::WindowMinimized) {
                    m_delegate->setWindowState(m_host, state & ~Qt::WindowMinimized);
src/core/contexts/win32windowcontext.cpp
@@ -573,6 +573,7 @@
            case RaiseWindowHook: {
                if (!windowId)
                    return;
                m_delegate->setWindowVisible(m_host, true);
                const auto hwnd = reinterpret_cast<HWND>(windowId);
                bringWindowToFront(hwnd);
                return;
src/core/windowitemdelegate_p.h
@@ -43,6 +43,7 @@
        virtual void setCursorShape(QObject *host, Qt::CursorShape shape) const = 0;
        virtual void restoreCursorShape(QObject *host) const = 0;
        virtual void setWindowFlags(QObject *host, Qt::WindowFlags flags) const = 0;
        virtual void setWindowVisible(QObject *host, bool visible) const = 0;
        virtual void bringWindowToTop(QObject *host) const = 0;
    private:
src/quick/quickitemdelegate.cpp
@@ -68,6 +68,10 @@
        static_cast<QQuickWindow *>(host)->setFlags(flags);
    }
    void QuickItemDelegate::setWindowVisible(QObject *host, bool visible) const {
        static_cast<QQuickWindow *>(host)->setVisible(visible);
    }
    void QuickItemDelegate::bringWindowToTop(QObject *host) const {
        static_cast<QQuickWindow *>(host)->raise();
    }
src/quick/quickitemdelegate_p.h
@@ -39,6 +39,7 @@
        void setCursorShape(QObject *host, Qt::CursorShape shape) const override;
        void restoreCursorShape(QObject *host) const override;
        void setWindowFlags(QObject *host, Qt::WindowFlags flags) const override;
        void setWindowVisible(QObject *host, bool visible) const override;
        void bringWindowToTop(QObject *host) const override;
    };
src/widgets/widgetitemdelegate.cpp
@@ -92,6 +92,10 @@
        static_cast<QWidget *>(host)->setWindowFlags(flags);
    }
    void WidgetItemDelegate::setWindowVisible(QObject *host, bool visible) const {
        static_cast<QWidget *>(host)->setVisible(visible);
    }
    void WidgetItemDelegate::bringWindowToTop(QObject *host) const {
        static_cast<QWidget *>(host)->raise();
    }
src/widgets/widgetitemdelegate_p.h
@@ -40,6 +40,7 @@
        void setCursorShape(QObject *host, Qt::CursorShape shape) const override;
        void restoreCursorShape(QObject *host) const override;
        void setWindowFlags(QObject *host, Qt::WindowFlags flags) const override;
        void setWindowVisible(QObject *host, bool visible) const override;
        void bringWindowToTop(QObject *host) const override;
    };
src/widgets/widgetwindowagent_win.cpp
@@ -45,7 +45,7 @@
            ctx->setWindowAttribute(QStringLiteral("extra-margins"), defaultMargins);
            // Enable dark mode by default, otherwise the frame borders are white
            // ctx->setWindowAttribute(QStringLiteral("dark-mode"), true);
            ctx->setWindowAttribute(QStringLiteral("dark-mode"), true);
            ctx->installNativeEventFilter(this);
            ctx->installSharedEventFilter(this);