diff options
| author | Epilepsy Gatherings <73647246+phonetic112@users.noreply.github.com> | 2024-03-07 21:24:44 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-08 02:24:44 +0000 |
| commit | e52d3fa8522ff83813a9006d4bf46b3057f4a4cc (patch) | |
| tree | 31b7e16e9a76718fe6cb5b6b2c19948ef6f946b9 /src/helpers/MiscFunctions.cpp | |
| parent | ceecdd0fd511122b7ff4f477a606880fe6599100 (diff) | |
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
Diffstat (limited to 'src/helpers/MiscFunctions.cpp')
| -rw-r--r-- | src/helpers/MiscFunctions.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
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) |
