From d0a4a0e0d8ecc0a47c0bcfbf84c090cae8cee7af Mon Sep 17 00:00:00 2001 From: Sungyoon Cho Date: Wed, 15 May 2024 00:14:43 +0900 Subject: input: fix modifier and leds (#6062) --- src/managers/input/InputManager.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'src/managers/input/InputManager.cpp') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 1d09dbb9..958fb255 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -1239,6 +1239,26 @@ void CInputManager::destroyTabletPad(SP pad) { removeFromHIDs(pad); } +void CInputManager::updateKeyboardsLeds(SP pKeyboard) { + if (!pKeyboard) + return; + + auto keyboard = pKeyboard->wlr(); + + if (!keyboard || keyboard->xkb_state == nullptr) + return; + + uint32_t leds = 0; + for (uint32_t i = 0; i < WLR_LED_COUNT; ++i) { + if (xkb_state_led_index_is_active(keyboard->xkb_state, keyboard->led_indexes[i])) + leds |= (1 << i); + } + + for (auto& k : m_vKeyboards) { + k->updateLEDs(leds); + } +} + void CInputManager::onKeyboardKey(std::any event, SP pKeyboard) { if (!pKeyboard->enabled) return; @@ -1271,9 +1291,7 @@ void CInputManager::onKeyboardKey(std::any event, SP pKeyboard) { wlr_seat_keyboard_notify_key(g_pCompositor->m_sSeat.seat, e.timeMs, e.keycode, e.state); } - for (auto& k : m_vKeyboards) { - k->updateLEDs(); - } + updateKeyboardsLeds(pKeyboard); } } @@ -1299,9 +1317,7 @@ void CInputManager::onKeyboardMod(SP pKeyboard) { wlr_seat_keyboard_notify_modifiers(g_pCompositor->m_sSeat.seat, &MODS); } - for (auto& k : m_vKeyboards) { - k->updateLEDs(); - } + updateKeyboardsLeds(pKeyboard); if (PWLRKB->modifiers.group != pKeyboard->activeLayout) { pKeyboard->activeLayout = PWLRKB->modifiers.group; -- cgit v1.2.3