store total window deco extents as animated var

modified:   src/Window.cpp
modified:   src/Window.hpp
modified:   src/layout/DwindleLayout.cpp
modified:   src/layout/MasterLayout.cpp
modified:   src/render/Renderer.cpp
modified:   src/render/decorations/CHyprDropShadowDecoration.cpp

Signed-off-by: MightyPlaza <123664421+MightyPlaza@users.noreply.github.com>
This commit is contained in:
MightyPlaza 2023-09-15 20:04:02 +01:00
parent fdcd002125
commit 6013a3c8a0
No known key found for this signature in database
GPG key ID: 284C27FD27A6DC0D
6 changed files with 49 additions and 40 deletions

View file

@ -6,6 +6,10 @@
CWindow::CWindow() { CWindow::CWindow() {
m_vRealPosition.create(AVARTYPE_VECTOR, g_pConfigManager->getAnimationPropertyConfig("windowsIn"), (void*)this, AVARDAMAGE_ENTIRE); m_vRealPosition.create(AVARTYPE_VECTOR, g_pConfigManager->getAnimationPropertyConfig("windowsIn"), (void*)this, AVARDAMAGE_ENTIRE);
m_vRealSize.create(AVARTYPE_VECTOR, g_pConfigManager->getAnimationPropertyConfig("windowsIn"), (void*)this, AVARDAMAGE_ENTIRE); m_vRealSize.create(AVARTYPE_VECTOR, g_pConfigManager->getAnimationPropertyConfig("windowsIn"), (void*)this, AVARDAMAGE_ENTIRE);
m_vReservedInternalTopLeft.create(AVARTYPE_VECTOR, g_pConfigManager->getAnimationPropertyConfig("windowsIn"), (void*)this, AVARDAMAGE_ENTIRE);
m_vReservedInternalBottomRight.create(AVARTYPE_VECTOR, g_pConfigManager->getAnimationPropertyConfig("windowsIn"), (void*)this, AVARDAMAGE_ENTIRE);
m_vReservedExternalTopLeft.create(AVARTYPE_VECTOR, g_pConfigManager->getAnimationPropertyConfig("windowsIn"), (void*)this, AVARDAMAGE_ENTIRE);
m_vReservedExternalBottomRight.create(AVARTYPE_VECTOR, g_pConfigManager->getAnimationPropertyConfig("windowsIn"), (void*)this, AVARDAMAGE_ENTIRE);
m_fBorderFadeAnimationProgress.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("border"), (void*)this, AVARDAMAGE_BORDER); m_fBorderFadeAnimationProgress.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("border"), (void*)this, AVARDAMAGE_BORDER);
m_fBorderAngleAnimationProgress.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("borderangle"), (void*)this, AVARDAMAGE_BORDER); m_fBorderAngleAnimationProgress.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("borderangle"), (void*)this, AVARDAMAGE_BORDER);
m_fAlpha.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("fadeIn"), (void*)this, AVARDAMAGE_ENTIRE); m_fAlpha.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("fadeIn"), (void*)this, AVARDAMAGE_ENTIRE);
@ -50,8 +54,8 @@ SWindowDecorationExtents CWindow::getFullWindowExtents() {
maxOutterExtents.bottomRight.y = std::max(maxOutterExtents.bottomRight.y, EXTENTS.bottomRight.y); maxOutterExtents.bottomRight.y = std::max(maxOutterExtents.bottomRight.y, EXTENTS.bottomRight.y);
} }
SWindowDecorationExtents maxExtents = {m_seReservedInternal.topLeft + Vector2D{BORDERSIZE + 2, BORDERSIZE + 2} + maxOutterExtents.topLeft, SWindowDecorationExtents maxExtents = {m_vReservedInternalTopLeft.goalv() + Vector2D{BORDERSIZE + 2, BORDERSIZE + 2} + maxOutterExtents.topLeft,
m_seReservedInternal.bottomRight + Vector2D{BORDERSIZE + 2, BORDERSIZE + 2} + maxOutterExtents.bottomRight}; m_vReservedInternalBottomRight.goalv() + Vector2D{BORDERSIZE + 2, BORDERSIZE + 2} + maxOutterExtents.bottomRight};
if (m_pWLSurface.exists() && !m_bIsX11) { if (m_pWLSurface.exists() && !m_bIsX11) {
wlr_box surfaceExtents = {0, 0, 0, 0}; wlr_box surfaceExtents = {0, 0, 0, 0};
@ -141,8 +145,8 @@ wlr_box CWindow::getWindowInputBox() {
return {PMONITOR->vecPosition.x, PMONITOR->vecPosition.y, PMONITOR->vecSize.x, PMONITOR->vecSize.y}; return {PMONITOR->vecPosition.x, PMONITOR->vecPosition.y, PMONITOR->vecSize.x, PMONITOR->vecSize.y};
} }
SWindowDecorationExtents maxExtents = {m_seReservedInternal.topLeft + Vector2D{BORDERSIZE + 2, BORDERSIZE + 2} + m_seReservedExternal.topLeft, SWindowDecorationExtents maxExtents = {m_vReservedInternalTopLeft.goalv() + Vector2D{BORDERSIZE + 2, BORDERSIZE + 2} + m_vReservedExternalTopLeft.goalv(),
m_seReservedInternal.bottomRight + Vector2D{BORDERSIZE + 2, BORDERSIZE + 2} + m_seReservedExternal.bottomRight}; m_vReservedInternalBottomRight.goalv() + Vector2D{BORDERSIZE + 2, BORDERSIZE + 2} + m_vReservedExternalBottomRight.goalv()};
// Add extents to the real base BB and return // Add extents to the real base BB and return
wlr_box finalBox = {m_vRealPosition.vec().x - maxExtents.topLeft.x, m_vRealPosition.vec().y - maxExtents.topLeft.y, wlr_box finalBox = {m_vRealPosition.vec().x - maxExtents.topLeft.x, m_vRealPosition.vec().y - maxExtents.topLeft.y,
@ -153,12 +157,13 @@ wlr_box CWindow::getWindowInputBox() {
SWindowDecorationExtents CWindow::getFullWindowReservedArea() { SWindowDecorationExtents CWindow::getFullWindowReservedArea() {
const int BORDERSIZE = getRealBorderSize(); const int BORDERSIZE = getRealBorderSize();
return {m_seReservedInternal.topLeft + m_seReservedExternal.topLeft + Vector2D(BORDERSIZE, BORDERSIZE), return {m_vReservedInternalTopLeft.goalv() + m_vReservedExternalTopLeft.goalv() + Vector2D(BORDERSIZE, BORDERSIZE),
m_seReservedInternal.bottomRight + m_seReservedExternal.bottomRight + Vector2D(BORDERSIZE, BORDERSIZE)}; m_vReservedInternalBottomRight.goalv() + m_vReservedExternalBottomRight.goalv() + Vector2D(BORDERSIZE, BORDERSIZE)};
} }
wlr_box CWindow::getWindowInternalBox() { wlr_box CWindow::getWindowInternalBox() {
wlr_box internalBox = {m_vRealPosition.vec().x, m_vRealPosition.vec().y, m_vRealSize.vec().x, m_vRealSize.vec().y}; wlr_box internalBox = {m_vRealPosition.vec().x, m_vRealPosition.vec().y, m_vRealSize.vec().x, m_vRealSize.vec().y};
SWindowDecorationExtents m_seReservedInternal = {m_vReservedInternalTopLeft.goalv(), m_vReservedInternalBottomRight.goalv()};
addExtentsToBox(&internalBox, &m_seReservedInternal); addExtentsToBox(&internalBox, &m_seReservedInternal);
return internalBox; return internalBox;
} }
@ -181,33 +186,34 @@ void CWindow::updateWindowDecos() {
} }
// handle this better later // handle this better later
auto i1 = m_seReservedInternal.topLeft; auto i1 = m_vReservedInternalTopLeft.goalv();
auto i2 = m_seReservedInternal.bottomRight; auto i2 = m_vReservedInternalBottomRight.goalv();
auto e1 = m_seReservedExternal.topLeft; auto e1 = m_vReservedExternalTopLeft.goalv();
auto e2 = m_seReservedExternal.bottomRight; auto e2 = m_vReservedExternalBottomRight.goalv();
// reset extents // reset extents
m_seReservedInternal.topLeft = Vector2D(); m_vReservedInternalTopLeft = Vector2D();
m_seReservedInternal.bottomRight = Vector2D(); m_vReservedInternalBottomRight = Vector2D();
m_seReservedExternal.topLeft = Vector2D(); m_vReservedExternalTopLeft = Vector2D();
m_seReservedExternal.bottomRight = Vector2D(); m_vReservedExternalBottomRight = Vector2D();
for (auto& wd : m_dWindowDecorations) { for (auto& wd : m_dWindowDecorations) {
const auto EXTENTS = wd->getWindowDecorationExtents(); const auto EXTENTS = wd->getWindowDecorationExtents();
if (EXTENTS.isInternalDecoration) { if (EXTENTS.isInternalDecoration) {
m_seReservedInternal.topLeft.x = std::max(m_seReservedInternal.topLeft.x, EXTENTS.topLeft.x); m_vReservedInternalTopLeft =
m_seReservedInternal.topLeft.y = std::max(m_seReservedInternal.topLeft.y, EXTENTS.topLeft.y); Vector2D(std::max(m_vReservedInternalTopLeft.goalv().x, EXTENTS.topLeft.x), std::max(m_vReservedInternalTopLeft.goalv().y, EXTENTS.topLeft.y));
m_seReservedInternal.bottomRight.x = std::max(m_seReservedInternal.bottomRight.x, EXTENTS.bottomRight.x); m_vReservedInternalBottomRight =
m_seReservedInternal.bottomRight.y = std::max(m_seReservedInternal.bottomRight.y, EXTENTS.bottomRight.y); Vector2D(std::max(m_vReservedInternalBottomRight.goalv().x, EXTENTS.bottomRight.x), std::max(m_vReservedInternalBottomRight.goalv().y, EXTENTS.bottomRight.y));
} else if (EXTENTS.isReservedArea) { } else if (EXTENTS.isReservedArea) {
m_seReservedExternal.topLeft.x = std::max(m_seReservedExternal.topLeft.x, EXTENTS.topLeft.x); m_vReservedExternalTopLeft =
m_seReservedExternal.topLeft.y = std::max(m_seReservedExternal.topLeft.y, EXTENTS.topLeft.y); Vector2D(std::max(m_vReservedExternalTopLeft.goalv().x, EXTENTS.topLeft.x), std::max(m_vReservedExternalTopLeft.goalv().y, EXTENTS.topLeft.y));
m_seReservedExternal.bottomRight.x = std::max(m_seReservedExternal.bottomRight.x, EXTENTS.bottomRight.x); m_vReservedExternalBottomRight =
m_seReservedExternal.bottomRight.y = std::max(m_seReservedExternal.bottomRight.y, EXTENTS.bottomRight.y); Vector2D(std::max(m_vReservedExternalBottomRight.goalv().x, EXTENTS.bottomRight.x), std::max(m_vReservedExternalBottomRight.goalv().y, EXTENTS.bottomRight.y));
} }
} }
if (i1 != m_seReservedInternal.topLeft || i2 != m_seReservedInternal.bottomRight || e1 != m_seReservedExternal.topLeft || e2 != m_seReservedExternal.bottomRight) if (i1 != m_vReservedInternalTopLeft.goalv() || i2 != m_vReservedInternalBottomRight.goalv() || e1 != m_vReservedExternalTopLeft.goalv() ||
e2 != m_vReservedExternalBottomRight.goalv())
recalc = true; recalc = true;
if (recalc) if (recalc)

View file

@ -286,8 +286,10 @@ class CWindow {
std::vector<IHyprWindowDecoration*> m_vDecosToRemove; std::vector<IHyprWindowDecoration*> m_vDecosToRemove;
// Window decorations internal and external reserved area // Window decorations internal and external reserved area
SWindowDecorationExtents m_seReservedInternal; CAnimatedVariable m_vReservedInternalTopLeft;
SWindowDecorationExtents m_seReservedExternal; CAnimatedVariable m_vReservedInternalBottomRight;
CAnimatedVariable m_vReservedExternalTopLeft;
CAnimatedVariable m_vReservedExternalBottomRight;
// Special render data, rules, etc // Special render data, rules, etc
SWindowSpecialRenderData m_sSpecialRenderData; SWindowSpecialRenderData m_sSpecialRenderData;

View file

@ -148,9 +148,9 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
PWINDOW->m_sSpecialRenderData.rounding = false; PWINDOW->m_sSpecialRenderData.rounding = false;
PWINDOW->m_sSpecialRenderData.shadow = false; PWINDOW->m_sSpecialRenderData.shadow = false;
PWINDOW->m_vRealPosition = PWINDOW->m_vPosition + PWINDOW->m_seReservedInternal.topLeft + PWINDOW->m_seReservedExternal.topLeft; PWINDOW->m_vRealPosition = PWINDOW->m_vPosition + PWINDOW->m_vReservedInternalTopLeft.goalv() + PWINDOW->m_vReservedExternalTopLeft.goalv();
PWINDOW->m_vRealSize = PWINDOW->m_vSize - (PWINDOW->m_seReservedInternal.topLeft + PWINDOW->m_seReservedInternal.bottomRight) - PWINDOW->m_vRealSize = PWINDOW->m_vSize - (PWINDOW->m_vReservedInternalTopLeft.goalv() + PWINDOW->m_vReservedInternalBottomRight.goalv()) -
(PWINDOW->m_seReservedExternal.topLeft + PWINDOW->m_seReservedExternal.bottomRight); (PWINDOW->m_vReservedExternalTopLeft.goalv() + PWINDOW->m_vReservedExternalBottomRight.goalv());
PWINDOW->updateWindowDecos(); PWINDOW->updateWindowDecos();

View file

@ -630,9 +630,9 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
PWINDOW->m_sSpecialRenderData.rounding = false; PWINDOW->m_sSpecialRenderData.rounding = false;
PWINDOW->m_sSpecialRenderData.shadow = false; PWINDOW->m_sSpecialRenderData.shadow = false;
PWINDOW->m_vRealPosition = PWINDOW->m_vPosition + PWINDOW->m_seReservedInternal.topLeft + PWINDOW->m_seReservedExternal.topLeft; PWINDOW->m_vRealPosition = PWINDOW->m_vPosition + PWINDOW->m_vReservedInternalTopLeft.goalv() + PWINDOW->m_vReservedExternalTopLeft.goalv();
PWINDOW->m_vRealSize = PWINDOW->m_vSize - (PWINDOW->m_seReservedInternal.topLeft + PWINDOW->m_seReservedInternal.bottomRight) - PWINDOW->m_vRealSize = PWINDOW->m_vSize - (PWINDOW->m_vReservedInternalTopLeft.goalv() + PWINDOW->m_vReservedInternalBottomRight.goalv()) -
(PWINDOW->m_seReservedExternal.topLeft + PWINDOW->m_seReservedExternal.bottomRight); (PWINDOW->m_vReservedExternalTopLeft.goalv() + PWINDOW->m_vReservedExternalBottomRight.goalv());
PWINDOW->updateWindowDecos(); PWINDOW->updateWindowDecos();

View file

@ -412,10 +412,10 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec*
wlr_box borderBox; wlr_box borderBox;
if (!pWindow->m_bIsFullscreen || PWORKSPACE->m_efFullscreenMode != FULLSCREEN_FULL) if (!pWindow->m_bIsFullscreen || PWORKSPACE->m_efFullscreenMode != FULLSCREEN_FULL)
borderBox = {renderdata.x - pMonitor->vecPosition.x - pWindow->m_seReservedInternal.topLeft.x, borderBox = {renderdata.x - pMonitor->vecPosition.x - pWindow->m_vReservedInternalTopLeft.goalv().x,
renderdata.y - pMonitor->vecPosition.y - pWindow->m_seReservedInternal.topLeft.y, renderdata.y - pMonitor->vecPosition.y - pWindow->m_vReservedInternalTopLeft.goalv().y,
renderdata.w + pWindow->m_seReservedInternal.topLeft.x + pWindow->m_seReservedInternal.bottomRight.x, renderdata.w + pWindow->m_vReservedInternalTopLeft.goalv().x + pWindow->m_vReservedInternalBottomRight.goalv().x,
renderdata.h + pWindow->m_seReservedInternal.topLeft.y + pWindow->m_seReservedInternal.bottomRight.y}; renderdata.h + pWindow->m_vReservedInternalTopLeft.goalv().y + pWindow->m_vReservedInternalBottomRight.goalv().y};
else else
borderBox = windowBox; borderBox = windowBox;

View file

@ -77,11 +77,12 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D
if (*PSHADOWS != 1) if (*PSHADOWS != 1)
return; // disabled return; // disabled
const auto ROUNDING = m_pWindow->getRealRounding(); const auto ROUNDING = m_pWindow->getRealRounding();
const auto BORDERSIZE = m_pWindow->getRealBorderSize(); const auto BORDERSIZE = m_pWindow->getRealBorderSize();
wlr_box windowBox = {m_vLastWindowPos.x, m_vLastWindowPos.y, m_vLastWindowSize.x, m_vLastWindowSize.y}; wlr_box windowBox = {m_vLastWindowPos.x, m_vLastWindowPos.y, m_vLastWindowSize.x, m_vLastWindowSize.y};
addExtentsToBox(&windowBox, &m_pWindow->m_seReservedInternal); SWindowDecorationExtents m_seReservedInternal = {m_pWindow->m_vReservedInternalTopLeft.goalv(), m_pWindow->m_vReservedInternalBottomRight.goalv()};
addExtentsToBox(&windowBox, &m_seReservedInternal);
windowBox.x -= pMonitor->vecPosition.x + BORDERSIZE; windowBox.x -= pMonitor->vecPosition.x + BORDERSIZE;
windowBox.y -= pMonitor->vecPosition.y + BORDERSIZE; windowBox.y -= pMonitor->vecPosition.y + BORDERSIZE;