diff options
| author | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2023-03-01 14:06:52 +0000 |
|---|---|---|
| committer | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2023-03-01 14:06:52 +0000 |
| commit | 7c5c7ced9170b5c1e34825735a720372a6c0c110 (patch) | |
| tree | 2171f38bbf4ba295c6bc6b1b7d74b861d1771277 /src/layout/MasterLayout.cpp | |
| parent | 3cef005fec6b5a5dbf843aff06059695c1fb52a4 (diff) | |
Convert reverse iterators to ranges
Diffstat (limited to 'src/layout/MasterLayout.cpp')
| -rw-r--r-- | src/layout/MasterLayout.cpp | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/layout/MasterLayout.cpp b/src/layout/MasterLayout.cpp index aa119864..36169f03 100644 --- a/src/layout/MasterLayout.cpp +++ b/src/layout/MasterLayout.cpp @@ -1,5 +1,6 @@ #include "MasterLayout.hpp" #include "../Compositor.hpp" +#include <ranges> SMasterNodeData* CHyprMasterLayout::getNodeFromWindow(CWindow* pWindow) { for (auto& nd : m_lMasterNodesData) { @@ -175,9 +176,9 @@ void CHyprMasterLayout::onWindowRemovedTiling(CWindow* pWindow) { m_lMasterNodesData.remove(*PNODE); if (getMastersOnWorkspace(WORKSPACEID) == getNodesOnWorkspace(WORKSPACEID) && MASTERSLEFT > 1) { - for (auto it = m_lMasterNodesData.rbegin(); it != m_lMasterNodesData.rend(); it++) { - if (it->workspaceID == WORKSPACEID) { - it->isMaster = false; + for (auto& nd : m_lMasterNodesData | std::views::reverse) { + if (nd.workspaceID == WORKSPACEID) { + nd.isMaster = false; break; } } @@ -781,23 +782,23 @@ CWindow* CHyprMasterLayout::getNextWindow(CWindow* pWindow, bool next) { } else { if (PNODE->isMaster) { // focus the last non master - for (auto it = m_lMasterNodesData.rbegin(); it != m_lMasterNodesData.rend(); it++) { - if (it->pWindow != pWindow && it->workspaceID == pWindow->m_iWorkspaceID) { - return it->pWindow; + 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 it = m_lMasterNodesData.rbegin(); it != m_lMasterNodesData.rend(); it++) { - if (it->pWindow == pWindow) { + for (auto& nd : m_lMasterNodesData | std::views::reverse) { + if (nd.pWindow == pWindow) { reached = true; continue; } - if (it->workspaceID == pWindow->m_iWorkspaceID && reached) { - return it->pWindow; + if (nd.workspaceID == pWindow->m_iWorkspaceID && reached) { + return nd.pWindow; } } if (!found) { @@ -1037,9 +1038,9 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri if (!PNODE || !PNODE->isMaster) { // first non-master node - for (auto it = m_lMasterNodesData.rbegin(); it != m_lMasterNodesData.rend(); it++) { - if (it->workspaceID == header.pWindow->m_iWorkspaceID && it->isMaster) { - it->isMaster = false; + for (auto& nd : m_lMasterNodesData | std::views::reverse) { + if (nd.workspaceID == header.pWindow->m_iWorkspaceID && nd.isMaster) { + nd.isMaster = false; break; } } |
