aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/wlr/types/wlr_xdg_shell_v6.h2
-rw-r--r--types/wlr_xdg_shell_v6.c13
2 files changed, 13 insertions, 2 deletions
diff --git a/include/wlr/types/wlr_xdg_shell_v6.h b/include/wlr/types/wlr_xdg_shell_v6.h
index 4eb957be..b723a950 100644
--- a/include/wlr/types/wlr_xdg_shell_v6.h
+++ b/include/wlr/types/wlr_xdg_shell_v6.h
@@ -11,6 +11,8 @@ struct wlr_xdg_shell_v6 {
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_xdg_shell_v6.c b/types/wlr_xdg_shell_v6.c
index 2627246f..23d36b6f 100644
--- a/types/wlr_xdg_shell_v6.c
+++ b/types/wlr_xdg_shell_v6.c
@@ -1250,6 +1250,12 @@ static void xdg_shell_bind(struct wl_client *wl_client, void *data,
}
}
+static void handle_display_destroy(struct wl_listener *listener, void *data) {
+ struct wlr_xdg_shell_v6 *xdg_shell =
+ wl_container_of(listener, xdg_shell, display_destroy);
+ wlr_xdg_shell_v6_destroy(xdg_shell);
+}
+
struct wlr_xdg_shell_v6 *wlr_xdg_shell_v6_create(struct wl_display *display) {
struct wlr_xdg_shell_v6 *xdg_shell =
calloc(1, sizeof(struct wlr_xdg_shell_v6));
@@ -1272,6 +1278,9 @@ struct wlr_xdg_shell_v6 *wlr_xdg_shell_v6_create(struct wl_display *display) {
wl_signal_init(&xdg_shell->events.new_surface);
+ xdg_shell->display_destroy.notify = handle_display_destroy;
+ wl_display_add_destroy_listener(display, &xdg_shell->display_destroy);
+
return xdg_shell;
}
@@ -1279,8 +1288,8 @@ void wlr_xdg_shell_v6_destroy(struct wlr_xdg_shell_v6 *xdg_shell) {
if (!xdg_shell) {
return;
}
- // TODO: this segfault (wl_display->registry_resource_list is not init)
- // wl_global_destroy(xdg_shell->wl_global);
+ wl_list_remove(&xdg_shell->display_destroy.link);
+ wl_global_destroy(xdg_shell->wl_global);
free(xdg_shell);
}