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>
dev
Pekka Paalanen 8 years ago
parent e952a01c3b
commit 7f340ff895
  1. 9
      libweston/compositor.c
  2. 2
      libweston/compositor.h

@ -4483,8 +4483,10 @@ weston_compositor_add_output(struct weston_compositor *compositor,
{
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 @@ weston_output_enable_undo(struct weston_output *output)
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 @@ weston_compositor_remove_output(struct weston_output *output)
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 @@ weston_compositor_remove_output(struct weston_output *output)
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 @@ weston_output_init(struct weston_output *output,
assert(output->name);
wl_list_init(&output->link);
output->enabled = false;
/* Add some (in)sane defaults which can be used
@ -4791,8 +4792,6 @@ weston_output_enable(struct weston_output *output)
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)

@ -233,7 +233,7 @@ struct weston_output {
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);

Loading…
Cancel
Save