libweston: move wl_output to weston_head

The wl_output protocol interface exposes things like monitor make,
model, sub-pixel layout and physical dimensions. Obviously wl_output is
meant to represent a monitor.

The abstraction of a monitor is weston_head. Therefore move the wl_output
global and the bound resources list into weston_head.

When clone mode gets implemented in the future, this means that monitors
driven by the same CRTC will still be represented as separate wl_output
globals. This allows to accurately represent the hardware.

Clone mode that used separate, not frame-locked, CRTCs to drive two
monitors as clones would necessarily also be exposed as separate
wl_output since they have different timings.

v6:
- adapt to upstream changes in weston_output_set_transform()

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>
dev
Pekka Paalanen 8 years ago
parent 01f60211b2
commit 1b9bf598a5
  1. 37
      libweston/compositor.c
  2. 5
      libweston/compositor.h

@ -81,6 +81,7 @@ static void weston_mode_switch_finish(struct weston_output *output,
int scale_changed) int scale_changed)
{ {
struct weston_seat *seat; struct weston_seat *seat;
struct weston_head *head;
struct wl_resource *resource; struct wl_resource *resource;
pixman_region32_t old_output_region; pixman_region32_t old_output_region;
int version; int version;
@ -129,8 +130,10 @@ static void weston_mode_switch_finish(struct weston_output *output,
if (!mode_changed && !scale_changed) if (!mode_changed && !scale_changed)
return; return;
head = &output->head;
/* notify clients of the changes */ /* notify clients of the changes */
wl_resource_for_each(resource, &output->resource_list) { wl_resource_for_each(resource, &head->resource_list) {
if (mode_changed) { if (mode_changed) {
wl_output_send_mode(resource, wl_output_send_mode(resource,
output->current_mode->flags, output->current_mode->flags,
@ -340,12 +343,14 @@ weston_presentation_feedback_present(
uint32_t flags) uint32_t flags)
{ {
struct wl_client *client = wl_resource_get_client(feedback->resource); struct wl_client *client = wl_resource_get_client(feedback->resource);
struct weston_head *head;
struct wl_resource *o; struct wl_resource *o;
uint32_t tv_sec_hi; uint32_t tv_sec_hi;
uint32_t tv_sec_lo; uint32_t tv_sec_lo;
uint32_t tv_nsec; uint32_t tv_nsec;
wl_resource_for_each(o, &output->resource_list) { head = &output->head;
wl_resource_for_each(o, &head->resource_list) {
if (wl_resource_get_client(o) != client) if (wl_resource_get_client(o) != client)
continue; continue;
@ -922,7 +927,7 @@ weston_view_damage_below(struct weston_view *view)
/** Send wl_surface.enter/leave events /** Send wl_surface.enter/leave events
* *
* \param surface The surface. * \param surface The surface.
* \param output The entered/left output. * \param head A head of the entered/left output.
* \param enter True if entered. * \param enter True if entered.
* \param left True if left. * \param left True if left.
* *
@ -931,7 +936,7 @@ weston_view_damage_below(struct weston_view *view)
*/ */
static void static void
weston_surface_send_enter_leave(struct weston_surface *surface, weston_surface_send_enter_leave(struct weston_surface *surface,
struct weston_output *output, struct weston_head *head,
bool enter, bool enter,
bool leave) bool leave)
{ {
@ -941,7 +946,7 @@ weston_surface_send_enter_leave(struct weston_surface *surface,
assert(enter != leave); assert(enter != leave);
client = wl_resource_get_client(surface->resource); client = wl_resource_get_client(surface->resource);
wl_resource_for_each(wloutput, &output->resource_list) { wl_resource_for_each(wloutput, &head->resource_list) {
if (wl_resource_get_client(wloutput) != client) if (wl_resource_get_client(wloutput) != client)
continue; continue;
@ -981,7 +986,7 @@ weston_surface_update_output_mask(struct weston_surface *es, uint32_t mask)
if (!(output_bit & different)) if (!(output_bit & different))
continue; continue;
weston_surface_send_enter_leave(es, output, weston_surface_send_enter_leave(es, &output->head,
output_bit & entered, output_bit & entered,
output_bit & left); output_bit & left);
} }
@ -4324,7 +4329,7 @@ bind_output(struct wl_client *client,
return; return;
} }
wl_list_insert(&output->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, data, unbind_resource);
wl_output_send_geometry(resource, wl_output_send_geometry(resource,
@ -4578,7 +4583,7 @@ weston_output_move(struct weston_output *output, int x, int y)
wl_signal_emit(&output->compositor->output_moved_signal, output); wl_signal_emit(&output->compositor->output_moved_signal, output);
/* Notify clients of the change for output position. */ /* Notify clients of the change for output position. */
wl_resource_for_each(resource, &output->resource_list) { wl_resource_for_each(resource, &head->resource_list) {
wl_output_send_geometry(resource, wl_output_send_geometry(resource,
output->x, output->x,
output->y, output->y,
@ -4612,6 +4617,7 @@ weston_compositor_add_output(struct weston_compositor *compositor,
struct weston_output *output) struct weston_output *output)
{ {
struct weston_view *view, *next; struct weston_view *view, *next;
struct weston_head *head;
assert(!output->enabled); assert(!output->enabled);
@ -4629,7 +4635,8 @@ weston_compositor_add_output(struct weston_compositor *compositor,
wl_list_insert(compositor->output_list.prev, &output->link); wl_list_insert(compositor->output_list.prev, &output->link);
output->enabled = true; output->enabled = true;
output->global = wl_global_create(compositor->wl_display, head = &output->head;
head->global = wl_global_create(compositor->wl_display,
&wl_output_interface, 3, &wl_output_interface, 3,
output, bind_output); output, bind_output);
@ -4703,6 +4710,7 @@ weston_compositor_remove_output(struct weston_output *output)
struct weston_compositor *compositor = output->compositor; struct weston_compositor *compositor = output->compositor;
struct wl_resource *resource; struct wl_resource *resource;
struct weston_view *view; struct weston_view *view;
struct weston_head *head;
assert(output->destroying); assert(output->destroying);
assert(output->enabled); assert(output->enabled);
@ -4723,9 +4731,10 @@ weston_compositor_remove_output(struct weston_output *output)
wl_signal_emit(&compositor->output_destroyed_signal, output); wl_signal_emit(&compositor->output_destroyed_signal, output);
wl_signal_emit(&output->destroy_signal, output); wl_signal_emit(&output->destroy_signal, output);
wl_global_destroy(output->global); head = &output->head;
output->global = NULL; wl_global_destroy(head->global);
wl_resource_for_each(resource, &output->resource_list) { head->global = NULL;
wl_resource_for_each(resource, &head->resource_list) {
wl_resource_set_destructor(resource, NULL); wl_resource_set_destructor(resource, NULL);
} }
@ -4793,7 +4802,7 @@ weston_output_set_transform(struct weston_output *output,
output->dirty = 1; output->dirty = 1;
/* Notify clients of the change for output transform. */ /* Notify clients of the change for output transform. */
wl_resource_for_each(resource, &output->resource_list) { wl_resource_for_each(resource, &head->resource_list) {
wl_output_send_geometry(resource, wl_output_send_geometry(resource,
output->x, output->x,
output->y, output->y,
@ -4967,7 +4976,7 @@ weston_output_enable(struct weston_output *output)
wl_signal_init(&output->frame_signal); wl_signal_init(&output->frame_signal);
wl_signal_init(&output->destroy_signal); wl_signal_init(&output->destroy_signal);
wl_list_init(&output->animation_list); wl_list_init(&output->animation_list);
wl_list_init(&output->resource_list); wl_list_init(&output->head.resource_list);
wl_list_init(&output->feedback_list); wl_list_init(&output->feedback_list);
/* Enable the output (set up the crtc or create a /* Enable the output (set up the crtc or create a

@ -153,6 +153,9 @@ enum dpms_enum {
* (windowed nested backends). * (windowed nested backends).
*/ */
struct weston_head { struct weston_head {
struct wl_list resource_list; /**< wl_output protocol objects */
struct wl_global *global; /**< wl_output global */
int32_t mm_width; /**< physical image width in mm */ int32_t mm_width; /**< physical image width in mm */
int32_t mm_height; /**< physical image height in mm */ int32_t mm_height; /**< physical image height in mm */
char *make; /**< monitor manufacturer (PNP ID) */ char *make; /**< monitor manufacturer (PNP ID) */
@ -169,8 +172,6 @@ struct weston_output {
void *renderer_state; void *renderer_state;
struct wl_list link; struct wl_list link;
struct wl_list resource_list;
struct wl_global *global;
struct weston_compositor *compositor; struct weston_compositor *compositor;
/** From global to output buffer coordinates. */ /** From global to output buffer coordinates. */

Loading…
Cancel
Save