mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-04 19:26:00 +01:00
update key state on key events to have mods working in drm
This commit is contained in:
parent
38895ce843
commit
1b025eee44
2 changed files with 10 additions and 2 deletions
|
@ -57,6 +57,7 @@ class IKeyboard : public IHID {
|
|||
void updateLEDs(uint32_t leds);
|
||||
uint32_t getModifiers();
|
||||
void updateModifiers(uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group);
|
||||
bool updateModifiersState(); // rets whether changed
|
||||
|
||||
bool active = false;
|
||||
bool enabled = true;
|
||||
|
@ -88,5 +89,4 @@ class IKeyboard : public IHID {
|
|||
|
||||
private:
|
||||
void clearManuallyAllocd();
|
||||
bool updateModifiersState(); // rets whether changed
|
||||
};
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "Keyboard.hpp"
|
||||
#include "../defines.hpp"
|
||||
#include "../Compositor.hpp"
|
||||
|
||||
#include <aquamarine/input/Input.hpp>
|
||||
|
||||
|
@ -29,7 +30,14 @@ CKeyboard::CKeyboard(SP<Aquamarine::IKeyboard> keeb) : keyboard(keeb) {
|
|||
});
|
||||
|
||||
listeners.key = keeb->events.key.registerListener([this](std::any d) {
|
||||
auto E = std::any_cast<Aquamarine::IKeyboard::SKeyEvent>(d);
|
||||
auto E = std::any_cast<Aquamarine::IKeyboard::SKeyEvent>(d);
|
||||
|
||||
uint32_t xkbKeycode = E.key + 8;
|
||||
xkb_state_update_key(xkbTranslationState, xkbKeycode, E.pressed ? XKB_KEY_DOWN : XKB_KEY_UP);
|
||||
|
||||
// we have to do this for DRM sessions, as they never send modifiers events
|
||||
if (g_pCompositor->m_pAqBackend->hasSession())
|
||||
updateModifiersState();
|
||||
|
||||
keyboardEvents.key.emit(SKeyEvent{
|
||||
.timeMs = E.timeMs,
|
||||
|
|
Loading…
Reference in a new issue