mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-22 16:05:58 +01:00
input: fix keyboard leds with multiple keyboards (#7079)
This commit is contained in:
parent
bc86afea7e
commit
9b6ae4f77b
3 changed files with 34 additions and 16 deletions
|
@ -274,9 +274,9 @@ std::string IKeyboard::getActiveLayout() {
|
|||
return "none";
|
||||
}
|
||||
|
||||
void IKeyboard::updateLEDs() {
|
||||
std::optional<uint32_t> IKeyboard::getLEDs() {
|
||||
if (xkbState == nullptr)
|
||||
return;
|
||||
return {};
|
||||
|
||||
uint32_t leds = 0;
|
||||
for (uint32_t i = 0; i < LED_COUNT; ++i) {
|
||||
|
@ -284,7 +284,16 @@ void IKeyboard::updateLEDs() {
|
|||
leds |= (1 << i);
|
||||
}
|
||||
|
||||
updateLEDs(leds);
|
||||
return leds;
|
||||
}
|
||||
|
||||
void IKeyboard::updateLEDs() {
|
||||
std::optional<uint32_t> leds = getLEDs();
|
||||
|
||||
if (!leds.has_value())
|
||||
return;
|
||||
|
||||
updateLEDs(leds.value());
|
||||
}
|
||||
|
||||
void IKeyboard::updateLEDs(uint32_t leds) {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "../macros.hpp"
|
||||
#include "../helpers/math/Math.hpp"
|
||||
|
||||
#include <optional>
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
|
||||
AQUAMARINE_FORWARD(IKeyboard);
|
||||
|
@ -64,6 +65,7 @@ class IKeyboard : public IHID {
|
|||
void setKeymap(const SStringRuleNames& rules);
|
||||
void updateXKBTranslationState(xkb_keymap* const keymap = nullptr);
|
||||
std::string getActiveLayout();
|
||||
std::optional<uint32_t> getLEDs();
|
||||
void updateLEDs();
|
||||
void updateLEDs(uint32_t leds);
|
||||
uint32_t getModifiers();
|
||||
|
|
|
@ -1265,7 +1265,14 @@ void CInputManager::updateKeyboardsLeds(SP<IKeyboard> pKeyboard) {
|
|||
if (!pKeyboard)
|
||||
return;
|
||||
|
||||
pKeyboard->updateLEDs();
|
||||
std::optional<uint32_t> leds = pKeyboard->getLEDs();
|
||||
|
||||
if (!leds.has_value())
|
||||
return;
|
||||
|
||||
for (auto& k : m_vKeyboards) {
|
||||
k->updateLEDs(leds.value());
|
||||
}
|
||||
}
|
||||
|
||||
void CInputManager::onKeyboardKey(std::any event, SP<IKeyboard> pKeyboard) {
|
||||
|
|
Loading…
Reference in a new issue