diff mbox

input: sdl: fix guest_cursor logic.

Message ID 1394439837-10021-1-git-send-email-kraxel@redhat.com
State New
Headers show

Commit Message

Gerd Hoffmann March 10, 2014, 8:23 a.m. UTC
Unbreaks relative mouse mode with SDL.

Reported-by: Gabriel L. Somlo <gsomlo@gmail.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/sdl.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

Comments

Richard Henderson March 12, 2014, 10:13 p.m. UTC | #1
On 03/10/2014 01:23 AM, Gerd Hoffmann wrote:
> +        if (guest_cursor) {
> +            x -= guest_x;
> +            y -= guest_y;
> +            guest_x += x;
> +            guest_y += y;
> +            dx = x;
> +            dy = y;
> +        }

Why write it in this funny way?  Surely better as

  dx = x - guest_x;
  dy = y - guest_y;
  guest_x = x;
  guest_y = y;


r~
diff mbox

Patch

diff --git a/ui/sdl.c b/ui/sdl.c
index c1a16be..4e7f920 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -455,13 +455,17 @@  static void sdl_send_mouse_event(int dx, int dy, int x, int y, int state)
                              real_screen->w);
         qemu_input_queue_abs(dcl->con, INPUT_AXIS_Y, y,
                              real_screen->h);
-    } else if (guest_cursor) {
-        x -= guest_x;
-        y -= guest_y;
-        guest_x += x;
-        guest_y += y;
-        qemu_input_queue_rel(dcl->con, INPUT_AXIS_X, x);
-        qemu_input_queue_rel(dcl->con, INPUT_AXIS_Y, y);
+    } else {
+        if (guest_cursor) {
+            x -= guest_x;
+            y -= guest_y;
+            guest_x += x;
+            guest_y += y;
+            dx = x;
+            dy = y;
+        }
+        qemu_input_queue_rel(dcl->con, INPUT_AXIS_X, dx);
+        qemu_input_queue_rel(dcl->con, INPUT_AXIS_Y, dy);
     }
     qemu_input_event_sync();
 }