diff options
author | Pekka Paalanen <pekka.paalanen@collabora.co.uk> | 2018-05-02 10:21:56 +0200 |
---|---|---|
committer | Pekka Paalanen <pekka.paalanen@collabora.co.uk> | 2018-05-24 17:20:04 +0300 |
commit | 30aa59759ae9a3629c5f4e6a1d9532c41620328b (patch) | |
tree | 20f5e4aa2c421140956547148c32c9646d3555b1 | |
parent | 99372bab4ce6555526edbf2c8ac114ac3c8acdfb (diff) | |
download | weston-30aa59759ae9a3629c5f4e6a1d9532c41620328b.tar.gz weston-30aa59759ae9a3629c5f4e6a1d9532c41620328b.tar.bz2 weston-30aa59759ae9a3629c5f4e6a1d9532c41620328b.zip |
desktop-shell: handle NULL output in center_on_output()
This is a tentative crash fix for a case where there are no enabled
weston_outputs at all.
If no output is given, just put the surface at 0,0. At least it should
become mostly visible if an output is plugged in, if not centered.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
-rw-r--r-- | desktop-shell/shell.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index 386177c3..f87151d9 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -4190,6 +4190,11 @@ center_on_output(struct weston_view *view, struct weston_output *output) int32_t surf_x, surf_y, width, height; float x, y; + if (!output) { + weston_view_set_position(view, 0, 0); + return; + } + surface_subsurfaces_boundingbox(view->surface, &surf_x, &surf_y, &width, &height); x = output->x + (output->width - width) / 2 - surf_x / 2; |