subsurface: init existing subsurfaces on children creations

fixes #5333
This commit is contained in:
Vaxry 2024-04-06 03:09:20 +01:00
parent fb22c996eb
commit ec73f033aa
2 changed files with 11 additions and 25 deletions

View file

@ -7,38 +7,24 @@ static void onNewSubsurface(void* owner, void* data);
CSubsurface::CSubsurface(CWindow* pOwner) : m_pWindowParent(pOwner) { CSubsurface::CSubsurface(CWindow* pOwner) : m_pWindowParent(pOwner) {
initSignals(); initSignals();
initExistingSubsurfaces(pOwner->m_pWLSurface.wlr());
wlr_subsurface* wlrSubsurface;
wl_list_for_each(wlrSubsurface, &pOwner->m_pWLSurface.wlr()->current.subsurfaces_below, current.link) {
::onNewSubsurface(this, wlrSubsurface);
}
wl_list_for_each(wlrSubsurface, &pOwner->m_pWLSurface.wlr()->current.subsurfaces_above, current.link) {
::onNewSubsurface(this, wlrSubsurface);
}
} }
CSubsurface::CSubsurface(CPopup* pOwner) : m_pPopupParent(pOwner) { CSubsurface::CSubsurface(CPopup* pOwner) : m_pPopupParent(pOwner) {
initSignals(); initSignals();
initExistingSubsurfaces(pOwner->m_sWLSurface.wlr());
wlr_subsurface* wlrSubsurface;
wl_list_for_each(wlrSubsurface, &pOwner->m_sWLSurface.wlr()->current.subsurfaces_below, current.link) {
::onNewSubsurface(this, wlrSubsurface);
}
wl_list_for_each(wlrSubsurface, &pOwner->m_sWLSurface.wlr()->current.subsurfaces_above, current.link) {
::onNewSubsurface(this, wlrSubsurface);
}
} }
CSubsurface::CSubsurface(wlr_subsurface* pSubsurface, CWindow* pOwner) : m_pSubsurface(pSubsurface), m_pWindowParent(pOwner) { CSubsurface::CSubsurface(wlr_subsurface* pSubsurface, CWindow* pOwner) : m_pSubsurface(pSubsurface), m_pWindowParent(pOwner) {
m_sWLSurface.assign(pSubsurface->surface, this); m_sWLSurface.assign(pSubsurface->surface, this);
initSignals(); initSignals();
initExistingSubsurfaces(); initExistingSubsurfaces(pSubsurface->surface);
} }
CSubsurface::CSubsurface(wlr_subsurface* pSubsurface, CPopup* pOwner) : m_pSubsurface(pSubsurface), m_pPopupParent(pOwner) { CSubsurface::CSubsurface(wlr_subsurface* pSubsurface, CPopup* pOwner) : m_pSubsurface(pSubsurface), m_pPopupParent(pOwner) {
m_sWLSurface.assign(pSubsurface->surface, this); m_sWLSurface.assign(pSubsurface->surface, this);
initSignals(); initSignals();
initExistingSubsurfaces(); initExistingSubsurfaces(pSubsurface->surface);
} }
CSubsurface::~CSubsurface() { CSubsurface::~CSubsurface() {
@ -47,6 +33,8 @@ CSubsurface::~CSubsurface() {
if (!m_pSubsurface) if (!m_pSubsurface)
return; return;
m_pSubsurface->data = nullptr;
hyprListener_commitSubsurface.removeCallback(); hyprListener_commitSubsurface.removeCallback();
hyprListener_destroySubsurface.removeCallback(); hyprListener_destroySubsurface.removeCallback();
} }
@ -78,6 +66,7 @@ static void onUnmapSubsurface(void* owner, void* data) {
void CSubsurface::initSignals() { void CSubsurface::initSignals() {
if (m_pSubsurface) { if (m_pSubsurface) {
m_pSubsurface->data = this;
hyprListener_commitSubsurface.initCallback(&m_pSubsurface->surface->events.commit, &onCommitSubsurface, this, "CSubsurface"); hyprListener_commitSubsurface.initCallback(&m_pSubsurface->surface->events.commit, &onCommitSubsurface, this, "CSubsurface");
hyprListener_destroySubsurface.initCallback(&m_pSubsurface->events.destroy, &onDestroySubsurface, this, "CSubsurface"); hyprListener_destroySubsurface.initCallback(&m_pSubsurface->events.destroy, &onDestroySubsurface, this, "CSubsurface");
hyprListener_newSubsurface.initCallback(&m_pSubsurface->surface->events.new_subsurface, &::onNewSubsurface, this, "CSubsurface"); hyprListener_newSubsurface.initCallback(&m_pSubsurface->surface->events.new_subsurface, &::onNewSubsurface, this, "CSubsurface");
@ -225,15 +214,12 @@ Vector2D CSubsurface::coordsGlobal() {
return coords; return coords;
} }
void CSubsurface::initExistingSubsurfaces() { void CSubsurface::initExistingSubsurfaces(wlr_surface* pSurface) {
if (m_pWindowParent)
return;
wlr_subsurface* wlrSubsurface; wlr_subsurface* wlrSubsurface;
wl_list_for_each(wlrSubsurface, &m_sWLSurface.wlr()->current.subsurfaces_below, current.link) { wl_list_for_each(wlrSubsurface, &pSurface->current.subsurfaces_below, current.link) {
::onNewSubsurface(this, wlrSubsurface); ::onNewSubsurface(this, wlrSubsurface);
} }
wl_list_for_each(wlrSubsurface, &m_sWLSurface.wlr()->current.subsurfaces_above, current.link) { wl_list_for_each(wlrSubsurface, &pSurface->current.subsurfaces_above, current.link) {
::onNewSubsurface(this, wlrSubsurface); ::onNewSubsurface(this, wlrSubsurface);
} }
} }

View file

@ -54,6 +54,6 @@ class CSubsurface {
bool m_bInert = false; bool m_bInert = false;
void initSignals(); void initSignals();
void initExistingSubsurfaces(); void initExistingSubsurfaces(wlr_surface* pSurface);
void checkSiblingDamage(); void checkSiblingDamage();
}; };