mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-30 03:06:00 +01:00
input: fix modifier and leds (#6062)
This commit is contained in:
parent
1584679004
commit
d0a4a0e0d8
5 changed files with 36 additions and 8 deletions
|
@ -131,8 +131,17 @@ void IKeyboard::updateLEDs() {
|
||||||
leds |= (1 << i);
|
leds |= (1 << i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateLEDs(leds);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IKeyboard::updateLEDs(uint32_t leds) {
|
||||||
|
auto keyboard = wlr();
|
||||||
|
|
||||||
|
if (!keyboard || keyboard->xkb_state == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
if (isVirtual() && g_pInputManager->shouldIgnoreVirtualKeyboard(self.lock()))
|
if (isVirtual() && g_pInputManager->shouldIgnoreVirtualKeyboard(self.lock()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wlr_keyboard_led_update(wlr(), leds);
|
wlr_keyboard_led_update(keyboard, leds);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ class IKeyboard : public IHID {
|
||||||
void updateXKBTranslationState(xkb_keymap* const keymap = nullptr);
|
void updateXKBTranslationState(xkb_keymap* const keymap = nullptr);
|
||||||
std::string getActiveLayout();
|
std::string getActiveLayout();
|
||||||
void updateLEDs();
|
void updateLEDs();
|
||||||
|
void updateLEDs(uint32_t leds);
|
||||||
|
|
||||||
bool active = false;
|
bool active = false;
|
||||||
bool enabled = true;
|
bool enabled = true;
|
||||||
|
|
|
@ -1239,6 +1239,26 @@ void CInputManager::destroyTabletPad(SP<CTabletPad> pad) {
|
||||||
removeFromHIDs(pad);
|
removeFromHIDs(pad);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CInputManager::updateKeyboardsLeds(SP<IKeyboard> 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<IKeyboard> pKeyboard) {
|
void CInputManager::onKeyboardKey(std::any event, SP<IKeyboard> pKeyboard) {
|
||||||
if (!pKeyboard->enabled)
|
if (!pKeyboard->enabled)
|
||||||
return;
|
return;
|
||||||
|
@ -1271,9 +1291,7 @@ void CInputManager::onKeyboardKey(std::any event, SP<IKeyboard> pKeyboard) {
|
||||||
wlr_seat_keyboard_notify_key(g_pCompositor->m_sSeat.seat, e.timeMs, e.keycode, e.state);
|
wlr_seat_keyboard_notify_key(g_pCompositor->m_sSeat.seat, e.timeMs, e.keycode, e.state);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& k : m_vKeyboards) {
|
updateKeyboardsLeds(pKeyboard);
|
||||||
k->updateLEDs();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1299,9 +1317,7 @@ void CInputManager::onKeyboardMod(SP<IKeyboard> pKeyboard) {
|
||||||
wlr_seat_keyboard_notify_modifiers(g_pCompositor->m_sSeat.seat, &MODS);
|
wlr_seat_keyboard_notify_modifiers(g_pCompositor->m_sSeat.seat, &MODS);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& k : m_vKeyboards) {
|
updateKeyboardsLeds(pKeyboard);
|
||||||
k->updateLEDs();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PWLRKB->modifiers.group != pKeyboard->activeLayout) {
|
if (PWLRKB->modifiers.group != pKeyboard->activeLayout) {
|
||||||
pKeyboard->activeLayout = PWLRKB->modifiers.group;
|
pKeyboard->activeLayout = PWLRKB->modifiers.group;
|
||||||
|
|
|
@ -114,6 +114,7 @@ class CInputManager {
|
||||||
|
|
||||||
void updateDragIcon();
|
void updateDragIcon();
|
||||||
void updateCapabilities();
|
void updateCapabilities();
|
||||||
|
void updateKeyboardsLeds(SP<IKeyboard>);
|
||||||
|
|
||||||
void setClickMode(eClickBehaviorMode);
|
void setClickMode(eClickBehaviorMode);
|
||||||
eClickBehaviorMode getClickMode();
|
eClickBehaviorMode getClickMode();
|
||||||
|
|
|
@ -53,7 +53,8 @@ void CInputMethodKeyboardGrabV2::sendKeyboardData(wlr_keyboard* keyboard) {
|
||||||
|
|
||||||
close(keymapFD);
|
close(keymapFD);
|
||||||
|
|
||||||
sendMods(0, 0, 0, 0);
|
const auto MODS = keyboard->modifiers;
|
||||||
|
sendMods(MODS.depressed, MODS.latched, MODS.locked, MODS.group);
|
||||||
|
|
||||||
resource->sendRepeatInfo(keyboard->repeat_info.rate, keyboard->repeat_info.delay);
|
resource->sendRepeatInfo(keyboard->repeat_info.rate, keyboard->repeat_info.delay);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue