xserver: Branch 'master' - 5 commits

Eamon Walsh ewalsh at kemper.freedesktop.org
Sat Dec 16 00:28:48 EET 2006


 GL/glx/glxcmds.c                |   18 +--
 XTrap/xtrapdi.c                 |    4 
 Xext/appgroup.c                 |   15 +-
 Xext/mbuf.c                     |   41 +++----
 Xext/panoramiX.c                |   27 ++--
 Xext/panoramiXprocs.c           |   18 +--
 Xext/saver.c                    |   36 +++---
 Xext/shape.c                    |   66 ++++++-----
 Xext/sync.c                     |   20 ++-
 Xext/xprint.c                   |   14 +-
 Xext/xtest.c                    |   19 +--
 Xext/xvdisp.c                   |   12 --
 Xi/chgprop.c                    |    9 -
 Xi/exevents.c                   |   22 ++-
 Xi/getprop.c                    |    9 -
 Xi/getselev.c                   |    8 -
 Xi/selectev.c                   |    8 -
 Xi/ungrdevb.c                   |    7 -
 Xi/ungrdevk.c                   |    7 -
 composite/compwindow.c          |    6 -
 dbe/dbe.c                       |   26 ++--
 dix/devices.c                   |    8 -
 dix/dispatch.c                  |  226 ++++++++++++++++++----------------------
 dix/dixutils.c                  |    5 
 dix/events.c                    |  117 ++++++++++----------
 dix/property.c                  |   45 +++----
 hw/darwin/quartz/applewm.c      |   12 --
 hw/darwin/quartz/pseudoramiX.c  |   27 ++--
 hw/darwin/quartz/xpr/appledri.c |   22 +--
 hw/dmx/dmx.c                    |   14 +-
 hw/dmx/glxProxy/glxcmds.c       |   98 ++++++++---------
 hw/xfree86/dri/xf86dri.c        |   35 ++----
 hw/xwin/winclipboardwrappers.c  |    8 -
 hw/xwin/winwindowswm.c          |   19 +--
 include/dix.h                   |    3 
 randr/rrdispatch.c              |    7 -
 randr/rrscreen.c                |   40 ++-----
 randr/rrxinerama.c              |   21 ++-
 xfixes/cursor.c                 |    8 -
 xfixes/saveset.c                |    7 -
 xfixes/select.c                 |    8 -
 41 files changed, 552 insertions(+), 570 deletions(-)

New commits:
diff-tree ab1d5b0c31a1cfce95ab6b1d06f209f2c44e19ac (from f11dafaafc68f5cff1a1538d9566907786d8ab72)
Author: Eamon Walsh <ewalsh at tycho.nsa.gov>
Date:   Fri Dec 15 17:26:58 2006 -0500

    Convert callers of LookupClient() to dixLookupClient().

diff --git a/Xext/appgroup.c b/Xext/appgroup.c
index 134b172..bb7a73c 100644
--- a/Xext/appgroup.c
+++ b/Xext/appgroup.c
@@ -485,10 +485,13 @@ int ProcXagQuery(
     ClientPtr pClient;
     AppGroupPtr pAppGrp;
     REQUEST (xXagQueryReq);
-    int n;
+    int n, rc;
 
     REQUEST_SIZE_MATCH (xXagQueryReq);
-    pClient = LookupClient (stuff->resource, client);
+    rc = dixLookupClient(&pClient, stuff->resource, client, DixUnknownAccess);
+    if (rc != Success)
+	return rc;
+
     for (pAppGrp = appGrpList; pAppGrp != NULL; pAppGrp = pAppGrp->next)
 	for (n = 0; n < pAppGrp->nclients; n++)
 	    if (pAppGrp->clients[n] == pClient) {
diff --git a/Xext/sync.c b/Xext/sync.c
index 1d89934..531b48c 100644
--- a/Xext/sync.c
+++ b/Xext/sync.c
@@ -1452,15 +1452,17 @@ ProcSyncSetPriority(client)
 {
     REQUEST(xSyncSetPriorityReq);
     ClientPtr priorityclient;
+    int rc;
 
     REQUEST_SIZE_MATCH(xSyncSetPriorityReq);
 
     if (stuff->id == None)
 	priorityclient = client;
-    else if (!(priorityclient = LookupClient(stuff->id, client)))
-    {
-	client->errorValue = stuff->id;
-	return BadMatch;
+    else {
+	rc = dixLookupClient(&priorityclient, stuff->id, client,
+			     DixUnknownAccess);
+	if (rc != Success)
+	    return rc;
     }
 
     if (priorityclient->priority != stuff->priority)
@@ -1487,15 +1489,17 @@ ProcSyncGetPriority(client)
     REQUEST(xSyncGetPriorityReq);
     xSyncGetPriorityReply rep;
     ClientPtr priorityclient;
+    int rc;
 
     REQUEST_SIZE_MATCH(xSyncGetPriorityReq);
 
     if (stuff->id == None)
 	priorityclient = client;
-    else if (!(priorityclient = LookupClient(stuff->id, client)))
-    {
-	client->errorValue = stuff->id;
-	return BadMatch;
+    else {
+	rc = dixLookupClient(&priorityclient, stuff->id, client,
+			     DixUnknownAccess);
+	if (rc != Success)
+	    return rc;
     }
 
     rep.type = X_Reply;
diff --git a/dix/dispatch.c b/dix/dispatch.c
index 3060a4c..51ad07d 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -3388,7 +3388,8 @@ int
 ProcKillClient(register ClientPtr client)
 {
     REQUEST(xResourceReq);
-    ClientPtr	killclient;
+    ClientPtr killclient;
+    int rc;
 
     REQUEST_SIZE_MATCH(xResourceReq);
     if (stuff->id == AllTemporary)
@@ -3397,8 +3398,8 @@ ProcKillClient(register ClientPtr client
         return (client->noClientException);
     }
 
-    if ((killclient = LookupClient(stuff->id, client)))
-    {
+    rc = dixLookupClient(&killclient, stuff->id, client, DixDestroyAccess);
+    if (rc == Success) {
 	CloseDownClient(killclient);
 	/* if an LBX proxy gets killed, isItTimeToYield will be set */
 	if (isItTimeToYield || (client == killclient))
@@ -3412,10 +3413,7 @@ ProcKillClient(register ClientPtr client
 	return (client->noClientException);
     }
     else
-    {
-	client->errorValue = stuff->id;
-	return (BadValue);
-    }
+	return rc;
 }
 
 int
diff --git a/dix/dixutils.c b/dix/dixutils.c
index 3479ddc..2859b96 100644
--- a/dix/dixutils.c
+++ b/dix/dixutils.c
@@ -262,11 +262,12 @@ dixLookupGC(GCPtr *pGC, XID id, ClientPt
 }
 
 _X_EXPORT int
-dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client)
+dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client, Mask access)
 {
     pointer pRes = (pointer)SecurityLookupIDByClass(client, rid, RC_ANY,
 						    DixReadAccess);
     int clientIndex = CLIENT_ID(rid);
+    client->errorValue = rid;
 
     if (clientIndex && pRes && clients[clientIndex] && !(rid & SERVER_BIT)) {
 	*pClient = clients[clientIndex];
@@ -312,7 +313,7 @@ _X_EXPORT ClientPtr
 LookupClient(XID id, ClientPtr client)
 {
     ClientPtr pClient;
-    int i = dixLookupClient(&pClient, id, client);
+    int i = dixLookupClient(&pClient, id, client, DixUnknownAccess);
     return (i == Success) ? pClient : NULL;
 }
 
diff --git a/include/dix.h b/include/dix.h
index baff43f..5c2c5b8 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -301,7 +301,8 @@ extern int dixLookupGC(
 extern int dixLookupClient(
     ClientPtr *result,
     XID id,
-    ClientPtr client);
+    ClientPtr client,
+    Mask access_mode);
 
 /*
  * These are deprecated compatibility functions and will be removed soon!
diff-tree f11dafaafc68f5cff1a1538d9566907786d8ab72 (from 10aabb729d1586db344f9c1abdf1cf45e7ddaa7a)
Author: Eamon Walsh <ewalsh at tycho.nsa.gov>
Date:   Fri Dec 15 16:51:58 2006 -0500

    Convert callers of SecurityLookupDrawable() to dixLookupDrawable().

diff --git a/dbe/dbe.c b/dbe/dbe.c
index 69ddf4f..38375f9 100644
--- a/dbe/dbe.c
+++ b/dbe/dbe.c
@@ -865,7 +865,7 @@ ProcDbeGetVisualInfo(ClientPtr client)
     xDbeGetVisualInfoReply	rep;
     Drawable			*drawables;
     DrawablePtr			*pDrawables = NULL;
-    register int		i, j, n;
+    register int		i, j, n, rc;
     register int		count;  /* number of visual infos in reply */
     register int		length; /* length of reply */
     ScreenPtr			pScreen;
@@ -887,11 +887,11 @@ ProcDbeGetVisualInfo(ClientPtr client)
 
         for (i = 0; i < stuff->n; i++)
         {
-            if (!(pDrawables[i] = (DrawablePtr)SecurityLookupDrawable(
-				drawables[i], client, DixReadAccess)))
-            {
+	    rc = dixLookupDrawable(pDrawables+i, drawables[i], client, 0,
+				   DixReadAccess);
+	    if (rc != Success) {
                 DEALLOCATE_LOCAL(pDrawables);
-                return(BadDrawable);
+                return rc;
             }
         }
     }
diff --git a/hw/darwin/quartz/xpr/appledri.c b/hw/darwin/quartz/xpr/appledri.c
index 585d7e1..dd688ca 100644
--- a/hw/darwin/quartz/xpr/appledri.c
+++ b/hw/darwin/quartz/xpr/appledri.c
@@ -213,6 +213,7 @@ ProcAppleDRICreateSurface(
     DrawablePtr pDrawable;
     xp_surface_id sid;
     unsigned int key[2];
+    int rc;
 
     REQUEST(xAppleDRICreateSurfaceReq);
     REQUEST_SIZE_MATCH(xAppleDRICreateSurfaceReq);
@@ -220,12 +221,10 @@ ProcAppleDRICreateSurface(
     rep.length = 0;
     rep.sequenceNumber = client->sequence;
 
-    if (!(pDrawable = (DrawablePtr)SecurityLookupDrawable(
-                                                (Drawable)stuff->drawable,
-                                                client, 
-                                                DixReadAccess))) {
-        return BadValue;
-    }
+    rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
+			   DixReadAccess);
+    if (rc != Success)
+	return rc;
 
     rep.key_0 = rep.key_1 = rep.uid = 0;
 
@@ -252,13 +251,12 @@ ProcAppleDRIDestroySurface(
     REQUEST(xAppleDRIDestroySurfaceReq);
     DrawablePtr pDrawable;
     REQUEST_SIZE_MATCH(xAppleDRIDestroySurfaceReq);
+    int rc;
 
-    if (!(pDrawable = (DrawablePtr)SecurityLookupDrawable(
-                                                (Drawable)stuff->drawable,
-                                                client, 
-                                                DixReadAccess))) {
-        return BadValue;
-    }
+    rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
+			   DixReadAccess);
+    if (rc != Success)
+	return rc;
 
     if (!DRIDestroySurface( screenInfo.screens[stuff->screen], 
                             (Drawable)stuff->drawable,
diff --git a/hw/xfree86/dri/xf86dri.c b/hw/xfree86/dri/xf86dri.c
index 03e6725..933cd3e 100644
--- a/hw/xfree86/dri/xf86dri.c
+++ b/hw/xfree86/dri/xf86dri.c
@@ -386,6 +386,7 @@ ProcXF86DRICreateDrawable(
 {
     xXF86DRICreateDrawableReply	rep;
     DrawablePtr pDrawable;
+    int rc;
 
     REQUEST(xXF86DRICreateDrawableReq);
     REQUEST_SIZE_MATCH(xXF86DRICreateDrawableReq);
@@ -398,12 +399,10 @@ ProcXF86DRICreateDrawable(
     rep.length = 0;
     rep.sequenceNumber = client->sequence;
 
-    if (!(pDrawable = (DrawablePtr)SecurityLookupDrawable(
-						(Drawable)stuff->drawable,
-						client, 
-						DixReadAccess))) {
-	return BadValue;
-    }
+    rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
+			   DixReadAccess);
+    if (rc != Success)
+	return rc;
 
     if (!DRICreateDrawable( screenInfo.screens[stuff->screen],
 			    (Drawable)stuff->drawable,
@@ -424,17 +423,17 @@ ProcXF86DRIDestroyDrawable(
     REQUEST(xXF86DRIDestroyDrawableReq);
     DrawablePtr pDrawable;
     REQUEST_SIZE_MATCH(xXF86DRIDestroyDrawableReq);
+    int rc;
+
     if (stuff->screen >= screenInfo.numScreens) {
 	client->errorValue = stuff->screen;
 	return BadValue;
     }
 
-    if (!(pDrawable = (DrawablePtr)SecurityLookupDrawable(
-						(Drawable)stuff->drawable,
-						client, 
-						DixReadAccess))) {
-	return BadValue;
-    }
+    rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
+			   DixReadAccess);
+    if (rc != Success)
+	return rc;
 
     if (!DRIDestroyDrawable( screenInfo.screens[stuff->screen], 
 			     (Drawable)stuff->drawable,
@@ -455,7 +454,7 @@ ProcXF86DRIGetDrawableInfo(
     int X, Y, W, H;
     drm_clip_rect_t * pClipRects;
     drm_clip_rect_t * pBackClipRects;
-    int backX, backY;
+    int backX, backY, rc;
 
     REQUEST(xXF86DRIGetDrawableInfoReq);
     REQUEST_SIZE_MATCH(xXF86DRIGetDrawableInfoReq);
@@ -468,12 +467,10 @@ ProcXF86DRIGetDrawableInfo(
     rep.length = 0;
     rep.sequenceNumber = client->sequence;
 
-    if (!(pDrawable = (DrawablePtr)SecurityLookupDrawable(
-						(Drawable)stuff->drawable,
-						client, 
-						DixReadAccess))) {
-	return BadValue;
-    }
+    rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
+			   DixReadAccess);
+    if (rc != Success)
+	return rc;
 
     if (!DRIGetDrawableInfo( screenInfo.screens[stuff->screen],
 			     pDrawable,
diff-tree 10aabb729d1586db344f9c1abdf1cf45e7ddaa7a (from 25d5e0a629f82d95bd71daf9a920a70e095b5188)
Author: Eamon Walsh <ewalsh at tycho.nsa.gov>
Date:   Fri Dec 15 16:36:29 2006 -0500

    Convert callers of LookupDrawable() to dixLookupDrawable().

diff --git a/GL/glx/glxcmds.c b/GL/glx/glxcmds.c
index ccdf3fa..6273edc 100644
--- a/GL/glx/glxcmds.c
+++ b/GL/glx/glxcmds.c
@@ -441,6 +441,7 @@ static int GetDrawableOrPixmap( __GLXcon
     __GLcontextModes *modes;
     __GLXdrawable *pGlxDraw;
     __GLXpixmap *drawPixmap = NULL;
+    int rc;
 
     /* This is the GLX 1.3 case - the client passes in a GLXWindow and
      * we just return the __GLXdrawable.  The first time a GLXPixmap
@@ -466,8 +467,8 @@ static int GetDrawableOrPixmap( __GLXcon
      * GLXWindow with the same XID as an X Window, so we wont get any
      * resource ID clashes.  Effectively, the X Window is now also a
      * GLXWindow. */
-    pDraw = (DrawablePtr) LookupDrawable(drawId, client);
-    if (pDraw) {
+    rc = dixLookupDrawable(&pDraw, drawId, client, 0, DixUnknownAccess);
+    if (rc == Success) {
 	if (pDraw->type == DRAWABLE_WINDOW) {
 	    VisualID vid = wVisual((WindowPtr)pDraw);
 
@@ -1199,12 +1200,12 @@ static int ValidateCreateDrawable(Client
     ScreenPtr pScreen;
     VisualPtr pVisual;
     __GLXscreen *pGlxScreen;
-    int i;
+    int i, rc;
 
     LEGAL_NEW_RESOURCE(glxDrawableId, client);
 
-    pDraw = (DrawablePtr) LookupDrawable(drawablId, client);
-    if (!pDraw || pDraw->type != type) {
+    rc = dixLookupDrawable(&pDraw, drawablId, client, 0, DixUnknownAccess);
+    if (rc != Success || pDraw->type != type) {
 	client->errorValue = drawablId;
 	return type == DRAWABLE_WINDOW ? BadWindow : BadPixmap;
     }
@@ -2034,10 +2035,11 @@ int __glXDisp_BindSwapBarrierSGIX(__GLXc
     xGLXBindSwapBarrierSGIXReq *req = (xGLXBindSwapBarrierSGIXReq *) pc;
     XID drawable = req->drawable;
     int barrier = req->barrier;
-    DrawablePtr pDraw = (DrawablePtr) LookupDrawable(drawable, client);
-    int screen;
+    DrawablePtr pDraw;
+    int screen, rc;
 
-    if (pDraw && (pDraw->type == DRAWABLE_WINDOW)) {
+    rc = dixLookupDrawable(&pDraw, drawable, client, 0, DixUnknownAccess);
+    if (rc == Success && (pDraw->type == DRAWABLE_WINDOW)) {
 	screen = pDraw->pScreen->myNum;
         if (__glXSwapBarrierFuncs &&
             __glXSwapBarrierFuncs[screen].bindSwapBarrierFunc) {
diff --git a/XTrap/xtrapdi.c b/XTrap/xtrapdi.c
index c5d640d..23d3bde 100644
--- a/XTrap/xtrapdi.c
+++ b/XTrap/xtrapdi.c
@@ -1092,8 +1092,8 @@ int XETrapRequestVector(ClientPtr client
             pdata->hdr.client = client->index;  /* stuff client index in hdr */
             if (BitIsTrue(penv->cur.data_config_flags_data,XETrapWinXY))
             {
-                window_ptr = (WindowPtr) LookupDrawable(stuff->id, client);
-                if (window_ptr == 0L)
+		if (Success != dixLookupDrawable(&window_ptr, stuff->id,
+						 client, 0, DixUnknownAccess))
                 {   /* Failed...invalidate the X and Y coordinate data. */
                     pdata->hdr.win_x = -1L;
                     pdata->hdr.win_y = -1L;
diff --git a/Xext/mbuf.c b/Xext/mbuf.c
index 43e2cc1..ed352e2 100644
--- a/Xext/mbuf.c
+++ b/Xext/mbuf.c
@@ -786,15 +786,15 @@ ProcGetBufferInfo (client)
     DrawablePtr		    pDrawable;
     xMbufGetBufferInfoReply rep;
     ScreenPtr		    pScreen;
-    int			    i, j, k;
-    int			    n;
+    int			    i, j, k, n, rc;
     xMbufBufferInfo	    *pInfo;
     int			    nInfo;
     DepthPtr		    pDepth;
 
-    pDrawable = (DrawablePtr) LookupDrawable (stuff->drawable, client);
-    if (!pDrawable)
-	return BadDrawable;
+    rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
+			   DixUnknownAccess);
+    if (rc != Success)
+	return rc;
     pScreen = pDrawable->pScreen;
     nInfo = 0;
     for (i = 0; i < pScreen->numDepths; i++)
diff --git a/Xext/saver.c b/Xext/saver.c
index d6b537a..7e3ebf4 100644
--- a/Xext/saver.c
+++ b/Xext/saver.c
@@ -780,16 +780,17 @@ ProcScreenSaverQueryInfo (client)
 {
     REQUEST(xScreenSaverQueryInfoReq);
     xScreenSaverQueryInfoReply	rep;
-    register int		n;
+    register int		n, rc;
     ScreenSaverStuffPtr		pSaver;
     DrawablePtr			pDraw;
     CARD32			lastInput;
     ScreenSaverScreenPrivatePtr	pPriv;
 
     REQUEST_SIZE_MATCH (xScreenSaverQueryInfoReq);
-    pDraw = (DrawablePtr) LookupDrawable (stuff->drawable, client);
-    if (!pDraw)
-	return BadDrawable;
+    rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0,
+			   DixUnknownAccess);
+    if (rc != Success)
+	return rc;
 
     pSaver = &savedScreenInfo[pDraw->pScreen->myNum];
     pPriv = GetScreenPrivate (pDraw->pScreen);
@@ -852,11 +853,13 @@ ProcScreenSaverSelectInput (client)
 {
     REQUEST(xScreenSaverSelectInputReq);
     DrawablePtr			pDraw;
+    int				rc;
 
     REQUEST_SIZE_MATCH (xScreenSaverSelectInputReq);
-    pDraw = (DrawablePtr) LookupDrawable (stuff->drawable, client);
-    if (!pDraw)
-	return BadDrawable;
+    rc = dixLookupDrawable (&pDraw, stuff->drawable, client, 0,
+			    DixUnknownAccess);
+    if (rc != Success)
+	return rc;
     if (!setEventMask (pDraw->pScreen, client, stuff->eventMask))
 	return BadAlloc;
     return Success;
@@ -871,9 +874,7 @@ ScreenSaverSetAttributes (ClientPtr clie
     ScreenPtr			pScreen;
     ScreenSaverScreenPrivatePtr pPriv = 0;
     ScreenSaverAttrPtr		pAttr = 0;
-    int				ret;
-    int				len;
-    int				class, bw, depth;
+    int				ret, len, class, bw, depth;
     unsigned long		visual;
     int				idepth, ivisual;
     Bool			fOK;
@@ -891,9 +892,10 @@ ScreenSaverSetAttributes (ClientPtr clie
     ColormapPtr			pCmap;
 
     REQUEST_AT_LEAST_SIZE (xScreenSaverSetAttributesReq);
-    pDraw = (DrawablePtr) LookupDrawable (stuff->drawable, client);
-    if (!pDraw)
-	return BadDrawable;
+    ret = dixLookupDrawable(&pDraw, stuff->drawable, client, 0,
+			    DixUnknownAccess);
+    if (ret != Success)
+	return ret;
     pScreen = pDraw->pScreen;
     pParent = WindowTable[pScreen->myNum];
 
@@ -1246,11 +1248,13 @@ ScreenSaverUnsetAttributes (ClientPtr cl
     REQUEST(xScreenSaverSetAttributesReq);
     DrawablePtr			pDraw;
     ScreenSaverScreenPrivatePtr	pPriv;
+    int				rc;
 
     REQUEST_SIZE_MATCH (xScreenSaverUnsetAttributesReq);
-    pDraw = (DrawablePtr) LookupDrawable (stuff->drawable, client);
-    if (!pDraw)
-	return BadDrawable;
+    rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0,
+			   DixUnknownAccess);
+    if (rc != Success)
+	return rc;
     pPriv = GetScreenPrivate (pDraw->pScreen);
     if (pPriv && pPriv->attr && pPriv->attr->client == client)
     {
diff --git a/Xext/xprint.c b/Xext/xprint.c
index d8fc517..4ac13e6 100644
--- a/Xext/xprint.c
+++ b/Xext/xprint.c
@@ -1944,8 +1944,11 @@ ProcXpPutDocumentData(ClientPtr client)
     if (stuff->drawable) {
 	if (pContext->state & DOC_RAW_STARTED)
 	    return BadDrawable;
-	pDraw = (DrawablePtr)LookupDrawable(stuff->drawable, client);
-	if (!pDraw || pDraw->pScreen->myNum != pContext->screenNum)
+	result = dixLookupDrawable(&pDraw, stuff->drawable, client, 0,
+				   DixUnknownAccess);
+	if (result != Success)
+	    return result;
+	if (pDraw->pScreen->myNum != pContext->screenNum)
 	    return BadDrawable;
     } else {
 	if (pContext->state & DOC_COOKED_STARTED)
diff --git a/hw/dmx/glxProxy/glxcmds.c b/hw/dmx/glxProxy/glxcmds.c
index aa9d831..6771cf1 100644
--- a/hw/dmx/glxProxy/glxcmds.c
+++ b/hw/dmx/glxProxy/glxcmds.c
@@ -430,9 +430,10 @@ int __glXBindSwapBarrierSGIX(__GLXclient
     DrawablePtr pDraw;
     __GLXpixmap *pGlxPixmap = NULL;
     __glXWindow *pGlxWindow = NULL;
+    int rc;
 
-    pDraw = (DrawablePtr) LookupDrawable(req->drawable, client);
-    if (!pDraw) {
+    rc = dixLookupDrawable(&pDraw, req->drawable, client, 0, DixUnknownAccess);
+    if (rc != Success) {
 	pGlxPixmap = (__GLXpixmap *) LookupIDByType(req->drawable,
 						    __glXPixmapRes);
 	if (pGlxPixmap) pDraw = pGlxPixmap->pDraw;
@@ -459,9 +460,10 @@ int __glXJoinSwapGroupSGIX(__GLXclientSt
     DrawablePtr pDraw, pMember = NULL;
     __GLXpixmap *pGlxPixmap = NULL;
     __glXWindow *pGlxWindow = NULL;
+    int rc;
 
-    pDraw = (DrawablePtr) LookupDrawable(req->drawable, client);
-    if (!pDraw) {
+    rc = dixLookupDrawable(&pDraw, req->drawable, client, 0, DixUnknownAccess);
+    if (rc != Success) {
 	pGlxPixmap = (__GLXpixmap *) LookupIDByType(req->drawable,
 						    __glXPixmapRes);
 	if (pGlxPixmap) pDraw = pGlxPixmap->pDraw;
@@ -479,8 +481,9 @@ int __glXJoinSwapGroupSGIX(__GLXclientSt
     }
 
     if (req->member != None) {
-	pMember = (DrawablePtr) LookupDrawable(req->member, client);
-	if (!pMember) {
+	rc = dixLookupDrawable(&pMember, req->member, client, 0,
+			       DixUnknownAccess);
+	if (rc != Success) {
 	    pGlxPixmap = (__GLXpixmap *) LookupIDByType(req->member,
 							__glXPixmapRes);
 	    if (pGlxPixmap) pMember = pGlxPixmap->pDraw;
@@ -734,7 +737,7 @@ static int MakeCurrent(__GLXclientState 
 #endif
     int from_screen = 0;
     int to_screen = 0;
-    int s;
+    int s, rc;
 
     /*
     ** If one is None and the other isn't, it's a bad match.
@@ -778,8 +781,8 @@ static int MakeCurrent(__GLXclientState 
     }
 
     if (drawId != None) {
-	pDraw = (DrawablePtr) LookupDrawable(drawId, client);
-	if (pDraw) {
+	rc = dixLookupDrawable(&pDraw, drawId, client, 0, DixUnknownAccess);
+	if (rc == Success) {
 	    if (pDraw->type == DRAWABLE_WINDOW) {
 		/*
 		** Drawable is an X Window.
@@ -885,8 +888,8 @@ static int MakeCurrent(__GLXclientState 
     }
 
     if (readId != None && readId != drawId ) {
-	pReadDraw = (DrawablePtr) LookupDrawable(readId, client);
-	if (pReadDraw) {
+	rc = dixLookupDrawable(&pReadDraw, readId, client, 0,DixUnknownAccess);
+	if (rc == Success) {
 	    if (pReadDraw->type == DRAWABLE_WINDOW) {
 		/*
 		** Drawable is an X Window.
@@ -1636,18 +1639,16 @@ static int CreateGLXPixmap(__GLXclientSt
     __GLXscreenInfo *pGlxScreen;
     __GLXvisualConfig *pGlxVisual;
     __GLXFBConfig *pFBConfig;
-    int i;
-    int s;
+    int i, s, rc;
     int from_screen, to_screen;
 #ifdef PANORAMIX
     PanoramiXRes *pXinDraw = NULL;
 #endif
 
-    pDraw = (DrawablePtr) LookupDrawable(pixmapId, client);
-    if (!pDraw || pDraw->type != DRAWABLE_PIXMAP) {
-	client->errorValue = pixmapId;
-	return BadPixmap;
-    }
+    rc = dixLookupDrawable(&pDraw, pixmapId, client, M_DRAWABLE_PIXMAP,
+			   DixUnknownAccess);
+    if (rc != Success)
+	return rc;
 
     /*
     ** Check if screen of visual matches screen of pixmap.
@@ -1778,7 +1779,8 @@ static int CreateGLXPixmap(__GLXclientSt
 
 #ifdef PANORAMIX
        if (pXinDraw) {
-	  pRealDraw = (DrawablePtr) LookupDrawable(pXinDraw->info[s].id,client);
+	   dixLookupDrawable(&pRealDraw, pXinDraw->info[s].id, client, 0,
+			     DixUnknownAccess);
        }
 #endif
 
@@ -1944,14 +1946,13 @@ int __glXDoSwapBuffers(__GLXclientState 
     __glXWindow *pGlxWindow = NULL;
     int from_screen = 0;
     int to_screen = 0;
-    int s;
+    int s, rc;
     
     /*
     ** Check that the GLX drawable is valid.
     */
-    pDraw = (DrawablePtr) LookupDrawable(drawId, client);
-    if (pDraw) {
-
+    rc = dixLookupDrawable(&pDraw, drawId, client, 0, DixUnknownAccess);
+    if (rc == Success) {
         from_screen = to_screen = pDraw->pScreen->myNum;
 
 	if (pDraw->type == DRAWABLE_WINDOW) {
@@ -2099,12 +2100,13 @@ int __glXSwapBuffers(__GLXclientState *c
     __GLXpixmap *pGlxPixmap = NULL;
     __GLXcontext *glxc = NULL;
     __glXWindow *pGlxWindow = NULL;
+    int rc;
     
     /*
     ** Check that the GLX drawable is valid.
     */
-    pDraw = (DrawablePtr) LookupDrawable(drawId, client);
-    if (pDraw) {
+    rc = dixLookupDrawable(&pDraw, drawId, client, 0, DixUnknownAccess);
+    if (rc == Success) {
 	if (pDraw->type != DRAWABLE_WINDOW) {
 	    /*
 	    ** Drawable is an X pixmap, which is not allowed.
@@ -2892,16 +2894,15 @@ int __glXCreateWindow(__GLXclientState *
     __GLXFBConfig *pGlxFBConfig = NULL;
     VisualPtr pVisual;
     VisualID visId;
-    int i;
+    int i, rc;
 
     /*
     ** Check if windowId is valid 
     */
-    pDraw = (DrawablePtr) LookupDrawable(windowId, client);
-    if (!pDraw || pDraw->type != DRAWABLE_WINDOW) {
-	client->errorValue = windowId;
-	return BadWindow;
-    }
+    rc = dixLookupDrawable(&pDraw, windowId, client, M_DRAWABLE_WINDOW,
+			   DixUnknownAccess);
+    if (rc != Success)
+	return rc;
 
     /*
     ** Check if screen of window matches screen of fbconfig.
@@ -3274,7 +3275,7 @@ int __glXGetDrawableAttributes(__GLXclie
    GLXDrawable be_drawable = 0;
    DrawablePtr pDraw = NULL;
    Display *dpy;
-   int screen;
+   int screen, rc;
    DMXScreenInfo *dmxScreen;
    CARD32 *attribs = NULL;
    int attribs_size;
@@ -3283,8 +3284,8 @@ int __glXGetDrawableAttributes(__GLXclie
 #endif
 
    if (drawId != None) {
-      pDraw = (DrawablePtr) LookupDrawable(drawId, client);
-      if (pDraw) {
+      rc = dixLookupDrawable(&pDraw, drawId, client, 0, DixUnknownAccess);
+      if (rc == Success) {
 	 if (pDraw->type == DRAWABLE_WINDOW) {
 		WindowPtr pWin = (WindowPtr)pDraw;
 		be_drawable = 0;
@@ -3435,7 +3436,7 @@ int __glXChangeDrawableAttributes(__GLXc
    GLXDrawable be_drawable = 0;
    DrawablePtr pDraw = NULL;
    Display *dpy;
-   int screen;
+   int screen, rc;
    DMXScreenInfo *dmxScreen;
    char *attrbuf;
 #ifdef PANORAMIX
@@ -3444,8 +3445,8 @@ int __glXChangeDrawableAttributes(__GLXc
 #endif
 
    if (drawId != None) {
-      pDraw = (DrawablePtr) LookupDrawable(drawId, client);
-      if (pDraw) {
+      rc = dixLookupDrawable(&pDraw, drawId, client, 0, DixUnknownAccess);
+      if (rc == Success) {
 	 if (pDraw->type == DRAWABLE_WINDOW) {
 		WindowPtr pWin = (WindowPtr)pDraw;
 		be_drawable = 0;
diff-tree 25d5e0a629f82d95bd71daf9a920a70e095b5188 (from 04c721854fbf1bd6379c165a53fab2bdc09961c0)
Author: Eamon Walsh <ewalsh at tycho.nsa.gov>
Date:   Fri Dec 15 15:50:46 2006 -0500

    Convert callers of SecurityLookupWindow() to dixLookupWindow().

diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c
index a193c41..1c53a1e 100644
--- a/Xext/panoramiXprocs.c
+++ b/Xext/panoramiXprocs.c
@@ -577,19 +577,17 @@ int PanoramiXTranslateCoords(ClientPtr c
 {
     INT16 x, y;
     REQUEST(xTranslateCoordsReq);
-
-    register WindowPtr pWin, pDst;
+    int rc;
+    WindowPtr pWin, pDst;
     xTranslateCoordsReply rep;
 
     REQUEST_SIZE_MATCH(xTranslateCoordsReq);
-    pWin = (WindowPtr)SecurityLookupWindow(stuff->srcWid, client,
-					   DixReadAccess);
-    if (!pWin)
-        return(BadWindow);
-    pDst = (WindowPtr)SecurityLookupWindow(stuff->dstWid, client,
-					   DixReadAccess);
-    if (!pDst)
-        return(BadWindow);
+    rc = dixLookupWindow(&pWin, stuff->srcWid, client, DixReadAccess);
+    if (rc != Success)
+        return rc;
+    rc = dixLookupWindow(&pDst, stuff->dstWid, client, DixReadAccess);
+    if (rc != Success)
+        return rc;
     rep.type = X_Reply;
     rep.length = 0;
     rep.sequenceNumber = client->sequence;
diff --git a/Xext/shape.c b/Xext/shape.c
index 58e3a69..928eeee 100644
--- a/Xext/shape.c
+++ b/Xext/shape.c
@@ -419,12 +419,13 @@ ProcShapeMask (client)
     RegionPtr		*destRgn;
     PixmapPtr		pPixmap;
     CreateDftPtr	createDefault;
+    int			rc;
 
     REQUEST_SIZE_MATCH (xShapeMaskReq);
     UpdateCurrentTime();
-    pWin = SecurityLookupWindow (stuff->dest, client, DixWriteAccess);
-    if (!pWin)
-	return BadWindow;
+    rc = dixLookupWindow(&pWin, stuff->dest, client, DixWriteAccess);
+    if (rc != Success)
+	return rc;
     switch (stuff->destKind) {
     case ShapeBounding:
 	createDefault = CreateBoundingShape;
@@ -822,11 +823,12 @@ ProcShapeSelectInput (client)
     WindowPtr		pWin;
     ShapeEventPtr	pShapeEvent, pNewShapeEvent, *pHead;
     XID			clientResource;
+    int			rc;
 
     REQUEST_SIZE_MATCH (xShapeSelectInputReq);
-    pWin = SecurityLookupWindow (stuff->window, client, DixWriteAccess);
-    if (!pWin)
-	return BadWindow;
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess);
+    if (rc != Success)
+	return rc;
     pHead = (ShapeEventPtr *)SecurityLookupIDByType(client,
 			pWin->drawable.id, EventType, DixWriteAccess);
     switch (stuff->enable) {
diff --git a/Xext/xprint.c b/Xext/xprint.c
index 669ad27..d8fc517 100644
--- a/Xext/xprint.c
+++ b/Xext/xprint.c
@@ -1852,9 +1852,10 @@ ProcXpStartPage(ClientPtr client)
     if(pContext->state & PAGE_STARTED)
 	return XpErrorBase+XPBadSequence;
 
-    pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
-					   DixWriteAccess);
-    if (!pWin || pWin->drawable.pScreen->myNum != pContext->screenNum)
+    result = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess);
+    if (result != Success)
+	return result;
+    if (pWin->drawable.pScreen->myNum != pContext->screenNum)
 	return BadWindow;
 
     if((c = (XpStPagePtr)xalloc(sizeof(XpStPageRec))) == (XpStPagePtr)NULL)
diff --git a/dbe/dbe.c b/dbe/dbe.c
index 649143c..69ddf4f 100644
--- a/dbe/dbe.c
+++ b/dbe/dbe.c
@@ -405,11 +405,9 @@ ProcDbeAllocateBackBufferName(ClientPtr 
     REQUEST_SIZE_MATCH(xDbeAllocateBackBufferNameReq);
 
     /* The window must be valid. */
-    if (!(pWin = SecurityLookupWindow(stuff->window, client,
-				      DixWriteAccess)))
-    {
-	return(BadWindow);
-    }
+    status = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess);
+    if (status != Success)
+	return status;
 
     /* The window must be InputOutput. */
     if (pWin->drawable.class != InputOutput)
@@ -729,11 +727,11 @@ ProcDbeSwapBuffers(ClientPtr client)
         /* Check all windows to swap. */
 
         /* Each window must be a valid window - BadWindow. */
-        if (!(pWin = SecurityLookupWindow(dbeSwapInfo[i].window, client,
-					  DixWriteAccess)))
-        {
+	error = dixLookupWindow(&pWin, dbeSwapInfo[i].window, client,
+				DixWriteAccess);
+	if (error != Success) {
             DEALLOCATE_LOCAL(swapInfo);
-	    return(BadWindow);
+	    return error;
         }
 
         /* Each window must be double-buffered - BadMatch. */
diff --git a/dix/devices.c b/dix/devices.c
index e6a5049..9f42184 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -1840,16 +1840,16 @@ ProcGetMotionEvents(ClientPtr client)
     WindowPtr pWin;
     xTimecoord * coords = (xTimecoord *) NULL;
     xGetMotionEventsReply rep;
-    int     i, count, xmin, xmax, ymin, ymax;
+    int i, count, xmin, xmax, ymin, ymax, rc;
     unsigned long nEvents;
     DeviceIntPtr mouse = inputInfo.pointer;
     TimeStamp start, stop;
     REQUEST(xGetMotionEventsReq);
 
     REQUEST_SIZE_MATCH(xGetMotionEventsReq);
-    pWin = SecurityLookupWindow(stuff->window, client, TRUE);
-    if (!pWin)
-	return BadWindow;
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+    if (rc != Success)
+	return rc;
     if (mouse->valuator->motionHintWindow)
 	MaybeStopHint(mouse, client);
     rep.type = X_Reply;
diff --git a/dix/dispatch.c b/dix/dispatch.c
index 0421886..3060a4c 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -554,17 +554,16 @@ ProcBadRequest(ClientPtr client)
 int
 ProcCreateWindow(ClientPtr client)
 {
-    register WindowPtr pParent, pWin;
+    WindowPtr pParent, pWin;
     REQUEST(xCreateWindowReq);
-    int result;
-    int len;
+    int result, len, rc;
 
     REQUEST_AT_LEAST_SIZE(xCreateWindowReq);
     
     LEGAL_NEW_RESOURCE(stuff->wid, client);
-    if (!(pParent = (WindowPtr)SecurityLookupWindow(stuff->parent, client,
-						    DixWriteAccess)))
-        return BadWindow;
+    rc = dixLookupWindow(&pParent, stuff->parent, client, DixWriteAccess);
+    if (rc != Success)
+        return rc;
     len = client->req_len - (sizeof(xCreateWindowReq) >> 2);
     if (Ones(stuff->mask) != len)
         return BadLength;
@@ -597,16 +596,15 @@ ProcCreateWindow(ClientPtr client)
 int
 ProcChangeWindowAttributes(register ClientPtr client)
 {
-    register WindowPtr pWin;
+    WindowPtr pWin;
     REQUEST(xChangeWindowAttributesReq);
     register int result;
-    int len;
+    int len, rc;
 
     REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq);
-    pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
-					   DixWriteAccess);
-    if (!pWin)
-        return(BadWindow);
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess);
+    if (rc != Success)
+        return rc;
     len = client->req_len - (sizeof(xChangeWindowAttributesReq) >> 2);
     if (len != Ones(stuff->valueMask))
         return BadLength;
@@ -623,15 +621,15 @@ ProcChangeWindowAttributes(register Clie
 int
 ProcGetWindowAttributes(register ClientPtr client)
 {
-    register WindowPtr pWin;
+    WindowPtr pWin;
     REQUEST(xResourceReq);
     xGetWindowAttributesReply wa;
+    int rc;
 
     REQUEST_SIZE_MATCH(xResourceReq);
-    pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
-					   DixReadAccess);
-    if (!pWin)
-        return(BadWindow);
+    rc = dixLookupWindow(&pWin, stuff->id, client, DixReadAccess);
+    if (rc != Success)
+	return rc;
     GetWindowAttributes(pWin, client, &wa);
     WriteReplyToClient(client, sizeof(xGetWindowAttributesReply), &wa);
     return(client->noClientException);
@@ -640,14 +638,14 @@ ProcGetWindowAttributes(register ClientP
 int
 ProcDestroyWindow(register ClientPtr client)
 {
-    register WindowPtr pWin;
+    WindowPtr pWin;
     REQUEST(xResourceReq);
+    int rc;
 
     REQUEST_SIZE_MATCH(xResourceReq);
-    pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
-					   DixDestroyAccess);
-    if (!pWin)
-        return(BadWindow);
+    rc = dixLookupWindow(&pWin, stuff->id, client, DixDestroyAccess);
+    if (rc != Success)
+	return rc;
     if (pWin->parent)
 	FreeResource(stuff->id, RT_NONE);
     return(client->noClientException);
@@ -656,14 +654,14 @@ ProcDestroyWindow(register ClientPtr cli
 int
 ProcDestroySubwindows(register ClientPtr client)
 {
-    register WindowPtr pWin;
+    WindowPtr pWin;
     REQUEST(xResourceReq);
+    int rc;
 
     REQUEST_SIZE_MATCH(xResourceReq);
-    pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
-					   DixDestroyAccess);
-    if (!pWin)
-        return(BadWindow);
+    rc = dixLookupWindow(&pWin, stuff->id, client, DixDestroyAccess);
+    if (rc != Success)
+	return rc;
     DestroySubwindows(pWin, client);
     return(client->noClientException);
 }
@@ -671,15 +669,14 @@ ProcDestroySubwindows(register ClientPtr
 int
 ProcChangeSaveSet(register ClientPtr client)
 {
-    register WindowPtr pWin;
+    WindowPtr pWin;
     REQUEST(xChangeSaveSetReq);
-    register int result;
+    register int result, rc;
 		  
     REQUEST_SIZE_MATCH(xChangeSaveSetReq);
-    pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
-					   DixReadAccess);
-    if (!pWin)
-        return(BadWindow);
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
+    if (rc != Success)
+        return rc;
     if (client->clientAsMask == (CLIENT_BITS(pWin->drawable.id)))
         return BadMatch;
     if ((stuff->mode == SetModeInsert) || (stuff->mode == SetModeDelete))
@@ -700,19 +697,17 @@ ProcChangeSaveSet(register ClientPtr cli
 int
 ProcReparentWindow(register ClientPtr client)
 {
-    register WindowPtr pWin, pParent;
+    WindowPtr pWin, pParent;
     REQUEST(xReparentWindowReq);
-    register int result;
+    register int result, rc;
 
     REQUEST_SIZE_MATCH(xReparentWindowReq);
-    pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
-					   DixWriteAccess);
-    if (!pWin)
-        return(BadWindow);
-    pParent = (WindowPtr)SecurityLookupWindow(stuff->parent, client,
-					      DixWriteAccess);
-    if (!pParent)
-        return(BadWindow);
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess);
+    if (rc != Success)
+        return rc;
+    rc = dixLookupWindow(&pParent, stuff->parent, client, DixWriteAccess);
+    if (rc != Success)
+        return rc;
     if (SAME_SCREENS(pWin->drawable, pParent->drawable))
     {
         if ((pWin->backgroundState == ParentRelative) &&
@@ -735,14 +730,14 @@ ProcReparentWindow(register ClientPtr cl
 int
 ProcMapWindow(register ClientPtr client)
 {
-    register WindowPtr pWin;
+    WindowPtr pWin;
     REQUEST(xResourceReq);
+    int rc;
 
     REQUEST_SIZE_MATCH(xResourceReq);
-    pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
-					   DixReadAccess);
-    if (!pWin)
-        return(BadWindow);
+    rc = dixLookupWindow(&pWin, stuff->id, client, DixReadAccess);
+    if (rc != Success)
+        return rc;
     MapWindow(pWin, client);
            /* update cache to say it is mapped */
     return(client->noClientException);
@@ -751,14 +746,14 @@ ProcMapWindow(register ClientPtr client)
 int
 ProcMapSubwindows(register ClientPtr client)
 {
-    register WindowPtr pWin;
+    WindowPtr pWin;
     REQUEST(xResourceReq);
+    int rc;
 
     REQUEST_SIZE_MATCH(xResourceReq);
-    pWin = (WindowPtr)SecurityLookupWindow( stuff->id, client,
-					    DixReadAccess);
-    if (!pWin)
-        return(BadWindow);
+    rc = dixLookupWindow(&pWin, stuff->id, client, DixReadAccess);
+    if (rc != Success)
+        return rc;
     MapSubwindows(pWin, client);
            /* update cache to say it is mapped */
     return(client->noClientException);
@@ -767,14 +762,14 @@ ProcMapSubwindows(register ClientPtr cli
 int
 ProcUnmapWindow(register ClientPtr client)
 {
-    register WindowPtr pWin;
+    WindowPtr pWin;
     REQUEST(xResourceReq);
+    int rc;
 
     REQUEST_SIZE_MATCH(xResourceReq);
-    pWin = (WindowPtr)SecurityLookupWindow( stuff->id, client,
-					    DixReadAccess);
-    if (!pWin)
-        return(BadWindow);
+    rc = dixLookupWindow(&pWin, stuff->id, client, DixReadAccess);
+    if (rc != Success)
+        return rc;
     UnmapWindow(pWin, FALSE);
            /* update cache to say it is mapped */
     return(client->noClientException);
@@ -783,14 +778,14 @@ ProcUnmapWindow(register ClientPtr clien
 int
 ProcUnmapSubwindows(register ClientPtr client)
 {
-    register WindowPtr pWin;
+    WindowPtr pWin;
     REQUEST(xResourceReq);
+    int rc;
 
     REQUEST_SIZE_MATCH(xResourceReq);
-    pWin = (WindowPtr)SecurityLookupWindow( stuff->id, client,
-					    DixReadAccess);
-    if (!pWin)
-        return(BadWindow);
+    rc = dixLookupWindow(&pWin, stuff->id, client, DixReadAccess);
+    if (rc != Success)
+        return rc;
     UnmapSubwindows(pWin);
     return(client->noClientException);
 }
@@ -798,16 +793,15 @@ ProcUnmapSubwindows(register ClientPtr c
 int
 ProcConfigureWindow(register ClientPtr client)
 {
-    register WindowPtr pWin;
+    WindowPtr pWin;
     REQUEST(xConfigureWindowReq);
     register int result;
-    int len;
+    int len, rc;
 
     REQUEST_AT_LEAST_SIZE(xConfigureWindowReq);
-    pWin = (WindowPtr)SecurityLookupWindow( stuff->window, client,
-					    DixWriteAccess);
-    if (!pWin)
-        return(BadWindow);
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess);
+    if (rc != Success)
+        return rc;
     len = client->req_len - (sizeof(xConfigureWindowReq) >> 2);
     if (Ones((Mask)stuff->mask) != len)
         return BadLength;
@@ -822,8 +816,9 @@ ProcConfigureWindow(register ClientPtr c
 int
 ProcCirculateWindow(register ClientPtr client)
 {
-    register WindowPtr pWin;
+    WindowPtr pWin;
     REQUEST(xCirculateWindowReq);
+    int rc;
 
     REQUEST_SIZE_MATCH(xCirculateWindowReq);
     if ((stuff->direction != RaiseLowest) &&
@@ -832,10 +827,9 @@ ProcCirculateWindow(register ClientPtr c
 	client->errorValue = stuff->direction;
         return BadValue;
     }
-    pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
-					   DixWriteAccess);
-    if (!pWin)
-        return(BadWindow);
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess);
+    if (rc != Success)
+        return rc;
     CirculateWindow(pWin, (int)stuff->direction, client);
     return(client->noClientException);
 }
@@ -903,16 +897,15 @@ int
 ProcQueryTree(register ClientPtr client)
 {
     xQueryTreeReply reply;
-    int numChildren = 0;
-    register WindowPtr pChild, pWin, pHead;
+    int rc, numChildren = 0;
+    WindowPtr pChild, pWin, pHead;
     Window  *childIDs = (Window *)NULL;
     REQUEST(xResourceReq);
 
     REQUEST_SIZE_MATCH(xResourceReq);
-    pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
-					   DixReadAccess);
-    if (!pWin)
-        return(BadWindow);
+    rc = dixLookupWindow(&pWin, stuff->id, client, DixReadAccess);
+    if (rc != Success)
+        return rc;
     reply.type = X_Reply;
     reply.root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id;
     reply.sequenceNumber = client->sequence;
@@ -1025,10 +1018,9 @@ ProcSetSelectionOwner(register ClientPtr
     	return Success;
     if (stuff->window != None)
     {
-        pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
-					       DixReadAccess);
-        if (!pWin)
-            return(BadWindow);
+	int rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
+        if (rc != Success)
+            return rc;
     }
     else
         pWin = (WindowPtr)None;
@@ -1142,12 +1134,12 @@ ProcConvertSelection(register ClientPtr 
     xEvent event;
     WindowPtr pWin;
     REQUEST(xConvertSelectionReq);
+    int rc;
 
     REQUEST_SIZE_MATCH(xConvertSelectionReq);
-    pWin = (WindowPtr)SecurityLookupWindow(stuff->requestor, client,
-					   DixReadAccess);
-    if (!pWin)
-        return(BadWindow);
+    rc = dixLookupWindow(&pWin, stuff->requestor, client, DixReadAccess);
+    if (rc != Success)
+        return rc;
 
     paramsOkay = (ValidAtom(stuff->selection) && ValidAtom(stuff->target));
     if (stuff->property != None)
@@ -1262,18 +1254,17 @@ ProcTranslateCoords(register ClientPtr c
 {
     REQUEST(xTranslateCoordsReq);
 
-    register WindowPtr pWin, pDst;
+    WindowPtr pWin, pDst;
     xTranslateCoordsReply rep;
+    int rc;
 
     REQUEST_SIZE_MATCH(xTranslateCoordsReq);
-    pWin = (WindowPtr)SecurityLookupWindow(stuff->srcWid, client,
-					   DixReadAccess);
-    if (!pWin)
-        return(BadWindow);
-    pDst = (WindowPtr)SecurityLookupWindow(stuff->dstWid, client,
-					   DixReadAccess);
-    if (!pDst)
-        return(BadWindow);
+    rc = dixLookupWindow(&pWin, stuff->srcWid, client, DixReadAccess);
+    if (rc != Success)
+        return rc;
+    rc = dixLookupWindow(&pDst, stuff->dstWid, client, DixReadAccess);
+    if (rc != Success)
+        return rc;
     rep.type = X_Reply;
     rep.length = 0;
     rep.sequenceNumber = client->sequence;
@@ -1762,13 +1753,13 @@ int
 ProcClearToBackground(register ClientPtr client)
 {
     REQUEST(xClearAreaReq);
-    register WindowPtr pWin;
+    WindowPtr pWin;
+    int rc;
 
     REQUEST_SIZE_MATCH(xClearAreaReq);
-    pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
-					   DixWriteAccess);
-    if (!pWin)
-        return(BadWindow);
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess);
+    if (rc != Success)
+        return rc;
     if (pWin->drawable.class == InputOnly)
     {
 	client->errorValue = stuff->window;
@@ -2496,7 +2487,7 @@ ProcCreateColormap(register ClientPtr cl
     VisualPtr	pVisual;
     ColormapPtr	pmap;
     Colormap	mid;
-    register WindowPtr   pWin;
+    WindowPtr   pWin;
     ScreenPtr pScreen;
     REQUEST(xCreateColormapReq);
     int i, result;
@@ -2510,10 +2501,9 @@ ProcCreateColormap(register ClientPtr cl
     }
     mid = stuff->mid;
     LEGAL_NEW_RESOURCE(mid, client);
-    pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
-					   DixReadAccess);
-    if (!pWin)
-        return(BadWindow);
+    result = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
+    if (result != Success)
+        return result;
 
     pScreen = pWin->drawable.pScreen;
     for (i = 0, pVisual = pScreen->visuals;
@@ -2631,16 +2621,14 @@ int
 ProcListInstalledColormaps(register ClientPtr client)
 {
     xListInstalledColormapsReply *preply; 
-    int nummaps;
+    int nummaps, rc;
     WindowPtr pWin;
     REQUEST(xResourceReq);
 
     REQUEST_SIZE_MATCH(xResourceReq);
-    pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
-					   DixReadAccess);
-
-    if (!pWin)
-        return(BadWindow);
+    rc = dixLookupWindow(&pWin, stuff->id, client, DixReadAccess);
+    if (rc != Success)
+        return rc;
 
     preply = (xListInstalledColormapsReply *) 
 		ALLOCATE_LOCAL(sizeof(xListInstalledColormapsReply) +
diff --git a/dix/events.c b/dix/events.c
index c7cf73e..0053f42 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -2228,16 +2228,15 @@ static int
 XineramaWarpPointer(ClientPtr client)
 {
     WindowPtr	dest = NULL;
-    int		x, y;
+    int		x, y, rc;
 
     REQUEST(xWarpPointerReq);
 
 
-    if (stuff->dstWid != None)
-    {
-	dest = SecurityLookupWindow(stuff->dstWid, client, DixReadAccess);
-	if (!dest)
-	    return BadWindow;
+    if (stuff->dstWid != None) {
+	rc = dixLookupWindow(&dest, stuff->dstWid, client, DixReadAccess);
+	if (rc != Success)
+	    return rc;
     }
     x = sprite.hotPhys.x;
     y = sprite.hotPhys.y;
@@ -2248,8 +2247,9 @@ XineramaWarpPointer(ClientPtr client)
  	XID 	winID = stuff->srcWid;
         WindowPtr source;
 	
-	source = SecurityLookupWindow(winID, client, DixReadAccess);
-	if (!source) return BadWindow;
+	rc = dixLookupWindow(&source, winID, client, DixReadAccess);
+	if (rc != Success)
+	    return rc;
 
 	winX = source->drawable.x;
 	winY = source->drawable.y;
@@ -2301,7 +2301,7 @@ int
 ProcWarpPointer(ClientPtr client)
 {
     WindowPtr	dest = NULL;
-    int		x, y;
+    int		x, y, rc;
     ScreenPtr	newScreen;
 
     REQUEST(xWarpPointerReq);
@@ -2313,11 +2313,10 @@ ProcWarpPointer(ClientPtr client)
 	return XineramaWarpPointer(client);
 #endif
 
-    if (stuff->dstWid != None)
-    {
-	dest = SecurityLookupWindow(stuff->dstWid, client, DixReadAccess);
-	if (!dest)
-	    return BadWindow;
+    if (stuff->dstWid != None) {
+	rc = dixLookupWindow(&dest, stuff->dstWid, client, DixReadAccess);
+	if (rc != Success)
+	    return rc;
     }
     x = sprite.hotPhys.x;
     y = sprite.hotPhys.y;
@@ -2328,8 +2327,9 @@ ProcWarpPointer(ClientPtr client)
  	XID 	winID = stuff->srcWid;
         WindowPtr source;
 	
-	source = SecurityLookupWindow(winID, client, DixReadAccess);
-	if (!source) return BadWindow;
+	rc = dixLookupWindow(&source, winID, client, DixReadAccess);
+	if (rc != Success)
+	    return rc;
 
 	winX = source->drawable.x;
 	winY = source->drawable.y;
@@ -3532,8 +3532,8 @@ SetInputFocus(
     Bool followOK)
 {
     register FocusClassPtr focus;
-    register WindowPtr focusWin;
-    int mode;
+    WindowPtr focusWin;
+    int mode, rc;
     TimeStamp time;
 
     UpdateCurrentTime();
@@ -3550,14 +3550,12 @@ SetInputFocus(
 	focusWin = (WindowPtr)(long)focusID;
     else if ((focusID == FollowKeyboard) && followOK)
 	focusWin = inputInfo.keyboard->focus->win;
-    else if (!(focusWin = SecurityLookupWindow(focusID, client,
-					       DixReadAccess)))
-	return BadWindow;
-    else
-    {
+    else {
+	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 
 	unviewable window. */
-
 	if(!focusWin->realized)
 	    return(BadMatch);
     }
@@ -3646,6 +3644,7 @@ ProcGrabPointer(ClientPtr client)
     CursorPtr cursor, oldCursor;
     REQUEST(xGrabPointerReq);
     TimeStamp time;
+    int rc;
 
     REQUEST_SIZE_MATCH(xGrabPointerReq);
     UpdateCurrentTime();
@@ -3671,17 +3670,17 @@ ProcGrabPointer(ClientPtr client)
 	client->errorValue = stuff->eventMask;
         return BadValue;
     }
-    pWin = SecurityLookupWindow(stuff->grabWindow, client, DixReadAccess);
-    if (!pWin)
-	return BadWindow;
+    rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixReadAccess);
+    if (rc != Success)
+	return rc;
     if (stuff->confineTo == None)
 	confineTo = NullWindow;
     else 
     {
-	confineTo = SecurityLookupWindow(stuff->confineTo, client,
-					 DixReadAccess);
-	if (!confineTo)
-	    return BadWindow;
+	rc = dixLookupWindow(&confineTo, stuff->confineTo, client,
+			     DixReadAccess);
+	if (rc != Success)
+	    return rc;
     }
     if (stuff->cursor == None)
 	cursor = NullCursor;
@@ -3812,9 +3811,10 @@ GrabDevice(register ClientPtr client, re
            unsigned this_mode, unsigned other_mode, Window grabWindow, 
            unsigned ownerEvents, Time ctime, Mask mask, CARD8 *status)
 {
-    register WindowPtr pWin;
+    WindowPtr pWin;
     register GrabPtr grab;
     TimeStamp time;
+    int rc;
 
     UpdateCurrentTime();
     if ((this_mode != GrabModeSync) && (this_mode != GrabModeAsync))
@@ -3832,9 +3832,9 @@ GrabDevice(register ClientPtr client, re
 	client->errorValue = ownerEvents;
         return BadValue;
     }
-    pWin = SecurityLookupWindow(grabWindow, client, DixReadAccess);
-    if (!pWin)
-	return BadWindow;
+    rc = dixLookupWindow(&pWin, grabWindow, client, DixReadAccess);
+    if (rc != Success)
+	return rc;
     time = ClientTimeToServerTime(ctime);
     grab = dev->grab;
     if (grab && !SameClient(grab, client))
@@ -3918,11 +3918,12 @@ ProcQueryPointer(ClientPtr client)
     WindowPtr pWin, t;
     REQUEST(xResourceReq);
     DeviceIntPtr mouse = inputInfo.pointer;
+    int rc;
 
     REQUEST_SIZE_MATCH(xResourceReq);
-    pWin = SecurityLookupWindow(stuff->id, client, DixReadAccess);
-    if (!pWin)
-	return BadWindow;
+    rc = dixLookupWindow(&pWin, stuff->id, client, DixReadAccess);
+    if (rc != Success)
+	return rc;
     if (mouse->valuator->motionHintWindow)
 	MaybeStopHint(mouse, client);
     rep.type = X_Reply;
@@ -4086,8 +4087,8 @@ ProcSendEvent(ClientPtr client)
 	    effectiveFocus = pWin = inputFocus;
     }
     else
-	pWin = SecurityLookupWindow(stuff->destination, client,
-				    DixReadAccess);
+	dixLookupWindow(&pWin, stuff->destination, client, DixReadAccess);
+
     if (!pWin)
 	return BadWindow;
     if ((stuff->propagate != xFalse) && (stuff->propagate != xTrue))
@@ -4123,11 +4124,12 @@ ProcUngrabKey(ClientPtr client)
     WindowPtr pWin;
     GrabRec tempGrab;
     DeviceIntPtr keybd = inputInfo.keyboard;
+    int rc;
 
     REQUEST_SIZE_MATCH(xUngrabKeyReq);
-    pWin = SecurityLookupWindow(stuff->grabWindow, client, DixReadAccess);
-    if (!pWin)
-	return BadWindow;
+    rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixReadAccess);
+    if (rc != Success)
+	return rc;
 
     if (((stuff->key > keybd->key->curKeySyms.maxKeyCode) ||
 	 (stuff->key < keybd->key->curKeySyms.minKeyCode))
@@ -4164,6 +4166,7 @@ ProcGrabKey(ClientPtr client)
     REQUEST(xGrabKeyReq);
     GrabPtr grab;
     DeviceIntPtr keybd = inputInfo.keyboard;
+    int rc;
 
     REQUEST_SIZE_MATCH(xGrabKeyReq);
     if ((stuff->ownerEvents != xTrue) && (stuff->ownerEvents != xFalse))
@@ -4196,9 +4199,9 @@ ProcGrabKey(ClientPtr client)
 	client->errorValue = stuff->modifiers;
 	return BadValue;
     }
-    pWin = SecurityLookupWindow(stuff->grabWindow, client, DixReadAccess);
-    if (!pWin)
-	return BadWindow;
+    rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixReadAccess);
+    if (rc != Success)
+	return rc;
 
     grab = CreateGrab(client->index, keybd, pWin, 
 	(Mask)(KeyPressMask | KeyReleaseMask), (Bool)stuff->ownerEvents,
@@ -4218,6 +4221,7 @@ ProcGrabButton(ClientPtr client)
     REQUEST(xGrabButtonReq);
     CursorPtr cursor;
     GrabPtr grab;
+    int rc;
 
     REQUEST_SIZE_MATCH(xGrabButtonReq);
     if ((stuff->pointerMode != GrabModeSync) &&
@@ -4248,16 +4252,16 @@ ProcGrabButton(ClientPtr client)
 	client->errorValue = stuff->eventMask;
         return BadValue;
     }
-    pWin = SecurityLookupWindow(stuff->grabWindow, client, DixReadAccess);
-    if (!pWin)
-	return BadWindow;
+    rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixReadAccess);
+    if (rc != Success)
+	return rc;
     if (stuff->confineTo == None)
        confineTo = NullWindow;
     else {
-	confineTo = SecurityLookupWindow(stuff->confineTo, client,
-					 DixReadAccess);
-	if (!confineTo)
-	    return BadWindow;
+	rc = dixLookupWindow(&confineTo, stuff->confineTo, client,
+			     DixReadAccess);
+	if (rc != Success)
+	    return rc;
     }
     if (stuff->cursor == None)
 	cursor = NullCursor;
@@ -4289,6 +4293,7 @@ ProcUngrabButton(ClientPtr client)
     REQUEST(xUngrabButtonReq);
     WindowPtr pWin;
     GrabRec tempGrab;
+    int rc;
 
     REQUEST_SIZE_MATCH(xUngrabButtonReq);
     if ((stuff->modifiers != AnyModifier) &&
@@ -4297,9 +4302,9 @@ ProcUngrabButton(ClientPtr client)
 	client->errorValue = stuff->modifiers;
 	return BadValue;
     }
-    pWin = SecurityLookupWindow(stuff->grabWindow, client, DixReadAccess);
-    if (!pWin)
-	return BadWindow;
+    rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixReadAccess);
+    if (rc != Success)
+	return rc;
     tempGrab.resource = client->clientAsMask;
     tempGrab.device = inputInfo.pointer;
     tempGrab.window = pWin;
diff --git a/dix/property.c b/dix/property.c
index 5c1e957..d402849 100644
--- a/dix/property.c
+++ b/dix/property.c
@@ -94,7 +94,7 @@ PrintPropertys(WindowPtr pWin)
 int
 ProcRotateProperties(ClientPtr client)
 {
-    int     i, j, delta;
+    int     i, j, delta, rc;
     REQUEST(xRotatePropertiesReq);
     WindowPtr pWin;
     register    Atom * atoms;
@@ -104,10 +104,9 @@ ProcRotateProperties(ClientPtr client)
 
     REQUEST_FIXED_SIZE(xRotatePropertiesReq, stuff->nAtoms << 2);
     UpdateCurrentTime();
-    pWin = (WindowPtr) SecurityLookupWindow(stuff->window, client,
-					    DixWriteAccess);
-    if (!pWin)
-        return(BadWindow);
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess);
+    if (rc != Success)
+        return rc;
     if (!stuff->nAtoms)
 	return(Success);
     atoms = (Atom *) & stuff[1];
@@ -181,9 +180,7 @@ ProcChangeProperty(ClientPtr client)
     WindowPtr pWin;
     char format, mode;
     unsigned long len;
-    int sizeInBytes;
-    int totalSize;
-    int err;
+    int sizeInBytes, totalSize, err;
     REQUEST(xChangePropertyReq);
 
     REQUEST_AT_LEAST_SIZE(xChangePropertyReq);
@@ -208,10 +205,9 @@ ProcChangeProperty(ClientPtr client)
     totalSize = len * sizeInBytes;
     REQUEST_FIXED_SIZE(xChangePropertyReq, totalSize);
 
-    pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
-					   DixWriteAccess);
-    if (!pWin)
-	return(BadWindow);
+    err = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess);
+    if (err != Success)
+	return err;
     if (!ValidAtom(stuff->property))
     {
 	client->errorValue = stuff->property;
@@ -445,7 +441,7 @@ int
 ProcGetProperty(ClientPtr client)
 {
     PropertyPtr pProp, prevProp;
-    unsigned long n, len, ind;
+    unsigned long n, len, ind, rc;
     WindowPtr pWin;
     xGetPropertyReply reply;
     Mask access_mode = DixReadAccess;
@@ -454,10 +450,9 @@ ProcGetProperty(ClientPtr client)
     REQUEST_SIZE_MATCH(xGetPropertyReq);
     if (stuff->delete)
 	UpdateCurrentTime();
-    pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
-					   DixReadAccess);
-    if (!pWin)
-	return BadWindow;
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
+    if (rc != Success)
+	return rc;
 
     if (!ValidAtom(stuff->property))
     {
@@ -585,16 +580,15 @@ ProcListProperties(ClientPtr client)
 {
     Atom *pAtoms = NULL, *temppAtoms;
     xListPropertiesReply xlpr;
-    int	numProps = 0;
+    int	rc, numProps = 0;
     WindowPtr pWin;
     PropertyPtr pProp;
     REQUEST(xResourceReq);
 
     REQUEST_SIZE_MATCH(xResourceReq);
-    pWin = (WindowPtr)SecurityLookupWindow(stuff->id, client,
-					   DixReadAccess);
-    if (!pWin)
-        return(BadWindow);
+    rc = dixLookupWindow(&pWin, stuff->id, client, DixReadAccess);
+    if (rc != Success)
+        return rc;
 
     pProp = wUserProps (pWin);
     while (pProp)
@@ -636,10 +630,9 @@ ProcDeleteProperty(register ClientPtr cl
               
     REQUEST_SIZE_MATCH(xDeletePropertyReq);
     UpdateCurrentTime();
-    pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
-					   DixWriteAccess);
-    if (!pWin)
-        return(BadWindow);
+    result = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess);
+    if (result != Success)
+        return result;
     if (!ValidAtom(stuff->property))
     {
 	client->errorValue = stuff->property;
diff --git a/hw/darwin/quartz/applewm.c b/hw/darwin/quartz/applewm.c
index a9d8b56..224d6c5 100644
--- a/hw/darwin/quartz/applewm.c
+++ b/hw/darwin/quartz/applewm.c
@@ -490,11 +490,9 @@ ProcAppleWMSetWindowLevel(
 
     REQUEST_SIZE_MATCH(xAppleWMSetWindowLevelReq);
 
-    if (!(pWin = SecurityLookupWindow((Drawable)stuff->window,
-                                      client, DixReadAccess)))
-    {
+    if (Success != dixLookupWindow(&pWin, stuff->window, client,
+				   DixReadAccess))
         return BadValue;
-    }
 
     if (stuff->level < 0 || stuff->level >= AppleWMNumWindowLevels) {
         return BadValue;
@@ -602,11 +600,9 @@ ProcAppleWMFrameDraw(
 
     REQUEST_AT_LEAST_SIZE(xAppleWMFrameDrawReq);
 
-    if (!(pWin = SecurityLookupWindow((Drawable)stuff->window,
-                                      client, DixReadAccess)))
-    {
+    if (Success != dixLookupWindow(&pWin, stuff->window, client,
+				   DixReadAccess))
         return BadValue;
-    }
 
     ir = make_box (stuff->ix, stuff->iy, stuff->iw, stuff->ih);
     or = make_box (stuff->ox, stuff->oy, stuff->ow, stuff->oh);
diff --git a/hw/dmx/dmx.c b/hw/dmx/dmx.c
index 02e8b1e..b7c81ee 100644
--- a/hw/dmx/dmx.c
+++ b/hw/dmx/dmx.c
@@ -286,8 +286,8 @@ static int ProcDMXForceWindowCreation(Cl
             return -1;           /* BadWindow */
 
         FOR_NSCREENS(i) {
-            if (!(pWin = SecurityLookupWindow(win->info[i].id, client,
-                                              DixReadAccess)))
+            if (Success != dixLookupWindow(&pWin, win->info[i].id, client,
+					   DixReadAccess))
                 return -1;       /* BadWindow */
 
             dmxForceWindowCreation(pWin);
@@ -296,8 +296,8 @@ static int ProcDMXForceWindowCreation(Cl
     }
 #endif
 
-    if (!(pWin = SecurityLookupWindow(stuff->window, client,
-                                      DixReadAccess)))
+    if (Success != dixLookupWindow(&pWin, stuff->window, client,
+				   DixReadAccess))
         return -1;               /* BadWindow */
 
     dmxForceWindowCreation(pWin);
@@ -560,8 +560,8 @@ static int dmxPopulatePanoramiX(ClientPt
         return -1;               /* BadWindow */
     
     FOR_NSCREENS(i) {
-        if (!(pWin = SecurityLookupWindow(win->info[i].id, client,
-                                          DixReadAccess)))
+        if (Success != dixLookupWindow(&pWin, win->info[i].id, client,
+				       DixReadAccess))
             return -1;          /* BadWindow */
         if (dmxGetWindowAttributes(pWin, &attr)) {
             screens[count] = attr.screen;
@@ -587,7 +587,7 @@ static int dmxPopulate(ClientPtr client,
                                     pos, vis);
 #endif
     
-    if (!(pWin = SecurityLookupWindow(window, client, DixReadAccess)))
+    if (Success != dixLookupWindow(&pWin, window, client, DixReadAccess))
         return -1;               /* BadWindow */
 
     dmxGetWindowAttributes(pWin, &attr);
diff --git a/hw/dmx/glxProxy/glxcmds.c b/hw/dmx/glxProxy/glxcmds.c
index 20a02a1..aa9d831 100644
--- a/hw/dmx/glxProxy/glxcmds.c
+++ b/hw/dmx/glxProxy/glxcmds.c
@@ -1137,9 +1137,7 @@ static int MakeCurrent(__GLXclientState 
        }
 #ifdef PANORAMIX
        else if (pXinDraw) {
-	  pWin = (WindowPtr)SecurityLookupWindow(pXinDraw->info[s].id,
-		                                 client,
-                                                 DixReadAccess);
+	  dixLookupWindow(&pWin, pXinDraw->info[s].id, client, DixReadAccess);
        }
 #endif
        else if (pGlxWindow) {
@@ -1195,9 +1193,8 @@ static int MakeCurrent(__GLXclientState 
 	  }
 #ifdef PANORAMIX
 	  else if (pXinReadDraw) {
-   	     pReadWin = (WindowPtr)SecurityLookupWindow(pXinReadDraw->info[s].id,
-		   client,
-		   DixReadAccess);
+	     dixLookupWindow(&pReadWin, pXinReadDraw->info[s].id, client,
+			     DixReadAccess);
    	  }
 #endif
 	  else if (pGlxReadWindow) {
@@ -2058,9 +2055,7 @@ int __glXDoSwapBuffers(__GLXclientState 
        }
 #ifdef PANORAMIX
        else if (pXinDraw) {
-	  pWin = (WindowPtr)SecurityLookupWindow(pXinDraw->info[s].id,
-		                                 client,
-                                                 DixReadAccess);
+	  dixLookupWindow(&pWin, pXinDraw->info[s].id, client, DixReadAccess);
        }
 #endif
        else if (pGlxWindow) {
@@ -3359,9 +3354,8 @@ int __glXGetDrawableAttributes(__GLXclie
 	     return __glXBadDrawable;
 	  }
 
-	  pWin = (WindowPtr)SecurityLookupWindow(pXinDraw->info[screen].id,
-		client,
-		DixReadAccess);
+	  dixLookupWindow(&pWin, pXinDraw->info[screen].id, client,
+			  DixReadAccess);
        }
 #endif
 
@@ -3521,9 +3515,8 @@ int __glXChangeDrawableAttributes(__GLXc
 	     return __glXBadDrawable;
 	  }
 
-	  pWin = (WindowPtr)SecurityLookupWindow(pXinDraw->info[screen].id,
-		client,
-		DixReadAccess);
+	  dixLookupWindow(&pWin, pXinDraw->info[screen].id, client,
+			  DixReadAccess);
        }
 #endif
 
diff --git a/hw/xwin/winclipboardwrappers.c b/hw/xwin/winclipboardwrappers.c
index e9bcea9..825d3dc 100755
--- a/hw/xwin/winclipboardwrappers.c
+++ b/hw/xwin/winclipboardwrappers.c
@@ -344,13 +344,11 @@ winProcSetSelectionOwner (ClientPtr clie
   if (None != stuff->window)
     {
       /* Grab the Window from the request */
-      pWindow = (WindowPtr) SecurityLookupWindow (stuff->window, client,
-						  DixReadAccess);
-      if (!pWindow)
-	{
+      int rc = dixLookupWindow(&pWindow, stuff->window, client, DixReadAccess);
+      if (rc != Success) {
 	  ErrorF ("winProcSetSelectionOwner - Found BadWindow, aborting.\n");
 	  goto winProcSetSelectionOwner_Done;
-	}
+      }
     }
 
   /* Now we either have a valid window or None */
diff --git a/hw/xwin/winwindowswm.c b/hw/xwin/winwindowswm.c
index ac92e26..e1994de 100755
--- a/hw/xwin/winwindowswm.c
+++ b/hw/xwin/winwindowswm.c
@@ -441,7 +441,7 @@ ProcWindowsWMFrameDraw (register ClientP
   WindowPtr pWin;
   win32RootlessWindowPtr pRLWinPriv;
   RECT rcNew;
-  int nCmdShow;
+  int nCmdShow, rc;
   RegionRec newShape;
   ScreenPtr pScreen;
 
@@ -450,11 +450,9 @@ ProcWindowsWMFrameDraw (register ClientP
 #if CYGMULTIWINDOW_DEBUG
   ErrorF ("ProcWindowsWMFrameDraw\n");
 #endif
-  if (!(pWin = SecurityLookupWindow((Drawable)stuff->window,
-				    client, DixReadAccess)))
-    {
-      return BadValue;
-    }
+  rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
+  if (rc != Success)
+      return rc;
 #if CYGMULTIWINDOW_DEBUG
   ErrorF ("ProcWindowsWMFrameDraw - Window found\n");
 #endif
@@ -538,6 +536,7 @@ ProcWindowsWMFrameSetTitle(
   REQUEST(xWindowsWMFrameSetTitleReq);
   WindowPtr pWin;
   win32RootlessWindowPtr pRLWinPriv;
+  int rc;
 
 #if CYGMULTIWINDOW_DEBUG
   ErrorF ("ProcWindowsWMFrameSetTitle\n");
@@ -545,11 +544,9 @@ ProcWindowsWMFrameSetTitle(
 
   REQUEST_AT_LEAST_SIZE(xWindowsWMFrameSetTitleReq);
 
-  if (!(pWin = SecurityLookupWindow((Drawable)stuff->window,
-				    client, DixReadAccess)))
-    {
-      return BadValue;
-    }
+  rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
+  if (rc != Success)
+      return rc;
 #if CYGMULTIWINDOW_DEBUG
   ErrorF ("ProcWindowsWMFrameSetTitle - Window found\n");
 #endif
diff --git a/randr/rrdispatch.c b/randr/rrdispatch.c
index b1ec68b..7f98965 100644
--- a/randr/rrdispatch.c
+++ b/randr/rrdispatch.c
@@ -70,11 +70,12 @@ ProcRRSelectInput (ClientPtr client)
     WindowPtr	pWin;
     RREventPtr	pRREvent, *pHead;
     XID		clientResource;
+    int		rc;
 
     REQUEST_SIZE_MATCH(xRRSelectInputReq);
-    pWin = SecurityLookupWindow (stuff->window, client, DixWriteAccess);
-    if (!pWin)
-	return BadWindow;
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess);
+    if (rc != Success)
+	return rc;
     pHead = (RREventPtr *)SecurityLookupIDByType(client,
 						 pWin->drawable.id, RREventType,
 						 DixWriteAccess);
diff --git a/randr/rrscreen.c b/randr/rrscreen.c
index f1d8fc5..6f7afaf 100644
--- a/randr/rrscreen.c
+++ b/randr/rrscreen.c
@@ -217,13 +217,12 @@ ProcRRGetScreenSizeRange (ClientPtr clie
     WindowPtr			pWin;
     ScreenPtr			pScreen;
     rrScrPrivPtr		pScrPriv;
+    int				rc;
     
     REQUEST_SIZE_MATCH(xRRGetScreenInfoReq);
-    pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
-					   DixReadAccess);
-
-    if (!pWin)
-	return BadWindow;
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
+    if (rc != Success)
+	return rc;
 
     pScreen = pWin->drawable.pScreen;
     pScrPriv = rrGetScrPriv(pScreen);
@@ -268,14 +267,12 @@ ProcRRSetScreenSize (ClientPtr client)
     WindowPtr		pWin;
     ScreenPtr		pScreen;
     rrScrPrivPtr	pScrPriv;
-    int			i;
+    int			i, rc;
     
     REQUEST_SIZE_MATCH(xRRSetScreenSizeReq);
-    pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
-					   DixReadAccess);
-
-    if (!pWin)
-	return BadWindow;
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
+    if (rc != Success)
+	return rc;
 
     pScreen = pWin->drawable.pScreen;
     pScrPriv = rrGetScrPriv(pScreen);
@@ -336,19 +333,16 @@ ProcRRGetScreenResources (ClientPtr clie
     rrScrPrivPtr		pScrPriv;
     CARD8			*extra;
     unsigned long		extraLen;
-    int				i;
+    int				i, n, rc;
     RRCrtc			*crtcs;
     RROutput			*outputs;
     xRRModeInfo			*modeinfos;
     CARD8			*names;
-    int				n;
     
     REQUEST_SIZE_MATCH(xRRGetScreenResourcesReq);
-    pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
-					   DixReadAccess);
-
-    if (!pWin)
-	return BadWindow;
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
+    if (rc != Success)
+	return rc;
     
     pScreen = pWin->drawable.pScreen;
     pScrPriv = rrGetScrPriv(pScreen);
@@ -580,7 +574,7 @@ ProcRRGetScreenInfo (ClientPtr client)
     REQUEST(xRRGetScreenInfoReq);
     xRRGetScreenInfoReply   rep;
     WindowPtr	    	    pWin;
-    int			    n;
+    int			    n, rc;
     ScreenPtr		    pScreen;
     rrScrPrivPtr	    pScrPriv;
     CARD8		    *extra;
@@ -588,11 +582,9 @@ ProcRRGetScreenInfo (ClientPtr client)
     RROutputPtr		    output;
 
     REQUEST_SIZE_MATCH(xRRGetScreenInfoReq);
-    pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
-					   DixReadAccess);
-
-    if (!pWin)
-	return BadWindow;
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
+    if (rc != Success)
+	return rc;
 
     pScreen = pWin->drawable.pScreen;
     pScrPriv = rrGetScrPriv(pScreen);
diff --git a/xfixes/cursor.c b/xfixes/cursor.c
index 21dbcc2..86a512c 100755
--- a/xfixes/cursor.c
+++ b/xfixes/cursor.c
@@ -239,12 +239,12 @@ ProcXFixesSelectCursorInput (ClientPtr c
 {
     REQUEST (xXFixesSelectCursorInputReq);
     WindowPtr	pWin;
+    int		rc;
 
     REQUEST_SIZE_MATCH (xXFixesSelectCursorInputReq);
-    pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
-					   DixReadAccess);
-    if (!pWin)
-        return(BadWindow);
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
+    if (rc != Success)
+        return rc;
     if (stuff->eventMask & ~CursorAllEvents)
     {
 	client->errorValue = stuff->eventMask;
diff --git a/xfixes/saveset.c b/xfixes/saveset.c
index 9ad2627..ab75619 100755
--- a/xfixes/saveset.c
+++ b/xfixes/saveset.c
@@ -37,10 +37,9 @@ ProcXFixesChangeSaveSet(ClientPtr client
     REQUEST(xXFixesChangeSaveSetReq);
 		  
     REQUEST_SIZE_MATCH(xXFixesChangeSaveSetReq);
-    pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
-					   DixReadAccess);
-    if (!pWin)
-        return(BadWindow);
+    result = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
+    if (result != Success)
+        return result;
     if (client->clientAsMask == (CLIENT_BITS(pWin->drawable.id)))
         return BadMatch;
     if ((stuff->mode != SetModeInsert) && (stuff->mode != SetModeDelete))
diff --git a/xfixes/select.c b/xfixes/select.c
index a718715..d1c22c5 100755
--- a/xfixes/select.c
+++ b/xfixes/select.c
@@ -193,12 +193,12 @@ ProcXFixesSelectSelectionInput (ClientPt
 {
     REQUEST (xXFixesSelectSelectionInputReq);
     WindowPtr	pWin;
+    int		rc;
 
     REQUEST_SIZE_MATCH (xXFixesSelectSelectionInputReq);
-    pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
-					   DixReadAccess);
-    if (!pWin)
-        return(BadWindow);
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
+    if (rc != Success)
+        return rc;
     if (stuff->eventMask & ~SelectionAllEvents)
     {
 	client->errorValue = stuff->eventMask;
diff-tree 04c721854fbf1bd6379c165a53fab2bdc09961c0 (from 670bbb87310503fcc17203cecfa6f4f2f5db51d2)
Author: Eamon Walsh <ewalsh at tycho.nsa.gov>
Date:   Fri Dec 15 14:11:40 2006 -0500

    Convert callers of LookupWindow() to dixLookupWindow().

diff --git a/Xext/appgroup.c b/Xext/appgroup.c
index 4f30005..134b172 100644
--- a/Xext/appgroup.c
+++ b/Xext/appgroup.c
@@ -355,13 +355,15 @@ int AttrValidate(
     AppGroupPtr pAppGrp)
 {
     WindowPtr pWin;
-    int idepth, ivids, found;
+    int idepth, ivids, found, rc;
     ScreenPtr pScreen;
     DepthPtr pDepth;
     ColormapPtr pColormap;
 
-    pWin = LookupWindow (pAppGrp->default_root, client);
-    /* XXX check that pWin is not NULL */
+    rc = dixLookupWindow(&pWin, pAppGrp->default_root, client,
+			 DixUnknownAccess);
+    if (rc != Success)
+	return rc;
     pScreen = pWin->drawable.pScreen;
     if (WindowTable[pScreen->myNum]->drawable.id != pAppGrp->default_root)
 	return BadWindow;
diff --git a/Xext/mbuf.c b/Xext/mbuf.c
index e0361dd..43e2cc1 100644
--- a/Xext/mbuf.c
+++ b/Xext/mbuf.c
@@ -448,16 +448,15 @@ ProcCreateImageBuffers (client)
     register int		n;
     WindowPtr			pWin;
     XID				*ids;
-    int				len, nbuf;
-    int				i;
-    int				err;
+    int				len, nbuf, i, err, rc;
 
     REQUEST_AT_LEAST_SIZE (xMbufCreateImageBuffersReq);
     len = stuff->length - (sizeof(xMbufCreateImageBuffersReq) >> 2);
     if (len == 0)
 	return BadLength;
-    if (!(pWin = LookupWindow (stuff->window, client)))
-	return BadWindow;
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+    if (rc != Success)
+	return rc;
     if (pWin->drawable.class == InputOnly)
 	return BadMatch;
     switch (stuff->updateAction)
@@ -584,10 +583,12 @@ ProcDestroyImageBuffers (client)
 {
     REQUEST (xMbufDestroyImageBuffersReq);
     WindowPtr	pWin;
+    int rc;
 
     REQUEST_SIZE_MATCH (xMbufDestroyImageBuffersReq);
-    if (!(pWin = LookupWindow (stuff->window, client)))
-	return BadWindow;
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+    if (rc != Success)
+	return rc;
     DestroyImageBuffers (pWin);
     return Success;
 }
@@ -599,16 +600,16 @@ ProcSetMBufferAttributes (client)
     REQUEST (xMbufSetMBufferAttributesReq);
     WindowPtr	pWin;
     MultibuffersPtr	pMultibuffers;
-    int		len;
+    int		len, rc;
     Mask	vmask;
     Mask	index2;
     CARD32	updateHint;
     XID		*vlist;
 
     REQUEST_AT_LEAST_SIZE (xMbufSetMBufferAttributesReq);
-    pWin = LookupWindow (stuff->window, client);
-    if (!pWin)
-	return BadWindow;
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+    if (rc != Success)
+	return rc;
     pMultibuffers = (MultibuffersPtr)LookupIDByType (pWin->drawable.id, MultibuffersResType);
     if (!pMultibuffers)
 	return BadMatch;
@@ -655,12 +656,12 @@ ProcGetMBufferAttributes (client)
     MultibuffersPtr	pMultibuffers;
     XID		*ids;
     xMbufGetMBufferAttributesReply  rep;
-    int		i, n;
+    int		i, n, rc;
 
     REQUEST_SIZE_MATCH (xMbufGetMBufferAttributesReq);
-    pWin = LookupWindow (stuff->window, client);
-    if (!pWin)
-	return BadWindow;
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+    if (rc != Success)
+	return rc;
     pMultibuffers = (MultibuffersPtr)LookupIDByType (pWin->drawable.id, MultibuffersResType);
     if (!pMultibuffers)
 	return BadAccess;
diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c
index 6b8b5f2..85f5913 100644
--- a/Xext/panoramiX.c
+++ b/Xext/panoramiX.c
@@ -958,12 +958,13 @@ ProcPanoramiXGetState(ClientPtr client)
 	REQUEST(xPanoramiXGetStateReq);
     	WindowPtr			pWin;
 	xPanoramiXGetStateReply		rep;
-	register int			n;
+	register int			n, rc;
 	
 	REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
-	pWin = LookupWindow (stuff->window, client);
-	if (!pWin)
-	     return BadWindow;
+	rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+	if (rc != Success)
+	    return rc;
+
 	rep.type = X_Reply;
 	rep.length = 0;
 	rep.sequenceNumber = client->sequence;
@@ -984,12 +985,13 @@ ProcPanoramiXGetScreenCount(ClientPtr cl
 	REQUEST(xPanoramiXGetScreenCountReq);
     	WindowPtr			pWin;
 	xPanoramiXGetScreenCountReply	rep;
-	register int			n;
+	register int			n, rc;
 
 	REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
-	pWin = LookupWindow (stuff->window, client);
-	if (!pWin)
-	     return BadWindow;
+	rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+	if (rc != Success)
+	    return rc;
+
 	rep.type = X_Reply;
 	rep.length = 0;
 	rep.sequenceNumber = client->sequence;
@@ -1009,12 +1011,13 @@ ProcPanoramiXGetScreenSize(ClientPtr cli
 	REQUEST(xPanoramiXGetScreenSizeReq);
     	WindowPtr			pWin;
 	xPanoramiXGetScreenSizeReply	rep;
-	register int			n;
+	register int			n, rc;
 	
 	REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
-	pWin = LookupWindow (stuff->window, client);
-	if (!pWin)
-	     return BadWindow;
+	rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+	if (rc != Success)
+	    return rc;
+
 	rep.type = X_Reply;
 	rep.length = 0;
 	rep.sequenceNumber = client->sequence;
diff --git a/Xext/shape.c b/Xext/shape.c
index 4a798da..58e3a69 100644
--- a/Xext/shape.c
+++ b/Xext/shape.c
@@ -316,16 +316,16 @@ ProcShapeRectangles (client)
     ScreenPtr		pScreen;
     REQUEST(xShapeRectanglesReq);
     xRectangle		*prects;
-    int		        nrects, ctype;
+    int		        nrects, ctype, rc;
     RegionPtr		srcRgn;
     RegionPtr		*destRgn;
     CreateDftPtr	createDefault;
 
     REQUEST_AT_LEAST_SIZE (xShapeRectanglesReq);
     UpdateCurrentTime();
-    pWin = LookupWindow (stuff->dest, client);
-    if (!pWin)
-	return BadWindow;
+    rc = dixLookupWindow(&pWin, stuff->dest, client, DixUnknownAccess);
+    if (rc != Success)
+	return rc;
     switch (stuff->destKind) {
     case ShapeBounding:
 	createDefault = CreateBoundingShape;
@@ -526,12 +526,13 @@ ProcShapeCombine (client)
     CreateDftPtr	createDefault;
     CreateDftPtr	createSrc;
     RegionPtr		tmp;
+    int			rc;
 
     REQUEST_SIZE_MATCH (xShapeCombineReq);
     UpdateCurrentTime();
-    pDestWin = LookupWindow (stuff->dest, client);
-    if (!pDestWin)
-	return BadWindow;
+    rc = dixLookupWindow(&pDestWin, stuff->dest, client, DixUnknownAccess);
+    if (rc != Success)
+	return rc;
     if (!pDestWin->optional)
 	MakeWindowOptional (pDestWin);
     switch (stuff->destKind) {
@@ -550,9 +551,9 @@ ProcShapeCombine (client)
     }
     pScreen = pDestWin->drawable.pScreen;
 
-    pSrcWin = LookupWindow (stuff->src, client);
-    if (!pSrcWin)
-	return BadWindow;
+    rc = dixLookupWindow(&pSrcWin, stuff->src, client, DixUnknownAccess);
+    if (rc != Success)
+	return rc;
     switch (stuff->srcKind) {
     case ShapeBounding:
 	srcRgn = wBoundingShape (pSrcWin);
@@ -645,12 +646,13 @@ ProcShapeOffset (client)
     ScreenPtr		pScreen;
     REQUEST(xShapeOffsetReq);
     RegionPtr		srcRgn;
+    int			rc;
 
     REQUEST_SIZE_MATCH (xShapeOffsetReq);
     UpdateCurrentTime();
-    pWin = LookupWindow (stuff->dest, client);
-    if (!pWin)
-	return BadWindow;
+    rc = dixLookupWindow(&pWin, stuff->dest, client, DixUnknownAccess);
+    if (rc != Success)
+	return rc;
     switch (stuff->destKind) {
     case ShapeBounding:
 	srcRgn = wBoundingShape (pWin);
@@ -709,13 +711,13 @@ ProcShapeQueryExtents (client)
     WindowPtr		pWin;
     xShapeQueryExtentsReply	rep;
     BoxRec		extents, *pExtents;
-    register int	n;
+    register int	n, rc;
     RegionPtr		region;
 
     REQUEST_SIZE_MATCH (xShapeQueryExtentsReq);
-    pWin = LookupWindow (stuff->window, client);
-    if (!pWin)
-	return BadWindow;
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+    if (rc != Success)
+	return rc;
     rep.type = X_Reply;
     rep.length = 0;
     rep.sequenceNumber = client->sequence;
@@ -990,14 +992,14 @@ ProcShapeInputSelected (client)
     REQUEST(xShapeInputSelectedReq);
     WindowPtr		pWin;
     ShapeEventPtr	pShapeEvent, *pHead;
-    int			enabled;
+    int			enabled, rc;
     xShapeInputSelectedReply	rep;
     register int		n;
 
     REQUEST_SIZE_MATCH (xShapeInputSelectedReq);
-    pWin = LookupWindow (stuff->window, client);
-    if (!pWin)
-	return BadWindow;
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+    if (rc != Success)
+	return rc;
     pHead = (ShapeEventPtr *) SecurityLookupIDByType(client,
 			pWin->drawable.id, EventType, DixReadAccess);
     enabled = xFalse;
@@ -1032,14 +1034,14 @@ ProcShapeGetRectangles (client)
     WindowPtr			pWin;
     xShapeGetRectanglesReply	rep;
     xRectangle			*rects;
-    int				nrects, i;
+    int				nrects, i, rc;
     RegionPtr			region;
     register int		n;
 
     REQUEST_SIZE_MATCH(xShapeGetRectanglesReq);
-    pWin = LookupWindow (stuff->window, client);
-    if (!pWin)
-	return BadWindow;
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+    if (rc != Success)
+	return rc;
     switch (stuff->kind) {
     case ShapeBounding:
 	region = wBoundingShape(pWin);
diff --git a/Xext/xtest.c b/Xext/xtest.c
index 83f8b8c..c9b511e 100644
--- a/Xext/xtest.c
+++ b/Xext/xtest.c
@@ -139,12 +139,12 @@ ProcXTestCompareCursor(client)
     xXTestCompareCursorReply rep;
     WindowPtr pWin;
     CursorPtr pCursor;
-    register int n;
+    register int n, rc;
 
     REQUEST_SIZE_MATCH(xXTestCompareCursorReq);
-    pWin = (WindowPtr)LookupWindow(stuff->window, client);
-    if (!pWin)
-        return(BadWindow);
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+    if (rc != Success)
+        return rc;
     if (stuff->cursor == None)
 	pCursor = NullCursor;
     else if (stuff->cursor == XTestCurrentCursor)
@@ -173,12 +173,10 @@ ProcXTestFakeInput(client)
     register ClientPtr client;
 {
     REQUEST(xXTestFakeInputReq);
-    int nev;
-    int	n;
+    int nev, n, type, rc;
     xEvent *ev;
     DeviceIntPtr dev = NULL;
     WindowPtr root;
-    int type;
 #ifdef XINPUT
     Bool extension = FALSE;
     deviceValuator *dv = NULL;
@@ -367,9 +365,10 @@ ProcXTestFakeInput(client)
 	    root = GetCurrentRootWindow();
 	else
 	{
-	    root = LookupWindow(ev->u.keyButtonPointer.root, client);
-	    if (!root)
-		return BadWindow;
+	    rc = dixLookupWindow(&root, ev->u.keyButtonPointer.root, client,
+				 DixUnknownAccess);
+	    if (rc != Success)
+		return rc;
 	    if (root->parent)
 	    {
 		client->errorValue = ev->u.keyButtonPointer.root;
diff --git a/Xext/xvdisp.c b/Xext/xvdisp.c
index 2afb7c6..21d00aa 100644
--- a/Xext/xvdisp.c
+++ b/Xext/xvdisp.c
@@ -373,10 +373,8 @@ ProcXvQueryAdaptors(ClientPtr client)
   xvFormat format;
   xvAdaptorInfo ainfo;
   xvQueryAdaptorsReply rep;
-  int totalSize;
-  int na;
+  int totalSize, na, nf, rc;
   XvAdaptorPtr pa;
-  int nf;
   XvFormatPtr pf;
   WindowPtr pWin;
   ScreenPtr pScreen;
@@ -385,11 +383,9 @@ ProcXvQueryAdaptors(ClientPtr client)
   REQUEST(xvQueryAdaptorsReq);
   REQUEST_SIZE_MATCH(xvQueryAdaptorsReq);
 
-  if(!(pWin = (WindowPtr)LookupWindow(stuff->window, client) ))
-    {
-      client->errorValue = stuff->window;
-      return (BadWindow);
-    }
+  rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+  if (rc != Success)
+      return rc;
 
   pScreen = pWin->drawable.pScreen;
   pxvs = (XvScreenPtr)pScreen->devPrivates[XvScreenIndex].ptr;
diff --git a/Xi/chgprop.c b/Xi/chgprop.c
index 52c3883..bab4597 100644
--- a/Xi/chgprop.c
+++ b/Xi/chgprop.c
@@ -106,7 +106,7 @@ SProcXChangeDeviceDontPropagateList(regi
 int
 ProcXChangeDeviceDontPropagateList(register ClientPtr client)
 {
-    int i;
+    int i, rc;
     WindowPtr pWin;
     struct tmask tmp[EMASKSIZE];
     OtherInputMasks *others;
@@ -121,11 +121,10 @@ ProcXChangeDeviceDontPropagateList(regis
 	return Success;
     }
 
-    pWin = (WindowPtr) LookupWindow(stuff->window, client);
-    if (!pWin) {
-	client->errorValue = stuff->window;
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+    if (rc != Success) {
 	SendErrorToClient(client, IReqCode, X_ChangeDeviceDontPropagateList, 0,
-			  BadWindow);
+			  rc);
 	return Success;
     }
 
diff --git a/Xi/exevents.c b/Xi/exevents.c
index 92a5f05..b7645f4 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -505,6 +505,7 @@ GrabButton(ClientPtr client, DeviceIntPt
     WindowPtr pWin, confineTo;
     CursorPtr cursor;
     GrabPtr grab;
+    int rc;
 
     if ((this_device_mode != GrabModeSync) &&
 	(this_device_mode != GrabModeAsync)) {
@@ -524,15 +525,15 @@ GrabButton(ClientPtr client, DeviceIntPt
 	client->errorValue = ownerEvents;
 	return BadValue;
     }
-    pWin = LookupWindow(grabWindow, client);
-    if (!pWin)
-	return BadWindow;
+    rc = dixLookupWindow(&pWin, grabWindow, client, DixUnknownAccess);
+    if (rc != Success)
+	return rc;
     if (rconfineTo == None)
 	confineTo = NullWindow;
     else {
-	confineTo = LookupWindow(rconfineTo, client);
-	if (!confineTo)
-	    return BadWindow;
+	rc = dixLookupWindow(&confineTo, rconfineTo, client, DixUnknownAccess);
+	if (rc != Success)
+	    return rc;
     }
     if (rcursor == None)
 	cursor = NullCursor;
@@ -562,6 +563,7 @@ GrabKey(ClientPtr client, DeviceIntPtr d
     WindowPtr pWin;
     GrabPtr grab;
     KeyClassPtr k = dev->key;
+    int rc;
 
     if (k == NULL)
 	return BadMatch;
@@ -588,9 +590,9 @@ GrabKey(ClientPtr client, DeviceIntPtr d
 	client->errorValue = ownerEvents;
 	return BadValue;
     }
-    pWin = LookupWindow(grabWindow, client);
-    if (!pWin)
-	return BadWindow;
+    rc = dixLookupWindow(&pWin, grabWindow, client, DixUnknownAccess);
+    if (rc != Success)
+	return rc;
 
     grab = CreateGrab(client->index, dev, pWin,
 		      mask, ownerEvents, this_device_mode, other_devices_mode,
@@ -810,7 +812,7 @@ SendEvent(ClientPtr client, DeviceIntPtr
 	} else
 	    effectiveFocus = pWin = inputFocus;
     } else
-	pWin = LookupWindow(dest, client);
+	dixLookupWindow(&pWin, dest, client, DixUnknownAccess);
     if (!pWin)
 	return BadWindow;
     if ((propagate != xFalse) && (propagate != xTrue)) {
diff --git a/Xi/getprop.c b/Xi/getprop.c
index 5308410..058c595 100644
--- a/Xi/getprop.c
+++ b/Xi/getprop.c
@@ -100,7 +100,7 @@ int
 ProcXGetDeviceDontPropagateList(register ClientPtr client)
 {
     CARD16 count = 0;
-    int i;
+    int i, rc;
     XEventClass *buf = NULL, *tbuf;
     WindowPtr pWin;
     xGetDeviceDontPropagateListReply rep;
@@ -115,11 +115,10 @@ ProcXGetDeviceDontPropagateList(register
     rep.length = 0;
     rep.count = 0;
 
-    pWin = (WindowPtr) LookupWindow(stuff->window, client);
-    if (!pWin) {
-	client->errorValue = stuff->window;
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+    if (rc != Success) {
 	SendErrorToClient(client, IReqCode, X_GetDeviceDontPropagateList, 0,
-			  BadWindow);
+			  rc);
 	return Success;
     }
 
diff --git a/Xi/getselev.c b/Xi/getselev.c
index a84c33d..533c66c 100644
--- a/Xi/getselev.c
+++ b/Xi/getselev.c
@@ -98,8 +98,7 @@ SProcXGetSelectedExtensionEvents(registe
 int
 ProcXGetSelectedExtensionEvents(register ClientPtr client)
 {
-    int i;
-    int total_length = 0;
+    int i, rc, total_length = 0;
     xGetSelectedExtensionEventsReply rep;
     WindowPtr pWin;
     XEventClass *buf = NULL;
@@ -118,9 +117,10 @@ ProcXGetSelectedExtensionEvents(register
     rep.this_client_count = 0;
     rep.all_clients_count = 0;
 
-    if (!(pWin = LookupWindow(stuff->window, client))) {
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+    if (rc != Success) {
 	SendErrorToClient(client, IReqCode, X_GetSelectedExtensionEvents, 0,
-			  BadWindow);
+			  rc);
 	return Success;
     }
 
diff --git a/Xi/selectev.c b/Xi/selectev.c
index 7d3ef9d..8c893ca 100644
--- a/Xi/selectev.c
+++ b/Xi/selectev.c
@@ -170,11 +170,9 @@ ProcXSelectExtensionEvent(register Clien
 	return Success;
     }
 
-    pWin = (WindowPtr) LookupWindow(stuff->window, client);
-    if (!pWin) {
-	client->errorValue = stuff->window;
-	SendErrorToClient(client, IReqCode, X_SelectExtensionEvent, 0,
-			  BadWindow);
+    ret = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+    if (ret != Success) {
+	SendErrorToClient(client, IReqCode, X_SelectExtensionEvent, 0, ret);
 	return Success;
     }
 
diff --git a/Xi/ungrdevb.c b/Xi/ungrdevb.c
index 64bb213..8db9307 100644
--- a/Xi/ungrdevb.c
+++ b/Xi/ungrdevb.c
@@ -105,6 +105,7 @@ ProcXUngrabDeviceButton(ClientPtr client
     DeviceIntPtr mdev;
     WindowPtr pWin;
     GrabRec temporaryGrab;
+    int rc;
 
     REQUEST(xUngrabDeviceButtonReq);
     REQUEST_SIZE_MATCH(xUngrabDeviceButtonReq);
@@ -134,9 +135,9 @@ ProcXUngrabDeviceButton(ClientPtr client
     } else
 	mdev = (DeviceIntPtr) LookupKeyboardDevice();
 
-    pWin = LookupWindow(stuff->grabWindow, client);
-    if (!pWin) {
-	SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0, BadWindow);
+    rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixUnknownAccess);
+    if (rc != Success) {
+	SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0, rc);
 	return Success;
     }
 
diff --git a/Xi/ungrdevk.c b/Xi/ungrdevk.c
index 0a6b3b6..ebb83bc 100644
--- a/Xi/ungrdevk.c
+++ b/Xi/ungrdevk.c
@@ -105,6 +105,7 @@ ProcXUngrabDeviceKey(ClientPtr client)
     DeviceIntPtr mdev;
     WindowPtr pWin;
     GrabRec temporaryGrab;
+    int rc;
 
     REQUEST(xUngrabDeviceKeyReq);
     REQUEST_SIZE_MATCH(xUngrabDeviceKeyReq);
@@ -133,9 +134,9 @@ ProcXUngrabDeviceKey(ClientPtr client)
     } else
 	mdev = (DeviceIntPtr) LookupKeyboardDevice();
 
-    pWin = LookupWindow(stuff->grabWindow, client);
-    if (!pWin) {
-	SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadWindow);
+    rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixUnknownAccess);
+    if (rc != Success) {
+	SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, rc);
 	return Success;
     }
     if (((stuff->key > dev->key->curKeySyms.maxKeyCode) ||
diff --git a/composite/compwindow.c b/composite/compwindow.c
index 2c86cdd..fed642e 100644
--- a/composite/compwindow.c
+++ b/composite/compwindow.c
@@ -93,10 +93,10 @@ typedef struct _compPixmapVisit {
 static Bool
 compRepaintBorder (ClientPtr pClient, pointer closure)
 {
-    WindowPtr	pWindow = LookupWindow ((XID) closure, pClient);
+    WindowPtr pWindow;
+    int rc = dixLookupWindow(&pWindow, (XID)closure, pClient,DixUnknownAccess);
 
-    if (pWindow)
-    {
+    if (rc == Success) {
 	RegionRec exposed;
 
 	REGION_NULL(pScreen, &exposed);
diff --git a/hw/darwin/quartz/pseudoramiX.c b/hw/darwin/quartz/pseudoramiX.c
index ab57827..a003daf 100644
--- a/hw/darwin/quartz/pseudoramiX.c
+++ b/hw/darwin/quartz/pseudoramiX.c
@@ -170,12 +170,13 @@ static int ProcPseudoramiXGetState(Clien
     REQUEST(xPanoramiXGetStateReq);
     WindowPtr pWin;
     xPanoramiXGetStateReply rep;
-    register int n;
+    register int n, rc;
 
     REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
-    pWin = LookupWindow (stuff->window, client);
-    if (!pWin)
-        return BadWindow;
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+    if (rc != Success)
+	return rc;
+
     rep.type = X_Reply;
     rep.length = 0;
     rep.sequenceNumber = client->sequence;
@@ -196,12 +197,13 @@ static int ProcPseudoramiXGetScreenCount
     REQUEST(xPanoramiXGetScreenCountReq);
     WindowPtr pWin;
     xPanoramiXGetScreenCountReply rep;
-    register int n;
+    register int n, rc;
 
     REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
-    pWin = LookupWindow (stuff->window, client);
-    if (!pWin)
-        return BadWindow;
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+    if (rc != Success)
+	return rc;
+
     rep.type = X_Reply;
     rep.length = 0;
     rep.sequenceNumber = client->sequence;
@@ -222,12 +224,13 @@ static int ProcPseudoramiXGetScreenSize(
     REQUEST(xPanoramiXGetScreenSizeReq);
     WindowPtr			pWin;
     xPanoramiXGetScreenSizeReply	rep;
-    register int			n;
+    register int			n, rc;
 
     REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
-    pWin = LookupWindow (stuff->window, client);
-    if (!pWin)
-        return BadWindow;
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+    if (rc != Success)
+	return rc;
+
     rep.type = X_Reply;
     rep.length = 0;
     rep.sequenceNumber = client->sequence;
diff --git a/randr/rrxinerama.c b/randr/rrxinerama.c
index 771ed09..8b95145 100644
--- a/randr/rrxinerama.c
+++ b/randr/rrxinerama.c
@@ -116,14 +116,15 @@ ProcRRXineramaGetState(ClientPtr client)
     REQUEST(xPanoramiXGetStateReq);
     WindowPtr			pWin;
     xPanoramiXGetStateReply	rep;
-    register int		n;
+    register int		n, rc;
     ScreenPtr			pScreen;
     rrScrPrivPtr		pScrPriv;
     Bool			active = FALSE;
 
     REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
-    pWin = LookupWindow(stuff->window, client);
-    if(!pWin) return BadWindow;
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+    if(rc != Success)
+	return rc;
 
     pScreen = pWin->drawable.pScreen;
     pScrPriv = rrGetScrPriv(pScreen);
@@ -180,11 +181,12 @@ ProcRRXineramaGetScreenCount(ClientPtr c
     REQUEST(xPanoramiXGetScreenCountReq);
     WindowPtr				pWin;
     xPanoramiXGetScreenCountReply	rep;
-    register int			n;
+    register int			n, rc;
 
     REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
-    pWin = LookupWindow(stuff->window, client);
-    if(!pWin) return BadWindow;
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+    if (rc != Success)
+	return rc;
     
     rep.type = X_Reply;
     rep.length = 0;
@@ -206,11 +208,12 @@ ProcRRXineramaGetScreenSize(ClientPtr cl
     WindowPtr				pWin, pRoot;
     ScreenPtr				pScreen;
     xPanoramiXGetScreenSizeReply	rep;
-    register int			n;
+    register int			n, rc;
 
     REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
-    pWin = LookupWindow (stuff->window, client);
-    if(!pWin)  return BadWindow;
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+    if (rc != Success)
+	return rc;
 
     pScreen = pWin->drawable.pScreen;
     pRoot = WindowTable[pScreen->myNum];



More information about the xorg-commit mailing list