[gedit] overlay: make sure not to request negative allocations



commit a5337af7ee9f1aeb57ea274e8bf0c2c77203312b
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Thu Feb 24 21:00:40 2011 -0500

    overlay: make sure not to request negative allocations
    
    Or to allocate a child more than the available overall allocation.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=643258

 gedit/gedit-overlay.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/gedit/gedit-overlay.c b/gedit/gedit-overlay.c
index 380f108..7e90e4c 100644
--- a/gedit/gedit-overlay.c
+++ b/gedit/gedit-overlay.c
@@ -219,7 +219,7 @@ gedit_overlay_size_allocate (GtkWidget     *widget,
 		{
 			/* The gravity is treated as position and not as a gravity */
 			case GEDIT_OVERLAY_CHILD_POSITION_NORTH_EAST:
-				alloc.x = main_alloc.width - req.width - offset;
+				alloc.x = MAX (main_alloc.x, main_alloc.width - req.width - (gint) offset);
 				alloc.y = 0;
 				break;
 			case GEDIT_OVERLAY_CHILD_POSITION_NORTH_WEST:
@@ -228,19 +228,19 @@ gedit_overlay_size_allocate (GtkWidget     *widget,
 				break;
 			case GEDIT_OVERLAY_CHILD_POSITION_SOUTH_WEST:
 				alloc.x = offset;
-				alloc.y = main_alloc.height - req.height;
+				alloc.y = MAX (main_alloc.y, main_alloc.height - req.height);
 				break;
 			case GEDIT_OVERLAY_CHILD_POSITION_SOUTH_EAST:
-				alloc.x = main_alloc.width - req.width - offset;
-				alloc.y = main_alloc.height - req.height;
+				alloc.x = MAX (main_alloc.x, main_alloc.width - req.width - (gint) offset);
+				alloc.y = MAX (main_alloc.y, main_alloc.height - req.height);
 				break;
 			default:
 				alloc.x = 0;
 				alloc.y = 0;
 		}
 
-		alloc.width = req.width;
-		alloc.height = req.height;
+		alloc.width = MIN (main_alloc.width, req.width);
+		alloc.height = MIN (main_alloc.height, req.height);
 
 		gtk_widget_size_allocate (child, &alloc);
 	}



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