xserver: Branch 'master' - 5 commits

Keith Packard keithp at kemper.freedesktop.org
Tue Mar 22 21:39:35 PDT 2011


 Xext/panoramiX.c      |   16 ++++++++--------
 Xext/panoramiX.h      |    4 +++-
 Xext/panoramiXprocs.c |   50 ++++++++++++++++++++------------------------------
 Xext/panoramiXsrv.h   |   11 +++++++++++
 Xext/shm.c            |    6 ++----
 Xext/xvdisp.c         |    4 ++--
 composite/compext.c   |    5 +----
 dix/events.c          |   10 +++++-----
 dix/window.c          |    4 ++--
 hw/dmx/dmxcb.c        |    7 ++++---
 hw/dmx/dmxextension.c |    4 ++--
 hw/dmx/dmxgcops.c     |    2 +-
 render/render.c       |   25 +++++--------------------
 13 files changed, 66 insertions(+), 82 deletions(-)

New commits:
commit 03f45df93469f6aef391e97007b9614e0770cc4c
Merge: efcb727... 5fb329a...
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Mar 23 13:38:37 2011 +0900

    Merge remote-tracking branch 'airlied/xinerama-cleanup'

commit 5fb329a04a18835ce864d0563f6dfeb3d3c78d69
Author: Dave Airlie <airlied at redhat.com>
Date:   Wed Mar 9 15:05:26 2011 +1000

    panoramiX: convert 1->panoramiXNumScreens loops to use macro (v2)
    
    This converts all the remaining 1->num loops to the macro,
    this removes nearly all the panoramiXNumScreens usage in
    loops, and is a step to replacing it.
    
    v2: move some from the other patch.
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c
index d10af70..74241d8 100644
--- a/Xext/panoramiX.c
+++ b/Xext/panoramiX.c
@@ -413,7 +413,7 @@ static void XineramaInitData(ScreenPtr pScreen)
     PanoramiXPixWidth = screenInfo.screens[0]->x + screenInfo.screens[0]->width;
     PanoramiXPixHeight = screenInfo.screens[0]->y + screenInfo.screens[0]->height;
 
-    for (i = 1; i < PanoramiXNumScreens; i++) {
+    FOR_NSCREENS_FORWARD_SKIP(i) {
 	pScreen = screenInfo.screens[i];
 	w = pScreen->x + pScreen->width;
 	h = pScreen->y + pScreen->height;
@@ -740,7 +740,7 @@ PanoramiXMaybeAddDepth(DepthPtr pDepth)
     int j, k;
     Bool found = FALSE;
 
-    for (j = 1; j < PanoramiXNumScreens; j++) {
+    FOR_NSCREENS_FORWARD_SKIP(j) {
 	pScreen = screenInfo.screens[j];
 	for (k = 0; k < pScreen->numDepths; k++) {
 	    if (pScreen->allowedDepths[k].depth == pDepth->depth) {
@@ -773,7 +773,7 @@ PanoramiXMaybeAddVisual(VisualPtr pVisual)
     int j, k;
     Bool found = FALSE;
 
-    for (j = 1; j < PanoramiXNumScreens; j++) {
+    FOR_NSCREENS_FORWARD_SKIP(j) {
 	pScreen = screenInfo.screens[j];
 	found = FALSE;
 
diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c
index 4eb9a13..9ea4611 100644
--- a/Xext/panoramiXprocs.c
+++ b/Xext/panoramiXprocs.c
@@ -1840,7 +1840,7 @@ int PanoramiXGetImage(ClientPtr client)
     }
 
     drawables[0] = pDraw;
-    for(i = 1; i < PanoramiXNumScreens; i++) {
+    FOR_NSCREENS_FORWARD_SKIP(i) {
 	rc = dixLookupDrawable(drawables+i, draw->info[i].id, client, 0,
 			       DixGetAttrAccess);
 	if (rc != Success)
diff --git a/Xext/shm.c b/Xext/shm.c
index 6294720..b08af82 100644
--- a/Xext/shm.c
+++ b/Xext/shm.c
@@ -848,7 +848,7 @@ ProcPanoramiXShmGetImage(ClientPtr client)
 	return BadAlloc;
 
     drawables[0] = pDraw;
-    for(i = 1; i < PanoramiXNumScreens; i++) {
+    FOR_NSCREENS_FORWARD_SKIP(i) {
 	rc = dixLookupDrawable(drawables+i, draw->info[i].id, client, 0, 
 			       DixReadAccess);
 	if (rc != Success)
diff --git a/Xext/xvdisp.c b/Xext/xvdisp.c
index beb26a9..b968431 100644
--- a/Xext/xvdisp.c
+++ b/Xext/xvdisp.c
@@ -1918,7 +1918,7 @@ void XineramifyXv(void)
 
       MatchingAdaptors[0] = refAdapt;
       isOverlay = hasOverlay(refAdapt);
-      for(j = 1; j < PanoramiXNumScreens; j++)
+      FOR_NSCREENS_FORWARD_SKIP(j)
 	 MatchingAdaptors[j] = matchAdaptor(screenInfo.screens[j], refAdapt, isOverlay);
 
       /* now create a resource for each port */
diff --git a/dix/events.c b/dix/events.c
index 5151f74..8835c5e 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -2554,7 +2554,7 @@ PointInBorderSize(WindowPtr pWin, int x, int y)
 	SpritePtr pSprite = inputInfo.pointer->spriteInfo->sprite;
 	int i;
 
-	for(i = 1; i < PanoramiXNumScreens; i++) {
+	FOR_NSCREENS_FORWARD_SKIP(i) {
 	   if(RegionContainsPoint(&pSprite->windows[i]->borderSize,
 				  x + screenInfo.screens[0]->x - screenInfo.screens[i]->x,
 				  y + screenInfo.screens[0]->y - screenInfo.screens[i]->y,
@@ -3153,7 +3153,7 @@ XineramaPointInWindowIsVisible(
     xoff = x + screenInfo.screens[0]->x;
     yoff = y + screenInfo.screens[0]->y;
 
-    for(i = 1; i < PanoramiXNumScreens; i++) {
+    FOR_NSCREENS_FORWARD_SKIP(i) {
 	pWin = inputInfo.pointer->spriteInfo->sprite->windows[i];
 	x = xoff - screenInfo.screens[i]->x;
 	y = yoff - screenInfo.screens[i]->y;
@@ -3360,7 +3360,7 @@ BorderSizeNotEmpty(DeviceIntPtr pDev, WindowPtr pWin)
      if(!noPanoramiXExtension && XineramaSetWindowPntrs(pDev, pWin)) {
 	int i;
 
-	for(i = 1; i < PanoramiXNumScreens; i++) {
+	FOR_NSCREENS_FORWARD_SKIP(i) {
 	    if(RegionNotEmpty(&pDev->spriteInfo->sprite->windows[i]->borderSize))
 		return TRUE;
 	}
diff --git a/hw/dmx/dmxgcops.c b/hw/dmx/dmxgcops.c
index bc8cd9e..500e2cd 100644
--- a/hw/dmx/dmxgcops.c
+++ b/hw/dmx/dmxgcops.c
@@ -529,7 +529,7 @@ static DMXScreenInfo *dmxFindAlternatePixmap(DrawablePtr pDrawable, XID *draw)
 					   NullClient, DixUnknownAccess))
         return NULL;
 
-    for (i = 1; i < PanoramiXNumScreens; i++) {
+    FOR_NSCREENS_FORWARD_SKIP(i) {
         dmxScreen = &dmxScreens[i];
         if (dmxScreen->beDisplay) {
             PixmapPtr     pSrc;
commit 0bccfcc97b2300b83aa4693454c27ac87f23f221
Author: Dave Airlie <airlied at redhat.com>
Date:   Wed Mar 9 15:01:20 2011 +1000

    panoramiX: convert 0->panoramiXNumScreens loops to macro (v3)
    
    This just uses the FOR_NSCREENS macro instead.
    
    v2: remove some of the 1->x loops.
    v3: drop the 1->0 loop, will rework later.
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c
index e6334bd..d10af70 100644
--- a/Xext/panoramiX.c
+++ b/Xext/panoramiX.c
@@ -393,7 +393,7 @@ static void XineramaInitData(ScreenPtr pScreen)
     int i, w, h;
 
     RegionNull(&PanoramiXScreenRegion);
-    for (i = 0; i < PanoramiXNumScreens; i++) {
+    FOR_NSCREENS(i) {
 	BoxRec TheBox;
 	RegionRec ScreenRegion;
 
@@ -478,7 +478,7 @@ void PanoramiXExtensionInit(int argc, char *argv[])
 	 *	run in non-PanoramiXeen mode.
 	 */
 
-	for (i = 0; i < PanoramiXNumScreens; i++) {
+	FOR_NSCREENS(i) {
 	   pScreen = screenInfo.screens[i];
 	   pScreenPriv = malloc(sizeof(PanoramiXScreenRec));
 	   dixSetPrivate(&pScreen->devPrivates, PanoramiXScreenKey,
@@ -836,7 +836,7 @@ PanoramiXConsolidate(void)
     saver = malloc(sizeof(PanoramiXRes));
     saver->type = XRT_WINDOW;
 
-    for (i =  0; i < PanoramiXNumScreens; i++) {
+    FOR_NSCREENS(i) {
 	ScreenPtr pScreen = screenInfo.screens[i];
 	root->info[i].id = pScreen->root->drawable.id;
 	root->u.win.class = InputOutput;
@@ -1074,7 +1074,7 @@ ProcXineramaQueryScreens(ClientPtr client)
 	xXineramaScreenInfo scratch;
 	int i;
 
-	for(i = 0; i < PanoramiXNumScreens; i++) {
+	FOR_NSCREENS(i) {
 	    scratch.x_org  = screenInfo.screens[i]->x;
 	    scratch.y_org  = screenInfo.screens[i]->y;
 	    scratch.width  = screenInfo.screens[i]->width;
@@ -1179,7 +1179,7 @@ XineramaGetImageData(
 
     depth = (format == XYPixmap) ? 1 : pDraw->depth;
 
-    for(i = 0; i < PanoramiXNumScreens; i++) {
+    FOR_NSCREENS(i) {
 	BoxRec TheBox;
 	ScreenPtr pScreen;
 	pDraw = pDrawables[i];
diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c
index 3e68d0a..4eb9a13 100644
--- a/Xext/panoramiXprocs.c
+++ b/Xext/panoramiXprocs.c
@@ -2186,7 +2186,7 @@ PanoramiXCopyColormapAndFree(ClientPtr client)
     newCmap->type = XRT_COLORMAP;
     panoramix_setup_ids(newCmap, client, stuff->mid);
 
-    FOR_NSCREENS_BACKWARD(j){
+    FOR_NSCREENS_BACKWARD(j) {
         stuff->srcCmap = cmap->info[j].id;
 	stuff->mid = newCmap->info[j].id;
         result = (* SavedProcVector[X_CopyColormapAndFree])(client);
diff --git a/Xext/xvdisp.c b/Xext/xvdisp.c
index deddebd..beb26a9 100644
--- a/Xext/xvdisp.c
+++ b/Xext/xvdisp.c
@@ -1927,7 +1927,7 @@ void XineramifyXv(void)
 	 if(!port)
 	    break;
 
-	 for(k = 0; k < PanoramiXNumScreens; k++) {
+	 FOR_NSCREENS(k) {
 	    if(MatchingAdaptors[k] && (MatchingAdaptors[k]->nPorts > j)) 
 		port->info[k].id = MatchingAdaptors[k]->base_id + j;
 	    else
diff --git a/dix/events.c b/dix/events.c
index df62e83..5151f74 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -558,7 +558,7 @@ XineramaSetWindowPntrs(DeviceIntPtr pDev, WindowPtr pWin)
 
     if(pWin == screenInfo.screens[0]->root) {
 	int i;
-	for (i = 0; i < PanoramiXNumScreens; i++)
+	FOR_NSCREENS(i)
 	    pSprite->windows[i] = screenInfo.screens[i]->root;
     } else {
 	PanoramiXRes *win;
@@ -569,7 +569,7 @@ XineramaSetWindowPntrs(DeviceIntPtr pDev, WindowPtr pWin)
 	if (rc != Success)
 	    return FALSE;
 
-	for(i = 0; i < PanoramiXNumScreens; i++) {
+	FOR_NSCREENS(i) {
 	    rc = dixLookupWindow(pSprite->windows + i, win->info[i].id,
 				 serverClient, DixReadAccess);
 	    if (rc != Success)  /* window is being unmapped */
diff --git a/dix/window.c b/dix/window.c
index 9be7064..3668370 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -3067,7 +3067,7 @@ SendVisibilityNotify(WindowPtr pWin)
 
 	switch(visibility) {
 	case VisibilityUnobscured:
-	    for(i = 0; i < PanoramiXNumScreens; i++) {
+	    FOR_NSCREENS(i) {
 		if(i == Scrnum) continue;
 
 		rc = dixLookupWindow(&pWin2, win->info[i].id, serverClient,
@@ -3089,7 +3089,7 @@ SendVisibilityNotify(WindowPtr pWin)
 	    }
 	    break;
 	case VisibilityFullyObscured:
-	    for(i = 0; i < PanoramiXNumScreens; i++) {
+	    FOR_NSCREENS(i) {
 		if(i == Scrnum) continue;
 
 		rc = dixLookupWindow(&pWin2, win->info[i].id, serverClient,
diff --git a/hw/dmx/dmxcb.c b/hw/dmx/dmxcb.c
index 4e7279a..d0eb351 100644
--- a/hw/dmx/dmxcb.c
+++ b/hw/dmx/dmxcb.c
@@ -46,6 +46,7 @@
 extern int     connBlockScreenStart;
 
 #ifdef PANORAMIX
+#include "panoramiXsrv.h"
 extern int     PanoramiXPixWidth;
 extern int     PanoramiXPixHeight;
 extern int     PanoramiXNumScreens;
@@ -137,7 +138,7 @@ void dmxConnectionBlockCallback(void)
         }
         dmxLog(dmxInfo, "%d screens configured with Xinerama (%d %d)\n",
                PanoramiXNumScreens, PanoramiXPixWidth, PanoramiXPixHeight);
-	for (i = 0; i < PanoramiXNumScreens; i++) found[i] = FALSE;
+	FOR_NSCREENS(i) found[i] = FALSE;
     } else {
 #endif
                                 /* This never happens because we're
@@ -177,7 +178,7 @@ void dmxConnectionBlockCallback(void)
 #ifdef PANORAMIX
 	    if (!noPanoramiXExtension) {
 		int  k;
-		for (k = 0; k < PanoramiXNumScreens; k++) {
+		FOR_NSCREENS(k) {
 		    DMXScreenInfo *dmxScreen = &dmxScreens[k];
 
 		    if (dmxScreen->beDisplay) {
@@ -203,7 +204,7 @@ void dmxConnectionBlockCallback(void)
 #ifdef PANORAMIX
     if (!noPanoramiXExtension) {
 	Bool fatal = FALSE;
-	for (i = 0; i < PanoramiXNumScreens; i++) {
+	FOR_NSCREENS(i) {
 	    fatal |= !found[i];
 	    if (!found[i]) {
 		dmxLog(dmxError,
diff --git a/hw/dmx/dmxextension.c b/hw/dmx/dmxextension.c
index bd326ce..db5709e 100644
--- a/hw/dmx/dmxextension.c
+++ b/hw/dmx/dmxextension.c
@@ -703,7 +703,7 @@ static void dmxBERestorePixmapImage(pointer value, XID id, RESTYPE type,
 				RT_PIXMAP, NullClient, DixUnknownAccess);
 	if (pPix != pDst) return; /* Not a match.... Next! */
 
-	for (i = 0; i < PanoramiXNumScreens; i++) {
+	FOR_NSCREENS(i) {
 	    PixmapPtr      pSrc;
 	    dmxPixPrivPtr  pSrcPriv = NULL;
 
@@ -1372,7 +1372,7 @@ static void dmxBEFindPixmapImage(pointer value, XID id, RESTYPE type,
 				RT_PIXMAP, NullClient, DixUnknownAccess);
 	if (pPix != pDst) return; /* Not a match.... Next! */
 
-	for (i = 0; i < PanoramiXNumScreens; i++) {
+	FOR_NSCREENS(i) {
 	    PixmapPtr      pSrc;
 	    dmxPixPrivPtr  pSrcPriv = NULL;
 
commit 5a94934487ea477947e24dcd4720b7cde77d3d2f
Author: Dave Airlie <airlied at redhat.com>
Date:   Wed Mar 9 14:53:26 2011 +1000

    panoramiX: consolidate common id assignment code.
    
    This adds a new FOR_NSCREENS_FORWARD_SKIP, which skips the first
    element and is a common idiom throughout panoramiX code.
    
    It then adds a new inline function to hide id assignment to a
    panoramiX resource and cleans up lots of common repeated code.
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/Xext/panoramiX.h b/Xext/panoramiX.h
index e4938f5..71651e5 100644
--- a/Xext/panoramiX.h
+++ b/Xext/panoramiX.h
@@ -44,7 +44,7 @@ Equipment Corporation.
 #include <X11/extensions/panoramiXproto.h>
 #undef _PANORAMIX_SERVER
 #include "gcstruct.h"
-
+#include "dixstruct.h"
 
 typedef struct _PanoramiXInfo {
     XID id ;
@@ -70,6 +70,7 @@ typedef struct {
 } PanoramiXRes;
 
 #define FOR_NSCREENS_FORWARD(j) for(j = 0; j < PanoramiXNumScreens; j++)
+#define FOR_NSCREENS_FORWARD_SKIP(j) for(j = 1; j < PanoramiXNumScreens; j++)
 #define FOR_NSCREENS_BACKWARD(j) for(j = PanoramiXNumScreens - 1; j >= 0; j--)
 #define FOR_NSCREENS(j) FOR_NSCREENS_FORWARD(j)
 
diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c
index 4ad5489..3e68d0a 100644
--- a/Xext/panoramiXprocs.c
+++ b/Xext/panoramiXprocs.c
@@ -120,9 +120,7 @@ int PanoramiXCreateWindow(ClientPtr client)
     newWin->u.win.visibility = VisibilityNotViewable;
     newWin->u.win.class = stuff->class;
     newWin->u.win.root = FALSE;
-    newWin->info[0].id = stuff->wid;
-    for(j = 1; j < PanoramiXNumScreens; j++)
-        newWin->info[j].id = FakeClientID(client->index);
+    panoramix_setup_ids(newWin, client, stuff->wid);
 
     if (stuff->class == InputOnly)
 	stuff->visual = CopyFromParent;
@@ -663,9 +661,7 @@ int PanoramiXCreatePixmap(ClientPtr client)
 
     newPix->type = XRT_PIXMAP;
     newPix->u.pix.shared = FALSE;
-    newPix->info[0].id = stuff->pid;
-    for(j = 1; j < PanoramiXNumScreens; j++)
-	newPix->info[j].id = FakeClientID(client->index);
+    panoramix_setup_ids(newPix, client, stuff->pid);
    
     FOR_NSCREENS_BACKWARD(j) {
 	stuff->pid = newPix->info[j].id;
@@ -767,9 +763,7 @@ int PanoramiXCreateGC(ClientPtr client)
         return BadAlloc;
 
     newGC->type = XRT_GC;
-    newGC->info[0].id = stuff->gc;
-    for(j = 1; j < PanoramiXNumScreens; j++)
-        newGC->info[j].id = FakeClientID(client->index);
+    panoramix_setup_ids(newGC, client, stuff->gc);
 
     FOR_NSCREENS_BACKWARD(j) {
         stuff->gc = newGC->info[j].id;
@@ -2121,9 +2115,7 @@ int PanoramiXCreateColormap(ClientPtr client)
         return BadAlloc;
 
     newCmap->type = XRT_COLORMAP;
-    newCmap->info[0].id = stuff->mid;
-    for(j = 1; j < PanoramiXNumScreens; j++)
-        newCmap->info[j].id = FakeClientID(client->index);
+    panoramix_setup_ids(newCmap, client, stuff->mid);
 
     orig_visual = stuff->visual;
     FOR_NSCREENS_BACKWARD(j){
@@ -2192,9 +2184,7 @@ PanoramiXCopyColormapAndFree(ClientPtr client)
         return BadAlloc;
 
     newCmap->type = XRT_COLORMAP;
-    newCmap->info[0].id = stuff->mid;
-    for(j = 1; j < PanoramiXNumScreens; j++)
-        newCmap->info[j].id = FakeClientID(client->index);
+    panoramix_setup_ids(newCmap, client, stuff->mid);
 
     FOR_NSCREENS_BACKWARD(j){
         stuff->srcCmap = cmap->info[j].id;
diff --git a/Xext/panoramiXsrv.h b/Xext/panoramiXsrv.h
index b0a5a6e..5dd02e8 100644
--- a/Xext/panoramiXsrv.h
+++ b/Xext/panoramiXsrv.h
@@ -51,4 +51,15 @@ extern _X_EXPORT void XineramaGetImageData(
     Bool isRoot
 );
 
+static inline void panoramix_setup_ids(PanoramiXRes *resource, 
+                                       ClientPtr client, XID base_id)
+{
+    int j;
+
+    resource->info[0].id = base_id;
+    FOR_NSCREENS_FORWARD_SKIP(j) {
+        resource->info[j].id = FakeClientID(client->index);
+    }
+}
+
 #endif /* _PANORAMIXSRV_H_ */
diff --git a/Xext/shm.c b/Xext/shm.c
index 23afe6b..6294720 100644
--- a/Xext/shm.c
+++ b/Xext/shm.c
@@ -972,9 +972,7 @@ CreatePmap:
 
     newPix->type = XRT_PIXMAP;
     newPix->u.pix.shared = TRUE;
-    newPix->info[0].id = stuff->pid;
-    for(j = 1; j < PanoramiXNumScreens; j++)
-	newPix->info[j].id = FakeClientID(client->index);
+    panoramix_setup_ids(newPix, client, stuff->pid);
 
     result = Success;
 
diff --git a/composite/compext.c b/composite/compext.c
index fbd36b5..e0d8e75 100644
--- a/composite/compext.c
+++ b/composite/compext.c
@@ -703,10 +703,7 @@ PanoramiXCompositeNameWindowPixmap (ClientPtr client)
 
     newPix->type = XRT_PIXMAP;
     newPix->u.pix.shared = FALSE;
-    newPix->info[0].id = stuff->pixmap;
-
-    for (i = 1; i < PanoramiXNumScreens; i++)
-	newPix->info[i].id = FakeClientID (client->index);
+    panoramix_setup_ids(newPix, client, stuff->pixmap);
 
     FOR_NSCREENS(i) {
 	rc = dixLookupResourceByType ((void **) &pWin, win->info[i].id,
diff --git a/render/render.c b/render/render.c
index 7029558..3cb1b54 100644
--- a/render/render.c
+++ b/render/render.c
@@ -2690,7 +2690,7 @@ PanoramiXRenderCreatePicture (ClientPtr client)
     if(!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes))))
 	return BadAlloc;
     newPict->type = XRT_PICTURE;
-    newPict->info[0].id = stuff->pid;
+    panoramix_setup_ids(newPict, client, stuff->pid);
     
     if (refDraw->type == XRT_WINDOW &&
 	stuff->drawable == screenInfo.screens[0]->root->drawable.id)
@@ -2699,9 +2699,6 @@ PanoramiXRenderCreatePicture (ClientPtr client)
     }
     else
 	newPict->u.pict.root = FALSE;
-
-    for(j = 1; j < PanoramiXNumScreens; j++)
-	newPict->info[j].id = FakeClientID(client->index);
     
     FOR_NSCREENS_BACKWARD(j) {
 	stuff->pid = newPict->info[j].id;
@@ -3225,11 +3222,8 @@ PanoramiXRenderCreateSolidFill (ClientPtr client)
 	return BadAlloc;
 
     newPict->type = XRT_PICTURE;
-    newPict->info[0].id = stuff->pid;
+    panoramix_setup_ids(newPict, client, stuff->pid);
     newPict->u.pict.root = FALSE;
-
-    for(j = 1; j < PanoramiXNumScreens; j++)
-	newPict->info[j].id = FakeClientID(client->index);
 	
     FOR_NSCREENS_BACKWARD(j) {
 	stuff->pid = newPict->info[j].id;
@@ -3258,12 +3252,9 @@ PanoramiXRenderCreateLinearGradient (ClientPtr client)
 	return BadAlloc;
 
     newPict->type = XRT_PICTURE;
-    newPict->info[0].id = stuff->pid;
+    panoramix_setup_ids(newPict, client, stuff->pid);
     newPict->u.pict.root = FALSE;
 
-    for(j = 1; j < PanoramiXNumScreens; j++)
-	newPict->info[j].id = FakeClientID(client->index);
-
     FOR_NSCREENS_BACKWARD(j) {
 	stuff->pid = newPict->info[j].id;
 	result = (*PanoramiXSaveRenderVector[X_RenderCreateLinearGradient]) (client);
@@ -3291,12 +3282,9 @@ PanoramiXRenderCreateRadialGradient (ClientPtr client)
 	return BadAlloc;
 
     newPict->type = XRT_PICTURE;
-    newPict->info[0].id = stuff->pid;
+    panoramix_setup_ids(newPict, client, stuff->pid);
     newPict->u.pict.root = FALSE;
 
-    for(j = 1; j < PanoramiXNumScreens; j++)
-	newPict->info[j].id = FakeClientID(client->index);
-
     FOR_NSCREENS_BACKWARD(j) {
 	stuff->pid = newPict->info[j].id;
 	result = (*PanoramiXSaveRenderVector[X_RenderCreateRadialGradient]) (client);
@@ -3324,12 +3312,9 @@ PanoramiXRenderCreateConicalGradient (ClientPtr client)
 	return BadAlloc;
 
     newPict->type = XRT_PICTURE;
-    newPict->info[0].id = stuff->pid;
+    panoramix_setup_ids(newPict, client, stuff->pid);
     newPict->u.pict.root = FALSE;
 
-    for(j = 1; j < PanoramiXNumScreens; j++)
-	newPict->info[j].id = FakeClientID(client->index);
-
     FOR_NSCREENS_BACKWARD(j) {
 	stuff->pid = newPict->info[j].id;
 	result = (*PanoramiXSaveRenderVector[X_RenderCreateConicalGradient]) (client);
commit c48c530e541e201ea1afe2512d85967659ceef84
Author: Dave Airlie <airlied at redhat.com>
Date:   Wed Mar 9 15:11:42 2011 +1000

    panoramiX: macro checking if drawable is root (v2)
    
    this code appears in quite a few places, consolidate it into
    a macro in a header.
    
    v2: align braces with macro just above it, and with
    lines removed
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/Xext/panoramiX.h b/Xext/panoramiX.h
index a8684f0..e4938f5 100644
--- a/Xext/panoramiX.h
+++ b/Xext/panoramiX.h
@@ -75,4 +75,5 @@ typedef struct {
 
 #define IS_SHARED_PIXMAP(r) (((r)->type == XRT_PIXMAP) && (r)->u.pix.shared)
 
+#define IS_ROOT_DRAWABLE(d) (((d)->type == XRT_WINDOW) && (d)->u.win.root)
 #endif /* _PANORAMIX_H_ */
diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c
index d843168..4ad5489 100644
--- a/Xext/panoramiXprocs.c
+++ b/Xext/panoramiXprocs.c
@@ -1334,7 +1334,7 @@ int PanoramiXPolyLine(ClientPtr client)
     if (result != Success)
 	return result;
 
-    isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
+    isRoot = IS_ROOT_DRAWABLE(draw);
     npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyLineReq));
     if (npoint > 0){
         origPts = malloc(npoint * sizeof(xPoint));
@@ -1394,7 +1394,7 @@ int PanoramiXPolySegment(ClientPtr client)
     if (result != Success)
 	return result;
 
-    isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
+    isRoot = IS_ROOT_DRAWABLE(draw);
 
     nsegs = (client->req_len << 2) - sizeof(xPolySegmentReq);
     if(nsegs & 4) return BadLength;
@@ -1457,7 +1457,7 @@ int PanoramiXPolyRectangle(ClientPtr client)
     if (result != Success)
 	return result;
 
-    isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
+    isRoot = IS_ROOT_DRAWABLE(draw);
 
     nrects = (client->req_len << 2) - sizeof(xPolyRectangleReq);
     if(nrects & 4) return BadLength;
@@ -1519,7 +1519,7 @@ int PanoramiXPolyArc(ClientPtr client)
     if (result != Success)
 	return result;
 
-    isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
+    isRoot = IS_ROOT_DRAWABLE(draw);
 
     narcs = (client->req_len << 2) - sizeof(xPolyArcReq);
     if(narcs % sizeof(xArc)) return BadLength;
@@ -1579,7 +1579,7 @@ int PanoramiXFillPoly(ClientPtr client)
     if (result != Success)
 	return result;
 
-    isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
+    isRoot = IS_ROOT_DRAWABLE(draw);
 
     count = bytes_to_int32((client->req_len << 2) - sizeof(xFillPolyReq));
     if (count > 0){
@@ -1640,7 +1640,7 @@ int PanoramiXPolyFillRectangle(ClientPtr client)
     if (result != Success)
 	return result;
 
-    isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
+    isRoot = IS_ROOT_DRAWABLE(draw);
 
     things = (client->req_len << 2) - sizeof(xPolyFillRectangleReq);
     if(things & 4) return BadLength;
@@ -1701,7 +1701,7 @@ int PanoramiXPolyFillArc(ClientPtr client)
     if (result != Success)
 	return result;
 
-    isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
+    isRoot = IS_ROOT_DRAWABLE(draw);
 
     narcs = (client->req_len << 2) - sizeof(xPolyFillArcReq);
     if (narcs % sizeof(xArc)) return BadLength;
@@ -1761,7 +1761,7 @@ int PanoramiXPutImage(ClientPtr client)
     if (result != Success)
 	return result;
 
-    isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
+    isRoot = IS_ROOT_DRAWABLE(draw);
 
     orig_x = stuff->dstX;
     orig_y = stuff->dstY;
@@ -1824,7 +1824,7 @@ int PanoramiXGetImage(ClientPtr client)
     format = stuff->format;
     planemask = stuff->planeMask;
 
-    isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
+    isRoot = IS_ROOT_DRAWABLE(draw);
 
     if(isRoot) {
       if( /* check for being onscreen */
@@ -1962,7 +1962,7 @@ PanoramiXPolyText8(ClientPtr client)
     if (result != Success)
 	return result;
 
-    isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
+    isRoot = IS_ROOT_DRAWABLE(draw);
 
     orig_x = stuff->x;
     orig_y = stuff->y;
@@ -2003,7 +2003,7 @@ PanoramiXPolyText16(ClientPtr client)
     if (result != Success)
 	return result;
 
-    isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
+    isRoot = IS_ROOT_DRAWABLE(draw);
 
     orig_x = stuff->x;
     orig_y = stuff->y;
@@ -2044,7 +2044,7 @@ int PanoramiXImageText8(ClientPtr client)
     if (result != Success)
 	return result;
 
-    isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
+    isRoot = IS_ROOT_DRAWABLE(draw);
 
     orig_x = stuff->x;
     orig_y = stuff->y;
@@ -2085,7 +2085,7 @@ int PanoramiXImageText16(ClientPtr client)
     if (result != Success)
 	return result;
 
-    isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
+    isRoot = IS_ROOT_DRAWABLE(draw);
 
     orig_x = stuff->x;
     orig_y = stuff->y;


More information about the xorg-commit mailing list