[gtk+] Fixed expressions in gtk_button_size_allocate()



commit 9ddef2365fe6785b2ed37dc20707fd86e194db25
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Sat Aug 7 17:41:29 2010 -0400

    Fixed expressions in gtk_button_size_allocate()
    
    Children were getting negative allocations by misusage
    of MAX() macro (bad signedness of expressions).

 gtk/gtkbutton.c |   34 ++++++++++++++++++++--------------
 1 files changed, 20 insertions(+), 14 deletions(-)
---
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c
index 9b2f475..e9527c1 100644
--- a/gtk/gtkbutton.c
+++ b/gtk/gtkbutton.c
@@ -1476,31 +1476,34 @@ gtk_button_size_allocate (GtkWidget     *widget,
       child_allocation.x = widget->allocation.x + border_width + inner_border.left + xthickness;
       child_allocation.y = widget->allocation.y + border_width + inner_border.top + ythickness;
       
-      child_allocation.width = MAX (1, widget->allocation.width -
-                                    xthickness * 2 -
-                                    inner_border.left -
-                                    inner_border.right -
-				    border_width * 2);
-      child_allocation.height = MAX (1, widget->allocation.height -
-                                     ythickness * 2 -
-                                     inner_border.top -
-                                     inner_border.bottom -
-				     border_width * 2);
+      child_allocation.width = 
+	widget->allocation.width -
+	xthickness * 2 -
+	inner_border.left -
+	inner_border.right -
+	border_width * 2;
+
+      child_allocation.height = 
+	widget->allocation.height -
+	ythickness * 2 -
+	inner_border.top -
+	inner_border.bottom -
+	border_width * 2;
 
       if (gtk_widget_get_can_default (GTK_WIDGET (button)))
 	{
 	  child_allocation.x += default_border.left;
 	  child_allocation.y += default_border.top;
-	  child_allocation.width =  MAX (1, child_allocation.width - default_border.left - default_border.right);
-	  child_allocation.height = MAX (1, child_allocation.height - default_border.top - default_border.bottom);
+	  child_allocation.width =  child_allocation.width - default_border.left - default_border.right;
+	  child_allocation.height = child_allocation.height - default_border.top - default_border.bottom;
 	}
 
       if (gtk_widget_get_can_focus (GTK_WIDGET (button)))
 	{
 	  child_allocation.x += focus_width + focus_pad;
 	  child_allocation.y += focus_width + focus_pad;
-	  child_allocation.width =  MAX (1, child_allocation.width - (focus_width + focus_pad) * 2);
-	  child_allocation.height = MAX (1, child_allocation.height - (focus_width + focus_pad) * 2);
+	  child_allocation.width =  child_allocation.width - (focus_width + focus_pad) * 2;
+	  child_allocation.height = child_allocation.height - (focus_width + focus_pad) * 2;
 	}
 
       if (button->depressed)
@@ -1516,6 +1519,9 @@ gtk_button_size_allocate (GtkWidget     *widget,
 	  child_allocation.y += child_displacement_y;
 	}
 
+      child_allocation.width  = MAX (1, child_allocation.width);
+      child_allocation.height = MAX (1, child_allocation.height);
+
       gtk_widget_size_allocate (child, &child_allocation);
     }
 }



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