grpupbar: Add config options to color inactive and locked groupbar titles (#10667)

This commit is contained in:
Jacob Ilias Komissar
2025-06-16 16:40:38 -04:00
committed by GitHub
parent aba2cfe7a8
commit 0ece4af36a
5 changed files with 50 additions and 11 deletions

View File

@@ -1940,7 +1940,7 @@ void CCompositor::updateWindowAnimatedDecorationValues(PHLWINDOW pWindow) {
if (pWindow == m_lastWindow)
*pWindow->m_realShadowColor = CHyprColor(*PSHADOWCOL);
else
*pWindow->m_realShadowColor = CHyprColor(*PSHADOWCOLINACTIVE != INT64_MAX ? *PSHADOWCOLINACTIVE : *PSHADOWCOL);
*pWindow->m_realShadowColor = CHyprColor(*PSHADOWCOLINACTIVE != -1 ? *PSHADOWCOLINACTIVE : *PSHADOWCOL);
} else {
pWindow->m_realShadowColor->setValueAndWarp(CHyprColor(0, 0, 0, 0)); // no shadow
}

View File

@@ -1015,10 +1015,28 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
},
SConfigOptionDescription{
.value = "group:groupbar:text_color",
.description = "controls the group bar text color",
.description = "color for window titles in the groupbar",
.type = CONFIG_OPTION_COLOR,
.data = SConfigOptionDescription::SColorData{0xffffffff},
},
SConfigOptionDescription{
.value = "group:groupbar:text_color_inactive",
.description = "color for inactive windows' titles in the groupbar (if unset, defaults to text_color)",
.type = CONFIG_OPTION_COLOR,
.data = SConfigOptionDescription::SColorData{}, //TODO: UNSET?
},
SConfigOptionDescription{
.value = "group:groupbar:text_color_locked_active",
.description = "color for the active window's title in a locked group (if unset, defaults to text_color)",
.type = CONFIG_OPTION_COLOR,
.data = SConfigOptionDescription::SColorData{}, //TODO: UNSET?
},
SConfigOptionDescription{
.value = "group:groupbar:text_color_locked_inactive",
.description = "color for inactive windows' titles in locked groups (if unset, defaults to text_color_inactive)",
.type = CONFIG_OPTION_COLOR,
.data = SConfigOptionDescription::SColorData{}, //TODO: UNSET?
},
SConfigOptionDescription{
.value = "group:groupbar:col.active",
.description = "active group border color",

View File

@@ -520,6 +520,9 @@ CConfigManager::CConfigManager() {
registerConfigVar("group:groupbar:render_titles", Hyprlang::INT{1});
registerConfigVar("group:groupbar:scrolling", Hyprlang::INT{1});
registerConfigVar("group:groupbar:text_color", Hyprlang::INT{0xffffffff});
registerConfigVar("group:groupbar:text_color_inactive", Hyprlang::INT{-1});
registerConfigVar("group:groupbar:text_color_locked_active", Hyprlang::INT{-1});
registerConfigVar("group:groupbar:text_color_locked_inactive", Hyprlang::INT{-1});
registerConfigVar("group:groupbar:stacked", Hyprlang::INT{0});
registerConfigVar("group:groupbar:rounding", Hyprlang::INT{1});
registerConfigVar("group:groupbar:gradient_rounding", Hyprlang::INT{2});
@@ -575,7 +578,7 @@ CConfigManager::CConfigManager() {
registerConfigVar("decoration:shadow:scale", {1.f});
registerConfigVar("decoration:shadow:sharp", Hyprlang::INT{0});
registerConfigVar("decoration:shadow:color", Hyprlang::INT{0xee1a1a1a});
registerConfigVar("decoration:shadow:color_inactive", {(Hyprlang::INT)INT64_MAX});
registerConfigVar("decoration:shadow:color_inactive", Hyprlang::INT{-1});
registerConfigVar("decoration:dim_inactive", Hyprlang::INT{0});
registerConfigVar("decoration:dim_strength", {0.5f});
registerConfigVar("decoration:dim_special", {0.2f});

View File

@@ -240,7 +240,12 @@ void CHyprGroupBarDecoration::draw(PHLMONITOR pMonitor, float const& a) {
pMonitor->m_scale))
.get();
const auto titleTex = m_dwGroupMembers[WINDOWINDEX] == g_pCompositor->m_lastWindow ? pTitleTex->m_texActive : pTitleTex->m_texInactive;
SP<CTexture> titleTex;
if (m_dwGroupMembers[WINDOWINDEX] == g_pCompositor->m_lastWindow)
titleTex = GROUPLOCKED ? pTitleTex->m_texLockedActive : pTitleTex->m_texActive;
else
titleTex = GROUPLOCKED ? pTitleTex->m_texLockedInactive : pTitleTex->m_texInactive;
rect.y += std::ceil(((rect.height - titleTex->m_size.y) / 2.0) - (*PTEXTOFFSET * pMonitor->m_scale));
rect.height = titleTex->m_size.y;
rect.width = titleTex->m_size.x;
@@ -279,10 +284,13 @@ void CHyprGroupBarDecoration::invalidateTextures() {
}
CTitleTex::CTitleTex(PHLWINDOW pWindow, const Vector2D& bufferSize, const float monitorScale) : m_content(pWindow->m_title), m_windowOwner(pWindow) {
static auto FALLBACKFONT = CConfigValue<std::string>("misc:font_family");
static auto PTITLEFONTFAMILY = CConfigValue<std::string>("group:groupbar:font_family");
static auto PTITLEFONTSIZE = CConfigValue<Hyprlang::INT>("group:groupbar:font_size");
static auto PTEXTCOLOR = CConfigValue<Hyprlang::INT>("group:groupbar:text_color");
static auto FALLBACKFONT = CConfigValue<std::string>("misc:font_family");
static auto PTITLEFONTFAMILY = CConfigValue<std::string>("group:groupbar:font_family");
static auto PTITLEFONTSIZE = CConfigValue<Hyprlang::INT>("group:groupbar:font_size");
static auto PTEXTCOLORACTIVE = CConfigValue<Hyprlang::INT>("group:groupbar:text_color");
static auto PTEXTCOLORINACTIVE = CConfigValue<Hyprlang::INT>("group:groupbar:text_color_inactive");
static auto PTEXTCOLORLOCKEDACTIVE = CConfigValue<Hyprlang::INT>("group:groupbar:text_color_locked_active");
static auto PTEXTCOLORLOCKEDINACTIVE = CConfigValue<Hyprlang::INT>("group:groupbar:text_color_locked_inactive");
static auto PTITLEFONTWEIGHTACTIVE = CConfigValue<Hyprlang::CUSTOMTYPE>("group:groupbar:font_weight_active");
static auto PTITLEFONTWEIGHTINACTIVE = CConfigValue<Hyprlang::CUSTOMTYPE>("group:groupbar:font_weight_inactive");
@@ -290,11 +298,19 @@ CTitleTex::CTitleTex(PHLWINDOW pWindow, const Vector2D& bufferSize, const float
const auto FONTWEIGHTACTIVE = (CFontWeightConfigValueData*)(PTITLEFONTWEIGHTACTIVE.ptr())->getData();
const auto FONTWEIGHTINACTIVE = (CFontWeightConfigValueData*)(PTITLEFONTWEIGHTINACTIVE.ptr())->getData();
const CHyprColor COLOR = CHyprColor(*PTEXTCOLOR);
const CHyprColor COLORACTIVE = CHyprColor(*PTEXTCOLORACTIVE);
const CHyprColor COLORINACTIVE = *PTEXTCOLORINACTIVE == -1 ? COLORACTIVE : CHyprColor(*PTEXTCOLORINACTIVE);
const CHyprColor COLORLOCKEDACTIVE = *PTEXTCOLORLOCKEDACTIVE == -1 ? COLORACTIVE : CHyprColor(*PTEXTCOLORLOCKEDACTIVE);
const CHyprColor COLORLOCKEDINACTIVE = *PTEXTCOLORLOCKEDINACTIVE == -1 ? COLORINACTIVE : CHyprColor(*PTEXTCOLORLOCKEDINACTIVE);
const auto FONTFAMILY = *PTITLEFONTFAMILY != STRVAL_EMPTY ? *PTITLEFONTFAMILY : *FALLBACKFONT;
m_texActive = g_pHyprOpenGL->renderText(pWindow->m_title, COLOR, *PTITLEFONTSIZE * monitorScale, false, FONTFAMILY, bufferSize.x - 2, FONTWEIGHTACTIVE->m_value);
m_texInactive = g_pHyprOpenGL->renderText(pWindow->m_title, COLOR, *PTITLEFONTSIZE * monitorScale, false, FONTFAMILY, bufferSize.x - 2, FONTWEIGHTINACTIVE->m_value);
#define RENDER_TEXT(color, weight) g_pHyprOpenGL->renderText(pWindow->m_title, (color), *PTITLEFONTSIZE* monitorScale, false, FONTFAMILY, bufferSize.x - 2, (weight));
m_texActive = RENDER_TEXT(COLORACTIVE, FONTWEIGHTACTIVE->m_value);
m_texInactive = RENDER_TEXT(COLORINACTIVE, FONTWEIGHTINACTIVE->m_value);
m_texLockedActive = RENDER_TEXT(COLORLOCKEDACTIVE, FONTWEIGHTACTIVE->m_value);
m_texLockedInactive = RENDER_TEXT(COLORLOCKEDINACTIVE, FONTWEIGHTINACTIVE->m_value);
#undef RENDER_TEXT
}
static void renderGradientTo(SP<CTexture> tex, CGradientValueData* grad) {

View File

@@ -14,6 +14,8 @@ class CTitleTex {
SP<CTexture> m_texActive;
SP<CTexture> m_texInactive;
SP<CTexture> m_texLockedActive;
SP<CTexture> m_texLockedInactive;
std::string m_content;
PHLWINDOWREF m_windowOwner;