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
|
void
|
||||||
mieqEnqueue(DeviceIntPtr pDev, xEvent *e)
|
mieqEnqueue(DeviceIntPtr pDev, xEvent *e)
|
||||||
{
|
{
|
||||||
HWEventQueueType oldtail = miEventQueue.tail, newtail;
|
unsigned int oldtail = miEventQueue.tail, newtail;
|
||||||
EventListPtr evt;
|
EventListPtr evt;
|
||||||
int isMotion = 0;
|
int isMotion = 0;
|
||||||
int evlen;
|
int evlen;
|
||||||
|
@ -138,7 +138,7 @@ mieqEnqueue(DeviceIntPtr pDev, xEvent *e)
|
||||||
EventPtr laste;
|
EventPtr laste;
|
||||||
deviceKeyButtonPointer *lastkbp;
|
deviceKeyButtonPointer *lastkbp;
|
||||||
|
|
||||||
laste = &miEventQueue.events[(oldtail ? oldtail : QUEUE_SIZE) - 1];
|
laste = &miEventQueue.events[(oldtail - 1) % QUEUE_SIZE];
|
||||||
lastkbp = (deviceKeyButtonPointer *) laste->events->event;
|
lastkbp = (deviceKeyButtonPointer *) laste->events->event;
|
||||||
|
|
||||||
if (laste->nevents > 6) {
|
if (laste->nevents > 6) {
|
||||||
|
@ -161,9 +161,7 @@ mieqEnqueue(DeviceIntPtr pDev, xEvent *e)
|
||||||
|
|
||||||
if (isMotion && isMotion == miEventQueue.lastMotion &&
|
if (isMotion && isMotion == miEventQueue.lastMotion &&
|
||||||
oldtail != miEventQueue.head) {
|
oldtail != miEventQueue.head) {
|
||||||
if (oldtail == 0)
|
oldtail = (oldtail - 1) % QUEUE_SIZE;
|
||||||
oldtail = QUEUE_SIZE;
|
|
||||||
oldtail = oldtail - 1;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
newtail = (oldtail + 1) % QUEUE_SIZE;
|
newtail = (oldtail + 1) % QUEUE_SIZE;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user