diff options
author | Simon Ser <contact@emersion.fr> | 2021-12-23 12:09:14 +0100 |
---|---|---|
committer | Ronan Pigott <rpigott@berkeley.edu> | 2022-01-08 19:07:27 -0700 |
commit | e2b4c573d6506250c77f01512bc07c72996cd363 (patch) | |
tree | 3c08682501f53da4228927e288873c153033b89e | |
parent | commands/move: Fix crash when pos_y is omitted (diff) | |
download | sway-e2b4c573d6506250c77f01512bc07c72996cd363.tar.gz sway-e2b4c573d6506250c77f01512bc07c72996cd363.tar.zst sway-e2b4c573d6506250c77f01512bc07c72996cd363.zip |
Destroy sub-surfaces with parent layer-shell surface
Closes: https://github.com/swaywm/sway/issues/6337
-rw-r--r-- | include/sway/layers.h | 3 | ||||
-rw-r--r-- | sway/desktop/layer_shell.c | 25 |
2 files changed, 23 insertions, 5 deletions
diff --git a/include/sway/layers.h b/include/sway/layers.h index 224dc5e6..14816861 100644 --- a/include/sway/layers.h +++ b/include/sway/layers.h | |||
@@ -25,6 +25,8 @@ struct sway_layer_surface { | |||
25 | bool mapped; | 25 | bool mapped; |
26 | struct wlr_box extent; | 26 | struct wlr_box extent; |
27 | enum zwlr_layer_shell_v1_layer layer; | 27 | enum zwlr_layer_shell_v1_layer layer; |
28 | |||
29 | struct wl_list subsurfaces; | ||
28 | }; | 30 | }; |
29 | 31 | ||
30 | struct sway_layer_popup { | 32 | struct sway_layer_popup { |
@@ -44,6 +46,7 @@ struct sway_layer_popup { | |||
44 | struct sway_layer_subsurface { | 46 | struct sway_layer_subsurface { |
45 | struct wlr_subsurface *wlr_subsurface; | 47 | struct wlr_subsurface *wlr_subsurface; |
46 | struct sway_layer_surface *layer_surface; | 48 | struct sway_layer_surface *layer_surface; |
49 | struct wl_list link; | ||
47 | 50 | ||
48 | struct wl_listener map; | 51 | struct wl_listener map; |
49 | struct wl_listener unmap; | 52 | struct wl_listener unmap; |
diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c index da59016d..27e457f1 100644 --- a/sway/desktop/layer_shell.c +++ b/sway/desktop/layer_shell.c | |||
@@ -352,6 +352,8 @@ static void unmap(struct sway_layer_surface *sway_layer) { | |||
352 | sway_layer->layer_surface->surface, true); | 352 | sway_layer->layer_surface->surface, true); |
353 | } | 353 | } |
354 | 354 | ||
355 | static void layer_subsurface_destroy(struct sway_layer_subsurface *subsurface); | ||
356 | |||
355 | static void handle_destroy(struct wl_listener *listener, void *data) { | 357 | static void handle_destroy(struct wl_listener *listener, void *data) { |
356 | struct sway_layer_surface *sway_layer = | 358 | struct sway_layer_surface *sway_layer = |
357 | wl_container_of(listener, sway_layer, destroy); | 359 | wl_container_of(listener, sway_layer, destroy); |
@@ -360,6 +362,12 @@ static void handle_destroy(struct wl_listener *listener, void *data) { | |||
360 | if (sway_layer->layer_surface->mapped) { | 362 | if (sway_layer->layer_surface->mapped) { |
361 | unmap(sway_layer); | 363 | unmap(sway_layer); |
362 | } | 364 | } |
365 | |||
366 | struct sway_layer_subsurface *subsurface, *subsurface_tmp; | ||
367 | wl_list_for_each_safe(subsurface, subsurface_tmp, &sway_layer->subsurfaces, link) { | ||
368 | layer_subsurface_destroy(subsurface); | ||
369 | } | ||
370 | |||
363 | wl_list_remove(&sway_layer->link); | 371 | wl_list_remove(&sway_layer->link); |
364 | wl_list_remove(&sway_layer->destroy.link); | 372 | wl_list_remove(&sway_layer->destroy.link); |
365 | wl_list_remove(&sway_layer->map.link); | 373 | wl_list_remove(&sway_layer->map.link); |
@@ -428,11 +436,8 @@ static void subsurface_handle_commit(struct wl_listener *listener, void *data) { | |||
428 | subsurface_damage(subsurface, false); | 436 | subsurface_damage(subsurface, false); |
429 | } | 437 | } |
430 | 438 | ||
431 | static void subsurface_handle_destroy(struct wl_listener *listener, | 439 | static void layer_subsurface_destroy(struct sway_layer_subsurface *subsurface) { |
432 | void *data) { | 440 | wl_list_remove(&subsurface->link); |
433 | struct sway_layer_subsurface *subsurface = | ||
434 | wl_container_of(listener, subsurface, destroy); | ||
435 | |||
436 | wl_list_remove(&subsurface->map.link); | 441 | wl_list_remove(&subsurface->map.link); |
437 | wl_list_remove(&subsurface->unmap.link); | 442 | wl_list_remove(&subsurface->unmap.link); |
438 | wl_list_remove(&subsurface->destroy.link); | 443 | wl_list_remove(&subsurface->destroy.link); |
@@ -440,6 +445,13 @@ static void subsurface_handle_destroy(struct wl_listener *listener, | |||
440 | free(subsurface); | 445 | free(subsurface); |
441 | } | 446 | } |
442 | 447 | ||
448 | static void subsurface_handle_destroy(struct wl_listener *listener, | ||
449 | void *data) { | ||
450 | struct sway_layer_subsurface *subsurface = | ||
451 | wl_container_of(listener, subsurface, destroy); | ||
452 | layer_subsurface_destroy(subsurface); | ||
453 | } | ||
454 | |||
443 | static struct sway_layer_subsurface *create_subsurface( | 455 | static struct sway_layer_subsurface *create_subsurface( |
444 | struct wlr_subsurface *wlr_subsurface, | 456 | struct wlr_subsurface *wlr_subsurface, |
445 | struct sway_layer_surface *layer_surface) { | 457 | struct sway_layer_surface *layer_surface) { |
@@ -451,6 +463,7 @@ static struct sway_layer_subsurface *create_subsurface( | |||
451 | 463 | ||
452 | subsurface->wlr_subsurface = wlr_subsurface; | 464 | subsurface->wlr_subsurface = wlr_subsurface; |
453 | subsurface->layer_surface = layer_surface; | 465 | subsurface->layer_surface = layer_surface; |
466 | wl_list_insert(&layer_surface->subsurfaces, &subsurface->link); | ||
454 | 467 | ||
455 | subsurface->map.notify = subsurface_handle_map; | 468 | subsurface->map.notify = subsurface_handle_map; |
456 | wl_signal_add(&wlr_subsurface->events.map, &subsurface->map); | 469 | wl_signal_add(&wlr_subsurface->events.map, &subsurface->map); |
@@ -643,6 +656,8 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) { | |||
643 | return; | 656 | return; |
644 | } | 657 | } |
645 | 658 | ||
659 | wl_list_init(&sway_layer->subsurfaces); | ||
660 | |||
646 | sway_layer->surface_commit.notify = handle_surface_commit; | 661 | sway_layer->surface_commit.notify = handle_surface_commit; |
647 | wl_signal_add(&layer_surface->surface->events.commit, | 662 | wl_signal_add(&layer_surface->surface->events.commit, |
648 | &sway_layer->surface_commit); | 663 | &sway_layer->surface_commit); |