[PATCH weston v2] compositor: send the output_created signal after inserting it in the list

Bryce Harrington bryce at osg.samsung.com
Fri May 8 14:10:15 PDT 2015


On Wed, May 06, 2015 at 09:41:57PM +0300, Giulio Camuffo wrote:
> The compositor's output_created signal used to be sent in weston_output_init()
> which the backend call before putting the output in the output_list.
> This caused problems when creating a new view in a listener to that signal,
> because weston_view_assign_output() doesn't yet know the new output exists.
> To fix this add a new weston_composito_add_output() func which adds the
> output in the list and later sends the signal, and make the backends call
> that.

Reviewed-by: Bryce Harrington <bryce at osg.samsung.com>

LGTM, pushed:
   22f3430..b114715  master -> master


> ---
>  src/compositor-drm.c      |  2 +-
>  src/compositor-fbdev.c    |  2 +-
>  src/compositor-headless.c |  2 +-
>  src/compositor-rdp.c      |  2 +-
>  src/compositor-rpi.c      |  2 +-
>  src/compositor-wayland.c  |  2 +-
>  src/compositor-x11.c      |  2 +-
>  src/compositor.c          | 15 ++++++++++++++-
>  src/compositor.h          |  3 +++
>  9 files changed, 24 insertions(+), 8 deletions(-)
> 
> diff --git a/src/compositor-drm.c b/src/compositor-drm.c
> index 43197a8..0cdb8f4 100644
> --- a/src/compositor-drm.c
> +++ b/src/compositor-drm.c
> @@ -2125,7 +2125,7 @@ create_output_for_connector(struct drm_compositor *ec,
>  		weston_log("Failed to initialize backlight\n");
>  	}
>  
> -	wl_list_insert(ec->base.output_list.prev, &output->base.link);
> +	weston_compositor_add_output(&ec->base, &output->base);
>  
>  	find_and_parse_output_edid(ec, output, connector);
>  	if (connector->connector_type == DRM_MODE_CONNECTOR_LVDS)
> diff --git a/src/compositor-fbdev.c b/src/compositor-fbdev.c
> index bac6b87..7c505ce 100644
> --- a/src/compositor-fbdev.c
> +++ b/src/compositor-fbdev.c
> @@ -581,7 +581,7 @@ fbdev_output_create(struct fbdev_compositor *compositor,
>  	output->finish_frame_timer =
>  		wl_event_loop_add_timer(loop, finish_frame_handler, output);
>  
> -	wl_list_insert(compositor->base.output_list.prev, &output->base.link);
> +	weston_compositor_add_output(&compositor->base, &output->base);
>  
>  	weston_log("fbdev output %d×%d px\n",
>  	           output->mode.width, output->mode.height);
> diff --git a/src/compositor-headless.c b/src/compositor-headless.c
> index 1b1d327..fe35289 100644
> --- a/src/compositor-headless.c
> +++ b/src/compositor-headless.c
> @@ -169,7 +169,7 @@ headless_compositor_create_output(struct headless_compositor *c,
>  						  output->image);
>  	}
>  
> -	wl_list_insert(c->base.output_list.prev, &output->base.link);
> +	weston_compositor_add_output(&c->base, &output->base);
>  
>  	return 0;
>  }
> diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
> index 6955d49..0d64928 100644
> --- a/src/compositor-rdp.c
> +++ b/src/compositor-rdp.c
> @@ -488,7 +488,7 @@ rdp_compositor_create_output(struct rdp_compositor *c, int width, int height)
>  	output->base.switch_mode = rdp_switch_mode;
>  	c->output = output;
>  
> -	wl_list_insert(c->base.output_list.prev, &output->base.link);
> +	weston_compositor_add_output(&c->base, &output->base);
>  	return 0;
>  
>  out_shadow_surface:
> diff --git a/src/compositor-rpi.c b/src/compositor-rpi.c
> index bc93923..1c0a783 100644
> --- a/src/compositor-rpi.c
> +++ b/src/compositor-rpi.c
> @@ -357,7 +357,7 @@ rpi_output_create(struct rpi_compositor *compositor, uint32_t transform)
>  	if (rpi_renderer_output_create(&output->base, output->display) < 0)
>  		goto out_output;
>  
> -	wl_list_insert(compositor->base.output_list.prev, &output->base.link);
> +	weston_compositor_add_output(&compositor->base, &output->base);
>  
>  	weston_log("Raspberry Pi HDMI output %dx%d px\n",
>  		   output->mode.width, output->mode.height);
> diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
> index 6c33361..303151c 100644
> --- a/src/compositor-wayland.c
> +++ b/src/compositor-wayland.c
> @@ -1057,7 +1057,7 @@ wayland_output_create(struct wayland_compositor *c, int x, int y,
>  	output->base.set_dpms = NULL;
>  	output->base.switch_mode = wayland_output_switch_mode;
>  
> -	wl_list_insert(c->base.output_list.prev, &output->base.link);
> +	weston_compositor_add_output(&c->base, &output->base);
>  
>  	return output;
>  
> diff --git a/src/compositor-x11.c b/src/compositor-x11.c
> index 9792ac6..5129e85 100644
> --- a/src/compositor-x11.c
> +++ b/src/compositor-x11.c
> @@ -915,7 +915,7 @@ x11_compositor_create_output(struct x11_compositor *c, int x, int y,
>  	output->finish_frame_timer =
>  		wl_event_loop_add_timer(loop, finish_frame_handler, output);
>  
> -	wl_list_insert(c->base.output_list.prev, &output->base.link);
> +	weston_compositor_add_output(&c->base, &output->base);
>  
>  	weston_log("x11 output %dx%d, window id %d\n",
>  		   width, height, output->window);
> diff --git a/src/compositor.c b/src/compositor.c
> index 698ee52..8f02b4d 100644
> --- a/src/compositor.c
> +++ b/src/compositor.c
> @@ -4125,7 +4125,20 @@ weston_output_init(struct weston_output *output, struct weston_compositor *c,
>  	output->global =
>  		wl_global_create(c->wl_display, &wl_output_interface, 2,
>  				 output, bind_output);
> -	wl_signal_emit(&c->output_created_signal, output);
> +}
> +
> +/** Adds an output to the compositor's output list and
> + *  send the compositor's output_created signal.
> + *
> + * \param compositor The compositor instance.
> + * \param output The output to be added.
> + */
> +WL_EXPORT void
> +weston_compositor_add_output(struct weston_compositor *compositor,
> +                             struct weston_output *output)
> +{
> +	wl_list_insert(compositor->output_list.prev, &output->link);
> +	wl_signal_emit(&compositor->output_created_signal, output);
>  }
>  
>  WL_EXPORT void
> diff --git a/src/compositor.h b/src/compositor.h
> index 2cfd53e..11f66ba 100644
> --- a/src/compositor.h
> +++ b/src/compositor.h
> @@ -1372,6 +1372,9 @@ void
>  weston_output_init(struct weston_output *output, struct weston_compositor *c,
>  		   int x, int y, int width, int height, uint32_t transform, int32_t scale);
>  void
> +weston_compositor_add_output(struct weston_compositor *compositor,
> +                             struct weston_output *output);
> +void
>  weston_output_destroy(struct weston_output *output);
>  void
>  weston_output_transform_coordinate(struct weston_output *output,
> -- 
> 2.3.7
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list