mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-11-14 09:23:50 +01:00
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:
parent
d9f8750c86
commit
7465ad6871
10
shortcuts.c
10
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->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;
|
||||||
|
15
zathura.c
15
zathura.c
@ -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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user