mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-04 20:55:58 +01:00
xdg-shell: destroy child popups on unmap
It doesn't make sense to keep popups opened when unmapped. We also need to do so in wlr_xdg_popup_destroy so that popups are destroyed in the correct order.
This commit is contained in:
parent
b2f56ad4a8
commit
7f5967234c
3 changed files with 17 additions and 19 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue