mirror of
https://github.com/hyprwm/hyprpicker.git
synced 2024-11-16 16:15:58 +01:00
Add keyboard listener and listen to escape to quit hyprpicker (#20)
* Add keyboard listener and listen to escape for quit
This commit is contained in:
parent
aa3c2acd59
commit
422b36c125
2 changed files with 39 additions and 1 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -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,6 +65,8 @@ 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 };
|
||||
|
|
Loading…
Reference in a new issue