1706f2543Smrg/*
2706f2543Smrg * Copyright © 2003 Keith Packard
3706f2543Smrg *
4706f2543Smrg * Permission to use, copy, modify, distribute, and sell this software and its
5706f2543Smrg * documentation for any purpose is hereby granted without fee, provided that
6706f2543Smrg * the above copyright notice appear in all copies and that both that
7706f2543Smrg * copyright notice and this permission notice appear in supporting
8706f2543Smrg * documentation, and that the name of Keith Packard not be used in
9706f2543Smrg * advertising or publicity pertaining to distribution of the software without
10706f2543Smrg * specific, written prior permission.  Keith Packard makes no
11706f2543Smrg * representations about the suitability of this software for any purpose.  It
12706f2543Smrg * is provided "as is" without express or implied warranty.
13706f2543Smrg *
14706f2543Smrg * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15706f2543Smrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16706f2543Smrg * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17706f2543Smrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18706f2543Smrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19706f2543Smrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20706f2543Smrg * PERFORMANCE OF THIS SOFTWARE.
21706f2543Smrg */
22706f2543Smrg
23706f2543Smrg#ifdef HAVE_DIX_CONFIG_H
24706f2543Smrg#include <dix-config.h>
25706f2543Smrg#endif
26706f2543Smrg
27706f2543Smrg#include "xfixesint.h"
28706f2543Smrg#include "scrnintstr.h"
29706f2543Smrg#include <picturestr.h>
30706f2543Smrgextern int RenderErrBase;
31706f2543Smrg#include <regionstr.h>
32706f2543Smrg#include <gcstruct.h>
33706f2543Smrg#include <window.h>
34706f2543Smrg
35706f2543SmrgRESTYPE RegionResType;
36706f2543Smrg
37706f2543Smrgstatic int
38706f2543SmrgRegionResFree (pointer data, XID id)
39706f2543Smrg{
40706f2543Smrg    RegionPtr    pRegion = (RegionPtr) data;
41706f2543Smrg
42706f2543Smrg    RegionDestroy(pRegion);
43706f2543Smrg    return Success;
44706f2543Smrg}
45706f2543Smrg
46706f2543SmrgRegionPtr
47706f2543SmrgXFixesRegionCopy (RegionPtr pRegion)
48706f2543Smrg{
49706f2543Smrg    RegionPtr   pNew = RegionCreate(RegionExtents(pRegion),
50706f2543Smrg				      RegionNumRects(pRegion));
51706f2543Smrg    if (!pNew)
52706f2543Smrg	return 0;
53706f2543Smrg    if (!RegionCopy(pNew, pRegion))
54706f2543Smrg    {
55706f2543Smrg	RegionDestroy(pNew);
56706f2543Smrg	return 0;
57706f2543Smrg    }
58706f2543Smrg    return pNew;
59706f2543Smrg}
60706f2543Smrg
61706f2543SmrgBool
62706f2543SmrgXFixesRegionInit (void)
63706f2543Smrg{
64706f2543Smrg    RegionResType = CreateNewResourceType(RegionResFree, "XFixesRegion");
65706f2543Smrg
66706f2543Smrg    return RegionResType != 0;
67706f2543Smrg}
68706f2543Smrg
69706f2543Smrgint
70706f2543SmrgProcXFixesCreateRegion (ClientPtr client)
71706f2543Smrg{
72706f2543Smrg    int		things;
73706f2543Smrg    RegionPtr	pRegion;
74706f2543Smrg    REQUEST (xXFixesCreateRegionReq);
75706f2543Smrg
76706f2543Smrg    REQUEST_AT_LEAST_SIZE(xXFixesCreateRegionReq);
77706f2543Smrg    LEGAL_NEW_RESOURCE (stuff->region, client);
78706f2543Smrg
79706f2543Smrg    things = (client->req_len << 2) - sizeof (xXFixesCreateRegionReq);
80706f2543Smrg    if (things & 4)
81706f2543Smrg	return BadLength;
82706f2543Smrg    things >>= 3;
83706f2543Smrg
84706f2543Smrg    pRegion = RegionFromRects(things, (xRectangle *) (stuff + 1), CT_UNSORTED);
85706f2543Smrg    if (!pRegion)
86706f2543Smrg	return BadAlloc;
87706f2543Smrg    if (!AddResource (stuff->region, RegionResType, (pointer) pRegion))
88706f2543Smrg	return BadAlloc;
89706f2543Smrg
90706f2543Smrg    return Success;
91706f2543Smrg}
92706f2543Smrg
93706f2543Smrgint
94706f2543SmrgSProcXFixesCreateRegion (ClientPtr client)
95706f2543Smrg{
96706f2543Smrg    register int n;
97706f2543Smrg    REQUEST(xXFixesCreateRegionReq);
98706f2543Smrg
99706f2543Smrg    swaps(&stuff->length, n);
100706f2543Smrg    REQUEST_AT_LEAST_SIZE(xXFixesCreateRegionReq);
101706f2543Smrg    swapl(&stuff->region, n);
102706f2543Smrg    SwapRestS(stuff);
103706f2543Smrg    return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
104706f2543Smrg}
105706f2543Smrg
106706f2543Smrgint
107706f2543SmrgProcXFixesCreateRegionFromBitmap (ClientPtr client)
108706f2543Smrg{
109706f2543Smrg    RegionPtr	pRegion;
110706f2543Smrg    PixmapPtr	pPixmap;
111706f2543Smrg    int rc;
112706f2543Smrg    REQUEST (xXFixesCreateRegionFromBitmapReq);
113706f2543Smrg
114706f2543Smrg    REQUEST_SIZE_MATCH (xXFixesCreateRegionFromBitmapReq);
115706f2543Smrg    LEGAL_NEW_RESOURCE (stuff->region, client);
116706f2543Smrg
117706f2543Smrg    rc = dixLookupResourceByType((pointer *)&pPixmap, stuff->bitmap, RT_PIXMAP,
118706f2543Smrg			   client, DixReadAccess);
119706f2543Smrg    if (rc != Success)
120706f2543Smrg    {
121706f2543Smrg	client->errorValue = stuff->bitmap;
122706f2543Smrg	return rc;
123706f2543Smrg    }
124706f2543Smrg    if (pPixmap->drawable.depth != 1)
125706f2543Smrg	return BadMatch;
126706f2543Smrg
127706f2543Smrg    pRegion = BitmapToRegion(pPixmap->drawable.pScreen, pPixmap);
128706f2543Smrg
129706f2543Smrg    if (!pRegion)
130706f2543Smrg	return BadAlloc;
131706f2543Smrg
132706f2543Smrg    if (!AddResource (stuff->region, RegionResType, (pointer) pRegion))
133706f2543Smrg	return BadAlloc;
134706f2543Smrg
135706f2543Smrg    return Success;
136706f2543Smrg}
137706f2543Smrg
138706f2543Smrgint
139706f2543SmrgSProcXFixesCreateRegionFromBitmap (ClientPtr client)
140706f2543Smrg{
141706f2543Smrg    int n;
142706f2543Smrg    REQUEST (xXFixesCreateRegionFromBitmapReq);
143706f2543Smrg
144706f2543Smrg    swaps(&stuff->length, n);
145706f2543Smrg    REQUEST_SIZE_MATCH (xXFixesCreateRegionFromBitmapReq);
146706f2543Smrg    swapl(&stuff->region, n);
147706f2543Smrg    swapl(&stuff->bitmap, n);
148706f2543Smrg    return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
149706f2543Smrg}
150706f2543Smrg
151706f2543Smrgint
152706f2543SmrgProcXFixesCreateRegionFromWindow (ClientPtr client)
153706f2543Smrg{
154706f2543Smrg    RegionPtr	pRegion;
155706f2543Smrg    Bool	copy = TRUE;
156706f2543Smrg    WindowPtr	pWin;
157706f2543Smrg    int rc;
158706f2543Smrg    REQUEST (xXFixesCreateRegionFromWindowReq);
159706f2543Smrg
160706f2543Smrg    REQUEST_SIZE_MATCH (xXFixesCreateRegionFromWindowReq);
161706f2543Smrg    LEGAL_NEW_RESOURCE (stuff->region, client);
162706f2543Smrg    rc = dixLookupResourceByType((pointer *)&pWin, stuff->window, RT_WINDOW,
163706f2543Smrg			   client, DixGetAttrAccess);
164706f2543Smrg    if (rc != Success)
165706f2543Smrg    {
166706f2543Smrg	client->errorValue = stuff->window;
167706f2543Smrg	return rc;
168706f2543Smrg    }
169706f2543Smrg    switch (stuff->kind) {
170706f2543Smrg    case WindowRegionBounding:
171706f2543Smrg	pRegion = wBoundingShape(pWin);
172706f2543Smrg	if (!pRegion)
173706f2543Smrg	{
174706f2543Smrg	    pRegion = CreateBoundingShape (pWin);
175706f2543Smrg	    copy = FALSE;
176706f2543Smrg	}
177706f2543Smrg	break;
178706f2543Smrg    case WindowRegionClip:
179706f2543Smrg	pRegion = wClipShape(pWin);
180706f2543Smrg	if (!pRegion)
181706f2543Smrg	{
182706f2543Smrg	    pRegion = CreateClipShape (pWin);
183706f2543Smrg	    copy = FALSE;
184706f2543Smrg	}
185706f2543Smrg	break;
186706f2543Smrg    default:
187706f2543Smrg	client->errorValue = stuff->kind;
188706f2543Smrg	return BadValue;
189706f2543Smrg    }
190706f2543Smrg    if (copy && pRegion)
191706f2543Smrg	pRegion = XFixesRegionCopy (pRegion);
192706f2543Smrg    if (!pRegion)
193706f2543Smrg	return BadAlloc;
194706f2543Smrg    if (!AddResource (stuff->region, RegionResType, (pointer) pRegion))
195706f2543Smrg	return BadAlloc;
196706f2543Smrg
197706f2543Smrg    return Success;
198706f2543Smrg}
199706f2543Smrg
200706f2543Smrgint
201706f2543SmrgSProcXFixesCreateRegionFromWindow (ClientPtr client)
202706f2543Smrg{
203706f2543Smrg    int n;
204706f2543Smrg    REQUEST (xXFixesCreateRegionFromWindowReq);
205706f2543Smrg
206706f2543Smrg    swaps(&stuff->length, n);
207706f2543Smrg    REQUEST_SIZE_MATCH (xXFixesCreateRegionFromWindowReq);
208706f2543Smrg    swapl(&stuff->region, n);
209706f2543Smrg    swapl(&stuff->window, n);
210706f2543Smrg    return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
211706f2543Smrg}
212706f2543Smrg
213706f2543Smrgint
214706f2543SmrgProcXFixesCreateRegionFromGC (ClientPtr client)
215706f2543Smrg{
216706f2543Smrg    RegionPtr	pRegion, pClip;
217706f2543Smrg    GCPtr	pGC;
218706f2543Smrg    int 	rc;
219706f2543Smrg    REQUEST (xXFixesCreateRegionFromGCReq);
220706f2543Smrg
221706f2543Smrg    REQUEST_SIZE_MATCH (xXFixesCreateRegionFromGCReq);
222706f2543Smrg    LEGAL_NEW_RESOURCE (stuff->region, client);
223706f2543Smrg
224706f2543Smrg    rc = dixLookupGC(&pGC, stuff->gc, client, DixGetAttrAccess);
225706f2543Smrg    if (rc != Success)
226706f2543Smrg	return rc;
227706f2543Smrg
228706f2543Smrg    switch (pGC->clientClipType) {
229706f2543Smrg    case CT_PIXMAP:
230706f2543Smrg	pRegion = BitmapToRegion(pGC->pScreen, (PixmapPtr) pGC->clientClip);
231706f2543Smrg	if (!pRegion)
232706f2543Smrg	    return BadAlloc;
233706f2543Smrg	break;
234706f2543Smrg    case CT_REGION:
235706f2543Smrg	pClip = (RegionPtr) pGC->clientClip;
236706f2543Smrg	pRegion = XFixesRegionCopy (pClip);
237706f2543Smrg	if (!pRegion)
238706f2543Smrg	    return BadAlloc;
239706f2543Smrg	break;
240706f2543Smrg    default:
241706f2543Smrg	return BadImplementation;   /* assume sane server bits */
242706f2543Smrg    }
243706f2543Smrg
244706f2543Smrg    if (!AddResource (stuff->region, RegionResType, (pointer) pRegion))
245706f2543Smrg	return BadAlloc;
246706f2543Smrg
247706f2543Smrg    return Success;
248706f2543Smrg}
249706f2543Smrg
250706f2543Smrgint
251706f2543SmrgSProcXFixesCreateRegionFromGC (ClientPtr client)
252706f2543Smrg{
253706f2543Smrg    int n;
254706f2543Smrg    REQUEST (xXFixesCreateRegionFromGCReq);
255706f2543Smrg
256706f2543Smrg    swaps(&stuff->length, n);
257706f2543Smrg    REQUEST_SIZE_MATCH (xXFixesCreateRegionFromGCReq);
258706f2543Smrg    swapl(&stuff->region, n);
259706f2543Smrg    swapl(&stuff->gc, n);
260706f2543Smrg    return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
261706f2543Smrg}
262706f2543Smrg
263706f2543Smrgint
264706f2543SmrgProcXFixesCreateRegionFromPicture (ClientPtr client)
265706f2543Smrg{
266706f2543Smrg    RegionPtr	pRegion;
267706f2543Smrg    PicturePtr	pPicture;
268706f2543Smrg    REQUEST (xXFixesCreateRegionFromPictureReq);
269706f2543Smrg
270706f2543Smrg    REQUEST_SIZE_MATCH (xXFixesCreateRegionFromPictureReq);
271706f2543Smrg    LEGAL_NEW_RESOURCE (stuff->region, client);
272706f2543Smrg
273706f2543Smrg    VERIFY_PICTURE(pPicture, stuff->picture, client, DixGetAttrAccess);
274706f2543Smrg
275706f2543Smrg    switch (pPicture->clientClipType) {
276706f2543Smrg    case CT_PIXMAP:
277706f2543Smrg	pRegion = BitmapToRegion(pPicture->pDrawable->pScreen,
278706f2543Smrg				   (PixmapPtr) pPicture->clientClip);
279706f2543Smrg	if (!pRegion)
280706f2543Smrg	    return BadAlloc;
281706f2543Smrg	break;
282706f2543Smrg    case CT_REGION:
283706f2543Smrg	pRegion = XFixesRegionCopy ((RegionPtr) pPicture->clientClip);
284706f2543Smrg	if (!pRegion)
285706f2543Smrg	    return BadAlloc;
286706f2543Smrg	break;
287706f2543Smrg    default:
288706f2543Smrg	return BadImplementation;   /* assume sane server bits */
289706f2543Smrg    }
290706f2543Smrg
291706f2543Smrg    if (!AddResource (stuff->region, RegionResType, (pointer) pRegion))
292706f2543Smrg	return BadAlloc;
293706f2543Smrg
294706f2543Smrg    return Success;
295706f2543Smrg}
296706f2543Smrg
297706f2543Smrgint
298706f2543SmrgSProcXFixesCreateRegionFromPicture (ClientPtr client)
299706f2543Smrg{
300706f2543Smrg    int n;
301706f2543Smrg    REQUEST (xXFixesCreateRegionFromPictureReq);
302706f2543Smrg
303706f2543Smrg    swaps(&stuff->length, n);
304706f2543Smrg    REQUEST_SIZE_MATCH (xXFixesCreateRegionFromPictureReq);
305706f2543Smrg    swapl(&stuff->region, n);
306706f2543Smrg    swapl(&stuff->picture, n);
307706f2543Smrg    return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
308706f2543Smrg}
309706f2543Smrg
310706f2543Smrgint
311706f2543SmrgProcXFixesDestroyRegion (ClientPtr client)
312706f2543Smrg{
313706f2543Smrg    REQUEST (xXFixesDestroyRegionReq);
314706f2543Smrg    RegionPtr	pRegion;
315706f2543Smrg
316706f2543Smrg    REQUEST_SIZE_MATCH(xXFixesDestroyRegionReq);
317706f2543Smrg    VERIFY_REGION(pRegion, stuff->region, client, DixWriteAccess);
318706f2543Smrg    FreeResource (stuff->region, RT_NONE);
319706f2543Smrg    return Success;
320706f2543Smrg}
321706f2543Smrg
322706f2543Smrgint
323706f2543SmrgSProcXFixesDestroyRegion (ClientPtr client)
324706f2543Smrg{
325706f2543Smrg    int n;
326706f2543Smrg    REQUEST (xXFixesDestroyRegionReq);
327706f2543Smrg
328706f2543Smrg    swaps (&stuff->length, n);
329706f2543Smrg    REQUEST_SIZE_MATCH(xXFixesDestroyRegionReq);
330706f2543Smrg    swapl (&stuff->region, n);
331706f2543Smrg    return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
332706f2543Smrg}
333706f2543Smrg
334706f2543Smrgint
335706f2543SmrgProcXFixesSetRegion (ClientPtr client)
336706f2543Smrg{
337706f2543Smrg    int		things;
338706f2543Smrg    RegionPtr	pRegion, pNew;
339706f2543Smrg    REQUEST (xXFixesSetRegionReq);
340706f2543Smrg
341706f2543Smrg    REQUEST_AT_LEAST_SIZE(xXFixesSetRegionReq);
342706f2543Smrg    VERIFY_REGION(pRegion, stuff->region, client, DixWriteAccess);
343706f2543Smrg
344706f2543Smrg    things = (client->req_len << 2) - sizeof (xXFixesCreateRegionReq);
345706f2543Smrg    if (things & 4)
346706f2543Smrg	return BadLength;
347706f2543Smrg    things >>= 3;
348706f2543Smrg
349706f2543Smrg    pNew = RegionFromRects(things, (xRectangle *) (stuff + 1), CT_UNSORTED);
350706f2543Smrg    if (!pNew)
351706f2543Smrg	return BadAlloc;
352706f2543Smrg    if (!RegionCopy(pRegion, pNew))
353706f2543Smrg    {
354706f2543Smrg	RegionDestroy(pNew);
355706f2543Smrg	return BadAlloc;
356706f2543Smrg    }
357706f2543Smrg    RegionDestroy(pNew);
358706f2543Smrg    return Success;
359706f2543Smrg}
360706f2543Smrg
361706f2543Smrgint
362706f2543SmrgSProcXFixesSetRegion (ClientPtr client)
363706f2543Smrg{
364706f2543Smrg    int n;
365706f2543Smrg    REQUEST (xXFixesSetRegionReq);
366706f2543Smrg
367706f2543Smrg    swaps (&stuff->length, n);
368706f2543Smrg    REQUEST_AT_LEAST_SIZE(xXFixesSetRegionReq);
369706f2543Smrg    swapl (&stuff->region, n);
370706f2543Smrg    SwapRestS(stuff);
371706f2543Smrg    return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
372706f2543Smrg}
373706f2543Smrg
374706f2543Smrgint
375706f2543SmrgProcXFixesCopyRegion (ClientPtr client)
376706f2543Smrg{
377706f2543Smrg    RegionPtr	pSource, pDestination;
378706f2543Smrg    REQUEST (xXFixesCopyRegionReq);
37948a68b89Smrg    REQUEST_SIZE_MATCH(xXFixesCopyRegionReq);
380706f2543Smrg
381706f2543Smrg    VERIFY_REGION(pSource, stuff->source, client, DixReadAccess);
382706f2543Smrg    VERIFY_REGION(pDestination, stuff->destination, client, DixWriteAccess);
383706f2543Smrg
384706f2543Smrg    if (!RegionCopy(pDestination, pSource))
385706f2543Smrg	return BadAlloc;
386706f2543Smrg
387706f2543Smrg    return Success;
388706f2543Smrg}
389706f2543Smrg
390706f2543Smrgint
391706f2543SmrgSProcXFixesCopyRegion (ClientPtr client)
392706f2543Smrg{
393706f2543Smrg    int n;
394706f2543Smrg    REQUEST (xXFixesCopyRegionReq);
395706f2543Smrg
396706f2543Smrg    swaps (&stuff->length, n);
39748a68b89Smrg    REQUEST_SIZE_MATCH(xXFixesCopyRegionReq);
398706f2543Smrg    swapl (&stuff->source, n);
399706f2543Smrg    swapl (&stuff->destination, n);
400706f2543Smrg    return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
401706f2543Smrg}
402706f2543Smrg
403706f2543Smrgint
404706f2543SmrgProcXFixesCombineRegion (ClientPtr client)
405706f2543Smrg{
406706f2543Smrg    RegionPtr	pSource1, pSource2, pDestination;
407706f2543Smrg    REQUEST (xXFixesCombineRegionReq);
408706f2543Smrg
409706f2543Smrg    REQUEST_SIZE_MATCH (xXFixesCombineRegionReq);
410706f2543Smrg    VERIFY_REGION(pSource1, stuff->source1, client, DixReadAccess);
411706f2543Smrg    VERIFY_REGION(pSource2, stuff->source2, client, DixReadAccess);
412706f2543Smrg    VERIFY_REGION(pDestination, stuff->destination, client, DixWriteAccess);
413706f2543Smrg
414706f2543Smrg    switch (stuff->xfixesReqType) {
415706f2543Smrg    case X_XFixesUnionRegion:
416706f2543Smrg	if (!RegionUnion(pDestination, pSource1, pSource2))
417706f2543Smrg	    return BadAlloc;
418706f2543Smrg	break;
419706f2543Smrg    case X_XFixesIntersectRegion:
420706f2543Smrg	if (!RegionIntersect(pDestination, pSource1, pSource2))
421706f2543Smrg	    return BadAlloc;
422706f2543Smrg	break;
423706f2543Smrg    case X_XFixesSubtractRegion:
424706f2543Smrg	if (!RegionSubtract(pDestination, pSource1, pSource2))
425706f2543Smrg	    return BadAlloc;
426706f2543Smrg	break;
427706f2543Smrg    }
428706f2543Smrg
429706f2543Smrg    return Success;
430706f2543Smrg}
431706f2543Smrg
432706f2543Smrgint
433706f2543SmrgSProcXFixesCombineRegion (ClientPtr client)
434706f2543Smrg{
435706f2543Smrg    int n;
436706f2543Smrg    REQUEST (xXFixesCombineRegionReq);
437706f2543Smrg
438706f2543Smrg    swaps (&stuff->length, n);
439706f2543Smrg    REQUEST_SIZE_MATCH (xXFixesCombineRegionReq);
440706f2543Smrg    swapl (&stuff->source1, n);
441706f2543Smrg    swapl (&stuff->source2, n);
442706f2543Smrg    swapl (&stuff->destination, n);
443706f2543Smrg    return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
444706f2543Smrg}
445706f2543Smrg
446706f2543Smrgint
447706f2543SmrgProcXFixesInvertRegion (ClientPtr client)
448706f2543Smrg{
449706f2543Smrg    RegionPtr	pSource, pDestination;
450706f2543Smrg    BoxRec	bounds;
451706f2543Smrg    REQUEST(xXFixesInvertRegionReq);
452706f2543Smrg
453706f2543Smrg    REQUEST_SIZE_MATCH(xXFixesInvertRegionReq);
454706f2543Smrg    VERIFY_REGION(pSource, stuff->source, client, DixReadAccess);
455706f2543Smrg    VERIFY_REGION(pDestination, stuff->destination, client, DixWriteAccess);
456706f2543Smrg
457706f2543Smrg    /* Compute bounds, limit to 16 bits */
458706f2543Smrg    bounds.x1 = stuff->x;
459706f2543Smrg    bounds.y1 = stuff->y;
460706f2543Smrg    if ((int) stuff->x + (int) stuff->width > MAXSHORT)
461706f2543Smrg	bounds.x2 = MAXSHORT;
462706f2543Smrg    else
463706f2543Smrg	bounds.x2 = stuff->x + stuff->width;
464706f2543Smrg
465706f2543Smrg    if ((int) stuff->y + (int) stuff->height > MAXSHORT)
466706f2543Smrg	bounds.y2 = MAXSHORT;
467706f2543Smrg    else
468706f2543Smrg	bounds.y2 = stuff->y + stuff->height;
469706f2543Smrg
470706f2543Smrg    if (!RegionInverse(pDestination, pSource, &bounds))
471706f2543Smrg	return BadAlloc;
472706f2543Smrg
473706f2543Smrg    return Success;
474706f2543Smrg}
475706f2543Smrg
476706f2543Smrgint
477706f2543SmrgSProcXFixesInvertRegion (ClientPtr client)
478706f2543Smrg{
479706f2543Smrg    int n;
480706f2543Smrg    REQUEST(xXFixesInvertRegionReq);
481706f2543Smrg
482706f2543Smrg    swaps (&stuff->length, n);
483706f2543Smrg    REQUEST_SIZE_MATCH(xXFixesInvertRegionReq);
484706f2543Smrg    swapl (&stuff->source, n);
485706f2543Smrg    swaps (&stuff->x, n);
486706f2543Smrg    swaps (&stuff->y, n);
487706f2543Smrg    swaps (&stuff->width, n);
488706f2543Smrg    swaps (&stuff->height, n);
489706f2543Smrg    swapl (&stuff->destination, n);
490706f2543Smrg    return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
491706f2543Smrg}
492706f2543Smrg
493706f2543Smrgint
494706f2543SmrgProcXFixesTranslateRegion (ClientPtr client)
495706f2543Smrg{
496706f2543Smrg    RegionPtr	pRegion;
497706f2543Smrg    REQUEST(xXFixesTranslateRegionReq);
498706f2543Smrg
499706f2543Smrg    REQUEST_SIZE_MATCH(xXFixesTranslateRegionReq);
500706f2543Smrg    VERIFY_REGION(pRegion, stuff->region, client, DixWriteAccess);
501706f2543Smrg
502706f2543Smrg    RegionTranslate(pRegion, stuff->dx, stuff->dy);
503706f2543Smrg    return Success;
504706f2543Smrg}
505706f2543Smrg
506706f2543Smrgint
507706f2543SmrgSProcXFixesTranslateRegion (ClientPtr client)
508706f2543Smrg{
509706f2543Smrg    int n;
510706f2543Smrg    REQUEST(xXFixesTranslateRegionReq);
511706f2543Smrg
512706f2543Smrg    swaps (&stuff->length, n);
513706f2543Smrg    REQUEST_SIZE_MATCH(xXFixesTranslateRegionReq);
514706f2543Smrg    swapl (&stuff->region, n);
515706f2543Smrg    swaps (&stuff->dx, n);
516706f2543Smrg    swaps (&stuff->dy, n);
517706f2543Smrg    return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
518706f2543Smrg}
519706f2543Smrg
520706f2543Smrgint
521706f2543SmrgProcXFixesRegionExtents (ClientPtr client)
522706f2543Smrg{
523706f2543Smrg    RegionPtr	pSource, pDestination;
524706f2543Smrg    REQUEST(xXFixesRegionExtentsReq);
525706f2543Smrg
526706f2543Smrg    REQUEST_SIZE_MATCH(xXFixesRegionExtentsReq);
527706f2543Smrg    VERIFY_REGION(pSource, stuff->source, client, DixReadAccess);
528706f2543Smrg    VERIFY_REGION(pDestination, stuff->destination, client, DixWriteAccess);
529706f2543Smrg
530706f2543Smrg    RegionReset(pDestination, RegionExtents(pSource));
531706f2543Smrg
532706f2543Smrg    return Success;
533706f2543Smrg}
534706f2543Smrg
535706f2543Smrgint
536706f2543SmrgSProcXFixesRegionExtents (ClientPtr client)
537706f2543Smrg{
538706f2543Smrg    int n;
539706f2543Smrg    REQUEST(xXFixesRegionExtentsReq);
540706f2543Smrg
541706f2543Smrg    swaps (&stuff->length, n);
542706f2543Smrg    REQUEST_SIZE_MATCH(xXFixesRegionExtentsReq);
543706f2543Smrg    swapl (&stuff->source, n);
544706f2543Smrg    swapl (&stuff->destination, n);
545706f2543Smrg    return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
546706f2543Smrg}
547706f2543Smrg
548706f2543Smrgint
549706f2543SmrgProcXFixesFetchRegion (ClientPtr client)
550706f2543Smrg{
551706f2543Smrg    RegionPtr		    pRegion;
552706f2543Smrg    xXFixesFetchRegionReply *reply;
553706f2543Smrg    xRectangle		    *pRect;
554706f2543Smrg    BoxPtr		    pExtent;
555706f2543Smrg    BoxPtr		    pBox;
556706f2543Smrg    int			    i, nBox;
557706f2543Smrg    REQUEST(xXFixesFetchRegionReq);
558706f2543Smrg
559706f2543Smrg    REQUEST_SIZE_MATCH(xXFixesFetchRegionReq);
560706f2543Smrg    VERIFY_REGION(pRegion, stuff->region, client, DixReadAccess);
561706f2543Smrg
562706f2543Smrg    pExtent = RegionExtents(pRegion);
563706f2543Smrg    pBox = RegionRects (pRegion);
564706f2543Smrg    nBox = RegionNumRects (pRegion);
565706f2543Smrg
566706f2543Smrg    reply = malloc(sizeof (xXFixesFetchRegionReply) +
567706f2543Smrg		    nBox * sizeof (xRectangle));
568706f2543Smrg    if (!reply)
569706f2543Smrg	return BadAlloc;
570706f2543Smrg    reply->type = X_Reply;
571706f2543Smrg    reply->sequenceNumber = client->sequence;
572706f2543Smrg    reply->length = nBox << 1;
573706f2543Smrg    reply->x = pExtent->x1;
574706f2543Smrg    reply->y = pExtent->y1;
575706f2543Smrg    reply->width = pExtent->x2 - pExtent->x1;
576706f2543Smrg    reply->height = pExtent->y2 - pExtent->y1;
577706f2543Smrg
578706f2543Smrg    pRect = (xRectangle *) (reply + 1);
579706f2543Smrg    for (i = 0; i < nBox; i++)
580706f2543Smrg    {
581706f2543Smrg	pRect[i].x = pBox[i].x1;
582706f2543Smrg	pRect[i].y = pBox[i].y1;
583706f2543Smrg	pRect[i].width = pBox[i].x2 - pBox[i].x1;
584706f2543Smrg	pRect[i].height = pBox[i].y2 - pBox[i].y1;
585706f2543Smrg    }
586706f2543Smrg    if (client->swapped)
587706f2543Smrg    {
588706f2543Smrg	int n;
589706f2543Smrg	swaps (&reply->sequenceNumber, n);
590706f2543Smrg	swapl (&reply->length, n);
591706f2543Smrg	swaps (&reply->x, n);
592706f2543Smrg	swaps (&reply->y, n);
593706f2543Smrg	swaps (&reply->width, n);
594706f2543Smrg	swaps (&reply->height, n);
595706f2543Smrg	SwapShorts ((INT16 *) pRect, nBox * 4);
596706f2543Smrg    }
597706f2543Smrg    (void) WriteToClient(client, sizeof (xXFixesFetchRegionReply) +
598706f2543Smrg			 nBox * sizeof (xRectangle), (char *) reply);
599706f2543Smrg    free(reply);
600706f2543Smrg    return Success;
601706f2543Smrg}
602706f2543Smrg
603706f2543Smrgint
604706f2543SmrgSProcXFixesFetchRegion (ClientPtr client)
605706f2543Smrg{
606706f2543Smrg    int n;
607706f2543Smrg    REQUEST(xXFixesFetchRegionReq);
608706f2543Smrg
609706f2543Smrg    swaps (&stuff->length, n);
610706f2543Smrg    REQUEST_SIZE_MATCH(xXFixesFetchRegionReq);
611706f2543Smrg    swapl (&stuff->region, n);
612706f2543Smrg    return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
613706f2543Smrg}
614706f2543Smrg
615706f2543Smrgint
616706f2543SmrgProcXFixesSetGCClipRegion (ClientPtr client)
617706f2543Smrg{
618706f2543Smrg    GCPtr	pGC;
619706f2543Smrg    RegionPtr	pRegion;
620706f2543Smrg    ChangeGCVal	vals[2];
621706f2543Smrg    int		rc;
622706f2543Smrg    REQUEST(xXFixesSetGCClipRegionReq);
623706f2543Smrg    REQUEST_SIZE_MATCH(xXFixesSetGCClipRegionReq);
624706f2543Smrg
625706f2543Smrg    rc = dixLookupGC(&pGC, stuff->gc, client, DixSetAttrAccess);
626706f2543Smrg    if (rc != Success)
627706f2543Smrg	return rc;
628706f2543Smrg
629706f2543Smrg    VERIFY_REGION_OR_NONE (pRegion, stuff->region, client, DixReadAccess);
630706f2543Smrg
631706f2543Smrg    if (pRegion)
632706f2543Smrg    {
633706f2543Smrg	pRegion = XFixesRegionCopy (pRegion);
634706f2543Smrg	if (!pRegion)
635706f2543Smrg	    return BadAlloc;
636706f2543Smrg    }
637706f2543Smrg
638706f2543Smrg    vals[0].val = stuff->xOrigin;
639706f2543Smrg    vals[1].val = stuff->yOrigin;
640706f2543Smrg    ChangeGC (NullClient, pGC, GCClipXOrigin|GCClipYOrigin, vals);
641706f2543Smrg    (*pGC->funcs->ChangeClip)(pGC, pRegion ? CT_REGION : CT_NONE, (pointer)pRegion, 0);
642706f2543Smrg
643706f2543Smrg    return Success;
644706f2543Smrg}
645706f2543Smrg
646706f2543Smrgint
647706f2543SmrgSProcXFixesSetGCClipRegion (ClientPtr client)
648706f2543Smrg{
649706f2543Smrg    int n;
650706f2543Smrg    REQUEST(xXFixesSetGCClipRegionReq);
651706f2543Smrg
652706f2543Smrg    swaps (&stuff->length, n);
653706f2543Smrg    REQUEST_SIZE_MATCH(xXFixesSetGCClipRegionReq);
654706f2543Smrg    swapl (&stuff->gc, n);
655706f2543Smrg    swapl (&stuff->region, n);
656706f2543Smrg    swaps (&stuff->xOrigin, n);
657706f2543Smrg    swaps (&stuff->yOrigin, n);
658706f2543Smrg    return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
659706f2543Smrg}
660706f2543Smrg
661706f2543Smrgtypedef	RegionPtr (*CreateDftPtr)(WindowPtr pWin);
662706f2543Smrg
663706f2543Smrgint
664706f2543SmrgProcXFixesSetWindowShapeRegion (ClientPtr client)
665706f2543Smrg{
666706f2543Smrg    WindowPtr	    pWin;
667706f2543Smrg    RegionPtr	    pRegion;
668706f2543Smrg    RegionPtr	    *pDestRegion;
669706f2543Smrg    int rc;
670706f2543Smrg    REQUEST(xXFixesSetWindowShapeRegionReq);
671706f2543Smrg
672706f2543Smrg    REQUEST_SIZE_MATCH(xXFixesSetWindowShapeRegionReq);
673706f2543Smrg    rc = dixLookupResourceByType((pointer *)&pWin, stuff->dest, RT_WINDOW,
674706f2543Smrg			   client, DixSetAttrAccess);
675706f2543Smrg    if (rc != Success)
676706f2543Smrg    {
677706f2543Smrg	client->errorValue = stuff->dest;
678706f2543Smrg	return rc;
679706f2543Smrg    }
680706f2543Smrg    VERIFY_REGION_OR_NONE(pRegion, stuff->region, client, DixWriteAccess);
681706f2543Smrg    switch (stuff->destKind) {
682706f2543Smrg    case ShapeBounding:
683706f2543Smrg    case ShapeClip:
684706f2543Smrg    case ShapeInput:
685706f2543Smrg	break;
686706f2543Smrg    default:
687706f2543Smrg	client->errorValue = stuff->destKind;
688706f2543Smrg	return BadValue;
689706f2543Smrg    }
690706f2543Smrg    if (pRegion)
691706f2543Smrg    {
692706f2543Smrg	pRegion = XFixesRegionCopy (pRegion);
693706f2543Smrg	if (!pRegion)
694706f2543Smrg	    return BadAlloc;
695706f2543Smrg	if (!pWin->optional)
696706f2543Smrg	    MakeWindowOptional (pWin);
697706f2543Smrg	switch (stuff->destKind) {
698706f2543Smrg	default:
699706f2543Smrg	case ShapeBounding:
700706f2543Smrg	    pDestRegion = &pWin->optional->boundingShape;
701706f2543Smrg	    break;
702706f2543Smrg	case ShapeClip:
703706f2543Smrg	    pDestRegion = &pWin->optional->clipShape;
704706f2543Smrg	    break;
705706f2543Smrg	case ShapeInput:
706706f2543Smrg	    pDestRegion = &pWin->optional->inputShape;
707706f2543Smrg	    break;
708706f2543Smrg	}
709706f2543Smrg	if (stuff->xOff || stuff->yOff)
710706f2543Smrg	    RegionTranslate(pRegion, stuff->xOff, stuff->yOff);
711706f2543Smrg    }
712706f2543Smrg    else
713706f2543Smrg    {
714706f2543Smrg	if (pWin->optional)
715706f2543Smrg	{
716706f2543Smrg	    switch (stuff->destKind) {
717706f2543Smrg	    default:
718706f2543Smrg	    case ShapeBounding:
719706f2543Smrg		pDestRegion = &pWin->optional->boundingShape;
720706f2543Smrg		break;
721706f2543Smrg	    case ShapeClip:
722706f2543Smrg		pDestRegion = &pWin->optional->clipShape;
723706f2543Smrg		break;
724706f2543Smrg	    case ShapeInput:
725706f2543Smrg		pDestRegion = &pWin->optional->inputShape;
726706f2543Smrg		break;
727706f2543Smrg	    }
728706f2543Smrg	}
729706f2543Smrg	else
730706f2543Smrg	    pDestRegion = &pRegion; /* a NULL region pointer */
731706f2543Smrg    }
732706f2543Smrg    if (*pDestRegion)
733706f2543Smrg	RegionDestroy(*pDestRegion);
734706f2543Smrg    *pDestRegion = pRegion;
735706f2543Smrg    (*pWin->drawable.pScreen->SetShape) (pWin, stuff->destKind);
736706f2543Smrg    SendShapeNotify (pWin, stuff->destKind);
737706f2543Smrg    return Success;
738706f2543Smrg}
739706f2543Smrg
740706f2543Smrgint
741706f2543SmrgSProcXFixesSetWindowShapeRegion (ClientPtr client)
742706f2543Smrg{
743706f2543Smrg    int n;
744706f2543Smrg    REQUEST(xXFixesSetWindowShapeRegionReq);
745706f2543Smrg
746706f2543Smrg    swaps (&stuff->length, n);
747706f2543Smrg    REQUEST_SIZE_MATCH(xXFixesSetWindowShapeRegionReq);
748706f2543Smrg    swapl (&stuff->dest, n);
749706f2543Smrg    swaps (&stuff->xOff, n);
750706f2543Smrg    swaps (&stuff->yOff, n);
751706f2543Smrg    swapl (&stuff->region, n);
752706f2543Smrg    return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
753706f2543Smrg}
754706f2543Smrg
755706f2543Smrgint
756706f2543SmrgProcXFixesSetPictureClipRegion (ClientPtr client)
757706f2543Smrg{
758706f2543Smrg    PicturePtr		pPicture;
759706f2543Smrg    RegionPtr		pRegion;
760706f2543Smrg    ScreenPtr		pScreen;
761706f2543Smrg    REQUEST(xXFixesSetPictureClipRegionReq);
762706f2543Smrg
763706f2543Smrg    REQUEST_SIZE_MATCH (xXFixesSetPictureClipRegionReq);
764706f2543Smrg    VERIFY_PICTURE(pPicture, stuff->picture, client, DixSetAttrAccess);
765706f2543Smrg    pScreen = pPicture->pDrawable->pScreen;
766706f2543Smrg    VERIFY_REGION_OR_NONE(pRegion, stuff->region, client, DixReadAccess);
767706f2543Smrg
768706f2543Smrg    return SetPictureClipRegion (pPicture, stuff->xOrigin, stuff->yOrigin,
769706f2543Smrg				 pRegion);
770706f2543Smrg}
771706f2543Smrg
772706f2543Smrgint
773706f2543SmrgSProcXFixesSetPictureClipRegion (ClientPtr client)
774706f2543Smrg{
775706f2543Smrg    int n;
776706f2543Smrg    REQUEST(xXFixesSetPictureClipRegionReq);
777706f2543Smrg
778706f2543Smrg    swaps (&stuff->length, n);
779706f2543Smrg    REQUEST_SIZE_MATCH (xXFixesSetPictureClipRegionReq);
780706f2543Smrg    swapl (&stuff->picture, n);
781706f2543Smrg    swapl (&stuff->region, n);
782706f2543Smrg    swaps (&stuff->xOrigin, n);
783706f2543Smrg    swaps (&stuff->yOrigin, n);
784706f2543Smrg    return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
785706f2543Smrg}
786706f2543Smrg
787706f2543Smrgint
788706f2543SmrgProcXFixesExpandRegion (ClientPtr client)
789706f2543Smrg{
790706f2543Smrg    RegionPtr	pSource, pDestination;
791706f2543Smrg    REQUEST (xXFixesExpandRegionReq);
792706f2543Smrg    BoxPtr	pTmp;
793706f2543Smrg    BoxPtr	pSrc;
794706f2543Smrg    int		nBoxes;
795706f2543Smrg    int		i;
796706f2543Smrg
797706f2543Smrg    REQUEST_SIZE_MATCH (xXFixesExpandRegionReq);
798706f2543Smrg    VERIFY_REGION(pSource, stuff->source, client, DixReadAccess);
799706f2543Smrg    VERIFY_REGION(pDestination, stuff->destination, client, DixWriteAccess);
800706f2543Smrg
801706f2543Smrg    nBoxes = RegionNumRects(pSource);
802706f2543Smrg    pSrc = RegionRects(pSource);
803706f2543Smrg    if (nBoxes)
804706f2543Smrg    {
805706f2543Smrg	pTmp = malloc(nBoxes * sizeof (BoxRec));
806706f2543Smrg	if (!pTmp)
807706f2543Smrg	    return BadAlloc;
808706f2543Smrg	for (i = 0; i < nBoxes; i++)
809706f2543Smrg	{
810706f2543Smrg	    pTmp[i].x1 = pSrc[i].x1 - stuff->left;
811706f2543Smrg	    pTmp[i].x2 = pSrc[i].x2 + stuff->right;
812706f2543Smrg	    pTmp[i].y1 = pSrc[i].y1 - stuff->top;
813706f2543Smrg	    pTmp[i].y2 = pSrc[i].y2 + stuff->bottom;
814706f2543Smrg	}
815706f2543Smrg	RegionEmpty(pDestination);
816706f2543Smrg	for (i = 0; i < nBoxes; i++)
817706f2543Smrg	{
818706f2543Smrg	    RegionRec	r;
819706f2543Smrg	    RegionInit(&r, &pTmp[i], 0);
820706f2543Smrg	    RegionUnion(pDestination, pDestination, &r);
821706f2543Smrg	}
822706f2543Smrg	free(pTmp);
823706f2543Smrg    }
824706f2543Smrg    return Success;
825706f2543Smrg}
826706f2543Smrg
827706f2543Smrgint
828706f2543SmrgSProcXFixesExpandRegion (ClientPtr client)
829706f2543Smrg{
830706f2543Smrg    int n;
831706f2543Smrg    REQUEST (xXFixesExpandRegionReq);
832706f2543Smrg
833706f2543Smrg    swaps (&stuff->length, n);
834706f2543Smrg    REQUEST_SIZE_MATCH (xXFixesExpandRegionReq);
835706f2543Smrg    swapl (&stuff->source, n);
836706f2543Smrg    swapl (&stuff->destination, n);
837706f2543Smrg    swaps (&stuff->left, n);
838706f2543Smrg    swaps (&stuff->right, n);
839706f2543Smrg    swaps (&stuff->top, n);
840706f2543Smrg    swaps (&stuff->bottom, n);
841706f2543Smrg    return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
842706f2543Smrg}
843706f2543Smrg
844706f2543Smrg#ifdef PANORAMIX
845706f2543Smrg#include "panoramiX.h"
846706f2543Smrg#include "panoramiXsrv.h"
847706f2543Smrg
848706f2543Smrgint
849706f2543SmrgPanoramiXFixesSetGCClipRegion (ClientPtr client)
850706f2543Smrg{
851706f2543Smrg    REQUEST(xXFixesSetGCClipRegionReq);
852706f2543Smrg    int		    result = Success, j;
853706f2543Smrg    PanoramiXRes    *gc;
854706f2543Smrg    REQUEST_SIZE_MATCH(xXFixesSetGCClipRegionReq);
855706f2543Smrg
856706f2543Smrg    if ((result = dixLookupResourceByType((void **)&gc, stuff->gc, XRT_GC,
857706f2543Smrg					  client, DixWriteAccess))) {
858706f2543Smrg	client->errorValue = stuff->gc;
859706f2543Smrg	return result;
860706f2543Smrg    }
861706f2543Smrg
862706f2543Smrg    FOR_NSCREENS_BACKWARD(j) {
863706f2543Smrg        stuff->gc = gc->info[j].id;
864706f2543Smrg        result = (*PanoramiXSaveXFixesVector[X_XFixesSetGCClipRegion]) (client);
865706f2543Smrg        if(result != Success) break;
866706f2543Smrg    }
867706f2543Smrg
868706f2543Smrg    return result;
869706f2543Smrg}
870706f2543Smrg
871706f2543Smrgint
872706f2543SmrgPanoramiXFixesSetWindowShapeRegion (ClientPtr client)
873706f2543Smrg{
874706f2543Smrg    int		    result = Success, j;
875706f2543Smrg    PanoramiXRes    *win;
876706f2543Smrg    REQUEST(xXFixesSetWindowShapeRegionReq);
877706f2543Smrg
878706f2543Smrg    REQUEST_SIZE_MATCH(xXFixesSetWindowShapeRegionReq);
879706f2543Smrg
880706f2543Smrg    if ((result = dixLookupResourceByType((void **)&win, stuff->dest,
881706f2543Smrg					  XRT_WINDOW, client,
882706f2543Smrg					  DixWriteAccess))) {
883706f2543Smrg	client->errorValue = stuff->dest;
884706f2543Smrg	return result;
885706f2543Smrg    }
886706f2543Smrg
887706f2543Smrg    FOR_NSCREENS_FORWARD(j) {
888706f2543Smrg	stuff->dest = win->info[j].id;
889706f2543Smrg	result = (*PanoramiXSaveXFixesVector[X_XFixesSetWindowShapeRegion]) (client);
890706f2543Smrg        if(result != Success) break;
891706f2543Smrg    }
892706f2543Smrg
893706f2543Smrg    return result;
894706f2543Smrg}
895706f2543Smrg
896706f2543Smrgint
897706f2543SmrgPanoramiXFixesSetPictureClipRegion (ClientPtr client)
898706f2543Smrg{
899706f2543Smrg    REQUEST(xXFixesSetPictureClipRegionReq);
900706f2543Smrg    int		    result = Success, j;
901706f2543Smrg    PanoramiXRes    *pict;
902706f2543Smrg
903706f2543Smrg    REQUEST_SIZE_MATCH (xXFixesSetPictureClipRegionReq);
904706f2543Smrg
905706f2543Smrg    if ((result = dixLookupResourceByType((void **)&pict, stuff->picture,
906706f2543Smrg					  XRT_PICTURE, client,
907706f2543Smrg					  DixWriteAccess))) {
908706f2543Smrg	client->errorValue = stuff->picture;
909706f2543Smrg	return result;
910706f2543Smrg    }
911706f2543Smrg
912706f2543Smrg    FOR_NSCREENS_BACKWARD(j) {
913706f2543Smrg        stuff->picture = pict->info[j].id;
914706f2543Smrg	result = (*PanoramiXSaveXFixesVector[X_XFixesSetPictureClipRegion]) (client);
915706f2543Smrg        if(result != Success) break;
916706f2543Smrg    }
917706f2543Smrg
918706f2543Smrg    return result;
919706f2543Smrg}
920706f2543Smrg
921706f2543Smrg#endif
922