diff options
author | Vaxry <[email protected]> | 2022-10-15 20:09:14 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2022-10-15 20:09:14 +0100 |
commit | 83d99ce5bde97733025ef33f2341d29282393376 (patch) | |
tree | 311c30316a805874bcbb01609ef9e6dc600d8b8e | |
parent | edeb759bb18fe9e8343d5d1c2ff8615811c23115 (diff) | |
parent | dca30815b03d44fe25c9beeb32ddb4ca8429dd7b (diff) | |
download | Hyprland-83d99ce5bde97733025ef33f2341d29282393376.tar.gz Hyprland-83d99ce5bde97733025ef33f2341d29282393376.zip |
Merge pull request #857 from K1llf0rce/max_size_rule
add maxsize window rule
-rw-r--r-- | src/config/ConfigManager.cpp | 1 | ||||
-rw-r--r-- | src/events/Windows.cpp | 15 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 93d684f5..738abcb0 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -722,6 +722,7 @@ bool windowRuleValid(const std::string& RULE) { && RULE.find("move") != 0 && RULE.find("size") != 0 && RULE.find("minsize") != 0 + && RULE.find("maxsize") != 0 && RULE.find("pseudo") != 0 && RULE.find("monitor") != 0 && RULE != "nofocus" diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 9c352e63..6586163f 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -269,6 +269,21 @@ void Events::listener_mapWindow(void* owner, void* data) { } catch (...) { Debug::log(LOG, "Rule minsize failed, rule: %s -> %s", r.szRule.c_str(), r.szValue.c_str()); } + } else if (r.szRule.find("maxsize") == 0) { + 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 SIZE = Vector2D(std::min((double)std::stoll(SIZEXSTR), PWINDOW->m_vRealSize.goalv().x), std::min((double)std::stoll(SIZEYSTR), PWINDOW->m_vRealSize.goalv().y)); + + PWINDOW->m_vRealSize = SIZE; + g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goalv()); + + PWINDOW->setHidden(false); + } catch (...) { + Debug::log(LOG, "Rule maxsize failed, rule: %s -> %s", r.szRule.c_str(), r.szValue.c_str()); + } } else if (r.szRule.find("move") == 0) { try { const auto VALUE = r.szRule.substr(r.szRule.find(" ") + 1); |