~exec64/imv#33: 
Allow rebinding mouse buttons

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.

Status
REPORTED
Submitter
~latipun
Assigned to
No-one
Submitted
1 year, 7 months ago
Updated
1 year, 2 months ago
Labels
No labels applied.

~whynothugo 1 year, 2 months ago

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.

~whynothugo 1 year, 2 months ago

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:

~whynothugo 1 year, 2 months ago

Huh, I think I can actually make this configurable.

~whynothugo 1 year, 2 months ago

~latipun 1 year, 2 months ago

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.

~whynothugo 1 year, 2 months ago

Oh, that's slightly different.

I can try and give that a shot once I hear some feedback for this first patch.

Register here or Log in to comment, or comment via email.