From 8e0f7b9b117b1a40a78261f1dd27d4a9b9cae916 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Tue, 13 Sep 2022 22:26:19 +0200 Subject: [PATCH] Various subsurface handling fixes --- src/helpers/SubsurfaceTree.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/helpers/SubsurfaceTree.cpp b/src/helpers/SubsurfaceTree.cpp index dc30fc9c..a5c7f0a0 100644 --- a/src/helpers/SubsurfaceTree.cpp +++ b/src/helpers/SubsurfaceTree.cpp @@ -3,9 +3,6 @@ #include "../Compositor.hpp" void addSurfaceGlobalOffset(SSurfaceTreeNode* node, int* lx, int* ly) { - if (!node->pSurface) - return; // ? how does this happen sometimes - *lx += node->pSurface->sx; *ly += node->pSurface->sy; @@ -104,6 +101,14 @@ void SubsurfaceTree::destroySurfaceTree(SSurfaceTreeNode* pNode) { g_pHyprRenderer->damageBox(&extents); } + // remove references to this node + for (auto& tn : surfaceTreeNodes) { + for (auto& cs : tn.childSubsurfaces) { + if (cs.pChild == pNode) + cs.pChild = nullptr; + } + } + surfaceTreeNodes.remove(*pNode); Debug::log(LOG, "SurfaceTree Node removed"); @@ -157,6 +162,9 @@ void Events::listener_newSubsurfaceNode(void* owner, void* data) { void Events::listener_mapSubsurface(void* owner, void* data) { SSubsurface* subsurface = (SSubsurface*)owner; + if (subsurface->pChild) + return; + Debug::log(LOG, "Subsurface %x mapped", subsurface->pSubsurface); subsurface->pChild = createSubsurfaceNode(subsurface->pParent, subsurface, subsurface->pSubsurface->surface, subsurface->pWindowOwner); @@ -181,8 +189,8 @@ void Events::listener_unmapSubsurface(void* owner, void* data) { g_pHyprRenderer->damageBox(&extents); } - SubsurfaceTree::destroySurfaceTree(subsurface->pChild); - subsurface->pChild = nullptr; + //SubsurfaceTree::destroySurfaceTree(subsurface->pChild); + //subsurface->pChild = nullptr; } } @@ -218,8 +226,9 @@ void Events::listener_commitSubsurface(void* owner, void* data) { void Events::listener_destroySubsurface(void* owner, void* data) { SSubsurface* subsurface = (SSubsurface*)owner; - if (subsurface->pChild) - listener_destroySubsurfaceNode(subsurface->pChild, nullptr); + if (subsurface->pChild) { + SubsurfaceTree::destroySurfaceTree(subsurface->pChild); + } Debug::log(LOG, "Subsurface %x destroyed", subsurface);