From 7465ad687115f9f9658433024275ca2921aa22a7 Mon Sep 17 00:00:00 2001 From: Marwan Tanager Date: Fri, 21 Jun 2013 14:25:28 +0200 Subject: [PATCH] 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 --- shortcuts.c | 12 +++++++----- zathura.c | 15 ++++----------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/shortcuts.c b/shortcuts.c index 6643a0f..bfb4cf3 100644 --- a/shortcuts.c +++ b/shortcuts.c @@ -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; } diff --git a/zathura.c b/zathura.c index f681bf1..a82fb55 100644 --- a/zathura.c +++ b/zathura.c @@ -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))); } }