[weston,2/4] desktop-shell: handle NULL output in center_on_output()

Submitted by Fabien Lahoudere on May 2, 2018, 8:21 a.m.

Details

Message ID 1525249318-4746-3-git-send-email-fabien.lahoudere@collabora.com
State Accepted
Commit 30aa59759ae9a3629c5f4e6a1d9532c41620328b
Headers show
Series "Handle several NULL output pointer" ( rev: 1 ) in Wayland (DEPRECATED)

Not browsing as part of any series.

Commit Message

Fabien Lahoudere May 2, 2018, 8:21 a.m.
From: Pekka Paalanen <pekka.paalanen@collabora.co.uk>

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>
---
 desktop-shell/shell.c | 5 +++++
 1 file changed, 5 insertions(+)

Patch hide | download patch | download mbox

diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index c1a551b..e6ce20b 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -4150,6 +4150,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;