add "internal_border" (breaks mouse more)

modified:   src/config/ConfigManager.cpp
modified:   src/render/Renderer.cpp
modified:   src/render/Texture.hpp
modified:   src/render/decorations/CHyprGroupBarDecoration.cpp
modified:   src/render/decorations/CHyprGroupBarDecoration.hpp
modified:   src/render/decorations/IHyprWindowDecoration.hpp
Signed-off-by: MightyPlaza <123664421+MightyPlaza@users.noreply.github.com>
This commit is contained in:
MightyPlaza 2023-09-06 15:49:41 +01:00
parent 566cfe2822
commit ddb49c1bef
No known key found for this signature in database
GPG key ID: 284C27FD27A6DC0D
6 changed files with 134 additions and 68 deletions

View file

@ -28,6 +28,7 @@ CConfigManager::CConfigManager() {
configValues["group:groupbar:col.inactive"].data = std::make_shared<CGradientValueData>(0x66777700); configValues["group:groupbar:col.inactive"].data = std::make_shared<CGradientValueData>(0x66777700);
configValues["group:groupbar:col.locked_active"].data = std::make_shared<CGradientValueData>(0x66ff5500); configValues["group:groupbar:col.locked_active"].data = std::make_shared<CGradientValueData>(0x66ff5500);
configValues["group:groupbar:col.locked_inactive"].data = std::make_shared<CGradientValueData>(0x66775500); configValues["group:groupbar:col.locked_inactive"].data = std::make_shared<CGradientValueData>(0x66775500);
configValues["group:groupbar:col.background"].data = std::make_shared<CGradientValueData>(0x66202000);
setDefaultVars(); setDefaultVars();
setDefaultAnimationVars(); setDefaultAnimationVars();
@ -129,6 +130,7 @@ void CConfigManager::setDefaultVars() {
configValues["group:groupbar:font"].strValue = "Sans"; configValues["group:groupbar:font"].strValue = "Sans";
configValues["group:groupbar:height"].intValue = 20; configValues["group:groupbar:height"].intValue = 20;
configValues["group:groupbar:mode"].intValue = 1; configValues["group:groupbar:mode"].intValue = 1;
configValues["group:groupbar:internal_border"].intValue = 1;
configValues["group:groupbar:render_titles"].intValue = 1; configValues["group:groupbar:render_titles"].intValue = 1;
configValues["group:groupbar:scrolling"].intValue = 1; configValues["group:groupbar:scrolling"].intValue = 1;
configValues["group:groupbar:text_color"].intValue = 0xffffffff; configValues["group:groupbar:text_color"].intValue = 0xffffffff;
@ -1652,6 +1654,10 @@ void CConfigManager::loadConfigLoadVars() {
wd->forceReload(w.get()); wd->forceReload(w.get());
} }
// TODO: hack needed for decorations, fix later
for (auto& m : g_pCompositor->m_vMonitors)
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m->ID);
// Update window border colors // Update window border colors
g_pCompositor->updateAllWindowsAnimatedDecorationValues(); g_pCompositor->updateAllWindowsAnimatedDecorationValues();

View file

@ -384,11 +384,20 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec*
renderdata.y += offset.y; renderdata.y += offset.y;
} }
SWindowDecorationExtents borderExtents;
// render window decorations first, if not fullscreen full // render window decorations first, if not fullscreen full
if (mode == RENDER_PASS_ALL || mode == RENDER_PASS_MAIN) { if (mode == RENDER_PASS_ALL || mode == RENDER_PASS_MAIN) {
if (!pWindow->m_bIsFullscreen || PWORKSPACE->m_efFullscreenMode != FULLSCREEN_FULL) if (!pWindow->m_bIsFullscreen || PWORKSPACE->m_efFullscreenMode != FULLSCREEN_FULL)
for (auto& wd : pWindow->m_dWindowDecorations) for (auto& wd : pWindow->m_dWindowDecorations) {
wd->draw(pMonitor, renderdata.alpha * renderdata.fadeAlpha, offset); wd->draw(pMonitor, renderdata.alpha * renderdata.fadeAlpha, offset);
const auto EXTENTS = wd->getWindowDecorationExtents();
if (EXTENTS.isInternalDecoration) {
borderExtents.topLeft.x += EXTENTS.topLeft.x;
borderExtents.topLeft.y += EXTENTS.topLeft.y;
borderExtents.bottomRight.x += EXTENTS.bottomRight.x;
borderExtents.bottomRight.y += EXTENTS.bottomRight.y;
}
}
static auto* const PXWLUSENN = &g_pConfigManager->getConfigValuePtr("xwayland:use_nearest_neighbor")->intValue; static auto* const PXWLUSENN = &g_pConfigManager->getConfigValuePtr("xwayland:use_nearest_neighbor")->intValue;
if (pWindow->m_bIsX11 && *PXWLUSENN) if (pWindow->m_bIsX11 && *PXWLUSENN)
@ -409,18 +418,21 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec*
} }
wlr_box windowBox = {renderdata.x - pMonitor->vecPosition.x, renderdata.y - pMonitor->vecPosition.y, renderdata.w, renderdata.h}; wlr_box windowBox = {renderdata.x - pMonitor->vecPosition.x, renderdata.y - pMonitor->vecPosition.y, renderdata.w, renderdata.h};
wlr_box borderBox = {renderdata.x - pMonitor->vecPosition.x - borderExtents.topLeft.x, renderdata.y - pMonitor->vecPosition.y - borderExtents.topLeft.y,
renderdata.w + borderExtents.topLeft.x + borderExtents.bottomRight.x, renderdata.h + borderExtents.topLeft.y + borderExtents.bottomRight.y};
scaleBox(&windowBox, pMonitor->scale); scaleBox(&windowBox, pMonitor->scale);
scaleBox(&borderBox, pMonitor->scale);
int borderSize = pWindow->m_sSpecialRenderData.borderSize.toUnderlying() == -1 ? *PBORDERSIZE : pWindow->m_sSpecialRenderData.borderSize.toUnderlying(); int borderSize = pWindow->m_sSpecialRenderData.borderSize.toUnderlying() == -1 ? *PBORDERSIZE : pWindow->m_sSpecialRenderData.borderSize.toUnderlying();
if (pWindow->m_sAdditionalConfigData.borderSize.toUnderlying() != -1) if (pWindow->m_sAdditionalConfigData.borderSize.toUnderlying() != -1)
borderSize = pWindow->m_sAdditionalConfigData.borderSize.toUnderlying(); borderSize = pWindow->m_sAdditionalConfigData.borderSize.toUnderlying();
g_pHyprOpenGL->renderBorder(&windowBox, grad, renderdata.rounding, borderSize, a1); g_pHyprOpenGL->renderBorder(&borderBox, grad, renderdata.rounding, borderSize, a1);
if (ANIMATED) { if (ANIMATED) {
float a2 = renderdata.fadeAlpha * renderdata.alpha * (1.f - g_pHyprOpenGL->m_pCurrentWindow->m_fBorderFadeAnimationProgress.fl()); float a2 = renderdata.fadeAlpha * renderdata.alpha * (1.f - g_pHyprOpenGL->m_pCurrentWindow->m_fBorderFadeAnimationProgress.fl());
g_pHyprOpenGL->renderBorder(&windowBox, g_pHyprOpenGL->m_pCurrentWindow->m_cRealBorderColorPrevious, renderdata.rounding, borderSize, a2); g_pHyprOpenGL->renderBorder(&borderBox, g_pHyprOpenGL->m_pCurrentWindow->m_cRealBorderColorPrevious, renderdata.rounding, borderSize, a2);
} }
} }
} }

View file

@ -2,8 +2,7 @@
#include "../defines.hpp" #include "../defines.hpp"
enum TEXTURETYPE enum TEXTURETYPE {
{
TEXTURE_INVALID, // Invalid TEXTURE_INVALID, // Invalid
TEXTURE_RGBA, // 4 channels TEXTURE_RGBA, // 4 channels
TEXTURE_RGBX, // discard A TEXTURE_RGBX, // discard A

View file

@ -11,6 +11,7 @@ static CTexture m_tGradientLockedInactive;
CHyprGroupBarDecoration::CHyprGroupBarDecoration(CWindow* pWindow) : IHyprWindowDecoration(pWindow) { CHyprGroupBarDecoration::CHyprGroupBarDecoration(CWindow* pWindow) : IHyprWindowDecoration(pWindow) {
m_pWindow = pWindow; m_pWindow = pWindow;
forceReload(m_pWindow);
} }
CHyprGroupBarDecoration::~CHyprGroupBarDecoration() {} CHyprGroupBarDecoration::~CHyprGroupBarDecoration() {}
@ -24,8 +25,8 @@ eDecorationType CHyprGroupBarDecoration::getDecorationType() {
} }
constexpr int BAR_INDICATOR_HEIGHT = 3; constexpr int BAR_INDICATOR_HEIGHT = 3;
constexpr int BAR_INTERNAL_PADDING = 2; constexpr int BAR_INTERNAL_PADDING = 3;
constexpr int BAR_EXTERNAL_PADDING = 2; constexpr int BAR_EXTERNAL_PADDING = 3;
constexpr int BAR_TEXT_PAD = 3; constexpr int BAR_TEXT_PAD = 3;
// //
@ -36,13 +37,7 @@ void CHyprGroupBarDecoration::updateWindow(CWindow* pWindow) {
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID); const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
const auto WORKSPACEOFFSET = PWORKSPACE && !pWindow->m_bPinned ? PWORKSPACE->m_vRenderOffset.vec() : Vector2D(); const auto WORKSPACEOFFSET = PWORKSPACE && !pWindow->m_bPinned ? PWORKSPACE->m_vRenderOffset.vec() : Vector2D();
static auto* const PLOCATIONTOP = &g_pConfigManager->getConfigValuePtr("group:groupbar:top")->intValue;
if (pWindow->m_vRealPosition.vec() + WORKSPACEOFFSET != m_vLastWindowPos || pWindow->m_vRealSize.vec() != m_vLastWindowSize) { if (pWindow->m_vRealPosition.vec() + WORKSPACEOFFSET != m_vLastWindowPos || pWindow->m_vRealSize.vec() != m_vLastWindowSize) {
const int BORDERSIZE = pWindow->getRealBorderSize();
m_seExtents = {{0, *PLOCATIONTOP ? BORDERSIZE + BAR_INTERNAL_PADDING + BAR_EXTERNAL_PADDING + getBarHeight() : 0},
{0, *PLOCATIONTOP ? 0 : BORDERSIZE + BAR_INTERNAL_PADDING + BAR_EXTERNAL_PADDING + getBarHeight()}};
m_vLastWindowPos = pWindow->m_vRealPosition.vec() + WORKSPACEOFFSET; m_vLastWindowPos = pWindow->m_vRealPosition.vec() + WORKSPACEOFFSET;
m_vLastWindowSize = pWindow->m_vRealSize.vec(); m_vLastWindowSize = pWindow->m_vRealSize.vec();
@ -55,48 +50,39 @@ void CHyprGroupBarDecoration::updateWindow(CWindow* pWindow) {
} }
m_dwGroupMembers.clear(); m_dwGroupMembers.clear();
CWindow* head = pWindow->getGroupHead();
m_dwGroupMembers.push_back(head);
CWindow* curr = head->m_sGroupData.pNextWindow; CWindow* HEAD = pWindow->getGroupHead();
while (curr != head) { CWindow* curr = HEAD;
do {
m_dwGroupMembers.push_back(curr); m_dwGroupMembers.push_back(curr);
curr = curr->m_sGroupData.pNextWindow; curr = curr->m_sGroupData.pNextWindow;
} } while (curr != HEAD);
damageEntire(); damageEntire();
if (m_dwGroupMembers.size() == 0) {
m_pWindow->m_vDecosToRemove.push_back(this);
return;
}
} }
void CHyprGroupBarDecoration::damageEntire() { void CHyprGroupBarDecoration::damageEntire() {
wlr_box dm = {m_vLastWindowPos.x, m_vLastWindowPos.y + (m_seExtents.topLeft.y != 0 ? -m_seExtents.topLeft.y : m_vLastWindowSize.y), m_vLastWindowSize.x, // TODO: do this properly
m_seExtents.topLeft.y + m_seExtents.bottomRight.y}; const int BORDERSIZE = m_pWindow->getRealBorderSize();
auto RESERVED = getWindowDecorationExtents();
wlr_box dm = {m_vLastWindowPos.x, m_vLastWindowPos.y + (RESERVED.topLeft.y != 0 ? -BORDERSIZE - RESERVED.topLeft.y : m_vLastWindowSize.y), m_vLastWindowSize.x + 2 * BORDERSIZE,
RESERVED.topLeft.y + RESERVED.bottomRight.y + BORDERSIZE};
g_pHyprRenderer->damageBox(&dm); g_pHyprRenderer->damageBox(&dm);
} }
void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a, const Vector2D& offset) { void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a, const Vector2D& offset) {
// get how many bars we will draw
int barsToDraw = m_dwGroupMembers.size();
static auto* const PMODE = &g_pConfigManager->getConfigValuePtr("group:groupbar:mode")->intValue;
static auto* const PRENDERTITLES = &g_pConfigManager->getConfigValuePtr("group:groupbar:render_titles")->intValue;
static auto* const PLOCATIONTOP = &g_pConfigManager->getConfigValuePtr("group:groupbar:top")->intValue;
const int BARHEIGHT = *PMODE != 1 ? g_pConfigManager->getConfigValuePtr("group:groupbar:height")->intValue : BAR_INDICATOR_HEIGHT;
const int GRADIENTHEIGHT = *PMODE == 1 ? g_pConfigManager->getConfigValuePtr("group:groupbar:height")->intValue : 0;
const int BORDERSIZE = m_pWindow->getRealBorderSize();
if (!m_pWindow->m_sSpecialRenderData.decorate) if (!m_pWindow->m_sSpecialRenderData.decorate)
return; return;
int barsToDraw = m_dwGroupMembers.size();
static auto* const PRENDERTITLES = &g_pConfigManager->getConfigValuePtr("group:groupbar:render_titles")->intValue;
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;
static auto* const PGROUPCOLBACKGROUND = &g_pConfigManager->getConfigValuePtr("group:groupbar:col.background")->data;
const bool GROUPLOCKED = m_pWindow->getGroupHead()->m_sGroupData.locked; const bool GROUPLOCKED = m_pWindow->getGroupHead()->m_sGroupData.locked;
const auto* const PCOLACTIVE = GROUPLOCKED ? PGROUPCOLACTIVELOCKED : PGROUPCOLACTIVE; const auto* const PCOLACTIVE = GROUPLOCKED ? PGROUPCOLACTIVELOCKED : PGROUPCOLACTIVE;
@ -104,8 +90,8 @@ void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a, const Vector2D&
// TODO: fix mouse event with rounding // TODO: fix mouse event with rounding
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(m_pWindow->m_iWorkspaceID); const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(m_pWindow->m_iWorkspaceID);
const int ROUNDING = const int ROUNDING = !m_pWindow->m_sSpecialRenderData.rounding ? 0 : m_pWindow->rounding();
(m_pWindow->m_bIsFullscreen && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL) || (!m_pWindow->m_sSpecialRenderData.rounding) ? 0 : m_pWindow->rounding(); const int BORDERSIZE = m_pWindow->getRealBorderSize();
const int PAD = 2; //2px const int PAD = 2; //2px
const int BARW = (m_vLastWindowSize.x - 2 * ROUNDING - PAD * (barsToDraw - 1)) / barsToDraw; const int BARW = (m_vLastWindowSize.x - 2 * ROUNDING - PAD * (barsToDraw - 1)) / barsToDraw;
@ -115,13 +101,14 @@ void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a, const Vector2D&
return; return;
// Bottom left of groupbar // Bottom left of groupbar
Vector2D pos = Vector2D(m_vLastWindowPos.x - pMonitor->vecPosition.x + offset.x + ROUNDING, Vector2D pos = Vector2D(std::round(m_vLastWindowPos.x - pMonitor->vecPosition.x + offset.x + ROUNDING),
m_vLastWindowPos.y - pMonitor->vecPosition.y + offset.y + std::round(m_vLastWindowPos.y - pMonitor->vecPosition.y + offset.y) +
(*PLOCATIONTOP ? -BORDERSIZE : m_vLastWindowSize.y + BORDERSIZE + getBarHeight() + BAR_INTERNAL_PADDING)); (m_bOnTop ? (m_bInternalBorder ? 0 : -BORDERSIZE) :
std::round(m_vLastWindowSize.y) + m_iBarInternalHeight + BAR_INTERNAL_PADDING + (m_bInternalBorder ? 0 : BORDERSIZE)));
wlr_box barBox = {pos.x, pos.y - BARHEIGHT + (*PLOCATIONTOP ? -BAR_INTERNAL_PADDING : 0), BARW, BARHEIGHT}; wlr_box barBox = {pos.x, pos.y - m_iBarHeight + (m_bOnTop ? -BAR_INTERNAL_PADDING : 0), BARW, m_iBarHeight};
wlr_box gradBox = {pos.x, pos.y - BARHEIGHT + (*PLOCATIONTOP ? -2 * BAR_INTERNAL_PADDING : -BAR_INTERNAL_PADDING) - GRADIENTHEIGHT, BARW, GRADIENTHEIGHT}; wlr_box gradBox = {pos.x, pos.y - m_iBarHeight + (m_bOnTop ? -2 * BAR_INTERNAL_PADDING : -BAR_INTERNAL_PADDING) - m_iGradientHeight, BARW, m_iGradientHeight};
wlr_box textBox = *PMODE == 1 ? gradBox : barBox; wlr_box textBox = m_iGradientHeight != 0 ? gradBox : barBox;
textBox.y += BAR_TEXT_PAD; textBox.y += BAR_TEXT_PAD;
textBox.height -= 2 * BAR_TEXT_PAD; textBox.height -= 2 * BAR_TEXT_PAD;
@ -129,6 +116,51 @@ void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a, const Vector2D&
scaleBox(&textBox, pMonitor->scale); scaleBox(&textBox, pMonitor->scale);
scaleBox(&gradBox, pMonitor->scale); scaleBox(&gradBox, pMonitor->scale);
if (m_bInternalBorder) {
float alpha = m_pWindow->m_fAlpha.fl() * (m_pWindow->m_bPinned ? 1.f : PWORKSPACE->m_fAlpha.fl()) * m_pWindow->m_fActiveInactiveAlpha.fl();
auto color = ((CGradientValueData*)PGROUPCOLBACKGROUND->get())->m_vColors[0];
color = CColor(color.r, color.g, color.b, alpha);
wlr_box backBox = {pos.x - ROUNDING, pos.y - m_iBarFullHeight + (m_bOnTop ? 0 : -2 * ROUNDING + BAR_EXTERNAL_PADDING), m_vLastWindowSize.x,
m_iBarFullHeight + 2 * ROUNDING};
scaleBox(&backBox, pMonitor->scale);
if (ROUNDING != 0) {
wlr_box backStencilBox = {pos.x - ROUNDING, pos.y + (m_bOnTop ? 0 : -2 * ROUNDING - m_iBarInternalHeight - BAR_INTERNAL_PADDING), m_vLastWindowSize.x, 2 * ROUNDING};
scaleBox(&backStencilBox, pMonitor->scale);
g_pHyprOpenGL->scissor(&backBox);
glClearStencil(0);
glClear(GL_STENCIL_BUFFER_BIT);
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_ALWAYS, 1, -1);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
g_pHyprOpenGL->renderRect(&backStencilBox, CColor(0, 0, 0, 0), ROUNDING * pMonitor->scale);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glStencilFunc(GL_NOTEQUAL, 1, -1);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
g_pHyprOpenGL->renderRect(&backBox, color, ROUNDING * pMonitor->scale);
// cleanup stencil
glClearStencil(0);
glClear(GL_STENCIL_BUFFER_BIT);
glDisable(GL_STENCIL_TEST);
glStencilMask(-1);
glStencilFunc(GL_ALWAYS, 1, 0xFF);
} else {
g_pHyprOpenGL->renderRect(&backBox, color, ROUNDING * pMonitor->scale);
}
}
for (int i = 0; i < barsToDraw; ++i) { for (int i = 0; i < barsToDraw; ++i) {
CColor color = CColor color =
@ -144,8 +176,10 @@ void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a, const Vector2D&
g_pHyprOpenGL->renderTexture(pTitleTex->tex, &textBox, 1.f); g_pHyprOpenGL->renderTexture(pTitleTex->tex, &textBox, 1.f);
} }
if (*PMODE == 1) { if (m_iGradientHeight != 0) {
if (m_tGradientActive.m_iTexID == 0) // no idea why it doesn't work
refreshGradients(); refreshGradients();
g_pHyprOpenGL->renderTexture((m_dwGroupMembers[i] == g_pCompositor->m_pLastWindow ? (GROUPLOCKED ? m_tGradientLockedActive : m_tGradientActive) : g_pHyprOpenGL->renderTexture((m_dwGroupMembers[i] == g_pCompositor->m_pLastWindow ? (GROUPLOCKED ? m_tGradientLockedActive : m_tGradientActive) :
(GROUPLOCKED ? m_tGradientLockedInactive : m_tGradientInactive)), (GROUPLOCKED ? m_tGradientLockedInactive : m_tGradientInactive)),
&gradBox, 1.0); &gradBox, 1.0);
@ -161,9 +195,7 @@ void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a, const Vector2D&
} }
SWindowDecorationExtents CHyprGroupBarDecoration::getWindowDecorationReservedArea() { SWindowDecorationExtents CHyprGroupBarDecoration::getWindowDecorationReservedArea() {
static auto* const PLOCATIONTOP = &g_pConfigManager->getConfigValuePtr("group:groupbar:top")->intValue; return {{0, m_bOnTop ? m_iBarFullHeight : 0}, {0, m_bOnTop ? 0 : m_iBarFullHeight}};
return {{0, *PLOCATIONTOP ? +BAR_INTERNAL_PADDING + BAR_EXTERNAL_PADDING + getBarHeight() : 0},
{0, *PLOCATIONTOP ? 0 : BAR_INTERNAL_PADDING + BAR_EXTERNAL_PADDING + getBarHeight()}};
} }
CTitleTex* CHyprGroupBarDecoration::textureFromTitle(const std::string& title) { CTitleTex* CHyprGroupBarDecoration::textureFromTitle(const std::string& title) {
@ -292,8 +324,12 @@ void renderGradientTo(CTexture& tex, const CColor& grad) {
} }
void CHyprGroupBarDecoration::refreshGradients() { void CHyprGroupBarDecoration::refreshGradients() {
if (m_tGradientActive.m_iTexID > 0) if (m_tGradientActive.m_iTexID > 0) {
return; m_tGradientActive.destroyTexture();
m_tGradientInactive.destroyTexture();
m_tGradientLockedActive.destroyTexture();
m_tGradientLockedInactive.destroyTexture();
}
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;
@ -306,18 +342,25 @@ void CHyprGroupBarDecoration::refreshGradients() {
renderGradientTo(m_tGradientLockedInactive, ((CGradientValueData*)PGROUPCOLINACTIVELOCKED->get())->m_vColors[0]); renderGradientTo(m_tGradientLockedInactive, ((CGradientValueData*)PGROUPCOLINACTIVELOCKED->get())->m_vColors[0]);
} }
int CHyprGroupBarDecoration::getBarHeight() { void CHyprGroupBarDecoration::forceReload(CWindow* pWindow) {
static auto* const PMODE = &g_pConfigManager->getConfigValuePtr("group:groupbar:mode")->intValue; static auto* const PMODE = &g_pConfigManager->getConfigValuePtr("group:groupbar:mode")->intValue;
static auto* const PHEIGHT = &g_pConfigManager->getConfigValuePtr("group:groupbar:height")->intValue; static auto* const PHEIGHT = &g_pConfigManager->getConfigValuePtr("group:groupbar:height")->intValue;
return *PHEIGHT + (*PMODE == 1 ? BAR_INDICATOR_HEIGHT + BAR_INTERNAL_PADDING : 0); static auto* const PINTERNALBORDER = &g_pConfigManager->getConfigValuePtr("group:groupbar:internal_border")->intValue;
}
void CHyprGroupBarDecoration::forceReload(CWindow* pWindow) { m_iBarInternalHeight = *PHEIGHT + (*PMODE == 1 ? BAR_INDICATOR_HEIGHT + BAR_INTERNAL_PADDING : 0);
m_tGradientActive.destroyTexture(); m_iBarFullHeight = m_iBarInternalHeight + BAR_INTERNAL_PADDING + BAR_EXTERNAL_PADDING;
m_tGradientInactive.destroyTexture();
m_tGradientLockedActive.destroyTexture(); m_bOnTop = g_pConfigManager->getConfigValuePtr("group:groupbar:top")->intValue;
m_tGradientLockedInactive.destroyTexture(); m_bInternalBorder = *PINTERNALBORDER;
updateWindow(pWindow);
m_seExtents.topLeft = Vector2D(0, m_bOnTop ? m_iBarFullHeight : 0);
m_seExtents.bottomRight = Vector2D(0, m_bOnTop ? 0 : m_iBarFullHeight);
m_seExtents.isInternalDecoration = *PINTERNALBORDER;
m_iBarHeight = *PMODE != 1 ? *PHEIGHT : BAR_INDICATOR_HEIGHT;
m_iGradientHeight = *PMODE == 1 ? *PHEIGHT : 0;
refreshGradients();
} }
bool CHyprGroupBarDecoration::allowsInput() { bool CHyprGroupBarDecoration::allowsInput() {

View file

@ -47,7 +47,12 @@ class CHyprGroupBarDecoration : public IHyprWindowDecoration {
std::deque<CWindow*> m_dwGroupMembers; std::deque<CWindow*> m_dwGroupMembers;
int getBarHeight(); int m_iBarInternalHeight;
int m_iBarFullHeight;
bool m_bOnTop;
bool m_bInternalBorder;
int m_iBarHeight;
int m_iGradientHeight;
CTitleTex* textureFromTitle(const std::string&); CTitleTex* textureFromTitle(const std::string&);
void invalidateTextures(); void invalidateTextures();

View file

@ -13,6 +13,7 @@ enum eDecorationType {
struct SWindowDecorationExtents { struct SWindowDecorationExtents {
Vector2D topLeft; Vector2D topLeft;
Vector2D bottomRight; Vector2D bottomRight;
bool isInternalDecoration = false;
}; };
class CWindow; class CWindow;