From 7f4acdb0f4869b93ff87df56c15715e39ab04cb7 Mon Sep 17 00:00:00 2001 From: Jeremie Knuesel Date: Tue, 23 Jan 2018 11:34:22 +0100 Subject: [PATCH] HiDPI: fix thumbnail scaling --- zathura/page-widget.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/zathura/page-widget.c b/zathura/page-widget.c index d5e4ad6..c6e170e 100644 --- a/zathura/page-widget.c +++ b/zathura/page-widget.c @@ -445,8 +445,18 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo) } else { const unsigned int height = cairo_image_surface_get_height(priv->thumbnail); const unsigned int width = cairo_image_surface_get_width(priv->thumbnail); - const unsigned int pheight = (rotation % 180 ? page_width : page_height); - const unsigned int pwidth = (rotation % 180 ? page_height : page_width); + unsigned int pheight = (rotation % 180 ? page_width : page_height); + unsigned int pwidth = (rotation % 180 ? page_height : page_width); + +#ifdef HAVE_HIDPI_SUPPORT + double device_scale_x; + double device_scale_y; + cairo_surface_get_device_scale(priv->thumbnail, &device_scale_x, &device_scale_y); + if (device_scale_x != 0.0 && device_scale_y != 0.0) { + pwidth *= device_scale_x; + pheight *= device_scale_y; + } +#endif cairo_scale(cairo, pwidth / (double)width, pheight / (double)height); cairo_set_source_surface(cairo, priv->thumbnail, 0, 0);