mirror of
https://github.com/hyprwm/Hyprland.git
synced 2024-12-27 17:55:24 +03:00
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
This commit is contained in:
parent
1778fb77e2
commit
7a0a5666d5
@ -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)
|
||||
|
@ -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) {
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user