[PATCH evdev 1/4] De-duplicate event queue access.
Peter Hutterer
peter.hutterer at who-t.net
Sun Oct 10 16:23:19 PDT 2010
Factor out access to the next queue element in a static function to be
reused for button and key presses.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
src/evdev.c | 42 +++++++++++++++++++++++-------------------
1 files changed, 23 insertions(+), 19 deletions(-)
diff --git a/src/evdev.c b/src/evdev.c
index 854ef3c..e5b3065 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -268,12 +268,26 @@ static int wheel_down_button = 5;
static int wheel_left_button = 6;
static int wheel_right_button = 7;
+static EventQueuePtr
+EvdevNextInQueue(InputInfoPtr pInfo)
+{
+ EvdevPtr pEvdev = pInfo->private;
+
+ if (pEvdev->num_queue >= EVDEV_MAXQUEUE)
+ {
+ xf86Msg(X_NONE, "%s: dropping event due to full queue!\n", pInfo->name);
+ return NULL;
+ }
+
+ pEvdev->num_queue++;
+ return &pEvdev->queue[pEvdev->num_queue - 1];
+}
+
void
EvdevQueueKbdEvent(InputInfoPtr pInfo, struct input_event *ev, int value)
{
int code = ev->code + MIN_KEYCODE;
EventQueuePtr pQueue;
- EvdevPtr pEvdev = pInfo->private;
/* Filter all repeated events from device.
We'll do softrepeat in the server, but only since 1.6 */
@@ -289,36 +303,26 @@ EvdevQueueKbdEvent(InputInfoPtr pInfo, struct input_event *ev, int value)
)
return;
- if (pEvdev->num_queue >= EVDEV_MAXQUEUE)
+ if ((pQueue = EvdevNextInQueue(pInfo)))
{
- xf86Msg(X_NONE, "%s: dropping event due to full queue!\n", pInfo->name);
- return;
+ pQueue->type = EV_QUEUE_KEY;
+ pQueue->key = code;
+ pQueue->val = value;
}
-
- pQueue = &pEvdev->queue[pEvdev->num_queue];
- pQueue->type = EV_QUEUE_KEY;
- pQueue->key = code;
- pQueue->val = value;
- pEvdev->num_queue++;
}
void
EvdevQueueButtonEvent(InputInfoPtr pInfo, int button, int value)
{
EventQueuePtr pQueue;
- EvdevPtr pEvdev = pInfo->private;
- if (pEvdev->num_queue >= EVDEV_MAXQUEUE)
+ if ((pQueue = EvdevNextInQueue(pInfo)))
{
- xf86Msg(X_NONE, "%s: dropping event due to full queue!\n", pInfo->name);
- return;
+ pQueue->type = EV_QUEUE_BTN;
+ pQueue->key = button;
+ pQueue->val = value;
}
- pQueue = &pEvdev->queue[pEvdev->num_queue];
- pQueue->type = EV_QUEUE_BTN;
- pQueue->key = button;
- pQueue->val = value;
- pEvdev->num_queue++;
}
/**
--
1.7.2.3
More information about the xorg-devel
mailing list