Skip to content

Commit

Permalink
Group/Tab Rework (#1580)
Browse files Browse the repository at this point in the history
  • Loading branch information
vaxerski authored Feb 19, 2023
1 parent 2363cc2 commit e5a4c0c
Show file tree
Hide file tree
Showing 12 changed files with 268 additions and 495 deletions.
22 changes: 15 additions & 7 deletions src/Compositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1583,6 +1583,8 @@ void CCompositor::updateWindowAnimatedDecorationValues(CWindow* pWindow) {
// optimization
static auto* const ACTIVECOL = (CGradientValueData*)g_pConfigManager->getConfigValuePtr("general:col.active_border")->data.get();
static auto* const INACTIVECOL = (CGradientValueData*)g_pConfigManager->getConfigValuePtr("general:col.inactive_border")->data.get();
static auto* const GROUPACTIVECOL = (CGradientValueData*)g_pConfigManager->getConfigValuePtr("general:col.group_border_active")->data.get();
static auto* const GROUPINACTIVECOL = (CGradientValueData*)g_pConfigManager->getConfigValuePtr("general:col.group_border")->data.get();
static auto* const PINACTIVEALPHA = &g_pConfigManager->getConfigValuePtr("decoration:inactive_opacity")->floatValue;
static auto* const PACTIVEALPHA = &g_pConfigManager->getConfigValuePtr("decoration:active_opacity")->floatValue;
static auto* const PFULLSCREENALPHA = &g_pConfigManager->getConfigValuePtr("decoration:fullscreen_opacity")->floatValue;
Expand All @@ -1604,13 +1606,19 @@ void CCompositor::updateWindowAnimatedDecorationValues(CWindow* pWindow) {
const auto RENDERDATA = g_pLayoutManager->getCurrentLayout()->requestRenderHints(pWindow);
if (RENDERDATA.isBorderGradient)
setBorderColor(*RENDERDATA.borderGradient);
else
setBorderColor(pWindow == m_pLastWindow ? (pWindow->m_sSpecialRenderData.activeBorderColor.toUnderlying() >= 0 ?
CGradientValueData(CColor(pWindow->m_sSpecialRenderData.activeBorderColor.toUnderlying())) :
*ACTIVECOL) :
(pWindow->m_sSpecialRenderData.inactiveBorderColor.toUnderlying() >= 0 ?
CGradientValueData(CColor(pWindow->m_sSpecialRenderData.inactiveBorderColor.toUnderlying())) :
*INACTIVECOL));
else {
if (pWindow == m_pLastWindow) {
const auto* const ACTIVECOLOR = !pWindow->m_sGroupData.pNextWindow ? ACTIVECOL : GROUPACTIVECOL;
setBorderColor(pWindow->m_sSpecialRenderData.activeBorderColor.toUnderlying() >= 0 ?
CGradientValueData(CColor(pWindow->m_sSpecialRenderData.activeBorderColor.toUnderlying())) :
*ACTIVECOLOR);
} else {
const auto* const INACTIVECOLOR = !pWindow->m_sGroupData.pNextWindow ? INACTIVECOL : GROUPINACTIVECOL;
setBorderColor(pWindow->m_sSpecialRenderData.inactiveBorderColor.toUnderlying() >= 0 ?
CGradientValueData(CColor(pWindow->m_sSpecialRenderData.inactiveBorderColor.toUnderlying())) :
*INACTIVECOLOR);
}
}

// tick angle if it's not running (aka dead)
if (!pWindow->m_fBorderAngleAnimationProgress.isBeingAnimated())
Expand Down
68 changes: 68 additions & 0 deletions src/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,3 +468,71 @@ bool CWindow::hasPopupAt(const Vector2D& pos) {

return resultSurf;
}

CWindow* CWindow::getGroupHead() {
CWindow* curr = this;
while (!curr->m_sGroupData.head)
curr = curr->m_sGroupData.pNextWindow;
return curr;
}

CWindow* CWindow::getGroupTail() {
CWindow* curr = this;
while (!curr->m_sGroupData.pNextWindow->m_sGroupData.head)
curr = curr->m_sGroupData.pNextWindow;
return curr;
}

CWindow* CWindow::getGroupCurrent() {
CWindow* curr = this;
while (curr->isHidden())
curr = curr->m_sGroupData.pNextWindow;
return curr;
}

void CWindow::setGroupCurrent(CWindow* pWindow) {
CWindow* curr = this->m_sGroupData.pNextWindow;
bool isMember = false;
while (curr != this) {
if (curr == pWindow) {
isMember = true;
break;
}
curr = curr->m_sGroupData.pNextWindow;
}

if (!isMember && pWindow != this)
return;

const auto PCURRENT = getGroupCurrent();

const auto PWINDOWSIZE = PCURRENT->m_vRealSize.goalv();
const auto PWINDOWPOS = PCURRENT->m_vRealPosition.goalv();

const auto CURRENTISFOCUS = PCURRENT == g_pCompositor->m_pLastWindow;

PCURRENT->setHidden(true);
pWindow->setHidden(false);

g_pLayoutManager->getCurrentLayout()->replaceWindowDataWith(PCURRENT, pWindow);

if (PCURRENT->m_bIsFloating) {
pWindow->m_vRealPosition.setValueAndWarp(PWINDOWPOS);
pWindow->m_vRealSize.setValueAndWarp(PWINDOWSIZE);
}

g_pCompositor->updateAllWindowsAnimatedDecorationValues();

if (CURRENTISFOCUS)
g_pCompositor->focusWindow(pWindow);
}

void CWindow::insertWindowToGroup(CWindow* pWindow) {
const auto PHEAD = getGroupHead();
const auto PTAIL = getGroupTail();

PTAIL->m_sGroupData.pNextWindow = pWindow;
pWindow->m_sGroupData.pNextWindow = PHEAD;

setGroupCurrent(pWindow);
}
12 changes: 12 additions & 0 deletions src/Window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,12 @@ class CWindow {
// for idle inhibiting windows
eIdleInhibitMode m_eIdleInhibitMode = IDLEINHIBIT_NONE;

// for groups
struct SGroupData {
CWindow* pNextWindow = nullptr; // nullptr means no grouping. Self means single group.
bool head = false;
} m_sGroupData;

// For the list lookup
bool operator==(const CWindow& rhs) {
return m_uSurface.xdg == rhs.m_uSurface.xdg && m_uSurface.xwayland == rhs.m_uSurface.xwayland && m_vPosition == rhs.m_vPosition && m_vSize == rhs.m_vSize &&
Expand Down Expand Up @@ -303,6 +309,12 @@ class CWindow {
bool isInCurvedCorner(double x, double y);
bool hasPopupAt(const Vector2D& pos);

CWindow* getGroupHead();
CWindow* getGroupTail();
CWindow* getGroupCurrent();
void setGroupCurrent(CWindow* pWindow);
void insertWindowToGroup(CWindow* pWindow);

private:
// For hidden windows and stuff
bool m_bHidden = false;
Expand Down
8 changes: 4 additions & 4 deletions src/config/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
CConfigManager::CConfigManager() {
configValues["general:col.active_border"].data = std::make_shared<CGradientValueData>(0xffffffff);
configValues["general:col.inactive_border"].data = std::make_shared<CGradientValueData>(0xff444444);
configValues["dwindle:col.group_border"].data = std::make_shared<CGradientValueData>(0x66777700);
configValues["dwindle:col.group_border_active"].data = std::make_shared<CGradientValueData>(0x66ffff00);
configValues["general:col.group_border"].data = std::make_shared<CGradientValueData>(0x66777700);
configValues["general:col.group_border_active"].data = std::make_shared<CGradientValueData>(0x66ffff00);

setDefaultVars();
setDefaultAnimationVars();
Expand Down Expand Up @@ -44,6 +44,8 @@ void CConfigManager::setDefaultVars() {
configValues["general:gaps_out"].intValue = 20;
((CGradientValueData*)configValues["general:col.active_border"].data.get())->reset(0xffffffff);
((CGradientValueData*)configValues["general:col.inactive_border"].data.get())->reset(0xff444444);
((CGradientValueData*)configValues["general:col.group_border"].data.get())->reset(0x66777700);
((CGradientValueData*)configValues["general:col.group_border_active"].data.get())->reset(0x66ffff00);
configValues["general:cursor_inactive_timeout"].intValue = 0;
configValues["general:no_cursor_warps"].intValue = 0;
configValues["general:resize_on_border"].intValue = 0;
Expand Down Expand Up @@ -102,8 +104,6 @@ void CConfigManager::setDefaultVars() {
configValues["decoration:dim_around"].floatValue = 0.4f;
configValues["decoration:screen_shader"].strValue = STRVAL_EMPTY;

((CGradientValueData*)configValues["dwindle:col.group_border"].data.get())->reset(0x66777700);
((CGradientValueData*)configValues["dwindle:col.group_border_active"].data.get())->reset(0x66ffff00);
configValues["dwindle:pseudotile"].intValue = 0;
configValues["dwindle:force_split"].intValue = 0;
configValues["dwindle:preserve_split"].intValue = 0;
Expand Down
Loading

0 comments on commit e5a4c0c

Please sign in to comment.