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 |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/src/core/contexts/qtwindowcontext.cpp b/src/core/contexts/qtwindowcontext.cpp
index 7941b56..d0abb6d 100644
--- a/src/core/contexts/qtwindowcontext.cpp
+++ b/src/core/contexts/qtwindowcontext.cpp
@@ -248,7 +248,20 @@
     }
 
     void QtWindowContext::winIdChanged(QWindow *oldWindow, bool isDestroyed) {
-        Q_UNUSED(oldWindow)
+        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