From 80d5becba2b487a6689adbc96be55869ec585012 Mon Sep 17 00:00:00 2001 From: MightyPlaza <123664421+MightyPlaza@users.noreply.github.com> Date: Mon, 11 Sep 2023 17:11:20 +0100 Subject: [PATCH] replace rounding() with getRealRounding() modified: src/Window.cpp modified: src/Window.hpp modified: src/render/Renderer.cpp modified: src/render/decorations/CHyprGroupBarDecoration.cpp Signed-off-by: MightyPlaza <123664421+MightyPlaza@users.noreply.github.com> --- src/Window.cpp | 21 +++++++++++-------- src/Window.hpp | 4 ++-- src/render/Renderer.cpp | 6 +++--- .../decorations/CHyprGroupBarDecoration.cpp | 4 ++-- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/Window.cpp b/src/Window.cpp index 3c805a18..8e4450c8 100644 --- a/src/Window.cpp +++ b/src/Window.cpp @@ -622,7 +622,7 @@ void CWindow::updateDynamicRules() { // it is assumed that the point is within the real window box (m_vRealPosition, m_vRealSize) // otherwise behaviour is undefined bool CWindow::isInCurvedCorner(double x, double y) { - const int ROUNDING = rounding(); + const int ROUNDING = getRealRounding(); if (getRealBorderSize() >= ROUNDING) return false; @@ -919,14 +919,6 @@ bool CWindow::opaque() { return false; } -float CWindow::rounding() { - static auto* const PROUNDING = &g_pConfigManager->getConfigValuePtr("decoration:rounding")->intValue; - - float rounding = m_sAdditionalConfigData.rounding.toUnderlying() == -1 ? *PROUNDING : m_sAdditionalConfigData.rounding.toUnderlying(); - - return rounding; -} - void CWindow::updateSpecialRenderData() { const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(m_iWorkspaceID); const auto WORKSPACERULE = PWORKSPACE ? g_pConfigManager->getWorkspaceRuleFor(PWORKSPACE) : SWorkspaceRule{}; @@ -942,6 +934,17 @@ void CWindow::updateSpecialRenderData() { m_sSpecialRenderData.shadow = WORKSPACERULE.shadow.value_or(true); } +int CWindow::getRealRounding() { + + if (!m_sSpecialRenderData.rounding) + return 0; + + if (m_sAdditionalConfigData.rounding.toUnderlying() != -1) + return m_sAdditionalConfigData.rounding.toUnderlying(); + + return g_pConfigManager->getConfigValuePtr("decoration:rounding")->intValue; +} + int CWindow::getRealBorderSize() { if (!m_sSpecialRenderData.border || m_sAdditionalConfigData.forceNoBorder) return 0; diff --git a/src/Window.hpp b/src/Window.hpp index bfe4231e..d3265bf5 100644 --- a/src/Window.hpp +++ b/src/Window.hpp @@ -356,10 +356,10 @@ class CWindow { SWindowDecorationExtents getFullWindowReservedArea(); Vector2D middle(); bool opaque(); - float rounding(); bool canBeTorn(); int getRealBorderSize(); + int getRealRounding(); void updateSpecialRenderData(); void onBorderAngleAnimEnd(void* ptr); @@ -424,4 +424,4 @@ struct std::formatter : std::formatter { std::format_to(out, ", class: {}", g_pXWaylandManager->getAppIDClass(w)); return std::format_to(out, "]"); } -}; \ No newline at end of file +}; diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 8b8de52c..a15b277e 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -329,11 +329,11 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec* renderdata.surface = pWindow->m_pWLSurface.wlr(); renderdata.w = std::max(pWindow->m_vRealSize.vec().x, 5.0); // clamp the size to min 5, renderdata.h = std::max(pWindow->m_vRealSize.vec().y, 5.0); // otherwise we'll have issues later with invalid boxes - renderdata.dontRound = (pWindow->m_bIsFullscreen && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL) || (!pWindow->m_sSpecialRenderData.rounding); + renderdata.dontRound = (pWindow->m_bIsFullscreen && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL); renderdata.fadeAlpha = pWindow->m_fAlpha.fl() * (pWindow->m_bPinned ? 1.f : PWORKSPACE->m_fAlpha.fl()); renderdata.alpha = pWindow->m_fActiveInactiveAlpha.fl(); renderdata.decorate = decorate && !pWindow->m_bX11DoesntWantBorders && (!pWindow->m_bIsFullscreen || PWORKSPACE->m_efFullscreenMode != FULLSCREEN_FULL); - renderdata.rounding = ignoreAllGeometry || renderdata.dontRound ? 0 : pWindow->rounding() * pMonitor->scale; + renderdata.rounding = ignoreAllGeometry || renderdata.dontRound ? 0 : pWindow->getRealRounding() * pMonitor->scale; renderdata.blur = !ignoreAllGeometry; // if it shouldn't, it will be ignored later renderdata.pWindow = pWindow; @@ -1991,7 +1991,7 @@ void CHyprRenderer::setOccludedForBackLayers(CRegion& region, CWorkspace* pWorks if (!w->opaque()) continue; - const auto ROUNDING = w->rounding() * PMONITOR->scale; + const auto ROUNDING = w->getRealRounding() * PMONITOR->scale; const Vector2D POS = w->m_vRealPosition.vec() + Vector2D{ROUNDING, ROUNDING} - PMONITOR->vecPosition + (w->m_bPinned ? Vector2D{} : pWorkspace->m_vRenderOffset.vec()); const Vector2D SIZE = w->m_vRealSize.vec() - Vector2D{ROUNDING * 2, ROUNDING * 2}; diff --git a/src/render/decorations/CHyprGroupBarDecoration.cpp b/src/render/decorations/CHyprGroupBarDecoration.cpp index 2651d7de..5c2701c2 100644 --- a/src/render/decorations/CHyprGroupBarDecoration.cpp +++ b/src/render/decorations/CHyprGroupBarDecoration.cpp @@ -91,7 +91,7 @@ void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a, const Vector2D& // TODO: fix mouse event with rounding const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(m_pWindow->m_iWorkspaceID); - const int ROUNDING = !m_pWindow->m_sSpecialRenderData.rounding ? 0 : m_pWindow->rounding(); + const int ROUNDING = m_pWindow->getRealRounding(); const int BORDERSIZE = m_pWindow->getRealBorderSize(); const int BARW = (m_vLastWindowSize.x - 2 * ROUNDING - BAR_HORIZONTAL_PADDING * (barsToDraw - 1)) / barsToDraw; @@ -364,7 +364,7 @@ void CHyprGroupBarDecoration::forceReload(CWindow* pWindow) { } CRegion CHyprGroupBarDecoration::getWindowDecorationRegion() { - const int ROUNDING = !m_pWindow->m_sSpecialRenderData.rounding ? 0 : m_pWindow->rounding(); + const int ROUNDING = m_pWindow->getRealRounding(); const int BORDERSIZE = m_pWindow->getRealBorderSize(); return CRegion(m_vLastWindowPos.x + ROUNDING, m_vLastWindowPos.y +