From a937016e38efe3d7ad71540755833242059e6902 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Tue, 19 Dec 2017 18:25:46 -0500 Subject: remove session from multibackend --- include/wlr/backend/multi.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/wlr/backend/multi.h') diff --git a/include/wlr/backend/multi.h b/include/wlr/backend/multi.h index e56b07b1..fc53f369 100644 --- a/include/wlr/backend/multi.h +++ b/include/wlr/backend/multi.h @@ -4,8 +4,8 @@ #include #include -struct wlr_backend *wlr_multi_backend_create(struct wl_display *display, - struct wlr_session *session); +struct wlr_backend *wlr_multi_backend_create(struct wl_display *display); + void wlr_multi_backend_add(struct wlr_backend *multi, struct wlr_backend *backend); -- cgit v1.2.3 From 58e69c9ce177f3de4790bddd161e9d74dd2e512c Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Tue, 19 Dec 2017 18:49:00 -0500 Subject: multibackend remove subbackend --- backend/multi/backend.c | 31 ++++++++++++++++++++++++++++++- include/wlr/backend/multi.h | 3 +++ 2 files changed, 33 insertions(+), 1 deletion(-) (limited to 'include/wlr/backend/multi.h') diff --git a/backend/multi/backend.c b/backend/multi/backend.c index 8659d8ec..e6be4a20 100644 --- a/backend/multi/backend.c +++ b/backend/multi/backend.c @@ -118,11 +118,27 @@ static void handle_subbackend_destroy(struct wl_listener *listener, subbackend_state_destroy(state); } +static struct subbackend_state *multi_backend_get_subbackend(struct wlr_multi_backend *multi, + struct wlr_backend *backend) { + struct subbackend_state *sub = NULL; + wl_list_for_each(sub, &multi->backends, link) { + if (sub->backend == backend) { + return sub; + } + } + return NULL; +} + void wlr_multi_backend_add(struct wlr_backend *_multi, struct wlr_backend *backend) { assert(wlr_backend_is_multi(_multi)); - struct wlr_multi_backend *multi = (struct wlr_multi_backend *)_multi; + + if (multi_backend_get_subbackend(multi, backend)) { + // already added + return; + } + struct subbackend_state *sub; if (!(sub = calloc(1, sizeof(struct subbackend_state)))) { wlr_log(L_ERROR, "Could not add backend: allocation failed"); @@ -149,6 +165,19 @@ void wlr_multi_backend_add(struct wlr_backend *_multi, sub->output_remove.notify = output_remove_reemit; } +void wlr_multi_backend_remove(struct wlr_backend *_multi, + struct wlr_backend *backend) { + assert(wlr_backend_is_multi(_multi)); + struct wlr_multi_backend *multi = (struct wlr_multi_backend *)_multi; + + struct subbackend_state *sub = + multi_backend_get_subbackend(multi, backend); + + if (sub) { + subbackend_state_destroy(sub); + } +} + struct wlr_session *wlr_multi_get_session(struct wlr_backend *_backend) { assert(wlr_backend_is_multi(_backend)); diff --git a/include/wlr/backend/multi.h b/include/wlr/backend/multi.h index fc53f369..35f7c165 100644 --- a/include/wlr/backend/multi.h +++ b/include/wlr/backend/multi.h @@ -9,6 +9,9 @@ struct wlr_backend *wlr_multi_backend_create(struct wl_display *display); void wlr_multi_backend_add(struct wlr_backend *multi, struct wlr_backend *backend); +void wlr_multi_backend_remove(struct wlr_backend *multi, + struct wlr_backend *backend); + bool wlr_backend_is_multi(struct wlr_backend *backend); struct wlr_session *wlr_multi_get_session(struct wlr_backend *base); -- cgit v1.2.3 From ee39dff1e7de4a234f2ff39c1ce2df6bc84abb04 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Wed, 20 Dec 2017 05:51:23 -0500 Subject: rootston: handle backend creation failed --- backend/multi/backend.c | 7 ++++++- include/backend/multi.h | 2 -- include/wlr/backend/multi.h | 2 ++ rootston/main.c | 7 +++++++ 4 files changed, 15 insertions(+), 3 deletions(-) (limited to 'include/wlr/backend/multi.h') diff --git a/backend/multi/backend.c b/backend/multi/backend.c index e6be4a20..c000342b 100644 --- a/backend/multi/backend.c +++ b/backend/multi/backend.c @@ -42,7 +42,6 @@ static void subbackend_state_destroy(struct subbackend_state *sub) { static void multi_backend_destroy(struct wlr_backend *wlr_backend) { struct wlr_multi_backend *backend = (struct wlr_multi_backend *)wlr_backend; - wl_list_remove(&backend->display_destroy.link); struct subbackend_state *sub, *next; wl_list_for_each_safe(sub, next, &backend->backends, link) { // XXX do we really want to take ownership over added backends? @@ -190,3 +189,9 @@ struct wlr_session *wlr_multi_get_session(struct wlr_backend *_backend) { } return NULL; } + +bool wlr_multi_is_empty(struct wlr_backend *_backend) { + assert(wlr_backend_is_multi(_backend)); + struct wlr_multi_backend *backend = (struct wlr_multi_backend *)_backend; + return wl_list_length(&backend->backends) < 1; +} diff --git a/include/backend/multi.h b/include/backend/multi.h index f0e50fc0..e283139c 100644 --- a/include/backend/multi.h +++ b/include/backend/multi.h @@ -10,8 +10,6 @@ struct wlr_multi_backend { struct wlr_backend backend; struct wl_list backends; - - struct wl_listener display_destroy; }; #endif diff --git a/include/wlr/backend/multi.h b/include/wlr/backend/multi.h index 35f7c165..d9914efc 100644 --- a/include/wlr/backend/multi.h +++ b/include/wlr/backend/multi.h @@ -16,4 +16,6 @@ bool wlr_backend_is_multi(struct wlr_backend *backend); struct wlr_session *wlr_multi_get_session(struct wlr_backend *base); +bool wlr_multi_is_empty(struct wlr_backend *backend); + #endif diff --git a/rootston/main.c b/rootston/main.c index aa20dbba..2f913272 100644 --- a/rootston/main.c +++ b/rootston/main.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -32,6 +33,12 @@ int main(int argc, char **argv) { assert(server.backend = wlr_backend_autocreate(server.wl_display)); + if (wlr_multi_is_empty(server.backend)) { + wlr_log(L_ERROR, "could not start backend"); + wlr_backend_destroy(server.backend); + return 1; + } + assert(server.renderer = wlr_gles2_renderer_create(server.backend)); server.data_device_manager = wlr_data_device_manager_create(server.wl_display); -- cgit v1.2.3