[gtk+/gtk-3-22] Expander: Also hide child GdkWindow when collapsed



commit 32553ad3a2068be6d099d9a045c0403b799c2700
Author: Daniel Boles <dboles src gnome org>
Date:   Thu Aug 24 21:05:00 2017 +0100

    Expander: Also hide child GdkWindow when collapsed
    
    Just adding/removing to/from the BoxGadget is not sufficient; that
    leaves the GdkWindow hanging around, taking input, changing the cursor,
    and all sorts of other nefarious shenanigans.
    
    Resolve by ensuring the child’s GdkWindow is unmapped if collapsed.
    
    Note: the reflexive solution is just to set_visible(child, expanded),
    but it is best to avoid messing with the child’s :visible property.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=776937

 gtk/gtkexpander.c |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkexpander.c b/gtk/gtkexpander.c
index ad84d5f..89f7582 100644
--- a/gtk/gtkexpander.c
+++ b/gtk/gtkexpander.c
@@ -1089,6 +1089,26 @@ gtk_expander_focus (GtkWidget        *widget,
 }
 
 static void
+gtk_expander_update_child_mapped (GtkExpander *expander,
+                                  GtkWidget   *child)
+{
+  /* If collapsing, we must unmap the child, as gtk_box_gadget_remove() does
+   * not, so otherwise the child is not drawn but still consumes input in-place.
+   */
+
+  if (expander->priv->expanded &&
+      gtk_widget_get_realized (child) &&
+      gtk_widget_get_visible (child))
+    {
+      gtk_widget_map (child);
+    }
+  else
+    {
+      gtk_widget_unmap (child);
+    }
+}
+
+static void
 gtk_expander_add (GtkContainer *container,
                   GtkWidget    *widget)
 {
@@ -1100,6 +1120,8 @@ gtk_expander_add (GtkContainer *container,
 
   if (expander->priv->expanded)
     gtk_box_gadget_insert_widget (GTK_BOX_GADGET (expander->priv->gadget), -1, widget);
+
+  gtk_expander_update_child_mapped (expander, widget);
 }
 
 static void
@@ -1274,6 +1296,8 @@ gtk_expander_set_expanded (GtkExpander *expander,
 
       gtk_widget_queue_resize (GTK_WIDGET (expander));
       gtk_expander_resize_toplevel (expander);
+
+      gtk_expander_update_child_mapped (expander, child);
     }
 
   g_object_notify (G_OBJECT (expander), "expanded");


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