mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-23 04:29:48 +01:00
master: better cycle
This commit is contained in:
parent
bcd8fe9573
commit
17deeb07ad
1 changed files with 11 additions and 58 deletions
|
@ -258,7 +258,7 @@ void CHyprMasterLayout::calculateWorkspace(const int& ws) {
|
||||||
if (getNodesOnWorkspace(PWORKSPACE->m_iID) < 2 && !centerMasterWindow) {
|
if (getNodesOnWorkspace(PWORKSPACE->m_iID) < 2 && !centerMasterWindow) {
|
||||||
PMASTERNODE->position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition;
|
PMASTERNODE->position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition;
|
||||||
PMASTERNODE->size = Vector2D(PMONITOR->vecSize.x - PMONITOR->vecReservedTopLeft.x - PMONITOR->vecReservedBottomRight.x,
|
PMASTERNODE->size = Vector2D(PMONITOR->vecSize.x - PMONITOR->vecReservedTopLeft.x - PMONITOR->vecReservedBottomRight.x,
|
||||||
PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y);
|
PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y);
|
||||||
applyNodeDataToWindow(PMASTERNODE);
|
applyNodeDataToWindow(PMASTERNODE);
|
||||||
return;
|
return;
|
||||||
} else if (orientation == ORIENTATION_LEFT || orientation == ORIENTATION_RIGHT) {
|
} else if (orientation == ORIENTATION_LEFT || orientation == ORIENTATION_RIGHT) {
|
||||||
|
@ -752,67 +752,20 @@ CWindow* CHyprMasterLayout::getNextWindow(CWindow* pWindow, bool next) {
|
||||||
|
|
||||||
const auto PNODE = getNodeFromWindow(pWindow);
|
const auto PNODE = getNodeFromWindow(pWindow);
|
||||||
|
|
||||||
if (next) {
|
auto nodes = m_lMasterNodesData;
|
||||||
if (PNODE->isMaster) {
|
if (!next)
|
||||||
// focus the first non master
|
std::reverse(nodes.begin(), nodes.end());
|
||||||
for (auto n : m_lMasterNodesData) {
|
|
||||||
if (n.pWindow != pWindow && n.workspaceID == pWindow->m_iWorkspaceID) {
|
|
||||||
return n.pWindow;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// focus next
|
|
||||||
bool reached = false;
|
|
||||||
bool found = false;
|
|
||||||
for (auto n : m_lMasterNodesData) {
|
|
||||||
if (n.pWindow == pWindow) {
|
|
||||||
reached = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (n.workspaceID == pWindow->m_iWorkspaceID && reached) {
|
const auto NODEIT = std::find(nodes.begin(), nodes.end(), *PNODE);
|
||||||
return n.pWindow;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!found) {
|
|
||||||
const auto PMASTER = getMasterNodeOnWorkspace(pWindow->m_iWorkspaceID);
|
|
||||||
|
|
||||||
if (PMASTER)
|
const bool ISMASTER = PNODE->isMaster;
|
||||||
return PMASTER->pWindow;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (PNODE->isMaster) {
|
|
||||||
// focus the last non master
|
|
||||||
for (auto& nd : m_lMasterNodesData | std::views::reverse) {
|
|
||||||
if (nd.pWindow != pWindow && nd.workspaceID == pWindow->m_iWorkspaceID) {
|
|
||||||
return nd.pWindow;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// focus previous
|
|
||||||
bool reached = false;
|
|
||||||
bool found = false;
|
|
||||||
for (auto& nd : m_lMasterNodesData | std::views::reverse) {
|
|
||||||
if (nd.pWindow == pWindow) {
|
|
||||||
reached = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nd.workspaceID == pWindow->m_iWorkspaceID && reached) {
|
auto CANDIDATE = std::find_if(NODEIT, nodes.end(), [&](const auto& other) { return other != *PNODE && ISMASTER == other.isMaster && other.workspaceID == PNODE->workspaceID; });
|
||||||
return nd.pWindow;
|
if (CANDIDATE == nodes.end())
|
||||||
}
|
CANDIDATE =
|
||||||
}
|
std::find_if(nodes.begin(), nodes.end(), [&](const auto& other) { return other != *PNODE && ISMASTER != other.isMaster && other.workspaceID == PNODE->workspaceID; });
|
||||||
if (!found) {
|
|
||||||
const auto PMASTER = getMasterNodeOnWorkspace(pWindow->m_iWorkspaceID);
|
|
||||||
|
|
||||||
if (PMASTER)
|
return CANDIDATE == nodes.end() ? nullptr : CANDIDATE->pWindow;
|
||||||
return PMASTER->pWindow;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CHyprMasterLayout::prepareLoseFocus(CWindow* pWindow) {
|
bool CHyprMasterLayout::prepareLoseFocus(CWindow* pWindow) {
|
||||||
|
|
Loading…
Reference in a new issue