gdk: Maintain popup tree in the frontend

We will need this information here, and we can
share the child lists between various backends.
This commit is contained in:
Matthias Clasen 2019-05-22 22:04:45 +00:00
parent 44be64278b
commit 3d283cc8f4
6 changed files with 11 additions and 37 deletions

View File

@ -66,21 +66,13 @@ gdk_broadway_surface_init (GdkBroadwaySurface *impl)
static void
gdk_broadway_surface_finalize (GObject *object)
{
GdkSurface *surface;
GdkBroadwaySurface *impl;
GdkBroadwayDisplay *broadway_display;
g_return_if_fail (GDK_IS_BROADWAY_SURFACE (object));
surface = GDK_SURFACE (object);
impl = GDK_BROADWAY_SURFACE (object);
if (surface->parent)
{
GdkBroadwaySurface *parent_impl = GDK_BROADWAY_SURFACE (surface->parent);
parent_impl->popups = g_list_remove (parent_impl->popups, surface);
}
_gdk_broadway_surface_grab_check_destroy (GDK_SURFACE (impl));
broadway_display = GDK_BROADWAY_DISPLAY (gdk_surface_get_display (GDK_SURFACE (impl)));
@ -238,12 +230,6 @@ _gdk_broadway_display_create_surface (GdkDisplay *display,
connect_frame_clock (surface);
if (parent)
{
GdkBroadwaySurface *parent_impl = GDK_BROADWAY_SURFACE (parent);
parent_impl->popups = g_list_prepend (parent_impl->popups, surface);
}
return surface;
}
@ -818,10 +804,9 @@ gdk_broadway_surface_set_functions (GdkSurface *surface,
void
gdk_broadway_surface_update_popups (GdkSurface *parent)
{
GdkBroadwaySurface *impl = GDK_BROADWAY_SURFACE (parent);
GList *l;
for (l = impl->popups; l; l = l->next)
for (l = parent ->children; l; l = l->next)
{
GdkBroadwaySurface *popup_impl = l->data;
GdkSurface *popup = GDK_SURFACE (popup_impl);

View File

@ -63,8 +63,6 @@ struct _GdkBroadwaySurface
int offset_x;
int offset_y;
GList *popups;
};
struct _GdkBroadwaySurfaceClass

View File

@ -90,7 +90,7 @@ enum {
/* Global info */
static void gdk_surface_finalize (GObject *object);
static void gdk_surface_finalize (GObject *object);
static void gdk_surface_set_property (GObject *object,
guint prop_id,
@ -633,6 +633,9 @@ gdk_surface_finalize (GObject *object)
if (surface->opaque_region)
cairo_region_destroy (surface->opaque_region);
if (surface->parent)
surface->parent->children = g_list_remove (surface->parent->children, surface);
G_OBJECT_CLASS (gdk_surface_parent_class)->finalize (object);
}
@ -750,6 +753,10 @@ gdk_surface_new (GdkDisplay *display,
parent,
x, y, width, height);
surface->parent = parent;
if (parent)
parent->children = g_list_prepend (parent->children, surface);
g_signal_connect (display, "seat-removed",
G_CALLBACK (seat_removed_cb), surface);

View File

@ -34,6 +34,7 @@ struct _GdkSurface
GdkSurface *transient_for; /* for toplevels */
GdkSurface *parent; /* for popups */
GList *children; /* popups */
gpointer widget;

View File

@ -425,20 +425,12 @@ gdk_x11_surface_end_frame (GdkSurface *surface)
static void
gdk_x11_surface_finalize (GObject *object)
{
GdkSurface *surface;
GdkX11Surface *impl;
g_return_if_fail (GDK_IS_X11_SURFACE (object));
surface = GDK_SURFACE (object);
impl = GDK_X11_SURFACE (object);
if (surface->parent)
{
GdkX11Surface *parent_impl = GDK_X11_SURFACE (surface->parent);
parent_impl->popups = g_list_remove (parent_impl->popups, surface);
}
if (impl->toplevel->in_frame)
unhook_surface_changed (GDK_SURFACE (impl));
@ -916,12 +908,6 @@ _gdk_x11_display_create_surface (GdkDisplay *display,
gdk_surface_freeze_updates (surface);
if (parent)
{
GdkX11Surface *parent_impl = GDK_X11_SURFACE (parent);
parent_impl->popups = g_list_prepend (parent_impl->popups, surface);
}
return surface;
}
@ -1383,10 +1369,9 @@ static void gdk_x11_surface_restack_toplevel (GdkSurface *surface,
void
gdk_x11_surface_update_popups (GdkSurface *parent)
{
GdkX11Surface *impl = GDK_X11_SURFACE (parent);
GList *l;
for (l = impl->popups; l; l = l->next)
for (l = parent->children; l; l = l->next)
{
GdkX11Surface *popup_impl = l->data;
GdkSurface *popup = GDK_SURFACE (popup_impl);

View File

@ -78,8 +78,6 @@ struct _GdkX11Surface
int offset_x;
int offset_y;
GList *popups;
};
struct _GdkX11SurfaceClass