diff options
| author | MightyPlaza <123664421+MightyPlaza@users.noreply.github.com> | 2026-04-30 11:59:03 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-30 12:59:03 +0100 |
| commit | 8884b9e6ce608a22c993b1a871e864171626e8e5 (patch) | |
| tree | af81ea833fc6e556602047c75936b8199ad5641f | |
| parent | d40860e8e27c2abc50cebaae56e16b4ac10af667 (diff) | |
binds: add an auto_consuming flag (#13919)
| -rw-r--r-- | meta/hl.meta.lua | 1 | ||||
| -rw-r--r-- | src/config/legacy/ConfigManager.cpp | 33 | ||||
| -rw-r--r-- | src/config/lua/bindings/LuaBindingsToplevel.cpp | 1 | ||||
| -rw-r--r-- | src/config/lua/objects/LuaKeybind.cpp | 2 | ||||
| -rw-r--r-- | src/debug/HyprCtl.cpp | 7 | ||||
| -rw-r--r-- | src/managers/KeybindManager.cpp | 6 | ||||
| -rw-r--r-- | src/managers/KeybindManager.hpp | 1 |
7 files changed, 42 insertions, 9 deletions
diff --git a/meta/hl.meta.lua b/meta/hl.meta.lua index 038c066b..96092e91 100644 --- a/meta/hl.meta.lua +++ b/meta/hl.meta.lua @@ -580,6 +580,7 @@ local __HL_Group = {} ---@field set_enabled fun(self: HL.Keybind, ...): any ---@field unbind fun(self: HL.Keybind, ...): any ---@field arg string +---@field auto_consuming boolean ---@field catchall boolean ---@field click boolean ---@field description any diff --git a/src/config/legacy/ConfigManager.cpp b/src/config/legacy/ConfigManager.cpp index 3e6fe6e9..2705c395 100644 --- a/src/config/legacy/ConfigManager.cpp +++ b/src/config/legacy/ConfigManager.cpp @@ -1478,6 +1478,7 @@ std::optional<std::string> CConfigManager::handleBind(const std::string& command bool repeat = false; bool mouse = false; bool nonConsuming = false; + bool autoConsuming = false; bool transparent = false; bool ignoreMods = false; bool multiKey = false; @@ -1497,6 +1498,7 @@ std::optional<std::string> CConfigManager::handleBind(const std::string& command case 'e': repeat = true; break; case 'm': mouse = true; break; case 'n': nonConsuming = true; break; + case 'a': autoConsuming = true; break; case 't': transparent = true; break; case 'i': ignoreMods = true; break; case 's': multiKey = true; break; @@ -1596,10 +1598,33 @@ std::optional<std::string> CConfigManager::handleBind(const std::string& command return "Invalid catchall, catchall keybinds are only allowed in submaps."; } - 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, submapUniversal, deviceInclusive, devices}); + g_pKeybindManager->addKeybind(SKeybind{parsedKey.key, + KEYSYMS, + parsedKey.keycode, + parsedKey.catchAll, + MOD, + MODS, + HANDLER, + COMMAND, + locked, + m_currentSubmap, + DESCRIPTION, + release, + repeat, + longPress, + mouse, + nonConsuming, + autoConsuming, + transparent, + ignoreMods, + multiKey, + hasDescription, + dontInhibit, + click, + drag, + submapUniversal, + deviceInclusive, + devices}); } return {}; diff --git a/src/config/lua/bindings/LuaBindingsToplevel.cpp b/src/config/lua/bindings/LuaBindingsToplevel.cpp index ec80c899..8bdd1c19 100644 --- a/src/config/lua/bindings/LuaBindingsToplevel.cpp +++ b/src/config/lua/bindings/LuaBindingsToplevel.cpp @@ -166,6 +166,7 @@ static int hlBind(lua_State* L) { kb.locked = getBool("locked"); kb.release = getBool("release"); kb.nonConsuming = getBool("non_consuming"); + kb.autoConsuming = getBool("auto_consuming"); kb.transparent = getBool("transparent"); kb.ignoreMods = getBool("ignore_mods"); kb.dontInhibit = getBool("dont_inhibit"); diff --git a/src/config/lua/objects/LuaKeybind.cpp b/src/config/lua/objects/LuaKeybind.cpp index aab2735d..ea2ce43d 100644 --- a/src/config/lua/objects/LuaKeybind.cpp +++ b/src/config/lua/objects/LuaKeybind.cpp @@ -143,6 +143,8 @@ static int keybindIndex(lua_State* L) { lua_pushboolean(L, (*keybind)->release); else if (key == "non_consuming") lua_pushboolean(L, (*keybind)->nonConsuming); + else if (key == "auto_consuming") + lua_pushboolean(L, (*keybind)->autoConsuming); else if (key == "transparent") lua_pushboolean(L, (*keybind)->transparent); else if (key == "ignore_mods") diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index a3f5f9e0..b334a26e 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -1015,6 +1015,8 @@ static std::string bindsRequest(eHyprCtlOutputFormat format, std::string request ret += "e"; if (kb->nonConsuming) ret += "n"; + if (kb->autoConsuming) + ret += "a"; if (kb->hasDescription) ret += "d"; @@ -1034,6 +1036,7 @@ static std::string bindsRequest(eHyprCtlOutputFormat format, std::string request "repeat": {}, "longPress": {}, "non_consuming": {}, + "auto_consuming": {}, "has_description": {}, "modmask": {}, "submap": "{}", @@ -1046,8 +1049,8 @@ 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), kb->submapUniversal, - escapeJSONStrings(kb->key), kb->keycode, kb->catchAll ? "true" : "false", escapeJSONStrings(kb->description), escapeJSONStrings(kb->handler), + kb->nonConsuming ? "true" : "false", kb->autoConsuming ? "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); diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 8b1ec653..4a5df4be 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -653,7 +653,7 @@ SDispatchResult CKeybindManager::handleKeybinds(const uint32_t modmask, const SP } if (pressed && k->release && !SPECIALDISPATCHER) { - if (k->nonConsuming) + if (k->nonConsuming || k->autoConsuming) continue; found = true; // suppress the event @@ -672,7 +672,7 @@ SDispatchResult CKeybindManager::handleKeybinds(const uint32_t modmask, const SP continue; } else if (!k->release && !SPECIALDISPATCHER) { - if (k->nonConsuming) + if (k->nonConsuming || k->autoConsuming) continue; found = true; // suppress the event @@ -737,7 +737,7 @@ SDispatchResult CKeybindManager::handleKeybinds(const uint32_t modmask, const SP m_repeatKeyTimer->updateTimeout(std::chrono::milliseconds(KEEB->m_repeatDelay)); } - if (!k->nonConsuming) + if (!k->nonConsuming && !(k->autoConsuming && !res.success)) found = true; } diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp index fc51fdf0..87cae14a 100644 --- a/src/managers/KeybindManager.hpp +++ b/src/managers/KeybindManager.hpp @@ -42,6 +42,7 @@ struct SKeybind { bool longPress = false; bool mouse = false; bool nonConsuming = false; + bool autoConsuming = false; bool transparent = false; bool ignoreMods = false; bool multiKey = false; |
