diff options
Diffstat (limited to 'xorg-server/dix/main.c')
-rw-r--r-- | xorg-server/dix/main.c | 383 |
1 files changed, 10 insertions, 373 deletions
diff --git a/xorg-server/dix/main.c b/xorg-server/dix/main.c index 0527621e7..f96245a4b 100644 --- a/xorg-server/dix/main.c +++ b/xorg-server/dix/main.c @@ -74,14 +74,15 @@ Equipment Corporation. ******************************************************************/ -#define NEED_EVENTS #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> +#include <version-config.h> #endif #include <X11/X.h> #include <X11/Xos.h> /* for unistd.h */ #include <X11/Xproto.h> +#include <pixman.h> #include "scrnintstr.h" #include "misc.h" #include "os.h" @@ -111,127 +112,13 @@ Equipment Corporation. #endif #ifdef DPMSExtension -#define DPMS_SERVER -#include <X11/extensions/dpms.h> +#include <X11/extensions/dpmsconst.h> #include "dpmsproc.h" #endif extern void Dispatch(void); -xConnSetupPrefix connSetupPrefix; - -extern FontPtr defaultFont; - extern void InitProcVectors(void); -extern Bool CreateGCperDepthArray(void); - -#ifndef PANORAMIX -static -#endif -Bool CreateConnectionBlock(void); - -_X_EXPORT PaddingInfo PixmapWidthPaddingInfo[33]; - -int connBlockScreenStart; - -_X_EXPORT void -NotImplemented(xEvent *from, xEvent *to) -{ - FatalError("Not implemented"); -} - -/* - * Dummy entry for ReplySwapVector[] - */ - -void -ReplyNotSwappd( - ClientPtr pClient , - int size , - void * pbuf - ) -{ - 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 */ -}; - -#ifndef MIN -#define MIN(a,b) (((a) < (b)) ? (a) : (b)) -#endif #ifdef XQUARTZ #include <pthread.h> @@ -252,6 +139,8 @@ int main(int argc, char *argv[], char *envp[]) InitRegions(); + pixman_disable_out_of_bounds_workaround(); + CheckUserParameters(argc, argv, envp); CheckUserAuthorization(); @@ -270,10 +159,10 @@ int main(int argc, char *argv[], char *envp[]) ScreenSaverBlanking = defaultScreenSaverBlanking; ScreenSaverAllowExposures = defaultScreenSaverAllowExposures; #ifdef DPMSExtension - DPMSStandbyTime = defaultDPMSStandbyTime; - DPMSSuspendTime = defaultDPMSSuspendTime; - DPMSOffTime = defaultDPMSOffTime; - DPMSEnabled = defaultDPMSEnabled; + DPMSStandbyTime = DEFAULT_SCREEN_SAVER_TIME; + DPMSSuspendTime = DEFAULT_SCREEN_SAVER_TIME; + DPMSOffTime = DEFAULT_SCREEN_SAVER_TIME; + DPMSEnabled = TRUE; DPMSPowerLevel = 0; #endif InitBlockAndWakeupHandlers(); @@ -286,7 +175,7 @@ int main(int argc, char *argv[], char *envp[]) InitProcVectors(); for (i=1; i<MAXCLIENTS; i++) clients[i] = NullClient; - serverClient = (ClientPtr)xalloc(sizeof(ClientRec)); + serverClient = xalloc(sizeof(ClientRec)); if (!serverClient) FatalError("couldn't create server client"); InitClient(serverClient, 0, (pointer)NULL); @@ -363,7 +252,6 @@ int main(int argc, char *argv[], char *envp[]) for (i = 0; i < screenInfo.numScreens; i++) InitRootWindow(WindowTable[i]); - DefineInitialRootWindow(WindowTable[0]); InitCoreDevices(); InitInput(argc, argv); @@ -457,254 +345,3 @@ int main(int argc, char *argv[], char *envp[]) return(0); } -static int VendorRelease = VENDOR_RELEASE; -static char *VendorString = VENDOR_NAME; - -void -SetVendorRelease(int release) -{ - VendorRelease = release; -} - -void -SetVendorString(char *string) -{ - VendorString = string; -} - -static const int padlength[4] = {0, 3, 2, 1}; - -#ifndef PANORAMIX -static -#endif -Bool -CreateConnectionBlock(void) -{ - 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 = VendorRelease; - /* - * per-server image and bitmap parameters are defined in Xmd.h - */ - setup.imageByteOrder = screenInfo.imageByteOrder; - - setup.bitmapScanlineUnit = screenInfo.bitmapScanlineUnit; - setup.bitmapScanlinePad = screenInfo.bitmapScanlinePad; - - setup.bitmapBitOrder = screenInfo.bitmapBitOrder; - setup.motionBufferSize = NumMotionEvents(); - setup.numRoots = screenInfo.numScreens; - setup.nbytesVendor = strlen(VendorString); - 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, VendorString, (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; - 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 = FALSE; - 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 -AddScreen( - Bool (* pfnInit)( - int /*index*/, - ScreenPtr /*pScreen*/, - int /*argc*/, - char ** /*argv*/ - ), - int argc, - char **argv) -{ - - int i; - int scanlinepad, format, depth, bitsPerPixel, j, k; - ScreenPtr pScreen; - - i = screenInfo.numScreens; - if (i == MAXSCREENS) - return -1; - - pScreen = (ScreenPtr) xcalloc(1, sizeof(ScreenRec)); - if (!pScreen) - return -1; - - pScreen->devPrivates = NULL; - pScreen->myNum = i; - pScreen->totalPixmapSize = BitmapBytePad(sizeof(PixmapRec)*8); - pScreen->ClipNotify = 0; /* for R4 ddx compatibility */ - pScreen->CreateScreenResources = 0; - - /* - * 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]; - PixmapWidthPaddingInfo[ depth ].bitsPerPixel = bitsPerPixel; - if (answerBytesPerPixel[bitsPerPixel]) - { - PixmapWidthPaddingInfo[ depth ].notPower2 = 1; - PixmapWidthPaddingInfo[ depth ].bytesPerPixel = - answerBytesPerPixel[bitsPerPixel]; - } - else - { - PixmapWidthPaddingInfo[ depth ].notPower2 = 0; - } - } - - /* 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)) - { - dixFreePrivates(pScreen->devPrivates); - xfree(pScreen); - screenInfo.numScreens--; - return -1; - } - return i; -} |