From a8b82bf1e63db9eceb7ff1ac69dd744e6c236aa4 Mon Sep 17 00:00:00 2001 From: Ketmar Dark Date: Sun, 31 May 2020 01:59:28 +0300 Subject: [PATCH] added C-Space to scroll down by the whole window (with a hack to skip gaps); fixed bug with pgup on the partially scrolled first page --- src/config.h | 1 + src/zathura.c | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/config.h b/src/config.h index 8bd9c53..f077cc6 100644 --- a/src/config.h +++ b/src/config.h @@ -196,6 +196,7 @@ static const Shortcut shortcuts[] = { //{GDK_CONTROL_MASK, GDK_space, sc_navigate, NORMAL | FULLSCREEN, { NEXT } }, {0, GDK_space, sc_scroll, NORMAL | FULLSCREEN, { /*FULL_DOWN*/WINDOW_DOWN } }, {GDK_SHIFT_MASK, GDK_space, sc_scroll, NORMAL | FULLSCREEN, { /*FULL_UP*/WINDOW_UP } }, + {GDK_CONTROL_MASK, GDK_space, sc_scroll, NORMAL | FULLSCREEN, { FULL_WINDOW_DOWN } }, {0, GDK_Page_Down, sc_scroll, NORMAL | FULLSCREEN, { FULL_DOWN } }, {0, GDK_Page_Up, sc_scroll, NORMAL | FULLSCREEN, { FULL_UP } }, }; diff --git a/src/zathura.c b/src/zathura.c index 671a83e..f694e33 100644 --- a/src/zathura.c +++ b/src/zathura.c @@ -194,8 +194,8 @@ enum { PREVIOUS_GROUP, ZOOM_IN, ZOOM_OUT, ZOOM_ORIGINAL, ZOOM_SPECIFIC, FORWARD, BACKWARD, ADJUST_BESTFIT, ADJUST_WIDTH, ADJUST_NONE, CONTINUOUS, DELETE_LAST, ADD_MARKER, EVAL_MARKER, EXPAND, COLLAPSE, SELECT, GOTO_DEFAULT, GOTO_LABELS, - GOTO_OFFSET, HALF_UP, HALF_DOWN, FULL_UP, FULL_DOWN, NEXT_CHAR, PREVIOUS_CHAR, - DELETE_TO_LINE_START, APPEND_FILEPATH, NO_SEARCH, + GOTO_OFFSET, HALF_UP, HALF_DOWN, FULL_UP, FULL_DOWN, FULL_WINDOW_DOWN, + NEXT_CHAR, PREVIOUS_CHAR, DELETE_TO_LINE_START, APPEND_FILEPATH, NO_SEARCH, WINDOW_UP, WINDOW_DOWN, @@ -2700,6 +2700,7 @@ void sc_navigate (Argument *argument) { new_page = (scroll_wrap ? (new_page+1)%number_of_pages : new_page+1); } else if (argument->n == PREVIOUS) { new_page = (scroll_wrap ? (new_page+number_of_pages-1)%number_of_pages : new_page-1); + if (new_page < 0 && Zathura.PDF.page_yskip_t > 0) new_page = 0; } if (!scroll_wrap && (new_page < 0 || new_page >= number_of_pages)) return; @@ -2791,19 +2792,29 @@ void sc_scroll (Argument *argument) { } if (argument->n == WINDOW_UP || argument->n == WINDOW_DOWN || - argument->n == UP || argument->n == DOWN) + argument->n == UP || argument->n == DOWN || argument->n == FULL_WINDOW_DOWN) { adjustment = gtk_scrolled_window_get_vadjustment(Zathura.UI.view); int window_y = gtk_adjustment_get_page_size(adjustment); int pgdelta = window_y/6; if (pgdelta < 2) return; // are you nuts? - int delta = (argument->n == WINDOW_UP || argument->n == WINDOW_DOWN ? window_y-pgdelta : 64); + int delta = + argument->n == WINDOW_UP || argument->n == WINDOW_DOWN ? window_y-pgdelta : + argument->n == FULL_WINDOW_DOWN ? window_y : + 64; int prevypos = calc_current_document_screen_offset(); int st_page = Zathura.PDF.page_number; if (argument->n == WINDOW_UP || argument->n == UP) { scroll_up_pixels_no_draw(delta); } else { scroll_down_pixels_no_draw(delta); + // hack for full-page scroll, why not? + // if we're moved past the page into the gap, skip the gap too + if (Zathura.PDF.page_yskip_t >= 1.0f && Zathura.PDF.page_number+1 < Zathura.PDF.number_of_pages) { + Zathura.PDF.page_number += 1; + Zathura.PDF.page_yskip_t = 0; + Zathura.PDF.page_yskip_pix = 0; + } } // scroll? if (smooth_scrolling > 0) { -- 2.11.4.GIT