wlroots-hyprland/backend/wayland/wl_seat.c

56 lines
1.7 KiB
C
Raw Normal View History

#define _XOPEN_SOURCE 500
2017-04-26 01:33:13 +02:00
#include <assert.h>
#include <stdlib.h>
2017-04-26 01:19:21 +02:00
#include <stdint.h>
#include <string.h>
2017-04-26 01:19:21 +02:00
#include <wayland-client.h>
#include "backend/wayland.h"
2017-04-26 01:33:13 +02:00
#include "common/log.h"
2017-04-26 01:19:21 +02:00
static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
enum wl_seat_capability caps) {
2017-04-26 01:33:13 +02:00
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)) {
wlr_log(L_DEBUG, "seat %p offered pointer", wl_seat);
2017-04-26 01:33:13 +02:00
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)) {
wlr_log(L_DEBUG, "seat %p offered keyboard", wl_seat);
2017-04-26 01:33:13 +02:00
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
2017-04-26 01:19:21 +02:00
}
static void seat_handle_name(void *data, struct wl_seat *wl_seat, const char *name) {
struct wlr_wl_seat *seat = data;
2017-04-26 01:33:13 +02:00
assert(seat->wl_seat == wl_seat);
seat->name = strdup(name);
2017-04-26 01:19:21 +02:00
}
const struct wl_seat_listener seat_listener = {
.capabilities = seat_handle_capabilities,
.name = seat_handle_name,
};