window: stop stomping on resize-mode set by external API

commit c3dc0d80f1 fixed the behavior of
GtkContainer widgets requesting an IMMEDIATE resize-mode.

However, GtkWindow has been stomping on resize-mode during realize()
since commit addcc64b9c. The combination
of factors that led to this not being a visible problem during all this
while is uncertain, but this now causes the Shell to continuously try to
relayout its ShellEmbeddedWindow (a GtkWindow subclass).

This commit separates the resize-mode as set internally by GtkWindow
from the one set with the external API, so that GtkWindow only changes
it when it had not been set before by the subclass.

https://bugzilla.gnome.org/show_bug.cgi?id=763650
This commit is contained in:
Cosimo Cecchi 2016-03-14 15:41:16 -07:00
parent 4f2cbd1856
commit d61c2b4cce
3 changed files with 40 additions and 21 deletions

View File

@ -287,6 +287,7 @@ struct _GtkContainerPrivate
guint reallocate_redraws : 1;
guint restyle_pending : 1;
guint resize_mode : 2;
guint resize_mode_set : 1;
guint request_mode : 2;
};
@ -1909,6 +1910,28 @@ gtk_container_remove (GtkContainer *container,
g_object_unref (container);
}
static void
gtk_container_real_set_resize_mode (GtkContainer *container,
GtkResizeMode resize_mode)
{
GtkWidget *widget = GTK_WIDGET (container);
GtkContainerPrivate *priv = container->priv;
if (_gtk_widget_is_toplevel (widget) &&
resize_mode == GTK_RESIZE_PARENT)
{
resize_mode = GTK_RESIZE_QUEUE;
}
if (priv->resize_mode != resize_mode)
{
priv->resize_mode = resize_mode;
gtk_widget_queue_resize (widget);
g_object_notify_by_pspec (G_OBJECT (container), container_props[PROP_RESIZE_MODE]);
}
}
/**
* gtk_container_set_resize_mode:
* @container: a #GtkContainer
@ -1929,26 +1952,26 @@ gtk_container_set_resize_mode (GtkContainer *container,
GtkResizeMode resize_mode)
{
GtkContainerPrivate *priv;
GtkWidget *widget = (GtkWidget *)container;
g_return_if_fail (GTK_IS_CONTAINER (container));
g_return_if_fail (resize_mode <= GTK_RESIZE_IMMEDIATE);
priv = container->priv;
priv->resize_mode_set = TRUE;
if (_gtk_widget_is_toplevel (widget) &&
resize_mode == GTK_RESIZE_PARENT)
{
resize_mode = GTK_RESIZE_QUEUE;
}
gtk_container_real_set_resize_mode (container, resize_mode);
}
if (priv->resize_mode != resize_mode)
{
priv->resize_mode = resize_mode;
void
gtk_container_set_default_resize_mode (GtkContainer *container,
GtkResizeMode resize_mode)
{
GtkContainerPrivate *priv = container->priv;
gtk_widget_queue_resize (widget);
g_object_notify_by_pspec (G_OBJECT (container), container_props[PROP_RESIZE_MODE]);
}
if (priv->resize_mode_set)
return;
gtk_container_real_set_resize_mode (container, resize_mode);
}
/**

View File

@ -44,6 +44,8 @@ void _gtk_container_set_border_width_set (GtkContainer *container,
gboolean border_width_set);
void gtk_container_get_children_clip (GtkContainer *container,
GtkAllocation *out_clip);
void gtk_container_set_default_resize_mode (GtkContainer *container,
GtkResizeMode resize_mode);
G_END_DECLS

View File

@ -1637,9 +1637,7 @@ gtk_window_init (GtkWindow *window)
_gtk_widget_set_is_toplevel (widget, TRUE);
_gtk_widget_set_anchored (widget, TRUE);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
gtk_container_set_resize_mode (GTK_CONTAINER (window), GTK_RESIZE_QUEUE);
G_GNUC_END_IGNORE_DEPRECATIONS;
gtk_container_set_default_resize_mode (GTK_CONTAINER (window), GTK_RESIZE_QUEUE);
priv->title = NULL;
priv->wmclass_name = g_strdup (g_get_prgname ());
@ -7140,9 +7138,7 @@ gtk_window_realize (GtkWidget *widget)
if (gtk_widget_get_parent_window (widget))
{
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
gtk_container_set_resize_mode (GTK_CONTAINER (widget), GTK_RESIZE_PARENT);
G_GNUC_END_IGNORE_DEPRECATIONS;
gtk_container_set_default_resize_mode (GTK_CONTAINER (widget), GTK_RESIZE_PARENT);
attributes.x = allocation.x;
attributes.y = allocation.y;
@ -7166,9 +7162,7 @@ gtk_window_realize (GtkWidget *widget)
return;
}
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
gtk_container_set_resize_mode (GTK_CONTAINER (window), GTK_RESIZE_QUEUE);
G_GNUC_END_IGNORE_DEPRECATIONS;
gtk_container_set_default_resize_mode (GTK_CONTAINER (window), GTK_RESIZE_QUEUE);
/* ensure widget tree is properly size allocated */
if (allocation.x == -1 &&