mirror of
https://github.com/swaywm/sway.git
synced 2026-04-23 06:46:27 -04:00
Destroy Sway subsurfaces when destroying Sway layer_surface
Otherwise destroying wlr_layer_surface could destroy sway_layer_surface before destroying its subsurfaces that would try to access the sway_layer_surface regardless, possibly crashing Sway.
This commit is contained in:
parent
f4cda5157e
commit
da34ef8dd4
2 changed files with 26 additions and 5 deletions
|
|
@ -21,6 +21,10 @@ struct sway_layer_surface {
|
|||
struct wl_listener new_popup;
|
||||
struct wl_listener new_subsurface;
|
||||
|
||||
struct {
|
||||
struct wl_signal destroy;
|
||||
} events;
|
||||
|
||||
struct wlr_box geo;
|
||||
enum zwlr_layer_shell_v1_layer layer;
|
||||
};
|
||||
|
|
@ -47,6 +51,7 @@ struct sway_layer_subsurface {
|
|||
struct wl_listener unmap;
|
||||
struct wl_listener destroy;
|
||||
struct wl_listener commit;
|
||||
struct wl_listener surface_destroy;
|
||||
};
|
||||
|
||||
struct sway_output;
|
||||
|
|
|
|||
|
|
@ -352,6 +352,7 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
|
|||
if (sway_layer->layer_surface->mapped) {
|
||||
unmap(sway_layer);
|
||||
}
|
||||
wl_signal_emit(&sway_layer->events.destroy, sway_layer);
|
||||
wl_list_remove(&sway_layer->link);
|
||||
wl_list_remove(&sway_layer->destroy.link);
|
||||
wl_list_remove(&sway_layer->map.link);
|
||||
|
|
@ -420,18 +421,29 @@ static void subsurface_handle_commit(struct wl_listener *listener, void *data) {
|
|||
subsurface_damage(subsurface, false);
|
||||
}
|
||||
|
||||
static void subsurface_handle_destroy(struct wl_listener *listener,
|
||||
void *data) {
|
||||
struct sway_layer_subsurface *subsurface =
|
||||
wl_container_of(listener, subsurface, destroy);
|
||||
|
||||
static void subsurface_destroy(struct sway_layer_subsurface *subsurface) {
|
||||
wl_list_remove(&subsurface->map.link);
|
||||
wl_list_remove(&subsurface->unmap.link);
|
||||
wl_list_remove(&subsurface->destroy.link);
|
||||
wl_list_remove(&subsurface->commit.link);
|
||||
wl_list_remove(&subsurface->surface_destroy.link);
|
||||
free(subsurface);
|
||||
}
|
||||
|
||||
static void subsurface_handle_destroy(struct wl_listener *listener,
|
||||
void *data) {
|
||||
struct sway_layer_subsurface *subsurface =
|
||||
wl_container_of(listener, subsurface, destroy);
|
||||
subsurface_destroy(subsurface);
|
||||
}
|
||||
|
||||
static void subsurface_handle_surface_destroy(struct wl_listener *listener,
|
||||
void *data) {
|
||||
struct sway_layer_subsurface *subsurface =
|
||||
wl_container_of(listener, subsurface, surface_destroy);
|
||||
subsurface_destroy(subsurface);
|
||||
}
|
||||
|
||||
static struct sway_layer_subsurface *create_subsurface(
|
||||
struct wlr_subsurface *wlr_subsurface,
|
||||
struct sway_layer_surface *layer_surface) {
|
||||
|
|
@ -452,6 +464,8 @@ static struct sway_layer_subsurface *create_subsurface(
|
|||
wl_signal_add(&wlr_subsurface->events.destroy, &subsurface->destroy);
|
||||
subsurface->commit.notify = subsurface_handle_commit;
|
||||
wl_signal_add(&wlr_subsurface->surface->events.commit, &subsurface->commit);
|
||||
subsurface->surface_destroy.notify = subsurface_handle_surface_destroy;
|
||||
wl_signal_add(&layer_surface->events.destroy, &subsurface->surface_destroy);
|
||||
|
||||
return subsurface;
|
||||
}
|
||||
|
|
@ -635,6 +649,8 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
|
|||
return;
|
||||
}
|
||||
|
||||
wl_signal_init(&sway_layer->events.destroy);
|
||||
|
||||
sway_layer->surface_commit.notify = handle_surface_commit;
|
||||
wl_signal_add(&layer_surface->surface->events.commit,
|
||||
&sway_layer->surface_commit);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue