2022-05-28 20:46:20 +02:00
|
|
|
#include "CHyprGroupBarDecoration.hpp"
|
|
|
|
#include "../../Compositor.hpp"
|
|
|
|
|
|
|
|
CHyprGroupBarDecoration::CHyprGroupBarDecoration(CWindow* pWindow) {
|
|
|
|
m_pWindow = pWindow;
|
|
|
|
}
|
|
|
|
|
|
|
|
CHyprGroupBarDecoration::~CHyprGroupBarDecoration() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
SWindowDecorationExtents CHyprGroupBarDecoration::getWindowDecorationExtents() {
|
|
|
|
return m_seExtents;
|
|
|
|
}
|
|
|
|
|
|
|
|
eDecorationType CHyprGroupBarDecoration::getDecorationType() {
|
|
|
|
return DECORATION_GROUPBAR;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CHyprGroupBarDecoration::updateWindow(CWindow* pWindow) {
|
|
|
|
damageEntire();
|
|
|
|
|
2022-06-27 00:25:37 +02:00
|
|
|
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
|
|
|
|
|
2022-09-11 20:27:59 +02:00
|
|
|
const auto WORKSPACEOFFSET = PWORKSPACE && !pWindow->m_bPinned ? PWORKSPACE->m_vRenderOffset.vec() : Vector2D();
|
2022-06-27 14:07:33 +02:00
|
|
|
|
|
|
|
if (pWindow->m_vRealPosition.vec() + WORKSPACEOFFSET != m_vLastWindowPos || pWindow->m_vRealSize.vec() != m_vLastWindowSize) {
|
2022-05-28 20:46:20 +02:00
|
|
|
// we draw 3px above the window's border with 3px
|
2022-09-03 22:49:45 +02:00
|
|
|
const auto PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
|
2022-05-28 20:46:20 +02:00
|
|
|
|
2022-09-03 22:49:45 +02:00
|
|
|
m_seExtents.topLeft = Vector2D(0, *PBORDERSIZE + 3 + 3);
|
2022-05-28 20:46:20 +02:00
|
|
|
m_seExtents.bottomRight = Vector2D();
|
|
|
|
|
2022-06-27 14:07:33 +02:00
|
|
|
m_vLastWindowPos = pWindow->m_vRealPosition.vec() + WORKSPACEOFFSET;
|
2022-05-28 20:46:20 +02:00
|
|
|
m_vLastWindowSize = pWindow->m_vRealSize.vec();
|
|
|
|
}
|
|
|
|
|
|
|
|
// let's check if the window group is different.
|
|
|
|
|
|
|
|
if (g_pLayoutManager->getCurrentLayout()->getLayoutName() != "dwindle") {
|
|
|
|
// ????
|
2022-07-05 17:31:47 +02:00
|
|
|
m_pWindow->m_vDecosToRemove.push_back(this);
|
|
|
|
return;
|
2022-05-28 20:46:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// get the group info
|
|
|
|
SLayoutMessageHeader header;
|
2022-09-20 19:04:39 +02:00
|
|
|
header.pWindow = m_pWindow;
|
2022-05-28 20:46:20 +02:00
|
|
|
|
|
|
|
m_dwGroupMembers = std::any_cast<std::deque<CWindow*>>(g_pLayoutManager->getCurrentLayout()->layoutMessage(header, "groupinfo"));
|
|
|
|
|
|
|
|
damageEntire();
|
|
|
|
|
|
|
|
if (m_dwGroupMembers.size() == 0) {
|
|
|
|
// remove
|
2022-07-05 17:31:47 +02:00
|
|
|
m_pWindow->m_vDecosToRemove.push_back(this);
|
|
|
|
return;
|
2022-05-28 20:46:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CHyprGroupBarDecoration::damageEntire() {
|
|
|
|
wlr_box dm = {m_vLastWindowPos.x - m_seExtents.topLeft.x, m_vLastWindowPos.y - m_seExtents.topLeft.y, m_vLastWindowSize.x + m_seExtents.topLeft.x + m_seExtents.bottomRight.x, m_seExtents.topLeft.y};
|
|
|
|
g_pHyprRenderer->damageBox(&dm);
|
|
|
|
}
|
|
|
|
|
2022-10-07 13:34:54 +02:00
|
|
|
void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a, const Vector2D& offset) {
|
2022-05-28 20:46:20 +02:00
|
|
|
// get how many bars we will draw
|
|
|
|
int barsToDraw = m_dwGroupMembers.size();
|
|
|
|
|
|
|
|
if (barsToDraw < 1 || m_pWindow->m_bHidden || !g_pCompositor->windowValidMapped(m_pWindow))
|
|
|
|
return;
|
|
|
|
|
2022-09-23 17:47:58 +02:00
|
|
|
if (!m_pWindow->m_sSpecialRenderData.decorate)
|
|
|
|
return;
|
|
|
|
|
2022-05-28 20:46:20 +02:00
|
|
|
const int PAD = 2; //2px
|
|
|
|
|
|
|
|
const int BARW = (m_vLastWindowSize.x - PAD * (barsToDraw - 1)) / barsToDraw;
|
|
|
|
|
|
|
|
int xoff = 0;
|
|
|
|
|
|
|
|
for (int i = 0; i < barsToDraw; ++i) {
|
2022-10-07 13:34:54 +02:00
|
|
|
wlr_box rect = {m_vLastWindowPos.x + xoff - pMonitor->vecPosition.x + offset.x, m_vLastWindowPos.y - m_seExtents.topLeft.y - pMonitor->vecPosition.y + offset.y, BARW, 3};
|
2022-05-28 20:46:20 +02:00
|
|
|
|
|
|
|
if (rect.width <= 0 || rect.height <= 0)
|
|
|
|
break;
|
|
|
|
|
2022-09-18 13:13:16 +02:00
|
|
|
scaleBox(&rect, pMonitor->scale);
|
|
|
|
|
2022-09-03 22:49:45 +02:00
|
|
|
static auto *const PGROUPCOLACTIVE = &g_pConfigManager->getConfigValuePtr("dwindle:col.group_border_active")->intValue;
|
|
|
|
static auto *const PGROUPCOLINACTIVE = &g_pConfigManager->getConfigValuePtr("dwindle:col.group_border")->intValue;
|
|
|
|
|
|
|
|
CColor color = m_dwGroupMembers[i] == g_pCompositor->m_pLastWindow ? CColor(*PGROUPCOLACTIVE) : CColor(*PGROUPCOLINACTIVE);
|
2022-06-25 20:31:54 +02:00
|
|
|
color.a *= a;
|
2022-05-28 20:46:20 +02:00
|
|
|
g_pHyprOpenGL->renderRect(&rect, color);
|
|
|
|
|
|
|
|
xoff += PAD + BARW;
|
|
|
|
}
|
|
|
|
}
|