diff options
| author | Tobias Zimmermann <cu3po42@gmail.com> | 2024-03-03 01:17:02 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-03 00:17:02 +0000 |
| commit | 964f1a438df5114fd9d771f24015e95b8061e503 (patch) | |
| tree | da67dfeecbdb4ee04296b45278fcc725f43166bf /src/managers/KeybindManager.cpp | |
| parent | 508262b7db6e8e88573a4069c88b4fb88ccff1d5 (diff) | |
keybinds: Add the 'catchall' keyword that matches all keys (#4930)
* Add the 'catchall' keyword that matches all keys
This keyword can be used to define arbitrary keybinds. The only special
behavior that it exhibits is that it matches every key, including
modifier keys. Any flags still apply normally.
This commit also fixes an issue that keys bound via the code:KEYCODE
format were not unbound correctly.
* Disallow catchall keybinds outside of submaps
A catchall keybind outside a submap would prevent essentially all key
events from going through to applications and would be difficult to
remove again.
Diffstat (limited to 'src/managers/KeybindManager.cpp')
| -rw-r--r-- | src/managers/KeybindManager.cpp | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 1ab8fa91..28c72029 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -95,18 +95,9 @@ void CKeybindManager::addKeybind(SKeybind kb) { m_pActiveKeybind = nullptr; } -void CKeybindManager::removeKeybind(uint32_t mod, const std::string& key) { +void CKeybindManager::removeKeybind(uint32_t mod, const SParsedKey& key) { for (auto it = m_lKeybinds.begin(); it != m_lKeybinds.end(); ++it) { - if (isNumber(key) && std::stoi(key) > 9) { - const uint32_t KEYNUM = std::stoi(key); - - if (it->modmask == mod && it->keycode == KEYNUM) { - it = m_lKeybinds.erase(it); - - if (it == m_lKeybinds.end()) - break; - } - } else if (it->modmask == mod && it->key == key) { + if (it->modmask == mod && it->key == key.key && it->keycode == key.keycode && it->catchAll == key.catchAll) { it = m_lKeybinds.erase(it); if (it == m_lKeybinds.end()) @@ -527,6 +518,9 @@ bool CKeybindManager::handleKeybinds(const uint32_t modmask, const SPressedKeyWi } else if (k.keycode != 0) { if (key.keycode != k.keycode) continue; + } else if (k.catchAll) { + if (found) + continue; } else { // oMg such performance hit!!11! // this little maneouver is gonna cost us 4µs |
