From bca7804bb6e1bf5ce5a99b9ae4806be25e36993c Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Sat, 27 Apr 2024 12:43:12 +0100 Subject: internal: Window storage rework - part 1 (#5762) * Window storage rework - part 1 * format * remove useless include * fix pch * format * fix crash in dwindle * fix vram leak * prefer .expired() for bool checks --- src/desktop/Popup.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/desktop/Popup.cpp') diff --git a/src/desktop/Popup.cpp b/src/desktop/Popup.cpp index 6a2aca7e..527c0b38 100644 --- a/src/desktop/Popup.cpp +++ b/src/desktop/Popup.cpp @@ -2,7 +2,7 @@ #include "../config/ConfigValue.hpp" #include "../Compositor.hpp" -CPopup::CPopup(CWindow* pOwner) : m_pWindowOwner(pOwner) { +CPopup::CPopup(PHLWINDOW pOwner) : m_pWindowOwner(pOwner) { initAllSignals(); } @@ -69,8 +69,8 @@ static void onRepositionPopup(void* owner, void* data) { void CPopup::initAllSignals() { if (!m_pWLR) { - if (m_pWindowOwner) - hyprListener_newPopup.initCallback(&m_pWindowOwner->m_uSurface.xdg->events.new_popup, ::onNewPopup, this, "CPopup Head"); + if (!m_pWindowOwner.expired()) + hyprListener_newPopup.initCallback(&m_pWindowOwner.lock()->m_uSurface.xdg->events.new_popup, ::onNewPopup, this, "CPopup Head"); else if (m_pLayerOwner) hyprListener_newPopup.initCallback(&m_pLayerOwner->layerSurface->events.new_popup, ::onNewPopup, this, "CPopup Head"); else @@ -146,12 +146,12 @@ void CPopup::onCommit(bool ignoreSiblings) { return; } - if (m_pWindowOwner && (!m_pWindowOwner->m_bIsMapped || !m_pWindowOwner->m_pWorkspace->m_bVisible)) { + if (!m_pWindowOwner.expired() && (!m_pWindowOwner.lock()->m_bIsMapped || !m_pWindowOwner.lock()->m_pWorkspace->m_bVisible)) { m_vLastSize = {m_pWLR->base->current.geometry.width, m_pWLR->base->current.geometry.height}; static auto PLOGDAMAGE = CConfigValue("debug:log_damage"); if (*PLOGDAMAGE) - Debug::log(LOG, "Refusing to commit damage from a subsurface of {} because it's invisible.", m_pWindowOwner); + Debug::log(LOG, "Refusing to commit damage from a subsurface of {} because it's invisible.", m_pWindowOwner.lock()); return; } @@ -230,8 +230,8 @@ Vector2D CPopup::localToGlobal(const Vector2D& rel) { } Vector2D CPopup::t1ParentCoords() { - if (m_pWindowOwner) - return m_pWindowOwner->m_vRealPosition.value(); + if (!m_pWindowOwner.expired()) + return m_pWindowOwner.lock()->m_vRealPosition.value(); if (m_pLayerOwner) return m_pLayerOwner->realPosition.value(); @@ -260,8 +260,8 @@ Vector2D CPopup::size() { } void CPopup::sendScale() { - if (m_pWindowOwner) - g_pCompositor->setPreferredScaleForSurface(m_sWLSurface.wlr(), m_pWindowOwner->m_pWLSurface.m_fLastScale); + if (!m_pWindowOwner.expired()) + g_pCompositor->setPreferredScaleForSurface(m_sWLSurface.wlr(), m_pWindowOwner.lock()->m_pWLSurface.m_fLastScale); else if (m_pLayerOwner) g_pCompositor->setPreferredScaleForSurface(m_sWLSurface.wlr(), m_pLayerOwner->surface.m_fLastScale); else -- cgit v1.2.3