mirror of
https://gitlab.freedesktop.org/wayland/weston
synced 2024-10-03 02:09:55 +00:00
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>
This commit is contained in:
parent
5dd796e447
commit
7d2112c713
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue