[PATCH weston] window: improve EGL-related error messages

Kristian Høgsberg hoegsberg at gmail.com
Thu Feb 14 09:17:54 PST 2013


On Thu, Feb 14, 2013 at 11:49:12AM +0200, Pekka Paalanen wrote:
> Make them explicitly mention EGL, otherwise one can easily think that
> "failed to initialize display" refers to Wayland display.
> 
> Also explicitly mention falling back to wl_shm. I tested this with a
> LD_PRELOAD trick that overrides eglBindAPI and makes it fail.
> 
> Signed-off-by: Pekka Paalanen <ppaalanen at gmail.com>
> ---
>  clients/window.c | 18 ++++++++++--------
>  1 file changed, 10 insertions(+), 8 deletions(-)

That certainly makes the error output more friendly and useful.  Commited.

Kristian

> diff --git a/clients/window.c b/clients/window.c
> index 9abb9ae..f06f1d6 100644
> --- a/clients/window.c
> +++ b/clients/window.c
> @@ -4222,36 +4222,36 @@ init_egl(struct display *d)
>  
>  	d->dpy = eglGetDisplay(d->display);
>  	if (!eglInitialize(d->dpy, &major, &minor)) {
> -		fprintf(stderr, "failed to initialize display\n");
> +		fprintf(stderr, "failed to initialize EGL\n");
>  		return -1;
>  	}
>  
>  	if (!eglBindAPI(api)) {
> -		fprintf(stderr, "failed to bind api EGL_OPENGL_API\n");
> +		fprintf(stderr, "failed to bind EGL client API\n");
>  		return -1;
>  	}
>  
>  	if (!eglChooseConfig(d->dpy, argb_cfg_attribs,
>  			     &d->argb_config, 1, &n) || n != 1) {
> -		fprintf(stderr, "failed to choose argb config\n");
> +		fprintf(stderr, "failed to choose argb EGL config\n");
>  		return -1;
>  	}
>  
>  	d->argb_ctx = eglCreateContext(d->dpy, d->argb_config,
>  				       EGL_NO_CONTEXT, context_attribs);
>  	if (d->argb_ctx == NULL) {
> -		fprintf(stderr, "failed to create context\n");
> +		fprintf(stderr, "failed to create EGL context\n");
>  		return -1;
>  	}
>  
>  	if (!eglMakeCurrent(d->dpy, NULL, NULL, d->argb_ctx)) {
> -		fprintf(stderr, "failed to make context current\n");
> +		fprintf(stderr, "failed to make EGL context current\n");
>  		return -1;
>  	}
>  
>  	d->argb_device = cairo_egl_device_create(d->dpy, d->argb_ctx);
>  	if (cairo_device_status(d->argb_device) != CAIRO_STATUS_SUCCESS) {
> -		fprintf(stderr, "failed to get cairo egl argb device\n");
> +		fprintf(stderr, "failed to get cairo EGL argb device\n");
>  		return -1;
>  	}
>  
> @@ -4335,7 +4335,7 @@ display_create(int argc, char *argv[])
>  
>  	d->display = wl_display_connect(NULL);
>  	if (d->display == NULL) {
> -		fprintf(stderr, "failed to create display: %m\n");
> +		fprintf(stderr, "failed to connect to Wayland display: %m\n");
>  		free(d);
>  		return NULL;
>  	}
> @@ -4364,7 +4364,9 @@ display_create(int argc, char *argv[])
>  	wl_registry_add_listener(d->registry, &registry_listener, d);
>  	wl_display_dispatch(d->display);
>  #ifdef HAVE_CAIRO_EGL
> -	init_egl(d);
> +	if (init_egl(d) < 0)
> +		fprintf(stderr, "EGL does not seem to work, "
> +			"falling back to software rendering and wl_shm.\n");
>  #endif
>  
>  	create_cursors(d);
> -- 
> 1.7.12.4
> 


More information about the wayland-devel mailing list