[PATCH weston] weston-info: display output scale

Pekka Paalanen ppaalanen at gmail.com
Wed Dec 16 23:19:43 PST 2015


On Wed, 16 Dec 2015 19:19:55 +0000
Jonny Lamb <jonny.lamb at collabora.co.uk> wrote:

> Fall back to not showing anything as before if we don't have a
> compositor with wl_output new enough (version 2 or newer).
> 
> Signed-off-by: Jonny Lamb <jonny.lamb at collabora.co.uk>
> ---
>  clients/weston-info.c | 25 +++++++++++++++++++++++--
>  1 file changed, 23 insertions(+), 2 deletions(-)
> 
> diff --git a/clients/weston-info.c b/clients/weston-info.c
> index f22781c..0b70701 100644
> --- a/clients/weston-info.c
> +++ b/clients/weston-info.c
> @@ -65,6 +65,7 @@ struct output_info {
>  
>  	struct {
>  		int32_t x, y;
> +		int32_t scale;
>  		int32_t physical_width, physical_height;
>  		enum wl_output_subpixel subpixel;
>  		enum wl_output_transform output_transform;
> @@ -233,8 +234,12 @@ print_output_info(void *data)
>  		break;
>  	}
>  
> -	printf("\tx: %d, y: %d,\n",
> +	printf("\tx: %d, y: %d,",
>  	       output->geometry.x, output->geometry.y);
> +	if (output->geometry.scale)
> +		printf(" scale: %d,", output->geometry.scale);
> +	printf("\n");
> +
>  	printf("\tphysical_width: %d mm, physical_height: %d mm,\n",
>  	       output->geometry.physical_width,
>  	       output->geometry.physical_height);
> @@ -519,9 +524,25 @@ output_handle_mode(void *data, struct wl_output *wl_output,
>  	wl_list_insert(output->modes.prev, &mode->link);
>  }
>  
> +static void
> +output_handle_done(void *data, struct wl_output *wl_output)
> +{
> +}
> +
> +static void
> +output_handle_scale(void *data, struct wl_output *wl_output,
> +		    int32_t scale)
> +{
> +	struct output_info *output = data;
> +
> +	output->geometry.scale = scale;
> +}
> +
>  static const struct wl_output_listener output_listener = {
>  	output_handle_geometry,
>  	output_handle_mode,
> +	output_handle_done,
> +	output_handle_scale,
>  };
>  
>  static void
> @@ -555,7 +576,7 @@ add_output_info(struct weston_info *info, uint32_t id, uint32_t version)
>  	wl_list_init(&output->modes);
>  
>  	output->output = wl_registry_bind(info->registry, id,
> -					  &wl_output_interface, 1);
> +					  &wl_output_interface, MIN(version, 2));
>  	wl_output_add_listener(output->output, &output_listener,
>  			       output);
>  

Hi Jonny,

yup, this looks like it should work. A slightly more orthodox
implementation would save the interface version you are binding and
make things conditional on that. The spec also says that scale is 1 if
it is not sent, so you'd probably want to init it to 1.

The spec would want us to wait for 'done' on version 2 interface before
assuming all parameters are received. That would be good to have, but
not strictly necessary I think, since this is handling only initial
events and there is no good reason why a compositor would delay sending
some events. A comment saying we are taking a shortcut would be good
though.


Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 811 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20151217/24204059/attachment.sig>


More information about the wayland-devel mailing list