summaryrefslogtreecommitdiff
path: root/src/managers/KeybindManager.cpp
diff options
context:
space:
mode:
authornyx <nnyyxxxx@protonmail.com>2025-04-21 14:47:14 -0400
committerGitHub <noreply@github.com>2025-04-21 20:47:14 +0200
commitd29723cb76479a860bf9d07d47c5a14b4d64dbc0 (patch)
treeaf1abba1f88f22c375fc3d991e4a69507cfae96c /src/managers/KeybindManager.cpp
parent400dd1607292165bccbafc4af7bce4855ac8a71c (diff)
keybinds: allow executing binds not bound to a key (#10102)
Diffstat (limited to 'src/managers/KeybindManager.cpp')
-rw-r--r--src/managers/KeybindManager.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index 06ea358d..2eae60b9 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -150,6 +150,10 @@ CKeybindManager::CKeybindManager() {
if (!m_pLastLongPressKeybind || g_pSeatManager->keyboard.expired())
return;
+ const auto PACTIVEKEEB = g_pSeatManager->keyboard.lock();
+ if (!PACTIVEKEEB->allowBinds)
+ return;
+
const auto DISPATCHER = g_pKeybindManager->m_mDispatchers.find(m_pLastLongPressKeybind->handler);
Debug::log(LOG, "Long press timeout passed, calling dispatcher.");
@@ -163,6 +167,10 @@ CKeybindManager::CKeybindManager() {
if (m_vActiveKeybinds.size() == 0 || g_pSeatManager->keyboard.expired())
return;
+ const auto PACTIVEKEEB = g_pSeatManager->keyboard.lock();
+ if (!PACTIVEKEEB->allowBinds)
+ return;
+
for (const auto& k : m_vActiveKeybinds) {
const auto DISPATCHER = g_pKeybindManager->m_mDispatchers.find(k->handler);
@@ -170,7 +178,6 @@ CKeybindManager::CKeybindManager() {
DISPATCHER->second(k->arg);
}
- const auto PACTIVEKEEB = g_pSeatManager->keyboard.lock();
self->updateTimeout(std::chrono::milliseconds(1000 / PACTIVEKEEB->repeatRate));
},
nullptr);
@@ -424,6 +431,9 @@ bool CKeybindManager::onKeyEvent(std::any event, SP<IKeyboard> pKeyboard) {
return true;
}
+ if (!pKeyboard->allowBinds)
+ return true;
+
if (!m_pXKBTranslationState) {
Debug::log(ERR, "BUG THIS: m_pXKBTranslationState nullptr!");
updateXKBTranslationState();
@@ -432,10 +442,7 @@ bool CKeybindManager::onKeyEvent(std::any event, SP<IKeyboard> pKeyboard) {
return true;
}
- auto e = std::any_cast<IKeyboard::SKeyEvent>(event);
-
- if (!pKeyboard->allowBinds)
- return true;
+ auto e = std::any_cast<IKeyboard::SKeyEvent>(event);
const auto KEYCODE = e.keycode + 8; // Because to xkbcommon it's +8 from libinput
@@ -770,6 +777,8 @@ SDispatchResult CKeybindManager::handleKeybinds(const uint32_t modmask, const SP
else if (SPECIALDISPATCHER && pressed)
m_vPressedSpecialBinds.emplace_back(k);
+ found = true;
+
// Should never happen, as we check in the ConfigManager, but oh well
if (DISPATCHER == m_mDispatchers.end()) {
Debug::log(ERR, "Invalid handler in a keybind! (handler {} does not exist)", k->handler);
@@ -787,10 +796,8 @@ SDispatchResult CKeybindManager::handleKeybinds(const uint32_t modmask, const SP
m_iPassPressed = -1;
- if (k->handler == "submap") {
- found = true; // don't process keybinds on submap change.
+ if (k->handler == "submap")
break;
- }
}
if (k->repeat) {