shell: Avoid modulo by zero error in positioning algorithm
As spotted by Philipp Brüschweiler <blei42@gmail.com>
This commit is contained in:
committed by
Kristian Høgsberg
parent
ac63e5bd7e
commit
4cb88c79e0
+6
-6
@@ -2636,15 +2636,15 @@ weston_surface_set_initial_position (struct weston_surface *surface,
|
|||||||
range_y = (target_output->current->height - panel_height) -
|
range_y = (target_output->current->height - panel_height) -
|
||||||
surface->geometry.height;
|
surface->geometry.height;
|
||||||
|
|
||||||
if (range_x < 0)
|
if (range_x > 0)
|
||||||
dx = 0;
|
|
||||||
else
|
|
||||||
dx = random() % range_x;
|
dx = random() % range_x;
|
||||||
|
|
||||||
if (range_y < 0)
|
|
||||||
dy = panel_height;
|
|
||||||
else
|
else
|
||||||
|
dx = 0;
|
||||||
|
|
||||||
|
if (range_y > 0)
|
||||||
dy = panel_height + random() % range_y;
|
dy = panel_height + random() % range_y;
|
||||||
|
else
|
||||||
|
dy = panel_height;
|
||||||
|
|
||||||
x = target_output->x + dx;
|
x = target_output->x + dx;
|
||||||
y = target_output->y + dy;
|
y = target_output->y + dy;
|
||||||
|
|||||||
Reference in New Issue
Block a user