📄 saver.c
字号:
if ((class == InputOutput) && (depth == 0)) depth = pParent->drawable.depth; ancwopt = pParent->optional; if (!ancwopt) ancwopt = FindWindowWithOptional(pParent)->optional; if (visual == CopyFromParent) visual = ancwopt->visual; /* Find out if the depth and visual are acceptable for this Screen */ if ((visual != ancwopt->visual) || (depth != pParent->drawable.depth)) { fOK = FALSE; for(idepth = 0; idepth < pScreen->numDepths; idepth++) { pDepth = (DepthPtr) &pScreen->allowedDepths[idepth]; if ((depth == pDepth->depth) || (depth == 0)) { for (ivisual = 0; ivisual < pDepth->numVids; ivisual++) { if (visual == pDepth->vids[ivisual]) { fOK = TRUE; break; } } } } if (fOK == FALSE) return BadMatch; } if (((stuff->mask & (CWBorderPixmap | CWBorderPixel)) == 0) && (class != InputOnly) && (depth != pParent->drawable.depth)) { return BadMatch; } if (((stuff->mask & CWColormap) == 0) && (class != InputOnly) && ((visual != ancwopt->visual) || (ancwopt->colormap == None))) { return BadMatch; } /* end of errors from CreateWindow */ pPriv = GetScreenPrivate (pScreen); if (pPriv && pPriv->attr) { if (pPriv->attr->client != client) return BadAccess; } if (!pPriv) { pPriv = MakeScreenPrivate (pScreen); if (!pPriv) return FALSE; } pAttr = New (ScreenSaverAttrRec); if (!pAttr) { ret = BadAlloc; goto bail; } /* over allocate for override redirect */ values = (unsigned long *) xalloc ((len + 1) * sizeof (unsigned long)); if (!values) { ret = BadAlloc; goto bail; } valuei = 0; pAttr->screen = pScreen; pAttr->client = client; pAttr->x = stuff->x; pAttr->y = stuff->y; pAttr->width = stuff->width; pAttr->height = stuff->height; pAttr->borderWidth = stuff->borderWidth; pAttr->class = stuff->c_class; pAttr->depth = depth; pAttr->visual = visual; pAttr->colormap = None; pAttr->pCursor = NullCursor; pAttr->pBackgroundPixmap = NullPixmap; pAttr->pBorderPixmap = NullPixmap; pAttr->values = values; /* * go through the mask, checking the values, * looking up pixmaps and cursors and hold a reference * to them. */ pAttr->mask = tmask = stuff->mask | CWOverrideRedirect; pVlist = (unsigned long *) (stuff + 1); while (tmask) { imask = lowbit (tmask); tmask &= ~imask; switch (imask) { case CWBackPixmap: pixID = (Pixmap )*pVlist; if (pixID == None) { *values++ = None; } else if (pixID == ParentRelative) { if (depth != pParent->drawable.depth) { ret = BadMatch; goto PatchUp; } *values++ = ParentRelative; } else { pPixmap = (PixmapPtr)LookupIDByType(pixID, RT_PIXMAP); if (pPixmap != (PixmapPtr) NULL) { if ((pPixmap->drawable.depth != depth) || (pPixmap->drawable.pScreen != pScreen)) { ret = BadMatch; goto PatchUp; } pAttr->pBackgroundPixmap = pPixmap; pPixmap->refcnt++; pAttr->mask &= ~CWBackPixmap; } else { ret = BadPixmap; client->errorValue = pixID; goto PatchUp; } } break; case CWBackPixel: *values++ = (CARD32) *pVlist; break; case CWBorderPixmap: pixID = (Pixmap ) *pVlist; if (pixID == CopyFromParent) { if (depth != pParent->drawable.depth) { ret = BadMatch; goto PatchUp; } *values++ = CopyFromParent; } else { pPixmap = (PixmapPtr)LookupIDByType(pixID, RT_PIXMAP); if (pPixmap) { if ((pPixmap->drawable.depth != depth) || (pPixmap->drawable.pScreen != pScreen)) { ret = BadMatch; goto PatchUp; } pAttr->pBorderPixmap = pPixmap; pPixmap->refcnt++; pAttr->mask &= ~CWBorderPixmap; } else { ret = BadPixmap; client->errorValue = pixID; goto PatchUp; } } break; case CWBorderPixel: *values++ = (CARD32) *pVlist; break; case CWBitGravity: val = (CARD8 )*pVlist; if (val > StaticGravity) { ret = BadValue; client->errorValue = val; goto PatchUp; } *values++ = val; break; case CWWinGravity: val = (CARD8 )*pVlist; if (val > StaticGravity) { ret = BadValue; client->errorValue = val; goto PatchUp; } *values++ = val; break; case CWBackingStore: val = (CARD8 )*pVlist; if ((val != NotUseful) && (val != WhenMapped) && (val != Always)) { ret = BadValue; client->errorValue = val; goto PatchUp; } *values++ = val; break; case CWBackingPlanes: *values++ = (CARD32) *pVlist; break; case CWBackingPixel: *values++ = (CARD32) *pVlist; break; case CWSaveUnder: val = (BOOL) *pVlist; if ((val != xTrue) && (val != xFalse)) { ret = BadValue; client->errorValue = val; goto PatchUp; } *values++ = val; break; case CWEventMask: *values++ = (CARD32) *pVlist; break; case CWDontPropagate: *values++ = (CARD32) *pVlist; break; case CWOverrideRedirect: if (!(stuff->mask & CWOverrideRedirect)) pVlist--; else { val = (BOOL ) *pVlist; if ((val != xTrue) && (val != xFalse)) { ret = BadValue; client->errorValue = val; goto PatchUp; } } *values++ = xTrue; break; case CWColormap: cmap = (Colormap) *pVlist; pCmap = (ColormapPtr)LookupIDByType(cmap, RT_COLORMAP); if (!pCmap) { ret = BadColor; client->errorValue = cmap; goto PatchUp; } if (pCmap->pVisual->vid != visual || pCmap->pScreen != pScreen) { ret = BadMatch; goto PatchUp; } pAttr->colormap = cmap; pAttr->mask &= ~CWColormap; break; case CWCursor: cursorID = (Cursor ) *pVlist; if ( cursorID == None) { *values++ = None; } else { pCursor = (CursorPtr)LookupIDByType(cursorID, RT_CURSOR); if (!pCursor) { ret = BadCursor; client->errorValue = cursorID; goto PatchUp; } pCursor->refcnt++; pAttr->pCursor = pCursor; pAttr->mask &= ~CWCursor; } break; default: ret = BadValue; client->errorValue = stuff->mask; goto PatchUp; } pVlist++; } if (pPriv->attr) FreeScreenAttr (pPriv->attr); pPriv->attr = pAttr; pAttr->resource = FakeClientID (client->index); if (!AddResource (pAttr->resource, AttrType, (pointer) pAttr)) return BadAlloc; return Success;PatchUp: FreeAttrs (pAttr);bail: CheckScreenPrivate (pScreen); xfree (pAttr); xfree (values); return ret;}static intProcScreenSaverUnsetAttributes (client) register ClientPtr client;{ REQUEST(xScreenSaverSetAttributesReq); DrawablePtr pDraw; ScreenSaverScreenPrivatePtr pPriv; REQUEST_SIZE_MATCH (xScreenSaverUnsetAttributesReq); pDraw = (DrawablePtr) LookupDrawable (stuff->drawable, client); if (!pDraw) return BadDrawable; pPriv = GetScreenPrivate (pDraw->pScreen); if (pPriv && pPriv->attr && pPriv->attr->client == client) { FreeScreenAttr (pPriv->attr); pPriv->attr = NULL; CheckScreenPrivate (pDraw->pScreen); } return Success;}static DISPATCH_PROC((*NormalVector[])) = { ProcScreenSaverQueryVersion, ProcScreenSaverQueryInfo, ProcScreenSaverSelectInput, ProcScreenSaverSetAttributes, ProcScreenSaverUnsetAttributes,};#define NUM_REQUESTS ((sizeof NormalVector) / (sizeof NormalVector[0]))static intProcScreenSaverDispatch (client) ClientPtr client;{ REQUEST(xReq); if (stuff->data < NUM_REQUESTS) return (*NormalVector[stuff->data])(client); return BadRequest;}static intSProcScreenSaverQueryVersion (client) ClientPtr client;{ REQUEST(xScreenSaverQueryVersionReq); int n; swaps (&stuff->length, n); REQUEST_SIZE_MATCH(xScreenSaverQueryVersionReq); return ProcScreenSaverQueryVersion (client);}static intSProcScreenSaverQueryInfo (client) ClientPtr client;{ REQUEST(xScreenSaverQueryInfoReq); int n; swaps (&stuff->length, n); REQUEST_SIZE_MATCH(xScreenSaverQueryInfoReq); swapl (&stuff->drawable, n); return ProcScreenSaverQueryInfo (client);}static intSProcScreenSaverSelectInput (client) ClientPtr client;{ REQUEST(xScreenSaverSelectInputReq); int n; swaps (&stuff->length, n); REQUEST_SIZE_MATCH(xScreenSaverSelectInputReq); swapl (&stuff->drawable, n); swapl (&stuff->eventMask, n); return ProcScreenSaverSelectInput (client);}static intSProcScreenSaverSetAttributes (client) ClientPtr client;{ REQUEST(xScreenSaverSetAttributesReq); int n; swaps (&stuff->length, n); REQUEST_AT_LEAST_SIZE(xScreenSaverSetAttributesReq); swapl (&stuff->drawable, n); swaps (&stuff->x, n); swaps (&stuff->y, n); swaps (&stuff->width, n); swaps (&stuff->height, n); swaps (&stuff->borderWidth, n); swapl (&stuff->visualID, n); swapl (&stuff->mask, n); SwapRestL(stuff); return ProcScreenSaverSetAttributes (client);}static intSProcScreenSaverUnsetAttributes (client) ClientPtr client;{ REQUEST(xScreenSaverUnsetAttributesReq); int n; swaps (&stuff->length, n); REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq); swapl (&stuff->drawable, n); return ProcScreenSaverUnsetAttributes (client);}static DISPATCH_PROC((*SwappedVector[])) = { SProcScreenSaverQueryVersion, SProcScreenSaverQueryInfo, SProcScreenSaverSelectInput, SProcScreenSaverSetAttributes, SProcScreenSaverUnsetAttributes,};static intSProcScreenSaverDispatch (client) ClientPtr client;{ REQUEST(xReq); if (stuff->data < NUM_REQUESTS) return (*SwappedVector[stuff->data])(client); return BadRequest;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -