[PATCH 10/16] dmx: remove dmx-internal event queue.

Peter Hutterer peter.hutterer at who-t.net
Wed Sep 9 23:54:16 PDT 2009


The EQ is in the DIX now.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 hw/dmx/dmxcursor.c          |    4 +-
 hw/dmx/dmxinput.c           |    4 -
 hw/dmx/dmxinput.h           |    2 -
 hw/dmx/input/dmxeq.c        |  206 -------------------------------------------
 hw/dmx/input/dmxevents.c    |  144 +++++++++++++-----------------
 hw/dmx/input/dmxinputinit.c |    8 +--
 6 files changed, 65 insertions(+), 303 deletions(-)

diff --git a/hw/dmx/dmxcursor.c b/hw/dmx/dmxcursor.c
index e8a1845..cbadf62 100644
--- a/hw/dmx/dmxcursor.c
+++ b/hw/dmx/dmxcursor.c
@@ -195,8 +195,8 @@ miPointerScreenFuncRec dmxPointerCursorFuncs =
     dmxCursorOffScreen,
     dmxCrossScreen,
     dmxWarpCursor,
-    dmxeqEnqueue,        /*XXX incompatible type/function! */
-    dmxeqSwitchScreen
+    NULL,
+    NULL,
 };
 
 
diff --git a/hw/dmx/dmxinput.c b/hw/dmx/dmxinput.c
index 83f8a4a..5203e1a 100644
--- a/hw/dmx/dmxinput.c
+++ b/hw/dmx/dmxinput.c
@@ -71,10 +71,6 @@ void InitInput(int argc, char **argv)
     
     for (i = 0, dmxInput = &dmxInputs[0]; i < dmxNumInputs; i++, dmxInput++)
         dmxInputInit(dmxInput);
-    if (!dmxeqInitialized()) {
-        dmxLog(dmxWarning, "Use keyboard/mouse pair with the first -input\n");
-        dmxLog(dmxFatal,   "At least one core keyboard/mouse pair required\n");
-    }
 
     mieqInit();
 }
diff --git a/hw/dmx/dmxinput.h b/hw/dmx/dmxinput.h
index 7af7b18..c60ce95 100644
--- a/hw/dmx/dmxinput.h
+++ b/hw/dmx/dmxinput.h
@@ -140,8 +140,6 @@ extern void dmxInputLogDevices(void);
 extern void dmxUpdateWindowInfo(DMXUpdateType type, WindowPtr pWindow);
 
 /* These functions are defined in input/dmxeq.c */
-extern Bool dmxeqInitialized(void);
-extern void dmxeqEnqueue(DeviceIntPtr pDev, xEvent *e);
 extern void dmxeqSwitchScreen(DeviceIntPtr pDev, ScreenPtr pScreen, Bool fromDIX);
 
 /* This type is used in input/dmxevents.c.  Also, these functions are
diff --git a/hw/dmx/input/dmxeq.c b/hw/dmx/input/dmxeq.c
index 3c2b44c..812a8f5 100644
--- a/hw/dmx/input/dmxeq.c
+++ b/hw/dmx/input/dmxeq.c
@@ -88,209 +88,3 @@
 #define DMXDBG2(f,a,b)
 #define DMXDBG5(f,a,b,c,d,e)
 #endif
-
-/** The size of our queue.  (The queue provided by mi/mieq.c has a size
- * of 256.) */
-#define QUEUE_SIZE  256
-
-/** Information about the event. */
-typedef struct _Event {
-    xEvent	   event;    /**< Event. */
-    ScreenPtr	   pScreen;  /**< Screen on which event occurred. */
-    deviceValuator valuator; /**< XInput device valuator information. */
-    DeviceIntPtr   pDev;
-} EventRec, *EventPtr;
-
-/** Event queue. */
-typedef struct _EventQueue {
-    HWEventQueueType head; /**< Queue head; must be long for SetInputCheck. */ 
-    HWEventQueueType tail; /**< Queue tail; must be long for SetInputCheck. */ 
-    CARD32           lastEventTime; /**< To avoid time running backwards. */
-    Bool	     lastMotion;    /**< True if last event was motion.  */
-    EventRec         events[QUEUE_SIZE]; /**< Static allocation for signals. */
-    DevicePtr	     pKbd, pPtr;    /**< Device pointers (to get funcs) */
-    ScreenPtr	     pEnqueueScreen;/**< Screen events are delivered to. */
-    ScreenPtr	     pDequeueScreen;/**< Screen events are dispatched to. */
-} EventQueueRec, *EventQueuePtr;
-
-static EventQueueRec dmxEventQueue;
-static Bool          dmxeqInitializedFlag = FALSE;
-
-Bool dmxeqInitialized(void)
-{
-    return dmxeqInitializedFlag;
-}
-
-Bool dmxeqInit(DevicePtr pKbd, DevicePtr pPtr)
-{
-    static unsigned long dmxGeneration = 0;
-    
-    if (dmxGeneration == serverGeneration && dmxeqInitializedFlag)
-        return FALSE;
-    dmxGeneration                = serverGeneration;
-    dmxeqInitializedFlag         = TRUE;
-    dmxEventQueue.head           = 0;
-    dmxEventQueue.tail           = 0;
-    dmxEventQueue.lastEventTime  = GetTimeInMillis();
-    dmxEventQueue.pKbd           = pKbd;
-    dmxEventQueue.pPtr           = pPtr;
-    dmxEventQueue.lastMotion     = FALSE;
-    dmxEventQueue.pEnqueueScreen = screenInfo.screens[0];
-    dmxEventQueue.pDequeueScreen = dmxEventQueue.pEnqueueScreen;
-    SetInputCheck(&dmxEventQueue.head, &dmxEventQueue.tail);
-    return TRUE;
-}
-
-/**
- * This function adds an event to the end of the queue.  If the event is
- * an XInput event, then the next event (the valuator event) is also
- * stored in the queue.  If the new event has a time before the time of
- * the last event currently on the queue, then the time is updated for
- * the new event.
- *
- * Must be reentrant with ProcessInputEvents.  Assumption: dmxeqEnqueue
- * will never be interrupted.  If this is called from both signal
- * handlers and regular code, make sure the signal is suspended when
- * called from regular code.
- */
-
-void dmxeqEnqueue(DeviceIntPtr pDev, xEvent *e)
-{
-    HWEventQueueType oldtail, newtail;
-    Bool             isMotion;
-    deviceKeyButtonPointer *ev;
-
-    oldtail                               = dmxEventQueue.tail;
-    isMotion                              = e->u.u.type == MotionNotify;
-    if (isMotion
-        && dmxEventQueue.lastMotion
-        && oldtail != dmxEventQueue.head) {
-	if (oldtail == 0) oldtail = QUEUE_SIZE;
-	oldtail = oldtail - 1;
-    } else {
-    	newtail = oldtail + 1;
-    	if (newtail == QUEUE_SIZE) newtail = 0;
-    	/* Toss events which come in late */
-    	if (newtail == dmxEventQueue.head) return;
-	dmxEventQueue.tail = newtail;
-    }
-    DMXDBG2("dmxeqEnqueue %d %d\n", dmxEventQueue.head, dmxEventQueue.tail);
-    dmxEventQueue.lastMotion              = isMotion;
-    dmxEventQueue.events[oldtail].pScreen = dmxEventQueue.pEnqueueScreen;
-
-                                /* Store the event in the queue */
-    dmxEventQueue.events[oldtail].event   = *e;
-    dmxEventQueue.events[oldtail].pDev    = pDev;
-                            /* If this is an XInput event, store the
-                             * valuator event, too */
-    ev = (deviceKeyButtonPointer *)e;
-    if (e->u.u.type >= LASTEvent && (ev->deviceid & MORE_EVENTS))
-        dmxEventQueue.events[oldtail].valuator = *(deviceValuator *)(ev+1);
-
-                                /* Make sure that event times don't go
-                                 * backwards - this is "unnecessary",
-                                 * but very useful */
-    if (e->u.keyButtonPointer.time < dmxEventQueue.lastEventTime
-        && dmxEventQueue.lastEventTime - e->u.keyButtonPointer.time < 10000) {
-	dmxEventQueue.events[oldtail].event.u.keyButtonPointer.time =
-	    dmxEventQueue.lastEventTime;
-    }
-}
-
-/** Make \a pScreen the new screen for enqueueing events.  If \a fromDIX
- * is TRUE, also make \a pScreen the new screen for dequeuing events. */
-void dmxeqSwitchScreen(DeviceIntPtr pDev, ScreenPtr pScreen, Bool fromDIX)
-{
-    dmxEventQueue.pEnqueueScreen = pScreen;
-    if (fromDIX) dmxEventQueue.pDequeueScreen = pScreen;
-}
-
-static void dmxeqProcessXInputEvent(xEvent *xe, EventRec *e)
-{
-    deviceKeyButtonPointer *ev     = (deviceKeyButtonPointer *)xe;
-    int                    id      = ev->deviceid & DEVICE_BITS;
-    DeviceIntPtr           pDevice;
-    
-    dixLookupDevice(&pDevice, id, serverClient, DixUnknownAccess);
-    if (!pDevice) {
-        dmxLog(dmxError, "dmxeqProcessInputEvents: id %d not found\n", id);
-        return;
-    }
-
-    if (!pDevice->public.processInputProc) {
-        dmxLog(dmxError,
-               "dmxeqProcessInputEvents: no processInputProc for"
-               " device id %d (%s)\n", id, pDevice->name);
-        return;
-    }
-    
-    if (ev->deviceid & MORE_EVENTS) {
-        xe[1] = *(xEvent *)(&e->valuator);
-        pDevice->public.processInputProc(xe, pDevice, 2);
-    } else {
-        pDevice->public.processInputProc(xe, pDevice, 1);
-    }
-}
-
-/**
- * This function is called from #ProcessInputEvents() to remove events
- * from the queue and process them.
- */
-void dmxeqProcessInputEvents(void)
-{
-    EventRec	*e;
-    int		x, y;
-    xEvent	xe[2];
-
-    while (dmxEventQueue.head != dmxEventQueue.tail) {
-        dmxDPMSWakeup();        /* Handles screen saver and DPMS */
-	e = &dmxEventQueue.events[dmxEventQueue.head];
-        DMXDBG5("dmxeqProcessInputEvents: type=%d screen=%p,%p root=%d,%d\n",
-                e->event.u.u.type,
-                e->pScreen, dmxEventQueue.pDequeueScreen,
-                e->event.u.keyButtonPointer.rootX,
-                e->event.u.keyButtonPointer.rootY);
-	/*
-	 * Assumption - screen switching can only occur on core motion events
-	 */
-	if (e->event.u.u.type == MotionNotify
-            && e->pScreen != dmxEventQueue.pDequeueScreen) {
-	    dmxEventQueue.pDequeueScreen = e->pScreen;
-	    x = e->event.u.keyButtonPointer.rootX;
-	    y = e->event.u.keyButtonPointer.rootY;
-	    if (dmxEventQueue.head == QUEUE_SIZE - 1) dmxEventQueue.head = 0;
-	    else                                      ++dmxEventQueue.head;
-	    NewCurrentScreen(e->pDev, dmxEventQueue.pDequeueScreen, x, y);
-	} else {
-	    xe[0] = e->event;
-	    if (dmxEventQueue.head == QUEUE_SIZE - 1) dmxEventQueue.head = 0;
-	    else                                      ++dmxEventQueue.head;
-	    switch (xe[0].u.u.type) {
-	    case KeyPress:
-	    case KeyRelease:
-                if (!dmxEventQueue.pKbd) {
-                    dmxLog(dmxError, "dmxeqProcessInputEvents: No keyboard\n");
-                    return;
-                }
-                dmxEventQueue.pKbd
-                    ->processInputProc(xe,
-                                       (DeviceIntPtr)dmxEventQueue.pKbd, 1);
-	    	break;
-            default:
-                dmxeqProcessXInputEvent(xe, e);
-                break;
-            case ButtonPress:
-            case ButtonRelease:
-            case MotionNotify:
-                if (!dmxEventQueue.pPtr) {
-                    dmxLog(dmxError, "dmxeqProcessInputEvents: No mouse\n");
-                    return;
-                }
-                dmxEventQueue.pPtr
-                    ->processInputProc(xe,
-                                       (DeviceIntPtr)dmxEventQueue.pPtr, 1);
-	    	break;
-	    }
-	}
-    }
-}
diff --git a/hw/dmx/input/dmxevents.c b/hw/dmx/input/dmxevents.c
index e7c382b..0b0813a 100644
--- a/hw/dmx/input/dmxevents.c
+++ b/hw/dmx/input/dmxevents.c
@@ -155,59 +155,6 @@ static int dmxCheckFunctionKeys(DMXLocalInputInfoPtr dmxLocal,
     return 0;
 }
 
-static void dmxEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal, xEvent *e,
-                               DMXBlockType block)
-{
-    xEvent                 xE[2];
-    deviceKeyButtonPointer *xev      = (deviceKeyButtonPointer *)xE;
-    deviceValuator         *xv       = (deviceValuator *)xev+1;
-    DeviceIntPtr           pDevice   = dmxLocal->pDevice;
-    DMXInputInfo           *dmxInput = &dmxInputs[dmxLocal->inputIdx];
-    int                    type      = e->u.u.type;
-
-    switch (e->u.u.type) {
-    case KeyPress:
-        type = DeviceKeyPress;
-        break;
-    case KeyRelease:
-        type = DeviceKeyRelease;
-        break;
-    case ButtonPress:
-        type = DeviceButtonPress;
-        break;
-    case ButtonRelease:
-        type = DeviceButtonRelease;
-        break;
-    case MotionNotify:
-        dmxLog(dmxError,
-               "dmxEnqueueExtEvent: MotionNotify not allowed here\n");
-        return;
-    default:
-        if (e->u.u.type == ProximityIn || e->u.u.type == ProximityOut)
-            break;
-        dmxLogInput(dmxInput,
-                    "dmxEnqueueExtEvent: Unhandled %s event (%d)\n",
-                    e->u.u.type >= LASTEvent ? "extension" : "non-extension",
-                    e->u.u.type);
-        return;
-    }
-
-    xev->type          = type;
-    xev->detail        = e->u.u.detail;
-    xev->deviceid      = pDevice->id | MORE_EVENTS;
-    xev->time          = e->u.keyButtonPointer.time;
-
-    xv->type           = DeviceValuator;
-    xv->deviceid       = pDevice->id;
-    xv->num_valuators  = 0;
-    xv->first_valuator = 0;
-
-    if (block)
-        dmxSigioBlock();
-    dmxeqEnqueue(pDevice, xE);
-    if (block)
-        dmxSigioUnblock();
-}
 
 DMXScreenInfo *dmxFindFirstScreen(int x, int y)
 {
@@ -291,7 +238,7 @@ dmxCoreMotion(DevicePtr pDev, int x, int y, int delta, DMXBlockType block)
                     pScreen->myNum, dmxScreen->index, localX, localY);
             if (block)
                 dmxSigioBlock();
-            dmxeqProcessInputEvents();
+            mieqProcessInputEvents();
             miPointerSetScreen(inputInfo.pointer, dmxScreen->index,
                                localX, localY);
             if (pDev)
@@ -344,6 +291,8 @@ static void dmxExtMotion(DMXLocalInputInfoPtr dmxLocal,
     int                    thisY   = 0;
     int                    i;
     int                    count;
+    EventListPtr           events;
+    int                    nevents;
 
     memset(xE, 0, sizeof(xE));
 
@@ -422,8 +371,12 @@ static void dmxExtMotion(DMXLocalInputInfoPtr dmxLocal,
 
     if (block)
         dmxSigioBlock();
-    dmxPointerPutMotionEvent(pDevice, firstAxis, axesCount, v, xev->time);
-    dmxeqEnqueue(pDevice, xE);
+    GetEventList(&events);
+    nevents = GetPointerEvents(events, pDevice, MotionNotify, 0, POINTER_ABSOLUTE,
+                               firstAxis, axesCount, v);
+    for (i = 0; i < nevents; i++)
+        mieqEnqueue(pDevice, (InternalEvent*)(events + i)->event);
+
     if (block)
         dmxSigioUnblock();
 }
@@ -431,14 +384,14 @@ static void dmxExtMotion(DMXLocalInputInfoPtr dmxLocal,
 static int dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
                                           XEvent *e, DMXBlockType block)
 {
-    xEvent                 xE[2];
-    deviceKeyButtonPointer *xev    = (deviceKeyButtonPointer *)xE;
-    deviceValuator         *xv     = (deviceValuator *)xev+1;
     int                    type;
     int                    event   = -1;
     XDeviceKeyEvent        *ke     = (XDeviceKeyEvent *)e;
     XDeviceMotionEvent     *me     = (XDeviceMotionEvent *)e;
     DeviceIntPtr           pDevice = dmxLocal->pDevice;
+    int                    valuators[6];
+    EventListPtr           events;
+    int                    nevents, i;
 
     if (!e)
         return -1;          /* No extended event passed, cannot handle */
@@ -463,11 +416,11 @@ static int dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
 
     switch (type) {
     case XI_DeviceValuator:          event = DeviceValuator;          break;
-    case XI_DeviceKeyPress:          event = DeviceKeyPress;          break;
-    case XI_DeviceKeyRelease:        event = DeviceKeyRelease;        break;
-    case XI_DeviceButtonPress:       event = DeviceButtonPress;       break;
-    case XI_DeviceButtonRelease:     event = DeviceButtonRelease;     break;
-    case XI_DeviceMotionNotify:      event = DeviceMotionNotify;      break;
+    case XI_DeviceKeyPress:          event = KeyPress;                break;
+    case XI_DeviceKeyRelease:        event = KeyRelease;              break;
+    case XI_DeviceButtonPress:       event = ButtonPress;             break;
+    case XI_DeviceButtonRelease:     event = ButtonRelease;           break;
+    case XI_DeviceMotionNotify:      event = MotionNotify;            break;
     case XI_DeviceFocusIn:           event = DeviceFocusIn;           break;
     case XI_DeviceFocusOut:          event = DeviceFocusOut;          break;
     case XI_ProximityIn:             event = ProximityIn;             break;
@@ -479,36 +432,63 @@ static int dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
     case XI_DeviceButtonstateNotify: event = DeviceStateNotify;       break;
     }
 
+#define EXTRACT_VALUATORS(ke, valuators) \
+        valuators[0]       = ke->axis_data[0]; \
+        valuators[1]       = ke->axis_data[1]; \
+        valuators[2]       = ke->axis_data[2]; \
+        valuators[3]       = ke->axis_data[3]; \
+        valuators[4]       = ke->axis_data[4]; \
+        valuators[5]       = ke->axis_data[5]; \
+
     switch (type) {
-    case XI_DeviceKeyPress: 
+    case XI_DeviceKeyPress:
     case XI_DeviceKeyRelease:
+        EXTRACT_VALUATORS(ke, valuators);
+        if (block)
+            dmxSigioBlock();
+        GetEventList(&events);
+        nevents = GetKeyboardValuatorEvents(events, pDevice, event,
+                                            ke->keycode, ke->first_axis,
+                                            ke->axes_count, valuators);
+        for (i = 0; i < nevents; i++)
+            mieqEnqueue(pDevice, (InternalEvent*)(events + i)->event);
+
+        if (block)
+            dmxSigioUnblock();
+        break;
     case XI_DeviceButtonPress:
     case XI_DeviceButtonRelease:
+        EXTRACT_VALUATORS(ke, valuators);
+        if (block)
+            dmxSigioBlock();
+        GetEventList(&events);
+        nevents = GetPointerEvents(events, pDevice, event, ke->keycode,
+                                   POINTER_ABSOLUTE, ke->first_axis,
+                                   ke->axes_count, valuators);
+        for (i = 0; i < nevents; i++)
+            mieqEnqueue(pDevice, (InternalEvent*)(events + i)->event);
+
+        if (block)
+            dmxSigioUnblock();
+        break;
     case XI_ProximityIn:
     case XI_ProximityOut:
-        xev->type          = event;
-        xev->detail        = ke->keycode; /* same as ->button */
-        xev->deviceid      = dmxLocal->pDevice->id | MORE_EVENTS;
-        xev->time          = GetTimeInMillis();
-
-        xv->type           = DeviceValuator;
-        xv->deviceid       = dmxLocal->pDevice->id;
-        xv->num_valuators  = ke->axes_count;
-        xv->first_valuator = ke->first_axis;
-        xv->valuator0      = ke->axis_data[0];
-        xv->valuator1      = ke->axis_data[1];
-        xv->valuator2      = ke->axis_data[2];
-        xv->valuator3      = ke->axis_data[3];
-        xv->valuator4      = ke->axis_data[4];
-        xv->valuator5      = ke->axis_data[5];
-
+        EXTRACT_VALUATORS(ke, valuators);
         if (block)
             dmxSigioBlock();
-        dmxeqEnqueue(pDevice, xE);
+        GetEventList(&events);
+        nevents = GetProximityEvents(events, pDevice, event,
+                                     ke->first_axis, ke->axes_count,
+                                     valuators);
+        for (i = 0; i < nevents; i++)
+            mieqEnqueue(pDevice, (InternalEvent*)(events + i)->event);
+
         if (block)
             dmxSigioUnblock();
         break;
 
+        break;
+
     case XI_DeviceMotionNotify:
         dmxExtMotion(dmxLocal, me->axis_data, me->first_axis, me->axes_count,
                      DMX_ABSOLUTE, block);
diff --git a/hw/dmx/input/dmxinputinit.c b/hw/dmx/input/dmxinputinit.c
index f92c888..73e804b 100644
--- a/hw/dmx/input/dmxinputinit.c
+++ b/hw/dmx/input/dmxinputinit.c
@@ -545,7 +545,7 @@ static void dmxProcessInputEvents(DMXInputInfo *dmxInput)
 {
     int i;
 
-    dmxeqProcessInputEvents();
+    mieqProcessInputEvents();
 #if 00 /*BP*/
     miPointerUpdate();
 #endif
@@ -1071,12 +1071,6 @@ void dmxInputInit(DMXInputInfo *dmxInput)
         }
     }
     
-    if (pPointer && pKeyboard) {
-        if (dmxeqInit(&pKeyboard->public, &pPointer->public))
-            dmxLogInput(dmxInput, "Using %s and %s as true core devices\n",
-                        pKeyboard->name, pPointer->name);
-    }
-
     dmxInput->processInputEvents    = dmxProcessInputEvents;
     dmxInput->detached              = False;
     
-- 
1.6.3.rc1.2.g0164.dirty



More information about the xorg-devel mailing list