mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-25 13:25:57 +01:00
add groupbar "max_size"
modified: src/config/ConfigManager.cpp modified: src/render/decorations/CHyprGroupBarDecoration.cpp Signed-off-by: MightyPlaza <123664421+MightyPlaza@users.noreply.github.com>
This commit is contained in:
parent
28734bab30
commit
fdcd002125
2 changed files with 13 additions and 3 deletions
|
@ -130,6 +130,7 @@ void CConfigManager::setDefaultVars() {
|
||||||
configValues["group:groupbar:enabled"].intValue = 1;
|
configValues["group:groupbar:enabled"].intValue = 1;
|
||||||
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:max_width"].intValue = 0;
|
||||||
configValues["group:groupbar:mode"].intValue = 1;
|
configValues["group:groupbar:mode"].intValue = 1;
|
||||||
configValues["group:groupbar:internal_bar"].intValue = 1;
|
configValues["group:groupbar:internal_bar"].intValue = 1;
|
||||||
configValues["group:groupbar:render_titles"].intValue = 1;
|
configValues["group:groupbar:render_titles"].intValue = 1;
|
||||||
|
|
|
@ -89,6 +89,8 @@ void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a, const Vector2D&
|
||||||
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;
|
static auto* const PGROUPCOLBACKGROUND = &g_pConfigManager->getConfigValuePtr("group:groupbar:col.background")->data;
|
||||||
|
|
||||||
|
static auto* const PMAXWIDTH = &g_pConfigManager->getConfigValuePtr("group:groupbar:max_width")->intValue;
|
||||||
|
|
||||||
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;
|
||||||
const auto* const PCOLINACTIVE = GROUPLOCKED ? PGROUPCOLINACTIVELOCKED : PGROUPCOLINACTIVE;
|
const auto* const PCOLINACTIVE = GROUPLOCKED ? PGROUPCOLINACTIVELOCKED : PGROUPCOLINACTIVE;
|
||||||
|
@ -99,6 +101,10 @@ void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a, const Vector2D&
|
||||||
|
|
||||||
m_fBarWidth = (m_vLastWindowSize.x - 2 * ROUNDING - BAR_HORIZONTAL_PADDING * (barsToDraw + 1)) / barsToDraw;
|
m_fBarWidth = (m_vLastWindowSize.x - 2 * ROUNDING - BAR_HORIZONTAL_PADDING * (barsToDraw + 1)) / barsToDraw;
|
||||||
|
|
||||||
|
if (*PMAXWIDTH >= 1) {
|
||||||
|
m_fBarWidth = std::min(m_fBarWidth, (float)*PMAXWIDTH);
|
||||||
|
}
|
||||||
|
|
||||||
float currentOffset = BAR_HORIZONTAL_PADDING;
|
float currentOffset = BAR_HORIZONTAL_PADDING;
|
||||||
|
|
||||||
if (m_fBarWidth <= 0)
|
if (m_fBarWidth <= 0)
|
||||||
|
@ -392,9 +398,10 @@ bool CHyprGroupBarDecoration::allowsInput() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprGroupBarDecoration::dragWindowToDecoration(CWindow* m_pDraggedWindow, const Vector2D& pos) {
|
void CHyprGroupBarDecoration::dragWindowToDecoration(CWindow* m_pDraggedWindow, const Vector2D& pos) {
|
||||||
|
const int SIZE = m_dwGroupMembers.size();
|
||||||
const int ROUNDING = m_pWindow->getRealRounding();
|
const int ROUNDING = m_pWindow->getRealRounding();
|
||||||
const float BARRELATIVEX = pos.x - (m_vLastWindowPos.x + ROUNDING) - (m_fBarWidth / 2 + BAR_HORIZONTAL_PADDING);
|
const float BARRELATIVEX = pos.x - (m_vLastWindowPos.x + ROUNDING) - (m_fBarWidth / 2 + BAR_HORIZONTAL_PADDING);
|
||||||
const int WINDOWINDEX = BARRELATIVEX < 0 ? -1 : (BARRELATIVEX) / (m_fBarWidth + BAR_HORIZONTAL_PADDING);
|
const int WINDOWINDEX = std::min(BARRELATIVEX < 0 ? -1 : (int)((BARRELATIVEX) / (m_fBarWidth + BAR_HORIZONTAL_PADDING)), SIZE - 1);
|
||||||
|
|
||||||
CWindow* pWindowInsertAfter = m_pWindow->getGroupWindowByIndex(WINDOWINDEX);
|
CWindow* pWindowInsertAfter = m_pWindow->getGroupWindowByIndex(WINDOWINDEX);
|
||||||
|
|
||||||
|
@ -405,11 +412,12 @@ void CHyprGroupBarDecoration::dragWindowToDecoration(CWindow* m_pDraggedWindow,
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprGroupBarDecoration::clickDecoration(const Vector2D& pos) {
|
void CHyprGroupBarDecoration::clickDecoration(const Vector2D& pos) {
|
||||||
|
const int SIZE = m_dwGroupMembers.size();
|
||||||
const int ROUNDING = m_pWindow->getRealRounding();
|
const int ROUNDING = m_pWindow->getRealRounding();
|
||||||
const float BARRELATIVEX = pos.x - (m_vLastWindowPos.x + ROUNDING);
|
const float BARRELATIVEX = pos.x - (m_vLastWindowPos.x + ROUNDING);
|
||||||
const int WINDOWINDEX = (BARRELATIVEX) / (m_fBarWidth + BAR_HORIZONTAL_PADDING);
|
const int WINDOWINDEX = (BARRELATIVEX) / (m_fBarWidth + BAR_HORIZONTAL_PADDING);
|
||||||
|
|
||||||
if (BARRELATIVEX - (m_fBarWidth + BAR_HORIZONTAL_PADDING) * WINDOWINDEX < BAR_HORIZONTAL_PADDING) {
|
if (BARRELATIVEX - (m_fBarWidth + BAR_HORIZONTAL_PADDING) * WINDOWINDEX < BAR_HORIZONTAL_PADDING || WINDOWINDEX > SIZE - 1) {
|
||||||
if (!g_pCompositor->isWindowActive(m_pWindow))
|
if (!g_pCompositor->isWindowActive(m_pWindow))
|
||||||
g_pCompositor->focusWindow(m_pWindow);
|
g_pCompositor->focusWindow(m_pWindow);
|
||||||
return;
|
return;
|
||||||
|
@ -425,11 +433,12 @@ void CHyprGroupBarDecoration::clickDecoration(const Vector2D& pos) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprGroupBarDecoration::dragFromDecoration(const Vector2D& pos) {
|
void CHyprGroupBarDecoration::dragFromDecoration(const Vector2D& pos) {
|
||||||
|
const int SIZE = m_dwGroupMembers.size();
|
||||||
const int ROUNDING = m_pWindow->getRealRounding();
|
const int ROUNDING = m_pWindow->getRealRounding();
|
||||||
const float BARRELATIVEX = pos.x - (m_vLastWindowPos.x + ROUNDING);
|
const float BARRELATIVEX = pos.x - (m_vLastWindowPos.x + ROUNDING);
|
||||||
const int WINDOWINDEX = (BARRELATIVEX) / (m_fBarWidth + BAR_HORIZONTAL_PADDING);
|
const int WINDOWINDEX = (BARRELATIVEX) / (m_fBarWidth + BAR_HORIZONTAL_PADDING);
|
||||||
|
|
||||||
if (BARRELATIVEX - (m_fBarWidth + BAR_HORIZONTAL_PADDING) * WINDOWINDEX < BAR_HORIZONTAL_PADDING)
|
if (BARRELATIVEX - (m_fBarWidth + BAR_HORIZONTAL_PADDING) * WINDOWINDEX < BAR_HORIZONTAL_PADDING || WINDOWINDEX > SIZE - 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CWindow* pWindow = m_pWindow->getGroupWindowByIndex(WINDOWINDEX);
|
CWindow* pWindow = m_pWindow->getGroupWindowByIndex(WINDOWINDEX);
|
||||||
|
|
Loading…
Reference in a new issue