From c9261fbd7019264e8543507e3afaec63d55595a2 Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <zhaoyuhang@rankyee.com> Date: 周三, 06 12月 2023 10:58:07 +0800 Subject: [PATCH] fix stupid code --- src/core/contexts/abstractwindowcontext_p.h | 28 +++++++++++++++++----------- 1 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/core/contexts/abstractwindowcontext_p.h b/src/core/contexts/abstractwindowcontext_p.h index a633b18..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> @@ -12,20 +15,15 @@ class QWK_CORE_EXPORT AbstractWindowContext : public QObject { Q_OBJECT - Q_DISABLE_COPY(AbstractWindowContext) - public: - inline AbstractWindowContext(QWindow *window, WindowItemDelegatePtr delegate) - : m_windowHandle(window), m_delegate(std::move(delegate)) - { - } + 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); @@ -39,9 +37,14 @@ 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; - WindowItemDelegatePtr m_delegate; QSet<QObject *> m_hitTestVisibleItems; QList<QRect> m_hitTestVisibleRects; @@ -49,9 +52,14 @@ QObject *m_titleBar{}; 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; @@ -69,8 +77,6 @@ inline QObject *AbstractWindowContext::titleBar() const { return m_titleBar; } - - using WindowContextPtr = std::shared_ptr<AbstractWindowContext>; } -- Gitblit v1.9.1