From 3cfe15a9c3db0993d8b8fef5d148625840e5a75c Mon Sep 17 00:00:00 2001 From: Sine Striker <trueful@163.com> Date: 周二, 05 12月 2023 15:43:39 +0800 Subject: [PATCH] Add host interface --- src/core/contexts/abstractwindowcontext_p.h | 27 +++++++++++++++++++-------- 1 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/core/contexts/abstractwindowcontext_p.h b/src/core/contexts/abstractwindowcontext_p.h index fd3a445..996a0e3 100644 --- a/src/core/contexts/abstractwindowcontext_p.h +++ b/src/core/contexts/abstractwindowcontext_p.h @@ -1,6 +1,9 @@ #ifndef ABSTRACTWINDOWCONTEXT_P_H #define ABSTRACTWINDOWCONTEXT_P_H +#include <array> +#include <memory> + #include <QtCore/QSet> #include <QtGui/QWindow> #include <QtGui/QPolygon> @@ -13,16 +16,14 @@ class QWK_CORE_EXPORT AbstractWindowContext : public QObject { Q_OBJECT public: - inline AbstractWindowContext(QWindow *window, WindowItemDelegate *delegate) - : m_windowHandle(window), m_delegate(delegate) { - } - ~AbstractWindowContext(); + AbstractWindowContext(QObject *host, WindowItemDelegate *delegate); + ~AbstractWindowContext() override; public: virtual bool setup() = 0; + inline QObject *host() const; inline QWindow *window() const; - void setupWindow(QWindow *window); inline bool isHitTestVisible(QObject *obj) const; bool setHitTestVisible(QObject *obj, bool visible); @@ -36,20 +37,30 @@ 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; QList<QRect> m_hitTestVisibleRects; QObject *m_titleBar{}; - QObject *m_systemButtons[CoreWindowAgent::NumSystemButton]{}; + std::array<QObject *, CoreWindowAgent::NumSystemButton> m_systemButtons{}; + // Cached shape mutable bool hitTestVisibleShapeDirty{}; - mutable QPolygon hitTestVisibleShape; + mutable QRegion hitTestVisibleShape; }; + inline QObject *AbstractWindowContext::host() const { + return m_host; + } + inline QWindow *AbstractWindowContext::window() const { return m_windowHandle; } -- Gitblit v1.9.1