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 +++++++++------------ 1 file changed, 45 insertions(+), 63 deletions(-) (limited to 'src/layout/algorithm/tiled/dwindle/DwindleAlgorithm.cpp') 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(); -- cgit v1.2.3