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/backend/drm/drm.h | 2 ++ include/backend/multi.h | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'include/backend') diff --git a/include/backend/drm/drm.h b/include/backend/drm/drm.h index 278c387c..72671f45 100644 --- a/include/backend/drm/drm.h +++ b/include/backend/drm/drm.h @@ -143,4 +143,6 @@ int wlr_drm_event(int fd, uint32_t mask, void *data); void wlr_drm_connector_start_renderer(struct wlr_drm_connector *conn); +struct wlr_session *wlr_drm_backend_get_session(struct wlr_backend *backend); + #endif diff --git a/include/backend/multi.h b/include/backend/multi.h index 2798048d..f0e50fc0 100644 --- a/include/backend/multi.h +++ b/include/backend/multi.h @@ -9,7 +9,6 @@ struct wlr_multi_backend { struct wlr_backend backend; - struct wlr_session *session; struct wl_list backends; struct wl_listener display_destroy; -- 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/backend') 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 From 6c8fd6017e92441e8b1702958f34fd9d88e32928 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Wed, 20 Dec 2017 05:54:41 -0500 Subject: backend add and remove events --- backend/multi/backend.c | 6 ++++++ include/backend/multi.h | 5 +++++ 2 files changed, 11 insertions(+) (limited to 'include/backend') diff --git a/backend/multi/backend.c b/backend/multi/backend.c index c000342b..0dd3c54b 100644 --- a/backend/multi/backend.c +++ b/backend/multi/backend.c @@ -79,6 +79,9 @@ struct wlr_backend *wlr_multi_backend_create(struct wl_display *display) { wl_list_init(&backend->backends); wlr_backend_init(&backend->backend, &backend_impl); + wl_signal_init(&backend->events.backend_add); + wl_signal_init(&backend->events.backend_remove); + return &backend->backend; } @@ -162,6 +165,8 @@ void wlr_multi_backend_add(struct wlr_backend *_multi, wl_signal_add(&backend->events.output_remove, &sub->output_remove); sub->output_remove.notify = output_remove_reemit; + + wl_signal_emit(&multi->events.backend_add, backend); } void wlr_multi_backend_remove(struct wlr_backend *_multi, @@ -173,6 +178,7 @@ void wlr_multi_backend_remove(struct wlr_backend *_multi, multi_backend_get_subbackend(multi, backend); if (sub) { + wl_signal_emit(&multi->events.backend_remove, backend); subbackend_state_destroy(sub); } } diff --git a/include/backend/multi.h b/include/backend/multi.h index e283139c..947464e1 100644 --- a/include/backend/multi.h +++ b/include/backend/multi.h @@ -10,6 +10,11 @@ struct wlr_multi_backend { struct wlr_backend backend; struct wl_list backends; + + struct { + struct wl_signal backend_add; + struct wl_signal backend_remove; + } events; }; #endif -- cgit v1.2.3 From d1dce19253d0b4d30d99d2074a05fe7970391a61 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Thu, 21 Dec 2017 08:13:36 -0500 Subject: handle display destroy --- backend/multi/backend.c | 10 +++++++++- include/backend/multi.h | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'include/backend') diff --git a/backend/multi/backend.c b/backend/multi/backend.c index 0dd3c54b..07e84c01 100644 --- a/backend/multi/backend.c +++ b/backend/multi/backend.c @@ -44,7 +44,6 @@ static void multi_backend_destroy(struct wlr_backend *wlr_backend) { struct wlr_multi_backend *backend = (struct wlr_multi_backend *)wlr_backend; 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? wlr_backend_destroy(sub->backend); } free(backend); @@ -68,6 +67,12 @@ struct wlr_backend_impl backend_impl = { .get_egl = multi_backend_get_egl, }; +static void handle_display_destroy(struct wl_listener *listener, void *data) { + struct wlr_multi_backend *backend = + wl_container_of(listener, backend, display_destroy); + multi_backend_destroy((struct wlr_backend*)backend); +} + struct wlr_backend *wlr_multi_backend_create(struct wl_display *display) { struct wlr_multi_backend *backend = calloc(1, sizeof(struct wlr_multi_backend)); @@ -82,6 +87,9 @@ struct wlr_backend *wlr_multi_backend_create(struct wl_display *display) { wl_signal_init(&backend->events.backend_add); wl_signal_init(&backend->events.backend_remove); + backend->display_destroy.notify = handle_display_destroy; + wl_display_add_destroy_listener(display, &backend->display_destroy); + return &backend->backend; } diff --git a/include/backend/multi.h b/include/backend/multi.h index 947464e1..3363c608 100644 --- a/include/backend/multi.h +++ b/include/backend/multi.h @@ -11,6 +11,8 @@ struct wlr_multi_backend { struct wl_list backends; + struct wl_listener display_destroy; + struct { struct wl_signal backend_add; struct wl_signal backend_remove; -- cgit v1.2.3