Sine Striker
2024-02-25 6f6f96909e7ded6ae3a4e59d9d4b62fa593abb23
Fix quick initialization failure
7个文件已修改
58 ■■■■ 已修改文件
src/core/contexts/abstractwindowcontext.cpp 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/core/contexts/abstractwindowcontext_p.h 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/core/kernel/winidchangeeventfilter.cpp 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/core/kernel/winidchangeeventfilter_p.h 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/core/windowitemdelegate.cpp 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/quick/quickwindowagent_win.cpp 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/widgets/widgetwindowagent_win.cpp 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/core/contexts/abstractwindowcontext.cpp
@@ -260,6 +260,12 @@
                m_windowAttributes.insert(it.key(), it.value());
            }
        }
        // Send to shared dispatchers
        if (oldWinId != m_windowId) {
            QEvent e(QEvent::WinIdChange);
            sharedDispatch(m_host, &e);
        }
    }
    QVariant AbstractWindowContext::windowAttribute(const QString &key) const {
src/core/contexts/abstractwindowcontext_p.h
@@ -43,6 +43,7 @@
        inline QObject *host() const;
        inline QWindow *window() const;
        inline WId windowId() const;
        inline WindowItemDelegate *delegate() const;
        inline bool isHitTestVisible(const QObject *obj) const;
@@ -114,6 +115,10 @@
        return m_windowHandle;
    }
    inline WId AbstractWindowContext::windowId() const {
        return m_windowId;
    }
    inline WindowItemDelegate *AbstractWindowContext::delegate() const {
        return m_delegate.get();
    }
src/core/kernel/winidchangeeventfilter.cpp
@@ -10,6 +10,12 @@
namespace QWK {
    WindowWinIdChangeEventFilter::WindowWinIdChangeEventFilter(QWindow *host,
                                                               AbstractWindowContext *context)
        : WinIdChangeEventFilter(host, context), win(host), isAboutToBeDestroyed(false) {
        host->installEventFilter(this);
    }
    WId WindowWinIdChangeEventFilter::winId() const {
        auto win = static_cast<QWindow *>(host);
        if (isAboutToBeDestroyed)
src/core/kernel/winidchangeeventfilter_p.h
@@ -37,10 +37,7 @@
    class QWK_CORE_EXPORT WindowWinIdChangeEventFilter : public WinIdChangeEventFilter {
    public:
        WindowWinIdChangeEventFilter(QObject *host, AbstractWindowContext *context)
            : WinIdChangeEventFilter(host, context), win(static_cast<QWindow *>(host)),
              isAboutToBeDestroyed(false) {
        }
        WindowWinIdChangeEventFilter(QWindow *host, AbstractWindowContext *context);
        WId winId() const override;
src/core/windowitemdelegate.cpp
@@ -17,7 +17,7 @@
    WinIdChangeEventFilter *
        WindowItemDelegate::createWinIdEventFilter(QObject *host,
                                                   AbstractWindowContext *context) const {
        return new WindowWinIdChangeEventFilter(host, context);
        return new WindowWinIdChangeEventFilter(static_cast<QWindow *>(host), context);
    }
}
src/quick/quickwindowagent_win.cpp
@@ -56,7 +56,8 @@
        anchors->setLeft(parentPri->left());
        anchors->setRight(parentPri->right());
        setZ(std::numeric_limits<qreal>::max()); // Make sure our fake border always above everything in the window.
        setZ(std::numeric_limits<qreal>::max()); // Make sure our fake border always above
                                                 // everything in the window.
        context->installNativeEventFilter(this);
        context->installSharedEventFilter(this);
@@ -132,6 +133,12 @@
        Q_UNUSED(obj)
        
        switch (event->type()) {
            case QEvent::WinIdChange: {
                if (auto winId = context->windowId()) {
                    updateGeometry();
                }
                break;
            }
            case QEvent::WindowStateChange: {
                updateGeometry();
                break;
src/widgets/widgetwindowagent_win.cpp
@@ -136,22 +136,31 @@
            Q_UNUSED(obj)
            auto window = widget->windowHandle();
            switch (event->type()) {
                case QEvent::Expose: {
            // Qt will absolutely send a QExposeEvent or QResizeEvent to the QWindow when it
            // receives a WM_PAINT message. When the control flow enters the expose handler, Qt
            // must have already called BeginPaint() and it's the best time for us to draw the
            // top border.
                    // receives a WM_PAINT message. When the control flow enters the expose handler,
                    // Qt must have already called BeginPaint() and it's the best time for us to
                    // draw the top border.
            // Since a QExposeEvent will be sent immediately after the QResizeEvent, we can simply
            // ignore it.
            if (event->type() == QEvent::Expose) {
                    // Since a QExposeEvent will be sent immediately after the QResizeEvent, we can
                    // simply ignore it.
                auto ee = static_cast<QExposeEvent *>(event);
                if (window->isExposed() && isNormalWindow() && !ee->region().isNull()) {
                    resumeWindowEventAndDraw(window, event);
                    return true;
                }
                    break;
            }
                case QEvent::WinIdChange: {
                    if (auto winId = ctx->windowId()) {
                        updateGeometry();
                    }
                    break;
                }
                default:
                    break;
            }
            return false;
        }