summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMightyPlaza <123664421+MightyPlaza@users.noreply.github.com>2023-11-26 17:59:49 +0000
committerGitHub <noreply@github.com>2023-11-26 17:59:49 +0000
commit7a0a5666d565a3ef892a7ab433a5007dd1cc72dd (patch)
treed9aede32bff1f184f519cfd7795d58e59c68bccd /src
parent1778fb77e20a7ff0c9fc20bb139b2e63fa41c7ef (diff)
groupbar: allow reload and fix locked groupbar gradient (#3546)
modified: src/config/ConfigManager.cpp modified: src/render/decorations/CHyprGroupBarDecoration.cpp modified: src/render/decorations/CHyprGroupBarDecoration.hpp
Diffstat (limited to 'src')
-rw-r--r--src/config/ConfigManager.cpp7
-rw-r--r--src/render/decorations/CHyprGroupBarDecoration.cpp31
-rw-r--r--src/render/decorations/CHyprGroupBarDecoration.hpp4
3 files changed, 27 insertions, 15 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index 54ecadb5..d02c5942 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -1,6 +1,8 @@
#include "ConfigManager.hpp"
#include "../managers/KeybindManager.hpp"
+#include "../render/decorations/CHyprGroupBarDecoration.hpp"
+
#include <string.h>
#include <string>
#include <sys/stat.h>
@@ -79,7 +81,7 @@ void CConfigManager::setDefaultVars() {
configValues["general:no_border_on_floating"].intValue = 0;
configValues["general:gaps_in"].intValue = 5;
configValues["general:gaps_out"].intValue = 20;
- configValues["general:gaps_workspaces"].intValue = 0;
+ configValues["general:gaps_workspaces"].intValue = 0;
((CGradientValueData*)configValues["general:col.active_border"].data.get())->reset(0xffffffff);
((CGradientValueData*)configValues["general:col.inactive_border"].data.get())->reset(0xff444444);
((CGradientValueData*)configValues["general:col.nogroup_border"].data.get())->reset(0xff444444);
@@ -1669,6 +1671,9 @@ void CConfigManager::loadConfigLoadVars() {
ensureVRR();
}
+ if (!isFirstLaunch && !g_pCompositor->m_bUnsafeState)
+ refreshGroupBarGradients();
+
// Updates dynamic window and workspace rules
for (auto& w : g_pCompositor->m_vWindows) {
if (!w->m_bIsMapped)
diff --git a/src/render/decorations/CHyprGroupBarDecoration.cpp b/src/render/decorations/CHyprGroupBarDecoration.cpp
index 7d2c84ee..d36093ae 100644
--- a/src/render/decorations/CHyprGroupBarDecoration.cpp
+++ b/src/render/decorations/CHyprGroupBarDecoration.cpp
@@ -6,6 +6,9 @@
// shared things to conserve VRAM
static CTexture m_tGradientActive;
static CTexture m_tGradientInactive;
+static CTexture m_tGradientLockedActive;
+static CTexture m_tGradientLockedInactive;
+
constexpr int BAR_INDICATOR_HEIGHT = 3;
constexpr int BAR_PADDING_OUTER_VERT = 2;
constexpr int BAR_TEXT_PAD = 2;
@@ -13,6 +16,8 @@ constexpr int BAR_HORIZONTAL_PADDING = 2;
CHyprGroupBarDecoration::CHyprGroupBarDecoration(CWindow* pWindow) : IHyprWindowDecoration(pWindow) {
m_pWindow = pWindow;
+ if (m_tGradientActive.m_iTexID == 0)
+ refreshGroupBarGradients();
}
CHyprGroupBarDecoration::~CHyprGroupBarDecoration() {}
@@ -130,10 +135,10 @@ void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a, const Vector2D&
Vector2D{m_fBarWidth * pMonitor->scale, (*PTITLEFONTSIZE + 2 * BAR_TEXT_PAD) * pMonitor->scale}))
.get();
- refreshGradients();
-
if (*PGRADIENTS)
- g_pHyprOpenGL->renderTexture((m_dwGroupMembers[i] == g_pCompositor->m_pLastWindow ? m_tGradientActive : m_tGradientInactive), &rect, 1.0);
+ 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 += (ASSIGNEDBOX.h / 2.0 - (*PTITLEFONTSIZE + 2 * BAR_TEXT_PAD) / 2.0) * pMonitor->scale;
rect.height = (*PTITLEFONTSIZE + 2 * BAR_TEXT_PAD) * pMonitor->scale;
@@ -273,21 +278,23 @@ void renderGradientTo(CTexture& tex, const CColor& grad) {
cairo_surface_destroy(CAIROSURFACE);
}
-void CHyprGroupBarDecoration::refreshGradients() {
- if (m_tGradientActive.m_iTexID > 0)
- return;
-
+void refreshGroupBarGradients() {
static auto* const PGROUPCOLACTIVE = &g_pConfigManager->getConfigValuePtr("group:groupbar:col.active")->data;
static auto* const PGROUPCOLINACTIVE = &g_pConfigManager->getConfigValuePtr("group:groupbar:col.inactive")->data;
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;
+ if (m_tGradientActive.m_iTexID != 0) {
+ m_tGradientActive.destroyTexture();
+ m_tGradientInactive.destroyTexture();
+ m_tGradientLockedActive.destroyTexture();
+ m_tGradientLockedInactive.destroyTexture();
+ }
- 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]);
}
bool CHyprGroupBarDecoration::onEndWindowDragOnDeco(CWindow* pDraggedWindow, const Vector2D& pos) {
diff --git a/src/render/decorations/CHyprGroupBarDecoration.hpp b/src/render/decorations/CHyprGroupBarDecoration.hpp
index 52439942..78edbeae 100644
--- a/src/render/decorations/CHyprGroupBarDecoration.hpp
+++ b/src/render/decorations/CHyprGroupBarDecoration.hpp
@@ -16,6 +16,8 @@ class CTitleTex {
CWindow* pWindowOwner = nullptr;
};
+void refreshGroupBarGradients();
+
class CHyprGroupBarDecoration : public IHyprWindowDecoration {
public:
CHyprGroupBarDecoration(CWindow*);
@@ -57,8 +59,6 @@ class CHyprGroupBarDecoration : public IHyprWindowDecoration {
CTitleTex* textureFromTitle(const std::string&);
void invalidateTextures();
- void refreshGradients();
-
CBox assignedBoxGlobal();
struct STitleTexs {