From ec73f033aa2d08163d0667d34623ed36686da83c Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sat, 6 Apr 2024 03:09:20 +0100 Subject: [PATCH] subsurface: init existing subsurfaces on children creations fixes #5333 --- src/desktop/Subsurface.cpp | 34 ++++++++++------------------------ src/desktop/Subsurface.hpp | 2 +- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/src/desktop/Subsurface.cpp b/src/desktop/Subsurface.cpp index c3538ee1..88a77af9 100644 --- a/src/desktop/Subsurface.cpp +++ b/src/desktop/Subsurface.cpp @@ -7,38 +7,24 @@ static void onNewSubsurface(void* owner, void* data); CSubsurface::CSubsurface(CWindow* pOwner) : m_pWindowParent(pOwner) { initSignals(); - - wlr_subsurface* wlrSubsurface; - wl_list_for_each(wlrSubsurface, &pOwner->m_pWLSurface.wlr()->current.subsurfaces_below, current.link) { - ::onNewSubsurface(this, wlrSubsurface); - } - wl_list_for_each(wlrSubsurface, &pOwner->m_pWLSurface.wlr()->current.subsurfaces_above, current.link) { - ::onNewSubsurface(this, wlrSubsurface); - } + initExistingSubsurfaces(pOwner->m_pWLSurface.wlr()); } CSubsurface::CSubsurface(CPopup* pOwner) : m_pPopupParent(pOwner) { initSignals(); - - wlr_subsurface* wlrSubsurface; - wl_list_for_each(wlrSubsurface, &pOwner->m_sWLSurface.wlr()->current.subsurfaces_below, current.link) { - ::onNewSubsurface(this, wlrSubsurface); - } - wl_list_for_each(wlrSubsurface, &pOwner->m_sWLSurface.wlr()->current.subsurfaces_above, current.link) { - ::onNewSubsurface(this, wlrSubsurface); - } + initExistingSubsurfaces(pOwner->m_sWLSurface.wlr()); } CSubsurface::CSubsurface(wlr_subsurface* pSubsurface, CWindow* pOwner) : m_pSubsurface(pSubsurface), m_pWindowParent(pOwner) { m_sWLSurface.assign(pSubsurface->surface, this); initSignals(); - initExistingSubsurfaces(); + initExistingSubsurfaces(pSubsurface->surface); } CSubsurface::CSubsurface(wlr_subsurface* pSubsurface, CPopup* pOwner) : m_pSubsurface(pSubsurface), m_pPopupParent(pOwner) { m_sWLSurface.assign(pSubsurface->surface, this); initSignals(); - initExistingSubsurfaces(); + initExistingSubsurfaces(pSubsurface->surface); } CSubsurface::~CSubsurface() { @@ -47,6 +33,8 @@ CSubsurface::~CSubsurface() { if (!m_pSubsurface) return; + m_pSubsurface->data = nullptr; + hyprListener_commitSubsurface.removeCallback(); hyprListener_destroySubsurface.removeCallback(); } @@ -78,6 +66,7 @@ static void onUnmapSubsurface(void* owner, void* data) { void CSubsurface::initSignals() { if (m_pSubsurface) { + m_pSubsurface->data = this; hyprListener_commitSubsurface.initCallback(&m_pSubsurface->surface->events.commit, &onCommitSubsurface, this, "CSubsurface"); hyprListener_destroySubsurface.initCallback(&m_pSubsurface->events.destroy, &onDestroySubsurface, this, "CSubsurface"); hyprListener_newSubsurface.initCallback(&m_pSubsurface->surface->events.new_subsurface, &::onNewSubsurface, this, "CSubsurface"); @@ -225,15 +214,12 @@ Vector2D CSubsurface::coordsGlobal() { return coords; } -void CSubsurface::initExistingSubsurfaces() { - if (m_pWindowParent) - return; - +void CSubsurface::initExistingSubsurfaces(wlr_surface* pSurface) { wlr_subsurface* wlrSubsurface; - wl_list_for_each(wlrSubsurface, &m_sWLSurface.wlr()->current.subsurfaces_below, current.link) { + wl_list_for_each(wlrSubsurface, &pSurface->current.subsurfaces_below, current.link) { ::onNewSubsurface(this, wlrSubsurface); } - wl_list_for_each(wlrSubsurface, &m_sWLSurface.wlr()->current.subsurfaces_above, current.link) { + wl_list_for_each(wlrSubsurface, &pSurface->current.subsurfaces_above, current.link) { ::onNewSubsurface(this, wlrSubsurface); } } diff --git a/src/desktop/Subsurface.hpp b/src/desktop/Subsurface.hpp index ca02a6d5..b7c0a397 100644 --- a/src/desktop/Subsurface.hpp +++ b/src/desktop/Subsurface.hpp @@ -54,6 +54,6 @@ class CSubsurface { bool m_bInert = false; void initSignals(); - void initExistingSubsurfaces(); + void initExistingSubsurfaces(wlr_surface* pSurface); void checkSiblingDamage(); }; \ No newline at end of file