diff options
author | rbuj <[email protected]> | 2019-08-02 12:56:13 +0200 |
---|---|---|
committer | Victor Kareh <[email protected]> | 2019-08-10 22:58:36 -0400 |
commit | d387353c800961b730496dc79d2372b2a56875d9 (patch) | |
tree | fe01277680a993b2b1f666ade7f8410fad21ab2f /libview/ev-view.c | |
parent | 82d6a871b48c5054c629c83612b60dba63e70cc9 (diff) | |
download | atril-d387353c800961b730496dc79d2372b2a56875d9.tar.bz2 atril-d387353c800961b730496dc79d2372b2a56875d9.tar.xz |
DPI: compute monitor resolution or get screen resolution
Diffstat (limited to 'libview/ev-view.c')
-rw-r--r-- | libview/ev-view.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/libview/ev-view.c b/libview/ev-view.c index 7703c6ed..90f9d3cb 100644 --- a/libview/ev-view.c +++ b/libview/ev-view.c @@ -494,18 +494,19 @@ is_dual_page (EvView *view, switch (view->page_layout) { case EV_PAGE_LAYOUT_AUTOMATIC: { - GdkScreen *screen; - GdkMonitor *monitor; - GdkDisplay *display; + GdkWindow *window; + GdkMonitor *monitor; + GdkDisplay *display; double scale; double doc_width; double doc_height; GtkAllocation allocation; - screen = gtk_widget_get_screen (GTK_WIDGET (view)); - display = gdk_screen_get_display (screen); - monitor = gdk_display_get_primary_monitor (display); - scale = ev_document_misc_get_screen_dpi (screen, monitor) / 72.0; + window = gtk_widget_get_window (GTK_WIDGET (view)); + display = gdk_window_get_display (window); + monitor = gdk_display_get_monitor_at_window (display, window); + + scale = ev_document_misc_get_monitor_dpi (monitor) / 72.0; ev_document_get_max_page_size (view->document, &doc_width, &doc_height); gtk_widget_get_allocation (GTK_WIDGET (view), &allocation); @@ -7105,8 +7106,6 @@ zoom_for_size_automatic (GdkScreen *screen, int target_width, int target_height) { - GdkMonitor *monitor; - GdkDisplay *display; double fit_width_scale; double scale; @@ -7118,11 +7117,15 @@ zoom_for_size_automatic (GdkScreen *screen, fit_height_scale = zoom_for_size_fit_height (doc_width, doc_height, target_width, target_height); scale = MIN (fit_width_scale, fit_height_scale); } else { - double actual_scale; + double actual_scale, resolution; - display = gdk_screen_get_display (screen); - monitor = gdk_display_get_primary_monitor (display); - actual_scale = ev_document_misc_get_screen_dpi (screen, monitor) / 72.0; + resolution = gdk_screen_get_resolution (screen); + if (resolution == -1) { + GdkDisplay *display = gdk_screen_get_display (screen); + GdkMonitor *monitor = gdk_display_get_primary_monitor (display); + resolution = ev_document_misc_get_monitor_dpi (monitor); + } + actual_scale = resolution / 72.0; scale = MIN (fit_width_scale, actual_scale); } |