Sine Striker
2023-12-07 1a1f26d9e4ab6a4fe51baa78e40c4cdf3f402bcf
src/core/contexts/abstractwindowcontext_p.h
@@ -2,6 +2,7 @@
#define ABSTRACTWINDOWCONTEXT_P_H
#include <array>
#include <memory>
#include <QtCore/QSet>
#include <QtGui/QWindow>
@@ -15,60 +16,65 @@
    class QWK_CORE_EXPORT AbstractWindowContext : public QObject {
        Q_OBJECT
    public:
        inline AbstractWindowContext(QWindow *window, WindowItemDelegate *delegate)
            : m_windowHandle(window), m_delegate(delegate) {
        }
        AbstractWindowContext();
        ~AbstractWindowContext() override;
    public:
        virtual bool setup() = 0;
        virtual bool setup(QObject *host, WindowItemDelegate *delegate);
        inline QObject *host() const;
        inline QWindow *window() const;
        void setupWindow(QWindow *window);
        inline bool isHitTestVisible(QObject *obj) const;
        bool setHitTestVisible(QObject *obj, bool visible);
        inline bool isHitTestVisible(const QObject *obj) const;
        bool setHitTestVisible(const QObject *obj, bool visible);
        bool setHitTestVisible(const QRect &rect, bool visible);
        inline QObject *systemButton(CoreWindowAgent::SystemButton button) const;
        bool setSystemButton(CoreWindowAgent::SystemButton button, QObject *obj);
        inline const QObject *systemButton(CoreWindowAgent::SystemButton button) const;
        bool setSystemButton(CoreWindowAgent::SystemButton button, const QObject *obj);
        inline QObject *titleBar() const;
        bool setTitleBar(QObject *obj);
        inline const QObject *titleBar() const;
        bool setTitleBar(const QObject *obj);
        void showSystemMenu(const QPoint &pos);
        QRegion hitTestShape() const;
        bool isInSystemButtons(const QPoint &pos, CoreWindowAgent::SystemButton *button) const;
        bool isInTitleBarDraggableArea(const QPoint &pos) const;
    protected:
        QObject *m_host;
        std::unique_ptr<WindowItemDelegate> m_delegate;
        QWindow *m_windowHandle;
        WindowItemDelegate *m_delegate;
        QSet<QObject *> m_hitTestVisibleItems;
        QSet<const QObject *> m_hitTestVisibleItems;
        QList<QRect> m_hitTestVisibleRects;
        QObject *m_titleBar{};
        std::array<QObject *, CoreWindowAgent::NumSystemButton> m_systemButtons{};
        const QObject *m_titleBar{};
        std::array<const QObject *, CoreWindowAgent::NumSystemButton> m_systemButtons{};
        // Cached shape
        mutable bool hitTestVisibleShapeDirty{};
        mutable QRegion hitTestVisibleShape;
    };
    inline QObject *AbstractWindowContext::host() const {
        return m_host;
    }
    inline QWindow *AbstractWindowContext::window() const {
        return m_windowHandle;
    }
    inline bool AbstractWindowContext::isHitTestVisible(QObject *obj) const {
    inline bool AbstractWindowContext::isHitTestVisible(const QObject *obj) const {
        return m_hitTestVisibleItems.contains(obj);
    }
    inline QObject *
    inline const QObject *
        AbstractWindowContext::systemButton(CoreWindowAgent::SystemButton button) const {
        return m_systemButtons[button];
    }
    inline QObject *AbstractWindowContext::titleBar() const {
    inline const QObject *AbstractWindowContext::titleBar() const {
        return m_titleBar;
    }