Skip to contentSkip to conversation

input: sdl: fix guest_cursor logic.

PATCH In review Gerd Hoffmann 2 participants 2 messages Mar 10, 2014 – Mar 12, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 input: sdl: fix guest_cursor logic.

Unbreaks relative mouse mode with SDL.

---
 ui/sdl.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
ui/sdl.c +11 -7
index c1a16be..4e7f920 100644
@@ -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();
 }
Signature · 1 line
1.8.3.1
#1 lore raw

ui/sdl.c static void sdl_send_mouse_event(int dx, int dy, int x, int y, int state) · line 466

Quoted 8 lines · Gerd Hoffmann
ui/sdl.c +8 -0
+        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~