From c3ef42dad254f6d04cab521c9ae619a46bb84f7a Mon Sep 17 00:00:00 2001 From: Sine Striker <trueful@163.com> Date: ćšć, 21 11æ 2024 21:17:32 +0800 Subject: [PATCH] Fix #151 and a crash bug related to sub frameless window --- src/quick/quickwindowagent.cpp | 53 ++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 38 insertions(+), 15 deletions(-) diff --git a/src/quick/quickwindowagent.cpp b/src/quick/quickwindowagent.cpp index 77ccc9e..9270311 100644 --- a/src/quick/quickwindowagent.cpp +++ b/src/quick/quickwindowagent.cpp @@ -1,17 +1,28 @@ +// 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.h" #include "quickwindowagent_p.h" #include <QtQuick/QQuickWindow> +#include <QtQuick/private/qquickanchors_p.h> #include "quickitemdelegate_p.h" namespace QWK { - QuickWindowAgentPrivate::QuickWindowAgentPrivate() { - } + /*! + \class QuickWindowAgent + \brief QuickWindowAgent is the window agent for QtQuick. - QuickWindowAgentPrivate::~QuickWindowAgentPrivate() { - } + It provides interfaces for QtQuick and processes some Qt events related to the QQuickItem + instance. The usage of all APIs is consistent with the \a Widgets module. + */ + + QuickWindowAgentPrivate::QuickWindowAgentPrivate() = default; + + QuickWindowAgentPrivate::~QuickWindowAgentPrivate() = default; void QuickWindowAgentPrivate::init() { } @@ -20,8 +31,7 @@ : QuickWindowAgent(*new QuickWindowAgentPrivate(), parent) { } - QuickWindowAgent::~QuickWindowAgent() { - } + QuickWindowAgent::~QuickWindowAgent() = default; bool QuickWindowAgent::setup(QQuickWindow *window) { Q_ASSERT(window); @@ -34,10 +44,18 @@ return false; } - if (!d->setup(window, new QuickItemDelegate())) { - return true; - } + d->setup(window, new QuickItemDelegate()); d->hostWindow = window; + +#if defined(Q_OS_WINDOWS) && QWINDOWKIT_CONFIG(ENABLE_WINDOWS_SYSTEM_BORDERS) + d->setupWindows10BorderWorkaround(); +#endif + +#ifdef Q_OS_WINDOWS + if (!windowAttribute(QStringLiteral("windows-system-border-enabled")).toBool()) { + window->setFlag(Qt::FramelessWindowHint); + } +#endif return true; } @@ -51,6 +69,9 @@ if (!d->context->setTitleBar(item)) { return; } +#ifdef Q_OS_MAC + setSystemButtonArea(nullptr); +#endif Q_EMIT titleBarWidgetChanged(item); } @@ -67,21 +88,23 @@ Q_EMIT systemButtonChanged(button, item); } +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) + bool QuickWindowAgent::isHitTestVisible(QQuickItem *item) const { +#else bool QuickWindowAgent::isHitTestVisible(const QQuickItem *item) const { +#endif Q_D(const QuickWindowAgent); return d->context->isHitTestVisible(item); } - void QuickWindowAgent::setHitTestVisible_item(const QQuickItem *item, bool visible) { + void QuickWindowAgent::setHitTestVisible(QQuickItem *item, bool visible) { Q_D(QuickWindowAgent); d->context->setHitTestVisible(item, visible); } - void QuickWindowAgent::setHitTestVisible_rect(const QRect &rect, bool visible) { - Q_D(QuickWindowAgent); - d->context->setHitTestVisible(rect, visible); - } - + /*! + \internal + */ QuickWindowAgent::QuickWindowAgent(QuickWindowAgentPrivate &d, QObject *parent) : WindowAgentBase(d, parent) { d.init(); -- Gitblit v1.9.1