From d25c926e1354ea8d6c4b4636503d7548a50cbd7e Mon Sep 17 00:00:00 2001 From: Nils Philippsen Date: Mon, 3 Sep 2012 16:07:44 +0200 Subject: [PATCH] patch: preview-window-size Squashed commit of the following: commit 9fa241f0f4a21623e0ae5be871d885f6b082dd38 Author: Nils Philippsen Date: Mon Sep 3 16:00:35 2012 +0200 calculate minimum window size better for multi-head setups --- src/xsane-preview.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/xsane-preview.c b/src/xsane-preview.c index 264c775..634a4e2 100644 --- a/src/xsane-preview.c +++ b/src/xsane-preview.c @@ -4665,6 +4665,9 @@ void preview_update_surface(Preview *p, int surface_changed) SANE_Unit unit; double min, max; int expand_surface = 0; + gint min_width, min_height; + GdkScreen *screen; + GdkRectangle geometry; DBG(DBG_proc, "preview_update_surface\n"); @@ -4848,8 +4851,20 @@ void preview_update_surface(Preview *p, int surface_changed) { DBG(DBG_info, "preview_update_surface: defining size of preview window\n"); - p->preview_window_width = 0.3 * gdk_screen_width(); - p->preview_window_height = 0.5 * gdk_screen_height(); + /* ensure preview window fits on displays, account for multi-head */ + min_width = gdk_screen_width(); + min_height = gdk_screen_height(); + + screen = gdk_screen_get_default(); + for (i = 0; i < gdk_screen_get_n_monitors(screen); i++) + { + gdk_screen_get_monitor_geometry(screen, i, &geometry); + min_width = MIN(min_width, geometry.width); + min_height = MIN(min_height, geometry.height); + } + + p->preview_window_width = 0.3 * min_width; + p->preview_window_height = 0.5 * min_height; preview_area_correct(p); /* calculate preview_width and height */ gtk_widget_set_size_request(GTK_WIDGET(p->window), p->preview_width, p->preview_height); } -- 1.7.11.4