keybinds: allow executing binds not bound to a key (#10102)

This commit is contained in:
nyx 2025-04-21 14:47:14 -04:00 committed by GitHub
parent 400dd16072
commit d29723cb76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 11 deletions

View File

@ -150,6 +150,10 @@ CKeybindManager::CKeybindManager() {
if (!m_pLastLongPressKeybind || g_pSeatManager->keyboard.expired()) if (!m_pLastLongPressKeybind || g_pSeatManager->keyboard.expired())
return; return;
const auto PACTIVEKEEB = g_pSeatManager->keyboard.lock();
if (!PACTIVEKEEB->allowBinds)
return;
const auto DISPATCHER = g_pKeybindManager->m_mDispatchers.find(m_pLastLongPressKeybind->handler); const auto DISPATCHER = g_pKeybindManager->m_mDispatchers.find(m_pLastLongPressKeybind->handler);
Debug::log(LOG, "Long press timeout passed, calling dispatcher."); Debug::log(LOG, "Long press timeout passed, calling dispatcher.");
@ -163,6 +167,10 @@ CKeybindManager::CKeybindManager() {
if (m_vActiveKeybinds.size() == 0 || g_pSeatManager->keyboard.expired()) if (m_vActiveKeybinds.size() == 0 || g_pSeatManager->keyboard.expired())
return; return;
const auto PACTIVEKEEB = g_pSeatManager->keyboard.lock();
if (!PACTIVEKEEB->allowBinds)
return;
for (const auto& k : m_vActiveKeybinds) { for (const auto& k : m_vActiveKeybinds) {
const auto DISPATCHER = g_pKeybindManager->m_mDispatchers.find(k->handler); const auto DISPATCHER = g_pKeybindManager->m_mDispatchers.find(k->handler);
@ -170,7 +178,6 @@ CKeybindManager::CKeybindManager() {
DISPATCHER->second(k->arg); DISPATCHER->second(k->arg);
} }
const auto PACTIVEKEEB = g_pSeatManager->keyboard.lock();
self->updateTimeout(std::chrono::milliseconds(1000 / PACTIVEKEEB->repeatRate)); self->updateTimeout(std::chrono::milliseconds(1000 / PACTIVEKEEB->repeatRate));
}, },
nullptr); nullptr);
@ -424,6 +431,9 @@ bool CKeybindManager::onKeyEvent(std::any event, SP<IKeyboard> pKeyboard) {
return true; return true;
} }
if (!pKeyboard->allowBinds)
return true;
if (!m_pXKBTranslationState) { if (!m_pXKBTranslationState) {
Debug::log(ERR, "BUG THIS: m_pXKBTranslationState nullptr!"); Debug::log(ERR, "BUG THIS: m_pXKBTranslationState nullptr!");
updateXKBTranslationState(); updateXKBTranslationState();
@ -432,10 +442,7 @@ bool CKeybindManager::onKeyEvent(std::any event, SP<IKeyboard> pKeyboard) {
return true; return true;
} }
auto e = std::any_cast<IKeyboard::SKeyEvent>(event); auto e = std::any_cast<IKeyboard::SKeyEvent>(event);
if (!pKeyboard->allowBinds)
return true;
const auto KEYCODE = e.keycode + 8; // Because to xkbcommon it's +8 from libinput 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) else if (SPECIALDISPATCHER && pressed)
m_vPressedSpecialBinds.emplace_back(k); m_vPressedSpecialBinds.emplace_back(k);
found = true;
// Should never happen, as we check in the ConfigManager, but oh well // Should never happen, as we check in the ConfigManager, but oh well
if (DISPATCHER == m_mDispatchers.end()) { if (DISPATCHER == m_mDispatchers.end()) {
Debug::log(ERR, "Invalid handler in a keybind! (handler {} does not exist)", k->handler); 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; m_iPassPressed = -1;
if (k->handler == "submap") { if (k->handler == "submap")
found = true; // don't process keybinds on submap change.
break; break;
}
} }
if (k->repeat) { if (k->repeat) {

View File

@ -1540,9 +1540,6 @@ uint32_t CInputManager::accumulateModsFromAllKBs() {
if (!kb->enabled) if (!kb->enabled)
continue; continue;
if (!kb->allowBinds)
continue;
finalMask |= kb->getModifiers(); finalMask |= kb->getModifiers();
} }