aboutsummaryrefslogtreecommitdiff
path: root/backend/multi/backend.c
diff options
context:
space:
mode:
Diffstat (limited to 'backend/multi/backend.c')
-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));