From 344e5a145e5e91515b801dc89c97678813238df6 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Mon, 6 Nov 2023 16:49:39 +0000 Subject: [PATCH] hyprbars: improve titleBarBox calculations --- hyprbars/barDeco.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hyprbars/barDeco.cpp b/hyprbars/barDeco.cpp index 6d8f36d..85ab308 100644 --- a/hyprbars/barDeco.cpp +++ b/hyprbars/barDeco.cpp @@ -349,7 +349,7 @@ void CHyprBar::draw(CMonitor* pMonitor, float a, const Vector2D& offset) { const auto ROUNDING = m_pWindow->rounding() + m_pWindow->getRealBorderSize(); const auto scaledRounding = ROUNDING > 0 ? ROUNDING * pMonitor->scale - 2 /* idk why but otherwise it looks bad due to the gaps */ : 0; - const auto scaledBorderSize = BORDERSIZE * pMonitor->scale; + const int scaledBorderSize = BORDERSIZE * pMonitor->scale; CColor color = *PCOLOR; color.a *= a; @@ -358,11 +358,15 @@ void CHyprBar::draw(CMonitor* pMonitor, float a, const Vector2D& offset) { const auto BARBUF = Vector2D{m_vLastWindowSize.x + 2 * BORDERSIZE, *PHEIGHT} * pMonitor->scale; - CBox titleBarBox = {m_vLastWindowPos.x - BORDERSIZE - pMonitor->vecPosition.x, m_vLastWindowPos.y - BORDERSIZE - *PHEIGHT - pMonitor->vecPosition.y, - m_vLastWindowSize.x + 2 * BORDERSIZE, *PHEIGHT + ROUNDING * 3 /* to fill the bottom cuz we can't disable rounding there */}; + CBox titleBarBox = {m_vLastWindowPos.x - pMonitor->vecPosition.x, m_vLastWindowPos.y - pMonitor->vecPosition.y, m_vLastWindowSize.x, + *PHEIGHT + ROUNDING * 3 /* to fill the bottom cuz we can't disable rounding there */}; titleBarBox.translate(offset).scale(pMonitor->scale).round(); + titleBarBox.x -= scaledBorderSize; + titleBarBox.y -= scaledBorderSize + static_cast(*PHEIGHT * pMonitor->scale); + titleBarBox.w += 2 * scaledBorderSize; + g_pHyprOpenGL->scissor(&titleBarBox); if (ROUNDING) {