From d599513d4a72d66ac62ffdedc41d6653fa81b39e Mon Sep 17 00:00:00 2001 From: ItsOhen Date: Sat, 11 Oct 2025 02:40:18 +0200 Subject: config: add automatic closing to submaps (#11760) * Allow submaps to auto reset to parent. * Really should be a stack instead. If hyprlang would allow for { } i would be so happy. * Fixed: Somewhat better way to do it.. Lets you define what submap you want to go to instead. * squash! Fixed: Somewhat better way to do it.. * God i hate cf.. * Force clang-format on the whole thing.. * Removed {}. * Added tests Tests and reset fix. --- src/config/ConfigManager.cpp | 12 +++++------- src/config/ConfigManager.hpp | 3 ++- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'src/config') diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 936ec383..47ac4730 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -2630,7 +2630,7 @@ std::optional CConfigManager::handleBind(const std::string& command if ((!KEY.empty()) || multiKey) { SParsedKey parsedKey = parseKey(KEY); - if (parsedKey.catchAll && m_currentSubmap.empty()) { + if (parsedKey.catchAll && m_currentSubmap.name.empty()) { Debug::log(ERR, "Catchall not allowed outside of submap!"); return "Invalid catchall, catchall keybinds are only allowed in submaps."; } @@ -3011,12 +3011,10 @@ std::optional CConfigManager::handleWorkspaceRules(const std::strin return {}; } -std::optional CConfigManager::handleSubmap(const std::string& command, const std::string& submap) { - if (submap == "reset") - m_currentSubmap = ""; - else - m_currentSubmap = submap; - +std::optional CConfigManager::handleSubmap(const std::string&, const std::string& submap) { + const auto SUBMAP = CConstVarList(submap); + m_currentSubmap.name = (SUBMAP[0] == "reset") ? "" : SUBMAP[0]; + m_currentSubmap.reset = SUBMAP[1]; return {}; } diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp index cff146f3..7f32be41 100644 --- a/src/config/ConfigManager.hpp +++ b/src/config/ConfigManager.hpp @@ -22,6 +22,7 @@ #include "../helpers/memory/Memory.hpp" #include "../desktop/WindowRule.hpp" #include "../managers/XWaylandManager.hpp" +#include "../managers/KeybindManager.hpp" #include @@ -307,7 +308,7 @@ class CConfigManager { Hyprutils::Animation::CAnimationConfigTree m_animationTree; - std::string m_currentSubmap = ""; // For storing the current keybind submap + SSubmap m_currentSubmap; std::vector m_execRequestedRules; // rules requested with exec, e.g. [workspace 2] kitty -- cgit v1.2.3