diff options
| author | MightyPlaza <123664421+MightyPlaza@users.noreply.github.com> | 2025-04-15 23:00:40 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-16 01:00:40 +0200 |
| commit | ffd6cf65e40a7140e82dc6e076c90b5119d41a54 (patch) | |
| tree | 0ccf8c15626b26d1eef39d880fd0a10533bdb489 /src/managers/KeybindManager.cpp | |
| parent | 8b7b169043de2a9d95f8505edb8b6576fac586fd (diff) | |
windowrules: allow incrementing window props (#9566)
Diffstat (limited to 'src/managers/KeybindManager.cpp')
| -rw-r--r-- | src/managers/KeybindManager.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 2644cf53..4ef7d229 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -18,6 +18,7 @@ #include "../managers/EventManager.hpp" #include "../render/Renderer.hpp" #include "../hyprerror/HyprError.hpp" +#include "../config/ConfigManager.hpp" #include <optional> #include <iterator> @@ -3221,7 +3222,7 @@ SDispatchResult CKeybindManager::setProp(std::string args) { } else if (auto search = NWindowProperties::boolWindowProperties.find(PROP); search != NWindowProperties::boolWindowProperties.end()) { auto pWindowDataElement = search->second(PWINDOW); if (VAL == "toggle") - *pWindowDataElement = CWindowOverridableVar(!pWindowDataElement->valueOrDefault(), PRIORITY_SET_PROP); + pWindowDataElement->increment(true, PRIORITY_SET_PROP); else if (VAL == "unset") pWindowDataElement->unset(PRIORITY_SET_PROP); else @@ -3229,12 +3230,18 @@ SDispatchResult CKeybindManager::setProp(std::string args) { } else if (auto search = NWindowProperties::intWindowProperties.find(PROP); search != NWindowProperties::intWindowProperties.end()) { if (VAL == "unset") search->second(PWINDOW)->unset(PRIORITY_SET_PROP); - else if (const auto V = configStringToInt(VAL); V) - *(search->second(PWINDOW)) = CWindowOverridableVar((int)*V, PRIORITY_SET_PROP); + else if (VAL.starts_with("relative")) { + const Hyprlang::INT V = std::stoi(VAL.substr(VAL.find(' '))); + search->second(PWINDOW)->increment(V, PRIORITY_SET_PROP); + } else if (const auto V = configStringToInt(VAL); V) + *(search->second(PWINDOW)) = CWindowOverridableVar((Hyprlang::INT)*V, PRIORITY_SET_PROP); } else if (auto search = NWindowProperties::floatWindowProperties.find(PROP); search != NWindowProperties::floatWindowProperties.end()) { if (VAL == "unset") search->second(PWINDOW)->unset(PRIORITY_SET_PROP); - else { + else if (VAL.starts_with("relative")) { + const auto V = std::stof(VAL.substr(VAL.find(' '))); + search->second(PWINDOW)->increment(V, PRIORITY_SET_PROP); + } else { const auto V = std::stof(VAL); *(search->second(PWINDOW)) = CWindowOverridableVar(V, PRIORITY_SET_PROP); } |
