Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
- Fixed unhandled notifications sending `NotificationClosed` out of order.
- Fixed `qs kill` not waiting for the process to exit.
- Fixed IPC calls from children of a crashed and relaunched process crashing.
- Fixed BackgroundEffect never applying if the compositor announces ext-background-effect-v1 after surface creation.
2 changes: 1 addition & 1 deletion src/wayland/background_effect/manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void BackgroundEffectManager::ext_background_effect_manager_v1_capabilities(uint

BackgroundEffectManager* BackgroundEffectManager::instance() {
static auto* instance = new BackgroundEffectManager(); // NOLINT
return instance->isInitialized() ? instance : nullptr;
return instance;
}

} // namespace qs::wayland::background_effect::impl
36 changes: 33 additions & 3 deletions src/wayland/background_effect/qml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,40 @@ void BackgroundEffect::onWaylandWindowDestroyed() { this->mWaylandWindow = nullp
void BackgroundEffect::onWaylandSurfaceCreated() {
auto* manager = impl::BackgroundEffectManager::instance();

if (!manager) {
qWarning() << "Cannot enable background effect as ext-background-effect-v1 is not supported "
"by the current compositor.";
if (!manager->isActive()) {
qWarning() << "Cannot enable background effect as ext-background-effect-v1 is not currently "
"supported by the compositor. The effect will be enabled if the protocol "
"becomes available.";

// The manager global may be announced at any point, including after surfaces
// that want an effect are created.
QObject::connect(
manager,
&impl::BackgroundEffectManager::activeChanged,
this,
&BackgroundEffect::onManagerActiveChanged
);

return;
}

this->attachEffectSurface();
}

void BackgroundEffect::onManagerActiveChanged() {
auto* manager = impl::BackgroundEffectManager::instance();
if (!manager->isActive()) return;

QObject::disconnect(manager, nullptr, this, nullptr);

if (this->proxyWindow && this->mWaylandWindow && this->mWaylandWindow->surface()) {
this->attachEffectSurface();
}
}

void BackgroundEffect::attachEffectSurface() {
auto* manager = impl::BackgroundEffectManager::instance();

// Steal protocol surface from previous BackgroundEffect to avoid duplicate-attachment on reload.
auto v = this->mWaylandWindow->property("qs_background_effect");
if (v.canConvert<BackgroundEffect*>()) {
Expand All @@ -222,6 +250,8 @@ void BackgroundEffect::onWaylandSurfaceCreated() {
}

void BackgroundEffect::onWaylandSurfaceDestroyed() {
QObject::disconnect(impl::BackgroundEffectManager::instance(), nullptr, this, nullptr);

this->surface = nullptr;
this->pendingBlurRegion = false;

Expand Down
3 changes: 3 additions & 0 deletions src/wayland/background_effect/qml.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,15 @@ private slots:
void onWaylandWindowDestroyed();
void onWaylandSurfaceCreated();
void onWaylandSurfaceDestroyed();
void onManagerActiveChanged();
void onProxyWindowDestroyed();
void onBlurRegionDestroyed();
void onWindowPolished();
void updateBlurRegion();

private:
void attachEffectSurface();

ProxyWindowBase* proxyWindow = nullptr;
QWindow* mWindow = nullptr;
QtWaylandClient::QWaylandWindow* mWaylandWindow = nullptr;
Expand Down
Loading