From 342750b56f5f481404f746fe3149fe2199761865 Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Wed, 29 Apr 2026 13:41:09 +0100 Subject: config/lua: fix unbind behavior (#14199) --- src/managers/KeybindManager.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/managers/KeybindManager.cpp') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 28c57eb9..8b1ec653 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -197,6 +197,23 @@ void CKeybindManager::removeKeybind(uint32_t mod, const SParsedKey& key) { m_lastLongPressKeybind.reset(); } +void CKeybindManager::removeKeybind(const std::string& displayKeys) { + static auto normalize = [](std::string x) -> std::string { + std::string n = x; + replaceInString(n, " ", ""); + std::ranges::transform(n, n.begin(), ::tolower); + return n; + }; + + const auto DISPLAY_KEYS_NORMALIZED = normalize(displayKeys); + + std::erase_if(m_keybinds, + [&displayKeys, &DISPLAY_KEYS_NORMALIZED](const auto& el) { return el->displayKey == displayKeys || DISPLAY_KEYS_NORMALIZED == normalize(el->displayKey); }); + + m_activeKeybinds.clear(); + m_lastLongPressKeybind.reset(); +} + uint32_t CKeybindManager::stringToModMask(std::string mods) { uint32_t modMask = 0; std::ranges::transform(mods, mods.begin(), ::toupper); -- cgit v1.2.3