From a5372ac566469efb59e6cfb29a695021c7c3528d Mon Sep 17 00:00:00 2001
From: Sine Striker <trueful@163.com>
Date: 周三, 20 12月 2023 00:53:42 +0800
Subject: [PATCH] Add TODO

---
 src/core/contexts/win32windowcontext.cpp |   39 ++++++++-------------------------------
 1 files changed, 8 insertions(+), 31 deletions(-)

diff --git a/src/core/contexts/win32windowcontext.cpp b/src/core/contexts/win32windowcontext.cpp
index ad502fe..230bf5d 100644
--- a/src/core/contexts/win32windowcontext.cpp
+++ b/src/core/contexts/win32windowcontext.cpp
@@ -480,21 +480,10 @@
         // so we use this small technique to pretend the foreground window is ours.
         ::AttachThreadInput(windowThreadProcessId, currentThreadId, TRUE);
 
-        struct Cleaner {
-            Cleaner(DWORD idAttach, DWORD idAttachTo)
-                : m_idAttach(idAttach), m_idAttachTo(idAttachTo) {
-            }
-            ~Cleaner() {
-                ::AttachThreadInput(m_idAttach, m_idAttachTo, FALSE);
-            }
-
-        private:
-            DWORD m_idAttach;
-            DWORD m_idAttachTo;
-
-            Q_DISABLE_COPY(Cleaner)
-        };
-        [[maybe_unused]] Cleaner cleaner{windowThreadProcessId, currentThreadId};
+        [[maybe_unused]] const auto &cleaner =
+            qScopeGuard([windowThreadProcessId, currentThreadId]() {
+                ::AttachThreadInput(windowThreadProcessId, currentThreadId, FALSE); //
+            });
 
         ::BringWindowToTop(hwnd);
         // Activate the window too. This will force us to the virtual desktop this
@@ -913,7 +902,7 @@
                 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
@@ -1450,21 +1439,9 @@
                 // Terminal does, however, later I found that if we choose a proper
                 // color, our homemade top border can almost have exactly the same
                 // appearance with the system's one.
-                struct HitTestRecorder {
-                    HitTestRecorder(Win32WindowContext *ctx, LRESULT *result)
-                        : ctx(ctx), result(result) {
-                    }
-                    ~HitTestRecorder() {
-                        ctx->lastHitTestResult = getHitWindowPart(int(*result));
-                    }
-
-                private:
-                    Win32WindowContext *ctx;
-                    LRESULT *result;
-
-                    Q_DISABLE_COPY(HitTestRecorder)
-                };
-                [[maybe_unused]] HitTestRecorder hitTestRecorder{this, result};
+                [[maybe_unused]] const auto &hitTestRecorder = qScopeGuard([this, result]() {
+                    lastHitTestResult = getHitWindowPart(int(*result)); //
+                });
 
                 POINT nativeGlobalPos{GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
                 POINT nativeLocalPos = nativeGlobalPos;

--
Gitblit v1.9.1