[gtk/fallback-rendering: 3/3] inspector: Add a switch for fallback rendering
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/fallback-rendering: 3/3] inspector: Add a switch for fallback rendering
- Date: Thu, 31 Oct 2019 02:32:51 +0000 (UTC)
commit 745a701b3d2dea18311ebd6e880c4477f2aa0047
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Oct 30 22:31:27 2019 -0400
inspector: Add a switch for fallback rendering
gtk/inspector/visual.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++
gtk/inspector/visual.ui | 27 +++++++++++++++++++++++++
2 files changed, 80 insertions(+)
---
diff --git a/gtk/inspector/visual.c b/gtk/inspector/visual.c
index ee632067e2..d11bb94c8f 100644
--- a/gtk/inspector/visual.c
+++ b/gtk/inspector/visual.c
@@ -36,6 +36,9 @@
#include "gtkscale.h"
#include "gtkwindow.h"
#include "gtklistbox.h"
+#include "gskdebugprivate.h"
+#include "gskrendererprivate.h"
+#include "gtknative.h"
#include "fallback-c89.c"
@@ -74,6 +77,7 @@ struct _GtkInspectorVisualPrivate
GtkWidget *debug_box;
GtkWidget *fps_switch;
GtkWidget *updates_switch;
+ GtkWidget *fallback_switch;
GtkWidget *baselines_switch;
GtkWidget *layout_switch;
GtkWidget *resize_switch;
@@ -302,6 +306,48 @@ updates_activate (GtkSwitch *sw,
redraw_everything ();
}
+static void
+fallback_activate (GtkSwitch *sw,
+ GParamSpec *pspec,
+ GtkInspectorVisual *vis)
+{
+ GtkInspectorWindow *iw;
+ gboolean fallback;
+ guint flags;
+ GList *toplevels, *l;
+
+ fallback = gtk_switch_get_active (sw);
+ iw = GTK_INSPECTOR_WINDOW (gtk_widget_get_root (GTK_WIDGET (vis)));
+ if (iw == NULL)
+ return;
+
+ flags = gsk_get_debug_flags ();
+ if (fallback)
+ flags = flags | GSK_DEBUG_FALLBACK;
+ else
+ flags = flags & ~GSK_DEBUG_FALLBACK;
+ gsk_set_debug_flags (flags);
+
+ toplevels = gtk_window_list_toplevels ();
+ for (l = toplevels; l; l = l->next)
+ {
+ GtkWidget *toplevel = l->data;
+ GskRenderer *renderer;
+
+ if ((GtkRoot *)toplevel == gtk_widget_get_root (GTK_WIDGET (sw))) /* skip the inspector */
+ continue;
+
+ renderer = gtk_native_get_renderer (GTK_NATIVE (toplevel));
+ if (!renderer)
+ continue;
+
+ gsk_renderer_set_debug_flags (renderer, flags);
+ }
+ g_list_free (toplevels);
+
+ redraw_everything ();
+}
+
static void
baselines_activate (GtkSwitch *sw)
{
@@ -871,6 +917,11 @@ row_activated (GtkListBox *box,
GtkSwitch *sw = GTK_SWITCH (vis->priv->updates_switch);
gtk_switch_set_active (sw, !gtk_switch_get_active (sw));
}
+ else if (gtk_widget_is_ancestor (vis->priv->fallback_switch, GTK_WIDGET (row)))
+ {
+ GtkSwitch *sw = GTK_SWITCH (vis->priv->fallback_switch);
+ gtk_switch_set_active (sw, !gtk_switch_get_active (sw));
+ }
else if (gtk_widget_is_ancestor (vis->priv->baselines_switch, GTK_WIDGET (row)))
{
GtkSwitch *sw = GTK_SWITCH (vis->priv->baselines_switch);
@@ -1058,12 +1109,14 @@ gtk_inspector_visual_class_init (GtkInspectorVisualClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, font_scale_adjustment);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, fps_switch);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, updates_switch);
+ gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, fallback_switch);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, baselines_switch);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, layout_switch);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, resize_switch);
gtk_widget_class_bind_template_callback (widget_class, fps_activate);
gtk_widget_class_bind_template_callback (widget_class, updates_activate);
+ gtk_widget_class_bind_template_callback (widget_class, fallback_activate);
gtk_widget_class_bind_template_callback (widget_class, direction_changed);
gtk_widget_class_bind_template_callback (widget_class, baselines_activate);
gtk_widget_class_bind_template_callback (widget_class, layout_activate);
diff --git a/gtk/inspector/visual.ui b/gtk/inspector/visual.ui
index a28d070d11..ead50b6384 100644
--- a/gtk/inspector/visual.ui
+++ b/gtk/inspector/visual.ui
@@ -425,6 +425,32 @@
</child>
</object>
</child>
+ <child>
+ <object class="GtkListBoxRow">
+ <child>
+ <object class="GtkBox">
+ <property name="margin">10</property>
+ <property name="spacing">40</property>
+ <child>
+ <object class="GtkLabel" id="fallback_label">
+ <property name="label" translatable="yes">Show Fallback Rendering</property>
+ <property name="halign">start</property>
+ <property name="valign">baseline</property>
+ <property name="xalign">0.0</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkSwitch" id="fallback_switch">
+ <property name="halign">end</property>
+ <property name="valign">baseline</property>
+ <property name="hexpand">1</property>
+ <signal name="notify::active" handler="fallback_activate"/>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
<child>
<object class="GtkListBoxRow">
<child>
@@ -586,6 +612,7 @@
<widget name="hidpi_label"/>
<widget name="animation_label"/>
<widget name="updates_label"/>
+ <widget name="fallback_label"/>
<widget name="baselines_label"/>
<widget name="layout_label"/>
<widget name="resize_label"/>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]