[PATCH 5/5] panoramiX: macro checking if drawable is root

Dave Airlie airlied at gmail.com
Tue Mar 8 21:29:53 PST 2011


From: Dave Airlie <airlied at redhat.com>

this code appears in quite a few places, consolidate it into
a macro in a header.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 Xext/panoramiX.h      |    1 +
 Xext/panoramiXprocs.c |   26 +++++++++++++-------------
 2 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/Xext/panoramiX.h b/Xext/panoramiX.h
index fcfac0e..048203c 100644
--- a/Xext/panoramiX.h
+++ b/Xext/panoramiX.h
@@ -76,4 +76,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 b6ca807..9ea4611 100644
--- a/Xext/panoramiXprocs.c
+++ b/Xext/panoramiXprocs.c
@@ -1328,7 +1328,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));
@@ -1388,7 +1388,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;
@@ -1451,7 +1451,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;
@@ -1513,7 +1513,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;
@@ -1573,7 +1573,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){
@@ -1634,7 +1634,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;
@@ -1695,7 +1695,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;
@@ -1755,7 +1755,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;
@@ -1818,7 +1818,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 */
@@ -1956,7 +1956,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;
@@ -1997,7 +1997,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;
@@ -2038,7 +2038,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;
@@ -2079,7 +2079,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;
-- 
1.7.3.4



More information about the xorg-devel mailing list