⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gc.c

📁 远程桌面连接工具
💻 C
📖 第 1 页 / 共 3 页
字号:
/***********************************************************Copyright (c) 1987  X ConsortiumPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included inall copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THEX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER INAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR INCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.Except as contained in this notice, the name of the X Consortium shall not beused in advertising or otherwise to promote the sale, use or other dealingsin this Software without prior written authorization from the X Consortium.Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.                        All Rights ReservedPermission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and thatboth that copyright notice and this permission notice appear in supporting documentation, and that the name of Digital not beused in advertising or publicity pertaining to distribution of thesoftware without specific, written prior permission.  DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDINGALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALLDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES ORANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THISSOFTWARE.******************************************************************//* $XConsortium: gc.c /main/70 1996/08/01 19:21:09 dpw $ *//* $XFree86: xc/programs/Xserver/dix/gc.c,v 3.4 1996/12/23 06:29:45 dawes Exp $ */#include "X.h"#include "Xmd.h"#include "Xproto.h"#include "misc.h"#include "resource.h"#include "gcstruct.h"#include "pixmapstr.h"#include "dixfontstr.h"#include "scrnintstr.h"#include "region.h"#include "dix.h"#include <assert.h>extern XID clientErrorValue;extern FontPtr defaultFont;static Bool CreateDefaultTile(#if NeedFunctionPrototypes    GCPtr /*pGC*/#endif);unsigned char DefaultDash[2] = {4, 4};voidValidateGC(pDraw, pGC)    DrawablePtr	pDraw;    GC		*pGC;{    (*pGC->funcs->ValidateGC) (pGC, pGC->stateChanges, pDraw);    pGC->stateChanges = 0;    pGC->serialNumber = pDraw->serialNumber;}/* dixChangeGC(client, pGC, mask, pC32, pUnion) *  * This function was created as part of the Security extension * implementation.  The client performing the gc change must be passed so * that access checks can be performed on any tiles, stipples, or fonts * that are specified.  ddxen can call this too; they should normally * pass NullClient for the client since any access checking should have * already been done at a higher level. *  * Since we had to create a new function anyway, we decided to change the * way the list of gc values is passed to eliminate the compiler warnings * caused by the DoChangeGC interface.  You can pass the values via pC32 * or pUnion, but not both; one of them must be NULL.  If you don't need * to pass any pointers, you can use either one: *  *     /* example calling dixChangeGC using pC32 parameter *     CARD32 v[2]; *     v[0] = foreground; *     v[1] = background; *     dixChangeGC(client, pGC, GCForeground|GCBackground, v, NULL); *  *     /* example calling dixChangeGC using pUnion parameter; *     /* same effect as above *     ChangeGCVal v[2]; *     v[0].val = foreground; *     v[1].val = background; *     dixChangeGC(client, pGC, GCForeground|GCBackground, NULL, v); *  * However, if you need to pass a pointer to a pixmap or font, you MUST * use the pUnion parameter. *  *     /* example calling dixChangeGC passing pointers in the value list *     ChangeGCVal v[2]; *     v[0].val = FillTiled; *     v[1].ptr = pPixmap; /* pointer to a pixmap *     dixChangeGC(client, pGC, GCFillStyle|GCTile, NULL, v); *  * Note: we could have gotten by with just the pUnion parameter, but on * 64 bit machines that would have forced us to copy the value list that * comes in the ChangeGC request. *  * Ideally, we'd change all the DoChangeGC calls to dixChangeGC, but this * is far too many changes to consider at this time, so we've only * changed the ones that caused compiler warnings.  New code should use * dixChangeGC. *  * dpw */#define NEXTVAL(_type, _var) { \      if (pC32) _var = (_type)*pC32++; \      else { \	_var = (_type)(pUnion->val); pUnion++; \      } \    }#define NEXT_PTR(_type, _var) { \    assert(pUnion); _var = (_type)pUnion->ptr; pUnion++; }intdixChangeGC(client, pGC, mask, pC32, pUnion)    ClientPtr client;    register GC 	*pGC;    register BITS32	mask;    CARD32		*pC32;    ChangeGCValPtr	pUnion;{    register BITS32 	index2;    register int 	error = 0;    PixmapPtr 		pPixmap;    BITS32		maskQ;    assert( (pC32 && !pUnion) || (!pC32 && pUnion) );    pGC->serialNumber |= GC_CHANGE_SERIAL_BIT;    maskQ = mask;	/* save these for when we walk the GCque */    while (mask && !error)     {	index2 = (BITS32) lowbit (mask);	mask &= ~index2;	pGC->stateChanges |= index2;	switch (index2)	{	    case GCFunction:	    {		CARD8 newalu;		NEXTVAL(CARD8, newalu);		if (newalu <= GXset)		    pGC->alu = newalu;		else		{		    clientErrorValue = newalu;		    error = BadValue;		}		break;	    }	    case GCPlaneMask:		NEXTVAL(unsigned long, pGC->planemask);		break;	    case GCForeground:		NEXTVAL(unsigned long, pGC->fgPixel);		/*		 * this is for CreateGC		 */		if (!pGC->tileIsPixel && !pGC->tile.pixmap)		{		    pGC->tileIsPixel = TRUE;		    pGC->tile.pixel = pGC->fgPixel;		}		break;	    case GCBackground:		NEXTVAL(unsigned long, pGC->bgPixel);		break;	    case GCLineWidth:		/* ??? line width is a CARD16 */		 NEXTVAL(CARD16, pGC->lineWidth);		break;	    case GCLineStyle:	    {		unsigned int newlinestyle;		NEXTVAL(unsigned int, newlinestyle);		if (newlinestyle <= LineDoubleDash)		    pGC->lineStyle = newlinestyle;		else		{		    clientErrorValue = newlinestyle;		    error = BadValue;		}		break;	    }	    case GCCapStyle:	    {		unsigned int newcapstyle;		NEXTVAL(unsigned int, newcapstyle);		if (newcapstyle <= CapProjecting)		    pGC->capStyle = newcapstyle;		else		{		    clientErrorValue = newcapstyle;		    error = BadValue;		}		break;	    }	    case GCJoinStyle:	    {		unsigned int newjoinstyle;		NEXTVAL(unsigned int, newjoinstyle);		if (newjoinstyle <= JoinBevel)		    pGC->joinStyle = newjoinstyle;		else		{		    clientErrorValue = newjoinstyle;		    error = BadValue;		}		break;	    }	    case GCFillStyle:	    {		unsigned int newfillstyle;		NEXTVAL(unsigned int, newfillstyle);		if (newfillstyle <= FillOpaqueStippled)		    pGC->fillStyle = newfillstyle;		else		{		    clientErrorValue = newfillstyle;		    error = BadValue;		}		break;	    }	    case GCFillRule:	    {		unsigned int newfillrule;		NEXTVAL(unsigned int, newfillrule);		if (newfillrule <= WindingRule)		    pGC->fillRule = newfillrule;		else		{		    clientErrorValue = newfillrule;		    error = BadValue;		}		break;	    }	    case GCTile:	    {		XID newpix = 0;		if (pUnion)		{		    NEXT_PTR(PixmapPtr, pPixmap);		}		else		{		    NEXTVAL(XID, newpix);		    pPixmap = (PixmapPtr)SecurityLookupIDByType(client,					newpix, RT_PIXMAP, SecurityReadAccess);		}		if (pPixmap)		{		    if ((pPixmap->drawable.depth != pGC->depth) ||			(pPixmap->drawable.pScreen != pGC->pScreen))		    {			error = BadMatch;		    }		    else		    {			pPixmap->refcnt++;			if (!pGC->tileIsPixel)			    (* pGC->pScreen->DestroyPixmap)(pGC->tile.pixmap);			pGC->tileIsPixel = FALSE;			pGC->tile.pixmap = pPixmap;		    }		}		else		{		    clientErrorValue = newpix;		    error = BadPixmap;		}		break;	    }	    case GCStipple:	    {		XID newstipple = 0;		if (pUnion)		{		    NEXT_PTR(PixmapPtr, pPixmap);		}		else		{		    NEXTVAL(XID, newstipple)		    pPixmap = (PixmapPtr)SecurityLookupIDByType(client,				newstipple, RT_PIXMAP, SecurityReadAccess);		}		if (pPixmap)		{		    if ((pPixmap->drawable.depth != 1) ||			(pPixmap->drawable.pScreen != pGC->pScreen))		    {			error = BadMatch;		    }		    else		    {			pPixmap->refcnt++;			if (pGC->stipple)			    (* pGC->pScreen->DestroyPixmap)(pGC->stipple);			pGC->stipple = pPixmap;		    }		}		else		{		    clientErrorValue = newstipple;		    error = BadPixmap;		}		break;	    }	    case GCTileStipXOrigin:		NEXTVAL(INT16, pGC->patOrg.x);		break;	    case GCTileStipYOrigin:		NEXTVAL(INT16, pGC->patOrg.y);		break;	    case GCFont:    	    {		FontPtr	pFont;		XID newfont = 0;		if (pUnion)		{		    NEXT_PTR(FontPtr, pFont);		}		else		{		    NEXTVAL(XID, newfont)		    pFont = (FontPtr)SecurityLookupIDByType(client, newfont,						RT_FONT, SecurityReadAccess);		}		if (pFont)		{		    pFont->refcnt++;		    if (pGC->font)    		        CloseFont(pGC->font, (Font)0);		    pGC->font = pFont;		 }		else		{		    clientErrorValue = newfont;		    error = BadFont;		}		break;	    }	    case GCSubwindowMode:	    {		unsigned int newclipmode;		NEXTVAL(unsigned int, newclipmode);		if (newclipmode <= IncludeInferiors)		    pGC->subWindowMode = newclipmode;		else		{		    clientErrorValue = newclipmode;		    error = BadValue;		}		break;	    }	    case GCGraphicsExposures:    	    {		unsigned int newge;		NEXTVAL(unsigned int, newge);		if (newge <= xTrue)		    pGC->graphicsExposures = newge;		else		{		    clientErrorValue = newge;		    error = BadValue;		}		break;	    }	    case GCClipXOrigin:		NEXTVAL(INT16, pGC->clipOrg.x);		break;	    case GCClipYOrigin:		NEXTVAL(INT16, pGC->clipOrg.y);		break;	    case GCClipMask:	    {		Pixmap pid;		int    clipType;		if (pUnion)		{		    NEXT_PTR(PixmapPtr, pPixmap);		}		else		{		    NEXTVAL(Pixmap, pid)		    if (pid == None)		    {			clipType = CT_NONE;			pPixmap = NullPixmap;		    }		    else		        pPixmap = (PixmapPtr)SecurityLookupIDByType(client,					pid, RT_PIXMAP, SecurityReadAccess);		}		if (pPixmap)		{		    if ((pPixmap->drawable.depth != 1) ||			(pPixmap->drawable.pScreen != pGC->pScreen))		    {			error = BadMatch;		    }		    else		    {			clipType = CT_PIXMAP;			pPixmap->refcnt++;		    }		}		else if (!pUnion && (pid != None))		{		    clientErrorValue = pid;		    error = BadPixmap;		}		if(error == Success)		{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -