From f72c237d85f406f4a6a4ca181ee35399ca8c37bc Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 16 Dec 2022 17:20:51 +0000 Subject: [PATCH] add disabling keyboards --- src/helpers/WLClasses.hpp | 1 + src/managers/input/InputManager.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/helpers/WLClasses.hpp b/src/helpers/WLClasses.hpp index 3da363f9..417a9d06 100644 --- a/src/helpers/WLClasses.hpp +++ b/src/helpers/WLClasses.hpp @@ -103,6 +103,7 @@ struct SKeyboard { bool isVirtual = false; bool active = false; + bool enabled = true; xkb_layout_index_t activeLayout = 0; diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index d3cd9079..6815f36b 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -555,6 +555,10 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) { const auto VARIANT = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_variant") : g_pConfigManager->getString("input:kb_variant"); const auto OPTIONS = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_options") : g_pConfigManager->getString("input:kb_options"); + const auto ENABLED = HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "enabled") : true; + + pKeyboard->enabled = ENABLED; + try { if (NUMLOCKON == pKeyboard->numlockOn && REPEATDELAY == pKeyboard->repeatDelay && REPEATRATE == pKeyboard->repeatRate && RULES != "" && RULES == pKeyboard->currentRules.rules && MODEL == pKeyboard->currentRules.model && LAYOUT == pKeyboard->currentRules.layout && @@ -847,6 +851,9 @@ void CInputManager::updateKeyboardsLeds(wlr_input_device* pKeyboard) { } void CInputManager::onKeyboardKey(wlr_keyboard_key_event* e, SKeyboard* pKeyboard) { + if (!pKeyboard->enabled) + return; + bool passEvent = g_pKeybindManager->onKeyEvent(e, pKeyboard); wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat); @@ -868,6 +875,9 @@ void CInputManager::onKeyboardKey(wlr_keyboard_key_event* e, SKeyboard* pKeyboar } void CInputManager::onKeyboardMod(void* data, SKeyboard* pKeyboard) { + if (!pKeyboard->enabled) + return; + const auto PIMEGRAB = m_sIMERelay.getIMEKeyboardGrab(pKeyboard); const auto ALLMODS = accumulateModsFromAllKBs(); @@ -1053,6 +1063,9 @@ uint32_t CInputManager::accumulateModsFromAllKBs() { if (kb.isVirtual && shouldIgnoreVirtualKeyboard(&kb)) continue; + if (!kb.enabled) + continue; + finalMask |= wlr_keyboard_get_modifiers(wlr_keyboard_from_input_device(kb.keyboard)); }