From ea8d13724433cab8ccf53e76f9b8b553d76141ff Mon Sep 17 00:00:00 2001 From: Sine Striker <trueful@163.com> Date: 周三, 08 5月 2024 13:38:24 +0800 Subject: [PATCH] minor tweaks --- src/quick/quickwindowagent_mac.cpp | 24 +++++++++++++++++++++--- 1 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/quick/quickwindowagent_mac.cpp b/src/quick/quickwindowagent_mac.cpp index 0e19772..c7a822e 100644 --- a/src/quick/quickwindowagent_mac.cpp +++ b/src/quick/quickwindowagent_mac.cpp @@ -1,3 +1,7 @@ +// Copyright (C) 2023-2024 Stdware Collections (https://www.github.com/stdware) +// Copyright (C) 2021-2023 wangwenx190 (Yuhang Zhao) +// SPDX-License-Identifier: Apache-2.0 + #include "quickwindowagent_p.h" namespace QWK { @@ -27,11 +31,14 @@ &SystemButtonAreaItemHandler::updateSystemButtonArea); connect(item, &QQuickItem::heightChanged, this, &SystemButtonAreaItemHandler::updateSystemButtonArea); - updateSystemButtonArea(); + + ctx->setSystemButtonAreaCallback([item](const QSize &) { + return QRectF(item->mapToScene(QPointF(0, 0)), item->size()).toRect(); // + }); } void SystemButtonAreaItemHandler::updateSystemButtonArea() { - ctx->setSystemButtonArea(QRectF(item->mapToScene(QPointF(0, 0)), item->size()).toRect()); + ctx->virtual_hook(AbstractWindowContext::SystemButtonAreaChangedHook, nullptr); } QQuickItem *QuickWindowAgent::systemButtonArea() const { @@ -48,10 +55,21 @@ d->systemButtonAreaItem = item; if (!item) { d->systemButtonAreaItemHandler.reset(); - ctx->setSystemButtonArea({}); + ctx->setSystemButtonAreaCallback({}); return; } d->systemButtonAreaItemHandler = std::make_unique<SystemButtonAreaItemHandler>(item, ctx); } + ScreenRectCallback QuickWindowAgent::systemButtonAreaCallback() const { + Q_D(const QuickWindowAgent); + return d->systemButtonAreaItem ? nullptr : d->context->systemButtonAreaCallback(); + } + + void QuickWindowAgent::setSystemButtonAreaCallback(const ScreenRectCallback &callback) { + Q_D(QuickWindowAgent); + setSystemButtonArea(nullptr); + d->context->setSystemButtonAreaCallback(callback); + } + } -- Gitblit v1.9.1