aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorHeghedus Razvan <heghedus.razvan@gmail.com>2017-10-14 23:33:00 +0300
committerHeghedus Razvan <heghedus.razvan@gmail.com>2017-10-20 19:44:59 +0300
commitd3f0878d716011bf158b49b063f9391080c22c8a (patch)
tree24c8055bef5336243f5cb5f28718293ab84f1b86 /backend
parente1f196a3e9477385ca30180686cda82e3ab735ce (diff)
Replace list_t with wl_list in wlr_wl_backend
Now wlr_backend->outputs is a list of wlr_wl_backend_output instead of wlr_output. Signed-off-by: Heghedus Razvan <heghedus.razvan@gmail.com>
Diffstat (limited to 'backend')
-rw-r--r--backend/wayland/backend.c35
-rw-r--r--backend/wayland/output.c9
-rw-r--r--backend/wayland/wl_seat.c6
3 files changed, 14 insertions, 36 deletions
diff --git a/backend/wayland/backend.c b/backend/wayland/backend.c
index e57f3583..84624bfe 100644
--- a/backend/wayland/backend.c
+++ b/backend/wayland/backend.c
@@ -64,16 +64,16 @@ static void wlr_wl_backend_destroy(struct wlr_backend *_backend) {
return;
}
- for (size_t i = 0; i < backend->outputs->length; ++i) {
- wlr_output_destroy(backend->outputs->items[i]);
+ struct wlr_wl_backend_output *output, *tmp_output;
+ wl_list_for_each_safe(output, tmp_output, &backend->outputs, link) {
+ wlr_output_destroy(&output->wlr_output);
}
- for (size_t i = 0; i < backend->devices->length; ++i) {
- wlr_input_device_destroy(backend->devices->items[i]);
+ struct wlr_input_device *input_device, *tmp_input_device;
+ wl_list_for_each_safe(input_device, tmp_input_device, &backend->devices, link) {
+ wlr_input_device_destroy(input_device);
}
- list_free(backend->devices);
- list_free(backend->outputs);
free(backend->seat_name);
wl_event_source_remove(backend->remote_display_src);
@@ -104,8 +104,8 @@ bool wlr_backend_is_wl(struct wlr_backend *b) {
struct wlr_wl_backend_output *wlr_wl_output_for_surface(
struct wlr_wl_backend *backend, struct wl_surface *surface) {
- for (size_t i = 0; i < backend->outputs->length; ++i) {
- struct wlr_wl_backend_output *output = backend->outputs->items[i];
+ struct wlr_wl_backend_output *output;
+ wl_list_for_each(output, &backend->outputs, link) {
if (output->surface == surface) {
return output;
}
@@ -123,15 +123,8 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display) {
}
wlr_backend_init(&backend->backend, &backend_impl);
- if (!(backend->devices = list_create())) {
- wlr_log(L_ERROR, "Could not allocate devices list");
- goto error;
- }
-
- if (!(backend->outputs = list_create())) {
- wlr_log(L_ERROR, "Could not allocate outputs list");
- goto error;
- }
+ wl_list_init(&backend->devices);
+ wl_list_init(&backend->outputs);
backend->local_display = display;
@@ -150,12 +143,4 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display) {
wlr_egl_bind_display(&backend->egl, backend->local_display);
return &backend->backend;
-
-error:
- if (backend) {
- list_free(backend->devices);
- list_free(backend->outputs);
- }
- free(backend);
- return NULL;
}
diff --git a/backend/wayland/output.c b/backend/wayland/output.c
index e1138ee1..1a0f0364 100644
--- a/backend/wayland/output.c
+++ b/backend/wayland/output.c
@@ -248,8 +248,8 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *_backend) {
wlr_output->height = 480;
strncpy(wlr_output->make, "wayland", sizeof(wlr_output->make));
strncpy(wlr_output->model, "wayland", sizeof(wlr_output->model));
- snprintf(wlr_output->name, sizeof(wlr_output->name), "WL-%zd",
- backend->outputs->length + 1);
+ snprintf(wlr_output->name, sizeof(wlr_output->name), "WL-%d",
+ wl_list_length(&backend->outputs) + 1);
wlr_output_update_matrix(wlr_output);
output->backend = backend;
@@ -306,10 +306,7 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *_backend) {
goto error;
}
- if (list_add(backend->outputs, wlr_output) == -1) {
- wlr_log(L_ERROR, "Allocation failed");
- goto error;
- }
+ wl_list_insert(&backend->outputs, &output->link);
wlr_output_create_global(wlr_output, backend->local_display);
wl_signal_emit(&backend->backend.events.output_add, wlr_output);
return wlr_output;
diff --git a/backend/wayland/wl_seat.c b/backend/wayland/wl_seat.c
index d3ff9b64..30074abd 100644
--- a/backend/wayland/wl_seat.c
+++ b/backend/wayland/wl_seat.c
@@ -204,11 +204,7 @@ static struct wlr_input_device *allocate_device(struct wlr_wl_backend *backend,
struct wlr_input_device *wlr_device = &wlr_wl_dev->wlr_input_device;
wlr_input_device_init(wlr_device, type, &input_device_impl,
name, vendor, product);
- if (list_add(backend->devices, wlr_device) == -1) {
- wlr_log_errno(L_ERROR, "Allocation failed");
- free(wlr_wl_dev);
- return NULL;
- }
+ wl_list_insert(&backend->devices, &wlr_device->link);
return wlr_device;
}