From 187f82bb4065589fa7fba5f6fa9bd51113357a2c Mon Sep 17 00:00:00 2001 From: SineStriker <trueful@163.com> Date: 周一, 18 12月 2023 14:29:35 +0800 Subject: [PATCH] minor tweaks --- src/core/contexts/abstractwindowcontext.cpp | 40 ++++++++++++++++++++++------------------ 1 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/core/contexts/abstractwindowcontext.cpp b/src/core/contexts/abstractwindowcontext.cpp index 96f2935..ef1efbf 100644 --- a/src/core/contexts/abstractwindowcontext.cpp +++ b/src/core/contexts/abstractwindowcontext.cpp @@ -11,27 +11,16 @@ AbstractWindowContext::~AbstractWindowContext() = default; - bool AbstractWindowContext::setup(QObject *host, WindowItemDelegate *delegate) { - if (!host || !delegate) { - return false; + void AbstractWindowContext::setup(QObject *host, WindowItemDelegate *delegate) { + if (m_host || !host || !delegate) { + return; } - - auto windowHandle = delegate->hostWindow(host); - if (!windowHandle) { - return false; - } - m_host = host; m_delegate.reset(delegate); - m_windowHandle = windowHandle; - - if (!setupHost()) { - m_host = nullptr; - m_delegate.reset(); - m_windowHandle = nullptr; - return false; + m_windowHandle = m_delegate->hostWindow(m_host); + if (m_windowHandle) { + winIdChanged(nullptr); } - return true; } bool AbstractWindowContext::setHitTestVisible(const QObject *obj, bool visible) { @@ -75,6 +64,13 @@ m_titleBar = item; return true; } + +#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 { @@ -176,4 +172,12 @@ virtual_hook(ShowSystemMenuHook, &const_cast<QPoint &>(pos)); } -} \ No newline at end of file + void AbstractWindowContext::notifyWinIdChange() { + auto oldWindow = m_windowHandle; + m_windowHandle = m_delegate->window(m_host); + if (oldWindow == m_windowHandle) + return; + winIdChanged(oldWindow); + } + +} -- Gitblit v1.9.1