From c6e47d177a8408b53b4f335eadfff35d8cdec509 Mon Sep 17 00:00:00 2001
From: Philipp Zabel
Date: Mon, 29 Mar 2021 13:51:31 +0200
Subject: [PATCH] libweston: consolidate
weston_compositor_create_output(_with_head)
Add a struct weston_head parameter to weston_compositor_create_output()
and fold weston_compositor_create_output_with_head() into it.
See: https://gitlab.freedesktop.org/wayland/weston/-/issues/268
Signed-off-by: Philipp Zabel
---
compositor/main.c | 6 ++--
.../toc/libweston/images/create_output.msc | 2 +-
include/libweston/libweston.h | 6 +---
libweston/compositor.c | 36 +++++--------------
4 files changed, 14 insertions(+), 36 deletions(-)
diff --git a/compositor/main.c b/compositor/main.c
index b9c740f3..747f0b75 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -1696,8 +1696,8 @@ simple_head_enable(struct wet_compositor *wet, struct weston_head *head)
struct weston_output *output;
int ret = 0;
- output = weston_compositor_create_output_with_head(wet->compositor,
- head);
+ output = weston_compositor_create_output(wet->compositor, head,
+ head->name);
if (!output) {
weston_log("Could not create an output for head \"%s\".\n",
weston_head_get_name(head));
@@ -2162,7 +2162,7 @@ wet_layoutput_create_output(struct wet_layoutput *lo, const char *name)
output->output =
weston_compositor_create_output(lo->compositor->compositor,
- name);
+ NULL, name);
if (!output->output) {
free(output);
return NULL;
diff --git a/doc/sphinx/toc/libweston/images/create_output.msc b/doc/sphinx/toc/libweston/images/create_output.msc
index f20cdb4e..b66b7548 100644
--- a/doc/sphinx/toc/libweston/images/create_output.msc
+++ b/doc/sphinx/toc/libweston/images/create_output.msc
@@ -11,7 +11,7 @@ msc {
--- [label = "Compositor creates an output for a head"];
c box c [label = "Have an existing head to process."];
- c => w [label = "weston_compositor_create_output_with_head()"];
+ c => w [label = "weston_compositor_create_output()"];
w => b [label = "weston_backend::create_output()"];
w << b [label = "an empty output, no hw resources"];
w => b [label = "weston_output::attach_head()"];
diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h
index c5f6f8cd..eb929a1f 100644
--- a/include/libweston/libweston.h
+++ b/include/libweston/libweston.h
@@ -2228,11 +2228,7 @@ weston_compositor_find_output_by_name(struct weston_compositor *compositor,
struct weston_output *
weston_compositor_create_output(struct weston_compositor *compositor,
- const char *name);
-
-struct weston_output *
-weston_compositor_create_output_with_head(struct weston_compositor *compositor,
- struct weston_head *head);
+ struct weston_head *head, const char *name);
void
weston_output_destroy(struct weston_output *output);
diff --git a/libweston/compositor.c b/libweston/compositor.c
index 128ee232..0dedb81f 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -7306,13 +7306,15 @@ weston_compositor_find_output_by_name(struct weston_compositor *compositor,
return NULL;
}
-/** Create a named output
+/** Create a named output for an unused head
*
* \param compositor The compositor.
+ * \param head The head to attach to the output.
* \param name The name for the output.
* \return A new \c weston_output, or NULL on failure.
*
- * This creates a new weston_output that starts with no heads attached.
+ * This creates a new weston_output that starts with the given head attached.
+ * The head must not be already attached to another output.
*
* An output must be configured and it must have at least one head before
* it can be enabled.
@@ -7321,8 +7323,11 @@ weston_compositor_find_output_by_name(struct weston_compositor *compositor,
*/
WL_EXPORT struct weston_output *
weston_compositor_create_output(struct weston_compositor *compositor,
+ struct weston_head *head,
const char *name)
{
+ struct weston_output *output;
+
assert(compositor->backend->create_output);
if (weston_compositor_find_output_by_name(compositor, name)) {
@@ -7331,34 +7336,11 @@ weston_compositor_create_output(struct weston_compositor *compositor,
return NULL;
}
- return compositor->backend->create_output(compositor, name);
-}
-
-/** Create an output for an unused head
- *
- * \param compositor The compositor.
- * \param head The head to attach to the output.
- * \return A new \c weston_output, or NULL on failure.
- *
- * This creates a new weston_output that starts with the given head attached.
- * The output inherits the name of the head. The head must not be already
- * attached to another output.
- *
- * An output must be configured before it can be enabled.
- *
- * \ingroup compositor
- */
-WL_EXPORT struct weston_output *
-weston_compositor_create_output_with_head(struct weston_compositor *compositor,
- struct weston_head *head)
-{
- struct weston_output *output;
-
- output = weston_compositor_create_output(compositor, head->name);
+ output = compositor->backend->create_output(compositor, name);
if (!output)
return NULL;
- if (weston_output_attach_head(output, head) < 0) {
+ if (head && weston_output_attach_head(output, head) < 0) {
weston_output_destroy(output);
return NULL;
}