Skip to content

Commit 0ece4af

Browse files
authored
grpupbar: Add config options to color inactive and locked groupbar titles (#10667)
1 parent aba2cfe commit 0ece4af

File tree

5 files changed

+50
-11
lines changed

5 files changed

+50
-11
lines changed

src/Compositor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1940,7 +1940,7 @@ void CCompositor::updateWindowAnimatedDecorationValues(PHLWINDOW pWindow) {
19401940
if (pWindow == m_lastWindow)
19411941
*pWindow->m_realShadowColor = CHyprColor(*PSHADOWCOL);
19421942
else
1943-
*pWindow->m_realShadowColor = CHyprColor(*PSHADOWCOLINACTIVE != INT64_MAX ? *PSHADOWCOLINACTIVE : *PSHADOWCOL);
1943+
*pWindow->m_realShadowColor = CHyprColor(*PSHADOWCOLINACTIVE != -1 ? *PSHADOWCOLINACTIVE : *PSHADOWCOL);
19441944
} else {
19451945
pWindow->m_realShadowColor->setValueAndWarp(CHyprColor(0, 0, 0, 0)); // no shadow
19461946
}

src/config/ConfigDescriptions.hpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,10 +1015,28 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
10151015
},
10161016
SConfigOptionDescription{
10171017
.value = "group:groupbar:text_color",
1018-
.description = "controls the group bar text color",
1018+
.description = "color for window titles in the groupbar",
10191019
.type = CONFIG_OPTION_COLOR,
10201020
.data = SConfigOptionDescription::SColorData{0xffffffff},
10211021
},
1022+
SConfigOptionDescription{
1023+
.value = "group:groupbar:text_color_inactive",
1024+
.description = "color for inactive windows' titles in the groupbar (if unset, defaults to text_color)",
1025+
.type = CONFIG_OPTION_COLOR,
1026+
.data = SConfigOptionDescription::SColorData{}, //TODO: UNSET?
1027+
},
1028+
SConfigOptionDescription{
1029+
.value = "group:groupbar:text_color_locked_active",
1030+
.description = "color for the active window's title in a locked group (if unset, defaults to text_color)",
1031+
.type = CONFIG_OPTION_COLOR,
1032+
.data = SConfigOptionDescription::SColorData{}, //TODO: UNSET?
1033+
},
1034+
SConfigOptionDescription{
1035+
.value = "group:groupbar:text_color_locked_inactive",
1036+
.description = "color for inactive windows' titles in locked groups (if unset, defaults to text_color_inactive)",
1037+
.type = CONFIG_OPTION_COLOR,
1038+
.data = SConfigOptionDescription::SColorData{}, //TODO: UNSET?
1039+
},
10221040
SConfigOptionDescription{
10231041
.value = "group:groupbar:col.active",
10241042
.description = "active group border color",

src/config/ConfigManager.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,9 @@ CConfigManager::CConfigManager() {
520520
registerConfigVar("group:groupbar:render_titles", Hyprlang::INT{1});
521521
registerConfigVar("group:groupbar:scrolling", Hyprlang::INT{1});
522522
registerConfigVar("group:groupbar:text_color", Hyprlang::INT{0xffffffff});
523+
registerConfigVar("group:groupbar:text_color_inactive", Hyprlang::INT{-1});
524+
registerConfigVar("group:groupbar:text_color_locked_active", Hyprlang::INT{-1});
525+
registerConfigVar("group:groupbar:text_color_locked_inactive", Hyprlang::INT{-1});
523526
registerConfigVar("group:groupbar:stacked", Hyprlang::INT{0});
524527
registerConfigVar("group:groupbar:rounding", Hyprlang::INT{1});
525528
registerConfigVar("group:groupbar:gradient_rounding", Hyprlang::INT{2});
@@ -575,7 +578,7 @@ CConfigManager::CConfigManager() {
575578
registerConfigVar("decoration:shadow:scale", {1.f});
576579
registerConfigVar("decoration:shadow:sharp", Hyprlang::INT{0});
577580
registerConfigVar("decoration:shadow:color", Hyprlang::INT{0xee1a1a1a});
578-
registerConfigVar("decoration:shadow:color_inactive", {(Hyprlang::INT)INT64_MAX});
581+
registerConfigVar("decoration:shadow:color_inactive", Hyprlang::INT{-1});
579582
registerConfigVar("decoration:dim_inactive", Hyprlang::INT{0});
580583
registerConfigVar("decoration:dim_strength", {0.5f});
581584
registerConfigVar("decoration:dim_special", {0.2f});

src/render/decorations/CHyprGroupBarDecoration.cpp

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,12 @@ void CHyprGroupBarDecoration::draw(PHLMONITOR pMonitor, float const& a) {
240240
pMonitor->m_scale))
241241
.get();
242242

243-
const auto titleTex = m_dwGroupMembers[WINDOWINDEX] == g_pCompositor->m_lastWindow ? pTitleTex->m_texActive : pTitleTex->m_texInactive;
243+
SP<CTexture> titleTex;
244+
if (m_dwGroupMembers[WINDOWINDEX] == g_pCompositor->m_lastWindow)
245+
titleTex = GROUPLOCKED ? pTitleTex->m_texLockedActive : pTitleTex->m_texActive;
246+
else
247+
titleTex = GROUPLOCKED ? pTitleTex->m_texLockedInactive : pTitleTex->m_texInactive;
248+
244249
rect.y += std::ceil(((rect.height - titleTex->m_size.y) / 2.0) - (*PTEXTOFFSET * pMonitor->m_scale));
245250
rect.height = titleTex->m_size.y;
246251
rect.width = titleTex->m_size.x;
@@ -279,22 +284,33 @@ void CHyprGroupBarDecoration::invalidateTextures() {
279284
}
280285

281286
CTitleTex::CTitleTex(PHLWINDOW pWindow, const Vector2D& bufferSize, const float monitorScale) : m_content(pWindow->m_title), m_windowOwner(pWindow) {
282-
static auto FALLBACKFONT = CConfigValue<std::string>("misc:font_family");
283-
static auto PTITLEFONTFAMILY = CConfigValue<std::string>("group:groupbar:font_family");
284-
static auto PTITLEFONTSIZE = CConfigValue<Hyprlang::INT>("group:groupbar:font_size");
285-
static auto PTEXTCOLOR = CConfigValue<Hyprlang::INT>("group:groupbar:text_color");
287+
static auto FALLBACKFONT = CConfigValue<std::string>("misc:font_family");
288+
static auto PTITLEFONTFAMILY = CConfigValue<std::string>("group:groupbar:font_family");
289+
static auto PTITLEFONTSIZE = CConfigValue<Hyprlang::INT>("group:groupbar:font_size");
290+
static auto PTEXTCOLORACTIVE = CConfigValue<Hyprlang::INT>("group:groupbar:text_color");
291+
static auto PTEXTCOLORINACTIVE = CConfigValue<Hyprlang::INT>("group:groupbar:text_color_inactive");
292+
static auto PTEXTCOLORLOCKEDACTIVE = CConfigValue<Hyprlang::INT>("group:groupbar:text_color_locked_active");
293+
static auto PTEXTCOLORLOCKEDINACTIVE = CConfigValue<Hyprlang::INT>("group:groupbar:text_color_locked_inactive");
286294

287295
static auto PTITLEFONTWEIGHTACTIVE = CConfigValue<Hyprlang::CUSTOMTYPE>("group:groupbar:font_weight_active");
288296
static auto PTITLEFONTWEIGHTINACTIVE = CConfigValue<Hyprlang::CUSTOMTYPE>("group:groupbar:font_weight_inactive");
289297

290298
const auto FONTWEIGHTACTIVE = (CFontWeightConfigValueData*)(PTITLEFONTWEIGHTACTIVE.ptr())->getData();
291299
const auto FONTWEIGHTINACTIVE = (CFontWeightConfigValueData*)(PTITLEFONTWEIGHTINACTIVE.ptr())->getData();
292300

293-
const CHyprColor COLOR = CHyprColor(*PTEXTCOLOR);
301+
const CHyprColor COLORACTIVE = CHyprColor(*PTEXTCOLORACTIVE);
302+
const CHyprColor COLORINACTIVE = *PTEXTCOLORINACTIVE == -1 ? COLORACTIVE : CHyprColor(*PTEXTCOLORINACTIVE);
303+
const CHyprColor COLORLOCKEDACTIVE = *PTEXTCOLORLOCKEDACTIVE == -1 ? COLORACTIVE : CHyprColor(*PTEXTCOLORLOCKEDACTIVE);
304+
const CHyprColor COLORLOCKEDINACTIVE = *PTEXTCOLORLOCKEDINACTIVE == -1 ? COLORINACTIVE : CHyprColor(*PTEXTCOLORLOCKEDINACTIVE);
305+
294306
const auto FONTFAMILY = *PTITLEFONTFAMILY != STRVAL_EMPTY ? *PTITLEFONTFAMILY : *FALLBACKFONT;
295307

296-
m_texActive = g_pHyprOpenGL->renderText(pWindow->m_title, COLOR, *PTITLEFONTSIZE * monitorScale, false, FONTFAMILY, bufferSize.x - 2, FONTWEIGHTACTIVE->m_value);
297-
m_texInactive = g_pHyprOpenGL->renderText(pWindow->m_title, COLOR, *PTITLEFONTSIZE * monitorScale, false, FONTFAMILY, bufferSize.x - 2, FONTWEIGHTINACTIVE->m_value);
308+
#define RENDER_TEXT(color, weight) g_pHyprOpenGL->renderText(pWindow->m_title, (color), *PTITLEFONTSIZE* monitorScale, false, FONTFAMILY, bufferSize.x - 2, (weight));
309+
m_texActive = RENDER_TEXT(COLORACTIVE, FONTWEIGHTACTIVE->m_value);
310+
m_texInactive = RENDER_TEXT(COLORINACTIVE, FONTWEIGHTINACTIVE->m_value);
311+
m_texLockedActive = RENDER_TEXT(COLORLOCKEDACTIVE, FONTWEIGHTACTIVE->m_value);
312+
m_texLockedInactive = RENDER_TEXT(COLORLOCKEDINACTIVE, FONTWEIGHTINACTIVE->m_value);
313+
#undef RENDER_TEXT
298314
}
299315

300316
static void renderGradientTo(SP<CTexture> tex, CGradientValueData* grad) {

src/render/decorations/CHyprGroupBarDecoration.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class CTitleTex {
1414

1515
SP<CTexture> m_texActive;
1616
SP<CTexture> m_texInactive;
17+
SP<CTexture> m_texLockedActive;
18+
SP<CTexture> m_texLockedInactive;
1719
std::string m_content;
1820

1921
PHLWINDOWREF m_windowOwner;

0 commit comments

Comments
 (0)