diff options
author | Matthew Petroff <[email protected]> | 2016-10-18 15:10:13 -0400 |
---|---|---|
committer | raveit65 <[email protected]> | 2017-08-15 15:30:32 +0200 |
commit | 31251cb1202aec7cb3bb1addfbbfe55c125f10d7 (patch) | |
tree | 167fbc1f980a8045b07e7df725b39c322e1762df /libview/ev-view.c | |
parent | 869befa181ab80046d87b2f8eadb5cab177f5003 (diff) | |
download | atril-31251cb1202aec7cb3bb1addfbbfe55c125f10d7.tar.bz2 atril-31251cb1202aec7cb3bb1addfbbfe55c125f10d7.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.c | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/libview/ev-view.c b/libview/ev-view.c index b7410d87..4584bd46 100644 --- a/libview/ev-view.c +++ b/libview/ev-view.c @@ -4463,6 +4463,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); @@ -4475,6 +4476,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); @@ -4490,13 +4495,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); @@ -4525,13 +4530,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); @@ -4873,6 +4878,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; @@ -4918,6 +4931,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 ***/ |