From dd811ac423fe1863caea4b1f8baa4a8f8210e74a Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Wed, 20 Mar 2024 22:32:34 -0700 Subject: [PATCH] core/window: fix mask reactivity Masks previously would not update if the item was changed, and full transparency was decided incorrectly. --- src/core/proxywindow.cpp | 7 +------ src/core/region.cpp | 12 ++++++++---- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/core/proxywindow.cpp b/src/core/proxywindow.cpp index 6be8f5a..6cd8b34 100644 --- a/src/core/proxywindow.cpp +++ b/src/core/proxywindow.cpp @@ -245,14 +245,9 @@ void ProxyWindowBase::updateMask() { auto windowRegion = QRegion(QRect(0, 0, this->width(), this->height())); mask = this->mMask->applyTo(windowRegion); } - - if (mask.isEmpty()) { - this->window->setFlag(Qt::WindowTransparentForInput, true); - } - } else { - this->window->setFlag(Qt::WindowTransparentForInput, false); } + this->window->setFlag(Qt::WindowTransparentForInput, this->mMask != nullptr && mask.isEmpty()); this->window->setMask(mask); } diff --git a/src/core/region.cpp b/src/core/region.cpp index 9826dbd..5bd7da5 100644 --- a/src/core/region.cpp +++ b/src/core/region.cpp @@ -26,10 +26,14 @@ void PendingRegion::setItem(QQuickItem* item) { this->mItem = item; - QObject::connect(this->mItem, &QQuickItem::xChanged, this, &PendingRegion::itemChanged); - QObject::connect(this->mItem, &QQuickItem::yChanged, this, &PendingRegion::itemChanged); - QObject::connect(this->mItem, &QQuickItem::widthChanged, this, &PendingRegion::itemChanged); - QObject::connect(this->mItem, &QQuickItem::heightChanged, this, &PendingRegion::itemChanged); + if (item != nullptr) { + QObject::connect(this->mItem, &QQuickItem::xChanged, this, &PendingRegion::itemChanged); + QObject::connect(this->mItem, &QQuickItem::yChanged, this, &PendingRegion::itemChanged); + QObject::connect(this->mItem, &QQuickItem::widthChanged, this, &PendingRegion::itemChanged); + QObject::connect(this->mItem, &QQuickItem::heightChanged, this, &PendingRegion::itemChanged); + } + + emit this->itemChanged(); } void PendingRegion::onItemDestroyed() { this->mItem = nullptr; }