summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Vlad <marius.vlad@collabora.com>2020-01-17 12:32:55 +0200
committerMarius Vlad <marius.vlad@collabora.com>2020-01-17 12:47:32 +0200
commita27658e9813003b53132aeccfd3b9861ade5e559 (patch)
treecb30ee0bf65544fda49144f4f51bc40caeb9bff6
parentc3c0b247a05da46eb032320f38428767acc26910 (diff)
desktop-shell: Do not try to add a child to a non-existent parent
Introduced with a8da2084, it seems that there are cases when there's no parent available (zenity, for instance). Removes any potential child and re-initialize it, in case the parent is not set. (Simon Ser) Fixes: #340 Signed-off-by: Marius Vlad <marius.vlad@collabora.com> Reviewed-by: Simon Ser <contact@emersion.fr> Reported-by: n3rdopolis <bluescreenavenger@gmail.com>
-rw-r--r--desktop-shell/shell.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index 7d9d703c..442a625f 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -2769,13 +2769,20 @@ desktop_surface_set_parent(struct weston_desktop_surface *desktop_surface,
struct weston_desktop_surface *parent,
void *shell)
{
+ struct shell_surface *shsurf_parent;
struct shell_surface *shsurf =
weston_desktop_surface_get_user_data(desktop_surface);
- struct shell_surface *shsurf_parent =
- weston_desktop_surface_get_user_data(parent);
- wl_list_insert(shsurf_parent->children_list.prev,
- &shsurf->children_link);
+ /* unlink any potential child */
+ wl_list_remove(&shsurf->children_link);
+
+ if (parent) {
+ shsurf_parent = weston_desktop_surface_get_user_data(parent);
+ wl_list_insert(shsurf_parent->children_list.prev,
+ &shsurf->children_link);
+ } else {
+ wl_list_init(&shsurf->children_link);
+ }
}
static void