summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Zabel <philipp.zabel@gmail.com>2023-04-16 18:20:10 +0200
committerPhilipp Zabel <philipp.zabel@gmail.com>2023-04-17 09:38:50 +0200
commit7d2112c713ffd504fa1e2e0c7053e52f4cdbf2a1 (patch)
tree290eaff09bade405c2bea2bdae5e7b99bcbc8456
parent5dd796e447f4613475f18e7e4e2f8099fd0ceca8 (diff)
downloadweston-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>
-rw-r--r--compositor/main.c10
-rw-r--r--include/libweston/windowed-output-api.h6
-rw-r--r--libweston/backend-headless/headless.c10
-rw-r--r--libweston/backend-wayland/wayland.c24
-rw-r--r--libweston/backend-x11/x11.c10
5 files changed, 31 insertions, 29 deletions
diff --git a/compositor/main.c b/compositor/main.c
index d175e8de..bb95beaf 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -3064,7 +3064,7 @@ load_headless_backend(struct weston_compositor *c,
return -1;
}
- if (api->create_head(c, "headless") < 0)
+ if (api->create_head(c->backend, "headless") < 0)
return -1;
}
@@ -3418,7 +3418,7 @@ load_x11_backend(struct weston_compositor *c,
continue;
}
- if (api->create_head(c, output_name) < 0) {
+ if (api->create_head(c->backend, output_name) < 0) {
free(output_name);
return -1;
}
@@ -3434,7 +3434,7 @@ load_x11_backend(struct weston_compositor *c,
return -1;
}
- if (api->create_head(c, default_output) < 0) {
+ if (api->create_head(c->backend, default_output) < 0) {
free(default_output);
return -1;
}
@@ -3559,7 +3559,7 @@ load_wayland_backend(struct weston_compositor *c,
continue;
}
- if (api->create_head(c, output_name) < 0) {
+ if (api->create_head(c->backend, output_name) < 0) {
free(output_name);
return -1;
}
@@ -3572,7 +3572,7 @@ load_wayland_backend(struct weston_compositor *c,
if (asprintf(&output_name, "wayland%d", i) < 0)
return -1;
- if (api->create_head(c, output_name) < 0) {
+ if (api->create_head(c->backend, output_name) < 0) {
free(output_name);
return -1;
}
diff --git a/include/libweston/windowed-output-api.h b/include/libweston/windowed-output-api.h
index 42214d1b..0f1bc0d7 100644
--- a/include/libweston/windowed-output-api.h
+++ b/include/libweston/windowed-output-api.h
@@ -35,7 +35,7 @@ extern "C" {
struct weston_compositor;
struct weston_output;
-#define WESTON_WINDOWED_OUTPUT_API_NAME "weston_windowed_output_api_v1"
+#define WESTON_WINDOWED_OUTPUT_API_NAME "weston_windowed_output_api_v2"
struct weston_windowed_output_api {
/** Assign a given width and height to an output.
@@ -58,7 +58,7 @@ struct weston_windowed_output_api {
/** Create a new windowed head.
*
- * \param compositor The compositor instance.
+ * \param backend The backend.
* \param name Desired name for a new head, not NULL.
*
* Returns 0 on success, -1 on failure.
@@ -74,7 +74,7 @@ struct weston_windowed_output_api {
* \sa weston_compositor_set_heads_changed_cb(),
* weston_compositor_create_output_with_head()
*/
- int (*create_head)(struct weston_compositor *compositor,
+ int (*create_head)(struct weston_backend *backend,
const char *name);
};
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;
}