From 0dd19d4a181378df5f61de9b5f54b3f2bba96e8a Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Tue, 12 Nov 2024 04:35:42 -0800 Subject: [PATCH] core/proxywindow: remove blank frame when destroying window Removes the blank frame caused by removing the content item from the window. Fixes an issue with hyprland's window exit animations. --- src/window/proxywindow.cpp | 12 +++++++----- src/window/proxywindow.hpp | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/window/proxywindow.cpp b/src/window/proxywindow.cpp index 07f8a233..3d01224d 100644 --- a/src/window/proxywindow.cpp +++ b/src/window/proxywindow.cpp @@ -44,7 +44,7 @@ ProxyWindowBase::ProxyWindowBase(QObject* parent) // clang-format on } -ProxyWindowBase::~ProxyWindowBase() { this->deleteWindow(); } +ProxyWindowBase::~ProxyWindowBase() { this->deleteWindow(true); } void ProxyWindowBase::onReload(QObject* oldInstance) { this->window = this->retrieveWindow(oldInstance); @@ -90,9 +90,9 @@ void ProxyWindowBase::createWindow() { emit this->windowConnected(); } -void ProxyWindowBase::deleteWindow() { +void ProxyWindowBase::deleteWindow(bool keepItemOwnership) { if (this->window != nullptr) emit this->windowDestroyed(); - if (auto* window = this->disownWindow()) { + if (auto* window = this->disownWindow(keepItemOwnership)) { if (auto* generation = EngineGeneration::findObjectGeneration(this)) { generation->deregisterIncubationController(window->incubationController()); } @@ -101,12 +101,14 @@ void ProxyWindowBase::deleteWindow() { } } -QQuickWindow* ProxyWindowBase::disownWindow() { +QQuickWindow* ProxyWindowBase::disownWindow(bool keepItemOwnership) { if (this->window == nullptr) return nullptr; QObject::disconnect(this->window, nullptr, this, nullptr); - this->mContentItem->setParentItem(nullptr); + if (!keepItemOwnership) { + this->mContentItem->setParentItem(nullptr); + } auto* window = this->window; this->window = nullptr; diff --git a/src/window/proxywindow.hpp b/src/window/proxywindow.hpp index dbbf1910..79d326e3 100644 --- a/src/window/proxywindow.hpp +++ b/src/window/proxywindow.hpp @@ -57,10 +57,10 @@ public: void onReload(QObject* oldInstance) override; void createWindow(); - void deleteWindow(); + void deleteWindow(bool keepItemOwnership = false); // Disown the backing window and delete all its children. - virtual QQuickWindow* disownWindow(); + virtual QQuickWindow* disownWindow(bool keepItemOwnership = false); virtual QQuickWindow* retrieveWindow(QObject* oldInstance); virtual QQuickWindow* createQQuickWindow();