diff options
| author | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2023-11-04 13:10:52 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-04 13:10:52 +0000 |
| commit | 73e78f05ad5cafa20ac5bf177c94ac9ecca37097 (patch) | |
| tree | 20a61de56d8542ef0d7e9be463aea181d7a73387 /src/render/decorations/CHyprDropShadowDecoration.cpp | |
| parent | 54e51b7acf809b4cf705ae516f78a910c70e651f (diff) | |
Decos: Window decoration flags, shadow improvements (#3739)
Diffstat (limited to 'src/render/decorations/CHyprDropShadowDecoration.cpp')
| -rw-r--r-- | src/render/decorations/CHyprDropShadowDecoration.cpp | 80 |
1 files changed, 48 insertions, 32 deletions
diff --git a/src/render/decorations/CHyprDropShadowDecoration.cpp b/src/render/decorations/CHyprDropShadowDecoration.cpp index ee1a65a5..c2edb9ce 100644 --- a/src/render/decorations/CHyprDropShadowDecoration.cpp +++ b/src/render/decorations/CHyprDropShadowDecoration.cpp @@ -45,6 +45,32 @@ void CHyprDropShadowDecoration::updateWindow(CWindow* pWindow) { m_vLastWindowSize = pWindow->m_vRealSize.vec(); damageEntire(); + + const auto BORDER = m_pWindow->getRealBorderSize(); + + // calculate extents of decos with the DECORATION_PART_OF_MAIN_WINDOW flag + SWindowDecorationExtents maxExtents; + + for (auto& wd : m_pWindow->m_dWindowDecorations) { + // conveniently, this will also skip us. + if (!(wd->getDecorationFlags() & DECORATION_PART_OF_MAIN_WINDOW)) + continue; + + const auto EXTENTS = wd->getWindowDecorationExtents(); + + if (maxExtents.topLeft.x < EXTENTS.topLeft.x) + maxExtents.topLeft.x = EXTENTS.topLeft.x; + if (maxExtents.topLeft.y < EXTENTS.topLeft.y) + maxExtents.topLeft.y = EXTENTS.topLeft.y; + if (maxExtents.bottomRight.x < EXTENTS.bottomRight.x) + maxExtents.bottomRight.x = EXTENTS.bottomRight.x; + if (maxExtents.bottomRight.y < EXTENTS.bottomRight.y) + maxExtents.bottomRight.y = EXTENTS.bottomRight.y; + } + + m_bLastWindowBox = {(int)(m_vLastWindowPos.x - maxExtents.topLeft.x - BORDER), (int)(m_vLastWindowPos.y - maxExtents.topLeft.y - BORDER), + (int)(m_vLastWindowSize.x + maxExtents.topLeft.x + maxExtents.bottomRight.x + 2 * BORDER), + (int)(m_vLastWindowSize.y + maxExtents.topLeft.y + maxExtents.bottomRight.y + 2 * BORDER)}; } } @@ -67,7 +93,6 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D static auto* const PSHADOWS = &g_pConfigManager->getConfigValuePtr("decoration:drop_shadow")->intValue; static auto* const PSHADOWSIZE = &g_pConfigManager->getConfigValuePtr("decoration:shadow_range")->intValue; - static auto* const PROUNDING = &g_pConfigManager->getConfigValuePtr("decoration:rounding")->intValue; static auto* const PSHADOWIGNOREWINDOW = &g_pConfigManager->getConfigValuePtr("decoration:shadow_ignore_window")->intValue; static auto* const PSHADOWSCALE = &g_pConfigManager->getConfigValuePtr("decoration:shadow_scale")->floatValue; static auto* const PSHADOWOFFSET = &g_pConfigManager->getConfigValuePtr("decoration:shadow_offset")->vecValue; @@ -75,12 +100,11 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D if (*PSHADOWS != 1) return; // disabled - const auto ROUNDING = !m_pWindow->m_sSpecialRenderData.rounding ? - 0 : - (m_pWindow->m_sAdditionalConfigData.rounding.toUnderlying() == -1 ? *PROUNDING : m_pWindow->m_sAdditionalConfigData.rounding.toUnderlying()); + const auto ROUNDING = m_pWindow->rounding() + m_pWindow->getRealBorderSize(); // draw the shadow - wlr_box fullBox = {m_vLastWindowPos.x - *PSHADOWSIZE, m_vLastWindowPos.y - *PSHADOWSIZE, m_vLastWindowSize.x + 2.0 * *PSHADOWSIZE, m_vLastWindowSize.y + 2.0 * *PSHADOWSIZE}; + wlr_box fullBox = {m_bLastWindowBox.x - *PSHADOWSIZE, m_bLastWindowBox.y - *PSHADOWSIZE, m_bLastWindowBox.width + 2.0 * *PSHADOWSIZE, + m_bLastWindowBox.height + 2.0 * *PSHADOWSIZE}; fullBox.x -= pMonitor->vecPosition.x; fullBox.y -= pMonitor->vecPosition.y; @@ -95,17 +119,17 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D if (PSHADOWOFFSET->x < 0) { fullBox.x += PSHADOWOFFSET->x; } else if (PSHADOWOFFSET->x > 0) { - fullBox.x = m_vLastWindowPos.x + m_vLastWindowSize.x - fullBox.width + (SHADOWSCALE * *PSHADOWSIZE) + PSHADOWOFFSET->x - pMonitor->vecPosition.x; + fullBox.x = m_bLastWindowBox.x + m_bLastWindowBox.width - fullBox.width + (SHADOWSCALE * *PSHADOWSIZE) + PSHADOWOFFSET->x - pMonitor->vecPosition.x; } else { - fullBox.x += ((m_vLastWindowSize.x + 2.0 * *PSHADOWSIZE) - NEWSIZE.x) / 2.0; + fullBox.x += ((m_bLastWindowBox.width + 2.0 * *PSHADOWSIZE) - NEWSIZE.x) / 2.0; } if (PSHADOWOFFSET->y < 0) { fullBox.y += PSHADOWOFFSET->y; } else if (PSHADOWOFFSET->y > 0) { - fullBox.y = m_vLastWindowPos.y + m_vLastWindowSize.y - fullBox.height + (SHADOWSCALE * *PSHADOWSIZE) + PSHADOWOFFSET->y - pMonitor->vecPosition.y; + fullBox.y = m_bLastWindowBox.y + m_bLastWindowBox.height - fullBox.height + (SHADOWSCALE * *PSHADOWSIZE) + PSHADOWOFFSET->y - pMonitor->vecPosition.y; } else { - fullBox.y += ((m_vLastWindowSize.y + 2.0 * *PSHADOWSIZE) - NEWSIZE.y) / 2.0; + fullBox.y += ((m_bLastWindowBox.height + 2.0 * *PSHADOWSIZE) - NEWSIZE.y) / 2.0; } m_seExtents = {{m_vLastWindowPos.x - fullBox.x - pMonitor->vecPosition.x + 2, m_vLastWindowPos.y - fullBox.y - pMonitor->vecPosition.y + 2}, @@ -120,39 +144,31 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D g_pHyprOpenGL->scissor((wlr_box*)nullptr); - if (*PSHADOWIGNOREWINDOW) { - glEnable(GL_STENCIL_TEST); - - glClearStencil(0); - glClear(GL_STENCIL_BUFFER_BIT); - - glStencilFunc(GL_ALWAYS, 1, -1); - glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); + // we'll take the liberty of using this as it should not be used rn + CFramebuffer& alphaFB = g_pHyprOpenGL->m_RenderData.pCurrentMonData->mirrorFB; + auto* LASTFB = g_pHyprOpenGL->m_RenderData.currentFB; - wlr_box windowBox = {m_vLastWindowPos.x - pMonitor->vecPosition.x, m_vLastWindowPos.y - pMonitor->vecPosition.y, m_vLastWindowSize.x, m_vLastWindowSize.y}; + if (*PSHADOWIGNOREWINDOW) { + wlr_box windowBox = {m_bLastWindowBox.x - pMonitor->vecPosition.x, m_bLastWindowBox.y - pMonitor->vecPosition.y, m_bLastWindowBox.width, m_bLastWindowBox.height}; scaleBox(&windowBox, pMonitor->scale); if (windowBox.width < 1 || windowBox.height < 1) { - glClearStencil(0); - glClear(GL_STENCIL_BUFFER_BIT); - glDisable(GL_STENCIL_TEST); return; // prevent assert failed } - g_pHyprOpenGL->renderRect(&windowBox, CColor(0, 0, 0, 0), ROUNDING * pMonitor->scale); + alphaFB.bind(); + g_pHyprOpenGL->clear(CColor(0, 0, 0, 0)); + + g_pHyprOpenGL->renderRect(&windowBox, CColor(1.0, 1.0, 1.0, 1.0), ROUNDING * pMonitor->scale); - glStencilFunc(GL_NOTEQUAL, 1, -1); - glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); + LASTFB->bind(); } scaleBox(&fullBox, pMonitor->scale); - g_pHyprOpenGL->renderRoundedShadow(&fullBox, ROUNDING * pMonitor->scale, *PSHADOWSIZE * pMonitor->scale, a); - - if (*PSHADOWIGNOREWINDOW) { - // cleanup - glClearStencil(0); - glClear(GL_STENCIL_BUFFER_BIT); - glDisable(GL_STENCIL_TEST); - } + g_pHyprOpenGL->renderRoundedShadow(&fullBox, ROUNDING * pMonitor->scale, *PSHADOWSIZE * pMonitor->scale, a, &alphaFB); } + +eDecorationLayer CHyprDropShadowDecoration::getDecorationLayer() { + return DECORATION_LAYER_BOTTOM; +}
\ No newline at end of file |
