summaryrefslogtreecommitdiff
path: root/mi
diff options
context:
space:
mode:
authorDaniel Stone <daniel@fooishbar.org>2006-10-20 00:30:28 +0300
committerDaniel Stone <daniels@endtroducing.fooishbar.org>2006-10-20 00:43:11 +0300
commitaeba855b07832354f59678e20cc29a085e42bd99 (patch)
treea2fefab9b508e639882a8cef040df707efca3c95 /mi
parenta8d3dad9d9f2b9053843e655abe463a68ba8dcb7 (diff)
move keymap copy to event processing, from enqueuing
Move the keymap copying to event processing time (in ProcessInputEvents), instead of being at event enqueuing time. Break SetCore{Pointer,Keyboard} out into separate functions. Change mieqEnqueue to take a device pointer, that asks for the _original_ device associated with this event.
Diffstat (limited to 'mi')
-rw-r--r--mi/mi.h1
-rw-r--r--mi/mieq.c152
2 files changed, 72 insertions, 81 deletions
diff --git a/mi/mi.h b/mi/mi.h
index 89d460fb7..8d9d120bd 100644
--- a/mi/mi.h
+++ b/mi/mi.h
@@ -173,6 +173,7 @@ extern Bool mieqInit(
);
extern void mieqEnqueue(
+ DeviceIntPtr /*pDev*/,
xEventPtr /*e*/
);
diff --git a/mi/mieq.c b/mi/mieq.c
index 16e638c64..0ac68d6e8 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -73,14 +73,14 @@ typedef struct _EventQueue {
static EventQueueRec miEventQueue;
Bool
-mieqInit ()
+mieqInit()
{
miEventQueue.head = miEventQueue.tail = 0;
miEventQueue.lastEventTime = GetTimeInMillis ();
miEventQueue.lastMotion = FALSE;
miEventQueue.pEnqueueScreen = screenInfo.screens[0];
miEventQueue.pDequeueScreen = miEventQueue.pEnqueueScreen;
- SetInputCheck (&miEventQueue.head, &miEventQueue.tail);
+ SetInputCheck(&miEventQueue.head, &miEventQueue.tail);
return TRUE;
}
@@ -92,57 +92,39 @@ mieqInit ()
*/
void
-mieqEnqueue (xEvent *e)
+mieqEnqueue(DeviceIntPtr pDev, xEvent *e)
{
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];
- if (e->u.u.type == MotionNotify) {
- 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;
- }
- memcpy(&(laste->event[laste->nevents++]), e, sizeof(xEvent));
+ if (e->u.u.type == MotionNotify)
+ isMotion = inputInfo.pointer->id;
+ else if (e->u.u.type == DeviceMotionNotify)
+ isMotion = pDev->id;
+
+ /* 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;
}
- else if (e->u.u.type == DeviceMotionNotify) {
- isMotion = pDev->id & DEVICE_BITS;
+ if (oldtail == miEventQueue.head ||
+ !(lastkbp->type == DeviceMotionNotify ||
+ lastkbp->type == DeviceButtonPress ||
+ lastkbp->type == DeviceButtonRelease) ||
+ (lastkbp->deviceid != v->deviceid)) {
+ ErrorF("mieqEnequeue: out-of-order valuator event; dropping.\n");
+ return;
}
+ memcpy(&(laste->event[laste->nevents++]), e, sizeof(xEvent));
+ return;
}
- if (!pDev)
- FatalError("Couldn't find device for event!\n");
-
if (isMotion && isMotion == miEventQueue.lastMotion &&
oldtail != miEventQueue.head) {
if (oldtail == 0)
@@ -164,10 +146,8 @@ mieqEnqueue (xEvent *e)
memcpy(&(miEventQueue.events[oldtail].event[0]), e, sizeof(xEvent));
miEventQueue.events[oldtail].nevents = 1;
- /*
- * Make sure that event times don't go backwards - this
- * is "unnecessary", but very useful
- */
+ /* Make sure that event times don't go backwards - this
+ * is "unnecessary", but very useful. */
if (e->u.keyButtonPointer.time < miEventQueue.lastEventTime &&
miEventQueue.lastEventTime - e->u.keyButtonPointer.time < 10000)
miEventQueue.events[oldtail].event[0].u.keyButtonPointer.time =
@@ -182,49 +162,59 @@ mieqEnqueue (xEvent *e)
}
void
-mieqSwitchScreen (ScreenPtr pScreen, Bool fromDIX)
+mieqSwitchScreen(ScreenPtr pScreen, Bool fromDIX)
{
miEventQueue.pEnqueueScreen = pScreen;
if (fromDIX)
miEventQueue.pDequeueScreen = pScreen;
}
-/*
- * Call this from ProcessInputEvents()
- */
-
-void mieqProcessInputEvents ()
+/* Call this from ProcessInputEvents(). */
+void
+mieqProcessInputEvents()
{
- EventRec *e;
- int x, y;
-
- while (miEventQueue.head != miEventQueue.tail)
- {
- if (screenIsSaved == SCREEN_SAVER_ON)
- SaveScreens (SCREEN_SAVER_OFF, ScreenSaverReset);
-
- e = &miEventQueue.events[miEventQueue.head];
- /*
- * Assumption - screen switching can only occur on motion events
- */
- if (e->pScreen != miEventQueue.pDequeueScreen)
- {
- miEventQueue.pDequeueScreen = e->pScreen;
- x = e->event[0].u.keyButtonPointer.rootX;
- y = e->event[0].u.keyButtonPointer.rootY;
- if (miEventQueue.head == QUEUE_SIZE - 1)
- miEventQueue.head = 0;
- else
- ++miEventQueue.head;
- NewCurrentScreen (miEventQueue.pDequeueScreen, x, y);
- }
- else
- {
- if (miEventQueue.head == QUEUE_SIZE - 1)
- miEventQueue.head = 0;
- else
- ++miEventQueue.head;
- (*e->pDev->public.processInputProc)(e->event, e->pDev, e->nevents);
- }
+ EventRec *e = NULL;
+ int x = 0, y = 0;
+ DeviceIntPtr dev = NULL;
+
+ while (miEventQueue.head != miEventQueue.tail) {
+ if (screenIsSaved == SCREEN_SAVER_ON)
+ SaveScreens (SCREEN_SAVER_OFF, ScreenSaverReset);
+
+ e = &miEventQueue.events[miEventQueue.head];
+ /* Assumption - screen switching can only occur on motion events. */
+ if (e->pScreen != miEventQueue.pDequeueScreen) {
+ miEventQueue.pDequeueScreen = e->pScreen;
+ x = e->event[0].u.keyButtonPointer.rootX;
+ y = e->event[0].u.keyButtonPointer.rootY;
+ if (miEventQueue.head == QUEUE_SIZE - 1)
+ miEventQueue.head = 0;
+ else
+ ++miEventQueue.head;
+ NewCurrentScreen (miEventQueue.pDequeueScreen, x, y);
+ }
+ else {
+ if (miEventQueue.head == QUEUE_SIZE - 1)
+ miEventQueue.head = 0;
+ else
+ ++miEventQueue.head;
+
+ if (e->event[0].u.u.type == KeyPress ||
+ e->event[0].u.u.type == KeyRelease) {
+ SwitchCoreKeyboard(e->pDev);
+ dev = inputInfo.keyboard;
+ }
+ else if (e->event[0].u.u.type == MotionNotify ||
+ e->event[0].u.u.type == ButtonPress ||
+ e->event[0].u.u.type == ButtonRelease) {
+ SwitchCorePointer(e->pDev);
+ dev = inputInfo.pointer;
+ }
+ else {
+ dev = e->pDev;
+ }
+
+ dev->public.processInputProc(e->event, dev, e->nevents);
+ }
}
}