summaryrefslogtreecommitdiff
path: root/shell/ev-window.c
diff options
context:
space:
mode:
authorraveit65 <[email protected]>2019-07-29 14:55:23 +0200
committerRobert Antoni Buj Gelonch <[email protected]>2019-08-19 14:15:38 +0200
commitbe9ae6b93b257af960da4eebf6544fd1331b5acf (patch)
treebd37ee7769e15478d972270214724f42ec730241 /shell/ev-window.c
parentc34be5dfa37885c5c5c7caece80aeaf4b343629e (diff)
downloadatril-be9ae6b93b257af960da4eebf6544fd1331b5acf.tar.bz2
atril-be9ae6b93b257af960da4eebf6544fd1331b5acf.tar.xz
shell: Use monitor instead of screen to determine window size
replace {Width/Height}OfScreen which works only with X11 inspired from: https://gitlab.gnome.org/GNOME/evince/commit/40aa446
Diffstat (limited to 'shell/ev-window.c')
-rw-r--r--shell/ev-window.c36
1 files changed, 31 insertions, 5 deletions
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 67dc52bf..15d81b4c 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -1360,6 +1360,31 @@ setup_model_from_metadata (EvWindow *window)
}
static void
+monitor_get_dimesions (EvWindow *ev_window,
+ gint *width,
+ gint *height)
+{
+ GdkDisplay *display;
+ GdkWindow *gdk_window;
+ GdkMonitor *monitor;
+ GdkRectangle geometry;
+
+ *width = 0;
+ *height = 0;
+
+ display = gtk_widget_get_display (GTK_WIDGET (ev_window));
+ gdk_window = gtk_widget_get_window (GTK_WIDGET (ev_window));
+
+ if (gdk_window) {
+ monitor = gdk_display_get_monitor_at_window (display,
+ gdk_window);
+ gdk_monitor_get_workarea (monitor, &geometry);
+ *width = geometry.width;
+ *height = geometry.height;
+ }
+}
+
+static void
setup_document_from_metadata (EvWindow *window)
{
gint page, n_pages;
@@ -1391,9 +1416,10 @@ setup_document_from_metadata (EvWindow *window)
if (width_ratio > 0. && height_ratio > 0.) {
gdouble document_width;
gdouble document_height;
- GdkScreen *screen;
gint request_width;
gint request_height;
+ gint monitor_width;
+ gint monitor_height;
ev_document_get_max_page_size (window->priv->document,
&document_width, &document_height);
@@ -1401,10 +1427,10 @@ setup_document_from_metadata (EvWindow *window)
request_width = (gint)(width_ratio * document_width + 0.5);
request_height = (gint)(height_ratio * document_height + 0.5);
- screen = gtk_window_get_screen (GTK_WINDOW (window));
- if (screen) {
- request_width = MIN (request_width, WidthOfScreen (gdk_x11_screen_get_xscreen (screen)));
- request_height = MIN (request_height, HeightOfScreen (gdk_x11_screen_get_xscreen (screen)));
+ monitor_get_dimesions (window, &monitor_width, &monitor_height);
+ if (monitor_width > 0 && monitor_height > 0) {
+ request_width = MIN (request_width, monitor_width);
+ request_height = MIN (request_height, monitor_height);
}
if (request_width > 0 && request_height > 0) {