[gtk] window: Properly detect if size allocation is needed



commit 2ba928e14263f06693baaf6434b198ab2a44e9d1
Author: Benjamin Otte <otte redhat com>
Date:   Tue Feb 12 02:20:36 2019 +0100

    window: Properly detect if size allocation is needed
    
    Instead of looking at the allocation, just look at the alloc_needed
    widget flag that tracks if an allocation is needed.

 gtk/gtkwindow.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index db108c8a2d..b101fc7376 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -6385,13 +6385,8 @@ gtk_window_realize (GtkWidget *widget)
   if (!priv->client_decorated && gtk_window_should_use_csd (window))
     create_decoration (widget);
 
-  _gtk_widget_get_allocation (widget, &allocation);
-
   /* ensure widget tree is properly size allocated */
-  if (allocation.x == -1 &&
-      allocation.y == -1 &&
-      allocation.width == 1 &&
-      allocation.height == 1)
+  if (_gtk_widget_get_alloc_needed (widget))
     {
       GdkRectangle request;
 
@@ -6408,16 +6403,15 @@ gtk_window_realize (GtkWidget *widget)
       g_return_if_fail (!_gtk_widget_get_realized (widget));
     }
 
+  _gtk_widget_get_allocation (widget, &allocation);
+
   if (priv->hardcoded_surface)
     {
       surface = priv->hardcoded_surface;
-      _gtk_widget_get_allocation (widget, &allocation);
       gdk_surface_resize (surface, allocation.width, allocation.height);
     }
   else
     {
-      _gtk_widget_get_allocation (widget, &allocation);
-
       switch (priv->type)
         {
         case GTK_WINDOW_TOPLEVEL:


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