mirror of
https://gitlab.freedesktop.org/wayland/weston
synced 2024-07-22 03:04:13 +00:00
shell: Avoid modulo by zero error in positioning algorithm
As spotted by Philipp Brüschweiler <blei42@gmail.com>
This commit is contained in:
parent
ac63e5bd7e
commit
4cb88c79e0
12
src/shell.c
12
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;
|
||||
|
|
Loading…
Reference in a new issue