From b7e9ad7989a1525a581cfb7065c3f8d576de03da Mon Sep 17 00:00:00 2001 From: Simon Zeni Date: Tue, 8 Mar 2022 15:15:32 -0500 Subject: [PATCH] backend/wayland: remove wlr_wl_input_device --- backend/wayland/backend.c | 6 --- backend/wayland/seat.c | 103 +------------------------------------- include/backend/wayland.h | 13 ----- 3 files changed, 1 insertion(+), 121 deletions(-) diff --git a/backend/wayland/backend.c b/backend/wayland/backend.c index 3428488e..998757f5 100644 --- a/backend/wayland/backend.c +++ b/backend/wayland/backend.c @@ -441,11 +441,6 @@ static void backend_destroy(struct wlr_backend *backend) { wlr_output_destroy(&output->wlr_output); } - struct wlr_wl_input_device *input_device, *tmp_input_device; - wl_list_for_each_safe(input_device, tmp_input_device, &wl->devices, link) { - destroy_wl_input_device(input_device); - } - struct wlr_wl_buffer *buffer, *tmp_buffer; wl_list_for_each_safe(buffer, tmp_buffer, &wl->buffers, link) { destroy_wl_buffer(buffer); @@ -538,7 +533,6 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display, wlr_backend_init(&wl->backend, &backend_impl); wl->local_display = display; - wl_list_init(&wl->devices); wl_list_init(&wl->outputs); wl_list_init(&wl->seats); wl_list_init(&wl->buffers); diff --git a/backend/wayland/seat.c b/backend/wayland/seat.c index 854447ee..768c4083 100644 --- a/backend/wayland/seat.c +++ b/backend/wayland/seat.c @@ -14,9 +14,9 @@ #include #include #include +#include #include -#include "interfaces/wlr_input_device.h" #include "backend/wayland.h" #include "util/signal.h" #include "util/time.h" @@ -222,12 +222,6 @@ static void init_seat_touch(struct wlr_wl_seat *seat) { &seat->wlr_touch.base); } -static struct wlr_wl_input_device *get_wl_input_device_from_input_device( - struct wlr_input_device *wlr_dev) { - assert(wlr_input_device_is_wl(wlr_dev)); - return (struct wlr_wl_input_device *)wlr_dev; -} - bool create_wl_seat(struct wl_seat *wl_seat, struct wlr_wl_backend *wl) { struct wlr_wl_seat *seat = calloc(1, sizeof(struct wlr_wl_seat)); if (!seat) { @@ -268,13 +262,6 @@ 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->seat); - return dev->seat; -} - bool wlr_input_device_is_wl(struct wlr_input_device *dev) { switch (dev->type) { case WLR_INPUT_DEVICE_KEYBOARD: @@ -292,90 +279,6 @@ bool wlr_input_device_is_wl(struct wlr_input_device *dev) { } } -struct wlr_wl_input_device *create_wl_input_device( - 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 = seat->backend; - dev->seat = seat; - - struct wlr_input_device *wlr_dev = &dev->wlr_input_device; - - const char *type_name = "unknown"; - - switch (type) { - case WLR_INPUT_DEVICE_KEYBOARD: - wlr_log(WLR_ERROR, "can't create keyboard wlr_wl_input_device"); - free(dev); - return NULL; - case WLR_INPUT_DEVICE_POINTER: - wlr_log(WLR_ERROR, "can't create pointer wlr_wl_input_device"); - free(dev); - return NULL; - case WLR_INPUT_DEVICE_TOUCH: - wlr_log(WLR_ERROR, "can't create touch wlr_wl_input_device"); - free(dev); - return NULL; - case WLR_INPUT_DEVICE_TABLET_TOOL: - wlr_log(WLR_ERROR, "can't create tablet tool wlr_wl_input_device"); - free(dev); - return NULL; - case WLR_INPUT_DEVICE_TABLET_PAD: - wlr_log(WLR_ERROR, "can't create tablet pad wlr_wl_input_device"); - free(dev); - return NULL; - default: - wlr_log(WLR_ERROR, "device not handled"); - free(dev); - return NULL; - } - - size_t name_size = 8 + strlen(type_name) + strlen(seat->name) + 1; - char name[name_size]; - (void) snprintf(name, name_size, "wayland-%s-%s", type_name, seat->name); - - wlr_input_device_init(wlr_dev, type, name); - wl_list_insert(&seat->backend->devices, &dev->link); - return dev; -} - -void destroy_wl_input_device(struct wlr_wl_input_device *dev) { - /** - * TODO remove the redundant wlr_input_device from wlr_wl_input_device - * wlr_wl_input_device::wlr_input_device is not owned by its input device - * type, which means we have 2 wlr_input_device to cleanup - */ - wlr_input_device_finish(&dev->wlr_input_device); - if (dev->wlr_input_device._device) { - struct wlr_input_device *wlr_dev = &dev->wlr_input_device; - switch (wlr_dev->type) { - case WLR_INPUT_DEVICE_KEYBOARD: - wlr_log(WLR_ERROR, "wlr_wl_input_device has no keyboard"); - break; - case WLR_INPUT_DEVICE_POINTER: - wlr_log(WLR_ERROR, "wlr_wl_input_device has no pointer"); - break; - case WLR_INPUT_DEVICE_TABLET_PAD: - wlr_log(WLR_ERROR, "wlr_wl_input_device has no tablet pad"); - break; - case WLR_INPUT_DEVICE_TABLET_TOOL: - wlr_log(WLR_ERROR, "wlr_wl_input_device has no tablet_tool"); - break; - case WLR_INPUT_DEVICE_TOUCH: - wlr_log(WLR_ERROR, "wlr_wl_input_device has no touch"); - break; - default: - break; - } - } - wl_list_remove(&dev->link); - free(dev); -} - static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat, enum wl_seat_capability caps) { struct wlr_wl_seat *seat = data; @@ -437,7 +340,3 @@ const struct wl_seat_listener seat_listener = { .capabilities = seat_handle_capabilities, .name = seat_handle_name, }; - -struct wl_seat *wlr_wl_input_device_get_seat(struct wlr_input_device *wlr_dev) { - return input_device_get_seat(wlr_dev)->wl_seat; -} diff --git a/include/backend/wayland.h b/include/backend/wayland.h index d683dfca..a6d56538 100644 --- a/include/backend/wayland.h +++ b/include/backend/wayland.h @@ -21,7 +21,6 @@ struct wlr_wl_backend { /* local state */ bool started; struct wl_display *local_display; - struct wl_list devices; struct wl_list outputs; int drm_fd; struct wl_list buffers; // wlr_wl_buffer.link @@ -89,15 +88,6 @@ struct wlr_wl_output { } cursor; }; -struct wlr_wl_input_device { - struct wlr_input_device wlr_input_device; - struct wl_list link; - - struct wlr_wl_backend *backend; - struct wlr_wl_seat *seat; - void *resource; -}; - struct wlr_wl_pointer { struct wlr_pointer wlr_pointer; @@ -157,11 +147,8 @@ void create_pointer(struct wlr_wl_seat *seat, struct wlr_wl_output *output); void init_seat_tablet(struct wlr_wl_seat *seat); void finish_seat_tablet(struct wlr_wl_seat *seat); -struct wlr_wl_input_device *create_wl_input_device( - 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); -void destroy_wl_input_device(struct wlr_wl_input_device *dev); void destroy_wl_buffer(struct wlr_wl_buffer *buffer); extern const struct wl_seat_listener seat_listener;