summaryrefslogtreecommitdiff
path: root/libweston/compositor.c
diff options
context:
space:
mode:
authorPhilipp Zabel <p.zabel@pengutronix.de>2021-02-16 12:25:38 +0100
committerDerek Foreman <derek.foreman@collabora.com>2023-09-28 14:02:04 +0000
commit76372375abc843b2b83a8507e567eb88ee955f1b (patch)
treec0f48d03e8e89165e5f0121e9db3a99251786dce /libweston/compositor.c
parent08018d3a286642fdc905e8036b55793272c9434c (diff)
libweston: store backends in a list
In preparation for multi-backend support, add a list of backends to the weston_compositor structure. Until backends are converted, this list just contains the single weston_compositor::backend. Keep that pointer for now, until the conversion is complete. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Diffstat (limited to 'libweston/compositor.c')
-rw-r--r--libweston/compositor.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/libweston/compositor.c b/libweston/compositor.c
index 773915ec..12ed1cab 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -8973,6 +8973,8 @@ weston_compositor_create(struct wl_display *display,
wl_list_init(&ec->debug_binding_list);
wl_list_init(&ec->tablet_manager_resource_list);
+ wl_list_init(&ec->backend_list);
+
wl_list_init(&ec->plugin_api_list);
wl_data_device_manager_init(ec->wl_display);
@@ -9399,6 +9401,25 @@ weston_compositor_add_destroy_listener_once(struct weston_compositor *compositor
return true;
}
+static void
+weston_compositor_shutdown_backends(struct weston_compositor *compositor)
+{
+ struct weston_backend *backend;
+
+ wl_list_for_each(backend, &compositor->backend_list, link)
+ if (backend->shutdown)
+ backend->shutdown(backend);
+}
+
+static void
+weston_compositor_destroy_backends(struct weston_compositor *compositor)
+{
+ struct weston_backend *backend, *tmp;
+
+ wl_list_for_each_safe(backend, tmp, &compositor->backend_list, link)
+ backend->destroy(backend);
+}
+
/** Destroys the compositor.
*
* This function cleans up the compositor state and then destroys it.
@@ -9417,13 +9438,11 @@ weston_compositor_destroy(struct weston_compositor *compositor)
weston_compositor_xkb_destroy(compositor);
- if (compositor->backend && compositor->backend->shutdown)
- compositor->backend->shutdown(compositor->backend);
+ weston_compositor_shutdown_backends(compositor);
weston_compositor_shutdown(compositor);
- if (compositor->backend)
- compositor->backend->destroy(compositor->backend);
+ weston_compositor_destroy_backends(compositor);
/* The backend is responsible for destroying the heads. */
assert(wl_list_empty(&compositor->head_list));
@@ -9530,6 +9549,8 @@ weston_compositor_load_backend(struct weston_compositor *compositor,
return -1;
}
+ wl_list_insert(&compositor->backend_list, &compositor->backend->link);
+
return 0;
}