diff --git a/man/feh.pre b/man/feh.pre index ed3247a7..5557f8f7 100644 --- a/man/feh.pre +++ b/man/feh.pre @@ -531,16 +531,35 @@ When not in fullscreen: Scale images to screen size if they are too big. . In tiling environments, this also causes the image to be centered in the window. . -.It Cm --scroll-step Ar count +.It Cm --scroll-step Ar percent . -Scroll -.Ar count -pixels whenever scroll_up, scroll_down, scroll_left or scroll_right is pressed. +.Ar Percent +of window whenever scroll_up, scroll_down, scroll_left or scroll_right is pressed. +Note that this option accepts negative numbers in case you need to inverse the +scroll direction; see +.Sx KEYS CONFIG SYNTAX +to change it permanently. You can give float number to this option. If +.Ar percent +is less than 1, then it will be iterpreted as +.Ar part +of screen. I.e. .5 and 50 are the same when provided to this option. +.br +Default: 5 +. +.It Cm --scroll-page-step Ar percent +. +.Ar Percent +of window whenever scroll_page_up, scroll_page_down, scroll_page_left or +scroll_page_right is pressed. Note that this option accepts negative numbers in case you need to inverse the scroll direction; see .Sx KEYS CONFIG SYNTAX to change it permanently. -Default: 20 +For details about what +.Ar percent +means and how it could be interpreted see --scroll-step. +.br +Default: 90 . .It Cm -D , --slideshow-delay Ar float . diff --git a/src/keyevents.c b/src/keyevents.c index 83fc358b..d009ee30 100644 --- a/src/keyevents.c +++ b/src/keyevents.c @@ -480,42 +480,42 @@ void feh_event_handle_keypress(XEvent * ev) feh_thumbnail_select_prev(winwid, 1); } else if (feh_is_kp(&keys.scroll_right, keysym, state)) { - winwid->im_x -= opt.scroll_step;; + winwid->im_x -= opt.scroll_step * winwid->w; winwidget_sanitise_offsets(winwid); winwidget_render_image(winwid, 0, 1); } else if (feh_is_kp(&keys.scroll_left, keysym, state)) { - winwid->im_x += opt.scroll_step; + winwid->im_x += opt.scroll_step * winwid->w; winwidget_sanitise_offsets(winwid); winwidget_render_image(winwid, 0, 1); } else if (feh_is_kp(&keys.scroll_down, keysym, state)) { - winwid->im_y -= opt.scroll_step; + winwid->im_y -= opt.scroll_step * winwid->w; winwidget_sanitise_offsets(winwid); winwidget_render_image(winwid, 0, 1); } else if (feh_is_kp(&keys.scroll_up, keysym, state)) { - winwid->im_y += opt.scroll_step; + winwid->im_y += opt.scroll_step * winwid->w; winwidget_sanitise_offsets(winwid); winwidget_render_image(winwid, 0, 1); } else if (feh_is_kp(&keys.scroll_right_page, keysym, state)) { - winwid->im_x -= winwid->w; + winwid->im_x -= opt.scroll_page_step * winwid->w; winwidget_sanitise_offsets(winwid); winwidget_render_image(winwid, 0, 0); } else if (feh_is_kp(&keys.scroll_left_page, keysym, state)) { - winwid->im_x += winwid->w; + winwid->im_x += opt.scroll_page_step * winwid->w; winwidget_sanitise_offsets(winwid); winwidget_render_image(winwid, 0, 0); } else if (feh_is_kp(&keys.scroll_down_page, keysym, state)) { - winwid->im_y -= winwid->h; + winwid->im_y -= opt.scroll_page_step * winwid->h; winwidget_sanitise_offsets(winwid); winwidget_render_image(winwid, 0, 0); } else if (feh_is_kp(&keys.scroll_up_page, keysym, state)) { - winwid->im_y += winwid->h; + winwid->im_y += opt.scroll_page_step * winwid->h; winwidget_sanitise_offsets(winwid); winwidget_render_image(winwid, 0, 0); } diff --git a/src/options.c b/src/options.c index 8fbdbfb2..e1aa4910 100644 --- a/src/options.c +++ b/src/options.c @@ -57,7 +57,8 @@ void init_parse_options(int argc, char **argv) opt.thumb_w = 60; opt.thumb_h = 60; opt.thumb_redraw = 10; - opt.scroll_step = 20; + opt.scroll_step = 5; + opt.scroll_page_step = 90; opt.menu_font = estrdup(DEFAULT_MENU_FONT); opt.font = NULL; opt.menu_bg = estrdup(PREFIX "/share/feh/images/menubg_default.png"); @@ -401,6 +402,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) {"no-fehbg" , 0, 0, 236}, {"keep-zoom-vp" , 0, 0, 237}, {"scroll-step" , 1, 0, 238}, + {"scroll-page-step" , 1, 0, 239}, {0, 0, 0, 0} }; @@ -735,7 +737,14 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) opt.keep_zoom_vp = 1; break; case 238: - opt.scroll_step = atoi(optarg); + opt.scroll_step = atof(optarg); + if (opt.scroll_step > 1) + opt.scroll_step /= 100; + break; + case 239: + opt.scroll_page_step = atof(optarg); + if (opt.scroll_page_step > 1) + opt.scroll_page_step /= 100; break; default: break; diff --git a/src/options.h b/src/options.h index a22cc059..5fd6b077 100644 --- a/src/options.h +++ b/src/options.h @@ -110,8 +110,9 @@ struct __fehoptions { int zoom_mode; unsigned char adjust_reload; - /* signed in case someone wants to invert scrolling real quick */ - int scroll_step; + /* possible to invert scrolling */ + float scroll_step; + float scroll_page_step; unsigned int min_width, min_height, max_width, max_height;