From 2a93b2cb1738feebf29e95de95b0a00acbb162d9 Mon Sep 17 00:00:00 2001 From: Maximilian Seidler Date: Mon, 29 Sep 2025 20:48:05 +0200 Subject: [PATCH] fix background reloads --- src/renderer/widgets/Background.cpp | 19 ++++++++++--------- src/renderer/widgets/Background.hpp | 6 +++--- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/renderer/widgets/Background.cpp b/src/renderer/widgets/Background.cpp index c938340..9b7dc86 100644 --- a/src/renderer/widgets/Background.cpp +++ b/src/renderer/widgets/Background.cpp @@ -251,10 +251,10 @@ bool CBackground::draw(const SRenderData& data) { } void CBackground::onAssetUpdate(ResourceID id, ASP newAsset) { - pendingResourceID = 0; + pendingResource = false; if (!newAsset) - Debug::log(ERR, "Background asset update failed, resourceID: {} not available on update!", pendingResourceID); + Debug::log(ERR, "Background asset update failed, resourceID: {} not available on update!", id); else if (newAsset->m_iType == TEXTURE_INVALID) { g_asyncResourceManager->unload(newAsset); Debug::log(ERR, "New background asset has an invalid texture!"); @@ -264,14 +264,13 @@ void CBackground::onAssetUpdate(ResourceID id, ASP newAsset) { *crossFadeProgress = 1.0; crossFadeProgress->setCallbackOnEnd( - [REF = m_self](auto) { + [REF = m_self, id](auto) { if (const auto PSELF = REF.lock()) { if (PSELF->asset) g_asyncResourceManager->unload(PSELF->asset); - PSELF->asset = PSELF->pendingAsset; - PSELF->pendingAsset = nullptr; - PSELF->resourceID = PSELF->pendingResourceID; - PSELF->pendingResourceID = 0; + PSELF->asset = PSELF->pendingAsset; + PSELF->pendingAsset = nullptr; + PSELF->resourceID = id; PSELF->blurredFB->destroyBuffer(); PSELF->blurredFB = std::move(PSELF->pendingBlurredFB); @@ -323,10 +322,12 @@ void CBackground::onReloadTimerUpdate() { return; } - if (pendingResourceID > 0) + if (pendingResource) return; + pendingResource = true; + // Issue the next request AWP widget(m_self); - pendingResourceID = g_asyncResourceManager->requestImage(path, m_imageRevision, widget); + g_asyncResourceManager->requestImage(path, m_imageRevision, widget); } diff --git a/src/renderer/widgets/Background.hpp b/src/renderer/widgets/Background.hpp index 52784a7..d3516c5 100644 --- a/src/renderer/widgets/Background.hpp +++ b/src/renderer/widgets/Background.hpp @@ -64,9 +64,9 @@ class CBackground : public IWidget { std::string outputPort; Hyprutils::Math::eTransform transform; - ResourceID resourceID = 0; - ResourceID scResourceID = 0; - ResourceID pendingResourceID = 0; + ResourceID resourceID = 0; + ResourceID scResourceID = 0; + bool pendingResource = false; PHLANIMVAR crossFadeProgress;