summaryrefslogtreecommitdiff
path: root/libview/ev-view.c
diff options
context:
space:
mode:
authorMatthew Petroff <[email protected]>2016-10-18 15:10:13 -0400
committerraveit65 <[email protected]>2017-08-12 22:01:34 +0200
commitb6a20b77926727af99b39773ee104ffa457c604f (patch)
tree16a6ce7fa9b585f4e70d8743554ca30933a554d4 /libview/ev-view.c
parent6217ba3214fb0284eb569ed22b5700ad2c6b5817 (diff)
downloadatril-b6a20b77926727af99b39773ee104ffa457c604f.tar.bz2
atril-b6a20b77926727af99b39773ee104ffa457c604f.tar.xz
Add hi-dpi support for main view.
Based on Evince commits 8b965e769808815df9c75a10a0e4972c0904d26a and a612f809e4e23d88a661a9604ce84f332189a658. https://github.com/linuxmint/xreader/commit/4eccf6b
Diffstat (limited to 'libview/ev-view.c')
-rw-r--r--libview/ev-view.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/libview/ev-view.c b/libview/ev-view.c
index 0e84a1e4..86eef350 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -4467,6 +4467,7 @@ draw_one_page (EvView *view,
cairo_surface_t *page_surface = NULL;
gint selection_width, selection_height;
cairo_surface_t *selection_surface = NULL;
+ double device_scale_x = 1, device_scale_y = 1;
page_surface = ev_pixbuf_cache_get_surface (view->pixbuf_cache, page);
@@ -4479,6 +4480,10 @@ draw_one_page (EvView *view,
return;
}
+#ifdef HAVE_HIDPI_SUPPORT
+ cairo_surface_get_device_scale (page_surface, &device_scale_x, &device_scale_y);
+#endif
+
if (page == current_page)
hide_loading_window (view);
@@ -4494,13 +4499,13 @@ draw_one_page (EvView *view,
cairo_pattern_set_filter (cairo_get_source (cr),
CAIRO_FILTER_FAST);
cairo_scale (cr,
- (gdouble)width / page_width,
- (gdouble)height / page_height);
+ (gdouble)width / page_width * device_scale_x,
+ (gdouble)height / page_height * device_scale_y);
}
cairo_surface_set_device_offset (page_surface,
- overlap.x - real_page_area.x,
- overlap.y - real_page_area.y);
+ (overlap.x - real_page_area.x) * device_scale_x,
+ (overlap.y - real_page_area.y) * device_scale_y);
cairo_set_source_surface (cr, page_surface, 0, 0);
cairo_paint (cr);
cairo_restore (cr);
@@ -4529,13 +4534,13 @@ draw_one_page (EvView *view,
cairo_pattern_set_filter (cairo_get_source (cr),
CAIRO_FILTER_FAST);
cairo_scale (cr,
- (gdouble)width / selection_width,
- (gdouble)height / selection_height);
+ (gdouble)width / selection_width * device_scale_x,
+ (gdouble)height / selection_height * device_scale_y);
}
cairo_surface_set_device_offset (selection_surface,
- overlap.x - real_page_area.x,
- overlap.y - real_page_area.y);
+ (overlap.x - real_page_area.x) * device_scale_x,
+ (overlap.y - real_page_area.y) * device_scale_y);
cairo_set_source_surface (cr, selection_surface, 0, 0);
cairo_paint (cr);
@@ -4877,6 +4882,14 @@ ev_view_class_init (EvViewClass *class)
}
static void
+on_notify_scale_factor (EvView *view,
+ GParamSpec *pspec)
+{
+ if (view->document)
+ view_update_range_and_current_page (view);
+}
+
+static void
ev_view_init (EvView *view)
{
GtkStyleContext *context;
@@ -4922,6 +4935,9 @@ ev_view_init (EvView *view)
view->pending_scroll = SCROLL_TO_KEEP_POSITION;
view->jump_to_find_result = TRUE;
view->highlight_find_results = FALSE;
+
+ g_signal_connect (view, "notify::scale-factor",
+ G_CALLBACK (on_notify_scale_factor), NULL);
}
/*** Callbacks ***/