From 000b305eccb8d732aa2bde5f4b2f126c23e574cf Mon Sep 17 00:00:00 2001 From: Markus Ongyerth Date: Tue, 17 Apr 2018 19:09:42 +0200 Subject: backend/libinput: Manage tablet tool livetimes This adds the management code to manage tablet tools lifetimes from libinput. It follows the suggestion made in the tablet-unstable-v2.xml to destroy tablet_tools once all tablets that it got into contact with were removed from the system. This is implemented via a refcount. If a tool is *not* unique, it will be destroyed on proximity out. This is libinput specific and mentioned in libinput docs that tools will not be found again, so we shouldn't keep a reference to them. Also they can't be on other tablets as well, because they cannot be tracked. The naming in this commit is a bit off (to not break things). The wlr names stay the same, tablet_tool is the libinput_device with capaiblity LIBINPUT_DEVICE_CAP_TABLET_TOOL which is more akin to "tablet" in the tablet-unstable-v2 protocol. The struct that corresponds to the tablet_tool in tablet-unstable-v2 is called tablet_tool_tool, a rename should be done at some point in the future. --- include/backend/libinput.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/backend') diff --git a/include/backend/libinput.h b/include/backend/libinput.h index f0928133..6ecdf44f 100644 --- a/include/backend/libinput.h +++ b/include/backend/libinput.h @@ -67,6 +67,7 @@ void handle_touch_cancel(struct libinput_event *event, struct wlr_tablet_tool *create_libinput_tablet_tool( struct libinput_device *device); +void wlr_libinput_tablet_tool_destroy(struct wlr_input_device *device); void handle_tablet_tool_axis(struct libinput_event *event, struct libinput_device *device); void handle_tablet_tool_proximity(struct libinput_event *event, -- cgit v1.2.3 From adba68a3c1fb51771342512f570c552a7404cc93 Mon Sep 17 00:00:00 2001 From: Markus Ongyerth Date: Tue, 15 May 2018 15:49:55 +0200 Subject: Use tablet_tool impl in libinput backend --- backend/libinput/events.c | 3 --- backend/libinput/tablet_tool.c | 12 +++++++++--- include/backend/libinput.h | 1 - 3 files changed, 9 insertions(+), 7 deletions(-) (limited to 'include/backend') diff --git a/backend/libinput/events.c b/backend/libinput/events.c index d15de6bb..93664af2 100644 --- a/backend/libinput/events.c +++ b/backend/libinput/events.c @@ -186,9 +186,6 @@ static void handle_device_removed(struct wlr_libinput_backend *backend, } struct wlr_input_device *dev, *tmp_dev; wl_list_for_each_safe(dev, tmp_dev, wlr_devices, link) { - if (dev->type == WLR_INPUT_DEVICE_TABLET_TOOL) { - wlr_libinput_tablet_tool_destroy(dev); - } wlr_input_device_destroy(dev); } for (size_t i = 0; i < backend->wlr_device_lists.length; i++) { diff --git a/backend/libinput/tablet_tool.c b/backend/libinput/tablet_tool.c index f02e045a..7cecb091 100644 --- a/backend/libinput/tablet_tool.c +++ b/backend/libinput/tablet_tool.c @@ -57,9 +57,9 @@ static void destroy_tool_tool(struct wlr_libinput_tablet_tool *tool) { } -void wlr_libinput_tablet_tool_destroy(struct wlr_input_device *wlr_dev) { +static void libinput_tablet_tool_destroy(struct wlr_tablet_tool *tool) { struct wlr_libinput_tablet *tablet = - wl_container_of(wlr_dev->tablet_tool, tablet, wlr_tool); + wl_container_of(tool, tablet, wlr_tool); struct tablet_tool_list_elem *pos; struct tablet_tool_list_elem *tmp; @@ -72,8 +72,14 @@ void wlr_libinput_tablet_tool_destroy(struct wlr_input_device *wlr_dev) { destroy_tool_tool(tool); } } + + free(tablet); } +static struct wlr_tablet_tool_impl tool_impl = { + .destroy = libinput_tablet_tool_destroy, +}; + struct wlr_tablet_tool *create_libinput_tablet_tool( struct libinput_device *libinput_dev) { assert(libinput_dev); @@ -91,7 +97,7 @@ struct wlr_tablet_tool *create_libinput_tablet_tool( wlr_tablet_tool->name = strdup(libinput_device_get_name(libinput_dev)); wl_list_init(&libinput_tablet_tool->tools); - wlr_tablet_tool_init(wlr_tablet_tool, NULL); + wlr_tablet_tool_init(wlr_tablet_tool, &tool_impl); return wlr_tablet_tool; } diff --git a/include/backend/libinput.h b/include/backend/libinput.h index 6ecdf44f..f0928133 100644 --- a/include/backend/libinput.h +++ b/include/backend/libinput.h @@ -67,7 +67,6 @@ void handle_touch_cancel(struct libinput_event *event, struct wlr_tablet_tool *create_libinput_tablet_tool( struct libinput_device *device); -void wlr_libinput_tablet_tool_destroy(struct wlr_input_device *device); void handle_tablet_tool_axis(struct libinput_event *event, struct libinput_device *device); void handle_tablet_tool_proximity(struct libinput_event *event, -- cgit v1.2.3 From d9e978e1b379c811c47f4b3b75f1ec186a640ff7 Mon Sep 17 00:00:00 2001 From: Markus Ongyerth Date: Sat, 16 Jun 2018 11:19:48 +0200 Subject: rename wlr_tablet_tool to wlr_tablet The previous naming was based on the input-device capability names from libinput. With code that uses the libinput_tablet_tool and mapping into tablet-v2, this is confusing, so the name is changed to follow the names used in the protocol. --- backend/headless/input_device.c | 8 ++-- backend/libinput/events.c | 4 +- backend/libinput/tablet_tool.c | 71 ++++++++++++++++---------------- examples/tablet.c | 6 +-- include/backend/libinput.h | 2 +- include/wlr/interfaces/wlr_tablet_tool.h | 10 ++--- include/wlr/types/wlr_input_device.h | 2 +- include/wlr/types/wlr_tablet_tool.h | 18 ++++---- include/wlr/types/wlr_tablet_v2.h | 6 +-- rootston/seat.c | 4 +- types/tablet_v2/wlr_tablet_v2_tablet.c | 13 +++--- types/tablet_v2/wlr_tablet_v2_tool.c | 2 +- types/wlr_cursor.c | 8 ++-- types/wlr_input_device.c | 2 +- types/wlr_tablet_tool.c | 28 ++++++------- 15 files changed, 93 insertions(+), 91 deletions(-) (limited to 'include/backend') diff --git a/backend/headless/input_device.c b/backend/headless/input_device.c index e0411c27..a2474aeb 100644 --- a/backend/headless/input_device.c +++ b/backend/headless/input_device.c @@ -60,12 +60,12 @@ struct wlr_input_device *wlr_headless_add_input_device( wlr_touch_init(wlr_device->touch, NULL); break; case WLR_INPUT_DEVICE_TABLET_TOOL: - wlr_device->tablet_tool = calloc(1, sizeof(struct wlr_tablet_tool)); - if (wlr_device->tablet_tool == NULL) { - wlr_log(WLR_ERROR, "Unable to allocate wlr_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_tool_init(wlr_device->tablet_tool, NULL); + 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)); diff --git a/backend/libinput/events.c b/backend/libinput/events.c index 93664af2..0548e502 100644 --- a/backend/libinput/events.c +++ b/backend/libinput/events.c @@ -130,8 +130,8 @@ static void handle_device_added(struct wlr_libinput_backend *backend, if (!wlr_dev) { goto fail; } - wlr_dev->tablet_tool = create_libinput_tablet_tool(libinput_dev); - if (!wlr_dev->tablet_tool) { + wlr_dev->tablet = create_libinput_tablet(libinput_dev); + if (!wlr_dev->tablet) { free(wlr_dev); goto fail; } diff --git a/backend/libinput/tablet_tool.c b/backend/libinput/tablet_tool.c index 0dab6795..563338b8 100644 --- a/backend/libinput/tablet_tool.c +++ b/backend/libinput/tablet_tool.c @@ -13,14 +13,14 @@ #include "backend/libinput.h" #include "util/signal.h" -static struct wlr_tablet_tool_impl tool_impl; +static struct wlr_tablet_impl tablet_impl; -static bool tablet_tool_is_libinput(struct wlr_tablet_tool *tool) { - return tool->impl == &tool_impl; +static bool tablet_is_libinput(struct wlr_tablet *tablet) { + return tablet->impl == &tablet_impl; } struct wlr_libinput_tablet_tool { - struct wlr_tablet_tool_tool wlr_tool; + struct wlr_tablet_tool wlr_tool; struct libinput_tablet_tool *libinput_tool; @@ -38,7 +38,7 @@ struct tablet_tool_list_elem { }; struct wlr_libinput_tablet { - struct wlr_tablet_tool wlr_tool; + struct wlr_tablet wlr_tablet; struct wl_list tools; // tablet_tool_list_elem::link }; @@ -51,10 +51,10 @@ static void destroy_tool_tool(struct wlr_libinput_tablet_tool *tool) { } -static void destroy_tablet_tool(struct wlr_tablet_tool *tool) { - assert(tablet_tool_is_libinput(tool)); +static void destroy_tablet(struct wlr_tablet *wlr_tablet) { + assert(tablet_is_libinput(wlr_tablet)); struct wlr_libinput_tablet *tablet = - wl_container_of(tool, tablet, wlr_tool); + wl_container_of(wlr_tablet, tablet, wlr_tablet); struct tablet_tool_list_elem *pos; struct tablet_tool_list_elem *tmp; @@ -71,29 +71,29 @@ static void destroy_tablet_tool(struct wlr_tablet_tool *tool) { free(tablet); } -static struct wlr_tablet_tool_impl tool_impl = { - .destroy = destroy_tablet_tool, +static struct wlr_tablet_impl tablet_impl = { + .destroy = destroy_tablet, }; -struct wlr_tablet_tool *create_libinput_tablet_tool( +struct wlr_tablet *create_libinput_tablet( struct libinput_device *libinput_dev) { assert(libinput_dev); - struct wlr_libinput_tablet *libinput_tablet_tool = + struct wlr_libinput_tablet *libinput_tablet = calloc(1, sizeof(struct wlr_libinput_tablet)); - if (!libinput_tablet_tool) { + if (!libinput_tablet) { wlr_log(WLR_ERROR, "Unable to allocate wlr_tablet_tool"); return NULL; } - struct wlr_tablet_tool *wlr_tablet_tool = &libinput_tablet_tool->wlr_tool; + struct wlr_tablet *wlr_tablet = &libinput_tablet->wlr_tablet; - wlr_list_init(&wlr_tablet_tool->paths); + wlr_list_init(&wlr_tablet->paths); struct udev_device *udev = libinput_device_get_udev_device(libinput_dev); - wlr_list_push(&wlr_tablet_tool->paths, strdup(udev_device_get_syspath(udev))); - wlr_tablet_tool->name = strdup(libinput_device_get_name(libinput_dev)); - wl_list_init(&libinput_tablet_tool->tools); + wlr_list_push(&wlr_tablet->paths, strdup(udev_device_get_syspath(udev))); + wlr_tablet->name = strdup(libinput_device_get_name(libinput_dev)); + wl_list_init(&libinput_tablet->tools); - wlr_tablet_tool_init(wlr_tablet_tool, &tool_impl); - return wlr_tablet_tool; + wlr_tablet_init(wlr_tablet, &tablet_impl); + return wlr_tablet; } static enum wlr_tablet_tool_type wlr_type_from_libinput_type( @@ -154,11 +154,11 @@ static struct wlr_libinput_tablet_tool *get_wlr_tablet_tool( } static void ensure_tool_reference(struct wlr_libinput_tablet_tool *tool, - struct wlr_tablet_tool *wlr_dev) { - assert(tablet_tool_is_libinput(wlr_dev)); - struct tablet_tool_list_elem *pos; - struct wlr_libinput_tablet *tablet = wl_container_of(wlr_dev, tablet, wlr_tool); + struct wlr_tablet *wlr_dev) { + assert(tablet_is_libinput(wlr_dev)); + struct wlr_libinput_tablet *tablet = wl_container_of(wlr_dev, tablet, wlr_tablet); + struct tablet_tool_list_elem *pos; wl_list_for_each(pos, &tablet->tools, link) { if (pos->tool == tool) { // We already have a ref // XXX: We *could* optimize the tool to the front of @@ -173,7 +173,8 @@ static void ensure_tool_reference(struct wlr_libinput_tablet_tool *tool, struct tablet_tool_list_elem *new = calloc(1, sizeof(struct tablet_tool_list_elem)); - if (!new) {// TODO: Should we at least log? + if (!new) { + wlr_log(WLR_ERROR, "Failed to allocate memory for tracking tablet tool"); return; } @@ -195,7 +196,7 @@ void handle_tablet_tool_axis(struct libinput_event *event, struct wlr_event_tablet_tool_axis wlr_event = { 0 }; struct wlr_libinput_tablet_tool *tool = get_wlr_tablet_tool( libinput_event_tablet_tool_get_tool(tevent)); - ensure_tool_reference(tool, wlr_dev->tablet_tool); + ensure_tool_reference(tool, wlr_dev->tablet); wlr_event.device = wlr_dev; wlr_event.tool = &tool->wlr_tool; @@ -239,7 +240,7 @@ void handle_tablet_tool_axis(struct libinput_event *event, wlr_event.updated_axes |= WLR_TABLET_TOOL_AXIS_WHEEL; wlr_event.wheel_delta = libinput_event_tablet_tool_get_wheel_delta(tevent); } - wlr_signal_emit_safe(&wlr_dev->tablet_tool->events.axis, &wlr_event); + wlr_signal_emit_safe(&wlr_dev->tablet->events.axis, &wlr_event); } void handle_tablet_tool_proximity(struct libinput_event *event, @@ -255,7 +256,7 @@ void handle_tablet_tool_proximity(struct libinput_event *event, struct wlr_event_tablet_tool_proximity wlr_event = { 0 }; struct wlr_libinput_tablet_tool *tool = get_wlr_tablet_tool( libinput_event_tablet_tool_get_tool(tevent)); - ensure_tool_reference(tool, wlr_dev->tablet_tool); + ensure_tool_reference(tool, wlr_dev->tablet); wlr_event.tool = &tool->wlr_tool; wlr_event.device = wlr_dev; @@ -269,7 +270,7 @@ void handle_tablet_tool_proximity(struct libinput_event *event, wlr_event.state = WLR_TABLET_TOOL_PROXIMITY_IN; break; } - wlr_signal_emit_safe(&wlr_dev->tablet_tool->events.proximity, &wlr_event); + wlr_signal_emit_safe(&wlr_dev->tablet->events.proximity, &wlr_event); if (libinput_event_tablet_tool_get_proximity_state(tevent) == LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN) { handle_tablet_tool_axis(event, libinput_dev); @@ -281,9 +282,9 @@ void handle_tablet_tool_proximity(struct libinput_event *event, libinput_event_tablet_tool_get_proximity_state(tevent) == LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_OUT) { // The tool isn't unique, it can't be on multiple tablets assert(tool->pad_refs == 1); - assert(tablet_tool_is_libinput(wlr_dev->tablet_tool)); + assert(tablet_is_libinput(wlr_dev->tablet)); struct wlr_libinput_tablet *tablet = - wl_container_of(wlr_dev->tablet_tool, tablet, wlr_tool); + wl_container_of(wlr_dev->tablet, tablet, wlr_tablet); struct tablet_tool_list_elem *pos; struct tablet_tool_list_elem *tmp; @@ -313,7 +314,7 @@ void handle_tablet_tool_tip(struct libinput_event *event, struct wlr_event_tablet_tool_tip wlr_event = { 0 }; struct wlr_libinput_tablet_tool *tool = get_wlr_tablet_tool( libinput_event_tablet_tool_get_tool(tevent)); - ensure_tool_reference(tool, wlr_dev->tablet_tool); + ensure_tool_reference(tool, wlr_dev->tablet); wlr_event.device = wlr_dev; wlr_event.tool = &tool->wlr_tool; @@ -327,7 +328,7 @@ void handle_tablet_tool_tip(struct libinput_event *event, wlr_event.state = WLR_TABLET_TOOL_TIP_DOWN; break; } - wlr_signal_emit_safe(&wlr_dev->tablet_tool->events.tip, &wlr_event); + wlr_signal_emit_safe(&wlr_dev->tablet->events.tip, &wlr_event); } void handle_tablet_tool_button(struct libinput_event *event, @@ -344,7 +345,7 @@ void handle_tablet_tool_button(struct libinput_event *event, struct wlr_event_tablet_tool_button wlr_event = { 0 }; struct wlr_libinput_tablet_tool *tool = get_wlr_tablet_tool( libinput_event_tablet_tool_get_tool(tevent)); - ensure_tool_reference(tool, wlr_dev->tablet_tool); + ensure_tool_reference(tool, wlr_dev->tablet); wlr_event.device = wlr_dev; wlr_event.tool = &tool->wlr_tool; @@ -359,5 +360,5 @@ void handle_tablet_tool_button(struct libinput_event *event, wlr_event.state = WLR_BUTTON_PRESSED; break; } - wlr_signal_emit_safe(&wlr_dev->tablet_tool->events.button, &wlr_event); + wlr_signal_emit_safe(&wlr_dev->tablet->events.button, &wlr_event); } diff --git a/examples/tablet.c b/examples/tablet.c index 7332afe0..4a27d0e1 100644 --- a/examples/tablet.c +++ b/examples/tablet.c @@ -326,11 +326,11 @@ void new_input_notify(struct wl_listener *listener, void *data) { tstate->destroy.notify = tablet_tool_destroy_notify; wl_signal_add(&device->events.destroy, &tstate->destroy); tstate->axis.notify = tablet_tool_axis_notify; - wl_signal_add(&device->tablet_tool->events.axis, &tstate->axis); + wl_signal_add(&device->tablet->events.axis, &tstate->axis); tstate->proximity.notify = tablet_tool_proximity_notify; - wl_signal_add(&device->tablet_tool->events.proximity, &tstate->proximity); + wl_signal_add(&device->tablet->events.proximity, &tstate->proximity); tstate->button.notify = tablet_tool_button_notify; - wl_signal_add(&device->tablet_tool->events.button, &tstate->button); + wl_signal_add(&device->tablet->events.button, &tstate->button); wl_list_insert(&sample->tablet_tools, &tstate->link); break; default: diff --git a/include/backend/libinput.h b/include/backend/libinput.h index f0928133..d1fb3a44 100644 --- a/include/backend/libinput.h +++ b/include/backend/libinput.h @@ -65,7 +65,7 @@ void handle_touch_motion(struct libinput_event *event, void handle_touch_cancel(struct libinput_event *event, struct libinput_device *device); -struct wlr_tablet_tool *create_libinput_tablet_tool( +struct wlr_tablet *create_libinput_tablet( struct libinput_device *device); void handle_tablet_tool_axis(struct libinput_event *event, struct libinput_device *device); diff --git a/include/wlr/interfaces/wlr_tablet_tool.h b/include/wlr/interfaces/wlr_tablet_tool.h index 347a0003..12b2e32e 100644 --- a/include/wlr/interfaces/wlr_tablet_tool.h +++ b/include/wlr/interfaces/wlr_tablet_tool.h @@ -3,12 +3,12 @@ #include -struct wlr_tablet_tool_impl { - void (*destroy)(struct wlr_tablet_tool *tool); +struct wlr_tablet_impl { + void (*destroy)(struct wlr_tablet *tablet); }; -void wlr_tablet_tool_init(struct wlr_tablet_tool *tool, - struct wlr_tablet_tool_impl *impl); -void wlr_tablet_tool_destroy(struct wlr_tablet_tool *tool); +void wlr_tablet_init(struct wlr_tablet *tablet, + struct wlr_tablet_impl *impl); +void wlr_tablet_destroy(struct wlr_tablet *tablet); #endif diff --git a/include/wlr/types/wlr_input_device.h b/include/wlr/types/wlr_input_device.h index 5cf26b65..cce15d90 100644 --- a/include/wlr/types/wlr_input_device.h +++ b/include/wlr/types/wlr_input_device.h @@ -39,7 +39,7 @@ struct wlr_input_device { struct wlr_keyboard *keyboard; struct wlr_pointer *pointer; struct wlr_touch *touch; - struct wlr_tablet_tool *tablet_tool; + struct wlr_tablet *tablet; struct wlr_tablet_pad *tablet_pad; }; diff --git a/include/wlr/types/wlr_tablet_tool.h b/include/wlr/types/wlr_tablet_tool.h index 0a92ffe2..bfa2e1f7 100644 --- a/include/wlr/types/wlr_tablet_tool.h +++ b/include/wlr/types/wlr_tablet_tool.h @@ -15,13 +15,13 @@ enum wlr_tablet_tool_type { WLR_TABLET_TOOL_TYPE_ERASER, /**< Eraser */ WLR_TABLET_TOOL_TYPE_BRUSH, /**< A paintbrush-like tool */ WLR_TABLET_TOOL_TYPE_PENCIL, /**< Physical drawing tool, e.g. - Wacom Inking Pen */ + Wacom Inking Pen */ WLR_TABLET_TOOL_TYPE_AIRBRUSH, /**< An airbrush-like tool */ WLR_TABLET_TOOL_TYPE_MOUSE, /**< A mouse bound to the tablet */ WLR_TABLET_TOOL_TYPE_LENS, /**< A mouse tool with a lens */ }; -struct wlr_tablet_tool_tool { +struct wlr_tablet_tool { enum wlr_tablet_tool_type type; uint64_t hardware_serial; uint64_t hardware_wacom; @@ -41,10 +41,10 @@ struct wlr_tablet_tool_tool { void *data; }; -struct wlr_tablet_tool_impl; +struct wlr_tablet_impl; -struct wlr_tablet_tool { - struct wlr_tablet_tool_impl *impl; +struct wlr_tablet { + struct wlr_tablet_impl *impl; struct { struct wl_signal axis; @@ -73,7 +73,7 @@ enum wlr_tablet_tool_axes { struct wlr_event_tablet_tool_axis { struct wlr_input_device *device; - struct wlr_tablet_tool_tool *tool; + struct wlr_tablet_tool *tool; uint32_t time_msec; uint32_t updated_axes; @@ -96,7 +96,7 @@ enum wlr_tablet_tool_proximity_state { struct wlr_event_tablet_tool_proximity { struct wlr_input_device *device; - struct wlr_tablet_tool_tool *tool; + struct wlr_tablet_tool *tool; uint32_t time_msec; // From 0..1 double x, y; @@ -110,7 +110,7 @@ enum wlr_tablet_tool_tip_state { struct wlr_event_tablet_tool_tip { struct wlr_input_device *device; - struct wlr_tablet_tool_tool *tool; + struct wlr_tablet_tool *tool; uint32_t time_msec; // From 0..1 double x, y; @@ -119,7 +119,7 @@ struct wlr_event_tablet_tool_tip { struct wlr_event_tablet_tool_button { struct wlr_input_device *device; - struct wlr_tablet_tool_tool *tool; + struct wlr_tablet_tool *tool; uint32_t time_msec; uint32_t button; enum wlr_button_state state; diff --git a/include/wlr/types/wlr_tablet_v2.h b/include/wlr/types/wlr_tablet_v2.h index 3818132c..bebf8a19 100644 --- a/include/wlr/types/wlr_tablet_v2.h +++ b/include/wlr/types/wlr_tablet_v2.h @@ -26,7 +26,7 @@ struct wlr_tablet_manager_v2 { struct wlr_tablet_v2_tablet { struct wl_list link; // wlr_tablet_seat_v2::tablets - struct wlr_tablet_tool *wlr_tool; + struct wlr_tablet *wlr_tablet; struct wlr_input_device *wlr_device; struct wl_list clients; // wlr_tablet_client_v2::tablet_link @@ -37,7 +37,7 @@ struct wlr_tablet_v2_tablet { struct wlr_tablet_v2_tablet_tool { struct wl_list link; // wlr_tablet_seat_v2::tablets - struct wlr_tablet_tool_tool *wlr_tool; + struct wlr_tablet_tool *wlr_tool; struct wl_list clients; // wlr_tablet_tool_client_v2::tool_link struct wl_listener tool_destroy; @@ -105,7 +105,7 @@ struct wlr_tablet_v2_tablet_pad *wlr_tablet_pad_create( struct wlr_tablet_v2_tablet_tool *wlr_tablet_tool_create( struct wlr_tablet_manager_v2 *manager, struct wlr_seat *wlr_seat, - struct wlr_tablet_tool_tool *wlr_tool); + struct wlr_tablet_tool *wlr_tool); struct wlr_tablet_manager_v2 *wlr_tablet_v2_create(struct wl_display *display); void wlr_tablet_v2_destroy(struct wlr_tablet_manager_v2 *manager); diff --git a/rootston/seat.c b/rootston/seat.c index 5bd6e752..89a32fa9 100644 --- a/rootston/seat.c +++ b/rootston/seat.c @@ -103,7 +103,7 @@ static void handle_touch_motion(struct wl_listener *listener, void *data) { static void handle_tablet_tool_position(struct roots_cursor *cursor, struct roots_tablet_tool *tool, - struct wlr_tablet_tool_tool *tool_tool, + struct wlr_tablet_tool *tool_tool, bool change_x, bool change_y, double x, double y, double dx, double dy) { if (!change_x && !change_y) { @@ -264,7 +264,7 @@ static void handle_tool_proximity(struct wl_listener *listener, void *data) { wlr_idle_notify_activity(desktop->idle, cursor->seat->seat); struct wlr_event_tablet_tool_proximity *event = data; - struct wlr_tablet_tool_tool *tool = event->tool; + struct wlr_tablet_tool *tool = event->tool; if (!tool->data) { struct roots_tablet_tool_tool *roots_tool = calloc(1, sizeof(struct roots_tablet_tool_tool)); diff --git a/types/tablet_v2/wlr_tablet_v2_tablet.c b/types/tablet_v2/wlr_tablet_v2_tablet.c index d3ef4de0..0d1b5aa3 100644 --- a/types/tablet_v2/wlr_tablet_v2_tablet.c +++ b/types/tablet_v2/wlr_tablet_v2_tablet.c @@ -59,13 +59,13 @@ struct wlr_tablet_v2_tablet *wlr_tablet_create( if (!seat) { return NULL; } - struct wlr_tablet_tool *tool = wlr_device->tablet_tool; + struct wlr_tablet *wlr_tablet = wlr_device->tablet; struct wlr_tablet_v2_tablet *tablet = calloc(1, sizeof(struct wlr_tablet_v2_tablet)); if (!tablet) { return NULL; } - tablet->wlr_tool = tool; + tablet->wlr_tablet = wlr_tablet; tablet->wlr_device = wlr_device; wl_list_init(&tablet->clients); @@ -107,14 +107,15 @@ void add_tablet_client(struct wlr_tablet_seat_client_v2 *seat, zwp_tablet_seat_v2_send_tablet_added(seat->resource, client->resource); // Send the expected events - if (tablet->wlr_tool->name) { - zwp_tablet_v2_send_name(client->resource, tablet->wlr_tool->name); + if (tablet->wlr_tablet->name) { + zwp_tablet_v2_send_name(client->resource, + tablet->wlr_tablet->name); } zwp_tablet_v2_send_id(client->resource, tablet->wlr_device->vendor, tablet->wlr_device->product); - for (size_t i = 0; i < tablet->wlr_tool->paths.length; ++i) { + for (size_t i = 0; i < tablet->wlr_tablet->paths.length; ++i) { zwp_tablet_v2_send_path(client->resource, - tablet->wlr_tool->paths.items[i]); + tablet->wlr_tablet->paths.items[i]); } zwp_tablet_v2_send_done(client->resource); diff --git a/types/tablet_v2/wlr_tablet_v2_tool.c b/types/tablet_v2/wlr_tablet_v2_tool.c index 9eefaad7..d254f21a 100644 --- a/types/tablet_v2/wlr_tablet_v2_tool.c +++ b/types/tablet_v2/wlr_tablet_v2_tool.c @@ -192,7 +192,7 @@ static void handle_wlr_tablet_tool_destroy(struct wl_listener *listener, void *d struct wlr_tablet_v2_tablet_tool *wlr_tablet_tool_create( struct wlr_tablet_manager_v2 *manager, struct wlr_seat *wlr_seat, - struct wlr_tablet_tool_tool *wlr_tool) { + struct wlr_tablet_tool *wlr_tool) { struct wlr_tablet_seat_v2 *seat = get_or_create_tablet_seat(manager, wlr_seat); if (!seat) { return NULL; diff --git a/types/wlr_cursor.c b/types/wlr_cursor.c index 4a30215f..82ad1a4a 100644 --- a/types/wlr_cursor.c +++ b/types/wlr_cursor.c @@ -551,19 +551,19 @@ static struct wlr_cursor_device *cursor_device_create( wl_signal_add(&device->touch->events.cancel, &c_device->touch_cancel); c_device->touch_cancel.notify = handle_touch_cancel; } else if (device->type == WLR_INPUT_DEVICE_TABLET_TOOL) { - wl_signal_add(&device->tablet_tool->events.tip, + wl_signal_add(&device->tablet->events.tip, &c_device->tablet_tool_tip); c_device->tablet_tool_tip.notify = handle_tablet_tool_tip; - wl_signal_add(&device->tablet_tool->events.proximity, + wl_signal_add(&device->tablet->events.proximity, &c_device->tablet_tool_proximity); c_device->tablet_tool_proximity.notify = handle_tablet_tool_proximity; - wl_signal_add(&device->tablet_tool->events.axis, + wl_signal_add(&device->tablet->events.axis, &c_device->tablet_tool_axis); c_device->tablet_tool_axis.notify = handle_tablet_tool_axis; - wl_signal_add(&device->tablet_tool->events.button, + wl_signal_add(&device->tablet->events.button, &c_device->tablet_tool_button); c_device->tablet_tool_button.notify = handle_tablet_tool_button; } diff --git a/types/wlr_input_device.c b/types/wlr_input_device.c index 3a8fc582..89ca13cb 100644 --- a/types/wlr_input_device.c +++ b/types/wlr_input_device.c @@ -44,7 +44,7 @@ void wlr_input_device_destroy(struct wlr_input_device *dev) { wlr_touch_destroy(dev->touch); break; case WLR_INPUT_DEVICE_TABLET_TOOL: - wlr_tablet_tool_destroy(dev->tablet_tool); + wlr_tablet_destroy(dev->tablet); break; case WLR_INPUT_DEVICE_TABLET_PAD: wlr_tablet_pad_destroy(dev->tablet_pad); diff --git a/types/wlr_tablet_tool.c b/types/wlr_tablet_tool.c index 85a13832..ca92d4e2 100644 --- a/types/wlr_tablet_tool.c +++ b/types/wlr_tablet_tool.c @@ -4,26 +4,26 @@ #include #include -void wlr_tablet_tool_init(struct wlr_tablet_tool *tool, - struct wlr_tablet_tool_impl *impl) { - tool->impl = impl; - wl_signal_init(&tool->events.axis); - wl_signal_init(&tool->events.proximity); - wl_signal_init(&tool->events.tip); - wl_signal_init(&tool->events.button); +void wlr_tablet_init(struct wlr_tablet *tablet, + struct wlr_tablet_impl *impl) { + tablet->impl = impl; + wl_signal_init(&tablet->events.axis); + wl_signal_init(&tablet->events.proximity); + wl_signal_init(&tablet->events.tip); + wl_signal_init(&tablet->events.button); } -void wlr_tablet_tool_destroy(struct wlr_tablet_tool *tool) { - if (!tool) { +void wlr_tablet_destroy(struct wlr_tablet *tablet) { + if (!tablet) { return; } - wlr_list_for_each(&tool->paths, free); - wlr_list_finish(&tool->paths); + wlr_list_for_each(&tablet->paths, free); + wlr_list_finish(&tablet->paths); - if (tool->impl && tool->impl->destroy) { - tool->impl->destroy(tool); + if (tablet->impl && tablet->impl->destroy) { + tablet->impl->destroy(tablet); } else { - free(tool); + free(tablet); } } -- cgit v1.2.3