dix: fix EnqueueEvent to work with internal events.

Note that we're only partially switched to internal events. The event in the
devices' event queue (dev->deviceGrab.sync.event) is still an XI event. The
events in syncEvents are InternalEvents only now.
This also implies fixing CheckVirtualMotion to work with internal events.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2009-01-31 08:46:43 +10:00
parent 75595ba4aa
commit daa3245c47
2 changed files with 64 additions and 67 deletions

View File

@ -708,13 +708,28 @@ CheckVirtualMotion(
{ {
SpritePtr pSprite = pDev->spriteInfo->sprite; SpritePtr pSprite = pDev->spriteInfo->sprite;
RegionPtr reg = NULL; RegionPtr reg = NULL;
DeviceEvent *ev = NULL;
if (qe) if (qe)
{ {
pSprite->hot.pScreen = qe->pScreen; ev = (DeviceEvent*)qe->event;
pSprite->hot.x = qe->event->u.keyButtonPointer.rootX; switch(ev->type)
pSprite->hot.y = qe->event->u.keyButtonPointer.rootY; {
pWin = pDev->deviceGrab.grab ? pDev->deviceGrab.grab->confineTo : NullWindow; case ET_Motion:
case ET_ButtonPress:
case ET_ButtonRelease:
case ET_KeyPress:
case ET_KeyRelease:
case ET_ProximityIn:
case ET_ProximityOut:
pSprite->hot.pScreen = qe->pScreen;
pSprite->hot.x = ev->root_x;
pSprite->hot.y = ev->root_y;
pWin = pDev->deviceGrab.grab ? pDev->deviceGrab.grab->confineTo : NullWindow;
break;
default:
break;
}
} }
if (pWin) if (pWin)
{ {
@ -783,11 +798,11 @@ CheckVirtualMotion(
if (reg) if (reg)
ConfineToShape(pDev, reg, &pSprite->hot.x, &pSprite->hot.y); ConfineToShape(pDev, reg, &pSprite->hot.x, &pSprite->hot.y);
if (qe) if (qe && ev)
{ {
qe->pScreen = pSprite->hot.pScreen; qe->pScreen = pSprite->hot.pScreen;
qe->event->u.keyButtonPointer.rootX = pSprite->hot.x; ev->root_x = pSprite->hot.x;
qe->event->u.keyButtonPointer.rootY = pSprite->hot.y; ev->root_y = pSprite->hot.y;
} }
} }
#ifdef PANORAMIX #ifdef PANORAMIX
@ -1020,21 +1035,15 @@ EnqueueEvent(xEvent *ev, DeviceIntPtr device, int count)
int eventlen; int eventlen;
DeviceEvent *event = (DeviceEvent*)ev; DeviceEvent *event = (DeviceEvent*)ev;
/* FIXME: temporary solution only. */
static int nevents;
static xEvent xi[1000]; /* enough bytes for the events we have atm */
xEvent *xE = xi;
NoticeTime((InternalEvent*)event); NoticeTime((InternalEvent*)event);
nevents = ConvertBackToXI((InternalEvent*)ev, xE);
/* Fix for key repeating bug. */ /* Fix for key repeating bug. */
if (device->key != NULL && device->key->xkbInfo != NULL && if (device->key != NULL && device->key->xkbInfo != NULL &&
xE->u.u.type == KeyRelease) event->type == ET_KeyRelease)
AccessXCancelRepeatKey(device->key->xkbInfo, xE->u.u.detail); AccessXCancelRepeatKey(device->key->xkbInfo, event->detail.key);
#if 0
/* FIXME: I'm broken now. Please fix me. */
if (DeviceEventCallback) if (DeviceEventCallback)
{ {
DeviceEventInfoRec eventinfo; DeviceEventInfoRec eventinfo;
@ -1054,35 +1063,35 @@ EnqueueEvent(xEvent *ev, DeviceIntPtr device, int count)
eventinfo.count = nevents; eventinfo.count = nevents;
CallCallbacks(&DeviceEventCallback, (pointer)&eventinfo); CallCallbacks(&DeviceEventCallback, (pointer)&eventinfo);
} }
if (xE->u.u.type == DeviceMotionNotify) #endif
if (event->type == ET_Motion)
{ {
#ifdef PANORAMIX #ifdef PANORAMIX
if(!noPanoramiXExtension) { if(!noPanoramiXExtension) {
XE_KBPTR.rootX += panoramiXdataPtr[pSprite->screen->myNum].x - event->root_x += panoramiXdataPtr[pSprite->screen->myNum].x -
panoramiXdataPtr[0].x; panoramiXdataPtr[0].x;
XE_KBPTR.rootY += panoramiXdataPtr[pSprite->screen->myNum].y - event->root_y += panoramiXdataPtr[pSprite->screen->myNum].y -
panoramiXdataPtr[0].y; panoramiXdataPtr[0].y;
} }
#endif #endif
pSprite->hotPhys.x = XE_KBPTR.rootX; pSprite->hotPhys.x = event->root_x;
pSprite->hotPhys.y = XE_KBPTR.rootY; pSprite->hotPhys.y = event->root_y;
/* do motion compression, but not if from different devices */ /* do motion compression, but not if from different devices */
if (tail && if (tail &&
(tail->event->u.u.type == DeviceMotionNotify) && (tail->event->u.any.type == ET_Motion) &&
(tail->device == device) && (tail->device == device) &&
(tail->pScreen == pSprite->hotPhys.pScreen)) (tail->pScreen == pSprite->hotPhys.pScreen))
{ {
tail->event->u.keyButtonPointer.rootX = pSprite->hotPhys.x; DeviceEvent *tailev = (DeviceEvent*)tail->event;
tail->event->u.keyButtonPointer.rootY = pSprite->hotPhys.y; tailev->root_x = pSprite->hotPhys.x;
tail->event->u.keyButtonPointer.time = XE_KBPTR.time; tailev->root_y = pSprite->hotPhys.y;
tailev->time = event->time;
tail->months = currentTime.months; tail->months = currentTime.months;
return; return;
} }
} }
eventlen = nevents * sizeof(xEvent); eventlen = event->length;
if (xE->u.u.type == GenericEvent) /* count is 1 for GenericEvents */
eventlen += ((xGenericEvent*)xE)->length * 4;
qe = xalloc(sizeof(QdEventRec) + eventlen); qe = xalloc(sizeof(QdEventRec) + eventlen);
if (!qe) if (!qe)
@ -1091,19 +1100,8 @@ EnqueueEvent(xEvent *ev, DeviceIntPtr device, int count)
qe->device = device; qe->device = device;
qe->pScreen = pSprite->hotPhys.pScreen; qe->pScreen = pSprite->hotPhys.pScreen;
qe->months = currentTime.months; qe->months = currentTime.months;
qe->event = (xEvent *)(qe + 1); qe->event = (InternalEvent *)(qe + 1);
qe->evcount = nevents; memcpy(qe->event, event, eventlen);
if (xE->u.u.type == GenericEvent)
{
memcpy(qe->event, xE, eventlen);
} else
{
xEvent *qxE;
for (qxE = qe->event; --nevents >= 0; qxE++, xE++)
{
*qxE = *xE;
}
}
if (tail) if (tail)
syncEvents.pendtail = &tail->next; syncEvents.pendtail = &tail->next;
*syncEvents.pendtail = qe; *syncEvents.pendtail = qe;
@ -1124,7 +1122,6 @@ PlayReleasedEvents(void)
QdEventPtr *prev, qe; QdEventPtr *prev, qe;
DeviceIntPtr dev; DeviceIntPtr dev;
DeviceIntPtr pDev; DeviceIntPtr pDev;
static CARD32 lastKnownMillis = 0; /* Hack, see comment below */
prev = &syncEvents.pending; prev = &syncEvents.pending;
while ( (qe = *prev) ) while ( (qe = *prev) )
@ -1135,36 +1132,37 @@ PlayReleasedEvents(void)
pDev = qe->device; pDev = qe->device;
if (*syncEvents.pendtail == *prev) if (*syncEvents.pendtail == *prev)
syncEvents.pendtail = prev; syncEvents.pendtail = prev;
if (qe->event->u.u.type == DeviceMotionNotify) if (qe->event->u.any.type == ET_Motion)
CheckVirtualMotion(pDev, qe, NullWindow); CheckVirtualMotion(pDev, qe, NullWindow);
syncEvents.time.months = qe->months; syncEvents.time.months = qe->months;
/* XXX: Hack! We can't reliably get the time from GenericEvents, syncEvents.time.milliseconds = qe->event->u.any.time;
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 #ifdef PANORAMIX
/* Translate back to the sprite screen since processInputProc /* Translate back to the sprite screen since processInputProc
will translate from sprite screen to screen 0 upon reentry will translate from sprite screen to screen 0 upon reentry
to the DIX layer */ to the DIX layer */
/* XXX: we can't do that for generic events */
if(!noPanoramiXExtension) { if(!noPanoramiXExtension) {
qe->event->u.keyButtonPointer.rootX += DeviceEvent *ev = (DeviceEvent*)(qe->event);
panoramiXdataPtr[0].x - switch(ev->type)
panoramiXdataPtr[pDev->spriteInfo->sprite->screen->myNum].x; {
qe->event->u.keyButtonPointer.rootY += case ET_Motion:
panoramiXdataPtr[0].y - case ET_ButtonPress:
panoramiXdataPtr[pDev->spriteInfo->sprite->screen->myNum].y; case ET_ButtonRelease:
case ET_KeyPress:
case ET_KeyRelease:
case ET_ProximityIn:
case ET_ProximityOut:
ev->root_x += panoramiXdataPtr[0].x -
panoramiXdataPtr[pDev->spriteInfo->sprite->screen->myNum].x;
ev->root_y += panoramiXdataPtr[0].y -
panoramiXdataPtr[pDev->spriteInfo->sprite->screen->myNum].y;
break;
default:
break;
}
} }
#endif #endif
(*qe->device->public.processInputProc)(qe->event, qe->device, (*qe->device->public.processInputProc)(qe->event, qe->device, 1);
qe->evcount);
xfree(qe); xfree(qe);
for (dev = inputInfo.devices; dev && dev->deviceGrab.sync.frozen; dev = dev->next) for (dev = inputInfo.devices; dev && dev->deviceGrab.sync.frozen; dev = dev->next)
; ;

View File

@ -516,8 +516,7 @@ typedef struct _QdEvent {
DeviceIntPtr device; DeviceIntPtr device;
ScreenPtr pScreen; /* what screen the pointer was on */ ScreenPtr pScreen; /* what screen the pointer was on */
unsigned long months; /* milliseconds is in the event */ unsigned long months; /* milliseconds is in the event */
xEvent *event; InternalEvent *event;
int evcount; } QdEventRec;
} QdEventRec;
#endif /* INPUTSTRUCT_H */ #endif /* INPUTSTRUCT_H */