diff options
-rw-r--r-- | backend/libinput/touch.c | 5 | ||||
-rw-r--r-- | backend/wayland/seat.c | 2 | ||||
-rw-r--r-- | backend/x11/input_device.c | 8 | ||||
-rw-r--r-- | backend/x11/output.c | 11 | ||||
-rw-r--r-- | include/backend/x11.h | 1 | ||||
-rw-r--r-- | include/wlr/interfaces/wlr_touch.h | 2 | ||||
-rw-r--r-- | include/wlr/types/wlr_touch.h | 3 | ||||
-rw-r--r-- | types/wlr_touch.c | 7 |
8 files changed, 24 insertions, 15 deletions
diff --git a/backend/libinput/touch.c b/backend/libinput/touch.c index ee987a91..d1f99611 100644 --- a/backend/libinput/touch.c +++ b/backend/libinput/touch.c @@ -16,7 +16,10 @@ struct wlr_touch *create_libinput_touch( wlr_log(WLR_ERROR, "Unable to allocate wlr_touch"); return NULL; } - wlr_touch_init(wlr_touch, NULL); + const char *name = libinput_device_get_name(libinput_dev); + wlr_touch_init(wlr_touch, NULL, name); + wlr_touch->base.vendor = libinput_device_get_id_vendor(libinput_dev); + wlr_touch->base.product = libinput_device_get_id_product(libinput_dev); return wlr_touch; } diff --git a/backend/wayland/seat.c b/backend/wayland/seat.c index 633e585a..6382347f 100644 --- a/backend/wayland/seat.c +++ b/backend/wayland/seat.c @@ -819,7 +819,7 @@ void create_wl_touch(struct wlr_wl_seat *seat) { wlr_input_device_destroy(wlr_dev); return; } - wlr_touch_init(wlr_dev->touch, NULL); + wlr_touch_init(wlr_dev->touch, NULL, wlr_dev->name); wl_touch_add_listener(wl_touch, &touch_listener, dev); wlr_signal_emit_safe(&seat->backend->backend.events.new_input, wlr_dev); diff --git a/backend/x11/input_device.c b/backend/x11/input_device.c index 5ca3e956..a020442a 100644 --- a/backend/x11/input_device.c +++ b/backend/x11/input_device.c @@ -72,7 +72,7 @@ static void send_pointer_position_event(struct wlr_x11_output *output, static void send_touch_down_event(struct wlr_x11_output *output, int16_t x, int16_t y, int32_t touch_id, xcb_timestamp_t time) { struct wlr_event_touch_down ev = { - .device = &output->touch_dev, + .device = &output->touch.base, .time_msec = time, .x = (double)x / output->wlr_output.width, .y = (double)y / output->wlr_output.height, @@ -85,7 +85,7 @@ static void send_touch_down_event(struct wlr_x11_output *output, static void send_touch_motion_event(struct wlr_x11_output *output, int16_t x, int16_t y, int32_t touch_id, xcb_timestamp_t time) { struct wlr_event_touch_motion ev = { - .device = &output->touch_dev, + .device = &output->touch.base, .time_msec = time, .x = (double)x / output->wlr_output.width, .y = (double)y / output->wlr_output.height, @@ -98,7 +98,7 @@ static void send_touch_motion_event(struct wlr_x11_output *output, static void send_touch_up_event(struct wlr_x11_output *output, int32_t touch_id, xcb_timestamp_t time) { struct wlr_event_touch_up ev = { - .device = &output->touch_dev, + .device = &output->touch.base, .time_msec = time, .touch_id = touch_id, }; @@ -341,6 +341,8 @@ bool wlr_input_device_is_x11(struct wlr_input_device *wlr_dev) { return wlr_dev->keyboard->impl == &keyboard_impl; case WLR_INPUT_DEVICE_POINTER: return wlr_dev->pointer->impl == &pointer_impl; + case WLR_INPUT_DEVICE_TOUCH: + return wlr_dev->touch->impl == &touch_impl; default: return wlr_dev->impl == &input_device_impl; } diff --git a/backend/x11/output.c b/backend/x11/output.c index 19eb5d55..0900a60a 100644 --- a/backend/x11/output.c +++ b/backend/x11/output.c @@ -77,7 +77,7 @@ static void output_destroy(struct wlr_output *wlr_output) { pixman_region32_fini(&output->exposed); wlr_pointer_destroy(&output->pointer); - wlr_input_device_destroy(&output->touch_dev); + wlr_touch_destroy(&output->touch); struct wlr_x11_buffer *buffer, *buffer_tmp; wl_list_for_each_safe(buffer, buffer_tmp, &output->buffers, link) { @@ -576,16 +576,13 @@ struct wlr_output *wlr_x11_output_create(struct wlr_backend *backend) { wlr_pointer_init(&output->pointer, &pointer_impl, "x11-pointer"); output->pointer.base.output_name = strdup(wlr_output->name); - wlr_input_device_init(&output->touch_dev, WLR_INPUT_DEVICE_TOUCH, - &input_device_impl, "X11 touch"); - wlr_touch_init(&output->touch, &touch_impl); - output->touch_dev.touch = &output->touch; - output->touch_dev.output_name = strdup(wlr_output->name); + wlr_touch_init(&output->touch, &touch_impl, "x11-touch"); + output->touch.base.output_name = strdup(wlr_output->name); wl_list_init(&output->touchpoints); wlr_signal_emit_safe(&x11->backend.events.new_output, wlr_output); wlr_signal_emit_safe(&x11->backend.events.new_input, &output->pointer.base); - wlr_signal_emit_safe(&x11->backend.events.new_input, &output->touch_dev); + wlr_signal_emit_safe(&x11->backend.events.new_input, &output->touch.base); // Start the rendering loop by requesting the compositor to render a frame wlr_output_schedule_frame(wlr_output); diff --git a/include/backend/x11.h b/include/backend/x11.h index ee484654..2c039355 100644 --- a/include/backend/x11.h +++ b/include/backend/x11.h @@ -37,7 +37,6 @@ struct wlr_x11_output { struct wlr_pointer pointer; struct wlr_touch touch; - struct wlr_input_device touch_dev; struct wl_list touchpoints; // wlr_x11_touchpoint::link struct wl_list buffers; // wlr_x11_buffer::link diff --git a/include/wlr/interfaces/wlr_touch.h b/include/wlr/interfaces/wlr_touch.h index e4ea6a78..2b95d2bf 100644 --- a/include/wlr/interfaces/wlr_touch.h +++ b/include/wlr/interfaces/wlr_touch.h @@ -16,7 +16,7 @@ struct wlr_touch_impl { }; void wlr_touch_init(struct wlr_touch *touch, - const struct wlr_touch_impl *impl); + const struct wlr_touch_impl *impl, const char *name); void wlr_touch_destroy(struct wlr_touch *touch); #endif diff --git a/include/wlr/types/wlr_touch.h b/include/wlr/types/wlr_touch.h index ca7cf2a6..b2c097e8 100644 --- a/include/wlr/types/wlr_touch.h +++ b/include/wlr/types/wlr_touch.h @@ -10,11 +10,14 @@ #define WLR_TYPES_WLR_TOUCH_H #include <stdint.h> +#include <wlr/types/wlr_input_device.h> #include <wayland-server-core.h> struct wlr_touch_impl; struct wlr_touch { + struct wlr_input_device base; + const struct wlr_touch_impl *impl; struct { diff --git a/types/wlr_touch.c b/types/wlr_touch.c index 9edfdaee..a0949933 100644 --- a/types/wlr_touch.c +++ b/types/wlr_touch.c @@ -1,11 +1,15 @@ #include <stdlib.h> #include <string.h> #include <wayland-server-core.h> +#include <wlr/interfaces/wlr_input_device.h> #include <wlr/interfaces/wlr_touch.h> #include <wlr/types/wlr_touch.h> void wlr_touch_init(struct wlr_touch *touch, - const struct wlr_touch_impl *impl) { + const struct wlr_touch_impl *impl, const char *name) { + wlr_input_device_init(&touch->base, WLR_INPUT_DEVICE_TOUCH, NULL, name); + touch->base.touch = touch; + touch->impl = impl; wl_signal_init(&touch->events.down); wl_signal_init(&touch->events.up); @@ -15,6 +19,7 @@ void wlr_touch_init(struct wlr_touch *touch, } void wlr_touch_destroy(struct wlr_touch *touch) { + wlr_input_device_finish(&touch->base); if (touch && touch->impl && touch->impl->destroy) { touch->impl->destroy(touch); } else { |