[Spice-devel] [3/6] [PATCH spice] Add horizontal mouse wheel support

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


Signed-off-by: Matthew Francis <mjay.francis at gmail.com>
---
 README                  |  2 +-
 configure.ac            |  2 +-
 server/inputs-channel.c | 15 +++++++++++----
 server/spice-input.h    |  8 ++++----
 4 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/README b/README
index 4aaf6a7..1e6e677 100644
--- a/README
+++ b/README
@@ -27,7 +27,7 @@ Or to install into a private user specific location
 The following mandatory dependencies are required in order to
 build SPICE
 
-    Spice protocol >= 0.12.13
+    Spice protocol >= 0.12.14
     Pixman         >= 0.17.7
     OpenSSL
     libjpeg
diff --git a/configure.ac b/configure.ac
index fb266ad..3401dba 100644
--- a/configure.ac
+++ b/configure.ac
@@ -156,7 +156,7 @@ AS_IF([test x"$have_smartcard" = "xyes"], [
     AS_VAR_APPEND([SPICE_REQUIRES], [" libcacard >= 0.1.2"])
 ])
 
-SPICE_PROTOCOL_MIN_VER=0.12.13
+SPICE_PROTOCOL_MIN_VER=0.12.14
 PKG_CHECK_MODULES([SPICE_PROTOCOL], [spice-protocol >= $SPICE_PROTOCOL_MIN_VER])
 AC_SUBST([SPICE_PROTOCOL_MIN_VER])
 
diff --git a/server/inputs-channel.c b/server/inputs-channel.c
index f6ad27e..0e295b0 100644
--- a/server/inputs-channel.c
+++ b/server/inputs-channel.c
@@ -287,7 +287,7 @@ static bool inputs_channel_handle_message(RedChannelClient *rcc, uint16_t type,
             SpiceMouseInterface *sif;
             sif = SPICE_CONTAINEROF(mouse->base.sif, SpiceMouseInterface, base);
             sif->motion(mouse,
-                        mouse_motion->dx, mouse_motion->dy, 0,
+                        mouse_motion->dx, mouse_motion->dy, 0, 0,
                         RED_MOUSE_STATE_TO_LOCAL(mouse_motion->buttons_state));
         }
         break;
@@ -317,8 +317,13 @@ static bool inputs_channel_handle_message(RedChannelClient *rcc, uint16_t type,
     }
     case SPICE_MSGC_INPUTS_MOUSE_PRESS: {
         SpiceMsgcMousePress *mouse_press = message;
+        int dw = 0;
         int dz = 0;
-        if (mouse_press->button == SPICE_MOUSE_BUTTON_UP) {
+        if (mouse_press->button == SPICE_MOUSE_BUTTON_WHEEL_LEFT) {
+            dw = -1;
+        } else if (mouse_press->button == SPICE_MOUSE_BUTTON_WHEEL_RIGHT) {
+            dw = 1;
+        } else if (mouse_press->button == SPICE_MOUSE_BUTTON_UP) {
             dz = -1;
         } else if (mouse_press->button == SPICE_MOUSE_BUTTON_DOWN) {
             dz = 1;
@@ -327,6 +332,8 @@ static bool inputs_channel_handle_message(RedChannelClient *rcc, uint16_t type,
             if (reds_config_get_agent_mouse(reds) && reds_has_vdagent(reds)) {
                 inputs_channel->mouse_state.buttons =
                     RED_MOUSE_BUTTON_STATE_TO_AGENT(mouse_press->buttons_state) |
+                    (dw == -1 ? VD_AGENT_WLBUTTON_MASK : 0) |
+                    (dw == 1 ? VD_AGENT_WRBUTTON_MASK : 0) |
                     (dz == -1 ? VD_AGENT_UBUTTON_MASK : 0) |
                     (dz == 1 ? VD_AGENT_DBUTTON_MASK : 0);
                 reds_handle_agent_mouse_event(reds, &inputs_channel->mouse_state);
@@ -334,14 +341,14 @@ static bool inputs_channel_handle_message(RedChannelClient *rcc, uint16_t type,
                 SpiceTabletInterface *sif;
                 sif = SPICE_CONTAINEROF(inputs_channel_get_tablet(inputs_channel)->base.sif,
                                         SpiceTabletInterface, base);
-                sif->wheel(inputs_channel_get_tablet(inputs_channel), dz,
+                sif->wheel(inputs_channel_get_tablet(inputs_channel), dw, dz,
                            RED_MOUSE_STATE_TO_LOCAL(mouse_press->buttons_state));
             }
         } else if (inputs_channel_get_mouse(inputs_channel)) {
             SpiceMouseInterface *sif;
             sif = SPICE_CONTAINEROF(inputs_channel_get_mouse(inputs_channel)->base.sif,
                                     SpiceMouseInterface, base);
-            sif->motion(inputs_channel_get_mouse(inputs_channel), 0, 0, dz,
+            sif->motion(inputs_channel_get_mouse(inputs_channel), 0, 0, dw, dz,
                         RED_MOUSE_STATE_TO_LOCAL(mouse_press->buttons_state));
         }
         break;
diff --git a/server/spice-input.h b/server/spice-input.h
index dc07c4f..1e2e44f 100644
--- a/server/spice-input.h
+++ b/server/spice-input.h
@@ -48,7 +48,7 @@ struct SpiceKbdInstance {
 int spice_server_kbd_leds(SpiceKbdInstance *sin, int leds);
 
 #define SPICE_INTERFACE_MOUSE "mouse"
-#define SPICE_INTERFACE_MOUSE_MAJOR 1
+#define SPICE_INTERFACE_MOUSE_MAJOR 2
 #define SPICE_INTERFACE_MOUSE_MINOR 1
 typedef struct SpiceMouseInterface SpiceMouseInterface;
 typedef struct SpiceMouseInstance SpiceMouseInstance;
@@ -57,7 +57,7 @@ typedef struct SpiceMouseState SpiceMouseState;
 struct SpiceMouseInterface {
     SpiceBaseInterface base;
 
-    void (*motion)(SpiceMouseInstance *sin, int dx, int dy, int dz,
+    void (*motion)(SpiceMouseInstance *sin, int dx, int dy, int dw, int dz,
                    uint32_t buttons_state);
     void (*buttons)(SpiceMouseInstance *sin, uint32_t buttons_state);
 };
@@ -68,7 +68,7 @@ struct SpiceMouseInstance {
 };
 
 #define SPICE_INTERFACE_TABLET "tablet"
-#define SPICE_INTERFACE_TABLET_MAJOR 1
+#define SPICE_INTERFACE_TABLET_MAJOR 2
 #define SPICE_INTERFACE_TABLET_MINOR 1
 typedef struct SpiceTabletInterface SpiceTabletInterface;
 typedef struct SpiceTabletInstance SpiceTabletInstance;
@@ -79,7 +79,7 @@ struct SpiceTabletInterface {
 
     void (*set_logical_size)(SpiceTabletInstance* tablet, int width, int height);
     void (*position)(SpiceTabletInstance* tablet, int x, int y, uint32_t buttons_state);
-    void (*wheel)(SpiceTabletInstance* tablet, int wheel_moution, uint32_t buttons_state);
+    void (*wheel)(SpiceTabletInstance* tablet, int wheel_hmotion, int wheel_vmotion, uint32_t buttons_state);
     void (*buttons)(SpiceTabletInstance* tablet, uint32_t buttons_state);
 };
 
-- 
2.7.4



More information about the Spice-devel mailing list