summaryrefslogtreecommitdiff
path: root/src/Compositor.cpp
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-07-23 15:48:08 +0200
committervaxerski <43317083+vaxerski@users.noreply.github.com>2022-07-23 15:48:08 +0200
commit1626707b7f4fd3d2b313e78cb3a41783f072f73b (patch)
treed03ac32a9c898f38216f191949b8c5b2ff89044e /src/Compositor.cpp
parent72700bf9dc17d1d145130bd53b436a80e1c971d2 (diff)
make layerSurfaces into RAII
Diffstat (limited to 'src/Compositor.cpp')
-rw-r--r--src/Compositor.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp
index 99a46dfa..d8c39e30 100644
--- a/src/Compositor.cpp
+++ b/src/Compositor.cpp
@@ -716,7 +716,7 @@ CWindow* CCompositor::getWindowForPopup(wlr_xdg_popup* popup) {
return nullptr;
}
-wlr_surface* CCompositor::vectorToLayerSurface(const Vector2D& pos, std::list<SLayerSurface*>* layerSurfaces, Vector2D* sCoords, SLayerSurface** ppLayerSurfaceFound) {
+wlr_surface* CCompositor::vectorToLayerSurface(const Vector2D& pos, std::vector<std::unique_ptr<SLayerSurface>>* layerSurfaces, Vector2D* sCoords, SLayerSurface** ppLayerSurfaceFound) {
for (auto it = layerSurfaces->rbegin(); it != layerSurfaces->rend(); it++) {
if ((*it)->fadingOut || !(*it)->layerSurface || ((*it)->layerSurface && !(*it)->layerSurface->mapped))
continue;
@@ -724,7 +724,7 @@ wlr_surface* CCompositor::vectorToLayerSurface(const Vector2D& pos, std::list<SL
const auto SURFACEAT = wlr_layer_surface_v1_surface_at((*it)->layerSurface, pos.x - (*it)->geometry.x, pos.y - (*it)->geometry.y, &sCoords->x, &sCoords->y);
if (SURFACEAT) {
- *ppLayerSurfaceFound = *it;
+ *ppLayerSurfaceFound = it->get();
return SURFACEAT;
}
}
@@ -900,18 +900,18 @@ void CCompositor::cleanupFadingOut(const int& monid) {
continue;
if (ls->fadingOut && ls->readyToDelete && !ls->alpha.isBeingAnimated()) {
- for (auto& m : m_vMonitors) {
- for (auto& lsl : m->m_aLayerSurfaceLists) {
- lsl.remove(ls);
- }
- }
-
g_pHyprOpenGL->m_mLayerFramebuffers[ls].release();
g_pHyprOpenGL->m_mLayerFramebuffers.erase(ls);
- delete ls;
m_vSurfacesFadingOut.erase(std::remove(m_vSurfacesFadingOut.begin(), m_vSurfacesFadingOut.end(), ls));
+ for (auto& m : m_vMonitors) {
+ for (auto& lsl : m->m_aLayerSurfaceLists) {
+ if (!lsl.empty() && std::find_if(lsl.begin(), lsl.end(), [&](std::unique_ptr<SLayerSurface>& other) { return other.get() == ls; }) != lsl.end())
+ lsl.erase(std::remove_if(lsl.begin(), lsl.end(), [&](std::unique_ptr<SLayerSurface>& other) { return other.get() == ls; }));
+ }
+ }
+
Debug::log(LOG, "Cleanup: destroyed a layersurface");
glFlush(); // to free mem NOW.