summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChase Douglas <chase.douglas@canonical.com>2011-11-21 11:41:12 -0800
committerChase Douglas <chase.douglas@canonical.com>2011-11-28 17:33:42 -0800
commit6c4e0e34c4abbc6be65b97b54d355c6306a2826e (patch)
tree54198d1e384a0ebfc66a8ccd6e4a97bdf8a1e19b
parentc4efc49239360d3b56e030d7342166056e49d71b (diff)
Change pendtail to be only a single pointer to the last event in queue
I could not wrap my head around what pendtail was attempting to do without serious effort and pen and paper. All it needs to be is a simple pointer to the last event in the queue, or NULL if there are no events. Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
-rw-r--r--dix/events.c30
-rw-r--r--include/inputstr.h2
2 files changed, 19 insertions, 13 deletions
diff --git a/dix/events.c b/dix/events.c
index 256d9d585..6487a711e 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -1128,7 +1128,7 @@ NoticeEventTime(InternalEvent *ev)
void
EnqueueEvent(InternalEvent *ev, DeviceIntPtr device)
{
- QdEventPtr tail = *syncEvents.pendtail;
+ QdEventPtr tail = syncEvents.pendtail;
QdEventPtr qe;
SpritePtr pSprite = device->spriteInfo->sprite;
int eventlen;
@@ -1199,8 +1199,10 @@ EnqueueEvent(InternalEvent *ev, DeviceIntPtr device)
qe->event = (InternalEvent *)(qe + 1);
memcpy(qe->event, event, eventlen);
if (tail)
- syncEvents.pendtail = &tail->next;
- *syncEvents.pendtail = qe;
+ tail->next = qe;
+ else
+ syncEvents.pending = qe;
+ syncEvents.pendtail = qe;
}
/**
@@ -1215,18 +1217,19 @@ EnqueueEvent(InternalEvent *ev, DeviceIntPtr device)
static void
PlayReleasedEvents(void)
{
- QdEventPtr *prev, qe;
+ QdEventPtr prev = NULL;
+ QdEventPtr qe = syncEvents.pending;
DeviceIntPtr dev;
DeviceIntPtr pDev;
- prev = &syncEvents.pending;
- while ( (qe = *prev) )
+ while (qe)
{
if (!qe->device->deviceGrab.sync.frozen)
{
- *prev = qe->next;
+ if (syncEvents.pending == qe)
+ syncEvents.pending = qe->next;
pDev = qe->device;
- if (*syncEvents.pendtail == *prev)
+ if (syncEvents.pendtail == qe)
syncEvents.pendtail = prev;
if (qe->event->any.type == ET_Motion)
CheckVirtualMotion(pDev, qe, NullWindow);
@@ -1266,10 +1269,13 @@ PlayReleasedEvents(void)
break;
/* Playing the event may have unfrozen another device. */
/* So to play it safe, restart at the head of the queue */
- prev = &syncEvents.pending;
+ qe = syncEvents.pending;
+ prev = NULL;
}
- else
- prev = &qe->next;
+ else {
+ prev = qe;
+ qe = qe->next;
+ }
}
}
@@ -5618,7 +5624,7 @@ InitEvents(void)
free(syncEvents.pending);
syncEvents.pending = next;
}
- syncEvents.pendtail = &syncEvents.pending;
+ syncEvents.pendtail = NULL;
syncEvents.playingEvents = FALSE;
syncEvents.time.months = 0;
syncEvents.time.milliseconds = 0; /* hardly matters */
diff --git a/include/inputstr.h b/include/inputstr.h
index 339529020..43372c3eb 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -649,7 +649,7 @@ typedef struct _QdEvent {
*/
typedef struct _EventSyncInfo {
QdEventPtr pending, /**< list of queued events */
- *pendtail; /**< last event in list */
+ pendtail; /**< last event in list */
/** The device to replay events for. Only set in AllowEvents(), in which
* case it is set to the device specified in the request. */
DeviceIntPtr replayDev; /* kludgy rock to put flag for */