[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH RFC 2/8] ui/input: Simplify kbd_mouse_event()
From: |
Andreas Färber |
Subject: |
[Qemu-devel] [PATCH RFC 2/8] ui/input: Simplify kbd_mouse_event() |
Date: |
Sun, 16 Jun 2013 05:39:59 +0200 |
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 <address@hidden>
---
ui/input.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
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);
}
}
--
1.8.1.4
- [Qemu-devel] [PATCH RFC 0/8] monitor: Fix mouse_button and improve mouse_move commands, Andreas Färber, 2013/06/15
- [Qemu-devel] [PATCH RFC 2/8] ui/input: Simplify kbd_mouse_event(),
Andreas Färber <=
- [Qemu-devel] [PATCH RFC 1/8] ui/input: Clean up QEMUPutMouseEntry struct, Andreas Färber, 2013/06/15
- [Qemu-devel] [PATCH RFC 3/8] ui/input: Use bool for qemu_add_mouse_event_handler(), Andreas Färber, 2013/06/15
- [Qemu-devel] [PATCH RFC 4/8] ui/input: Introduce MouseOps for qemu_add_mouse_event_handler(), Andreas Färber, 2013/06/15
- [Qemu-devel] [PATCH RFC 6/8] monitor: Eliminate global mouse buttons state for mouse_move, Andreas Färber, 2013/06/15
- [Qemu-devel] [PATCH RFC 8/8] monitor: Fix mouse_button command for absolute coordinates, Andreas Färber, 2013/06/15
- [Qemu-devel] [PATCH RFC 5/8] ui/input: Introduce MouseOps::get_buttons_state(), Andreas Färber, 2013/06/15
- [Qemu-devel] [PATCH RFC 7/8] ui/input: Introduce MouseOps::get_position(), Andreas Färber, 2013/06/15