From ffd6cf65e40a7140e82dc6e076c90b5119d41a54 Mon Sep 17 00:00:00 2001 From: MightyPlaza <123664421+MightyPlaza@users.noreply.github.com> Date: Tue, 15 Apr 2025 23:00:40 +0000 Subject: windowrules: allow incrementing window props (#9566) --- src/managers/KeybindManager.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/managers/KeybindManager.cpp') 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 #include @@ -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); } -- cgit v1.2.3