From 7f340ff89595c397153d0e485cbddd8562dc8a0e Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Thu, 30 Mar 2017 14:56:22 +0300 Subject: [PATCH] libweston: specify weston_output::enabled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Armin Krezović --- libweston/compositor.c | 9 ++++----- libweston/compositor.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/libweston/compositor.c b/libweston/compositor.c index 97ade223..6d3dc1cc 100644 --- a/libweston/compositor.c +++ b/libweston/compositor.c @@ -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) diff --git a/libweston/compositor.h b/libweston/compositor.h index 4e01f056..0be9157e 100644 --- a/libweston/compositor.h +++ b/libweston/compositor.h @@ -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);