static int ProcShapeOffset(ClientPtr client) { WindowPtr pWin; REQUEST(xShapeOffsetReq); RegionPtr srcRgn; int rc; REQUEST_SIZE_MATCH(xShapeOffsetReq); UpdateCurrentTime(); rc = dixLookupWindow(&pWin, stuff->dest, client, DixSetAttrAccess); if (rc != Success) return rc; switch (stuff->destKind) { case ShapeBounding: srcRgn = wBoundingShape(pWin); break; case ShapeClip: srcRgn = wClipShape(pWin); break; case ShapeInput: srcRgn = wInputShape(pWin); break; default: client->errorValue = stuff->destKind; return BadValue; } if (srcRgn) { RegionTranslate(srcRgn, stuff->xOff, stuff->yOff); (*pWin->drawable.pScreen->SetShape) (pWin, stuff->destKind); } SendShapeNotify(pWin, (int) stuff->destKind); return Success; }
int ProcXFixesSetWindowShapeRegion (ClientPtr client) { #ifdef SHAPE WindowPtr pWin; ScreenPtr pScreen; RegionPtr pRegion; RegionPtr *pDestRegion; REQUEST(xXFixesSetWindowShapeRegionReq); REQUEST_SIZE_MATCH(xXFixesSetWindowShapeRegionReq); pWin = (WindowPtr) LookupIDByType (stuff->dest, RT_WINDOW); if (!pWin) { client->errorValue = stuff->dest; return BadWindow; } VERIFY_REGION_OR_NONE(pRegion, stuff->region, client, DixWriteAccess); pScreen = pWin->drawable.pScreen; switch (stuff->destKind) { case ShapeBounding: case ShapeClip: case ShapeInput: break; default: client->errorValue = stuff->destKind; return BadValue; } if (pRegion) { pRegion = XFixesRegionCopy (pRegion); if (!pRegion) return BadAlloc; if (!pWin->optional) MakeWindowOptional (pWin); switch (stuff->destKind) { default: case ShapeBounding: pDestRegion = &pWin->optional->boundingShape; break; case ShapeClip: pDestRegion = &pWin->optional->clipShape; break; case ShapeInput: pDestRegion = &pWin->optional->inputShape; break; } if (stuff->xOff || stuff->yOff) REGION_TRANSLATE (0, pRegion, stuff->xOff, stuff->yOff); } else { if (pWin->optional) { switch (stuff->destKind) { default: case ShapeBounding: pDestRegion = &pWin->optional->boundingShape; break; case ShapeClip: pDestRegion = &pWin->optional->clipShape; break; case ShapeInput: pDestRegion = &pWin->optional->inputShape; break; } } else pDestRegion = &pRegion; /* a NULL region pointer */ } if (*pDestRegion) REGION_DESTROY(pScreen, *pDestRegion); *pDestRegion = pRegion; (*pScreen->SetShape) (pWin); SendShapeNotify (pWin, stuff->destKind); return (client->noClientException); #else return BadRequest; #endif }
int ProcXFixesSetWindowShapeRegion(ClientPtr client) { WindowPtr pWin; RegionPtr pRegion; RegionPtr *pDestRegion; int rc; REQUEST(xXFixesSetWindowShapeRegionReq); REQUEST_SIZE_MATCH(xXFixesSetWindowShapeRegionReq); rc = dixLookupResourceByType((void **) &pWin, stuff->dest, RT_WINDOW, client, DixSetAttrAccess); if (rc != Success) { client->errorValue = stuff->dest; return rc; } VERIFY_REGION_OR_NONE(pRegion, stuff->region, client, DixWriteAccess); switch (stuff->destKind) { case ShapeBounding: case ShapeClip: case ShapeInput: break; default: client->errorValue = stuff->destKind; return BadValue; } if (pRegion) { pRegion = XFixesRegionCopy(pRegion); if (!pRegion) return BadAlloc; if (!pWin->optional) MakeWindowOptional(pWin); switch (stuff->destKind) { default: case ShapeBounding: pDestRegion = &pWin->optional->boundingShape; break; case ShapeClip: pDestRegion = &pWin->optional->clipShape; break; case ShapeInput: pDestRegion = &pWin->optional->inputShape; break; } if (stuff->xOff || stuff->yOff) RegionTranslate(pRegion, stuff->xOff, stuff->yOff); } else { if (pWin->optional) { switch (stuff->destKind) { default: case ShapeBounding: pDestRegion = &pWin->optional->boundingShape; break; case ShapeClip: pDestRegion = &pWin->optional->clipShape; break; case ShapeInput: pDestRegion = &pWin->optional->inputShape; break; } } else pDestRegion = &pRegion; /* a NULL region pointer */ } if (*pDestRegion) RegionDestroy(*pDestRegion); *pDestRegion = pRegion; (*pWin->drawable.pScreen->SetShape) (pWin, stuff->destKind); SendShapeNotify(pWin, stuff->destKind); return Success; }
static int RegionOperate(ClientPtr client, WindowPtr pWin, int kind, RegionPtr *destRgnp, RegionPtr srcRgn, int op, int xoff, int yoff, CreateDftPtr create) { if (srcRgn && (xoff || yoff)) RegionTranslate(srcRgn, xoff, yoff); if (!pWin->parent) { if (srcRgn) RegionDestroy(srcRgn); return Success; } /* May/30/2001: * The shape.PS specs say if src is None, existing shape is to be * removed (and so the op-code has no meaning in such removal); * see shape.PS, page 3, ShapeMask. */ if (srcRgn == NULL) { if (*destRgnp != NULL) { RegionDestroy(*destRgnp); *destRgnp = 0; /* go on to remove shape and generate ShapeNotify */ } else { /* May/30/2001: * The target currently has no shape in effect, so nothing to * do here. The specs say that ShapeNotify is generated whenever * the client region is "modified"; since no modification is done * here, we do not generate that event. The specs does not say * "it is an error to request removal when there is no shape in * effect", so we return good status. */ return Success; } } else switch (op) { case ShapeSet: if (*destRgnp) RegionDestroy(*destRgnp); *destRgnp = srcRgn; srcRgn = 0; break; case ShapeUnion: if (*destRgnp) RegionUnion(*destRgnp, *destRgnp, srcRgn); break; case ShapeIntersect: if (*destRgnp) RegionIntersect(*destRgnp, *destRgnp, srcRgn); else { *destRgnp = srcRgn; srcRgn = 0; } break; case ShapeSubtract: if (!*destRgnp) *destRgnp = (*create) (pWin); RegionSubtract(*destRgnp, *destRgnp, srcRgn); break; case ShapeInvert: if (!*destRgnp) *destRgnp = RegionCreate((BoxPtr) 0, 0); else RegionSubtract(*destRgnp, srcRgn, *destRgnp); break; default: client->errorValue = op; return BadValue; } if (srcRgn) RegionDestroy(srcRgn); (*pWin->drawable.pScreen->SetShape) (pWin, kind); SendShapeNotify(pWin, kind); return Success; }