libweston: use head in wl_output global

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@collabora.co.uk>
v5 Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
This commit is contained in:
Pekka Paalanen 2017-03-27 12:24:34 +03:00
parent 1b9bf598a5
commit 0534762b21
2 changed files with 9 additions and 4 deletions

View File

@ -4317,10 +4317,10 @@ static void
bind_output(struct wl_client *client, bind_output(struct wl_client *client,
void *data, uint32_t version, uint32_t id) 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 weston_mode *mode;
struct wl_resource *resource; struct wl_resource *resource;
struct weston_head *head = &output->head;
resource = wl_resource_create(client, &wl_output_interface, resource = wl_resource_create(client, &wl_output_interface,
version, id); version, id);
@ -4330,8 +4330,10 @@ bind_output(struct wl_client *client,
} }
wl_list_insert(&head->resource_list, wl_resource_get_link(resource)); 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, wl_output_send_geometry(resource,
output->x, output->x,
output->y, output->y,
@ -4636,9 +4638,10 @@ weston_compositor_add_output(struct weston_compositor *compositor,
output->enabled = true; output->enabled = true;
head = &output->head; head = &output->head;
head->output = output;
head->global = wl_global_create(compositor->wl_display, head->global = wl_global_create(compositor->wl_display,
&wl_output_interface, 3, &wl_output_interface, 3,
output, bind_output); head, bind_output);
wl_signal_emit(&compositor->output_created_signal, output); wl_signal_emit(&compositor->output_created_signal, output);

View File

@ -153,6 +153,8 @@ enum dpms_enum {
* (windowed nested backends). * (windowed nested backends).
*/ */
struct weston_head { struct weston_head {
struct weston_output *output; /**< the output driving this head */
struct wl_list resource_list; /**< wl_output protocol objects */ struct wl_list resource_list; /**< wl_output protocol objects */
struct wl_global *global; /**< wl_output global */ struct wl_global *global; /**< wl_output global */