mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-05 06:25:59 +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);
|
void updateLEDs(uint32_t leds);
|
||||||
uint32_t getModifiers();
|
uint32_t getModifiers();
|
||||||
void updateModifiers(uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group);
|
void updateModifiers(uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group);
|
||||||
|
bool updateModifiersState(); // rets whether changed
|
||||||
|
|
||||||
bool active = false;
|
bool active = false;
|
||||||
bool enabled = true;
|
bool enabled = true;
|
||||||
|
@ -88,5 +89,4 @@ class IKeyboard : public IHID {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void clearManuallyAllocd();
|
void clearManuallyAllocd();
|
||||||
bool updateModifiersState(); // rets whether changed
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "Keyboard.hpp"
|
#include "Keyboard.hpp"
|
||||||
#include "../defines.hpp"
|
#include "../defines.hpp"
|
||||||
|
#include "../Compositor.hpp"
|
||||||
|
|
||||||
#include <aquamarine/input/Input.hpp>
|
#include <aquamarine/input/Input.hpp>
|
||||||
|
|
||||||
|
@ -31,6 +32,13 @@ CKeyboard::CKeyboard(SP<Aquamarine::IKeyboard> keeb) : keyboard(keeb) {
|
||||||
listeners.key = keeb->events.key.registerListener([this](std::any d) {
|
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{
|
keyboardEvents.key.emit(SKeyEvent{
|
||||||
.timeMs = E.timeMs,
|
.timeMs = E.timeMs,
|
||||||
.keycode = E.key,
|
.keycode = E.key,
|
||||||
|
|
Loading…
Reference in a new issue