From de17088c918ce48de323873605f759b4ee0a1eac Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Tue, 8 May 2012 14:08:07 +0200 Subject: [PATCH] Update sc_adjust_window on ZATHURA_ADJUST_BESTFIT Closes: #200 --- shortcuts.c | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/shortcuts.c b/shortcuts.c index 9216118..49b4231 100644 --- a/shortcuts.c +++ b/shortcuts.c @@ -118,20 +118,32 @@ sc_adjust_window(girara_session_t* session, girara_argument_t* argument, } unsigned int rotation = zathura_document_get_rotation(zathura->document); - if (argument->n == ZATHURA_ADJUST_WIDTH) { - if (rotation == 0 || rotation == 180) { - zathura_document_set_scale(zathura->document, width / total_width); - } else { - zathura_document_set_scale(zathura->document, width / total_height); - } - } else if (argument->n == ZATHURA_ADJUST_BESTFIT) { - if (rotation == 0 || rotation == 180) { - zathura_document_set_scale(zathura->document, height / max_height); - } else { - zathura_document_set_scale(zathura->document, width / total_height); - } - } else { - goto error_ret; + switch (argument->n) { + case ZATHURA_ADJUST_WIDTH: + if (rotation == 0 || rotation == 180) { + zathura_document_set_scale(zathura->document, width / total_width); + } else { + zathura_document_set_scale(zathura->document, width / total_height); + } + break; + case ZATHURA_ADJUST_BESTFIT: + if (total_width < total_height) { + if (rotation == 0 || rotation == 180) { + zathura_document_set_scale(zathura->document, height / max_height); + } else { + zathura_document_set_scale(zathura->document, width / total_height); + } + } else { + if (rotation == 0 || rotation == 180) { + zathura_document_set_scale(zathura->document, width / total_width); + } else { + zathura_document_set_scale(zathura->document, height / total_width); + } + } + + break; + default: + goto error_ret; } /* keep position */