aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2016-06-16 11:03:18 +0200
committerGerd Hoffmann <kraxel@redhat.com>2016-07-12 09:25:50 +0200
commitd4df42c43168873521632836bdffecf2f3a9f9f1 (patch)
tree08de5d9bff7ea16191f5c6dd7301565bfcda5162 /ui
parentc80276b4206d534daaaf87305df5805db1b8db02 (diff)
input-linux: factor out input_linux_handle_mouse
No functional change. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-id: 1466067800-25434-2-git-send-email-kraxel@redhat.com
Diffstat (limited to 'ui')
-rw-r--r--ui/input-linux.c102
1 files changed, 53 insertions, 49 deletions
diff --git a/ui/input-linux.c b/ui/input-linux.c
index 1d33b5c121..a932290a9f 100644
--- a/ui/input-linux.c
+++ b/ui/input-linux.c
@@ -265,6 +265,58 @@ static void input_linux_event_mouse_button(int button)
qemu_input_event_sync();
}
+static void input_linux_handle_mouse(InputLinux *il, struct input_event *event)
+{
+ if (!il->grab_active) {
+ return;
+ }
+
+ switch (event->type) {
+ case EV_KEY:
+ switch (event->code) {
+ case BTN_LEFT:
+ qemu_input_queue_btn(NULL, INPUT_BUTTON_LEFT, event->value);
+ break;
+ case BTN_RIGHT:
+ qemu_input_queue_btn(NULL, INPUT_BUTTON_RIGHT, event->value);
+ break;
+ case BTN_MIDDLE:
+ qemu_input_queue_btn(NULL, INPUT_BUTTON_MIDDLE, event->value);
+ break;
+ case BTN_GEAR_UP:
+ qemu_input_queue_btn(NULL, INPUT_BUTTON_WHEEL_UP, event->value);
+ break;
+ case BTN_GEAR_DOWN:
+ qemu_input_queue_btn(NULL, INPUT_BUTTON_WHEEL_DOWN,
+ event->value);
+ break;
+ };
+ break;
+ case EV_REL:
+ switch (event->code) {
+ case REL_X:
+ qemu_input_queue_rel(NULL, INPUT_AXIS_X, event->value);
+ break;
+ case REL_Y:
+ qemu_input_queue_rel(NULL, INPUT_AXIS_Y, event->value);
+ break;
+ case REL_WHEEL:
+ il->wheel = event->value;
+ break;
+ }
+ break;
+ case EV_SYN:
+ qemu_input_event_sync();
+ if (il->wheel != 0) {
+ input_linux_event_mouse_button((il->wheel > 0)
+ ? INPUT_BUTTON_WHEEL_UP
+ : INPUT_BUTTON_WHEEL_DOWN);
+ il->wheel = 0;
+ }
+ break;
+ }
+}
+
static void input_linux_event_mouse(void *opaque)
{
InputLinux *il = opaque;
@@ -282,55 +334,7 @@ static void input_linux_event_mouse(void *opaque)
break;
}
- /* only send event to guest when grab is active */
- if (!il->grab_active) {
- continue;
- }
-
- switch (event.type) {
- case EV_KEY:
- switch (event.code) {
- case BTN_LEFT:
- qemu_input_queue_btn(NULL, INPUT_BUTTON_LEFT, event.value);
- break;
- case BTN_RIGHT:
- qemu_input_queue_btn(NULL, INPUT_BUTTON_RIGHT, event.value);
- break;
- case BTN_MIDDLE:
- qemu_input_queue_btn(NULL, INPUT_BUTTON_MIDDLE, event.value);
- break;
- case BTN_GEAR_UP:
- qemu_input_queue_btn(NULL, INPUT_BUTTON_WHEEL_UP, event.value);
- break;
- case BTN_GEAR_DOWN:
- qemu_input_queue_btn(NULL, INPUT_BUTTON_WHEEL_DOWN,
- event.value);
- break;
- };
- break;
- case EV_REL:
- switch (event.code) {
- case REL_X:
- qemu_input_queue_rel(NULL, INPUT_AXIS_X, event.value);
- break;
- case REL_Y:
- qemu_input_queue_rel(NULL, INPUT_AXIS_Y, event.value);
- break;
- case REL_WHEEL:
- il->wheel = event.value;
- break;
- }
- break;
- case EV_SYN:
- qemu_input_event_sync();
- if (il->wheel != 0) {
- input_linux_event_mouse_button((il->wheel > 0)
- ? INPUT_BUTTON_WHEEL_UP
- : INPUT_BUTTON_WHEEL_DOWN);
- il->wheel = 0;
- }
- break;
- }
+ input_linux_handle_mouse(il, &event);
}
}