summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <RyanDwyer@users.noreply.github.com>2018-11-28 20:46:22 +1000
committerLibravatar GitHub <noreply@github.com>2018-11-28 20:46:22 +1000
commitf737854e307a3cfeaba43f5ff18d540c23c65fa5 (patch)
tree36829a49e6ee1a90b07ddbf10554650e234c6c05
parentMerge pull request #3207 from RedSoxFan/swaynag-no-term-buttons (diff)
parentDamage view child when destroyed (diff)
downloadsway-f737854e307a3cfeaba43f5ff18d540c23c65fa5.tar.gz
sway-f737854e307a3cfeaba43f5ff18d540c23c65fa5.tar.zst
sway-f737854e307a3cfeaba43f5ff18d540c23c65fa5.zip
Merge pull request #3199 from emersion/handle-subsurface-destroy
Handle destroyed subsurfaces
-rw-r--r--include/sway/tree/view.h6
-rw-r--r--sway/tree/view.c40
2 files changed, 42 insertions, 4 deletions
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h
index 4716c688..d74f1bc9 100644
--- a/include/sway/tree/view.h
+++ b/include/sway/tree/view.h
@@ -203,6 +203,12 @@ struct sway_view_child {
203 struct wl_listener surface_destroy; 203 struct wl_listener surface_destroy;
204}; 204};
205 205
206struct sway_subsurface {
207 struct sway_view_child child;
208
209 struct wl_listener destroy;
210};
211
206struct sway_xdg_popup_v6 { 212struct sway_xdg_popup_v6 {
207 struct sway_view_child child; 213 struct sway_view_child child;
208 214
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 511c2ecc..0edefc8e 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -679,6 +679,8 @@ void view_update_size(struct sway_view *view, int width, int height) {
679 container_set_geometry_from_content(view->container); 679 container_set_geometry_from_content(view->container);
680} 680}
681 681
682static const struct sway_view_child_impl subsurface_impl;
683
682static void subsurface_get_root_coords(struct sway_view_child *child, 684static void subsurface_get_root_coords(struct sway_view_child *child,
683 int *root_sx, int *root_sy) { 685 int *root_sx, int *root_sy) {
684 struct wlr_surface *surface = child->surface; 686 struct wlr_surface *surface = child->surface;
@@ -694,18 +696,44 @@ static void subsurface_get_root_coords(struct sway_view_child *child,
694 } 696 }
695} 697}
696 698
699static void subsurface_destroy(struct sway_view_child *child) {
700 if (!sway_assert(child->impl == &subsurface_impl,
701 "Expected a subsurface")) {
702 return;
703 }
704 struct sway_subsurface *subsurface = (struct sway_subsurface *)child;
705 wl_list_remove(&subsurface->destroy.link);
706 free(subsurface);
707}
708
697static const struct sway_view_child_impl subsurface_impl = { 709static const struct sway_view_child_impl subsurface_impl = {
698 .get_root_coords = subsurface_get_root_coords, 710 .get_root_coords = subsurface_get_root_coords,
711 .destroy = subsurface_destroy,
699}; 712};
700 713
714static void view_child_damage(struct sway_view_child *child, bool whole);
715
716static void subsurface_handle_destroy(struct wl_listener *listener,
717 void *data) {
718 struct sway_subsurface *subsurface =
719 wl_container_of(listener, subsurface, destroy);
720 struct sway_view_child *child = &subsurface->child;
721 view_child_destroy(child);
722}
723
701static void view_subsurface_create(struct sway_view *view, 724static void view_subsurface_create(struct sway_view *view,
702 struct wlr_subsurface *subsurface) { 725 struct wlr_subsurface *wlr_subsurface) {
703 struct sway_view_child *child = calloc(1, sizeof(struct sway_view_child)); 726 struct sway_subsurface *subsurface =
704 if (child == NULL) { 727 calloc(1, sizeof(struct sway_subsurface));
728 if (subsurface == NULL) {
705 wlr_log(WLR_ERROR, "Allocation failed"); 729 wlr_log(WLR_ERROR, "Allocation failed");
706 return; 730 return;
707 } 731 }
708 view_child_init(child, &subsurface_impl, view, subsurface->surface); 732 view_child_init(&subsurface->child, &subsurface_impl, view,
733 wlr_subsurface->surface);
734
735 wl_signal_add(&wlr_subsurface->events.destroy, &subsurface->destroy);
736 subsurface->destroy.notify = subsurface_handle_destroy;
709} 737}
710 738
711static void view_child_damage(struct sway_view_child *child, bool whole) { 739static void view_child_damage(struct sway_view_child *child, bool whole) {
@@ -786,6 +814,10 @@ void view_child_init(struct sway_view_child *child,
786} 814}
787 815
788void view_child_destroy(struct sway_view_child *child) { 816void view_child_destroy(struct sway_view_child *child) {
817 if (child->view->container != NULL) {
818 view_child_damage(child, true);
819 }
820
789 wl_list_remove(&child->surface_commit.link); 821 wl_list_remove(&child->surface_commit.link);
790 wl_list_remove(&child->surface_destroy.link); 822 wl_list_remove(&child->surface_destroy.link);
791 823