From 170c9f8ba808fb55faea47f2112ca3f7bb9a490a Mon Sep 17 00:00:00 2001 From: Tom Marshall Date: Mon, 15 Jul 2024 14:10:33 -0600 Subject: [PATCH] Added partial up/down scrolling like that which exists in evince --- zathura/config.c | 8 ++++++++ zathura/shortcuts.c | 11 ++++++++++- zathura/zathura.h | 2 ++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/zathura/config.c b/zathura/config.c index 30071301..16b2cd1e 100644 --- a/zathura/config.c +++ b/zathura/config.c @@ -380,6 +380,12 @@ void config_load_default(zathura_t* zathura) { girara_shortcut_add(gsession, 0, GDK_KEY_L, NULL, sc_scroll, (mode), PAGE_BOTTOM, NULL); \ girara_shortcut_add(gsession, 0, GDK_KEY_Right, NULL, sc_scroll, (mode), RIGHT, NULL); \ girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_t, NULL, sc_scroll, (mode), HALF_LEFT, NULL); \ + \ + girara_shortcut_add(gsession, GDK_MOD1_MASK, GDK_KEY_k, NULL, sc_scroll, (mode), PARTIAL_UP, NULL); \ + girara_shortcut_add(gsession, GDK_MOD1_MASK, GDK_KEY_j, NULL, sc_scroll, (mode), PARTIAL_DOWN, NULL); \ + girara_shortcut_add(gsession, GDK_MOD1_MASK, GDK_KEY_Up, NULL, sc_scroll, (mode), PARTIAL_UP, NULL); \ + girara_shortcut_add(gsession, GDK_MOD1_MASK, GDK_KEY_Down, NULL, sc_scroll, (mode), PARTIAL_DOWN, NULL); \ + \ girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_d, NULL, sc_scroll, (mode), HALF_DOWN, NULL); \ girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_u, NULL, sc_scroll, (mode), HALF_UP, NULL); \ girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_y, NULL, sc_scroll, (mode), HALF_RIGHT, NULL); \ @@ -609,6 +615,8 @@ void config_load_default(zathura_t* zathura) { girara_argument_mapping_add(gsession, "full-up", FULL_UP); girara_argument_mapping_add(gsession, "half-down", HALF_DOWN); girara_argument_mapping_add(gsession, "half-up", HALF_UP); + girara_argument_mapping_add(gsession, "partial-down", PARTIAL_DOWN); + girara_argument_mapping_add(gsession, "partial-up", PARTIAL_UP); girara_argument_mapping_add(gsession, "full-right", FULL_RIGHT); girara_argument_mapping_add(gsession, "full-left", FULL_LEFT); girara_argument_mapping_add(gsession, "half-right", HALF_RIGHT); diff --git a/zathura/shortcuts.c b/zathura/shortcuts.c index f3355203..79f2d63c 100644 --- a/zathura/shortcuts.c +++ b/zathura/shortcuts.c @@ -587,7 +587,7 @@ bool sc_scroll(girara_session_t* session, girara_argument_t* argument, girara_ev /* compute the direction of scrolling */ double direction = 1.0; if ((argument->n == LEFT) || (argument->n == FULL_LEFT) || (argument->n == HALF_LEFT) || (argument->n == UP) || - (argument->n == FULL_UP) || (argument->n == HALF_UP)) { + (argument->n == FULL_UP) || (argument->n == HALF_UP) || (argument->n == PARTIAL_UP)) { direction = -1.0; } @@ -612,6 +612,11 @@ bool sc_scroll(girara_session_t* session, girara_argument_t* argument, girara_ev pos_y += direction * 0.5 * vstep; break; + case PARTIAL_UP: + case PARTIAL_DOWN: + pos_y += direction * t * (scroll_step * 0.2) / (double)doc_height; + break; + case HALF_LEFT: case HALF_RIGHT: pos_x += direction * 0.5 * hstep; @@ -670,11 +675,13 @@ bool sc_scroll(girara_session_t* session, girara_argument_t* argument, girara_ev case FULL_UP: case HALF_UP: + case PARTIAL_UP: page_number_to_position(zathura->document, new_page_id, 0.0, 1.0, &dummy, &pos_y); break; case FULL_DOWN: case HALF_DOWN: + case PARTIAL_DOWN: page_number_to_position(zathura->document, new_page_id, 0.0, 0.0, &dummy, &pos_y); break; } @@ -1098,11 +1105,13 @@ bool sc_navigate_index(girara_session_t* session, girara_argument_t* argument, g } break; case HALF_UP: + case PARTIAL_UP: gtk_tree_path_free(path); path = gtk_tree_path_copy(start_path); need_to_scroll = TRUE; break; case HALF_DOWN: + case PARTIAL_DOWN: gtk_tree_path_free(path); path = gtk_tree_path_copy(end_path); need_to_scroll = TRUE; diff --git a/zathura/zathura.h b/zathura/zathura.h index 07863b4a..2d414342 100644 --- a/zathura/zathura.h +++ b/zathura/zathura.h @@ -54,6 +54,8 @@ enum { HALF_DOWN, FULL_UP, FULL_DOWN, + PARTIAL_UP, + PARTIAL_DOWN, HALF_LEFT, HALF_RIGHT, FULL_LEFT,