summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuke Barkess <57995669+Brumus14@users.noreply.github.com>2025-11-11 22:59:21 +0000
committerGitHub <noreply@github.com>2025-11-11 22:59:21 +0000
commit308226a4fc2c9b63fa19894d5f85e79e05d75e03 (patch)
tree50a5c0d7577113726189824fda971b71c479867c /src
parentee2168c665c9c01991cd2a0e73633e4e7d833259 (diff)
config/keybinds: add a submap universal keybind flag (#12100)
Diffstat (limited to 'src')
-rw-r--r--src/config/ConfigManager.cpp83
-rw-r--r--src/debug/HyprCtl.cpp6
-rw-r--r--src/managers/KeybindManager.cpp2
-rw-r--r--src/managers/KeybindManager.hpp47
4 files changed, 67 insertions, 71 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index d03ad83e..a3c60d2b 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -2539,52 +2539,45 @@ std::optional<std::string> CConfigManager::handleBind(const std::string& command
// bind[fl]=SUPER,G,exec,dmenu_run <args>
// flags
- bool locked = false;
- bool release = false;
- bool repeat = false;
- bool mouse = false;
- bool nonConsuming = false;
- bool transparent = false;
- bool ignoreMods = false;
- bool multiKey = false;
- bool longPress = false;
- bool hasDescription = false;
- bool dontInhibit = false;
- bool click = false;
- bool drag = false;
- const auto BINDARGS = command.substr(4);
+ bool locked = false;
+ bool release = false;
+ bool repeat = false;
+ bool mouse = false;
+ bool nonConsuming = false;
+ bool transparent = false;
+ bool ignoreMods = false;
+ bool multiKey = false;
+ bool longPress = false;
+ bool hasDescription = false;
+ bool dontInhibit = false;
+ bool click = false;
+ bool drag = false;
+ bool submapUniversal = false;
+ const auto BINDARGS = command.substr(4);
for (auto const& arg : BINDARGS) {
- if (arg == 'l') {
- locked = true;
- } else if (arg == 'r') {
- release = true;
- } else if (arg == 'e') {
- repeat = true;
- } else if (arg == 'm') {
- mouse = true;
- } else if (arg == 'n') {
- nonConsuming = true;
- } else if (arg == 't') {
- transparent = true;
- } else if (arg == 'i') {
- ignoreMods = true;
- } else if (arg == 's') {
- multiKey = true;
- } else if (arg == 'o') {
- longPress = true;
- } else if (arg == 'd') {
- hasDescription = true;
- } else if (arg == 'p') {
- dontInhibit = true;
- } else if (arg == 'c') {
- click = true;
- release = true;
- } else if (arg == 'g') {
- drag = true;
- release = true;
- } else {
- return "bind: invalid flag";
+ switch (arg) {
+ case 'l': locked = true; break;
+ case 'r': release = true; break;
+ case 'e': repeat = true; break;
+ case 'm': mouse = true; break;
+ case 'n': nonConsuming = true; break;
+ case 't': transparent = true; break;
+ case 'i': ignoreMods = true; break;
+ case 's': multiKey = true; break;
+ case 'o': longPress = true; break;
+ case 'd': hasDescription = true; break;
+ case 'p': dontInhibit = true; break;
+ case 'c':
+ click = true;
+ release = true;
+ break;
+ case 'g':
+ drag = true;
+ release = true;
+ break;
+ case 'u': submapUniversal = true; break;
+ default: return "bind: invalid flag";
}
}
@@ -2657,7 +2650,7 @@ std::optional<std::string> CConfigManager::handleBind(const std::string& command
g_pKeybindManager->addKeybind(SKeybind{parsedKey.key, KEYSYMS, parsedKey.keycode, parsedKey.catchAll, MOD, MODS, HANDLER,
COMMAND, locked, m_currentSubmap, DESCRIPTION, release, repeat, longPress,
mouse, nonConsuming, transparent, ignoreMods, multiKey, hasDescription, dontInhibit,
- click, drag});
+ click, drag, submapUniversal});
}
return {};
diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp
index a0ccddd0..b5de6503 100644
--- a/src/debug/HyprCtl.cpp
+++ b/src/debug/HyprCtl.cpp
@@ -1025,6 +1025,7 @@ static std::string bindsRequest(eHyprCtlOutputFormat format, std::string request
"has_description": {},
"modmask": {},
"submap": "{}",
+ "submap_universal": "{}",
"key": "{}",
"keycode": {},
"catch_all": {},
@@ -1033,8 +1034,9 @@ static std::string bindsRequest(eHyprCtlOutputFormat format, std::string request
"arg": "{}"
}},)#",
kb->locked ? "true" : "false", kb->mouse ? "true" : "false", kb->release ? "true" : "false", kb->repeat ? "true" : "false", kb->longPress ? "true" : "false",
- kb->nonConsuming ? "true" : "false", kb->hasDescription ? "true" : "false", kb->modmask, escapeJSONStrings(kb->submap.name), escapeJSONStrings(kb->key),
- kb->keycode, kb->catchAll ? "true" : "false", escapeJSONStrings(kb->description), escapeJSONStrings(kb->handler), escapeJSONStrings(kb->arg));
+ kb->nonConsuming ? "true" : "false", kb->hasDescription ? "true" : "false", kb->modmask, escapeJSONStrings(kb->submap.name), kb->submapUniversal,
+ escapeJSONStrings(kb->key), kb->keycode, kb->catchAll ? "true" : "false", escapeJSONStrings(kb->description), escapeJSONStrings(kb->handler),
+ escapeJSONStrings(kb->arg));
}
trimTrailingComma(ret);
ret += "]";
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index 68750ad7..8194f739 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -680,7 +680,7 @@ SDispatchResult CKeybindManager::handleKeybinds(const uint32_t modmask, const SP
if (!k->locked && g_pSessionLockManager->isSessionLocked())
continue;
- if (!IGNORECONDITIONS && ((modmask != k->modmask && !k->ignoreMods) || k->submap != m_currentSelectedSubmap || k->shadowed))
+ if (!IGNORECONDITIONS && ((modmask != k->modmask && !k->ignoreMods) || (k->submap != m_currentSelectedSubmap && !k->submapUniversal) || k->shadowed))
continue;
if (k->multiKey) {
diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp
index 592588b5..e3433a10 100644
--- a/src/managers/KeybindManager.hpp
+++ b/src/managers/KeybindManager.hpp
@@ -26,29 +26,30 @@ struct SSubmap {
};
struct SKeybind {
- std::string key = "";
- std::set<xkb_keysym_t> sMkKeys = {};
- uint32_t keycode = 0;
- bool catchAll = false;
- uint32_t modmask = 0;
- std::set<xkb_keysym_t> sMkMods = {};
- std::string handler = "";
- std::string arg = "";
- bool locked = false;
- SSubmap submap = {};
- std::string description = "";
- bool release = false;
- bool repeat = false;
- bool longPress = false;
- bool mouse = false;
- bool nonConsuming = false;
- bool transparent = false;
- bool ignoreMods = false;
- bool multiKey = false;
- bool hasDescription = false;
- bool dontInhibit = false;
- bool click = false;
- bool drag = false;
+ std::string key = "";
+ std::set<xkb_keysym_t> sMkKeys = {};
+ uint32_t keycode = 0;
+ bool catchAll = false;
+ uint32_t modmask = 0;
+ std::set<xkb_keysym_t> sMkMods = {};
+ std::string handler = "";
+ std::string arg = "";
+ bool locked = false;
+ SSubmap submap = {};
+ std::string description = "";
+ bool release = false;
+ bool repeat = false;
+ bool longPress = false;
+ bool mouse = false;
+ bool nonConsuming = false;
+ bool transparent = false;
+ bool ignoreMods = false;
+ bool multiKey = false;
+ bool hasDescription = false;
+ bool dontInhibit = false;
+ bool click = false;
+ bool drag = false;
+ bool submapUniversal = false;
// DO NOT INITIALIZE
bool shadowed = false;