summaryrefslogtreecommitdiff
path: root/src/layout
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2022-12-16 17:17:31 +0000
committerGitHub <noreply@github.com>2022-12-16 17:17:31 +0000
commit98a4fa2b0d79298fa29b048a3ba15c3bf5aed8cd (patch)
tree64e78342cf08e5f9ad87bd5f6ea36233133be7bb /src/layout
parent7c33c7fc64203c17b4f3625a16ae6b4774992c0e (diff)
Added clang format (#1239)
* clang-format stuff and format files
Diffstat (limited to 'src/layout')
-rw-r--r--src/layout/DwindleLayout.cpp387
-rw-r--r--src/layout/DwindleLayout.hpp103
-rw-r--r--src/layout/IHyprLayout.cpp69
-rw-r--r--src/layout/IHyprLayout.hpp73
-rw-r--r--src/layout/MasterLayout.cpp178
-rw-r--r--src/layout/MasterLayout.hpp75
6 files changed, 451 insertions, 434 deletions
diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp
index e8371e4c..8a62698f 100644
--- a/src/layout/DwindleLayout.cpp
+++ b/src/layout/DwindleLayout.cpp
@@ -4,10 +4,10 @@
void SDwindleNodeData::recalcSizePosRecursive(bool force) {
if (children[0]) {
- const auto REVERSESPLITRATIO = 2.f - splitRatio;
+ const auto REVERSESPLITRATIO = 2.f - splitRatio;
- static auto *const PPRESERVESPLIT = &g_pConfigManager->getConfigValuePtr("dwindle:preserve_split")->intValue;
- static auto *const PFLMULT = &g_pConfigManager->getConfigValuePtr("dwindle:split_width_multiplier")->floatValue;
+ static auto* const PPRESERVESPLIT = &g_pConfigManager->getConfigValuePtr("dwindle:preserve_split")->intValue;
+ static auto* const PFLMULT = &g_pConfigManager->getConfigValuePtr("dwindle:split_width_multiplier")->floatValue;
if (*PPRESERVESPLIT == 0) {
splitTop = size.y * *PFLMULT > size.x;
@@ -18,15 +18,15 @@ void SDwindleNodeData::recalcSizePosRecursive(bool force) {
if (SPLITSIDE) {
// split left/right
children[0]->position = position;
- children[0]->size = Vector2D(size.x / 2.f * splitRatio, size.y);
+ children[0]->size = Vector2D(size.x / 2.f * splitRatio, size.y);
children[1]->position = Vector2D(position.x + size.x / 2.f * splitRatio, position.y);
- children[1]->size = Vector2D(size.x / 2.f * REVERSESPLITRATIO, size.y);
+ children[1]->size = Vector2D(size.x / 2.f * REVERSESPLITRATIO, size.y);
} else {
// split top/bottom
children[0]->position = position;
- children[0]->size = Vector2D(size.x, size.y / 2.f * splitRatio);
+ children[0]->size = Vector2D(size.x, size.y / 2.f * splitRatio);
children[1]->position = Vector2D(position.x, position.y + size.y / 2.f * splitRatio);
- children[1]->size = Vector2D(size.x, size.y / 2.f * REVERSESPLITRATIO);
+ children[1]->size = Vector2D(size.x, size.y / 2.f * REVERSESPLITRATIO);
}
children[0]->recalcSizePosRecursive(force);
@@ -93,7 +93,7 @@ void SDwindleNodeData::setGroupFocusedNode(SDwindleNodeData* pMember) {
int SDwindleNodeData::getGroupMemberCount() {
SDwindleNodeData* current = this->pNextGroupMember;
- int no = 1;
+ int no = 1;
while (current != this) {
current = current->pNextGroupMember;
@@ -161,14 +161,14 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
}
// for gaps outer
- const bool DISPLAYLEFT = STICKS(pNode->position.x, PMONITOR->vecPosition.x + PMONITOR->vecReservedTopLeft.x);
- const bool DISPLAYRIGHT = STICKS(pNode->position.x + pNode->size.x, PMONITOR->vecPosition.x + PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x);
- const bool DISPLAYTOP = STICKS(pNode->position.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y);
- const bool DISPLAYBOTTOM = STICKS(pNode->position.y + pNode->size.y, PMONITOR->vecPosition.y + PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y);
+ const bool DISPLAYLEFT = STICKS(pNode->position.x, PMONITOR->vecPosition.x + PMONITOR->vecReservedTopLeft.x);
+ const bool DISPLAYRIGHT = STICKS(pNode->position.x + pNode->size.x, PMONITOR->vecPosition.x + PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x);
+ const bool DISPLAYTOP = STICKS(pNode->position.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y);
+ const bool DISPLAYBOTTOM = STICKS(pNode->position.y + pNode->size.y, PMONITOR->vecPosition.y + PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y);
- const auto PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
- const auto PGAPSIN = &g_pConfigManager->getConfigValuePtr("general:gaps_in")->intValue;
- const auto PGAPSOUT = &g_pConfigManager->getConfigValuePtr("general:gaps_out")->intValue;
+ const auto PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
+ const auto PGAPSIN = &g_pConfigManager->getConfigValuePtr("general:gaps_in")->intValue;
+ const auto PGAPSOUT = &g_pConfigManager->getConfigValuePtr("general:gaps_out")->intValue;
const auto PWINDOW = pNode->pWindow;
@@ -178,40 +178,40 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
return;
}
- PWINDOW->m_vSize = pNode->size;
+ PWINDOW->m_vSize = pNode->size;
PWINDOW->m_vPosition = pNode->position;
- static auto *const PNOGAPSWHENONLY = &g_pConfigManager->getConfigValuePtr("dwindle:no_gaps_when_only")->intValue;
+ static auto* const PNOGAPSWHENONLY = &g_pConfigManager->getConfigValuePtr("dwindle:no_gaps_when_only")->intValue;
- auto calcPos = PWINDOW->m_vPosition + Vector2D(*PBORDERSIZE, *PBORDERSIZE);
- auto calcSize = PWINDOW->m_vSize - Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE);
+ auto calcPos = PWINDOW->m_vPosition + Vector2D(*PBORDERSIZE, *PBORDERSIZE);
+ auto calcSize = PWINDOW->m_vSize - Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE);
- const auto NODESONWORKSPACE = getNodesOnWorkspace(PWINDOW->m_iWorkspaceID);
+ const auto NODESONWORKSPACE = getNodesOnWorkspace(PWINDOW->m_iWorkspaceID);
- if (*PNOGAPSWHENONLY && !g_pCompositor->isWorkspaceSpecial(PWINDOW->m_iWorkspaceID) && (NODESONWORKSPACE == 1 || (pNode->isGroupMember() && pNode->getGroupMemberCount() == NODESONWORKSPACE) || (PWINDOW->m_bIsFullscreen && g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID)->m_efFullscreenMode == FULLSCREEN_MAXIMIZED))) {
+ if (*PNOGAPSWHENONLY && !g_pCompositor->isWorkspaceSpecial(PWINDOW->m_iWorkspaceID) &&
+ (NODESONWORKSPACE == 1 || (pNode->isGroupMember() && pNode->getGroupMemberCount() == NODESONWORKSPACE) ||
+ (PWINDOW->m_bIsFullscreen && g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID)->m_efFullscreenMode == FULLSCREEN_MAXIMIZED))) {
PWINDOW->m_vRealPosition = calcPos - Vector2D(*PBORDERSIZE, *PBORDERSIZE);
- PWINDOW->m_vRealSize = calcSize + Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE);
+ PWINDOW->m_vRealSize = calcSize + Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE);
PWINDOW->updateWindowDecos();
PWINDOW->m_sSpecialRenderData.rounding = false;
- PWINDOW->m_sSpecialRenderData.border = false;
+ PWINDOW->m_sSpecialRenderData.border = false;
PWINDOW->m_sSpecialRenderData.decorate = false;
return;
}
PWINDOW->m_sSpecialRenderData.rounding = true;
- PWINDOW->m_sSpecialRenderData.border = true;
+ PWINDOW->m_sSpecialRenderData.border = true;
PWINDOW->m_sSpecialRenderData.decorate = true;
- const auto OFFSETTOPLEFT = Vector2D(DISPLAYLEFT ? *PGAPSOUT : *PGAPSIN,
- DISPLAYTOP ? *PGAPSOUT : *PGAPSIN);
+ const auto OFFSETTOPLEFT = Vector2D(DISPLAYLEFT ? *PGAPSOUT : *PGAPSIN, DISPLAYTOP ? *PGAPSOUT : *PGAPSIN);
- const auto OFFSETBOTTOMRIGHT = Vector2D(DISPLAYRIGHT ? *PGAPSOUT : *PGAPSIN,
- DISPLAYBOTTOM ? *PGAPSOUT : *PGAPSIN);
+ const auto OFFSETBOTTOMRIGHT = Vector2D(DISPLAYRIGHT ? *PGAPSOUT : *PGAPSIN, DISPLAYBOTTOM ? *PGAPSOUT : *PGAPSIN);
- calcPos = calcPos + OFFSETTOPLEFT;
+ calcPos = calcPos + OFFSETTOPLEFT;
calcSize = calcSize - OFFSETTOPLEFT - OFFSETBOTTOMRIGHT;
if (PWINDOW->m_bIsPseudotiled) {
@@ -229,25 +229,25 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
}
auto DELTA = calcSize - PWINDOW->m_vPseudoSize * scale;
- calcSize = PWINDOW->m_vPseudoSize * scale;
- calcPos = calcPos + DELTA / 2.f; // center
+ calcSize = PWINDOW->m_vPseudoSize * scale;
+ calcPos = calcPos + DELTA / 2.f; // center
} else {
auto DELTA = calcSize - PWINDOW->m_vPseudoSize;
- calcPos = calcPos + DELTA / 2.f; // center
- calcSize = PWINDOW->m_vPseudoSize;
+ calcPos = calcPos + DELTA / 2.f; // center
+ calcSize = PWINDOW->m_vPseudoSize;
}
}
if (g_pCompositor->isWorkspaceSpecial(PWINDOW->m_iWorkspaceID)) {
// if special, we adjust the coords a bit
- static auto *const PSCALEFACTOR = &g_pConfigManager->getConfigValuePtr("dwindle:special_scale_factor")->floatValue;
+ static auto* const PSCALEFACTOR = &g_pConfigManager->getConfigValuePtr("dwindle:special_scale_factor")->floatValue;
PWINDOW->m_vRealPosition = calcPos + (calcSize - calcSize * *PSCALEFACTOR) / 2.f;
- PWINDOW->m_vRealSize = calcSize * *PSCALEFACTOR;
+ PWINDOW->m_vRealSize = calcSize * *PSCALEFACTOR;
g_pXWaylandManager->setWindowSize(PWINDOW, calcSize * *PSCALEFACTOR);
} else {
- PWINDOW->m_vRealSize = calcSize;
+ PWINDOW->m_vRealSize = calcSize;
PWINDOW->m_vRealPosition = calcPos;
g_pXWaylandManager->setWindowSize(PWINDOW, calcSize);
@@ -266,7 +266,7 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
// update visible node
const auto PVISNODE = pNode->getGroupVisible();
- PVISNODE->pWindow->m_vRealSize = PWINDOW->m_vRealSize.goalv();
+ PVISNODE->pWindow->m_vRealSize = PWINDOW->m_vRealSize.goalv();
PVISNODE->pWindow->m_vRealPosition = PWINDOW->m_vRealPosition.goalv();
}
@@ -278,22 +278,23 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
return;
m_lDwindleNodesData.push_back(SDwindleNodeData());
- const auto PNODE = &m_lDwindleNodesData.back();
+ const auto PNODE = &m_lDwindleNodesData.back();
- const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
+ const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
- static auto *const PUSEACTIVE = &g_pConfigManager->getConfigValuePtr("dwindle:use_active_for_splits")->intValue;
+ static auto* const PUSEACTIVE = &g_pConfigManager->getConfigValuePtr("dwindle:use_active_for_splits")->intValue;
// Populate the node with our window's data
PNODE->workspaceID = pWindow->m_iWorkspaceID;
- PNODE->pWindow = pWindow;
- PNODE->isNode = false;
- PNODE->layout = this;
+ PNODE->pWindow = pWindow;
+ PNODE->isNode = false;
+ PNODE->layout = this;
SDwindleNodeData* OPENINGON;
- const auto MONFROMCURSOR = g_pCompositor->getMonitorFromCursor();
+ const auto MONFROMCURSOR = g_pCompositor->getMonitorFromCursor();
- if (PMONITOR->ID == MONFROMCURSOR->ID && (PNODE->workspaceID == PMONITOR->activeWorkspace || (g_pCompositor->isWorkspaceSpecial(PNODE->workspaceID) && PMONITOR->specialWorkspaceID)) && !*PUSEACTIVE) {
+ if (PMONITOR->ID == MONFROMCURSOR->ID &&
+ (PNODE->workspaceID == PMONITOR->activeWorkspace || (g_pCompositor->isWorkspaceSpecial(PNODE->workspaceID) && PMONITOR->specialWorkspaceID)) && !*PUSEACTIVE) {
OPENINGON = getNodeFromWindow(g_pCompositor->vectorToWindowTiled(g_pInputManager->getMouseCoordsInternal()));
// happens on reserved area
@@ -301,7 +302,8 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
OPENINGON = getFirstNodeOnWorkspace(PMONITOR->activeWorkspace);
} else if (*PUSEACTIVE) {
- if (g_pCompositor->m_pLastWindow && !g_pCompositor->m_pLastWindow->m_bIsFloating && g_pCompositor->m_pLastWindow != pWindow && g_pCompositor->m_pLastWindow->m_iWorkspaceID == pWindow->m_iWorkspaceID && g_pCompositor->m_pLastWindow->m_bIsMapped) {
+ if (g_pCompositor->m_pLastWindow && !g_pCompositor->m_pLastWindow->m_bIsFloating && g_pCompositor->m_pLastWindow != pWindow &&
+ g_pCompositor->m_pLastWindow->m_iWorkspaceID == pWindow->m_iWorkspaceID && g_pCompositor->m_pLastWindow->m_bIsMapped) {
OPENINGON = getNodeFromWindow(g_pCompositor->m_pLastWindow);
} else {
OPENINGON = getNodeFromWindow(g_pCompositor->vectorToWindowTiled(g_pInputManager->getMouseCoordsInternal()));
@@ -349,7 +351,7 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
// if it's the first, it's easy. Make it fullscreen.
if (!OPENINGON || OPENINGON->pWindow == pWindow) {
PNODE->position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
- PNODE->size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
+ PNODE->size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
applyNodeDataToWindow(PNODE);
@@ -363,15 +365,15 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
const auto PTAIL = PHEAD->pPreviousGroupMember;
PHEAD->pPreviousGroupMember = PNODE;
- PTAIL->pNextGroupMember = PNODE;
+ PTAIL->pNextGroupMember = PNODE;
- PNODE->pNextGroupMember = PHEAD;
+ PNODE->pNextGroupMember = PHEAD;
PNODE->pPreviousGroupMember = PTAIL;
PHEAD->setGroupFocusedNode(PNODE);
PNODE->position = PHEAD->position;
- PNODE->size = PHEAD->size;
+ PNODE->size = PHEAD->size;
applyNodeDataToWindow(PNODE);
@@ -386,25 +388,29 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
const auto NEWPARENT = &m_lDwindleNodesData.back();
// make the parent have the OPENINGON's stats
- NEWPARENT->position = OPENINGON->position;
- NEWPARENT->size = OPENINGON->size;
+ NEWPARENT->position = OPENINGON->position;
+ NEWPARENT->size = OPENINGON->size;
NEWPARENT->workspaceID = OPENINGON->workspaceID;
- NEWPARENT->pParent = OPENINGON->pParent;
- NEWPARENT->isNode = true; // it is a node
+ NEWPARENT->pParent = OPENINGON->pParent;
+ NEWPARENT->isNode = true; // it is a node
const auto PWIDTHMULTIPLIER = &g_pConfigManager->getConfigValuePtr("dwindle:split_width_multiplier")->floatValue;
// if cursor over first child, make it first, etc
const auto SIDEBYSIDE = NEWPARENT->size.x > NEWPARENT->size.y * *PWIDTHMULTIPLIER;
- NEWPARENT->splitTop = !SIDEBYSIDE;
+ NEWPARENT->splitTop = !SIDEBYSIDE;
const auto MOUSECOORDS = g_pInputManager->getMouseCoordsInternal();
const auto PFORCESPLIT = &g_pConfigManager->getConfigValuePtr("dwindle:force_split")->intValue;
if (*PFORCESPLIT == 0) {
- if ((SIDEBYSIDE && VECINRECT(MOUSECOORDS, NEWPARENT->position.x, NEWPARENT->position.y / *PWIDTHMULTIPLIER, NEWPARENT->position.x + NEWPARENT->size.x / 2.f, NEWPARENT->position.y + NEWPARENT->size.y))
- || (!SIDEBYSIDE && VECINRECT(MOUSECOORDS, NEWPARENT->position.x, NEWPARENT->position.y / *PWIDTHMULTIPLIER, NEWPARENT->position.x + NEWPARENT->size.x, NEWPARENT->position.y + NEWPARENT->size.y / 2.f))) {
+ if ((SIDEBYSIDE &&
+ VECINRECT(MOUSECOORDS, NEWPARENT->position.x, NEWPARENT->position.y / *PWIDTHMULTIPLIER, NEWPARENT->position.x + NEWPARENT->size.x / 2.f,
+ NEWPARENT->position.y + NEWPARENT->size.y)) ||
+ (!SIDEBYSIDE &&
+ VECINRECT(MOUSECOORDS, NEWPARENT->position.x, NEWPARENT->position.y / *PWIDTHMULTIPLIER, NEWPARENT->position.x + NEWPARENT->size.x,
+ NEWPARENT->position.y + NEWPARENT->size.y / 2.f))) {
// we are hovering over the first node, make PNODE first.
NEWPARENT->children[1] = OPENINGON;
NEWPARENT->children[0] = PNODE;
@@ -434,23 +440,22 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
// Update the children
-
if (NEWPARENT->size.x * *PWIDTHMULTIPLIER > NEWPARENT->size.y) {
// split left/right
OPENINGON->position = NEWPARENT->position;
- OPENINGON->size = Vector2D(NEWPARENT->size.x / 2.f, NEWPARENT->size.y);
- PNODE->position = Vector2D(NEWPARENT->position.x + NEWPARENT->size.x / 2.f, NEWPARENT->position.y);
- PNODE->size = Vector2D(NEWPARENT->size.x / 2.f, NEWPARENT->size.y);
+ OPENINGON->size = Vector2D(NEWPARENT->size.x / 2.f, NEWPARENT->size.y);
+ PNODE->position = Vector2D(NEWPARENT->position.x + NEWPARENT->size.x / 2.f, NEWPARENT->position.y);
+ PNODE->size = Vector2D(NEWPARENT->size.x / 2.f, NEWPARENT->size.y);
} else {
// split top/bottom
OPENINGON->position = NEWPARENT->position;
- OPENINGON->size = Vector2D(NEWPARENT->size.x, NEWPARENT->size.y / 2.f);
- PNODE->position = Vector2D(NEWPARENT->position.x, NEWPARENT->position.y + NEWPARENT->size.y / 2.f);
- PNODE->size = Vector2D(NEWPARENT->size.x, NEWPARENT->size.y / 2.f);
+ OPENINGON->size = Vector2D(NEWPARENT->size.x, NEWPARENT->size.y / 2.f);
+ PNODE->position = Vector2D(NEWPARENT->position.x, NEWPARENT->position.y + NEWPARENT->size.y / 2.f);
+ PNODE->size = Vector2D(NEWPARENT->size.x, NEWPARENT->size.y / 2.f);
}
OPENINGON->pParent = NEWPARENT;
- PNODE->pParent = NEWPARENT;
+ PNODE->pParent = NEWPARENT;
NEWPARENT->recalcSizePosRecursive();
@@ -468,7 +473,7 @@ void CHyprDwindleLayout::onWindowRemovedTiling(CWindow* pWindow) {
}
pWindow->m_sSpecialRenderData.rounding = true;
- pWindow->m_sSpecialRenderData.border = true;
+ pWindow->m_sSpecialRenderData.border = true;
pWindow->m_sSpecialRenderData.decorate = true;
if (pWindow->m_bIsFullscreen)
@@ -480,12 +485,12 @@ void CHyprDwindleLayout::onWindowRemovedTiling(CWindow* pWindow) {
const auto PPREV = PNODE->pPreviousGroupMember;
const auto PNEXT = PNODE->pNextGroupMember;
- PPREV->pNextGroupMember = PNEXT;
+ PPREV->pNextGroupMember = PNEXT;
PNEXT->pPreviousGroupMember = PPREV;
if (PNODE->groupHead) {
PNEXT->groupHead = true;
- PNEXT->pParent = PNODE->pParent;
+ PNEXT->pParent = PNODE->pParent;
if (PNODE->pParent) {
if (PNODE->pParent->children[0] == PNODE) {
@@ -496,12 +501,12 @@ void CHyprDwindleLayout::onWindowRemovedTiling(CWindow* pWindow) {
}
PNEXT->position = PNODE->position;
- PNEXT->size = PNODE->size;
+ PNEXT->size = PNODE->size;
} else {
const auto PHEAD = PNODE->getGroupHead();
PNEXT->position = PHEAD->position;
- PNEXT->size = PHEAD->size;
+ PNEXT->size = PHEAD->size;
}
PNEXT->setGroupFocusedNode(PNEXT);
@@ -530,8 +535,8 @@ void CHyprDwindleLayout::onWindowRemovedTiling(CWindow* pWindow) {
const auto PSIBLING = PPARENT->children[0] == PNODE ? PPARENT->children[1] : PPARENT->children[0];
PSIBLING->position = PPARENT->position;
- PSIBLING->size = PPARENT->size;
- PSIBLING->pParent = PPARENT->pParent;
+ PSIBLING->size = PPARENT->size;
+ PSIBLING->pParent = PPARENT->pParent;
if (PSIBLING->isGroupMember()) {
// apply to all group members
@@ -539,8 +544,8 @@ void CHyprDwindleLayout::onWindowRemovedTiling(CWindow* pWindow) {
while (current != PSIBLING) {
current->position = PPARENT->position;
- current->size = PPARENT->size;
- current = current->pNextGroupMember;
+ current->size = PPARENT->size;
+ current = current->pNextGroupMember;
}
}
@@ -553,7 +558,7 @@ void CHyprDwindleLayout::onWindowRemovedTiling(CWindow* pWindow) {
}
PPARENT->valid = false;
- PNODE->valid = false;
+ PNODE->valid = false;
if (PSIBLING->pParent)
PSIBLING->pParent->recalcSizePosRecursive();
@@ -582,7 +587,7 @@ void CHyprDwindleLayout::recalculateMonitor(const int& monid) {
if (TOPNODE && PMONITOR) {
TOPNODE->position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
- TOPNODE->size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
+ TOPNODE->size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
TOPNODE->recalcSizePosRecursive();
}
}
@@ -599,12 +604,12 @@ void CHyprDwindleLayout::recalculateMonitor(const int& monid) {
PWORKSPACE->m_bHasFullscreenWindow = false;
} else {
SDwindleNodeData fakeNode;
- fakeNode.pWindow = PFULLWINDOW;
- fakeNode.position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
- fakeNode.size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
- fakeNode.workspaceID = PWORKSPACE->m_iID;
+ fakeNode.pWindow = PFULLWINDOW;
+ fakeNode.position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
+ fakeNode.size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
+ fakeNode.workspaceID = PWORKSPACE->m_iID;
PFULLWINDOW->m_vPosition = fakeNode.position;
- PFULLWINDOW->m_vSize = fakeNode.size;
+ PFULLWINDOW->m_vSize = fakeNode.size;
applyNodeDataToWindow(&fakeNode);
@@ -616,7 +621,7 @@ void CHyprDwindleLayout::recalculateMonitor(const int& monid) {
if (TOPNODE && PMONITOR) {
TOPNODE->position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
- TOPNODE->size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
+ TOPNODE->size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
TOPNODE->recalcSizePosRecursive();
}
}
@@ -643,10 +648,10 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, CWindow*
const auto PANIMATE = &g_pConfigManager->getConfigValuePtr("misc:animate_manual_resizes")->intValue;
// get some data about our window
- const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
- const bool DISPLAYLEFT = STICKS(PWINDOW->m_vPosition.x, PMONITOR->vecPosition.x + PMONITOR->vecReservedTopLeft.x);
- const bool DISPLAYRIGHT = STICKS(PWINDOW->m_vPosition.x + PWINDOW->m_vSize.x, PMONITOR->vecPosition.x + PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x);
- const bool DISPLAYTOP = STICKS(PWINDOW->m_vPosition.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y);
+ const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
+ const bool DISPLAYLEFT = STICKS(PWINDOW->m_vPosition.x, PMONITOR->vecPosition.x + PMONITOR->vecReservedTopLeft.x);
+ const bool DISPLAYRIGHT = STICKS(PWINDOW->m_vPosition.x + PWINDOW->m_vSize.x, PMONITOR->vecPosition.x + PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x);
+ const bool DISPLAYTOP = STICKS(PWINDOW->m_vPosition.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y);
const bool DISPLAYBOTTOM = STICKS(PWINDOW->m_vPosition.y + PWINDOW->m_vSize.y, PMONITOR->vecPosition.y + PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y);
// construct allowed movement
@@ -661,7 +666,7 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, CWindow*
const auto PPARENT = PNODE->pParent;
if (!PPARENT)
- return; // the only window on a workspace, ignore
+ return; // the only window on a workspace, ignore
const bool PARENTSIDEBYSIDE = !PPARENT->splitTop;
@@ -704,13 +709,13 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, CWindow*
// 2 axes of freedom
const auto SIDECONTAINER = PARENTSIDEBYSIDE ? PPARENT : PPARENT2;
- const auto TOPCONTAINER = PARENTSIDEBYSIDE ? PPARENT2 : PPARENT;
+ const auto TOPCONTAINER = PARENTSIDEBYSIDE ? PPARENT2 : PPARENT;
allowedMovement.x *= 2.f / SIDECONTAINER->size.x;
allowedMovement.y *= 2.f / TOPCONTAINER->size.y;
SIDECONTAINER->splitRatio = std::clamp(SIDECONTAINER->splitRatio + allowedMovement.x, 0.1, 1.9);
- TOPCONTAINER->splitRatio = std::clamp(TOPCONTAINER->splitRatio + allowedMovement.y, 0.1, 1.9);
+ TOPCONTAINER->splitRatio = std::clamp(TOPCONTAINER->splitRatio + allowedMovement.y, 0.1, 1.9);
SIDECONTAINER->recalcSizePosRecursive(*PANIMATE == 0);
TOPCONTAINER->recalcSizePosRecursive(*PANIMATE == 0);
}
@@ -722,7 +727,7 @@ void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscree
if (on == pWindow->m_bIsFullscreen || g_pCompositor->isWorkspaceSpecial(pWindow->m_iWorkspaceID))
return; // ignore
- const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
+ const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
if (PWORKSPACE->m_bHasFullscreenWindow && on) {
@@ -732,7 +737,7 @@ void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscree
}
// otherwise, accept it.
- pWindow->m_bIsFullscreen = on;
+ pWindow->m_bIsFullscreen = on;
PWORKSPACE->m_bHasFullscreenWindow = !PWORKSPACE->m_bHasFullscreenWindow;
g_pEventManager->postEvent(SHyprIPCEvent{"fullscreen", std::to_string((int)on)});
@@ -745,7 +750,7 @@ void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscree
else {
// get back its' dimensions from position and size
pWindow->m_vRealPosition = pWindow->m_vPosition;
- pWindow->m_vRealSize = pWindow->m_vSize;
+ pWindow->m_vRealSize = pWindow->m_vSize;
}
} else {
// if it now got fullscreen, make it fullscreen
@@ -755,25 +760,25 @@ void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscree
// save position and size if floating
if (pWindow->m_bIsFloating) {
pWindow->m_vPosition = pWindow->m_vRealPosition.vec();
- pWindow->m_vSize = pWindow->m_vRealSize.vec();
+ pWindow->m_vSize = pWindow->m_vRealSize.vec();
}
// apply new pos and size being monitors' box
if (fullscreenMode == FULLSCREEN_FULL) {
pWindow->m_vRealPosition = PMONITOR->vecPosition;
- pWindow->m_vRealSize = PMONITOR->vecSize;
+ pWindow->m_vRealSize = PMONITOR->vecSize;
} else {
// This is a massive hack.
// We make a fake "only" node and apply
// To keep consistent with the settings without C+P code
SDwindleNodeData fakeNode;
- fakeNode.pWindow = pWindow;
- fakeNode.position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
- fakeNode.size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
+ fakeNode.pWindow = pWindow;
+ fakeNode.position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
+ fakeNode.size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
fakeNode.workspaceID = pWindow->m_iWorkspaceID;
pWindow->m_vPosition = fakeNode.position;
- pWindow->m_vSize = fakeNode.size;
+ pWindow->m_vSize = fakeNode.size;
applyNodeDataToWindow(&fakeNode);
}
@@ -828,7 +833,7 @@ void CHyprDwindleLayout::toggleWindowGroup(CWindow* pWindow) {
if (PNODE->isGroupMember()) {
// dissolve group
- const auto PHEAD = PNODE->getGroupHead();
+ const auto PHEAD = PNODE->getGroupHead();
SDwindleNodeData* current = PNODE->pNextGroupMember;
@@ -836,26 +841,26 @@ void CHyprDwindleLayout::toggleWindowGroup(CWindow* pWindow) {
std::deque<CWindow*> toAddWindows;
- const auto PWINDOWNODE = PNODE->pWindow;
+ const auto PWINDOWNODE = PNODE->pWindow;
toAddWindows.push_back(PWINDOWNODE);
while (current != PNODE) {
const auto PWINDOW = current->pWindow;
- current = current->pNextGroupMember;
+ current = current->pNextGroupMember;
toAddWindows.push_back(PWINDOW);
PWINDOW->setHidden(false);
}
- if (PHEAD->pPreviousGroupMember)
- PHEAD->pPreviousGroupMember->pNextGroupMember = PHEAD->pNextGroupMember;
+ if (PHEAD->pPreviousGroupMember)
+ PHEAD->pPreviousGroupMember->pNextGroupMember = PHEAD->pNextGroupMember;
- if (PHEAD->pNextGroupMember)
- PHEAD->pNextGroupMember->pPreviousGroupMember = PHEAD->pPreviousGroupMember;
+ if (PHEAD->pNextGroupMember)
+ PHEAD->pNextGroupMember->pPreviousGroupMember = PHEAD->pPreviousGroupMember;
- PHEAD->pPreviousGroupMember = nullptr;
- PHEAD->pNextGroupMember = nullptr;
+ PHEAD->pPreviousGroupMember = nullptr;
+ PHEAD->pNextGroupMember = nullptr;
onWindowRemoved(PHEAD->pWindow);
@@ -902,7 +907,7 @@ void CHyprDwindleLayout::toggleWindowGroup(CWindow* pWindow) {
}
PNODE->position = PNODE->pParent->position;
- PNODE->size = PNODE->pParent->size;
+ PNODE->size = PNODE->pParent->size;
applyNodeDataToWindow(PNODE);
@@ -925,14 +930,14 @@ void CHyprDwindleLayout::toggleWindowGroup(CWindow* pWindow) {
for (int i = 0; i < (int)newGroupMembers.size(); ++i) {
if (i != 0) {
newGroupMembers[i]->groupHead = false;
- newGroupMembers[i]->pParent = PNODE->pParent;
+ newGroupMembers[i]->pParent = PNODE->pParent;
}
const auto PREVMEMBER = i == 0 ? newGroupMembers[newGroupMembers.size() - 1] : newGroupMembers[i - 1];
const auto NEXTMEMBER = i == (int)newGroupMembers.size() - 1 ? newGroupMembers[0] : newGroupMembers[i + 1];
newGroupMembers[i]->pPreviousGroupMember = PREVMEMBER;
- newGroupMembers[i]->pNextGroupMember = NEXTMEMBER;
+ newGroupMembers[i]->pNextGroupMember = NEXTMEMBER;
// add the deco
newGroupMembers[i]->pWindow->m_dWindowDecorations.emplace_back(std::make_unique<CHyprGroupBarDecoration>(newGroupMembers[i]->pWindow));
@@ -961,9 +966,9 @@ std::deque<CWindow*> CHyprDwindleLayout::getGroupMembers(CWindow* pWindow) {
const auto PNODE = getNodeFromWindow(pWindow);
if (!PNODE || !PNODE->isGroupMember())
- return result; // reject with empty
+ return result; // reject with empty
- const auto HEAD = PNODE->getGroupHead();
+ const auto HEAD = PNODE->getGroupHead();
SDwindleNodeData* current = HEAD->pNextGroupMember;
result.push_back(HEAD->pWindow);
@@ -985,7 +990,7 @@ void CHyprDwindleLayout::switchGroupWindow(CWindow* pWindow, bool forward, CWind
if (!PNODE || !PNODE->isGroupMember())
return; // reject
- const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PNODE->workspaceID);
+ const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PNODE->workspaceID);
SDwindleNodeData* pNewNode;
@@ -1003,8 +1008,8 @@ void CHyprDwindleLayout::switchGroupWindow(CWindow* pWindow, bool forward, CWind
PNODE->setGroupFocusedNode(pNewNode);
- pNewNode->position = PNODE->position;
- pNewNode->size = PNODE->size;
+ pNewNode->position = PNODE->position;
+ pNewNode->size = PNODE->size;
pNewNode->workspaceID = PNODE->workspaceID;
applyNodeDataToWindow(pNewNode);
@@ -1037,10 +1042,10 @@ SWindowRenderLayoutHints CHyprDwindleLayout::requestRenderHints(CWindow* pWindow
SWindowRenderLayoutHints hints;
- 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;
+ 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;
- const auto PNODE = getNodeFromWindow(pWindow);
+ const auto PNODE = getNodeFromWindow(pWindow);
if (!PNODE)
return hints; // left for the future, maybe floating funkiness
@@ -1059,17 +1064,17 @@ SWindowRenderLayoutHints CHyprDwindleLayout::requestRenderHints(CWindow* pWindow
void CHyprDwindleLayout::switchWindows(CWindow* pWindow, CWindow* pWindow2) {
// windows should be valid, insallah
- auto PNODE = getNodeFromWindow(pWindow);
+ auto PNODE = getNodeFromWindow(pWindow);
auto PNODE2 = getNodeFromWindow(pWindow2);
if (!PNODE2 || !PNODE) {
- return;
- }
+ return;
+ }
SDwindleNodeData* ACTIVE1 = nullptr;
- SDwindleNodeData* ACTIVE2 = nullptr;
+ SDwindleNodeData* ACTIVE2 = nullptr;
- if (PNODE2->isGroupMember() || PNODE->isGroupMember()) {
+ if (PNODE2->isGroupMember() || PNODE->isGroupMember()) {
if (PNODE->workspaceID != PNODE2->workspaceID) {
Debug::log(ERR, "Groups are confined to a monitor");
@@ -1078,82 +1083,82 @@ void CHyprDwindleLayout::switchWindows(CWindow* pWindow, CWindow* pWindow2) {
if (PNODE->isGroupMember()) {
ACTIVE1 = PNODE;
- PNODE = PNODE->getGroupHead();
- }
+ PNODE = PNODE->getGroupHead();
+ }
- if (PNODE2->isGroupMember()) {
+ if (PNODE2->isGroupMember()) {
ACTIVE2 = PNODE2;
- PNODE2 = PNODE2->getGroupHead();
- }
-
- if (PNODE2->pParent == PNODE->pParent) {
- const auto PPARENT = PNODE->pParent;
-
- if (PPARENT->children[0] == PNODE) {
- PPARENT->children[0] = PNODE2;
- PPARENT->children[1] = PNODE;
- } else {
- PPARENT->children[0] = PNODE;
- PPARENT->children[1] = PNODE2;
- }
- } else {
- if (PNODE->pParent) {
- const auto PPARENT = PNODE->pParent;
-
- if (PPARENT->children[0] == PNODE) {
- PPARENT->children[0] = PNODE2;
- } else {
- PPARENT->children[1] = PNODE2;
- }
- }
-
- if (PNODE2->pParent) {
- const auto PPARENT = PNODE2->pParent;
-
- if (PPARENT->children[0] == PNODE2) {
- PPARENT->children[0] = PNODE;
- } else {
- PPARENT->children[1] = PNODE;
- }
- }
- }
-
- const auto PPARENTNODE2 = PNODE2->pParent;
- PNODE2->pParent = PNODE->pParent;
- PNODE->pParent = PPARENTNODE2;
-
- std::swap(PNODE2->workspaceID, PNODE->workspaceID);
- } else {
- // swap the windows and recalc
- PNODE2->pWindow = pWindow;
- PNODE->pWindow = pWindow2;
- }
-
- if (PNODE->workspaceID != PNODE2->workspaceID) {
- std::swap(pWindow2->m_iMonitorID, pWindow->m_iMonitorID);
- std::swap(pWindow2->m_iWorkspaceID, pWindow->m_iWorkspaceID);
- }
-
- // recalc the workspace
+ PNODE2 = PNODE2->getGroupHead();
+ }
+
+ if (PNODE2->pParent == PNODE->pParent) {
+ const auto PPARENT = PNODE->pParent;
+
+ if (PPARENT->children[0] == PNODE) {
+ PPARENT->children[0] = PNODE2;
+ PPARENT->children[1] = PNODE;
+ } else {
+ PPARENT->children[0] = PNODE;
+ PPARENT->children[1] = PNODE2;
+ }
+ } else {
+ if (PNODE->pParent) {
+ const auto PPARENT = PNODE->pParent;
+
+ if (PPARENT->children[0] == PNODE) {
+ PPARENT->children[0] = PNODE2;
+ } else {
+ PPARENT->children[1] = PNODE2;
+ }
+ }
+
+ if (PNODE2->pParent) {
+ const auto PPARENT = PNODE2->pParent;
+
+ if (PPARENT->children[0] == PNODE2) {
+ PPARENT->children[0] = PNODE;
+ } else {
+ PPARENT->children[1] = PNODE;
+ }
+ }
+ }
+
+ const auto PPARENTNODE2 = PNODE2->pParent;
+ PNODE2->pParent = PNODE->pParent;
+ PNODE->pParent = PPARENTNODE2;
+
+ std::swap(PNODE2->workspaceID, PNODE->workspaceID);
+ } else {
+ // swap the windows and recalc
+ PNODE2->pWindow = pWindow;
+ PNODE->pWindow = pWindow2;
+ }
+
+ if (PNODE->workspaceID != PNODE2->workspaceID) {
+ std::swap(pWindow2->m_iMonitorID, pWindow->m_iMonitorID);
+ std::swap(pWindow2->m_iWorkspaceID, pWindow->m_iWorkspaceID);
+ }
+
+ // recalc the workspace
getMasterNodeOnWorkspace(PNODE->workspaceID)->recalcSizePosRecursive();
if (PNODE2->workspaceID != PNODE->workspaceID) {
getMasterNodeOnWorkspace(PNODE2->workspaceID)->recalcSizePosRecursive();
}
- if (ACTIVE1) {
- ACTIVE1->position = PNODE->position;
- ACTIVE1->size = PNODE->size;
- ACTIVE1->pWindow->m_vPosition = ACTIVE1->position;
- ACTIVE1->pWindow->m_vSize = ACTIVE1->size;
- }
-
- if (ACTIVE2) {
- ACTIVE2->position = PNODE2->position;
- ACTIVE2->size = PNODE2->size;
- ACTIVE2->pWindow->m_vPosition = ACTIVE2->position;
- ACTIVE2->pWindow->m_vSize = ACTIVE2->size;
- }
+ if (ACTIVE1) {
+ ACTIVE1->position = PNODE->position;
+ ACTIVE1->size = PNODE->size;
+ ACTIVE1->pWindow->m_vPosition = ACTIVE1->position;
+ ACTIVE1->pWindow->m_vSize = ACTIVE1->size;
+ }
+
+ if (ACTIVE2) {
+ ACTIVE2->position = PNODE2->position;
+ ACTIVE2->size = PNODE2->size;
+ ACTIVE2->pWindow->m_vPosition = ACTIVE2->position;
+ ACTIVE2->pWindow->m_vSize = ACTIVE2->size;
+ }
g_pHyprRenderer->damageWindow(pWindow);
g_pHyprRenderer->damageWindow(pWindow2);
diff --git a/src/layout/DwindleLayout.hpp b/src/layout/DwindleLayout.hpp
index 624863b6..2c6f7229 100644
--- a/src/layout/DwindleLayout.hpp
+++ b/src/layout/DwindleLayout.hpp
@@ -4,80 +4,81 @@
#include <list>
#include <deque>
#include "../render/decorations/CHyprGroupBarDecoration.hpp"
+#include <array>
class CHyprDwindleLayout;
enum eFullscreenMode : uint8_t;
struct SDwindleNodeData {
- SDwindleNodeData* pParent = nullptr;
- bool isNode = false;
+ SDwindleNodeData* pParent = nullptr;
+ bool isNode = false;
- CWindow* pWindow = nullptr;
+ CWindow* pWindow = nullptr;
- std::array<SDwindleNodeData*, 2> children = { nullptr, nullptr };
+ std::array<SDwindleNodeData*, 2> children = {nullptr, nullptr};
- bool splitTop = false; // for preserve_split
+ bool splitTop = false; // for preserve_split
- bool groupHead = false;
- SDwindleNodeData* pNextGroupMember = nullptr;
- SDwindleNodeData* pPreviousGroupMember = nullptr;
+ bool groupHead = false;
+ SDwindleNodeData* pNextGroupMember = nullptr;
+ SDwindleNodeData* pPreviousGroupMember = nullptr;
- Vector2D position;
- Vector2D size;
+ Vector2D position;
+ Vector2D size;
- int workspaceID = -1;
+ int workspaceID = -1;
- float splitRatio = 1.f;
+ float splitRatio = 1.f;
- bool valid = true;
+ bool valid = true;
// For list lookup
bool operator==(const SDwindleNodeData& rhs) {
- return pWindow == rhs.pWindow && workspaceID == rhs.workspaceID && position == rhs.position && size == rhs.size && pParent == rhs.pParent && children[0] == rhs.children[0] && children[1] == rhs.children[1];
+ return pWindow == rhs.pWindow && workspaceID == rhs.workspaceID && position == rhs.position && size == rhs.size && pParent == rhs.pParent &&
+ children[0] == rhs.children[0] && children[1] == rhs.children[1];
}
- void recalcSizePosRecursive(bool force = false);
- void getAllChildrenRecursive(std::deque<SDwindleNodeData*>*);
- bool isGroupMember();
- SDwindleNodeData* getGroupHead();
- SDwindleNodeData* getGroupVisible();
- int getGroupMemberCount();
- void setGroupFocusedNode(SDwindleNodeData*);
+ void recalcSizePosRecursive(bool force = false);
+ void getAllChildrenRecursive(std::deque<SDwindleNodeData*>*);
+ bool isGroupMember();
+ SDwindleNodeData* getGroupHead();
+ SDwindleNodeData* getGroupVisible();
+ int getGroupMemberCount();
+ void setGroupFocusedNode(SDwindleNodeData*);
CHyprDwindleLayout* layout = nullptr;
};
class CHyprDwindleLayout : public IHyprLayout {
-public:
- virtual void onWindowCreatedTiling(CWindow*);
- virtual void onWindowRemovedTiling(CWindow*);
- virtual bool isWindowTiled(CWindow*);
- virtual void recalculateMonitor(const int&);
- virtual void recalculateWindow(CWindow*);
- virtual void resizeActiveWindow(const Vector2D&, CWindow* pWindow = nullptr);
- virtual void fullscreenRequestForWindow(CWindow*, eFullscreenMode, bool);
- virtual std::any layoutMessage(SLayoutMessageHeader, std::string);
+ public:
+ virtual void onWindowCreatedTiling(CWindow*);
+ virtual void onWindowRemovedTiling(CWindow*);
+ virtual bool isWindowTiled(CWindow*);
+ virtual void recalculateMonitor(const int&);
+ virtual void recalculateWindow(CWindow*);
+ virtual void resizeActiveWindow(const Vector2D&, CWindow* pWindow = nullptr);
+ virtual void fullscreenRequestForWindow(CWindow*, eFullscreenMode, bool);
+ virtual std::any layoutMessage(SLayoutMessageHeader, std::string);
virtual SWindowRenderLayoutHints requestRenderHints(CWindow*);
- virtual void switchWindows(CWindow*, CWindow*);
- virtual void alterSplitRatioBy(CWindow*, float);
- virtual std::string getLayoutName();
-
- virtual void onEnable();
- virtual void onDisable();
-
-private:
-
- std::list<SDwindleNodeData> m_lDwindleNodesData;
-
- int getNodesOnWorkspace(const int&);
- void applyNodeDataToWindow(SDwindleNodeData*, bool force = false);
- SDwindleNodeData* getNodeFromWindow(CWindow*);
- SDwindleNodeData* getFirstNodeOnWorkspace(const int&);
- SDwindleNodeData* getMasterNodeOnWorkspace(const int&);
-
- void toggleWindowGroup(CWindow*);
- void switchGroupWindow(CWindow*, bool forward, CWindow* to = nullptr);
- void toggleSplit(CWindow*);
- std::deque<CWindow*> getGroupMembers(CWindow*);
+ virtual void switchWindows(CWindow*, CWindow*);
+ virtual void alterSplitRatioBy(CWindow*, float);
+ virtual std::string getLayoutName();
+
+ virtual void onEnable();
+ virtual void onDisable();
+
+ private:
+ std::list<SDwindleNodeData> m_lDwindleNodesData;
+
+ int getNodesOnWorkspace(const int&);
+ void applyNodeDataToWindow(SDwindleNodeData*, bool force = false);
+ SDwindleNodeData* getNodeFromWindow(CWindow*);
+ SDwindleNodeData* getFirstNodeOnWorkspace(const int&);
+ SDwindleNodeData* getMasterNodeOnWorkspace(const int&);
+
+ void toggleWindowGroup(CWindow*);
+ void switchGroupWindow(CWindow*, bool forward, CWindow* to = nullptr);
+ void toggleSplit(CWindow*);
+ std::deque<CWindow*> getGroupMembers(CWindow*);
friend struct SDwindleNodeData;
}; \ No newline at end of file
diff --git a/src/layout/IHyprLayout.cpp b/src/layout/IHyprLayout.cpp
index 8696dc31..bc7e7984 100644
--- a/src/layout/IHyprLayout.cpp
+++ b/src/layout/IHyprLayout.cpp
@@ -10,7 +10,7 @@ void IHyprLayout::onWindowCreated(CWindow* pWindow) {
g_pXWaylandManager->getGeometryForWindow(pWindow, &desiredGeometry);
if (desiredGeometry.width <= 5 || desiredGeometry.height <= 5) {
- const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
+ const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
pWindow->m_vLastFloatingSize = PMONITOR->vecSize / 2.f;
} else {
pWindow->m_vLastFloatingSize = Vector2D(desiredGeometry.width, desiredGeometry.height);
@@ -50,9 +50,10 @@ void IHyprLayout::onWindowCreatedFloating(CWindow* pWindow) {
if (desiredGeometry.width <= 5 || desiredGeometry.height <= 5) {
const auto PWINDOWSURFACE = g_pXWaylandManager->getWindowSurface(pWindow);
- pWindow->m_vRealSize = Vector2D(PWINDOWSURFACE->current.width, PWINDOWSURFACE->current.height);
+ pWindow->m_vRealSize = Vector2D(PWINDOWSURFACE->current.width, PWINDOWSURFACE->current.height);
- if ((desiredGeometry.width <= 1 || desiredGeometry.height <= 1) && pWindow->m_bIsX11 && pWindow->m_iX11Type == 2) { // XDG windows should be fine. TODO: check for weird atoms?
+ if ((desiredGeometry.width <= 1 || desiredGeometry.height <= 1) && pWindow->m_bIsX11 &&
+ pWindow->m_iX11Type == 2) { // XDG windows should be fine. TODO: check for weird atoms?
pWindow->setHidden(true);
return;
}
@@ -62,7 +63,8 @@ void IHyprLayout::onWindowCreatedFloating(CWindow* pWindow) {
pWindow->m_vRealSize = PMONITOR->vecSize / 2.f;
}
- pWindow->m_vRealPosition = Vector2D(PMONITOR->vecPosition.x + (PMONITOR->vecSize.x - pWindow->m_vRealSize.goalv().x) / 2.f, PMONITOR->vecPosition.y + (PMONITOR->vecSize.y - pWindow->m_vRealSize.goalv().y) / 2.f);
+ pWindow->m_vRealPosition = Vector2D(PMONITOR->vecPosition.x + (PMONITOR->vecSize.x - pWindow->m_vRealSize.goalv().x) / 2.f,
+ PMONITOR->vecPosition.y + (PMONITOR->vecSize.y - pWindow->m_vRealSize.goalv().y) / 2.f);
} else {
// we respect the size.
pWindow->m_vRealSize = Vector2D(desiredGeometry.width, desiredGeometry.height);
@@ -75,10 +77,14 @@ void IHyprLayout::onWindowCreatedFloating(CWindow* pWindow) {
if (!pWindow->m_bIsX11) {
for (auto& m : g_pCompositor->m_vMonitors) {
- if (VECINRECT(Vector2D(desiredGeometry.x, desiredGeometry.y), m->vecPosition.x, m->vecPosition.y, m->vecPosition.x + m->vecSize.x, m->vecPosition.y + m->vecPosition.y)
- || VECINRECT(Vector2D(desiredGeometry.x + desiredGeometry.width, desiredGeometry.y), m->vecPosition.x, m->vecPosition.y, m->vecPosition.x + m->vecSize.x, m->vecPosition.y + m->vecPosition.y)
- || VECINRECT(Vector2D(desiredGeometry.x, desiredGeometry.y + desiredGeometry.height), m->vecPosition.x, m->vecPosition.y, m->vecPosition.x + m->vecSize.x, m->vecPosition.y + m->vecPosition.y)
- || VECINRECT(Vector2D(desiredGeometry.x + desiredGeometry.width, desiredGeometry.y + desiredGeometry.height), m->vecPosition.x, m->vecPosition.y, m->vecPosition.x + m->vecSize.x, m->vecPosition.y + m->vecPosition.y)) {
+ if (VECINRECT(Vector2D(desiredGeometry.x, desiredGeometry.y), m->vecPosition.x, m->vecPosition.y, m->vecPosition.x + m->vecSize.x,
+ m->vecPosition.y + m->vecPosition.y) ||
+ VECINRECT(Vector2D(desiredGeometry.x + desiredGeometry.width, desiredGeometry.y), m->vecPosition.x, m->vecPosition.y, m->vecPosition.x + m->vecSize.x,
+ m->vecPosition.y + m->vecPosition.y) ||
+ VECINRECT(Vector2D(desiredGeometry.x, desiredGeometry.y + desiredGeometry.height), m->vecPosition.x, m->vecPosition.y, m->vecPosition.x + m->vecSize.x,
+ m->vecPosition.y + m->vecPosition.y) ||
+ VECINRECT(Vector2D(desiredGeometry.x + desiredGeometry.width, desiredGeometry.y + desiredGeometry.height), m->vecPosition.x, m->vecPosition.y,
+ m->vecPosition.x + m->vecSize.x, m->vecPosition.y + m->vecPosition.y)) {
visible = true;
break;
@@ -144,17 +150,17 @@ void IHyprLayout::onBeginDragWindow() {
if (!DRAGGINGWINDOW->m_bIsFloating) {
if (g_pInputManager->dragMode == MBIND_MOVE) {
changeWindowFloatingMode(DRAGGINGWINDOW);
- DRAGGINGWINDOW->m_bIsFloating = true;
+ DRAGGINGWINDOW->m_bIsFloating = true;
DRAGGINGWINDOW->m_bDraggingTiled = true;
DRAGGINGWINDOW->m_vRealPosition = g_pInputManager->getMouseCoordsInternal() - DRAGGINGWINDOW->m_vRealSize.goalv() / 2.f;
}
}
- m_vBeginDragXY = g_pInputManager->getMouseCoordsInternal();
+ m_vBeginDragXY = g_pInputManager->getMouseCoordsInternal();
m_vBeginDragPositionXY = DRAGGINGWINDOW->m_vRealPosition.goalv();
- m_vBeginDragSizeXY = DRAGGINGWINDOW->m_vRealSize.goalv();
- m_vLastDragXY = m_vBeginDragXY;
+ m_vBeginDragSizeXY = DRAGGINGWINDOW->m_vRealSize.goalv();
+ m_vLastDragXY = m_vBeginDragXY;
// get the grab corner
if (m_vBeginDragXY.x < m_vBeginDragPositionXY.x + m_vBeginDragSizeXY.x / 2.0) {
@@ -208,7 +214,7 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) {
const auto SPECIAL = g_pCompositor->isWorkspaceSpecial(DRAGGINGWINDOW->m_iWorkspaceID);
- const auto DELTA = Vector2D(mousePos.x - m_vBeginDragXY.x, mousePos.y - m_vBeginDragXY.y);
+ const auto DELTA = Vector2D(mousePos.x - m_vBeginDragXY.x, mousePos.y - m_vBeginDragXY.y);
const auto TICKDELTA = Vector2D(mousePos.x - m_vLastDragXY.x, mousePos.y - m_vLastDragXY.y);
const auto PANIMATE = &g_pConfigManager->getConfigValuePtr("misc:animate_manual_resizes")->intValue;
@@ -237,25 +243,25 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) {
// calc the new size and pos
Vector2D newSize = m_vBeginDragSizeXY;
- Vector2D newPos = m_vBeginDragPositionXY;
+ Vector2D newPos = m_vBeginDragPositionXY;
if (m_iGrabbedCorner == 3) {
newSize = newSize + DELTA;
} else if (m_iGrabbedCorner == 0) {
newSize = newSize - DELTA;
- newPos = newPos + DELTA;
+ newPos = newPos + DELTA;
} else if (m_iGrabbedCorner == 1) {
newSize = newSize + Vector2D(DELTA.x, -DELTA.y);
- newPos = newPos + Vector2D(0, DELTA.y);
+ newPos = newPos + Vector2D(0, DELTA.y);
} else if (m_iGrabbedCorner == 4) {
newSize = newSize + Vector2D(-DELTA.x, DELTA.y);
- newPos = newPos + Vector2D(DELTA.x, 0);
+ newPos = newPos + Vector2D(DELTA.x, 0);
}
- newSize = newSize.clamp(Vector2D(20,20), MAXSIZE);
+ newSize = newSize.clamp(Vector2D(20, 20), MAXSIZE);
if (*PANIMATE) {
- DRAGGINGWINDOW->m_vRealSize = newSize;
+ DRAGGINGWINDOW->m_vRealSize = newSize;
DRAGGINGWINDOW->m_vRealPosition = newPos;
} else {
DRAGGINGWINDOW->m_vRealSize.setValueAndWarp(newSize);
@@ -301,15 +307,15 @@ void IHyprLayout::changeWindowFloatingMode(CWindow* pWindow) {
const auto TILED = isWindowTiled(pWindow);
// event
- g_pEventManager->postEvent(SHyprIPCEvent{ "changefloatingmode", getFormat("%x,%d", pWindow, (int)TILED) });
+ g_pEventManager->postEvent(SHyprIPCEvent{"changefloatingmode", getFormat("%x,%d", pWindow, (int)TILED)});
if (!TILED) {
- const auto PNEWMON = g_pCompositor->getMonitorFromVector(pWindow->m_vRealPosition.vec() + pWindow->m_vRealSize.vec() / 2.f);
+ const auto PNEWMON = g_pCompositor->getMonitorFromVector(pWindow->m_vRealPosition.vec() + pWindow->m_vRealSize.vec() / 2.f);
pWindow->m_iMonitorID = PNEWMON->ID;
pWindow->moveToWorkspace(PNEWMON->activeWorkspace);
// save real pos cuz the func applies the default 5,5 mid
- const auto PSAVEDPOS = pWindow->m_vRealPosition.goalv();
+ const auto PSAVEDPOS = pWindow->m_vRealPosition.goalv();
const auto PSAVEDSIZE = pWindow->m_vRealSize.goalv();
// if the window is pseudo, update its size
@@ -336,9 +342,9 @@ void IHyprLayout::changeWindowFloatingMode(CWindow* pWindow) {
g_pCompositor->moveWindowToTop(pWindow);
pWindow->m_vRealPosition = pWindow->m_vRealPosition.goalv() + (pWindow->m_vRealSize.goalv() - pWindow->m_vLastFloatingSize) / 2.f;
- pWindow->m_vRealSize = pWindow->m_vLastFloatingSize;
+ pWindow->m_vRealSize = pWindow->m_vLastFloatingSize;
- pWindow->m_vSize = pWindow->m_vRealSize.goalv();
+ pWindow->m_vSize = pWindow->m_vRealSize.goalv();
pWindow->m_vPosition = pWindow->m_vRealPosition.goalv();
g_pHyprRenderer->damageMonitor(g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID));
@@ -389,8 +395,10 @@ CWindow* IHyprLayout::getNextWindowCandidate(CWindow* pWindow) {
// find whether there is a floating window below this one
for (auto& w : g_pCompositor->m_vWindows) {
- if (w->m_bIsMapped && !w->isHidden() && w->m_bIsFloating && w->m_iX11Type != 2 && w->m_iWorkspaceID == pWindow->m_iWorkspaceID && !w->m_bX11ShouldntFocus && !w->m_bNoFocus) {
- if (VECINRECT((pWindow->m_vSize / 2.f + pWindow->m_vPosition), w->m_vPosition.x, w->m_vPosition.y, w->m_vPosition.x + w->m_vSize.x, w->m_vPosition.y + w->m_vSize.y)) {
+ if (w->m_bIsMapped && !w->isHidden() && w->m_bIsFloating && w->m_iX11Type != 2 && w->m_iWorkspaceID == pWindow->m_iWorkspaceID && !w->m_bX11ShouldntFocus &&
+ !w->m_bNoFocus) {
+ if (VECINRECT((pWindow->m_vSize / 2.f + pWindow->m_vPosition), w->m_vPosition.x, w->m_vPosition.y, w->m_vPosition.x + w->m_vSize.x,
+ w->m_vPosition.y + w->m_vSize.y)) {
return w.get();
}
}
@@ -406,7 +414,8 @@ CWindow* IHyprLayout::getNextWindowCandidate(CWindow* pWindow) {
// if not, floating window
for (auto& w : g_pCompositor->m_vWindows) {
- if (w->m_bIsMapped && !w->isHidden() && w->m_bIsFloating && w->m_iX11Type != 2 && w->m_iWorkspaceID == pWindow->m_iWorkspaceID && !w->m_bX11ShouldntFocus && !w->m_bNoFocus)
+ if (w->m_bIsMapped && !w->isHidden() && w->m_bIsFloating && w->m_iX11Type != 2 && w->m_iWorkspaceID == pWindow->m_iWorkspaceID && !w->m_bX11ShouldntFocus &&
+ !w->m_bNoFocus)
return w.get();
}
@@ -417,11 +426,11 @@ CWindow* IHyprLayout::getNextWindowCandidate(CWindow* pWindow) {
// if it was a tiled window, we first try to find the window that will replace it.
const auto PWINDOWCANDIDATE = g_pCompositor->vectorToWindowIdeal(pWindow->m_vRealPosition.goalv() + pWindow->m_vRealSize.goalv() / 2.f);
- if (!PWINDOWCANDIDATE || pWindow == PWINDOWCANDIDATE || !PWINDOWCANDIDATE->m_bIsMapped || PWINDOWCANDIDATE->isHidden() || PWINDOWCANDIDATE->m_bX11ShouldntFocus || PWINDOWCANDIDATE->m_iX11Type == 2 || PWINDOWCANDIDATE->m_iMonitorID != g_pCompositor->m_pLastMonitor->ID)
+ if (!PWINDOWCANDIDATE || pWindow == PWINDOWCANDIDATE || !PWINDOWCANDIDATE->m_bIsMapped || PWINDOWCANDIDATE->isHidden() || PWINDOWCANDIDATE->m_bX11ShouldntFocus ||
+ PWINDOWCANDIDATE->m_iX11Type == 2 || PWINDOWCANDIDATE->m_iMonitorID != g_pCompositor->m_pLastMonitor->ID)
return nullptr;
return PWINDOWCANDIDATE;
}
-IHyprLayout::~IHyprLayout() {
-}
+IHyprLayout::~IHyprLayout() {}
diff --git a/src/layout/IHyprLayout.hpp b/src/layout/IHyprLayout.hpp
index 1d22e41c..a58783e4 100644
--- a/src/layout/IHyprLayout.hpp
+++ b/src/layout/IHyprLayout.hpp
@@ -2,103 +2,104 @@
#include "../defines.hpp"
#include "../Window.hpp"
+#include <any>
struct SWindowRenderLayoutHints {
- bool isBorderColor = false;
- CColor borderColor;
+ bool isBorderColor = false;
+ CColor borderColor;
};
struct SLayoutMessageHeader {
- CWindow* pWindow = nullptr;
+ CWindow* pWindow = nullptr;
};
enum eFullscreenMode : uint8_t;
interface IHyprLayout {
-public:
- virtual ~IHyprLayout() = 0;
- virtual void onEnable() = 0;
- virtual void onDisable() = 0;
+ public:
+ virtual ~IHyprLayout() = 0;
+ virtual void onEnable() = 0;
+ virtual void onDisable() = 0;
/*
Called when a window is created (mapped)
The layout HAS TO set the goal pos and size (anim mgr will use it)
If !animationinprogress, then the anim mgr will not apply an anim.
*/
- virtual void onWindowCreated(CWindow*);
- virtual void onWindowCreatedTiling(CWindow*) = 0;
- virtual void onWindowCreatedFloating(CWindow*);
+ virtual void onWindowCreated(CWindow*);
+ virtual void onWindowCreatedTiling(CWindow*) = 0;
+ virtual void onWindowCreatedFloating(CWindow*);
/*
Return tiled status
*/
- virtual bool isWindowTiled(CWindow*) = 0;
+ virtual bool isWindowTiled(CWindow*) = 0;
/*
Called when a window is removed (unmapped)
*/
- virtual void onWindowRemoved(CWindow*);
- virtual void onWindowRemovedTiling(CWindow*) = 0;
- virtual void onWindowRemovedFloating(CWindow*);
+ virtual void onWindowRemoved(CWindow*);
+ virtual void onWindowRemovedTiling(CWindow*) = 0;
+ virtual void onWindowRemovedFloating(CWindow*);
/*
Called when the monitor requires a layout recalculation
this usually means reserved area changes
*/
- virtual void recalculateMonitor(const int&) = 0;
+ virtual void recalculateMonitor(const int&) = 0;
/*
Called when the compositor requests a window
to be recalculated, e.g. when pseudo is toggled.
*/
- virtual void recalculateWindow(CWindow*) = 0;
+ virtual void recalculateWindow(CWindow*) = 0;
/*
Called when a window is requested to be floated
*/
- virtual void changeWindowFloatingMode(CWindow*);
+ virtual void changeWindowFloatingMode(CWindow*);
/*
Called when a window is clicked on, beginning a drag
this might be a resize, move, whatever the layout defines it
as.
*/
- virtual void onBeginDragWindow();
+ virtual void onBeginDragWindow();
/*
Called when a user requests a resize of the current window by a vec
Vector2D holds pixel values
Optional pWindow for a specific window
*/
- virtual void resizeActiveWindow(const Vector2D&, CWindow* pWindow = nullptr) = 0;
+ virtual void resizeActiveWindow(const Vector2D&, CWindow* pWindow = nullptr) = 0;
/*
Called when a user requests a move of the current window by a vec
Vector2D holds pixel values
Optional pWindow for a specific window
*/
- virtual void moveActiveWindow(const Vector2D&, CWindow* pWindow = nullptr);
+ virtual void moveActiveWindow(const Vector2D&, CWindow* pWindow = nullptr);
/*
Called when a window is ended being dragged
(mouse up)
*/
- virtual void onEndDragWindow();
+ virtual void onEndDragWindow();
/*
Called whenever the mouse moves, should the layout want to
do anything with it.
Useful for dragging.
*/
- virtual void onMouseMove(const Vector2D&);
+ virtual void onMouseMove(const Vector2D&);
/*
Called when a window / the user requests to toggle the fullscreen state of a window
The layout sets all the fullscreen flags.
It can either accept or ignore.
*/
- virtual void fullscreenRequestForWindow(CWindow*, eFullscreenMode, bool) = 0;
+ virtual void fullscreenRequestForWindow(CWindow*, eFullscreenMode, bool) = 0;
/*
Called when a dispatcher requests a custom message
The layout is free to ignore.
std::any is the reply. Can be empty.
*/
- virtual std::any layoutMessage(SLayoutMessageHeader, std::string) = 0;
+ virtual std::any layoutMessage(SLayoutMessageHeader, std::string) = 0;
/*
Required to be handled, but may return just SWindowRenderLayoutHints()
@@ -111,35 +112,35 @@ public:
Called when the user requests two windows to be swapped places.
The layout is free to ignore.
*/
- virtual void switchWindows(CWindow*, CWindow*) = 0;
+ virtual void switchWindows(CWindow*, CWindow*) = 0;
/*
Called when the user requests to change the splitratio by X
on a window
*/
- virtual void alterSplitRatioBy(CWindow*, float) = 0;
+ virtual void alterSplitRatioBy(CWindow*, float) = 0;
/*
Called when something wants the current layout's name
*/
- virtual std::string getLayoutName() = 0;
+ virtual std::string getLayoutName() = 0;
/*
Called for getting the next candidate for a focus
*/
- virtual CWindow* getNextWindowCandidate(CWindow*);
+ virtual CWindow* getNextWindowCandidate(CWindow*);
/*
Internal: called when window focus changes
*/
- virtual void onWindowFocusChange(CWindow*);
+ virtual void onWindowFocusChange(CWindow*);
-private:
- Vector2D m_vBeginDragXY;
- Vector2D m_vLastDragXY;
- Vector2D m_vBeginDragPositionXY;
- Vector2D m_vBeginDragSizeXY;
- int m_iGrabbedCorner = 0;
+ private:
+ Vector2D m_vBeginDragXY;
+ Vector2D m_vLastDragXY;
+ Vector2D m_vBeginDragPositionXY;
+ Vector2D m_vBeginDragSizeXY;
+ int m_iGrabbedCorner = 0;
- CWindow* m_pLastTiledWindow = nullptr;
+ CWindow* m_pLastTiledWindow = nullptr;
};
diff --git a/src/layout/MasterLayout.cpp b/src/layout/MasterLayout.cpp
index d1ece288..e4d8474c 100644
--- a/src/layout/MasterLayout.cpp
+++ b/src/layout/MasterLayout.cpp
@@ -37,9 +37,9 @@ SMasterWorkspaceData* CHyprMasterLayout::getMasterWorkspaceData(const int& ws) {
}
//create on the fly if it doesn't exist yet
- const auto PWORKSPACEDATA = &m_lMasterWorkspacesData.emplace_back();
+ const auto PWORKSPACEDATA = &m_lMasterWorkspacesData.emplace_back();
PWORKSPACEDATA->workspaceID = ws;
- const auto orientation = &g_pConfigManager->getConfigValuePtr("master:orientation")->strValue;
+ const auto orientation = &g_pConfigManager->getConfigValuePtr("master:orientation")->strValue;
if (*orientation == "top") {
PWORKSPACEDATA->orientation = ORIENTATION_TOP;
} else if (*orientation == "right") {
@@ -69,30 +69,30 @@ void CHyprMasterLayout::onWindowCreatedTiling(CWindow* pWindow) {
if (pWindow->m_bIsFloating)
return;
- static auto *const PNEWTOP = &g_pConfigManager->getConfigValuePtr("master:new_on_top")->intValue;
+ static auto* const PNEWTOP = &g_pConfigManager->getConfigValuePtr("master:new_on_top")->intValue;
- const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
+ const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
- const auto PNODE = *PNEWTOP ? &m_lMasterNodesData.emplace_front() : &m_lMasterNodesData.emplace_back();
+ const auto PNODE = *PNEWTOP ? &m_lMasterNodesData.emplace_front() : &m_lMasterNodesData.emplace_back();
PNODE->workspaceID = pWindow->m_iWorkspaceID;
- PNODE->pWindow = pWindow;
+ PNODE->pWindow = pWindow;
- static auto *const PNEWISMASTER = &g_pConfigManager->getConfigValuePtr("master:new_is_master")->intValue;
+ static auto* const PNEWISMASTER = &g_pConfigManager->getConfigValuePtr("master:new_is_master")->intValue;
- const auto WINDOWSONWORKSPACE = getNodesOnWorkspace(PNODE->workspaceID);
- float lastSplitPercent = 0.5f;
+ const auto WINDOWSONWORKSPACE = getNodesOnWorkspace(PNODE->workspaceID);
+ float lastSplitPercent = 0.5f;
if (*PNEWISMASTER || WINDOWSONWORKSPACE == 1) {
for (auto& nd : m_lMasterNodesData) {
if (nd.isMaster && nd.workspaceID == PNODE->workspaceID) {
- nd.isMaster = false;
+ nd.isMaster = false;
lastSplitPercent = nd.percMaster;
break;
}
}
- PNODE->isMaster = true;
+ PNODE->isMaster = true;
PNODE->percMaster = lastSplitPercent;
// first, check if it isn't too big.
@@ -107,7 +107,8 @@ void CHyprMasterLayout::onWindowCreatedTiling(CWindow* pWindow) {
PNODE->isMaster = false;
// first, check if it isn't too big.
- if (const auto MAXSIZE = g_pXWaylandManager->getMaxSizeForWindow(pWindow); MAXSIZE.x < PMONITOR->vecSize.x * (1 - lastSplitPercent) || MAXSIZE.y < PMONITOR->vecSize.y * (1.f / (WINDOWSONWORKSPACE - 1))) {
+ if (const auto MAXSIZE = g_pXWaylandManager->getMaxSizeForWindow(pWindow);
+ MAXSIZE.x < PMONITOR->vecSize.x * (1 - lastSplitPercent) || MAXSIZE.y < PMONITOR->vecSize.y * (1.f / (WINDOWSONWORKSPACE - 1))) {
// we can't continue. make it floating.
pWindow->m_bIsFloating = true;
m_lMasterNodesData.remove(*PNODE);
@@ -134,7 +135,7 @@ void CHyprMasterLayout::onWindowRemovedTiling(CWindow* pWindow) {
return;
pWindow->m_sSpecialRenderData.rounding = true;
- pWindow->m_sSpecialRenderData.border = true;
+ pWindow->m_sSpecialRenderData.border = true;
pWindow->m_sSpecialRenderData.decorate = true;
if (pWindow->m_bIsFullscreen)
@@ -169,7 +170,7 @@ void CHyprMasterLayout::onWindowRemovedTiling(CWindow* pWindow) {
}
void CHyprMasterLayout::recalculateMonitor(const int& monid) {
- const auto PMONITOR = g_pCompositor->getMonitorFromID(monid);
+ const auto PMONITOR = g_pCompositor->getMonitorFromID(monid);
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace);
if (!PWORKSPACE)
@@ -186,15 +187,15 @@ void CHyprMasterLayout::recalculateMonitor(const int& monid) {
return;
// massive hack from the fullscreen func
- const auto PFULLWINDOW = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
+ const auto PFULLWINDOW = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
SMasterNodeData fakeNode;
- fakeNode.pWindow = PFULLWINDOW;
- fakeNode.position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
- fakeNode.size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
- fakeNode.workspaceID = PWORKSPACE->m_iID;
+ fakeNode.pWindow = PFULLWINDOW;
+ fakeNode.position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
+ fakeNode.size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
+ fakeNode.workspaceID = PWORKSPACE->m_iID;
PFULLWINDOW->m_vPosition = fakeNode.position;
- PFULLWINDOW->m_vSize = fakeNode.size;
+ PFULLWINDOW->m_vSize = fakeNode.size;
applyNodeDataToWindow(&fakeNode);
@@ -225,14 +226,15 @@ void CHyprMasterLayout::calculateWorkspace(const int& ws) {
//compute placement of master window(s)
if (getNodesOnWorkspace(PWORKSPACE->m_iID) < 2) {
PMASTERNODE->position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition;
- PMASTERNODE->size = Vector2D(PMONITOR->vecSize.x - PMONITOR->vecReservedTopLeft.x - PMONITOR->vecReservedBottomRight.x, PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y);
+ PMASTERNODE->size = Vector2D(PMONITOR->vecSize.x - PMONITOR->vecReservedTopLeft.x - PMONITOR->vecReservedBottomRight.x,
+ PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y);
applyNodeDataToWindow(PMASTERNODE);
return;
} else if (PWORKSPACEDATA->orientation == ORIENTATION_LEFT || PWORKSPACEDATA->orientation == ORIENTATION_RIGHT) {
- float heightLeft = PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y;
- int nodesLeft = MASTERS;
- float nextY = 0;
- const float WIDTH = (PMONITOR->vecSize.x - PMONITOR->vecReservedTopLeft.x - PMONITOR->vecReservedBottomRight.x) * PMASTERNODE->percMaster;
+ float heightLeft = PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y;
+ int nodesLeft = MASTERS;
+ float nextY = 0;
+ const float WIDTH = (PMONITOR->vecSize.x - PMONITOR->vecReservedTopLeft.x - PMONITOR->vecReservedBottomRight.x) * PMASTERNODE->percMaster;
for (auto& n : m_lMasterNodesData) {
if (n.workspaceID == PWORKSPACE->m_iID && n.isMaster) {
@@ -254,15 +256,15 @@ void CHyprMasterLayout::calculateWorkspace(const int& ws) {
}
}
} else if (PWORKSPACEDATA->orientation == ORIENTATION_TOP || PWORKSPACEDATA->orientation == ORIENTATION_BOTTOM) {
- float widthLeft = PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x - PMONITOR->vecReservedTopLeft.x;
- int nodesLeft = MASTERS;
- float nextX = 0;
- const float HEIGHT = (PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y) * PMASTERNODE->percMaster;
+ float widthLeft = PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x - PMONITOR->vecReservedTopLeft.x;
+ int nodesLeft = MASTERS;
+ float nextX = 0;
+ const float HEIGHT = (PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y) * PMASTERNODE->percMaster;
for (auto& n : m_lMasterNodesData) {
if (n.workspaceID == PWORKSPACE->m_iID && n.isMaster) {
- if (PWORKSPACEDATA->orientation == ORIENTATION_BOTTOM) {
- n.position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition + Vector2D(nextX,PMONITOR->vecSize.y - HEIGHT - PMONITOR->vecReservedBottomRight.y);
+ if (PWORKSPACEDATA->orientation == ORIENTATION_BOTTOM) {
+ n.position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition + Vector2D(nextX, PMONITOR->vecSize.y - HEIGHT - PMONITOR->vecReservedBottomRight.y);
} else {
n.position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition + Vector2D(nextX, 0);
}
@@ -280,20 +282,20 @@ void CHyprMasterLayout::calculateWorkspace(const int& ws) {
}
}
-
//compute placement of slave window(s)
int slavesLeft = getNodesOnWorkspace(PWORKSPACE->m_iID) - MASTERS;
if (PWORKSPACEDATA->orientation == ORIENTATION_LEFT || PWORKSPACEDATA->orientation == ORIENTATION_RIGHT) {
- float heightLeft = PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y;
- float nextY = 0;
- const float WIDTH = PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x - PMONITOR->vecReservedTopLeft.x - PMASTERNODE->size.x;
+ float heightLeft = PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y;
+ float nextY = 0;
+ const float WIDTH = PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x - PMONITOR->vecReservedTopLeft.x - PMASTERNODE->size.x;
for (auto& nd : m_lMasterNodesData) {
if (nd.workspaceID != PWORKSPACE->m_iID || nd.isMaster)
continue;
if (PWORKSPACEDATA->orientation == ORIENTATION_LEFT) {
- nd.position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition + Vector2D(PMASTERNODE->percMaster * (PMONITOR->vecSize.x - PMONITOR->vecReservedTopLeft.x - PMONITOR->vecReservedBottomRight.x), nextY);
+ nd.position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition +
+ Vector2D(PMASTERNODE->percMaster * (PMONITOR->vecSize.x - PMONITOR->vecReservedTopLeft.x - PMONITOR->vecReservedBottomRight.x), nextY);
} else {
nd.position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition + Vector2D(0, nextY);
}
@@ -309,15 +311,16 @@ void CHyprMasterLayout::calculateWorkspace(const int& ws) {
applyNodeDataToWindow(&nd);
}
} else if (PWORKSPACEDATA->orientation == ORIENTATION_TOP || PWORKSPACEDATA->orientation == ORIENTATION_BOTTOM) {
- float widthLeft = PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x - PMONITOR->vecReservedTopLeft.x;
- float nextX = 0;
- const float HEIGHT = PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y - PMASTERNODE->size.y;
+ float widthLeft = PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x - PMONITOR->vecReservedTopLeft.x;
+ float nextX = 0;
+ const float HEIGHT = PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y - PMASTERNODE->size.y;
for (auto& nd : m_lMasterNodesData) {
if (nd.workspaceID != PWORKSPACE->m_iID || nd.isMaster)
continue;
if (PWORKSPACEDATA->orientation == ORIENTATION_TOP) {
- nd.position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition + Vector2D(nextX, PMASTERNODE->percMaster * (PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y));
+ nd.position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition +
+ Vector2D(nextX, PMASTERNODE->percMaster * (PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y));
} else {
nd.position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition + Vector2D(nextX, 0);
}
@@ -333,8 +336,6 @@ void CHyprMasterLayout::calculateWorkspace(const int& ws) {
applyNodeDataToWindow(&nd);
}
}
-
-
}
void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
@@ -357,14 +358,14 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
}
// for gaps outer
- const bool DISPLAYLEFT = STICKS(pNode->position.x, PMONITOR->vecPosition.x + PMONITOR->vecReservedTopLeft.x);
- const bool DISPLAYRIGHT = STICKS(pNode->position.x + pNode->size.x, PMONITOR->vecPosition.x + PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x);
- const bool DISPLAYTOP = STICKS(pNode->position.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y);
- const bool DISPLAYBOTTOM = STICKS(pNode->position.y + pNode->size.y, PMONITOR->vecPosition.y + PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y);
+ const bool DISPLAYLEFT = STICKS(pNode->position.x, PMONITOR->vecPosition.x + PMONITOR->vecReservedTopLeft.x);
+ const bool DISPLAYRIGHT = STICKS(pNode->position.x + pNode->size.x, PMONITOR->vecPosition.x + PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x);
+ const bool DISPLAYTOP = STICKS(pNode->position.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y);
+ const bool DISPLAYBOTTOM = STICKS(pNode->position.y + pNode->size.y, PMONITOR->vecPosition.y + PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y);
- const auto PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
- const auto PGAPSIN = &g_pConfigManager->getConfigValuePtr("general:gaps_in")->intValue;
- const auto PGAPSOUT = &g_pConfigManager->getConfigValuePtr("general:gaps_out")->intValue;
+ const auto PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
+ const auto PGAPSIN = &g_pConfigManager->getConfigValuePtr("general:gaps_in")->intValue;
+ const auto PGAPSOUT = &g_pConfigManager->getConfigValuePtr("general:gaps_out")->intValue;
const auto PWINDOW = pNode->pWindow;
@@ -373,49 +374,49 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
return;
}
- static auto *const PNOGAPSWHENONLY = &g_pConfigManager->getConfigValuePtr("master:no_gaps_when_only")->intValue;
+ static auto* const PNOGAPSWHENONLY = &g_pConfigManager->getConfigValuePtr("master:no_gaps_when_only")->intValue;
- PWINDOW->m_vSize = pNode->size;
+ PWINDOW->m_vSize = pNode->size;
PWINDOW->m_vPosition = pNode->position;
- auto calcPos = PWINDOW->m_vPosition + Vector2D(*PBORDERSIZE, *PBORDERSIZE);
+ auto calcPos = PWINDOW->m_vPosition + Vector2D(*PBORDERSIZE, *PBORDERSIZE);
auto calcSize = PWINDOW->m_vSize - Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE);
- if (*PNOGAPSWHENONLY && !g_pCompositor->isWorkspaceSpecial(PWINDOW->m_iWorkspaceID) && (getNodesOnWorkspace(PWINDOW->m_iWorkspaceID) == 1 || (PWINDOW->m_bIsFullscreen && g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID)->m_efFullscreenMode == FULLSCREEN_MAXIMIZED))) {
+ if (*PNOGAPSWHENONLY && !g_pCompositor->isWorkspaceSpecial(PWINDOW->m_iWorkspaceID) &&
+ (getNodesOnWorkspace(PWINDOW->m_iWorkspaceID) == 1 ||
+ (PWINDOW->m_bIsFullscreen && g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID)->m_efFullscreenMode == FULLSCREEN_MAXIMIZED))) {
PWINDOW->m_vRealPosition = calcPos - Vector2D(*PBORDERSIZE, *PBORDERSIZE);
- PWINDOW->m_vRealSize = calcSize + Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE);
+ PWINDOW->m_vRealSize = calcSize + Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE);
PWINDOW->updateWindowDecos();
PWINDOW->m_sSpecialRenderData.rounding = false;
- PWINDOW->m_sSpecialRenderData.border = false;
+ PWINDOW->m_sSpecialRenderData.border = false;
PWINDOW->m_sSpecialRenderData.decorate = false;
return;
}
PWINDOW->m_sSpecialRenderData.rounding = true;
- PWINDOW->m_sSpecialRenderData.border = true;
+ PWINDOW->m_sSpecialRenderData.border = true;
PWINDOW->m_sSpecialRenderData.decorate = true;
- const auto OFFSETTOPLEFT = Vector2D(DISPLAYLEFT ? *PGAPSOUT : *PGAPSIN,
- DISPLAYTOP ? *PGAPSOUT : *PGAPSIN);
+ const auto OFFSETTOPLEFT = Vector2D(DISPLAYLEFT ? *PGAPSOUT : *PGAPSIN, DISPLAYTOP ? *PGAPSOUT : *PGAPSIN);
- const auto OFFSETBOTTOMRIGHT = Vector2D(DISPLAYRIGHT ? *PGAPSOUT : *PGAPSIN,
- DISPLAYBOTTOM ? *PGAPSOUT : *PGAPSIN);
+ const auto OFFSETBOTTOMRIGHT = Vector2D(DISPLAYRIGHT ? *PGAPSOUT : *PGAPSIN, DISPLAYBOTTOM ? *PGAPSOUT : *PGAPSIN);
- calcPos = calcPos + OFFSETTOPLEFT;
+ calcPos = calcPos + OFFSETTOPLEFT;
calcSize = calcSize - OFFSETTOPLEFT - OFFSETBOTTOMRIGHT;
if (g_pCompositor->isWorkspaceSpecial(PWINDOW->m_iWorkspaceID)) {
- static auto *const PSCALEFACTOR = &g_pConfigManager->getConfigValuePtr("master:special_scale_factor")->floatValue;
+ static auto* const PSCALEFACTOR = &g_pConfigManager->getConfigValuePtr("master:special_scale_factor")->floatValue;
PWINDOW->m_vRealPosition = calcPos + (calcSize - calcSize * *PSCALEFACTOR) / 2.f;
- PWINDOW->m_vRealSize = calcSize * *PSCALEFACTOR;
+ PWINDOW->m_vRealSize = calcSize * *PSCALEFACTOR;
g_pXWaylandManager->setWindowSize(PWINDOW, calcSize * *PSCALEFACTOR);
} else {
- PWINDOW->m_vRealSize = calcSize;
+ PWINDOW->m_vRealSize = calcSize;
PWINDOW->m_vRealPosition = calcPos;
g_pXWaylandManager->setWindowSize(PWINDOW, calcSize);
@@ -471,10 +472,10 @@ void CHyprMasterLayout::resizeActiveWindow(const Vector2D& pixResize, CWindow* p
if (PNODE->isMaster && getMastersOnWorkspace(PNODE->workspaceID) > 1) {
// check master size
const auto SIZEY = (PMONITOR->vecSize.y - PMONITOR->vecReservedTopLeft.y - PMONITOR->vecReservedBottomRight.y) / getMastersOnWorkspace(PNODE->workspaceID);
- PNODE->percSize = std::clamp(PNODE->percSize + pixResize.y / SIZEY, 0.05, 1.95);
+ PNODE->percSize = std::clamp(PNODE->percSize + pixResize.y / SIZEY, 0.05, 1.95);
} else if (!PNODE->isMaster && (getNodesOnWorkspace(PWINDOW->m_iWorkspaceID) - getMastersOnWorkspace(PNODE->workspaceID)) > 1) {
const auto SIZEY = (PMONITOR->vecSize.y - PMONITOR->vecReservedTopLeft.y - PMONITOR->vecReservedBottomRight.y) / getNodesOnWorkspace(PNODE->workspaceID);
- PNODE->percSize = std::clamp(PNODE->percSize + pixResize.y / SIZEY, 0.05, 1.95);
+ PNODE->percSize = std::clamp(PNODE->percSize + pixResize.y / SIZEY, 0.05, 1.95);
}
}
@@ -488,9 +489,9 @@ void CHyprMasterLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscreen
return;
if (on == pWindow->m_bIsFullscreen || g_pCompositor->isWorkspaceSpecial(pWindow->m_iWorkspaceID))
- return; // ignore
+ return; // ignore
- const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
+ const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
if (PWORKSPACE->m_bHasFullscreenWindow && on) {
@@ -500,7 +501,7 @@ void CHyprMasterLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscreen
}
// otherwise, accept it.
- pWindow->m_bIsFullscreen = on;
+ pWindow->m_bIsFullscreen = on;
PWORKSPACE->m_bHasFullscreenWindow = !PWORKSPACE->m_bHasFullscreenWindow;
g_pEventManager->postEvent(SHyprIPCEvent{"fullscreen", std::to_string((int)on)});
@@ -513,7 +514,7 @@ void CHyprMasterLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscreen
else {
// get back its' dimensions from position and size
pWindow->m_vRealPosition = pWindow->m_vPosition;
- pWindow->m_vRealSize = pWindow->m_vSize;
+ pWindow->m_vRealSize = pWindow->m_vSize;
}
} else {
// if it now got fullscreen, make it fullscreen
@@ -523,25 +524,25 @@ void CHyprMasterLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscreen
// save position and size if floating
if (pWindow->m_bIsFloating) {
pWindow->m_vPosition = pWindow->m_vRealPosition.vec();
- pWindow->m_vSize = pWindow->m_vRealSize.vec();
+ pWindow->m_vSize = pWindow->m_vRealSize.vec();
}
// apply new pos and size being monitors' box
if (fullscreenMode == FULLSCREEN_FULL) {
pWindow->m_vRealPosition = PMONITOR->vecPosition;
- pWindow->m_vRealSize = PMONITOR->vecSize;
+ pWindow->m_vRealSize = PMONITOR->vecSize;
} else {
// This is a massive hack.
// We make a fake "only" node and apply
// To keep consistent with the settings without C+P code
SMasterNodeData fakeNode;
- fakeNode.pWindow = pWindow;
- fakeNode.position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
- fakeNode.size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
+ fakeNode.pWindow = pWindow;
+ fakeNode.position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
+ fakeNode.size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
fakeNode.workspaceID = pWindow->m_iWorkspaceID;
pWindow->m_vPosition = fakeNode.position;
- pWindow->m_vSize = fakeNode.size;
+ pWindow->m_vSize = fakeNode.size;
applyNodeDataToWindow(&fakeNode);
}
@@ -576,7 +577,7 @@ SWindowRenderLayoutHints CHyprMasterLayout::requestRenderHints(CWindow* pWindow)
void CHyprMasterLayout::switchWindows(CWindow* pWindow, CWindow* pWindow2) {
// windows should be valid, insallah
- const auto PNODE = getNodeFromWindow(pWindow);
+ const auto PNODE = getNodeFromWindow(pWindow);
const auto PNODE2 = getNodeFromWindow(pWindow2);
if (!PNODE2 || !PNODE)
@@ -590,7 +591,7 @@ void CHyprMasterLayout::switchWindows(CWindow* pWindow, CWindow* pWindow2) {
}
// massive hack: just swap window pointers, lol
- PNODE->pWindow = pWindow2;
+ PNODE->pWindow = pWindow2;
PNODE2->pWindow = pWindow;
recalculateMonitor(pWindow->m_iMonitorID);
@@ -635,7 +636,7 @@ CWindow* CHyprMasterLayout::getNextWindow(CWindow* pWindow, bool next) {
} else {
// focus next
bool reached = false;
- bool found = false;
+ bool found = false;
for (auto n : m_lMasterNodesData) {
if (n.pWindow == pWindow) {
reached = true;
@@ -664,7 +665,7 @@ CWindow* CHyprMasterLayout::getNextWindow(CWindow* pWindow, bool next) {
} else {
// focus previous
bool reached = false;
- bool found = false;
+ bool found = false;
for (auto it = m_lMasterNodesData.rbegin(); it != m_lMasterNodesData.rend(); it++) {
if (it->pWindow == pWindow) {
reached = true;
@@ -694,7 +695,7 @@ bool CHyprMasterLayout::prepareLoseFocus(CWindow* pWindow) {
//if the current window is fullscreen, make it normal again if we are about to lose focus
if (pWindow->m_bIsFullscreen) {
g_pCompositor->setWindowFullscreen(pWindow, false, FULLSCREEN_FULL);
- static auto *const INHERIT = &g_pConfigManager->getConfigValuePtr("master:inherit_fullscreen")->intValue;
+ static auto* const INHERIT = &g_pConfigManager->getConfigValuePtr("master:inherit_fullscreen")->intValue;
return *INHERIT == 1;
}
@@ -732,7 +733,6 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
if (!PMASTER)
return 0;
-
if (PMASTER->pWindow != PWINDOW) {
switchWindows(PWINDOW, PMASTER->pWindow);
switchToWindow(PWINDOW);
@@ -835,7 +835,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
if (header.pWindow->m_bIsFloating)
return 0;
- const auto PNODE = getNodeFromWindow(header.pWindow);
+ const auto PNODE = getNodeFromWindow(header.pWindow);
const auto WINDOWS = getNodesOnWorkspace(header.pWindow->m_iWorkspaceID);
const auto MASTERS = getMastersOnWorkspace(header.pWindow->m_iWorkspaceID);
@@ -900,13 +900,13 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
const auto PWORKSPACEDATA = getMasterWorkspaceData(PWINDOW->m_iWorkspaceID);
- if (message == "orientationleft")
+ if (message == "orientationleft")
PWORKSPACEDATA->orientation = ORIENTATION_LEFT;
- else if (message == "orientationright")
+ else if (message == "orientationright")
PWORKSPACEDATA->orientation = ORIENTATION_RIGHT;
- else if (message == "orientationtop")
+ else if (message == "orientationtop")
PWORKSPACEDATA->orientation = ORIENTATION_TOP;
- else if (message == "orientationbottom")
+ else if (message == "orientationbottom")
PWORKSPACEDATA->orientation = ORIENTATION_BOTTOM;
recalculateMonitor(header.pWindow->m_iMonitorID);
@@ -924,7 +924,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
if (PWORKSPACEDATA->orientation == ORIENTATION_BOTTOM) {
PWORKSPACEDATA->orientation = ORIENTATION_LEFT;
} else {
- PWORKSPACEDATA->orientation = (eOrientation) (PWORKSPACEDATA->orientation + 1);
+ PWORKSPACEDATA->orientation = (eOrientation)(PWORKSPACEDATA->orientation + 1);
}
recalculateMonitor(header.pWindow->m_iMonitorID);
@@ -941,7 +941,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
if (PWORKSPACEDATA->orientation == ORIENTATION_LEFT) {
PWORKSPACEDATA->orientation = ORIENTATION_BOTTOM;
} else {
- PWORKSPACEDATA->orientation = (eOrientation) (PWORKSPACEDATA->orientation - 1);
+ PWORKSPACEDATA->orientation = (eOrientation)(PWORKSPACEDATA->orientation - 1);
}
recalculateMonitor(header.pWindow->m_iMonitorID);
diff --git a/src/layout/MasterLayout.hpp b/src/layout/MasterLayout.hpp
index 06dd8f00..1b637fde 100644
--- a/src/layout/MasterLayout.hpp
+++ b/src/layout/MasterLayout.hpp
@@ -4,11 +4,13 @@
#include <vector>
#include <list>
#include <deque>
+#include <any>
enum eFullscreenMode : uint8_t;
//orientation determines which side of the screen the master area resides
-enum eOrientation : uint8_t {
+enum eOrientation : uint8_t
+{
ORIENTATION_LEFT = 0,
ORIENTATION_TOP,
ORIENTATION_RIGHT,
@@ -16,67 +18,66 @@ enum eOrientation : uint8_t {
};
struct SMasterNodeData {
- bool isMaster = false;
- float percMaster = 0.5f;
+ bool isMaster = false;
+ float percMaster = 0.5f;
CWindow* pWindow = nullptr;
Vector2D position;
Vector2D size;
- float percSize = 1.f; // size multiplier for resizing children
+ float percSize = 1.f; // size multiplier for resizing children
- int workspaceID = -1;
+ int workspaceID = -1;
- bool operator==(const SMasterNodeData& rhs) {
+ bool operator==(const SMasterNodeData& rhs) {
return pWindow == rhs.pWindow;
}
};
struct SMasterWorkspaceData {
- int workspaceID = -1;
+ int workspaceID = -1;
eOrientation orientation = ORIENTATION_LEFT;
- bool operator==(const SMasterWorkspaceData& rhs) {
+ bool operator==(const SMasterWorkspaceData& rhs) {
return workspaceID == rhs.workspaceID;
}
};
class CHyprMasterLayout : public IHyprLayout {
-public:
- virtual void onWindowCreatedTiling(CWindow*);
- virtual void onWindowRemovedTiling(CWindow*);
- virtual bool isWindowTiled(CWindow*);
- virtual void recalculateMonitor(const int&);
- virtual void recalculateWindow(CWindow*);
- virtual void resizeActiveWindow(const Vector2D&, CWindow* pWindow = nullptr);
- virtual void fullscreenRequestForWindow(CWindow*, eFullscreenMode, bool);
- virtual std::any layoutMessage(SLayoutMessageHeader, std::string);
+ public:
+ virtual void onWindowCreatedTiling(CWindow*);
+ virtual void onWindowRemovedTiling(CWindow*);
+ virtual bool isWindowTiled(CWindow*);
+ virtual void recalculateMonitor(const int&);
+ virtual void recalculateWindow(CWindow*);
+ virtual void resizeActiveWindow(const Vector2D&, CWindow* pWindow = nullptr);
+ virtual void fullscreenRequestForWindow(CWindow*, eFullscreenMode, bool);
+ virtual std::any layoutMessage(SLayoutMessageHeader, std::string);
virtual SWindowRenderLayoutHints requestRenderHints(CWindow*);
- virtual void switchWindows(CWindow*, CWindow*);
- virtual void alterSplitRatioBy(CWindow*, float);
- virtual std::string getLayoutName();
+ virtual void switchWindows(CWindow*, CWindow*);
+ virtual void alterSplitRatioBy(CWindow*, float);
+ virtual std::string getLayoutName();
- virtual void onEnable();
- virtual void onDisable();
+ virtual void onEnable();
+ virtual void onDisable();
-private:
-
- std::list<SMasterNodeData> m_lMasterNodesData;
+ private:
+ std::list<SMasterNodeData> m_lMasterNodesData;
std::vector<SMasterWorkspaceData> m_lMasterWorkspacesData;
- bool m_bForceWarps = false;
-
- int getNodesOnWorkspace(const int&);
- void applyNodeDataToWindow(SMasterNodeData*);
- SMasterNodeData* getNodeFromWindow(CWindow*);
- SMasterNodeData* getMasterNodeOnWorkspace(const int&);
- SMasterWorkspaceData* getMasterWorkspaceData(const int&);
- void calculateWorkspace(const int&);
- CWindow* getNextWindow(CWindow*, bool);
- int getMastersOnWorkspace(const int&);
- bool prepareLoseFocus(CWindow*);
- void prepareNewFocus(CWindow*, bool inherit_fullscreen);
+ bool m_bForceWarps = false;
+
+ int getNodesOnWorkspace(const int&);
+ void applyNodeDataToWindow(SMasterNodeData*);
+ SMasterNodeData* getNodeFromWindow(CWindow*);
+ SMasterNodeData* getMasterNodeOnWorkspace(const int&);
+ SMasterWorkspaceData* getMasterWorkspaceData(const int&);
+ void calculateWorkspace(const int&);
+ CWindow* getNextWindow(CWindow*, bool);
+ int getMastersOnWorkspace(const int&);
+ bool prepareLoseFocus(CWindow*);
+ void prepareNewFocus(CWindow*, bool inherit_fullscreen);
friend struct SMasterNodeData;
friend struct SMasterWorkspaceData;