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.
This commit is contained in:
outfoxxed 2024-11-12 04:35:42 -08:00
parent 2c0e46cedb
commit 0dd19d4a18
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
2 changed files with 9 additions and 7 deletions

View file

@ -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;

View file

@ -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();