📄 dispatch.c
字号:
if (grabState != GrabNone && client != grabClient) { ResetCurrentRequest(client); client->sequence--; BITSET(grabWaiters, client->index); IgnoreClient(client); return(client->noClientException); } OnlyListenToOneClient(client); grabState = GrabKickout; grabClient = client; if (ServerGrabCallback) { ServerGrabInfoRec grabinfo; grabinfo.client = client; grabinfo.grabstate = SERVER_GRABBED; CallCallbacks(&ServerGrabCallback, (pointer)&grabinfo); } return(client->noClientException);}static void#if NeedFunctionPrototypesUngrabServer(ClientPtr client)#elseUngrabServer(client) ClientPtr client;#endif{ int i; grabState = GrabNone; ListenToAllClients(); for (i = mskcnt; --i >= 0 && !grabWaiters[i]; ) ; if (i >= 0) { i <<= 5; while (!GETBIT(grabWaiters, i)) i++; BITCLEAR(grabWaiters, i); AttendClient(clients[i]); } if (ServerGrabCallback) { ServerGrabInfoRec grabinfo; grabinfo.client = client; grabinfo.grabstate = SERVER_UNGRABBED; CallCallbacks(&ServerGrabCallback, (pointer)&grabinfo); }}intProcUngrabServer(client) register ClientPtr client;{ REQUEST_SIZE_MATCH(xReq); UngrabServer(client); return(client->noClientException);}intProcTranslateCoords(client) register ClientPtr client;{ REQUEST(xTranslateCoordsReq); register WindowPtr pWin, pDst; xTranslateCoordsReply rep; REQUEST_SIZE_MATCH(xTranslateCoordsReq); pWin = (WindowPtr)SecurityLookupWindow(stuff->srcWid, client, SecurityReadAccess); if (!pWin) return(BadWindow); pDst = (WindowPtr)SecurityLookupWindow(stuff->dstWid, client, SecurityReadAccess); if (!pDst) return(BadWindow); rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; if (!SAME_SCREENS(pWin->drawable, pDst->drawable)) { rep.sameScreen = xFalse; rep.child = None; rep.dstX = rep.dstY = 0; } else { INT16 x, y; rep.sameScreen = xTrue; rep.child = None; /* computing absolute coordinates -- adjust to destination later */ x = pWin->drawable.x + stuff->srcX; y = pWin->drawable.y + stuff->srcY; pWin = pDst->firstChild; while (pWin) {#ifdef SHAPE BoxRec box;#endif if ((pWin->mapped) && (x >= pWin->drawable.x - wBorderWidth (pWin)) && (x < pWin->drawable.x + (int)pWin->drawable.width + wBorderWidth (pWin)) && (y >= pWin->drawable.y - wBorderWidth (pWin)) && (y < pWin->drawable.y + (int)pWin->drawable.height + wBorderWidth (pWin))#ifdef SHAPE /* When a window is shaped, a further check * is made to see if the point is inside * borderSize */ && (!wBoundingShape(pWin) || POINT_IN_REGION(pWin->drawable.pScreen, &pWin->borderSize, x, y, &box))#endif ) { rep.child = pWin->drawable.id; pWin = (WindowPtr) NULL; } else pWin = pWin->nextSib; } /* adjust to destination coordinates */ rep.dstX = x - pDst->drawable.x; rep.dstY = y - pDst->drawable.y; } WriteReplyToClient(client, sizeof(xTranslateCoordsReply), &rep); return(client->noClientException);}intProcOpenFont(client) register ClientPtr client;{ int err; REQUEST(xOpenFontReq); REQUEST_FIXED_SIZE(xOpenFontReq, stuff->nbytes); client->errorValue = stuff->fid; LEGAL_NEW_RESOURCE(stuff->fid, client); err = OpenFont(client, stuff->fid, (Mask) 0, stuff->nbytes, (char *)&stuff[1]); if (err == Success) { return(client->noClientException); } else return err;}intProcCloseFont(client) register ClientPtr client;{ FontPtr pFont; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); pFont = (FontPtr)SecurityLookupIDByType(client, stuff->id, RT_FONT, SecurityDestroyAccess); if ( pFont != (FontPtr)NULL) /* id was valid */ { FreeResource(stuff->id, RT_NONE); return(client->noClientException); } else { client->errorValue = stuff->id; return (BadFont); }}intProcQueryFont(client) register ClientPtr client;{ xQueryFontReply *reply; FontPtr pFont; register GC *pGC; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); client->errorValue = stuff->id; /* EITHER font or gc */ pFont = (FontPtr)SecurityLookupIDByType(client, stuff->id, RT_FONT, SecurityReadAccess); if (!pFont) { /* can't use VERIFY_GC because it might return BadGC */ pGC = (GC *) SecurityLookupIDByType(client, stuff->id, RT_GC, SecurityReadAccess); if (!pGC) { client->errorValue = stuff->id; return(BadFont); /* procotol spec says only error is BadFont */ } pFont = pGC->font; } { xCharInfo *pmax = FONTINKMAX(pFont); xCharInfo *pmin = FONTINKMIN(pFont); int nprotoxcistructs; int rlength; nprotoxcistructs = ( pmax->rightSideBearing == pmin->rightSideBearing && pmax->leftSideBearing == pmin->leftSideBearing && pmax->descent == pmin->descent && pmax->ascent == pmin->ascent && pmax->characterWidth == pmin->characterWidth) ? 0 : N2dChars(pFont); rlength = sizeof(xQueryFontReply) + FONTINFONPROPS(FONTCHARSET(pFont)) * sizeof(xFontProp) + nprotoxcistructs * sizeof(xCharInfo); reply = (xQueryFontReply *)ALLOCATE_LOCAL(rlength); if(!reply) { return(BadAlloc); } reply->type = X_Reply; reply->length = (rlength - sizeof(xGenericReply)) >> 2; reply->sequenceNumber = client->sequence; QueryFont( pFont, reply, nprotoxcistructs); WriteReplyToClient(client, rlength, reply); DEALLOCATE_LOCAL(reply); return(client->noClientException); }}intProcQueryTextExtents(client) register ClientPtr client;{ REQUEST(xQueryTextExtentsReq); xQueryTextExtentsReply reply; FontPtr pFont; GC *pGC; ExtentInfoRec info; unsigned long length; REQUEST_AT_LEAST_SIZE(xQueryTextExtentsReq); pFont = (FontPtr)SecurityLookupIDByType(client, stuff->fid, RT_FONT, SecurityReadAccess); if (!pFont) { pGC = (GC *)SecurityLookupIDByType(client, stuff->fid, RT_GC, SecurityReadAccess); if (!pGC) { client->errorValue = stuff->fid; return(BadFont); } pFont = pGC->font; } length = client->req_len - (sizeof(xQueryTextExtentsReq) >> 2); length = length << 1; if (stuff->oddLength) { if (length == 0) return(BadLength); length--; } if (!QueryTextExtents(pFont, length, (unsigned char *)&stuff[1], &info)) return(BadAlloc); reply.type = X_Reply; reply.length = 0; reply.sequenceNumber = client->sequence; reply.drawDirection = info.drawDirection; reply.fontAscent = info.fontAscent; reply.fontDescent = info.fontDescent; reply.overallAscent = info.overallAscent; reply.overallDescent = info.overallDescent; reply.overallWidth = info.overallWidth; reply.overallLeft = info.overallLeft; reply.overallRight = info.overallRight; WriteReplyToClient(client, sizeof(xQueryTextExtentsReply), &reply); return(client->noClientException);}intProcListFonts(client) register ClientPtr client;{ REQUEST(xListFontsReq); REQUEST_FIXED_SIZE(xListFontsReq, stuff->nbytes); return ListFonts(client, (unsigned char *) &stuff[1], stuff->nbytes, stuff->maxNames);}intProcListFontsWithInfo(client) register ClientPtr client;{ REQUEST(xListFontsWithInfoReq); REQUEST_FIXED_SIZE(xListFontsWithInfoReq, stuff->nbytes); return StartListFontsWithInfo(client, stuff->nbytes, (unsigned char *) &stuff[1], stuff->maxNames);}/*ARGSUSED*/intdixDestroyPixmap(value, pid) pointer value; /* must conform to DeleteType */ XID pid;{ PixmapPtr pPixmap = (PixmapPtr)value; return (*pPixmap->drawable.pScreen->DestroyPixmap)(pPixmap);}intProcCreatePixmap(client) register ClientPtr client;{ PixmapPtr pMap; register DrawablePtr pDraw; REQUEST(xCreatePixmapReq); DepthPtr pDepth; register int i; REQUEST_SIZE_MATCH(xCreatePixmapReq); client->errorValue = stuff->pid; LEGAL_NEW_RESOURCE(stuff->pid, client); SECURITY_VERIFY_GEOMETRABLE (pDraw, stuff->drawable, client, SecurityReadAccess); if (!stuff->width || !stuff->height) { client->errorValue = 0; return BadValue; } if (stuff->depth != 1) { pDepth = pDraw->pScreen->allowedDepths; for (i=0; i<pDraw->pScreen->numDepths; i++, pDepth++) if (pDepth->depth == stuff->depth) goto CreatePmap; client->errorValue = stuff->depth; return BadValue; }CreatePmap: pMap = (PixmapPtr)(*pDraw->pScreen->CreatePixmap) (pDraw->pScreen, stuff->width, stuff->height, stuff->depth); if (pMap) { pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER; pMap->drawable.id = stuff->pid; if (AddResource(stuff->pid, RT_PIXMAP, (pointer)pMap)) return(client->noClientException); } return (BadAlloc);}intProcFreePixmap(client) register ClientPtr client;{ PixmapPtr pMap; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); pMap = (PixmapPtr)SecurityLookupIDByType(client, stuff->id, RT_PIXMAP, SecurityDestroyAccess); if (pMap) { FreeResource(stuff->id, RT_NONE); return(client->noClientException); } else { client->errorValue = stuff->id; return (BadPixmap); }}intProcCreateGC(client) register ClientPtr client;{ int error; GC *pGC; register DrawablePtr pDraw; unsigned len; REQUEST(xCreateGCReq); REQUEST_AT_LEAST_SIZE(xCreateGCReq); client->errorValue = stuff->gc; LEGAL_NEW_RESOURCE(stuff->gc, client); SECURITY_VERIFY_DRAWABLE (pDraw, stuff->drawable, client, SecurityReadAccess); len = client->req_len - (sizeof(xCreateGCReq) >> 2); if (len != Ones(stuff->mask)) return BadLength; pGC = (GC *)CreateGC(pDraw, stuff->mask, (XID *) &stuff[1], &error); if (error != Success) return error; if (!AddResource(stuff->gc, RT_GC, (pointer)pGC)) return (BadAlloc); return(client->noClientException);}intProcChangeGC(client) register ClientPtr client;{ GC *pGC; REQUEST(xChangeGCReq); int result; unsigned len; REQUEST_AT_LEAST_SIZE(xChangeGCReq); SECURITY_VERIFY_GC(pGC, stuff->gc, client, SecurityWriteAccess); len = client->req_len - (sizeof(xChangeGCReq) >> 2); if (len != Ones(stuff->mask)) return BadLength; result = dixChangeGC(client, pGC, stuff->mask, (CARD32 *) &stuff[1], 0); if (client->noClientException != Success) return(client->noClientException); else { client->errorValue = clientErrorValue; return(result); }}intProcCopyGC(client) register ClientPtr client;{ register GC *dstGC; register GC *pGC; int result; REQUEST(xCopyGCReq); REQUEST_SIZE_MATCH(xCopyGCReq); SECURITY_VERIFY_GC( pGC, stuff->srcGC, client, SecurityReadAccess); SECURITY_VERIFY_GC( dstGC, stuff->dstGC, client, SecurityWriteAccess); if ((dstGC->pScreen != pGC->pScreen) || (dstGC->depth != pGC->depth)) return (BadMatch); result = CopyGC(pGC, dstGC, stuff->mask); if (client->noClientException != Success) return(client->noClientException); else { client->errorValue = clientErrorValue; return(result); }}intProcSetDashes(client) register ClientPtr client;{ register GC *pGC; int result; REQUEST(xSetDashesReq); REQUEST_FIXED_SIZE(xSetDashesReq, stuff->nDashes); if (stuff->nDashes == 0) { client->errorValue = 0; return BadValue; } SECURITY_VERIFY_GC(pGC,stuff->gc, client, SecurityWriteAccess); result = SetDashes(pGC, stuff->dashOffset, stuff->nDashes, (unsigned char *)&stuff[1]); if (client->noClientException != Success) return(client->noClientException); else { client->errorValue = clientErrorValue; return(result); }}intProcSetClipRectangles(client) register ClientPtr client;{ int nr; int result;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -