I would like to bind mouse button 8
and button 9
to next and previous image. Some people want to bind scroll to next/prev image too ( see: https://github.com/eXeC64/imv/issues/175#issuecomment-576547709 ).
Please consider adding support for binds mouse button. Thank you.
I hacked
imv
to switch between images (e.g.: next/previous with the mouse wheel):diff --git a/src/imv.c b/src/imv.c index bca52fd..575ec09 100644 --- a/src/imv.c +++ b/src/imv.c @@ -463,10 +463,13 @@ static void event_handler(void *data, const struct imv_event *e) break; case IMV_EVENT_MOUSE_SCROLL: { - double x, y; - imv_window_get_mouse_position(imv->window, &x, &y); - imv_viewport_zoom(imv->view, imv->current_image, IMV_ZOOM_MOUSE, - x, y, -e->data.mouse_scroll.dy); + if (e->data.mouse_scroll.dy > 0) { + struct list *args = list_from_string("next", ' '); + command_next(args, 0, imv); + } else { + struct list *args = list_from_string("prev", ' '); + command_prev(args, 0, imv); + } } break; case IMV_EVENT_CUSTOM:This obviously can't be merged as-is, but should help as a workaround for anyone willing to build from source in the meantime.
Actually, here's a cleaner patch:
diff --git a/src/imv.c b/src/imv.c index bca52fd..edeadd3 100644 --- a/src/imv.c +++ b/src/imv.c @@ -463,10 +463,14 @@ static void event_handler(void *data, const struct imv_event *e) break; case IMV_EVENT_MOUSE_SCROLL: { - double x, y; - imv_window_get_mouse_position(imv->window, &x, &y); - imv_viewport_zoom(imv->view, imv->current_image, IMV_ZOOM_MOUSE, - x, y, -e->data.mouse_scroll.dy); + int index; + if (e->data.mouse_scroll.dy > 0) { + index = 1; + } else { + index = -1; + } + imv_navigator_select_rel(imv->navigator, index); + imv_viewport_reset_transform(imv->view); } break; case IMV_EVENT_CUSTOM:
Huh, I think I can actually make this configurable.
See: https://lists.sr.ht/~exec64/imv-devel/patches/39632
Feedback welcome.
Actually I want to bind extra mouse button for next and previous to navigate next and previous image, and still have scroll to zoom in and zoom out image. Now, I can't bind that extra mouse button to any functions.
Oh, that's slightly different.
I can try and give that a shot once I hear some feedback for this first patch.
~whynothugo - I've just tried https://lists.sr.ht/~exec64/imv-devel/patches/39632 (Gentoo / X11).
[options] mouse_wheel = navigatedoesn't work very well on my end. With
imv-dir
, I can usually go to next picture about three times just fine, then it's stuck on current image: most scroll up/down movements no longer do anything. I have to scroll at least 3 or 4 times so that it eventually registers. Sometimes, it's stuck forever on an image if I repeatedly scroll up/scroll down (once each time), I then have to scroll multiple times (either up or down) rather quickly to finally move to another image. Interestingly, this seems to only occur withjpg
andtiff
files. No issue withgif
orpng
files.Another issue specific to
svg
files: when scrolling up or down,imv
skips one file for some reason. All good with left/right arrows.Another issue when mixing
gif
andpng
files of different sizes: the next image isn't placed/scaled as it should. Sometimes it's completely zoomed out, sometimes it's zoomed in too much and placement is erratic too. Likewise, no issue with left/right arrows.This still works fine for zooming though:
[options] mouse_wheel = zoomCheers
I can't reproduce any of the above issues (I've been using the patch for over year without any issues).
My patch is pretty straightforward, and I can't imagine what's causing those errors. For example, behaviour that only reproduces with svg/gif seem wildly unrelated.
I'm not sure how to gather debug information on X11 though, so can't help much. It would be useful if someone else could test on X11.
I'm trying to bind a mouse button (the "back" thumb button, MOUSE_BTN7 ) to exit the program, is this possible? Also I don't mind the default mouse wheel for adjusting zoom, but it's MUCH too sensitive, it's about fifteen times stronger than the keyboard plus and minus key zoom, is there a way to adjust the scroll wheel sensitivity / zoom amount?