From a92e5f8d4634a5d24c2fbab4a7fe0256558a96e6 Mon Sep 17 00:00:00 2001 From: Simon Zeni Date: Tue, 8 Mar 2022 16:45:03 -0500 Subject: [PATCH] types/wlr_input_device: move output_name field to wlr_pointer and wlr_touch --- backend/wayland/pointer.c | 3 +-- backend/wayland/seat.c | 7 +++++++ backend/x11/output.c | 4 ++-- include/wlr/types/wlr_input_device.h | 1 - include/wlr/types/wlr_pointer.h | 2 ++ include/wlr/types/wlr_touch.h | 2 ++ types/wlr_input_device.c | 1 - types/wlr_pointer.c | 2 ++ types/wlr_touch.c | 2 ++ 9 files changed, 18 insertions(+), 6 deletions(-) diff --git a/backend/wayland/pointer.c b/backend/wayland/pointer.c index 9d3131b99..2dc5d752e 100644 --- a/backend/wayland/pointer.c +++ b/backend/wayland/pointer.c @@ -440,8 +440,7 @@ void create_pointer(struct wlr_wl_seat *seat, struct wlr_wl_output *output) { snprintf(name, sizeof(name), "wayland-pointer-%s", seat->name); wlr_pointer_init(&pointer->wlr_pointer, &wl_pointer_impl, name); - /* TODO: move output_name to pointer/touch */ - pointer->wlr_pointer.base.output_name = strdup(output->wlr_output.name); + pointer->wlr_pointer.output_name = strdup(output->wlr_output.name); pointer->seat = seat; pointer->output = output; diff --git a/backend/wayland/seat.c b/backend/wayland/seat.c index 7d16d7d4d..33a7383c5 100644 --- a/backend/wayland/seat.c +++ b/backend/wayland/seat.c @@ -217,6 +217,13 @@ static void init_seat_touch(struct wlr_wl_seat *seat) { wlr_touch_init(&seat->wlr_touch, &touch_impl, name); + struct wlr_wl_output *output; + wl_list_for_each(output, &seat->backend->outputs, link) { + /* Multi-output touch not supproted */ + seat->wlr_touch.output_name = strdup(output->wlr_output.name); + break; + } + wl_touch_add_listener(seat->wl_touch, &touch_listener, seat); wlr_signal_emit_safe(&seat->backend->backend.events.new_input, &seat->wlr_touch.base); diff --git a/backend/x11/output.c b/backend/x11/output.c index 1b51b629a..86e1dfd8e 100644 --- a/backend/x11/output.c +++ b/backend/x11/output.c @@ -574,10 +574,10 @@ struct wlr_output *wlr_x11_output_create(struct wlr_backend *backend) { wlr_output_update_enabled(wlr_output, true); wlr_pointer_init(&output->pointer, &x11_pointer_impl, "x11-pointer"); - output->pointer.base.output_name = strdup(wlr_output->name); + output->pointer.output_name = strdup(wlr_output->name); wlr_touch_init(&output->touch, &x11_touch_impl, "x11-touch"); - output->touch.base.output_name = strdup(wlr_output->name); + output->touch.output_name = strdup(wlr_output->name); wl_list_init(&output->touchpoints); wlr_signal_emit_safe(&x11->backend.events.new_output, wlr_output); diff --git a/include/wlr/types/wlr_input_device.h b/include/wlr/types/wlr_input_device.h index 0ca64341b..730912f71 100644 --- a/include/wlr/types/wlr_input_device.h +++ b/include/wlr/types/wlr_input_device.h @@ -31,7 +31,6 @@ struct wlr_input_device { char *name; // Or 0 if not applicable to this device double width_mm, height_mm; - char *output_name; /* wlr_input_device.type determines which of these is valid */ union { diff --git a/include/wlr/types/wlr_pointer.h b/include/wlr/types/wlr_pointer.h index a58507189..dc7611b80 100644 --- a/include/wlr/types/wlr_pointer.h +++ b/include/wlr/types/wlr_pointer.h @@ -21,6 +21,8 @@ struct wlr_pointer { const struct wlr_pointer_impl *impl; + char *output_name; + struct { struct wl_signal motion; // struct wlr_event_pointer_motion struct wl_signal motion_absolute; // struct wlr_event_pointer_motion_absolute diff --git a/include/wlr/types/wlr_touch.h b/include/wlr/types/wlr_touch.h index b2c097e8f..ed2f0033c 100644 --- a/include/wlr/types/wlr_touch.h +++ b/include/wlr/types/wlr_touch.h @@ -20,6 +20,8 @@ struct wlr_touch { const struct wlr_touch_impl *impl; + char *output_name; + struct { struct wl_signal down; // struct wlr_event_touch_down struct wl_signal up; // struct wlr_event_touch_up diff --git a/types/wlr_input_device.c b/types/wlr_input_device.c index d376582ed..d87935d85 100644 --- a/types/wlr_input_device.c +++ b/types/wlr_input_device.c @@ -25,5 +25,4 @@ void wlr_input_device_finish(struct wlr_input_device *wlr_device) { wl_list_remove(&wlr_device->events.destroy.listener_list); free(wlr_device->name); - free(wlr_device->output_name); } diff --git a/types/wlr_pointer.c b/types/wlr_pointer.c index 737d36ec6..09782cda8 100644 --- a/types/wlr_pointer.c +++ b/types/wlr_pointer.c @@ -29,4 +29,6 @@ void wlr_pointer_init(struct wlr_pointer *pointer, void wlr_pointer_finish(struct wlr_pointer *pointer) { wlr_input_device_finish(&pointer->base); + + free(pointer->output_name); } diff --git a/types/wlr_touch.c b/types/wlr_touch.c index 612efcda8..96d196d34 100644 --- a/types/wlr_touch.c +++ b/types/wlr_touch.c @@ -21,4 +21,6 @@ void wlr_touch_init(struct wlr_touch *touch, void wlr_touch_finish(struct wlr_touch *touch) { wlr_input_device_finish(&touch->base); + + free(touch->output_name); }