desktop: Damage subsurface when position changes (#10094)

This commit is contained in:
Lee Bousfield
2025-04-16 10:49:01 -05:00
committed by GitHub
parent 1ae7e2164c
commit 3fa6320a39
3 changed files with 20 additions and 22 deletions

View File

@@ -115,21 +115,10 @@ void CSubsurface::onCommit() {
// 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) {
// TODO: fix this
// CBox box{COORDS, m_vLastSize};
// g_pHyprRenderer->damageBox(box);
// m_vLastSize = m_pWLSurface->resource()->current.size;
// box = {COORDS, m_vLastSize};
// g_pHyprRenderer->damageBox(box);
CBox box;
if (m_pPopupParent && !m_pPopupParent->inert() && m_pPopupParent->m_pWLSurface)
box = m_pPopupParent->m_pWLSurface->getSurfaceBoxGlobal().value_or(CBox{});
else if (m_pWindowParent)
box = m_pWindowParent->getWindowMainSurfaceBox();
g_pHyprRenderer->damageBox(box);
if (m_vLastSize != m_pWLSurface->resource()->current.size || m_vLastPosition != m_pSubsurface->position) {
damageLastArea();
m_vLastSize = m_pWLSurface->resource()->current.size;
m_vLastPosition = m_pSubsurface->position;
}
}
@@ -162,7 +151,8 @@ void CSubsurface::onNewSubsurface(SP<CWLSubsurfaceResource> pSubsurface) {
}
void CSubsurface::onMap() {
m_vLastSize = m_pWLSurface->resource()->current.size;
m_vLastSize = m_pWLSurface->resource()->current.size;
m_vLastPosition = m_pSubsurface->position;
const auto COORDS = coordsGlobal();
CBox box{COORDS, m_vLastSize};
@@ -174,10 +164,7 @@ void CSubsurface::onMap() {
}
void CSubsurface::onUnmap() {
const auto COORDS = coordsGlobal();
CBox box{COORDS, m_vLastSize};
box.expand(4);
g_pHyprRenderer->damageBox(box);
damageLastArea();
if (m_pWLSurface->resource() == g_pCompositor->m_pLastFocus)
g_pInputManager->releaseAllMouseButtons();
@@ -187,6 +174,13 @@ void CSubsurface::onUnmap() {
// TODO: should this remove children? Currently it won't, only on .destroy
}
void CSubsurface::damageLastArea() {
const auto COORDS = coordsGlobal() + m_vLastPosition - m_pSubsurface->position;
CBox box{COORDS, m_vLastSize};
box.expand(4);
g_pHyprRenderer->damageBox(box);
}
Vector2D CSubsurface::coordsRelativeToParent() {
if (!m_pSubsurface)
return {};