qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] vnc,ps2: fix the PS/2 mouse work badly when connect VNC


From: Shiyuan Gao
Subject: [PATCH] vnc,ps2: fix the PS/2 mouse work badly when connect VNC
Date: Mon, 17 Jul 2023 10:59:36 +0800

When only use PS/2 mouse without usb-tablet, the mouse pointer of the
guest on the VNC will work badly that the cursor of VNC is inconsistent
with the mouse pointer of guest.

The reason is the PS/2 mouse use relative coordinates and we can't know
the initial position of the guest mouse pointer.

So move the guest mouse pointer to (0, 0) of the screen when connect the
VNC, and then move the mouse pointer to the cursor of VNC(absolute
coordinates are also relative coordinates).

On windows VM, also need disable "Enhance Pointer Precision" Option in
"Pointer Options" (Control Panel -> Mouse).

Signed-off-by: Shiyuan Gao <gaoshiyuan@baidu.com>
---
 hw/input/ps2.c | 2 +-
 ui/vnc.c       | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/hw/input/ps2.c b/hw/input/ps2.c
index 45af76a837..e1f44bd298 100644
--- a/hw/input/ps2.c
+++ b/hw/input/ps2.c
@@ -77,7 +77,7 @@
 #define MOUSE_STATUS_ENABLED    0x20
 #define MOUSE_STATUS_SCALE21    0x10
 
-#define PS2_QUEUE_SIZE      16  /* Queue size required by PS/2 protocol */
+#define PS2_QUEUE_SIZE      32  /* Queue size required by PS/2 protocol */
 #define PS2_QUEUE_HEADROOM  8   /* Queue size for keyboard command replies */
 
 /* Bits for 'modifiers' field in PS2KbdState */
diff --git a/ui/vnc.c b/ui/vnc.c
index 92964dcc0c..a1a6048ee4 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -1816,6 +1816,11 @@ static void pointer_event(VncState *vs, int button_mask, 
int x, int y)
         if (vs->last_x != -1) {
             qemu_input_queue_rel(con, INPUT_AXIS_X, x - vs->last_x);
             qemu_input_queue_rel(con, INPUT_AXIS_Y, y - vs->last_y);
+        } else {
+            qemu_input_queue_rel(con, INPUT_AXIS_X, 0 - width);
+            qemu_input_queue_rel(con, INPUT_AXIS_Y, 0 - height);
+            x = 0;
+            y = 0;
         }
         vs->last_x = x;
         vs->last_y = y;
-- 
2.27.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]