aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorVaxry <[email protected]>2022-11-12 21:00:38 +0000
committerGitHub <[email protected]>2022-11-12 21:00:38 +0000
commit2cdabf581e98c474f2fa602f8340d91b192df282 (patch)
treebe913263bd9e3ff9e5e31c1cc9859b6736ba504b
parentdd11434e901ec616a5acc1008bb1ce4c1ef33a65 (diff)
parent34a7f17956146077b964d68a7e9be5d9a8742086 (diff)
downloadHyprland-2cdabf581e98c474f2fa602f8340d91b192df282.tar.gz
Hyprland-2cdabf581e98c474f2fa602f8340d91b192df282.zip
Merge pull request #997 from leftas/main
Add keyboards' leds update on Key/Mod press
-rw-r--r--src/managers/input/InputManager.cpp29
-rw-r--r--src/managers/input/InputManager.hpp2
2 files changed, 31 insertions, 0 deletions
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index adca5b14..93e83035 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -818,6 +818,31 @@ void CInputManager::destroyMouse(wlr_input_device* mouse) {
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) {
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_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);
}
+ updateKeyboardsLeds(pKeyboard->keyboard);
+
const auto PWLRKB = wlr_keyboard_from_input_device(pKeyboard->keyboard);
if (PWLRKB->modifiers.group != pKeyboard->activeLayout) {
diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp
index 18786758..4885277b 100644
--- a/src/managers/input/InputManager.hpp
+++ b/src/managers/input/InputManager.hpp
@@ -115,6 +115,8 @@ public:
CInputMethodRelay m_sIMERelay;
+ void updateKeyboardsLeds(wlr_input_device* pKeyboard);
+
// for shared mods
uint32_t accumulateModsFromAllKBs();