summaryrefslogtreecommitdiff
path: root/src/desktop/Subsurface.cpp
diff options
context:
space:
mode:
authordavc0n <dconti.dev@gmail.com>2025-04-25 02:37:12 +0200
committerGitHub <noreply@github.com>2025-04-25 02:37:12 +0200
commit02d7badd15601e52547e2f3e1c594ceede0a0455 (patch)
tree9b4ae3a642231f7a7d3360d5b3858106f6f1c0cd /src/desktop/Subsurface.cpp
parent0e80ecc5342db04c8c1f807fa6db4c703fb89e3a (diff)
workspaces: refactor class member vars (#10167)
Diffstat (limited to 'src/desktop/Subsurface.cpp')
-rw-r--r--src/desktop/Subsurface.cpp156
1 files changed, 78 insertions, 78 deletions
diff --git a/src/desktop/Subsurface.cpp b/src/desktop/Subsurface.cpp
index d30692fe..60032ead 100644
--- a/src/desktop/Subsurface.cpp
+++ b/src/desktop/Subsurface.cpp
@@ -8,9 +8,9 @@
#include "../managers/input/InputManager.hpp"
UP<CSubsurface> CSubsurface::create(PHLWINDOW pOwner) {
- auto subsurface = UP<CSubsurface>(new CSubsurface());
- subsurface->m_pWindowParent = pOwner;
- subsurface->m_pSelf = subsurface;
+ auto subsurface = UP<CSubsurface>(new CSubsurface());
+ subsurface->m_windowParent = pOwner;
+ subsurface->m_self = subsurface;
subsurface->initSignals();
subsurface->initExistingSubsurfaces(pOwner->m_pWLSurface->resource());
@@ -18,155 +18,155 @@ UP<CSubsurface> CSubsurface::create(PHLWINDOW pOwner) {
}
UP<CSubsurface> CSubsurface::create(WP<CPopup> pOwner) {
- auto subsurface = UP<CSubsurface>(new CSubsurface());
- subsurface->m_pPopupParent = pOwner;
- subsurface->m_pSelf = subsurface;
+ auto subsurface = UP<CSubsurface>(new CSubsurface());
+ subsurface->m_popupParent = pOwner;
+ subsurface->m_self = subsurface;
subsurface->initSignals();
subsurface->initExistingSubsurfaces(pOwner->m_wlSurface->resource());
return subsurface;
}
UP<CSubsurface> CSubsurface::create(SP<CWLSubsurfaceResource> pSubsurface, PHLWINDOW pOwner) {
- auto subsurface = UP<CSubsurface>(new CSubsurface());
- subsurface->m_pWindowParent = pOwner;
- subsurface->m_pSubsurface = pSubsurface;
- subsurface->m_pSelf = subsurface;
- subsurface->m_pWLSurface = CWLSurface::create();
- subsurface->m_pWLSurface->assign(pSubsurface->surface.lock(), subsurface.get());
+ auto subsurface = UP<CSubsurface>(new CSubsurface());
+ subsurface->m_windowParent = pOwner;
+ subsurface->m_subsurface = pSubsurface;
+ subsurface->m_self = subsurface;
+ subsurface->m_wlSurface = CWLSurface::create();
+ subsurface->m_wlSurface->assign(pSubsurface->surface.lock(), subsurface.get());
subsurface->initSignals();
subsurface->initExistingSubsurfaces(pSubsurface->surface.lock());
return subsurface;
}
UP<CSubsurface> CSubsurface::create(SP<CWLSubsurfaceResource> pSubsurface, WP<CPopup> pOwner) {
- auto subsurface = UP<CSubsurface>(new CSubsurface());
- subsurface->m_pPopupParent = pOwner;
- subsurface->m_pSubsurface = pSubsurface;
- subsurface->m_pSelf = subsurface;
- subsurface->m_pWLSurface = CWLSurface::create();
- subsurface->m_pWLSurface->assign(pSubsurface->surface.lock(), subsurface.get());
+ auto subsurface = UP<CSubsurface>(new CSubsurface());
+ subsurface->m_popupParent = pOwner;
+ subsurface->m_subsurface = pSubsurface;
+ subsurface->m_self = subsurface;
+ subsurface->m_wlSurface = CWLSurface::create();
+ subsurface->m_wlSurface->assign(pSubsurface->surface.lock(), subsurface.get());
subsurface->initSignals();
subsurface->initExistingSubsurfaces(pSubsurface->surface.lock());
return subsurface;
}
void CSubsurface::initSignals() {
- if (m_pSubsurface) {
- listeners.commitSubsurface = m_pSubsurface->surface->events.commit.registerListener([this](std::any d) { onCommit(); });
- listeners.destroySubsurface = m_pSubsurface->events.destroy.registerListener([this](std::any d) { onDestroy(); });
- listeners.mapSubsurface = m_pSubsurface->surface->events.map.registerListener([this](std::any d) { onMap(); });
- listeners.unmapSubsurface = m_pSubsurface->surface->events.unmap.registerListener([this](std::any d) { onUnmap(); });
- listeners.newSubsurface =
- m_pSubsurface->surface->events.newSubsurface.registerListener([this](std::any d) { onNewSubsurface(std::any_cast<SP<CWLSubsurfaceResource>>(d)); });
+ if (m_subsurface) {
+ m_listeners.commitSubsurface = m_subsurface->surface->events.commit.registerListener([this](std::any d) { onCommit(); });
+ m_listeners.destroySubsurface = m_subsurface->events.destroy.registerListener([this](std::any d) { onDestroy(); });
+ m_listeners.mapSubsurface = m_subsurface->surface->events.map.registerListener([this](std::any d) { onMap(); });
+ m_listeners.unmapSubsurface = m_subsurface->surface->events.unmap.registerListener([this](std::any d) { onUnmap(); });
+ m_listeners.newSubsurface =
+ m_subsurface->surface->events.newSubsurface.registerListener([this](std::any d) { onNewSubsurface(std::any_cast<SP<CWLSubsurfaceResource>>(d)); });
} else {
- if (m_pWindowParent)
- listeners.newSubsurface = m_pWindowParent->m_pWLSurface->resource()->events.newSubsurface.registerListener(
- [this](std::any d) { onNewSubsurface(std::any_cast<SP<CWLSubsurfaceResource>>(d)); });
- else if (m_pPopupParent)
- listeners.newSubsurface = m_pPopupParent->m_wlSurface->resource()->events.newSubsurface.registerListener(
+ if (m_windowParent)
+ m_listeners.newSubsurface = m_windowParent->m_pWLSurface->resource()->events.newSubsurface.registerListener(
[this](std::any d) { onNewSubsurface(std::any_cast<SP<CWLSubsurfaceResource>>(d)); });
+ else if (m_popupParent)
+ m_listeners.newSubsurface =
+ m_popupParent->m_wlSurface->resource()->events.newSubsurface.registerListener([this](std::any d) { onNewSubsurface(std::any_cast<SP<CWLSubsurfaceResource>>(d)); });
else
ASSERT(false);
}
}
void CSubsurface::checkSiblingDamage() {
- if (!m_pParent)
+ if (!m_parent)
return; // ??????????
- const double SCALE = m_pWindowParent.lock() && m_pWindowParent->m_bIsX11 ? 1.0 / m_pWindowParent->m_fX11SurfaceScaledBy : 1.0;
+ const double SCALE = m_windowParent.lock() && m_windowParent->m_bIsX11 ? 1.0 / m_windowParent->m_fX11SurfaceScaledBy : 1.0;
- for (auto const& n : m_pParent->m_vChildren) {
+ for (auto const& n : m_parent->m_children) {
if (n.get() == this)
continue;
const auto COORDS = n->coordsGlobal();
- g_pHyprRenderer->damageSurface(n->m_pWLSurface->resource(), COORDS.x, COORDS.y, SCALE);
+ g_pHyprRenderer->damageSurface(n->m_wlSurface->resource(), COORDS.x, COORDS.y, SCALE);
}
}
void CSubsurface::recheckDamageForSubsurfaces() {
- for (auto const& n : m_vChildren) {
+ for (auto const& n : m_children) {
const auto COORDS = n->coordsGlobal();
- g_pHyprRenderer->damageSurface(n->m_pWLSurface->resource(), COORDS.x, COORDS.y);
+ g_pHyprRenderer->damageSurface(n->m_wlSurface->resource(), COORDS.x, COORDS.y);
}
}
void CSubsurface::onCommit() {
// no damaging if it's not visible
- if (!m_pWindowParent.expired() && (!m_pWindowParent->m_bIsMapped || !m_pWindowParent->m_pWorkspace->m_bVisible)) {
- m_vLastSize = m_pWLSurface->resource()->current.size;
+ if (!m_windowParent.expired() && (!m_windowParent->m_bIsMapped || !m_windowParent->m_pWorkspace->m_visible)) {
+ m_lastSize = m_wlSurface->resource()->current.size;
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.lock());
+ Debug::log(LOG, "Refusing to commit damage from a subsurface of {} because it's invisible.", m_windowParent.lock());
return;
}
const auto COORDS = coordsGlobal();
- g_pHyprRenderer->damageSurface(m_pWLSurface->resource(), COORDS.x, COORDS.y);
+ g_pHyprRenderer->damageSurface(m_wlSurface->resource(), COORDS.x, COORDS.y);
- if (m_pPopupParent && !m_pPopupParent->inert() && m_pPopupParent->m_wlSurface)
- m_pPopupParent->recheckTree();
- if (!m_pWindowParent.expired()) // I hate you firefox why are you doing this
- m_pWindowParent->m_pPopupHead->recheckTree();
+ if (m_popupParent && !m_popupParent->inert() && m_popupParent->m_wlSurface)
+ m_popupParent->recheckTree();
+ if (!m_windowParent.expired()) // I hate you firefox why are you doing this
+ m_windowParent->m_pPopupHead->recheckTree();
// I do not think this is correct, but it solves a lot of issues with some apps (e.g. firefox)
checkSiblingDamage();
- if (m_vLastSize != m_pWLSurface->resource()->current.size || m_vLastPosition != m_pSubsurface->position) {
+ if (m_lastSize != m_wlSurface->resource()->current.size || m_lastPosition != m_subsurface->position) {
damageLastArea();
- m_vLastSize = m_pWLSurface->resource()->current.size;
- m_vLastPosition = m_pSubsurface->position;
+ m_lastSize = m_wlSurface->resource()->current.size;
+ m_lastPosition = m_subsurface->position;
}
}
void CSubsurface::onDestroy() {
// destroy children
- m_vChildren.clear();
+ m_children.clear();
- m_bInert = true;
+ m_inert = true;
- if (!m_pSubsurface)
+ if (!m_subsurface)
return; // dummy node, nothing to do, it's the parent dying
// kill ourselves
- std::erase_if(m_pParent->m_vChildren, [this](const auto& other) { return other.get() == this; });
+ std::erase_if(m_parent->m_children, [this](const auto& other) { return other.get() == this; });
}
void CSubsurface::onNewSubsurface(SP<CWLSubsurfaceResource> pSubsurface) {
WP<CSubsurface> PSUBSURFACE;
- if (!m_pWindowParent.expired())
- PSUBSURFACE = m_vChildren.emplace_back(CSubsurface::create(pSubsurface, m_pWindowParent.lock()));
- else if (m_pPopupParent)
- PSUBSURFACE = m_vChildren.emplace_back(CSubsurface::create(pSubsurface, m_pPopupParent));
+ if (!m_windowParent.expired())
+ PSUBSURFACE = m_children.emplace_back(CSubsurface::create(pSubsurface, m_windowParent.lock()));
+ else if (m_popupParent)
+ PSUBSURFACE = m_children.emplace_back(CSubsurface::create(pSubsurface, m_popupParent));
- PSUBSURFACE->m_pSelf = PSUBSURFACE;
+ PSUBSURFACE->m_self = PSUBSURFACE;
ASSERT(PSUBSURFACE);
- PSUBSURFACE->m_pParent = m_pSelf;
+ PSUBSURFACE->m_parent = m_self;
}
void CSubsurface::onMap() {
- m_vLastSize = m_pWLSurface->resource()->current.size;
- m_vLastPosition = m_pSubsurface->position;
+ m_lastSize = m_wlSurface->resource()->current.size;
+ m_lastPosition = m_subsurface->position;
const auto COORDS = coordsGlobal();
- CBox box{COORDS, m_vLastSize};
+ CBox box{COORDS, m_lastSize};
box.expand(4);
g_pHyprRenderer->damageBox(box);
- if (!m_pWindowParent.expired())
- m_pWindowParent->updateSurfaceScaleTransformDetails();
+ if (!m_windowParent.expired())
+ m_windowParent->updateSurfaceScaleTransformDetails();
}
void CSubsurface::onUnmap() {
damageLastArea();
- if (m_pWLSurface->resource() == g_pCompositor->m_lastFocus)
+ if (m_wlSurface->resource() == g_pCompositor->m_lastFocus)
g_pInputManager->releaseAllMouseButtons();
g_pInputManager->simulateMouseMovement();
@@ -175,25 +175,25 @@ void CSubsurface::onUnmap() {
}
void CSubsurface::damageLastArea() {
- const auto COORDS = coordsGlobal() + m_vLastPosition - m_pSubsurface->position;
- CBox box{COORDS, m_vLastSize};
+ const auto COORDS = coordsGlobal() + m_lastPosition - m_subsurface->position;
+ CBox box{COORDS, m_lastSize};
box.expand(4);
g_pHyprRenderer->damageBox(box);
}
Vector2D CSubsurface::coordsRelativeToParent() {
- if (!m_pSubsurface)
+ if (!m_subsurface)
return {};
- return m_pSubsurface->posRelativeToParent();
+ return m_subsurface->posRelativeToParent();
}
Vector2D CSubsurface::coordsGlobal() {
Vector2D coords = coordsRelativeToParent();
- if (!m_pWindowParent.expired())
- coords += m_pWindowParent->m_vRealPosition->value();
- else if (m_pPopupParent)
- coords += m_pPopupParent->coordsGlobal();
+ if (!m_windowParent.expired())
+ coords += m_windowParent->m_vRealPosition->value();
+ else if (m_popupParent)
+ coords += m_popupParent->coordsGlobal();
return coords;
}
@@ -207,16 +207,16 @@ void CSubsurface::initExistingSubsurfaces(SP<CWLSurfaceResource> pSurface) {
}
Vector2D CSubsurface::size() {
- return m_pWLSurface->resource()->current.size;
+ return m_wlSurface->resource()->current.size;
}
bool CSubsurface::visible() {
- if (!m_pWindowParent.expired())
- return g_pHyprRenderer->shouldRenderWindow(m_pWindowParent.lock());
- if (m_pPopupParent)
- return m_pPopupParent->visible();
- if (m_pParent)
- return m_pParent->visible();
+ if (!m_windowParent.expired())
+ return g_pHyprRenderer->shouldRenderWindow(m_windowParent.lock());
+ if (m_popupParent)
+ return m_popupParent->visible();
+ if (m_parent)
+ return m_parent->visible();
return false;
}