[gtk+/wip/window-scales2: 21/40] Add GDK_DPI_SCALE env var



commit ae43f9facbfa756915989dcd7ddd7b3497ffa323
Author: Alexander Larsson <alexl redhat com>
Date:   Thu Jun 20 18:43:42 2013 +0200

    Add GDK_DPI_SCALE env var
    
    This is very useful for hidpi where the dpi is scaled to make
    non-dpi aware apps larger. In that case a dpi aware gtk+ using
    GDK_SCALE will be getting huge fonts. You can the set GDK_DPI_SCALE
    to compensate for this.

 gtk/gtksettings.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c
index ab96154..47e3d2a 100644
--- a/gtk/gtksettings.c
+++ b/gtk/gtksettings.c
@@ -2810,6 +2810,8 @@ settings_update_resolution (GtkSettings *settings)
   GtkSettingsPrivate *priv = settings->priv;
   gint dpi_int;
   gdouble dpi;
+  const char *scale_env;
+  double scale;
 
   g_object_get (settings,
                 "gtk-xft-dpi", &dpi_int,
@@ -2820,6 +2822,14 @@ settings_update_resolution (GtkSettings *settings)
   else
     dpi = -1.;
 
+  scale_env = g_getenv ("GDK_DPI_SCALE");
+  if (scale_env)
+    {
+      scale = g_ascii_strtod (scale_env, NULL);
+      if (scale != 0 && dpi > 0)
+       dpi *= scale;
+    }
+
   gdk_screen_set_resolution (priv->screen, dpi);
 }
 


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