mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-01 10:06:00 +01:00
keep position while zooming
This commit is contained in:
parent
fea48f3438
commit
a51183cd66
1 changed files with 9 additions and 1 deletions
10
shortcuts.c
10
shortcuts.c
|
@ -740,6 +740,7 @@ sc_zoom(girara_session_t* session, girara_argument_t* argument, girara_event_t*
|
||||||
girara_setting_get(zathura->ui.session, "zoom-step", &value);
|
girara_setting_get(zathura->ui.session, "zoom-step", &value);
|
||||||
|
|
||||||
float zoom_step = value / 100.0f;
|
float zoom_step = value / 100.0f;
|
||||||
|
float oldzoom = zathura->document->scale;
|
||||||
|
|
||||||
/* specify new zoom value */
|
/* specify new zoom value */
|
||||||
if (argument->n == ZOOM_IN) {
|
if (argument->n == ZOOM_IN) {
|
||||||
|
@ -747,7 +748,6 @@ sc_zoom(girara_session_t* session, girara_argument_t* argument, girara_event_t*
|
||||||
} else if (argument->n == ZOOM_OUT) {
|
} else if (argument->n == ZOOM_OUT) {
|
||||||
zathura->document->scale -= zoom_step;
|
zathura->document->scale -= zoom_step;
|
||||||
} else if (argument->n == ZOOM_SPECIFIC) {
|
} else if (argument->n == ZOOM_SPECIFIC) {
|
||||||
fprintf(stderr, "t: %d\n", t);
|
|
||||||
zathura->document->scale = t / 100.0f;
|
zathura->document->scale = t / 100.0f;
|
||||||
} else {
|
} else {
|
||||||
zathura->document->scale = 1.0;
|
zathura->document->scale = 1.0;
|
||||||
|
@ -760,6 +760,14 @@ sc_zoom(girara_session_t* session, girara_argument_t* argument, girara_event_t*
|
||||||
zathura->document->scale = 10.0f;
|
zathura->document->scale = 10.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* keep 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));
|
||||||
|
gdouble valx = gtk_adjustment_get_value(view_hadjustment) / oldzoom * zathura->document->scale;
|
||||||
|
gdouble valy = gtk_adjustment_get_value(view_vadjustment) / oldzoom * zathura->document->scale;
|
||||||
|
set_adjustment(view_hadjustment, valx);
|
||||||
|
set_adjustment(view_vadjustment, valy);
|
||||||
|
|
||||||
render_all(zathura);
|
render_all(zathura);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue