[PATCH weston v3 10/36] libweston: add name to weston_head

Pekka Paalanen ppaalanen at gmail.com
Tue Oct 31 11:48:20 UTC 2017


From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>

Heads need to be named, so they can be referenced in logs and
configuration sources.

When clone mode is implemented, output and head names may differ.

Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
---
 libweston/compositor.c | 10 ++++++++--
 libweston/compositor.h |  2 ++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/libweston/compositor.c b/libweston/compositor.c
index de667cfa..2b8a0c95 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -4392,14 +4392,18 @@ weston_head_from_resource(struct wl_resource *resource)
 /** Initialize a pre-allocated weston_head
  *
  * \param head The head to initialize.
+ * \param name The head name, e.g. the connector name or equivalent.
  *
  * The head will be safe to attach, detach and release.
  *
+ * The name is used in logs, and can be used by compositors as a configuration
+ * identifier.
+ *
  * \memberof weston_head
  * \internal
  */
 static void
-weston_head_init(struct weston_head *head)
+weston_head_init(struct weston_head *head, const char *name)
 {
 	/* Add some (in)sane defaults which can be used
 	 * for checking if an output was properly configured
@@ -4408,6 +4412,7 @@ weston_head_init(struct weston_head *head)
 
 	wl_list_init(&head->output_link);
 	wl_list_init(&head->resource_list);
+	head->name = strdup(name);
 }
 
 /** Attach a head to an inactive output
@@ -4483,6 +4488,7 @@ weston_head_release(struct weston_head *head)
 	free(head->make);
 	free(head->model);
 	free(head->serial_number);
+	free(head->name);
 }
 
 /** Store monitor make, model and serial number
@@ -4945,7 +4951,7 @@ weston_output_init(struct weston_output *output,
 
 	wl_list_init(&output->head_list);
 
-	weston_head_init(&output->head);
+	weston_head_init(&output->head, name);
 
 	/* Add some (in)sane defaults which can be used
 	 * for checking if an output was properly configured
diff --git a/libweston/compositor.h b/libweston/compositor.h
index 47aacbc8..9ba13f6c 100644
--- a/libweston/compositor.h
+++ b/libweston/compositor.h
@@ -165,6 +165,8 @@ struct weston_head {
 	char *serial_number;		/**< monitor serial */
 	uint32_t subpixel;		/**< enum wl_output_subpixel */
 	bool connection_internal;	/**< embedded monitor (e.g. laptop) */
+
+	char *name;			/**< head name, e.g. connector name */
 };
 
 struct weston_output {
-- 
2.13.6



More information about the wayland-devel mailing list