aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/layout/DwindleLayout.cpp
diff options
context:
space:
mode:
authorVaxry <[email protected]>2024-04-02 20:32:39 +0100
committerGitHub <[email protected]>2024-04-02 20:32:39 +0100
commitef23ef60c5641c5903f9cf40571ead7ad6aba1b9 (patch)
tree2eece29849bf25d7710edd9cee5d12186a9253fc /src/layout/DwindleLayout.cpp
parentfc0a7af7ba5c52f7a70309020f5cb27c19d068e6 (diff)
downloadHyprland-ef23ef60c5641c5903f9cf40571ead7ad6aba1b9.tar.gz
Hyprland-ef23ef60c5641c5903f9cf40571ead7ad6aba1b9.zip
Workspace/core: Refactor workspace storage (#5380)
* refactor workspaces to use ptrs * clang-format
Diffstat (limited to 'src/layout/DwindleLayout.cpp')
-rw-r--r--src/layout/DwindleLayout.cpp53
1 files changed, 24 insertions, 29 deletions
diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp
index 93f60e3f..67390010 100644
--- a/src/layout/DwindleLayout.cpp
+++ b/src/layout/DwindleLayout.cpp
@@ -105,7 +105,7 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
if (g_pCompositor->isWorkspaceSpecial(pNode->workspaceID)) {
for (auto& m : g_pCompositor->m_vMonitors) {
- if (m->specialWorkspaceID == pNode->workspaceID) {
+ if (m->activeSpecialWorkspaceID() == pNode->workspaceID) {
PMONITOR = m.get();
break;
}
@@ -162,10 +162,10 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
PWINDOW->m_vSize = nodeBox.size();
PWINDOW->m_vPosition = nodeBox.pos();
- const auto NODESONWORKSPACE = getNodesOnWorkspace(PWINDOW->m_iWorkspaceID);
+ const auto NODESONWORKSPACE = getNodesOnWorkspace(PWINDOW->workspaceID());
- if (*PNOGAPSWHENONLY && !g_pCompositor->isWorkspaceSpecial(PWINDOW->m_iWorkspaceID) &&
- (NODESONWORKSPACE == 1 || (PWINDOW->m_bIsFullscreen && g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID)->m_efFullscreenMode == FULLSCREEN_MAXIMIZED))) {
+ if (*PNOGAPSWHENONLY && !PWINDOW->onSpecialWorkspace() &&
+ (NODESONWORKSPACE == 1 || (PWINDOW->m_bIsFullscreen && PWINDOW->m_pWorkspace->m_efFullscreenMode == FULLSCREEN_MAXIMIZED))) {
PWINDOW->m_sSpecialRenderData.rounding = false;
PWINDOW->m_sSpecialRenderData.shadow = false;
@@ -229,7 +229,7 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
calcPos = calcPos + RESERVED.topLeft;
calcSize = calcSize - (RESERVED.topLeft + RESERVED.bottomRight);
- if (g_pCompositor->isWorkspaceSpecial(PWINDOW->m_iWorkspaceID) && !PWINDOW->m_bIsFullscreen) {
+ if (PWINDOW->onSpecialWorkspace() && !PWINDOW->m_bIsFullscreen) {
// if special, we adjust the coords a bit
static auto PSCALEFACTOR = CConfigValue<Hyprlang::FLOAT>("dwindle:special_scale_factor");
@@ -278,7 +278,7 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection dire
overrideDirection = direction;
// Populate the node with our window's data
- PNODE->workspaceID = pWindow->m_iWorkspaceID;
+ PNODE->workspaceID = pWindow->workspaceID();
PNODE->pWindow = pWindow;
PNODE->isNode = false;
PNODE->layout = this;
@@ -289,7 +289,7 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection dire
const auto MONFROMCURSOR = g_pCompositor->getMonitorFromVector(MOUSECOORDS);
if (PMONITOR->ID == MONFROMCURSOR->ID &&
- (PNODE->workspaceID == PMONITOR->activeWorkspace || (g_pCompositor->isWorkspaceSpecial(PNODE->workspaceID) && PMONITOR->specialWorkspaceID)) && !*PUSEACTIVE) {
+ (PNODE->workspaceID == PMONITOR->activeWorkspaceID() || (g_pCompositor->isWorkspaceSpecial(PNODE->workspaceID) && PMONITOR->activeSpecialWorkspace)) && !*PUSEACTIVE) {
OPENINGON = getNodeFromWindow(g_pCompositor->vectorToWindowUnified(MOUSECOORDS, RESERVED_EXTENTS | INPUT_EXTENTS));
if (!OPENINGON && g_pCompositor->isPointOnReservedArea(MOUSECOORDS, PMONITOR))
@@ -297,7 +297,7 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection dire
} 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) {
+ g_pCompositor->m_pLastWindow->m_pWorkspace == pWindow->m_pWorkspace && g_pCompositor->m_pLastWindow->m_bIsMapped) {
OPENINGON = getNodeFromWindow(g_pCompositor->m_pLastWindow);
} else {
OPENINGON = getNodeFromWindow(g_pCompositor->vectorToWindowUnified(MOUSECOORDS, RESERVED_EXTENTS | INPUT_EXTENTS));
@@ -307,7 +307,7 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection dire
OPENINGON = getClosestNodeOnWorkspace(PNODE->workspaceID, MOUSECOORDS);
} else
- OPENINGON = getFirstNodeOnWorkspace(pWindow->m_iWorkspaceID);
+ OPENINGON = getFirstNodeOnWorkspace(pWindow->workspaceID());
Debug::log(LOG, "OPENINGON: {}, Monitor: {}", OPENINGON, PMONITOR->ID);
@@ -551,40 +551,35 @@ void CHyprDwindleLayout::onWindowRemovedTiling(CWindow* pWindow) {
void CHyprDwindleLayout::recalculateMonitor(const int& monid) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(monid);
- if (!PMONITOR)
+ if (!PMONITOR || !PMONITOR->activeWorkspace)
return; // ???
g_pHyprRenderer->damageMonitor(PMONITOR);
- if (PMONITOR->specialWorkspaceID)
- calculateWorkspace(PMONITOR->specialWorkspaceID);
+ if (PMONITOR->activeSpecialWorkspace)
+ calculateWorkspace(PMONITOR->activeSpecialWorkspace);
calculateWorkspace(PMONITOR->activeWorkspace);
}
-void CHyprDwindleLayout::calculateWorkspace(const int& ws) {
- const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(ws);
-
- if (!PWORKSPACE)
- return;
-
- const auto PMONITOR = g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID);
+void CHyprDwindleLayout::calculateWorkspace(const PHLWORKSPACE& pWorkspace) {
+ const auto PMONITOR = g_pCompositor->getMonitorFromID(pWorkspace->m_iMonitorID);
if (!PMONITOR)
return;
- if (PWORKSPACE->m_bHasFullscreenWindow) {
+ if (pWorkspace->m_bHasFullscreenWindow) {
// massive hack from the fullscreen func
- const auto PFULLWINDOW = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
+ const auto PFULLWINDOW = g_pCompositor->getFullscreenWindowOnWorkspace(pWorkspace->m_iID);
- if (PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL) {
+ if (pWorkspace->m_efFullscreenMode == FULLSCREEN_FULL) {
PFULLWINDOW->m_vRealPosition = PMONITOR->vecPosition;
PFULLWINDOW->m_vRealSize = PMONITOR->vecSize;
- } else if (PWORKSPACE->m_efFullscreenMode == FULLSCREEN_MAXIMIZED) {
+ } else if (pWorkspace->m_efFullscreenMode == FULLSCREEN_MAXIMIZED) {
SDwindleNodeData fakeNode;
fakeNode.pWindow = PFULLWINDOW;
fakeNode.box = {PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft, PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight};
- fakeNode.workspaceID = PWORKSPACE->m_iID;
+ fakeNode.workspaceID = pWorkspace->m_iID;
PFULLWINDOW->m_vPosition = fakeNode.box.pos();
PFULLWINDOW->m_vSize = fakeNode.box.size();
fakeNode.ignoreFullscreenChecks = true;
@@ -596,7 +591,7 @@ void CHyprDwindleLayout::calculateWorkspace(const int& ws) {
return;
}
- const auto TOPNODE = getMasterNodeOnWorkspace(ws);
+ const auto TOPNODE = getMasterNodeOnWorkspace(pWorkspace->m_iID);
if (TOPNODE) {
TOPNODE->box = {PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft, PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight};
@@ -813,7 +808,7 @@ void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscree
return; // ignore
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
- const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
+ const auto PWORKSPACE = pWindow->m_pWorkspace;
if (PWORKSPACE->m_bHasFullscreenWindow && on) {
// if the window wants to be fullscreen but there already is one,
@@ -868,7 +863,7 @@ void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscree
SDwindleNodeData fakeNode;
fakeNode.pWindow = pWindow;
fakeNode.box = {PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft, PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight};
- fakeNode.workspaceID = pWindow->m_iWorkspaceID;
+ fakeNode.workspaceID = pWindow->workspaceID();
pWindow->m_vPosition = fakeNode.box.pos();
pWindow->m_vSize = fakeNode.box.size();
fakeNode.ignoreFullscreenChecks = true;
@@ -981,7 +976,7 @@ void CHyprDwindleLayout::switchWindows(CWindow* pWindow, CWindow* pWindow2) {
if (PNODE->workspaceID != PNODE2->workspaceID) {
std::swap(pWindow2->m_iMonitorID, pWindow->m_iMonitorID);
- std::swap(pWindow2->m_iWorkspaceID, pWindow->m_iWorkspaceID);
+ std::swap(pWindow2->m_pWorkspace, pWindow->m_pWorkspace);
}
pWindow->setAnimationsToMove();
@@ -1137,7 +1132,7 @@ Vector2D CHyprDwindleLayout::predictSizeForNewWindowTiled() {
CWindow* candidate = g_pCompositor->m_pLastWindow;
if (!candidate)
- candidate = g_pCompositor->getFirstWindowOnWorkspace(g_pCompositor->m_pLastMonitor->activeWorkspace);
+ candidate = g_pCompositor->getFirstWindowOnWorkspace(g_pCompositor->m_pLastMonitor->activeWorkspace->m_iID);
// create a fake node
SDwindleNodeData node;