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

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

Details

Message ID 1525249318-4746-2-git-send-email-fabien.lahoudere@collabora.com
State Accepted
Commit 99372bab4ce6555526edbf2c8ac114ac3c8acdfb
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.

Let get_output_work_area() return a zero area if the given output is
NULL. If there is no output, there is no area. Unfortunately we cannot
return "no position" but have to use 0,0 instead.

In send_configure_for_surface(), this causes a maximized surface to
receive width=0 and height=0 in the configure event, which means the
client is free to choose the size. There is no correct size to send for
maximizing for no output.

In constrain_position(), this has no effect. The interactive move of a
surface is restricted to not go below the panel, so even if a user
managed to move a surface without an output, it just prevents the
surface moving beyond y=0.

In weston_view_set_initial_position(), get_output_work_area() will not
be called with NULL output anyway.

In set_maximized_position(), this makes it behave as if the output was
at 0,0 which is the default position of the first output.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.com>
---
 desktop-shell/shell.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Patch hide | download patch | download mbox

diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index b846e30..c1a551b 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -341,6 +341,15 @@  get_output_work_area(struct desktop_shell *shell,
 {
 	int32_t panel_width = 0, panel_height = 0;
 
+	if (!output) {
+		area->x = 0;
+		area->y = 0;
+		area->width = 0;
+		area->height = 0;
+
+		return;
+	}
+
 	area->x = output->x;
 	area->y = output->y;