1 /*****************************************************************
2 Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
3 Permission is hereby granted, free of charge, to any person obtaining a copy
4 of this software and associated documentation files (the "Software"), to deal
5 in the Software without restriction, including without limitation the rights
6 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 copies of the Software.
9 The above copyright notice and this permission notice shall be included in
10 all copies or substantial portions of the Software.
12 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
15 DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
16 BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY,
17 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
18 IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 Except as contained in this notice, the name of Digital Equipment Corporation
21 shall not be used in advertising or otherwise to promote the sale, use or other
22 dealings in this Software without prior written authorization from Digital
23 Equipment Corporation.
24 ******************************************************************/
26 /* Massively rewritten by Mark Vojkovich <markv@valinux.com> */
29 #ifdef HAVE_DIX_CONFIG_H
30 #include <dix-config.h>
37 #include <X11/Xproto.h>
38 #include "windowstr.h"
39 #include "dixfontstr.h"
41 #include "colormapst.h"
42 #include "scrnintstr.h"
47 #include "dixstruct.h"
48 #include "panoramiX.h"
49 #include "panoramiXsrv.h"
51 #include "panoramiXh.h"
53 #define XINERAMA_IMAGE_BUFSIZE (256*1024)
54 #define INPUTONLY_LEGAL_MASK (CWWinGravity | CWEventMask | \
55 CWDontPropagate | CWOverrideRedirect | CWCursor )
58 extern void (* EventSwapVector
[128]) (fsError
*, fsError
*);
60 extern void Swap32Write();
61 extern void SLHostsExtend();
62 extern void SQColorsExtend();
63 WriteSConnectionInfo();
64 extern void WriteSConnSetupPrefix();
67 /* Various of the DIX function interfaces were not designed to allow
68 * the client->errorValue to be set on BadValue and other errors.
69 * Rather than changing interfaces and breaking untold code we introduce
70 * a new global that dispatch can use.
72 extern XID clientErrorValue
; /* XXX this is a kludge */
74 int PanoramiXCreateWindow(ClientPtr client
)
76 PanoramiXRes
*parent
, *newWin
;
77 PanoramiXRes
*backPix
= NULL
;
78 PanoramiXRes
*bordPix
= NULL
;
79 PanoramiXRes
*cmap
= NULL
;
80 REQUEST(xCreateWindowReq
);
81 int pback_offset
= 0, pbord_offset
= 0, cmap_offset
= 0;
82 int result
= 0, len
, j
;
87 REQUEST_AT_LEAST_SIZE(xCreateWindowReq
);
89 len
= client
->req_len
- (sizeof(xCreateWindowReq
) >> 2);
90 if (Ones(stuff
->mask
) != len
)
93 if (!(parent
= (PanoramiXRes
*)SecurityLookupIDByType(
94 client
, stuff
->parent
, XRT_WINDOW
, DixWriteAccess
)))
97 if(stuff
->class == CopyFromParent
)
98 stuff
->class = parent
->u
.win
.class;
100 if((stuff
->class == InputOnly
) && (stuff
->mask
& (~INPUTONLY_LEGAL_MASK
)))
103 if ((Mask
)stuff
->mask
& CWBackPixmap
) {
104 pback_offset
= Ones((Mask
)stuff
->mask
& (CWBackPixmap
- 1));
105 tmp
= *((CARD32
*) &stuff
[1] + pback_offset
);
106 if ((tmp
!= None
) && (tmp
!= ParentRelative
)) {
107 if(!(backPix
= (PanoramiXRes
*) SecurityLookupIDByType(
108 client
, tmp
, XRT_PIXMAP
, DixReadAccess
)))
112 if ((Mask
)stuff
->mask
& CWBorderPixmap
) {
113 pbord_offset
= Ones((Mask
)stuff
->mask
& (CWBorderPixmap
- 1));
114 tmp
= *((CARD32
*) &stuff
[1] + pbord_offset
);
115 if (tmp
!= CopyFromParent
) {
116 if(!(bordPix
= (PanoramiXRes
*) SecurityLookupIDByType(
117 client
, tmp
, XRT_PIXMAP
, DixReadAccess
)))
121 if ((Mask
)stuff
->mask
& CWColormap
) {
122 cmap_offset
= Ones((Mask
)stuff
->mask
& (CWColormap
- 1));
123 tmp
= *((CARD32
*) &stuff
[1] + cmap_offset
);
124 if ((tmp
!= CopyFromParent
) && (tmp
!= None
)) {
125 if(!(cmap
= (PanoramiXRes
*) SecurityLookupIDByType(
126 client
, tmp
, XRT_COLORMAP
, DixReadAccess
)))
131 if(!(newWin
= (PanoramiXRes
*) xalloc(sizeof(PanoramiXRes
))))
134 newWin
->type
= XRT_WINDOW
;
135 newWin
->u
.win
.visibility
= VisibilityNotViewable
;
136 newWin
->u
.win
.class = stuff
->class;
137 newWin
->u
.win
.root
= FALSE
;
138 newWin
->info
[0].id
= stuff
->wid
;
139 for(j
= 1; j
< PanoramiXNumScreens
; j
++)
140 newWin
->info
[j
].id
= FakeClientID(client
->index
);
142 if (stuff
->class == InputOnly
)
143 stuff
->visual
= CopyFromParent
;
144 orig_visual
= stuff
->visual
;
147 parentIsRoot
= (stuff
->parent
== WindowTable
[0]->drawable
.id
) ||
148 (stuff
->parent
== savedScreenInfo
[0].wid
);
149 FOR_NSCREENS_BACKWARD(j
) {
150 stuff
->wid
= newWin
->info
[j
].id
;
151 stuff
->parent
= parent
->info
[j
].id
;
153 stuff
->x
= orig_x
- panoramiXdataPtr
[j
].x
;
154 stuff
->y
= orig_y
- panoramiXdataPtr
[j
].y
;
157 *((CARD32
*) &stuff
[1] + pback_offset
) = backPix
->info
[j
].id
;
159 *((CARD32
*) &stuff
[1] + pbord_offset
) = bordPix
->info
[j
].id
;
161 *((CARD32
*) &stuff
[1] + cmap_offset
) = cmap
->info
[j
].id
;
162 if ( orig_visual
!= CopyFromParent
)
163 stuff
->visual
= PanoramiXVisualTable
[(orig_visual
*MAXSCREENS
) + j
];
164 result
= (*SavedProcVector
[X_CreateWindow
])(client
);
165 if(result
!= Success
) break;
168 if (result
== Success
)
169 AddResource(newWin
->info
[0].id
, XRT_WINDOW
, newWin
);
177 int PanoramiXChangeWindowAttributes(ClientPtr client
)
180 PanoramiXRes
*backPix
= NULL
;
181 PanoramiXRes
*bordPix
= NULL
;
182 PanoramiXRes
*cmap
= NULL
;
183 REQUEST(xChangeWindowAttributesReq
);
184 int pback_offset
= 0, pbord_offset
= 0, cmap_offset
= 0;
185 int result
= 0, len
, j
;
188 REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq
);
190 len
= client
->req_len
- (sizeof(xChangeWindowAttributesReq
) >> 2);
191 if (Ones(stuff
->valueMask
) != len
)
194 if (!(win
= (PanoramiXRes
*)SecurityLookupIDByType(
195 client
, stuff
->window
, XRT_WINDOW
, DixWriteAccess
)))
198 if((win
->u
.win
.class == InputOnly
) &&
199 (stuff
->valueMask
& (~INPUTONLY_LEGAL_MASK
)))
202 if ((Mask
)stuff
->valueMask
& CWBackPixmap
) {
203 pback_offset
= Ones((Mask
)stuff
->valueMask
& (CWBackPixmap
- 1));
204 tmp
= *((CARD32
*) &stuff
[1] + pback_offset
);
205 if ((tmp
!= None
) && (tmp
!= ParentRelative
)) {
206 if(!(backPix
= (PanoramiXRes
*) SecurityLookupIDByType(
207 client
, tmp
, XRT_PIXMAP
, DixReadAccess
)))
211 if ((Mask
)stuff
->valueMask
& CWBorderPixmap
) {
212 pbord_offset
= Ones((Mask
)stuff
->valueMask
& (CWBorderPixmap
- 1));
213 tmp
= *((CARD32
*) &stuff
[1] + pbord_offset
);
214 if (tmp
!= CopyFromParent
) {
215 if(!(bordPix
= (PanoramiXRes
*) SecurityLookupIDByType(
216 client
, tmp
, XRT_PIXMAP
, DixReadAccess
)))
220 if ((Mask
)stuff
->valueMask
& CWColormap
) {
221 cmap_offset
= Ones((Mask
)stuff
->valueMask
& (CWColormap
- 1));
222 tmp
= *((CARD32
*) &stuff
[1] + cmap_offset
);
223 if ((tmp
!= CopyFromParent
) && (tmp
!= None
)) {
224 if(!(cmap
= (PanoramiXRes
*) SecurityLookupIDByType(
225 client
, tmp
, XRT_COLORMAP
, DixReadAccess
)))
230 FOR_NSCREENS_BACKWARD(j
) {
231 stuff
->window
= win
->info
[j
].id
;
233 *((CARD32
*) &stuff
[1] + pback_offset
) = backPix
->info
[j
].id
;
235 *((CARD32
*) &stuff
[1] + pbord_offset
) = bordPix
->info
[j
].id
;
237 *((CARD32
*) &stuff
[1] + cmap_offset
) = cmap
->info
[j
].id
;
238 result
= (*SavedProcVector
[X_ChangeWindowAttributes
])(client
);
245 int PanoramiXDestroyWindow(ClientPtr client
)
249 REQUEST(xResourceReq
);
251 REQUEST_SIZE_MATCH(xResourceReq
);
253 if(!(win
= (PanoramiXRes
*)SecurityLookupIDByType(
254 client
, stuff
->id
, XRT_WINDOW
, DixDestroyAccess
)))
257 FOR_NSCREENS_BACKWARD(j
) {
258 stuff
->id
= win
->info
[j
].id
;
259 result
= (*SavedProcVector
[X_DestroyWindow
])(client
);
260 if(result
!= Success
) break;
263 /* Since ProcDestroyWindow is using FreeResource, it will free
264 our resource for us on the last pass through the loop above */
270 int PanoramiXDestroySubwindows(ClientPtr client
)
274 REQUEST(xResourceReq
);
276 REQUEST_SIZE_MATCH(xResourceReq
);
278 if(!(win
= (PanoramiXRes
*)SecurityLookupIDByType(
279 client
, stuff
->id
, XRT_WINDOW
, DixDestroyAccess
)))
282 FOR_NSCREENS_BACKWARD(j
) {
283 stuff
->id
= win
->info
[j
].id
;
284 result
= (*SavedProcVector
[X_DestroySubwindows
])(client
);
285 if(result
!= Success
) break;
288 /* DestroySubwindows is using FreeResource which will free
289 our resources for us on the last pass through the loop above */
295 int PanoramiXChangeSaveSet(ClientPtr client
)
299 REQUEST(xChangeSaveSetReq
);
301 REQUEST_SIZE_MATCH(xChangeSaveSetReq
);
303 if(!(win
= (PanoramiXRes
*)SecurityLookupIDByType(
304 client
, stuff
->window
, XRT_WINDOW
, DixReadAccess
)))
307 FOR_NSCREENS_BACKWARD(j
) {
308 stuff
->window
= win
->info
[j
].id
;
309 result
= (*SavedProcVector
[X_ChangeSaveSet
])(client
);
310 if(result
!= Success
) break;
317 int PanoramiXReparentWindow(ClientPtr client
)
319 PanoramiXRes
*win
, *parent
;
323 REQUEST(xReparentWindowReq
);
325 REQUEST_SIZE_MATCH(xReparentWindowReq
);
327 if(!(win
= (PanoramiXRes
*)SecurityLookupIDByType(
328 client
, stuff
->window
, XRT_WINDOW
, DixWriteAccess
)))
331 if(!(parent
= (PanoramiXRes
*)SecurityLookupIDByType(
332 client
, stuff
->parent
, XRT_WINDOW
, DixWriteAccess
)))
337 parentIsRoot
= (stuff
->parent
== WindowTable
[0]->drawable
.id
) ||
338 (stuff
->parent
== savedScreenInfo
[0].wid
);
339 FOR_NSCREENS_BACKWARD(j
) {
340 stuff
->window
= win
->info
[j
].id
;
341 stuff
->parent
= parent
->info
[j
].id
;
343 stuff
->x
= x
- panoramiXdataPtr
[j
].x
;
344 stuff
->y
= y
- panoramiXdataPtr
[j
].y
;
346 result
= (*SavedProcVector
[X_ReparentWindow
])(client
);
347 if(result
!= Success
) break;
354 int PanoramiXMapWindow(ClientPtr client
)
358 REQUEST(xResourceReq
);
360 REQUEST_SIZE_MATCH(xResourceReq
);
362 if(!(win
= (PanoramiXRes
*)SecurityLookupIDByType(
363 client
, stuff
->id
, XRT_WINDOW
, DixReadAccess
)))
366 FOR_NSCREENS_FORWARD(j
) {
367 stuff
->id
= win
->info
[j
].id
;
368 result
= (*SavedProcVector
[X_MapWindow
])(client
);
369 if(result
!= Success
) break;
376 int PanoramiXMapSubwindows(ClientPtr client
)
380 REQUEST(xResourceReq
);
382 REQUEST_SIZE_MATCH(xResourceReq
);
384 if(!(win
= (PanoramiXRes
*)SecurityLookupIDByType(
385 client
, stuff
->id
, XRT_WINDOW
, DixReadAccess
)))
388 FOR_NSCREENS_FORWARD(j
) {
389 stuff
->id
= win
->info
[j
].id
;
390 result
= (*SavedProcVector
[X_MapSubwindows
])(client
);
391 if(result
!= Success
) break;
398 int PanoramiXUnmapWindow(ClientPtr client
)
402 REQUEST(xResourceReq
);
404 REQUEST_SIZE_MATCH(xResourceReq
);
406 if(!(win
= (PanoramiXRes
*)SecurityLookupIDByType(
407 client
, stuff
->id
, XRT_WINDOW
, DixReadAccess
)))
410 FOR_NSCREENS_FORWARD(j
) {
411 stuff
->id
= win
->info
[j
].id
;
412 result
= (*SavedProcVector
[X_UnmapWindow
])(client
);
413 if(result
!= Success
) break;
420 int PanoramiXUnmapSubwindows(ClientPtr client
)
424 REQUEST(xResourceReq
);
426 REQUEST_SIZE_MATCH(xResourceReq
);
428 if(!(win
= (PanoramiXRes
*)SecurityLookupIDByType(
429 client
, stuff
->id
, XRT_WINDOW
, DixReadAccess
)))
432 FOR_NSCREENS_FORWARD(j
) {
433 stuff
->id
= win
->info
[j
].id
;
434 result
= (*SavedProcVector
[X_UnmapSubwindows
])(client
);
435 if(result
!= Success
) break;
442 int PanoramiXConfigureWindow(ClientPtr client
)
445 PanoramiXRes
*sib
= NULL
;
447 int result
= 0, j
, len
, sib_offset
= 0, x
= 0, y
= 0;
450 REQUEST(xConfigureWindowReq
);
452 REQUEST_AT_LEAST_SIZE(xConfigureWindowReq
);
454 len
= client
->req_len
- (sizeof(xConfigureWindowReq
) >> 2);
455 if (Ones(stuff
->mask
) != len
)
458 /* because we need the parent */
459 if (!(pWin
= (WindowPtr
)SecurityLookupIDByType(
460 client
, stuff
->window
, RT_WINDOW
, DixWriteAccess
)))
463 if (!(win
= (PanoramiXRes
*)SecurityLookupIDByType(
464 client
, stuff
->window
, XRT_WINDOW
, DixWriteAccess
)))
467 if ((Mask
)stuff
->mask
& CWSibling
) {
469 sib_offset
= Ones((Mask
)stuff
->mask
& (CWSibling
- 1));
470 if ((tmp
= *((CARD32
*) &stuff
[1] + sib_offset
))) {
471 if(!(sib
= (PanoramiXRes
*) SecurityLookupIDByType(
472 client
, tmp
, XRT_WINDOW
, DixReadAccess
)))
477 if(pWin
->parent
&& ((pWin
->parent
== WindowTable
[0]) ||
478 (pWin
->parent
->drawable
.id
== savedScreenInfo
[0].wid
)))
480 if ((Mask
)stuff
->mask
& CWX
) {
482 x
= *((CARD32
*)&stuff
[1]);
484 if ((Mask
)stuff
->mask
& CWY
) {
485 y_offset
= (x_offset
== -1) ? 0 : 1;
486 y
= *((CARD32
*) &stuff
[1] + y_offset
);
490 /* have to go forward or you get expose events before
491 ConfigureNotify events */
492 FOR_NSCREENS_FORWARD(j
) {
493 stuff
->window
= win
->info
[j
].id
;
495 *((CARD32
*) &stuff
[1] + sib_offset
) = sib
->info
[j
].id
;
497 *((CARD32
*) &stuff
[1] + x_offset
) = x
- panoramiXdataPtr
[j
].x
;
499 *((CARD32
*) &stuff
[1] + y_offset
) = y
- panoramiXdataPtr
[j
].y
;
500 result
= (*SavedProcVector
[X_ConfigureWindow
])(client
);
501 if(result
!= Success
) break;
508 int PanoramiXCirculateWindow(ClientPtr client
)
512 REQUEST(xCirculateWindowReq
);
514 REQUEST_SIZE_MATCH(xCirculateWindowReq
);
516 if(!(win
= (PanoramiXRes
*)SecurityLookupIDByType(
517 client
, stuff
->window
, XRT_WINDOW
, DixWriteAccess
)))
520 FOR_NSCREENS_FORWARD(j
) {
521 stuff
->window
= win
->info
[j
].id
;
522 result
= (*SavedProcVector
[X_CirculateWindow
])(client
);
523 if(result
!= Success
) break;
530 int PanoramiXGetGeometry(ClientPtr client
)
532 xGetGeometryReply rep
;
535 REQUEST(xResourceReq
);
537 REQUEST_SIZE_MATCH(xResourceReq
);
538 rc
= dixLookupDrawable(&pDraw
, stuff
->id
, client
, M_ANY
, DixUnknownAccess
);
544 rep
.sequenceNumber
= client
->sequence
;
545 rep
.root
= WindowTable
[0]->drawable
.id
;
546 rep
.depth
= pDraw
->depth
;
547 rep
.width
= pDraw
->width
;
548 rep
.height
= pDraw
->height
;
549 rep
.x
= rep
.y
= rep
.borderWidth
= 0;
551 if (stuff
->id
== rep
.root
) {
552 xWindowRoot
*root
= (xWindowRoot
*)
553 (ConnectionInfo
+ connBlockScreenStart
);
555 rep
.width
= root
->pixWidth
;
556 rep
.height
= root
->pixHeight
;
558 if ((pDraw
->type
== UNDRAWABLE_WINDOW
) || (pDraw
->type
== DRAWABLE_WINDOW
))
560 WindowPtr pWin
= (WindowPtr
)pDraw
;
561 rep
.x
= pWin
->origin
.x
- wBorderWidth (pWin
);
562 rep
.y
= pWin
->origin
.y
- wBorderWidth (pWin
);
563 if((pWin
->parent
== WindowTable
[0]) ||
564 (pWin
->parent
->drawable
.id
== savedScreenInfo
[0].wid
))
566 rep
.x
+= panoramiXdataPtr
[0].x
;
567 rep
.y
+= panoramiXdataPtr
[0].y
;
569 rep
.borderWidth
= pWin
->borderWidth
;
572 WriteReplyToClient(client
, sizeof(xGetGeometryReply
), &rep
);
573 return (client
->noClientException
);
576 int PanoramiXTranslateCoords(ClientPtr client
)
579 REQUEST(xTranslateCoordsReq
);
581 WindowPtr pWin
, pDst
;
582 xTranslateCoordsReply rep
;
584 REQUEST_SIZE_MATCH(xTranslateCoordsReq
);
585 rc
= dixLookupWindow(&pWin
, stuff
->srcWid
, client
, DixReadAccess
);
588 rc
= dixLookupWindow(&pDst
, stuff
->dstWid
, client
, DixReadAccess
);
593 rep
.sequenceNumber
= client
->sequence
;
594 rep
.sameScreen
= xTrue
;
597 if((pWin
== WindowTable
[0]) ||
598 (pWin
->drawable
.id
== savedScreenInfo
[0].wid
))
600 x
= stuff
->srcX
- panoramiXdataPtr
[0].x
;
601 y
= stuff
->srcY
- panoramiXdataPtr
[0].y
;
603 x
= pWin
->drawable
.x
+ stuff
->srcX
;
604 y
= pWin
->drawable
.y
+ stuff
->srcY
;
606 pWin
= pDst
->firstChild
;
611 if ((pWin
->mapped
) &&
612 (x
>= pWin
->drawable
.x
- wBorderWidth (pWin
)) &&
613 (x
< pWin
->drawable
.x
+ (int)pWin
->drawable
.width
+
614 wBorderWidth (pWin
)) &&
615 (y
>= pWin
->drawable
.y
- wBorderWidth (pWin
)) &&
616 (y
< pWin
->drawable
.y
+ (int)pWin
->drawable
.height
+
619 /* When a window is shaped, a further check
620 * is made to see if the point is inside
623 && (!wBoundingShape(pWin
) ||
624 POINT_IN_REGION(pWin
->drawable
.pScreen
,
625 wBoundingShape(pWin
),
626 x
- pWin
->drawable
.x
,
627 y
- pWin
->drawable
.y
, &box
))
631 rep
.child
= pWin
->drawable
.id
;
632 pWin
= (WindowPtr
) NULL
;
635 pWin
= pWin
->nextSib
;
637 rep
.dstX
= x
- pDst
->drawable
.x
;
638 rep
.dstY
= y
- pDst
->drawable
.y
;
639 if((pDst
== WindowTable
[0]) ||
640 (pDst
->drawable
.id
== savedScreenInfo
[0].wid
))
642 rep
.dstX
+= panoramiXdataPtr
[0].x
;
643 rep
.dstY
+= panoramiXdataPtr
[0].y
;
646 WriteReplyToClient(client
, sizeof(xTranslateCoordsReply
), &rep
);
647 return(client
->noClientException
);
650 int PanoramiXCreatePixmap(ClientPtr client
)
652 PanoramiXRes
*refDraw
, *newPix
;
654 REQUEST(xCreatePixmapReq
);
656 REQUEST_SIZE_MATCH(xCreatePixmapReq
);
657 client
->errorValue
= stuff
->pid
;
659 if(!(refDraw
= (PanoramiXRes
*)SecurityLookupIDByClass(
660 client
, stuff
->drawable
, XRC_DRAWABLE
, DixReadAccess
)))
663 if(!(newPix
= (PanoramiXRes
*) xalloc(sizeof(PanoramiXRes
))))
666 newPix
->type
= XRT_PIXMAP
;
667 newPix
->u
.pix
.shared
= FALSE
;
668 newPix
->info
[0].id
= stuff
->pid
;
669 for(j
= 1; j
< PanoramiXNumScreens
; j
++)
670 newPix
->info
[j
].id
= FakeClientID(client
->index
);
672 FOR_NSCREENS_BACKWARD(j
) {
673 stuff
->pid
= newPix
->info
[j
].id
;
674 stuff
->drawable
= refDraw
->info
[j
].id
;
675 result
= (*SavedProcVector
[X_CreatePixmap
])(client
);
676 if(result
!= Success
) break;
679 if (result
== Success
)
680 AddResource(newPix
->info
[0].id
, XRT_PIXMAP
, newPix
);
688 int PanoramiXFreePixmap(ClientPtr client
)
692 REQUEST(xResourceReq
);
694 REQUEST_SIZE_MATCH(xResourceReq
);
696 client
->errorValue
= stuff
->id
;
698 if(!(pix
= (PanoramiXRes
*)SecurityLookupIDByType(
699 client
, stuff
->id
, XRT_PIXMAP
, DixDestroyAccess
)))
702 FOR_NSCREENS_BACKWARD(j
) {
703 stuff
->id
= pix
->info
[j
].id
;
704 result
= (*SavedProcVector
[X_FreePixmap
])(client
);
705 if(result
!= Success
) break;
708 /* Since ProcFreePixmap is using FreeResource, it will free
709 our resource for us on the last pass through the loop above */
715 int PanoramiXCreateGC(ClientPtr client
)
717 PanoramiXRes
*refDraw
;
719 PanoramiXRes
*stip
= NULL
;
720 PanoramiXRes
*tile
= NULL
;
721 PanoramiXRes
*clip
= NULL
;
722 REQUEST(xCreateGCReq
);
723 int tile_offset
= 0, stip_offset
= 0, clip_offset
= 0;
724 int result
= 0, len
, j
;
727 REQUEST_AT_LEAST_SIZE(xCreateGCReq
);
729 client
->errorValue
= stuff
->gc
;
730 len
= client
->req_len
- (sizeof(xCreateGCReq
) >> 2);
731 if (Ones(stuff
->mask
) != len
)
734 if (!(refDraw
= (PanoramiXRes
*)SecurityLookupIDByClass(
735 client
, stuff
->drawable
, XRC_DRAWABLE
, DixReadAccess
)))
738 if ((Mask
)stuff
->mask
& GCTile
) {
739 tile_offset
= Ones((Mask
)stuff
->mask
& (GCTile
- 1));
740 if ((tmp
= *((CARD32
*) &stuff
[1] + tile_offset
))) {
741 if(!(tile
= (PanoramiXRes
*) SecurityLookupIDByType(
742 client
, tmp
, XRT_PIXMAP
, DixReadAccess
)))
746 if ((Mask
)stuff
->mask
& GCStipple
) {
747 stip_offset
= Ones((Mask
)stuff
->mask
& (GCStipple
- 1));
748 if ((tmp
= *((CARD32
*) &stuff
[1] + stip_offset
))) {
749 if(!(stip
= (PanoramiXRes
*) SecurityLookupIDByType(
750 client
, tmp
, XRT_PIXMAP
, DixReadAccess
)))
754 if ((Mask
)stuff
->mask
& GCClipMask
) {
755 clip_offset
= Ones((Mask
)stuff
->mask
& (GCClipMask
- 1));
756 if ((tmp
= *((CARD32
*) &stuff
[1] + clip_offset
))) {
757 if(!(clip
= (PanoramiXRes
*) SecurityLookupIDByType(
758 client
, tmp
, XRT_PIXMAP
, DixReadAccess
)))
763 if(!(newGC
= (PanoramiXRes
*) xalloc(sizeof(PanoramiXRes
))))
766 newGC
->type
= XRT_GC
;
767 newGC
->info
[0].id
= stuff
->gc
;
768 for(j
= 1; j
< PanoramiXNumScreens
; j
++)
769 newGC
->info
[j
].id
= FakeClientID(client
->index
);
771 FOR_NSCREENS_BACKWARD(j
) {
772 stuff
->gc
= newGC
->info
[j
].id
;
773 stuff
->drawable
= refDraw
->info
[j
].id
;
775 *((CARD32
*) &stuff
[1] + tile_offset
) = tile
->info
[j
].id
;
777 *((CARD32
*) &stuff
[1] + stip_offset
) = stip
->info
[j
].id
;
779 *((CARD32
*) &stuff
[1] + clip_offset
) = clip
->info
[j
].id
;
780 result
= (*SavedProcVector
[X_CreateGC
])(client
);
781 if(result
!= Success
) break;
784 if (result
== Success
)
785 AddResource(newGC
->info
[0].id
, XRT_GC
, newGC
);
792 int PanoramiXChangeGC(ClientPtr client
)
795 PanoramiXRes
*stip
= NULL
;
796 PanoramiXRes
*tile
= NULL
;
797 PanoramiXRes
*clip
= NULL
;
798 REQUEST(xChangeGCReq
);
799 int tile_offset
= 0, stip_offset
= 0, clip_offset
= 0;
800 int result
= 0, len
, j
;
803 REQUEST_AT_LEAST_SIZE(xChangeGCReq
);
805 len
= client
->req_len
- (sizeof(xChangeGCReq
) >> 2);
806 if (Ones(stuff
->mask
) != len
)
809 if (!(gc
= (PanoramiXRes
*)SecurityLookupIDByType(
810 client
, stuff
->gc
, XRT_GC
, DixReadAccess
)))
813 if ((Mask
)stuff
->mask
& GCTile
) {
814 tile_offset
= Ones((Mask
)stuff
->mask
& (GCTile
- 1));
815 if ((tmp
= *((CARD32
*) &stuff
[1] + tile_offset
))) {
816 if(!(tile
= (PanoramiXRes
*) SecurityLookupIDByType(
817 client
, tmp
, XRT_PIXMAP
, DixReadAccess
)))
821 if ((Mask
)stuff
->mask
& GCStipple
) {
822 stip_offset
= Ones((Mask
)stuff
->mask
& (GCStipple
- 1));
823 if ((tmp
= *((CARD32
*) &stuff
[1] + stip_offset
))) {
824 if(!(stip
= (PanoramiXRes
*) SecurityLookupIDByType(
825 client
, tmp
, XRT_PIXMAP
, DixReadAccess
)))
829 if ((Mask
)stuff
->mask
& GCClipMask
) {
830 clip_offset
= Ones((Mask
)stuff
->mask
& (GCClipMask
- 1));
831 if ((tmp
= *((CARD32
*) &stuff
[1] + clip_offset
))) {
832 if(!(clip
= (PanoramiXRes
*) SecurityLookupIDByType(
833 client
, tmp
, XRT_PIXMAP
, DixReadAccess
)))
839 FOR_NSCREENS_BACKWARD(j
) {
840 stuff
->gc
= gc
->info
[j
].id
;
842 *((CARD32
*) &stuff
[1] + tile_offset
) = tile
->info
[j
].id
;
844 *((CARD32
*) &stuff
[1] + stip_offset
) = stip
->info
[j
].id
;
846 *((CARD32
*) &stuff
[1] + clip_offset
) = clip
->info
[j
].id
;
847 result
= (*SavedProcVector
[X_ChangeGC
])(client
);
848 if(result
!= Success
) break;
855 int PanoramiXCopyGC(ClientPtr client
)
857 PanoramiXRes
*srcGC
, *dstGC
;
861 REQUEST_SIZE_MATCH(xCopyGCReq
);
863 if(!(srcGC
= (PanoramiXRes
*)SecurityLookupIDByType(
864 client
, stuff
->srcGC
, XRT_GC
, DixReadAccess
)))
867 if(!(dstGC
= (PanoramiXRes
*)SecurityLookupIDByType(
868 client
, stuff
->dstGC
, XRT_GC
, DixWriteAccess
)))
872 stuff
->srcGC
= srcGC
->info
[j
].id
;
873 stuff
->dstGC
= dstGC
->info
[j
].id
;
874 result
= (*SavedProcVector
[X_CopyGC
])(client
);
875 if(result
!= Success
) break;
882 int PanoramiXSetDashes(ClientPtr client
)
886 REQUEST(xSetDashesReq
);
888 REQUEST_FIXED_SIZE(xSetDashesReq
, stuff
->nDashes
);
890 if(!(gc
= (PanoramiXRes
*)SecurityLookupIDByType(
891 client
, stuff
->gc
, XRT_GC
, DixWriteAccess
)))
894 FOR_NSCREENS_BACKWARD(j
) {
895 stuff
->gc
= gc
->info
[j
].id
;
896 result
= (*SavedProcVector
[X_SetDashes
])(client
);
897 if(result
!= Success
) break;
904 int PanoramiXSetClipRectangles(ClientPtr client
)
908 REQUEST(xSetClipRectanglesReq
);
910 REQUEST_AT_LEAST_SIZE(xSetClipRectanglesReq
);
912 if(!(gc
= (PanoramiXRes
*)SecurityLookupIDByType(
913 client
, stuff
->gc
, XRT_GC
, DixWriteAccess
)))
916 FOR_NSCREENS_BACKWARD(j
) {
917 stuff
->gc
= gc
->info
[j
].id
;
918 result
= (*SavedProcVector
[X_SetClipRectangles
])(client
);
919 if(result
!= Success
) break;
926 int PanoramiXFreeGC(ClientPtr client
)
930 REQUEST(xResourceReq
);
932 REQUEST_SIZE_MATCH(xResourceReq
);
934 if(!(gc
= (PanoramiXRes
*)SecurityLookupIDByType(
935 client
, stuff
->id
, XRT_GC
, DixDestroyAccess
)))
938 FOR_NSCREENS_BACKWARD(j
) {
939 stuff
->id
= gc
->info
[j
].id
;
940 result
= (*SavedProcVector
[X_FreeGC
])(client
);
941 if(result
!= Success
) break;
944 /* Since ProcFreeGC is using FreeResource, it will free
945 our resource for us on the last pass through the loop above */
951 int PanoramiXClearToBackground(ClientPtr client
)
954 int result
= 0, j
, x
, y
;
956 REQUEST(xClearAreaReq
);
958 REQUEST_SIZE_MATCH(xClearAreaReq
);
960 if(!(win
= (PanoramiXRes
*)SecurityLookupIDByType(
961 client
, stuff
->window
, XRT_WINDOW
, DixWriteAccess
)))
966 isRoot
= win
->u
.win
.root
;
967 FOR_NSCREENS_BACKWARD(j
) {
968 stuff
->window
= win
->info
[j
].id
;
970 stuff
->x
= x
- panoramiXdataPtr
[j
].x
;
971 stuff
->y
= y
- panoramiXdataPtr
[j
].y
;
973 result
= (*SavedProcVector
[X_ClearArea
])(client
);
974 if(result
!= Success
) break;
982 For Window to Pixmap copies you're screwed since each screen's
983 pixmap will look like what it sees on its screen. Unless the
984 screens overlap and the window lies on each, the two copies
985 will be out of sync. To remedy this we do a GetImage and PutImage
986 in place of the copy. Doing this as a single Image isn't quite
987 correct since it will include the obscured areas but we will
988 have to fix this later. (MArk).
991 int PanoramiXCopyArea(ClientPtr client
)
993 int j
, result
= 0, srcx
, srcy
, dstx
, dsty
;
994 PanoramiXRes
*gc
, *src
, *dst
;
995 Bool srcIsRoot
= FALSE
;
996 Bool dstIsRoot
= FALSE
;
997 Bool srcShared
, dstShared
;
998 REQUEST(xCopyAreaReq
);
1000 REQUEST_SIZE_MATCH(xCopyAreaReq
);
1002 if(!(src
= (PanoramiXRes
*)SecurityLookupIDByClass(
1003 client
, stuff
->srcDrawable
, XRC_DRAWABLE
, DixReadAccess
)))
1006 srcShared
= IS_SHARED_PIXMAP(src
);
1008 if(!(dst
= (PanoramiXRes
*)SecurityLookupIDByClass(
1009 client
, stuff
->dstDrawable
, XRC_DRAWABLE
, DixWriteAccess
)))
1012 dstShared
= IS_SHARED_PIXMAP(dst
);
1014 if(dstShared
&& srcShared
)
1015 return (* SavedProcVector
[X_CopyArea
])(client
);
1017 if(!(gc
= (PanoramiXRes
*)SecurityLookupIDByType(
1018 client
, stuff
->gc
, XRT_GC
, DixReadAccess
)))
1021 if((dst
->type
== XRT_WINDOW
) && dst
->u
.win
.root
)
1023 if((src
->type
== XRT_WINDOW
) && src
->u
.win
.root
)
1026 srcx
= stuff
->srcX
; srcy
= stuff
->srcY
;
1027 dstx
= stuff
->dstX
; dsty
= stuff
->dstY
;
1028 if((dst
->type
== XRT_PIXMAP
) && (src
->type
== XRT_WINDOW
)) {
1029 DrawablePtr drawables
[MAXSCREENS
];
1036 rc
= dixLookupDrawable(drawables
+j
, src
->info
[j
].id
, client
, 0,
1042 pitch
= PixmapBytePad(stuff
->width
, drawables
[0]->depth
);
1043 if(!(data
= xcalloc(1, stuff
->height
* pitch
)))
1046 XineramaGetImageData(drawables
, srcx
, srcy
,
1047 stuff
->width
, stuff
->height
, ZPixmap
, ~0, data
, pitch
,
1050 FOR_NSCREENS_BACKWARD(j
) {
1051 stuff
->gc
= gc
->info
[j
].id
;
1052 VALIDATE_DRAWABLE_AND_GC(dst
->info
[j
].id
, pDst
, pGC
, client
);
1054 if(drawables
[0]->depth
!= pDst
->depth
) {
1055 client
->errorValue
= stuff
->dstDrawable
;
1060 (*pGC
->ops
->PutImage
) (pDst
, pGC
, pDst
->depth
, dstx
, dsty
,
1061 stuff
->width
, stuff
->height
,
1064 if(dstShared
) break;
1071 DrawablePtr pDst
= NULL
, pSrc
= NULL
;
1073 RegionPtr pRgn
[MAXSCREENS
];
1076 FOR_NSCREENS_BACKWARD(j
) {
1077 stuff
->dstDrawable
= dst
->info
[j
].id
;
1078 stuff
->srcDrawable
= src
->info
[j
].id
;
1079 stuff
->gc
= gc
->info
[j
].id
;
1081 stuff
->srcX
= srcx
- panoramiXdataPtr
[j
].x
;
1082 stuff
->srcY
= srcy
- panoramiXdataPtr
[j
].y
;
1085 stuff
->dstX
= dstx
- panoramiXdataPtr
[j
].x
;
1086 stuff
->dstY
= dsty
- panoramiXdataPtr
[j
].y
;
1089 VALIDATE_DRAWABLE_AND_GC(stuff
->dstDrawable
, pDst
, pGC
, client
);
1090 if (stuff
->dstDrawable
!= stuff
->srcDrawable
) {
1091 rc
= dixLookupDrawable(&pSrc
, stuff
->srcDrawable
, client
, 0,
1096 if ((pDst
->pScreen
!= pSrc
->pScreen
) ||
1097 (pDst
->depth
!= pSrc
->depth
)) {
1098 client
->errorValue
= stuff
->dstDrawable
;
1104 pRgn
[j
] = (*pGC
->ops
->CopyArea
)(pSrc
, pDst
, pGC
,
1105 stuff
->srcX
, stuff
->srcY
,
1106 stuff
->width
, stuff
->height
,
1107 stuff
->dstX
, stuff
->dstY
);
1110 while(j
--) pRgn
[j
] = NULL
;
1115 if(pGC
->graphicsExposures
) {
1116 ScreenPtr pScreen
= pDst
->pScreen
;
1120 REGION_NULL(pScreen
, &totalReg
);
1121 FOR_NSCREENS_BACKWARD(j
) {
1124 REGION_TRANSLATE(pScreen
, pRgn
[j
],
1125 panoramiXdataPtr
[j
].x
, panoramiXdataPtr
[j
].y
);
1127 REGION_APPEND(pScreen
, &totalReg
, pRgn
[j
]);
1128 REGION_DESTROY(pScreen
, pRgn
[j
]);
1131 REGION_VALIDATE(pScreen
, &totalReg
, &overlap
);
1132 (*pScreen
->SendGraphicsExpose
)(
1133 client
, &totalReg
, stuff
->dstDrawable
, X_CopyArea
, 0);
1134 REGION_UNINIT(pScreen
, &totalReg
);
1137 result
= client
->noClientException
;
1144 int PanoramiXCopyPlane(ClientPtr client
)
1146 int j
, srcx
, srcy
, dstx
, dsty
, rc
;
1147 PanoramiXRes
*gc
, *src
, *dst
;
1148 Bool srcIsRoot
= FALSE
;
1149 Bool dstIsRoot
= FALSE
;
1150 Bool srcShared
, dstShared
;
1151 DrawablePtr psrcDraw
, pdstDraw
= NULL
;
1153 RegionPtr pRgn
[MAXSCREENS
];
1154 REQUEST(xCopyPlaneReq
);
1156 REQUEST_SIZE_MATCH(xCopyPlaneReq
);
1158 if(!(src
= (PanoramiXRes
*)SecurityLookupIDByClass(
1159 client
, stuff
->srcDrawable
, XRC_DRAWABLE
, DixReadAccess
)))
1162 srcShared
= IS_SHARED_PIXMAP(src
);
1164 if(!(dst
= (PanoramiXRes
*)SecurityLookupIDByClass(
1165 client
, stuff
->dstDrawable
, XRC_DRAWABLE
, DixWriteAccess
)))
1168 dstShared
= IS_SHARED_PIXMAP(dst
);
1170 if(dstShared
&& srcShared
)
1171 return (* SavedProcVector
[X_CopyPlane
])(client
);
1173 if(!(gc
= (PanoramiXRes
*)SecurityLookupIDByType(
1174 client
, stuff
->gc
, XRT_GC
, DixReadAccess
)))
1177 if((dst
->type
== XRT_WINDOW
) && dst
->u
.win
.root
)
1179 if((src
->type
== XRT_WINDOW
) && src
->u
.win
.root
)
1182 srcx
= stuff
->srcX
; srcy
= stuff
->srcY
;
1183 dstx
= stuff
->dstX
; dsty
= stuff
->dstY
;
1185 FOR_NSCREENS_BACKWARD(j
) {
1186 stuff
->dstDrawable
= dst
->info
[j
].id
;
1187 stuff
->srcDrawable
= src
->info
[j
].id
;
1188 stuff
->gc
= gc
->info
[j
].id
;
1190 stuff
->srcX
= srcx
- panoramiXdataPtr
[j
].x
;
1191 stuff
->srcY
= srcy
- panoramiXdataPtr
[j
].y
;
1194 stuff
->dstX
= dstx
- panoramiXdataPtr
[j
].x
;
1195 stuff
->dstY
= dsty
- panoramiXdataPtr
[j
].y
;
1198 VALIDATE_DRAWABLE_AND_GC(stuff
->dstDrawable
, pdstDraw
, pGC
, client
);
1199 if (stuff
->dstDrawable
!= stuff
->srcDrawable
) {
1200 rc
= dixLookupDrawable(&psrcDraw
, stuff
->srcDrawable
, client
, 0,
1205 if (pdstDraw
->pScreen
!= psrcDraw
->pScreen
) {
1206 client
->errorValue
= stuff
->dstDrawable
;
1210 psrcDraw
= pdstDraw
;
1212 if(stuff
->bitPlane
== 0 || (stuff
->bitPlane
& (stuff
->bitPlane
- 1)) ||
1213 (stuff
->bitPlane
> (1L << (psrcDraw
->depth
- 1)))) {
1214 client
->errorValue
= stuff
->bitPlane
;
1218 pRgn
[j
] = (*pGC
->ops
->CopyPlane
)(psrcDraw
, pdstDraw
, pGC
,
1219 stuff
->srcX
, stuff
->srcY
,
1220 stuff
->width
, stuff
->height
,
1221 stuff
->dstX
, stuff
->dstY
, stuff
->bitPlane
);
1224 while(j
--) pRgn
[j
] = NULL
;
1229 if(pGC
->graphicsExposures
) {
1230 ScreenPtr pScreen
= pdstDraw
->pScreen
;
1234 REGION_NULL(pScreen
, &totalReg
);
1235 FOR_NSCREENS_BACKWARD(j
) {
1237 REGION_APPEND(pScreen
, &totalReg
, pRgn
[j
]);
1238 REGION_DESTROY(pScreen
, pRgn
[j
]);
1241 REGION_VALIDATE(pScreen
, &totalReg
, &overlap
);
1242 (*pScreen
->SendGraphicsExpose
)(
1243 client
, &totalReg
, stuff
->dstDrawable
, X_CopyPlane
, 0);
1244 REGION_UNINIT(pScreen
, &totalReg
);
1247 return (client
->noClientException
);
1251 int PanoramiXPolyPoint(ClientPtr client
)
1253 PanoramiXRes
*gc
, *draw
;
1254 int result
= 0, npoint
, j
;
1257 REQUEST(xPolyPointReq
);
1259 REQUEST_AT_LEAST_SIZE(xPolyPointReq
);
1261 if(!(draw
= (PanoramiXRes
*)SecurityLookupIDByClass(
1262 client
, stuff
->drawable
, XRC_DRAWABLE
, DixWriteAccess
)))
1265 if(IS_SHARED_PIXMAP(draw
))
1266 return (*SavedProcVector
[X_PolyPoint
])(client
);
1268 if(!(gc
= (PanoramiXRes
*)SecurityLookupIDByType(
1269 client
, stuff
->gc
, XRT_GC
, DixReadAccess
)))
1272 isRoot
= (draw
->type
== XRT_WINDOW
) && draw
->u
.win
.root
;
1273 npoint
= ((client
->req_len
<< 2) - sizeof(xPolyPointReq
)) >> 2;
1275 origPts
= (xPoint
*) ALLOCATE_LOCAL(npoint
* sizeof(xPoint
));
1276 memcpy((char *) origPts
, (char *) &stuff
[1], npoint
* sizeof(xPoint
));
1277 FOR_NSCREENS_FORWARD(j
){
1279 if(j
) memcpy(&stuff
[1], origPts
, npoint
* sizeof(xPoint
));
1282 int x_off
= panoramiXdataPtr
[j
].x
;
1283 int y_off
= panoramiXdataPtr
[j
].y
;
1285 if(x_off
|| y_off
) {
1286 xPoint
*pnts
= (xPoint
*)&stuff
[1];
1287 int i
= (stuff
->coordMode
==CoordModePrevious
) ? 1 : npoint
;
1297 stuff
->drawable
= draw
->info
[j
].id
;
1298 stuff
->gc
= gc
->info
[j
].id
;
1299 result
= (* SavedProcVector
[X_PolyPoint
])(client
);
1300 if(result
!= Success
) break;
1302 DEALLOCATE_LOCAL(origPts
);
1305 return (client
->noClientException
);
1309 int PanoramiXPolyLine(ClientPtr client
)
1311 PanoramiXRes
*gc
, *draw
;
1312 int result
= 0, npoint
, j
;
1315 REQUEST(xPolyLineReq
);
1317 REQUEST_AT_LEAST_SIZE(xPolyLineReq
);
1319 if(!(draw
= (PanoramiXRes
*)SecurityLookupIDByClass(
1320 client
, stuff
->drawable
, XRC_DRAWABLE
, DixWriteAccess
)))
1323 if(IS_SHARED_PIXMAP(draw
))
1324 return (*SavedProcVector
[X_PolyLine
])(client
);
1326 if(!(gc
= (PanoramiXRes
*)SecurityLookupIDByType(
1327 client
, stuff
->gc
, XRT_GC
, DixReadAccess
)))
1330 isRoot
= (draw
->type
== XRT_WINDOW
) && draw
->u
.win
.root
;
1331 npoint
= ((client
->req_len
<< 2) - sizeof(xPolyLineReq
)) >> 2;
1333 origPts
= (xPoint
*) ALLOCATE_LOCAL(npoint
* sizeof(xPoint
));
1334 memcpy((char *) origPts
, (char *) &stuff
[1], npoint
* sizeof(xPoint
));
1335 FOR_NSCREENS_FORWARD(j
){
1337 if(j
) memcpy(&stuff
[1], origPts
, npoint
* sizeof(xPoint
));
1340 int x_off
= panoramiXdataPtr
[j
].x
;
1341 int y_off
= panoramiXdataPtr
[j
].y
;
1343 if(x_off
|| y_off
) {
1344 xPoint
*pnts
= (xPoint
*)&stuff
[1];
1345 int i
= (stuff
->coordMode
==CoordModePrevious
) ? 1 : npoint
;
1355 stuff
->drawable
= draw
->info
[j
].id
;
1356 stuff
->gc
= gc
->info
[j
].id
;
1357 result
= (* SavedProcVector
[X_PolyLine
])(client
);
1358 if(result
!= Success
) break;
1360 DEALLOCATE_LOCAL(origPts
);
1363 return (client
->noClientException
);
1367 int PanoramiXPolySegment(ClientPtr client
)
1369 int result
= 0, nsegs
, i
, j
;
1370 PanoramiXRes
*gc
, *draw
;
1373 REQUEST(xPolySegmentReq
);
1375 REQUEST_AT_LEAST_SIZE(xPolySegmentReq
);
1377 if(!(draw
= (PanoramiXRes
*)SecurityLookupIDByClass(
1378 client
, stuff
->drawable
, XRC_DRAWABLE
, DixWriteAccess
)))
1381 if(IS_SHARED_PIXMAP(draw
))
1382 return (*SavedProcVector
[X_PolySegment
])(client
);
1384 if(!(gc
= (PanoramiXRes
*)SecurityLookupIDByType(
1385 client
, stuff
->gc
, XRT_GC
, DixReadAccess
)))
1388 isRoot
= (draw
->type
== XRT_WINDOW
) && draw
->u
.win
.root
;
1390 nsegs
= (client
->req_len
<< 2) - sizeof(xPolySegmentReq
);
1391 if(nsegs
& 4) return BadLength
;
1394 origSegs
= (xSegment
*) ALLOCATE_LOCAL(nsegs
* sizeof(xSegment
));
1395 memcpy((char *) origSegs
, (char *) &stuff
[1], nsegs
* sizeof(xSegment
));
1396 FOR_NSCREENS_FORWARD(j
){
1398 if(j
) memcpy(&stuff
[1], origSegs
, nsegs
* sizeof(xSegment
));
1401 int x_off
= panoramiXdataPtr
[j
].x
;
1402 int y_off
= panoramiXdataPtr
[j
].y
;
1404 if(x_off
|| y_off
) {
1405 xSegment
*segs
= (xSegment
*)&stuff
[1];
1407 for (i
= nsegs
; i
--; segs
++) {
1416 stuff
->drawable
= draw
->info
[j
].id
;
1417 stuff
->gc
= gc
->info
[j
].id
;
1418 result
= (* SavedProcVector
[X_PolySegment
])(client
);
1419 if(result
!= Success
) break;
1421 DEALLOCATE_LOCAL(origSegs
);
1424 return (client
->noClientException
);
1428 int PanoramiXPolyRectangle(ClientPtr client
)
1430 int result
= 0, nrects
, i
, j
;
1431 PanoramiXRes
*gc
, *draw
;
1433 xRectangle
*origRecs
;
1434 REQUEST(xPolyRectangleReq
);
1436 REQUEST_AT_LEAST_SIZE(xPolyRectangleReq
);
1439 if(!(draw
= (PanoramiXRes
*)SecurityLookupIDByClass(
1440 client
, stuff
->drawable
, XRC_DRAWABLE
, DixWriteAccess
)))
1443 if(IS_SHARED_PIXMAP(draw
))
1444 return (*SavedProcVector
[X_PolyRectangle
])(client
);
1446 if(!(gc
= (PanoramiXRes
*)SecurityLookupIDByType(
1447 client
, stuff
->gc
, XRT_GC
, DixReadAccess
)))
1450 isRoot
= (draw
->type
== XRT_WINDOW
) && draw
->u
.win
.root
;
1452 nrects
= (client
->req_len
<< 2) - sizeof(xPolyRectangleReq
);
1453 if(nrects
& 4) return BadLength
;
1456 origRecs
= (xRectangle
*) ALLOCATE_LOCAL(nrects
* sizeof(xRectangle
));
1457 memcpy((char *)origRecs
,(char *)&stuff
[1],nrects
* sizeof(xRectangle
));
1458 FOR_NSCREENS_FORWARD(j
){
1460 if(j
) memcpy(&stuff
[1], origRecs
, nrects
* sizeof(xRectangle
));
1463 int x_off
= panoramiXdataPtr
[j
].x
;
1464 int y_off
= panoramiXdataPtr
[j
].y
;
1467 if(x_off
|| y_off
) {
1468 xRectangle
*rects
= (xRectangle
*) &stuff
[1];
1470 for (i
= nrects
; i
--; rects
++) {
1477 stuff
->drawable
= draw
->info
[j
].id
;
1478 stuff
->gc
= gc
->info
[j
].id
;
1479 result
= (* SavedProcVector
[X_PolyRectangle
])(client
);
1480 if(result
!= Success
) break;
1482 DEALLOCATE_LOCAL(origRecs
);
1485 return (client
->noClientException
);
1489 int PanoramiXPolyArc(ClientPtr client
)
1491 int result
= 0, narcs
, i
, j
;
1492 PanoramiXRes
*gc
, *draw
;
1495 REQUEST(xPolyArcReq
);
1497 REQUEST_AT_LEAST_SIZE(xPolyArcReq
);
1499 if(!(draw
= (PanoramiXRes
*)SecurityLookupIDByClass(
1500 client
, stuff
->drawable
, XRC_DRAWABLE
, DixWriteAccess
)))
1503 if(IS_SHARED_PIXMAP(draw
))
1504 return (*SavedProcVector
[X_PolyArc
])(client
);
1506 if(!(gc
= (PanoramiXRes
*)SecurityLookupIDByType(
1507 client
, stuff
->gc
, XRT_GC
, DixReadAccess
)))
1510 isRoot
= (draw
->type
== XRT_WINDOW
) && draw
->u
.win
.root
;
1512 narcs
= (client
->req_len
<< 2) - sizeof(xPolyArcReq
);
1513 if(narcs
% sizeof(xArc
)) return BadLength
;
1514 narcs
/= sizeof(xArc
);
1516 origArcs
= (xArc
*) ALLOCATE_LOCAL(narcs
* sizeof(xArc
));
1517 memcpy((char *) origArcs
, (char *) &stuff
[1], narcs
* sizeof(xArc
));
1518 FOR_NSCREENS_FORWARD(j
){
1520 if(j
) memcpy(&stuff
[1], origArcs
, narcs
* sizeof(xArc
));
1523 int x_off
= panoramiXdataPtr
[j
].x
;
1524 int y_off
= panoramiXdataPtr
[j
].y
;
1526 if(x_off
|| y_off
) {
1527 xArc
*arcs
= (xArc
*) &stuff
[1];
1529 for (i
= narcs
; i
--; arcs
++) {
1535 stuff
->drawable
= draw
->info
[j
].id
;
1536 stuff
->gc
= gc
->info
[j
].id
;
1537 result
= (* SavedProcVector
[X_PolyArc
])(client
);
1538 if(result
!= Success
) break;
1540 DEALLOCATE_LOCAL(origArcs
);
1543 return (client
->noClientException
);
1547 int PanoramiXFillPoly(ClientPtr client
)
1549 int result
= 0, count
, j
;
1550 PanoramiXRes
*gc
, *draw
;
1553 REQUEST(xFillPolyReq
);
1555 REQUEST_AT_LEAST_SIZE(xFillPolyReq
);
1557 if(!(draw
= (PanoramiXRes
*)SecurityLookupIDByClass(
1558 client
, stuff
->drawable
, XRC_DRAWABLE
, DixWriteAccess
)))
1561 if(IS_SHARED_PIXMAP(draw
))
1562 return (*SavedProcVector
[X_FillPoly
])(client
);
1564 if(!(gc
= (PanoramiXRes
*)SecurityLookupIDByType(
1565 client
, stuff
->gc
, XRT_GC
, DixReadAccess
)))
1568 isRoot
= (draw
->type
== XRT_WINDOW
) && draw
->u
.win
.root
;
1570 count
= ((client
->req_len
<< 2) - sizeof(xFillPolyReq
)) >> 2;
1572 locPts
= (DDXPointPtr
) ALLOCATE_LOCAL(count
* sizeof(DDXPointRec
));
1573 memcpy((char *)locPts
, (char *)&stuff
[1], count
* sizeof(DDXPointRec
));
1574 FOR_NSCREENS_FORWARD(j
){
1576 if(j
) memcpy(&stuff
[1], locPts
, count
* sizeof(DDXPointRec
));
1579 int x_off
= panoramiXdataPtr
[j
].x
;
1580 int y_off
= panoramiXdataPtr
[j
].y
;
1582 if(x_off
|| y_off
) {
1583 DDXPointPtr pnts
= (DDXPointPtr
)&stuff
[1];
1584 int i
= (stuff
->coordMode
==CoordModePrevious
) ? 1 : count
;
1594 stuff
->drawable
= draw
->info
[j
].id
;
1595 stuff
->gc
= gc
->info
[j
].id
;
1596 result
= (* SavedProcVector
[X_FillPoly
])(client
);
1597 if(result
!= Success
) break;
1599 DEALLOCATE_LOCAL(locPts
);
1602 return (client
->noClientException
);
1606 int PanoramiXPolyFillRectangle(ClientPtr client
)
1608 int result
= 0, things
, i
, j
;
1609 PanoramiXRes
*gc
, *draw
;
1611 xRectangle
*origRects
;
1612 REQUEST(xPolyFillRectangleReq
);
1614 REQUEST_AT_LEAST_SIZE(xPolyFillRectangleReq
);
1616 if(!(draw
= (PanoramiXRes
*)SecurityLookupIDByClass(
1617 client
, stuff
->drawable
, XRC_DRAWABLE
, DixWriteAccess
)))
1620 if(IS_SHARED_PIXMAP(draw
))
1621 return (*SavedProcVector
[X_PolyFillRectangle
])(client
);
1623 if(!(gc
= (PanoramiXRes
*)SecurityLookupIDByType(
1624 client
, stuff
->gc
, XRT_GC
, DixReadAccess
)))
1627 isRoot
= (draw
->type
== XRT_WINDOW
) && draw
->u
.win
.root
;
1629 things
= (client
->req_len
<< 2) - sizeof(xPolyFillRectangleReq
);
1630 if(things
& 4) return BadLength
;
1633 origRects
= (xRectangle
*) ALLOCATE_LOCAL(things
* sizeof(xRectangle
));
1634 memcpy((char*)origRects
,(char*)&stuff
[1], things
* sizeof(xRectangle
));
1635 FOR_NSCREENS_FORWARD(j
){
1637 if(j
) memcpy(&stuff
[1], origRects
, things
* sizeof(xRectangle
));
1640 int x_off
= panoramiXdataPtr
[j
].x
;
1641 int y_off
= panoramiXdataPtr
[j
].y
;
1643 if(x_off
|| y_off
) {
1644 xRectangle
*rects
= (xRectangle
*) &stuff
[1];
1646 for (i
= things
; i
--; rects
++) {
1653 stuff
->drawable
= draw
->info
[j
].id
;
1654 stuff
->gc
= gc
->info
[j
].id
;
1655 result
= (* SavedProcVector
[X_PolyFillRectangle
])(client
);
1656 if(result
!= Success
) break;
1658 DEALLOCATE_LOCAL(origRects
);
1661 return (client
->noClientException
);
1665 int PanoramiXPolyFillArc(ClientPtr client
)
1667 PanoramiXRes
*gc
, *draw
;
1669 int result
= 0, narcs
, i
, j
;
1671 REQUEST(xPolyFillArcReq
);
1673 REQUEST_AT_LEAST_SIZE(xPolyFillArcReq
);
1675 if(!(draw
= (PanoramiXRes
*)SecurityLookupIDByClass(
1676 client
, stuff
->drawable
, XRC_DRAWABLE
, DixWriteAccess
)))
1679 if(IS_SHARED_PIXMAP(draw
))
1680 return (*SavedProcVector
[X_PolyFillArc
])(client
);
1682 if(!(gc
= (PanoramiXRes
*)SecurityLookupIDByType(
1683 client
, stuff
->gc
, XRT_GC
, DixReadAccess
)))
1686 isRoot
= (draw
->type
== XRT_WINDOW
) && draw
->u
.win
.root
;
1688 narcs
= (client
->req_len
<< 2) - sizeof(xPolyFillArcReq
);
1689 IF_RETURN((narcs
% sizeof(xArc
)), BadLength
);
1690 narcs
/= sizeof(xArc
);
1692 origArcs
= (xArc
*) ALLOCATE_LOCAL(narcs
* sizeof(xArc
));
1693 memcpy((char *) origArcs
, (char *)&stuff
[1], narcs
* sizeof(xArc
));
1694 FOR_NSCREENS_FORWARD(j
){
1696 if(j
) memcpy(&stuff
[1], origArcs
, narcs
* sizeof(xArc
));
1699 int x_off
= panoramiXdataPtr
[j
].x
;
1700 int y_off
= panoramiXdataPtr
[j
].y
;
1702 if(x_off
|| y_off
) {
1703 xArc
*arcs
= (xArc
*) &stuff
[1];
1705 for (i
= narcs
; i
--; arcs
++) {
1712 stuff
->drawable
= draw
->info
[j
].id
;
1713 stuff
->gc
= gc
->info
[j
].id
;
1714 result
= (* SavedProcVector
[X_PolyFillArc
])(client
);
1715 if(result
!= Success
) break;
1717 DEALLOCATE_LOCAL(origArcs
);
1720 return (client
->noClientException
);
1724 int PanoramiXPutImage(ClientPtr client
)
1726 PanoramiXRes
*gc
, *draw
;
1728 int j
, result
= 0, orig_x
, orig_y
;
1729 REQUEST(xPutImageReq
);
1731 REQUEST_AT_LEAST_SIZE(xPutImageReq
);
1733 if(!(draw
= (PanoramiXRes
*)SecurityLookupIDByClass(
1734 client
, stuff
->drawable
, XRC_DRAWABLE
, DixWriteAccess
)))
1737 if(IS_SHARED_PIXMAP(draw
))
1738 return (*SavedProcVector
[X_PutImage
])(client
);
1740 if(!(gc
= (PanoramiXRes
*)SecurityLookupIDByType(
1741 client
, stuff
->gc
, XRT_GC
, DixReadAccess
)))
1744 isRoot
= (draw
->type
== XRT_WINDOW
) && draw
->u
.win
.root
;
1746 orig_x
= stuff
->dstX
;
1747 orig_y
= stuff
->dstY
;
1748 FOR_NSCREENS_BACKWARD(j
){
1750 stuff
->dstX
= orig_x
- panoramiXdataPtr
[j
].x
;
1751 stuff
->dstY
= orig_y
- panoramiXdataPtr
[j
].y
;
1753 stuff
->drawable
= draw
->info
[j
].id
;
1754 stuff
->gc
= gc
->info
[j
].id
;
1755 result
= (* SavedProcVector
[X_PutImage
])(client
);
1756 if(result
!= Success
) break;
1762 int PanoramiXGetImage(ClientPtr client
)
1764 DrawablePtr drawables
[MAXSCREENS
];
1770 int i
, x
, y
, w
, h
, format
, rc
;
1771 Mask plane
= 0, planemask
;
1772 int linesDone
, nlines
, linesPerBuf
;
1773 long widthBytesLine
, length
;
1775 REQUEST(xGetImageReq
);
1777 REQUEST_SIZE_MATCH(xGetImageReq
);
1779 if ((stuff
->format
!= XYPixmap
) && (stuff
->format
!= ZPixmap
)) {
1780 client
->errorValue
= stuff
->format
;
1784 if(!(draw
= (PanoramiXRes
*)SecurityLookupIDByClass(
1785 client
, stuff
->drawable
, XRC_DRAWABLE
, DixWriteAccess
)))
1788 if(draw
->type
== XRT_PIXMAP
)
1789 return (*SavedProcVector
[X_GetImage
])(client
);
1791 rc
= dixLookupDrawable(&pDraw
, stuff
->drawable
, client
, 0,
1796 if(!((WindowPtr
)pDraw
)->realized
)
1803 format
= stuff
->format
;
1804 planemask
= stuff
->planeMask
;
1806 isRoot
= (draw
->type
== XRT_WINDOW
) && draw
->u
.win
.root
;
1809 if( /* check for being onscreen */
1810 x
< 0 || x
+ w
> PanoramiXPixWidth
||
1811 y
< 0 || y
+ h
> PanoramiXPixHeight
)
1814 if( /* check for being onscreen */
1815 panoramiXdataPtr
[0].x
+ pDraw
->x
+ x
< 0 ||
1816 panoramiXdataPtr
[0].x
+ pDraw
->x
+ x
+ w
> PanoramiXPixWidth
||
1817 panoramiXdataPtr
[0].y
+ pDraw
->y
+ y
< 0 ||
1818 panoramiXdataPtr
[0].y
+ pDraw
->y
+ y
+ h
> PanoramiXPixHeight
||
1819 /* check for being inside of border */
1820 x
< - wBorderWidth((WindowPtr
)pDraw
) ||
1821 x
+ w
> wBorderWidth((WindowPtr
)pDraw
) + (int)pDraw
->width
||
1822 y
< -wBorderWidth((WindowPtr
)pDraw
) ||
1823 y
+ h
> wBorderWidth ((WindowPtr
)pDraw
) + (int)pDraw
->height
)
1827 drawables
[0] = pDraw
;
1828 for(i
= 1; i
< PanoramiXNumScreens
; i
++) {
1829 rc
= dixLookupDrawable(drawables
+i
, draw
->info
[i
].id
, client
, 0,
1835 xgi
.visual
= wVisual (((WindowPtr
) pDraw
));
1837 xgi
.sequenceNumber
= client
->sequence
;
1838 xgi
.depth
= pDraw
->depth
;
1839 if(format
== ZPixmap
) {
1840 widthBytesLine
= PixmapBytePad(w
, pDraw
->depth
);
1841 length
= widthBytesLine
* h
;
1845 widthBytesLine
= BitmapBytePad(w
);
1846 plane
= ((Mask
)1) << (pDraw
->depth
- 1);
1847 /* only planes asked for */
1848 length
= widthBytesLine
* h
*
1849 Ones(planemask
& (plane
| (plane
- 1)));
1853 xgi
.length
= (length
+ 3) >> 2;
1855 if (widthBytesLine
== 0 || h
== 0)
1857 else if (widthBytesLine
>= XINERAMA_IMAGE_BUFSIZE
)
1860 linesPerBuf
= XINERAMA_IMAGE_BUFSIZE
/ widthBytesLine
;
1861 if (linesPerBuf
> h
)
1864 length
= linesPerBuf
* widthBytesLine
;
1865 if(!(pBuf
= xalloc(length
)))
1868 WriteReplyToClient(client
, sizeof (xGetImageReply
), &xgi
);
1870 if (linesPerBuf
== 0) {
1873 else if (format
== ZPixmap
) {
1875 while (h
- linesDone
> 0) {
1876 nlines
= min(linesPerBuf
, h
- linesDone
);
1878 if(pDraw
->depth
== 1)
1879 bzero(pBuf
, nlines
* widthBytesLine
);
1881 XineramaGetImageData(drawables
, x
, y
+ linesDone
, w
, nlines
,
1882 format
, planemask
, pBuf
, widthBytesLine
, isRoot
);
1884 (void)WriteToClient(client
,
1885 (int)(nlines
* widthBytesLine
),
1887 linesDone
+= nlines
;
1889 } else { /* XYPixmap */
1890 for (; plane
; plane
>>= 1) {
1891 if (planemask
& plane
) {
1893 while (h
- linesDone
> 0) {
1894 nlines
= min(linesPerBuf
, h
- linesDone
);
1896 bzero(pBuf
, nlines
* widthBytesLine
);
1898 XineramaGetImageData(drawables
, x
, y
+ linesDone
, w
,
1899 nlines
, format
, plane
, pBuf
,
1900 widthBytesLine
, isRoot
);
1902 (void)WriteToClient(client
,
1903 (int)(nlines
* widthBytesLine
),
1906 linesDone
+= nlines
;
1912 return (client
->noClientException
);
1916 /* The text stuff should be rewritten so that duplication happens
1917 at the GlyphBlt level. That is, loading the font and getting
1918 the glyphs should only happen once */
1921 PanoramiXPolyText8(ClientPtr client
)
1923 PanoramiXRes
*gc
, *draw
;
1927 REQUEST(xPolyTextReq
);
1929 REQUEST_AT_LEAST_SIZE(xPolyTextReq
);
1931 if(!(draw
= (PanoramiXRes
*)SecurityLookupIDByClass(
1932 client
, stuff
->drawable
, XRC_DRAWABLE
, DixWriteAccess
)))
1935 if(IS_SHARED_PIXMAP(draw
))
1936 return (*SavedProcVector
[X_PolyText8
])(client
);
1938 if(!(gc
= (PanoramiXRes
*)SecurityLookupIDByType(
1939 client
, stuff
->gc
, XRT_GC
, DixReadAccess
)))
1942 isRoot
= (draw
->type
== XRT_WINDOW
) && draw
->u
.win
.root
;
1946 FOR_NSCREENS_BACKWARD(j
){
1947 stuff
->drawable
= draw
->info
[j
].id
;
1948 stuff
->gc
= gc
->info
[j
].id
;
1950 stuff
->x
= orig_x
- panoramiXdataPtr
[j
].x
;
1951 stuff
->y
= orig_y
- panoramiXdataPtr
[j
].y
;
1953 result
= (*SavedProcVector
[X_PolyText8
])(client
);
1954 if(result
!= Success
) break;
1960 PanoramiXPolyText16(ClientPtr client
)
1962 PanoramiXRes
*gc
, *draw
;
1966 REQUEST(xPolyTextReq
);
1968 REQUEST_AT_LEAST_SIZE(xPolyTextReq
);
1970 if(!(draw
= (PanoramiXRes
*)SecurityLookupIDByClass(
1971 client
, stuff
->drawable
, XRC_DRAWABLE
, DixWriteAccess
)))
1974 if(IS_SHARED_PIXMAP(draw
))
1975 return (*SavedProcVector
[X_PolyText16
])(client
);
1977 if(!(gc
= (PanoramiXRes
*)SecurityLookupIDByType(
1978 client
, stuff
->gc
, XRT_GC
, DixReadAccess
)))
1981 isRoot
= (draw
->type
== XRT_WINDOW
) && draw
->u
.win
.root
;
1985 FOR_NSCREENS_BACKWARD(j
){
1986 stuff
->drawable
= draw
->info
[j
].id
;
1987 stuff
->gc
= gc
->info
[j
].id
;
1989 stuff
->x
= orig_x
- panoramiXdataPtr
[j
].x
;
1990 stuff
->y
= orig_y
- panoramiXdataPtr
[j
].y
;
1992 result
= (*SavedProcVector
[X_PolyText16
])(client
);
1993 if(result
!= Success
) break;
1999 int PanoramiXImageText8(ClientPtr client
)
2002 PanoramiXRes
*gc
, *draw
;
2005 REQUEST(xImageTextReq
);
2007 REQUEST_FIXED_SIZE(xImageTextReq
, stuff
->nChars
);
2009 if(!(draw
= (PanoramiXRes
*)SecurityLookupIDByClass(
2010 client
, stuff
->drawable
, XRC_DRAWABLE
, DixWriteAccess
)))
2013 if(IS_SHARED_PIXMAP(draw
))
2014 return (*SavedProcVector
[X_ImageText8
])(client
);
2016 if(!(gc
= (PanoramiXRes
*)SecurityLookupIDByType(
2017 client
, stuff
->gc
, XRT_GC
, DixReadAccess
)))
2020 isRoot
= (draw
->type
== XRT_WINDOW
) && draw
->u
.win
.root
;
2024 FOR_NSCREENS_BACKWARD(j
){
2025 stuff
->drawable
= draw
->info
[j
].id
;
2026 stuff
->gc
= gc
->info
[j
].id
;
2028 stuff
->x
= orig_x
- panoramiXdataPtr
[j
].x
;
2029 stuff
->y
= orig_y
- panoramiXdataPtr
[j
].y
;
2031 result
= (*SavedProcVector
[X_ImageText8
])(client
);
2032 if(result
!= Success
) break;
2038 int PanoramiXImageText16(ClientPtr client
)
2041 PanoramiXRes
*gc
, *draw
;
2044 REQUEST(xImageTextReq
);
2046 REQUEST_FIXED_SIZE(xImageTextReq
, stuff
->nChars
<< 1);
2048 if(!(draw
= (PanoramiXRes
*)SecurityLookupIDByClass(
2049 client
, stuff
->drawable
, XRC_DRAWABLE
, DixWriteAccess
)))
2052 if(IS_SHARED_PIXMAP(draw
))
2053 return (*SavedProcVector
[X_ImageText16
])(client
);
2055 if(!(gc
= (PanoramiXRes
*)SecurityLookupIDByType(
2056 client
, stuff
->gc
, XRT_GC
, DixReadAccess
)))
2059 isRoot
= (draw
->type
== XRT_WINDOW
) && draw
->u
.win
.root
;
2063 FOR_NSCREENS_BACKWARD(j
){
2064 stuff
->drawable
= draw
->info
[j
].id
;
2065 stuff
->gc
= gc
->info
[j
].id
;
2067 stuff
->x
= orig_x
- panoramiXdataPtr
[j
].x
;
2068 stuff
->y
= orig_y
- panoramiXdataPtr
[j
].y
;
2070 result
= (*SavedProcVector
[X_ImageText16
])(client
);
2071 if(result
!= Success
) break;
2078 int PanoramiXCreateColormap(ClientPtr client
)
2080 PanoramiXRes
*win
, *newCmap
;
2081 int result
= 0, j
, orig_visual
;
2082 REQUEST(xCreateColormapReq
);
2084 REQUEST_SIZE_MATCH(xCreateColormapReq
);
2086 if(!(win
= (PanoramiXRes
*)SecurityLookupIDByType(
2087 client
, stuff
->window
, XRT_WINDOW
, DixReadAccess
)))
2090 if(!stuff
->visual
|| (stuff
->visual
> 255))
2093 if(!(newCmap
= (PanoramiXRes
*) xalloc(sizeof(PanoramiXRes
))))
2096 newCmap
->type
= XRT_COLORMAP
;
2097 newCmap
->info
[0].id
= stuff
->mid
;
2098 for(j
= 1; j
< PanoramiXNumScreens
; j
++)
2099 newCmap
->info
[j
].id
= FakeClientID(client
->index
);
2101 orig_visual
= stuff
->visual
;
2102 FOR_NSCREENS_BACKWARD(j
){
2103 stuff
->mid
= newCmap
->info
[j
].id
;
2104 stuff
->window
= win
->info
[j
].id
;
2105 stuff
->visual
= PanoramiXVisualTable
[(orig_visual
* MAXSCREENS
) + j
];
2106 result
= (* SavedProcVector
[X_CreateColormap
])(client
);
2107 if(result
!= Success
) break;
2110 if (result
== Success
)
2111 AddResource(newCmap
->info
[0].id
, XRT_COLORMAP
, newCmap
);
2119 int PanoramiXFreeColormap(ClientPtr client
)
2123 REQUEST(xResourceReq
);
2125 REQUEST_SIZE_MATCH(xResourceReq
);
2127 client
->errorValue
= stuff
->id
;
2129 if(!(cmap
= (PanoramiXRes
*)SecurityLookupIDByType(
2130 client
, stuff
->id
, XRT_COLORMAP
, DixDestroyAccess
)))
2133 FOR_NSCREENS_BACKWARD(j
) {
2134 stuff
->id
= cmap
->info
[j
].id
;
2135 result
= (* SavedProcVector
[X_FreeColormap
])(client
);
2136 if(result
!= Success
) break;
2139 /* Since ProcFreeColormap is using FreeResource, it will free
2140 our resource for us on the last pass through the loop above */
2147 PanoramiXCopyColormapAndFree(ClientPtr client
)
2149 PanoramiXRes
*cmap
, *newCmap
;
2151 REQUEST(xCopyColormapAndFreeReq
);
2153 REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq
);
2155 client
->errorValue
= stuff
->srcCmap
;
2157 if(!(cmap
= (PanoramiXRes
*)SecurityLookupIDByType(
2158 client
, stuff
->srcCmap
, XRT_COLORMAP
,
2159 DixReadAccess
| DixWriteAccess
)))
2162 if(!(newCmap
= (PanoramiXRes
*) xalloc(sizeof(PanoramiXRes
))))
2165 newCmap
->type
= XRT_COLORMAP
;
2166 newCmap
->info
[0].id
= stuff
->mid
;
2167 for(j
= 1; j
< PanoramiXNumScreens
; j
++)
2168 newCmap
->info
[j
].id
= FakeClientID(client
->index
);
2170 FOR_NSCREENS_BACKWARD(j
){
2171 stuff
->srcCmap
= cmap
->info
[j
].id
;
2172 stuff
->mid
= newCmap
->info
[j
].id
;
2173 result
= (* SavedProcVector
[X_CopyColormapAndFree
])(client
);
2174 if(result
!= Success
) break;
2177 if (result
== Success
)
2178 AddResource(newCmap
->info
[0].id
, XRT_COLORMAP
, newCmap
);
2186 int PanoramiXInstallColormap(ClientPtr client
)
2188 REQUEST(xResourceReq
);
2192 REQUEST_SIZE_MATCH(xResourceReq
);
2194 client
->errorValue
= stuff
->id
;
2196 if(!(cmap
= (PanoramiXRes
*)SecurityLookupIDByType(
2197 client
, stuff
->id
, XRT_COLORMAP
, DixReadAccess
)))
2200 FOR_NSCREENS_BACKWARD(j
){
2201 stuff
->id
= cmap
->info
[j
].id
;
2202 result
= (* SavedProcVector
[X_InstallColormap
])(client
);
2203 if(result
!= Success
) break;
2209 int PanoramiXUninstallColormap(ClientPtr client
)
2211 REQUEST(xResourceReq
);
2215 REQUEST_SIZE_MATCH(xResourceReq
);
2217 client
->errorValue
= stuff
->id
;
2219 if(!(cmap
= (PanoramiXRes
*)SecurityLookupIDByType(
2220 client
, stuff
->id
, XRT_COLORMAP
, DixReadAccess
)))
2223 FOR_NSCREENS_BACKWARD(j
) {
2224 stuff
->id
= cmap
->info
[j
].id
;
2225 result
= (* SavedProcVector
[X_UninstallColormap
])(client
);
2226 if(result
!= Success
) break;
2232 int PanoramiXAllocColor(ClientPtr client
)
2236 REQUEST(xAllocColorReq
);
2238 REQUEST_SIZE_MATCH(xAllocColorReq
);
2240 client
->errorValue
= stuff
->cmap
;
2242 if(!(cmap
= (PanoramiXRes
*)SecurityLookupIDByType(
2243 client
, stuff
->cmap
, XRT_COLORMAP
, DixWriteAccess
)))
2246 FOR_NSCREENS_BACKWARD(j
){
2247 stuff
->cmap
= cmap
->info
[j
].id
;
2248 result
= (* SavedProcVector
[X_AllocColor
])(client
);
2249 if(result
!= Success
) break;
2255 int PanoramiXAllocNamedColor(ClientPtr client
)
2259 REQUEST(xAllocNamedColorReq
);
2261 REQUEST_FIXED_SIZE(xAllocNamedColorReq
, stuff
->nbytes
);
2263 client
->errorValue
= stuff
->cmap
;
2265 if(!(cmap
= (PanoramiXRes
*)SecurityLookupIDByType(
2266 client
, stuff
->cmap
, XRT_COLORMAP
, DixWriteAccess
)))
2269 FOR_NSCREENS_BACKWARD(j
){
2270 stuff
->cmap
= cmap
->info
[j
].id
;
2271 result
= (* SavedProcVector
[X_AllocNamedColor
])(client
);
2272 if(result
!= Success
) break;
2278 int PanoramiXAllocColorCells(ClientPtr client
)
2282 REQUEST(xAllocColorCellsReq
);
2284 REQUEST_SIZE_MATCH(xAllocColorCellsReq
);
2286 client
->errorValue
= stuff
->cmap
;
2288 if(!(cmap
= (PanoramiXRes
*)SecurityLookupIDByType(
2289 client
, stuff
->cmap
, XRT_COLORMAP
, DixWriteAccess
)))
2292 FOR_NSCREENS_BACKWARD(j
){
2293 stuff
->cmap
= cmap
->info
[j
].id
;
2294 result
= (* SavedProcVector
[X_AllocColorCells
])(client
);
2295 if(result
!= Success
) break;
2301 int PanoramiXAllocColorPlanes(ClientPtr client
)
2305 REQUEST(xAllocColorPlanesReq
);
2307 REQUEST_SIZE_MATCH(xAllocColorPlanesReq
);
2309 client
->errorValue
= stuff
->cmap
;
2311 if(!(cmap
= (PanoramiXRes
*)SecurityLookupIDByType(
2312 client
, stuff
->cmap
, XRT_COLORMAP
, DixWriteAccess
)))
2315 FOR_NSCREENS_BACKWARD(j
){
2316 stuff
->cmap
= cmap
->info
[j
].id
;
2317 result
= (* SavedProcVector
[X_AllocColorPlanes
])(client
);
2318 if(result
!= Success
) break;
2325 int PanoramiXFreeColors(ClientPtr client
)
2329 REQUEST(xFreeColorsReq
);
2331 REQUEST_AT_LEAST_SIZE(xFreeColorsReq
);
2333 client
->errorValue
= stuff
->cmap
;
2335 if(!(cmap
= (PanoramiXRes
*)SecurityLookupIDByType(
2336 client
, stuff
->cmap
, XRT_COLORMAP
, DixWriteAccess
)))
2339 FOR_NSCREENS_BACKWARD(j
) {
2340 stuff
->cmap
= cmap
->info
[j
].id
;
2341 result
= (* SavedProcVector
[X_FreeColors
])(client
);
2347 int PanoramiXStoreColors(ClientPtr client
)
2351 REQUEST(xStoreColorsReq
);
2353 REQUEST_AT_LEAST_SIZE(xStoreColorsReq
);
2355 client
->errorValue
= stuff
->cmap
;
2357 if(!(cmap
= (PanoramiXRes
*)SecurityLookupIDByType(
2358 client
, stuff
->cmap
, XRT_COLORMAP
, DixWriteAccess
)))
2361 FOR_NSCREENS_BACKWARD(j
){
2362 stuff
->cmap
= cmap
->info
[j
].id
;
2363 result
= (* SavedProcVector
[X_StoreColors
])(client
);
2364 if(result
!= Success
) break;
2370 int PanoramiXStoreNamedColor(ClientPtr client
)
2374 REQUEST(xStoreNamedColorReq
);
2376 REQUEST_FIXED_SIZE(xStoreNamedColorReq
, stuff
->nbytes
);
2378 client
->errorValue
= stuff
->cmap
;
2380 if(!(cmap
= (PanoramiXRes
*)SecurityLookupIDByType(
2381 client
, stuff
->cmap
, XRT_COLORMAP
, DixWriteAccess
)))
2384 FOR_NSCREENS_BACKWARD(j
){
2385 stuff
->cmap
= cmap
->info
[j
].id
;
2386 result
= (* SavedProcVector
[X_StoreNamedColor
])(client
);
2387 if(result
!= Success
) break;