From 5ba33f846129f3e6c0505b19f94634b24505e828 Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Sun, 26 Apr 2026 15:16:36 +0100 Subject: config/lua: init lua config manager, use lua if available (#13817) Adds a new lua config manager, which will automatically be used if there is a lua config present. --- .../algorithm/tiled/dwindle/DwindleAlgorithm.cpp | 108 +++++++++------------ .../algorithm/tiled/dwindle/DwindleAlgorithm.hpp | 23 ++++- .../algorithm/tiled/master/MasterAlgorithm.cpp | 56 ++++------- .../algorithm/tiled/master/MasterAlgorithm.hpp | 18 +++- .../algorithm/tiled/monocle/MonocleAlgorithm.cpp | 2 +- .../tiled/scrolling/ScrollingAlgorithm.cpp | 44 ++++----- .../tiled/scrolling/ScrollingAlgorithm.hpp | 2 +- 7 files changed, 125 insertions(+), 128 deletions(-) (limited to 'src/layout/algorithm/tiled') diff --git a/src/layout/algorithm/tiled/dwindle/DwindleAlgorithm.cpp b/src/layout/algorithm/tiled/dwindle/DwindleAlgorithm.cpp index baf767be..32035de0 100644 --- a/src/layout/algorithm/tiled/dwindle/DwindleAlgorithm.cpp +++ b/src/layout/algorithm/tiled/dwindle/DwindleAlgorithm.cpp @@ -18,58 +18,40 @@ using namespace Layout::Tiled; using namespace Hyprutils::String; -struct Layout::Tiled::SDwindleNodeData { - WP pParent; - bool isNode = false; - WP pTarget; - std::array, 2> children = {}; - WP self; - bool splitTop = false; // for preserve_split - CBox box = {0}; - float splitRatio = 1.f; - bool valid = true; - bool ignoreFullscreenChecks = false; - - // For list lookup - bool operator==(const SDwindleNodeData& rhs) const { - return pTarget.lock() == rhs.pTarget.lock() && box == rhs.box && pParent == rhs.pParent && children[0] == rhs.children[0] && children[1] == rhs.children[1]; - } - - void recalcSizePosRecursive(bool force = false, bool horizontalOverride = false, bool verticalOverride = false) { - if (children[0]) { - static auto PSMARTSPLIT = CConfigValue("dwindle:smart_split"); - static auto PPRESERVESPLIT = CConfigValue("dwindle:preserve_split"); - static auto PFLMULT = CConfigValue("dwindle:split_width_multiplier"); - static auto PPRECISEMOUSEMOVE = CConfigValue("dwindle:precise_mouse_move"); - - if (*PPRESERVESPLIT == 0 && *PSMARTSPLIT == 0 && *PPRECISEMOUSEMOVE == 0) - splitTop = box.h * *PFLMULT > box.w; - - if (verticalOverride) - splitTop = true; - else if (horizontalOverride) - splitTop = false; - - const auto SPLITSIDE = !splitTop; - - if (SPLITSIDE) { - // split left/right - const float FIRSTSIZE = box.w / 2.0 * splitRatio; - children[0]->box = CBox{box.x, box.y, FIRSTSIZE, box.h}.noNegativeSize(); - children[1]->box = CBox{box.x + FIRSTSIZE, box.y, box.w - FIRSTSIZE, box.h}.noNegativeSize(); - } else { - // split top/bottom - const float FIRSTSIZE = box.h / 2.0 * splitRatio; - children[0]->box = CBox{box.x, box.y, box.w, FIRSTSIZE}.noNegativeSize(); - children[1]->box = CBox{box.x, box.y + FIRSTSIZE, box.w, box.h - FIRSTSIZE}.noNegativeSize(); - } +void SDwindleNodeData::recalcSizePosRecursive(bool force, bool horizontalOverride, bool verticalOverride) { + if (children[0]) { + static auto PSMARTSPLIT = CConfigValue("dwindle:smart_split"); + static auto PPRESERVESPLIT = CConfigValue("dwindle:preserve_split"); + static auto PFLMULT = CConfigValue("dwindle:split_width_multiplier"); + static auto PPRECISEMOUSEMOVE = CConfigValue("dwindle:precise_mouse_move"); + + if (*PPRESERVESPLIT == 0 && *PSMARTSPLIT == 0 && *PPRECISEMOUSEMOVE == 0) + splitTop = box.h * *PFLMULT > box.w; + + if (verticalOverride) + splitTop = true; + else if (horizontalOverride) + splitTop = false; + + const auto SPLITSIDE = !splitTop; + + if (SPLITSIDE) { + // split left/right + const float FIRSTSIZE = box.w / 2.0 * splitRatio; + children[0]->box = CBox{box.x, box.y, FIRSTSIZE, box.h}.noNegativeSize(); + children[1]->box = CBox{box.x + FIRSTSIZE, box.y, box.w - FIRSTSIZE, box.h}.noNegativeSize(); + } else { + // split top/bottom + const float FIRSTSIZE = box.h / 2.0 * splitRatio; + children[0]->box = CBox{box.x, box.y, box.w, FIRSTSIZE}.noNegativeSize(); + children[1]->box = CBox{box.x, box.y + FIRSTSIZE, box.w, box.h - FIRSTSIZE}.noNegativeSize(); + } - children[0]->recalcSizePosRecursive(force); - children[1]->recalcSizePosRecursive(force); - } else - pTarget->setPositionGlobal(box); - } -}; + children[0]->recalcSizePosRecursive(force); + children[1]->recalcSizePosRecursive(force); + } else + pTarget->setPositionGlobal(box); +} void CDwindleAlgorithm::newTarget(SP target) { addTarget(target); @@ -84,8 +66,8 @@ void CDwindleAlgorithm::addTarget(SP target) { const auto PMONITOR = m_parent->space()->workspace()->m_monitor; const auto PWORKSPACE = m_parent->space()->workspace(); - static auto PUSEACTIVE = CConfigValue("dwindle:use_active_for_splits"); - static auto PDEFAULTSPLIT = CConfigValue("dwindle:default_split_ratio"); + static auto PUSEACTIVE = CConfigValue("dwindle:use_active_for_splits"); + static auto PDEFAULTSPLIT = CConfigValue("dwindle:default_split_ratio"); // Populate the node with our window's data PNODE->pTarget = target; @@ -154,17 +136,17 @@ void CDwindleAlgorithm::addTarget(SP target) { NEWPARENT->isNode = true; // it is a node NEWPARENT->splitRatio = std::clamp(*PDEFAULTSPLIT, 0.1F, 1.9F); - static auto PWIDTHMULTIPLIER = CConfigValue("dwindle:split_width_multiplier"); + static auto PWIDTHMULTIPLIER = CConfigValue("dwindle:split_width_multiplier"); // if cursor over first child, make it first, etc const auto SIDEBYSIDE = NEWPARENT->box.w > NEWPARENT->box.h * *PWIDTHMULTIPLIER; NEWPARENT->splitTop = !SIDEBYSIDE; - static auto PFORCESPLIT = CConfigValue("dwindle:force_split"); - static auto PERMANENTDIRECTIONOVERRIDE = CConfigValue("dwindle:permanent_direction_override"); - static auto PSMARTSPLIT = CConfigValue("dwindle:smart_split"); - static auto PSPLITBIAS = CConfigValue("dwindle:split_bias"); - static auto PPRECISEMOUSEMOVE = CConfigValue("dwindle:precise_mouse_move"); + static auto PFORCESPLIT = CConfigValue("dwindle:force_split"); + static auto PERMANENTDIRECTIONOVERRIDE = CConfigValue("dwindle:permanent_direction_override"); + static auto PSMARTSPLIT = CConfigValue("dwindle:smart_split"); + static auto PSPLITBIAS = CConfigValue("dwindle:split_bias"); + static auto PPRECISEMOUSEMOVE = CConfigValue("dwindle:precise_mouse_move"); bool horizontalOverride = false; bool verticalOverride = false; @@ -324,8 +306,8 @@ void CDwindleAlgorithm::resizeTarget(const Vector2D& Δ, SP target, eRe if (!PNODE) return; - static auto PANIMATE = CConfigValue("misc:animate_manual_resizes"); - static auto PSMARTRESIZING = CConfigValue("dwindle:smart_resizing"); + static auto PANIMATE = CConfigValue("misc:animate_manual_resizes"); + static auto PSMARTRESIZING = CConfigValue("dwindle:smart_resizing"); // get some data about our window const auto PMONITOR = m_parent->space()->workspace()->m_monitor; @@ -533,7 +515,7 @@ std::optional CDwindleAlgorithm::predictSizeForNewTarget() { CBox box = PNODE->box; - static auto PFLMULT = CConfigValue("dwindle:split_width_multiplier"); + static auto PFLMULT = CConfigValue("dwindle:split_width_multiplier"); bool splitTop = box.h * *PFLMULT > box.w; @@ -553,7 +535,7 @@ std::optional CDwindleAlgorithm::predictSizeForNewTarget() { } void CDwindleAlgorithm::moveTargetInDirection(SP t, Math::eDirection dir, bool silent) { - static auto PMONITORFALLBACK = CConfigValue("binds:window_direction_monitor_fallback"); + static auto PMONITORFALLBACK = CConfigValue("binds:window_direction_monitor_fallback"); const auto PNODE = getNodeFromTarget(t); const Vector2D originalPos = t->position().middle(); diff --git a/src/layout/algorithm/tiled/dwindle/DwindleAlgorithm.hpp b/src/layout/algorithm/tiled/dwindle/DwindleAlgorithm.hpp index 043f8738..9216e843 100644 --- a/src/layout/algorithm/tiled/dwindle/DwindleAlgorithm.hpp +++ b/src/layout/algorithm/tiled/dwindle/DwindleAlgorithm.hpp @@ -5,7 +5,25 @@ namespace Layout { } namespace Layout::Tiled { - struct SDwindleNodeData; + struct SDwindleNodeData { + WP pParent; + bool isNode = false; + WP pTarget; + std::array, 2> children = {}; + WP self; + bool splitTop = false; // for preserve_split + CBox box = {0}; + float splitRatio = 1.f; + bool valid = true; + bool ignoreFullscreenChecks = false; + + // For list lookup + bool operator==(const SDwindleNodeData& rhs) const { + return pTarget.lock() == rhs.pTarget.lock() && box == rhs.box && pParent == rhs.pParent && children[0] == rhs.children[0] && children[1] == rhs.children[1]; + } + + void recalcSizePosRecursive(bool force = false, bool horizontalOverride = false, bool verticalOverride = false); + }; class CDwindleAlgorithm : public ITiledAlgorithm { public: @@ -27,6 +45,8 @@ namespace Layout::Tiled { virtual void swapTargets(SP a, SP b); virtual void moveTargetInDirection(SP t, Math::eDirection dir, bool silent); + SP getNodeFromWindow(PHLWINDOW w); + private: std::vector> m_dwindleNodesData; @@ -42,7 +62,6 @@ namespace Layout::Tiled { void addTarget(SP target); void calculateWorkspace(); SP getNodeFromTarget(SP); - SP getNodeFromWindow(PHLWINDOW w); int getNodes(); SP getFirstNode(); SP getClosestNode(const Vector2D&, SP skip = nullptr); diff --git a/src/layout/algorithm/tiled/master/MasterAlgorithm.cpp b/src/layout/algorithm/tiled/master/MasterAlgorithm.cpp index 7017deb1..11a59a5f 100644 --- a/src/layout/algorithm/tiled/master/MasterAlgorithm.cpp +++ b/src/layout/algorithm/tiled/master/MasterAlgorithm.cpp @@ -5,6 +5,7 @@ #include "../../../target/WindowTarget.hpp" #include "../../../../config/ConfigValue.hpp" +#include "../../../../config/shared/actions/ConfigActions.hpp" #include "../../../../config/shared/workspace/WorkspaceRuleManager.hpp" #include "../../../../desktop/state/FocusState.hpp" #include "../../../../helpers/Monitor.hpp" @@ -18,25 +19,6 @@ using namespace Layout; using namespace Layout::Tiled; using namespace Hyprutils::String; -struct Layout::Tiled::SMasterNodeData { - bool isMaster = false; - float percMaster = 0.5f; - - WP pTarget; - - Vector2D position; - Vector2D size; - - float percSize = 1.f; // size multiplier for resizing children - - bool ignoreFullscreenChecks = false; - - // - bool operator==(const SMasterNodeData& rhs) const { - return pTarget.lock() == rhs.pTarget.lock(); - } -}; - void CMasterAlgorithm::newTarget(SP target) { addTarget(target, true); } @@ -47,7 +29,7 @@ void CMasterAlgorithm::movedTarget(SP target, std::optional f void CMasterAlgorithm::addTarget(SP target, bool firstMap) { static auto PNEWONACTIVE = CConfigValue("master:new_on_active"); - static auto PNEWONTOP = CConfigValue("master:new_on_top"); + static auto PNEWONTOP = CConfigValue("master:new_on_top"); static auto PNEWSTATUS = CConfigValue("master:new_status"); const auto PWORKSPACE = m_parent->space()->workspace(); @@ -79,7 +61,7 @@ void CMasterAlgorithm::addTarget(SP target, bool firstMap) { PNODE->pTarget = target; const auto WINDOWSONWORKSPACE = getNodesNo(); - static auto PMFACT = CConfigValue("master:mfact"); + static auto PMFACT = CConfigValue("master:mfact"); float lastSplitPercent = *PMFACT; auto OPENINGON = isWindowTiled(Desktop::focusState()->window()) && Desktop::focusState()->window()->m_workspace == PWORKSPACE ? @@ -87,7 +69,7 @@ void CMasterAlgorithm::addTarget(SP target, bool firstMap) { getMasterNode(); const auto MOUSECOORDS = g_pInputManager->getMouseCoordsInternal(); - static auto PDROPATCURSOR = CConfigValue("master:drop_at_cursor"); + static auto PDROPATCURSOR = CConfigValue("master:drop_at_cursor"); eOrientation orientation = getDynamicOrientation(); const auto NODEIT = std::ranges::find(m_masterNodesData, PNODE); @@ -97,7 +79,7 @@ void CMasterAlgorithm::addTarget(SP target, bool firstMap) { if (WINDOWSONWORKSPACE > 2) { auto& v = m_masterNodesData; - const std::size_t srcIndex = static_cast(std::distance(v.begin(), NODEIT)); + const std::size_t srcIndex = sc(std::distance(v.begin(), NODEIT)); for (std::size_t i = 0; i < v.size(); ++i) { const CBox box = v[i]->pTarget->position(); @@ -131,8 +113,8 @@ void CMasterAlgorithm::addTarget(SP target, bool firstMap) { break; auto node = std::move(v[srcIndex]); - v.erase(v.begin() + static_cast(srcIndex)); - v.insert(v.begin() + static_cast(insertIndex), std::move(node)); + v.erase(v.begin() + sc(srcIndex)); + v.insert(v.begin() + sc(insertIndex), std::move(node)); break; } @@ -222,7 +204,7 @@ void CMasterAlgorithm::addTarget(SP target, bool firstMap) { void CMasterAlgorithm::removeTarget(SP target) { const auto MASTERSLEFT = getMastersNo(); - static auto SMALLSPLIT = CConfigValue("master:allow_small_split"); + static auto SMALLSPLIT = CConfigValue("master:allow_small_split"); const auto PNODE = getNodeFromTarget(target); @@ -269,8 +251,8 @@ void CMasterAlgorithm::resizeTarget(const Vector2D& Δ, SP target, eRec return; const auto PMONITOR = m_parent->space()->workspace()->m_monitor; - static auto SLAVECOUNTFORCENTER = CConfigValue("master:slave_count_for_center_master"); - static auto PSMARTRESIZING = CConfigValue("master:smart_resizing"); + static auto SLAVECOUNTFORCENTER = CConfigValue("master:slave_count_for_center_master"); + static auto PSMARTRESIZING = CConfigValue("master:smart_resizing"); const auto WORKAREA = PMONITOR->logicalBoxMinusReserved(); const bool DISPLAYBOTTOM = STICKS(PNODE->position.y + PNODE->size.y, WORKAREA.y + WORKAREA.h); @@ -405,7 +387,7 @@ void CMasterAlgorithm::swapTargets(SP a, SP b) { } void CMasterAlgorithm::moveTargetInDirection(SP t, Math::eDirection dir, bool silent) { - static auto PMONITORFALLBACK = CConfigValue("binds:window_direction_monitor_fallback"); + static auto PMONITORFALLBACK = CConfigValue("binds:window_direction_monitor_fallback"); const auto PWINDOW2 = g_pCompositor->getWindowInDirection(t->window(), dir); @@ -576,7 +558,7 @@ std::expected CMasterAlgorithm::layoutMsg(const std::string_v return std::unexpected("no window"); if (PWINDOW->layoutTarget()->floating()) { - g_pKeybindManager->m_dispatchers["swapnext"](""); + Config::Actions::swapNext(true); return {}; } @@ -593,7 +575,7 @@ std::expected CMasterAlgorithm::layoutMsg(const std::string_v return std::unexpected("no window"); if (PWINDOW->layoutTarget()->floating()) { - g_pKeybindManager->m_dispatchers["swapnext"]("prev"); + Config::Actions::swapNext(false); return {}; } @@ -616,7 +598,7 @@ std::expected CMasterAlgorithm::layoutMsg(const std::string_v const auto WINDOWS = getNodesNo(); const auto MASTERS = getMastersNo(); - static auto SMALLSPLIT = CConfigValue("master:allow_small_split"); + static auto SMALLSPLIT = CConfigValue("master:allow_small_split"); if (MASTERS + 2 > WINDOWS && *SMALLSPLIT == 0) return std::unexpected("nothing to do"); @@ -916,7 +898,7 @@ SP CMasterAlgorithm::getNodeFromWindow(PHLWINDOW x) { return x ? getNodeFromTarget(x->layoutTarget()) : nullptr; } -SP CMasterAlgorithm::getNodeFromTarget(SP x) { +SP CMasterAlgorithm::getNodeFromTarget(SP x) const { for (const auto& n : m_masterNodesData) { if (n->pTarget == x) return n; @@ -953,10 +935,10 @@ void CMasterAlgorithm::calculateWorkspace() { eOrientation orientation = getDynamicOrientation(); bool centerMasterWindow = false; - static auto SLAVECOUNTFORCENTER = CConfigValue("master:slave_count_for_center_master"); + static auto SLAVECOUNTFORCENTER = CConfigValue("master:slave_count_for_center_master"); static auto CMFALLBACK = CConfigValue("master:center_master_fallback"); - static auto PIGNORERESERVED = CConfigValue("master:center_ignores_reserved"); - static auto PSMARTRESIZING = CConfigValue("master:smart_resizing"); + static auto PIGNORERESERVED = CConfigValue("master:center_ignores_reserved"); + static auto PSMARTRESIZING = CConfigValue("master:smart_resizing"); const auto MASTERS = getMastersNo(); const auto WINDOWS = getNodesNo(); @@ -1003,7 +985,7 @@ void CMasterAlgorithm::calculateWorkspace() { // compute placement of master window(s) if (WINDOWS == 1 && !centerMasterWindow) { - static auto PALWAYSKEEPPOSITION = CConfigValue("master:always_keep_position"); + static auto PALWAYSKEEPPOSITION = CConfigValue("master:always_keep_position"); if (*PALWAYSKEEPPOSITION) { const float WIDTH = WORKAREA.w * PMASTERNODE->percMaster; float nextX = 0; diff --git a/src/layout/algorithm/tiled/master/MasterAlgorithm.hpp b/src/layout/algorithm/tiled/master/MasterAlgorithm.hpp index 5cfa6b36..44c61369 100644 --- a/src/layout/algorithm/tiled/master/MasterAlgorithm.hpp +++ b/src/layout/algorithm/tiled/master/MasterAlgorithm.hpp @@ -7,7 +7,20 @@ namespace Layout { } namespace Layout::Tiled { - struct SMasterNodeData; + + struct SMasterNodeData { + bool isMaster = false; + float percMaster = 0.5f; + WP pTarget; + Vector2D position; + Vector2D size; + float percSize = 1.f; + bool ignoreFullscreenChecks = false; + + bool operator==(const SMasterNodeData& rhs) const { + return pTarget.lock() == rhs.pTarget.lock(); + } + }; //orientation determines which side of the screen the master area resides enum eOrientation : uint8_t { @@ -50,6 +63,8 @@ namespace Layout::Tiled { virtual void swapTargets(SP a, SP b); virtual void moveTargetInDirection(SP t, Math::eDirection dir, bool silent); + SP getNodeFromTarget(SP) const; + private: std::vector> m_masterNodesData; SMasterWorkspaceData m_workspaceData; @@ -64,7 +79,6 @@ namespace Layout::Tiled { eOrientation getDynamicOrientation(); int getNodesNo(); SP getNodeFromWindow(PHLWINDOW); - SP getNodeFromTarget(SP); SP getMasterNode(); SP getClosestNode(const Vector2D&); void calculateWorkspace(); diff --git a/src/layout/algorithm/tiled/monocle/MonocleAlgorithm.cpp b/src/layout/algorithm/tiled/monocle/MonocleAlgorithm.cpp index e1b4c608..29810fb2 100644 --- a/src/layout/algorithm/tiled/monocle/MonocleAlgorithm.cpp +++ b/src/layout/algorithm/tiled/monocle/MonocleAlgorithm.cpp @@ -202,7 +202,7 @@ void CMonocleAlgorithm::swapTargets(SP a, SP b) { } void CMonocleAlgorithm::moveTargetInDirection(SP t, Math::eDirection dir, bool silent) { - static auto PMONITORFALLBACK = CConfigValue("binds:window_direction_monitor_fallback"); + static auto PMONITORFALLBACK = CConfigValue("binds:window_direction_monitor_fallback"); if (!*PMONITORFALLBACK) return; // noop diff --git a/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp b/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp index 83ab0974..3322d466 100644 --- a/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp +++ b/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp @@ -378,7 +378,7 @@ void SScrollingData::centerCol(SP c) { if (!c) return; - static const auto PFSONONE = CConfigValue("scrolling:fullscreen_on_one_column"); + static const auto PFSONONE = CConfigValue("scrolling:fullscreen_on_one_column"); const auto USABLE = algorithm->usableArea(); int64_t colIdx = idx(c); @@ -390,7 +390,7 @@ void SScrollingData::fitCol(SP c) { if (!c) return; - static const auto PFSONONE = CConfigValue("scrolling:fullscreen_on_one_column"); + static const auto PFSONONE = CConfigValue("scrolling:fullscreen_on_one_column"); const auto USABLE = algorithm->usableArea(); int64_t colIdx = idx(c); @@ -402,7 +402,7 @@ void SScrollingData::centerOrFitCol(SP c) { if (!c) return; - static const auto PFITMETHOD = CConfigValue("scrolling:focus_fit_method"); + static const auto PFITMETHOD = CConfigValue("scrolling:focus_fit_method"); if (*PFITMETHOD == 1) fitCol(c); @@ -411,7 +411,7 @@ void SScrollingData::centerOrFitCol(SP c) { } SP SScrollingData::atCenter() { - static const auto PFSONONE = CConfigValue("scrolling:fullscreen_on_one_column"); + static const auto PFSONONE = CConfigValue("scrolling:fullscreen_on_one_column"); const auto USABLE = algorithm->usableArea(); size_t centerIdx = controller->getStripAtCenter(USABLE, *PFSONONE); @@ -427,7 +427,7 @@ void SScrollingData::recalculate(bool forceInstant) { algorithm->m_parent->space()->workspace()->m_hasFullscreenWindow) return; - static const auto PFSONONE = CConfigValue("scrolling:fullscreen_on_one_column"); + static const auto PFSONONE = CConfigValue("scrolling:fullscreen_on_one_column"); const CBox USABLE = algorithm->usableArea(); const auto WORKAREA = algorithm->m_parent->space()->workArea(); @@ -451,14 +451,14 @@ void SScrollingData::recalculate(bool forceInstant) { } double SScrollingData::maxWidth() { - static const auto PFSONONE = CConfigValue("scrolling:fullscreen_on_one_column"); + static const auto PFSONONE = CConfigValue("scrolling:fullscreen_on_one_column"); const auto USABLE = algorithm->usableArea(); return controller->calculateMaxExtent(USABLE, *PFSONONE); } bool SScrollingData::visible(SP c, bool full) { - static const auto PFSONONE = CConfigValue("scrolling:fullscreen_on_one_column"); + static const auto PFSONONE = CConfigValue("scrolling:fullscreen_on_one_column"); const auto USABLE = algorithm->usableArea(); int64_t colIdx = idx(c); @@ -469,8 +469,8 @@ bool SScrollingData::visible(SP c, bool full) { } CScrollingAlgorithm::CScrollingAlgorithm() { - static const auto PCONFWIDTHS = CConfigValue("scrolling:explicit_column_widths"); - static const auto PCONFDIRECTION = CConfigValue("scrolling:direction"); + static const auto PCONFWIDTHS = CConfigValue("scrolling:explicit_column_widths"); + static const auto PCONFDIRECTION = CConfigValue("scrolling:direction"); m_scrollingData = makeShared(this); m_scrollingData->self = m_scrollingData; @@ -503,7 +503,7 @@ CScrollingAlgorithm::CScrollingAlgorithm() { }; m_configCallback = Event::bus()->m_events.config.reloaded.listen([this, parseColumnWidths, parseDirection] { - static const auto PCONFDIRECTION = CConfigValue("scrolling:direction"); + static const auto PCONFDIRECTION = CConfigValue("scrolling:direction"); m_config.configuredWidths.clear(); m_config.configuredWidths = parseColumnWidths(*PCONFWIDTHS); @@ -513,7 +513,7 @@ CScrollingAlgorithm::CScrollingAlgorithm() { }); m_mouseButtonCallback = Event::bus()->m_events.input.mouse.button.listen([this](IPointer::SButtonEvent e, Event::SCallbackInfo&) { - static const auto PFOLLOW_FOCUS = CConfigValue("scrolling:follow_focus"); + static const auto PFOLLOW_FOCUS = CConfigValue("scrolling:follow_focus"); if (*PFOLLOW_FOCUS && e.state == WL_POINTER_BUTTON_STATE_RELEASED && Desktop::focusState()->window()) focusOnInput(Desktop::focusState()->window()->layoutTarget(), INPUT_MODE_CLICK); @@ -523,7 +523,7 @@ CScrollingAlgorithm::CScrollingAlgorithm() { if (!pWindow) return; - static const auto PFOLLOW_FOCUS = CConfigValue("scrolling:follow_focus"); + static const auto PFOLLOW_FOCUS = CConfigValue("scrolling:follow_focus"); if (!*PFOLLOW_FOCUS && !Desktop::isHardInputFocusReason(reason)) return; @@ -549,7 +549,7 @@ CScrollingAlgorithm::~CScrollingAlgorithm() { } void CScrollingAlgorithm::focusOnInput(SP target, eInputMode input) { - static const auto PFOLLOW_FOCUS_MIN_PERC = CConfigValue("scrolling:follow_min_visible"); + static const auto PFOLLOW_FOCUS_MIN_PERC = CConfigValue("scrolling:follow_min_visible"); if (!target || target->space() != m_parent->space()) return; @@ -579,7 +579,7 @@ void CScrollingAlgorithm::focusOnInput(SP target, eInputMode input) { if (m_scrollingData->visible(TARGETDATA->column.lock(), true) && input != INPUT_MODE_KB) return; - static const auto PFITMETHOD = CConfigValue("scrolling:focus_fit_method"); + static const auto PFITMETHOD = CConfigValue("scrolling:focus_fit_method"); if (*PFITMETHOD == 1) m_scrollingData->fitCol(TARGETDATA->column.lock()); else @@ -671,7 +671,7 @@ void CScrollingAlgorithm::resizeTarget(const Vector2D& delta, SP target if (!DATA->column || !DATA->column->scrollingData) return; - static const auto PFSONONE = CConfigValue("scrolling:fullscreen_on_one_column"); + static const auto PFSONONE = CConfigValue("scrolling:fullscreen_on_one_column"); const auto ADJUSTED_DELTA = m_scrollingData->controller->isPrimaryHorizontal() ? delta : Vector2D{delta.y, delta.x}; const auto USABLE = usableArea(); @@ -859,7 +859,7 @@ void CScrollingAlgorithm::moveTargetInDirection(SP t, Math::eDirection } void CScrollingAlgorithm::moveTargetTo(SP t, Math::eDirection dir, bool silent) { - static auto PMONITORFALLBACK = CConfigValue("binds:window_direction_monitor_fallback"); + static auto PMONITORFALLBACK = CConfigValue("binds:window_direction_monitor_fallback"); const auto DATA = dataFor(t); @@ -986,7 +986,7 @@ void CScrollingAlgorithm::moveTargetTo(SP t, Math::eDirection dir, bool std::expected CScrollingAlgorithm::layoutMsg(const std::string_view& sv) { auto centerOrFit = [this](const SP COL) -> void { - static const auto PFITMETHOD = CConfigValue("scrolling:focus_fit_method"); + static const auto PFITMETHOD = CConfigValue("scrolling:focus_fit_method"); if (*PFITMETHOD == 1) m_scrollingData->fitCol(COL); else @@ -1267,8 +1267,8 @@ std::expected CScrollingAlgorithm::layoutMsg(const std::strin } } 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"); - static const auto PCONFWRAPFOCUS = CConfigValue("scrolling:wrap_focus"); + 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"); @@ -1429,7 +1429,7 @@ std::expected CScrollingAlgorithm::layoutMsg(const std::strin m_scrollingData->recalculate(); } else if (ARGS[0] == "swapcol") { - static const auto PCONFWRAPSWAPCOL = CConfigValue("scrolling:wrap_swapcol"); + static const auto PCONFWRAPSWAPCOL = CConfigValue("scrolling:wrap_swapcol"); if (ARGS.size() < 2) return std::unexpected("not enough args"); @@ -1561,7 +1561,7 @@ eScrollDirection CScrollingAlgorithm::getDynamicDirection() { if (WORKSPACERULE && WORKSPACERULE->m_layoutopts.contains("direction")) directionString = WORKSPACERULE->m_layoutopts.at("direction"); - static const auto PCONFDIRECTION = CConfigValue("scrolling:direction"); + static const auto PCONFDIRECTION = CConfigValue("scrolling:direction"); std::string configDirection = *PCONFDIRECTION; // Workspace rule overrides global config @@ -1600,6 +1600,6 @@ CBox CScrollingAlgorithm::usableArea() { } float CScrollingAlgorithm::defaultColumnWidth() { - static const auto PCOLWIDTH = CConfigValue("scrolling:column_width"); + static const auto PCOLWIDTH = CConfigValue("scrolling:column_width"); return std::clamp(*PCOLWIDTH, MIN_COLUMN_WIDTH, MAX_COLUMN_WIDTH); } diff --git a/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.hpp b/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.hpp index 1b2b1d1e..2f6a5ce6 100644 --- a/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.hpp +++ b/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.hpp @@ -110,6 +110,7 @@ namespace Layout::Tiled { virtual void moveTargetInDirection(SP t, Math::eDirection dir, bool silent); CBox usableArea(); + SP dataFor(SP t); enum eInputMode : uint8_t { INPUT_MODE_SOFT = 0, @@ -131,7 +132,6 @@ namespace Layout::Tiled { eScrollDirection getDynamicDirection(); SP findBestNeighbor(SP pCurrent, SP pTargetCol); - SP dataFor(SP t); SP closestNode(const Vector2D& posGlobglobgabgalab); void focusTargetUpdate(SP target); -- cgit v1.2.3