diff options
| author | Peter Hutterer <peter@cs.unisa.edu.au> | 2007-06-26 19:43:54 +0930 |
|---|---|---|
| committer | Peter Hutterer <peter@cs.unisa.edu.au> | 2007-06-27 11:58:12 +0930 |
| commit | 49136d3e9fe2d065090ee90c18a49f65fb027c9f (patch) | |
| tree | af3ef716c81d41deab2a719ac3e6e28d0be1f69a | |
| parent | 8396bf7c8b4eb6b8f2d1e1ef19887064c69591da (diff) | |
mieqEnqueue: use modulo for queue tail wrapping.
This was previously committed by Michael Daenzer, but was lost during a pull.
| -rw-r--r-- | mi/mieq.c | 8 |
1 files changed, 3 insertions, 5 deletions
@@ -119,7 +119,7 @@ mieqInit(void) void mieqEnqueue(DeviceIntPtr pDev, xEvent *e) { - HWEventQueueType oldtail = miEventQueue.tail, newtail; + unsigned int oldtail = miEventQueue.tail, newtail; EventListPtr evt; int isMotion = 0; int evlen; @@ -138,7 +138,7 @@ mieqEnqueue(DeviceIntPtr pDev, xEvent *e) EventPtr laste; deviceKeyButtonPointer *lastkbp; - laste = &miEventQueue.events[(oldtail ? oldtail : QUEUE_SIZE) - 1]; + laste = &miEventQueue.events[(oldtail - 1) % QUEUE_SIZE]; lastkbp = (deviceKeyButtonPointer *) laste->events->event; if (laste->nevents > 6) { @@ -161,9 +161,7 @@ mieqEnqueue(DeviceIntPtr pDev, xEvent *e) if (isMotion && isMotion == miEventQueue.lastMotion && oldtail != miEventQueue.head) { - if (oldtail == 0) - oldtail = QUEUE_SIZE; - oldtail = oldtail - 1; + oldtail = (oldtail - 1) % QUEUE_SIZE; } else { newtail = (oldtail + 1) % QUEUE_SIZE; |
