diff options
-rw-r--r-- | backend/wayland/registry.c | 15 | ||||
-rw-r--r-- | backend/wayland/wl_seat.c | 36 |
2 files changed, 46 insertions, 5 deletions
diff --git a/backend/wayland/registry.c b/backend/wayland/registry.c index a0cfb91f..b3955bc1 100644 --- a/backend/wayland/registry.c +++ b/backend/wayland/registry.c @@ -21,7 +21,9 @@ static void registry_wl_seat(struct wlr_wl_backend *backend, goto error; } seat->wl_seat = wl_seat; + wl_seat_set_user_data(wl_seat, backend); wl_seat_add_listener(wl_seat, &seat_listener, seat); + return; error: //wlr_wl_seat_free(seat); TODO return; @@ -32,13 +34,21 @@ static void registry_wl_output(struct wlr_wl_backend *backend, struct wlr_wl_output *output; if (!(output = calloc(sizeof(struct wlr_wl_output), 1))) { wlr_log(L_ERROR, "Failed to allocate wlr_wl_output"); - return; + goto error; + } + if (!(output->modes = list_create())) { + wlr_log(L_ERROR, "Failed to allocate wlr_wl_output"); + goto error; } output->wl_output = wl_output; output->scale = 1; list_add(backend->outputs, output); wl_output_set_user_data(wl_output, backend); wl_output_add_listener(wl_output, &output_listener, output); + return; +error: + //wlr_wl_output_free(output); TODO + return; } static void registry_global(void *data, struct wl_registry *registry, @@ -77,8 +87,7 @@ static const struct wl_registry_listener registry_listener = { }; void wlr_wlb_registry_poll(struct wlr_wl_backend *backend) { - wl_registry_add_listener(backend->registry, - ®istry_listener, backend->registry); + wl_registry_add_listener(backend->registry, ®istry_listener, backend); wl_display_dispatch(backend->remote_display); wl_display_roundtrip(backend->remote_display); } diff --git a/backend/wayland/wl_seat.c b/backend/wayland/wl_seat.c index 489c1e39..5269d5fe 100644 --- a/backend/wayland/wl_seat.c +++ b/backend/wayland/wl_seat.c @@ -1,15 +1,47 @@ +#include <assert.h> +#include <stdlib.h> #include <stdint.h> #include <wayland-client.h> #include "backend/wayland.h" +#include "common/log.h" static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat, enum wl_seat_capability caps) { - //struct wlr_wl_seat *seat = data; - // TODO + struct wlr_wl_seat *seat = data; + assert(seat->wl_seat == wl_seat); + struct wlr_wl_backend *backend = wl_seat_get_user_data(wl_seat); + assert(backend); + + if ((caps & WL_SEAT_CAPABILITY_POINTER)) { + struct wl_pointer *wl_pointer = wl_seat_get_pointer(wl_seat); + struct wlr_wl_pointer *pointer; + if (!(pointer = calloc(sizeof(struct wlr_wl_pointer), 1))) { + wl_pointer_destroy(wl_pointer); + wlr_log(L_ERROR, "Unable to allocate wlr_wl_pointer"); + return; + } + pointer->wl_pointer = wl_pointer; + //wl_pointer_add_listener(wl_pointer, &pointer_listener, backend->registry); TODO + } + + if ((caps & WL_SEAT_CAPABILITY_KEYBOARD)) { + struct wl_keyboard *wl_keyboard = wl_seat_get_keyboard(wl_seat); + struct wlr_wl_keyboard *keyboard; + if (!(keyboard = calloc(sizeof(struct wlr_wl_pointer), 1))) { + wl_keyboard_destroy(wl_keyboard); + wlr_log(L_ERROR, "Unable to allocate wlr_wl_keyboard"); + return; + } + keyboard->wl_keyboard = wl_keyboard; + //wl_keyboard_add_listener(wl_keyboard, &keyboard_listener, backend->registry); TODO + } + + // TODO: touch } static void seat_handle_name(void *data, struct wl_seat *wl_seat, const char *name) { struct wlr_wl_seat *seat = data; + assert(seat->wl_seat == wl_seat); seat->name = name; } |