[gtk/wip/matthiasc/popup5: 163/186] gdk: Maintain popup tree in the frontend



commit dc746e1fb25d3d2f34d8596e1539d7bdbe3e7c65
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed May 22 22:04:45 2019 +0000

    gdk: Maintain popup tree in the frontend
    
    We will need this information here, and we can
    share the child lists between various backends.

 gdk/broadway/gdksurface-broadway.c | 17 +----------------
 gdk/broadway/gdksurface-broadway.h |  2 --
 gdk/gdksurface.c                   |  9 ++++++++-
 gdk/gdksurfaceprivate.h            |  1 +
 gdk/x11/gdksurface-x11.c           | 17 +----------------
 gdk/x11/gdksurface-x11.h           |  2 --
 6 files changed, 11 insertions(+), 37 deletions(-)
---
diff --git a/gdk/broadway/gdksurface-broadway.c b/gdk/broadway/gdksurface-broadway.c
index 6c3af4c95a..d8a0ffb44c 100644
--- a/gdk/broadway/gdksurface-broadway.c
+++ b/gdk/broadway/gdksurface-broadway.c
@@ -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);
diff --git a/gdk/broadway/gdksurface-broadway.h b/gdk/broadway/gdksurface-broadway.h
index 4c47a887a6..b2940f2b08 100644
--- a/gdk/broadway/gdksurface-broadway.h
+++ b/gdk/broadway/gdksurface-broadway.h
@@ -63,8 +63,6 @@ struct _GdkBroadwaySurface
 
   int offset_x;
   int offset_y;
-
-  GList *popups;
 };
 
 struct _GdkBroadwaySurfaceClass
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index 281ac8b034..7db9f2cc8d 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -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);
 
diff --git a/gdk/gdksurfaceprivate.h b/gdk/gdksurfaceprivate.h
index c7933fe0f2..ce81b23a84 100644
--- a/gdk/gdksurfaceprivate.h
+++ b/gdk/gdksurfaceprivate.h
@@ -34,6 +34,7 @@ struct _GdkSurface
 
   GdkSurface *transient_for; /* for toplevels */
   GdkSurface *parent;        /* for popups */
+  GList *children;           /* popups */
 
   gpointer widget;
 
diff --git a/gdk/x11/gdksurface-x11.c b/gdk/x11/gdksurface-x11.c
index dc12f44f0a..afdb6c243b 100644
--- a/gdk/x11/gdksurface-x11.c
+++ b/gdk/x11/gdksurface-x11.c
@@ -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);
diff --git a/gdk/x11/gdksurface-x11.h b/gdk/x11/gdksurface-x11.h
index c051d10d82..6c6744a71d 100644
--- a/gdk/x11/gdksurface-x11.h
+++ b/gdk/x11/gdksurface-x11.h
@@ -78,8 +78,6 @@ struct _GdkX11Surface
 
   int offset_x;
   int offset_y;
-
-  GList *popups;
 };
  
 struct _GdkX11SurfaceClass 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]