Skip to content

Commit

Permalink
spice: support mouse 4 & 5
Browse files Browse the repository at this point in the history
Resolves #5295
  • Loading branch information
osy committed May 29, 2023
1 parent 291be25 commit e8f9046
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 8 deletions.
12 changes: 4 additions & 8 deletions Platform/macOS/Display/VMMetalView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,8 @@ class VMMetalView: MTKView {
logger.trace("other mouse down: \(event.buttonNumber)")
switch event.buttonNumber {
case 2: inputDelegate?.mouseDown(button: .middle)
case 3: inputDelegate?.mouseDown(button: .up)
case 4: inputDelegate?.mouseDown(button: .down)
case 5: inputDelegate?.mouseDown(button: .side)
case 6: inputDelegate?.mouseDown(button: .extra)
case 3: inputDelegate?.mouseDown(button: .side)
case 4: inputDelegate?.mouseDown(button: .extra)
default: break
}
}
Expand All @@ -138,10 +136,8 @@ class VMMetalView: MTKView {
logger.trace("other mouse up: \(event.buttonNumber)")
switch event.buttonNumber {
case 2: inputDelegate?.mouseUp(button: .middle)
case 3: inputDelegate?.mouseUp(button: .up)
case 4: inputDelegate?.mouseUp(button: .down)
case 5: inputDelegate?.mouseUp(button: .side)
case 6: inputDelegate?.mouseUp(button: .extra)
case 3: inputDelegate?.mouseUp(button: .side)
case 4: inputDelegate?.mouseUp(button: .extra)
default: break
}
}
Expand Down
48 changes: 48 additions & 0 deletions patches/spice-0.14.3.patch
Original file line number Diff line number Diff line change
Expand Up @@ -584,3 +584,51 @@ index dbfcd440..8cdf86f5 100644
error('Python module @0@ not found'.format(module))
endif

From 8bb90e55aa5cb80c7a8366c3faa0bba508b1e89f Mon Sep 17 00:00:00 2001
From: Frediano Ziglio <freddy77@gmail.com>
Date: Thu, 20 Aug 2020 11:31:36 +0100
Subject: [PATCH] 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@gmail.com>
Acked-by: Kevin Pouget <kpouget@redhat.com>
---
server/inputs-channel.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/server/inputs-channel.c b/server/inputs-channel.c
index f22421f30..80ea8a897 100644
--- a/server/inputs-channel.c
+++ b/server/inputs-channel.c
@@ -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()
{
--
GitLab

0 comments on commit e8f9046

Please sign in to comment.