aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMykola Orliuk <virkony@gmail.com>2020-10-03 22:11:38 +0200
committerSimon Ser <contact@emersion.fr>2020-11-12 12:31:32 +0100
commit85b08726500c8f297ea78714ac9d636b9ae70987 (patch)
tree00e21828fb6fc00b199113c3c55c899bd20fe61d
parent40bfd9f8f79927b5095166a4b4b5b191288338ef (diff)
backend/wayland: Link input devices with seats
-rw-r--r--backend/wayland/backend.c2
-rw-r--r--backend/wayland/output.c2
-rw-r--r--backend/wayland/seat.c39
-rw-r--r--backend/wayland/tablet_v2.c6
-rw-r--r--include/backend/wayland.h9
5 files changed, 32 insertions, 26 deletions
diff --git a/backend/wayland/backend.c b/backend/wayland/backend.c
index 4d814cd2..bd4d6eb6 100644
--- a/backend/wayland/backend.c
+++ b/backend/wayland/backend.c
@@ -160,7 +160,7 @@ static bool backend_start(struct wlr_backend *backend) {
struct wlr_wl_seat *seat = wl->seat;
if (seat != NULL) {
if (seat->keyboard) {
- create_wl_keyboard(seat->keyboard, wl);
+ create_wl_keyboard(seat);
}
if (wl->tablet_manager) {
diff --git a/backend/wayland/output.c b/backend/wayland/output.c
index 568d90db..c8149149 100644
--- a/backend/wayland/output.c
+++ b/backend/wayland/output.c
@@ -589,7 +589,7 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *wlr_backend) {
struct wlr_wl_seat *seat = backend->seat;
if (seat != NULL) {
if (seat->pointer) {
- create_wl_pointer(seat->pointer, output);
+ create_wl_pointer(seat, output);
}
}
diff --git a/backend/wayland/seat.c b/backend/wayland/seat.c
index 56e8dc75..e038bb52 100644
--- a/backend/wayland/seat.c
+++ b/backend/wayland/seat.c
@@ -412,8 +412,8 @@ void destroy_wl_seats(struct wlr_wl_backend *wl) {
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);
- assert(dev->backend->seat);
- return dev->backend->seat;
+ assert(dev->seat);
+ return dev->seat;
}
static void input_device_destroy(struct wlr_input_device *wlr_dev) {
@@ -437,14 +437,15 @@ bool wlr_input_device_is_wl(struct wlr_input_device *dev) {
}
struct wlr_wl_input_device *create_wl_input_device(
- struct wlr_wl_backend *backend, enum wlr_input_device_type type) {
+ struct wlr_wl_seat *seat, enum wlr_input_device_type type) {
struct wlr_wl_input_device *dev =
calloc(1, sizeof(struct wlr_wl_input_device));
if (dev == NULL) {
wlr_log_errno(WLR_ERROR, "Allocation failed");
return NULL;
}
- dev->backend = backend;
+ dev->backend = seat->backend;
+ dev->seat = seat;
struct wlr_input_device *wlr_dev = &dev->wlr_input_device;
@@ -452,7 +453,7 @@ struct wlr_wl_input_device *create_wl_input_device(
const char *name = "wayland";
wlr_input_device_init(wlr_dev, type, &input_device_impl, name, vendor,
product);
- wl_list_insert(&backend->devices, &wlr_dev->link);
+ wl_list_insert(&seat->backend->devices, &wlr_dev->link);
return dev;
}
@@ -617,7 +618,9 @@ static void pointer_handle_output_destroy(struct wl_listener *listener,
wlr_input_device_destroy(&pointer->input_device->wlr_input_device);
}
-void create_wl_pointer(struct wl_pointer *wl_pointer, struct wlr_wl_output *output) {
+void create_wl_pointer(struct wlr_wl_seat *seat, struct wlr_wl_output *output) {
+ assert(seat->pointer);
+ struct wl_pointer *wl_pointer = seat->pointer;
struct wlr_wl_backend *backend = output->backend;
struct wlr_input_device *wlr_dev;
@@ -640,7 +643,7 @@ void create_wl_pointer(struct wl_pointer *wl_pointer, struct wlr_wl_output *outp
pointer->output = output;
struct wlr_wl_input_device *dev =
- create_wl_input_device(backend, WLR_INPUT_DEVICE_POINTER);
+ create_wl_input_device(seat, WLR_INPUT_DEVICE_POINTER);
if (dev == NULL) {
free(pointer);
wlr_log(WLR_ERROR, "Allocation failed");
@@ -677,9 +680,11 @@ void create_wl_pointer(struct wl_pointer *wl_pointer, struct wlr_wl_output *outp
wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_dev);
}
-void create_wl_keyboard(struct wl_keyboard *wl_keyboard, struct wlr_wl_backend *wl) {
+void create_wl_keyboard(struct wlr_wl_seat *seat) {
+ assert(seat->keyboard);
+ struct wl_keyboard *wl_keyboard = seat->keyboard;
struct wlr_wl_input_device *dev =
- create_wl_input_device(wl, WLR_INPUT_DEVICE_KEYBOARD);
+ create_wl_input_device(seat, WLR_INPUT_DEVICE_KEYBOARD);
if (!dev) {
return;
}
@@ -695,12 +700,14 @@ void create_wl_keyboard(struct wl_keyboard *wl_keyboard, struct wlr_wl_backend *
wlr_keyboard_init(wlr_dev->keyboard, NULL);
wl_keyboard_add_listener(wl_keyboard, &keyboard_listener, wlr_dev);
- wlr_signal_emit_safe(&wl->backend.events.new_input, wlr_dev);
+ wlr_signal_emit_safe(&seat->backend->backend.events.new_input, wlr_dev);
}
-void create_wl_touch(struct wl_touch *wl_touch, struct wlr_wl_backend *wl) {
+void create_wl_touch(struct wlr_wl_seat *seat) {
+ assert(seat->touch);
+ struct wl_touch *wl_touch = seat->touch;
struct wlr_wl_input_device *dev =
- create_wl_input_device(wl, WLR_INPUT_DEVICE_TOUCH);
+ create_wl_input_device(seat, WLR_INPUT_DEVICE_TOUCH);
if (!dev) {
return;
}
@@ -716,7 +723,7 @@ void create_wl_touch(struct wl_touch *wl_touch, struct wlr_wl_backend *wl) {
wlr_touch_init(wlr_dev->touch, NULL);
wl_touch_add_listener(wl_touch, &touch_listener, dev);
- wlr_signal_emit_safe(&wl->backend.events.new_input, wlr_dev);
+ wlr_signal_emit_safe(&seat->backend->backend.events.new_input, wlr_dev);
}
@@ -733,7 +740,7 @@ static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
struct wlr_wl_output *output;
wl_list_for_each(output, &backend->outputs, link) {
- create_wl_pointer(wl_pointer, output);
+ create_wl_pointer(seat, output);
}
}
if (!(caps & WL_SEAT_CAPABILITY_POINTER) && seat->pointer != NULL) {
@@ -757,7 +764,7 @@ static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
seat->keyboard = wl_keyboard;
if (backend->started) {
- create_wl_keyboard(wl_keyboard, backend);
+ create_wl_keyboard(seat);
}
}
if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && seat->keyboard != NULL) {
@@ -777,7 +784,7 @@ static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
seat->touch = wl_seat_get_touch(wl_seat);
if (backend->started) {
- create_wl_touch(seat->touch, backend);
+ create_wl_touch(seat);
}
}
if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && seat->touch != NULL) {
diff --git a/backend/wayland/tablet_v2.c b/backend/wayland/tablet_v2.c
index cf2ae532..b7ad73ea 100644
--- a/backend/wayland/tablet_v2.c
+++ b/backend/wayland/tablet_v2.c
@@ -430,9 +430,8 @@ static void handle_pad_added(void *data,
struct zwp_tablet_pad_v2 *id) {
wlr_log(WLR_DEBUG, "New tablet pad");
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);
+ seat, WLR_INPUT_DEVICE_TABLET_PAD);
if (!dev) {
/* This leaks a couple of server-sent resource ids. iirc this
* shouldn't ever be a problem, but it isn't exactly nice
@@ -891,9 +890,8 @@ static void handle_tab_added(void *data,
struct zwp_tablet_v2 *id) {
wlr_log(WLR_DEBUG, "New tablet");
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);
+ seat, WLR_INPUT_DEVICE_TABLET_TOOL);
if (!dev) {
zwp_tablet_v2_destroy(id);
diff --git a/include/backend/wayland.h b/include/backend/wayland.h
index c8a0429c..65fe6bbc 100644
--- a/include/backend/wayland.h
+++ b/include/backend/wayland.h
@@ -87,6 +87,7 @@ struct wlr_wl_input_device {
uint32_t fingers;
struct wlr_wl_backend *backend;
+ struct wlr_wl_seat *seat;
void *resource;
};
@@ -119,11 +120,11 @@ struct wlr_wl_seat {
struct wlr_wl_backend *get_wl_backend_from_backend(struct wlr_backend *backend);
void update_wl_output_cursor(struct wlr_wl_output *output);
struct wlr_wl_pointer *pointer_get_wl(struct wlr_pointer *wlr_pointer);
-void create_wl_pointer(struct wl_pointer *wl_pointer, struct wlr_wl_output *output);
-void create_wl_keyboard(struct wl_keyboard *wl_keyboard, struct wlr_wl_backend *wl);
-void create_wl_touch(struct wl_touch *wl_touch, struct wlr_wl_backend *wl);
+void create_wl_pointer(struct wlr_wl_seat *seat, struct wlr_wl_output *output);
+void create_wl_keyboard(struct wlr_wl_seat *seat);
+void create_wl_touch(struct wlr_wl_seat *seat);
struct wlr_wl_input_device *create_wl_input_device(
- struct wlr_wl_backend *backend, enum wlr_input_device_type type);
+ struct wlr_wl_seat *seat, enum wlr_input_device_type type);
bool create_wl_seat(struct wl_seat *wl_seat, struct wlr_wl_backend *wl);
void destroy_wl_seats(struct wlr_wl_backend *wl);