summaryrefslogtreecommitdiff
path: root/src/layout/algorithm/tiled/master/MasterAlgorithm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/layout/algorithm/tiled/master/MasterAlgorithm.cpp')
-rw-r--r--src/layout/algorithm/tiled/master/MasterAlgorithm.cpp56
1 files changed, 19 insertions, 37 deletions
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;