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, 16 insertions(+), 2 deletions(-) diff --git a/src/core/contexts/abstractwindowcontext.cpp b/src/core/contexts/abstractwindowcontext.cpp index faac874..a6d4aeb 100644 --- a/src/core/contexts/abstractwindowcontext.cpp +++ b/src/core/contexts/abstractwindowcontext.cpp @@ -2,7 +2,9 @@ namespace QWK { - AbstractWindowContext::~AbstractWindowContext() = default; + AbstractWindowContext::~AbstractWindowContext() { + delete m_delegate; + } void AbstractWindowContext::setupWindow(QWindow *window) { Q_ASSERT(window); @@ -37,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)) { @@ -72,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