diff --git a/backend/libinput/tablet_pad.c b/backend/libinput/tablet_pad.c index 691bb185..c9ec30ae 100644 --- a/backend/libinput/tablet_pad.c +++ b/backend/libinput/tablet_pad.c @@ -85,7 +85,8 @@ struct wlr_tablet_pad *create_libinput_tablet_pad( libinput_device_tablet_pad_get_num_strips(libinput_dev); struct udev_device *udev = libinput_device_get_udev_device(libinput_dev); - wlr_list_push(&wlr_tablet_pad->paths, strdup(udev_device_get_syspath(udev))); + char **dst = wl_array_add(&wlr_tablet_pad->paths, sizeof(char *)); + *dst = strdup(udev_device_get_syspath(udev)); int groups = libinput_device_tablet_pad_get_num_mode_groups(libinput_dev); for (int i = 0; i < groups; ++i) { diff --git a/backend/libinput/tablet_tool.c b/backend/libinput/tablet_tool.c index a6deeec8..5b867cef 100644 --- a/backend/libinput/tablet_tool.c +++ b/backend/libinput/tablet_tool.c @@ -84,15 +84,18 @@ struct wlr_tablet *create_libinput_tablet( wlr_log(WLR_ERROR, "Unable to allocate wlr_tablet_tool"); return NULL; } - struct wlr_tablet *wlr_tablet = &libinput_tablet->wlr_tablet; - wlr_list_init(&wlr_tablet->paths); + struct wlr_tablet *wlr_tablet = &libinput_tablet->wlr_tablet; + wlr_tablet_init(wlr_tablet, &tablet_impl); + struct udev_device *udev = libinput_device_get_udev_device(libinput_dev); - wlr_list_push(&wlr_tablet->paths, strdup(udev_device_get_syspath(udev))); + char **dst = wl_array_add(&wlr_tablet->paths, sizeof(char *)); + *dst = strdup(udev_device_get_syspath(udev)); + wlr_tablet->name = strdup(libinput_device_get_name(libinput_dev)); + wl_list_init(&libinput_tablet->tools); - wlr_tablet_init(wlr_tablet, &tablet_impl); return wlr_tablet; } diff --git a/backend/wayland/tablet_v2.c b/backend/wayland/tablet_v2.c index b7ad73ea..9f90a369 100644 --- a/backend/wayland/tablet_v2.c +++ b/backend/wayland/tablet_v2.c @@ -336,7 +336,8 @@ static void handle_tablet_pad_path(void *data, struct wlr_wl_input_device *dev = data; struct wlr_tablet_pad *tablet_pad = dev->wlr_input_device.tablet_pad; - wlr_list_push(&tablet_pad->paths, strdup(path)); + char **dst = wl_array_add(&tablet_pad->paths, sizeof(char *)); + *dst = strdup(path); } static void handle_tablet_pad_buttons(void *data, @@ -854,7 +855,8 @@ static void handle_tablet_path(void *data, struct zwp_tablet_v2 *zwp_tablet_v2, struct wlr_wl_input_device *dev = data; struct wlr_tablet *tablet = dev->wlr_input_device.tablet; - wlr_list_push(&tablet->paths, strdup(path)); + char **dst = wl_array_add(&tablet->paths, sizeof(char *)); + *dst = strdup(path); } static void handle_tablet_done(void *data, struct zwp_tablet_v2 *zwp_tablet_v2) { diff --git a/include/wlr/types/wlr_tablet_pad.h b/include/wlr/types/wlr_tablet_pad.h index 255fa89e..6cd1b70e 100644 --- a/include/wlr/types/wlr_tablet_pad.h +++ b/include/wlr/types/wlr_tablet_pad.h @@ -12,7 +12,6 @@ #include #include #include -#include /* * NOTE: the wlr tablet pad implementation does not currently support tablets @@ -37,7 +36,7 @@ struct wlr_tablet_pad { size_t strip_count; struct wl_list groups; // wlr_tablet_pad_group::link - struct wlr_list paths; // char * + struct wl_array paths; // char * void *data; }; diff --git a/include/wlr/types/wlr_tablet_tool.h b/include/wlr/types/wlr_tablet_tool.h index 9dbf6ffb..75fc1ee8 100644 --- a/include/wlr/types/wlr_tablet_tool.h +++ b/include/wlr/types/wlr_tablet_tool.h @@ -12,7 +12,6 @@ #include #include #include -#include /* * Copy+Paste from libinput, but this should neither use libinput, nor @@ -71,7 +70,7 @@ struct wlr_tablet { } events; char *name; - struct wlr_list paths; // char * + struct wl_array paths; // char * void *data; }; diff --git a/types/tablet_v2/wlr_tablet_v2_pad.c b/types/tablet_v2/wlr_tablet_v2_pad.c index 4ceede91..e961dc3e 100644 --- a/types/tablet_v2/wlr_tablet_v2_pad.c +++ b/types/tablet_v2/wlr_tablet_v2_pad.c @@ -325,10 +325,12 @@ void add_tablet_pad_client(struct wlr_tablet_seat_client_v2 *seat, if (pad->wlr_pad->button_count) { zwp_tablet_pad_v2_send_buttons(client->resource, pad->wlr_pad->button_count); } - for (size_t i = 0; i < pad->wlr_pad->paths.length; ++i) { - zwp_tablet_pad_v2_send_path(client->resource, - pad->wlr_pad->paths.items[i]); + + const char *path; + wl_array_for_each(path, &pad->wlr_pad->paths) { + zwp_tablet_pad_v2_send_path(client->resource, path); } + size_t i = 0; struct wlr_tablet_pad_group *group; client->group_count = pad->group_count; diff --git a/types/tablet_v2/wlr_tablet_v2_tablet.c b/types/tablet_v2/wlr_tablet_v2_tablet.c index 397d97cb..16042995 100644 --- a/types/tablet_v2/wlr_tablet_v2_tablet.c +++ b/types/tablet_v2/wlr_tablet_v2_tablet.c @@ -113,10 +113,12 @@ void add_tablet_client(struct wlr_tablet_seat_client_v2 *seat, } zwp_tablet_v2_send_id(client->resource, tablet->wlr_device->vendor, tablet->wlr_device->product); - for (size_t i = 0; i < tablet->wlr_tablet->paths.length; ++i) { - zwp_tablet_v2_send_path(client->resource, - tablet->wlr_tablet->paths.items[i]); + + const char *path; + wl_array_for_each(path, &tablet->wlr_tablet->paths) { + zwp_tablet_v2_send_path(client->resource, path); } + zwp_tablet_v2_send_done(client->resource); client->client = seat->wl_client; diff --git a/types/wlr_tablet_pad.c b/types/wlr_tablet_pad.c index aa0111fe..3f9e2651 100644 --- a/types/wlr_tablet_pad.c +++ b/types/wlr_tablet_pad.c @@ -13,7 +13,7 @@ void wlr_tablet_pad_init(struct wlr_tablet_pad *pad, wl_signal_init(&pad->events.attach_tablet); wl_list_init(&pad->groups); - wlr_list_init(&pad->paths); + wl_array_init(&pad->paths); } void wlr_tablet_pad_destroy(struct wlr_tablet_pad *pad) { @@ -21,8 +21,11 @@ void wlr_tablet_pad_destroy(struct wlr_tablet_pad *pad) { return; } - wlr_list_for_each(&pad->paths, free); - wlr_list_finish(&pad->paths); + char *path; + wl_array_for_each(path, &pad->paths) { + free(path); + } + wl_array_release(&pad->paths); if (pad->impl && pad->impl->destroy) { pad->impl->destroy(pad); diff --git a/types/wlr_tablet_tool.c b/types/wlr_tablet_tool.c index 5738cca9..f01ae3c3 100644 --- a/types/wlr_tablet_tool.c +++ b/types/wlr_tablet_tool.c @@ -11,6 +11,7 @@ void wlr_tablet_init(struct wlr_tablet *tablet, wl_signal_init(&tablet->events.proximity); wl_signal_init(&tablet->events.tip); wl_signal_init(&tablet->events.button); + wl_array_init(&tablet->paths); } void wlr_tablet_destroy(struct wlr_tablet *tablet) { @@ -18,8 +19,11 @@ void wlr_tablet_destroy(struct wlr_tablet *tablet) { return; } - wlr_list_for_each(&tablet->paths, free); - wlr_list_finish(&tablet->paths); + char *path; + wl_array_for_each(path, &tablet->paths) { + free(path); + } + wl_array_release(&tablet->paths); if (tablet->impl && tablet->impl->destroy) { tablet->impl->destroy(tablet);