From 4cb88c79e0277579fc36a152653dc1efe2cdf6c9 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Mon, 13 Aug 2012 15:18:44 +0100 Subject: [PATCH] shell: Avoid modulo by zero error in positioning algorithm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As spotted by Philipp Brüschweiler --- src/shell.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/shell.c b/src/shell.c index 9d969ff9..4633049a 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;