mirror of
https://github.com/hyprwm/Hyprland.git
synced 2024-12-24 08:03:36 +03:00
input manager progress
This commit is contained in:
parent
bc937e3e71
commit
854c827911
@ -158,26 +158,32 @@ void Events::listener_mapWindow(wl_listener* listener, void* data) {
|
|||||||
|
|
||||||
// test
|
// test
|
||||||
wlr_xdg_toplevel_set_size(PWINDOW->m_uSurface.xdg->toplevel, PMONITOR->vecSize.x, PMONITOR->vecSize.y);
|
wlr_xdg_toplevel_set_size(PWINDOW->m_uSurface.xdg->toplevel, PMONITOR->vecSize.x, PMONITOR->vecSize.y);
|
||||||
|
|
||||||
|
Debug::log(LOG, "Map request dispatched.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Events::listener_unmapWindow(wl_listener* listener, void* data) {
|
void Events::listener_unmapWindow(wl_listener* listener, void* data) {
|
||||||
|
CWindow* PWINDOW = wl_container_of(listener, PWINDOW, listen_mapWindow);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Events::listener_commitWindow(wl_listener* listener, void* data) {
|
void Events::listener_commitWindow(wl_listener* listener, void* data) {
|
||||||
|
CWindow* PWINDOW = wl_container_of(listener, PWINDOW, listen_mapWindow);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Events::listener_destroyWindow(wl_listener* listener, void* data) {
|
void Events::listener_destroyWindow(wl_listener* listener, void* data) {
|
||||||
|
CWindow* PWINDOW = wl_container_of(listener, PWINDOW, listen_mapWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Events::listener_setTitleWindow(wl_listener* listener, void* data) {
|
void Events::listener_setTitleWindow(wl_listener* listener, void* data) {
|
||||||
|
CWindow* PWINDOW = wl_container_of(listener, PWINDOW, listen_mapWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Events::listener_fullscreenWindow(wl_listener* listener, void* data) {
|
void Events::listener_fullscreenWindow(wl_listener* listener, void* data) {
|
||||||
|
CWindow* PWINDOW = wl_container_of(listener, PWINDOW, listen_mapWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Events::listener_mouseAxis(wl_listener* listener, void* data) {
|
void Events::listener_mouseAxis(wl_listener* listener, void* data) {
|
||||||
@ -188,6 +194,18 @@ void Events::listener_mouseButton(wl_listener* listener, void* data) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Events::listener_keyboardDestroy(wl_listener* listener, void* data) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Events::listener_keyboardKey(wl_listener* listener, void* data) {
|
||||||
|
g_pInputManager->onKeyboardKey((wlr_event_keyboard_key*)data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Events::listener_keyboardMod(wl_listener* listener, void* data) {
|
||||||
|
g_pInputManager->onKeyboardMod(data);
|
||||||
|
}
|
||||||
|
|
||||||
void Events::listener_mouseFrame(wl_listener* listener, void* data) {
|
void Events::listener_mouseFrame(wl_listener* listener, void* data) {
|
||||||
wlr_seat_pointer_notify_frame(g_pCompositor->m_sWLRSeat);
|
wlr_seat_pointer_notify_frame(g_pCompositor->m_sWLRSeat);
|
||||||
}
|
}
|
||||||
@ -206,7 +224,7 @@ void Events::listener_newInput(wl_listener* listener, void* data) {
|
|||||||
switch(DEVICE->type) {
|
switch(DEVICE->type) {
|
||||||
case WLR_INPUT_DEVICE_KEYBOARD:
|
case WLR_INPUT_DEVICE_KEYBOARD:
|
||||||
Debug::log(LOG, "Attached a keyboard with name %s", DEVICE->name);
|
Debug::log(LOG, "Attached a keyboard with name %s", DEVICE->name);
|
||||||
// TODO:
|
g_pInputManager->newKeyboard(DEVICE);
|
||||||
break;
|
break;
|
||||||
case WLR_INPUT_DEVICE_POINTER:
|
case WLR_INPUT_DEVICE_POINTER:
|
||||||
Debug::log(LOG, "Attached a mouse with name %s", DEVICE->name);
|
Debug::log(LOG, "Attached a mouse with name %s", DEVICE->name);
|
||||||
@ -223,10 +241,6 @@ void Events::listener_newInput(wl_listener* listener, void* data) {
|
|||||||
wlr_seat_set_capabilities(g_pCompositor->m_sWLRSeat, capabilities);
|
wlr_seat_set_capabilities(g_pCompositor->m_sWLRSeat, capabilities);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Events::listener_newKeyboard(wl_listener* listener, void* data) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Events::listener_newXDGSurface(wl_listener* listener, void* data) {
|
void Events::listener_newXDGSurface(wl_listener* listener, void* data) {
|
||||||
// A window got opened
|
// A window got opened
|
||||||
const auto XDGSURFACE = (wlr_xdg_surface*)data;
|
const auto XDGSURFACE = (wlr_xdg_surface*)data;
|
||||||
@ -244,13 +258,17 @@ void Events::listener_newXDGSurface(wl_listener* listener, void* data) {
|
|||||||
wl_signal_add(&XDGSURFACE->events.destroy, &PNEWWINDOW->listen_destroyWindow);
|
wl_signal_add(&XDGSURFACE->events.destroy, &PNEWWINDOW->listen_destroyWindow);
|
||||||
wl_signal_add(&XDGSURFACE->toplevel->events.set_title, &PNEWWINDOW->listen_setTitleWindow);
|
wl_signal_add(&XDGSURFACE->toplevel->events.set_title, &PNEWWINDOW->listen_setTitleWindow);
|
||||||
wl_signal_add(&XDGSURFACE->toplevel->events.request_fullscreen, &PNEWWINDOW->listen_fullscreenWindow);
|
wl_signal_add(&XDGSURFACE->toplevel->events.request_fullscreen, &PNEWWINDOW->listen_fullscreenWindow);
|
||||||
|
|
||||||
|
Debug::log(LOG, "New XDG Surface created.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Events::listener_outputMgrApply(wl_listener* listener, void* data) {
|
void Events::listener_outputMgrApply(wl_listener* listener, void* data) {
|
||||||
|
const auto CONFIG = (wlr_output_configuration_v1*)data;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Events::listener_outputMgrTest(wl_listener* listener, void* data) {
|
void Events::listener_outputMgrTest(wl_listener* listener, void* data) {
|
||||||
|
const auto CONFIG = (wlr_output_configuration_v1*)data;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,9 +277,11 @@ void Events::listener_requestMouse(wl_listener* listener, void* data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Events::listener_requestSetPrimarySel(wl_listener* listener, void* data) {
|
void Events::listener_requestSetPrimarySel(wl_listener* listener, void* data) {
|
||||||
|
const auto EVENT = (wlr_seat_request_set_primary_selection_event*)data;
|
||||||
|
wlr_seat_set_primary_selection(g_pCompositor->m_sWLRSeat, EVENT->source, EVENT->serial);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Events::listener_requestSetSel(wl_listener* listener, void* data) {
|
void Events::listener_requestSetSel(wl_listener* listener, void* data) {
|
||||||
|
const auto EVENT = (wlr_seat_request_set_selection_event*)data;
|
||||||
|
wlr_seat_set_selection(g_pCompositor->m_sWLRSeat, EVENT->source, EVENT->serial);
|
||||||
}
|
}
|
@ -26,8 +26,12 @@ namespace Events {
|
|||||||
LISTENER(mouseButton);
|
LISTENER(mouseButton);
|
||||||
LISTENER(mouseAxis);
|
LISTENER(mouseAxis);
|
||||||
LISTENER(mouseFrame);
|
LISTENER(mouseFrame);
|
||||||
|
|
||||||
LISTENER(newInput);
|
LISTENER(newInput);
|
||||||
LISTENER(newKeyboard);
|
|
||||||
|
LISTENER(keyboardKey);
|
||||||
|
LISTENER(keyboardMod);
|
||||||
|
LISTENER(keyboardDestroy);
|
||||||
|
|
||||||
LISTENER(requestMouse);
|
LISTENER(requestMouse);
|
||||||
LISTENER(requestSetSel);
|
LISTENER(requestSetSel);
|
||||||
|
@ -23,3 +23,11 @@ struct SRenderData {
|
|||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SKeyboard {
|
||||||
|
wlr_input_device* keyboard;
|
||||||
|
|
||||||
|
DYNLISTENER(keyboardMod);
|
||||||
|
DYNLISTENER(keyboardKey);
|
||||||
|
DYNLISTENER(keyboardDestroy);
|
||||||
|
};
|
@ -22,4 +22,36 @@ void CInputManager::onMouseWarp(wlr_event_pointer_motion_absolute* e) {
|
|||||||
|
|
||||||
Vector2D CInputManager::getMouseCoordsInternal() {
|
Vector2D CInputManager::getMouseCoordsInternal() {
|
||||||
return m_vMouseCoords;
|
return m_vMouseCoords;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CInputManager::newKeyboard(wlr_input_device* keyboard) {
|
||||||
|
m_dKeyboards.push_back(SKeyboard());
|
||||||
|
|
||||||
|
const auto PNEWKEYBOARD = &m_dKeyboards.back();
|
||||||
|
|
||||||
|
PNEWKEYBOARD->keyboard = keyboard;
|
||||||
|
|
||||||
|
xkb_rule_names rules;
|
||||||
|
|
||||||
|
const auto CONTEXT = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
||||||
|
const auto KEYMAP = xkb_keymap_new_from_names(CONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||||
|
|
||||||
|
wlr_keyboard_set_keymap(keyboard->keyboard, KEYMAP);
|
||||||
|
xkb_keymap_unref(KEYMAP);
|
||||||
|
xkb_context_unref(CONTEXT);
|
||||||
|
wlr_keyboard_set_repeat_info(keyboard->keyboard, 25, 600);
|
||||||
|
|
||||||
|
wl_signal_add(&keyboard->keyboard->events.modifiers, &PNEWKEYBOARD->listen_keyboardMod);
|
||||||
|
wl_signal_add(&keyboard->keyboard->events.key, &PNEWKEYBOARD->listen_keyboardKey);
|
||||||
|
wl_signal_add(&keyboard->events.destroy, &PNEWKEYBOARD->listen_keyboardDestroy);
|
||||||
|
|
||||||
|
wlr_seat_set_keyboard(g_pCompositor->m_sWLRSeat, keyboard);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CInputManager::onKeyboardKey(wlr_event_keyboard_key* event) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CInputManager::onKeyboardMod(void* data) {
|
||||||
|
|
||||||
}
|
}
|
@ -1,13 +1,18 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../defines.hpp"
|
#include "../defines.hpp"
|
||||||
|
#include <deque>
|
||||||
|
#include "../helpers/WLClasses.hpp"
|
||||||
|
|
||||||
class CInputManager {
|
class CInputManager {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void onMouseMoved(wlr_event_pointer_motion*);
|
void onMouseMoved(wlr_event_pointer_motion*);
|
||||||
void onMouseWarp(wlr_event_pointer_motion_absolute*);
|
void onMouseWarp(wlr_event_pointer_motion_absolute*);
|
||||||
|
void onKeyboardKey(wlr_event_keyboard_key*);
|
||||||
|
void onKeyboardMod(void*);
|
||||||
|
|
||||||
|
void newKeyboard(wlr_input_device*);
|
||||||
|
|
||||||
Vector2D getMouseCoordsInternal();
|
Vector2D getMouseCoordsInternal();
|
||||||
|
|
||||||
@ -15,6 +20,8 @@ private:
|
|||||||
Vector2D m_vMouseCoords = Vector2D(0,0);
|
Vector2D m_vMouseCoords = Vector2D(0,0);
|
||||||
Vector2D m_vWLRMouseCoords = Vector2D(0,0);
|
Vector2D m_vWLRMouseCoords = Vector2D(0,0);
|
||||||
|
|
||||||
|
std::deque<SKeyboard> m_dKeyboards;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::unique_ptr<CInputManager> g_pInputManager;
|
inline std::unique_ptr<CInputManager> g_pInputManager;
|
Loading…
Reference in New Issue
Block a user