rule: nuke parseRelativeVector

This commit is contained in:
Vaxry 2025-11-19 19:03:26 +00:00
parent 1c29d6b1ba
commit 7532115318
No known key found for this signature in database
GPG key ID: 665806380871D640
3 changed files with 2 additions and 25 deletions

View file

@ -7,27 +7,6 @@
using namespace Desktop;
using namespace Desktop::Rule;
std::optional<Vector2D> 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) {
;
}

View file

@ -8,9 +8,7 @@
#include <unordered_set>
namespace Desktop::Rule {
constexpr const char* EXEC_RULE_ENV_NAME = "HL_EXEC_RULE_TOKEN";
std::optional<Vector2D> parseRelativeVector(PHLWINDOW w, const std::string& s);
constexpr const char* EXEC_RULE_ENV_NAME = "HL_EXEC_RULE_TOKEN";
class CWindowRule : public IRule {
private:

View file

@ -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();
}