diff options
author | Drew DeVault <sir@cmpwn.com> | 2017-11-20 15:32:47 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-20 15:32:47 -0500 |
commit | 6bde8dd56beebc429445196d7d4a120677289317 (patch) | |
tree | f6256c013de96d3acfd4218b1f516249bd63c0d6 /backend | |
parent | becd75fd2ebd31fec9fdcf9cc2f37c5957d31b37 (diff) | |
parent | 64221c6da1a8783ba1e614a1c821b585b1e70ab8 (diff) |
Merge pull request #431 from emersion/refactor-wlr-list
Refactor wlr_list
Diffstat (limited to 'backend')
-rw-r--r-- | backend/libinput/backend.c | 15 | ||||
-rw-r--r-- | backend/libinput/events.c | 8 |
2 files changed, 12 insertions, 11 deletions
diff --git a/backend/libinput/backend.c b/backend/libinput/backend.c index 45b4e368..1028e238 100644 --- a/backend/libinput/backend.c +++ b/backend/libinput/backend.c @@ -69,9 +69,9 @@ static bool wlr_libinput_backend_start(struct wlr_backend *_backend) { no_devs = NULL; } } - if (!no_devs && backend->wlr_device_lists->length == 0) { + if (!no_devs && backend->wlr_device_lists.length == 0) { wlr_libinput_readable(libinput_fd, WL_EVENT_READABLE, backend); - if (backend->wlr_device_lists->length == 0) { + if (backend->wlr_device_lists.length == 0) { wlr_log(L_ERROR, "libinput initialization failed, no input devices"); wlr_log(L_ERROR, "Set WLR_LIBINPUT_NO_DEVICES=1 to suppress this check"); return false; @@ -97,9 +97,10 @@ static void wlr_libinput_backend_destroy(struct wlr_backend *_backend) { if (!_backend) { return; } - struct wlr_libinput_backend *backend = (struct wlr_libinput_backend *)_backend; - for (size_t i = 0; i < backend->wlr_device_lists->length; i++) { - struct wl_list *wlr_devices = backend->wlr_device_lists->items[i]; + struct wlr_libinput_backend *backend = + (struct wlr_libinput_backend *)_backend; + for (size_t i = 0; i < backend->wlr_device_lists.length; i++) { + struct wl_list *wlr_devices = backend->wlr_device_lists.items[i]; struct wlr_input_device *wlr_dev, *next; wl_list_for_each_safe(wlr_dev, next, wlr_devices, link) { wl_signal_emit(&backend->backend.events.input_remove, wlr_dev); @@ -107,7 +108,7 @@ static void wlr_libinput_backend_destroy(struct wlr_backend *_backend) { } free(wlr_devices); } - wlr_list_free(backend->wlr_device_lists); + wlr_list_finish(&backend->wlr_device_lists); wl_event_source_remove(backend->input_event); libinput_unref(backend->libinput_context); free(backend); @@ -148,7 +149,7 @@ struct wlr_backend *wlr_libinput_backend_create(struct wl_display *display, } wlr_backend_init(&backend->backend, &backend_impl); - if (!(backend->wlr_device_lists = wlr_list_create())) { + if (!wlr_list_init(&backend->wlr_device_lists)) { wlr_log(L_ERROR, "Allocation failed: %s", strerror(errno)); goto error_backend; } diff --git a/backend/libinput/events.c b/backend/libinput/events.c index 3ca41124..c14aef01 100644 --- a/backend/libinput/events.c +++ b/backend/libinput/events.c @@ -147,7 +147,7 @@ static void handle_device_added(struct wlr_libinput_backend *backend, if (wl_list_length(wlr_devices) > 0) { libinput_device_set_user_data(libinput_dev, wlr_devices); - wlr_list_add(backend->wlr_device_lists, wlr_devices); + wlr_list_push(&backend->wlr_device_lists, wlr_devices); } else { free(wlr_devices); } @@ -177,9 +177,9 @@ static void handle_device_removed(struct wlr_libinput_backend *backend, wl_signal_emit(&backend->backend.events.input_remove, dev); wlr_input_device_destroy(dev); } - for (size_t i = 0; i < backend->wlr_device_lists->length; i++) { - if (backend->wlr_device_lists->items[i] == wlr_devices) { - wlr_list_del(backend->wlr_device_lists, i); + for (size_t i = 0; i < backend->wlr_device_lists.length; i++) { + if (backend->wlr_device_lists.items[i] == wlr_devices) { + wlr_list_del(&backend->wlr_device_lists, i); break; } } |