Add keyboard led update after keys/mod update

This commit is contained in:
Leftas 2022-11-12 13:12:37 +02:00
parent dd11434e90
commit 34a7f17956
No known key found for this signature in database
GPG key ID: 68981317EB17192D
2 changed files with 31 additions and 0 deletions

View file

@ -818,6 +818,31 @@ void CInputManager::destroyMouse(wlr_input_device* mouse) {
unconstrainMouse(); unconstrainMouse();
} }
void CInputManager::updateKeyboardsLeds(wlr_input_device* pKeyboard) {
auto keyboard = wlr_keyboard_from_input_device(pKeyboard);
if (keyboard->xkb_state == NULL) {
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& kb : m_lKeyboards) {
if ((kb.isVirtual && shouldIgnoreVirtualKeyboard(&kb)) || kb.keyboard == pKeyboard)
continue;
wlr_keyboard_led_update(wlr_keyboard_from_input_device(kb.keyboard), leds);
}
}
void CInputManager::onKeyboardKey(wlr_keyboard_key_event* e, SKeyboard* pKeyboard) { void CInputManager::onKeyboardKey(wlr_keyboard_key_event* e, SKeyboard* pKeyboard) {
bool passEvent = g_pKeybindManager->onKeyEvent(e, pKeyboard); bool passEvent = g_pKeybindManager->onKeyEvent(e, pKeyboard);
@ -834,6 +859,8 @@ void CInputManager::onKeyboardKey(wlr_keyboard_key_event* e, SKeyboard* pKeyboar
wlr_seat_set_keyboard(g_pCompositor->m_sSeat.seat, wlr_keyboard_from_input_device(pKeyboard->keyboard)); wlr_seat_set_keyboard(g_pCompositor->m_sSeat.seat, wlr_keyboard_from_input_device(pKeyboard->keyboard));
wlr_seat_keyboard_notify_key(g_pCompositor->m_sSeat.seat, e->time_msec, e->keycode, e->state); wlr_seat_keyboard_notify_key(g_pCompositor->m_sSeat.seat, e->time_msec, e->keycode, e->state);
} }
updateKeyboardsLeds(pKeyboard->keyboard);
} }
} }
@ -853,6 +880,8 @@ void CInputManager::onKeyboardMod(void* data, SKeyboard* pKeyboard) {
wlr_seat_keyboard_notify_modifiers(g_pCompositor->m_sSeat.seat, &MODS); wlr_seat_keyboard_notify_modifiers(g_pCompositor->m_sSeat.seat, &MODS);
} }
updateKeyboardsLeds(pKeyboard->keyboard);
const auto PWLRKB = wlr_keyboard_from_input_device(pKeyboard->keyboard); const auto PWLRKB = wlr_keyboard_from_input_device(pKeyboard->keyboard);
if (PWLRKB->modifiers.group != pKeyboard->activeLayout) { if (PWLRKB->modifiers.group != pKeyboard->activeLayout) {

View file

@ -115,6 +115,8 @@ public:
CInputMethodRelay m_sIMERelay; CInputMethodRelay m_sIMERelay;
void updateKeyboardsLeds(wlr_input_device* pKeyboard);
// for shared mods // for shared mods
uint32_t accumulateModsFromAllKBs(); uint32_t accumulateModsFromAllKBs();