[gtk+] inspector: Respect text-scaling-factor value initially



commit 1af817e2549fd7c676fd3ff23f0d2bc5ac18432a
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Nov 23 19:16:16 2016 -0500

    inspector: Respect text-scaling-factor value initially
    
    This was pointed out in
    https://bugzilla.gnome.org/show_bug.cgi?id=774893

 gtk/inspector/visual.c |   45 +++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 41 insertions(+), 4 deletions(-)
---
diff --git a/gtk/inspector/visual.c b/gtk/inspector/visual.c
index 8c44401..b63dcbc 100644
--- a/gtk/inspector/visual.c
+++ b/gtk/inspector/visual.c
@@ -37,6 +37,9 @@
 #ifdef GDK_WINDOWING_X11
 #include "x11/gdkx.h"
 #endif
+#ifdef GDK_WINDOWING_WAYLAND
+#include "wayland/gdkwayland.h"
+#endif
 
 #include "gdk/gdk-private.h"
 
@@ -140,14 +143,46 @@ redraw_everything (void)
   g_list_free (toplevels);
 }
 
+static double
+get_font_scale (GtkInspectorVisual *vis)
+{
+#ifdef GDK_WINDOWING_X11
+  if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
+    {
+      int dpi_int;
+
+      g_object_get (gtk_settings_get_default (),
+                    "gtk-xft-dpi", &dpi_int,
+                    NULL);
+
+      return dpi_int / (96.0 * 1024.0);
+    }
+#endif
+#ifdef GDK_WINDOWING_WAYLAND
+  if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ()))
+    {
+      int dpi_int;
+
+      g_object_get (gtk_settings_get_default (),
+                    "gtk-xft-dpi", &dpi_int,
+                    NULL);
+
+      return dpi_int / (96.0 * 1024.0);
+    }
+#endif
+
+  return 1.0;
+}
+
 static void
 update_font_scale (GtkInspectorVisual *vis,
                    gdouble             factor,
                    gboolean            update_adjustment,
                    gboolean            update_entry)
 {
-  g_object_set (gtk_settings_get_default (), "gtk-xft-dpi",
-                (gint)(factor * 96 * 1024), NULL);
+  g_object_set (gtk_settings_get_default (),
+                "gtk-xft-dpi", (gint)(factor * 96 * 1024),
+                NULL);
 
   if (update_adjustment)
     gtk_adjustment_set_value (vis->priv->font_scale_adjustment, factor);
@@ -547,8 +582,10 @@ init_font (GtkInspectorVisual *vis)
 static void
 init_font_scale (GtkInspectorVisual *vis)
 {
-  /* There is no backend agnostic way to get the default value, so use 1.0 */
-  update_font_scale (vis, 1.0, TRUE, TRUE);
+  double scale;
+
+  scale = get_font_scale (vis);
+  update_font_scale (vis, scale, TRUE, TRUE);
   g_signal_connect (vis->priv->font_scale_adjustment, "value-changed",
                     G_CALLBACK (font_scale_adjustment_changed), vis);
   g_signal_connect (vis->priv->font_scale_entry, "activate",


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