From 544146b9be4078009c35695b1744431c98a81a40 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 15 Dec 2010 10:33:02 +0100 Subject: [PATCH] size-request: Clamp size requests to screen size Size requests should only ever need to return the screen's width/height and max. This way, potentially large widgets (tree view or icon view) don't need to do so many computations, but can stop when their computed size has reached the screen size. --- gtk/gtksizerequest.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gtk/gtksizerequest.c b/gtk/gtksizerequest.c index c5e49e7db3..41ec2599f4 100644 --- a/gtk/gtksizerequest.c +++ b/gtk/gtksizerequest.c @@ -239,6 +239,14 @@ compute_size_for_orientation (GtkWidget *widget, &min_size, &nat_size); pop_recursion_check (widget, orientation); } +#ifndef G_DISABLE_CHECKS + if (gtk_widget_get_screen (widget)) + { + guint screen_width = gdk_screen_get_width (gtk_widget_get_screen (widget)); + min_size = MIN (min_size, screen_width); + nat_size = MIN (nat_size, screen_width); + } +#endif } else { @@ -272,6 +280,14 @@ compute_size_for_orientation (GtkWidget *widget, &min_size, &nat_size); pop_recursion_check (widget, orientation); } +#ifndef G_DISABLE_CHECKS + if (gtk_widget_get_screen (widget)) + { + guint screen_height = gdk_screen_get_height (gtk_widget_get_screen (widget)); + min_size = MIN (min_size, screen_height); + nat_size = MIN (nat_size, screen_height); + } +#endif } if (min_size > nat_size)