[evince] [presentation] Fix scale calculation on rotated monitors



commit cb2ba938b053f63558bfba2d6cde2d66d7583ca6
Author: Carlos Garcia Campos <carlosgc gnome org>
Date:   Sat Mar 13 15:45:02 2010 +0100

    [presentation] Fix scale calculation on rotated monitors
    
    Spotted by José Aliste.

 libview/ev-view-presentation.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/libview/ev-view-presentation.c b/libview/ev-view-presentation.c
index 7d72541..17491ae 100644
--- a/libview/ev-view-presentation.c
+++ b/libview/ev-view-presentation.c
@@ -62,6 +62,7 @@ struct _EvViewPresentation
 	guint                  rotation;
 	EvPresentationState    state;
 	gdouble                scale;
+	gint                   monitor_width;
 	gint                   monitor_height;
 
 	/* Cursors */
@@ -168,9 +169,14 @@ ev_view_presentation_get_scale_for_page (EvViewPresentation *pview,
 		gdouble width, height;
 
 		ev_document_get_page_size (pview->document, page, &width, &height);
-		pview->scale = (pview->rotation == 90 || pview->rotation == 270) ?
-			pview->monitor_height / width :
-			pview->monitor_height / height;
+		if (pview->rotation == 90 || pview->rotation == 270) {
+			gdouble tmp;
+
+			tmp = width;
+			width = height;
+			height = tmp;
+		}
+		pview->scale = MIN (pview->monitor_width / width, pview->monitor_height / height);
 	}
 
 	return pview->scale;
@@ -1195,6 +1201,7 @@ init_presentation (GtkWidget *widget)
 
 	monitor_num = gdk_screen_get_monitor_at_window (screen, widget->window);
 	gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
+	pview->monitor_width = monitor.width;
 	pview->monitor_height = monitor.height;
 
 	ev_view_presentation_update_current_page (pview, pview->current_page);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]