wayland: Let the popup surface explicitly dismiss the popup

Instead of relying on destroy signals attached to the corresponding
role object, let the roles explicitly dismiss the popup when it should
be dismissed.

https://bugzilla.gnome.org/show_bug.cgi?id=763431
This commit is contained in:
Jonas Ådahl 2016-01-21 17:03:16 +08:00
parent 229a143eac
commit 61c717abb3
2 changed files with 14 additions and 24 deletions

View File

@ -62,7 +62,6 @@ struct _MetaWaylandPopupGrab
struct _MetaWaylandPopup
{
MetaWaylandPopupGrab *grab;
struct wl_listener surface_destroy_listener;
MetaWaylandPopupSurface *popup_surface;
struct wl_list link;
};
@ -231,7 +230,6 @@ meta_wayland_popup_destroy (MetaWaylandPopup *popup)
{
meta_wayland_popup_surface_dismiss (popup->popup_surface);
wl_list_remove (&popup->surface_destroy_listener.link);
wl_list_remove (&popup->link);
g_slice_free (MetaWaylandPopup, popup);
}
@ -253,16 +251,6 @@ meta_wayland_popup_get_top_popup (MetaWaylandPopup *popup)
return meta_wayland_popup_grab_get_top_popup (popup->grab);
}
static void
on_popup_surface_destroy (struct wl_listener *listener,
void *data)
{
MetaWaylandPopup *popup =
wl_container_of (listener, popup, surface_destroy_listener);
meta_wayland_popup_dismiss (popup);
}
MetaWaylandPopup *
meta_wayland_popup_create (MetaWaylandPopupSurface *popup_surface,
MetaWaylandPopupGrab *grab)
@ -278,17 +266,6 @@ meta_wayland_popup_create (MetaWaylandPopupSurface *popup_surface,
popup = g_slice_new0 (MetaWaylandPopup);
popup->grab = grab;
popup->popup_surface = popup_surface;
popup->surface_destroy_listener.notify = on_popup_surface_destroy;
if (surface->xdg_popup)
{
wl_resource_add_destroy_listener (surface->xdg_popup,
&popup->surface_destroy_listener);
}
else if (surface->wl_shell_surface)
{
wl_resource_add_destroy_listener (surface->wl_shell_surface,
&popup->surface_destroy_listener);
}
wl_list_insert (&grab->all_popups, &popup->link);

View File

@ -61,6 +61,9 @@ wl_shell_surface_destructor (struct wl_resource *resource)
meta_wayland_compositor_destroy_frame_callbacks (surface->compositor,
surface);
if (surface->popup.popup)
meta_wayland_popup_dismiss (surface->popup.popup);
for (l = surface->wl_shell.children; l; l = l->next)
{
MetaWaylandSurface *child_surface = l->data;
@ -168,6 +171,13 @@ wl_shell_surface_set_state (MetaWaylandSurface *surface,
if (surface->window && old_state != state)
{
if (old_state == META_WL_SHELL_SURFACE_STATE_POPUP &&
surface->popup.popup)
{
meta_wayland_popup_dismiss (surface->popup.popup);
surface->popup.popup = NULL;
}
if (state == META_WL_SHELL_SURFACE_STATE_FULLSCREEN)
meta_window_make_fullscreen (surface->window);
else
@ -498,7 +508,10 @@ wl_shell_surface_role_commit (MetaWaylandSurfaceRole *surface_role,
}
else if (!surface->buffer_ref.buffer && window)
{
meta_wayland_surface_destroy_window (surface);
if (surface->popup.popup)
meta_wayland_popup_dismiss (surface->popup.popup);
else
meta_wayland_surface_destroy_window (surface);
return;
}