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:
Tobias Zimmermann 2024-03-03 01:17:02 +01:00 committed by GitHub
parent 508262b7db
commit 964f1a438d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 39 additions and 24 deletions

View file

@ -13,6 +13,7 @@ class CPluginSystem;
struct SKeybind {
std::string key = "";
uint32_t keycode = 0;
bool catchAll = false;
uint32_t modmask = 0;
std::string handler = "";
std::string arg = "";
@ -44,6 +45,12 @@ struct SPressedKeyWithMods {
bool sent = false;
};
struct SParsedKey {
std::string key = "";
uint32_t keycode = 0;
bool catchAll = false;
};
class CKeybindManager {
public:
CKeybindManager();
@ -57,7 +64,7 @@ class CKeybindManager {
void onSwitchOffEvent(const std::string&);
void addKeybind(SKeybind);
void removeKeybind(uint32_t, const std::string&);
void removeKeybind(uint32_t, const SParsedKey&);
uint32_t stringToModMask(std::string);
uint32_t keycodeToModifier(xkb_keycode_t);
void clearKeybinds();