GtkWindow: fix default empty window size with CSD

In the non-CSD case we checked for 0x0 window size requisition
and replaced it with 200x200 so the window was still visible.
This no longer works in case of CSD as the shadow and title bar
are always added to the requisition resulting in a titlebar/shadow
only window in case there is no child widget (this is currently
visible under wayland or when setting GTK_CSD=1).

Instead of special casing the final window size, special case
the child requisition paths instead. This gives us the same
requisition in both, CSD and non-CSD cases (the header bar
has a too large minimum width atm so the resulting window is
still not the same)

https://bugzilla.gnome.org/show_bug.cgi?id=751341
This commit is contained in:
Christoph Reiter 2015-06-22 20:36:50 +02:00 committed by Christoph Reiter
parent da14dbe4e5
commit 84e99b20ac

View File

@ -126,6 +126,12 @@
*/
#define MNEMONICS_DELAY 300 /* ms */
#define NO_CONTENT_CHILD_NAT 200
/* In case the content (excluding header bar and shadows) of the window
* would be empty, either because there is no visible child widget or only an
* empty container widget, we use NO_CONTENT_CHILD_NAT as natural width/height
* instead.
*/
typedef struct _GtkWindowPopover GtkWindowPopover;
@ -7054,12 +7060,6 @@ gtk_window_realize (GtkWidget *widget)
gtk_window_get_remembered_size (window, &w, &h);
allocation.width = MAX (allocation.width, w);
allocation.height = MAX (allocation.height, h);
if (allocation.width == 0 || allocation.height == 0)
{
/* non-empty window */
allocation.width = 200;
allocation.height = 200;
}
gtk_widget_size_allocate (widget, &allocation);
_gtk_container_queue_resize (GTK_CONTAINER (widget));
@ -8396,11 +8396,18 @@ gtk_window_get_preferred_width (GtkWidget *widget,
if (child && gtk_widget_get_visible (child))
{
gtk_widget_get_preferred_width (child, &child_min, &child_nat);
if (child_nat == 0)
child_nat = NO_CONTENT_CHILD_NAT;
child_min += border_width * 2 +
window_border.left + window_border.right;
child_nat += border_width * 2 +
window_border.left + window_border.right;
}
else
{
child_nat = NO_CONTENT_CHILD_NAT;
}
*minimum_size = MAX (title_min, child_min);
*natural_size = MAX (title_nat, child_nat);
@ -8454,11 +8461,18 @@ gtk_window_get_preferred_width_for_height (GtkWidget *widget,
gtk_widget_get_preferred_width_for_height (child,
height,
&child_min, &child_nat);
if (child_nat == 0 && height == 0)
child_nat = NO_CONTENT_CHILD_NAT;
child_min += border_width * 2 +
window_border.left + window_border.right;
child_nat += border_width * 2 +
window_border.left + window_border.right;
}
else
{
child_nat = NO_CONTENT_CHILD_NAT;
}
*minimum_size = MAX (title_min, child_min);
*natural_size = MAX (title_nat, child_nat);
@ -8510,9 +8524,15 @@ gtk_window_get_preferred_height (GtkWidget *widget,
gint child_min, child_nat;
gtk_widget_get_preferred_height (child, &child_min, &child_nat);
if (child_nat == 0)
child_nat = NO_CONTENT_CHILD_NAT;
*minimum_size += child_min + 2 * border_width;
*natural_size += child_nat + 2 * border_width;
}
else
{
*natural_size += NO_CONTENT_CHILD_NAT;
}
}
@ -8569,9 +8589,15 @@ gtk_window_get_preferred_height_for_width (GtkWidget *widget,
gtk_widget_get_preferred_height_for_width (child, width,
&child_min, &child_nat);
if (child_nat == 0 && width == 0)
child_nat = NO_CONTENT_CHILD_NAT;
*minimum_size += child_min + 2 * border_width;
*natural_size += child_nat + 2 * border_width;
}
else
{
*natural_size += NO_CONTENT_CHILD_NAT;
}
}
/**
@ -8755,13 +8781,6 @@ gtk_window_compute_configure_request_size (GtkWindow *window,
*width = MAX (*width, w);
*height = MAX (*height, h);
/* If window is empty so requests 0, default to random nonzero size */
if (*width == 0 && *height == 0)
{
*width = 200;
*height = 200;
}
/* Override with default size */
if (info)
{