diff options
| author | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2026-04-26 15:16:36 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-26 15:16:36 +0100 |
| commit | 5ba33f846129f3e6c0505b19f94634b24505e828 (patch) | |
| tree | aaacabe678006040c342935481a86607c66607fd /src/layout/algorithm/tiled | |
| parent | 329b2b356dd92ac07f4e2aa69cbce82ee9ba9d19 (diff) | |
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.
Diffstat (limited to 'src/layout/algorithm/tiled')
7 files changed, 125 insertions, 128 deletions
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<SDwindleNodeData> pParent; - bool isNode = false; - WP<ITarget> pTarget; - std::array<WP<SDwindleNodeData>, 2> children = {}; - WP<SDwindleNodeData> 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<Hyprlang::INT>("dwindle:smart_split"); - static auto PPRESERVESPLIT = CConfigValue<Hyprlang::INT>("dwindle:preserve_split"); - static auto PFLMULT = CConfigValue<Hyprlang::FLOAT>("dwindle:split_width_multiplier"); - static auto PPRECISEMOUSEMOVE = CConfigValue<Hyprlang::INT>("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<Config::INTEGER>("dwindle:smart_split"); + static auto PPRESERVESPLIT = CConfigValue<Config::INTEGER>("dwindle:preserve_split"); + static auto PFLMULT = CConfigValue<Config::FLOAT>("dwindle:split_width_multiplier"); + static auto PPRECISEMOUSEMOVE = CConfigValue<Config::INTEGER>("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<ITarget> target) { addTarget(target); @@ -84,8 +66,8 @@ void CDwindleAlgorithm::addTarget(SP<ITarget> target) { const auto PMONITOR = m_parent->space()->workspace()->m_monitor; const auto PWORKSPACE = m_parent->space()->workspace(); - static auto PUSEACTIVE = CConfigValue<Hyprlang::INT>("dwindle:use_active_for_splits"); - static auto PDEFAULTSPLIT = CConfigValue<Hyprlang::FLOAT>("dwindle:default_split_ratio"); + static auto PUSEACTIVE = CConfigValue<Config::INTEGER>("dwindle:use_active_for_splits"); + static auto PDEFAULTSPLIT = CConfigValue<Config::FLOAT>("dwindle:default_split_ratio"); // Populate the node with our window's data PNODE->pTarget = target; @@ -154,17 +136,17 @@ void CDwindleAlgorithm::addTarget(SP<ITarget> target) { NEWPARENT->isNode = true; // it is a node NEWPARENT->splitRatio = std::clamp(*PDEFAULTSPLIT, 0.1F, 1.9F); - static auto PWIDTHMULTIPLIER = CConfigValue<Hyprlang::FLOAT>("dwindle:split_width_multiplier"); + static auto PWIDTHMULTIPLIER = CConfigValue<Config::FLOAT>("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<Hyprlang::INT>("dwindle:force_split"); - static auto PERMANENTDIRECTIONOVERRIDE = CConfigValue<Hyprlang::INT>("dwindle:permanent_direction_override"); - static auto PSMARTSPLIT = CConfigValue<Hyprlang::INT>("dwindle:smart_split"); - static auto PSPLITBIAS = CConfigValue<Hyprlang::INT>("dwindle:split_bias"); - static auto PPRECISEMOUSEMOVE = CConfigValue<Hyprlang::INT>("dwindle:precise_mouse_move"); + static auto PFORCESPLIT = CConfigValue<Config::INTEGER>("dwindle:force_split"); + static auto PERMANENTDIRECTIONOVERRIDE = CConfigValue<Config::INTEGER>("dwindle:permanent_direction_override"); + static auto PSMARTSPLIT = CConfigValue<Config::INTEGER>("dwindle:smart_split"); + static auto PSPLITBIAS = CConfigValue<Config::INTEGER>("dwindle:split_bias"); + static auto PPRECISEMOUSEMOVE = CConfigValue<Config::INTEGER>("dwindle:precise_mouse_move"); bool horizontalOverride = false; bool verticalOverride = false; @@ -324,8 +306,8 @@ void CDwindleAlgorithm::resizeTarget(const Vector2D& Δ, SP<ITarget> target, eRe if (!PNODE) return; - static auto PANIMATE = CConfigValue<Hyprlang::INT>("misc:animate_manual_resizes"); - static auto PSMARTRESIZING = CConfigValue<Hyprlang::INT>("dwindle:smart_resizing"); + static auto PANIMATE = CConfigValue<Config::INTEGER>("misc:animate_manual_resizes"); + static auto PSMARTRESIZING = CConfigValue<Config::INTEGER>("dwindle:smart_resizing"); // get some data about our window const auto PMONITOR = m_parent->space()->workspace()->m_monitor; @@ -533,7 +515,7 @@ std::optional<Vector2D> CDwindleAlgorithm::predictSizeForNewTarget() { CBox box = PNODE->box; - static auto PFLMULT = CConfigValue<Hyprlang::FLOAT>("dwindle:split_width_multiplier"); + static auto PFLMULT = CConfigValue<Config::FLOAT>("dwindle:split_width_multiplier"); bool splitTop = box.h * *PFLMULT > box.w; @@ -553,7 +535,7 @@ std::optional<Vector2D> CDwindleAlgorithm::predictSizeForNewTarget() { } void CDwindleAlgorithm::moveTargetInDirection(SP<ITarget> t, Math::eDirection dir, bool silent) { - static auto PMONITORFALLBACK = CConfigValue<Hyprlang::INT>("binds:window_direction_monitor_fallback"); + static auto PMONITORFALLBACK = CConfigValue<Config::INTEGER>("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<SDwindleNodeData> pParent; + bool isNode = false; + WP<ITarget> pTarget; + std::array<WP<SDwindleNodeData>, 2> children = {}; + WP<SDwindleNodeData> 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<ITarget> a, SP<ITarget> b); virtual void moveTargetInDirection(SP<ITarget> t, Math::eDirection dir, bool silent); + SP<SDwindleNodeData> getNodeFromWindow(PHLWINDOW w); + private: std::vector<SP<SDwindleNodeData>> m_dwindleNodesData; @@ -42,7 +62,6 @@ namespace Layout::Tiled { void addTarget(SP<ITarget> target); void calculateWorkspace(); SP<SDwindleNodeData> getNodeFromTarget(SP<ITarget>); - SP<SDwindleNodeData> getNodeFromWindow(PHLWINDOW w); int getNodes(); SP<SDwindleNodeData> getFirstNode(); SP<SDwindleNodeData> getClosestNode(const Vector2D&, SP<ITarget> 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<ITarget> 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<ITarget> target) { addTarget(target, true); } @@ -47,7 +29,7 @@ void CMasterAlgorithm::movedTarget(SP<ITarget> target, std::optional<Vector2D> f void CMasterAlgorithm::addTarget(SP<ITarget> target, bool firstMap) { static auto PNEWONACTIVE = CConfigValue<std::string>("master:new_on_active"); - static auto PNEWONTOP = CConfigValue<Hyprlang::INT>("master:new_on_top"); + static auto PNEWONTOP = CConfigValue<Config::INTEGER>("master:new_on_top"); static auto PNEWSTATUS = CConfigValue<std::string>("master:new_status"); const auto PWORKSPACE = m_parent->space()->workspace(); @@ -79,7 +61,7 @@ void CMasterAlgorithm::addTarget(SP<ITarget> target, bool firstMap) { PNODE->pTarget = target; const auto WINDOWSONWORKSPACE = getNodesNo(); - static auto PMFACT = CConfigValue<Hyprlang::FLOAT>("master:mfact"); + static auto PMFACT = CConfigValue<Config::FLOAT>("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<ITarget> target, bool firstMap) { getMasterNode(); const auto MOUSECOORDS = g_pInputManager->getMouseCoordsInternal(); - static auto PDROPATCURSOR = CConfigValue<Hyprlang::INT>("master:drop_at_cursor"); + static auto PDROPATCURSOR = CConfigValue<Config::INTEGER>("master:drop_at_cursor"); eOrientation orientation = getDynamicOrientation(); const auto NODEIT = std::ranges::find(m_masterNodesData, PNODE); @@ -97,7 +79,7 @@ void CMasterAlgorithm::addTarget(SP<ITarget> target, bool firstMap) { if (WINDOWSONWORKSPACE > 2) { auto& v = m_masterNodesData; - const std::size_t srcIndex = static_cast<std::size_t>(std::distance(v.begin(), NODEIT)); + const std::size_t srcIndex = sc<std::size_t>(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<ITarget> target, bool firstMap) { break; auto node = std::move(v[srcIndex]); - v.erase(v.begin() + static_cast<std::ptrdiff_t>(srcIndex)); - v.insert(v.begin() + static_cast<std::ptrdiff_t>(insertIndex), std::move(node)); + v.erase(v.begin() + sc<std::ptrdiff_t>(srcIndex)); + v.insert(v.begin() + sc<std::ptrdiff_t>(insertIndex), std::move(node)); break; } @@ -222,7 +204,7 @@ void CMasterAlgorithm::addTarget(SP<ITarget> target, bool firstMap) { void CMasterAlgorithm::removeTarget(SP<ITarget> target) { const auto MASTERSLEFT = getMastersNo(); - static auto SMALLSPLIT = CConfigValue<Hyprlang::INT>("master:allow_small_split"); + static auto SMALLSPLIT = CConfigValue<Config::INTEGER>("master:allow_small_split"); const auto PNODE = getNodeFromTarget(target); @@ -269,8 +251,8 @@ void CMasterAlgorithm::resizeTarget(const Vector2D& Δ, SP<ITarget> target, eRec return; const auto PMONITOR = m_parent->space()->workspace()->m_monitor; - static auto SLAVECOUNTFORCENTER = CConfigValue<Hyprlang::INT>("master:slave_count_for_center_master"); - static auto PSMARTRESIZING = CConfigValue<Hyprlang::INT>("master:smart_resizing"); + static auto SLAVECOUNTFORCENTER = CConfigValue<Config::INTEGER>("master:slave_count_for_center_master"); + static auto PSMARTRESIZING = CConfigValue<Config::INTEGER>("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<ITarget> a, SP<ITarget> b) { } void CMasterAlgorithm::moveTargetInDirection(SP<ITarget> t, Math::eDirection dir, bool silent) { - static auto PMONITORFALLBACK = CConfigValue<Hyprlang::INT>("binds:window_direction_monitor_fallback"); + static auto PMONITORFALLBACK = CConfigValue<Config::INTEGER>("binds:window_direction_monitor_fallback"); const auto PWINDOW2 = g_pCompositor->getWindowInDirection(t->window(), dir); @@ -576,7 +558,7 @@ std::expected<void, std::string> 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<void, std::string> 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<void, std::string> CMasterAlgorithm::layoutMsg(const std::string_v const auto WINDOWS = getNodesNo(); const auto MASTERS = getMastersNo(); - static auto SMALLSPLIT = CConfigValue<Hyprlang::INT>("master:allow_small_split"); + static auto SMALLSPLIT = CConfigValue<Config::INTEGER>("master:allow_small_split"); if (MASTERS + 2 > WINDOWS && *SMALLSPLIT == 0) return std::unexpected("nothing to do"); @@ -916,7 +898,7 @@ SP<SMasterNodeData> CMasterAlgorithm::getNodeFromWindow(PHLWINDOW x) { return x ? getNodeFromTarget(x->layoutTarget()) : nullptr; } -SP<SMasterNodeData> CMasterAlgorithm::getNodeFromTarget(SP<ITarget> x) { +SP<SMasterNodeData> CMasterAlgorithm::getNodeFromTarget(SP<ITarget> 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<Hyprlang::INT>("master:slave_count_for_center_master"); + static auto SLAVECOUNTFORCENTER = CConfigValue<Config::INTEGER>("master:slave_count_for_center_master"); static auto CMFALLBACK = CConfigValue<std::string>("master:center_master_fallback"); - static auto PIGNORERESERVED = CConfigValue<Hyprlang::INT>("master:center_ignores_reserved"); - static auto PSMARTRESIZING = CConfigValue<Hyprlang::INT>("master:smart_resizing"); + static auto PIGNORERESERVED = CConfigValue<Config::INTEGER>("master:center_ignores_reserved"); + static auto PSMARTRESIZING = CConfigValue<Config::INTEGER>("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<Hyprlang::INT>("master:always_keep_position"); + static auto PALWAYSKEEPPOSITION = CConfigValue<Config::INTEGER>("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<ITarget> 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<ITarget> a, SP<ITarget> b); virtual void moveTargetInDirection(SP<ITarget> t, Math::eDirection dir, bool silent); + SP<SMasterNodeData> getNodeFromTarget(SP<ITarget>) const; + private: std::vector<SP<SMasterNodeData>> m_masterNodesData; SMasterWorkspaceData m_workspaceData; @@ -64,7 +79,6 @@ namespace Layout::Tiled { eOrientation getDynamicOrientation(); int getNodesNo(); SP<SMasterNodeData> getNodeFromWindow(PHLWINDOW); - SP<SMasterNodeData> getNodeFromTarget(SP<ITarget>); SP<SMasterNodeData> getMasterNode(); SP<SMasterNodeData> 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<ITarget> a, SP<ITarget> b) { } void CMonocleAlgorithm::moveTargetInDirection(SP<ITarget> t, Math::eDirection dir, bool silent) { - static auto PMONITORFALLBACK = CConfigValue<Hyprlang::INT>("binds:window_direction_monitor_fallback"); + static auto PMONITORFALLBACK = CConfigValue<Config::INTEGER>("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<SColumnData> c) { if (!c) return; - static const auto PFSONONE = CConfigValue<Hyprlang::INT>("scrolling:fullscreen_on_one_column"); + static const auto PFSONONE = CConfigValue<Config::INTEGER>("scrolling:fullscreen_on_one_column"); const auto USABLE = algorithm->usableArea(); int64_t colIdx = idx(c); @@ -390,7 +390,7 @@ void SScrollingData::fitCol(SP<SColumnData> c) { if (!c) return; - static const auto PFSONONE = CConfigValue<Hyprlang::INT>("scrolling:fullscreen_on_one_column"); + static const auto PFSONONE = CConfigValue<Config::INTEGER>("scrolling:fullscreen_on_one_column"); const auto USABLE = algorithm->usableArea(); int64_t colIdx = idx(c); @@ -402,7 +402,7 @@ void SScrollingData::centerOrFitCol(SP<SColumnData> c) { if (!c) return; - static const auto PFITMETHOD = CConfigValue<Hyprlang::INT>("scrolling:focus_fit_method"); + static const auto PFITMETHOD = CConfigValue<Config::INTEGER>("scrolling:focus_fit_method"); if (*PFITMETHOD == 1) fitCol(c); @@ -411,7 +411,7 @@ void SScrollingData::centerOrFitCol(SP<SColumnData> c) { } SP<SColumnData> SScrollingData::atCenter() { - static const auto PFSONONE = CConfigValue<Hyprlang::INT>("scrolling:fullscreen_on_one_column"); + static const auto PFSONONE = CConfigValue<Config::INTEGER>("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<Hyprlang::INT>("scrolling:fullscreen_on_one_column"); + static const auto PFSONONE = CConfigValue<Config::INTEGER>("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<Hyprlang::INT>("scrolling:fullscreen_on_one_column"); + static const auto PFSONONE = CConfigValue<Config::INTEGER>("scrolling:fullscreen_on_one_column"); const auto USABLE = algorithm->usableArea(); return controller->calculateMaxExtent(USABLE, *PFSONONE); } bool SScrollingData::visible(SP<SColumnData> c, bool full) { - static const auto PFSONONE = CConfigValue<Hyprlang::INT>("scrolling:fullscreen_on_one_column"); + static const auto PFSONONE = CConfigValue<Config::INTEGER>("scrolling:fullscreen_on_one_column"); const auto USABLE = algorithm->usableArea(); int64_t colIdx = idx(c); @@ -469,8 +469,8 @@ bool SScrollingData::visible(SP<SColumnData> c, bool full) { } CScrollingAlgorithm::CScrollingAlgorithm() { - static const auto PCONFWIDTHS = CConfigValue<Hyprlang::STRING>("scrolling:explicit_column_widths"); - static const auto PCONFDIRECTION = CConfigValue<Hyprlang::STRING>("scrolling:direction"); + static const auto PCONFWIDTHS = CConfigValue<Config::STRING>("scrolling:explicit_column_widths"); + static const auto PCONFDIRECTION = CConfigValue<Config::STRING>("scrolling:direction"); m_scrollingData = makeShared<SScrollingData>(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<Hyprlang::STRING>("scrolling:direction"); + static const auto PCONFDIRECTION = CConfigValue<Config::STRING>("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<Hyprlang::INT>("scrolling:follow_focus"); + static const auto PFOLLOW_FOCUS = CConfigValue<Config::INTEGER>("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<Hyprlang::INT>("scrolling:follow_focus"); + static const auto PFOLLOW_FOCUS = CConfigValue<Config::INTEGER>("scrolling:follow_focus"); if (!*PFOLLOW_FOCUS && !Desktop::isHardInputFocusReason(reason)) return; @@ -549,7 +549,7 @@ CScrollingAlgorithm::~CScrollingAlgorithm() { } void CScrollingAlgorithm::focusOnInput(SP<ITarget> target, eInputMode input) { - static const auto PFOLLOW_FOCUS_MIN_PERC = CConfigValue<Hyprlang::FLOAT>("scrolling:follow_min_visible"); + static const auto PFOLLOW_FOCUS_MIN_PERC = CConfigValue<Config::FLOAT>("scrolling:follow_min_visible"); if (!target || target->space() != m_parent->space()) return; @@ -579,7 +579,7 @@ void CScrollingAlgorithm::focusOnInput(SP<ITarget> target, eInputMode input) { if (m_scrollingData->visible(TARGETDATA->column.lock(), true) && input != INPUT_MODE_KB) return; - static const auto PFITMETHOD = CConfigValue<Hyprlang::INT>("scrolling:focus_fit_method"); + static const auto PFITMETHOD = CConfigValue<Config::INTEGER>("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<ITarget> target if (!DATA->column || !DATA->column->scrollingData) return; - static const auto PFSONONE = CConfigValue<Hyprlang::INT>("scrolling:fullscreen_on_one_column"); + static const auto PFSONONE = CConfigValue<Config::INTEGER>("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<ITarget> t, Math::eDirection } void CScrollingAlgorithm::moveTargetTo(SP<ITarget> t, Math::eDirection dir, bool silent) { - static auto PMONITORFALLBACK = CConfigValue<Hyprlang::INT>("binds:window_direction_monitor_fallback"); + static auto PMONITORFALLBACK = CConfigValue<Config::INTEGER>("binds:window_direction_monitor_fallback"); const auto DATA = dataFor(t); @@ -986,7 +986,7 @@ void CScrollingAlgorithm::moveTargetTo(SP<ITarget> t, Math::eDirection dir, bool std::expected<void, std::string> CScrollingAlgorithm::layoutMsg(const std::string_view& sv) { auto centerOrFit = [this](const SP<SColumnData> COL) -> void { - static const auto PFITMETHOD = CConfigValue<Hyprlang::INT>("scrolling:focus_fit_method"); + static const auto PFITMETHOD = CConfigValue<Config::INTEGER>("scrolling:focus_fit_method"); if (*PFITMETHOD == 1) m_scrollingData->fitCol(COL); else @@ -1267,8 +1267,8 @@ std::expected<void, std::string> 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<Hyprlang::INT>("general:no_focus_fallback"); - static const auto PCONFWRAPFOCUS = CConfigValue<Hyprlang::INT>("scrolling:wrap_focus"); + static const auto PNOFALLBACK = CConfigValue<Config::INTEGER>("general:no_focus_fallback"); + static const auto PCONFWRAPFOCUS = CConfigValue<Config::INTEGER>("scrolling:wrap_focus"); if (!TDATA || ARGS[1].empty()) return std::unexpected("no window to focus"); @@ -1429,7 +1429,7 @@ std::expected<void, std::string> CScrollingAlgorithm::layoutMsg(const std::strin m_scrollingData->recalculate(); } else if (ARGS[0] == "swapcol") { - static const auto PCONFWRAPSWAPCOL = CConfigValue<Hyprlang::INT>("scrolling:wrap_swapcol"); + static const auto PCONFWRAPSWAPCOL = CConfigValue<Config::INTEGER>("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<Hyprlang::STRING>("scrolling:direction"); + static const auto PCONFDIRECTION = CConfigValue<Config::STRING>("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<Hyprlang::FLOAT>("scrolling:column_width"); + static const auto PCOLWIDTH = CConfigValue<Config::FLOAT>("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<ITarget> t, Math::eDirection dir, bool silent); CBox usableArea(); + SP<SScrollingTargetData> dataFor(SP<ITarget> t); enum eInputMode : uint8_t { INPUT_MODE_SOFT = 0, @@ -131,7 +132,6 @@ namespace Layout::Tiled { eScrollDirection getDynamicDirection(); SP<SScrollingTargetData> findBestNeighbor(SP<SScrollingTargetData> pCurrent, SP<SColumnData> pTargetCol); - SP<SScrollingTargetData> dataFor(SP<ITarget> t); SP<SScrollingTargetData> closestNode(const Vector2D& posGlobglobgabgalab); void focusTargetUpdate(SP<ITarget> target); |
