From 881f8282501845f57505015e85abbe668bfb740f Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sun, 9 Oct 2022 17:23:12 +0100 Subject: [PATCH] better subsurface handling on unmaps --- src/helpers/SubsurfaceTree.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/helpers/SubsurfaceTree.cpp b/src/helpers/SubsurfaceTree.cpp index a5c7f0a0..349f5090 100644 --- a/src/helpers/SubsurfaceTree.cpp +++ b/src/helpers/SubsurfaceTree.cpp @@ -178,19 +178,23 @@ void Events::listener_unmapSubsurface(void* owner, void* data) { if (subsurface->pChild) { const auto PNODE = subsurface->pChild; - int lx = 0, ly = 0; - addSurfaceGlobalOffset(PNODE, &lx, &ly); + const auto IT = std::find_if(SubsurfaceTree::surfaceTreeNodes.begin(), SubsurfaceTree::surfaceTreeNodes.end(), [&](const SSurfaceTreeNode& other) { return &other == PNODE; }); - wlr_box extents = {lx, ly, 0, 0}; - if (PNODE->pSurface) { - extents.width = PNODE->pSurface->current.width; - extents.height = PNODE->pSurface->current.height; + if (IT != SubsurfaceTree::surfaceTreeNodes.end()) { + int lx = 0, ly = 0; + addSurfaceGlobalOffset(PNODE, &lx, &ly); - g_pHyprRenderer->damageBox(&extents); + wlr_box extents = {lx, ly, 0, 0}; + if (PNODE->pSurface) { + extents.width = PNODE->pSurface->current.width; + extents.height = PNODE->pSurface->current.height; + + g_pHyprRenderer->damageBox(&extents); + } + + // SubsurfaceTree::destroySurfaceTree(subsurface->pChild); + // subsurface->pChild = nullptr; } - - //SubsurfaceTree::destroySurfaceTree(subsurface->pChild); - //subsurface->pChild = nullptr; } }