From f87ad0cdc41af88f134475ab50b0d604004d9cdc Mon Sep 17 00:00:00 2001 From: marha Date: Mon, 1 Aug 2011 09:05:15 +0200 Subject: mesa xserver pixman xkeyboard-config git update 1 aug 2011 --- xorg-server/hw/dmx/dmxinit.c | 2056 ++++++++++---------- xorg-server/hw/kdrive/src/kdrive.c | 6 +- xorg-server/hw/vfb/InitOutput.c | 1938 +++++++++--------- xorg-server/hw/xfree86/common/xf86Config.c | 3 + xorg-server/hw/xfree86/common/xf86Configure.c | 2 +- xorg-server/hw/xfree86/common/xf86Helper.c | 4 +- xorg-server/hw/xfree86/common/xf86Init.c | 40 +- xorg-server/hw/xfree86/common/xf86Option.c | 2 +- xorg-server/hw/xfree86/common/xf86Priv.h | 2 +- xorg-server/hw/xfree86/common/xf86ShowOpts.c | 260 +-- xorg-server/hw/xfree86/common/xf86Xinput.c | 1 + xorg-server/hw/xnest/Init.c | 6 +- xorg-server/hw/xquartz/darwin.c | 6 +- xorg-server/hw/xwin/InitOutput.c | 10 +- xorg-server/hw/xwin/Makefile.am | 22 +- xorg-server/hw/xwin/winerror.c | 292 +-- xorg-server/hw/xwin/xlaunch/COPYING | 25 - xorg-server/hw/xwin/xlaunch/Makefile | 79 - xorg-server/hw/xwin/xlaunch/config.cc | 282 --- xorg-server/hw/xwin/xlaunch/config.h | 60 - xorg-server/hw/xwin/xlaunch/main.cc | 700 ------- xorg-server/hw/xwin/xlaunch/resources/dialog.rc | 118 -- .../hw/xwin/xlaunch/resources/fullscreen.bmp | Bin 22554 -> 0 bytes xorg-server/hw/xwin/xlaunch/resources/images.rc | 29 - .../hw/xwin/xlaunch/resources/multiwindow.bmp | Bin 22554 -> 0 bytes .../hw/xwin/xlaunch/resources/nodecoration.bmp | Bin 22554 -> 0 bytes xorg-server/hw/xwin/xlaunch/resources/resources.h | 99 - xorg-server/hw/xwin/xlaunch/resources/resources.rc | 30 - xorg-server/hw/xwin/xlaunch/resources/strings.rc | 108 - xorg-server/hw/xwin/xlaunch/resources/windowed.bmp | Bin 22554 -> 0 bytes xorg-server/hw/xwin/xlaunch/window/dialog.cc | 86 - xorg-server/hw/xwin/xlaunch/window/dialog.h | 54 - xorg-server/hw/xwin/xlaunch/window/util.cc | 1112 ----------- xorg-server/hw/xwin/xlaunch/window/util.h | 53 - xorg-server/hw/xwin/xlaunch/window/window.cc | 284 --- xorg-server/hw/xwin/xlaunch/window/window.h | 114 -- xorg-server/hw/xwin/xlaunch/window/wizard.cc | 244 --- xorg-server/hw/xwin/xlaunch/window/wizard.h | 59 - 38 files changed, 2328 insertions(+), 5858 deletions(-) delete mode 100644 xorg-server/hw/xwin/xlaunch/COPYING delete mode 100644 xorg-server/hw/xwin/xlaunch/Makefile delete mode 100644 xorg-server/hw/xwin/xlaunch/config.cc delete mode 100644 xorg-server/hw/xwin/xlaunch/config.h delete mode 100644 xorg-server/hw/xwin/xlaunch/main.cc delete mode 100644 xorg-server/hw/xwin/xlaunch/resources/dialog.rc delete mode 100644 xorg-server/hw/xwin/xlaunch/resources/fullscreen.bmp delete mode 100644 xorg-server/hw/xwin/xlaunch/resources/images.rc delete mode 100644 xorg-server/hw/xwin/xlaunch/resources/multiwindow.bmp delete mode 100644 xorg-server/hw/xwin/xlaunch/resources/nodecoration.bmp delete mode 100644 xorg-server/hw/xwin/xlaunch/resources/resources.h delete mode 100644 xorg-server/hw/xwin/xlaunch/resources/resources.rc delete mode 100644 xorg-server/hw/xwin/xlaunch/resources/strings.rc delete mode 100644 xorg-server/hw/xwin/xlaunch/resources/windowed.bmp delete mode 100644 xorg-server/hw/xwin/xlaunch/window/dialog.cc delete mode 100644 xorg-server/hw/xwin/xlaunch/window/dialog.h delete mode 100644 xorg-server/hw/xwin/xlaunch/window/util.cc delete mode 100644 xorg-server/hw/xwin/xlaunch/window/util.h delete mode 100644 xorg-server/hw/xwin/xlaunch/window/window.cc delete mode 100644 xorg-server/hw/xwin/xlaunch/window/window.h delete mode 100644 xorg-server/hw/xwin/xlaunch/window/wizard.cc delete mode 100644 xorg-server/hw/xwin/xlaunch/window/wizard.h (limited to 'xorg-server/hw') diff --git a/xorg-server/hw/dmx/dmxinit.c b/xorg-server/hw/dmx/dmxinit.c index e0e5d1228..bc1509b35 100644 --- a/xorg-server/hw/dmx/dmxinit.c +++ b/xorg-server/hw/dmx/dmxinit.c @@ -1,1028 +1,1028 @@ -/* - * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina. - * - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation on the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* - * Authors: - * Kevin E. Martin - * David H. Dawes - * Rickard E. (Rik) Faith - * - */ - -/** \file - * Provide expected functions for initialization from the ddx layer and - * global variables for the DMX server. */ - -#ifdef HAVE_DMX_CONFIG_H -#include -#endif - -#include "dmx.h" -#include "dmxinit.h" -#include "dmxsync.h" -#include "dmxlog.h" -#include "dmxinput.h" -#include "dmxscrinit.h" -#include "dmxcursor.h" -#include "dmxfont.h" -#include "config/dmxconfig.h" -#include "dmxcb.h" -#include "dmxprop.h" -#include "dmxstat.h" -#include "dmxpict.h" - -#include /* For gettimeofday */ -#include "dixstruct.h" -#ifdef PANORAMIX -#include "panoramiXsrv.h" -#endif - -#include /* For SIGQUIT */ - -#ifdef GLXEXT -#include -#include -#include "dmx_glxvisuals.h" -#include -#include -#endif /* GLXEXT */ - -/* Global variables available to all Xserver/hw/dmx routines. */ -int dmxNumScreens; -DMXScreenInfo *dmxScreens; - -int dmxNumInputs; -DMXInputInfo *dmxInputs; - -int dmxShadowFB = FALSE; - -XErrorEvent dmxLastErrorEvent; -Bool dmxErrorOccurred = FALSE; - -char *dmxFontPath = NULL; - -Bool dmxOffScreenOpt = TRUE; - -Bool dmxSubdividePrimitives = TRUE; - -Bool dmxLazyWindowCreation = TRUE; - -Bool dmxUseXKB = TRUE; - -int dmxDepth = 0; - -#ifndef GLXEXT -static Bool dmxGLXProxy = FALSE; -#else -Bool dmxGLXProxy = TRUE; - -Bool dmxGLXSwapGroupSupport = TRUE; - -Bool dmxGLXSyncSwap = FALSE; - -Bool dmxGLXFinishSwap = FALSE; -#endif - -Bool dmxIgnoreBadFontPaths = 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) -{ -#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]; - _XExtension *ext = NULL; - - dmxErrorOccurred = TRUE; - dmxLastErrorEvent = *ev; - - XGetErrorText(dpy, ev->error_code, buf, sizeof(buf)); - dmxLog(dmxWarning, "dmxErrorHandler: %s\n", buf); - - /* Find major opcode name */ - if (ev->request_code < 128) { - XmuSnprintf(request, sizeof(request), "%d", ev->request_code); - XGetErrorDatabaseText(dpy, "XRequest", request, "", buf, sizeof(buf)); - } else { - for (ext = dpy->ext_procs; - ext && ext->codes.major_opcode != ev->request_code; - ext = ext->next); - if (ext) strncpy(buf, ext->name, sizeof(buf)); - else buf[0] = '\0'; - } - dmxLog(dmxWarning, " Major opcode: %d (%s)\n", - ev->request_code, buf); - - /* Find minor opcode name */ - if (ev->request_code >= 128 && ext) { - XmuSnprintf(request, sizeof(request), "%d", ev->request_code); - XmuSnprintf(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 */ - switch (ev->error_code) { - case BadValue: - dmxLog(dmxWarning, " Value: 0x%x\n", - ev->resourceid); - break; - case BadAtom: - dmxLog(dmxWarning, " AtomID: 0x%x\n", - ev->resourceid); - break; - default: - dmxLog(dmxWarning, " ResourceID: 0x%x\n", - ev->resourceid); - break; - } - - /* Provide serial number information */ - dmxLog(dmxWarning, " Failed serial number: %d\n", - ev->serial); - dmxLog(dmxWarning, " Current serial number: %d\n", - dpy->request); - return 0; -} - -#ifdef GLXEXT -static int dmxNOPErrorHandler(Display *dpy, XErrorEvent *ev) -{ - return 0; -} -#endif - -Bool dmxOpenDisplay(DMXScreenInfo *dmxScreen) -{ - if (!(dmxScreen->beDisplay = XOpenDisplay(dmxScreen->name))) - return FALSE; - - dmxPropertyDisplay(dmxScreen); - return TRUE; -} - -void dmxSetErrorHandler(DMXScreenInfo *dmxScreen) -{ - XSetErrorHandler(dmxErrorHandler); -} - -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); - - XGetWindowAttributes(dpy, DefaultRootWindow(dpy), &attribs); - 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); - int major = -1, minor = -1, patch = -1, subpatch = -1; - - if (v < 336) - major = v / 100, minor = (v / 10) % 10, patch = v % 10; - else if (v < 3900) { - major = v / 1000; - minor = (v / 100) % 10; - if (((v / 10) % 10) || (v % 10)) { - patch = (v / 10) % 10; - if (v % 10) subpatch = v % 10; - } - } else if (v < 40000000) { - major = v / 1000; - minor = (v / 10) % 10; - if (v % 10) patch = v % 10; - } else { - major = v / 10000000; - minor = (v / 100000) % 100; - patch = (v / 1000) % 100; - 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); - dmxLogOutputCont(dmxScreen, ")\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++) - dmxLogOutputCont(dmxScreen, "%c%d", i ? ',' : ' ', depths[i]); - dmxLogOutputCont(dmxScreen, "\n"); - dmxLogOutput(dmxScreen, "Depth of root window: %d plane%s (%d)\n", - attribs.depth, attribs.depth == 1 ? "" : "s", - DisplayPlanes(dpy, scr)); - 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"); - dmxLogOutput(dmxScreen, "Window Manager running: %s\n", - (dmxScreen->WMRunningOnBE) ? "yes" : "no"); - - if (dmxScreen->WMRunningOnBE) { - dmxLogOutputWarning(dmxScreen, - "Window manager running " - "-- colormaps not supported\n"); - } - XFree(depths); -} - -void dmxGetScreenAttribs(DMXScreenInfo *dmxScreen) -{ - XWindowAttributes attribs; - Display *dpy = dmxScreen->beDisplay; -#ifdef GLXEXT - int dummy; -#endif - - XGetWindowAttributes(dpy, DefaultRootWindow(dpy), &attribs); - - dmxScreen->beWidth = attribs.width; - dmxScreen->beHeight = attribs.height; - - /* 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; - } - } - if (dmxScreen->scrnYSign < 0) { - if (dmxScreen->scrnHeight) { - dmxScreen->scrnY = (attribs.height - dmxScreen->scrnHeight - - dmxScreen->scrnY); - } else { - dmxScreen->scrnHeight = attribs.height - dmxScreen->scrnY; - dmxScreen->scrnY = 0; - } - } - if (!dmxScreen->scrnWidth) - 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->rootX > dmxScreen->scrnWidth) - dmxScreen->rootWidth = dmxScreen->scrnWidth - dmxScreen->rootX; - if (dmxScreen->rootHeight + dmxScreen->rootY > dmxScreen->scrnHeight) - dmxScreen->rootHeight = dmxScreen->scrnHeight - dmxScreen->rootY; - - /* FIXME: Get these from the back-end server */ - 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; - -#ifdef GLXEXT - /* get the majorOpcode for the back-end GLX extension */ - XQueryExtension(dpy, "GLX", &dmxScreen->glxMajorOpcode, - &dummy, &dmxScreen->glxErrorBase); -#endif - - dmxPrintScreenInfo(dmxScreen); - dmxLogOutput(dmxScreen, "%dx%d+%d+%d on %dx%d at depth=%d, bpp=%d\n", - dmxScreen->scrnWidth, dmxScreen->scrnHeight, - dmxScreen->scrnX, dmxScreen->scrnY, - dmxScreen->beWidth, dmxScreen->beHeight, - dmxScreen->beDepth, dmxScreen->beBPP); - if (dmxScreen->beDepth == 8) - dmxLogOutputWarning(dmxScreen, - "Support for depth == 8 is not complete\n"); -} - -Bool dmxGetVisualInfo(DMXScreenInfo *dmxScreen) -{ - int i; - XVisualInfo visinfo; - - visinfo.screen = DefaultScreen(dmxScreen->beDisplay); - dmxScreen->beVisuals = XGetVisualInfo(dmxScreen->beDisplay, - 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++) - dmxLogVisual(dmxScreen, &dmxScreen->beVisuals[i], - (i == dmxScreen->beDefVisualIndex)); - - return dmxScreen->beDefVisualIndex >= 0; -} - -void dmxGetColormaps(DMXScreenInfo *dmxScreen) -{ - int i; - - dmxScreen->beNumDefColormaps = dmxScreen->beNumVisuals; - dmxScreen->beDefColormaps = malloc(dmxScreen->beNumDefColormaps * - 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->beBlackPixel = BlackPixel(dmxScreen->beDisplay, - DefaultScreen(dmxScreen->beDisplay)); - dmxScreen->beWhitePixel = WhitePixel(dmxScreen->beDisplay, - DefaultScreen(dmxScreen->beDisplay)); -} - -void dmxGetPixmapFormats(DMXScreenInfo *dmxScreen) -{ - dmxScreen->beDepths = - XListDepths(dmxScreen->beDisplay, DefaultScreen(dmxScreen->beDisplay), - &dmxScreen->beNumDepths); - - dmxScreen->bePixmapFormats = - XListPixmapFormats(dmxScreen->beDisplay, - &dmxScreen->beNumPixmapFormats); -} - -static Bool dmxSetPixmapFormats(ScreenInfo *pScreenInfo, - DMXScreenInfo *dmxScreen) -{ - XPixmapFormatValues *bePixmapFormat; - PixmapFormatRec *format; - int i, j; - - pScreenInfo->imageByteOrder = ImageByteOrder(dmxScreen->beDisplay); - pScreenInfo->bitmapScanlineUnit = BitmapUnit(dmxScreen->beDisplay); - pScreenInfo->bitmapScanlinePad = BitmapPad(dmxScreen->beDisplay); - pScreenInfo->bitmapBitOrder = BitmapBitOrder(dmxScreen->beDisplay); - - 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; - } - } - - return TRUE; -} - -void dmxCheckForWM(DMXScreenInfo *dmxScreen) -{ - Status status; - XWindowAttributes xwa; - - status = XGetWindowAttributes(dmxScreen->beDisplay, - DefaultRootWindow(dmxScreen->beDisplay), - &xwa); - dmxScreen->WMRunningOnBE = - (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) -{ - if (!dmxOpenDisplay(dmxScreen)) - 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"); - - dmxGetColormaps(dmxScreen); - dmxGetPixmapFormats(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 ""; } -#else -#include -static const char *dmxExecOS(void) -{ - static char buffer[128]; - static int initialized = 0; - struct utsname u; - - if (!initialized++) { - memset(buffer, 0, sizeof(buffer)); - uname(&u); - XmuSnprintf(buffer, sizeof(buffer)-1, "%s %s %s", - u.sysname, u.release, u.version); - } - return buffer; -} -#endif - -static const char *dmxBuildCompiler(void) -{ - static char buffer[128]; - static int initialized = 0; - - if (!initialized++) { - memset(buffer, 0, sizeof(buffer)); -#if defined(__GNUC__) && defined(__GNUC_MINOR__) &&defined(__GNUC_PATCHLEVEL__) - XmuSnprintf(buffer, sizeof(buffer)-1, "gcc %d.%d.%d", - __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__); -#endif - } - return buffer; -} - -static const char *dmxExecHost(void) -{ - static char buffer[128]; - static int initialized = 0; - - if (!initialized++) { - memset(buffer, 0, sizeof(buffer)); - XmuGetHostname(buffer, sizeof(buffer) - 1); - } - return buffer; -} - -/** This routine is called in Xserver/dix/main.c from \a main(). */ -void InitOutput(ScreenInfo *pScreenInfo, int argc, char *argv[]) -{ - int i; - static unsigned long dmxGeneration = 0; -#ifdef GLXEXT - Bool glxSupported = TRUE; -#endif - - if (dmxGeneration != serverGeneration) { - 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; - - /* 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", - major, minor, year, month, day, VENDOR_STRING); - - SetVendorRelease(VENDOR_RELEASE); - SetVendorString(VENDOR_STRING); - - if (dmxGeneration == 1) { - dmxLog(dmxInfo, "DMX Build OS: %s (%s)\n", OSNAME, OSVENDOR); - dmxLog(dmxInfo, "DMX Build Compiler: %s\n", dmxBuildCompiler()); - dmxLog(dmxInfo, "DMX Execution OS: %s\n", dmxExecOS()); - dmxLog(dmxInfo, "DMX Execution Host: %s\n", dmxExecHost()); - } - dmxLog(dmxInfo, "MAXSCREENS: %d\n", MAXSCREENS); - - for (i = 0; i < dmxNumScreens; i++) { - if (dmxScreens[i].beDisplay) - dmxLog(dmxWarning, "Display \"%s\" still open\n", - dmxScreens[i].name); - dmxStatFree(dmxScreens[i].stat); - dmxScreens[i].stat = NULL; - } - for (i = 0; i < dmxNumInputs; i++) dmxInputFree(&dmxInputs[i]); - free(dmxScreens); - free(dmxInputs); - dmxScreens = NULL; - dmxInputs = NULL; - dmxNumScreens = 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. */ - dmxLog(dmxWarning, - "GLX Proxy and Render extensions do not yet support dynamic\n"); - dmxLog(dmxWarning, - "screen addition and removal. Please specify -noglxproxy\n"); - dmxLog(dmxWarning, - "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"); - dmxLog(dmxWarning, - "the dynamic addition and removal of screens support.\n"); - dmxLog(dmxFatal, - "Dynamic screen addition/removal error (see above).\n"); - } - - /* ddxProcessArgument has been called at this point, but any data - * from the configuration file has not been applied. Do so, and be - * sure we have at least one back-end display. */ - dmxConfigConfigure(); - if (!dmxNumScreens) - 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"); - dmxLog(dmxInfo, - " since it requires the offscreen optimization\n"); - dmxLog(dmxInfo, - " to function properly.\n"); - dmxLazyWindowCreation = FALSE; - } - - /* Open each display and gather information about it. */ - for (i = 0; i < dmxNumScreens; i++) - dmxDisplayInit(&dmxScreens[i]); - -#if PANORAMIX - /* Register a Xinerama callback which will run from within - * PanoramiXCreateConnectionBlock. We can use the callback to - * determine if Xinerama is loaded and to check the visuals - * determined by PanoramiXConsolidate. */ - XineramaRegisterConnectionBlockCallback(dmxConnectionBlockCallback); -#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; - - /* Might want to install a signal handler to allow cleaning up after - * unexpected signals. The DIX/OS layer already handles SIGINT and - * SIGTERM, so everything is OK for expected signals. --DD - * - * SIGHUP, SIGINT, and SIGTERM are trapped in os/connection.c - * SIGQUIT is another common signal that is sent from the keyboard. - * Trap it here, to ensure that the keyboard modifier map and other - * state for the input devices are restored. (This makes the - * behavior of SIGQUIT somewhat unexpected, since it will be the - * same as the behavior of SIGINT. However, leaving the modifier - * map of the input devices empty is even more unexpected.) --RF - */ - OsSignal(SIGQUIT, GiveUp); - -#ifdef GLXEXT - /* Check if GLX extension exists on all back-end servers */ - for (i = 0; i < dmxNumScreens; i++) - 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; - } - } - } - } - - XFlush(dmxScreen->beDisplay); - } - } -#endif /* GLXEXT */ - - AddScreen(dmxScreenInit, argc, argv); - } - - /* Compute origin information. */ - dmxInitOrigins(); - - /* Compute overlap information. */ - dmxInitOverlap(); - - /* Make sure there is a global width/height available */ - dmxComputeWidthHeight(DMX_NO_RECOMPUTE_BOUNDING_BOX); - - /* FIXME: The following is temporarily placed here. When the DMX - * extension is available, it will be move there. - */ - dmxInitFonts(); - - /* Initialize the render extension */ - if (!noRenderExtension) - dmxInitRender(); - - /* Initialized things that need timer hooks */ - dmxStatInit(); - dmxSyncInit(); /* Calls RegisterBlockAndWakeupHandlers */ - - dmxLog(dmxInfo, "Shadow framebuffer support %s\n", - 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(char *fp) -{ - int fplen = strlen(fp) + 1; - - if (dmxFontPath) { - int len; - - len = strlen(dmxFontPath); - dmxFontPath = realloc(dmxFontPath, len+fplen+1); - dmxFontPath[len] = ','; - strncpy(&dmxFontPath[len+1], fp, fplen); - } else { - dmxFontPath = malloc(fplen); - strncpy(dmxFontPath, fp, fplen); - } - - defaultFontPath = dmxFontPath; -} - -/** 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(void) -{ - int i; - - for (i=0; i < dmxNumScreens; i++) { - DMXScreenInfo *dmxScreen = &dmxScreens[i]; - - if (dmxScreen->beDisplay) XCloseDisplay(dmxScreen->beDisplay); - dmxScreen->beDisplay = NULL; - } -} - -#ifdef DDXBEFORERESET -void ddxBeforeReset(void) -{ -} -#endif - -/** 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(void) -{ - AbortDDX(); -} - -/** This function is called in Xserver/os/osinit.c from \a OsInit(). */ -void OsVendorInit(void) -{ -} - -/** This function is called in Xserver/os/utils.c from \a FatalError() - * and \a VFatalError(). (Note that setting the function pointer \a - * 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) -{ -} - -/** Process our command line arguments. */ -int ddxProcessArgument(int argc, char *argv[], int i) -{ - int retval = 0; - - if (!strcmp(argv[i], "-display")) { - if (++i < argc) dmxConfigStoreDisplay(argv[i]); - retval = 2; - } 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]); - retval = 2; - } 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")) { - 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 = 2; - } 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]); - retval = 2; - } 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]); - retval = 2; - } else if (!strcmp(argv[i], "-nooffscreenopt")) { - dmxOffScreenOpt = FALSE; - retval = 1; - } else if (!strcmp(argv[i], "-nosubdivprims")) { - dmxSubdividePrimitives = FALSE; - retval = 1; - } else if (!strcmp(argv[i], "-nowindowopt")) { - dmxLazyWindowCreation = FALSE; - retval = 1; - } else if (!strcmp(argv[i], "-noxkb")) { - dmxUseXKB = FALSE; - retval = 1; - } else if (!strcmp(argv[i], "-depth")) { - if (++i < argc) dmxDepth = atoi(argv[i]); - retval = 2; - } else if (!strcmp(argv[i], "-norender")) { - noRenderExtension = TRUE; - retval = 1; -#ifdef GLXEXT - } else if (!strcmp(argv[i], "-noglxproxy")) { - dmxGLXProxy = FALSE; - retval = 1; - } else if (!strcmp(argv[i], "-noglxswapgroup")) { - dmxGLXSwapGroupSupport = FALSE; - retval = 1; - } else if (!strcmp(argv[i], "-glxsyncswap")) { - dmxGLXSyncSwap = TRUE; - retval = 1; - } else if (!strcmp(argv[i], "-glxfinishswap")) { - dmxGLXFinishSwap = TRUE; - retval = 1; -#endif - } else if (!strcmp(argv[i], "-ignorebadfontpaths")) { - dmxIgnoreBadFontPaths = TRUE; - retval = 1; - } else if (!strcmp(argv[i], "-addremovescreens")) { - dmxAddRemoveScreens = TRUE; - retval = 1; - } else if (!strcmp(argv[i], "-param")) { - if ((i += 2) < argc) { - if (!strcasecmp(argv[i-1], "xkbrules")) - dmxConfigSetXkbRules(argv[i]); - else if (!strcasecmp(argv[i-1], "xkbmodel")) - dmxConfigSetXkbModel(argv[i]); - else if (!strcasecmp(argv[i-1], "xkblayout")) - dmxConfigSetXkbLayout(argv[i]); - else if (!strcasecmp(argv[i-1], "xkbvariant")) - dmxConfigSetXkbVariant(argv[i]); - else if (!strcasecmp(argv[i-1], "xkboptions")) - dmxConfigSetXkbOptions(argv[i]); - else - dmxLog(dmxWarning, - "-param requires: XkbRules, XkbModel, XkbLayout," - " XkbVariant, or XkbOptions\n"); - } - retval = 3; - } - if (!serverGeneration) dmxConfigSetMaxScreens(); - return retval; -} - -/** Provide succinct usage information for the DMX server. */ -void ddxUseMsg(void) -{ - ErrorF("\n\nDevice Dependent Usage:\n"); - ErrorF("-display string Specify the back-end display(s)\n"); - ErrorF("-input string Specify input source for core device\n"); - ErrorF("-xinput string Specify input source for XInput device\n"); - ErrorF("-shadowfb Enable shadow frame buffer\n"); - ErrorF("-configfile file Read from a configuration file\n"); - ErrorF("-config config Select a specific configuration\n"); - ErrorF("-nomulticursor Turn of multiple cursor support\n"); - ErrorF("-fontpath Sets the default font path\n"); - ErrorF("-stat inter scrns Print out performance statistics\n"); - ErrorF("-syncbatch inter Set interval for XSync batching\n"); - ErrorF("-nooffscreenopt Disable offscreen optimization\n"); - ErrorF("-nosubdivprims Disable primitive subdivision\n"); - ErrorF(" optimization\n"); - ErrorF("-nowindowopt Disable lazy window creation optimization\n"); - ErrorF("-noxkb Disable use of the XKB extension with\n"); - ErrorF(" backend displays (cf. -kb).\n"); - ErrorF("-depth Specify the default root window depth\n"); - ErrorF("-norender Disable RENDER extension support\n"); -#ifdef GLXEXT - ErrorF("-noglxproxy Disable GLX Proxy\n"); - ErrorF("-noglxswapgroup Disable swap group and swap barrier\n"); - ErrorF(" extensions in GLX proxy\n"); - 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("-addremovescreens Enable dynamic screen addition/removal\n"); - ErrorF("-param ... Specify configuration parameters (e.g.,\n"); - ErrorF(" XkbRules, XkbModel, XkbLayout, etc.)\n"); - ErrorF("\n"); - ErrorF(" If the -input string matches a -display string, then input\n" - " is taken from that backend display. (XInput cannot be taken\n" - " from a backend display.) Placing \",console\" after the\n" - " display name will force a console window to be opened on\n" - " 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" - " -input local,kbd,ps2 will use a ps2 mouse\n" - " -input local,kbd,ms will use a serial mouse\n" - " -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"); - ErrorF(" Ctrl-Alt-q Quit (core devices only)\n"); - ErrorF(" Ctrl-Alt-F* Switch to VC (local only)\n"); -} +/* + * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina. + * + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation on the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* + * Authors: + * Kevin E. Martin + * David H. Dawes + * Rickard E. (Rik) Faith + * + */ + +/** \file + * Provide expected functions for initialization from the ddx layer and + * global variables for the DMX server. */ + +#ifdef HAVE_DMX_CONFIG_H +#include +#endif + +#include "dmx.h" +#include "dmxinit.h" +#include "dmxsync.h" +#include "dmxlog.h" +#include "dmxinput.h" +#include "dmxscrinit.h" +#include "dmxcursor.h" +#include "dmxfont.h" +#include "config/dmxconfig.h" +#include "dmxcb.h" +#include "dmxprop.h" +#include "dmxstat.h" +#include "dmxpict.h" + +#include /* For gettimeofday */ +#include "dixstruct.h" +#ifdef PANORAMIX +#include "panoramiXsrv.h" +#endif + +#include /* For SIGQUIT */ + +#ifdef GLXEXT +#include +#include +#include "dmx_glxvisuals.h" +#include +#include +#endif /* GLXEXT */ + +/* Global variables available to all Xserver/hw/dmx routines. */ +int dmxNumScreens; +DMXScreenInfo *dmxScreens; + +int dmxNumInputs; +DMXInputInfo *dmxInputs; + +int dmxShadowFB = FALSE; + +XErrorEvent dmxLastErrorEvent; +Bool dmxErrorOccurred = FALSE; + +char *dmxFontPath = NULL; + +Bool dmxOffScreenOpt = TRUE; + +Bool dmxSubdividePrimitives = TRUE; + +Bool dmxLazyWindowCreation = TRUE; + +Bool dmxUseXKB = TRUE; + +int dmxDepth = 0; + +#ifndef GLXEXT +static Bool dmxGLXProxy = FALSE; +#else +Bool dmxGLXProxy = TRUE; + +Bool dmxGLXSwapGroupSupport = TRUE; + +Bool dmxGLXSyncSwap = FALSE; + +Bool dmxGLXFinishSwap = FALSE; +#endif + +Bool dmxIgnoreBadFontPaths = 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) +{ +#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]; + _XExtension *ext = NULL; + + dmxErrorOccurred = TRUE; + dmxLastErrorEvent = *ev; + + XGetErrorText(dpy, ev->error_code, buf, sizeof(buf)); + dmxLog(dmxWarning, "dmxErrorHandler: %s\n", buf); + + /* Find major opcode name */ + if (ev->request_code < 128) { + XmuSnprintf(request, sizeof(request), "%d", ev->request_code); + XGetErrorDatabaseText(dpy, "XRequest", request, "", buf, sizeof(buf)); + } else { + for (ext = dpy->ext_procs; + ext && ext->codes.major_opcode != ev->request_code; + ext = ext->next); + if (ext) strncpy(buf, ext->name, sizeof(buf)); + else buf[0] = '\0'; + } + dmxLog(dmxWarning, " Major opcode: %d (%s)\n", + ev->request_code, buf); + + /* Find minor opcode name */ + if (ev->request_code >= 128 && ext) { + XmuSnprintf(request, sizeof(request), "%d", ev->request_code); + XmuSnprintf(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 */ + switch (ev->error_code) { + case BadValue: + dmxLog(dmxWarning, " Value: 0x%x\n", + ev->resourceid); + break; + case BadAtom: + dmxLog(dmxWarning, " AtomID: 0x%x\n", + ev->resourceid); + break; + default: + dmxLog(dmxWarning, " ResourceID: 0x%x\n", + ev->resourceid); + break; + } + + /* Provide serial number information */ + dmxLog(dmxWarning, " Failed serial number: %d\n", + ev->serial); + dmxLog(dmxWarning, " Current serial number: %d\n", + dpy->request); + return 0; +} + +#ifdef GLXEXT +static int dmxNOPErrorHandler(Display *dpy, XErrorEvent *ev) +{ + return 0; +} +#endif + +Bool dmxOpenDisplay(DMXScreenInfo *dmxScreen) +{ + if (!(dmxScreen->beDisplay = XOpenDisplay(dmxScreen->name))) + return FALSE; + + dmxPropertyDisplay(dmxScreen); + return TRUE; +} + +void dmxSetErrorHandler(DMXScreenInfo *dmxScreen) +{ + XSetErrorHandler(dmxErrorHandler); +} + +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); + + XGetWindowAttributes(dpy, DefaultRootWindow(dpy), &attribs); + 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); + int major = -1, minor = -1, patch = -1, subpatch = -1; + + if (v < 336) + major = v / 100, minor = (v / 10) % 10, patch = v % 10; + else if (v < 3900) { + major = v / 1000; + minor = (v / 100) % 10; + if (((v / 10) % 10) || (v % 10)) { + patch = (v / 10) % 10; + if (v % 10) subpatch = v % 10; + } + } else if (v < 40000000) { + major = v / 1000; + minor = (v / 10) % 10; + if (v % 10) patch = v % 10; + } else { + major = v / 10000000; + minor = (v / 100000) % 100; + patch = (v / 1000) % 100; + 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); + dmxLogOutputCont(dmxScreen, ")\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++) + dmxLogOutputCont(dmxScreen, "%c%d", i ? ',' : ' ', depths[i]); + dmxLogOutputCont(dmxScreen, "\n"); + dmxLogOutput(dmxScreen, "Depth of root window: %d plane%s (%d)\n", + attribs.depth, attribs.depth == 1 ? "" : "s", + DisplayPlanes(dpy, scr)); + 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"); + dmxLogOutput(dmxScreen, "Window Manager running: %s\n", + (dmxScreen->WMRunningOnBE) ? "yes" : "no"); + + if (dmxScreen->WMRunningOnBE) { + dmxLogOutputWarning(dmxScreen, + "Window manager running " + "-- colormaps not supported\n"); + } + XFree(depths); +} + +void dmxGetScreenAttribs(DMXScreenInfo *dmxScreen) +{ + XWindowAttributes attribs; + Display *dpy = dmxScreen->beDisplay; +#ifdef GLXEXT + int dummy; +#endif + + XGetWindowAttributes(dpy, DefaultRootWindow(dpy), &attribs); + + dmxScreen->beWidth = attribs.width; + dmxScreen->beHeight = attribs.height; + + /* 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; + } + } + if (dmxScreen->scrnYSign < 0) { + if (dmxScreen->scrnHeight) { + dmxScreen->scrnY = (attribs.height - dmxScreen->scrnHeight + - dmxScreen->scrnY); + } else { + dmxScreen->scrnHeight = attribs.height - dmxScreen->scrnY; + dmxScreen->scrnY = 0; + } + } + if (!dmxScreen->scrnWidth) + 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->rootX > dmxScreen->scrnWidth) + dmxScreen->rootWidth = dmxScreen->scrnWidth - dmxScreen->rootX; + if (dmxScreen->rootHeight + dmxScreen->rootY > dmxScreen->scrnHeight) + dmxScreen->rootHeight = dmxScreen->scrnHeight - dmxScreen->rootY; + + /* FIXME: Get these from the back-end server */ + 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; + +#ifdef GLXEXT + /* get the majorOpcode for the back-end GLX extension */ + XQueryExtension(dpy, "GLX", &dmxScreen->glxMajorOpcode, + &dummy, &dmxScreen->glxErrorBase); +#endif + + dmxPrintScreenInfo(dmxScreen); + dmxLogOutput(dmxScreen, "%dx%d+%d+%d on %dx%d at depth=%d, bpp=%d\n", + dmxScreen->scrnWidth, dmxScreen->scrnHeight, + dmxScreen->scrnX, dmxScreen->scrnY, + dmxScreen->beWidth, dmxScreen->beHeight, + dmxScreen->beDepth, dmxScreen->beBPP); + if (dmxScreen->beDepth == 8) + dmxLogOutputWarning(dmxScreen, + "Support for depth == 8 is not complete\n"); +} + +Bool dmxGetVisualInfo(DMXScreenInfo *dmxScreen) +{ + int i; + XVisualInfo visinfo; + + visinfo.screen = DefaultScreen(dmxScreen->beDisplay); + dmxScreen->beVisuals = XGetVisualInfo(dmxScreen->beDisplay, + 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++) + dmxLogVisual(dmxScreen, &dmxScreen->beVisuals[i], + (i == dmxScreen->beDefVisualIndex)); + + return dmxScreen->beDefVisualIndex >= 0; +} + +void dmxGetColormaps(DMXScreenInfo *dmxScreen) +{ + int i; + + dmxScreen->beNumDefColormaps = dmxScreen->beNumVisuals; + dmxScreen->beDefColormaps = malloc(dmxScreen->beNumDefColormaps * + 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->beBlackPixel = BlackPixel(dmxScreen->beDisplay, + DefaultScreen(dmxScreen->beDisplay)); + dmxScreen->beWhitePixel = WhitePixel(dmxScreen->beDisplay, + DefaultScreen(dmxScreen->beDisplay)); +} + +void dmxGetPixmapFormats(DMXScreenInfo *dmxScreen) +{ + dmxScreen->beDepths = + XListDepths(dmxScreen->beDisplay, DefaultScreen(dmxScreen->beDisplay), + &dmxScreen->beNumDepths); + + dmxScreen->bePixmapFormats = + XListPixmapFormats(dmxScreen->beDisplay, + &dmxScreen->beNumPixmapFormats); +} + +static Bool dmxSetPixmapFormats(ScreenInfo *pScreenInfo, + DMXScreenInfo *dmxScreen) +{ + XPixmapFormatValues *bePixmapFormat; + PixmapFormatRec *format; + int i, j; + + pScreenInfo->imageByteOrder = ImageByteOrder(dmxScreen->beDisplay); + pScreenInfo->bitmapScanlineUnit = BitmapUnit(dmxScreen->beDisplay); + pScreenInfo->bitmapScanlinePad = BitmapPad(dmxScreen->beDisplay); + pScreenInfo->bitmapBitOrder = BitmapBitOrder(dmxScreen->beDisplay); + + 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; + } + } + + return TRUE; +} + +void dmxCheckForWM(DMXScreenInfo *dmxScreen) +{ + Status status; + XWindowAttributes xwa; + + status = XGetWindowAttributes(dmxScreen->beDisplay, + DefaultRootWindow(dmxScreen->beDisplay), + &xwa); + dmxScreen->WMRunningOnBE = + (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) +{ + if (!dmxOpenDisplay(dmxScreen)) + 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"); + + dmxGetColormaps(dmxScreen); + dmxGetPixmapFormats(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 ""; } +#else +#include +static const char *dmxExecOS(void) +{ + static char buffer[128]; + static int initialized = 0; + struct utsname u; + + if (!initialized++) { + memset(buffer, 0, sizeof(buffer)); + uname(&u); + XmuSnprintf(buffer, sizeof(buffer)-1, "%s %s %s", + u.sysname, u.release, u.version); + } + return buffer; +} +#endif + +static const char *dmxBuildCompiler(void) +{ + static char buffer[128]; + static int initialized = 0; + + if (!initialized++) { + memset(buffer, 0, sizeof(buffer)); +#if defined(__GNUC__) && defined(__GNUC_MINOR__) &&defined(__GNUC_PATCHLEVEL__) + XmuSnprintf(buffer, sizeof(buffer)-1, "gcc %d.%d.%d", + __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__); +#endif + } + return buffer; +} + +static const char *dmxExecHost(void) +{ + static char buffer[128]; + static int initialized = 0; + + if (!initialized++) { + memset(buffer, 0, sizeof(buffer)); + XmuGetHostname(buffer, sizeof(buffer) - 1); + } + return buffer; +} + +/** This routine is called in Xserver/dix/main.c from \a main(). */ +void InitOutput(ScreenInfo *pScreenInfo, int argc, char *argv[]) +{ + int i; + static unsigned long dmxGeneration = 0; +#ifdef GLXEXT + Bool glxSupported = TRUE; +#endif + + if (dmxGeneration != serverGeneration) { + 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; + + /* 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", + major, minor, year, month, day, VENDOR_STRING); + + SetVendorRelease(VENDOR_RELEASE); + SetVendorString(VENDOR_STRING); + + if (dmxGeneration == 1) { + dmxLog(dmxInfo, "DMX Build OS: %s (%s)\n", OSNAME, OSVENDOR); + dmxLog(dmxInfo, "DMX Build Compiler: %s\n", dmxBuildCompiler()); + dmxLog(dmxInfo, "DMX Execution OS: %s\n", dmxExecOS()); + dmxLog(dmxInfo, "DMX Execution Host: %s\n", dmxExecHost()); + } + dmxLog(dmxInfo, "MAXSCREENS: %d\n", MAXSCREENS); + + for (i = 0; i < dmxNumScreens; i++) { + if (dmxScreens[i].beDisplay) + dmxLog(dmxWarning, "Display \"%s\" still open\n", + dmxScreens[i].name); + dmxStatFree(dmxScreens[i].stat); + dmxScreens[i].stat = NULL; + } + for (i = 0; i < dmxNumInputs; i++) dmxInputFree(&dmxInputs[i]); + free(dmxScreens); + free(dmxInputs); + dmxScreens = NULL; + dmxInputs = NULL; + dmxNumScreens = 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. */ + dmxLog(dmxWarning, + "GLX Proxy and Render extensions do not yet support dynamic\n"); + dmxLog(dmxWarning, + "screen addition and removal. Please specify -noglxproxy\n"); + dmxLog(dmxWarning, + "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"); + dmxLog(dmxWarning, + "the dynamic addition and removal of screens support.\n"); + dmxLog(dmxFatal, + "Dynamic screen addition/removal error (see above).\n"); + } + + /* ddxProcessArgument has been called at this point, but any data + * from the configuration file has not been applied. Do so, and be + * sure we have at least one back-end display. */ + dmxConfigConfigure(); + if (!dmxNumScreens) + 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"); + dmxLog(dmxInfo, + " since it requires the offscreen optimization\n"); + dmxLog(dmxInfo, + " to function properly.\n"); + dmxLazyWindowCreation = FALSE; + } + + /* Open each display and gather information about it. */ + for (i = 0; i < dmxNumScreens; i++) + dmxDisplayInit(&dmxScreens[i]); + +#if PANORAMIX + /* Register a Xinerama callback which will run from within + * PanoramiXCreateConnectionBlock. We can use the callback to + * determine if Xinerama is loaded and to check the visuals + * determined by PanoramiXConsolidate. */ + XineramaRegisterConnectionBlockCallback(dmxConnectionBlockCallback); +#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; + + /* Might want to install a signal handler to allow cleaning up after + * unexpected signals. The DIX/OS layer already handles SIGINT and + * SIGTERM, so everything is OK for expected signals. --DD + * + * SIGHUP, SIGINT, and SIGTERM are trapped in os/connection.c + * SIGQUIT is another common signal that is sent from the keyboard. + * Trap it here, to ensure that the keyboard modifier map and other + * state for the input devices are restored. (This makes the + * behavior of SIGQUIT somewhat unexpected, since it will be the + * same as the behavior of SIGINT. However, leaving the modifier + * map of the input devices empty is even more unexpected.) --RF + */ + OsSignal(SIGQUIT, GiveUp); + +#ifdef GLXEXT + /* Check if GLX extension exists on all back-end servers */ + for (i = 0; i < dmxNumScreens; i++) + 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; + } + } + } + } + + XFlush(dmxScreen->beDisplay); + } + } +#endif /* GLXEXT */ + + AddScreen(dmxScreenInit, argc, argv); + } + + /* Compute origin information. */ + dmxInitOrigins(); + + /* Compute overlap information. */ + dmxInitOverlap(); + + /* Make sure there is a global width/height available */ + dmxComputeWidthHeight(DMX_NO_RECOMPUTE_BOUNDING_BOX); + + /* FIXME: The following is temporarily placed here. When the DMX + * extension is available, it will be move there. + */ + dmxInitFonts(); + + /* Initialize the render extension */ + if (!noRenderExtension) + dmxInitRender(); + + /* Initialized things that need timer hooks */ + dmxStatInit(); + dmxSyncInit(); /* Calls RegisterBlockAndWakeupHandlers */ + + dmxLog(dmxInfo, "Shadow framebuffer support %s\n", + 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(char *fp) +{ + int fplen = strlen(fp) + 1; + + if (dmxFontPath) { + int len; + + len = strlen(dmxFontPath); + dmxFontPath = realloc(dmxFontPath, len+fplen+1); + dmxFontPath[len] = ','; + strncpy(&dmxFontPath[len+1], fp, fplen); + } else { + dmxFontPath = malloc(fplen); + strncpy(dmxFontPath, fp, fplen); + } + + defaultFontPath = dmxFontPath; +} + +/** 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) +{ + int i; + + for (i=0; i < dmxNumScreens; i++) { + DMXScreenInfo *dmxScreen = &dmxScreens[i]; + + if (dmxScreen->beDisplay) XCloseDisplay(dmxScreen->beDisplay); + dmxScreen->beDisplay = NULL; + } +} + +#ifdef DDXBEFORERESET +void ddxBeforeReset(void) +{ +} +#endif + +/** 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) +{ + AbortDDX(error); +} + +/** This function is called in Xserver/os/osinit.c from \a OsInit(). */ +void OsVendorInit(void) +{ +} + +/** This function is called in Xserver/os/utils.c from \a FatalError() + * and \a VFatalError(). (Note that setting the function pointer \a + * 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) +{ +} + +/** Process our command line arguments. */ +int ddxProcessArgument(int argc, char *argv[], int i) +{ + int retval = 0; + + if (!strcmp(argv[i], "-display")) { + if (++i < argc) dmxConfigStoreDisplay(argv[i]); + retval = 2; + } 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]); + retval = 2; + } 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")) { + 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 = 2; + } 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]); + retval = 2; + } 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]); + retval = 2; + } else if (!strcmp(argv[i], "-nooffscreenopt")) { + dmxOffScreenOpt = FALSE; + retval = 1; + } else if (!strcmp(argv[i], "-nosubdivprims")) { + dmxSubdividePrimitives = FALSE; + retval = 1; + } else if (!strcmp(argv[i], "-nowindowopt")) { + dmxLazyWindowCreation = FALSE; + retval = 1; + } else if (!strcmp(argv[i], "-noxkb")) { + dmxUseXKB = FALSE; + retval = 1; + } else if (!strcmp(argv[i], "-depth")) { + if (++i < argc) dmxDepth = atoi(argv[i]); + retval = 2; + } else if (!strcmp(argv[i], "-norender")) { + noRenderExtension = TRUE; + retval = 1; +#ifdef GLXEXT + } else if (!strcmp(argv[i], "-noglxproxy")) { + dmxGLXProxy = FALSE; + retval = 1; + } else if (!strcmp(argv[i], "-noglxswapgroup")) { + dmxGLXSwapGroupSupport = FALSE; + retval = 1; + } else if (!strcmp(argv[i], "-glxsyncswap")) { + dmxGLXSyncSwap = TRUE; + retval = 1; + } else if (!strcmp(argv[i], "-glxfinishswap")) { + dmxGLXFinishSwap = TRUE; + retval = 1; +#endif + } else if (!strcmp(argv[i], "-ignorebadfontpaths")) { + dmxIgnoreBadFontPaths = TRUE; + retval = 1; + } else if (!strcmp(argv[i], "-addremovescreens")) { + dmxAddRemoveScreens = TRUE; + retval = 1; + } else if (!strcmp(argv[i], "-param")) { + if ((i += 2) < argc) { + if (!strcasecmp(argv[i-1], "xkbrules")) + dmxConfigSetXkbRules(argv[i]); + else if (!strcasecmp(argv[i-1], "xkbmodel")) + dmxConfigSetXkbModel(argv[i]); + else if (!strcasecmp(argv[i-1], "xkblayout")) + dmxConfigSetXkbLayout(argv[i]); + else if (!strcasecmp(argv[i-1], "xkbvariant")) + dmxConfigSetXkbVariant(argv[i]); + else if (!strcasecmp(argv[i-1], "xkboptions")) + dmxConfigSetXkbOptions(argv[i]); + else + dmxLog(dmxWarning, + "-param requires: XkbRules, XkbModel, XkbLayout," + " XkbVariant, or XkbOptions\n"); + } + retval = 3; + } + if (!serverGeneration) dmxConfigSetMaxScreens(); + return retval; +} + +/** Provide succinct usage information for the DMX server. */ +void ddxUseMsg(void) +{ + ErrorF("\n\nDevice Dependent Usage:\n"); + ErrorF("-display string Specify the back-end display(s)\n"); + ErrorF("-input string Specify input source for core device\n"); + ErrorF("-xinput string Specify input source for XInput device\n"); + ErrorF("-shadowfb Enable shadow frame buffer\n"); + ErrorF("-configfile file Read from a configuration file\n"); + ErrorF("-config config Select a specific configuration\n"); + ErrorF("-nomulticursor Turn of multiple cursor support\n"); + ErrorF("-fontpath Sets the default font path\n"); + ErrorF("-stat inter scrns Print out performance statistics\n"); + ErrorF("-syncbatch inter Set interval for XSync batching\n"); + ErrorF("-nooffscreenopt Disable offscreen optimization\n"); + ErrorF("-nosubdivprims Disable primitive subdivision\n"); + ErrorF(" optimization\n"); + ErrorF("-nowindowopt Disable lazy window creation optimization\n"); + ErrorF("-noxkb Disable use of the XKB extension with\n"); + ErrorF(" backend displays (cf. -kb).\n"); + ErrorF("-depth Specify the default root window depth\n"); + ErrorF("-norender Disable RENDER extension support\n"); +#ifdef GLXEXT + ErrorF("-noglxproxy Disable GLX Proxy\n"); + ErrorF("-noglxswapgroup Disable swap group and swap barrier\n"); + ErrorF(" extensions in GLX proxy\n"); + 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("-addremovescreens Enable dynamic screen addition/removal\n"); + ErrorF("-param ... Specify configuration parameters (e.g.,\n"); + ErrorF(" XkbRules, XkbModel, XkbLayout, etc.)\n"); + ErrorF("\n"); + ErrorF(" If the -input string matches a -display string, then input\n" + " is taken from that backend display. (XInput cannot be taken\n" + " from a backend display.) Placing \",console\" after the\n" + " display name will force a console window to be opened on\n" + " 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" + " -input local,kbd,ps2 will use a ps2 mouse\n" + " -input local,kbd,ms will use a serial mouse\n" + " -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"); + ErrorF(" Ctrl-Alt-q Quit (core devices only)\n"); + ErrorF(" Ctrl-Alt-F* Switch to VC (local only)\n"); +} diff --git a/xorg-server/hw/kdrive/src/kdrive.c b/xorg-server/hw/kdrive/src/kdrive.c index f034ce463..8dd039e1d 100644 --- a/xorg-server/hw/kdrive/src/kdrive.c +++ b/xorg-server/hw/kdrive/src/kdrive.c @@ -232,7 +232,7 @@ KdProcessSwitch (void) } void -AbortDDX(void) +AbortDDX(enum ExitCode error) { KdDisableScreens (); if (kdOsFuncs) @@ -249,9 +249,9 @@ AbortDDX(void) } void -ddxGiveUp (void) +ddxGiveUp (enum ExitCode error) { - AbortDDX (); + AbortDDX (error); } Bool kdDumbDriver; diff --git a/xorg-server/hw/vfb/InitOutput.c b/xorg-server/hw/vfb/InitOutput.c index 04253dc5a..31ed50533 100644 --- a/xorg-server/hw/vfb/InitOutput.c +++ b/xorg-server/hw/vfb/InitOutput.c @@ -1,969 +1,969 @@ -/* - -Copyright 1993, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall -not be used in advertising or otherwise to promote the sale, use or -other dealings in this Software without prior written authorization -from The Open Group. - -*/ - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#if defined(WIN32) -#include -#endif -#include -#include -#include -#include -#include "scrnintstr.h" -#include "servermd.h" -#define PSZ 8 -#include "fb.h" -#include "mibstore.h" -#include "colormapst.h" -#include "gcstruct.h" -#include "input.h" -#include "mipointer.h" -#include "micmap.h" -#include -#ifdef HAS_MMAP -#include -#ifndef MAP_FILE -#define MAP_FILE 0 -#endif -#endif /* HAS_MMAP */ -#include -#include -#ifndef WIN32 -#include -#endif -#include -#ifdef HAS_SHM -#include -#include -#endif /* HAS_SHM */ -#include "dix.h" -#include "miline.h" - -#define VFB_DEFAULT_WIDTH 1280 -#define VFB_DEFAULT_HEIGHT 1024 -#define VFB_DEFAULT_DEPTH 8 -#define VFB_DEFAULT_WHITEPIXEL 1 -#define VFB_DEFAULT_BLACKPIXEL 0 -#define VFB_DEFAULT_LINEBIAS 0 -#define XWD_WINDOW_NAME_LEN 60 - -typedef struct -{ - int width; - int paddedBytesWidth; - int paddedWidth; - int height; - int depth; - int bitsPerPixel; - int sizeInBytes; - int ncolors; - char *pfbMemory; - XWDColor *pXWDCmap; - XWDFileHeader *pXWDHeader; - Pixel blackPixel; - Pixel whitePixel; - unsigned int lineBias; - CloseScreenProcPtr closeScreen; - -#ifdef HAS_MMAP - int mmap_fd; - char mmap_file[MAXPATHLEN]; -#endif - -#ifdef HAS_SHM - int shmid; -#endif -} vfbScreenInfo, *vfbScreenInfoPtr; - -static int vfbNumScreens; -static vfbScreenInfo *vfbScreens; -static vfbScreenInfo defaultScreenInfo = { - .width = VFB_DEFAULT_WIDTH, - .height = VFB_DEFAULT_HEIGHT, - .depth = VFB_DEFAULT_DEPTH, - .blackPixel = VFB_DEFAULT_BLACKPIXEL, - .whitePixel = VFB_DEFAULT_WHITEPIXEL, - .lineBias = VFB_DEFAULT_LINEBIAS, -}; -static Bool vfbPixmapDepths[33]; -#ifdef HAS_MMAP -static char *pfbdir = NULL; -#endif -typedef enum { NORMAL_MEMORY_FB, SHARED_MEMORY_FB, MMAPPED_FILE_FB } fbMemType; -static fbMemType fbmemtype = NORMAL_MEMORY_FB; -static char needswap = 0; -static Bool Render = TRUE; - -#define swapcopy16(_dst, _src) \ - if (needswap) { CARD16 _s = _src; cpswaps(_s, _dst); } \ - else _dst = _src; - -#define swapcopy32(_dst, _src) \ - if (needswap) { CARD32 _s = _src; cpswapl(_s, _dst); } \ - else _dst = _src; - - -static void -vfbInitializePixmapDepths(void) -{ - int i; - vfbPixmapDepths[1] = TRUE; /* always need bitmaps */ - for (i = 2; i <= 32; i++) - vfbPixmapDepths[i] = FALSE; -} - -static int -vfbBitsPerPixel(int depth) -{ - if (depth == 1) return 1; - else if (depth <= 8) return 8; - else if (depth <= 16) return 16; - else return 32; -} - -void -ddxGiveUp(void) -{ - int i; - - /* clean up the framebuffers */ - - switch (fbmemtype) - { -#ifdef HAS_MMAP - case MMAPPED_FILE_FB: - for (i = 0; i < vfbNumScreens; i++) - { - if (-1 == unlink(vfbScreens[i].mmap_file)) - { - perror("unlink"); - ErrorF("unlink %s failed, %s", - vfbScreens[i].mmap_file, strerror(errno)); - } - } - break; -#else /* HAS_MMAP */ - case MMAPPED_FILE_FB: - break; -#endif /* HAS_MMAP */ - -#ifdef HAS_SHM - case SHARED_MEMORY_FB: - for (i = 0; i < vfbNumScreens; i++) - { - if (-1 == shmdt((char *)vfbScreens[i].pXWDHeader)) - { - perror("shmdt"); - ErrorF("shmdt failed, %s", strerror(errno)); - } - } - break; -#else /* HAS_SHM */ - case SHARED_MEMORY_FB: - break; -#endif /* HAS_SHM */ - - case NORMAL_MEMORY_FB: - for (i = 0; i < vfbNumScreens; i++) - { - free(vfbScreens[i].pXWDHeader); - } - break; - } -} - -void -AbortDDX(void) -{ - ddxGiveUp(); -} - -#ifdef __APPLE__ -void -DarwinHandleGUI(int argc, char *argv[]) -{ -} -#endif - -void -OsVendorInit(void) -{ -} - -void -OsVendorFatalError(void) -{ -} - -#if defined(DDXBEFORERESET) -void ddxBeforeReset(void) -{ - return; -} -#endif - -void -ddxUseMsg(void) -{ - ErrorF("-screen scrn WxHxD set screen's width, height, depth\n"); - ErrorF("-pixdepths list-of-int support given pixmap depths\n"); - ErrorF("+/-render turn on/off RENDER extension support" - "(default on)\n"); - ErrorF("-linebias n adjust thin line pixelization\n"); - ErrorF("-blackpixel n pixel value for black\n"); - ErrorF("-whitepixel n pixel value for white\n"); - -#ifdef HAS_MMAP - ErrorF("-fbdir directory put framebuffers in mmap'ed files in directory\n"); -#endif - -#ifdef HAS_SHM - ErrorF("-shmem put framebuffers in shared memory\n"); -#endif -} - -int -ddxProcessArgument(int argc, char *argv[], int i) -{ - static Bool firstTime = TRUE; - static int lastScreen = -1; - vfbScreenInfo *currentScreen; - - if (firstTime) - { - vfbInitializePixmapDepths(); - firstTime = FALSE; - } - - if (lastScreen == -1) - currentScreen = &defaultScreenInfo; - else - currentScreen = &vfbScreens[lastScreen]; - -#define CHECK_FOR_REQUIRED_ARGUMENTS(num) \ - if (((i + num) >= argc) || (!argv[i + num])) { \ - ErrorF("Required argument to %s not specified\n", argv[i]); \ - UseMsg(); \ - FatalError("Required argument to %s not specified\n", argv[i]); \ - } - - if (strcmp (argv[i], "-screen") == 0) /* -screen n WxHxD */ - { - int screenNum; - CHECK_FOR_REQUIRED_ARGUMENTS(2); - screenNum = atoi(argv[i+1]); - if (screenNum < 0) - { - ErrorF("Invalid screen number %d\n", screenNum); - UseMsg(); - FatalError("Invalid screen number %d passed to -screen\n", - screenNum); - } - - if (vfbNumScreens <= screenNum) - { - vfbScreens = realloc(vfbScreens, sizeof(*vfbScreens) * (screenNum + 1)); - if (!vfbScreens) - FatalError("Not enough memory for screen %d\n", screenNum); - for (; vfbNumScreens <= screenNum; ++vfbNumScreens) - vfbScreens[vfbNumScreens] = defaultScreenInfo; - } - - if (3 != sscanf(argv[i+2], "%dx%dx%d", - &vfbScreens[screenNum].width, - &vfbScreens[screenNum].height, - &vfbScreens[screenNum].depth)) - { - ErrorF("Invalid screen configuration %s\n", argv[i+2]); - UseMsg(); - FatalError("Invalid screen configuration %s for -screen %d\n", - argv[i+2], screenNum); - } - - lastScreen = screenNum; - return 3; - } - - if (strcmp (argv[i], "-pixdepths") == 0) /* -pixdepths list-of-depth */ - { - int depth, ret = 1; - - CHECK_FOR_REQUIRED_ARGUMENTS(1); - while ((++i < argc) && (depth = atoi(argv[i])) != 0) - { - if (depth < 0 || depth > 32) - { - ErrorF("Invalid pixmap depth %d\n", depth); - UseMsg(); - FatalError("Invalid pixmap depth %d passed to -pixdepths\n", - depth); - } - vfbPixmapDepths[depth] = TRUE; - ret++; - } - return ret; - } - - if (strcmp (argv[i], "+render") == 0) /* +render */ - { - Render = TRUE; - return 1; - } - - if (strcmp (argv[i], "-render") == 0) /* -render */ - { - Render = FALSE; -#ifdef COMPOSITE - noCompositeExtension = TRUE; -#endif - return 1; - } - - if (strcmp (argv[i], "-blackpixel") == 0) /* -blackpixel n */ - { - CHECK_FOR_REQUIRED_ARGUMENTS(1); - currentScreen->blackPixel = atoi(argv[++i]); - return 2; - } - - if (strcmp (argv[i], "-whitepixel") == 0) /* -whitepixel n */ - { - CHECK_FOR_REQUIRED_ARGUMENTS(1); - currentScreen->whitePixel = atoi(argv[++i]); - return 2; - } - - if (strcmp (argv[i], "-linebias") == 0) /* -linebias n */ - { - CHECK_FOR_REQUIRED_ARGUMENTS(1); - currentScreen->lineBias = atoi(argv[++i]); - return 2; - } - -#ifdef HAS_MMAP - if (strcmp (argv[i], "-fbdir") == 0) /* -fbdir directory */ - { - CHECK_FOR_REQUIRED_ARGUMENTS(1); - pfbdir = argv[++i]; - fbmemtype = MMAPPED_FILE_FB; - return 2; - } -#endif /* HAS_MMAP */ - -#ifdef HAS_SHM - if (strcmp (argv[i], "-shmem") == 0) /* -shmem */ - { - fbmemtype = SHARED_MEMORY_FB; - return 1; - } -#endif - - return 0; -} - -static DevPrivateKeyRec cmapScrPrivateKeyRec; -#define cmapScrPrivateKey (&cmapScrPrivateKeyRec) - -#define GetInstalledColormap(s) ((ColormapPtr) dixLookupPrivate(&(s)->devPrivates, cmapScrPrivateKey)) -#define SetInstalledColormap(s,c) (dixSetPrivate(&(s)->devPrivates, cmapScrPrivateKey, c)) - -static int -vfbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps) -{ - /* By the time we are processing requests, we can guarantee that there - * is always a colormap installed */ - *pmaps = GetInstalledColormap(pScreen)->mid; - return 1; -} - - -static void -vfbInstallColormap(ColormapPtr pmap) -{ - ColormapPtr oldpmap = GetInstalledColormap(pmap->pScreen); - - if (pmap != oldpmap) - { - int entries; - XWDFileHeader *pXWDHeader; - XWDColor *pXWDCmap; - VisualPtr pVisual; - Pixel * ppix; - xrgb * prgb; - xColorItem *defs; - int i; - - if(oldpmap != (ColormapPtr)None) - WalkTree(pmap->pScreen, TellLostMap, (char *)&oldpmap->mid); - /* Install pmap */ - SetInstalledColormap(pmap->pScreen, pmap); - WalkTree(pmap->pScreen, TellGainedMap, (char *)&pmap->mid); - - entries = pmap->pVisual->ColormapEntries; - pXWDHeader = vfbScreens[pmap->pScreen->myNum].pXWDHeader; - pXWDCmap = vfbScreens[pmap->pScreen->myNum].pXWDCmap; - pVisual = pmap->pVisual; - - swapcopy32(pXWDHeader->visual_class, pVisual->class); - swapcopy32(pXWDHeader->red_mask, pVisual->redMask); - swapcopy32(pXWDHeader->green_mask, pVisual->greenMask); - swapcopy32(pXWDHeader->blue_mask, pVisual->blueMask); - swapcopy32(pXWDHeader->bits_per_rgb, pVisual->bitsPerRGBValue); - swapcopy32(pXWDHeader->colormap_entries, pVisual->ColormapEntries); - - ppix = (Pixel *)malloc(entries * sizeof(Pixel)); - prgb = (xrgb *)malloc(entries * sizeof(xrgb)); - defs = (xColorItem *)malloc(entries * sizeof(xColorItem)); - - for (i = 0; i < entries; i++) ppix[i] = i; - /* XXX truecolor */ - QueryColors(pmap, entries, ppix, prgb, serverClient); - - for (i = 0; i < entries; i++) { /* convert xrgbs to xColorItems */ - defs[i].pixel = ppix[i] & 0xff; /* change pixel to index */ - defs[i].red = prgb[i].red; - defs[i].green = prgb[i].green; - defs[i].blue = prgb[i].blue; - defs[i].flags = DoRed|DoGreen|DoBlue; - } - (*pmap->pScreen->StoreColors)(pmap, entries, defs); - - free(ppix); - free(prgb); - free(defs); - } -} - -static void -vfbUninstallColormap(ColormapPtr pmap) -{ - ColormapPtr curpmap = GetInstalledColormap(pmap->pScreen); - - if(pmap == curpmap) - { - if (pmap->mid != pmap->pScreen->defColormap) - { - dixLookupResourceByType((pointer *)&curpmap, - pmap->pScreen->defColormap, - RT_COLORMAP, serverClient, - DixInstallAccess); - (*pmap->pScreen->InstallColormap)(curpmap); - } - } -} - -static void -vfbStoreColors(ColormapPtr pmap, int ndef, xColorItem *pdefs) -{ - XWDColor *pXWDCmap; - int i; - - if (pmap != GetInstalledColormap(pmap->pScreen)) - { - return; - } - - pXWDCmap = vfbScreens[pmap->pScreen->myNum].pXWDCmap; - - if ((pmap->pVisual->class | DynamicClass) == DirectColor) - { - return; - } - - for (i = 0; i < ndef; i++) - { - if (pdefs[i].flags & DoRed) - { - swapcopy16(pXWDCmap[pdefs[i].pixel].red, pdefs[i].red); - } - if (pdefs[i].flags & DoGreen) - { - swapcopy16(pXWDCmap[pdefs[i].pixel].green, pdefs[i].green); - } - if (pdefs[i].flags & DoBlue) - { - swapcopy16(pXWDCmap[pdefs[i].pixel].blue, pdefs[i].blue); - } - } -} - -static Bool -vfbSaveScreen(ScreenPtr pScreen, int on) -{ - return TRUE; -} - -#ifdef HAS_MMAP - -/* this flushes any changes to the screens out to the mmapped file */ -static void -vfbBlockHandler(pointer blockData, OSTimePtr pTimeout, pointer pReadmask) -{ - int i; - - for (i = 0; i < vfbNumScreens; i++) - { -#ifdef MS_ASYNC - if (-1 == msync((caddr_t)vfbScreens[i].pXWDHeader, - (size_t)vfbScreens[i].sizeInBytes, MS_ASYNC)) -#else - /* silly NetBSD and who else? */ - if (-1 == msync((caddr_t)vfbScreens[i].pXWDHeader, - (size_t)vfbScreens[i].sizeInBytes)) -#endif - { - perror("msync"); - ErrorF("msync failed, %s", strerror(errno)); - } - } -} - - -static void -vfbWakeupHandler(pointer blockData, int result, pointer pReadmask) -{ -} - - -static void -vfbAllocateMmappedFramebuffer(vfbScreenInfoPtr pvfb) -{ -#define DUMMY_BUFFER_SIZE 65536 - char dummyBuffer[DUMMY_BUFFER_SIZE]; - int currentFileSize, writeThisTime; - - sprintf(pvfb->mmap_file, "%s/Xvfb_screen%d", pfbdir, (int) (pvfb - vfbScreens)); - if (-1 == (pvfb->mmap_fd = open(pvfb->mmap_file, O_CREAT|O_RDWR, 0666))) - { - perror("open"); - ErrorF("open %s failed, %s", pvfb->mmap_file, strerror(errno)); - return; - } - - /* Extend the file to be the proper size */ - - memset(dummyBuffer, 0, DUMMY_BUFFER_SIZE); - for (currentFileSize = 0; - currentFileSize < pvfb->sizeInBytes; - currentFileSize += writeThisTime) - { - writeThisTime = min(DUMMY_BUFFER_SIZE, - pvfb->sizeInBytes - currentFileSize); - if (-1 == write(pvfb->mmap_fd, dummyBuffer, writeThisTime)) - { - perror("write"); - ErrorF("write %s failed, %s", pvfb->mmap_file, strerror(errno)); - return; - } - } - - /* try to mmap the file */ - - pvfb->pXWDHeader = (XWDFileHeader *)mmap((caddr_t)NULL, pvfb->sizeInBytes, - PROT_READ|PROT_WRITE, - MAP_FILE|MAP_SHARED, - pvfb->mmap_fd, 0); - if (-1 == (long)pvfb->pXWDHeader) - { - perror("mmap"); - ErrorF("mmap %s failed, %s", pvfb->mmap_file, strerror(errno)); - pvfb->pXWDHeader = NULL; - return; - } - - if (!RegisterBlockAndWakeupHandlers(vfbBlockHandler, vfbWakeupHandler, - NULL)) - { - pvfb->pXWDHeader = NULL; - } -} -#endif /* HAS_MMAP */ - - -#ifdef HAS_SHM -static void -vfbAllocateSharedMemoryFramebuffer(vfbScreenInfoPtr pvfb) -{ - /* create the shared memory segment */ - - pvfb->shmid = shmget(IPC_PRIVATE, pvfb->sizeInBytes, IPC_CREAT|0777); - if (pvfb->shmid < 0) - { - perror("shmget"); - ErrorF("shmget %d bytes failed, %s", pvfb->sizeInBytes, strerror(errno)); - return; - } - - /* try to attach it */ - - pvfb->pXWDHeader = (XWDFileHeader *)shmat(pvfb->shmid, 0, 0); - if (-1 == (long)pvfb->pXWDHeader) - { - perror("shmat"); - ErrorF("shmat failed, %s", strerror(errno)); - pvfb->pXWDHeader = NULL; - return; - } - - ErrorF("screen %d shmid %d\n", (int) (pvfb - vfbScreens), pvfb->shmid); -} -#endif /* HAS_SHM */ - -static char * -vfbAllocateFramebufferMemory(vfbScreenInfoPtr pvfb) -{ - if (pvfb->pfbMemory) return pvfb->pfbMemory; /* already done */ - - pvfb->sizeInBytes = pvfb->paddedBytesWidth * pvfb->height; - - /* Calculate how many entries in colormap. This is rather bogus, because - * the visuals haven't even been set up yet, but we need to know because we - * have to allocate space in the file for the colormap. The number 10 - * below comes from the MAX_PSEUDO_DEPTH define in cfbcmap.c. - */ - - if (pvfb->depth <= 10) - { /* single index colormaps */ - pvfb->ncolors = 1 << pvfb->depth; - } - else - { /* decomposed colormaps */ - int nplanes_per_color_component = pvfb->depth / 3; - if (pvfb->depth % 3) nplanes_per_color_component++; - pvfb->ncolors = 1 << nplanes_per_color_component; - } - - /* add extra bytes for XWDFileHeader, window name, and colormap */ - - pvfb->sizeInBytes += SIZEOF(XWDheader) + XWD_WINDOW_NAME_LEN + - pvfb->ncolors * SIZEOF(XWDColor); - - pvfb->pXWDHeader = NULL; - switch (fbmemtype) - { -#ifdef HAS_MMAP - case MMAPPED_FILE_FB: vfbAllocateMmappedFramebuffer(pvfb); break; -#else - case MMAPPED_FILE_FB: break; -#endif - -#ifdef HAS_SHM - case SHARED_MEMORY_FB: vfbAllocateSharedMemoryFramebuffer(pvfb); break; -#else - case SHARED_MEMORY_FB: break; -#endif - - case NORMAL_MEMORY_FB: - pvfb->pXWDHeader = (XWDFileHeader *)malloc(pvfb->sizeInBytes); - break; - } - - if (pvfb->pXWDHeader) - { - pvfb->pXWDCmap = (XWDColor *)((char *)pvfb->pXWDHeader - + SIZEOF(XWDheader) + XWD_WINDOW_NAME_LEN); - pvfb->pfbMemory = (char *)(pvfb->pXWDCmap + pvfb->ncolors); - - return pvfb->pfbMemory; - } - else - return NULL; -} - - -static void -vfbWriteXWDFileHeader(ScreenPtr pScreen) -{ - vfbScreenInfoPtr pvfb = &vfbScreens[pScreen->myNum]; - XWDFileHeader *pXWDHeader = pvfb->pXWDHeader; - char hostname[XWD_WINDOW_NAME_LEN]; - unsigned long swaptest = 1; - int i; - - needswap = *(char *) &swaptest; - - pXWDHeader->header_size = (char *)pvfb->pXWDCmap - (char *)pvfb->pXWDHeader; - pXWDHeader->file_version = XWD_FILE_VERSION; - - pXWDHeader->pixmap_format = ZPixmap; - pXWDHeader->pixmap_depth = pvfb->depth; - pXWDHeader->pixmap_height = pXWDHeader->window_height = pvfb->height; - pXWDHeader->xoffset = 0; - pXWDHeader->byte_order = IMAGE_BYTE_ORDER; - pXWDHeader->bitmap_bit_order = BITMAP_BIT_ORDER; -#ifndef INTERNAL_VS_EXTERNAL_PADDING - pXWDHeader->pixmap_width = pXWDHeader->window_width = pvfb->width; - pXWDHeader->bitmap_unit = BITMAP_SCANLINE_UNIT; - pXWDHeader->bitmap_pad = BITMAP_SCANLINE_PAD; -#else - pXWDHeader->pixmap_width = pXWDHeader->window_width = pvfb->paddedWidth; - pXWDHeader->bitmap_unit = BITMAP_SCANLINE_UNIT_PROTO; - pXWDHeader->bitmap_pad = BITMAP_SCANLINE_PAD_PROTO; -#endif - pXWDHeader->bits_per_pixel = pvfb->bitsPerPixel; - pXWDHeader->bytes_per_line = pvfb->paddedBytesWidth; - pXWDHeader->ncolors = pvfb->ncolors; - - /* visual related fields are written when colormap is installed */ - - pXWDHeader->window_x = pXWDHeader->window_y = 0; - pXWDHeader->window_bdrwidth = 0; - - /* write xwd "window" name: Xvfb hostname:server.screen */ - - if (-1 == gethostname(hostname, sizeof(hostname))) - hostname[0] = 0; - else - hostname[XWD_WINDOW_NAME_LEN-1] = 0; - sprintf((char *)(pXWDHeader+1), "Xvfb %s:%s.%d", hostname, display, - pScreen->myNum); - - /* write colormap pixel slot values */ - - for (i = 0; i < pvfb->ncolors; i++) - { - pvfb->pXWDCmap[i].pixel = i; - } - - /* byte swap to most significant byte first */ - - if (needswap) - { - SwapLongs((CARD32 *)pXWDHeader, SIZEOF(XWDheader)/4); - for (i = 0; i < pvfb->ncolors; i++) - { - register char n; - swapl(&pvfb->pXWDCmap[i].pixel, n); - } - } -} - - -static Bool -vfbCursorOffScreen (ScreenPtr *ppScreen, int *x, int *y) -{ - return FALSE; -} - -static void -vfbCrossScreen (ScreenPtr pScreen, Bool entering) -{ -} - -static miPointerScreenFuncRec vfbPointerCursorFuncs = -{ - vfbCursorOffScreen, - vfbCrossScreen, - miPointerWarpCursor -}; - -static Bool -vfbCloseScreen(int index, ScreenPtr pScreen) -{ - vfbScreenInfoPtr pvfb = &vfbScreens[index]; - int i; - - pScreen->CloseScreen = pvfb->closeScreen; - - /* - * XXX probably lots of stuff to clean. For now, - * clear installed colormaps so that server reset works correctly. - */ - for (i = 0; i < screenInfo.numScreens; i++) - SetInstalledColormap(screenInfo.screens[i], NULL); - - return pScreen->CloseScreen(index, pScreen); -} - -static Bool -vfbScreenInit(int index, ScreenPtr pScreen, int argc, char **argv) -{ - vfbScreenInfoPtr pvfb = &vfbScreens[index]; - int dpix = monitorResolution, dpiy = monitorResolution; - int ret; - char *pbits; - - if (!dixRegisterPrivateKey(&cmapScrPrivateKeyRec, PRIVATE_SCREEN, 0)) - return FALSE; - - if (dpix == 0) - dpix = 100; - - if (dpiy == 0) - dpiy = 100; - - pvfb->paddedBytesWidth = PixmapBytePad(pvfb->width, pvfb->depth); - pvfb->bitsPerPixel = vfbBitsPerPixel(pvfb->depth); - if (pvfb->bitsPerPixel >= 8 ) - pvfb->paddedWidth = pvfb->paddedBytesWidth / (pvfb->bitsPerPixel / 8); - else - pvfb->paddedWidth = pvfb->paddedBytesWidth * 8; - pbits = vfbAllocateFramebufferMemory(pvfb); - if (!pbits) return FALSE; - - switch (pvfb->depth) { - case 8: - miSetVisualTypesAndMasks (8, - ((1 << StaticGray) | - (1 << GrayScale) | - (1 << StaticColor) | - (1 << PseudoColor) | - (1 << TrueColor) | - (1 << DirectColor)), - 8, PseudoColor, 0, 0, 0); - break; - case 15: - miSetVisualTypesAndMasks (15, - ((1 << TrueColor) | - (1 << DirectColor)), - 8, TrueColor, 0x7c00, 0x03e0, 0x001f); - break; - case 16: - miSetVisualTypesAndMasks (16, - ((1 << TrueColor) | - (1 << DirectColor)), - 8, TrueColor, 0xf800, 0x07e0, 0x001f); - break; - case 24: - miSetVisualTypesAndMasks (24, - ((1 << TrueColor) | - (1 << DirectColor)), - 8, TrueColor, 0xff0000, 0x00ff00, 0x0000ff); - break; - case 30: - miSetVisualTypesAndMasks (30, - ((1 << TrueColor) | - (1 << DirectColor)), - 10, TrueColor, 0x3ff00000, 0x000ffc00, 0x000003ff); - break; - } - - miSetPixmapDepths (); - - ret = fbScreenInit(pScreen, pbits, pvfb->width, pvfb->height, - dpix, dpiy, pvfb->paddedWidth,pvfb->bitsPerPixel); - if (ret && Render) - fbPictureInit (pScreen, 0, 0); - - if (!ret) return FALSE; - - pScreen->InstallColormap = vfbInstallColormap; - pScreen->UninstallColormap = vfbUninstallColormap; - pScreen->ListInstalledColormaps = vfbListInstalledColormaps; - - pScreen->SaveScreen = vfbSaveScreen; - pScreen->StoreColors = vfbStoreColors; - - miDCInitialize(pScreen, &vfbPointerCursorFuncs); - - vfbWriteXWDFileHeader(pScreen); - - pScreen->blackPixel = pvfb->blackPixel; - pScreen->whitePixel = pvfb->whitePixel; - - ret = fbCreateDefColormap(pScreen); - - miSetZeroLineBias(pScreen, pvfb->lineBias); - - pvfb->closeScreen = pScreen->CloseScreen; - pScreen->CloseScreen = vfbCloseScreen; - - return ret; - -} /* end vfbScreenInit */ - - -void -InitOutput(ScreenInfo *screenInfo, int argc, char **argv) -{ - int i; - int NumFormats = 0; - - /* initialize pixmap formats */ - - /* must have a pixmap depth to match every screen depth */ - for (i = 0; i < vfbNumScreens; i++) - { - vfbPixmapDepths[vfbScreens[i].depth] = TRUE; - } - - /* RENDER needs a good set of pixmaps. */ - if (Render) { - vfbPixmapDepths[1] = TRUE; - vfbPixmapDepths[4] = TRUE; - vfbPixmapDepths[8] = TRUE; -#if 0 - vfbPixmapDepths[12] = TRUE; -#endif -/* vfbPixmapDepths[15] = TRUE; */ - vfbPixmapDepths[16] = TRUE; - vfbPixmapDepths[24] = TRUE; -#if 0 - vfbPixmapDepths[30] = TRUE; -#endif - vfbPixmapDepths[32] = TRUE; - } - - for (i = 1; i <= 32; i++) - { - if (vfbPixmapDepths[i]) - { - if (NumFormats >= MAXFORMATS) - FatalError ("MAXFORMATS is too small for this server\n"); - screenInfo->formats[NumFormats].depth = i; - screenInfo->formats[NumFormats].bitsPerPixel = vfbBitsPerPixel(i); - screenInfo->formats[NumFormats].scanlinePad = BITMAP_SCANLINE_PAD; - NumFormats++; - } - } - - screenInfo->imageByteOrder = IMAGE_BYTE_ORDER; - screenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT; - screenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD; - screenInfo->bitmapBitOrder = BITMAP_BIT_ORDER; - screenInfo->numPixmapFormats = NumFormats; - - /* initialize screens */ - - if (vfbNumScreens < 1) - { - vfbScreens = &defaultScreenInfo; - vfbNumScreens = 1; - } - for (i = 0; i < vfbNumScreens; i++) - { - if (-1 == AddScreen(vfbScreenInit, argc, argv)) - { - FatalError("Couldn't add screen %d", i); - } - } - -} /* end InitOutput */ +/* + +Copyright 1993, 1998 The Open Group + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of The Open Group shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from The Open Group. + +*/ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#if defined(WIN32) +#include +#endif +#include +#include +#include +#include +#include "scrnintstr.h" +#include "servermd.h" +#define PSZ 8 +#include "fb.h" +#include "mibstore.h" +#include "colormapst.h" +#include "gcstruct.h" +#include "input.h" +#include "mipointer.h" +#include "micmap.h" +#include +#ifdef HAS_MMAP +#include +#ifndef MAP_FILE +#define MAP_FILE 0 +#endif +#endif /* HAS_MMAP */ +#include +#include +#ifndef WIN32 +#include +#endif +#include +#ifdef HAS_SHM +#include +#include +#endif /* HAS_SHM */ +#include "dix.h" +#include "miline.h" + +#define VFB_DEFAULT_WIDTH 1280 +#define VFB_DEFAULT_HEIGHT 1024 +#define VFB_DEFAULT_DEPTH 8 +#define VFB_DEFAULT_WHITEPIXEL 1 +#define VFB_DEFAULT_BLACKPIXEL 0 +#define VFB_DEFAULT_LINEBIAS 0 +#define XWD_WINDOW_NAME_LEN 60 + +typedef struct +{ + int width; + int paddedBytesWidth; + int paddedWidth; + int height; + int depth; + int bitsPerPixel; + int sizeInBytes; + int ncolors; + char *pfbMemory; + XWDColor *pXWDCmap; + XWDFileHeader *pXWDHeader; + Pixel blackPixel; + Pixel whitePixel; + unsigned int lineBias; + CloseScreenProcPtr closeScreen; + +#ifdef HAS_MMAP + int mmap_fd; + char mmap_file[MAXPATHLEN]; +#endif + +#ifdef HAS_SHM + int shmid; +#endif +} vfbScreenInfo, *vfbScreenInfoPtr; + +static int vfbNumScreens; +static vfbScreenInfo *vfbScreens; +static vfbScreenInfo defaultScreenInfo = { + .width = VFB_DEFAULT_WIDTH, + .height = VFB_DEFAULT_HEIGHT, + .depth = VFB_DEFAULT_DEPTH, + .blackPixel = VFB_DEFAULT_BLACKPIXEL, + .whitePixel = VFB_DEFAULT_WHITEPIXEL, + .lineBias = VFB_DEFAULT_LINEBIAS, +}; +static Bool vfbPixmapDepths[33]; +#ifdef HAS_MMAP +static char *pfbdir = NULL; +#endif +typedef enum { NORMAL_MEMORY_FB, SHARED_MEMORY_FB, MMAPPED_FILE_FB } fbMemType; +static fbMemType fbmemtype = NORMAL_MEMORY_FB; +static char needswap = 0; +static Bool Render = TRUE; + +#define swapcopy16(_dst, _src) \ + if (needswap) { CARD16 _s = _src; cpswaps(_s, _dst); } \ + else _dst = _src; + +#define swapcopy32(_dst, _src) \ + if (needswap) { CARD32 _s = _src; cpswapl(_s, _dst); } \ + else _dst = _src; + + +static void +vfbInitializePixmapDepths(void) +{ + int i; + vfbPixmapDepths[1] = TRUE; /* always need bitmaps */ + for (i = 2; i <= 32; i++) + vfbPixmapDepths[i] = FALSE; +} + +static int +vfbBitsPerPixel(int depth) +{ + if (depth == 1) return 1; + else if (depth <= 8) return 8; + else if (depth <= 16) return 16; + else return 32; +} + +void +ddxGiveUp(enum ExitCode error) +{ + int i; + + /* clean up the framebuffers */ + + switch (fbmemtype) + { +#ifdef HAS_MMAP + case MMAPPED_FILE_FB: + for (i = 0; i < vfbNumScreens; i++) + { + if (-1 == unlink(vfbScreens[i].mmap_file)) + { + perror("unlink"); + ErrorF("unlink %s failed, %s", + vfbScreens[i].mmap_file, strerror(errno)); + } + } + break; +#else /* HAS_MMAP */ + case MMAPPED_FILE_FB: + break; +#endif /* HAS_MMAP */ + +#ifdef HAS_SHM + case SHARED_MEMORY_FB: + for (i = 0; i < vfbNumScreens; i++) + { + if (-1 == shmdt((char *)vfbScreens[i].pXWDHeader)) + { + perror("shmdt"); + ErrorF("shmdt failed, %s", strerror(errno)); + } + } + break; +#else /* HAS_SHM */ + case SHARED_MEMORY_FB: + break; +#endif /* HAS_SHM */ + + case NORMAL_MEMORY_FB: + for (i = 0; i < vfbNumScreens; i++) + { + free(vfbScreens[i].pXWDHeader); + } + break; + } +} + +void +AbortDDX(enum ExitCode error) +{ + ddxGiveUp(error); +} + +#ifdef __APPLE__ +void +DarwinHandleGUI(int argc, char *argv[]) +{ +} +#endif + +void +OsVendorInit(void) +{ +} + +void +OsVendorFatalError(void) +{ +} + +#if defined(DDXBEFORERESET) +void ddxBeforeReset(void) +{ + return; +} +#endif + +void +ddxUseMsg(void) +{ + ErrorF("-screen scrn WxHxD set screen's width, height, depth\n"); + ErrorF("-pixdepths list-of-int support given pixmap depths\n"); + ErrorF("+/-render turn on/off RENDER extension support" + "(default on)\n"); + ErrorF("-linebias n adjust thin line pixelization\n"); + ErrorF("-blackpixel n pixel value for black\n"); + ErrorF("-whitepixel n pixel value for white\n"); + +#ifdef HAS_MMAP + ErrorF("-fbdir directory put framebuffers in mmap'ed files in directory\n"); +#endif + +#ifdef HAS_SHM + ErrorF("-shmem put framebuffers in shared memory\n"); +#endif +} + +int +ddxProcessArgument(int argc, char *argv[], int i) +{ + static Bool firstTime = TRUE; + static int lastScreen = -1; + vfbScreenInfo *currentScreen; + + if (firstTime) + { + vfbInitializePixmapDepths(); + firstTime = FALSE; + } + + if (lastScreen == -1) + currentScreen = &defaultScreenInfo; + else + currentScreen = &vfbScreens[lastScreen]; + +#define CHECK_FOR_REQUIRED_ARGUMENTS(num) \ + if (((i + num) >= argc) || (!argv[i + num])) { \ + ErrorF("Required argument to %s not specified\n", argv[i]); \ + UseMsg(); \ + FatalError("Required argument to %s not specified\n", argv[i]); \ + } + + if (strcmp (argv[i], "-screen") == 0) /* -screen n WxHxD */ + { + int screenNum; + CHECK_FOR_REQUIRED_ARGUMENTS(2); + screenNum = atoi(argv[i+1]); + if (screenNum < 0) + { + ErrorF("Invalid screen number %d\n", screenNum); + UseMsg(); + FatalError("Invalid screen number %d passed to -screen\n", + screenNum); + } + + if (vfbNumScreens <= screenNum) + { + vfbScreens = realloc(vfbScreens, sizeof(*vfbScreens) * (screenNum + 1)); + if (!vfbScreens) + FatalError("Not enough memory for screen %d\n", screenNum); + for (; vfbNumScreens <= screenNum; ++vfbNumScreens) + vfbScreens[vfbNumScreens] = defaultScreenInfo; + } + + if (3 != sscanf(argv[i+2], "%dx%dx%d", + &vfbScreens[screenNum].width, + &vfbScreens[screenNum].height, + &vfbScreens[screenNum].depth)) + { + ErrorF("Invalid screen configuration %s\n", argv[i+2]); + UseMsg(); + FatalError("Invalid screen configuration %s for -screen %d\n", + argv[i+2], screenNum); + } + + lastScreen = screenNum; + return 3; + } + + if (strcmp (argv[i], "-pixdepths") == 0) /* -pixdepths list-of-depth */ + { + int depth, ret = 1; + + CHECK_FOR_REQUIRED_ARGUMENTS(1); + while ((++i < argc) && (depth = atoi(argv[i])) != 0) + { + if (depth < 0 || depth > 32) + { + ErrorF("Invalid pixmap depth %d\n", depth); + UseMsg(); + FatalError("Invalid pixmap depth %d passed to -pixdepths\n", + depth); + } + vfbPixmapDepths[depth] = TRUE; + ret++; + } + return ret; + } + + if (strcmp (argv[i], "+render") == 0) /* +render */ + { + Render = TRUE; + return 1; + } + + if (strcmp (argv[i], "-render") == 0) /* -render */ + { + Render = FALSE; +#ifdef COMPOSITE + noCompositeExtension = TRUE; +#endif + return 1; + } + + if (strcmp (argv[i], "-blackpixel") == 0) /* -blackpixel n */ + { + CHECK_FOR_REQUIRED_ARGUMENTS(1); + currentScreen->blackPixel = atoi(argv[++i]); + return 2; + } + + if (strcmp (argv[i], "-whitepixel") == 0) /* -whitepixel n */ + { + CHECK_FOR_REQUIRED_ARGUMENTS(1); + currentScreen->whitePixel = atoi(argv[++i]); + return 2; + } + + if (strcmp (argv[i], "-linebias") == 0) /* -linebias n */ + { + CHECK_FOR_REQUIRED_ARGUMENTS(1); + currentScreen->lineBias = atoi(argv[++i]); + return 2; + } + +#ifdef HAS_MMAP + if (strcmp (argv[i], "-fbdir") == 0) /* -fbdir directory */ + { + CHECK_FOR_REQUIRED_ARGUMENTS(1); + pfbdir = argv[++i]; + fbmemtype = MMAPPED_FILE_FB; + return 2; + } +#endif /* HAS_MMAP */ + +#ifdef HAS_SHM + if (strcmp (argv[i], "-shmem") == 0) /* -shmem */ + { + fbmemtype = SHARED_MEMORY_FB; + return 1; + } +#endif + + return 0; +} + +static DevPrivateKeyRec cmapScrPrivateKeyRec; +#define cmapScrPrivateKey (&cmapScrPrivateKeyRec) + +#define GetInstalledColormap(s) ((ColormapPtr) dixLookupPrivate(&(s)->devPrivates, cmapScrPrivateKey)) +#define SetInstalledColormap(s,c) (dixSetPrivate(&(s)->devPrivates, cmapScrPrivateKey, c)) + +static int +vfbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps) +{ + /* By the time we are processing requests, we can guarantee that there + * is always a colormap installed */ + *pmaps = GetInstalledColormap(pScreen)->mid; + return 1; +} + + +static void +vfbInstallColormap(ColormapPtr pmap) +{ + ColormapPtr oldpmap = GetInstalledColormap(pmap->pScreen); + + if (pmap != oldpmap) + { + int entries; + XWDFileHeader *pXWDHeader; + XWDColor *pXWDCmap; + VisualPtr pVisual; + Pixel * ppix; + xrgb * prgb; + xColorItem *defs; + int i; + + if(oldpmap != (ColormapPtr)None) + WalkTree(pmap->pScreen, TellLostMap, (char *)&oldpmap->mid); + /* Install pmap */ + SetInstalledColormap(pmap->pScreen, pmap); + WalkTree(pmap->pScreen, TellGainedMap, (char *)&pmap->mid); + + entries = pmap->pVisual->ColormapEntries; + pXWDHeader = vfbScreens[pmap->pScreen->myNum].pXWDHeader; + pXWDCmap = vfbScreens[pmap->pScreen->myNum].pXWDCmap; + pVisual = pmap->pVisual; + + swapcopy32(pXWDHeader->visual_class, pVisual->class); + swapcopy32(pXWDHeader->red_mask, pVisual->redMask); + swapcopy32(pXWDHeader->green_mask, pVisual->greenMask); + swapcopy32(pXWDHeader->blue_mask, pVisual->blueMask); + swapcopy32(pXWDHeader->bits_per_rgb, pVisual->bitsPerRGBValue); + swapcopy32(pXWDHeader->colormap_entries, pVisual->ColormapEntries); + + ppix = (Pixel *)malloc(entries * sizeof(Pixel)); + prgb = (xrgb *)malloc(entries * sizeof(xrgb)); + defs = (xColorItem *)malloc(entries * sizeof(xColorItem)); + + for (i = 0; i < entries; i++) ppix[i] = i; + /* XXX truecolor */ + QueryColors(pmap, entries, ppix, prgb, serverClient); + + for (i = 0; i < entries; i++) { /* convert xrgbs to xColorItems */ + defs[i].pixel = ppix[i] & 0xff; /* change pixel to index */ + defs[i].red = prgb[i].red; + defs[i].green = prgb[i].green; + defs[i].blue = prgb[i].blue; + defs[i].flags = DoRed|DoGreen|DoBlue; + } + (*pmap->pScreen->StoreColors)(pmap, entries, defs); + + free(ppix); + free(prgb); + free(defs); + } +} + +static void +vfbUninstallColormap(ColormapPtr pmap) +{ + ColormapPtr curpmap = GetInstalledColormap(pmap->pScreen); + + if(pmap == curpmap) + { + if (pmap->mid != pmap->pScreen->defColormap) + { + dixLookupResourceByType((pointer *)&curpmap, + pmap->pScreen->defColormap, + RT_COLORMAP, serverClient, + DixInstallAccess); + (*pmap->pScreen->InstallColormap)(curpmap); + } + } +} + +static void +vfbStoreColors(ColormapPtr pmap, int ndef, xColorItem *pdefs) +{ + XWDColor *pXWDCmap; + int i; + + if (pmap != GetInstalledColormap(pmap->pScreen)) + { + return; + } + + pXWDCmap = vfbScreens[pmap->pScreen->myNum].pXWDCmap; + + if ((pmap->pVisual->class | DynamicClass) == DirectColor) + { + return; + } + + for (i = 0; i < ndef; i++) + { + if (pdefs[i].flags & DoRed) + { + swapcopy16(pXWDCmap[pdefs[i].pixel].red, pdefs[i].red); + } + if (pdefs[i].flags & DoGreen) + { + swapcopy16(pXWDCmap[pdefs[i].pixel].green, pdefs[i].green); + } + if (pdefs[i].flags & DoBlue) + { + swapcopy16(pXWDCmap[pdefs[i].pixel].blue, pdefs[i].blue); + } + } +} + +static Bool +vfbSaveScreen(ScreenPtr pScreen, int on) +{ + return TRUE; +} + +#ifdef HAS_MMAP + +/* this flushes any changes to the screens out to the mmapped file */ +static void +vfbBlockHandler(pointer blockData, OSTimePtr pTimeout, pointer pReadmask) +{ + int i; + + for (i = 0; i < vfbNumScreens; i++) + { +#ifdef MS_ASYNC + if (-1 == msync((caddr_t)vfbScreens[i].pXWDHeader, + (size_t)vfbScreens[i].sizeInBytes, MS_ASYNC)) +#else + /* silly NetBSD and who else? */ + if (-1 == msync((caddr_t)vfbScreens[i].pXWDHeader, + (size_t)vfbScreens[i].sizeInBytes)) +#endif + { + perror("msync"); + ErrorF("msync failed, %s", strerror(errno)); + } + } +} + + +static void +vfbWakeupHandler(pointer blockData, int result, pointer pReadmask) +{ +} + + +static void +vfbAllocateMmappedFramebuffer(vfbScreenInfoPtr pvfb) +{ +#define DUMMY_BUFFER_SIZE 65536 + char dummyBuffer[DUMMY_BUFFER_SIZE]; + int currentFileSize, writeThisTime; + + sprintf(pvfb->mmap_file, "%s/Xvfb_screen%d", pfbdir, (int) (pvfb - vfbScreens)); + if (-1 == (pvfb->mmap_fd = open(pvfb->mmap_file, O_CREAT|O_RDWR, 0666))) + { + perror("open"); + ErrorF("open %s failed, %s", pvfb->mmap_file, strerror(errno)); + return; + } + + /* Extend the file to be the proper size */ + + memset(dummyBuffer, 0, DUMMY_BUFFER_SIZE); + for (currentFileSize = 0; + currentFileSize < pvfb->sizeInBytes; + currentFileSize += writeThisTime) + { + writeThisTime = min(DUMMY_BUFFER_SIZE, + pvfb->sizeInBytes - currentFileSize); + if (-1 == write(pvfb->mmap_fd, dummyBuffer, writeThisTime)) + { + perror("write"); + ErrorF("write %s failed, %s", pvfb->mmap_file, strerror(errno)); + return; + } + } + + /* try to mmap the file */ + + pvfb->pXWDHeader = (XWDFileHeader *)mmap((caddr_t)NULL, pvfb->sizeInBytes, + PROT_READ|PROT_WRITE, + MAP_FILE|MAP_SHARED, + pvfb->mmap_fd, 0); + if (-1 == (long)pvfb->pXWDHeader) + { + perror("mmap"); + ErrorF("mmap %s failed, %s", pvfb->mmap_file, strerror(errno)); + pvfb->pXWDHeader = NULL; + return; + } + + if (!RegisterBlockAndWakeupHandlers(vfbBlockHandler, vfbWakeupHandler, + NULL)) + { + pvfb->pXWDHeader = NULL; + } +} +#endif /* HAS_MMAP */ + + +#ifdef HAS_SHM +static void +vfbAllocateSharedMemoryFramebuffer(vfbScreenInfoPtr pvfb) +{ + /* create the shared memory segment */ + + pvfb->shmid = shmget(IPC_PRIVATE, pvfb->sizeInBytes, IPC_CREAT|0777); + if (pvfb->shmid < 0) + { + perror("shmget"); + ErrorF("shmget %d bytes failed, %s", pvfb->sizeInBytes, strerror(errno)); + return; + } + + /* try to attach it */ + + pvfb->pXWDHeader = (XWDFileHeader *)shmat(pvfb->shmid, 0, 0); + if (-1 == (long)pvfb->pXWDHeader) + { + perror("shmat"); + ErrorF("shmat failed, %s", strerror(errno)); + pvfb->pXWDHeader = NULL; + return; + } + + ErrorF("screen %d shmid %d\n", (int) (pvfb - vfbScreens), pvfb->shmid); +} +#endif /* HAS_SHM */ + +static char * +vfbAllocateFramebufferMemory(vfbScreenInfoPtr pvfb) +{ + if (pvfb->pfbMemory) return pvfb->pfbMemory; /* already done */ + + pvfb->sizeInBytes = pvfb->paddedBytesWidth * pvfb->height; + + /* Calculate how many entries in colormap. This is rather bogus, because + * the visuals haven't even been set up yet, but we need to know because we + * have to allocate space in the file for the colormap. The number 10 + * below comes from the MAX_PSEUDO_DEPTH define in cfbcmap.c. + */ + + if (pvfb->depth <= 10) + { /* single index colormaps */ + pvfb->ncolors = 1 << pvfb->depth; + } + else + { /* decomposed colormaps */ + int nplanes_per_color_component = pvfb->depth / 3; + if (pvfb->depth % 3) nplanes_per_color_component++; + pvfb->ncolors = 1 << nplanes_per_color_component; + } + + /* add extra bytes for XWDFileHeader, window name, and colormap */ + + pvfb->sizeInBytes += SIZEOF(XWDheader) + XWD_WINDOW_NAME_LEN + + pvfb->ncolors * SIZEOF(XWDColor); + + pvfb->pXWDHeader = NULL; + switch (fbmemtype) + { +#ifdef HAS_MMAP + case MMAPPED_FILE_FB: vfbAllocateMmappedFramebuffer(pvfb); break; +#else + case MMAPPED_FILE_FB: break; +#endif + +#ifdef HAS_SHM + case SHARED_MEMORY_FB: vfbAllocateSharedMemoryFramebuffer(pvfb); break; +#else + case SHARED_MEMORY_FB: break; +#endif + + case NORMAL_MEMORY_FB: + pvfb->pXWDHeader = (XWDFileHeader *)malloc(pvfb->sizeInBytes); + break; + } + + if (pvfb->pXWDHeader) + { + pvfb->pXWDCmap = (XWDColor *)((char *)pvfb->pXWDHeader + + SIZEOF(XWDheader) + XWD_WINDOW_NAME_LEN); + pvfb->pfbMemory = (char *)(pvfb->pXWDCmap + pvfb->ncolors); + + return pvfb->pfbMemory; + } + else + return NULL; +} + + +static void +vfbWriteXWDFileHeader(ScreenPtr pScreen) +{ + vfbScreenInfoPtr pvfb = &vfbScreens[pScreen->myNum]; + XWDFileHeader *pXWDHeader = pvfb->pXWDHeader; + char hostname[XWD_WINDOW_NAME_LEN]; + unsigned long swaptest = 1; + int i; + + needswap = *(char *) &swaptest; + + pXWDHeader->header_size = (char *)pvfb->pXWDCmap - (char *)pvfb->pXWDHeader; + pXWDHeader->file_version = XWD_FILE_VERSION; + + pXWDHeader->pixmap_format = ZPixmap; + pXWDHeader->pixmap_depth = pvfb->depth; + pXWDHeader->pixmap_height = pXWDHeader->window_height = pvfb->height; + pXWDHeader->xoffset = 0; + pXWDHeader->byte_order = IMAGE_BYTE_ORDER; + pXWDHeader->bitmap_bit_order = BITMAP_BIT_ORDER; +#ifndef INTERNAL_VS_EXTERNAL_PADDING + pXWDHeader->pixmap_width = pXWDHeader->window_width = pvfb->width; + pXWDHeader->bitmap_unit = BITMAP_SCANLINE_UNIT; + pXWDHeader->bitmap_pad = BITMAP_SCANLINE_PAD; +#else + pXWDHeader->pixmap_width = pXWDHeader->window_width = pvfb->paddedWidth; + pXWDHeader->bitmap_unit = BITMAP_SCANLINE_UNIT_PROTO; + pXWDHeader->bitmap_pad = BITMAP_SCANLINE_PAD_PROTO; +#endif + pXWDHeader->bits_per_pixel = pvfb->bitsPerPixel; + pXWDHeader->bytes_per_line = pvfb->paddedBytesWidth; + pXWDHeader->ncolors = pvfb->ncolors; + + /* visual related fields are written when colormap is installed */ + + pXWDHeader->window_x = pXWDHeader->window_y = 0; + pXWDHeader->window_bdrwidth = 0; + + /* write xwd "window" name: Xvfb hostname:server.screen */ + + if (-1 == gethostname(hostname, sizeof(hostname))) + hostname[0] = 0; + else + hostname[XWD_WINDOW_NAME_LEN-1] = 0; + sprintf((char *)(pXWDHeader+1), "Xvfb %s:%s.%d", hostname, display, + pScreen->myNum); + + /* write colormap pixel slot values */ + + for (i = 0; i < pvfb->ncolors; i++) + { + pvfb->pXWDCmap[i].pixel = i; + } + + /* byte swap to most significant byte first */ + + if (needswap) + { + SwapLongs((CARD32 *)pXWDHeader, SIZEOF(XWDheader)/4); + for (i = 0; i < pvfb->ncolors; i++) + { + register char n; + swapl(&pvfb->pXWDCmap[i].pixel, n); + } + } +} + + +static Bool +vfbCursorOffScreen (ScreenPtr *ppScreen, int *x, int *y) +{ + return FALSE; +} + +static void +vfbCrossScreen (ScreenPtr pScreen, Bool entering) +{ +} + +static miPointerScreenFuncRec vfbPointerCursorFuncs = +{ + vfbCursorOffScreen, + vfbCrossScreen, + miPointerWarpCursor +}; + +static Bool +vfbCloseScreen(int index, ScreenPtr pScreen) +{ + vfbScreenInfoPtr pvfb = &vfbScreens[index]; + int i; + + pScreen->CloseScreen = pvfb->closeScreen; + + /* + * XXX probably lots of stuff to clean. For now, + * clear installed colormaps so that server reset works correctly. + */ + for (i = 0; i < screenInfo.numScreens; i++) + SetInstalledColormap(screenInfo.screens[i], NULL); + + return pScreen->CloseScreen(index, pScreen); +} + +static Bool +vfbScreenInit(int index, ScreenPtr pScreen, int argc, char **argv) +{ + vfbScreenInfoPtr pvfb = &vfbScreens[index]; + int dpix = monitorResolution, dpiy = monitorResolution; + int ret; + char *pbits; + + if (!dixRegisterPrivateKey(&cmapScrPrivateKeyRec, PRIVATE_SCREEN, 0)) + return FALSE; + + if (dpix == 0) + dpix = 100; + + if (dpiy == 0) + dpiy = 100; + + pvfb->paddedBytesWidth = PixmapBytePad(pvfb->width, pvfb->depth); + pvfb->bitsPerPixel = vfbBitsPerPixel(pvfb->depth); + if (pvfb->bitsPerPixel >= 8 ) + pvfb->paddedWidth = pvfb->paddedBytesWidth / (pvfb->bitsPerPixel / 8); + else + pvfb->paddedWidth = pvfb->paddedBytesWidth * 8; + pbits = vfbAllocateFramebufferMemory(pvfb); + if (!pbits) return FALSE; + + switch (pvfb->depth) { + case 8: + miSetVisualTypesAndMasks (8, + ((1 << StaticGray) | + (1 << GrayScale) | + (1 << StaticColor) | + (1 << PseudoColor) | + (1 << TrueColor) | + (1 << DirectColor)), + 8, PseudoColor, 0, 0, 0); + break; + case 15: + miSetVisualTypesAndMasks (15, + ((1 << TrueColor) | + (1 << DirectColor)), + 8, TrueColor, 0x7c00, 0x03e0, 0x001f); + break; + case 16: + miSetVisualTypesAndMasks (16, + ((1 << TrueColor) | + (1 << DirectColor)), + 8, TrueColor, 0xf800, 0x07e0, 0x001f); + break; + case 24: + miSetVisualTypesAndMasks (24, + ((1 << TrueColor) | + (1 << DirectColor)), + 8, TrueColor, 0xff0000, 0x00ff00, 0x0000ff); + break; + case 30: + miSetVisualTypesAndMasks (30, + ((1 << TrueColor) | + (1 << DirectColor)), + 10, TrueColor, 0x3ff00000, 0x000ffc00, 0x000003ff); + break; + } + + miSetPixmapDepths (); + + ret = fbScreenInit(pScreen, pbits, pvfb->width, pvfb->height, + dpix, dpiy, pvfb->paddedWidth,pvfb->bitsPerPixel); + if (ret && Render) + fbPictureInit (pScreen, 0, 0); + + if (!ret) return FALSE; + + pScreen->InstallColormap = vfbInstallColormap; + pScreen->UninstallColormap = vfbUninstallColormap; + pScreen->ListInstalledColormaps = vfbListInstalledColormaps; + + pScreen->SaveScreen = vfbSaveScreen; + pScreen->StoreColors = vfbStoreColors; + + miDCInitialize(pScreen, &vfbPointerCursorFuncs); + + vfbWriteXWDFileHeader(pScreen); + + pScreen->blackPixel = pvfb->blackPixel; + pScreen->whitePixel = pvfb->whitePixel; + + ret = fbCreateDefColormap(pScreen); + + miSetZeroLineBias(pScreen, pvfb->lineBias); + + pvfb->closeScreen = pScreen->CloseScreen; + pScreen->CloseScreen = vfbCloseScreen; + + return ret; + +} /* end vfbScreenInit */ + + +void +InitOutput(ScreenInfo *screenInfo, int argc, char **argv) +{ + int i; + int NumFormats = 0; + + /* initialize pixmap formats */ + + /* must have a pixmap depth to match every screen depth */ + for (i = 0; i < vfbNumScreens; i++) + { + vfbPixmapDepths[vfbScreens[i].depth] = TRUE; + } + + /* RENDER needs a good set of pixmaps. */ + if (Render) { + vfbPixmapDepths[1] = TRUE; + vfbPixmapDepths[4] = TRUE; + vfbPixmapDepths[8] = TRUE; +#if 0 + vfbPixmapDepths[12] = TRUE; +#endif +/* vfbPixmapDepths[15] = TRUE; */ + vfbPixmapDepths[16] = TRUE; + vfbPixmapDepths[24] = TRUE; +#if 0 + vfbPixmapDepths[30] = TRUE; +#endif + vfbPixmapDepths[32] = TRUE; + } + + for (i = 1; i <= 32; i++) + { + if (vfbPixmapDepths[i]) + { + if (NumFormats >= MAXFORMATS) + FatalError ("MAXFORMATS is too small for this server\n"); + screenInfo->formats[NumFormats].depth = i; + screenInfo->formats[NumFormats].bitsPerPixel = vfbBitsPerPixel(i); + screenInfo->formats[NumFormats].scanlinePad = BITMAP_SCANLINE_PAD; + NumFormats++; + } + } + + screenInfo->imageByteOrder = IMAGE_BYTE_ORDER; + screenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT; + screenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD; + screenInfo->bitmapBitOrder = BITMAP_BIT_ORDER; + screenInfo->numPixmapFormats = NumFormats; + + /* initialize screens */ + + if (vfbNumScreens < 1) + { + vfbScreens = &defaultScreenInfo; + vfbNumScreens = 1; + } + for (i = 0; i < vfbNumScreens; i++) + { + if (-1 == AddScreen(vfbScreenInit, argc, argv)) + { + FatalError("Couldn't add screen %d", i); + } + } + +} /* end InitOutput */ diff --git a/xorg-server/hw/xfree86/common/xf86Config.c b/xorg-server/hw/xfree86/common/xf86Config.c index 114bdc3a3..58b30dd68 100644 --- a/xorg-server/hw/xfree86/common/xf86Config.c +++ b/xorg-server/hw/xfree86/common/xf86Config.c @@ -1222,6 +1222,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout) devs = xnfrealloc(servlayoutp->inputs, (count + 1) * sizeof(InputInfoPtr)); devs[count - 1] = xnfalloc(sizeof(InputInfoRec)); + Pointer.fd = -1; *devs[count - 1] = Pointer; devs[count - 1]->options = xf86addNewOption(devs[count -1]->options, @@ -1267,6 +1268,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout) devs = xnfrealloc(servlayoutp->inputs, (count + 1) * sizeof(InputInfoPtr)); devs[count - 1] = xnfalloc(sizeof(InputInfoRec)); + Pointer.fd = -1; *devs[count - 1] = Pointer; devs[count - 1]->options = xf86addNewOption(NULL, xnfstrdup("AlwaysCore"), NULL); @@ -1363,6 +1365,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout) devs = xnfrealloc(servlayoutp->inputs, (count + 1) * sizeof(InputInfoPtr)); devs[count - 1] = xnfalloc(sizeof(InputInfoRec)); + Keyboard.fd = -1; *devs[count - 1] = Keyboard; devs[count - 1]->options = xf86addNewOption(devs[count - 1]->options, diff --git a/xorg-server/hw/xfree86/common/xf86Configure.c b/xorg-server/hw/xfree86/common/xf86Configure.c index 975266943..ab0751507 100644 --- a/xorg-server/hw/xfree86/common/xf86Configure.c +++ b/xorg-server/hw/xfree86/common/xf86Configure.c @@ -749,7 +749,7 @@ DoConfigure(void) bail: OsCleanup(TRUE); - AbortDDX(); + AbortDDX(EXIT_ERR_CONFIGURE); fflush(stderr); exit(0); } diff --git a/xorg-server/hw/xfree86/common/xf86Helper.c b/xorg-server/hw/xfree86/common/xf86Helper.c index 3cdffdb43..f8e6c8b41 100644 --- a/xorg-server/hw/xfree86/common/xf86Helper.c +++ b/xorg-server/hw/xfree86/common/xf86Helper.c @@ -1198,9 +1198,9 @@ xf86LogInit(void) } void -xf86CloseLog(void) +xf86CloseLog(enum ExitCode error) { - LogClose(); + LogClose(error); } diff --git a/xorg-server/hw/xfree86/common/xf86Init.c b/xorg-server/hw/xfree86/common/xf86Init.c index 15fdbc349..71926f8e7 100644 --- a/xorg-server/hw/xfree86/common/xf86Init.c +++ b/xorg-server/hw/xfree86/common/xf86Init.c @@ -791,6 +791,21 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv) NULL); } +static InputInfoPtr +duplicateDevice(InputInfoPtr pInfo) +{ + InputInfoPtr dup = calloc(1, sizeof(InputInfoRec)); + if (dup) { + dup->name = strdup(pInfo->name); + dup->driver = strdup(pInfo->driver); + dup->options = xf86OptionListDuplicate(pInfo->options); + /* type_name is a const string */ + dup->type_name = pInfo->type_name; + dup->fd = -1; + } + return dup; +} + /* * InitInput -- * Initialize all supported input devices. @@ -799,7 +814,7 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv) void InitInput(int argc, char **argv) { - InputInfoPtr* pDev; + InputInfoPtr* pInfo; DeviceIntPtr dev; xf86Info.vtRequestsPending = FALSE; @@ -807,14 +822,21 @@ InitInput(int argc, char **argv) mieqInit(); /* Initialize all configured input devices */ - for (pDev = xf86ConfigLayout.inputs; pDev && *pDev; pDev++) { + for (pInfo = xf86ConfigLayout.inputs; pInfo && *pInfo; pInfo++) { + InputInfoPtr dup; /* Replace obsolete keyboard driver with kbd */ - if (!xf86NameCmp((*pDev)->driver, "keyboard")) { - strcpy((*pDev)->driver, "kbd"); + if (!xf86NameCmp((*pInfo)->driver, "keyboard")) { + strcpy((*pInfo)->driver, "kbd"); } + /* Data passed into xf86NewInputDevice will be freed on shutdown. + * Duplicate from xf86ConfigLayout.inputs, otherwise we don't have any + * xorg.conf input devices in the second generation + */ + dup = duplicateDevice(*pInfo); + /* If one fails, the others will too */ - if (xf86NewInputDevice(*pDev, &dev, TRUE) == BadAlloc) + if (xf86NewInputDevice(dup, &dev, TRUE) == BadAlloc) break; } @@ -880,7 +902,7 @@ OsVendorInit(void) */ void -ddxGiveUp(void) +ddxGiveUp(enum ExitCode error) { int i; @@ -907,7 +929,7 @@ ddxGiveUp(void) if (xorgHWOpenConsole) xf86CloseConsole(); - xf86CloseLog(); + xf86CloseLog(error); /* If an unexpected signal was caught, dump a core for debugging */ if (xf86Info.caughtSignal) @@ -924,7 +946,7 @@ ddxGiveUp(void) */ void -AbortDDX(void) +AbortDDX(enum ExitCode error) { int i; @@ -957,7 +979,7 @@ AbortDDX(void) * This is needed for an abnormal server exit, since the normal exit stuff * MUST also be performed (i.e. the vt must be left in a defined state) */ - ddxGiveUp(); + ddxGiveUp(error); } void diff --git a/xorg-server/hw/xfree86/common/xf86Option.c b/xorg-server/hw/xfree86/common/xf86Option.c index 480f38694..a3a836fc1 100644 --- a/xorg-server/hw/xfree86/common/xf86Option.c +++ b/xorg-server/hw/xfree86/common/xf86Option.c @@ -340,7 +340,7 @@ pointer xf86AddNewOption(pointer head, const char *name, const char *val) { /* XXX These should actually be allocated in the parser library. */ - char *tmp = strdup(val); + char *tmp = val ? strdup(val) : NULL; char *tmp_name = strdup(name); return xf86addNewOption(head, tmp_name, tmp); diff --git a/xorg-server/hw/xfree86/common/xf86Priv.h b/xorg-server/hw/xfree86/common/xf86Priv.h index 5d91ab367..1fe3d7e0d 100644 --- a/xorg-server/hw/xfree86/common/xf86Priv.h +++ b/xorg-server/hw/xfree86/common/xf86Priv.h @@ -140,7 +140,7 @@ extern _X_EXPORT pmWait (*xf86PMConfirmEventToOs)(int fd,pmEvent event); /* xf86Helper.c */ extern _X_EXPORT void xf86LogInit(void); -extern _X_EXPORT void xf86CloseLog(void); +extern _X_EXPORT void xf86CloseLog(enum ExitCode error); /* xf86Init.c */ extern _X_EXPORT Bool xf86LoadModules(char **list, pointer *optlist); diff --git a/xorg-server/hw/xfree86/common/xf86ShowOpts.c b/xorg-server/hw/xfree86/common/xf86ShowOpts.c index 7aa79eb6a..a8059168d 100644 --- a/xorg-server/hw/xfree86/common/xf86ShowOpts.c +++ b/xorg-server/hw/xfree86/common/xf86ShowOpts.c @@ -1,130 +1,130 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86ShopwOpts.c,v 3.80 2003/10/08 14:58:27 dawes Exp $ */ -/* - * Copyright 2000-2002 by Alan Hourihane, Flint Mountain, North Wales. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Alan Hourihane not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Alan Hourihane makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY 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 THIS SOFTWARE. - * - * Author: Marcus Schaefer, ms@suse.de - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include "os.h" -#ifdef XFree86LOADER -#include "loaderProcs.h" -#endif -#include "xf86.h" -#include "xf86Config.h" -#include "xf86_OSlib.h" -#include "xf86Priv.h" -/* #include "xf86PciData.h" */ -#define IN_XSERVER -#include "xf86Parser.h" -#include "xf86tokens.h" -#include "Configint.h" -#include "xf86DDC.h" -#if defined(__sparc__) && !defined(__OpenBSD__) -#include "xf86Bus.h" -#include "xf86Sbus.h" -#endif -#include "globals.h" - -static const char* -optionTypeToSting(OptionValueType type) -{ - switch (type) { - case OPTV_NONE: - return ""; - case OPTV_INTEGER: - return ""; - case OPTV_STRING: - return ""; - case OPTV_ANYSTR: - return ""; - case OPTV_REAL: - return ""; - case OPTV_BOOLEAN: - return ""; - case OPTV_FREQ: - return ""; - case OPTV_PERCENT: - return ""; - default: - return ""; - } -} - -void DoShowOptions (void) { - int i = 0; - char **vlist = 0; - char *pSymbol = 0; - XF86ModuleData *initData = 0; - if (! (vlist = xf86DriverlistFromCompile())) { - ErrorF("Missing output drivers\n"); - goto bail; - } - xf86LoadModules (vlist,0); - free(vlist); - for (i = 0; i < xf86NumDrivers; i++) { - if (xf86DriverList[i]->AvailableOptions) { - OptionInfoPtr pOption = (OptionInfoPtr)(*xf86DriverList[i]->AvailableOptions)(0,0); - if (! pOption) { - ErrorF ("(EE) Couldn't read option table for %s driver\n", - xf86DriverList[i]->driverName - ); - continue; - } - XNFasprintf(&pSymbol, "%sModuleData", - xf86DriverList[i]->driverName); - initData = LoaderSymbol (pSymbol); - if (initData) { - XF86ModuleVersionInfo *vers = initData->vers; - OptionInfoPtr p; - ErrorF ("Driver[%d]:%s[%s] {\n", - i,xf86DriverList[i]->driverName,vers->vendor - ); - for (p = pOption; p->name != NULL; p++) { - const char *opttype = optionTypeToSting(p->type); - /* XXX: Why overallocate by 2 bytes? - * Otherwise, this would be strdup() - */ - char *optname = malloc(strlen(p->name) + 2 + 1); - if (!optname) { - continue; - } - sprintf(optname, "%s", p->name); - ErrorF ("\t%s:%s\n", optname,opttype); - } - ErrorF ("}\n"); - } - } - } - bail: - OsCleanup (TRUE); - AbortDDX (); - fflush (stderr); - exit (0); -} +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86ShopwOpts.c,v 3.80 2003/10/08 14:58:27 dawes Exp $ */ +/* + * Copyright 2000-2002 by Alan Hourihane, Flint Mountain, North Wales. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Alan Hourihane not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Alan Hourihane makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY 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 THIS SOFTWARE. + * + * Author: Marcus Schaefer, ms@suse.de + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "os.h" +#ifdef XFree86LOADER +#include "loaderProcs.h" +#endif +#include "xf86.h" +#include "xf86Config.h" +#include "xf86_OSlib.h" +#include "xf86Priv.h" +/* #include "xf86PciData.h" */ +#define IN_XSERVER +#include "xf86Parser.h" +#include "xf86tokens.h" +#include "Configint.h" +#include "xf86DDC.h" +#if defined(__sparc__) && !defined(__OpenBSD__) +#include "xf86Bus.h" +#include "xf86Sbus.h" +#endif +#include "globals.h" + +static const char* +optionTypeToSting(OptionValueType type) +{ + switch (type) { + case OPTV_NONE: + return ""; + case OPTV_INTEGER: + return ""; + case OPTV_STRING: + return ""; + case OPTV_ANYSTR: + return ""; + case OPTV_REAL: + return ""; + case OPTV_BOOLEAN: + return ""; + case OPTV_FREQ: + return ""; + case OPTV_PERCENT: + return ""; + default: + return ""; + } +} + +void DoShowOptions (void) { + int i = 0; + char **vlist = 0; + char *pSymbol = 0; + XF86ModuleData *initData = 0; + if (! (vlist = xf86DriverlistFromCompile())) { + ErrorF("Missing output drivers\n"); + goto bail; + } + xf86LoadModules (vlist,0); + free(vlist); + for (i = 0; i < xf86NumDrivers; i++) { + if (xf86DriverList[i]->AvailableOptions) { + OptionInfoPtr pOption = (OptionInfoPtr)(*xf86DriverList[i]->AvailableOptions)(0,0); + if (! pOption) { + ErrorF ("(EE) Couldn't read option table for %s driver\n", + xf86DriverList[i]->driverName + ); + continue; + } + XNFasprintf(&pSymbol, "%sModuleData", + xf86DriverList[i]->driverName); + initData = LoaderSymbol (pSymbol); + if (initData) { + XF86ModuleVersionInfo *vers = initData->vers; + OptionInfoPtr p; + ErrorF ("Driver[%d]:%s[%s] {\n", + i,xf86DriverList[i]->driverName,vers->vendor + ); + for (p = pOption; p->name != NULL; p++) { + const char *opttype = optionTypeToSting(p->type); + /* XXX: Why overallocate by 2 bytes? + * Otherwise, this would be strdup() + */ + char *optname = malloc(strlen(p->name) + 2 + 1); + if (!optname) { + continue; + } + sprintf(optname, "%s", p->name); + ErrorF ("\t%s:%s\n", optname,opttype); + } + ErrorF ("}\n"); + } + } + } + bail: + OsCleanup (TRUE); + AbortDDX (EXIT_ERR_DRIVERS); + fflush (stderr); + exit (0); +} diff --git a/xorg-server/hw/xfree86/common/xf86Xinput.c b/xorg-server/hw/xfree86/common/xf86Xinput.c index 26051ad7f..d22fdc8b9 100644 --- a/xorg-server/hw/xfree86/common/xf86Xinput.c +++ b/xorg-server/hw/xfree86/common/xf86Xinput.c @@ -844,6 +844,7 @@ xf86NewInputDevice(InputInfoPtr pInfo, DeviceIntPtr *pdev, BOOL enable) { OsReleaseSignals(); xf86Msg(X_ERROR, "Couldn't init device \"%s\"\n", pInfo->name); + RemoveDevice(dev, TRUE); rval = BadMatch; goto unwind; } diff --git a/xorg-server/hw/xnest/Init.c b/xorg-server/hw/xnest/Init.c index ea0669a6a..af57518ba 100644 --- a/xorg-server/hw/xnest/Init.c +++ b/xorg-server/hw/xnest/Init.c @@ -114,16 +114,16 @@ CloseInput(void) /* * DDX - specific abort routine. Called by AbortServer(). */ -void AbortDDX(void) +void AbortDDX(enum ExitCode error) { xnestDoFullGeneration = True; xnestCloseDisplay(); } /* Called by GiveUp(). */ -void ddxGiveUp(void) +void ddxGiveUp(enum ExitCode error) { - AbortDDX(); + AbortDDX(error); } #ifdef __APPLE__ diff --git a/xorg-server/hw/xquartz/darwin.c b/xorg-server/hw/xquartz/darwin.c index 73685b0d4..f19d7bf30 100644 --- a/xorg-server/hw/xquartz/darwin.c +++ b/xorg-server/hw/xquartz/darwin.c @@ -766,9 +766,9 @@ void ddxUseMsg( void ) * ddxGiveUp -- * Device dependent cleanup. Called by dix before normal server death. */ -void ddxGiveUp( void ) +void ddxGiveUp( enum ExitCode error ) { - ErrorF( "Quitting Xquartz\n" ); + LogClose(error); } @@ -779,7 +779,7 @@ void ddxGiveUp( void ) * are closed. */ _X_NORETURN -void AbortDDX( void ) { +void AbortDDX( enum ExitCode error ) { ErrorF( " AbortDDX\n" ); OsAbort(); } diff --git a/xorg-server/hw/xwin/InitOutput.c b/xorg-server/hw/xwin/InitOutput.c index 22ef8da76..4fe5053b3 100644 --- a/xorg-server/hw/xwin/InitOutput.c +++ b/xorg-server/hw/xwin/InitOutput.c @@ -191,7 +191,7 @@ ddxBeforeReset (void) /* See Porting Layer Definition - p. 57 */ void -ddxGiveUp (void) +ddxGiveUp (enum ExitCode error) { int i; @@ -228,7 +228,7 @@ ddxGiveUp (void) g_pszLogFile = LogInit (g_pszLogFile, NULL); g_fLogInited = TRUE; } - LogClose (); + LogClose (error); /* * At this point we aren't creating any new screens, so @@ -258,12 +258,12 @@ ddxGiveUp (void) /* See Porting Layer Definition - p. 57 */ void -AbortDDX (void) +AbortDDX (enum ExitCode error) { #if CYGDEBUG winDebug ("AbortDDX\n"); #endif - ddxGiveUp (); + ddxGiveUp (error); } #ifdef __CYGWIN__ @@ -901,7 +901,7 @@ ddxUseMsg(void) g_pszLogFile = LogInit (g_pszLogFile, NULL); g_fLogInited = TRUE; } - LogClose (); + LogClose (EXIT_NO_ERROR); /* Notify user where UseMsg text can be found.*/ if (!g_fNoHelpMessageBox) diff --git a/xorg-server/hw/xwin/Makefile.am b/xorg-server/hw/xwin/Makefile.am index ce2edb2e6..256af0bb1 100644 --- a/xorg-server/hw/xwin/Makefile.am +++ b/xorg-server/hw/xwin/Makefile.am @@ -175,27 +175,7 @@ install-exec-hook: EXTRA_DIST = \ $(xwinconfig_DATA) \ X.ico \ - XWin.rc \ - xlaunch/config.cc \ - xlaunch/COPYING \ - xlaunch/main.cc \ - xlaunch/resources/dialog.rc \ - xlaunch/resources/fullscreen.bmp \ - xlaunch/resources/images.rc \ - xlaunch/resources/multiwindow.bmp \ - xlaunch/resources/nodecoration.bmp \ - xlaunch/resources/resources.h \ - xlaunch/resources/resources.rc \ - xlaunch/resources/strings.rc \ - xlaunch/resources/windowed.bmp \ - xlaunch/window/dialog.cc \ - xlaunch/window/dialog.h \ - xlaunch/window/util.cc \ - xlaunch/window/util.h \ - xlaunch/window/window.cc \ - xlaunch/window/window.h \ - xlaunch/window/wizard.cc \ - xlaunch/window/wizard.h + XWin.rc relink: $(AM_V_at)rm -f XWin$(EXEEXT) && $(MAKE) XWin$(EXEEXT) diff --git a/xorg-server/hw/xwin/winerror.c b/xorg-server/hw/xwin/winerror.c index 988c5952e..0440d13ff 100644 --- a/xorg-server/hw/xwin/winerror.c +++ b/xorg-server/hw/xwin/winerror.c @@ -1,146 +1,146 @@ -/* - *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved. - * - *Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - *"Software"), to deal in the Software without restriction, including - *without limitation the rights to use, copy, modify, merge, publish, - *distribute, sublicense, and/or sell copies of the Software, and to - *permit persons to whom the Software is furnished to do so, subject to - *the following conditions: - * - *The above copyright notice and this permission notice shall be - *included in all copies or substantial portions of the Software. - * - *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR - *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - *Except as contained in this notice, the name of Harold L Hunt II - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from Harold L Hunt II. - * - * Authors: Harold L Hunt II - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include -#endif - -#include <../xfree86/common/xorgVersion.h> -#include "win.h" - -#ifdef DDXOSVERRORF -/* Prototype */ -void -OsVendorVErrorF (const char *pszFormat, va_list va_args); - -void -OsVendorVErrorF (const char *pszFormat, va_list va_args) -{ -#if defined(XWIN_CLIPBOARD) || defined (XWIN_MULTIWINDOW) - /* make sure the clipboard and multiwindow threads do not interfere the - * main thread */ - static pthread_mutex_t s_pmPrinting = PTHREAD_MUTEX_INITIALIZER; - - /* Lock the printing mutex */ - pthread_mutex_lock (&s_pmPrinting); -#endif - - /* Print the error message to a log file, could be stderr */ - LogVWrite (0, pszFormat, va_args); - -#if defined(XWIN_CLIPBOARD) || defined (XWIN_MULTIWINDOW) - /* Unlock the printing mutex */ - pthread_mutex_unlock (&s_pmPrinting); -#endif -} -#endif - - -/* - * os/util.c/FatalError () calls our vendor ErrorF, so the message - * from a FatalError will be logged. Thus, the message for the - * fatal error is not passed to this function. - * - * Attempt to do last-ditch, safe, important cleanup here. - */ -void -OsVendorFatalError (void) -{ - /* Don't give duplicate warning if UseMsg was called */ - if (g_fSilentFatalError) - return; - - if (!g_fLogInited) { - g_fLogInited = TRUE; - g_pszLogFile = LogInit (g_pszLogFile, NULL); - } - LogClose (); - - winMessageBoxF ( - "A fatal error has occurred and " PROJECT_NAME " will now exit.\n" \ - "Please open %s for more information.\n", - MB_ICONERROR, (g_pszLogFile?g_pszLogFile:"the logfile")); -} - - -/* - * winMessageBoxF - Print a formatted error message in a useful - * message box. - */ - -void -winMessageBoxF (const char *pszError, UINT uType, ...) -{ - char * pszErrorF = NULL; - char * pszMsgBox = NULL; - va_list args; - int size; - - va_start(args, uType); - size = vasprintf (&pszErrorF, pszError, args); - va_end(args); - if (size == -1) { - pszErrorF = NULL; - goto winMessageBoxF_Cleanup; - } - -#define MESSAGEBOXF \ - "%s\n" \ - "Vendor: %s\n" \ - "Release: %d.%d.%d.%d (%d)\n" \ - "Contact: %s\n" \ - "%s\n\n" \ - "XWin was started with the following command-line:\n\n" \ - "%s\n" - - size = asprintf (&pszMsgBox, MESSAGEBOXF, - pszErrorF, XVENDORNAME, - XORG_VERSION_MAJOR, XORG_VERSION_MINOR, XORG_VERSION_PATCH, - XORG_VERSION_SNAP, XORG_VERSION_CURRENT, - BUILDERADDR, - BUILDERSTRING, - g_pszCommandLine); - - if (size == -1) { - pszMsgBox = NULL; - goto winMessageBoxF_Cleanup; - } - - /* Display the message box string */ - MessageBox (NULL, - pszMsgBox, - PROJECT_NAME, - MB_OK | uType); - - winMessageBoxF_Cleanup: - free(pszErrorF); - free(pszMsgBox); -#undef MESSAGEBOXF -} +/* + *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved. + * + *Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + *"Software"), to deal in the Software without restriction, including + *without limitation the rights to use, copy, modify, merge, publish, + *distribute, sublicense, and/or sell copies of the Software, and to + *permit persons to whom the Software is furnished to do so, subject to + *the following conditions: + * + *The above copyright notice and this permission notice shall be + *included in all copies or substantial portions of the Software. + * + *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR + *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + *Except as contained in this notice, the name of Harold L Hunt II + *shall not be used in advertising or otherwise to promote the sale, use + *or other dealings in this Software without prior written authorization + *from Harold L Hunt II. + * + * Authors: Harold L Hunt II + */ + +#ifdef HAVE_XWIN_CONFIG_H +#include +#endif + +#include <../xfree86/common/xorgVersion.h> +#include "win.h" + +#ifdef DDXOSVERRORF +/* Prototype */ +void +OsVendorVErrorF (const char *pszFormat, va_list va_args); + +void +OsVendorVErrorF (const char *pszFormat, va_list va_args) +{ +#if defined(XWIN_CLIPBOARD) || defined (XWIN_MULTIWINDOW) + /* make sure the clipboard and multiwindow threads do not interfere the + * main thread */ + static pthread_mutex_t s_pmPrinting = PTHREAD_MUTEX_INITIALIZER; + + /* Lock the printing mutex */ + pthread_mutex_lock (&s_pmPrinting); +#endif + + /* Print the error message to a log file, could be stderr */ + LogVWrite (0, pszFormat, va_args); + +#if defined(XWIN_CLIPBOARD) || defined (XWIN_MULTIWINDOW) + /* Unlock the printing mutex */ + pthread_mutex_unlock (&s_pmPrinting); +#endif +} +#endif + + +/* + * os/util.c/FatalError () calls our vendor ErrorF, so the message + * from a FatalError will be logged. Thus, the message for the + * fatal error is not passed to this function. + * + * Attempt to do last-ditch, safe, important cleanup here. + */ +void +OsVendorFatalError (void) +{ + /* Don't give duplicate warning if UseMsg was called */ + if (g_fSilentFatalError) + return; + + if (!g_fLogInited) { + g_fLogInited = TRUE; + g_pszLogFile = LogInit (g_pszLogFile, NULL); + } + LogClose (EXIT_ERR_ABORT); + + winMessageBoxF ( + "A fatal error has occurred and " PROJECT_NAME " will now exit.\n" \ + "Please open %s for more information.\n", + MB_ICONERROR, (g_pszLogFile?g_pszLogFile:"the logfile")); +} + + +/* + * winMessageBoxF - Print a formatted error message in a useful + * message box. + */ + +void +winMessageBoxF (const char *pszError, UINT uType, ...) +{ + char * pszErrorF = NULL; + char * pszMsgBox = NULL; + va_list args; + int size; + + va_start(args, uType); + size = vasprintf (&pszErrorF, pszError, args); + va_end(args); + if (size == -1) { + pszErrorF = NULL; + goto winMessageBoxF_Cleanup; + } + +#define MESSAGEBOXF \ + "%s\n" \ + "Vendor: %s\n" \ + "Release: %d.%d.%d.%d (%d)\n" \ + "Contact: %s\n" \ + "%s\n\n" \ + "XWin was started with the following command-line:\n\n" \ + "%s\n" + + size = asprintf (&pszMsgBox, MESSAGEBOXF, + pszErrorF, XVENDORNAME, + XORG_VERSION_MAJOR, XORG_VERSION_MINOR, XORG_VERSION_PATCH, + XORG_VERSION_SNAP, XORG_VERSION_CURRENT, + BUILDERADDR, + BUILDERSTRING, + g_pszCommandLine); + + if (size == -1) { + pszMsgBox = NULL; + goto winMessageBoxF_Cleanup; + } + + /* Display the message box string */ + MessageBox (NULL, + pszMsgBox, + PROJECT_NAME, + MB_OK | uType); + + winMessageBoxF_Cleanup: + free(pszErrorF); + free(pszMsgBox); +#undef MESSAGEBOXF +} diff --git a/xorg-server/hw/xwin/xlaunch/COPYING b/xorg-server/hw/xwin/xlaunch/COPYING deleted file mode 100644 index c7fa84400..000000000 --- a/xorg-server/hw/xwin/xlaunch/COPYING +++ /dev/null @@ -1,25 +0,0 @@ - - Copyright (c) 2005 Alexander Gottwald - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the "Software"), - to deal in the Software without restriction, including without limitation - the rights to use, copy, modify, merge, publish, distribute, sublicense, - and/or sell copies of the Software, and to permit persons to whom the - Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - - Except as contained in this notice, the name(s) of the above copyright - holders shall not be used in advertising or otherwise to promote the sale, - use or other dealings in this Software without prior written authorization. - diff --git a/xorg-server/hw/xwin/xlaunch/Makefile b/xorg-server/hw/xwin/xlaunch/Makefile deleted file mode 100644 index f7cf923df..000000000 --- a/xorg-server/hw/xwin/xlaunch/Makefile +++ /dev/null @@ -1,79 +0,0 @@ -# -# Copyright (c) 2005 Alexander Gottwald -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the "Software"), -# to deal in the Software without restriction, including without limitation -# the rights to use, copy, modify, merge, publish, distribute, sublicense, -# and/or sell copies of the Software, and to permit persons to whom the -# Software is furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -# THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR -# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -# DEALINGS IN THE SOFTWARE. -# -# Except as contained in this notice, the name(s) of the above copyright -# holders shall not be used in advertising or otherwise to promote the sale, -# use or other dealings in this Software without prior written authorization. -# -WINDRES=windres - -TARGET=mingw -#DEBUG_FLAGS=-D_DEBUG - -OS_FLAGS_mingw=-mno-cygwin -OS_FLAGS=$(OS_FLAGS_$(TARGET)) $(DEBUG_FLAGS) - -X11_DIR_$(TARGET)=/usr/X11R6 -X11_DIR_mingw=../../../../../exports -X11_DIR=$(X11_DIR_$(TARGET)) -X11_INCLUDE=-I$(X11_DIR)/include -X11_LIBDIR=-L$(X11_DIR)/lib -X11_LIBS_$(TARGET)=-lX11 -X11_LIBS_mingw=-lX11 -lwsock32 -X11_LIBS=$(X11_LIBS_$(TARGET)) - -PROGRAMFILES:=$(shell cygpath -u $(PROGRAMFILES)) -#MSXML_DIR=$(PROGRAMFILES)/MSXML 4.0 -MSXML_DIR=$(PROGRAMFILES)/Microsoft XML Parser SDK -MSXML_INCLUDE="-I$(MSXML_DIR)/inc" -MSXML_LIBDIR="-L$(MSXML_DIR)/lib" -MSXML_LIBS= - - -CXXFLAGS=-g $(OS_FLAGS) $(X11_INCLUDE) $(MSXML_INCLUDE) -LDFLAGS=-mwindows $(X11_LIBDIR) $(MSXML_LIBDIR) -LIBS=-lcomctl32 -lole32 -loleaut32 $(X11_LIBS) $(MSXML_LIBS) -all:xlaunch.exe -%.res: %.rc - $(WINDRES) -O coff -o $@ $< - -WINDOW_PARTS=window util dialog wizard -WINDOW_OBJECTS=$(foreach file,$(WINDOW_PARTS),window/$(file).o) - -RESOURCES_IMAGES=resources/multiwindow.bmp resources/fullscreen.bmp \ - resources/windowed.bmp resources/nodecoration.bmp - -resources/resources.res: resources/resources.rc resources/resources.h \ - resources/images.rc resources/dialog.rc resources/strings.rc \ - $(RESOURCES_IMAGES) -xlaunch.exe: $(WINDOW_OBJECTS) main.o config.o resources/resources.res - $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) - - -window/dialog.o: window/dialog.cc window/dialog.h window/window.h window/util.h -window/frame.o: window/frame.cc window/frame.h window/window.h -window/util.o: window/util.cc window/util.h -window/window.o: window/window.cc window/window.h window/util.h -window/wizard.o: window/wizard.cc window/wizard.h window/dialog.h \ - window/window.h window/util.h -main.o: main.cc window/util.h window/wizard.h window/dialog.h \ - window/window.h resources/resources.h config.h -config.o: config.cc config.h diff --git a/xorg-server/hw/xwin/xlaunch/config.cc b/xorg-server/hw/xwin/xlaunch/config.cc deleted file mode 100644 index b6bf65ae3..000000000 --- a/xorg-server/hw/xwin/xlaunch/config.cc +++ /dev/null @@ -1,282 +0,0 @@ -/* - * Copyright (c) 2005 Alexander Gottwald - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name(s) of the above copyright - * holders shall not be used in advertising or otherwise to promote the sale, - * use or other dealings in this Software without prior written authorization. - */ -#include "config.h" -#include "window/util.h" -#include -#include - -const CLSID CLSID_DOMDocument40 = {0x88d969c0,0xf192,0x11d4,0xa6,0x5f,0x00,0x40,0x96,0x32,0x51,0xe5}; -const CLSID CLSID_DOMDocument30 = {0xf5078f32,0xc551,0x11d3,0x89,0xb9,0x00,0x00,0xf8,0x1f,0xe2,0x21}; -const IID IID_IXMLDOMDocument2 = {0x2933BF95,0x7B36,0x11d2,0xB2,0x0E,0x00,0xC0,0x4F,0x98,0x3E,0x60}; - -#define HRCALL(x, msg) if (FAILED(x)) { throw std::runtime_error("OLE Error:" msg " failed"); }; - -char *wcconvert(const wchar_t *wstr) -{ - int chars = WideCharToMultiByte(CP_ACP, 0, wstr, -1, NULL, 0, NULL, NULL); - if (chars == 0) - throw win32_error("WideCharToMultiByte"); - char *mbstr = new char[chars]; - chars = WideCharToMultiByte(CP_ACP, 0, wstr, -1, mbstr, chars, NULL, NULL); - if (chars == 0) - throw win32_error("WideCharToMultiByte"); - return mbstr; -} - -wchar_t *mbconvert(const char *mbstr) -{ - int chars = MultiByteToWideChar(CP_ACP, 0, mbstr, -1, NULL, 0); - if (chars == 0) - throw win32_error("MultiByteToWideChar"); - wchar_t *wstr = new wchar_t[chars]; - chars = MultiByteToWideChar(CP_ACP, 0, mbstr, -1, wstr, chars); - if (chars == 0) - throw win32_error("MultiByteToWideChar"); - return wstr; -} - -VARIANT VariantString(const char *filename) -{ - - wchar_t *str = mbconvert(filename); - - VARIANT var; - VariantInit(&var); - V_BSTR(&var) = SysAllocString(str); - V_VT(&var) = VT_BSTR; - - delete [] str; - return var; -} - -VARIANT VariantString(const wchar_t *str) -{ - VARIANT var; - VariantInit(&var); - V_BSTR(&var) = SysAllocString(str); - V_VT(&var) = VT_BSTR; - return var; -} - -IXMLDOMDocument2 *CreateDocument() -{ - IXMLDOMDocument2 *doc = NULL; - - CoInitialize(NULL); - - HRCALL(CoCreateInstance(CLSID_DOMDocument40, NULL, CLSCTX_INPROC_SERVER, - IID_IXMLDOMDocument2, (void**)&doc), "CoCreateInstance"); - - try { - HRCALL(doc->put_async(VARIANT_FALSE), "put_async"); - HRCALL(doc->put_validateOnParse(VARIANT_FALSE), "put_validateOnParse"); - HRCALL(doc->put_resolveExternals(VARIANT_FALSE), "put_resolveExternals"); - - IXMLDOMProcessingInstruction *pi = NULL; - IXMLDOMElement *root = NULL; - BSTR xml = SysAllocString(L"xml"); - BSTR ver = SysAllocString(L"version='1.0'"); - HRCALL(doc->createProcessingInstruction(xml,ver, &pi), - "createProcessingInstruction"); - HRCALL(doc->appendChild(pi, NULL), - "appendChild"); - pi->Release(); - SysFreeString(xml); - SysFreeString(ver); - - BSTR elemname = SysAllocString(L"XLaunch"); - HRCALL(doc->createElement(elemname, &root), "createElement"); - HRCALL(doc->appendChild(root, NULL), "appendChild"); - SysFreeString(elemname); - } catch (...) - { - doc->Release(); - throw; - } - return doc; -} - -void setAttribute(IXMLDOMElement *elem, const wchar_t *name, const wchar_t *value) -{ - BSTR str = SysAllocString(name); - VARIANT var = VariantString(value); - HRCALL(elem->setAttribute(str, var), "setAttribute"); - VariantClear(&var); - SysFreeString(str); -} - -void setAttribute(IXMLDOMElement *elem, const wchar_t *name, const char *value) -{ - wchar_t *wstr = mbconvert(value); - setAttribute(elem, name, wstr); - delete [] wstr; - return; -} - -void CConfig::Save(const char *filename) -{ - IXMLDOMDocument2 *doc = CreateDocument(); - IXMLDOMElement *root = NULL; - - HRCALL(doc->get_documentElement(&root), "get_documentElement"); - - switch (window) - { - case MultiWindow: - setAttribute(root, L"WindowMode", L"MultiWindow"); - break; - case Fullscreen: - setAttribute(root, L"WindowMode", L"Fullscreen"); - break; - default: - case Windowed: - setAttribute(root, L"WindowMode", L"Windowed"); - break; - case Nodecoration: - setAttribute(root, L"WindowMode", L"Nodecoration"); - break; - } - switch (client) - { - default: - case NoClient: - setAttribute(root, L"ClientMode", L"NoClient"); - break; - case StartProgram: - setAttribute(root, L"ClientMode", L"StartProgram"); - break; - case XDMCP: - setAttribute(root, L"ClientMode", L"XDMCP"); - break; - } - setAttribute(root, L"LocalClient", local?L"True":L"False"); - setAttribute(root, L"Display", display.c_str()); - setAttribute(root, L"Program", program.c_str()); - setAttribute(root, L"RemoteProtocol", protocol.c_str()); - setAttribute(root, L"RemoteHost", host.c_str()); - setAttribute(root, L"RemoteUser", user.c_str()); - setAttribute(root, L"XDMCPHost", xdmcp_host.c_str()); - setAttribute(root, L"XDMCPBroadcast", broadcast?L"True":L"False"); - setAttribute(root, L"XDMCPIndirect", indirect?L"True":L"False"); - setAttribute(root, L"Clipboard", clipboard?L"True":L"False"); - setAttribute(root, L"ExtraParams", extra_params.c_str()); - - VARIANT var = VariantString(filename); - HRCALL(doc->save(var), "save"); - VariantClear(&var); - - - root->Release(); - doc->Release(); -} - -BOOL getAttribute(IXMLDOMElement *elem, const wchar_t *name, std::string &ret) -{ - VARIANT var; - HRCALL(elem->getAttribute((OLECHAR*)name, &var), "getAttribute"); - if (V_VT(&var) != VT_NULL && V_VT(&var) == VT_BSTR) - { - char *str = wcconvert(V_BSTR(&var)); - ret = str; - delete [] str; - return true; - } - return false; -} - -BOOL getAttributeBool(IXMLDOMElement *elem, const wchar_t *name, bool &ret) -{ - std::string str; - if (getAttribute(elem, name, str)) - { - if (str == "True") - ret = true; - else - ret = false; - return true; - } - return false; -} - - -void CConfig::Load(const char *filename) -{ - IXMLDOMDocument2 *doc = CreateDocument(); - IXMLDOMElement *root = NULL; - - VARIANT var = VariantString(filename); - VARIANT_BOOL status; - HRCALL(doc->load(var, &status), "load"); - VariantClear(&var); - - if (status == VARIANT_FALSE) - { - doc->Release(); - return; - } - - HRCALL(doc->get_documentElement(&root), "get_documentElement"); - - std::string windowMode; - std::string clientMode; - - if (getAttribute(root, L"WindowMode", windowMode)) - { - if (windowMode == "MultiWindow") - window = MultiWindow; - else if (windowMode == "Fullscreen") - window = Fullscreen; - else if (windowMode == "Windowed") - window = Windowed; - else if (windowMode == "Nodecoration") - window = Nodecoration; - } - if (getAttribute(root, L"ClientMode", clientMode)) - { - if (clientMode == "NoClient") - client = NoClient; - else if (clientMode == "StartProgram") - client = StartProgram; - else if (clientMode == "XDMCP") - client = XDMCP; - } - - getAttributeBool(root, L"LocalClient", local); - getAttribute(root, L"Display", display); - getAttribute(root, L"Program", program); - getAttribute(root, L"RemoteProtocol", protocol); - getAttribute(root, L"RemoteHost", host); - getAttribute(root, L"RemoteUser", user); - getAttribute(root, L"XDMCPHost", xdmcp_host); - getAttributeBool(root, L"XDMCPBroadcast", broadcast); - getAttributeBool(root, L"XDMCPIndirect", indirect); - getAttributeBool(root, L"Clipboard", clipboard); - getAttribute(root, L"ExtraParams", extra_params); - - - doc->Release(); -} - diff --git a/xorg-server/hw/xwin/xlaunch/config.h b/xorg-server/hw/xwin/xlaunch/config.h deleted file mode 100644 index f0aed3cf1..000000000 --- a/xorg-server/hw/xwin/xlaunch/config.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2005 Alexander Gottwald - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name(s) of the above copyright - * holders shall not be used in advertising or otherwise to promote the sale, - * use or other dealings in this Software without prior written authorization. - */ -#ifndef __CONFIG_H__ -#define __CONFIG_H__ - -#include -struct CConfig -{ - enum {MultiWindow, Fullscreen, Windowed, Nodecoration} window; - enum {NoClient, StartProgram, XDMCP} client; - bool local; - std::string display; - std::string protocol; - std::string program; - std::string host; - std::string user; - bool broadcast; - bool indirect; - std::string xdmcp_host; - bool clipboard; - std::string extra_params; -#ifdef _DEBUG - CConfig() : window(MultiWindow), client(StartProgram), local(false), display("1"), - protocol("Putty"), program("xterm"), host("lupus"), user("ago"), - broadcast(false), indirect(false), xdmcp_host("lupus"), - clipboard(true), extra_params() {}; -#else - CConfig() : window(MultiWindow), client(StartProgram), local(false), display("0"), - protocol("Putty"), program("xterm"), host(""), user(""), - broadcast(true), indirect(false), xdmcp_host(""), - clipboard(true), extra_params() {}; -#endif - void Load(const char* filename); - void Save(const char* filename); -}; - -#endif diff --git a/xorg-server/hw/xwin/xlaunch/main.cc b/xorg-server/hw/xwin/xlaunch/main.cc deleted file mode 100644 index 2247d3aaf..000000000 --- a/xorg-server/hw/xwin/xlaunch/main.cc +++ /dev/null @@ -1,700 +0,0 @@ -/* - * Copyright (c) 2005 Alexander Gottwald - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name(s) of the above copyright - * holders shall not be used in advertising or otherwise to promote the sale, - * use or other dealings in this Software without prior written authorization. - */ -#include "window/util.h" -#include "window/wizard.h" -#include "resources/resources.h" -#include "config.h" -#include -#include - -#include - -#include - -/// @brief Send WM_ENDSESSION to all program windows. -/// This will shutdown the started xserver -BOOL CALLBACK KillWindowsProc(HWND hwnd, LPARAM lParam) -{ - SendMessage(hwnd, WM_ENDSESSION, 0, 0); - return TRUE; -} - -/// @brief Actual wizard implementation. -/// This is based on generic CWizard but handles the special dialogs -class CMyWizard : public CWizard -{ - public: - private: - CConfig config; /// Storage for config options. - public: - /// @brief Constructor. - /// Set wizard pages. - CMyWizard() : CWizard() - { - AddPage(IDD_DISPLAY, IDS_DISPLAY_TITLE, IDS_DISPLAY_SUBTITLE); - AddPage(IDD_CLIENTS, IDS_CLIENTS_TITLE, IDS_CLIENTS_SUBTITLE); - AddPage(IDD_PROGRAM, IDS_PROGRAM_TITLE, IDS_PROGRAM_SUBTITLE); - AddPage(IDD_XDMCP, IDS_XDMCP_TITLE, IDS_XDMCP_SUBTITLE); - //AddPage(IDD_FONTPATH, IDS_FONTPATH_TITLE, IDS_FONTPATH_SUBTITLE); - AddPage(IDD_CLIPBOARD, IDS_CLIPBOARD_TITLE, IDS_CLIPBOARD_SUBTITLE); - AddPage(IDD_FINISH, IDS_FINISH_TITLE, IDS_FINISH_SUBTITLE); - } - - virtual void LoadConfig(const char *filename) - { - try { - config.Load(filename); - } catch (std::runtime_error &e) - { - printf("Fehler: %s\n", e.what()); - } - } - - /// @brief Handle the PSN_WIZNEXT message. - /// @param hwndDlg Handle to active page dialog. - /// @param index Index of current page. - /// @return TRUE if the message was handled. FALSE otherwise. - virtual BOOL WizardNext(HWND hwndDlg, unsigned index) - { -#ifdef _DEBUG - printf("%s %d\n", __FUNCTION__, index); -#endif - switch (PageID(index)) - { - case IDD_DISPLAY: - // Check for select window mode - if (IsDlgButtonChecked(hwndDlg, IDC_MULTIWINDOW)) - config.window = CConfig::MultiWindow; - else if (IsDlgButtonChecked(hwndDlg, IDC_FULLSCREEN)) - config.window = CConfig::Fullscreen; - else if (IsDlgButtonChecked(hwndDlg, IDC_WINDOWED)) - config.window = CConfig::Windowed; - else if (IsDlgButtonChecked(hwndDlg, IDC_NODECORATION)) - config.window = CConfig::Nodecoration; - else - { - SetWindowLong(hwndDlg, DWL_MSGRESULT, -1); - return TRUE; - } - // Get selected display number - { - char buffer[512]; - GetDlgItemText(hwndDlg, IDC_DISPLAY, buffer, 512); - buffer[511] = 0; - config.display = buffer; - } - // Check for valid input - if (config.display.empty()) - SetWindowLong(hwndDlg, DWL_MSGRESULT, -1); - else - SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_CLIENTS); - return TRUE; - case IDD_CLIENTS: - // Check for select client startup method - if (IsDlgButtonChecked(hwndDlg, IDC_CLIENT)) - { - config.client = CConfig::StartProgram; - SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_PROGRAM); - } else if (IsDlgButtonChecked(hwndDlg, IDC_XDMCP)) - { - config.client = CConfig::XDMCP; - SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_XDMCP); - } else if (IsDlgButtonChecked(hwndDlg, IDC_CLIENT_NONE)) - { - config.client = CConfig::NoClient; - SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_CLIPBOARD); - } else - SetWindowLong(hwndDlg, DWL_MSGRESULT, -1); - return TRUE; - case IDD_PROGRAM: - // Check wether local or remote client should be started - if (IsDlgButtonChecked(hwndDlg, IDC_CLIENT_LOCAL)) - config.local = true; - else if (IsDlgButtonChecked(hwndDlg, IDC_CLIENT_REMOTE)) - config.local = false; - else - { - SetWindowLong(hwndDlg, DWL_MSGRESULT, -1); - return TRUE; - } - // Read program, user and host name - { - char buffer[512]; - GetDlgItemText(hwndDlg, IDC_CLIENT_USER, buffer, 512); - buffer[511] = 0; - config.user = buffer; - GetDlgItemText(hwndDlg, IDC_CLIENT_HOST, buffer, 512); - buffer[511] = 0; - config.host = buffer; - GetDlgItemText(hwndDlg, IDC_CLIENT_PROGRAM, buffer, 512); - buffer[511] = 0; - config.program = buffer; - } - // Check for valid input - if (!config.local && (config.host.empty() || config.program.empty())) - SetWindowLong(hwndDlg, DWL_MSGRESULT, -1); - else - SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_CLIPBOARD); - return TRUE; - case IDD_XDMCP: - // Check for broadcast - if (IsDlgButtonChecked(hwndDlg, IDC_XDMCP_BROADCAST)) - config.broadcast = true; - else if (IsDlgButtonChecked(hwndDlg, IDC_XDMCP_QUERY)) - config.broadcast = false; - else - { - SetWindowLong(hwndDlg, DWL_MSGRESULT, -1); - return TRUE; - } - // Check for indirect mode - if (IsDlgButtonChecked(hwndDlg, IDC_XDMCP_INDIRECT)) - config.indirect = true; - else - config.indirect = false; - // Read hostname - { - char buffer[512]; - GetDlgItemText(hwndDlg, IDC_XDMCP_HOST, buffer, 512); - buffer[511] = 0; - config.xdmcp_host = buffer; - } - // Check for valid input - if (!config.broadcast && config.xdmcp_host.empty()) - SetWindowLong(hwndDlg, DWL_MSGRESULT, -1); - else - SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_CLIPBOARD); - return TRUE; - case IDD_CLIPBOARD: - // check for clipboard - if (IsDlgButtonChecked(hwndDlg, IDC_CLIPBOARD)) - config.clipboard = true; - else - config.clipboard = false; - // read parameters - { - char buffer[512]; - GetDlgItemText(hwndDlg, IDC_EXTRA_PARAMS, buffer, 512); - buffer[511] = 0; - config.extra_params = buffer; - } - SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_FINISH); - return TRUE; - default: - break; - } - return FALSE; - } - /// @brief Handle PSN_WIZFINISH message. - /// @param hwndDlg Handle to active page dialog. - /// @param index Index of current page. - /// @return TRUE if the message was handled. FALSE otherwise. - virtual BOOL WizardFinish(HWND hwndDlg, unsigned index) - { -#ifdef _DEBUG - printf("finish %d\n", index); -#endif - return FALSE; - } - /// @brief Handle PSN_WIZBACK message. - /// Basicly handles switching to proper page (skipping XDMCP or program page - /// if required). - /// @param hwndDlg Handle to active page dialog. - /// @param index Index of current page. - /// @return TRUE if the message was handled. FALSE otherwise. - virtual BOOL WizardBack(HWND hwndDlg, unsigned index) - { - switch (PageID(index)) - { - case IDD_PROGRAM: - case IDD_XDMCP: - SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_CLIENTS); - return TRUE; - case IDD_FONTPATH: - case IDD_CLIPBOARD: // temporary. fontpath is disabled - switch (config.client) - { - case CConfig::NoClient: - SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_CLIENTS); - return TRUE; - case CConfig::StartProgram: - SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_PROGRAM); - return TRUE; - case CConfig::XDMCP: - SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_XDMCP); - return TRUE; - } - break; - } - return FALSE; - } - /// @brief Handle PSN_SETACTIVE message. - /// @param hwndDlg Handle to active page dialog. - /// @param index Index of current page. - /// @return TRUE if the message was handled. FALSE otherwise. - virtual BOOL WizardActivate(HWND hwndDlg, unsigned index) - { -#ifdef _DEBUG - printf("%s %d\n", __FUNCTION__, index); -#endif - switch (PageID(index)) - { - case IDD_CLIENTS: - // Enable or disable XDMCP radiobutton and text - EnableWindow(GetDlgItem(hwndDlg, IDC_XDMCP), config.window != CConfig::MultiWindow); - EnableWindow(GetDlgItem(hwndDlg, IDC_XDMCP_DESC), config.window != CConfig::MultiWindow); - break; - } - return FALSE; - } - protected: - /// @brief Enable or disable the control for remote clients. - /// @param hwndDlg Handle to active page dialog. - /// @param state State of control group. - void EnableRemoteProgramGroup(HWND hwndDlg, BOOL state) - { - EnableWindow(GetDlgItem(hwndDlg, IDC_CLIENT_PROTOCOL), state); - EnableWindow(GetDlgItem(hwndDlg, IDC_CLIENT_HOST), state); - EnableWindow(GetDlgItem(hwndDlg, IDC_CLIENT_USER), state); - EnableWindow(GetDlgItem(hwndDlg, IDC_CLIENT_PROTOCOL_DESC), state); - EnableWindow(GetDlgItem(hwndDlg, IDC_CLIENT_HOST_DESC), state); - EnableWindow(GetDlgItem(hwndDlg, IDC_CLIENT_USER_DESC), state); - } - /// @brief Enable or disable the control for XDMCP connection. - /// @param hwndDlg Handle to active page dialog. - /// @param state State of control group. - void EnableXDMCPQueryGroup(HWND hwndDlg, BOOL state) - { - EnableWindow(GetDlgItem(hwndDlg, IDC_XDMCP_HOST), state); - EnableWindow(GetDlgItem(hwndDlg, IDC_XDMCP_INDIRECT), state); - } - /// @brief Fill program box with default values. - /// @param hwndDlg Handle to active page dialog. - void FillProgramBox(HWND hwndDlg) - { - HWND cbwnd = GetDlgItem(hwndDlg, IDC_CLIENT_PROGRAM); - if (cbwnd == NULL) - return; - SendMessage(cbwnd, CB_RESETCONTENT, 0, 0); - SendMessage(cbwnd, CB_ADDSTRING, 0, (LPARAM) "xterm"); - SendMessage(cbwnd, CB_ADDSTRING, 0, (LPARAM) "startkde"); - SendMessage(cbwnd, CB_ADDSTRING, 0, (LPARAM) "gnome-session"); - SendMessage(cbwnd, CB_ADDSTRING, 0, (LPARAM) ".xinitrc"); - SendMessage(cbwnd, CB_ADDSTRING, 0, (LPARAM) "wmaker"); - SendMessage(cbwnd, CB_SETCURSEL, 0, 0); - } - /// @brief Fill protocol box with default values. - /// @param hwndDlg Handle to active page dialog. - void FillProtocolBox(HWND hwndDlg) - { - HWND cbwnd = GetDlgItem(hwndDlg, IDC_CLIENT_PROTOCOL); - if (cbwnd == NULL) - return; - SendMessage(cbwnd, CB_RESETCONTENT, 0, 0); - SendMessage(cbwnd, CB_ADDSTRING, 0, (LPARAM) "Putty"); - //SendMessage(cbwnd, CB_ADDSTRING, 0, (LPARAM) "OpenSSH"); - SendMessage(cbwnd, CB_SETCURSEL, 0, 0); - } - void ShowSaveDialog(HWND parent) - { - char szTitle[512]; - char szFilter[512]; - char szFileTitle[512]; - char szFile[MAX_PATH]; - HINSTANCE hInst = GetModuleHandle(NULL); - - LoadString(hInst, IDS_SAVE_TITLE, szTitle, sizeof(szTitle)); - LoadString(hInst, IDS_SAVE_FILETITLE, szFileTitle, sizeof(szFileTitle)); - LoadString(hInst, IDS_SAVE_FILTER, szFilter, sizeof(szFilter)); - for (unsigned i=0; szFilter[i]; i++) - if (szFilter[i] == '%') - szFilter[i] = '\0'; - - strcpy(szFile, "config.xlaunch"); - - OPENFILENAME ofn; - memset(&ofn, 0, sizeof(OPENFILENAME)); - ofn.lStructSize = sizeof(OPENFILENAME); - ofn.hwndOwner = parent; - ofn.lpstrFilter = szFilter; - ofn.lpstrFile= szFile; - ofn.nMaxFile = sizeof(szFile)/ sizeof(*szFile); - ofn.lpstrFileTitle = szFileTitle; - ofn.nMaxFileTitle = sizeof(szFileTitle); - ofn.lpstrInitialDir = (LPSTR)NULL; - ofn.Flags = OFN_SHOWHELP | OFN_OVERWRITEPROMPT; - ofn.lpstrTitle = szTitle; - - if (GetSaveFileName(&ofn)) - { - try { - config.Save(ofn.lpstrFile); - } catch (std::runtime_error &e) - { - printf("Fehler: %s\n", e.what()); - } - } - } - public: - - /// @brief Handle messages fo the dialog pages. - /// @param hwndDlg Handle of active dialog. - /// @param uMsg Message code. - /// @param wParam Message parameter. - /// @param lParam Message parameter. - /// @param psp Handle to sheet paramters. - virtual INT_PTR PageDispatch(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam, PROPSHEETPAGE *psp) - { - HWND hwnd; - switch (uMsg) - { - case WM_INITDIALOG: - switch (PageID(PageIndex(psp))) - { - case IDD_DISPLAY: - // Init display dialog. Enable correct check buttons - switch (config.window) - { - default: - case CConfig::MultiWindow: - CheckRadioButton(hwndDlg, IDC_MULTIWINDOW, IDC_NODECORATION, IDC_MULTIWINDOW); - break; - case CConfig::Fullscreen: - CheckRadioButton(hwndDlg, IDC_MULTIWINDOW, IDC_NODECORATION, IDC_FULLSCREEN); - break; - case CConfig::Windowed: - CheckRadioButton(hwndDlg, IDC_MULTIWINDOW, IDC_NODECORATION, IDC_WINDOWED); - break; - case CConfig::Nodecoration: - CheckRadioButton(hwndDlg, IDC_MULTIWINDOW, IDC_NODECORATION, IDC_NODECORATION); - break; - } - // Set display number - SetDlgItemText(hwndDlg, IDC_DISPLAY, config.display.c_str()); - break; - case IDD_CLIENTS: - // Init client dialog. Enable correct check buttons - switch (config.client) - { - default: - case CConfig::NoClient: - CheckRadioButton(hwndDlg, IDC_CLIENT_NONE, IDC_CLIENT, IDC_CLIENT_NONE); - break; - case CConfig::StartProgram: - CheckRadioButton(hwndDlg, IDC_CLIENT_NONE, IDC_CLIENT, IDC_CLIENT); - break; - case CConfig::XDMCP: - CheckRadioButton(hwndDlg, IDC_CLIENT_NONE, IDC_CLIENT, IDC_XDMCP); - break; - } - break; - case IDD_PROGRAM: - // Init program dialog. Check local and remote buttons - CheckRadioButton(hwndDlg, IDC_CLIENT_LOCAL, IDC_CLIENT_REMOTE, config.local?IDC_CLIENT_LOCAL:IDC_CLIENT_REMOTE); - EnableRemoteProgramGroup(hwndDlg, config.local?FALSE:TRUE); - // Fill combo boxes - FillProgramBox(hwndDlg); - FillProtocolBox(hwndDlg); - // Set edit fields - if (!config.program.empty()) - SetDlgItemText(hwndDlg, IDC_CLIENT_PROGRAM, config.program.c_str()); - SetDlgItemText(hwndDlg, IDC_CLIENT_USER, config.user.c_str()); - SetDlgItemText(hwndDlg, IDC_CLIENT_HOST, config.host.c_str()); - break; - case IDD_XDMCP: - // Init XDMCP dialog. Check broadcast and indirect button - CheckRadioButton(hwndDlg, IDC_XDMCP_QUERY, IDC_XDMCP_BROADCAST, config.broadcast?IDC_XDMCP_BROADCAST:IDC_XDMCP_QUERY); - CheckDlgButton(hwndDlg, IDC_XDMCP_INDIRECT, config.indirect?BST_CHECKED:BST_UNCHECKED); - EnableXDMCPQueryGroup(hwndDlg, config.broadcast?FALSE:TRUE); - // Set hostname - SetDlgItemText(hwndDlg, IDC_XDMCP_HOST, config.xdmcp_host.c_str()); - break; - case IDD_CLIPBOARD: - CheckDlgButton(hwndDlg, IDC_CLIPBOARD, config.clipboard?BST_CHECKED:BST_UNCHECKED); - SetDlgItemText(hwndDlg, IDC_EXTRA_PARAMS, config.extra_params.c_str()); - break; - - } - case WM_COMMAND: - // Handle control messages - switch (LOWORD(wParam)) - { - // Handle clicks on images. Check proper radiobutton - case IDC_MULTIWINDOW_IMG: - case IDC_FULLSCREEN_IMG: - case IDC_WINDOWED_IMG: - case IDC_NODECORATION_IMG: - CheckRadioButton(hwndDlg, IDC_MULTIWINDOW, IDC_NODECORATION, LOWORD(wParam)-4); - SetFocus(GetDlgItem(hwndDlg, LOWORD(wParam)-4)); - break; - // Disable unavailable controls - case IDC_CLIENT_REMOTE: - case IDC_CLIENT_LOCAL: - EnableRemoteProgramGroup(hwndDlg, LOWORD(wParam) == IDC_CLIENT_REMOTE); - break; - case IDC_XDMCP_QUERY: - case IDC_XDMCP_BROADCAST: - EnableXDMCPQueryGroup(hwndDlg, LOWORD(wParam) == IDC_XDMCP_QUERY); - break; - case IDC_FINISH_SAVE: - ShowSaveDialog(hwndDlg); - break; - } - } - // pass messages to parent - return CWizard::PageDispatch(hwndDlg, uMsg, wParam, lParam, psp); - } - - /// @brief Try to connect to server. - /// Repeat until successful, server died or maximum number of retries - /// reached. - Display *WaitForServer(HANDLE serverProcess) - { - int ncycles = 120; /* # of cycles to wait */ - int cycles; /* Wait cycle count */ - Display *xd; - - for (cycles = 0; cycles < ncycles; cycles++) { - if ((xd = XOpenDisplay(NULL))) { - return xd; - } - else { - if (WaitForSingleObject(serverProcess, 1000) == WAIT_TIMEOUT) - continue; - } - } - return NULL; - } - - /// @brief Do the actual start of Xming and clients - void StartUp() - { - std::string buffer; - std::string client; - - // Construct display strings - std::string display_id = ":" + config.display; - std::string display = "localhost" + display_id + ":0"; - -#ifdef _DEBUG - // Debug only: Switch to Xming installation directory - SetCurrentDirectory("C:\\Programme\\Xming"); -#endif - - // Build Xming commandline - buffer = "Xming " + display_id + " "; - switch (config.window) - { - case CConfig::MultiWindow: - buffer += "-multiwindow "; - break; - case CConfig::Fullscreen: - buffer += "-fullscreen "; - break; - case CConfig::Nodecoration: - buffer += "-nodecoration "; - break; - default: - break; - } - // Add XDMCP parameter - if (config.client == CConfig::XDMCP) - { - if (config.broadcast) - buffer += "-broadcast "; - else - { - if (config.indirect) - buffer += "-indirect "; - else - buffer += "-query "; - buffer += config.xdmcp_host; - buffer += " "; - } - } - if (config.clipboard) - buffer += "-clipboard "; - if (!config.extra_params.empty()) - { - buffer += config.extra_params; - buffer += " "; - } - - // Construct client commandline - if (config.client == CConfig::StartProgram) - { - if (!config.local) - { - char cmdline[512]; - std::string host = config.host; - if (!config.user.empty()) - host = config.user + "@" + config.host; - if (config.protocol == "Putty") - snprintf(cmdline,512,"plink -X %s %s", - host.c_str(),config.program.c_str()); - else - snprintf(cmdline,512,"ssh -Y %s %s", - host.c_str(),config.program.c_str()); - client += cmdline; - } else - client += config.program.c_str(); - } - - // Prepare program startup - STARTUPINFO si, sic; - PROCESS_INFORMATION pi, pic; - HANDLE handles[2]; - DWORD hcount = 0; - Display *dpy = NULL; - - ZeroMemory( &si, sizeof(si) ); - si.cb = sizeof(si); - ZeroMemory( &pi, sizeof(pi) ); - ZeroMemory( &sic, sizeof(sic) ); - sic.cb = sizeof(sic); - ZeroMemory( &pic, sizeof(pic) ); - - // Start Xming process. -#ifdef _DEBUG - printf("%s\n", buffer.c_str()); -#endif - if( !CreateProcess( NULL, (CHAR*)buffer.c_str(), NULL, NULL, - FALSE, 0, NULL, NULL, &si, &pi )) - throw win32_error("CreateProcess failed"); - handles[hcount++] = pi.hProcess; - - if (!client.empty()) - { - // Set DISPLAY variable - SetEnvironmentVariable("DISPLAY",display.c_str()); - - // Wait for server to startup - dpy = WaitForServer(pi.hProcess); - if (dpy == NULL) - { - while (hcount--) - TerminateProcess(handles[hcount], (DWORD)-1); - throw std::runtime_error("Connection to server failed"); - } - -#ifdef _DEBUG - printf("%s\n", client.c_str()); -#endif - - // Hide a console window - // FIXME: This may make it impossible to enter the password - sic.dwFlags = STARTF_USESHOWWINDOW; - sic.wShowWindow = SW_HIDE; - - // Start the child process. - if( !CreateProcess( NULL, (CHAR*)client.c_str(), NULL, NULL, - FALSE, 0, NULL, NULL, &sic, &pic )) - { - DWORD err = GetLastError(); - while (hcount--) - TerminateProcess(handles[hcount], (DWORD)-1); - throw win32_error("CreateProcess failed", err); - } - handles[hcount++] = pic.hProcess; - } - - // Wait until any child process exits. - DWORD ret = WaitForMultipleObjects(hcount, handles, FALSE, INFINITE ); - -#ifdef _DEBUG - printf("killing process!\n"); -#endif - // Check if Xming is still running - DWORD exitcode; - GetExitCodeProcess(pi.hProcess, &exitcode); - unsigned counter = 0; - while (exitcode == STILL_ACTIVE) - { - if (++counter > 10) - TerminateProcess(pi.hProcess, (DWORD)-1); - else - // Shutdown Xming (the soft way!) - EnumThreadWindows(pi.dwThreadId, KillWindowsProc, 0); - Sleep(500); - GetExitCodeProcess(pi.hProcess, &exitcode); - } - // Kill the client - TerminateProcess(pic.hProcess, (DWORD)-1); - - // Close process and thread handles. - CloseHandle( pi.hProcess ); - CloseHandle( pi.hThread ); - CloseHandle( pic.hProcess ); - CloseHandle( pic.hThread ); - } -}; - -int main(int argc, char **argv) -{ - try { - InitCommonControls(); - CMyWizard dialog; - - bool skip_wizard = false; - - for (int i = 1; i < argc; i++) - { - if (argv[i] == NULL) - continue; - - std::string arg(argv[i]); - if (arg == "-load" && i + 1 < argc) - { - i++; - dialog.LoadConfig(argv[i]); - continue; - } - if (arg == "-run" && i + 1 < argc) - { - i++; - dialog.LoadConfig(argv[i]); - skip_wizard = true; - continue; - } - } - - int ret = 0; - if (skip_wizard || (ret =dialog.ShowModal()) != 0) - dialog.StartUp(); -#ifdef _DEBUG - printf("return %d\n", ret); -#endif - return 0; - } catch (std::runtime_error &e) - { - printf("Fehler: %s\n", e.what()); - return -1; - } -} - - - - diff --git a/xorg-server/hw/xwin/xlaunch/resources/dialog.rc b/xorg-server/hw/xwin/xlaunch/resources/dialog.rc deleted file mode 100644 index 8b00df4ef..000000000 --- a/xorg-server/hw/xwin/xlaunch/resources/dialog.rc +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2005 Alexander Gottwald - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name(s) of the above copyright - * holders shall not be used in advertising or otherwise to promote the sale, - * use or other dealings in this Software without prior written authorization. - */ -#include -#include "resources.h" - -#ifndef STR_CAPTION_DISPLAY -#include "strings.rc" -#endif - -IDD_DISPLAY DIALOGEX 0, 0, 317, 143 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_CENTERMOUSE -CAPTION STR_CAPTION_DISPLAY -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - AUTORADIOBUTTON STR_MULTIWINDOW,IDC_MULTIWINDOW,7,25,70,24,BS_MULTILINE|BS_TOP - AUTORADIOBUTTON STR_FULLSCREEN,IDC_FULLSCREEN,157,25,70,24,BS_MULTILINE|BS_TOP - AUTORADIOBUTTON STR_WINDOWED,IDC_WINDOWED,7,75,70,24,BS_MULTILINE|BS_TOP - AUTORADIOBUTTON STR_NODECORATION,IDC_NODECORATION,157,75,70,24,BS_MULTILINE|BS_TOP - - CONTROL "IMG_MULTIWINDOW",IDC_MULTIWINDOW_IMG,"Static",SS_BITMAP | SS_NOTIFY,80,10,0,0 - CONTROL "IMG_FULLSCREEN",IDC_FULLSCREEN_IMG,"Static",SS_BITMAP | SS_NOTIFY,230,10,0,0 - CONTROL "IMG_WINDOWED",IDC_WINDOWED_IMG,"Static",SS_BITMAP | SS_NOTIFY,80,60,0,0 - CONTROL "IMG_NODECORATION",IDC_NODECORATION_IMG,"Static",SS_BITMAP | SS_NOTIFY,230,60,0,0 - - LTEXT STR_DISPLAY_DESC,IDC_DISPLAY_DESC,7,120,64,12 - EDITTEXT IDC_DISPLAY,80,118,67,12,ES_NUMBER -END - -IDD_CLIENTS DIALOGEX 0, 0, 317, 143 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_CENTERMOUSE -CAPTION STR_CAPTION_CLIENTS -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - AUTORADIOBUTTON STR_CLIENT_NONE,IDC_CLIENT_NONE,7,14,300,10 - AUTORADIOBUTTON STR_CLIENT,IDC_CLIENT,7,56,300,10 - AUTORADIOBUTTON STR_XDMCP,IDC_XDMCP,7,98,300,10 - - LTEXT STR_CLIENT_NONE_DESC,IDC_CLIENT_NONE_DESC,19,28,280,27 - LTEXT STR_CLIENT_DESC,IDC_CLIENT_DESC,19,70,280,27 - LTEXT STR_XDMCP_DESC,IDC_XDMCP_DESC,19,112,280,27 -END - -IDD_PROGRAM DIALOGEX 0, 0, 317, 143 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_CENTERMOUSE -CAPTION STR_CAPTION_PROGRAM -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - LTEXT STR_CLIENT_PROGRAM_DESC,IDC_CLIENT_PROGRAM_DESC,7,14,64,10 - COMBOBOX IDC_CLIENT_PROGRAM,70,12,64,54,CBS_DROPDOWN | WS_VSCROLL - - AUTORADIOBUTTON STR_CLIENT_LOCAL,IDC_CLIENT_LOCAL,7,28,300,10 - AUTORADIOBUTTON STR_CLIENT_REMOTE,IDC_CLIENT_REMOTE,7,42,300,10 - - LTEXT STR_CLIENT_PROTOCOL_DESC,IDC_CLIENT_PROTOCOL_DESC,19,56,70,10 - COMBOBOX IDC_CLIENT_PROTOCOL,100,54,64,54,CBS_DROPDOWNLIST | WS_VSCROLL - - LTEXT STR_CLIENT_HOST_DESC,IDC_CLIENT_HOST_DESC,19,70,70,10 - LTEXT STR_CLIENT_USER_DESC,IDC_CLIENT_USER_DESC,19,84,70,10 - EDITTEXT IDC_CLIENT_HOST,100,68,64,12 - EDITTEXT IDC_CLIENT_USER,100,82,64,12 -END - -IDD_XDMCP DIALOGEX 0, 0, 317, 143 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_CENTERMOUSE -CAPTION STR_CAPTION_XDMCP -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - AUTORADIOBUTTON STR_XDMCP_QUERY, IDC_XDMCP_QUERY,7,14,64,10 - EDITTEXT IDC_XDMCP_HOST,78,12,64,12 - AUTOCHECKBOX STR_XDMCP_INDIRECT,IDC_XDMCP_INDIRECT,19,28,280,10 - AUTORADIOBUTTON STR_XDMCP_BROADCAST, IDC_XDMCP_BROADCAST,7,42,300,10 - LTEXT STR_XDMCP_QUERY_DESC,IDC_XDMCP_QUERY_DESC,7,56,300,42 -END - -IDD_CLIPBOARD DIALOGEX 0, 0, 317, 143 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_CENTERMOUSE -CAPTION STR_CAPTION_CLIPBOARD -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - AUTOCHECKBOX STR_CLIPBOARD,IDC_CLIPBOARD,7,14,300,10 - LTEXT STR_CLIPBOARD_DESC,IDC_CLIPBOARD_DESC,19,28,280,27 - - LTEXT STR_EXTRA_PARAMS_DESC,IDC_EXTRA_PARAMS_DESC,7,56,280,10 - EDITTEXT IDC_EXTRA_PARAMS,7,70,128,12 -END - -IDD_FINISH DIALOGEX 0, 0, 317, 143 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_CENTERMOUSE -CAPTION STR_CAPTION_FINISH -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - LTEXT STR_FINISH_DESC,IDC_FINISH_DESC,7,14,300,28 - LTEXT STR_FINISH_SAVE_DESC,IDC_FINISH_SAVE_DESC,7,56,300,12 - PUSHBUTTON STR_FINISH_SAVE,IDC_FINISH_SAVE,7,68,75,14 -END diff --git a/xorg-server/hw/xwin/xlaunch/resources/fullscreen.bmp b/xorg-server/hw/xwin/xlaunch/resources/fullscreen.bmp deleted file mode 100644 index 0d051f0b4..000000000 Binary files a/xorg-server/hw/xwin/xlaunch/resources/fullscreen.bmp and /dev/null differ diff --git a/xorg-server/hw/xwin/xlaunch/resources/images.rc b/xorg-server/hw/xwin/xlaunch/resources/images.rc deleted file mode 100644 index 2eac53c93..000000000 --- a/xorg-server/hw/xwin/xlaunch/resources/images.rc +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2005 Alexander Gottwald - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name(s) of the above copyright - * holders shall not be used in advertising or otherwise to promote the sale, - * use or other dealings in this Software without prior written authorization. - */ -IMG_MULTIWINDOW BITMAP "resources\\multiwindow.bmp" -IMG_WINDOWED BITMAP "resources\\windowed.bmp" -IMG_FULLSCREEN BITMAP "resources\\fullscreen.bmp" -IMG_NODECORATION BITMAP "resources\\nodecoration.bmp" diff --git a/xorg-server/hw/xwin/xlaunch/resources/multiwindow.bmp b/xorg-server/hw/xwin/xlaunch/resources/multiwindow.bmp deleted file mode 100644 index 0755c87b4..000000000 Binary files a/xorg-server/hw/xwin/xlaunch/resources/multiwindow.bmp and /dev/null differ diff --git a/xorg-server/hw/xwin/xlaunch/resources/nodecoration.bmp b/xorg-server/hw/xwin/xlaunch/resources/nodecoration.bmp deleted file mode 100644 index e9e1ce690..000000000 Binary files a/xorg-server/hw/xwin/xlaunch/resources/nodecoration.bmp and /dev/null differ diff --git a/xorg-server/hw/xwin/xlaunch/resources/resources.h b/xorg-server/hw/xwin/xlaunch/resources/resources.h deleted file mode 100644 index 470005192..000000000 --- a/xorg-server/hw/xwin/xlaunch/resources/resources.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2005 Alexander Gottwald - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name(s) of the above copyright - * holders shall not be used in advertising or otherwise to promote the sale, - * use or other dealings in this Software without prior written authorization. - */ - -#define IDC_STATIC -1 - -#define IDD_WELCOME 100 -#define IDD_FINISH 101 -#define IDD_DISPLAY 102 -#define IDD_CLIENTS 103 -#define IDD_PROGRAM 104 -#define IDD_XDMCP 105 -#define IDD_FONTPATH 106 -#define IDD_CLIPBOARD 107 - -#define IDS_DISPLAY_TITLE 300 -#define IDS_DISPLAY_SUBTITLE 301 -#define IDS_CLIENTS_TITLE 302 -#define IDS_CLIENTS_SUBTITLE 303 -#define IDS_PROGRAM_TITLE 304 -#define IDS_PROGRAM_SUBTITLE 305 -#define IDS_XDMCP_TITLE 306 -#define IDS_XDMCP_SUBTITLE 307 -#define IDS_FONTPATH_TITLE 308 -#define IDS_FONTPATH_SUBTITLE 309 -#define IDS_FINISH_TITLE 310 -#define IDS_FINISH_SUBTITLE 311 -#define IDS_CLIPBOARD_TITLE 312 -#define IDS_CLIPBOARD_SUBTITLE 313 -#define IDS_SAVE_TITLE 320 -#define IDS_SAVE_FILETITLE 321 -#define IDS_SAVE_FILTER 322 - -#define IDC_MULTIWINDOW 200 -#define IDC_WINDOWED 201 -#define IDC_FULLSCREEN 202 -#define IDC_NODECORATION 203 -#define IDC_MULTIWINDOW_IMG 204 -#define IDC_WINDOWED_IMG 205 -#define IDC_FULLSCREEN_IMG 206 -#define IDC_NODECORATION_IMG 207 -#define IDC_DISPLAY 208 -#define IDC_DISPLAY_DESC 209 - -#define IDC_CLIENT_NONE 210 -#define IDC_XDMCP 211 -#define IDC_CLIENT 212 -#define IDC_CLIENT_LOCAL 213 -#define IDC_CLIENT_REMOTE 214 -#define IDC_CLIENT_HOST 215 -#define IDC_CLIENT_USER 216 -#define IDC_CLIENT_PROTOCOL 217 -#define IDC_CLIENT_CONFIGURE 218 -#define IDC_CLIENT_PROGRAM 219 -#define IDC_XDMCP_QUERY 220 -#define IDC_XDMCP_BROADCAST 221 -#define IDC_XDMCP_INDIRECT 222 -#define IDC_XDMCP_HOST 223 -#define IDC_CLIENT_NONE_DESC 224 -#define IDC_XDMCP_DESC 225 -#define IDC_CLIENT_DESC 226 -#define IDC_XDMCP_QUERY_DESC 227 -#define IDC_CLIENT_PROGRAM_DESC 228 -#define IDC_CLIENT_HOST_DESC 229 -#define IDC_CLIENT_USER_DESC 230 -#define IDC_CLIENT_PROTOCOL_DESC 231 - -#define IDC_FONTPATH_DESC 240 - -#define IDC_FINISH_DESC 250 -#define IDC_FINISH_SAVE 251 -#define IDC_FINISH_SAVE_DESC 252 - -#define IDC_CLIPBOARD 260 -#define IDC_CLIPBOARD_DESC 261 -#define IDC_EXTRA_PARAMS 262 -#define IDC_EXTRA_PARAMS_DESC 263 diff --git a/xorg-server/hw/xwin/xlaunch/resources/resources.rc b/xorg-server/hw/xwin/xlaunch/resources/resources.rc deleted file mode 100644 index 07fd52f32..000000000 --- a/xorg-server/hw/xwin/xlaunch/resources/resources.rc +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2005 Alexander Gottwald - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name(s) of the above copyright - * holders shall not be used in advertising or otherwise to promote the sale, - * use or other dealings in this Software without prior written authorization. - */ -#include - -#include "resources.h" -#include "images.rc" -#include "dialog.rc" diff --git a/xorg-server/hw/xwin/xlaunch/resources/strings.rc b/xorg-server/hw/xwin/xlaunch/resources/strings.rc deleted file mode 100644 index 5a9cd281b..000000000 --- a/xorg-server/hw/xwin/xlaunch/resources/strings.rc +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2005 Alexander Gottwald - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name(s) of the above copyright - * holders shall not be used in advertising or otherwise to promote the sale, - * use or other dealings in this Software without prior written authorization. - */ - -#define STR_CAPTION_DISPLAY "Display settings" -#define STR_MULTIWINDOW "Multiple windows" -#define STR_FULLSCREEN "Fullscreen" -#define STR_WINDOWED "One large window" -#define STR_NODECORATION "One window without titlebar" -#define STR_DISPLAY_DESC "Display number" - -#define STR_CAPTION_CLIENTS "Client startup" -#define STR_CLIENT_NONE "Start no client" -#define STR_CLIENT_NONE_DESC "This will just start the xserver. You will be able to start local clients later." -#define STR_CLIENT "Start a program" -#define STR_CLIENT_DESC "This will start a local or remote program which will connect to the xserver. You will be able to start local clients later too. Remote programs are started using SSH." -#define STR_XDMCP "Open session via XDMCP" -#define STR_XDMCP_DESC "This will start a remote XDMCP session. Starting local clients later is limited. This option is not available with the ""Multiple windows"" mode." - -#define STR_CAPTION_PROGRAM "Start program" -#define STR_CLIENT_PROGRAM_DESC "Start program" -#define STR_CLIENT_LOCAL "Start program on this computer" -#define STR_CLIENT_REMOTE "Start program on remote computer" -#define STR_CLIENT_PROTOCOL_DESC "Connect using" -#define STR_CLIENT_HOST_DESC "Connect to computer" -#define STR_CLIENT_USER_DESC "Login as user" - - -#define STR_CAPTION_XDMCP "XDMCP settings" -#define STR_XDMCP_QUERY "Connect to host" -#define STR_XDMCP_INDIRECT "Use indirect connect" -#define STR_XDMCP_BROADCAST "Search for hosts (broadcast)" -#define STR_XDMCP_QUERY_DESC "Some XDMCP servers must be configured to allow remote connections. Please check the documentation about configuring XDMCP servers." - - -#define STR_CAPTION_FONTPATH "Fontpath settings" - -#define STR_CAPTION_CLIPBOARD "Clipboard settings" -#define STR_CLIPBOARD "Clipboard" -#define STR_CLIPBOARD_DESC "Start the integrated clipboard manager" -#define STR_EXTRA_PARAMS_DESC "Additional parameters for Xming" - -#define STR_CAPTION_FINISH "Finish configuration" -#define STR_FINISH_DESC "Configuration is complete. Clish Finish to start Xming." -#define STR_FINISH_SAVE_DESC "You may also save the configuration for later use." -#define STR_FINISH_SAVE "Save configuration" - -#define STR_DISPLAY_TITLE "Select display settings" -#define STR_DISPLAY_SUBTITLE "Choose how Xming display programs" -#define STR_CLIENTS_TITLE "Select how to start clients" -#define STR_CLIENTS_SUBTITLE "" -#define STR_PROGRAM_TITLE "Specify the program to start" -#define STR_PROGRAM_SUBTITLE "" -#define STR_XDMCP_TITLE "Configure a remote XDMCP connection" -#define STR_XDMCP_SUBTITLE "" -#define STR_FONTPATH_TITLE "Define font locations" -#define STR_FONTPATH_SUBTITLE "" -#define STR_FINISH_TITLE "Configuration complete" -#define STR_FINISH_SUBTITLE "" -#define STR_CLIPBOARD_TITLE "Clipboard settings" -#define STR_CLIPBOARD_SUBTITLE "" - -#define STR_SAVE_TITLE "Save configuration" -#define STR_SAVE_FILETITLE "Filename" -#define STR_SAVE_FILTER "Xlaunch Files (*.xlaunch)%*.xlaunch%%" - -STRINGTABLE -BEGIN - IDS_DISPLAY_TITLE STR_DISPLAY_TITLE - IDS_DISPLAY_SUBTITLE STR_DISPLAY_SUBTITLE - IDS_CLIENTS_TITLE STR_CLIENTS_TITLE - IDS_CLIENTS_SUBTITLE STR_CLIENTS_SUBTITLE - IDS_PROGRAM_TITLE STR_PROGRAM_TITLE - IDS_PROGRAM_SUBTITLE STR_PROGRAM_SUBTITLE - IDS_XDMCP_TITLE STR_XDMCP_TITLE - IDS_XDMCP_SUBTITLE STR_XDMCP_SUBTITLE - IDS_FONTPATH_TITLE STR_FONTPATH_TITLE - IDS_FONTPATH_SUBTITLE STR_FONTPATH_SUBTITLE - IDS_FINISH_TITLE STR_FINISH_TITLE - IDS_FINISH_SUBTITLE STR_FINISH_SUBTITLE - IDS_CLIPBOARD_TITLE STR_CLIPBOARD_TITLE - IDS_CLIPBOARD_SUBTITLE STR_CLIPBOARD_SUBTITLE - IDS_SAVE_TITLE STR_SAVE_TITLE - IDS_SAVE_FILETITLE STR_SAVE_FILETITLE - IDS_SAVE_FILTER STR_SAVE_FILTER -END diff --git a/xorg-server/hw/xwin/xlaunch/resources/windowed.bmp b/xorg-server/hw/xwin/xlaunch/resources/windowed.bmp deleted file mode 100644 index 9eff2bff9..000000000 Binary files a/xorg-server/hw/xwin/xlaunch/resources/windowed.bmp and /dev/null differ diff --git a/xorg-server/hw/xwin/xlaunch/window/dialog.cc b/xorg-server/hw/xwin/xlaunch/window/dialog.cc deleted file mode 100644 index 76e5c35ac..000000000 --- a/xorg-server/hw/xwin/xlaunch/window/dialog.cc +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2005 Alexander Gottwald - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name(s) of the above copyright - * holders shall not be used in advertising or otherwise to promote the sale, - * use or other dealings in this Software without prior written authorization. - */ -#include -#include "dialog.h" -#include "util.h" - -CBaseDialog::CBaseDialog() : CWindow(""), result(0) -{ -} - -CDialog::CDialog(const char *res) : CBaseDialog(), resourcename(res) -{ -} - -HWND CDialog::CreateWindowHandle() -{ - HWND ret = CreateDialog( - GetModuleHandle(NULL), - resourcename.c_str(), - NULL, - DialogProc); - if (ret == NULL) - throw win32_error("CreateDialog failed"); - return ret; -} - -INT_PTR CALLBACK CBaseDialog::DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - MessageDebug::debug(hwndDlg, uMsg, wParam, lParam, __FUNCTION__); - CBaseDialog* dialog = (CDialog*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - if (dialog != NULL) - return dialog->DlgDispatch(hwndDlg, uMsg, wParam, lParam); - return FALSE; -} - -INT_PTR CBaseDialog::DlgDispatch(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - switch (uMsg) - { - case WM_COMMAND: - switch (LOWORD(wParam)) - { - case IDOK: - case IDCANCEL: - result = wParam; - EndDialog(hwndDlg, wParam); - DestroyWindow(hwndDlg); - return TRUE; - } - break; - } - return FALSE; -} - -INT_PTR CDialog::DlgDispatch(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - return CBaseDialog::DlgDispatch(hwndDlg, uMsg, wParam, lParam); -} - -int CBaseDialog::Execute() -{ - return CWindow::ShowModal(); -} diff --git a/xorg-server/hw/xwin/xlaunch/window/dialog.h b/xorg-server/hw/xwin/xlaunch/window/dialog.h deleted file mode 100644 index 073394bb2..000000000 --- a/xorg-server/hw/xwin/xlaunch/window/dialog.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2005 Alexander Gottwald - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name(s) of the above copyright - * holders shall not be used in advertising or otherwise to promote the sale, - * use or other dealings in this Software without prior written authorization. - */ -#ifndef __DIALOG_H__ -#define __DIALOG_H__ - -#include "window.h" -class CBaseDialog : public CWindow -{ - private: - int result; - protected: - static INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); - virtual INT_PTR DlgDispatch(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); - public: - CBaseDialog(); - int Execute(); -}; - -class CDialog : public CBaseDialog -{ - private: - std::string resourcename; - protected: - virtual INT_PTR DlgDispatch(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); - virtual HWND CreateWindowHandle(); - public: - CDialog(const char *res); -}; - - -#endif diff --git a/xorg-server/hw/xwin/xlaunch/window/util.cc b/xorg-server/hw/xwin/xlaunch/window/util.cc deleted file mode 100644 index fb7e87297..000000000 --- a/xorg-server/hw/xwin/xlaunch/window/util.cc +++ /dev/null @@ -1,1112 +0,0 @@ -/* - * Copyright (c) 2005 Alexander Gottwald - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name(s) of the above copyright - * holders shall not be used in advertising or otherwise to promote the sale, - * use or other dealings in this Software without prior written authorization. - */ -#include "util.h" - -std::string win32_error::message(DWORD errorcode) -{ - LPVOID lpMsgBuf; - if (!FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - errorcode, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPTSTR) &lpMsgBuf, - 0, - NULL )) - { - return "Unknown error in FormatMessage"; - } - - std::string ret((LPCTSTR)lpMsgBuf); - LocalFree( lpMsgBuf ); - return ret; -} - -void MessageDebug::debug(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, const char *prefix) -{ -#ifdef _DEBUG - static const char *psn_notify[] = { - "PSN_SETACTIVE", - "PSN_KILLACTIVE", - "PSN_APPLY", - "PSN_RESET", - NULL, - "PSN_HELP", - "PSN_WIZBACK", - "PSN_WIZNEXT", - "PSN_WIZFINISH", - "PSN_QUERYCANCEL" }; - if (uMsg == WM_NOTIFY) - { - LPNMHDR pnmh = (LPNMHDR)lParam; - int psn_index = -(int)pnmh->code - 200; - if (psn_index >= 0 && psn_index < 10 && psn_notify[psn_index]) - printf("%s: %08x %04x WM_NOTIFY (%s)\n", prefix, hwnd, wParam, psn_notify[psn_index]); - else if (pnmh->code < NOTIFY_NAMES_LEN && notify_names[pnmh->code]) - printf("%s: %08x %04x WM_NOTIFY (%s)\n", prefix, hwnd, wParam, notify_names[pnmh->code]); - else - printf("%s: %08x %04x WM_NOTIFY (%u)\n", prefix, hwnd, wParam, pnmh->code); - } - else if (uMsg >= MESSAGE_NAMES_LEN) - if (uMsg >= WM_USER) - printf("%s: %08x %04x %08x WM_USER + %d\n", prefix, hwnd, wParam, lParam, uMsg - WM_USER); - else - printf("%s: %08x %04x %08x %d\n", prefix, hwnd, wParam, lParam, uMsg); - else if (uMsg >= 0 && uMsg < MESSAGE_NAMES_LEN && message_names[uMsg]) - printf("%s: %08x %04x %08x %s\n", prefix, hwnd, wParam, lParam, message_names[uMsg]); -#endif -} - - -const char * MessageDebug::message_names[MESSAGE_NAMES_LEN] = { - "WM_NULL", - "WM_CREATE", - "WM_DESTROY", - "WM_MOVE", - "4", - "WM_SIZE", - "WM_ACTIVATE", - "WM_SETFOCUS", - "WM_KILLFOCUS", - "9", - "WM_ENABLE", - "WM_SETREDRAW", - "WM_SETTEXT", - "WM_GETTEXT", - "WM_GETTEXTLENGTH", - "WM_PAINT", - "WM_CLOSE", - "WM_QUERYENDSESSION", - "WM_QUIT", - "WM_QUERYOPEN", - "WM_ERASEBKGND", - "WM_SYSCOLORCHANGE", - "WM_ENDSESSION", - "23", - "WM_SHOWWINDOW", - "25", - "WM_WININICHANGE", - "WM_DEVMODECHANGE", - "WM_ACTIVATEAPP", - "WM_FONTCHANGE", - "WM_TIMECHANGE", - "WM_CANCELMODE", - NULL /* WM_SETCURSOR */, - "WM_MOUSEACTIVATE", - "WM_CHILDACTIVATE", - "WM_QUEUESYNC", - "WM_GETMINMAXINFO", - "37", - "WM_PAINTICON", - "WM_ICONERASEBKGND", - "WM_NEXTDLGCTL", - "41", - "WM_SPOOLERSTATUS", - "WM_DRAWITEM", - "WM_MEASUREITEM", - "WM_DELETEITEM", - "WM_VKEYTOITEM", - "WM_CHARTOITEM", - "WM_SETFONT", - "WM_GETFONT", - "WM_SETHOTKEY", - "WM_GETHOTKEY", - "52", - "53", - "54", - "WM_QUERYDRAGICON", - "56", - "WM_COMPAREITEM", - "58", - "59", - "60", - "61", - "62", - "63", - "64", - "WM_COMPACTING", - "66", - "67", - "WM_COMMNOTIFY", - "69", - "WM_WINDOWPOSCHANGING", - "WM_WINDOWPOSCHANGED", - "WM_POWER", - "73", - "WM_COPYDATA", - "WM_CANCELJOURNAL", - "76", - "77", - "WM_NOTIFY", - "79", - "WM_INPUTLANGCHANGEREQUEST", - "WM_INPUTLANGCHANGE", - "WM_TCARD", - "WM_HELP", - "WM_USERCHANGED", - "WM_NOTIFYFORMAT", - "86", - "87", - "88", - "89", - "90", - "91", - "92", - "93", - "94", - "95", - "96", - "97", - "98", - "99", - "100", - "101", - "102", - "103", - "104", - "105", - "106", - "107", - "108", - "109", - "110", - "111", - "112", - "113", - "114", - "115", - "116", - "117", - "118", - "119", - "120", - "121", - "122", - "WM_CONTEXTMENU", - "WM_STYLECHANGING", - "WM_STYLECHANGED", - "WM_DISPLAYCHANGE", - "WM_GETICON", - "WM_SETICON", - "WM_NCCREATE", - "WM_NCDESTROY", - "WM_NCCALCSIZE", - NULL /* WM_NCHITTEST */, - "WM_NCPAINT", - "WM_NCACTIVATE", - "WM_GETDLGCODE", - "WM_SYNCPAINT", - "137", - "138", - "139", - "140", - "141", - "142", - "143", - "144", - "145", - "146", - "147", - "148", - "149", - "150", - "151", - "152", - "153", - "154", - "155", - "156", - "157", - "158", - "159", - NULL /* WM_NCMOUSEMOVE */, - "WM_NCLBUTTONDOWN", - "WM_NCLBUTTONUP", - "WM_NCLBUTTONDBLCLK", - "WM_NCRBUTTONDOWN", - "WM_NCRBUTTONUP", - "WM_NCRBUTTONDBLCLK", - "WM_NCMBUTTONDOWN", - "WM_NCMBUTTONUP", - "WM_NCMBUTTONDBLCLK", - "170", - "171", - "172", - "173", - "174", - "175", - "176", - "177", - "178", - "179", - "180", - "181", - "182", - "183", - "184", - "185", - "186", - "187", - "188", - "189", - "190", - "191", - "192", - "193", - "194", - "195", - "196", - "197", - "198", - "199", - "200", - "201", - "202", - "203", - "204", - "205", - "206", - "207", - "208", - "209", - "210", - "211", - "212", - "213", - "214", - "215", - "216", - "217", - "218", - "219", - "220", - "221", - "222", - "223", - "224", - "225", - "226", - "227", - "228", - "229", - "230", - "231", - "232", - "233", - "234", - "235", - "236", - "237", - "238", - "239", - "240", - "241", - "242", - "243", - "244", - "245", - "246", - "247", - "248", - "249", - "250", - "251", - "252", - "253", - "254", - "255", - "WM_KEYDOWN", - "WM_KEYUP", - "WM_CHAR", - "WM_DEADCHAR", - "WM_SYSKEYDOWN", - "WM_SYSKEYUP", - "WM_SYSCHAR", - "WM_SYSDEADCHAR", - "WM_CONVERTREQUESTEX", - "265", - "266", - "267", - "268", - "WM_IME_STARTCOMPOSITION", - "WM_IME_ENDCOMPOSITION", - "WM_IME_KEYLAST", - "WM_INITDIALOG", - "WM_COMMAND", - "WM_SYSCOMMAND", - NULL /* WM_TIMER */, - "WM_HSCROLL", - "WM_VSCROLL", - "WM_INITMENU", - "WM_INITMENUPOPUP", - "280", - "281", - "282", - "283", - "284", - "285", - "286", - "WM_MENUSELECT", - "WM_MENUCHAR", - "WM_ENTERIDLE", - "290", - "291", - "292", - "293", - "294", - "295", - "296", - "297", - "298", - "299", - "300", - "301", - "302", - "303", - "304", - "305", - "WM_CTLCOLORMSGBOX", - "WM_CTLCOLOREDIT", - "WM_CTLCOLORLISTBOX", - "WM_CTLCOLORBTN", - "WM_CTLCOLORDLG", - "WM_CTLCOLORSCROLLBAR", - "WM_CTLCOLORSTATIC", - "313", - "314", - "315", - "316", - "317", - "318", - "319", - "320", - "321", - "322", - "323", - "324", - "325", - "326", - "327", - "328", - "329", - "330", - "331", - "332", - "333", - "334", - "335", - "336", - "337", - "338", - "339", - "340", - "341", - "342", - "343", - "344", - "345", - "346", - "347", - "348", - "349", - "350", - "351", - "352", - "353", - "354", - "355", - "356", - "357", - "358", - "359", - "360", - "361", - "362", - "363", - "364", - "365", - "366", - "367", - "368", - "369", - "370", - "371", - "372", - "373", - "374", - "375", - "376", - "377", - "378", - "379", - "380", - "381", - "382", - "383", - "384", - "385", - "386", - "387", - "388", - "389", - "390", - "391", - "392", - "393", - "394", - "395", - "396", - "397", - "398", - "399", - "400", - "401", - "402", - "403", - "404", - "405", - "406", - "407", - "408", - "409", - "410", - "411", - "412", - "413", - "414", - "415", - "416", - "417", - "418", - "419", - "420", - "421", - "422", - "423", - "424", - "425", - "426", - "427", - "428", - "429", - "430", - "431", - "432", - "433", - "434", - "435", - "436", - "437", - "438", - "439", - "440", - "441", - "442", - "443", - "444", - "445", - "446", - "447", - "448", - "449", - "450", - "451", - "452", - "453", - "454", - "455", - "456", - "457", - "458", - "459", - "460", - "461", - "462", - "463", - "464", - "465", - "466", - "467", - "468", - "469", - "470", - "471", - "472", - "473", - "474", - "475", - "476", - "477", - "478", - "479", - "480", - "481", - "482", - "483", - "484", - "485", - "486", - "487", - "488", - "489", - "490", - "491", - "492", - "493", - "494", - "495", - "496", - "497", - "498", - "499", - "500", - "501", - "502", - "503", - "504", - "505", - "506", - "507", - "508", - "509", - "510", - "511", - NULL /* WM_MOUSEMOVE */, - "WM_LBUTTONDOWN", - "WM_LBUTTONUP", - "WM_LBUTTONDBLCLK", - "WM_RBUTTONDOWN", - "WM_RBUTTONUP", - "WM_RBUTTONDBLCLK", - "WM_MBUTTONDOWN", - "WM_MBUTTONUP", - "WM_MBUTTONDBLCLK", - "WM_MOUSEWHEEL", - "WM_XBUTTONDOWN", - "WM_XBUTTONUP", - "WM_XBUTTONDBLCLK", - "526", - "527", - "WM_PARENTNOTIFY", - "WM_ENTERMENULOOP", - "WM_EXITMENULOOP", - "WM_NEXTMENU", - "WM_SIZING", - "WM_CAPTURECHANGED", - "WM_MOVING", - "535", - "WM_POWERBROADCAST", - "WM_DEVICECHANGE", - "538", - "539", - "540", - "541", - "542", - "543", - "WM_MDICREATE", - "WM_MDIDESTROY", - "WM_MDIACTIVATE", - "WM_MDIRESTORE", - "WM_MDINEXT", - "WM_MDIMAXIMIZE", - "WM_MDITILE", - "WM_MDICASCADE", - "WM_MDIICONARRANGE", - "WM_MDIGETACTIVE", - "554", - "555", - "556", - "557", - "558", - "559", - "WM_MDISETMENU", - "WM_ENTERSIZEMOVE", - "WM_EXITSIZEMOVE", - "WM_DROPFILES", - "WM_MDIREFRESHMENU", - "565", - "566", - "567", - "568", - "569", - "570", - "571", - "572", - "573", - "574", - "575", - "576", - "577", - "578", - "579", - "580", - "581", - "582", - "583", - "584", - "585", - "586", - "587", - "588", - "589", - "590", - "591", - "592", - "593", - "594", - "595", - "596", - "597", - "598", - "599", - "600", - "601", - "602", - "603", - "604", - "605", - "606", - "607", - "608", - "609", - "610", - "611", - "612", - "613", - "614", - "615", - "616", - "617", - "618", - "619", - "620", - "621", - "622", - "623", - "624", - "625", - "626", - "627", - "628", - "629", - "630", - "631", - "632", - "633", - "634", - "635", - "636", - "637", - "638", - "639", - "640", - "WM_IME_SETCONTEXT", - "WM_IME_NOTIFY", - "WM_IME_CONTROL", - "WM_IME_COMPOSITIONFULL", - "WM_IME_SELECT", - "WM_IME_CHAR", - "647", - "648", - "649", - "650", - "651", - "652", - "653", - "654", - "655", - "WM_IME_KEYDOWN", - "WM_IME_KEYUP", - "658", - "659", - "660", - "661", - "662", - "663", - "664", - "665", - "666", - "667", - "668", - "669", - "670", - "671", - "672", - "WM_MOUSEHOVER", - "674", - "WM_MOUSELEAVE", - "676", - "677", - "678", - "679", - "680", - "681", - "682", - "683", - "684", - "685", - "686", - "687", - "688", - "689", - "690", - "691", - "692", - "693", - "694", - "695", - "696", - "697", - "698", - "699", - "700", - "701", - "702", - "703", - "704", - "705", - "706", - "707", - "708", - "709", - "710", - "711", - "712", - "713", - "714", - "715", - "716", - "717", - "718", - "719", - "720", - "721", - "722", - "723", - "724", - "725", - "726", - "727", - "728", - "729", - "730", - "731", - "732", - "733", - "734", - "735", - "736", - "737", - "738", - "739", - "740", - "741", - "742", - "743", - "744", - "745", - "746", - "747", - "748", - "749", - "750", - "751", - "752", - "753", - "754", - "755", - "756", - "757", - "758", - "759", - "760", - "761", - "762", - "763", - "764", - "765", - "766", - "767", - "WM_CUT", - "WM_COPY", - "WM_PASTE", - "WM_CLEAR", - "WM_UNDO", - "WM_RENDERFORMAT", - "WM_RENDERALLFORMATS", - "WM_DESTROYCLIPBOARD", - "WM_DRAWCLIPBOARD", - "WM_PAINTCLIPBOARD", - "WM_VSCROLLCLIPBOARD", - "WM_SIZECLIPBOARD", - "WM_ASKCBFORMATNAME", - "WM_CHANGECBCHAIN", - "WM_HSCROLLCLIPBOARD", - "WM_QUERYNEWPALETTE", - "WM_PALETTEISCHANGING", - "WM_PALETTECHANGED", - "WM_HOTKEY", - "787", - "788", - "789", - "790", - "WM_PRINT", - "WM_PRINTCLIENT", - "793", - "794", - "795", - "796", - "797", - "798", - "799", - "800", - "801", - "802", - "803", - "804", - "805", - "806", - "807", - "808", - "809", - "810", - "811", - "812", - "813", - "814", - "815", - "816", - "817", - "818", - "819", - "820", - "821", - "822", - "823", - "824", - "825", - "826", - "827", - "828", - "829", - "830", - "831", - "832", - "833", - "834", - "835", - "836", - "837", - "838", - "839", - "840", - "841", - "842", - "843", - "844", - "845", - "846", - "847", - "848", - "849", - "850", - "851", - "852", - "853", - "854", - "855", - "856", - "857", - "858", - "859", - "860", - "861", - "862", - "863", - "864", - "865", - "866", - "867", - "868", - "869", - "870", - "871", - "872", - "873", - "874", - "875", - "876", - "877", - "878", - "879", - "880", - "881", - "882", - "883", - "884", - "885", - "886", - "887", - "888", - "889", - "890", - "891", - "892", - "893", - "894", - "895", - "896", - "897", - "898", - "899", - "900", - "901", - "902", - "903", - "904", - "905", - "906", - "907", - "908", - "909", - "910", - "911", - "912", - "913", - "914", - "915", - "916", - "917", - "918", - "919", - "920", - "921", - "922", - "923", - "924", - "925", - "926", - "927", - "928", - "929", - "930", - "931", - "932", - "933", - "934", - "935", - "936", - "937", - "938", - "939", - "940", - "941", - "942", - "943", - "944", - "945", - "946", - "947", - "948", - "949", - "950", - "951", - "952", - "953", - "954", - "955", - "956", - "957", - "958", - "959", - "960", - "961", - "962", - "963", - "964", - "965", - "966", - "967", - "968", - "969", - "970", - "971", - "972", - "973", - "974", - "975", - "976", - "977", - "978", - "979", - "980", - "981", - "982", - "983", - "984", - "985", - "986", - "987", - "988", - "989", - "990", - "991", - "992", - "993", - "994", - "995", - "996", - "997", - "998", - "999", - "1000", - "1001", - "1002", - "1003", - "1004", - "1005", - "1006", - "1007", - "1008", - "1009", - "1010", - "1011", - "1012", - "1013", - "1014", - "1015", - "1016", - "1017", - "1018", - "1019", - "1020", - "1021", - "1022", - "1023" -}; - diff --git a/xorg-server/hw/xwin/xlaunch/window/util.h b/xorg-server/hw/xwin/xlaunch/window/util.h deleted file mode 100644 index cd21da657..000000000 --- a/xorg-server/hw/xwin/xlaunch/window/util.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2005 Alexander Gottwald - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name(s) of the above copyright - * holders shall not be used in advertising or otherwise to promote the sale, - * use or other dealings in this Software without prior written authorization. - */ -#ifndef __UTIL_H__ -#define __UTIL_H__ - -#include -#include - - -class win32_error : public std::runtime_error -{ - public: - static std::string message(DWORD code); - DWORD errorcode; - win32_error(const std::string &msg,DWORD code = GetLastError()) : std::runtime_error(msg + ":" + message(code)), errorcode(code) {}; -}; - -#define MESSAGE_NAMES_LEN 1024 -#define NOTIFY_NAMES_LEN 0 -class MessageDebug -{ - protected: - static const char * message_names[MESSAGE_NAMES_LEN]; - static const char * notify_names[NOTIFY_NAMES_LEN]; - public: - static void debug(HWND handle, UINT uMsg, WPARAM wParam, LPARAM lParam, const char *prefix); -}; - - -#endif diff --git a/xorg-server/hw/xwin/xlaunch/window/window.cc b/xorg-server/hw/xwin/xlaunch/window/window.cc deleted file mode 100644 index cca3a485a..000000000 --- a/xorg-server/hw/xwin/xlaunch/window/window.cc +++ /dev/null @@ -1,284 +0,0 @@ -/* - * Copyright (c) 2005 Alexander Gottwald - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name(s) of the above copyright - * holders shall not be used in advertising or otherwise to promote the sale, - * use or other dealings in this Software without prior written authorization. - */ - -#include "window.h" -#include "util.h" -#include -#include - -CWindow::CWindowClass CWindow::windowClass("CWINDOWCLASS", DefWindowProc); - -CWindow::CWindowClass::CWindowClass(const char *_name, WNDPROC _wndproc) : - wndproc(_wndproc), atom(0), classname(_name) -{ - Register(); -} - -CWindow::CWindowClass::~CWindowClass() -{ - UnregisterClass(classname.c_str(), GetModuleHandle(NULL)); -} - -void CWindow::CWindowClass::Register() -{ - WNDCLASSEX wndclass; - memset(&wndclass, 0, sizeof(wndclass)); - wndclass.cbSize = sizeof(wndclass); - wndclass.style = 0; - wndclass.lpfnWndProc = wndproc; - wndclass.cbClsExtra = 0; - wndclass.cbWndExtra = 0; - wndclass.hInstance = GetModuleHandle(NULL); - wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); - wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); - wndclass.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE); - wndclass.lpszMenuName = NULL; - wndclass.lpszClassName = classname.c_str(); - wndclass.hIconSm = NULL; - atom = RegisterClassEx(&wndclass); - if (atom == 0) - throw win32_error("RegisterClassEx failed"); -} - -CWindow::CWindow(const char *_title) : title(_title), hwnd(NULL), parent(NULL), bounds(), owndproc(NULL), showing(FALSE) -{ - style = WS_CHILD; - exstyle = 0; -} - -HWND CWindow::CreateWindowHandle() -{ - HWND ret = CreateWindowEx( - exstyle, - GetClassName(), - title.c_str(), - style, - bounds.left, - bounds.top, - bounds.width, - bounds.height, - parent, - NULL, - GetModuleHandle(NULL), - 0 - ); - if (ret == NULL) - throw win32_error("CreateWindowEx failed"); - return ret; -} - -void CWindow::Create() -{ - if (hwnd != NULL) - return; - hwnd = CreateWindowHandle(); - if (hwnd == NULL) - throw win32_error("Could not create window"); - - // Reset the error code - DWORD err = 0; - SetLastError(err); - - // Attach the object reference to the window handle - SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)this); - err = GetLastError(); - if (err != 0) - throw win32_error("SetWindowLongPtr failed",err); - - // Set the window proc - owndproc = (WNDPROC)SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)WindowProc); - err = GetLastError(); - if (err != 0) - throw win32_error("SetWindowLongPtr failed",err); -} - -const char *CWindow::GetClassName() -{ - return windowClass.GetClassName(); -} - -LRESULT CALLBACK CWindow::WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - MessageDebug::debug(hwnd, uMsg, wParam, lParam, __FUNCTION__); - CWindow* window = (CWindow*)GetWindowLongPtr(hwnd, GWLP_USERDATA); - if (window != NULL) - return window->Dispatch(hwnd, uMsg, wParam, lParam); - return DefWindowProc(hwnd, uMsg, wParam, lParam); -} - -LRESULT CWindow::Dispatch(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - switch (uMsg) - { - case WM_SIZE: - bounds.width = LOWORD(lParam); - bounds.height = LOWORD(lParam); - break; - case WM_MOVE: - bounds.left = LOWORD(lParam); - bounds.top = LOWORD(lParam); - break; - case WM_DESTROY: - showing = FALSE; - break; - } - if (owndproc) - return CallWindowProc(owndproc, hwnd, uMsg, wParam, lParam); - else - return DefWindowProc(hwnd, uMsg, wParam, lParam); -} - -void CWindow::Show() -{ - if (hwnd == NULL) - Create(); - ShowWindow(hwnd, SW_SHOWNORMAL); -} - -int CWindow::ShowModal() -{ - MSG msg; - BOOL bRet; - showing = TRUE; - Show(); - - while( showing && (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0) - { - if (bRet == -1) - { - // handle the error and possibly exit - } - else - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - return 0; -} - -void CWindow::SetLeft(int left) -{ - bounds.left = left; - if (hwnd) - if (!SetWindowPos(hwnd, NULL, - bounds.left, bounds.top, - 0, 0, - SWP_NOZORDER | SWP_NOSIZE)) - throw win32_error("SetWindowPos failed"); -} - -void CWindow::SetTop(int top) -{ - bounds.top = top; - if (hwnd) - if (!SetWindowPos(hwnd, NULL, - bounds.left, bounds.top, - 0, 0, - SWP_NOZORDER | SWP_NOSIZE)) - throw win32_error("SetWindowPos failed"); -} - -void CWindow::SetWidth(int width) -{ - bounds.width = width; - if (hwnd) - if (!SetWindowPos(hwnd, NULL, - 0, 0, - bounds.width, bounds.height, - SWP_NOZORDER | SWP_NOMOVE)) - throw win32_error("SetWindowPos failed"); -} -void CWindow::SetHeight(int height) -{ - bounds.height = height; - if (hwnd) - if (!SetWindowPos(hwnd, NULL, - 0, 0, - bounds.width, bounds.height, - SWP_NOZORDER | SWP_NOMOVE)) - throw win32_error("SetWindowPos failed"); -} - -void CWindow::SetBounds(int left, int top, int width, int height) -{ - bounds = CBoundary(left, top, width, height); - if (hwnd) - if (!SetWindowPos(hwnd, NULL, - bounds.left, bounds.top, - bounds.width, bounds.height, - SWP_NOZORDER)) - throw win32_error("SetWindowPos failed"); -} - -void CWindow::SetBounds(const RECT &rect) -{ - bounds = rect; - if (hwnd) - if (!SetWindowPos(hwnd, NULL, - bounds.left, bounds.top, - bounds.width, bounds.height, - SWP_NOZORDER)) - throw win32_error("SetWindowPos failed"); -} - -HWND CWindow::GetHandle() -{ - if (hwnd == NULL) - Create(); - return hwnd; -} - -void CWindow::SetParent(CWindow *window) -{ - parent = window->GetHandle(); - if (hwnd != NULL) - if (::SetParent(hwnd, parent) == NULL) - throw win32_error("SetParent failed"); - -} - -void CWindow::SetStyle(DWORD style) -{ - this->style = style; - SetLastError(0); - if (hwnd) - SetWindowLong(hwnd, GWL_STYLE, style); - int err = GetLastError(); - if (err != 0) - throw win32_error("SetWindowLong failed", err); -} - -void CWindow::SetExStyle(DWORD exstyle) -{ - this->exstyle = exstyle; - SetLastError(0); - if (hwnd) - SetWindowLong(hwnd, GWL_EXSTYLE, exstyle); - int err = GetLastError(); - if (err != 0) - throw win32_error("SetWindowWLong failed", err); -} diff --git a/xorg-server/hw/xwin/xlaunch/window/window.h b/xorg-server/hw/xwin/xlaunch/window/window.h deleted file mode 100644 index baf401405..000000000 --- a/xorg-server/hw/xwin/xlaunch/window/window.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2005 Alexander Gottwald - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name(s) of the above copyright - * holders shall not be used in advertising or otherwise to promote the sale, - * use or other dealings in this Software without prior written authorization. - */ -#ifndef __WINDOW_H__ -#define __WINDOW_H__ - -#include -#include - -class CDialog; -class CWindow -{ - friend class CDialog; - public: - struct CBoundary - { - int left; - int top; - int width; - int height; - CBoundary() : - left(0), top(0), width(0), height(0) {}; - CBoundary(int x, int y, int w, int h) : - left(x), top(y), width(w), height(h) {}; - CBoundary(const RECT &r) : - left(r.left), top(r.top), width(r.right-r.left), height(r.bottom-r.top) {}; - }; - class CWindowClass - { - private: - WNDPROC wndproc; - ATOM atom; - std::string classname; - protected: - void Register(); - public: - CWindowClass(const char *name, WNDPROC wndproc); - ~CWindowClass(); - const char *GetClassName() { return classname.c_str(); }; - }; - private: - static CWindowClass windowClass; - - std::string title; - DWORD exstyle; - DWORD style; - CBoundary bounds; - HWND hwnd; - HWND parent; - WNDPROC owndproc; - - BOOL showing; - - protected: - - virtual const char *GetClassName(); - virtual HWND CreateWindowHandle(); - static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - public: - CWindow(const char *title); - virtual void Create(); - - virtual int ShowModal(); - - void Show(); - void Hide(); - - void SetWidth(int width); - void SetHeight(int height); - void SetLeft(int left); - void SetTop(int top); - int GetWidth() { return bounds.width; }; - int GetHeight() { return bounds.height; }; - int GetLeft() { return bounds.left; }; - int GetTop() { return bounds.top; }; - - void SetBounds(int left, int top, int width, int height); - void SetBounds(const RECT &rect); - - void SetStyle(DWORD style); - DWORD GetStyle() { return style; }; - - void SetExStyle(DWORD exstyle); - DWORD GetExStyle() { return exstyle; }; - - HWND GetHandle(); - void SetParent(CWindow *window); - - virtual LRESULT Dispatch(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); -}; - -#endif diff --git a/xorg-server/hw/xwin/xlaunch/window/wizard.cc b/xorg-server/hw/xwin/xlaunch/window/wizard.cc deleted file mode 100644 index 9d6c71193..000000000 --- a/xorg-server/hw/xwin/xlaunch/window/wizard.cc +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright (c) 2005 Alexander Gottwald - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name(s) of the above copyright - * holders shall not be used in advertising or otherwise to promote the sale, - * use or other dealings in this Software without prior written authorization. - */ -#include "wizard.h" -#include "util.h" - -CWizard::CWizard() : pages() -{ -}; - -void CWizard::AddPage(const PROPSHEETPAGE &page) -{ - pages.push_back(page); -} - -void CWizard::AddPage(const char *page, HINSTANCE instance) -{ - PROPSHEETPAGE psp; - if (instance == NULL) - instance = GetModuleHandle(NULL); - - memset(&psp, 0, sizeof(psp)); - psp.dwSize = sizeof(PROPSHEETPAGE); - psp.dwFlags = PSP_DEFAULT; - psp.hInstance = instance; - psp.pszTemplate = page; - psp.pfnDlgProc = WizardDialogProc; - psp.lParam = (LPARAM)this; - - AddPage(psp); -} - -void CWizard::AddPage(DWORD id, DWORD title, DWORD subtitle, HINSTANCE instance) -{ - PROPSHEETPAGE psp; - if (instance == NULL) - instance = GetModuleHandle(NULL); - - memset(&psp, 0, sizeof(psp)); - psp.dwSize = sizeof(PROPSHEETPAGE); - psp.dwFlags = PSP_DEFAULT; -#if _WIN32_IE >= 0x0500 - if (title != 0) - { - psp.dwFlags |= PSP_USEHEADERTITLE; - psp.pszHeaderTitle = MAKEINTRESOURCE(title); - } - if (subtitle != 0) - { - psp.dwFlags |= PSP_USEHEADERSUBTITLE; - psp.pszHeaderSubTitle = MAKEINTRESOURCE(subtitle); - } -#endif - - psp.hInstance = instance; - psp.pszTemplate = MAKEINTRESOURCE(id); - psp.pfnDlgProc = WizardDialogProc; - psp.lParam = (LPARAM)this; - - AddPage(psp); -} - -HWND CWizard::CreateWindowHandle() -{ - PROPSHEETHEADER psh; - HWND ret; - - PrepareSheetHeader(psh, FALSE); - ret = (HWND)PropertySheet(&psh); - free(psh.phpage); - if (ret == NULL) - throw win32_error("PropertySheet failed"); - return ret; -} - -int CWizard::ShowModal() -{ - PROPSHEETHEADER psh; - int ret; - - PrepareSheetHeader(psh, TRUE); - ret = PropertySheet(&psh); - free(psh.phpage); - return ret; -} - -void CWizard::PrepareSheetHeader(PROPSHEETHEADER &psh, BOOL modal) -{ - HPROPSHEETPAGE *phpage = (HPROPSHEETPAGE*)malloc(pages.size() * sizeof(HPROPSHEETPAGE)); - DWORD modeflag; - - if (modal) - modeflag = 0; - else - modeflag = PSH_MODELESS; - - for (unsigned i = 0; i < pages.size(); i++) - { - phpage[i] = CreatePropertySheetPage(&pages[i]); - if (phpage[i] == NULL) - { - DWORD err = GetLastError(); - free(phpage); - throw win32_error("CreatePropertySheetPage failed", err); - } - } - - memset(&psh, 0, sizeof(psh)); - psh.dwSize = sizeof(PROPSHEETHEADER); -#if _WIN32_IE >= 0x0500 - psh.dwFlags = PSH_WIZARD97 | modeflag; -#else - psh.dwFlags = PSH_WIZARD | modeflag; -#endif - psh.hwndParent = NULL; - psh.hInstance = GetModuleHandle(NULL); - psh.pszIcon = NULL; - psh.pszCaption = (LPSTR) "Cell Properties"; - psh.nPages = pages.size(); - psh.nStartPage = 0; - psh.phpage = phpage; - psh.pfnCallback = NULL; -} - -DWORD CWizard::PageID(unsigned index) -{ - if (index < pages.size() && IS_INTRESOURCE(pages[index].pszTemplate)) - return (DWORD)pages[index].pszTemplate; - return (DWORD)-1; -} - -unsigned CWizard::PageIndex(PROPSHEETPAGE *psp) -{ - for (unsigned i = 0; i < pages.size(); i++) - { - if (IS_INTRESOURCE(psp->pszTemplate) || IS_INTRESOURCE(pages[i].pszTemplate )) - { - if (psp->pszTemplate == pages[i].pszTemplate) - return i; - } - else if (psp->pszTemplate && pages[i].pszTemplate) - { - if (strcmp(psp->pszTemplate, pages[i].pszTemplate) == 0) - return i; - } - } - return (unsigned)-1; -} - -INT_PTR CWizard::DlgDispatch(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - return CBaseDialog::DlgDispatch(hwndDlg, uMsg, wParam, lParam); -} - -INT_PTR CWizard::PageDispatch(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam, PROPSHEETPAGE *psp) -{ - LPNMHDR pnmh = (LPNMHDR)lParam; - DWORD flags; - unsigned pageindex; - switch (uMsg) - { - case WM_NOTIFY: - switch (pnmh->code) - { - case PSN_SETACTIVE: -#ifdef _DEBUG - printf("PSN_SETACTIVE %d\n", PageIndex(psp)); -#endif - pageindex = PageIndex(psp); - if (pageindex != (unsigned)-1) - { - flags = 0; - if (pageindex > 0) - flags |= PSWIZB_BACK; - if ((unsigned)pageindex + 1 == pages.size()) - flags |= PSWIZB_FINISH; - if ((unsigned)pageindex + 1 < pages.size()) - flags |= PSWIZB_NEXT; - PropSheet_SetWizButtons(GetParent(hwndDlg), flags); - } - WizardActivate(hwndDlg, pageindex); - break; - case PSN_WIZNEXT: - if (WizardNext(hwndDlg, PageIndex(psp))) - return TRUE; - break; - case PSN_WIZBACK: - if (WizardBack(hwndDlg, PageIndex(psp))) - return TRUE; - break; - case PSN_WIZFINISH: - if (WizardFinish(hwndDlg, PageIndex(psp))) - return TRUE; - DestroyWindow(GetParent(hwndDlg)); - case PSN_RESET: - if (WizardReset(hwndDlg, PageIndex(psp))) - return TRUE; - DestroyWindow(GetParent(hwndDlg)); - break; - } - } - return DlgDispatch(hwndDlg, uMsg, wParam, lParam); -} - - -INT_PTR CALLBACK CWizard::WizardDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - MessageDebug::debug(hwndDlg, uMsg, wParam, lParam, __FUNCTION__); - PROPSHEETPAGE *psp = (PROPSHEETPAGE*)lParam; - switch (uMsg) - { - case WM_INITDIALOG: - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)psp); - break; - } - psp = (PROPSHEETPAGE*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - CWizard* wizard = psp?(CWizard*)psp->lParam:NULL; - if (wizard != NULL) - return wizard->PageDispatch(hwndDlg, uMsg, wParam, lParam, psp); - return FALSE; -} - diff --git a/xorg-server/hw/xwin/xlaunch/window/wizard.h b/xorg-server/hw/xwin/xlaunch/window/wizard.h deleted file mode 100644 index a2361c51c..000000000 --- a/xorg-server/hw/xwin/xlaunch/window/wizard.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2005 Alexander Gottwald - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name(s) of the above copyright - * holders shall not be used in advertising or otherwise to promote the sale, - * use or other dealings in this Software without prior written authorization. - */ -#ifndef __WIZARD_H__ -#define __WIZARD_H__ - -#include "dialog.h" -#include - -#define _WIN32_IE 0x0500 -#include - -class CWizard : public CBaseDialog -{ - private: - std::vector pages; - void PrepareSheetHeader(PROPSHEETHEADER &psh, BOOL modal); - protected: - virtual HWND CreateWindowHandle(); - static INT_PTR CALLBACK WizardDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); - virtual INT_PTR DlgDispatch(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); - virtual INT_PTR PageDispatch(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam, PROPSHEETPAGE *psp); - virtual unsigned PageIndex(PROPSHEETPAGE *psp); - virtual DWORD PageID(unsigned index); - virtual BOOL WizardNext(HWND hwndDlg, unsigned index) { return FALSE; } - virtual BOOL WizardBack(HWND hwndDlg, unsigned index) { return FALSE; } - virtual BOOL WizardFinish(HWND hwndDlg, unsigned index) { return FALSE; } - virtual BOOL WizardReset(HWND hwndDlg, unsigned index) { return FALSE; } - virtual BOOL WizardActivate(HWND hwndDlg, unsigned index) { return FALSE; } - public: - CWizard(); - void AddPage(const PROPSHEETPAGE &page); - void AddPage(const char *page, HINSTANCE instance = NULL); - void AddPage(DWORD id, DWORD title, DWORD subtitle, HINSTANCE instance = NULL); - virtual int ShowModal(); -}; -#endif -- cgit v1.2.3