123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943 |
- /*
- * Copyright © 2003 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
- #ifdef HAVE_DIX_CONFIG_H
- #include <dix-config.h>
- #endif
- #include "xfixesint.h"
- #include "scrnintstr.h"
- #include <picturestr.h>
- #include <regionstr.h>
- #include <gcstruct.h>
- #include <window.h>
- RESTYPE RegionResType;
- static int
- RegionResFree(void *data, XID id)
- {
- RegionPtr pRegion = (RegionPtr) data;
- RegionDestroy(pRegion);
- return Success;
- }
- RegionPtr
- XFixesRegionCopy(RegionPtr pRegion)
- {
- RegionPtr pNew = RegionCreate(RegionExtents(pRegion),
- RegionNumRects(pRegion));
- if (!pNew)
- return 0;
- if (!RegionCopy(pNew, pRegion)) {
- RegionDestroy(pNew);
- return 0;
- }
- return pNew;
- }
- Bool
- XFixesRegionInit(void)
- {
- RegionResType = CreateNewResourceType(RegionResFree, "XFixesRegion");
- return RegionResType != 0;
- }
- int
- ProcXFixesCreateRegion(ClientPtr client)
- {
- int things;
- RegionPtr pRegion;
- REQUEST(xXFixesCreateRegionReq);
- REQUEST_AT_LEAST_SIZE(xXFixesCreateRegionReq);
- LEGAL_NEW_RESOURCE(stuff->region, client);
- things = (client->req_len << 2) - sizeof(xXFixesCreateRegionReq);
- if (things & 4)
- return BadLength;
- things >>= 3;
- pRegion = RegionFromRects(things, (xRectangle *) (stuff + 1), CT_UNSORTED);
- if (!pRegion)
- return BadAlloc;
- if (!AddResource(stuff->region, RegionResType, (void *) pRegion))
- return BadAlloc;
- return Success;
- }
- int
- SProcXFixesCreateRegion(ClientPtr client)
- {
- REQUEST(xXFixesCreateRegionReq);
- swaps(&stuff->length);
- REQUEST_AT_LEAST_SIZE(xXFixesCreateRegionReq);
- swapl(&stuff->region);
- SwapRestS(stuff);
- return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
- }
- int
- ProcXFixesCreateRegionFromBitmap(ClientPtr client)
- {
- RegionPtr pRegion;
- PixmapPtr pPixmap;
- int rc;
- REQUEST(xXFixesCreateRegionFromBitmapReq);
- REQUEST_SIZE_MATCH(xXFixesCreateRegionFromBitmapReq);
- LEGAL_NEW_RESOURCE(stuff->region, client);
- rc = dixLookupResourceByType((void **) &pPixmap, stuff->bitmap, RT_PIXMAP,
- client, DixReadAccess);
- if (rc != Success) {
- client->errorValue = stuff->bitmap;
- return rc;
- }
- if (pPixmap->drawable.depth != 1)
- return BadMatch;
- pRegion = BitmapToRegion(pPixmap->drawable.pScreen, pPixmap);
- if (!pRegion)
- return BadAlloc;
- if (!AddResource(stuff->region, RegionResType, (void *) pRegion))
- return BadAlloc;
- return Success;
- }
- int
- SProcXFixesCreateRegionFromBitmap(ClientPtr client)
- {
- REQUEST(xXFixesCreateRegionFromBitmapReq);
- swaps(&stuff->length);
- REQUEST_SIZE_MATCH(xXFixesCreateRegionFromBitmapReq);
- swapl(&stuff->region);
- swapl(&stuff->bitmap);
- return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
- }
- int
- ProcXFixesCreateRegionFromWindow(ClientPtr client)
- {
- RegionPtr pRegion;
- Bool copy = TRUE;
- WindowPtr pWin;
- int rc;
- REQUEST(xXFixesCreateRegionFromWindowReq);
- REQUEST_SIZE_MATCH(xXFixesCreateRegionFromWindowReq);
- LEGAL_NEW_RESOURCE(stuff->region, client);
- rc = dixLookupResourceByType((void **) &pWin, stuff->window, RT_WINDOW,
- client, DixGetAttrAccess);
- if (rc != Success) {
- client->errorValue = stuff->window;
- return rc;
- }
- switch (stuff->kind) {
- case WindowRegionBounding:
- pRegion = wBoundingShape(pWin);
- if (!pRegion) {
- pRegion = CreateBoundingShape(pWin);
- copy = FALSE;
- }
- break;
- case WindowRegionClip:
- pRegion = wClipShape(pWin);
- if (!pRegion) {
- pRegion = CreateClipShape(pWin);
- copy = FALSE;
- }
- break;
- default:
- client->errorValue = stuff->kind;
- return BadValue;
- }
- if (copy && pRegion)
- pRegion = XFixesRegionCopy(pRegion);
- if (!pRegion)
- return BadAlloc;
- if (!AddResource(stuff->region, RegionResType, (void *) pRegion))
- return BadAlloc;
- return Success;
- }
- int
- SProcXFixesCreateRegionFromWindow(ClientPtr client)
- {
- REQUEST(xXFixesCreateRegionFromWindowReq);
- swaps(&stuff->length);
- REQUEST_SIZE_MATCH(xXFixesCreateRegionFromWindowReq);
- swapl(&stuff->region);
- swapl(&stuff->window);
- return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
- }
- int
- ProcXFixesCreateRegionFromGC(ClientPtr client)
- {
- RegionPtr pRegion, pClip;
- GCPtr pGC;
- int rc;
- REQUEST(xXFixesCreateRegionFromGCReq);
- REQUEST_SIZE_MATCH(xXFixesCreateRegionFromGCReq);
- LEGAL_NEW_RESOURCE(stuff->region, client);
- rc = dixLookupGC(&pGC, stuff->gc, client, DixGetAttrAccess);
- if (rc != Success)
- return rc;
- switch (pGC->clientClipType) {
- case CT_PIXMAP:
- pRegion = BitmapToRegion(pGC->pScreen, (PixmapPtr) pGC->clientClip);
- if (!pRegion)
- return BadAlloc;
- break;
- case CT_REGION:
- pClip = (RegionPtr) pGC->clientClip;
- pRegion = XFixesRegionCopy(pClip);
- if (!pRegion)
- return BadAlloc;
- break;
- default:
- return BadImplementation; /* assume sane server bits */
- }
- if (!AddResource(stuff->region, RegionResType, (void *) pRegion))
- return BadAlloc;
- return Success;
- }
- int
- SProcXFixesCreateRegionFromGC(ClientPtr client)
- {
- REQUEST(xXFixesCreateRegionFromGCReq);
- swaps(&stuff->length);
- REQUEST_SIZE_MATCH(xXFixesCreateRegionFromGCReq);
- swapl(&stuff->region);
- swapl(&stuff->gc);
- return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
- }
- int
- ProcXFixesCreateRegionFromPicture(ClientPtr client)
- {
- RegionPtr pRegion;
- PicturePtr pPicture;
- REQUEST(xXFixesCreateRegionFromPictureReq);
- REQUEST_SIZE_MATCH(xXFixesCreateRegionFromPictureReq);
- LEGAL_NEW_RESOURCE(stuff->region, client);
- VERIFY_PICTURE(pPicture, stuff->picture, client, DixGetAttrAccess);
- if (!pPicture->pDrawable)
- return RenderErrBase + BadPicture;
- switch (pPicture->clientClipType) {
- case CT_PIXMAP:
- pRegion = BitmapToRegion(pPicture->pDrawable->pScreen,
- (PixmapPtr) pPicture->clientClip);
- if (!pRegion)
- return BadAlloc;
- break;
- case CT_REGION:
- pRegion = XFixesRegionCopy((RegionPtr) pPicture->clientClip);
- if (!pRegion)
- return BadAlloc;
- break;
- default:
- return BadImplementation; /* assume sane server bits */
- }
- if (!AddResource(stuff->region, RegionResType, (void *) pRegion))
- return BadAlloc;
- return Success;
- }
- int
- SProcXFixesCreateRegionFromPicture(ClientPtr client)
- {
- REQUEST(xXFixesCreateRegionFromPictureReq);
- swaps(&stuff->length);
- REQUEST_SIZE_MATCH(xXFixesCreateRegionFromPictureReq);
- swapl(&stuff->region);
- swapl(&stuff->picture);
- return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
- }
- int
- ProcXFixesDestroyRegion(ClientPtr client)
- {
- REQUEST(xXFixesDestroyRegionReq);
- RegionPtr pRegion;
- REQUEST_SIZE_MATCH(xXFixesDestroyRegionReq);
- VERIFY_REGION(pRegion, stuff->region, client, DixWriteAccess);
- FreeResource(stuff->region, RT_NONE);
- return Success;
- }
- int
- SProcXFixesDestroyRegion(ClientPtr client)
- {
- REQUEST(xXFixesDestroyRegionReq);
- swaps(&stuff->length);
- REQUEST_SIZE_MATCH(xXFixesDestroyRegionReq);
- swapl(&stuff->region);
- return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
- }
- int
- ProcXFixesSetRegion(ClientPtr client)
- {
- int things;
- RegionPtr pRegion, pNew;
- REQUEST(xXFixesSetRegionReq);
- REQUEST_AT_LEAST_SIZE(xXFixesSetRegionReq);
- VERIFY_REGION(pRegion, stuff->region, client, DixWriteAccess);
- things = (client->req_len << 2) - sizeof(xXFixesCreateRegionReq);
- if (things & 4)
- return BadLength;
- things >>= 3;
- pNew = RegionFromRects(things, (xRectangle *) (stuff + 1), CT_UNSORTED);
- if (!pNew)
- return BadAlloc;
- if (!RegionCopy(pRegion, pNew)) {
- RegionDestroy(pNew);
- return BadAlloc;
- }
- RegionDestroy(pNew);
- return Success;
- }
- int
- SProcXFixesSetRegion(ClientPtr client)
- {
- REQUEST(xXFixesSetRegionReq);
- swaps(&stuff->length);
- REQUEST_AT_LEAST_SIZE(xXFixesSetRegionReq);
- swapl(&stuff->region);
- SwapRestS(stuff);
- return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
- }
- int
- ProcXFixesCopyRegion(ClientPtr client)
- {
- RegionPtr pSource, pDestination;
- REQUEST(xXFixesCopyRegionReq);
- VERIFY_REGION(pSource, stuff->source, client, DixReadAccess);
- VERIFY_REGION(pDestination, stuff->destination, client, DixWriteAccess);
- if (!RegionCopy(pDestination, pSource))
- return BadAlloc;
- return Success;
- }
- int
- SProcXFixesCopyRegion(ClientPtr client)
- {
- REQUEST(xXFixesCopyRegionReq);
- swaps(&stuff->length);
- REQUEST_AT_LEAST_SIZE(xXFixesCopyRegionReq);
- swapl(&stuff->source);
- swapl(&stuff->destination);
- return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
- }
- int
- ProcXFixesCombineRegion(ClientPtr client)
- {
- RegionPtr pSource1, pSource2, pDestination;
- REQUEST(xXFixesCombineRegionReq);
- REQUEST_SIZE_MATCH(xXFixesCombineRegionReq);
- VERIFY_REGION(pSource1, stuff->source1, client, DixReadAccess);
- VERIFY_REGION(pSource2, stuff->source2, client, DixReadAccess);
- VERIFY_REGION(pDestination, stuff->destination, client, DixWriteAccess);
- switch (stuff->xfixesReqType) {
- case X_XFixesUnionRegion:
- if (!RegionUnion(pDestination, pSource1, pSource2))
- return BadAlloc;
- break;
- case X_XFixesIntersectRegion:
- if (!RegionIntersect(pDestination, pSource1, pSource2))
- return BadAlloc;
- break;
- case X_XFixesSubtractRegion:
- if (!RegionSubtract(pDestination, pSource1, pSource2))
- return BadAlloc;
- break;
- }
- return Success;
- }
- int
- SProcXFixesCombineRegion(ClientPtr client)
- {
- REQUEST(xXFixesCombineRegionReq);
- swaps(&stuff->length);
- REQUEST_SIZE_MATCH(xXFixesCombineRegionReq);
- swapl(&stuff->source1);
- swapl(&stuff->source2);
- swapl(&stuff->destination);
- return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
- }
- int
- ProcXFixesInvertRegion(ClientPtr client)
- {
- RegionPtr pSource, pDestination;
- BoxRec bounds;
- REQUEST(xXFixesInvertRegionReq);
- REQUEST_SIZE_MATCH(xXFixesInvertRegionReq);
- VERIFY_REGION(pSource, stuff->source, client, DixReadAccess);
- VERIFY_REGION(pDestination, stuff->destination, client, DixWriteAccess);
- /* Compute bounds, limit to 16 bits */
- bounds.x1 = stuff->x;
- bounds.y1 = stuff->y;
- if ((int) stuff->x + (int) stuff->width > MAXSHORT)
- bounds.x2 = MAXSHORT;
- else
- bounds.x2 = stuff->x + stuff->width;
- if ((int) stuff->y + (int) stuff->height > MAXSHORT)
- bounds.y2 = MAXSHORT;
- else
- bounds.y2 = stuff->y + stuff->height;
- if (!RegionInverse(pDestination, pSource, &bounds))
- return BadAlloc;
- return Success;
- }
- int
- SProcXFixesInvertRegion(ClientPtr client)
- {
- REQUEST(xXFixesInvertRegionReq);
- swaps(&stuff->length);
- REQUEST_SIZE_MATCH(xXFixesInvertRegionReq);
- swapl(&stuff->source);
- swaps(&stuff->x);
- swaps(&stuff->y);
- swaps(&stuff->width);
- swaps(&stuff->height);
- swapl(&stuff->destination);
- return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
- }
- int
- ProcXFixesTranslateRegion(ClientPtr client)
- {
- RegionPtr pRegion;
- REQUEST(xXFixesTranslateRegionReq);
- REQUEST_SIZE_MATCH(xXFixesTranslateRegionReq);
- VERIFY_REGION(pRegion, stuff->region, client, DixWriteAccess);
- RegionTranslate(pRegion, stuff->dx, stuff->dy);
- return Success;
- }
- int
- SProcXFixesTranslateRegion(ClientPtr client)
- {
- REQUEST(xXFixesTranslateRegionReq);
- swaps(&stuff->length);
- REQUEST_SIZE_MATCH(xXFixesTranslateRegionReq);
- swapl(&stuff->region);
- swaps(&stuff->dx);
- swaps(&stuff->dy);
- return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
- }
- int
- ProcXFixesRegionExtents(ClientPtr client)
- {
- RegionPtr pSource, pDestination;
- REQUEST(xXFixesRegionExtentsReq);
- REQUEST_SIZE_MATCH(xXFixesRegionExtentsReq);
- VERIFY_REGION(pSource, stuff->source, client, DixReadAccess);
- VERIFY_REGION(pDestination, stuff->destination, client, DixWriteAccess);
- RegionReset(pDestination, RegionExtents(pSource));
- return Success;
- }
- int
- SProcXFixesRegionExtents(ClientPtr client)
- {
- REQUEST(xXFixesRegionExtentsReq);
- swaps(&stuff->length);
- REQUEST_SIZE_MATCH(xXFixesRegionExtentsReq);
- swapl(&stuff->source);
- swapl(&stuff->destination);
- return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
- }
- int
- ProcXFixesFetchRegion(ClientPtr client)
- {
- RegionPtr pRegion;
- xXFixesFetchRegionReply *reply;
- xRectangle *pRect;
- BoxPtr pExtent;
- BoxPtr pBox;
- int i, nBox;
- REQUEST(xXFixesFetchRegionReq);
- REQUEST_SIZE_MATCH(xXFixesFetchRegionReq);
- VERIFY_REGION(pRegion, stuff->region, client, DixReadAccess);
- pExtent = RegionExtents(pRegion);
- pBox = RegionRects(pRegion);
- nBox = RegionNumRects(pRegion);
- reply = calloc(sizeof(xXFixesFetchRegionReply) + nBox * sizeof(xRectangle),
- 1);
- if (!reply)
- return BadAlloc;
- reply->type = X_Reply;
- reply->sequenceNumber = client->sequence;
- reply->length = nBox << 1;
- reply->x = pExtent->x1;
- reply->y = pExtent->y1;
- reply->width = pExtent->x2 - pExtent->x1;
- reply->height = pExtent->y2 - pExtent->y1;
- pRect = (xRectangle *) (reply + 1);
- for (i = 0; i < nBox; i++) {
- pRect[i].x = pBox[i].x1;
- pRect[i].y = pBox[i].y1;
- pRect[i].width = pBox[i].x2 - pBox[i].x1;
- pRect[i].height = pBox[i].y2 - pBox[i].y1;
- }
- if (client->swapped) {
- swaps(&reply->sequenceNumber);
- swapl(&reply->length);
- swaps(&reply->x);
- swaps(&reply->y);
- swaps(&reply->width);
- swaps(&reply->height);
- SwapShorts((INT16 *) pRect, nBox * 4);
- }
- WriteToClient(client, sizeof(xXFixesFetchRegionReply) +
- nBox * sizeof(xRectangle), (char *) reply);
- free(reply);
- return Success;
- }
- int
- SProcXFixesFetchRegion(ClientPtr client)
- {
- REQUEST(xXFixesFetchRegionReq);
- swaps(&stuff->length);
- REQUEST_SIZE_MATCH(xXFixesFetchRegionReq);
- swapl(&stuff->region);
- return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
- }
- int
- ProcXFixesSetGCClipRegion(ClientPtr client)
- {
- GCPtr pGC;
- RegionPtr pRegion;
- ChangeGCVal vals[2];
- int rc;
- REQUEST(xXFixesSetGCClipRegionReq);
- REQUEST_SIZE_MATCH(xXFixesSetGCClipRegionReq);
- rc = dixLookupGC(&pGC, stuff->gc, client, DixSetAttrAccess);
- if (rc != Success)
- return rc;
- VERIFY_REGION_OR_NONE(pRegion, stuff->region, client, DixReadAccess);
- if (pRegion) {
- pRegion = XFixesRegionCopy(pRegion);
- if (!pRegion)
- return BadAlloc;
- }
- vals[0].val = stuff->xOrigin;
- vals[1].val = stuff->yOrigin;
- ChangeGC(NullClient, pGC, GCClipXOrigin | GCClipYOrigin, vals);
- (*pGC->funcs->ChangeClip) (pGC, pRegion ? CT_REGION : CT_NONE,
- (void *) pRegion, 0);
- return Success;
- }
- int
- SProcXFixesSetGCClipRegion(ClientPtr client)
- {
- REQUEST(xXFixesSetGCClipRegionReq);
- swaps(&stuff->length);
- REQUEST_SIZE_MATCH(xXFixesSetGCClipRegionReq);
- swapl(&stuff->gc);
- swapl(&stuff->region);
- swaps(&stuff->xOrigin);
- swaps(&stuff->yOrigin);
- return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
- }
- typedef RegionPtr (*CreateDftPtr) (WindowPtr pWin);
- 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;
- }
- int
- SProcXFixesSetWindowShapeRegion(ClientPtr client)
- {
- REQUEST(xXFixesSetWindowShapeRegionReq);
- swaps(&stuff->length);
- REQUEST_SIZE_MATCH(xXFixesSetWindowShapeRegionReq);
- swapl(&stuff->dest);
- swaps(&stuff->xOff);
- swaps(&stuff->yOff);
- swapl(&stuff->region);
- return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
- }
- int
- ProcXFixesSetPictureClipRegion(ClientPtr client)
- {
- PicturePtr pPicture;
- RegionPtr pRegion;
- REQUEST(xXFixesSetPictureClipRegionReq);
- REQUEST_SIZE_MATCH(xXFixesSetPictureClipRegionReq);
- VERIFY_PICTURE(pPicture, stuff->picture, client, DixSetAttrAccess);
- VERIFY_REGION_OR_NONE(pRegion, stuff->region, client, DixReadAccess);
- if (!pPicture->pDrawable)
- return RenderErrBase + BadPicture;
- return SetPictureClipRegion(pPicture, stuff->xOrigin, stuff->yOrigin,
- pRegion);
- }
- int
- SProcXFixesSetPictureClipRegion(ClientPtr client)
- {
- REQUEST(xXFixesSetPictureClipRegionReq);
- swaps(&stuff->length);
- REQUEST_SIZE_MATCH(xXFixesSetPictureClipRegionReq);
- swapl(&stuff->picture);
- swapl(&stuff->region);
- swaps(&stuff->xOrigin);
- swaps(&stuff->yOrigin);
- return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
- }
- int
- ProcXFixesExpandRegion(ClientPtr client)
- {
- RegionPtr pSource, pDestination;
- REQUEST(xXFixesExpandRegionReq);
- BoxPtr pTmp;
- BoxPtr pSrc;
- int nBoxes;
- int i;
- REQUEST_SIZE_MATCH(xXFixesExpandRegionReq);
- VERIFY_REGION(pSource, stuff->source, client, DixReadAccess);
- VERIFY_REGION(pDestination, stuff->destination, client, DixWriteAccess);
- nBoxes = RegionNumRects(pSource);
- pSrc = RegionRects(pSource);
- if (nBoxes) {
- pTmp = malloc(nBoxes * sizeof(BoxRec));
- if (!pTmp)
- return BadAlloc;
- for (i = 0; i < nBoxes; i++) {
- pTmp[i].x1 = pSrc[i].x1 - stuff->left;
- pTmp[i].x2 = pSrc[i].x2 + stuff->right;
- pTmp[i].y1 = pSrc[i].y1 - stuff->top;
- pTmp[i].y2 = pSrc[i].y2 + stuff->bottom;
- }
- RegionEmpty(pDestination);
- for (i = 0; i < nBoxes; i++) {
- RegionRec r;
- RegionInit(&r, &pTmp[i], 0);
- RegionUnion(pDestination, pDestination, &r);
- }
- free(pTmp);
- }
- return Success;
- }
- int
- SProcXFixesExpandRegion(ClientPtr client)
- {
- REQUEST(xXFixesExpandRegionReq);
- swaps(&stuff->length);
- REQUEST_SIZE_MATCH(xXFixesExpandRegionReq);
- swapl(&stuff->source);
- swapl(&stuff->destination);
- swaps(&stuff->left);
- swaps(&stuff->right);
- swaps(&stuff->top);
- swaps(&stuff->bottom);
- return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
- }
- #ifdef PANORAMIX
- #include "panoramiX.h"
- #include "panoramiXsrv.h"
- int
- PanoramiXFixesSetGCClipRegion(ClientPtr client)
- {
- REQUEST(xXFixesSetGCClipRegionReq);
- int result = Success, j;
- PanoramiXRes *gc;
- REQUEST_SIZE_MATCH(xXFixesSetGCClipRegionReq);
- if ((result = dixLookupResourceByType((void **) &gc, stuff->gc, XRT_GC,
- client, DixWriteAccess))) {
- client->errorValue = stuff->gc;
- return result;
- }
- FOR_NSCREENS_BACKWARD(j) {
- stuff->gc = gc->info[j].id;
- result = (*PanoramiXSaveXFixesVector[X_XFixesSetGCClipRegion]) (client);
- if (result != Success)
- break;
- }
- return result;
- }
- int
- PanoramiXFixesSetWindowShapeRegion(ClientPtr client)
- {
- int result = Success, j;
- PanoramiXRes *win;
- RegionPtr reg = NULL;
- REQUEST(xXFixesSetWindowShapeRegionReq);
- REQUEST_SIZE_MATCH(xXFixesSetWindowShapeRegionReq);
- if ((result = dixLookupResourceByType((void **) &win, stuff->dest,
- XRT_WINDOW, client,
- DixWriteAccess))) {
- client->errorValue = stuff->dest;
- return result;
- }
- if (win->u.win.root)
- VERIFY_REGION_OR_NONE(reg, stuff->region, client, DixReadAccess);
- FOR_NSCREENS_FORWARD(j) {
- ScreenPtr screen = screenInfo.screens[j];
- stuff->dest = win->info[j].id;
- if (reg)
- RegionTranslate(reg, -screen->x, -screen->y);
- result =
- (*PanoramiXSaveXFixesVector[X_XFixesSetWindowShapeRegion]) (client);
- if (reg)
- RegionTranslate(reg, screen->x, screen->y);
- if (result != Success)
- break;
- }
- return result;
- }
- int
- PanoramiXFixesSetPictureClipRegion(ClientPtr client)
- {
- REQUEST(xXFixesSetPictureClipRegionReq);
- int result = Success, j;
- PanoramiXRes *pict;
- RegionPtr reg = NULL;
- REQUEST_SIZE_MATCH(xXFixesSetPictureClipRegionReq);
- if ((result = dixLookupResourceByType((void **) &pict, stuff->picture,
- XRT_PICTURE, client,
- DixWriteAccess))) {
- client->errorValue = stuff->picture;
- return result;
- }
- if (pict->u.pict.root)
- VERIFY_REGION_OR_NONE(reg, stuff->region, client, DixReadAccess);
- FOR_NSCREENS_BACKWARD(j) {
- ScreenPtr screen = screenInfo.screens[j];
- stuff->picture = pict->info[j].id;
- if (reg)
- RegionTranslate(reg, -screen->x, -screen->y);
- result =
- (*PanoramiXSaveXFixesVector[X_XFixesSetPictureClipRegion]) (client);
- if (reg)
- RegionTranslate(reg, screen->x, screen->y);
- if (result != Success)
- break;
- }
- return result;
- }
- #endif
|