mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-22 15:45:59 +01:00
keyboard fix
This commit is contained in:
parent
7f8648fc8b
commit
5971576a50
4 changed files with 30 additions and 8 deletions
|
@ -257,10 +257,6 @@ void Events::listener_mouseButton(wl_listener* listener, void* data) {
|
|||
g_pInputManager->onMouseButton((wlr_event_pointer_button*)data);
|
||||
}
|
||||
|
||||
void Events::listener_keyboardDestroy(wl_listener* listener, void* data) {
|
||||
|
||||
}
|
||||
|
||||
void Events::listener_activateX11(wl_listener* listener, void* data) {
|
||||
CWindow* PWINDOW = wl_container_of(listener, PWINDOW, listen_activateX11);
|
||||
|
||||
|
@ -319,6 +315,13 @@ void Events::listener_surfaceXWayland(wl_listener* listener, void* data) {
|
|||
Debug::log(LOG, "New XWayland Surface created.");
|
||||
}
|
||||
|
||||
void Events::listener_keyboardDestroy(wl_listener* listener, void* data) {
|
||||
SKeyboard* PKEYBOARD = wl_container_of(listener, PKEYBOARD, listen_keyboardDestroy);
|
||||
g_pInputManager->destroyKeyboard(PKEYBOARD);
|
||||
|
||||
Debug::log(LOG, "Destroyed keyboard %x", PKEYBOARD);
|
||||
}
|
||||
|
||||
void Events::listener_keyboardKey(wl_listener* listener, void* data) {
|
||||
SKeyboard* PKEYBOARD = wl_container_of(listener, PKEYBOARD, listen_keyboardKey);
|
||||
g_pInputManager->onKeyboardKey((wlr_event_keyboard_key*)data, PKEYBOARD);
|
||||
|
|
|
@ -38,4 +38,9 @@ struct SKeyboard {
|
|||
DYNLISTENER(keyboardMod);
|
||||
DYNLISTENER(keyboardKey);
|
||||
DYNLISTENER(keyboardDestroy);
|
||||
|
||||
// For the list lookup
|
||||
bool operator==(const SKeyboard& rhs) {
|
||||
return keyboard == rhs.keyboard;
|
||||
}
|
||||
};
|
|
@ -52,9 +52,9 @@ Vector2D CInputManager::getMouseCoordsInternal() {
|
|||
}
|
||||
|
||||
void CInputManager::newKeyboard(wlr_input_device* keyboard) {
|
||||
m_dKeyboards.push_back(SKeyboard());
|
||||
m_lKeyboards.push_back(SKeyboard());
|
||||
|
||||
const auto PNEWKEYBOARD = &m_dKeyboards.back();
|
||||
const auto PNEWKEYBOARD = &m_lKeyboards.back();
|
||||
|
||||
PNEWKEYBOARD->keyboard = keyboard;
|
||||
|
||||
|
@ -89,6 +89,18 @@ void CInputManager::newMouse(wlr_input_device* mouse) {
|
|||
wlr_cursor_attach_input_device(g_pCompositor->m_sWLRCursor, mouse);
|
||||
}
|
||||
|
||||
void CInputManager::destroyKeyboard(SKeyboard* pKeyboard) {
|
||||
wl_list_remove(&pKeyboard->listen_keyboardMod.link);
|
||||
wl_list_remove(&pKeyboard->listen_keyboardKey.link);
|
||||
wl_list_remove(&pKeyboard->listen_keyboardDestroy.link);
|
||||
|
||||
m_lKeyboards.remove(*pKeyboard);
|
||||
}
|
||||
|
||||
void CInputManager::destroyMouse(wlr_input_device* mouse) {
|
||||
//
|
||||
}
|
||||
|
||||
void CInputManager::onKeyboardKey(wlr_event_keyboard_key* e, SKeyboard* pKeyboard) {
|
||||
const auto KEYCODE = e->keycode + 8; // Because to xkbcommon it's +8 from libinput
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "../defines.hpp"
|
||||
#include <deque>
|
||||
#include <list>
|
||||
#include "../helpers/WLClasses.hpp"
|
||||
|
||||
class CInputManager {
|
||||
|
@ -15,6 +15,8 @@ public:
|
|||
|
||||
void newKeyboard(wlr_input_device*);
|
||||
void newMouse(wlr_input_device*);
|
||||
void destroyKeyboard(SKeyboard*);
|
||||
void destroyMouse(wlr_input_device*);
|
||||
|
||||
Vector2D getMouseCoordsInternal();
|
||||
|
||||
|
@ -22,7 +24,7 @@ private:
|
|||
Vector2D m_vMouseCoords = Vector2D(0,0);
|
||||
Vector2D m_vWLRMouseCoords = Vector2D(0,0);
|
||||
|
||||
std::deque<SKeyboard> m_dKeyboards;
|
||||
std::list<SKeyboard> m_lKeyboards;
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue