diff options
| author | MightyPlaza <123664421+MightyPlaza@users.noreply.github.com> | 2024-10-30 18:58:36 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-30 18:58:36 +0000 |
| commit | 12c1bb936dd463c4188def1c73c2bb786433a6dc (patch) | |
| tree | d59596edbf4c4ffa0581b92e3bbcf5710e9758e6 /src/events/Windows.cpp | |
| parent | 5f721dce36651232ae245d872c17dfa3aae5cc6c (diff) | |
internal: check size limit in layouts (#8298)
modified: src/desktop/Window.cpp
modified: src/desktop/Window.hpp
modified: src/events/Windows.cpp
modified: src/helpers/MiscFunctions.cpp
modified: src/helpers/MiscFunctions.hpp
modified: src/layout/DwindleLayout.cpp
modified: src/layout/IHyprLayout.cpp
modified: src/layout/MasterLayout.cpp
modified: src/macros.hpp
Diffstat (limited to 'src/events/Windows.cpp')
| -rw-r--r-- | src/events/Windows.cpp | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 30d982fb..f946ce03 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -334,13 +334,6 @@ void Events::listener_mapWindow(void* owner, void* data) { try { auto stringToFloatClamp = [](const std::string& VALUE, const float CURR, const float REL) { - auto stringToPercentage = [](const std::string& VALUE, const float REL) { - if (VALUE.ends_with('%')) - return (std::stof(VALUE.substr(0, VALUE.length() - 1)) * REL) / 100; - else - return std::stof(VALUE); - }; - if (VALUE.starts_with('<')) return std::min(CURR, stringToPercentage(VALUE.substr(1, VALUE.length() - 1), REL)); else if (VALUE.starts_with('>')) @@ -355,11 +348,11 @@ void Events::listener_mapWindow(void* owner, void* data) { const auto MAXSIZE = g_pXWaylandManager->getMaxSizeForWindow(PWINDOW); - const float SIZEX = - SIZEXSTR == "max" ? std::clamp(MAXSIZE.x, 20.0, PMONITOR->vecSize.x) : stringToFloatClamp(SIZEXSTR, PWINDOW->m_vRealSize.goal().x, PMONITOR->vecSize.x); + const float SIZEX = SIZEXSTR == "max" ? std::clamp(MAXSIZE.x, MIN_WINDOW_SIZE, PMONITOR->vecSize.x) : + stringToFloatClamp(SIZEXSTR, PWINDOW->m_vRealSize.goal().x, PMONITOR->vecSize.x); - const float SIZEY = - SIZEYSTR == "max" ? std::clamp(MAXSIZE.y, 20.0, PMONITOR->vecSize.y) : stringToFloatClamp(SIZEYSTR, PWINDOW->m_vRealSize.goal().y, PMONITOR->vecSize.y); + const float SIZEY = SIZEYSTR == "max" ? std::clamp(MAXSIZE.y, MIN_WINDOW_SIZE, PMONITOR->vecSize.y) : + stringToFloatClamp(SIZEYSTR, PWINDOW->m_vRealSize.goal().y, PMONITOR->vecSize.y); Debug::log(LOG, "Rule size, applying to {}", PWINDOW); @@ -472,18 +465,15 @@ void Events::listener_mapWindow(void* owner, void* data) { for (auto const& r : PWINDOW->m_vMatchedRules) { if (r.szRule.starts_with("size")) { try { - const auto VALUE = r.szRule.substr(r.szRule.find(' ') + 1); - const auto SIZEXSTR = VALUE.substr(0, VALUE.find(' ')); - const auto SIZEYSTR = VALUE.substr(VALUE.find(' ') + 1); - - const auto MAXSIZE = g_pXWaylandManager->getMaxSizeForWindow(PWINDOW); - - const auto SIZEX = SIZEXSTR == "max" ? - std::clamp(MAXSIZE.x, 20.0, PMONITOR->vecSize.x) : - (!SIZEXSTR.contains('%') ? std::stoi(SIZEXSTR) : std::stof(SIZEXSTR.substr(0, SIZEXSTR.length() - 1)) * 0.01 * PMONITOR->vecSize.x); - const auto SIZEY = SIZEYSTR == "max" ? - std::clamp(MAXSIZE.y, 20.0, PMONITOR->vecSize.y) : - (!SIZEYSTR.contains('%') ? std::stoi(SIZEYSTR) : std::stof(SIZEYSTR.substr(0, SIZEYSTR.length() - 1)) * 0.01 * PMONITOR->vecSize.y); + const auto VALUE = r.szRule.substr(r.szRule.find(' ') + 1); + const auto SIZEXSTR = VALUE.substr(0, VALUE.find(' ')); + const auto SIZEYSTR = VALUE.substr(VALUE.find(' ') + 1); + + const auto MAXSIZE = g_pXWaylandManager->getMaxSizeForWindow(PWINDOW); + + const float SIZEX = SIZEXSTR == "max" ? std::clamp(MAXSIZE.x, MIN_WINDOW_SIZE, PMONITOR->vecSize.x) : stringToPercentage(SIZEXSTR, PMONITOR->vecSize.x); + + const float SIZEY = SIZEYSTR == "max" ? std::clamp(MAXSIZE.y, MIN_WINDOW_SIZE, PMONITOR->vecSize.y) : stringToPercentage(SIZEYSTR, PMONITOR->vecSize.y); Debug::log(LOG, "Rule size (tiled), applying to {}", PWINDOW); |
