mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-07-25 17:21:54 -07:00
desktop: Damage subsurface when position changes (#10094)
This commit is contained in:
@@ -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 {};
|
||||
|
@@ -49,7 +49,8 @@ class CSubsurface {
|
||||
|
||||
WP<CWLSubsurfaceResource> m_pSubsurface;
|
||||
SP<CWLSurface> m_pWLSurface;
|
||||
Vector2D m_vLastSize = {};
|
||||
Vector2D m_vLastSize = {};
|
||||
Vector2D m_vLastPosition = {};
|
||||
|
||||
// if nullptr, means it's a dummy node
|
||||
WP<CSubsurface> m_pParent;
|
||||
@@ -64,4 +65,5 @@ class CSubsurface {
|
||||
void initSignals();
|
||||
void initExistingSubsurfaces(SP<CWLSurfaceResource> pSurface);
|
||||
void checkSiblingDamage();
|
||||
void damageLastArea();
|
||||
};
|
||||
|
@@ -99,8 +99,10 @@ CWLSubsurfaceResource::~CWLSubsurfaceResource() {
|
||||
}
|
||||
|
||||
void CWLSubsurfaceResource::destroy() {
|
||||
if (surface && surface->mapped)
|
||||
if (surface && surface->mapped) {
|
||||
surface->events.unmap.emit();
|
||||
surface->unmap();
|
||||
}
|
||||
events.destroy.emit();
|
||||
PROTO::subcompositor->destroyResource(this);
|
||||
}
|
||||
|
Reference in New Issue
Block a user