diff --git a/src/events/Events.cpp b/src/events/Events.cpp index 2fdea91..3fe80f3 100644 --- a/src/events/Events.cpp +++ b/src/events/Events.cpp @@ -78,6 +78,10 @@ void Events::handleCapabilities(void *data, wl_seat *wl_seat, uint32_t capabilit Debug::log(CRIT, "Hyprpicker cannot work without a pointer!"); g_pHyprpicker->finish(1); } + + if (capabilities & WL_SEAT_CAPABILITY_KEYBOARD) { + wl_keyboard_add_listener(wl_seat_get_keyboard(wl_seat), &keyboardListener, wl_seat); + } } void Events::handlePointerEnter(void *data, struct wl_pointer *wl_pointer, uint32_t serial, struct wl_surface *surface, wl_fixed_t surface_x, wl_fixed_t surface_y) { @@ -256,6 +260,28 @@ void Events::handlePointerButton(void *data, struct wl_pointer *wl_pointer, uint g_pHyprpicker->finish(); } +void Events::handleKeyboardKeymap(void* data, wl_keyboard* wl_keyboard, uint format, int fd, uint size) { + +} + +void Events::handleKeyboardKey(void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state) { + if (key == 1) // escape + g_pHyprpicker->finish(); +} + +void Events::handleKeyboardEnter(void* data, wl_keyboard* wl_keyboard, uint serial, wl_surface* surface, wl_array* keys) { + +} + +void Events::handleKeyboardLeave(void* data, wl_keyboard* wl_keyboard, uint serial, wl_surface* surface) { + +} + +void Events::handleKeyboardModifiers(void* data, wl_keyboard* wl_keyboard, uint serial, uint mods_depressed, uint mods_latched, uint mods_locked, uint group) { + +} + + void Events::handleFrameDone(void *data, struct wl_callback *callback, uint32_t time) { CLayerSurface* pLS = (CLayerSurface*)data; diff --git a/src/events/Events.hpp b/src/events/Events.hpp index bbf6a19..ddc40e1 100644 --- a/src/events/Events.hpp +++ b/src/events/Events.hpp @@ -33,6 +33,16 @@ namespace Events { void handlePointerLeave(void *data, struct wl_pointer *wl_pointer, uint32_t serial, struct wl_surface *surface); + void handleKeyboardKeymap(void* data, wl_keyboard* wl_keyboard, uint format, int fd, uint size); + + void handleKeyboardKey(void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state); + + void handleKeyboardEnter(void* data, wl_keyboard* wl_keyboard, uint serial, wl_surface* surface, wl_array* keys); + + void handleKeyboardLeave(void* data, wl_keyboard* wl_keyboard, uint serial, wl_surface* surface); + + void handleKeyboardModifiers(void* data, wl_keyboard* wl_keyboard, uint serial, uint mods_depressed, uint mods_latched, uint mods_locked, uint group); + void handleFrameDone(void *data, struct wl_callback *callback, uint32_t time); void handleBufferRelease(void *data, struct wl_buffer *wl_buffer); @@ -55,9 +65,11 @@ namespace Events { inline const wl_pointer_listener pointerListener = { .enter = handlePointerEnter, .leave = handlePointerLeave, .motion = handlePointerMotion, .button = handlePointerButton, .axis = handlePointerAxis }; + inline const wl_keyboard_listener keyboardListener = { .keymap = handleKeyboardKeymap, .enter = handleKeyboardEnter,.leave = handleKeyboardLeave, .key = handleKeyboardKey, .modifiers = handleKeyboardModifiers }; + inline const wl_callback_listener frameListener = { .done = handleFrameDone }; inline const wl_buffer_listener bufferListener = { .release = handleBufferRelease }; inline const zwlr_screencopy_frame_v1_listener screencopyListener = { .buffer = handleSCBuffer, .flags = handleSCFlags, .ready = handleSCReady, .failed = handleSCFailed }; -}; \ No newline at end of file +};