From f203d69f9813983582d0f3d3a85f5e172015cd95 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sun, 29 Oct 2023 22:57:55 +0000 Subject: [PATCH] hyprbars: fix dynamic updates of height --- hyprbars/barDeco.cpp | 19 +++++++++++++++---- hyprbars/barDeco.hpp | 3 +++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/hyprbars/barDeco.cpp b/hyprbars/barDeco.cpp index 5757bab..2305ed2 100644 --- a/hyprbars/barDeco.cpp +++ b/hyprbars/barDeco.cpp @@ -345,12 +345,17 @@ void CHyprBar::draw(CMonitor* pMonitor, float a, const Vector2D& offset) { static auto* const PCOLOR = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_color")->intValue; static auto* const PHEIGHT = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_height")->intValue; - const auto BORDERSIZE = m_pWindow->getRealBorderSize(); + if (*PHEIGHT < 1) { + m_iLastHeight = *PHEIGHT; + return; + } - const auto scaledRounding = *PROUNDING * pMonitor->scale; - const auto scaledBorderSize = BORDERSIZE * pMonitor->scale; + const auto BORDERSIZE = m_pWindow->getRealBorderSize(); - CColor color = *PCOLOR; + const auto scaledRounding = *PROUNDING * pMonitor->scale; + const auto scaledBorderSize = BORDERSIZE * pMonitor->scale; + + CColor color = *PCOLOR; color.a *= a; const auto ROUNDING = !m_pWindow->m_sSpecialRenderData.rounding ? @@ -423,6 +428,12 @@ void CHyprBar::draw(CMonitor* pMonitor, float a, const Vector2D& offset) { renderBarButtonsText(&textBox, pMonitor->scale); m_bWindowSizeChanged = false; + + // dynamic updates change the extents + if (m_iLastHeight != *PHEIGHT) { + g_pLayoutManager->getCurrentLayout()->recalculateWindow(m_pWindow); + m_iLastHeight = *PHEIGHT; + } } eDecorationType CHyprBar::getDecorationType() { diff --git a/hyprbars/barDeco.hpp b/hyprbars/barDeco.hpp index 9ea5bf7..7f3b8a3 100644 --- a/hyprbars/barDeco.hpp +++ b/hyprbars/barDeco.hpp @@ -57,4 +57,7 @@ class CHyprBar : public IHyprWindowDecoration { bool m_bDraggingThis = false; bool m_bDragPending = false; bool m_bCancelledDown = false; + + // for dynamic updates + int m_iLastHeight = 0; };