diff options
| author | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2024-04-27 12:43:12 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-27 12:43:12 +0100 |
| commit | bca7804bb6e1bf5ce5a99b9ae4806be25e36993c (patch) | |
| tree | ebd3a578de1dfe11b54f9440cfc3a408ffa6a620 /src/desktop/Subsurface.cpp | |
| parent | 25aec3ac8ce65ed224f025f8f6dfef73780577a4 (diff) | |
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
Diffstat (limited to 'src/desktop/Subsurface.cpp')
| -rw-r--r-- | src/desktop/Subsurface.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/desktop/Subsurface.cpp b/src/desktop/Subsurface.cpp index fd9d1899..b2c9f8bd 100644 --- a/src/desktop/Subsurface.cpp +++ b/src/desktop/Subsurface.cpp @@ -5,7 +5,7 @@ static void onNewSubsurface(void* owner, void* data); -CSubsurface::CSubsurface(CWindow* pOwner) : m_pWindowParent(pOwner) { +CSubsurface::CSubsurface(PHLWINDOW pOwner) : m_pWindowParent(pOwner) { initSignals(); initExistingSubsurfaces(pOwner->m_pWLSurface.wlr()); } @@ -15,7 +15,7 @@ CSubsurface::CSubsurface(CPopup* pOwner) : m_pPopupParent(pOwner) { initExistingSubsurfaces(pOwner->m_sWLSurface.wlr()); } -CSubsurface::CSubsurface(wlr_subsurface* pSubsurface, CWindow* pOwner) : m_pSubsurface(pSubsurface), m_pWindowParent(pOwner) { +CSubsurface::CSubsurface(wlr_subsurface* pSubsurface, PHLWINDOW pOwner) : m_pSubsurface(pSubsurface), m_pWindowParent(pOwner) { m_sWLSurface.assign(pSubsurface->surface, this); initSignals(); initExistingSubsurfaces(pSubsurface->surface); @@ -73,8 +73,8 @@ void CSubsurface::initSignals() { hyprListener_mapSubsurface.initCallback(&m_pSubsurface->surface->events.map, &onMapSubsurface, this, "CSubsurface"); hyprListener_unmapSubsurface.initCallback(&m_pSubsurface->surface->events.unmap, &onUnmapSubsurface, this, "CSubsurface"); } else { - if (m_pWindowParent) - hyprListener_newSubsurface.initCallback(&m_pWindowParent->m_pWLSurface.wlr()->events.new_subsurface, &::onNewSubsurface, this, "CSubsurface Head"); + if (!m_pWindowParent.expired()) + hyprListener_newSubsurface.initCallback(&m_pWindowParent.lock()->m_pWLSurface.wlr()->events.new_subsurface, &::onNewSubsurface, this, "CSubsurface Head"); else if (m_pPopupParent) hyprListener_newSubsurface.initCallback(&m_pPopupParent->m_sWLSurface.wlr()->events.new_subsurface, &::onNewSubsurface, this, "CSubsurface Head"); else @@ -86,7 +86,7 @@ void CSubsurface::checkSiblingDamage() { if (!m_pParent) return; // ?????????? - const double SCALE = m_pWindowParent && m_pWindowParent->m_bIsX11 ? 1.0 / m_pWindowParent->m_fX11SurfaceScaledBy : 1.0; + const double SCALE = m_pWindowParent.lock() && m_pWindowParent.lock()->m_bIsX11 ? 1.0 / m_pWindowParent.lock()->m_fX11SurfaceScaledBy : 1.0; for (auto& n : m_pParent->m_vChildren) { if (n.get() == this) @@ -106,12 +106,12 @@ void CSubsurface::recheckDamageForSubsurfaces() { void CSubsurface::onCommit() { // no damaging if it's not visible - if (m_pWindowParent && (!m_pWindowParent->m_bIsMapped || !m_pWindowParent->m_pWorkspace->m_bVisible)) { + if (!m_pWindowParent.expired() && (!m_pWindowParent.lock()->m_bIsMapped || !m_pWindowParent.lock()->m_pWorkspace->m_bVisible)) { m_vLastSize = Vector2D{m_sWLSurface.wlr()->current.width, m_sWLSurface.wlr()->current.height}; static auto PLOGDAMAGE = CConfigValue<Hyprlang::INT>("debug:log_damage"); if (*PLOGDAMAGE) - Debug::log(LOG, "Refusing to commit damage from a subsurface of {} because it's invisible.", m_pWindowParent); + Debug::log(LOG, "Refusing to commit damage from a subsurface of {} because it's invisible.", m_pWindowParent.lock()); return; } @@ -121,8 +121,8 @@ void CSubsurface::onCommit() { if (m_pPopupParent) m_pPopupParent->recheckTree(); - if (m_pWindowParent) // I hate you firefox why are you doing this - m_pWindowParent->m_pPopupHead->recheckTree(); + if (!m_pWindowParent.expired()) // I hate you firefox why are you doing this + m_pWindowParent.lock()->m_pPopupHead->recheckTree(); // I do not think this is correct, but it solves a lot of issues with some apps (e.g. firefox) checkSiblingDamage(); @@ -152,8 +152,8 @@ void CSubsurface::onDestroy() { void CSubsurface::onNewSubsurface(wlr_subsurface* pSubsurface) { CSubsurface* PSUBSURFACE = nullptr; - if (m_pWindowParent) - PSUBSURFACE = m_vChildren.emplace_back(std::make_unique<CSubsurface>(pSubsurface, m_pWindowParent)).get(); + if (!m_pWindowParent.expired()) + PSUBSURFACE = m_vChildren.emplace_back(std::make_unique<CSubsurface>(pSubsurface, m_pWindowParent.lock())).get(); else if (m_pPopupParent) PSUBSURFACE = m_vChildren.emplace_back(std::make_unique<CSubsurface>(pSubsurface, m_pPopupParent)).get(); PSUBSURFACE->m_pParent = this; @@ -169,8 +169,8 @@ void CSubsurface::onMap() { box.expand(4); g_pHyprRenderer->damageBox(&box); - if (m_pWindowParent) - m_pWindowParent->updateSurfaceScaleTransformDetails(); + if (!m_pWindowParent.expired()) + m_pWindowParent.lock()->updateSurfaceScaleTransformDetails(); } void CSubsurface::onUnmap() { @@ -206,8 +206,8 @@ Vector2D CSubsurface::coordsRelativeToParent() { Vector2D CSubsurface::coordsGlobal() { Vector2D coords = coordsRelativeToParent(); - if (m_pWindowParent) - coords += m_pWindowParent->m_vRealPosition.value(); + if (!m_pWindowParent.expired()) + coords += m_pWindowParent.lock()->m_vRealPosition.value(); else if (m_pPopupParent) coords += m_pPopupParent->coordsGlobal(); |
