xenocara/xserver/xfixes/region.c

911 lines
23 KiB
C
Raw Normal View History

2006-11-26 11:13:41 -07:00
/*
* 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>
2006-11-26 11:13:41 -07:00
#include <regionstr.h>
#include <gcstruct.h>
#include <window.h>
RESTYPE RegionResType;
2006-11-26 11:13:41 -07:00
static int
RegionResFree(pointer data, XID id)
2006-11-26 11:13:41 -07:00
{
RegionPtr pRegion = (RegionPtr) data;
2006-11-26 11:13:41 -07:00
RegionDestroy(pRegion);
2006-11-26 11:13:41 -07:00
return Success;
}
RegionPtr
XFixesRegionCopy(RegionPtr pRegion)
2006-11-26 11:13:41 -07:00
{
RegionPtr pNew = RegionCreate(RegionExtents(pRegion),
RegionNumRects(pRegion));
2006-11-26 11:13:41 -07:00
if (!pNew)
return 0;
if (!RegionCopy(pNew, pRegion)) {
RegionDestroy(pNew);
return 0;
2006-11-26 11:13:41 -07:00
}
return pNew;
}
Bool
XFixesRegionInit(void)
2006-11-26 11:13:41 -07:00
{
RegionResType = CreateNewResourceType(RegionResFree, "XFixesRegion");
return RegionResType != 0;
2006-11-26 11:13:41 -07:00
}
int
ProcXFixesCreateRegion(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
int things;
RegionPtr pRegion;
REQUEST(xXFixesCreateRegionReq);
2006-11-26 11:13:41 -07:00
REQUEST_AT_LEAST_SIZE(xXFixesCreateRegionReq);
LEGAL_NEW_RESOURCE(stuff->region, client);
things = (client->req_len << 2) - sizeof(xXFixesCreateRegionReq);
2006-11-26 11:13:41 -07:00
if (things & 4)
return BadLength;
2006-11-26 11:13:41 -07:00
things >>= 3;
pRegion = RegionFromRects(things, (xRectangle *) (stuff + 1), CT_UNSORTED);
2006-11-26 11:13:41 -07:00
if (!pRegion)
return BadAlloc;
if (!AddResource(stuff->region, RegionResType, (pointer) pRegion))
return BadAlloc;
return Success;
2006-11-26 11:13:41 -07:00
}
int
SProcXFixesCreateRegion(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
REQUEST(xXFixesCreateRegionReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_AT_LEAST_SIZE(xXFixesCreateRegionReq);
swapl(&stuff->region);
2006-11-26 11:13:41 -07:00
SwapRestS(stuff);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int
ProcXFixesCreateRegionFromBitmap(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
RegionPtr pRegion;
PixmapPtr pPixmap;
int rc;
2006-11-26 11:13:41 -07:00
REQUEST(xXFixesCreateRegionFromBitmapReq);
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xXFixesCreateRegionFromBitmapReq);
LEGAL_NEW_RESOURCE(stuff->region, client);
rc = dixLookupResourceByType((pointer *) &pPixmap, stuff->bitmap, RT_PIXMAP,
client, DixReadAccess);
if (rc != Success) {
client->errorValue = stuff->bitmap;
return rc;
2006-11-26 11:13:41 -07:00
}
if (pPixmap->drawable.depth != 1)
return BadMatch;
2006-11-26 11:13:41 -07:00
pRegion = BitmapToRegion(pPixmap->drawable.pScreen, pPixmap);
2006-11-26 11:13:41 -07:00
if (!pRegion)
return BadAlloc;
if (!AddResource(stuff->region, RegionResType, (pointer) pRegion))
return BadAlloc;
return Success;
2006-11-26 11:13:41 -07:00
}
int
SProcXFixesCreateRegionFromBitmap(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
REQUEST(xXFixesCreateRegionFromBitmapReq);
2006-11-26 11:13:41 -07:00
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXFixesCreateRegionFromBitmapReq);
swapl(&stuff->region);
swapl(&stuff->bitmap);
2006-11-26 11:13:41 -07:00
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int
ProcXFixesCreateRegionFromWindow(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
RegionPtr pRegion;
Bool copy = TRUE;
WindowPtr pWin;
int rc;
REQUEST(xXFixesCreateRegionFromWindowReq);
REQUEST_SIZE_MATCH(xXFixesCreateRegionFromWindowReq);
LEGAL_NEW_RESOURCE(stuff->region, client);
rc = dixLookupResourceByType((pointer *) &pWin, stuff->window, RT_WINDOW,
client, DixGetAttrAccess);
if (rc != Success) {
client->errorValue = stuff->window;
return rc;
2006-11-26 11:13:41 -07:00
}
switch (stuff->kind) {
case WindowRegionBounding:
pRegion = wBoundingShape(pWin);
if (!pRegion) {
pRegion = CreateBoundingShape(pWin);
copy = FALSE;
}
break;
2006-11-26 11:13:41 -07:00
case WindowRegionClip:
pRegion = wClipShape(pWin);
if (!pRegion) {
pRegion = CreateClipShape(pWin);
copy = FALSE;
}
break;
2006-11-26 11:13:41 -07:00
default:
client->errorValue = stuff->kind;
return BadValue;
2006-11-26 11:13:41 -07:00
}
if (copy && pRegion)
pRegion = XFixesRegionCopy(pRegion);
2006-11-26 11:13:41 -07:00
if (!pRegion)
return BadAlloc;
if (!AddResource(stuff->region, RegionResType, (pointer) pRegion))
return BadAlloc;
return Success;
2006-11-26 11:13:41 -07:00
}
int
SProcXFixesCreateRegionFromWindow(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
REQUEST(xXFixesCreateRegionFromWindowReq);
2006-11-26 11:13:41 -07:00
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXFixesCreateRegionFromWindowReq);
swapl(&stuff->region);
swapl(&stuff->window);
2006-11-26 11:13:41 -07:00
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int
ProcXFixesCreateRegionFromGC(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
RegionPtr pRegion, pClip;
GCPtr pGC;
int rc;
REQUEST(xXFixesCreateRegionFromGCReq);
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xXFixesCreateRegionFromGCReq);
LEGAL_NEW_RESOURCE(stuff->region, client);
2006-11-26 11:13:41 -07:00
rc = dixLookupGC(&pGC, stuff->gc, client, DixGetAttrAccess);
2007-11-24 10:55:21 -07:00
if (rc != Success)
return rc;
2006-11-26 11:13:41 -07:00
switch (pGC->clientClipType) {
case CT_PIXMAP:
pRegion = BitmapToRegion(pGC->pScreen, (PixmapPtr) pGC->clientClip);
if (!pRegion)
return BadAlloc;
break;
2006-11-26 11:13:41 -07:00
case CT_REGION:
pClip = (RegionPtr) pGC->clientClip;
pRegion = XFixesRegionCopy(pClip);
if (!pRegion)
return BadAlloc;
break;
2006-11-26 11:13:41 -07:00
default:
return BadImplementation; /* assume sane server bits */
2006-11-26 11:13:41 -07:00
}
if (!AddResource(stuff->region, RegionResType, (pointer) pRegion))
return BadAlloc;
return Success;
2006-11-26 11:13:41 -07:00
}
int
SProcXFixesCreateRegionFromGC(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
REQUEST(xXFixesCreateRegionFromGCReq);
2006-11-26 11:13:41 -07:00
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXFixesCreateRegionFromGCReq);
swapl(&stuff->region);
swapl(&stuff->gc);
2006-11-26 11:13:41 -07:00
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int
ProcXFixesCreateRegionFromPicture(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
RegionPtr pRegion;
PicturePtr pPicture;
2006-11-26 11:13:41 -07:00
REQUEST(xXFixesCreateRegionFromPictureReq);
REQUEST_SIZE_MATCH(xXFixesCreateRegionFromPictureReq);
LEGAL_NEW_RESOURCE(stuff->region, client);
2006-11-26 11:13:41 -07:00
VERIFY_PICTURE(pPicture, stuff->picture, client, DixGetAttrAccess);
2006-11-26 11:13:41 -07:00
switch (pPicture->clientClipType) {
case CT_PIXMAP:
pRegion = BitmapToRegion(pPicture->pDrawable->pScreen,
(PixmapPtr) pPicture->clientClip);
if (!pRegion)
return BadAlloc;
break;
2006-11-26 11:13:41 -07:00
case CT_REGION:
pRegion = XFixesRegionCopy((RegionPtr) pPicture->clientClip);
if (!pRegion)
return BadAlloc;
break;
2006-11-26 11:13:41 -07:00
default:
return BadImplementation; /* assume sane server bits */
2006-11-26 11:13:41 -07:00
}
if (!AddResource(stuff->region, RegionResType, (pointer) pRegion))
return BadAlloc;
return Success;
2006-11-26 11:13:41 -07:00
}
int
SProcXFixesCreateRegionFromPicture(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
REQUEST(xXFixesCreateRegionFromPictureReq);
2006-11-26 11:13:41 -07:00
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXFixesCreateRegionFromPictureReq);
swapl(&stuff->region);
swapl(&stuff->picture);
2006-11-26 11:13:41 -07:00
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int
ProcXFixesDestroyRegion(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
REQUEST(xXFixesDestroyRegionReq);
RegionPtr pRegion;
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xXFixesDestroyRegionReq);
2007-11-24 10:55:21 -07:00
VERIFY_REGION(pRegion, stuff->region, client, DixWriteAccess);
FreeResource(stuff->region, RT_NONE);
return Success;
2006-11-26 11:13:41 -07:00
}
int
SProcXFixesDestroyRegion(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
REQUEST(xXFixesDestroyRegionReq);
2006-11-26 11:13:41 -07:00
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xXFixesDestroyRegionReq);
swapl(&stuff->region);
2006-11-26 11:13:41 -07:00
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int
ProcXFixesSetRegion(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
int things;
RegionPtr pRegion, pNew;
REQUEST(xXFixesSetRegionReq);
2006-11-26 11:13:41 -07:00
REQUEST_AT_LEAST_SIZE(xXFixesSetRegionReq);
2007-11-24 10:55:21 -07:00
VERIFY_REGION(pRegion, stuff->region, client, DixWriteAccess);
things = (client->req_len << 2) - sizeof(xXFixesCreateRegionReq);
2006-11-26 11:13:41 -07:00
if (things & 4)
return BadLength;
2006-11-26 11:13:41 -07:00
things >>= 3;
pNew = RegionFromRects(things, (xRectangle *) (stuff + 1), CT_UNSORTED);
2006-11-26 11:13:41 -07:00
if (!pNew)
return BadAlloc;
if (!RegionCopy(pRegion, pNew)) {
RegionDestroy(pNew);
return BadAlloc;
2006-11-26 11:13:41 -07:00
}
RegionDestroy(pNew);
return Success;
2006-11-26 11:13:41 -07:00
}
int
SProcXFixesSetRegion(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
REQUEST(xXFixesSetRegionReq);
2006-11-26 11:13:41 -07:00
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_AT_LEAST_SIZE(xXFixesSetRegionReq);
swapl(&stuff->region);
2006-11-26 11:13:41 -07:00
SwapRestS(stuff);
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int
ProcXFixesCopyRegion(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
RegionPtr pSource, pDestination;
REQUEST(xXFixesCopyRegionReq);
2007-11-24 10:55:21 -07:00
VERIFY_REGION(pSource, stuff->source, client, DixReadAccess);
VERIFY_REGION(pDestination, stuff->destination, client, DixWriteAccess);
if (!RegionCopy(pDestination, pSource))
return BadAlloc;
2006-11-26 11:13:41 -07:00
return Success;
2006-11-26 11:13:41 -07:00
}
int
SProcXFixesCopyRegion(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
REQUEST(xXFixesCopyRegionReq);
2006-11-26 11:13:41 -07:00
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_AT_LEAST_SIZE(xXFixesCopyRegionReq);
swapl(&stuff->source);
swapl(&stuff->destination);
2006-11-26 11:13:41 -07:00
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int
ProcXFixesCombineRegion(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
RegionPtr pSource1, pSource2, pDestination;
2006-11-26 11:13:41 -07:00
REQUEST(xXFixesCombineRegionReq);
REQUEST_SIZE_MATCH(xXFixesCombineRegionReq);
2007-11-24 10:55:21 -07:00
VERIFY_REGION(pSource1, stuff->source1, client, DixReadAccess);
VERIFY_REGION(pSource2, stuff->source2, client, DixReadAccess);
VERIFY_REGION(pDestination, stuff->destination, client, DixWriteAccess);
2006-11-26 11:13:41 -07:00
switch (stuff->xfixesReqType) {
case X_XFixesUnionRegion:
if (!RegionUnion(pDestination, pSource1, pSource2))
return BadAlloc;
break;
2006-11-26 11:13:41 -07:00
case X_XFixesIntersectRegion:
if (!RegionIntersect(pDestination, pSource1, pSource2))
return BadAlloc;
break;
2006-11-26 11:13:41 -07:00
case X_XFixesSubtractRegion:
if (!RegionSubtract(pDestination, pSource1, pSource2))
return BadAlloc;
break;
2006-11-26 11:13:41 -07:00
}
return Success;
2006-11-26 11:13:41 -07:00
}
int
SProcXFixesCombineRegion(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
REQUEST(xXFixesCombineRegionReq);
2006-11-26 11:13:41 -07:00
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXFixesCombineRegionReq);
swapl(&stuff->source1);
swapl(&stuff->source2);
swapl(&stuff->destination);
2006-11-26 11:13:41 -07:00
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int
ProcXFixesInvertRegion(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
RegionPtr pSource, pDestination;
BoxRec bounds;
2006-11-26 11:13:41 -07:00
REQUEST(xXFixesInvertRegionReq);
REQUEST_SIZE_MATCH(xXFixesInvertRegionReq);
2007-11-24 10:55:21 -07:00
VERIFY_REGION(pSource, stuff->source, client, DixReadAccess);
VERIFY_REGION(pDestination, stuff->destination, client, DixWriteAccess);
2006-11-26 11:13:41 -07:00
/* 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;
2006-11-26 11:13:41 -07:00
else
bounds.x2 = stuff->x + stuff->width;
2006-11-26 11:13:41 -07:00
if ((int) stuff->y + (int) stuff->height > MAXSHORT)
bounds.y2 = MAXSHORT;
2006-11-26 11:13:41 -07:00
else
bounds.y2 = stuff->y + stuff->height;
2006-11-26 11:13:41 -07:00
if (!RegionInverse(pDestination, pSource, &bounds))
return BadAlloc;
2006-11-26 11:13:41 -07:00
return Success;
2006-11-26 11:13:41 -07:00
}
int
SProcXFixesInvertRegion(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
REQUEST(xXFixesInvertRegionReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xXFixesInvertRegionReq);
swapl(&stuff->source);
swaps(&stuff->x);
swaps(&stuff->y);
swaps(&stuff->width);
swaps(&stuff->height);
swapl(&stuff->destination);
2006-11-26 11:13:41 -07:00
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int
ProcXFixesTranslateRegion(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
RegionPtr pRegion;
2006-11-26 11:13:41 -07:00
REQUEST(xXFixesTranslateRegionReq);
REQUEST_SIZE_MATCH(xXFixesTranslateRegionReq);
2007-11-24 10:55:21 -07:00
VERIFY_REGION(pRegion, stuff->region, client, DixWriteAccess);
2006-11-26 11:13:41 -07:00
RegionTranslate(pRegion, stuff->dx, stuff->dy);
return Success;
2006-11-26 11:13:41 -07:00
}
int
SProcXFixesTranslateRegion(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
REQUEST(xXFixesTranslateRegionReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xXFixesTranslateRegionReq);
swapl(&stuff->region);
swaps(&stuff->dx);
swaps(&stuff->dy);
2006-11-26 11:13:41 -07:00
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int
ProcXFixesRegionExtents(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
RegionPtr pSource, pDestination;
2006-11-26 11:13:41 -07:00
REQUEST(xXFixesRegionExtentsReq);
REQUEST_SIZE_MATCH(xXFixesRegionExtentsReq);
2007-11-24 10:55:21 -07:00
VERIFY_REGION(pSource, stuff->source, client, DixReadAccess);
VERIFY_REGION(pDestination, stuff->destination, client, DixWriteAccess);
2006-11-26 11:13:41 -07:00
RegionReset(pDestination, RegionExtents(pSource));
2006-11-26 11:13:41 -07:00
return Success;
2006-11-26 11:13:41 -07:00
}
int
SProcXFixesRegionExtents(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
REQUEST(xXFixesRegionExtentsReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xXFixesRegionExtentsReq);
swapl(&stuff->source);
swapl(&stuff->destination);
2006-11-26 11:13:41 -07:00
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int
ProcXFixesFetchRegion(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
RegionPtr pRegion;
2006-11-26 11:13:41 -07:00
xXFixesFetchRegionReply *reply;
xRectangle *pRect;
BoxPtr pExtent;
BoxPtr pBox;
int i, nBox;
2006-11-26 11:13:41 -07:00
REQUEST(xXFixesFetchRegionReq);
REQUEST_SIZE_MATCH(xXFixesFetchRegionReq);
2007-11-24 10:55:21 -07:00
VERIFY_REGION(pRegion, stuff->region, client, DixReadAccess);
2006-11-26 11:13:41 -07:00
pExtent = RegionExtents(pRegion);
pBox = RegionRects(pRegion);
nBox = RegionNumRects(pRegion);
reply = calloc(sizeof(xXFixesFetchRegionReply) + nBox * sizeof(xRectangle),
1);
2006-11-26 11:13:41 -07:00
if (!reply)
return BadAlloc;
2006-11-26 11:13:41 -07:00
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;
2006-11-26 11:13:41 -07:00
}
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);
2006-11-26 11:13:41 -07:00
}
WriteToClient(client, sizeof(xXFixesFetchRegionReply) +
nBox * sizeof(xRectangle), (char *) reply);
free(reply);
return Success;
2006-11-26 11:13:41 -07:00
}
int
SProcXFixesFetchRegion(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
REQUEST(xXFixesFetchRegionReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xXFixesFetchRegionReq);
swapl(&stuff->region);
2006-11-26 11:13:41 -07:00
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int
ProcXFixesSetGCClipRegion(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
GCPtr pGC;
RegionPtr pRegion;
ChangeGCVal vals[2];
int rc;
2006-11-26 11:13:41 -07:00
REQUEST(xXFixesSetGCClipRegionReq);
REQUEST_SIZE_MATCH(xXFixesSetGCClipRegionReq);
2007-11-24 10:55:21 -07:00
rc = dixLookupGC(&pGC, stuff->gc, client, DixSetAttrAccess);
2007-11-24 10:55:21 -07:00
if (rc != Success)
return rc;
2007-11-24 10:55:21 -07:00
VERIFY_REGION_OR_NONE(pRegion, stuff->region, client, DixReadAccess);
2006-11-26 11:13:41 -07:00
if (pRegion) {
pRegion = XFixesRegionCopy(pRegion);
if (!pRegion)
return BadAlloc;
2006-11-26 11:13:41 -07:00
}
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,
(pointer) pRegion, 0);
2006-11-26 11:13:41 -07:00
return Success;
2006-11-26 11:13:41 -07:00
}
int
SProcXFixesSetGCClipRegion(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
REQUEST(xXFixesSetGCClipRegionReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xXFixesSetGCClipRegionReq);
swapl(&stuff->gc);
swapl(&stuff->region);
swaps(&stuff->xOrigin);
swaps(&stuff->yOrigin);
2006-11-26 11:13:41 -07:00
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
typedef RegionPtr (*CreateDftPtr) (WindowPtr pWin);
2006-11-26 11:13:41 -07:00
int
ProcXFixesSetWindowShapeRegion(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
WindowPtr pWin;
RegionPtr pRegion;
RegionPtr *pDestRegion;
int rc;
2006-11-26 11:13:41 -07:00
REQUEST(xXFixesSetWindowShapeRegionReq);
REQUEST_SIZE_MATCH(xXFixesSetWindowShapeRegionReq);
rc = dixLookupResourceByType((pointer *) &pWin, stuff->dest, RT_WINDOW,
client, DixSetAttrAccess);
if (rc != Success) {
client->errorValue = stuff->dest;
return rc;
2006-11-26 11:13:41 -07:00
}
2007-11-24 10:55:21 -07:00
VERIFY_REGION_OR_NONE(pRegion, stuff->region, client, DixWriteAccess);
2006-11-26 11:13:41 -07:00
switch (stuff->destKind) {
case ShapeBounding:
case ShapeClip:
case ShapeInput:
break;
2006-11-26 11:13:41 -07:00
default:
client->errorValue = stuff->destKind;
return BadValue;
2006-11-26 11:13:41 -07:00
}
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);
2006-11-26 11:13:41 -07:00
}
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 */
2006-11-26 11:13:41 -07:00
}
if (*pDestRegion)
RegionDestroy(*pDestRegion);
2006-11-26 11:13:41 -07:00
*pDestRegion = pRegion;
(*pWin->drawable.pScreen->SetShape) (pWin, stuff->destKind);
SendShapeNotify(pWin, stuff->destKind);
return Success;
2006-11-26 11:13:41 -07:00
}
int
SProcXFixesSetWindowShapeRegion(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
REQUEST(xXFixesSetWindowShapeRegionReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xXFixesSetWindowShapeRegionReq);
swapl(&stuff->dest);
swaps(&stuff->xOff);
swaps(&stuff->yOff);
swapl(&stuff->region);
2006-11-26 11:13:41 -07:00
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int
ProcXFixesSetPictureClipRegion(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
PicturePtr pPicture;
RegionPtr pRegion;
2006-11-26 11:13:41 -07:00
REQUEST(xXFixesSetPictureClipRegionReq);
REQUEST_SIZE_MATCH(xXFixesSetPictureClipRegionReq);
VERIFY_PICTURE(pPicture, stuff->picture, client, DixSetAttrAccess);
2007-11-24 10:55:21 -07:00
VERIFY_REGION_OR_NONE(pRegion, stuff->region, client, DixReadAccess);
return SetPictureClipRegion(pPicture, stuff->xOrigin, stuff->yOrigin,
pRegion);
2006-11-26 11:13:41 -07:00
}
int
SProcXFixesSetPictureClipRegion(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
REQUEST(xXFixesSetPictureClipRegionReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xXFixesSetPictureClipRegionReq);
swapl(&stuff->picture);
swapl(&stuff->region);
swaps(&stuff->xOrigin);
swaps(&stuff->yOrigin);
2006-11-26 11:13:41 -07:00
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
int
ProcXFixesExpandRegion(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
RegionPtr pSource, pDestination;
REQUEST(xXFixesExpandRegionReq);
BoxPtr pTmp;
BoxPtr pSrc;
int nBoxes;
int i;
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xXFixesExpandRegionReq);
2007-11-24 10:55:21 -07:00
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);
2006-11-26 11:13:41 -07:00
}
return Success;
2006-11-26 11:13:41 -07:00
}
int
SProcXFixesExpandRegion(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
REQUEST(xXFixesExpandRegionReq);
2006-11-26 11:13:41 -07:00
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);
2006-11-26 11:13:41 -07:00
return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
}
2011-11-05 07:32:40 -06:00
#ifdef PANORAMIX
#include "panoramiX.h"
#include "panoramiXsrv.h"
int
PanoramiXFixesSetGCClipRegion(ClientPtr client)
2011-11-05 07:32:40 -06:00
{
REQUEST(xXFixesSetGCClipRegionReq);
int result = Success, j;
PanoramiXRes *gc;
2011-11-05 07:32:40 -06:00
REQUEST_SIZE_MATCH(xXFixesSetGCClipRegionReq);
if ((result = dixLookupResourceByType((void **) &gc, stuff->gc, XRT_GC,
client, DixWriteAccess))) {
client->errorValue = stuff->gc;
return result;
2011-11-05 07:32:40 -06:00
}
FOR_NSCREENS_BACKWARD(j) {
stuff->gc = gc->info[j].id;
result = (*PanoramiXSaveXFixesVector[X_XFixesSetGCClipRegion]) (client);
if (result != Success)
break;
2011-11-05 07:32:40 -06:00
}
return result;
}
int
PanoramiXFixesSetWindowShapeRegion(ClientPtr client)
2011-11-05 07:32:40 -06:00
{
int result = Success, j;
PanoramiXRes *win;
2011-11-05 07:32:40 -06:00
REQUEST(xXFixesSetWindowShapeRegionReq);
REQUEST_SIZE_MATCH(xXFixesSetWindowShapeRegionReq);
if ((result = dixLookupResourceByType((void **) &win, stuff->dest,
XRT_WINDOW, client,
DixWriteAccess))) {
client->errorValue = stuff->dest;
return result;
2011-11-05 07:32:40 -06:00
}
FOR_NSCREENS_FORWARD(j) {
stuff->dest = win->info[j].id;
result =
(*PanoramiXSaveXFixesVector[X_XFixesSetWindowShapeRegion]) (client);
if (result != Success)
break;
2011-11-05 07:32:40 -06:00
}
return result;
}
int
PanoramiXFixesSetPictureClipRegion(ClientPtr client)
2011-11-05 07:32:40 -06:00
{
REQUEST(xXFixesSetPictureClipRegionReq);
int result = Success, j;
PanoramiXRes *pict;
2011-11-05 07:32:40 -06:00
REQUEST_SIZE_MATCH(xXFixesSetPictureClipRegionReq);
2011-11-05 07:32:40 -06:00
if ((result = dixLookupResourceByType((void **) &pict, stuff->picture,
XRT_PICTURE, client,
DixWriteAccess))) {
client->errorValue = stuff->picture;
return result;
2011-11-05 07:32:40 -06:00
}
FOR_NSCREENS_BACKWARD(j) {
stuff->picture = pict->info[j].id;
result =
(*PanoramiXSaveXFixesVector[X_XFixesSetPictureClipRegion]) (client);
if (result != Success)
break;
2011-11-05 07:32:40 -06:00
}
return result;
}
#endif