diff options
| author | Kyler Clay <kylerclay@proton.me> | 2026-05-02 16:41:29 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-02 21:41:29 +0100 |
| commit | fe17cea39ed9e001b61035e8edbbf2f12871659b (patch) | |
| tree | 8e9b1c824169d7e7c1bb5b01b5614493d8785126 /src | |
| parent | 5202ab22f53c3298d599dbae0781037a1b1184d7 (diff) | |
layout/master: fix rollprev/rollnext focusing the wrong window (#14209)
* layout/master: fix rollprev/rollnext focusing the wrong window
* tests/master: add tests for rollnext/rollprev focus
Diffstat (limited to 'src')
| -rw-r--r-- | src/layout/algorithm/tiled/master/MasterAlgorithm.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/layout/algorithm/tiled/master/MasterAlgorithm.cpp b/src/layout/algorithm/tiled/master/MasterAlgorithm.cpp index a0ea13c3..c57a3639 100644 --- a/src/layout/algorithm/tiled/master/MasterAlgorithm.cpp +++ b/src/layout/algorithm/tiled/master/MasterAlgorithm.cpp @@ -715,12 +715,15 @@ Config::ErrorResult CMasterAlgorithm::layoutMsg(const std::string_view& sv) { if (!OLDMASTER) return stateErr("no old master"); - auto oldMasterIt = std::ranges::find(m_masterNodesData, OLDMASTER); + auto oldMasterIt = std::ranges::find(m_masterNodesData, OLDMASTER); + + SP<ITarget> newFocus; for (auto& nd : m_masterNodesData) { if (!nd->isMaster) { const auto& newMaster = nd; newMaster->isMaster = true; + newFocus = newMaster->pTarget.lock(); auto newMasterIt = std::ranges::find(m_masterNodesData, newMaster); @@ -729,7 +732,6 @@ Config::ErrorResult CMasterAlgorithm::layoutMsg(const std::string_view& sv) { else if (newMasterIt > oldMasterIt) std::ranges::rotate(oldMasterIt, newMasterIt, std::next(newMasterIt)); - switchToWindow(newMaster->pTarget.lock()); OLDMASTER->isMaster = false; oldMasterIt = std::ranges::find(m_masterNodesData, OLDMASTER); @@ -741,6 +743,8 @@ Config::ErrorResult CMasterAlgorithm::layoutMsg(const std::string_view& sv) { } calculateWorkspace(); + if (newFocus) + switchToWindow(newFocus); } else if (command == "rollprev") { const auto PNODE = getNodeFromWindow(PWINDOW); @@ -751,12 +755,15 @@ Config::ErrorResult CMasterAlgorithm::layoutMsg(const std::string_view& sv) { if (!OLDMASTER) return stateErr("no old master"); - auto oldMasterIt = std::ranges::find(m_masterNodesData, OLDMASTER); + auto oldMasterIt = std::ranges::find(m_masterNodesData, OLDMASTER); + + SP<ITarget> newFocus; for (auto& nd : m_masterNodesData | std::views::reverse) { if (!nd->isMaster) { const auto& newMaster = nd; newMaster->isMaster = true; + newFocus = newMaster->pTarget.lock(); auto newMasterIt = std::ranges::find(m_masterNodesData, newMaster); @@ -765,7 +772,6 @@ Config::ErrorResult CMasterAlgorithm::layoutMsg(const std::string_view& sv) { else if (newMasterIt > oldMasterIt) std::ranges::rotate(oldMasterIt, newMasterIt, std::next(newMasterIt)); - switchToWindow(newMaster->pTarget.lock()); OLDMASTER->isMaster = false; oldMasterIt = std::ranges::find(m_masterNodesData, OLDMASTER); @@ -777,6 +783,8 @@ Config::ErrorResult CMasterAlgorithm::layoutMsg(const std::string_view& sv) { } calculateWorkspace(); + if (newFocus) + switchToWindow(newFocus); } else return Config::configError(std::format("Unknown master layoutmsg: {}", sv), Config::eConfigErrorLevel::ERROR, Config::eConfigErrorCode::INVALID_ARGUMENT); |
