[gtk+/popovers: 23/26] window: Keep track of popover children mapped status



commit 28b06335127b8651d4d2de57cbfef6cd1e4fc501
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Dec 23 19:05:33 2013 +0100

    window: Keep track of popover children mapped status
    
    In order to maintain visibility of the GdkWindow that's the parent window
    of the popover widget.

 gtk/gtkwindow.c |   43 ++++++++++++++++++++++++++++++-------------
 1 files changed, 30 insertions(+), 13 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index b1c3bf3..7882223 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -131,6 +131,7 @@ struct _GtkWindowPopover
   GdkWindow *window;
   GtkPositionType pos;
   cairo_rectangle_int_t rect;
+  gulong unmap_id;
 };
 
 struct _GtkWindowPrivate
@@ -1285,6 +1286,12 @@ gtk_window_close (GtkWindow *window)
 static void
 popover_destroy (GtkWindowPopover *popover)
 {
+  if (popover->unmap_id)
+    {
+      g_signal_handler_disconnect (popover->widget, popover->unmap_id);
+      popover->unmap_id = 0;
+    }
+
   if (popover->widget && gtk_widget_get_parent (popover->widget))
     gtk_widget_unparent (popover->widget);
 
@@ -5369,6 +5376,24 @@ gtk_window_hide (GtkWidget *widget)
 }
 
 static void
+popover_unmap (GtkWidget        *widget,
+               GtkWindowPopover *popover)
+{
+  if (popover->window)
+    {
+      if (gtk_widget_is_visible (popover->widget))
+        gtk_widget_unmap (popover->widget);
+      gdk_window_hide (popover->window);
+    }
+
+  if (popover->unmap_id)
+    {
+      g_signal_handler_disconnect (widget, popover->unmap_id);
+      popover->unmap_id = 0;
+    }
+}
+
+static void
 popover_map (GtkWidget        *widget,
              GtkWindowPopover *popover)
 {
@@ -5377,7 +5402,11 @@ popover_map (GtkWidget        *widget,
       gdk_window_show (popover->window);
 
       if (gtk_widget_get_visible (popover->widget))
-        gtk_widget_map (popover->widget);
+        {
+          gtk_widget_map (popover->widget);
+          popover->unmap_id = g_signal_connect (popover->widget, "unmap",
+                                                G_CALLBACK (popover_unmap), popover);
+        }
     }
 }
 
@@ -5517,18 +5546,6 @@ gtk_window_map_event (GtkWidget   *widget,
 }
 
 static void
-popover_unmap (GtkWidget        *widget,
-               GtkWindowPopover *popover)
-{
-  if (popover->window)
-    {
-      if (gtk_widget_is_visible (popover->widget))
-        gtk_widget_unmap (popover->widget);
-      gdk_window_hide (popover->window);
-    }
-}
-
-static void
 gtk_window_unmap (GtkWidget *widget)
 {
   GtkWindow *window = GTK_WINDOW (widget);


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