summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrbuj <[email protected]>2019-08-08 19:31:29 +0200
committerVictor Kareh <[email protected]>2019-08-10 22:58:36 -0400
commitfa163ddb1a0466db7874164a1956faaf8ca18297 (patch)
tree03b0df9284260acbf28c97832cdb91b8d66dc833
parentd387353c800961b730496dc79d2372b2a56875d9 (diff)
downloadatril-fa163ddb1a0466db7874164a1956faaf8ca18297.tar.bz2
atril-fa163ddb1a0466db7874164a1956faaf8ca18297.tar.xz
shell: fix get_monitor_dpi when widget’s window is not realized
-rw-r--r--shell/ev-window.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 82aa74a7..86019e93 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -402,9 +402,13 @@ get_monitor_dpi (EvWindow *ev_window)
GdkDisplay *display;
window = gtk_widget_get_window (GTK_WIDGET (ev_window));
- display = gdk_window_get_display (window);
- monitor = gdk_display_get_monitor_at_window (display, window);
-
+ if (window) {
+ display = gdk_window_get_display (window);
+ monitor = gdk_display_get_monitor_at_window (display, window);
+ } else {
+ display = gdk_display_get_default();
+ monitor = gdk_display_get_primary_monitor (display);
+ }
return ev_document_misc_get_monitor_dpi (monitor);
}