From b54e368f16e8bd977fe57fcc738fc6804af076e4 Mon Sep 17 00:00:00 2001
From: Zhao Yuhang <2546789017@qq.com>
Date: 周一, 01 1月 2024 22:20:17 +0800
Subject: [PATCH] Update README

---
 src/core/contexts/qtwindowcontext.cpp |   21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/core/contexts/qtwindowcontext.cpp b/src/core/contexts/qtwindowcontext.cpp
index 9c05fa4..8b25c04 100644
--- a/src/core/contexts/qtwindowcontext.cpp
+++ b/src/core/contexts/qtwindowcontext.cpp
@@ -1,3 +1,6 @@
+// Copyright (C) 2023-2024 Stdware Collections
+// SPDX-License-Identifier: Apache-2.0
+
 #include "qtwindowcontext_p.h"
 
 #include <QtCore/QDebug>
@@ -77,9 +80,9 @@
 #endif
     }
 
-    class QtWindowEventFilter : public QObject {
+    class QtWindowEventFilter : public SharedEventFilter {
     public:
-        explicit QtWindowEventFilter(AbstractWindowContext *context, QObject *parent = nullptr);
+        explicit QtWindowEventFilter(AbstractWindowContext *context);
         ~QtWindowEventFilter() override;
 
         enum WindowStatus {
@@ -91,7 +94,7 @@
         };
 
     protected:
-        bool eventFilter(QObject *object, QEvent *event) override;
+        bool sharedEventFilter(QObject *object, QEvent *event) override;
 
     private:
         AbstractWindowContext *m_context;
@@ -99,15 +102,16 @@
         WindowStatus m_windowStatus;
     };
 
-    QtWindowEventFilter::QtWindowEventFilter(AbstractWindowContext *context, QObject *parent)
-        : QObject(parent), m_context(context), m_cursorShapeChanged(false), m_windowStatus(Idle) {
-        m_context->window()->installEventFilter(this);
+    QtWindowEventFilter::QtWindowEventFilter(AbstractWindowContext *context)
+        : m_context(context), m_cursorShapeChanged(false), m_windowStatus(Idle) {
+        m_context->installSharedEventFilter(this);
     }
 
     QtWindowEventFilter::~QtWindowEventFilter() = default;
 
-    bool QtWindowEventFilter::eventFilter(QObject *obj, QEvent *event) {
+    bool QtWindowEventFilter::sharedEventFilter(QObject *obj, QEvent *event) {
         Q_UNUSED(obj)
+
         auto type = event->type();
         if (type < QEvent::MouseButtonPress || type > QEvent::MouseMove) {
             return false;
@@ -235,6 +239,7 @@
     }
 
     QtWindowContext::QtWindowContext() : AbstractWindowContext() {
+        qtWindowEventFilter = std::make_unique<QtWindowEventFilter>(this);
     }
 
     QtWindowContext::~QtWindowContext() = default;
@@ -251,14 +256,12 @@
         if (!m_windowHandle) {
             m_delegate->setWindowFlags(m_host, m_delegate->getWindowFlags(m_host) &
                                                    ~Qt::FramelessWindowHint);
-            qtWindowEventFilter.reset();
             return;
         }
 
         // Allocate new resources
         m_delegate->setWindowFlags(m_host,
                                    m_delegate->getWindowFlags(m_host) | Qt::FramelessWindowHint);
-        qtWindowEventFilter = std::make_unique<QtWindowEventFilter>(this);
     }
 
 }

--
Gitblit v1.9.1