diff options
author | Tony Crisci <tony@dubstepdish.com> | 2017-12-19 18:49:00 -0500 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2017-12-19 18:49:00 -0500 |
commit | 58e69c9ce177f3de4790bddd161e9d74dd2e512c (patch) | |
tree | 792b7f6a51a056e3d28ca871bb17df33de0f8465 | |
parent | 6c75a184e7f05305fce8f693052a40047b07fc2f (diff) |
multibackend remove subbackend
-rw-r--r-- | backend/multi/backend.c | 31 | ||||
-rw-r--r-- | include/wlr/backend/multi.h | 3 |
2 files changed, 33 insertions, 1 deletions
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); |