[PATCH xserver] xace: Don't censor window borders

Keith Packard keithp at keithp.com
Sun Sep 25 11:19:08 UTC 2016


GetImage is allowed to return window border contents, so don't remove
that from the returned image.

Signed-off-by: Keith Packard <keithp at keithp.com>
---
 Xext/xace.c    | 13 ++++++-------
 dix/dispatch.c | 10 ++--------
 2 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/Xext/xace.c b/Xext/xace.c
index a3a83a2..f8f8d13 100644
--- a/Xext/xace.c
+++ b/Xext/xace.c
@@ -236,16 +236,15 @@ XaceCensorImage(ClientPtr client,
     BoxRec imageBox;
     int nRects;
 
-    imageBox.x1 = x;
-    imageBox.y1 = y;
-    imageBox.x2 = x + w;
-    imageBox.y2 = y + h;
+    imageBox.x1 = pDraw->x + x;
+    imageBox.y1 = pDraw->y + y;
+    imageBox.x2 = pDraw->x + x + w;
+    imageBox.y2 = pDraw->y + y + h;
     RegionInit(&imageRegion, &imageBox, 1);
     RegionNull(&censorRegion);
 
     /* censorRegion = imageRegion - visibleRegion */
     RegionSubtract(&censorRegion, &imageRegion, pVisibleRegion);
-    RegionTranslate(&censorRegion, -x, -y);
     nRects = RegionNumRects(&censorRegion);
     if (nRects > 0) {           /* we have something to censor */
         GCPtr pScratchGC = NULL;
@@ -265,8 +264,8 @@ XaceCensorImage(ClientPtr client,
             goto failSafe;
         }
         for (pBox = RegionRects(&censorRegion), i = 0; i < nRects; i++, pBox++) {
-            pRects[i].x = pBox->x1;
-            pRects[i].y = pBox->y1;
+            pRects[i].x = pBox->x1 - imageBox.x1;
+            pRects[i].y = pBox->y1 - imageBox.y1;
             pRects[i].width = pBox->x2 - pBox->x1;
             pRects[i].height = pBox->y2 - pBox->y1;
         }
diff --git a/dix/dispatch.c b/dix/dispatch.c
index adcc9cf..e111377 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -2187,12 +2187,8 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
         return BadAlloc;
     WriteReplyToClient(client, sizeof(xGetImageReply), &xgi);
 
-    if (pDraw->type == DRAWABLE_WINDOW) {
-        pVisibleRegion = NotClippedByChildren((WindowPtr) pDraw);
-        if (pVisibleRegion) {
-            RegionTranslate(pVisibleRegion, -pDraw->x, -pDraw->y);
-        }
-    }
+    if (pDraw->type == DRAWABLE_WINDOW)
+        pVisibleRegion = &((WindowPtr) pDraw)->borderClip;
 
     if (linesPerBuf == 0) {
         /* nothing to do */
@@ -2251,8 +2247,6 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
             }
         }
     }
-    if (pVisibleRegion)
-        RegionDestroy(pVisibleRegion);
     free(pBuf);
     return Success;
 }
-- 
2.9.3



More information about the xorg-devel mailing list