diff options
Diffstat (limited to 'mi')
-rw-r--r-- | mi/mi.h | 3 | ||||
-rw-r--r-- | mi/mieq.c | 143 | ||||
-rw-r--r-- | mi/mipointer.c | 14 | ||||
-rw-r--r-- | mi/mipointrst.h | 1 |
4 files changed, 97 insertions, 64 deletions
@@ -171,8 +171,7 @@ typedef struct _DeviceRec *DevicePtr; #endif extern Bool mieqInit( - DevicePtr /*pKbd*/, - DevicePtr /*pPtr*/ + void ); extern void mieqEnqueue( @@ -43,35 +43,38 @@ in this Software without prior written authorization from The Open Group. # include "pixmapstr.h" # include "inputstr.h" # include "mi.h" +# include "mipointer.h" # include "scrnintstr.h" +# include <X11/extensions/XI.h> +# include <X11/extensions/XIproto.h> +# include "extinit.h" +# include "exglobals.h" #define QUEUE_SIZE 256 typedef struct _Event { - xEvent event; - ScreenPtr pScreen; + xEvent event[2]; + int nevents; + ScreenPtr pScreen; + DeviceIntPtr pDev; } EventRec, *EventPtr; typedef struct _EventQueue { - HWEventQueueType head, tail; /* long for SetInputCheck */ - CARD32 lastEventTime; /* to avoid time running backwards */ - Bool lastMotion; - EventRec events[QUEUE_SIZE]; /* static allocation for signals */ - DevicePtr pKbd, pPtr; /* device pointer, to get funcs */ - ScreenPtr pEnqueueScreen; /* screen events are being delivered to */ - ScreenPtr pDequeueScreen; /* screen events are being dispatched to */ + HWEventQueueType head, tail; /* long for SetInputCheck */ + CARD32 lastEventTime; /* to avoid time running backwards */ + int lastMotion; /* device ID if last event motion? */ + EventRec events[QUEUE_SIZE]; /* static allocation for signals */ + ScreenPtr pEnqueueScreen; /* screen events are being delivered to */ + ScreenPtr pDequeueScreen; /* screen events are being dispatched to */ } EventQueueRec, *EventQueuePtr; static EventQueueRec miEventQueue; Bool -mieqInit (pKbd, pPtr) - DevicePtr pKbd, pPtr; +mieqInit () { miEventQueue.head = miEventQueue.tail = 0; miEventQueue.lastEventTime = GetTimeInMillis (); - miEventQueue.pKbd = pKbd; - miEventQueue.pPtr = pPtr; miEventQueue.lastMotion = FALSE; miEventQueue.pEnqueueScreen = screenInfo.screens[0]; miEventQueue.pDequeueScreen = miEventQueue.pEnqueueScreen; @@ -87,32 +90,83 @@ mieqInit (pKbd, pPtr) */ void -mieqEnqueue (e) - xEvent *e; +mieqEnqueue (xEvent *e) { - HWEventQueueType oldtail, newtail; - Bool isMotion; + HWEventQueueType oldtail = miEventQueue.tail, newtail; + int isMotion = 0; + DeviceIntPtr pDev = NULL; + deviceKeyButtonPointer *kbp = (deviceKeyButtonPointer *) e; + deviceValuator *v = (deviceValuator *) e; + EventPtr laste = &miEventQueue.events[oldtail - 1]; + deviceKeyButtonPointer *lastkbp = (deviceKeyButtonPointer *) + &laste->event[0]; + + ErrorF("mieqEnqueue: slamming an event on to the queue from %d\n", kbp->deviceid & DEVICE_BITS); + if (e->u.u.type == MotionNotify) { + miPointerAbsoluteCursor(e->u.keyButtonPointer.rootX, + e->u.keyButtonPointer.rootY, + e->u.keyButtonPointer.time); + pDev = inputInfo.pointer; + isMotion = inputInfo.pointer->id & DEVICE_BITS; + } + else if (e->u.u.type == KeyPress || e->u.u.type == KeyRelease) { + pDev = inputInfo.keyboard; + } + else if (e->u.u.type == ButtonPress || e->u.u.type == ButtonRelease) { + pDev = inputInfo.pointer; + } + else { + pDev = LookupDeviceIntRec(kbp->deviceid & DEVICE_BITS); + + /* We silently steal valuator events: just tack them on to the last + * motion event they need to be attached to. Sigh. */ + if (e->u.u.type == DeviceValuator) { + if (laste->nevents >= 6) { + ErrorF("mieqEnqueue: more than six valuator events; dropping.\n"); + return; + } + if (oldtail == miEventQueue.head || + !(lastkbp->type == DeviceMotionNotify || + lastkbp->type == DeviceButtonPress || + lastkbp->type == DeviceButtonRelease) || + ((lastkbp->deviceid & DEVICE_BITS) != + (v->deviceid & DEVICE_BITS))) { + ErrorF("mieqEnequeue: out-of-order valuator event; dropping.\n"); + return; + } + laste->event[laste->nevents++] = *e; + ErrorF("put a valuator event into the queue\n"); + return; + } + else if (e->u.u.type == DeviceMotionNotify) { + isMotion = pDev->id & DEVICE_BITS; + } + } - oldtail = miEventQueue.tail; - isMotion = e->u.u.type == MotionNotify; - if (isMotion && miEventQueue.lastMotion && oldtail != miEventQueue.head) - { + if (!pDev) + FatalError("Couldn't find device for event!\n"); + + if (isMotion && isMotion == miEventQueue.lastMotion && + oldtail != miEventQueue.head) { if (oldtail == 0) oldtail = QUEUE_SIZE; oldtail = oldtail - 1; } - else - { + else { newtail = oldtail + 1; if (newtail == QUEUE_SIZE) newtail = 0; /* Toss events which come in late */ - if (newtail == miEventQueue.head) + if (newtail == miEventQueue.head) { + ErrorF("tossed event which came in late\n"); return; + } miEventQueue.tail = newtail; } - miEventQueue.lastMotion = isMotion; - miEventQueue.events[oldtail].event = *e; + + miEventQueue.events[oldtail].event[0] = *e; + miEventQueue.events[oldtail].nevents = 1; + /* * Make sure that event times don't go backwards - this * is "unnecessary", but very useful @@ -120,18 +174,23 @@ mieqEnqueue (e) if (e->u.keyButtonPointer.time < miEventQueue.lastEventTime && miEventQueue.lastEventTime - e->u.keyButtonPointer.time < 10000) { - miEventQueue.events[oldtail].event.u.keyButtonPointer.time = + ErrorF("mieq: rewinding event time from %d to %d\n", + miEventQueue.lastEventTime, + miEventQueue.events[oldtail].event[0].u.keyButtonPointer.time); + miEventQueue.events[oldtail].event[0].u.keyButtonPointer.time = miEventQueue.lastEventTime; } miEventQueue.lastEventTime = - miEventQueue.events[oldtail].event.u.keyButtonPointer.time; + miEventQueue.events[oldtail].event[0].u.keyButtonPointer.time; miEventQueue.events[oldtail].pScreen = miEventQueue.pEnqueueScreen; + miEventQueue.events[oldtail].pDev = pDev; + + miEventQueue.lastMotion = isMotion; + ErrorF("bottom of mieqEnqueue\n"); } void -mieqSwitchScreen (pScreen, fromDIX) - ScreenPtr pScreen; - Bool fromDIX; +mieqSwitchScreen (ScreenPtr pScreen, Bool fromDIX) { miEventQueue.pEnqueueScreen = pScreen; if (fromDIX) @@ -146,7 +205,8 @@ void mieqProcessInputEvents () { EventRec *e; int x, y; - xEvent xe; + + ErrorF("mieqPIE: head %p, tail %p\n", miEventQueue.head, miEventQueue.tail); while (miEventQueue.head != miEventQueue.tail) { @@ -160,8 +220,8 @@ void mieqProcessInputEvents () if (e->pScreen != miEventQueue.pDequeueScreen) { miEventQueue.pDequeueScreen = e->pScreen; - x = e->event.u.keyButtonPointer.rootX; - y = e->event.u.keyButtonPointer.rootY; + x = e->event[0].u.keyButtonPointer.rootX; + y = e->event[0].u.keyButtonPointer.rootY; if (miEventQueue.head == QUEUE_SIZE - 1) miEventQueue.head = 0; else @@ -170,23 +230,12 @@ void mieqProcessInputEvents () } else { - xe = e->event; if (miEventQueue.head == QUEUE_SIZE - 1) miEventQueue.head = 0; else ++miEventQueue.head; - switch (xe.u.u.type) - { - case KeyPress: - case KeyRelease: - (*miEventQueue.pKbd->processInputProc) - (&xe, (DeviceIntPtr)miEventQueue.pKbd, 1); - break; - default: - (*miEventQueue.pPtr->processInputProc) - (&xe, (DeviceIntPtr)miEventQueue.pPtr, 1); - break; - } + ErrorF("calling pIP from mieqPIE\n"); + (*e->pDev->public.processInputProc)(e->event, e->pDev, e->nevents); } } } diff --git a/mi/mipointer.c b/mi/mipointer.c index 4602d4703..f52116f4b 100644 --- a/mi/mipointer.c +++ b/mi/mipointer.c @@ -490,12 +490,6 @@ miPointerMove (pScreen, x, y, time) miPointer.y = y; miPointer.pScreen = pScreen; - xE.u.u.type = MotionNotify; - xE.u.keyButtonPointer.rootX = x; - xE.u.keyButtonPointer.rootY = y; - xE.u.keyButtonPointer.time = time; - (*pScreenPriv->screenFuncs->EnqueueEvent) (&xE); - end = miPointer.history_end; start = miPointer.history_start; prev = end - 1; @@ -521,11 +515,3 @@ miPointerMove (pScreen, x, y, time) history->event.time = time; history->pScreen = pScreen; } - -void -miRegisterPointerDevice (pScreen, pDevice) - ScreenPtr pScreen; - DeviceIntPtr pDevice; -{ - miPointer.pPointer = (DevicePtr)pDevice; -} diff --git a/mi/mipointrst.h b/mi/mipointrst.h index 682f8ac88..feeb5ec09 100644 --- a/mi/mipointrst.h +++ b/mi/mipointrst.h @@ -50,7 +50,6 @@ typedef struct { Bool confined; /* pointer can't change screens */ int x, y; /* hot spot location */ int devx, devy; /* sprite position */ - DevicePtr pPointer; /* pointer device structure */ miHistoryRec history[MOTION_SIZE]; int history_start, history_end; } miPointerRec, *miPointerPtr; |