[PATCH weston v2] compositor: Refactor weston_output_mode_switch()

Pekka Paalanen ppaalanen at gmail.com
Wed Nov 5 03:17:48 PST 2014


On Tue,  4 Nov 2014 10:47:33 -0600
Derek Foreman <derekf at osg.samsung.com> wrote:

> This breaks weston_output_mode_switch() into 3 functions:
> weston_output_mode_set_native()
> weston_output_mode_switch_to_temporary()
> weston_output_mode_switch_to_native()
> 
> Differences from previous behaviour:
> SET_NATIVE didn't set current_scale (now it does)
> SET_TEMPORARY could set mode and scale independently - now it can't.
> 
> Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
> ---
> In previous version weston_output_mode_switch_to_temporary didn't
> call weston_mode_switch_finish() correctly
> 
>  desktop-shell/shell.c               |  12 +--
>  fullscreen-shell/fullscreen-shell.c |  13 +--
>  src/compositor-rdp.c                |   2 +-
>  src/compositor.c                    | 185 ++++++++++++++++++++----------------
>  src/compositor.h                    |  17 ++--
>  5 files changed, 123 insertions(+), 106 deletions(-)

...

> @@ -211,25 +148,113 @@ weston_output_switch_mode(struct weston_output *output, struct weston_mode *mode
>  	pixman_region32_fini(&old_output_region);
>  
>  	/* notify clients of the changes */
> -	if (notify_mode_changed || notify_scale_changed) {
> -		wl_resource_for_each(resource, &output->resource_list) {
> -			if(notify_mode_changed) {
> -				wl_output_send_mode(resource,
> -						mode->flags | WL_OUTPUT_MODE_CURRENT,
> -						mode->width,
> -						mode->height,
> -						mode->refresh);
> -			}
> +	wl_resource_for_each(resource, &output->resource_list) {
> +		if (mode_changed) {
> +			wl_output_send_mode(resource,
> +					    output->current_mode->flags,
> +					    output->current_mode->width,
> +					    output->current_mode->height,
> +					    output->current_mode->refresh);
> +		}
> +
> +		if (scale_changed)
> +			wl_output_send_scale(resource, output->current_scale);

This and the original code have a bug here. The 'scale' event was added
in interface version 2 according to wayland.xml, just like 'done', so
need to check the resource version before sending.

Would you like to send another patch fixing that?

> +
> +		if (wl_resource_get_version(resource) >= 2)
> +			   wl_output_send_done(resource);
> +	}
> +}
>  
> -			if (notify_scale_changed)
> -				wl_output_send_scale(resource, scale);
> +WL_EXPORT int
> +weston_output_mode_set_native(struct weston_output *output,
> +			      struct weston_mode *mode,
> +			      int32_t scale)
> +{
> +	int ret;
> +	int mode_changed = 0, scale_changed = 0;
>  
> -			if (wl_resource_get_version(resource) >= 2)
> -				   wl_output_send_done(resource);

Looks good, pushed.


Thanks,
pq


More information about the wayland-devel mailing list