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

📄 main.c

📁 远程桌面连接工具
💻 C
📖 第 1 页 / 共 2 页
字号:
	if (InitAndStartDevices() != Success)	    FatalError("failed to initialize core devices");	InitFonts();	if (SetDefaultFontPath(defaultFontPath) != Success)	    ErrorF("failed to set default font path '%s'", defaultFontPath);	if (!SetDefaultFont(defaultTextFont))	    FatalError("could not open default font '%s'", defaultTextFont);	if (!(rootCursor = CreateRootCursor(defaultCursorFont, 0)))	    FatalError("could not open default cursor font '%s'",		       defaultCursorFont);#ifdef DPMSExtension 	/* check all screens, looking for DPMS Capabilities */ 	DPMSCapableFlag = DPMSSupported();	if (!DPMSCapableFlag)     	    DPMSEnabled = FALSE;#endif	for (i = 0; i < screenInfo.numScreens; i++)	    InitRootWindow(WindowTable[i]);        DefineInitialRootWindow(WindowTable[0]);	if (!CreateConnectionBlock())	    FatalError("could not create connection block info");	Dispatch();	/* Now free up whatever must be freed */	if (screenIsSaved == SCREEN_SAVER_ON)	    SaveScreens(SCREEN_SAVER_OFF, ScreenSaverReset);	CloseDownExtensions();	FreeAllResources();	CloseDownDevices();	for (i = screenInfo.numScreens - 1; i >= 0; i--)	{	    FreeScratchPixmapsForScreen(i);	    FreeGCperDepth(i);	    FreeDefaultStipple(i);	    (* screenInfo.screens[i]->CloseScreen)(i, screenInfo.screens[i]);	    FreeScreen(screenInfo.screens[i]);	    screenInfo.numScreens = i;	}	xfree(WindowTable);	FreeFonts ();	xfree(serverClient->devPrivates);	if (dispatchException & DE_TERMINATE)	{	    OsCleanup();	    ddxGiveUp();	    break;	}	xfree(ConnectionInfo);    }    return(0);}static int padlength[4] = {0, 3, 2, 1};static BoolCreateConnectionBlock(){    xConnSetup setup;    xWindowRoot root;    xDepth	depth;    xVisualType visual;    xPixmapFormat format;    unsigned long vid;    int i, j, k,        lenofblock,        sizesofar = 0;    char *pBuf;        /* Leave off the ridBase and ridMask, these must be sent with        connection */    setup.release = VENDOR_RELEASE;    /*     * per-server image and bitmap parameters are defined in Xmd.h     */    setup.imageByteOrder = screenInfo.imageByteOrder;#ifdef INTERNAL_VS_EXTERNAL_PADDING    if ( screenInfo.bitmapScanlineUnit > 32 )    	setup.bitmapScanlineUnit  = 32;    else#endif     	setup.bitmapScanlineUnit  = screenInfo.bitmapScanlineUnit;#ifdef INTERNAL_VS_EXTERNAL_PADDING    if ( screenInfo.bitmapScanlinePad > 32 )    	setup.bitmapScanlinePad = 32;    else#endif 	setup.bitmapScanlinePad = screenInfo.bitmapScanlinePad;    setup.bitmapBitOrder = screenInfo.bitmapBitOrder;    setup.motionBufferSize = NumMotionEvents();    setup.numRoots = screenInfo.numScreens;    setup.nbytesVendor = strlen(VENDOR_STRING);     setup.numFormats = screenInfo.numPixmapFormats;    setup.maxRequestSize = MAX_REQUEST_SIZE;    QueryMinMaxKeyCodes(&setup.minKeyCode, &setup.maxKeyCode);        lenofblock = sizeof(xConnSetup) +             ((setup.nbytesVendor + 3) & ~3) +	    (setup.numFormats * sizeof(xPixmapFormat)) +            (setup.numRoots * sizeof(xWindowRoot));    ConnectionInfo = (char *) xalloc(lenofblock);    if (!ConnectionInfo)	return FALSE;    memmove(ConnectionInfo, (char *)&setup, sizeof(xConnSetup));    sizesofar = sizeof(xConnSetup);    pBuf = ConnectionInfo + sizeof(xConnSetup);    memmove(pBuf, VENDOR_STRING, (int)setup.nbytesVendor);    sizesofar += setup.nbytesVendor;    pBuf += setup.nbytesVendor;    i = padlength[setup.nbytesVendor & 3];    sizesofar += i;    while (--i >= 0)        *pBuf++ = 0;        for (i=0; i<screenInfo.numPixmapFormats; i++)    {	format.depth = screenInfo.formats[i].depth;	format.bitsPerPixel = screenInfo.formats[i].bitsPerPixel;#ifdef INTERNAL_VS_EXTERNAL_PADDING	if ( screenInfo.formats[i].scanlinePad > 32 )	    format.scanLinePad = 32;	else#endif	    format.scanLinePad = screenInfo.formats[i].scanlinePad;	memmove(pBuf, (char *)&format, sizeof(xPixmapFormat));	pBuf += sizeof(xPixmapFormat);	sizesofar += sizeof(xPixmapFormat);    }    connBlockScreenStart = sizesofar;    for (i=0; i<screenInfo.numScreens; i++)     {	ScreenPtr	pScreen;	DepthPtr	pDepth;	VisualPtr	pVisual;	pScreen = screenInfo.screens[i];	root.windowId = WindowTable[i]->drawable.id;	root.defaultColormap = pScreen->defColormap;	root.whitePixel = pScreen->whitePixel;	root.blackPixel = pScreen->blackPixel;	root.currentInputMask = 0;    /* filled in when sent */	root.pixWidth = pScreen->width;	root.pixHeight = pScreen->height;	root.mmWidth = pScreen->mmWidth;	root.mmHeight = pScreen->mmHeight;	root.minInstalledMaps = pScreen->minInstalledCmaps;	root.maxInstalledMaps = pScreen->maxInstalledCmaps; 	root.rootVisualID = pScreen->rootVisual;			root.backingStore = pScreen->backingStoreSupport;	root.saveUnders = pScreen->saveUnderSupport != NotUseful;	root.rootDepth = pScreen->rootDepth;	root.nDepths = pScreen->numDepths;	memmove(pBuf, (char *)&root, sizeof(xWindowRoot));	sizesofar += sizeof(xWindowRoot);	pBuf += sizeof(xWindowRoot);	pDepth = pScreen->allowedDepths;	for(j = 0; j < pScreen->numDepths; j++, pDepth++)	{	    lenofblock += sizeof(xDepth) + 		    (pDepth->numVids * sizeof(xVisualType));	    pBuf = (char *)xrealloc(ConnectionInfo, lenofblock);	    if (!pBuf)	    {		xfree(ConnectionInfo);		return FALSE;	    }	    ConnectionInfo = pBuf;	    pBuf += sizesofar;            	    depth.depth = pDepth->depth;	    depth.nVisuals = pDepth->numVids;	    memmove(pBuf, (char *)&depth, sizeof(xDepth));	    pBuf += sizeof(xDepth);	    sizesofar += sizeof(xDepth);	    for(k = 0; k < pDepth->numVids; k++)	    {		vid = pDepth->vids[k];		for (pVisual = pScreen->visuals;		     pVisual->vid != vid;		     pVisual++)		    ;		visual.visualID = vid;		visual.class = pVisual->class;		visual.bitsPerRGB = pVisual->bitsPerRGBValue;		visual.colormapEntries = pVisual->ColormapEntries;		visual.redMask = pVisual->redMask;		visual.greenMask = pVisual->greenMask;		visual.blueMask = pVisual->blueMask;		memmove(pBuf, (char *)&visual, sizeof(xVisualType));		pBuf += sizeof(xVisualType);		sizesofar += sizeof(xVisualType);	    }	}    }    connSetupPrefix.success = xTrue;    connSetupPrefix.length = lenofblock/4;    connSetupPrefix.majorVersion = X_PROTOCOL;    connSetupPrefix.minorVersion = X_PROTOCOL_REVISION;    return TRUE;}/*	grow the array of screenRecs if necessary.	call the device-supplied initialization procedure with its screen number, a pointer to its ScreenRec, argc, and argv.	return the number of successfully installed screens.*/int#if NeedFunctionPrototypesAddScreen(    Bool	(* pfnInit)(#if NeedNestedPrototypes	int /*index*/,	ScreenPtr /*pScreen*/,	int /*argc*/,	char ** /*argv*/#endif		),    int argc,    char **argv)#elseAddScreen(pfnInit, argc, argv)    Bool	(* pfnInit)();    int argc;    char **argv;#endif{    int i;    int scanlinepad, format, depth, bitsPerPixel, j, k;    ScreenPtr pScreen;#ifdef DEBUG    void	(**jNI) ();#endif /* DEBUG */    i = screenInfo.numScreens;    if (i == MAXSCREENS)	return -1;    pScreen = (ScreenPtr) xalloc(sizeof(ScreenRec));    if (!pScreen)	return -1;    pScreen->devPrivates = (DevUnion *)xalloc(screenPrivateCount *					      sizeof(DevUnion));    if (!pScreen->devPrivates && screenPrivateCount)    {	xfree(pScreen);	return -1;    }    pScreen->myNum = i;    pScreen->WindowPrivateLen = 0;    pScreen->WindowPrivateSizes = (unsigned *)NULL;    pScreen->totalWindowSize = sizeof(WindowRec);    pScreen->GCPrivateLen = 0;    pScreen->GCPrivateSizes = (unsigned *)NULL;    pScreen->totalGCSize = sizeof(GC);#ifdef PIXPRIV    pScreen->PixmapPrivateLen = 0;    pScreen->PixmapPrivateSizes = (unsigned *)NULL;    pScreen->totalPixmapSize = BitmapBytePad(sizeof(PixmapRec)*8);#endif    pScreen->ClipNotify = 0;	/* for R4 ddx compatibility */    pScreen->CreateScreenResources = 0;    #ifdef DEBUG    for (jNI = &pScreen->QueryBestSize; 	 jNI < (void (**) ()) &pScreen->SendGraphicsExpose;	 jNI++)	*jNI = NotImplemented;#endif /* DEBUG */    /*     * This loop gets run once for every Screen that gets added,     * but thats ok.  If the ddx layer initializes the formats     * one at a time calling AddScreen() after each, then each     * iteration will make it a little more accurate.  Worst case     * we do this loop N * numPixmapFormats where N is # of screens.     * Anyway, this must be called after InitOutput and before the     * screen init routine is called.     */    for (format=0; format<screenInfo.numPixmapFormats; format++)    { 	depth = screenInfo.formats[format].depth; 	bitsPerPixel = screenInfo.formats[format].bitsPerPixel;  	scanlinepad = screenInfo.formats[format].scanlinePad; 	j = indexForBitsPerPixel[ bitsPerPixel ];  	k = indexForScanlinePad[ scanlinepad ]; 	PixmapWidthPaddingInfo[ depth ].padPixelsLog2 = answer[j][k]; 	PixmapWidthPaddingInfo[ depth ].padRoundUp = 	    (scanlinepad/bitsPerPixel) - 1; 	j = indexForBitsPerPixel[ 8 ]; /* bits per byte */ 	PixmapWidthPaddingInfo[ depth ].padBytesLog2 = answer[j][k];	if (answerBytesPerPixel[bitsPerPixel])	{	    PixmapWidthPaddingInfo[ depth ].notPower2 = 1;	    PixmapWidthPaddingInfo[ depth ].bytesPerPixel =		answerBytesPerPixel[bitsPerPixel];	}	else	{	    PixmapWidthPaddingInfo[ depth ].notPower2 = 0;	}#ifdef INTERNAL_VS_EXTERNAL_PADDING	/* Fake out protocol interface to make them believe we support	 * a different padding than the actual internal padding.	 */ 	j = indexForBitsPerPixel[ bitsPerPixel ];  	k = indexForScanlinePad[ BITMAP_SCANLINE_PAD_PROTO ]; 	PixmapWidthPaddingInfoProto[ depth ].padPixelsLog2 = answer[j][k]; 	PixmapWidthPaddingInfoProto[ depth ].padRoundUp = 	    (BITMAP_SCANLINE_PAD_PROTO/bitsPerPixel) - 1; 	j = indexForBitsPerPixel[ 8 ]; /* bits per byte */ 	PixmapWidthPaddingInfoProto[ depth ].padBytesLog2 = answer[j][k];	if (answerBytesPerPixel[bitsPerPixel])	{	    PixmapWidthPaddingInfoProto[ depth ].notPower2 = 1;	    PixmapWidthPaddingInfoProto[ depth ].bytesPerPixel =		answerBytesPerPixel[bitsPerPixel];	}	else	{	    PixmapWidthPaddingInfoProto[ depth ].notPower2 = 0;	}#endif /* INTERNAL_VS_EXTERNAL_PADDING */    }      /* This is where screen specific stuff gets initialized.  Load the       screen structure, call the hardware, whatever.       This is also where the default colormap should be allocated and       also pixel values for blackPixel, whitePixel, and the cursor       Note that InitScreen is NOT allowed to modify argc, argv, or       any of the strings pointed to by argv.  They may be passed to       multiple screens.     */     pScreen->rgf = ~0L;  /* there are no scratch GCs yet*/    WindowTable[i] = NullWindow;    screenInfo.screens[i] = pScreen;    screenInfo.numScreens++;    if (!(*pfnInit)(i, pScreen, argc, argv))    {	FreeScreen(pScreen);	screenInfo.numScreens--;	return -1;    }    return i;}static voidFreeScreen(pScreen)    ScreenPtr pScreen;{    xfree(pScreen->WindowPrivateSizes);    xfree(pScreen->GCPrivateSizes);#ifdef PIXPRIV    xfree(pScreen->PixmapPrivateSizes);#endif    xfree(pScreen->devPrivates);    xfree(pScreen);}

⌨️ 快捷键说明

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