inspector: Force a full redraw for debug nodes

Without this, debug nodes randomly are missing
in the tree, where we are reusing older render
nodes.
This commit is contained in:
Matthias Clasen 2023-03-11 12:30:44 +01:00
parent 582e74737c
commit 61ad0147bd
2 changed files with 29 additions and 1 deletions

View File

@ -584,6 +584,31 @@ gtk_inspector_window_enable_debugging (GtkWindow *window,
return FALSE;
}
static void
force_one_full_redraw (GtkWidget *w)
{
gtk_widget_queue_draw (w);
for (w = gtk_widget_get_first_child (w); w; w = gtk_widget_get_next_sibling (w))
force_one_full_redraw (w);
}
static void
force_full_redraw (GtkInspectorWindow *window)
{
GListModel *toplevels;
toplevels = gtk_window_get_toplevels ();
for (unsigned int i = 0; i < g_list_model_get_n_items (toplevels); i++)
{
GtkWidget *w = GTK_WIDGET (g_list_model_get_item (toplevels, i));
if (gtk_widget_get_display (w) == window->inspected_display)
force_one_full_redraw (w);
g_object_unref (w);
}
}
static void
gtk_inspector_window_class_init (GtkInspectorWindowClass *klass)
{
@ -671,6 +696,7 @@ gtk_inspector_window_class_init (GtkInspectorWindowClass *klass)
gtk_widget_class_bind_template_callback (widget_class, go_up_cb);
gtk_widget_class_bind_template_callback (widget_class, go_down_cb);
gtk_widget_class_bind_template_callback (widget_class, go_next_cb);
gtk_widget_class_bind_template_callback (widget_class, force_full_redraw);
}
static GdkDisplay *

View File

@ -618,7 +618,9 @@
<property name="name">recorder</property>
<property name="title" translatable="yes">Recorder</property>
<property name="child">
<object class="GtkInspectorRecorder" id="widget_recorder"/>
<object class="GtkInspectorRecorder" id="widget_recorder">
<signal name="notify::debug-nodes" handler="force_full_redraw" swapped='true'/>
</object>
</property>
</object>
</child>