xserver: Branch 'mpx' - 25 commits

Peter Hutterer whot at kemper.freedesktop.org
Fri Sep 28 02:30:43 PDT 2007


 Xi/chaccess.c                  |    4 
 Xi/exevents.c                  |  114 ++++++++++++++++++----
 Xi/extinit.c                   |    2 
 Xi/qryacces.c                  |    2 
 dix/access.c                   |    8 -
 dix/cursor.c                   |    2 
 dix/devices.c                  |   19 +--
 dix/dixfonts.c                 |    8 -
 dix/dixutils.c                 |    6 -
 dix/events.c                   |  212 ++++++++++++++++++++++++++++++++---------
 dix/getevents.c                |   59 +++--------
 dix/main.c                     |    2 
 dix/property.c                 |    8 -
 dix/resource.c                 |    4 
 dix/window.c                   |    9 -
 hw/xfree86/common/xf86Xinput.c |   28 ++++-
 include/cursor.h               |    2 
 include/dix.h                  |    3 
 include/xkbsrv.h               |    8 -
 mi/mieq.c                      |   23 ----
 xkb/ddxBeep.c                  |    4 
 xkb/ddxCtrls.c                 |    2 
 xkb/ddxKeyClick.c              |    2 
 xkb/ddxList.c                  |    6 -
 xkb/ddxLoad.c                  |   34 +++---
 xkb/xkb.c                      |   36 +++---
 xkb/xkbAccessX.c               |   29 +++++
 xkb/xkbActions.c               |   32 ++----
 xkb/xkbEvents.c                |   25 ++--
 xkb/xkbInit.c                  |   10 -
 xkb/xkbPrKeyEv.c               |    8 -
 xkb/xkbSwap.c                  |    2 
 xkb/xkbUtils.c                 |    2 
 33 files changed, 459 insertions(+), 256 deletions(-)

New commits:
diff-tree a511c445debbd13e8c48146ecd2d7c97e793f788 (from be466d8df808c4e4067a7963617bc3f506768f2d)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Fri Sep 28 18:46:41 2007 +0930

    Remove generation of core events, long live XI!
    
    Let the drivers only generate XI events and put those into the event queue.
    When processing events, generate core events as needed. This fixes a number of
    problems with XKB and the DIX in general.
    
    The previous approach was to put core events and XI events as separate events
    into the event queue. When being processed, the server had no knowledge of
    them coming from the same device state change. Anything that would then change
    the state of the device accordingly was in danger of changing it twice,
    leading to some funny (i.e. not funny at all) results.
    
    Emulating core events while processing XI events fixes this, there is only one
    path that actually changes the device state now. Although we have to be
    careful when replaying events from synced devices, otherwise we may lose
    events.
    
    Note: XI has precedence over core for passive grabs, but core events are
    delivered to the client first.
    
    This removes the wrapping added in 340911d7243a7f1095d79b5b2dcfa81b145c2474

diff --git a/Xi/exevents.c b/Xi/exevents.c
index d844eef..3566906 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -149,7 +149,15 @@ RegisterOtherDevice(DeviceIntPtr device)
     WRAP_PROCESS_INPUT_PROC(device, xiPrivPtr, ProcessOtherEvent);
 }
 
- /*ARGSUSED*/ void
+/**
+ * Main device event processing function. 
+ * Called from when processing the events from the event queue. 
+ * Generates core events for XI events as needed.
+ * 
+ * Note that these core events are then delivered first. For passive grabs, XI
+ * events have preference over core.
+ */
+void
 ProcessOtherEvent(xEventPtr xE, DeviceIntPtr device, int count)
 {
     BYTE *kptr;
@@ -163,19 +171,13 @@ ProcessOtherEvent(xEventPtr xE, DeviceIn
     KeyClassPtr k = device->key;
     ValuatorClassPtr v = device->valuator;
     deviceValuator *xV = (deviceValuator *) xE;
-
-    /* Handle core events. */
-    if (xE->u.u.type < LASTEvent && xE->u.u.type != GenericEvent)
-    {
-        ProcessInputProc backupproc;
-        xiDevPrivatePtr xiPrivPtr = 
-            (xiDevPrivatePtr)device->devPrivates[xiDevPrivateIndex].ptr;
-        UNWRAP_PROCESS_INPUT_PROC(device, xiPrivPtr, backupproc);
-        device->public.processInputProc(xE, device, count);
-        /* only rewraps is the processInputProc hasn't been modified */
-        REWRAP_PROCESS_INPUT_PROC(device, xiPrivPtr, backupproc);
-        return;
-    }
+    BOOL sendCore = FALSE;
+    xEvent core;
+    int coretype = 0;
+
+    coretype = XItoCoreType(xE->u.u.type);
+    if (device->coreEvents && coretype)
+        sendCore = TRUE;
 
     CheckMotion(xE, device);
 
@@ -280,7 +282,12 @@ ProcessOtherEvent(xEventPtr xE, DeviceIn
 		modifiers &= ~mask;
 	    }
 	}
-	if (!grab && CheckDeviceGrabs(device, xE, 0, count)) {
+        /* XI grabs have priority */
+        core = *xE;
+        core.u.u.type = coretype;
+	if (!grab &&
+              (CheckDeviceGrabs(device, xE, 0, count) ||
+                 (sendCore && CheckDeviceGrabs(device, &core, 0, 1)))) {
 	    device->deviceGrab.activatingKey = key;
 	    return;
 	}
@@ -308,7 +315,6 @@ ProcessOtherEvent(xEventPtr xE, DeviceIn
 	}
 
 	if (device->deviceGrab.fromPassiveGrab && 
-            !device->deviceGrab.grab->coreGrab &&
             (key == device->deviceGrab.activatingKey))
 	    deactivateDeviceGrab = TRUE;
     } else if (xE->u.u.type == DeviceButtonPress) {
@@ -328,10 +334,17 @@ ProcessOtherEvent(xEventPtr xE, DeviceIn
 	    b->state |= (Button1Mask >> 1) << xE->u.u.detail;
 	SetMaskForEvent(Motion_Filter(b), DeviceMotionNotify);
         if (!grab)
-            if (CheckDeviceGrabs(device, xE, 0, count))
+        {
+            core = *xE;
+            core.u.u.type = coretype;
+            if (CheckDeviceGrabs(device, xE, 0, count) ||
+                    (sendCore && CheckDeviceGrabs(device, &core, 0, 1)))
+            {
                 /* if a passive grab was activated, the event has been sent
                  * already */
                 return;
+            }
+        }
 
     } else if (xE->u.u.type == DeviceButtonRelease) {
         if (!b)
@@ -350,21 +363,39 @@ ProcessOtherEvent(xEventPtr xE, DeviceIn
 	    b->state &= ~((Button1Mask >> 1) << xE->u.u.detail);
 	SetMaskForEvent(Motion_Filter(b), DeviceMotionNotify);
         if (!b->state 
-            && device->deviceGrab.fromPassiveGrab
-            && !device->deviceGrab.grab->coreGrab)
+            && device->deviceGrab.fromPassiveGrab)
             deactivateDeviceGrab = TRUE;
     } else if (xE->u.u.type == ProximityIn)
 	device->valuator->mode &= ~OutOfProximity;
     else if (xE->u.u.type == ProximityOut)
 	device->valuator->mode |= OutOfProximity;
 
+    if (sendCore)
+    {
+        core = *xE;
+        core.u.u.type = coretype;
+    }
+
     if (grab)
-	DeliverGrabbedEvent(xE, device, deactivateDeviceGrab, count);
+    {
+        if (sendCore)                      /* never deactivate from core */
+            DeliverGrabbedEvent(&core, device, FALSE , 1);
+        DeliverGrabbedEvent(xE, device, deactivateDeviceGrab, count);
+    }
     else if (device->focus)
+    {
+        if (sendCore)
+            DeliverFocusedEvent(device, &core, GetSpriteWindow(device), 1);
 	DeliverFocusedEvent(device, xE, GetSpriteWindow(device), count);
+    }
     else
+    {
+        if (sendCore)
+            DeliverDeviceEvents(GetSpriteWindow(device), &core, NullGrab,
+                                NullWindow, device, 1);
 	DeliverDeviceEvents(GetSpriteWindow(device), xE, NullGrab, NullWindow,
 			    device, count);
+    }
 
     if (deactivateDeviceGrab == TRUE)
 	(*device->deviceGrab.DeactivateGrab) (device);
diff --git a/dix/events.c b/dix/events.c
index 45ff943..6eac090 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -294,6 +294,27 @@ static struct {
 static xEvent* swapEvent = NULL;
 static int swapEventLen = 0;
 
+/**
+ * Convert the given event type from an XI event to a core event.
+ * @return The matching core event type or 0 if there is none.
+ */
+_X_EXPORT int
+XItoCoreType(int xitype)
+{
+    int coretype = 0;
+    if (xitype == DeviceMotionNotify)
+        coretype = MotionNotify;
+    else if (xitype == DeviceButtonPress)
+        coretype = ButtonPress;
+    else if (xitype == DeviceButtonRelease)
+        coretype = ButtonRelease;
+    else if (xitype == DeviceKeyPress)
+        coretype = KeyPress;
+    else if (xitype == DeviceKeyRelease)
+        coretype = KeyRelease;
+    return coretype;
+}
+
 /** 
  * True if device owns a cursor, false if device shares a cursor sprite with
  * another device.
@@ -775,9 +796,15 @@ XineramaChangeToCursor(DeviceIntPtr pDev
 void
 SetMaskForEvent(Mask mask, int event)
 {
+    int coretype;
     if ((event < LASTEvent) || (event >= 128))
 	FatalError("SetMaskForEvent: bogus event number");
     filters[event] = mask;
+
+    /* Need to change the mask for the core events too */
+    coretype = XItoCoreType(event);
+    if (coretype)
+        filters[coretype] = mask;
 }
 
 _X_EXPORT void
@@ -1343,10 +1370,11 @@ ComputeFreezes(void)
     DeviceIntPtr replayDev = syncEvents.replayDev;
     int i;
     WindowPtr w;
-    xEvent *xE;
+    xEvent *xE, core;
     int count;
     GrabPtr grab;
     DeviceIntPtr dev;
+    BOOL sendCore;
 
     for (dev = inputInfo.devices; dev; dev = dev->next)
 	FreezeThaw(dev, dev->deviceGrab.sync.other || 
@@ -1367,11 +1395,38 @@ ComputeFreezes(void)
 		replayDev->spriteInfo->sprite->spriteTrace[i])
 	    {
 		if (!CheckDeviceGrabs(replayDev, xE, i+1, count)) {
+                    /* There is no other client that gets a passive grab on
+                     * the event anymore. Emulate core event if necessary and
+                     * deliver it too.
+                     * However, we might get here with a core event, in which
+                     * case we mustn't emulate a core event.
+                     * XXX: I think this may break things. If a client has a
+                     * device grab, and another client a core grab on an
+                     * inferior window, we never get the core grab. (whot)
+                     */
+                    sendCore = (replayDev->coreEvents &&
+                        (xE->u.u.type & EXTENSION_EVENT_BASE &&
+                         XItoCoreType(xE->u.u.type)));
+
+                    if (sendCore)
+                    {
+                        core = *xE;
+                        core.u.u.type = XItoCoreType(xE->u.u.type);
+                    }
 		    if (replayDev->focus)
+                    {
+                        if (sendCore)
+                            DeliverFocusedEvent(replayDev, &core, w, 1);
 			DeliverFocusedEvent(replayDev, xE, w, count);
+                    }
 		    else
+                    {
+                        if (sendCore)
+                            DeliverDeviceEvents(w, &core, NullGrab,
+                                                NullWindow, replayDev, 1);
 			DeliverDeviceEvents(w, xE, NullGrab, NullWindow,
 					        replayDev, count);
+                    }
 		}
 		goto playmore;
 	    }
@@ -2089,7 +2144,13 @@ DeliverEventsToWindow(DeviceIntPtr pDev,
             }
         }
     }
-    if ((type == ButtonPress) && deliveries && (!grab))
+    /*
+     * Note that since core events are delivered first, an implicit grab may
+     * be activated on a core grab, stopping the XI events.
+     */
+    if ((type == DeviceButtonPress || type == ButtonPress)
+            && deliveries
+            && (!grab))
     {
 	GrabRec tempGrab;
         OtherInputMasks *inputMasks;
@@ -2104,7 +2165,7 @@ DeliverEventsToWindow(DeviceIntPtr pDev,
 	tempGrab.pointerMode = GrabModeAsync;
 	tempGrab.confineTo = NullWindow;
 	tempGrab.cursor = NullCursor;
-        tempGrab.coreGrab = True;
+        tempGrab.coreGrab = (type == ButtonPress);
 
         /* get the XI device mask */
         inputMasks = wOtherInputMasks(pWin);
@@ -2127,9 +2188,8 @@ DeliverEventsToWindow(DeviceIntPtr pDev,
                 tempGrab.genericMasks->next = NULL;
             }
         }
-	(*inputInfo.pointer->deviceGrab.ActivateGrab)(pDev, &tempGrab,
-					   currentTime, 
-                                           TRUE | ImplicitGrabMask);
+	(*pDev->deviceGrab.ActivateGrab)(pDev, &tempGrab,
+                                        currentTime, TRUE | ImplicitGrabMask);
     }
     else if ((type == MotionNotify) && deliveries)
 	pDev->valuator->motionHintWindow = pWin;
@@ -3182,6 +3242,8 @@ CheckPassiveGrabsOnWindow(
 	XkbSrvInfoPtr	xkbi;
 
 	gdev= grab->modifierDevice;
+        if (grab->coreGrab)
+            gdev = GetPairedKeyboard(device);
 	xkbi= gdev->key->xkbInfo;
 #endif
 	tempGrab.modifierDevice = grab->modifierDevice;
diff --git a/dix/getevents.c b/dix/getevents.c
index fda4e27..7457078 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -191,10 +191,10 @@ updateMotionHistory(DeviceIntPtr pDev, C
  */
 _X_EXPORT int
 GetMaximumEventsNum(void) {
-    /* Three base events -- raw event, core and device, plus valuator events.
+    /* Three base events -- raw event and device, plus valuator events.
      * Multiply by two if we're doing key repeats. 
      */
-    int ret = 3 + MAX_VALUATOR_EVENTS;
+    int ret = 2 + MAX_VALUATOR_EVENTS;
 
 #ifdef XKB
     if (noXkbExtension)
@@ -366,6 +366,9 @@ GetKeyboardEvents(EventList *events, Dev
  * Returns a set of keyboard events for KeyPress/KeyRelease, optionally
  * also with valuator events.  Handles Xi and XKB.
  *
+ * DOES NOT GENERATE CORE EVENTS! Core events are created when processing the
+ * event (ProcessOtherEvent).
+ *
  * events is not NULL-terminated; the return value is the number of events.
  * The DDX is responsible for allocating the event structure in the first
  * place via GetMaximumEventsNum(), and for freeing it.
@@ -399,10 +402,7 @@ GetKeyboardValuatorEvents(EventList *eve
         (pDev->coreEvents && !inputInfo.keyboard->key))
         return 0;
 
-    if (pDev->coreEvents)
-        numEvents = 2;
-    else
-        numEvents = 1;
+    numEvents = 1;
 
     if (num_valuators) {
         if ((num_valuators / 6) + 1 > MAX_VALUATOR_EVENTS)
@@ -469,12 +469,6 @@ GetKeyboardValuatorEvents(EventList *eve
                                    num_valuators, valuators);
     }
 
-    if (pDev->coreEvents) {
-        events->event->u.keyButtonPointer.time = ms;
-        events->event->u.u.type = type;
-        events->event->u.u.detail = key_code;
-    }
-
     return numEvents;
 }
 
@@ -533,6 +527,9 @@ FreeEventList(EventListPtr list, int num
  * Generate a series of xEvents (filled into the EventList) representing
  * pointer motion, or button presses.  Xi and XKB-aware.
  *
+ * DOES NOT GENERATE CORE EVENTS! Core events are created when processing the
+ * event (ProcessOtherEvent).
+ *
  * events is not NULL-terminated; the return value is the number of events.
  * The DDX is responsible for allocating the event structure in the first
  * place via InitEventList() and GetMaximumEventsNum(), and for freeing it.
@@ -567,10 +564,7 @@ GetPointerEvents(EventList *events, Devi
     if (!pDev->valuator)
         return 0;
 
-    if (!coreOnly && pDev->coreEvents)
-        num_events = 3;
-    else
-        num_events = 2;
+    num_events = 2;
 
     if (type == MotionNotify && num_valuators <= 0)
         return 0;
@@ -703,24 +697,6 @@ GetPointerEvents(EventList *events, Devi
         }
     }
 
-    /* for some reason inputInfo.pointer does not have coreEvents set */
-    if (coreOnly || pDev->coreEvents) {
-        events->event->u.u.type = type;
-        events->event->u.keyButtonPointer.time = ms;
-        events->event->u.keyButtonPointer.rootX = x;
-        events->event->u.keyButtonPointer.rootY = y;
-
-        if (type == ButtonPress || type == ButtonRelease) {
-            /* We hijack SetPointerMapping to work on all core-sending
-             * devices, so we use the device-specific map here instead of
-             * the core one. */
-            events->event->u.u.detail = pDev->button->map[buttons];
-        }
-        else {
-            events->event->u.u.detail = 0;
-        }
-    }
-
     return num_events;
 }
 
diff --git a/include/dix.h b/include/dix.h
index bec19dd..34abb2d 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -689,6 +689,7 @@ typedef struct {
 extern int xstrcasecmp(char *s1, char *s2);
 #endif
 
+extern int XItoCoreType(int xi_type);
 extern Bool DevHasCursor(DeviceIntPtr pDev);
 
 extern Bool IsPointerDevice( DeviceIntPtr dev);
diff --git a/mi/mieq.c b/mi/mieq.c
index 78e57ad..9e0f5be 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -300,7 +300,8 @@ mieqProcessInputEvents(void)
         }
 
         /* Update the sprite now. Next event may be from different device. */
-        if (e->events->event[0].u.u.type == MotionNotify && e->pDev->coreEvents)
+        if (e->events->event[0].u.u.type == DeviceMotionNotify 
+                && e->pDev->coreEvents)
         {
             miPointerUpdateSprite(e->pDev);
         }
diff-tree be466d8df808c4e4067a7963617bc3f506768f2d (from 53434edc3d306137d019d95189ecdf0dbff75205)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Thu Sep 27 22:23:05 2007 +0930

    dix: GetPairedKeyboard() always returns a valid keyboard (VCK if necessary).
    
    We need it unconditionally in a few places, and the rest checked for NULL and
    then set it to VCK anyway. So, fixing up all callers to appreciate the defined
    return value.

diff --git a/dix/devices.c b/dix/devices.c
index 63d7ea4..24eaa4b 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -2229,15 +2229,16 @@ GetPairedPointer(DeviceIntPtr kbd)
 }
 
 /* Find the keyboard device that is paired with the given pointer. If none is
- * found, return NULL.
- * We also check if the paired device is a keyboard. If not (e.g. evdev brain)
- * we don't return it. This probably needs to be fixed.
+ * found, return the VCK.
  */
 _X_EXPORT DeviceIntPtr
 GetPairedKeyboard(DeviceIntPtr ptr)
 {
     DeviceIntPtr dev = inputInfo.devices;
 
+    if (IsKeyboardDevice(ptr))
+        return ptr;
+
     while(dev)
     {
         if (ptr != dev && 
@@ -2246,7 +2247,7 @@ GetPairedKeyboard(DeviceIntPtr ptr)
             return dev;
         dev = dev->next;
     }
-    return dev;
+    return (dev) ? dev : inputInfo.keyboard;
 }
 
 /*
diff --git a/dix/events.c b/dix/events.c
index a803550..45ff943 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -3233,8 +3233,6 @@ CheckPassiveGrabsOnWindow(
             {
                 grab->device = device; 
                 grab->modifierDevice = GetPairedKeyboard(device);
-                if (!grab->modifierDevice)
-                    grab->modifierDevice = inputInfo.keyboard;
             }
 
 	    (*grabinfo->ActivateGrab)(device, grab, currentTime, TRUE);
@@ -4052,8 +4050,7 @@ EnterLeaveEvent(
     int                 mskidx;
     OtherInputMasks     *inputMasks;
 
-    if (!(keybd = GetPairedKeyboard(mouse)))
-        keybd = inputInfo.keyboard;
+    keybd = GetPairedKeyboard(mouse);
 
     if ((pWin == mouse->valuator->motionHintWindow) &&
 	(detail != NotifyInferior))
@@ -4572,11 +4569,7 @@ SetInputFocus(
     if (IsKeyboardDevice(dev))
         keybd = dev;
     else
-    {
         keybd = GetPairedKeyboard(dev);
-        if (!keybd) 
-            keybd = inputInfo.keyboard;
-    }
 
     if ((focusID == None) || (focusID == PointerRoot))
 	focusWin = (WindowPtr)(long)focusID;
@@ -5592,8 +5585,6 @@ ProcGrabButton(ClientPtr client)
 
     pointer = PickPointer(client);
     modifierDevice = GetPairedKeyboard(pointer);
-    if (!modifierDevice)
-        modifierDevice = inputInfo.keyboard;
 
     grab = CreateGrab(client->index, pointer, pWin, 
         (Mask)stuff->eventMask, (Bool)stuff->ownerEvents,
diff-tree 53434edc3d306137d019d95189ecdf0dbff75205 (from de06a47d4ad9c845b098438d9492a5f42483a2ad)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Thu Sep 27 22:14:09 2007 +0930

    dix: take paired keyboard instead of VCK (CoreProcessPointerEvents)

diff --git a/dix/events.c b/dix/events.c
index b396b65..a803550 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -3707,7 +3707,7 @@ ProcessPointerEvent (xEvent *xE, DeviceI
     SpritePtr           pSprite = mouse->spriteInfo->sprite;
 
 #ifdef XKB
-    XkbSrvInfoPtr xkbi= inputInfo.keyboard->key->xkbInfo;
+    XkbSrvInfoPtr xkbi= GetPairedKeyboard(mouse)->key->xkbInfo;
 #endif
 #ifdef XEVIE
     if(xevieFlag && clients[xevieClientIndex] && !xeviegrabState &&
diff-tree de06a47d4ad9c845b098438d9492a5f42483a2ad (from 32d0440c7f6e604807cb14dd32349df6f22c903b)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Thu Sep 27 11:45:03 2007 +0930

    dix: GetMaximumEventsNum() needs to return 3 + MAX_VALUATOR_EVENTS.
    
    Raw events can be generated for pointer events, so 2 + MVE isn't enough.

diff --git a/dix/getevents.c b/dix/getevents.c
index df1dc6a..fda4e27 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -191,9 +191,10 @@ updateMotionHistory(DeviceIntPtr pDev, C
  */
 _X_EXPORT int
 GetMaximumEventsNum(void) {
-    /* Two base events -- core and device, plus valuator events.  Multiply
-     * by two if we're doing key repeats. */
-    int ret = 2 + MAX_VALUATOR_EVENTS;
+    /* Three base events -- raw event, core and device, plus valuator events.
+     * Multiply by two if we're doing key repeats. 
+     */
+    int ret = 3 + MAX_VALUATOR_EVENTS;
 
 #ifdef XKB
     if (noXkbExtension)
diff-tree 32d0440c7f6e604807cb14dd32349df6f22c903b (from 8f9bf927e1beecf9b9ec8877131ec12c765e4d84)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Thu Sep 27 11:44:03 2007 +0930

    xkb: xkbHandleActions: let wrapping take care of event delivery.
    
    This is hopefully better than hardcodey calling CoreProcessPointerEvent.

diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
index cc707bd..891b915 100644
--- a/xkb/xkbActions.c
+++ b/xkb/xkbActions.c
@@ -1148,7 +1148,6 @@ XkbAction	act;
 XkbFilterPtr	filter;
 Bool		keyEvent;
 Bool		pressEvent;
-Bool		xiEvent;
 ProcessInputProc backupproc;
     
 xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev);
@@ -1173,9 +1172,6 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEI
 		(xE->u.u.type==KeyRelease)||(xE->u.u.type==DeviceKeyRelease));
     pressEvent= (xE->u.u.type==KeyPress)||(xE->u.u.type==DeviceKeyPress)||
 		 (xE->u.u.type==ButtonPress)||(xE->u.u.type==DeviceButtonPress);
-    xiEvent= (xE->u.u.type==DeviceKeyPress)||(xE->u.u.type==DeviceKeyRelease)||
-	     (xE->u.u.type==DeviceButtonPress)||
-	     (xE->u.u.type==DeviceButtonRelease);
 
     if (pressEvent) {
 	if (keyEvent)	
@@ -1279,23 +1275,21 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEI
     }
 
     if (sendEvent) {
+        DeviceIntPtr tmpdev;
 	if (keyEvent) {
 	    realMods = keyc->modifierMap[key];
 	    keyc->modifierMap[key] = 0;
-	    UNWRAP_PROCESS_INPUT_PROC(dev,xkbPrivPtr, backupproc);
-	    dev->public.processInputProc(xE,dev,count);
-	    COND_WRAP_PROCESS_INPUT_PROC(dev, xkbPrivPtr,
-					 backupproc,xkbUnwrapProc);
+            tmpdev = dev;
+        } else
+            tmpdev = GetPairedPointer(dev);
+
+
+        UNWRAP_PROCESS_INPUT_PROC(tmpdev,xkbPrivPtr, backupproc);
+        dev->public.processInputProc(xE,tmpdev,count);
+        COND_WRAP_PROCESS_INPUT_PROC(tmpdev, xkbPrivPtr,
+                                     backupproc,xkbUnwrapProc);
+        if (keyEvent)
 	    keyc->modifierMap[key] = realMods;
-	}
-	else 
-        {
-            if (xE->u.u.type & EXTENSION_EVENT_BASE)
-                ProcessOtherEvent(xE, dev, count);
-            else
-                CoreProcessPointerEvent(xE,dev,count);
-            
-        }
     }
     else if (keyEvent)
 	FixKeyState(xE,dev);
diff-tree 8f9bf927e1beecf9b9ec8877131ec12c765e4d84 (from 3342b5ad47be25c6838321c0aafc28c329c308b5)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Wed Sep 26 18:04:59 2007 +0930

    xkb: Unwrap properly in ProcessPointerEvent.
    
    Instead of hardcoding CoreProcessPointerEvent, actually try to unwrap properly
    and then call the unwrapped processInputProc. Seems to be a better idea,
    especially since it makes stuff actually work...

diff --git a/xkb/xkbAccessX.c b/xkb/xkbAccessX.c
index 8e897c8..063c844 100644
--- a/xkb/xkbAccessX.c
+++ b/xkb/xkbAccessX.c
@@ -684,6 +684,8 @@ Bool		ignoreKeyEvent = FALSE;
 /* don't accidentally turn on StickyKeys or the Keyboard Response Group.*/
 /*									*/
 /************************************************************************/
+extern int xkbDevicePrivateIndex;
+extern void xkbUnwrapProc(DeviceIntPtr, DeviceHandleProc, pointer);
 void
 ProcessPointerEvent(	register xEvent  *	xE, 
 			register DeviceIntPtr	mouse, 
@@ -692,6 +694,8 @@ ProcessPointerEvent(	register xEvent  *	
 DeviceIntPtr	dev = (DeviceIntPtr)LookupKeyboardDevice();
 XkbSrvInfoPtr	xkbi = dev->key->xkbInfo;
 unsigned 	changed = 0;
+ProcessInputProc backupproc;
+xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(mouse);
 
     xkbi->shiftKeyCount = 0;
     xkbi->lastPtrEventTime= xE->u.keyButtonPointer.time;
@@ -703,7 +707,26 @@ unsigned 	changed = 0;
 	xkbi->lockedPtrButtons&= ~(1<<(xE->u.u.detail&0x7));
 	changed |= XkbPointerButtonMask;
     }
-    CoreProcessPointerEvent(xE,mouse,count);
+
+    /* Guesswork. mostly. 
+     * xkb actuall goes through some effort to transparently wrap the
+     * processInputProcs (see XkbSetExtension). But we all love fun, so the
+     * previous XKB implementation just hardcoded the CPPE call here instead
+     * of unwrapping like anybody with any sense of decency would do. 
+     * I got no clue what the correct thing to do is, but my guess is that
+     * it's not hardcoding. I may be wrong. whatever it is, don't come whining
+     * to me. I just work here. 
+     *
+     * Anyway. here's the old call, if you don't like the wrapping, revert it.
+     *
+     * CoreProcessPointerEvent(xE,mouse,count);
+     *
+     *          see. it's still steaming. told you. (whot)
+     */
+    UNWRAP_PROCESS_INPUT_PROC(mouse, xkbPrivPtr, backupproc);
+    mouse->public.processInputProc(xE, mouse, count);
+    COND_WRAP_PROCESS_INPUT_PROC(mouse, xkbPrivPtr,
+				     backupproc, xkbUnwrapProc);
 
     xkbi->state.ptr_buttons = mouse->button->state;
     
diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
index e51b0cc..cc707bd 100644
--- a/xkb/xkbActions.c
+++ b/xkb/xkbActions.c
@@ -42,9 +42,9 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #define EXTENSION_EVENT_BASE 64
 
 static unsigned int _xkbServerGeneration;
-static int xkbDevicePrivateIndex = -1;
+int xkbDevicePrivateIndex = -1;
 
-static void
+void
 xkbUnwrapProc(DeviceIntPtr device, DeviceHandleProc proc,
                    pointer data)
 {
diff-tree 3342b5ad47be25c6838321c0aafc28c329c308b5 (from e2cb8515661b1f7826981931d82dee6e05529f04)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Wed Sep 26 18:03:21 2007 +0930

    Xi: fix the wrapper code for processInputProc wrapping.
    
    Followup to [1].
    If a core grab causes the device to freeze, it overwrites the processInputProc
    of the device. [1] would then overwrite this while unwrapping, the device
    does not thaw anymore.
    Changing this to only re-wrap if the processInputProc hasn't been changed
    during the event handling.
    
    [1] 340911d7243a7f1095d79b5b2dcfa81b145c2474

diff --git a/Xi/exevents.c b/Xi/exevents.c
index 2baaa58..d844eef 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -104,15 +104,23 @@ typedef struct {
  */
 
 #define WRAP_PROCESS_INPUT_PROC(device, saveprocs, newproc) \
-    saveprocs->processInputProc = device->public.processInputProc; \
+    saveprocs->processInputProc = \
     saveprocs->realInputProc = device->public.realInputProc; \
     device->public.processInputProc = newproc; \
-    device->public.realInputProc = newproc;
+    device->public.realInputProc = newproc 
 
-#define UNWRAP_PROCESS_INPUT_PROC(device, saveprocs) \
+#define UNWRAP_PROCESS_INPUT_PROC(device, saveprocs, backupproc) \
+    backupproc = device->public.processInputProc; \
     device->public.processInputProc = saveprocs->processInputProc; \
     device->public.realInputProc = saveprocs->realInputProc; 
 
+#define REWRAP_PROCESS_INPUT_PROC(device, saveprocs, newproc) \
+    if (device->public.processInputProc == device->public.realInputProc) \
+        device->public.processInputProc = newproc; \
+    saveprocs->processInputProc = \
+    saveprocs->realInputProc = device->public.realInputProc; \
+    device->public.realInputProc = newproc;
+
 void
 RegisterOtherDevice(DeviceIntPtr device)
 {
@@ -159,11 +167,13 @@ ProcessOtherEvent(xEventPtr xE, DeviceIn
     /* Handle core events. */
     if (xE->u.u.type < LASTEvent && xE->u.u.type != GenericEvent)
     {
+        ProcessInputProc backupproc;
         xiDevPrivatePtr xiPrivPtr = 
             (xiDevPrivatePtr)device->devPrivates[xiDevPrivateIndex].ptr;
-        UNWRAP_PROCESS_INPUT_PROC(device, xiPrivPtr);
+        UNWRAP_PROCESS_INPUT_PROC(device, xiPrivPtr, backupproc);
         device->public.processInputProc(xE, device, count);
-        WRAP_PROCESS_INPUT_PROC(device, xiPrivPtr, ProcessOtherEvent);
+        /* only rewraps is the processInputProc hasn't been modified */
+        REWRAP_PROCESS_INPUT_PROC(device, xiPrivPtr, backupproc);
         return;
     }
 
diff-tree e2cb8515661b1f7826981931d82dee6e05529f04 (from 27bc1a8fef2bfd3d62fb44f7c7eb0d463ed08632)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Wed Sep 26 18:01:17 2007 +0930

    xfree86: pass in the XKB event processing proc instead of the XI one.
    
    We need to pass ProcessPointerEvent or ProcessKeyboardEvent to
    XkbSetExtension, otherwise we lose the xkb layer.

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 31c3008..a43230e 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -205,7 +205,7 @@ xf86ActivateDevice(LocalDevicePtr local)
 
         RegisterOtherDevice(dev);
         if (!noXkbExtension)
-            XkbSetExtension(dev, ProcessOtherEvent);
+            XkbSetExtension(dev, (DeviceIsPointerType(dev)) ? ProcessPointerEvent : ProcessKeyboardEvent);
 
         if (serverGeneration == 1) 
             xf86Msg(X_INFO, "XINPUT: Adding extended input device \"%s\" (type: %s)\n",
diff-tree 27bc1a8fef2bfd3d62fb44f7c7eb0d463ed08632 (from bfc89c035542a10594f5f0cbde1c7e28b7d024a7)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Wed Sep 26 15:24:41 2007 +0930

    xkb: XkbFilterEvents: Remove unused variable compiler warning.

diff --git a/xkb/xkbEvents.c b/xkb/xkbEvents.c
index 64cddd0..37d850d 100644
--- a/xkb/xkbEvents.c
+++ b/xkb/xkbEvents.c
@@ -809,7 +809,6 @@ XkbFilterEvents(ClientPtr pClient,int nE
 int	i, button_mask;
 DeviceIntPtr pXDev = (DeviceIntPtr)LookupKeyboardDevice();
 XkbSrvInfoPtr	xkbi;
-GrabInfoPtr grabinfo;
 
     xkbi= pXDev->key->xkbInfo;
     if ( pClient->xkbClientFlags & _XkbClientInitialized ) {
diff-tree bfc89c035542a10594f5f0cbde1c7e28b7d024a7 (from 8b508f5d6bd0d3995294d5ff300a856754442999)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Wed Sep 26 15:23:37 2007 +0930

    xkb: unify ErrorFs. Prefix all with [xkb].
    
    Output for XkbUseMsg intentionally skipped.

diff --git a/xkb/ddxBeep.c b/xkb/ddxBeep.c
index 331357d..2fab4ed 100644
--- a/xkb/ddxBeep.c
+++ b/xkb/ddxBeep.c
@@ -141,12 +141,12 @@ Atom		name;
     duration= oldDuration= ctrl->bell_duration;
 #ifdef DEBUG
     if (xkbDebugFlags>1)
-	ErrorF("beep: %d (count= %d)\n",xkbInfo->beepType,xkbInfo->beepCount);
+	ErrorF("[xkb] beep: %d (count= %d)\n",xkbInfo->beepType,xkbInfo->beepCount);
 #endif
     name= None;
     switch (xkbInfo->beepType) {
 	default:
-	    ErrorF("Unknown beep type %d\n",xkbInfo->beepType);
+	    ErrorF("[xkb] Unknown beep type %d\n",xkbInfo->beepType);
 	case _BEEP_NONE:
 	    duration= 0;
 	    break;
diff --git a/xkb/ddxCtrls.c b/xkb/ddxCtrls.c
index 0f7f918..73a5e03 100644
--- a/xkb/ddxCtrls.c
+++ b/xkb/ddxCtrls.c
@@ -49,7 +49,7 @@ int realRepeat;
 	ctrl->autoRepeat= 0;
 #ifdef DEBUG
 if (xkbDebugFlags&0x4) {
-    ErrorF("XkbDDXKeybdCtrlProc: setting repeat to %d (real repeat is %d)\n",
+    ErrorF("[xkb] XkbDDXKeybdCtrlProc: setting repeat to %d (real repeat is %d)\n",
 					ctrl->autoRepeat,realRepeat);
 }
 #endif
diff --git a/xkb/ddxKeyClick.c b/xkb/ddxKeyClick.c
index f48296d..10f3f38 100644
--- a/xkb/ddxKeyClick.c
+++ b/xkb/ddxKeyClick.c
@@ -44,7 +44,7 @@ XkbDDXKeyClick(DeviceIntPtr pXDev,int ke
 {
 #ifdef DEBUG
     if (xkbDebugFlags)
-	ErrorF("Click.\n");
+	ErrorF("[xkb] Click.\n");
 #endif
     return;
 }
diff --git a/xkb/ddxList.c b/xkb/ddxList.c
index a91a9ba..2baf652 100644
--- a/xkb/ddxList.c
+++ b/xkb/ddxList.c
@@ -200,10 +200,10 @@ char	tmpname[PATH_MAX];
 	in= Popen(buf,"r");
 #else
 #ifdef DEBUG_CMD
-	ErrorF("xkb executes: %s\n",buf);
+	ErrorF("[xkb] xkb executes: %s\n",buf);
 #endif
 	if (System(buf) < 0)
-	    ErrorF("Could not invoke keymap compiler\n");
+	    ErrorF("[xkb] Could not invoke keymap compiler\n");
 	else
 	    in= fopen(tmpname, "r");
 #endif
@@ -271,7 +271,7 @@ char	tmpname[PATH_MAX];
 	fclose(in);
     else if ((rval=Pclose(in))!=0) {
 	if (xkbDebugFlags)
-	    ErrorF("xkbcomp returned exit code %d\n",rval);
+	    ErrorF("[xkb] xkbcomp returned exit code %d\n",rval);
     }
 #else
     fclose(in);
diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c
index d79ae7a..a0fa606 100644
--- a/xkb/ddxLoad.c
+++ b/xkb/ddxLoad.c
@@ -134,11 +134,11 @@ Win32System(const char *cmdline)
 		    0,
 		    NULL ))
 	{
-	    ErrorF("Starting '%s' failed!\n", cmdline); 
+	    ErrorF("[xkb] Starting '%s' failed!\n", cmdline); 
 	}
 	else
 	{
-	    ErrorF("Starting '%s' failed: %s", cmdline, (char *)buffer); 
+	    ErrorF("[xkb] Starting '%s' failed: %s", cmdline, (char *)buffer); 
 	    LocalFree(buffer);
 	}
 
@@ -258,12 +258,12 @@ char 	*cmd = NULL,file[PATH_MAX],xkm_out
     }
 #ifdef DEBUG
     if (xkbDebugFlags) {
-	ErrorF("XkbDDXCompileNamedKeymap compiling keymap using:\n");
-	ErrorF("    \"cmd\"\n");
+	ErrorF("[xkb] XkbDDXCompileNamedKeymap compiling keymap using:\n");
+	ErrorF("[xkb]     \"cmd\"\n");
     }
 #endif
 #ifdef DEBUG_CMD
-    ErrorF("xkb executes: %s\n",cmd);
+    ErrorF("[xkb] xkb executes: %s\n",cmd);
 #endif
     if (System(cmd)==0) {
 	if (nameRtrn) {
@@ -277,7 +277,7 @@ char 	*cmd = NULL,file[PATH_MAX],xkm_out
 	return True;
     } 
 #ifdef DEBUG
-    ErrorF("Error compiling keymap (%s)\n",names->keymap);
+    ErrorF("[xkb] Error compiling keymap (%s)\n",names->keymap);
 #endif
     if (outFile!=NULL)
 	_XkbFree(outFile);
@@ -305,7 +305,7 @@ char tmpname[PATH_MAX];
     }
     else {
 	if (strlen(names->keymap) > PATH_MAX - 1) {
-	    ErrorF("name of keymap (%s) exceeds max length\n", names->keymap);
+	    ErrorF("[xkb] name of keymap (%s) exceeds max length\n", names->keymap);
 	    return False;
 	}
 	strcpy(keymap,names->keymap);
@@ -360,7 +360,7 @@ char tmpname[PATH_MAX];
     if (out!=NULL) {
 #ifdef DEBUG
     if (xkbDebugFlags) {
-       ErrorF("XkbDDXCompileKeymapByNames compiling keymap:\n");
+       ErrorF("[xkb] XkbDDXCompileKeymapByNames compiling keymap:\n");
        XkbWriteXKBKeymapForNames(stderr,names,NULL,xkb,want,need);
     }
 #endif
@@ -372,10 +372,10 @@ char tmpname[PATH_MAX];
 #endif
 	{
 #ifdef DEBUG_CMD
-	    ErrorF("xkb executes: %s\n",buf);
-	    ErrorF("xkbcomp input:\n");
+	    ErrorF("[xkb] xkb executes: %s\n",buf);
+	    ErrorF("[xkb] xkbcomp input:\n");
 	    XkbWriteXKBKeymapForNames(stderr,names,NULL,xkb,want,need);
-	    ErrorF("end xkbcomp input\n");
+	    ErrorF("[xkb] end xkbcomp input\n");
 #endif
 	    if (nameRtrn) {
 		strncpy(nameRtrn,keymap,nameRtrnLen);
@@ -387,7 +387,7 @@ char tmpname[PATH_MAX];
 	}
 #ifdef DEBUG
 	else
-	    ErrorF("Error compiling keymap (%s)\n",keymap);
+	    ErrorF("[xkb] Error compiling keymap (%s)\n",keymap);
 #endif
 #ifdef WIN32
         /* remove the temporary file */
@@ -397,9 +397,9 @@ char tmpname[PATH_MAX];
 #ifdef DEBUG
     else {
 #ifndef WIN32
-	ErrorF("Could not invoke keymap compiler\n");
+	ErrorF("[xkb] Could not invoke keymap compiler\n");
 #else
-	ErrorF("Could not open file %s\n", tmpname);
+	ErrorF("[xkb] Could not open file %s\n", tmpname);
 #endif
     }
 #endif
@@ -478,7 +478,7 @@ unsigned	missing;
 	}
 	else if (!XkbDDXCompileNamedKeymap(xkb,names,nameRtrn,nameRtrnLen)) {
 #ifdef NOISY
-	    ErrorF("Couldn't compile keymap file\n");
+	    ErrorF("[xkb] Couldn't compile keymap file\n");
 #endif
 	    return 0;
 	}
@@ -486,7 +486,7 @@ unsigned	missing;
     else if (!XkbDDXCompileKeymapByNames(xkb,names,want,need,
 						nameRtrn,nameRtrnLen)){
 #ifdef NOISY
-	ErrorF("Couldn't compile keymap file\n");
+	ErrorF("[xkb] Couldn't compile keymap file\n");
 #endif
 	return 0;
     }
@@ -504,7 +504,7 @@ unsigned	missing;
     }
 #ifdef DEBUG
     else if (xkbDebugFlags) {
-	ErrorF("Loaded %s, defined=0x%x\n",fileName,finfoRtrn->defined);
+	ErrorF("[xkb] Loaded %s, defined=0x%x\n",fileName,finfoRtrn->defined);
     }
 #endif
     fclose(file);
diff --git a/xkb/xkb.c b/xkb/xkb.c
index cf42430..4f0677a 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -170,7 +170,7 @@ ProcXkbUseExtension(ClientPtr client)
 	client->vMinor= stuff->wantedMinor;
     }
     else if (xkbDebugFlags&0x1) {
-	ErrorF("Rejecting client %d (0x%lx) (wants %d.%02d, have %d.%02d)\n",
+	ErrorF("[xkb] Rejecting client %d (0x%lx) (wants %d.%02d, have %d.%02d)\n",
 					client->index,
 					(long)client->clientAsMask,
 					stuff->wantedMajor,stuff->wantedMinor,
@@ -334,7 +334,7 @@ ProcXkbSelectEvents(ClientPtr client)
 	    }
 	}
 	if (dataLeft>2) {
-	    ErrorF("Extra data (%d bytes) after SelectEvents\n",dataLeft);
+	    ErrorF("[xkb] Extra data (%d bytes) after SelectEvents\n",dataLeft);
 	    return BadLength;
 	}
 	return client->noClientException;
@@ -1339,7 +1339,7 @@ char		*desc,*start;
     if ( rep->totalVModMapKeys>0 )
 	desc= XkbWriteVirtualModMap(xkb,rep,desc,client);
     if ((desc-start)!=(len)) {
-	ErrorF("BOGUS LENGTH in write keyboard desc, expected %d, got %ld\n",
+	ErrorF("[xkb] BOGUS LENGTH in write keyboard desc, expected %d, got %ld\n",
 					len, (unsigned long)(desc-start));
     }
     if (client->swapped) {
@@ -2374,7 +2374,7 @@ ProcXkbSetMap(ClientPtr client)
 	return BadValue;
     }
     if (((tmp-((char *)stuff))/4)!=stuff->length) {
-	ErrorF("Internal error! Bad length in XkbSetMap (after check)\n");
+	ErrorF("[xkb] Internal error! Bad length in XkbSetMap (after check)\n");
 	client->errorValue = tmp-((char *)&stuff[1]);
 	return BadLength;
     }
@@ -2425,7 +2425,7 @@ ProcXkbSetMap(ClientPtr client)
     if (stuff->present&XkbVirtualModMapMask)
 	tmp= SetVirtualModMap(xkbi,stuff,(xkbVModMapWireDesc *)tmp,&change);
     if (((tmp-((char *)stuff))/4)!=stuff->length) {
-	ErrorF("Internal error! Bad length in XkbSetMap (after set)\n");
+	ErrorF("[xkb] Internal error! Bad length in XkbSetMap (after set)\n");
 	client->errorValue = tmp-((char *)&stuff[1]);
 	return BadLength;
     }
@@ -2701,7 +2701,7 @@ ProcXkbSetCompatMap(ClientPtr client)
     }
     i= XkbPaddedSize((data-((char *)stuff)));
     if ((i/4)!=stuff->length) {
-	ErrorF("Internal length error on read in ProcXkbSetCompatMap\n");
+	ErrorF("[xkb] Internal length error on read in ProcXkbSetCompatMap\n");
 	return BadLength;
     }
     
@@ -3411,7 +3411,7 @@ register int            n;
     }
 
     if ((desc-start)!=(length)) {
-	ErrorF("BOGUS LENGTH in write names, expected %d, got %ld\n",
+	ErrorF("[xkb] BOGUS LENGTH in write names, expected %d, got %ld\n",
 					length, (unsigned long)(desc-start));
     }
     WriteToClient(client, SIZEOF(xkbGetNamesReply), (char *)rep);
@@ -4102,9 +4102,9 @@ xkbDoodadWireDesc *	doodadWire;
 		wire= XkbWriteCountedString(wire,doodad->logo.logo_name,swap);
 		break;
 	    default:
-		ErrorF("Unknown doodad type %d in XkbWriteGeomDoodads\n",
+		ErrorF("[xkb] Unknown doodad type %d in XkbWriteGeomDoodads\n",
 			doodad->any.type);
-		ErrorF("Ignored\n");
+		ErrorF("[xkb] Ignored\n");
 		break;
 	}
     }
@@ -4332,7 +4332,7 @@ XkbSendGeometry(	ClientPtr		client,
 	if ( rep->nKeyAliases>0 )
 	    desc = XkbWriteGeomKeyAliases(desc,geom,client->swapped);
 	if ((desc-start)!=(len)) {
-	    ErrorF("BOGUS LENGTH in XkbSendGeometry, expected %d, got %ld\n",
+	    ErrorF("[xkb] BOGUS LENGTH in XkbSendGeometry, expected %d, got %ld\n",
 			len, (unsigned long)(desc-start));
 	}
     }
@@ -5781,8 +5781,8 @@ char *			str;
     }
     else if (length!=0)  {
 #ifdef DEBUG
-	ErrorF("Internal Error!  BadLength in ProcXkbGetDeviceInfo\n");
-	ErrorF("                 Wrote %d fewer bytes than expected\n",length);
+	ErrorF("[xkb] Internal Error!  BadLength in ProcXkbGetDeviceInfo\n");
+	ErrorF("[xkb]                  Wrote %d fewer bytes than expected\n",length);
 #endif
 	return BadLength;
     }
@@ -6078,25 +6078,25 @@ xkbSetDebuggingFlagsReply 	rep;
     newCtrls=  xkbDebugCtrls&(~stuff->affectCtrls);
     newCtrls|= (stuff->ctrls&stuff->affectCtrls);
     if (xkbDebugFlags || newFlags || stuff->msgLength) {
-	ErrorF("XkbDebug: Setting debug flags to 0x%lx\n",(long)newFlags);
+	ErrorF("[xkb] XkbDebug: Setting debug flags to 0x%lx\n",(long)newFlags);
 	if (newCtrls!=xkbDebugCtrls)
-	    ErrorF("XkbDebug: Setting debug controls to 0x%lx\n",(long)newCtrls);
+	    ErrorF("[xkb] XkbDebug: Setting debug controls to 0x%lx\n",(long)newCtrls);
     }
     extraLength= (stuff->length<<2)-sz_xkbSetDebuggingFlagsReq;
     if (stuff->msgLength>0) {
 	char *msg;
 	if (extraLength<XkbPaddedSize(stuff->msgLength)) {
-	    ErrorF("XkbDebug: msgLength= %d, length= %ld (should be %d)\n",
+	    ErrorF("[xkb] XkbDebug: msgLength= %d, length= %ld (should be %d)\n",
 			stuff->msgLength,(long)extraLength,
 			XkbPaddedSize(stuff->msgLength));
 	    return BadLength;
 	}
 	msg= (char *)&stuff[1];
 	if (msg[stuff->msgLength-1]!='\0') {
-	    ErrorF("XkbDebug: message not null-terminated\n");
+	    ErrorF("[xkb] XkbDebug: message not null-terminated\n");
 	    return BadValue;
 	}
-	ErrorF("XkbDebug: %s\n",msg);
+	ErrorF("[xkb] XkbDebug: %s\n",msg);
     }
     xkbDebugFlags = newFlags;
     xkbDebugCtrls = newCtrls;
@@ -6193,7 +6193,7 @@ XkbClientGone(pointer data,XID id)
     DevicePtr	pXDev = (DevicePtr)data;
 
     if (!XkbRemoveResourceClient(pXDev,id)) {
-	ErrorF("Internal Error! bad RemoveResourceClient in XkbClientGone\n");
+	ErrorF("[xkb] Internal Error! bad RemoveResourceClient in XkbClientGone\n");
     }
     return 1;
 }
diff --git a/xkb/xkbAccessX.c b/xkb/xkbAccessX.c
index 2954a0c..8e897c8 100644
--- a/xkb/xkbAccessX.c
+++ b/xkb/xkbAccessX.c
@@ -132,7 +132,7 @@ xEvent		xE;
     xE.u.keyButtonPointer.time = GetTimeInMillis();	    
 #ifdef DEBUG
     if (xkbDebugFlags&0x8) {
-	ErrorF("AXKE: Key %d %s\n",keyCode,(xE.u.u.type==KeyPress?"down":"up"));
+	ErrorF("[xkb] AXKE: Key %d %s\n",keyCode,(xE.u.u.type==KeyPress?"down":"up"));
     }
 #endif
 
@@ -530,7 +530,7 @@ KeySym *	sym = XkbKeySymsPtr(xkbi->desc,
 	    if (BitIsOn(keybd->kbdfeed->ctrl.autoRepeats,key)) {
 #ifdef DEBUG
 		if (xkbDebugFlags&0x10)
-		    ErrorF("Starting software autorepeat...\n");
+		    ErrorF("[xkb] Starting software autorepeat...\n");
 #endif	    
 		xkbi->repeatKey = key;
 		xkbi->repeatKeyTimer= TimerSet(xkbi->repeatKeyTimer,
diff --git a/xkb/xkbEvents.c b/xkb/xkbEvents.c
index b387a8c..64cddd0 100644
--- a/xkb/xkbEvents.c
+++ b/xkb/xkbEvents.c
@@ -818,15 +818,15 @@ GrabInfoPtr grabinfo;
 		((xE[0].u.u.type==KeyPress)||(xE[0].u.u.type==KeyRelease)||
                  (xE[0].u.u.type==DeviceKeyPress)||
                  (xE[0].u.u.type == DeviceKeyRelease))) {
-	    ErrorF("XKbFilterWriteEvents:\n");
-	    ErrorF("   Event state= 0x%04x\n",xE[0].u.keyButtonPointer.state);
-	    ErrorF("   XkbLastRepeatEvent!=xE (0x%p!=0x%p) %s\n",
+	    ErrorF("[xkb] XKbFilterWriteEvents:\n");
+	    ErrorF("[xkb]    Event state= 0x%04x\n",xE[0].u.keyButtonPointer.state);
+	    ErrorF("[xkb]    XkbLastRepeatEvent!=xE (0x%p!=0x%p) %s\n",
 			XkbLastRepeatEvent,xE,
 			((XkbLastRepeatEvent!=(pointer)xE)?"True":"False"));
-	    ErrorF("   (xkbClientEventsFlags&XWDA)==0 (0x%x) %s\n",
+	    ErrorF("[xkb]    (xkbClientEventsFlags&XWDA)==0 (0x%x) %s\n",
 		pClient->xkbClientFlags,
 		(_XkbWantsDetectableAutoRepeat(pClient)?"True":"False"));
-	    ErrorF("   !IsRelease(%d) %s\n",xE[0].u.u.type,
+	    ErrorF("[xkb]    !IsRelease(%d) %s\n",xE[0].u.u.type,
 			(!_XkbIsReleaseEvent(xE[0].u.u.type))?"True":"False");
 	}
 #endif /* DEBUG */
@@ -872,7 +872,7 @@ GrabInfoPtr grabinfo;
 	     * when the mouse is released, the server does not behave properly.
 	     * Faking a release of the button here solves the problem.
 	     */
-	    ErrorF("Faking release of button %d\n", xE[0].u.u.detail);
+	    ErrorF("[xkb] Faking release of button %d\n", xE[0].u.u.detail);
 #endif
 	    XkbDDXFakePointerButton(ButtonRelease, xE[0].u.u.detail);
         }
@@ -888,11 +888,11 @@ GrabInfoPtr grabinfo;
                  (xE[i].u.u.type==DeviceKeyPress)||
                  (xE[i].u.u.type == DeviceKeyRelease))) {
 		XkbStatePtr s= &xkbi->state;
-		ErrorF("XKbFilterWriteEvents (non-XKB):\n");
-		ErrorF("event= 0x%04x\n",xE[i].u.keyButtonPointer.state);
-		ErrorF("lookup= 0x%02x, grab= 0x%02x\n",s->lookup_mods,
+		ErrorF("[xkb] XKbFilterWriteEvents (non-XKB):\n");
+		ErrorF("[xkb] event= 0x%04x\n",xE[i].u.keyButtonPointer.state);
+		ErrorF("[xkb] lookup= 0x%02x, grab= 0x%02x\n",s->lookup_mods,
 							s->grab_mods);
-		ErrorF("compat lookup= 0x%02x, grab= 0x%02x\n",
+		ErrorF("[xkb] compat lookup= 0x%02x, grab= 0x%02x\n",
 							s->compat_lookup_mods,
 							s->compat_grab_mods);
 	    }
@@ -930,14 +930,14 @@ GrabInfoPtr grabinfo;
 		((xE[i].u.keyButtonPointer.state >> 7) & button_mask) == button_mask &&
 		(xkbi->lockedPtrButtons & button_mask) == button_mask) {
 #ifdef DEBUG
-		ErrorF("Faking release of button %d\n", xE[i].u.u.detail);
+		ErrorF("[xkb] Faking release of button %d\n", xE[i].u.u.detail);
 #endif
 		XkbDDXFakePointerButton(ButtonRelease, xE[i].u.u.detail);
 	    } else if (type == DeviceButtonPress &&
                     ((((deviceKeyButtonPointer*)&xE[i])->state >> 7) & button_mask) == button_mask &&
                     (xkbi->lockedPtrButtons & button_mask) == button_mask) {
 #ifdef DEBUG
-		ErrorF("Faking release of button %d\n", ((deviceKeyButtonPointer*)&xE[i])->state);
+		ErrorF("[xkb] Faking release of button %d\n", ((deviceKeyButtonPointer*)&xE[i])->state);
 #endif
 		XkbDDXFakePointerButton(DeviceButtonRelease, ((deviceKeyButtonPointer*)&xE[i])->state);
             }
diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c
index c0867ad..bcfd149 100644
--- a/xkb/xkbInit.c
+++ b/xkb/xkbInit.c
@@ -179,12 +179,12 @@ char *			pval;
 
     name= MakeAtom(_XKB_RF_NAMES_PROP_ATOM,strlen(_XKB_RF_NAMES_PROP_ATOM),1);
     if (name==None) {
-	ErrorF("Atom error: %s not created\n",_XKB_RF_NAMES_PROP_ATOM);
+	ErrorF("[xkb] Atom error: %s not created\n",_XKB_RF_NAMES_PROP_ATOM);
 	return True;
     }
     pval= (char*) ALLOCATE_LOCAL(len);
     if (!pval) {
-	ErrorF("Allocation error: %s proprerty not created\n",
+	ErrorF("[xkb] Allocation error: %s proprerty not created\n",
 						_XKB_RF_NAMES_PROP_ATOM);
 	return True;
     }
@@ -218,7 +218,7 @@ char *			pval;
     }
     pval[out++]= '\0';
     if (out!=len) {
-	ErrorF("Internal Error! bad size (%d!=%d) for _XKB_RULES_NAMES\n",
+	ErrorF("[xkb] Internal Error! bad size (%d!=%d) for _XKB_RULES_NAMES\n",
 								out,len);
     }
     ChangeWindowProperty(WindowTable[0],name,XA_STRING,8,PropModeReplace,
@@ -511,7 +511,7 @@ XkbEventCauseRec	cause;
 	    /*                 the other here, but for now just complain */
 	    /*                 can't just update the core range without */
 	    /*                 reallocating the KeySymsRec (pain)       */
-	    ErrorF("Internal Error!! XKB and core keymap have different range\n");
+	    ErrorF("[xkb] Internal Error!! XKB and core keymap have different range\n");
 	}
 	if (XkbAllocClientMap(xkb,XkbAllClientInfoMask,0)!=Success)
 	    FatalError("Couldn't allocate client map in XkbInitDevice\n");
@@ -772,7 +772,7 @@ XkbSrvLedInfoPtr	sli;
     if (sli && xkbi)
 	XkbCheckIndicatorMaps(xkbi->device,sli,XkbAllIndicatorsMask);
 #ifdef DEBUG
-    else ErrorF("No indicator feedback in XkbFinishInit (shouldn't happen)!\n");
+    else ErrorF("[xkb] No indicator feedback in XkbFinishInit (shouldn't happen)!\n");
 #endif
     return softRepeat;
 }
diff --git a/xkb/xkbPrKeyEv.c b/xkb/xkbPrKeyEv.c
index ba3fcc0..212ee94 100644
--- a/xkb/xkbPrKeyEv.c
+++ b/xkb/xkbPrKeyEv.c
@@ -58,7 +58,7 @@ int             xiEvent;
     xiEvent= (xE->u.u.type & EXTENSION_EVENT_BASE);
 #ifdef DEBUG
     if (xkbDebugFlags&0x8) {
-	ErrorF("XkbPKE: Key %d %s\n",key,(xE->u.u.type==KeyPress?"down":"up"));
+	ErrorF("[xkb] XkbPKE: Key %d %s\n",key,(xE->u.u.type==KeyPress?"down":"up"));
     }
 #endif
 
@@ -162,7 +162,7 @@ int             xiEvent;
 		    }
 		    rg->currentDown= key;
 		}
-		else ErrorF("InternalError! Illegal radio group %d\n",ndx);
+		else ErrorF("[xkb] InternalError! Illegal radio group %d\n",ndx);
 		break;
 	    case XkbKB_Overlay1: case XkbKB_Overlay2:
 		{
@@ -182,7 +182,7 @@ int             xiEvent;
 		}
 		break;
 	    default:
-		ErrorF("unknown key behavior 0x%04x\n",behavior.type);
+		ErrorF("[xkb] unknown key behavior 0x%04x\n",behavior.type);
 		break;
 	}
     }
@@ -201,7 +201,7 @@ XkbSrvInfoPtr	xkbi;
 #ifdef DEBUG
     if (xkbDebugFlags&0x8) {
 	int key= xE->u.u.detail;
-	ErrorF("PKE: Key %d %s\n",key,(xE->u.u.type==KeyPress?"down":"up"));
+	ErrorF("[xkb] PKE: Key %d %s\n",key,(xE->u.u.type==KeyPress?"down":"up"));
     }
 #endif
     if ((xkbi->desc->ctrls->enabled_ctrls&XkbAllFilteredEventsMask)==0)
diff --git a/xkb/xkbSwap.c b/xkb/xkbSwap.c
index da4c905..bbb2a91 100644
--- a/xkb/xkbSwap.c
+++ b/xkb/xkbSwap.c
@@ -129,7 +129,7 @@ register int n;
 	    dataLeft-= (size*2);
 	}
 	if (dataLeft>2) {
-	    ErrorF("Extra data (%d bytes) after SelectEvents\n",dataLeft);
+	    ErrorF("[xkb] Extra data (%d bytes) after SelectEvents\n",dataLeft);
 	    return BadLength;
 	}
     }
diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index c7f9a26..e87064a 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -2010,7 +2010,7 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
 
     if (sendNotifies) {
         if (!pDev) {
-            ErrorF("XkbCopyKeymap: asked for notifies, but can't find device!\n");
+            ErrorF("[xkb] XkbCopyKeymap: asked for notifies, but can't find device!\n");
         }
         else {
             /* send NewKeyboardNotify if the keycode range changed, else
diff-tree 8b508f5d6bd0d3995294d5ff300a856754442999 (from 394f3c1dbee7270a1d930846d49278424c3072d4)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Wed Sep 26 15:19:53 2007 +0930

    dix: unify ErrorFs. prepend all with [dix].

diff --git a/dix/access.c b/dix/access.c
index 2015716..e7d39b4 100644
--- a/dix/access.c
+++ b/dix/access.c
@@ -143,7 +143,7 @@ ACChangeWindowAccess(ClientPtr client, 
 
     if (!win->optional && !MakeWindowOptional(win))
     {
-        ErrorF("ACChangeWindowAcccess: Failed to make window optional.\n");
+        ErrorF("[dix] ACChangeWindowAcccess: Failed to make window optional.\n");
         return BadImplementation;
     }
 
@@ -183,7 +183,7 @@ acReplaceList(DeviceIntPtr** list, 
             xalloc(ndevices * sizeof(DeviceIntPtr*));
         if (!*list)
         {
-            ErrorF("ACChangeWindowAccess: out of memory\n");
+            ErrorF("[dix] ACChangeWindowAccess: out of memory\n");
             return;
         }
         memcpy(*list,
@@ -223,7 +223,7 @@ ACQueryWindowAccess(WindowPtr win, 
         *perm = (DeviceIntPtr*)xalloc(*nperm * sizeof(DeviceIntPtr));
         if (!*perm)
         {
-            ErrorF("ACQuerywinAccess: xalloc failure\n");
+            ErrorF("[dix] ACQuerywinAccess: xalloc failure\n");
             return;
         }
         memcpy(*perm, 
@@ -237,7 +237,7 @@ ACQueryWindowAccess(WindowPtr win, 
         *deny = (DeviceIntPtr*)xalloc(*ndeny * sizeof(DeviceIntPtr));
         if (!*deny)
         {
-            ErrorF("ACQuerywinAccess: xalloc failure\n");
+            ErrorF("[dix] ACQuerywinAccess: xalloc failure\n");
             return;
         }
         memcpy(*deny, 
diff --git a/dix/devices.c b/dix/devices.c
index 3ce045c..63d7ea4 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -220,7 +220,7 @@ EnableDevice(DeviceIntPtr dev)
 
     if ((*prev != dev) || !dev->inited ||
 	((ret = (*dev->deviceProc)(dev, DEVICE_ON)) != Success)) {
-        ErrorF("couldn't enable device %d\n", dev->id);
+        ErrorF("[dix] couldn't enable device %d\n", dev->id);
 	return FALSE;
     }
     dev->enabled = TRUE;
@@ -357,13 +357,13 @@ CoreKeyboardProc(DeviceIntPtr pDev, int 
                                          keySyms.minKeyCode + 1) *
                                         keySyms.mapWidth);
         if (!keySyms.map) {
-            ErrorF("Couldn't allocate core keymap\n");
+            ErrorF("[dix] Couldn't allocate core keymap\n");
             return BadAlloc;
         }
 
         modMap = (CARD8 *)xalloc(MAP_LENGTH);
         if (!modMap) {
-            ErrorF("Couldn't allocate core modifier map\n");
+            ErrorF("[dix] Couldn't allocate core modifier map\n");
             return BadAlloc;
         }
         bzero((char *)modMap, MAP_LENGTH);
@@ -529,11 +529,11 @@ InitAndStartDevices(WindowPtr root)
     }
 
     if (!inputInfo.keyboard) {
-	ErrorF("No core keyboard\n");
+	ErrorF("[dix] No core keyboard\n");
 	return BadImplementation;
     }
     if (!inputInfo.pointer) {
-	ErrorF("No core pointer\n");
+	ErrorF("[dix] No core pointer\n");
 	return BadImplementation;
     }
 
diff --git a/dix/dixfonts.c b/dix/dixfonts.c
index c21b3ec..9d3bf08 100644
--- a/dix/dixfonts.c
+++ b/dix/dixfonts.c
@@ -378,7 +378,7 @@ OpenFont(ClientPtr client, XID fid, Mask
     f = (char *)xalloc(lenfname + 1);
     memmove(f, pfontname, lenfname);
     f[lenfname] = '\0';
-    ErrorF("OpenFont: fontname is \"%s\"\n", f);
+    ErrorF("[dix] OpenFont: fontname is \"%s\"\n", f);
     xfree(f);
 #endif
     if (!lenfname || lenfname > XLFDMAXFONTNAMELEN)
@@ -1628,7 +1628,7 @@ FreeFontPath(FontPathElementPtr *list, i
 		    found++;
 	    }
 	    if (list[i]->refcount != found) {
-		ErrorF("FreeFontPath: FPE \"%.*s\" refcount is %d, should be %d; fixing.\n",
+		ErrorF("[dix] FreeFontPath: FPE \"%.*s\" refcount is %d, should be %d; fixing.\n",
 		       list[i]->name_length, list[i]->name,
 		       list[i]->refcount, found);
 		list[i]->refcount = found; /* ensure it will get freed */
@@ -1680,7 +1680,7 @@ SetFontPathElements(int npaths, unsigned
 	if (len == 0) 
 	{
 	    if (persist)
-		ErrorF ("Removing empty element from the valid list of fontpaths\n");
+		ErrorF("[dix] Removing empty element from the valid list of fontpaths\n");
 	    err = BadValue;
 	}
 	else
@@ -1732,7 +1732,7 @@ SetFontPathElements(int npaths, unsigned
 		{
 		    if (persist)
 		    {
-			ErrorF("Could not init font path element %s, removing from list!\n",
+			ErrorF("[dix] Could not init font path element %s, removing from list!\n",
 			       fpe->name);
 		    }
 		    xfree (fpe->name);
diff --git a/dix/dixutils.c b/dix/dixutils.c
index c1e30ff..dc4e08c 100644
--- a/dix/dixutils.c
+++ b/dix/dixutils.c
@@ -288,7 +288,7 @@ SecurityLookupWindow(XID id, ClientPtr c
     int i = dixLookupWindow(&pWin, id, client, access_mode);
     static int warn = 1;
     if (warn-- > 0)
-	ErrorF("Warning: LookupWindow()/SecurityLookupWindow() "
+	ErrorF("[dix] Warning: LookupWindow()/SecurityLookupWindow() "
 	       "are deprecated.  Please convert your driver/module "
 	       "to use dixLookupWindow().\n");
     return (i == Success) ? pWin : NULL;
@@ -307,7 +307,7 @@ SecurityLookupDrawable(XID id, ClientPtr
     int i = dixLookupDrawable(&pDraw, id, client, M_DRAWABLE, access_mode);
     static int warn = 1;
     if (warn-- > 0)
-	ErrorF("Warning: LookupDrawable()/SecurityLookupDrawable() "
+	ErrorF("[dix] Warning: LookupDrawable()/SecurityLookupDrawable() "
 	       "are deprecated.  Please convert your driver/module "
 	       "to use dixLookupDrawable().\n");
     return (i == Success) ? pDraw : NULL;
@@ -326,7 +326,7 @@ LookupClient(XID id, ClientPtr client)
     int i = dixLookupClient(&pClient, id, client, DixUnknownAccess);
     static int warn = 1;
     if (warn-- > 0)
-	ErrorF("Warning: LookupClient() is deprecated.  Please convert your "
+	ErrorF("[dix] Warning: LookupClient() is deprecated.  Please convert your "
 	       "driver/module to use dixLookupClient().\n");
     return (i == Success) ? pClient : NULL;
 }
diff --git a/dix/events.c b/dix/events.c
index 7d69ca5..b396b65 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -1887,7 +1887,7 @@ TryClientEvents (ClientPtr client, xEven
     int type;
 
 #ifdef DEBUG_EVENTS
-    ErrorF("Event([%d, %d], mask=0x%x), client=%d",
+    ErrorF("[dix] Event([%d, %d], mask=0x%x), client=%d",
 	pEvents->u.u.type, pEvents->u.u.detail, mask, client->index);
 #endif
     if ((client) && (client != serverClient) && (!client->clientGone) &&
@@ -1904,8 +1904,8 @@ TryClientEvents (ClientPtr client, xEven
 		    pEvents->u.keyButtonPointer.event)
 		{
 #ifdef DEBUG_EVENTS
-		    ErrorF("\n");
-	    ErrorF("motionHintWindow == keyButtonPointer.event\n");
+		    ErrorF("[dix] \n");
+	    ErrorF("[dix] motionHintWindow == keyButtonPointer.event\n");
 #endif
 		    return 1; /* don't send, but pretend we did */
 		}
@@ -1944,14 +1944,14 @@ TryClientEvents (ClientPtr client, xEven
 
 	WriteEventsToClient(client, count, pEvents);
 #ifdef DEBUG_EVENTS
-	ErrorF(  " delivered\n");
+	ErrorF("[dix]  delivered\n");
 #endif
 	return 1;
     }
     else
     {
 #ifdef DEBUG_EVENTS
-	ErrorF("\n");
+	ErrorF("[dix] \n");
 #endif
 	return 0;
     }
@@ -2031,7 +2031,7 @@ DeliverEventsToWindow(DeviceIntPtr pDev,
             /* We don't do more than one GenericEvent at a time. */
             if (count > 1)
             {
-                ErrorF("Do not send more than one GenericEvent at a time!\n");
+                ErrorF("[dix] Do not send more than one GenericEvent at a time!\n");
                 return 0;
             }
 
@@ -2355,7 +2355,7 @@ DeliverDeviceEvents(WindowPtr pWin, xEve
 
             if (count > 1)
             {
-                ErrorF("Do not send more than one GenericEvent at a time!\n");
+                ErrorF("[dix] Do not send more than one GenericEvent at a time!\n");
                 return 0;
             }
             filter = generic_filters[GEEXTIDX(xE)][ge->evtype];
@@ -5942,7 +5942,7 @@ WriteEventsToClient(ClientPtr pClient, i
     {
         if (events[i].u.u.type == GenericEvent)
         {
-            ErrorF("TryClientEvents: Only one GenericEvent at a time.");
+            ErrorF("[dix] TryClientEvents: Only one GenericEvent at a time.\n");
             return; 
         }
     }
@@ -6028,7 +6028,7 @@ PickPointer(ClientPtr client)
 
         if (!it)
         {
-            ErrorF("Picking VCP\n");
+            ErrorF("[dix] Picking VCP\n");
             return inputInfo.pointer;
         }
     }
diff --git a/dix/main.c b/dix/main.c
index 5d24922..d78d7e8 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -402,7 +402,7 @@ main(int argc, char *argv[], char *envp[
 	}
         else {
 	    if (SetDefaultFontPath(defaultFontPath) != Success)
-		ErrorF("failed to set default font path '%s'",
+		ErrorF("[dix] failed to set default font path '%s'",
 			defaultFontPath);
 	}
 	if (!SetDefaultFont(defaultTextFont)) {
diff --git a/dix/property.c b/dix/property.c
index e281dd7..6768100 100644
--- a/dix/property.c
+++ b/dix/property.c
@@ -81,11 +81,11 @@ PrintPropertys(WindowPtr pWin)
     pProp = pWin->userProps;
     while (pProp)
     {
-        ErrorF(  "%x %x\n", pProp->propertyName, pProp->type);
-        ErrorF("property format: %d\n", pProp->format);
-        ErrorF("property data: \n");
+        ErrorF("[dix] %x %x\n", pProp->propertyName, pProp->type);
+        ErrorF("[dix] property format: %d\n", pProp->format);
+        ErrorF("[dix] property data: \n");
         for (j=0; j<(pProp->format/8)*pProp->size; j++)
-           ErrorF("%c\n", pProp->data[j]);
+           ErrorF("[dix] %c\n", pProp->data[j]);
         pProp = pProp->next;
     }
 }
diff --git a/dix/resource.c b/dix/resource.c
index e83c529..e5bc900 100644
--- a/dix/resource.c
+++ b/dix/resource.c
@@ -468,7 +468,7 @@ AddResource(XID id, RESTYPE type, pointe
     rrec = &clientTable[client];
     if (!rrec->buckets)
     {
-	ErrorF("AddResource(%lx, %lx, %lx), client=%d \n",
+	ErrorF("[dix] AddResource(%lx, %lx, %lx), client=%d \n",
 		(unsigned long)id, type, (unsigned long)value, client);
         FatalError("client not in use\n");
     }
@@ -589,7 +589,7 @@ FreeResource(XID id, RESTYPE skipDeleteF
 	}
     }
     if (!gotOne)
-	ErrorF("Freeing resource id=%lX which isn't there.\n",
+	ErrorF("[dix] Freeing resource id=%lX which isn't there.\n",
 		   (unsigned long)id);
 }
 
diff --git a/dix/window.c b/dix/window.c
index 3247446..f296d34 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -206,8 +206,9 @@ PrintChildren(WindowPtr p1, int indent)
     while (p1)
     {
 	p2 = p1->firstChild;
-	for (i=0; i<indent; i++) ErrorF( " ");
-	ErrorF( "%lx\n", p1->drawable.id);
+        ErrorF("[dix] ");
+	for (i=0; i<indent; i++) ErrorF(" ");
+	ErrorF("%lx\n", p1->drawable.id);
 	miPrintRegion(&p1->clipList);
 	PrintChildren(p2, indent+4);
 	p1 = p1->nextSib;
@@ -222,7 +223,7 @@ PrintWindowTree(void)
 
     for (i=0; i<screenInfo.numScreens; i++)
     {
-	ErrorF( "WINDOW %d\n", i);
+	ErrorF("[dix] WINDOW %d\n", i);
 	pWin = WindowTable[i];
 	miPrintRegion(&pWin->clipList);
 	p1 = pWin->firstChild;
@@ -2232,7 +2233,7 @@ WhereDoIGoInTheStack(
 	    return pWin->nextSib;
       default:
       {
-	ErrorF("Internal error in ConfigureWindow, smode == %d\n",smode );
+	ErrorF("[dix] Internal error in ConfigureWindow, smode == %d\n",smode );
 	return pWin->nextSib;
       }
     }
diff-tree 394f3c1dbee7270a1d930846d49278424c3072d4 (from 55fd50273ea67eb99a0c8a830349851931298387)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Wed Sep 26 15:19:37 2007 +0930

    dix: GetPointerEvents: remove unused variable compiler warning.

diff --git a/dix/getevents.c b/dix/getevents.c
index 12ddc82..df1dc6a 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -550,7 +550,6 @@ GetPointerEvents(EventList *events, Devi
     /* Thanks to a broken lib, we _always_ have to chase DeviceMotionNotifies
      * with DeviceValuators. */
     Bool sendValuators = (type == MotionNotify || flags & POINTER_ABSOLUTE);
-    DeviceIntPtr pointer = NULL;
     int x = 0, y = 0;
     /* The core pointer must not send Xi events. */
     Bool coreOnly = (pDev == inputInfo.pointer);
diff-tree 55fd50273ea67eb99a0c8a830349851931298387 (from 340911d7243a7f1095d79b5b2dcfa81b145c2474)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Wed Sep 26 15:15:34 2007 +0930

    Xi: unify ErrorFs. Prefix all with [Xi].

diff --git a/Xi/chaccess.c b/Xi/chaccess.c
index f099206..2a0e5fa 100644
--- a/Xi/chaccess.c
+++ b/Xi/chaccess.c
@@ -110,7 +110,7 @@ ProcXChangeWindowAccess(ClientPtr client
             (DeviceIntPtr*)xalloc(stuff->npermit * sizeof(DeviceIntPtr));
         if (!perm_devices)
         {
-            ErrorF("ProcXChangeWindowAccess: alloc failure.\n");
+            ErrorF("[Xi] ProcXChangeWindowAccess: alloc failure.\n");
             SendErrorToClient(client, IReqCode, X_ChangeWindowAccess, 0, 
                     BadImplementation);
             return Success;
@@ -136,7 +136,7 @@ ProcXChangeWindowAccess(ClientPtr client
             (DeviceIntPtr*)xalloc(stuff->ndeny * sizeof(DeviceIntPtr));
         if (!deny_devices)
         {
-            ErrorF("ProcXChangeWindowAccecss: alloc failure.\n");
+            ErrorF("[Xi] ProcXChangeWindowAccecss: alloc failure.\n");
             SendErrorToClient(client, IReqCode, X_ChangeWindowAccess, 0, 
                     BadImplementation);
 
diff --git a/Xi/extinit.c b/Xi/extinit.c
index 1d23809..c1b6eed 100644
--- a/Xi/extinit.c
+++ b/Xi/extinit.c
@@ -891,7 +891,7 @@ FixExtensionEvents(ExtensionEntry * extE
     {
         /* This should never happen, but if it does, hide under the
          * bed and cry for help. */
-        ErrorF("DeviceButtonMotionMask != ButtonMotionMask. Trouble!\n");
+        ErrorF("[Xi] DeviceButtonMotionMask != ButtonMotionMask. Trouble!\n");
     }
 
     DeviceFocusChangeMask = GetNextExtEventMask();
diff --git a/Xi/qryacces.c b/Xi/qryacces.c
index b596969..95f2dd0 100644
--- a/Xi/qryacces.c
+++ b/Xi/qryacces.c
@@ -99,7 +99,7 @@ ProcXQueryWindowAccess(ClientPtr client)
         deviceids = (XID*)xalloc((nperm + ndeny) * sizeof(XID));
         if (!deviceids)
         {
-            ErrorF("ProcXQueryWindowAccess: xalloc failure.\n");
+            ErrorF("[Xi] ProcXQueryWindowAccess: xalloc failure.\n");
             SendErrorToClient(client, IReqCode, X_QueryWindowAccess, 
                     0, BadImplementation); 
             return Success;
diff-tree 340911d7243a7f1095d79b5b2dcfa81b145c2474 (from b2a4883bd89d406713d4f808e72721ecc1456d67)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Wed Sep 26 15:12:49 2007 +0930

    Wrap core event handling through ProcessOtherEvents.
    
    When processing events from the EQ, _always_ call the processInputProc of the
    matching device. For XI devices, this proc is wrapped in three layers.
    Core event handling is wrapped by XI event handling, which is wrapped by XKB.
    A core event now passes through XKB -> XI -> DIX.
    
    This gets rid of a sync'd grab problem: with the previous code, core events
    did disappear during a sync'd device grab on account of mieqProcessInputEvents
    calling the processInputProc of the VCP/VCK instead of the actual device. This
    lead to the event being processed as normal instead of being enqueued for
    later replaying.

diff --git a/Xi/exevents.c b/Xi/exevents.c
index aa2b4c9..2baaa58 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -89,26 +89,56 @@ Bool ShouldFreeInputMasks(WindowPtr /* p
 static Bool MakeInputMasks(WindowPtr	/* pWin */
     );
 
+static int xiDevPrivateIndex = 0;
+static int _xiServerGeneration = -1;
+
+typedef struct {
+    ProcessInputProc processInputProc;
+    ProcessInputProc realInputProc;
+} xiDevPrivateRec, *xiDevPrivatePtr;
+
 /**************************************************************************
  *
  * Procedures for extension device event routing.
  *
  */
 
+#define WRAP_PROCESS_INPUT_PROC(device, saveprocs, newproc) \
+    saveprocs->processInputProc = device->public.processInputProc; \
+    saveprocs->realInputProc = device->public.realInputProc; \
+    device->public.processInputProc = newproc; \
+    device->public.realInputProc = newproc;
+
+#define UNWRAP_PROCESS_INPUT_PROC(device, saveprocs) \
+    device->public.processInputProc = saveprocs->processInputProc; \
+    device->public.realInputProc = saveprocs->realInputProc; 
+
 void
 RegisterOtherDevice(DeviceIntPtr device)
 {
-    device->public.processInputProc = ProcessOtherEvent;
-    device->public.realInputProc = ProcessOtherEvent;
-    if (DeviceIsPointerType(device))
-    {
-        (device)->deviceGrab.ActivateGrab = ActivatePointerGrab;
-        (device)->deviceGrab.DeactivateGrab = DeactivatePointerGrab;
-    } else 
+    xiDevPrivatePtr xiPrivPtr;
+
+    if (serverGeneration != _xiServerGeneration)
     {
-        (device)->deviceGrab.ActivateGrab = ActivateKeyboardGrab;
-        (device)->deviceGrab.DeactivateGrab = DeactivateKeyboardGrab;
+        xiDevPrivateIndex = AllocateDevicePrivateIndex();
+        if (xiDevPrivateIndex == 1)
+        {
+            FatalError("[Xi] Could not allocate private index.\n"); 
+        }
+        _xiServerGeneration = serverGeneration;
     }
+
+    if (!AllocateDevicePrivate(device, xiDevPrivateIndex))
+        FatalError("[Xi] Dev private allocation failed.\n");
+
+
+    xiPrivPtr = (xiDevPrivatePtr)xcalloc(1, sizeof(xiDevPrivateRec));
+    if (!xiPrivPtr)
+        FatalError("[Xi] Cannot get memory for dev private.\n");
+
+    device->devPrivates[xiDevPrivateIndex].ptr = xiPrivPtr;
+
+    WRAP_PROCESS_INPUT_PROC(device, xiPrivPtr, ProcessOtherEvent);
 }
 
  /*ARGSUSED*/ void
@@ -126,6 +156,17 @@ ProcessOtherEvent(xEventPtr xE, DeviceIn
     ValuatorClassPtr v = device->valuator;
     deviceValuator *xV = (deviceValuator *) xE;
 
+    /* Handle core events. */
+    if (xE->u.u.type < LASTEvent && xE->u.u.type != GenericEvent)
+    {
+        xiDevPrivatePtr xiPrivPtr = 
+            (xiDevPrivatePtr)device->devPrivates[xiDevPrivateIndex].ptr;
+        UNWRAP_PROCESS_INPUT_PROC(device, xiPrivPtr);
+        device->public.processInputProc(xE, device, count);
+        WRAP_PROCESS_INPUT_PROC(device, xiPrivPtr, ProcessOtherEvent);
+        return;
+    }
+
     CheckMotion(xE, device);
 
     if (xE->u.u.type != DeviceValuator && xE->u.u.type != GenericEvent) {
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 2436231..31c3008 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -179,15 +179,33 @@ xf86ActivateDevice(LocalDevicePtr local)
         dev->coreEvents = local->flags & XI86_ALWAYS_CORE; 
         dev->spriteInfo->spriteOwner = !(local->flags & XI86_SHARED_POINTER);
 
-        RegisterOtherDevice(dev);
-
+        if (DeviceIsPointerType(dev))
+        {
 #ifdef XKB
-        if (!DeviceIsPointerType(dev) && !noXkbExtension)
+            dev->public.processInputProc = CoreProcessPointerEvent;
+            dev->public.realInputProc = CoreProcessPointerEvent;
+#else
+            dev->public.processInputProc = ProcessPointerEvent;
+            dev->public.realInputProc = ProcessPointerEvent;
+#endif
+            dev->deviceGrab.ActivateGrab = ActivatePointerGrab;
+            dev->deviceGrab.DeactivateGrab = DeactivatePointerGrab;
+        } else 
         {
-            XkbSetExtension(dev, ProcessKeyboardEvent);
-        }
+#ifdef XKB
+            dev->public.processInputProc = CoreProcessKeyboardEvent;
+            dev->public.realInputProc = CoreProcessKeyboardEvent;
+#else
+            dev->public.processInputProc = ProcessKeyboardEvent;
+            dev->public.realInputProc = ProcessKeyboardEvent;
 #endif
+            dev->deviceGrab.ActivateGrab = ActivateKeyboardGrab;
+            dev->deviceGrab.DeactivateGrab = DeactivateKeyboardGrab;
+        }
 
+        RegisterOtherDevice(dev);
+        if (!noXkbExtension)
+            XkbSetExtension(dev, ProcessOtherEvent);
 
         if (serverGeneration == 1) 
             xf86Msg(X_INFO, "XINPUT: Adding extended input device \"%s\" (type: %s)\n",
diff --git a/mi/mieq.c b/mi/mieq.c
index c3f63fb..78e57ad 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -232,7 +232,6 @@ mieqProcessInputEvents(void)
 {
     EventRec *e = NULL;
     int x = 0, y = 0;
-    DeviceIntPtr dev = NULL;
     xEvent* event;
 
     while (miEventQueue.head != miEventQueue.tail) {
@@ -262,7 +261,8 @@ mieqProcessInputEvents(void)
             if (miEventQueue.handlers[e->events->event->u.u.type]) {
                 miEventQueue.handlers[e->events->event->u.u.type](
                                               DequeueScreen(e->pDev)->myNum,
-                                                      e->events->event, dev,
+                                                      e->events->event,
+                                                      e->pDev,
                                                       e->nevents);
                 return;
             }
@@ -272,17 +272,7 @@ mieqProcessInputEvents(void)
             if (e->events->event[0].u.u.type == KeyPress ||
                 e->events->event[0].u.u.type == KeyRelease) {
                 SwitchCoreKeyboard(e->pDev);
-                dev = inputInfo.keyboard;
             }
-            else if (e->events->event[0].u.u.type == MotionNotify ||
-                     e->events->event[0].u.u.type == ButtonPress ||
-                     e->events->event[0].u.u.type == ButtonRelease) {
-                dev = inputInfo.pointer;
-            }
-            else {
-                dev = e->pDev;
-            }
-
 
             /* FIXME: Bad hack. The only event where we actually get multiple
              * events at once is a DeviceMotionNotify followed by
@@ -303,11 +293,7 @@ mieqProcessInputEvents(void)
                 event = e->events->event;
             }
 
-            /* MPX devices send both core and Xi events. 
-             * Use dev to get the correct processing function but supply
-             *  e->pDev to pass the correct device 
-             */
-            dev->public.processInputProc(event, e->pDev, e->nevents);
+            e->pDev->public.processInputProc(event, e->pDev, e->nevents);
 
             if (e->nevents > 1)
                 xfree(event);
diff-tree b2a4883bd89d406713d4f808e72721ecc1456d67 (from 275dc77c2972147407584323b866b8acc1654ea0)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Wed Sep 26 09:20:11 2007 +0930

    dix: add comments to PlayReleasedEvents()
    
    Also stick another warning in, more changes needed for XGE if panoramix is
    active.

diff --git a/dix/events.c b/dix/events.c
index f5b0f00..7d69ca5 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -1241,6 +1241,15 @@ EnqueueEvent(xEvent *xE, DeviceIntPtr de
     *syncEvents.pendtail = qe;
 }
 
+/**
+ * Run through the list of events queued up in syncEvents.
+ * For each event do: 
+ * If the device for this event is not frozen anymore, take it and process it
+ * as usually. 
+ * After that, check if there's any devices in the list that are not frozen.
+ * If there is none, we're done. If there is at least one device that is not
+ * frozen, then re-run from the beginning of the event queue.
+ */
 static void
 PlayReleasedEvents(void)
 {
@@ -1276,6 +1285,7 @@ PlayReleasedEvents(void)
 	   /* Translate back to the sprite screen since processInputProc
 	      will translate from sprite screen to screen 0 upon reentry
 	      to the DIX layer */
+            /* XXX: we can't do that for generic events */
 	    if(!noPanoramiXExtension) {
 		qe->event->u.keyButtonPointer.rootX += 
 			panoramiXdataPtr[0].x - 
diff-tree 275dc77c2972147407584323b866b8acc1654ea0 (from 5d9f6cf51becdeb1d2be9bdeec4bb5d0c4dd0e8b)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Tue Sep 25 21:40:08 2007 +0930

    dix: add comments to ComputeFreezes() and syncEvents struct.

diff --git a/dix/events.c b/dix/events.c
index aab5352..f5b0f00 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -263,6 +263,24 @@ static int DontPropagateRefCnts[DNPMCOUN
  */
 _X_EXPORT InputInfo inputInfo;
 
+/**
+ * syncEvents is the global structure for queued events.
+ * Devices can be frozen through GrabModeSync pointer grabs. If this is the
+ * case, events from these devices are added to "pending" instead of being
+ * processed normally. When the device is unfrozen, events in "pending" are
+ * replayed and processed as if they would come from the device directly.
+ *
+ * pending ... list of queued events
+ * pendtail ... last event in list
+ * replayDev ... The device to replay events for. Only set in AllowEvents, in
+ *               which case it is set to the device specified in the request.
+ * replayWin ... the window the events are supposed to be replayed on. This
+ *               window may be set to the grab's window (but only when
+ *               Replay{Pointer|Keyboard} is given in the XAllowEvents
+ *               request.
+ * playingEvents ... flag to indicate whether we're in the process of
+ *                   replaying events. Only set in ComputeFreezes().
+ */
 static struct {
     QdEventPtr		pending, *pendtail;
     DeviceIntPtr	replayDev;	/* kludgy rock to put flag for */
@@ -1430,6 +1448,9 @@ CheckGrabForSyncs(DeviceIntPtr thisDev, 
 	     CLIENT_BITS(grab->resource)))
 	    thisDev->deviceGrab.sync.other = NullGrab;
     }
+    /* XXX: other should only work on the paired keyboard, not on all other
+       devices 
+     */
     for (dev = inputInfo.devices; dev; dev = dev->next)
     {
 	if (dev != thisDev)
diff-tree 5d9f6cf51becdeb1d2be9bdeec4bb5d0c4dd0e8b (from c4db4d1fcf7fa2ba802a208beee6b3adc83921f5)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Thu Sep 13 23:33:07 2007 +0930

    dix: cosmetic change. Remove "pointer" variable, might as well use pDev.

diff --git a/dix/getevents.c b/dix/getevents.c
index e88c56c..12ddc82 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -619,7 +619,6 @@ GetPointerEvents(EventList *events, Devi
         *valptr = valuators[i];
 
     events++;
-    pointer = pDev;
 
     /* Set x and y based on whether this is absolute or relative, and
      * accelerate if we need to. */
@@ -628,14 +627,14 @@ GetPointerEvents(EventList *events, Devi
             x = valuators[0];
         }
         else {
-            x = pointer->valuator->lastx;
+            x = pDev->valuator->lastx;
         }
 
         if (first_valuator <= 1 && num_valuators >= (2 - first_valuator)) {
             y = valuators[1 - first_valuator];
         }
         else {
-            y = pointer->valuator->lasty;
+            y = pDev->valuator->lasty;
         }
     }
     else {
@@ -644,14 +643,14 @@ GetPointerEvents(EventList *events, Devi
                               valuators);
 
         if (first_valuator == 0 && num_valuators >= 1)
-            x = pointer->valuator->lastx + valuators[0];
+            x = pDev->valuator->lastx + valuators[0];
         else
-            x = pointer->valuator->lastx;
+            x = pDev->valuator->lastx;
 
         if (first_valuator <= 1 && num_valuators >= (2 - first_valuator))
-            y = pointer->valuator->lasty + valuators[1 - first_valuator];
+            y = pDev->valuator->lasty + valuators[1 - first_valuator];
         else
-            y = pointer->valuator->lasty;
+            y = pDev->valuator->lasty;
     }
 
     /* Clip both x and y to the defined limits (usually co-ord space limit). */
diff-tree c4db4d1fcf7fa2ba802a208beee6b3adc83921f5 (from 1c25c46f3d5f98be8dbf36684aad4302b220e163)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Thu Sep 13 23:27:07 2007 +0930

    include: remove register keywords.

diff --git a/include/cursor.h b/include/cursor.h
index e51394c..ef81afc 100644
--- a/include/cursor.h
+++ b/include/cursor.h
@@ -119,7 +119,7 @@ extern CursorPtr CreateRootCursor(
 extern int ServerBitsFromGlyph(
     FontPtr /*pfont*/,
     unsigned int /*ch*/,
-    register CursorMetricPtr /*cm*/,
+    CursorMetricPtr /*cm*/,
     unsigned char ** /*ppbits*/);
 
 extern Bool CursorMetricsFromGlyph(
diff --git a/include/dix.h b/include/dix.h
index 5caa6e2..bec19dd 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -61,7 +61,7 @@ SOFTWARE.
 
 #define NullClient ((ClientPtr) 0)
 #define REQUEST(type) \
-	register type *stuff = (type *)client->requestBuffer
+	type *stuff = (type *)client->requestBuffer
 
 
 #define REQUEST_SIZE_MATCH(req)\
diff --git a/include/xkbsrv.h b/include/xkbsrv.h
index e220f0a..a4f15f0 100644
--- a/include/xkbsrv.h
+++ b/include/xkbsrv.h
@@ -737,14 +737,14 @@ extern void AccessXInit(
 );
 
 extern Bool AccessXFilterPressEvent(
-    register struct _xEvent *	/* xE */,
-    register DeviceIntPtr	/* keybd */,
+    struct _xEvent *	/* xE */,
+    DeviceIntPtr	/* keybd */,
     int				/* count */
 );
 
 extern Bool AccessXFilterReleaseEvent(
-    register struct _xEvent *	/* xE */,
-    register DeviceIntPtr	/* keybd */,
+    struct _xEvent *	/* xE */,
+    DeviceIntPtr	/* keybd */,
     int				/* count */
 );
 
diff-tree 1c25c46f3d5f98be8dbf36684aad4302b220e163 (from 68e0c4988e359e3c9da933946bc703cf8530bdbc)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Thu Sep 13 23:22:27 2007 +0930

    dix: fix compiler warnings about unused variables.

diff --git a/dix/events.c b/dix/events.c
index 3d833ef..aab5352 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -777,8 +777,9 @@ ConfineToShape(DeviceIntPtr pDev, Region
     BoxRec box;
     int x = *px, y = *py;
     int incx = 1, incy = 1;
-    SpritePtr pSprite = pDev->spriteInfo->sprite;
+    SpritePtr pSprite; 
 
+    pSprite = pDev->spriteInfo->sprite;
     if (POINT_IN_REGION(pSprite->hot.pScreen, shape, x, y, &box))
 	return;
     box = *REGION_EXTENTS(pSprite->hot.pScreen, shape);
@@ -3488,16 +3489,14 @@ ProcessKeyboardEvent (xEvent *xE, Device
 #endif
 {
     int             key, bit;
-    BYTE   *kptr;
-    int    i;
-    CARD8  modifiers;
-    CARD16 mask;
+    BYTE            *kptr;
+    CARD8           modifiers;
     GrabPtr         grab;
     GrabInfoPtr     grabinfo;
     Bool            deactivateGrab = FALSE;
-    KeyClassPtr keyc = keybd->key;
+    KeyClassPtr     keyc = keybd->key;
 #ifdef XEVIE
-    static Window           rootWin = 0;
+    static Window   rootWin = 0;
 
     if(!xeviegrabState && xevieFlag && clients[xevieClientIndex] &&
           (xevieMask & xevieFilters[xE->u.u.type])) {
diff-tree 68e0c4988e359e3c9da933946bc703cf8530bdbc (from b484451eab261a919fe94c0c0f56877f7571fc9e)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Wed Sep 12 20:48:48 2007 +0930

    dix: fix "possible use of uninitialized variable" warning.
    
    The device passed through to UnrealizeCursor isn't used anyway, so setting it
    to NULL is enough.

diff --git a/dix/cursor.c b/dix/cursor.c
index 917dc69..5f48c83 100644
--- a/dix/cursor.c
+++ b/dix/cursor.c
@@ -115,7 +115,7 @@ FreeCursor(pointer value, XID cid)
     CursorPtr 	pCurs = (CursorPtr)value;
 
     ScreenPtr	pscr;
-    DeviceIntPtr pDev; 
+    DeviceIntPtr pDev = NULL; /* unused anyway */
 
     if ( --pCurs->refcnt != 0)
 	return(Success);
diff-tree b484451eab261a919fe94c0c0f56877f7571fc9e (from 1c38eac442a3ab9e8469e944f382251957996c5a)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Wed Sep 12 18:34:51 2007 +0930

    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.

diff --git a/dix/events.c b/dix/events.c
index f13d542..3d833ef 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
diff-tree 1c38eac442a3ab9e8469e944f382251957996c5a (from 06188ce90d2a8146140773f9367f23404b464282)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Wed Sep 12 18:09:57 2007 +0930

    dix: fix comment for DeliverDeviceEvents.
    
    DDE is not always called, grabbed or focused devices go through
    Deliver{Grabbed|Focus}Event first.
    
    Thanks to Eamon Walsh for spotting it.

diff --git a/dix/events.c b/dix/events.c
index 8dfea6a..f13d542 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -2246,9 +2246,14 @@ FixUpEventFromWindow(
 }
 
 /**
- * Deliver events caused by input devices. Called for all core input events
- * and XI events. No filtering of events happens before DeliverDeviceEvents(),
- * it will be called for any event that comes out of the event queue.
+ * Deliver events caused by input devices. Called for both core input events
+ * and XI events. 
+ * For events from a non-grabbed, non-focus device, DeliverDeviceEvents is
+ * called directly from the processInputProc.
+ * For grabbed devices, DeliverGrabbedEvent is called first, and _may_ call
+ * DeliverDeviceEvents.
+ * For focused events, DeliverFocusedEvent is called first, and _may_ call
+ * DeliverDeviceEvents.
  *
  * @param pWin Window to deliver event to.
  * @param xE Events to deliver.
@@ -2257,6 +2262,8 @@ FixUpEventFromWindow(
  * @param dev The device that is responsible for the event.
  * @param count number of events in xE.
  *
+ * @see DeliverGrabbedEvent
+ * @see DeliverFocusedEvent
  */
 int
 DeliverDeviceEvents(WindowPtr pWin, xEvent *xE, GrabPtr grab, 
diff-tree 06188ce90d2a8146140773f9367f23404b464282 (from 8840829ab93c4eb62eb58753c015da5307133fe5)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Wed Sep 12 18:00:03 2007 +0930

    dix: Make EnqueueEvent aware of GenericEvents.
    
    GenericEvents can be > sizeof(xEvents), so we need to make sure we're
    allocating and copying enough memory for the event.

diff --git a/dix/events.c b/dix/events.c
index 87cf7b0..8dfea6a 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -1125,13 +1125,19 @@ NoticeEventTime(xEvent *xE)
  *            The following procedures deal with synchronous events       *
  **************************************************************************/
 
+/**
+ * EnqueueEvent is a device's processInputProc if a device is frozen. 
+ * Instead of delivering the events to the client, the event is tacked onto a
+ * linked list for later delivery.
+ */
 void
 EnqueueEvent(xEvent *xE, DeviceIntPtr device, int count)
 {
-    QdEventPtr tail = *syncEvents.pendtail;
-    QdEventPtr qe;
-    xEvent		*qxE;
-    SpritePtr pSprite = device->spriteInfo->sprite;
+    QdEventPtr 	tail = *syncEvents.pendtail;
+    QdEventPtr 	qe;
+    SpritePtr 	pSprite = device->spriteInfo->sprite;
+    int		eventlen;
+
 
     NoticeTime(xE);
 
@@ -1186,7 +1192,12 @@ EnqueueEvent(xEvent *xE, DeviceIntPtr de
 	    return;
 	}
     }
-    qe = (QdEventPtr)xalloc(sizeof(QdEventRec) + (count * sizeof(xEvent)));
+
+    eventlen = count * sizeof(xEvent);
+    if (xE->u.u.type == GenericEvent) /* count is 1 for GenericEvents */
+	eventlen += ((xGenericEvent*)xE)->length * 4;
+
+    qe = (QdEventPtr)xalloc(sizeof(QdEventRec) + eventlen);
     if (!qe)
 	return;
     qe->next = (QdEventPtr)NULL;
@@ -1195,8 +1206,17 @@ EnqueueEvent(xEvent *xE, DeviceIntPtr de
     qe->months = currentTime.months;
     qe->event = (xEvent *)(qe + 1);
     qe->evcount = count;
-    for (qxE = qe->event; --count >= 0; qxE++, xE++)
-	*qxE = *xE;
+    if (xE->u.u.type == GenericEvent)
+    {
+	memcpy(qe->event, xE, eventlen);
+    } else
+    {
+	xEvent	*qxE;
+	for (qxE = qe->event; --count >= 0; qxE++, xE++)
+	{
+	    *qxE = *xE;
+	}
+    }
     if (tail)
 	syncEvents.pendtail = &tail->next;
     *syncEvents.pendtail = qe;
diff-tree 8840829ab93c4eb62eb58753c015da5307133fe5 (from 12a18cc8903fac53c3c77b23dd8093187594a4f3)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Wed Sep 12 17:40:11 2007 +0930

    dix: don't compress motion events from different devices (EventEnqueue)

diff --git a/dix/events.c b/dix/events.c
index ad9ec1c..87cf7b0 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -1173,9 +1173,10 @@ EnqueueEvent(xEvent *xE, DeviceIntPtr de
 #endif
 	pSprite->hotPhys.x = XE_KBPTR.rootX;
 	pSprite->hotPhys.y = XE_KBPTR.rootY;
-	/* do motion compression */
+	/* do motion compression, but not if from different devices */
 	if (tail &&
 	    (tail->event->u.u.type == MotionNotify) &&
+            (tail->device == device) &&
 	    (tail->pScreen == pSprite->hotPhys.pScreen))
 	{
 	    tail->event->u.keyButtonPointer.rootX = pSprite->hotPhys.x;
diff-tree 12a18cc8903fac53c3c77b23dd8093187594a4f3 (from 72b347e681f5667b68257822e7cec02ab4c9cb6d)
Author: David Nolden <david.nolden.git at art-master.de>
Date:   Fri Sep 14 22:42:19 2007 +0200

    compilation-fix in debug mode

diff --git a/xkb/xkbEvents.c b/xkb/xkbEvents.c
index 22ca2d6..b387a8c 100644
--- a/xkb/xkbEvents.c
+++ b/xkb/xkbEvents.c
@@ -937,7 +937,7 @@ GrabInfoPtr grabinfo;
                     ((((deviceKeyButtonPointer*)&xE[i])->state >> 7) & button_mask) == button_mask &&
                     (xkbi->lockedPtrButtons & button_mask) == button_mask) {
 #ifdef DEBUG
-		ErrorF("Faking release of button %d\n", ((deviceKeyButtonPointer*)&xE[i])->state)
+		ErrorF("Faking release of button %d\n", ((deviceKeyButtonPointer*)&xE[i])->state);
 #endif
 		XkbDDXFakePointerButton(DeviceButtonRelease, ((deviceKeyButtonPointer*)&xE[i])->state);
             }


More information about the xorg-commit mailing list