|
|
1.1 ! root 1: /* $Header: dispatch.c,v 1.16 87/09/12 21:40:28 sun Exp $ */ ! 2: /************************************************************ ! 3: Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts, ! 4: and the Massachusetts Institute of Technology, Cambridge, Massachusetts. ! 5: ! 6: All Rights Reserved ! 7: ! 8: Permission to use, copy, modify, and distribute this software and its ! 9: documentation for any purpose and without fee is hereby granted, ! 10: provided that the above copyright notice appear in all copies and that ! 11: both that copyright notice and this permission notice appear in ! 12: supporting documentation, and that the names of Digital or MIT not be ! 13: used in advertising or publicity pertaining to distribution of the ! 14: software without specific, written prior permission. ! 15: ! 16: DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ! 17: ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL ! 18: DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ! 19: ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, ! 20: WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ! 21: ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS ! 22: SOFTWARE. ! 23: ! 24: ********************************************************/ ! 25: ! 26: #include "X.h" ! 27: #define NEED_REPLIES ! 28: #define NEED_EVENTS ! 29: #include "Xproto.h" ! 30: #include "windowstr.h" ! 31: #include "fontstruct.h" ! 32: #include "dixfontstr.h" ! 33: #include "gcstruct.h" ! 34: #include "osstruct.h" ! 35: #include "selection.h" ! 36: #include "colormapst.h" ! 37: #include "cursorstr.h" ! 38: #include "scrnintstr.h" ! 39: #include "opaque.h" ! 40: #include "input.h" ! 41: #include "servermd.h" ! 42: ! 43: extern WindowRec WindowTable[]; ! 44: extern xConnSetupPrefix connSetupPrefix; ! 45: extern char *ConnectionInfo; ! 46: extern void ProcessInputEvents(); ! 47: extern void ValidateGC(); ! 48: ! 49: Selection *CurrentSelections = (Selection *)NULL; ! 50: int NumCurrentSelections = 0; ! 51: ! 52: extern long ScreenSaverTime; ! 53: extern long ScreenSaverInterval; ! 54: extern int ScreenSaverBlanking; ! 55: extern int ScreenSaverAllowExposures; ! 56: static ClientPtr onlyClient; ! 57: static Bool grabbingClient = FALSE; ! 58: static long *checkForInput[2]; ! 59: extern Bool clientsDoomed; ! 60: extern int connBlockScreenStart; ! 61: ! 62: extern int (* ProcVector[256]) (); ! 63: extern int (* SwappedProcVector[256]) (); ! 64: extern void (* EventSwapVector[128]) (); ! 65: extern void (* ReplySwapVector[256]) (); ! 66: extern void Swap32Write(), SLHostsExtend(), SQColorsExtend(), WriteSConnectionInfo(); ! 67: void KillAllClients(); ! 68: ! 69: /* buffers for clients. legal values below */ ! 70: static int nextFreeClientID=1; /* 0 is for the server */ ! 71: ! 72: static int nClients = 0; /* number active clients */ ! 73: ! 74: #define SAME_SCREENS(a, b) (\ ! 75: (a.pScreen == b.pScreen)) ! 76: ! 77: #define VALIDATE(pGC, pDraw, rt) {\ ! 78: if (pGC->serialNumber != pDraw->serialNumber)\ ! 79: {\ ! 80: ValidateGC(pDraw, pGC);\ ! 81: } \ ! 82: } ! 83: ! 84: #define LEGAL_NEW_RESOURCE(id)\ ! 85: if ((LookupID(id, RT_ANY, RC_CORE) != 0) || (id & SERVER_BIT) \ ! 86: || (client->clientAsMask != CLIENT_BITS(id)))\ ! 87: return(BadIDChoice) ! 88: ! 89: ! 90: #define LOOKUP_DRAWABLE(did, client)\ ! 91: ((client->lastDrawableID == did) ? \ ! 92: (DrawablePtr)client->lastDrawable : (DrawablePtr)LookupDrawable(did, client)) ! 93: ! 94: #define VERIFY_GC(pGC, rid, client)\ ! 95: if (client->lastGCID == rid)\ ! 96: {\ ! 97: pGC = (GC *) client->lastGC;\ ! 98: }\ ! 99: else\ ! 100: {\ ! 101: pGC = (GC *)LookupID(rid, RT_GC, RC_CORE);\ ! 102: if (!pGC)\ ! 103: {\ ! 104: client->errorValue = rid;\ ! 105: return (BadGC);\ ! 106: }\ ! 107: } ! 108: ! 109: #define VALIDATE_DRAWABLE_AND_GC(drawID, pDraw, pGC, client)\ ! 110: if ((client->lastDrawableID != drawID) || (client->lastGCID != stuff->gc))\ ! 111: {\ ! 112: if (client->lastDrawableID != drawID)\ ! 113: {\ ! 114: pDraw = (DrawablePtr)LookupID(drawID, RT_DRAWABLE, RC_CORE);\ ! 115: if (!pDraw)\ ! 116: {\ ! 117: client->errorValue = drawID; \ ! 118: return (BadDrawable);\ ! 119: }\ ! 120: if ((pDraw->type == DRAWABLE_WINDOW) || \ ! 121: (pDraw->type == DRAWABLE_PIXMAP))\ ! 122: {\ ! 123: client->lastDrawable = (DrawablePtr)pDraw;\ ! 124: client->lastDrawableID = drawID;\ ! 125: }\ ! 126: else\ ! 127: {\ ! 128: client->errorValue = drawID;\ ! 129: return (BadDrawable);\ ! 130: }\ ! 131: }\ ! 132: else\ ! 133: pDraw = (DrawablePtr)client->lastDrawable;\ ! 134: if (client->lastGCID != stuff->gc)\ ! 135: {\ ! 136: pGC = (GC *)LookupID(stuff->gc, RT_GC, RC_CORE);\ ! 137: if (!pGC)\ ! 138: {\ ! 139: client->errorValue = stuff->gc;\ ! 140: return (BadGC);\ ! 141: }\ ! 142: client->lastGC = (GCPtr)pGC;\ ! 143: client->lastGCID = stuff->gc;\ ! 144: }\ ! 145: else\ ! 146: pGC = (GC *) client->lastGC;\ ! 147: if ((pGC->depth != pDraw->depth) || (pGC->pScreen != pDraw->pScreen))\ ! 148: {\ ! 149: client->errorValue = stuff->gc;\ ! 150: client->lastGCID = -1;\ ! 151: return (BadMatch);\ ! 152: }\ ! 153: }\ ! 154: else\ ! 155: {\ ! 156: pGC = (GC *) client->lastGC;\ ! 157: pDraw = (DrawablePtr)client->lastDrawable;\ ! 158: }\ ! 159: if (pGC->serialNumber != pDraw->serialNumber)\ ! 160: { \ ! 161: ValidateGC(pDraw, pGC);\ ! 162: } ! 163: ! 164: void ! 165: SetInputCheck(c0, c1) ! 166: long *c0, *c1; ! 167: { ! 168: checkForInput[0] = c0; ! 169: checkForInput[1] = c1; ! 170: } ! 171: ! 172: void ! 173: InitSelections() ! 174: { ! 175: int i; ! 176: ! 177: if (NumCurrentSelections == 0) ! 178: { ! 179: CurrentSelections = (Selection *)Xalloc(sizeof(Selection)); ! 180: NumCurrentSelections = 1; ! 181: } ! 182: for (i = 0; i< NumCurrentSelections; i++) ! 183: CurrentSelections[i].window = None; ! 184: } ! 185: ! 186: void ! 187: FlushClientCaches(id) ! 188: int id; ! 189: { ! 190: int i; ! 191: register ClientPtr client; ! 192: ! 193: client = clients[CLIENT_ID(id)]; ! 194: if (client == NullClient) ! 195: return ; ! 196: for (i=0; i<currentMaxClients; i++) ! 197: { ! 198: if (client == clients[i]) ! 199: { ! 200: if (client->lastDrawableID == id) ! 201: client->lastDrawableID = INVALID; ! 202: else if (client->lastGCID == id) ! 203: client->lastGCID = -1; ! 204: } ! 205: } ! 206: } ! 207: ! 208: Dispatch() ! 209: { ! 210: ClientPtr *clientReady; /* mask of request ready clients */ ! 211: ClientPtr *newClients; /* mask of new clients */ ! 212: int result; ! 213: xReq *request; ! 214: int ErrorStatus; ! 215: ClientPtr client; ! 216: int nready, nnew; ! 217: ! 218: nextFreeClientID = 1; ! 219: InitSelections(); ! 220: nClients = 0; ! 221: clientsDoomed = FALSE; ! 222: ! 223: clientReady = (ClientPtr *) ALLOCATE_LOCAL(sizeof(ClientPtr) * MaxClients); ! 224: newClients = (ClientPtr *)ALLOCATE_LOCAL(sizeof(ClientPtr) * MaxClients); ! 225: ! 226: while (1) ! 227: { ! 228: StartOver: ! 229: if (*checkForInput[0] != *checkForInput[1]) ! 230: ProcessInputEvents(); ! 231: ! 232: WaitForSomething(clientReady, &nready, newClients, &nnew); ! 233: ! 234: /***************** ! 235: * Establish any new connections ! 236: *****************/ ! 237: ! 238: while (nnew--) ! 239: { ! 240: client = newClients[nnew]; ! 241: client->requestLogIndex = 0; ! 242: InitClientResources(client); ! 243: SendConnectionSetupInfo(client); ! 244: nClients++; ! 245: } ! 246: ! 247: /***************** ! 248: * Handle events in round robin fashion, doing input between ! 249: * each round ! 250: *****************/ ! 251: ! 252: while ((nready--) > 0) ! 253: { ! 254: client = clientReady[nready]; ! 255: if (! client) ! 256: { ! 257: ErrorF( "HORRIBLE ERROR, unused client %d\n", nready); ! 258: continue; ! 259: } ! 260: isItTimeToYield = FALSE; ! 261: ! 262: requestingClient = client; ! 263: while (! isItTimeToYield) ! 264: { ! 265: if (*checkForInput[0] != *checkForInput[1]) ! 266: ProcessInputEvents(); ! 267: ! 268: /* now, finally, deal with client requests */ ! 269: ! 270: request = (xReq *)ReadRequestFromClient( ! 271: client, &result, request); ! 272: if (result < 0) ! 273: { ! 274: CloseDownClient(client); ! 275: isItTimeToYield = TRUE; ! 276: continue; ! 277: } ! 278: else if (result == 0) ! 279: { ! 280: #ifdef notdef ! 281: ErrorF( "Blocked read in dispatcher\n"); ! 282: ErrorF( "reqType %d %d\n", ! 283: (request ? request->reqType : -1), ! 284: nready); ! 285: #endif ! 286: if (nready > 0) ! 287: continue; ! 288: else ! 289: goto StartOver; ! 290: } ! 291: ! 292: client->sequence++; ! 293: client->requestBuffer = (pointer)request; ! 294: if (client->requestLogIndex == MAX_REQUEST_LOG) ! 295: client->requestLogIndex = 0; ! 296: client->requestLog[client->requestLogIndex] = request->reqType; ! 297: client->requestLogIndex++; ! 298: ErrorStatus = (* (client->swapped ? ! 299: SwappedProcVector : ProcVector)[request->reqType])(client); ! 300: ! 301: if (ErrorStatus != Success) ! 302: { ! 303: if (client->noClientException != Success) ! 304: CloseDownClient(client); ! 305: else ! 306: Oops(client, request->reqType, 0, ErrorStatus); ! 307: isItTimeToYield = TRUE; ! 308: continue; ! 309: } ! 310: } ! 311: } ! 312: /* Not an error, we just need to know to restart */ ! 313: if((nClients == -1) || clientsDoomed) ! 314: break; /* so that DEALLOCATE_LOCALs happen */ ! 315: } ! 316: if (clientsDoomed) ! 317: KillAllClients(); ! 318: DEALLOCATE_LOCAL(newClients); ! 319: DEALLOCATE_LOCAL(clientReady); ! 320: } ! 321: ! 322: int ! 323: ProcBadRequest(client) ! 324: ClientPtr client; ! 325: { ! 326: return (BadRequest); ! 327: } ! 328: ! 329: extern int Ones(); ! 330: ! 331: int ! 332: ProcCreateWindow(client) ! 333: register ClientPtr client; ! 334: { ! 335: register WindowPtr pParent, pWin; ! 336: REQUEST(xCreateWindowReq); ! 337: int result; ! 338: int len; ! 339: ! 340: REQUEST_AT_LEAST_SIZE(xCreateWindowReq); ! 341: ! 342: LEGAL_NEW_RESOURCE(stuff->wid); ! 343: if (!(pParent = (WindowPtr)LookupWindow(stuff->parent, client))) ! 344: return BadWindow; ! 345: len = stuff->length - (sizeof(xCreateWindowReq) >> 2); ! 346: if (Ones(stuff->mask) != len) ! 347: return BadLength; ! 348: if (!stuff->width || !stuff->height) ! 349: return BadValue; ! 350: pWin = CreateWindow(stuff->wid, pParent, stuff->x, ! 351: stuff->y, stuff->width, stuff->height, ! 352: stuff->borderWidth, stuff->class, ! 353: stuff->mask, (long *) &stuff[1], ! 354: stuff->depth, ! 355: client, stuff->visual, &result); ! 356: if (pWin) ! 357: AddResource(stuff->wid, RT_WINDOW, pWin, DeleteWindow, RC_CORE); ! 358: if (client->noClientException != Success) ! 359: return(client->noClientException); ! 360: else ! 361: return(result); ! 362: } ! 363: ! 364: int ! 365: ProcChangeWindowAttributes(client) ! 366: register ClientPtr client; ! 367: { ! 368: register WindowPtr pWin; ! 369: REQUEST(xChangeWindowAttributesReq); ! 370: register int result; ! 371: int len; ! 372: ! 373: REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq); ! 374: pWin = (WindowPtr)LookupWindow(stuff->window, client); ! 375: if (!pWin) ! 376: return(BadWindow); ! 377: len = stuff->length - (sizeof(xChangeWindowAttributesReq) >> 2); ! 378: if (len != Ones(stuff->valueMask)) ! 379: return BadLength; ! 380: client->lastDrawableID = INVALID; ! 381: result = ChangeWindowAttributes(pWin, ! 382: stuff->valueMask, ! 383: (long *) &stuff[1], ! 384: client); ! 385: if (client->noClientException != Success) ! 386: return(client->noClientException); ! 387: else ! 388: return(result); ! 389: } ! 390: ! 391: int ! 392: ProcGetWindowAttributes(client) ! 393: register ClientPtr client; ! 394: { ! 395: register WindowPtr pWin; ! 396: REQUEST(xResourceReq); ! 397: ! 398: REQUEST_SIZE_MATCH(xResourceReq); ! 399: pWin = (WindowPtr)LookupWindow(stuff->id, client); ! 400: if (!pWin) ! 401: return(BadWindow); ! 402: GetWindowAttributes(pWin, client); ! 403: return(client->noClientException); ! 404: } ! 405: ! 406: int ! 407: ProcDestroyWindow(client) ! 408: register ClientPtr client; ! 409: { ! 410: register WindowPtr pWin; ! 411: REQUEST(xResourceReq); ! 412: ! 413: REQUEST_SIZE_MATCH(xResourceReq); ! 414: pWin = (WindowPtr)LookupWindow(stuff->id, client); ! 415: if (!pWin) ! 416: return(BadWindow); ! 417: FreeResource(stuff->id, RC_NONE); ! 418: return(client->noClientException); ! 419: } ! 420: ! 421: int ! 422: ProcDestroySubwindows(client) ! 423: register ClientPtr client; ! 424: { ! 425: register WindowPtr pWin; ! 426: REQUEST(xResourceReq); ! 427: ! 428: REQUEST_SIZE_MATCH(xResourceReq); ! 429: pWin = (WindowPtr)LookupWindow(stuff->id, client); ! 430: if (!pWin) ! 431: return(BadWindow); ! 432: DestroySubwindows(pWin, client); ! 433: return(client->noClientException); ! 434: } ! 435: ! 436: int ! 437: ProcChangeSaveSet(client) ! 438: register ClientPtr client; ! 439: { ! 440: register WindowPtr pWin; ! 441: REQUEST(xChangeSaveSetReq); ! 442: register result; ! 443: ! 444: REQUEST_SIZE_MATCH(xChangeSaveSetReq); ! 445: pWin = (WindowPtr)LookupWindow(stuff->window, client); ! 446: if (!pWin) ! 447: return(BadWindow); ! 448: if (client->clientAsMask == (CLIENT_ID(pWin->wid))) ! 449: return BadMatch; ! 450: if ((stuff->mode == SetModeInsert) || (stuff->mode == SetModeDelete)) ! 451: { ! 452: result = AlterSaveSetForClient(client, pWin, stuff->mode); ! 453: if (client->noClientException != Success) ! 454: return(client->noClientException); ! 455: else ! 456: return(result); ! 457: } ! 458: else ! 459: return( BadValue ); ! 460: } ! 461: ! 462: int ! 463: ProcReparentWindow(client) ! 464: register ClientPtr client; ! 465: { ! 466: register WindowPtr pWin, pParent; ! 467: REQUEST(xReparentWindowReq); ! 468: register int result; ! 469: ! 470: REQUEST_SIZE_MATCH(xReparentWindowReq); ! 471: pWin = (WindowPtr)LookupWindow(stuff->window, client); ! 472: if (!pWin) ! 473: return(BadWindow); ! 474: pParent = (WindowPtr)LookupWindow(stuff->parent, client); ! 475: if (!pParent) ! 476: return(BadWindow); ! 477: if (SAME_SCREENS(pWin->drawable, pParent->drawable)) ! 478: { ! 479: if ((pWin->backgroundTile == (PixmapPtr)ParentRelative) && ! 480: (pParent->drawable.depth != pWin->drawable.depth)) ! 481: return BadMatch; ! 482: result = ReparentWindow(pWin, pParent, ! 483: (short)stuff->x, (short)stuff->y, client); ! 484: if (client->noClientException != Success) ! 485: return(client->noClientException); ! 486: else ! 487: return(result); ! 488: } ! 489: else ! 490: return (BadMatch); ! 491: } ! 492: ! 493: int ! 494: ProcMapWindow(client) ! 495: register ClientPtr client; ! 496: { ! 497: register WindowPtr pWin; ! 498: REQUEST(xResourceReq); ! 499: ! 500: REQUEST_SIZE_MATCH(xResourceReq); ! 501: pWin = (WindowPtr)LookupWindow(stuff->id, client); ! 502: if (!pWin) ! 503: return(BadWindow); ! 504: MapWindow(pWin, HANDLE_EXPOSURES, BITS_DISCARDED, ! 505: SEND_NOTIFICATION, client); ! 506: /* update cache to say it is mapped */ ! 507: return(client->noClientException); ! 508: } ! 509: ! 510: int ! 511: ProcMapSubwindows(client) ! 512: register ClientPtr client; ! 513: { ! 514: register WindowPtr pWin; ! 515: REQUEST(xResourceReq); ! 516: ! 517: REQUEST_SIZE_MATCH(xResourceReq); ! 518: pWin = (WindowPtr)LookupWindow( stuff->id, client); ! 519: if (!pWin) ! 520: return(BadWindow); ! 521: MapSubwindows(pWin, HANDLE_EXPOSURES, client); ! 522: /* update cache to say it is mapped */ ! 523: return(client->noClientException); ! 524: } ! 525: ! 526: int ! 527: ProcUnmapWindow(client) ! 528: register ClientPtr client; ! 529: { ! 530: register WindowPtr pWin; ! 531: REQUEST(xResourceReq); ! 532: ! 533: REQUEST_SIZE_MATCH(xResourceReq); ! 534: pWin = (WindowPtr)LookupWindow( stuff->id, client); ! 535: if (!pWin) ! 536: return(BadWindow); ! 537: UnmapWindow(pWin, HANDLE_EXPOSURES, SEND_NOTIFICATION, FALSE); ! 538: /* update cache to say it is mapped */ ! 539: return(client->noClientException); ! 540: } ! 541: ! 542: int ! 543: ProcUnmapSubwindows(client) ! 544: register ClientPtr client; ! 545: { ! 546: register WindowPtr pWin; ! 547: REQUEST(xResourceReq); ! 548: ! 549: REQUEST_SIZE_MATCH(xResourceReq); ! 550: pWin = (WindowPtr)LookupWindow( stuff->id, client); ! 551: if (!pWin) ! 552: return(BadWindow); ! 553: UnmapSubwindows(pWin, HANDLE_EXPOSURES, FALSE); ! 554: return(client->noClientException); ! 555: } ! 556: ! 557: int ! 558: ProcConfigureWindow(client) ! 559: register ClientPtr client; ! 560: { ! 561: register WindowPtr pWin; ! 562: REQUEST(xConfigureWindowReq); ! 563: register int result; ! 564: int len; ! 565: ! 566: REQUEST_AT_LEAST_SIZE(xConfigureWindowReq); ! 567: pWin = (WindowPtr)LookupWindow( stuff->window, client); ! 568: if (!pWin) ! 569: return(BadWindow); ! 570: len = stuff->length - (sizeof(xConfigureWindowReq) >> 2); ! 571: if (Ones(stuff->mask) != len) ! 572: return BadLength; ! 573: result = ConfigureWindow(pWin, stuff->mask, (char *) &stuff[1], ! 574: client); ! 575: if (client->noClientException != Success) ! 576: return(client->noClientException); ! 577: else ! 578: return(result); ! 579: } ! 580: ! 581: int ! 582: ProcCirculateWindow(client) ! 583: register ClientPtr client; ! 584: { ! 585: register WindowPtr pWin; ! 586: REQUEST(xCirculateWindowReq); ! 587: ! 588: REQUEST_SIZE_MATCH(xCirculateWindowReq); ! 589: if ((stuff->direction != RaiseLowest) && ! 590: (stuff->direction != LowerHighest)) ! 591: return BadValue; ! 592: pWin = (WindowPtr)LookupWindow(stuff->window, client); ! 593: if (!pWin) ! 594: return(BadWindow); ! 595: CirculateWindow(pWin, stuff->direction, client); ! 596: return(client->noClientException); ! 597: } ! 598: ! 599: int ! 600: ProcGetGeometry(client) ! 601: register ClientPtr client; ! 602: { ! 603: xGetGeometryReply rep; ! 604: register DrawablePtr pDraw; ! 605: REQUEST(xResourceReq); ! 606: ! 607: REQUEST_SIZE_MATCH(xResourceReq); ! 608: if (!(pDraw = LOOKUP_DRAWABLE(stuff->id, client))) ! 609: { /* can be inputonly */ ! 610: if (!(pDraw = (DrawablePtr)LookupWindow(stuff->id, client))) ! 611: return (BadDrawable); ! 612: } ! 613: rep.type = X_Reply; ! 614: rep.length = 0; ! 615: rep.sequenceNumber = client->sequence; ! 616: rep.root = WindowTable[pDraw->pScreen->myNum].wid; ! 617: rep.depth = pDraw->depth; ! 618: ! 619: if (pDraw->type == DRAWABLE_PIXMAP) ! 620: { ! 621: PixmapPtr pPixmap = (PixmapPtr)pDraw; ! 622: ! 623: rep.x = rep.y = rep.borderWidth = 0; ! 624: rep.width = pPixmap->width; ! 625: rep.height = pPixmap->height; ! 626: } ! 627: else ! 628: { ! 629: register WindowPtr pWin = (WindowPtr)pDraw; ! 630: rep.x = pWin->clientWinSize.x - pWin->borderWidth; ! 631: rep.y = pWin->clientWinSize.y - pWin->borderWidth; ! 632: rep.borderWidth = pWin->borderWidth; ! 633: rep.width = pWin->clientWinSize.width; ! 634: rep.height = pWin->clientWinSize.height; ! 635: } ! 636: WriteReplyToClient(client, sizeof(xGetGeometryReply), &rep); ! 637: return(client->noClientException); ! 638: } ! 639: ! 640: int ! 641: ProcQueryTree(client) ! 642: register ClientPtr client; ! 643: { ! 644: ! 645: xQueryTreeReply reply; ! 646: int numChildren = 0; ! 647: register WindowPtr pChild, pWin; ! 648: Window *childIDs = (Window *)NULL; ! 649: REQUEST(xResourceReq); ! 650: ! 651: REQUEST_SIZE_MATCH(xResourceReq); ! 652: pWin = (WindowPtr)LookupWindow(stuff->id, client); ! 653: if (!pWin) ! 654: return(BadWindow); ! 655: reply.type = X_Reply; ! 656: reply.root = WindowTable[pWin->drawable.pScreen->myNum].wid; ! 657: reply.sequenceNumber = client->sequence; ! 658: if (pWin->parent) ! 659: reply.parent = pWin->parent->wid; ! 660: else ! 661: reply.parent = (Window)None; ! 662: ! 663: for (pChild = pWin->lastChild; pChild; pChild = pChild->prevSib) ! 664: numChildren++; ! 665: if (numChildren) ! 666: { ! 667: int curChild = 0; ! 668: ! 669: childIDs = (Window *) Xalloc(numChildren * sizeof(Window)); ! 670: for (pChild = pWin->lastChild; pChild; pChild = pChild->prevSib) ! 671: childIDs[curChild++] = pChild->wid; ! 672: } ! 673: ! 674: reply.nChildren = numChildren; ! 675: reply.length = (numChildren * sizeof(Window)) >> 2; ! 676: ! 677: WriteReplyToClient(client, sizeof(xQueryTreeReply), &reply); ! 678: if (numChildren) ! 679: { ! 680: client->pSwapReplyFunc = Swap32Write; ! 681: WriteSwappedDataToClient(client, numChildren * sizeof(Window), childIDs); ! 682: Xfree(childIDs); ! 683: } ! 684: ! 685: return(client->noClientException); ! 686: } ! 687: ! 688: int ! 689: ProcInternAtom(client) ! 690: register ClientPtr client; ! 691: { ! 692: Atom atom; ! 693: char *tchar; ! 694: REQUEST(xInternAtomReq); ! 695: ! 696: REQUEST_AT_LEAST_SIZE(xInternAtomReq); ! 697: tchar = (char *) &stuff[1]; ! 698: atom = MakeAtom(tchar, stuff->nbytes, !stuff->onlyIfExists); ! 699: if (atom || stuff->onlyIfExists) ! 700: { ! 701: xInternAtomReply reply; ! 702: reply.type = X_Reply; ! 703: reply.length = 0; ! 704: reply.sequenceNumber = client->sequence; ! 705: reply.atom = (atom ? atom : None); ! 706: WriteReplyToClient(client, sizeof(xInternAtomReply), &reply); ! 707: return(client->noClientException); ! 708: } ! 709: else ! 710: return (BadAlloc); ! 711: } ! 712: ! 713: int ! 714: ProcGetAtomName(client) ! 715: register ClientPtr client; ! 716: { ! 717: char *str; ! 718: xGetAtomNameReply reply; ! 719: int len; ! 720: REQUEST(xResourceReq); ! 721: ! 722: REQUEST_SIZE_MATCH(xResourceReq); ! 723: if (str = (char *)NameForAtom(stuff->id)) ! 724: { ! 725: len = strlen(str); ! 726: reply.type = X_Reply; ! 727: reply.length = (len + 3) >> 2; ! 728: reply.sequenceNumber = client->sequence; ! 729: reply.nameLength = len; ! 730: WriteReplyToClient(client, sizeof(xGetAtomNameReply), &reply); ! 731: WriteToClient(client, len, str); ! 732: return(client->noClientException); ! 733: } ! 734: else ! 735: { ! 736: client->errorValue = stuff->id; ! 737: return (BadAtom); ! 738: } ! 739: } ! 740: ! 741: int ! 742: ProcDeleteProperty(client) ! 743: register ClientPtr client; ! 744: { ! 745: WindowPtr pWin; ! 746: REQUEST(xDeletePropertyReq); ! 747: int result; ! 748: ! 749: REQUEST_SIZE_MATCH(xDeletePropertyReq); ! 750: pWin = (WindowPtr)LookupWindow(stuff->window, client); ! 751: if (!pWin) ! 752: return(BadWindow); ! 753: if (ValidAtom(stuff->property)) ! 754: { ! 755: result = DeleteProperty(pWin, stuff->property); ! 756: if (client->noClientException != Success) ! 757: return(client->noClientException); ! 758: else ! 759: return(result); ! 760: } ! 761: else ! 762: return (BadAtom); ! 763: } ! 764: ! 765: ! 766: int ! 767: ProcSetSelectionOwner(client) ! 768: register ClientPtr client; ! 769: { ! 770: WindowPtr pWin; ! 771: TimeStamp time; ! 772: REQUEST(xSetSelectionOwnerReq); ! 773: ! 774: REQUEST_SIZE_MATCH(xSetSelectionOwnerReq); ! 775: time = ClientTimeToServerTime(stuff->time); ! 776: ! 777: /* If the client's time stamp is in the future relative to the server's ! 778: time stamp, do not set the selection, just return success. */ ! 779: if (CompareTimeStamps(time, currentTime) == LATER) ! 780: return Success; ! 781: if (stuff->window != None) ! 782: { ! 783: pWin = (WindowPtr)LookupWindow(stuff->window, client); ! 784: if (!pWin) ! 785: return(BadWindow); ! 786: } ! 787: else ! 788: pWin = (WindowPtr)None; ! 789: if (ValidAtom(stuff->selection)) ! 790: { ! 791: int i = 0; ! 792: ! 793: /* ! 794: * First, see if the selection is already set... ! 795: */ ! 796: while ((i < NumCurrentSelections) && ! 797: CurrentSelections[i].selection != stuff->selection) ! 798: i++; ! 799: if (i < NumCurrentSelections) ! 800: { ! 801: xEvent event; ! 802: ! 803: /* If the timestamp in client's request is in the past relative ! 804: to the time stamp indicating the last time the owner of the ! 805: selection was set, do not set the selection, just return ! 806: success. */ ! 807: if (CompareTimeStamps(time, CurrentSelections[i].lastTimeChanged) ! 808: == EARLIER) ! 809: return Success; ! 810: if (CurrentSelections[i].pWin != (WindowPtr)None) ! 811: { ! 812: event.u.u.type = SelectionClear; ! 813: event.u.selectionClear.time = time.milliseconds; ! 814: event.u.selectionClear.window = CurrentSelections[i].window; ! 815: event.u.selectionClear.atom = CurrentSelections[i].selection; ! 816: DeliverEvents(CurrentSelections[i].pWin, &event, 1); ! 817: } ! 818: CurrentSelections[i].selection = stuff->selection; ! 819: CurrentSelections[i].lastTimeChanged = time; ! 820: CurrentSelections[i].window = stuff->window; ! 821: CurrentSelections[i].pWin = pWin; ! 822: CurrentSelections[i].client = client; ! 823: return (client->noClientException); ! 824: } ! 825: /* ! 826: * It doesn't exist, so add it... ! 827: */ ! 828: NumCurrentSelections++; ! 829: CurrentSelections = ! 830: (Selection *)Xrealloc(CurrentSelections, ! 831: NumCurrentSelections * sizeof(Selection)); ! 832: ! 833: CurrentSelections[i].selection = stuff->selection; ! 834: CurrentSelections[i].lastTimeChanged = time; ! 835: CurrentSelections[i].window = stuff->window; ! 836: CurrentSelections[i].pWin = pWin; ! 837: CurrentSelections[i].client = client; ! 838: return (client->noClientException); ! 839: } ! 840: else ! 841: return (BadAtom); ! 842: } ! 843: ! 844: int ! 845: ProcGetSelectionOwner(client) ! 846: register ClientPtr client; ! 847: { ! 848: REQUEST(xResourceReq); ! 849: ! 850: REQUEST_SIZE_MATCH(xResourceReq); ! 851: if (ValidAtom(stuff->id)) ! 852: { ! 853: int i; ! 854: xGetSelectionOwnerReply reply; ! 855: ! 856: i = 0; ! 857: while ((i < NumCurrentSelections) && ! 858: CurrentSelections[i].selection != stuff->id) i++; ! 859: reply.type = X_Reply; ! 860: reply.length = 0; ! 861: reply.sequenceNumber = client->sequence; ! 862: if (i < NumCurrentSelections) ! 863: reply.owner = CurrentSelections[i].window; ! 864: else ! 865: reply.owner = None; ! 866: WriteReplyToClient(client, sizeof(xGetSelectionOwnerReply), &reply); ! 867: return(client->noClientException); ! 868: } ! 869: else ! 870: return (BadAtom); ! 871: } ! 872: ! 873: int ! 874: ProcConvertSelection(client) ! 875: register ClientPtr client; ! 876: { ! 877: Bool paramsOkay = TRUE; ! 878: xEvent event; ! 879: WindowPtr pWin; ! 880: REQUEST(xConvertSelectionReq); ! 881: ! 882: REQUEST_SIZE_MATCH(xConvertSelectionReq); ! 883: pWin = (WindowPtr)LookupWindow(stuff->requestor, client); ! 884: if (!pWin) ! 885: return(BadWindow); ! 886: ! 887: paramsOkay = (ValidAtom(stuff->selection) && ValidAtom(stuff->target)); ! 888: if (stuff->property != None) ! 889: paramsOkay &= ValidAtom(stuff->property); ! 890: if (paramsOkay) ! 891: { ! 892: int i; ! 893: ! 894: i = 0; ! 895: while ((i < NumCurrentSelections) && ! 896: CurrentSelections[i].selection != stuff->selection) i++; ! 897: if ((i < NumCurrentSelections) && ! 898: (CurrentSelections[i].window != None)) ! 899: { ! 900: event.u.u.type = SelectionRequest; ! 901: event.u.selectionRequest.time = stuff->time; ! 902: event.u.selectionRequest.owner = ! 903: CurrentSelections[i].window; ! 904: event.u.selectionRequest.requestor = stuff->requestor; ! 905: event.u.selectionRequest.selection = stuff->selection; ! 906: event.u.selectionRequest.target = stuff->target; ! 907: event.u.selectionRequest.property = stuff->property; ! 908: if (TryClientEvents( ! 909: CurrentSelections[i].client, &event, 1, NoEventMask, ! 910: NoEventMask, NullGrab)) ! 911: return (client->noClientException); ! 912: } ! 913: event.u.u.type = SelectionNotify; ! 914: event.u.selectionNotify.time = stuff->time; ! 915: event.u.selectionNotify.requestor = stuff->requestor; ! 916: event.u.selectionNotify.selection = stuff->selection; ! 917: event.u.selectionNotify.target = stuff->target; ! 918: event.u.selectionNotify.property = None; ! 919: DeliverEvents(pWin, &event, 1); ! 920: return (client->noClientException); ! 921: } ! 922: else ! 923: return (BadAtom); ! 924: } ! 925: ! 926: int ! 927: ProcGrabServer(client) ! 928: register ClientPtr client; ! 929: { ! 930: OnlyListenToOneClient(client); ! 931: grabbingClient = TRUE; ! 932: onlyClient = client; ! 933: return(client->noClientException); ! 934: } ! 935: ! 936: int ! 937: ProcUngrabServer(client) ! 938: register ClientPtr client; ! 939: { ! 940: REQUEST(xReq); ! 941: REQUEST_SIZE_MATCH(xReq); ! 942: grabbingClient = FALSE; ! 943: ListenToAllClients(); ! 944: return(client->noClientException); ! 945: } ! 946: ! 947: int ! 948: ProcTranslateCoords(client) ! 949: register ClientPtr client; ! 950: { ! 951: REQUEST(xTranslateCoordsReq); ! 952: ! 953: register WindowPtr pWin, pDst; ! 954: xTranslateCoordsReply rep; ! 955: ! 956: REQUEST_SIZE_MATCH(xTranslateCoordsReq); ! 957: pWin = (WindowPtr)LookupWindow(stuff->srcWid, client); ! 958: if (!pWin) ! 959: return(BadWindow); ! 960: pDst = (WindowPtr)LookupWindow(stuff->dstWid, client); ! 961: if (!pDst) ! 962: return(BadWindow); ! 963: rep.type = X_Reply; ! 964: rep.length = 0; ! 965: rep.sequenceNumber = client->sequence; ! 966: if (!SAME_SCREENS(pWin->drawable, pDst->drawable)) ! 967: { ! 968: rep.sameScreen = xFalse; ! 969: rep.child = None; ! 970: rep.dstX = rep.dstY = 0; ! 971: } ! 972: else ! 973: { ! 974: INT16 x, y; ! 975: rep.sameScreen = xTrue; ! 976: rep.child = None; ! 977: /* computing absolute coordinates -- adjust to destination later */ ! 978: x = pWin->absCorner.x + stuff->srcX; ! 979: y = pWin->absCorner.y + stuff->srcY; ! 980: pWin = pDst->firstChild; ! 981: while (pWin) ! 982: { ! 983: if ((pWin->mapped) && ! 984: (x >= pWin->absCorner.x - pWin->borderWidth) && ! 985: (x < pWin->absCorner.x + pWin->clientWinSize.width + ! 986: pWin->borderWidth) && ! 987: (y >= pWin->absCorner.y - pWin->borderWidth) && ! 988: (y < pWin->absCorner.y + pWin->clientWinSize.height ! 989: + pWin->borderWidth)) ! 990: { ! 991: rep.child = pWin->wid; ! 992: pWin = (WindowPtr) NULL; ! 993: } ! 994: else ! 995: pWin = pWin->nextSib; ! 996: } ! 997: /* adjust to destination coordinates */ ! 998: rep.dstX = x - pDst->absCorner.x; ! 999: rep.dstY = y - pDst->absCorner.y; ! 1000: } ! 1001: WriteReplyToClient(client, sizeof(xTranslateCoordsReply), &rep); ! 1002: return(client->noClientException); ! 1003: } ! 1004: ! 1005: int ! 1006: ProcOpenFont(client) ! 1007: register ClientPtr client; ! 1008: { ! 1009: FontPtr pFont; ! 1010: REQUEST(xOpenFontReq); ! 1011: ! 1012: REQUEST_AT_LEAST_SIZE(xOpenFontReq); ! 1013: client->errorValue = stuff->fid; ! 1014: LEGAL_NEW_RESOURCE(stuff->fid); ! 1015: if ( pFont = OpenFont( stuff->nbytes, (char *)&stuff[1])) ! 1016: { ! 1017: AddResource( stuff->fid, RT_FONT, pFont, CloseFont,RC_CORE); ! 1018: return(client->noClientException); ! 1019: } ! 1020: else ! 1021: return (BadName); ! 1022: } ! 1023: ! 1024: int ! 1025: ProcCloseFont(client) ! 1026: register ClientPtr client; ! 1027: { ! 1028: FontPtr pFont; ! 1029: REQUEST(xResourceReq); ! 1030: ! 1031: REQUEST_SIZE_MATCH(xResourceReq); ! 1032: pFont = (FontPtr)LookupID(stuff->id, RT_FONT, RC_CORE); ! 1033: if ( pFont != (FontPtr)NULL) /* id was valid */ ! 1034: { ! 1035: FreeResource( stuff->id, RC_NONE); ! 1036: return(client->noClientException); ! 1037: } ! 1038: else ! 1039: return (BadFont); ! 1040: } ! 1041: ! 1042: int ! 1043: ProcQueryFont(client) ! 1044: register ClientPtr client; ! 1045: { ! 1046: xQueryFontReply *reply; ! 1047: FontPtr pFont; ! 1048: register GC *pGC; ! 1049: REQUEST(xResourceReq); ! 1050: ! 1051: REQUEST_SIZE_MATCH(xResourceReq); ! 1052: client->errorValue = stuff->id; /* EITHER font or gc */ ! 1053: pFont = (FontPtr)LookupID(stuff->id, RT_FONT, RC_CORE); ! 1054: if (!pFont) ! 1055: { ! 1056: /* can't use VERIFY_GC because it might return BadGC */ ! 1057: pGC = (GC *) LookupID(stuff->id, RT_GC, RC_CORE); ! 1058: if (!pGC) ! 1059: return(BadFont); /* procotol spec says only error is BadFont */ ! 1060: pFont = pGC->font; ! 1061: } ! 1062: ! 1063: { ! 1064: CharInfoPtr pmax = &pFont->pFI->maxbounds; ! 1065: CharInfoPtr pmin = &pFont->pFI->minbounds; ! 1066: int nprotoxcistructs; ! 1067: int rlength; ! 1068: ! 1069: nprotoxcistructs = ( ! 1070: pmax->metrics.rightSideBearing == pmin->metrics.rightSideBearing && ! 1071: pmax->metrics.leftSideBearing == pmin->metrics.leftSideBearing && ! 1072: pmax->metrics.descent == pmin->metrics.descent && ! 1073: pmax->metrics.ascent == pmin->metrics.ascent && ! 1074: pmax->metrics.characterWidth == pmin->metrics.characterWidth) ? ! 1075: 0 : n2dChars(pFont->pFI); ! 1076: ! 1077: rlength = sizeof(xQueryFontReply) + ! 1078: pFont->pFI->nProps * sizeof(xFontProp) + ! 1079: nprotoxcistructs * sizeof(xCharInfo); ! 1080: reply = (xQueryFontReply *)ALLOCATE_LOCAL(rlength); ! 1081: if(!reply) ! 1082: { ! 1083: return(client->noClientException = BadAlloc); ! 1084: } ! 1085: ! 1086: reply->type = X_Reply; ! 1087: reply->length = (rlength - sizeof(xGenericReply)) >> 2; ! 1088: reply->sequenceNumber = client->sequence; ! 1089: QueryFont( pFont, reply, nprotoxcistructs); ! 1090: ! 1091: WriteReplyToClient(client, rlength, reply); ! 1092: DEALLOCATE_LOCAL(reply); ! 1093: return(client->noClientException); ! 1094: } ! 1095: } ! 1096: ! 1097: int ! 1098: ProcQueryTextExtents(client) ! 1099: register ClientPtr client; ! 1100: { ! 1101: REQUEST(xQueryTextExtentsReq); ! 1102: xQueryTextExtentsReply reply; ! 1103: FontPtr pFont; ! 1104: GC *pGC; ! 1105: ExtentInfoRec info; ! 1106: short length; ! 1107: ! 1108: REQUEST_AT_LEAST_SIZE(xQueryTextExtentsReq); ! 1109: ! 1110: pFont = (FontPtr)LookupID( stuff->fid, RT_FONT, RC_CORE); ! 1111: if (!pFont) ! 1112: { ! 1113: pGC = (GC *)LookupID( stuff->fid, RT_GC, RC_CORE); ! 1114: if (!pGC) ! 1115: return(BadFont); ! 1116: pFont = pGC->font; ! 1117: } ! 1118: length = stuff->length - (sizeof(xQueryTextExtentsReq) >> 2); ! 1119: length = length << 1; ! 1120: if (stuff->oddLength) ! 1121: length--; ! 1122: QueryTextExtents(pFont, length, &stuff[1], &info); ! 1123: reply.type = X_Reply; ! 1124: reply.length = 0; ! 1125: reply.sequenceNumber = client->sequence; ! 1126: reply.drawDirection = info.drawDirection; ! 1127: reply.fontAscent = info.fontAscent; ! 1128: reply.fontDescent = info.fontDescent; ! 1129: reply.overallAscent = info.overallAscent; ! 1130: reply.overallDescent = info.overallDescent; ! 1131: reply.overallWidth = info.overallWidth; ! 1132: reply.overallLeft = info.overallLeft; ! 1133: reply.overallRight = info.overallRight; ! 1134: WriteReplyToClient(client, sizeof(xQueryTextExtentsReply), &reply); ! 1135: return(client->noClientException); ! 1136: } ! 1137: ! 1138: int ! 1139: ProcListFonts(client) ! 1140: register ClientPtr client; ! 1141: { ! 1142: xListFontsReply reply; ! 1143: FontPathPtr fpr; ! 1144: int stringLens, i; ! 1145: char *bufptr, *bufferStart; ! 1146: REQUEST(xListFontsReq); ! 1147: ! 1148: REQUEST_AT_LEAST_SIZE(xListFontsReq); ! 1149: ! 1150: fpr = ExpandFontNamePattern( stuff->nbytes, ! 1151: &stuff[1], stuff->maxNames); ! 1152: stringLens = 0; ! 1153: for (i=0; i<fpr->npaths; i++) ! 1154: stringLens += fpr->length[i]; ! 1155: ! 1156: reply.type = X_Reply; ! 1157: reply.length = (stringLens + fpr->npaths + 3) >> 2; ! 1158: reply.nFonts = fpr->npaths; ! 1159: reply.sequenceNumber = client->sequence; ! 1160: ! 1161: bufptr = bufferStart = (char *)ALLOCATE_LOCAL(reply.length << 2); ! 1162: if(!bufptr) ! 1163: return(client->noClientException = BadAlloc); ! 1164: ! 1165: /* since WriteToClient long word aligns things, ! 1166: copy to temp buffer and write all at once */ ! 1167: for (i=0; i<fpr->npaths; i++) ! 1168: { ! 1169: *bufptr++ = fpr->length[i]; ! 1170: bcopy(fpr->paths[i], bufptr, fpr->length[i]); ! 1171: bufptr += fpr->length[i]; ! 1172: } ! 1173: WriteReplyToClient(client, sizeof(xListFontsReply), &reply); ! 1174: WriteToClient(client, stringLens + fpr->npaths, bufferStart); ! 1175: FreeFontRecord(fpr); ! 1176: DEALLOCATE_LOCAL(bufferStart); ! 1177: ! 1178: return(client->noClientException); ! 1179: } ! 1180: ! 1181: int ! 1182: ProcListFontsWithInfo(client) ! 1183: register ClientPtr client; ! 1184: { ! 1185: register xListFontsWithInfoReply *reply; ! 1186: xListFontsWithInfoReply last_reply; ! 1187: FontRec font; ! 1188: FontInfoRec finfo; ! 1189: register FontPathPtr fpaths; ! 1190: register char **path; ! 1191: register int n, *length; ! 1192: int rlength; ! 1193: REQUEST(xListFontsWithInfoReq); ! 1194: ! 1195: REQUEST_AT_LEAST_SIZE(xListFontsWithInfoReq); ! 1196: ! 1197: fpaths = ExpandFontNamePattern( stuff->nbytes, &stuff[1], stuff->maxNames); ! 1198: font.pFI = &finfo; ! 1199: for (n = fpaths->npaths, path = fpaths->paths, length = fpaths->length; ! 1200: --n >= 0; ! 1201: path++, length++) ! 1202: { ! 1203: if (!(DescribeFont(*path, *length, &finfo, &font.pFP))) ! 1204: continue; ! 1205: rlength = sizeof(xListFontsWithInfoReply) ! 1206: + finfo.nProps * sizeof(xFontProp); ! 1207: if (reply = (xListFontsWithInfoReply *)ALLOCATE_LOCAL(rlength)) ! 1208: { ! 1209: reply->type = X_Reply; ! 1210: reply->sequenceNumber = client->sequence; ! 1211: reply->length = (rlength - sizeof(xGenericReply) ! 1212: + *length + 3) >> 2; ! 1213: QueryFont(&font, (xQueryFontReply *) reply, 0); ! 1214: reply->nameLength = *length; ! 1215: reply->nReplies = n; ! 1216: WriteReplyToClient(client, rlength, reply); ! 1217: WriteToClient(client, *length, *path); ! 1218: DEALLOCATE_LOCAL(reply); ! 1219: } ! 1220: Xfree((char *)font.pFP); ! 1221: } ! 1222: FreeFontRecord(fpaths); ! 1223: bzero((char *)&last_reply, sizeof(xListFontsWithInfoReply)); ! 1224: last_reply.type = X_Reply; ! 1225: last_reply.sequenceNumber = client->sequence; ! 1226: last_reply.length = (sizeof(xListFontsWithInfoReply) ! 1227: - sizeof(xGenericReply)) >> 2; ! 1228: WriteReplyToClient(client, sizeof(xListFontsWithInfoReply), &last_reply); ! 1229: return(client->noClientException); ! 1230: } ! 1231: ! 1232: int ! 1233: ProcCreatePixmap(client) ! 1234: register ClientPtr client; ! 1235: { ! 1236: PixmapPtr pMap; ! 1237: register DrawablePtr pDraw; ! 1238: REQUEST(xCreatePixmapReq); ! 1239: DepthPtr pDepth; ! 1240: register int i; ! 1241: ! 1242: REQUEST_AT_LEAST_SIZE(xCreatePixmapReq); ! 1243: client->errorValue = stuff->pid; ! 1244: LEGAL_NEW_RESOURCE(stuff->pid); ! 1245: if (!(pDraw = LOOKUP_DRAWABLE(stuff->drawable, client))) ! 1246: { /* can be inputonly */ ! 1247: if (!(pDraw = (DrawablePtr)LookupWindow(stuff->drawable, client))) ! 1248: return (BadDrawable); ! 1249: } ! 1250: ! 1251: if (!stuff->width || !stuff->height) ! 1252: return BadValue; ! 1253: if (stuff->depth != 1) ! 1254: { ! 1255: pDepth = pDraw->pScreen->allowedDepths; ! 1256: for (i=0; i<pDraw->pScreen->numDepths; i++, pDepth++) ! 1257: if (pDepth->depth == stuff->depth) ! 1258: goto CreatePmap; ! 1259: return BadValue; ! 1260: } ! 1261: CreatePmap: ! 1262: pMap = (PixmapPtr)(*pDraw->pScreen->CreatePixmap) ! 1263: (pDraw->pScreen, stuff->width, ! 1264: stuff->height, stuff->depth); ! 1265: if (pMap) ! 1266: { ! 1267: pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER; ! 1268: AddResource( ! 1269: stuff->pid, RT_PIXMAP, pMap, pDraw->pScreen->DestroyPixmap, ! 1270: RC_CORE); ! 1271: return(client->noClientException); ! 1272: } ! 1273: else ! 1274: return (BadAlloc); ! 1275: } ! 1276: ! 1277: int ! 1278: ProcFreePixmap(client) ! 1279: register ClientPtr client; ! 1280: { ! 1281: PixmapPtr pMap; ! 1282: ! 1283: REQUEST(xResourceReq); ! 1284: ! 1285: REQUEST_SIZE_MATCH(xResourceReq); ! 1286: pMap = (PixmapPtr)LookupID(stuff->id, RT_PIXMAP, RC_CORE); ! 1287: if (pMap) ! 1288: { ! 1289: FreeResource(stuff->id, RC_NONE); ! 1290: return(client->noClientException); ! 1291: } ! 1292: else ! 1293: { ! 1294: client->errorValue = stuff->id; ! 1295: return (BadPixmap); ! 1296: } ! 1297: } ! 1298: ! 1299: int ! 1300: ProcCreateGC(client) ! 1301: register ClientPtr client; ! 1302: { ! 1303: int error; ! 1304: GC *pGC; ! 1305: register DrawablePtr pDraw; ! 1306: int len; ! 1307: REQUEST(xCreateGCReq); ! 1308: ! 1309: REQUEST_AT_LEAST_SIZE(xCreateGCReq); ! 1310: client->errorValue = stuff->gc; ! 1311: LEGAL_NEW_RESOURCE(stuff->gc); ! 1312: if (!(pDraw = LOOKUP_DRAWABLE( stuff->drawable, client) )) ! 1313: return (BadDrawable); ! 1314: len = stuff->length - (sizeof(xCreateGCReq) >> 2); ! 1315: if (len != Ones(stuff->mask)) ! 1316: return BadLength; ! 1317: pGC = (GC *)CreateGC(pDraw, stuff->mask, ! 1318: (char *) &stuff[1], &error); ! 1319: if (error != Success) ! 1320: return error; ! 1321: if (pGC) ! 1322: { ! 1323: AddResource(stuff->gc, RT_GC, pGC, FreeGC, RC_CORE); ! 1324: return(client->noClientException); ! 1325: } ! 1326: else ! 1327: return (BadAlloc); ! 1328: } ! 1329: ! 1330: int ! 1331: ProcChangeGC(client) ! 1332: register ClientPtr client; ! 1333: { ! 1334: GC *pGC; ! 1335: REQUEST(xChangeGCReq); ! 1336: int result, len; ! 1337: ! 1338: REQUEST_AT_LEAST_SIZE(xChangeGCReq); ! 1339: VERIFY_GC(pGC, stuff->gc, client); ! 1340: len = stuff->length - (sizeof(xChangeGCReq) >> 2); ! 1341: if (len != Ones(stuff->mask)) ! 1342: return BadLength; ! 1343: result = DoChangeGC(pGC, stuff->mask, (int *) &stuff[1], 0); ! 1344: if (client->noClientException != Success) ! 1345: return(client->noClientException); ! 1346: else ! 1347: return(result); ! 1348: } ! 1349: ! 1350: int ! 1351: ProcCopyGC(client) ! 1352: register ClientPtr client; ! 1353: { ! 1354: register GC *dstGC; ! 1355: register GC *pGC; ! 1356: REQUEST(xCopyGCReq); ! 1357: ! 1358: REQUEST_SIZE_MATCH(xCopyGCReq); ! 1359: VERIFY_GC( pGC, stuff->srcGC, client); ! 1360: VERIFY_GC( dstGC, stuff->dstGC, client); ! 1361: if ((dstGC->pScreen != pGC->pScreen) || (dstGC->depth != pGC->depth)) ! 1362: return (BadMatch); ! 1363: CopyGC(pGC, dstGC, stuff->mask); ! 1364: return (client->noClientException); ! 1365: } ! 1366: ! 1367: int ! 1368: ProcSetDashes(client) ! 1369: register ClientPtr client; ! 1370: { ! 1371: register GC *pGC; ! 1372: int result; ! 1373: REQUEST(xSetDashesReq); ! 1374: ! 1375: REQUEST_AT_LEAST_SIZE(xSetDashesReq); ! 1376: if ((sizeof(xSetDashesReq) >> 2) == stuff->length) ! 1377: return BadValue; ! 1378: ! 1379: VERIFY_GC(pGC,stuff->gc, client); ! 1380: ! 1381: result = SetDashes(pGC, stuff->dashOffset, stuff->nDashes, &stuff[1]); ! 1382: if (client->noClientException != Success) ! 1383: return(client->noClientException); ! 1384: else ! 1385: return(result); ! 1386: } ! 1387: ! 1388: int ! 1389: ProcSetClipRectangles(client) ! 1390: register ClientPtr client; ! 1391: { ! 1392: int nr; ! 1393: register GC *pGC; ! 1394: REQUEST(xSetClipRectanglesReq); ! 1395: ! 1396: REQUEST_AT_LEAST_SIZE(xSetClipRectanglesReq); ! 1397: if ((stuff->ordering != Unsorted) && (stuff->ordering != YSorted) && ! 1398: (stuff->ordering != YXSorted) && (stuff->ordering != YXBanded)) ! 1399: return BadValue; ! 1400: VERIFY_GC(pGC,stuff->gc, client); ! 1401: pGC->clipOrg.x = stuff->xOrigin; ! 1402: pGC->stateChanges |= GCClipXOrigin; ! 1403: ! 1404: pGC->clipOrg.y = stuff->yOrigin; ! 1405: pGC->stateChanges |= GCClipYOrigin; ! 1406: ! 1407: nr = ((stuff->length << 2) - sizeof(xSetClipRectanglesReq)) >> 3; ! 1408: SetClipRects(pGC, nr, &stuff[1], stuff->ordering); ! 1409: pGC->stateChanges |= GCClipMask; ! 1410: pGC->serialNumber = 0; ! 1411: return(client->noClientException); ! 1412: } ! 1413: ! 1414: int ! 1415: ProcFreeGC(client) ! 1416: register ClientPtr client; ! 1417: { ! 1418: register GC *pGC; ! 1419: REQUEST(xResourceReq); ! 1420: ! 1421: REQUEST_SIZE_MATCH(xResourceReq); ! 1422: VERIFY_GC(pGC,stuff->id,client); ! 1423: FreeResource(stuff->id, RC_NONE); ! 1424: return(client->noClientException); ! 1425: } ! 1426: ! 1427: int ! 1428: ProcClearToBackground(client) ! 1429: register ClientPtr client; ! 1430: { ! 1431: REQUEST(xClearAreaReq); ! 1432: register WindowPtr pWin; ! 1433: ! 1434: REQUEST_SIZE_MATCH(xClearAreaReq); ! 1435: pWin = (WindowPtr)LookupWindow( stuff->window, client); ! 1436: if (!pWin) ! 1437: return(BadWindow); ! 1438: if (pWin->class == InputOnly) ! 1439: { ! 1440: client->errorValue = stuff->window; ! 1441: return (BadWindow); ! 1442: } ! 1443: if ((stuff->exposures != xTrue) && (stuff->exposures != xFalse)) ! 1444: return(BadValue); ! 1445: (*pWin->ClearToBackground)(pWin, stuff->x, stuff->y, ! 1446: stuff->width, stuff->height, ! 1447: (Bool)stuff->exposures); ! 1448: return(client->noClientException); ! 1449: } ! 1450: ! 1451: int ! 1452: ProcCopyArea(client) ! 1453: register ClientPtr client; ! 1454: { ! 1455: register DrawablePtr pDst; ! 1456: register DrawablePtr pSrc; ! 1457: register GC *pGC; ! 1458: REQUEST(xCopyAreaReq); ! 1459: ! 1460: REQUEST_SIZE_MATCH(xCopyAreaReq); ! 1461: ! 1462: VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pDst, pGC, client); ! 1463: if (stuff->dstDrawable != stuff->srcDrawable) ! 1464: { ! 1465: if (!(pSrc = LOOKUP_DRAWABLE(stuff->srcDrawable, client))) ! 1466: return(BadDrawable); ! 1467: if ((pDst->pScreen != pSrc->pScreen) || (pDst->depth != pSrc->depth)) ! 1468: { ! 1469: client->errorValue = stuff->dstDrawable; ! 1470: return (BadMatch); ! 1471: } ! 1472: } ! 1473: else ! 1474: pSrc = pDst; ! 1475: (*pGC->CopyArea)(pSrc, pDst, pGC, stuff->srcX, stuff->srcY, ! 1476: stuff->width, stuff->height, ! 1477: stuff->dstX, stuff->dstY); ! 1478: ! 1479: return(client->noClientException); ! 1480: } ! 1481: ! 1482: int ! 1483: ProcCopyPlane(client) ! 1484: register ClientPtr client; ! 1485: { ! 1486: register DrawablePtr psrcDraw, pdstDraw; ! 1487: register GC *pGC; ! 1488: REQUEST(xCopyPlaneReq); ! 1489: ! 1490: REQUEST_SIZE_MATCH(xCopyPlaneReq); ! 1491: ! 1492: /* Check to see if stuff->bitPlane has exactly ONE bit set */ ! 1493: if(stuff->bitPlane == 0 || stuff->bitPlane & (stuff->bitPlane - 1)) ! 1494: return(BadValue); ! 1495: ! 1496: VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pdstDraw, pGC, client); ! 1497: if (stuff->dstDrawable != stuff->srcDrawable) ! 1498: { ! 1499: if (!(psrcDraw = LOOKUP_DRAWABLE(stuff->srcDrawable, client))) ! 1500: return(BadDrawable); ! 1501: if (pdstDraw->pScreen != psrcDraw->pScreen) ! 1502: { ! 1503: client->errorValue = stuff->dstDrawable; ! 1504: return (BadMatch); ! 1505: } ! 1506: } ! 1507: else ! 1508: psrcDraw = pdstDraw; ! 1509: (*pGC->CopyPlane)(psrcDraw, pdstDraw, pGC, stuff->srcX, stuff->srcY, ! 1510: stuff->width, stuff->height, ! 1511: stuff->dstX, stuff->dstY, stuff->bitPlane); ! 1512: return(client->noClientException); ! 1513: } ! 1514: ! 1515: int ! 1516: ProcPolyPoint(client) ! 1517: register ClientPtr client; ! 1518: { ! 1519: int npoint; ! 1520: register GC *pGC; ! 1521: register DrawablePtr pDraw; ! 1522: REQUEST(xPolyPointReq); ! 1523: ! 1524: REQUEST_AT_LEAST_SIZE(xPolyPointReq); ! 1525: if ((stuff->coordMode != CoordModeOrigin) && ! 1526: (stuff->coordMode != CoordModePrevious)) ! 1527: return BadValue; ! 1528: VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); ! 1529: npoint = ((stuff->length << 2) - sizeof(xPolyPointReq)) >> 2; ! 1530: if (npoint) ! 1531: (*pGC->PolyPoint)(pDraw, pGC, stuff->coordMode, npoint, ! 1532: (xPoint *) &stuff[1]); ! 1533: return (client->noClientException); ! 1534: } ! 1535: ! 1536: int ! 1537: ProcPolyLine(client) ! 1538: register ClientPtr client; ! 1539: { ! 1540: int npoint; ! 1541: register GC *pGC; ! 1542: register DrawablePtr pDraw; ! 1543: REQUEST(xPolyLineReq); ! 1544: ! 1545: REQUEST_AT_LEAST_SIZE(xPolyLineReq); ! 1546: if ((stuff->coordMode != CoordModeOrigin) && ! 1547: (stuff->coordMode != CoordModePrevious)) ! 1548: return BadValue; ! 1549: VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); ! 1550: npoint = ((stuff->length << 2) - sizeof(xPolyLineReq)); ! 1551: if(npoint % sizeof(xPoint) != 0) ! 1552: return(BadLength); ! 1553: npoint >>= 2; ! 1554: if (npoint < 1) ! 1555: return(BadLength); ! 1556: ! 1557: (*pGC->Polylines)(pDraw, pGC, stuff->coordMode, npoint, ! 1558: (xPoint *) &stuff[1]); ! 1559: return(client->noClientException); ! 1560: } ! 1561: ! 1562: int ! 1563: ProcPolySegment(client) ! 1564: register ClientPtr client; ! 1565: { ! 1566: int nsegs; ! 1567: register GC *pGC; ! 1568: register DrawablePtr pDraw; ! 1569: REQUEST(xPolySegmentReq); ! 1570: ! 1571: REQUEST_AT_LEAST_SIZE(xPolySegmentReq); ! 1572: VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); ! 1573: nsegs = (stuff->length << 2) - sizeof(xPolySegmentReq); ! 1574: if(nsegs % sizeof(xSegment) != 0) ! 1575: return(BadLength); ! 1576: nsegs >>= 3; ! 1577: if (nsegs) ! 1578: (*pGC->PolySegment)(pDraw, pGC, nsegs, (xSegment *) &stuff[1]); ! 1579: return (client->noClientException); ! 1580: } ! 1581: ! 1582: int ! 1583: ProcPolyRectangle (client) ! 1584: register ClientPtr client; ! 1585: { ! 1586: int nrects; ! 1587: register GC *pGC; ! 1588: register DrawablePtr pDraw; ! 1589: REQUEST(xPolyRectangleReq); ! 1590: ! 1591: REQUEST_AT_LEAST_SIZE(xPolyRectangleReq); ! 1592: VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); ! 1593: nrects = ((stuff->length << 2) - sizeof(xPolyRectangleReq)) >> 3; ! 1594: if (nrects) ! 1595: (*pGC->PolyRectangle)(pDraw, pGC, ! 1596: nrects, (xRectangle *) &stuff[1]); ! 1597: return(client->noClientException); ! 1598: } ! 1599: ! 1600: int ! 1601: ProcPolyArc(client) ! 1602: register ClientPtr client; ! 1603: { ! 1604: int narcs; ! 1605: register GC *pGC; ! 1606: register DrawablePtr pDraw; ! 1607: REQUEST(xPolyArcReq); ! 1608: ! 1609: REQUEST_AT_LEAST_SIZE(xPolyArcReq); ! 1610: VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); ! 1611: narcs = ((stuff->length << 2) - sizeof(xPolyArcReq)) / ! 1612: sizeof(xArc); ! 1613: if (narcs) ! 1614: (*pGC->PolyArc)(pDraw, pGC, narcs, (xArc *) &stuff[1]); ! 1615: return (client->noClientException); ! 1616: } ! 1617: ! 1618: int ! 1619: ProcFillPoly(client) ! 1620: register ClientPtr client; ! 1621: { ! 1622: int things; ! 1623: register GC *pGC; ! 1624: register DrawablePtr pDraw; ! 1625: REQUEST(xFillPolyReq); ! 1626: ! 1627: REQUEST_AT_LEAST_SIZE(xFillPolyReq); ! 1628: if ((stuff->shape != Complex) && (stuff->shape != Nonconvex) && ! 1629: (stuff->shape != Convex) && (stuff->coordMode != CoordModeOrigin) && ! 1630: (stuff->coordMode != CoordModePrevious)) ! 1631: return BadValue; ! 1632: ! 1633: VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); ! 1634: things = ((stuff->length << 2) - sizeof(xFillPolyReq)) >> 2; ! 1635: if (things) ! 1636: (*pGC->FillPolygon) (pDraw, pGC, stuff->shape, ! 1637: stuff->coordMode, things, ! 1638: (DDXPointPtr) &stuff[1]); ! 1639: return(client->noClientException); ! 1640: } ! 1641: ! 1642: int ! 1643: ProcPolyFillRectangle(client) ! 1644: register ClientPtr client; ! 1645: { ! 1646: int things; ! 1647: register GC *pGC; ! 1648: register DrawablePtr pDraw; ! 1649: REQUEST(xPolyFillRectangleReq); ! 1650: ! 1651: REQUEST_AT_LEAST_SIZE(xPolyFillRectangleReq); ! 1652: VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); ! 1653: things = ((stuff->length << 2) - ! 1654: sizeof(xPolyFillRectangleReq)) >> 3; ! 1655: if (things) ! 1656: (*pGC->PolyFillRect) (pDraw, pGC, things, ! 1657: (xRectangle *) &stuff[1]); ! 1658: return (client->noClientException); ! 1659: } ! 1660: ! 1661: int ! 1662: ProcPolyFillArc (client) ! 1663: register ClientPtr client; ! 1664: { ! 1665: int narcs; ! 1666: register GC *pGC; ! 1667: register DrawablePtr pDraw; ! 1668: REQUEST(xPolyFillArcReq); ! 1669: ! 1670: REQUEST_AT_LEAST_SIZE(xPolyFillArcReq); ! 1671: VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); ! 1672: narcs = ((stuff->length << 2) - ! 1673: sizeof(xPolyFillArcReq)) / sizeof(xArc); ! 1674: if (narcs) ! 1675: (*pGC->PolyFillArc) (pDraw, pGC, narcs, (xArc *) &stuff[1]); ! 1676: return (client->noClientException); ! 1677: } ! 1678: ! 1679: int ! 1680: ProcPutImage(client) ! 1681: register ClientPtr client; ! 1682: { ! 1683: register GC *pGC; ! 1684: register DrawablePtr pDraw; ! 1685: REQUEST(xPutImageReq); ! 1686: ! 1687: REQUEST_AT_LEAST_SIZE(xPutImageReq); ! 1688: VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); ! 1689: if (stuff->format == XYBitmap) ! 1690: { ! 1691: if ((stuff->depth != 1) || (stuff->leftPad > screenInfo.bitmapScanlineUnit)) ! 1692: return BadMatch; ! 1693: } ! 1694: else if (stuff->format == XYPixmap) ! 1695: { ! 1696: if ((pDraw->depth != stuff->depth) || ! 1697: (stuff->leftPad > screenInfo.bitmapScanlineUnit)) ! 1698: return BadMatch; ! 1699: } ! 1700: else if (stuff->format == ZPixmap) ! 1701: { ! 1702: if ((pDraw->depth != stuff->depth) || (stuff->leftPad != 0)) ! 1703: return BadMatch; ! 1704: } ! 1705: else ! 1706: return BadValue; ! 1707: (*pGC->PutImage) (pDraw, pGC, stuff->depth, stuff->dstX, stuff->dstY, ! 1708: stuff->width, stuff->height, ! 1709: stuff->leftPad, stuff->format, ! 1710: (char *) &stuff[1]); ! 1711: return (client->noClientException); ! 1712: } ! 1713: ! 1714: int ! 1715: ProcGetImage(client) ! 1716: register ClientPtr client; ! 1717: { ! 1718: register DrawablePtr pDraw; ! 1719: int nlines, linesPerBuf, widthBytesLine; ! 1720: register int height, linesDone; ! 1721: int plane; ! 1722: char *pBuf; ! 1723: xGetImageReply xgi; ! 1724: ! 1725: REQUEST(xGetImageReq); ! 1726: ! 1727: height = stuff->height; ! 1728: REQUEST_SIZE_MATCH(xGetImageReq); ! 1729: if ((stuff->format != XYPixmap) && (stuff->format != ZPixmap)) ! 1730: return(BadValue); ! 1731: if(!(pDraw = LOOKUP_DRAWABLE(stuff->drawable, client) )) ! 1732: return (BadDrawable); ! 1733: if(pDraw->type == DRAWABLE_WINDOW) ! 1734: { ! 1735: if( /* check for being on screen */ ! 1736: ((WindowPtr) pDraw)->absCorner.x + stuff->x < 0 || ! 1737: ((WindowPtr) pDraw)->absCorner.x + stuff->x + stuff->width > ! 1738: pDraw->pScreen->width || ! 1739: ((WindowPtr) pDraw)->absCorner.y + stuff->y < 0 || ! 1740: ((WindowPtr) pDraw)->absCorner.y + stuff->y + height > ! 1741: pDraw->pScreen->height || ! 1742: /* check for being inside of border */ ! 1743: stuff->x < -((WindowPtr)pDraw)->borderWidth || ! 1744: stuff->x + stuff->width > ! 1745: ((WindowPtr)pDraw)->borderWidth + ! 1746: ((WindowPtr)pDraw)->clientWinSize.width || ! 1747: stuff->y < -((WindowPtr)pDraw)->borderWidth || ! 1748: stuff->y + stuff->height > ! 1749: ((WindowPtr)pDraw)->borderWidth + ! 1750: ((WindowPtr)pDraw)->clientWinSize.height ! 1751: ) ! 1752: return(BadMatch); ! 1753: xgi.visual = ((WindowPtr) pDraw)->visual; ! 1754: } ! 1755: else ! 1756: { ! 1757: if((stuff->x < 0) || ! 1758: (stuff->x+stuff->width > ((PixmapPtr) pDraw)->width) || ! 1759: (stuff->y < 0) || ! 1760: (stuff->y+stuff->height > ((PixmapPtr) pDraw)->height) ! 1761: ) ! 1762: return(BadMatch); ! 1763: xgi.visual = None; ! 1764: } ! 1765: xgi.type = X_Reply; ! 1766: /* should this be set??? */ ! 1767: xgi.sequenceNumber = client->sequence; ! 1768: xgi.depth = pDraw->depth; ! 1769: if(stuff->format == ZPixmap) ! 1770: { ! 1771: widthBytesLine = PixmapBytePad(stuff->width, pDraw->depth); ! 1772: xgi.length = (widthBytesLine >> 2) * stuff->height; ! 1773: } ! 1774: else ! 1775: { ! 1776: widthBytesLine = PixmapBytePad(stuff->width, 1); ! 1777: xgi.length = (widthBytesLine >> 2) * stuff->height * ! 1778: /* only planes asked for */ ! 1779: Ones(stuff->planeMask & ((1 << pDraw->depth) - 1)); ! 1780: } ! 1781: linesPerBuf = IMAGE_BUFSIZE / widthBytesLine; ! 1782: if(!(pBuf = (char *) ALLOCATE_LOCAL(IMAGE_BUFSIZE))) ! 1783: return (client->noClientException = BadAlloc); ! 1784: ! 1785: WriteReplyToClient(client, sizeof (xGetImageReply), &xgi); ! 1786: ! 1787: if (stuff->format == ZPixmap) ! 1788: { ! 1789: linesDone = 0; ! 1790: while (height - linesDone > 0) ! 1791: { ! 1792: nlines = min(linesPerBuf, height - linesDone); ! 1793: (*pDraw->pScreen->GetImage) (pDraw, ! 1794: stuff->x, ! 1795: stuff->y + linesDone, ! 1796: stuff->width, ! 1797: nlines, ! 1798: stuff->format, ! 1799: stuff->planeMask, ! 1800: pBuf); ! 1801: /* Note that this is NOT a call to WriteSwappedDataToClient, ! 1802: as we do NOT byte swap */ ! 1803: WriteToClient(client, nlines * widthBytesLine, pBuf); ! 1804: linesDone += nlines; ! 1805: } ! 1806: } ! 1807: else ! 1808: { ! 1809: for (plane = 1 << (pDraw->depth - 1); plane; plane >>= 1) ! 1810: { ! 1811: if (stuff->planeMask & plane) ! 1812: { ! 1813: linesDone = 0; ! 1814: while (height - linesDone > 0) ! 1815: { ! 1816: nlines = min(linesPerBuf, height - linesDone); ! 1817: (*pDraw->pScreen->GetImage) (pDraw, ! 1818: stuff->x, ! 1819: stuff->y + linesDone, ! 1820: stuff->width, ! 1821: nlines, ! 1822: stuff->format, ! 1823: plane, ! 1824: pBuf); ! 1825: /* Note: NOT a call to WriteSwappedDataToClient, ! 1826: as we do NOT byte swap */ ! 1827: WriteToClient(client, nlines * widthBytesLine, pBuf); ! 1828: linesDone += nlines; ! 1829: } ! 1830: } ! 1831: } ! 1832: } ! 1833: DEALLOCATE_LOCAL(pBuf); ! 1834: return (client->noClientException); ! 1835: } ! 1836: ! 1837: ! 1838: int ! 1839: ProcPolyText(client) ! 1840: register ClientPtr client; ! 1841: { ! 1842: int xorg; ! 1843: REQUEST(xPolyTextReq); ! 1844: register DrawablePtr pDraw; ! 1845: register GC *pGC; ! 1846: register FontPtr pFont; ! 1847: ! 1848: int (* polyText)(); ! 1849: register unsigned char *pElt; ! 1850: unsigned char *pNextElt; ! 1851: unsigned char *endReq; ! 1852: int itemSize; ! 1853: ! 1854: #define TextEltHeader 2 ! 1855: #define FontShiftSize 5 ! 1856: ! 1857: REQUEST_AT_LEAST_SIZE(xPolyTextReq); ! 1858: VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); ! 1859: ! 1860: pElt = (unsigned char *)&stuff[1]; ! 1861: endReq = ((unsigned char *) stuff) + (stuff->length <<2); ! 1862: xorg = stuff->x; ! 1863: if (stuff->reqType == X_PolyText8) ! 1864: { ! 1865: polyText = pGC->PolyText8; ! 1866: itemSize = 1; ! 1867: } ! 1868: else ! 1869: { ! 1870: polyText = pGC->PolyText16; ! 1871: itemSize = 2; ! 1872: } ! 1873: ! 1874: while (endReq - pElt > TextEltHeader) ! 1875: { ! 1876: if (*pElt == FontChange) ! 1877: { ! 1878: Font fid; ! 1879: ! 1880: if (endReq - pElt < FontShiftSize) ! 1881: return (BadLength); ! 1882: fid = *(pElt+4) /* big-endian */ ! 1883: | *(pElt+3) << 8 ! 1884: | *(pElt+2) << 16 ! 1885: | *(pElt+1) << 24; ! 1886: pFont = (FontPtr)LookupID(fid, RT_FONT, RC_CORE); ! 1887: if (!pFont) ! 1888: { ! 1889: client->errorValue = fid; ! 1890: return (BadFont); ! 1891: } ! 1892: if (pFont != pGC->font) ! 1893: { ! 1894: DoChangeGC( pGC, GCFont, &fid, 0); ! 1895: ValidateGC(pDraw, pGC); ! 1896: } ! 1897: pElt += FontShiftSize; ! 1898: } ! 1899: else /* print a string */ ! 1900: { ! 1901: pNextElt = pElt + TextEltHeader + (*pElt)*itemSize; ! 1902: if ( pNextElt > endReq) ! 1903: return( BadLength); ! 1904: xorg += *((char *)(pElt + 1)); /* must be signed */ ! 1905: xorg = (* polyText)(pDraw, pGC, xorg, stuff->y, *pElt, ! 1906: pElt + TextEltHeader); ! 1907: pElt = pNextElt; ! 1908: } ! 1909: } ! 1910: return (client->noClientException); ! 1911: #undef TextEltHeader ! 1912: #undef FontShiftSize ! 1913: } ! 1914: ! 1915: int ! 1916: ProcImageText(client) ! 1917: register ClientPtr client; ! 1918: { ! 1919: register DrawablePtr pDraw; ! 1920: register GC *pGC; ! 1921: ! 1922: REQUEST(xImageTextReq); ! 1923: ! 1924: REQUEST_AT_LEAST_SIZE(xImageTextReq); ! 1925: VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); ! 1926: ! 1927: (*((stuff->reqType == X_ImageText8) ? pGC->ImageText8 : pGC->ImageText16)) ! 1928: (pDraw, pGC, stuff->x, stuff->y, stuff->nChars, &stuff[1]); ! 1929: return (client->noClientException); ! 1930: } ! 1931: ! 1932: ! 1933: int ! 1934: ProcCreateColormap(client) ! 1935: register ClientPtr client; ! 1936: { ! 1937: VisualPtr pVisual; ! 1938: ColormapPtr pmap; ! 1939: int mid; ! 1940: register WindowPtr pWin; ! 1941: REQUEST(xCreateColormapReq); ! 1942: int result; ! 1943: ! 1944: REQUEST_SIZE_MATCH(xCreateColormapReq); ! 1945: ! 1946: if ((stuff->alloc != AllocNone) && (stuff->alloc != AllocAll)) ! 1947: return(BadValue); ! 1948: mid = stuff->mid; ! 1949: LEGAL_NEW_RESOURCE(mid); ! 1950: pWin = (WindowPtr)LookupWindow(stuff->window, client); ! 1951: if (!pWin) ! 1952: return(BadWindow); ! 1953: ! 1954: pVisual = (VisualPtr)LookupID(stuff->visual, RT_VISUALID, RC_CORE); ! 1955: if ((!pVisual) || pVisual->screen != pWin->drawable.pScreen->myNum) ! 1956: { ! 1957: client->errorValue = stuff->visual; ! 1958: return(BadValue); ! 1959: } ! 1960: result = CreateColormap(mid, pWin->drawable.pScreen, ! 1961: pVisual, &pmap, stuff->alloc, client->index); ! 1962: if (client->noClientException != Success) ! 1963: return(client->noClientException); ! 1964: else ! 1965: return(result); ! 1966: } ! 1967: ! 1968: int ! 1969: ProcFreeColormap(client) ! 1970: register ClientPtr client; ! 1971: { ! 1972: ColormapPtr pmap; ! 1973: REQUEST(xResourceReq); ! 1974: ! 1975: REQUEST_SIZE_MATCH(xResourceReq); ! 1976: pmap = (ColormapPtr )LookupID(stuff->id, RT_COLORMAP, RC_CORE); ! 1977: if (pmap) ! 1978: { ! 1979: FreeColormap(pmap, (client->index << CLIENTOFFSET)); ! 1980: FreeResource(stuff->id, RC_NONE); ! 1981: return (client->noClientException); ! 1982: } ! 1983: else ! 1984: { ! 1985: client->errorValue = stuff->id; ! 1986: return (BadColor); ! 1987: } ! 1988: } ! 1989: ! 1990: ! 1991: int ! 1992: ProcCopyColormapAndFree(client) ! 1993: register ClientPtr client; ! 1994: { ! 1995: int mid; ! 1996: ColormapPtr pSrcMap; ! 1997: REQUEST(xCopyColormapAndFreeReq); ! 1998: int result; ! 1999: ! 2000: REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq); ! 2001: mid = stuff->mid; ! 2002: LEGAL_NEW_RESOURCE(mid); ! 2003: if(pSrcMap = (ColormapPtr )LookupID(stuff->srcCmap, RT_COLORMAP, RC_CORE)) ! 2004: { ! 2005: result = CopyColormapAndFree(mid, pSrcMap, client->index); ! 2006: if (client->noClientException != Success) ! 2007: return(client->noClientException); ! 2008: else ! 2009: return(result); ! 2010: } ! 2011: else ! 2012: { ! 2013: client->errorValue = stuff->srcCmap; ! 2014: return(BadColor); ! 2015: } ! 2016: } ! 2017: ! 2018: int ! 2019: ProcInstallColormap(client) ! 2020: register ClientPtr client; ! 2021: { ! 2022: ColormapPtr pcmp; ! 2023: REQUEST(xResourceReq); ! 2024: ! 2025: REQUEST_SIZE_MATCH(xResourceReq); ! 2026: pcmp = (ColormapPtr )LookupID(stuff->id, RT_COLORMAP, RC_CORE); ! 2027: if (pcmp) ! 2028: { ! 2029: (*(pcmp->pScreen->InstallColormap)) (pcmp); ! 2030: return (client->noClientException); ! 2031: } ! 2032: else ! 2033: { ! 2034: client->errorValue = stuff->id; ! 2035: return (BadColor); ! 2036: } ! 2037: } ! 2038: ! 2039: int ! 2040: ProcUninstallColormap(client) ! 2041: register ClientPtr client; ! 2042: { ! 2043: ColormapPtr pcmp; ! 2044: REQUEST(xResourceReq); ! 2045: ! 2046: REQUEST_SIZE_MATCH(xResourceReq); ! 2047: pcmp = (ColormapPtr )LookupID(stuff->id, RT_COLORMAP, RC_CORE); ! 2048: if (pcmp) ! 2049: { ! 2050: if(pcmp->mid != pcmp->pScreen->defColormap) ! 2051: (*(pcmp->pScreen->UninstallColormap)) (pcmp); ! 2052: return (client->noClientException); ! 2053: } ! 2054: else ! 2055: { ! 2056: client->errorValue = stuff->id; ! 2057: return (BadColor); ! 2058: } ! 2059: } ! 2060: ! 2061: int ! 2062: ProcListInstalledColormaps(client) ! 2063: register ClientPtr client; ! 2064: { ! 2065: xListInstalledColormapsReply *preply; ! 2066: int nummaps; ! 2067: WindowPtr pWin; ! 2068: REQUEST(xResourceReq); ! 2069: ! 2070: REQUEST_SIZE_MATCH(xResourceReq); ! 2071: pWin = (WindowPtr)LookupWindow(stuff->id, client); ! 2072: ! 2073: if (!pWin) ! 2074: return(BadWindow); ! 2075: ! 2076: preply = (xListInstalledColormapsReply *) ! 2077: ALLOCATE_LOCAL(sizeof(xListInstalledColormapsReply) + ! 2078: pWin->drawable.pScreen->maxInstalledCmaps * ! 2079: sizeof(Colormap)); ! 2080: if(!preply) ! 2081: return(client->noClientException = BadAlloc); ! 2082: ! 2083: preply->type = X_Reply; ! 2084: preply->sequenceNumber = client->sequence; ! 2085: nummaps = (*pWin->drawable.pScreen->ListInstalledColormaps) ! 2086: (pWin->drawable.pScreen, (Colormap *)&preply[1]); ! 2087: preply->nColormaps = nummaps; ! 2088: preply->length = nummaps; ! 2089: WriteReplyToClient(client, sizeof (xListInstalledColormapsReply), preply); ! 2090: client->pSwapReplyFunc = Swap32Write; ! 2091: WriteSwappedDataToClient(client, nummaps * sizeof(Colormap), &preply[1]); ! 2092: DEALLOCATE_LOCAL(preply); ! 2093: return(client->noClientException); ! 2094: } ! 2095: ! 2096: int ! 2097: ProcAllocColor (client) ! 2098: register ClientPtr client; ! 2099: { ! 2100: ColormapPtr pmap; ! 2101: int retval; ! 2102: xAllocColorReply acr; ! 2103: REQUEST(xAllocColorReq); ! 2104: ! 2105: REQUEST_SIZE_MATCH(xAllocColorReq); ! 2106: pmap = (ColormapPtr )LookupID(stuff->cmap, RT_COLORMAP, RC_CORE); ! 2107: if (pmap) ! 2108: { ! 2109: acr.type = X_Reply; ! 2110: acr.length = 0; ! 2111: acr.sequenceNumber = client->sequence; ! 2112: acr.red = stuff->red; ! 2113: acr.green = stuff->green; ! 2114: acr.blue = stuff->blue; ! 2115: acr.pixel = 0; ! 2116: if(retval = AllocColor(pmap, &acr.red, &acr.green, &acr.blue, ! 2117: &acr.pixel, client->index)) ! 2118: { ! 2119: if (client->noClientException != Success) ! 2120: return(client->noClientException); ! 2121: else ! 2122: return (retval); ! 2123: } ! 2124: WriteReplyToClient(client, sizeof(xAllocColorReply), &acr); ! 2125: return (client->noClientException); ! 2126: ! 2127: } ! 2128: else ! 2129: { ! 2130: client->errorValue = stuff->cmap; ! 2131: return (BadColor); ! 2132: } ! 2133: } ! 2134: ! 2135: int ! 2136: ProcAllocNamedColor (client) ! 2137: register ClientPtr client; ! 2138: { ! 2139: ColormapPtr pcmp; ! 2140: REQUEST(xAllocNamedColorReq); ! 2141: ! 2142: REQUEST_AT_LEAST_SIZE(xAllocNamedColorReq); ! 2143: pcmp = (ColormapPtr )LookupID(stuff->cmap, RT_COLORMAP, RC_CORE); ! 2144: if (pcmp) ! 2145: { ! 2146: int retval; ! 2147: ! 2148: xAllocNamedColorReply ancr; ! 2149: ! 2150: ancr.type = X_Reply; ! 2151: ancr.length = 0; ! 2152: ancr.sequenceNumber = client->sequence; ! 2153: ! 2154: if(OsLookupColor(pcmp->pScreen->myNum, (char *)&stuff[1], stuff->nbytes, ! 2155: &ancr.exactRed, &ancr.exactGreen, &ancr.exactBlue)) ! 2156: { ! 2157: ancr.screenRed = ancr.exactRed; ! 2158: ancr.screenGreen = ancr.exactGreen; ! 2159: ancr.screenBlue = ancr.exactBlue; ! 2160: ancr.pixel = 0; ! 2161: if(retval = AllocColor(pcmp, ! 2162: &ancr.screenRed, &ancr.screenGreen, &ancr.screenBlue, ! 2163: &ancr.pixel, client->index)) ! 2164: { ! 2165: if (client->noClientException != Success) ! 2166: return(client->noClientException); ! 2167: else ! 2168: return(retval); ! 2169: } ! 2170: WriteReplyToClient(client, sizeof (xAllocNamedColorReply), &ancr); ! 2171: return (client->noClientException); ! 2172: } ! 2173: else ! 2174: return(BadName); ! 2175: ! 2176: } ! 2177: else ! 2178: { ! 2179: client->errorValue = stuff->cmap; ! 2180: return (BadColor); ! 2181: } ! 2182: } ! 2183: ! 2184: int ! 2185: ProcAllocColorCells (client) ! 2186: register ClientPtr client; ! 2187: { ! 2188: ColormapPtr pcmp; ! 2189: REQUEST(xAllocColorCellsReq); ! 2190: ! 2191: REQUEST_SIZE_MATCH(xAllocColorCellsReq); ! 2192: pcmp = (ColormapPtr )LookupID(stuff->cmap, RT_COLORMAP, RC_CORE); ! 2193: if (pcmp) ! 2194: { ! 2195: xAllocColorCellsReply accr; ! 2196: int npixels, nmasks, retval; ! 2197: unsigned long *ppixels, *pmasks; ! 2198: ! 2199: npixels = stuff->colors; ! 2200: nmasks = stuff->planes; ! 2201: ppixels = (unsigned long *)ALLOCATE_LOCAL(npixels * sizeof(long) + ! 2202: nmasks * sizeof(long)); ! 2203: if(!ppixels) ! 2204: return(client->noClientException = BadAlloc); ! 2205: pmasks = ppixels + npixels; ! 2206: ! 2207: if(retval = AllocColorCells(client->index, pcmp, npixels, nmasks, ! 2208: stuff->contiguous, ppixels, pmasks)) ! 2209: { ! 2210: DEALLOCATE_LOCAL(ppixels); ! 2211: if (client->noClientException != Success) ! 2212: return(client->noClientException); ! 2213: else ! 2214: return(retval); ! 2215: } ! 2216: accr.type = X_Reply; ! 2217: accr.length = ( (npixels + nmasks) * sizeof(long)) >> 2; ! 2218: accr.sequenceNumber = client->sequence; ! 2219: accr.nPixels = npixels; ! 2220: accr.nMasks = nmasks; ! 2221: WriteReplyToClient(client, sizeof (xAllocColorCellsReply), &accr); ! 2222: client->pSwapReplyFunc = Swap32Write; ! 2223: WriteSwappedDataToClient(client, (npixels + nmasks) * sizeof (long), ppixels); ! 2224: DEALLOCATE_LOCAL(ppixels); ! 2225: return (client->noClientException); ! 2226: } ! 2227: else ! 2228: { ! 2229: client->errorValue = stuff->cmap; ! 2230: return (BadColor); ! 2231: } ! 2232: } ! 2233: ! 2234: int ! 2235: ProcAllocColorPlanes(client) ! 2236: register ClientPtr client; ! 2237: { ! 2238: ColormapPtr pcmp; ! 2239: REQUEST(xAllocColorPlanesReq); ! 2240: ! 2241: REQUEST_SIZE_MATCH(xAllocColorPlanesReq); ! 2242: pcmp = (ColormapPtr )LookupID(stuff->cmap, RT_COLORMAP, RC_CORE); ! 2243: if (pcmp) ! 2244: { ! 2245: xAllocColorPlanesReply acpr; ! 2246: int npixels, retval; ! 2247: unsigned long *ppixels; ! 2248: ! 2249: npixels = stuff->colors; ! 2250: acpr.type = X_Reply; ! 2251: acpr.sequenceNumber = client->sequence; ! 2252: acpr.nPixels = npixels; ! 2253: npixels *= sizeof(long); ! 2254: ppixels = (unsigned long *)ALLOCATE_LOCAL(npixels); ! 2255: if(!ppixels) ! 2256: return(client->noClientException = BadAlloc); ! 2257: if(retval = AllocColorPlanes(client->index, pcmp, stuff->colors, ! 2258: stuff->red, stuff->green, stuff->blue, stuff->contiguous, ppixels, ! 2259: &acpr.redMask, &acpr.greenMask, &acpr.blueMask)) ! 2260: { ! 2261: DEALLOCATE_LOCAL(ppixels); ! 2262: if (client->noClientException != Success) ! 2263: return(client->noClientException); ! 2264: else ! 2265: return(retval); ! 2266: } ! 2267: acpr.length = npixels >> 2; ! 2268: WriteReplyToClient(client, sizeof(xAllocColorPlanesReply), &acpr); ! 2269: client->pSwapReplyFunc = Swap32Write; ! 2270: WriteSwappedDataToClient(client, npixels, ppixels); ! 2271: DEALLOCATE_LOCAL(ppixels); ! 2272: return (client->noClientException); ! 2273: } ! 2274: else ! 2275: { ! 2276: client->errorValue = stuff->cmap; ! 2277: return (BadColor); ! 2278: } ! 2279: } ! 2280: ! 2281: int ! 2282: ProcFreeColors (client) ! 2283: register ClientPtr client; ! 2284: { ! 2285: ColormapPtr pcmp; ! 2286: REQUEST(xFreeColorsReq); ! 2287: ! 2288: REQUEST_AT_LEAST_SIZE(xFreeColorsReq); ! 2289: pcmp = (ColormapPtr )LookupID(stuff->cmap, RT_COLORMAP, RC_CORE); ! 2290: if (pcmp) ! 2291: { ! 2292: int count; ! 2293: int retval; ! 2294: ! 2295: if(pcmp->flags & AllAllocated) ! 2296: return(BadAccess); ! 2297: count = ((stuff->length << 2)- sizeof(xFreeColorsReq)) >> 2; ! 2298: retval = FreeColors(pcmp, client->index, count, ! 2299: (unsigned long *)&stuff[1], stuff->planeMask); ! 2300: if (client->noClientException != Success) ! 2301: return(client->noClientException); ! 2302: else ! 2303: return(retval); ! 2304: ! 2305: } ! 2306: else ! 2307: { ! 2308: client->errorValue = stuff->cmap; ! 2309: return (BadColor); ! 2310: } ! 2311: } ! 2312: ! 2313: int ! 2314: ProcStoreColors (client) ! 2315: register ClientPtr client; ! 2316: { ! 2317: ColormapPtr pcmp; ! 2318: REQUEST(xStoreColorsReq); ! 2319: ! 2320: REQUEST_AT_LEAST_SIZE(xStoreColorsReq); ! 2321: pcmp = (ColormapPtr )LookupID(stuff->cmap, RT_COLORMAP, RC_CORE); ! 2322: if (pcmp) ! 2323: { ! 2324: int count; ! 2325: int retval; ! 2326: ! 2327: if(pcmp->flags & AllAllocated) ! 2328: if(CLIENT_ID(stuff->cmap) != client->index) ! 2329: return(BadAccess); ! 2330: count = ! 2331: ((stuff->length << 2) - sizeof(xStoreColorsReq)) / sizeof(xColorItem); ! 2332: retval = StoreColors(pcmp, count, (xColorItem *)&stuff[1]); ! 2333: if (client->noClientException != Success) ! 2334: return(client->noClientException); ! 2335: else ! 2336: return(retval); ! 2337: } ! 2338: else ! 2339: { ! 2340: client->errorValue = stuff->cmap; ! 2341: return (BadColor); ! 2342: } ! 2343: } ! 2344: ! 2345: int ! 2346: ProcStoreNamedColor (client) ! 2347: register ClientPtr client; ! 2348: { ! 2349: ColormapPtr pcmp; ! 2350: REQUEST(xStoreNamedColorReq); ! 2351: ! 2352: REQUEST_AT_LEAST_SIZE(xStoreNamedColorReq); ! 2353: pcmp = (ColormapPtr )LookupID(stuff->cmap, RT_COLORMAP, RC_CORE); ! 2354: if (pcmp) ! 2355: { ! 2356: xColorItem def; ! 2357: int retval; ! 2358: ! 2359: if(pcmp->flags & AllAllocated) ! 2360: if(CLIENT_ID(stuff->cmap) != client->index) ! 2361: return(BadAccess); ! 2362: ! 2363: if(OsLookupColor(pcmp->pScreen->myNum, (char *)&stuff[1], ! 2364: stuff->nbytes, &def.red, &def.green, &def.blue)) ! 2365: { ! 2366: def.flags = stuff->flags; ! 2367: retval = StoreColors(pcmp, 1, &def); ! 2368: if (client->noClientException != Success) ! 2369: return(client->noClientException); ! 2370: else ! 2371: return(retval); ! 2372: } ! 2373: return (BadName); ! 2374: } ! 2375: else ! 2376: { ! 2377: client->errorValue = stuff->cmap; ! 2378: return (BadColor); ! 2379: } ! 2380: } ! 2381: ! 2382: int ! 2383: ProcQueryColors(client) ! 2384: register ClientPtr client; ! 2385: { ! 2386: ColormapPtr pcmp; ! 2387: REQUEST(xQueryColorsReq); ! 2388: ! 2389: REQUEST_AT_LEAST_SIZE(xQueryColorsReq); ! 2390: pcmp = (ColormapPtr )LookupID(stuff->cmap, RT_COLORMAP, RC_CORE); ! 2391: if (pcmp) ! 2392: { ! 2393: int count, retval; ! 2394: xrgb *prgbs; ! 2395: xQueryColorsReply qcr; ! 2396: ! 2397: count = ((stuff->length << 2) - sizeof(xQueryColorsReq)) >> 2; ! 2398: if(!(prgbs = (xrgb *)ALLOCATE_LOCAL(count * sizeof(xrgb)))) ! 2399: return(client->noClientException = BadAlloc); ! 2400: if(retval = QueryColors(pcmp, count, (unsigned long *)&stuff[1], prgbs)) ! 2401: { ! 2402: DEALLOCATE_LOCAL(prgbs); ! 2403: if (client->noClientException != Success) ! 2404: return(client->noClientException); ! 2405: else ! 2406: return (retval); ! 2407: } ! 2408: qcr.type = X_Reply; ! 2409: qcr.length = (count * sizeof(xrgb)) >> 2; ! 2410: qcr.sequenceNumber = client->sequence; ! 2411: qcr.nColors = count; ! 2412: WriteReplyToClient(client, sizeof(xQueryColorsReply), &qcr); ! 2413: client->pSwapReplyFunc = SQColorsExtend; ! 2414: WriteSwappedDataToClient(client, count * sizeof(xrgb), prgbs); ! 2415: DEALLOCATE_LOCAL(prgbs); ! 2416: return(client->noClientException); ! 2417: ! 2418: } ! 2419: else ! 2420: { ! 2421: client->errorValue = stuff->cmap; ! 2422: return (BadColor); ! 2423: } ! 2424: } ! 2425: ! 2426: int ! 2427: ProcLookupColor(client) ! 2428: register ClientPtr client; ! 2429: { ! 2430: ColormapPtr pcmp; ! 2431: REQUEST(xLookupColorReq); ! 2432: ! 2433: REQUEST_AT_LEAST_SIZE(xLookupColorReq); ! 2434: pcmp = (ColormapPtr )LookupID(stuff->cmap, RT_COLORMAP, RC_CORE); ! 2435: if (pcmp) ! 2436: { ! 2437: xLookupColorReply lcr; ! 2438: ! 2439: if(OsLookupColor(pcmp->pScreen->myNum, (char *)&stuff[1], stuff->nbytes, ! 2440: &lcr.exactRed, &lcr.exactGreen, &lcr.exactBlue)) ! 2441: { ! 2442: lcr.type = X_Reply; ! 2443: lcr.length = 0; ! 2444: lcr.sequenceNumber = client->sequence; ! 2445: lcr.screenRed = lcr.exactRed; ! 2446: lcr.screenGreen = lcr.exactGreen; ! 2447: lcr.screenBlue = lcr.exactBlue; ! 2448: (*pcmp->pScreen->ResolveColor)(&lcr.screenRed, ! 2449: &lcr.screenGreen, ! 2450: &lcr.screenBlue); ! 2451: WriteReplyToClient(client, sizeof(xLookupColorReply), &lcr); ! 2452: return(client->noClientException); ! 2453: } ! 2454: return (BadName); ! 2455: } ! 2456: else ! 2457: { ! 2458: client->errorValue = stuff->cmap; ! 2459: return (BadColor); ! 2460: } ! 2461: } ! 2462: ! 2463: int ! 2464: ProcCreateCursor( client) ! 2465: register ClientPtr client; ! 2466: { ! 2467: CursorPtr pCursor; ! 2468: ! 2469: register PixmapPtr src; ! 2470: register PixmapPtr msk; ! 2471: unsigned int * srcbits; ! 2472: unsigned int * mskbits; ! 2473: int width, height; ! 2474: CursorMetricRec cm; ! 2475: ! 2476: ! 2477: REQUEST(xCreateCursorReq); ! 2478: ! 2479: REQUEST_SIZE_MATCH(xCreateCursorReq); ! 2480: LEGAL_NEW_RESOURCE(stuff->cid); ! 2481: ! 2482: src = (PixmapPtr)LookupID( stuff->source, RT_PIXMAP, RC_CORE); ! 2483: msk = (PixmapPtr)LookupID( stuff->mask, RT_PIXMAP, RC_CORE); ! 2484: if ( src == (PixmapPtr)NULL) ! 2485: return (BadPixmap); ! 2486: if ( msk == (PixmapPtr)NULL) ! 2487: msk = src; ! 2488: ! 2489: if ( src->width != msk->width ! 2490: || src->height != msk->height ! 2491: || src->drawable.depth != 1 ! 2492: || msk->drawable.depth != 1) ! 2493: return (BadMatch); ! 2494: ! 2495: width = src->width; ! 2496: height = src->height; ! 2497: ! 2498: if ( stuff->x > width ! 2499: || stuff->y > height ) ! 2500: return (BadMatch); ! 2501: ! 2502: srcbits = (unsigned int *)Xalloc( PixmapBytePad(width, 1)*height); ! 2503: mskbits = (unsigned int *)Xalloc( PixmapBytePad(width, 1)*height); ! 2504: ! 2505: (* src->drawable.pScreen->GetImage)( src, 0, 0, width, height, ! 2506: XYBitmap, 0xffffffff, srcbits); ! 2507: (* msk->drawable.pScreen->GetImage)( msk, 0, 0, width, height, ! 2508: XYBitmap, 0xffffffff, mskbits); ! 2509: cm.width = width; ! 2510: cm.height = height; ! 2511: cm.xhot = stuff->x; ! 2512: cm.yhot = stuff->y; ! 2513: pCursor = AllocCursor( srcbits, mskbits, &cm, ! 2514: stuff->foreRed, stuff->foreGreen, stuff->foreBlue, ! 2515: stuff->backRed, stuff->backGreen, stuff->backBlue); ! 2516: ! 2517: AddResource( stuff->cid, RT_CURSOR, pCursor, FreeCursor, RC_CORE); ! 2518: return (client->noClientException); ! 2519: } ! 2520: ! 2521: /* ! 2522: * protocol requires positioning of glyphs so hot-spots are coincident XXX ! 2523: */ ! 2524: int ! 2525: ProcCreateGlyphCursor( client) ! 2526: register ClientPtr client; ! 2527: { ! 2528: FontPtr sourcefont; ! 2529: FontPtr maskfont; ! 2530: char *srcbits; ! 2531: char *mskbits; ! 2532: CursorPtr pCursor; ! 2533: CursorMetricRec cm; ! 2534: int res; ! 2535: ! 2536: REQUEST(xCreateGlyphCursorReq); ! 2537: ! 2538: REQUEST_SIZE_MATCH(xCreateGlyphCursorReq); ! 2539: LEGAL_NEW_RESOURCE(stuff->cid); ! 2540: ! 2541: sourcefont = (FontPtr) LookupID(stuff->source, RT_FONT, RC_CORE); ! 2542: maskfont = (FontPtr) LookupID(stuff->mask, RT_FONT, RC_CORE); ! 2543: ! 2544: if (sourcefont == (FontPtr) NULL) ! 2545: { ! 2546: client->errorValue = stuff->source; ! 2547: return(BadFont); ! 2548: } ! 2549: ! 2550: if (maskfont == (FontPtr) NULL) ! 2551: { ! 2552: client->errorValue = stuff->mask; ! 2553: return(BadFont); ! 2554: } ! 2555: ! 2556: if (!CursorMetricsFromGlyph(maskfont, stuff->maskChar, &cm)) ! 2557: { ! 2558: client->errorValue = stuff->mask; ! 2559: return BadValue; ! 2560: } ! 2561: ! 2562: if (res = ServerBitsFromGlyph(stuff->source, ! 2563: sourcefont, stuff->sourceChar, ! 2564: &cm, &srcbits)) ! 2565: return res; ! 2566: if (res = ServerBitsFromGlyph(stuff->mask, ! 2567: maskfont, stuff->maskChar, ! 2568: &cm, &mskbits)) ! 2569: return res; ! 2570: ! 2571: pCursor = AllocCursor(srcbits, mskbits, &cm, ! 2572: stuff->foreRed, stuff->foreGreen, stuff->foreBlue, ! 2573: stuff->backRed, stuff->backGreen, stuff->backBlue); ! 2574: ! 2575: AddResource(stuff->cid, RT_CURSOR, pCursor, FreeCursor, RC_CORE); ! 2576: return client->noClientException; ! 2577: } ! 2578: ! 2579: ! 2580: int ! 2581: ProcFreeCursor(client) ! 2582: register ClientPtr client; ! 2583: { ! 2584: CursorPtr pCursor; ! 2585: REQUEST(xResourceReq); ! 2586: ! 2587: REQUEST_SIZE_MATCH(xResourceReq); ! 2588: pCursor = (CursorPtr)LookupID(stuff->id, RT_CURSOR, RC_CORE); ! 2589: if (pCursor) ! 2590: { ! 2591: FreeResource( stuff->id, RC_NONE); ! 2592: return (client->noClientException); ! 2593: } ! 2594: else ! 2595: { ! 2596: return (BadCursor); ! 2597: } ! 2598: } ! 2599: ! 2600: int ! 2601: ProcQueryBestSize (client) ! 2602: register ClientPtr client; ! 2603: { ! 2604: xQueryBestSizeReply reply; ! 2605: register DrawablePtr pDraw; ! 2606: ScreenPtr pScreen; ! 2607: REQUEST(xQueryBestSizeReq); ! 2608: ! 2609: REQUEST_SIZE_MATCH(xQueryBestSizeReq); ! 2610: if ((stuff->class != CursorShape) && ! 2611: (stuff->class != TileShape) && ! 2612: (stuff->class != StippleShape)) ! 2613: return(BadValue); ! 2614: if (!(pDraw = LOOKUP_DRAWABLE(stuff->drawable, client))) ! 2615: { ! 2616: client->errorValue = stuff->drawable; ! 2617: return (BadDrawable); ! 2618: } ! 2619: pScreen = pDraw->pScreen; ! 2620: (* pScreen->QueryBestSize)(stuff->class, &stuff->width, ! 2621: &stuff->height); ! 2622: reply.type = X_Reply; ! 2623: reply.length = 0; ! 2624: reply.sequenceNumber = client->sequence; ! 2625: reply.width = stuff->width; ! 2626: reply.height = stuff->height; ! 2627: WriteReplyToClient(client, sizeof(xQueryBestSizeReply), &reply); ! 2628: return (client->noClientException); ! 2629: } ! 2630: ! 2631: ! 2632: int ! 2633: ProcSetScreenSaver (client) ! 2634: register ClientPtr client; ! 2635: { ! 2636: int blankingOption, exposureOption; ! 2637: REQUEST(xSetScreenSaverReq); ! 2638: ! 2639: REQUEST_SIZE_MATCH(xSetScreenSaverReq); ! 2640: blankingOption = stuff->preferBlank; ! 2641: if ((blankingOption != DontPreferBlanking) && ! 2642: (blankingOption != PreferBlanking) && ! 2643: (blankingOption != DefaultBlanking)) ! 2644: return BadMatch; ! 2645: ! 2646: exposureOption = stuff->allowExpose; ! 2647: if ((exposureOption != DontAllowExposures) && ! 2648: (exposureOption != AllowExposures) && ! 2649: (exposureOption != DefaultExposures)) ! 2650: return BadMatch; ! 2651: ! 2652: if ((stuff->timeout < -1) || (stuff->interval < -1)) ! 2653: return BadMatch; ! 2654: ! 2655: ScreenSaverBlanking = blankingOption; ! 2656: ScreenSaverAllowExposures = exposureOption; ! 2657: ! 2658: if (stuff->timeout >= 0) ! 2659: ScreenSaverTime = stuff->timeout * MILLI_PER_SECOND; ! 2660: else ! 2661: ScreenSaverTime = DEFAULT_SCREEN_SAVER_TIME; ! 2662: if (stuff->interval > 0) ! 2663: ScreenSaverInterval = stuff->interval * MILLI_PER_SECOND; ! 2664: else ! 2665: ScreenSaverInterval = DEFAULT_SCREEN_SAVER_TIME; ! 2666: return (client->noClientException); ! 2667: } ! 2668: ! 2669: int ! 2670: ProcGetScreenSaver(client) ! 2671: register ClientPtr client; ! 2672: { ! 2673: xGetScreenSaverReply rep; ! 2674: ! 2675: rep.type = X_Reply; ! 2676: rep.length = 0; ! 2677: rep.sequenceNumber = client->sequence; ! 2678: rep.timeout = ScreenSaverTime / MILLI_PER_SECOND; ! 2679: rep.interval = ScreenSaverInterval / MILLI_PER_SECOND; ! 2680: rep.preferBlanking = ScreenSaverBlanking; ! 2681: rep.allowExposures = ScreenSaverAllowExposures; ! 2682: WriteReplyToClient(client, sizeof(xGetScreenSaverReply), &rep); ! 2683: return (client->noClientException); ! 2684: } ! 2685: ! 2686: int ! 2687: ProcChangeHosts(client) ! 2688: register ClientPtr client; ! 2689: { ! 2690: REQUEST(xChangeHostsReq); ! 2691: int result; ! 2692: ! 2693: REQUEST_AT_LEAST_SIZE(xChangeHostsReq); ! 2694: ! 2695: if(stuff->mode == HostInsert) ! 2696: result = AddHost(client, stuff->hostFamily, stuff->hostLength, ! 2697: &stuff[1]); ! 2698: else if (stuff->mode == HostDelete) ! 2699: result = RemoveHost(client, stuff->hostFamily, ! 2700: stuff->hostLength, &stuff[1]); ! 2701: else ! 2702: return BadValue; ! 2703: return (result || client->noClientException); ! 2704: } ! 2705: ! 2706: int ! 2707: ProcListHosts(client) ! 2708: register ClientPtr client; ! 2709: { ! 2710: extern int GetHosts(); ! 2711: xListHostsReply reply; ! 2712: int len, nHosts; ! 2713: pointer pdata; ! 2714: REQUEST(xListHostsReq); ! 2715: ! 2716: REQUEST_SIZE_MATCH(xListHostsReq); ! 2717: if((len = GetHosts(&pdata, &nHosts, &reply.enabled)) < 0) ! 2718: return(BadImplementation); ! 2719: reply.type = X_Reply; ! 2720: reply.sequenceNumber = client->sequence; ! 2721: reply.nHosts = nHosts; ! 2722: reply.length = len >> 2; ! 2723: WriteReplyToClient(client, sizeof(xListHostsReply), &reply); ! 2724: client->pSwapReplyFunc = SLHostsExtend; ! 2725: WriteSwappedDataToClient(client, len, pdata); ! 2726: Xfree(pdata); ! 2727: return (client->noClientException); ! 2728: } ! 2729: ! 2730: int ! 2731: ProcChangeAccessControl(client) ! 2732: register ClientPtr client; ! 2733: { ! 2734: REQUEST(xSetAccessControlReq); ! 2735: ! 2736: REQUEST_SIZE_MATCH(xSetAccessControlReq); ! 2737: if ((stuff->mode != EnableAccess) && (stuff->mode != DisableAccess)) ! 2738: return BadValue; ! 2739: ChangeAccessControl(client, stuff->mode == EnableAccess); ! 2740: return (client->noClientException); ! 2741: } ! 2742: ! 2743: int ! 2744: ProcKillClient(client) ! 2745: register ClientPtr client; ! 2746: { ! 2747: REQUEST(xResourceReq); ! 2748: ! 2749: pointer *pResource; ! 2750: int clientIndex; ! 2751: ! 2752: REQUEST_SIZE_MATCH(xResourceReq); ! 2753: if (stuff->id == AllTemporary) ! 2754: { ! 2755: CloseDownRetainedResources(); ! 2756: return (client->noClientException); ! 2757: } ! 2758: pResource = (pointer *)LookupID(stuff->id, RT_ANY, RC_CORE); ! 2759: ! 2760: clientIndex = CLIENT_ID(stuff->id); ! 2761: ! 2762: if (clientIndex && pResource) ! 2763: { ! 2764: if (clients[clientIndex] && !clients[clientIndex]->clientGone) ! 2765: { ! 2766: CloseDownClient(clients[clientIndex]); ! 2767: return (client->noClientException); ! 2768: } ! 2769: } ! 2770: else /* can't kill client 0, which is server */ ! 2771: { ! 2772: client->errorValue = stuff->id; ! 2773: return (BadValue); ! 2774: } ! 2775: } ! 2776: ! 2777: int ! 2778: ProcSetFontPath(client) ! 2779: register ClientPtr client; ! 2780: { ! 2781: REQUEST(xSetFontPathReq); ! 2782: ! 2783: REQUEST_AT_LEAST_SIZE(xSetFontPathReq); ! 2784: ! 2785: SetFontPath(stuff->nFonts, stuff->length, &stuff[1]); ! 2786: return (client->noClientException); ! 2787: } ! 2788: ! 2789: int ! 2790: ProcGetFontPath(client) ! 2791: register ClientPtr client; ! 2792: { ! 2793: FontPathPtr pFP; ! 2794: xGetFontPathReply reply; ! 2795: int stringLens, i; ! 2796: char *bufferStart; ! 2797: register char *bufptr; ! 2798: REQUEST (xReq); ! 2799: ! 2800: REQUEST_SIZE_MATCH(xReq); ! 2801: pFP = GetFontPath(); ! 2802: stringLens = 0; ! 2803: for (i=0; i<pFP->npaths; i++) ! 2804: stringLens += pFP->length[i]; ! 2805: ! 2806: reply.type = X_Reply; ! 2807: reply.sequenceNumber = client->sequence; ! 2808: reply.length = (stringLens + pFP->npaths + 3) >> 2; ! 2809: reply.nPaths = pFP->npaths; ! 2810: ! 2811: bufptr = bufferStart = (char *)ALLOCATE_LOCAL(reply.length << 2); ! 2812: if(!bufptr) ! 2813: return(client->noClientException = BadAlloc); ! 2814: /* since WriteToClient long word aligns things, ! 2815: copy to temp buffer and write all at once */ ! 2816: for (i=0; i<pFP->npaths; i++) ! 2817: { ! 2818: *bufptr++ = pFP->length[i]; ! 2819: bcopy(pFP->paths[i], bufptr, pFP->length[i]); ! 2820: bufptr += pFP->length[i]; ! 2821: } ! 2822: WriteReplyToClient(client, sizeof(xGetFontPathReply), &reply); ! 2823: WriteToClient(client, stringLens + pFP->npaths, bufferStart); ! 2824: DEALLOCATE_LOCAL(bufferStart); ! 2825: return(client->noClientException); ! 2826: } ! 2827: ! 2828: int ! 2829: ProcChangeCloseDownMode(client) ! 2830: register ClientPtr client; ! 2831: { ! 2832: REQUEST(xSetCloseDownModeReq); ! 2833: ! 2834: REQUEST_SIZE_MATCH(xSetCloseDownModeReq); ! 2835: if ((stuff->mode == AllTemporary) || ! 2836: (stuff->mode == RetainPermanent) || ! 2837: (stuff->mode == RetainTemporary)) ! 2838: { ! 2839: client->closeDownMode = stuff->mode; ! 2840: return (client->noClientException); ! 2841: } ! 2842: else ! 2843: { ! 2844: client->errorValue = stuff->mode; ! 2845: return (BadValue); ! 2846: } ! 2847: } ! 2848: ! 2849: int ProcForceScreenSaver(client) ! 2850: register ClientPtr client; ! 2851: { ! 2852: REQUEST(xForceScreenSaverReq); ! 2853: ! 2854: REQUEST_SIZE_MATCH(xForceScreenSaverReq); ! 2855: ! 2856: if ((stuff->mode != ScreenSaverReset) && ! 2857: (stuff->mode != ScreenSaverActive)) ! 2858: return BadValue; ! 2859: SaveScreens(SCREEN_SAVER_FORCER, stuff->mode); ! 2860: return client->noClientException; ! 2861: } ! 2862: ! 2863: int ProcNoOperation(client) ! 2864: register ClientPtr client; ! 2865: { ! 2866: REQUEST(xReq); ! 2867: ! 2868: REQUEST_AT_LEAST_SIZE(xReq); ! 2869: ! 2870: /* noop -- don't do anything */ ! 2871: return(client->noClientException); ! 2872: } ! 2873: ! 2874: extern void NotImplemented(); ! 2875: ! 2876: void ! 2877: InitProcVectors() ! 2878: { ! 2879: int i; ! 2880: for (i = 0; i<256; i++) ! 2881: { ! 2882: if(!ProcVector[i]) ! 2883: { ! 2884: ProcVector[i] = SwappedProcVector[i] = ProcBadRequest; ! 2885: ReplySwapVector[i] = NotImplemented; ! 2886: } ! 2887: } ! 2888: for(i = LASTEvent; i < 128; i++) ! 2889: { ! 2890: EventSwapVector[i] = NotImplemented; ! 2891: } ! 2892: ! 2893: } ! 2894: ! 2895: /********************** ! 2896: * CloseDownClient ! 2897: * ! 2898: * Client can either mark his resources destroy or retain. If retained and ! 2899: * then killed again, the client is really destroyed. ! 2900: *********************/ ! 2901: ! 2902: void ! 2903: CloseDownClient(client) ! 2904: register ClientPtr client; ! 2905: { ! 2906: extern void DeleteClientFromAnySelections(); ! 2907: register int i; ! 2908: /* ungrab server if grabbing client dies */ ! 2909: if (grabbingClient && (onlyClient == client)) ! 2910: { ! 2911: grabbingClient = FALSE; ! 2912: ListenToAllClients(); ! 2913: } ! 2914: DeleteClientFromAnySelections(client); ! 2915: ReleaseActiveGrabs(client); ! 2916: ! 2917: if (client->closeDownMode == DestroyAll) ! 2918: { ! 2919: client->clientGone = TRUE; /* so events aren't sent to client */ ! 2920: CloseDownConnection(client); ! 2921: FreeClientResources(client); ! 2922: for (i=0; i<currentMaxClients; i++) ! 2923: if (clients[i] == client) ! 2924: { ! 2925: nextFreeClientID = i; ! 2926: clients[nextFreeClientID] = NullClient; ! 2927: break; ! 2928: } ! 2929: Xfree(client); ! 2930: if(--nClients == 0) ! 2931: nClients = -1; ! 2932: } ! 2933: /* really kill resources this time */ ! 2934: else if (client->clientGone) ! 2935: { ! 2936: FreeClientResources(client); ! 2937: for (i=0; i<currentMaxClients; i++) ! 2938: if (clients[i] == client) ! 2939: { ! 2940: nextFreeClientID = i; ! 2941: clients[nextFreeClientID] = NullClient; ! 2942: break; ! 2943: } ! 2944: Xfree(client); ! 2945: --nClients; ! 2946: } ! 2947: else ! 2948: { ! 2949: client->clientGone = TRUE; ! 2950: CloseDownConnection(client); ! 2951: } ! 2952: } ! 2953: ! 2954: static void ! 2955: KillAllClients() ! 2956: { ! 2957: int i; ! 2958: for (i=1; i<currentMaxClients; i++) ! 2959: if (clients[i] && !clients[i]->clientGone) ! 2960: CloseDownClient(clients[i]); ! 2961: } ! 2962: ! 2963: void ! 2964: KillServerResources() ! 2965: { ! 2966: int i; ! 2967: ! 2968: KillAllClients(); ! 2969: /* Good thing we stashed these two in globals so we could get at them ! 2970: * here. */ ! 2971: CloseDownDevices(argcGlobal, argvGlobal); ! 2972: for (i = 0; i < screenInfo.numScreens; i++) ! 2973: (*screenInfo.screen[i].CloseScreen)(i, &screenInfo.screen[i]); ! 2974: } ! 2975: ! 2976: ! 2977: /********************* ! 2978: * CloseDownRetainedResources ! 2979: * ! 2980: * Find all clients that are gone and have terminated in RetainTemporary ! 2981: * and destroy their resources. ! 2982: *********************/ ! 2983: ! 2984: CloseDownRetainedResources() ! 2985: { ! 2986: register int i; ! 2987: register ClientPtr client; ! 2988: ! 2989: for (i=1; i<currentMaxClients; i++) ! 2990: { ! 2991: client = clients[i]; ! 2992: if (client && (client->closeDownMode == RetainTemporary) ! 2993: && (client->clientGone)) ! 2994: { ! 2995: FreeClientResources(client); ! 2996: nextFreeClientID = i; ! 2997: Xfree(client); ! 2998: clients[i] = NullClient; ! 2999: } ! 3000: } ! 3001: } ! 3002: ! 3003: /************************ ! 3004: * int NextAvailableClientID() ! 3005: * ! 3006: * OS depedent portion can't assign client id's because of CloseDownModes. ! 3007: * Returns -1 if the there are no free clients. ! 3008: *************************/ ! 3009: ! 3010: ClientPtr ! 3011: NextAvailableClient() ! 3012: { ! 3013: int i; ! 3014: ClientPtr client; ! 3015: ! 3016: if (nextFreeClientID >= currentMaxClients) ! 3017: nextFreeClientID = 1; ! 3018: if (!clients[nextFreeClientID]) ! 3019: { ! 3020: i = nextFreeClientID; ! 3021: nextFreeClientID++; ! 3022: } ! 3023: else ! 3024: { ! 3025: i = 1; ! 3026: while ((i<currentMaxClients) && (clients[i])) ! 3027: i++; ! 3028: if (i < currentMaxClients) ! 3029: nextFreeClientID = i; ! 3030: else ! 3031: { ! 3032: clients = (ClientPtr *)Xrealloc(clients, i * sizeof(ClientRec)); ! 3033: currentMaxClients++; ! 3034: } ! 3035: } ! 3036: clients[i] = client = (ClientPtr)Xalloc(sizeof(ClientRec)); ! 3037: client->index = i; ! 3038: client->sequence = 0; ! 3039: client->clientAsMask = i << CLIENTOFFSET; ! 3040: client->closeDownMode = DestroyAll; ! 3041: client->clientGone = FALSE; ! 3042: client->lastDrawable = (DrawablePtr) NULL; ! 3043: client->lastDrawableID = INVALID; ! 3044: client->lastGC = (GCPtr) NULL; ! 3045: client->lastGCID = -1; ! 3046: client->numSaved = 0; ! 3047: client->saveSet = (pointer *)NULL; ! 3048: client->noClientException = Success; ! 3049: ! 3050: return(client); ! 3051: } ! 3052: ! 3053: SendConnectionSetupInfo(client) ! 3054: ClientPtr client; ! 3055: { ! 3056: xWindowRoot *root; ! 3057: int i; ! 3058: ! 3059: ((xConnSetup *)ConnectionInfo)->ridBase = client->clientAsMask; ! 3060: ((xConnSetup *)ConnectionInfo)->ridMask = 0xfffff; ! 3061: /* fill in the "currentInputMask" */ ! 3062: root = (xWindowRoot *)(ConnectionInfo + connBlockScreenStart); ! 3063: for (i=0; i<screenInfo.numScreens; root += sizeof(xWindowRoot), i++) ! 3064: root->currentInputMask = WindowTable[i].allEventMasks; ! 3065: ! 3066: if (client->swapped) { ! 3067: WriteSConnSetupPrefix(client, &connSetupPrefix); ! 3068: WriteSConnectionInfo(client, connSetupPrefix.length << 2, ConnectionInfo); ! 3069: } ! 3070: else { ! 3071: WriteToClient(client, sizeof(xConnSetupPrefix), (char *) &connSetupPrefix); ! 3072: WriteToClient(client, connSetupPrefix.length << 2, ConnectionInfo); ! 3073: } ! 3074: } ! 3075: ! 3076: /***************** ! 3077: * Oops ! 3078: * Send an Error back to the client. ! 3079: *****************/ ! 3080: ! 3081: Oops (client, reqCode, minorCode, status) ! 3082: ClientPtr client; ! 3083: char reqCode, minorCode, status; ! 3084: { ! 3085: xError rep; ! 3086: register int i; ! 3087: ! 3088: rep.type = X_Error; ! 3089: rep.sequenceNumber = client->sequence; ! 3090: rep.errorCode = status; ! 3091: rep.majorCode = reqCode; ! 3092: rep.minorCode = minorCode; ! 3093: rep.resourceID = client->errorValue; ! 3094: ! 3095: for (i=0; i<currentMaxClients; i++) ! 3096: if (clients[i] == client) break; ! 3097: #ifdef notdef ! 3098: ErrorF( "OOPS! => client: %x, seq: %d, err: %d, maj:%d, min: %d resID: %x\n", ! 3099: client->index, rep.sequenceNumber, rep.errorCode, ! 3100: rep.majorCode, rep.minorCode, rep.resourceID); ! 3101: #endif ! 3102: ! 3103: WriteEventsToClient (client, 1, (xEvent *) &rep); ! 3104: } ! 3105: ! 3106: ! 3107: void ! 3108: DeleteWindowFromAnySelections(pWin) ! 3109: WindowPtr pWin; ! 3110: { ! 3111: int i = 0; ! 3112: ! 3113: for (i = 0; i< NumCurrentSelections; i++) ! 3114: if (CurrentSelections[i].pWin == pWin) ! 3115: { ! 3116: CurrentSelections[i].pWin = (WindowPtr)NULL; ! 3117: CurrentSelections[i].window = None; ! 3118: } ! 3119: } ! 3120: ! 3121: static void ! 3122: DeleteClientFromAnySelections(client) ! 3123: ClientPtr client; ! 3124: { ! 3125: int i = 0; ! 3126: ! 3127: for (i = 0; i< NumCurrentSelections; i++) ! 3128: if (CurrentSelections[i].client == client) ! 3129: { ! 3130: CurrentSelections[i].pWin = (WindowPtr)NULL; ! 3131: CurrentSelections[i].window = None; ! 3132: } ! 3133: } ! 3134: ! 3135: void ! 3136: MarkClientException(client) ! 3137: ClientPtr client; ! 3138: { ! 3139: client->noClientException = -1; ! 3140: } ! 3141: ! 3142: ! 3143: /* Byte swap a list of longs */ ! 3144: ! 3145: SwapLongs (list, count) ! 3146: register long *list; ! 3147: register int count; ! 3148: { ! 3149: register int n; ! 3150: ! 3151: while (count >= 8) { ! 3152: swapl(list+0, n); ! 3153: swapl(list+1, n); ! 3154: swapl(list+2, n); ! 3155: swapl(list+3, n); ! 3156: swapl(list+4, n); ! 3157: swapl(list+5, n); ! 3158: swapl(list+6, n); ! 3159: swapl(list+7, n); ! 3160: list += 8; ! 3161: count -= 8; ! 3162: } ! 3163: while (--count >= 0) { ! 3164: swapl(list, n); ! 3165: list++; ! 3166: } ! 3167: } ! 3168: ! 3169: /* Byte swap a list of shorts */ ! 3170: ! 3171: SwapShorts (list, count) ! 3172: register short *list; ! 3173: register int count; ! 3174: { ! 3175: register int n; ! 3176: ! 3177: while (count >= 16) { ! 3178: swaps(list+0, n); ! 3179: swaps(list+1, n); ! 3180: swaps(list+2, n); ! 3181: swaps(list+3, n); ! 3182: swaps(list+4, n); ! 3183: swaps(list+5, n); ! 3184: swaps(list+6, n); ! 3185: swaps(list+7, n); ! 3186: swaps(list+8, n); ! 3187: swaps(list+9, n); ! 3188: swaps(list+10, n); ! 3189: swaps(list+11, n); ! 3190: swaps(list+12, n); ! 3191: swaps(list+13, n); ! 3192: swaps(list+14, n); ! 3193: swaps(list+15, n); ! 3194: list += 16; ! 3195: count -= 16; ! 3196: } ! 3197: while (--count >= 0) ! 3198: { ! 3199: swaps(list, n); ! 3200: list++; ! 3201: } ! 3202: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.