Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added partial up/down scrolling like that which exists in evince #635

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions zathura/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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); \
Expand Down Expand Up @@ -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);
Expand Down
11 changes: 10 additions & 1 deletion zathura/shortcuts.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions zathura/zathura.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ enum {
HALF_DOWN,
FULL_UP,
FULL_DOWN,
PARTIAL_UP,
PARTIAL_DOWN,
HALF_LEFT,
HALF_RIGHT,
FULL_LEFT,
Expand Down