[PATCH] shell: Avoid modulo by zero error in positioning algorithm

Kristian Høgsberg hoegsberg at gmail.com
Mon Aug 13 07:58:48 PDT 2012


On Mon, Aug 13, 2012 at 03:18:44PM +0100, Rob Bradford wrote:
> From: Rob Bradford <rob at linux.intel.com>

Oh, yup, committed.

Krsitian

> As spotted by Philipp Brüschweiler <blei42 at gmail.com>
> ---
>  src/shell.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/src/shell.c b/src/shell.c
> index 9d969ff..4633049 100644
> --- a/src/shell.c
> +++ b/src/shell.c
> @@ -2636,15 +2636,15 @@ weston_surface_set_initial_position (struct weston_surface *surface,
>  	range_y = (target_output->current->height - panel_height) -
>  		  surface->geometry.height;
>  
> -	if (range_x < 0)
> -		dx = 0;
> -	else
> +	if (range_x > 0)
>  		dx = random() % range_x;
> -
> -	if (range_y < 0)
> -		dy = panel_height;
>  	else
> +		dx = 0;
> +
> +	if (range_y > 0)
>  		dy = panel_height + random() % range_y;
> +	else
> +		dy = panel_height;
>  
>  	x = target_output->x + dx;
>  	y = target_output->y + dy;
> -- 
> 1.7.11.2
> 
> _______________________________________________
> 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