libweston: specify weston_output::enabled
It was ambiguous what this flag meant - it did not mean whether the
backend is considering this output to be enabled, because
weston_output_destroy() unsets it while deliberately not calling the
backend disable() vfunc.
Perhaps the most clear definition is with respect to the output's
assignment in the pending vs. enabled output lists. There is also a whole
bunch of variables that are allocated only when enabled is true.
Since the flag is related to the list membership, set and clear the flag
only when manipulating the lists.
Assert that weston_compositor_add_output() and
weston_compositor_remove_output() are not called in a wrong state.
v2:
- talk about "list of enabled outputs"
- clear 'enabled' in weston_compositor_remove_output() earlier
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
diff --git a/libweston/compositor.c b/libweston/compositor.c
index 97ade22..6d3dc1c 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -4483,8 +4483,10 @@
{
struct weston_view *view, *next;
+ assert(!output->enabled);
wl_list_remove(&output->link);
wl_list_insert(compositor->output_list.prev, &output->link);
+ output->enabled = true;
wl_signal_emit(&compositor->output_created_signal, output);
@@ -4540,8 +4542,6 @@
pixman_region32_fini(&output->region);
pixman_region32_fini(&output->previous_damage);
output->compositor->output_id_pool &= ~(1u << output->id);
-
- output->enabled = false;
}
/** Removes output from compositor's list of enabled outputs
@@ -4577,6 +4577,7 @@
struct weston_view *view;
assert(output->destroying);
+ assert(output->enabled);
wl_list_for_each(view, &compositor->view_list, link) {
if (view->output_mask & (1u << output->id))
@@ -4589,6 +4590,7 @@
wl_list_remove(&output->link);
wl_list_insert(compositor->pending_output_list.prev, &output->link);
+ output->enabled = false;
wl_signal_emit(&compositor->output_destroyed_signal, output);
wl_signal_emit(&output->destroy_signal, output);
@@ -4671,7 +4673,6 @@
assert(output->name);
wl_list_init(&output->link);
-
output->enabled = false;
/* Add some (in)sane defaults which can be used
@@ -4791,8 +4792,6 @@
wl_global_create(c->wl_display, &wl_output_interface, 3,
output, bind_output);
- output->enabled = true;
-
/* Enable the output (set up the crtc or create a
* window representing the output, set up the
* renderer, etc)
diff --git a/libweston/compositor.h b/libweston/compositor.h
index 4e01f05..0be9157 100644
--- a/libweston/compositor.h
+++ b/libweston/compositor.h
@@ -233,7 +233,7 @@
struct weston_timeline_object timeline;
- bool enabled;
+ bool enabled; /**< is in the output_list, not pending list */
int scale;
int (*enable)(struct weston_output *output);