summaryrefslogtreecommitdiff
path: root/src/layout
diff options
context:
space:
mode:
authorthejch <66577496+thejch@users.noreply.github.com>2024-03-16 17:15:12 -0700
committerGitHub <noreply@github.com>2024-03-17 00:15:12 +0000
commit0387528c56c4d9faf93946cbc9426973de6ef61b (patch)
treeccf67ca0ceb71a8ce4c17743321e274ba044df69 /src/layout
parent0e87a08e15c023325b64920d9e1159f38a090695 (diff)
master: fix moving fullscreen workspace and remove duplicate code (#5131)
Diffstat (limited to 'src/layout')
-rw-r--r--src/layout/DwindleLayout.cpp49
-rw-r--r--src/layout/DwindleLayout.hpp3
-rw-r--r--src/layout/MasterLayout.cpp65
3 files changed, 39 insertions, 78 deletions
diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp
index cc4bc0b3..1ce6aa82 100644
--- a/src/layout/DwindleLayout.cpp
+++ b/src/layout/DwindleLayout.cpp
@@ -541,42 +541,24 @@ void CHyprDwindleLayout::recalculateMonitor(const int& monid) {
if (!PMONITOR)
return; // ???
- const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace);
+ g_pHyprRenderer->damageMonitor(PMONITOR);
- if (!PWORKSPACE)
- return;
+ if (PMONITOR->specialWorkspaceID)
+ calculateWorkspace(PMONITOR->specialWorkspaceID);
- g_pHyprRenderer->damageMonitor(PMONITOR);
+ calculateWorkspace(PMONITOR->activeWorkspace);
+}
- if (PMONITOR->specialWorkspaceID) {
- const auto PSPECIALWS = g_pCompositor->getWorkspaceByID(PMONITOR->specialWorkspaceID);
-
- if (PSPECIALWS->m_bHasFullscreenWindow) {
- const auto PFULLWINDOW = g_pCompositor->getFullscreenWindowOnWorkspace(PSPECIALWS->m_iID);
-
- if (PSPECIALWS->m_efFullscreenMode == FULLSCREEN_FULL) {
- PFULLWINDOW->m_vRealPosition = PMONITOR->vecPosition;
- PFULLWINDOW->m_vRealSize = PMONITOR->vecSize;
- } else if (PSPECIALWS->m_efFullscreenMode == FULLSCREEN_MAXIMIZED) {
- SDwindleNodeData fakeNode;
- fakeNode.pWindow = PFULLWINDOW;
- fakeNode.box = {PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft, PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight};
- fakeNode.workspaceID = PSPECIALWS->m_iID;
- PFULLWINDOW->m_vPosition = fakeNode.box.pos();
- PFULLWINDOW->m_vSize = fakeNode.box.size();
- fakeNode.ignoreFullscreenChecks = true;
-
- applyNodeDataToWindow(&fakeNode);
- }
- }
+void CHyprDwindleLayout::calculateWorkspace(const int& ws) {
+ const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(ws);
- const auto TOPNODE = getMasterNodeOnWorkspace(PMONITOR->specialWorkspaceID);
+ if (!PWORKSPACE)
+ return;
- if (TOPNODE && PMONITOR) {
- TOPNODE->box = {PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft, PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight};
- TOPNODE->recalcSizePosRecursive();
- }
- }
+ const auto PMONITOR = g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID);
+
+ if (!PMONITOR)
+ return;
if (PWORKSPACE->m_bHasFullscreenWindow) {
// massive hack from the fullscreen func
@@ -597,12 +579,13 @@ void CHyprDwindleLayout::recalculateMonitor(const int& monid) {
applyNodeDataToWindow(&fakeNode);
}
+ // if has fullscreen, don't calculate the rest
return;
}
- const auto TOPNODE = getMasterNodeOnWorkspace(PMONITOR->activeWorkspace);
+ const auto TOPNODE = getMasterNodeOnWorkspace(ws);
- if (TOPNODE && PMONITOR) {
+ if (TOPNODE) {
TOPNODE->box = {PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft, PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight};
TOPNODE->recalcSizePosRecursive();
}
diff --git a/src/layout/DwindleLayout.hpp b/src/layout/DwindleLayout.hpp
index fc73540a..5ca90fcd 100644
--- a/src/layout/DwindleLayout.hpp
+++ b/src/layout/DwindleLayout.hpp
@@ -78,6 +78,7 @@ class CHyprDwindleLayout : public IHyprLayout {
int getNodesOnWorkspace(const int&);
void applyNodeDataToWindow(SDwindleNodeData*, bool force = false);
+ void calculateWorkspace(const int& ws);
SDwindleNodeData* getNodeFromWindow(CWindow*);
SDwindleNodeData* getFirstNodeOnWorkspace(const int&);
SDwindleNodeData* getClosestNodeOnWorkspace(const int&, const Vector2D&);
@@ -103,4 +104,4 @@ struct std::formatter<SDwindleNodeData*, CharT> : std::formatter<CharT> {
std::format_to(out, ", window: {:x}", node->pWindow);
return std::format_to(out, "]");
}
-}; \ No newline at end of file
+};
diff --git a/src/layout/MasterLayout.cpp b/src/layout/MasterLayout.cpp
index 9e7f8880..7919d50f 100644
--- a/src/layout/MasterLayout.cpp
+++ b/src/layout/MasterLayout.cpp
@@ -287,38 +287,24 @@ void CHyprMasterLayout::recalculateMonitor(const int& monid) {
if (!PMONITOR)
return;
- const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace);
+ g_pHyprRenderer->damageMonitor(PMONITOR);
+
+ if (PMONITOR->specialWorkspaceID)
+ calculateWorkspace(PMONITOR->specialWorkspaceID);
+
+ calculateWorkspace(PMONITOR->activeWorkspace);
+}
+
+void CHyprMasterLayout::calculateWorkspace(const int& ws) {
+ const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(ws);
if (!PWORKSPACE)
return;
- g_pHyprRenderer->damageMonitor(PMONITOR);
+ const auto PMONITOR = g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID);
- if (PMONITOR->specialWorkspaceID) {
- const auto PSPECIALWS = g_pCompositor->getWorkspaceByID(PMONITOR->specialWorkspaceID);
-
- if (PSPECIALWS->m_bHasFullscreenWindow) {
- const auto PFULLWINDOW = g_pCompositor->getFullscreenWindowOnWorkspace(PSPECIALWS->m_iID);
-
- if (PSPECIALWS->m_efFullscreenMode == FULLSCREEN_FULL) {
- PFULLWINDOW->m_vRealPosition = PMONITOR->vecPosition;
- PFULLWINDOW->m_vRealSize = PMONITOR->vecSize;
- } else if (PSPECIALWS->m_efFullscreenMode == FULLSCREEN_MAXIMIZED) {
- SMasterNodeData fakeNode;
- fakeNode.pWindow = PFULLWINDOW;
- fakeNode.position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
- fakeNode.size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
- fakeNode.workspaceID = PSPECIALWS->m_iID;
- PFULLWINDOW->m_vPosition = fakeNode.position;
- PFULLWINDOW->m_vSize = fakeNode.size;
- fakeNode.ignoreFullscreenChecks = true;
-
- applyNodeDataToWindow(&fakeNode);
- }
- }
-
- calculateWorkspace(PMONITOR->specialWorkspaceID);
- }
+ if (!PMONITOR)
+ return;
if (PWORKSPACE->m_bHasFullscreenWindow) {
// massive hack from the fullscreen func
@@ -329,31 +315,22 @@ void CHyprMasterLayout::recalculateMonitor(const int& monid) {
PFULLWINDOW->m_vRealSize = PMONITOR->vecSize;
} else if (PWORKSPACE->m_efFullscreenMode == FULLSCREEN_MAXIMIZED) {
SMasterNodeData fakeNode;
- 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;
+ 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;
+ fakeNode.ignoreFullscreenChecks = true;
applyNodeDataToWindow(&fakeNode);
}
+ // if has fullscreen, don't calculate the rest
return;
}
- // calc the WS
- calculateWorkspace(PWORKSPACE->m_iID);
-}
-
-void CHyprMasterLayout::calculateWorkspace(const int& ws) {
- const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(ws);
-
- if (!PWORKSPACE)
- return;
-
const auto PWORKSPACEDATA = getMasterWorkspaceData(ws);
- const auto PMONITOR = g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID);
const auto PMASTERNODE = getMasterNodeOnWorkspace(PWORKSPACE->m_iID);
if (!PMASTERNODE)