libweston: add explicit weston_compositor::primary_backend pointer

This avoids spreading around the knowledge that the primary backend is
the first backend on weston_compositor::backend:list.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
This commit is contained in:
Philipp Zabel 2023-06-21 14:46:27 +02:00 committed by Derek Foreman
parent a4f0666659
commit c93a54ece3
2 changed files with 7 additions and 1 deletions

View file

@ -1439,6 +1439,8 @@ struct weston_compositor {
struct weston_renderer *renderer;
const struct pixel_format_info *read_format;
/* Pointer to the first backend on backend_list */
struct weston_backend *primary_backend;
struct wl_list backend_list;
struct weston_launcher *launcher;

View file

@ -9150,6 +9150,10 @@ weston_compositor_backends_loaded(struct weston_compositor *compositor)
struct weston_backend *backend;
uint32_t supported_clocks = 0xffffffff;
compositor->primary_backend =
wl_container_of(compositor->backend_list.prev,
compositor->primary_backend, link);
wl_list_for_each(backend, &compositor->backend_list, link)
supported_clocks &= backend->supported_presentation_clocks;
@ -9562,9 +9566,9 @@ weston_compositor_load_backend(struct weston_compositor *compositor,
if (backend_init(compositor, config_base) < 0)
return NULL;
/* Return the last loaded backend. */
b = wl_container_of(compositor->backend_list.next, b, link);
/* Return the last loaded backend. */
return b;
}