From ef3eb37c7f2cdbbab23e611aedc438c317463ef8 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Thu, 22 Sep 2022 18:12:25 +0100 Subject: [PATCH] support max in size rules --- src/events/Windows.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 42aa344b..3fbaddb1 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -233,8 +233,10 @@ void Events::listener_mapWindow(void* owner, void* data) { const auto SIZEXSTR = VALUE.substr(0, VALUE.find(" ")); const auto SIZEYSTR = VALUE.substr(VALUE.find(" ") + 1); - const auto SIZEX = !SIZEXSTR.contains('%') ? std::stoi(SIZEXSTR) : std::stoi(SIZEXSTR.substr(0, SIZEXSTR.length() - 1)) * 0.01f * PMONITOR->vecSize.x; - const auto SIZEY = !SIZEYSTR.contains('%') ? std::stoi(SIZEYSTR) : std::stoi(SIZEYSTR.substr(0, SIZEYSTR.length() - 1)) * 0.01f * PMONITOR->vecSize.y; + const auto MAXSIZE = g_pXWaylandManager->getMaxSizeForWindow(PWINDOW); + + const auto SIZEX = SIZEXSTR == "max" ? std::clamp(MAXSIZE.x, (double)20, PMONITOR->vecSize.x) : (!SIZEXSTR.contains('%') ? std::stoi(SIZEXSTR) : std::stoi(SIZEXSTR.substr(0, SIZEXSTR.length() - 1)) * 0.01f * PMONITOR->vecSize.x); + const auto SIZEY = SIZEYSTR == "max" ? std::clamp(MAXSIZE.y, (double)20, PMONITOR->vecSize.y) : (!SIZEYSTR.contains('%') ? 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);