[PATCH weston v6 03/73] libweston: use head in wl_output global

Pekka Paalanen ppaalanen at gmail.com
Fri Feb 16 14:56:48 UTC 2018


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

As a wl_output represents weston_head, use a weston_head pointer as the
wl_output global's user data.

Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
v5 Reviewed-by: Derek Foreman <derekf at osg.samsung.com>
---
 libweston/compositor.c | 11 +++++++----
 libweston/compositor.h |  2 ++
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/libweston/compositor.c b/libweston/compositor.c
index 99a56269..aa636341 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -4316,10 +4316,10 @@ static void
 bind_output(struct wl_client *client,
 	    void *data, uint32_t version, uint32_t id)
 {
-	struct weston_output *output = data;
+	struct weston_head *head = data;
+	struct weston_output *output = head->output;
 	struct weston_mode *mode;
 	struct wl_resource *resource;
-	struct weston_head *head = &output->head;
 
 	resource = wl_resource_create(client, &wl_output_interface,
 				      version, id);
@@ -4329,8 +4329,10 @@ bind_output(struct wl_client *client,
 	}
 
 	wl_list_insert(&head->resource_list, wl_resource_get_link(resource));
-	wl_resource_set_implementation(resource, &output_interface, data, unbind_resource);
+	wl_resource_set_implementation(resource, &output_interface, output,
+				       unbind_resource);
 
+	assert(output);
 	wl_output_send_geometry(resource,
 				output->x,
 				output->y,
@@ -4635,9 +4637,10 @@ weston_compositor_add_output(struct weston_compositor *compositor,
 	output->enabled = true;
 
 	head = &output->head;
+	head->output = output;
 	head->global = wl_global_create(compositor->wl_display,
 					&wl_output_interface, 3,
-					output, bind_output);
+					head, bind_output);
 
 	wl_signal_emit(&compositor->output_created_signal, output);
 
diff --git a/libweston/compositor.h b/libweston/compositor.h
index c2de761b..4e8797c7 100644
--- a/libweston/compositor.h
+++ b/libweston/compositor.h
@@ -153,6 +153,8 @@ enum dpms_enum {
  * (windowed nested backends).
  */
 struct weston_head {
+	struct weston_output *output;	/**< the output driving this head */
+
 	struct wl_list resource_list;	/**< wl_output protocol objects */
 	struct wl_global *global;	/**< wl_output global */
 
-- 
2.13.6



More information about the wayland-devel mailing list