From 499afac952920595e6c3d4f94806427f894c7674 Mon Sep 17 00:00:00 2001
From: Sine Striker <trueful@163.com>
Date: 周六, 02 12月 2023 19:05:24 +0800
Subject: [PATCH] optimize code

---
 src/core/contexts/abstractwindowcontext_p.h |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/core/contexts/abstractwindowcontext_p.h b/src/core/contexts/abstractwindowcontext_p.h
index a633b18..4c04734 100644
--- a/src/core/contexts/abstractwindowcontext_p.h
+++ b/src/core/contexts/abstractwindowcontext_p.h
@@ -1,6 +1,8 @@
 #ifndef ABSTRACTWINDOWCONTEXT_P_H
 #define ABSTRACTWINDOWCONTEXT_P_H
 
+#include <array>
+
 #include <QtCore/QSet>
 #include <QtGui/QWindow>
 #include <QtGui/QPolygon>
@@ -12,12 +14,9 @@
 
     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))
-        {
+        inline AbstractWindowContext(QWindow *window, WindowItemDelegate *delegate)
+            : m_windowHandle(window), m_delegate(delegate) {
         }
         ~AbstractWindowContext() override;
 
@@ -39,9 +38,11 @@
 
         void showSystemMenu(const QPoint &pos);
 
+        QRegion hitTestShape() const;
+
     protected:
         QWindow *m_windowHandle;
-        WindowItemDelegatePtr m_delegate;
+        WindowItemDelegate *m_delegate;
 
         QSet<QObject *> m_hitTestVisibleItems;
         QList<QRect> m_hitTestVisibleRects;
@@ -49,8 +50,9 @@
         QObject *m_titleBar{};
         std::array<QObject *, CoreWindowAgent::NumSystemButton> m_systemButtons{};
 
+        // Cached shape
         mutable bool hitTestVisibleShapeDirty{};
-        mutable QPolygon hitTestVisibleShape;
+        mutable QRegion hitTestVisibleShape;
     };
 
     inline QWindow *AbstractWindowContext::window() const {
@@ -69,8 +71,6 @@
     inline QObject *AbstractWindowContext::titleBar() const {
         return m_titleBar;
     }
-
-    using WindowContextPtr = std::shared_ptr<AbstractWindowContext>;
 
 }
 

--
Gitblit v1.9.1