Merge pull request #1530 from emersion/unmap-destroy-popups

xdg-shell: destroy child popups on unmap
This commit is contained in:
Drew DeVault 2019-02-05 20:24:12 +01:00 committed by GitHub
commit 8cf7aa3bbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 19 deletions

View File

@ -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); 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_popup_grab *get_xdg_shell_popup_grab_from_seat(
struct wlr_xdg_shell *shell, struct wlr_seat *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, void create_xdg_toplevel(struct wlr_xdg_surface *xdg_surface,
uint32_t id); uint32_t id);

View File

@ -210,9 +210,12 @@ static const struct xdg_popup_interface xdg_popup_implementation = {
}; };
static void xdg_popup_handle_resource_destroy(struct wl_resource *resource) { 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); 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 = { 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, void wlr_xdg_popup_get_anchor_point(struct wlr_xdg_popup *popup,
int *root_sx, int *root_sy) { int *root_sx, int *root_sy) {
struct wlr_box rect = popup->positioner.anchor_rect; struct wlr_box rect = popup->positioner.anchor_rect;

View File

@ -29,6 +29,11 @@ static void xdg_surface_configure_destroy(
void unmap_xdg_surface(struct wlr_xdg_surface *surface) { void unmap_xdg_surface(struct wlr_xdg_surface *surface) {
assert(surface->role != WLR_XDG_SURFACE_ROLE_NONE); 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 // TODO: probably need to ungrab before this event
if (surface->mapped) { if (surface->mapped) {
wlr_signal_emit_safe(&surface->events.unmap, surface); 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) { void destroy_xdg_surface(struct wlr_xdg_surface *surface) {
reset_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); wl_resource_set_user_data(surface->resource, NULL);
surface->surface->role_data = 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->popup);
assert(surface->role == WLR_XDG_SURFACE_ROLE_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); xdg_popup_send_popup_done(surface->popup->resource);
wl_resource_set_user_data(surface->popup->resource, NULL); 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, static void xdg_popup_get_position(struct wlr_xdg_popup *popup,