From ed5f9693b3cd7ddcdc746c4bb65dcd9cf7a8268b Mon Sep 17 00:00:00 2001
From: Sine Striker <trueful@163.com>
Date: 周二, 19 12月 2023 15:09:49 +0800
Subject: [PATCH] Add window attributes

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

diff --git a/src/core/contexts/win32windowcontext.cpp b/src/core/contexts/win32windowcontext.cpp
index 2cfd8b1..8af6a3f 100644
--- a/src/core/contexts/win32windowcontext.cpp
+++ b/src/core/contexts/win32windowcontext.cpp
@@ -780,7 +780,7 @@
         g_wndProcHash->insert(hWnd, ctx);
     }
 
-    static inline void removeManagedWindow(HWND hWnd, bool restore) {
+    static inline void removeManagedWindow(HWND hWnd) {
         // Remove window handle mapping
         if (!g_wndProcHash->remove(hWnd))
             return;
@@ -789,11 +789,6 @@
         if (g_wndProcHash->empty()) {
             WindowsNativeEventFilter::uninstall();
         }
-
-        // Restore window proc
-        if (restore) {
-            ::SetWindowLongPtrW(hWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(g_qtWindowProc));
-        }
     }
 
     Win32WindowContext::Win32WindowContext() : AbstractWindowContext() {
@@ -801,7 +796,7 @@
 
     Win32WindowContext::~Win32WindowContext() {
         if (windowId) {
-            removeManagedWindow(reinterpret_cast<HWND>(windowId), false);
+            removeManagedWindow(reinterpret_cast<HWND>(windowId));
         }
     }
 
@@ -829,6 +824,23 @@
                 showSystemMenu2(hWnd, qpoint2point(nativeGlobalPos), false,
                                 m_delegate->isHostSizeFixed(m_host));
                 return;
+            }
+
+            case WindowAttributeChangedHook: {
+                auto args = static_cast<void **>(data);
+                const auto &key = *static_cast<const QString *>(args[0]);
+                const auto &newVar = *static_cast<const QVariant *>(args[1]);
+                const auto &oldVar = *static_cast<const QVariant *>(args[2]);
+
+                if (key == QStringLiteral("no-frame-shadow")) {
+                    if (newVar.toBool()) {
+                        // TODO: set off
+                    } else {
+                        // TODO: set on
+                    }
+                }
+
+                break;
             }
 
             case DefaultColorsHook: {
@@ -897,11 +909,8 @@
         return getWindowFrameBorderThickness(reinterpret_cast<HWND>(windowId));
     }
 
-    void Win32WindowContext::winIdChanged(QWindow *oldWindow, bool destroyed) {
-        if (oldWindow) {
-            removeManagedWindow(reinterpret_cast<HWND>(windowId), !destroyed);
-        }
-
+    void Win32WindowContext::winIdChanged(QWindow *oldWindow) {
+        removeManagedWindow(reinterpret_cast<HWND>(windowId));
         if (!m_windowHandle) {
             return;
         }

--
Gitblit v1.9.1