From ba5bc5871fb015a8fb55ff6991bc951f677a2a4f Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sun, 12 Nov 2023 23:06:31 +0000 Subject: [PATCH] subsurfaces: damage window on subsurface size change --- src/helpers/SubsurfaceTree.cpp | 10 +++++++++- src/helpers/SubsurfaceTree.hpp | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/helpers/SubsurfaceTree.cpp b/src/helpers/SubsurfaceTree.cpp index c10d45e1..5891411b 100644 --- a/src/helpers/SubsurfaceTree.cpp +++ b/src/helpers/SubsurfaceTree.cpp @@ -220,6 +220,8 @@ void Events::listener_commitSubsurface(void* owner, void* data) { // no damaging if it's not visible if (!g_pHyprRenderer->shouldRenderWindow(pNode->pWindowOwner)) { + pNode->lastSize = pNode->pSurface->exists() ? Vector2D{pNode->pSurface->wlr()->current.width, pNode->pSurface->wlr()->current.height} : Vector2D{}; + static auto* const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue; if (*PLOGDAMAGE) Debug::log(LOG, "Refusing to commit damage from {} because it's invisible.", pNode->pWindowOwner); @@ -244,9 +246,13 @@ void Events::listener_commitSubsurface(void* owner, void* data) { } } - if (pNode->pSurface && pNode->pSurface->exists()) + if (pNode->pSurface && pNode->pSurface->exists()) { g_pHyprRenderer->damageSurface(pNode->pSurface->wlr(), lx, ly, SCALE); + if (pNode->lastSize != Vector2D{pNode->pSurface->wlr()->current.width, pNode->pSurface->wlr()->current.height} && pNode->pWindowOwner) + g_pHyprRenderer->damageWindow(pNode->pWindowOwner); + } + if (pNode->pWindowOwner) { if (pNode->pWindowOwner->m_bIsX11) pNode->pWindowOwner->m_vReportedSize = pNode->pWindowOwner->m_vPendingReportedSize; // apply pending size. We pinged, the window ponged. @@ -269,6 +275,8 @@ void Events::listener_commitSubsurface(void* owner, void* data) { } } } + + pNode->lastSize = pNode->pSurface->exists() ? Vector2D{pNode->pSurface->wlr()->current.width, pNode->pSurface->wlr()->current.height} : Vector2D{}; } void Events::listener_destroySubsurface(void* owner, void* data) { diff --git a/src/helpers/SubsurfaceTree.hpp b/src/helpers/SubsurfaceTree.hpp index d6f04a58..7a8b8fb8 100644 --- a/src/helpers/SubsurfaceTree.hpp +++ b/src/helpers/SubsurfaceTree.hpp @@ -26,6 +26,8 @@ struct SSurfaceTreeNode { void* globalOffsetData; CWindow* pWindowOwner = nullptr; + Vector2D lastSize; + // bool operator==(const SSurfaceTreeNode& rhs) const { return pSurface == rhs.pSurface;