[Spice-devel] [5/6] [PATCH vdagent] Add horizontal mouse wheel support

Matthew Francis mjay.francis at gmail.com
Wed Oct 25 11:23:51 UTC 2017


Signed-off-by: Matthew Francis <mjay.francis at gmail.com>
---
 configure.ac          |  2 +-
 src/vdagentd/uinput.c | 15 +++++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index d92b527..fcb0802 100644
--- a/configure.ac
+++ b/configure.ac
@@ -87,7 +87,7 @@ AC_ARG_ENABLE([static-uinput],
 
 PKG_CHECK_MODULES([GLIB2], [glib-2.0 >= 2.34])
 PKG_CHECK_MODULES(X, [xfixes xrandr >= 1.3 xinerama x11])
-PKG_CHECK_MODULES(SPICE, [spice-protocol >= 0.12.13])
+PKG_CHECK_MODULES(SPICE, [spice-protocol >= 0.12.14])
 PKG_CHECK_MODULES(ALSA, [alsa >= 1.0.22])
 PKG_CHECK_MODULES([DBUS], [dbus-1])
 
diff --git a/src/vdagentd/uinput.c b/src/vdagentd/uinput.c
index e2966c4..33caa19 100644
--- a/src/vdagentd/uinput.c
+++ b/src/vdagentd/uinput.c
@@ -149,6 +149,7 @@ void vdagentd_uinput_update_size(struct vdagentd_uinput **uinputp,
     /* wheel */
     ioctl(uinput->fd, UI_SET_EVBIT, EV_REL);
     ioctl(uinput->fd, UI_SET_RELBIT, REL_WHEEL);
+    ioctl(uinput->fd, UI_SET_RELBIT, REL_HWHEEL);
 
     /* abs ptr */
     ioctl(uinput->fd, UI_SET_EVBIT, EV_ABS);
@@ -198,6 +199,10 @@ void vdagentd_uinput_do_mouse(struct vdagentd_uinput **uinputp,
         { .name = "up",     .mask =  VD_AGENT_UBUTTON_MASK, .btn = 1  },
         { .name = "down",   .mask =  VD_AGENT_DBUTTON_MASK, .btn = -1 },
     };
+    static const struct button_s hwheel[] = {
+        { .name = "left",   .mask =  VD_AGENT_WLBUTTON_MASK, .btn = 1  },
+        { .name = "right",  .mask =  VD_AGENT_WRBUTTON_MASK, .btn = -1 },
+    };
     int i, down;
 
     if (*uinputp) {
@@ -247,6 +252,16 @@ void vdagentd_uinput_do_mouse(struct vdagentd_uinput **uinputp,
             uinput_send_event(uinputp, EV_REL, REL_WHEEL, wheel[i].btn);
         }
     }
+    for (i = 0; i < sizeof(hwheel)/sizeof(hwheel[0]) && *uinputp; i++) {
+        if ((uinput->last.buttons & hwheel[i].mask) ==
+                (mouse->buttons & hwheel[i].mask))
+            continue;
+        if (mouse->buttons & hwheel[i].mask) {
+            if (uinput->debug)
+                syslog(LOG_DEBUG, "mouse: hwheel-%s", hwheel[i].name);
+            uinput_send_event(uinputp, EV_REL, REL_HWHEEL, hwheel[i].btn);
+        }
+    }
 
     if (*uinputp) {
         if (uinput->debug)
-- 
2.7.4



More information about the Spice-devel mailing list