calculate minimum window size better for multi-head setups

This commit is contained in:
Nils Philippsen 2012-09-03 16:37:33 +02:00
parent c1618aba05
commit 232a993376
2 changed files with 64 additions and 1 deletions

View File

@ -0,0 +1,56 @@
From d25c926e1354ea8d6c4b4636503d7548a50cbd7e Mon Sep 17 00:00:00 2001
From: Nils Philippsen <nils@redhat.com>
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 <nils@redhat.com>
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

View File

@ -15,7 +15,7 @@
Name: xsane Name: xsane
Summary: X Window System front-end for the SANE scanner interface Summary: X Window System front-end for the SANE scanner interface
Version: 0.998 Version: 0.998
Release: 11%{?dist} Release: 12%{?dist}
Source0: http://www.xsane.org/download/%{name}-%{version}.tar.gz Source0: http://www.xsane.org/download/%{name}-%{version}.tar.gz
Source1: xsane-256x256.png Source1: xsane-256x256.png
# distro-specific: use "xdg-open" instead of "netscape" to launch help browser # distro-specific: use "xdg-open" instead of "netscape" to launch help browser
@ -50,6 +50,9 @@ Patch9: xsane-0.998-libpng.patch
# distro-specific: set program name/wmclass so GNOME shell picks appropriate # distro-specific: set program name/wmclass so GNOME shell picks appropriate
# high resolution icon file # high resolution icon file
Patch10: xsane-0.998-wmclass.patch Patch10: xsane-0.998-wmclass.patch
# calculate minimum window size better for multi-head setups
# submitted to upstream (Oliver Rauch) via email, 2012-09-03
Patch11: xsane-0.998-preview-window-size.patch
# autoconf-generated files # autoconf-generated files
Patch100: xsane-0.998-1-autoconf.patch.bz2 Patch100: xsane-0.998-1-autoconf.patch.bz2
License: GPLv2+ License: GPLv2+
@ -112,6 +115,7 @@ done
%patch8 -p1 -b .preview-selection.patch %patch8 -p1 -b .preview-selection.patch
%patch9 -p1 -b .libpng %patch9 -p1 -b .libpng
%patch10 -p1 -b .wmclass %patch10 -p1 -b .wmclass
%patch11 -p1 -b .preview-window-size
%patch100 -p1 -b .autoconf %patch100 -p1 -b .autoconf
@ -209,6 +213,9 @@ fi
%{_datadir}/sane/xsane %{_datadir}/sane/xsane
%changelog %changelog
* Mon Sep 03 2012 Nils Philippsen <nils@redhat.com> - 0.998-12
- calculate minimum window size better for multi-head setups
* Sun Jul 22 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.998-11 * Sun Jul 22 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.998-11
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild