From 3871bfc5d3aff45e498fa2944c27e6eb5d146c8e Mon Sep 17 00:00:00 2001
From: SineStriker <trueful@163.com>
Date: 周三, 20 12月 2023 19:56:32 +0800
Subject: [PATCH] Add mac hot-switch implementations

---
 src/core/contexts/qtwindowcontext.cpp |   23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/src/core/contexts/qtwindowcontext.cpp b/src/core/contexts/qtwindowcontext.cpp
index 8a71c2b..d0abb6d 100644
--- a/src/core/contexts/qtwindowcontext.cpp
+++ b/src/core/contexts/qtwindowcontext.cpp
@@ -244,17 +244,24 @@
     }
 
     void QtWindowContext::virtual_hook(int id, void *data) {
-        switch (id) {
-            case ShowSystemMenuHook:
-                return;
-            default:
-                break;
-        }
         AbstractWindowContext::virtual_hook(id, data);
     }
 
-    void QtWindowContext::winIdChanged(QWindow *oldWindow) {
-        Q_UNUSED(oldWindow)
+    void QtWindowContext::winIdChanged(QWindow *oldWindow, bool isDestroyed) {
+        Q_UNUSED(isDestroyed)
+
+        // If the original window id is valid, remove all resources related
+        if (oldWindow) {
+            qtWindowEventFilter.reset();
+        }
+
+        if (!m_windowHandle) {
+            m_delegate->setWindowFlags(m_host, m_delegate->getWindowFlags(m_host) &
+                                                   ~Qt::FramelessWindowHint);
+            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