diff options
author | Simon Ser <contact@emersion.fr> | 2022-10-18 13:02:47 +0200 |
---|---|---|
committer | Simon Zeni <simon@bl4ckb0ne.ca> | 2022-11-18 15:35:20 +0000 |
commit | d3b84463f8d6d483f446b3cdd18fcff031bc830c (patch) | |
tree | f58202caceb35f546a92d1bdaf119e4f0808e909 | |
parent | 44c7e233ff7581c9735b03c2105d9803f9a8535f (diff) |
xwayland: add wlr_xwayland_shell_v1_destroy()
-rw-r--r-- | include/wlr/xwayland/shell.h | 7 | ||||
-rw-r--r-- | xwayland/shell.c | 22 |
2 files changed, 25 insertions, 4 deletions
diff --git a/include/wlr/xwayland/shell.h b/include/wlr/xwayland/shell.h index 893e5fda..91b7c716 100644 --- a/include/wlr/xwayland/shell.h +++ b/include/wlr/xwayland/shell.h @@ -27,6 +27,7 @@ struct wlr_xwayland_shell_v1 { // private state struct wl_client *client; + struct wl_list surfaces; // wlr_xwayland_surface_v1.link struct wl_listener display_destroy; struct wl_listener client_destroy; @@ -42,6 +43,7 @@ struct wlr_xwayland_surface_v1 { // private state struct wl_resource *resource; + struct wl_list link; struct wlr_xwayland_shell_v1 *shell; bool added; @@ -58,6 +60,11 @@ struct wlr_xwayland_shell_v1 *wlr_xwayland_shell_v1_create( struct wl_display *display, uint32_t version); /** + * Destroy the xwayland_shell_v1 global. + */ +void wlr_xwayland_shell_v1_destroy(struct wlr_xwayland_shell_v1 *shell); + +/** * Allow a client to bind to the xwayland_shell_v1 global. */ void wlr_xwayland_shell_v1_set_client(struct wlr_xwayland_shell_v1 *shell, diff --git a/xwayland/shell.c b/xwayland/shell.c index 75049f64..a6ec315b 100644 --- a/xwayland/shell.c +++ b/xwayland/shell.c @@ -161,10 +161,7 @@ static void shell_bind(struct wl_client *client, void *data, uint32_t version, static void handle_display_destroy(struct wl_listener *listener, void *data) { struct wlr_xwayland_shell_v1 *shell = wl_container_of(listener, shell, display_destroy); - wl_list_remove(&shell->display_destroy.link); - wl_list_remove(&shell->client_destroy.link); - wl_global_destroy(shell->global); - free(shell); + wlr_xwayland_shell_v1_destroy(shell); } struct wlr_xwayland_shell_v1 *wlr_xwayland_shell_v1_create( @@ -183,6 +180,7 @@ struct wlr_xwayland_shell_v1 *wlr_xwayland_shell_v1_create( return NULL; } + wl_list_init(&shell->surfaces); wl_signal_init(&shell->events.new_surface); shell->display_destroy.notify = handle_display_destroy; @@ -193,6 +191,22 @@ struct wlr_xwayland_shell_v1 *wlr_xwayland_shell_v1_create( return shell; } +void wlr_xwayland_shell_v1_destroy(struct wlr_xwayland_shell_v1 *shell) { + if (shell == NULL) { + return; + } + + struct wlr_xwayland_surface_v1 *xwl_surface, *tmp; + wl_list_for_each_safe(xwl_surface, tmp, &shell->surfaces, link) { + wlr_surface_destroy_role_object(xwl_surface->surface); + } + + wl_list_remove(&shell->display_destroy.link); + wl_list_remove(&shell->client_destroy.link); + wl_global_destroy(shell->global); + free(shell); +} + static void shell_handle_client_destroy(struct wl_listener *listener, void *data) { struct wlr_xwayland_shell_v1 *shell = wl_container_of(listener, shell, client_destroy); |