From ee9d75b5802fd623a9a6a88406ac84a2db4bfaf0 Mon Sep 17 00:00:00 2001 From: Maximilian Seidler Date: Thu, 27 Jun 2024 19:53:19 +0200 Subject: [PATCH] renderer: remove widgets for destroyed lockSurfaces --- src/core/hyprlock.cpp | 6 +++++- src/renderer/Renderer.cpp | 4 ++++ src/renderer/Renderer.hpp | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/core/hyprlock.cpp b/src/core/hyprlock.cpp index 8ea5059..05eda53 100644 --- a/src/core/hyprlock.cpp +++ b/src/core/hyprlock.cpp @@ -300,7 +300,11 @@ void CHyprlock::onGlobal(void* data, struct wl_registry* registry, uint32_t name void CHyprlock::onGlobalRemoved(void* data, struct wl_registry* registry, uint32_t name) { Debug::log(LOG, " | removed iface {}", name); - std::erase_if(m_vOutputs, [name](const auto& other) { return other->name == name; }); + auto outputIt = std::find_if(m_vOutputs.begin(), m_vOutputs.end(), [name](const auto& other) { return other->name == name; }); + if (outputIt != m_vOutputs.end()) { + g_pRenderer->removeWidgetsFor(outputIt->get()->sessionLockSurface.get()); + m_vOutputs.erase(outputIt); + } } // end wl_registry diff --git a/src/renderer/Renderer.cpp b/src/renderer/Renderer.cpp index 08a15c9..394ad26 100644 --- a/src/renderer/Renderer.cpp +++ b/src/renderer/Renderer.cpp @@ -512,3 +512,7 @@ void CRenderer::popFb() { boundFBs.pop_back(); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, boundFBs.empty() ? 0 : boundFBs.back()); } + +void CRenderer::removeWidgetsFor(const CSessionLockSurface* surf) { + widgets.erase(surf); +} diff --git a/src/renderer/Renderer.hpp b/src/renderer/Renderer.hpp index 6599740..d3fc2b6 100644 --- a/src/renderer/Renderer.hpp +++ b/src/renderer/Renderer.hpp @@ -41,6 +41,8 @@ class CRenderer { void pushFb(GLint fb); void popFb(); + void removeWidgetsFor(const CSessionLockSurface* surf); + private: widgetMap_t widgets;