From ad1c209b69a083f78d7ee9c28f5ae2f4e16654d0 Mon Sep 17 00:00:00 2001 From: Finn Teegen Date: Wed, 10 Jan 2024 13:34:08 +0100 Subject: [PATCH] Add support for simple tap zones derf/feh#726 --- man/feh.pre | 4 ++++ src/events.c | 9 ++++++--- src/help.raw | 1 + src/options.c | 4 ++++ src/options.h | 2 ++ 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/man/feh.pre b/man/feh.pre index fdaa8781..b663df76 100644 --- a/man/feh.pre +++ b/man/feh.pre @@ -437,6 +437,10 @@ Specify as extra directory in which to search for fonts; can be used multiple times to add multiple paths. . +.It Cm --tap-zones +. +Enable tap zones for previous/next file in slide show mode +. .It Cm --force-aliasing . Disable anti-aliasing for zooming, background setting etc. diff --git a/src/events.c b/src/events.c index de9e7b3e..77798b38 100644 --- a/src/events.c +++ b/src/events.c @@ -366,9 +366,12 @@ static void feh_event_handle_ButtonRelease(XEvent * ev) } else if (opt.mode == MODE_NEXT) { opt.mode = MODE_NORMAL; winwid->mode = MODE_NORMAL; - if (winwid->type == WIN_TYPE_SLIDESHOW) - slideshow_change_image(winwid, SLIDE_NEXT, 1); - else if (winwid->type == WIN_TYPE_THUMBNAIL) { + if (winwid->type == WIN_TYPE_SLIDESHOW) { + if (opt.tap_zones && ev->xbutton.x < winwid->w / 2) + slideshow_change_image(winwid, SLIDE_PREV, 1); + else + slideshow_change_image(winwid, SLIDE_NEXT, 1); + } else if (winwid->type == WIN_TYPE_THUMBNAIL) { feh_file *thumbfile; int x, y; diff --git a/src/help.raw b/src/help.raw index e218e784..0e99c689 100644 --- a/src/help.raw +++ b/src/help.raw @@ -62,6 +62,7 @@ OPTIONS reloads image with \";\", switches to next otherwise --action[1-9] Extra actions triggered by pressing keys <1>to <9> -G, --draw-actions Show the defined actions in the image window + --tap-zones Enable tap zones for previous/next file in slide show mode --force-aliasing Disable antialiasing -m, --montage Enable montage mode -i, --index Create an index print of all images diff --git a/src/options.c b/src/options.c index 0fc656d2..ae39285e 100644 --- a/src/options.c +++ b/src/options.c @@ -419,6 +419,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) {"no-xinerama" , 0, 0, OPTION_no_xinerama}, {"draw-tinted" , 0, 0, OPTION_draw_tinted}, {"info" , 1, 0, OPTION_info}, + {"tap-zones" , 0, 0, OPTION_tap_zones}, {"force-aliasing", 0, 0, OPTION_force_aliasing}, {"no-fehbg" , 0, 0, OPTION_no_fehbg}, {"keep-zoom-vp" , 0, 0, OPTION_keep_zoom_vp}, @@ -783,6 +784,9 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) opt.draw_info = 1; } break; + case OPTION_tap_zones: + opt.tap_zones = 1; + break; case OPTION_force_aliasing: opt.force_aliasing = 1; break; diff --git a/src/options.h b/src/options.h index aa3cd910..2aed6a61 100644 --- a/src/options.h +++ b/src/options.h @@ -107,6 +107,7 @@ struct __fehoptions { char *index_info; int force_aliasing; + int tap_zones; int thumb_w; int thumb_h; int limit_w; @@ -239,6 +240,7 @@ OPTION_auto_rotate, OPTION_no_xinerama, OPTION_draw_tinted, OPTION_info, +OPTION_tap_zones, OPTION_force_aliasing, OPTION_no_fehbg, OPTION_scroll_step,