From 6fdac9c20915539f47eac93f37d33bc6893ddeba Mon Sep 17 00:00:00 2001 From: MightyPlaza <123664421+MightyPlaza@users.noreply.github.com> Date: Fri, 1 Sep 2023 23:16:34 +0100 Subject: [PATCH] allow reload and fix locked on groupbar gradient modified: src/config/ConfigManager.cpp modified: src/render/decorations/CHyprGroupBarDecoration.cpp modified: src/render/decorations/CHyprGroupBarDecoration.hpp modified: src/render/decorations/IHyprWindowDecoration.cpp modified: src/render/decorations/IHyprWindowDecoration.hpp Signed-off-by: MightyPlaza <123664421+MightyPlaza@users.noreply.github.com> --- src/config/ConfigManager.cpp | 2 ++ .../decorations/CHyprGroupBarDecoration.cpp | 28 ++++++++++++------- .../decorations/CHyprGroupBarDecoration.hpp | 2 ++ .../decorations/IHyprWindowDecoration.cpp | 4 +++ .../decorations/IHyprWindowDecoration.hpp | 2 ++ 5 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index bcd06889..de121e14 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -1648,6 +1648,8 @@ void CConfigManager::loadConfigLoadVars() { w->updateDynamicRules(); w->updateSpecialRenderData(); + for (auto& wd : w->m_dWindowDecorations) + wd->forceReload(w.get()); } // Update window border colors diff --git a/src/render/decorations/CHyprGroupBarDecoration.cpp b/src/render/decorations/CHyprGroupBarDecoration.cpp index a5c7e6f6..9a2fc215 100644 --- a/src/render/decorations/CHyprGroupBarDecoration.cpp +++ b/src/render/decorations/CHyprGroupBarDecoration.cpp @@ -6,6 +6,8 @@ // shared things to conserve VRAM static CTexture m_tGradientActive; static CTexture m_tGradientInactive; +static CTexture m_tGradientLockedActive; +static CTexture m_tGradientLockedInactive; CHyprGroupBarDecoration::CHyprGroupBarDecoration(CWindow* pWindow) : IHyprWindowDecoration(pWindow) { m_pWindow = pWindow; @@ -136,10 +138,12 @@ void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a, const Vector2D& rect.y -= rect.height; rect.width = BARW * pMonitor->scale; - refreshGradients(); - - if (*PGRADIENTS == 1) - g_pHyprOpenGL->renderTexture((m_dwGroupMembers[i] == g_pCompositor->m_pLastWindow ? m_tGradientActive : m_tGradientInactive), &rect, 1.0); + if (*PGRADIENTS == 1) { + refreshGradients(); + g_pHyprOpenGL->renderTexture((m_dwGroupMembers[i] == g_pCompositor->m_pLastWindow ? (GROUPLOCKED ? m_tGradientLockedActive : m_tGradientActive) : + (GROUPLOCKED ? m_tGradientLockedInactive : m_tGradientInactive)), + &rect, 1.0); + } rect.y -= (*PTITLEFONTSIZE + 2 * BAR_TEXT_PAD) * 0.2 * pMonitor->scale; rect.height = (*PTITLEFONTSIZE + 2 * BAR_TEXT_PAD) * pMonitor->scale; @@ -293,12 +297,10 @@ void CHyprGroupBarDecoration::refreshGradients() { static auto* const PGROUPCOLACTIVELOCKED = &g_pConfigManager->getConfigValuePtr("group:groupbar:col.locked_active")->data; static auto* const PGROUPCOLINACTIVELOCKED = &g_pConfigManager->getConfigValuePtr("group:groupbar:col.locked_inactive")->data; - const bool GROUPLOCKED = m_pWindow->getGroupHead()->m_sGroupData.locked; - const auto* const PCOLACTIVE = GROUPLOCKED ? PGROUPCOLACTIVELOCKED : PGROUPCOLACTIVE; - const auto* const PCOLINACTIVE = GROUPLOCKED ? PGROUPCOLINACTIVELOCKED : PGROUPCOLINACTIVE; - - renderGradientTo(m_tGradientActive, ((CGradientValueData*)PCOLACTIVE->get())->m_vColors[0]); - renderGradientTo(m_tGradientInactive, ((CGradientValueData*)PCOLINACTIVE->get())->m_vColors[0]); + renderGradientTo(m_tGradientActive, ((CGradientValueData*)PGROUPCOLACTIVE->get())->m_vColors[0]); + renderGradientTo(m_tGradientInactive, ((CGradientValueData*)PGROUPCOLINACTIVE->get())->m_vColors[0]); + renderGradientTo(m_tGradientLockedActive, ((CGradientValueData*)PGROUPCOLACTIVELOCKED->get())->m_vColors[0]); + renderGradientTo(m_tGradientLockedInactive, ((CGradientValueData*)PGROUPCOLINACTIVELOCKED->get())->m_vColors[0]); } int CHyprGroupBarDecoration::getBarHeight() { @@ -309,6 +311,12 @@ int CHyprGroupBarDecoration::getBarHeight() { return BARHEIGHT + (*PRENDERTITLES ? *PTITLEFONTSIZE : 0); } +void CHyprGroupBarDecoration::forceReload(CWindow* pWindow) { + m_tGradientActive.destroyTexture(); + m_tGradientInactive.destroyTexture(); + updateWindow(pWindow); +} + bool CHyprGroupBarDecoration::allowsInput() { return true; } diff --git a/src/render/decorations/CHyprGroupBarDecoration.hpp b/src/render/decorations/CHyprGroupBarDecoration.hpp index 79f5d95b..b68b4531 100644 --- a/src/render/decorations/CHyprGroupBarDecoration.hpp +++ b/src/render/decorations/CHyprGroupBarDecoration.hpp @@ -33,6 +33,8 @@ class CHyprGroupBarDecoration : public IHyprWindowDecoration { virtual SWindowDecorationExtents getWindowDecorationReservedArea(); + virtual void forceReload(CWindow*); + virtual bool allowsInput(); private: diff --git a/src/render/decorations/IHyprWindowDecoration.cpp b/src/render/decorations/IHyprWindowDecoration.cpp index a87c334a..940ea3c3 100644 --- a/src/render/decorations/IHyprWindowDecoration.cpp +++ b/src/render/decorations/IHyprWindowDecoration.cpp @@ -25,6 +25,10 @@ CRegion IHyprWindowDecoration::getWindowDecorationRegion() { m_pWindow->m_vRealSize.vec().y + 2 * BORDERSIZE)); } +void IHyprWindowDecoration::forceReload(CWindow* pWindow) { + updateWindow(pWindow); +} + bool IHyprWindowDecoration::allowsInput() { return false; } diff --git a/src/render/decorations/IHyprWindowDecoration.hpp b/src/render/decorations/IHyprWindowDecoration.hpp index fec7305d..d3251190 100644 --- a/src/render/decorations/IHyprWindowDecoration.hpp +++ b/src/render/decorations/IHyprWindowDecoration.hpp @@ -33,6 +33,8 @@ class IHyprWindowDecoration { virtual void damageEntire() = 0; + virtual void forceReload(CWindow*); + virtual SWindowDecorationExtents getWindowDecorationReservedArea(); virtual CRegion getWindowDecorationRegion();