From 245ddfa1f01b4c9fa10337246b8045755e5bcce5 Mon Sep 17 00:00:00 2001 From: Sine Striker <trueful@163.com> Date: 周二, 19 12月 2023 21:03:58 +0800 Subject: [PATCH] Change back to qScopeGuard --- src/core/contexts/win32windowcontext.cpp | 37 +++++++------------------------------ 1 files changed, 7 insertions(+), 30 deletions(-) diff --git a/src/core/contexts/win32windowcontext.cpp b/src/core/contexts/win32windowcontext.cpp index ad502fe..cd1ab62 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 @@ -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