mieqEnqueue: use modulo for queue tail wrapping.
This was previously committed by Michael Daenzer, but was lost during a pull.
This commit is contained in:
parent
8396bf7c8b
commit
49136d3e9f
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user