📄 main.c
字号:
/***********************************************************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: main.c /main/82 1996/09/28 17:12:09 rws $ *//* $XFree86: xc/programs/Xserver/dix/main.c,v 3.10.2.2 1998/01/22 10:47:08 dawes Exp $ */#define NEED_EVENTS#include "X.h"#include "Xproto.h"#include "scrnintstr.h"#include "misc.h"#include "os.h"#include "windowstr.h"#include "resource.h"#include "dixstruct.h"#include "gcstruct.h"#include "extension.h"#include "extnsionst.h"#include "colormap.h"#include "colormapst.h"#include "cursorstr.h"#include "font.h"#include "opaque.h"#include "servermd.h"#include "site.h"#include "dixfont.h"#include "dixevents.h" /* InitEvents() */#include "dispatch.h" /* InitProcVectors() */extern CARD32 defaultScreenSaverTime;extern CARD32 defaultScreenSaverInterval;extern int defaultScreenSaverBlanking;extern int defaultScreenSaverAllowExposures;#ifdef DPMSExtension#include "dpms.h"#endifvoid ddxGiveUp();extern int InitClientPrivates(#if NeedFunctionPrototypes ClientPtr /*client*/#endif);extern void Dispatch(#if NeedFunctionPrototypes void#endif);extern char *display;char *ConnectionInfo;xConnSetupPrefix connSetupPrefix;extern WindowPtr *WindowTable;extern FontPtr defaultFont;extern int screenPrivateCount;static Bool CreateConnectionBlock(#if NeedFunctionPrototypes void#endif);static void FreeScreen(#if NeedFunctionPrototypes ScreenPtr /*pScreen*/#endif);PaddingInfo PixmapWidthPaddingInfo[33];#ifdef INTERNAL_VS_EXTERNAL_PADDING/* add padding info for 32-bit interface. PutImage and GetImage will * work on 32-bit padding while the rest of the server will work * on 64-bit padding (Alpha). */PaddingInfo PixmapWidthPaddingInfoProto[33];#endifint connBlockScreenStart;static int restart = 0;/* * Dummy entry for EventSwapVector[] *//*ARGSUSED*/voidNotImplemented(#if NeedFunctionPrototypes && defined(EVENT_SWAP_PTR) xEvent * from, xEvent * to#endif ){ FatalError("Not implemented");}/* * Dummy entry for ReplySwapVector[] *//*ARGSUSED*/voidReplyNotSwappd(#if NeedNestedPrototypes ClientPtr pClient , int size , void * pbuf#endif ){ FatalError("Not implemented");}/* * This array encodes the answer to the question "what is the log base 2 * of the number of pixels that fit in a scanline pad unit?" * Note that ~0 is an invalid entry (mostly for the benefit of the reader). */static int answer[6][4] = { /* pad pad pad pad*/ /* 8 16 32 64 */ { 3, 4, 5 , 6 }, /* 1 bit per pixel */ { 1, 2, 3 , 4 }, /* 4 bits per pixel */ { 0, 1, 2 , 3 }, /* 8 bits per pixel */ { ~0, 0, 1 , 2 }, /* 16 bits per pixel */ { ~0, ~0, 0 , 1 }, /* 24 bits per pixel */ { ~0, ~0, 0 , 1 } /* 32 bits per pixel */};/* * This array gives the answer to the question "what is the first index for * the answer array above given the number of bits per pixel?" * Note that ~0 is an invalid entry (mostly for the benefit of the reader). */static int indexForBitsPerPixel[ 33 ] = { ~0, 0, ~0, ~0, /* 1 bit per pixel */ 1, ~0, ~0, ~0, /* 4 bits per pixel */ 2, ~0, ~0, ~0, /* 8 bits per pixel */ ~0,~0, ~0, ~0, 3, ~0, ~0, ~0, /* 16 bits per pixel */ ~0,~0, ~0, ~0, 4, ~0, ~0, ~0, /* 24 bits per pixel */ ~0,~0, ~0, ~0, 5 /* 32 bits per pixel */};/* * This array gives the bytesperPixel value for cases where the number * of bits per pixel is a multiple of 8 but not a power of 2. */static int answerBytesPerPixel[ 33 ] = { ~0, 0, ~0, ~0, /* 1 bit per pixel */ 0, ~0, ~0, ~0, /* 4 bits per pixel */ 0, ~0, ~0, ~0, /* 8 bits per pixel */ ~0,~0, ~0, ~0, 0, ~0, ~0, ~0, /* 16 bits per pixel */ ~0,~0, ~0, ~0, 3, ~0, ~0, ~0, /* 24 bits per pixel */ ~0,~0, ~0, ~0, 0 /* 32 bits per pixel */};/* * This array gives the answer to the question "what is the second index for * the answer array above given the number of bits per scanline pad unit?" * Note that ~0 is an invalid entry (mostly for the benefit of the reader). */static int indexForScanlinePad[ 65 ] = { ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, 0, ~0, ~0, ~0, /* 8 bits per scanline pad unit */ ~0, ~0, ~0, ~0, 1, ~0, ~0, ~0, /* 16 bits per scanline pad unit */ ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, 2, ~0, ~0, ~0, /* 32 bits per scanline pad unit */ ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, 3 /* 64 bits per scanline pad unit */};intmain(argc, argv) int argc; char *argv[];{ int i, j, k; HWEventQueueType alwaysCheckForInput[2]; /* Notice if we're restart. Probably this is because we jumped through * uninitialized pointer */ if (restart) FatalError("server restarted. Jumped through uninitialized pointer?\n"); else restart = 1;#if 0 ExpandCommandLine(&argc, &argv);#endif /* These are needed by some routines which are called from interrupt * handlers, thus have no direct calling path back to main and thus * can't be passed argc, argv as parameters */ argcGlobal = argc; argvGlobal = argv; display = "0"; ProcessCommandLine(argc, argv); alwaysCheckForInput[0] = 0; alwaysCheckForInput[1] = 1; while(1) { serverGeneration++; ScreenSaverTime = defaultScreenSaverTime; ScreenSaverInterval = defaultScreenSaverInterval; ScreenSaverBlanking = defaultScreenSaverBlanking; ScreenSaverAllowExposures = defaultScreenSaverAllowExposures;#ifdef DPMSExtension DPMSStandbyTime = defaultDPMSStandbyTime; DPMSSuspendTime = defaultDPMSSuspendTime; DPMSOffTime = defaultDPMSOffTime; DPMSEnabled = defaultDPMSEnabled; DPMSPowerLevel = 0;#endif InitBlockAndWakeupHandlers(); /* Perform any operating system dependent initializations you'd like */ OsInit(); if(serverGeneration == 1) { CreateWellKnownSockets(); InitProcVectors(); clients = (ClientPtr *)xalloc(MAXCLIENTS * sizeof(ClientPtr)); if (!clients) FatalError("couldn't create client array"); for (i=1; i<MAXCLIENTS; i++) clients[i] = NullClient; serverClient = (ClientPtr)xalloc(sizeof(ClientRec)); if (!serverClient) FatalError("couldn't create server client"); InitClient(serverClient, 0, (pointer)NULL); } else ResetWellKnownSockets (); clients[0] = serverClient; currentMaxClients = 1; if (!InitClientResources(serverClient)) /* for root resources */ FatalError("couldn't init server resources"); SetInputCheck(&alwaysCheckForInput[0], &alwaysCheckForInput[1]); screenInfo.arraySize = MAXSCREENS; screenInfo.numScreens = 0; screenInfo.numVideoScreens = -1; WindowTable = (WindowPtr *)xalloc(MAXSCREENS * sizeof(WindowPtr)); if (!WindowTable) FatalError("couldn't create root window table"); /* * Just in case the ddx doesnt supply a format for depth 1 (like qvss). */ j = indexForBitsPerPixel[ 1 ]; k = indexForScanlinePad[ BITMAP_SCANLINE_PAD ]; PixmapWidthPaddingInfo[1].padRoundUp = BITMAP_SCANLINE_PAD-1; PixmapWidthPaddingInfo[1].padPixelsLog2 = answer[j][k]; j = indexForBitsPerPixel[8]; /* bits per byte */ PixmapWidthPaddingInfo[1].padBytesLog2 = answer[j][k];#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[ 1 ]; k = indexForScanlinePad[ BITMAP_SCANLINE_PAD_PROTO ]; PixmapWidthPaddingInfoProto[1].padRoundUp = BITMAP_SCANLINE_PAD_PROTO-1; PixmapWidthPaddingInfoProto[1].padPixelsLog2 = answer[j][k]; j = indexForBitsPerPixel[8]; /* bits per byte */ PixmapWidthPaddingInfoProto[1].padBytesLog2 = answer[j][k];#endif /* INTERNAL_VS_EXTERNAL_PADDING */ InitAtoms(); InitEvents(); InitGlyphCaching(); ResetClientPrivates(); ResetScreenPrivates(); ResetWindowPrivates(); ResetGCPrivates();#ifdef PIXPRIV ResetPixmapPrivates();#endif ResetColormapPrivates(); ResetFontPrivateIndex(); InitCallbackManager(); InitOutput(&screenInfo, argc, argv); if (screenInfo.numScreens < 1) FatalError("no screens found"); if (screenInfo.numVideoScreens < 0) screenInfo.numVideoScreens = screenInfo.numScreens;#ifdef XPRINT PrinterInitOutput(&screenInfo, argc, argv);#endif InitExtensions(argc, argv); if (!InitClientPrivates(serverClient)) FatalError("failed to allocate serverClient devprivates"); for (i = 0; i < screenInfo.numScreens; i++) { ScreenPtr pScreen = screenInfo.screens[i]; if (!CreateScratchPixmapsForScreen(i)) FatalError("failed to create scratch pixmaps"); if (pScreen->CreateScreenResources && !(*pScreen->CreateScreenResources)(pScreen)) FatalError("failed to create screen resources"); if (!CreateGCperDepth(i)) FatalError("failed to create scratch GCs"); if (!CreateDefaultStipple(i)) FatalError("failed to create default stipple"); if (!CreateRootWindow(pScreen)) FatalError("failed to create root window"); } InitInput(argc, argv);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -