summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2019-04-06 23:03:25 +0000
committerMatthias Clasen <mclasen@redhat.com>2019-04-06 23:03:25 +0000
commitbea7ccb41fdde2dde05b16fcd70f9745dcb36f6a (patch)
tree7e35bc2e1a86cd74be2a23de79729a5c713ffdc1
parent9895f2bd3ab3870edbe14f52e0f228e4f7f66b15 (diff)
downloadgtk+-bea7ccb41fdde2dde05b16fcd70f9745dcb36f6a.tar.gz
widget: Propagate display changes to the style context
When a root is set on a widget, the style context may already exist. We need to make sure that the style context has the right display set. This was showing up as "css spillover" in the inspector. Closes: #https://gitlab.gnome.org/GNOME/gtk/issues/1817
-rw-r--r--gtk/gtkwidget.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index aec86f331c..ed0a21f5a7 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -2953,6 +2953,9 @@ gtk_widget_root (GtkWidget *widget)
priv->root = priv->parent->priv->root;
+ if (priv->context)
+ gtk_style_context_set_display (priv->context, gtk_root_get_display (priv->root));
+
GTK_WIDGET_GET_CLASS (widget)->root (widget);
g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_ROOT]);
@@ -2972,6 +2975,9 @@ gtk_widget_unroot (GtkWidget *widget)
GTK_WIDGET_GET_CLASS (widget)->unroot (widget);
+ if (priv->context)
+ gtk_style_context_set_display (priv->context, gdk_display_get_default ());
+
priv->root = NULL;
g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_ROOT]);