summaryrefslogtreecommitdiff
path: root/libdocument
diff options
context:
space:
mode:
authorrbuj <[email protected]>2019-08-02 12:56:13 +0200
committerVictor Kareh <[email protected]>2019-08-10 22:58:36 -0400
commitd387353c800961b730496dc79d2372b2a56875d9 (patch)
treefe01277680a993b2b1f666ade7f8410fad21ab2f /libdocument
parent82d6a871b48c5054c629c83612b60dba63e70cc9 (diff)
downloadatril-d387353c800961b730496dc79d2372b2a56875d9.tar.bz2
atril-d387353c800961b730496dc79d2372b2a56875d9.tar.xz
DPI: compute monitor resolution or get screen resolution
Diffstat (limited to 'libdocument')
-rw-r--r--libdocument/ev-document-misc.c10
-rw-r--r--libdocument/ev-document-misc.h2
2 files changed, 8 insertions, 4 deletions
diff --git a/libdocument/ev-document-misc.c b/libdocument/ev-document-misc.c
index 1a07781c..e25b9ca6 100644
--- a/libdocument/ev-document-misc.c
+++ b/libdocument/ev-document-misc.c
@@ -339,16 +339,20 @@ ev_document_misc_invert_pixbuf (GdkPixbuf *pixbuf)
}
gdouble
-ev_document_misc_get_screen_dpi (GdkScreen *screen, GdkMonitor *monitor)
+ev_document_misc_get_monitor_dpi (GdkMonitor *monitor)
{
+ GdkRectangle geometry;
+ int s;
gdouble dp, di;
+ gdk_monitor_get_geometry (monitor, &geometry);
+ s = gdk_monitor_get_scale_factor (monitor);
+
/*diagonal in pixels*/
- dp = hypot (WidthOfScreen (gdk_x11_screen_get_xscreen (screen)), HeightOfScreen (gdk_x11_screen_get_xscreen (screen)));
+ dp = hypot (geometry.width * s, geometry.height * s);
/*diagonal in inches*/
di = hypot (gdk_monitor_get_width_mm(monitor), gdk_monitor_get_height_mm (monitor)) / 25.4;
- di /= gdk_monitor_get_scale_factor (monitor);
return (dp / di);
}
diff --git a/libdocument/ev-document-misc.h b/libdocument/ev-document-misc.h
index 5dec395a..3b97e3f8 100644
--- a/libdocument/ev-document-misc.h
+++ b/libdocument/ev-document-misc.h
@@ -61,7 +61,7 @@ cairo_surface_t *ev_document_misc_surface_rotate_and_scale (cairo_surface_t *sur
void ev_document_misc_invert_surface (cairo_surface_t *surface);
void ev_document_misc_invert_pixbuf (GdkPixbuf *pixbuf);
-gdouble ev_document_misc_get_screen_dpi (GdkScreen *screen, GdkMonitor *monitor);
+gdouble ev_document_misc_get_monitor_dpi (GdkMonitor *monitor);
gchar *ev_document_misc_format_date (GTime utime);