backend/wayland: Bind seat listener to wlr_wl_seat

This commit is contained in:
Mykola Orliuk 2020-10-03 20:48:11 +02:00 committed by Simon Ser
parent e06c9e43af
commit 40bfd9f8f7
4 changed files with 16 additions and 18 deletions

View file

@ -164,8 +164,7 @@ static bool backend_start(struct wlr_backend *backend) {
}
if (wl->tablet_manager) {
wl_add_tablet_seat(wl->tablet_manager,
seat->wl_seat, wl);
wl_add_tablet_seat(wl->tablet_manager, seat);
}
}

View file

@ -380,8 +380,9 @@ bool create_wl_seat(struct wl_seat *wl_seat, struct wlr_wl_backend *wl) {
return false;
}
seat->wl_seat = wl_seat;
seat->backend = wl;
wl->seat = seat;
wl_seat_add_listener(wl_seat, &seat_listener, wl);
wl_seat_add_listener(wl_seat, &seat_listener, seat);
return true;
}
@ -408,11 +409,6 @@ void destroy_wl_seats(struct wlr_wl_backend *wl) {
free(seat);
}
static struct wlr_wl_seat *backend_get_seat(struct wlr_wl_backend *backend, struct wl_seat *wl_seat) {
assert(backend->seat && backend->seat->wl_seat == wl_seat);
return backend->seat;
}
static struct wlr_wl_seat *input_device_get_seat(struct wlr_input_device *wlr_dev) {
struct wlr_wl_input_device *dev =
get_wl_input_device_from_input_device(wlr_dev);
@ -726,8 +722,8 @@ void create_wl_touch(struct wl_touch *wl_touch, struct wlr_wl_backend *wl) {
static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
enum wl_seat_capability caps) {
struct wlr_wl_backend *backend = data;
struct wlr_wl_seat *seat = backend_get_seat(backend, wl_seat);
struct wlr_wl_seat *seat = data;
struct wlr_wl_backend *backend = seat->backend;
if ((caps & WL_SEAT_CAPABILITY_POINTER) && seat->pointer == NULL) {
wlr_log(WLR_DEBUG, "seat %p offered pointer", (void *)wl_seat);
@ -801,8 +797,7 @@ static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
static void seat_handle_name(void *data, struct wl_seat *wl_seat,
const char *name) {
struct wlr_wl_backend *backend = data;
struct wlr_wl_seat *seat = backend_get_seat(backend, wl_seat);
struct wlr_wl_seat *seat = data;
free(seat->name);
seat->name = strdup(name);
}

View file

@ -429,7 +429,8 @@ static void handle_pad_added(void *data,
struct zwp_tablet_seat_v2 *zwp_tablet_seat_v2,
struct zwp_tablet_pad_v2 *id) {
wlr_log(WLR_DEBUG, "New tablet pad");
struct wlr_wl_backend *backend = data;
struct wlr_wl_seat *seat = data;
struct wlr_wl_backend *backend = seat->backend;
struct wlr_wl_input_device *dev = create_wl_input_device(
backend, WLR_INPUT_DEVICE_TABLET_PAD);
if (!dev) {
@ -889,7 +890,8 @@ static void handle_tab_added(void *data,
struct zwp_tablet_seat_v2 *zwp_tablet_seat_v2,
struct zwp_tablet_v2 *id) {
wlr_log(WLR_DEBUG, "New tablet");
struct wlr_wl_backend *backend = data;
struct wlr_wl_seat *seat = data;
struct wlr_wl_backend *backend = seat->backend;
struct wlr_wl_input_device *dev = create_wl_input_device(
backend, WLR_INPUT_DEVICE_TABLET_TOOL);
@ -919,18 +921,18 @@ static const struct zwp_tablet_seat_v2_listener tablet_seat_listener = {
struct wlr_wl_tablet_seat *wl_add_tablet_seat(
struct zwp_tablet_manager_v2 *manager,
struct wl_seat *seat, struct wlr_wl_backend *backend) {
struct wlr_wl_seat *seat) {
struct wlr_wl_tablet_seat *ret =
calloc(1, sizeof(struct wlr_wl_tablet_seat));
if (!(ret->tablet_seat =
zwp_tablet_manager_v2_get_tablet_seat(manager, seat))) {
zwp_tablet_manager_v2_get_tablet_seat(manager, seat->wl_seat))) {
free(ret);
return NULL;
}
zwp_tablet_seat_v2_add_listener(ret->tablet_seat,
&tablet_seat_listener, backend);
&tablet_seat_listener, seat);
return ret;
}

View file

@ -112,6 +112,8 @@ struct wlr_wl_seat {
struct wl_touch *touch;
struct wl_pointer *pointer;
struct wl_keyboard *keyboard;
struct wlr_wl_backend *backend;
};
struct wlr_wl_backend *get_wl_backend_from_backend(struct wlr_backend *backend);
@ -129,6 +131,6 @@ extern const struct wl_seat_listener seat_listener;
struct wlr_wl_tablet_seat *wl_add_tablet_seat(
struct zwp_tablet_manager_v2 *manager,
struct wl_seat *seat, struct wlr_wl_backend *backend);
struct wlr_wl_seat *seat);
#endif