mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-06 07:01:57 -07:00
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.
This commit is contained in:
committed by
GitHub
parent
508262b7db
commit
964f1a438d
@@ -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
|
||||
|
Reference in New Issue
Block a user