Commit 7465ad68 authored by Marwan Tanager's avatar Marwan Tanager Committed by Sebastian Ramacher

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's avatarSebastian Ramacher <sebastian+dev@ramacher.at>
parent d9f8750c
......@@ -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->jumplist.size != 0, false);
const double scale = zathura_document_get_scale(zathura->document);
double x = gtk_adjustment_get_value(gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(session->gtk.view))) / scale;
double y = gtk_adjustment_get_value(gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(session->gtk.view))) / scale;
GtkAdjustment* hadj = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(session->gtk.view));
GtkAdjustment* vadj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(session->gtk.view));
double x = zathura_adjustment_get_ratio(hadj);
double y = zathura_adjustment_get_ratio(vadj);
zathura_jump_t* jump = NULL;
zathura_jump_t* prev_jump = zathura_jumplist_current(zathura);
bool go_to_current = false;
......@@ -765,10 +766,11 @@ sc_jumplist(girara_session_t* session, girara_argument_t* argument,
}
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);
statusbar_page_number_update(zathura);
position_set_delayed(zathura, jump->x * scale, jump->y * scale);
}
}
return false;
}
......
......@@ -1234,12 +1234,9 @@ zathura_jumplist_add(zathura_t* zathura)
if (zathura->jumplist.list != NULL) {
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));
GtkAdjustment* view_hadjustment = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view));
double x, y;
double x = zathura_adjustment_get_ratio(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)));
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_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);
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->x = gtk_adjustment_get_value(view_hadjustment) / zathura_document_get_scale(zathura->document);
cur->y = gtk_adjustment_get_value(view_vadjustment) / 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 = zathura_adjustment_get_ratio(gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view)));
}
}
......
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