[gtk+] window: stop stomping on resize-mode set by external API
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] window: stop stomping on resize-mode set by external API
- Date: Mon, 14 Mar 2016 23:10:52 +0000 (UTC)
commit d61c2b4cce38eb480aa53f8fdb08c4b181e2aa99
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Mon Mar 14 15:41:16 2016 -0700
window: stop stomping on resize-mode set by external API
commit c3dc0d80f1353ac66882ca3288ca7e9a13c47d6f fixed the behavior of
GtkContainer widgets requesting an IMMEDIATE resize-mode.
However, GtkWindow has been stomping on resize-mode during realize()
since commit addcc64b9cbb2fb1225080075ad3112a3d93d839. 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
gtk/gtkcontainer.c | 47 +++++++++++++++++++++++++++++++++-----------
gtk/gtkcontainerprivate.h | 2 +
gtk/gtkwindow.c | 12 ++--------
3 files changed, 40 insertions(+), 21 deletions(-)
---
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c
index 5e6d54a..44c6573 100644
--- a/gtk/gtkcontainer.c
+++ b/gtk/gtkcontainer.c
@@ -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);
}
/**
diff --git a/gtk/gtkcontainerprivate.h b/gtk/gtkcontainerprivate.h
index 1961444..7402a66 100644
--- a/gtk/gtkcontainerprivate.h
+++ b/gtk/gtkcontainerprivate.h
@@ -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
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 3e8d321..6b21e0b 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -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 &&
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]