From b484451eab261a919fe94c0c0f56877f7571fc9e Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 12 Sep 2007 18:34:51 +0930 Subject: [PATCH] dix: don't try to access "time" field for GenericEvents in PlayReleasedEvent. GenericEvents can't be parsed to keyButtonPointer, and there's no guarantee that it has a time field anyway. PlayReleasedEvent needs to store the millis when we know it (core events, XI event) and just re-use them for GenericEvents. Yes, this is a hack. But it looks like the time has zero significance anyway. --- dix/events.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/dix/events.c b/dix/events.c index f13d54276..3d833ef95 100644 --- a/dix/events.c +++ b/dix/events.c @@ -1228,6 +1228,7 @@ PlayReleasedEvents(void) QdEventPtr *prev, qe; DeviceIntPtr dev; DeviceIntPtr pDev; + static CARD32 lastKnownMillis = 0; /* Hack, see comment below */ prev = &syncEvents.pending; while ( (qe = *prev) ) @@ -1241,7 +1242,17 @@ PlayReleasedEvents(void) if (qe->event->u.u.type == MotionNotify) CheckVirtualMotion(pDev, qe, NullWindow); syncEvents.time.months = qe->months; - syncEvents.time.milliseconds = qe->event->u.keyButtonPointer.time; + /* XXX: Hack! We can't reliably get the time from GenericEvents, + since we don't know which struct it may be. So we store the time + when we know it, and re-use it when we can't get it. */ + if (qe->event->u.u.type == GenericEvent) + { + syncEvents.time.milliseconds = lastKnownMillis; + } else + { + syncEvents.time.milliseconds = qe->event->u.keyButtonPointer.time; + lastKnownMillis = syncEvents.time.milliseconds; + } #ifdef PANORAMIX /* Translate back to the sprite screen since processInputProc will translate from sprite screen to screen 0 upon reentry