From 5edc32930d85f5f481160b938965c8bc329487e7 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Tue, 30 Apr 2024 02:41:27 +0100 Subject: layerSurface: refactor/move to a memory-safe impl Makes all the pointers smart to avoid memory issues Refactors layerSurface code to live inside desktop/layersurface --- src/desktop/WLSurface.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/desktop/WLSurface.cpp') diff --git a/src/desktop/WLSurface.cpp b/src/desktop/WLSurface.cpp index 55601a99..41c357e0 100644 --- a/src/desktop/WLSurface.cpp +++ b/src/desktop/WLSurface.cpp @@ -14,7 +14,7 @@ void CWLSurface::assign(wlr_surface* pSurface, PHLWINDOW pOwner) { m_bInert = false; } -void CWLSurface::assign(wlr_surface* pSurface, SLayerSurface* pOwner) { +void CWLSurface::assign(wlr_surface* pSurface, PHLLS pOwner) { m_pLayerOwner = pOwner; m_pWLRSurface = pSurface; init(); @@ -113,7 +113,7 @@ void CWLSurface::destroy() { hyprListener_commit.removeCallback(); m_pWLRSurface->data = nullptr; m_pWindowOwner.reset(); - m_pLayerOwner = nullptr; + m_pLayerOwner.reset(); m_pPopupOwner = nullptr; m_pSubsurfaceOwner = nullptr; m_bInert = true; @@ -154,8 +154,8 @@ PHLWINDOW CWLSurface::getWindow() { return m_pWindowOwner.lock(); } -SLayerSurface* CWLSurface::getLayer() { - return m_pLayerOwner; +PHLLS CWLSurface::getLayer() { + return m_pLayerOwner.lock(); } CPopup* CWLSurface::getPopup() { @@ -167,7 +167,7 @@ CSubsurface* CWLSurface::getSubsurface() { } bool CWLSurface::desktopComponent() { - return m_pLayerOwner || !m_pWindowOwner.expired() || m_pSubsurfaceOwner || m_pPopupOwner; + return !m_pLayerOwner.expired() || !m_pWindowOwner.expired() || m_pSubsurfaceOwner || m_pPopupOwner; } std::optional CWLSurface::getSurfaceBoxGlobal() { @@ -176,8 +176,8 @@ std::optional CWLSurface::getSurfaceBoxGlobal() { if (!m_pWindowOwner.expired()) return m_pWindowOwner.lock()->getWindowMainSurfaceBox(); - if (m_pLayerOwner) - return m_pLayerOwner->geometry; + if (!m_pLayerOwner.expired()) + return m_pLayerOwner.lock()->geometry; if (m_pPopupOwner) return CBox{m_pPopupOwner->coordsGlobal(), m_pPopupOwner->size()}; if (m_pSubsurfaceOwner) -- cgit v1.2.3