[gtk/inspector-work: 1/2] widget: Propagate display changes to the style context



commit bea7ccb41fdde2dde05b16fcd70f9745dcb36f6a
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Apr 6 23:03:25 2019 +0000

    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

 gtk/gtkwidget.c | 6 ++++++
 1 file changed, 6 insertions(+)
---
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]);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]