summaryrefslogtreecommitdiff
path: root/src/events/Windows.cpp
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-04-22 14:31:14 +0200
committervaxerski <43317083+vaxerski@users.noreply.github.com>2022-04-22 14:31:14 +0200
commita8e5e9c5587b02f6fbbd9bdff97b3913f32f490f (patch)
treef2a13aec719104f5a93d18941aebbe0abb56aa39 /src/events/Windows.cpp
parent15eb844260965dfeeddf9a684e00175bac62ee9b (diff)
Allow percentages in move and size rules
Diffstat (limited to 'src/events/Windows.cpp')
-rw-r--r--src/events/Windows.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp
index d62ea926..9851a76b 100644
--- a/src/events/Windows.cpp
+++ b/src/events/Windows.cpp
@@ -98,8 +98,11 @@ void Events::listener_mapWindow(void* owner, void* data) {
if (r.szRule.find("size") == 0) {
try {
const auto VALUE = r.szRule.substr(r.szRule.find(" ") + 1);
- const auto SIZEX = stoi(VALUE.substr(0, VALUE.find(" ")));
- const auto SIZEY = stoi(VALUE.substr(VALUE.find(" ") + 1));
+ const auto SIZEXSTR = VALUE.substr(0, VALUE.find(" "));
+ const auto SIZEYSTR = VALUE.substr(VALUE.find(" ") + 1);
+
+ const auto SIZEX = SIZEXSTR.find('%') == std::string::npos ? std::stoi(SIZEXSTR) : std::stoi(SIZEXSTR.substr(0, SIZEXSTR.length() - 1)) * 0.01f * PMONITOR->vecSize.x;
+ const auto SIZEY = SIZEYSTR.find('%') == std::string::npos ? std::stoi(SIZEYSTR) : std::stoi(SIZEYSTR.substr(0, SIZEYSTR.length() - 1)) * 0.01f * PMONITOR->vecSize.y;
Debug::log(LOG, "Rule size, applying to window %x", PWINDOW);
@@ -111,8 +114,11 @@ void Events::listener_mapWindow(void* owner, void* data) {
} else if (r.szRule.find("move") == 0) {
try {
const auto VALUE = r.szRule.substr(r.szRule.find(" ") + 1);
- const auto POSX = stoi(VALUE.substr(0, VALUE.find(" ")));
- const auto POSY = stoi(VALUE.substr(VALUE.find(" ") + 1));
+ const auto POSXSTR = VALUE.substr(0, VALUE.find(" "));
+ const auto POSYSTR = VALUE.substr(VALUE.find(" ") + 1);
+
+ const auto POSX = POSXSTR.find('%') == std::string::npos ? std::stoi(POSXSTR) : std::stoi(POSXSTR.substr(0, POSXSTR.length() - 1)) * 0.01f * PMONITOR->vecSize.x;
+ const auto POSY = POSYSTR.find('%') == std::string::npos ? std::stoi(POSYSTR) : std::stoi(POSYSTR.substr(0, POSYSTR.length() - 1)) * 0.01f * PMONITOR->vecSize.y;
Debug::log(LOG, "Rule move, applying to window %x", PWINDOW);