aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-02-05 20:24:12 +0100
committerGitHub <noreply@github.com>2019-02-05 20:24:12 +0100
commit8cf7aa3bbec47a03687fb2b5d2ef406c10c11ec5 (patch)
tree3cbdada3dd457e72c23c18b7a85acc0c55264d5f
parentb2f56ad4a84229239f55a6e0235fa7b76a9b2feb (diff)
parent7f5967234c1bcd4a93252d8606bf0f5a647c7dfa (diff)
Merge pull request #1530 from emersion/unmap-destroy-popups
xdg-shell: destroy child popups on unmap
-rw-r--r--include/types/wlr_xdg_shell.h1
-rw-r--r--types/xdg_shell/wlr_xdg_popup.c16
-rw-r--r--types/xdg_shell/wlr_xdg_surface.c19
3 files changed, 17 insertions, 19 deletions
diff --git a/include/types/wlr_xdg_shell.h b/include/types/wlr_xdg_shell.h
index 08a691bd..93058530 100644
--- a/include/types/wlr_xdg_shell.h
+++ b/include/types/wlr_xdg_shell.h
@@ -33,7 +33,6 @@ void create_xdg_popup(struct wlr_xdg_surface *xdg_surface,
void handle_xdg_surface_popup_committed(struct wlr_xdg_surface *surface);
struct wlr_xdg_popup_grab *get_xdg_shell_popup_grab_from_seat(
struct wlr_xdg_shell *shell, struct wlr_seat *seat);
-void destroy_xdg_popup(struct wlr_xdg_surface *surface);
void create_xdg_toplevel(struct wlr_xdg_surface *xdg_surface,
uint32_t id);
diff --git a/types/xdg_shell/wlr_xdg_popup.c b/types/xdg_shell/wlr_xdg_popup.c
index b27a629e..4e4b9c5b 100644
--- a/types/xdg_shell/wlr_xdg_popup.c
+++ b/types/xdg_shell/wlr_xdg_popup.c
@@ -210,9 +210,12 @@ static const struct xdg_popup_interface xdg_popup_implementation = {
};
static void xdg_popup_handle_resource_destroy(struct wl_resource *resource) {
- struct wlr_xdg_surface *surface =
+ struct wlr_xdg_surface *xdg_surface =
wlr_xdg_surface_from_popup_resource(resource);
- destroy_xdg_popup(surface);
+ if (xdg_surface == NULL) {
+ return;
+ }
+ wlr_xdg_popup_destroy(xdg_surface);
}
const struct wlr_surface_role xdg_popup_surface_role = {
@@ -281,15 +284,6 @@ void create_xdg_popup(struct wlr_xdg_surface *xdg_surface,
}
}
-void destroy_xdg_popup(struct wlr_xdg_surface *xdg_surface) {
- if (xdg_surface == NULL) {
- return;
- }
- assert(xdg_surface->role == WLR_XDG_SURFACE_ROLE_POPUP ||
- xdg_surface->role == WLR_XDG_SURFACE_ROLE_NONE);
- reset_xdg_surface(xdg_surface);
-}
-
void wlr_xdg_popup_get_anchor_point(struct wlr_xdg_popup *popup,
int *root_sx, int *root_sy) {
struct wlr_box rect = popup->positioner.anchor_rect;
diff --git a/types/xdg_shell/wlr_xdg_surface.c b/types/xdg_shell/wlr_xdg_surface.c
index db3fc29a..ada5b419 100644
--- a/types/xdg_shell/wlr_xdg_surface.c
+++ b/types/xdg_shell/wlr_xdg_surface.c
@@ -29,6 +29,11 @@ static void xdg_surface_configure_destroy(
void unmap_xdg_surface(struct wlr_xdg_surface *surface) {
assert(surface->role != WLR_XDG_SURFACE_ROLE_NONE);
+ struct wlr_xdg_popup *popup, *popup_tmp;
+ wl_list_for_each_safe(popup, popup_tmp, &surface->popups, link) {
+ wlr_xdg_popup_destroy(popup->base);
+ }
+
// TODO: probably need to ungrab before this event
if (surface->mapped) {
wlr_signal_emit_safe(&surface->events.unmap, surface);
@@ -477,12 +482,6 @@ void reset_xdg_surface(struct wlr_xdg_surface *xdg_surface) {
void destroy_xdg_surface(struct wlr_xdg_surface *surface) {
reset_xdg_surface(surface);
- struct wlr_xdg_popup *popup_state, *next;
- wl_list_for_each_safe(popup_state, next, &surface->popups, link) {
- xdg_popup_send_popup_done(popup_state->resource);
- destroy_xdg_popup(popup_state->base);
- }
-
wl_resource_set_user_data(surface->resource, NULL);
surface->surface->role_data = NULL;
@@ -529,9 +528,15 @@ void wlr_xdg_popup_destroy(struct wlr_xdg_surface *surface) {
}
assert(surface->popup);
assert(surface->role == WLR_XDG_SURFACE_ROLE_POPUP);
+
+ struct wlr_xdg_popup *popup, *popup_tmp;
+ wl_list_for_each_safe(popup, popup_tmp, &surface->popups, link) {
+ wlr_xdg_popup_destroy(popup->base);
+ }
+
xdg_popup_send_popup_done(surface->popup->resource);
wl_resource_set_user_data(surface->popup->resource, NULL);
- destroy_xdg_popup(surface);
+ reset_xdg_surface(surface);
}
static void xdg_popup_get_position(struct wlr_xdg_popup *popup,