From 7d560df90e7ee684dc26306f44a0b3c7f8cf2702 Mon Sep 17 00:00:00 2001 From: Simon Zeni Date: Thu, 27 Jan 2022 10:00:57 -0500 Subject: [PATCH] backend/headless: remove unused wlr_headless_input_device --- backend/headless/backend.c | 13 ---- backend/headless/input_device.c | 108 -------------------------------- backend/headless/meson.build | 1 - include/backend/headless.h | 7 --- include/wlr/backend/headless.h | 9 +-- 5 files changed, 1 insertion(+), 137 deletions(-) delete mode 100644 backend/headless/input_device.c diff --git a/backend/headless/backend.c b/backend/headless/backend.c index b7788105..e44595de 100644 --- a/backend/headless/backend.c +++ b/backend/headless/backend.c @@ -25,12 +25,6 @@ static bool backend_start(struct wlr_backend *wlr_backend) { &output->wlr_output); } - struct wlr_headless_input_device *input_device; - wl_list_for_each(input_device, &backend->input_devices, link) { - wlr_signal_emit_safe(&backend->backend.events.new_input, - &input_device->wlr_input_device); - } - backend->started = true; return true; } @@ -49,12 +43,6 @@ static void backend_destroy(struct wlr_backend *wlr_backend) { wlr_output_destroy(&output->wlr_output); } - struct wlr_headless_input_device *input_device, *input_device_tmp; - wl_list_for_each_safe(input_device, input_device_tmp, - &backend->input_devices, link) { - wlr_input_device_destroy(&input_device->wlr_input_device); - } - wlr_backend_finish(wlr_backend); free(backend); @@ -92,7 +80,6 @@ struct wlr_backend *wlr_headless_backend_create(struct wl_display *display) { backend->display = display; wl_list_init(&backend->outputs); - wl_list_init(&backend->input_devices); backend->display_destroy.notify = handle_display_destroy; wl_display_add_destroy_listener(display, &backend->display_destroy); diff --git a/backend/headless/input_device.c b/backend/headless/input_device.c deleted file mode 100644 index 4df01aff..00000000 --- a/backend/headless/input_device.c +++ /dev/null @@ -1,108 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "backend/headless.h" -#include "util/signal.h" - -static void input_device_destroy(struct wlr_input_device *wlr_dev) { - struct wlr_headless_input_device *dev = - wl_container_of(wlr_dev, dev, wlr_input_device); - wl_list_remove(&dev->link); - free(dev); -} - -static const struct wlr_input_device_impl input_device_impl = { - .destroy = input_device_destroy, -}; - -bool wlr_input_device_is_headless(struct wlr_input_device *wlr_dev) { - return wlr_dev->impl == &input_device_impl; -} - -struct wlr_input_device *wlr_headless_add_input_device( - struct wlr_backend *wlr_backend, enum wlr_input_device_type type) { - struct wlr_headless_backend *backend = - headless_backend_from_backend(wlr_backend); - - struct wlr_headless_input_device *device = - calloc(1, sizeof(struct wlr_headless_input_device)); - if (device == NULL) { - return NULL; - } - device->backend = backend; - - int vendor = 0; - int product = 0; - const char *name = "headless"; - struct wlr_input_device *wlr_device = &device->wlr_input_device; - wlr_input_device_init(wlr_device, type, &input_device_impl, name, vendor, - product); - - switch (type) { - case WLR_INPUT_DEVICE_KEYBOARD: - wlr_device->keyboard = calloc(1, sizeof(struct wlr_keyboard)); - if (wlr_device->keyboard == NULL) { - wlr_log(WLR_ERROR, "Unable to allocate wlr_keyboard"); - goto error; - } - wlr_keyboard_init(wlr_device->keyboard, NULL); - break; - case WLR_INPUT_DEVICE_POINTER: - wlr_device->pointer = calloc(1, sizeof(struct wlr_pointer)); - if (wlr_device->pointer == NULL) { - wlr_log(WLR_ERROR, "Unable to allocate wlr_pointer"); - goto error; - } - wlr_pointer_init(wlr_device->pointer, NULL); - break; - case WLR_INPUT_DEVICE_TOUCH: - wlr_device->touch = calloc(1, sizeof(struct wlr_touch)); - if (wlr_device->touch == NULL) { - wlr_log(WLR_ERROR, "Unable to allocate wlr_touch"); - goto error; - } - wlr_touch_init(wlr_device->touch, NULL); - break; - case WLR_INPUT_DEVICE_TABLET_TOOL: - wlr_device->tablet = calloc(1, sizeof(struct wlr_tablet)); - if (wlr_device->tablet == NULL) { - wlr_log(WLR_ERROR, "Unable to allocate wlr_tablet"); - goto error; - } - wlr_tablet_init(wlr_device->tablet, NULL); - break; - case WLR_INPUT_DEVICE_TABLET_PAD: - wlr_device->tablet_pad = calloc(1, sizeof(struct wlr_tablet_pad)); - if (wlr_device->tablet_pad == NULL) { - wlr_log(WLR_ERROR, "Unable to allocate wlr_tablet_pad"); - goto error; - } - wlr_tablet_pad_init(wlr_device->tablet_pad, NULL); - break; - case WLR_INPUT_DEVICE_SWITCH: - wlr_device->switch_device = calloc(1, sizeof(struct wlr_switch)); - if (wlr_device->switch_device == NULL) { - wlr_log(WLR_ERROR, "Unable to allocate wlr_switch"); - goto error; - } - wlr_switch_init(wlr_device->switch_device, NULL); - } - - wl_list_insert(&backend->input_devices, &device->link); - - if (backend->started) { - wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_device); - } - - return wlr_device; -error: - free(device); - return NULL; -} diff --git a/backend/headless/meson.build b/backend/headless/meson.build index e38ce133..950c0716 100644 --- a/backend/headless/meson.build +++ b/backend/headless/meson.build @@ -1,5 +1,4 @@ wlr_files += files( 'backend.c', - 'input_device.c', 'output.c', ) diff --git a/include/backend/headless.h b/include/backend/headless.h index e126ac4e..04750900 100644 --- a/include/backend/headless.h +++ b/include/backend/headless.h @@ -11,7 +11,6 @@ struct wlr_headless_backend { struct wl_display *display; struct wl_list outputs; size_t last_output_num; - struct wl_list input_devices; struct wl_listener display_destroy; bool started; }; @@ -26,12 +25,6 @@ struct wlr_headless_output { int frame_delay; // ms }; -struct wlr_headless_input_device { - struct wlr_input_device wlr_input_device; - struct wl_list link; - struct wlr_headless_backend *backend; -}; - struct wlr_headless_backend *headless_backend_from_backend( struct wlr_backend *wlr_backend); diff --git a/include/wlr/backend/headless.h b/include/wlr/backend/headless.h index 07dac9b8..f4735483 100644 --- a/include/wlr/backend/headless.h +++ b/include/wlr/backend/headless.h @@ -25,15 +25,8 @@ struct wlr_backend *wlr_headless_backend_create(struct wl_display *display); */ struct wlr_output *wlr_headless_add_output(struct wlr_backend *backend, unsigned int width, unsigned int height); -/** - * Creates a new input device. The caller is responsible for manually raising - * any event signals on the new input device if it wants to simulate input - * events. - */ -struct wlr_input_device *wlr_headless_add_input_device( - struct wlr_backend *backend, enum wlr_input_device_type type); + bool wlr_backend_is_headless(struct wlr_backend *backend); -bool wlr_input_device_is_headless(struct wlr_input_device *device); bool wlr_output_is_headless(struct wlr_output *output); #endif