Replace list_t with wl_list in wlr_multi_backend

Signed-off-by: Heghedus Razvan <heghedus.razvan@gmail.com>
This commit is contained in:
Heghedus Razvan 2017-10-14 22:55:45 +03:00
parent a339b10dcd
commit bde25fe020
2 changed files with 12 additions and 22 deletions

View File

@ -13,14 +13,15 @@ struct subbackend_state {
struct wl_listener input_remove; struct wl_listener input_remove;
struct wl_listener output_add; struct wl_listener output_add;
struct wl_listener output_remove; struct wl_listener output_remove;
struct wl_list link;
}; };
static bool multi_backend_start(struct wlr_backend *_backend) { static bool multi_backend_start(struct wlr_backend *_backend) {
struct wlr_multi_backend *backend = (struct wlr_multi_backend *)_backend; struct wlr_multi_backend *backend = (struct wlr_multi_backend *)_backend;
for (size_t i = 0; i < backend->backends->length; ++i) { struct subbackend_state *sub;
struct subbackend_state *sub = backend->backends->items[i]; wl_list_for_each(sub, &backend->backends, link) {
if (!wlr_backend_start(sub->backend)) { if (!wlr_backend_start(sub->backend)) {
wlr_log(L_ERROR, "Failed to initialize backend %zd", i); wlr_log(L_ERROR, "Failed to initialize backend.");
return false; return false;
} }
} }
@ -29,20 +30,19 @@ static bool multi_backend_start(struct wlr_backend *_backend) {
static void multi_backend_destroy(struct wlr_backend *_backend) { static void multi_backend_destroy(struct wlr_backend *_backend) {
struct wlr_multi_backend *backend = (struct wlr_multi_backend *)_backend; struct wlr_multi_backend *backend = (struct wlr_multi_backend *)_backend;
for (size_t i = 0; i < backend->backends->length; ++i) { struct subbackend_state *sub;
struct subbackend_state *sub = backend->backends->items[i]; wl_list_for_each(sub, &backend->backends, link) {
wlr_backend_destroy(sub->backend); wlr_backend_destroy(sub->backend);
free(sub); free(sub);
} }
list_free(backend->backends);
wlr_session_destroy(backend->session); wlr_session_destroy(backend->session);
free(backend); free(backend);
} }
static struct wlr_egl *multi_backend_get_egl(struct wlr_backend *_backend) { static struct wlr_egl *multi_backend_get_egl(struct wlr_backend *_backend) {
struct wlr_multi_backend *backend = (struct wlr_multi_backend *)_backend; struct wlr_multi_backend *backend = (struct wlr_multi_backend *)_backend;
for (size_t i = 0; i < backend->backends->length; ++i) { struct subbackend_state *sub;
struct subbackend_state *sub = backend->backends->items[i]; wl_list_for_each(sub, &backend->backends, link) {
struct wlr_egl *egl = wlr_backend_get_egl(sub->backend); struct wlr_egl *egl = wlr_backend_get_egl(sub->backend);
if (egl) { if (egl) {
return egl; return egl;
@ -65,13 +65,7 @@ struct wlr_backend *wlr_multi_backend_create(struct wlr_session *session) {
return NULL; return NULL;
} }
backend->backends = list_create(); wl_list_init(&backend->backends);
if (!backend->backends) {
free(backend);
wlr_log(L_ERROR, "Backend allocation failed");
return NULL;
}
wlr_backend_init(&backend->backend, &backend_impl); wlr_backend_init(&backend->backend, &backend_impl);
backend->session = session; backend->session = session;
@ -116,11 +110,7 @@ void wlr_multi_backend_add(struct wlr_backend *_multi,
wlr_log(L_ERROR, "Could not add backend: allocation failed"); wlr_log(L_ERROR, "Could not add backend: allocation failed");
return; return;
} }
if (list_add(multi->backends, sub) == -1) { wl_list_insert(&multi->backends, &sub->link);
wlr_log(L_ERROR, "Could not add backend: allocation failed");
free(sub);
return;
}
sub->backend = backend; sub->backend = backend;
sub->container = &multi->backend; sub->container = &multi->backend;

View File

@ -3,14 +3,14 @@
#include <wlr/backend/interface.h> #include <wlr/backend/interface.h>
#include <wlr/backend/multi.h> #include <wlr/backend/multi.h>
#include <wlr/util/list.h>
#include <wlr/backend/session.h> #include <wlr/backend/session.h>
#include <wayland-util.h>
struct wlr_multi_backend { struct wlr_multi_backend {
struct wlr_backend backend; struct wlr_backend backend;
struct wlr_session *session; struct wlr_session *session;
list_t *backends; struct wl_list backends;
}; };
#endif #endif