static void
weston_compositor_build_view_list(struct weston_compositor *compositor);
+static char *
+weston_output_create_heads_string(struct weston_output *output);
+
/** Send wl_output events for mode and scale changes
*
* \param head Send on all resources bound to this head.
wl_output_send_done(resource);
}
+static void
+weston_head_add_global(struct weston_head *head)
+{
+ head->global = wl_global_create(head->compositor->wl_display,
+ &wl_output_interface, 3,
+ head, bind_output);
+}
+
/** Remove the global wl_output protocol object
*
* \param head The head whose global to remove.
return container_of(node, struct weston_head, output_link);
}
-/** Attach a head to an inactive output
+/** Attach a head to an output
*
* \param output The output to attach to.
* \param head The head that is not yet attached.
*
* On failure, the head remains unattached. Success of this function does not
* guarantee the output configuration is actually valid. The final checks are
- * made on weston_output_enable().
+ * made on weston_output_enable() unless the output was already enabled.
*
* \memberof weston_output
*/
weston_output_attach_head(struct weston_output *output,
struct weston_head *head)
{
- if (output->enabled)
- return -1;
+ char *head_names;
if (!wl_list_empty(&head->output_link))
return -1;
head->output = output;
wl_list_insert(output->head_list.prev, &head->output_link);
+ if (output->enabled) {
+ weston_head_add_global(head);
+
+ head_names = weston_output_create_heads_string(output);
+ weston_log("Output '%s' updated to have head(s) %s\n",
+ output->name, head_names);
+ free(head_names);
+ }
+
return 0;
}
wl_list_insert(compositor->output_list.prev, &output->link);
output->enabled = true;
- wl_list_for_each(head, &output->head_list, output_link) {
- head->global = wl_global_create(compositor->wl_display,
- &wl_output_interface, 3,
- head, bind_output);
- }
+ wl_list_for_each(head, &output->head_list, output_link)
+ weston_head_add_global(head);
wl_signal_emit(&compositor->output_created_signal, output);