aboutsummaryrefslogtreecommitdiff
path: root/backend/multi
diff options
context:
space:
mode:
authorTony Crisci <tony@dubstepdish.com>2017-12-19 18:49:00 -0500
committerTony Crisci <tony@dubstepdish.com>2017-12-19 18:49:00 -0500
commit58e69c9ce177f3de4790bddd161e9d74dd2e512c (patch)
tree792b7f6a51a056e3d28ca871bb17df33de0f8465 /backend/multi
parent6c75a184e7f05305fce8f693052a40047b07fc2f (diff)
multibackend remove subbackend
Diffstat (limited to 'backend/multi')
-rw-r--r--backend/multi/backend.c31
1 files changed, 30 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));