First import
[xorg_rtime.git] / xorg-server-1.4 / Xext / panoramiXprocs.c
blob1c53a1e1aee1fde98f36bc7ed2af29a57442f259
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>
31 #endif
33 #include <stdio.h>
34 #include <X11/X.h>
35 #define NEED_REPLIES
36 #define NEED_EVENTS
37 #include <X11/Xproto.h>
38 #include "windowstr.h"
39 #include "dixfontstr.h"
40 #include "gcstruct.h"
41 #include "colormapst.h"
42 #include "scrnintstr.h"
43 #include "opaque.h"
44 #include "inputstr.h"
45 #include "migc.h"
46 #include "misc.h"
47 #include "dixstruct.h"
48 #include "panoramiX.h"
49 #include "panoramiXsrv.h"
50 #include "resource.h"
51 #include "panoramiXh.h"
53 #define XINERAMA_IMAGE_BUFSIZE (256*1024)
54 #define INPUTONLY_LEGAL_MASK (CWWinGravity | CWEventMask | \
55 CWDontPropagate | CWOverrideRedirect | CWCursor )
57 #if 0
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();
65 #endif
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;
83 int orig_x, orig_y;
84 XID orig_visual, tmp;
85 Bool parentIsRoot;
87 REQUEST_AT_LEAST_SIZE(xCreateWindowReq);
89 len = client->req_len - (sizeof(xCreateWindowReq) >> 2);
90 if (Ones(stuff->mask) != len)
91 return BadLength;
93 if (!(parent = (PanoramiXRes *)SecurityLookupIDByType(
94 client, stuff->parent, XRT_WINDOW, DixWriteAccess)))
95 return BadWindow;
97 if(stuff->class == CopyFromParent)
98 stuff->class = parent->u.win.class;
100 if((stuff->class == InputOnly) && (stuff->mask & (~INPUTONLY_LEGAL_MASK)))
101 return BadMatch;
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)))
109 return BadPixmap;
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)))
118 return BadPixmap;
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)))
127 return BadColor;
131 if(!(newWin = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes))))
132 return BadAlloc;
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;
145 orig_x = stuff->x;
146 orig_y = stuff->y;
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;
152 if (parentIsRoot) {
153 stuff->x = orig_x - panoramiXdataPtr[j].x;
154 stuff->y = orig_y - panoramiXdataPtr[j].y;
156 if (backPix)
157 *((CARD32 *) &stuff[1] + pback_offset) = backPix->info[j].id;
158 if (bordPix)
159 *((CARD32 *) &stuff[1] + pbord_offset) = bordPix->info[j].id;
160 if (cmap)
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);
170 else
171 xfree(newWin);
173 return (result);
177 int PanoramiXChangeWindowAttributes(ClientPtr client)
179 PanoramiXRes *win;
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;
186 XID tmp;
188 REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq);
190 len = client->req_len - (sizeof(xChangeWindowAttributesReq) >> 2);
191 if (Ones(stuff->valueMask) != len)
192 return BadLength;
194 if (!(win = (PanoramiXRes *)SecurityLookupIDByType(
195 client, stuff->window, XRT_WINDOW, DixWriteAccess)))
196 return BadWindow;
198 if((win->u.win.class == InputOnly) &&
199 (stuff->valueMask & (~INPUTONLY_LEGAL_MASK)))
200 return BadMatch;
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)))
208 return BadPixmap;
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)))
217 return BadPixmap;
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)))
226 return BadColor;
230 FOR_NSCREENS_BACKWARD(j) {
231 stuff->window = win->info[j].id;
232 if (backPix)
233 *((CARD32 *) &stuff[1] + pback_offset) = backPix->info[j].id;
234 if (bordPix)
235 *((CARD32 *) &stuff[1] + pbord_offset) = bordPix->info[j].id;
236 if (cmap)
237 *((CARD32 *) &stuff[1] + cmap_offset) = cmap->info[j].id;
238 result = (*SavedProcVector[X_ChangeWindowAttributes])(client);
241 return (result);
245 int PanoramiXDestroyWindow(ClientPtr client)
247 PanoramiXRes *win;
248 int result = 0, j;
249 REQUEST(xResourceReq);
251 REQUEST_SIZE_MATCH(xResourceReq);
253 if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
254 client, stuff->id, XRT_WINDOW, DixDestroyAccess)))
255 return BadWindow;
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 */
266 return (result);
270 int PanoramiXDestroySubwindows(ClientPtr client)
272 PanoramiXRes *win;
273 int result = 0, j;
274 REQUEST(xResourceReq);
276 REQUEST_SIZE_MATCH(xResourceReq);
278 if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
279 client, stuff->id, XRT_WINDOW, DixDestroyAccess)))
280 return BadWindow;
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 */
291 return (result);
295 int PanoramiXChangeSaveSet(ClientPtr client)
297 PanoramiXRes *win;
298 int result = 0, j;
299 REQUEST(xChangeSaveSetReq);
301 REQUEST_SIZE_MATCH(xChangeSaveSetReq);
303 if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
304 client, stuff->window, XRT_WINDOW, DixReadAccess)))
305 return BadWindow;
307 FOR_NSCREENS_BACKWARD(j) {
308 stuff->window = win->info[j].id;
309 result = (*SavedProcVector[X_ChangeSaveSet])(client);
310 if(result != Success) break;
313 return (result);
317 int PanoramiXReparentWindow(ClientPtr client)
319 PanoramiXRes *win, *parent;
320 int result = 0, j;
321 int x, y;
322 Bool parentIsRoot;
323 REQUEST(xReparentWindowReq);
325 REQUEST_SIZE_MATCH(xReparentWindowReq);
327 if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
328 client, stuff->window, XRT_WINDOW, DixWriteAccess)))
329 return BadWindow;
331 if(!(parent = (PanoramiXRes *)SecurityLookupIDByType(
332 client, stuff->parent, XRT_WINDOW, DixWriteAccess)))
333 return BadWindow;
335 x = stuff->x;
336 y = stuff->y;
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;
342 if(parentIsRoot) {
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;
350 return (result);
354 int PanoramiXMapWindow(ClientPtr client)
356 PanoramiXRes *win;
357 int result = 0, j;
358 REQUEST(xResourceReq);
360 REQUEST_SIZE_MATCH(xResourceReq);
362 if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
363 client, stuff->id, XRT_WINDOW, DixReadAccess)))
364 return BadWindow;
366 FOR_NSCREENS_FORWARD(j) {
367 stuff->id = win->info[j].id;
368 result = (*SavedProcVector[X_MapWindow])(client);
369 if(result != Success) break;
372 return (result);
376 int PanoramiXMapSubwindows(ClientPtr client)
378 PanoramiXRes *win;
379 int result = 0, j;
380 REQUEST(xResourceReq);
382 REQUEST_SIZE_MATCH(xResourceReq);
384 if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
385 client, stuff->id, XRT_WINDOW, DixReadAccess)))
386 return BadWindow;
388 FOR_NSCREENS_FORWARD(j) {
389 stuff->id = win->info[j].id;
390 result = (*SavedProcVector[X_MapSubwindows])(client);
391 if(result != Success) break;
394 return (result);
398 int PanoramiXUnmapWindow(ClientPtr client)
400 PanoramiXRes *win;
401 int result = 0, j;
402 REQUEST(xResourceReq);
404 REQUEST_SIZE_MATCH(xResourceReq);
406 if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
407 client, stuff->id, XRT_WINDOW, DixReadAccess)))
408 return BadWindow;
410 FOR_NSCREENS_FORWARD(j) {
411 stuff->id = win->info[j].id;
412 result = (*SavedProcVector[X_UnmapWindow])(client);
413 if(result != Success) break;
416 return (result);
420 int PanoramiXUnmapSubwindows(ClientPtr client)
422 PanoramiXRes *win;
423 int result = 0, j;
424 REQUEST(xResourceReq);
426 REQUEST_SIZE_MATCH(xResourceReq);
428 if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
429 client, stuff->id, XRT_WINDOW, DixReadAccess)))
430 return BadWindow;
432 FOR_NSCREENS_FORWARD(j) {
433 stuff->id = win->info[j].id;
434 result = (*SavedProcVector[X_UnmapSubwindows])(client);
435 if(result != Success) break;
438 return (result);
442 int PanoramiXConfigureWindow(ClientPtr client)
444 PanoramiXRes *win;
445 PanoramiXRes *sib = NULL;
446 WindowPtr pWin;
447 int result = 0, j, len, sib_offset = 0, x = 0, y = 0;
448 int x_offset = -1;
449 int y_offset = -1;
450 REQUEST(xConfigureWindowReq);
452 REQUEST_AT_LEAST_SIZE(xConfigureWindowReq);
454 len = client->req_len - (sizeof(xConfigureWindowReq) >> 2);
455 if (Ones(stuff->mask) != len)
456 return BadLength;
458 /* because we need the parent */
459 if (!(pWin = (WindowPtr)SecurityLookupIDByType(
460 client, stuff->window, RT_WINDOW, DixWriteAccess)))
461 return BadWindow;
463 if (!(win = (PanoramiXRes *)SecurityLookupIDByType(
464 client, stuff->window, XRT_WINDOW, DixWriteAccess)))
465 return BadWindow;
467 if ((Mask)stuff->mask & CWSibling) {
468 XID tmp;
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)))
473 return BadWindow;
477 if(pWin->parent && ((pWin->parent == WindowTable[0]) ||
478 (pWin->parent->drawable.id == savedScreenInfo[0].wid)))
480 if ((Mask)stuff->mask & CWX) {
481 x_offset = 0;
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;
494 if(sib)
495 *((CARD32 *) &stuff[1] + sib_offset) = sib->info[j].id;
496 if(x_offset >= 0)
497 *((CARD32 *) &stuff[1] + x_offset) = x - panoramiXdataPtr[j].x;
498 if(y_offset >= 0)
499 *((CARD32 *) &stuff[1] + y_offset) = y - panoramiXdataPtr[j].y;
500 result = (*SavedProcVector[X_ConfigureWindow])(client);
501 if(result != Success) break;
504 return (result);
508 int PanoramiXCirculateWindow(ClientPtr client)
510 PanoramiXRes *win;
511 int result = 0, j;
512 REQUEST(xCirculateWindowReq);
514 REQUEST_SIZE_MATCH(xCirculateWindowReq);
516 if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
517 client, stuff->window, XRT_WINDOW, DixWriteAccess)))
518 return BadWindow;
520 FOR_NSCREENS_FORWARD(j) {
521 stuff->window = win->info[j].id;
522 result = (*SavedProcVector[X_CirculateWindow])(client);
523 if(result != Success) break;
526 return (result);
530 int PanoramiXGetGeometry(ClientPtr client)
532 xGetGeometryReply rep;
533 DrawablePtr pDraw;
534 int rc;
535 REQUEST(xResourceReq);
537 REQUEST_SIZE_MATCH(xResourceReq);
538 rc = dixLookupDrawable(&pDraw, stuff->id, client, M_ANY, DixUnknownAccess);
539 if (rc != Success)
540 return rc;
542 rep.type = X_Reply;
543 rep.length = 0;
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;
557 } else
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)
578 INT16 x, y;
579 REQUEST(xTranslateCoordsReq);
580 int rc;
581 WindowPtr pWin, pDst;
582 xTranslateCoordsReply rep;
584 REQUEST_SIZE_MATCH(xTranslateCoordsReq);
585 rc = dixLookupWindow(&pWin, stuff->srcWid, client, DixReadAccess);
586 if (rc != Success)
587 return rc;
588 rc = dixLookupWindow(&pDst, stuff->dstWid, client, DixReadAccess);
589 if (rc != Success)
590 return rc;
591 rep.type = X_Reply;
592 rep.length = 0;
593 rep.sequenceNumber = client->sequence;
594 rep.sameScreen = xTrue;
595 rep.child = None;
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;
602 } else {
603 x = pWin->drawable.x + stuff->srcX;
604 y = pWin->drawable.y + stuff->srcY;
606 pWin = pDst->firstChild;
607 while (pWin) {
608 #ifdef SHAPE
609 BoxRec box;
610 #endif
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 +
617 wBorderWidth (pWin))
618 #ifdef SHAPE
619 /* When a window is shaped, a further check
620 * is made to see if the point is inside
621 * borderSize
623 && (!wBoundingShape(pWin) ||
624 POINT_IN_REGION(pWin->drawable.pScreen,
625 wBoundingShape(pWin),
626 x - pWin->drawable.x,
627 y - pWin->drawable.y, &box))
628 #endif
631 rep.child = pWin->drawable.id;
632 pWin = (WindowPtr) NULL;
634 else
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;
653 int result = 0, j;
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)))
661 return BadDrawable;
663 if(!(newPix = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes))))
664 return BadAlloc;
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);
681 else
682 xfree(newPix);
684 return (result);
688 int PanoramiXFreePixmap(ClientPtr client)
690 PanoramiXRes *pix;
691 int result = 0, j;
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)))
700 return BadPixmap;
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 */
711 return (result);
715 int PanoramiXCreateGC(ClientPtr client)
717 PanoramiXRes *refDraw;
718 PanoramiXRes *newGC;
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;
725 XID tmp;
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)
732 return BadLength;
734 if (!(refDraw = (PanoramiXRes *)SecurityLookupIDByClass(
735 client, stuff->drawable, XRC_DRAWABLE, DixReadAccess)))
736 return BadDrawable;
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)))
743 return BadPixmap;
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)))
751 return BadPixmap;
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)))
759 return BadPixmap;
763 if(!(newGC = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes))))
764 return BadAlloc;
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;
774 if (tile)
775 *((CARD32 *) &stuff[1] + tile_offset) = tile->info[j].id;
776 if (stip)
777 *((CARD32 *) &stuff[1] + stip_offset) = stip->info[j].id;
778 if (clip)
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);
786 else
787 xfree(newGC);
789 return (result);
792 int PanoramiXChangeGC(ClientPtr client)
794 PanoramiXRes *gc;
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;
801 XID tmp;
803 REQUEST_AT_LEAST_SIZE(xChangeGCReq);
805 len = client->req_len - (sizeof(xChangeGCReq) >> 2);
806 if (Ones(stuff->mask) != len)
807 return BadLength;
809 if (!(gc = (PanoramiXRes *)SecurityLookupIDByType(
810 client, stuff->gc, XRT_GC, DixReadAccess)))
811 return BadGC;
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)))
818 return BadPixmap;
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)))
826 return BadPixmap;
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)))
834 return BadPixmap;
839 FOR_NSCREENS_BACKWARD(j) {
840 stuff->gc = gc->info[j].id;
841 if (tile)
842 *((CARD32 *) &stuff[1] + tile_offset) = tile->info[j].id;
843 if (stip)
844 *((CARD32 *) &stuff[1] + stip_offset) = stip->info[j].id;
845 if (clip)
846 *((CARD32 *) &stuff[1] + clip_offset) = clip->info[j].id;
847 result = (*SavedProcVector[X_ChangeGC])(client);
848 if(result != Success) break;
851 return (result);
855 int PanoramiXCopyGC(ClientPtr client)
857 PanoramiXRes *srcGC, *dstGC;
858 int result = 0, j;
859 REQUEST(xCopyGCReq);
861 REQUEST_SIZE_MATCH(xCopyGCReq);
863 if(!(srcGC = (PanoramiXRes *)SecurityLookupIDByType(
864 client, stuff->srcGC, XRT_GC, DixReadAccess)))
865 return BadGC;
867 if(!(dstGC = (PanoramiXRes *)SecurityLookupIDByType(
868 client, stuff->dstGC, XRT_GC, DixWriteAccess)))
869 return BadGC;
871 FOR_NSCREENS(j) {
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;
878 return (result);
882 int PanoramiXSetDashes(ClientPtr client)
884 PanoramiXRes *gc;
885 int result = 0, j;
886 REQUEST(xSetDashesReq);
888 REQUEST_FIXED_SIZE(xSetDashesReq, stuff->nDashes);
890 if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
891 client, stuff->gc, XRT_GC, DixWriteAccess)))
892 return BadGC;
894 FOR_NSCREENS_BACKWARD(j) {
895 stuff->gc = gc->info[j].id;
896 result = (*SavedProcVector[X_SetDashes])(client);
897 if(result != Success) break;
900 return (result);
904 int PanoramiXSetClipRectangles(ClientPtr client)
906 PanoramiXRes *gc;
907 int result = 0, j;
908 REQUEST(xSetClipRectanglesReq);
910 REQUEST_AT_LEAST_SIZE(xSetClipRectanglesReq);
912 if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
913 client, stuff->gc, XRT_GC, DixWriteAccess)))
914 return BadGC;
916 FOR_NSCREENS_BACKWARD(j) {
917 stuff->gc = gc->info[j].id;
918 result = (*SavedProcVector[X_SetClipRectangles])(client);
919 if(result != Success) break;
922 return (result);
926 int PanoramiXFreeGC(ClientPtr client)
928 PanoramiXRes *gc;
929 int result = 0, j;
930 REQUEST(xResourceReq);
932 REQUEST_SIZE_MATCH(xResourceReq);
934 if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
935 client, stuff->id, XRT_GC, DixDestroyAccess)))
936 return BadGC;
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 */
947 return (result);
951 int PanoramiXClearToBackground(ClientPtr client)
953 PanoramiXRes *win;
954 int result = 0, j, x, y;
955 Bool isRoot;
956 REQUEST(xClearAreaReq);
958 REQUEST_SIZE_MATCH(xClearAreaReq);
960 if(!(win = (PanoramiXRes *)SecurityLookupIDByType(
961 client, stuff->window, XRT_WINDOW, DixWriteAccess)))
962 return BadWindow;
964 x = stuff->x;
965 y = stuff->y;
966 isRoot = win->u.win.root;
967 FOR_NSCREENS_BACKWARD(j) {
968 stuff->window = win->info[j].id;
969 if(isRoot) {
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;
977 return (result);
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)))
1004 return BadDrawable;
1006 srcShared = IS_SHARED_PIXMAP(src);
1008 if(!(dst = (PanoramiXRes *)SecurityLookupIDByClass(
1009 client, stuff->dstDrawable, XRC_DRAWABLE, DixWriteAccess)))
1010 return BadDrawable;
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)))
1019 return BadGC;
1021 if((dst->type == XRT_WINDOW) && dst->u.win.root)
1022 dstIsRoot = TRUE;
1023 if((src->type == XRT_WINDOW) && src->u.win.root)
1024 srcIsRoot = TRUE;
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];
1030 DrawablePtr pDst;
1031 GCPtr pGC;
1032 char *data;
1033 int pitch, rc;
1035 FOR_NSCREENS(j) {
1036 rc = dixLookupDrawable(drawables+j, src->info[j].id, client, 0,
1037 DixUnknownAccess);
1038 if (rc != Success)
1039 return rc;
1042 pitch = PixmapBytePad(stuff->width, drawables[0]->depth);
1043 if(!(data = xcalloc(1, stuff->height * pitch)))
1044 return BadAlloc;
1046 XineramaGetImageData(drawables, srcx, srcy,
1047 stuff->width, stuff->height, ZPixmap, ~0, data, pitch,
1048 srcIsRoot);
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;
1056 xfree(data);
1057 return (BadMatch);
1060 (*pGC->ops->PutImage) (pDst, pGC, pDst->depth, dstx, dsty,
1061 stuff->width, stuff->height,
1062 0, ZPixmap, data);
1064 if(dstShared) break;
1067 xfree(data);
1069 result = Success;
1070 } else {
1071 DrawablePtr pDst = NULL, pSrc = NULL;
1072 GCPtr pGC = NULL;
1073 RegionPtr pRgn[MAXSCREENS];
1074 int rc;
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;
1080 if (srcIsRoot) {
1081 stuff->srcX = srcx - panoramiXdataPtr[j].x;
1082 stuff->srcY = srcy - panoramiXdataPtr[j].y;
1084 if (dstIsRoot) {
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,
1092 DixReadAccess);
1093 if (rc != Success)
1094 return rc;
1096 if ((pDst->pScreen != pSrc->pScreen) ||
1097 (pDst->depth != pSrc->depth)) {
1098 client->errorValue = stuff->dstDrawable;
1099 return (BadMatch);
1101 } else
1102 pSrc = pDst;
1104 pRgn[j] = (*pGC->ops->CopyArea)(pSrc, pDst, pGC,
1105 stuff->srcX, stuff->srcY,
1106 stuff->width, stuff->height,
1107 stuff->dstX, stuff->dstY);
1109 if(dstShared) {
1110 while(j--) pRgn[j] = NULL;
1111 break;
1115 if(pGC->graphicsExposures) {
1116 ScreenPtr pScreen = pDst->pScreen;
1117 RegionRec totalReg;
1118 Bool overlap;
1120 REGION_NULL(pScreen, &totalReg);
1121 FOR_NSCREENS_BACKWARD(j) {
1122 if(pRgn[j]) {
1123 if(srcIsRoot) {
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;
1140 return (result);
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;
1152 GCPtr pGC = 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)))
1160 return BadDrawable;
1162 srcShared = IS_SHARED_PIXMAP(src);
1164 if(!(dst = (PanoramiXRes *)SecurityLookupIDByClass(
1165 client, stuff->dstDrawable, XRC_DRAWABLE, DixWriteAccess)))
1166 return BadDrawable;
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)))
1175 return BadGC;
1177 if((dst->type == XRT_WINDOW) && dst->u.win.root)
1178 dstIsRoot = TRUE;
1179 if((src->type == XRT_WINDOW) && src->u.win.root)
1180 srcIsRoot = TRUE;
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;
1189 if (srcIsRoot) {
1190 stuff->srcX = srcx - panoramiXdataPtr[j].x;
1191 stuff->srcY = srcy - panoramiXdataPtr[j].y;
1193 if (dstIsRoot) {
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,
1201 DixReadAccess);
1202 if (rc != Success)
1203 return rc;
1205 if (pdstDraw->pScreen != psrcDraw->pScreen) {
1206 client->errorValue = stuff->dstDrawable;
1207 return (BadMatch);
1209 } else
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;
1215 return(BadValue);
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);
1223 if(dstShared) {
1224 while(j--) pRgn[j] = NULL;
1225 break;
1229 if(pGC->graphicsExposures) {
1230 ScreenPtr pScreen = pdstDraw->pScreen;
1231 RegionRec totalReg;
1232 Bool overlap;
1234 REGION_NULL(pScreen, &totalReg);
1235 FOR_NSCREENS_BACKWARD(j) {
1236 if(pRgn[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;
1255 xPoint *origPts;
1256 Bool isRoot;
1257 REQUEST(xPolyPointReq);
1259 REQUEST_AT_LEAST_SIZE(xPolyPointReq);
1261 if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
1262 client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
1263 return BadDrawable;
1265 if(IS_SHARED_PIXMAP(draw))
1266 return (*SavedProcVector[X_PolyPoint])(client);
1268 if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
1269 client, stuff->gc, XRT_GC, DixReadAccess)))
1270 return BadGC;
1272 isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
1273 npoint = ((client->req_len << 2) - sizeof(xPolyPointReq)) >> 2;
1274 if (npoint > 0) {
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));
1281 if (isRoot) {
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;
1289 while(i--) {
1290 pnts->x -= x_off;
1291 pnts->y -= y_off;
1292 pnts++;
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);
1303 return (result);
1304 } else
1305 return (client->noClientException);
1309 int PanoramiXPolyLine(ClientPtr client)
1311 PanoramiXRes *gc, *draw;
1312 int result = 0, npoint, j;
1313 xPoint *origPts;
1314 Bool isRoot;
1315 REQUEST(xPolyLineReq);
1317 REQUEST_AT_LEAST_SIZE(xPolyLineReq);
1319 if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
1320 client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
1321 return BadDrawable;
1323 if(IS_SHARED_PIXMAP(draw))
1324 return (*SavedProcVector[X_PolyLine])(client);
1326 if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
1327 client, stuff->gc, XRT_GC, DixReadAccess)))
1328 return BadGC;
1330 isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
1331 npoint = ((client->req_len << 2) - sizeof(xPolyLineReq)) >> 2;
1332 if (npoint > 0){
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));
1339 if (isRoot) {
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;
1347 while(i--) {
1348 pnts->x -= x_off;
1349 pnts->y -= y_off;
1350 pnts++;
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);
1361 return (result);
1362 } else
1363 return (client->noClientException);
1367 int PanoramiXPolySegment(ClientPtr client)
1369 int result = 0, nsegs, i, j;
1370 PanoramiXRes *gc, *draw;
1371 xSegment *origSegs;
1372 Bool isRoot;
1373 REQUEST(xPolySegmentReq);
1375 REQUEST_AT_LEAST_SIZE(xPolySegmentReq);
1377 if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
1378 client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
1379 return BadDrawable;
1381 if(IS_SHARED_PIXMAP(draw))
1382 return (*SavedProcVector[X_PolySegment])(client);
1384 if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
1385 client, stuff->gc, XRT_GC, DixReadAccess)))
1386 return BadGC;
1388 isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
1390 nsegs = (client->req_len << 2) - sizeof(xPolySegmentReq);
1391 if(nsegs & 4) return BadLength;
1392 nsegs >>= 3;
1393 if (nsegs > 0) {
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));
1400 if (isRoot) {
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++) {
1408 segs->x1 -= x_off;
1409 segs->x2 -= x_off;
1410 segs->y1 -= y_off;
1411 segs->y2 -= y_off;
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);
1422 return (result);
1423 } else
1424 return (client->noClientException);
1428 int PanoramiXPolyRectangle(ClientPtr client)
1430 int result = 0, nrects, i, j;
1431 PanoramiXRes *gc, *draw;
1432 Bool isRoot;
1433 xRectangle *origRecs;
1434 REQUEST(xPolyRectangleReq);
1436 REQUEST_AT_LEAST_SIZE(xPolyRectangleReq);
1439 if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
1440 client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
1441 return BadDrawable;
1443 if(IS_SHARED_PIXMAP(draw))
1444 return (*SavedProcVector[X_PolyRectangle])(client);
1446 if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
1447 client, stuff->gc, XRT_GC, DixReadAccess)))
1448 return BadGC;
1450 isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
1452 nrects = (client->req_len << 2) - sizeof(xPolyRectangleReq);
1453 if(nrects & 4) return BadLength;
1454 nrects >>= 3;
1455 if (nrects > 0){
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));
1462 if (isRoot) {
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++) {
1471 rects->x -= x_off;
1472 rects->y -= y_off;
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);
1483 return (result);
1484 } else
1485 return (client->noClientException);
1489 int PanoramiXPolyArc(ClientPtr client)
1491 int result = 0, narcs, i, j;
1492 PanoramiXRes *gc, *draw;
1493 Bool isRoot;
1494 xArc *origArcs;
1495 REQUEST(xPolyArcReq);
1497 REQUEST_AT_LEAST_SIZE(xPolyArcReq);
1499 if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
1500 client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
1501 return BadDrawable;
1503 if(IS_SHARED_PIXMAP(draw))
1504 return (*SavedProcVector[X_PolyArc])(client);
1506 if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
1507 client, stuff->gc, XRT_GC, DixReadAccess)))
1508 return BadGC;
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);
1515 if (narcs > 0){
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));
1522 if (isRoot) {
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++) {
1530 arcs->x -= x_off;
1531 arcs->y -= y_off;
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);
1541 return (result);
1542 } else
1543 return (client->noClientException);
1547 int PanoramiXFillPoly(ClientPtr client)
1549 int result = 0, count, j;
1550 PanoramiXRes *gc, *draw;
1551 Bool isRoot;
1552 DDXPointPtr locPts;
1553 REQUEST(xFillPolyReq);
1555 REQUEST_AT_LEAST_SIZE(xFillPolyReq);
1557 if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
1558 client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
1559 return BadDrawable;
1561 if(IS_SHARED_PIXMAP(draw))
1562 return (*SavedProcVector[X_FillPoly])(client);
1564 if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
1565 client, stuff->gc, XRT_GC, DixReadAccess)))
1566 return BadGC;
1568 isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
1570 count = ((client->req_len << 2) - sizeof(xFillPolyReq)) >> 2;
1571 if (count > 0){
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));
1578 if (isRoot) {
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;
1586 while(i--) {
1587 pnts->x -= x_off;
1588 pnts->y -= y_off;
1589 pnts++;
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);
1600 return (result);
1601 } else
1602 return (client->noClientException);
1606 int PanoramiXPolyFillRectangle(ClientPtr client)
1608 int result = 0, things, i, j;
1609 PanoramiXRes *gc, *draw;
1610 Bool isRoot;
1611 xRectangle *origRects;
1612 REQUEST(xPolyFillRectangleReq);
1614 REQUEST_AT_LEAST_SIZE(xPolyFillRectangleReq);
1616 if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
1617 client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
1618 return BadDrawable;
1620 if(IS_SHARED_PIXMAP(draw))
1621 return (*SavedProcVector[X_PolyFillRectangle])(client);
1623 if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
1624 client, stuff->gc, XRT_GC, DixReadAccess)))
1625 return BadGC;
1627 isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
1629 things = (client->req_len << 2) - sizeof(xPolyFillRectangleReq);
1630 if(things & 4) return BadLength;
1631 things >>= 3;
1632 if (things > 0){
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));
1639 if (isRoot) {
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++) {
1647 rects->x -= x_off;
1648 rects->y -= y_off;
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);
1659 return (result);
1660 } else
1661 return (client->noClientException);
1665 int PanoramiXPolyFillArc(ClientPtr client)
1667 PanoramiXRes *gc, *draw;
1668 Bool isRoot;
1669 int result = 0, narcs, i, j;
1670 xArc *origArcs;
1671 REQUEST(xPolyFillArcReq);
1673 REQUEST_AT_LEAST_SIZE(xPolyFillArcReq);
1675 if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
1676 client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
1677 return BadDrawable;
1679 if(IS_SHARED_PIXMAP(draw))
1680 return (*SavedProcVector[X_PolyFillArc])(client);
1682 if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
1683 client, stuff->gc, XRT_GC, DixReadAccess)))
1684 return BadGC;
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);
1691 if (narcs > 0) {
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));
1698 if (isRoot) {
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++) {
1706 arcs->x -= x_off;
1707 arcs->y -= y_off;
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);
1718 return (result);
1719 } else
1720 return (client->noClientException);
1724 int PanoramiXPutImage(ClientPtr client)
1726 PanoramiXRes *gc, *draw;
1727 Bool isRoot;
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)))
1735 return BadDrawable;
1737 if(IS_SHARED_PIXMAP(draw))
1738 return (*SavedProcVector[X_PutImage])(client);
1740 if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
1741 client, stuff->gc, XRT_GC, DixReadAccess)))
1742 return BadGC;
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){
1749 if (isRoot) {
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;
1758 return (result);
1762 int PanoramiXGetImage(ClientPtr client)
1764 DrawablePtr drawables[MAXSCREENS];
1765 DrawablePtr pDraw;
1766 PanoramiXRes *draw;
1767 xGetImageReply xgi;
1768 Bool isRoot;
1769 char *pBuf;
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;
1781 return(BadValue);
1784 if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
1785 client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
1786 return BadDrawable;
1788 if(draw->type == XRT_PIXMAP)
1789 return (*SavedProcVector[X_GetImage])(client);
1791 rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0,
1792 DixUnknownAccess);
1793 if (rc != Success)
1794 return rc;
1796 if(!((WindowPtr)pDraw)->realized)
1797 return(BadMatch);
1799 x = stuff->x;
1800 y = stuff->y;
1801 w = stuff->width;
1802 h = stuff->height;
1803 format = stuff->format;
1804 planemask = stuff->planeMask;
1806 isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
1808 if(isRoot) {
1809 if( /* check for being onscreen */
1810 x < 0 || x + w > PanoramiXPixWidth ||
1811 y < 0 || y + h > PanoramiXPixHeight )
1812 return(BadMatch);
1813 } else {
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)
1824 return(BadMatch);
1827 drawables[0] = pDraw;
1828 for(i = 1; i < PanoramiXNumScreens; i++) {
1829 rc = dixLookupDrawable(drawables+i, draw->info[i].id, client, 0,
1830 DixUnknownAccess);
1831 if (rc != Success)
1832 return rc;
1835 xgi.visual = wVisual (((WindowPtr) pDraw));
1836 xgi.type = X_Reply;
1837 xgi.sequenceNumber = client->sequence;
1838 xgi.depth = pDraw->depth;
1839 if(format == ZPixmap) {
1840 widthBytesLine = PixmapBytePad(w, pDraw->depth);
1841 length = widthBytesLine * h;
1844 } else {
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)
1856 linesPerBuf = 0;
1857 else if (widthBytesLine >= XINERAMA_IMAGE_BUFSIZE)
1858 linesPerBuf = 1;
1859 else {
1860 linesPerBuf = XINERAMA_IMAGE_BUFSIZE / widthBytesLine;
1861 if (linesPerBuf > h)
1862 linesPerBuf = h;
1864 length = linesPerBuf * widthBytesLine;
1865 if(!(pBuf = xalloc(length)))
1866 return (BadAlloc);
1868 WriteReplyToClient(client, sizeof (xGetImageReply), &xgi);
1870 if (linesPerBuf == 0) {
1871 /* nothing to do */
1873 else if (format == ZPixmap) {
1874 linesDone = 0;
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),
1886 pBuf);
1887 linesDone += nlines;
1889 } else { /* XYPixmap */
1890 for (; plane; plane >>= 1) {
1891 if (planemask & plane) {
1892 linesDone = 0;
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),
1904 pBuf);
1906 linesDone += nlines;
1911 xfree(pBuf);
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 */
1920 int
1921 PanoramiXPolyText8(ClientPtr client)
1923 PanoramiXRes *gc, *draw;
1924 Bool isRoot;
1925 int result = 0, j;
1926 int orig_x, orig_y;
1927 REQUEST(xPolyTextReq);
1929 REQUEST_AT_LEAST_SIZE(xPolyTextReq);
1931 if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
1932 client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
1933 return BadDrawable;
1935 if(IS_SHARED_PIXMAP(draw))
1936 return (*SavedProcVector[X_PolyText8])(client);
1938 if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
1939 client, stuff->gc, XRT_GC, DixReadAccess)))
1940 return BadGC;
1942 isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
1944 orig_x = stuff->x;
1945 orig_y = stuff->y;
1946 FOR_NSCREENS_BACKWARD(j){
1947 stuff->drawable = draw->info[j].id;
1948 stuff->gc = gc->info[j].id;
1949 if (isRoot) {
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;
1956 return (result);
1959 int
1960 PanoramiXPolyText16(ClientPtr client)
1962 PanoramiXRes *gc, *draw;
1963 Bool isRoot;
1964 int result = 0, j;
1965 int orig_x, orig_y;
1966 REQUEST(xPolyTextReq);
1968 REQUEST_AT_LEAST_SIZE(xPolyTextReq);
1970 if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
1971 client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
1972 return BadDrawable;
1974 if(IS_SHARED_PIXMAP(draw))
1975 return (*SavedProcVector[X_PolyText16])(client);
1977 if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
1978 client, stuff->gc, XRT_GC, DixReadAccess)))
1979 return BadGC;
1981 isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
1983 orig_x = stuff->x;
1984 orig_y = stuff->y;
1985 FOR_NSCREENS_BACKWARD(j){
1986 stuff->drawable = draw->info[j].id;
1987 stuff->gc = gc->info[j].id;
1988 if (isRoot) {
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;
1995 return (result);
1999 int PanoramiXImageText8(ClientPtr client)
2001 int result = 0, j;
2002 PanoramiXRes *gc, *draw;
2003 Bool isRoot;
2004 int orig_x, orig_y;
2005 REQUEST(xImageTextReq);
2007 REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars);
2009 if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
2010 client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
2011 return BadDrawable;
2013 if(IS_SHARED_PIXMAP(draw))
2014 return (*SavedProcVector[X_ImageText8])(client);
2016 if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
2017 client, stuff->gc, XRT_GC, DixReadAccess)))
2018 return BadGC;
2020 isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
2022 orig_x = stuff->x;
2023 orig_y = stuff->y;
2024 FOR_NSCREENS_BACKWARD(j){
2025 stuff->drawable = draw->info[j].id;
2026 stuff->gc = gc->info[j].id;
2027 if (isRoot) {
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;
2034 return (result);
2038 int PanoramiXImageText16(ClientPtr client)
2040 int result = 0, j;
2041 PanoramiXRes *gc, *draw;
2042 Bool isRoot;
2043 int orig_x, orig_y;
2044 REQUEST(xImageTextReq);
2046 REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars << 1);
2048 if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
2049 client, stuff->drawable, XRC_DRAWABLE, DixWriteAccess)))
2050 return BadDrawable;
2052 if(IS_SHARED_PIXMAP(draw))
2053 return (*SavedProcVector[X_ImageText16])(client);
2055 if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
2056 client, stuff->gc, XRT_GC, DixReadAccess)))
2057 return BadGC;
2059 isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
2061 orig_x = stuff->x;
2062 orig_y = stuff->y;
2063 FOR_NSCREENS_BACKWARD(j){
2064 stuff->drawable = draw->info[j].id;
2065 stuff->gc = gc->info[j].id;
2066 if (isRoot) {
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;
2073 return (result);
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)))
2088 return BadWindow;
2090 if(!stuff->visual || (stuff->visual > 255))
2091 return BadValue;
2093 if(!(newCmap = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes))))
2094 return BadAlloc;
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);
2112 else
2113 xfree(newCmap);
2115 return (result);
2119 int PanoramiXFreeColormap(ClientPtr client)
2121 PanoramiXRes *cmap;
2122 int result = 0, j;
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)))
2131 return BadColor;
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 */
2142 return (result);
2147 PanoramiXCopyColormapAndFree(ClientPtr client)
2149 PanoramiXRes *cmap, *newCmap;
2150 int result = 0, j;
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)))
2160 return BadColor;
2162 if(!(newCmap = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes))))
2163 return BadAlloc;
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);
2179 else
2180 xfree(newCmap);
2182 return (result);
2186 int PanoramiXInstallColormap(ClientPtr client)
2188 REQUEST(xResourceReq);
2189 int result = 0, j;
2190 PanoramiXRes *cmap;
2192 REQUEST_SIZE_MATCH(xResourceReq);
2194 client->errorValue = stuff->id;
2196 if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType(
2197 client, stuff->id, XRT_COLORMAP, DixReadAccess)))
2198 return BadColor;
2200 FOR_NSCREENS_BACKWARD(j){
2201 stuff->id = cmap->info[j].id;
2202 result = (* SavedProcVector[X_InstallColormap])(client);
2203 if(result != Success) break;
2205 return (result);
2209 int PanoramiXUninstallColormap(ClientPtr client)
2211 REQUEST(xResourceReq);
2212 int result = 0, j;
2213 PanoramiXRes *cmap;
2215 REQUEST_SIZE_MATCH(xResourceReq);
2217 client->errorValue = stuff->id;
2219 if(!(cmap = (PanoramiXRes *)SecurityLookupIDByType(
2220 client, stuff->id, XRT_COLORMAP, DixReadAccess)))
2221 return BadColor;
2223 FOR_NSCREENS_BACKWARD(j) {
2224 stuff->id = cmap->info[j].id;
2225 result = (* SavedProcVector[X_UninstallColormap])(client);
2226 if(result != Success) break;
2228 return (result);
2232 int PanoramiXAllocColor(ClientPtr client)
2234 int result = 0, j;
2235 PanoramiXRes *cmap;
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)))
2244 return BadColor;
2246 FOR_NSCREENS_BACKWARD(j){
2247 stuff->cmap = cmap->info[j].id;
2248 result = (* SavedProcVector[X_AllocColor])(client);
2249 if(result != Success) break;
2251 return (result);
2255 int PanoramiXAllocNamedColor(ClientPtr client)
2257 int result = 0, j;
2258 PanoramiXRes *cmap;
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)))
2267 return BadColor;
2269 FOR_NSCREENS_BACKWARD(j){
2270 stuff->cmap = cmap->info[j].id;
2271 result = (* SavedProcVector[X_AllocNamedColor])(client);
2272 if(result != Success) break;
2274 return (result);
2278 int PanoramiXAllocColorCells(ClientPtr client)
2280 int result = 0, j;
2281 PanoramiXRes *cmap;
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)))
2290 return BadColor;
2292 FOR_NSCREENS_BACKWARD(j){
2293 stuff->cmap = cmap->info[j].id;
2294 result = (* SavedProcVector[X_AllocColorCells])(client);
2295 if(result != Success) break;
2297 return (result);
2301 int PanoramiXAllocColorPlanes(ClientPtr client)
2303 int result = 0, j;
2304 PanoramiXRes *cmap;
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)))
2313 return BadColor;
2315 FOR_NSCREENS_BACKWARD(j){
2316 stuff->cmap = cmap->info[j].id;
2317 result = (* SavedProcVector[X_AllocColorPlanes])(client);
2318 if(result != Success) break;
2320 return (result);
2325 int PanoramiXFreeColors(ClientPtr client)
2327 int result = 0, j;
2328 PanoramiXRes *cmap;
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)))
2337 return BadColor;
2339 FOR_NSCREENS_BACKWARD(j) {
2340 stuff->cmap = cmap->info[j].id;
2341 result = (* SavedProcVector[X_FreeColors])(client);
2343 return (result);
2347 int PanoramiXStoreColors(ClientPtr client)
2349 int result = 0, j;
2350 PanoramiXRes *cmap;
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)))
2359 return BadColor;
2361 FOR_NSCREENS_BACKWARD(j){
2362 stuff->cmap = cmap->info[j].id;
2363 result = (* SavedProcVector[X_StoreColors])(client);
2364 if(result != Success) break;
2366 return (result);
2370 int PanoramiXStoreNamedColor(ClientPtr client)
2372 int result = 0, j;
2373 PanoramiXRes *cmap;
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)))
2382 return BadColor;
2384 FOR_NSCREENS_BACKWARD(j){
2385 stuff->cmap = cmap->info[j].id;
2386 result = (* SavedProcVector[X_StoreNamedColor])(client);
2387 if(result != Success) break;
2389 return (result);