GtkWindow: some min/nat size corrections.

Don't add the container border to the title request size; it
is only used for the child widget.

Don't call gtk_widget_get_preferred_width_for_height() for
the title bar with an unrelated height and subtract the title
bar height before querying the child widget width.

Guard against negative size requests after substracting the
borders/shadows and the title bar.

https://bugzilla.gnome.org/show_bug.cgi?id=751341
This commit is contained in:
Christoph Reiter
2015-06-22 19:22:10 +02:00
committed by Christoph Reiter
parent f9422ab223
commit 48ea0cbe4b

View File

@ -8387,10 +8387,8 @@ gtk_window_get_preferred_width (GtkWidget *widget,
gtk_widget_get_preferred_width (priv->title_box, gtk_widget_get_preferred_width (priv->title_box,
&title_min, &title_nat); &title_min, &title_nat);
title_min += border_width * 2 + title_min += window_border.left + window_border.right;
window_border.left + window_border.right; title_nat += window_border.left + window_border.right;
title_nat += border_width * 2 +
window_border.left + window_border.right;
} }
if (child && gtk_widget_get_visible (child)) if (child && gtk_widget_get_visible (child))
@ -8426,6 +8424,7 @@ gtk_window_get_preferred_width_for_height (GtkWidget *widget,
guint border_width; guint border_width;
gint title_min = 0, title_nat = 0; gint title_min = 0, title_nat = 0;
gint child_min = 0, child_nat = 0; gint child_min = 0, child_nat = 0;
gint title_height = 0;
GtkBorder window_border = { 0 }; GtkBorder window_border = { 0 };
window = GTK_WINDOW (widget); window = GTK_WINDOW (widget);
@ -8446,20 +8445,23 @@ gtk_window_get_preferred_width_for_height (GtkWidget *widget,
if (priv->title_box != NULL && if (priv->title_box != NULL &&
gtk_widget_get_visible (priv->title_box) && gtk_widget_get_visible (priv->title_box) &&
gtk_widget_get_child_visible (priv->title_box)) gtk_widget_get_child_visible (priv->title_box))
gtk_widget_get_preferred_width_for_height (priv->title_box, {
height, gtk_widget_get_preferred_height (priv->title_box,
&title_min, &title_nat); NULL, &title_height);
gtk_widget_get_preferred_width_for_height (priv->title_box,
title_height,
&title_min, &title_nat);
height -= title_height;
}
title_min += border_width * 2 + title_min += window_border.left + window_border.right;
window_border.left + window_border.right; title_nat += window_border.left + window_border.right;
title_nat += border_width * 2 +
window_border.left + window_border.right;
} }
if (child && gtk_widget_get_visible (child)) if (child && gtk_widget_get_visible (child))
{ {
gtk_widget_get_preferred_width_for_height (child, gtk_widget_get_preferred_width_for_height (child,
height, MAX (height, 0),
&child_min, &child_nat); &child_min, &child_nat);
if (child_nat == 0 && height == 0) if (child_nat == 0 && height == 0)
@ -8572,7 +8574,7 @@ gtk_window_get_preferred_height_for_width (GtkWidget *widget,
gtk_widget_get_visible (priv->title_box) && gtk_widget_get_visible (priv->title_box) &&
gtk_widget_get_child_visible (priv->title_box)) gtk_widget_get_child_visible (priv->title_box))
gtk_widget_get_preferred_height_for_width (priv->title_box, gtk_widget_get_preferred_height_for_width (priv->title_box,
width, MAX (width, 0),
&title_min, &title_min,
&title_height); &title_height);
@ -8586,7 +8588,7 @@ gtk_window_get_preferred_height_for_width (GtkWidget *widget,
if (child && gtk_widget_get_visible (child)) if (child && gtk_widget_get_visible (child))
{ {
gint child_min, child_nat; gint child_min, child_nat;
gtk_widget_get_preferred_height_for_width (child, width, gtk_widget_get_preferred_height_for_width (child, MAX (width, 0),
&child_min, &child_nat); &child_min, &child_nat);
if (child_nat == 0 && width == 0) if (child_nat == 0 && width == 0)