From 7532115318cd5c1ddf434d93e37995e55d5bc8cb Mon Sep 17 00:00:00 2001 From: Vaxry Date: Wed, 19 Nov 2025 19:03:26 +0000 Subject: [PATCH] rule: nuke parseRelativeVector --- src/desktop/rule/windowRule/WindowRule.cpp | 21 --------------------- src/desktop/rule/windowRule/WindowRule.hpp | 4 +--- src/layout/IHyprLayout.cpp | 2 +- 3 files changed, 2 insertions(+), 25 deletions(-) diff --git a/src/desktop/rule/windowRule/WindowRule.cpp b/src/desktop/rule/windowRule/WindowRule.cpp index 1bcbbc96..6a6878d2 100644 --- a/src/desktop/rule/windowRule/WindowRule.cpp +++ b/src/desktop/rule/windowRule/WindowRule.cpp @@ -7,27 +7,6 @@ using namespace Desktop; using namespace Desktop::Rule; -std::optional Rule::parseRelativeVector(PHLWINDOW w, const std::string& s) { - try { - const auto VALUE = s.substr(s.find(' ') + 1); - const auto SIZEXSTR = VALUE.substr(0, VALUE.find(' ')); - const auto SIZEYSTR = VALUE.substr(VALUE.find(' ') + 1); - - const auto MAXSIZE = w->requestedMaxSize(); - - const float SIZEX = SIZEXSTR == "max" ? std::clamp(MAXSIZE.x, MIN_WINDOW_SIZE, g_pCompositor->m_lastMonitor->m_size.x) : - stringToPercentage(SIZEXSTR, g_pCompositor->m_lastMonitor->m_size.x); - - const float SIZEY = SIZEYSTR == "max" ? std::clamp(MAXSIZE.y, MIN_WINDOW_SIZE, g_pCompositor->m_lastMonitor->m_size.y) : - stringToPercentage(SIZEYSTR, g_pCompositor->m_lastMonitor->m_size.y); - - return Vector2D{SIZEX, SIZEY}; - - } catch (...) { Debug::log(LOG, "Rule size failed, rule: {}", s); } - - return std::nullopt; -} - CWindowRule::CWindowRule(const std::string& name) : IRule(name) { ; } diff --git a/src/desktop/rule/windowRule/WindowRule.hpp b/src/desktop/rule/windowRule/WindowRule.hpp index 944614ce..f7621828 100644 --- a/src/desktop/rule/windowRule/WindowRule.hpp +++ b/src/desktop/rule/windowRule/WindowRule.hpp @@ -8,9 +8,7 @@ #include namespace Desktop::Rule { - constexpr const char* EXEC_RULE_ENV_NAME = "HL_EXEC_RULE_TOKEN"; - - std::optional parseRelativeVector(PHLWINDOW w, const std::string& s); + constexpr const char* EXEC_RULE_ENV_NAME = "HL_EXEC_RULE_TOKEN"; class CWindowRule : public IRule { private: diff --git a/src/layout/IHyprLayout.cpp b/src/layout/IHyprLayout.cpp index 85b401bd..953e8e02 100644 --- a/src/layout/IHyprLayout.cpp +++ b/src/layout/IHyprLayout.cpp @@ -965,7 +965,7 @@ Vector2D IHyprLayout::predictSizeForNewWindowFloating(PHLWINDOW pWindow) { // ge } if (!pWindow->m_ruleApplicator->static_.size.empty()) { - const auto SIZE = Desktop::Rule::parseRelativeVector(pWindow, pWindow->m_ruleApplicator->static_.size); + const auto SIZE = pWindow->calculateExpression(pWindow->m_ruleApplicator->static_.size); if (SIZE) return SIZE.value(); }