From 1702fb620a5a6436d4c083951c73a33658249f53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Knecht?= Date: Sat, 23 Mar 2013 10:07:17 +0000 Subject: [PATCH] Don't scroll the document when focusing the inputbar Add a new adjust mode that is set when focusing the inputbar and disables adjusting the vertical scrollbar. As a result, focusing the inputbar doesn't scroll the document, leading to better results when changing pages from the inputbar (e.g. using bookmarks). Reported-by: Marwan Tanager Signed-off-by: Sebastian Ramacher --- callbacks.c | 7 +++++++ document.c | 6 +----- shortcuts.c | 2 ++ types.h | 3 ++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/callbacks.c b/callbacks.c index 9bd4806..4ec2382 100644 --- a/callbacks.c +++ b/callbacks.c @@ -148,6 +148,13 @@ cb_view_vadjustment_changed(GtkAdjustment* adjustment, gpointer data) zathura_t* zathura = data; g_return_if_fail(zathura != NULL); + zathura_adjust_mode_t adjust_mode = + zathura_document_get_adjust_mode(zathura->document); + + /* Don't scroll we're focusing the inputbar. */ + if (adjust_mode == ZATHURA_ADJUST_INPUTBAR) + return; + double ratio = zathura_adjustment_get_ratio(zathura->ui.vadjustment); zathura_adjustment_set_value_from_ratio(adjustment, ratio); } diff --git a/document.c b/document.c index 6b8d52b..370db98 100644 --- a/document.c +++ b/document.c @@ -362,11 +362,7 @@ zathura_document_set_adjust_mode(zathura_document_t* document, zathura_adjust_mo return; } - if (mode == ZATHURA_ADJUST_BESTFIT || mode == ZATHURA_ADJUST_WIDTH) { - document->adjust_mode = mode; - } else { - document->adjust_mode = ZATHURA_ADJUST_NONE; - } + document->adjust_mode = mode; } unsigned int diff --git a/shortcuts.c b/shortcuts.c index 2e4d138..1de5ee6 100644 --- a/shortcuts.c +++ b/shortcuts.c @@ -232,6 +232,8 @@ sc_focus_inputbar(girara_session_t* session, girara_argument_t* argument, girara zathura_t* zathura = session->global.data; g_return_val_if_fail(argument != NULL, false); + zathura_document_set_adjust_mode(zathura->document, ZATHURA_ADJUST_INPUTBAR); + if (gtk_widget_get_visible(GTK_WIDGET(session->gtk.inputbar)) == false) { gtk_widget_show(GTK_WIDGET(session->gtk.inputbar)); } diff --git a/types.h b/types.h index 8aade9a..50bacb6 100644 --- a/types.h +++ b/types.h @@ -85,7 +85,8 @@ typedef enum zathura_adjust_mode_e { ZATHURA_ADJUST_NONE, /**< No adjustment */ ZATHURA_ADJUST_BESTFIT, /**< Adjust to best-fit */ - ZATHURA_ADJUST_WIDTH /**< Adjust to width */ + ZATHURA_ADJUST_WIDTH, /**< Adjust to width */ + ZATHURA_ADJUST_INPUTBAR /**< Focusing the inputbar */ } zathura_adjust_mode_t; /**