xserver: Branch 'mpx' - 4 commits

Peter Hutterer whot at kemper.freedesktop.org
Tue Nov 13 15:42:38 PST 2007


 Xi/Makefile.am   |    2 
 Xi/chaccess.c    |   38 +--
 Xi/chdevcur.c    |   14 -
 Xi/chdevhier.c   |   18 -
 Xi/chpkpair.c    |   16 -
 Xi/closedev.c    |    2 
 Xi/exevents.c    |   14 -
 Xi/extgrbdev.c   |   58 ++--
 Xi/extinit.c     |   34 +-
 Xi/fakedevdata.c |    4 
 Xi/getcptr.c     |    8 
 Xi/grabacc.c     |    4 
 Xi/grabdev.c     |    6 
 Xi/listdev.c     |    4 
 Xi/qryacces.c    |   12 
 Xi/querydp.c     |    8 
 Xi/regpair.c     |  108 --------
 Xi/regpair.h     |   43 ---
 Xi/sendexev.c    |    2 
 Xi/stubs.c       |   10 
 Xi/warpdevp.c    |    8 
 dix/devices.c    |  147 +++++-------
 dix/events.c     |  666 +++++++++++++++++++++++++++----------------------------
 23 files changed, 531 insertions(+), 695 deletions(-)

New commits:
commit 0bdfeb55fc559ffe0334df69ba6e9e711b26dc18
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Tue Nov 13 17:31:20 2007 +1030

    Xi: remove RegisterPairingClient handling. Deprecated with device hierarchy.

diff --git a/Xi/Makefile.am b/Xi/Makefile.am
index 407928d..9c5658d 100644
--- a/Xi/Makefile.am
+++ b/Xi/Makefile.am
@@ -76,8 +76,6 @@ libXi_la_SOURCES =	\
 	queryst.h \
 	qryacces.c \
 	qryacces.h \
-	regpair.c \
-	regpair.h \
 	selectev.c \
 	selectev.h \
 	sendexev.c \
diff --git a/Xi/extinit.c b/Xi/extinit.c
index aed0083..07ef266 100644
--- a/Xi/extinit.c
+++ b/Xi/extinit.c
@@ -109,7 +109,6 @@ SOFTWARE.
 #include "qryacces.c"
 #include "querydp.h"
 #include "queryst.h"
-#include "regpair.h"
 #include "selectev.h"
 #include "sendexev.h"
 #include "chgkmap.h"
@@ -329,8 +328,6 @@ ProcIDispatch(ClientPtr client)
         return (ProcXChangeDeviceHierarchy(client));
     else if (stuff->data == X_XiSelectEvent)
         return (ProcXiSelectEvent(client));
-    else if (stuff->data == X_RegisterPairingClient)
-        return (ProcXRegisterPairingClient(client));
     else if (stuff->data == X_GrabAccessControl)
         return (ProcXGrabAccessControl(client));
     else if (stuff->data == X_ChangeWindowAccess)
@@ -446,8 +443,6 @@ SProcIDispatch(ClientPtr client)
         return (SProcXChangeDeviceHierarchy(client));
     else if (stuff->data == X_XiSelectEvent)
         return (SProcXiSelectEvent(client));
-    else if (stuff->data == X_RegisterPairingClient)
-        return (SProcXRegisterPairingClient(client));
     else if (stuff->data == X_GrabAccessControl)
         return (SProcXGrabAccessControl(client));
     else if (stuff->data == X_ChangeWindowAccess)
@@ -539,9 +534,6 @@ SReplyIDispatch(ClientPtr client, int len, xGrabDeviceReply * rep)
     else if (rep->RepType == X_QueryDevicePointer)
 	SRepXQueryDevicePointer(client, len,
 				(xQueryDevicePointerReply *) rep);
-    else if (rep->RepType == X_RegisterPairingClient)
-	SRepXRegisterPairingClient(client, len,
-				  (xRegisterPairingClientReply *) rep);
     else if (rep->RepType == X_GrabAccessControl)
         SRepXGrabAccessControl(client, len,
                                   (xGrabAccessControlReply*) rep);
diff --git a/Xi/regpair.c b/Xi/regpair.c
deleted file mode 100644
index 3fe4591..0000000
--- a/Xi/regpair.c
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
-
-Copyright 2007 Peter Hutterer <peter at cs.unisa.edu.au>
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
-OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of the author shall
-not be used in advertising or otherwise to promote the sale, use or
-other dealings in this Software without prior written authorization
-from the author.
-
-*/
-
-/***********************************************************************
- *
- * Request to authenticate as pairing client
- *
- */
-
-#define	 NEED_EVENTS
-#define	 NEED_REPLIES
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <X11/X.h>	/* for inputstr.h    */
-#include <X11/Xproto.h>	/* Request macro     */
-#include "inputstr.h"	/* DeviceIntPtr      */
-#include "windowstr.h"	/* window structure  */
-#include <X11/extensions/XI.h>
-#include <X11/extensions/XIproto.h>
-#include "extnsionst.h"
-#include "exevents.h"
-#include "exglobals.h"
-
-#include "regpair.h"
-
-/***********************************************************************
- *
- * This procedure allows a client to register the pairing of a pointer
- * with a keyboard.
- *
- */
-
-int
-SProcXRegisterPairingClient(ClientPtr client)
-{
-    char n;
-    REQUEST(xRegisterPairingClientReq);
-    swaps(&stuff->length, n);
-    return ProcXRegisterPairingClient(client);
-}
-
-int
-ProcXRegisterPairingClient(ClientPtr client)
-{
-    xRegisterPairingClientReply rep;
-
-    REQUEST(xRegisterPairingClientReq);
-    REQUEST_SIZE_MATCH(xRegisterPairingClientReq);
-
-    if (stuff->disable)
-        UnregisterPairingClient(client);
-
-    rep.repType = X_Reply;
-    rep.RepType = X_RegisterPairingClient;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-    rep.success = stuff->disable || RegisterPairingClient(client);
-
-    WriteReplyToClient(client, sizeof(xRegisterPairingClientReply), &rep);
-    return Success;
-}
-
-/***********************************************************************
- *
- * This procedure writes the reply for the XRegisterPairingClient function,
- * if the client and server have a different byte ordering.
- *
- */
-
-void
-SRepXRegisterPairingClient(ClientPtr client, int size,
-        xRegisterPairingClientReply* rep)
-{
-    register char n;
-
-    swaps(&rep->sequenceNumber, n);
-    swapl(&rep->length, n);
-    WriteToClient(client, size, (char *)rep);
-}
-
diff --git a/Xi/regpair.h b/Xi/regpair.h
deleted file mode 100644
index b2bfaff..0000000
--- a/Xi/regpair.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
-
-Copyright 2007 Peter Hutterer <peter at cs.unisa.edu.au>
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
-OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of the author shall
-not be used in advertising or otherwise to promote the sale, use or
-other dealings in this Software without prior written authorization
-from the author.
-
-*/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#ifndef REGPAIR_H
-#define REGPAIR_H 1
-
-int SProcXRegisterPairingClient(ClientPtr /* client */);
-int ProcXRegisterPairingClient(ClientPtr /* client */);
-
-void SRepXRegisterPairingClient(ClientPtr /* client */, 
-                                int /* size */,
-                                xRegisterPairingClientReply* /* rep */);
-
-#endif /* REGPAIR_H */
commit e96d926d64f7fb63f6bf2aa0ea0a8440a188947b
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Tue Nov 13 17:14:35 2007 +1030

    Xi: remove trailing whitespaces.

diff --git a/Xi/chaccess.c b/Xi/chaccess.c
index 2a0e5fa..9baa871 100644
--- a/Xi/chaccess.c
+++ b/Xi/chaccess.c
@@ -50,9 +50,9 @@ from the author.
  * This procedure allows a client to change window access control.
  */
 
-int 
+int
 SProcXChangeWindowAccess(ClientPtr client)
-{    
+{
     char n;
     REQUEST(xChangeWindowAccessReq);
 
@@ -61,7 +61,7 @@ SProcXChangeWindowAccess(ClientPtr client)
     return ProcXChangeWindowAccess(client);
 }
 
-int 
+int
 ProcXChangeWindowAccess(ClientPtr client)
 {
     int padding, err, i;
@@ -71,14 +71,14 @@ ProcXChangeWindowAccess(ClientPtr client)
     DeviceIntPtr* deny_devices = NULL;
     REQUEST(xChangeWindowAccessReq);
     REQUEST_AT_LEAST_SIZE(xChangeWindowAccessReq);
-    
+
 
     padding = (4 - (((stuff->npermit + stuff->ndeny) * sizeof(XID)) % 4)) % 4;
 
-    if (stuff->length != ((sizeof(xChangeWindowAccessReq)  + 
+    if (stuff->length != ((sizeof(xChangeWindowAccessReq)  +
             (((stuff->npermit + stuff->ndeny) * sizeof(XID)) + padding)) >> 2))
     {
-        SendErrorToClient(client, IReqCode, X_ChangeWindowAccess, 
+        SendErrorToClient(client, IReqCode, X_ChangeWindowAccess,
                 0, BadLength);
         return Success;
     }
@@ -87,7 +87,7 @@ ProcXChangeWindowAccess(ClientPtr client)
     err = dixLookupWindow(&win, stuff->win, client, DixWriteAccess);
     if (err != Success)
     {
-        SendErrorToClient(client, IReqCode, X_ChangeWindowAccess, 
+        SendErrorToClient(client, IReqCode, X_ChangeWindowAccess,
                           stuff->win, err);
         return Success;
     }
@@ -106,12 +106,12 @@ ProcXChangeWindowAccess(ClientPtr client)
 
     if (stuff->npermit)
     {
-        perm_devices = 
+        perm_devices =
             (DeviceIntPtr*)xalloc(stuff->npermit * sizeof(DeviceIntPtr));
         if (!perm_devices)
         {
             ErrorF("[Xi] ProcXChangeWindowAccess: alloc failure.\n");
-            SendErrorToClient(client, IReqCode, X_ChangeWindowAccess, 0, 
+            SendErrorToClient(client, IReqCode, X_ChangeWindowAccess, 0,
                     BadImplementation);
             return Success;
         }
@@ -123,8 +123,8 @@ ProcXChangeWindowAccess(ClientPtr client)
             if (!perm_devices[i])
             {
                 xfree(perm_devices);
-                SendErrorToClient(client, IReqCode, X_ChangeWindowAccess, 
-                        deviceids[i], BadDevice); 
+                SendErrorToClient(client, IReqCode, X_ChangeWindowAccess,
+                        deviceids[i], BadDevice);
                 return Success;
             }
         }
@@ -132,12 +132,12 @@ ProcXChangeWindowAccess(ClientPtr client)
 
     if (stuff->ndeny)
     {
-        deny_devices = 
+        deny_devices =
             (DeviceIntPtr*)xalloc(stuff->ndeny * sizeof(DeviceIntPtr));
         if (!deny_devices)
         {
             ErrorF("[Xi] ProcXChangeWindowAccecss: alloc failure.\n");
-            SendErrorToClient(client, IReqCode, X_ChangeWindowAccess, 0, 
+            SendErrorToClient(client, IReqCode, X_ChangeWindowAccess, 0,
                     BadImplementation);
 
             xfree(perm_devices);
@@ -146,15 +146,15 @@ ProcXChangeWindowAccess(ClientPtr client)
 
         for (i = 0; i < stuff->ndeny; i++)
         {
-            deny_devices[i] = 
+            deny_devices[i] =
                 LookupDeviceIntRec(deviceids[i+stuff->npermit]);
-            
+
             if (!deny_devices[i])
             {
                 xfree(perm_devices);
                 xfree(deny_devices);
-                SendErrorToClient(client, IReqCode, X_ChangeWindowAccess, 
-                        deviceids[i + stuff->npermit], BadDevice); 
+                SendErrorToClient(client, IReqCode, X_ChangeWindowAccess,
+                        deviceids[i + stuff->npermit], BadDevice);
                 return Success;
             }
         }
@@ -165,11 +165,11 @@ ProcXChangeWindowAccess(ClientPtr client)
                                deny_devices, stuff->ndeny);
     if (err != Success)
     {
-        SendErrorToClient(client, IReqCode, X_ChangeWindowAccess, 
+        SendErrorToClient(client, IReqCode, X_ChangeWindowAccess,
                           stuff->win, err);
         return Success;
     }
-    
+
     xfree(perm_devices);
     xfree(deny_devices);
     return Success;
diff --git a/Xi/chdevcur.c b/Xi/chdevcur.c
index e69a266..dfa45ee 100644
--- a/Xi/chdevcur.c
+++ b/Xi/chdevcur.c
@@ -82,7 +82,7 @@ int ProcXChangeDeviceCursor(ClientPtr client)
     pDev = LookupDeviceIntRec(stuff->deviceid);
     if (pDev == NULL) {
         SendErrorToClient(client, IReqCode, X_ChangeDeviceCursor, 0,
-                BadDevice); 
+                BadDevice);
         return Success;
     }
 
@@ -91,7 +91,7 @@ int ProcXChangeDeviceCursor(ClientPtr client)
         err = dixLookupWindow(&pWin, stuff->win, client, DixReadWriteAccess);
         if (err != Success)
         {
-            SendErrorToClient(client, IReqCode, X_ChangeDeviceCursor, 
+            SendErrorToClient(client, IReqCode, X_ChangeDeviceCursor,
                     stuff->win, err);
             return Success;
         }
@@ -103,18 +103,18 @@ int ProcXChangeDeviceCursor(ClientPtr client)
             pCursor = rootCursor;
         else
             pCursor = (CursorPtr)None;
-    } 
-    else 
+    }
+    else
     {
         pCursor = (CursorPtr)SecurityLookupIDByType(client, stuff->cursor,
-                                RT_CURSOR, DixReadAccess); 
+                                RT_CURSOR, DixReadAccess);
         if (!pCursor)
         {
-            SendErrorToClient(client, IReqCode, X_ChangeDeviceCursor, 
+            SendErrorToClient(client, IReqCode, X_ChangeDeviceCursor,
                     stuff->cursor, BadCursor);
             return Success;
         }
-    } 
+    }
 
     ChangeWindowDeviceCursor(pWin, pDev, pCursor);
 
diff --git a/Xi/chdevhier.c b/Xi/chdevhier.c
index 338c074..ac912f7 100644
--- a/Xi/chdevhier.c
+++ b/Xi/chdevhier.c
@@ -90,7 +90,7 @@ ProcXChangeDeviceHierarchy(ClientPtr client)
 
     /* XXX: check if client is allowed to change hierarch */
 
-    
+
     any = (xAnyHierarchyChangeInfo*)&stuff[1];
     while(stuff->num_changes--)
     {
@@ -108,7 +108,7 @@ ProcXChangeDeviceHierarchy(ClientPtr client)
                     xCreateMasterInfo* c = (xCreateMasterInfo*)any;
                     char* name;
                     int ret;
-                    
+
                     SWAPIF(swaps(&c->namelen, n));
                     name = xcalloc(c->namelen + 1, sizeof(char));
                     strncpy(name, (char*)&c[1], c->namelen);
@@ -138,7 +138,7 @@ ProcXChangeDeviceHierarchy(ClientPtr client)
                 {
                     xRemoveMasterInfo* r = (xRemoveMasterInfo*)any;
 
-                    if (r->returnMode != AttachToMaster && 
+                    if (r->returnMode != AttachToMaster &&
                             r->returnMode != Floating)
                         return BadValue;
 
@@ -164,8 +164,8 @@ ProcXChangeDeviceHierarchy(ClientPtr client)
                      * desired. */
                     if (r->returnMode == AttachToMaster)
                     {
-                        DeviceIntPtr attached, 
-                                     newptr, 
+                        DeviceIntPtr attached,
+                                     newptr,
                                      newkeybd;
 
                         newptr = LookupDeviceIntRec(r->returnPointer);
@@ -174,8 +174,8 @@ ProcXChangeDeviceHierarchy(ClientPtr client)
                                 !newkeybd || !newkeybd->isMaster)
                             return BadDevice;
 
-                        for (attached = inputInfo.devices; 
-                                attached; 
+                        for (attached = inputInfo.devices;
+                                attached;
                                 attached = attached->next)
                         {
                             if (!attached->isMaster) {
@@ -216,7 +216,7 @@ ProcXChangeDeviceHierarchy(ClientPtr client)
                         if ((IsPointerDevice(newmaster) &&
                                     !IsPointerDevice(ptr)) ||
                                 (IsKeyboardDevice(newmaster) &&
-                                 !IsKeyboardDevice(ptr))) 
+                                 !IsKeyboardDevice(ptr)))
                                 return BadDevice;
                         AttachDevice(client, ptr, newmaster);
                     }
@@ -234,7 +234,7 @@ ProcXChangeDeviceHierarchy(ClientPtr client)
     ev.evtype = XI_DeviceHierarchyChangedNotify;
     ev.time = GetTimeInMillis();
 
-    SendEventToAllWindows(&dummyDev, XI_DeviceHierarchyChangedMask, 
+    SendEventToAllWindows(&dummyDev, XI_DeviceHierarchyChangedMask,
             (xEvent*)&ev, 1);
     return Success;
 }
diff --git a/Xi/chpkpair.c b/Xi/chpkpair.c
index db8e7f6..c44a263 100644
--- a/Xi/chpkpair.c
+++ b/Xi/chpkpair.c
@@ -77,7 +77,7 @@ ProcXChangePointerKeyboardPairing(ClientPtr client)
 {
     DeviceIntPtr pPointer, pKeyboard;
     int ret;
-    pairingChangedNotify ev; 
+    pairingChangedNotify ev;
 
     REQUEST(xChangePointerKeyboardPairingReq);
     REQUEST_SIZE_MATCH(xChangePointerKeyboardPairingReq);
@@ -87,16 +87,16 @@ ProcXChangePointerKeyboardPairing(ClientPtr client)
     pPointer = LookupDeviceIntRec(stuff->pointer);
     if (pPointer == NULL)
     {
-        SendErrorToClient(client, IReqCode, X_ChangePointerKeyboardPairing, 
-                stuff->pointer, BadDevice); 
+        SendErrorToClient(client, IReqCode, X_ChangePointerKeyboardPairing,
+                stuff->pointer, BadDevice);
         return Success;
     }
 
     pKeyboard = LookupDeviceIntRec(stuff->keyboard);
     if (pKeyboard == NULL)
     {
-        SendErrorToClient(client, IReqCode, X_ChangePointerKeyboardPairing, 
-                stuff->keyboard, BadDevice); 
+        SendErrorToClient(client, IReqCode, X_ChangePointerKeyboardPairing,
+                stuff->keyboard, BadDevice);
         return Success;
     }
 
@@ -116,15 +116,15 @@ ProcXChangePointerKeyboardPairing(ClientPtr client)
     ev.keyboard = pKeyboard->id;
     ev.length = 0;
     ev.time = currentTime.milliseconds;
-    SendEventToAllWindows(inputInfo.pointer, 
+    SendEventToAllWindows(inputInfo.pointer,
             XI_PointerKeyboardPairingChangedMask,
             (xEvent*)&ev, 1);
     return Success;
 }
 
 /* Event swap proc */
-void 
-SPointerKeyboardPairingChangedNotifyEvent (pairingChangedNotify *from, 
+void
+SPointerKeyboardPairingChangedNotifyEvent (pairingChangedNotify *from,
                                                 pairingChangedNotify *to)
 {
     char n;
diff --git a/Xi/closedev.c b/Xi/closedev.c
index cd6e537..f9a0f4f 100644
--- a/Xi/closedev.c
+++ b/Xi/closedev.c
@@ -154,7 +154,7 @@ ProcXCloseDevice(ClientPtr client)
     if (d->deviceGrab.grab && SameClient(d->deviceGrab.grab, client))
 	(*d->deviceGrab.DeactivateGrab) (d);	/* release active grab */
 
-    /* Remove event selections from all windows for events from this device 
+    /* Remove event selections from all windows for events from this device
      * and selected by this client.
      * Delete passive grabs from all windows for this device.      */
 
diff --git a/Xi/exevents.c b/Xi/exevents.c
index 3ef3200..511930b 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -103,10 +103,10 @@ RegisterOtherDevice(DeviceIntPtr device)
 }
 
 /**
- * Main device event processing function. 
- * Called from when processing the events from the event queue. 
+ * 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.
  */
@@ -309,7 +309,7 @@ ProcessOtherEvent(xEventPtr xE, DeviceIntPtr device, int count)
 	    }
 	}
 
-	if (device->deviceGrab.fromPassiveGrab && 
+	if (device->deviceGrab.fromPassiveGrab &&
             (key == device->deviceGrab.activatingKey))
 	    deactivateDeviceGrab = TRUE;
     } else if (xE->u.u.type == DeviceButtonPress) {
@@ -357,7 +357,7 @@ ProcessOtherEvent(xEventPtr xE, DeviceIntPtr device, int count)
 	if (xE->u.u.detail <= 5)
 	    b->state &= ~((Button1Mask >> 1) << xE->u.u.detail);
 	SetMaskForEvent(Motion_Filter(b), DeviceMotionNotify);
-        if (!b->state 
+        if (!b->state
             && device->deviceGrab.fromPassiveGrab)
             deactivateDeviceGrab = TRUE;
     } else if (xE->u.u.type == ProximityIn)
@@ -413,7 +413,7 @@ InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, int minval, int maxval,
 		       int resolution, int min_res, int max_res)
 {
     AxisInfoPtr ax;
-   
+  
     if (!dev || !dev->valuator)
         return;
 
@@ -1122,7 +1122,7 @@ DeleteDeviceFromAnyExtEvents(WindowPtr pWin, DeviceIntPtr dev)
     if (dev->deviceGrab.grab && (dev->deviceGrab.grab->window == pWin))
 	(*dev->deviceGrab.DeactivateGrab) (dev);
 
-    /* If the focus window is a root window (ie. has no parent) 
+    /* If the focus window is a root window (ie. has no parent)
      * then don't delete the focus from it. */
 
     if (dev->focus && (pWin == dev->focus->win) && (pWin->parent != NullWindow)) {
diff --git a/Xi/extgrbdev.c b/Xi/extgrbdev.c
index c4011f5..7cafdba 100644
--- a/Xi/extgrbdev.c
+++ b/Xi/extgrbdev.c
@@ -55,7 +55,7 @@ from the author.
 
 #include "extgrbdev.h"
 
-int 
+int
 SProcXExtendedGrabDevice(ClientPtr client)
 {
     char        n;
@@ -89,15 +89,15 @@ SProcXExtendedGrabDevice(ClientPtr client)
 }
 
 
-int 
+int
 ProcXExtendedGrabDevice(ClientPtr client)
 {
     xExtendedGrabDeviceReply rep;
     DeviceIntPtr             dev;
-    int                      err = Success, 
+    int                      err = Success,
                              errval = 0,
                              i;
-    WindowPtr                grab_window, 
+    WindowPtr                grab_window,
                              confineTo = 0;
     CursorPtr                cursor = NULL;
     struct tmask             tmp[EMASKSIZE];
@@ -119,7 +119,7 @@ ProcXExtendedGrabDevice(ClientPtr client)
     rep.length          = 0;
 
     if (!stuff->ungrab && /* other fields are undefined for ungrab */
-            (stuff->length != (sizeof(xExtendedGrabDeviceReq) >> 2) + 
+            (stuff->length != (sizeof(xExtendedGrabDeviceReq) >> 2) +
             stuff->event_count + 2 * stuff->generic_event_count))
     {
         errval = 0;
@@ -141,21 +141,21 @@ ProcXExtendedGrabDevice(ClientPtr client)
         goto cleanup;
     }
 
-    err = dixLookupWindow(&grab_window, 
-                          stuff->grab_window, 
-                          client, 
+    err = dixLookupWindow(&grab_window,
+                          stuff->grab_window,
+                          client,
                           DixReadAccess);
     if (err != Success)
     {
         errval = stuff->grab_window;
         goto cleanup;
     }
-    
+
     if (stuff->confine_to)
     {
-        err = dixLookupWindow(&confineTo, 
-                              stuff->confine_to, 
-                              client, 
+        err = dixLookupWindow(&confineTo,
+                              stuff->confine_to,
+                              client,
                               DixReadAccess);
         if (err != Success)
         {
@@ -166,10 +166,10 @@ ProcXExtendedGrabDevice(ClientPtr client)
 
     if (stuff->cursor)
     {
-        cursor = (CursorPtr)SecurityLookupIDByType(client, 
+        cursor = (CursorPtr)SecurityLookupIDByType(client,
                                                     stuff->cursor,
-                                                    RT_CURSOR, 
-                                                    DixReadAccess); 
+                                                    RT_CURSOR,
+                                                    DixReadAccess);
         if (!cursor)
         {
             errval = stuff->cursor;
@@ -178,11 +178,11 @@ ProcXExtendedGrabDevice(ClientPtr client)
         }
     }
 
-    if (CreateMaskFromList(client, 
+    if (CreateMaskFromList(client,
                            (XEventClass*)&stuff[1],
-                           stuff->event_count, 
-                           tmp, 
-                           dev, 
+                           stuff->event_count,
+                           tmp,
+                           dev,
                            X_GrabDevice) != Success)
         return Success;
 
@@ -190,7 +190,7 @@ ProcXExtendedGrabDevice(ClientPtr client)
 
     if (stuff->generic_event_count)
     {
-        xgeMask = 
+        xgeMask =
             (XGenericEventMask*)(((XEventClass*)&stuff[1]) + stuff->event_count);
 
         gemasks = xcalloc(1, sizeof(GenericMaskRec));
@@ -203,16 +203,16 @@ ProcXExtendedGrabDevice(ClientPtr client)
             gemasks->eventMask[xgeMask->extension & 0x7F]= xgeMask->evmask;
     }
 
-    ExtGrabDevice(client, dev, stuff->device_mode, 
-                  grab_window, confineTo, time, stuff->owner_events, 
-                  cursor, tmp[stuff->deviceid].mask, 
+    ExtGrabDevice(client, dev, stuff->device_mode,
+                  grab_window, confineTo, time, stuff->owner_events,
+                  cursor, tmp[stuff->deviceid].mask,
                   gemasks);
 
     if (err != Success) {
         errval = 0;
         goto cleanup;
     }
-    
+
 cleanup:
 
     if (gemasks)
@@ -221,18 +221,18 @@ cleanup:
     if (err == Success)
     {
         WriteReplyToClient(client, sizeof(xGrabDeviceReply), &rep);
-    } 
-    else 
+    }
+    else
     {
-        SendErrorToClient(client, IReqCode, 
-                          X_ExtendedGrabDevice, 
+        SendErrorToClient(client, IReqCode,
+                          X_ExtendedGrabDevice,
                           errval, err);
     }
     return Success;
 }
 
 void
-SRepXExtendedGrabDevice(ClientPtr client, int size, 
+SRepXExtendedGrabDevice(ClientPtr client, int size,
                         xExtendedGrabDeviceReply* rep)
 {
     char n;
diff --git a/Xi/extinit.c b/Xi/extinit.c
index 017b693..aed0083 100644
--- a/Xi/extinit.c
+++ b/Xi/extinit.c
@@ -133,7 +133,7 @@ Mask ExtExclusiveMasks[EMASKSIZE];
 
 
 /**
- * Filters for various generic events. 
+ * Filters for various generic events.
  * Evtype is index, mask is value at index.
  */
 static Mask xi_filters[3] = {
@@ -355,7 +355,7 @@ ProcIDispatch(ClientPtr client)
 
 /*******************************************************************************
  *
- * SProcXDispatch 
+ * SProcXDispatch
  *
  * Main swapped dispatch routine for requests to this extension.
  * This routine is used if server and client do not have the same byte ordering.
@@ -659,7 +659,7 @@ SDevicePresenceNotifyEvent (devicePresenceNotify *from, devicePresenceNotify *to
     swaps(&to->control, n);
 }
 
-static void 
+static void
 SDeviceEnterNotifyEvent (deviceEnterNotify *from, deviceEnterNotify *to)
 {
     char n;
@@ -669,7 +669,7 @@ SDeviceEnterNotifyEvent (deviceEnterNotify *from, deviceEnterNotify *to)
     swapl(&to->time, n);
 }
 
-static void 
+static void
 SDeviceLeaveNotifyEvent (deviceLeaveNotify *from, deviceLeaveNotify *to)
 {
     char n;
@@ -692,7 +692,7 @@ SRawDeviceEvent(rawDeviceEvent* from, rawDeviceEvent *to)
     char n;
     int i;
     CARD32* valptr;
-    
+   
 
     *to = *from;
     swaps(&to->sequenceNumber, n);
@@ -704,7 +704,7 @@ SRawDeviceEvent(rawDeviceEvent* from, rawDeviceEvent *to)
 }
 
 static void
-SDeviceClassesChangedEvent(deviceClassesChangedEvent* from, 
+SDeviceClassesChangedEvent(deviceClassesChangedEvent* from,
                            deviceClassesChangedEvent* to)
 {
     char n;
@@ -717,7 +717,7 @@ SDeviceClassesChangedEvent(deviceClassesChangedEvent* from,
     swaps(&to->sequenceNumber, n);
     swapl(&to->length, n);
     swapl(&to->time, n);
-    
+   
     /* now swap the actual classes */
     any = (xAnyClassPtr)&to[1];
     for (i = 0; i < to->num_classes; i++)
@@ -796,7 +796,7 @@ GetNextExtEventMask(void)
  *
  * Since extension event types will never be less than 64, we can use
  * 0-63 in the EventInfo array as the "type" to be used to look up this
- * mask.  This means that the corresponding macros such as 
+ * mask.  This means that the corresponding macros such as
  * DevicePointerMotionHint must have access to the same constants.
  *
  */
@@ -973,7 +973,7 @@ FixExtensionEvents(ExtensionEntry * extEntry)
 
 /************************************************************************
  *
- * This function restores extension event types and masks to their 
+ * This function restores extension event types and masks to their
  * initial state.
  *
  */
@@ -1189,7 +1189,7 @@ SEventIDispatch(xEvent * from, xEvent * to)
  * EventSwap for generic events coming from the GE extension.
  */
 
-static void 
+static void
 XIGEEventSwap(xGenericEvent* from, xGenericEvent* to)
 {
     int n;
@@ -1201,7 +1201,7 @@ XIGEEventSwap(xGenericEvent* from, xGenericEvent* to)
             SRawDeviceEvent((rawDeviceEvent*)from, (rawDeviceEvent*)to);
             break;
         case XI_DeviceClassesChangedNotify:
-            SDeviceClassesChangedEvent((deviceClassesChangedEvent*)from, 
+            SDeviceClassesChangedEvent((deviceClassesChangedEvent*)from,
                                        (deviceClassesChangedEvent*)to);
             break;
     }
@@ -1211,8 +1211,8 @@ XIGEEventSwap(xGenericEvent* from, xGenericEvent* to)
  * EventFill to fill various fields for events before they are delivered to
  * the client.
  */
-static void 
-XIGEEventFill(xGenericEvent* ev, DeviceIntPtr pDev, 
+static void
+XIGEEventFill(xGenericEvent* ev, DeviceIntPtr pDev,
               WindowPtr pWin, GrabPtr grab)
 {
 }
diff --git a/Xi/fakedevdata.c b/Xi/fakedevdata.c
index 64f2ea6..2ebb7c3 100644
--- a/Xi/fakedevdata.c
+++ b/Xi/fakedevdata.c
@@ -74,7 +74,7 @@ SProcXFakeDeviceData(ClientPtr client)
     return ProcXFakeDeviceData(client);;
 }
 
-int 
+int
 ProcXFakeDeviceData(ClientPtr client)
 {
     DeviceIntPtr dev;
@@ -92,7 +92,7 @@ ProcXFakeDeviceData(ClientPtr client)
 
     dev = LookupDeviceIntRec(stuff->deviceid);
     if (dev == NULL) {
-        SendErrorToClient(client, IReqCode, X_FakeDeviceData, 0, BadDevice); 
+        SendErrorToClient(client, IReqCode, X_FakeDeviceData, 0, BadDevice);
         return Success;
     }
 
diff --git a/Xi/getcptr.c b/Xi/getcptr.c
index d9ca4d3..ba69f9c 100644
--- a/Xi/getcptr.c
+++ b/Xi/getcptr.c
@@ -74,8 +74,8 @@ int ProcXGetClientPointer(ClientPtr client)
     err = dixLookupWindow(&win, stuff->win, client, DixReadAccess);
     if (err != Success)
     {
-        SendErrorToClient(client, IReqCode, X_GetClientPointer, 
-                stuff->win, err); 
+        SendErrorToClient(client, IReqCode, X_GetClientPointer,
+                stuff->win, err);
         return Success;
     }
 
@@ -99,8 +99,8 @@ int ProcXGetClientPointer(ClientPtr client)
  *
  */
 
-void 
-SRepXGetClientPointer(ClientPtr client, int size, 
+void
+SRepXGetClientPointer(ClientPtr client, int size,
         xGetClientPointerReply* rep)
 {
     char n;
diff --git a/Xi/grabacc.c b/Xi/grabacc.c
index 59888ee..83b8736 100644
--- a/Xi/grabacc.c
+++ b/Xi/grabacc.c
@@ -62,7 +62,7 @@ SProcXGrabAccessControl(ClientPtr client)
     return ProcXGrabAccessControl(client);
 }
 
-int 
+int
 ProcXGrabAccessControl(ClientPtr client)
 {
     xGrabAccessControlReply rep;
@@ -90,7 +90,7 @@ ProcXGrabAccessControl(ClientPtr client)
  */
 
 void
-SRepXGrabAccessControl(ClientPtr client, int size, 
+SRepXGrabAccessControl(ClientPtr client, int size,
         xGrabAccessControlReply* rep)
 {
     char n;
diff --git a/Xi/grabdev.c b/Xi/grabdev.c
index 16f4b7e..a963aa4 100644
--- a/Xi/grabdev.c
+++ b/Xi/grabdev.c
@@ -147,12 +147,12 @@ ProcXGrabDevice(ClientPtr client)
  *
  * This procedure creates an event mask from a list of XEventClasses.
  *
- * Procedure is as follows: 
+ * Procedure is as follows:
  * An XEventClass is (deviceid << 8 | eventtype). For each entry in the list,
  * get the device. Then run through all available event indices (those are
  * set when XI starts up) and binary OR's the device's mask to whatever the
- * event mask for the given event type was. 
- * If an error occurs, it is sent to the client. Errors are generated if 
+ * event mask for the given event type was.
+ * If an error occurs, it is sent to the client. Errors are generated if
  *  - if the device given in the event classs is invalid
  *  - if the device in the class list is not the device given as parameter (no
  *  error if parameter is NULL)
diff --git a/Xi/listdev.c b/Xi/listdev.c
index 1810c9b..a0be219 100644
--- a/Xi/listdev.c
+++ b/Xi/listdev.c
@@ -186,7 +186,7 @@ CopySwapDevice(ClientPtr client, DeviceIntPtr d, int num_classes,
         dev->use = IsXExtensionPointer;
     else
 	dev->use = IsXExtensionDevice;
-    if (!d->isMaster) 
+    if (!d->isMaster)
         dev->attached = (d->u.master) ? d->u.master->id : IsFloating;
 
     if (client->swapped) {
@@ -225,7 +225,7 @@ CopySwapKeyClass(ClientPtr client, KeyClassPtr k, char **buf)
  *
  * Devices may have up to 255 valuators.  The length of a ValuatorClass is
  * defined to be sizeof(ValuatorClassInfo) + num_axes * sizeof (xAxisInfo).
- * The maximum length is therefore (8 + 255 * 12) = 3068.  However, the 
+ * The maximum length is therefore (8 + 255 * 12) = 3068.  However, the
  * length field is one byte.  If a device has more than 20 valuators, we
  * must therefore return multiple valuator classes to the client.
  *
diff --git a/Xi/qryacces.c b/Xi/qryacces.c
index 95f2dd0..673028c 100644
--- a/Xi/qryacces.c
+++ b/Xi/qryacces.c
@@ -78,8 +78,8 @@ ProcXQueryWindowAccess(ClientPtr client)
     err = dixLookupWindow(&win, stuff->win, client, DixReadAccess);
     if (err != Success)
     {
-        SendErrorToClient(client, IReqCode, X_QueryWindowAccess, 
-                          stuff->win, err); 
+        SendErrorToClient(client, IReqCode, X_QueryWindowAccess,
+                          stuff->win, err);
         return Success;
     }
 
@@ -100,8 +100,8 @@ ProcXQueryWindowAccess(ClientPtr client)
         if (!deviceids)
         {
             ErrorF("[Xi] ProcXQueryWindowAccess: xalloc failure.\n");
-            SendErrorToClient(client, IReqCode, X_QueryWindowAccess, 
-                    0, BadImplementation); 
+            SendErrorToClient(client, IReqCode, X_QueryWindowAccess,
+                    0, BadImplementation);
             return Success;
         }
 
@@ -117,8 +117,8 @@ ProcXQueryWindowAccess(ClientPtr client)
 }
 
 void
-SRepXQueryWindowAccess(ClientPtr client, 
-                      int size, 
+SRepXQueryWindowAccess(ClientPtr client,
+                      int size,
                       xQueryWindowAccessReply* rep)
 {
     char n;
diff --git a/Xi/querydp.c b/Xi/querydp.c
index 6224f13..85b4802 100644
--- a/Xi/querydp.c
+++ b/Xi/querydp.c
@@ -86,14 +86,14 @@ ProcXQueryDevicePointer(ClientPtr client)
     pDev = LookupDeviceIntRec(stuff->deviceid);
     if (pDev == NULL || pDev->valuator == NULL) {
         SendErrorToClient(client, IReqCode, X_QueryDevicePointer,
-                stuff->deviceid, BadDevice); 
+                stuff->deviceid, BadDevice);
         return Success;
     }
 
     rc = dixLookupWindow(&pWin, stuff->win, client, DixReadAccess);
     if (rc != Success)
     {
-        SendErrorToClient(client, IReqCode, X_QueryDevicePointer, 
+        SendErrorToClient(client, IReqCode, X_QueryDevicePointer,
                 stuff->win, rc);
         return Success;
     }
@@ -111,7 +111,7 @@ ProcXQueryDevicePointer(ClientPtr client)
     rep.rootX = pSprite->hot.x;
     rep.rootY = pSprite->hot.y;
     rep.child = None;
-    rep.shared = (pDev->spriteInfo->spriteOwner) ? xFalse : xTrue; 
+    rep.shared = (pDev->spriteInfo->spriteOwner) ? xFalse : xTrue;
 
     if (pSprite->hot.pScreen == pWin->drawable.pScreen)
     {
@@ -155,7 +155,7 @@ ProcXQueryDevicePointer(ClientPtr client)
  */
 
 void
-SRepXQueryDevicePointer(ClientPtr client, int size, 
+SRepXQueryDevicePointer(ClientPtr client, int size,
         xQueryDevicePointerReply * rep)
 {
     char n;
diff --git a/Xi/regpair.c b/Xi/regpair.c
index cfaddb8..3fe4591 100644
--- a/Xi/regpair.c
+++ b/Xi/regpair.c
@@ -53,12 +53,12 @@ from the author.
 
 /***********************************************************************
  *
- * This procedure allows a client to register the pairing of a pointer 
+ * This procedure allows a client to register the pairing of a pointer
  * with a keyboard.
  *
  */
 
-int 
+int
 SProcXRegisterPairingClient(ClientPtr client)
 {
     char n;
@@ -67,7 +67,7 @@ SProcXRegisterPairingClient(ClientPtr client)
     return ProcXRegisterPairingClient(client);
 }
 
-int 
+int
 ProcXRegisterPairingClient(ClientPtr client)
 {
     xRegisterPairingClientReply rep;
@@ -96,7 +96,7 @@ ProcXRegisterPairingClient(ClientPtr client)
  */
 
 void
-SRepXRegisterPairingClient(ClientPtr client, int size, 
+SRepXRegisterPairingClient(ClientPtr client, int size,
         xRegisterPairingClientReply* rep)
 {
     register char n;
diff --git a/Xi/sendexev.c b/Xi/sendexev.c
index 20b415a..12fe7d2 100644
--- a/Xi/sendexev.c
+++ b/Xi/sendexev.c
@@ -110,7 +110,7 @@ SProcXSendExtensionEvent(ClientPtr client)
 
 /***********************************************************************
  *
- * Send an event to some client, as if it had come from an extension input 
+ * Send an event to some client, as if it had come from an extension input
  * device.
  *
  */
diff --git a/Xi/stubs.c b/Xi/stubs.c
index 40cd02f..744447a 100644
--- a/Xi/stubs.c
+++ b/Xi/stubs.c
@@ -88,7 +88,7 @@ CloseInputDevice(DeviceIntPtr d, ClientPtr client)
  *
  * Caller:	ProcXListInputDevices
  *
- * This is the implementation-dependent routine to initialize an input 
+ * This is the implementation-dependent routine to initialize an input
  * device to the point that information about it can be listed.
  * Some implementations open all input devices when the server is first
  * initialized, and never close them.  Other implementations open only
@@ -100,12 +100,12 @@ CloseInputDevice(DeviceIntPtr d, ClientPtr client)
  * This procedure should be used by implementations that do not initialize
  * all input devices at server startup.  It should do device-dependent
  * initialization for any devices not previously initialized, and call
- * AddInputDevice for each of those devices so that a DeviceIntRec will be 
+ * AddInputDevice for each of those devices so that a DeviceIntRec will be
  * created for them.
  *
  * The default implementation is to do nothing (assume all input devices
  * are initialized during X server initialization and kept open).
- * The commented-out sample code shows what you might do if you don't want 
+ * The commented-out sample code shows what you might do if you don't want
  * the default.
  *
  */
@@ -114,7 +114,7 @@ void
 AddOtherInputDevices(void)
 {
     /**********************************************************************
-     for each uninitialized device, do something like: 
+     for each uninitialized device, do something like:
 
     DeviceIntPtr dev;
     DeviceProc deviceProc;
@@ -137,7 +137,7 @@ AddOtherInputDevices(void)
  * initialized, and never close them.  Other implementations open only
  * the X pointer and keyboard devices during server initialization,
  * and only open other input devices when some client makes an
- * XOpenDevice request.  This entry point is for the latter type of 
+ * XOpenDevice request.  This entry point is for the latter type of
  * implementation.
  *
  * If the physical device is not already open, do it here.  In this case,
diff --git a/Xi/warpdevp.c b/Xi/warpdevp.c
index 82d71d5..a675bdc 100644
--- a/Xi/warpdevp.c
+++ b/Xi/warpdevp.c
@@ -87,7 +87,7 @@ ProcXWarpDevicePointer(ClientPtr client)
     if (pDev == NULL) {
         SendErrorToClient(client, IReqCode, X_WarpDevicePointer,
                 stuff->deviceid,
-                BadDevice); 
+                BadDevice);
         return Success;
     }
 
@@ -96,7 +96,7 @@ ProcXWarpDevicePointer(ClientPtr client)
         err = dixLookupWindow(&dest, stuff->dst_win, client, DixReadAccess);
         if (err != Success)
         {
-            SendErrorToClient(client, IReqCode, X_WarpDevicePointer, 
+            SendErrorToClient(client, IReqCode, X_WarpDevicePointer,
                     stuff->dst_win, err);
             return Success;
         }
@@ -114,14 +114,14 @@ ProcXWarpDevicePointer(ClientPtr client)
         err = dixLookupWindow(&src, stuff->src_win, client, DixReadAccess);
         if (err != Success)
         {
-            SendErrorToClient(client, IReqCode, X_WarpDevicePointer, 
+            SendErrorToClient(client, IReqCode, X_WarpDevicePointer,
                     stuff->src_win, err);
             return Success;
         }
 
         winX = src->drawable.x;
         winY = src->drawable.y;
-        if (src->drawable.pScreen != pSprite->hotPhys.pScreen || 
+        if (src->drawable.pScreen != pSprite->hotPhys.pScreen ||
                 x < winX + stuff->src_x ||
                 y < winY + stuff->src_y ||
                 (stuff->src_width != 0 &&
commit 5031238aad2b6b7511aab0f9d15edfbdd2b4cce7
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Tue Nov 13 16:58:23 2007 +1030

    dix: remove trailing/wrong whitespaces from devices.c and events.c

diff --git a/dix/devices.c b/dix/devices.c
index 7841e64..fa80a0c 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -27,13 +27,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -203,7 +203,7 @@ AddInputDevice(DeviceProc deviceProc, Bool autoStart)
  *
  * A master pointer device needs to be enabled before a master keyboard
  * device.
- * 
+ *
  * @param The device to be enabled.
  * @return TRUE on success or FALSE otherwise.
  */
@@ -300,7 +300,7 @@ DisableDevice(DeviceIntPtr dev)
         {
             if (other->spriteInfo->paired == dev)
             {
-                ErrorF("[dix] cannot disable device, still paired. " 
+                ErrorF("[dix] cannot disable device, still paired. "
                         "This is a bug. \n");
                 return FALSE;
             }
@@ -316,7 +316,7 @@ DisableDevice(DeviceIntPtr dev)
     /* float attached devices */
     if (dev->isMaster)
     {
-        for (other = inputInfo.devices; other; other = other->next) 
+        for (other = inputInfo.devices; other; other = other->next)
         {
             if (other->u.master == dev)
                 AttachDevice(NULL, dev, NULL);
@@ -337,7 +337,7 @@ DisableDevice(DeviceIntPtr dev)
 /**
  * Initialise a new device through the driver and tell all clients about the
  * new device.
- * 
+ *
  * Must be called before EnableDevice.
  * The device will NOT send events until it is enabled!
  *
@@ -360,7 +360,7 @@ ActivateDevice(DeviceIntPtr dev)
     /* Initialize memory for sprites. */
     if (dev->isMaster && dev->spriteInfo->spriteOwner)
         pScreen->DeviceCursorInitialize(dev, pScreen);
-    
+
     ev.type = DevicePresenceNotify;
     ev.time = currentTime.milliseconds;
     ev.devchange = DeviceAdded;
@@ -391,7 +391,7 @@ CoreKeyboardCtl(DeviceIntPtr pDev, KeybdCtrl *ctrl)
 }
 
 /**
- * Device control function for the Virtual Core Keyboard. 
+ * Device control function for the Virtual Core Keyboard.
  */
 static int
 CoreKeyboardProc(DeviceIntPtr pDev, int what)
@@ -475,7 +475,7 @@ CoreKeyboardProc(DeviceIntPtr pDev, int what)
 
 /**
  * Device control function for the Virtual Core Pointer.
- * 
+ *
  * Aside from initialisation, it backs up the original device classes into the
  * devicePrivates. This only needs to be done for master devices.
  */
@@ -492,7 +492,7 @@ CorePointerProc(DeviceIntPtr pDev, int what)
         if (MasterDevClassesPrivIdx == -1)
             MasterDevClassesPrivIdx = AllocateDevicePrivateIndex();
 
-        if (!AllocateDevicePrivate(pDev, MasterDevClassesPrivIdx) || 
+        if (!AllocateDevicePrivate(pDev, MasterDevClassesPrivIdx) ||
                 !(classes = xcalloc(1, sizeof(ClassesRec))))
             return BadAlloc;
 
@@ -553,8 +553,8 @@ InitCoreDevices(void)
         CoreDevicePrivatesGeneration = serverGeneration;
     }
 
-    if (AllocMasterDevice("Virtual core", 
-                          &inputInfo.pointer, 
+    if (AllocMasterDevice("Virtual core",
+                          &inputInfo.pointer,
                           &inputInfo.keyboard) == BadAlloc)
         FatalError("Failed to allocate core devices");
 
@@ -573,14 +573,14 @@ InitCoreDevices(void)
 
 /**
  * Activate all switched-off devices and then enable all those devices.
- * 
+ *
  * Will return an error if no core keyboard or core pointer is present.
  * In theory this should never happen if you call InitCoreDevices() first.
  *
  * InitAndStartDevices needs to be called AFTER the windows are initialized.
  * Devices will start sending events after InitAndStartDevices() has
  * completed.
- * 
+ *
  * @return Success or error code on failure.
  */
 int
@@ -621,7 +621,7 @@ InitAndStartDevices(WindowPtr root)
 }
 
 /**
- * Close down a device and free all resources. 
+ * Close down a device and free all resources.
  * Once closed down, the driver will probably not expect you that you'll ever
  * enable it again and free associated structs. If you want the device to just
  * be disabled, DisableDevice().
@@ -654,7 +654,7 @@ CloseDevice(DeviceIntPtr dev)
 
     if (dev->isMaster)
         classes = (ClassesPtr)dev->devPrivates[MasterDevClassesPrivIdx].ptr;
-    else 
+    else
         classes = (ClassesPtr)&dev->key;
 
     if (classes->key) {
@@ -704,7 +704,7 @@ CloseDevice(DeviceIntPtr dev)
 	pnext = p->next;
 	xfree(p);
     }
-    
+
     for (i = classes->intfeed; i; i = inext) {
 	inext = i->next;
 	xfree(i);
@@ -735,7 +735,7 @@ CloseDevice(DeviceIntPtr dev)
     while (dev->xkb_interest)
 	XkbRemoveResourceClient((DevicePtr)dev,dev->xkb_interest->resource);
 #endif
-    
+
     if (DevHasCursor(dev)) {
         xfree(dev->spriteInfo->sprite->spriteTrace);
         xfree(dev->spriteInfo->sprite);
@@ -759,7 +759,7 @@ CloseDevice(DeviceIntPtr dev)
 }
 
 /**
- * Shut down all devices, free all resources, etc. 
+ * Shut down all devices, free all resources, etc.
  * Only useful if you're shutting down the server!
  */
 void
@@ -788,7 +788,7 @@ CloseDownDevices(void)
  * Remove the cursor sprite for all devices. This needs to be done before any
  * resources are freed or any device is deleted.
  */
-void 
+void
 UndisplayDevices()
 {
     DeviceIntPtr dev;
@@ -802,7 +802,7 @@ UndisplayDevices()
 
 /**
  * Remove a device from the device list, closes it and thus frees all
- * resources. 
+ * resources.
  * Removes both enabled and disabled devices and notifies all devices about
  * the removal of the device.
  */
@@ -855,7 +855,7 @@ RemoveDevice(DeviceIntPtr dev)
             ret = Success;
 	}
     }
-    
+
     if (ret == Success) {
         inputInfo.numDevices--;
         ev.type = DevicePresenceNotify;
@@ -873,7 +873,7 @@ RemoveDevice(DeviceIntPtr dev)
 int
 NumMotionEvents(void)
 {
-    /* only called to fill data in initial connection reply. 
+    /* only called to fill data in initial connection reply.
      * VCP is ok here, it is the only fixed device we have. */
     return inputInfo.pointer->valuator->numMotionEvents;
 }
@@ -1023,7 +1023,7 @@ InitKeyClassDeviceStruct(DeviceIntPtr dev, KeySymsPtr pKeySyms, CARD8 pModifiers
 {
     int i;
     KeyClassPtr keyc;
-    
+
     keyc = (KeyClassPtr)xalloc(sizeof(KeyClassRec));
     if (!keyc)
 	return FALSE;
@@ -1058,7 +1058,7 @@ InitKeyClassDeviceStruct(DeviceIntPtr dev, KeySymsPtr pKeySyms, CARD8 pModifiers
 }
 
 _X_EXPORT Bool
-InitButtonClassDeviceStruct(DeviceIntPtr dev, int numButtons, 
+InitButtonClassDeviceStruct(DeviceIntPtr dev, int numButtons,
                             CARD8 *map)
 {
     ButtonClassPtr butc;
@@ -1082,8 +1082,8 @@ InitButtonClassDeviceStruct(DeviceIntPtr dev, int numButtons,
 }
 
 _X_EXPORT Bool
-InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes, 
-                              ValuatorMotionProcPtr motionProc, 
+InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes,
+                              ValuatorMotionProcPtr motionProc,
                               int numMotionEvents, int mode)
 {
     int i;
@@ -1176,7 +1176,7 @@ InitFocusClassDeviceStruct(DeviceIntPtr dev)
 }
 
 _X_EXPORT Bool
-InitKbdFeedbackClassDeviceStruct(DeviceIntPtr dev, BellProcPtr bellProc, 
+InitKbdFeedbackClassDeviceStruct(DeviceIntPtr dev, BellProcPtr bellProc,
                                  KbdCtrlProcPtr controlProc)
 {
     KbdFeedbackPtr feedc;
@@ -1240,7 +1240,7 @@ static IntegerCtrl defaultIntegerControl = {
 
 _X_EXPORT Bool
 InitStringFeedbackClassDeviceStruct (
-      DeviceIntPtr dev, StringCtrlProcPtr controlProc, 
+      DeviceIntPtr dev, StringCtrlProcPtr controlProc,
       int max_symbols, int num_symbols_supported, KeySym *symbols)
 {
     int i;
@@ -1253,9 +1253,9 @@ InitStringFeedbackClassDeviceStruct (
     feedc->ctrl.num_symbols_supported = num_symbols_supported;
     feedc->ctrl.num_symbols_displayed = 0;
     feedc->ctrl.max_symbols = max_symbols;
-    feedc->ctrl.symbols_supported = (KeySym *) 
+    feedc->ctrl.symbols_supported = (KeySym *)
 	xalloc (sizeof (KeySym) * num_symbols_supported);
-    feedc->ctrl.symbols_displayed = (KeySym *) 
+    feedc->ctrl.symbols_displayed = (KeySym *)
 	xalloc (sizeof (KeySym) * max_symbols);
     if (!feedc->ctrl.symbols_supported || !feedc->ctrl.symbols_displayed)
     {
@@ -1279,7 +1279,7 @@ InitStringFeedbackClassDeviceStruct (
 }
 
 _X_EXPORT Bool
-InitBellFeedbackClassDeviceStruct (DeviceIntPtr dev, BellProcPtr bellProc, 
+InitBellFeedbackClassDeviceStruct (DeviceIntPtr dev, BellProcPtr bellProc,
                                    BellCtrlProcPtr controlProc)
 {
     BellFeedbackPtr feedc;
@@ -1338,8 +1338,8 @@ InitIntegerFeedbackClassDeviceStruct (DeviceIntPtr dev, IntegerCtrlProcPtr contr
 }
 
 _X_EXPORT Bool
-InitPointerDeviceStruct(DevicePtr device, CARD8 *map, int numButtons, 
-                        ValuatorMotionProcPtr motionProc, 
+InitPointerDeviceStruct(DevicePtr device, CARD8 *map, int numButtons,
+                        ValuatorMotionProcPtr motionProc,
                         PtrCtrlProcPtr controlProc, int numMotionEvents,
                         int numAxes)
 {
@@ -1352,9 +1352,9 @@ InitPointerDeviceStruct(DevicePtr device, CARD8 *map, int numButtons,
 }
 
 _X_EXPORT Bool
-InitKeyboardDeviceStruct(DevicePtr device, KeySymsPtr pKeySyms, 
-                         CARD8 pModifiers[], BellProcPtr bellProc, 
-                         KbdCtrlProcPtr controlProc) 
+InitKeyboardDeviceStruct(DevicePtr device, KeySymsPtr pKeySyms,
+                         CARD8 pModifiers[], BellProcPtr bellProc,
+                         KbdCtrlProcPtr controlProc)
 {
     DeviceIntPtr dev = (DeviceIntPtr)device;
 
@@ -1525,13 +1525,13 @@ DoSetModifierMapping(ClientPtr client, KeyCode *inputMap,
     return Success;
 }
 
-int 
+int
 ProcSetModifierMapping(ClientPtr client)
 {
     xSetModifierMappingReply rep;
     DeviceIntPtr dev;
     REQUEST(xSetModifierMappingReq);
-    
+
     REQUEST_AT_LEAST_SIZE(xSetModifierMappingReq);
 
     if (client->req_len != ((stuff->numKeyPerModifier << 1) +
@@ -1583,7 +1583,7 @@ ProcChangeKeyboardMapping(ClientPtr client)
     DeviceIntPtr pDev = NULL;
     REQUEST_AT_LEAST_SIZE(xChangeKeyboardMappingReq);
 
-    len = client->req_len - (sizeof(xChangeKeyboardMappingReq) >> 2);  
+    len = client->req_len - (sizeof(xChangeKeyboardMappingReq) >> 2);
     if (len != (stuff->keyCodes * stuff->keySymsPerKeyCode))
             return BadLength;
 
@@ -1671,7 +1671,7 @@ ProcSetPointerMapping(ClientPtr client)
     rep.sequenceNumber = client->sequence;
     rep.success = MappingSuccess;
     map = (BYTE *)&stuff[1];
-    
+
     /* So we're bounded here by the number of core buttons.  This check
      * probably wants disabling through XFixes. */
     /* MPX: With ClientPointer, we can return the right number of buttons.
@@ -1750,7 +1750,7 @@ ProcGetPointerMapping(ClientPtr client)
     rep.length = ((unsigned)rep.nElts + (4-1))/4;
     WriteReplyToClient(client, sizeof(xGetPointerMappingReply), &rep);
     (void)WriteToClient(client, (int)rep.nElts, (char *)&butc->map[1]);
-    return Success;    
+    return Success;
 }
 
 void
@@ -1790,7 +1790,7 @@ DoChangeKeyboardControl (ClientPtr client, DeviceIntPtr keybd, XID *vlist,
 	index2 = (BITS32) lowbit (vmask);
 	vmask &= ~index2;
 	switch (index2) {
-	case KBKeyClickPercent: 
+	case KBKeyClickPercent:
 	    t = (INT8)*vlist;
 	    vlist++;
 	    if (t == -1) {
@@ -1940,7 +1940,7 @@ DoChangeKeyboardControl (ClientPtr client, DeviceIntPtr keybd, XID *vlist,
     return Success;
 
 #undef DO_ALL
-} 
+}
 
 int
 ProcChangeKeyboardControl (ClientPtr client)
@@ -2000,7 +2000,7 @@ ProcGetKeyboardControl (ClientPtr client)
 	rep.map[i] = ctrl->autoRepeats[i];
     WriteReplyToClient(client, sizeof(xGetKeyboardControlReply), &rep);
     return Success;
-} 
+}
 
 int
 ProcBell(ClientPtr client)
@@ -2013,7 +2013,7 @@ ProcBell(ClientPtr client)
 
     if (!keybd->kbdfeed->BellProc)
         return BadDevice;
-    
+
     if (stuff->percent < -100 || stuff->percent > 100) {
 	client->errorValue = stuff->percent;
 	return BadValue;
@@ -2023,7 +2023,7 @@ ProcBell(ClientPtr client)
     if (stuff->percent < 0)
         newpercent = base + newpercent;
     else
-    	newpercent = base - newpercent + stuff->percent;
+	newpercent = base - newpercent + stuff->percent;
 
     for (keybd = inputInfo.devices; keybd; keybd = keybd->next) {
         if ((keybd->coreEvents || keybd == inputInfo.keyboard) &&
@@ -2040,7 +2040,7 @@ ProcBell(ClientPtr client)
     }
 
     return Success;
-} 
+}
 
 int
 ProcChangePointerControl(ClientPtr client)
@@ -2050,10 +2050,10 @@ ProcChangePointerControl(ClientPtr client)
     REQUEST(xChangePointerControlReq);
 
     REQUEST_SIZE_MATCH(xChangePointerControlReq);
-    
+
     if (!mouse->ptrfeed->CtrlProc)
         return BadDevice;
-    
+
     ctrl = mouse->ptrfeed->ctrl;
     if ((stuff->doAccel != xTrue) && (stuff->doAccel != xFalse)) {
 	client->errorValue = stuff->doAccel;
@@ -2109,7 +2109,7 @@ ProcChangePointerControl(ClientPtr client)
     }
 
     return Success;
-} 
+}
 
 int
 ProcGetPointerControl(ClientPtr client)
@@ -2231,17 +2231,17 @@ ProcQueryKeymap(ClientPtr client)
 	bzero((char *)&rep.map[0], 32);
 
     WriteReplyToClient(client, sizeof(xQueryKeymapReply), &rep);
- 
+
    return Success;
 }
 
 /* Pair the keyboard to the pointer device. Keyboard events will follow the
- * pointer sprite. Only applicable for master devices. 
+ * pointer sprite. Only applicable for master devices.
  * If the client is set, the request to pair comes from some client. In this
  * case, we need to check for access. If the client is NULL, it's from an
  * internal automatic pairing, we must always permit this.
  */
-int 
+int
 PairDevices(ClientPtr client, DeviceIntPtr ptr, DeviceIntPtr kbd)
 {
     if (!ptr)
@@ -2277,15 +2277,15 @@ PairDevices(ClientPtr client, DeviceIntPtr ptr, DeviceIntPtr kbd)
  * Client is set to the client that issued the request, or NULL if it comes
  * from some internal automatic pairing.
  *
- * Master may be NULL to set the device floating. 
+ * Master may be NULL to set the device floating.
  *
  * We don't allow multi-layer hierarchies right now. You can't attach a slave
- * to another slave. 
+ * to another slave.
  */
 int
 AttachDevice(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr master)
 {
-    if (!dev || dev->isMaster) 
+    if (!dev || dev->isMaster)
         return BadDevice;
 
     if (master && !master->isMaster) /* can't attach to slaves */
@@ -2345,13 +2345,13 @@ AttachDevice(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr master)
 
             /* Send event to clients */
             CreateClassesChangedEvent(&event, master, master);
-            deviceClassesChangedEvent *dcce = 
+            deviceClassesChangedEvent *dcce =
                         (deviceClassesChangedEvent*)event.event;
             dcce->deviceid = master->id;
             dcce->num_classes = 0;
             classbuf = (char*)&event.event[1];
             CopySwapClasses(NullClient, master, &dcce->num_classes, &classbuf);
-            SendEventToAllWindows(master, XI_DeviceClassesChangedMask, 
+            SendEventToAllWindows(master, XI_DeviceClassesChangedMask,
                     event.event, 1);
             xfree(event.event);
         }
@@ -2380,7 +2380,7 @@ GetPairedDevice(DeviceIntPtr dev)
 }
 
 /*
- * Register a client to be able to pair devices. 
+ * Register a client to be able to pair devices.
  */
 Bool
 RegisterPairingClient(ClientPtr client)
@@ -2398,22 +2398,22 @@ RegisterPairingClient(ClientPtr client)
 /*
  * Unregister pairing client;
  */
-Bool 
+Bool
 UnregisterPairingClient(ClientPtr client)
 {
-    if (pairingClient) 
+    if (pairingClient)
     {
         if ( pairingClient == client)
         {
             pairingClient = NULL;
-        } else 
+        } else
             return False;
     }
     return True;
 }
 
 /* Guess a pointer that could be a good one for pairing. Any pointer that is
- * not yet paired with keyboard is considered a good one. 
+ * not yet paired with keyboard is considered a good one.
  * If no pointer is found, the last real pointer is chosen. If that doesn't
  * work either, we take the core pointer.
  */
@@ -2422,7 +2422,7 @@ GuessFreePointerDevice()
 {
     DeviceIntPtr it, it2;
     DeviceIntPtr lastRealPtr = NULL;
-        
+
     it = inputInfo.devices;
 
     while(it)
@@ -2436,7 +2436,7 @@ GuessFreePointerDevice()
             while(it2)
             {
                 /* something paired with it? */
-                if (it != it2 && 
+                if (it != it2 &&
                         it2->spriteInfo->sprite == it->spriteInfo->sprite)
                     break;
 
@@ -2458,8 +2458,8 @@ NextFreePointerDevice()
 {
     DeviceIntPtr dev;
     for (dev = inputInfo.devices; dev; dev = dev->next)
-        if (dev->isMaster && 
-                dev->spriteInfo->spriteOwner && 
+        if (dev->isMaster &&
+                dev->spriteInfo->spriteOwner &&
                 !dev->spriteInfo->paired)
             return dev;
     return NULL;
diff --git a/dix/events.c b/dix/events.c
index daebe35..88ce501 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -27,13 +27,13 @@ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 
                         All Rights Reserved
 
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
+both that copyright notice and this permission notice appear in
 supporting documentation, and that the name of Digital not be
 used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
+software without specific, written prior permission.
 
 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
@@ -107,7 +107,7 @@ of the copyright holder.
 
 ******************************************************************/
 
-/* 
+/*
  * MPX additions
  * Copyright 2006 by Peter Hutterer
  * Author: Peter Hutterer <peter at cs.unisa.edu.au>
@@ -239,22 +239,22 @@ static int DontPropagateRefCnts[DNPMCOUNT];
 
 
 /**
- * Main input device struct. 
- *     inputInfo.pointer 
+ * Main input device struct.
+ *     inputInfo.pointer
  *     is the core pointer. Referred to as "virtual core pointer", "VCP",
  *     "core pointer" or inputInfo.pointer. There is exactly one core pointer,
  *     but multiple devices may send core events. The VCP is only used if no
- *     physical device is connected and does not have a visible cursor. 
+ *     physical device is connected and does not have a visible cursor.
  *     Before the integration of MPX, any core request would operate on the
  *     VCP/VCK. Core events would always come from one of those two. Now both
  *     are only fallback devices if no physical devices are available.
- * 
+ *
  *     inputInfo.keyboard
  *     is the core keyboard ("virtual core keyboard", "VCK", "core keyboard").
  *     See inputInfo.pointer.
- * 
+ *
  *     inputInfo.devices
- *     linked list containing all devices BUT NOT INCLUDING VCK and VCP. 
+ *     linked list containing all devices BUT NOT INCLUDING VCK and VCP.
  *
  *     inputInfo.off_devices
  *     Devices that have not been initialized and are thus turned off.
@@ -316,12 +316,12 @@ XItoCoreType(int xitype)
     return coretype;
 }
 
-/** 
+/**
  * True if device owns a cursor, false if device shares a cursor sprite with
  * another device.
  */
 _X_EXPORT Bool
-DevHasCursor(DeviceIntPtr pDev) 
+DevHasCursor(DeviceIntPtr pDev)
 {
     return pDev->spriteInfo->spriteOwner;
 }
@@ -352,11 +352,11 @@ _X_EXPORT HotSpot xeviehot;
 #endif
 
 static void DoEnterLeaveEvents(
-    DeviceIntPtr pDev, 
+    DeviceIntPtr pDev,
     WindowPtr fromWin,
     WindowPtr toWin,
     int mode
-); 
+);
 
 static WindowPtr XYToWindow(
     DeviceIntPtr pDev,
@@ -416,9 +416,9 @@ static Mask filters[128] =
 };
 
 
-/** 
+/**
  * same principle as filters, but one set of filters for each extension.
- * The extension is responsible for setting the filters by calling 
+ * The extension is responsible for setting the filters by calling
  * SetGenericFilter().
  */
 static Mask* generic_filters[MAXEXTENSIONS];
@@ -441,8 +441,8 @@ static void PostNewCursor(DeviceIntPtr pDev);
 static Bool
 XineramaSetCursorPosition(
     DeviceIntPtr pDev,
-    int x, 
-    int y, 
+    int x,
+    int y,
     Bool generateEvent
 ){
     ScreenPtr pScreen;
@@ -451,7 +451,7 @@ XineramaSetCursorPosition(
     SpritePtr pSprite = pDev->spriteInfo->sprite;
 
     /* x,y are in Screen 0 coordinates.  We need to decide what Screen
-       to send the message too and what the coordinates relative to 
+       to send the message too and what the coordinates relative to
        that screen are. */
 
     pScreen = pSprite->screen;
@@ -459,11 +459,11 @@ XineramaSetCursorPosition(
     y += panoramiXdataPtr[0].y;
 
     if(!POINT_IN_REGION(pScreen, &XineramaScreenRegions[pScreen->myNum],
-								x, y, &box)) 
+								x, y, &box))
     {
-	FOR_NSCREENS(i) 
+	FOR_NSCREENS(i)
 	{
-	    if(i == pScreen->myNum) 
+	    if(i == pScreen->myNum)
 		continue;
 	    if(POINT_IN_REGION(pScreen, &XineramaScreenRegions[i], x, y, &box))
 	    {
@@ -514,7 +514,7 @@ XineramaCheckPhysLimits(
 
     if (!cursor)
 	return;
- 
+
     new = pSprite->hotPhys;
 
     /* I don't care what the DDX has to say about it */
@@ -553,7 +553,7 @@ XineramaSetWindowPntrs(DeviceIntPtr pDev, WindowPtr pWin)
     SpritePtr pSprite = pDev->spriteInfo->sprite;
 
     if(pWin == WindowTable[0]) {
-	    memcpy(pSprite->windows, WindowTable, 
+	    memcpy(pSprite->windows, WindowTable,
 				PanoramiXNumScreens*sizeof(WindowPtr));
     } else {
 	PanoramiXRes *win;
@@ -577,7 +577,7 @@ static void
 XineramaCheckVirtualMotion(
    DeviceIntPtr pDev,
    QdEventPtr qe,
-   WindowPtr pWin) 
+   WindowPtr pWin)
 {
     SpritePtr pSprite = pDev->spriteInfo->sprite;
 
@@ -598,9 +598,9 @@ XineramaCheckVirtualMotion(
 	    return;
 
 	i = PanoramiXNumScreens - 1;
-	
-	REGION_COPY(pSprite->screen, &pSprite->Reg2, 
-					&pSprite->windows[i]->borderSize); 
+
+	REGION_COPY(pSprite->screen, &pSprite->Reg2,
+					&pSprite->windows[i]->borderSize);
 	off_x = panoramiXdataPtr[i].x;
 	off_y = panoramiXdataPtr[i].y;
 
@@ -610,8 +610,8 @@ XineramaCheckVirtualMotion(
 
 	    if(x || y)
 		REGION_TRANSLATE(pSprite->screen, &pSprite->Reg2, x, y);
-		
-	    REGION_UNION(pSprite->screen, &pSprite->Reg2, &pSprite->Reg2, 
+
+	    REGION_UNION(pSprite->screen, &pSprite->Reg2, &pSprite->Reg2,
 					&pSprite->windows[i]->borderSize);
 
 	    off_x = panoramiXdataPtr[i].x;
@@ -629,8 +629,8 @@ XineramaCheckVirtualMotion(
         else if (pSprite->hot.y >= lims.y2)
             pSprite->hot.y = lims.y2 - 1;
 
-	if (REGION_NUM_RECTS(&pSprite->Reg2) > 1) 
-	    ConfineToShape(pDev, &pSprite->Reg2, 
+	if (REGION_NUM_RECTS(&pSprite->Reg2) > 1)
+	    ConfineToShape(pDev, &pSprite->Reg2,
                     &pSprite->hot.x, &pSprite->hot.y);
 
 	if (qe)
@@ -658,7 +658,7 @@ XineramaCheckMotion(xEvent *xE, DeviceIntPtr pDev)
     if (xE && !syncEvents.playingEvents)
     {
 	/* Motion events entering DIX get translated to Screen 0
-	   coordinates.  Replayed events have already been 
+	   coordinates.  Replayed events have already been
 	   translated since they've entered DIX before */
 	XE_KBPTR.rootX += panoramiXdataPtr[pSprite->screen->myNum].x -
 			  panoramiXdataPtr[0].x;
@@ -675,7 +675,7 @@ XineramaCheckMotion(xEvent *xE, DeviceIntPtr pDev)
 	else if (pSprite->hot.y >= pSprite->physLimits.y2)
 	    pSprite->hot.y = pSprite->physLimits.y2 - 1;
 
-	if (pSprite->hotShape) 
+	if (pSprite->hotShape)
 	    ConfineToShape(pDev, pSprite->hotShape, &pSprite->hot.x, &pSprite->hot.y);
 
 	pSprite->hotPhys = pSprite->hot;
@@ -702,7 +702,7 @@ XineramaCheckMotion(xEvent *xE, DeviceIntPtr pDev)
 	    if (!xE)
 		UpdateCurrentTimeIf();
             DoEnterLeaveEvents(pDev, prevSpriteWin, pSprite->win,
-                               NotifyNormal); 
+                               NotifyNormal);
         }
 	PostNewCursor(pDev);
         return FALSE;
@@ -712,8 +712,8 @@ XineramaCheckMotion(xEvent *xE, DeviceIntPtr pDev)
 
 
 static void
-XineramaConfineCursorToWindow(DeviceIntPtr pDev, 
-                              WindowPtr pWin, 
+XineramaConfineCursorToWindow(DeviceIntPtr pDev,
+                              WindowPtr pWin,
                               Bool generateEvents)
 {
     SpritePtr pSprite = pDev->spriteInfo->sprite;
@@ -731,9 +731,9 @@ XineramaConfineCursorToWindow(DeviceIntPtr pDev,
 	    return;
 
 	i = PanoramiXNumScreens - 1;
-	
-	REGION_COPY(pSprite->screen, &pSprite->Reg1, 
-					&pSprite->windows[i]->borderSize); 
+
+	REGION_COPY(pSprite->screen, &pSprite->Reg1,
+					&pSprite->windows[i]->borderSize);
 	off_x = panoramiXdataPtr[i].x;
 	off_y = panoramiXdataPtr[i].y;
 
@@ -743,8 +743,8 @@ XineramaConfineCursorToWindow(DeviceIntPtr pDev,
 
 	    if(x || y)
 		REGION_TRANSLATE(pSprite->screen, &pSprite->Reg1, x, y);
-		
-	    REGION_UNION(pSprite->screen, &pSprite->Reg1, &pSprite->Reg1, 
+
+	    REGION_UNION(pSprite->screen, &pSprite->Reg1, &pSprite->Reg1,
 					&pSprite->windows[i]->borderSize);
 
 	    off_x = panoramiXdataPtr[i].x;
@@ -757,12 +757,12 @@ XineramaConfineCursorToWindow(DeviceIntPtr pDev,
 	   pSprite->hotShape = &pSprite->Reg1;
 	else
 	   pSprite->hotShape = NullRegion;
-	
+
 	pSprite->confined = FALSE;
 	pSprite->confineWin = (pWin == WindowTable[0]) ? NullWindow : pWin;
 
         XineramaCheckPhysLimits(pDev, pSprite->current,
-                                generateEvents); 
+                                generateEvents);
     }
 }
 
@@ -777,7 +777,7 @@ XineramaChangeToCursor(DeviceIntPtr pDev, CursorPtr cursor)
 	if ((pSprite->current->bits->xhot != cursor->bits->xhot) ||
 		(pSprite->current->bits->yhot != cursor->bits->yhot))
 	    XineramaCheckPhysLimits(pDev, cursor, FALSE);
-    	(*pSprite->screen->DisplayCursor)(pDev, pSprite->screen, cursor);
+	(*pSprite->screen->DisplayCursor)(pDev, pSprite->screen, cursor);
 	FreeCursor(pSprite->current, (Cursor)0);
 	pSprite->current = cursor;
 	pSprite->current->refcnt++;
@@ -823,7 +823,7 @@ ConfineToShape(DeviceIntPtr pDev, RegionPtr shape, int *px, int *py)
     BoxRec box;
     int x = *px, y = *py;
     int incx = 1, incy = 1;
-    SpritePtr pSprite; 
+    SpritePtr pSprite;
 
     pSprite = pDev->spriteInfo->sprite;
     if (POINT_IN_REGION(pSprite->hot.pScreen, shape, x, y, &box))
@@ -858,7 +858,7 @@ ConfineToShape(DeviceIntPtr pDev, RegionPtr shape, int *px, int *py)
 
 static void
 CheckPhysLimits(
-    DeviceIntPtr pDev, 
+    DeviceIntPtr pDev,
     CursorPtr cursor,
     Bool generateEvents,
     Bool confineToScreen,
@@ -890,15 +890,15 @@ CheckPhysLimits(
 	    new.y = pSprite->physLimits.y2 - 1;
 #ifdef SHAPE
     if (pSprite->hotShape)
-	ConfineToShape(pDev, pSprite->hotShape, &new.x, &new.y); 
+	ConfineToShape(pDev, pSprite->hotShape, &new.x, &new.y);
 #endif
     if ((pScreen != pSprite->hotPhys.pScreen) ||
 	(new.x != pSprite->hotPhys.x) || (new.y != pSprite->hotPhys.y))
     {
 	if (pScreen != pSprite->hotPhys.pScreen)
 	    pSprite->hotPhys = new;
-        (*pScreen->SetCursorPosition) 
-            (pDev, pScreen, new.x, new.y, generateEvents); 
+        (*pScreen->SetCursorPosition)
+            (pDev, pScreen, new.x, new.y, generateEvents);
         if (!generateEvents)
 	    SyntheticMotion(pDev, new.x, new.y);
     }
@@ -945,7 +945,7 @@ CheckVirtualMotion(
 	    pSprite->hot.y = lims.y2 - 1;
 #ifdef SHAPE
 	if (wBoundingShape(pWin))
-	    ConfineToShape(pDev, &pWin->borderSize, 
+	    ConfineToShape(pDev, &pWin->borderSize,
                     &pSprite->hot.x, &pSprite->hot.y);
 #endif
 	if (qe)
@@ -972,7 +972,7 @@ ConfineCursorToWindow(DeviceIntPtr pDev, WindowPtr pWin, Bool generateEvents, Bo
     if(!noPanoramiXExtension) {
 	XineramaConfineCursorToWindow(pDev, pWin, generateEvents);
 	return;
-    }	
+    }
 #endif
 
     if (syncEvents.playingEvents)
@@ -1033,7 +1033,7 @@ ChangeToCursor(DeviceIntPtr pDev, CursorPtr cursor)
 }
 
 /**
- * @returns true if b is a descendent of a 
+ * @returns true if b is a descendent of a
  */
 Bool
 IsParent(WindowPtr a, WindowPtr b)
@@ -1046,7 +1046,7 @@ IsParent(WindowPtr a, WindowPtr b)
 /**
  * Update the cursor displayed on the screen.
  *
- * Called whenever a cursor may have changed shape or position.  
+ * Called whenever a cursor may have changed shape or position.
  */
 static void
 PostNewCursor(DeviceIntPtr pDev)
@@ -1074,7 +1074,7 @@ PostNewCursor(DeviceIntPtr pDev)
 	win = pSprite->win;
     for (; win; win = win->parent)
     {
-	if (win->optional) 
+	if (win->optional)
         {
             pCursor = WindowGetDeviceCursor(win, pDev);
             if (!pCursor && win->optional->cursor != NullCursor)
@@ -1173,16 +1173,16 @@ NoticeEventTime(xEvent *xE)
  **************************************************************************/
 
 /**
- * EnqueueEvent is a device's processInputProc if a device is frozen. 
+ * 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;
-    SpritePtr 	pSprite = device->spriteInfo->sprite;
+    QdEventPtr	tail = *syncEvents.pendtail;
+    QdEventPtr	qe;
+    SpritePtr	pSprite = device->spriteInfo->sprite;
     int		eventlen;
 
 
@@ -1190,7 +1190,7 @@ EnqueueEvent(xEvent *xE, DeviceIntPtr device, int count)
 
 #ifdef XKB
     /* Fix for key repeating bug. */
-    if (device->key != NULL && device->key->xkbInfo != NULL && 
+    if (device->key != NULL && device->key->xkbInfo != NULL &&
 	xE->u.u.type == KeyRelease)
 	AccessXCancelRepeatKey(device->key->xkbInfo, xE->u.u.detail);
 #endif
@@ -1271,9 +1271,9 @@ EnqueueEvent(xEvent *xE, DeviceIntPtr device, int count)
 
 /**
  * Run through the list of events queued up in syncEvents.
- * For each event do: 
+ * For each event do:
  * If the device for this event is not frozen anymore, take it and process it
- * as usually. 
+ * 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.
@@ -1315,11 +1315,11 @@ PlayReleasedEvents(void)
 	      to the DIX layer */
             /* XXX: we can't do that for generic events */
 	    if(!noPanoramiXExtension) {
-		qe->event->u.keyButtonPointer.rootX += 
-			panoramiXdataPtr[0].x - 
+		qe->event->u.keyButtonPointer.rootX +=
+			panoramiXdataPtr[0].x -
 			panoramiXdataPtr[pDev->spriteInfo->sprite->screen->myNum].x;
-		qe->event->u.keyButtonPointer.rootY += 
-			panoramiXdataPtr[0].y - 
+		qe->event->u.keyButtonPointer.rootY +=
+			panoramiXdataPtr[0].y -
 			panoramiXdataPtr[pDev->spriteInfo->sprite->screen->myNum].y;
 	    }
 #endif
@@ -1336,7 +1336,7 @@ PlayReleasedEvents(void)
 	}
 	else
 	    prev = &qe->next;
-    } 
+    }
 }
 
 /**
@@ -1378,7 +1378,7 @@ ComputeFreezes(void)
     BOOL sendCore;
 
     for (dev = inputInfo.devices; dev; dev = dev->next)
-	FreezeThaw(dev, dev->deviceGrab.sync.other || 
+	FreezeThaw(dev, dev->deviceGrab.sync.other ||
                 (dev->deviceGrab.sync.state >= FROZEN));
     if (syncEvents.playingEvents || (!replayDev && !syncEvents.pending))
 	return;
@@ -1412,7 +1412,7 @@ ComputeFreezes(void)
                         core = *xE;
                         core.u.u.type = XItoCoreType(xE->u.u.type);
                         /* * XXX: Not sure if this is correct: we need to
-                         * check inferior windows for core passive grabs. 
+                         * check inferior windows for core passive grabs.
                          */
                         if (CheckDeviceGrabs(replayDev, &core, i+1, 1))
                         {
@@ -1458,12 +1458,12 @@ playmore:
     {
         if (DevHasCursor(dev))
         {
-            /* the following may have been skipped during replay, 
+            /* the following may have been skipped during replay,
               so do it now */
             if ((grab = dev->deviceGrab.grab) && grab->confineTo)
             {
                 if (grab->confineTo->drawable.pScreen !=
-                        dev->spriteInfo->sprite->hotPhys.pScreen) 
+                        dev->spriteInfo->sprite->hotPhys.pScreen)
                     dev->spriteInfo->sprite->hotPhys.x =
                         dev->spriteInfo->sprite->hotPhys.y = 0;
                 ConfineCursorToWindow(dev, grab->confineTo, TRUE, TRUE);
@@ -1491,13 +1491,13 @@ ScreenRestructured (ScreenPtr pScreen)
          * worry about it. */
         if ((grab = pDev->deviceGrab.grab) && grab->confineTo)
         {
-            if (grab->confineTo->drawable.pScreen 
+            if (grab->confineTo->drawable.pScreen
                     != pDev->spriteInfo->sprite->hotPhys.pScreen)
                 pDev->spriteInfo->sprite->hotPhys.x = pDev->spriteInfo->sprite->hotPhys.y = 0;
             ConfineCursorToWindow(pDev, grab->confineTo, TRUE, TRUE);
         }
         else
-            ConfineCursorToWindow(pDev, 
+            ConfineCursorToWindow(pDev,
                     WindowTable[pDev->spriteInfo->sprite->hotPhys.pScreen->myNum],
                     TRUE, FALSE);
     }
@@ -1521,7 +1521,7 @@ CheckGrabForSyncs(DeviceIntPtr thisDev, Bool thisMode, Bool otherMode)
 	    thisDev->deviceGrab.sync.other = NullGrab;
     }
     /* XXX: other should only work on the paired keyboard, not on all other
-       devices 
+       devices
      */
     for (dev = inputInfo.devices; dev; dev = dev->next)
     {
@@ -1591,25 +1591,25 @@ RestoreOldMaster(DeviceIntPtr dev)
 
 /**
  * Activate a pointer grab on the given device. A pointer grab will cause all
- * core pointer events of this device to be delivered to the grabbing client only. 
+ * core pointer events of this device to be delivered to the grabbing client only.
  * No other device will send core events to the grab client while the grab is
  * on, but core events will be sent to other clients.
  * Can cause the cursor to change if a grab cursor is set.
- * 
+ *
  * Note that parameter autoGrab may be (True & ImplicitGrabMask) if the grab
  * is an implicit grab caused by a ButtonPress event.
- * 
+ *
  * @param mouse The device to grab.
  * @param grab The grab structure, needs to be setup.
  * @param autoGrab True if the grab was caused by a button down event and not
- * explicitely by a client. 
+ * explicitely by a client.
  */
 void
-ActivatePointerGrab(DeviceIntPtr mouse, GrabPtr grab, 
+ActivatePointerGrab(DeviceIntPtr mouse, GrabPtr grab,
                     TimeStamp time, Bool autoGrab)
 {
     GrabInfoPtr grabinfo = &mouse->deviceGrab;
-    WindowPtr oldWin = (grabinfo->grab) ? 
+    WindowPtr oldWin = (grabinfo->grab) ?
                         grabinfo->grab->window
                         : mouse->spriteInfo->sprite->win;
     Bool isPassive = autoGrab & ~ImplicitGrabMask;
@@ -1623,9 +1623,9 @@ ActivatePointerGrab(DeviceIntPtr mouse, GrabPtr grab,
 
     if (grab->confineTo)
     {
-	if (grab->confineTo->drawable.pScreen 
+	if (grab->confineTo->drawable.pScreen
                 != mouse->spriteInfo->sprite->hotPhys.pScreen)
-	    mouse->spriteInfo->sprite->hotPhys.x = 
+	    mouse->spriteInfo->sprite->hotPhys.x =
                 mouse->spriteInfo->sprite->hotPhys.y = 0;
 	ConfineCursorToWindow(mouse, grab->confineTo, FALSE, TRUE);
     }
@@ -1666,7 +1666,7 @@ DeactivatePointerGrab(DeviceIntPtr mouse)
 	if (dev->deviceGrab.sync.other == grab)
 	    dev->deviceGrab.sync.other = NullGrab;
     }
-    DoEnterLeaveEvents(mouse, grab->window, 
+    DoEnterLeaveEvents(mouse, grab->window,
                        mouse->spriteInfo->sprite->win, NotifyUngrab);
     if (grab->confineTo)
 	ConfineCursorToWindow(mouse, RootWindow(mouse), FALSE, FALSE);
@@ -1681,7 +1681,7 @@ DeactivatePointerGrab(DeviceIntPtr mouse)
 }
 
 /**
- * Activate a keyboard grab on the given device. 
+ * Activate a keyboard grab on the given device.
  *
  * Extension devices have ActivateKeyboardGrab() set as their grabbing proc.
  */
@@ -1720,7 +1720,7 @@ ActivateKeyboardGrab(DeviceIntPtr keybd, GrabPtr grab, TimeStamp time, Bool pass
 }
 
 /**
- * Delete keyboard grab for the given device. 
+ * Delete keyboard grab for the given device.
  */
 void
 DeactivateKeyboardGrab(DeviceIntPtr keybd)
@@ -1752,16 +1752,16 @@ DeactivateKeyboardGrab(DeviceIntPtr keybd)
 }
 
 void
-AllowSome(ClientPtr client, 
-          TimeStamp time, 
-          DeviceIntPtr thisDev, 
-          int newState, 
+AllowSome(ClientPtr client,
+          TimeStamp time,
+          DeviceIntPtr thisDev,
+          int newState,
           Bool core)
 {
     Bool thisGrabbed, otherGrabbed, othersFrozen, thisSynced;
     TimeStamp grabTime;
     DeviceIntPtr dev;
-    GrabInfoPtr devgrabinfo, 
+    GrabInfoPtr devgrabinfo,
                 grabinfo = &thisDev->deviceGrab;
 
     thisGrabbed = grabinfo->grab && SameClient(grabinfo->grab, client);
@@ -1796,7 +1796,7 @@ AllowSome(ClientPtr client,
 	return;
     switch (newState)
     {
-	case THAWED:	 	       /* Async */
+	case THAWED:		       /* Async */
 	    if (thisGrabbed)
 		grabinfo->sync.state = THAWED;
 	    if (thisSynced)
@@ -1818,10 +1818,10 @@ AllowSome(ClientPtr client,
 		for (dev = inputInfo.devices; dev; dev = dev->next)
 		{
                     devgrabinfo = &dev->deviceGrab;
-		    if (devgrabinfo->grab 
+		    if (devgrabinfo->grab
                             && SameClient(devgrabinfo->grab, client))
 			devgrabinfo->sync.state = THAWED;
-		    if (devgrabinfo->sync.other && 
+		    if (devgrabinfo->sync.other &&
                             SameClient(devgrabinfo->sync.other, client))
 			devgrabinfo->sync.other = NullGrab;
 		}
@@ -1834,10 +1834,10 @@ AllowSome(ClientPtr client,
 		for (dev = inputInfo.devices; dev; dev = dev->next)
 		{
                     devgrabinfo = &dev->deviceGrab;
-		    if (devgrabinfo->grab 
+		    if (devgrabinfo->grab
                             && SameClient(devgrabinfo->grab, client))
 			devgrabinfo->sync.state = FREEZE_BOTH_NEXT_EVENT;
-		    if (devgrabinfo->sync.other 
+		    if (devgrabinfo->sync.other
                             && SameClient(devgrabinfo->sync.other, client))
 			devgrabinfo->sync.other = NullGrab;
 		}
@@ -1863,10 +1863,10 @@ AllowSome(ClientPtr client,
 		    if (dev == thisDev)
 			continue;
                     devgrabinfo = (core) ? &dev->deviceGrab : &dev->deviceGrab;
-		    if (devgrabinfo->grab 
+		    if (devgrabinfo->grab
                             && SameClient(devgrabinfo->grab, client))
 			devgrabinfo->sync.state = THAWED;
-		    if (devgrabinfo->sync.other 
+		    if (devgrabinfo->sync.other
                             && SameClient(devgrabinfo->sync.other, client))
 			devgrabinfo->sync.other = NullGrab;
 		}
@@ -1879,8 +1879,8 @@ AllowSome(ClientPtr client,
 /**
  * Server-side protocol handling for AllowEvents request.
  *
- * Release some events from a frozen device. 
- * 
+ * Release some events from a frozen device.
+ *
  * In some cases, the grab the client has is not on the ClientPointer but on
  * some other device (see ProcGrabPointer comments). To cover this case, we
  * need to run through all devices to ensure we don't forget the device we
@@ -1909,7 +1909,7 @@ ProcAllowEvents(ClientPtr client)
             else if (IsKeyboardDevice(grabbed))
                 keybd = grabbed;
 
-	    if (mouse && keybd) 
+	    if (mouse && keybd)
 		break;
         }
     }
@@ -1924,19 +1924,19 @@ ProcAllowEvents(ClientPtr client)
 	case ReplayPointer:
 	    AllowSome(client, time, mouse, NOT_GRABBED, True);
 	    break;
-	case SyncPointer: 
+	case SyncPointer:
 	    AllowSome(client, time, mouse, FREEZE_NEXT_EVENT, True);
 	    break;
-	case AsyncPointer: 
+	case AsyncPointer:
 	    AllowSome(client, time, mouse, THAWED, True);
 	    break;
-	case ReplayKeyboard: 
+	case ReplayKeyboard:
 	    AllowSome(client, time, keybd, NOT_GRABBED, True);
 	    break;
-	case SyncKeyboard: 
+	case SyncKeyboard:
 	    AllowSome(client, time, keybd, FREEZE_NEXT_EVENT, True);
 	    break;
-	case AsyncKeyboard: 
+	case AsyncKeyboard:
 	    AllowSome(client, time, keybd, THAWED, True);
 	    break;
 	case SyncBoth:
@@ -1945,7 +1945,7 @@ ProcAllowEvents(ClientPtr client)
 	case AsyncBoth:
 	    AllowSome(client, time, keybd, THAWED_BOTH, True);
 	    break;
-	default: 
+	default:
 	    client->errorValue = stuff->mode;
 	    return BadValue;
     }
@@ -1965,21 +1965,21 @@ ReleaseActiveGrabs(ClientPtr client)
      * releasing active grabs.
      */
     do {
-    	done = TRUE;
-    	for (dev = inputInfo.devices; dev; dev = dev->next)
-    	{
+	done = TRUE;
+	for (dev = inputInfo.devices; dev; dev = dev->next)
+	{
 	    if (dev->deviceGrab.grab && SameClient(dev->deviceGrab.grab, client))
 	    {
-	    	(*dev->deviceGrab.DeactivateGrab)(dev);
-	    	done = FALSE;
+		(*dev->deviceGrab.DeactivateGrab)(dev);
+		done = FALSE;
 	    }
 
 	    if (dev->deviceGrab.grab && SameClient(dev->deviceGrab.grab, client))
 	    {
-	    	(*dev->deviceGrab.DeactivateGrab)(dev);
-	    	done = FALSE;
+		(*dev->deviceGrab.DeactivateGrab)(dev);
+		done = FALSE;
 	    }
-    	}
+	}
     } while (!done);
 }
 
@@ -1995,24 +1995,24 @@ ReleaseActiveGrabs(ClientPtr client)
  *
  * TryClientEvents() is the last station before actually writing the events to
  * the socket. Anything that is not filtered here, will get delivered to the
- * client. 
- * An event is only delivered if 
+ * client.
+ * An event is only delivered if
  *   - mask and filter match up.
  *   - no other client has a grab on the device that caused the event.
- * 
+ *
  *
  * @param client The target client to deliver to.
  * @param pEvents The events to be delivered.
  * @param count Number of elements in pEvents.
  * @param mask Event mask as set by the window.
  * @param filter Mask based on event type.
- * @param grab Possible grab on the device that caused the event. 
+ * @param grab Possible grab on the device that caused the event.
  *
  * @return 1 if event was delivered, 0 if not or -1 if grab was not set by the
  * client.
  */
 _X_EXPORT int
-TryClientEvents (ClientPtr client, xEvent *pEvents, int count, Mask mask, 
+TryClientEvents (ClientPtr client, xEvent *pEvents, int count, Mask mask,
                  Mask filter, GrabPtr grab)
 {
     int i;
@@ -2093,19 +2093,19 @@ TryClientEvents (ClientPtr client, xEvent *pEvents, int count, Mask mask,
  * Deliver events to a window. At this point, we do not yet know if the event
  * actually needs to be delivered. May activate a grab if the event is a
  * button press.
- * 
+ *
  * Core events are always delivered to the window owner. If the filter is
  * something other than CantBeFiltered, the event is also delivered to other
  * clients with the matching mask on the window.
  *
  * More than one event may be delivered at a time. This is the case with
  * DeviceMotionNotifies which may be followed by DeviceValuator events.
- * 
+ *
  * @param pWin The window that would get the event.
  * @param pEvents The events to be delivered.
  * @param count Number of elements in pEvents.
  * @param filter Mask based on event type.
- * @param grab Possible grab on the device that caused the event. 
+ * @param grab Possible grab on the device that caused the event.
  * @param mskidx Mask index, depending on device that caused event.
  *
  * @return Number of events delivered to various clients.
@@ -2121,7 +2121,7 @@ DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent
     Mask deliveryMask = 0; /* If a grab occurs due to a button press, then
 		              this mask is the mask of the grab. */
     int type = pEvents->u.u.type;
-    
+
     /* if a  is denied, we return 0. This could cause the caller to
      * traverse the parent. May be bad! (whot) */
     if (!ACDeviceAllowed(pWin, pDev, pEvents))
@@ -2130,15 +2130,15 @@ DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent
     }
 
     /* CantBeFiltered means only window owner gets the event */
-    if ((filter == CantBeFiltered) || 
+    if ((filter == CantBeFiltered) ||
             (!(type & EXTENSION_EVENT_BASE) && type != GenericEvent))
     {
 	/* if nobody ever wants to see this event, skip some work */
 	if (filter != CantBeFiltered &&
 	    !((wOtherEventMasks(pWin)|pWin->eventMask) & filter))
 	    return 0;
-        
-        if (!(type & EXTENSION_EVENT_BASE) && 
+
+        if (!(type & EXTENSION_EVENT_BASE) &&
             IsInterferingGrab(wClient(pWin), pDev, pEvents))
                 return 0;
 
@@ -2177,11 +2177,11 @@ DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent
             {
                 if (pClient->eventMask[GEEXTIDX(pEvents)] & filter)
                 {
-                    if (TryClientEvents(pClient->client, pEvents, count, 
+                    if (TryClientEvents(pClient->client, pEvents, count,
                             pClient->eventMask[GEEXTIDX(pEvents)], filter, grab) > 0)
                     {
                         deliveries++;
-                    } else 
+                    } else
                         nondeliveries--;
                 }
             }
@@ -2248,7 +2248,7 @@ DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent
         inputMasks = wOtherInputMasks(pWin);
         tempGrab.deviceMask = (inputMasks) ? inputMasks->inputEvents[pDev->id]: 0;
 
-        /* get the XGE event mask. 
+        /* get the XGE event mask.
          * FIXME: needs to be freed somewhere too.
          */
         tempGrab.genericMasks = NULL;
@@ -2294,11 +2294,11 @@ DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent
 */
 
 #ifdef PANORAMIX
-static int 
+static int
 XineramaTryClientEventsResult(
     ClientPtr client,
     GrabPtr grab,
-    Mask mask, 
+    Mask mask,
     Mask filter
 ){
     if ((client) && (client != serverClient) && (!client->clientGone) &&
@@ -2321,7 +2321,7 @@ XineramaTryClientEventsResult(
  * @param dontClient Don't deliver to the dontClient.
  */
 int
-MaybeDeliverEventsToClient(WindowPtr pWin, xEvent *pEvents, 
+MaybeDeliverEventsToClient(WindowPtr pWin, xEvent *pEvents,
                            int count, Mask filter, ClientPtr dontClient)
 {
     OtherClients *other;
@@ -2332,7 +2332,7 @@ MaybeDeliverEventsToClient(WindowPtr pWin, xEvent *pEvents,
         if (wClient(pWin) == dontClient)
 	    return 0;
 #ifdef PANORAMIX
-	if(!noPanoramiXExtension && pWin->drawable.pScreen->myNum) 
+	if(!noPanoramiXExtension && pWin->drawable.pScreen->myNum)
 	    return XineramaTryClientEventsResult(
 			wClient(pWin), NullGrab, pWin->eventMask, filter);
 #endif
@@ -2346,7 +2346,7 @@ MaybeDeliverEventsToClient(WindowPtr pWin, xEvent *pEvents,
             if (SameClient(other, dontClient))
 		return 0;
 #ifdef PANORAMIX
-	    if(!noPanoramiXExtension && pWin->drawable.pScreen->myNum) 
+	    if(!noPanoramiXExtension && pWin->drawable.pScreen->myNum)
 	      return XineramaTryClientEventsResult(
 			rClient(other), NullGrab, other->mask, filter);
 #endif
@@ -2381,29 +2381,29 @@ FixUpEventFromWindow(
     if (calcChild)
     {
         WindowPtr w= pSprite->spriteTrace[pSprite->spriteTraceGood-1];
-	/* If the search ends up past the root should the child field be 
-	 	set to none or should the value in the argument be passed 
-		through. It probably doesn't matter since everyone calls 
+	/* If the search ends up past the root should the child field be
+		set to none or should the value in the argument be passed
+		through. It probably doesn't matter since everyone calls
 		this function with child == None anyway. */
 
-        while (w) 
+        while (w)
         {
             /* If the source window is same as event window, child should be
 		none.  Don't bother going all all the way back to the root. */
 
- 	    if (w == pWin)
-	    { 
-   		child = None;
- 		break;
+	    if (w == pWin)
+	    {
+		child = None;
+		break;
 	    }
-	    
+
 	    if (w->parent == pWin)
 	    {
 		child = w->drawable.id;
 		break;
             }
- 	    w = w->parent;
-        } 	    
+	    w = w->parent;
+        }
     }
     XE_KBPTR.root = RootWindow(pDev)->drawable.id;
     XE_KBPTR.event = pWin->drawable.id;
@@ -2427,7 +2427,7 @@ FixUpEventFromWindow(
 
 /**
  * Deliver events caused by input devices. Called for both core input events
- * and XI 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
@@ -2446,7 +2446,7 @@ FixUpEventFromWindow(
  * @see DeliverFocusedEvent
  */
 int
-DeliverDeviceEvents(WindowPtr pWin, xEvent *xE, GrabPtr grab, 
+DeliverDeviceEvents(WindowPtr pWin, xEvent *xE, GrabPtr grab,
                     WindowPtr stopAt, DeviceIntPtr dev, int count)
 {
     Window child = None;
@@ -2503,7 +2503,7 @@ DeliverDeviceEvents(WindowPtr pWin, xEvent *xE, GrabPtr grab,
                 {
                     if (GEExtensions[GEEXTIDX(xE)].evfill)
                         GEExtensions[GEEXTIDX(xE)].evfill(ge, dev, pWin, grab);
-                    deliveries = DeliverEventsToWindow(dev, pWin, xE, count, 
+                    deliveries = DeliverEventsToWindow(dev, pWin, xE, count,
                                                         filter, grab, 0);
                     if (deliveries > 0)
                         return deliveries;
@@ -2511,7 +2511,7 @@ DeliverDeviceEvents(WindowPtr pWin, xEvent *xE, GrabPtr grab,
 
                 pWin = pWin->parent;
             }
-        } 
+        }
         else
         {
             /* core protocol events */
@@ -2542,7 +2542,7 @@ DeliverDeviceEvents(WindowPtr pWin, xEvent *xE, GrabPtr grab,
 /**
  * Deliver event to a window and it's immediate parent. Used for most window
  * events (CreateNotify, ConfigureNotify, etc.). Not useful for events that
- * propagate up the tree or extension events 
+ * propagate up the tree or extension events
  *
  * In case of a ReparentNotify event, the event will be delivered to the
  * otherParent as well.
@@ -2553,7 +2553,7 @@ DeliverDeviceEvents(WindowPtr pWin, xEvent *xE, GrabPtr grab,
  * @param otherParent Used for ReparentNotify events.
  */
 _X_EXPORT int
-DeliverEvents(WindowPtr pWin, xEvent *xE, int count, 
+DeliverEvents(WindowPtr pWin, xEvent *xE, int count,
               WindowPtr otherParent)
 {
     Mask filter;
@@ -2591,7 +2591,7 @@ DeliverEvents(WindowPtr pWin, xEvent *xE, int count,
 }
 
 
-static Bool 
+static Bool
 PointInBorderSize(WindowPtr pWin, int x, int y)
 {
     BoxRec box;
@@ -2601,15 +2601,15 @@ PointInBorderSize(WindowPtr pWin, int x, int y)
 	return TRUE;
 
 #ifdef PANORAMIX
-    if(!noPanoramiXExtension && 
+    if(!noPanoramiXExtension &&
             XineramaSetWindowPntrs(inputInfo.pointer, pWin)) {
 	int i;
 
 	for(i = 1; i < PanoramiXNumScreens; i++) {
-	   if(POINT_IN_REGION(pSprite->screen, 
-			&pSprite->windows[i]->borderSize, 
-			x + panoramiXdataPtr[0].x - panoramiXdataPtr[i].x, 
-			y + panoramiXdataPtr[0].y - panoramiXdataPtr[i].y, 
+	   if(POINT_IN_REGION(pSprite->screen,
+			&pSprite->windows[i]->borderSize,
+			x + panoramiXdataPtr[0].x - panoramiXdataPtr[i].x,
+			y + panoramiXdataPtr[0].y - panoramiXdataPtr[i].y,
 			&box))
 		return TRUE;
 	}
@@ -2629,7 +2629,7 @@ PointInBorderSize(WindowPtr pWin, int x, int y)
  *
  * @returns the window at the given coordinates.
  */
-static WindowPtr 
+static WindowPtr
 XYToWindow(DeviceIntPtr pDev, int x, int y)
 {
     WindowPtr  pWin;
@@ -2689,7 +2689,7 @@ XYToWindow(DeviceIntPtr pDev, int x, int y)
  * CheckMotion() will not do anything and return FALSE if the event is not a
  * pointer event.
  *
- * @return TRUE if the sprite has moved or FALSE otherwise. 
+ * @return TRUE if the sprite has moved or FALSE otherwise.
  */
 Bool
 CheckMotion(xEvent *xE, DeviceIntPtr pDev)
@@ -2697,7 +2697,7 @@ CheckMotion(xEvent *xE, DeviceIntPtr pDev)
     INT16     *rootX, *rootY;
     WindowPtr prevSpriteWin;
     SpritePtr pSprite = pDev->spriteInfo->sprite;
-        
+
     prevSpriteWin = pSprite->win;
 
 #ifdef PANORAMIX
@@ -2785,7 +2785,7 @@ CheckMotion(xEvent *xE, DeviceIntPtr pDev)
 	    if (!xE)
 		UpdateCurrentTimeIf();
             DoEnterLeaveEvents(pDev, prevSpriteWin, pSprite->win,
-                               NotifyNormal); 
+                               NotifyNormal);
         }
 	PostNewCursor(pDev);
         return FALSE;
@@ -2835,7 +2835,7 @@ void ReinitializeRootWindow(WindowPtr win, int xoff, int yoff)
             pSprite->hotPhys.x    -= xoff;
             pSprite->hotPhys.y    -= yoff;
 
-            pSprite->hotLimits.x1 -= xoff; 
+            pSprite->hotLimits.x1 -= xoff;
             pSprite->hotLimits.y1 -= yoff;
             pSprite->hotLimits.x2 -= xoff;
             pSprite->hotLimits.y2 -= yoff;
@@ -2847,7 +2847,7 @@ void ReinitializeRootWindow(WindowPtr win, int xoff, int yoff)
 
             /* FIXME: if we call ConfineCursorToWindow, must we do anything else? */
             if ((grab = pDev->deviceGrab.grab) && grab->confineTo) {
-                if (grab->confineTo->drawable.pScreen 
+                if (grab->confineTo->drawable.pScreen
                         != pSprite->hotPhys.pScreen)
                     pSprite->hotPhys.x = pSprite->hotPhys.y = 0;
                 ConfineCursorToWindow(pDev, grab->confineTo, TRUE, TRUE);
@@ -2889,13 +2889,13 @@ DefineInitialRootWindow(WindowPtr win)
  *
  * @param pDev The device to initialize.
  * @param pWin The window where to generate the sprite in.
- * 
+ *
  */
-void 
+void
 InitializeSprite(DeviceIntPtr pDev, WindowPtr pWin)
 {
     SpritePtr pSprite;
-    ScreenPtr pScreen; 
+    ScreenPtr pScreen;
 
     if (!pDev->spriteInfo->sprite)
     {
@@ -2941,7 +2941,7 @@ InitializeSprite(DeviceIntPtr pDev, WindowPtr pWin)
     {
         pSprite->current = wCursor(pWin);
         pSprite->current->refcnt++;
- 	pSprite->spriteTrace = (WindowPtr *)xcalloc(1, 32*sizeof(WindowPtr));
+	pSprite->spriteTrace = (WindowPtr *)xcalloc(1, 32*sizeof(WindowPtr));
 	if (!pSprite->spriteTrace)
 	    FatalError("Failed to allocate spriteTrace");
 	pSprite->spriteTraceSize = 32;
@@ -2971,7 +2971,7 @@ InitializeSprite(DeviceIntPtr pDev, WindowPtr pWin)
                                      &pSprite->physLimits);
         (*pScreen->SetCursorPosition) (pDev, pScreen, pSprite->hot.x,
                                        pSprite->hot.y,
-                                       FALSE); 
+                                       FALSE);
         (*pScreen->DisplayCursor) (pDev, pScreen, pSprite->current);
     }
 #ifdef PANORAMIX
@@ -3082,33 +3082,33 @@ NewCurrentScreen(DeviceIntPtr pDev, ScreenPtr newScreen, int x, int y)
     pSprite->hotPhys.y = y;
 #ifdef PANORAMIX
     if(!noPanoramiXExtension) {
-	pSprite->hotPhys.x += panoramiXdataPtr[newScreen->myNum].x - 
+	pSprite->hotPhys.x += panoramiXdataPtr[newScreen->myNum].x -
 			    panoramiXdataPtr[0].x;
-	pSprite->hotPhys.y += panoramiXdataPtr[newScreen->myNum].y - 
+	pSprite->hotPhys.y += panoramiXdataPtr[newScreen->myNum].y -
 			    panoramiXdataPtr[0].y;
 	if (newScreen != pSprite->screen) {
 	    pSprite->screen = newScreen;
 	    /* Make sure we tell the DDX to update its copy of the screen */
 	    if(pSprite->confineWin)
-		XineramaConfineCursorToWindow(pDev, 
+		XineramaConfineCursorToWindow(pDev,
                         pSprite->confineWin, TRUE);
 	    else
 		XineramaConfineCursorToWindow(pDev, WindowTable[0], TRUE);
-	    /* if the pointer wasn't confined, the DDX won't get 
+	    /* if the pointer wasn't confined, the DDX won't get
 	       told of the pointer warp so we reposition it here */
 	    if(!syncEvents.playingEvents)
 		(*pSprite->screen->SetCursorPosition)(
                                                       pDev,
                                                       pSprite->screen,
-		    pSprite->hotPhys.x + panoramiXdataPtr[0].x - 
+		    pSprite->hotPhys.x + panoramiXdataPtr[0].x -
 			panoramiXdataPtr[pSprite->screen->myNum].x,
-		    pSprite->hotPhys.y + panoramiXdataPtr[0].y - 
+		    pSprite->hotPhys.y + panoramiXdataPtr[0].y -
 			panoramiXdataPtr[pSprite->screen->myNum].y, FALSE);
 	}
-    } else 
+    } else
 #endif
     if (newScreen != pSprite->hotPhys.pScreen)
-	ConfineCursorToWindow(pDev, WindowTable[newScreen->myNum], 
+	ConfineCursorToWindow(pDev, WindowTable[newScreen->myNum],
                 TRUE, FALSE);
 }
 
@@ -3129,11 +3129,11 @@ XineramaPointInWindowIsVisible(
 
     if (POINT_IN_REGION(pScreen, &pWin->borderClip, x, y, &box))
         return TRUE;
-    
+
     if(!XineramaSetWindowPntrs(inputInfo.pointer, pWin)) return FALSE;
 
-    xoff = x + panoramiXdataPtr[0].x;  
-    yoff = y + panoramiXdataPtr[0].y;  
+    xoff = x + panoramiXdataPtr[0].x;
+    yoff = y + panoramiXdataPtr[0].y;
 
     for(i = 1; i < PanoramiXNumScreens; i++) {
 	pWin = inputInfo.pointer->spriteInfo->sprite->windows[i];
@@ -3145,7 +3145,7 @@ XineramaPointInWindowIsVisible(
 	   && (!wInputShape(pWin) ||
 	       POINT_IN_REGION(pWin->drawable.pScreen,
 			       wInputShape(pWin),
-			       x - pWin->drawable.x, 
+			       x - pWin->drawable.x,
 			       y - pWin->drawable.y, &box)))
             return TRUE;
 
@@ -3175,9 +3175,9 @@ XineramaWarpPointer(ClientPtr client)
     if (stuff->srcWid != None)
     {
 	int     winX, winY;
- 	XID 	winID = stuff->srcWid;
+	XID	winID = stuff->srcWid;
         WindowPtr source;
-	
+
 	rc = dixLookupWindow(&source, winID, client, DixReadAccess);
 	if (rc != Success)
 	    return rc;
@@ -3204,7 +3204,7 @@ XineramaWarpPointer(ClientPtr client)
 	    x -= panoramiXdataPtr[0].x;
 	    y -= panoramiXdataPtr[0].y;
 	}
-    } 
+    }
 
     x += stuff->dstX;
     y += stuff->dstY;
@@ -3260,9 +3260,9 @@ ProcWarpPointer(ClientPtr client)
     if (stuff->srcWid != None)
     {
 	int     winX, winY;
- 	XID 	winID = stuff->srcWid;
+	XID	winID = stuff->srcWid;
         WindowPtr source;
-	
+
 	rc = dixLookupWindow(&source, winID, client, DixReadAccess);
 	if (rc != Success)
 	    return rc;
@@ -3279,12 +3279,12 @@ ProcWarpPointer(ClientPtr client)
 	    !PointInWindowIsVisible(source, x, y))
 	    return Success;
     }
-    if (dest) 
+    if (dest)
     {
 	x = dest->drawable.x;
 	y = dest->drawable.y;
 	newScreen = dest->drawable.pScreen;
-    } else 
+    } else
 	newScreen = pSprite->hotPhys.pScreen;
 
     x += stuff->dstX;
@@ -3314,7 +3314,7 @@ ProcWarpPointer(ClientPtr client)
 	    ConfineToShape(PickPointer(client), pSprite->hotShape, &x, &y);
 #endif
         (*newScreen->SetCursorPosition)(PickPointer(client), newScreen, x, y,
-                                        TRUE); 
+                                        TRUE);
     }
     else if (!PointerConfinedToScreen(PickPointer(client)))
     {
@@ -3323,7 +3323,7 @@ ProcWarpPointer(ClientPtr client)
     return Success;
 }
 
-static Bool 
+static Bool
 BorderSizeNotEmpty(DeviceIntPtr pDev, WindowPtr pWin)
 {
      if(REGION_NOTEMPTY(pDev->spriteInfo->sprite->hotPhys.pScreen, &pWin->borderSize))
@@ -3334,7 +3334,7 @@ BorderSizeNotEmpty(DeviceIntPtr pDev, WindowPtr pWin)
 	int i;
 
 	for(i = 1; i < PanoramiXNumScreens; i++) {
-	    if(REGION_NOTEMPTY(pDev->spriteInfo->sprite->screen, 
+	    if(REGION_NOTEMPTY(pDev->spriteInfo->sprite->screen,
                         &pDev->spriteInfo->sprite->windows[i]->borderSize))
 		return TRUE;
 	}
@@ -3343,11 +3343,11 @@ BorderSizeNotEmpty(DeviceIntPtr pDev, WindowPtr pWin)
      return FALSE;
 }
 
-/** 
+/**
  * "CheckPassiveGrabsOnWindow" checks to see if the event passed in causes a
- * passive grab set on the window to be activated. 
+ * passive grab set on the window to be activated.
  * If a passive grab is activated, the event will be delivered to the client.
- * 
+ *
  * @param pWin The window that may be subject to a passive grab.
  * @param device Device that caused the event.
  * @param xE List of events (multiple ones for DeviceMotionNotify)
@@ -3419,7 +3419,7 @@ CheckPassiveGrabsOnWindow(
             /* ignore the device for core events when comparing grabs */
 	if (GrabMatchesSecond(&tempGrab, grab, (xE->u.u.type < LASTEvent)) &&
 	    (!grab->confineTo ||
-	     (grab->confineTo->realized && 
+	     (grab->confineTo->realized &&
 				BorderSizeNotEmpty(device, grab->confineTo))))
 	{
 	    if (!XaceHook(XACE_DEVICE_ACCESS, wClient(pWin), device, FALSE))
@@ -3440,10 +3440,10 @@ CheckPassiveGrabsOnWindow(
                modifierDevice explicitly, we don't override this choice.
                This essentially requires a client to re-create all
                passiveGrabs when the pairing changes... oh well.
-             */ 
+             */
             if (xE->u.u.type < LASTEvent)
             {
-                grab->device = device; 
+                grab->device = device;
                 grab->modifierDevice = GetPairedDevice(device);
             }
 
@@ -3477,7 +3477,7 @@ CheckPassiveGrabsOnWindow(
 
 
 	    (*grabinfo->ActivateGrab)(device, grab, currentTime, TRUE);
- 
+
 	    FixUpEventFromWindow(device, xE, grab->window, None, TRUE);
 
 	    (void) TryClientEvents(rClient(grab), xE, count,
@@ -3497,8 +3497,8 @@ CheckPassiveGrabsOnWindow(
 		grabinfo->sync.evcount = count;
 		for (dxE = grabinfo->sync.event; --count >= 0; dxE++, xE++)
 		    *dxE = *xE;
-	    	grabinfo->sync.state = FROZEN_WITH_EVENT;
-            }	
+		grabinfo->sync.state = FROZEN_WITH_EVENT;
+            }
 	    return TRUE;
 	}
     }
@@ -3507,14 +3507,14 @@ CheckPassiveGrabsOnWindow(
 
 /**
  * CheckDeviceGrabs handles both keyboard and pointer events that may cause
- * a passive grab to be activated.  
+ * a passive grab to be activated.
  *
  * If the event is a keyboard event, the ancestors of the focus window are
  * traced down and tried to see if they have any passive grabs to be
  * activated.  If the focus window itself is reached and it's descendants
  * contain the pointer, the ancestors of the window that the pointer is in
  * are then traced down starting at the focus window, otherwise no grabs are
- * activated.  
+ * activated.
  * If the event is a pointer event, the ancestors of the window that the
  * pointer is in are traced down starting at the root until CheckPassiveGrabs
  * causes a passive grab to activate or all the windows are
@@ -3529,7 +3529,7 @@ CheckPassiveGrabsOnWindow(
 */
 
 Bool
-CheckDeviceGrabs(DeviceIntPtr device, xEvent *xE, 
+CheckDeviceGrabs(DeviceIntPtr device, xEvent *xE,
                  int checkFirst, int count)
 {
     int i;
@@ -3554,7 +3554,7 @@ CheckDeviceGrabs(DeviceIntPtr device, xEvent *xE,
 		CheckPassiveGrabsOnWindow(pWin, device, xE, count))
 		return TRUE;
 	}
-  
+
 	if ((focus->win == NoneWin) ||
 	    (i >= device->spriteInfo->sprite->spriteTraceGood) ||
 	    ((i > checkFirst) &&
@@ -3620,7 +3620,7 @@ DeliverFocusedEvent(DeviceIntPtr keybd, xEvent *xE, WindowPtr window, int count)
  * @param deactivateGrab True if the device's grab should be deactivated.
  */
 void
-DeliverGrabbedEvent(xEvent *xE, DeviceIntPtr thisDev, 
+DeliverGrabbedEvent(xEvent *xE, DeviceIntPtr thisDev,
                     Bool deactivateGrab, int count)
 {
     GrabPtr grab;
@@ -3646,9 +3646,9 @@ DeliverGrabbedEvent(xEvent *xE, DeviceIntPtr thisDev,
 	else
 	    focus = PointerRootWin;
 	if (focus == PointerRootWin)
-	    deliveries = DeliverDeviceEvents(pSprite->win, xE, grab, 
+	    deliveries = DeliverDeviceEvents(pSprite->win, xE, grab,
                                              NullWindow, thisDev, count);
-	else if (focus && (focus == pSprite->win || 
+	else if (focus && (focus == pSprite->win ||
                     IsParent(focus, pSprite->win)))
 	    deliveries = DeliverDeviceEvents(pSprite->win, xE, grab, focus,
 					     thisDev, count);
@@ -3671,15 +3671,15 @@ DeliverGrabbedEvent(xEvent *xE, DeviceIntPtr thisDev,
 
                 if (GEEventFill(xE))
                     GEEventFill(xE)(ge, thisDev, grab->window, grab);
-                deliveries = TryClientEvents(rClient(grab), xE, count, 
+                deliveries = TryClientEvents(rClient(grab), xE, count,
                         gemask->eventMask[GEEXTIDX(ge)],
                         generic_filters[GEEXTIDX(ge)][ge->evtype],
                         grab);
-            } else 
+            } else
             {
                 Mask mask = grab->eventMask;
                 if (grabinfo->fromPassiveGrab  &&
-                        grabinfo->implicitGrab && 
+                        grabinfo->implicitGrab &&
                         (xE->u.u.type & EXTENSION_EVENT_BASE))
                     mask = grab->deviceMask;
 
@@ -3739,7 +3739,7 @@ DeliverGrabbedEvent(xEvent *xE, DeviceIntPtr thisDev,
 }
 
 /**
- * Main keyboard event processing function for core keyboard events. 
+ * Main keyboard event processing function for core keyboard events.
  * Updates the events fields from the current pointer state and delivers the
  * event.
  *
@@ -3852,11 +3852,11 @@ drawable.id:0;
 
     switch (xE->u.u.type)
     {
-	case KeyPress: 
+	case KeyPress:
             /* We MUST NOT change the device itself here.  All device state
              * changes must be performed in ProcessOtherEvents. We're dealing
              * with the same device struct, so if we change it in POE and
-             * here, we've just screwed up the state by setting it twice. 
+             * here, we've just screwed up the state by setting it twice.
              *
              * Devices may not send core events but always send XI events, so
              * the state must be changed in POE, not here.
@@ -3867,14 +3867,14 @@ drawable.id:0;
 		return;
 	    }
 	    break;
-	case KeyRelease: 
+	case KeyRelease:
 	    if (!(*kptr & bit)) /* guard against duplicates */
 		return;
             /* No device state changes, see comment for KeyPress */
 	    if (grabinfo->fromPassiveGrab && (key == grabinfo->activatingKey))
 		deactivateGrab = TRUE;
 	    break;
-	default: 
+	default:
 	    FatalError("Impossible keyboard event");
     }
     if (grab)
@@ -3889,7 +3889,7 @@ drawable.id:0;
 
 #ifdef XKB
 /* This function is used to set the key pressed or key released state -
-   this is only used when the pressing of keys does not cause 
+   this is only used when the pressing of keys does not cause
    the device's processInputProc to be called, as in for example Mouse Keys.
 */
 void
@@ -3919,8 +3919,8 @@ FixKeyState (xEvent *xE, DeviceIntPtr keybd)
 }
 #endif
 
-/** 
- * Main pointer event processing function for core pointer events. 
+/**
+ * Main pointer event processing function for core pointer events.
  * For motion events: update the sprite.
  * For all other events: Update the event fields based on the current sprite
  * state.
@@ -4003,7 +4003,7 @@ ProcessPointerEvent (xEvent *xE, DeviceIntPtr mouse, int count)
 	bit = 1 << (key & 7);
 	switch (xE->u.u.type)
 	{
-	case ButtonPress: 
+	case ButtonPress:
             /*
              * We rely on the fact that ButtonMotionMask is the same as
              * DeviceButtonMotionMask, so setting the motionMask
@@ -4016,14 +4016,14 @@ ProcessPointerEvent (xEvent *xE, DeviceIntPtr mouse, int count)
 		if (CheckDeviceGrabs(mouse, xE, 0, count))
 		    return;
 	    break;
-	case ButtonRelease: 
+	case ButtonRelease:
 	    if (xE->u.u.detail == 0)
 		return;
 	    filters[MotionNotify] = Motion_Filter(butc);
 	    if (!butc->state && mouse->deviceGrab.fromPassiveGrab)
 		deactivateGrab = TRUE;
 	    break;
-	default: 
+	default:
 	    FatalError("bogus pointer event from ddx");
 	}
     }
@@ -4184,7 +4184,7 @@ EventSelectForWindow(WindowPtr pWin, ClientPtr client, Mask mask)
 	if (!AddResource(others->resource, RT_OTHERCLIENT, (pointer)pWin))
 	    return BadAlloc;
     }
-maskSet: 
+maskSet:
     if ((inputInfo.pointer->valuator->motionHintWindow == pWin) &&
 	(mask & PointerMotionHintMask) &&
 	!(check & PointerMotionHintMask) &&
@@ -4195,7 +4195,7 @@ maskSet:
 }
 
 int
-EventSuppressForWindow(WindowPtr pWin, ClientPtr client, 
+EventSuppressForWindow(WindowPtr pWin, ClientPtr client,
                        Mask mask, Bool *checkOptional)
 {
     int i, free;
@@ -4253,7 +4253,7 @@ EventSuppressForWindow(WindowPtr pWin, ClientPtr client,
 /**
  * @return The window that is the first ancestor of both a and b.
  */
-static WindowPtr 
+static WindowPtr
 CommonAncestor(
     WindowPtr a,
     WindowPtr b)
@@ -4264,7 +4264,7 @@ CommonAncestor(
 }
 
 /**
- * Assembles an EnterNotify or LeaveNotify and sends it event to the client. 
+ * Assembles an EnterNotify or LeaveNotify and sends it event to the client.
  * Uses the paired keyboard to get some additional information.
  */
 static void
@@ -4283,7 +4283,7 @@ EnterLeaveEvent(
     GrabPtr	        devgrab = mouse->deviceGrab.grab;
     Mask		mask;
     int*                inWindow; /* no of sprites inside pWin */
-    Bool                sendevent = FALSE;        
+    Bool                sendevent = FALSE;
 
     deviceEnterNotify   *devEnterLeave;
     int                 mskidx;
@@ -4320,7 +4320,7 @@ EnterLeaveEvent(
     if (!noXkbExtension) {
         event.u.enterLeave.state = mouse->button->state & 0x1f00;
         if (keybd)
-            event.u.enterLeave.state |= 
+            event.u.enterLeave.state |=
                 XkbGrabStateFromRec(&keybd->key->xkbInfo->state);
     } else
 #endif
@@ -4339,29 +4339,29 @@ EnterLeaveEvent(
 
     /*
      * Sending multiple core enter/leave events to the same window confuse the
-     * client.  
+     * client.
      * We can send multiple events that have detail NotifyVirtual or
      * NotifyNonlinearVirtual however. For most clients anyway.
      *
      * For standard events (NotifyAncestor, NotifyInferior, NotifyNonlinear)
      * we only send an enter event for the first pointer to enter. A leave
-     * event is sent for the last pointer to leave. 
+     * event is sent for the last pointer to leave.
      *
      * For events with Virtual detail, we send them only to a window that does
      * not have a pointer inside.
      *
-     * For a window tree in the form of 
+     * For a window tree in the form of
      *
-     * A -> Bp -> C -> D 
+     * A -> Bp -> C -> D
      *  \               (where B and E have pointers)
-     *    -> Ep         
-     *    
+     *    -> Ep
+     *
      * If the pointer moves from E into D, a LeaveNotify is sent to E, an
      * EnterNotify is sent to D, an EnterNotify with detail
      * NotifyNonlinearVirtual to C and nothing to B.
      */
 
-    if (event.u.u.detail != NotifyVirtual && 
+    if (event.u.u.detail != NotifyVirtual &&
             event.u.u.detail != NotifyNonlinearVirtual)
     {
         if (((*inWindow) == (LeaveNotify - type)))
@@ -4382,7 +4382,7 @@ EnterLeaveEvent(
                                         NullGrab, 0);
     }
 
-    /* we don't have enough bytes, so we squash flags and mode into 
+    /* we don't have enough bytes, so we squash flags and mode into
        one byte, and use the last byte for the deviceid. */
     devEnterLeave = (deviceEnterNotify*)&event;
     devEnterLeave->type = (type == EnterNotify) ? DeviceEnterNotify :
@@ -4393,15 +4393,15 @@ EnterLeaveEvent(
     devEnterLeave->deviceid = mouse->id;
     mskidx = mouse->id;
     inputMasks = wOtherInputMasks(pWin);
-    if (inputMasks && 
+    if (inputMasks &&
        (filters[devEnterLeave->type] & inputMasks->deliverableEvents[mskidx]))
     {
         if (devgrab)
             (void)TryClientEvents(rClient(devgrab), (xEvent*)devEnterLeave, 1,
                                 mask, filters[devEnterLeave->type], devgrab);
 	else
-	    (void)DeliverEventsToWindow(mouse, pWin, (xEvent*)devEnterLeave, 
-                                        1, filters[devEnterLeave->type], 
+	    (void)DeliverEventsToWindow(mouse, pWin, (xEvent*)devEnterLeave,
+                                        1, filters[devEnterLeave->type],
                                         NullGrab, mouse->id);
     }
 
@@ -4430,11 +4430,11 @@ EnterLeaveEvent(
  * This function recurses.
  */
 static void
-EnterNotifies(DeviceIntPtr pDev, 
-              WindowPtr ancestor, 
-              WindowPtr child, 
-              int mode, 
-              int detail) 
+EnterNotifies(DeviceIntPtr pDev,
+              WindowPtr ancestor,
+              WindowPtr child,
+              int mode,
+              int detail)
 {
     WindowPtr	parent = child->parent;
 
@@ -4450,10 +4450,10 @@ EnterNotifies(DeviceIntPtr pDev,
  * This function recurses.
  */
 static void
-LeaveNotifies(DeviceIntPtr pDev, 
-              WindowPtr child, 
-              WindowPtr ancestor, 
-              int mode, 
+LeaveNotifies(DeviceIntPtr pDev,
+              WindowPtr child,
+              WindowPtr ancestor,
+              int mode,
               int detail)
 {
     WindowPtr  pWin;
@@ -4463,7 +4463,7 @@ LeaveNotifies(DeviceIntPtr pDev,
     for (pWin = child->parent; pWin != ancestor; pWin = pWin->parent)
     {
         EnterLeaveEvent(pDev, LeaveNotify, mode, detail, pWin,
-                        child->drawable.id); 
+                        child->drawable.id);
         child = pWin;
     }
 }
@@ -4478,7 +4478,7 @@ LeaveNotifies(DeviceIntPtr pDev,
         } \
     }
 #define ENTER_LEAVE_SEMAPHORE_UP(win, mode)  \
-        FOCUS_SEMAPHORE_MODIFY(win, enterleave, mode, 1); 
+        FOCUS_SEMAPHORE_MODIFY(win, enterleave, mode, 1);
 
 #define ENTER_LEAVE_SEMAPHORE_DOWN(win, mode) \
         FOCUS_SEMAPHORE_MODIFY(win, enterleave, mode,  -1);
@@ -4487,23 +4487,23 @@ LeaveNotifies(DeviceIntPtr pDev,
 /**
  * Figure out if enter/leave events are necessary and send them to the
  * appropriate windows.
- * 
+ *
  * @param fromWin Window the sprite moved out of.
  * @param toWin Window the sprite moved into.
  */
 static void
-DoEnterLeaveEvents(DeviceIntPtr pDev, 
-        WindowPtr fromWin, 
-        WindowPtr toWin, 
-        int mode) 
+DoEnterLeaveEvents(DeviceIntPtr pDev,
+        WindowPtr fromWin,
+        WindowPtr toWin,
+        int mode)
 {
     if (fromWin == toWin)
 	return;
     if (IsParent(fromWin, toWin))
     {
-        ENTER_LEAVE_SEMAPHORE_DOWN(fromWin, mode); 
+        ENTER_LEAVE_SEMAPHORE_DOWN(fromWin, mode);
         EnterLeaveEvent(pDev, LeaveNotify, mode, NotifyInferior, fromWin,
-                        None); 
+                        None);
         EnterNotifies(pDev, fromWin, toWin, mode,
                       NotifyVirtual);
         ENTER_LEAVE_SEMAPHORE_UP(toWin, mode);
@@ -4511,8 +4511,8 @@ DoEnterLeaveEvents(DeviceIntPtr pDev,
     }
     else if (IsParent(toWin, fromWin))
     {
-        ENTER_LEAVE_SEMAPHORE_DOWN(fromWin, mode); 
-	EnterLeaveEvent(pDev, LeaveNotify, mode, NotifyAncestor, fromWin, 
+        ENTER_LEAVE_SEMAPHORE_DOWN(fromWin, mode);
+	EnterLeaveEvent(pDev, LeaveNotify, mode, NotifyAncestor, fromWin,
                         None);
 	LeaveNotifies(pDev, fromWin, toWin, mode, NotifyVirtual);
         ENTER_LEAVE_SEMAPHORE_UP(toWin, mode);
@@ -4522,14 +4522,14 @@ DoEnterLeaveEvents(DeviceIntPtr pDev,
     { /* neither fromWin nor toWin is descendent of the other */
 	WindowPtr common = CommonAncestor(toWin, fromWin);
 	/* common == NullWindow ==> different screens */
-        ENTER_LEAVE_SEMAPHORE_DOWN(fromWin, mode); 
+        ENTER_LEAVE_SEMAPHORE_DOWN(fromWin, mode);
         EnterLeaveEvent(pDev, LeaveNotify, mode, NotifyNonlinear, fromWin,
-                        None); 
+                        None);
         LeaveNotifies(pDev, fromWin, common, mode, NotifyNonlinearVirtual);
 	EnterNotifies(pDev, common, toWin, mode, NotifyNonlinearVirtual);
         ENTER_LEAVE_SEMAPHORE_UP(toWin, mode);
         EnterLeaveEvent(pDev, EnterNotify, mode, NotifyNonlinear, toWin,
-                        None); 
+                        None);
     }
 }
 
@@ -4547,7 +4547,7 @@ FocusEvent(DeviceIntPtr dev, int type, int mode, int detail, WindowPtr pWin)
      * Same procedure as for Enter/Leave events.
      *
      * Sending multiple core FocusIn/Out events to the same window may confuse
-     * the client.  
+     * the client.
      * We can send multiple events that have detail NotifyVirtual,
      * NotifyNonlinearVirtual, NotifyPointerRoot, NotifyDetailNone or
      * NotifyPointer however.
@@ -4560,12 +4560,12 @@ FocusEvent(DeviceIntPtr dev, int type, int mode, int detail, WindowPtr pWin)
      * For events with Virtual detail, we send them only to a window that does
      * not have a focus from another keyboard.
      *
-     * For a window tree in the form of 
+     * For a window tree in the form of
      *
-     * A -> Bf -> C -> D 
+     * A -> Bf -> C -> D
      *  \               (where B and E have focus)
-     *    -> Ef         
-     *    
+     *    -> Ef
+     *
      * If the focus changes from E into D, a FocusOut is sent to E, a
      * FocusIn is sent to D, a FocusIn with detail
      * NotifyNonlinearVirtual to C and nothing to B.
@@ -4575,8 +4575,8 @@ FocusEvent(DeviceIntPtr dev, int type, int mode, int detail, WindowPtr pWin)
         &((FocusSemaphoresPtr)pWin->devPrivates[FocusPrivatesIndex].ptr)->focusinout;
     if (mode == NotifyGrab || mode == NotifyUngrab)
         sendevent = TRUE;
-    else if (detail != NotifyVirtual && 
-            detail != NotifyNonlinearVirtual && 
+    else if (detail != NotifyVirtual &&
+            detail != NotifyNonlinearVirtual &&
             detail != NotifyPointer &&
             detail != NotifyPointerRoot &&
             detail != NotifyDetailNone)
@@ -4677,15 +4677,15 @@ DoFocusEvents(DeviceIntPtr dev, WindowPtr fromWin, WindowPtr toWin, int mode)
     if ((toWin == NullWindow) || (toWin == PointerRootWin))
     {
 	if ((fromWin == NullWindow) || (fromWin == PointerRootWin))
-   	{
+	{
 	    if (fromWin == PointerRootWin)
                 FocusOutEvents(dev, pSprite->win, RootWindow(dev), mode,
                                NotifyPointer, TRUE);
 	    /* Notify all the roots */
 #ifdef PANORAMIX
- 	    if ( !noPanoramiXExtension )
+	    if ( !noPanoramiXExtension )
 	        FocusEvent(dev, FocusOut, mode, out, WindowTable[0]);
-	    else 
+	    else
 #endif
 	        for (i=0; i<screenInfo.numScreens; i++)
 	            FocusEvent(dev, FocusOut, mode, out, WindowTable[i]);
@@ -4704,7 +4704,7 @@ DoFocusEvents(DeviceIntPtr dev, WindowPtr fromWin, WindowPtr toWin, int mode)
 #ifdef PANORAMIX
 	if ( !noPanoramiXExtension )
 	    FocusEvent(dev, FocusIn, mode, in, WindowTable[0]);
-	else 
+	else
 #endif
 	    for (i=0; i<screenInfo.numScreens; i++)
 	        FocusEvent(dev, FocusIn, mode, in, WindowTable[i]);
@@ -4720,9 +4720,9 @@ DoFocusEvents(DeviceIntPtr dev, WindowPtr fromWin, WindowPtr toWin, int mode)
 		FocusOutEvents(dev, pSprite->win, RootWindow(dev), mode,
 			       NotifyPointer, TRUE);
 #ifdef PANORAMIX
- 	    if ( !noPanoramiXExtension )
+	    if ( !noPanoramiXExtension )
 	        FocusEvent(dev, FocusOut, mode, out, WindowTable[0]);
-	    else 
+	    else
 #endif
 	        for (i=0; i<screenInfo.numScreens; i++)
 	            FocusEvent(dev, FocusOut, mode, out, WindowTable[i]);
@@ -4731,7 +4731,7 @@ DoFocusEvents(DeviceIntPtr dev, WindowPtr fromWin, WindowPtr toWin, int mode)
 				  NotifyNonlinearVirtual, TRUE);
 	    FocusEvent(dev, FocusIn, mode, NotifyNonlinear, toWin);
 	    if (IsParent(toWin, pSprite->win))
-    	       (void)FocusInEvents(dev, toWin, pSprite->win, NullWindow, mode,
+	       (void)FocusInEvents(dev, toWin, pSprite->win, NullWindow, mode,
 				   NotifyPointer, FALSE);
 	}
 	else
@@ -4790,14 +4790,14 @@ DoFocusEvents(DeviceIntPtr dev, WindowPtr fromWin, WindowPtr toWin, int mode)
 /**
  * Set the input focus to the given window. Subsequent keyboard events will be
  * delivered to the given window.
- * 
+ *
  * Usually called from ProcSetInputFocus as result of a client request. If so,
  * the device is the inputInfo.keyboard.
  * If called from ProcXSetInputFocus as result of a client xinput request, the
  * device is set to the device specified by the client.
  *
  * @param client Client that requested input focus change.
- * @param dev Focus device. 
+ * @param dev Focus device.
  * @param focusID The window to obtain the focus. Can be PointerRoot or None.
  * @param revertTo Specifies where the focus reverts to when window becomes
  * unviewable.
@@ -4846,7 +4846,7 @@ SetInputFocus(
 	rc = dixLookupWindow(&focusWin, focusID, client, DixReadAccess);
 	if (rc != Success)
 	    return rc;
- 	/* It is a match error to try to set the input focus to an 
+	/* It is a match error to try to set the input focus to an
 	unviewable window. */
 	if(!focusWin->realized)
 	    return(BadMatch);
@@ -4884,7 +4884,7 @@ SetInputFocus(
 	    Must_have_memory = FALSE; /* XXX */
 	}
 	focus->traceGood = depth;
-        for (pWin = focusWin, depth--; pWin; pWin = pWin->parent, depth--) 
+        for (pWin = focusWin, depth--; pWin; pWin = pWin->parent, depth--)
 	    focus->trace[depth] = pWin;
     }
     return Success;
@@ -4913,7 +4913,7 @@ ProcSetInputFocus(client)
 
 /**
  * Server-side protocol handling for GetInputFocus request.
- * 
+ *
  * Sends the current input focus for the client's keyboard back to the
  * client.
  */
@@ -4993,7 +4993,7 @@ ProcGrabPointer(ClientPtr client)
 	return rc;
     if (stuff->confineTo == None)
 	confineTo = NullWindow;
-    else 
+    else
     {
 	rc = dixLookupWindow(&confineTo, stuff->confineTo, client,
 			     DixReadAccess);
@@ -5037,11 +5037,11 @@ ProcGrabPointer(ClientPtr client)
 	rep.status = AlreadyGrabbed;
     else if ((!pWin->realized) ||
              (confineTo &&
-                !(confineTo->realized 
+                !(confineTo->realized
                     && BorderSizeNotEmpty(device, confineTo))))
 	rep.status = GrabNotViewable;
     else if (device->deviceGrab.sync.frozen &&
-	     device->deviceGrab.sync.other && 
+	     device->deviceGrab.sync.other &&
              !SameClient(device->deviceGrab.sync.other, client))
 	rep.status = GrabFrozen;
     else if ((CompareTimeStamps(time, currentTime) == LATER) ||
@@ -5053,7 +5053,7 @@ ProcGrabPointer(ClientPtr client)
 
 	oldCursor = NullCursor;
 	if (grab)
- 	{
+	{
 	    if (grab->confineTo && !confineTo)
 		ConfineCursorToWindow(device, RootWindow(device), FALSE, FALSE);
 	    oldCursor = grab->cursor;
@@ -5086,11 +5086,11 @@ ProcGrabPointer(ClientPtr client)
  * Server-side protocol handling for ChangeActivePointerGrab request.
  *
  * Changes properties of the grab hold by the client. If the client does not
- * hold an active grab on the device, nothing happens. 
+ * hold an active grab on the device, nothing happens.
  *
  * Works on the client's ClientPointer, but in some cases the client may have
  * a grab on a device that isn't the ClientPointer (see ProcGrabPointer
- * comments). 
+ * comments).
  */
 int
 ProcChangeActivePointerGrab(ClientPtr client)
@@ -5223,25 +5223,25 @@ ProcUngrabPointer(ClientPtr client)
 
 /**
  * Sets a grab on the given device.
- * 
+ *
  * Called from ProcGrabKeyboard to work on the client's keyboard.
  * Called from ProcXGrabDevice to work on the device specified by the client.
- * 
+ *
  * The parameters this_mode and other_mode represent the keyboard_mode and
- * pointer_mode parameters of XGrabKeyboard(). 
+ * pointer_mode parameters of XGrabKeyboard().
  * See man page for details on all the parameters
- * 
+ *
  * @param client Client that owns the grab.
- * @param dev The device to grab. 
+ * @param dev The device to grab.
  * @param this_mode GrabModeSync or GrabModeAsync
  * @param other_mode GrabModeSync or GrabModeAsync
  * @param status Return code to be returned to the caller.
- * 
+ *
  * @returns Success or BadValue.
  */
 int
-GrabDevice(ClientPtr client, DeviceIntPtr dev, 
-           unsigned this_mode, unsigned other_mode, Window grabWindow, 
+GrabDevice(ClientPtr client, DeviceIntPtr dev,
+           unsigned this_mode, unsigned other_mode, Window grabWindow,
            unsigned ownerEvents, Time ctime, Mask mask, CARD8 *status,
            Bool coreGrab)
 {
@@ -5317,7 +5317,7 @@ GrabDevice(ClientPtr client, DeviceIntPtr dev,
  * Grabs are only removed if the other device matches the type of device. If
  * dev is a pointer device, only other pointer grabs are removed. Likewise, if
  * dev is a keyboard device, only keyboard grabs are removed.
- * 
+ *
  * If dev doesn't have a grab, do nothing and go for a beer.
  *
  * @param client The client that is to be limited.
@@ -5462,7 +5462,7 @@ ProcUngrabKeyboard(ClientPtr client)
  * Server-side protocol handling for QueryPointer request.
  *
  * Returns the current state and position of the client's ClientPointer to the
- * client. 
+ * client.
  */
 int
 ProcQueryPointer(ClientPtr client)
@@ -5521,7 +5521,7 @@ ProcQueryPointer(ClientPtr client)
 
     WriteReplyToClient(client, sizeof(xQueryPointerReply), &rep);
 
-    return(Success);    
+    return(Success);
 }
 
 /**
@@ -5579,7 +5579,7 @@ CloseDownEvents(void)
 /**
  * Server-side protocol handling for SendEvent request.
  *
- * Locates the window to send the event to and forwards the event. 
+ * Locates the window to send the event to and forwards the event.
  */
 int
 ProcSendEvent(ClientPtr client)
@@ -5595,7 +5595,7 @@ ProcSendEvent(ClientPtr client)
 	extension. */
 
     if ( ! ((stuff->event.u.u.type > X_Reply &&
-	     stuff->event.u.u.type < LASTEvent) || 
+	     stuff->event.u.u.type < LASTEvent) ||
 	    (stuff->event.u.u.type >= EXTENSION_EVENT_BASE &&
 	     stuff->event.u.u.type < (unsigned)lastEvent)))
     {
@@ -5627,7 +5627,7 @@ ProcSendEvent(ClientPtr client)
 
 	/* If the input focus is PointerRootWin, send the event to where
 	the pointer is if possible, then perhaps propogate up to root. */
-   	if (inputFocus == PointerRootWin)
+	if (inputFocus == PointerRootWin)
 	    inputFocus = pSprite->spriteTrace[0]; /* Root window! */
 
 	if (IsParent(inputFocus, pSprite->win))
@@ -5722,7 +5722,7 @@ ProcUngrabKey(ClientPtr client)
  * Server-side protocol handling for GrabKey request.
  *
  * Creates a grab for the client's keyboard and adds it to the list of passive
- * grabs. 
+ * grabs.
  */
 int
 ProcGrabKey(ClientPtr client)
@@ -5768,10 +5768,10 @@ ProcGrabKey(ClientPtr client)
     if (rc != Success)
 	return rc;
 
-    grab = CreateGrab(client->index, keybd, pWin, 
+    grab = CreateGrab(client->index, keybd, pWin,
 	(Mask)(KeyPressMask | KeyReleaseMask), (Bool)stuff->ownerEvents,
 	(Bool)stuff->keyboardMode, (Bool)stuff->pointerMode,
-	keybd, stuff->modifiers, KeyPress, stuff->key, 
+	keybd, stuff->modifiers, KeyPress, stuff->key,
 	NullWindow, NullCursor);
     if (!grab)
 	return BadAlloc;
@@ -5851,7 +5851,7 @@ ProcGrabButton(ClientPtr client)
     pointer = PickPointer(client);
     modifierDevice = GetPairedDevice(pointer);
 
-    grab = CreateGrab(client->index, pointer, pWin, 
+    grab = CreateGrab(client->index, pointer, pWin,
         (Mask)stuff->eventMask, (Bool)stuff->ownerEvents,
         (Bool) stuff->keyboardMode, (Bool)stuff->pointerMode,
         modifierDevice, stuff->modifiers, ButtonPress,
@@ -5920,7 +5920,7 @@ DeleteWindowFromAnyEvents(WindowPtr pWin, Bool freeResources)
     FocusClassPtr	focus;
     OtherClientsPtr	oc;
     GrabPtr		passive;
-    GrabPtr             grab; 
+    GrabPtr             grab;
 
 
     /* Deactivate any grabs performed on this window, before making any
@@ -5951,7 +5951,7 @@ DeleteWindowFromAnyEvents(WindowPtr pWin, Bool freeResources)
         {
             focus = keybd->focus;
 
-            /* If the focus window is a root window (ie. has no parent) then don't 
+            /* If the focus window is a root window (ie. has no parent) then don't
                delete the focus from it. */
 
             if ((pWin == focus->win) && (pWin->parent != NullWindow))
@@ -6077,14 +6077,14 @@ ProcRecolorCursor(ClientPtr client)
     CursorPtr pCursor;
     int		nscr;
     ScreenPtr	pscr;
-    Bool 	displayed;
+    Bool	displayed;
     SpritePtr   pSprite = PickPointer(client)->spriteInfo->sprite;
     REQUEST(xRecolorCursorReq);
 
     REQUEST_SIZE_MATCH(xRecolorCursorReq);
     pCursor = (CursorPtr)SecurityLookupIDByType(client, stuff->cursor,
 					RT_CURSOR, DixWriteAccess);
-    if ( !pCursor) 
+    if ( !pCursor)
     {
 	client->errorValue = stuff->cursor;
 	return (BadCursor);
@@ -6119,10 +6119,10 @@ ProcRecolorCursor(ClientPtr client)
  * the given event type.
  *
  * In the case of DeviceMotionNotify trailed by DeviceValuators, the events
- * can be more than one. Usually it's just one event. 
+ * can be more than one. Usually it's just one event.
  *
  * Do not modify the event structure passed in. See comment below.
- * 
+ *
  * @param pClient Client to send events to.
  * @param count Number of events.
  * @param events The event list.
@@ -6143,8 +6143,8 @@ WriteEventsToClient(ClientPtr pClient, int count, xEvent *events)
 #endif
 
 #ifdef PANORAMIX
-    if(!noPanoramiXExtension && 
-       (panoramiXdataPtr[0].x || panoramiXdataPtr[0].y)) 
+    if(!noPanoramiXExtension &&
+       (panoramiXdataPtr[0].x || panoramiXdataPtr[0].y))
     {
 	switch(events->u.u.type) {
 	case MotionNotify:
@@ -6154,17 +6154,17 @@ WriteEventsToClient(ClientPtr pClient, int count, xEvent *events)
 	case KeyRelease:
 	case EnterNotify:
 	case LeaveNotify:
-	/* 
+	/*
 	   When multiple clients want the same event DeliverEventsToWindow
-	   passes the same event structure multiple times so we can't 
-	   modify the one passed to us 
+	   passes the same event structure multiple times so we can't
+	   modify the one passed to us
         */
 	    count = 1;  /* should always be 1 */
 	    memcpy(&eventCopy, events, sizeof(xEvent));
 	    eventCopy.u.keyButtonPointer.rootX += panoramiXdataPtr[0].x;
 	    eventCopy.u.keyButtonPointer.rootY += panoramiXdataPtr[0].y;
-	    if(eventCopy.u.keyButtonPointer.event == 
-	       eventCopy.u.keyButtonPointer.root) 
+	    if(eventCopy.u.keyButtonPointer.event ==
+	       eventCopy.u.keyButtonPointer.root)
 	    {
 		eventCopy.u.keyButtonPointer.eventX += panoramiXdataPtr[0].x;
 		eventCopy.u.keyButtonPointer.eventY += panoramiXdataPtr[0].y;
@@ -6191,7 +6191,7 @@ WriteEventsToClient(ClientPtr pClient, int count, xEvent *events)
 	    XSERVER_SEND_EVENT(pClient->index, events[i].u.u.type, &events[i]);
 	}
     }
-#endif	
+#endif
     /* Just a safety check to make sure we only have one GenericEvent, it just
      * makes things easier for me right now. (whot) */
     for (i = 1; i < count; i++)
@@ -6199,7 +6199,7 @@ WriteEventsToClient(ClientPtr pClient, int count, xEvent *events)
         if (events[i].u.u.type == GenericEvent)
         {
             ErrorF("[dix] TryClientEvents: Only one GenericEvent at a time.\n");
-            return; 
+            return;
         }
     }
 
@@ -6249,7 +6249,7 @@ WriteEventsToClient(ClientPtr pClient, int count, xEvent *events)
  * A client can have exactly one ClientPointer. Each time a
  * request/reply/event is processed and the choice of devices is ambiguous
  * (e.g. QueryPointer request), the server will pick the ClientPointer (see
- * PickPointer()). 
+ * PickPointer()).
  * If a keyboard is needed, the first keyboard paired with the CP is used.
  */
 _X_EXPORT Bool
@@ -6261,7 +6261,7 @@ SetClientPointer(ClientPtr client, ClientPtr setter, DeviceIntPtr device)
         return FALSE;
     } else if (!device->spriteInfo->spriteOwner)
     {
-        ErrorF("[dix] Device %d does not have a sprite. " 
+        ErrorF("[dix] Device %d does not have a sprite. "
                 "Cannot be ClientPointer\n", device->id);
         return FALSE;
     }
@@ -6303,7 +6303,7 @@ PickKeyboard(ClientPtr client)
 
     if (!kbd)
     {
-        ErrorF("[dix] ClientPointer not paired with a keyboard. This " 
+        ErrorF("[dix] ClientPointer not paired with a keyboard. This "
                 "is a bug.\n");
     }
 
@@ -6318,7 +6318,7 @@ PickKeyboard(ClientPtr client)
  * Return true if a core event from the device would interfere and should not
  * be delivered.
  */
-Bool 
+Bool
 IsInterferingGrab(ClientPtr client, DeviceIntPtr dev, xEvent* event)
 {
     DeviceIntPtr it = inputInfo.devices;
@@ -6359,13 +6359,13 @@ IsInterferingGrab(ClientPtr client, DeviceIntPtr dev, xEvent* event)
 }
 
 /**
- * Set the filters for a extension. 
+ * Set the filters for a extension.
  * The filters array needs to contain the Masks that are applicable for each
  * event type for the given extension.
  * e.g. if generic event type 2 should be let through for windows with
  * MyExampleMask set, make sure that filters[2] == MyExampleMask.
  */
-_X_EXPORT void 
+_X_EXPORT void
 SetGenericFilter(int extension, Mask* filters)
 {
     generic_filters[extension & 0x7f] = filters;
@@ -6377,15 +6377,15 @@ SetGenericFilter(int extension, Mask* filters)
  * grabmode is used to ungrab a device.
  */
 _X_EXPORT int
-ExtGrabDevice(ClientPtr client, 
-              DeviceIntPtr dev, 
+ExtGrabDevice(ClientPtr client,
+              DeviceIntPtr dev,
               int device_mode,
-              WindowPtr grabWindow, 
-              WindowPtr confineTo, 
-              TimeStamp ctime, 
-              Bool ownerEvents, 
-              CursorPtr cursor, 
-              Mask xi_mask, 
+              WindowPtr grabWindow,
+              WindowPtr confineTo,
+              TimeStamp ctime,
+              Bool ownerEvents,
+              CursorPtr cursor,
+              Mask xi_mask,
               GenericMaskPtr ge_masks)
 {
     GrabInfoPtr grabinfo;
commit c703849e79391bb1bb01a994bb8d5cf2eb64e48b
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Tue Nov 13 16:50:18 2007 +1030

    dix: Attach spriteInfoRec to same memory block as the DeviceIntRec.
    
    No need to alloc a separate one, we never do anything special with it anyway.

diff --git a/dix/devices.c b/dix/devices.c
index 2c6d3e1..7841e64 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -134,7 +134,7 @@ AddInputDevice(DeviceProc deviceProc, Bool autoStart)
 
     if (devid >= MAX_DEVICES)
 	return (DeviceIntPtr)NULL;
-    dev = (DeviceIntPtr) xcalloc(sizeof(DeviceIntRec), 1);
+    dev = (DeviceIntPtr) xcalloc(sizeof(DeviceIntRec) + sizeof(SpriteInfoRec), 1);
     if (!dev)
 	return (DeviceIntPtr)NULL;
     dev->name = (char *)NULL;
@@ -183,9 +183,7 @@ AddInputDevice(DeviceProc deviceProc, Bool autoStart)
     dev->enabled = FALSE;
 
     /* sprite defaults */
-    dev->spriteInfo = (SpriteInfoPtr)xcalloc(sizeof(SpriteInfoRec), 1);
-    if (!dev->spriteInfo)
-        return (DeviceIntPtr)NULL;
+    dev->spriteInfo = (SpriteInfoPtr)&dev[1];
     dev->spriteInfo->sprite = NULL;
     dev->spriteInfo->spriteOwner = FALSE;
 
@@ -757,7 +755,6 @@ CloseDevice(DeviceIntPtr dev)
 	xfree(dev->devPrivates);
 
     xfree(dev->deviceGrab.sync.event);
-    xfree(dev->spriteInfo);
     xfree(dev);
 }
 


More information about the xorg-commit mailing list