master: fix moving fullscreen workspace and remove duplicate code (#5131)

This commit is contained in:
thejch 2024-03-16 17:15:12 -07:00 committed by GitHub
parent 0e87a08e15
commit 0387528c56
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 39 additions and 78 deletions

View file

@ -541,42 +541,24 @@ void CHyprDwindleLayout::recalculateMonitor(const int& monid) {
if (!PMONITOR) if (!PMONITOR)
return; // ??? return; // ???
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace); g_pHyprRenderer->damageMonitor(PMONITOR);
if (PMONITOR->specialWorkspaceID)
calculateWorkspace(PMONITOR->specialWorkspaceID);
calculateWorkspace(PMONITOR->activeWorkspace);
}
void CHyprDwindleLayout::calculateWorkspace(const int& ws) {
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(ws);
if (!PWORKSPACE) if (!PWORKSPACE)
return; return;
g_pHyprRenderer->damageMonitor(PMONITOR); const auto PMONITOR = g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID);
if (PMONITOR->specialWorkspaceID) { if (!PMONITOR)
const auto PSPECIALWS = g_pCompositor->getWorkspaceByID(PMONITOR->specialWorkspaceID); return;
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);
}
}
const auto TOPNODE = getMasterNodeOnWorkspace(PMONITOR->specialWorkspaceID);
if (TOPNODE && PMONITOR) {
TOPNODE->box = {PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft, PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight};
TOPNODE->recalcSizePosRecursive();
}
}
if (PWORKSPACE->m_bHasFullscreenWindow) { if (PWORKSPACE->m_bHasFullscreenWindow) {
// massive hack from the fullscreen func // massive hack from the fullscreen func
@ -597,12 +579,13 @@ void CHyprDwindleLayout::recalculateMonitor(const int& monid) {
applyNodeDataToWindow(&fakeNode); applyNodeDataToWindow(&fakeNode);
} }
// if has fullscreen, don't calculate the rest
return; 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->box = {PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft, PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight};
TOPNODE->recalcSizePosRecursive(); TOPNODE->recalcSizePosRecursive();
} }

View file

@ -78,6 +78,7 @@ class CHyprDwindleLayout : public IHyprLayout {
int getNodesOnWorkspace(const int&); int getNodesOnWorkspace(const int&);
void applyNodeDataToWindow(SDwindleNodeData*, bool force = false); void applyNodeDataToWindow(SDwindleNodeData*, bool force = false);
void calculateWorkspace(const int& ws);
SDwindleNodeData* getNodeFromWindow(CWindow*); SDwindleNodeData* getNodeFromWindow(CWindow*);
SDwindleNodeData* getFirstNodeOnWorkspace(const int&); SDwindleNodeData* getFirstNodeOnWorkspace(const int&);
SDwindleNodeData* getClosestNodeOnWorkspace(const int&, const Vector2D&); SDwindleNodeData* getClosestNodeOnWorkspace(const int&, const Vector2D&);

View file

@ -287,38 +287,24 @@ void CHyprMasterLayout::recalculateMonitor(const int& monid) {
if (!PMONITOR) if (!PMONITOR)
return; 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) if (!PWORKSPACE)
return; return;
g_pHyprRenderer->damageMonitor(PMONITOR); const auto PMONITOR = g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID);
if (PMONITOR->specialWorkspaceID) { if (!PMONITOR)
const auto PSPECIALWS = g_pCompositor->getWorkspaceByID(PMONITOR->specialWorkspaceID); return;
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 (PWORKSPACE->m_bHasFullscreenWindow) { if (PWORKSPACE->m_bHasFullscreenWindow) {
// massive hack from the fullscreen func // massive hack from the fullscreen func
@ -335,25 +321,16 @@ void CHyprMasterLayout::recalculateMonitor(const int& monid) {
fakeNode.workspaceID = PWORKSPACE->m_iID; fakeNode.workspaceID = PWORKSPACE->m_iID;
PFULLWINDOW->m_vPosition = fakeNode.position; PFULLWINDOW->m_vPosition = fakeNode.position;
PFULLWINDOW->m_vSize = fakeNode.size; PFULLWINDOW->m_vSize = fakeNode.size;
fakeNode.ignoreFullscreenChecks = true;
applyNodeDataToWindow(&fakeNode); applyNodeDataToWindow(&fakeNode);
} }
// if has fullscreen, don't calculate the rest
return; 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 PWORKSPACEDATA = getMasterWorkspaceData(ws);
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID);
const auto PMASTERNODE = getMasterNodeOnWorkspace(PWORKSPACE->m_iID); const auto PMASTERNODE = getMasterNodeOnWorkspace(PWORKSPACE->m_iID);
if (!PMASTERNODE) if (!PMASTERNODE)