From 0f834b91a4768673833ab4917e87d86c237bb1a6 Mon Sep 17 00:00:00 2001 From: marha Date: Fri, 23 Mar 2012 10:05:55 +0100 Subject: libX11 xserver fontconfig mesa pixman xkbcomp xkeyboard-config git update 23 Mar 2012 --- xorg-server/hw/dmx/dmxinit.c | 850 ++++++++++++++++++++++++------------------- 1 file changed, 468 insertions(+), 382 deletions(-) (limited to 'xorg-server/hw/dmx/dmxinit.c') diff --git a/xorg-server/hw/dmx/dmxinit.c b/xorg-server/hw/dmx/dmxinit.c index 57c242598..09e3d74ea 100644 --- a/xorg-server/hw/dmx/dmxinit.c +++ b/xorg-server/hw/dmx/dmxinit.c @@ -55,8 +55,8 @@ #include "dmxstat.h" #include "dmxpict.h" -#include /* For gettimeofday */ -#include /* For XmuGetHostname */ +#include /* For gettimeofday */ +#include /* For XmuGetHostname */ #include "dixstruct.h" #ifdef PANORAMIX #include "panoramiXsrv.h" @@ -70,91 +70,94 @@ #include "dmx_glxvisuals.h" #include #include -#endif /* GLXEXT */ +#endif /* GLXEXT */ /* Global variables available to all Xserver/hw/dmx routines. */ -int dmxNumScreens; -DMXScreenInfo *dmxScreens; +int dmxNumScreens; +DMXScreenInfo *dmxScreens; -int dmxNumInputs; -DMXInputInfo *dmxInputs; +int dmxNumInputs; +DMXInputInfo *dmxInputs; -int dmxShadowFB = FALSE; +int dmxShadowFB = FALSE; -XErrorEvent dmxLastErrorEvent; -Bool dmxErrorOccurred = FALSE; +XErrorEvent dmxLastErrorEvent; +Bool dmxErrorOccurred = FALSE; -char *dmxFontPath = NULL; +char *dmxFontPath = NULL; -Bool dmxOffScreenOpt = TRUE; +Bool dmxOffScreenOpt = TRUE; -Bool dmxSubdividePrimitives = TRUE; +Bool dmxSubdividePrimitives = TRUE; -Bool dmxLazyWindowCreation = TRUE; +Bool dmxLazyWindowCreation = TRUE; -Bool dmxUseXKB = TRUE; +Bool dmxUseXKB = TRUE; -int dmxDepth = 0; +int dmxDepth = 0; #ifndef GLXEXT -static Bool dmxGLXProxy = FALSE; +static Bool dmxGLXProxy = FALSE; #else -Bool dmxGLXProxy = TRUE; +Bool dmxGLXProxy = TRUE; -Bool dmxGLXSwapGroupSupport = TRUE; +Bool dmxGLXSwapGroupSupport = TRUE; -Bool dmxGLXSyncSwap = FALSE; +Bool dmxGLXSyncSwap = FALSE; -Bool dmxGLXFinishSwap = FALSE; +Bool dmxGLXFinishSwap = FALSE; #endif -Bool dmxIgnoreBadFontPaths = FALSE; +Bool dmxIgnoreBadFontPaths = FALSE; -Bool dmxAddRemoveScreens = FALSE; +Bool dmxAddRemoveScreens = FALSE; /* dmxErrorHandler catches errors that occur when calling one of the * back-end servers. Some of this code is based on _XPrintDefaultError * in xc/lib/X11/XlibInt.c */ -static int dmxErrorHandler(Display *dpy, XErrorEvent *ev) +static int +dmxErrorHandler(Display * dpy, XErrorEvent * ev) { #define DMX_ERROR_BUF_SIZE 256 - /* RATS: these buffers are only used in - * length-limited calls. */ - char buf[DMX_ERROR_BUF_SIZE]; - char request[DMX_ERROR_BUF_SIZE]; + /* RATS: these buffers are only used in + * length-limited calls. */ + char buf[DMX_ERROR_BUF_SIZE]; + char request[DMX_ERROR_BUF_SIZE]; _XExtension *ext = NULL; - dmxErrorOccurred = TRUE; + dmxErrorOccurred = TRUE; dmxLastErrorEvent = *ev; XGetErrorText(dpy, ev->error_code, buf, sizeof(buf)); dmxLog(dmxWarning, "dmxErrorHandler: %s\n", buf); - /* Find major opcode name */ + /* Find major opcode name */ if (ev->request_code < 128) { snprintf(request, sizeof(request), "%d", ev->request_code); XGetErrorDatabaseText(dpy, "XRequest", request, "", buf, sizeof(buf)); - } else { + } + else { for (ext = dpy->ext_procs; ext && ext->codes.major_opcode != ev->request_code; ext = ext->next); - if (ext) strlcpy(buf, ext->name, sizeof(buf)); - else buf[0] = '\0'; + if (ext) + strlcpy(buf, ext->name, sizeof(buf)); + else + buf[0] = '\0'; } dmxLog(dmxWarning, " Major opcode: %d (%s)\n", ev->request_code, buf); - /* Find minor opcode name */ + /* Find minor opcode name */ if (ev->request_code >= 128 && ext) { snprintf(request, sizeof(request), "%d", ev->request_code); - snprintf(request, sizeof(request), "%s.%d", - ext->name, ev->minor_code); + snprintf(request, sizeof(request), "%s.%d", ext->name, ev->minor_code); XGetErrorDatabaseText(dpy, "XRequest", request, "", buf, sizeof(buf)); dmxLog(dmxWarning, " Minor opcode: %d (%s)\n", ev->minor_code, buf); } - /* Provide value information */ + /* Provide value information */ switch (ev->error_code) { case BadValue: dmxLog(dmxWarning, " Value: 0x%x\n", @@ -170,7 +173,7 @@ static int dmxErrorHandler(Display *dpy, XErrorEvent *ev) break; } - /* Provide serial number information */ + /* Provide serial number information */ dmxLog(dmxWarning, " Failed serial number: %d\n", ev->serial); dmxLog(dmxWarning, " Current serial number: %d\n", @@ -179,47 +182,53 @@ static int dmxErrorHandler(Display *dpy, XErrorEvent *ev) } #ifdef GLXEXT -static int dmxNOPErrorHandler(Display *dpy, XErrorEvent *ev) +static int +dmxNOPErrorHandler(Display * dpy, XErrorEvent * ev) { return 0; } #endif -Bool dmxOpenDisplay(DMXScreenInfo *dmxScreen) +Bool +dmxOpenDisplay(DMXScreenInfo * dmxScreen) { if (!(dmxScreen->beDisplay = XOpenDisplay(dmxScreen->name))) - return FALSE; + return FALSE; dmxPropertyDisplay(dmxScreen); return TRUE; } -void dmxSetErrorHandler(DMXScreenInfo *dmxScreen) +void +dmxSetErrorHandler(DMXScreenInfo * dmxScreen) { XSetErrorHandler(dmxErrorHandler); } -static void dmxPrintScreenInfo(DMXScreenInfo *dmxScreen) +static void +dmxPrintScreenInfo(DMXScreenInfo * dmxScreen) { XWindowAttributes attribs; - int ndepths = 0, *depths = NULL; - int i; - Display *dpy = dmxScreen->beDisplay; - Screen *s = DefaultScreenOfDisplay(dpy); - int scr = DefaultScreen(dpy); + int ndepths = 0, *depths = NULL; + int i; + Display *dpy = dmxScreen->beDisplay; + Screen *s = DefaultScreenOfDisplay(dpy); + int scr = DefaultScreen(dpy); XGetWindowAttributes(dpy, DefaultRootWindow(dpy), &attribs); - if (!(depths = XListDepths(dpy, scr, &ndepths))) ndepths = 0; - + if (!(depths = XListDepths(dpy, scr, &ndepths))) + ndepths = 0; + dmxLogOutput(dmxScreen, "Name of display: %s\n", DisplayString(dpy)); dmxLogOutput(dmxScreen, "Version number: %d.%d\n", ProtocolVersion(dpy), ProtocolRevision(dpy)); dmxLogOutput(dmxScreen, "Vendor string: %s\n", ServerVendor(dpy)); if (!strstr(ServerVendor(dpy), "XFree86")) { dmxLogOutput(dmxScreen, "Vendor release: %d\n", VendorRelease(dpy)); - } else { - /* This code based on xdpyinfo.c */ - int v = VendorRelease(dpy); + } + else { + /* This code based on xdpyinfo.c */ + int v = VendorRelease(dpy); int major = -1, minor = -1, patch = -1, subpatch = -1; if (v < 336) @@ -229,27 +238,33 @@ static void dmxPrintScreenInfo(DMXScreenInfo *dmxScreen) minor = (v / 100) % 10; if (((v / 10) % 10) || (v % 10)) { patch = (v / 10) % 10; - if (v % 10) subpatch = v % 10; + if (v % 10) + subpatch = v % 10; } - } else if (v < 40000000) { + } + else if (v < 40000000) { major = v / 1000; minor = (v / 10) % 10; - if (v % 10) patch = v % 10; - } else { + if (v % 10) + patch = v % 10; + } + else { major = v / 10000000; minor = (v / 100000) % 100; patch = (v / 1000) % 100; - if (v % 1000) subpatch = v % 1000; - } + if (v % 1000) + subpatch = v % 1000; + } dmxLogOutput(dmxScreen, "Vendor release: %d (XFree86 version: %d.%d", v, major, minor); - if (patch > 0) dmxLogOutputCont(dmxScreen, ".%d", patch); - if (subpatch > 0) dmxLogOutputCont(dmxScreen, ".%d", subpatch); + if (patch > 0) + dmxLogOutputCont(dmxScreen, ".%d", patch); + if (subpatch > 0) + dmxLogOutputCont(dmxScreen, ".%d", subpatch); dmxLogOutputCont(dmxScreen, ")\n"); } - - dmxLogOutput(dmxScreen, "Dimensions: %dx%d pixels\n", + dmxLogOutput(dmxScreen, "Dimensions: %dx%d pixels\n", attribs.width, attribs.height); dmxLogOutput(dmxScreen, "%d depths on screen %d: ", ndepths, scr); for (i = 0; i < ndepths; i++) @@ -261,59 +276,65 @@ static void dmxPrintScreenInfo(DMXScreenInfo *dmxScreen) dmxLogOutput(dmxScreen, "Number of colormaps: %d min, %d max\n", MinCmapsOfScreen(s), MaxCmapsOfScreen(s)); dmxLogOutput(dmxScreen, "Options: backing-store %s, save-unders %s\n", - (DoesBackingStore (s) == NotUseful) ? "no" : - ((DoesBackingStore (s) == Always) ? "yes" : "when mapped"), - DoesSaveUnders (s) ? "yes" : "no"); + (DoesBackingStore(s) == NotUseful) ? "no" : + ((DoesBackingStore(s) == Always) ? "yes" : "when mapped"), + DoesSaveUnders(s) ? "yes" : "no"); dmxLogOutput(dmxScreen, "Window Manager running: %s\n", - (dmxScreen->WMRunningOnBE) ? "yes" : "no"); + (dmxScreen->WMRunningOnBE) ? "yes" : "no"); if (dmxScreen->WMRunningOnBE) { - dmxLogOutputWarning(dmxScreen, - "Window manager running " - "-- colormaps not supported\n"); + dmxLogOutputWarning(dmxScreen, + "Window manager running " + "-- colormaps not supported\n"); } XFree(depths); } -void dmxGetScreenAttribs(DMXScreenInfo *dmxScreen) +void +dmxGetScreenAttribs(DMXScreenInfo * dmxScreen) { XWindowAttributes attribs; - Display *dpy = dmxScreen->beDisplay; + Display *dpy = dmxScreen->beDisplay; + #ifdef GLXEXT - int dummy; + int dummy; #endif XGetWindowAttributes(dpy, DefaultRootWindow(dpy), &attribs); - dmxScreen->beWidth = attribs.width; + dmxScreen->beWidth = attribs.width; dmxScreen->beHeight = attribs.height; - - /* Fill in missing geometry information */ + + /* Fill in missing geometry information */ if (dmxScreen->scrnXSign < 0) { if (dmxScreen->scrnWidth) { - dmxScreen->scrnX = (attribs.width - dmxScreen->scrnWidth - - dmxScreen->scrnX); - } else { - dmxScreen->scrnWidth = attribs.width - dmxScreen->scrnX; - dmxScreen->scrnX = 0; + dmxScreen->scrnX = (attribs.width - dmxScreen->scrnWidth + - dmxScreen->scrnX); + } + else { + dmxScreen->scrnWidth = attribs.width - dmxScreen->scrnX; + dmxScreen->scrnX = 0; } } if (dmxScreen->scrnYSign < 0) { if (dmxScreen->scrnHeight) { - dmxScreen->scrnY = (attribs.height - dmxScreen->scrnHeight - - dmxScreen->scrnY); - } else { + dmxScreen->scrnY = (attribs.height - dmxScreen->scrnHeight + - dmxScreen->scrnY); + } + else { dmxScreen->scrnHeight = attribs.height - dmxScreen->scrnY; - dmxScreen->scrnY = 0; + dmxScreen->scrnY = 0; } } if (!dmxScreen->scrnWidth) - dmxScreen->scrnWidth = attribs.width - dmxScreen->scrnX; + dmxScreen->scrnWidth = attribs.width - dmxScreen->scrnX; if (!dmxScreen->scrnHeight) dmxScreen->scrnHeight = attribs.height - dmxScreen->scrnY; - if (!dmxScreen->rootWidth) dmxScreen->rootWidth = dmxScreen->scrnWidth; - if (!dmxScreen->rootHeight) dmxScreen->rootHeight = dmxScreen->scrnHeight; + if (!dmxScreen->rootWidth) + dmxScreen->rootWidth = dmxScreen->scrnWidth; + if (!dmxScreen->rootHeight) + dmxScreen->rootHeight = dmxScreen->scrnHeight; if (dmxScreen->rootWidth + dmxScreen->rootX > dmxScreen->scrnWidth) dmxScreen->rootWidth = dmxScreen->scrnWidth - dmxScreen->rootX; if (dmxScreen->rootHeight + dmxScreen->rootY > dmxScreen->scrnHeight) @@ -323,22 +344,25 @@ void dmxGetScreenAttribs(DMXScreenInfo *dmxScreen) dmxScreen->beXDPI = 75; dmxScreen->beYDPI = 75; - dmxScreen->beDepth = attribs.depth; /* FIXME: verify that this - * works always. In - * particular, this will work - * well for depth=16, will fail - * because of colormap issues - * at depth 8. More work needs - * to be done here. */ - - if (dmxScreen->beDepth <= 8) dmxScreen->beBPP = 8; - else if (dmxScreen->beDepth <= 16) dmxScreen->beBPP = 16; - else dmxScreen->beBPP = 32; + dmxScreen->beDepth = attribs.depth; /* FIXME: verify that this + * works always. In + * particular, this will work + * well for depth=16, will fail + * because of colormap issues + * at depth 8. More work needs + * to be done here. */ + + if (dmxScreen->beDepth <= 8) + dmxScreen->beBPP = 8; + else if (dmxScreen->beDepth <= 16) + dmxScreen->beBPP = 16; + else + dmxScreen->beBPP = 32; #ifdef GLXEXT /* get the majorOpcode for the back-end GLX extension */ XQueryExtension(dpy, "GLX", &dmxScreen->glxMajorOpcode, - &dummy, &dmxScreen->glxErrorBase); + &dummy, &dmxScreen->glxErrorBase); #endif dmxPrintScreenInfo(dmxScreen); @@ -352,47 +376,50 @@ void dmxGetScreenAttribs(DMXScreenInfo *dmxScreen) "Support for depth == 8 is not complete\n"); } -Bool dmxGetVisualInfo(DMXScreenInfo *dmxScreen) +Bool +dmxGetVisualInfo(DMXScreenInfo * dmxScreen) { int i; XVisualInfo visinfo; visinfo.screen = DefaultScreen(dmxScreen->beDisplay); dmxScreen->beVisuals = XGetVisualInfo(dmxScreen->beDisplay, - VisualScreenMask, - &visinfo, - &dmxScreen->beNumVisuals); + VisualScreenMask, + &visinfo, &dmxScreen->beNumVisuals); dmxScreen->beDefVisualIndex = -1; if (defaultColorVisualClass >= 0 || dmxDepth > 0) { - for (i = 0; i < dmxScreen->beNumVisuals; i++) - if (defaultColorVisualClass >= 0) { - if (dmxScreen->beVisuals[i].class == defaultColorVisualClass) { - if (dmxDepth > 0) { - if (dmxScreen->beVisuals[i].depth == dmxDepth) { - dmxScreen->beDefVisualIndex = i; - break; - } - } else { - dmxScreen->beDefVisualIndex = i; - break; - } - } - } else if (dmxScreen->beVisuals[i].depth == dmxDepth) { - dmxScreen->beDefVisualIndex = i; - break; - } - } else { - visinfo.visualid = - XVisualIDFromVisual(DefaultVisual(dmxScreen->beDisplay, - visinfo.screen)); - - for (i = 0; i < dmxScreen->beNumVisuals; i++) - if (visinfo.visualid == dmxScreen->beVisuals[i].visualid) { - dmxScreen->beDefVisualIndex = i; - break; - } + for (i = 0; i < dmxScreen->beNumVisuals; i++) + if (defaultColorVisualClass >= 0) { + if (dmxScreen->beVisuals[i].class == defaultColorVisualClass) { + if (dmxDepth > 0) { + if (dmxScreen->beVisuals[i].depth == dmxDepth) { + dmxScreen->beDefVisualIndex = i; + break; + } + } + else { + dmxScreen->beDefVisualIndex = i; + break; + } + } + } + else if (dmxScreen->beVisuals[i].depth == dmxDepth) { + dmxScreen->beDefVisualIndex = i; + break; + } + } + else { + visinfo.visualid = + XVisualIDFromVisual(DefaultVisual(dmxScreen->beDisplay, + visinfo.screen)); + + for (i = 0; i < dmxScreen->beNumVisuals; i++) + if (visinfo.visualid == dmxScreen->beVisuals[i].visualid) { + dmxScreen->beDefVisualIndex = i; + break; + } } for (i = 0; i < dmxScreen->beNumVisuals; i++) @@ -402,44 +429,45 @@ Bool dmxGetVisualInfo(DMXScreenInfo *dmxScreen) return dmxScreen->beDefVisualIndex >= 0; } -void dmxGetColormaps(DMXScreenInfo *dmxScreen) +void +dmxGetColormaps(DMXScreenInfo * dmxScreen) { int i; dmxScreen->beNumDefColormaps = dmxScreen->beNumVisuals; dmxScreen->beDefColormaps = malloc(dmxScreen->beNumDefColormaps * - sizeof(*dmxScreen->beDefColormaps)); + sizeof(*dmxScreen->beDefColormaps)); for (i = 0; i < dmxScreen->beNumDefColormaps; i++) - dmxScreen->beDefColormaps[i] = - XCreateColormap(dmxScreen->beDisplay, - DefaultRootWindow(dmxScreen->beDisplay), - dmxScreen->beVisuals[i].visual, - AllocNone); + dmxScreen->beDefColormaps[i] = + XCreateColormap(dmxScreen->beDisplay, + DefaultRootWindow(dmxScreen->beDisplay), + dmxScreen->beVisuals[i].visual, AllocNone); dmxScreen->beBlackPixel = BlackPixel(dmxScreen->beDisplay, - DefaultScreen(dmxScreen->beDisplay)); + DefaultScreen(dmxScreen->beDisplay)); dmxScreen->beWhitePixel = WhitePixel(dmxScreen->beDisplay, - DefaultScreen(dmxScreen->beDisplay)); + DefaultScreen(dmxScreen->beDisplay)); } -void dmxGetPixmapFormats(DMXScreenInfo *dmxScreen) +void +dmxGetPixmapFormats(DMXScreenInfo * dmxScreen) { dmxScreen->beDepths = - XListDepths(dmxScreen->beDisplay, DefaultScreen(dmxScreen->beDisplay), - &dmxScreen->beNumDepths); + XListDepths(dmxScreen->beDisplay, DefaultScreen(dmxScreen->beDisplay), + &dmxScreen->beNumDepths); dmxScreen->bePixmapFormats = - XListPixmapFormats(dmxScreen->beDisplay, - &dmxScreen->beNumPixmapFormats); + XListPixmapFormats(dmxScreen->beDisplay, + &dmxScreen->beNumPixmapFormats); } -static Bool dmxSetPixmapFormats(ScreenInfo *pScreenInfo, - DMXScreenInfo *dmxScreen) +static Bool +dmxSetPixmapFormats(ScreenInfo * pScreenInfo, DMXScreenInfo * dmxScreen) { XPixmapFormatValues *bePixmapFormat; - PixmapFormatRec *format; - int i, j; + PixmapFormatRec *format; + int i, j; pScreenInfo->imageByteOrder = ImageByteOrder(dmxScreen->beDisplay); pScreenInfo->bitmapScanlineUnit = BitmapUnit(dmxScreen->beDisplay); @@ -448,53 +476,54 @@ static Bool dmxSetPixmapFormats(ScreenInfo *pScreenInfo, pScreenInfo->numPixmapFormats = 0; for (i = 0; i < dmxScreen->beNumPixmapFormats; i++) { - bePixmapFormat = &dmxScreen->bePixmapFormats[i]; - for (j = 0; j < dmxScreen->beNumDepths; j++) - if ((bePixmapFormat->depth == 1) || - (bePixmapFormat->depth == dmxScreen->beDepths[j])) { - format = &pScreenInfo->formats[pScreenInfo->numPixmapFormats]; - - format->depth = bePixmapFormat->depth; - format->bitsPerPixel = bePixmapFormat->bits_per_pixel; - format->scanlinePad = bePixmapFormat->scanline_pad; - - pScreenInfo->numPixmapFormats++; - break; - } + bePixmapFormat = &dmxScreen->bePixmapFormats[i]; + for (j = 0; j < dmxScreen->beNumDepths; j++) + if ((bePixmapFormat->depth == 1) || + (bePixmapFormat->depth == dmxScreen->beDepths[j])) { + format = &pScreenInfo->formats[pScreenInfo->numPixmapFormats]; + + format->depth = bePixmapFormat->depth; + format->bitsPerPixel = bePixmapFormat->bits_per_pixel; + format->scanlinePad = bePixmapFormat->scanline_pad; + + pScreenInfo->numPixmapFormats++; + break; + } } return TRUE; } -void dmxCheckForWM(DMXScreenInfo *dmxScreen) +void +dmxCheckForWM(DMXScreenInfo * dmxScreen) { Status status; XWindowAttributes xwa; status = XGetWindowAttributes(dmxScreen->beDisplay, - DefaultRootWindow(dmxScreen->beDisplay), - &xwa); + DefaultRootWindow(dmxScreen->beDisplay), + &xwa); dmxScreen->WMRunningOnBE = - (status && - ((xwa.all_event_masks & SubstructureRedirectMask) || - (xwa.all_event_masks & SubstructureNotifyMask))); + (status && + ((xwa.all_event_masks & SubstructureRedirectMask) || + (xwa.all_event_masks & SubstructureNotifyMask))); } /** Initialize the display and collect relevant information about the * display properties */ -static void dmxDisplayInit(DMXScreenInfo *dmxScreen) +static void +dmxDisplayInit(DMXScreenInfo * dmxScreen) { if (!dmxOpenDisplay(dmxScreen)) - dmxLog(dmxFatal, - "dmxOpenDisplay: Unable to open display %s\n", - dmxScreen->name); + dmxLog(dmxFatal, + "dmxOpenDisplay: Unable to open display %s\n", dmxScreen->name); dmxSetErrorHandler(dmxScreen); dmxCheckForWM(dmxScreen); dmxGetScreenAttribs(dmxScreen); if (!dmxGetVisualInfo(dmxScreen)) - dmxLog(dmxFatal, "dmxGetVisualInfo: No matching visuals found\n"); + dmxLog(dmxFatal, "dmxGetVisualInfo: No matching visuals found\n"); dmxGetColormaps(dmxScreen); dmxGetPixmapFormats(dmxScreen); @@ -503,45 +532,52 @@ static void dmxDisplayInit(DMXScreenInfo *dmxScreen) /* If this doesn't compile, just add || defined(yoursystem) to the line * below. This information is to help with bug reports and is not * critical. */ -#if !defined(_POSIX_SOURCE) -static const char *dmxExecOS(void) { return ""; } +#if !defined(_POSIX_SOURCE) +static const char * +dmxExecOS(void) +{ + return ""; +} #else #include -static const char *dmxExecOS(void) +static const char * +dmxExecOS(void) { static char buffer[128]; - static int initialized = 0; + static int initialized = 0; struct utsname u; if (!initialized++) { memset(buffer, 0, sizeof(buffer)); uname(&u); - snprintf(buffer, sizeof(buffer)-1, "%s %s %s", - u.sysname, u.release, u.version); + snprintf(buffer, sizeof(buffer) - 1, "%s %s %s", + u.sysname, u.release, u.version); } return buffer; } #endif -static const char *dmxBuildCompiler(void) +static const char * +dmxBuildCompiler(void) { static char buffer[128]; - static int initialized = 0; + static int initialized = 0; if (!initialized++) { memset(buffer, 0, sizeof(buffer)); #if defined(__GNUC__) && defined(__GNUC_MINOR__) &&defined(__GNUC_PATCHLEVEL__) - snprintf(buffer, sizeof(buffer)-1, "gcc %d.%d.%d", - __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__); + snprintf(buffer, sizeof(buffer) - 1, "gcc %d.%d.%d", + __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__); #endif } return buffer; } -static const char *dmxExecHost(void) +static const char * +dmxExecHost(void) { static char buffer[128]; - static int initialized = 0; + static int initialized = 0; if (!initialized++) { memset(buffer, 0, sizeof(buffer)); @@ -551,32 +587,35 @@ static const char *dmxExecHost(void) } /** This routine is called in Xserver/dix/main.c from \a main(). */ -void InitOutput(ScreenInfo *pScreenInfo, int argc, char *argv[]) +void +InitOutput(ScreenInfo * pScreenInfo, int argc, char *argv[]) { - int i; + int i; static unsigned long dmxGeneration = 0; + #ifdef GLXEXT - Bool glxSupported = TRUE; + Bool glxSupported = TRUE; #endif if (dmxGeneration != serverGeneration) { - int vendrel = VENDOR_RELEASE; + int vendrel = VENDOR_RELEASE; int major, minor, year, month, day; - + dmxGeneration = serverGeneration; - major = vendrel / 100000000; - vendrel -= major * 100000000; - minor = vendrel / 1000000; - vendrel -= minor * 1000000; - year = vendrel / 10000; - vendrel -= year * 10000; - month = vendrel / 100; - vendrel -= month * 100; - day = vendrel; + major = vendrel / 100000000; + vendrel -= major * 100000000; + minor = vendrel / 1000000; + vendrel -= minor * 1000000; + year = vendrel / 10000; + vendrel -= year * 10000; + month = vendrel / 100; + vendrel -= month * 100; + day = vendrel; - /* Add other epoch tests here */ - if (major > 0 && minor > 0) year += 2000; + /* Add other epoch tests here */ + if (major > 0 && minor > 0) + year += 2000; dmxLog(dmxInfo, "Generation: %d\n", dmxGeneration); dmxLog(dmxInfo, "DMX version: %d.%d.%02d%02d%02d (%s)\n", @@ -600,32 +639,33 @@ void InitOutput(ScreenInfo *pScreenInfo, int argc, char *argv[]) dmxStatFree(dmxScreens[i].stat); dmxScreens[i].stat = NULL; } - for (i = 0; i < dmxNumInputs; i++) dmxInputFree(&dmxInputs[i]); + for (i = 0; i < dmxNumInputs; i++) + dmxInputFree(&dmxInputs[i]); free(dmxScreens); free(dmxInputs); - dmxScreens = NULL; - dmxInputs = NULL; + dmxScreens = NULL; + dmxInputs = NULL; dmxNumScreens = 0; - dmxNumInputs = 0; + dmxNumInputs = 0; } /* Make sure that the command-line arguments are sane. */ if (dmxAddRemoveScreens && dmxGLXProxy) { - /* Currently it is not possible to support GLX and Render - * extensions with dynamic screen addition/removal due to the - * state that each extension keeps, which cannot be restored. */ + /* Currently it is not possible to support GLX and Render + * extensions with dynamic screen addition/removal due to the + * state that each extension keeps, which cannot be restored. */ dmxLog(dmxWarning, - "GLX Proxy and Render extensions do not yet support dynamic\n"); + "GLX Proxy and Render extensions do not yet support dynamic\n"); dmxLog(dmxWarning, - "screen addition and removal. Please specify -noglxproxy\n"); + "screen addition and removal. Please specify -noglxproxy\n"); dmxLog(dmxWarning, - "and -norender on the command line or in the configuration\n"); + "and -norender on the command line or in the configuration\n"); dmxLog(dmxWarning, - "file to disable these two extensions if you wish to use\n"); + "file to disable these two extensions if you wish to use\n"); dmxLog(dmxWarning, - "the dynamic addition and removal of screens support.\n"); + "the dynamic addition and removal of screens support.\n"); dmxLog(dmxFatal, - "Dynamic screen addition/removal error (see above).\n"); + "Dynamic screen addition/removal error (see above).\n"); } /* ddxProcessArgument has been called at this point, but any data @@ -636,17 +676,16 @@ void InitOutput(ScreenInfo *pScreenInfo, int argc, char *argv[]) dmxLog(dmxFatal, "InitOutput: no back-end displays found\n"); if (!dmxNumInputs) dmxLog(dmxInfo, "InitOutput: no inputs found\n"); - + /* Disable lazy window creation optimization if offscreen * optimization is disabled */ if (!dmxOffScreenOpt && dmxLazyWindowCreation) { dmxLog(dmxInfo, - "InitOutput: Disabling lazy window creation optimization\n"); + "InitOutput: Disabling lazy window creation optimization\n"); dmxLog(dmxInfo, - " since it requires the offscreen optimization\n"); - dmxLog(dmxInfo, - " to function properly.\n"); - dmxLazyWindowCreation = FALSE; + " since it requires the offscreen optimization\n"); + dmxLog(dmxInfo, " to function properly.\n"); + dmxLazyWindowCreation = FALSE; } /* Open each display and gather information about it. */ @@ -662,8 +701,9 @@ void InitOutput(ScreenInfo *pScreenInfo, int argc, char *argv[]) #endif /* Since we only have a single screen thus far, we only need to set - the pixmap formats to match that screen. FIXME: this isn't true.*/ - if (!dmxSetPixmapFormats(pScreenInfo, &dmxScreens[0])) return; + the pixmap formats to match that screen. FIXME: this isn't true. */ + if (!dmxSetPixmapFormats(pScreenInfo, &dmxScreens[0])) + return; /* Might want to install a signal handler to allow cleaning up after * unexpected signals. The DIX/OS layer already handles SIGINT and @@ -682,93 +722,95 @@ void InitOutput(ScreenInfo *pScreenInfo, int argc, char *argv[]) #ifdef GLXEXT /* Check if GLX extension exists on all back-end servers */ for (i = 0; i < dmxNumScreens; i++) - glxSupported &= (dmxScreens[i].glxMajorOpcode > 0); + glxSupported &= (dmxScreens[i].glxMajorOpcode > 0); #endif /* Tell dix layer about the backend displays */ for (i = 0; i < dmxNumScreens; i++) { #ifdef GLXEXT - if (glxSupported) { - /* - * Builds GLX configurations from the list of visuals - * supported by the back-end server, and give that - * configuration list to the glx layer - so that he will - * build the visuals accordingly. - */ - - DMXScreenInfo *dmxScreen = &dmxScreens[i]; - __GLXvisualConfig *configs = NULL; - dmxGlxVisualPrivate **configprivs = NULL; - int nconfigs = 0; - int (*oldErrorHandler)(Display *, XErrorEvent *); - int i; - - /* Catch errors if when using an older GLX w/o FBconfigs */ - oldErrorHandler = XSetErrorHandler(dmxNOPErrorHandler); - - /* Get FBConfigs of the back-end server */ - dmxScreen->fbconfigs = GetGLXFBConfigs(dmxScreen->beDisplay, - dmxScreen->glxMajorOpcode, - &dmxScreen->numFBConfigs); - - XSetErrorHandler(oldErrorHandler); - - dmxScreen->glxVisuals = - GetGLXVisualConfigs(dmxScreen->beDisplay, - DefaultScreen(dmxScreen->beDisplay), - &dmxScreen->numGlxVisuals); - - if (dmxScreen->fbconfigs) { - configs = - GetGLXVisualConfigsFromFBConfigs(dmxScreen->fbconfigs, - dmxScreen->numFBConfigs, - dmxScreen->beVisuals, - dmxScreen->beNumVisuals, - dmxScreen->glxVisuals, - dmxScreen->numGlxVisuals, - &nconfigs); - } else { - configs = dmxScreen->glxVisuals; - nconfigs = dmxScreen->numGlxVisuals; - } - - configprivs = malloc(nconfigs * sizeof(dmxGlxVisualPrivate*)); - - if (configs != NULL && configprivs != NULL) { - - /* Initialize our private info for each visual - * (currently only x_visual_depth and x_visual_class) - */ - for (i = 0; i < nconfigs; i++) { - - configprivs[i] = (dmxGlxVisualPrivate *) - malloc(sizeof(dmxGlxVisualPrivate)); - configprivs[i]->x_visual_depth = 0; - configprivs[i]->x_visual_class = 0; - - /* Find the visual depth */ - if (configs[i].vid > 0) { - int j; - for (j = 0; j < dmxScreen->beNumVisuals; j++) { - if (dmxScreen->beVisuals[j].visualid == - configs[i].vid) { - configprivs[i]->x_visual_depth = - dmxScreen->beVisuals[j].depth; - configprivs[i]->x_visual_class = - dmxScreen->beVisuals[j].class; - break; - } - } - } - } + if (glxSupported) { + /* + * Builds GLX configurations from the list of visuals + * supported by the back-end server, and give that + * configuration list to the glx layer - so that he will + * build the visuals accordingly. + */ + + DMXScreenInfo *dmxScreen = &dmxScreens[i]; + __GLXvisualConfig *configs = NULL; + dmxGlxVisualPrivate **configprivs = NULL; + int nconfigs = 0; + int (*oldErrorHandler) (Display *, XErrorEvent *); + int i; + + /* Catch errors if when using an older GLX w/o FBconfigs */ + oldErrorHandler = XSetErrorHandler(dmxNOPErrorHandler); + + /* Get FBConfigs of the back-end server */ + dmxScreen->fbconfigs = GetGLXFBConfigs(dmxScreen->beDisplay, + dmxScreen->glxMajorOpcode, + &dmxScreen->numFBConfigs); + + XSetErrorHandler(oldErrorHandler); + + dmxScreen->glxVisuals = + GetGLXVisualConfigs(dmxScreen->beDisplay, + DefaultScreen(dmxScreen->beDisplay), + &dmxScreen->numGlxVisuals); + + if (dmxScreen->fbconfigs) { + configs = + GetGLXVisualConfigsFromFBConfigs(dmxScreen->fbconfigs, + dmxScreen->numFBConfigs, + dmxScreen->beVisuals, + dmxScreen->beNumVisuals, + dmxScreen->glxVisuals, + dmxScreen->numGlxVisuals, + &nconfigs); + } + else { + configs = dmxScreen->glxVisuals; + nconfigs = dmxScreen->numGlxVisuals; + } + + configprivs = malloc(nconfigs * sizeof(dmxGlxVisualPrivate *)); + + if (configs != NULL && configprivs != NULL) { + + /* Initialize our private info for each visual + * (currently only x_visual_depth and x_visual_class) + */ + for (i = 0; i < nconfigs; i++) { + + configprivs[i] = (dmxGlxVisualPrivate *) + malloc(sizeof(dmxGlxVisualPrivate)); + configprivs[i]->x_visual_depth = 0; + configprivs[i]->x_visual_class = 0; + + /* Find the visual depth */ + if (configs[i].vid > 0) { + int j; + + for (j = 0; j < dmxScreen->beNumVisuals; j++) { + if (dmxScreen->beVisuals[j].visualid == + configs[i].vid) { + configprivs[i]->x_visual_depth = + dmxScreen->beVisuals[j].depth; + configprivs[i]->x_visual_class = + dmxScreen->beVisuals[j].class; + break; + } + } + } + } XFlush(dmxScreen->beDisplay); - } - } -#endif /* GLXEXT */ + } + } +#endif /* GLXEXT */ - AddScreen(dmxScreenInit, argc, argv); + AddScreen(dmxScreenInit, argc, argv); } /* Compute origin information. */ @@ -787,30 +829,32 @@ void InitOutput(ScreenInfo *pScreenInfo, int argc, char *argv[]) /* Initialize the render extension */ if (!noRenderExtension) - dmxInitRender(); + dmxInitRender(); /* Initialized things that need timer hooks */ dmxStatInit(); dmxSyncInit(); /* Calls RegisterBlockAndWakeupHandlers */ dmxLog(dmxInfo, "Shadow framebuffer support %s\n", - dmxShadowFB ? "enabled" : "disabled"); + dmxShadowFB ? "enabled" : "disabled"); } /* RATS: Assuming the fp string (which comes from the command-line argv vector) is NULL-terminated, the buffer is large enough for the - strcpy. */ -static void dmxSetDefaultFontPath(const char *fp) + strcpy. */ +static void +dmxSetDefaultFontPath(const char *fp) { if (dmxFontPath) { - int fplen = strlen(fp) + 1; - int len = strlen(dmxFontPath); - - dmxFontPath = realloc(dmxFontPath, len+fplen+1); - dmxFontPath[len] = ','; - strncpy(&dmxFontPath[len+1], fp, fplen); - } else { - dmxFontPath = strdup(fp); + int fplen = strlen(fp) + 1; + int len = strlen(dmxFontPath); + + dmxFontPath = realloc(dmxFontPath, len + fplen + 1); + dmxFontPath[len] = ','; + strncpy(&dmxFontPath[len + 1], fp, fplen); + } + else { + dmxFontPath = strdup(fp); } defaultFontPath = dmxFontPath; @@ -819,20 +863,23 @@ static void dmxSetDefaultFontPath(const char *fp) /** This function is called in Xserver/os/utils.c from \a AbortServer(). * We must ensure that backend and console state is restored in the * event the server shutdown wasn't clean. */ -void AbortDDX(enum ExitCode error) +void +AbortDDX(enum ExitCode error) { int i; - for (i=0; i < dmxNumScreens; i++) { + for (i = 0; i < dmxNumScreens; i++) { DMXScreenInfo *dmxScreen = &dmxScreens[i]; - - if (dmxScreen->beDisplay) XCloseDisplay(dmxScreen->beDisplay); + + if (dmxScreen->beDisplay) + XCloseDisplay(dmxScreen->beDisplay); dmxScreen->beDisplay = NULL; } } #ifdef DDXBEFORERESET -void ddxBeforeReset(void) +void +ddxBeforeReset(void) { } #endif @@ -840,13 +887,15 @@ void ddxBeforeReset(void) /** This function is called in Xserver/dix/main.c from \a main() when * dispatchException & DE_TERMINATE (which is the only way to exit the * main loop without an interruption. */ -void ddxGiveUp(enum ExitCode error) +void +ddxGiveUp(enum ExitCode error) { AbortDDX(error); } /** This function is called in Xserver/os/osinit.c from \a OsInit(). */ -void OsVendorInit(void) +void +OsVendorInit(void) { } @@ -855,100 +904,134 @@ void OsVendorInit(void) * OsVendorVErrorFProc will cause \a VErrorF() (which is called by the * two routines mentioned here, as well as by others) to use the * referenced routine instead of \a vfprintf().) */ -void OsVendorFatalError(void) +void +OsVendorFatalError(void) { } /** Process our command line arguments. */ -int ddxProcessArgument(int argc, char *argv[], int i) +int +ddxProcessArgument(int argc, char *argv[], int i) { int retval = 0; - + if (!strcmp(argv[i], "-display")) { - if (++i < argc) dmxConfigStoreDisplay(argv[i]); + if (++i < argc) + dmxConfigStoreDisplay(argv[i]); retval = 2; - } else if (!strcmp(argv[i], "-inputfrom") || !strcmp(argv[i], "-input")) { - if (++i < argc) dmxConfigStoreInput(argv[i]); + } + else if (!strcmp(argv[i], "-inputfrom") || !strcmp(argv[i], "-input")) { + if (++i < argc) + dmxConfigStoreInput(argv[i]); retval = 2; - } else if (!strcmp(argv[i], "-xinputfrom") || !strcmp(argv[i],"-xinput")) { - if (++i < argc) dmxConfigStoreXInput(argv[i]); + } + else if (!strcmp(argv[i], "-xinputfrom") || !strcmp(argv[i], "-xinput")) { + if (++i < argc) + dmxConfigStoreXInput(argv[i]); retval = 2; - } else if (!strcmp(argv[i], "-noshadowfb")) { + } + else if (!strcmp(argv[i], "-noshadowfb")) { dmxLog(dmxWarning, "-noshadowfb has been deprecated " - "since it is now the default\n"); - dmxShadowFB = FALSE; - retval = 1; - } else if (!strcmp(argv[i], "-nomulticursor")) { + "since it is now the default\n"); + dmxShadowFB = FALSE; + retval = 1; + } + else if (!strcmp(argv[i], "-nomulticursor")) { dmxCursorNoMulti(); - retval = 1; - } else if (!strcmp(argv[i], "-shadowfb")) { - dmxShadowFB = TRUE; - retval = 1; - } else if (!strcmp(argv[i], "-configfile")) { - if (++i < argc) dmxConfigStoreFile(argv[i]); + retval = 1; + } + else if (!strcmp(argv[i], "-shadowfb")) { + dmxShadowFB = TRUE; + retval = 1; + } + else if (!strcmp(argv[i], "-configfile")) { + if (++i < argc) + dmxConfigStoreFile(argv[i]); retval = 2; - } else if (!strcmp(argv[i], "-config")) { - if (++i < argc) dmxConfigStoreConfig(argv[i]); + } + else if (!strcmp(argv[i], "-config")) { + if (++i < argc) + dmxConfigStoreConfig(argv[i]); retval = 2; - } else if (!strcmp(argv[i], "-fontpath")) { - if (++i < argc) dmxSetDefaultFontPath(argv[i]); + } + else if (!strcmp(argv[i], "-fontpath")) { + if (++i < argc) + dmxSetDefaultFontPath(argv[i]); retval = 2; - } else if (!strcmp(argv[i], "-stat")) { - if ((i += 2) < argc) dmxStatActivate(argv[i-1], argv[i]); + } + else if (!strcmp(argv[i], "-stat")) { + if ((i += 2) < argc) + dmxStatActivate(argv[i - 1], argv[i]); retval = 3; - } else if (!strcmp(argv[i], "-syncbatch")) { - if (++i < argc) dmxSyncActivate(argv[i]); + } + else if (!strcmp(argv[i], "-syncbatch")) { + if (++i < argc) + dmxSyncActivate(argv[i]); retval = 2; - } else if (!strcmp(argv[i], "-nooffscreenopt")) { - dmxOffScreenOpt = FALSE; + } + else if (!strcmp(argv[i], "-nooffscreenopt")) { + dmxOffScreenOpt = FALSE; retval = 1; - } else if (!strcmp(argv[i], "-nosubdivprims")) { - dmxSubdividePrimitives = FALSE; + } + else if (!strcmp(argv[i], "-nosubdivprims")) { + dmxSubdividePrimitives = FALSE; retval = 1; - } else if (!strcmp(argv[i], "-nowindowopt")) { - dmxLazyWindowCreation = FALSE; + } + else if (!strcmp(argv[i], "-nowindowopt")) { + dmxLazyWindowCreation = FALSE; retval = 1; - } else if (!strcmp(argv[i], "-noxkb")) { - dmxUseXKB = FALSE; + } + else if (!strcmp(argv[i], "-noxkb")) { + dmxUseXKB = FALSE; retval = 1; - } else if (!strcmp(argv[i], "-depth")) { - if (++i < argc) dmxDepth = atoi(argv[i]); + } + else if (!strcmp(argv[i], "-depth")) { + if (++i < argc) + dmxDepth = atoi(argv[i]); retval = 2; - } else if (!strcmp(argv[i], "-norender")) { - noRenderExtension = TRUE; + } + else if (!strcmp(argv[i], "-norender")) { + noRenderExtension = TRUE; retval = 1; #ifdef GLXEXT - } else if (!strcmp(argv[i], "-noglxproxy")) { - dmxGLXProxy = FALSE; + } + else if (!strcmp(argv[i], "-noglxproxy")) { + dmxGLXProxy = FALSE; retval = 1; - } else if (!strcmp(argv[i], "-noglxswapgroup")) { - dmxGLXSwapGroupSupport = FALSE; + } + else if (!strcmp(argv[i], "-noglxswapgroup")) { + dmxGLXSwapGroupSupport = FALSE; retval = 1; - } else if (!strcmp(argv[i], "-glxsyncswap")) { - dmxGLXSyncSwap = TRUE; + } + else if (!strcmp(argv[i], "-glxsyncswap")) { + dmxGLXSyncSwap = TRUE; retval = 1; - } else if (!strcmp(argv[i], "-glxfinishswap")) { - dmxGLXFinishSwap = TRUE; + } + else if (!strcmp(argv[i], "-glxfinishswap")) { + dmxGLXFinishSwap = TRUE; retval = 1; #endif - } else if (!strcmp(argv[i], "-ignorebadfontpaths")) { - dmxIgnoreBadFontPaths = TRUE; + } + else if (!strcmp(argv[i], "-ignorebadfontpaths")) { + dmxIgnoreBadFontPaths = TRUE; retval = 1; - } else if (!strcmp(argv[i], "-addremovescreens")) { - dmxAddRemoveScreens = TRUE; + } + else if (!strcmp(argv[i], "-addremovescreens")) { + dmxAddRemoveScreens = TRUE; retval = 1; - } else if (!strcmp(argv[i], "-param")) { + } + else if (!strcmp(argv[i], "-param")) { if ((i += 2) < argc) { - if (!strcasecmp(argv[i-1], "xkbrules")) + if (!strcasecmp(argv[i - 1], "xkbrules")) dmxConfigSetXkbRules(argv[i]); - else if (!strcasecmp(argv[i-1], "xkbmodel")) + else if (!strcasecmp(argv[i - 1], "xkbmodel")) dmxConfigSetXkbModel(argv[i]); - else if (!strcasecmp(argv[i-1], "xkblayout")) + else if (!strcasecmp(argv[i - 1], "xkblayout")) dmxConfigSetXkbLayout(argv[i]); - else if (!strcasecmp(argv[i-1], "xkbvariant")) + else if (!strcasecmp(argv[i - 1], "xkbvariant")) dmxConfigSetXkbVariant(argv[i]); - else if (!strcasecmp(argv[i-1], "xkboptions")) + else if (!strcasecmp(argv[i - 1], "xkboptions")) dmxConfigSetXkbOptions(argv[i]); else dmxLog(dmxWarning, @@ -957,12 +1040,14 @@ int ddxProcessArgument(int argc, char *argv[], int i) } retval = 3; } - if (!serverGeneration) dmxConfigSetMaxScreens(); + if (!serverGeneration) + dmxConfigSetMaxScreens(); return retval; } /** Provide succinct usage information for the DMX server. */ -void ddxUseMsg(void) +void +ddxUseMsg(void) { ErrorF("\n\nDevice Dependent Usage:\n"); ErrorF("-display string Specify the back-end display(s)\n"); @@ -990,7 +1075,8 @@ void ddxUseMsg(void) ErrorF("-glxsyncswap Force XSync after swap buffers\n"); ErrorF("-glxfinishswap Force glFinish after swap buffers\n"); #endif - ErrorF("-ignorebadfontpaths Ignore bad font paths during initialization\n"); + ErrorF + ("-ignorebadfontpaths Ignore bad font paths during initialization\n"); ErrorF("-addremovescreens Enable dynamic screen addition/removal\n"); ErrorF("-param ... Specify configuration parameters (e.g.,\n"); ErrorF(" XkbRules, XkbModel, XkbLayout, etc.)\n"); @@ -1002,13 +1088,13 @@ void ddxUseMsg(void) " that display in addition to the backend input. This is\n" " useful if the backend window does not cover the whole\n" " physical display.\n\n"); - + ErrorF(" Otherwise, if the -input or -xinput string specifies another\n" " X display, then a console window will be created on that\n" " display. Placing \",windows\" or \",nowindows\" after the\n" " display name will control the display of window outlines in\n" " the console.\n\n"); - + ErrorF(" -input or -xinput dummy specifies no input.\n"); ErrorF(" -input or -xinput local specifies the use of a raw keyboard,\n" " mouse, or other (extension) device:\n" @@ -1017,7 +1103,7 @@ void ddxUseMsg(void) " -input local,usb-kbd,usb-mou will use USB devices \n" " -xinput local,usb-oth will use a non-mouse and\n" " non-keyboard USB device with XInput\n\n"); - + ErrorF(" Special Keys:\n"); ErrorF(" Ctrl-Alt-g Server grab/ungrab (console only)\n"); ErrorF(" Ctrl-Alt-f Fine (1-pixel) mouse mode (console only)\n"); -- cgit v1.2.3