From 499afac952920595e6c3d4f94806427f894c7674 Mon Sep 17 00:00:00 2001 From: Sine Striker <trueful@163.com> Date: 周六, 02 12月 2023 19:05:24 +0800 Subject: [PATCH] optimize code --- src/core/contexts/abstractwindowcontext.cpp | 18 +++++++++++++++++- 1 files changed, 17 insertions(+), 1 deletions(-) diff --git a/src/core/contexts/abstractwindowcontext.cpp b/src/core/contexts/abstractwindowcontext.cpp index 0cefb8b..a6d4aeb 100644 --- a/src/core/contexts/abstractwindowcontext.cpp +++ b/src/core/contexts/abstractwindowcontext.cpp @@ -7,6 +7,10 @@ } void AbstractWindowContext::setupWindow(QWindow *window) { + Q_ASSERT(window); + if (!window) { + return; + } m_windowHandle = window; } @@ -35,11 +39,12 @@ } else { m_hitTestVisibleRects.removeAll(rect); } + hitTestVisibleShapeDirty = true; return true; } bool AbstractWindowContext::setSystemButton(CoreWindowAgent::SystemButton button, - QObject *obj) { + QObject *obj) { Q_ASSERT(obj); Q_ASSERT(button != CoreWindowAgent::Unknown); if (!obj || (button == CoreWindowAgent::Unknown)) { @@ -70,4 +75,15 @@ // ? } + QRegion AbstractWindowContext::hitTestShape() const { + if (hitTestVisibleShapeDirty) { + hitTestVisibleShape = {}; + for (const auto &rect : m_hitTestVisibleRects) { + hitTestVisibleShape += rect; + } + hitTestVisibleShapeDirty = false; + } + return hitTestVisibleShape; + } + } \ No newline at end of file -- Gitblit v1.9.1