Patchwork [RFC,2/8] ui/input: Simplify kbd_mouse_event()

login
register
mail settings
Submitter Andreas Färber
Date June 16, 2013, 3:39 a.m.
Message ID <1371354005-26873-3-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/251648/
State New
Headers show

Comments

Andreas Färber - June 16, 2013, 3:39 a.m.
Now that the field names are bearable, there's no compelling reason to
use local variables for the fields.

Unify the four callback invokations through variables for the rotated
coordinates instead.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 ui/input.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
Gerd Hoffmann - June 17, 2013, 7:17 a.m.
On 06/16/13 05:39, Andreas Färber wrote:
> Now that the field names are bearable, there's no compelling reason to
> use local variables for the fields.
> 
> Unify the four callback invokations through variables for the rotated
> coordinates instead.

Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>

cheers,
  Gerd

Patch

diff --git a/ui/input.c b/ui/input.c
index badf6c3..28353b4 100644
--- a/ui/input.c
+++ b/ui/input.c
@@ -431,9 +431,8 @@  void kbd_put_ledstate(int ledstate)
 void kbd_mouse_event(int dx, int dy, int dz, int buttons_state)
 {
     QEMUPutMouseEntry *entry;
-    QEMUPutMouseEvent *mouse_event;
-    void *mouse_event_opaque;
     int width, height;
+    int rotated_dx, rotated_dy;
 
     if (!runstate_is_running() && !runstate_check(RUN_STATE_SUSPENDED)) {
         return;
@@ -444,10 +443,7 @@  void kbd_mouse_event(int dx, int dy, int dz, int buttons_state)
 
     entry = QTAILQ_FIRST(&mouse_handlers);
 
-    mouse_event = entry->put_event;
-    mouse_event_opaque = entry->opaque;
-
-    if (mouse_event) {
+    if (entry->put_event) {
         if (entry->absolute) {
             width = 0x7fff;
             height = 0x7fff;
@@ -458,22 +454,26 @@  void kbd_mouse_event(int dx, int dy, int dz, int buttons_state)
 
         switch (graphic_rotate) {
         case 0:
-            mouse_event(mouse_event_opaque,
-                        dx, dy, dz, buttons_state);
+            rotated_dx = dx;
+            rotated_dy = dy;
             break;
         case 90:
-            mouse_event(mouse_event_opaque,
-                        width - dy, dx, dz, buttons_state);
+            rotated_dx = width - dy;
+            rotated_dy = dx;
             break;
         case 180:
-            mouse_event(mouse_event_opaque,
-                        width - dx, height - dy, dz, buttons_state);
+            rotated_dx = width - dx;
+            rotated_dy = height - dy;
             break;
         case 270:
-            mouse_event(mouse_event_opaque,
-                        dy, height - dx, dz, buttons_state);
+            rotated_dx = dy;
+            rotated_dy = height - dx;
             break;
+        default:
+            return;
         }
+        entry->put_event(entry->opaque,
+                         rotated_dx, rotated_dy, dz, buttons_state);
     }
 }