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>
This commit is contained in:
Heghedus Razvan 2017-10-14 23:33:00 +03:00
parent e1f196a3e9
commit d3f0878d71
5 changed files with 19 additions and 39 deletions

View file

@ -64,16 +64,16 @@ static void wlr_wl_backend_destroy(struct wlr_backend *_backend) {
return; return;
} }
for (size_t i = 0; i < backend->outputs->length; ++i) { struct wlr_wl_backend_output *output, *tmp_output;
wlr_output_destroy(backend->outputs->items[i]); 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) { struct wlr_input_device *input_device, *tmp_input_device;
wlr_input_device_destroy(backend->devices->items[i]); 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); free(backend->seat_name);
wl_event_source_remove(backend->remote_display_src); 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_output *wlr_wl_output_for_surface(
struct wlr_wl_backend *backend, struct wl_surface *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;
struct wlr_wl_backend_output *output = backend->outputs->items[i]; wl_list_for_each(output, &backend->outputs, link) {
if (output->surface == surface) { if (output->surface == surface) {
return output; return output;
} }
@ -123,15 +123,8 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display) {
} }
wlr_backend_init(&backend->backend, &backend_impl); wlr_backend_init(&backend->backend, &backend_impl);
if (!(backend->devices = list_create())) { wl_list_init(&backend->devices);
wlr_log(L_ERROR, "Could not allocate devices list"); wl_list_init(&backend->outputs);
goto error;
}
if (!(backend->outputs = list_create())) {
wlr_log(L_ERROR, "Could not allocate outputs list");
goto error;
}
backend->local_display = display; 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); wlr_egl_bind_display(&backend->egl, backend->local_display);
return &backend->backend; return &backend->backend;
error:
if (backend) {
list_free(backend->devices);
list_free(backend->outputs);
}
free(backend);
return NULL;
} }

View file

@ -248,8 +248,8 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *_backend) {
wlr_output->height = 480; wlr_output->height = 480;
strncpy(wlr_output->make, "wayland", sizeof(wlr_output->make)); strncpy(wlr_output->make, "wayland", sizeof(wlr_output->make));
strncpy(wlr_output->model, "wayland", sizeof(wlr_output->model)); strncpy(wlr_output->model, "wayland", sizeof(wlr_output->model));
snprintf(wlr_output->name, sizeof(wlr_output->name), "WL-%zd", snprintf(wlr_output->name, sizeof(wlr_output->name), "WL-%d",
backend->outputs->length + 1); wl_list_length(&backend->outputs) + 1);
wlr_output_update_matrix(wlr_output); wlr_output_update_matrix(wlr_output);
output->backend = backend; output->backend = backend;
@ -306,10 +306,7 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *_backend) {
goto error; goto error;
} }
if (list_add(backend->outputs, wlr_output) == -1) { wl_list_insert(&backend->outputs, &output->link);
wlr_log(L_ERROR, "Allocation failed");
goto error;
}
wlr_output_create_global(wlr_output, backend->local_display); wlr_output_create_global(wlr_output, backend->local_display);
wl_signal_emit(&backend->backend.events.output_add, wlr_output); wl_signal_emit(&backend->backend.events.output_add, wlr_output);
return wlr_output; return wlr_output;

View file

@ -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; struct wlr_input_device *wlr_device = &wlr_wl_dev->wlr_input_device;
wlr_input_device_init(wlr_device, type, &input_device_impl, wlr_input_device_init(wlr_device, type, &input_device_impl,
name, vendor, product); name, vendor, product);
if (list_add(backend->devices, wlr_device) == -1) { wl_list_insert(&backend->devices, &wlr_device->link);
wlr_log_errno(L_ERROR, "Allocation failed");
free(wlr_wl_dev);
return NULL;
}
return wlr_device; return wlr_device;
} }

View file

@ -9,7 +9,7 @@
#include <wlr/backend/wayland.h> #include <wlr/backend/wayland.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_input_device.h> #include <wlr/types/wlr_input_device.h>
#include <wlr/util/list.h> #include <wayland-util.h>
struct wlr_wl_backend { struct wlr_wl_backend {
struct wlr_backend backend; struct wlr_backend backend;
@ -17,8 +17,8 @@ struct wlr_wl_backend {
/* local state */ /* local state */
bool started; bool started;
struct wl_display *local_display; struct wl_display *local_display;
list_t *devices; struct wl_list devices;
list_t *outputs; struct wl_list outputs;
struct wlr_egl egl; struct wlr_egl egl;
size_t requested_outputs; size_t requested_outputs;
/* remote state */ /* remote state */
@ -51,6 +51,7 @@ struct wlr_wl_backend_output {
uint32_t enter_serial; uint32_t enter_serial;
void *egl_surface; void *egl_surface;
struct wl_list link;
}; };
struct wlr_wl_input_device { struct wlr_wl_input_device {

View file

@ -1,6 +1,7 @@
#ifndef WLR_TYPES_WLR_OUTPUT_H #ifndef WLR_TYPES_WLR_OUTPUT_H
#define WLR_TYPES_WLR_OUTPUT_H #define WLR_TYPES_WLR_OUTPUT_H
#include <wayland-util.h>
#include <wayland-server.h> #include <wayland-server.h>
#include <stdbool.h> #include <stdbool.h>