Jumplist: record the adjustments ratios, rather than their values

This makes jumping works accurately, even if the document is scaled up or down.

Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
Marwan Tanager 2013-06-21 14:25:28 +02:00 committed by Sebastian Ramacher
parent d9f8750c86
commit 7465ad6871
2 changed files with 11 additions and 16 deletions

View File

@ -723,9 +723,10 @@ sc_jumplist(girara_session_t* session, girara_argument_t* argument,
g_return_val_if_fail(zathura->document != NULL, false); g_return_val_if_fail(zathura->document != NULL, false);
g_return_val_if_fail(zathura->jumplist.size != 0, false); g_return_val_if_fail(zathura->jumplist.size != 0, false);
const double scale = zathura_document_get_scale(zathura->document); GtkAdjustment* hadj = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(session->gtk.view));
double x = gtk_adjustment_get_value(gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(session->gtk.view))) / scale; GtkAdjustment* vadj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(session->gtk.view));
double y = gtk_adjustment_get_value(gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(session->gtk.view))) / scale; double x = zathura_adjustment_get_ratio(hadj);
double y = zathura_adjustment_get_ratio(vadj);
zathura_jump_t* jump = NULL; zathura_jump_t* jump = NULL;
zathura_jump_t* prev_jump = zathura_jumplist_current(zathura); zathura_jump_t* prev_jump = zathura_jumplist_current(zathura);
bool go_to_current = false; bool go_to_current = false;
@ -765,9 +766,10 @@ sc_jumplist(girara_session_t* session, girara_argument_t* argument,
} }
if (jump != NULL) { if (jump != NULL) {
zathura_adjustment_set_value_from_ratio(hadj, jump->x);
zathura_adjustment_set_value_from_ratio(vadj, jump->y);
zathura_document_set_current_page_number(zathura->document, jump->page); zathura_document_set_current_page_number(zathura->document, jump->page);
statusbar_page_number_update(zathura); statusbar_page_number_update(zathura);
position_set_delayed(zathura, jump->x * scale, jump->y * scale);
} }
return false; return false;

View File

@ -1234,12 +1234,9 @@ zathura_jumplist_add(zathura_t* zathura)
if (zathura->jumplist.list != NULL) { if (zathura->jumplist.list != NULL) {
unsigned int pagenum = zathura_document_get_current_page_number(zathura->document); unsigned int pagenum = zathura_document_get_current_page_number(zathura->document);
GtkAdjustment* view_vadjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view)); double x = zathura_adjustment_get_ratio(gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view)));
GtkAdjustment* view_hadjustment = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view)); double y = zathura_adjustment_get_ratio(gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view)));
double x, y;
x = gtk_adjustment_get_value(view_hadjustment) / zathura_document_get_scale(zathura->document);
y = gtk_adjustment_get_value(view_vadjustment) / zathura_document_get_scale(zathura->document);
zathura_jumplist_reset_current(zathura); zathura_jumplist_reset_current(zathura);
zathura_jump_t* cur = zathura_jumplist_current(zathura); zathura_jump_t* cur = zathura_jumplist_current(zathura);
@ -1262,13 +1259,9 @@ zathura_jumplist_save(zathura_t* zathura)
unsigned int pagenum = zathura_document_get_current_page_number(zathura->document); unsigned int pagenum = zathura_document_get_current_page_number(zathura->document);
if (cur) { if (cur) {
/* get position */
GtkAdjustment* view_vadjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view));
GtkAdjustment* view_hadjustment = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view));
cur->page = pagenum; cur->page = pagenum;
cur->x = gtk_adjustment_get_value(view_hadjustment) / zathura_document_get_scale(zathura->document); cur->x = zathura_adjustment_get_ratio(gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view)));
cur->y = gtk_adjustment_get_value(view_vadjustment) / zathura_document_get_scale(zathura->document); cur->y = zathura_adjustment_get_ratio(gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view)));
} }
} }