[PATCH weston v3 03/36] libweston: move wl_output to weston_head
Pekka Paalanen
ppaalanen at gmail.com
Tue Oct 31 11:48:13 UTC 2017
From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
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.
Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
---
libweston/compositor.c | 39 ++++++++++++++++++++++++---------------
libweston/compositor.h | 5 +++--
2 files changed, 27 insertions(+), 17 deletions(-)
diff --git a/libweston/compositor.c b/libweston/compositor.c
index 009b6608..00b2dd3f 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -81,6 +81,7 @@ static void weston_mode_switch_finish(struct weston_output *output,
int scale_changed)
{
struct weston_seat *seat;
+ struct weston_head *head;
struct wl_resource *resource;
pixman_region32_t old_output_region;
int version;
@@ -129,8 +130,10 @@ static void weston_mode_switch_finish(struct weston_output *output,
if (!mode_changed && !scale_changed)
return;
+ head = &output->head;
+
/* notify clients of the changes */
- wl_resource_for_each(resource, &output->resource_list) {
+ wl_resource_for_each(resource, &head->resource_list) {
if (mode_changed) {
wl_output_send_mode(resource,
output->current_mode->flags,
@@ -340,10 +343,12 @@ weston_presentation_feedback_present(
uint32_t flags)
{
struct wl_client *client = wl_resource_get_client(feedback->resource);
+ struct weston_head *head;
struct wl_resource *o;
uint64_t secs;
- 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)
continue;
@@ -921,7 +926,7 @@ weston_view_damage_below(struct weston_view *view)
/** Send wl_surface.enter/leave events
*
* \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 left True if left.
*
@@ -930,7 +935,7 @@ weston_view_damage_below(struct weston_view *view)
*/
static void
weston_surface_send_enter_leave(struct weston_surface *surface,
- struct weston_output *output,
+ struct weston_head *head,
bool enter,
bool leave)
{
@@ -940,7 +945,7 @@ weston_surface_send_enter_leave(struct weston_surface *surface,
assert(enter != leave);
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)
continue;
@@ -980,7 +985,7 @@ weston_surface_update_output_mask(struct weston_surface *es, uint32_t mask)
if (!(output_bit & different))
continue;
- weston_surface_send_enter_leave(es, output,
+ weston_surface_send_enter_leave(es, &output->head,
output_bit & entered,
output_bit & left);
}
@@ -4323,7 +4328,7 @@ bind_output(struct wl_client *client,
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_output_send_geometry(resource,
@@ -4577,7 +4582,7 @@ weston_output_move(struct weston_output *output, int x, int y)
wl_signal_emit(&output->compositor->output_moved_signal, output);
/* 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,
output->x,
output->y,
@@ -4611,6 +4616,7 @@ weston_compositor_add_output(struct weston_compositor *compositor,
struct weston_output *output)
{
struct weston_view *view, *next;
+ struct weston_head *head;
assert(!output->enabled);
@@ -4628,9 +4634,10 @@ weston_compositor_add_output(struct weston_compositor *compositor,
wl_list_insert(compositor->output_list.prev, &output->link);
output->enabled = true;
- output->global = wl_global_create(compositor->wl_display,
- &wl_output_interface, 3,
- output, bind_output);
+ head = &output->head;
+ head->global = wl_global_create(compositor->wl_display,
+ &wl_output_interface, 3,
+ output, bind_output);
wl_signal_emit(&compositor->output_created_signal, output);
@@ -4702,6 +4709,7 @@ weston_compositor_remove_output(struct weston_output *output)
struct weston_compositor *compositor = output->compositor;
struct wl_resource *resource;
struct weston_view *view;
+ struct weston_head *head;
assert(output->destroying);
assert(output->enabled);
@@ -4722,9 +4730,10 @@ weston_compositor_remove_output(struct weston_output *output)
wl_signal_emit(&compositor->output_destroyed_signal, output);
wl_signal_emit(&output->destroy_signal, output);
- wl_global_destroy(output->global);
- output->global = NULL;
- wl_resource_for_each(resource, &output->resource_list) {
+ head = &output->head;
+ wl_global_destroy(head->global);
+ head->global = NULL;
+ wl_resource_for_each(resource, &head->resource_list) {
wl_resource_set_destructor(resource, NULL);
}
@@ -4922,7 +4931,7 @@ weston_output_enable(struct weston_output *output)
wl_signal_init(&output->frame_signal);
wl_signal_init(&output->destroy_signal);
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);
/* Enable the output (set up the crtc or create a
diff --git a/libweston/compositor.h b/libweston/compositor.h
index a4d9d704..19971132 100644
--- a/libweston/compositor.h
+++ b/libweston/compositor.h
@@ -152,6 +152,9 @@ enum dpms_enum {
* (windowed nested backends).
*/
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_height; /**< physical image height in mm */
char *make; /**< monitor manufacturer (PNP ID) */
@@ -168,8 +171,6 @@ struct weston_output {
void *renderer_state;
struct wl_list link;
- struct wl_list resource_list;
- struct wl_global *global;
struct weston_compositor *compositor;
/** From global to output buffer coordinates. */
--
2.13.6
More information about the wayland-devel
mailing list