From a2146f6394ec91b60b718b44051dcd9b6d53dd7b Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Tue, 15 Jul 2025 15:35:48 -0700 Subject: [PATCH] core/window: add closed() signal to all window types --- src/window/proxywindow.cpp | 12 +++++++++++- src/window/proxywindow.hpp | 2 ++ src/window/windowinterface.cpp | 1 + src/window/windowinterface.hpp | 3 +++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/window/proxywindow.cpp b/src/window/proxywindow.cpp index 56d250cf..ac5127bf 100644 --- a/src/window/proxywindow.cpp +++ b/src/window/proxywindow.cpp @@ -188,7 +188,7 @@ void ProxyWindowBase::connectWindow() { this->window->setProxy(this); // clang-format off - QObject::connect(this->window, &QWindow::visibilityChanged, this, &ProxyWindowBase::visibleChanged); + QObject::connect(this->window, &QWindow::visibilityChanged, this, &ProxyWindowBase::onVisibleChanged); QObject::connect(this->window, &QWindow::xChanged, this, &ProxyWindowBase::xChanged); QObject::connect(this->window, &QWindow::yChanged, this, &ProxyWindowBase::yChanged); QObject::connect(this->window, &QWindow::widthChanged, this, &ProxyWindowBase::widthChanged); @@ -226,6 +226,16 @@ void ProxyWindowBase::completeWindow() { emit this->screenChanged(); } +void ProxyWindowBase::onVisibleChanged() { + if (this->mVisible && !this->window->isVisible()) { + this->mVisible = false; + this->setVisibleDirect(false); + emit this->closed(); + } + + emit this->visibleChanged(); +} + bool ProxyWindowBase::deleteOnInvisible() const { return false; } QQuickWindow* ProxyWindowBase::backingWindow() const { return this->window; } diff --git a/src/window/proxywindow.hpp b/src/window/proxywindow.hpp index 3fbc08e1..ba35d594 100644 --- a/src/window/proxywindow.hpp +++ b/src/window/proxywindow.hpp @@ -141,6 +141,7 @@ public: [[nodiscard]] QQmlListProperty data(); signals: + void closed(); void windowConnected(); void windowDestroyed(); void visibleChanged(); @@ -160,6 +161,7 @@ signals: void polished(); protected slots: + void onVisibleChanged(); virtual void onWidthChanged(); virtual void onHeightChanged(); void onMaskChanged(); diff --git a/src/window/windowinterface.cpp b/src/window/windowinterface.cpp index d808c80f..aac0df34 100644 --- a/src/window/windowinterface.cpp +++ b/src/window/windowinterface.cpp @@ -133,6 +133,7 @@ QQmlListProperty WindowInterface::data() const { return this->proxyWind void WindowInterface::connectSignals() const { auto* window = this->proxyWindow(); // clang-format off + QObject::connect(window, &ProxyWindowBase::closed, this, &WindowInterface::closed); QObject::connect(window, &ProxyWindowBase::windowConnected, this, &WindowInterface::windowConnected); QObject::connect(window, &ProxyWindowBase::visibleChanged, this, &WindowInterface::visibleChanged); QObject::connect(window, &ProxyWindowBase::backerVisibilityChanged, this, &WindowInterface::backingWindowVisibleChanged); diff --git a/src/window/windowinterface.hpp b/src/window/windowinterface.hpp index 5021ae84..e3ed84a4 100644 --- a/src/window/windowinterface.hpp +++ b/src/window/windowinterface.hpp @@ -236,6 +236,9 @@ public: static QsWindowAttached* qmlAttachedProperties(QObject* object); signals: + /// This signal is emitted when the window is closed by the user, the display server, + /// or an error. It is not emitted when @@visible is set to false. + void closed(); void windowConnected(); void visibleChanged(); void backingWindowVisibleChanged();