diff options
| author | Vaxry <vaxry@vaxry.net> | 2025-02-01 15:08:30 +0000 |
|---|---|---|
| committer | Vaxry <vaxry@vaxry.net> | 2025-02-01 15:08:30 +0000 |
| commit | c6f672257bd2ae98f4fd7a6a273b2d1d3e944baa (patch) | |
| tree | 3b331626749173588719ac4303dd347af0820e5e /src/desktop/Popup.cpp | |
| parent | 5b43c106bd1cde9ac0b5626130890cde4de0b245 (diff) | |
desktop: move popup and subsurface ctors to factories
makes sure m_pSelf is set before we do anything like possibly adding children
fixes #9275
supersedes #9276
Diffstat (limited to 'src/desktop/Popup.cpp')
| -rw-r--r-- | src/desktop/Popup.cpp | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/src/desktop/Popup.cpp b/src/desktop/Popup.cpp index dea94f55..20ff49d7 100644 --- a/src/desktop/Popup.cpp +++ b/src/desktop/Popup.cpp @@ -12,23 +12,37 @@ #include "../render/OpenGL.hpp" #include <ranges> -CPopup::CPopup(PHLWINDOW pOwner) : m_pWindowOwner(pOwner) { - initAllSignals(); +SP<CPopup> CPopup::create(PHLWINDOW pOwner) { + auto popup = SP<CPopup>(new CPopup()); + popup->m_pWindowOwner = pOwner; + popup->m_pSelf = popup; + popup->initAllSignals(); + return popup; } -CPopup::CPopup(PHLLS pOwner) : m_pLayerOwner(pOwner) { - initAllSignals(); +SP<CPopup> CPopup::create(PHLLS pOwner) { + auto popup = SP<CPopup>(new CPopup()); + popup->m_pLayerOwner = pOwner; + popup->m_pSelf = popup; + popup->initAllSignals(); + return popup; } -CPopup::CPopup(SP<CXDGPopupResource> popup, WP<CPopup> pOwner) : - m_pWindowOwner(pOwner->m_pWindowOwner), m_pLayerOwner(pOwner->m_pLayerOwner), m_pParent(pOwner), m_pResource(popup) { - m_pWLSurface = CWLSurface::create(); - m_pWLSurface->assign(popup->surface->surface.lock(), this); - - m_vLastSize = popup->surface->current.geometry.size(); - reposition(); - - initAllSignals(); +SP<CPopup> CPopup::create(SP<CXDGPopupResource> resource, WP<CPopup> pOwner) { + auto popup = SP<CPopup>(new CPopup()); + popup->m_pResource = resource; + popup->m_pWindowOwner = pOwner->m_pWindowOwner; + popup->m_pLayerOwner = pOwner->m_pLayerOwner; + popup->m_pParent = pOwner; + popup->m_pSelf = popup; + popup->m_pWLSurface = CWLSurface::create(); + popup->m_pWLSurface->assign(resource->surface->surface.lock(), popup.get()); + + popup->m_vLastSize = resource->surface->current.geometry.size(); + popup->reposition(); + + popup->initAllSignals(); + return popup; } CPopup::~CPopup() { @@ -59,7 +73,7 @@ void CPopup::initAllSignals() { } void CPopup::onNewPopup(SP<CXDGPopupResource> popup) { - const auto& POPUP = m_vChildren.emplace_back(makeShared<CPopup>(popup, m_pSelf)); + const auto& POPUP = m_vChildren.emplace_back(CPopup::create(popup, m_pSelf)); POPUP->m_pSelf = POPUP; Debug::log(LOG, "New popup at {:x}", (uintptr_t)POPUP); } @@ -91,8 +105,7 @@ void CPopup::onMap() { g_pInputManager->simulateMouseMovement(); - m_pSubsurfaceHead = makeUnique<CSubsurface>(m_pSelf); - m_pSubsurfaceHead->m_pSelf = m_pSubsurfaceHead; + m_pSubsurfaceHead = CSubsurface::create(m_pSelf); //unconstrain(); sendScale(); |
