diff options
| -rw-r--r-- | keyboard.c | 12 | ||||
| -rw-r--r-- | layer_surface.c | 2 | ||||
| -rw-r--r-- | main.c | 2 | ||||
| -rw-r--r-- | pointer.c | 2 | ||||
| -rw-r--r-- | registry.c | 6 | ||||
| -rw-r--r-- | seat.c | 6 | ||||
| -rw-r--r-- | wayland.h | 2 |
7 files changed, 21 insertions, 11 deletions
@@ -11,6 +11,8 @@ void setup_keyboard(client_state* state) { wl_keyboard_add_listener(state->keyboard, &keyboard_listener, state); } +// listeners + void wl_keyboard_keymap(void *data, struct wl_keyboard *wl_keyboard, uint32_t format, int32_t fd, uint32_t size) { client_state* state = data; @@ -69,12 +71,12 @@ void wl_keyboard_leave(void *data, struct wl_keyboard *wl_keyboard, void wl_keyboard_key(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t key_state) { - client_state *state = data; + client_state *state = data; - xkb_keysym_t keysym = xkb_state_key_get_one_sym(state->xkb_state, key + 8); - if (keysym == XKB_KEY_q) { - state->running = false; - } + xkb_keysym_t keysym = xkb_state_key_get_one_sym(state->xkb_state, key + 8); + if (keysym == XKB_KEY_q) { + state->running = false; + } } void wl_keyboard_modifiers(void *data, struct wl_keyboard *wl_keyboard, diff --git a/layer_surface.c b/layer_surface.c index 0463677..11e369c 100644 --- a/layer_surface.c +++ b/layer_surface.c @@ -20,6 +20,8 @@ void setup_surface(client_state* state) { wl_display_roundtrip(state->display); } +// listeners + void configure(void *data, struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, uint32_t serial, uint32_t width, uint32_t height) { client_state* state = data; state->width = width; @@ -1,4 +1,3 @@ -#include <EGL/egl.h> #include <stdio.h> #include "state.h" @@ -16,6 +15,7 @@ int main() { } setup_registry(&state); + setup_seat(&state); setup_surface(&state); if (!init_gl(&state)) { @@ -9,6 +9,8 @@ void setup_pointer(client_state* state) { wl_pointer_add_listener(state->pointer, &pointer_listener, state); } +// listeners + void enter(void *data, struct wl_pointer *pointer, uint32_t serial, struct wl_surface *surface, wl_fixed_t fixed_surface_x, wl_fixed_t fixed_surface_y) { client_state* state = data; @@ -2,7 +2,6 @@ #include <string.h> #include "./state.h" -#include "wayland.h" struct wl_registry_listener registry_listener; @@ -11,6 +10,9 @@ void setup_registry(client_state* state) { wl_registry_add_listener(state->registry, ®istry_listener, state); wl_display_roundtrip(state->display); } + +// listeners + void global(void *data, struct wl_registry *wl_registry, uint32_t name, const char *interface, uint32_t version) { client_state* state = data; @@ -20,7 +22,7 @@ void global(void *data, struct wl_registry *wl_registry, uint32_t name, const ch state->compositor = wl_registry_bind(wl_registry, name, &wl_compositor_interface, 1); } else if (!strcmp(interface, wl_seat_interface.name)) { - setup_seat(state, name); + state->seat = wl_registry_bind(state->registry, name, &wl_seat_interface, 1); } else if (!strcmp(interface, zwlr_layer_shell_v1_interface.name)) { state->layer_shell = wl_registry_bind(wl_registry, name, &zwlr_layer_shell_v1_interface, version); @@ -4,11 +4,13 @@ struct wl_seat_listener seat_listener; -void setup_seat(client_state* state, uint32_t name) { - state->seat = wl_registry_bind(state->registry, name, &wl_seat_interface, 1); +void setup_seat(client_state* state) { wl_seat_add_listener(state->seat, &seat_listener, state); + wl_display_roundtrip(state->display); } +// listeners + void capabilities(void *data, struct wl_seat *wl_seat, uint32_t capabilities) { client_state* state = data; @@ -5,7 +5,7 @@ void setup_registry(client_state* state); void setup_surface(client_state* state); -void setup_seat(client_state* state, uint32_t name); +void setup_seat(client_state* state); void setup_pointer(client_state* state); void setup_keyboard(client_state* state); |
