Flesh out wl_seat and fix some bugs

This commit is contained in:
Drew DeVault 2017-04-25 19:33:13 -04:00
parent 5ca9d612f4
commit 1e8970b4a9
2 changed files with 46 additions and 5 deletions

View File

@ -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,
&registry_listener, backend->registry);
wl_registry_add_listener(backend->registry, &registry_listener, backend);
wl_display_dispatch(backend->remote_display);
wl_display_roundtrip(backend->remote_display);
}

View File

@ -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;
}