From e52d3fa8522ff83813a9006d4bf46b3057f4a4cc Mon Sep 17 00:00:00 2001 From: Epilepsy Gatherings <73647246+phonetic112@users.noreply.github.com> Date: Thu, 7 Mar 2024 21:24:44 -0500 Subject: windowrules: Make min/maxsize rules dynamic (#4775) * rebase * simplify and remove prop * Stuff - add back win prop - change minsize defaults - change request formatting for setprop * style fix * remove empty line * change defaults * redo string to vec * remove redundant parsing * change to vec * support commas * remove static rules * take out garbage * format * don't allow commas and resize on setprop * use isNumber --- src/helpers/MiscFunctions.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/helpers/MiscFunctions.cpp') diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp index 2905ce2b..860d8456 100644 --- a/src/helpers/MiscFunctions.cpp +++ b/src/helpers/MiscFunctions.cpp @@ -722,6 +722,32 @@ int64_t configStringToInt(const std::string& VALUE) { return std::stoll(VALUE); } +Vector2D configStringToVector2D(const std::string& VALUE) { + std::istringstream iss(VALUE); + std::string token; + + if (!std::getline(iss, token, ' ') && !std::getline(iss, token, ',')) + throw std::invalid_argument("Invalid string format"); + + if (!isNumber(token)) + throw std::invalid_argument("Invalid x value"); + + long long x = std::stoll(token); + + if (!std::getline(iss, token)) + throw std::invalid_argument("Invalid string format"); + + if (!isNumber(token)) + throw std::invalid_argument("Invalid y value"); + + long long y = std::stoll(token); + + if (std::getline(iss, token)) + throw std::invalid_argument("Invalid string format"); + + return Vector2D(x, y); +} + double normalizeAngleRad(double ang) { if (ang > M_PI * 2) { while (ang > M_PI * 2) -- cgit v1.2.3