diff options
author | Philipp Zabel <philipp.zabel@gmail.com> | 2023-04-16 18:20:10 +0200 |
---|---|---|
committer | Philipp Zabel <philipp.zabel@gmail.com> | 2023-04-17 09:38:50 +0200 |
commit | 7d2112c713ffd504fa1e2e0c7053e52f4cdbf2a1 (patch) | |
tree | 290eaff09bade405c2bea2bdae5e7b99bcbc8456 /libweston | |
parent | 5dd796e447f4613475f18e7e4e2f8099fd0ceca8 (diff) | |
download | weston-7d2112c713ffd504fa1e2e0c7053e52f4cdbf2a1.tar.gz |
libweston: pass backend to weston_windowed_output_api::create_head()
Pass the backend instead of the compositor to the windowed output API
create_head() method and increment the API version.
That way the backend will not have to find the backend pointer from the
compositor. This is trivial now, but in the multi-backend case would
entail iterating over all backends to find the correct one.
Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
Diffstat (limited to 'libweston')
-rw-r--r-- | libweston/backend-headless/headless.c | 10 | ||||
-rw-r--r-- | libweston/backend-wayland/wayland.c | 24 | ||||
-rw-r--r-- | libweston/backend-x11/x11.c | 10 |
3 files changed, 23 insertions, 21 deletions
diff --git a/libweston/backend-headless/headless.c b/libweston/backend-headless/headless.c index a7d692d8..b1d49f09 100644 --- a/libweston/backend-headless/headless.c +++ b/libweston/backend-headless/headless.c @@ -111,9 +111,9 @@ to_headless_output(struct weston_output *base) } static inline struct headless_backend * -to_headless_backend(struct weston_compositor *base) +to_headless_backend(struct weston_backend *base) { - return container_of(base->backend, struct headless_backend, base); + return container_of(base, struct headless_backend, base); } static int @@ -446,10 +446,10 @@ headless_output_create(struct weston_backend *backend, const char *name) } static int -headless_head_create(struct weston_compositor *compositor, +headless_head_create(struct weston_backend *base, const char *name) { - struct headless_backend *backend = to_headless_backend(compositor); + struct headless_backend *backend = to_headless_backend(base); struct headless_head *head; /* name can't be NULL. */ @@ -472,7 +472,7 @@ headless_head_create(struct weston_compositor *compositor, * We do not have those until set_size() time through. */ - weston_compositor_add_head(compositor, &head->base); + weston_compositor_add_head(backend->compositor, &head->base); return 0; } diff --git a/libweston/backend-wayland/wayland.c b/libweston/backend-wayland/wayland.c index afa40e87..1808a98b 100644 --- a/libweston/backend-wayland/wayland.c +++ b/libweston/backend-wayland/wayland.c @@ -260,9 +260,9 @@ to_wayland_output(struct weston_output *base) } static inline struct wayland_backend * -to_wayland_backend(struct weston_compositor *base) +to_wayland_backend(struct weston_backend *base) { - return container_of(base->backend, struct wayland_backend, base); + return container_of(base, struct wayland_backend, base); } static void @@ -1423,9 +1423,9 @@ wayland_output_create(struct weston_backend *backend, const char *name) } static struct wayland_head * -wayland_head_create(struct weston_compositor *compositor, const char *name) +wayland_head_create(struct wayland_backend *backend, const char *name) { - struct wayland_backend *backend = to_wayland_backend(compositor); + struct weston_compositor *compositor = backend->compositor; struct wayland_head *head; assert(name); @@ -1445,17 +1445,19 @@ wayland_head_create(struct weston_compositor *compositor, const char *name) } static int -wayland_head_create_windowed(struct weston_compositor *compositor, +wayland_head_create_windowed(struct weston_backend *base, const char *name) { - if (!wayland_head_create(compositor, name)) + struct wayland_backend *backend = to_wayland_backend(base); + + if (!wayland_head_create(backend, name)) return -1; return 0; } static int -wayland_head_create_for_parent_output(struct weston_compositor *compositor, +wayland_head_create_for_parent_output(struct wayland_backend *backend, struct wayland_parent_output *poutput) { struct wayland_head *head; @@ -1466,7 +1468,7 @@ wayland_head_create_for_parent_output(struct weston_compositor *compositor, if (ret < 1 || (unsigned)ret >= sizeof(name)) return -1; - head = wayland_head_create(compositor, name); + head = wayland_head_create(backend, name); if (!head) return -1; @@ -2590,7 +2592,7 @@ output_sync_callback(void *data, struct wl_callback *callback, uint32_t unused) assert(output->backend->sprawl_across_outputs); - wayland_head_create_for_parent_output(output->backend->compositor, output); + wayland_head_create_for_parent_output(output->backend, output); } static const struct wl_callback_listener output_sync_listener = { @@ -3016,13 +3018,13 @@ weston_backend_init(struct weston_compositor *compositor, wl_display_roundtrip(b->parent.wl_display); wl_list_for_each(poutput, &b->parent.output_list, link) - wayland_head_create_for_parent_output(compositor, poutput); + wayland_head_create_for_parent_output(b, poutput); return 0; } if (new_config.fullscreen) { - if (!wayland_head_create(compositor, "wayland-fullscreen")) { + if (!wayland_head_create(b, "wayland-fullscreen")) { weston_log("Unable to create a fullscreen head.\n"); goto err_outputs; } diff --git a/libweston/backend-x11/x11.c b/libweston/backend-x11/x11.c index 006b2948..f115acda 100644 --- a/libweston/backend-x11/x11.c +++ b/libweston/backend-x11/x11.c @@ -177,9 +177,9 @@ to_x11_output(struct weston_output *base) } static inline struct x11_backend * -to_x11_backend(struct weston_compositor *base) +to_x11_backend(struct weston_backend *backend) { - return container_of(base->backend, struct x11_backend, base); + return container_of(backend, struct x11_backend, base); } static xcb_screen_t * @@ -1199,9 +1199,9 @@ x11_output_create(struct weston_backend *backend, const char *name) } static int -x11_head_create(struct weston_compositor *compositor, const char *name) +x11_head_create(struct weston_backend *base, const char *name) { - struct x11_backend *backend = to_x11_backend(compositor); + struct x11_backend *backend = to_x11_backend(base); struct x11_head *head; assert(name); @@ -1215,7 +1215,7 @@ x11_head_create(struct weston_compositor *compositor, const char *name) head->base.backend = &backend->base; weston_head_set_connection_status(&head->base, true); - weston_compositor_add_head(compositor, &head->base); + weston_compositor_add_head(backend->compositor, &head->base); return 0; } |