mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-23 03:05:59 +01: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
3 changed files with 27 additions and 15 deletions
|
@ -1,6 +1,8 @@
|
||||||
#include "ConfigManager.hpp"
|
#include "ConfigManager.hpp"
|
||||||
#include "../managers/KeybindManager.hpp"
|
#include "../managers/KeybindManager.hpp"
|
||||||
|
|
||||||
|
#include "../render/decorations/CHyprGroupBarDecoration.hpp"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
@ -79,7 +81,7 @@ void CConfigManager::setDefaultVars() {
|
||||||
configValues["general:no_border_on_floating"].intValue = 0;
|
configValues["general:no_border_on_floating"].intValue = 0;
|
||||||
configValues["general:gaps_in"].intValue = 5;
|
configValues["general:gaps_in"].intValue = 5;
|
||||||
configValues["general:gaps_out"].intValue = 20;
|
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.active_border"].data.get())->reset(0xffffffff);
|
||||||
((CGradientValueData*)configValues["general:col.inactive_border"].data.get())->reset(0xff444444);
|
((CGradientValueData*)configValues["general:col.inactive_border"].data.get())->reset(0xff444444);
|
||||||
((CGradientValueData*)configValues["general:col.nogroup_border"].data.get())->reset(0xff444444);
|
((CGradientValueData*)configValues["general:col.nogroup_border"].data.get())->reset(0xff444444);
|
||||||
|
@ -1669,6 +1671,9 @@ void CConfigManager::loadConfigLoadVars() {
|
||||||
ensureVRR();
|
ensureVRR();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isFirstLaunch && !g_pCompositor->m_bUnsafeState)
|
||||||
|
refreshGroupBarGradients();
|
||||||
|
|
||||||
// Updates dynamic window and workspace rules
|
// Updates dynamic window and workspace rules
|
||||||
for (auto& w : g_pCompositor->m_vWindows) {
|
for (auto& w : g_pCompositor->m_vWindows) {
|
||||||
if (!w->m_bIsMapped)
|
if (!w->m_bIsMapped)
|
||||||
|
|
|
@ -6,6 +6,9 @@
|
||||||
// shared things to conserve VRAM
|
// shared things to conserve VRAM
|
||||||
static CTexture m_tGradientActive;
|
static CTexture m_tGradientActive;
|
||||||
static CTexture m_tGradientInactive;
|
static CTexture m_tGradientInactive;
|
||||||
|
static CTexture m_tGradientLockedActive;
|
||||||
|
static CTexture m_tGradientLockedInactive;
|
||||||
|
|
||||||
constexpr int BAR_INDICATOR_HEIGHT = 3;
|
constexpr int BAR_INDICATOR_HEIGHT = 3;
|
||||||
constexpr int BAR_PADDING_OUTER_VERT = 2;
|
constexpr int BAR_PADDING_OUTER_VERT = 2;
|
||||||
constexpr int BAR_TEXT_PAD = 2;
|
constexpr int BAR_TEXT_PAD = 2;
|
||||||
|
@ -13,6 +16,8 @@ constexpr int BAR_HORIZONTAL_PADDING = 2;
|
||||||
|
|
||||||
CHyprGroupBarDecoration::CHyprGroupBarDecoration(CWindow* pWindow) : IHyprWindowDecoration(pWindow) {
|
CHyprGroupBarDecoration::CHyprGroupBarDecoration(CWindow* pWindow) : IHyprWindowDecoration(pWindow) {
|
||||||
m_pWindow = pWindow;
|
m_pWindow = pWindow;
|
||||||
|
if (m_tGradientActive.m_iTexID == 0)
|
||||||
|
refreshGroupBarGradients();
|
||||||
}
|
}
|
||||||
|
|
||||||
CHyprGroupBarDecoration::~CHyprGroupBarDecoration() {}
|
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}))
|
Vector2D{m_fBarWidth * pMonitor->scale, (*PTITLEFONTSIZE + 2 * BAR_TEXT_PAD) * pMonitor->scale}))
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
refreshGradients();
|
|
||||||
|
|
||||||
if (*PGRADIENTS)
|
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.y += (ASSIGNEDBOX.h / 2.0 - (*PTITLEFONTSIZE + 2 * BAR_TEXT_PAD) / 2.0) * pMonitor->scale;
|
||||||
rect.height = (*PTITLEFONTSIZE + 2 * BAR_TEXT_PAD) * 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);
|
cairo_surface_destroy(CAIROSURFACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprGroupBarDecoration::refreshGradients() {
|
void refreshGroupBarGradients() {
|
||||||
if (m_tGradientActive.m_iTexID > 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
static auto* const PGROUPCOLACTIVE = &g_pConfigManager->getConfigValuePtr("group:groupbar:col.active")->data;
|
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 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 PGROUPCOLACTIVELOCKED = &g_pConfigManager->getConfigValuePtr("group:groupbar:col.locked_active")->data;
|
||||||
static auto* const PGROUPCOLINACTIVELOCKED = &g_pConfigManager->getConfigValuePtr("group:groupbar:col.locked_inactive")->data;
|
static auto* const PGROUPCOLINACTIVELOCKED = &g_pConfigManager->getConfigValuePtr("group:groupbar:col.locked_inactive")->data;
|
||||||
|
|
||||||
const bool GROUPLOCKED = m_pWindow->getGroupHead()->m_sGroupData.locked;
|
if (m_tGradientActive.m_iTexID != 0) {
|
||||||
const auto* const PCOLACTIVE = GROUPLOCKED ? PGROUPCOLACTIVELOCKED : PGROUPCOLACTIVE;
|
m_tGradientActive.destroyTexture();
|
||||||
const auto* const PCOLINACTIVE = GROUPLOCKED ? PGROUPCOLINACTIVELOCKED : PGROUPCOLINACTIVE;
|
m_tGradientInactive.destroyTexture();
|
||||||
|
m_tGradientLockedActive.destroyTexture();
|
||||||
|
m_tGradientLockedInactive.destroyTexture();
|
||||||
|
}
|
||||||
|
|
||||||
renderGradientTo(m_tGradientActive, ((CGradientValueData*)PCOLACTIVE->get())->m_vColors[0]);
|
renderGradientTo(m_tGradientActive, ((CGradientValueData*)PGROUPCOLACTIVE->get())->m_vColors[0]);
|
||||||
renderGradientTo(m_tGradientInactive, ((CGradientValueData*)PCOLINACTIVE->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) {
|
bool CHyprGroupBarDecoration::onEndWindowDragOnDeco(CWindow* pDraggedWindow, const Vector2D& pos) {
|
||||||
|
|
|
@ -16,6 +16,8 @@ class CTitleTex {
|
||||||
CWindow* pWindowOwner = nullptr;
|
CWindow* pWindowOwner = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void refreshGroupBarGradients();
|
||||||
|
|
||||||
class CHyprGroupBarDecoration : public IHyprWindowDecoration {
|
class CHyprGroupBarDecoration : public IHyprWindowDecoration {
|
||||||
public:
|
public:
|
||||||
CHyprGroupBarDecoration(CWindow*);
|
CHyprGroupBarDecoration(CWindow*);
|
||||||
|
@ -57,8 +59,6 @@ class CHyprGroupBarDecoration : public IHyprWindowDecoration {
|
||||||
CTitleTex* textureFromTitle(const std::string&);
|
CTitleTex* textureFromTitle(const std::string&);
|
||||||
void invalidateTextures();
|
void invalidateTextures();
|
||||||
|
|
||||||
void refreshGradients();
|
|
||||||
|
|
||||||
CBox assignedBoxGlobal();
|
CBox assignedBoxGlobal();
|
||||||
|
|
||||||
struct STitleTexs {
|
struct STitleTexs {
|
||||||
|
|
Loading…
Reference in a new issue