Commit 1702fb62 authored by Benoît Knecht's avatar Benoît Knecht Committed by Sebastian Ramacher

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: default avatarMarwan Tanager <marwan.tngr@gmail.com>
Signed-off-by: Sebastian Ramacher's avatarSebastian Ramacher <sebastian+dev@ramacher.at>
parent c9eef954
......@@ -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);
}
......
......@@ -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
......
......@@ -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));
}
......
......@@ -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;
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment