[gtk+] container: Request layout again depending on layout mode



commit c3dc0d80f1353ac66882ca3288ca7e9a13c47d6f
Author: Benjamin Otte <otte redhat com>
Date:   Mon Feb 22 21:38:03 2016 +0100

    container: Request layout again depending on layout mode
    
    Containers with RESIZE_MODE_PARENT should never request layout and those
    with RESIZE_MODE_IMMEDIATE should only request it for updating CSS.
    
    Fixes clutter embeds (like the tray icon embed in gnome-shell)
    continuously requesting relayout when all they want to do is relegate
    relayout to Clutter.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=758893

 gtk/gtkcontainer.c |   26 +++++++++++++++++++-------
 1 files changed, 19 insertions(+), 7 deletions(-)
---
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c
index 69ffbd7..01dbbcb 100644
--- a/gtk/gtkcontainer.c
+++ b/gtk/gtkcontainer.c
@@ -2000,6 +2000,23 @@ gtk_container_set_reallocate_redraws (GtkContainer *container,
   container->priv->reallocate_redraws = needs_redraws ? TRUE : FALSE;
 }
 
+static gboolean
+gtk_container_needs_idle_sizer (GtkContainer *container)
+{
+  GtkContainerPrivate *priv = container->priv;
+
+  if (priv->resize_mode == GTK_RESIZE_PARENT)
+    return FALSE;
+
+  if (container->priv->restyle_pending)
+    return TRUE;
+
+  if (priv->resize_mode == GTK_RESIZE_IMMEDIATE)
+    return FALSE;
+
+  return gtk_widget_needs_allocate (GTK_WIDGET (container));
+}
+
 static void
 gtk_container_idle_sizer (GdkFrameClock *clock,
                          GtkContainer  *container)
@@ -2031,7 +2048,7 @@ gtk_container_idle_sizer (GdkFrameClock *clock,
       gtk_container_check_resize (container);
     }
 
-  if (!container->priv->restyle_pending && !gtk_widget_needs_allocate (GTK_WIDGET (container)))
+  if (!gtk_container_needs_idle_sizer (container))
     {
       _gtk_container_stop_idle_sizer (container);
     }
@@ -2126,12 +2143,7 @@ _gtk_container_queue_restyle (GtkContainer *container)
 void
 _gtk_container_maybe_start_idle_sizer (GtkContainer *container)
 {
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-  if (!GTK_IS_RESIZE_CONTAINER (container))
-    return;
-G_GNUC_END_IGNORE_DEPRECATIONS;
-
-  if (container->priv->restyle_pending || gtk_widget_needs_allocate (GTK_WIDGET (container)))
+  if (gtk_container_needs_idle_sizer (container))
     gtk_container_start_idle_sizer (container);
 }
 


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