[Spice-commits] server/inputs-channel.cpp

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Sep 2 08:21:41 UTC 2020


 server/inputs-channel.cpp |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

New commits:
commit 8bb90e55aa5cb80c7a8366c3faa0bba508b1e89f
Author: Frediano Ziglio <freddy77 at gmail.com>
Date:   Thu Aug 20 11:31:36 2020 +0100

    inputs-channel: Support more mouse buttons
    
    Extend mouse button bits support.
    Allows to support up to 16 buttons.
    
    Partly based on a patch from Kevin Pouget (RED_MOUSE_BUTTON_STATE_TO_AGENT
    macro, updated on new protocol constants).
    
    Signed-off-by: Frediano Ziglio <freddy77 at gmail.com>
    Acked-by: Kevin Pouget <kpouget at redhat.com>

diff --git a/server/inputs-channel.cpp b/server/inputs-channel.cpp
index f22421f3..80ea8a89 100644
--- a/server/inputs-channel.cpp
+++ b/server/inputs-channel.cpp
@@ -117,15 +117,16 @@ const VDAgentMouseState *InputsChannel::get_mouse_state()
     return &mouse_state;
 }
 
-#define RED_MOUSE_STATE_TO_LOCAL(state)     \
-    ((state & SPICE_MOUSE_BUTTON_MASK_LEFT) |          \
-     ((state & SPICE_MOUSE_BUTTON_MASK_MIDDLE) << 1) |   \
+// middle and right states are inverted
+// all buttons from SPICE_MOUSE_BUTTON_MASK_SIDE are mapped a bit higher
+// to avoid conflicting with some internal Qemu bit
+#define RED_MOUSE_STATE_TO_LOCAL(state)                           \
+    ((state & SPICE_MOUSE_BUTTON_MASK_LEFT) |                     \
+     ((state & (SPICE_MOUSE_BUTTON_MASK_MIDDLE|0xffe0)) << 1) |   \
      ((state & SPICE_MOUSE_BUTTON_MASK_RIGHT) >> 1))
 
-#define RED_MOUSE_BUTTON_STATE_TO_AGENT(state)                      \
-    (((state & SPICE_MOUSE_BUTTON_MASK_LEFT) ? VD_AGENT_LBUTTON_MASK : 0) |    \
-     ((state & SPICE_MOUSE_BUTTON_MASK_MIDDLE) ? VD_AGENT_MBUTTON_MASK : 0) |    \
-     ((state & SPICE_MOUSE_BUTTON_MASK_RIGHT) ? VD_AGENT_RBUTTON_MASK : 0))
+// mouse button constants are defined to be off-one between agent and SPICE protocol
+#define RED_MOUSE_BUTTON_STATE_TO_AGENT(state) ((state) << 1)
 
 void InputsChannel::activate_modifiers_watch()
 {


More information about the Spice-commits mailing list