diff options
author | Oliver McFadden <oliver.mcfadden@nokia.com> | 2009-08-02 12:03:04 +0300 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2009-08-04 16:07:17 +1000 |
commit | 69d6ff3e01263ce2d52ed18b08f054bf3fdb923c (patch) | |
tree | 117bd91d00a9e6e2ee572d7de40c6facddfba4e4 | |
parent | 6f4634111a83808bc52e7e53733cf2d3bab0cccd (diff) |
evdev: Use the EvdevPost...Event() functions in the emulation code.
This is similar to commit 1f641d75edba7394201c1c53938215bae696791b.
It provides the same functionality of queuing the (in this case
emulated) events and waiting until an EV_SYN synchronization event is
received before posting them to the server.
This preserves the order of events (both real and emulated) and ensures
that MotionNotify events will always be posted first. It also unifies
the event posting into a few small functions which improves
maintainability.
From this point on, you should never use the xf86Post...Event()
functions in new code, but rather the EvdevPost...Event() versions.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | src/draglock.c | 4 | ||||
-rw-r--r-- | src/emuMB.c | 6 | ||||
-rw-r--r-- | src/emuWheel.c | 7 | ||||
-rw-r--r-- | src/evdev.c | 33 | ||||
-rw-r--r-- | src/evdev.h | 9 |
5 files changed, 33 insertions, 26 deletions
diff --git a/src/draglock.c b/src/draglock.c index 414166f..203f25c 100644 --- a/src/draglock.c +++ b/src/draglock.c @@ -152,13 +152,13 @@ void EvdevDragLockLockButton(InputInfoPtr pInfo, unsigned int button) { EvdevPtr pEvdev = (EvdevPtr)pInfo->private; - BOOL state=0; + BOOL state = 0; /* update button state */ state = pEvdev->dragLock.lock_state[button - 1] ? FALSE : TRUE; pEvdev->dragLock.lock_state[button - 1] = state; - xf86PostButtonEvent(pInfo->dev, 0, button, state, 0, 0); + EvdevPostButtonEvent(pInfo, button, state); } /* Filter button presses looking for either a meta button or the diff --git a/src/emuMB.c b/src/emuMB.c index b29f552..dc689b6 100644 --- a/src/emuMB.c +++ b/src/emuMB.c @@ -198,7 +198,7 @@ EvdevMBEmuTimer(InputInfoPtr pInfo) pEvdev->emulateMB.pending = FALSE; if ((id = stateTab[pEvdev->emulateMB.state][4][0]) != 0) { - xf86PostButtonEvent(pInfo->dev, 0, abs(id), (id >= 0), 0, 0); + EvdevPostButtonEvent(pInfo, abs(id), (id >= 0)); pEvdev->emulateMB.state = stateTab[pEvdev->emulateMB.state][4][2]; } else { @@ -248,12 +248,12 @@ EvdevMBEmuFilterEvent(InputInfoPtr pInfo, int button, BOOL press) if ((id = stateTab[pEvdev->emulateMB.state][*btstate][0]) != 0) { - xf86PostButtonEvent(pInfo->dev, 0, abs(id), (id >= 0), 0, 0); + EvdevPostButtonEvent(pInfo, abs(id), (id >= 0)); ret = TRUE; } if ((id = stateTab[pEvdev->emulateMB.state][*btstate][1]) != 0) { - xf86PostButtonEvent(pInfo->dev, 0, abs(id), (id >= 0), 0, 0); + EvdevPostButtonEvent(pInfo, abs(id), (id >= 0)); ret = TRUE; } diff --git a/src/emuWheel.c b/src/emuWheel.c index a1c754d..b9337de 100644 --- a/src/emuWheel.c +++ b/src/emuWheel.c @@ -82,8 +82,7 @@ EvdevWheelEmuFilterButton(InputInfoPtr pInfo, unsigned int button, int value) * If the button is released early enough emit the button * press/release events */ - xf86PostButtonEvent(pInfo->dev, 0, button, 1, 0, 0); - xf86PostButtonEvent(pInfo->dev, 0, button, 0, 0, 0); + EvdevPostButtonClicks(pInfo, button, 1); } } @@ -163,10 +162,8 @@ EvdevWheelEmuInertia(InputInfoPtr pInfo, WheelAxisPtr axis, int value) /* Produce button press events for wheel motion */ while(abs(axis->traveled_distance) > pEvdev->emulateWheel.inertia) { - axis->traveled_distance -= inertia; - xf86PostButtonEvent(pInfo->dev, 0, button, 1, 0, 0); - xf86PostButtonEvent(pInfo->dev, 0, button, 0, 0, 0); + EvdevPostButtonClicks(pInfo, button, 1); } } diff --git a/src/evdev.c b/src/evdev.c index e4e6d72..9528dbf 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -24,6 +24,7 @@ * Kristian Høgsberg (krh@redhat.com) * Adam Jackson (ajax@redhat.com) * Peter Hutterer (peter.hutterer@redhat.com) + * Oliver McFadden (oliver.mcfadden@nokia.com) */ #ifdef HAVE_CONFIG_H @@ -248,8 +249,8 @@ static int wheel_down_button = 5; static int wheel_left_button = 6; static int wheel_right_button = 7; -static void -PostKbdEvent(InputInfoPtr pInfo, struct input_event *ev, int value) +void +EvdevPostKbdEvent(InputInfoPtr pInfo, struct input_event *ev, int value) { int code = ev->code + MIN_KEYCODE; static char warned[KEY_CNT]; @@ -296,8 +297,8 @@ PostKbdEvent(InputInfoPtr pInfo, struct input_event *ev, int value) pEvdev->num_queue++; } -static void -PostButtonEvent(InputInfoPtr pInfo, int button, int value) +void +EvdevPostButtonEvent(InputInfoPtr pInfo, int button, int value) { EventQueuePtr pQueue; EvdevPtr pEvdev = pInfo->private; @@ -315,14 +316,14 @@ PostButtonEvent(InputInfoPtr pInfo, int button, int value) pEvdev->num_queue++; } -static void -PostButtonClicks(InputInfoPtr pInfo, int button, int count) +void +EvdevPostButtonClicks(InputInfoPtr pInfo, int button, int count) { int i; for (i = 0; i < count; i++) { - PostButtonEvent(pInfo, button, 1); - PostButtonEvent(pInfo, button, 0); + EvdevPostButtonEvent(pInfo, button, 1); + EvdevPostButtonEvent(pInfo, button, 0); } } @@ -506,9 +507,9 @@ EvdevProcessButtonEvent(InputInfoPtr pInfo, struct input_event *ev) return; if (button) - PostButtonEvent(pInfo, button, value); + EvdevPostButtonEvent(pInfo, button, value); else - PostKbdEvent(pInfo, ev, value); + EvdevPostKbdEvent(pInfo, ev, value); } /** @@ -536,17 +537,17 @@ EvdevProcessRelativeMotionEvent(InputInfoPtr pInfo, struct input_event *ev) switch (ev->code) { case REL_WHEEL: if (value > 0) - PostButtonClicks(pInfo, wheel_up_button, value); + EvdevPostButtonClicks(pInfo, wheel_up_button, value); else if (value < 0) - PostButtonClicks(pInfo, wheel_down_button, -value); + EvdevPostButtonClicks(pInfo, wheel_down_button, -value); break; case REL_DIAL: case REL_HWHEEL: if (value > 0) - PostButtonClicks(pInfo, wheel_right_button, value); + EvdevPostButtonClicks(pInfo, wheel_right_button, value); else if (value < 0) - PostButtonClicks(pInfo, wheel_left_button, -value); + EvdevPostButtonClicks(pInfo, wheel_left_button, -value); break; /* We don't post wheel events as axis motion. */ @@ -628,7 +629,7 @@ EvdevProcessKeyEvent(InputInfoPtr pInfo, struct input_event *ev) /** * Post the relative motion events. */ -static void +void EvdevPostRelativeMotionEvents(InputInfoPtr pInfo, int *num_v, int *first_v, int v[MAX_VALUATORS]) { @@ -642,7 +643,7 @@ EvdevPostRelativeMotionEvents(InputInfoPtr pInfo, int *num_v, int *first_v, /** * Post the absolute motion events. */ -static void +void EvdevPostAbsoluteMotionEvents(InputInfoPtr pInfo, int *num_v, int *first_v, int v[MAX_VALUATORS]) { diff --git a/src/evdev.h b/src/evdev.h index 23ee003..142801c 100644 --- a/src/evdev.h +++ b/src/evdev.h @@ -25,6 +25,7 @@ * Kristian Høgsberg (krh@redhat.com) * Adam Jackson (ajax@redhat.com) * Peter Hutterer (peter@cs.unisa.edu.au) + * Oliver McFadden (oliver.mcfadden@nokia.com) */ #ifndef EVDEV_H @@ -179,6 +180,14 @@ typedef struct { EventQueueRec queue[EVDEV_MAXQUEUE]; } EvdevRec, *EvdevPtr; +/* Event posting functions */ +void EvdevPostKbdEvent(InputInfoPtr pInfo, struct input_event *ev, int value); +void EvdevPostButtonEvent(InputInfoPtr pInfo, int button, int value); +void EvdevPostButtonClicks(InputInfoPtr pInfo, int button, int count); +void EvdevPostRelativeMotionEvents(InputInfoPtr pInfo, int *num_v, int *first_v, + int v[MAX_VALUATORS]); +void EvdevPostAbsoluteMotionEvents(InputInfoPtr pInfo, int *num_v, int *first_v, + int v[MAX_VALUATORS]); unsigned int EvdevUtilButtonEventToButtonNumber(EvdevPtr pEvdev, int code); /* Middle Button emulation */ |