summaryrefslogtreecommitdiff
path: root/src/wayland/meta-wayland-surface.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/wayland/meta-wayland-surface.c')
-rw-r--r--src/wayland/meta-wayland-surface.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
index accec6a94..51bcf3817 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -1588,6 +1588,17 @@ wl_shell_surface_set_fullscreen (struct wl_client *client,
}
static void
+handle_wl_shell_popup_parent_destroyed (struct wl_listener *listener,
+ void *data)
+{
+ MetaWaylandSurface *surface =
+ wl_container_of (listener, surface, popup.parent_destroy_listener);
+
+ wl_list_remove (&surface->popup.parent_destroy_listener.link);
+ surface->popup.parent = NULL;
+}
+
+static void
wl_shell_surface_set_popup (struct wl_client *client,
struct wl_resource *resource,
struct wl_resource *seat_resource,
@@ -1615,6 +1626,15 @@ wl_shell_surface_set_popup (struct wl_client *client,
parent_surf->window->rect.y + y);
surface->window->placed = TRUE;
+ if (!surface->popup.parent)
+ {
+ surface->popup.parent = parent_surf;
+ surface->popup.parent_destroy_listener.notify =
+ handle_wl_shell_popup_parent_destroyed;
+ wl_resource_add_destroy_listener (parent_surf->resource,
+ &surface->popup.parent_destroy_listener);
+ }
+
meta_wayland_pointer_start_popup_grab (&seat->pointer, surface);
}
@@ -2229,9 +2249,14 @@ meta_wayland_surface_get_toplevel_window (MetaWaylandSurface *surface)
while (surface)
{
if (surface->window)
- return surface->window;
-
- surface = surface->sub.parent;
+ {
+ if (surface->popup.parent)
+ surface = surface->popup.parent;
+ else
+ return surface->window;
+ }
+ else
+ surface = surface->sub.parent;
}
return NULL;