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 <marwan.tngr@gmail.com>

Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
Benoît Knecht 2013-03-23 10:07:17 +00:00 committed by Sebastian Ramacher
parent c9eef95492
commit 1702fb620a
4 changed files with 12 additions and 6 deletions

View file

@ -148,6 +148,13 @@ cb_view_vadjustment_changed(GtkAdjustment* adjustment, gpointer data)
zathura_t* zathura = data; zathura_t* zathura = data;
g_return_if_fail(zathura != NULL); 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); double ratio = zathura_adjustment_get_ratio(zathura->ui.vadjustment);
zathura_adjustment_set_value_from_ratio(adjustment, ratio); zathura_adjustment_set_value_from_ratio(adjustment, ratio);
} }

View file

@ -362,11 +362,7 @@ zathura_document_set_adjust_mode(zathura_document_t* document, zathura_adjust_mo
return; return;
} }
if (mode == ZATHURA_ADJUST_BESTFIT || mode == ZATHURA_ADJUST_WIDTH) { document->adjust_mode = mode;
document->adjust_mode = mode;
} else {
document->adjust_mode = ZATHURA_ADJUST_NONE;
}
} }
unsigned int unsigned int

View file

@ -232,6 +232,8 @@ sc_focus_inputbar(girara_session_t* session, girara_argument_t* argument, girara
zathura_t* zathura = session->global.data; zathura_t* zathura = session->global.data;
g_return_val_if_fail(argument != NULL, false); 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) { if (gtk_widget_get_visible(GTK_WIDGET(session->gtk.inputbar)) == false) {
gtk_widget_show(GTK_WIDGET(session->gtk.inputbar)); gtk_widget_show(GTK_WIDGET(session->gtk.inputbar));
} }

View file

@ -85,7 +85,8 @@ typedef enum zathura_adjust_mode_e
{ {
ZATHURA_ADJUST_NONE, /**< No adjustment */ ZATHURA_ADJUST_NONE, /**< No adjustment */
ZATHURA_ADJUST_BESTFIT, /**< Adjust to best-fit */ 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; } zathura_adjust_mode_t;
/** /**