aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2017-12-07 01:05:49 +0100
committeremersion <contact@emersion.fr>2017-12-07 01:05:49 +0100
commit9ddaea14a1b24bf755417bffce792b0d4a23a87c (patch)
treee5840112f7d81b82da3a1f41adfdc21d0150c26d
parent983ea3033fdbf477e0810582501b0bbc1460f1c9 (diff)
Listen to display destroy in wl-shell
-rw-r--r--include/wlr/types/wlr_wl_shell.h2
-rw-r--r--types/wlr_wl_shell.c14
2 files changed, 14 insertions, 2 deletions
diff --git a/include/wlr/types/wlr_wl_shell.h b/include/wlr/types/wlr_wl_shell.h
index 986f92e8..29446b04 100644
--- a/include/wlr/types/wlr_wl_shell.h
+++ b/include/wlr/types/wlr_wl_shell.h
@@ -12,6 +12,8 @@ struct wlr_wl_shell {
struct wl_list popup_grabs;
uint32_t ping_timeout;
+ struct wl_listener display_destroy;
+
struct {
struct wl_signal new_surface;
} events;
diff --git a/types/wlr_wl_shell.c b/types/wlr_wl_shell.c
index ee72856c..78154245 100644
--- a/types/wlr_wl_shell.c
+++ b/types/wlr_wl_shell.c
@@ -564,6 +564,12 @@ static void shell_bind(struct wl_client *wl_client, void *data,
wl_list_insert(&wl_shell->wl_resources, wl_resource_get_link(wl_resource));
}
+static void handle_display_destroy(struct wl_listener *listener, void *data) {
+ struct wlr_wl_shell *wl_shell =
+ wl_container_of(listener, wl_shell, display_destroy);
+ wlr_wl_shell_destroy(wl_shell);
+}
+
struct wlr_wl_shell *wlr_wl_shell_create(struct wl_display *display) {
struct wlr_wl_shell *wl_shell = calloc(1, sizeof(struct wlr_wl_shell));
if (!wl_shell) {
@@ -581,6 +587,10 @@ struct wlr_wl_shell *wlr_wl_shell_create(struct wl_display *display) {
wl_list_init(&wl_shell->surfaces);
wl_list_init(&wl_shell->popup_grabs);
wl_signal_init(&wl_shell->events.new_surface);
+
+ wl_shell->display_destroy.notify = handle_display_destroy;
+ wl_display_add_destroy_listener(display, &wl_shell->display_destroy);
+
return wl_shell;
}
@@ -588,14 +598,14 @@ void wlr_wl_shell_destroy(struct wlr_wl_shell *wlr_wl_shell) {
if (!wlr_wl_shell) {
return;
}
+ wl_list_remove(&wlr_wl_shell->display_destroy.link);
struct wl_resource *resource = NULL, *temp = NULL;
wl_resource_for_each_safe(resource, temp, &wlr_wl_shell->wl_resources) {
struct wl_list *link = wl_resource_get_link(resource);
wl_list_remove(link);
}
// TODO: destroy surfaces
- // TODO: this segfault (wl_display->registry_resource_list is not init)
- // wl_global_destroy(wlr_wl_shell->wl_global);
+ wl_global_destroy(wlr_wl_shell->wl_global);
free(wlr_wl_shell);
}