Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell/ev-utils.c
diff options
context:
space:
mode:
authorJuanjo MarĂ­n <juanj.marin@juntadeandalucia.es>2010-02-21 11:14:25 (GMT)
committer Carlos Garcia Campos <carlosgc@gnome.org>2010-02-21 11:14:25 (GMT)
commitdb8a118298552769e835c67d29dfe1fa41de698a (patch)
tree21819b1c44492b11dd9abc180e21c21d2f5569bf /shell/ev-utils.c
parent5ef0d418d651705e098d2a1a8495e86bf7c0f538 (diff)
Fix dpi calculation
Fixes bug #608586.
Diffstat (limited to 'shell/ev-utils.c')
-rw-r--r--shell/ev-utils.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/shell/ev-utils.c b/shell/ev-utils.c
index 8cda889..d77e91f 100644
--- a/shell/ev-utils.c
+++ b/shell/ev-utils.c
@@ -307,14 +307,17 @@ gdouble
get_screen_dpi (GtkWindow *window)
{
GdkScreen *screen;
- gdouble xdpi, ydpi;
+ gdouble dp, di;
screen = gtk_window_get_screen (window);
- xdpi = 25.4 * gdk_screen_get_width (screen) / gdk_screen_get_width_mm (screen);
- ydpi = 25.4 * gdk_screen_get_height (screen) / gdk_screen_get_height_mm (screen);
-
- return (xdpi + ydpi) / 2.0;
+ /*diagonal in pixels*/
+ dp = hypot (gdk_screen_get_width (screen), gdk_screen_get_height (screen));
+
+ /*diagonal in inches*/
+ di = hypot (gdk_screen_get_width_mm(screen), gdk_screen_get_height_mm (screen)) / 25.4;
+
+ return (dp / di);
}