From 52a662ed17db6c3a3ff2050d61bc2e06ea21b056 Mon Sep 17 00:00:00 2001 From: Sine Striker <trueful@163.com> Date: 周日, 17 12月 2023 01:07:13 +0800 Subject: [PATCH] Add Mac system button area interfaces --- src/core/contexts/abstractwindowcontext.cpp | 47 +++++++++++++---------------------------------- 1 files changed, 13 insertions(+), 34 deletions(-) diff --git a/src/core/contexts/abstractwindowcontext.cpp b/src/core/contexts/abstractwindowcontext.cpp index 2a68081..7c40c89 100644 --- a/src/core/contexts/abstractwindowcontext.cpp +++ b/src/core/contexts/abstractwindowcontext.cpp @@ -7,13 +7,6 @@ namespace QWK { - QWK_USED static constexpr const struct { - const quint32 activeLight = MAKE_RGBA_COLOR(210, 233, 189, 226); - const quint32 activeDark = MAKE_RGBA_COLOR(177, 205, 190, 240); - const quint32 inactiveLight = MAKE_RGBA_COLOR(193, 195, 211, 203); - const quint32 inactiveDark = MAKE_RGBA_COLOR(240, 240, 250, 255); - } kSampleColorSet; - AbstractWindowContext::AbstractWindowContext() = default; AbstractWindowContext::~AbstractWindowContext() = default; @@ -55,21 +48,6 @@ return true; } - bool AbstractWindowContext::setHitTestVisible(const QRect &rect, bool visible) { - Q_ASSERT(rect.isValid()); - if (!rect.isValid()) { - return false; - } - - if (visible) { - m_hitTestVisibleRects.append(rect); - } else { - m_hitTestVisibleRects.removeAll(rect); - } - hitTestVisibleShapeDirty = true; - return true; - } - bool AbstractWindowContext::setSystemButton(WindowAgentBase::SystemButton button, QObject *obj) { Q_ASSERT(obj); @@ -98,16 +76,12 @@ return true; } - QRegion AbstractWindowContext::hitTestShape() const { - if (hitTestVisibleShapeDirty) { - hitTestVisibleShape = {}; - for (const auto &rect : m_hitTestVisibleRects) { - hitTestVisibleShape += rect; - } - hitTestVisibleShapeDirty = false; - } - return hitTestVisibleShape; +#ifdef Q_OS_MAC + void AbstractWindowContext::setSystemButtonArea(const QRect &rect) { + m_systemButtonArea = rect; + virtual_hook(SystemButtonAreaChangedHook, nullptr); } +#endif bool AbstractWindowContext::isInSystemButtons(const QPoint &pos, WindowAgentBase::SystemButton *button) const { @@ -164,15 +138,19 @@ } } - if (!m_hitTestVisibleRects.isEmpty() && hitTestShape().contains(pos)) { - return false; - } return true; } QString AbstractWindowContext::key() const { return {}; } + + QWK_USED static constexpr const struct { + const quint32 activeLight = MAKE_RGBA_COLOR(210, 233, 189, 226); + const quint32 activeDark = MAKE_RGBA_COLOR(177, 205, 190, 240); + const quint32 inactiveLight = MAKE_RGBA_COLOR(193, 195, 211, 203); + const quint32 inactiveDark = MAKE_RGBA_COLOR(240, 240, 250, 255); + } kSampleColorSet; void AbstractWindowContext::virtual_hook(int id, void *data) { switch (id) { @@ -195,6 +173,7 @@ map.insert(QStringLiteral("inactiveDark"), kSampleColorSet.inactiveDark); return; } + default: break; } -- Gitblit v1.9.1