mirror of
https://github.com/hyprwm/Hyprland.git
synced 2024-09-11 13:25:42 +03:00
master: add dispatchers rollnext and rollprev (#4209)
This commit is contained in:
parent
bd952dcef2
commit
7cec618fe4
@ -1332,6 +1332,50 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
|
||||
nd.percMaster = std::clamp(newMfact, 0.05f, 0.95f);
|
||||
}
|
||||
}
|
||||
} else if (command == "rollnext") {
|
||||
const auto PWINDOW = header.pWindow;
|
||||
const auto PNODE = getNodeFromWindow(PWINDOW);
|
||||
|
||||
const auto OLDMASTER = PNODE->isMaster ? PNODE : getMasterNodeOnWorkspace(PNODE->workspaceID);
|
||||
const auto OLDMASTERIT = std::find(m_lMasterNodesData.begin(), m_lMasterNodesData.end(), *OLDMASTER);
|
||||
|
||||
for (auto& nd : m_lMasterNodesData) {
|
||||
if (nd.workspaceID == PNODE->workspaceID && !nd.isMaster) {
|
||||
nd.isMaster = true;
|
||||
const auto NEWMASTERIT = std::find(m_lMasterNodesData.begin(), m_lMasterNodesData.end(), nd);
|
||||
m_lMasterNodesData.splice(OLDMASTERIT, m_lMasterNodesData, NEWMASTERIT);
|
||||
const bool inheritFullscreen = prepareLoseFocus(PWINDOW);
|
||||
switchToWindow(nd.pWindow);
|
||||
prepareNewFocus(nd.pWindow, inheritFullscreen);
|
||||
OLDMASTER->isMaster = false;
|
||||
m_lMasterNodesData.splice(m_lMasterNodesData.end(), m_lMasterNodesData, OLDMASTERIT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
recalculateMonitor(PWINDOW->m_iMonitorID);
|
||||
} else if (command == "rollprev") {
|
||||
const auto PWINDOW = header.pWindow;
|
||||
const auto PNODE = getNodeFromWindow(PWINDOW);
|
||||
|
||||
const auto OLDMASTER = PNODE->isMaster ? PNODE : getMasterNodeOnWorkspace(PNODE->workspaceID);
|
||||
const auto OLDMASTERIT = std::find(m_lMasterNodesData.begin(), m_lMasterNodesData.end(), *OLDMASTER);
|
||||
|
||||
for (auto& nd : m_lMasterNodesData | std::views::reverse) {
|
||||
if (nd.workspaceID == PNODE->workspaceID && !nd.isMaster) {
|
||||
nd.isMaster = true;
|
||||
const auto NEWMASTERIT = std::find(m_lMasterNodesData.begin(), m_lMasterNodesData.end(), nd);
|
||||
m_lMasterNodesData.splice(OLDMASTERIT, m_lMasterNodesData, NEWMASTERIT);
|
||||
const bool inheritFullscreen = prepareLoseFocus(PWINDOW);
|
||||
switchToWindow(nd.pWindow);
|
||||
prepareNewFocus(nd.pWindow, inheritFullscreen);
|
||||
OLDMASTER->isMaster = false;
|
||||
m_lMasterNodesData.splice(m_lMasterNodesData.begin(), m_lMasterNodesData, OLDMASTERIT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
recalculateMonitor(PWINDOW->m_iMonitorID);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user