aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2018-11-28 14:08:20 +0100
committeremersion <contact@emersion.fr>2018-11-28 14:08:20 +0100
commitb98563d2d7fd2481188c60c0dafc036a9ca4dd15 (patch)
tree4ce855c622235ebd43781329bfe0f620db81b3e2
parentf737854e307a3cfeaba43f5ff18d540c23c65fa5 (diff)
Fix segfault when destroying unmapped child view
-rw-r--r--include/sway/tree/view.h1
-rw-r--r--sway/tree/view.c12
2 files changed, 10 insertions, 3 deletions
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h
index d74f1bc9..5cc9777b 100644
--- a/include/sway/tree/view.h
+++ b/include/sway/tree/view.h
@@ -195,6 +195,7 @@ struct sway_view_child {
struct sway_view *view;
struct wlr_surface *surface;
+ bool mapped;
struct wl_listener surface_commit;
struct wl_listener surface_new_subsurface;
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 0edefc8e..4c46d0e9 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -711,8 +711,6 @@ static const struct sway_view_child_impl subsurface_impl = {
.destroy = subsurface_destroy,
};
-static void view_child_damage(struct sway_view_child *child, bool whole);
-
static void subsurface_handle_destroy(struct wl_listener *listener,
void *data) {
struct sway_subsurface *subsurface =
@@ -721,6 +719,8 @@ static void subsurface_handle_destroy(struct wl_listener *listener,
view_child_destroy(child);
}
+static void view_child_damage(struct sway_view_child *child, bool whole);
+
static void view_subsurface_create(struct sway_view *view,
struct wlr_subsurface *wlr_subsurface) {
struct sway_subsurface *subsurface =
@@ -734,6 +734,9 @@ static void view_subsurface_create(struct sway_view *view,
wl_signal_add(&wlr_subsurface->events.destroy, &subsurface->destroy);
subsurface->destroy.notify = subsurface_handle_destroy;
+
+ subsurface->child.mapped = true;
+ view_child_damage(&subsurface->child, true);
}
static void view_child_damage(struct sway_view_child *child, bool whole) {
@@ -778,6 +781,7 @@ static void view_child_handle_surface_map(struct wl_listener *listener,
void *data) {
struct sway_view_child *child =
wl_container_of(listener, child, surface_map);
+ child->mapped = true;
view_child_damage(child, true);
}
@@ -786,6 +790,7 @@ static void view_child_handle_surface_unmap(struct wl_listener *listener,
struct sway_view_child *child =
wl_container_of(listener, child, surface_unmap);
view_child_damage(child, true);
+ child->mapped = false;
}
void view_child_init(struct sway_view_child *child,
@@ -804,6 +809,7 @@ void view_child_init(struct sway_view_child *child,
wl_signal_add(&surface->events.destroy, &child->surface_destroy);
child->surface_destroy.notify = view_child_handle_surface_destroy;
+ // Not all child views have a map/unmap event
child->surface_map.notify = view_child_handle_surface_map;
child->surface_unmap.notify = view_child_handle_surface_unmap;
@@ -814,7 +820,7 @@ void view_child_init(struct sway_view_child *child,
}
void view_child_destroy(struct sway_view_child *child) {
- if (child->view->container != NULL) {
+ if (child->mapped && child->view->container != NULL) {
view_child_damage(child, true);
}