handle keys and focus

This commit is contained in:
vaxerski 2022-03-18 23:06:45 +01:00
parent 5811d968bf
commit dbf566c78a
4 changed files with 28 additions and 7 deletions

View file

@ -193,4 +193,6 @@ void CCompositor::focusWindow(CWindow* pWindow) {
g_pXWaylandManager->activateSurface(g_pXWaylandManager->getWindowSurface(m_pLastFocus), false);
m_pLastFocus = pWindow;
Debug::log(LOG, "Set focus to %x", pWindow);
}

View file

@ -203,6 +203,7 @@ void Events::listener_mapWindow(wl_listener* listener, void* data) {
// test
g_pXWaylandManager->setWindowSize(PWINDOW, PMONITOR->vecSize);
g_pCompositor->focusWindow(PWINDOW);
Debug::log(LOG, "Map request dispatched.");
}
@ -318,11 +319,13 @@ void Events::listener_surfaceXWayland(wl_listener* listener, void* data) {
}
void Events::listener_keyboardKey(wl_listener* listener, void* data) {
g_pInputManager->onKeyboardKey((wlr_event_keyboard_key*)data);
SKeyboard* PKEYBOARD = wl_container_of(listener, PKEYBOARD, listen_keyboardKey);
g_pInputManager->onKeyboardKey((wlr_event_keyboard_key*)data, PKEYBOARD);
}
void Events::listener_keyboardMod(wl_listener* listener, void* data) {
g_pInputManager->onKeyboardMod(data);
SKeyboard* PKEYBOARD = wl_container_of(listener, PKEYBOARD, listen_keyboardMod);
g_pInputManager->onKeyboardMod(data, PKEYBOARD);
}
void Events::listener_mouseFrame(wl_listener* listener, void* data) {

View file

@ -89,10 +89,26 @@ void CInputManager::newMouse(wlr_input_device* mouse) {
wlr_cursor_attach_input_device(g_pCompositor->m_sWLRCursor, mouse);
}
void CInputManager::onKeyboardKey(wlr_event_keyboard_key* event) {
void CInputManager::onKeyboardKey(wlr_event_keyboard_key* e, SKeyboard* pKeyboard) {
const auto KEYCODE = e->keycode + 8; // Because to xkbcommon it's +8 from libinput
const xkb_keysym_t* keysyms;
int syms = xkb_state_key_get_syms(pKeyboard->keyboard->keyboard->xkb_state, KEYCODE, &keysyms);
const auto MODS = wlr_keyboard_get_modifiers(pKeyboard->keyboard->keyboard);
wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sWLRSeat);
if (e->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
// TODO: keybinds
}
void CInputManager::onKeyboardMod(void* data) {
wlr_seat_set_keyboard(g_pCompositor->m_sWLRSeat, pKeyboard->keyboard);
wlr_seat_keyboard_notify_key(g_pCompositor->m_sWLRSeat, e->time_msec, e->keycode, e->state);
}
void CInputManager::onKeyboardMod(void* data, SKeyboard* pKeyboard) {
wlr_seat_set_keyboard(g_pCompositor->m_sWLRSeat, pKeyboard->keyboard);
wlr_seat_keyboard_notify_modifiers(g_pCompositor->m_sWLRSeat, &pKeyboard->keyboard->keyboard->modifiers);
}

View file

@ -10,8 +10,8 @@ public:
void onMouseMoved(wlr_event_pointer_motion*);
void onMouseWarp(wlr_event_pointer_motion_absolute*);
void onMouseButton(wlr_event_pointer_button*);
void onKeyboardKey(wlr_event_keyboard_key*);
void onKeyboardMod(void*);
void onKeyboardKey(wlr_event_keyboard_key*, SKeyboard*);
void onKeyboardMod(void*, SKeyboard*);
void newKeyboard(wlr_input_device*);
void newMouse(wlr_input_device*);