From 3284dd729b3529e744a1c0db7d1c3ff1e296f7ea Mon Sep 17 00:00:00 2001 From: Thedudeman <108754421+RockClapps@users.noreply.github.com> Date: Thu, 5 Mar 2026 09:08:40 -0500 Subject: algo/scrolling: add config options for focus and swapcol wrapping (#13518) --- .../tiled/scrolling/ScrollingAlgorithm.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src/layout/algorithm') diff --git a/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp b/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp index afba398f..ae7c6ecc 100644 --- a/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp +++ b/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp @@ -1255,8 +1255,9 @@ std::expected CScrollingAlgorithm::layoutMsg(const std::strin m_scrollingData->recalculate(); } } else if (ARGS[0] == "focus") { - const auto TDATA = dataFor(Desktop::focusState()->window() ? Desktop::focusState()->window()->layoutTarget() : nullptr); - static const auto PNOFALLBACK = CConfigValue("general:no_focus_fallback"); + const auto TDATA = dataFor(Desktop::focusState()->window() ? Desktop::focusState()->window()->layoutTarget() : nullptr); + static const auto PNOFALLBACK = CConfigValue("general:no_focus_fallback"); + static const auto PCONFWRAPFOCUS = CConfigValue("scrolling:wrap_focus"); if (!TDATA || ARGS[1].empty()) return std::unexpected("no window to focus"); @@ -1312,7 +1313,7 @@ std::expected CScrollingAlgorithm::layoutMsg(const std::strin g_pCompositor->warpCursorTo(TDATA->target->window()->middle()); return {}; } else - PREV = m_scrollingData->columns.back(); + PREV = (*PCONFWRAPFOCUS == 1) ? m_scrollingData->columns.back() : m_scrollingData->columns.front(); } auto pTargetData = findBestNeighbor(TDATA, PREV); @@ -1334,7 +1335,7 @@ std::expected CScrollingAlgorithm::layoutMsg(const std::strin g_pCompositor->warpCursorTo(TDATA->target->window()->middle()); return {}; } else - NEXT = m_scrollingData->columns.front(); + NEXT = (*PCONFWRAPFOCUS == 1) ? m_scrollingData->columns.front() : m_scrollingData->columns.back(); } auto pTargetData = findBestNeighbor(TDATA, NEXT); @@ -1361,6 +1362,8 @@ std::expected CScrollingAlgorithm::layoutMsg(const std::strin m_scrollingData->recalculate(); } else if (ARGS[0] == "swapcol") { + static const auto PCONFWRAPSWAPCOL = CConfigValue("scrolling:wrap_swapcol"); + if (ARGS.size() < 2) return std::unexpected("not enough args"); @@ -1386,9 +1389,15 @@ std::expected CScrollingAlgorithm::layoutMsg(const std::strin // wrap around swaps if (direction == "l") - targetIdx = (currentIdx == 0) ? (colCount - 1) : (currentIdx - 1); + if (*PCONFWRAPSWAPCOL == 1) + targetIdx = (currentIdx == 0) ? (colCount - 1) : (currentIdx - 1); + else + targetIdx = (currentIdx == 0) ? 0 : (currentIdx - 1); else if (direction == "r") - targetIdx = (currentIdx == (int64_t)colCount - 1) ? 0 : (currentIdx + 1); + if (*PCONFWRAPSWAPCOL == 1) + targetIdx = (currentIdx == (int64_t)colCount - 1) ? 0 : (currentIdx + 1); + else + targetIdx = (currentIdx == (int64_t)colCount - 1) ? (colCount - 1) : (currentIdx + 1); else return std::unexpected("no target (invalid direction?)"); ; -- cgit v1.2.3