From e4b9924c4d78e74918bd9832f6c556b7a8437539 Mon Sep 17 00:00:00 2001 From: "Ignas Anikevicius (gns_ank)" Date: Mon, 16 Jul 2012 21:22:54 +0100 Subject: [PATCH] Fix BESTFIT to work well when pages-per-row > 1. There are two causes of the problem: - page_ratio should be defined differently This is because the usefull page ratio is max_height/total_width or max_width/total_height. This then changes accordingly if pages_per_row != 1, otherwise, if the pages are of the same size, the page ratios will not change, which screws up the resizing. - Sometimes we need to do height or width division diferently. This is because not always total_height or total_width is meaningful in BESTFIT condition. This commit also should fix the bug #0000226. Signed-off-by: Ignas Anikevicius (gns_ank) Signed-off-by: Sebastian Ramacher --- shortcuts.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shortcuts.c b/shortcuts.c index 39f03f9..0782083 100644 --- a/shortcuts.c +++ b/shortcuts.c @@ -122,11 +122,11 @@ sc_adjust_window(girara_session_t* session, girara_argument_t* argument, } unsigned int rotation = zathura_document_get_rotation(zathura->document); - double page_ratio = total_height / total_width; + double page_ratio = max_height / total_width; double window_ratio = height / width; if (rotation == 90 || rotation == 270) { - page_ratio = total_width / total_height; + page_ratio = max_width / total_height; } switch (argument->n) { @@ -142,13 +142,13 @@ sc_adjust_window(girara_session_t* session, girara_argument_t* argument, if (page_ratio < window_ratio) { zathura_document_set_scale(zathura->document, width / total_width); } else { - zathura_document_set_scale(zathura->document, height / total_height); + zathura_document_set_scale(zathura->document, height / max_height); } } else { if (page_ratio < window_ratio) { zathura_document_set_scale(zathura->document, width / total_height); } else { - zathura_document_set_scale(zathura->document, height / total_width); + zathura_document_set_scale(zathura->document, height / max_width); } } break;