xserver: Branch 'xquartz-composite' - 321 commits

Ben Byer bbyer at kemper.freedesktop.org
Sun Apr 20 23:58:19 PDT 2008


Rebased ref, commits from common ancestor:
commit c06b6d622aee2b03a4c28b53a68ed288019e8290
Author: Ben Byer <bbyer at bbyer.local>
Date:   Sun Apr 20 23:55:36 2008 -0700

    all of this debug-dust sprinkled throughout, and it still doesn't work :(

diff --git a/composite/compalloc.c b/composite/compalloc.c
index 006e808..f25e73d 100644
--- a/composite/compalloc.c
+++ b/composite/compalloc.c
@@ -462,8 +462,9 @@ compNewPixmap (WindowPtr pWin, int x, int y, int w, int h)
     WindowPtr	    pParent = pWin->parent;
     PixmapPtr	    pPixmap;
 
+    ErrorF("compNewPixmap(%p, %d, %d, %d, %d)=", pWin, x, y, w, h);
     pPixmap = (*pScreen->CreatePixmap) (pScreen, w, h, pWin->drawable.depth);
-
+    ErrorF("%p\n", pPixmap);
     if (!pPixmap)
 	return 0;
     
diff --git a/composite/compwindow.c b/composite/compwindow.c
index 33192ad..7776421 100644
--- a/composite/compwindow.c
+++ b/composite/compwindow.c
@@ -45,6 +45,8 @@
 #endif
 
 #include "compint.h"
+#include "../miext/rootless/rootlessCommon.h"
+#include "../miext/rootless/rootlessWindow.h"
 
 #ifdef COMPOSITE_DEBUG
 static int
@@ -147,7 +149,7 @@ compCheckRedirect (WindowPtr pWin)
 
     should = pWin->realized && (pWin->drawable.class != InputOnly) &&
 	     (cw != NULL);
-    
+    ErrorF("compCheckRedirect(%p), should = %d\n", pWin, should);
     /* Never redirect the overlay window */
     if (cs->pOverlayWin != NULL) {
 	if (pWin == cs->pOverlayWin) {
@@ -614,6 +616,7 @@ compCreateWindow (WindowPtr pWin)
     CompScreenPtr	cs = GetCompScreen (pScreen);
     Bool		ret;
 
+    ErrorF("compCreateWindow(%p)\n", pWin);
     pScreen->CreateWindow = cs->CreateWindow;
     ret = (*pScreen->CreateWindow) (pWin);
     if (pWin->parent && ret)
@@ -742,7 +745,14 @@ compWindowUpdateAutomatic (WindowPtr pWin)
 						 &subwindowMode,
 						 serverClient,
 						 &error);
-    
+					RootlessFrameID rFrameID;
+    fprintf(stderr, "compWindowUpdateAutomatic(%p), parent = %p\n", pWin, pWin->parent);
+	if(pWin->parent == NULL) {
+		fprintf(stderr, "calling RootlessFrameForWindow(%p, true)\n", pWin);
+		rFrameID = RootlessFrameForWindow(pWin, TRUE);
+		fprintf(stderr, "Got frame id = %d\n", rFrameID);
+		/* insert magic here */
+	}
     /*
      * First move the region from window to screen coordinates
      */
diff --git a/fb/fbfill.c b/fb/fbfill.c
index 0f86f2f..c094e76 100644
--- a/fb/fbfill.c
+++ b/fb/fbfill.c
@@ -44,7 +44,7 @@ fbFill (DrawablePtr pDrawable,
         return;
 
     fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
-
+#define FB_ACCESS_WRAPPER //(whatever the hell that is
     switch (pGC->fillStyle) {
     case FillSolid:
 #ifndef FB_ACCESS_WRAPPER
diff --git a/fb/fbutil.c b/fb/fbutil.c
index fae42d9..5b7e148 100644
--- a/fb/fbutil.c
+++ b/fb/fbutil.c
@@ -386,7 +386,6 @@ void _fbGetDrawable(DrawablePtr pDrawable, FbBits ** pointer, int *stride,
       assert(_pPix->type == DRAWABLE_PIXMAP);
       break;
     case DRAWABLE_WINDOW:
-      ErrorF("drawable type is %d\n", pDrawable->type);
       _pPix = fbGetWindowPixmap(pDrawable);
       assert(_pPix->type == DRAWABLE_PIXMAP);
       *xoff = __fbPixOffXWin(_pPix);
diff --git a/include/pixmapstr.h b/include/pixmapstr.h
index 4594882..73adb09 100644
--- a/include/pixmapstr.h
+++ b/include/pixmapstr.h
@@ -89,6 +89,8 @@ typedef struct _Pixmap {
 #ifdef COMPOSITE
     short		screen_x;
     short		screen_y;
+#else
+#error FAIL
 #endif
 } PixmapRec;
 
diff --git a/miext/rootless/rootlessCommon.c b/miext/rootless/rootlessCommon.c
index 562f655..c10f103 100644
--- a/miext/rootless/rootlessCommon.c
+++ b/miext/rootless/rootlessCommon.c
@@ -173,6 +173,7 @@ void RootlessStartDrawing(WindowPtr pWindow)
     }
 
     PixmapPtr curPixmap = pScreen->GetWindowPixmap(pWindow);
+    ErrorF("curPixmap = %p\n", curPixmap);
     if (curPixmap == winRec->pixmap)
     {
         RL_DEBUG_MSG("Window %p already has winRec->pixmap %p; not pushing\n", pWindow, winRec->pixmap);
diff --git a/miext/rootless/rootlessCommon.h b/miext/rootless/rootlessCommon.h
index 62524b9..e20366b 100644
--- a/miext/rootless/rootlessCommon.h
+++ b/miext/rootless/rootlessCommon.h
@@ -235,6 +235,7 @@ extern RegionRec rootlessHugeRoot;
  */
 #define SetPixmapBaseToScreen(pix, _x, _y) {                                \
     PixmapPtr   _pPix = (PixmapPtr) (pix);                                  \
+    ErrorF("SetPixmapBaseToScreen(%p, %d, %d)\n", _pPix, (_x), (_y));       \
     _pPix->devPrivate.ptr = (char *) (_pPix->devPrivate.ptr) -              \
                             ((int)(_x) * _pPix->drawable.bitsPerPixel/8 +   \
                              (int)(_y) * _pPix->devKind);                   \
diff --git a/miext/rootless/rootlessConfig.h b/miext/rootless/rootlessConfig.h
index 50bac3f..cfe4e69 100644
--- a/miext/rootless/rootlessConfig.h
+++ b/miext/rootless/rootlessConfig.h
@@ -41,7 +41,7 @@
 # define ROOTLESS_REDISPLAY_DELAY 10
 # define ROOTLESS_RESIZE_GRAVITY TRUE
 # undef  ROOTLESS_TRACK_DAMAGE
-/*# define ROOTLESSDEBUG*/
+# define ROOTLESSDEBUG
 
 /* Bit mask for alpha channel with a particular number of bits per
    pixel. Note that we only care for 32bpp data. Mac OS X uses planar
diff --git a/miext/rootless/rootlessScreen.c b/miext/rootless/rootlessScreen.c
index 503d57c..aeab767 100644
--- a/miext/rootless/rootlessScreen.c
+++ b/miext/rootless/rootlessScreen.c
@@ -665,16 +665,16 @@ RootlessWrap(ScreenPtr pScreen)
     WRAP(CreateScreenResources);
     WRAP(CloseScreen);
     WRAP(CreateGC);
-    WRAP(PaintWindowBackground);
-    WRAP(PaintWindowBorder);
-    WRAP(CopyWindow);
-    WRAP(GetImage);
+//    WRAP(PaintWindowBackground);
+//    WRAP(PaintWindowBorder);
+//    WRAP(CopyWindow);
+//    WRAP(GetImage);
     WRAP(SourceValidate);
     WRAP(CreateWindow);
     WRAP(DestroyWindow);
     WRAP(RealizeWindow);
     WRAP(UnrealizeWindow);
-    WRAP(MoveWindow);
+    //    WRAP(MoveWindow);
     WRAP(PositionWindow);
     WRAP(ResizeWindow);
     WRAP(RestackWindow);
diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index 453f7d1..333e9d3 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -213,7 +213,23 @@ RootlessCreateWindow(WindowPtr pWin)
 
     if (pWin->parent) {
         NORMAL_ROOT(pWin);
-    }
+    } else {
+      ErrorF("RootlessCreateWindow(pwin=%p, parent=%p)\n",
+	     pWin, pWin->parent);
+      assert(compRedirectWindow(serverClient, pWin, CompositeRedirectAutomatic) == Success);
+      compCheckRedirect(pWin);
+            assert(compRedirectSubwindows(serverClient, pWin, CompositeRedirectAutomatic) == Success);
+      compCheckRedirect(pWin);
+           
+#if 0
+     if(pWin->parent == NULL) {
+              fprintf(stderr, "calling RootlessFrameForWindow(%p, true)\n", pWin);
+              rFrameID = RootlessFrameForWindow(pWin, TRUE);
+              fprintf(stderr, "Got frame id = %d\n", rFrameID);
+               /* insert magic here */
+      }
+#endif
+}
 
     SCREEN_WRAP(pWin->drawable.pScreen, CreateWindow);
 
commit 61c79f342e82dc1e10d88f0c10dd7d928da53459
Author: Ben Byer <bbyer at bbyer.local>
Date:   Sun Apr 20 04:50:48 2008 -0700

    Don't paint the background in Rootless mode

diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index 45ec9f3..c2d2ab8 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -287,7 +287,7 @@ void QuartzDisplayChangedHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev,
     pRoot = WindowTable[pScreen->myNum];
     AppleWMSetScreenOrigin(pRoot);
     pScreen->ResizeWindow(pRoot, x - sx, y - sy, width, height, NULL);
-    miPaintWindow(pRoot, &pRoot->borderClip,  PW_BACKGROUND);
+    //    miPaintWindow(pRoot, &pRoot->borderClip,  PW_BACKGROUND);
 //    QuartzIgnoreNextWarpCursor();
     DefineInitialRootWindow(pRoot);
 
commit 6877235d176dc534ee6ac655182d939fe83f3117
Author: Ben Byer <bbyer at bbyer.local>
Date:   Sun Apr 20 04:49:57 2008 -0700

    converted fbGetDrawable into a function, for extra debugging bliss

diff --git a/fb/fb.h b/fb/fb.h
index 65fa173..a37eab4 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -707,6 +707,7 @@ typedef struct {
 #define __fbPixOffXPix(pPix)	(__fbPixDrawableX(pPix))
 #define __fbPixOffYPix(pPix)	(__fbPixDrawableY(pPix))
 
+#if 0
 #define fbGetDrawable(pDrawable, pointer, stride, bpp, xoff, yoff) { \
     PixmapPtr   _pPix; \
     if ((pDrawable)->type != DRAWABLE_PIXMAP) { \
@@ -724,6 +725,10 @@ typedef struct {
     (bpp) = _pPix->drawable.bitsPerPixel;  (void)(bpp); \
     CHECK_NULL(pointer); \
 }
+#else
+	#define fbGetDrawable(pDrawable, pointer, stride, bpp, xoff, yoff) \
+		_fbGetDrawable(pDrawable, &(pointer), &(stride), &(bpp), &(xoff), &(yoff))
+#endif
 
 #define fbGetStipDrawable(pDrawable, pointer, stride, bpp, xoff, yoff) { \
     PixmapPtr   _pPix; \
diff --git a/fb/fbutil.c b/fb/fbutil.c
index 5e23297..fae42d9 100644
--- a/fb/fbutil.c
+++ b/fb/fbutil.c
@@ -360,3 +360,46 @@ const FbBits	* const fbStippleTable[] = {
     0,
     fbStipple8Bits,
 };
+
+static char *_fb_drawable_type_names[] = {
+  "DRAWABLE_WINDOW",
+  "DRAWABLE_PIXMAP",
+  "UNDRAWABLE_WINDOW",
+  "DRAWABLE_BUFFER"
+};
+
+void _fbGetDrawable(DrawablePtr pDrawable, FbBits ** pointer, int *stride, 
+		    int *bpp, int *xoff, int *yoff) { 
+    PixmapPtr   _pPix;
+    switch (pDrawable->type) {
+    case DRAWABLE_PIXMAP:
+      _pPix = (PixmapPtr) pDrawable;
+      *xoff = __fbPixOffXPix(_pPix);
+      *yoff = __fbPixOffYPix(_pPix);
+      break;
+    case DRAWABLE_BUFFER:
+      ErrorF("Invalid call to fbGetDrawable on a non-window buffer\n");
+      assert(pDrawable->type != DRAWABLE_BUFFER); // die
+      break;
+    case UNDRAWABLE_WINDOW:
+      ErrorF("Undrawable window?\n");
+      assert(_pPix->type == DRAWABLE_PIXMAP);
+      break;
+    case DRAWABLE_WINDOW:
+      ErrorF("drawable type is %d\n", pDrawable->type);
+      _pPix = fbGetWindowPixmap(pDrawable);
+      assert(_pPix->type == DRAWABLE_PIXMAP);
+      *xoff = __fbPixOffXWin(_pPix);
+      *yoff = __fbPixOffYWin(_pPix);
+      break;
+    default: 
+      FatalError("Unknown drawable type %d\n", pDrawable->type);
+      break;
+    }
+
+    fbPrepareAccess(pDrawable);
+    *pointer = (FbBits *) _pPix->devPrivate.ptr;
+    *stride = ((int) _pPix->devKind) / sizeof (FbBits);
+    *bpp = _pPix->drawable.bitsPerPixel;
+    CHECK_NULL(pointer);
+  }
commit b83ceaaabc989c80e78391e1d81e17d6d9c31afe
Author: Ben Byer <bbyer at bbyer.local>
Date:   Fri Apr 18 23:05:35 2008 -0700

    add CompWindowUpdateAutomatic call

diff --git a/hw/xquartz/quartzCocoa.m b/hw/xquartz/quartzCocoa.m
index d8f9c69..9570283 100644
--- a/hw/xquartz/quartzCocoa.m
+++ b/hw/xquartz/quartzCocoa.m
@@ -47,10 +47,12 @@
 #undef BOOL
 
 #include "pseudoramiX.h"
+#include <X11/extensions/composite.h>
 
 extern void FatalError(const char *, ...);
 extern char *display;
 extern int noPanoramiXExtension;
+int comp_redirect_done = 0;
 
 /*
  * QuartzWriteCocoaPasteboard
@@ -129,7 +131,7 @@ void QuartzBlockHandler(
     pointer pReadmask)
 {
     static NSAutoreleasePool *aPool = nil;
-
+//    ErrorF("QuartzBlockHandler()\n");
     [aPool release];
     aPool = [[NSAutoreleasePool alloc] init];
 }
@@ -143,5 +145,12 @@ void QuartzWakeupHandler(
     int result,
     pointer pReadmask)
 {
-    // nothing here
+//  ErrorF("QuartzWakeupHandler()\n");
+  if(comp_redirect_done) return;
+  comp_redirect_done=1;
+  ErrorF("QuartzWakeupHandler(%p,%d,%p)\n", blockData, result, pReadmask);
+//  ErrorF("requestingClient=%p\n",requestingClient);
+//  ErrorF("serverClient=%p\n",serverClient);
+  int retval=compRedirectSubwindows (serverClient, GetCurrentRootWindow(), CompositeRedirectAutomatic);
+  ErrorF("compRedirectSubwindows returned %d\n",retval);
 }
commit 1695fa6268a1e64ef57c5f599bd6fbbecc499cc5
Author: Ben Byer <bbyer at bbyer.local>
Date:   Fri Apr 18 23:02:22 2008 -0700

    properly initialise the optional member

diff --git a/dix/window.c b/dix/window.c
index f5a6a4b..9f4ae71 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -3689,6 +3689,7 @@ MakeWindowOptional (WindowPtr pWin)
     optional->userProps = NULL;
     optional->backingBitPlanes = ~0L;
     optional->backingPixel = 0;
+    optional->actualised = 0;
 #ifdef SHAPE
     optional->boundingShape = NULL;
     optional->clipShape = NULL;
diff --git a/fb/fbwindow.c b/fb/fbwindow.c
index b96d68b..da2548d 100644
--- a/fb/fbwindow.c
+++ b/fb/fbwindow.c
@@ -31,6 +31,7 @@
 Bool
 fbCreateWindow(WindowPtr pWin)
 {
+    MakeWindowOptional(pWin);
     pWin->optional->actualised = 1;
 #ifndef FB_NO_WINDOW_PIXMAPS
     pWin->devPrivates[fbWinPrivateIndex].ptr = 
commit fcebaa84960e44e7b6b83fe1162a83948839923f
Author: Ben Byer <bbyer at bbyer.local>
Date:   Fri Apr 18 17:31:06 2008 -0700

    re-enable COMPOSITE by default

diff --git a/configure.ac b/configure.ac
index 125f1f3..0ac7e53 100644
--- a/configure.ac
+++ b/configure.ac
@@ -495,7 +495,7 @@ AC_ARG_ENABLE(glx-tls,        AS_HELP_STRING([--enable-glx-tls], [Build GLX with
                                 [GLX_USE_TLS=no])
 
 dnl Extensions.
-AC_ARG_ENABLE(composite,      AS_HELP_STRING([--disable-composite], [Build Composite extension (default: enabled)]), [COMPOSITE=$enableval], [COMPOSITE=auto])
+AC_ARG_ENABLE(composite,      AS_HELP_STRING([--disable-composite], [Build Composite extension (default: enabled)]), [COMPOSITE=$enableval], [COMPOSITE=yes])
 AC_ARG_ENABLE(mitshm,         AS_HELP_STRING([--disable-shm], [Build SHM extension (default: enabled)]), [MITSHM=$enableval], [MITSHM=yes])
 AC_ARG_ENABLE(xres,           AS_HELP_STRING([--disable-xres], [Build XRes extension (default: enabled)]), [RES=$enableval], [RES=yes])
 AC_ARG_ENABLE(xtrap,          AS_HELP_STRING([--disable-xtrap], [Build XTrap extension (default: enabled)]), [XTRAP=$enableval], [XTRAP=yes])
commit 4db1e4a2187e8b7a1e3ab78f644caba143b8b1e4
Author: Ben Byer <bbyer at bbyer.local>
Date:   Fri Apr 18 17:30:28 2008 -0700

    patches to add Actualized flag, from daniels

diff --git a/fb/fbarc.c b/fb/fbarc.c
index 3f46bd4..ef58b7a 100644
--- a/fb/fbarc.c
+++ b/fb/fbarc.c
@@ -44,6 +44,9 @@ fbPolyArc (DrawablePtr	pDrawable,
 	   xArc		*parcs)
 {
     FbArc	arc;
+
+    if (pDrawable->type == DRAWABLE_WINDOW && !wActualised((WindowPtr)pDrawable))
+        return;
     
     if (pGC->lineWidth == 0)
     {
diff --git a/fb/fbcopy.c b/fb/fbcopy.c
index 68f403f..2db88a7 100644
--- a/fb/fbcopy.c
+++ b/fb/fbcopy.c
@@ -51,7 +51,11 @@ fbCopyNtoN (DrawablePtr	pSrcDrawable,
     FbStride	dstStride;
     int		dstBpp;
     int		dstXoff, dstYoff;
-    
+
+    if ((pSrcDrawable->type == DRAWABLE_WINDOW && wActualised((WindowPtr)pSrcDrawable)) ||
+        (pDstDrawable->type == DRAWABLE_WINDOW && wActualised((WindowPtr)pDstDrawable)))
+        return;
+
     fbGetDrawable (pSrcDrawable, src, srcStride, srcBpp, srcXoff, srcYoff);
     fbGetDrawable (pDstDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
 
@@ -123,6 +127,10 @@ fbCopy1toN (DrawablePtr	pSrcDrawable,
     int		dstBpp;
     int		dstXoff, dstYoff;
 
+    if ((pSrcDrawable->type == DRAWABLE_WINDOW && wActualised((WindowPtr)pSrcDrawable)) ||
+        (pDstDrawable->type == DRAWABLE_WINDOW && wActualised((WindowPtr)pDstDrawable)))
+        return;
+
     fbGetDrawable (pSrcDrawable, src, srcStride, srcBpp, srcXoff, srcYoff);
     fbGetDrawable (pDstDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
 
@@ -188,6 +196,10 @@ fbCopyNto1 (DrawablePtr	pSrcDrawable,
 {
     FbGCPrivPtr	pPriv = fbGetGCPrivate (pGC);
     
+    if ((pSrcDrawable->type == DRAWABLE_WINDOW && wActualised((WindowPtr)pSrcDrawable)) ||
+        (pDstDrawable->type == DRAWABLE_WINDOW && wActualised((WindowPtr)pDstDrawable)))
+        return;
+
     while (nbox--)
     {
 	if (pDstDrawable->bitsPerPixel == 1)
@@ -307,6 +319,10 @@ fbCopyRegion (DrawablePtr   pSrcDrawable,
     int		nbox;
     BoxPtr	pboxNew1, pboxNew2, pboxBase, pboxNext, pboxTmp;
     
+    if ((pSrcDrawable->type == DRAWABLE_WINDOW && wActualised((WindowPtr)pSrcDrawable)) ||
+        (pDstDrawable->type == DRAWABLE_WINDOW && wActualised((WindowPtr)pDstDrawable)))
+        return;
+
     pbox = REGION_RECTS(pDstRegion);
     nbox = REGION_NUM_RECTS(pDstRegion);
     
@@ -436,6 +452,10 @@ fbDoCopy (DrawablePtr	pSrcDrawable,
     Bool	fastDst = FALSE;    /* for fast clipping with one rect dest */
     Bool	fastExpose = FALSE; /* for fast exposures with pixmap source */
 
+    if ((pSrcDrawable->type == DRAWABLE_WINDOW && wActualised((WindowPtr)pSrcDrawable)) ||
+        (pDstDrawable->type == DRAWABLE_WINDOW && wActualised((WindowPtr)pDstDrawable)))
+        return;
+
     /* Short cut for unmapped windows */
 
     if (pDstDrawable->type == DRAWABLE_WINDOW && 
diff --git a/fb/fbfill.c b/fb/fbfill.c
index 831b1ce..0f86f2f 100644
--- a/fb/fbfill.c
+++ b/fb/fbfill.c
@@ -39,7 +39,10 @@ fbFill (DrawablePtr pDrawable,
     int		    dstBpp;
     int		    dstXoff, dstYoff;
     FbGCPrivPtr	    pPriv = fbGetGCPrivate(pGC);
-    
+
+    if (pDrawable->type == DRAWABLE_WINDOW && !wActualised((WindowPtr)pDrawable))
+        return;
+
     fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
 
     switch (pGC->fillStyle) {
diff --git a/fb/fbfillrect.c b/fb/fbfillrect.c
index 4e4edb3..21bddbb 100644
--- a/fb/fbfillrect.c
+++ b/fb/fbfillrect.c
@@ -41,6 +41,9 @@ fbPolyFillRect(DrawablePtr  pDrawable,
     int		    xorg, yorg;
     int		    n;
 
+    if (pDrawable->type == DRAWABLE_WINDOW && !wActualised((WindowPtr)pDrawable))
+        return;
+
     xorg = pDrawable->x;
     yorg = pDrawable->y;
     
diff --git a/fb/fbfillsp.c b/fb/fbfillsp.c
index 5d21472..29050aa 100644
--- a/fb/fbfillsp.c
+++ b/fb/fbfillsp.c
@@ -41,6 +41,9 @@ fbFillSpans (DrawablePtr    pDrawable,
     int		    fullX1, fullX2, fullY1;
     int		    partX1, partX2;
     
+    if (pDrawable->type == DRAWABLE_WINDOW && !wActualised((WindowPtr)pDrawable))
+        return;
+
     pextent = REGION_EXTENTS(pGC->pScreen, pClip);
     extentX1 = pextent->x1;
     extentY1 = pextent->y1;
diff --git a/fb/fbglyph.c b/fb/fbglyph.c
index 2c19b74..363b248 100644
--- a/fb/fbglyph.c
+++ b/fb/fbglyph.c
@@ -281,6 +281,9 @@ fbPolyGlyphBlt (DrawablePtr	pDrawable,
     int		    dstBpp = 0;
     int		    dstXoff = 0, dstYoff = 0;
     
+    if (pDrawable->type == DRAWABLE_WINDOW && !wActualised((WindowPtr)pDrawable))
+        return;
+
     glyph = 0;
     if (pGC->fillStyle == FillSolid && pPriv->and == 0)
     {
@@ -374,6 +377,9 @@ fbImageGlyphBlt (DrawablePtr	pDrawable,
     int		    dstBpp = 0;
     int		    dstXoff = 0, dstYoff = 0;
     
+    if (pDrawable->type == DRAWABLE_WINDOW && !wActualised((WindowPtr)pDrawable))
+        return;
+
     glyph = 0;
     if (pPriv->and == 0)
     {
diff --git a/fb/fbimage.c b/fb/fbimage.c
index 2b9ac27..154bfc5 100644
--- a/fb/fbimage.c
+++ b/fb/fbimage.c
@@ -45,6 +45,9 @@ fbPutImage (DrawablePtr	pDrawable,
     FbStride	    srcStride;
     FbStip	    *src = (FbStip *) pImage;
     
+    if (pDrawable->type == DRAWABLE_WINDOW && !wActualised((WindowPtr)pDrawable))
+        return;
+
     x += pDrawable->x;
     y += pDrawable->y;
     
diff --git a/fb/fbline.c b/fb/fbline.c
index 2cee123..986019a 100644
--- a/fb/fbline.c
+++ b/fb/fbline.c
@@ -37,6 +37,9 @@ fbZeroLine (DrawablePtr	pDrawable,
     int		    x, y;
     int		    dashOffset;
 
+    if (pDrawable->type == DRAWABLE_WINDOW && !wActualised((WindowPtr)pDrawable))
+        return;
+
     x = pDrawable->x;
     y = pDrawable->y;
     x1 = ppt->x;
@@ -71,6 +74,9 @@ fbZeroSegment (DrawablePtr  pDrawable,
     int	    x, y;
     Bool    drawLast = pGC->capStyle != CapNotLast;
     
+    if (pDrawable->type == DRAWABLE_WINDOW && !wActualised((WindowPtr)pDrawable))
+        return;
+
     x = pDrawable->x;
     y = pDrawable->y;
     while (nseg--)
@@ -111,6 +117,9 @@ fbPolyLine (DrawablePtr	pDrawable,
 {
     void	(*line) (DrawablePtr, GCPtr, int mode, int npt, DDXPointPtr ppt);
     
+    if (pDrawable->type == DRAWABLE_WINDOW && !wActualised((WindowPtr)pDrawable))
+        return;
+
     if (pGC->lineWidth == 0)
     {
 	line = fbZeroLine;
@@ -148,6 +157,9 @@ fbPolySegment (DrawablePtr  pDrawable,
 {
     void    (*seg) (DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment *pseg);
 
+    if (pDrawable->type == DRAWABLE_WINDOW && !wActualised((WindowPtr)pDrawable))
+        return;
+
     if (pGC->lineWidth == 0)
     {
 	seg = fbZeroSegment;
diff --git a/fb/fbpoint.c b/fb/fbpoint.c
index c0ea8ba..66a2f15 100644
--- a/fb/fbpoint.c
+++ b/fb/fbpoint.c
@@ -127,6 +127,9 @@ fbPolyPoint (DrawablePtr    pDrawable,
     BoxPtr	pBox;
     int		nBox;
     
+    if (pDrawable->type == DRAWABLE_WINDOW && !wActualised((WindowPtr)pDrawable))
+        return;
+
     /* make pointlist origin relative */
     ppt = pptInit;
     npt = nptInit;
diff --git a/fb/fbpush.c b/fb/fbpush.c
index 891572f..d28365f 100644
--- a/fb/fbpush.c
+++ b/fb/fbpush.c
@@ -45,6 +45,9 @@ fbPushPattern (DrawablePtr  pDrawable,
     int		    w;
     int		    lenspan;
     
+    if (pDrawable->type == DRAWABLE_WINDOW && !wActualised((WindowPtr)pDrawable))
+        return;
+
     src += srcX >> FB_STIP_SHIFT;
     srcX &= FB_STIP_MASK;
     
@@ -115,6 +118,9 @@ fbPushFill (DrawablePtr	pDrawable,
 {
     FbGCPrivPtr	pPriv = fbGetGCPrivate(pGC);
     
+    if (pDrawable->type == DRAWABLE_WINDOW && !wActualised((WindowPtr)pDrawable))
+        return;
+
     if (pGC->fillStyle == FillSolid)
     {
 	FbBits	    *dst;
@@ -190,6 +196,9 @@ fbPushImage (DrawablePtr    pDrawable,
     BoxPtr	pbox;
     int		x1, y1, x2, y2;
     
+    if (pDrawable->type == DRAWABLE_WINDOW && !wActualised((WindowPtr)pDrawable))
+        return;
+
     for (nbox = REGION_NUM_RECTS (pClip),
 	 pbox = REGION_RECTS(pClip);
 	 nbox--;
@@ -237,6 +246,9 @@ fbPushPixels (GCPtr	    pGC,
     int		stipBpp;
     int		stipXoff, stipYoff; /* Assumed to be zero */
 
+    if (pDrawable->type == DRAWABLE_WINDOW && !wActualised((WindowPtr)pDrawable))
+        return;
+
     fbGetStipDrawable (&pBitmap->drawable, stip, stipStride, stipBpp, stipXoff, stipYoff);
 
     fbPushImage (pDrawable, pGC,
diff --git a/fb/fbseg.c b/fb/fbseg.c
index 80ce740..dbeea6f 100644
--- a/fb/fbseg.c
+++ b/fb/fbseg.c
@@ -57,6 +57,9 @@ fbBresSolid (DrawablePtr    pDrawable,
     FbStip	mask, mask0;
     FbStip	bits;
     
+    if (pDrawable->type == DRAWABLE_WINDOW && !wActualised((WindowPtr)pDrawable))
+        return;
+
     fbGetStipDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
     dst += ((y1 + dstYoff) * dstStride);
     x1 = (x1 + dstXoff) * dstBpp;
@@ -146,6 +149,9 @@ fbBresDash (DrawablePtr	pDrawable,
     Bool	even;
     Bool	doOdd;
     
+    if (pDrawable->type == DRAWABLE_WINDOW && !wActualised((WindowPtr)pDrawable))
+        return;
+
     fbGetStipDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
     doOdd = pGC->lineStyle == LineDoubleDash;
 
@@ -217,6 +223,9 @@ fbBresFill (DrawablePtr	pDrawable,
 	    int		e3,
 	    int		len)
 {
+    if (pDrawable->type == DRAWABLE_WINDOW && !wActualised((WindowPtr)pDrawable))
+        return;
+
     while (len--)
     {
 	fbFill (pDrawable, pGC, x1, y1, 1, 1);
@@ -248,6 +257,9 @@ fbSetFg (DrawablePtr	pDrawable,
 	 GCPtr		pGC,
 	 Pixel		fg)
 {
+    if (pDrawable->type == DRAWABLE_WINDOW && !wActualised((WindowPtr)pDrawable))
+        return;
+
     if (fg != pGC->fgPixel)
     {
 	DoChangeGC (pGC, GCForeground, (XID *) &fg, FALSE);
@@ -277,6 +289,9 @@ fbBresFillDash (DrawablePtr pDrawable,
     Bool	doBg;
     Pixel	fg, bg;
     
+    if (pDrawable->type == DRAWABLE_WINDOW && !wActualised((WindowPtr)pDrawable))
+        return;
+
     fg = pGC->fgPixel;
     bg = pGC->bgPixel;
     
@@ -357,6 +372,9 @@ fbBresSolid24RRop (DrawablePtr  pDrawable,
     int		rot;
     FbStip	andT, xorT;
     
+    if (pDrawable->type == DRAWABLE_WINDOW && !wActualised((WindowPtr)pDrawable))
+        return;
+
     fbGetStipDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
     dst += ((y1 + dstYoff) * dstStride);
     x1 = (x1 + dstXoff) * 24;
@@ -439,6 +457,9 @@ fbBresDash24RRop (DrawablePtr	pDrawable,
     Bool	even;
     Bool	doOdd;
     
+    if (pDrawable->type == DRAWABLE_WINDOW && !wActualised((WindowPtr)pDrawable))
+        return;
+
     fbGetStipDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
     doOdd = pGC->lineStyle == LineDoubleDash;
 
@@ -521,6 +542,9 @@ fbSelectBres (DrawablePtr   pDrawable,
     int		dstBpp = pDrawable->bitsPerPixel;
     FbBres *	bres;
     
+    if (pDrawable->type == DRAWABLE_WINDOW && !wActualised((WindowPtr)pDrawable))
+        return;
+
     if (pGC->lineStyle == LineSolid)
     {
 	bres = fbBresFill;
@@ -589,6 +613,9 @@ fbBres (DrawablePtr	pDrawable,
 	int		e3,
 	int		len)
 {
+    if (pDrawable->type == DRAWABLE_WINDOW && !wActualised((WindowPtr)pDrawable))
+        return;
+
     (*fbSelectBres (pDrawable, pGC)) (pDrawable, pGC, dashOffset,
 				      signdx, signdy, axis, x1, y1,
 				      e, e1, e3, len);
@@ -622,6 +649,9 @@ fbSegment (DrawablePtr	pDrawable,
     unsigned int oc1;	/* outcode of point 1 */
     unsigned int oc2;	/* outcode of point 2 */
 
+    if (pDrawable->type == DRAWABLE_WINDOW && !wActualised((WindowPtr)pDrawable))
+        return;
+
     nBox = REGION_NUM_RECTS (pClip);
     pBox = REGION_RECTS (pClip);
     
diff --git a/fb/fbsetsp.c b/fb/fbsetsp.c
index 227ba4c..bf985a9 100644
--- a/fb/fbsetsp.c
+++ b/fb/fbsetsp.c
@@ -46,6 +46,9 @@ fbSetSpans (DrawablePtr	    pDrawable,
     int		    xoff;
     int		    x1, x2;
     
+    if (pDrawable->type == DRAWABLE_WINDOW && !wActualised((WindowPtr)pDrawable))
+        return;
+
 #ifdef FB_24_32BIT
     if (pDrawable->bitsPerPixel != BitsPerPixel(pDrawable->depth))
     {
diff --git a/fb/fbwindow.c b/fb/fbwindow.c
index 144f083..b96d68b 100644
--- a/fb/fbwindow.c
+++ b/fb/fbwindow.c
@@ -31,6 +31,7 @@
 Bool
 fbCreateWindow(WindowPtr pWin)
 {
+    pWin->optional->actualised = 1;
 #ifndef FB_NO_WINDOW_PIXMAPS
     pWin->devPrivates[fbWinPrivateIndex].ptr = 
 	(pointer) fbGetScreenPixmap(pWin->drawable.pScreen);
@@ -88,6 +89,10 @@ fbCopyWindowProc (DrawablePtr	pSrcDrawable,
     int		dstBpp;
     int		dstXoff, dstYoff;
     
+    if ((pSrcDrawable->type == DRAWABLE_WINDOW && !wActualised((WindowPtr)pSrcDrawable)) ||
+        (pDstDrawable->type == DRAWABLE_WINDOW && !wActualised((WindowPtr)pDstDrawable)))
+        return;
+
     fbGetDrawable (pSrcDrawable, src, srcStride, srcBpp, srcXoff, srcYoff);
     fbGetDrawable (pDstDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
     
@@ -286,6 +291,7 @@ fbFillRegionTiled (DrawablePtr	pDrawable,
 	}
     }
 #endif
+
     fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
     fbGetDrawable (&pTile->drawable, tile, tileStride, tileBpp, tileXoff, tileYoff);
     tileWidth = pTile->drawable.width;
diff --git a/include/windowstr.h b/include/windowstr.h
index d9b839b..ac3365c 100644
--- a/include/windowstr.h
+++ b/include/windowstr.h
@@ -79,6 +79,7 @@ typedef struct _WindowOpt {
     struct _OtherClients *otherClients;	   /* default: NULL */
     struct _GrabRec	*passiveGrabs;	   /* default: NULL */
     PropertyPtr		userProps;	   /* default: NULL */
+    unsigned int        actualised;        /* default: 0 */
     unsigned long	backingBitPlanes;  /* default: ~0L */
     unsigned long	backingPixel;	   /* default: 0 */
 #ifdef SHAPE
@@ -201,6 +202,7 @@ extern Mask	    DontPropagateMasks[];
 #endif
 #define wClient(w)		(clients[CLIENT_ID((w)->drawable.id)])
 #define wBorderWidth(w)		((int) (w)->borderWidth)
+#define wActualised(w)          wUseDefault(w, actualised, 0)
 
 /* true when w needs a border drawn. */
 
commit 1b4c37d8f9b517fbec5b94ed4e4a5e86a31472a5
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Thu Apr 17 11:06:54 2008 -0700

    XQuartz: Use strerror(errno)... cause I like text more than grepping header files

diff --git a/hw/xquartz/quartzKeyboard.c b/hw/xquartz/quartzKeyboard.c
index 56061fe..30eec1d 100644
--- a/hw/xquartz/quartzKeyboard.c
+++ b/hw/xquartz/quartzKeyboard.c
@@ -438,13 +438,13 @@ static Bool DarwinReadKeymapFile(NXKeyMapping *keyMap) {
 
     fref = fopen( darwinKeymapFile, "rb" );
     if (fref == NULL) {
-        ErrorF("Unable to open keymapping file '%s' (errno %d).\n",
-               darwinKeymapFile, errno);
+        ErrorF("Unable to open keymapping file '%s': %s.\n",
+               darwinKeymapFile, strerror(errno));
         return FALSE;
     }
     if (fstat(fileno(fref), &st) == -1) {
-        ErrorF("Could not stat keymapping file '%s' (errno %d).\n",
-               darwinKeymapFile, errno);
+        ErrorF("Could not stat keymapping file '%s': %s.\n",
+               darwinKeymapFile, strerror(errno));
         return FALSE;
     }
 
@@ -458,8 +458,8 @@ static Bool DarwinReadKeymapFile(NXKeyMapping *keyMap) {
     inBuffer = (char*) xalloc( st.st_size );
     bufferEnd = (int *) (inBuffer + st.st_size);
     if (fread(inBuffer, st.st_size, 1, fref) != 1) {
-        ErrorF("Could not read %qd bytes from keymapping file '%s' (errno %d).\n",
-               st.st_size, darwinKeymapFile, errno);
+        ErrorF("Could not read %qd bytes from keymapping file '%s': %s.\n",
+               st.st_size, darwinKeymapFile, strerror(errno));
         return FALSE;
     }
 
commit 57bb07320908b74facea0a97822bb19ed6f960a9
Author: Ben Byer <bbyer at apple.com>
Date:   Thu Apr 17 02:56:54 2008 -0700

    merged darwinKeyboard.[ch] into quartzKeyboard

diff --git a/hw/xquartz/Makefile.am b/hw/xquartz/Makefile.am
index 0753824..6854557 100644
--- a/hw/xquartz/Makefile.am
+++ b/hw/xquartz/Makefile.am
@@ -25,7 +25,6 @@ libXquartz_la_SOURCES = \
 	applewm.c \
 	darwin.c \
 	darwinEvents.c \
-	darwinKeyboard.c \
 	darwinXinput.c \
 	keysym2ucs.c \
 	pseudoramiX.c \
@@ -44,7 +43,6 @@ EXTRA_DIST = \
 	darwinClut8.h \
 	darwin.h \
 	darwinEvents.h \
-	darwinKeyboard.h \
 	keysym2ucs.h \
 	pseudoramiX.h \
 	quartz.h \
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index 2232cf5..b84ccbe 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -76,7 +76,7 @@
 
 #include "darwin.h"
 #include "darwinEvents.h"
-#include "darwinKeyboard.h"
+#include "quartzKeyboard.h"
 #include "quartz.h"
 //#include "darwinClut8.h"
 
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 37a66f7..260690c 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -48,7 +48,7 @@ in this Software without prior written authorization from The Open Group.
 
 #include "darwin.h"
 #include "quartz.h"
-#include "darwinKeyboard.h"
+#include "quartzKeyboard.h"
 #include "darwinEvents.h"
 
 #include <sys/types.h>
diff --git a/hw/xquartz/darwinKeyboard.c b/hw/xquartz/darwinKeyboard.c
deleted file mode 100644
index e29ba5d..0000000
--- a/hw/xquartz/darwinKeyboard.c
+++ /dev/null
@@ -1,971 +0,0 @@
-//=============================================================================
-//
-// Keyboard support for Xquartz
-//
-// Copyright (c) 2003, 2008 Apple, Inc.
-// Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
-// Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
-//
-// The code to parse the Darwin keymap is derived from dumpkeymap.c
-// by Eric Sunshine, which includes the following copyright:
-//
-// Copyright (C) 1999,2000 by Eric Sunshine <sunshine at sunshineco.com>
-// All rights reserved.
-//
-//-----------------------------------------------------------------------------
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-//   1. Redistributions of source code must retain the above copyright
-//      notice, this list of conditions and the following disclaimer.
-//   2. Redistributions in binary form must reproduce the above copyright
-//      notice, this list of conditions and the following disclaimer in the
-//      documentation and/or other materials provided with the distribution.
-//   3. The name of the author may not be used to endorse or promote products
-//      derived from this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
-// NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
-// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-//=============================================================================
-
-
-/*
-===========================================================================
-
- An X keyCode must be in the range XkbMinLegalKeyCode (8) to
- XkbMaxLegalKeyCode(255).
-
- The keyCodes we get from the kernel range from 0 to 127, so we need to
- offset the range before passing the keyCode to X.
-
- An X KeySym is an extended ascii code that is device independent.
-
- The modifier map is accessed by the keyCode, but the normal map is
- accessed by keyCode - MIN_KEYCODE.  Sigh.
-
-===========================================================================
-*/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-// Define this to get a diagnostic output to stderr which is helpful
-// in determining how the X server is interpreting the Darwin keymap.
-#define DUMP_DARWIN_KEYMAP
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <IOKit/hidsystem/event_status_driver.h>
-#include <IOKit/hidsystem/ev_keymap.h>
-#include <architecture/byte_order.h>  // For the NXSwap*
-#include "darwin.h"
-#include "darwinKeyboard.h"
-#include "quartzKeyboard.h"
-#include "quartzAudio.h"
-
-#ifdef NDEBUG
-#undef NDEBUG
-#include <assert.h>
-#define NDEBUG 1
-#else
-#include <assert.h>
-#endif
-
-#define AltMask         Mod1Mask
-#define MetaMask        Mod2Mask
-#define FunctionMask    Mod3Mask
-
-#define UK(a)           NoSymbol    // unknown symbol
-
-static KeySym const next_to_x[256] = {
-	NoSymbol,	NoSymbol,	NoSymbol,	XK_KP_Enter,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_BackSpace,	XK_Tab,		XK_Linefeed,	NoSymbol,
-	NoSymbol,	XK_Return,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	XK_Escape,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_space,	XK_exclam,	XK_quotedbl,	XK_numbersign,
-	XK_dollar,	XK_percent,	XK_ampersand,	XK_apostrophe,
-	XK_parenleft,	XK_parenright,	XK_asterisk,	XK_plus,
-	XK_comma,	XK_minus,	XK_period,	XK_slash,
-	XK_0,		XK_1,		XK_2,		XK_3,
-	XK_4,		XK_5,		XK_6,		XK_7,
-	XK_8,		XK_9,		XK_colon,	XK_semicolon,
-	XK_less,	XK_equal,	XK_greater,	XK_question,
-	XK_at,		XK_A,		XK_B,		XK_C,
-	XK_D,		XK_E,		XK_F,		XK_G,
-	XK_H,		XK_I,		XK_J,		XK_K,
-	XK_L,		XK_M,		XK_N,		XK_O,
-	XK_P,		XK_Q,		XK_R,		XK_S,
-	XK_T,		XK_U,		XK_V,		XK_W,
-	XK_X,		XK_Y,		XK_Z,		XK_bracketleft,
-	XK_backslash,	XK_bracketright,XK_asciicircum,	XK_underscore,
-	XK_grave,	XK_a,		XK_b,		XK_c,
-	XK_d,		XK_e,		XK_f,		XK_g,
-	XK_h,		XK_i,		XK_j,		XK_k,
-	XK_l,		XK_m,		XK_n,		XK_o,
-	XK_p,		XK_q,		XK_r,		XK_s,
-	XK_t,		XK_u,		XK_v,		XK_w,
-	XK_x,		XK_y,		XK_z,		XK_braceleft,
-	XK_bar,		XK_braceright,	XK_asciitilde,	XK_BackSpace,
-// 128
-	NoSymbol,	XK_Agrave,	XK_Aacute,	XK_Acircumflex,
-	XK_Atilde,	XK_Adiaeresis,	XK_Aring,	XK_Ccedilla,
-	XK_Egrave,	XK_Eacute,	XK_Ecircumflex,	XK_Ediaeresis,
-	XK_Igrave,	XK_Iacute,	XK_Icircumflex,	XK_Idiaeresis,
-// 144
-	XK_ETH,		XK_Ntilde,	XK_Ograve,	XK_Oacute,
-	XK_Ocircumflex,	XK_Otilde,	XK_Odiaeresis,	XK_Ugrave,
-	XK_Uacute,	XK_Ucircumflex,	XK_Udiaeresis,	XK_Yacute,
-	XK_THORN,	XK_mu,		XK_multiply,	XK_division,
-// 160
-	XK_copyright,	XK_exclamdown,	XK_cent,	XK_sterling,
-	UK(fraction),	XK_yen,		UK(fhook),	XK_section,
-	XK_currency,	XK_rightsinglequotemark,
-					XK_leftdoublequotemark,
-							XK_guillemotleft,
-	XK_leftanglebracket,
-			XK_rightanglebracket,
-					UK(filigature),	UK(flligature),
-// 176
-	XK_registered,	XK_endash,	XK_dagger,	XK_doubledagger,
-	XK_periodcentered,XK_brokenbar,	XK_paragraph,	UK(bullet),
-	XK_singlelowquotemark,
-			XK_doublelowquotemark,
-					XK_rightdoublequotemark,
-							XK_guillemotright,
-	XK_ellipsis,	UK(permille),	XK_notsign,	XK_questiondown,
-// 192
-	XK_onesuperior,	XK_dead_grave,	XK_dead_acute,	XK_dead_circumflex,
-	XK_dead_tilde,	XK_dead_macron,	XK_dead_breve,	XK_dead_abovedot,
-	XK_dead_diaeresis,
-			XK_twosuperior,	XK_dead_abovering,
-							XK_dead_cedilla,
-	XK_threesuperior,
-			XK_dead_doubleacute,
-					XK_dead_ogonek,	XK_dead_caron,
-// 208
-	XK_emdash,	XK_plusminus,	XK_onequarter,	XK_onehalf,
-	XK_threequarters,
-			XK_agrave,	XK_aacute,	XK_acircumflex,
-	XK_atilde,	XK_adiaeresis,	XK_aring,	XK_ccedilla,
-	XK_egrave,	XK_eacute,	XK_ecircumflex,	XK_ediaeresis,
-// 224
-	XK_igrave,	XK_AE,		XK_iacute,	XK_ordfeminine,
-	XK_icircumflex,	XK_idiaeresis,	XK_eth,		XK_ntilde,
-	XK_Lstroke,	XK_Ooblique,	XK_OE,		XK_masculine,
-	XK_ograve,	XK_oacute,	XK_ocircumflex, XK_otilde,
-// 240
-	XK_odiaeresis,	XK_ae,		XK_ugrave,	XK_uacute,
-	XK_ucircumflex,	XK_idotless,	XK_udiaeresis,	XK_ygrave,
-	XK_lstroke,	XK_ooblique,	XK_oe,		XK_ssharp,
-	XK_thorn,	XK_ydiaeresis,	NoSymbol,	NoSymbol,
-  };
-
-#define MIN_SYMBOL      0xAC
-static KeySym const symbol_to_x[] = {
-    XK_Left,        XK_Up,          XK_Right,      XK_Down
-  };
-static int const NUM_SYMBOL = sizeof(symbol_to_x) / sizeof(symbol_to_x[0]);
-
-#define MIN_FUNCKEY     0x20
-static KeySym const funckey_to_x[] = {
-    XK_F1,          XK_F2,          XK_F3,          XK_F4,
-    XK_F5,          XK_F6,          XK_F7,          XK_F8,
-    XK_F9,          XK_F10,         XK_F11,         XK_F12,
-    XK_Insert,      XK_Delete,      XK_Home,        XK_End,
-    XK_Page_Up,     XK_Page_Down,   XK_F13,         XK_F14,
-    XK_F15
-  };
-static int const NUM_FUNCKEY = sizeof(funckey_to_x) / sizeof(funckey_to_x[0]);
-
-typedef struct {
-    KeySym      normalSym;
-    KeySym      keypadSym;
-} darwinKeyPad_t;
-
-static darwinKeyPad_t const normal_to_keypad[] = {
-    { XK_0,         XK_KP_0 },
-    { XK_1,         XK_KP_1 },
-    { XK_2,         XK_KP_2 },
-    { XK_3,         XK_KP_3 },
-    { XK_4,         XK_KP_4 },
-    { XK_5,         XK_KP_5 },
-    { XK_6,         XK_KP_6 },
-    { XK_7,         XK_KP_7 },
-    { XK_8,         XK_KP_8 },
-    { XK_9,         XK_KP_9 },
-    { XK_equal,     XK_KP_Equal },
-    { XK_asterisk,  XK_KP_Multiply },
-    { XK_plus,      XK_KP_Add },
-    { XK_comma,     XK_KP_Separator },
-    { XK_minus,     XK_KP_Subtract },
-    { XK_period,    XK_KP_Decimal },
-    { XK_slash,     XK_KP_Divide }
-};
-static int const NUM_KEYPAD = sizeof(normal_to_keypad) / sizeof(normal_to_keypad[0]);
-
-static void DarwinChangeKeyboardControl( DeviceIntPtr device, KeybdCtrl *ctrl )
-{
-	// FIXME: to be implemented
-    // keyclick, bell volume / pitch, autorepead, LED's
-}
-
-darwinKeyboardInfo keyInfo;
-static FILE *fref = NULL;
-static char *inBuffer = NULL;
-
-//-----------------------------------------------------------------------------
-// Data Stream Object
-//      Can be configured to treat embedded "numbers" as being composed of
-//      either 1, 2, or 4 bytes, apiece.
-//-----------------------------------------------------------------------------
-typedef struct _DataStream {
-    unsigned char const *data;
-    unsigned char const *data_end;
-    short number_size;  // Size in bytes of a "number" in the stream.
-} DataStream;
-
-static DataStream* new_data_stream(unsigned char const* data, int size) {
-    DataStream* s = (DataStream*)xalloc( sizeof(DataStream) );
-    if(s) {
-        s->data = data;
-        s->data_end = data + size;
-        s->number_size = 1; // Default to byte-sized numbers.
-    }
-    return s;
-}
-
-static void destroy_data_stream(DataStream* s) {
-    xfree(s);
-}
-
-static unsigned char get_byte(DataStream* s) {
-    assert(s->data + 1 <= s->data_end);
-    return *s->data++;
-}
-
-static short get_word(DataStream* s) {
-    short hi, lo;
-    assert(s->data + 2 <= s->data_end);
-    hi = *s->data++;
-    lo = *s->data++;
-    return ((hi << 8) | lo);
-}
-
-static int get_dword(DataStream* s) {
-    int b1, b2, b3, b4;
-    assert(s->data + 4 <= s->data_end);
-    b4 = *s->data++;
-    b3 = *s->data++;
-    b2 = *s->data++;
-    b1 = *s->data++;
-    return ((b4 << 24) | (b3 << 16) | (b2 << 8) | b1);
-}
-
-static int get_number(DataStream* s) {
-    switch (s->number_size) {
-        case 4:  return get_dword(s);
-        case 2:  return get_word(s);
-        default: return get_byte(s);
-    }
-}
-
-//-----------------------------------------------------------------------------
-// Utility functions to help parse Darwin keymap
-//-----------------------------------------------------------------------------
-
-/*
- * bits_set
- *      Calculate number of bits set in the modifier mask.
- */
-static short bits_set(short mask) {
-    short n = 0;
-
-    for ( ; mask != 0; mask >>= 1)
-        if ((mask & 0x01) != 0)
-            n++;
-    return n;
-}
-
-/*
- * parse_next_char_code
- *      Read the next character code from the Darwin keymapping
- *      and write it to the X keymap.
- */
-static void parse_next_char_code(DataStream *s, KeySym *k) {
-    const short charSet = get_number(s);
-    const short charCode = get_number(s);
-
-    if (charSet == 0) {                 // ascii character
-        if (charCode >= 0 && charCode < 256)
-            *k = next_to_x[charCode];
-    } else if (charSet == 0x01) {       // symbol character
-        if (charCode >= MIN_SYMBOL &&
-            charCode <= MIN_SYMBOL + NUM_SYMBOL)
-            *k = symbol_to_x[charCode - MIN_SYMBOL];
-    } else if (charSet == 0xFE) {       // function key
-        if (charCode >= MIN_FUNCKEY &&
-            charCode <= MIN_FUNCKEY + NUM_FUNCKEY)
-            *k = funckey_to_x[charCode - MIN_FUNCKEY];
-    }
-}
-
-
-/*
- * DarwinReadKeymapFile
- *      Read the appropriate keymapping from a keymapping file.
- */
-static Bool DarwinReadKeymapFile(NXKeyMapping *keyMap) {
-    struct stat         st;
-    NXEventSystemDevice info[20];
-    int                 interface = 0, handler_id = 0;
-    int                 map_interface, map_handler_id, map_size = 0;
-    unsigned int        i, size;
-    int                 *bufferEnd;
-    union km_tag {
-        int             *intP;
-        char            *charP;
-    } km;
-
-    fref = fopen( darwinKeymapFile, "rb" );
-    if (fref == NULL) {
-        ErrorF("Unable to open keymapping file '%s' (errno %d).\n",
-               darwinKeymapFile, errno);
-        return FALSE;
-    }
-    if (fstat(fileno(fref), &st) == -1) {
-        ErrorF("Could not stat keymapping file '%s' (errno %d).\n",
-               darwinKeymapFile, errno);
-        return FALSE;
-    }
-
-    // check to make sure we don't crash later
-    if (st.st_size <= 16*sizeof(int)) {
-        ErrorF("Keymapping file '%s' is invalid (too small).\n",
-               darwinKeymapFile);
-        return FALSE;
-    }
-
-    inBuffer = (char*) xalloc( st.st_size );
-    bufferEnd = (int *) (inBuffer + st.st_size);
-    if (fread(inBuffer, st.st_size, 1, fref) != 1) {
-        ErrorF("Could not read %qd bytes from keymapping file '%s' (errno %d).\n",
-               st.st_size, darwinKeymapFile, errno);
-        return FALSE;
-    }
-
-    if (strncmp( inBuffer, "KYM1", 4 ) == 0) {
-        // Magic number OK.
-    } else if (strncmp( inBuffer, "KYMP", 4 ) == 0) {
-        ErrorF("Keymapping file '%s' is intended for use with the original NeXT keyboards and cannot be used by XDarwin.\n", darwinKeymapFile);
-        return FALSE;
-    } else {
-        ErrorF("Keymapping file '%s' has a bad magic number and cannot be used by XDarwin.\n", darwinKeymapFile);
-        return FALSE;
-    }
-
-    // find the keyboard interface and handler id
-    size = sizeof( info ) / sizeof( int );
-    if (!NXEventSystemInfo( darwinParamConnect, NX_EVS_DEVICE_INFO,
-                            (NXEventSystemInfoType) info, &size )) {
-        ErrorF("Error reading event status driver info.\n");
-        return FALSE;
-    }
-
-    size = size * sizeof( int ) / sizeof( info[0] );
-    for( i = 0; i < size; i++) {
-        if (info[i].dev_type == NX_EVS_DEVICE_TYPE_KEYBOARD) {
-            Bool hasInterface = FALSE;
-            Bool hasMatch = FALSE;
-
-            interface = info[i].interface;
-            handler_id = info[i].id;
-
-            // Find an appropriate keymapping:
-            // The first time we try to match both interface and handler_id.
-            // If we can't match both, we take the first match for interface.
-
-            do {
-                km.charP = inBuffer;
-                km.intP++;
-                while (km.intP+3 < bufferEnd) {
-                    map_interface = NXSwapBigIntToHost(*(km.intP++));
-                    map_handler_id = NXSwapBigIntToHost(*(km.intP++));
-                    map_size = NXSwapBigIntToHost(*(km.intP++));
-                    if (map_interface == interface) {
-                        if (map_handler_id == handler_id || hasInterface) {
-                            hasMatch = TRUE;
-                            break;
-                        } else {
-                            hasInterface = TRUE;
-                        }
-                    }
-                    km.charP += map_size;
-                }
-            } while (hasInterface && !hasMatch);
-
-            if (hasMatch) {
-                // fill in NXKeyMapping structure
-                keyMap->size = map_size;
-                keyMap->mapping = (char*) xalloc(map_size);
-                memcpy(keyMap->mapping, km.charP, map_size);
-                return TRUE;
-            }
-        } // if dev_id == keyboard device
-    } // foreach info struct
-
-    // The keymapping file didn't match any of the info structs
-    // returned by NXEventSystemInfo.
-    ErrorF("Keymapping file '%s' did not contain appropriate keyboard interface.\n", darwinKeymapFile);
-    return FALSE;
-}
-
-
-/*
- * DarwinParseNXKeyMapping
- */
-static Bool DarwinParseNXKeyMapping(darwinKeyboardInfo  *info) {
-    KeySym              *k;
-    int                 i;
-    short               numMods, numKeys, numPadKeys = 0;
-    Bool                haveKeymap = FALSE;
-    NXKeyMapping        keyMap;
-    DataStream          *keyMapStream;
-    unsigned char const *numPadStart = 0;
-
-    if (darwinKeymapFile) {
-        haveKeymap = DarwinReadKeymapFile(&keyMap);
-        if (fref)
-            fclose(fref);
-        if (inBuffer)
-            xfree(inBuffer);
-        if (!haveKeymap) {
-            ErrorF("Reverting to kernel keymapping.\n");
-        }
-    }
-
-    if (!haveKeymap) {
-        // get the Darwin keyboard map
-        keyMap.size = NXKeyMappingLength( darwinParamConnect );
-        keyMap.mapping = (char*) xalloc( keyMap.size );
-        if (!NXGetKeyMapping( darwinParamConnect, &keyMap )) {
-            return FALSE;
-        }
-    }
-
-    keyMapStream = new_data_stream( (unsigned char const*)keyMap.mapping,
-                                    keyMap.size );
-
-    // check the type of map
-    if (get_word(keyMapStream)) {
-        keyMapStream->number_size = 2;
-        ErrorF("Current 16-bit keymapping may not be interpreted correctly.\n");
-    }
-
-    // Insert X modifier KeySyms into the keyboard map.
-    numMods = get_number(keyMapStream);
-    while (numMods-- > 0) {
-        int             left = 1;               // first keycode is left
-        short const     charCode = get_number(keyMapStream);
-        short           numKeyCodes = get_number(keyMapStream);
-
-        // This is just a marker, not a real modifier.
-        // Store numeric keypad keys for later.
-        if (charCode == NX_MODIFIERKEY_NUMERICPAD) {
-            numPadStart = keyMapStream->data;
-            numPadKeys = numKeyCodes;
-        }
-
-        while (numKeyCodes-- > 0) {
-            const short keyCode = get_number(keyMapStream);
-            if (charCode != NX_MODIFIERKEY_NUMERICPAD) {
-                switch (charCode) {
-                    case NX_MODIFIERKEY_ALPHALOCK:
-                        info->keyMap[keyCode * GLYPHS_PER_KEY] = XK_Caps_Lock;
-                        break;
-                    case NX_MODIFIERKEY_SHIFT:
-                        info->keyMap[keyCode * GLYPHS_PER_KEY] =
-                                (left ? XK_Shift_L : XK_Shift_R);
-                        break;
-                    case NX_MODIFIERKEY_CONTROL:
-                        info->keyMap[keyCode * GLYPHS_PER_KEY] =
-                                (left ? XK_Control_L : XK_Control_R);
-                        break;
-                    case NX_MODIFIERKEY_ALTERNATE:
-                        // info->keyMap[keyCode * GLYPHS_PER_KEY] = XK_Mode_switch;
-                        info->keyMap[keyCode * GLYPHS_PER_KEY] =
-                                (left ? XK_Alt_L : XK_Alt_R);
-                        break;
-                    case NX_MODIFIERKEY_COMMAND:
-                        info->keyMap[keyCode * GLYPHS_PER_KEY] =
-                                (left ? XK_Meta_L : XK_Meta_R);
-                        break;
-                    case NX_MODIFIERKEY_SECONDARYFN:
-                        info->keyMap[keyCode * GLYPHS_PER_KEY] =
-                                (left ? XK_Control_L : XK_Control_R);
-                        break;
-                    case NX_MODIFIERKEY_HELP:
-                        // Help is not an X11 modifier; treat as normal key
-                        info->keyMap[keyCode * GLYPHS_PER_KEY] = XK_Help;
-                        break;
-                }
-            }
-            left = 0;
-        }
-    }
-
-    // Convert the Darwin keyboard mapping to an X keyboard map.
-    // A key can have a different character code for each combination of
-    // modifiers. We currently ignore all modifier combinations except
-    // those with Shift, AlphaLock, and Alt.
-    numKeys = get_number(keyMapStream);
-    for (i = 0, k = info->keyMap; i < numKeys; i++, k += GLYPHS_PER_KEY) {
-        short const     charGenMask = get_number(keyMapStream);
-        if (charGenMask != 0xFF) {              // is key bound?
-            short       numKeyCodes = 1 << bits_set(charGenMask);
-
-            // Record unmodified case
-            parse_next_char_code( keyMapStream, k );
-            numKeyCodes--;
-
-            // If AlphaLock and Shift modifiers produce different codes,
-            // we record the Shift case since X handles AlphaLock.
-            if (charGenMask & 0x01) {       // AlphaLock
-                parse_next_char_code( keyMapStream, k+1 );
-                numKeyCodes--;
-            }
-
-            if (charGenMask & 0x02) {       // Shift
-                parse_next_char_code( keyMapStream, k+1 );
-                numKeyCodes--;
-
-                if (charGenMask & 0x01) {   // Shift-AlphaLock
-                    get_number(keyMapStream); get_number(keyMapStream);
-                    numKeyCodes--;
-                }
-            }
-
-            // Skip the Control cases
-            if (charGenMask & 0x04) {       // Control
-                get_number(keyMapStream); get_number(keyMapStream);
-                numKeyCodes--;
-
-                if (charGenMask & 0x01) {   // Control-AlphaLock
-                    get_number(keyMapStream); get_number(keyMapStream);
-                    numKeyCodes--;
-                }
-
-                if (charGenMask & 0x02) {   // Control-Shift
-                    get_number(keyMapStream); get_number(keyMapStream);
-                    numKeyCodes--;
-
-                    if (charGenMask & 0x01) {   // Shift-Control-AlphaLock
-                        get_number(keyMapStream); get_number(keyMapStream);
-                        numKeyCodes--;
-                    }
-                }
-            }
-
-            // Process Alt cases
-            if (charGenMask & 0x08) {       // Alt
-                parse_next_char_code( keyMapStream, k+2 );
-                numKeyCodes--;
-
-                if (charGenMask & 0x01) {   // Alt-AlphaLock
-                    parse_next_char_code( keyMapStream, k+3 );
-                    numKeyCodes--;
-                }
-
-                if (charGenMask & 0x02) {   // Alt-Shift
-                    parse_next_char_code( keyMapStream, k+3 );
-                    numKeyCodes--;
-
-                    if (charGenMask & 0x01) {   // Alt-Shift-AlphaLock
-                        get_number(keyMapStream); get_number(keyMapStream);
-                        numKeyCodes--;
-                    }
-                }
-            }
-
-            while (numKeyCodes-- > 0) {
-                get_number(keyMapStream); get_number(keyMapStream);
-            }
-
-            if (k[3] == k[2]) k[3] = NoSymbol;
-            if (k[2] == k[1]) k[2] = NoSymbol;
-            if (k[1] == k[0]) k[1] = NoSymbol;
-            if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol;
-        }
-    }
-
-    // Now we have to go back through the list of keycodes that are on the
-    // numeric keypad and update the X keymap.
-    keyMapStream->data = numPadStart;
-    while(numPadKeys-- > 0) {
-        const short keyCode = get_number(keyMapStream);
-        k = &info->keyMap[keyCode * GLYPHS_PER_KEY];
-        for (i = 0; i < NUM_KEYPAD; i++) {
-            if (*k == normal_to_keypad[i].normalSym) {
-                k[0] = normal_to_keypad[i].keypadSym;
-                break;
-            }
-        }
-    }
-
-    // free Darwin keyboard map
-    destroy_data_stream( keyMapStream );
-    xfree( keyMap.mapping );
-
-    return TRUE;
-}
-
-/*
- * DarwinBuildModifierMaps
- *      Use the keyMap field of keyboard info structure to populate
- *      the modMap and modifierKeycodes fields.
- */
-static void DarwinBuildModifierMaps(darwinKeyboardInfo *info) {
-    int i;
-    KeySym *k;
-
-    memset(info->modMap, NoSymbol, sizeof(info->modMap));
-    memset(info->modifierKeycodes, 0, sizeof(info->modifierKeycodes));
-
-    for (i = 0; i < NUM_KEYCODES; i++) {
-        k = info->keyMap + i * GLYPHS_PER_KEY;
-
-        switch (*k) {
-            case XK_Shift_L:
-                info->modifierKeycodes[NX_MODIFIERKEY_SHIFT][0] = i;
-                info->modMap[MIN_KEYCODE + i] = ShiftMask;
-                break;
-
-            case XK_Shift_R:
-#ifdef NX_MODIFIERKEY_RSHIFT
-                info->modifierKeycodes[NX_MODIFIERKEY_RSHIFT][0] = i;
-#else
-                info->modifierKeycodes[NX_MODIFIERKEY_SHIFT][0] = i;
-#endif
-                info->modMap[MIN_KEYCODE + i] = ShiftMask;
-                break;
-
-            case XK_Control_L:
-                info->modifierKeycodes[NX_MODIFIERKEY_CONTROL][0] = i;
-                info->modMap[MIN_KEYCODE + i] = ControlMask;
-                break;
-
-            case XK_Control_R:
-#ifdef NX_MODIFIERKEY_RCONTROL
-                info->modifierKeycodes[NX_MODIFIERKEY_RCONTROL][0] = i;
-#else
-                info->modifierKeycodes[NX_MODIFIERKEY_CONTROL][0] = i;
-#endif
-                info->modMap[MIN_KEYCODE + i] = ControlMask;
-                break;
-
-            case XK_Caps_Lock:
-                info->modifierKeycodes[NX_MODIFIERKEY_ALPHALOCK][0] = i;
-                info->modMap[MIN_KEYCODE + i] = LockMask;
-                break;
-
-            case XK_Alt_L:
-                info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
-                info->modMap[MIN_KEYCODE + i] = Mod1Mask;
-                *k = XK_Mode_switch; // Yes, this is ugly.  This needs to be cleaned up when we integrate quartzKeyboard with this code and refactor.
-                break;
-
-            case XK_Alt_R:
-#ifdef NX_MODIFIERKEY_RALTERNATE
-                info->modifierKeycodes[NX_MODIFIERKEY_RALTERNATE][0] = i;
-#else
-                info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
-#endif
-                *k = XK_Mode_switch; // Yes, this is ugly.  This needs to be cleaned up when we integrate quartzKeyboard with this code and refactor.
-                info->modMap[MIN_KEYCODE + i] = Mod1Mask;
-                break;
-
-            case XK_Mode_switch:
-                info->modMap[MIN_KEYCODE + i] = Mod1Mask;
-                break;
-
-            case XK_Meta_L:
-                info->modifierKeycodes[NX_MODIFIERKEY_COMMAND][0] = i;
-                info->modMap[MIN_KEYCODE + i] = Mod2Mask;
-                break;
-
-            case XK_Meta_R:
-#ifdef NX_MODIFIERKEY_RCOMMAND
-                info->modifierKeycodes[NX_MODIFIERKEY_RCOMMAND][0] = i;
-#else
-                info->modifierKeycodes[NX_MODIFIERKEY_COMMAND][0] = i;
-#endif
-                info->modMap[MIN_KEYCODE + i] = Mod2Mask;
-                break;
-
-            case XK_Num_Lock:
-                info->modMap[MIN_KEYCODE + i] = Mod3Mask;
-                break;
-        }
-    }
-}
-
-/*
- * DarwinLoadKeyboardMapping
- *  Load the keyboard map from a file or system and convert
- *  it to an equivalent X keyboard map and modifier map.
- */
-static void DarwinLoadKeyboardMapping(KeySymsRec *keySyms) {
-    memset(keyInfo.keyMap, 0, sizeof(keyInfo.keyMap));
-
-    /* TODO: Clean this up
-     * QuartzReadSystemKeymap is in quartz/quartzKeyboard.c
-     * DarwinParseNXKeyMapping is here
-     */
-    if (!DarwinParseNXKeyMapping(&keyInfo)) {
-        DEBUG_LOG("DarwinParseNXKeyMapping returned 0... running QuartzReadSystemKeymap().\n");
-        if (!QuartzReadSystemKeymap(&keyInfo)) {
-            FatalError("Could not build a valid keymap.");
-        }
-    }
-
-    DarwinBuildModifierMaps(&keyInfo);
-
-#ifdef DUMP_DARWIN_KEYMAP
-    int i;
-    KeySym *k;
-    DEBUG_LOG("Darwin -> X converted keyboard map\n");
-    for (i = 0, k = keyInfo.keyMap; i < NX_NUMKEYCODES;
-         i++, k += GLYPHS_PER_KEY)
-    {
-        int j;
-        for (j = 0; j < GLYPHS_PER_KEY; j++) {
-            if (k[j] == NoSymbol) {
-                DEBUG_LOG("0x%02x:\tNoSym\n", i);
-            } else {
-                DEBUG_LOG("0x%02x:\t0x%lx\n", i, k[j]);
-            }
-        }
-    }
-#endif
-
-    keySyms->map        = keyInfo.keyMap;
-    keySyms->mapWidth   = GLYPHS_PER_KEY;
-    keySyms->minKeyCode = MIN_KEYCODE;
-    keySyms->maxKeyCode = MAX_KEYCODE;
-}
-
-
-/*
- * DarwinKeyboardInit
- *      Get the Darwin keyboard map and compute an equivalent
- *      X keyboard map and modifier map. Set the new keyboard
- *      device structure.
- */
-void DarwinKeyboardInit(DeviceIntPtr pDev) {
-    KeySymsRec          keySyms;
-
-    // Open a shared connection to the HID System.
-    // Note that the Event Status Driver is really just a wrapper
-    // for a kIOHIDParamConnectType connection.
-    assert( darwinParamConnect = NXOpenEventStatus() );
-
-    DarwinLoadKeyboardMapping(&keySyms);
-    //    DarwinKeyboardReload(pDev);
-    /* Initialize the seed, so we don't reload the keymap unnecessarily
-       (and possibly overwrite xinitrc changes) */
-    QuartzSystemKeymapSeed();
-
-    assert( InitKeyboardDeviceStruct( (DevicePtr)pDev, &keySyms,
-                                      keyInfo.modMap, QuartzBell,
-                                      DarwinChangeKeyboardControl ));
-    SwitchCoreKeyboard(pDev);
-}
-
-
-void DarwinKeyboardReloadHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents) {
-    KeySymsRec keySyms;
-	if (dev == NULL) dev = darwinKeyboard;
-	
-	DEBUG_LOG("DarwinKeyboardReloadHandler(%p)\n", dev);
-    DarwinLoadKeyboardMapping(&keySyms);
-
-	if (dev->key) {
-		if (dev->key->curKeySyms.map) xfree(dev->key->curKeySyms.map);
-		if (dev->key->modifierKeyMap) xfree(dev->key->modifierKeyMap);
-		xfree(dev->key);
-	}
-	
-	if (!InitKeyClassDeviceStruct(dev, &keySyms, keyInfo.modMap)) {
-		DEBUG_LOG("InitKeyClassDeviceStruct failed\n");
-		return;
-	}
-
-    SendMappingNotify(MappingKeyboard, MIN_KEYCODE, NUM_KEYCODES, 0);
-    SendMappingNotify(MappingModifier, 0, 0, 0);
-}
-
-
-//-----------------------------------------------------------------------------
-// Modifier translation functions
-//
-// There are three different ways to specify a Mac modifier key:
-// keycode - specifies hardware key, read from keymapping
-// key     - NX_MODIFIERKEY_*, really an index
-// mask    - NX_*MASK, mask for modifier flags in event record
-// Left and right side have different keycodes but the same key and mask.
-//-----------------------------------------------------------------------------
-
-/*
- * DarwinModifierNXKeyToNXKeycode
- *      Return the keycode for an NX_MODIFIERKEY_* modifier.
- *      side = 0 for left or 1 for right.
- *      Returns 0 if key+side is not a known modifier.
- */
-int DarwinModifierNXKeyToNXKeycode(int key, int side) {
-    return keyInfo.modifierKeycodes[key][side];
-}
-
-/*
- * DarwinModifierNXKeycodeToNXKey
- *      Returns -1 if keycode+side is not a modifier key
- *      outSide may be NULL, else it gets 0 for left and 1 for right.
- */
-int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide) {
-    int key, side;
-
-    keycode += MIN_KEYCODE;
-    // search modifierKeycodes for this keycode+side
-    for (key = 0; key < NX_NUMMODIFIERS; key++) {
-        for (side = 0; side <= 1; side++) {
-            if (keyInfo.modifierKeycodes[key][side] == keycode) break;
-        }
-    }
-    if (key == NX_NUMMODIFIERS) return -1;
-    if (outSide) *outSide = side;
-    return key;
-}
-
-/*
- * DarwinModifierNXMaskToNXKey
- *      Returns -1 if mask is not a known modifier mask.
- */
-int DarwinModifierNXMaskToNXKey(int mask) {
-    switch (mask) {
-        case NX_ALPHASHIFTMASK:       return NX_MODIFIERKEY_ALPHALOCK;
-        case NX_SHIFTMASK:            return NX_MODIFIERKEY_SHIFT;
-#ifdef NX_DEVICELSHIFTKEYMASK
-        case NX_DEVICELSHIFTKEYMASK:  return NX_MODIFIERKEY_SHIFT;
-        case NX_DEVICERSHIFTKEYMASK:  return NX_MODIFIERKEY_RSHIFT;
-#endif
-        case NX_CONTROLMASK:          return NX_MODIFIERKEY_CONTROL;
-#ifdef NX_DEVICELCTLKEYMASK
-        case NX_DEVICELCTLKEYMASK:    return NX_MODIFIERKEY_CONTROL;
-        case NX_DEVICERCTLKEYMASK:    return NX_MODIFIERKEY_RCONTROL;
-#endif
-        case NX_ALTERNATEMASK:        return NX_MODIFIERKEY_ALTERNATE;
-#ifdef NX_DEVICELALTKEYMASK
-        case NX_DEVICELALTKEYMASK:    return NX_MODIFIERKEY_ALTERNATE;
-        case NX_DEVICERALTKEYMASK:    return NX_MODIFIERKEY_RALTERNATE;
-#endif
-        case NX_COMMANDMASK:          return NX_MODIFIERKEY_COMMAND;
-#ifdef NX_DEVICELCMDKEYMASK
-        case NX_DEVICELCMDKEYMASK:    return NX_MODIFIERKEY_COMMAND;
-        case NX_DEVICERCMDKEYMASK:    return NX_MODIFIERKEY_RCOMMAND;
-#endif
-        case NX_NUMERICPADMASK:       return NX_MODIFIERKEY_NUMERICPAD;
-        case NX_HELPMASK:             return NX_MODIFIERKEY_HELP;
-        case NX_SECONDARYFNMASK:      return NX_MODIFIERKEY_SECONDARYFN;
-    }
-    return -1;
-}
-
-static const char *DarwinModifierNXMaskTostring(int mask) {
-    switch (mask) {
-        case NX_ALPHASHIFTMASK:      return "NX_ALPHASHIFTMASK";
-        case NX_SHIFTMASK:           return "NX_SHIFTMASK";
-        case NX_DEVICELSHIFTKEYMASK: return "NX_DEVICELSHIFTKEYMASK";
-        case NX_DEVICERSHIFTKEYMASK: return "NX_DEVICERSHIFTKEYMASK";
-        case NX_CONTROLMASK:         return "NX_CONTROLMASK";
-        case NX_DEVICELCTLKEYMASK:   return "NX_DEVICELCTLKEYMASK";
-        case NX_DEVICERCTLKEYMASK:   return "NX_DEVICERCTLKEYMASK";
-        case NX_ALTERNATEMASK:       return "NX_ALTERNATEMASK";
-        case NX_DEVICELALTKEYMASK:   return "NX_DEVICELALTKEYMASK";
-        case NX_DEVICERALTKEYMASK:   return "NX_DEVICERALTKEYMASK";
-        case NX_COMMANDMASK:         return "NX_COMMANDMASK";
-        case NX_DEVICELCMDKEYMASK:   return "NX_DEVICELCMDKEYMASK";
-        case NX_DEVICERCMDKEYMASK:   return "NX_DEVICERCMDKEYMASK";
-        case NX_NUMERICPADMASK:      return "NX_NUMERICPADMASK";
-        case NX_HELPMASK:            return "NX_HELPMASK";
-        case NX_SECONDARYFNMASK:     return "NX_SECONDARYFNMASK";
-    }
-    return "unknown mask";
-}
-
-/*
- * DarwinModifierNXKeyToNXMask
- *      Returns 0 if key is not a known modifier key.
- */
-int DarwinModifierNXKeyToNXMask(int key) {
-    switch (key) {
-        case NX_MODIFIERKEY_ALPHALOCK:   return NX_ALPHASHIFTMASK;
-        case NX_MODIFIERKEY_SHIFT:       return NX_SHIFTMASK;
-#ifdef NX_MODIFIERKEY_RSHIFT
-        case NX_MODIFIERKEY_RSHIFT:      return NX_SHIFTMASK;
-#endif
-        case NX_MODIFIERKEY_CONTROL:     return NX_CONTROLMASK;
-#ifdef NX_MODIFIERKEY_RCONTROL
-        case NX_MODIFIERKEY_RCONTROL:    return NX_CONTROLMASK;
-#endif
-        case NX_MODIFIERKEY_ALTERNATE:   return NX_ALTERNATEMASK;
-#ifdef NX_MODIFIERKEY_RALTERNATE
-        case NX_MODIFIERKEY_RALTERNATE:  return NX_ALTERNATEMASK;
-#endif
-        case NX_MODIFIERKEY_COMMAND:     return NX_COMMANDMASK;
-#ifdef NX_MODIFIERKEY_RCOMMAND
-        case NX_MODIFIERKEY_RCOMMAND:    return NX_COMMANDMASK;
-#endif
-        case NX_MODIFIERKEY_NUMERICPAD:  return NX_NUMERICPADMASK;
-        case NX_MODIFIERKEY_HELP:        return NX_HELPMASK;
-        case NX_MODIFIERKEY_SECONDARYFN: return NX_SECONDARYFNMASK;
-    }
-    return 0;
-}
-
-/*
- * DarwinModifierStringToNXKey
- *      Returns -1 if string is not a known modifier.
- */
-int DarwinModifierStringToNXKey(const char *str) {
-    if      (!strcasecmp(str, "shift"))   return NX_MODIFIERKEY_SHIFT;
-    else if (!strcasecmp(str, "control")) return NX_MODIFIERKEY_CONTROL;
-    else if (!strcasecmp(str, "option"))  return NX_MODIFIERKEY_ALTERNATE;
-    else if (!strcasecmp(str, "command")) return NX_MODIFIERKEY_COMMAND;
-    else if (!strcasecmp(str, "fn"))      return NX_MODIFIERKEY_SECONDARYFN;
-    else return -1;
-}
-
-/*
- * LegalModifier
- *      This allows the ddx layer to prevent some keys from being remapped
- *      as modifier keys.
- */
-Bool LegalModifier(unsigned int key, DeviceIntPtr pDev)
-{
-    return 1;
-}
diff --git a/hw/xquartz/darwinKeyboard.h b/hw/xquartz/darwinKeyboard.h
deleted file mode 100644
index 762f659..0000000
--- a/hw/xquartz/darwinKeyboard.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2003-2004 Torrey T. Lyons. 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
- * 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 DARWIN_KEYBOARD_H
-#define DARWIN_KEYBOARD_H 1
-
-#include "quartzKeyboard.h"
-
-/* Provided for darwinEvents.c */
-extern darwinKeyboardInfo keyInfo;
-void DarwinKeyboardReloadHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents);
-void DarwinKeyboardInit(DeviceIntPtr pDev);
-int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide);
-int DarwinModifierNXKeyToNXKeycode(int key, int side);
-int DarwinModifierNXKeyToNXMask(int key);
-int DarwinModifierNXMaskToNXKey(int mask);
-int DarwinModifierStringToNXKey(const char *string);
-
-/* Provided for darwin.c */
-void DarwinKeyboardInit(DeviceIntPtr pDev);
-
-#endif /* DARWIN_KEYBOARD_H */
diff --git a/hw/xquartz/quartzKeyboard.c b/hw/xquartz/quartzKeyboard.c
index 9b899ca..56061fe 100644
--- a/hw/xquartz/quartzKeyboard.c
+++ b/hw/xquartz/quartzKeyboard.c
@@ -1,51 +1,81 @@
 /*
-   quartzKeyboard.c
-
-   Code to build a keymap using the Carbon Keyboard Layout API.
-
-   Copyright (c) 2003-2007 Apple Inc.
-
-   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.
+   quartzKeyboard.c: Keyboard support for Xquartz
+
+   Copyright (c) 2003-2008 Apple Inc.
+   Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
+   Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
+
+   The code to parse the Darwin keymap is derived from dumpkeymap.c
+   by Eric Sunshine, which includes the following copyright:
+
+   Copyright (C) 1999,2000 by Eric Sunshine <sunshine at sunshineco.com>
+   All rights reserved.
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions are met:
+
+     1. Redistributions of source code must retain the above copyright
+        notice, this list of conditions and the following disclaimer.
+     2. Redistributions in binary form must reproduce the above copyright
+        notice, this list of conditions and the following disclaimer in the
+        documentation and/or other materials provided with the distribution.
+     3. The name of the author may not be used to endorse or promote products
+        derived from this software without specific prior written permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+   IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+   OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+   NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+   TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
 #ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
 #endif
 
+// Define this to get a diagnostic output to stderr which is helpful
+// in determining how the X server is interpreting the Darwin keymap.
+#define DUMP_DARWIN_KEYMAP
+
+#define HACK_MISSING 1
+#define HACK_KEYPAD 1
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/stat.h>
+
 #include "quartzCommon.h"
 
 #include <CoreServices/CoreServices.h>
 #include <Carbon/Carbon.h>
+#include <IOKit/hidsystem/event_status_driver.h>
+#include <IOKit/hidsystem/ev_keymap.h>
+#include <architecture/byte_order.h>  // For the NXSwap*
+#include "darwin.h"
 
 #include "quartzKeyboard.h"
+#include "quartzAudio.h"
+
+#ifdef NDEBUG
+#undef NDEBUG
+#include <assert.h>
+#define NDEBUG 1
+#else
+#include <assert.h>
+#endif
+
+
+
+
 #include "X11/keysym.h"
 #include "keysym2ucs.h"
 
-#define HACK_MISSING 1
-#define HACK_KEYPAD 1
 
 enum {
     MOD_COMMAND = 256,
@@ -56,6 +86,143 @@ enum {
 
 #define UKEYSYM(u) ((u) | 0x01000000)
 
+#define AltMask         Mod1Mask
+#define MetaMask        Mod2Mask
+#define FunctionMask    Mod3Mask
+
+#define UK(a)           NoSymbol    // unknown symbol
+
+static KeySym const next_to_x[256] = {
+	NoSymbol,	NoSymbol,	NoSymbol,	XK_KP_Enter,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+	XK_BackSpace,	XK_Tab,		XK_Linefeed,	NoSymbol,
+	NoSymbol,	XK_Return,	NoSymbol,	NoSymbol,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+	NoSymbol,	NoSymbol,	NoSymbol,	XK_Escape,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+	XK_space,	XK_exclam,	XK_quotedbl,	XK_numbersign,
+	XK_dollar,	XK_percent,	XK_ampersand,	XK_apostrophe,
+	XK_parenleft,	XK_parenright,	XK_asterisk,	XK_plus,
+	XK_comma,	XK_minus,	XK_period,	XK_slash,
+	XK_0,		XK_1,		XK_2,		XK_3,
+	XK_4,		XK_5,		XK_6,		XK_7,
+	XK_8,		XK_9,		XK_colon,	XK_semicolon,
+	XK_less,	XK_equal,	XK_greater,	XK_question,
+	XK_at,		XK_A,		XK_B,		XK_C,
+	XK_D,		XK_E,		XK_F,		XK_G,
+	XK_H,		XK_I,		XK_J,		XK_K,
+	XK_L,		XK_M,		XK_N,		XK_O,
+	XK_P,		XK_Q,		XK_R,		XK_S,
+	XK_T,		XK_U,		XK_V,		XK_W,
+	XK_X,		XK_Y,		XK_Z,		XK_bracketleft,
+	XK_backslash,	XK_bracketright,XK_asciicircum,	XK_underscore,
+	XK_grave,	XK_a,		XK_b,		XK_c,
+	XK_d,		XK_e,		XK_f,		XK_g,
+	XK_h,		XK_i,		XK_j,		XK_k,
+	XK_l,		XK_m,		XK_n,		XK_o,
+	XK_p,		XK_q,		XK_r,		XK_s,
+	XK_t,		XK_u,		XK_v,		XK_w,
+	XK_x,		XK_y,		XK_z,		XK_braceleft,
+	XK_bar,		XK_braceright,	XK_asciitilde,	XK_BackSpace,
+// 128
+	NoSymbol,	XK_Agrave,	XK_Aacute,	XK_Acircumflex,
+	XK_Atilde,	XK_Adiaeresis,	XK_Aring,	XK_Ccedilla,
+	XK_Egrave,	XK_Eacute,	XK_Ecircumflex,	XK_Ediaeresis,
+	XK_Igrave,	XK_Iacute,	XK_Icircumflex,	XK_Idiaeresis,
+// 144
+	XK_ETH,		XK_Ntilde,	XK_Ograve,	XK_Oacute,
+	XK_Ocircumflex,	XK_Otilde,	XK_Odiaeresis,	XK_Ugrave,
+	XK_Uacute,	XK_Ucircumflex,	XK_Udiaeresis,	XK_Yacute,
+	XK_THORN,	XK_mu,		XK_multiply,	XK_division,
+// 160
+	XK_copyright,	XK_exclamdown,	XK_cent,	XK_sterling,
+	UK(fraction),	XK_yen,		UK(fhook),	XK_section,
+	XK_currency,	XK_rightsinglequotemark,
+					XK_leftdoublequotemark,
+							XK_guillemotleft,
+	XK_leftanglebracket,
+			XK_rightanglebracket,
+					UK(filigature),	UK(flligature),
+// 176
+	XK_registered,	XK_endash,	XK_dagger,	XK_doubledagger,
+	XK_periodcentered,XK_brokenbar,	XK_paragraph,	UK(bullet),
+	XK_singlelowquotemark,
+			XK_doublelowquotemark,
+					XK_rightdoublequotemark,
+							XK_guillemotright,
+	XK_ellipsis,	UK(permille),	XK_notsign,	XK_questiondown,
+// 192
+	XK_onesuperior,	XK_dead_grave,	XK_dead_acute,	XK_dead_circumflex,
+	XK_dead_tilde,	XK_dead_macron,	XK_dead_breve,	XK_dead_abovedot,
+	XK_dead_diaeresis,
+			XK_twosuperior,	XK_dead_abovering,
+							XK_dead_cedilla,
+	XK_threesuperior,
+			XK_dead_doubleacute,
+					XK_dead_ogonek,	XK_dead_caron,
+// 208
+	XK_emdash,	XK_plusminus,	XK_onequarter,	XK_onehalf,
+	XK_threequarters,
+			XK_agrave,	XK_aacute,	XK_acircumflex,
+	XK_atilde,	XK_adiaeresis,	XK_aring,	XK_ccedilla,
+	XK_egrave,	XK_eacute,	XK_ecircumflex,	XK_ediaeresis,
+// 224
+	XK_igrave,	XK_AE,		XK_iacute,	XK_ordfeminine,
+	XK_icircumflex,	XK_idiaeresis,	XK_eth,		XK_ntilde,
+	XK_Lstroke,	XK_Ooblique,	XK_OE,		XK_masculine,
+	XK_ograve,	XK_oacute,	XK_ocircumflex, XK_otilde,
+// 240
+	XK_odiaeresis,	XK_ae,		XK_ugrave,	XK_uacute,
+	XK_ucircumflex,	XK_idotless,	XK_udiaeresis,	XK_ygrave,
+	XK_lstroke,	XK_ooblique,	XK_oe,		XK_ssharp,
+	XK_thorn,	XK_ydiaeresis,	NoSymbol,	NoSymbol,
+  };
+
+#define MIN_SYMBOL      0xAC
+static KeySym const symbol_to_x[] = {
+    XK_Left,        XK_Up,          XK_Right,      XK_Down
+  };
+static int const NUM_SYMBOL = sizeof(symbol_to_x) / sizeof(symbol_to_x[0]);
+
+#define MIN_FUNCKEY     0x20
+static KeySym const funckey_to_x[] = {
+    XK_F1,          XK_F2,          XK_F3,          XK_F4,
+    XK_F5,          XK_F6,          XK_F7,          XK_F8,
+    XK_F9,          XK_F10,         XK_F11,         XK_F12,
+    XK_Insert,      XK_Delete,      XK_Home,        XK_End,
+    XK_Page_Up,     XK_Page_Down,   XK_F13,         XK_F14,
+    XK_F15
+  };
+static int const NUM_FUNCKEY = sizeof(funckey_to_x) / sizeof(funckey_to_x[0]);
+
+typedef struct {
+    KeySym      normalSym;
+    KeySym      keypadSym;
+} darwinKeyPad_t;
+
+static darwinKeyPad_t const normal_to_keypad[] = {
+    { XK_0,         XK_KP_0 },
+    { XK_1,         XK_KP_1 },
+    { XK_2,         XK_KP_2 },
+    { XK_3,         XK_KP_3 },
+    { XK_4,         XK_KP_4 },
+    { XK_5,         XK_KP_5 },
+    { XK_6,         XK_KP_6 },
+    { XK_7,         XK_KP_7 },
+    { XK_8,         XK_KP_8 },
+    { XK_9,         XK_KP_9 },
+    { XK_equal,     XK_KP_Equal },
+    { XK_asterisk,  XK_KP_Multiply },
+    { XK_plus,      XK_KP_Add },
+    { XK_comma,     XK_KP_Separator },
+    { XK_minus,     XK_KP_Subtract },
+    { XK_period,    XK_KP_Decimal },
+    { XK_slash,     XK_KP_Divide }
+};
+
+static int const NUM_KEYPAD = sizeof(normal_to_keypad) / sizeof(normal_to_keypad[0]);
+
 /* Table of keycode->keysym mappings we use to fallback on for important
    keys that are often not in the Unicode mapping. */
 
@@ -146,6 +313,756 @@ const static struct {
     {UKEYSYM (0x31b), XK_dead_horn},		/* COMBINING HORN */
 };
 
+darwinKeyboardInfo keyInfo;
+static FILE *fref = NULL;
+static char *inBuffer = NULL;
+
+static void DarwinChangeKeyboardControl( DeviceIntPtr device, KeybdCtrl *ctrl )
+{
+	// FIXME: to be implemented
+    // keyclick, bell volume / pitch, autorepead, LED's
+}
+
+//-----------------------------------------------------------------------------
+// Data Stream Object
+//      Can be configured to treat embedded "numbers" as being composed of
+//      either 1, 2, or 4 bytes, apiece.
+//-----------------------------------------------------------------------------
+typedef struct _DataStream {
+    unsigned char const *data;
+    unsigned char const *data_end;
+    short number_size;  // Size in bytes of a "number" in the stream.
+} DataStream;
+
+static DataStream* new_data_stream(unsigned char const* data, int size) {
+    DataStream* s = (DataStream*)xalloc( sizeof(DataStream) );
+    if(s) {
+        s->data = data;
+        s->data_end = data + size;
+        s->number_size = 1; // Default to byte-sized numbers.
+    }
+    return s;
+}
+
+static void destroy_data_stream(DataStream* s) {
+    xfree(s);
+}
+
+static unsigned char get_byte(DataStream* s) {
+    assert(s->data + 1 <= s->data_end);
+    return *s->data++;
+}
+
+static short get_word(DataStream* s) {
+    short hi, lo;
+    assert(s->data + 2 <= s->data_end);
+    hi = *s->data++;
+    lo = *s->data++;
+    return ((hi << 8) | lo);
+}
+
+static int get_dword(DataStream* s) {
+    int b1, b2, b3, b4;
+    assert(s->data + 4 <= s->data_end);
+    b4 = *s->data++;
+    b3 = *s->data++;
+    b2 = *s->data++;
+    b1 = *s->data++;
+    return ((b4 << 24) | (b3 << 16) | (b2 << 8) | b1);
+}
+
+static int get_number(DataStream* s) {
+    switch (s->number_size) {
+        case 4:  return get_dword(s);
+        case 2:  return get_word(s);
+        default: return get_byte(s);
+    }
+}
+
+//-----------------------------------------------------------------------------
+// Utility functions to help parse Darwin keymap
+//-----------------------------------------------------------------------------
+
+/*
+ * bits_set
+ *      Calculate number of bits set in the modifier mask.
+ */
+static short bits_set(short mask) {
+    short n = 0;
+
+    for ( ; mask != 0; mask >>= 1)
+        if ((mask & 0x01) != 0)
+            n++;
+    return n;
+}
+
+/*
+ * parse_next_char_code
+ *      Read the next character code from the Darwin keymapping
+ *      and write it to the X keymap.
+ */
+static void parse_next_char_code(DataStream *s, KeySym *k) {
+    const short charSet = get_number(s);
+    const short charCode = get_number(s);
+
+    if (charSet == 0) {                 // ascii character
+        if (charCode >= 0 && charCode < 256)
+            *k = next_to_x[charCode];
+    } else if (charSet == 0x01) {       // symbol character
+        if (charCode >= MIN_SYMBOL &&
+            charCode <= MIN_SYMBOL + NUM_SYMBOL)
+            *k = symbol_to_x[charCode - MIN_SYMBOL];
+    } else if (charSet == 0xFE) {       // function key
+        if (charCode >= MIN_FUNCKEY &&
+            charCode <= MIN_FUNCKEY + NUM_FUNCKEY)
+            *k = funckey_to_x[charCode - MIN_FUNCKEY];
+    }
+}
+
+
+/*
+ * DarwinReadKeymapFile
+ *      Read the appropriate keymapping from a keymapping file.
+ */
+static Bool DarwinReadKeymapFile(NXKeyMapping *keyMap) {
+    struct stat         st;
+    NXEventSystemDevice info[20];
+    int                 interface = 0, handler_id = 0;
+    int                 map_interface, map_handler_id, map_size = 0;
+    unsigned int        i, size;
+    int                 *bufferEnd;
+    union km_tag {
+        int             *intP;
+        char            *charP;
+    } km;
+
+    fref = fopen( darwinKeymapFile, "rb" );
+    if (fref == NULL) {
+        ErrorF("Unable to open keymapping file '%s' (errno %d).\n",
+               darwinKeymapFile, errno);
+        return FALSE;
+    }
+    if (fstat(fileno(fref), &st) == -1) {
+        ErrorF("Could not stat keymapping file '%s' (errno %d).\n",
+               darwinKeymapFile, errno);
+        return FALSE;
+    }
+
+    // check to make sure we don't crash later
+    if (st.st_size <= 16*sizeof(int)) {
+        ErrorF("Keymapping file '%s' is invalid (too small).\n",
+               darwinKeymapFile);
+        return FALSE;
+    }
+
+    inBuffer = (char*) xalloc( st.st_size );
+    bufferEnd = (int *) (inBuffer + st.st_size);
+    if (fread(inBuffer, st.st_size, 1, fref) != 1) {
+        ErrorF("Could not read %qd bytes from keymapping file '%s' (errno %d).\n",
+               st.st_size, darwinKeymapFile, errno);
+        return FALSE;
+    }
+
+    if (strncmp( inBuffer, "KYM1", 4 ) == 0) {
+        // Magic number OK.
+    } else if (strncmp( inBuffer, "KYMP", 4 ) == 0) {
+        ErrorF("Keymapping file '%s' is intended for use with the original NeXT keyboards and cannot be used by XDarwin.\n", darwinKeymapFile);
+        return FALSE;
+    } else {
+        ErrorF("Keymapping file '%s' has a bad magic number and cannot be used by XDarwin.\n", darwinKeymapFile);
+        return FALSE;
+    }
+
+    // find the keyboard interface and handler id
+    size = sizeof( info ) / sizeof( int );
+    if (!NXEventSystemInfo( darwinParamConnect, NX_EVS_DEVICE_INFO,
+                            (NXEventSystemInfoType) info, &size )) {
+        ErrorF("Error reading event status driver info.\n");
+        return FALSE;
+    }
+
+    size = size * sizeof( int ) / sizeof( info[0] );
+    for( i = 0; i < size; i++) {
+        if (info[i].dev_type == NX_EVS_DEVICE_TYPE_KEYBOARD) {
+            Bool hasInterface = FALSE;
+            Bool hasMatch = FALSE;
+
+            interface = info[i].interface;
+            handler_id = info[i].id;
+
+            // Find an appropriate keymapping:
+            // The first time we try to match both interface and handler_id.
+            // If we can't match both, we take the first match for interface.
+
+            do {
+                km.charP = inBuffer;
+                km.intP++;
+                while (km.intP+3 < bufferEnd) {
+                    map_interface = NXSwapBigIntToHost(*(km.intP++));
+                    map_handler_id = NXSwapBigIntToHost(*(km.intP++));
+                    map_size = NXSwapBigIntToHost(*(km.intP++));
+                    if (map_interface == interface) {
+                        if (map_handler_id == handler_id || hasInterface) {
+                            hasMatch = TRUE;
+                            break;
+                        } else {
+                            hasInterface = TRUE;
+                        }
+                    }
+                    km.charP += map_size;
+                }
+            } while (hasInterface && !hasMatch);
+
+            if (hasMatch) {
+                // fill in NXKeyMapping structure
+                keyMap->size = map_size;
+                keyMap->mapping = (char*) xalloc(map_size);
+                memcpy(keyMap->mapping, km.charP, map_size);
+                return TRUE;
+            }
+        } // if dev_id == keyboard device
+    } // foreach info struct
+
+    // The keymapping file didn't match any of the info structs
+    // returned by NXEventSystemInfo.
+    ErrorF("Keymapping file '%s' did not contain appropriate keyboard interface.\n", darwinKeymapFile);
+    return FALSE;
+}
+
+
+/*
+ * DarwinParseNXKeyMapping
+ */
+static Bool DarwinParseNXKeyMapping(darwinKeyboardInfo  *info) {
+    KeySym              *k;
+    int                 i;
+    short               numMods, numKeys, numPadKeys = 0;
+    Bool                haveKeymap = FALSE;
+    NXKeyMapping        keyMap;
+    DataStream          *keyMapStream;
+    unsigned char const *numPadStart = 0;
+
+    if (darwinKeymapFile) {
+        haveKeymap = DarwinReadKeymapFile(&keyMap);
+        if (fref)
+            fclose(fref);
+        if (inBuffer)
+            xfree(inBuffer);
+        if (!haveKeymap) {
+            ErrorF("Reverting to kernel keymapping.\n");
+        }
+    }
+
+    if (!haveKeymap) {
+        // get the Darwin keyboard map
+        keyMap.size = NXKeyMappingLength( darwinParamConnect );
+        keyMap.mapping = (char*) xalloc( keyMap.size );
+        if (!NXGetKeyMapping( darwinParamConnect, &keyMap )) {
+            return FALSE;
+        }
+    }
+
+    keyMapStream = new_data_stream( (unsigned char const*)keyMap.mapping,
+                                    keyMap.size );
+
+    // check the type of map
+    if (get_word(keyMapStream)) {
+        keyMapStream->number_size = 2;
+        ErrorF("Current 16-bit keymapping may not be interpreted correctly.\n");
+    }
+
+    // Insert X modifier KeySyms into the keyboard map.
+    numMods = get_number(keyMapStream);
+    while (numMods-- > 0) {
+        int             left = 1;               // first keycode is left
+        short const     charCode = get_number(keyMapStream);
+        short           numKeyCodes = get_number(keyMapStream);
+
+        // This is just a marker, not a real modifier.
+        // Store numeric keypad keys for later.
+        if (charCode == NX_MODIFIERKEY_NUMERICPAD) {
+            numPadStart = keyMapStream->data;
+            numPadKeys = numKeyCodes;
+        }
+
+        while (numKeyCodes-- > 0) {
+            const short keyCode = get_number(keyMapStream);
+            if (charCode != NX_MODIFIERKEY_NUMERICPAD) {
+                switch (charCode) {
+                    case NX_MODIFIERKEY_ALPHALOCK:
+                        info->keyMap[keyCode * GLYPHS_PER_KEY] = XK_Caps_Lock;
+                        break;
+                    case NX_MODIFIERKEY_SHIFT:
+                        info->keyMap[keyCode * GLYPHS_PER_KEY] =
+                                (left ? XK_Shift_L : XK_Shift_R);
+                        break;
+                    case NX_MODIFIERKEY_CONTROL:
+                        info->keyMap[keyCode * GLYPHS_PER_KEY] =
+                                (left ? XK_Control_L : XK_Control_R);
+                        break;
+                    case NX_MODIFIERKEY_ALTERNATE:
+                        // info->keyMap[keyCode * GLYPHS_PER_KEY] = XK_Mode_switch;
+                        info->keyMap[keyCode * GLYPHS_PER_KEY] =
+                                (left ? XK_Alt_L : XK_Alt_R);
+                        break;
+                    case NX_MODIFIERKEY_COMMAND:
+                        info->keyMap[keyCode * GLYPHS_PER_KEY] =
+                                (left ? XK_Meta_L : XK_Meta_R);
+                        break;
+                    case NX_MODIFIERKEY_SECONDARYFN:
+                        info->keyMap[keyCode * GLYPHS_PER_KEY] =
+                                (left ? XK_Control_L : XK_Control_R);
+                        break;
+                    case NX_MODIFIERKEY_HELP:
+                        // Help is not an X11 modifier; treat as normal key
+                        info->keyMap[keyCode * GLYPHS_PER_KEY] = XK_Help;
+                        break;
+                }
+            }
+            left = 0;
+        }
+    }
+
+    // Convert the Darwin keyboard mapping to an X keyboard map.
+    // A key can have a different character code for each combination of
+    // modifiers. We currently ignore all modifier combinations except
+    // those with Shift, AlphaLock, and Alt.
+    numKeys = get_number(keyMapStream);
+    for (i = 0, k = info->keyMap; i < numKeys; i++, k += GLYPHS_PER_KEY) {
+        short const     charGenMask = get_number(keyMapStream);
+        if (charGenMask != 0xFF) {              // is key bound?
+            short       numKeyCodes = 1 << bits_set(charGenMask);
+
+            // Record unmodified case
+            parse_next_char_code( keyMapStream, k );
+            numKeyCodes--;
+
+            // If AlphaLock and Shift modifiers produce different codes,
+            // we record the Shift case since X handles AlphaLock.
+            if (charGenMask & 0x01) {       // AlphaLock
+                parse_next_char_code( keyMapStream, k+1 );
+                numKeyCodes--;
+            }
+
+            if (charGenMask & 0x02) {       // Shift
+                parse_next_char_code( keyMapStream, k+1 );
+                numKeyCodes--;
+
+                if (charGenMask & 0x01) {   // Shift-AlphaLock
+                    get_number(keyMapStream); get_number(keyMapStream);
+                    numKeyCodes--;
+                }
+            }
+
+            // Skip the Control cases
+            if (charGenMask & 0x04) {       // Control
+                get_number(keyMapStream); get_number(keyMapStream);
+                numKeyCodes--;
+
+                if (charGenMask & 0x01) {   // Control-AlphaLock
+                    get_number(keyMapStream); get_number(keyMapStream);
+                    numKeyCodes--;
+                }
+
+                if (charGenMask & 0x02) {   // Control-Shift
+                    get_number(keyMapStream); get_number(keyMapStream);
+                    numKeyCodes--;
+
+                    if (charGenMask & 0x01) {   // Shift-Control-AlphaLock
+                        get_number(keyMapStream); get_number(keyMapStream);
+                        numKeyCodes--;
+                    }
+                }
+            }
+
+            // Process Alt cases
+            if (charGenMask & 0x08) {       // Alt
+                parse_next_char_code( keyMapStream, k+2 );
+                numKeyCodes--;
+
+                if (charGenMask & 0x01) {   // Alt-AlphaLock
+                    parse_next_char_code( keyMapStream, k+3 );
+                    numKeyCodes--;
+                }
+
+                if (charGenMask & 0x02) {   // Alt-Shift
+                    parse_next_char_code( keyMapStream, k+3 );
+                    numKeyCodes--;
+
+                    if (charGenMask & 0x01) {   // Alt-Shift-AlphaLock
+                        get_number(keyMapStream); get_number(keyMapStream);
+                        numKeyCodes--;
+                    }
+                }
+            }
+
+            while (numKeyCodes-- > 0) {
+                get_number(keyMapStream); get_number(keyMapStream);
+            }
+
+            if (k[3] == k[2]) k[3] = NoSymbol;
+            if (k[2] == k[1]) k[2] = NoSymbol;
+            if (k[1] == k[0]) k[1] = NoSymbol;
+            if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol;
+        }
+    }
+
+    // Now we have to go back through the list of keycodes that are on the
+    // numeric keypad and update the X keymap.
+    keyMapStream->data = numPadStart;
+    while(numPadKeys-- > 0) {
+        const short keyCode = get_number(keyMapStream);
+        k = &info->keyMap[keyCode * GLYPHS_PER_KEY];
+        for (i = 0; i < NUM_KEYPAD; i++) {
+            if (*k == normal_to_keypad[i].normalSym) {
+                k[0] = normal_to_keypad[i].keypadSym;
+                break;
+            }
+        }
+    }
+
+    // free Darwin keyboard map
+    destroy_data_stream( keyMapStream );
+    xfree( keyMap.mapping );
+
+    return TRUE;
+}
+
+/*
+ * DarwinBuildModifierMaps
+ *      Use the keyMap field of keyboard info structure to populate
+ *      the modMap and modifierKeycodes fields.
+ */
+static void DarwinBuildModifierMaps(darwinKeyboardInfo *info) {
+    int i;
+    KeySym *k;
+
+    memset(info->modMap, NoSymbol, sizeof(info->modMap));
+    memset(info->modifierKeycodes, 0, sizeof(info->modifierKeycodes));
+
+    for (i = 0; i < NUM_KEYCODES; i++) {
+        k = info->keyMap + i * GLYPHS_PER_KEY;
+
+        switch (*k) {
+            case XK_Shift_L:
+                info->modifierKeycodes[NX_MODIFIERKEY_SHIFT][0] = i;
+                info->modMap[MIN_KEYCODE + i] = ShiftMask;
+                break;
+
+            case XK_Shift_R:
+#ifdef NX_MODIFIERKEY_RSHIFT
+                info->modifierKeycodes[NX_MODIFIERKEY_RSHIFT][0] = i;
+#else
+                info->modifierKeycodes[NX_MODIFIERKEY_SHIFT][0] = i;
+#endif
+                info->modMap[MIN_KEYCODE + i] = ShiftMask;
+                break;
+
+            case XK_Control_L:
+                info->modifierKeycodes[NX_MODIFIERKEY_CONTROL][0] = i;
+                info->modMap[MIN_KEYCODE + i] = ControlMask;
+                break;
+
+            case XK_Control_R:
+#ifdef NX_MODIFIERKEY_RCONTROL
+                info->modifierKeycodes[NX_MODIFIERKEY_RCONTROL][0] = i;
+#else
+                info->modifierKeycodes[NX_MODIFIERKEY_CONTROL][0] = i;
+#endif
+                info->modMap[MIN_KEYCODE + i] = ControlMask;
+                break;
+
+            case XK_Caps_Lock:
+                info->modifierKeycodes[NX_MODIFIERKEY_ALPHALOCK][0] = i;
+                info->modMap[MIN_KEYCODE + i] = LockMask;
+                break;
+
+            case XK_Alt_L:
+                info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
+                info->modMap[MIN_KEYCODE + i] = Mod1Mask;
+                *k = XK_Mode_switch; // Yes, this is ugly.  This needs to be cleaned up when we integrate quartzKeyboard with this code and refactor.
+                break;
+
+            case XK_Alt_R:
+#ifdef NX_MODIFIERKEY_RALTERNATE
+                info->modifierKeycodes[NX_MODIFIERKEY_RALTERNATE][0] = i;
+#else
+                info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
+#endif
+                *k = XK_Mode_switch; // Yes, this is ugly.  This needs to be cleaned up when we integrate quartzKeyboard with this code and refactor.
+                info->modMap[MIN_KEYCODE + i] = Mod1Mask;
+                break;
+
+            case XK_Mode_switch:
+                info->modMap[MIN_KEYCODE + i] = Mod1Mask;
+                break;
+
+            case XK_Meta_L:
+                info->modifierKeycodes[NX_MODIFIERKEY_COMMAND][0] = i;
+                info->modMap[MIN_KEYCODE + i] = Mod2Mask;
+                break;
+
+            case XK_Meta_R:
+#ifdef NX_MODIFIERKEY_RCOMMAND
+                info->modifierKeycodes[NX_MODIFIERKEY_RCOMMAND][0] = i;
+#else
+                info->modifierKeycodes[NX_MODIFIERKEY_COMMAND][0] = i;
+#endif
+                info->modMap[MIN_KEYCODE + i] = Mod2Mask;
+                break;
+
+            case XK_Num_Lock:
+                info->modMap[MIN_KEYCODE + i] = Mod3Mask;
+                break;
+        }
+    }
+}
+
+/*
+ * DarwinLoadKeyboardMapping
+ *  Load the keyboard map from a file or system and convert
+ *  it to an equivalent X keyboard map and modifier map.
+ */
+static void DarwinLoadKeyboardMapping(KeySymsRec *keySyms) {
+    memset(keyInfo.keyMap, 0, sizeof(keyInfo.keyMap));
+
+    /* TODO: Clean this up
+     * QuartzReadSystemKeymap is in quartz/quartzKeyboard.c
+     * DarwinParseNXKeyMapping is here
+     */
+    if (!DarwinParseNXKeyMapping(&keyInfo)) {
+        DEBUG_LOG("DarwinParseNXKeyMapping returned 0... running QuartzReadSystemKeymap().\n");
+        if (!QuartzReadSystemKeymap(&keyInfo)) {
+            FatalError("Could not build a valid keymap.");
+        }
+    }
+
+    DarwinBuildModifierMaps(&keyInfo);
+
+#ifdef DUMP_DARWIN_KEYMAP
+    int i;
+    KeySym *k;
+    DEBUG_LOG("Darwin -> X converted keyboard map\n");
+    for (i = 0, k = keyInfo.keyMap; i < NX_NUMKEYCODES;
+         i++, k += GLYPHS_PER_KEY)
+    {
+        int j;
+        for (j = 0; j < GLYPHS_PER_KEY; j++) {
+            if (k[j] == NoSymbol) {
+                DEBUG_LOG("0x%02x:\tNoSym\n", i);
+            } else {
+                DEBUG_LOG("0x%02x:\t0x%lx\n", i, k[j]);
+            }
+        }
+    }
+#endif
+
+    keySyms->map        = keyInfo.keyMap;
+    keySyms->mapWidth   = GLYPHS_PER_KEY;
+    keySyms->minKeyCode = MIN_KEYCODE;
+    keySyms->maxKeyCode = MAX_KEYCODE;
+}
+
+
+/*
+ * DarwinKeyboardInit
+ *      Get the Darwin keyboard map and compute an equivalent
+ *      X keyboard map and modifier map. Set the new keyboard
+ *      device structure.
+ */
+void DarwinKeyboardInit(DeviceIntPtr pDev) {
+    KeySymsRec          keySyms;
+
+    // Open a shared connection to the HID System.
+    // Note that the Event Status Driver is really just a wrapper
+    // for a kIOHIDParamConnectType connection.
+    assert( darwinParamConnect = NXOpenEventStatus() );
+
+    DarwinLoadKeyboardMapping(&keySyms);
+    //    DarwinKeyboardReload(pDev);
+    /* Initialize the seed, so we don't reload the keymap unnecessarily
+       (and possibly overwrite xinitrc changes) */
+    QuartzSystemKeymapSeed();
+
+    assert( InitKeyboardDeviceStruct( (DevicePtr)pDev, &keySyms,
+                                      keyInfo.modMap, QuartzBell,
+                                      DarwinChangeKeyboardControl ));
+    SwitchCoreKeyboard(pDev);
+}
+
+
+void DarwinKeyboardReloadHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents) {
+    KeySymsRec keySyms;
+	if (dev == NULL) dev = darwinKeyboard;
+	
+	DEBUG_LOG("DarwinKeyboardReloadHandler(%p)\n", dev);
+    DarwinLoadKeyboardMapping(&keySyms);
+
+	if (dev->key) {
+		if (dev->key->curKeySyms.map) xfree(dev->key->curKeySyms.map);
+		if (dev->key->modifierKeyMap) xfree(dev->key->modifierKeyMap);
+		xfree(dev->key);
+	}
+	
+	if (!InitKeyClassDeviceStruct(dev, &keySyms, keyInfo.modMap)) {
+		DEBUG_LOG("InitKeyClassDeviceStruct failed\n");
+		return;
+	}
+
+    SendMappingNotify(MappingKeyboard, MIN_KEYCODE, NUM_KEYCODES, 0);
+    SendMappingNotify(MappingModifier, 0, 0, 0);
+}
+
+
+//-----------------------------------------------------------------------------
+// Modifier translation functions
+//
+// There are three different ways to specify a Mac modifier key:
+// keycode - specifies hardware key, read from keymapping
+// key     - NX_MODIFIERKEY_*, really an index
+// mask    - NX_*MASK, mask for modifier flags in event record
+// Left and right side have different keycodes but the same key and mask.
+//-----------------------------------------------------------------------------
+
+/*
+ * DarwinModifierNXKeyToNXKeycode
+ *      Return the keycode for an NX_MODIFIERKEY_* modifier.
+ *      side = 0 for left or 1 for right.
+ *      Returns 0 if key+side is not a known modifier.
+ */
+int DarwinModifierNXKeyToNXKeycode(int key, int side) {
+    return keyInfo.modifierKeycodes[key][side];
+}
+
+/*
+ * DarwinModifierNXKeycodeToNXKey
+ *      Returns -1 if keycode+side is not a modifier key
+ *      outSide may be NULL, else it gets 0 for left and 1 for right.
+ */
+int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide) {
+    int key, side;
+
+    keycode += MIN_KEYCODE;
+    // search modifierKeycodes for this keycode+side
+    for (key = 0; key < NX_NUMMODIFIERS; key++) {
+        for (side = 0; side <= 1; side++) {
+            if (keyInfo.modifierKeycodes[key][side] == keycode) break;
+        }
+    }
+    if (key == NX_NUMMODIFIERS) return -1;
+    if (outSide) *outSide = side;
+    return key;
+}
+
+/*
+ * DarwinModifierNXMaskToNXKey
+ *      Returns -1 if mask is not a known modifier mask.
+ */
+int DarwinModifierNXMaskToNXKey(int mask) {
+    switch (mask) {
+        case NX_ALPHASHIFTMASK:       return NX_MODIFIERKEY_ALPHALOCK;
+        case NX_SHIFTMASK:            return NX_MODIFIERKEY_SHIFT;
+#ifdef NX_DEVICELSHIFTKEYMASK
+        case NX_DEVICELSHIFTKEYMASK:  return NX_MODIFIERKEY_SHIFT;
+        case NX_DEVICERSHIFTKEYMASK:  return NX_MODIFIERKEY_RSHIFT;
+#endif
+        case NX_CONTROLMASK:          return NX_MODIFIERKEY_CONTROL;
+#ifdef NX_DEVICELCTLKEYMASK
+        case NX_DEVICELCTLKEYMASK:    return NX_MODIFIERKEY_CONTROL;
+        case NX_DEVICERCTLKEYMASK:    return NX_MODIFIERKEY_RCONTROL;
+#endif
+        case NX_ALTERNATEMASK:        return NX_MODIFIERKEY_ALTERNATE;
+#ifdef NX_DEVICELALTKEYMASK
+        case NX_DEVICELALTKEYMASK:    return NX_MODIFIERKEY_ALTERNATE;
+        case NX_DEVICERALTKEYMASK:    return NX_MODIFIERKEY_RALTERNATE;
+#endif
+        case NX_COMMANDMASK:          return NX_MODIFIERKEY_COMMAND;
+#ifdef NX_DEVICELCMDKEYMASK
+        case NX_DEVICELCMDKEYMASK:    return NX_MODIFIERKEY_COMMAND;
+        case NX_DEVICERCMDKEYMASK:    return NX_MODIFIERKEY_RCOMMAND;
+#endif
+        case NX_NUMERICPADMASK:       return NX_MODIFIERKEY_NUMERICPAD;
+        case NX_HELPMASK:             return NX_MODIFIERKEY_HELP;
+        case NX_SECONDARYFNMASK:      return NX_MODIFIERKEY_SECONDARYFN;
+    }
+    return -1;
+}
+
+static const char *DarwinModifierNXMaskTostring(int mask) {
+    switch (mask) {
+        case NX_ALPHASHIFTMASK:      return "NX_ALPHASHIFTMASK";
+        case NX_SHIFTMASK:           return "NX_SHIFTMASK";
+        case NX_DEVICELSHIFTKEYMASK: return "NX_DEVICELSHIFTKEYMASK";
+        case NX_DEVICERSHIFTKEYMASK: return "NX_DEVICERSHIFTKEYMASK";
+        case NX_CONTROLMASK:         return "NX_CONTROLMASK";
+        case NX_DEVICELCTLKEYMASK:   return "NX_DEVICELCTLKEYMASK";
+        case NX_DEVICERCTLKEYMASK:   return "NX_DEVICERCTLKEYMASK";
+        case NX_ALTERNATEMASK:       return "NX_ALTERNATEMASK";
+        case NX_DEVICELALTKEYMASK:   return "NX_DEVICELALTKEYMASK";
+        case NX_DEVICERALTKEYMASK:   return "NX_DEVICERALTKEYMASK";
+        case NX_COMMANDMASK:         return "NX_COMMANDMASK";
+        case NX_DEVICELCMDKEYMASK:   return "NX_DEVICELCMDKEYMASK";
+        case NX_DEVICERCMDKEYMASK:   return "NX_DEVICERCMDKEYMASK";
+        case NX_NUMERICPADMASK:      return "NX_NUMERICPADMASK";
+        case NX_HELPMASK:            return "NX_HELPMASK";
+        case NX_SECONDARYFNMASK:     return "NX_SECONDARYFNMASK";
+    }
+    return "unknown mask";
+}
+
+/*
+ * DarwinModifierNXKeyToNXMask
+ *      Returns 0 if key is not a known modifier key.
+ */
+int DarwinModifierNXKeyToNXMask(int key) {
+    switch (key) {
+        case NX_MODIFIERKEY_ALPHALOCK:   return NX_ALPHASHIFTMASK;
+        case NX_MODIFIERKEY_SHIFT:       return NX_SHIFTMASK;
+#ifdef NX_MODIFIERKEY_RSHIFT
+        case NX_MODIFIERKEY_RSHIFT:      return NX_SHIFTMASK;
+#endif
+        case NX_MODIFIERKEY_CONTROL:     return NX_CONTROLMASK;
+#ifdef NX_MODIFIERKEY_RCONTROL
+        case NX_MODIFIERKEY_RCONTROL:    return NX_CONTROLMASK;
+#endif
+        case NX_MODIFIERKEY_ALTERNATE:   return NX_ALTERNATEMASK;
+#ifdef NX_MODIFIERKEY_RALTERNATE
+        case NX_MODIFIERKEY_RALTERNATE:  return NX_ALTERNATEMASK;
+#endif
+        case NX_MODIFIERKEY_COMMAND:     return NX_COMMANDMASK;
+#ifdef NX_MODIFIERKEY_RCOMMAND
+        case NX_MODIFIERKEY_RCOMMAND:    return NX_COMMANDMASK;
+#endif
+        case NX_MODIFIERKEY_NUMERICPAD:  return NX_NUMERICPADMASK;
+        case NX_MODIFIERKEY_HELP:        return NX_HELPMASK;
+        case NX_MODIFIERKEY_SECONDARYFN: return NX_SECONDARYFNMASK;
+    }
+    return 0;
+}
+
+/*
+ * DarwinModifierStringToNXKey
+ *      Returns -1 if string is not a known modifier.
+ */
+int DarwinModifierStringToNXKey(const char *str) {
+    if      (!strcasecmp(str, "shift"))   return NX_MODIFIERKEY_SHIFT;
+    else if (!strcasecmp(str, "control")) return NX_MODIFIERKEY_CONTROL;
+    else if (!strcasecmp(str, "option"))  return NX_MODIFIERKEY_ALTERNATE;
+    else if (!strcasecmp(str, "command")) return NX_MODIFIERKEY_COMMAND;
+    else if (!strcasecmp(str, "fn"))      return NX_MODIFIERKEY_SECONDARYFN;
+    else return -1;
+}
+
+/*
+ * LegalModifier
+ *      This allows the ddx layer to prevent some keys from being remapped
+ *      as modifier keys.
+ */
+Bool LegalModifier(unsigned int key, DeviceIntPtr pDev)
+{
+    return 1;
+}
+
 unsigned int QuartzSystemKeymapSeed(void) {
     static unsigned int seed;
     static KeyboardLayoutRef last_key_layout;
diff --git a/hw/xquartz/quartzKeyboard.h b/hw/xquartz/quartzKeyboard.h
index 4f495bb..964ea01 100644
--- a/hw/xquartz/quartzKeyboard.h
+++ b/hw/xquartz/quartzKeyboard.h
@@ -49,4 +49,17 @@ typedef struct darwinKeyboardInfo_struct {
 Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info);
 unsigned int QuartzSystemKeymapSeed(void);
 
+/* Provided for darwinEvents.c */
+extern darwinKeyboardInfo keyInfo;
+void DarwinKeyboardReloadHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents);
+void DarwinKeyboardInit(DeviceIntPtr pDev);
+int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide);
+int DarwinModifierNXKeyToNXKeycode(int key, int side);
+int DarwinModifierNXKeyToNXMask(int key);
+int DarwinModifierNXMaskToNXKey(int mask);
+int DarwinModifierStringToNXKey(const char *string);
+
+/* Provided for darwin.c */
+void DarwinKeyboardInit(DeviceIntPtr pDev);
+
 #endif /* QUARTZ_KEYBOARD_H */
commit 19872a6aeb8ee9cb0e33e4b4ffd794c9dbefe0cf
Author: Ben Byer <bbyer at apple.com>
Date:   Thu Apr 17 02:31:53 2008 -0700

    oops, missed a spot

diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index bb2a97d..37a66f7 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -459,7 +459,7 @@ void DarwinSendScrollEvents(float count_x, float count_y,
 		ErrorF("DarwinSendScrollEvents called before darwinEvents was initialized\n");
 		return;
 	}
-	ErrorF("scroll(%f, %f)\n", count_x, count_y);
+
 	int sign_x = count_x > 0.0f ? SCROLLWHEELLEFTFAKE : SCROLLWHEELRIGHTFAKE;
 	int sign_y = count_y > 0.0f ? SCROLLWHEELUPFAKE : SCROLLWHEELDOWNFAKE;
 	count_x = fabs(count_x);
commit 769acd29348abf9e5b0bebfca6ae695d345f3077
Author: Ben Byer <bbyer at apple.com>
Date:   Thu Apr 17 02:30:36 2008 -0700

    formatting cleanup

diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index c4ba146..bb2a97d 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -324,16 +324,12 @@ Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr) {
  */
 void ProcessInputEvents(void) {
     xEvent  xe;
-    // button number and modifier mask of currently pressed fake button
-    input_check_flag=0;
+	int x = sizeof(xe);
 
-    //    ErrorF("calling mieqProcessInputEvents\n");
     mieqProcessInputEvents();
 
     // Empty the signaling pipe
-    int x = sizeof(xe);
     while (x == sizeof(xe)) {
-//      DEBUG_LOG("draining pipe\n");
       x = read(darwinEventReadFD, &xe, sizeof(xe));
     }
 }
@@ -341,23 +337,23 @@ void ProcessInputEvents(void) {
 /* Sends a null byte down darwinEventWriteFD, which will cause the
    Dispatch() event loop to check out event queue */
 void DarwinPokeEQ(void) {
-  char nullbyte=0;
-  input_check_flag++;
-  //  <daniels> bushing: oh, i ... er ... christ.
-  write(darwinEventWriteFD, &nullbyte, 1);
+	char nullbyte=0;
+	input_check_flag++;
+	//  <daniels> oh, i ... er ... christ.
+	write(darwinEventWriteFD, &nullbyte, 1);
 }
 
 void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int pointer_y, 
 			     float pressure, float tilt_x, float tilt_y) {
-  static int darwinFakeMouseButtonDown = 0;
-  static int darwinFakeMouseButtonMask = 0;
-  int i, num_events;
+	static int darwinFakeMouseButtonDown = 0;
+	static int darwinFakeMouseButtonMask = 0;
+	int i, num_events;
 
 	if(!darwinEvents) {
 		ErrorF("DarwinSendPointerEvents called before darwinEvents was initialized\n");
 		return;
 	}
-  /* I can't find a spec for this, but at least GTK expects that tablets are
+	/* I can't find a spec for this, but at least GTK expects that tablets are
      just like mice, except they have either one or three extra valuators, in this
      order:
      
@@ -366,91 +362,92 @@ void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int poin
      we can't do that.  Again, GTK seems to record the min/max of each valuator,
      and then perform scaling back to float itself using that info. Soo.... */
 
-  int valuators[5] = {pointer_x, pointer_y, 
+	int valuators[5] = {pointer_x, pointer_y, 
 		      pressure * INT32_MAX * 1.0f, 
 		      tilt_x * INT32_MAX * 1.0f, 
 		      tilt_y * INT32_MAX * 1.0f};
 
-  if (ev_type == ButtonPress && darwinFakeButtons && ev_button == 1) {
-    // Mimic multi-button mouse with modifier-clicks
-    // If both sets of modifiers are pressed,
-    // button 2 is clicked.
-    if ((old_flags & darwinFakeMouse2Mask) == darwinFakeMouse2Mask) {
-      DarwinSimulateMouseClick(pointer_x, pointer_y, pressure, 
+	if (ev_type == ButtonPress && darwinFakeButtons && ev_button == 1) {
+		// Mimic multi-button mouse with modifier-clicks
+		// If both sets of modifiers are pressed,
+		// button 2 is clicked.
+		if ((old_flags & darwinFakeMouse2Mask) == darwinFakeMouse2Mask) {
+			DarwinSimulateMouseClick(pointer_x, pointer_y, pressure, 
 			       tilt_x, tilt_y, 2, darwinFakeMouse2Mask);
-      darwinFakeMouseButtonDown = 2;
-      darwinFakeMouseButtonMask = darwinFakeMouse2Mask;
-      return;
-    } else if ((old_flags & darwinFakeMouse3Mask) == darwinFakeMouse3Mask) {
-      DarwinSimulateMouseClick(pointer_x, pointer_y, pressure, 
+			darwinFakeMouseButtonDown = 2;
+			darwinFakeMouseButtonMask = darwinFakeMouse2Mask;
+			return;
+		} else if ((old_flags & darwinFakeMouse3Mask) == darwinFakeMouse3Mask) {
+			DarwinSimulateMouseClick(pointer_x, pointer_y, pressure, 
 			       tilt_x, tilt_y, 3, darwinFakeMouse3Mask);
-      darwinFakeMouseButtonDown = 3;
-      darwinFakeMouseButtonMask = darwinFakeMouse3Mask;
-      return;
-    }
-  }
-  if (ev_type == ButtonRelease && darwinFakeButtons && darwinFakeMouseButtonDown) {
-    // If last mousedown was a fake click, don't check for
-    // mouse modifiers here. The user may have released the
-    // modifiers before the mouse button.
-    ev_button = darwinFakeMouseButtonDown;
-    darwinFakeMouseButtonDown = 0;
-    // Bring modifiers back up to date
-    DarwinUpdateModifiers(KeyPress, darwinFakeMouseButtonMask & old_flags);
-    darwinFakeMouseButtonMask = 0;
-    return;
-  } 
-
-  num_events = GetPointerEvents(darwinEvents, darwinPointer, ev_type, ev_button, 
+			darwinFakeMouseButtonDown = 3;
+			darwinFakeMouseButtonMask = darwinFakeMouse3Mask;
+			return;
+		}
+	}
+
+	if (ev_type == ButtonRelease && darwinFakeButtons && darwinFakeMouseButtonDown) {
+		// If last mousedown was a fake click, don't check for
+		// mouse modifiers here. The user may have released the
+		// modifiers before the mouse button.
+		ev_button = darwinFakeMouseButtonDown;
+		darwinFakeMouseButtonDown = 0;
+		// Bring modifiers back up to date
+		DarwinUpdateModifiers(KeyPress, darwinFakeMouseButtonMask & old_flags);
+		darwinFakeMouseButtonMask = 0;
+		return;
+	} 
+
+	num_events = GetPointerEvents(darwinEvents, darwinPointer, ev_type, ev_button, 
 				POINTER_ABSOLUTE, 0, 5, valuators);
       
-  for(i=0; i<num_events; i++) mieqEnqueue (darwinPointer,&darwinEvents[i]);
-  DarwinPokeEQ();
+	for(i=0; i<num_events; i++) mieqEnqueue (darwinPointer,&darwinEvents[i]);
+	DarwinPokeEQ();
 }
 
 void DarwinSendKeyboardEvents(int ev_type, int keycode) {
-  int i, num_events;
+	int i, num_events;
 	if(!darwinEvents) {
 		ErrorF("DarwinSendKeyboardEvents called before darwinEvents was initialized\n");
 		return;
 	}
 
-  if (old_flags == 0 && darwinSyncKeymap && darwinKeymapFile == NULL) {
-    /* See if keymap has changed. */
+	if (old_flags == 0 && darwinSyncKeymap && darwinKeymapFile == NULL) {
+		/* See if keymap has changed. */
 
-    static unsigned int last_seed;
-    unsigned int this_seed;
+		static unsigned int last_seed;
+		unsigned int this_seed;
 
-    this_seed = QuartzSystemKeymapSeed();
-    if (this_seed != last_seed) {
-		last_seed = this_seed;
-		DarwinSendDDXEvent(kXquartzReloadKeymap, 0);
-    }
-  }
+		this_seed = QuartzSystemKeymapSeed();
+		if (this_seed != last_seed) {
+			last_seed = this_seed;
+			DarwinSendDDXEvent(kXquartzReloadKeymap, 0);
+		}
+	}
 
-  num_events = GetKeyboardEvents(darwinEvents, darwinKeyboard, ev_type, keycode + MIN_KEYCODE);
-  for(i=0; i<num_events; i++) mieqEnqueue(darwinKeyboard,&darwinEvents[i]);
-  DarwinPokeEQ();
+	num_events = GetKeyboardEvents(darwinEvents, darwinKeyboard, ev_type, keycode + MIN_KEYCODE);
+	for(i=0; i<num_events; i++) mieqEnqueue(darwinKeyboard,&darwinEvents[i]);
+	DarwinPokeEQ();
 }
 
 void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y, 
 			       float pressure, float tilt_x, float tilt_y) {
-  int i, num_events;
-  int valuators[5] = {pointer_x, pointer_y, 
+	int i, num_events;
+	int valuators[5] = {pointer_x, pointer_y, 
 		      pressure * INT32_MAX * 1.0f, 
 		      tilt_x * INT32_MAX * 1.0f, 
 		      tilt_y * INT32_MAX * 1.0f};
 
-  if(!darwinEvents) {
+	if(!darwinEvents) {
 		ErrorF("DarwinSendProximityvents called before darwinEvents was initialized\n");
 		return;
-}
+	}
 
-  num_events = GetProximityEvents(darwinEvents, darwinPointer, ev_type,
+	num_events = GetProximityEvents(darwinEvents, darwinPointer, ev_type,
 				0, 5, valuators);
       
-  for(i=0; i<num_events; i++) mieqEnqueue (darwinPointer,&darwinEvents[i]);
-  DarwinPokeEQ();
+	for(i=0; i<num_events; i++) mieqEnqueue (darwinPointer,&darwinEvents[i]);
+	DarwinPokeEQ();
 }
 
 
@@ -485,9 +482,9 @@ void DarwinSendScrollEvents(float count_x, float count_y,
 /* Send the appropriate KeyPress/KeyRelease events to GetKeyboardEvents to
    reflect changing modifier flags (alt, control, meta, etc) */
 void DarwinUpdateModKeys(int flags) {
-  DarwinUpdateModifiers(KeyRelease, old_flags & ~flags);
-  DarwinUpdateModifiers(KeyPress, ~old_flags & flags);
-  old_flags = flags;
+	DarwinUpdateModifiers(KeyRelease, old_flags & ~flags);
+	DarwinUpdateModifiers(KeyPress, ~old_flags & flags);
+	old_flags = flags;
 }
 
 
commit f04f3af86a91d0cafbc86a0d71aeb0599d685f07
Author: Ben Byer <bbyer at apple.com>
Date:   Thu Apr 17 02:21:33 2008 -0700

    delete debugging spew

diff --git a/hw/xquartz/darwinKeyboard.c b/hw/xquartz/darwinKeyboard.c
index baf38f1..e29ba5d 100644
--- a/hw/xquartz/darwinKeyboard.c
+++ b/hw/xquartz/darwinKeyboard.c
@@ -731,14 +731,6 @@ static void DarwinBuildModifierMaps(darwinKeyboardInfo *info) {
  *  it to an equivalent X keyboard map and modifier map.
  */
 static void DarwinLoadKeyboardMapping(KeySymsRec *keySyms) {
-  void* callstack[128];
-  int i, frames = backtrace(callstack, 128);
-  char** strs = backtrace_symbols(callstack, frames);
-  for (i = 0; i < frames; ++i) {
-    ErrorF("%s\n", strs[i]);
-  }
-  free(strs);
-
     memset(keyInfo.keyMap, 0, sizeof(keyInfo.keyMap));
 
     /* TODO: Clean this up
commit f525a4a432ebd0545ad1dd0a7ad84ad3e47e8b61
Author: Ben Byer <bbyer at apple.com>
Date:   Thu Apr 17 02:21:11 2008 -0700

    add support for horizontal scrolling (buttons 6 and 7)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 2ac8a8c..726ddb4 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -903,7 +903,7 @@ static void send_nsevent (NSEventType type, NSEvent *e) {
 		break;
 
 		case NSScrollWheel:
-			DarwinSendScrollEvents([e deltaY], pointer_x, pointer_y,
+			DarwinSendScrollEvents([e deltaX], [e deltaY], pointer_x, pointer_y,
 				pressure, tilt_x, tilt_y);
 		break;
 
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index e397795..2232cf5 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -337,7 +337,7 @@ static int DarwinMouseProc(
     DeviceIntPtr    pPointer,
     int             what )
 {
-    CARD8 map[6];
+  CARD8 map[8] = {0, 1, 2, 3, 4, 5, 6, 7};
 
     switch (what) {
 
@@ -345,15 +345,10 @@ static int DarwinMouseProc(
             pPointer->public.on = FALSE;
 
             // Set button map.
-            map[1] = 1;
-            map[2] = 2;
-            map[3] = 3;
-            map[4] = 4;
-            map[5] = 5;
-            InitPointerDeviceStruct( (DevicePtr)pPointer, map, 5,
+              InitPointerDeviceStruct( (DevicePtr)pPointer, map, 7,
 				     GetMotionHistory,
 				     (PtrCtrlProcPtr)NoopDDA,
-				     GetMotionHistorySize(), 5);
+				     GetMotionHistorySize(), 7);
 	    InitProximityClassDeviceStruct( (DevicePtr)pPointer);
             break;
 
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 70dfdaf..c4ba146 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -1,7 +1,7 @@
 /*
 Darwin event queue and event handling
 
-Copyright 2007 Apple Inc.
+Copyright 2007-2008 Apple Inc.
 Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
 Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved.
 
@@ -56,6 +56,12 @@ in this Software without prior written authorization from The Open Group.
 #include <unistd.h>
 #include <IOKit/hidsystem/IOLLEvent.h>
 
+/* Fake button press/release for scroll wheel move. */
+#define SCROLLWHEELUPFAKE    4
+#define SCROLLWHEELDOWNFAKE  5
+#define SCROLLWHEELLEFTFAKE  6
+#define SCROLLWHEELRIGHTFAKE 7
+
 #define _APPLEWM_SERVER_
 #include "applewmExt.h"
 #include <X11/extensions/applewm.h>
@@ -65,10 +71,6 @@ in this Software without prior written authorization from The Open Group.
 #include "rootlessWindow.h"
 WindowPtr xprGetXWindow(xp_window_id wid);
 
-/* Fake button press/release for scroll wheel move. */
-#define SCROLLWHEELUPFAKE   4
-#define SCROLLWHEELDOWNFAKE 5
-
 int input_check_zero, input_check_flag;
 
 static int old_flags = 0;  // last known modifier state
@@ -452,30 +454,32 @@ void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y,
 }
 
 
-/* Send the appropriate number of button 4 / 5 clicks to emulate scroll wheel */
-void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y, 
-			    float pressure, float tilt_x, float tilt_y) {
-  int i;
-  int ev_button = count > 0.0f ? 4 : 5;
-  int valuators[5] = {pointer_x, pointer_y, 
-		      pressure * INT32_MAX * 1.0f, 
-		      tilt_x * INT32_MAX * 1.0f, 
-		      tilt_y * INT32_MAX * 1.0f};
-
+/* Send the appropriate number of button clicks to emulate scroll wheel */
+void DarwinSendScrollEvents(float count_x, float count_y, 
+							int pointer_x, int pointer_y, 
+			    			float pressure, float tilt_x, float tilt_y) {
 	if(!darwinEvents) {
 		ErrorF("DarwinSendScrollEvents called before darwinEvents was initialized\n");
 		return;
 	}
-
-  for (count = fabs(count); count > 0.0; count = count - 1.0f) {
-    int num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonPress, ev_button, 
-				      POINTER_ABSOLUTE, 0, 5, valuators);
-    for(i=0; i<num_events; i++) mieqEnqueue(darwinPointer,&darwinEvents[i]);
-    num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonRelease, ev_button, 
-				      POINTER_ABSOLUTE, 0, 5, valuators);
-    for(i=0; i<num_events; i++) mieqEnqueue(darwinPointer,&darwinEvents[i]);
-  }
-  DarwinPokeEQ();
+	ErrorF("scroll(%f, %f)\n", count_x, count_y);
+	int sign_x = count_x > 0.0f ? SCROLLWHEELLEFTFAKE : SCROLLWHEELRIGHTFAKE;
+	int sign_y = count_y > 0.0f ? SCROLLWHEELUPFAKE : SCROLLWHEELDOWNFAKE;
+	count_x = fabs(count_x);
+	count_y = fabs(count_y);
+	
+	while ((count_x > 0.0f) || (count_y > 0.0f)) {
+		if (count_x > 0.0f) {
+			DarwinSendPointerEvents(ButtonPress, sign_x, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+			DarwinSendPointerEvents(ButtonRelease, sign_x, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+			count_x = count_x - 1.0f;
+		}
+		if (count_y > 0.0f) {
+			DarwinSendPointerEvents(ButtonPress, sign_y, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+			DarwinSendPointerEvents(ButtonRelease, sign_y, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+			count_y = count_y - 1.0f;
+		}
+	}
 }
 
 /* Send the appropriate KeyPress/KeyRelease events to GetKeyboardEvents to
diff --git a/hw/xquartz/darwinEvents.h b/hw/xquartz/darwinEvents.h
index 7c56be9..98426d6 100644
--- a/hw/xquartz/darwinEvents.h
+++ b/hw/xquartz/darwinEvents.h
@@ -38,7 +38,7 @@ void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int poin
 void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y, 
 			       float pressure, float tilt_x, float tilt_y);
 void DarwinSendKeyboardEvents(int ev_type, int keycode);
-void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y,
+void DarwinSendScrollEvents(float count_x, float count_y, int pointer_x, int pointer_y,
 			    float pressure, float tilt_x, float tilt_y);
 void DarwinUpdateModKeys(int flags);
 
commit ab662c736e0654e2b4347091f0d9e87f26034216
Author: Ben Byer <bbyer at apple.com>
Date:   Thu Apr 17 01:32:56 2008 -0700

    enable keyboard map debugging -- it's going to x11-debug.txt, anyway ... so no harm

diff --git a/hw/xquartz/darwinKeyboard.c b/hw/xquartz/darwinKeyboard.c
index 8186af2..baf38f1 100644
--- a/hw/xquartz/darwinKeyboard.c
+++ b/hw/xquartz/darwinKeyboard.c
@@ -62,7 +62,7 @@
 
 // Define this to get a diagnostic output to stderr which is helpful
 // in determining how the X server is interpreting the Darwin keymap.
-// #define DUMP_DARWIN_KEYMAP
+#define DUMP_DARWIN_KEYMAP
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -222,6 +222,7 @@ static int const NUM_KEYPAD = sizeof(normal_to_keypad) / sizeof(normal_to_keypad
 
 static void DarwinChangeKeyboardControl( DeviceIntPtr device, KeybdCtrl *ctrl )
 {
+	// FIXME: to be implemented
     // keyclick, bell volume / pitch, autorepead, LED's
 }
 
commit a8a090b853e811b9843a5732572cbbe542224f32
Author: Ben Byer <bbyer at apple.com>
Date:   Thu Apr 17 01:29:46 2008 -0700

    darwinKeyboard: refactor slightly so that we're not cutting and pasting code from dix, kthx

diff --git a/hw/xquartz/darwinKeyboard.c b/hw/xquartz/darwinKeyboard.c
index bd3588e..8186af2 100644
--- a/hw/xquartz/darwinKeyboard.c
+++ b/hw/xquartz/darwinKeyboard.c
@@ -1,9 +1,9 @@
 //=============================================================================
 //
-// Keyboard support for the Darwin X Server
+// Keyboard support for Xquartz
 //
+// Copyright (c) 2003, 2008 Apple, Inc.
 // Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
-// Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved.
 // Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
 //
 // The code to parse the Darwin keymap is derived from dumpkeymap.c
@@ -805,52 +805,6 @@ void DarwinKeyboardInit(DeviceIntPtr pDev) {
 }
 
 
-/* Borrowed from dix/devices.c */
-static Bool InitModMap(register KeyClassPtr keyc) {
-    int i, j;
-    CARD8 keysPerModifier[8];
-    CARD8 mask;
-
-    //    darwinKeyc = keyc;
-    if (keyc->modifierKeyMap != NULL)
-        xfree (keyc->modifierKeyMap);
-
-    keyc->maxKeysPerModifier = 0;
-    for (i = 0; i < 8; i++)
-        keysPerModifier[i] = 0;
-    for (i = 8; i < MAP_LENGTH; i++)
-    {
-        for (j = 0, mask = 1; j < 8; j++, mask <<= 1)
-        {
-            if (mask & keyc->modifierMap[i])
-            {
-                if (++keysPerModifier[j] > keyc->maxKeysPerModifier)
-                    keyc->maxKeysPerModifier = keysPerModifier[j];
-            }
-        }
-    }
-    keyc->modifierKeyMap = (KeyCode *)xalloc(8*keyc->maxKeysPerModifier);
-    if (!keyc->modifierKeyMap && keyc->maxKeysPerModifier)
-        return (FALSE);
-    bzero((char *)keyc->modifierKeyMap, 8*(int)keyc->maxKeysPerModifier);
-    for (i = 0; i < 8; i++)
-        keysPerModifier[i] = 0;
-    for (i = 8; i < MAP_LENGTH; i++)
-    {
-        for (j = 0, mask = 1; j < 8; j++, mask <<= 1)
-        {
-            if (mask & keyc->modifierMap[i])
-            {
-                keyc->modifierKeyMap[(j*keyc->maxKeysPerModifier) +
-                         keysPerModifier[j]] = i;
-                keysPerModifier[j]++;
-            }
-        }
-    }
-    return TRUE;
-}
-
-
 void DarwinKeyboardReloadHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents) {
     KeySymsRec keySyms;
 	if (dev == NULL) dev = darwinKeyboard;
@@ -858,12 +812,16 @@ void DarwinKeyboardReloadHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev,
 	DEBUG_LOG("DarwinKeyboardReloadHandler(%p)\n", dev);
     DarwinLoadKeyboardMapping(&keySyms);
 
-    if (SetKeySymsMap(&dev->key->curKeySyms, &keySyms)) {
-        /* now try to update modifiers. */
-
-        memmove(dev->key->modifierMap, keyInfo.modMap, MAP_LENGTH);
-        InitModMap(dev->key);
-    } else DEBUG_LOG("SetKeySymsMap=0\n");
+	if (dev->key) {
+		if (dev->key->curKeySyms.map) xfree(dev->key->curKeySyms.map);
+		if (dev->key->modifierKeyMap) xfree(dev->key->modifierKeyMap);
+		xfree(dev->key);
+	}
+	
+	if (!InitKeyClassDeviceStruct(dev, &keySyms, keyInfo.modMap)) {
+		DEBUG_LOG("InitKeyClassDeviceStruct failed\n");
+		return;
+	}
 
     SendMappingNotify(MappingKeyboard, MIN_KEYCODE, NUM_KEYCODES, 0);
     SendMappingNotify(MappingModifier, 0, 0, 0);
commit cab54466a61281cfafc12825017c23d720cd75f4
Author: Ben Byer <bbyer at apple.com>
Date:   Thu Apr 17 00:19:56 2008 -0700

    hack to Xquartz to prevent xmodmap from wiping out our valid modmap, per daniels

diff --git a/hw/xquartz/darwinKeyboard.c b/hw/xquartz/darwinKeyboard.c
index a9fbdfc..bd3588e 100644
--- a/hw/xquartz/darwinKeyboard.c
+++ b/hw/xquartz/darwinKeyboard.c
@@ -801,6 +801,7 @@ void DarwinKeyboardInit(DeviceIntPtr pDev) {
     assert( InitKeyboardDeviceStruct( (DevicePtr)pDev, &keySyms,
                                       keyInfo.modMap, QuartzBell,
                                       DarwinChangeKeyboardControl ));
+    SwitchCoreKeyboard(pDev);
 }
 
 
commit a494ff04b2a14470eaf5a23c7cf6dbdea182c6d1
Author: Ben Byer <bbyer at apple.com>
Date:   Wed Apr 16 22:48:54 2008 -0700

    kludge: miEqEnqueue wants a device, even if we're passing custom messages,
    so give it one

diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 78708d2..70dfdaf 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -511,5 +511,5 @@ void DarwinSendDDXEvent(int type, int argc, ...) {
         va_end (args);
     }
 
-    mieqEnqueue(NULL, &xe);
+    mieqEnqueue(darwinPointer, &xe);
 }
commit 6d3d344b5b95b6dc4166556d03cfd8c9576dc3f0
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Wed Apr 16 21:49:19 2008 -0700

    XQuartz: Don't use composite.

diff --git a/configure.ac b/configure.ac
index 87785a5..125f1f3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -495,7 +495,7 @@ AC_ARG_ENABLE(glx-tls,        AS_HELP_STRING([--enable-glx-tls], [Build GLX with
                                 [GLX_USE_TLS=no])
 
 dnl Extensions.
-AC_ARG_ENABLE(composite,      AS_HELP_STRING([--disable-composite], [Build Composite extension (default: enabled)]), [COMPOSITE=$enableval], [COMPOSITE=yes])
+AC_ARG_ENABLE(composite,      AS_HELP_STRING([--disable-composite], [Build Composite extension (default: enabled)]), [COMPOSITE=$enableval], [COMPOSITE=auto])
 AC_ARG_ENABLE(mitshm,         AS_HELP_STRING([--disable-shm], [Build SHM extension (default: enabled)]), [MITSHM=$enableval], [MITSHM=yes])
 AC_ARG_ENABLE(xres,           AS_HELP_STRING([--disable-xres], [Build XRes extension (default: enabled)]), [RES=$enableval], [RES=yes])
 AC_ARG_ENABLE(xtrap,          AS_HELP_STRING([--disable-xtrap], [Build XTrap extension (default: enabled)]), [XTRAP=$enableval], [XTRAP=yes])
@@ -694,6 +694,14 @@ if test "x$XVMC" = xyes; then
 	AC_DEFINE(XvMCExtension, 1, [Build XvMC extension])
 fi
 
+dnl XQuartz DDX Detection... Yes, it's ugly to have it here... but we need to disable COMPOSITE for 
+if test "x$COMPOSITE" = xauto; then
+	case $host_os in
+		darwin*)
+			[ "x$XQUARTZ" = xyes -o "x$XQUARTZ" = xauto ] && COMPOSITE=no
+			;;
+	esac
+fi
 
 AM_CONDITIONAL(COMPOSITE, [test "x$COMPOSITE" = xyes])
 if test "x$COMPOSITE" = xyes; then
diff --git a/hw/xquartz/xpr/Makefile.am b/hw/xquartz/xpr/Makefile.am
index 6523561..f6ede8b 100644
--- a/hw/xquartz/xpr/Makefile.am
+++ b/hw/xquartz/xpr/Makefile.am
@@ -27,7 +27,6 @@ Xquartz_LDADD = \
 	$(top_builddir)/miext/shadow/libshadow.la \
 	$(top_builddir)/fb/libfb.la \
 	$(top_builddir)/mi/libmi.la \
-	$(top_builddir)/composite/libcomposite.la \
 	$(top_builddir)/damageext/libdamageext.la \
 	$(top_builddir)/miext/damage/libdamage.la \
 	$(top_builddir)/xfixes/libxfixes.la \
commit 180ec128adef11a9a90cea1189dc31ac5de8359f
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Wed Apr 16 21:48:52 2008 -0700

    Xquartz: Don't need to link against rlAccel since we don't use it

diff --git a/hw/xquartz/xpr/Makefile.am b/hw/xquartz/xpr/Makefile.am
index b4d67c7..6523561 100644
--- a/hw/xquartz/xpr/Makefile.am
+++ b/hw/xquartz/xpr/Makefile.am
@@ -40,7 +40,6 @@ Xquartz_LDADD = \
 	$(top_builddir)/record/librecord.la \
 	$(top_builddir)/XTrap/libxtrap.la \
 	$(top_builddir)/miext/rootless/librootless.la \
-	$(top_builddir)/miext/rootless/accel/librlAccel.la \
 	$(DARWIN_LIBS) $(XSERVER_LIBS) $(XSERVER_SYS_LIBS) -lXplugin
 
 Xquartz_LDFLAGS =  \
commit 7b4b89c1da02d712f08589d5d4f445bbe4b0404c
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Thu Apr 3 16:29:43 2008 -0700

    XQuartz: Don't enable rootless accelerated functionality... crashy...
    (cherry picked from commit cdb4c291d8c10c3a9ea59d8e79275a30d2ea82b4)

diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c
index 78dcd4b..150c4bd 100644
--- a/hw/xquartz/xpr/xprScreen.c
+++ b/hw/xquartz/xpr/xprScreen.c
@@ -356,7 +356,9 @@ xprSetupScreen(int index, ScreenPtr pScreen)
 {
     // Initialize accelerated rootless drawing
     // Note that this must be done before DamageSetup().
-    RootlessAccelInit(pScreen);
+
+    // These are crashing ugly... better to be stable and not crash for now.
+    //RootlessAccelInit(pScreen);
 
 #ifdef DAMAGE
     // The Damage extension needs to wrap underneath the
diff --git a/miext/rootless/README.txt b/miext/rootless/README.txt
index ffd1790..2c3fbb0 100644
--- a/miext/rootless/README.txt
+++ b/miext/rootless/README.txt
@@ -76,10 +76,6 @@ rootlessConfig.h to specify compile time options for its platform.
         The following compile-time options are defined in 
 rootlessConfig.h:
 
-      o ROOTLESS_ACCEL: If true, use the optional rootless acceleration
-        functions where possible to a accelerate X11 drawing primitives.
-        If false, all drawing will be done with fb.
-
       o ROOTLESS_GLOBAL_COORDS: This option controls the way that frame
         coordinates are passed to the rootless implementation. If false,
         the coordinates are passed per screen relative to the origin of 
diff --git a/miext/rootless/rootlessConfig.h b/miext/rootless/rootlessConfig.h
index ab0187e..50bac3f 100644
--- a/miext/rootless/rootlessConfig.h
+++ b/miext/rootless/rootlessConfig.h
@@ -36,12 +36,12 @@
 
 #ifdef __APPLE__
 
-# define ROOTLESS_ACCEL TRUE
 # define ROOTLESS_GLOBAL_COORDS TRUE
 # define ROOTLESS_PROTECT_ALPHA TRUE
 # define ROOTLESS_REDISPLAY_DELAY 10
 # define ROOTLESS_RESIZE_GRAVITY TRUE
 # undef  ROOTLESS_TRACK_DAMAGE
+/*# define ROOTLESSDEBUG*/
 
 /* Bit mask for alpha channel with a particular number of bits per
    pixel. Note that we only care for 32bpp data. Mac OS X uses planar
@@ -52,7 +52,6 @@
 
 #if defined(__CYGWIN__) || defined(WIN32)
 
-# define ROOTLESS_ACCEL YES
 # define ROOTLESS_GLOBAL_COORDS TRUE
 # define ROOTLESS_PROTECT_ALPHA NO
 # define ROOTLESS_REDISPLAY_DELAY 10
diff --git a/miext/rootless/rootlessGC.c b/miext/rootless/rootlessGC.c
index 7e0778e..d4a5436 100644
--- a/miext/rootless/rootlessGC.c
+++ b/miext/rootless/rootlessGC.c
@@ -118,7 +118,7 @@ static GCOps rootlessGCOps = {
 
 /*
    There are two issues we must contend with when drawing. These are
-   controlled with ROOTLESS_PROTECT_ALPHA and ROOTLESS_ACCEL.
+   controlled with ROOTLESS_PROTECT_ALPHA and RootlessAccelInit().
 
    If ROOTLESS_PROTECT_ALPHA is set, we have to make sure that the alpha
    channel of the on screen windows is always opaque. fb makes this harder
@@ -141,9 +141,9 @@ static GCOps rootlessGCOps = {
    from another window since its alpha channel must also be opaque.
 
    The other issue to consider is that the rootless implementation may
-   provide accelerated drawing functions if ROOTLESS_ACCEL is set. For some
-   drawing primitives we swap in rootless acceleration functions, which use
-   the accelerated drawing functions where possible.
+   provide accelerated drawing functions if RootlessAccelInit() is called.For 
+   some drawing primitives we swap in rootless acceleration functions, which
+   use the accelerated drawing functions where possible.
 
    Where both alpha protection and acceleration is used, it is even a bigger
    win to relax the planemask to all ones because most accelerated drawing
commit 6606b9d126a73620e2adef018719a9ae37781127
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Tue Apr 15 12:01:57 2008 -0700

    XQuartz: Removed a call to RootlessReorderWindow from the Carbon thread
    (cherry picked from commit cb27d5ca8230707b276763c0ec20e586203144c9)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index c185d37..2ac8a8c 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -51,10 +51,6 @@
 #include <unistd.h>
 #include <pthread.h>
 
-#include "rootlessCommon.h"
-
-WindowPtr xprGetXWindowFromAppKit(int windowNumber); // xpr/xprFrame.c
-
 #define DEFAULTS_FILE "/usr/X11/lib/X11/xserver/Xquartz.plist"
 
 #ifndef XSERVER_VERSION
@@ -214,8 +210,6 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
 			if (_x_active) [self activateX:NO];
 		} else if ([self modalWindow] == nil) {
 			/* Must be an X window. Tell appkit it doesn't have focus. */
-			WindowPtr pWin = xprGetXWindowFromAppKit([e windowNumber]);
-			if (pWin) RootlessReorderWindow(pWin);
 			for_appkit = NO;
 
 			if ([self isActive]) {
diff --git a/hw/xquartz/xpr/dri.h b/hw/xquartz/xpr/dri.h
index cf2638a..8bb2e9e 100644
--- a/hw/xquartz/xpr/dri.h
+++ b/hw/xquartz/xpr/dri.h
@@ -41,7 +41,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "scrnintstr.h"
 #define _APPLEDRI_SERVER_
 #include "appledri.h"
-#include "Xplugin.h"
+#include <Xplugin.h>
 
 typedef void (*ClipNotifyPtr)( WindowPtr, int, int );
 
diff --git a/hw/xquartz/xpr/xprAppleWM.c b/hw/xquartz/xpr/xprAppleWM.c
index bd82df0..aa5f291 100644
--- a/hw/xquartz/xpr/xprAppleWM.c
+++ b/hw/xquartz/xpr/xprAppleWM.c
@@ -34,7 +34,7 @@
 #include "xpr.h"
 #include "applewmExt.h"
 #include "rootless.h"
-#include "Xplugin.h"
+#include <Xplugin.h>
 #include <X11/X.h>
 
 static int xprSetWindowLevel(
diff --git a/hw/xquartz/xpr/xprCursor.c b/hw/xquartz/xpr/xprCursor.c
index 9e94ed5..56f7955 100644
--- a/hw/xquartz/xpr/xprCursor.c
+++ b/hw/xquartz/xpr/xprCursor.c
@@ -37,7 +37,7 @@
 #include "xpr.h"
 #include "darwin.h"
 #include "darwinEvents.h"
-#include "Xplugin.h"
+#include <Xplugin.h>
 
 #include "mi.h"
 #include "scrnintstr.h"
diff --git a/hw/xquartz/xpr/xprFrame.c b/hw/xquartz/xpr/xprFrame.c
index 2d97f27..c892c60 100644
--- a/hw/xquartz/xpr/xprFrame.c
+++ b/hw/xquartz/xpr/xprFrame.c
@@ -33,7 +33,7 @@
 
 #include "xpr.h"
 #include "rootlessCommon.h"
-#include "Xplugin.h"
+#include <Xplugin.h>
 #include "x-hash.h"
 #include "x-list.h"
 #include "applewmExt.h"
diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c
index 65c7a9f..78dcd4b 100644
--- a/hw/xquartz/xpr/xprScreen.c
+++ b/hw/xquartz/xpr/xprScreen.c
@@ -40,7 +40,7 @@
 #include "rootless.h"
 #include "dri.h"
 #include "globals.h"
-#include "Xplugin.h"
+#include <Xplugin.h>
 #include "applewmExt.h"
 #include "micmap.h"
 
commit 55d9973b053f25bb95b26e00351dc5531caf5b04
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Fri Apr 11 17:49:51 2008 -0700

    Xquartz: Added applicationShouldHandleReopen:hasVisibleWindows to handle dock icon clicking

diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m
index 5bf4f4d..2fd9886 100644
--- a/hw/xquartz/X11Controller.m
+++ b/hw/xquartz/X11Controller.m
@@ -743,15 +743,21 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
 
 - (BOOL) application:(NSApplication *)app openFile:(NSString *)filename
 {
-  const char *name = [filename UTF8String];
-	
-  if (finished_launching)
-    [self launch_client:filename];
-  else if (name[0] != ':')		/* ignore display names */
-    pending_apps = x_list_prepend (pending_apps, [filename retain]);
-	
-  /* FIXME: report failures. */
-  return YES;
+    const char *name = [filename UTF8String];
+    
+    if (finished_launching)
+        [self launch_client:filename];
+    else if (name[0] != ':')		/* ignore display names */
+        pending_apps = x_list_prepend (pending_apps, [filename retain]);
+    
+    /* FIXME: report failures. */
+    return YES;
+}
+
+- (BOOL) applicationShouldHandleReopen:(NSApplication *)app
+                     hasVisibleWindows:(BOOL)hasVis {
+    DarwinSendDDXEvent(kXquartzBringAllToFront, 0);
+    return YES;
 }
 
 @end
commit bc4883e00b12a9289eeb9625862d42b0ea141356
Merge: 126e9bc... dd6b0de...
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Tue Apr 8 21:25:37 2008 -0700

    Merge branch 'server-1.4-branch' into xorg-server-1.4-apple

commit 126e9bc8c480b403dedc44c1e8c4fe1476340ed9
Author: Ben Byer <bbyer at apple.com>
Date:   Tue Apr 8 20:37:25 2008 -0700

    add missing dix-config include

diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 410acdd..78708d2 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -30,6 +30,10 @@ 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 <dix-config.h>
+#endif
+
 #define NEED_EVENTS
 #include   <X11/X.h>
 #include   <X11/Xmd.h>
commit 2bb14682c60acd4f46b181655ad9759081b6a10e
Author: Ben Byer <bbyer at apple.com>
Date:   Tue Apr 8 20:35:17 2008 -0700

    add correct default ACLOCAL and PKGCONFIG_PATH settings to autogen.sh

diff --git a/autogen.sh b/autogen.sh
index 98d22ea..11864f5 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -1,5 +1,8 @@
 #! /bin/sh
 
+export PKGCONFIG_PATH=/usr/X11/lib/pkgconfig:$PKGCONFIG_PATH
+export ACLOCAL="aclocal -I /usr/X11/share/aclocal"
+
 srcdir=`dirname $0`
 test -z "$srcdir" && srcdir=.
 
commit df21312c8b0e9ef0c809bfc57cdf64f27db0d8a7
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Tue Apr 8 16:59:56 2008 -0700

    XQuartz: Fix issue where clicking on an X11 window might send that event to an X11 window in another space.
    (cherry picked from commit 2e78818232314908a73113b1d46c2420d9d4fcbf)

diff --git a/configure.ac b/configure.ac
index 427a951..1a10875 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1730,7 +1730,8 @@ if test "X$XQUARTZ" = Xauto; then
 fi
 
 if test "x$XQUARTZ" = xyes; then
-	AC_DEFINE([XQUARTZ],[1],[Have Quartz])
+	AC_DEFINE(XQUARTZ,1,[Have Quartz])
+	AC_DEFINE(ROOTLESS,1,[Build Rootless code])
 
 #glxAGL / glxCGL don't work yet
 #	AC_CACHE_CHECK([for AGL framework],xorg_cv_AGL_framework,[
diff --git a/dix/events.c b/dix/events.c
index 5bd67e3..5930ead 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -2158,6 +2158,13 @@ XYToWindow(int x, int y)
 				x - pWin->drawable.x,
 				y - pWin->drawable.y, &box))
 #endif
+#ifdef ROOTLESS
+    /* In rootless mode windows may be offscreen, even when
+     * they're in X's stack. (E.g. if the native window system
+     * implements some form of virtual desktop system).
+     */
+		&& !pWin->rootlessUnhittable
+#endif
 	    )
 	{
 	    if (spriteTraceGood >= spriteTraceSize)
diff --git a/dix/window.c b/dix/window.c
index 961c02a..f5a6a4b 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -300,6 +300,9 @@ SetWindowToDefaults(WindowPtr pWin)
 #ifdef COMPOSITE
     pWin->redirectDraw = RedirectDrawNone;
 #endif
+#ifdef ROOTLESS
+    pWin->rootlessUnhittable = FALSE;
+#endif
 }
 
 static void
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 3afbaf8..410acdd 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -56,6 +56,10 @@ in this Software without prior written authorization from The Open Group.
 #include "applewmExt.h"
 #include <X11/extensions/applewm.h>
 
+/* FIXME: Abstract this away into xpr */
+#include <Xplugin.h>
+#include "rootlessWindow.h"
+WindowPtr xprGetXWindow(xp_window_id wid);
 
 /* Fake button press/release for scroll wheel move. */
 #define SCROLLWHEELUPFAKE   4
@@ -228,7 +232,7 @@ void DarwinEventHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int neven
 
         case kXquartzWindowState:
             DEBUG_LOG("kXquartzWindowState\n");
-            RootlessNativeWindowStateChanged(xe[i].u.clientMessage.u.l.longs0,
+            RootlessNativeWindowStateChanged(xprGetXWindow(xe[i].u.clientMessage.u.l.longs0),
                                              xe[i].u.clientMessage.u.l.longs1);
             break;
 
diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index 7f600ab..45ec9f3 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -52,7 +52,6 @@
 #include "windowstr.h"
 #include "colormapst.h"
 #include "globals.h"
-#include "rootlessWindow.h"
 
 // System headers
 #include <sys/types.h>
diff --git a/include/windowstr.h b/include/windowstr.h
index 6d874ae..d9b839b 100644
--- a/include/windowstr.h
+++ b/include/windowstr.h
@@ -159,6 +159,9 @@ typedef struct _Window {
 #ifdef COMPOSITE
     unsigned		redirectDraw:2;	/* rendering is redirected from here */
 #endif
+#ifdef ROOTLESS
+    unsigned		rootlessUnhittable:1;	/* doesn't hit-test */
+#endif
     DevUnion		*devPrivates;
 } WindowRec;
 
diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index bf0380f..453f7d1 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -117,12 +117,10 @@ rootlessHasRoot (ScreenPtr pScreen)
 }
 
 void
-RootlessNativeWindowStateChanged (xp_window_id id, unsigned int state)
+RootlessNativeWindowStateChanged (WindowPtr pWin, unsigned int state)
 {
-  WindowPtr pWin;
   RootlessWindowRec *winRec;
 
-  pWin = xprGetXWindow (id);
   if (pWin == NULL) return;
 
   winRec = WINREC (pWin);
@@ -130,7 +128,7 @@ RootlessNativeWindowStateChanged (xp_window_id id, unsigned int state)
 
   winRec->is_offscreen = ((state & XP_WINDOW_STATE_OFFSCREEN) != 0);
   winRec->is_obscured = ((state & XP_WINDOW_STATE_OBSCURED) != 0);
-  //  pWin->rootlessUnhittable = winRec->is_offscreen;
+  pWin->rootlessUnhittable = winRec->is_offscreen;
 }
 
 void
@@ -143,7 +141,7 @@ RootlessNativeWindowMoved (WindowPtr pWin)
   ClientPtr client;
   RootlessWindowRec *winRec = WINREC(pWin);
 
-  if (xp_get_window_bounds (winRec->wid, &bounds) != Success) return;
+  if (xp_get_window_bounds ((xp_window_id)winRec->wid, &bounds) != Success) return;
 
   sx = dixScreenOrigins[pWin->drawable.pScreen->myNum].x + darwinMainScreenX;
   sy = dixScreenOrigins[pWin->drawable.pScreen->myNum].y + darwinMainScreenY;
@@ -1428,6 +1426,10 @@ RootlessReparentWindow(WindowPtr pWin, WindowPtr pPriorParent)
 
     pTopWin = TopLevelParent(pWin);
     assert(pTopWin != pWin);
+    
+    pWin->rootlessUnhittable = FALSE;
+    
+    DeleteProperty (pWin, xa_native_window_id ());
 
     if (WINREC(pTopWin) != NULL) {
         /* We're screwed. */
@@ -1484,7 +1486,7 @@ RootlessFlushWindowColormap (WindowPtr pWin)
   wc.colormap = RootlessColormapCallback;
   wc.colormap_data = pWin->drawable.pScreen;
 
-  configure_window (winRec->wid, XP_COLORMAP, &wc);
+  configure_window ((xp_window_id)winRec->wid, XP_COLORMAP, &wc);
 }
 
 /*
diff --git a/miext/rootless/rootlessWindow.h b/miext/rootless/rootlessWindow.h
index ad876e5..3bdb3bd 100644
--- a/miext/rootless/rootlessWindow.h
+++ b/miext/rootless/rootlessWindow.h
@@ -36,8 +36,6 @@
 
 #include "rootlessCommon.h"
 
-#include <Xplugin.h>
-
 Bool RootlessCreateWindow(WindowPtr pWin);
 Bool RootlessDestroyWindow(WindowPtr pWin);
 
@@ -61,6 +59,6 @@ void RootlessPaintWindowBorder(WindowPtr pWin, RegionPtr pRegion,
                                int what);
 void RootlessChangeBorderWidth(WindowPtr pWin, unsigned int width);
 void RootlessNativeWindowMoved (WindowPtr pWin);
-void RootlessNativeWindowStateChanged (xp_window_id id, unsigned int state); 
+void RootlessNativeWindowStateChanged (WindowPtr pWin, unsigned int state); 
 
 #endif
commit dd6b0de38d649617600a8357e576955c9b831328
Author: Hasso Tepper <hasso at estpak.ee>
Date:   Mon Apr 7 14:09:04 2008 +0300

    configure.ac: DragonFly BSD support
    
    Add support for DragonFly BSD, which is just the same as FreeBSD for all
    of these cases.
    (cherry picked from commit 0f87b41a432a6472a15ec0c9dee997e3bddbd0f2)

diff --git a/configure.ac b/configure.ac
index 72d9819..dfb2950 100644
--- a/configure.ac
+++ b/configure.ac
@@ -291,6 +291,7 @@ case $host_cpu in
 	        darwin*)	use_x86_asm="no" ;;
 		*linux*)	DEFAULT_INT10=vm86 ;;
 		*freebsd*)	AC_DEFINE(USE_DEV_IO) ;;
+		*dragonfly*)	AC_DEFINE(USE_DEV_IO) ;;
 		*netbsd*)	AC_DEFINE(USE_I386_IOPL)
 				SYS_LIBS=-li386
 				;;
@@ -316,6 +317,7 @@ case $host_cpu in
 	case $host_os in
 	        darwin*)	use_x86_asm="no" ;;
 		*freebsd*)	AC_DEFINE(USE_DEV_IO, 1, [BSD /dev/io]) ;;
+		*dragonfly*)	AC_DEFINE(USE_DEV_IO, 1, [BSD /dev/io]) ;;
 		*netbsd*)	AC_DEFINE(USE_I386_IOPL, 1, [BSD i386 iopl])
 				SYS_LIBS=-lx86_64
 				;;
@@ -337,7 +339,7 @@ DRI=no
 KDRIVE_HW=no
 dnl it would be nice to autodetect these *CONS_SUPPORTs
 case $host_os in
-  *freebsd*)
+  *freebsd* | *dragonfly*)
 	case $host_os in
 		kfreebsd*-gnu) ;;
 		*) AC_DEFINE(CSRG_BASED, 1, [System is BSD-like]) ;;
@@ -1363,7 +1365,7 @@ return 0;}
 			;;
 		esac
 		;;
-	  freebsd* | kfreebsd*-gnu)
+	  freebsd* | kfreebsd*-gnu | dragonfly*)
 	  	XORG_OS="freebsd"
 		XORG_OS_SUBDIR="bsd"
 		case $host_cpu in
commit 76b950cd6e03f0060afe463871de4570fca90213
Author: Jeremy C. Reed <reed at glacier.reedmedia.net>
Date:   Thu Aug 16 11:20:12 2007 -0500

    Add some more support for DragonFly. From Joerg Sonnenberger
    and pkgsrc.
    (cherry picked from commit 1d4bea6106d7a1c83e1dfe37fad8268589feaa0b)

diff --git a/Xext/shm.c b/Xext/shm.c
index 376f123..3c0d1ee 100644
--- a/Xext/shm.c
+++ b/Xext/shm.c
@@ -154,7 +154,7 @@ static ShmFuncs fbFuncs = {fbShmCreatePixmap, fbShmPutImage};
 }
 
 
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__)
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) || defined(__DragonFly__)
 #include <sys/signal.h>
 
 static Bool badSysCall = FALSE;
diff --git a/Xext/xf86bigfont.c b/Xext/xf86bigfont.c
index f50481f..c2f891a 100644
--- a/Xext/xf86bigfont.c
+++ b/Xext/xf86bigfont.c
@@ -104,7 +104,7 @@ static unsigned int pagesize;
 
 static Bool badSysCall = FALSE;
 
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__)
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) || defined(__DragonFly__)
 
 #include <sys/signal.h>
 
diff --git a/hw/xfree86/loader/os.c b/hw/xfree86/loader/os.c
index fdddce8..12cf3d8 100644
--- a/hw/xfree86/loader/os.c
+++ b/hw/xfree86/loader/os.c
@@ -42,6 +42,8 @@
 #define OSNAME "linux"
 #elif defined(__FreeBSD__)
 #define OSNAME "freebsd"
+#elif defined(__DragonFly__)
+#define OSNAME "dragonfly"
 #elif defined(__NetBSD__)
 #define OSNAME "netbsd"
 #elif defined(__OpenBSD__)
diff --git a/hw/xfree86/os-support/bus/Pci.h b/hw/xfree86/os-support/bus/Pci.h
index f0cb916..5ebbdd5 100644
--- a/hw/xfree86/os-support/bus/Pci.h
+++ b/hw/xfree86/os-support/bus/Pci.h
@@ -235,7 +235,7 @@
 # if defined(linux)
 #  define ARCH_PCI_INIT axpPciInit
 #  define INCLUDE_XF86_MAP_PCI_MEM
-# elif defined(__FreeBSD__) || defined(__OpenBSD__)
+# elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
 #  define ARCH_PCI_INIT freebsdPciInit
 #  define INCLUDE_XF86_MAP_PCI_MEM
 #  define INCLUDE_XF86_NO_DOMAIN
diff --git a/hw/xfree86/os-support/bus/freebsdPci.c b/hw/xfree86/os-support/bus/freebsdPci.c
index 61cb405..63c00b2 100644
--- a/hw/xfree86/os-support/bus/freebsdPci.c
+++ b/hw/xfree86/os-support/bus/freebsdPci.c
@@ -83,7 +83,7 @@ static pciBusInfo_t freebsdPci0 = {
 /* bridge      */	NULL
 };
 
-#if !defined(__OpenBSD__) && !defined(__FreeBSD__)
+#if !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__DragonFly__)
 #if X_BYTE_ORDER == X_BIG_ENDIAN
 #ifdef __sparc__
 #ifndef ASI_PL
commit c95170f23ccf4de60cb3dd5f9c64f1d561bf30d5
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Wed Apr 2 18:05:34 2008 -0700

    XQuartz: Change reporting of space change to debug log rather than stderr
    (cherry picked from commit ed15556a9fc4ebdb88f42961052fc8456082165f)

diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c
index 2956956..65c7a9f 100644
--- a/hw/xquartz/xpr/xprScreen.c
+++ b/hw/xquartz/xpr/xprScreen.c
@@ -109,7 +109,7 @@ static void eventHandler(unsigned int type, const void *arg,
             break;
 #ifdef XP_EVENT_SPACE_CHANGED
         case  XP_EVENT_SPACE_CHANGED:
-            ErrorF("XP_EVENT_SPACE_CHANGED\n");
+            DEBUG_LOG("XP_EVENT_SPACE_CHANGED\n");
             if(arg_size == sizeof(uint32_t)) {
                 uint32_t space_id = *(uint32_t *)arg;
                 DarwinSendDDXEvent(kXquartzSpaceChanged, 1, space_id);
commit 632d49fc37f9092aa5b11edea8beda29cd979851
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Wed Apr 2 15:01:33 2008 -0700

    XQuartz: Fixed missing close-paren in preference pane text.
    (cherry picked from commit ea37e151dc6032d2a1a33cef809f2a7d507aae35)

diff --git a/hw/xquartz/bundle/English.lproj/main.nib/designable.nib b/hw/xquartz/bundle/English.lproj/main.nib/designable.nib
index 672ba90..c159d6e 100644
--- a/hw/xquartz/bundle/English.lproj/main.nib/designable.nib
+++ b/hw/xquartz/bundle/English.lproj/main.nib/designable.nib
@@ -2,7 +2,7 @@
 <archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.02">
 	<data>
 		<int key="IBDocument.SystemTarget">1050</int>
-		<string key="IBDocument.SystemVersion">9C31</string>
+		<string key="IBDocument.SystemVersion">9C7010</string>
 		<string key="IBDocument.InterfaceBuilderVersion">639</string>
 		<string key="IBDocument.AppKitVersion">949.26</string>
 		<string key="IBDocument.HIToolboxVersion">352.00</string>
@@ -948,7 +948,7 @@ ZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KA</string>
 												<object class="NSTextFieldCell" key="NSCell" id="989804990">
 													<int key="NSCellFlags">67239424</int>
 													<int key="NSCellFlags2">4194304</int>
-													<string key="NSContents">When enabled, creation of a new X11 window will cause X11.app to move to the foreground (instead of Finder.app, Terminal.app, etc.</string>
+													<string key="NSContents">When enabled, creation of a new X11 window will cause X11.app to move to the foreground (instead of Finder.app, Terminal.app, etc.)</string>
 													<reference key="NSSupport" ref="26"/>
 													<reference key="NSControlView" ref="57161931"/>
 													<reference key="NSBackgroundColor" ref="57160303"/>
diff --git a/hw/xquartz/bundle/English.lproj/main.nib/keyedobjects.nib b/hw/xquartz/bundle/English.lproj/main.nib/keyedobjects.nib
index 91a7c5a..95420e4 100644
Binary files a/hw/xquartz/bundle/English.lproj/main.nib/keyedobjects.nib and b/hw/xquartz/bundle/English.lproj/main.nib/keyedobjects.nib differ
commit 7e653f806ff5508aace059312156f319a9ed4479
Author: Ben Byer <bbyer at apple.com>
Date:   Tue Apr 1 00:40:46 2008 -0700

    The AppKit thread should not be calling directly into the X server
    functions to change state when the keyboard is reloaded; instead,
    pass it as an event.

diff --git a/hw/xquartz/darwin.h b/hw/xquartz/darwin.h
index a8ac9ff..f672047 100644
--- a/hw/xquartz/darwin.h
+++ b/hw/xquartz/darwin.h
@@ -91,13 +91,8 @@ extern int              darwinMainScreenY;
  * Special ddx events understood by the X server
  */
 enum {
-    kXquartzUpdateModifiers   // update all modifier keys
+    kXquartzReloadKeymap      // Reload system keymap
             = LASTEvent+1,    // (from X.h list of event names)
-    kXquartzUpdateButtons,    // update state of mouse buttons 2 and up
-    kXquartzScrollWheel,      // scroll wheel event
-    /*
-     * Quartz-specific events -- not used in IOKit mode
-     */
     kXquartzActivate,         // restore X drawing and cursor
     kXquartzDeactivate,       // clip X drawing and switch to Aqua cursor
     kXquartzSetRootClip,      // enable or disable drawing to the X screen
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index b6cd3f2..3afbaf8 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -289,6 +289,7 @@ Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr) {
         FatalError("Couldn't allocate event buffer\n");
 
     mieqInit();
+    mieqSetHandler(kXquartzReloadKeymap, DarwinKeyboardReloadHandler);
     mieqSetHandler(kXquartzActivate, DarwinEventHandler);
     mieqSetHandler(kXquartzDeactivate, DarwinEventHandler);
     mieqSetHandler(kXquartzSetRootClip, DarwinEventHandler);
@@ -322,7 +323,7 @@ void ProcessInputEvents(void) {
     // Empty the signaling pipe
     int x = sizeof(xe);
     while (x == sizeof(xe)) {
-      DEBUG_LOG("draining pipe\n");
+//      DEBUG_LOG("draining pipe\n");
       x = read(darwinEventReadFD, &xe, sizeof(xe));
     }
 }
@@ -412,8 +413,8 @@ void DarwinSendKeyboardEvents(int ev_type, int keycode) {
 
     this_seed = QuartzSystemKeymapSeed();
     if (this_seed != last_seed) {
-      last_seed = this_seed;
-      DarwinKeyboardReload(darwinKeyboard);
+		last_seed = this_seed;
+		DarwinSendDDXEvent(kXquartzReloadKeymap, 0);
     }
   }
 
diff --git a/hw/xquartz/darwinKeyboard.c b/hw/xquartz/darwinKeyboard.c
index 472d80d..a9fbdfc 100644
--- a/hw/xquartz/darwinKeyboard.c
+++ b/hw/xquartz/darwinKeyboard.c
@@ -850,16 +850,18 @@ static Bool InitModMap(register KeyClassPtr keyc) {
 }
 
 
-void DarwinKeyboardReload(DeviceIntPtr pDev) {
+void DarwinKeyboardReloadHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents) {
     KeySymsRec keySyms;
-
+	if (dev == NULL) dev = darwinKeyboard;
+	
+	DEBUG_LOG("DarwinKeyboardReloadHandler(%p)\n", dev);
     DarwinLoadKeyboardMapping(&keySyms);
 
-    if (SetKeySymsMap(&pDev->key->curKeySyms, &keySyms)) {
+    if (SetKeySymsMap(&dev->key->curKeySyms, &keySyms)) {
         /* now try to update modifiers. */
 
-        memmove(pDev->key->modifierMap, keyInfo.modMap, MAP_LENGTH);
-        InitModMap(pDev->key);
+        memmove(dev->key->modifierMap, keyInfo.modMap, MAP_LENGTH);
+        InitModMap(dev->key);
     } else DEBUG_LOG("SetKeySymsMap=0\n");
 
     SendMappingNotify(MappingKeyboard, MIN_KEYCODE, NUM_KEYCODES, 0);
diff --git a/hw/xquartz/darwinKeyboard.h b/hw/xquartz/darwinKeyboard.h
index 5cf64c7..762f659 100644
--- a/hw/xquartz/darwinKeyboard.h
+++ b/hw/xquartz/darwinKeyboard.h
@@ -31,7 +31,7 @@
 
 /* Provided for darwinEvents.c */
 extern darwinKeyboardInfo keyInfo;
-void DarwinKeyboardReload(DeviceIntPtr pDev);
+void DarwinKeyboardReloadHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents);
 void DarwinKeyboardInit(DeviceIntPtr pDev);
 int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide);
 int DarwinModifierNXKeyToNXKeycode(int key, int side);
diff --git a/hw/xquartz/quartzKeyboard.h b/hw/xquartz/quartzKeyboard.h
index 8131b56..4f495bb 100644
--- a/hw/xquartz/quartzKeyboard.h
+++ b/hw/xquartz/quartzKeyboard.h
@@ -46,7 +46,6 @@ typedef struct darwinKeyboardInfo_struct {
 } darwinKeyboardInfo;
 
 /* These functions need to be implemented by Xquartz, XDarwin, etc. */
-void DarwinKeyboardReload(DeviceIntPtr pDev);
 Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info);
 unsigned int QuartzSystemKeymapSeed(void);
 
commit eb083d3f68f459d90417558da1ed00729b749950
Author: Ben Byer <bbyer at apple.com>
Date:   Mon Mar 31 23:31:25 2008 -0700

    formatting cleanup for X11Application.m (no code changes)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 8ddc347..c185d37 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -170,171 +170,170 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
     static TSMDocumentID x11_document;
 	DEBUG_LOG("state=%d, _x_active=%d, \n", state, _x_active)
     if (state) {
-      DarwinSendDDXEvent(kXquartzActivate, 0);
-      
-      if (!_x_active) {
-	if (x11_document == 0 && darwinKeymapFile == NULL) {
-	  OSType types[1];
-	  types[0] = kUnicodeDocument;
-	  NewTSMDocument (1, types, &x11_document, 0);
-	}
-	
-	if (x11_document != 0)	ActivateTSMDocument (x11_document);
-      }
+		DarwinSendDDXEvent(kXquartzActivate, 0);
+
+		if (!_x_active) {
+			if (x11_document == 0 && darwinKeymapFile == NULL) {
+				OSType types[1];
+				types[0] = kUnicodeDocument;
+				NewTSMDocument (1, types, &x11_document, 0);
+			}
+
+			if (x11_document != 0)	ActivateTSMDocument (x11_document);
+		}
     } else {
-      DarwinSendDDXEvent(kXquartzDeactivate, 0);
-      
-      if (_x_active && x11_document != 0)
-		DeactivateTSMDocument (x11_document);
-    }
-    
-    _x_active = state;
+		DarwinSendDDXEvent(kXquartzDeactivate, 0);
+
+		if (_x_active && x11_document != 0)
+			DeactivateTSMDocument (x11_document);
+	}
+
+	_x_active = state;
 }
 
 - (void) became_key:(NSWindow *)win {
-    [self activateX:NO];
+	[self activateX:NO];
 }
 
 - (void) sendEvent:(NSEvent *)e {
-  NSEventType type;
-  BOOL for_appkit, for_x;
-  
-  type = [e type];
-  
-  /* By default pass down the responder chain and to X. */
-  for_appkit = YES;
-  for_x = YES;
-  
-  switch (type) {
-  case NSLeftMouseDown: case NSRightMouseDown: case NSOtherMouseDown:
-  case NSLeftMouseUp: case NSRightMouseUp: case NSOtherMouseUp:
-    if ([e window] != nil) {
-      /* Pointer event has an (AppKit) window. Probably something for the kit. */
-      for_x = NO;
-      if (_x_active) [self activateX:NO];
-    } else if ([self modalWindow] == nil) {
-      /* Must be an X window. Tell appkit it doesn't have focus. */
-      WindowPtr pWin = xprGetXWindowFromAppKit([e windowNumber]);
-      if (pWin) RootlessReorderWindow(pWin);
-      for_appkit = NO;
-      
-      if ([self isActive]) {
-	[self deactivate];
-	
-	if (!_x_active && quartzProcs->IsX11Window([e window],
-						   [e windowNumber]))
-	  [self activateX:YES];
-      }
-    }
-    break;
-      
-  case NSKeyDown: case NSKeyUp:
-    if (_x_active) {
-      static int swallow_up;
-      
-      /* No kit window is focused, so send it to X. */
-      for_appkit = NO;
-      if (type == NSKeyDown) {
-	/* Before that though, see if there are any global
-	   shortcuts bound to it. */
-	
-	if (X11EnableKeyEquivalents
-	    && [[self mainMenu] performKeyEquivalent:e]) {
-	  swallow_up = [e keyCode];
-	  for_x = NO;
-	} else if (!quartzEnableRootless
-		   && ([e modifierFlags] & ALL_KEY_MASKS)
-		   == (NSCommandKeyMask | NSAlternateKeyMask)
-		   && ([e keyCode] == 0 /*a*/
-		    || [e keyCode] == 53 /*Esc*/)) {
-	  swallow_up = 0;
-	  for_x = NO;
+ 	NSEventType type;
+	BOOL for_appkit, for_x;
+
+	type = [e type];
+
+	/* By default pass down the responder chain and to X. */
+	for_appkit = YES;
+	for_x = YES;
+  
+	switch (type) {
+		case NSLeftMouseDown: case NSRightMouseDown: case NSOtherMouseDown:
+		case NSLeftMouseUp: case NSRightMouseUp: case NSOtherMouseUp:
+		if ([e window] != nil) {
+			/* Pointer event has an (AppKit) window. Probably something for the kit. */
+			for_x = NO;
+			if (_x_active) [self activateX:NO];
+		} else if ([self modalWindow] == nil) {
+			/* Must be an X window. Tell appkit it doesn't have focus. */
+			WindowPtr pWin = xprGetXWindowFromAppKit([e windowNumber]);
+			if (pWin) RootlessReorderWindow(pWin);
+			for_appkit = NO;
+
+			if ([self isActive]) {
+				[self deactivate];
+				if (!_x_active && quartzProcs->IsX11Window([e window],
+					[e windowNumber]))
+					[self activateX:YES];
+			}
+		}
+		break;
+
+		case NSKeyDown: case NSKeyUp:
+		if (_x_active) {
+			static int swallow_up;
+
+			/* No kit window is focused, so send it to X. */
+			for_appkit = NO;
+			if (type == NSKeyDown) {
+				/* Before that though, see if there are any global
+				shortcuts bound to it. */
+
+					if (X11EnableKeyEquivalents
+						&& [[self mainMenu] performKeyEquivalent:e]) {
+							swallow_up = [e keyCode];
+							for_x = NO;
+					} else if (!quartzEnableRootless
+						&& ([e modifierFlags] & ALL_KEY_MASKS)
+						== (NSCommandKeyMask | NSAlternateKeyMask)
+						&& ([e keyCode] == 0 /*a*/
+							|| [e keyCode] == 53 /*Esc*/)) {
+						swallow_up = 0;
+						for_x = NO;
 #ifdef DARWIN_DDX_MISSING
-	  DarwinSendDDXEvent(kXquartzToggleFullscreen, 0);
+						DarwinSendDDXEvent(kXquartzToggleFullscreen, 0);
 #endif
+					}
+			} else {
+			/* If we saw a key equivalent on the down, don't pass
+	   			the up through to X. */
+
+				if (swallow_up != 0 && [e keyCode] == swallow_up) {
+					swallow_up = 0;
+					for_x = NO;
+				}
+			}
+    		} else for_x = NO;
+    	break;
+
+		case NSFlagsChanged:
+			/* For the l33t X users who remap modifier keys to normal keysyms. */
+			if (!_x_active) for_x = NO;
+		break;
+
+		case NSAppKitDefined:
+		switch ([e subtype]) {
+			case NSApplicationActivatedEventType:
+      		for_x = NO;
+			if ([self modalWindow] == nil) {
+				for_appkit = NO;
+
+				/* FIXME: hack to avoid having to pass the event to appkit,
+	   			which would cause it to raise one of its windows. */
+				_appFlags._active = YES;
+
+				[self activateX:YES];
+				if ([e data2] & 0x10) X11ApplicationSetFrontProcess();
+			}
+			break;
+
+			case 18: /* ApplicationDidReactivate */
+				if (quartzHasRoot) for_appkit = NO;
+			break;
+
+			case NSApplicationDeactivatedEventType:
+				for_x = NO;
+				[self activateX:NO];
+			break;
+		}
+	break;
+ 
+	default: break; /* for gcc */
 	}
-      } else {
-	/* If we saw a key equivalent on the down, don't pass
-	   the up through to X. */
-	
-	if (swallow_up != 0 && [e keyCode] == swallow_up) {
-	  swallow_up = 0;
-	  for_x = NO;
-	}
-      }
-    } else for_x = NO;
-    break;
-    
-  case NSFlagsChanged:
-    /* For the l33t X users who remap modifier keys to normal keysyms. */
-    if (!_x_active) for_x = NO;
-    break;
-    
-  case NSAppKitDefined:
-    switch ([e subtype]) {
-    case NSApplicationActivatedEventType:
-      for_x = NO;
-      if ([self modalWindow] == nil) {
-		for_appkit = NO;
-	
-	/* FIXME: hack to avoid having to pass the event to appkit,
-	   which would cause it to raise one of its windows. */
-	_appFlags._active = YES;
-	
-	[self activateX:YES];
-	if ([e data2] & 0x10) X11ApplicationSetFrontProcess();
-      }
-      break;
-      
-    case 18: /* ApplicationDidReactivate */
-      if (quartzHasRoot) for_appkit = NO;
-      break;
-      
-    case NSApplicationDeactivatedEventType:
-      for_x = NO;
-      [self activateX:NO];
-      break;
-    }
-    break;
-    
-  default: break; /* for gcc */
-  }
-  
-  if (for_appkit) [super sendEvent:e];
-  
-  if (for_x) send_nsevent (type, e);
+
+	if (for_appkit) [super sendEvent:e];
+
+	if (for_x) send_nsevent (type, e);
 }
 
 - (void) set_window_menu:(NSArray *)list {
-    [_controller set_window_menu:list];
+	[_controller set_window_menu:list];
 }
 
 - (void) set_window_menu_check:(NSNumber *)n {
-    [_controller set_window_menu_check:n];
+	[_controller set_window_menu_check:n];
 }
 
 - (void) set_apps_menu:(NSArray *)list {
-    [_controller set_apps_menu:list];
+	[_controller set_apps_menu:list];
 }
 
 - (void) set_front_process:unused {
-    [NSApp activateIgnoringOtherApps:YES];
+	[NSApp activateIgnoringOtherApps:YES];
 
-    if ([self modalWindow] == nil)
-        [self activateX:YES];
+	if ([self modalWindow] == nil)
+		[self activateX:YES];
 }
 
 - (void) set_can_quit:(NSNumber *)state {
-    [_controller set_can_quit:[state boolValue]];
+	[_controller set_can_quit:[state boolValue]];
 }
 
 - (void) server_ready:unused {
-    [_controller server_ready];
+	[_controller server_ready];
 }
 
 - (void) show_hide_menubar:(NSNumber *)state {
-    if ([state boolValue]) ShowMenuBar ();
-    else HideMenuBar ();
+	if ([state boolValue]) ShowMenuBar ();
+	else HideMenuBar ();
 }
 
 
@@ -352,57 +351,57 @@ static void cfrelease (CFAllocatorRef a, const void *b) {
 }
 
 static CFMutableArrayRef nsarray_to_cfarray (NSArray *in) {
-    CFMutableArrayRef out;
-    CFArrayCallBacks cb;
-    NSObject *ns;
-    const CFTypeRef *cf;
-    int i, count;
-	
-    memset (&cb, 0, sizeof (cb));
-    cb.version = 0;
-    cb.retain = cfretain;
-    cb.release = cfrelease;
-	
-    count = [in count];
-    out = CFArrayCreateMutable (NULL, count, &cb);
-	
-    for (i = 0; i < count; i++) {
-      ns = [in objectAtIndex:i];
-      
-      if ([ns isKindOfClass:[NSArray class]])
-	cf = (CFTypeRef) nsarray_to_cfarray ((NSArray *) ns);
-      else
-	cf = CFRetain ((CFTypeRef) ns);
-      
-      CFArrayAppendValue (out, cf);
-      CFRelease (cf);
-    }
-    
-    return out;
+	CFMutableArrayRef out;
+	CFArrayCallBacks cb;
+	NSObject *ns;
+	const CFTypeRef *cf;
+	int i, count;
+
+	memset (&cb, 0, sizeof (cb));
+	cb.version = 0;
+	cb.retain = cfretain;
+	cb.release = cfrelease;
+
+	count = [in count];
+	out = CFArrayCreateMutable (NULL, count, &cb);
+
+	for (i = 0; i < count; i++) {
+		ns = [in objectAtIndex:i];
+
+		if ([ns isKindOfClass:[NSArray class]])
+			cf = (CFTypeRef) nsarray_to_cfarray ((NSArray *) ns);
+		else
+			cf = CFRetain ((CFTypeRef) ns);
+
+		CFArrayAppendValue (out, cf);
+		CFRelease (cf);
+	}
+
+	return out;
 }
 
 static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
-    NSMutableArray *out;
-    const CFTypeRef *cf;
-    NSObject *ns;
-    int i, count;
-	
-    count = CFArrayGetCount (in);
-    out = [[NSMutableArray alloc] initWithCapacity:count];
-	
-    for (i = 0; i < count; i++) {
-      cf = CFArrayGetValueAtIndex (in, i);
-		
-      if (CFGetTypeID (cf) == CFArrayGetTypeID ())
-	ns = cfarray_to_nsarray ((CFArrayRef) cf);
-      else
-	ns = [(id)cf retain];
-      
-      [out addObject:ns];
-      [ns release];
-    }
-    
-    return out;
+	NSMutableArray *out;
+	const CFTypeRef *cf;
+	NSObject *ns;
+	int i, count;
+
+	count = CFArrayGetCount (in);
+	out = [[NSMutableArray alloc] initWithCapacity:count];
+
+	for (i = 0; i < count; i++) {
+		cf = CFArrayGetValueAtIndex (in, i);
+
+		if (CFGetTypeID (cf) == CFArrayGetTypeID ())
+			ns = cfarray_to_nsarray ((CFArrayRef) cf);
+		else
+			ns = [(id)cf retain];
+
+		[out addObject:ns];
+		[ns release];
+	}
+
+	return out;
 }
 
 - (CFPropertyListRef) prefs_get:(NSString *)key {
@@ -859,86 +858,68 @@ convert_flags (unsigned int nsflags) {
     return xflags;
 }
 
-
-// This code should probably be merged with that in XDarwin's XServer.m - BB
 static void send_nsevent (NSEventType type, NSEvent *e) {
-  //    static unsigned int button_state = 0;
-    NSRect screen;
-    NSPoint location;
-    NSWindow *window;
-    int pointer_x, pointer_y, ev_button, ev_type;
-    float pressure, tilt_x, tilt_y;
-
-    //    int num_events=0, i=0, state;
-    // xEvent xe;
-	
-    /* convert location to global top-left coordinates */
-    location = [e locationInWindow];
-    window = [e window];
-    screen = [[[NSScreen screens] objectAtIndex:0] frame];
-		
+	NSRect screen;
+	NSPoint location;
+	NSWindow *window;
+	int pointer_x, pointer_y, ev_button, ev_type;
+	float pressure, tilt_x, tilt_y;
+
+	/* convert location to global top-left coordinates */
+	location = [e locationInWindow];
+	window = [e window];
+	screen = [[[NSScreen screens] objectAtIndex:0] frame];
+
     if (window != nil)	{
-      NSRect frame = [window frame];
-      pointer_x = location.x + frame.origin.x;
-      pointer_y = (((screen.origin.y + screen.size.height)
-		    - location.y) - frame.origin.y);
-    } else {
-      pointer_x = location.x;
-      pointer_y = (screen.origin.y + screen.size.height) - location.y;
-    }
-    
-    pointer_y -= aquaMenuBarHeight;
-    //    state = convert_flags ([e modifierFlags]);
-    
-    pressure = 0;  // for tablets
-    tilt_x = 0;
-    tilt_y = 0;
-
-    switch (type) {
-    case NSLeftMouseDown:    ev_button=1; ev_type=ButtonPress; goto handle_mouse;
-    case NSOtherMouseDown:   ev_button=2; ev_type=ButtonPress; goto handle_mouse;
-    case NSRightMouseDown:   ev_button=3; ev_type=ButtonPress; goto handle_mouse;
-    case NSLeftMouseUp:      ev_button=1; ev_type=ButtonRelease; goto handle_mouse;
-    case NSOtherMouseUp:     ev_button=2; ev_type=ButtonRelease; goto handle_mouse;
-    case NSRightMouseUp:     ev_button=3; ev_type=ButtonRelease; goto handle_mouse;
-    case NSLeftMouseDragged:  ev_button=1; ev_type=MotionNotify; goto handle_mouse;
-    case NSOtherMouseDragged: ev_button=2; ev_type=MotionNotify; goto handle_mouse;
-    case NSRightMouseDragged: ev_button=3; ev_type=MotionNotify; goto handle_mouse;
-    case NSTabletPoint:
-      pressure = [e pressure];
-      tilt_x = [e tilt].x;
-      tilt_y = [e tilt].y; // fall through
-    case NSMouseMoved: ev_button=0; ev_type=MotionNotify; goto handle_mouse;
-    handle_mouse:
-      
-      /* I'm not sure the below code is necessary or useful (-bb)
-	if(ev_type==ButtonPress) {
-	if (!quartzProcs->IsX11Window([e window], [e windowNumber])) {
-	  fprintf(stderr, "Dropping event because it's not a window\n");
-	  break;
+		NSRect frame = [window frame];
+		pointer_x = location.x + frame.origin.x;
+		pointer_y = (((screen.origin.y + screen.size.height)
+			- location.y) - frame.origin.y);
+	} else {
+		pointer_x = location.x;
+		pointer_y = (screen.origin.y + screen.size.height) - location.y;
 	}
-	button_state |= (1 << ev_button);
-	DarwinSendPointerEvents(ev_type, ev_button, pointer_x, pointer_y);
-      } else if (ev_type==ButtonRelease && (button_state & (1 << ev_button)) == 0) break;
-      */
-
-      //      if ([e subtype] == NSTabletPointEventSubtype) pressure = [e pressure];
-      DarwinSendPointerEvents(ev_type, ev_button, pointer_x, pointer_y,
-			      pressure, tilt_x, tilt_y);
-      break;
-    case NSScrollWheel:
-      DarwinSendScrollEvents([e deltaY], pointer_x, pointer_y,
-			     pressure, tilt_x, tilt_y);
-      break;
-      
-    case NSKeyDown:  // do we need to translate these keyCodes?
-    case NSKeyUp:
-      DarwinSendKeyboardEvents((type == NSKeyDown)?KeyPress:KeyRelease, [e keyCode]);
-      break;
-
-    case NSFlagsChanged:
-      DarwinUpdateModKeys([e modifierFlags]);
-      break;
-    default: break; /* for gcc */
-    }	
+
+	pointer_y -= aquaMenuBarHeight;
+
+	pressure = 0;  // for tablets
+	tilt_x = 0;
+	tilt_y = 0;
+
+	switch (type) {
+		case NSLeftMouseDown:    ev_button=1; ev_type=ButtonPress; goto handle_mouse;
+		case NSOtherMouseDown:   ev_button=2; ev_type=ButtonPress; goto handle_mouse;
+		case NSRightMouseDown:   ev_button=3; ev_type=ButtonPress; goto handle_mouse;
+		case NSLeftMouseUp:      ev_button=1; ev_type=ButtonRelease; goto handle_mouse;
+		case NSOtherMouseUp:     ev_button=2; ev_type=ButtonRelease; goto handle_mouse;
+		case NSRightMouseUp:     ev_button=3; ev_type=ButtonRelease; goto handle_mouse;
+		case NSLeftMouseDragged:  ev_button=1; ev_type=MotionNotify; goto handle_mouse;
+		case NSOtherMouseDragged: ev_button=2; ev_type=MotionNotify; goto handle_mouse;
+		case NSRightMouseDragged: ev_button=3; ev_type=MotionNotify; goto handle_mouse;
+		case NSTabletPoint:
+			pressure = [e pressure];
+			tilt_x = [e tilt].x;
+			tilt_y = [e tilt].y; // fall through
+		case NSMouseMoved: ev_button=0; ev_type=MotionNotify; goto handle_mouse;
+		handle_mouse:
+
+//      if ([e subtype] == NSTabletPointEventSubtype) pressure = [e pressure];
+		DarwinSendPointerEvents(ev_type, ev_button, pointer_x, pointer_y,
+			pressure, tilt_x, tilt_y);
+		break;
+
+		case NSScrollWheel:
+			DarwinSendScrollEvents([e deltaY], pointer_x, pointer_y,
+				pressure, tilt_x, tilt_y);
+		break;
+
+		case NSKeyDown: case NSKeyUp:
+			DarwinSendKeyboardEvents((type == NSKeyDown)?KeyPress:KeyRelease, [e keyCode]);
+		break;
+
+		case NSFlagsChanged:
+			DarwinUpdateModKeys([e modifierFlags]);
+		break;
+		default: break; /* for gcc */
+	}	
 }
commit bee2b377efc930e25017636e5112093a3a6549c7
Author: Ben Byer <bbyer at apple.com>
Date:   Mon Mar 31 22:55:24 2008 -0700

    moved and renamed QuartzMessageServerThread to
    DarwinSendDDXEvent to make more clear what it actually does.

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 0bed917..8ddc347 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -1,6 +1,6 @@
 /* X11Application.m -- subclass of NSApplication to multiplex events
  
- Copyright (c) 2002-2007 Apple Inc.
+ Copyright (c) 2002-2008 Apple Inc.
  
  Permission is hereby granted, free of charge, to any person
  obtaining a copy of this software and associated documentation files
@@ -170,7 +170,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
     static TSMDocumentID x11_document;
 	DEBUG_LOG("state=%d, _x_active=%d, \n", state, _x_active)
     if (state) {
-      QuartzMessageServerThread (kXquartzActivate, 0);
+      DarwinSendDDXEvent(kXquartzActivate, 0);
       
       if (!_x_active) {
 	if (x11_document == 0 && darwinKeymapFile == NULL) {
@@ -182,10 +182,10 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
 	if (x11_document != 0)	ActivateTSMDocument (x11_document);
       }
     } else {
-      QuartzMessageServerThread (kXquartzDeactivate, 0);
+      DarwinSendDDXEvent(kXquartzDeactivate, 0);
       
       if (_x_active && x11_document != 0)
-	DeactivateTSMDocument (x11_document);
+		DeactivateTSMDocument (x11_document);
     }
     
     _x_active = state;
@@ -250,7 +250,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
 	  swallow_up = 0;
 	  for_x = NO;
 #ifdef DARWIN_DDX_MISSING
-	  QuartzMessageServerThread (kXquartzToggleFullscreen, 0);
+	  DarwinSendDDXEvent(kXquartzToggleFullscreen, 0);
 #endif
 	}
       } else {
@@ -275,7 +275,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
     case NSApplicationActivatedEventType:
       for_x = NO;
       if ([self modalWindow] == nil) {
-	for_appkit = NO;
+		for_appkit = NO;
 	
 	/* FIXME: hack to avoid having to pass the event to appkit,
 	   which would cause it to raise one of its windows. */
@@ -658,7 +658,7 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
 
 /* This will end up at the end of the responder chain. */
 - (void) copy:sender {
-  QuartzMessageServerThread (kXquartzPasteboardNotify, 1,
+  DarwinSendDDXEvent(kXquartzPasteboardNotify, 1,
 			     AppleWMCopyToPasteboard);
 }
 
diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m
index aa9fa94..5bf4f4d 100644
--- a/hw/xquartz/X11Controller.m
+++ b/hw/xquartz/X11Controller.m
@@ -1,6 +1,6 @@
 /* X11Controller.m -- connect the IB ui, also the NSApp delegate
  
-   Copyright (c) 2002-2007 Apple Inc. All rights reserved.
+   Copyright (c) 2002-2008 Apple Inc. All rights reserved.
  
    Permission is hereby granted, free of charge, to any person
    obtaining a copy of this software and associated documentation files
@@ -103,7 +103,7 @@
 {
   [NSApp activateIgnoringOtherApps:YES];
 	
-  QuartzMessageServerThread (kXquartzControllerNotify, 2,
+  DarwinSendDDXEvent(kXquartzControllerNotify, 2,
 			     AppleWMWindowMenuItem, [sender tag]);
 }
 
@@ -254,7 +254,7 @@
   [self remove_window_menu];
   [self install_window_menu:list];
 	
-  QuartzMessageServerThread (kXquartzControllerNotify, 1,
+  DarwinSendDDXEvent(kXquartzControllerNotify, 1,
 			     AppleWMWindowMenuNotify);
 }
 
@@ -539,20 +539,20 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
 - (void) hide_window:sender
 {
   if ([X11App x_active])
-    QuartzMessageServerThread (kXquartzControllerNotify, 1, AppleWMHideWindow);
+    DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMHideWindow);
   else
     NSBeep ();			/* FIXME: something here */
 }
 
 - (IBAction)bring_to_front:sender
 {
-  QuartzMessageServerThread(kXquartzControllerNotify, 1, AppleWMBringAllToFront);
+  DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMBringAllToFront);
 }
 
 - (IBAction)close_window:sender
 {
   if ([X11App x_active])
-    QuartzMessageServerThread (kXquartzControllerNotify, 1, AppleWMCloseWindow);
+    DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMCloseWindow);
   else
     [[NSApp keyWindow] performClose:sender];
 }
@@ -560,7 +560,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
 - (IBAction)minimize_window:sender
 {
   if ([X11App x_active])
-    QuartzMessageServerThread (kXquartzControllerNotify, 1, AppleWMMinimizeWindow);
+    DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMMinimizeWindow);
   else
     [[NSApp keyWindow] performMiniaturize:sender];
 }
@@ -568,19 +568,19 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
 - (IBAction)zoom_window:sender
 {
   if ([X11App x_active])
-    QuartzMessageServerThread (kXquartzControllerNotify, 1, AppleWMZoomWindow);
+    DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMZoomWindow);
   else
     [[NSApp keyWindow] performZoom:sender];
 }
 
 - (IBAction) next_window:sender
 {
-  QuartzMessageServerThread (kXquartzControllerNotify, 1, AppleWMNextWindow);
+  DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMNextWindow);
 }
 
 - (IBAction) previous_window:sender
 {
-  QuartzMessageServerThread (kXquartzControllerNotify, 1, AppleWMPreviousWindow);
+  DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMPreviousWindow);
 }
 
 - (IBAction) enable_fullscreen_changed:sender
@@ -588,7 +588,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
   int value = ![enable_fullscreen intValue];
 	
 #ifdef DARWIN_DDX_MISSING
-  QuartzMessageServerThread (kXquartzSetRootless, 1, value);
+  DarwinSendDDXEvent(kXquartzSetRootless, 1, value);
 #endif
 	
   [NSApp prefs_set_boolean:@PREFS_ROOTLESS value:value];
@@ -598,7 +598,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
 - (IBAction) toggle_fullscreen:sender
 {
 #ifdef DARWIN_DDX_MISSING
-  QuartzMessageServerThread (kXquartzToggleFullscreen, 0);
+  DarwinSendDDXEvent(kXquartzToggleFullscreen, 0);
 #endif
 }
 
@@ -661,7 +661,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
 
 - (IBAction) quit:sender
 {
-  QuartzMessageServerThread (kXquartzQuit, 0);
+  DarwinSendDDXEvent(kXquartzQuit, 0);
 }
 
 - (IBAction) x11_help:sender
@@ -684,12 +684,12 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
 
 - (void) applicationDidHide:(NSNotification *)notify
 {
-  QuartzMessageServerThread (kXquartzControllerNotify, 1, AppleWMHideAll);
+  DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMHideAll);
 }
 
 - (void) applicationDidUnhide:(NSNotification *)notify
 {
-  QuartzMessageServerThread (kXquartzControllerNotify, 1, AppleWMShowAll);
+  DarwinSendDDXEvent(kXquartzControllerNotify, 1, AppleWMShowAll);
 }
 
 - (NSApplicationTerminateReply) applicationShouldTerminate:sender
@@ -717,7 +717,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
   [X11App prefs_synchronize];
 	
   /* shutdown the X server, it will exit () for us. */
-  QuartzMessageServerThread (kXquartzQuit, 0);
+  DarwinSendDDXEvent(kXquartzQuit, 0);
 	
   /* In case it doesn't, exit anyway after a while. */
   while (sleep (10) != 0) ;
diff --git a/hw/xquartz/darwin.h b/hw/xquartz/darwin.h
index a71941d..a8ac9ff 100644
--- a/hw/xquartz/darwin.h
+++ b/hw/xquartz/darwin.h
@@ -1,4 +1,5 @@
 /*
+ * Copyright (C) 2008 Apple, Inc.
  * Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -120,6 +121,8 @@ enum {
     kXquartzWindowMoved,      // window has moved on screen
 };
 
+void DarwinSendDDXEvent(int type, int argc, ...);
+
 #define ENABLE_DEBUG_LOG 1
 
 #ifdef ENABLE_DEBUG_LOG
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 28a712d..b6cd3f2 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -476,3 +476,31 @@ void DarwinUpdateModKeys(int flags) {
   DarwinUpdateModifiers(KeyPress, ~old_flags & flags);
   old_flags = flags;
 }
+
+
+/*
+ * DarwinSendDDXEvent
+ *  Send the X server thread a message by placing it on the event queue.
+ */
+void DarwinSendDDXEvent(int type, int argc, ...) {
+    xEvent xe;
+    INT32 *argv;
+    int i, max_args;
+    va_list args;
+
+    memset(&xe, 0, sizeof(xe));
+    xe.u.u.type = type;
+    xe.u.clientMessage.u.l.type = type;
+
+    argv = &xe.u.clientMessage.u.l.longs0;
+    max_args = 4;
+
+    if (argc > 0 && argc <= max_args) {
+        va_start (args, argc);
+        for (i = 0; i < argc; i++)
+            argv[i] = (int) va_arg (args, int);
+        va_end (args);
+    }
+
+    mieqEnqueue(NULL, &xe);
+}
diff --git a/hw/xquartz/darwinEvents.h b/hw/xquartz/darwinEvents.h
index 1d8e92a..7c56be9 100644
--- a/hw/xquartz/darwinEvents.h
+++ b/hw/xquartz/darwinEvents.h
@@ -1,4 +1,5 @@
 /*
+ * Copyright (c) 2008 Apple, Inc.
  * Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -43,4 +44,5 @@ void DarwinUpdateModKeys(int flags);
 
 void DarwinEventHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, 
 			int nevents);
+
 #endif  /* _DARWIN_EVENTS_H */
diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index 7ab1e15..7f600ab 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -381,34 +381,3 @@ void QuartzSpaceChanged(uint32_t space_id) {
     /* Do something special here, so we don't depend on quartz-wm for spaces to work... */
     DEBUG_LOG("Space Changed (%u) ... do something interesting...\n", space_id);
 }
-
-/*
- * QuartzMessageServerThread
- *  Send the X server thread a message by placing it on the event queue.
- */
-void
-QuartzMessageServerThread(
-    int type,
-    int argc, ...)
-{
-    xEvent xe;
-    INT32 *argv;
-    int i, max_args;
-    va_list args;
-
-    memset(&xe, 0, sizeof(xe));
-    xe.u.u.type = type;
-    xe.u.clientMessage.u.l.type = type;
-
-    argv = &xe.u.clientMessage.u.l.longs0;
-    max_args = 4;
-
-    if (argc > 0 && argc <= max_args) {
-        va_start (args, argc);
-        for (i = 0; i < argc; i++)
-            argv[i] = (int) va_arg (args, int);
-        va_end (args);
-    }
-
-    mieqEnqueue(NULL, &xe);
-}
diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c
index 4aa654a..2956956 100644
--- a/hw/xquartz/xpr/xprScreen.c
+++ b/hw/xquartz/xpr/xprScreen.c
@@ -68,7 +68,7 @@ static void eventHandler(unsigned int type, const void *arg,
     switch (type) {
         case XP_EVENT_DISPLAY_CHANGED:
             DEBUG_LOG("XP_EVENT_DISPLAY_CHANGED\n");
-            QuartzMessageServerThread(kXquartzDisplayChanged, 0);
+            DarwinSendDDXEvent(kXquartzDisplayChanged, 0);
             break;
             
         case XP_EVENT_WINDOW_STATE_CHANGED:
@@ -76,7 +76,7 @@ static void eventHandler(unsigned int type, const void *arg,
                 const xp_window_state_event *ws_arg = arg;
                 
                 DEBUG_LOG("XP_EVENT_WINDOW_STATE_CHANGED: id=%d, state=%d\n", ws_arg->id, ws_arg->state);
-                QuartzMessageServerThread(kXquartzWindowState, 2,
+                DarwinSendDDXEvent(kXquartzWindowState, 2,
                                           ws_arg->id, ws_arg->state);
             } else {
                 DEBUG_LOG("XP_EVENT_WINDOW_STATE_CHANGED: ignored\n");
@@ -88,7 +88,7 @@ static void eventHandler(unsigned int type, const void *arg,
             if (arg_size == sizeof(xp_window_id))  {
                 xp_window_id id = * (xp_window_id *) arg;
                 WindowPtr pWin = xprGetXWindow(id);
-                QuartzMessageServerThread(kXquartzWindowMoved, 1, pWin);
+                DarwinSendDDXEvent(kXquartzWindowMoved, 1, pWin);
             }
             break;
             
@@ -112,7 +112,7 @@ static void eventHandler(unsigned int type, const void *arg,
             ErrorF("XP_EVENT_SPACE_CHANGED\n");
             if(arg_size == sizeof(uint32_t)) {
                 uint32_t space_id = *(uint32_t *)arg;
-                QuartzMessageServerThread(kXquartzSpaceChanged, 1, space_id);
+                DarwinSendDDXEvent(kXquartzSpaceChanged, 1, space_id);
             }
             break;
 #endif
commit 2143182ba49195bbb2e9163ea6872fd68e7a4a85
Author: Ben Byer <bbyer at apple.com>
Date:   Mon Mar 31 21:04:37 2008 -0700

    shovelling code around ...

diff --git a/dix/main.c b/dix/main.c
index 8b57e12..590f1a5 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -110,6 +110,9 @@ Equipment Corporation.
 #include "dispatch.h"		/* InitProcVectors() */
 #endif
 
+#include <pthread.h>
+pthread_key_t threadname_key=0;
+
 #ifdef DPMSExtension
 #define DPMS_SERVER
 #include <X11/extensions/dpms.h>
@@ -252,6 +255,17 @@ main(int argc, char *argv[], char *envp[])
     char	*xauthfile;
     HWEventQueueType	alwaysCheckForInput[2];
 
+    if(threadname_key == 0) ErrorF("pthread_key_create returned %d\n", pthread_key_create(&threadname_key, NULL));
+    ErrorF("threadname_key = %d\n", threadname_key);
+    if(pthread_getspecific(threadname_key) == NULL) {
+      char *nameptr = malloc(32);
+      sprintf(nameptr, "main thread %d", random());
+      //      strcpy(nameptr, "main thread");
+      ErrorF("calling: pthread_setspecific(%d, %s)=%d\n", threadname_key, nameptr, pthread_setspecific(threadname_key, nameptr));
+      if (pthread_getspecific(threadname_key) != NULL) ErrorF("current thread: %s\n", (char *)pthread_getspecific(threadname_key));
+    } else {
+      if (pthread_getspecific(threadname_key) != NULL) ErrorF("thread was already: %s\n", (char *)pthread_getspecific(threadname_key));
+    }
     display = "0";
 
     InitGlobals();
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 230050f..28a712d 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -52,6 +52,11 @@ in this Software without prior written authorization from The Open Group.
 #include <unistd.h>
 #include <IOKit/hidsystem/IOLLEvent.h>
 
+#define _APPLEWM_SERVER_
+#include "applewmExt.h"
+#include <X11/extensions/applewm.h>
+
+
 /* Fake button press/release for scroll wheel move. */
 #define SCROLLWHEELUPFAKE   4
 #define SCROLLWHEELDOWNFAKE 5
@@ -177,14 +182,103 @@ static void DarwinSimulateMouseClick(
     DarwinUpdateModifiers(KeyPress, modifierMask);
 }
 
+/* Generic handler for Xquartz-specifc events.  When possible, these should
+   be moved into their own individual functions and set as handlers using
+   mieqSetHandler. */
+
 void DarwinEventHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents) {
   int i;
 
   DEBUG_LOG("DarwinEventHandler(%d, %p, %p, %d)\n", screenNum, xe, dev, nevents);
   for (i=0; i<nevents; i++) {
-    if (xe[i].u.u.type == kXquartzDeactivate)
-      DarwinReleaseModifiers();
-    QuartzProcessEvent(&xe[i]);
+	switch(xe[i].u.u.type) {
+		case kXquartzControllerNotify:
+            DEBUG_LOG("kXquartzControllerNotify\n");
+            AppleWMSendEvent(AppleWMControllerNotify,
+                             AppleWMControllerNotifyMask,
+                             xe[i].u.clientMessage.u.l.longs0,
+                             xe[i].u.clientMessage.u.l.longs1);
+            break;
+
+        case kXquartzPasteboardNotify:
+            DEBUG_LOG("kXquartzPasteboardNotify\n");
+            AppleWMSendEvent(AppleWMPasteboardNotify,
+                             AppleWMPasteboardNotifyMask,
+                             xe[i].u.clientMessage.u.l.longs0,
+                             xe[i].u.clientMessage.u.l.longs1);
+            break;
+
+        case kXquartzActivate:
+            DEBUG_LOG("kXquartzActivate\n");
+            QuartzShow(xe[i].u.keyButtonPointer.rootX,
+                       xe[i].u.keyButtonPointer.rootY);
+            AppleWMSendEvent(AppleWMActivationNotify,
+                             AppleWMActivationNotifyMask,
+                             AppleWMIsActive, 0);
+            break;
+
+        case kXquartzDeactivate:
+            DEBUG_LOG("kXquartzDeactivate\n");
+      		DarwinReleaseModifiers();
+            AppleWMSendEvent(AppleWMActivationNotify,
+                             AppleWMActivationNotifyMask,
+                             AppleWMIsInactive, 0);
+            QuartzHide();
+            break;
+
+        case kXquartzWindowState:
+            DEBUG_LOG("kXquartzWindowState\n");
+            RootlessNativeWindowStateChanged(xe[i].u.clientMessage.u.l.longs0,
+                                             xe[i].u.clientMessage.u.l.longs1);
+            break;
+
+        case kXquartzWindowMoved:
+            DEBUG_LOG("kXquartzWindowMoved\n");
+            RootlessNativeWindowMoved ((WindowPtr)xe[i].u.clientMessage.u.l.longs0);
+            break;
+
+        case kXquartzToggleFullscreen:
+            DEBUG_LOG("kXquartzToggleFullscreen\n");
+#ifdef DARWIN_DDX_MISSING
+            if (quartzEnableRootless) QuartzSetFullscreen(!quartzHasRoot);
+            else if (quartzHasRoot) QuartzHide();
+            else QuartzShow();
+#else
+    //      ErrorF("kXquartzToggleFullscreen not implemented\n");               
+#endif
+            break;
+
+        case kXquartzSetRootless:
+            DEBUG_LOG("kXquartzSetRootless\n");
+#ifdef DARWIN_DDX_MISSING
+            QuartzSetRootless(xe[i].u.clientMessage.u.l.longs0);
+            if (!quartzEnableRootless && !quartzHasRoot) QuartzHide();
+#else
+    //      ErrorF("kXquartzSetRootless not implemented\n");                    
+#endif
+            break;
+
+        case kXquartzSetRootClip:
+            QuartzSetRootClip((BOOL)xe[i].u.clientMessage.u.l.longs0);
+		     break;
+
+        case kXquartzQuit:
+            GiveUp(0);
+            break;
+
+        case kXquartzBringAllToFront:
+     	    DEBUG_LOG("kXquartzBringAllToFront\n");
+            RootlessOrderAllWindows();
+            break;
+
+		case kXquartzSpaceChanged:
+            DEBUG_LOG("kXquartzSpaceChanged\n");
+            QuartzSpaceChanged(xe[i].u.clientMessage.u.l.longs0);
+
+            break;
+        default:
+            ErrorF("Unknown application defined event type %d.\n", xe[i].u.u.type);
+		}	
   }
 }
 
@@ -199,14 +293,14 @@ Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr) {
     mieqSetHandler(kXquartzDeactivate, DarwinEventHandler);
     mieqSetHandler(kXquartzSetRootClip, DarwinEventHandler);
     mieqSetHandler(kXquartzQuit, DarwinEventHandler);
-    mieqSetHandler(kXquartzReadPasteboard, DarwinEventHandler);
-    mieqSetHandler(kXquartzWritePasteboard, DarwinEventHandler);
+    mieqSetHandler(kXquartzReadPasteboard, QuartzReadPasteboard);
+	mieqSetHandler(kXquartzWritePasteboard, QuartzWritePasteboard);
     mieqSetHandler(kXquartzToggleFullscreen, DarwinEventHandler);
     mieqSetHandler(kXquartzSetRootless, DarwinEventHandler);
     mieqSetHandler(kXquartzSpaceChanged, DarwinEventHandler);
     mieqSetHandler(kXquartzControllerNotify, DarwinEventHandler);
     mieqSetHandler(kXquartzPasteboardNotify, DarwinEventHandler);
-    mieqSetHandler(kXquartzDisplayChanged, DarwinEventHandler);
+    mieqSetHandler(kXquartzDisplayChanged, QuartzDisplayChangedHandler);
     mieqSetHandler(kXquartzWindowState, DarwinEventHandler);
     mieqSetHandler(kXquartzWindowMoved, DarwinEventHandler);
 
diff --git a/hw/xquartz/darwinKeyboard.c b/hw/xquartz/darwinKeyboard.c
index b368fe9..472d80d 100644
--- a/hw/xquartz/darwinKeyboard.c
+++ b/hw/xquartz/darwinKeyboard.c
@@ -730,6 +730,14 @@ static void DarwinBuildModifierMaps(darwinKeyboardInfo *info) {
  *  it to an equivalent X keyboard map and modifier map.
  */
 static void DarwinLoadKeyboardMapping(KeySymsRec *keySyms) {
+  void* callstack[128];
+  int i, frames = backtrace(callstack, 128);
+  char** strs = backtrace_symbols(callstack, frames);
+  for (i = 0; i < frames; ++i) {
+    ErrorF("%s\n", strs[i]);
+  }
+  free(strs);
+
     memset(keyInfo.keyMap, 0, sizeof(keyInfo.keyMap));
 
     /* TODO: Clean this up
diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index f0093bd..7ab1e15 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -240,17 +240,17 @@ RREditConnectionInfo (ScreenPtr pScreen)
 #endif
 
 /*
- * QuartzUpdateScreens
+ * QuartzDisplayChangeHandler
  *  Adjust for screen arrangement changes.
  */
-static void QuartzUpdateScreens(void)
+void QuartzDisplayChangedHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents)
 {
     ScreenPtr pScreen;
     WindowPtr pRoot;
     int x, y, width, height, sx, sy;
     xEvent e;
 
-    DEBUG_LOG("QuartzUpdateScreens()\n");
+    DEBUG_LOG("QuartzDisplayChangedHandler()\n");
     if (noPseudoramiXExtension || screenInfo.numScreens != 1)
     {
         /* FIXME: if not using Xinerama, we have multiple screens, and
@@ -316,7 +316,7 @@ static void QuartzUpdateScreens(void)
  *  Calls mode specific screen resume to restore the X clip regions
  *  (if needed) and the X server cursor state.
  */
-static void QuartzShow(
+void QuartzShow(
     int x,      // cursor location
     int y )
 {
@@ -339,7 +339,7 @@ static void QuartzShow(
  *  hidden. Calls mode specific screen suspend to set X clip regions to
  *  prevent drawing (if needed) and restore the Aqua cursor.
  */
-static void QuartzHide(void)
+void QuartzHide(void)
 {
     int i;
 
@@ -358,7 +358,7 @@ static void QuartzHide(void)
  * QuartzSetRootClip
  *  Enable or disable rendering to the X screen.
  */
-static void QuartzSetRootClip(
+void QuartzSetRootClip(
     BOOL enable)
 {
     int i;
@@ -377,7 +377,7 @@ static void QuartzSetRootClip(
  * QuartzSpaceChanged
  *  Unmap offscreen windows, map onscreen windows
  */
-static void QuartzSpaceChanged(uint32_t space_id) {
+void QuartzSpaceChanged(uint32_t space_id) {
     /* Do something special here, so we don't depend on quartz-wm for spaces to work... */
     DEBUG_LOG("Space Changed (%u) ... do something interesting...\n", space_id);
 }
@@ -412,112 +412,3 @@ QuartzMessageServerThread(
 
     mieqEnqueue(NULL, &xe);
 }
-
-
-/*
- * QuartzProcessEvent
- *  Process Quartz specific events.
- */
-void QuartzProcessEvent(xEvent *xe) {
-    switch (xe->u.u.type) {
-        case kXquartzControllerNotify:
-            DEBUG_LOG("kXquartzControllerNotify\n");
-            AppleWMSendEvent(AppleWMControllerNotify,
-                             AppleWMControllerNotifyMask,
-                             xe->u.clientMessage.u.l.longs0,
-                             xe->u.clientMessage.u.l.longs1);
-            break;
-
-        case kXquartzPasteboardNotify:
-            DEBUG_LOG("kXquartzPasteboardNotify\n");
-            AppleWMSendEvent(AppleWMPasteboardNotify,
-                             AppleWMPasteboardNotifyMask,
-                             xe->u.clientMessage.u.l.longs0,
-                             xe->u.clientMessage.u.l.longs1);
-            break;
-
-        case kXquartzActivate:
-            DEBUG_LOG("kXquartzActivate\n");
-            QuartzShow(xe->u.keyButtonPointer.rootX,
-                       xe->u.keyButtonPointer.rootY);
-            AppleWMSendEvent(AppleWMActivationNotify,
-                             AppleWMActivationNotifyMask,
-                             AppleWMIsActive, 0);
-            break;
-
-        case kXquartzDeactivate:
-            DEBUG_LOG("kXquartzDeactivate\n");
-            AppleWMSendEvent(AppleWMActivationNotify,
-                             AppleWMActivationNotifyMask,
-                             AppleWMIsInactive, 0);
-            QuartzHide();
-            break;
-
-        case kXquartzDisplayChanged:
-            DEBUG_LOG("kXquartzDisplayChanged\n");
-            QuartzUpdateScreens();
-            break;
-
-        case kXquartzWindowState:
-            DEBUG_LOG("kXquartzWindowState\n");
-            RootlessNativeWindowStateChanged(xe->u.clientMessage.u.l.longs0,
-		  			     xe->u.clientMessage.u.l.longs1);
-	    break;
-	  
-        case kXquartzWindowMoved:
-            DEBUG_LOG("kXquartzWindowMoved\n");
-            RootlessNativeWindowMoved ((WindowPtr)xe->u.clientMessage.u.l.longs0);
-	    break;
-
-        case kXquartzToggleFullscreen:
-            DEBUG_LOG("kXquartzToggleFullscreen\n");
-#ifdef DARWIN_DDX_MISSING
-            if (quartzEnableRootless) QuartzSetFullscreen(!quartzHasRoot);
-            else if (quartzHasRoot) QuartzHide();
-            else QuartzShow();
-#else
-    //	    ErrorF("kXquartzToggleFullscreen not implemented\n");
-#endif
-            break;
-
-        case kXquartzSetRootless:
-            DEBUG_LOG("kXquartzSetRootless\n");
-#ifdef DARWIN_DDX_MISSING
-            QuartzSetRootless(xe->u.clientMessage.u.l.longs0);
-            if (!quartzEnableRootless && !quartzHasRoot) QuartzHide();
-#else
-    //	    ErrorF("kXquartzSetRootless not implemented\n");
-#endif
-            break;
-
-        case kXquartzSetRootClip:
-            QuartzSetRootClip((BOOL)xe->u.clientMessage.u.l.longs0);
-            break;
-
-        case kXquartzQuit:
-            GiveUp(0);
-            break;
-
-#if 0
-        case kXquartzReadPasteboard:
-            QuartzReadPasteboard();
-            break;
-
-        case kXquartzWritePasteboard:
-            QuartzWritePasteboard();
-            break;
-#endif
-
-        case kXquartzBringAllToFront:
-            DEBUG_LOG("kXquartzBringAllToFront\n");
-            RootlessOrderAllWindows();
-            break;
-
-        case kXquartzSpaceChanged:
-            DEBUG_LOG("kXquartzSpaceChanged\n");
-            QuartzSpaceChanged(xe->u.clientMessage.u.l.longs0);
-            break;
-        default:
-            ErrorF("Unknown application defined event type %d.\n", xe->u.u.type);
-    }
-}
diff --git a/hw/xquartz/quartz.h b/hw/xquartz/quartz.h
index fbe308a..ffe06f9 100644
--- a/hw/xquartz/quartz.h
+++ b/hw/xquartz/quartz.h
@@ -130,5 +130,5 @@ void QuartzInitOutput(int argc,char **argv);
 void QuartzInitInput(int argc, char **argv);
 void QuartzGiveUp(void);
 void QuartzProcessEvent(xEvent *xe);
-
+void QuartzDisplayChangedHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents);
 #endif
commit 6e833e41e2f3a84f7e5164b918737b3975517c12
Author: Ben Byer <bbyer at apple.com>
Date:   Mon Mar 31 20:21:24 2008 -0700

    fix compilation on systems that don't have
    XP_EVENT_SPACE_CHANGED defined

diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c
index 5e14473..4aa654a 100644
--- a/hw/xquartz/xpr/xprScreen.c
+++ b/hw/xquartz/xpr/xprScreen.c
@@ -107,6 +107,7 @@ static void eventHandler(unsigned int type, const void *arg,
                 DRISurfaceNotify(*(xp_surface_id *) arg, kind);
             }
             break;
+#ifdef XP_EVENT_SPACE_CHANGED
         case  XP_EVENT_SPACE_CHANGED:
             ErrorF("XP_EVENT_SPACE_CHANGED\n");
             if(arg_size == sizeof(uint32_t)) {
@@ -114,6 +115,7 @@ static void eventHandler(unsigned int type, const void *arg,
                 QuartzMessageServerThread(kXquartzSpaceChanged, 1, space_id);
             }
             break;
+#endif
         default:
             ErrorF("Unknown XP_EVENT type (%d) in xprScreen:eventHandler\n", type);
     }
@@ -241,9 +243,11 @@ xprDisplayInit(void)
     xp_select_events(XP_EVENT_DISPLAY_CHANGED
                      | XP_EVENT_WINDOW_STATE_CHANGED
                      | XP_EVENT_WINDOW_MOVED
+#ifdef XP_EVENT_SPACE_CHANGED
+                     | XP_EVENT_SPACE_CHANGED
+#endif
                      | XP_EVENT_SURFACE_CHANGED
-                     | XP_EVENT_SURFACE_DESTROYED
-                     | XP_EVENT_SPACE_CHANGED,
+                     | XP_EVENT_SURFACE_DESTROYED,
                      eventHandler, NULL);
 
     AppleDRIExtensionInit();
commit 4aedba5aa727e22316e8ca456f7218bea9ee0313
Author: Ben Byer <bbyer at apple.com>
Date:   Mon Mar 31 20:18:58 2008 -0700

    just a bit of juggling headers around -- we're preparing
    to call our Xquartz-specific event handlers directly
    as mieqHandlers

diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index ec1d5e0..e397795 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -887,7 +887,7 @@ void AbortDDX( void )
  */
 
 void
-xf86SetRootClip (ScreenPtr pScreen, BOOL enable)
+xf86SetRootClip (ScreenPtr pScreen, int enable)
 {
     WindowPtr	pWin = WindowTable[pScreen->myNum];
     WindowPtr	pChild;
diff --git a/hw/xquartz/darwin.h b/hw/xquartz/darwin.h
index 5b3bc75..a71941d 100644
--- a/hw/xquartz/darwin.h
+++ b/hw/xquartz/darwin.h
@@ -54,7 +54,7 @@ typedef struct {
 void DarwinPrintBanner(void);
 int DarwinParseModifierList(const char *constmodifiers);
 void DarwinAdjustScreenOrigins(ScreenInfo *pScreenInfo);
-void xf86SetRootClip (ScreenPtr pScreen, BOOL enable);
+void xf86SetRootClip (ScreenPtr pScreen, int enable);
 
 #define SCREEN_PRIV(pScreen) \
     ((DarwinFramebufferPtr)pScreen->devPrivates[darwinScreenIndex].ptr)
diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index afb3776..f0093bd 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -33,6 +33,7 @@
 #endif
 
 #include "quartzCommon.h"
+#include "inputstr.h"
 #include "quartz.h"
 #include "darwin.h"
 #include "darwinEvents.h"
@@ -497,6 +498,7 @@ void QuartzProcessEvent(xEvent *xe) {
             GiveUp(0);
             break;
 
+#if 0
         case kXquartzReadPasteboard:
             QuartzReadPasteboard();
             break;
@@ -504,6 +506,7 @@ void QuartzProcessEvent(xEvent *xe) {
         case kXquartzWritePasteboard:
             QuartzWritePasteboard();
             break;
+#endif
 
         case kXquartzBringAllToFront:
             DEBUG_LOG("kXquartzBringAllToFront\n");
diff --git a/hw/xquartz/quartzCocoa.m b/hw/xquartz/quartzCocoa.m
index 53e3f08..d8f9c69 100644
--- a/hw/xquartz/quartzCocoa.m
+++ b/hw/xquartz/quartzCocoa.m
@@ -37,13 +37,14 @@
 #endif
 
 #include "quartzCommon.h"
+#include "inputstr.h"
 #include "quartzPasteboard.h"
 
 #define BOOL xBOOL
 #include "darwin.h"
-#undef BOOL
 
 #include <Cocoa/Cocoa.h>
+#undef BOOL
 
 #include "pseudoramiX.h"
 
diff --git a/hw/xquartz/quartzPasteboard.c b/hw/xquartz/quartzPasteboard.c
index 0cecff5..3833572 100644
--- a/hw/xquartz/quartzPasteboard.c
+++ b/hw/xquartz/quartzPasteboard.c
@@ -34,6 +34,8 @@
 #include <dix-config.h>
 #endif
 
+#include "misc.h"
+#include "inputstr.h"
 #include "quartzPasteboard.h"
 
 #include <X11/Xatom.h>
@@ -81,8 +83,8 @@ static char * QuartzReadCutBuffer(void)
 }
 
 // Write X cut buffer to Mac OS X pasteboard
-// Called by ProcessInputEvents() in response to request from X server thread.
-void QuartzWritePasteboard(void)
+// Called by mieqProcessInputEvents() in response to request from X server thread.
+void QuartzWritePasteboard(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents)
 {
     char *text;
     text = QuartzReadCutBuffer();
@@ -95,8 +97,8 @@ void QuartzWritePasteboard(void)
 #define strequal(a, b) (0 == strcmp((a), (b)))
 
 // Read Mac OS X pasteboard into X cut buffer
-// Called by ProcessInputEvents() in response to request from X server thread.
-void QuartzReadPasteboard(void)
+// Called by mieqProcessInputEvents() in response to request from X server thread.
+void QuartzReadPasteboard(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents)
 {
     char *oldText = QuartzReadCutBuffer();
     char *text = QuartzReadCocoaPasteboard();
diff --git a/hw/xquartz/quartzPasteboard.h b/hw/xquartz/quartzPasteboard.h
index d6a8ee8..b51cd88 100644
--- a/hw/xquartz/quartzPasteboard.h
+++ b/hw/xquartz/quartzPasteboard.h
@@ -34,11 +34,11 @@
 #define _QUARTZPASTEBOARD_H
 
 // Aqua->X 
-void QuartzReadPasteboard(void);
+void QuartzReadPasteboard(int, xEventPtr, DeviceIntPtr, int);
 char * QuartzReadCocoaPasteboard(void);	// caller must free string
 
 // X->Aqua
-void QuartzWritePasteboard(void);
+void QuartzWritePasteboard(int, xEventPtr, DeviceIntPtr, int);
 void QuartzWriteCocoaPasteboard(char *text);
 
 #endif	/* _QUARTZPASTEBOARD_H */
diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c
index b653a6e..5e14473 100644
--- a/hw/xquartz/xpr/xprScreen.c
+++ b/hw/xquartz/xpr/xprScreen.c
@@ -32,6 +32,7 @@
 #endif
 
 #include "quartzCommon.h"
+#include "inputstr.h"
 #include "quartz.h"
 #include "xpr.h"
 #include "pseudoramiX.h"
commit 1e0ec02202eeaffae480048b91bf02140ee29f8a
Author: Ben Byer <bbyer at apple.com>
Date:   Mon Mar 31 19:47:28 2008 -0700

    nuke DarwinEventQueue

diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 5b037d2..230050f 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -56,28 +56,10 @@ in this Software without prior written authorization from The Open Group.
 #define SCROLLWHEELUPFAKE   4
 #define SCROLLWHEELDOWNFAKE 5
 
-#define QUEUE_SIZE 256
-
-typedef struct _Event {
-    xEvent      event;
-    ScreenPtr   pScreen;
-} EventRec, *EventPtr;
-
 int input_check_zero, input_check_flag;
 
 static int old_flags = 0;  // last known modifier state
 
-typedef struct _EventQueue {
-    HWEventQueueType    head, tail; /* long for SetInputCheck */
-    CARD32      lastEventTime;      /* to avoid time running backwards */
-    Bool        lastMotion;
-    EventRec    events[QUEUE_SIZE]; /* static allocation for signals */
-    DevicePtr   pKbd, pPtr;         /* device pointer, to get funcs */
-    ScreenPtr   pEnqueueScreen;     /* screen events are being delivered to */
-    ScreenPtr   pDequeueScreen;     /* screen events are being dispatched to */
-} EventQueueRec, *EventQueuePtr;
-
-static EventQueueRec darwinEventQueue;
 xEvent *darwinEvents = NULL;
 
 /*
@@ -231,21 +213,6 @@ Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr) {
     return TRUE;
 }
 
-
-/*
- * DarwinEQEnqueue
- *  Must be thread safe with ProcessInputEvents.
- *    DarwinEQEnqueue    - called from event gathering thread
- *    ProcessInputEvents - called from X server thread
- *  DarwinEQEnqueue should never be called from more than one thread.
- * 
- * This should be deprecated in favor of miEQEnqueue -- BB
- */
-void DarwinEQEnqueue(const xEventPtr e) {
-  mieqEnqueue(NULL, e);
-  DarwinPokeEQ();
-}
-
 /*
  * ProcessInputEvents
  *  Read and process events from the event queue until it is empty.
diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index 1f1b9a4..afb3776 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -409,7 +409,7 @@ QuartzMessageServerThread(
         va_end (args);
     }
 
-    DarwinEQEnqueue(&xe);
+    mieqEnqueue(NULL, &xe);
 }
 
 
commit c34fce7051b996633291dddc061b696ff737f3fb
Author: Ben Byer <bbyer at apple.com>
Date:   Mon Mar 31 19:39:51 2008 -0700

    continue with gutting darwinEvents.c

diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index b146321..5b037d2 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -78,7 +78,7 @@ typedef struct _EventQueue {
 } EventQueueRec, *EventQueuePtr;
 
 static EventQueueRec darwinEventQueue;
-xEvent *darwinEvents;
+xEvent *darwinEvents = NULL;
 
 /*
  * DarwinPressModifierMask
@@ -207,8 +207,11 @@ void DarwinEventHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int neven
 }
 
 Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr) { 
+    if (!darwinEvents)
+        darwinEvents = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+    if (!darwinEvents)
+        FatalError("Couldn't allocate event buffer\n");
 
-    darwinEvents = (xEvent *)malloc(sizeof(xEvent) * GetMaximumEventsNum());
     mieqInit();
     mieqSetHandler(kXquartzActivate, DarwinEventHandler);
     mieqSetHandler(kXquartzDeactivate, DarwinEventHandler);
@@ -225,13 +228,6 @@ Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr) {
     mieqSetHandler(kXquartzWindowState, DarwinEventHandler);
     mieqSetHandler(kXquartzWindowMoved, DarwinEventHandler);
 
-    darwinEventQueue.head = darwinEventQueue.tail = 0;
-    darwinEventQueue.lastEventTime = GetTimeInMillis ();
-    darwinEventQueue.pKbd = pKbd;
-    darwinEventQueue.pPtr = pPtr;
-    darwinEventQueue.pEnqueueScreen = screenInfo.screens[0];
-    darwinEventQueue.pDequeueScreen = darwinEventQueue.pEnqueueScreen;
-    SetInputCheck(&input_check_zero, &input_check_flag);
     return TRUE;
 }
 
@@ -255,8 +251,6 @@ void DarwinEQEnqueue(const xEventPtr e) {
  *  Read and process events from the event queue until it is empty.
  */
 void ProcessInputEvents(void) {
-    EventRec *e;
-    int     x, y;
     xEvent  xe;
     // button number and modifier mask of currently pressed fake button
     input_check_flag=0;
@@ -265,92 +259,11 @@ void ProcessInputEvents(void) {
     mieqProcessInputEvents();
 
     // Empty the signaling pipe
-    x = sizeof(xe);
-    while (x == sizeof(xe)) 
-        x = read(darwinEventReadFD, &xe, sizeof(xe));
-
-    while (darwinEventQueue.head != darwinEventQueue.tail)
-    {
-        if (screenIsSaved == SCREEN_SAVER_ON)
-            SaveScreens (SCREEN_SAVER_OFF, ScreenSaverReset);
-
-        e = &darwinEventQueue.events[darwinEventQueue.head];
-        xe = e->event;
-
-        // Shift from global screen coordinates to coordinates relative to
-        // the origin of the current screen.
-        xe.u.keyButtonPointer.rootX -= darwinMainScreenX +
-                dixScreenOrigins[miPointerCurrentScreen()->myNum].x;
-        xe.u.keyButtonPointer.rootY -= darwinMainScreenY +
-                dixScreenOrigins[miPointerCurrentScreen()->myNum].y;
-	
-	/*	ErrorF("old rootX = (%d,%d) darwinMainScreen = (%d,%d) dixScreenOrigins[%d]=(%d,%d)\n",
-	       xe.u.keyButtonPointer.rootX, xe.u.keyButtonPointer.rootY,
-	       darwinMainScreenX, darwinMainScreenY,
-	       miPointerCurrentScreen()->myNum,
-	       dixScreenOrigins[miPointerCurrentScreen()->myNum].x,
-	       dixScreenOrigins[miPointerCurrentScreen()->myNum].y); */
-
-	//Assumption - screen switching can only occur on motion events
-
-        if (e->pScreen != darwinEventQueue.pDequeueScreen)
-        {
-            darwinEventQueue.pDequeueScreen = e->pScreen;
-            x = xe.u.keyButtonPointer.rootX;
-            y = xe.u.keyButtonPointer.rootY;
-            if (darwinEventQueue.head == QUEUE_SIZE - 1)
-                darwinEventQueue.head = 0;
-            else
-                ++darwinEventQueue.head;
-            NewCurrentScreen (darwinEventQueue.pDequeueScreen, x, y);
-        }
-        else
-        {
-            if (darwinEventQueue.head == QUEUE_SIZE - 1)
-                darwinEventQueue.head = 0;
-            else
-                ++darwinEventQueue.head;
-            switch (xe.u.u.type) {
-            case KeyPress:
-            case KeyRelease:
-	      ErrorF("Unexpected Keyboard event in DarwinProcessInputEvents\n");
-	      break;
-
-            case ButtonPress:
-	      ErrorF("Unexpected ButtonPress event in DarwinProcessInputEvents\n");
-                break;
-
-            case ButtonRelease:
-	      ErrorF("Unexpected ButtonRelease event in DarwinProcessInputEvents\n");
-                break;
-
-            case MotionNotify:
-	      ErrorF("Unexpected MotionNotify event in DarwinProcessInputEvents\n");
-                break;
-
-            case kXquartzUpdateModifiers:
-	      ErrorF("Unexpected kXquartzUpdateModifiers event in DarwinProcessInputEvents\n");
-	      break;
-
-            case kXquartzUpdateButtons:
-	      ErrorF("Unexpected kXquartzUpdateButtons event in DarwinProcessInputEvents\n");
-	      break;
-
-            case kXquartzScrollWheel: 
-	      ErrorF("Unexpected kXquartzScrollWheel event in DarwinProcessInputEvents\n");
-	      break;
-
-			case kXquartzDeactivate:
-				DarwinReleaseModifiers();
-				// fall through
-            default:
-                // Check for mode specific event
-                QuartzProcessEvent(&xe);
-            }
-        }
+    int x = sizeof(xe);
+    while (x == sizeof(xe)) {
+      DEBUG_LOG("draining pipe\n");
+      x = read(darwinEventReadFD, &xe, sizeof(xe));
     }
-
-    //    miPointerUpdate();
 }
 
 /* Sends a null byte down darwinEventWriteFD, which will cause the
@@ -368,6 +281,10 @@ void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int poin
   static int darwinFakeMouseButtonMask = 0;
   int i, num_events;
 
+	if(!darwinEvents) {
+		ErrorF("DarwinSendPointerEvents called before darwinEvents was initialized\n");
+		return;
+	}
   /* I can't find a spec for this, but at least GTK expects that tablets are
      just like mice, except they have either one or three extra valuators, in this
      order:
@@ -421,6 +338,11 @@ void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int poin
 
 void DarwinSendKeyboardEvents(int ev_type, int keycode) {
   int i, num_events;
+	if(!darwinEvents) {
+		ErrorF("DarwinSendKeyboardEvents called before darwinEvents was initialized\n");
+		return;
+	}
+
   if (old_flags == 0 && darwinSyncKeymap && darwinKeymapFile == NULL) {
     /* See if keymap has changed. */
 
@@ -447,6 +369,11 @@ void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y,
 		      tilt_x * INT32_MAX * 1.0f, 
 		      tilt_y * INT32_MAX * 1.0f};
 
+  if(!darwinEvents) {
+		ErrorF("DarwinSendProximityvents called before darwinEvents was initialized\n");
+		return;
+}
+
   num_events = GetProximityEvents(darwinEvents, darwinPointer, ev_type,
 				0, 5, valuators);
       
@@ -465,6 +392,11 @@ void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y,
 		      tilt_x * INT32_MAX * 1.0f, 
 		      tilt_y * INT32_MAX * 1.0f};
 
+	if(!darwinEvents) {
+		ErrorF("DarwinSendScrollEvents called before darwinEvents was initialized\n");
+		return;
+	}
+
   for (count = fabs(count); count > 0.0; count = count - 1.0f) {
     int num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonPress, ev_button, 
 				      POINTER_ABSOLUTE, 0, 5, valuators);
commit bfec44d7b4baf0ad0aae55c8209bc60ac93c5b58
Author: Ben Byer <bbyer at apple.com>
Date:   Mon Mar 31 18:26:00 2008 -0700

    turns out we weren't actually using these files. oops

diff --git a/hw/xquartz/Makefile.am b/hw/xquartz/Makefile.am
index 99d23eb..0753824 100644
--- a/hw/xquartz/Makefile.am
+++ b/hw/xquartz/Makefile.am
@@ -50,8 +50,6 @@ EXTRA_DIST = \
 	quartz.h \
 	quartzAudio.h \
 	quartzCommon.h \
-	quartzCursor.c \
-	quartzCursor.h \
 	quartzForeground.h \
 	quartzKeyboard.h \
 	quartzPasteboard.h
diff --git a/hw/xquartz/quartzCursor.c b/hw/xquartz/quartzCursor.c
deleted file mode 100644
index 26ffa77..0000000
--- a/hw/xquartz/quartzCursor.c
+++ /dev/null
@@ -1,654 +0,0 @@
-/**************************************************************
- *
- * Support for using the Quartz Window Manager cursor
- *
- * Copyright (c) 2001-2003 Torrey T. Lyons and Greg Parker.
- *                 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
- * 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "quartzCommon.h"
-#include "quartzCursor.h"
-#include "darwin.h"
-
-#include <pthread.h>
-
-#include "mi.h"
-#include "scrnintstr.h"
-#include "cursorstr.h"
-#include "mipointrst.h"
-#include "globals.h"
-
-// Size of the QuickDraw cursor
-#define CURSORWIDTH 16
-#define CURSORHEIGHT 16
-
-typedef struct {
-    int                     qdCursorMode;
-    int                     qdCursorVisible;
-    int                     useQDCursor;
-    QueryBestSizeProcPtr    QueryBestSize;
-    miPointerSpriteFuncPtr  spriteFuncs;
-} QuartzCursorScreenRec, *QuartzCursorScreenPtr;
-
-static int darwinCursorScreenIndex = -1;
-static unsigned long darwinCursorGeneration = 0;
-static CursorPtr quartzLatentCursor = NULL;
-static QD_Cursor gQDArrow; // QuickDraw arrow cursor
-
-// Cursor for the main thread to set (NULL = arrow cursor).
-static CCrsrHandle currentCursor = NULL;
-static pthread_mutex_t cursorMutex;
-static pthread_cond_t cursorCondition;
-
-#define CURSOR_PRIV(pScreen) \
-    ((QuartzCursorScreenPtr)pScreen->devPrivates[darwinCursorScreenIndex].ptr)
-
-#define HIDE_QD_CURSOR(pScreen, visible)                                \
-    if (visible) {                                                      \
-        int ix;                                                         \
-        for (ix = 0; ix < QUARTZ_PRIV(pScreen)->displayCount; ix++) {   \
-            CGDisplayHideCursor(QUARTZ_PRIV(pScreen)->displayIDs[ix]);  \
-        }                                                               \
-        visible = FALSE;                                                \
-    } ((void)0)
-
-#define SHOW_QD_CURSOR(pScreen, visible)                                \
-    {                                                                   \
-        int ix;                                                         \
-        for (ix = 0; ix < QUARTZ_PRIV(pScreen)->displayCount; ix++) {   \
-            CGDisplayShowCursor(QUARTZ_PRIV(pScreen)->displayIDs[ix]);  \
-        }                                                               \
-        visible = TRUE;                                                 \
-    } ((void)0)
-
-#define CHANGE_QD_CURSOR(cursorH)                                       \
-    if (!quartzServerQuitting) {                                        \
-        /* Acquire lock and tell the main thread to change cursor */    \
-        pthread_mutex_lock(&cursorMutex);                               \
-        currentCursor = (CCrsrHandle) (cursorH);                        \
-        QuartzMessageMainThread(kQuartzCursorUpdate, NULL, 0);          \
-                                                                        \
-        /* Wait for the main thread to change the cursor */             \
-        pthread_cond_wait(&cursorCondition, &cursorMutex);              \
-        pthread_mutex_unlock(&cursorMutex);                             \
-    } ((void)0)
-
-
-/*
- * MakeQDCursor helpers: CTAB_ENTER, interleave
- */
-
-// Add a color entry to a ctab
-#define CTAB_ENTER(ctab, index, r, g, b)                                \
-    ctab->ctTable[index].value = index;                                 \
-    ctab->ctTable[index].rgb.red = r;                                   \
-    ctab->ctTable[index].rgb.green = g;                                 \
-    ctab->ctTable[index].rgb.blue = b
-
-// Make an unsigned short by interleaving the bits of bytes c1 and c2.
-// High bit of c1 is first; low bit of c2 is last.
-// Interleave is a built-in INTERCAL operator.
-static unsigned short
-interleave(
-    unsigned char c1,
-    unsigned char c2 )
-{
-    return
-        ((c1 & 0x80) << 8) | ((c2 & 0x80) << 7) |
-        ((c1 & 0x40) << 7) | ((c2 & 0x40) << 6) |
-        ((c1 & 0x20) << 6) | ((c2 & 0x20) << 5) |
-        ((c1 & 0x10) << 5) | ((c2 & 0x10) << 4) |
-        ((c1 & 0x08) << 4) | ((c2 & 0x08) << 3) |
-        ((c1 & 0x04) << 3) | ((c2 & 0x04) << 2) |
-        ((c1 & 0x02) << 2) | ((c2 & 0x02) << 1) |
-        ((c1 & 0x01) << 1) | ((c2 & 0x01) << 0) ;
-}
-
-/*
- * MakeQDCursor
- * Make a QuickDraw color cursor from the given X11 cursor.
- * Warning: This code is nasty. Color cursors were meant to be read
- * from resources; constructing the structures programmatically is messy.
- */
-/*
-    QuickDraw cursor representation:
-    Our color cursor is a 2 bit per pixel pixmap.
-    Each pixel's bits are (source<<1 | mask) from the original X cursor pixel.
-    The cursor's color table maps the colors like this:
-    (2-bit value | X result    | colortable | Mac result)
-             00  | transparent | white      | transparent (white outside mask)
-             01  | back color  | back color | back color
-             10  | undefined   | black      | invert background (just for fun)
-             11  | fore color  | fore color | fore color
-*/
-static CCrsrHandle
-MakeQDCursor(
-    CursorPtr pCursor )
-{
-    CCrsrHandle result;
-    CCrsrPtr curs;
-    int i, w, h;
-    unsigned short rowMask;
-    PixMap *pix;
-    ColorTable *ctab;
-    unsigned short *image;
-
-    result = (CCrsrHandle) NewHandleClear(sizeof(CCrsr));
-    if (!result) return NULL;
-    HLock((Handle)result);
-    curs = *result;
-
-    // Initialize CCrsr
-    curs->crsrType = 0x8001;     // 0x8000 = b&w, 0x8001 = color
-    curs->crsrMap = (PixMapHandle) NewHandleClear(sizeof(PixMap));
-    if (!curs->crsrMap) goto pixAllocFailed;
-    HLock((Handle)curs->crsrMap);
-    pix = *curs->crsrMap;
-    curs->crsrData = NULL;       // raw cursor image data (set below)
-    curs->crsrXData = NULL;      // QD's processed data
-    curs->crsrXValid = 0;        // zero means QD must re-process cursor data
-    curs->crsrXHandle = NULL;    // reserved
-    memset(curs->crsr1Data, 0, CURSORWIDTH*CURSORHEIGHT/8); // b&w data
-    memset(curs->crsrMask,  0, CURSORWIDTH*CURSORHEIGHT/8); // b&w & color mask
-    curs->crsrHotSpot.h = min(CURSORWIDTH,  pCursor->bits->xhot); // hot spot
-    curs->crsrHotSpot.v = min(CURSORHEIGHT, pCursor->bits->yhot); // hot spot
-    curs->crsrXTable = 0;        // reserved
-    curs->crsrID = GetCTSeed();  // unique ID from Color Manager
-
-    // Set the b&w data and mask
-    w = min(pCursor->bits->width,  CURSORWIDTH);
-    h = min(pCursor->bits->height, CURSORHEIGHT);
-    rowMask = ~((1 << (CURSORWIDTH - w)) - 1);
-    for (i = 0; i < h; i++) {
-        curs->crsr1Data[i] = rowMask &
-        ((pCursor->bits->source[i*4]<<8) | pCursor->bits->source[i*4+1]);
-        curs->crsrMask[i] = rowMask &
-        ((pCursor->bits->mask[i*4]<<8)   | pCursor->bits->mask[i*4+1]);
-    }
-
-    // Set the color data and mask
-    // crsrMap: defines bit depth and size and colortable only
-    pix->rowBytes = (CURSORWIDTH * 2 / 8) | 0x8000; // last bit on means PixMap
-    SetRect(&pix->bounds, 0, 0, CURSORWIDTH, CURSORHEIGHT); // see TN 1020
-    pix->pixelSize = 2;
-    pix->cmpCount = 1;
-    pix->cmpSize = 2;
-    // pix->pmTable set below
-
-    // crsrData is the pixel data. crsrMap's baseAddr is not used.
-    curs->crsrData = NewHandleClear(CURSORWIDTH*CURSORHEIGHT * 2 / 8);
-    if (!curs->crsrData) goto imageAllocFailed;
-    HLock((Handle)curs->crsrData);
-    image = (unsigned short *) *curs->crsrData;
-    // Pixel data is just 1-bit data and mask interleaved (see above)
-    for (i = 0; i < h; i++) {
-        unsigned char s, m;
-        s = pCursor->bits->source[i*4] & (rowMask >> 8);
-        m = pCursor->bits->mask[i*4] & (rowMask >> 8);
-        image[2*i] = interleave(s, m);
-        s = pCursor->bits->source[i*4+1] & (rowMask & 0x00ff);
-        m = pCursor->bits->mask[i*4+1] & (rowMask & 0x00ff);
-        image[2*i+1] = interleave(s, m);
-    }
-
-    // Build the color table (entries described above)
-    // NewPixMap allocates a color table handle.
-    pix->pmTable = (CTabHandle) NewHandleClear(sizeof(ColorTable) + 3
-                    * sizeof(ColorSpec));
-    if (!pix->pmTable) goto ctabAllocFailed;
-    HLock((Handle)pix->pmTable);
-    ctab = *pix->pmTable;
-    ctab->ctSeed = GetCTSeed();
-    ctab->ctFlags = 0;
-    ctab->ctSize = 3; // color count - 1
-    CTAB_ENTER(ctab, 0, 0xffff, 0xffff, 0xffff);
-    CTAB_ENTER(ctab, 1, pCursor->backRed, pCursor->backGreen,
-               pCursor->backBlue);
-    CTAB_ENTER(ctab, 2, 0x0000, 0x0000, 0x0000);
-    CTAB_ENTER(ctab, 3, pCursor->foreRed, pCursor->foreGreen,
-               pCursor->foreBlue);
-
-    HUnlock((Handle)pix->pmTable); // ctab
-    HUnlock((Handle)curs->crsrData); // image data
-    HUnlock((Handle)curs->crsrMap); // pix
-    HUnlock((Handle)result); // cursor
-
-    return result;
-
-    // "What we have here is a failure to allocate"
-ctabAllocFailed:
-    HUnlock((Handle)curs->crsrData);
-    DisposeHandle((Handle)curs->crsrData);
-imageAllocFailed:
-    HUnlock((Handle)curs->crsrMap);
-    DisposeHandle((Handle)curs->crsrMap);
-pixAllocFailed:
-    HUnlock((Handle)result);
-    DisposeHandle((Handle)result);
-    return NULL;
-}
-
-
-/*
- * FreeQDCursor
- * Destroy a QuickDraw color cursor created with MakeQDCursor().
- * The cursor must not currently be on screen.
- */
-static void FreeQDCursor(CCrsrHandle cursHandle)
-{
-    CCrsrPtr curs;
-    PixMap *pix;
-
-    HLock((Handle)cursHandle);
-    curs = *cursHandle;
-    HLock((Handle)curs->crsrMap);
-    pix = *curs->crsrMap;
-    DisposeHandle((Handle)pix->pmTable);
-    HUnlock((Handle)curs->crsrMap);
-    DisposeHandle((Handle)curs->crsrMap);
-    DisposeHandle((Handle)curs->crsrData);
-    HUnlock((Handle)cursHandle);
-    DisposeHandle((Handle)cursHandle);
-}
-
-
-/*
-===========================================================================
-
- Pointer sprite functions
-
-===========================================================================
-*/
-
-/*
- * QuartzRealizeCursor
- * Convert the X cursor representation to QuickDraw format if possible.
- */
-Bool
-QuartzRealizeCursor(
-    ScreenPtr pScreen,
-    CursorPtr pCursor )
-{
-    CCrsrHandle qdCursor;
-    QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
-
-    if(!pCursor || !pCursor->bits)
-        return FALSE;
-
-    // if the cursor is too big we use a software cursor
-    if ((pCursor->bits->height > CURSORHEIGHT) ||
-        (pCursor->bits->width > CURSORWIDTH) || !ScreenPriv->useQDCursor)
-    {
-        if (quartzRootless) {
-            // rootless can't use a software cursor
-            return TRUE;
-        } else {
-            return (*ScreenPriv->spriteFuncs->RealizeCursor)
-                        (pScreen, pCursor);
-        }
-    }
-
-    // make new cursor image
-    qdCursor = MakeQDCursor(pCursor);
-    if (!qdCursor) return FALSE;
-
-    // save the result
-    pCursor->devPriv[pScreen->myNum] = (pointer) qdCursor;
-
-    return TRUE;
-}
-
-
-/*
- * QuartzUnrealizeCursor
- * Free the storage space associated with a realized cursor.
- */
-Bool
-QuartzUnrealizeCursor(
-    ScreenPtr pScreen,
-    CursorPtr pCursor )
-{
-    QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
-
-    if ((pCursor->bits->height > CURSORHEIGHT) ||
-        (pCursor->bits->width > CURSORWIDTH) || !ScreenPriv->useQDCursor)
-    {
-        if (quartzRootless) {
-            return TRUE;
-        } else {
-            return (*ScreenPriv->spriteFuncs->UnrealizeCursor)
-                        (pScreen, pCursor);
-        }
-    } else {
-        CCrsrHandle oldCursor = (CCrsrHandle) pCursor->devPriv[pScreen->myNum];
-
-        if (currentCursor != oldCursor) {
-            // This should only fail when quitting, in which case we just leak.
-            FreeQDCursor(oldCursor);
-        }
-        pCursor->devPriv[pScreen->myNum] = NULL;
-        return TRUE;
-    }
-}
-
-
-/*
- * QuartzSetCursor
- * Set the cursor sprite and position.
- * Use QuickDraw cursor if possible.
- */
-static void
-QuartzSetCursor(
-    ScreenPtr       pScreen,
-    CursorPtr       pCursor,
-    int             x,
-    int             y)
-{
-    QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
-
-    quartzLatentCursor = pCursor;
-
-    // Don't touch Mac OS cursor if X is hidden!
-    if (!quartzServerVisible)
-        return;
-
-    if (!pCursor) {
-        // Remove the cursor completely.
-        HIDE_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
-        if (! ScreenPriv->qdCursorMode)
-            (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, 0, x, y);
-    }
-    else if ((pCursor->bits->height <= CURSORHEIGHT) &&
-             (pCursor->bits->width <= CURSORWIDTH) && ScreenPriv->useQDCursor)
-    {
-        // Cursor is small enough to use QuickDraw directly.
-        if (! ScreenPriv->qdCursorMode)    // remove the X cursor
-            (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, 0, x, y);
-        ScreenPriv->qdCursorMode = TRUE;
-
-        CHANGE_QD_CURSOR(pCursor->devPriv[pScreen->myNum]);
-        SHOW_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
-    }
-    else if (quartzRootless) {
-        // Rootless can't use a software cursor, so we just use Mac OS arrow.
-        CHANGE_QD_CURSOR(NULL);
-        SHOW_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
-    }
-    else {
-        // Cursor is too big for QuickDraw. Use X software cursor.
-        HIDE_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
-        ScreenPriv->qdCursorMode = FALSE;
-        (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, pCursor, x, y);
-    }
-}
-
-
-/*
- * QuartzReallySetCursor
- * Set the QuickDraw cursor. Called from the main thread since changing the
- * cursor with QuickDraw is not thread safe on dual processor machines.
- */
-void
-QuartzReallySetCursor()
-{
-    pthread_mutex_lock(&cursorMutex);
-
-    if (currentCursor) {
-        SetCCursor(currentCursor);
-    } else {
-        SetCursor(&gQDArrow);
-    }
-
-    pthread_cond_signal(&cursorCondition);
-    pthread_mutex_unlock(&cursorMutex);
-}
-
-
-/*
- * QuartzMoveCursor
- * Move the cursor. This is a noop for QuickDraw.
- */
-static void
-QuartzMoveCursor(
-    ScreenPtr   pScreen,
-    int         x,
-    int         y)
-{
-    QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
-
-    // only the X cursor needs to be explicitly moved
-    if (!ScreenPriv->qdCursorMode)
-        (*ScreenPriv->spriteFuncs->MoveCursor)(pScreen, x, y);
-}
-
-
-static miPointerSpriteFuncRec quartzSpriteFuncsRec = {
-    QuartzRealizeCursor,
-    QuartzUnrealizeCursor,
-    QuartzSetCursor,
-    QuartzMoveCursor
-};
-
-
-/*
-===========================================================================
-
- Pointer screen functions
-
-===========================================================================
-*/
-
-/*
- * QuartzCursorOffScreen
- */
-static Bool QuartzCursorOffScreen(ScreenPtr *pScreen, int *x, int *y)
-{
-    return FALSE;
-}
-
-
-/*
- * QuartzCrossScreen
- */
-static void QuartzCrossScreen(ScreenPtr pScreen, Bool entering)
-{
-    return;
-}
-
-
-/*
- * QuartzWarpCursor
- *  Change the cursor position without generating an event or motion history.
- *  The input coordinates (x,y) are in pScreen-local X11 coordinates.
- *
- */
-static void
-QuartzWarpCursor(
-    ScreenPtr               pScreen,
-    int                     x,
-    int                     y)
-{
-    static int              neverMoved = TRUE;
-
-    if (neverMoved) {
-        // Don't move the cursor the first time. This is the jump-to-center
-        // initialization, and it's annoying because we may still be in MacOS.
-        neverMoved = FALSE;
-        return;
-    }
-
-    if (quartzServerVisible) {
-        CGDisplayErr        cgErr;
-        CGPoint             cgPoint;
-        // Only need to do this for one display. Any display will do.
-        CGDirectDisplayID   cgID = QUARTZ_PRIV(pScreen)->displayIDs[0];
-        CGRect              cgRect = CGDisplayBounds(cgID);
-
-        // Convert (x,y) to CoreGraphics screen-local CG coordinates.
-        // This is necessary because the X11 screen and CG screen may not
-        // coincide. (e.g. X11 screen may be moved to dodge the menu bar)
-
-        // Make point in X11 global coordinates
-        cgPoint = CGPointMake(x + dixScreenOrigins[pScreen->myNum].x,
-                              y + dixScreenOrigins[pScreen->myNum].y);
-        // Shift to CoreGraphics global screen coordinates
-        cgPoint.x += darwinMainScreenX;
-        cgPoint.y += darwinMainScreenY;
-        // Shift to CoreGraphics screen-local coordinates
-        cgPoint.x -= cgRect.origin.x;
-        cgPoint.y -= cgRect.origin.y;
-
-        cgErr = CGDisplayMoveCursorToPoint(cgID, cgPoint);
-        if (cgErr != CGDisplayNoErr) {
-            ErrorF("Could not set cursor position with error code 0x%x.\n",
-                    cgErr);
-        }
-    }
-
-    miPointerWarpCursor(pScreen, x, y);
-    miPointerUpdate();
-}
-
-
-static miPointerScreenFuncRec quartzScreenFuncsRec = {
-    QuartzCursorOffScreen,
-    QuartzCrossScreen,
-    QuartzWarpCursor,
-    NULL,
-    NULL 
-};
-
-
-/*
-===========================================================================
-
- Other screen functions
-
-===========================================================================
-*/
-
-/*
- * QuartzCursorQueryBestSize
- * Handle queries for best cursor size
- */
-static void
-QuartzCursorQueryBestSize(
-   int              class,
-   unsigned short   *width,
-   unsigned short   *height,
-   ScreenPtr        pScreen)
-{
-    QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
-
-    if (class == CursorShape) {
-        *width = CURSORWIDTH;
-        *height = CURSORHEIGHT;
-    } else {
-        (*ScreenPriv->QueryBestSize)(class, width, height, pScreen);
-    }
-}
-
-
-/*
- * QuartzInitCursor
- * Initialize cursor support
- */
-Bool
-QuartzInitCursor(
-    ScreenPtr   pScreen )
-{
-    QuartzCursorScreenPtr   ScreenPriv;
-    miPointerScreenPtr      PointPriv;
-    DarwinFramebufferPtr    dfb = SCREEN_PRIV(pScreen);
-
-    // initialize software cursor handling (always needed as backup)
-    if (!miDCInitialize(pScreen, &quartzScreenFuncsRec)) {
-        return FALSE;
-    }
-
-    // allocate private storage for this screen's QuickDraw cursor info
-    if (darwinCursorGeneration != serverGeneration) {
-        if ((darwinCursorScreenIndex = AllocateScreenPrivateIndex()) < 0)
-            return FALSE;
-        darwinCursorGeneration = serverGeneration;
-    }
-
-    ScreenPriv = xcalloc( 1, sizeof(QuartzCursorScreenRec) );
-    if (!ScreenPriv) return FALSE;
-
-    CURSOR_PRIV(pScreen) = ScreenPriv;
-
-    // override some screen procedures
-    ScreenPriv->QueryBestSize = pScreen->QueryBestSize;
-    pScreen->QueryBestSize = QuartzCursorQueryBestSize;
-
-    // initialize QuickDraw cursor handling
-    GetQDGlobalsArrow(&gQDArrow);
-    PointPriv = (miPointerScreenPtr)
-                    pScreen->devPrivates[miPointerScreenIndex].ptr;
-
-    ScreenPriv->spriteFuncs = PointPriv->spriteFuncs;
-    PointPriv->spriteFuncs = &quartzSpriteFuncsRec;
-
-    if (!quartzRootless)
-        ScreenPriv->useQDCursor = QuartzFSUseQDCursor(dfb->colorBitsPerPixel);
-    else
-        ScreenPriv->useQDCursor = TRUE;
-    ScreenPriv->qdCursorMode = TRUE;
-    ScreenPriv->qdCursorVisible = TRUE;
-
-    // initialize cursor mutex lock
-    pthread_mutex_init(&cursorMutex, NULL);
-
-    // initialize condition for waiting
-    pthread_cond_init(&cursorCondition, NULL);
-
-    return TRUE;
-}
-
-
-// X server is hiding. Restore the Aqua cursor.
-void QuartzSuspendXCursor(
-    ScreenPtr pScreen )
-{
-    QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
-
-    CHANGE_QD_CURSOR(NULL);
-    SHOW_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
-}
-
-
-// X server is showing. Restore the X cursor.
-void QuartzResumeXCursor(
-    ScreenPtr pScreen,
-    int x,
-    int y )
-{
-    QuartzSetCursor(pScreen, quartzLatentCursor, x, y);
-}
diff --git a/hw/xquartz/quartzCursor.h b/hw/xquartz/quartzCursor.h
deleted file mode 100644
index 56a0209..0000000
--- a/hw/xquartz/quartzCursor.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * quartzCursor.h
- *
- * External interface for Quartz hardware cursor
- *
- * Copyright (c) 2001 Torrey T. Lyons and Greg Parker.
- *                 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
- * 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 QUARTZCURSOR_H
-#define QUARTZCURSOR_H
-
-#include "screenint.h"
-
-Bool QuartzInitCursor(ScreenPtr pScreen);
-void QuartzReallySetCursor(void);
-void QuartzSuspendXCursor(ScreenPtr pScreen);
-void QuartzResumeXCursor(ScreenPtr pScreen, int x, int y);
-
-#endif
commit a25704c423598d596fd7f2ed4290d4b860bd5d5f
Author: Ben Byer <bbyer at apple.com>
Date:   Mon Mar 31 18:15:18 2008 -0700

    remove vestigal DarwinEQPointerPost etc

diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 9c8efa0..b146321 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -251,23 +251,6 @@ void DarwinEQEnqueue(const xEventPtr e) {
 }
 
 /*
- * DarwinEQPointerPost
- *  Post a pointer event. Used by the mipointer.c routines.
- */
-void DarwinEQPointerPost(DeviceIntPtr pdev, xEventPtr e) {
-    (*darwinEventQueue.pPtr->processInputProc)
-            (e, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
-}
-
-
-void DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX) {
-    darwinEventQueue.pEnqueueScreen = pScreen;
-    if (fromDIX)
-        darwinEventQueue.pDequeueScreen = pScreen;
-}
-
-
-/*
  * ProcessInputEvents
  *  Read and process events from the event queue until it is empty.
  */
diff --git a/hw/xquartz/quartzCursor.c b/hw/xquartz/quartzCursor.c
index 6e86acb..26ffa77 100644
--- a/hw/xquartz/quartzCursor.c
+++ b/hw/xquartz/quartzCursor.c
@@ -540,8 +540,8 @@ static miPointerScreenFuncRec quartzScreenFuncsRec = {
     QuartzCursorOffScreen,
     QuartzCrossScreen,
     QuartzWarpCursor,
-    DarwinEQPointerPost,
-    DarwinEQSwitchScreen
+    NULL,
+    NULL 
 };
 
 
diff --git a/hw/xquartz/xpr/xprCursor.c b/hw/xquartz/xpr/xprCursor.c
index dc7a73e..9e94ed5 100644
--- a/hw/xquartz/xpr/xprCursor.c
+++ b/hw/xquartz/xpr/xprCursor.c
@@ -321,8 +321,8 @@ static miPointerScreenFuncRec quartzScreenFuncsRec = {
     QuartzCursorOffScreen,
     QuartzCrossScreen,
     QuartzWarpCursor,
-    DarwinEQPointerPost,
-    DarwinEQSwitchScreen
+    NULL,
+    NULL
 };
 
 
commit a9e081a60ca227c0d96d4613075d97d6b762366a
Author: Ben Byer <bbyer at apple.com>
Date:   Mon Mar 31 17:48:09 2008 -0700

    gut darwinEQEnqueue, and make it just call mieqEnqueue (for the moment)

diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index e9ad234..9c8efa0 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -199,7 +199,11 @@ void DarwinEventHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int neven
   int i;
 
   DEBUG_LOG("DarwinEventHandler(%d, %p, %p, %d)\n", screenNum, xe, dev, nevents);
-  for (i=0; i<nevents; i++) QuartzProcessEvent(&xe[i]);
+  for (i=0; i<nevents; i++) {
+    if (xe[i].u.u.type == kXquartzDeactivate)
+      DarwinReleaseModifiers();
+    QuartzProcessEvent(&xe[i]);
+  }
 }
 
 Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr) { 
@@ -242,40 +246,10 @@ Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr) {
  * This should be deprecated in favor of miEQEnqueue -- BB
  */
 void DarwinEQEnqueue(const xEventPtr e) {
-    HWEventQueueType oldtail, newtail;
-
-    oldtail = darwinEventQueue.tail;
-
-    // mieqEnqueue() collapses successive motion events into one event.
-    // This is difficult to do in a thread-safe way and rarely useful.
-
-    newtail = oldtail + 1;
-    if (newtail == QUEUE_SIZE) newtail = 0;
-    /* Toss events which come in late */
-    if (newtail == darwinEventQueue.head) return;
-
-    darwinEventQueue.events[oldtail].event = *e;
-
-    /*
-     * Make sure that event times don't go backwards - this
-     * is "unnecessary", but very useful
-     */
-    if (e->u.keyButtonPointer.time < darwinEventQueue.lastEventTime &&
-        darwinEventQueue.lastEventTime - e->u.keyButtonPointer.time < 10000)
-    {
-        darwinEventQueue.events[oldtail].event.u.keyButtonPointer.time =
-        darwinEventQueue.lastEventTime;
-    }
-    darwinEventQueue.events[oldtail].pScreen = darwinEventQueue.pEnqueueScreen;
-
-    // Update the tail after the event is prepared
-    darwinEventQueue.tail = newtail;
-
-    // Signal there is an event ready to handle
-    DarwinPokeEQ();
+  mieqEnqueue(NULL, e);
+  DarwinPokeEQ();
 }
 
-
 /*
  * DarwinEQPointerPost
  *  Post a pointer event. Used by the mipointer.c routines.
commit 9a03ae33c4f9de830f15eabf3b994882ead7c000
Author: Ben Byer <bbyer at apple.com>
Date:   Mon Mar 31 17:08:45 2008 -0700

    add prototype for DarwinEventHandler

diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index de3541d..e9ad234 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -204,8 +204,6 @@ void DarwinEventHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int neven
 
 Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr) { 
 
-  void mieqSetHandler(int event, mieqHandler handler);
-
     darwinEvents = (xEvent *)malloc(sizeof(xEvent) * GetMaximumEventsNum());
     mieqInit();
     mieqSetHandler(kXquartzActivate, DarwinEventHandler);
diff --git a/hw/xquartz/darwinEvents.h b/hw/xquartz/darwinEvents.h
index 4960614..1d8e92a 100644
--- a/hw/xquartz/darwinEvents.h
+++ b/hw/xquartz/darwinEvents.h
@@ -41,4 +41,6 @@ void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y,
 			    float pressure, float tilt_x, float tilt_y);
 void DarwinUpdateModKeys(int flags);
 
+void DarwinEventHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, 
+			int nevents);
 #endif  /* _DARWIN_EVENTS_H */
commit 5848510cc5a8091b30230ab920d904ca6b159480
Author: Ben Byer <bbyer at apple.com>
Date:   Mon Mar 31 16:30:16 2008 -0700

    add logging of current thread ID to DEBUG_LOG macro

diff --git a/hw/xquartz/darwin.h b/hw/xquartz/darwin.h
index ce104cf..5b3bc75 100644
--- a/hw/xquartz/darwin.h
+++ b/hw/xquartz/darwin.h
@@ -125,7 +125,7 @@ enum {
 #ifdef ENABLE_DEBUG_LOG
 extern FILE *debug_log_fp;
 #define DEBUG_LOG_NAME "x11-debug.txt"
-#define DEBUG_LOG(msg, args...) if (debug_log_fp) fprintf(debug_log_fp, "%s:%s:%d " msg, __FILE__, __FUNCTION__, __LINE__, ##args ); fflush(debug_log_fp);
+#define DEBUG_LOG(msg, args...) if (debug_log_fp) fprintf(debug_log_fp, "%x:%s:%s:%d " msg, pthread_self(), __FILE__, __FUNCTION__, __LINE__, ##args ); fflush(debug_log_fp);
 #else
 #define DEBUG_LOG(msg, args...) 
 #endif
commit 3f4447b95f73a82b3aa0f7b0d1640aba5fb0d1bc
Author: Ben Byer <bbyer at apple.com>
Date:   Mon Mar 31 16:24:01 2008 -0700

    Begin to move all of our Xquartz DDX-specific event handlers
    to miEQ, in preparation to remove the DDX-specific code entirely.

diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index d6d9ba5..de3541d 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -195,10 +195,34 @@ static void DarwinSimulateMouseClick(
     DarwinUpdateModifiers(KeyPress, modifierMask);
 }
 
+void DarwinEventHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents) {
+  int i;
+
+  DEBUG_LOG("DarwinEventHandler(%d, %p, %p, %d)\n", screenNum, xe, dev, nevents);
+  for (i=0; i<nevents; i++) QuartzProcessEvent(&xe[i]);
+}
 
 Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr) { 
+
+  void mieqSetHandler(int event, mieqHandler handler);
+
     darwinEvents = (xEvent *)malloc(sizeof(xEvent) * GetMaximumEventsNum());
     mieqInit();
+    mieqSetHandler(kXquartzActivate, DarwinEventHandler);
+    mieqSetHandler(kXquartzDeactivate, DarwinEventHandler);
+    mieqSetHandler(kXquartzSetRootClip, DarwinEventHandler);
+    mieqSetHandler(kXquartzQuit, DarwinEventHandler);
+    mieqSetHandler(kXquartzReadPasteboard, DarwinEventHandler);
+    mieqSetHandler(kXquartzWritePasteboard, DarwinEventHandler);
+    mieqSetHandler(kXquartzToggleFullscreen, DarwinEventHandler);
+    mieqSetHandler(kXquartzSetRootless, DarwinEventHandler);
+    mieqSetHandler(kXquartzSpaceChanged, DarwinEventHandler);
+    mieqSetHandler(kXquartzControllerNotify, DarwinEventHandler);
+    mieqSetHandler(kXquartzPasteboardNotify, DarwinEventHandler);
+    mieqSetHandler(kXquartzDisplayChanged, DarwinEventHandler);
+    mieqSetHandler(kXquartzWindowState, DarwinEventHandler);
+    mieqSetHandler(kXquartzWindowMoved, DarwinEventHandler);
+
     darwinEventQueue.head = darwinEventQueue.tail = 0;
     darwinEventQueue.lastEventTime = GetTimeInMillis ();
     darwinEventQueue.pKbd = pKbd;
commit 135eb27bce025b21ca9b1b067377fa31f0f1e1c2
Author: Ben Byer <bbyer at apple.com>
Date:   Fri Mar 28 20:47:44 2008 -0700

    Add code to track 5 valuators for pointing device, in preparation
    for supporting tablet input in Xquartz.

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 8ce42c1..0bed917 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -65,7 +65,7 @@ int X11EnableKeyEquivalents = TRUE;
 int quartzHasRoot = FALSE, quartzEnableRootless = TRUE;
 
 extern int darwinFakeButtons, input_check_flag;
-extern Bool enable_stereo; 
+extern Bool enable_stereo;
 
 extern xEvent *darwinEvents;
 
@@ -157,7 +157,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
 	
     tem = [infoDict objectForKey:@"CFBundleShortVersionString"];
 	
-    [dict setObject:[NSString stringWithFormat:@"Xquartz %@ - (xorg-server %s)", tem, XSERVER_VERSION] 
+    [dict setObject:[NSString stringWithFormat:@"XQuartz %@ - (xorg-server %s)", tem, XSERVER_VERSION]
 	  forKey:@"ApplicationVersion"];
 	
     [self orderFrontStandardAboutPanelWithOptions: dict];
@@ -505,7 +505,7 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
   
   if (value != NULL
       && CFGetTypeID (value) == CFNumberGetTypeID ()
-      && CFNumberIsFloatType (value)) 
+      && CFNumberIsFloatType (value))
     CFNumberGetValue (value, kCFNumberFloatType, &ret);
   else if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ())
     ret = CFStringGetDoubleValue (value);
@@ -866,7 +866,9 @@ static void send_nsevent (NSEventType type, NSEvent *e) {
     NSRect screen;
     NSPoint location;
     NSWindow *window;
-    int pointer_x, pointer_y, ev_button, ev_type; 
+    int pointer_x, pointer_y, ev_button, ev_type;
+    float pressure, tilt_x, tilt_y;
+
     //    int num_events=0, i=0, state;
     // xEvent xe;
 	
@@ -888,6 +890,10 @@ static void send_nsevent (NSEventType type, NSEvent *e) {
     pointer_y -= aquaMenuBarHeight;
     //    state = convert_flags ([e modifierFlags]);
     
+    pressure = 0;  // for tablets
+    tilt_x = 0;
+    tilt_y = 0;
+
     switch (type) {
     case NSLeftMouseDown:    ev_button=1; ev_type=ButtonPress; goto handle_mouse;
     case NSOtherMouseDown:   ev_button=2; ev_type=ButtonPress; goto handle_mouse;
@@ -898,6 +904,10 @@ static void send_nsevent (NSEventType type, NSEvent *e) {
     case NSLeftMouseDragged:  ev_button=1; ev_type=MotionNotify; goto handle_mouse;
     case NSOtherMouseDragged: ev_button=2; ev_type=MotionNotify; goto handle_mouse;
     case NSRightMouseDragged: ev_button=3; ev_type=MotionNotify; goto handle_mouse;
+    case NSTabletPoint:
+      pressure = [e pressure];
+      tilt_x = [e tilt].x;
+      tilt_y = [e tilt].y; // fall through
     case NSMouseMoved: ev_button=0; ev_type=MotionNotify; goto handle_mouse;
     handle_mouse:
       
@@ -911,10 +921,14 @@ static void send_nsevent (NSEventType type, NSEvent *e) {
 	DarwinSendPointerEvents(ev_type, ev_button, pointer_x, pointer_y);
       } else if (ev_type==ButtonRelease && (button_state & (1 << ev_button)) == 0) break;
       */
-      DarwinSendPointerEvents(ev_type, ev_button, pointer_x, pointer_y);
+
+      //      if ([e subtype] == NSTabletPointEventSubtype) pressure = [e pressure];
+      DarwinSendPointerEvents(ev_type, ev_button, pointer_x, pointer_y,
+			      pressure, tilt_x, tilt_y);
       break;
-    case NSScrollWheel: 
-      DarwinSendScrollEvents([e deltaY], pointer_x, pointer_y);
+    case NSScrollWheel:
+      DarwinSendScrollEvents([e deltaY], pointer_x, pointer_y,
+			     pressure, tilt_x, tilt_y);
       break;
       
     case NSKeyDown:  // do we need to translate these keyCodes?
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 60a9084..d6d9ba5 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -173,6 +173,9 @@ static void DarwinReleaseModifiers(void) {
 static void DarwinSimulateMouseClick(
     int pointer_x,
     int pointer_y,
+    float pressure,
+    float tilt_x,
+    float tilt_y,
     int whichButton,    // mouse button to be pressed
     int modifierMask)   // modifiers used for the fake click
 {
@@ -183,8 +186,10 @@ static void DarwinSimulateMouseClick(
     DarwinUpdateModifiers(KeyRelease, modifierMask);
 
     // push the mouse button
-    DarwinSendPointerEvents(ButtonPress, whichButton, pointer_x, pointer_y);
-    DarwinSendPointerEvents(ButtonRelease, whichButton, pointer_x, pointer_y);
+    DarwinSendPointerEvents(ButtonPress, whichButton, pointer_x, pointer_y, 
+			    pressure, tilt_x, tilt_y);
+    DarwinSendPointerEvents(ButtonRelease, whichButton, pointer_x, pointer_y, 
+			    pressure, tilt_x, tilt_y);
 
     // restore old modifiers
     DarwinUpdateModifiers(KeyPress, modifierMask);
@@ -378,22 +383,39 @@ void DarwinPokeEQ(void) {
   write(darwinEventWriteFD, &nullbyte, 1);
 }
 
-void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int pointer_y) {
+void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int pointer_y, 
+			     float pressure, float tilt_x, float tilt_y) {
   static int darwinFakeMouseButtonDown = 0;
   static int darwinFakeMouseButtonMask = 0;
   int i, num_events;
-  int valuators[2] = {pointer_x, pointer_y};
+
+  /* I can't find a spec for this, but at least GTK expects that tablets are
+     just like mice, except they have either one or three extra valuators, in this
+     order:
+     
+     X coord, Y coord, pressure, X tilt, Y tilt
+     Pressure and tilt should be represented natively as floats; unfortunately,
+     we can't do that.  Again, GTK seems to record the min/max of each valuator,
+     and then perform scaling back to float itself using that info. Soo.... */
+
+  int valuators[5] = {pointer_x, pointer_y, 
+		      pressure * INT32_MAX * 1.0f, 
+		      tilt_x * INT32_MAX * 1.0f, 
+		      tilt_y * INT32_MAX * 1.0f};
+
   if (ev_type == ButtonPress && darwinFakeButtons && ev_button == 1) {
     // Mimic multi-button mouse with modifier-clicks
     // If both sets of modifiers are pressed,
     // button 2 is clicked.
     if ((old_flags & darwinFakeMouse2Mask) == darwinFakeMouse2Mask) {
-      DarwinSimulateMouseClick(pointer_x, pointer_y, 2, darwinFakeMouse2Mask);
+      DarwinSimulateMouseClick(pointer_x, pointer_y, pressure, 
+			       tilt_x, tilt_y, 2, darwinFakeMouse2Mask);
       darwinFakeMouseButtonDown = 2;
       darwinFakeMouseButtonMask = darwinFakeMouse2Mask;
       return;
     } else if ((old_flags & darwinFakeMouse3Mask) == darwinFakeMouse3Mask) {
-      DarwinSimulateMouseClick(pointer_x, pointer_y, 3, darwinFakeMouse3Mask);
+      DarwinSimulateMouseClick(pointer_x, pointer_y, pressure, 
+			       tilt_x, tilt_y, 3, darwinFakeMouse3Mask);
       darwinFakeMouseButtonDown = 3;
       darwinFakeMouseButtonMask = darwinFakeMouse3Mask;
       return;
@@ -412,7 +434,7 @@ void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int poin
   } 
 
   num_events = GetPointerEvents(darwinEvents, darwinPointer, ev_type, ev_button, 
-				POINTER_ABSOLUTE, 0, 2, valuators);
+				POINTER_ABSOLUTE, 0, 5, valuators);
       
   for(i=0; i<num_events; i++) mieqEnqueue (darwinPointer,&darwinEvents[i]);
   DarwinPokeEQ();
@@ -438,18 +460,38 @@ void DarwinSendKeyboardEvents(int ev_type, int keycode) {
   DarwinPokeEQ();
 }
 
+void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y, 
+			       float pressure, float tilt_x, float tilt_y) {
+  int i, num_events;
+  int valuators[5] = {pointer_x, pointer_y, 
+		      pressure * INT32_MAX * 1.0f, 
+		      tilt_x * INT32_MAX * 1.0f, 
+		      tilt_y * INT32_MAX * 1.0f};
+
+  num_events = GetProximityEvents(darwinEvents, darwinPointer, ev_type,
+				0, 5, valuators);
+      
+  for(i=0; i<num_events; i++) mieqEnqueue (darwinPointer,&darwinEvents[i]);
+  DarwinPokeEQ();
+}
+
+
 /* Send the appropriate number of button 4 / 5 clicks to emulate scroll wheel */
-void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y) {
+void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y, 
+			    float pressure, float tilt_x, float tilt_y) {
   int i;
   int ev_button = count > 0.0f ? 4 : 5;
-  int valuators[2] = {pointer_x, pointer_y};
+  int valuators[5] = {pointer_x, pointer_y, 
+		      pressure * INT32_MAX * 1.0f, 
+		      tilt_x * INT32_MAX * 1.0f, 
+		      tilt_y * INT32_MAX * 1.0f};
 
   for (count = fabs(count); count > 0.0; count = count - 1.0f) {
     int num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonPress, ev_button, 
-				      POINTER_ABSOLUTE, 0, 2, valuators);
+				      POINTER_ABSOLUTE, 0, 5, valuators);
     for(i=0; i<num_events; i++) mieqEnqueue(darwinPointer,&darwinEvents[i]);
     num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonRelease, ev_button, 
-				      POINTER_ABSOLUTE, 0, 2, valuators);
+				      POINTER_ABSOLUTE, 0, 5, valuators);
     for(i=0; i<num_events; i++) mieqEnqueue(darwinPointer,&darwinEvents[i]);
   }
   DarwinPokeEQ();
diff --git a/hw/xquartz/darwinEvents.h b/hw/xquartz/darwinEvents.h
index 82cc26b..4960614 100644
--- a/hw/xquartz/darwinEvents.h
+++ b/hw/xquartz/darwinEvents.h
@@ -32,9 +32,13 @@ void DarwinEQEnqueue(const xEventPtr e);
 void DarwinEQPointerPost(DeviceIntPtr pDev, xEventPtr e);
 void DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX);
 void DarwinPokeEQ(void);
-void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int pointer_y);
+void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int pointer_y,
+			     float pressure, float tilt_x, float tilt_y);
+void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y, 
+			       float pressure, float tilt_x, float tilt_y);
 void DarwinSendKeyboardEvents(int ev_type, int keycode);
-void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y);
+void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y,
+			    float pressure, float tilt_x, float tilt_y);
 void DarwinUpdateModKeys(int flags);
 
 #endif  /* _DARWIN_EVENTS_H */
commit a6c8fbc818933bdcf9ba0705ebbaa0a039fe5b7b
Author: Ben Byer <bbyer at apple.com>
Date:   Fri Mar 28 18:27:02 2008 -0700

    add debug statements so we can see if/when our Xinput stubs are getting called.

diff --git a/hw/xquartz/darwinXinput.c b/hw/xquartz/darwinXinput.c
index 50ba656..59bae6f 100644
--- a/hw/xquartz/darwinXinput.c
+++ b/hw/xquartz/darwinXinput.c
@@ -62,6 +62,7 @@ SOFTWARE.
 #include <X11/extensions/XI.h>
 #include <X11/extensions/XIproto.h>
 #include "XIstubs.h"
+#include "darwin.h"
 
 /***********************************************************************
  *
@@ -79,6 +80,7 @@ SOFTWARE.
 void
 CloseInputDevice(DeviceIntPtr d, ClientPtr client)
 {
+  DEBUG_LOG("CloseInputDevice(%p, %p)\n", d, client);
 }
 
 /***********************************************************************
@@ -122,7 +124,7 @@ AddOtherInputDevices(void)
     RegisterOtherDevice(dev);
     dev->inited = ((*dev->deviceProc)(dev, DEVICE_INIT) == Success);
     ************************************************************************/
-
+  DEBUG_LOG("AddOtherInputDevices\n");
 }
 
 /***********************************************************************
@@ -150,6 +152,7 @@ AddOtherInputDevices(void)
 void
 OpenInputDevice(DeviceIntPtr dev, ClientPtr client, int *status)
 {
+  DEBUG_LOG("OpenInputDevice(%p, %p, %p)\n", dev, client, status);
 }
 
 /****************************************************************************
@@ -167,6 +170,7 @@ OpenInputDevice(DeviceIntPtr dev, ClientPtr client, int *status)
 int
 SetDeviceMode(ClientPtr client, DeviceIntPtr dev, int mode)
 {
+  DEBUG_LOG("SetDeviceMode(%p, %p, %d)\n", client, dev, mode);
     return BadMatch;
 }
 
@@ -186,7 +190,9 @@ int
 SetDeviceValuators(ClientPtr client, DeviceIntPtr dev,
 		   int *valuators, int first_valuator, int num_valuators)
 {
-    return BadMatch;
+  DEBUG_LOG("SetDeviceValuators(%p, %p, %p, %d, %d)\n", client,
+	    dev, valuators, first_valuator, num_valuators);
+  return BadMatch;
 }
 
 /****************************************************************************
@@ -201,6 +207,8 @@ int
 ChangeDeviceControl(ClientPtr client, DeviceIntPtr dev,
 		    xDeviceCtl * control)
 {
+
+  DEBUG_LOG("ChangeDeviceControl(%p, %p, %p)\n", client, dev, control);
     switch (control->control) {
     case DEVICE_RESOLUTION:
 	return (BadMatch);
@@ -225,7 +233,8 @@ ChangeDeviceControl(ClientPtr client, DeviceIntPtr dev,
 int
 NewInputDeviceRequest(InputOption *options, DeviceIntPtr *pdev)
 {
-    return BadValue;
+  DEBUG_LOG("NewInputDeviceRequest(%p, %p)\n", options, pdev);
+  return BadValue;
 }
 
 /****************************************************************************
@@ -238,4 +247,5 @@ NewInputDeviceRequest(InputOption *options, DeviceIntPtr *pdev)
 void
 DeleteInputDeviceRequest(DeviceIntPtr dev)
 {
+  DEBUG_LOG("DeleteInputDeviceRequest(%p)\n", dev);
 }
commit 8b5737b3cf54afd01013045622c7af8d8e316507
Author: Ben Byer <bbyer at apple.com>
Date:   Fri Mar 28 18:25:03 2008 -0700

    Remove calls to InitValuatorAxisStruct -- these are now handled in dix by
    InitValuatorDeviceClass.
    Add InitProximityClassDeviceStruct call to prepare for tablet support.

diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index fa65a79..ec1d5e0 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -353,24 +353,8 @@ static int DarwinMouseProc(
             InitPointerDeviceStruct( (DevicePtr)pPointer, map, 5,
 				     GetMotionHistory,
 				     (PtrCtrlProcPtr)NoopDDA,
-				     GetMotionHistorySize(), 2);
-
-#ifdef XINPUT
-            InitValuatorAxisStruct( pPointer,
-                                    0,     // X axis
-                                    0,     // min value
-                                    16000, // max value (fixme screen size?)
-                                    1,     // resolution (fixme ?)
-                                    1,     // min resolution
-                                    1 );   // max resolution
-            InitValuatorAxisStruct( pPointer,
-                                    1,     // X axis
-                                    0,     // min value
-                                    16000, // max value (fixme screen size?)
-                                    1,     // resolution (fixme ?)
-                                    1,     // min resolution
-                                    1 );   // max resolution
-#endif
+				     GetMotionHistorySize(), 5);
+	    InitProximityClassDeviceStruct( (DevicePtr)pPointer);
             break;
 
         case DEVICE_ON:
commit a28b8c23d9fa606c68dd5e5f86af52e19604b245
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Fri Mar 28 17:00:08 2008 -0700

    XQuartz: Fixed names of enums to be more consistent

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 2172b3c..8ce42c1 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -157,7 +157,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
 	
     tem = [infoDict objectForKey:@"CFBundleShortVersionString"];
 	
-    [dict setObject:[NSString stringWithFormat:@"XQuartz %@ - (xorg-server %s)", tem, XSERVER_VERSION] 
+    [dict setObject:[NSString stringWithFormat:@"Xquartz %@ - (xorg-server %s)", tem, XSERVER_VERSION] 
 	  forKey:@"ApplicationVersion"];
 	
     [self orderFrontStandardAboutPanelWithOptions: dict];
@@ -170,7 +170,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
     static TSMDocumentID x11_document;
 	DEBUG_LOG("state=%d, _x_active=%d, \n", state, _x_active)
     if (state) {
-      QuartzMessageServerThread (kXDarwinActivate, 0);
+      QuartzMessageServerThread (kXquartzActivate, 0);
       
       if (!_x_active) {
 	if (x11_document == 0 && darwinKeymapFile == NULL) {
@@ -182,7 +182,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
 	if (x11_document != 0)	ActivateTSMDocument (x11_document);
       }
     } else {
-      QuartzMessageServerThread (kXDarwinDeactivate, 0);
+      QuartzMessageServerThread (kXquartzDeactivate, 0);
       
       if (_x_active && x11_document != 0)
 	DeactivateTSMDocument (x11_document);
@@ -250,7 +250,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
 	  swallow_up = 0;
 	  for_x = NO;
 #ifdef DARWIN_DDX_MISSING
-	  QuartzMessageServerThread (kXDarwinToggleFullscreen, 0);
+	  QuartzMessageServerThread (kXquartzToggleFullscreen, 0);
 #endif
 	}
       } else {
@@ -658,7 +658,7 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
 
 /* This will end up at the end of the responder chain. */
 - (void) copy:sender {
-  QuartzMessageServerThread (kXDarwinPasteboardNotify, 1,
+  QuartzMessageServerThread (kXquartzPasteboardNotify, 1,
 			     AppleWMCopyToPasteboard);
 }
 
diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m
index dfa2074..aa9fa94 100644
--- a/hw/xquartz/X11Controller.m
+++ b/hw/xquartz/X11Controller.m
@@ -103,7 +103,7 @@
 {
   [NSApp activateIgnoringOtherApps:YES];
 	
-  QuartzMessageServerThread (kXDarwinControllerNotify, 2,
+  QuartzMessageServerThread (kXquartzControllerNotify, 2,
 			     AppleWMWindowMenuItem, [sender tag]);
 }
 
@@ -254,7 +254,7 @@
   [self remove_window_menu];
   [self install_window_menu:list];
 	
-  QuartzMessageServerThread (kXDarwinControllerNotify, 1,
+  QuartzMessageServerThread (kXquartzControllerNotify, 1,
 			     AppleWMWindowMenuNotify);
 }
 
@@ -539,20 +539,20 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
 - (void) hide_window:sender
 {
   if ([X11App x_active])
-    QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMHideWindow);
+    QuartzMessageServerThread (kXquartzControllerNotify, 1, AppleWMHideWindow);
   else
     NSBeep ();			/* FIXME: something here */
 }
 
 - (IBAction)bring_to_front:sender
 {
-  QuartzMessageServerThread(kXDarwinControllerNotify, 1, AppleWMBringAllToFront);
+  QuartzMessageServerThread(kXquartzControllerNotify, 1, AppleWMBringAllToFront);
 }
 
 - (IBAction)close_window:sender
 {
   if ([X11App x_active])
-    QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMCloseWindow);
+    QuartzMessageServerThread (kXquartzControllerNotify, 1, AppleWMCloseWindow);
   else
     [[NSApp keyWindow] performClose:sender];
 }
@@ -560,7 +560,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
 - (IBAction)minimize_window:sender
 {
   if ([X11App x_active])
-    QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMMinimizeWindow);
+    QuartzMessageServerThread (kXquartzControllerNotify, 1, AppleWMMinimizeWindow);
   else
     [[NSApp keyWindow] performMiniaturize:sender];
 }
@@ -568,19 +568,19 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
 - (IBAction)zoom_window:sender
 {
   if ([X11App x_active])
-    QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMZoomWindow);
+    QuartzMessageServerThread (kXquartzControllerNotify, 1, AppleWMZoomWindow);
   else
     [[NSApp keyWindow] performZoom:sender];
 }
 
 - (IBAction) next_window:sender
 {
-  QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMNextWindow);
+  QuartzMessageServerThread (kXquartzControllerNotify, 1, AppleWMNextWindow);
 }
 
 - (IBAction) previous_window:sender
 {
-  QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMPreviousWindow);
+  QuartzMessageServerThread (kXquartzControllerNotify, 1, AppleWMPreviousWindow);
 }
 
 - (IBAction) enable_fullscreen_changed:sender
@@ -588,7 +588,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
   int value = ![enable_fullscreen intValue];
 	
 #ifdef DARWIN_DDX_MISSING
-  QuartzMessageServerThread (kXDarwinSetRootless, 1, value);
+  QuartzMessageServerThread (kXquartzSetRootless, 1, value);
 #endif
 	
   [NSApp prefs_set_boolean:@PREFS_ROOTLESS value:value];
@@ -598,7 +598,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
 - (IBAction) toggle_fullscreen:sender
 {
 #ifdef DARWIN_DDX_MISSING
-  QuartzMessageServerThread (kXDarwinToggleFullscreen, 0);
+  QuartzMessageServerThread (kXquartzToggleFullscreen, 0);
 #endif
 }
 
@@ -661,7 +661,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
 
 - (IBAction) quit:sender
 {
-  QuartzMessageServerThread (kXDarwinQuit, 0);
+  QuartzMessageServerThread (kXquartzQuit, 0);
 }
 
 - (IBAction) x11_help:sender
@@ -684,12 +684,12 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
 
 - (void) applicationDidHide:(NSNotification *)notify
 {
-  QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMHideAll);
+  QuartzMessageServerThread (kXquartzControllerNotify, 1, AppleWMHideAll);
 }
 
 - (void) applicationDidUnhide:(NSNotification *)notify
 {
-  QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMShowAll);
+  QuartzMessageServerThread (kXquartzControllerNotify, 1, AppleWMShowAll);
 }
 
 - (NSApplicationTerminateReply) applicationShouldTerminate:sender
@@ -717,7 +717,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
   [X11App prefs_synchronize];
 	
   /* shutdown the X server, it will exit () for us. */
-  QuartzMessageServerThread (kXDarwinQuit, 0);
+  QuartzMessageServerThread (kXquartzQuit, 0);
 	
   /* In case it doesn't, exit anyway after a while. */
   while (sleep (10) != 0) ;
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index 873f709..fa65a79 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -150,7 +150,7 @@ void
 DarwinPrintBanner(void)
 { 
   // this should change depending on which specific server we are building
-  ErrorF("XQuartz starting:\n");
+  ErrorF("Xquartz starting:\n");
   ErrorF("X.org Release 7.2\n"); // This is here to help fink until they fix their packages.
   ErrorF("X.Org X Server %s\nBuild Date: %s\n", XSERVER_VERSION, BUILD_DATE );
 }
@@ -863,7 +863,7 @@ void ddxUseMsg( void )
  */
 void ddxGiveUp( void )
 {
-    ErrorF( "Quitting XQuartz...\n" );
+    ErrorF( "Quitting Xquartz...\n" );
 
     //if (!quartzRootless)
     //    quartzProcs->ReleaseScreens();
diff --git a/hw/xquartz/darwin.h b/hw/xquartz/darwin.h
index 0d8e457..ce104cf 100644
--- a/hw/xquartz/darwin.h
+++ b/hw/xquartz/darwin.h
@@ -90,34 +90,34 @@ extern int              darwinMainScreenY;
  * Special ddx events understood by the X server
  */
 enum {
-    kXDarwinUpdateModifiers   // update all modifier keys
+    kXquartzUpdateModifiers   // update all modifier keys
             = LASTEvent+1,    // (from X.h list of event names)
-    kXDarwinUpdateButtons,    // update state of mouse buttons 2 and up
-    kXDarwinScrollWheel,      // scroll wheel event
+    kXquartzUpdateButtons,    // update state of mouse buttons 2 and up
+    kXquartzScrollWheel,      // scroll wheel event
     /*
      * Quartz-specific events -- not used in IOKit mode
      */
-    kXDarwinActivate,         // restore X drawing and cursor
-    kXDarwinDeactivate,       // clip X drawing and switch to Aqua cursor
-    kXDarwinSetRootClip,      // enable or disable drawing to the X screen
-    kXDarwinQuit,             // kill the X server and release the display
-    kXDarwinReadPasteboard,   // copy Mac OS X pasteboard into X cut buffer
-    kXDarwinWritePasteboard,  // copy X cut buffer onto Mac OS X pasteboard
-    kXDarwinBringAllToFront,  // bring all X windows to front
-    kXDarwinToggleFullscreen, // Enable/Disable fullscreen mode
-    kXDarwinSetRootless,      // Set rootless mode
-    kXDarwinSpaceChanged,     // Spaces changed
+    kXquartzActivate,         // restore X drawing and cursor
+    kXquartzDeactivate,       // clip X drawing and switch to Aqua cursor
+    kXquartzSetRootClip,      // enable or disable drawing to the X screen
+    kXquartzQuit,             // kill the X server and release the display
+    kXquartzReadPasteboard,   // copy Mac OS X pasteboard into X cut buffer
+    kXquartzWritePasteboard,  // copy X cut buffer onto Mac OS X pasteboard
+    kXquartzBringAllToFront,  // bring all X windows to front
+    kXquartzToggleFullscreen, // Enable/Disable fullscreen mode
+    kXquartzSetRootless,      // Set rootless mode
+    kXquartzSpaceChanged,     // Spaces changed
     /*
      * AppleWM events
      */
-    kXDarwinControllerNotify, // send an AppleWMControllerNotify event
-    kXDarwinPasteboardNotify, // notify the WM to copy or paste
+    kXquartzControllerNotify, // send an AppleWMControllerNotify event
+    kXquartzPasteboardNotify, // notify the WM to copy or paste
     /*
      * Xplugin notification events
      */
-    kXDarwinDisplayChanged,   // display configuration has changed
-    kXDarwinWindowState,      // window visibility state has changed
-    kXDarwinWindowMoved,      // window has moved on screen
+    kXquartzDisplayChanged,   // display configuration has changed
+    kXquartzWindowState,      // window visibility state has changed
+    kXquartzWindowMoved,      // window has moved on screen
 };
 
 #define ENABLE_DEBUG_LOG 1
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index a183011..60a9084 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -152,7 +152,7 @@ static void DarwinUpdateModifiers(
 /*
  * DarwinReleaseModifiers
  * This hacky function releases all modifier keys.  It should be called when X11.app
- * is deactivated (kXDarwinDeactivate) to prevent modifiers from getting stuck if they
+ * is deactivated (kXquartzDeactivate) to prevent modifiers from getting stuck if they
  * are held down during a "context" switch -- otherwise, we would miss the KeyUp.
  */
 static void DarwinReleaseModifiers(void) {
@@ -341,22 +341,22 @@ void ProcessInputEvents(void) {
                 break;
 
             case MotionNotify:
-	      ErrorF("Unexpected ButtonRelease event in DarwinProcessInputEvents\n");
+	      ErrorF("Unexpected MotionNotify event in DarwinProcessInputEvents\n");
                 break;
 
-            case kXDarwinUpdateModifiers:
-	      ErrorF("Unexpected ButtonRelease event in DarwinProcessInputEvents\n");
+            case kXquartzUpdateModifiers:
+	      ErrorF("Unexpected kXquartzUpdateModifiers event in DarwinProcessInputEvents\n");
 	      break;
 
-            case kXDarwinUpdateButtons:
-	      ErrorF("Unexpected XDarwinScrollWheel event in DarwinProcessInputEvents\n");
+            case kXquartzUpdateButtons:
+	      ErrorF("Unexpected kXquartzUpdateButtons event in DarwinProcessInputEvents\n");
 	      break;
 
-            case kXDarwinScrollWheel: 
-	      ErrorF("Unexpected XDarwinScrollWheel event in DarwinProcessInputEvents\n");
+            case kXquartzScrollWheel: 
+	      ErrorF("Unexpected kXquartzScrollWheel event in DarwinProcessInputEvents\n");
 	      break;
 
-			case kXDarwinDeactivate:
+			case kXquartzDeactivate:
 				DarwinReleaseModifiers();
 				// fall through
             default:
diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index 46027fd..1f1b9a4 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -419,24 +419,24 @@ QuartzMessageServerThread(
  */
 void QuartzProcessEvent(xEvent *xe) {
     switch (xe->u.u.type) {
-        case kXDarwinControllerNotify:
-            DEBUG_LOG("kXDarwinControllerNotify\n");
+        case kXquartzControllerNotify:
+            DEBUG_LOG("kXquartzControllerNotify\n");
             AppleWMSendEvent(AppleWMControllerNotify,
                              AppleWMControllerNotifyMask,
                              xe->u.clientMessage.u.l.longs0,
                              xe->u.clientMessage.u.l.longs1);
             break;
 
-        case kXDarwinPasteboardNotify:
-            DEBUG_LOG("kXDarwinPasteboardNotify\n");
+        case kXquartzPasteboardNotify:
+            DEBUG_LOG("kXquartzPasteboardNotify\n");
             AppleWMSendEvent(AppleWMPasteboardNotify,
                              AppleWMPasteboardNotifyMask,
                              xe->u.clientMessage.u.l.longs0,
                              xe->u.clientMessage.u.l.longs1);
             break;
 
-        case kXDarwinActivate:
-            DEBUG_LOG("kXDarwinActivate\n");
+        case kXquartzActivate:
+            DEBUG_LOG("kXquartzActivate\n");
             QuartzShow(xe->u.keyButtonPointer.rootX,
                        xe->u.keyButtonPointer.rootY);
             AppleWMSendEvent(AppleWMActivationNotify,
@@ -444,74 +444,74 @@ void QuartzProcessEvent(xEvent *xe) {
                              AppleWMIsActive, 0);
             break;
 
-        case kXDarwinDeactivate:
-            DEBUG_LOG("kXDarwinDeactivate\n");
+        case kXquartzDeactivate:
+            DEBUG_LOG("kXquartzDeactivate\n");
             AppleWMSendEvent(AppleWMActivationNotify,
                              AppleWMActivationNotifyMask,
                              AppleWMIsInactive, 0);
             QuartzHide();
             break;
 
-        case kXDarwinDisplayChanged:
-            DEBUG_LOG("kXDarwinDisplayChanged\n");
+        case kXquartzDisplayChanged:
+            DEBUG_LOG("kXquartzDisplayChanged\n");
             QuartzUpdateScreens();
             break;
 
-        case kXDarwinWindowState:
-            DEBUG_LOG("kXDarwinWindowState\n");
+        case kXquartzWindowState:
+            DEBUG_LOG("kXquartzWindowState\n");
             RootlessNativeWindowStateChanged(xe->u.clientMessage.u.l.longs0,
 		  			     xe->u.clientMessage.u.l.longs1);
 	    break;
 	  
-        case kXDarwinWindowMoved:
-            DEBUG_LOG("kXDarwinWindowMoved\n");
+        case kXquartzWindowMoved:
+            DEBUG_LOG("kXquartzWindowMoved\n");
             RootlessNativeWindowMoved ((WindowPtr)xe->u.clientMessage.u.l.longs0);
 	    break;
 
-        case kXDarwinToggleFullscreen:
-            DEBUG_LOG("kXDarwinToggleFullscreen\n");
+        case kXquartzToggleFullscreen:
+            DEBUG_LOG("kXquartzToggleFullscreen\n");
 #ifdef DARWIN_DDX_MISSING
             if (quartzEnableRootless) QuartzSetFullscreen(!quartzHasRoot);
             else if (quartzHasRoot) QuartzHide();
             else QuartzShow();
 #else
-    //	    ErrorF("kXDarwinToggleFullscreen not implemented\n");
+    //	    ErrorF("kXquartzToggleFullscreen not implemented\n");
 #endif
             break;
 
-        case kXDarwinSetRootless:
-            DEBUG_LOG("kXDarwinSetRootless\n");
+        case kXquartzSetRootless:
+            DEBUG_LOG("kXquartzSetRootless\n");
 #ifdef DARWIN_DDX_MISSING
             QuartzSetRootless(xe->u.clientMessage.u.l.longs0);
             if (!quartzEnableRootless && !quartzHasRoot) QuartzHide();
 #else
-    //	    ErrorF("kXDarwinSetRootless not implemented\n");
+    //	    ErrorF("kXquartzSetRootless not implemented\n");
 #endif
             break;
 
-        case kXDarwinSetRootClip:
+        case kXquartzSetRootClip:
             QuartzSetRootClip((BOOL)xe->u.clientMessage.u.l.longs0);
             break;
 
-        case kXDarwinQuit:
+        case kXquartzQuit:
             GiveUp(0);
             break;
 
-        case kXDarwinReadPasteboard:
+        case kXquartzReadPasteboard:
             QuartzReadPasteboard();
             break;
 
-        case kXDarwinWritePasteboard:
+        case kXquartzWritePasteboard:
             QuartzWritePasteboard();
             break;
 
-        case kXDarwinBringAllToFront:
-            DEBUG_LOG("kXDarwinBringAllToFront\n");
+        case kXquartzBringAllToFront:
+            DEBUG_LOG("kXquartzBringAllToFront\n");
             RootlessOrderAllWindows();
             break;
 
-        case kXDarwinSpaceChanged:
-            DEBUG_LOG("kXDarwinSpaceChanged\n");
+        case kXquartzSpaceChanged:
+            DEBUG_LOG("kXquartzSpaceChanged\n");
             QuartzSpaceChanged(xe->u.clientMessage.u.l.longs0);
             break;
         default:
diff --git a/hw/xquartz/quartzKeyboard.h b/hw/xquartz/quartzKeyboard.h
index 0c7e70e..8131b56 100644
--- a/hw/xquartz/quartzKeyboard.h
+++ b/hw/xquartz/quartzKeyboard.h
@@ -45,7 +45,7 @@ typedef struct darwinKeyboardInfo_struct {
     unsigned char modifierKeycodes[32][2];
 } darwinKeyboardInfo;
 
-/* These functions need to be implemented by XQuartz, XDarwin, etc. */
+/* These functions need to be implemented by Xquartz, XDarwin, etc. */
 void DarwinKeyboardReload(DeviceIntPtr pDev);
 Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info);
 unsigned int QuartzSystemKeymapSeed(void);
diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c
index 4dc5846..b653a6e 100644
--- a/hw/xquartz/xpr/xprScreen.c
+++ b/hw/xquartz/xpr/xprScreen.c
@@ -67,7 +67,7 @@ static void eventHandler(unsigned int type, const void *arg,
     switch (type) {
         case XP_EVENT_DISPLAY_CHANGED:
             DEBUG_LOG("XP_EVENT_DISPLAY_CHANGED\n");
-            QuartzMessageServerThread(kXDarwinDisplayChanged, 0);
+            QuartzMessageServerThread(kXquartzDisplayChanged, 0);
             break;
             
         case XP_EVENT_WINDOW_STATE_CHANGED:
@@ -75,7 +75,7 @@ static void eventHandler(unsigned int type, const void *arg,
                 const xp_window_state_event *ws_arg = arg;
                 
                 DEBUG_LOG("XP_EVENT_WINDOW_STATE_CHANGED: id=%d, state=%d\n", ws_arg->id, ws_arg->state);
-                QuartzMessageServerThread(kXDarwinWindowState, 2,
+                QuartzMessageServerThread(kXquartzWindowState, 2,
                                           ws_arg->id, ws_arg->state);
             } else {
                 DEBUG_LOG("XP_EVENT_WINDOW_STATE_CHANGED: ignored\n");
@@ -87,7 +87,7 @@ static void eventHandler(unsigned int type, const void *arg,
             if (arg_size == sizeof(xp_window_id))  {
                 xp_window_id id = * (xp_window_id *) arg;
                 WindowPtr pWin = xprGetXWindow(id);
-                QuartzMessageServerThread(kXDarwinWindowMoved, 1, pWin);
+                QuartzMessageServerThread(kXquartzWindowMoved, 1, pWin);
             }
             break;
             
@@ -110,7 +110,7 @@ static void eventHandler(unsigned int type, const void *arg,
             ErrorF("XP_EVENT_SPACE_CHANGED\n");
             if(arg_size == sizeof(uint32_t)) {
                 uint32_t space_id = *(uint32_t *)arg;
-                QuartzMessageServerThread(kXDarwinSpaceChanged, 1, space_id);
+                QuartzMessageServerThread(kXquartzSpaceChanged, 1, space_id);
             }
             break;
         default:
commit cc17ce1b73dadee75ad96ae96757fe8e4ba990de
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Fri Mar 28 16:38:18 2008 -0700

    XQuartz: Another Exposé fix: F9 doesn't raise all windows
    (cherry picked from commit b9cffa20debae73737c674bf75ab65db1bd74556)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 1ed87c6..2172b3c 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -318,9 +318,10 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
 }
 
 - (void) set_front_process:unused {
-    QuartzMessageServerThread(kXDarwinBringAllToFront, 0);
-    ProcessSerialNumber psn = { 0, kCurrentProcess };
-    SetFrontProcess(&psn);
+    [NSApp activateIgnoringOtherApps:YES];
+
+    if ([self modalWindow] == nil)
+        [self activateX:YES];
 }
 
 - (void) set_can_quit:(NSNumber *)state {
commit f57a2f38eee5e0f537e62c495dce1fcebffe3a54
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Tue Mar 25 23:01:02 2008 -0700

    XQuartz: Sanity-check the removal of the 256-color option
    Fixes the 'one-time-preferences' bug in 2.2.0_rc1
    (cherry picked from commit 38cbd13490fc21724e8eef0ec7e1a20a9cc2e39d)

diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m
index a9d2add..dfa2074 100644
--- a/hw/xquartz/X11Controller.m
+++ b/hw/xquartz/X11Controller.m
@@ -649,7 +649,8 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
 
     [depth selectItemAtIndex:[depth indexOfItemWithTag:[NSApp prefs_get_integer:@PREFS_DEPTH default:-1]]];
     // TODO: Add 256 color support
-    [depth removeItemAtIndex:[depth indexOfItemWithTag:8]];
+    if([depth indexOfItemWithTag:8] != -1)
+        [depth removeItemAtIndex:[depth indexOfItemWithTag:8]];
 	
     [enable_fullscreen setIntValue:!quartzEnableRootless];
     // TODO: Add fullscreen support
commit de722e2fea70467a1299b728a1bd9028664ec0c9
Author: Ben Byer <bbyer at apple.com>
Date:   Tue Mar 25 19:25:00 2008 -0700

    xquartz: copy in new stubs from Xi/stubs.c to replace our old
    Xinput stubs.  Hey, it's a start.

diff --git a/hw/xquartz/darwinXinput.c b/hw/xquartz/darwinXinput.c
index e62ec0a..50ba656 100644
--- a/hw/xquartz/darwinXinput.c
+++ b/hw/xquartz/darwinXinput.c
@@ -1,8 +1,7 @@
-
 /*
- * X server support of the XINPUT extension for Darwin
+ * X server support of the XINPUT extension for xquartz
  *
- * This is currently a copy of mi/stubs.c, but eventually this
+ * This is currently a copy of Xi/stubs.c, but eventually this
  * should include more complete XINPUT support.
  */
 
@@ -52,100 +51,17 @@ SOFTWARE.
 
 ********************************************************/
 
+#define	 NEED_EVENTS
 #ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
 #endif
 
-#define	 NEED_EVENTS
 #include <X11/X.h>
 #include <X11/Xproto.h>
 #include "inputstr.h"
 #include <X11/extensions/XI.h>
 #include <X11/extensions/XIproto.h>
 #include "XIstubs.h"
-#include "chgkbd.h"
-
-/***********************************************************************
- *
- * Caller:	ProcXChangeKeyboardDevice
- *
- * This procedure does the implementation-dependent portion of the work
- * needed to change the keyboard device.
- *
- * The X keyboard device has a FocusRec.  If the device that has been 
- * made into the new X keyboard did not have a FocusRec, 
- * ProcXChangeKeyboardDevice will allocate one for it.
- *
- * If you do not want clients to be able to focus the old X keyboard
- * device, call DeleteFocusClassDeviceStruct to free the FocusRec.
- *
- * If you support input devices with keys that you do not want to be 
- * used as the X keyboard, you need to check for them here and return 
- * a BadDevice error.
- *
- * The default implementation is to do nothing (assume you do want
- * clients to be able to focus the old X keyboard).  The commented-out
- * sample code shows what you might do if you don't want the default.
- *
- */
-
-int ChangeKeyboardDevice (DeviceIntPtr old_dev, DeviceIntPtr new_dev) {
-    /***********************************************************************
-     DeleteFocusClassDeviceStruct(old_dev);	 * defined in xchgptr.c *
-    **********************************************************************/
-    return BadMatch;
-}
-
-
-/***********************************************************************
- *
- * Caller:	ProcXChangePointerDevice
- *
- * This procedure does the implementation-dependent portion of the work
- * needed to change the pointer device.
- *
- * The X pointer device does not have a FocusRec.  If the device that
- * has been made into the new X pointer had a FocusRec, 
- * ProcXChangePointerDevice will free it.
- *
- * If you want clients to be able to focus the old pointer device that
- * has now become accessible through the input extension, you need to 
- * add a FocusRec to it here.
- *
- * The XChangePointerDevice protocol request also allows the client
- * to choose which axes of the new pointer device are used to move 
- * the X cursor in the X- and Y- directions.  If the axes are different
- * than the default ones, you need to keep track of that here.
- *
- * If you support input devices with valuators that you do not want to be 
- * used as the X pointer, you need to check for them here and return a 
- * BadDevice error.
- *
- * The default implementation is to do nothing (assume you don't want
- * clients to be able to focus the old X pointer).  The commented-out
- * sample code shows what you might do if you don't want the default.
- *
- */
-
-int
-ChangePointerDevice (
-    DeviceIntPtr	old_dev,
-    DeviceIntPtr	new_dev,
-    unsigned char	x,
-    unsigned char	y)
-    {
-    /***********************************************************************
-    InitFocusClassDeviceStruct(old_dev);	* allow focusing old ptr*
-
-    x_axis = x;					* keep track of new x-axis*
-    y_axis = y;					* keep track of new y-axis*
-    if (x_axis != 0 || y_axis != 1)
-	axes_changed = TRUE;			* remember axes have changed*
-    else
-	axes_changed = FALSE;
-    *************************************************************************/
-    return BadMatch;
-    }
 
 /***********************************************************************
  *
@@ -161,11 +77,9 @@ ChangePointerDevice (
  */
 
 void
-CloseInputDevice (d, client)
-    DeviceIntPtr d;
-    ClientPtr client;
-    {
-    }
+CloseInputDevice(DeviceIntPtr d, ClientPtr client)
+{
+}
 
 /***********************************************************************
  *
@@ -194,8 +108,8 @@ CloseInputDevice (d, client)
  */
 
 void
-AddOtherInputDevices ()
-    {
+AddOtherInputDevices(void)
+{
     /**********************************************************************
      for each uninitialized device, do something like: 
 
@@ -209,7 +123,7 @@ AddOtherInputDevices ()
     dev->inited = ((*dev->deviceProc)(dev, DEVICE_INIT) == Success);
     ************************************************************************/
 
-    }
+}
 
 /***********************************************************************
  *
@@ -234,12 +148,9 @@ AddOtherInputDevices ()
  */
 
 void
-OpenInputDevice (dev, client, status)
-    DeviceIntPtr dev;
-    ClientPtr client;
-    int *status;
-    {
-    }
+OpenInputDevice(DeviceIntPtr dev, ClientPtr client, int *status)
+{
+}
 
 /****************************************************************************
  *
@@ -254,13 +165,10 @@ OpenInputDevice (dev, client, status)
  */
 
 int
-SetDeviceMode (client, dev, mode)
-    register	ClientPtr	client;
-    DeviceIntPtr dev;
-    int		mode;
-    {
+SetDeviceMode(ClientPtr client, DeviceIntPtr dev, int mode)
+{
     return BadMatch;
-    }
+}
 
 /****************************************************************************
  *
@@ -275,15 +183,11 @@ SetDeviceMode (client, dev, mode)
  */
 
 int
-SetDeviceValuators (client, dev, valuators, first_valuator, num_valuators)
-    register	ClientPtr	client;
-    DeviceIntPtr dev;
-    int		*valuators;
-    int		first_valuator;
-    int		num_valuators;
-    {
+SetDeviceValuators(ClientPtr client, DeviceIntPtr dev,
+		   int *valuators, int first_valuator, int num_valuators)
+{
     return BadMatch;
-    }
+}
 
 /****************************************************************************
  *
@@ -294,16 +198,44 @@ SetDeviceValuators (client, dev, valuators, first_valuator, num_valuators)
  */
 
 int
-ChangeDeviceControl (client, dev, control)
-    register	ClientPtr	client;
-    DeviceIntPtr dev;
-    xDeviceCtl	*control;
-    {
-    switch (control->control)
-	{
-	case DEVICE_RESOLUTION:
-	    return (BadMatch);
-	default:
-	    return (BadMatch);
-	}
+ChangeDeviceControl(ClientPtr client, DeviceIntPtr dev,
+		    xDeviceCtl * control)
+{
+    switch (control->control) {
+    case DEVICE_RESOLUTION:
+	return (BadMatch);
+    case DEVICE_ABS_CALIB:
+    case DEVICE_ABS_AREA:
+        return (BadMatch);
+    case DEVICE_CORE:
+        return (BadMatch);
+    default:
+	return (BadMatch);
     }
+}
+
+
+/****************************************************************************
+ *
+ * Caller: configAddDevice (and others)
+ *
+ * Add a new device with the specified options.
+ *
+ */
+int
+NewInputDeviceRequest(InputOption *options, DeviceIntPtr *pdev)
+{
+    return BadValue;
+}
+
+/****************************************************************************
+ *
+ * Caller: configRemoveDevice (and others)
+ *
+ * Remove the specified device previously added.
+ *
+ */
+void
+DeleteInputDeviceRequest(DeviceIntPtr dev)
+{
+}
commit d34ff74c3c0b1561dc891661c306af793d071d77
Author: Ben Byer <bbyer at apple.com>
Date:   Mon Mar 24 22:43:10 2008 -0700

    prevent "fake mouse clicks" from generating spurious extra events

diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index b212e98..a183011 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -391,10 +391,12 @@ void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int poin
       DarwinSimulateMouseClick(pointer_x, pointer_y, 2, darwinFakeMouse2Mask);
       darwinFakeMouseButtonDown = 2;
       darwinFakeMouseButtonMask = darwinFakeMouse2Mask;
+      return;
     } else if ((old_flags & darwinFakeMouse3Mask) == darwinFakeMouse3Mask) {
       DarwinSimulateMouseClick(pointer_x, pointer_y, 3, darwinFakeMouse3Mask);
       darwinFakeMouseButtonDown = 3;
       darwinFakeMouseButtonMask = darwinFakeMouse3Mask;
+      return;
     }
   }
   if (ev_type == ButtonRelease && darwinFakeButtons && darwinFakeMouseButtonDown) {
@@ -406,6 +408,7 @@ void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int poin
     // Bring modifiers back up to date
     DarwinUpdateModifiers(KeyPress, darwinFakeMouseButtonMask & old_flags);
     darwinFakeMouseButtonMask = 0;
+    return;
   } 
 
   num_events = GetPointerEvents(darwinEvents, darwinPointer, ev_type, ev_button, 
commit 98b5f373e6c6adfef38f1477f86f3ebcf806a1bd
Author: Jeremy Huddleston <jeremy at tifa.local>
Date:   Fri Mar 21 19:31:31 2008 -0700

    XQuartz: Disable 256 color option and fullscreen option
    (cherry picked from commit 7c1964338a33558d3f25e369dfca99e3ef9d10f9)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index b843b74..1ed87c6 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -611,8 +611,10 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
 	
     quartzUseSysBeep = [self prefs_get_boolean:@PREFS_SYSBEEP
                         default:quartzUseSysBeep];
-    quartzEnableRootless = [self prefs_get_boolean:@PREFS_ROOTLESS
-                        default:quartzEnableRootless];
+
+    // TODO: Add fullscreen support
+    //quartzEnableRootless = [self prefs_get_boolean:@PREFS_ROOTLESS
+    //                    default:quartzEnableRootless];
 #ifdef DARWIN_DDX_MISSING
     quartzFullscreenDisableHotkeys = ![self prefs_get_boolean:
 					      @PREFS_FULLSCREEN_HOTKEYS default:
@@ -644,6 +646,10 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
 	
     darwinDesiredDepth = [self prefs_get_integer:@PREFS_DEPTH
                           default:darwinDesiredDepth];
+    
+    // TODO: Add 256 color support
+    if(darwinDesiredDepth == 8)
+        darwinDesiredDepth = -1;
 	
     enable_stereo = [self prefs_get_boolean:@PREFS_ENABLE_STEREO
                      default:false];
diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m
index 3880b3f..a9d2add 100644
--- a/hw/xquartz/X11Controller.m
+++ b/hw/xquartz/X11Controller.m
@@ -635,22 +635,27 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
 
 - (IBAction) prefs_show:sender
 {
-  [fake_buttons setIntValue:darwinFakeButtons];
-  [use_sysbeep setIntValue:quartzUseSysBeep];
-  [enable_keyequivs setIntValue:X11EnableKeyEquivalents];
-  [sync_keymap setIntValue:darwinSyncKeymap];
-  [sync_keymap setEnabled:darwinKeymapFile == NULL];
-  [click_through setIntValue:[NSApp prefs_get_boolean:@PREFS_CLICK_THROUGH default:NO]];
-  [focus_follows_mouse setIntValue:[NSApp prefs_get_boolean:@PREFS_FFM default:NO]];
-  [focus_on_new_window setIntValue:[NSApp prefs_get_boolean:@PREFS_FOCUS_ON_NEW_WINDOW default:YES]];
-
-  [enable_auth setIntValue:![NSApp prefs_get_boolean:@PREFS_NO_AUTH default:NO]];
-  [enable_tcp setIntValue:![NSApp prefs_get_boolean:@PREFS_NO_TCP default:NO]];
-  [depth selectItemAtIndex:[depth indexOfItemWithTag:[NSApp prefs_get_integer:@PREFS_DEPTH default:-1]]];
-	
-  [enable_fullscreen setIntValue:!quartzEnableRootless];
-	
-  [prefs_panel makeKeyAndOrderFront:sender];
+    [fake_buttons setIntValue:darwinFakeButtons];
+    [use_sysbeep setIntValue:quartzUseSysBeep];
+    [enable_keyequivs setIntValue:X11EnableKeyEquivalents];
+    [sync_keymap setIntValue:darwinSyncKeymap];
+    [sync_keymap setEnabled:darwinKeymapFile == NULL];
+    [click_through setIntValue:[NSApp prefs_get_boolean:@PREFS_CLICK_THROUGH default:NO]];
+    [focus_follows_mouse setIntValue:[NSApp prefs_get_boolean:@PREFS_FFM default:NO]];
+    [focus_on_new_window setIntValue:[NSApp prefs_get_boolean:@PREFS_FOCUS_ON_NEW_WINDOW default:YES]];
+    
+    [enable_auth setIntValue:![NSApp prefs_get_boolean:@PREFS_NO_AUTH default:NO]];
+    [enable_tcp setIntValue:![NSApp prefs_get_boolean:@PREFS_NO_TCP default:NO]];
+
+    [depth selectItemAtIndex:[depth indexOfItemWithTag:[NSApp prefs_get_integer:@PREFS_DEPTH default:-1]]];
+    // TODO: Add 256 color support
+    [depth removeItemAtIndex:[depth indexOfItemWithTag:8]];
+	
+    [enable_fullscreen setIntValue:!quartzEnableRootless];
+    // TODO: Add fullscreen support
+    [enable_fullscreen setEnabled:NO];
+	
+    [prefs_panel makeKeyAndOrderFront:sender];
 }
 
 - (IBAction) quit:sender
diff --git a/hw/xquartz/bundle/English.lproj/main.nib/designable.nib b/hw/xquartz/bundle/English.lproj/main.nib/designable.nib
index adc0340..672ba90 100644
--- a/hw/xquartz/bundle/English.lproj/main.nib/designable.nib
+++ b/hw/xquartz/bundle/English.lproj/main.nib/designable.nib
@@ -472,7 +472,7 @@
 										<characters key="NS.bytes">1</characters>
 									</object>
 									<object class="NSView" key="NSView" id="596750588">
-										<nil key="NSNextResponder"/>
+										<reference key="NSNextResponder" ref="448510093"/>
 										<int key="NSvFlags">256</int>
 										<object class="NSMutableArray" key="NSSubviews">
 											<bool key="EncodedWithXMLCoder">YES</bool>
@@ -616,6 +616,7 @@ ZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KA</string>
 											</object>
 										</object>
 										<string key="NSFrame">{{10, 33}, {438, 218}}</string>
+										<reference key="NSSuperview" ref="448510093"/>
 									</object>
 									<string key="NSLabel">Input</string>
 									<reference key="NSColor" ref="57160303"/>
@@ -839,7 +840,7 @@ ZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KA</string>
 										<characters key="NS.bytes">2</characters>
 									</object>
 									<object class="NSView" key="NSView" id="184765684">
-										<reference key="NSNextResponder" ref="448510093"/>
+										<nil key="NSNextResponder"/>
 										<int key="NSvFlags">256</int>
 										<object class="NSMutableArray" key="NSSubviews">
 											<bool key="EncodedWithXMLCoder">YES</bool>
@@ -956,7 +957,6 @@ ZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KA</string>
 											</object>
 										</object>
 										<string key="NSFrame">{{10, 33}, {438, 218}}</string>
-										<reference key="NSSuperview" ref="448510093"/>
 									</object>
 									<string key="NSLabel">Windows</string>
 									<reference key="NSColor" ref="57160303"/>
@@ -1068,14 +1068,14 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 									<reference key="NSTabView" ref="448510093"/>
 								</object>
 							</object>
-							<reference key="NSSelectedTabViewItem" ref="10973343"/>
+							<reference key="NSSelectedTabViewItem" ref="287591690"/>
 							<reference key="NSFont" ref="463863101"/>
 							<int key="NSTvFlags">0</int>
 							<bool key="NSAllowTruncatedLabels">YES</bool>
 							<bool key="NSDrawsBackground">YES</bool>
 							<object class="NSMutableArray" key="NSSubviews">
 								<bool key="EncodedWithXMLCoder">YES</bool>
-								<reference ref="184765684"/>
+								<reference ref="596750588"/>
 							</object>
 						</object>
 					</object>
@@ -3363,9 +3363,9 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
 					<string>{{271, 666}, {301, 153}}</string>
-					<string>{{460, 353}, {484, 280}}</string>
+					<string>{{313, 353}, {484, 280}}</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>{{460, 353}, {484, 280}}</string>
+					<string>{{313, 353}, {484, 280}}</string>
 					<reference ref="9"/>
 					<string>{{184, 290}, {481, 345}}</string>
 					<object class="NSDictionary">
diff --git a/hw/xquartz/bundle/English.lproj/main.nib/keyedobjects.nib b/hw/xquartz/bundle/English.lproj/main.nib/keyedobjects.nib
index 400ee5c..91a7c5a 100644
Binary files a/hw/xquartz/bundle/English.lproj/main.nib/keyedobjects.nib and b/hw/xquartz/bundle/English.lproj/main.nib/keyedobjects.nib differ
commit f06a7ae344608edd6bdb45ab2afecf18cf257f27
Author: Jeremy Huddleston <jeremy at tifa.local>
Date:   Fri Mar 21 19:11:59 2008 -0700

    Xquartz: Added separate preference tab for quartz-wm settings
    Added FFM and "Focus on new window" options
    (cherry picked from commit 6841d078b7cb0b0db3db948d26b4d5ec7747deb8)

diff --git a/hw/xquartz/X11Application.h b/hw/xquartz/X11Application.h
index 86da67f..ea9a6b7 100644
--- a/hw/xquartz/X11Application.h
+++ b/hw/xquartz/X11Application.h
@@ -98,6 +98,8 @@ extern int quartzHasRoot, quartzEnableRootless;
 #define PREFS_XP_OPTIONS            "xp_options"
 #define PREFS_ENABLE_STEREO         "enable_stereo"
 #define PREFS_LOGIN_SHELL           "login_shell"
-#define PREFS_QUARTZ_WM_CLICK_THROUGH "wm_click_through"
+#define PREFS_CLICK_THROUGH         "wm_click_through"
+#define PREFS_FFM                   "wm_ffm"
+#define PREFS_FOCUS_ON_NEW_WINDOW   "wm_focus_on_new_window"
 
 #endif /* X11APPLICATION_H */
diff --git a/hw/xquartz/X11Controller.h b/hw/xquartz/X11Controller.h
index 64d5cd1..8d6a38f 100644
--- a/hw/xquartz/X11Controller.h
+++ b/hw/xquartz/X11Controller.h
@@ -45,6 +45,8 @@
     IBOutlet NSButton *enable_keyequivs;
     IBOutlet NSButton *sync_keymap;
     IBOutlet NSButton *click_through;
+    IBOutlet NSButton *focus_follows_mouse;
+    IBOutlet NSButton *focus_on_new_window;
     IBOutlet NSButton *enable_auth;
     IBOutlet NSButton *enable_tcp;
     IBOutlet NSPopUpButton *depth;
diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m
index 5111eaf..3880b3f 100644
--- a/hw/xquartz/X11Controller.m
+++ b/hw/xquartz/X11Controller.m
@@ -609,24 +609,28 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
 
 - (IBAction)prefs_changed:sender
 {
-  darwinFakeButtons = [fake_buttons intValue];
-  quartzUseSysBeep = [use_sysbeep intValue];
-  X11EnableKeyEquivalents = [enable_keyequivs intValue];
-  darwinSyncKeymap = [sync_keymap intValue];
-
-  /* after adding prefs here, also add to [X11Application read_defaults]
+    darwinFakeButtons = [fake_buttons intValue];
+    quartzUseSysBeep = [use_sysbeep intValue];
+    X11EnableKeyEquivalents = [enable_keyequivs intValue];
+    darwinSyncKeymap = [sync_keymap intValue];
+    
+    /* after adding prefs here, also add to [X11Application read_defaults]
      and below */
 	
-  [NSApp prefs_set_boolean:@PREFS_FAKEBUTTONS value:darwinFakeButtons];
-  [NSApp prefs_set_boolean:@PREFS_SYSBEEP value:quartzUseSysBeep];
-  [NSApp prefs_set_boolean:@PREFS_KEYEQUIVS value:X11EnableKeyEquivalents];
-  [NSApp prefs_set_boolean:@PREFS_SYNC_KEYMAP value:darwinSyncKeymap];
-  [NSApp prefs_set_boolean:@PREFS_QUARTZ_WM_CLICK_THROUGH value:[click_through intValue]];
-  [NSApp prefs_set_boolean:@PREFS_NO_AUTH value:![enable_auth intValue]];
-  [NSApp prefs_set_boolean:@PREFS_NO_TCP value:![enable_tcp intValue]];
-  [NSApp prefs_set_integer:@PREFS_DEPTH value:[depth selectedTag]];
+    [NSApp prefs_set_boolean:@PREFS_FAKEBUTTONS value:darwinFakeButtons];
+    [NSApp prefs_set_boolean:@PREFS_SYSBEEP value:quartzUseSysBeep];
+    [NSApp prefs_set_boolean:@PREFS_KEYEQUIVS value:X11EnableKeyEquivalents];
+    [NSApp prefs_set_boolean:@PREFS_SYNC_KEYMAP value:darwinSyncKeymap];
+    [NSApp prefs_set_boolean:@PREFS_CLICK_THROUGH value:[click_through intValue]];
+    [NSApp prefs_set_boolean:@PREFS_FFM value:[focus_follows_mouse intValue]];
+    [NSApp prefs_set_boolean:@PREFS_FOCUS_ON_NEW_WINDOW value:[focus_on_new_window intValue]];
+    [NSApp prefs_set_boolean:@PREFS_NO_AUTH value:![enable_auth intValue]];
+    [NSApp prefs_set_boolean:@PREFS_NO_TCP value:![enable_tcp intValue]];
+    [NSApp prefs_set_integer:@PREFS_DEPTH value:[depth selectedTag]];
+    
+    system("killall -HUP quartz-wm");
 	
-  [NSApp prefs_synchronize];
+    [NSApp prefs_synchronize];
 }
 
 - (IBAction) prefs_show:sender
@@ -636,8 +640,10 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
   [enable_keyequivs setIntValue:X11EnableKeyEquivalents];
   [sync_keymap setIntValue:darwinSyncKeymap];
   [sync_keymap setEnabled:darwinKeymapFile == NULL];
-  [click_through setIntValue:[NSApp prefs_get_boolean:@PREFS_QUARTZ_WM_CLICK_THROUGH default:NO]];
-	
+  [click_through setIntValue:[NSApp prefs_get_boolean:@PREFS_CLICK_THROUGH default:NO]];
+  [focus_follows_mouse setIntValue:[NSApp prefs_get_boolean:@PREFS_FFM default:NO]];
+  [focus_on_new_window setIntValue:[NSApp prefs_get_boolean:@PREFS_FOCUS_ON_NEW_WINDOW default:YES]];
+
   [enable_auth setIntValue:![NSApp prefs_get_boolean:@PREFS_NO_AUTH default:NO]];
   [enable_tcp setIntValue:![NSApp prefs_get_boolean:@PREFS_NO_TCP default:NO]];
   [depth selectItemAtIndex:[depth indexOfItemWithTag:[NSApp prefs_get_integer:@PREFS_DEPTH default:-1]]];
diff --git a/hw/xquartz/bundle/English.lproj/main.nib/designable.nib b/hw/xquartz/bundle/English.lproj/main.nib/designable.nib
index ea3a0da..adc0340 100644
--- a/hw/xquartz/bundle/English.lproj/main.nib/designable.nib
+++ b/hw/xquartz/bundle/English.lproj/main.nib/designable.nib
@@ -8,8 +8,6 @@
 		<string key="IBDocument.HIToolboxVersion">352.00</string>
 		<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
 			<bool key="EncodedWithXMLCoder">YES</bool>
-			<integer value="57"/>
-			<integer value="285"/>
 		</object>
 		<object class="NSArray" key="IBDocument.PluginDependencies">
 			<bool key="EncodedWithXMLCoder">YES</bool>
@@ -448,7 +446,7 @@
 			<object class="NSWindowTemplate" id="124913468">
 				<int key="NSWindowStyleMask">3</int>
 				<int key="NSWindowBacking">2</int>
-				<string key="NSWindowRect">{{319, 294}, {481, 345}}</string>
+				<string key="NSWindowRect">{{266, 392}, {484, 280}}</string>
 				<int key="NSWTFlags">1350041600</int>
 				<string key="NSWindowTitle">X11 Preferences</string>
 				<string key="NSWindowClass">NSPanel</string>
@@ -465,7 +463,7 @@
 						<object class="NSTabView" id="448510093">
 							<reference key="NSNextResponder" ref="941366957"/>
 							<int key="NSvFlags">256</int>
-							<string key="NSFrame">{{10, 10}, {458, 325}}</string>
+							<string key="NSFrame">{{13, 10}, {458, 264}}</string>
 							<reference key="NSSuperview" ref="941366957"/>
 							<object class="NSMutableArray" key="NSTabViewItems">
 								<bool key="EncodedWithXMLCoder">YES</bool>
@@ -474,14 +472,14 @@
 										<characters key="NS.bytes">1</characters>
 									</object>
 									<object class="NSView" key="NSView" id="596750588">
-										<reference key="NSNextResponder" ref="448510093"/>
+										<nil key="NSNextResponder"/>
 										<int key="NSvFlags">256</int>
 										<object class="NSMutableArray" key="NSSubviews">
 											<bool key="EncodedWithXMLCoder">YES</bool>
 											<object class="NSButton" id="119157981">
 												<reference key="NSNextResponder" ref="596750588"/>
 												<int key="NSvFlags">256</int>
-												<string key="NSFrame">{{18, 243}, {402, 18}}</string>
+												<string key="NSFrame">{{18, 182}, {402, 18}}</string>
 												<reference key="NSSuperview" ref="596750588"/>
 												<bool key="NSEnabled">YES</bool>
 												<object class="NSButtonCell" key="NSCell" id="990762273">
@@ -508,7 +506,7 @@
 											<object class="NSTextField" id="443008216">
 												<reference key="NSNextResponder" ref="596750588"/>
 												<int key="NSvFlags">256</int>
-												<string key="NSFrame">{{36, 93}, {385, 31}}</string>
+												<string key="NSFrame">{{36, 32}, {385, 31}}</string>
 												<reference key="NSSuperview" ref="596750588"/>
 												<bool key="NSEnabled">YES</bool>
 												<object class="NSTextFieldCell" key="NSCell" id="391919450">
@@ -544,7 +542,7 @@
 											<object class="NSTextField" id="282885445">
 												<reference key="NSNextResponder" ref="596750588"/>
 												<int key="NSvFlags">256</int>
-												<string key="NSFrame">{{36, 208}, {385, 29}}</string>
+												<string key="NSFrame">{{36, 147}, {385, 29}}</string>
 												<reference key="NSSuperview" ref="596750588"/>
 												<bool key="NSEnabled">YES</bool>
 												<object class="NSTextFieldCell" key="NSCell" id="649334366">
@@ -561,7 +559,7 @@ ZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KA</string>
 											<object class="NSButton" id="842100515">
 												<reference key="NSNextResponder" ref="596750588"/>
 												<int key="NSvFlags">256</int>
-												<string key="NSFrame">{{18, 130}, {402, 18}}</string>
+												<string key="NSFrame">{{18, 69}, {402, 18}}</string>
 												<reference key="NSSuperview" ref="596750588"/>
 												<bool key="NSEnabled">YES</bool>
 												<object class="NSButtonCell" key="NSCell" id="940564599">
@@ -582,7 +580,7 @@ ZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KA</string>
 											<object class="NSTextField" id="31160162">
 												<reference key="NSNextResponder" ref="596750588"/>
 												<int key="NSvFlags">256</int>
-												<string key="NSFrame">{{36, 159}, {385, 14}}</string>
+												<string key="NSFrame">{{36, 98}, {385, 14}}</string>
 												<reference key="NSSuperview" ref="596750588"/>
 												<bool key="NSEnabled">YES</bool>
 												<object class="NSTextFieldCell" key="NSCell" id="666057093">
@@ -598,7 +596,7 @@ ZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KA</string>
 											<object class="NSButton" id="179949713">
 												<reference key="NSNextResponder" ref="596750588"/>
 												<int key="NSvFlags">256</int>
-												<string key="NSFrame">{{18, 179}, {402, 18}}</string>
+												<string key="NSFrame">{{18, 118}, {402, 18}}</string>
 												<reference key="NSSuperview" ref="596750588"/>
 												<bool key="NSEnabled">YES</bool>
 												<object class="NSButtonCell" key="NSCell" id="967619578">
@@ -616,46 +614,8 @@ ZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KA</string>
 													<int key="NSPeriodicInterval">25</int>
 												</object>
 											</object>
-											<object class="NSButton" id="915448994">
-												<reference key="NSNextResponder" ref="596750588"/>
-												<int key="NSvFlags">256</int>
-												<string key="NSFrame">{{18, 69}, {402, 18}}</string>
-												<reference key="NSSuperview" ref="596750588"/>
-												<bool key="NSEnabled">YES</bool>
-												<object class="NSButtonCell" key="NSCell" id="117056849">
-													<int key="NSCellFlags">67239424</int>
-													<int key="NSCellFlags2">0</int>
-													<string key="NSContents">Click-through Inactive Windows</string>
-													<reference key="NSSupport" ref="463863101"/>
-													<reference key="NSControlView" ref="915448994"/>
-													<int key="NSButtonFlags">1211912703</int>
-													<int key="NSButtonFlags2">2</int>
-													<reference key="NSAlternateImage" ref="391434389"/>
-													<string key="NSAlternateContents"/>
-													<string key="NSKeyEquivalent"/>
-													<int key="NSPeriodicDelay">200</int>
-													<int key="NSPeriodicInterval">25</int>
-												</object>
-											</object>
-											<object class="NSTextField" id="707276799">
-												<reference key="NSNextResponder" ref="596750588"/>
-												<int key="NSvFlags">256</int>
-												<string key="NSFrame">{{33, 32}, {385, 31}}</string>
-												<reference key="NSSuperview" ref="596750588"/>
-												<bool key="NSEnabled">YES</bool>
-												<object class="NSTextFieldCell" key="NSCell" id="318286890">
-													<int key="NSCellFlags">67239424</int>
-													<int key="NSCellFlags2">4194304</int>
-													<string key="NSContents">When enabled, clicking on an inactive window will cause that mouse click to pass through to that window in addition to activating it.</string>
-													<reference key="NSSupport" ref="26"/>
-													<reference key="NSControlView" ref="707276799"/>
-													<reference key="NSBackgroundColor" ref="57160303"/>
-													<reference key="NSTextColor" ref="930815747"/>
-												</object>
-											</object>
 										</object>
-										<string key="NSFrame">{{10, 33}, {438, 279}}</string>
-										<reference key="NSSuperview" ref="448510093"/>
+										<string key="NSFrame">{{10, 33}, {438, 218}}</string>
 									</object>
 									<string key="NSLabel">Input</string>
 									<reference key="NSColor" ref="57160303"/>
@@ -673,7 +633,7 @@ ZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KA</string>
 											<object class="NSButton" id="418227126">
 												<reference key="NSNextResponder" ref="515308735"/>
 												<int key="NSvFlags">256</int>
-												<string key="NSFrame">{{18, 116}, {402, 18}}</string>
+												<string key="NSFrame">{{18, 55}, {402, 18}}</string>
 												<reference key="NSSuperview" ref="515308735"/>
 												<bool key="NSEnabled">YES</bool>
 												<object class="NSButtonCell" key="NSCell" id="1016069354">
@@ -694,7 +654,7 @@ ZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KA</string>
 											<object class="NSTextField" id="1039016593">
 												<reference key="NSNextResponder" ref="515308735"/>
 												<int key="NSvFlags">256</int>
-												<string key="NSFrame">{{36, 82}, {385, 28}}</string>
+												<string key="NSFrame">{{36, 21}, {385, 28}}</string>
 												<reference key="NSSuperview" ref="515308735"/>
 												<bool key="NSEnabled">YES</bool>
 												<object class="NSTextFieldCell" key="NSCell" id="624655599">
@@ -710,7 +670,7 @@ ZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KA</string>
 											<object class="NSPopUpButton" id="709074847">
 												<reference key="NSNextResponder" ref="515308735"/>
 												<int key="NSvFlags">256</int>
-												<string key="NSFrame">{{74, 235}, {128, 26}}</string>
+												<string key="NSFrame">{{74, 174}, {128, 26}}</string>
 												<reference key="NSSuperview" ref="515308735"/>
 												<bool key="NSEnabled">YES</bool>
 												<object class="NSPopUpButtonCell" key="NSCell" id="633115429">
@@ -801,7 +761,7 @@ ZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KA</string>
 											<object class="NSTextField" id="201731424">
 												<reference key="NSNextResponder" ref="515308735"/>
 												<int key="NSvFlags">256</int>
-												<string key="NSFrame">{{17, 238}, {55, 20}}</string>
+												<string key="NSFrame">{{17, 177}, {55, 20}}</string>
 												<reference key="NSSuperview" ref="515308735"/>
 												<bool key="NSEnabled">YES</bool>
 												<object class="NSTextFieldCell" key="NSCell" id="930265681">
@@ -817,7 +777,7 @@ ZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KA</string>
 											<object class="NSTextField" id="86150604">
 												<reference key="NSNextResponder" ref="515308735"/>
 												<int key="NSvFlags">256</int>
-												<string key="NSFrame">{{36, 216}, {392, 14}}</string>
+												<string key="NSFrame">{{36, 155}, {392, 14}}</string>
 												<reference key="NSSuperview" ref="515308735"/>
 												<bool key="NSEnabled">YES</bool>
 												<object class="NSTextFieldCell" key="NSCell" id="311969422">
@@ -833,7 +793,7 @@ ZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KA</string>
 											<object class="NSButton" id="477203622">
 												<reference key="NSNextResponder" ref="515308735"/>
 												<int key="NSvFlags">256</int>
-												<string key="NSFrame">{{18, 182}, {409, 23}}</string>
+												<string key="NSFrame">{{18, 121}, {409, 23}}</string>
 												<reference key="NSSuperview" ref="515308735"/>
 												<bool key="NSEnabled">YES</bool>
 												<object class="NSButtonCell" key="NSCell" id="631531164">
@@ -854,7 +814,7 @@ ZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KA</string>
 											<object class="NSTextField" id="298603383">
 												<reference key="NSNextResponder" ref="515308735"/>
 												<int key="NSvFlags">256</int>
-												<string key="NSFrame">{{36, 145}, {385, 31}}</string>
+												<string key="NSFrame">{{36, 84}, {385, 31}}</string>
 												<reference key="NSSuperview" ref="515308735"/>
 												<bool key="NSEnabled">YES</bool>
 												<object class="NSTextFieldCell" key="NSCell" id="761107402">
@@ -868,12 +828,140 @@ ZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KA</string>
 												</object>
 											</object>
 										</object>
-										<string key="NSFrame">{{10, 33}, {438, 279}}</string>
+										<string key="NSFrame">{{10, 33}, {438, 218}}</string>
 									</object>
 									<string key="NSLabel">Output</string>
 									<reference key="NSColor" ref="57160303"/>
 									<reference key="NSTabView" ref="448510093"/>
 								</object>
+								<object class="NSTabViewItem" id="10973343">
+									<object class="NSMutableString" key="NSIdentifier">
+										<characters key="NS.bytes">2</characters>
+									</object>
+									<object class="NSView" key="NSView" id="184765684">
+										<reference key="NSNextResponder" ref="448510093"/>
+										<int key="NSvFlags">256</int>
+										<object class="NSMutableArray" key="NSSubviews">
+											<bool key="EncodedWithXMLCoder">YES</bool>
+											<object class="NSButton" id="657659108">
+												<reference key="NSNextResponder" ref="184765684"/>
+												<int key="NSvFlags">256</int>
+												<string key="NSFrame">{{15, 184}, {402, 18}}</string>
+												<reference key="NSSuperview" ref="184765684"/>
+												<bool key="NSEnabled">YES</bool>
+												<object class="NSButtonCell" key="NSCell" id="259618205">
+													<int key="NSCellFlags">67239424</int>
+													<int key="NSCellFlags2">0</int>
+													<string key="NSContents">Click-through Inactive Windows</string>
+													<reference key="NSSupport" ref="463863101"/>
+													<reference key="NSControlView" ref="657659108"/>
+													<int key="NSButtonFlags">1211912703</int>
+													<int key="NSButtonFlags2">2</int>
+													<reference key="NSAlternateImage" ref="391434389"/>
+													<string key="NSAlternateContents"/>
+													<string key="NSKeyEquivalent"/>
+													<int key="NSPeriodicDelay">200</int>
+													<int key="NSPeriodicInterval">25</int>
+												</object>
+											</object>
+											<object class="NSTextField" id="290578835">
+												<reference key="NSNextResponder" ref="184765684"/>
+												<int key="NSvFlags">256</int>
+												<string key="NSFrame">{{23, 147}, {385, 31}}</string>
+												<reference key="NSSuperview" ref="184765684"/>
+												<bool key="NSEnabled">YES</bool>
+												<object class="NSTextFieldCell" key="NSCell" id="399127858">
+													<int key="NSCellFlags">67239424</int>
+													<int key="NSCellFlags2">4194304</int>
+													<string key="NSContents">When enabled, clicking on an inactive window will cause that mouse click to pass through to that window in addition to activating it.</string>
+													<reference key="NSSupport" ref="26"/>
+													<reference key="NSControlView" ref="290578835"/>
+													<reference key="NSBackgroundColor" ref="57160303"/>
+													<reference key="NSTextColor" ref="930815747"/>
+												</object>
+											</object>
+											<object class="NSButton" id="992839333">
+												<reference key="NSNextResponder" ref="184765684"/>
+												<int key="NSvFlags">256</int>
+												<string key="NSFrame">{{15, 123}, {402, 18}}</string>
+												<reference key="NSSuperview" ref="184765684"/>
+												<bool key="NSEnabled">YES</bool>
+												<object class="NSButtonCell" key="NSCell" id="959555182">
+													<int key="NSCellFlags">67239424</int>
+													<int key="NSCellFlags2">0</int>
+													<string key="NSContents">Focus Follows Mouse</string>
+													<reference key="NSSupport" ref="463863101"/>
+													<reference key="NSControlView" ref="992839333"/>
+													<int key="NSButtonFlags">1211912703</int>
+													<int key="NSButtonFlags2">2</int>
+													<reference key="NSAlternateImage" ref="391434389"/>
+													<string key="NSAlternateContents"/>
+													<string key="NSKeyEquivalent"/>
+													<int key="NSPeriodicDelay">200</int>
+													<int key="NSPeriodicInterval">25</int>
+												</object>
+											</object>
+											<object class="NSTextField" id="138261120">
+												<reference key="NSNextResponder" ref="184765684"/>
+												<int key="NSvFlags">256</int>
+												<string key="NSFrame">{{23, 100}, {385, 17}}</string>
+												<reference key="NSSuperview" ref="184765684"/>
+												<bool key="NSEnabled">YES</bool>
+												<object class="NSTextFieldCell" key="NSCell" id="183409141">
+													<int key="NSCellFlags">67239424</int>
+													<int key="NSCellFlags2">4194304</int>
+													<string key="NSContents">X11 window focus follows the cursor</string>
+													<reference key="NSSupport" ref="26"/>
+													<reference key="NSControlView" ref="138261120"/>
+													<reference key="NSBackgroundColor" ref="57160303"/>
+													<reference key="NSTextColor" ref="930815747"/>
+												</object>
+											</object>
+											<object class="NSButton" id="128352289">
+												<reference key="NSNextResponder" ref="184765684"/>
+												<int key="NSvFlags">256</int>
+												<string key="NSFrame">{{15, 79}, {402, 18}}</string>
+												<reference key="NSSuperview" ref="184765684"/>
+												<bool key="NSEnabled">YES</bool>
+												<object class="NSButtonCell" key="NSCell" id="556463187">
+													<int key="NSCellFlags">67239424</int>
+													<int key="NSCellFlags2">0</int>
+													<string key="NSContents">Focus On New Windows</string>
+													<reference key="NSSupport" ref="463863101"/>
+													<reference key="NSControlView" ref="128352289"/>
+													<int key="NSButtonFlags">1211912703</int>
+													<int key="NSButtonFlags2">2</int>
+													<reference key="NSAlternateImage" ref="391434389"/>
+													<string key="NSAlternateContents"/>
+													<string key="NSKeyEquivalent"/>
+													<int key="NSPeriodicDelay">200</int>
+													<int key="NSPeriodicInterval">25</int>
+												</object>
+											</object>
+											<object class="NSTextField" id="57161931">
+												<reference key="NSNextResponder" ref="184765684"/>
+												<int key="NSvFlags">256</int>
+												<string key="NSFrame">{{23, 45}, {385, 28}}</string>
+												<reference key="NSSuperview" ref="184765684"/>
+												<bool key="NSEnabled">YES</bool>
+												<object class="NSTextFieldCell" key="NSCell" id="989804990">
+													<int key="NSCellFlags">67239424</int>
+													<int key="NSCellFlags2">4194304</int>
+													<string key="NSContents">When enabled, creation of a new X11 window will cause X11.app to move to the foreground (instead of Finder.app, Terminal.app, etc.</string>
+													<reference key="NSSupport" ref="26"/>
+													<reference key="NSControlView" ref="57161931"/>
+													<reference key="NSBackgroundColor" ref="57160303"/>
+													<reference key="NSTextColor" ref="930815747"/>
+												</object>
+											</object>
+										</object>
+										<string key="NSFrame">{{10, 33}, {438, 218}}</string>
+										<reference key="NSSuperview" ref="448510093"/>
+									</object>
+									<string key="NSLabel">Windows</string>
+									<reference key="NSColor" ref="57160303"/>
+									<reference key="NSTabView" ref="448510093"/>
+								</object>
 								<object class="NSTabViewItem" id="348328898">
 									<object class="NSView" key="NSView" id="300811574">
 										<nil key="NSNextResponder"/>
@@ -883,7 +971,7 @@ ZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KA</string>
 											<object class="NSButton" id="989050925">
 												<reference key="NSNextResponder" ref="300811574"/>
 												<int key="NSvFlags">256</int>
-												<string key="NSFrame">{{18, 243}, {402, 18}}</string>
+												<string key="NSFrame">{{18, 182}, {402, 18}}</string>
 												<reference key="NSSuperview" ref="300811574"/>
 												<bool key="NSEnabled">YES</bool>
 												<object class="NSButtonCell" key="NSCell" id="189594322">
@@ -904,7 +992,7 @@ ZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KA</string>
 											<object class="NSButton" id="700826966">
 												<reference key="NSNextResponder" ref="300811574"/>
 												<int key="NSvFlags">256</int>
-												<string key="NSFrame">{{18, 166}, {402, 18}}</string>
+												<string key="NSFrame">{{18, 105}, {402, 18}}</string>
 												<reference key="NSSuperview" ref="300811574"/>
 												<bool key="NSEnabled">YES</bool>
 												<object class="NSButtonCell" key="NSCell" id="489340979">
@@ -925,7 +1013,7 @@ ZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KA</string>
 											<object class="NSTextField" id="168436707">
 												<reference key="NSNextResponder" ref="300811574"/>
 												<int key="NSvFlags">256</int>
-												<string key="NSFrame">{{36, 195}, {385, 42}}</string>
+												<string key="NSFrame">{{36, 134}, {385, 42}}</string>
 												<reference key="NSSuperview" ref="300811574"/>
 												<bool key="NSEnabled">YES</bool>
 												<object class="NSTextFieldCell" key="NSCell" id="53243865">
@@ -943,7 +1031,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 											<object class="NSTextField" id="363817195">
 												<reference key="NSNextResponder" ref="300811574"/>
 												<int key="NSvFlags">256</int>
-												<string key="NSFrame">{{36, 118}, {385, 42}}</string>
+												<string key="NSFrame">{{36, 57}, {385, 42}}</string>
 												<reference key="NSSuperview" ref="300811574"/>
 												<bool key="NSEnabled">YES</bool>
 												<object class="NSTextFieldCell" key="NSCell" id="390084685">
@@ -959,7 +1047,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 											<object class="NSTextField" id="223835729">
 												<reference key="NSNextResponder" ref="300811574"/>
 												<int key="NSvFlags">256</int>
-												<string key="NSFrame">{{20, 17}, {404, 14}}</string>
+												<string key="NSFrame">{{20, -44}, {404, 14}}</string>
 												<reference key="NSSuperview" ref="300811574"/>
 												<bool key="NSEnabled">YES</bool>
 												<object class="NSTextFieldCell" key="NSCell" id="283628678">
@@ -973,27 +1061,27 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 												</object>
 											</object>
 										</object>
-										<string key="NSFrame">{{10, 33}, {438, 279}}</string>
+										<string key="NSFrame">{{10, 33}, {438, 218}}</string>
 									</object>
 									<string key="NSLabel">Security</string>
 									<reference key="NSColor" ref="57160303"/>
 									<reference key="NSTabView" ref="448510093"/>
 								</object>
 							</object>
-							<reference key="NSSelectedTabViewItem" ref="287591690"/>
+							<reference key="NSSelectedTabViewItem" ref="10973343"/>
 							<reference key="NSFont" ref="463863101"/>
 							<int key="NSTvFlags">0</int>
 							<bool key="NSAllowTruncatedLabels">YES</bool>
 							<bool key="NSDrawsBackground">YES</bool>
 							<object class="NSMutableArray" key="NSSubviews">
 								<bool key="EncodedWithXMLCoder">YES</bool>
-								<reference ref="596750588"/>
+								<reference ref="184765684"/>
 							</object>
 						</object>
 					</object>
-					<string key="NSFrameSize">{481, 345}</string>
+					<string key="NSFrameSize">{484, 280}</string>
 				</object>
-				<string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
+				<string key="NSScreenRect">{{0, 0}, {1280, 938}}</string>
 				<string key="NSMinSize">{213, 129}</string>
 				<string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
 				<string key="NSFrameAutosaveName">x11_prefs</string>
@@ -1001,7 +1089,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 			<object class="NSWindowTemplate" id="604417141">
 				<int key="NSWindowStyleMask">11</int>
 				<int key="NSWindowBacking">2</int>
-				<string key="NSWindowRect">{{361, 362}, {454, 311}}</string>
+				<string key="NSWindowRect">{{302, 400}, {454, 311}}</string>
 				<int key="NSWTFlags">1350041600</int>
 				<string key="NSWindowTitle">X11 Application Menu</string>
 				<string key="NSWindowClass">NSPanel</string>
@@ -1011,7 +1099,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 				<string key="NSWindowContentMaxSize">{10000, 10000}</string>
 				<string key="NSWindowContentMinSize">{320, 240}</string>
 				<object class="NSView" key="NSWindowView" id="85544634">
-					<reference key="NSNextResponder"/>
+					<nil key="NSNextResponder"/>
 					<int key="NSvFlags">256</int>
 					<object class="NSMutableArray" key="NSSubviews">
 						<bool key="EncodedWithXMLCoder">YES</bool>
@@ -1353,9 +1441,8 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 						</object>
 					</object>
 					<string key="NSFrameSize">{454, 311}</string>
-					<reference key="NSSuperview"/>
 				</object>
-				<string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
+				<string key="NSScreenRect">{{0, 0}, {1280, 938}}</string>
 				<string key="NSMinSize">{320, 262}</string>
 				<string key="NSFrameAutosaveName">x11_apps</string>
 			</object>
@@ -1842,14 +1929,6 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 					<int key="connectionID">549</int>
 				</object>
 				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">prefs_changed:</string>
-						<reference key="source" ref="485884620"/>
-						<reference key="destination" ref="915448994"/>
-					</object>
-					<int key="connectionID">300300</int>
-				</object>
-				<object class="IBConnectionRecord">
 					<object class="IBOutletConnection" key="connection">
 						<string key="label">window_separator</string>
 						<reference key="source" ref="485884620"/>
@@ -1859,14 +1938,6 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBOutletConnection" key="connection">
-						<string key="label">click_through</string>
-						<reference key="source" ref="485884620"/>
-						<reference key="destination" ref="915448994"/>
-					</object>
-					<int key="connectionID">300332</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
 						<string key="label">menu</string>
 						<reference key="source" ref="815810918"/>
 						<reference key="destination" ref="524015605"/>
@@ -1881,6 +1952,54 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 					</object>
 					<int key="connectionID">300336</int>
 				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">prefs_changed:</string>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="657659108"/>
+					</object>
+					<int key="connectionID">300389</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">prefs_changed:</string>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="992839333"/>
+					</object>
+					<int key="connectionID">300390</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">prefs_changed:</string>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="128352289"/>
+					</object>
+					<int key="connectionID">300391</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBOutletConnection" key="connection">
+						<string key="label">click_through</string>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="657659108"/>
+					</object>
+					<int key="connectionID">300392</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBOutletConnection" key="connection">
+						<string key="label">focus_follows_mouse</string>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="992839333"/>
+					</object>
+					<int key="connectionID">300393</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBOutletConnection" key="connection">
+						<string key="label">focus_on_new_window</string>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="128352289"/>
+					</object>
+					<int key="connectionID">300394</int>
+				</object>
 			</object>
 			<object class="IBMutableOrderedSet" key="objectRecords">
 				<object class="NSArray" key="orderedObjects">
@@ -2239,6 +2358,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 							<reference ref="287591690"/>
 							<reference ref="960678392"/>
 							<reference ref="348328898"/>
+							<reference ref="10973343"/>
 						</object>
 						<reference key="parent" ref="941366957"/>
 					</object>
@@ -2262,8 +2382,6 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 							<reference ref="842100515"/>
 							<reference ref="31160162"/>
 							<reference ref="179949713"/>
-							<reference ref="915448994"/>
-							<reference ref="707276799"/>
 						</object>
 						<reference key="parent" ref="287591690"/>
 					</object>
@@ -2671,34 +2789,6 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 						<reference key="parent" ref="341113515"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">300296</int>
-						<reference key="object" ref="915448994"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="117056849"/>
-						</object>
-						<reference key="parent" ref="596750588"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">300297</int>
-						<reference key="object" ref="117056849"/>
-						<reference key="parent" ref="915448994"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">300298</int>
-						<reference key="object" ref="707276799"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="318286890"/>
-						</object>
-						<reference key="parent" ref="596750588"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">300299</int>
-						<reference key="object" ref="318286890"/>
-						<reference key="parent" ref="707276799"/>
-					</object>
-					<object class="IBObjectRecord">
 						<int key="objectID">295</int>
 						<reference key="object" ref="1063387772"/>
 						<object class="NSMutableArray" key="children">
@@ -2853,6 +2943,113 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 						<reference key="object" ref="444952046"/>
 						<reference key="parent" ref="96874957"/>
 					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">300337</int>
+						<reference key="object" ref="10973343"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="184765684"/>
+						</object>
+						<reference key="parent" ref="448510093"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">300338</int>
+						<reference key="object" ref="184765684"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="657659108"/>
+							<reference ref="290578835"/>
+							<reference ref="992839333"/>
+							<reference ref="138261120"/>
+							<reference ref="128352289"/>
+							<reference ref="57161931"/>
+						</object>
+						<reference key="parent" ref="10973343"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">300358</int>
+						<reference key="object" ref="290578835"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="399127858"/>
+						</object>
+						<reference key="parent" ref="184765684"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">300359</int>
+						<reference key="object" ref="657659108"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="259618205"/>
+						</object>
+						<reference key="parent" ref="184765684"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">300360</int>
+						<reference key="object" ref="259618205"/>
+						<reference key="parent" ref="657659108"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">300361</int>
+						<reference key="object" ref="399127858"/>
+						<reference key="parent" ref="290578835"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">300362</int>
+						<reference key="object" ref="992839333"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="959555182"/>
+						</object>
+						<reference key="parent" ref="184765684"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">300363</int>
+						<reference key="object" ref="959555182"/>
+						<reference key="parent" ref="992839333"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">300364</int>
+						<reference key="object" ref="138261120"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="183409141"/>
+						</object>
+						<reference key="parent" ref="184765684"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">300365</int>
+						<reference key="object" ref="183409141"/>
+						<reference key="parent" ref="138261120"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">300368</int>
+						<reference key="object" ref="128352289"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="556463187"/>
+						</object>
+						<reference key="parent" ref="184765684"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">300369</int>
+						<reference key="object" ref="556463187"/>
+						<reference key="parent" ref="128352289"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">300370</int>
+						<reference key="object" ref="57161931"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="989804990"/>
+						</object>
+						<reference key="parent" ref="184765684"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">300371</int>
+						<reference key="object" ref="989804990"/>
+						<reference key="parent" ref="57161931"/>
+					</object>
 				</object>
 			</object>
 			<object class="NSMutableDictionary" key="flattenedProperties">
@@ -2919,10 +3116,12 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 					<string>24.IBPluginDependency</string>
 					<string>24.ImportedFromIB2</string>
 					<string>24.editorWindowContentRectSynchronizationRect</string>
+					<string>244.IBEditorWindowLastContentRect</string>
 					<string>244.IBPluginDependency</string>
 					<string>244.IBWindowTemplateEditedContentRect</string>
 					<string>244.ImportedFromIB2</string>
 					<string>244.editorWindowContentRectSynchronizationRect</string>
+					<string>244.lastResizeAction</string>
 					<string>244.windowTemplate.hasMaxSize</string>
 					<string>244.windowTemplate.hasMinSize</string>
 					<string>244.windowTemplate.maxSize</string>
@@ -2971,12 +3170,24 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 					<string>299.IBPluginDependency</string>
 					<string>299.ImportedFromIB2</string>
 					<string>300295.IBShouldRemoveOnLegacySave</string>
-					<string>300296.IBPluginDependency</string>
-					<string>300296.ImportedFromIB2</string>
-					<string>300298.IBPluginDependency</string>
-					<string>300298.ImportedFromIB2</string>
 					<string>300330.IBPluginDependency</string>
 					<string>300330.ImportedFromIB2</string>
+					<string>300337.IBPluginDependency</string>
+					<string>300337.ImportedFromIB2</string>
+					<string>300338.IBPluginDependency</string>
+					<string>300338.ImportedFromIB2</string>
+					<string>300358.IBPluginDependency</string>
+					<string>300358.ImportedFromIB2</string>
+					<string>300359.IBPluginDependency</string>
+					<string>300359.ImportedFromIB2</string>
+					<string>300362.IBPluginDependency</string>
+					<string>300362.ImportedFromIB2</string>
+					<string>300364.IBPluginDependency</string>
+					<string>300364.ImportedFromIB2</string>
+					<string>300368.IBPluginDependency</string>
+					<string>300368.ImportedFromIB2</string>
+					<string>300370.IBPluginDependency</string>
+					<string>300370.ImportedFromIB2</string>
 					<string>305.IBPluginDependency</string>
 					<string>305.ImportedFromIB2</string>
 					<string>310.IBPluginDependency</string>
@@ -3152,10 +3363,24 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
 					<string>{{271, 666}, {301, 153}}</string>
+					<string>{{460, 353}, {484, 280}}</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>{{184, 290}, {481, 345}}</string>
+					<string>{{460, 353}, {484, 280}}</string>
 					<reference ref="9"/>
 					<string>{{184, 290}, {481, 345}}</string>
+					<object class="NSDictionary">
+						<bool key="EncodedWithXMLCoder">YES</bool>
+						<object class="NSMutableArray" key="dict.sortedKeys">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<string>IBResizeActionFinalFrame</string>
+							<string>IBResizeActionInitialFrame</string>
+						</object>
+						<object class="NSMutableArray" key="dict.values">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<string>{{182, 481}, {484, 280}}</string>
+							<string>{{182, 103}, {536, 658}}</string>
+						</object>
+					</object>
 					<reference ref="9"/>
 					<reference ref="9"/>
 					<string>{3.40282e+38, 3.40282e+38}</string>
@@ -3169,11 +3394,11 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 					<string>{{100, 746}, {155, 33}}</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<string>{{537, 545}, {454, 311}}</string>
+					<string>{{407, 545}, {454, 311}}</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
 					<reference ref="9"/>
-					<string>{{537, 545}, {454, 311}}</string>
+					<string>{{407, 545}, {454, 311}}</string>
 					<reference ref="9"/>
 					<string>{{433, 406}, {486, 327}}</string>
 					<object class="NSDictionary">
@@ -3320,6 +3545,18 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 					<reference ref="9"/>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+					<reference ref="9"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+					<reference ref="9"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+					<reference ref="9"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+					<reference ref="9"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+					<reference ref="9"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+					<reference ref="9"/>
 					<string>{{12, 633}, {218, 203}}</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
@@ -3356,7 +3593,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 				</object>
 			</object>
 			<nil key="sourceID"/>
-			<int key="maxID">300336</int>
+			<int key="maxID">300394</int>
 		</object>
 		<object class="IBClassDescriber" key="IBDocument.Classes">
 			<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -3378,6 +3615,17 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 				<object class="IBPartialClassDescription">
 					<string key="className">X11Controller</string>
 					<string key="superclassName">NSObject</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBUserSource</string>
+						<string key="minorKey"/>
+					</object>
+				</object>
+			</object>
+			<object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.1+">
+				<bool key="EncodedWithXMLCoder">YES</bool>
+				<object class="IBPartialClassDescription">
+					<string key="className">X11Controller</string>
+					<string key="superclassName">NSObject</string>
 					<object class="NSMutableDictionary" key="actions">
 						<bool key="EncodedWithXMLCoder">YES</bool>
 						<object class="NSMutableArray" key="dict.sortedKeys">
@@ -3439,6 +3687,8 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 							<string>enable_keyequivs</string>
 							<string>enable_tcp</string>
 							<string>fake_buttons</string>
+							<string>focus_follows_mouse</string>
+							<string>focus_on_new_window</string>
 							<string>prefs_panel</string>
 							<string>sync_keymap</string>
 							<string>toggle_fullscreen_item</string>
@@ -3460,6 +3710,8 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 							<string>NSButton</string>
 							<string>NSButton</string>
 							<string>NSButton</string>
+							<string>NSButton</string>
+							<string>NSButton</string>
 							<string>NSPanel</string>
 							<string>NSButton</string>
 							<string>NSMenuItem</string>
@@ -3469,8 +3721,8 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 						</object>
 					</object>
 					<object class="IBClassDescriptionSource" key="sourceIdentifier">
-						<string key="majorKey">IBUserSource</string>
-						<string key="minorKey"/>
+						<string key="majorKey">IBDocumentRelativeSource</string>
+						<string key="minorKey">../../X11Controller.h</string>
 					</object>
 				</object>
 			</object>
diff --git a/hw/xquartz/bundle/English.lproj/main.nib/keyedobjects.nib b/hw/xquartz/bundle/English.lproj/main.nib/keyedobjects.nib
index f60dcba..400ee5c 100644
Binary files a/hw/xquartz/bundle/English.lproj/main.nib/keyedobjects.nib and b/hw/xquartz/bundle/English.lproj/main.nib/keyedobjects.nib differ
diff --git a/hw/xquartz/quartzCommon.h b/hw/xquartz/quartzCommon.h
index 6379f92..40c72b3 100644
--- a/hw/xquartz/quartzCommon.h
+++ b/hw/xquartz/quartzCommon.h
@@ -67,6 +67,7 @@ extern int              quartzEventWriteFD;
 // User preferences used by Quartz modes
 extern int              quartzRootless;
 extern int              quartzUseSysBeep;
+extern int              focusOnNewWindow;
 extern int              quartzUseAGL;
 extern int              quartzEnableKeyEquivalents;
 
@@ -90,17 +91,4 @@ int  QuartzFSUseQDCursor(int depth);
 void QuartzBlockHandler(pointer blockData, OSTimePtr pTimeout, pointer pReadmask);
 void QuartzWakeupHandler(pointer blockData, int result, pointer pReadmask);
 
-// Messages that can be sent to the main thread.
-enum {
-    kQuartzServerHidden,
-    kQuartzServerStarted,
-    kQuartzServerDied,
-    kQuartzCursorUpdate,
-    kQuartzPostEvent,
-    kQuartzSetWindowMenu,
-    kQuartzSetWindowMenuCheck,
-    kQuartzSetFrontProcess,
-    kQuartzSetCanQuit
-};
-
 #endif  /* _QUARTZCOMMON_H */
diff --git a/hw/xquartz/quartzForeground.c b/hw/xquartz/quartzForeground.c
index 0e724de..80a04a1 100644
--- a/hw/xquartz/quartzForeground.c
+++ b/hw/xquartz/quartzForeground.c
@@ -38,7 +38,7 @@ int QuartzMoveToForeground() {
    ProcessSerialNumber psn = { 0, kCurrentProcess };
    OSStatus returnCode = TransformProcessType(& psn, kProcessTransformToForegroundApplication);
    if( returnCode == 0) {
-       fprintf(stderr, "TransformProcessType: Success\n");
+       /* fprintf(stderr, "TransformProcessType: Success\n"); */
        SetFrontProcess(&psn);
    } else {
        fprintf(stderr, "TransformProcessType: Failure\n");
commit 6fc293182f26063288175ca1522c508617e2fb83
Author: Jeremy Huddleston <jeremy at tifa.local>
Date:   Fri Mar 21 18:07:38 2008 -0700

    XQuartz: Initial framework for dealing with spaces on OS-X
    (cherry picked from commit 9831324998f9d1f05ff944c58c5bf60dcae17355)

diff --git a/hw/xquartz/darwin.h b/hw/xquartz/darwin.h
index f516432..0d8e457 100644
--- a/hw/xquartz/darwin.h
+++ b/hw/xquartz/darwin.h
@@ -106,6 +106,7 @@ enum {
     kXDarwinBringAllToFront,  // bring all X windows to front
     kXDarwinToggleFullscreen, // Enable/Disable fullscreen mode
     kXDarwinSetRootless,      // Set rootless mode
+    kXDarwinSpaceChanged,     // Spaces changed
     /*
      * AppleWM events
      */
@@ -116,7 +117,7 @@ enum {
      */
     kXDarwinDisplayChanged,   // display configuration has changed
     kXDarwinWindowState,      // window visibility state has changed
-    kXDarwinWindowMoved       // window has moved on screen
+    kXDarwinWindowMoved,      // window has moved on screen
 };
 
 #define ENABLE_DEBUG_LOG 1
diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index 81c3325..46027fd 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -274,7 +274,7 @@ static void QuartzUpdateScreens(void)
     
 #ifndef FAKE_RANDR
     if(!QuartzRandRInit(pScreen))
-      FatalError("Failed to init RandR extension.\n");
+        FatalError("Failed to init RandR extension.\n");
 #endif
 
     DarwinAdjustScreenOrigins(&screenInfo);
@@ -372,6 +372,14 @@ static void QuartzSetRootClip(
     }
 }
 
+/* 
+ * QuartzSpaceChanged
+ *  Unmap offscreen windows, map onscreen windows
+ */
+static void QuartzSpaceChanged(uint32_t space_id) {
+    /* Do something special here, so we don't depend on quartz-wm for spaces to work... */
+    DEBUG_LOG("Space Changed (%u) ... do something interesting...\n", space_id);
+}
 
 /*
  * QuartzMessageServerThread
@@ -502,6 +510,10 @@ void QuartzProcessEvent(xEvent *xe) {
             RootlessOrderAllWindows();
             break;
 
+        case kXDarwinSpaceChanged:
+            DEBUG_LOG("kXDarwinSpaceChanged\n");
+            QuartzSpaceChanged(xe->u.clientMessage.u.l.longs0);
+            break;
         default:
             ErrorF("Unknown application defined event type %d.\n", xe->u.u.type);
     }
diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c
index db36403..4dc5846 100644
--- a/hw/xquartz/xpr/xprScreen.c
+++ b/hw/xquartz/xpr/xprScreen.c
@@ -63,6 +63,7 @@ static const char *xprOpenGLBundle = "glxCGL.bundle";
  */
 static void eventHandler(unsigned int type, const void *arg,
                          unsigned int arg_size, void *data) {
+    
     switch (type) {
         case XP_EVENT_DISPLAY_CHANGED:
             DEBUG_LOG("XP_EVENT_DISPLAY_CHANGED\n");
@@ -105,6 +106,13 @@ static void eventHandler(unsigned int type, const void *arg,
                 DRISurfaceNotify(*(xp_surface_id *) arg, kind);
             }
             break;
+        case  XP_EVENT_SPACE_CHANGED:
+            ErrorF("XP_EVENT_SPACE_CHANGED\n");
+            if(arg_size == sizeof(uint32_t)) {
+                uint32_t space_id = *(uint32_t *)arg;
+                QuartzMessageServerThread(kXDarwinSpaceChanged, 1, space_id);
+            }
+            break;
         default:
             ErrorF("Unknown XP_EVENT type (%d) in xprScreen:eventHandler\n", type);
     }
@@ -233,7 +241,8 @@ xprDisplayInit(void)
                      | XP_EVENT_WINDOW_STATE_CHANGED
                      | XP_EVENT_WINDOW_MOVED
                      | XP_EVENT_SURFACE_CHANGED
-                     | XP_EVENT_SURFACE_DESTROYED,
+                     | XP_EVENT_SURFACE_DESTROYED
+                     | XP_EVENT_SPACE_CHANGED,
                      eventHandler, NULL);
 
     AppleDRIExtensionInit();
commit f03202ad15457c98be7ca78cc59bac88cf5f1966
Author: Jeremy Huddleston <jeremy at tifa.local>
Date:   Mon Mar 17 23:57:41 2008 -0700

    Rootless: Removed safeAlphaXXXX() in favor of using fb/pixman

diff --git a/configure.ac b/configure.ac
index dc7b826..427a951 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2068,7 +2068,6 @@ miext/damage/Makefile
 miext/shadow/Makefile
 miext/cw/Makefile
 miext/rootless/Makefile
-miext/rootless/safeAlpha/Makefile
 miext/rootless/accel/Makefile
 os/Makefile
 randr/Makefile
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 65c7d0a..b843b74 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -318,12 +318,9 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
 }
 
 - (void) set_front_process:unused {
-    /* Hackery needed due to argv[0] hackery */
-    //    [self activateX:YES];
+    QuartzMessageServerThread(kXDarwinBringAllToFront, 0);
     ProcessSerialNumber psn = { 0, kCurrentProcess };
     SetFrontProcess(&psn);
-
-    QuartzMessageServerThread(kXDarwinBringAllToFront, 0);
 }
 
 - (void) set_can_quit:(NSNumber *)state {
diff --git a/hw/xquartz/xpr/Makefile.am b/hw/xquartz/xpr/Makefile.am
index ae1b192..b4d67c7 100644
--- a/hw/xquartz/xpr/Makefile.am
+++ b/hw/xquartz/xpr/Makefile.am
@@ -4,8 +4,7 @@ AM_CFLAGS =  $(XSERVER_CFLAGS) $(DIX_CFLAGS)
 AM_CPPFLAGS = \
 	-I$(srcdir) -I$(srcdir)/.. \
 	-I$(top_srcdir)/miext \
-	-I$(top_srcdir)/miext/rootless \
-	-I$(top_srcdir)/miext/rootless/safeAlpha
+	-I$(top_srcdir)/miext/rootless
 
 Xquartz_SOURCES = \
 	appledri.c \
@@ -41,7 +40,6 @@ Xquartz_LDADD = \
 	$(top_builddir)/record/librecord.la \
 	$(top_builddir)/XTrap/libxtrap.la \
 	$(top_builddir)/miext/rootless/librootless.la \
-	$(top_builddir)/miext/rootless/safeAlpha/libsafeAlpha.la \
 	$(top_builddir)/miext/rootless/accel/librlAccel.la \
 	$(DARWIN_LIBS) $(XSERVER_LIBS) $(XSERVER_SYS_LIBS) -lXplugin
 
diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c
index e4e1fda..db36403 100644
--- a/hw/xquartz/xpr/xprScreen.c
+++ b/hw/xquartz/xpr/xprScreen.c
@@ -37,7 +37,6 @@
 #include "pseudoramiX.h"
 #include "darwin.h"
 #include "rootless.h"
-#include "safeAlpha/safeAlpha.h"
 #include "dri.h"
 #include "globals.h"
 #include "Xplugin.h"
@@ -341,15 +340,6 @@ xprAddScreen(int index, ScreenPtr pScreen)
 static Bool
 xprSetupScreen(int index, ScreenPtr pScreen)
 {
-    // Add alpha protecting replacements for fb screen functions
-
-#ifdef RENDER
-    {
-        PictureScreenPtr ps = GetPictureScreen(pScreen);
-        ps->Composite = SafeAlphaComposite;
-    }
-#endif /* RENDER */
-
     // Initialize accelerated rootless drawing
     // Note that this must be done before DamageSetup().
     RootlessAccelInit(pScreen);
diff --git a/miext/rootless/Makefile.am b/miext/rootless/Makefile.am
index aa8528e..dc85170 100644
--- a/miext/rootless/Makefile.am
+++ b/miext/rootless/Makefile.am
@@ -1,7 +1,7 @@
 AM_CFLAGS = $(DIX_CFLAGS) $(XSERVER_CFLAGS)
 AM_CPPFLAGS = -I$(top_srcdir)/hw/xfree86/os-support
 
-SUBDIRS = safeAlpha accel
+SUBDIRS = accel
 
 noinst_LTLIBRARIES = librootless.la
 librootless_la_SOURCES = \
diff --git a/miext/rootless/safeAlpha/Makefile.am b/miext/rootless/safeAlpha/Makefile.am
deleted file mode 100644
index d264393..0000000
--- a/miext/rootless/safeAlpha/Makefile.am
+++ /dev/null
@@ -1,9 +0,0 @@
-AM_CFLAGS = $(DIX_CFLAGS) $(XSERVER_CFLAGS)
-AM_CPPFLAGS = -I$(srcdir)/.. -I$(top_srcdir)/hw/xfree86/os-support
-
-noinst_LTLIBRARIES = libsafeAlpha.la
-libsafeAlpha_la_SOURCES = \
-	safeAlphaPicture.c \
-	safeAlphaWindow.c
-
-EXTRA_DIST = safeAlpha.h
diff --git a/miext/rootless/safeAlpha/safeAlpha.h b/miext/rootless/safeAlpha/safeAlpha.h
deleted file mode 100644
index bd1ce32..0000000
--- a/miext/rootless/safeAlpha/safeAlpha.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Replacement functions to protect the alpha channel
- */
-/*
- * Copyright (c) 2002-2003 Torrey T. Lyons. 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
- * 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 _SAFEALPHA_H
-#define _SAFEALPHA_H
-
-#include "picturestr.h"
-
-void SafeAlphaPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what);
-
-#ifdef RENDER
-void
-SafeAlphaComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
-                   INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask,
-                   INT16 xDst, INT16 yDst, CARD16 width, CARD16 height);
-#endif /* RENDER */
-
-#endif /* _SAFEALPHA_H */
diff --git a/miext/rootless/safeAlpha/safeAlphaPicture.c b/miext/rootless/safeAlpha/safeAlphaPicture.c
deleted file mode 100644
index 8f66315..0000000
--- a/miext/rootless/safeAlpha/safeAlphaPicture.c
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Support for RENDER extension while protecting the alpha channel
- */
-/*
- * Copyright (c) 2002-2003 Torrey T. Lyons. All Rights Reserved.
- * Copyright (c) 2002 Apple Computer, Inc. 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
- * 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.
- */
-/* This file is largely based on fbcompose.c and fbpict.c, which contain
- * the following copyright:
- *
- * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
- */
-
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-#ifdef RENDER
-
-#include <stddef.h> /* For NULL */
-#include "fb.h"
-#include "picturestr.h"
-#include "mipict.h"
-#include "fbpict.h"
-#include "safeAlpha.h"
-#include "rootlessCommon.h"
-# define mod(a,b)	((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b))
-
-/* Optimized version of fbCompositeSolidMask_nx8x8888 */
-void
-SafeAlphaCompositeSolidMask_nx8x8888(
-    CARD8      op,
-    PicturePtr pSrc,
-    PicturePtr pMask,
-    PicturePtr pDst,
-    INT16      xSrc,
-    INT16      ySrc,
-    INT16      xMask,
-    INT16      yMask,
-    INT16      xDst,
-    INT16      yDst,
-    CARD16     width,
-    CARD16     height)
-{
-    CARD32	src, srca;
-    CARD32	*dstLine, *dst, d, dstMask;
-    CARD8	*maskLine, *mask, m;
-    FbStride	dstStride, maskStride;
-    CARD16	w;
-
-    fbComposeGetSolid(pSrc, src, pDst->format);
-
-    dstMask = FbFullMask (pDst->pDrawable->depth);
-    srca = src >> 24;
-    if (src == 0)
-	return;
-
-    fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1);
-    fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1);
-
-    if (dstMask == FB_ALLONES && pDst->pDrawable->bitsPerPixel == 32 &&
-        width * height > rootless_CompositePixels_threshold &&
-        SCREENREC(pDst->pDrawable->pScreen)->imp->CompositePixels)
-    {
-	void *srcp[2], *destp[2];
-	unsigned int dest_rowbytes[2];
-	unsigned int fn;
-
-	srcp[0] = &src; srcp[1] = &src;
-	/* null rowbytes pointer means use first value as a constant */
-	destp[0] = dstLine; destp[1] = dstLine;
-	dest_rowbytes[0] = dstStride * 4; dest_rowbytes[1] = dest_rowbytes[0];
-	fn = RL_COMPOSITE_FUNCTION(RL_COMPOSITE_OVER, RL_DEPTH_ARGB8888,
-                                   RL_DEPTH_A8, RL_DEPTH_ARGB8888);
-
-	if (SCREENREC(pDst->pDrawable->pScreen)->imp->CompositePixels(
-                width, height, fn, srcp, NULL,
-                maskLine, maskStride,
-                destp, dest_rowbytes) == Success)
-	{
-	    return;
-	}
-    }
-
-    while (height--)
-    {
-	dst = dstLine;
-	dstLine += dstStride;
-	mask = maskLine;
-	maskLine += maskStride;
-	w = width;
-
-	while (w--)
-	{
-	    m = *mask++;
-	    if (m == 0xff)
-	    {
-		if (srca == 0xff)
-		    *dst = src & dstMask;
-		else
-		    *dst = fbOver (src, *dst) & dstMask;
-	    }
-	    else if (m)
-	    {
-		d = fbIn (src, m);
-		*dst = fbOver (d, *dst) & dstMask;
-	    }
-	    dst++;
-	}
-    }
-}
-
-void
-SafeAlphaComposite (CARD8           op,
-                    PicturePtr      pSrc,
-                    PicturePtr      pMask,
-                    PicturePtr      pDst,
-                    INT16           xSrc,
-                    INT16           ySrc,
-                    INT16           xMask,
-                    INT16           yMask,
-                    INT16           xDst,
-                    INT16           yDst,
-                    CARD16          width,
-                    CARD16          height)
-{
-  if (!pSrc) {
-    ErrorF("SafeAlphaComposite: pSrc must not be null!\n");
-    return;
-  }
-
-  if (!pDst) {
-    ErrorF("SafeAlphaComposite: pDst must not be null!\n");
-    return;
-  }
-  
-  int oldDepth = pDst->pDrawable->depth;
-  int oldFormat = pDst->format;
-    
-  /*
-   * We can use the more optimized fbpict code, but it sets bits above
-   * the depth to zero. Temporarily adjust destination depth if needed.
-   */
-  if (pDst->pDrawable->type == DRAWABLE_WINDOW
-        && pDst->pDrawable->depth == 24
-      && pDst->pDrawable->bitsPerPixel == 32)
-    {
-      pDst->pDrawable->depth = 32;
-    }
-    
-  /* For rootless preserve the alpha in x8r8g8b8 which really is
-   * a8r8g8b8
-   */
-  if (oldFormat == PICT_x8r8g8b8)
-    {
-      pDst->format = PICT_a8r8g8b8;
-    }
-    
-  if (pSrc->pDrawable && pMask && pMask->pDrawable &&
-        !pSrc->transform && !pMask->transform &&
-        !pSrc->alphaMap && !pMask->alphaMap &&
-        !pMask->repeat && !pMask->componentAlpha && !pDst->alphaMap &&
-        pMask->format == PICT_a8 &&
-       pSrc->repeatType == RepeatNormal && 
-        pSrc->pDrawable->width == 1 &&
-        pSrc->pDrawable->height == 1 &&
-      (pDst->format == PICT_a8r8g8b8 ||
-         pDst->format == PICT_x8r8g8b8 ||
-         pDst->format == PICT_a8b8g8r8 ||
-       pDst->format == PICT_x8b8g8r8))
-    {
-      fbWalkCompositeRegion (op, pSrc, pMask, pDst,
-			     xSrc, ySrc, xMask, yMask, xDst, yDst,
-			     width, height,
-			     TRUE /* srcRepeat */,
-			     FALSE /* maskRepeat */,
-			     SafeAlphaCompositeSolidMask_nx8x8888);
-    }
-  else
-    {
-      fbComposite (op, pSrc, pMask, pDst,
-		   xSrc, ySrc, xMask, yMask, xDst, yDst, width, height);
-    }
-
-  pDst->pDrawable->depth = oldDepth;
-  pDst->format = oldFormat;
-}
-
-#endif /* RENDER */
diff --git a/miext/rootless/safeAlpha/safeAlphaWindow.c b/miext/rootless/safeAlpha/safeAlphaWindow.c
deleted file mode 100644
index 5226782..0000000
--- a/miext/rootless/safeAlpha/safeAlphaWindow.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Specialized window functions to protect the alpha channel
- */
-/*
- * Copyright (c) 2002-2003 Torrey T. Lyons. 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
- * 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.
- */
-/* Portions of this file are based on fbwindow.c, which contains the
- * following copyright:
- *
- * Copyright © 1998 Keith Packard
- */
-
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-#include "fb.h"
-#include "safeAlpha.h"
-#include "rootlessCommon.h"
-
-#ifdef PANORAMIX
-#include "panoramiX.h"
-#include "panoramiXsrv.h"
-#endif
-
-/*
- * SafeAlphaFillRegionTiled
- *  Fill using a tile while leaving the alpha channel untouched.
- *  Based on fbfillRegionTiled.
- */
-void
-SafeAlphaFillRegionTiled(
-    DrawablePtr pDrawable,
-    RegionPtr   pRegion,
-    PixmapPtr   pTile)
-{
-    FbBits      *dst;
-    FbStride    dstStride;
-    int         dstBpp;
-    int         dstXoff, dstYoff;
-    FbBits      *tile;
-    FbStride    tileStride;
-    int         tileBpp;
-    int         tileXoff, tileYoff; /* XXX assumed to be zero */
-    int         tileWidth, tileHeight;
-    int         n = REGION_NUM_RECTS(pRegion);
-    BoxPtr      pbox = REGION_RECTS(pRegion);
-    int         xRot = pDrawable->x;
-    int         yRot = pDrawable->y;
-    FbBits      planeMask;
-
-#ifdef PANORAMIX
-    if(!noPanoramiXExtension)
-    {
-        int index = pDrawable->pScreen->myNum;
-        if(&WindowTable[index]->drawable == pDrawable)
-        {
-            xRot -= panoramiXdataPtr[index].x;
-            yRot -= panoramiXdataPtr[index].y;
-        }
-    }
-#endif
-    fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
-    fbGetDrawable (&pTile->drawable, tile, tileStride, tileBpp,
-                   tileXoff, tileYoff);
-    tileWidth = pTile->drawable.width;
-    tileHeight = pTile->drawable.height;
-    xRot += dstXoff;
-    yRot += dstYoff;
-    planeMask = FB_ALLONES & ~RootlessAlphaMask(dstBpp);
-
-    while (n--)
-    {
-        fbTile (dst + (pbox->y1 + dstYoff) * dstStride,
-                dstStride,
-                (pbox->x1 + dstXoff) * dstBpp,
-                (pbox->x2 - pbox->x1) * dstBpp,
-                pbox->y2 - pbox->y1,
-                tile,
-                tileStride,
-                tileWidth * dstBpp,
-                tileHeight,
-                GXcopy,
-                planeMask,
-                dstBpp,
-                xRot * dstBpp,
-                yRot - pbox->y1);
-        pbox++;
-    }
-}
-
-
-/*
- * SafeAlphaPaintWindow
- *  Paint the window while filling in the alpha channel with all on.
- *  We can't use fbPaintWindow because it zeros the alpha channel.
- */
-void
-SafeAlphaPaintWindow(
-    WindowPtr pWin,
-    RegionPtr pRegion,
-    int what)
-{
-    switch (what) {
-      case PW_BACKGROUND:
-
-        switch (pWin->backgroundState) {
-            case None:
-                break;
-            case ParentRelative:
-                do {
-                    pWin = pWin->parent;
-                } while (pWin->backgroundState == ParentRelative);
-                (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
-                                                                 what);
-                break;
-            case BackgroundPixmap:
-                SafeAlphaFillRegionTiled (&pWin->drawable,
-                                          pRegion,
-                                          pWin->background.pixmap);
-                break;
-            case BackgroundPixel:
-            {
-                Pixel pixel = pWin->background.pixel |
-                              RootlessAlphaMask(pWin->drawable.bitsPerPixel);
-                fbFillRegionSolid (&pWin->drawable, pRegion, 0,
-                                   fbReplicatePixel (pixel,
-                                        pWin->drawable.bitsPerPixel));
-                break;
-            }
-        }
-    	break;
-      case PW_BORDER:
-        if (pWin->borderIsPixel)
-        {
-            Pixel pixel = pWin->border.pixel |
-                          RootlessAlphaMask(pWin->drawable.bitsPerPixel);
-            fbFillRegionSolid (&pWin->drawable, pRegion, 0,
-                               fbReplicatePixel (pixel,
-                                    pWin->drawable.bitsPerPixel));
-        }
-        else
-        {
-            WindowPtr pBgWin;
-            for (pBgWin = pWin; pBgWin->backgroundState == ParentRelative;
-                 pBgWin = pBgWin->parent);
-    
-            SafeAlphaFillRegionTiled (&pBgWin->drawable,
-                                      pRegion,
-                                      pWin->border.pixmap);
-        }
-        break;
-    }
-    fbValidateDrawable (&pWin->drawable);
-}
commit 509827a598537e9bcd79dae33643d140921d6ffe
Merge: f91c915... a65d4ae...
Author: Jeremy Huddleston <jeremy at tifa.local>
Date:   Sat Mar 1 17:10:42 2008 -0800

    Merge branch 'server-1.4-branch' into xorg-server-1.4-apple

commit a65d4aed06acd839fb21153f74144498abda3e18
Author: Alan Hourihane <alanh at tungstengraphics.com>
Date:   Wed Feb 27 16:49:34 2008 +0000

    Fix context sharing between direct/indirect contexts

diff --git a/GL/glx/glxdri.c b/GL/glx/glxdri.c
index 685683d..09abca3 100644
--- a/GL/glx/glxdri.c
+++ b/GL/glx/glxdri.c
@@ -598,6 +598,9 @@ __glXDRIscreenCreateContext(__GLXscreen *baseScreen,
     else
 	sharePrivate = NULL;
 
+    if (baseShareContext && baseShareContext->isDirect)
+        return NULL;
+
     context = xalloc(sizeof *context);
     if (context == NULL)
 	return NULL;
@@ -617,6 +620,11 @@ __glXDRIscreenCreateContext(__GLXscreen *baseScreen,
 					   0, /* render type */
 					   sharePrivate,
 					   &context->driContext);
+    
+    if (!context->driContext.private) {
+    	xfree(context);
+    	return NULL;
+    }
 
     context->driContext.mode = modes;
 
commit f91c915903182113da50e5a73c775c181592ff31
Author: Jeremy Huddleston <jeremy at tifa.local>
Date:   Sat Feb 23 00:01:02 2008 -0800

    XQuartz: Quit now properly warns the user
    (cherry picked from commit ed3d7b3959c2a0cb63e37210455bcc6cf195b807)

diff --git a/hw/xquartz/bundle/English.lproj/main.nib/designable.nib b/hw/xquartz/bundle/English.lproj/main.nib/designable.nib
index b5cfcf6..ea3a0da 100644
--- a/hw/xquartz/bundle/English.lproj/main.nib/designable.nib
+++ b/hw/xquartz/bundle/English.lproj/main.nib/designable.nib
@@ -2,14 +2,14 @@
 <archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.02">
 	<data>
 		<int key="IBDocument.SystemTarget">1050</int>
-		<string key="IBDocument.SystemVersion">9B18</string>
+		<string key="IBDocument.SystemVersion">9C31</string>
 		<string key="IBDocument.InterfaceBuilderVersion">639</string>
-		<string key="IBDocument.AppKitVersion">949</string>
-		<string key="IBDocument.HIToolboxVersion">343.00</string>
+		<string key="IBDocument.AppKitVersion">949.26</string>
+		<string key="IBDocument.HIToolboxVersion">352.00</string>
 		<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
 			<bool key="EncodedWithXMLCoder">YES</bool>
+			<integer value="57"/>
 			<integer value="285"/>
-			<integer value="29"/>
 		</object>
 		<object class="NSArray" key="IBDocument.PluginDependencies">
 			<bool key="EncodedWithXMLCoder">YES</bool>
@@ -448,7 +448,7 @@
 			<object class="NSWindowTemplate" id="124913468">
 				<int key="NSWindowStyleMask">3</int>
 				<int key="NSWindowBacking">2</int>
-				<string key="NSWindowRect">{{479, 459}, {481, 345}}</string>
+				<string key="NSWindowRect">{{319, 294}, {481, 345}}</string>
 				<int key="NSWTFlags">1350041600</int>
 				<string key="NSWindowTitle">X11 Preferences</string>
 				<string key="NSWindowClass">NSPanel</string>
@@ -993,7 +993,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 					</object>
 					<string key="NSFrameSize">{481, 345}</string>
 				</object>
-				<string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
+				<string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
 				<string key="NSMinSize">{213, 129}</string>
 				<string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
 				<string key="NSFrameAutosaveName">x11_prefs</string>
@@ -1001,7 +1001,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 			<object class="NSWindowTemplate" id="604417141">
 				<int key="NSWindowStyleMask">11</int>
 				<int key="NSWindowBacking">2</int>
-				<string key="NSWindowRect">{{537, 554}, {454, 311}}</string>
+				<string key="NSWindowRect">{{361, 362}, {454, 311}}</string>
 				<int key="NSWTFlags">1350041600</int>
 				<string key="NSWindowTitle">X11 Application Menu</string>
 				<string key="NSWindowClass">NSPanel</string>
@@ -1355,7 +1355,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 					<string key="NSFrameSize">{454, 311}</string>
 					<reference key="NSSuperview"/>
 				</object>
-				<string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
+				<string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
 				<string key="NSMinSize">{320, 262}</string>
 				<string key="NSFrameAutosaveName">x11_apps</string>
 			</object>
@@ -1866,14 +1866,6 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 					<int key="connectionID">300332</int>
 				</object>
 				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">quit:</string>
-						<reference key="source" ref="485884620"/>
-						<reference key="destination" ref="274138642"/>
-					</object>
-					<int key="connectionID">300333</int>
-				</object>
-				<object class="IBConnectionRecord">
 					<object class="IBOutletConnection" key="connection">
 						<string key="label">menu</string>
 						<reference key="source" ref="815810918"/>
@@ -1881,6 +1873,14 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 					</object>
 					<int key="connectionID">300334</int>
 				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">terminate:</string>
+						<reference key="source" ref="815810918"/>
+						<reference key="destination" ref="274138642"/>
+					</object>
+					<int key="connectionID">300336</int>
+				</object>
 			</object>
 			<object class="IBMutableOrderedSet" key="objectRecords">
 				<object class="NSArray" key="orderedObjects">
@@ -3075,6 +3075,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 					<string>545.ImportedFromIB2</string>
 					<string>56.IBPluginDependency</string>
 					<string>56.ImportedFromIB2</string>
+					<string>57.IBEditorWindowLastContentRect</string>
 					<string>57.IBPluginDependency</string>
 					<string>57.ImportedFromIB2</string>
 					<string>57.editorWindowContentRectSynchronizationRect</string>
@@ -3168,11 +3169,11 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 					<string>{{100, 746}, {155, 33}}</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<string>{{537, 554}, {454, 311}}</string>
+					<string>{{537, 545}, {454, 311}}</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
 					<reference ref="9"/>
-					<string>{{537, 554}, {454, 311}}</string>
+					<string>{{537, 545}, {454, 311}}</string>
 					<reference ref="9"/>
 					<string>{{433, 406}, {486, 327}}</string>
 					<object class="NSDictionary">
@@ -3194,7 +3195,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 					<string>{320, 240}</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<string>{{0, 1114}, {336, 20}}</string>
+					<string>{{0, 836}, {336, 20}}</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
 					<string>{{67, 819}, {336, 20}}</string>
@@ -3319,6 +3320,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 					<reference ref="9"/>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
+					<string>{{12, 633}, {218, 203}}</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
 					<string>{{79, 616}, {218, 203}}</string>
@@ -3354,7 +3356,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 				</object>
 			</object>
 			<nil key="sourceID"/>
-			<int key="maxID">300334</int>
+			<int key="maxID">300336</int>
 		</object>
 		<object class="IBClassDescriber" key="IBDocument.Classes">
 			<object class="NSMutableArray" key="referencedPartialClassDescriptions">
diff --git a/hw/xquartz/bundle/English.lproj/main.nib/keyedobjects.nib b/hw/xquartz/bundle/English.lproj/main.nib/keyedobjects.nib
index 5223c9a..f60dcba 100644
Binary files a/hw/xquartz/bundle/English.lproj/main.nib/keyedobjects.nib and b/hw/xquartz/bundle/English.lproj/main.nib/keyedobjects.nib differ
commit 44f46bfb981ca69515dafc520f62f33654711194
Author: Matthias Hopf <mhopf at suse.de>
Date:   Mon Jan 21 16:13:21 2008 +0100

    CVE-2007-6429: Always test for size+offset wrapping.

diff --git a/Xext/shm.c b/Xext/shm.c
index 6f99e90..376f123 100644
--- a/Xext/shm.c
+++ b/Xext/shm.c
@@ -753,10 +753,10 @@ CreatePmap:
     if (sizeof(size) == 4 && BitsPerPixel(depth) > 8) {
         if (size < width * height)
             return BadAlloc;
-        /* thankfully, offset is unsigned */
-        if (stuff->offset + size < size)
-            return BadAlloc;
     }
+    /* thankfully, offset is unsigned */
+    if (stuff->offset + size < size)
+	return BadAlloc;
 
     VERIFY_SHMSIZE(shmdesc, stuff->offset, size, client);
 
@@ -1098,10 +1098,10 @@ CreatePmap:
     if (sizeof(size) == 4 && BitsPerPixel(depth) > 8) {
 	if (size < width * height)
 	    return BadAlloc;
-	/* thankfully, offset is unsigned */
-	if (stuff->offset + size < size)
-	    return BadAlloc;
     }
+    /* thankfully, offset is unsigned */
+    if (stuff->offset + size < size)
+	return BadAlloc;
 
     VERIFY_SHMSIZE(shmdesc, stuff->offset, size, client);
     pMap = (*shmFuncs[pDraw->pScreen->myNum]->CreatePixmap)(
commit bcbfd619f8da888224afd80ee3a2db7d500523eb
Author: Kristian Høgsberg <krh at redhat.com>
Date:   Wed Jan 16 20:24:11 2008 -0500

    Don't break grab and focus state for a window when redirecting it.
    
    Composite uses an unmap/map cycle to trigger backing pixmap allocation
    and cliprect recomputation when a window is redirected or unredirected.
    To avoid protocol visible side effects, map and unmap events are
    disabled temporarily.  However, when a window is unmapped it is also
    removed from grabs and loses focus, but these state changes are not
    disabled.
    
    This change supresses the unmap side effects during the composite
    unmap/map cycle and fixes this bug:
    
      http://bugzilla.gnome.org/show_bug.cgi?id=488264
    
    where compiz would cause gnome-screensaver to lose its grab when
    compiz unredirects the fullscreen lock window.

diff --git a/dix/window.c b/dix/window.c
index be4ea2c..961c02a 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -3023,7 +3023,8 @@ UnrealizeTree(
 	    } 
 #endif
 	    (* Unrealize)(pChild);
-	    DeleteWindowFromAnyEvents(pChild, FALSE);
+	    if (MapUnmapEventsEnabled(pWin))
+		DeleteWindowFromAnyEvents(pChild, FALSE);
 	    if (pChild->viewable)
 	    {
 #ifdef DO_SAVE_UNDERS
commit dc30ade6496c7cc24e38c419e229159525fe042f
Author: Maarten Maathuis <madman2003 at gmail.com>
Date:   Sun Feb 17 18:47:28 2008 +0100

    Fix rotation for multi-monitor situation.
    
    - The (x,y)-coordinates of the crtc were not being passed as xFixed values, which made it an obscure bug to find.
    - Fix bug #13787.
    (cherry picked from commit a48cc88ea2674c28b69b8d738b168cbafcf4001f)

diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c
index 380478f..dd0e659 100644
--- a/hw/xfree86/modes/xf86Rotate.c
+++ b/hw/xfree86/modes/xf86Rotate.c
@@ -579,9 +579,9 @@ xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation)
     }
     else
     {
-	PictureTransformTranslate (&crtc_to_fb, &fb_to_crtc, crtc->x, crtc->y);
+	PictureTransformTranslate (&crtc_to_fb, &fb_to_crtc, F(crtc->x), F(crtc->y));
 	PictureTransformIsInverse ("offset", &crtc_to_fb, &fb_to_crtc);
-	
+
 	/* 
 	 * these are the size of the shadow pixmap, which
 	 * matches the mode, not the pre-rotated copy in the
commit 3db5930c61aeb849de3b21e7ba0d86d3c0cf72bb
Author: Maarten Maathuis <madman2003 at gmail.com>
Date:   Sun Feb 17 11:21:01 2008 +0100

    Resize composite overlay window when the root window changes.
    
    - This allows some compositing managers to work, even after randr12 has changed the root window size.
    - Thanks to ajax for figuring out the best place to put this.
    - Example:
    	- xf86RandR12SetMode() calls EnableDisableFBAccess().
    	- That calls xf86SetRootClip() which in turn calls ResizeChildrenWinSize().
    	- The final step is the call to PositionWindow().
    (cherry picked from commit 70c0592a97c7dc9db0576d32b3bdbe4766520509)

diff --git a/composite/compwindow.c b/composite/compwindow.c
index bfd2946..33192ad 100644
--- a/composite/compwindow.c
+++ b/composite/compwindow.c
@@ -165,6 +165,29 @@ compCheckRedirect (WindowPtr pWin)
     return TRUE;
 }
 
+static int
+updateOverlayWindow(ScreenPtr pScreen)
+{
+	CompScreenPtr cs;
+	WindowPtr pWin; /* overlay window */
+	XID vlist[2];
+
+	cs = GetCompScreen(pScreen);
+	if ((pWin = cs->pOverlayWin) != NULL) {
+		if ((pWin->drawable.width == pScreen->width) &&
+			(pWin->drawable.height == pScreen->height))
+			return Success;
+
+		/* Let's resize the overlay window. */
+		vlist[0] = pScreen->width;
+		vlist[1] = pScreen->height;
+		return ConfigureWindow(pWin, CWWidth | CWHeight, vlist, wClient(pWin));
+	}
+
+	/* Let's be on the safe side and not assume an overlay window is always allocated. */
+	return Success;
+}
+
 Bool
 compPositionWindow (WindowPtr pWin, int x, int y)
 {
@@ -203,6 +226,8 @@ compPositionWindow (WindowPtr pWin, int x, int y)
     cs->PositionWindow = pScreen->PositionWindow;
     pScreen->PositionWindow = compPositionWindow;
     compCheckTree (pWin->drawable.pScreen);
+    if (updateOverlayWindow(pScreen) != Success)
+	ret = FALSE;
     return ret;
 }
 
commit 04a09e927183e74ada5c27563e4f5ad5bb9ce330
Author: Jeremy Huddleston <jeremy at tifa.local>
Date:   Tue Feb 19 00:00:11 2008 -0800

    XQuartz: unsetenv("DISPLAY") before startx if X11.app can't connect to it.
    Also fix casting to silence warning.
    (cherry picked from commit a5cbf78471ec6e6ad672dc00118fc7edbd6ddc7c)

diff --git a/hw/xquartz/bundle/bundle-main.c b/hw/xquartz/bundle/bundle-main.c
index 54d0136..e97770a 100644
--- a/hw/xquartz/bundle/bundle-main.c
+++ b/hw/xquartz/bundle/bundle-main.c
@@ -45,6 +45,7 @@ static char *command_from_prefs(const char *key, const char *default_value);
 
 int main(int argc, char **argv) {
     Display *display;
+    const char *s;
 
     size_t i;
     fprintf(stderr, "X11.app: main(): argc=%d\n", argc);
@@ -72,7 +73,12 @@ int main(int argc, char **argv) {
     }
 
     /* Start the server */
-    fprintf(stderr, "X11.app: Could not connect to server.  Starting X server.");
+    if(s = getenv("DISPLAY")) {
+        fprintf(stderr, "X11.app: Could not connect to server (DISPLAY=\"%s\", unsetting).  Starting X server.\n", s);
+        unsetenv("DISPLAY");
+    } else {
+        fprintf(stderr, "X11.app: Could not connect to server (DISPLAY is not set).  Starting X server.\n");
+    }
     return execute(command_from_prefs("startx_script", DEFAULT_STARTX));
 }
 
@@ -93,7 +99,7 @@ static int execute(const char *command) {
         fprintf(stderr, "\targv[%d] = %s\n", s - newargv, *s);
     }
 
-    execvp (newargv[0], (const char **) newargv);
+    execvp (newargv[0], (char * const *) newargv);
     perror ("X11.app: Couldn't exec.");
     return(1);
 }
commit 70f9495e0c1f1459507064b673fe57b1c90d3c2c
Author: Jeremy Huddleston <jeremy at tifa-2.local>
Date:   Sat Feb 16 01:33:13 2008 -0800

    Added Xquartz.plist to EXTRA_DIST

diff --git a/hw/xquartz/bundle/Makefile.am b/hw/xquartz/bundle/Makefile.am
index 093a102..801fdc7 100644
--- a/hw/xquartz/bundle/Makefile.am
+++ b/hw/xquartz/bundle/Makefile.am
@@ -15,6 +15,7 @@ resourcedir=$(libdir)/X11/xserver
 resource_DATA = Xquartz.plist
 
 EXTRA_DIST = \
+	$(resource_DATA) \
 	Info.plist \
 	X11.icns \
 	bundle-main.c \
commit c3e87251b8264177fd67d027c7a68a2d445122de
Author: Jeremy Huddleston <jeremy at tifa-2.local>
Date:   Sat Feb 16 00:35:50 2008 -0800

    Fixed unescaped newline in EXTRA_DIST
    (cherry picked from commit 567c172c4d400fdfe69e7b096a3877fce5c2de9f)

diff --git a/hw/xquartz/bundle/Makefile.am b/hw/xquartz/bundle/Makefile.am
index 95cfd19..093a102 100644
--- a/hw/xquartz/bundle/Makefile.am
+++ b/hw/xquartz/bundle/Makefile.am
@@ -18,7 +18,7 @@ EXTRA_DIST = \
 	Info.plist \
 	X11.icns \
 	bundle-main.c \
-	X11.xcodeproj/project.pbxproj
+	X11.xcodeproj/project.pbxproj \
 	Dutch.lproj/InfoPlist.strings \
 	Dutch.lproj/Localizable.strings \
 	Dutch.lproj/main.nib/keyedobjects.nib \
commit e079e40319e8be5ceab8568616b0cae064b6c9d4
Author: Jeremy Huddleston <jeremy at tifa.local>
Date:   Mon Feb 11 16:09:03 2008 -0800

    XQuartz: Fixed EXTRA_DIST to include localization
    (cherry picked from commit 1b338c2a9330c85490a7c24d52adf24b124b70e6)

diff --git a/hw/xquartz/bundle/Makefile.am b/hw/xquartz/bundle/Makefile.am
index 00d540f..95cfd19 100644
--- a/hw/xquartz/bundle/Makefile.am
+++ b/hw/xquartz/bundle/Makefile.am
@@ -18,9 +18,59 @@ EXTRA_DIST = \
 	Info.plist \
 	X11.icns \
 	bundle-main.c \
+	X11.xcodeproj/project.pbxproj
+	Dutch.lproj/InfoPlist.strings \
+	Dutch.lproj/Localizable.strings \
+	Dutch.lproj/main.nib/keyedobjects.nib \
 	English.lproj/InfoPlist.strings \
 	English.lproj/Localizable.strings \
-	English.lproj/main.nib/classes.nib \
-	English.lproj/main.nib/info.nib \
+	English.lproj/main.nib/designable.nib \
 	English.lproj/main.nib/keyedobjects.nib \
-	X11.xcodeproj/project.pbxproj
+	French.lproj/InfoPlist.strings \
+	French.lproj/Localizable.strings \
+	French.lproj/main.nib/keyedobjects.nib \
+	German.lproj/InfoPlist.strings \
+	German.lproj/Localizable.strings \
+	German.lproj/main.nib/keyedobjects.nib \
+	Italian.lproj/InfoPlist.strings \
+	Italian.lproj/Localizable.strings \
+	Italian.lproj/main.nib/keyedobjects.nib \
+	Japanese.lproj/InfoPlist.strings \
+	Japanese.lproj/Localizable.strings \
+	Japanese.lproj/main.nib/keyedobjects.nib \
+	Spanish.lproj/InfoPlist.strings \
+	Spanish.lproj/Localizable.strings \
+	Spanish.lproj/main.nib/keyedobjects.nib \
+	da.lproj/InfoPlist.strings \
+	da.lproj/Localizable.strings \
+	da.lproj/main.nib/keyedobjects.nib \
+	fi.lproj/InfoPlist.strings \
+	fi.lproj/Localizable.strings \
+	fi.lproj/main.nib/keyedobjects.nib \
+	ko.lproj/InfoPlist.strings \
+	ko.lproj/Localizable.strings \
+	ko.lproj/main.nib/keyedobjects.nib \
+	no.lproj/InfoPlist.strings \
+	no.lproj/Localizable.strings \
+	no.lproj/main.nib/keyedobjects.nib \
+	pl.lproj/InfoPlist.strings \
+	pl.lproj/Localizable.strings \
+	pl.lproj/main.nib/keyedobjects.nib \
+	pt.lproj/InfoPlist.strings \
+	pt.lproj/Localizable.strings \
+	pt.lproj/main.nib/keyedobjects.nib \
+	pt_PT.lproj/InfoPlist.strings \
+	pt_PT.lproj/Localizable.strings \
+	pt_PT.lproj/main.nib/keyedobjects.nib \
+	ru.lproj/InfoPlist.strings \
+	ru.lproj/Localizable.strings \
+	ru.lproj/main.nib/keyedobjects.nib \
+	sv.lproj/InfoPlist.strings \
+	sv.lproj/Localizable.strings \
+	sv.lproj/main.nib/keyedobjects.nib \
+	zh_CN.lproj/InfoPlist.strings \
+	zh_CN.lproj/Localizable.strings \
+	zh_CN.lproj/main.nib/keyedobjects.nib \
+	zh_TW.lproj/InfoPlist.strings \
+	zh_TW.lproj/Localizable.strings \
+	zh_TW.lproj/main.nib/keyedobjects.nib
commit a4069c94a6b45a2a0c74f1c49e8b38e50380e168
Author: Jeremy Huddleston <jeremy at tifa-2.local>
Date:   Fri Feb 15 23:16:11 2008 -0800

    1.4.0-apple1

diff --git a/configure.ac b/configure.ac
index a967fa4..dc7b826 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,7 +26,7 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ(2.57)
-AC_INIT([xorg-server], 1.4.0.90, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+AC_INIT([xorg-server], 1.4.0-apple1, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([dist-bzip2 foreign])
 AM_MAINTAINER_MODE
commit 74b40bba327a2e97780e8e3f995f784add2d6231
Author: Eamon Walsh <ewalsh at tycho.nsa.gov>
Date:   Thu Feb 14 19:47:44 2008 -0500

    security: Fix for Bug #14480: untrusted access broken in 7.3.

diff --git a/Xext/security.c b/Xext/security.c
index e9d48c9..14ad354 100644
--- a/Xext/security.c
+++ b/Xext/security.c
@@ -1014,7 +1014,7 @@ CALLBACK(SecurityCheckResourceIDAccess)
     }
     else /* server-owned resource - probably a default colormap or root window */
     {
-	if (RT_WINDOW == rtype || RC_DRAWABLE == rtype)
+	if (RC_DRAWABLE & rtype)
 	{
 	    switch (reqtype)
 	    {   /* the following operations are allowed on root windows */
commit 1b22192e5079cec0e0b5e072415e93aae67d8593
Merge: b3eabf1... bc72ef3...
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Wed Feb 13 23:48:02 2008 -0800

    Merge branch 'server-1.4-branch' into xorg-server-1.4-apple

commit b3eabf13af1bfb4abc071385e42ddb47f4974b2d
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Mon Feb 11 12:09:41 2008 -0800

    XQuartz: Fixed layout of Applications->Customize menu
    
    Now resizing it won't produce weir overlaps of the widgets.  Thanks to
    Pelle Johansson for his help showing me how to do this.
    (cherry picked from commit ef3498e92d13c82633fdbe8120396bfbe1e7489a)

diff --git a/hw/xquartz/bundle/English.lproj/main.nib/designable.nib b/hw/xquartz/bundle/English.lproj/main.nib/designable.nib
index 08b3810..b5cfcf6 100644
--- a/hw/xquartz/bundle/English.lproj/main.nib/designable.nib
+++ b/hw/xquartz/bundle/English.lproj/main.nib/designable.nib
@@ -1,18 +1,19 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.01">
+<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.02">
 	<data>
 		<int key="IBDocument.SystemTarget">1050</int>
-		<string key="IBDocument.SystemVersion">9C31</string>
-		<string key="IBDocument.InterfaceBuilderVersion">629</string>
-		<string key="IBDocument.AppKitVersion">949.26</string>
-		<string key="IBDocument.HIToolboxVersion">352.00</string>
+		<string key="IBDocument.SystemVersion">9B18</string>
+		<string key="IBDocument.InterfaceBuilderVersion">639</string>
+		<string key="IBDocument.AppKitVersion">949</string>
+		<string key="IBDocument.HIToolboxVersion">343.00</string>
 		<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
 			<bool key="EncodedWithXMLCoder">YES</bool>
+			<integer value="285"/>
 			<integer value="29"/>
 		</object>
 		<object class="NSArray" key="IBDocument.PluginDependencies">
 			<bool key="EncodedWithXMLCoder">YES</bool>
-			<string id="1013584587">com.apple.InterfaceBuilder.CocoaPlugin</string>
+			<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 		</object>
 		<object class="NSMutableArray" key="IBDocument.RootObjects" id="904585544">
 			<bool key="EncodedWithXMLCoder">YES</bool>
@@ -22,41 +23,41 @@
 				</object>
 			</object>
 			<object class="NSCustomObject" id="941939442">
-				<string key="NSClassName" id="671773319">FirstResponder</string>
+				<string key="NSClassName">FirstResponder</string>
 			</object>
 			<object class="NSCustomObject" id="951368722">
 				<string key="NSClassName">NSApplication</string>
 			</object>
 			<object class="NSMenu" id="524015605">
-				<string key="NSTitle" id="121567387">MainMenu</string>
+				<string key="NSTitle">MainMenu</string>
 				<object class="NSMutableArray" key="NSMenuItems">
 					<bool key="EncodedWithXMLCoder">YES</bool>
 					<object class="NSMenuItem" id="365880285">
 						<reference key="NSMenu" ref="524015605"/>
-						<string key="NSTitle" id="335360021">X11</string>
-						<string key="NSKeyEquiv" id="331740794"/>
+						<string key="NSTitle">X11</string>
+						<string key="NSKeyEquiv"/>
 						<int key="NSKeyEquivModMask">1048576</int>
 						<int key="NSMnemonicLoc">2147483647</int>
 						<object class="NSCustomResource" key="NSOnImage" id="531645050">
-							<string key="NSClassName" id="1072749539">NSImage</string>
+							<string key="NSClassName">NSImage</string>
 							<string key="NSResourceName">NSMenuCheckmark</string>
 						</object>
-						<object class="NSCustomResource" key="NSMixedImage" id="246283459">
-							<reference key="NSClassName" ref="1072749539"/>
+						<object class="NSCustomResource" key="NSMixedImage" id="351811234">
+							<string key="NSClassName">NSImage</string>
 							<string key="NSResourceName">NSMenuMixedState</string>
 						</object>
 						<string key="NSAction">submenuAction:</string>
 						<object class="NSMenu" key="NSSubmenu" id="576521955">
-							<reference key="NSTitle" ref="335360021"/>
+							<string key="NSTitle">X11</string>
 							<object class="NSMutableArray" key="NSMenuItems">
 								<bool key="EncodedWithXMLCoder">YES</bool>
 								<object class="NSMenuItem" id="139290918">
 									<reference key="NSMenu" ref="576521955"/>
 									<string key="NSTitle">About X11</string>
-									<reference key="NSKeyEquiv" ref="331740794"/>
+									<string key="NSKeyEquiv"/>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="246283459"/>
+									<reference key="NSMixedImage" ref="351811234"/>
 								</object>
 								<object class="NSMenuItem" id="386173216">
 									<reference key="NSMenu" ref="576521955"/>
@@ -65,27 +66,27 @@
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="246283459"/>
+									<reference key="NSMixedImage" ref="351811234"/>
 								</object>
 								<object class="NSMenuItem" id="272876017">
 									<reference key="NSMenu" ref="576521955"/>
 									<bool key="NSIsDisabled">YES</bool>
 									<bool key="NSIsSeparator">YES</bool>
-									<reference key="NSTitle" ref="331740794"/>
-									<reference key="NSKeyEquiv" ref="331740794"/>
+									<string key="NSTitle"/>
+									<string key="NSKeyEquiv"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="246283459"/>
+									<reference key="NSMixedImage" ref="351811234"/>
 								</object>
 								<object class="NSMenuItem" id="32285361">
 									<reference key="NSMenu" ref="576521955"/>
 									<string key="NSTitle">Services</string>
-									<reference key="NSKeyEquiv" ref="331740794"/>
+									<string key="NSKeyEquiv"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="246283459"/>
+									<reference key="NSMixedImage" ref="351811234"/>
 									<string key="NSAction">submenuAction:</string>
 									<object class="NSMenu" key="NSSubmenu" id="821388474">
 										<object class="NSMutableString" key="NSTitle">
@@ -101,32 +102,32 @@
 									<reference key="NSMenu" ref="576521955"/>
 									<bool key="NSIsDisabled">YES</bool>
 									<bool key="NSIsSeparator">YES</bool>
-									<reference key="NSTitle" ref="331740794"/>
-									<reference key="NSKeyEquiv" ref="331740794"/>
+									<string key="NSTitle"/>
+									<string key="NSKeyEquiv"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="246283459"/>
+									<reference key="NSMixedImage" ref="351811234"/>
 								</object>
 								<object class="NSMenuItem" id="6876565">
 									<reference key="NSMenu" ref="576521955"/>
 									<string key="NSTitle">Toggle Full Screen</string>
-									<string key="NSKeyEquiv" id="934453074">a</string>
+									<string key="NSKeyEquiv">a</string>
 									<int key="NSKeyEquivModMask">1572864</int>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="246283459"/>
+									<reference key="NSMixedImage" ref="351811234"/>
 								</object>
 								<object class="NSMenuItem" id="479677589">
 									<reference key="NSMenu" ref="576521955"/>
 									<bool key="NSIsDisabled">YES</bool>
 									<bool key="NSIsSeparator">YES</bool>
-									<reference key="NSTitle" ref="331740794"/>
-									<reference key="NSKeyEquiv" ref="331740794"/>
+									<string key="NSTitle"/>
+									<string key="NSKeyEquiv"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="246283459"/>
+									<reference key="NSMixedImage" ref="351811234"/>
 								</object>
 								<object class="NSMenuItem" id="301008465">
 									<reference key="NSMenu" ref="576521955"/>
@@ -135,38 +136,38 @@
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="246283459"/>
+									<reference key="NSMixedImage" ref="351811234"/>
 									<int key="NSTag">42</int>
 								</object>
 								<object class="NSMenuItem" id="206802571">
 									<reference key="NSMenu" ref="576521955"/>
 									<string key="NSTitle">Hide Others</string>
-									<reference key="NSKeyEquiv" ref="331740794"/>
+									<string key="NSKeyEquiv"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="246283459"/>
+									<reference key="NSMixedImage" ref="351811234"/>
 								</object>
 								<object class="NSMenuItem" id="1023546148">
 									<reference key="NSMenu" ref="576521955"/>
 									<string key="NSTitle">Show All</string>
-									<reference key="NSKeyEquiv" ref="331740794"/>
+									<string key="NSKeyEquiv"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="246283459"/>
+									<reference key="NSMixedImage" ref="351811234"/>
 									<int key="NSTag">42</int>
 								</object>
 								<object class="NSMenuItem" id="848095279">
 									<reference key="NSMenu" ref="576521955"/>
 									<bool key="NSIsDisabled">YES</bool>
 									<bool key="NSIsSeparator">YES</bool>
-									<reference key="NSTitle" ref="331740794"/>
-									<reference key="NSKeyEquiv" ref="331740794"/>
+									<string key="NSTitle"/>
+									<string key="NSKeyEquiv"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="246283459"/>
+									<reference key="NSMixedImage" ref="351811234"/>
 								</object>
 								<object class="NSMenuItem" id="274138642">
 									<reference key="NSMenu" ref="576521955"/>
@@ -175,7 +176,7 @@
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="246283459"/>
+									<reference key="NSMixedImage" ref="351811234"/>
 								</object>
 							</object>
 							<string key="NSName">_NSAppleMenu</string>
@@ -183,51 +184,51 @@
 					</object>
 					<object class="NSMenuItem" id="868031522">
 						<reference key="NSMenu" ref="524015605"/>
-						<string key="NSTitle" id="667842658">Applications</string>
-						<reference key="NSKeyEquiv" ref="331740794"/>
+						<string key="NSTitle">Applications</string>
+						<string key="NSKeyEquiv"/>
 						<int key="NSKeyEquivModMask">1048576</int>
 						<int key="NSMnemonicLoc">2147483647</int>
 						<reference key="NSOnImage" ref="531645050"/>
-						<reference key="NSMixedImage" ref="246283459"/>
+						<reference key="NSMixedImage" ref="351811234"/>
 						<string key="NSAction">submenuAction:</string>
 						<object class="NSMenu" key="NSSubmenu" id="981161348">
-							<reference key="NSTitle" ref="667842658"/>
+							<string key="NSTitle">Applications</string>
 							<object class="NSMutableArray" key="NSMenuItems">
 								<bool key="EncodedWithXMLCoder">YES</bool>
 								<object class="NSMenuItem" id="390088328">
 									<reference key="NSMenu" ref="981161348"/>
 									<bool key="NSIsDisabled">YES</bool>
 									<bool key="NSIsSeparator">YES</bool>
-									<reference key="NSTitle" ref="331740794"/>
-									<reference key="NSKeyEquiv" ref="331740794"/>
+									<string key="NSTitle"/>
+									<string key="NSKeyEquiv"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="246283459"/>
+									<reference key="NSMixedImage" ref="351811234"/>
 								</object>
 								<object class="NSMenuItem" id="1065386165">
 									<reference key="NSMenu" ref="981161348"/>
 									<string key="NSTitle">Customize...</string>
-									<reference key="NSKeyEquiv" ref="331740794"/>
+									<string key="NSKeyEquiv"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="246283459"/>
+									<reference key="NSMixedImage" ref="351811234"/>
 								</object>
 							</object>
 						</object>
 					</object>
 					<object class="NSMenuItem" id="200491363">
 						<reference key="NSMenu" ref="524015605"/>
-						<string key="NSTitle" id="934359734">Edit</string>
-						<reference key="NSKeyEquiv" ref="331740794"/>
+						<string key="NSTitle">Edit</string>
+						<string key="NSKeyEquiv"/>
 						<int key="NSKeyEquivModMask">1048576</int>
 						<int key="NSMnemonicLoc">2147483647</int>
 						<reference key="NSOnImage" ref="531645050"/>
-						<reference key="NSMixedImage" ref="246283459"/>
+						<reference key="NSMixedImage" ref="351811234"/>
 						<string key="NSAction">submenuAction:</string>
 						<object class="NSMenu" key="NSSubmenu" id="526778998">
-							<reference key="NSTitle" ref="934359734"/>
+							<string key="NSTitle">Edit</string>
 							<object class="NSMutableArray" key="NSMenuItems">
 								<bool key="EncodedWithXMLCoder">YES</bool>
 								<object class="NSMenuItem" id="1010221707">
@@ -237,7 +238,7 @@
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="246283459"/>
+									<reference key="NSMixedImage" ref="351811234"/>
 								</object>
 								<object class="NSMenuItem" id="535038564">
 									<reference key="NSMenu" ref="526778998"/>
@@ -246,18 +247,18 @@
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="246283459"/>
+									<reference key="NSMixedImage" ref="351811234"/>
 								</object>
 								<object class="NSMenuItem" id="839739619">
 									<reference key="NSMenu" ref="526778998"/>
 									<bool key="NSIsDisabled">YES</bool>
 									<bool key="NSIsSeparator">YES</bool>
-									<reference key="NSTitle" ref="331740794"/>
-									<reference key="NSKeyEquiv" ref="331740794"/>
+									<string key="NSTitle"/>
+									<string key="NSKeyEquiv"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="246283459"/>
+									<reference key="NSMixedImage" ref="351811234"/>
 								</object>
 								<object class="NSMenuItem" id="581727829">
 									<reference key="NSMenu" ref="526778998"/>
@@ -266,7 +267,7 @@
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="246283459"/>
+									<reference key="NSMixedImage" ref="351811234"/>
 								</object>
 								<object class="NSMenuItem" id="185296989">
 									<reference key="NSMenu" ref="526778998"/>
@@ -275,7 +276,7 @@
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="246283459"/>
+									<reference key="NSMixedImage" ref="351811234"/>
 								</object>
 								<object class="NSMenuItem" id="924678073">
 									<reference key="NSMenu" ref="526778998"/>
@@ -284,25 +285,25 @@
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="246283459"/>
+									<reference key="NSMixedImage" ref="351811234"/>
 								</object>
 								<object class="NSMenuItem" id="994817848">
 									<reference key="NSMenu" ref="526778998"/>
 									<string key="NSTitle">Delete</string>
-									<reference key="NSKeyEquiv" ref="331740794"/>
+									<string key="NSKeyEquiv"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="246283459"/>
+									<reference key="NSMixedImage" ref="351811234"/>
 								</object>
 								<object class="NSMenuItem" id="322866464">
 									<reference key="NSMenu" ref="526778998"/>
 									<string key="NSTitle">Select All</string>
-									<reference key="NSKeyEquiv" ref="934453074"/>
+									<string key="NSKeyEquiv">a</string>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="246283459"/>
+									<reference key="NSMixedImage" ref="351811234"/>
 								</object>
 							</object>
 						</object>
@@ -310,11 +311,11 @@
 					<object class="NSMenuItem" id="931553638">
 						<reference key="NSMenu" ref="524015605"/>
 						<string key="NSTitle">Window</string>
-						<reference key="NSKeyEquiv" ref="331740794"/>
+						<string key="NSKeyEquiv"/>
 						<int key="NSKeyEquivModMask">1048576</int>
 						<int key="NSMnemonicLoc">2147483647</int>
 						<reference key="NSOnImage" ref="531645050"/>
-						<reference key="NSMixedImage" ref="246283459"/>
+						<reference key="NSMixedImage" ref="351811234"/>
 						<string key="NSAction">submenuAction:</string>
 						<object class="NSMenu" key="NSSubmenu" id="96874957">
 							<object class="NSMutableString" key="NSTitle">
@@ -329,16 +330,16 @@
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="246283459"/>
+									<reference key="NSMixedImage" ref="351811234"/>
 								</object>
 								<object class="NSMenuItem" id="1066447520">
 									<reference key="NSMenu" ref="96874957"/>
 									<string key="NSTitle">Zoom</string>
-									<reference key="NSKeyEquiv" ref="331740794"/>
+									<string key="NSKeyEquiv"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="246283459"/>
+									<reference key="NSMixedImage" ref="351811234"/>
 								</object>
 								<object class="NSMenuItem" id="1036389925">
 									<reference key="NSMenu" ref="96874957"/>
@@ -347,7 +348,7 @@
 									<int key="NSKeyEquivModMask">1048840</int>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="246283459"/>
+									<reference key="NSMixedImage" ref="351811234"/>
 								</object>
 								<object class="NSMenuItem" id="369641893">
 									<reference key="NSMenu" ref="96874957"/>
@@ -356,18 +357,18 @@
 									<int key="NSKeyEquivModMask">1179914</int>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="246283459"/>
+									<reference key="NSMixedImage" ref="351811234"/>
 								</object>
 								<object class="NSMenuItem" id="280172320">
 									<reference key="NSMenu" ref="96874957"/>
 									<bool key="NSIsDisabled">YES</bool>
 									<bool key="NSIsSeparator">YES</bool>
-									<reference key="NSTitle" ref="331740794"/>
-									<reference key="NSKeyEquiv" ref="331740794"/>
+									<string key="NSTitle"/>
+									<string key="NSKeyEquiv"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="246283459"/>
+									<reference key="NSMixedImage" ref="351811234"/>
 								</object>
 								<object class="NSMenuItem" id="984461797">
 									<reference key="NSMenu" ref="96874957"/>
@@ -376,38 +377,38 @@
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="246283459"/>
+									<reference key="NSMixedImage" ref="351811234"/>
 								</object>
 								<object class="NSMenuItem" id="155085383">
 									<reference key="NSMenu" ref="96874957"/>
 									<bool key="NSIsDisabled">YES</bool>
 									<bool key="NSIsSeparator">YES</bool>
-									<reference key="NSTitle" ref="331740794"/>
-									<reference key="NSKeyEquiv" ref="331740794"/>
+									<string key="NSTitle"/>
+									<string key="NSKeyEquiv"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="246283459"/>
+									<reference key="NSMixedImage" ref="351811234"/>
 								</object>
 								<object class="NSMenuItem" id="276216762">
 									<reference key="NSMenu" ref="96874957"/>
 									<string key="NSTitle">Bring All to Front</string>
-									<reference key="NSKeyEquiv" ref="331740794"/>
+									<string key="NSKeyEquiv"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="246283459"/>
+									<reference key="NSMixedImage" ref="351811234"/>
 								</object>
 								<object class="NSMenuItem" id="444952046">
 									<reference key="NSMenu" ref="96874957"/>
 									<bool key="NSIsDisabled">YES</bool>
 									<bool key="NSIsSeparator">YES</bool>
-									<reference key="NSTitle" ref="331740794"/>
-									<reference key="NSKeyEquiv" ref="331740794"/>
+									<string key="NSTitle"/>
+									<string key="NSKeyEquiv"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="246283459"/>
+									<reference key="NSMixedImage" ref="351811234"/>
 								</object>
 							</object>
 							<string key="NSName">_NSWindowsMenu</string>
@@ -415,25 +416,25 @@
 					</object>
 					<object class="NSMenuItem" id="551174276">
 						<reference key="NSMenu" ref="524015605"/>
-						<string key="NSTitle" id="214661970">Help</string>
-						<reference key="NSKeyEquiv" ref="331740794"/>
+						<string key="NSTitle">Help</string>
+						<string key="NSKeyEquiv"/>
 						<int key="NSKeyEquivModMask">1048576</int>
 						<int key="NSMnemonicLoc">2147483647</int>
 						<reference key="NSOnImage" ref="531645050"/>
-						<reference key="NSMixedImage" ref="246283459"/>
+						<reference key="NSMixedImage" ref="351811234"/>
 						<string key="NSAction">submenuAction:</string>
 						<object class="NSMenu" key="NSSubmenu" id="511848303">
-							<reference key="NSTitle" ref="214661970"/>
+							<string key="NSTitle">Help</string>
 							<object class="NSMutableArray" key="NSMenuItems">
 								<bool key="EncodedWithXMLCoder">YES</bool>
 								<object class="NSMenuItem" id="504984881">
 									<reference key="NSMenu" ref="511848303"/>
 									<string key="NSTitle">X11 Help</string>
-									<reference key="NSKeyEquiv" ref="331740794"/>
+									<string key="NSKeyEquiv"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="246283459"/>
+									<reference key="NSMixedImage" ref="351811234"/>
 								</object>
 							</object>
 						</object>
@@ -442,15 +443,15 @@
 				<string key="NSName">_NSMainMenu</string>
 			</object>
 			<object class="NSCustomObject" id="485884620">
-				<string key="NSClassName" id="865849805">X11Controller</string>
+				<string key="NSClassName">X11Controller</string>
 			</object>
 			<object class="NSWindowTemplate" id="124913468">
 				<int key="NSWindowStyleMask">3</int>
 				<int key="NSWindowBacking">2</int>
-				<string key="NSWindowRect">{{319, 294}, {481, 345}}</string>
+				<string key="NSWindowRect">{{479, 459}, {481, 345}}</string>
 				<int key="NSWTFlags">1350041600</int>
 				<string key="NSWindowTitle">X11 Preferences</string>
-				<string key="NSWindowClass" id="666842945">NSPanel</string>
+				<string key="NSWindowClass">NSPanel</string>
 				<object class="NSMutableString" key="NSViewClass">
 					<characters key="NS.bytes">View</characters>
 				</object>
@@ -464,202 +465,198 @@
 						<object class="NSTabView" id="448510093">
 							<reference key="NSNextResponder" ref="941366957"/>
 							<int key="NSvFlags">256</int>
-							<object class="NSMutableArray" key="NSSubviews">
+							<string key="NSFrame">{{10, 10}, {458, 325}}</string>
+							<reference key="NSSuperview" ref="941366957"/>
+							<object class="NSMutableArray" key="NSTabViewItems">
 								<bool key="EncodedWithXMLCoder">YES</bool>
-								<object class="NSView" id="596750588">
-									<reference key="NSNextResponder" ref="448510093"/>
-									<int key="NSvFlags">256</int>
-									<object class="NSMutableArray" key="NSSubviews">
-										<bool key="EncodedWithXMLCoder">YES</bool>
-										<object class="NSButton" id="119157981">
-											<reference key="NSNextResponder" ref="596750588"/>
-											<int key="NSvFlags">256</int>
-											<string key="NSFrame">{{18, 243}, {402, 18}}</string>
-											<reference key="NSSuperview" ref="596750588"/>
-											<bool key="NSEnabled">YES</bool>
-											<object class="NSButtonCell" key="NSCell" id="990762273">
-												<int key="NSCellFlags">67239424</int>
-												<int key="NSCellFlags2">0</int>
-												<string key="NSContents">Emulate three button mouse</string>
-												<object class="NSFont" key="NSSupport" id="463863101">
-													<string key="NSName" id="512586816">LucidaGrande</string>
-													<double key="NSSize">1.300000e+01</double>
-													<int key="NSfFlags">1044</int>
-												</object>
-												<reference key="NSControlView" ref="119157981"/>
-												<int key="NSButtonFlags">1211912703</int>
-												<int key="NSButtonFlags2">2</int>
-												<object class="NSButtonImageSource" key="NSAlternateImage" id="391434389">
-													<string key="NSImageName">NSSwitch</string>
+								<object class="NSTabViewItem" id="287591690">
+									<object class="NSMutableString" key="NSIdentifier">
+										<characters key="NS.bytes">1</characters>
+									</object>
+									<object class="NSView" key="NSView" id="596750588">
+										<reference key="NSNextResponder" ref="448510093"/>
+										<int key="NSvFlags">256</int>
+										<object class="NSMutableArray" key="NSSubviews">
+											<bool key="EncodedWithXMLCoder">YES</bool>
+											<object class="NSButton" id="119157981">
+												<reference key="NSNextResponder" ref="596750588"/>
+												<int key="NSvFlags">256</int>
+												<string key="NSFrame">{{18, 243}, {402, 18}}</string>
+												<reference key="NSSuperview" ref="596750588"/>
+												<bool key="NSEnabled">YES</bool>
+												<object class="NSButtonCell" key="NSCell" id="990762273">
+													<int key="NSCellFlags">67239424</int>
+													<int key="NSCellFlags2">0</int>
+													<string key="NSContents">Emulate three button mouse</string>
+													<object class="NSFont" key="NSSupport" id="463863101">
+														<string key="NSName">LucidaGrande</string>
+														<double key="NSSize">1.300000e+01</double>
+														<int key="NSfFlags">1044</int>
+													</object>
+													<reference key="NSControlView" ref="119157981"/>
+													<int key="NSButtonFlags">1211912703</int>
+													<int key="NSButtonFlags2">2</int>
+													<object class="NSButtonImageSource" key="NSAlternateImage" id="391434389">
+														<string key="NSImageName">NSSwitch</string>
+													</object>
+													<string key="NSAlternateContents"/>
+													<string key="NSKeyEquivalent"/>
+													<int key="NSPeriodicDelay">200</int>
+													<int key="NSPeriodicInterval">25</int>
 												</object>
-												<reference key="NSAlternateContents" ref="331740794"/>
-												<reference key="NSKeyEquivalent" ref="331740794"/>
-												<int key="NSPeriodicDelay">200</int>
-												<int key="NSPeriodicInterval">25</int>
 											</object>
-										</object>
-										<object class="NSTextField" id="443008216">
-											<reference key="NSNextResponder" ref="596750588"/>
-											<int key="NSvFlags">256</int>
-											<string key="NSFrame">{{36, 93}, {385, 31}}</string>
-											<reference key="NSSuperview" ref="596750588"/>
-											<bool key="NSEnabled">YES</bool>
-											<object class="NSTextFieldCell" key="NSCell" id="391919450">
-												<int key="NSCellFlags">67239424</int>
-												<int key="NSCellFlags2">4194304</int>
-												<string key="NSContents">When enabled, menu bar key equivalents may interfere with X11 applications that use the Meta modifier.</string>
-												<object class="NSFont" key="NSSupport" id="26">
-													<reference key="NSName" ref="512586816"/>
-													<double key="NSSize">1.100000e+01</double>
-													<int key="NSfFlags">3100</int>
-												</object>
-												<reference key="NSControlView" ref="443008216"/>
-												<object class="NSColor" key="NSBackgroundColor" id="57160303">
-													<int key="NSColorSpace">6</int>
-													<string key="NSCatalogName" id="905527164">System</string>
-													<string key="NSColorName">controlColor</string>
-													<object class="NSColor" key="NSColor" id="590688762">
-														<int key="NSColorSpace">3</int>
-														<bytes key="NSWhite">MC42NjY2NjY2OQA</bytes>
+											<object class="NSTextField" id="443008216">
+												<reference key="NSNextResponder" ref="596750588"/>
+												<int key="NSvFlags">256</int>
+												<string key="NSFrame">{{36, 93}, {385, 31}}</string>
+												<reference key="NSSuperview" ref="596750588"/>
+												<bool key="NSEnabled">YES</bool>
+												<object class="NSTextFieldCell" key="NSCell" id="391919450">
+													<int key="NSCellFlags">67239424</int>
+													<int key="NSCellFlags2">4194304</int>
+													<string key="NSContents">When enabled, menu bar key equivalents may interfere with X11 applications that use the Meta modifier.</string>
+													<object class="NSFont" key="NSSupport" id="26">
+														<string key="NSName">LucidaGrande</string>
+														<double key="NSSize">1.100000e+01</double>
+														<int key="NSfFlags">3100</int>
 													</object>
-												</object>
-												<object class="NSColor" key="NSTextColor" id="930815747">
-													<int key="NSColorSpace">6</int>
-													<reference key="NSCatalogName" ref="905527164"/>
-													<string key="NSColorName">controlTextColor</string>
-													<object class="NSColor" key="NSColor" id="214098874">
-														<int key="NSColorSpace">3</int>
-														<bytes key="NSWhite">MAA</bytes>
+													<reference key="NSControlView" ref="443008216"/>
+													<object class="NSColor" key="NSBackgroundColor" id="57160303">
+														<int key="NSColorSpace">6</int>
+														<string key="NSCatalogName">System</string>
+														<string key="NSColorName">controlColor</string>
+														<object class="NSColor" key="NSColor" id="590688762">
+															<int key="NSColorSpace">3</int>
+															<bytes key="NSWhite">MC42NjY2NjY2OQA</bytes>
+														</object>
+													</object>
+													<object class="NSColor" key="NSTextColor" id="930815747">
+														<int key="NSColorSpace">6</int>
+														<string key="NSCatalogName">System</string>
+														<string key="NSColorName">controlTextColor</string>
+														<object class="NSColor" key="NSColor" id="214098874">
+															<int key="NSColorSpace">3</int>
+															<bytes key="NSWhite">MAA</bytes>
+														</object>
 													</object>
 												</object>
 											</object>
-										</object>
-										<object class="NSTextField" id="282885445">
-											<reference key="NSNextResponder" ref="596750588"/>
-											<int key="NSvFlags">256</int>
-											<string key="NSFrame">{{36, 208}, {385, 29}}</string>
-											<reference key="NSSuperview" ref="596750588"/>
-											<bool key="NSEnabled">YES</bool>
-											<object class="NSTextFieldCell" key="NSCell" id="649334366">
-												<int key="NSCellFlags">67239424</int>
-												<int key="NSCellFlags2">4194304</int>
-												<string type="base64-UTF8" key="NSContents">SG9sZCBPcHRpb24gYW5kIENvbW1hbmQgd2hpbGUgY2xpY2tpbmcgdG8gYWN0aXZhdGUgdGhlIG1pZGRs
+											<object class="NSTextField" id="282885445">
+												<reference key="NSNextResponder" ref="596750588"/>
+												<int key="NSvFlags">256</int>
+												<string key="NSFrame">{{36, 208}, {385, 29}}</string>
+												<reference key="NSSuperview" ref="596750588"/>
+												<bool key="NSEnabled">YES</bool>
+												<object class="NSTextFieldCell" key="NSCell" id="649334366">
+													<int key="NSCellFlags">67239424</int>
+													<int key="NSCellFlags2">4194304</int>
+													<string type="base64-UTF8" key="NSContents">SG9sZCBPcHRpb24gYW5kIENvbW1hbmQgd2hpbGUgY2xpY2tpbmcgdG8gYWN0aXZhdGUgdGhlIG1pZGRs
 ZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KA</string>
-												<reference key="NSSupport" ref="26"/>
-												<reference key="NSControlView" ref="282885445"/>
-												<reference key="NSBackgroundColor" ref="57160303"/>
-												<reference key="NSTextColor" ref="930815747"/>
+													<reference key="NSSupport" ref="26"/>
+													<reference key="NSControlView" ref="282885445"/>
+													<reference key="NSBackgroundColor" ref="57160303"/>
+													<reference key="NSTextColor" ref="930815747"/>
+												</object>
 											</object>
-										</object>
-										<object class="NSButton" id="842100515">
-											<reference key="NSNextResponder" ref="596750588"/>
-											<int key="NSvFlags">256</int>
-											<string key="NSFrame">{{18, 130}, {402, 18}}</string>
-											<reference key="NSSuperview" ref="596750588"/>
-											<bool key="NSEnabled">YES</bool>
-											<object class="NSButtonCell" key="NSCell" id="940564599">
-												<int key="NSCellFlags">67239424</int>
-												<int key="NSCellFlags2">0</int>
-												<string key="NSContents">Enable key equivalents under X11</string>
-												<reference key="NSSupport" ref="463863101"/>
-												<reference key="NSControlView" ref="842100515"/>
-												<int key="NSButtonFlags">1211912703</int>
-												<int key="NSButtonFlags2">2</int>
-												<reference key="NSAlternateImage" ref="391434389"/>
-												<reference key="NSAlternateContents" ref="331740794"/>
-												<reference key="NSKeyEquivalent" ref="331740794"/>
-												<int key="NSPeriodicDelay">200</int>
-												<int key="NSPeriodicInterval">25</int>
+											<object class="NSButton" id="842100515">
+												<reference key="NSNextResponder" ref="596750588"/>
+												<int key="NSvFlags">256</int>
+												<string key="NSFrame">{{18, 130}, {402, 18}}</string>
+												<reference key="NSSuperview" ref="596750588"/>
+												<bool key="NSEnabled">YES</bool>
+												<object class="NSButtonCell" key="NSCell" id="940564599">
+													<int key="NSCellFlags">67239424</int>
+													<int key="NSCellFlags2">0</int>
+													<string key="NSContents">Enable key equivalents under X11</string>
+													<reference key="NSSupport" ref="463863101"/>
+													<reference key="NSControlView" ref="842100515"/>
+													<int key="NSButtonFlags">1211912703</int>
+													<int key="NSButtonFlags2">2</int>
+													<reference key="NSAlternateImage" ref="391434389"/>
+													<string key="NSAlternateContents"/>
+													<string key="NSKeyEquivalent"/>
+													<int key="NSPeriodicDelay">200</int>
+													<int key="NSPeriodicInterval">25</int>
+												</object>
 											</object>
-										</object>
-										<object class="NSTextField" id="31160162">
-											<reference key="NSNextResponder" ref="596750588"/>
-											<int key="NSvFlags">256</int>
-											<string key="NSFrame">{{36, 159}, {385, 14}}</string>
-											<reference key="NSSuperview" ref="596750588"/>
-											<bool key="NSEnabled">YES</bool>
-											<object class="NSTextFieldCell" key="NSCell" id="666057093">
-												<int key="NSCellFlags">67239424</int>
-												<int key="NSCellFlags2">4194304</int>
-												<string key="NSContents">Allows input menu changes to overwrite the current X11 keymap.</string>
-												<reference key="NSSupport" ref="26"/>
-												<reference key="NSControlView" ref="31160162"/>
-												<reference key="NSBackgroundColor" ref="57160303"/>
-												<reference key="NSTextColor" ref="930815747"/>
+											<object class="NSTextField" id="31160162">
+												<reference key="NSNextResponder" ref="596750588"/>
+												<int key="NSvFlags">256</int>
+												<string key="NSFrame">{{36, 159}, {385, 14}}</string>
+												<reference key="NSSuperview" ref="596750588"/>
+												<bool key="NSEnabled">YES</bool>
+												<object class="NSTextFieldCell" key="NSCell" id="666057093">
+													<int key="NSCellFlags">67239424</int>
+													<int key="NSCellFlags2">4194304</int>
+													<string key="NSContents">Allows input menu changes to overwrite the current X11 keymap.</string>
+													<reference key="NSSupport" ref="26"/>
+													<reference key="NSControlView" ref="31160162"/>
+													<reference key="NSBackgroundColor" ref="57160303"/>
+													<reference key="NSTextColor" ref="930815747"/>
+												</object>
 											</object>
-										</object>
-										<object class="NSButton" id="179949713">
-											<reference key="NSNextResponder" ref="596750588"/>
-											<int key="NSvFlags">256</int>
-											<string key="NSFrame">{{18, 179}, {402, 18}}</string>
-											<reference key="NSSuperview" ref="596750588"/>
-											<bool key="NSEnabled">YES</bool>
-											<object class="NSButtonCell" key="NSCell" id="967619578">
-												<int key="NSCellFlags">67239424</int>
-												<int key="NSCellFlags2">0</int>
-												<string key="NSContents">Follow system keyboard layout</string>
-												<reference key="NSSupport" ref="463863101"/>
-												<reference key="NSControlView" ref="179949713"/>
-												<int key="NSButtonFlags">1211912703</int>
-												<int key="NSButtonFlags2">2</int>
-												<reference key="NSAlternateImage" ref="391434389"/>
-												<reference key="NSAlternateContents" ref="331740794"/>
-												<reference key="NSKeyEquivalent" ref="331740794"/>
-												<int key="NSPeriodicDelay">200</int>
-												<int key="NSPeriodicInterval">25</int>
+											<object class="NSButton" id="179949713">
+												<reference key="NSNextResponder" ref="596750588"/>
+												<int key="NSvFlags">256</int>
+												<string key="NSFrame">{{18, 179}, {402, 18}}</string>
+												<reference key="NSSuperview" ref="596750588"/>
+												<bool key="NSEnabled">YES</bool>
+												<object class="NSButtonCell" key="NSCell" id="967619578">
+													<int key="NSCellFlags">67239424</int>
+													<int key="NSCellFlags2">0</int>
+													<string key="NSContents">Follow system keyboard layout</string>
+													<reference key="NSSupport" ref="463863101"/>
+													<reference key="NSControlView" ref="179949713"/>
+													<int key="NSButtonFlags">1211912703</int>
+													<int key="NSButtonFlags2">2</int>
+													<reference key="NSAlternateImage" ref="391434389"/>
+													<string key="NSAlternateContents"/>
+													<string key="NSKeyEquivalent"/>
+													<int key="NSPeriodicDelay">200</int>
+													<int key="NSPeriodicInterval">25</int>
+												</object>
 											</object>
-										</object>
-										<object class="NSButton" id="915448994">
-											<reference key="NSNextResponder" ref="596750588"/>
-											<int key="NSvFlags">256</int>
-											<string key="NSFrame">{{18, 69}, {402, 18}}</string>
-											<reference key="NSSuperview" ref="596750588"/>
-											<bool key="NSEnabled">YES</bool>
-											<object class="NSButtonCell" key="NSCell" id="117056849">
-												<int key="NSCellFlags">67239424</int>
-												<int key="NSCellFlags2">0</int>
-												<string key="NSContents">Click-through Inactive Windows</string>
-												<reference key="NSSupport" ref="463863101"/>
-												<reference key="NSControlView" ref="915448994"/>
-												<int key="NSButtonFlags">1211912703</int>
-												<int key="NSButtonFlags2">2</int>
-												<reference key="NSAlternateImage" ref="391434389"/>
-												<reference key="NSAlternateContents" ref="331740794"/>
-												<reference key="NSKeyEquivalent" ref="331740794"/>
-												<int key="NSPeriodicDelay">200</int>
-												<int key="NSPeriodicInterval">25</int>
+											<object class="NSButton" id="915448994">
+												<reference key="NSNextResponder" ref="596750588"/>
+												<int key="NSvFlags">256</int>
+												<string key="NSFrame">{{18, 69}, {402, 18}}</string>
+												<reference key="NSSuperview" ref="596750588"/>
+												<bool key="NSEnabled">YES</bool>
+												<object class="NSButtonCell" key="NSCell" id="117056849">
+													<int key="NSCellFlags">67239424</int>
+													<int key="NSCellFlags2">0</int>
+													<string key="NSContents">Click-through Inactive Windows</string>
+													<reference key="NSSupport" ref="463863101"/>
+													<reference key="NSControlView" ref="915448994"/>
+													<int key="NSButtonFlags">1211912703</int>
+													<int key="NSButtonFlags2">2</int>
+													<reference key="NSAlternateImage" ref="391434389"/>
+													<string key="NSAlternateContents"/>
+													<string key="NSKeyEquivalent"/>
+													<int key="NSPeriodicDelay">200</int>
+													<int key="NSPeriodicInterval">25</int>
+												</object>
 											</object>
-										</object>
-										<object class="NSTextField" id="707276799">
-											<reference key="NSNextResponder" ref="596750588"/>
-											<int key="NSvFlags">256</int>
-											<string key="NSFrame">{{33, 32}, {385, 31}}</string>
-											<reference key="NSSuperview" ref="596750588"/>
-											<bool key="NSEnabled">YES</bool>
-											<object class="NSTextFieldCell" key="NSCell" id="318286890">
-												<int key="NSCellFlags">67239424</int>
-												<int key="NSCellFlags2">4194304</int>
-												<string key="NSContents">When enabled, clicking on an inactive window will cause that mouse click to pass through to that window in addition to activating it.</string>
-												<reference key="NSSupport" ref="26"/>
-												<reference key="NSControlView" ref="707276799"/>
-												<reference key="NSBackgroundColor" ref="57160303"/>
-												<reference key="NSTextColor" ref="930815747"/>
+											<object class="NSTextField" id="707276799">
+												<reference key="NSNextResponder" ref="596750588"/>
+												<int key="NSvFlags">256</int>
+												<string key="NSFrame">{{33, 32}, {385, 31}}</string>
+												<reference key="NSSuperview" ref="596750588"/>
+												<bool key="NSEnabled">YES</bool>
+												<object class="NSTextFieldCell" key="NSCell" id="318286890">
+													<int key="NSCellFlags">67239424</int>
+													<int key="NSCellFlags2">4194304</int>
+													<string key="NSContents">When enabled, clicking on an inactive window will cause that mouse click to pass through to that window in addition to activating it.</string>
+													<reference key="NSSupport" ref="26"/>
+													<reference key="NSControlView" ref="707276799"/>
+													<reference key="NSBackgroundColor" ref="57160303"/>
+													<reference key="NSTextColor" ref="930815747"/>
+												</object>
 											</object>
 										</object>
+										<string key="NSFrame">{{10, 33}, {438, 279}}</string>
+										<reference key="NSSuperview" ref="448510093"/>
 									</object>
-									<string key="NSFrame">{{10, 33}, {438, 279}}</string>
-									<reference key="NSSuperview" ref="448510093"/>
-								</object>
-							</object>
-							<string key="NSFrame">{{10, 10}, {458, 325}}</string>
-							<reference key="NSSuperview" ref="941366957"/>
-							<object class="NSMutableArray" key="NSTabViewItems">
-								<bool key="EncodedWithXMLCoder">YES</bool>
-								<object class="NSTabViewItem" id="287591690">
-									<object class="NSMutableString" key="NSIdentifier">
-										<characters key="NS.bytes">1</characters>
-									</object>
-									<reference key="NSView" ref="596750588"/>
 									<string key="NSLabel">Input</string>
 									<reference key="NSColor" ref="57160303"/>
 									<reference key="NSTabView" ref="448510093"/>
@@ -688,8 +685,8 @@ ZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KA</string>
 													<int key="NSButtonFlags">1211912703</int>
 													<int key="NSButtonFlags2">2</int>
 													<reference key="NSAlternateImage" ref="391434389"/>
-													<reference key="NSAlternateContents" ref="331740794"/>
-													<reference key="NSKeyEquivalent" ref="331740794"/>
+													<string key="NSAlternateContents"/>
+													<string key="NSKeyEquivalent"/>
 													<int key="NSPeriodicDelay">200</int>
 													<int key="NSPeriodicInterval">25</int>
 												</object>
@@ -724,7 +721,7 @@ ZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KA</string>
 													<int key="NSButtonFlags">109199615</int>
 													<int key="NSButtonFlags2">1</int>
 													<object class="NSFont" key="NSAlternateImage">
-														<reference key="NSName" ref="512586816"/>
+														<string key="NSName">LucidaGrande</string>
 														<double key="NSSize">1.300000e+01</double>
 														<int key="NSfFlags">16</int>
 													</object>
@@ -739,12 +736,12 @@ ZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KA</string>
 													<object class="NSMenuItem" key="NSMenuItem" id="616492372">
 														<reference key="NSMenu" ref="341113515"/>
 														<string key="NSTitle">From Display</string>
-														<reference key="NSKeyEquiv" ref="331740794"/>
+														<string key="NSKeyEquiv"/>
 														<int key="NSKeyEquivModMask">1048576</int>
 														<int key="NSMnemonicLoc">2147483647</int>
 														<int key="NSState">1</int>
 														<reference key="NSOnImage" ref="531645050"/>
-														<reference key="NSMixedImage" ref="246283459"/>
+														<reference key="NSMixedImage" ref="351811234"/>
 														<string key="NSAction">_popUpItemAction:</string>
 														<int key="NSTag">-1</int>
 														<reference key="NSTarget" ref="633115429"/>
@@ -760,11 +757,11 @@ ZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KA</string>
 															<object class="NSMenuItem" id="759499526">
 																<reference key="NSMenu" ref="341113515"/>
 																<string key="NSTitle">256 Colors</string>
-																<reference key="NSKeyEquiv" ref="331740794"/>
+																<string key="NSKeyEquiv"/>
 																<int key="NSKeyEquivModMask">1048576</int>
 																<int key="NSMnemonicLoc">2147483647</int>
 																<reference key="NSOnImage" ref="531645050"/>
-																<reference key="NSMixedImage" ref="246283459"/>
+																<reference key="NSMixedImage" ref="351811234"/>
 																<string key="NSAction">_popUpItemAction:</string>
 																<int key="NSTag">8</int>
 																<reference key="NSTarget" ref="633115429"/>
@@ -772,11 +769,11 @@ ZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KA</string>
 															<object class="NSMenuItem" id="543935434">
 																<reference key="NSMenu" ref="341113515"/>
 																<string key="NSTitle">Thousands</string>
-																<reference key="NSKeyEquiv" ref="331740794"/>
+																<string key="NSKeyEquiv"/>
 																<int key="NSKeyEquivModMask">1048576</int>
 																<int key="NSMnemonicLoc">2147483647</int>
 																<reference key="NSOnImage" ref="531645050"/>
-																<reference key="NSMixedImage" ref="246283459"/>
+																<reference key="NSMixedImage" ref="351811234"/>
 																<string key="NSAction">_popUpItemAction:</string>
 																<int key="NSTag">15</int>
 																<reference key="NSTarget" ref="633115429"/>
@@ -784,11 +781,11 @@ ZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KA</string>
 															<object class="NSMenuItem" id="836673018">
 																<reference key="NSMenu" ref="341113515"/>
 																<string key="NSTitle">Millions</string>
-																<reference key="NSKeyEquiv" ref="331740794"/>
+																<string key="NSKeyEquiv"/>
 																<int key="NSKeyEquivModMask">1048576</int>
 																<int key="NSMnemonicLoc">2147483647</int>
 																<reference key="NSOnImage" ref="531645050"/>
-																<reference key="NSMixedImage" ref="246283459"/>
+																<reference key="NSMixedImage" ref="351811234"/>
 																<string key="NSAction">_popUpItemAction:</string>
 																<int key="NSTag">24</int>
 																<reference key="NSTarget" ref="633115429"/>
@@ -848,8 +845,8 @@ ZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KA</string>
 													<int key="NSButtonFlags">1211912703</int>
 													<int key="NSButtonFlags2">2</int>
 													<reference key="NSAlternateImage" ref="391434389"/>
-													<reference key="NSAlternateContents" ref="331740794"/>
-													<reference key="NSKeyEquivalent" ref="331740794"/>
+													<string key="NSAlternateContents"/>
+													<string key="NSKeyEquivalent"/>
 													<int key="NSPeriodicDelay">200</int>
 													<int key="NSPeriodicInterval">25</int>
 												</object>
@@ -898,8 +895,8 @@ ZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KA</string>
 													<int key="NSButtonFlags">1211912703</int>
 													<int key="NSButtonFlags2">2</int>
 													<reference key="NSAlternateImage" ref="391434389"/>
-													<reference key="NSAlternateContents" ref="331740794"/>
-													<reference key="NSKeyEquivalent" ref="331740794"/>
+													<string key="NSAlternateContents"/>
+													<string key="NSKeyEquivalent"/>
 													<int key="NSPeriodicDelay">200</int>
 													<int key="NSPeriodicInterval">25</int>
 												</object>
@@ -919,8 +916,8 @@ ZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KA</string>
 													<int key="NSButtonFlags">1211912703</int>
 													<int key="NSButtonFlags2">2</int>
 													<reference key="NSAlternateImage" ref="391434389"/>
-													<reference key="NSAlternateContents" ref="331740794"/>
-													<reference key="NSKeyEquivalent" ref="331740794"/>
+													<string key="NSAlternateContents"/>
+													<string key="NSKeyEquivalent"/>
 													<int key="NSPeriodicDelay">200</int>
 													<int key="NSPeriodicInterval">25</int>
 												</object>
@@ -988,11 +985,15 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 							<int key="NSTvFlags">0</int>
 							<bool key="NSAllowTruncatedLabels">YES</bool>
 							<bool key="NSDrawsBackground">YES</bool>
+							<object class="NSMutableArray" key="NSSubviews">
+								<bool key="EncodedWithXMLCoder">YES</bool>
+								<reference ref="596750588"/>
+							</object>
 						</object>
 					</object>
 					<string key="NSFrameSize">{481, 345}</string>
 				</object>
-				<string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
+				<string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
 				<string key="NSMinSize">{213, 129}</string>
 				<string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
 				<string key="NSFrameAutosaveName">x11_prefs</string>
@@ -1000,51 +1001,24 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 			<object class="NSWindowTemplate" id="604417141">
 				<int key="NSWindowStyleMask">11</int>
 				<int key="NSWindowBacking">2</int>
-				<string key="NSWindowRect">{{279, 253}, {486, 327}}</string>
+				<string key="NSWindowRect">{{537, 554}, {454, 311}}</string>
 				<int key="NSWTFlags">1350041600</int>
 				<string key="NSWindowTitle">X11 Application Menu</string>
-				<reference key="NSWindowClass" ref="666842945"/>
+				<string key="NSWindowClass">NSPanel</string>
 				<object class="NSMutableString" key="NSViewClass">
 					<characters key="NS.bytes">View</characters>
 				</object>
-				<string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string>
-				<string key="NSWindowContentMinSize">{213, 107}</string>
+				<string key="NSWindowContentMaxSize">{10000, 10000}</string>
+				<string key="NSWindowContentMinSize">{320, 240}</string>
 				<object class="NSView" key="NSWindowView" id="85544634">
-					<nil key="NSNextResponder"/>
+					<reference key="NSNextResponder"/>
 					<int key="NSvFlags">256</int>
 					<object class="NSMutableArray" key="NSSubviews">
 						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSButton" id="724002248">
-							<reference key="NSNextResponder" ref="85544634"/>
-							<int key="NSvFlags">303</int>
-							<string key="NSFrame">{{268, 12}, {84, 32}}</string>
-							<reference key="NSSuperview" ref="85544634"/>
-							<bool key="NSEnabled">YES</bool>
-							<object class="NSButtonCell" key="NSCell" id="809610613">
-								<int key="NSCellFlags">-2080244224</int>
-								<int key="NSCellFlags2">137887744</int>
-								<string key="NSContents">Done</string>
-								<reference key="NSSupport" ref="463863101"/>
-								<reference key="NSControlView" ref="724002248"/>
-								<int key="NSButtonFlags">-2038284033</int>
-								<int key="NSButtonFlags2">1</int>
-								<object class="NSFont" key="NSAlternateImage" id="549406736">
-									<string key="NSName">Helvetica</string>
-									<double key="NSSize">1.300000e+01</double>
-									<int key="NSfFlags">16</int>
-								</object>
-								<reference key="NSAlternateContents" ref="331740794"/>
-								<object class="NSMutableString" key="NSKeyEquivalent">
-									<characters key="NS.bytes"/>
-								</object>
-								<int key="NSPeriodicDelay">200</int>
-								<int key="NSPeriodicInterval">25</int>
-							</object>
-						</object>
 						<object class="NSButton" id="671954382">
 							<reference key="NSNextResponder" ref="85544634"/>
-							<int key="NSvFlags">301</int>
-							<string key="NSFrame">{{372, 247}, {100, 32}}</string>
+							<int key="NSvFlags">265</int>
+							<string key="NSFrame">{{340, 231}, {100, 32}}</string>
 							<reference key="NSSuperview" ref="85544634"/>
 							<bool key="NSEnabled">YES</bool>
 							<object class="NSButtonCell" key="NSCell" id="143554520">
@@ -1055,7 +1029,11 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 								<reference key="NSControlView" ref="671954382"/>
 								<int key="NSButtonFlags">-2038284033</int>
 								<int key="NSButtonFlags2">1</int>
-								<reference key="NSAlternateImage" ref="549406736"/>
+								<object class="NSFont" key="NSAlternateImage" id="549406736">
+									<string key="NSName">Helvetica</string>
+									<double key="NSSize">1.300000e+01</double>
+									<int key="NSfFlags">16</int>
+								</object>
 								<object class="NSMutableString" key="NSAlternateContents">
 									<characters key="NS.bytes"/>
 								</object>
@@ -1068,8 +1046,8 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 						</object>
 						<object class="NSButton" id="492358940">
 							<reference key="NSNextResponder" ref="85544634"/>
-							<int key="NSvFlags">301</int>
-							<string key="NSFrame">{{372, 215}, {100, 32}}</string>
+							<int key="NSvFlags">265</int>
+							<string key="NSFrame">{{340, 199}, {100, 32}}</string>
 							<reference key="NSSuperview" ref="85544634"/>
 							<bool key="NSEnabled">YES</bool>
 							<object class="NSButtonCell" key="NSCell" id="8201128">
@@ -1093,7 +1071,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 						</object>
 						<object class="NSScrollView" id="1063387772">
 							<reference key="NSNextResponder" ref="85544634"/>
-							<int key="NSvFlags">307</int>
+							<int key="NSvFlags">274</int>
 							<object class="NSMutableArray" key="NSSubviews">
 								<bool key="EncodedWithXMLCoder">YES</bool>
 								<object class="NSClipView" id="580565898">
@@ -1104,26 +1082,26 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 										<object class="NSTableView" id="905092943">
 											<reference key="NSNextResponder" ref="580565898"/>
 											<int key="NSvFlags">256</int>
-											<string key="NSFrameSize">{333, 197}</string>
+											<string key="NSFrameSize">{301, 198}</string>
 											<reference key="NSSuperview" ref="580565898"/>
 											<bool key="NSEnabled">YES</bool>
 											<object class="NSTableHeaderView" key="NSHeaderView" id="792419186">
 												<reference key="NSNextResponder" ref="672307654"/>
 												<int key="NSvFlags">256</int>
-												<string key="NSFrameSize">{333, 17}</string>
+												<string key="NSFrameSize">{301, 17}</string>
 												<reference key="NSSuperview" ref="672307654"/>
 												<reference key="NSTableView" ref="905092943"/>
 											</object>
 											<object class="_NSCornerView" key="NSCornerView" id="898633680">
 												<reference key="NSNextResponder" ref="1063387772"/>
 												<int key="NSvFlags">256</int>
-												<string key="NSFrame">{{334, 0}, {16, 17}}</string>
+												<string key="NSFrame">{{302, 0}, {16, 17}}</string>
 												<reference key="NSSuperview" ref="1063387772"/>
 											</object>
 											<object class="NSMutableArray" key="NSTableColumns">
 												<bool key="EncodedWithXMLCoder">YES</bool>
 												<object class="NSTableColumn" id="84282687">
-													<double key="NSWidth">1.110000e+02</double>
+													<double key="NSWidth">9.900000e+01</double>
 													<double key="NSMinWidth">4.000000e+01</double>
 													<double key="NSMaxWidth">1.000000e+03</double>
 													<object class="NSTableHeaderCell" key="NSHeaderCell">
@@ -1137,7 +1115,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 														</object>
 														<object class="NSColor" key="NSTextColor" id="249576247">
 															<int key="NSColorSpace">6</int>
-															<reference key="NSCatalogName" ref="905527164"/>
+															<string key="NSCatalogName">System</string>
 															<string key="NSColorName">headerTextColor</string>
 															<reference key="NSColor" ref="214098874"/>
 														</object>
@@ -1145,7 +1123,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 													<object class="NSTextFieldCell" key="NSDataCell" id="432610585">
 														<int key="NSCellFlags">338820672</int>
 														<int key="NSCellFlags2">1024</int>
-														<string key="NSContents" id="548220387">Text Cell</string>
+														<string key="NSContents">Text Cell</string>
 														<reference key="NSSupport" ref="463863101"/>
 														<reference key="NSControlView" ref="905092943"/>
 														<object class="NSColor" key="NSBackgroundColor" id="822946413">
@@ -1160,7 +1138,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 													<reference key="NSTableView" ref="905092943"/>
 												</object>
 												<object class="NSTableColumn" id="938444323">
-													<double key="NSWidth">1.327310e+02</double>
+													<double key="NSWidth">1.217310e+02</double>
 													<double key="NSMinWidth">6.273100e+01</double>
 													<double key="NSMaxWidth">1.000000e+03</double>
 													<object class="NSTableHeaderCell" key="NSHeaderCell">
@@ -1174,7 +1152,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 													<object class="NSTextFieldCell" key="NSDataCell" id="825378892">
 														<int key="NSCellFlags">338820672</int>
 														<int key="NSCellFlags2">1024</int>
-														<reference key="NSContents" ref="548220387"/>
+														<string key="NSContents">Text Cell</string>
 														<reference key="NSSupport" ref="463863101"/>
 														<reference key="NSControlView" ref="905092943"/>
 														<reference key="NSBackgroundColor" ref="822946413"/>
@@ -1186,7 +1164,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 													<reference key="NSTableView" ref="905092943"/>
 												</object>
 												<object class="NSTableColumn" id="242608782">
-													<double key="NSWidth">8.000000e+01</double>
+													<double key="NSWidth">7.100000e+01</double>
 													<double key="NSMinWidth">1.000000e+01</double>
 													<double key="NSMaxWidth">1.000000e+03</double>
 													<object class="NSTableHeaderCell" key="NSHeaderCell">
@@ -1196,7 +1174,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 														<reference key="NSSupport" ref="26"/>
 														<object class="NSColor" key="NSBackgroundColor">
 															<int key="NSColorSpace">6</int>
-															<reference key="NSCatalogName" ref="905527164"/>
+															<string key="NSCatalogName">System</string>
 															<string key="NSColorName">headerColor</string>
 															<reference key="NSColor" ref="822946413"/>
 														</object>
@@ -1205,9 +1183,9 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 													<object class="NSTextFieldCell" key="NSDataCell" id="34714764">
 														<int key="NSCellFlags">338820672</int>
 														<int key="NSCellFlags2">1024</int>
-														<reference key="NSContents" ref="548220387"/>
+														<string key="NSContents">Text Cell</string>
 														<object class="NSFont" key="NSSupport">
-															<reference key="NSName" ref="512586816"/>
+															<string key="NSName">LucidaGrande</string>
 															<double key="NSSize">1.200000e+01</double>
 															<int key="NSfFlags">16</int>
 														</object>
@@ -1215,7 +1193,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 														<bool key="NSDrawsBackground">YES</bool>
 														<object class="NSColor" key="NSBackgroundColor" id="812484075">
 															<int key="NSColorSpace">6</int>
-															<reference key="NSCatalogName" ref="905527164"/>
+															<string key="NSCatalogName">System</string>
 															<string key="NSColorName">controlBackgroundColor</string>
 															<reference key="NSColor" ref="590688762"/>
 														</object>
@@ -1232,7 +1210,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 											<reference key="NSBackgroundColor" ref="822946413"/>
 											<object class="NSColor" key="NSGridColor">
 												<int key="NSColorSpace">6</int>
-												<reference key="NSCatalogName" ref="905527164"/>
+												<string key="NSCatalogName">System</string>
 												<string key="NSColorName">gridColor</string>
 												<object class="NSColor" key="NSColor">
 													<int key="NSColorSpace">3</int>
@@ -1247,7 +1225,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 											<bool key="NSAllowsTypeSelect">YES</bool>
 										</object>
 									</object>
-									<string key="NSFrame">{{1, 17}, {333, 197}}</string>
+									<string key="NSFrame">{{1, 17}, {301, 198}}</string>
 									<reference key="NSSuperview" ref="1063387772"/>
 									<reference key="NSNextKeyView" ref="905092943"/>
 									<reference key="NSDocView" ref="905092943"/>
@@ -1257,20 +1235,20 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 								<object class="NSScroller" id="842897584">
 									<reference key="NSNextResponder" ref="1063387772"/>
 									<int key="NSvFlags">256</int>
-									<string key="NSFrame">{{334, 17}, {15, 197}}</string>
+									<string key="NSFrame">{{302, 17}, {15, 198}}</string>
 									<reference key="NSSuperview" ref="1063387772"/>
 									<reference key="NSTarget" ref="1063387772"/>
-									<string key="NSAction" id="365694962">_doScroller:</string>
+									<string key="NSAction">_doScroller:</string>
 									<double key="NSPercent">9.949238e-01</double>
 								</object>
 								<object class="NSScroller" id="17278747">
 									<reference key="NSNextResponder" ref="1063387772"/>
 									<int key="NSvFlags">256</int>
-									<string key="NSFrame">{{1, 214}, {333, 15}}</string>
+									<string key="NSFrame">{{1, 215}, {301, 15}}</string>
 									<reference key="NSSuperview" ref="1063387772"/>
 									<int key="NSsFlags">1</int>
 									<reference key="NSTarget" ref="1063387772"/>
-									<reference key="NSAction" ref="365694962"/>
+									<string key="NSAction">_doScroller:</string>
 									<double key="NSPercent">6.885246e-01</double>
 								</object>
 								<object class="NSClipView" id="672307654">
@@ -1280,7 +1258,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 										<bool key="EncodedWithXMLCoder">YES</bool>
 										<reference ref="792419186"/>
 									</object>
-									<string key="NSFrame">{{1, 0}, {333, 17}}</string>
+									<string key="NSFrame">{{1, 0}, {301, 17}}</string>
 									<reference key="NSSuperview" ref="1063387772"/>
 									<reference key="NSNextKeyView" ref="792419186"/>
 									<reference key="NSDocView" ref="792419186"/>
@@ -1289,7 +1267,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 								</object>
 								<reference ref="898633680"/>
 							</object>
-							<string key="NSFrame">{{20, 77}, {350, 230}}</string>
+							<string key="NSFrame">{{20, 60}, {318, 231}}</string>
 							<reference key="NSSuperview" ref="85544634"/>
 							<reference key="NSNextKeyView" ref="580565898"/>
 							<int key="NSsFlags">50</int>
@@ -1300,10 +1278,35 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 							<reference key="NSCornerView" ref="898633680"/>
 							<bytes key="NSScrollAmts">QSAAAEEgAABBmAAAQZgAAA</bytes>
 						</object>
+						<object class="NSButton" id="758204686">
+							<reference key="NSNextResponder" ref="85544634"/>
+							<int key="NSvFlags">265</int>
+							<string key="NSFrame">{{340, 263}, {100, 32}}</string>
+							<reference key="NSSuperview" ref="85544634"/>
+							<bool key="NSEnabled">YES</bool>
+							<object class="NSButtonCell" key="NSCell" id="1025474039">
+								<int key="NSCellFlags">-2080244224</int>
+								<int key="NSCellFlags2">137887744</int>
+								<string key="NSContents">Add Item</string>
+								<reference key="NSSupport" ref="463863101"/>
+								<reference key="NSControlView" ref="758204686"/>
+								<int key="NSButtonFlags">-2038284033</int>
+								<int key="NSButtonFlags2">1</int>
+								<reference key="NSAlternateImage" ref="549406736"/>
+								<object class="NSMutableString" key="NSAlternateContents">
+									<characters key="NS.bytes"/>
+								</object>
+								<object class="NSMutableString" key="NSKeyEquivalent">
+									<characters key="NS.bytes"/>
+								</object>
+								<int key="NSPeriodicDelay">200</int>
+								<int key="NSPeriodicInterval">25</int>
+							</object>
+						</object>
 						<object class="NSButton" id="125703429">
 							<reference key="NSNextResponder" ref="85544634"/>
-							<int key="NSvFlags">303</int>
-							<string key="NSFrame">{{352, 12}, {84, 32}}</string>
+							<int key="NSvFlags">257</int>
+							<string key="NSFrame">{{356, 12}, {84, 32}}</string>
 							<reference key="NSSuperview" ref="85544634"/>
 							<bool key="NSEnabled">YES</bool>
 							<object class="NSButtonCell" key="NSCell" id="892296813">
@@ -1325,24 +1328,22 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 								<int key="NSPeriodicInterval">25</int>
 							</object>
 						</object>
-						<object class="NSButton" id="758204686">
+						<object class="NSButton" id="724002248">
 							<reference key="NSNextResponder" ref="85544634"/>
-							<int key="NSvFlags">301</int>
-							<string key="NSFrame">{{372, 279}, {100, 32}}</string>
+							<int key="NSvFlags">257</int>
+							<string key="NSFrame">{{272, 12}, {84, 32}}</string>
 							<reference key="NSSuperview" ref="85544634"/>
 							<bool key="NSEnabled">YES</bool>
-							<object class="NSButtonCell" key="NSCell" id="1025474039">
-								<int key="NSCellFlags">67239424</int>
+							<object class="NSButtonCell" key="NSCell" id="809610613">
+								<int key="NSCellFlags">-2080244224</int>
 								<int key="NSCellFlags2">137887744</int>
-								<string key="NSContents">Add Item</string>
+								<string key="NSContents">Done</string>
 								<reference key="NSSupport" ref="463863101"/>
-								<reference key="NSControlView" ref="758204686"/>
+								<reference key="NSControlView" ref="724002248"/>
 								<int key="NSButtonFlags">-2038284033</int>
 								<int key="NSButtonFlags2">1</int>
 								<reference key="NSAlternateImage" ref="549406736"/>
-								<object class="NSMutableString" key="NSAlternateContents">
-									<characters key="NS.bytes"/>
-								</object>
+								<string key="NSAlternateContents"/>
 								<object class="NSMutableString" key="NSKeyEquivalent">
 									<characters key="NS.bytes"/>
 								</object>
@@ -1351,11 +1352,11 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 							</object>
 						</object>
 					</object>
-					<string key="NSFrameSize">{486, 327}</string>
+					<string key="NSFrameSize">{454, 311}</string>
+					<reference key="NSSuperview"/>
 				</object>
-				<string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
-				<string key="NSMinSize">{213, 129}</string>
-				<string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
+				<string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
+				<string key="NSMinSize">{320, 262}</string>
 				<string key="NSFrameAutosaveName">x11_apps</string>
 			</object>
 			<object class="NSMenu" id="294137138">
@@ -1366,51 +1367,51 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 						<reference key="NSMenu" ref="294137138"/>
 						<bool key="NSIsDisabled">YES</bool>
 						<bool key="NSIsSeparator">YES</bool>
-						<reference key="NSTitle" ref="331740794"/>
-						<reference key="NSKeyEquiv" ref="331740794"/>
+						<string key="NSTitle"/>
+						<string key="NSKeyEquiv"/>
 						<int key="NSKeyEquivModMask">1048576</int>
 						<int key="NSMnemonicLoc">2147483647</int>
 						<reference key="NSOnImage" ref="531645050"/>
-						<reference key="NSMixedImage" ref="246283459"/>
+						<reference key="NSMixedImage" ref="351811234"/>
 					</object>
 					<object class="NSMenuItem" id="511651072">
 						<reference key="NSMenu" ref="294137138"/>
-						<reference key="NSTitle" ref="667842658"/>
-						<reference key="NSKeyEquiv" ref="331740794"/>
+						<string key="NSTitle">Applications</string>
+						<string key="NSKeyEquiv"/>
 						<int key="NSKeyEquivModMask">1048576</int>
 						<int key="NSMnemonicLoc">2147483647</int>
 						<reference key="NSOnImage" ref="531645050"/>
-						<reference key="NSMixedImage" ref="246283459"/>
+						<reference key="NSMixedImage" ref="351811234"/>
 						<string key="NSAction">submenuAction:</string>
 						<object class="NSMenu" key="NSSubmenu" id="48278059">
-							<reference key="NSTitle" ref="667842658"/>
+							<string key="NSTitle">Applications</string>
 							<object class="NSMutableArray" key="NSMenuItems">
 								<bool key="EncodedWithXMLCoder">YES</bool>
 								<object class="NSMenuItem" id="563798000">
 									<reference key="NSMenu" ref="48278059"/>
 									<bool key="NSIsDisabled">YES</bool>
 									<bool key="NSIsSeparator">YES</bool>
-									<reference key="NSTitle" ref="331740794"/>
-									<reference key="NSKeyEquiv" ref="331740794"/>
+									<string key="NSTitle"/>
+									<string key="NSKeyEquiv"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="246283459"/>
+									<reference key="NSMixedImage" ref="351811234"/>
 								</object>
 								<object class="NSMenuItem" id="1032342329">
 									<reference key="NSMenu" ref="48278059"/>
 									<string type="base64-UTF8" key="NSTitle">Q3VzdG9taXpl4oCmA</string>
-									<reference key="NSKeyEquiv" ref="331740794"/>
+									<string key="NSKeyEquiv"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
 									<reference key="NSOnImage" ref="531645050"/>
-									<reference key="NSMixedImage" ref="246283459"/>
+									<reference key="NSMixedImage" ref="351811234"/>
 								</object>
 							</object>
 						</object>
 					</object>
 				</object>
-				<reference key="NSName" ref="331740794"/>
+				<string key="NSName"/>
 			</object>
 		</object>
 		<object class="IBObjectContainer" key="IBDocument.Objects">
@@ -1554,7 +1555,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
-						<string key="label" id="75505755">apps_table_show:</string>
+						<string key="label">apps_table_show:</string>
 						<reference key="source" ref="485884620"/>
 						<reference key="destination" ref="1065386165"/>
 					</object>
@@ -1650,7 +1651,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
-						<string key="label" id="582333102">prefs_changed:</string>
+						<string key="label">prefs_changed:</string>
 						<reference key="source" ref="485884620"/>
 						<reference key="destination" ref="119157981"/>
 					</object>
@@ -1658,7 +1659,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
-						<reference key="label" ref="582333102"/>
+						<string key="label">prefs_changed:</string>
 						<reference key="source" ref="485884620"/>
 						<reference key="destination" ref="179949713"/>
 					</object>
@@ -1666,7 +1667,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
-						<reference key="label" ref="582333102"/>
+						<string key="label">prefs_changed:</string>
 						<reference key="source" ref="485884620"/>
 						<reference key="destination" ref="842100515"/>
 					</object>
@@ -1674,7 +1675,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
-						<reference key="label" ref="582333102"/>
+						<string key="label">prefs_changed:</string>
 						<reference key="source" ref="485884620"/>
 						<reference key="destination" ref="418227126"/>
 					</object>
@@ -1682,7 +1683,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
-						<reference key="label" ref="582333102"/>
+						<string key="label">prefs_changed:</string>
 						<reference key="source" ref="485884620"/>
 						<reference key="destination" ref="709074847"/>
 					</object>
@@ -1690,7 +1691,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
-						<reference key="label" ref="582333102"/>
+						<string key="label">prefs_changed:</string>
 						<reference key="source" ref="485884620"/>
 						<reference key="destination" ref="989050925"/>
 					</object>
@@ -1698,7 +1699,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
-						<reference key="label" ref="582333102"/>
+						<string key="label">prefs_changed:</string>
 						<reference key="source" ref="485884620"/>
 						<reference key="destination" ref="700826966"/>
 					</object>
@@ -1786,7 +1787,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
-						<reference key="label" ref="75505755"/>
+						<string key="label">apps_table_show:</string>
 						<reference key="source" ref="485884620"/>
 						<reference key="destination" ref="1032342329"/>
 					</object>
@@ -1842,7 +1843,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
-						<reference key="label" ref="582333102"/>
+						<string key="label">prefs_changed:</string>
 						<reference key="source" ref="485884620"/>
 						<reference key="destination" ref="915448994"/>
 					</object>
@@ -1922,7 +1923,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 							<reference ref="551174276"/>
 						</object>
 						<reference key="parent" ref="330408435"/>
-						<reference key="objectName" ref="121567387"/>
+						<string key="objectName">MainMenu</string>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">19</int>
@@ -2209,7 +2210,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 						<int key="objectID">196</int>
 						<reference key="object" ref="485884620"/>
 						<reference key="parent" ref="330408435"/>
-						<reference key="objectName" ref="865849805"/>
+						<string key="objectName">X11Controller</string>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">244</int>
@@ -2935,18 +2936,21 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 					<string>270.editorWindowContentRectSynchronizationRect</string>
 					<string>272.IBPluginDependency</string>
 					<string>272.ImportedFromIB2</string>
+					<string>285.IBEditorWindowLastContentRect</string>
 					<string>285.IBPluginDependency</string>
 					<string>285.IBViewEditorWindowController.showingBoundsRectangles</string>
 					<string>285.IBViewEditorWindowController.showingLayoutRectangles</string>
 					<string>285.IBWindowTemplateEditedContentRect</string>
 					<string>285.ImportedFromIB2</string>
 					<string>285.editorWindowContentRectSynchronizationRect</string>
+					<string>285.lastResizeAction</string>
 					<string>285.windowTemplate.hasMaxSize</string>
 					<string>285.windowTemplate.hasMinSize</string>
 					<string>285.windowTemplate.maxSize</string>
 					<string>285.windowTemplate.minSize</string>
 					<string>286.IBPluginDependency</string>
 					<string>286.ImportedFromIB2</string>
+					<string>29.IBEditorWindowLastContentRect</string>
 					<string>29.IBPluginDependency</string>
 					<string>29.ImportedFromIB2</string>
 					<string>29.editorWindowContentRectSynchronizationRect</string>
@@ -3087,231 +3091,246 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 				</object>
 				<object class="NSMutableArray" key="dict.values">
 					<bool key="EncodedWithXMLCoder">YES</bool>
-					<reference ref="1013584587"/>
-					<reference ref="1013584587"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<integer value="1" id="9"/>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
 					<string>{{202, 626}, {154, 153}}</string>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
 					<string>{{271, 666}, {301, 153}}</string>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<string>{{184, 290}, {481, 345}}</string>
 					<reference ref="9"/>
 					<string>{{184, 290}, {481, 345}}</string>
 					<reference ref="9"/>
 					<reference ref="9"/>
-					<string id="169660368">{3.40282e+38, 3.40282e+38}</string>
-					<string id="432763037">{213, 107}</string>
-					<reference ref="1013584587"/>
+					<string>{3.40282e+38, 3.40282e+38}</string>
+					<string>{213, 107}</string>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
 					<string>{{100, 746}, {155, 33}}</string>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>{{537, 554}, {454, 311}}</string>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
 					<reference ref="9"/>
-					<string id="678991548">{{433, 406}, {486, 327}}</string>
-					<reference ref="9"/>
-					<reference ref="678991548"/>
+					<string>{{537, 554}, {454, 311}}</string>
 					<reference ref="9"/>
+					<string>{{433, 406}, {486, 327}}</string>
+					<object class="NSDictionary">
+						<bool key="EncodedWithXMLCoder">YES</bool>
+						<object class="NSMutableArray" key="dict.sortedKeys">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<string>IBResizeActionFinalFrame</string>
+							<string>IBResizeActionInitialFrame</string>
+						</object>
+						<object class="NSMutableArray" key="dict.values">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<string>{{537, 554}, {454, 311}}</string>
+							<string>{{537, 576}, {471, 289}}</string>
+						</object>
+					</object>
+					<integer value="0"/>
 					<reference ref="9"/>
-					<reference ref="169660368"/>
-					<reference ref="432763037"/>
-					<reference ref="1013584587"/>
+					<string>{3.40282e+38, 3.40282e+38}</string>
+					<string>{320, 240}</string>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>{{0, 1114}, {336, 20}}</string>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
 					<string>{{67, 819}, {336, 20}}</string>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
 					<string>{{79, 616}, {218, 203}}</string>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
-					<reference ref="1013584587"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
 				</object>
 			</object>
@@ -3341,29 +3360,17 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 			<object class="NSMutableArray" key="referencedPartialClassDescriptions">
 				<bool key="EncodedWithXMLCoder">YES</bool>
 				<object class="IBPartialClassDescription">
-					<reference key="className" ref="671773319"/>
-					<nil key="superclassName"/>
-					<object class="NSMutableDictionary" key="actions">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSArray" key="dict.sortedKeys">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-						</object>
-						<object class="NSMutableArray" key="dict.values">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-						</object>
-					</object>
-					<object class="NSMutableDictionary" key="outlets">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSArray" key="dict.sortedKeys">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-						</object>
-						<object class="NSMutableArray" key="dict.values">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-						</object>
+					<string key="className">FirstResponder</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBUserSource</string>
+						<string key="minorKey"/>
 					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">NSFormatter</string>
 					<object class="IBClassDescriptionSource" key="sourceIdentifier">
-						<string key="majorKey" id="360524387">IBUserSource</string>
-						<reference key="minorKey" ref="331740794"/>
+						<string key="majorKey">IBUserSource</string>
+						<string key="minorKey"/>
 					</object>
 				</object>
 				<object class="IBPartialClassDescription">
@@ -3394,24 +3401,24 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 						</object>
 						<object class="NSMutableArray" key="dict.values">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string id="678582588">id</string>
-							<reference ref="678582588"/>
-							<reference ref="678582588"/>
-							<reference ref="678582588"/>
-							<reference ref="678582588"/>
-							<reference ref="678582588"/>
-							<reference ref="678582588"/>
-							<reference ref="678582588"/>
-							<reference ref="678582588"/>
-							<reference ref="678582588"/>
-							<reference ref="678582588"/>
-							<reference ref="678582588"/>
-							<reference ref="678582588"/>
-							<reference ref="678582588"/>
-							<reference ref="678582588"/>
-							<reference ref="678582588"/>
-							<reference ref="678582588"/>
-							<reference ref="678582588"/>
+							<string>id</string>
+							<string>id</string>
+							<string>id</string>
+							<string>id</string>
+							<string>id</string>
+							<string>id</string>
+							<string>id</string>
+							<string>id</string>
+							<string>id</string>
+							<string>id</string>
+							<string>id</string>
+							<string>id</string>
+							<string>id</string>
+							<string>id</string>
+							<string>id</string>
+							<string>id</string>
+							<string>id</string>
+							<string>id</string>
 						</object>
 					</object>
 					<object class="NSMutableDictionary" key="outlets">
@@ -3439,24 +3446,24 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 						</object>
 						<object class="NSMutableArray" key="dict.values">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string id="133216019">NSMenuItem</string>
+							<string>NSMenuItem</string>
 							<string>NSTableView</string>
-							<string id="623744785">NSButton</string>
+							<string>NSButton</string>
 							<string>NSPopUpButton</string>
-							<string id="455827649">NSMenu</string>
-							<reference ref="455827649"/>
-							<reference ref="133216019"/>
-							<reference ref="623744785"/>
-							<reference ref="623744785"/>
-							<reference ref="623744785"/>
-							<reference ref="623744785"/>
-							<reference ref="623744785"/>
+							<string>NSMenu</string>
+							<string>NSMenu</string>
+							<string>NSMenuItem</string>
+							<string>NSButton</string>
+							<string>NSButton</string>
+							<string>NSButton</string>
+							<string>NSButton</string>
+							<string>NSButton</string>
 							<string>NSPanel</string>
-							<reference ref="623744785"/>
-							<reference ref="133216019"/>
-							<reference ref="623744785"/>
-							<reference ref="133216019"/>
-							<reference ref="133216019"/>
+							<string>NSButton</string>
+							<string>NSMenuItem</string>
+							<string>NSButton</string>
+							<string>NSMenuItem</string>
+							<string>NSMenuItem</string>
 						</object>
 					</object>
 					<object class="IBClassDescriptionSource" key="sourceIdentifier">
@@ -3464,628 +3471,10 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 						<string key="minorKey"/>
 					</object>
 				</object>
-				<object class="IBPartialClassDescription">
-					<string key="className">NSFormatter</string>
-					<nil key="superclassName"/>
-					<object class="NSMutableDictionary" key="actions">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSArray" key="dict.sortedKeys">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-						</object>
-						<object class="NSMutableArray" key="dict.values">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-						</object>
-					</object>
-					<object class="NSMutableDictionary" key="outlets">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSArray" key="dict.sortedKeys">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-						</object>
-						<object class="NSMutableArray" key="dict.values">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-						</object>
-					</object>
-					<object class="IBClassDescriptionSource" key="sourceIdentifier">
-						<reference key="majorKey" ref="360524387"/>
-						<reference key="minorKey" ref="331740794"/>
-					</object>
-				</object>
 			</object>
 		</object>
 		<int key="IBDocument.localizationMode">0</int>
 		<nil key="IBDocument.LastKnownRelativeProjectPath"/>
 		<int key="IBDocument.defaultPropertyAccessControl">3</int>
-		<object class="NSMutableData" key="IBDocument.RunnableNib">
-			<bytes key="NS.bytes">YnBsaXN0MDDUAAEAAgADAAQABQAGAAkAClgkdmVyc2lvblQkdG9wWSRhcmNoaXZlclgkb2JqZWN0cxIA
-AYag0QAHAAhdSUIub2JqZWN0ZGF0YYABXxAPTlNLZXllZEFyY2hpdmVyrxEDQgALAAwAMQA1ADkAQABD
-AEQASABMAIkAkQCZAJoAnwCyALMAuAC5ALoAvQDBAMIAxQDQANEA0gDWANsA5ADrAOwA8ADyAPMA9wD8
-AQoBEgETAS0BLgE1ATYBOQE9AT4BQAFCAUYBTAFPAVABUQFUAVkBYAFlAWYBZwFsAXMBeAF5AXoBewGA
-AYcBjQGOAZkBmgGeAZ8BogGjAagBrwGwAbgBuQG6Ab8BwAHFAcwB0QHSAekB7AHuAfAB/QIBAgICAwIG
-Ag0CFwICAhgCIgICAiMCLQICAi4CMgI1AjYCOwJDAkQCRQJKAlMCVwJYAl0CZAJlAm0CbgJzAnsCfAJ9
-An4CgwKIAo8ClAKVAp0CngKjAqoCqwKzArQCuQLBAsICwwLEAskC0QLSAtMC1ALZAtoC3wLgAuQC6wLv
-AvAC8QL1AvwC/QL+Av8DBAMJAwoDEgMbANEDHAMrAzIDMwM0Az0DRgDRA0cDTANOA1EDUgNbA2QDawNs
-A20DdAN1A34DhQOGA4cDiADRA5EDlgOdA54DpwDRA6gDswO6A7sDvAPDA8QDxQPOA9UD1gPXA94D3wPg
-A+cD6APxANED8gP0BAAEBwQIBAkEEAQRBBoEIwQqBCsENAQ1BD4A0QQ/BEMERwROBE8EUARRBFYEWwRi
-BGMEawRsBG0EcgRzBHgEfwSABIgEiQSLBI0EjgSSBJMEmASZBJ4EnwSkBMAEwQTCBMMExgTHBMgEzQTR
-BOEE5QTwBPcE+AUCBQMFCAUSBRMFFAUYBRoFHwUgBSMFJgUpBTAFMQU4BTkFQAVBBUgFSQVQBVEFWAVZ
-BVoFXAVdBWMFbAVvBXAFcwV6BX0FhwWOBY8FlwWYBZ8FoAWnBagFrwWwBbcFuAW/BcAFxwXIBc8F0AXX
-BVkF2AXZBd8F5wKqBe4F9gX3Bf4F/wYGBgcGDgYPBhYGFwYeBh8GJgVZBicGKAYqBisGLATGBi0GLgYx
-BjIGNwY4Bj0GPgZDBkQGSQZKBk8GVwZYBmEGYgZkBmYGZwZsBnEGcgZ2BncGfAaDBoQGjAaNBo8GkQaS
-BpcGmAadBrgGxwbIBs8G2AbZBtwG4Qb2BvcG+gcABxIHGQcaBx0HIgcjByYHLgcvBzIHNQc+B0QHRQdM
-B1UHWwdcB2EHYgdqB24Hcwd0B3kHegd9B38HgAeFB4YHiweMB5EHkgeXB5sHnAehB6IHpwesB60HsQey
-B7cHuAe9B74HwwfEB8kHygfPB9AH1AfVB9oH2wfgB+cH6AfwB/EH8wf0CHgIgAiECIUIiAiRCJIIkwiW
-CJ4InwijCKQIpQioCLYItwi4BMYExwi6CMMGKwYsBMYIxAjFADgIyAjKCU4J0wpYClkKWgpbClwKXQpe
-Cl8KYAphCmIKYwpkCmUKZgpnCmgKaQpqCmsKbAptCm4KbwpwCnEKcgpzCnQKdQp2CncKeAp5CnoKewp8
-Cn0Kfgp/CoAKgQqCCoMKhAqFCoYKhwqICokKigqLBMUKjAqNCo4KjwqQCpEKkgqTCpQKlQqWCpcKmAqZ
-CpoKmwqcCp0KngqfCqAKoQqiCqMKpAqlCqYKpwqoCqkKqgqrCqwKrQquCq8KsAqxCrIKswq0CrUKtgq3
-CrgKuQq6CrsKvAq9Cr4KvwrACsEKwgrDCsQKxQrGCscKyArJCsoKywrMCs0KzgrPCtAK0QrSCtMK1ArV
-CtYK1wraCt0LnAxbDFwMXQxeDF8MYAxhDGIMYwxkDGUMZgxnDGgMaQxqDGsMbAxtDG4MbwxwDHEMcgxz
-DHQMdQx2DHcMeAx5DHoMewx8DH0Mfgx/DIAMgQyCDIMMhAyFDIYMhwyIDIkMigyLDIwMjQyODI8MkAyR
-DJIMkwyUDJUMlgyXDJgMmQyaDJsMnAydDJ4MnwygDKEMogyjDKQMpQymDKcMqAypDKoMqwysDK0Mrgyv
-DLAMsQyyDLMMtAy1DLYMtwy4DLkMugy7DLwMvQy+DL8MwAzBDMIMwwzEDMUMxgzHDMgMyQzKDMsMzAzN
-AiwMzgzPDNAM0QzSDNMM1AzVDNYM1wzYDNkM2gzbDNwM3QzeDN8M4AzhDOIM4wzkDOUM5gznDOgM6Qzq
-DOsM7AztDO4M7wzwDPEM8gzzDPQM9Qz2DPcM+Az5DPoBBwz7DPwM/Qz+DP8NAA0BDQINAw0EDQUGVA0G
-DQcNCA0JDQoNCw0MDQ0NDg0PDRANEQ0SDRMNFA0XDRoNHVUkbnVsbN8QEgANAA4ADwAQABEAEgATABQA
-FQAWABcAGAAZABoAGwAcAB0AHgAfACAAIQAiACMAJAAlACYAJwAoACkAKgArACwALQAuAC8AMFZOU1Jv
-b3RWJGNsYXNzXU5TT2JqZWN0c0tleXNfEA9OU0NsYXNzZXNWYWx1ZXNfEBlOU0FjY2Vzc2liaWxpdHlP
-aWRzVmFsdWVzXU5TQ29ubmVjdGlvbnNbTlNOYW1lc0tleXNbTlNGcmFtZXdvcmtdTlNDbGFzc2VzS2V5
-c1pOU09pZHNLZXlzXU5TTmFtZXNWYWx1ZXNfEBlOU0FjY2Vzc2liaWxpdHlDb25uZWN0b3JzXU5TRm9u
-dE1hbmFnZXJfEBBOU1Zpc2libGVXaW5kb3dzXxAPTlNPYmplY3RzVmFsdWVzXxAXTlNBY2Nlc3NpYmls
-aXR5T2lkc0tleXNZTlNOZXh0T2lkXE5TT2lkc1ZhbHVlc4ACgQNBgQHdgQJ/gQNAgAmBAfyABoECfoEC
-gIEB/YEDPoAAgAeBAfuBAz8SAASVMIECgdIADgAyADMANFtOU0NsYXNzTmFtZYAFgAPSAA4ANgA3ADhZ
-TlMuc3RyaW5ngARdTlNBcHBsaWNhdGlvbtIAOgA7ADwAPVgkY2xhc3Nlc1okY2xhc3NuYW1lowA9AD4A
-P18QD05TTXV0YWJsZVN0cmluZ1hOU1N0cmluZ1hOU09iamVjdNIAOgA7AEEAQqIAQgA/Xk5TQ3VzdG9t
-T2JqZWN0XxAQSUJDb2NvYUZyYW1ld29ya9IADgBFAEYAR1pOUy5vYmplY3RzgAig0gA6ADsASQBKowBK
-AEsAP1xOU011dGFibGVTZXRVTlNTZXTSAA4ARQBNAE6AH68QOgBPAFAAUQBSAFMAVABVAFYAVwBYAFkA
-WgBbAFwAXQBeAF8AYABhAGIAYwBkAGUAZgBnAGgAaQBqAGsAbABtAG4AbwBwAHEAcgBzAHQAdQB2AHcA
-eAB5AHoAewB8AH0AfgB/AIAAgQCCAIMAhACFAIYAhwCIgAqAI4A2gDuAQYBLgFGAU4BtgHGAdYB6gH+A
-gICGgIuAkICVgJeAmYCegKOA84D0gPqA/IEBBIEBBoEBCIEBCoEBb4EBcYEBc4EBdYEBd4EBf4EBgIEB
-goEBhIEBjIEBjoEBuIEBuoEBvIEBvoEBv4EBwYEBw4EBxIEBxoEByIEByoEBzIEBzoEB0IEB0oEB1IEB
-1tQADgCKAIsAjACNAI4AHwCQXU5TRGVzdGluYXRpb25YTlNTb3VyY2VXTlNMYWJlbIAigAuAAoAh1AAO
-AJIAkwCUAJUAlgCXAJhXTlNUaXRsZVZOU05hbWVbTlNNZW51SXRlbXOAIIAMgA+ADVRNZW510gAOAEUA
-TQCcgB+iAJ0AnoAOgBfaAA4AkgCgAKEAogCjAKQApQCmAKcAqACXAKoAqwCXAKsArgCvALAAjl8QEU5T
-S2V5RXF1aXZNb2RNYXNrXU5TSXNTZXBhcmF0b3JaTlNLZXlFcXVpdlxOU0lzRGlzYWJsZWRdTlNNbmVt
-b25pY0xvY1lOU09uSW1hZ2VcTlNNaXhlZEltYWdlVk5TTWVudYAWgA8SABAAAAmADwkSf////4AQgBSA
-C1DTAA4AMgC0ALUAtgC3Xk5TUmVzb3VyY2VOYW1lgBOAEYASV05TSW1hZ2VfEA9OU01lbnVDaGVja21h
-cmvSADoAOwC7ALyiALwAP18QEE5TQ3VzdG9tUmVzb3VyY2XTAA4AMgC0ALUAtgDAgBOAEYAVXxAQTlNN
-ZW51TWl4ZWRTdGF0ZdIAOgA7AMMAxKIAxAA/Wk5TTWVudUl0ZW3aAA4AxgCSAKAAogCkAKUApgCnAMcA
-qADJAMoAqgCXAK4ArwCwAI4Az1lOU1N1Ym1lbnVYTlNBY3Rpb26AFoAagBiAD4AQgBSAC4AZXEFwcGxp
-Y2F0aW9uc15zdWJtZW51QWN0aW9uOtMADgCSAJQAlQDKANWAIIAYgBvSAA4ARQBNANiAH6IA2QDagByA
-HdoADgCSAKAAoQCiAKMApAClAKYApwCoAJcAqgCrAJcAqwCuAK8AsADJgBaADwmADwmAEIAUgBrYAA4A
-kgCgAKIApAClAKYApwCoAOYAqgCXAK4ArwCwAMmAFoAegA+AEIAUgBpqAEMAdQBzAHQAbwBtAGkAegBl
-ICbSADoAOwDtAO6jAO4A7wA/Xk5TTXV0YWJsZUFycmF5V05TQXJyYXnSADoAOwDxAKeiAKcAP1hkb2Nr
-TWVuddIAOgA7APQA9aMA9QD2AD9fEBROU05pYk91dGxldENvbm5lY3Rvcl5OU05pYkNvbm5lY3RvctQA
-DgCKAIsAjAD4APkA+gD7gDWAMoAkgDTXAP0ADgD+AP8BAAEBAQIBAwEEAQUBBgEHAKsBA18QD05TTmV4
-dFJlc3BvbmRlcldOU0ZyYW1lVk5TQ2VsbFhOU3ZGbGFnc1lOU0VuYWJsZWRbTlNTdXBlcnZpZXeAJYAx
-gCaAJxEBLQmAJdUA/QAOAQsBAAEMACsBDgEPARABEVpOU1N1YnZpZXdzW05TRnJhbWVTaXplgACBATOB
-AfIRAQCBAfNfEBd7ezM3MiwgMjc5fSwgezEwMCwgMzJ9fd0BFAAOARUBFgEXARgBGQEaARsBHAEdAR4B
-HwEgASEBIgEjASQBJQEmAScBKAD6ASoBKwEsW05TQ2VsbEZsYWdzXxATTlNBbHRlcm5hdGVDb250ZW50
-c18QEk5TUGVyaW9kaWNJbnRlcnZhbF5OU0J1dHRvbkZsYWdzMl8QEE5TQWx0ZXJuYXRlSW1hZ2VfEA9O
-U0tleUVxdWl2YWxlbnRaTlNDb250ZW50c1lOU1N1cHBvcnRdTlNDb250cm9sVmlld18QD05TUGVyaW9k
-aWNEZWxheVxOU0NlbGxGbGFnczJdTlNCdXR0b25GbGFncxIEAf4AgDCALhAZEAGALIAvgCiAKYAkEMgS
-CDgAABP/////hoJA/1hBZGQgSXRlbdQADgEvAJMBMAExATIBMwE0Vk5TU2l6ZVhOU2ZGbGFnc4ArI0Aq
-AAAAAAAAgCoRBBRcTHVjaWRhR3JhbmRl0gA6ADsBNwE4ogE4AD9WTlNGb2501AAOAS8AkwEwATEBMgE7
-ATyAK4AtEBBZSGVsdmV0aWNh0gAOADYANwCygATSAA4ANgA3ALKABNIAOgA7AUMBRKQBRAFFAP8AP1xO
-U0J1dHRvbkNlbGxcTlNBY3Rpb25DZWxs0gA6ADsBRwFIpQFIAUkBSgFLAD9YTlNCdXR0b25ZTlNDb250
-cm9sVk5TVmlld1tOU1Jlc3BvbmRlctIADgAyADMBToAFgDNdWDExQ29udHJvbGxlcl8QD2FwcHNfdGFi
-bGVfbmV3OtIAOgA7AVIBU6MBUwD2AD9fEBVOU05pYkNvbnRyb2xDb25uZWN0b3LUAA4AigCLAIwA+AAf
-AVcBWIA1gAKAN4A61wAOAJIAogCkAKUApgCnAKgBWwCXAK4ArwCwAV+AFoA5gA+AEIAUgDjUAA4AkgCT
-AJQAlQFiAWMBZIAggKiAwYCqWUFib3V0IFgxMV8QHW9yZGVyRnJvbnRTdGFuZGFyZEFib3V0UGFuZWw6
-1AAOAIoAiwCMAPgA+QFqAWuANYAygDyAQNgADgCSAKAAogCkAKUApgCnAKgBbgCqAW8ArgCvALABcoAW
-gD6AP4AQgBSAPdQADgCSAJMAlACVAXUBdgF3gCCA3YDpgN5VQ2xvc2VRd11jbG9zZV93aW5kb3c61AAO
-AIoAiwCMAI0BfQD5AX+AIoBCgDKAStcA/QAOAP4A/wEAAQEBAgGBAQQBgwGEARAAqwGBgEOAMYBEgEUJ
-gEPWAP0ADgD+AQsBAAECAYgBDgGKAYsBEAGIgQEUgQEzgQEygQEWgQEUXxAWe3sxOCwgMTMwfSwgezQw
-MiwgMTh9fd0BFAAOARUBFgEXARgBGQEaARsBHAEdAR4BHwEgASEAlwEjAZEBkgCXAZQBKAF9ASoBlwGY
-gDCADxACgEeAD4BGgCmAQhAAEkg8Uf9fECBFbmFibGUga2V5IGVxdWl2YWxlbnRzIHVuZGVyIFgxMdIA
-DgGbAZwBnVtOU0ltYWdlTmFtZYBJgEhYTlNTd2l0Y2jSADoAOwGgAaGiAaEAP18QE05TQnV0dG9uSW1h
-Z2VTb3VyY2VfEBBlbmFibGVfa2V5ZXF1aXZz1AAOAIoAiwCMAPgA+QGmAaeANYAygEyAUNcA/QAOAP4A
-/wEAAQEBAgGBAQQBqwGsARAAqwGBgEOAMYBNgE4JgENfEBZ7ezE4LCAxNzl9LCB7NDAyLCAxOH193QEU
-AA4BFQEWARcBGAEZARoBGwEcAR0BHgEfASABIQCXASMBkQGSAJcBtQEoAaYBKgGXAZiAMIAPgEeAD4BP
-gCmATF8QHUZvbGxvdyBzeXN0ZW0ga2V5Ym9hcmQgbGF5b3V0XnByZWZzX2NoYW5nZWQ61AAOAIoAiwCM
-AI0AjgD5Ab6AIoALgDKAUllkb2NrX21lbnXUAA4AigCLAIwAjQHCAPkBxIAigFSAMoBs1wD9AA4A/gD/
-AQABAQECAcYBxwHIAckBEACrAcaAVYBrgFaAVwmAVdUA/QAOAP4BCwEAACsBDgHPAdABEIAAgQEzgQFR
-gQE8XxAWe3s3NCwgMjM1fSwgezEyOCwgMjZ9fd8QEwEUAdMB1AEVARYADgEXARgBGQEbAMQBHAHVAdYB
-1wEdAR4ApwEfAdgAqwEkAdoB2wHcASQB3QHeASgB4AHCAeIAqwCrAeUB5gHnAehfEBpOU01lbnVJdGVt
-UmVzcGVjdEFsaWdubWVudF8QD05TQXJyb3dQb3NpdGlvbl8QD05TUHJlZmVycmVkRWRnZV8QEk5TVXNl
-c0l0ZW1Gcm9tTWVudV1OU0FsdGVyc1N0YXRlE/////+EQf5ACYBZEEuAaoBYgFqAKYBbgFQQAwkJEQGQ
-EQQAgFwSBoJA/9QADgEvAJMBMAExATIBMwE8gCuAKtIADgA2ADcAsoAE0gAOADYANwCygATcAfEADgCS
-AKAAogCkAKUApgCnAMcB8gHzAckAqAH2AKoAlwCuAK8AsAHnAfsB/AEkWE5TVGFyZ2V0VU5TVGFnV05T
-U3RhdGWAV4AWgF2AD4AQgBSAXIBeE///////////0wAOAJIAlACVAf8CAIAggF+AYFxGcm9tIERpc3Bs
-YXlfEBFfcG9wVXBJdGVtQWN0aW9uOtIADgA2ADcCBYAEWk90aGVyVmlld3PSAA4ARQBNAgiAH6QB4AIK
-AgsCDIBbgGGAZIBn2wHxAA4AkgCgAKIApAClAKYApwDHAfIByQCoAhAAqgCXAK4ArwCwAecCFQIWgFeA
-FoBigA+AEIAUgFyAYxAIWjI1NiBDb2xvcnPbAfEADgCSAKAAogCkAKUApgCnAMcB8gHJAKgCGwCqAJcA
-rgCvALAB5wIgAiGAV4AWgGWAD4AQgBSAXIBmEA9ZVGhvdXNhbmRz2wHxAA4AkgCgAKIApAClAKYApwDH
-AfIByQCoAiYAqgCXAK4ArwCwAecCKwIsgFeAFoBogA+AEIAUgFyAaRAYWE1pbGxpb25z0gA6ADsCLwIw
-pgIwAjEBRAFFAP8AP18QEU5TUG9wVXBCdXR0b25DZWxsXk5TTWVudUl0ZW1DZWxs0gA6ADsCMwI0pgI0
-AUgBSQFKAUsAP11OU1BvcFVwQnV0dG9uVWRlcHRo1AAOAIoAiwCMAPgAHwI5AjqANYACgG6AcNkADgCS
-AKAAogCkAKUApgCnAfIAqAI9AKoAlwCuAK8AsAFfAkKAFoBvgA+AEIAUgDgQKlhTaG93IEFsbF8QFnVu
-aGlkZUFsbEFwcGxpY2F0aW9uczrUAA4AigCLAIwAjQJHAPkCSYAigHKAMoB02gAOAJIAoAChAKIAowCk
-AKUApgCnAKgAlwCqAKsAlwCrAK4ArwCwAlKAFoAPCYAPCYAQgBSAc9MADgCSAJQAlQDKAlaAIIAYgMRe
-YXBwc19zZXBhcmF0b3LUAA4AigCLAIwA+AD5AlsBp4A1gDKAdoBQ1wD9AA4A/gD/AQABAQECAYEBBAJg
-AmEBEACrAYGAQ4AxgHeAeAmAQ18QFXt7MTgsIDY5fSwgezQwMiwgMTh9fd0BFAAOARUBFgEXARgBGQEa
-ARsBHAEdAR4BHwEgASEAlwEjAZEBkgCXAmoBKAJbASoBlwGYgDCAD4BHgA+AeYApgHZfEB5DbGljay10
-aHJvdWdoIEluYWN0aXZlIFdpbmRvd3PUAA4AigCLAIwA+AD5AnECcoA1gDKAe4B+2AAOAJIAoACiAKQA
-pQCmAKcAqAJ1AnYCdwCuAK8AsAFygBaAfBIAEAEIgH2AEIAUgD1fEBVDeWNsZSBUaHJvdWdoIFdpbmRv
-d3NRYFxuZXh0X3dpbmRvdzrUAA4AigCLAIwA+AD5AcIBp4A1gDKAVIBQ1AAOAIoAiwCMAPgA+QKGAaeA
-NYAygIGAUNcA/QAOAP4A/wEAAQEBAgKJAQQCiwKMARAAqwKJgIKAMYCDgIQJgILVAP0ADgD+AQsBAAAr
-AQ4CkgKTARCAAIEBM4EBZYEBVF8QFnt7MTgsIDE2Nn0sIHs0MDIsIDE4fX3dARQADgEVARYBFwEYARkB
-GgEbARwBHQEeAR8BIAEhAJcBIwGRAZIAlwKaASgChgEqAZcBmIAwgA+AR4APgIWAKYCBXxAmQWxsb3cg
-Y29ubmVjdGlvbnMgZnJvbSBuZXR3b3JrIGNsaWVudHPUAA4AigCLAIwA+AD5AqEBp4A1gDKAh4BQ1wD9
-AA4A/gD/AQABAQECAYEBBAKmAqcBEACrAYGAQ4AxgIiAiQmAQ18QFnt7MTgsIDI0M30sIHs0MDIsIDE4
-fX3dARQADgEVARYBFwEYARkBGgEbARwBHQEeAR8BIAEhAJcBIwGRAZIAlwKwASgCoQEqAZcBmIAwgA+A
-R4APgIqAKYCHXxAaRW11bGF0ZSB0aHJlZSBidXR0b24gbW91c2XUAA4AigCLAIwAjQK2APkCuIAigIyA
-MoCP2AAOAJIAoACiAKQApQCmAKcAqAK7ArwCvQCuAK8AsAFfgBaAjRIAGAAAgI6AEIAUgDhfEBJUb2dn
-bGUgRnVsbCBTY3JlZW5RYV8QFnRvZ2dsZV9mdWxsc2NyZWVuX2l0ZW3UAA4AigCLAIwA+AD5AscCyIA1
-gDKAkYCU2AAOAJIAoACiAKQApQCmAKcAqALLAswCzQCuAK8AsAFygBaAkhIAEgEKgJOAEIAUgD1fEB1S
-ZXZlcnNlIEN5Y2xlIFRocm91Z2ggV2luZG93c1F+XxAQcHJldmlvdXNfd2luZG93OtQADgCKAIsAjACN
-AVcA+QLYgCKAN4AygJZeeDExX2Fib3V0X2l0ZW3UAA4AigCLAIwAjQDJAPkC3oAigBqAMoCYXmRvY2tf
-YXBwc19tZW510wAOAIsAjAD4AuIC44A1gJqAndgADgCSAKAAogCkAKUApgCnAKgC5gCqAr0ArgCvALAC
-6oAWgJyAjoAQgBSAm9MADgCSAJQAlQLtAu6AIIDIgMpaU2VsZWN0IEFsbFpzZWxlY3RBbGw60wAOAIsA
-jAD4AvMC9IA1gJ+AotgADgCSAKAAogCkAKUApgCnAKgC9wCqAvgArgCvALAC6oAWgKCAoYAQgBSAm1RD
-b3B5UWNVY29weTrUAA4AigCLAIwAjQMBAB8DA4AigKSAAoDy1AAOAJIAkwCUAJUDBgMHAwiAIIClgPGA
-plhNYWluTWVuddIADgBFAE0DDIAfpQMNAw4DDwMQAxGAp4DCgMeA2oDq2gAOAMYAkgCgAKIApAClAKYA
-pwDHAKgBXwFiAKoAlwCuAK8AsAMBAxqAFoA4gKiAD4AQgBSApICpU1gxMdIADgBFAE0DHoAfrAFXAyAD
-IQMiAyMCtgMlAyYDJwI5AykDKoA3gKuAroCvgLaAjIC3gLiAu4BugL2AvtgADgCSAKAAogCkAKUApgCn
-AKgDLQCqAy4ArgCvALABX4AWgKyArYAQgBSAOF5QcmVmZXJlbmNlcy4uLlEs2gAOAJIAoAChAKIAowCk
-AKUApgCnAKgAlwCqAKsAlwCrAK4ArwCwAV+AFoAPCYAPCYAQgBSAONoADgDGAJIAoACiAKQApQCmAKcA
-xwCoAz8DQACqAJcArgCvALABXwNFgBaAsoCwgA+AEIAUgDiAsVhTZXJ2aWNlc9QADgCSAJMAlACVA0kD
-SgNLgCCAs4C1gLTSAA4ANgA3A0aABNIADgBFAE0DUIAfoF8QD19OU1NlcnZpY2VzTWVuddoADgCSAKAA
-oQCiAKMApAClAKYApwCoAJcAqgCrAJcAqwCuAK8AsAFfgBaADwmADwmAEIAUgDjaAA4AkgCgAKEAogCj
-AKQApQCmAKcAqACXAKoAqwCXAKsArgCvALABX4AWgA8JgA8JgBCAFIA42QAOAJIAoACiAKQApQCmAKcB
-8gCoA2YAqgNnAK4ArwCwAV8CQoAWgLmAuoAQgBSAOFhIaWRlIFgxMVFo2AAOAJIAoACiAKQApQCmAKcA
-qANvAKoAlwCuAK8AsAFfgBaAvIAPgBCAFIA4W0hpZGUgT3RoZXJz2gAOAJIAoAChAKIAowCkAKUApgCn
-AKgAlwCqAKsAlwCrAK4ArwCwAV+AFoAPCYAPCYAQgBSAONgADgCSAKAAogCkAKUApgCnAKgDgACqA4EA
-rgCvALABX4AWgL+AwIAQgBSAOFhRdWl0IFgxMVFxXF9OU0FwcGxlTWVuddoADgDGAJIAoACiAKQApQCm
-AKcAxwCoAlIAygCqAJcArgCvALADAQOQgBaAc4AYgA+AEIAUgKSAw9IADgBFAE0Dk4AfogJHA5WAcoDF
-2AAOAJIAoACiAKQApQCmAKcAqAOYAKoAlwCuAK8AsAJSgBaAxoAPgBCAFIBzXEN1c3RvbWl6ZS4uLtoA
-DgDGAJIAoACiAKQApQCmAKcAxwCoAuoC7QCqAJcArgCvALADAQOmgBaAm4DIgA+AEIAUgKSAyVRFZGl0
-0gAOAEUATQOqgB+oA6sDrAOtA64C8wOwA7EC4oDLgM6A0YDSgJ+A1YDYgJrYAA4AkgCgAKIApAClAKYA
-pwCoA7UAqgO2AK4ArwCwAuqAFoDMgM2AEIAUgJtUVW5kb1F62AAOAJIAoACiAKQApQCmAKcAqAO+AKoD
-vwCuAK8AsALqgBaAz4DQgBCAFICbVFJlZG9RWtoADgCSAKAAoQCiAKMApAClAKYApwCoAJcAqgCrAJcA
-qwCuAK8AsALqgBaADwmADwmAEIAUgJvYAA4AkgCgAKIApAClAKYApwCoA9AAqgPRAK4ArwCwAuqAFoDT
-gNSAEIAUgJtTQ3V0UXjYAA4AkgCgAKIApAClAKYApwCoA9kAqgPaAK4ArwCwAuqAFoDWgNeAEIAUgJtV
-UGFzdGVRdtgADgCSAKAAogCkAKUApgCnAKgD4gCqAJcArgCvALAC6oAWgNmAD4AQgBSAm1ZEZWxldGXa
-AA4AxgCSAKAAogCkAKUApgCnAMcAqAFyA+sAqgCXAK4ArwCwAwED8IAWgD2A24APgBCAFICkgNxWV2lu
-ZG930gAOADYANwPxgATSAA4ARQBNA/aAH6kD9wP4AnECxwP7AWoD/QP+A/+A34DigHuAkYDkgDyA5YDm
-gOjYAA4AkgCgAKIApAClAKYApwCoBAIAqgQDAK4ArwCwAXKAFoDggOGAEIAUgD1YTWluaW1pemVRbdgA
-DgCSAKAAogCkAKUApgCnAKgECwCqAJcArgCvALABcoAWgOOAD4AQgBSAPVRab29t2gAOAJIAoAChAKIA
-owCkAKUApgCnAKgAlwCqAKsAlwCrAK4ArwCwAXKAFoAPCYAPCYAQgBSAPdoADgCSAKAAoQCiAKMApACl
-AKYApwCoAJcAqgCrAJcAqwCuAK8AsAFygBaADwmADwmAEIAUgD3YAA4AkgCgAKIApAClAKYApwCoBCUA
-qgCXAK4ArwCwAXKAFoDngA+AEIAUgD1fEBJCcmluZyBBbGwgdG8gRnJvbnTaAA4AkgCgAKEAogCjAKQA
-pQCmAKcAqACXAKoAqwCXAKsArgCvALABcoAWgA8JgA8JgBCAFIA9Xl9OU1dpbmRvd3NNZW512gAOAMYA
-kgCgAKIApAClAKYApwDHAKgENwQ4AKoAlwCuAK8AsAMBBD2AFoDtgOuAD4AQgBSApIDsVEhlbHDTAA4A
-kgCUAJUEOARCgCCA64Du0gAOAEUATQRFgB+hBEaA79gADgCSAKAAogCkAKUApgCnAKgESQCqAJcArgCv
-ALAEN4AWgPCAD4AQgBSA7VhYMTEgSGVscFtfTlNNYWluTWVudVRtZW511AAOAIoAiwCMAPgA+QF9AaeA
-NYAygEKAUNQADgCKAIsAjACNBFgA+QRagCKA9YAygPnXAP0ADgD+AP8BAAEBAQIBxgEEBF4EXwEQAKsB
-xoBVgDGA9oD3CYBVXxAWe3sxOCwgMTgyfSwgezQwOSwgMjN9fd0BFAAOARUBFgEXARgBGQEaARsBHAEd
-AR4BHwEgASEAlwEjAZEBkgCXBGgBKARYASoBlwGYgDCAD4BHgA+A+IApgPVfEBBGdWxsIHNjcmVlbiBt
-b2RlXxARZW5hYmxlX2Z1bGxzY3JlZW7UAA4AigCLAIwA+AD5BFgEcYA1gDKA9YD7XxAaZW5hYmxlX2Z1
-bGxzY3JlZW5fY2hhbmdlZDrUAA4AigCLAIwA+AD5BHYEd4A1gDKA/YEBA9cA/QAOAP4A/wEAAQEBAgED
-AQQEewR8AQcAqwEDgCWAMYD+gP8JgCVfEBd7ezM3MiwgMjE1fSwgezEwMCwgMzJ9fd0BFAAOARUBFgEX
-ARgBGQEaARsBHAEdAR4BHwEgASEEggEjASQBJQSEBIUBKAR2ASoBKwEsgDCBAQGALIEBAoEBAIApgP1W
-UmVtb3Zl0gAOADYANwCygATSAA4ANgA3ALKABF8QEmFwcHNfdGFibGVfZGVsZXRlOtMADgCLAIwA+AOr
-BJGANYDLgQEFVXVuZG861AAOAIoAiwCMAPgA+QMgBJeANYAygKuBAQdbcHJlZnNfc2hvdzrUAA4AigCL
-AIwA+AD5ArYEnYA1gDKAjIEBCV8QEnRvZ2dsZV9mdWxsc2NyZWVuOtQADgCKAIsAjACNBKEA+QSjgCKB
-AQuAMoEBbt8QDwSlAA4EpgSnBKgEqQSqBKsErAStBK4ErwSwBLEEsgSzBLQEtQS2BLcEuAS5BLoEuwS8
-BL0BkQHiBL4Ev1xOU1dpbmRvd1ZpZXdfEBZOU1dpbmRvd0NvbnRlbnRNYXhTaXplXE5TU2NyZWVuUmVj
-dF8QE05TRnJhbWVBdXRvc2F2ZU5hbWVdTlNXaW5kb3dUaXRsZVlOU1dURmxhZ3NdTlNXaW5kb3dDbGFz
-c18QFk5TV2luZG93Q29udGVudE1pblNpemVcTlNXaW5kb3dSZWN0WU5TTWF4U2l6ZV8QD05TV2luZG93
-QmFja2luZ18QEU5TV2luZG93U3R5bGVNYXNrWU5TTWluU2l6ZVtOU1ZpZXdDbGFzc4EBEoEBbYEBEIEB
-aYEBbIEBDRJQeAAAgQEOgQERgQEMgQFrgQFqgQEPXxAYe3szMTksIDI5NH0sIHs0ODEsIDM0NX19XxAP
-WDExIFByZWZlcmVuY2VzV05TUGFuZWzSAA4ANgA3BMWABFRWaWV3XxAaezMuNDAyODJlKzM4LCAzLjQw
-MjgyZSszOH1aezIxMywgMTA3fdUA/QAOAQsBAAEMACsBDgTLARAEzIAAgQEzgQETgQFo0gAOAEUATQTP
-gB+hAYiBARTcAP0ADgTSBNMA/gE4AQsBAATUAQIE1QTWBLME2ATZAZcE2gEoBNwBEACrBLMAqwTgXk5T
-VGFiVmlld0l0ZW1zWU5TVHZGbGFnc18QEU5TRHJhd3NCYWNrZ3JvdW5kXxAWTlNBbGxvd1RydW5jYXRl
-ZExhYmVsc18QFU5TU2VsZWN0ZWRUYWJWaWV3SXRlbYEBEoEBZ4EBNYEBNIApgQEVCYEBEgmBATbSAA4A
-RQBNBOOAH6EBgYBD0gAOAEUATQTngB+oAqEE6QTqAX0E7AGmAlsE74CHgQEXgQEmgEKBASqATIB2gQEu
-1wD9AA4A/gD/AQABAQECAYEE8gTzBPQBEACrAYGAQ4EBJYEBGIEBGQmAQ18QFXt7MzYsIDkzfSwgezM4
-NSwgMzF9fdgBFAAOBPkBGgEbARwBHgT6ASAE+wT8BP0E/gTpBQAFAV8QEU5TQmFja2dyb3VuZENvbG9y
-W05TVGV4dENvbG9ygQEkgQEcgQEagQEbgQEXEgBAAACBASFfEGZXaGVuIGVuYWJsZWQsIG1lbnUgYmFy
-IGtleSBlcXVpdmFsZW50cyBtYXkgaW50ZXJmZXJlIHdpdGggWDExIGFwcGxpY2F0aW9ucyB0aGF0IHVz
-ZSB0aGUgTWV0YSBtb2RpZmllci7UAA4BLwCTATABMQUFATMFB4ArI0AmAAAAAAAAgCoRDBzVAA4FCQUK
-BQsFDAUNBQ4FDwUQBRFXTlNDb2xvclxOU0NvbG9yU3BhY2VbTlNDb2xvck5hbWVdTlNDYXRhbG9nTmFt
-ZYEBIIEBHxAGgQEegQEdVlN5c3RlbVxjb250cm9sQ29sb3LTAA4FCgUVBQ0B4gUXV05TV2hpdGWBASBL
-MC42NjY2NjY2OQDSADoAOwUZBQmiBQkAP9UADgUJBQoFCwUMBQ0FHAUPBR0FEYEBIIEBI4EBIoEBHV8Q
-EGNvbnRyb2xUZXh0Q29sb3LTAA4FCgUVBQ0B4gUigQEgQjAA0gA6ADsFJAUlpAUlAUUA/wA/XxAPTlNU
-ZXh0RmllbGRDZWxs0gA6ADsFJwUopQUoAUkBSgFLAD9bTlNUZXh0RmllbGTXAP0ADgD+AP8BAAEBAQIB
-gQTyBSwFLQEQAKsBgYBDgQElgQEngQEoCYBDXxAWe3szNiwgMjA4fSwgezM4NSwgMjl9fdgBFAAOBPkB
-GgEbARwBHgT6ASAE+wT8BTQE/gTqBQAFAYEBJIEBHIEBKYEBG4EBJoEBIV8QV0hvbGQgT3B0aW9uIGFu
-ZCBDb21tYW5kIHdoaWxlIGNsaWNraW5nIHRvIGFjdGl2YXRlIHRoZSBtaWRkbGUgYW5kIHJpZ2h0IG1v
-dXNlIGJ1dHRvbnMuCtcA/QAOAP4A/wEAAQEBAgGBBPIFPAU9ARAAqwGBgEOBASWBASuBASwJgENfEBZ7
-ezM2LCAxNTl9LCB7Mzg1LCAxNH192AEUAA4E+QEaARsBHAEeBPoBIAT7BPwFRAT+BOwFAAUBgQEkgQEc
-gQEtgQEbgQEqgQEhXxA+QWxsb3dzIGlucHV0IG1lbnUgY2hhbmdlcyB0byBvdmVyd3JpdGUgdGhlIGN1
-cnJlbnQgWDExIGtleW1hcC7XAP0ADgD+AP8BAAEBAQIBgQTyBUwFTQEQAKsBgYBDgQElgQEvgQEwCYBD
-XxAVe3szMywgMzJ9LCB7Mzg1LCAzMX192AEUAA4E+QEaARsBHAEeBPoBIAT7BPwFVAT+BO8FAAUBgQEk
-gQEcgQExgQEbgQEugQEhXxCFV2hlbiBlbmFibGVkLCBjbGlja2luZyBvbiBhbiBpbmFjdGl2ZSB3aW5k
-b3cgd2lsbCBjYXVzZSB0aGF0IG1vdXNlIGNsaWNrIHRvIHBhc3MgdGhyb3VnaCB0byB0aGF0IHdpbmRv
-dyBpbiBhZGRpdGlvbiB0byBhY3RpdmF0aW5nIGl0Ll8QFnt7MTAsIDMzfSwgezQzOCwgMjc5fX3SADoA
-OwVbAUqjAUoBSwA/XxAWe3sxMCwgMTB9LCB7NDU4LCAzMjV9fdIADgBFAE0FX4AfowTgBWEFYoEBNoEB
-OoEBU9YADgVkAUoFZQUJAIwFZgVnAYEBiAT8BWtcTlNJZGVudGlmaWVyWU5TVGFiVmlld4EBOYEBN4BD
-gQEUgQEcgQE40gAOADYANwVugARRMVVJbnB1dNIAOgA7BXEFcqIFcgA/XU5TVGFiVmlld0l0ZW3WAA4F
-ZAFKBWUFCQCMBWYFdQHGAYgE/AV5gQE5gQE7gFWBARSBARyBAVLSAA4ANgA3BXyABFEy0gAOAEUATQV/
-gB+nBYAFgQHCBYMFhARYBYaBAT2BAUGAVIEBRYEBSYD1gQFN1wD9AA4A/gD/AQABAQECAcYBBAWKBYsB
-EACrAcaAVYAxgQE+gQE/CYBVXxAWe3sxOCwgMTE2fSwgezQwMiwgMTh9fd0BFAAOARUBFgEXARgBGQEa
-ARsBHAEdAR4BHwEgASEAlwEjAZEBkgCXBZQBKAWAASoBlwGYgDCAD4BHgA+BAUCAKYEBPV8QF1VzZSBz
-eXN0ZW0gYWxlcnQgZWZmZWN01wD9AA4A/gD/AQABAQECAcYE8gWbBZwBEACrAcaAVYEBJYEBQoEBQwmA
-VV8QFXt7MzYsIDgyfSwgezM4NSwgMjh9fdgBFAAOBPkBGgEbARwBHgT6ASAE+wT8BaME/gWBBQAFAYEB
-JIEBHIEBRIEBG4EBQYEBIV8QZ1gxMSBiZWVwcyB3aWxsIHVzZSB0aGUgc3RhbmRhcmQgc3lzdGVtIGFs
-ZXJ0LCBhcyBkZWZpbmVkIGluIHRoZSBTb3VuZCBFZmZlY3RzIHN5c3RlbSBwcmVmZXJlbmNlcyBwYW5l
-bC7XAP0ADgD+AP8BAAEBAQIBxgTyBasFrAEQAKsBxoBVgQElgQFGgQFHCYBVXxAVe3sxNywgMjM4fSwg
-ezU1LCAyMH192AEUAA4E+QEaARsBHAEeBPoBIAT7BPwFswEoBYMFAAUBgQEkgQEcgQFIgCmBAUWBASFY
-Q29sb3JzOgrXAP0ADgD+AP8BAAEBAQIBxgTyBbsFvAEQAKsBxoBVgQElgQFKgQFLCYBVXxAWe3szNiwg
-MjE2fSwgezM5MiwgMTR9fdgBFAAOBPkBGgEbARwBHgT6ASAE+wT8BcME/gWEBQAFAYEBJIEBHIEBTIEB
-G4EBSYEBIV8QNFRoaXMgb3B0aW9uIHRha2VzIGVmZmVjdCB3aGVuIFgxMSBpcyBsYXVuY2hlZCBhZ2Fp
-bi7XAP0ADgD+AP8BAAEBAQIBxgTyBcsFzAEQAKsBxoBVgQElgQFOgQFPCYBVXxAWe3szNiwgMTQ1fSwg
-ezM4NSwgMzF9fdgBFAAOBPkBGgEbARwBHgT6ASAE+wT8BdME/gWGBQAFAYEBJIEBHIEBUIEBG4EBTYEB
-IV8QZEVuYWJsZXMgdGhlIFgxMSByb290IHdpbmRvdy4gVXNlIHRoZSBDb21tYW5kLU9wdGlvbi1BIGtl
-eXN0cm9rZSB0byBlbnRlciBhbmQgbGVhdmUgZnVsbCBzY3JlZW4gbW9kZS5WT3V0cHV01QAOAUoFZQUJ
-AIwFZgKJAYgE/AXegQE5gIKBARSBARyBAWbSAA4ARQBNBeGAH6UF4gKGBeQF5QXmgQFVgIGBAVmBAV2B
-AWHXAP0ADgD+AP8BAAEBAQICiQEEBeoF6wEQAKsCiYCCgDGBAVaBAVcJgILdARQADgEVARYBFwEYARkB
-GgEbARwBHQEeAR8BIAEhAJcBIwGRAZIAlwXzASgF4gEqAZcBmIAwgA+AR4APgQFYgCmBAVVfEBhBdXRo
-ZW50aWNhdGUgY29ubmVjdGlvbnPXAP0ADgD+AP8BAAEBAQICiQTyBfoF+wEQAKsCiYCCgQElgQFagQFb
-CYCCXxAWe3szNiwgMTk1fSwgezM4NSwgNDJ9fdgBFAAOBPkBGgEbARwBHgT6ASAE+wT8BgIE/gXkBQAF
-AYEBJIEBHIEBXIEBG4EBWYEBIV8QqkxhdW5jaGluZyBYMTEgd2lsbCBjcmVhdGUgWGF1dGhvcml0eSBh
-Y2Nlc3MtY29udHJvbCBrZXlzLiBJZiB0aGUgc3lzdGVtJ3MgSVAgYWRkcmVzcyBjaGFuZ2VzLCB0aGVz
-ZSBrZXlzIGJlY29tZSBpbnZhbGlkIHdoaWNoIG1heSBwcmV2ZW50IFgxMSBhcHBsaWNhdGlvbnMgZnJv
-bSBsYXVuY2hpbmcu1wD9AA4A/gD/AQABAQECAokE8gYKBgsBEACrAomAgoEBJYEBXoEBXwmAgl8QFnt7
-MzYsIDExOH0sIHszODUsIDQyfX3YARQADgT5ARoBGwEcAR4E+gEgBPsE/AYSBP4F5QUABQGBASSBARyB
-AWCBARuBAV2BASFfEJlJZiBlbmFibGVkLCBBdXRoZW50aWNhdGUgY29ubmVjdGlvbnMgbXVzdCBhbHNv
-IGJlIGVuYWJsZWQgdG8gZW5zdXJlIHN5c3RlbSBzZWN1cml0eS4gV2hlbiBkaXNhYmxlZCwgY29ubmVj
-dGlvbnMgZnJvbSByZW1vdGUgYXBwbGljYXRpb25zIGFyZSBub3QgYWxsb3dlZC7XAP0ADgD+AP8BAAEB
-AQICiQTyBhoGGwEQAKsCiYCCgQElgQFigQFjCYCCXxAVe3syMCwgMTd9LCB7NDA0LCAxNH192AEUAA4E
-+QEaARsBHAEeBPoBIAT7BPwGIgT+BeYFAAUBgQEkgQEcgQFkgQEbgQFhgQEhXxA0VGhlc2Ugb3B0aW9u
-cyB0YWtlIGVmZmVjdCB3aGVuIFgxMSBpcyBuZXh0IGxhdW5jaGVkLlhTZWN1cml0edIAOgA7BikFZaQF
-ZQFKAUsAP1p7NDgxLCAzNDV9XxAVe3swLCAwfSwgezE0NDAsIDg3OH19WnsyMTMsIDEyOX1ZeDExX3By
-ZWZz0gA6ADsGLwYwogYwAD9fEBBOU1dpbmRvd1RlbXBsYXRlW3ByZWZzX3BhbmVs1AAOAIoAiwCMAPgA
-+QDaBjaANYAygB2BAXBfEBBhcHBzX3RhYmxlX3Nob3c61AAOAIoAiwCMAI0A+QAfBjyAIoAygAKBAXJY
-ZGVsZWdhdGXUAA4AigCLAIwAjQXiAPkGQoAigQFVgDKBAXRbZW5hYmxlX2F1dGjUAA4AigCLAIwA+AAf
-AycGSIA1gAKAu4EBdl8QFmhpZGVPdGhlckFwcGxpY2F0aW9uczrUAA4AigCLAIwA+AD5Bk0GToA1gDKB
-AXiBAX7XAP0ADgD+AP8BAAEBAQIBAwEEBlIGUwZUAKsBA4AlgDGBAXmBAXoRAS8JgCVfEBV7ezM1Miwg
-MTJ9LCB7ODQsIDMyfX3dARQADgEVARYBFwEYARkBGgEbARwBHQEeAR8GWQEhBlsBIwEkASUGXQZeASgG
-TQEqASsBLBP/////hAH+AIAwgQF8gCyBAX2BAXuAKYEBeFZDYW5jZWzSAA4ANgA3ALKABNIADgA2ADcA
-soAEXxASYXBwc190YWJsZV9jYW5jZWw61AAOAIoAiwCMAPgA+QOVBjaANYAygMWBAXDUAA4AigCLAIwA
-+AD5A/cGcIA1gDKA34EBgV8QEG1pbmltaXplX3dpbmRvdzrTAA4AiwCMAPgDrgZ1gDWA0oEBg1RjdXQ6
-1AAOAIoAiwCMAPgA+QZ6BnuANYAygQGFgQGL1wD9AA4A/gD/AQABAQECAQMBBAZ/BoABBwCrAQOAJYAx
-gQGGgQGHCYAlXxAXe3szNzIsIDI0N30sIHsxMDAsIDMyfX3dARQADgEVARYBFwEYARkBGgEbARwBHQEe
-AR8BIAEhBoYBIwEkASUGiAaJASgGegEqASsBLIAwgQGJgCyBAYqBAYiAKYEBhVlEdXBsaWNhdGXSAA4A
-NgA3ALKABNIADgA2ADcAsoAEXxAVYXBwc190YWJsZV9kdXBsaWNhdGU61AAOAIoAiwCMAI0FgAD5BpaA
-IoEBPYAygQGNW3VzZV9zeXNiZWVw1AAOAIoAiwCMAI0GmgD5BpyAIoEBj4AygQG33xATAP0GngAOBNMG
-nwT5BqAGoQaiBqMGpAEAAQwBAQalBqYBAganBqgGqQGXBqoGqwasBq0AqwavBrABJAaxARAGsgCrBrQB
-/AapBrYGt18QH05TRHJhZ2dpbmdTb3VyY2VNYXNrRm9yTm9uTG9jYWxcTlNIZWFkZXJWaWV3XxASTlNB
-bGxvd3NUeXBlU2VsZWN0XE5TQ29ybmVyVmlld18QF05TSW50ZXJjZWxsU3BhY2luZ1dpZHRoXxAZTlND
-b2x1bW5BdXRvcmVzaXppbmdTdHlsZV8QGE5TSW50ZXJjZWxsU3BhY2luZ0hlaWdodFtOU0dyaWRDb2xv
-cl8QHE5TRHJhZ2dpbmdTb3VyY2VNYXNrRm9yTG9jYWxeTlNUYWJsZUNvbHVtbnNbTlNSb3dIZWlnaHSB
-AZCBAbYSUkCAAIEBkoEBpAmBAZYjQAgAAAAAAAAjQAAAAAAAAACBAZEJgQGzgQGQgQGaI0AxAAAAAAAA
-2gD9AA4A/ga5AQsBAAa6BrsBAga8Br0Gvga/BsAGwQbCBpoGxAa9BppZTlNjdkZsYWdzWU5TRG9jVmll
-d1lOU0JHQ29sb3JdTlNOZXh0S2V5Vmlld4EBl4EB4YEB4BAEgQHfEQkAgQGPgQGxgQGXgQGPWnszMzMs
-IDE5N33WAP0ADgEAAQwBAgbJBsoGywEQBswGygaaW05TVGFibGVWaWV3gQGTgQGVgQGUgQGTgQGP2gD9
-AA4A/ga5AQsBAAa6BrsBAga8Br0GvgbSBsAG0wbCBqwGxAa9BqyBAZeBAeGBAemBAeiBAZKBAbGBAZeB
-AZJZezMzMywgMTd90gA6ADsG2gbbpAbbAUoBSwA/XxARTlNUYWJsZUhlYWRlclZpZXfVAP0ADgD+AQAB
-Aga9Bt4G3wEQBr2BAZeBAZmBAZiBAZfeAP0G4gAOAP4G4wahBuQBCwblAQABAgbmBrwG5wEDBukG6gbr
-BuwGrwbKBu8G8AbxAQMG8wapBqlbTlNIU2Nyb2xsZXJYTlNzRmxhZ3NfEBBOU0hlYWRlckNsaXBWaWV3
-XE5TU2Nyb2xsQW10c1tOU1ZTY3JvbGxlcl1OU0NvbnRlbnRWaWV3gCWBAeaBAeuBAeoQMoEBloEBk4EB
-3k8QEEEgAABBIAAAQZgAAEGYAAARATOAJYEB4oEBkIEBkF8QFHt7MzM0LCAwfSwgezE2LCAxN3190gA6
-ADsG+Ab5pAb5AUoBSwA/XV9OU0Nvcm5lclZpZXfSAA4ARQBNBvyAH6MG/Qb+Bv+BAZuBAaaBAaraBwEA
-DgcCBwMHBAcFBwYHBwcIBskAqwcKBwsHDAcNAeIHDgcPAKsGml5OU0lzUmVzaXplYWJsZVxOU0hlYWRl
-ckNlbGxXTlNXaWR0aFpOU0RhdGFDZWxsXk5TUmVzaXppbmdNYXNrWk5TTWluV2lkdGhaTlNNYXhXaWR0
-aFxOU0lzRWRpdGFibGUJgQGlgQGcI0BbwAAAAAAAgQGiI0BEAAAAAAAAI0CPQAAAAAAACYEBj9cBFAAO
-BPkBGgEbAR4E+gcTBxQHFQcWBP4BlwcYEgSB/gCBAaGBAZ6BAZ2BARuBAZ9UTmFtZdMADgUKBRUFDQHi
-BxyBASBLMC4zMzMzMzI5OQDVAA4FCQUKBQsFDAUNBRwFDwcgBRGBASCBASOBAaCBAR1fEA9oZWFkZXJU
-ZXh0Q29sb3LSADoAOwckByWlByUFJQFFAP8AP18QEU5TVGFibGVIZWFkZXJDZWxs2AEUAA4E+QEaARsB
-HAEeBPoHJwT7Bq0HKgEoBpoB5gUBEhQx/kCBASSBAaSBAaOAKYEBj4EBIVlUZXh0IENlbGzTAA4FCgUV
-BQ0B4gcxgQEgQjEA0gA6ADsHMwc0ogc0AD9dTlNUYWJsZUNvbHVtbtoHAQAOBwIHAwcEBwUHBgcHBwgG
-yQCrBwoHOAc5BzoB4gc7Bw8AqwaaCYEBpYEBpyNAYJdkYAAAAIEBqSNAT12RYAAAAAmBAY/XARQADgT5
-ARoBGwEeBPoHEwcUBxUHQQT+AZcHGIEBoYEBnoEBqIEBG4EBn1dDb21tYW5k2AEUAA4E+QEaARsBHAEe
-BPoHJwT7Bq0HKgEoBpoB5gUBgQEkgQGkgQGjgCmBAY+BASHaBwEADgcCBwMHBAcFBwYHBwcIBskAqwcK
-B08HUAdRAeIHUgcPAKsGmgmBAaWBAasjQFQAAAAAAACBAa8jQCQAAAAAAAAJgQGP1wEUAA4E+QEaARsB
-HgT6ASAHFAdXB1gE/gGXBxiBAaGBAa2BAayBARuBAZ9YU2hvcnRjdXTVAA4FCQUKBQsFDAUNBq0FDwdf
-BRGBASCBAaSBAa6BAR1baGVhZGVyQ29sb3LZARQADgT5ARoBGwEcAR4E1AT6BycE+wbEByoHZgaaAeYA
-qwUBgQEkgQGxgQGjgQGwgQGPCYEBIdQADgEvAJMBMAExB2wBMwE8gCsjQCgAAAAAAACAKtUADgUJBQoF
-CwUMBQ0FDgUPB3EFEYEBIIEBH4EBsoEBHV8QFmNvbnRyb2xCYWNrZ3JvdW5kQ29sb3LVAA4FCQUKBQsF
-DAUNB3YFDwd3BRGBASCBAbWBAbSBAR1ZZ3JpZENvbG9y0wAOBQoFFQUNAeIHfIEBIEQwLjUA0gA6ADsH
-fgbJpQbJAUkBSgFLAD9aYXBwc190YWJsZdQADgCKAIsAjAD4AB8DJgeEgDWAAoC4gQG5VWhpZGU61AAO
-AIoAiwCMAPgA+QP4B4qANYAygOKBAbtcem9vbV93aW5kb3c61AAOAIoAiwCMAPgA+QP+B5CANYAygOaB
-Ab1fEA9icmluZ190b19mcm9udDrUAA4AigCLAIwA+AD5BeIBp4A1gDKBAVWAUNMADgCLAIwA+AOxB5qA
-NYDYgQHAV2RlbGV0ZTrUAA4AigCLAIwAjQGmAPkHoIAigEyAMoEBwltzeW5jX2tleW1hcNQADgCKAIsA
-jAD4APkFgAGngDWAMoEBPYBQ1AAOAIoAiwCMAPgA+QRGB6uANYAygO+BAcVZeDExX2hlbHA60wAOAIsA
-jAD4A7AHsIA1gNWBAcdWcGFzdGU61AAOAIoAiwCMAI0CWwD5B7aAIoB2gDKBAcldY2xpY2tfdGhyb3Vn
-aNQADgCKAIsAjACNA/8A+Qe8gCKA6IAygQHLXxAQd2luZG93X3NlcGFyYXRvctQADgCKAIsAjAD4APkD
-KgfCgDWAMoC+gQHNVXF1aXQ61AAOAIoAiwCMAI0CoQD5B8iAIoCHgDKBAc9cZmFrZV9idXR0b25z1AAO
-AIoAiwCMAI0AnQD5B86AIoAOgDKBAdFfEBVkb2NrX3dpbmRvd19zZXBhcmF0b3LTAA4AiwCMAPgDrAfT
-gDWAzoEB01VyZWRvOtQADgCKAIsAjACNAoYA+QfZgCKAgYAygQHVWmVuYWJsZV90Y3DUAA4AigCLAIwA
-+AD5B94H34A1gDKBAdeBAdzXAP0ADgD+AP8BAAEBAQIBAwEEB+MH5AZUAKsBA4AlgDGBAdiBAdkJgCVf
-EBV7ezI2OCwgMTJ9LCB7ODQsIDMyfX3dARQADgEVARYBFwEYARkBGgEbARwBHQEeAR8GWQEhAJcBIwEk
-ASUH7AftASgH3gEqASsBLIAwgA+ALIEB24EB2oApgQHXVERvbmXSAA4ANgA3ALKABF8QEGFwcHNfdGFi
-bGVfZG9uZTrSAA4ARQf1B/aBAfqvEIEDIAOsAecG/wXmAscCWwa9APkF+wUtAgsCDATvAYED/QMmAyoD
-lQGmAawF6wR8Bk0A2QTsAxEFnACdAmEFYQaABv0CcQGIBeIGrAEGB94CpwMQBeUFgAHCA/cAngK2A60C
-4gWBAMkFiwHGBgsDPwJHA/sGegOrA/4DDwMhANoDJwTqBzoAjgYbCDsCoQTgBYQHUQb+AuoCOQShAlIE
-RgFyA/gDAQbzAeABAwOuAPoFTQWGBWIBhAFXBukBXwfkBeQDJQKGAgoE6QW8CFwFPQOxBcwDIgF9BF8E
-swHJBlMC8wT0Aw0HDQR2BDcFgwMjBFgGmgMOA7AFrAP/AowBagMpAomAq4DOgFyBAaqBAWGAkYB2gQGX
-gDKBAVuBASiAZIBngQEugEOA5YC4gL6AxYBMgE6BAVeA/4EBeIAcgQEqgOqBAUOADoB4gQE6gQGHgQGb
-gHuBARSBAVWBAZKAJ4EB14CJgNqBAV2BAT2AVIDfgBeAjIDRgJqBAUGAGoEBP4BVgQFfgLKAcoDkgQGF
-gMuA5oDHgK6AHYC7gQEmgQGpgAuBAWOBAeyAh4EBNoEBSYEBr4EBpoCbgG6BAQuAc4DvgD2A4oCkgQHi
-gFuAJYDSgCSBATCBAU2BAVOARYA3gQHmgDiBAdmBAVmAt4CBgGGBAReBAUuBAfiBASyA2IEBT4CvgEKA
-94EBEoBXgQF6gJ+BARmAp4EBooD9gO2BAUWAtoD1gQGPgMKA1YEBR4DogISAPIC9gILSAA4ARQBNCHqA
-H6UGqQbzBukGygavgQGQgQHigQHmgQGTgQGW0gAOAEUATQiCgB+hBpqBAY9fEBV7ezEsIDE3fSwgezMz
-MywgMTk3fX3SADoAOwiGCIekCIcBSgFLAD9aTlNDbGlwVmlld9gA/QHxAA4A/gEAAMcBAgiJBr0GvQiM
-CI0BEAiOBr0IkFlOU1BlcmNlbnSBAZeBAZeBAeWBAeOBAeSBAZcjP+/WamAAAABfEBZ7ezMzNCwgMTd9
-LCB7MTUsIDE5N319XF9kb1Njcm9sbGVyOtIAOgA7CJQIlaUIlQFJAUoBSwA/Wk5TU2Nyb2xsZXLZAP0B
-8QAOAP4G4wEAAMcBAgiJBr0GvQiMCJoBJAEQCI4GvQidgQGXgQGXgQHlgQHngQHkgQGXIz/mCGTAAAAA
-XxAVe3sxLCAyMTR9LCB7MzMzLCAxNX190gAOAEUATQihgB+hBqyBAZJfEBN7ezEsIDB9LCB7MzMzLCAx
-N319XxAWe3syMCwgNzd9LCB7MzUwLCAyMzB9fdIAOgA7CKYIp6QIpwFKAUsAP1xOU1Njcm9sbFZpZXff
-EA8EpQAOBKYEpwSoBKkEqgSrBKwErQSuBK8EsASxBLIBAwS0CKsIrAitCK4EuQS6CLAIsQiyAZEIswi0
-CLWAJYEBbYEB8IEB9IEB94EB7oEBDoEB8YEB7YEB9hALgQH1gQHvXxAYe3syNzksIDI1M30sIHs0ODYs
-IDMyN319XxAUWDExIEFwcGxpY2F0aW9uIE1lbnXSAA4ANgA3BMWABNIADgBFAE0IvIAfpgfeBnoEdga9
-Bk0A+oEB14EBhYD9gQGXgQF4gCRaezQ4NiwgMzI3fVh4MTFfYXBwc9IADgAyADMIx4AFgQH50gA6ADsI
-yQDvogDvAD/SAA4ARQf1CMyBAfqvEIEBXwLqAckGmgKJAXIBgQEDAB8F5ATqAecB5wGBBOABcgFfAV8C
-UgGBAaYF4gR2AQMAyQGBAwEFgQCOAlsBiAZ6BpoBcgSzAokGvQD6AQMCoQMBAokBxgHGAXIAjgFfAuoC
-6gHGAJ4FgAVhBeUDIgJSAXIBAwLqAXIDAQFfAMkBXwGBBv4AHwXmAB8BgQGIAcYG/waaAw8BXwAfAw4E
-NwMQAXIAHwa9AecIOwLqAQME7wHGAYgBfQFfBr0DDQfeAokBXwKJAecBgQWEAB8E7ALqBYYBXwGBBFgE
-oQHCBk0C6gTpAwEG/QEDAxEBxgFfAcYGvQMBAuoFgwFyAoYBcgFfBWKAOICbgFeBAY+AgoA9gEOAJYAC
-gQFZgQEmgFyAXIBDgQE2gD2AOIA4gHOAQ4BMgQFVgP2AJYAagEOApIEBQYALgHaBARSBAYWBAY+APYEB
-EoCCgQGXgCSAJYCHgKSAgoBVgFWAPYALgDiAm4CbgFWAF4EBPYEBOoEBXYCvgHOAPYAlgJuAPYCkgDiA
-GoA4gEOBAaaAAoEBYYACgEOBARSAVYEBqoEBj4DHgDiAAoDCgO2A2oA9gAKBAZeAXIEB7ICbgCWBAS6A
-VYEBFIBCgDiBAZeAp4EB14CCgDiAgoBcgEOBAUmAAoEBKoCbgQFNgDiAQ4D1gQELgFSBAXiAm4EBF4Ck
-gQGbgCWA6oBVgDiAVYEBl4CkgJuBAUWAPYCBgD2AOIEBU9IADgBFB/UJUIEB+q8QggMgA6wG/wHnBeYC
-xwa9AlsA+QX7BS0CCwIMBO8BgQP9AyYDKgOVBHwBpgGsBesGTQDZBOwDEQWcAJ0FYQaAAmEG/QGIAnEF
-4gasAQYH3gKnAxAF5QWAAJ4D9wHCArYAHwOtAuIFgQDJBYsBxgYLAz8CRwZ6A/sDqwP+Aw8DIQDaAycE
-6gCOBzoGGwg7AqEE4AWEB1EG/gLqAjkEoQJSBEYBcgP4AwEG8wEDAeADrgD6BWIFhgVNBukBVwfkAV8B
-hAXkAyUChgIKBOkFvAhcBcwDsQU9AyIBfQRfBLMByQZTAvMHDQMNBPQEdgQ3BYMDIwRYBpoDDgOwBawD
-/wKMAWoDKQKJgKuAzoEBqoBcgQFhgJGBAZeAdoAygQFbgQEogGSAZ4EBLoBDgOWAuIC+gMWA/4BMgE6B
-AVeBAXiAHIEBKoDqgQFDgA6BATqBAYeAeIEBm4EBFIB7gQFVgQGSgCeBAdeAiYDagQFdgQE9gBeA34BU
-gIyAAoDRgJqBAUGAGoEBP4BVgQFfgLKAcoEBhYDkgMuA5oDHgK6AHYC7gQEmgAuBAamBAWOBAeyAh4EB
-NoEBSYEBr4EBpoCbgG6BAQuAc4DvgD2A4oCkgQHigCWAW4DSgCSBAVOBAU2BATCBAeaAN4EB2YA4gEWB
-AVmAt4CBgGGBAReBAUuBAfiBAU+A2IEBLICvgEKA94EBEoBXgQF6gJ+BAaKAp4EBGYD9gO2BAUWAtoD1
-gQGPgMKA1YEBR4DogISAPIC9gILSAA4ARQf1CdWBAfqvEIIJ1gnXCdgJ2QnaCdsJ3AndAU4J3wngCeEJ
-4gnjCeQJ5QnmCecJ6AnpCeoJ6wnsCe0J7gnvCfAJ8QnyCfMJ9An1CfYJ9wn4CfkJ+gn7CfwJ/Qn+Cf8K
-AAoBCgIKAwoECgUKBgoHCggKCQoKCgsKDAoNCg4KDwoQChEKEgoTChQKFQoWChcKGAoZChoKGwocCh0K
-HgofCiAKIQoiCiMKJAolCiYKJwMGCikKKgorCiwKLQouCi8KMAoxCjIKMwo0CjUKNgo3CjgKOQo6CjsK
-PAo9Cj4KPwpACkEKQgpDCkQKRQpGCkcKSApJCkoKSwpMCk0KTgpPClAKUQpSClMKVApVClYKV4EB/oEB
-/4ECAIECAYECAoECA4ECBIECBYAzgQIGgQIHgQIIgQIJgQIKgQILgQIMgQINgQIOgQIPgQIQgQIRgQIS
-gQITgQIUgQIVgQIWgQIXgQIYgQIZgQIagQIbgQIcgQIdgQIegQIfgQIggQIhgQIigQIjgQIkgQIlgQIm
-gQIngQIogQIpgQIqgQIrgQIsgQItgQIugQIvgQIwgQIxgQIygQIzgQI0gQI1gQI2gQI3gQI4gQI5gQI6
-gQI7gQI8gQI9gQI+gQI/gQJAgQJBgQJCgQJDgQJEgQJFgQJGgQJHgQJIgQJJgQJKgQJLgQJMgQJNgQJO
-gKWBAk+BAlCBAlGBAlKBAlOBAlSBAlWBAlaBAleBAliBAlmBAlqBAluBAlyBAl2BAl6BAl+BAmCBAmGB
-AmKBAmOBAmSBAmWBAmaBAmeBAmiBAmmBAmqBAmuBAmyBAm2BAm6BAm+BAnCBAnGBAnKBAnOBAnSBAnWB
-AnaBAneBAniBAnmBAnqBAnuBAnyBAn1fEBpNZW51IEl0ZW0gKFByZWZlcmVuY2VzLi4uKV8QEE1lbnUg
-SXRlbSAoUmVkbylfEBdUYWJsZSBDb2x1bW4gKFNob3J0Y3V0KV8QEU1lbnUgKE90aGVyVmlld3MpXxBC
-U3RhdGljIFRleHQgKFRoZXNlIG9wdGlvbnMgdGFrZSBlZmZlY3Qgd2hlbiBYMTEgaXMgbmV4dCBsYXVu
-Y2hlZC4pXxApTWVudSBJdGVtIChSZXZlcnNlIEN5Y2xlIFRocm91Z2ggV2luZG93cylbU2Nyb2xsIFZp
-ZXdfECpDaGVjayBCb3ggKENsaWNrLXRocm91Z2ggSW5hY3RpdmUgV2luZG93cylfELxUZXh0IEZpZWxk
-IENlbGwgKExhdW5jaGluZyBYMTEgd2lsbCBjcmVhdGUgWGF1dGhvcml0eSBhY2Nlc3MtY29udHJvbCBr
-ZXlzLiBJZiB0aGUgc3lzdGVtJ3MgSVAgYWRkcmVzcyBjaGFuZ2VzLCB0aGVzZSBrZXlzIGJlY29tZSBp
-bnZhbGlkIHdoaWNoIG1heSBwcmV2ZW50IFgxMSBhcHBsaWNhdGlvbnMgZnJvbSBsYXVuY2hpbmcuKV8Q
-aVRleHQgRmllbGQgQ2VsbCAoSG9sZCBPcHRpb24gYW5kIENvbW1hbmQgd2hpbGUgY2xpY2tpbmcgdG8g
-YWN0aXZhdGUgdGhlIG1pZGRsZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KKV8QFU1lbnUgSXRlbSAo
-VGhvdXNhbmRzKV8QFE1lbnUgSXRlbSAoTWlsbGlvbnMpXxCTU3RhdGljIFRleHQgKFdoZW4gZW5hYmxl
-ZCwgY2xpY2tpbmcgb24gYW4gaW5hY3RpdmUgd2luZG93IHdpbGwgY2F1c2UgdGhhdCBtb3VzZSBjbGlj
-ayB0byBwYXNzIHRocm91Z2ggdG8gdGhhdCB3aW5kb3cgaW4gYWRkaXRpb24gdG8gYWN0aXZhdGluZyBp
-dC4pVlZpZXctMVtTZXBhcmF0b3ItMV8QFE1lbnUgSXRlbSAoSGlkZSBYMTEpXxAUTWVudSBJdGVtIChR
-dWl0IFgxMSlfEBhNZW51IEl0ZW0gKEN1c3RvbWl6ZS4uLilfEBRCdXR0b24gQ2VsbCAoUmVtb3ZlKV8Q
-KUNoZWNrIEJveCAoRm9sbG93IHN5c3RlbSBrZXlib2FyZCBsYXlvdXQpXxArQnV0dG9uIENlbGwgKEZv
-bGxvdyBzeXN0ZW0ga2V5Ym9hcmQgbGF5b3V0KV8QJkJ1dHRvbiBDZWxsIChBdXRoZW50aWNhdGUgY29u
-bmVjdGlvbnMpXxAUUHVzaCBCdXR0b24gKENhbmNlbClcU2VwYXJhdG9yLTEwXxBMU3RhdGljIFRleHQg
-KEFsbG93cyBpbnB1dCBtZW51IGNoYW5nZXMgdG8gb3ZlcndyaXRlIHRoZSBjdXJyZW50IFgxMSBrZXlt
-YXAuKV8QEE1lbnUgSXRlbSAoSGVscClfEHlUZXh0IEZpZWxkIENlbGwgKFgxMSBiZWVwcyB3aWxsIHVz
-ZSB0aGUgc3RhbmRhcmQgc3lzdGVtIGFsZXJ0LCBhcyBkZWZpbmVkIGluIHRoZSBTb3VuZCBFZmZlY3Rz
-IHN5c3RlbSBwcmVmZXJlbmNlcyBwYW5lbC4pWVNlcGFyYXRvcl8QFlRhYiBWaWV3IEl0ZW0gKE91dHB1
-dClfEBdCdXR0b24gQ2VsbCAoRHVwbGljYXRlKV8QLEJ1dHRvbiBDZWxsIChDbGljay10aHJvdWdoIElu
-YWN0aXZlIFdpbmRvd3MpXxATVGFibGUgQ29sdW1uIChOYW1lKV8QJlRvcCBUYWIgVmlldyAoSW5wdXQs
-IE91dHB1dCwgU2VjdXJpdHkpXxAhTWVudSBJdGVtIChDeWNsZSBUaHJvdWdoIFdpbmRvd3MpXxAkQ2hl
-Y2sgQm94IChBdXRoZW50aWNhdGUgY29ubmVjdGlvbnMpXxARVGFibGUgSGVhZGVyIFZpZXdfEBZCdXR0
-b24gQ2VsbCAoQWRkIEl0ZW0pXxASUHVzaCBCdXR0b24gKERvbmUpXxAoQnV0dG9uIENlbGwgKEVtdWxh
-dGUgdGhyZWUgYnV0dG9uIG1vdXNlKV8QEk1lbnUgSXRlbSAoV2luZG93KV8Qp1N0YXRpYyBUZXh0IChJ
-ZiBlbmFibGVkLCBBdXRoZW50aWNhdGUgY29ubmVjdGlvbnMgbXVzdCBhbHNvIGJlIGVuYWJsZWQgdG8g
-ZW5zdXJlIHN5c3RlbSBzZWN1cml0eS4gV2hlbiBkaXNhYmxlZCwgY29ubmVjdGlvbnMgZnJvbSByZW1v
-dGUgYXBwbGljYXRpb25zIGFyZSBub3QgYWxsb3dlZC4pXxAjQ2hlY2sgQm94IChVc2Ugc3lzdGVtIGFs
-ZXJ0IGVmZmVjdClfEBpNZW51IEl0ZW0gKEFwcGxpY2F0aW9ucyktMV8QFE1lbnUgSXRlbSAoTWluaW1p
-emUpXxAbUG9wdXAgQnV0dG9uIChGcm9tIERpc3BsYXkpXxAeTWVudSBJdGVtIChUb2dnbGUgRnVsbCBT
-Y3JlZW4pXEZpbGUncyBPd25lcltTZXBhcmF0b3ItNF8QFk1lbnUgSXRlbSAoU2VsZWN0IEFsbClfEHVT
-dGF0aWMgVGV4dCAoWDExIGJlZXBzIHdpbGwgdXNlIHRoZSBzdGFuZGFyZCBzeXN0ZW0gYWxlcnQsIGFz
-IGRlZmluZWQgaW4gdGhlIFNvdW5kIEVmZmVjdHMgc3lzdGVtIHByZWZlcmVuY2VzIHBhbmVsLilfEBVN
-ZW51IChBcHBsaWNhdGlvbnMpLTFfECVCdXR0b24gQ2VsbCAoVXNlIHN5c3RlbSBhbGVydCBlZmZlY3Qp
-XxCrVGV4dCBGaWVsZCBDZWxsIChJZiBlbmFibGVkLCBBdXRoZW50aWNhdGUgY29ubmVjdGlvbnMgbXVz
-dCBhbHNvIGJlIGVuYWJsZWQgdG8gZW5zdXJlIHN5c3RlbSBzZWN1cml0eS4gV2hlbiBkaXNhYmxlZCwg
-Y29ubmVjdGlvbnMgZnJvbSByZW1vdGUgYXBwbGljYXRpb25zIGFyZSBub3QgYWxsb3dlZC4pXxAPTWVu
-dSAoU2VydmljZXMpW1NlcGFyYXRvci05XxAXUHVzaCBCdXR0b24gKER1cGxpY2F0ZSlbU2VwYXJhdG9y
-LTJfEBBNZW51IEl0ZW0gKFVuZG8pXxAeTWVudSBJdGVtIChCcmluZyBBbGwgdG8gRnJvbnQpXxAQTWVu
-dSBJdGVtIChFZGl0KVtTZXBhcmF0b3ItNW8QFgBNAGUAbgB1ACAASQB0AGUAbQAgACgAQwB1AHMAdABv
-AG0AaQB6AGUgJgApXxAXTWVudSBJdGVtIChIaWRlIE90aGVycylfEGVTdGF0aWMgVGV4dCAoSG9sZCBP
-cHRpb24gYW5kIENvbW1hbmQgd2hpbGUgY2xpY2tpbmcgdG8gYWN0aXZhdGUgdGhlIG1pZGRsZSBhbmQg
-cmlnaHQgbW91c2UgYnV0dG9ucy4KKVhEb2NrTWVudV8QHVRleHQgRmllbGQgQ2VsbCAoVGV4dCBDZWxs
-KS0yXxBGVGV4dCBGaWVsZCBDZWxsIChUaGVzZSBvcHRpb25zIHRha2UgZWZmZWN0IHdoZW4gWDExIGlz
-IG5leHQgbGF1bmNoZWQuKVxFZGl0UHJvZ3JhbXNfECZDaGVjayBCb3ggKEVtdWxhdGUgdGhyZWUgYnV0
-dG9uIG1vdXNlKV8QFVRhYiBWaWV3IEl0ZW0gKElucHV0KV8QQlN0YXRpYyBUZXh0IChUaGlzIG9wdGlv
-biB0YWtlcyBlZmZlY3Qgd2hlbiBYMTEgaXMgbGF1bmNoZWQgYWdhaW4uKV8QG1RleHQgRmllbGQgQ2Vs
-bCAoVGV4dCBDZWxsKV8QFlRhYmxlIENvbHVtbiAoQ29tbWFuZClbTWVudSAoRWRpdClfEBRNZW51IEl0
-ZW0gKFNob3cgQWxsKVpQcmVmc1BhbmVsXxATTWVudSAoQXBwbGljYXRpb25zKV8QFE1lbnUgSXRlbSAo
-WDExIEhlbHApXU1lbnUgKFdpbmRvdylfEBBNZW51IEl0ZW0gKFpvb20pXxARVmVydGljYWwgU2Nyb2xs
-ZXJeQ29udGVudCBWaWV3LTFfEBhNZW51IEl0ZW0gKEZyb20gRGlzcGxheSlfEA9NZW51IEl0ZW0gKEN1
-dClfEBZQdXNoIEJ1dHRvbiAoQWRkIEl0ZW0pXxAYVGFiIFZpZXcgSXRlbSAoU2VjdXJpdHkpXxByU3Rh
-dGljIFRleHQgKEVuYWJsZXMgdGhlIFgxMSByb290IHdpbmRvdy4gVXNlIHRoZSBDb21tYW5kLU9wdGlv
-bi1BIGtleXN0cm9rZSB0byBlbnRlciBhbmQgbGVhdmUgZnVsbCBzY3JlZW4gbW9kZS4pXxCXVGV4dCBG
-aWVsZCBDZWxsIChXaGVuIGVuYWJsZWQsIGNsaWNraW5nIG9uIGFuIGluYWN0aXZlIHdpbmRvdyB3aWxs
-IGNhdXNlIHRoYXQgbW91c2UgY2xpY2sgdG8gcGFzcyB0aHJvdWdoIHRvIHRoYXQgd2luZG93IGluIGFk
-ZGl0aW9uIHRvIGFjdGl2YXRpbmcgaXQuKV8QE0hvcml6b250YWwgU2Nyb2xsZXJfEBVNZW51IEl0ZW0g
-KEFib3V0IFgxMSlfEBJCdXR0b24gQ2VsbCAoRG9uZSlaTWVudSAoWDExKV8QLkJ1dHRvbiBDZWxsIChF
-bmFibGUga2V5IGVxdWl2YWxlbnRzIHVuZGVyIFgxMSlfELhTdGF0aWMgVGV4dCAoTGF1bmNoaW5nIFgx
-MSB3aWxsIGNyZWF0ZSBYYXV0aG9yaXR5IGFjY2Vzcy1jb250cm9sIGtleXMuIElmIHRoZSBzeXN0ZW0n
-cyBJUCBhZGRyZXNzIGNoYW5nZXMsIHRoZXNlIGtleXMgYmVjb21lIGludmFsaWQgd2hpY2ggbWF5IHBy
-ZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4pW1NlcGFyYXRvci02XxAyQ2hlY2sg
-Qm94IChBbGxvdyBjb25uZWN0aW9ucyBmcm9tIG5ldHdvcmsgY2xpZW50cylfEBZNZW51IEl0ZW0gKDI1
-NiBDb2xvcnMpXxB0U3RhdGljIFRleHQgKFdoZW4gZW5hYmxlZCwgbWVudSBiYXIga2V5IGVxdWl2YWxl
-bnRzIG1heSBpbnRlcmZlcmUgd2l0aCBYMTEgYXBwbGljYXRpb25zIHRoYXQgdXNlIHRoZSBNZXRhIG1v
-ZGlmaWVyLilfEEZUZXh0IEZpZWxkIENlbGwgKFRoaXMgb3B0aW9uIHRha2VzIGVmZmVjdCB3aGVuIFgx
-MSBpcyBsYXVuY2hlZCBhZ2Fpbi4pW0FwcGxpY2F0aW9uXxB2VGV4dCBGaWVsZCBDZWxsIChFbmFibGVz
-IHRoZSBYMTEgcm9vdCB3aW5kb3cuIFVzZSB0aGUgQ29tbWFuZC1PcHRpb24tQSBrZXlzdHJva2UgdG8g
-ZW50ZXIgYW5kIGxlYXZlIGZ1bGwgc2NyZWVuIG1vZGUuKV8QEk1lbnUgSXRlbSAoRGVsZXRlKV8QUFRl
-eHQgRmllbGQgQ2VsbCAoQWxsb3dzIGlucHV0IG1lbnUgY2hhbmdlcyB0byBvdmVyd3JpdGUgdGhlIGN1
-cnJlbnQgWDExIGtleW1hcC4pXxAUTWVudSBJdGVtIChTZXJ2aWNlcylfECxDaGVjayBCb3ggKEVuYWJs
-ZSBrZXkgZXF1aXZhbGVudHMgdW5kZXIgWDExKV8QHkJ1dHRvbiBDZWxsIChGdWxsIHNjcmVlbiBtb2Rl
-KVxDb250ZW50IFZpZXdfECFQb3AgVXAgQnV0dG9uIENlbGwgKEZyb20gRGlzcGxheSlfEBRCdXR0b24g
-Q2VsbCAoQ2FuY2VsKV8QEE1lbnUgSXRlbSAoQ29weSlfEB1UZXh0IEZpZWxkIENlbGwgKFRleHQgQ2Vs
-bCktMV8QD01lbnUgSXRlbSAoWDExKV8QeFRleHQgRmllbGQgQ2VsbCAoV2hlbiBlbmFibGVkLCBtZW51
-IGJhciBrZXkgZXF1aXZhbGVudHMgbWF5IGludGVyZmVyZSB3aXRoIFgxMSBhcHBsaWNhdGlvbnMgdGhh
-dCB1c2UgdGhlIE1ldGEgbW9kaWZpZXIuKV8QFFB1c2ggQnV0dG9uIChSZW1vdmUpW01lbnUgKEhlbHAp
-XxAWU3RhdGljIFRleHQgKENvbG9yczoKKVtTZXBhcmF0b3ItN18QHENoZWNrIEJveCAoRnVsbCBzY3Jl
-ZW4gbW9kZSlfECRUYWJsZSBWaWV3IChOYW1lLCBDb21tYW5kLCBTaG9ydGN1dClfEBhNZW51IEl0ZW0g
-KEFwcGxpY2F0aW9ucylfEBFNZW51IEl0ZW0gKFBhc3RlKV8QGlRleHQgRmllbGQgQ2VsbCAoQ29sb3Jz
-OgopW1NlcGFyYXRvci0zXxA0QnV0dG9uIENlbGwgKEFsbG93IGNvbm5lY3Rpb25zIGZyb20gbmV0d29y
-ayBjbGllbnRzKV8QEU1lbnUgSXRlbSAoQ2xvc2UpW1NlcGFyYXRvci04VlZpZXctMtIADgBFB/UK2YEB
-+qDSAA4ARQf1CtyBAfqg0gAOAEUH9QrfgQH6rxC8AyADrAHnBv8F5gLHAHICWwa9APkAagCHBfsFLQIL
-AgwE7wGBA/0DJgMqA5UBpgGsBesEfABZAFwAXQBgAGkGTQDZBOwDEQWcAJ0AUwBwAHYCYQVhBoAAXwb9
-AnEBiAXiAGcAWAasAF4BBgBkB94CpwCBAH8AhACFAxAF5QWAAcID9wCeArYAVQBtAB8AdAOtAuIFgQDJ
-BYsATwBXAcYGCwBmAz8CRwP7BnoDqwB8A/4DDwMhANoDJwTqBzoAjgYbAFoIOwKhAFsE4ACCBYQHUQb+
-AuoCOQShAFIAVgJSAGwAYwB4BEYBcgBUA/gAeQMBBvMAhgHgAQMDrgD6BU0FhgViAYQBVwbpAV8H5AXk
-AyUAYgBuAHoAfgCDAoYAcwIKAIgAYQB9BOkFvAhcBT0DsQXMAFADIgBxAX0EXwCABLMByQB3BlMAdQLz
-BPQDDQcNAGUEdgQ3BYMDIwBoAG8AawRYAFEGmgMOA7AFrAP/AowBagMpAHsCiYCrgM6AXIEBqoEBYYCR
-gQF/gHaBAZeAMoEBBoEB1IEBW4EBKIBkgGeBAS6AQ4DlgLiAvoDFgEyAToEBV4D/gHWAgICGgJWBAQSB
-AXiAHIEBKoDqgQFDgA6AQYEBdYEBjIB4gQE6gQGHgJCBAZuAe4EBFIEBVYD6gHGBAZKAi4AngKOBAdeA
-iYEByIEBxIEBzoEB0IDagQFdgQE9gFSA34AXgIyAUYEBb4ACgQGCgNGAmoEBQYAagQE/gAqAbYBVgQFf
-gPSAsoBygOSBAYWAy4EBv4DmgMeAroAdgLuBASaBAamAC4EBY4B6gQHsgIeAf4EBNoEByoEBSYEBr4EB
-poCbgG6BAQuAO4BTgHOBAQqAnoEBuIDvgD2AS4DigQG6gKSBAeKBAdKAW4AlgNKAJIEBMIEBTYEBU4BF
-gDeBAeaAOIEB2YEBWYC3gJmBAXGBAbyBAcOBAcyAgYEBgIBhgQHWgJeBAcGBAReBAUuBAfiBASyA2IEB
-T4AjgK+BAXeAQoD3gQHGgQESgFeBAY6BAXqBAYSAn4EBGYCngQGigPOA/YDtgQFFgLaA/IEBc4EBCID1
-gDaBAY+AwoDVgQFHgOiAhIA8gL2BAb6AgtIADgBFB/ULnoEB+q8QvAufC6ALoQuiC6MLpAulC6YLpwuo
-C6kLqgurC6wLrQuuC68LsAuxC7ILswu0C7ULtgu3C7gLuQu6C7sLvAu9C74LvwvAC8ELwgvDC8QLxQvG
-C8cLyAvJC8oLywvMC80LzgvPC9AL0QvSC9ML1AvVC9YL1wvYC9kL2gvbC9wL3QveC98L4AvhC+IL4wvk
-C+UL5gvnC+gL6QvqC+sL7AvtC+4L7wvwC/EL8gvzC/QL9Qv2C/cL+Av5C/oL+wv8C/0L/gv/DAAMAQwC
-DAMMBAwFDAYMBwwIDAkMCgwLDAwMDQwODA8MEAwRDBIMEwwUDBUMFgwXDBgMGQwaDBsMHAwdDB4MHwwg
-DCEMIgwjDCQMJQwmDCcMKAwpDCoMKwwsDC0MLgwvDDAMMQwyDDMMNAw1DDYMNww4DDkMOgw7DDwMPQw+
-DD8MQAxBDEIMQwxEDEUMRgxHDEgMSQxKDEsMTAxNDE4MTwxQDFEMUgxTDFQMVQxWDFcMWAxZDFqBAoKB
-AoOBAoSBAoWBAoaBAoeBAoiBAomBAoqBAouBAoyBAo2BAo6BAo+BApCBApGBApKBApOBApSBApWBApaB
-ApeBApiBApmBApqBApuBApyBAp2BAp6BAp+BAqCBAqGBAqKBAqOBAqSBAqWBAqaBAqeBAqiBAqmBAqqB
-AquBAqyBAq2BAq6BAq+BArCBArGBArKBArOBArSBArWBAraBAreBAriBArmBArqBAruBAryBAr2BAr6B
-Ar+BAsCBAsGBAsKBAsOBAsSBAsWBAsaBAseBAsiBAsmBAsqBAsuBAsyBAs2BAs6BAs+BAtCBAtGBAtKB
-AtOBAtSBAtWBAtaBAteBAtiBAtmBAtqBAtuBAtyBAt2BAt6BAt+BAuCBAuGBAuKBAuOBAuSBAuWBAuaB
-AueBAuiBAumBAuqBAuuBAuyBAu2BAu6BAu+BAvCBAvGBAvKBAvOBAvSBAvWBAvaBAveBAviBAvmBAvqB
-AvuBAvyBAv2BAv6BAv+BAwCBAwGBAwKBAwOBAwSBAwWBAwaBAweBAwiBAwmBAwqBAwuBAwyBAw2BAw6B
-Aw+BAxCBAxGBAxKBAxOBAxSBAxWBAxaBAxeBAxiBAxmBAxqBAxuBAxyBAx2BAx6BAx+BAyCBAyGBAyKB
-AyOBAySBAyWBAyaBAyeBAyiBAymBAyqBAyuBAyyBAy2BAy6BAy+BAzCBAzGBAzKBAzOBAzSBAzWBAzaB
-AzeBAziBAzmBAzqBAzuBAzyBAz0QgRCtEQF8EQIXEQF7EQIaEQE0EgAElQgRAScQxBEBPhEBhBIAAYgY
-EgABiA0RAX8RAX0SAASVChEBXxECGBCGEIgRATERAXISAAGIEhIAAYgWEgABh8USAASVDBEBkREBihEB
-QRC0EQErEQIVEQFxEQGjEgABiBQRAgwRAYkRAQcRAYYSAASVCREBYBIAAYfEEQIcEQEpEQIZEQFcEQF2
-EQIjEQEREgAElQcRAiUSAAGH1hIABJUuEQEjEgABiAsSAASVLBEBphEBhxECExATEQF5EQFzEQF+EBcR
-Ag4RAiARAawRAhYSAASVLxCvEJwQrBEBdBECDxIAAYgTEQGqEQGvEQFeEgABiBkRAiIQghEBEBBcEQEk
-EJ4QwxAFEKMQjxECFBCREQFtEQI9EQGnEgABiBsRAhsRAR0RAWsRAY4RAV0SAASVKxEBghECPxEBKhCp
-EJYQ9BDNEQGFEQEOEQGSELURAa4RAaURAYsQzBDOEB0SAAGHxxCyEQGAEQEeEKARATYSAASVCxECHxEB
-YRIAAYgQEDoSAAMOZxA5EgABh8MRAXgRAiEQsxEBrRDPEQGNEgAElS0RAXcQyhEBsxEBLhECEhEBiBEB
-bBIAAYgiE//////////9EgABiBEQpBIAAYi/EQE3EIMRATURAXASAAGIvRCwEPUSAAGIHhIAAYfLEQEw
-EJ0SAAGIDBA4EQI+EQGMEQElEQGkEQGBEJARAYMRAiQRAh0RAbERASgRAQ0QqxIAAYghEgAElSoSAAGI
-FxDLEJURAY8RAWLSAA4ARQBNDRaAH6DSAA4ARQf1DRmBAfqg0gAOAEUH9Q0cgQH6oNIAOgA7DR4NH6IN
-HwA/Xk5TSUJPYmplY3REYXRhAAgAGQAiACcAMQA6AD8ARABSAFQAZgbuBvQHPwdGB00HWwdtB4kHlwej
-B68HvQfIB9YH8ggACBMIJQg/CEkIVghYCFsIXghhCGQIZghpCGsIbghxCHQIdwh5CHsIfgiBCIYIiQiS
-CJ4IoAiiCKsItQi3CMUIzgjXCOII6Qj7CQQJDQkWCRsJKgk9CUYJUQlTCVQJXQlkCXEJdwmACYIJ+Qn7
-Cf0J/woBCgMKBQoHCgkKCwoNCg8KEQoTChUKFwoZChsKHQofCiEKIwolCicKKQorCi0KMAozCjYKOQo8
-Cj8KQgpFCkgKSwpOClEKVApXCloKXQpgCmMKZgppCmwKbwpyCnUKeAp7Cn4KgQqECocKigqNCp4KrAq1
-Cr0KvwrBCsMKxQrWCt4K5QrxCvMK9Qr3CvkK/gsHCwkLDgsQCxILOwtPC10LaAt1C4MLjQuaC6ELowul
-C6oLqwutC64Lswu1C7cLuQu6C8cL1gvYC9oL3AvkC/YL/wwEDBcMJAwmDCgMKgw9DEYMSwxWDH8MiQyS
-DJQMlgyYDJoMnAyeDKAMogyvDL4MywzNDM8M0QzaDNwM4QzjDOUNDg0QDRINEw0VDRYNGA0aDRwNPQ0/
-DUENQw1FDUcNSQ1eDWcNbg19DYUNjg2TDZwNpQ2sDcMN0g3jDeUN5w3pDesOCA4aDiIOKQ4yDjwOSA5K
-DkwOTg5QDlMOVA5WDmsOdg6CDoQOhw6KDo0OkA6qDt8O6w8BDxYPJQ84D0oPVQ9fD20Pfw+MD5oPnw+h
-D6MPpQ+nD6kPqw+tD68PsQ+zD7gPwQ/KD9sP4g/rD+0P9g/4D/sQCBAREBYQHRAuEDAQMhA0ED4QRxBJ
-EFIQVBBdEGYQcxCAEIkQlBCdEKcQrhC6EMMQxRDHENUQ5xDwEPcRDxEgESIRJBEmESgRRRFHEUkRSxFN
-EU8RURFiEWQRZhFoEWoRdBGUEaURpxGpEasRrRHOEdAR0hHUEdYR2BHaEesR7RHvEfER8xH5EfsSCRIa
-EhwSHhIgEiISPxJBEkMSRRJHEkgSShJjEmYSaRJsEm8SchKLEsASwhLEEsYSyBLKEswSzhLQEtIS1xL6
-EwMTDxMRExMTHBMlEyoTQBNTE2QTZhNoE2oTbBOJE4sTjROPE5ETkhOUE60T4hPkE+YT6BPqE+wT7hPw
-FBAUHxQwFDIUNBQ2FDgUQhRTFFUUVxRZFFsUeBR6FHwUfhSAFIEUgxSYFJoUnRSgFKMUvBULFSgVOhVM
-FWEVbxV4FXkVexV9FX8VgRWDFYUVhxWJFYsVjBWNFZAVkxWVFZoVqxWtFa8VuBW6FcMVxRX2Ff8WBRYN
-Fg8WERYTFhUWFxYZFhsWHRYmFjMWNRY3FjkWRhZaFmMWZRZwFnkWexaEFoYWiBaKFowWuRa7Fr0WvxbB
-FsMWxRbHFskWyxbWFwMXBRcHFwkXCxcNFw8XERcTFxUXHxdMF04XUBdSF1QXVhdYF1oXXBdeF2cXcBd9
-F5EXoBepF7YXxBfKF9sX3RffF+EX4xgIGAoYDBgOGBAYEhgUGBYYHxg4GEkYSxhNGE8YURh6GHwYfhh/
-GIEYghiEGIYYiBiVGJcYmRibGKoYuxi9GL8YwRjDGOAY4hjkGOYY6BjpGOsZAxk4GToZPBk+GUAZQhlE
-GUYZZxl4GXoZfBl+GYAZoRmjGaUZqhmsGa4ZsBmyGcoZzBnZGeoZ7BnuGfAZ8hoDGgUaBxoJGgsaKBoq
-GiwaLhowGjEaMxpIGkoaTRpQGlMabBqhGqMapRqnGqkaqxqtGq8a2BrpGusa7RrvGvEbDhsQGxIbFBsW
-GxcbGRsyG2cbaRtrG20bbxtxG3MbdRuSG6MbpRunG6kbqxvMG84b0BvVG9cb2RvbG90b8hv0HA0cHhwg
-HCIcJBwmHEccSRxLHFAcUhxUHFYcWBx4HHocjRyeHKAcohykHKYctRzGHMgcyhzMHM4c3RzqHOwc7hzw
-HREdEx0VHRcdGR0bHR0dKh0sHS4dMB07HUYdUx1VHVcdWR16HXwdfh2AHYIdhB2GHYsdjR2THaQdph2o
-HaodrB29Hb8dwR3DHcUdzh3XHdkd5B3mHegd6h3sHe4eFx4ZHhseHR4fHiEeIx4lHiceKx40HjYeTx5R
-HlMeVR5XHlkeWx5dHl8eYR5jHmUeZx6IHooejB6OHpAekh6UHqMepR7OHtAe0h7THtUe1h7YHtoe3B8F
-HwcfCR8LHw0fDx8RHxMfFR8eHy8fMR8zHzUfNx9AH0IfSx9NH04fYB+JH4sfjR+OH5AfkR+TH5Uflx/A
-H8IfxB/FH8cfyB/KH8wfzh/zH/Uf9x/5H/sf/R//IAggCiArIC0gLyAxIDMgNSA3IEMgbCBuIHAgcSBz
-IHQgdiB4IHogmyCdIJ8goSCjIKUgpyCwILIgvyDoIOog7CDuIPAg8iD0IPYg+CEBIQMhCCEKIQwhLSEv
-ITEhMyE1ITchOSFGIW8hcSFzIXUhdyF5IXshfSF/IYQhjSGPIaAhoiGkIaYhqCGqIawhriGwIdEh0yHV
-Idch2SHbId0h4iHkIgUiByIJIgsiDSIPIhEiFiIYIkEiQyJFIkYiSCJJIksiTSJPInAiciJ0InYieCJ6
-InwigCKCIqMipSKnIqkiqyKtIq8itSK3Itgi2iLcIt4i4CLiIuQi6yMUIxYjGCMaIxwjHiMgIyIjJCMr
-IzQjNiM/I0EjVCNWI1gjWiNcI14jYCNiI2QjZiOHI4kjiyONI48jkSOTI5wjniO/I8EjwyPFI8cjySPL
-I9Aj+SP7I/0j/iQAJAEkAyQFJAckMCQyJDQkNSQ3JDgkOiQ8JD4kXyRhJGMkZSRnJGkkaySAJKkkqySt
-JK4ksCSxJLMktSS3JMYk7yTxJPMk9ST3JPkk+yT9JP8lBCURJRMlFSUXJSAlIiUlJSclSCVKJUwlTiVQ
-JVIlVCVdJWklbiV/JYElgyWFJYclmCWaJZwlniWgJb0lvyXBJcMlxSXGJcgl4SYWJhgmGiYcJh4mICYi
-JiQmNyZLJlwmXiZgJmImZCaBJpImlCaWJpgmmya4JromvCa+JsAmwSbDJt0nEicUJxcnGSccJx8nIScj
-JyonMyc1Jz4nQCdVJ2InZCdmJ2knbyeAJ4InhCeGJ4knlSemJ6gnqiesJ68nxCfVJ9cn2ifcJ98oHigr
-KEQoUShnKHUofyiNKKYosyi9KM8o4yjtKPko/Cj/KQIpBSkIKQspECkTKRYpGSkcKR8pIik9KU8pVylg
-KWIpZymEKY8ppCmmKakprCmvKbgpuim9KcAp8SoAKgoqHio3Kk8qUipVKlgqWypdKmAqYSpkKmUqaCpx
-KnMqdip4KoEqgyqUKpYqmSqcKp4qoSqjKqUqqCrFKscqyirNKtAq0SrTKusrDCsgKywrLysyKzUrOCs7
-K0ArQyusK70rvyvIK8orzSviK+or9ywDLBEsFCwXLBksHCwfLCYsMyxALEgsSyxXLGAsZSx6LH0sgCyD
-LIYsmSymLKksrCy1LL4s0CzZLOQs8C0NLQ8tEi0VLRgtGS0bLTQtVS1YLVstXi1hLWQtZy3BLd4t4C3j
-LeYt6S3qLewuBS4mLikuLC4vLjIuNS44Lnkuli6YLpsuni6hLqIupC68Lt0u4C7jLuYu6S7sLu8vdy+Q
-L5kvoC+5L8IvxC/LL84v0S/UL+0v+jAEMAcwCjAMMA8wEjAVMB4wIDAiMCgwMTA2MEQwXTBgMGMwZTBo
-MGswbjB3MHkwezCEMIYwlTCYMJswnTCgMKMwpTCoMMUwxzDJMMwwzzDQMNIw6zEgMSIxJDEmMSgxKzEt
-MTAxSjFnMWkxbDFvMXIxczF1MY0xrjGxMbQxtzG6Mb0xwDIqMkcySTJMMk8yUjJTMlUybTKOMpEylDKX
-MpkynDKfMqgyxTLHMsoyzTLQMtEy0zLsMw0zEDMTMxYzGTMcMx8zVjNzM3UzeDN7M34zfzOBM5ozuzO+
-M8EzxDPHM8ozzTQ0NDs0UDRTNFU0WDRbNF40ZzRpNHQ0dzR5NHw0fzSCNJ80oTSjNKY0qTSqNKw04TTj
-NOU05zTpNOw07jTxNQw1KTUrNS41MTU0NTU1NzVQNXE1dDV3NXo1fTWANYM2MDZNNk82UjZVNlg2WTZb
-NnQ2lTaYNps2njahNqQ2pzdDN2A3YjdlN2g3azdsN243hjenN6o3rTewN7M3tje5N/A3+TgCOAs4Fjgu
-ODk4QzhMOFE4ZDhwOIE4gziFOIc4ijidOK44sDiyOLQ4tzjAONE40zjWONg42zjnOPg4+jj8OP45ATka
-OSs5LTkvOTI5NTlSOVQ5VjlZOVw5XzlgOWI5ejmvObg5ujm9Ob85wjnFOcc5yjnROdo53DnlOec5/DoN
-Og86EToTOhY6JzopOis6LTowOkM6UDpSOlQ6VzpcOm06bzpxOnQ6dzqUOpY6mDqbOp46nzqhOrs68Dry
-OvU69zr6Ov06/zsCOww7FTsXOyA7Ijs6O0s7TTtQO1I7VTthO3I7dDt3O3k7fDvLO+07+jwPPBw8NjxS
-PG08eTyYPKc8szy2PLk8vjzBPMQ8xTzIPNE82jzdPN484TzkPOc88D0ZPSM9LT03PUU9SD1LPU49UD1T
-PVY9WT1cPV89Yj1tPYY9kj2VPZg9mz2ePaE9yj3NPdA90z3WPdk93D3fPeI97D31Pf4+Ej4nPio+LT4w
-PjM+bD54PoE+lD6hPq0+uz69PsA+wz7GPsg+yz7OPtE+5D7nPuk+7D7vPvI/CT8SPxs/KT8yPzQ/Oz8+
-P0E/RD9tP3w/iT+RP5w/qz+2P8E/zj/PP9I/1T/eP+E/6j/zP/Q/90AUQBlAHEAfQCJAJUAoQC1AOkA9
-QElAXkBhQGRAZ0BqQHxAhUCQQKRAxUDKQM1A0EDTQNVA2EDbQOVA8kD1QPhBAUEGQRRBPUE+QUFBREFN
-QVBBWUFaQV1BekF9QYBBg0GGQYlBkUGyQbVBuEG7Qb1BwEHDQexB7UHwQfNB/EH/QghCCUIMQilCLEIv
-QjJCNUI4QkFCVkJZQlxCX0JiQm5Ck0KWQplCnEKfQqJCo0KmQrdCuULCQsRC2ULcQt9C4kLlQv5DE0MW
-QxlDHEMfQylDNkM5Qz5DR0NSQ11DbkNwQ3JDdEN3Q31DjkOQQ5JDlEOXQ6RDtUO3Q7lDu0O+Q9BD4UPj
-Q+VD6EPqQ/dD+UP7Q/5EBkQXRBlEG0QdRCBELEQ9RD9EQUREREZEV0RZRFtEXURgRGpEd0R5RHtEfkSF
-RJZEmESaRJxEn0StRL5EwETCRMREx0TaROtE7UTvRPFE9ET6RQtFDUUPRRFFFEUhRTJFNEU2RThFO0VT
-RWBFYkVkRWdFbUV+RYBFgkWERYdFkkWjRaVFp0WqRa1FykXMRc5F0UXURdVF10XvRiRGJkYoRipGLUYw
-RjJGNUY6RkNGRUZYRmFGZEdpR2tHbUdvR3JHdUd3R3lHfEd+R4FHhEeGR4hHi0eNR49HkUeTR5VHl0eZ
-R5xHnkehR6NHpkeoR6tHrUevR7JHtUe4R7pHvUfAR8NHxUfIR8pHzEfPR9JH1EfWR9hH2kfcR95H4Ufj
-R+ZH6EfrR+1H70fxR/RH9kf4R/pH/Ef+SABIA0gGSAhIC0gOSBBIE0gWSBlIHEgeSCBII0glSCdIKUgr
-SC1IMEgySDRINkg4SDtIPkhBSENIRUhISEpITUhQSFJIVEhWSFlIXEhfSGJIZEhnSGlIa0htSHBIckh1
-SHdIekh8SH9IgUiDSIZIiEiKSI1Ij0iRSJRIlkiYSJpInEieSKdIqUi0SLdIuki9SMBIw0jMSM5I0UjU
-SOxI9Uj+SQlJKkk0STdJOkk9SUBJQ0lGSU9JaEl1SX5JiUmUSblJvEm/ScJJxUnISctJ1EnsSfVJ90n6
-Sf1KE0osSjVKPkpLSopKjEqPSpJKlUqYSptKnkqhSqRKp0qpSqxKr0rKSuFK6krsSvVK90sESwdLCksM
-Sw9LEksUSx9LKEsxSzNLNks/S0RLTUtQTFVMV0xZTFtMXkxgTGJMZExmTGhMa0xuTHBMckx0THdMeUx7
-TH1Mf0yBTINMhkyITIpMjEyOTJBMk0yVTJdMmkydTKBMokylTKdMqkysTK5MsEyyTLRMtky4TLpMvEy+
-TMBMwkzETMZMyUzMTM9M0UzTTNVM10zZTNtM3UzfTOFM40zlTOhM6kztTO9M8Uz0TPZM+Uz8TP5NAE0C
-TQRNBk0ITQpNDE0PTRFNFE0WTRhNG00dTSBNIk0kTSdNKU0sTS5NME0yTTRNNk05TTtNPk1ATUNNRU1H
-TUlNTE1OTVFNU01WTVhNW01dTV9NYU1jTWVNaE1qTWxNb01xTXNNdU13TXpNg02GTo1Oj06RTpROlk6Z
-TptOnk6gTqJOpU6oTqpOrE6vTrFOs061TrdOuU67Tr1Ov07CTsVOx07KTsxOz07RTtRO107ZTtxO307h
-TuRO507pTuxO7k7wTvNO9k74TvpO/E7+TwBPAk8ETwdPCU8MTw5PEU8TTxVPGE8aTxxPHk8gTyJPJE8m
-TylPK08uTzFPNE82TzlPPE8/T0JPRE9GT0lPS09NT09PUU9TT1ZPWE9aT1xPXk9hT2RPZ09qT2xPb09x
-T3NPdk94T3pPfE9/T4JPhU+IT4pPjU+PT5FPk0+WT5hPm0+dT6BPok+lT6dPqU+sT65PsE+zT7VPt0+6
-T7xPvk/AT8JPxE/NT9BQ11DaUN1Q4FDjUOZQ6VDsUO9Q8VD0UPdQ+lD9UQBRA1EGUQlRDFEPURJRFVEY
-URtRHlEhUSRRJ1EqUS1RMFEzUTZROVE8UT9RQlFFUUhRS1FOUVFRVFFXUVpRXVFgUWNRZlFpUWxRb1Fy
-UXVReFF7UX5RgVGEUYdRilGNUZBRk1GWUZlRnFGfUaJRpVGoUatRrlGxUbRRt1G6Ub1RwFHDUcZRyVHM
-Uc5R0VHUUddR2lHdUeBR41HmUelR7FHvUfJR9VH4UftR/lIBUgRSB1IKUg1SEFITUhZSGVIcUh9SIlIl
-UihSK1IuUjFSNFI3UjpSPVJAUkNSRlJJUkxST1JSUlVSWFJbUnhSi1KlUrlS/lMqUzZTY1QiVI5UplS9
-VVNVWlVmVX1VlFWvVcZV8lYgVklWYFZtVrxWz1dLV1VXbleIV7dXzVf2WBpYQVhVWG5Yg1iuWMNZbVmT
-WbBZx1nlWgZaE1ofWjhasFrIWvBbnluwW7xb1lviW/VcFlwpXDVcZFx+XOZc710PXVhdZV2OXaZd614J
-XiJeLl5FXlBeZl59Xotenl6yXsFe3F7uXwdfIl+XYDFgR2BfYHRgf2CwYWthd2GsYcViPGKFYpFjCmMf
-Y3JjiWO4Y9lj5mQKZCFkNGRUZGZk4WT4ZQRlHWUpZUhlb2WKZZ5lu2XHZf5mEmYeZiVmLmYxZjJmO2Y+
-Zj9mSGZLZ8ZnyGfKZ8xnz2fSZ9Rn12fZZ9xn3mfhZ+Rn52fqZ+xn7mfxZ/Nn9Wf3Z/ln+2f9Z/9oAmgE
-aAZoCGgKaAxoD2gSaBRoF2gZaBxoHmggaCNoJmgoaCtoLmgwaDNoNWg4aDtoPWg/aEJoRGhGaEhoS2hN
-aFBoU2hWaFloW2heaGFoY2hlaGdoaWhraG5ocGhzaHVod2h6aHxof2iBaINohWiIaIpojGiOaJBok2iV
-aJhommicaJ5ooGiiaKVoqGiqaK1or2iyaLRotmi5aLxov2jCaMVox2jJaMxozmjQaNJo1WjXaNpo3Gje
-aOBo4mjlaOdo6mjtaO9o8WjzaPVo+Gj7aP5pAGkCaQVpB2kKaQ1pD2kRaRRpF2kaaR1pH2kiaSRpJ2kp
-aSxpL2kyaTVpOGk6aT1pP2lBaURpRmlIaUtpTmlQaVNpVmlZaVtpXmlgaWNpZWlnaWlpbGluaXBpc2l2
-aXhpeml9aX9pgWmEaYZpiGmKaYxpj2mRaZppnWsYaxtrHmshayRrJ2sqay1rMGszazZrOWs8az9rQmtF
-a0hrS2tOa1FrVGtXa1prXWtga2NrZmtpa2xrb2tya3VreGt7a35rgWuEa4drimuNa5Brk2uWa5lrnGuf
-a6JrpWuoa6trrmuxa7Rrt2u6a71rwGvDa8ZryWvMa89r0mvVa9hr22vea+Fr5Gvna+pr7Wvwa/Nr9mv5
-a/xr/2wCbAVsCGwLbA5sEWwUbBdsGmwdbCBsI2wmbClsLGwvbDJsNWw4bDtsPmxBbERsR2xKbE1sUGxT
-bFZsWWxcbF9sYmxlbGhsa2xubHFsdGx3bHpsfWyAbINshmyJbIxsj2ySbJVsmGybbJ5soWykbKdsqmyt
-bLBss2y2bLlsvGy/bMJsxWzIbMtszmzRbNRs12zabN1s4GzjbOZs6WzsbO9s8mz1bPhs+2z+bQFtBG0H
-bQptDW0QbRNtFm0ZbRxtH20ibSVtKG0rbS5tMW00bTdtOm09bUBtQ21GbUltTG1ObVBtU21WbVltXG1f
-bWRtZ21pbWxtb210bXltfG1/bYRth22KbYxtjm2RbZRtmW2ebaNtqG2rba5tsW2zbbZtuW28bb9txG3H
-bcptzW3QbdVt2G3dbeBt423mbelt7G3vbfJt9236bf9uBG4HbgxuEW4UbhduGm4cbh9uIm4lbiduKm4t
-bjBuM244bjpuPG4+bkFuRG5JbkxuT25SblduWm5cbl9uYW5kbmZuaG5qbmxubm5xbnNudm55bnxugW6E
-boduim6NbpBulW6Ybptunm6gbqJupG6mbqlurG6vbrFutG63brpuvG6+bsBuxW7HbspuzW7PbtJu127a
-bt1u4m7kbulu627wbvNu9m74bvtu/W8AbwVvCG8Kbw1vEG8TbxZvGW8ebydvLG8ubzNvNm84bztvPm9D
-b0VvR29Mb1FvVG9Wb1tvXW9gb2NvZm9pb2xvbm9xb3Rvd296b31vgG+Cb4dvjG+Rb5NvlW+Yb5tvpG+m
-b6dvsG+zb7RvvW/Ab8Fvym/PAAAAAAAAAgIAAAAAAAANIAAAAAAAAAAAAAAAAAAAb94</bytes>
-		</object>
 	</data>
 </archive>
diff --git a/hw/xquartz/bundle/English.lproj/main.nib/keyedobjects.nib b/hw/xquartz/bundle/English.lproj/main.nib/keyedobjects.nib
index 4306102..5223c9a 100644
Binary files a/hw/xquartz/bundle/English.lproj/main.nib/keyedobjects.nib and b/hw/xquartz/bundle/English.lproj/main.nib/keyedobjects.nib differ
commit 407f7fec88f5354f6fa6b027a0e6104ed6749c40
Author: Jeremy Huddleston <jeremy at tifa.local>
Date:   Sun Feb 10 18:27:52 2008 -0800

    XQuartz: Added option for setting quartz-wm click-through preference
    (cherry picked from commit bf54c267cba97b2b3b9a621da0575776a388b2cb)

diff --git a/hw/xquartz/X11Application.h b/hw/xquartz/X11Application.h
index af5aea2..86da67f 100644
--- a/hw/xquartz/X11Application.h
+++ b/hw/xquartz/X11Application.h
@@ -98,5 +98,6 @@ extern int quartzHasRoot, quartzEnableRootless;
 #define PREFS_XP_OPTIONS            "xp_options"
 #define PREFS_ENABLE_STEREO         "enable_stereo"
 #define PREFS_LOGIN_SHELL           "login_shell"
+#define PREFS_QUARTZ_WM_CLICK_THROUGH "wm_click_through"
 
 #endif /* X11APPLICATION_H */
diff --git a/hw/xquartz/X11Controller.h b/hw/xquartz/X11Controller.h
index 47f5220..64d5cd1 100644
--- a/hw/xquartz/X11Controller.h
+++ b/hw/xquartz/X11Controller.h
@@ -37,29 +37,30 @@
 
 @interface X11Controller : NSObject
 {
-    NSPanel *prefs_panel;
-
-    NSButton *fake_buttons;
-    NSButton *enable_fullscreen;
-    NSButton *use_sysbeep;
-    NSButton *enable_keyequivs;
-    NSButton *sync_keymap;
-    NSButton *enable_auth;
-    NSButton *enable_tcp;
-    NSPopUpButton *depth;
-
-    NSMenuItem *x11_about_item;
-    NSMenuItem *window_separator;
-    NSMenuItem *dock_window_separator;
-    NSMenuItem *apps_separator;
-    NSMenuItem *toggle_fullscreen_item;
-    NSMenu *dock_apps_menu;
-    NSTableView *apps_table;
+    IBOutlet NSPanel *prefs_panel;
+
+    IBOutlet NSButton *fake_buttons;
+    IBOutlet NSButton *enable_fullscreen;
+    IBOutlet NSButton *use_sysbeep;
+    IBOutlet NSButton *enable_keyequivs;
+    IBOutlet NSButton *sync_keymap;
+    IBOutlet NSButton *click_through;
+    IBOutlet NSButton *enable_auth;
+    IBOutlet NSButton *enable_tcp;
+    IBOutlet NSPopUpButton *depth;
+
+    IBOutlet NSMenuItem *x11_about_item;
+    IBOutlet NSMenuItem *window_separator;
+    IBOutlet NSMenuItem *dock_window_separator;
+    IBOutlet NSMenuItem *apps_separator;
+    IBOutlet NSMenuItem *toggle_fullscreen_item;
+    IBOutlet NSMenu *dock_apps_menu;
+    IBOutlet NSTableView *apps_table;
 
     NSArray *apps;
     NSMutableArray *table_apps;
 
-    NSMenu *dock_menu;
+    IBOutlet NSMenu *dock_menu;
 
     int checked_window_item;
     x_list *pending_apps;
@@ -74,6 +75,25 @@
 - (void) set_can_quit:(BOOL)state;
 - (void) server_ready;
 
+- (IBAction) apps_table_show:(id)sender;
+- (IBAction) apps_table_cancel:(id)sender;
+- (IBAction) apps_table_done:(id)sender;
+- (IBAction) apps_table_new:(id)sender;
+- (IBAction) apps_table_duplicate:(id)sender;
+- (IBAction) apps_table_delete:(id)sender;
+- (IBAction) bring_to_front:(id)sender;
+- (IBAction) close_window:(id)sender;
+- (IBAction) minimize_window:(id)sender;
+- (IBAction) zoom_window:(id)sender;
+- (IBAction) next_window:(id)sender;
+- (IBAction) previous_window:(id)sender;
+- (IBAction) enable_fullscreen_changed:(id)sender;
+- (IBAction) toggle_fullscreen:(id)sender;
+- (IBAction) prefs_changed:(id)sender;
+- (IBAction) prefs_show:(id)sender;
+- (IBAction) quit:(id)sender;
+- (IBAction) x11_help:(id)sender;
+
 @end
 
 #endif /* __OBJC__ */
diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m
index d3f8365..5111eaf 100644
--- a/hw/xquartz/X11Controller.m
+++ b/hw/xquartz/X11Controller.m
@@ -613,7 +613,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
   quartzUseSysBeep = [use_sysbeep intValue];
   X11EnableKeyEquivalents = [enable_keyequivs intValue];
   darwinSyncKeymap = [sync_keymap intValue];
-	
+
   /* after adding prefs here, also add to [X11Application read_defaults]
      and below */
 	
@@ -621,6 +621,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
   [NSApp prefs_set_boolean:@PREFS_SYSBEEP value:quartzUseSysBeep];
   [NSApp prefs_set_boolean:@PREFS_KEYEQUIVS value:X11EnableKeyEquivalents];
   [NSApp prefs_set_boolean:@PREFS_SYNC_KEYMAP value:darwinSyncKeymap];
+  [NSApp prefs_set_boolean:@PREFS_QUARTZ_WM_CLICK_THROUGH value:[click_through intValue]];
   [NSApp prefs_set_boolean:@PREFS_NO_AUTH value:![enable_auth intValue]];
   [NSApp prefs_set_boolean:@PREFS_NO_TCP value:![enable_tcp intValue]];
   [NSApp prefs_set_integer:@PREFS_DEPTH value:[depth selectedTag]];
@@ -635,6 +636,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
   [enable_keyequivs setIntValue:X11EnableKeyEquivalents];
   [sync_keymap setIntValue:darwinSyncKeymap];
   [sync_keymap setEnabled:darwinKeymapFile == NULL];
+  [click_through setIntValue:[NSApp prefs_get_boolean:@PREFS_QUARTZ_WM_CLICK_THROUGH default:NO]];
 	
   [enable_auth setIntValue:![NSApp prefs_get_boolean:@PREFS_NO_AUTH default:NO]];
   [enable_tcp setIntValue:![NSApp prefs_get_boolean:@PREFS_NO_TCP default:NO]];
diff --git a/hw/xquartz/bundle/English.lproj/main.nib/designable.nib b/hw/xquartz/bundle/English.lproj/main.nib/designable.nib
index c267e45..08b3810 100644
--- a/hw/xquartz/bundle/English.lproj/main.nib/designable.nib
+++ b/hw/xquartz/bundle/English.lproj/main.nib/designable.nib
@@ -8,85 +8,86 @@
 		<string key="IBDocument.HIToolboxVersion">352.00</string>
 		<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
 			<bool key="EncodedWithXMLCoder">YES</bool>
+			<integer value="29"/>
 		</object>
 		<object class="NSArray" key="IBDocument.PluginDependencies">
 			<bool key="EncodedWithXMLCoder">YES</bool>
-			<string id="874199827">com.apple.InterfaceBuilder.CocoaPlugin</string>
+			<string id="1013584587">com.apple.InterfaceBuilder.CocoaPlugin</string>
 		</object>
-		<object class="NSMutableArray" key="IBDocument.RootObjects" id="874420287">
+		<object class="NSMutableArray" key="IBDocument.RootObjects" id="904585544">
 			<bool key="EncodedWithXMLCoder">YES</bool>
-			<object class="NSCustomObject" id="584863936">
+			<object class="NSCustomObject" id="815810918">
 				<object class="NSMutableString" key="NSClassName">
 					<characters key="NS.bytes">NSApplication</characters>
 				</object>
 			</object>
-			<object class="NSCustomObject" id="518703249">
-				<string key="NSClassName">FirstResponder</string>
+			<object class="NSCustomObject" id="941939442">
+				<string key="NSClassName" id="671773319">FirstResponder</string>
 			</object>
-			<object class="NSCustomObject" id="166373373">
+			<object class="NSCustomObject" id="951368722">
 				<string key="NSClassName">NSApplication</string>
 			</object>
-			<object class="NSMenu" id="496556081">
-				<string key="NSTitle" id="414137626">MainMenu</string>
+			<object class="NSMenu" id="524015605">
+				<string key="NSTitle" id="121567387">MainMenu</string>
 				<object class="NSMutableArray" key="NSMenuItems">
 					<bool key="EncodedWithXMLCoder">YES</bool>
-					<object class="NSMenuItem" id="385138428">
-						<reference key="NSMenu" ref="496556081"/>
-						<string key="NSTitle" id="845099910">X11</string>
-						<string key="NSKeyEquiv" id="1005878359"/>
+					<object class="NSMenuItem" id="365880285">
+						<reference key="NSMenu" ref="524015605"/>
+						<string key="NSTitle" id="335360021">X11</string>
+						<string key="NSKeyEquiv" id="331740794"/>
 						<int key="NSKeyEquivModMask">1048576</int>
 						<int key="NSMnemonicLoc">2147483647</int>
-						<object class="NSCustomResource" key="NSOnImage" id="732862070">
-							<string key="NSClassName" id="642323532">NSImage</string>
+						<object class="NSCustomResource" key="NSOnImage" id="531645050">
+							<string key="NSClassName" id="1072749539">NSImage</string>
 							<string key="NSResourceName">NSMenuCheckmark</string>
 						</object>
-						<object class="NSCustomResource" key="NSMixedImage" id="154462367">
-							<reference key="NSClassName" ref="642323532"/>
+						<object class="NSCustomResource" key="NSMixedImage" id="246283459">
+							<reference key="NSClassName" ref="1072749539"/>
 							<string key="NSResourceName">NSMenuMixedState</string>
 						</object>
 						<string key="NSAction">submenuAction:</string>
-						<object class="NSMenu" key="NSSubmenu" id="856655711">
-							<reference key="NSTitle" ref="845099910"/>
+						<object class="NSMenu" key="NSSubmenu" id="576521955">
+							<reference key="NSTitle" ref="335360021"/>
 							<object class="NSMutableArray" key="NSMenuItems">
 								<bool key="EncodedWithXMLCoder">YES</bool>
-								<object class="NSMenuItem" id="588913325">
-									<reference key="NSMenu" ref="856655711"/>
+								<object class="NSMenuItem" id="139290918">
+									<reference key="NSMenu" ref="576521955"/>
 									<string key="NSTitle">About X11</string>
-									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<reference key="NSKeyEquiv" ref="331740794"/>
 									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="732862070"/>
-									<reference key="NSMixedImage" ref="154462367"/>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="246283459"/>
 								</object>
-								<object class="NSMenuItem" id="836585695">
-									<reference key="NSMenu" ref="856655711"/>
+								<object class="NSMenuItem" id="386173216">
+									<reference key="NSMenu" ref="576521955"/>
 									<string key="NSTitle">Preferences...</string>
 									<string key="NSKeyEquiv">,</string>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="732862070"/>
-									<reference key="NSMixedImage" ref="154462367"/>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="246283459"/>
 								</object>
-								<object class="NSMenuItem" id="562920394">
-									<reference key="NSMenu" ref="856655711"/>
+								<object class="NSMenuItem" id="272876017">
+									<reference key="NSMenu" ref="576521955"/>
 									<bool key="NSIsDisabled">YES</bool>
 									<bool key="NSIsSeparator">YES</bool>
-									<reference key="NSTitle" ref="1005878359"/>
-									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<reference key="NSTitle" ref="331740794"/>
+									<reference key="NSKeyEquiv" ref="331740794"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="732862070"/>
-									<reference key="NSMixedImage" ref="154462367"/>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="246283459"/>
 								</object>
-								<object class="NSMenuItem" id="63158341">
-									<reference key="NSMenu" ref="856655711"/>
+								<object class="NSMenuItem" id="32285361">
+									<reference key="NSMenu" ref="576521955"/>
 									<string key="NSTitle">Services</string>
-									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<reference key="NSKeyEquiv" ref="331740794"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="732862070"/>
-									<reference key="NSMixedImage" ref="154462367"/>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="246283459"/>
 									<string key="NSAction">submenuAction:</string>
-									<object class="NSMenu" key="NSSubmenu" id="502073457">
+									<object class="NSMenu" key="NSSubmenu" id="821388474">
 										<object class="NSMutableString" key="NSTitle">
 											<characters key="NS.bytes">Services</characters>
 										</object>
@@ -96,343 +97,343 @@
 										<string key="NSName">_NSServicesMenu</string>
 									</object>
 								</object>
-								<object class="NSMenuItem" id="635454008">
-									<reference key="NSMenu" ref="856655711"/>
+								<object class="NSMenuItem" id="431301145">
+									<reference key="NSMenu" ref="576521955"/>
 									<bool key="NSIsDisabled">YES</bool>
 									<bool key="NSIsSeparator">YES</bool>
-									<reference key="NSTitle" ref="1005878359"/>
-									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<reference key="NSTitle" ref="331740794"/>
+									<reference key="NSKeyEquiv" ref="331740794"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="732862070"/>
-									<reference key="NSMixedImage" ref="154462367"/>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="246283459"/>
 								</object>
-								<object class="NSMenuItem" id="101686423">
-									<reference key="NSMenu" ref="856655711"/>
+								<object class="NSMenuItem" id="6876565">
+									<reference key="NSMenu" ref="576521955"/>
 									<string key="NSTitle">Toggle Full Screen</string>
-									<string key="NSKeyEquiv" id="982375500">a</string>
+									<string key="NSKeyEquiv" id="934453074">a</string>
 									<int key="NSKeyEquivModMask">1572864</int>
 									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="732862070"/>
-									<reference key="NSMixedImage" ref="154462367"/>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="246283459"/>
 								</object>
-								<object class="NSMenuItem" id="754231570">
-									<reference key="NSMenu" ref="856655711"/>
+								<object class="NSMenuItem" id="479677589">
+									<reference key="NSMenu" ref="576521955"/>
 									<bool key="NSIsDisabled">YES</bool>
 									<bool key="NSIsSeparator">YES</bool>
-									<reference key="NSTitle" ref="1005878359"/>
-									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<reference key="NSTitle" ref="331740794"/>
+									<reference key="NSKeyEquiv" ref="331740794"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="732862070"/>
-									<reference key="NSMixedImage" ref="154462367"/>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="246283459"/>
 								</object>
-								<object class="NSMenuItem" id="147703239">
-									<reference key="NSMenu" ref="856655711"/>
+								<object class="NSMenuItem" id="301008465">
+									<reference key="NSMenu" ref="576521955"/>
 									<string key="NSTitle">Hide X11</string>
 									<string key="NSKeyEquiv">h</string>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="732862070"/>
-									<reference key="NSMixedImage" ref="154462367"/>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="246283459"/>
 									<int key="NSTag">42</int>
 								</object>
-								<object class="NSMenuItem" id="191312176">
-									<reference key="NSMenu" ref="856655711"/>
+								<object class="NSMenuItem" id="206802571">
+									<reference key="NSMenu" ref="576521955"/>
 									<string key="NSTitle">Hide Others</string>
-									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<reference key="NSKeyEquiv" ref="331740794"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="732862070"/>
-									<reference key="NSMixedImage" ref="154462367"/>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="246283459"/>
 								</object>
-								<object class="NSMenuItem" id="392807560">
-									<reference key="NSMenu" ref="856655711"/>
+								<object class="NSMenuItem" id="1023546148">
+									<reference key="NSMenu" ref="576521955"/>
 									<string key="NSTitle">Show All</string>
-									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<reference key="NSKeyEquiv" ref="331740794"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="732862070"/>
-									<reference key="NSMixedImage" ref="154462367"/>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="246283459"/>
 									<int key="NSTag">42</int>
 								</object>
-								<object class="NSMenuItem" id="648021277">
-									<reference key="NSMenu" ref="856655711"/>
+								<object class="NSMenuItem" id="848095279">
+									<reference key="NSMenu" ref="576521955"/>
 									<bool key="NSIsDisabled">YES</bool>
 									<bool key="NSIsSeparator">YES</bool>
-									<reference key="NSTitle" ref="1005878359"/>
-									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<reference key="NSTitle" ref="331740794"/>
+									<reference key="NSKeyEquiv" ref="331740794"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="732862070"/>
-									<reference key="NSMixedImage" ref="154462367"/>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="246283459"/>
 								</object>
-								<object class="NSMenuItem" id="275459236">
-									<reference key="NSMenu" ref="856655711"/>
+								<object class="NSMenuItem" id="274138642">
+									<reference key="NSMenu" ref="576521955"/>
 									<string key="NSTitle">Quit X11</string>
 									<string key="NSKeyEquiv">q</string>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="732862070"/>
-									<reference key="NSMixedImage" ref="154462367"/>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="246283459"/>
 								</object>
 							</object>
 							<string key="NSName">_NSAppleMenu</string>
 						</object>
 					</object>
-					<object class="NSMenuItem" id="940914550">
-						<reference key="NSMenu" ref="496556081"/>
-						<string key="NSTitle" id="942587293">Applications</string>
-						<reference key="NSKeyEquiv" ref="1005878359"/>
+					<object class="NSMenuItem" id="868031522">
+						<reference key="NSMenu" ref="524015605"/>
+						<string key="NSTitle" id="667842658">Applications</string>
+						<reference key="NSKeyEquiv" ref="331740794"/>
 						<int key="NSKeyEquivModMask">1048576</int>
 						<int key="NSMnemonicLoc">2147483647</int>
-						<reference key="NSOnImage" ref="732862070"/>
-						<reference key="NSMixedImage" ref="154462367"/>
+						<reference key="NSOnImage" ref="531645050"/>
+						<reference key="NSMixedImage" ref="246283459"/>
 						<string key="NSAction">submenuAction:</string>
-						<object class="NSMenu" key="NSSubmenu" id="684156653">
-							<reference key="NSTitle" ref="942587293"/>
+						<object class="NSMenu" key="NSSubmenu" id="981161348">
+							<reference key="NSTitle" ref="667842658"/>
 							<object class="NSMutableArray" key="NSMenuItems">
 								<bool key="EncodedWithXMLCoder">YES</bool>
-								<object class="NSMenuItem" id="940363272">
-									<reference key="NSMenu" ref="684156653"/>
+								<object class="NSMenuItem" id="390088328">
+									<reference key="NSMenu" ref="981161348"/>
 									<bool key="NSIsDisabled">YES</bool>
 									<bool key="NSIsSeparator">YES</bool>
-									<reference key="NSTitle" ref="1005878359"/>
-									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<reference key="NSTitle" ref="331740794"/>
+									<reference key="NSKeyEquiv" ref="331740794"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="732862070"/>
-									<reference key="NSMixedImage" ref="154462367"/>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="246283459"/>
 								</object>
-								<object class="NSMenuItem" id="767830074">
-									<reference key="NSMenu" ref="684156653"/>
+								<object class="NSMenuItem" id="1065386165">
+									<reference key="NSMenu" ref="981161348"/>
 									<string key="NSTitle">Customize...</string>
-									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<reference key="NSKeyEquiv" ref="331740794"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="732862070"/>
-									<reference key="NSMixedImage" ref="154462367"/>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="246283459"/>
 								</object>
 							</object>
 						</object>
 					</object>
-					<object class="NSMenuItem" id="326076563">
-						<reference key="NSMenu" ref="496556081"/>
-						<string key="NSTitle" id="38701994">Edit</string>
-						<reference key="NSKeyEquiv" ref="1005878359"/>
+					<object class="NSMenuItem" id="200491363">
+						<reference key="NSMenu" ref="524015605"/>
+						<string key="NSTitle" id="934359734">Edit</string>
+						<reference key="NSKeyEquiv" ref="331740794"/>
 						<int key="NSKeyEquivModMask">1048576</int>
 						<int key="NSMnemonicLoc">2147483647</int>
-						<reference key="NSOnImage" ref="732862070"/>
-						<reference key="NSMixedImage" ref="154462367"/>
+						<reference key="NSOnImage" ref="531645050"/>
+						<reference key="NSMixedImage" ref="246283459"/>
 						<string key="NSAction">submenuAction:</string>
-						<object class="NSMenu" key="NSSubmenu" id="932839819">
-							<reference key="NSTitle" ref="38701994"/>
+						<object class="NSMenu" key="NSSubmenu" id="526778998">
+							<reference key="NSTitle" ref="934359734"/>
 							<object class="NSMutableArray" key="NSMenuItems">
 								<bool key="EncodedWithXMLCoder">YES</bool>
-								<object class="NSMenuItem" id="159704190">
-									<reference key="NSMenu" ref="932839819"/>
+								<object class="NSMenuItem" id="1010221707">
+									<reference key="NSMenu" ref="526778998"/>
 									<string key="NSTitle">Undo</string>
 									<string key="NSKeyEquiv">z</string>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="732862070"/>
-									<reference key="NSMixedImage" ref="154462367"/>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="246283459"/>
 								</object>
-								<object class="NSMenuItem" id="634656440">
-									<reference key="NSMenu" ref="932839819"/>
+								<object class="NSMenuItem" id="535038564">
+									<reference key="NSMenu" ref="526778998"/>
 									<string key="NSTitle">Redo</string>
 									<string key="NSKeyEquiv">Z</string>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="732862070"/>
-									<reference key="NSMixedImage" ref="154462367"/>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="246283459"/>
 								</object>
-								<object class="NSMenuItem" id="342107529">
-									<reference key="NSMenu" ref="932839819"/>
+								<object class="NSMenuItem" id="839739619">
+									<reference key="NSMenu" ref="526778998"/>
 									<bool key="NSIsDisabled">YES</bool>
 									<bool key="NSIsSeparator">YES</bool>
-									<reference key="NSTitle" ref="1005878359"/>
-									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<reference key="NSTitle" ref="331740794"/>
+									<reference key="NSKeyEquiv" ref="331740794"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="732862070"/>
-									<reference key="NSMixedImage" ref="154462367"/>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="246283459"/>
 								</object>
-								<object class="NSMenuItem" id="590926585">
-									<reference key="NSMenu" ref="932839819"/>
+								<object class="NSMenuItem" id="581727829">
+									<reference key="NSMenu" ref="526778998"/>
 									<string key="NSTitle">Cut</string>
 									<string key="NSKeyEquiv">x</string>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="732862070"/>
-									<reference key="NSMixedImage" ref="154462367"/>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="246283459"/>
 								</object>
-								<object class="NSMenuItem" id="204575684">
-									<reference key="NSMenu" ref="932839819"/>
+								<object class="NSMenuItem" id="185296989">
+									<reference key="NSMenu" ref="526778998"/>
 									<string key="NSTitle">Copy</string>
 									<string key="NSKeyEquiv">c</string>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="732862070"/>
-									<reference key="NSMixedImage" ref="154462367"/>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="246283459"/>
 								</object>
-								<object class="NSMenuItem" id="739720090">
-									<reference key="NSMenu" ref="932839819"/>
+								<object class="NSMenuItem" id="924678073">
+									<reference key="NSMenu" ref="526778998"/>
 									<string key="NSTitle">Paste</string>
 									<string key="NSKeyEquiv">v</string>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="732862070"/>
-									<reference key="NSMixedImage" ref="154462367"/>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="246283459"/>
 								</object>
-								<object class="NSMenuItem" id="549812830">
-									<reference key="NSMenu" ref="932839819"/>
+								<object class="NSMenuItem" id="994817848">
+									<reference key="NSMenu" ref="526778998"/>
 									<string key="NSTitle">Delete</string>
-									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<reference key="NSKeyEquiv" ref="331740794"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="732862070"/>
-									<reference key="NSMixedImage" ref="154462367"/>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="246283459"/>
 								</object>
-								<object class="NSMenuItem" id="584461964">
-									<reference key="NSMenu" ref="932839819"/>
+								<object class="NSMenuItem" id="322866464">
+									<reference key="NSMenu" ref="526778998"/>
 									<string key="NSTitle">Select All</string>
-									<reference key="NSKeyEquiv" ref="982375500"/>
+									<reference key="NSKeyEquiv" ref="934453074"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="732862070"/>
-									<reference key="NSMixedImage" ref="154462367"/>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="246283459"/>
 								</object>
 							</object>
 						</object>
 					</object>
-					<object class="NSMenuItem" id="736341863">
-						<reference key="NSMenu" ref="496556081"/>
+					<object class="NSMenuItem" id="931553638">
+						<reference key="NSMenu" ref="524015605"/>
 						<string key="NSTitle">Window</string>
-						<reference key="NSKeyEquiv" ref="1005878359"/>
+						<reference key="NSKeyEquiv" ref="331740794"/>
 						<int key="NSKeyEquivModMask">1048576</int>
 						<int key="NSMnemonicLoc">2147483647</int>
-						<reference key="NSOnImage" ref="732862070"/>
-						<reference key="NSMixedImage" ref="154462367"/>
+						<reference key="NSOnImage" ref="531645050"/>
+						<reference key="NSMixedImage" ref="246283459"/>
 						<string key="NSAction">submenuAction:</string>
-						<object class="NSMenu" key="NSSubmenu" id="943404979">
+						<object class="NSMenu" key="NSSubmenu" id="96874957">
 							<object class="NSMutableString" key="NSTitle">
 								<characters key="NS.bytes">Window</characters>
 							</object>
 							<object class="NSMutableArray" key="NSMenuItems">
 								<bool key="EncodedWithXMLCoder">YES</bool>
-								<object class="NSMenuItem" id="915861349">
-									<reference key="NSMenu" ref="943404979"/>
-									<string key="NSTitle">Minimize Window</string>
+								<object class="NSMenuItem" id="677652931">
+									<reference key="NSMenu" ref="96874957"/>
+									<string key="NSTitle">Minimize</string>
 									<string key="NSKeyEquiv">m</string>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="732862070"/>
-									<reference key="NSMixedImage" ref="154462367"/>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="246283459"/>
 								</object>
-								<object class="NSMenuItem" id="442007350">
-									<reference key="NSMenu" ref="943404979"/>
-									<string key="NSTitle">Close Window</string>
-									<string key="NSKeyEquiv">w</string>
+								<object class="NSMenuItem" id="1066447520">
+									<reference key="NSMenu" ref="96874957"/>
+									<string key="NSTitle">Zoom</string>
+									<reference key="NSKeyEquiv" ref="331740794"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="732862070"/>
-									<reference key="NSMixedImage" ref="154462367"/>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="246283459"/>
 								</object>
-								<object class="NSMenuItem" id="722764538">
-									<reference key="NSMenu" ref="943404979"/>
-									<string key="NSTitle">Zoom Window</string>
-									<reference key="NSKeyEquiv" ref="1005878359"/>
-									<int key="NSKeyEquivModMask">1048576</int>
+								<object class="NSMenuItem" id="1036389925">
+									<reference key="NSMenu" ref="96874957"/>
+									<string key="NSTitle">Cycle Through Windows</string>
+									<string key="NSKeyEquiv">`</string>
+									<int key="NSKeyEquivModMask">1048840</int>
 									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="732862070"/>
-									<reference key="NSMixedImage" ref="154462367"/>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="246283459"/>
 								</object>
-								<object class="NSMenuItem" id="783034074">
-									<reference key="NSMenu" ref="943404979"/>
-									<bool key="NSIsDisabled">YES</bool>
-									<bool key="NSIsSeparator">YES</bool>
-									<reference key="NSTitle" ref="1005878359"/>
-									<reference key="NSKeyEquiv" ref="1005878359"/>
-									<int key="NSKeyEquivModMask">1048576</int>
+								<object class="NSMenuItem" id="369641893">
+									<reference key="NSMenu" ref="96874957"/>
+									<string key="NSTitle">Reverse Cycle Through Windows</string>
+									<string key="NSKeyEquiv">~</string>
+									<int key="NSKeyEquivModMask">1179914</int>
 									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="732862070"/>
-									<reference key="NSMixedImage" ref="154462367"/>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="246283459"/>
 								</object>
-								<object class="NSMenuItem" id="283496700">
-									<reference key="NSMenu" ref="943404979"/>
-									<string key="NSTitle">Next Window</string>
-									<string type="base64-UTF8" key="NSKeyEquiv">75yDA</string>
+								<object class="NSMenuItem" id="280172320">
+									<reference key="NSMenu" ref="96874957"/>
+									<bool key="NSIsDisabled">YES</bool>
+									<bool key="NSIsSeparator">YES</bool>
+									<reference key="NSTitle" ref="331740794"/>
+									<reference key="NSKeyEquiv" ref="331740794"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="732862070"/>
-									<reference key="NSMixedImage" ref="154462367"/>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="246283459"/>
 								</object>
-								<object class="NSMenuItem" id="500397106">
-									<reference key="NSMenu" ref="943404979"/>
-									<string key="NSTitle">Previous Window</string>
-									<string type="base64-UTF8" key="NSKeyEquiv">75yCA</string>
+								<object class="NSMenuItem" id="984461797">
+									<reference key="NSMenu" ref="96874957"/>
+									<string key="NSTitle">Close</string>
+									<string key="NSKeyEquiv">w</string>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="732862070"/>
-									<reference key="NSMixedImage" ref="154462367"/>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="246283459"/>
 								</object>
-								<object class="NSMenuItem" id="303213786">
-									<reference key="NSMenu" ref="943404979"/>
+								<object class="NSMenuItem" id="155085383">
+									<reference key="NSMenu" ref="96874957"/>
 									<bool key="NSIsDisabled">YES</bool>
 									<bool key="NSIsSeparator">YES</bool>
-									<reference key="NSTitle" ref="1005878359"/>
-									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<reference key="NSTitle" ref="331740794"/>
+									<reference key="NSKeyEquiv" ref="331740794"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="732862070"/>
-									<reference key="NSMixedImage" ref="154462367"/>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="246283459"/>
 								</object>
-								<object class="NSMenuItem" id="853630143">
-									<reference key="NSMenu" ref="943404979"/>
+								<object class="NSMenuItem" id="276216762">
+									<reference key="NSMenu" ref="96874957"/>
 									<string key="NSTitle">Bring All to Front</string>
-									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<reference key="NSKeyEquiv" ref="331740794"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="732862070"/>
-									<reference key="NSMixedImage" ref="154462367"/>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="246283459"/>
 								</object>
-								<object class="NSMenuItem" id="332241222">
-									<reference key="NSMenu" ref="943404979"/>
+								<object class="NSMenuItem" id="444952046">
+									<reference key="NSMenu" ref="96874957"/>
 									<bool key="NSIsDisabled">YES</bool>
 									<bool key="NSIsSeparator">YES</bool>
-									<reference key="NSTitle" ref="1005878359"/>
-									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<reference key="NSTitle" ref="331740794"/>
+									<reference key="NSKeyEquiv" ref="331740794"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="732862070"/>
-									<reference key="NSMixedImage" ref="154462367"/>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="246283459"/>
 								</object>
 							</object>
 							<string key="NSName">_NSWindowsMenu</string>
 						</object>
 					</object>
-					<object class="NSMenuItem" id="934950259">
-						<reference key="NSMenu" ref="496556081"/>
-						<string key="NSTitle" id="955297347">Help</string>
-						<reference key="NSKeyEquiv" ref="1005878359"/>
+					<object class="NSMenuItem" id="551174276">
+						<reference key="NSMenu" ref="524015605"/>
+						<string key="NSTitle" id="214661970">Help</string>
+						<reference key="NSKeyEquiv" ref="331740794"/>
 						<int key="NSKeyEquivModMask">1048576</int>
 						<int key="NSMnemonicLoc">2147483647</int>
-						<reference key="NSOnImage" ref="732862070"/>
-						<reference key="NSMixedImage" ref="154462367"/>
+						<reference key="NSOnImage" ref="531645050"/>
+						<reference key="NSMixedImage" ref="246283459"/>
 						<string key="NSAction">submenuAction:</string>
-						<object class="NSMenu" key="NSSubmenu" id="1052262524">
-							<reference key="NSTitle" ref="955297347"/>
+						<object class="NSMenu" key="NSSubmenu" id="511848303">
+							<reference key="NSTitle" ref="214661970"/>
 							<object class="NSMutableArray" key="NSMenuItems">
 								<bool key="EncodedWithXMLCoder">YES</bool>
-								<object class="NSMenuItem" id="122992289">
-									<reference key="NSMenu" ref="1052262524"/>
+								<object class="NSMenuItem" id="504984881">
+									<reference key="NSMenu" ref="511848303"/>
 									<string key="NSTitle">X11 Help</string>
-									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<reference key="NSKeyEquiv" ref="331740794"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="732862070"/>
-									<reference key="NSMixedImage" ref="154462367"/>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="246283459"/>
 								</object>
 							</object>
 						</object>
@@ -440,562 +441,599 @@
 				</object>
 				<string key="NSName">_NSMainMenu</string>
 			</object>
-			<object class="NSCustomObject" id="88064061">
-				<string key="NSClassName" id="517073442">X11Controller</string>
+			<object class="NSCustomObject" id="485884620">
+				<string key="NSClassName" id="865849805">X11Controller</string>
 			</object>
-			<object class="NSWindowTemplate" id="210544761">
+			<object class="NSWindowTemplate" id="124913468">
 				<int key="NSWindowStyleMask">3</int>
 				<int key="NSWindowBacking">2</int>
-				<string key="NSWindowRect">{{319, 323}, {478, 316}}</string>
+				<string key="NSWindowRect">{{319, 294}, {481, 345}}</string>
 				<int key="NSWTFlags">1350041600</int>
 				<string key="NSWindowTitle">X11 Preferences</string>
-				<string key="NSWindowClass" id="643663067">NSPanel</string>
+				<string key="NSWindowClass" id="666842945">NSPanel</string>
 				<object class="NSMutableString" key="NSViewClass">
 					<characters key="NS.bytes">View</characters>
 				</object>
 				<string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string>
 				<string key="NSWindowContentMinSize">{213, 107}</string>
-				<object class="NSView" key="NSWindowView" id="404125972">
+				<object class="NSView" key="NSWindowView" id="941366957">
 					<nil key="NSNextResponder"/>
 					<int key="NSvFlags">256</int>
 					<object class="NSMutableArray" key="NSSubviews">
 						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSTabView" id="75927203">
-							<reference key="NSNextResponder" ref="404125972"/>
+						<object class="NSTabView" id="448510093">
+							<reference key="NSNextResponder" ref="941366957"/>
 							<int key="NSvFlags">256</int>
 							<object class="NSMutableArray" key="NSSubviews">
 								<bool key="EncodedWithXMLCoder">YES</bool>
-								<object class="NSView" id="527709877">
-									<reference key="NSNextResponder" ref="75927203"/>
+								<object class="NSView" id="596750588">
+									<reference key="NSNextResponder" ref="448510093"/>
 									<int key="NSvFlags">256</int>
 									<object class="NSMutableArray" key="NSSubviews">
 										<bool key="EncodedWithXMLCoder">YES</bool>
-										<object class="NSButton" id="1045559310">
-											<reference key="NSNextResponder" ref="527709877"/>
+										<object class="NSButton" id="119157981">
+											<reference key="NSNextResponder" ref="596750588"/>
 											<int key="NSvFlags">256</int>
-											<string key="NSFrame">{{18, 90}, {402, 18}}</string>
-											<reference key="NSSuperview" ref="527709877"/>
+											<string key="NSFrame">{{18, 243}, {402, 18}}</string>
+											<reference key="NSSuperview" ref="596750588"/>
 											<bool key="NSEnabled">YES</bool>
-											<object class="NSButtonCell" key="NSCell" id="225158677">
+											<object class="NSButtonCell" key="NSCell" id="990762273">
 												<int key="NSCellFlags">67239424</int>
 												<int key="NSCellFlags2">0</int>
-												<string key="NSContents">Use system alert effect</string>
-												<object class="NSFont" key="NSSupport" id="706343604">
-													<string key="NSName" id="508374773">LucidaGrande</string>
+												<string key="NSContents">Emulate three button mouse</string>
+												<object class="NSFont" key="NSSupport" id="463863101">
+													<string key="NSName" id="512586816">LucidaGrande</string>
 													<double key="NSSize">1.300000e+01</double>
 													<int key="NSfFlags">1044</int>
 												</object>
-												<reference key="NSControlView" ref="1045559310"/>
+												<reference key="NSControlView" ref="119157981"/>
 												<int key="NSButtonFlags">1211912703</int>
 												<int key="NSButtonFlags2">2</int>
-												<object class="NSButtonImageSource" key="NSAlternateImage" id="876172194">
+												<object class="NSButtonImageSource" key="NSAlternateImage" id="391434389">
 													<string key="NSImageName">NSSwitch</string>
 												</object>
-												<reference key="NSAlternateContents" ref="1005878359"/>
-												<reference key="NSKeyEquivalent" ref="1005878359"/>
+												<reference key="NSAlternateContents" ref="331740794"/>
+												<reference key="NSKeyEquivalent" ref="331740794"/>
 												<int key="NSPeriodicDelay">200</int>
 												<int key="NSPeriodicInterval">25</int>
 											</object>
 										</object>
-										<object class="NSTextField" id="67626595">
-											<reference key="NSNextResponder" ref="527709877"/>
+										<object class="NSTextField" id="443008216">
+											<reference key="NSNextResponder" ref="596750588"/>
 											<int key="NSvFlags">256</int>
-											<string key="NSFrame">{{36, 56}, {385, 28}}</string>
-											<reference key="NSSuperview" ref="527709877"/>
+											<string key="NSFrame">{{36, 93}, {385, 31}}</string>
+											<reference key="NSSuperview" ref="596750588"/>
 											<bool key="NSEnabled">YES</bool>
-											<object class="NSTextFieldCell" key="NSCell" id="1072420481">
+											<object class="NSTextFieldCell" key="NSCell" id="391919450">
 												<int key="NSCellFlags">67239424</int>
 												<int key="NSCellFlags2">4194304</int>
-												<string key="NSContents">X11 beeps will use the standard system alert, as defined in the Sound Effects system preferences panel.</string>
+												<string key="NSContents">When enabled, menu bar key equivalents may interfere with X11 applications that use the Meta modifier.</string>
 												<object class="NSFont" key="NSSupport" id="26">
-													<reference key="NSName" ref="508374773"/>
+													<reference key="NSName" ref="512586816"/>
 													<double key="NSSize">1.100000e+01</double>
 													<int key="NSfFlags">3100</int>
 												</object>
-												<reference key="NSControlView" ref="67626595"/>
-												<object class="NSColor" key="NSBackgroundColor" id="320865741">
+												<reference key="NSControlView" ref="443008216"/>
+												<object class="NSColor" key="NSBackgroundColor" id="57160303">
 													<int key="NSColorSpace">6</int>
-													<string key="NSCatalogName" id="1000587476">System</string>
+													<string key="NSCatalogName" id="905527164">System</string>
 													<string key="NSColorName">controlColor</string>
-													<object class="NSColor" key="NSColor" id="1000384962">
+													<object class="NSColor" key="NSColor" id="590688762">
 														<int key="NSColorSpace">3</int>
 														<bytes key="NSWhite">MC42NjY2NjY2OQA</bytes>
 													</object>
 												</object>
-												<object class="NSColor" key="NSTextColor" id="233849662">
+												<object class="NSColor" key="NSTextColor" id="930815747">
 													<int key="NSColorSpace">6</int>
-													<reference key="NSCatalogName" ref="1000587476"/>
+													<reference key="NSCatalogName" ref="905527164"/>
 													<string key="NSColorName">controlTextColor</string>
-													<object class="NSColor" key="NSColor" id="608123050">
+													<object class="NSColor" key="NSColor" id="214098874">
 														<int key="NSColorSpace">3</int>
 														<bytes key="NSWhite">MAA</bytes>
 													</object>
 												</object>
 											</object>
 										</object>
-										<object class="NSPopUpButton" id="300224954">
-											<reference key="NSNextResponder" ref="527709877"/>
+										<object class="NSTextField" id="282885445">
+											<reference key="NSNextResponder" ref="596750588"/>
 											<int key="NSvFlags">256</int>
-											<string key="NSFrame">{{74, 209}, {128, 26}}</string>
-											<reference key="NSSuperview" ref="527709877"/>
+											<string key="NSFrame">{{36, 208}, {385, 29}}</string>
+											<reference key="NSSuperview" ref="596750588"/>
 											<bool key="NSEnabled">YES</bool>
-											<object class="NSPopUpButtonCell" key="NSCell" id="301142744">
-												<int key="NSCellFlags">-2076049856</int>
-												<int key="NSCellFlags2">1024</int>
-												<reference key="NSSupport" ref="706343604"/>
-												<reference key="NSControlView" ref="300224954"/>
-												<int key="NSButtonFlags">109199615</int>
-												<int key="NSButtonFlags2">1</int>
-												<object class="NSFont" key="NSAlternateImage">
-													<reference key="NSName" ref="508374773"/>
-													<double key="NSSize">1.300000e+01</double>
-													<int key="NSfFlags">16</int>
-												</object>
-												<object class="NSMutableString" key="NSAlternateContents">
-													<characters key="NS.bytes"/>
-												</object>
-												<object class="NSMutableString" key="NSKeyEquivalent">
-													<characters key="NS.bytes"/>
-												</object>
-												<int key="NSPeriodicDelay">400</int>
-												<int key="NSPeriodicInterval">75</int>
-												<object class="NSMenuItem" key="NSMenuItem" id="473657062">
-													<reference key="NSMenu" ref="1071781177"/>
-													<string key="NSTitle">From Display</string>
-													<reference key="NSKeyEquiv" ref="1005878359"/>
-													<int key="NSKeyEquivModMask">1048576</int>
-													<int key="NSMnemonicLoc">2147483647</int>
-													<int key="NSState">1</int>
-													<reference key="NSOnImage" ref="732862070"/>
-													<reference key="NSMixedImage" ref="154462367"/>
-													<string key="NSAction">_popUpItemAction:</string>
-													<int key="NSTag">-1</int>
-													<reference key="NSTarget" ref="301142744"/>
-												</object>
-												<bool key="NSMenuItemRespectAlignment">YES</bool>
-												<object class="NSMenu" key="NSMenu" id="1071781177">
-													<object class="NSMutableString" key="NSTitle">
-														<characters key="NS.bytes">OtherViews</characters>
-													</object>
-													<object class="NSMutableArray" key="NSMenuItems">
-														<bool key="EncodedWithXMLCoder">YES</bool>
-														<reference ref="473657062"/>
-														<object class="NSMenuItem" id="827519886">
-															<reference key="NSMenu" ref="1071781177"/>
-															<string key="NSTitle">256 Colors</string>
-															<reference key="NSKeyEquiv" ref="1005878359"/>
-															<int key="NSKeyEquivModMask">1048576</int>
-															<int key="NSMnemonicLoc">2147483647</int>
-															<reference key="NSOnImage" ref="732862070"/>
-															<reference key="NSMixedImage" ref="154462367"/>
-															<string key="NSAction">_popUpItemAction:</string>
-															<int key="NSTag">8</int>
-															<reference key="NSTarget" ref="301142744"/>
-														</object>
-														<object class="NSMenuItem" id="247508345">
-															<reference key="NSMenu" ref="1071781177"/>
-															<string key="NSTitle">Thousands</string>
-															<reference key="NSKeyEquiv" ref="1005878359"/>
-															<int key="NSKeyEquivModMask">1048576</int>
-															<int key="NSMnemonicLoc">2147483647</int>
-															<reference key="NSOnImage" ref="732862070"/>
-															<reference key="NSMixedImage" ref="154462367"/>
-															<string key="NSAction">_popUpItemAction:</string>
-															<int key="NSTag">15</int>
-															<reference key="NSTarget" ref="301142744"/>
-														</object>
-														<object class="NSMenuItem" id="611307925">
-															<reference key="NSMenu" ref="1071781177"/>
-															<string key="NSTitle">Millions</string>
-															<reference key="NSKeyEquiv" ref="1005878359"/>
-															<int key="NSKeyEquivModMask">1048576</int>
-															<int key="NSMnemonicLoc">2147483647</int>
-															<reference key="NSOnImage" ref="732862070"/>
-															<reference key="NSMixedImage" ref="154462367"/>
-															<string key="NSAction">_popUpItemAction:</string>
-															<int key="NSTag">24</int>
-															<reference key="NSTarget" ref="301142744"/>
-														</object>
-													</object>
-												</object>
-												<int key="NSPreferredEdge">3</int>
-												<bool key="NSUsesItemFromMenu">YES</bool>
-												<bool key="NSAltersState">YES</bool>
-												<int key="NSArrowPosition">1</int>
+											<object class="NSTextFieldCell" key="NSCell" id="649334366">
+												<int key="NSCellFlags">67239424</int>
+												<int key="NSCellFlags2">4194304</int>
+												<string type="base64-UTF8" key="NSContents">SG9sZCBPcHRpb24gYW5kIENvbW1hbmQgd2hpbGUgY2xpY2tpbmcgdG8gYWN0aXZhdGUgdGhlIG1pZGRs
+ZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KA</string>
+												<reference key="NSSupport" ref="26"/>
+												<reference key="NSControlView" ref="282885445"/>
+												<reference key="NSBackgroundColor" ref="57160303"/>
+												<reference key="NSTextColor" ref="930815747"/>
 											</object>
 										</object>
-										<object class="NSTextField" id="717889178">
-											<reference key="NSNextResponder" ref="527709877"/>
+										<object class="NSButton" id="842100515">
+											<reference key="NSNextResponder" ref="596750588"/>
 											<int key="NSvFlags">256</int>
-											<string key="NSFrame">{{17, 212}, {55, 20}}</string>
-											<reference key="NSSuperview" ref="527709877"/>
+											<string key="NSFrame">{{18, 130}, {402, 18}}</string>
+											<reference key="NSSuperview" ref="596750588"/>
 											<bool key="NSEnabled">YES</bool>
-											<object class="NSTextFieldCell" key="NSCell" id="749756205">
+											<object class="NSButtonCell" key="NSCell" id="940564599">
 												<int key="NSCellFlags">67239424</int>
-												<int key="NSCellFlags2">4194304</int>
-												<string type="base64-UTF8" key="NSContents">Q29sb3JzOgo</string>
-												<reference key="NSSupport" ref="706343604"/>
-												<reference key="NSControlView" ref="717889178"/>
-												<reference key="NSBackgroundColor" ref="320865741"/>
-												<reference key="NSTextColor" ref="233849662"/>
+												<int key="NSCellFlags2">0</int>
+												<string key="NSContents">Enable key equivalents under X11</string>
+												<reference key="NSSupport" ref="463863101"/>
+												<reference key="NSControlView" ref="842100515"/>
+												<int key="NSButtonFlags">1211912703</int>
+												<int key="NSButtonFlags2">2</int>
+												<reference key="NSAlternateImage" ref="391434389"/>
+												<reference key="NSAlternateContents" ref="331740794"/>
+												<reference key="NSKeyEquivalent" ref="331740794"/>
+												<int key="NSPeriodicDelay">200</int>
+												<int key="NSPeriodicInterval">25</int>
 											</object>
 										</object>
-										<object class="NSTextField" id="114173823">
-											<reference key="NSNextResponder" ref="527709877"/>
+										<object class="NSTextField" id="31160162">
+											<reference key="NSNextResponder" ref="596750588"/>
 											<int key="NSvFlags">256</int>
-											<string key="NSFrame">{{36, 190}, {392, 14}}</string>
-											<reference key="NSSuperview" ref="527709877"/>
+											<string key="NSFrame">{{36, 159}, {385, 14}}</string>
+											<reference key="NSSuperview" ref="596750588"/>
 											<bool key="NSEnabled">YES</bool>
-											<object class="NSTextFieldCell" key="NSCell" id="725554783">
+											<object class="NSTextFieldCell" key="NSCell" id="666057093">
 												<int key="NSCellFlags">67239424</int>
 												<int key="NSCellFlags2">4194304</int>
-												<string key="NSContents">This option takes effect when X11 is launched again.</string>
+												<string key="NSContents">Allows input menu changes to overwrite the current X11 keymap.</string>
 												<reference key="NSSupport" ref="26"/>
-												<reference key="NSControlView" ref="114173823"/>
-												<reference key="NSBackgroundColor" ref="320865741"/>
-												<reference key="NSTextColor" ref="233849662"/>
+												<reference key="NSControlView" ref="31160162"/>
+												<reference key="NSBackgroundColor" ref="57160303"/>
+												<reference key="NSTextColor" ref="930815747"/>
+											</object>
+										</object>
+										<object class="NSButton" id="179949713">
+											<reference key="NSNextResponder" ref="596750588"/>
+											<int key="NSvFlags">256</int>
+											<string key="NSFrame">{{18, 179}, {402, 18}}</string>
+											<reference key="NSSuperview" ref="596750588"/>
+											<bool key="NSEnabled">YES</bool>
+											<object class="NSButtonCell" key="NSCell" id="967619578">
+												<int key="NSCellFlags">67239424</int>
+												<int key="NSCellFlags2">0</int>
+												<string key="NSContents">Follow system keyboard layout</string>
+												<reference key="NSSupport" ref="463863101"/>
+												<reference key="NSControlView" ref="179949713"/>
+												<int key="NSButtonFlags">1211912703</int>
+												<int key="NSButtonFlags2">2</int>
+												<reference key="NSAlternateImage" ref="391434389"/>
+												<reference key="NSAlternateContents" ref="331740794"/>
+												<reference key="NSKeyEquivalent" ref="331740794"/>
+												<int key="NSPeriodicDelay">200</int>
+												<int key="NSPeriodicInterval">25</int>
 											</object>
 										</object>
-										<object class="NSButton" id="817420822">
-											<reference key="NSNextResponder" ref="527709877"/>
+										<object class="NSButton" id="915448994">
+											<reference key="NSNextResponder" ref="596750588"/>
 											<int key="NSvFlags">256</int>
-											<string key="NSFrame">{{18, 156}, {409, 23}}</string>
-											<reference key="NSSuperview" ref="527709877"/>
+											<string key="NSFrame">{{18, 69}, {402, 18}}</string>
+											<reference key="NSSuperview" ref="596750588"/>
 											<bool key="NSEnabled">YES</bool>
-											<object class="NSButtonCell" key="NSCell" id="100363081">
+											<object class="NSButtonCell" key="NSCell" id="117056849">
 												<int key="NSCellFlags">67239424</int>
 												<int key="NSCellFlags2">0</int>
-												<string key="NSContents">Full screen mode</string>
-												<reference key="NSSupport" ref="706343604"/>
-												<reference key="NSControlView" ref="817420822"/>
+												<string key="NSContents">Click-through Inactive Windows</string>
+												<reference key="NSSupport" ref="463863101"/>
+												<reference key="NSControlView" ref="915448994"/>
 												<int key="NSButtonFlags">1211912703</int>
 												<int key="NSButtonFlags2">2</int>
-												<reference key="NSAlternateImage" ref="876172194"/>
-												<reference key="NSAlternateContents" ref="1005878359"/>
-												<reference key="NSKeyEquivalent" ref="1005878359"/>
+												<reference key="NSAlternateImage" ref="391434389"/>
+												<reference key="NSAlternateContents" ref="331740794"/>
+												<reference key="NSKeyEquivalent" ref="331740794"/>
 												<int key="NSPeriodicDelay">200</int>
 												<int key="NSPeriodicInterval">25</int>
 											</object>
 										</object>
-										<object class="NSTextField" id="959270736">
-											<reference key="NSNextResponder" ref="527709877"/>
+										<object class="NSTextField" id="707276799">
+											<reference key="NSNextResponder" ref="596750588"/>
 											<int key="NSvFlags">256</int>
-											<string key="NSFrame">{{36, 119}, {385, 31}}</string>
-											<reference key="NSSuperview" ref="527709877"/>
+											<string key="NSFrame">{{33, 32}, {385, 31}}</string>
+											<reference key="NSSuperview" ref="596750588"/>
 											<bool key="NSEnabled">YES</bool>
-											<object class="NSTextFieldCell" key="NSCell" id="550432669">
+											<object class="NSTextFieldCell" key="NSCell" id="318286890">
 												<int key="NSCellFlags">67239424</int>
 												<int key="NSCellFlags2">4194304</int>
-												<string key="NSContents">Enables the X11 root window. Use the Command-Option-A keystroke to enter and leave full screen mode.</string>
+												<string key="NSContents">When enabled, clicking on an inactive window will cause that mouse click to pass through to that window in addition to activating it.</string>
 												<reference key="NSSupport" ref="26"/>
-												<reference key="NSControlView" ref="959270736"/>
-												<reference key="NSBackgroundColor" ref="320865741"/>
-												<reference key="NSTextColor" ref="233849662"/>
+												<reference key="NSControlView" ref="707276799"/>
+												<reference key="NSBackgroundColor" ref="57160303"/>
+												<reference key="NSTextColor" ref="930815747"/>
 											</object>
 										</object>
 									</object>
-									<string key="NSFrame">{{10, 33}, {438, 253}}</string>
-									<reference key="NSSuperview" ref="75927203"/>
+									<string key="NSFrame">{{10, 33}, {438, 279}}</string>
+									<reference key="NSSuperview" ref="448510093"/>
 								</object>
 							</object>
-							<string key="NSFrame">{{10, 7}, {458, 299}}</string>
-							<reference key="NSSuperview" ref="404125972"/>
+							<string key="NSFrame">{{10, 10}, {458, 325}}</string>
+							<reference key="NSSuperview" ref="941366957"/>
 							<object class="NSMutableArray" key="NSTabViewItems">
 								<bool key="EncodedWithXMLCoder">YES</bool>
-								<object class="NSTabViewItem" id="17244958">
+								<object class="NSTabViewItem" id="287591690">
 									<object class="NSMutableString" key="NSIdentifier">
 										<characters key="NS.bytes">1</characters>
 									</object>
-									<object class="NSView" key="NSView" id="600332710">
+									<reference key="NSView" ref="596750588"/>
+									<string key="NSLabel">Input</string>
+									<reference key="NSColor" ref="57160303"/>
+									<reference key="NSTabView" ref="448510093"/>
+								</object>
+								<object class="NSTabViewItem" id="960678392">
+									<object class="NSMutableString" key="NSIdentifier">
+										<characters key="NS.bytes">2</characters>
+									</object>
+									<object class="NSView" key="NSView" id="515308735">
 										<nil key="NSNextResponder"/>
 										<int key="NSvFlags">256</int>
 										<object class="NSMutableArray" key="NSSubviews">
 											<bool key="EncodedWithXMLCoder">YES</bool>
-											<object class="NSButton" id="808306730">
-												<reference key="NSNextResponder" ref="600332710"/>
+											<object class="NSButton" id="418227126">
+												<reference key="NSNextResponder" ref="515308735"/>
 												<int key="NSvFlags">256</int>
-												<string key="NSFrame">{{18, 217}, {402, 18}}</string>
-												<reference key="NSSuperview" ref="600332710"/>
+												<string key="NSFrame">{{18, 116}, {402, 18}}</string>
+												<reference key="NSSuperview" ref="515308735"/>
 												<bool key="NSEnabled">YES</bool>
-												<object class="NSButtonCell" key="NSCell" id="727617204">
+												<object class="NSButtonCell" key="NSCell" id="1016069354">
 													<int key="NSCellFlags">67239424</int>
 													<int key="NSCellFlags2">0</int>
-													<string key="NSContents">Emulate three button mouse</string>
-													<reference key="NSSupport" ref="706343604"/>
-													<reference key="NSControlView" ref="808306730"/>
+													<string key="NSContents">Use system alert effect</string>
+													<reference key="NSSupport" ref="463863101"/>
+													<reference key="NSControlView" ref="418227126"/>
 													<int key="NSButtonFlags">1211912703</int>
 													<int key="NSButtonFlags2">2</int>
-													<reference key="NSAlternateImage" ref="876172194"/>
-													<reference key="NSAlternateContents" ref="1005878359"/>
-													<reference key="NSKeyEquivalent" ref="1005878359"/>
+													<reference key="NSAlternateImage" ref="391434389"/>
+													<reference key="NSAlternateContents" ref="331740794"/>
+													<reference key="NSKeyEquivalent" ref="331740794"/>
 													<int key="NSPeriodicDelay">200</int>
 													<int key="NSPeriodicInterval">25</int>
 												</object>
 											</object>
-											<object class="NSTextField" id="618388983">
-												<reference key="NSNextResponder" ref="600332710"/>
+											<object class="NSTextField" id="1039016593">
+												<reference key="NSNextResponder" ref="515308735"/>
 												<int key="NSvFlags">256</int>
-												<string key="NSFrame">{{36, 67}, {385, 31}}</string>
-												<reference key="NSSuperview" ref="600332710"/>
+												<string key="NSFrame">{{36, 82}, {385, 28}}</string>
+												<reference key="NSSuperview" ref="515308735"/>
 												<bool key="NSEnabled">YES</bool>
-												<object class="NSTextFieldCell" key="NSCell" id="140236247">
+												<object class="NSTextFieldCell" key="NSCell" id="624655599">
 													<int key="NSCellFlags">67239424</int>
 													<int key="NSCellFlags2">4194304</int>
-													<string key="NSContents">When enabled, menu bar key equivalents may interfere with X11 applications that use the Meta modifier.</string>
+													<string key="NSContents">X11 beeps will use the standard system alert, as defined in the Sound Effects system preferences panel.</string>
 													<reference key="NSSupport" ref="26"/>
-													<reference key="NSControlView" ref="618388983"/>
-													<reference key="NSBackgroundColor" ref="320865741"/>
-													<reference key="NSTextColor" ref="233849662"/>
+													<reference key="NSControlView" ref="1039016593"/>
+													<reference key="NSBackgroundColor" ref="57160303"/>
+													<reference key="NSTextColor" ref="930815747"/>
 												</object>
 											</object>
-											<object class="NSTextField" id="754792079">
-												<reference key="NSNextResponder" ref="600332710"/>
+											<object class="NSPopUpButton" id="709074847">
+												<reference key="NSNextResponder" ref="515308735"/>
 												<int key="NSvFlags">256</int>
-												<string key="NSFrame">{{36, 182}, {385, 29}}</string>
-												<reference key="NSSuperview" ref="600332710"/>
+												<string key="NSFrame">{{74, 235}, {128, 26}}</string>
+												<reference key="NSSuperview" ref="515308735"/>
 												<bool key="NSEnabled">YES</bool>
-												<object class="NSTextFieldCell" key="NSCell" id="110537159">
-													<int key="NSCellFlags">67239424</int>
-													<int key="NSCellFlags2">4194304</int>
-													<string type="base64-UTF8" key="NSContents">SG9sZCBPcHRpb24gYW5kIENvbW1hbmQgd2hpbGUgY2xpY2tpbmcgdG8gYWN0aXZhdGUgdGhlIG1pZGRs
-ZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KA</string>
-													<reference key="NSSupport" ref="26"/>
-													<reference key="NSControlView" ref="754792079"/>
-													<reference key="NSBackgroundColor" ref="320865741"/>
-													<reference key="NSTextColor" ref="233849662"/>
+												<object class="NSPopUpButtonCell" key="NSCell" id="633115429">
+													<int key="NSCellFlags">-2076049856</int>
+													<int key="NSCellFlags2">1024</int>
+													<reference key="NSSupport" ref="463863101"/>
+													<reference key="NSControlView" ref="709074847"/>
+													<int key="NSButtonFlags">109199615</int>
+													<int key="NSButtonFlags2">1</int>
+													<object class="NSFont" key="NSAlternateImage">
+														<reference key="NSName" ref="512586816"/>
+														<double key="NSSize">1.300000e+01</double>
+														<int key="NSfFlags">16</int>
+													</object>
+													<object class="NSMutableString" key="NSAlternateContents">
+														<characters key="NS.bytes"/>
+													</object>
+													<object class="NSMutableString" key="NSKeyEquivalent">
+														<characters key="NS.bytes"/>
+													</object>
+													<int key="NSPeriodicDelay">400</int>
+													<int key="NSPeriodicInterval">75</int>
+													<object class="NSMenuItem" key="NSMenuItem" id="616492372">
+														<reference key="NSMenu" ref="341113515"/>
+														<string key="NSTitle">From Display</string>
+														<reference key="NSKeyEquiv" ref="331740794"/>
+														<int key="NSKeyEquivModMask">1048576</int>
+														<int key="NSMnemonicLoc">2147483647</int>
+														<int key="NSState">1</int>
+														<reference key="NSOnImage" ref="531645050"/>
+														<reference key="NSMixedImage" ref="246283459"/>
+														<string key="NSAction">_popUpItemAction:</string>
+														<int key="NSTag">-1</int>
+														<reference key="NSTarget" ref="633115429"/>
+													</object>
+													<bool key="NSMenuItemRespectAlignment">YES</bool>
+													<object class="NSMenu" key="NSMenu" id="341113515">
+														<object class="NSMutableString" key="NSTitle">
+															<characters key="NS.bytes">OtherViews</characters>
+														</object>
+														<object class="NSMutableArray" key="NSMenuItems">
+															<bool key="EncodedWithXMLCoder">YES</bool>
+															<reference ref="616492372"/>
+															<object class="NSMenuItem" id="759499526">
+																<reference key="NSMenu" ref="341113515"/>
+																<string key="NSTitle">256 Colors</string>
+																<reference key="NSKeyEquiv" ref="331740794"/>
+																<int key="NSKeyEquivModMask">1048576</int>
+																<int key="NSMnemonicLoc">2147483647</int>
+																<reference key="NSOnImage" ref="531645050"/>
+																<reference key="NSMixedImage" ref="246283459"/>
+																<string key="NSAction">_popUpItemAction:</string>
+																<int key="NSTag">8</int>
+																<reference key="NSTarget" ref="633115429"/>
+															</object>
+															<object class="NSMenuItem" id="543935434">
+																<reference key="NSMenu" ref="341113515"/>
+																<string key="NSTitle">Thousands</string>
+																<reference key="NSKeyEquiv" ref="331740794"/>
+																<int key="NSKeyEquivModMask">1048576</int>
+																<int key="NSMnemonicLoc">2147483647</int>
+																<reference key="NSOnImage" ref="531645050"/>
+																<reference key="NSMixedImage" ref="246283459"/>
+																<string key="NSAction">_popUpItemAction:</string>
+																<int key="NSTag">15</int>
+																<reference key="NSTarget" ref="633115429"/>
+															</object>
+															<object class="NSMenuItem" id="836673018">
+																<reference key="NSMenu" ref="341113515"/>
+																<string key="NSTitle">Millions</string>
+																<reference key="NSKeyEquiv" ref="331740794"/>
+																<int key="NSKeyEquivModMask">1048576</int>
+																<int key="NSMnemonicLoc">2147483647</int>
+																<reference key="NSOnImage" ref="531645050"/>
+																<reference key="NSMixedImage" ref="246283459"/>
+																<string key="NSAction">_popUpItemAction:</string>
+																<int key="NSTag">24</int>
+																<reference key="NSTarget" ref="633115429"/>
+															</object>
+														</object>
+													</object>
+													<int key="NSPreferredEdge">3</int>
+													<bool key="NSUsesItemFromMenu">YES</bool>
+													<bool key="NSAltersState">YES</bool>
+													<int key="NSArrowPosition">1</int>
 												</object>
 											</object>
-											<object class="NSButton" id="677150201">
-												<reference key="NSNextResponder" ref="600332710"/>
+											<object class="NSTextField" id="201731424">
+												<reference key="NSNextResponder" ref="515308735"/>
 												<int key="NSvFlags">256</int>
-												<string key="NSFrame">{{18, 104}, {402, 18}}</string>
-												<reference key="NSSuperview" ref="600332710"/>
+												<string key="NSFrame">{{17, 238}, {55, 20}}</string>
+												<reference key="NSSuperview" ref="515308735"/>
 												<bool key="NSEnabled">YES</bool>
-												<object class="NSButtonCell" key="NSCell" id="46680941">
+												<object class="NSTextFieldCell" key="NSCell" id="930265681">
 													<int key="NSCellFlags">67239424</int>
-													<int key="NSCellFlags2">0</int>
-													<string key="NSContents">Enable key equivalents under X11</string>
-													<reference key="NSSupport" ref="706343604"/>
-													<reference key="NSControlView" ref="677150201"/>
-													<int key="NSButtonFlags">1211912703</int>
-													<int key="NSButtonFlags2">2</int>
-													<reference key="NSAlternateImage" ref="876172194"/>
-													<reference key="NSAlternateContents" ref="1005878359"/>
-													<reference key="NSKeyEquivalent" ref="1005878359"/>
-													<int key="NSPeriodicDelay">200</int>
-													<int key="NSPeriodicInterval">25</int>
+													<int key="NSCellFlags2">4194304</int>
+													<string type="base64-UTF8" key="NSContents">Q29sb3JzOgo</string>
+													<reference key="NSSupport" ref="463863101"/>
+													<reference key="NSControlView" ref="201731424"/>
+													<reference key="NSBackgroundColor" ref="57160303"/>
+													<reference key="NSTextColor" ref="930815747"/>
 												</object>
 											</object>
-											<object class="NSTextField" id="228801813">
-												<reference key="NSNextResponder" ref="600332710"/>
+											<object class="NSTextField" id="86150604">
+												<reference key="NSNextResponder" ref="515308735"/>
 												<int key="NSvFlags">256</int>
-												<string key="NSFrame">{{36, 133}, {385, 14}}</string>
-												<reference key="NSSuperview" ref="600332710"/>
+												<string key="NSFrame">{{36, 216}, {392, 14}}</string>
+												<reference key="NSSuperview" ref="515308735"/>
 												<bool key="NSEnabled">YES</bool>
-												<object class="NSTextFieldCell" key="NSCell" id="415694484">
+												<object class="NSTextFieldCell" key="NSCell" id="311969422">
 													<int key="NSCellFlags">67239424</int>
 													<int key="NSCellFlags2">4194304</int>
-													<string key="NSContents">Allows input menu changes to overwrite the current X11 keymap.</string>
+													<string key="NSContents">This option takes effect when X11 is launched again.</string>
 													<reference key="NSSupport" ref="26"/>
-													<reference key="NSControlView" ref="228801813"/>
-													<reference key="NSBackgroundColor" ref="320865741"/>
-													<reference key="NSTextColor" ref="233849662"/>
+													<reference key="NSControlView" ref="86150604"/>
+													<reference key="NSBackgroundColor" ref="57160303"/>
+													<reference key="NSTextColor" ref="930815747"/>
 												</object>
 											</object>
-											<object class="NSButton" id="793493073">
-												<reference key="NSNextResponder" ref="600332710"/>
+											<object class="NSButton" id="477203622">
+												<reference key="NSNextResponder" ref="515308735"/>
 												<int key="NSvFlags">256</int>
-												<string key="NSFrame">{{18, 153}, {402, 18}}</string>
-												<reference key="NSSuperview" ref="600332710"/>
+												<string key="NSFrame">{{18, 182}, {409, 23}}</string>
+												<reference key="NSSuperview" ref="515308735"/>
 												<bool key="NSEnabled">YES</bool>
-												<object class="NSButtonCell" key="NSCell" id="466260504">
+												<object class="NSButtonCell" key="NSCell" id="631531164">
 													<int key="NSCellFlags">67239424</int>
 													<int key="NSCellFlags2">0</int>
-													<string key="NSContents">Follow system keyboard layout</string>
-													<reference key="NSSupport" ref="706343604"/>
-													<reference key="NSControlView" ref="793493073"/>
+													<string key="NSContents">Full screen mode</string>
+													<reference key="NSSupport" ref="463863101"/>
+													<reference key="NSControlView" ref="477203622"/>
 													<int key="NSButtonFlags">1211912703</int>
 													<int key="NSButtonFlags2">2</int>
-													<reference key="NSAlternateImage" ref="876172194"/>
-													<reference key="NSAlternateContents" ref="1005878359"/>
-													<reference key="NSKeyEquivalent" ref="1005878359"/>
+													<reference key="NSAlternateImage" ref="391434389"/>
+													<reference key="NSAlternateContents" ref="331740794"/>
+													<reference key="NSKeyEquivalent" ref="331740794"/>
 													<int key="NSPeriodicDelay">200</int>
 													<int key="NSPeriodicInterval">25</int>
 												</object>
 											</object>
+											<object class="NSTextField" id="298603383">
+												<reference key="NSNextResponder" ref="515308735"/>
+												<int key="NSvFlags">256</int>
+												<string key="NSFrame">{{36, 145}, {385, 31}}</string>
+												<reference key="NSSuperview" ref="515308735"/>
+												<bool key="NSEnabled">YES</bool>
+												<object class="NSTextFieldCell" key="NSCell" id="761107402">
+													<int key="NSCellFlags">67239424</int>
+													<int key="NSCellFlags2">4194304</int>
+													<string key="NSContents">Enables the X11 root window. Use the Command-Option-A keystroke to enter and leave full screen mode.</string>
+													<reference key="NSSupport" ref="26"/>
+													<reference key="NSControlView" ref="298603383"/>
+													<reference key="NSBackgroundColor" ref="57160303"/>
+													<reference key="NSTextColor" ref="930815747"/>
+												</object>
+											</object>
 										</object>
-										<string key="NSFrame">{{10, 33}, {438, 253}}</string>
-									</object>
-									<string key="NSLabel">Input</string>
-									<reference key="NSColor" ref="320865741"/>
-									<reference key="NSTabView" ref="75927203"/>
-								</object>
-								<object class="NSTabViewItem" id="493727923">
-									<object class="NSMutableString" key="NSIdentifier">
-										<characters key="NS.bytes">2</characters>
+										<string key="NSFrame">{{10, 33}, {438, 279}}</string>
 									</object>
-									<reference key="NSView" ref="527709877"/>
 									<string key="NSLabel">Output</string>
-									<reference key="NSColor" ref="320865741"/>
-									<reference key="NSTabView" ref="75927203"/>
+									<reference key="NSColor" ref="57160303"/>
+									<reference key="NSTabView" ref="448510093"/>
 								</object>
-								<object class="NSTabViewItem" id="1036577743">
-									<object class="NSView" key="NSView" id="536248195">
+								<object class="NSTabViewItem" id="348328898">
+									<object class="NSView" key="NSView" id="300811574">
 										<nil key="NSNextResponder"/>
 										<int key="NSvFlags">256</int>
 										<object class="NSMutableArray" key="NSSubviews">
 											<bool key="EncodedWithXMLCoder">YES</bool>
-											<object class="NSButton" id="137435489">
-												<reference key="NSNextResponder" ref="536248195"/>
+											<object class="NSButton" id="989050925">
+												<reference key="NSNextResponder" ref="300811574"/>
 												<int key="NSvFlags">256</int>
-												<string key="NSFrame">{{18, 217}, {402, 18}}</string>
-												<reference key="NSSuperview" ref="536248195"/>
+												<string key="NSFrame">{{18, 243}, {402, 18}}</string>
+												<reference key="NSSuperview" ref="300811574"/>
 												<bool key="NSEnabled">YES</bool>
-												<object class="NSButtonCell" key="NSCell" id="891925158">
+												<object class="NSButtonCell" key="NSCell" id="189594322">
 													<int key="NSCellFlags">67239424</int>
 													<int key="NSCellFlags2">0</int>
 													<string key="NSContents">Authenticate connections</string>
-													<reference key="NSSupport" ref="706343604"/>
-													<reference key="NSControlView" ref="137435489"/>
+													<reference key="NSSupport" ref="463863101"/>
+													<reference key="NSControlView" ref="989050925"/>
 													<int key="NSButtonFlags">1211912703</int>
 													<int key="NSButtonFlags2">2</int>
-													<reference key="NSAlternateImage" ref="876172194"/>
-													<reference key="NSAlternateContents" ref="1005878359"/>
-													<reference key="NSKeyEquivalent" ref="1005878359"/>
+													<reference key="NSAlternateImage" ref="391434389"/>
+													<reference key="NSAlternateContents" ref="331740794"/>
+													<reference key="NSKeyEquivalent" ref="331740794"/>
 													<int key="NSPeriodicDelay">200</int>
 													<int key="NSPeriodicInterval">25</int>
 												</object>
 											</object>
-											<object class="NSButton" id="663154230">
-												<reference key="NSNextResponder" ref="536248195"/>
+											<object class="NSButton" id="700826966">
+												<reference key="NSNextResponder" ref="300811574"/>
 												<int key="NSvFlags">256</int>
-												<string key="NSFrame">{{18, 140}, {402, 18}}</string>
-												<reference key="NSSuperview" ref="536248195"/>
+												<string key="NSFrame">{{18, 166}, {402, 18}}</string>
+												<reference key="NSSuperview" ref="300811574"/>
 												<bool key="NSEnabled">YES</bool>
-												<object class="NSButtonCell" key="NSCell" id="836703945">
+												<object class="NSButtonCell" key="NSCell" id="489340979">
 													<int key="NSCellFlags">67239424</int>
 													<int key="NSCellFlags2">0</int>
 													<string key="NSContents">Allow connections from network clients</string>
-													<reference key="NSSupport" ref="706343604"/>
-													<reference key="NSControlView" ref="663154230"/>
+													<reference key="NSSupport" ref="463863101"/>
+													<reference key="NSControlView" ref="700826966"/>
 													<int key="NSButtonFlags">1211912703</int>
 													<int key="NSButtonFlags2">2</int>
-													<reference key="NSAlternateImage" ref="876172194"/>
-													<reference key="NSAlternateContents" ref="1005878359"/>
-													<reference key="NSKeyEquivalent" ref="1005878359"/>
+													<reference key="NSAlternateImage" ref="391434389"/>
+													<reference key="NSAlternateContents" ref="331740794"/>
+													<reference key="NSKeyEquivalent" ref="331740794"/>
 													<int key="NSPeriodicDelay">200</int>
 													<int key="NSPeriodicInterval">25</int>
 												</object>
 											</object>
-											<object class="NSTextField" id="417801719">
-												<reference key="NSNextResponder" ref="536248195"/>
+											<object class="NSTextField" id="168436707">
+												<reference key="NSNextResponder" ref="300811574"/>
 												<int key="NSvFlags">256</int>
-												<string key="NSFrame">{{36, 169}, {385, 42}}</string>
-												<reference key="NSSuperview" ref="536248195"/>
+												<string key="NSFrame">{{36, 195}, {385, 42}}</string>
+												<reference key="NSSuperview" ref="300811574"/>
 												<bool key="NSEnabled">YES</bool>
-												<object class="NSTextFieldCell" key="NSCell" id="935570098">
+												<object class="NSTextFieldCell" key="NSCell" id="53243865">
 													<int key="NSCellFlags">67239424</int>
 													<int key="NSCellFlags2">4194304</int>
 													<string type="base64-UTF8" key="NSContents">TGF1bmNoaW5nIFgxMSB3aWxsIGNyZWF0ZSBYYXV0aG9yaXR5IGFjY2Vzcy1jb250cm9sIGtleXMuIElm
 IHRoZSBzeXN0ZW0ncyBJUCBhZGRyZXNzIGNoYW5nZXMsIHRoZXNlIGtleXMgYmVjb21lIGludmFsaWQg
 d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 													<reference key="NSSupport" ref="26"/>
-													<reference key="NSControlView" ref="417801719"/>
-													<reference key="NSBackgroundColor" ref="320865741"/>
-													<reference key="NSTextColor" ref="233849662"/>
+													<reference key="NSControlView" ref="168436707"/>
+													<reference key="NSBackgroundColor" ref="57160303"/>
+													<reference key="NSTextColor" ref="930815747"/>
 												</object>
 											</object>
-											<object class="NSTextField" id="115954190">
-												<reference key="NSNextResponder" ref="536248195"/>
+											<object class="NSTextField" id="363817195">
+												<reference key="NSNextResponder" ref="300811574"/>
 												<int key="NSvFlags">256</int>
-												<string key="NSFrame">{{36, 92}, {385, 42}}</string>
-												<reference key="NSSuperview" ref="536248195"/>
+												<string key="NSFrame">{{36, 118}, {385, 42}}</string>
+												<reference key="NSSuperview" ref="300811574"/>
 												<bool key="NSEnabled">YES</bool>
-												<object class="NSTextFieldCell" key="NSCell" id="144257898">
+												<object class="NSTextFieldCell" key="NSCell" id="390084685">
 													<int key="NSCellFlags">67239424</int>
 													<int key="NSCellFlags2">4194304</int>
 													<string key="NSContents">If enabled, Authenticate connections must also be enabled to ensure system security. When disabled, connections from remote applications are not allowed.</string>
 													<reference key="NSSupport" ref="26"/>
-													<reference key="NSControlView" ref="115954190"/>
-													<reference key="NSBackgroundColor" ref="320865741"/>
-													<reference key="NSTextColor" ref="233849662"/>
+													<reference key="NSControlView" ref="363817195"/>
+													<reference key="NSBackgroundColor" ref="57160303"/>
+													<reference key="NSTextColor" ref="930815747"/>
 												</object>
 											</object>
-											<object class="NSTextField" id="1067279202">
-												<reference key="NSNextResponder" ref="536248195"/>
+											<object class="NSTextField" id="223835729">
+												<reference key="NSNextResponder" ref="300811574"/>
 												<int key="NSvFlags">256</int>
-												<string key="NSFrame">{{17, 20}, {404, 14}}</string>
-												<reference key="NSSuperview" ref="536248195"/>
+												<string key="NSFrame">{{20, 17}, {404, 14}}</string>
+												<reference key="NSSuperview" ref="300811574"/>
 												<bool key="NSEnabled">YES</bool>
-												<object class="NSTextFieldCell" key="NSCell" id="703874672">
+												<object class="NSTextFieldCell" key="NSCell" id="283628678">
 													<int key="NSCellFlags">67239424</int>
 													<int key="NSCellFlags2">4194304</int>
 													<string key="NSContents">These options take effect when X11 is next launched.</string>
 													<reference key="NSSupport" ref="26"/>
-													<reference key="NSControlView" ref="1067279202"/>
-													<reference key="NSBackgroundColor" ref="320865741"/>
-													<reference key="NSTextColor" ref="233849662"/>
+													<reference key="NSControlView" ref="223835729"/>
+													<reference key="NSBackgroundColor" ref="57160303"/>
+													<reference key="NSTextColor" ref="930815747"/>
 												</object>
 											</object>
 										</object>
-										<string key="NSFrame">{{10, 33}, {438, 253}}</string>
+										<string key="NSFrame">{{10, 33}, {438, 279}}</string>
 									</object>
 									<string key="NSLabel">Security</string>
-									<reference key="NSColor" ref="320865741"/>
-									<reference key="NSTabView" ref="75927203"/>
+									<reference key="NSColor" ref="57160303"/>
+									<reference key="NSTabView" ref="448510093"/>
 								</object>
 							</object>
-							<reference key="NSSelectedTabViewItem" ref="493727923"/>
-							<reference key="NSFont" ref="706343604"/>
+							<reference key="NSSelectedTabViewItem" ref="287591690"/>
+							<reference key="NSFont" ref="463863101"/>
 							<int key="NSTvFlags">0</int>
 							<bool key="NSAllowTruncatedLabels">YES</bool>
 							<bool key="NSDrawsBackground">YES</bool>
 						</object>
 					</object>
-					<string key="NSFrameSize">{478, 316}</string>
+					<string key="NSFrameSize">{481, 345}</string>
 				</object>
 				<string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
 				<string key="NSMinSize">{213, 129}</string>
 				<string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
 				<string key="NSFrameAutosaveName">x11_prefs</string>
 			</object>
-			<object class="NSWindowTemplate" id="796776534">
+			<object class="NSWindowTemplate" id="604417141">
 				<int key="NSWindowStyleMask">11</int>
 				<int key="NSWindowBacking">2</int>
-				<string key="NSWindowRect">{{279, 270}, {486, 310}}</string>
+				<string key="NSWindowRect">{{279, 253}, {486, 327}}</string>
 				<int key="NSWTFlags">1350041600</int>
 				<string key="NSWindowTitle">X11 Application Menu</string>
-				<reference key="NSWindowClass" ref="643663067"/>
+				<reference key="NSWindowClass" ref="666842945"/>
 				<object class="NSMutableString" key="NSViewClass">
 					<characters key="NS.bytes">View</characters>
 				</object>
 				<string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string>
 				<string key="NSWindowContentMinSize">{213, 107}</string>
-				<object class="NSView" key="NSWindowView" id="1039094689">
+				<object class="NSView" key="NSWindowView" id="85544634">
 					<nil key="NSNextResponder"/>
 					<int key="NSvFlags">256</int>
 					<object class="NSMutableArray" key="NSSubviews">
 						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSButton" id="1002101696">
-							<reference key="NSNextResponder" ref="1039094689"/>
+						<object class="NSButton" id="724002248">
+							<reference key="NSNextResponder" ref="85544634"/>
 							<int key="NSvFlags">303</int>
-							<string key="NSFrame">{{388, 12}, {84, 32}}</string>
-							<reference key="NSSuperview" ref="1039094689"/>
+							<string key="NSFrame">{{268, 12}, {84, 32}}</string>
+							<reference key="NSSuperview" ref="85544634"/>
 							<bool key="NSEnabled">YES</bool>
-							<object class="NSButtonCell" key="NSCell" id="558394524">
+							<object class="NSButtonCell" key="NSCell" id="809610613">
 								<int key="NSCellFlags">-2080244224</int>
 								<int key="NSCellFlags2">137887744</int>
 								<string key="NSContents">Done</string>
-								<reference key="NSSupport" ref="706343604"/>
-								<reference key="NSControlView" ref="1002101696"/>
+								<reference key="NSSupport" ref="463863101"/>
+								<reference key="NSControlView" ref="724002248"/>
 								<int key="NSButtonFlags">-2038284033</int>
 								<int key="NSButtonFlags2">1</int>
-								<object class="NSFont" key="NSAlternateImage" id="965938342">
+								<object class="NSFont" key="NSAlternateImage" id="549406736">
 									<string key="NSName">Helvetica</string>
 									<double key="NSSize">1.300000e+01</double>
 									<int key="NSfFlags">16</int>
 								</object>
-								<reference key="NSAlternateContents" ref="1005878359"/>
+								<reference key="NSAlternateContents" ref="331740794"/>
 								<object class="NSMutableString" key="NSKeyEquivalent">
 									<characters key="NS.bytes"/>
 								</object>
@@ -1003,21 +1041,21 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 								<int key="NSPeriodicInterval">25</int>
 							</object>
 						</object>
-						<object class="NSButton" id="711288662">
-							<reference key="NSNextResponder" ref="1039094689"/>
+						<object class="NSButton" id="671954382">
+							<reference key="NSNextResponder" ref="85544634"/>
 							<int key="NSvFlags">301</int>
-							<string key="NSFrame">{{372, 230}, {100, 32}}</string>
-							<reference key="NSSuperview" ref="1039094689"/>
+							<string key="NSFrame">{{372, 247}, {100, 32}}</string>
+							<reference key="NSSuperview" ref="85544634"/>
 							<bool key="NSEnabled">YES</bool>
-							<object class="NSButtonCell" key="NSCell" id="413164923">
+							<object class="NSButtonCell" key="NSCell" id="143554520">
 								<int key="NSCellFlags">67239424</int>
 								<int key="NSCellFlags2">137887744</int>
 								<string key="NSContents">Duplicate</string>
-								<reference key="NSSupport" ref="706343604"/>
-								<reference key="NSControlView" ref="711288662"/>
+								<reference key="NSSupport" ref="463863101"/>
+								<reference key="NSControlView" ref="671954382"/>
 								<int key="NSButtonFlags">-2038284033</int>
 								<int key="NSButtonFlags2">1</int>
-								<reference key="NSAlternateImage" ref="965938342"/>
+								<reference key="NSAlternateImage" ref="549406736"/>
 								<object class="NSMutableString" key="NSAlternateContents">
 									<characters key="NS.bytes"/>
 								</object>
@@ -1028,21 +1066,21 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 								<int key="NSPeriodicInterval">25</int>
 							</object>
 						</object>
-						<object class="NSButton" id="634701477">
-							<reference key="NSNextResponder" ref="1039094689"/>
+						<object class="NSButton" id="492358940">
+							<reference key="NSNextResponder" ref="85544634"/>
 							<int key="NSvFlags">301</int>
-							<string key="NSFrame">{{372, 198}, {100, 32}}</string>
-							<reference key="NSSuperview" ref="1039094689"/>
+							<string key="NSFrame">{{372, 215}, {100, 32}}</string>
+							<reference key="NSSuperview" ref="85544634"/>
 							<bool key="NSEnabled">YES</bool>
-							<object class="NSButtonCell" key="NSCell" id="26248495">
+							<object class="NSButtonCell" key="NSCell" id="8201128">
 								<int key="NSCellFlags">67239424</int>
 								<int key="NSCellFlags2">137887744</int>
 								<string key="NSContents">Remove</string>
-								<reference key="NSSupport" ref="706343604"/>
-								<reference key="NSControlView" ref="634701477"/>
+								<reference key="NSSupport" ref="463863101"/>
+								<reference key="NSControlView" ref="492358940"/>
 								<int key="NSButtonFlags">-2038284033</int>
 								<int key="NSButtonFlags2">1</int>
-								<reference key="NSAlternateImage" ref="965938342"/>
+								<reference key="NSAlternateImage" ref="549406736"/>
 								<object class="NSMutableString" key="NSAlternateContents">
 									<characters key="NS.bytes"/>
 								</object>
@@ -1053,39 +1091,39 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 								<int key="NSPeriodicInterval">25</int>
 							</object>
 						</object>
-						<object class="NSScrollView" id="1011512617">
-							<reference key="NSNextResponder" ref="1039094689"/>
+						<object class="NSScrollView" id="1063387772">
+							<reference key="NSNextResponder" ref="85544634"/>
 							<int key="NSvFlags">307</int>
 							<object class="NSMutableArray" key="NSSubviews">
 								<bool key="EncodedWithXMLCoder">YES</bool>
-								<object class="NSClipView" id="963977695">
-									<reference key="NSNextResponder" ref="1011512617"/>
+								<object class="NSClipView" id="580565898">
+									<reference key="NSNextResponder" ref="1063387772"/>
 									<int key="NSvFlags">2304</int>
 									<object class="NSMutableArray" key="NSSubviews">
 										<bool key="EncodedWithXMLCoder">YES</bool>
-										<object class="NSTableView" id="411425856">
-											<reference key="NSNextResponder" ref="963977695"/>
+										<object class="NSTableView" id="905092943">
+											<reference key="NSNextResponder" ref="580565898"/>
 											<int key="NSvFlags">256</int>
 											<string key="NSFrameSize">{333, 197}</string>
-											<reference key="NSSuperview" ref="963977695"/>
+											<reference key="NSSuperview" ref="580565898"/>
 											<bool key="NSEnabled">YES</bool>
-											<object class="NSTableHeaderView" key="NSHeaderView" id="526973850">
-												<reference key="NSNextResponder" ref="935843221"/>
+											<object class="NSTableHeaderView" key="NSHeaderView" id="792419186">
+												<reference key="NSNextResponder" ref="672307654"/>
 												<int key="NSvFlags">256</int>
 												<string key="NSFrameSize">{333, 17}</string>
-												<reference key="NSSuperview" ref="935843221"/>
-												<reference key="NSTableView" ref="411425856"/>
+												<reference key="NSSuperview" ref="672307654"/>
+												<reference key="NSTableView" ref="905092943"/>
 											</object>
-											<object class="_NSCornerView" key="NSCornerView" id="182265797">
-												<reference key="NSNextResponder" ref="1011512617"/>
+											<object class="_NSCornerView" key="NSCornerView" id="898633680">
+												<reference key="NSNextResponder" ref="1063387772"/>
 												<int key="NSvFlags">256</int>
 												<string key="NSFrame">{{334, 0}, {16, 17}}</string>
-												<reference key="NSSuperview" ref="1011512617"/>
+												<reference key="NSSuperview" ref="1063387772"/>
 											</object>
 											<object class="NSMutableArray" key="NSTableColumns">
 												<bool key="EncodedWithXMLCoder">YES</bool>
-												<object class="NSTableColumn" id="621551865">
-													<double key="NSWidth">7.900000e+01</double>
+												<object class="NSTableColumn" id="84282687">
+													<double key="NSWidth">1.110000e+02</double>
 													<double key="NSMinWidth">4.000000e+01</double>
 													<double key="NSMaxWidth">1.000000e+03</double>
 													<object class="NSTableHeaderCell" key="NSHeaderCell">
@@ -1093,35 +1131,36 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 														<int key="NSCellFlags2">0</int>
 														<string key="NSContents">Name</string>
 														<reference key="NSSupport" ref="26"/>
-														<object class="NSColor" key="NSBackgroundColor" id="182967138">
+														<object class="NSColor" key="NSBackgroundColor" id="113872566">
 															<int key="NSColorSpace">3</int>
 															<bytes key="NSWhite">MC4zMzMzMzI5OQA</bytes>
 														</object>
-														<object class="NSColor" key="NSTextColor" id="645274518">
+														<object class="NSColor" key="NSTextColor" id="249576247">
 															<int key="NSColorSpace">6</int>
-															<reference key="NSCatalogName" ref="1000587476"/>
+															<reference key="NSCatalogName" ref="905527164"/>
 															<string key="NSColorName">headerTextColor</string>
-															<reference key="NSColor" ref="608123050"/>
+															<reference key="NSColor" ref="214098874"/>
 														</object>
 													</object>
-													<object class="NSTextFieldCell" key="NSDataCell" id="195831317">
+													<object class="NSTextFieldCell" key="NSDataCell" id="432610585">
 														<int key="NSCellFlags">338820672</int>
 														<int key="NSCellFlags2">1024</int>
-														<reference key="NSSupport" ref="706343604"/>
-														<reference key="NSControlView" ref="411425856"/>
-														<object class="NSColor" key="NSBackgroundColor" id="722293876">
+														<string key="NSContents" id="548220387">Text Cell</string>
+														<reference key="NSSupport" ref="463863101"/>
+														<reference key="NSControlView" ref="905092943"/>
+														<object class="NSColor" key="NSBackgroundColor" id="822946413">
 															<int key="NSColorSpace">3</int>
 															<bytes key="NSWhite">MQA</bytes>
 														</object>
-														<reference key="NSTextColor" ref="233849662"/>
+														<reference key="NSTextColor" ref="930815747"/>
 													</object>
 													<int key="NSResizingMask">3</int>
 													<bool key="NSIsResizeable">YES</bool>
 													<bool key="NSIsEditable">YES</bool>
-													<reference key="NSTableView" ref="411425856"/>
+													<reference key="NSTableView" ref="905092943"/>
 												</object>
-												<object class="NSTableColumn" id="976084317">
-													<double key="NSWidth">1.937310e+02</double>
+												<object class="NSTableColumn" id="938444323">
+													<double key="NSWidth">1.327310e+02</double>
 													<double key="NSMinWidth">6.273100e+01</double>
 													<double key="NSMaxWidth">1.000000e+03</double>
 													<object class="NSTableHeaderCell" key="NSHeaderCell">
@@ -1129,24 +1168,25 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 														<int key="NSCellFlags2">0</int>
 														<string key="NSContents">Command</string>
 														<reference key="NSSupport" ref="26"/>
-														<reference key="NSBackgroundColor" ref="182967138"/>
-														<reference key="NSTextColor" ref="645274518"/>
+														<reference key="NSBackgroundColor" ref="113872566"/>
+														<reference key="NSTextColor" ref="249576247"/>
 													</object>
-													<object class="NSTextFieldCell" key="NSDataCell" id="656574062">
+													<object class="NSTextFieldCell" key="NSDataCell" id="825378892">
 														<int key="NSCellFlags">338820672</int>
 														<int key="NSCellFlags2">1024</int>
-														<reference key="NSSupport" ref="706343604"/>
-														<reference key="NSControlView" ref="411425856"/>
-														<reference key="NSBackgroundColor" ref="722293876"/>
-														<reference key="NSTextColor" ref="233849662"/>
+														<reference key="NSContents" ref="548220387"/>
+														<reference key="NSSupport" ref="463863101"/>
+														<reference key="NSControlView" ref="905092943"/>
+														<reference key="NSBackgroundColor" ref="822946413"/>
+														<reference key="NSTextColor" ref="930815747"/>
 													</object>
 													<int key="NSResizingMask">3</int>
 													<bool key="NSIsResizeable">YES</bool>
 													<bool key="NSIsEditable">YES</bool>
-													<reference key="NSTableView" ref="411425856"/>
+													<reference key="NSTableView" ref="905092943"/>
 												</object>
-												<object class="NSTableColumn" id="661701503">
-													<double key="NSWidth">5.100000e+01</double>
+												<object class="NSTableColumn" id="242608782">
+													<double key="NSWidth">8.000000e+01</double>
 													<double key="NSMinWidth">1.000000e+01</double>
 													<double key="NSMaxWidth">1.000000e+03</double>
 													<object class="NSTableHeaderCell" key="NSHeaderCell">
@@ -1156,42 +1196,43 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 														<reference key="NSSupport" ref="26"/>
 														<object class="NSColor" key="NSBackgroundColor">
 															<int key="NSColorSpace">6</int>
-															<reference key="NSCatalogName" ref="1000587476"/>
+															<reference key="NSCatalogName" ref="905527164"/>
 															<string key="NSColorName">headerColor</string>
-															<reference key="NSColor" ref="722293876"/>
+															<reference key="NSColor" ref="822946413"/>
 														</object>
-														<reference key="NSTextColor" ref="645274518"/>
+														<reference key="NSTextColor" ref="249576247"/>
 													</object>
-													<object class="NSTextFieldCell" key="NSDataCell" id="90031137">
+													<object class="NSTextFieldCell" key="NSDataCell" id="34714764">
 														<int key="NSCellFlags">338820672</int>
 														<int key="NSCellFlags2">1024</int>
+														<reference key="NSContents" ref="548220387"/>
 														<object class="NSFont" key="NSSupport">
-															<reference key="NSName" ref="508374773"/>
+															<reference key="NSName" ref="512586816"/>
 															<double key="NSSize">1.200000e+01</double>
 															<int key="NSfFlags">16</int>
 														</object>
-														<reference key="NSControlView" ref="411425856"/>
+														<reference key="NSControlView" ref="905092943"/>
 														<bool key="NSDrawsBackground">YES</bool>
-														<object class="NSColor" key="NSBackgroundColor" id="447702889">
+														<object class="NSColor" key="NSBackgroundColor" id="812484075">
 															<int key="NSColorSpace">6</int>
-															<reference key="NSCatalogName" ref="1000587476"/>
+															<reference key="NSCatalogName" ref="905527164"/>
 															<string key="NSColorName">controlBackgroundColor</string>
-															<reference key="NSColor" ref="1000384962"/>
+															<reference key="NSColor" ref="590688762"/>
 														</object>
-														<reference key="NSTextColor" ref="233849662"/>
+														<reference key="NSTextColor" ref="930815747"/>
 													</object>
 													<int key="NSResizingMask">3</int>
 													<bool key="NSIsResizeable">YES</bool>
 													<bool key="NSIsEditable">YES</bool>
-													<reference key="NSTableView" ref="411425856"/>
+													<reference key="NSTableView" ref="905092943"/>
 												</object>
 											</object>
 											<double key="NSIntercellSpacingWidth">3.000000e+00</double>
 											<double key="NSIntercellSpacingHeight">2.000000e+00</double>
-											<reference key="NSBackgroundColor" ref="722293876"/>
+											<reference key="NSBackgroundColor" ref="822946413"/>
 											<object class="NSColor" key="NSGridColor">
 												<int key="NSColorSpace">6</int>
-												<reference key="NSCatalogName" ref="1000587476"/>
+												<reference key="NSCatalogName" ref="905527164"/>
 												<string key="NSColorName">gridColor</string>
 												<object class="NSColor" key="NSColor">
 													<int key="NSColorSpace">3</int>
@@ -1207,72 +1248,73 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 										</object>
 									</object>
 									<string key="NSFrame">{{1, 17}, {333, 197}}</string>
-									<reference key="NSSuperview" ref="1011512617"/>
-									<reference key="NSNextKeyView" ref="411425856"/>
-									<reference key="NSDocView" ref="411425856"/>
-									<reference key="NSBGColor" ref="447702889"/>
+									<reference key="NSSuperview" ref="1063387772"/>
+									<reference key="NSNextKeyView" ref="905092943"/>
+									<reference key="NSDocView" ref="905092943"/>
+									<reference key="NSBGColor" ref="812484075"/>
 									<int key="NScvFlags">4</int>
 								</object>
-								<object class="NSScroller" id="152467947">
-									<reference key="NSNextResponder" ref="1011512617"/>
+								<object class="NSScroller" id="842897584">
+									<reference key="NSNextResponder" ref="1063387772"/>
 									<int key="NSvFlags">256</int>
 									<string key="NSFrame">{{334, 17}, {15, 197}}</string>
-									<reference key="NSSuperview" ref="1011512617"/>
-									<reference key="NSTarget" ref="1011512617"/>
-									<string key="NSAction" id="607822787">_doScroller:</string>
+									<reference key="NSSuperview" ref="1063387772"/>
+									<reference key="NSTarget" ref="1063387772"/>
+									<string key="NSAction" id="365694962">_doScroller:</string>
 									<double key="NSPercent">9.949238e-01</double>
 								</object>
-								<object class="NSScroller" id="208024104">
-									<reference key="NSNextResponder" ref="1011512617"/>
+								<object class="NSScroller" id="17278747">
+									<reference key="NSNextResponder" ref="1063387772"/>
 									<int key="NSvFlags">256</int>
 									<string key="NSFrame">{{1, 214}, {333, 15}}</string>
-									<reference key="NSSuperview" ref="1011512617"/>
+									<reference key="NSSuperview" ref="1063387772"/>
 									<int key="NSsFlags">1</int>
-									<reference key="NSTarget" ref="1011512617"/>
-									<reference key="NSAction" ref="607822787"/>
-									<double key="NSPercent">9.940299e-01</double>
+									<reference key="NSTarget" ref="1063387772"/>
+									<reference key="NSAction" ref="365694962"/>
+									<double key="NSPercent">6.885246e-01</double>
 								</object>
-								<object class="NSClipView" id="935843221">
-									<reference key="NSNextResponder" ref="1011512617"/>
+								<object class="NSClipView" id="672307654">
+									<reference key="NSNextResponder" ref="1063387772"/>
 									<int key="NSvFlags">2304</int>
 									<object class="NSMutableArray" key="NSSubviews">
 										<bool key="EncodedWithXMLCoder">YES</bool>
-										<reference ref="526973850"/>
+										<reference ref="792419186"/>
 									</object>
 									<string key="NSFrame">{{1, 0}, {333, 17}}</string>
-									<reference key="NSSuperview" ref="1011512617"/>
-									<reference key="NSNextKeyView" ref="526973850"/>
-									<reference key="NSDocView" ref="526973850"/>
-									<reference key="NSBGColor" ref="447702889"/>
+									<reference key="NSSuperview" ref="1063387772"/>
+									<reference key="NSNextKeyView" ref="792419186"/>
+									<reference key="NSDocView" ref="792419186"/>
+									<reference key="NSBGColor" ref="812484075"/>
 									<int key="NScvFlags">4</int>
 								</object>
-								<reference ref="182265797"/>
+								<reference ref="898633680"/>
 							</object>
-							<string key="NSFrame">{{20, 60}, {350, 230}}</string>
-							<reference key="NSSuperview" ref="1039094689"/>
-							<reference key="NSNextKeyView" ref="963977695"/>
+							<string key="NSFrame">{{20, 77}, {350, 230}}</string>
+							<reference key="NSSuperview" ref="85544634"/>
+							<reference key="NSNextKeyView" ref="580565898"/>
 							<int key="NSsFlags">50</int>
-							<reference key="NSVScroller" ref="152467947"/>
-							<reference key="NSHScroller" ref="208024104"/>
-							<reference key="NSContentView" ref="963977695"/>
-							<reference key="NSHeaderClipView" ref="935843221"/>
+							<reference key="NSVScroller" ref="842897584"/>
+							<reference key="NSHScroller" ref="17278747"/>
+							<reference key="NSContentView" ref="580565898"/>
+							<reference key="NSHeaderClipView" ref="672307654"/>
+							<reference key="NSCornerView" ref="898633680"/>
 							<bytes key="NSScrollAmts">QSAAAEEgAABBmAAAQZgAAA</bytes>
 						</object>
-						<object class="NSButton" id="859414998">
-							<reference key="NSNextResponder" ref="1039094689"/>
+						<object class="NSButton" id="125703429">
+							<reference key="NSNextResponder" ref="85544634"/>
 							<int key="NSvFlags">303</int>
-							<string key="NSFrame">{{304, 12}, {84, 32}}</string>
-							<reference key="NSSuperview" ref="1039094689"/>
+							<string key="NSFrame">{{352, 12}, {84, 32}}</string>
+							<reference key="NSSuperview" ref="85544634"/>
 							<bool key="NSEnabled">YES</bool>
-							<object class="NSButtonCell" key="NSCell" id="537937846">
-								<int key="NSCellFlags">67239424</int>
+							<object class="NSButtonCell" key="NSCell" id="892296813">
+								<int key="NSCellFlags">-2080244224</int>
 								<int key="NSCellFlags2">137887744</int>
 								<string key="NSContents">Cancel</string>
-								<reference key="NSSupport" ref="706343604"/>
-								<reference key="NSControlView" ref="859414998"/>
+								<reference key="NSSupport" ref="463863101"/>
+								<reference key="NSControlView" ref="125703429"/>
 								<int key="NSButtonFlags">-2038284033</int>
 								<int key="NSButtonFlags2">1</int>
-								<reference key="NSAlternateImage" ref="965938342"/>
+								<reference key="NSAlternateImage" ref="549406736"/>
 								<object class="NSMutableString" key="NSAlternateContents">
 									<characters key="NS.bytes"/>
 								</object>
@@ -1283,21 +1325,21 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 								<int key="NSPeriodicInterval">25</int>
 							</object>
 						</object>
-						<object class="NSButton" id="381268760">
-							<reference key="NSNextResponder" ref="1039094689"/>
+						<object class="NSButton" id="758204686">
+							<reference key="NSNextResponder" ref="85544634"/>
 							<int key="NSvFlags">301</int>
-							<string key="NSFrame">{{372, 262}, {100, 32}}</string>
-							<reference key="NSSuperview" ref="1039094689"/>
+							<string key="NSFrame">{{372, 279}, {100, 32}}</string>
+							<reference key="NSSuperview" ref="85544634"/>
 							<bool key="NSEnabled">YES</bool>
-							<object class="NSButtonCell" key="NSCell" id="99903682">
+							<object class="NSButtonCell" key="NSCell" id="1025474039">
 								<int key="NSCellFlags">67239424</int>
 								<int key="NSCellFlags2">137887744</int>
 								<string key="NSContents">Add Item</string>
-								<reference key="NSSupport" ref="706343604"/>
-								<reference key="NSControlView" ref="381268760"/>
+								<reference key="NSSupport" ref="463863101"/>
+								<reference key="NSControlView" ref="758204686"/>
 								<int key="NSButtonFlags">-2038284033</int>
 								<int key="NSButtonFlags2">1</int>
-								<reference key="NSAlternateImage" ref="965938342"/>
+								<reference key="NSAlternateImage" ref="549406736"/>
 								<object class="NSMutableString" key="NSAlternateContents">
 									<characters key="NS.bytes"/>
 								</object>
@@ -1309,66 +1351,66 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 							</object>
 						</object>
 					</object>
-					<string key="NSFrame">{{1, 1}, {486, 310}}</string>
+					<string key="NSFrameSize">{486, 327}</string>
 				</object>
 				<string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
 				<string key="NSMinSize">{213, 129}</string>
 				<string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
 				<string key="NSFrameAutosaveName">x11_apps</string>
 			</object>
-			<object class="NSMenu" id="1001514180">
+			<object class="NSMenu" id="294137138">
 				<string key="NSTitle">Menu</string>
 				<object class="NSMutableArray" key="NSMenuItems">
 					<bool key="EncodedWithXMLCoder">YES</bool>
-					<object class="NSMenuItem" id="355724345">
-						<reference key="NSMenu" ref="1001514180"/>
+					<object class="NSMenuItem" id="318286212">
+						<reference key="NSMenu" ref="294137138"/>
 						<bool key="NSIsDisabled">YES</bool>
 						<bool key="NSIsSeparator">YES</bool>
-						<reference key="NSTitle" ref="1005878359"/>
-						<reference key="NSKeyEquiv" ref="1005878359"/>
+						<reference key="NSTitle" ref="331740794"/>
+						<reference key="NSKeyEquiv" ref="331740794"/>
 						<int key="NSKeyEquivModMask">1048576</int>
 						<int key="NSMnemonicLoc">2147483647</int>
-						<reference key="NSOnImage" ref="732862070"/>
-						<reference key="NSMixedImage" ref="154462367"/>
+						<reference key="NSOnImage" ref="531645050"/>
+						<reference key="NSMixedImage" ref="246283459"/>
 					</object>
-					<object class="NSMenuItem" id="107275095">
-						<reference key="NSMenu" ref="1001514180"/>
-						<reference key="NSTitle" ref="942587293"/>
-						<reference key="NSKeyEquiv" ref="1005878359"/>
+					<object class="NSMenuItem" id="511651072">
+						<reference key="NSMenu" ref="294137138"/>
+						<reference key="NSTitle" ref="667842658"/>
+						<reference key="NSKeyEquiv" ref="331740794"/>
 						<int key="NSKeyEquivModMask">1048576</int>
 						<int key="NSMnemonicLoc">2147483647</int>
-						<reference key="NSOnImage" ref="732862070"/>
-						<reference key="NSMixedImage" ref="154462367"/>
+						<reference key="NSOnImage" ref="531645050"/>
+						<reference key="NSMixedImage" ref="246283459"/>
 						<string key="NSAction">submenuAction:</string>
-						<object class="NSMenu" key="NSSubmenu" id="321919370">
-							<reference key="NSTitle" ref="942587293"/>
+						<object class="NSMenu" key="NSSubmenu" id="48278059">
+							<reference key="NSTitle" ref="667842658"/>
 							<object class="NSMutableArray" key="NSMenuItems">
 								<bool key="EncodedWithXMLCoder">YES</bool>
-								<object class="NSMenuItem" id="500771766">
-									<reference key="NSMenu" ref="321919370"/>
+								<object class="NSMenuItem" id="563798000">
+									<reference key="NSMenu" ref="48278059"/>
 									<bool key="NSIsDisabled">YES</bool>
 									<bool key="NSIsSeparator">YES</bool>
-									<reference key="NSTitle" ref="1005878359"/>
-									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<reference key="NSTitle" ref="331740794"/>
+									<reference key="NSKeyEquiv" ref="331740794"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="732862070"/>
-									<reference key="NSMixedImage" ref="154462367"/>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="246283459"/>
 								</object>
-								<object class="NSMenuItem" id="656726997">
-									<reference key="NSMenu" ref="321919370"/>
+								<object class="NSMenuItem" id="1032342329">
+									<reference key="NSMenu" ref="48278059"/>
 									<string type="base64-UTF8" key="NSTitle">Q3VzdG9taXpl4oCmA</string>
-									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<reference key="NSKeyEquiv" ref="331740794"/>
 									<int key="NSKeyEquivModMask">1048576</int>
 									<int key="NSMnemonicLoc">2147483647</int>
-									<reference key="NSOnImage" ref="732862070"/>
-									<reference key="NSMixedImage" ref="154462367"/>
+									<reference key="NSOnImage" ref="531645050"/>
+									<reference key="NSMixedImage" ref="246283459"/>
 								</object>
 							</object>
 						</object>
 					</object>
 				</object>
-				<reference key="NSName" ref="1005878359"/>
+				<reference key="NSName" ref="331740794"/>
 			</object>
 		</object>
 		<object class="IBObjectContainer" key="IBDocument.Objects">
@@ -1377,1384 +1419,1438 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
 						<string key="label">cut:</string>
-						<reference key="source" ref="518703249"/>
-						<reference key="destination" ref="590926585"/>
+						<reference key="source" ref="941939442"/>
+						<reference key="destination" ref="581727829"/>
 					</object>
 					<int key="connectionID">175</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
 						<string key="label">paste:</string>
-						<reference key="source" ref="518703249"/>
-						<reference key="destination" ref="739720090"/>
+						<reference key="source" ref="941939442"/>
+						<reference key="destination" ref="924678073"/>
 					</object>
 					<int key="connectionID">176</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
 						<string key="label">redo:</string>
-						<reference key="source" ref="518703249"/>
-						<reference key="destination" ref="634656440"/>
+						<reference key="source" ref="941939442"/>
+						<reference key="destination" ref="535038564"/>
 					</object>
 					<int key="connectionID">178</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
 						<string key="label">selectAll:</string>
-						<reference key="source" ref="518703249"/>
-						<reference key="destination" ref="584461964"/>
+						<reference key="source" ref="941939442"/>
+						<reference key="destination" ref="322866464"/>
 					</object>
 					<int key="connectionID">179</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
 						<string key="label">undo:</string>
-						<reference key="source" ref="518703249"/>
-						<reference key="destination" ref="159704190"/>
+						<reference key="source" ref="941939442"/>
+						<reference key="destination" ref="1010221707"/>
 					</object>
 					<int key="connectionID">180</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
 						<string key="label">copy:</string>
-						<reference key="source" ref="518703249"/>
-						<reference key="destination" ref="204575684"/>
+						<reference key="source" ref="941939442"/>
+						<reference key="destination" ref="185296989"/>
 					</object>
 					<int key="connectionID">181</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
 						<string key="label">delete:</string>
-						<reference key="source" ref="518703249"/>
-						<reference key="destination" ref="549812830"/>
+						<reference key="source" ref="941939442"/>
+						<reference key="destination" ref="994817848"/>
 					</object>
 					<int key="connectionID">195</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
 						<string key="label">minimize_window:</string>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="915861349"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="677652931"/>
 					</object>
 					<int key="connectionID">202</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
 						<string key="label">close_window:</string>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="442007350"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="984461797"/>
 					</object>
 					<int key="connectionID">205</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
 						<string key="label">zoom_window:</string>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="722764538"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="1066447520"/>
 					</object>
 					<int key="connectionID">206</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
 						<string key="label">bring_to_front:</string>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="853630143"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="276216762"/>
 					</object>
 					<int key="connectionID">207</int>
 				</object>
 				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">window_separator</string>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="332241222"/>
-					</object>
-					<int key="connectionID">260</int>
-				</object>
-				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
 						<string key="label">hideOtherApplications:</string>
-						<reference key="source" ref="584863936"/>
-						<reference key="destination" ref="191312176"/>
+						<reference key="source" ref="815810918"/>
+						<reference key="destination" ref="206802571"/>
 					</object>
 					<int key="connectionID">263</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBOutletConnection" key="connection">
 						<string key="label">apps_separator</string>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="940363272"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="390088328"/>
 					</object>
 					<int key="connectionID">273</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBOutletConnection" key="connection">
 						<string key="label">apps_table</string>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="411425856"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="905092943"/>
 					</object>
 					<int key="connectionID">301</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
 						<string key="label">apps_table_done:</string>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="1002101696"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="724002248"/>
 					</object>
 					<int key="connectionID">302</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
 						<string key="label">apps_table_delete:</string>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="634701477"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="492358940"/>
 					</object>
 					<int key="connectionID">303</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
 						<string key="label">apps_table_duplicate:</string>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="711288662"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="671954382"/>
 					</object>
 					<int key="connectionID">304</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
-						<string key="label" id="178478735">apps_table_show:</string>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="767830074"/>
+						<string key="label" id="75505755">apps_table_show:</string>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="1065386165"/>
 					</object>
 					<int key="connectionID">308</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
 						<string key="label">apps_table_cancel:</string>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="859414998"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="125703429"/>
 					</object>
 					<int key="connectionID">309</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
 						<string key="label">apps_table_new:</string>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="381268760"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="758204686"/>
 					</object>
 					<int key="connectionID">311</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
 						<string key="label">prefs_show:</string>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="836585695"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="386173216"/>
 					</object>
 					<int key="connectionID">318</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBOutletConnection" key="connection">
 						<string key="label">x11_about_item</string>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="588913325"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="139290918"/>
 					</object>
 					<int key="connectionID">321</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBOutletConnection" key="connection">
 						<string key="label">enable_auth</string>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="137435489"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="989050925"/>
 					</object>
 					<int key="connectionID">387</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBOutletConnection" key="connection">
 						<string key="label">enable_tcp</string>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="663154230"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="700826966"/>
 					</object>
 					<int key="connectionID">388</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBOutletConnection" key="connection">
 						<string key="label">depth</string>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="300224954"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="709074847"/>
 					</object>
 					<int key="connectionID">389</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBOutletConnection" key="connection">
 						<string key="label">use_sysbeep</string>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="1045559310"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="418227126"/>
 					</object>
 					<int key="connectionID">390</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBOutletConnection" key="connection">
 						<string key="label">fake_buttons</string>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="808306730"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="119157981"/>
 					</object>
 					<int key="connectionID">391</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBOutletConnection" key="connection">
 						<string key="label">sync_keymap</string>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="793493073"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="179949713"/>
 					</object>
 					<int key="connectionID">392</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBOutletConnection" key="connection">
 						<string key="label">enable_keyequivs</string>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="677150201"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="842100515"/>
 					</object>
 					<int key="connectionID">393</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
-						<string key="label" id="694471214">prefs_changed:</string>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="808306730"/>
+						<string key="label" id="582333102">prefs_changed:</string>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="119157981"/>
 					</object>
 					<int key="connectionID">394</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
-						<reference key="label" ref="694471214"/>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="793493073"/>
+						<reference key="label" ref="582333102"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="179949713"/>
 					</object>
 					<int key="connectionID">395</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
-						<reference key="label" ref="694471214"/>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="677150201"/>
+						<reference key="label" ref="582333102"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="842100515"/>
 					</object>
 					<int key="connectionID">396</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
-						<reference key="label" ref="694471214"/>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="1045559310"/>
+						<reference key="label" ref="582333102"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="418227126"/>
 					</object>
 					<int key="connectionID">397</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
-						<reference key="label" ref="694471214"/>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="300224954"/>
+						<reference key="label" ref="582333102"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="709074847"/>
 					</object>
 					<int key="connectionID">398</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
-						<reference key="label" ref="694471214"/>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="137435489"/>
+						<reference key="label" ref="582333102"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="989050925"/>
 					</object>
 					<int key="connectionID">399</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
-						<reference key="label" ref="694471214"/>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="663154230"/>
+						<reference key="label" ref="582333102"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="700826966"/>
 					</object>
 					<int key="connectionID">401</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBOutletConnection" key="connection">
 						<string key="label">prefs_panel</string>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="210544761"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="124913468"/>
 					</object>
 					<int key="connectionID">402</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
 						<string key="label">x11_help:</string>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="122992289"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="504984881"/>
 					</object>
 					<int key="connectionID">422</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBOutletConnection" key="connection">
 						<string key="label">dockMenu</string>
-						<reference key="source" ref="584863936"/>
-						<reference key="destination" ref="1001514180"/>
+						<reference key="source" ref="815810918"/>
+						<reference key="destination" ref="294137138"/>
 					</object>
 					<int key="connectionID">426</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBOutletConnection" key="connection">
 						<string key="label">dock_menu</string>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="1001514180"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="294137138"/>
 					</object>
 					<int key="connectionID">428</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBOutletConnection" key="connection">
 						<string key="label">delegate</string>
-						<reference key="source" ref="584863936"/>
-						<reference key="destination" ref="88064061"/>
+						<reference key="source" ref="815810918"/>
+						<reference key="destination" ref="485884620"/>
 					</object>
 					<int key="connectionID">429</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
 						<string key="label">hide:</string>
-						<reference key="source" ref="584863936"/>
-						<reference key="destination" ref="147703239"/>
+						<reference key="source" ref="815810918"/>
+						<reference key="destination" ref="301008465"/>
 					</object>
 					<int key="connectionID">430</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
 						<string key="label">unhideAllApplications:</string>
-						<reference key="source" ref="584863936"/>
-						<reference key="destination" ref="392807560"/>
+						<reference key="source" ref="815810918"/>
+						<reference key="destination" ref="1023546148"/>
 					</object>
 					<int key="connectionID">431</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
-						<string key="label">terminate:</string>
-						<reference key="source" ref="584863936"/>
-						<reference key="destination" ref="275459236"/>
-					</object>
-					<int key="connectionID">432</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
 						<string key="label">orderFrontStandardAboutPanel:</string>
-						<reference key="source" ref="584863936"/>
-						<reference key="destination" ref="588913325"/>
+						<reference key="source" ref="815810918"/>
+						<reference key="destination" ref="139290918"/>
 					</object>
 					<int key="connectionID">433</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBOutletConnection" key="connection">
 						<string key="label">dock_apps_menu</string>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="321919370"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="48278059"/>
 					</object>
 					<int key="connectionID">530</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBOutletConnection" key="connection">
 						<string key="label">dock_window_separator</string>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="355724345"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="318286212"/>
 					</object>
 					<int key="connectionID">531</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
-						<reference key="label" ref="178478735"/>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="656726997"/>
+						<reference key="label" ref="75505755"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="1032342329"/>
 					</object>
 					<int key="connectionID">534</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
 						<string key="label">next_window:</string>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="283496700"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="1036389925"/>
 					</object>
 					<int key="connectionID">539</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
 						<string key="label">previous_window:</string>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="500397106"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="369641893"/>
 					</object>
 					<int key="connectionID">540</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBOutletConnection" key="connection">
 						<string key="label">enable_fullscreen</string>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="817420822"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="477203622"/>
 					</object>
 					<int key="connectionID">546</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
 						<string key="label">enable_fullscreen_changed:</string>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="817420822"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="477203622"/>
 					</object>
 					<int key="connectionID">547</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
 						<string key="label">toggle_fullscreen:</string>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="101686423"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="6876565"/>
 					</object>
 					<int key="connectionID">548</int>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBOutletConnection" key="connection">
 						<string key="label">toggle_fullscreen_item</string>
-						<reference key="source" ref="88064061"/>
-						<reference key="destination" ref="101686423"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="6876565"/>
 					</object>
 					<int key="connectionID">549</int>
 				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<reference key="label" ref="582333102"/>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="915448994"/>
+					</object>
+					<int key="connectionID">300300</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBOutletConnection" key="connection">
+						<string key="label">window_separator</string>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="444952046"/>
+					</object>
+					<int key="connectionID">300331</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBOutletConnection" key="connection">
+						<string key="label">click_through</string>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="915448994"/>
+					</object>
+					<int key="connectionID">300332</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">quit:</string>
+						<reference key="source" ref="485884620"/>
+						<reference key="destination" ref="274138642"/>
+					</object>
+					<int key="connectionID">300333</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBOutletConnection" key="connection">
+						<string key="label">menu</string>
+						<reference key="source" ref="815810918"/>
+						<reference key="destination" ref="524015605"/>
+					</object>
+					<int key="connectionID">300334</int>
+				</object>
 			</object>
 			<object class="IBMutableOrderedSet" key="objectRecords">
 				<object class="NSArray" key="orderedObjects">
 					<bool key="EncodedWithXMLCoder">YES</bool>
 					<object class="IBObjectRecord">
 						<int key="objectID">0</int>
-						<object class="NSArray" key="object" id="0">
+						<object class="NSArray" key="object" id="330408435">
 							<bool key="EncodedWithXMLCoder">YES</bool>
 						</object>
-						<reference key="children" ref="874420287"/>
+						<reference key="children" ref="904585544"/>
 						<nil key="parent"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">-2</int>
-						<reference key="object" ref="584863936"/>
-						<reference key="parent" ref="0"/>
+						<reference key="object" ref="815810918"/>
+						<reference key="parent" ref="330408435"/>
 						<string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">-1</int>
-						<reference key="object" ref="518703249"/>
-						<reference key="parent" ref="0"/>
+						<reference key="object" ref="941939442"/>
+						<reference key="parent" ref="330408435"/>
 						<string key="objectName">First Responder</string>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">-3</int>
-						<reference key="object" ref="166373373"/>
-						<reference key="parent" ref="0"/>
+						<reference key="object" ref="951368722"/>
+						<reference key="parent" ref="330408435"/>
 						<string key="objectName">Application</string>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">29</int>
-						<reference key="object" ref="496556081"/>
+						<reference key="object" ref="524015605"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="736341863"/>
-							<reference ref="385138428"/>
-							<reference ref="326076563"/>
-							<reference ref="940914550"/>
-							<reference ref="934950259"/>
+							<reference ref="931553638"/>
+							<reference ref="365880285"/>
+							<reference ref="200491363"/>
+							<reference ref="868031522"/>
+							<reference ref="551174276"/>
 						</object>
-						<reference key="parent" ref="0"/>
-						<reference key="objectName" ref="414137626"/>
+						<reference key="parent" ref="330408435"/>
+						<reference key="objectName" ref="121567387"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">19</int>
-						<reference key="object" ref="736341863"/>
+						<reference key="object" ref="931553638"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="943404979"/>
+							<reference ref="96874957"/>
 						</object>
-						<reference key="parent" ref="496556081"/>
+						<reference key="parent" ref="524015605"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">24</int>
-						<reference key="object" ref="943404979"/>
+						<reference key="object" ref="96874957"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="853630143"/>
-							<reference ref="915861349"/>
-							<reference ref="783034074"/>
-							<reference ref="442007350"/>
-							<reference ref="722764538"/>
-							<reference ref="332241222"/>
-							<reference ref="303213786"/>
-							<reference ref="283496700"/>
-							<reference ref="500397106"/>
+							<reference ref="677652931"/>
+							<reference ref="276216762"/>
+							<reference ref="1066447520"/>
+							<reference ref="1036389925"/>
+							<reference ref="280172320"/>
+							<reference ref="369641893"/>
+							<reference ref="984461797"/>
+							<reference ref="155085383"/>
+							<reference ref="444952046"/>
 						</object>
-						<reference key="parent" ref="736341863"/>
+						<reference key="parent" ref="931553638"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">5</int>
-						<reference key="object" ref="853630143"/>
-						<reference key="parent" ref="943404979"/>
+						<reference key="object" ref="276216762"/>
+						<reference key="parent" ref="96874957"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">23</int>
-						<reference key="object" ref="915861349"/>
-						<reference key="parent" ref="943404979"/>
+						<reference key="object" ref="677652931"/>
+						<reference key="parent" ref="96874957"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">92</int>
-						<reference key="object" ref="783034074"/>
-						<reference key="parent" ref="943404979"/>
+						<reference key="object" ref="280172320"/>
+						<reference key="parent" ref="96874957"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">203</int>
-						<reference key="object" ref="442007350"/>
-						<reference key="parent" ref="943404979"/>
+						<reference key="object" ref="984461797"/>
+						<reference key="parent" ref="96874957"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">204</int>
-						<reference key="object" ref="722764538"/>
-						<reference key="parent" ref="943404979"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">208</int>
-						<reference key="object" ref="332241222"/>
-						<reference key="parent" ref="943404979"/>
+						<reference key="object" ref="1066447520"/>
+						<reference key="parent" ref="96874957"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">536</int>
-						<reference key="object" ref="303213786"/>
-						<reference key="parent" ref="943404979"/>
+						<reference key="object" ref="155085383"/>
+						<reference key="parent" ref="96874957"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">537</int>
-						<reference key="object" ref="283496700"/>
-						<reference key="parent" ref="943404979"/>
+						<reference key="object" ref="1036389925"/>
+						<reference key="parent" ref="96874957"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">538</int>
-						<reference key="object" ref="500397106"/>
-						<reference key="parent" ref="943404979"/>
+						<reference key="object" ref="369641893"/>
+						<reference key="parent" ref="96874957"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">56</int>
-						<reference key="object" ref="385138428"/>
+						<reference key="object" ref="365880285"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="856655711"/>
+							<reference ref="576521955"/>
 						</object>
-						<reference key="parent" ref="496556081"/>
+						<reference key="parent" ref="524015605"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">57</int>
-						<reference key="object" ref="856655711"/>
+						<reference key="object" ref="576521955"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="588913325"/>
-							<reference ref="836585695"/>
-							<reference ref="63158341"/>
-							<reference ref="147703239"/>
-							<reference ref="275459236"/>
-							<reference ref="562920394"/>
-							<reference ref="635454008"/>
-							<reference ref="191312176"/>
-							<reference ref="648021277"/>
-							<reference ref="392807560"/>
-							<reference ref="101686423"/>
-							<reference ref="754231570"/>
+							<reference ref="139290918"/>
+							<reference ref="386173216"/>
+							<reference ref="32285361"/>
+							<reference ref="301008465"/>
+							<reference ref="274138642"/>
+							<reference ref="272876017"/>
+							<reference ref="431301145"/>
+							<reference ref="206802571"/>
+							<reference ref="848095279"/>
+							<reference ref="1023546148"/>
+							<reference ref="6876565"/>
+							<reference ref="479677589"/>
 						</object>
-						<reference key="parent" ref="385138428"/>
+						<reference key="parent" ref="365880285"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">58</int>
-						<reference key="object" ref="588913325"/>
-						<reference key="parent" ref="856655711"/>
+						<reference key="object" ref="139290918"/>
+						<reference key="parent" ref="576521955"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">129</int>
-						<reference key="object" ref="836585695"/>
-						<reference key="parent" ref="856655711"/>
+						<reference key="object" ref="386173216"/>
+						<reference key="parent" ref="576521955"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">131</int>
-						<reference key="object" ref="63158341"/>
+						<reference key="object" ref="32285361"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="502073457"/>
+							<reference ref="821388474"/>
 						</object>
-						<reference key="parent" ref="856655711"/>
+						<reference key="parent" ref="576521955"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">130</int>
-						<reference key="object" ref="502073457"/>
-						<reference key="parent" ref="63158341"/>
+						<reference key="object" ref="821388474"/>
+						<reference key="parent" ref="32285361"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">134</int>
-						<reference key="object" ref="147703239"/>
-						<reference key="parent" ref="856655711"/>
+						<reference key="object" ref="301008465"/>
+						<reference key="parent" ref="576521955"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">136</int>
-						<reference key="object" ref="275459236"/>
-						<reference key="parent" ref="856655711"/>
+						<reference key="object" ref="274138642"/>
+						<reference key="parent" ref="576521955"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">143</int>
-						<reference key="object" ref="562920394"/>
-						<reference key="parent" ref="856655711"/>
+						<reference key="object" ref="272876017"/>
+						<reference key="parent" ref="576521955"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">144</int>
-						<reference key="object" ref="635454008"/>
-						<reference key="parent" ref="856655711"/>
+						<reference key="object" ref="431301145"/>
+						<reference key="parent" ref="576521955"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">145</int>
-						<reference key="object" ref="191312176"/>
-						<reference key="parent" ref="856655711"/>
+						<reference key="object" ref="206802571"/>
+						<reference key="parent" ref="576521955"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">149</int>
-						<reference key="object" ref="648021277"/>
-						<reference key="parent" ref="856655711"/>
+						<reference key="object" ref="848095279"/>
+						<reference key="parent" ref="576521955"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">150</int>
-						<reference key="object" ref="392807560"/>
-						<reference key="parent" ref="856655711"/>
+						<reference key="object" ref="1023546148"/>
+						<reference key="parent" ref="576521955"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">544</int>
-						<reference key="object" ref="101686423"/>
-						<reference key="parent" ref="856655711"/>
+						<reference key="object" ref="6876565"/>
+						<reference key="parent" ref="576521955"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">545</int>
-						<reference key="object" ref="754231570"/>
-						<reference key="parent" ref="856655711"/>
+						<reference key="object" ref="479677589"/>
+						<reference key="parent" ref="576521955"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">163</int>
-						<reference key="object" ref="326076563"/>
+						<reference key="object" ref="200491363"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="932839819"/>
+							<reference ref="526778998"/>
 						</object>
-						<reference key="parent" ref="496556081"/>
+						<reference key="parent" ref="524015605"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">169</int>
-						<reference key="object" ref="932839819"/>
+						<reference key="object" ref="526778998"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="342107529"/>
-							<reference ref="204575684"/>
-							<reference ref="159704190"/>
-							<reference ref="590926585"/>
-							<reference ref="549812830"/>
-							<reference ref="739720090"/>
-							<reference ref="584461964"/>
-							<reference ref="634656440"/>
+							<reference ref="839739619"/>
+							<reference ref="185296989"/>
+							<reference ref="1010221707"/>
+							<reference ref="581727829"/>
+							<reference ref="994817848"/>
+							<reference ref="924678073"/>
+							<reference ref="322866464"/>
+							<reference ref="535038564"/>
 						</object>
-						<reference key="parent" ref="326076563"/>
+						<reference key="parent" ref="200491363"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">156</int>
-						<reference key="object" ref="342107529"/>
-						<reference key="parent" ref="932839819"/>
+						<reference key="object" ref="839739619"/>
+						<reference key="parent" ref="526778998"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">157</int>
-						<reference key="object" ref="204575684"/>
-						<reference key="parent" ref="932839819"/>
+						<reference key="object" ref="185296989"/>
+						<reference key="parent" ref="526778998"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">158</int>
-						<reference key="object" ref="159704190"/>
-						<reference key="parent" ref="932839819"/>
+						<reference key="object" ref="1010221707"/>
+						<reference key="parent" ref="526778998"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">160</int>
-						<reference key="object" ref="590926585"/>
-						<reference key="parent" ref="932839819"/>
+						<reference key="object" ref="581727829"/>
+						<reference key="parent" ref="526778998"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">164</int>
-						<reference key="object" ref="549812830"/>
-						<reference key="parent" ref="932839819"/>
+						<reference key="object" ref="994817848"/>
+						<reference key="parent" ref="526778998"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">171</int>
-						<reference key="object" ref="739720090"/>
-						<reference key="parent" ref="932839819"/>
+						<reference key="object" ref="924678073"/>
+						<reference key="parent" ref="526778998"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">172</int>
-						<reference key="object" ref="584461964"/>
-						<reference key="parent" ref="932839819"/>
+						<reference key="object" ref="322866464"/>
+						<reference key="parent" ref="526778998"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">173</int>
-						<reference key="object" ref="634656440"/>
-						<reference key="parent" ref="932839819"/>
+						<reference key="object" ref="535038564"/>
+						<reference key="parent" ref="526778998"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">269</int>
-						<reference key="object" ref="940914550"/>
+						<reference key="object" ref="868031522"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="684156653"/>
+							<reference ref="981161348"/>
 						</object>
-						<reference key="parent" ref="496556081"/>
+						<reference key="parent" ref="524015605"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">270</int>
-						<reference key="object" ref="684156653"/>
+						<reference key="object" ref="981161348"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="940363272"/>
-							<reference ref="767830074"/>
+							<reference ref="390088328"/>
+							<reference ref="1065386165"/>
 						</object>
-						<reference key="parent" ref="940914550"/>
+						<reference key="parent" ref="868031522"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">272</int>
-						<reference key="object" ref="940363272"/>
-						<reference key="parent" ref="684156653"/>
+						<reference key="object" ref="390088328"/>
+						<reference key="parent" ref="981161348"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">305</int>
-						<reference key="object" ref="767830074"/>
-						<reference key="parent" ref="684156653"/>
+						<reference key="object" ref="1065386165"/>
+						<reference key="parent" ref="981161348"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">419</int>
-						<reference key="object" ref="934950259"/>
+						<reference key="object" ref="551174276"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="1052262524"/>
+							<reference ref="511848303"/>
 						</object>
-						<reference key="parent" ref="496556081"/>
+						<reference key="parent" ref="524015605"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">420</int>
-						<reference key="object" ref="1052262524"/>
+						<reference key="object" ref="511848303"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="122992289"/>
+							<reference ref="504984881"/>
 						</object>
-						<reference key="parent" ref="934950259"/>
+						<reference key="parent" ref="551174276"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">421</int>
-						<reference key="object" ref="122992289"/>
-						<reference key="parent" ref="1052262524"/>
+						<reference key="object" ref="504984881"/>
+						<reference key="parent" ref="511848303"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">196</int>
-						<reference key="object" ref="88064061"/>
-						<reference key="parent" ref="0"/>
-						<reference key="objectName" ref="517073442"/>
+						<reference key="object" ref="485884620"/>
+						<reference key="parent" ref="330408435"/>
+						<reference key="objectName" ref="865849805"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">244</int>
-						<reference key="object" ref="210544761"/>
+						<reference key="object" ref="124913468"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="404125972"/>
+							<reference ref="941366957"/>
 						</object>
-						<reference key="parent" ref="0"/>
+						<reference key="parent" ref="330408435"/>
 						<string key="objectName">PrefsPanel</string>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">245</int>
-						<reference key="object" ref="404125972"/>
+						<reference key="object" ref="941366957"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="75927203"/>
+							<reference ref="448510093"/>
 						</object>
-						<reference key="parent" ref="210544761"/>
+						<reference key="parent" ref="124913468"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">348</int>
-						<reference key="object" ref="75927203"/>
+						<reference key="object" ref="448510093"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="17244958"/>
-							<reference ref="493727923"/>
-							<reference ref="1036577743"/>
+							<reference ref="287591690"/>
+							<reference ref="960678392"/>
+							<reference ref="348328898"/>
 						</object>
-						<reference key="parent" ref="404125972"/>
+						<reference key="parent" ref="941366957"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">349</int>
-						<reference key="object" ref="17244958"/>
+						<reference key="object" ref="287591690"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="600332710"/>
+							<reference ref="596750588"/>
 						</object>
-						<reference key="parent" ref="75927203"/>
+						<reference key="parent" ref="448510093"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">351</int>
-						<reference key="object" ref="600332710"/>
+						<reference key="object" ref="596750588"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="808306730"/>
-							<reference ref="618388983"/>
-							<reference ref="754792079"/>
-							<reference ref="677150201"/>
-							<reference ref="228801813"/>
-							<reference ref="793493073"/>
+							<reference ref="119157981"/>
+							<reference ref="443008216"/>
+							<reference ref="282885445"/>
+							<reference ref="842100515"/>
+							<reference ref="31160162"/>
+							<reference ref="179949713"/>
+							<reference ref="915448994"/>
+							<reference ref="707276799"/>
 						</object>
-						<reference key="parent" ref="17244958"/>
+						<reference key="parent" ref="287591690"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">363</int>
-						<reference key="object" ref="808306730"/>
+						<reference key="object" ref="119157981"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="727617204"/>
+							<reference ref="990762273"/>
 						</object>
-						<reference key="parent" ref="600332710"/>
+						<reference key="parent" ref="596750588"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">364</int>
-						<reference key="object" ref="618388983"/>
+						<reference key="object" ref="443008216"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="140236247"/>
+							<reference ref="391919450"/>
 						</object>
-						<reference key="parent" ref="600332710"/>
+						<reference key="parent" ref="596750588"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">365</int>
-						<reference key="object" ref="754792079"/>
+						<reference key="object" ref="282885445"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="110537159"/>
+							<reference ref="649334366"/>
 						</object>
-						<reference key="parent" ref="600332710"/>
+						<reference key="parent" ref="596750588"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">368</int>
-						<reference key="object" ref="677150201"/>
+						<reference key="object" ref="842100515"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="46680941"/>
+							<reference ref="940564599"/>
 						</object>
-						<reference key="parent" ref="600332710"/>
+						<reference key="parent" ref="596750588"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">369</int>
-						<reference key="object" ref="228801813"/>
+						<reference key="object" ref="31160162"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="415694484"/>
+							<reference ref="666057093"/>
 						</object>
-						<reference key="parent" ref="600332710"/>
+						<reference key="parent" ref="596750588"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">370</int>
-						<reference key="object" ref="793493073"/>
+						<reference key="object" ref="179949713"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="466260504"/>
+							<reference ref="967619578"/>
 						</object>
-						<reference key="parent" ref="600332710"/>
+						<reference key="parent" ref="596750588"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">352</int>
-						<reference key="object" ref="493727923"/>
+						<reference key="object" ref="960678392"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="527709877"/>
+							<reference ref="515308735"/>
 						</object>
-						<reference key="parent" ref="75927203"/>
+						<reference key="parent" ref="448510093"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">350</int>
-						<reference key="object" ref="527709877"/>
+						<reference key="object" ref="515308735"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="1045559310"/>
-							<reference ref="67626595"/>
-							<reference ref="300224954"/>
-							<reference ref="717889178"/>
-							<reference ref="114173823"/>
-							<reference ref="817420822"/>
-							<reference ref="959270736"/>
+							<reference ref="418227126"/>
+							<reference ref="1039016593"/>
+							<reference ref="709074847"/>
+							<reference ref="201731424"/>
+							<reference ref="86150604"/>
+							<reference ref="477203622"/>
+							<reference ref="298603383"/>
 						</object>
-						<reference key="parent" ref="493727923"/>
+						<reference key="parent" ref="960678392"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">371</int>
-						<reference key="object" ref="1045559310"/>
+						<reference key="object" ref="418227126"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="225158677"/>
+							<reference ref="1016069354"/>
 						</object>
-						<reference key="parent" ref="527709877"/>
+						<reference key="parent" ref="515308735"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">372</int>
-						<reference key="object" ref="67626595"/>
+						<reference key="object" ref="1039016593"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="1072420481"/>
+							<reference ref="624655599"/>
 						</object>
-						<reference key="parent" ref="527709877"/>
+						<reference key="parent" ref="515308735"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">382</int>
-						<reference key="object" ref="300224954"/>
+						<reference key="object" ref="709074847"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="301142744"/>
+							<reference ref="633115429"/>
 						</object>
-						<reference key="parent" ref="527709877"/>
+						<reference key="parent" ref="515308735"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">385</int>
-						<reference key="object" ref="717889178"/>
+						<reference key="object" ref="201731424"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="749756205"/>
+							<reference ref="930265681"/>
 						</object>
-						<reference key="parent" ref="527709877"/>
+						<reference key="parent" ref="515308735"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">386</int>
-						<reference key="object" ref="114173823"/>
+						<reference key="object" ref="86150604"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="725554783"/>
+							<reference ref="311969422"/>
 						</object>
-						<reference key="parent" ref="527709877"/>
+						<reference key="parent" ref="515308735"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">541</int>
-						<reference key="object" ref="817420822"/>
+						<reference key="object" ref="477203622"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="100363081"/>
+							<reference ref="631531164"/>
 						</object>
-						<reference key="parent" ref="527709877"/>
+						<reference key="parent" ref="515308735"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">543</int>
-						<reference key="object" ref="959270736"/>
+						<reference key="object" ref="298603383"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="550432669"/>
+							<reference ref="761107402"/>
 						</object>
-						<reference key="parent" ref="527709877"/>
+						<reference key="parent" ref="515308735"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">353</int>
-						<reference key="object" ref="1036577743"/>
+						<reference key="object" ref="348328898"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="536248195"/>
+							<reference ref="300811574"/>
 						</object>
-						<reference key="parent" ref="75927203"/>
+						<reference key="parent" ref="448510093"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">354</int>
-						<reference key="object" ref="536248195"/>
+						<reference key="object" ref="300811574"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="137435489"/>
-							<reference ref="663154230"/>
-							<reference ref="417801719"/>
-							<reference ref="115954190"/>
-							<reference ref="1067279202"/>
+							<reference ref="989050925"/>
+							<reference ref="700826966"/>
+							<reference ref="168436707"/>
+							<reference ref="363817195"/>
+							<reference ref="223835729"/>
 						</object>
-						<reference key="parent" ref="1036577743"/>
+						<reference key="parent" ref="348328898"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">374</int>
-						<reference key="object" ref="137435489"/>
+						<reference key="object" ref="989050925"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="891925158"/>
+							<reference ref="189594322"/>
 						</object>
-						<reference key="parent" ref="536248195"/>
+						<reference key="parent" ref="300811574"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">375</int>
-						<reference key="object" ref="663154230"/>
+						<reference key="object" ref="700826966"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="836703945"/>
+							<reference ref="489340979"/>
 						</object>
-						<reference key="parent" ref="536248195"/>
+						<reference key="parent" ref="300811574"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">376</int>
-						<reference key="object" ref="417801719"/>
+						<reference key="object" ref="168436707"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="935570098"/>
+							<reference ref="53243865"/>
 						</object>
-						<reference key="parent" ref="536248195"/>
+						<reference key="parent" ref="300811574"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">377</int>
-						<reference key="object" ref="115954190"/>
+						<reference key="object" ref="363817195"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="144257898"/>
+							<reference ref="390084685"/>
 						</object>
-						<reference key="parent" ref="536248195"/>
+						<reference key="parent" ref="300811574"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">379</int>
-						<reference key="object" ref="1067279202"/>
+						<reference key="object" ref="223835729"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="703874672"/>
+							<reference ref="283628678"/>
 						</object>
-						<reference key="parent" ref="536248195"/>
+						<reference key="parent" ref="300811574"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">285</int>
-						<reference key="object" ref="796776534"/>
+						<reference key="object" ref="604417141"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="1039094689"/>
+							<reference ref="85544634"/>
 						</object>
-						<reference key="parent" ref="0"/>
+						<reference key="parent" ref="330408435"/>
 						<string key="objectName">EditPrograms</string>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">286</int>
-						<reference key="object" ref="1039094689"/>
+						<reference key="object" ref="85544634"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="1002101696"/>
-							<reference ref="711288662"/>
-							<reference ref="634701477"/>
-							<reference ref="1011512617"/>
-							<reference ref="859414998"/>
-							<reference ref="381268760"/>
+							<reference ref="1063387772"/>
+							<reference ref="758204686"/>
+							<reference ref="671954382"/>
+							<reference ref="492358940"/>
+							<reference ref="125703429"/>
+							<reference ref="724002248"/>
 						</object>
-						<reference key="parent" ref="796776534"/>
+						<reference key="parent" ref="604417141"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">291</int>
-						<reference key="object" ref="1002101696"/>
+						<int key="objectID">423</int>
+						<reference key="object" ref="294137138"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="558394524"/>
+							<reference ref="318286212"/>
+							<reference ref="511651072"/>
 						</object>
-						<reference key="parent" ref="1039094689"/>
+						<reference key="parent" ref="330408435"/>
+						<string key="objectName">DockMenu</string>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">292</int>
-						<reference key="object" ref="711288662"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="413164923"/>
-						</object>
-						<reference key="parent" ref="1039094689"/>
+						<int key="objectID">524</int>
+						<reference key="object" ref="318286212"/>
+						<reference key="parent" ref="294137138"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">293</int>
-						<reference key="object" ref="634701477"/>
+						<int key="objectID">526</int>
+						<reference key="object" ref="511651072"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="26248495"/>
+							<reference ref="48278059"/>
 						</object>
-						<reference key="parent" ref="1039094689"/>
+						<reference key="parent" ref="294137138"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">295</int>
-						<reference key="object" ref="1011512617"/>
+						<int key="objectID">527</int>
+						<reference key="object" ref="48278059"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="411425856"/>
-							<reference ref="152467947"/>
-							<reference ref="208024104"/>
-							<reference ref="526973850"/>
+							<reference ref="1032342329"/>
+							<reference ref="563798000"/>
 						</object>
-						<reference key="parent" ref="1039094689"/>
+						<reference key="parent" ref="511651072"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">296</int>
-						<reference key="object" ref="411425856"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="621551865"/>
-							<reference ref="976084317"/>
-							<reference ref="661701503"/>
-						</object>
-						<reference key="parent" ref="1011512617"/>
+						<int key="objectID">532</int>
+						<reference key="object" ref="1032342329"/>
+						<reference key="parent" ref="48278059"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">297</int>
-						<reference key="object" ref="621551865"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="195831317"/>
-						</object>
-						<reference key="parent" ref="411425856"/>
+						<int key="objectID">533</int>
+						<reference key="object" ref="563798000"/>
+						<reference key="parent" ref="48278059"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">574</int>
-						<reference key="object" ref="195831317"/>
-						<reference key="parent" ref="621551865"/>
+						<int key="objectID">100363</int>
+						<reference key="object" ref="990762273"/>
+						<reference key="parent" ref="119157981"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">298</int>
-						<reference key="object" ref="976084317"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="656574062"/>
-						</object>
-						<reference key="parent" ref="411425856"/>
+						<int key="objectID">100364</int>
+						<reference key="object" ref="391919450"/>
+						<reference key="parent" ref="443008216"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">573</int>
-						<reference key="object" ref="656574062"/>
-						<reference key="parent" ref="976084317"/>
+						<int key="objectID">100365</int>
+						<reference key="object" ref="649334366"/>
+						<reference key="parent" ref="282885445"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">535</int>
-						<reference key="object" ref="661701503"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="90031137"/>
-						</object>
-						<reference key="parent" ref="411425856"/>
+						<int key="objectID">100368</int>
+						<reference key="object" ref="940564599"/>
+						<reference key="parent" ref="842100515"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">575</int>
-						<reference key="object" ref="90031137"/>
-						<reference key="parent" ref="661701503"/>
+						<int key="objectID">100369</int>
+						<reference key="object" ref="666057093"/>
+						<reference key="parent" ref="31160162"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">299</int>
-						<reference key="object" ref="859414998"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="537937846"/>
-						</object>
-						<reference key="parent" ref="1039094689"/>
+						<int key="objectID">100370</int>
+						<reference key="object" ref="967619578"/>
+						<reference key="parent" ref="179949713"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">310</int>
-						<reference key="object" ref="381268760"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="99903682"/>
-						</object>
-						<reference key="parent" ref="1039094689"/>
+						<int key="objectID">100371</int>
+						<reference key="object" ref="1016069354"/>
+						<reference key="parent" ref="418227126"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">423</int>
-						<reference key="object" ref="1001514180"/>
+						<int key="objectID">100372</int>
+						<reference key="object" ref="624655599"/>
+						<reference key="parent" ref="1039016593"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">100382</int>
+						<reference key="object" ref="633115429"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="355724345"/>
-							<reference ref="107275095"/>
+							<reference ref="341113515"/>
 						</object>
-						<reference key="parent" ref="0"/>
-						<string key="objectName">DockMenu</string>
+						<reference key="parent" ref="709074847"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">524</int>
-						<reference key="object" ref="355724345"/>
-						<reference key="parent" ref="1001514180"/>
+						<int key="objectID">100385</int>
+						<reference key="object" ref="930265681"/>
+						<reference key="parent" ref="201731424"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">526</int>
-						<reference key="object" ref="107275095"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="321919370"/>
-						</object>
-						<reference key="parent" ref="1001514180"/>
+						<int key="objectID">100386</int>
+						<reference key="object" ref="311969422"/>
+						<reference key="parent" ref="86150604"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">527</int>
-						<reference key="object" ref="321919370"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="656726997"/>
-							<reference ref="500771766"/>
-						</object>
-						<reference key="parent" ref="107275095"/>
+						<int key="objectID">100541</int>
+						<reference key="object" ref="631531164"/>
+						<reference key="parent" ref="477203622"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">532</int>
-						<reference key="object" ref="656726997"/>
-						<reference key="parent" ref="321919370"/>
+						<int key="objectID">100543</int>
+						<reference key="object" ref="761107402"/>
+						<reference key="parent" ref="298603383"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">533</int>
-						<reference key="object" ref="500771766"/>
-						<reference key="parent" ref="321919370"/>
+						<int key="objectID">100374</int>
+						<reference key="object" ref="189594322"/>
+						<reference key="parent" ref="989050925"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">100363</int>
-						<reference key="object" ref="727617204"/>
-						<reference key="parent" ref="808306730"/>
+						<int key="objectID">100375</int>
+						<reference key="object" ref="489340979"/>
+						<reference key="parent" ref="700826966"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">100364</int>
-						<reference key="object" ref="140236247"/>
-						<reference key="parent" ref="618388983"/>
+						<int key="objectID">100376</int>
+						<reference key="object" ref="53243865"/>
+						<reference key="parent" ref="168436707"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">100365</int>
-						<reference key="object" ref="110537159"/>
-						<reference key="parent" ref="754792079"/>
+						<int key="objectID">100377</int>
+						<reference key="object" ref="390084685"/>
+						<reference key="parent" ref="363817195"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">100368</int>
-						<reference key="object" ref="46680941"/>
-						<reference key="parent" ref="677150201"/>
+						<int key="objectID">100379</int>
+						<reference key="object" ref="283628678"/>
+						<reference key="parent" ref="223835729"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">100369</int>
-						<reference key="object" ref="415694484"/>
-						<reference key="parent" ref="228801813"/>
+						<int key="objectID">380</int>
+						<reference key="object" ref="341113515"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="759499526"/>
+							<reference ref="616492372"/>
+							<reference ref="543935434"/>
+							<reference ref="836673018"/>
+						</object>
+						<reference key="parent" ref="633115429"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">100370</int>
-						<reference key="object" ref="466260504"/>
-						<reference key="parent" ref="793493073"/>
+						<int key="objectID">435</int>
+						<reference key="object" ref="759499526"/>
+						<reference key="parent" ref="341113515"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">100371</int>
-						<reference key="object" ref="225158677"/>
-						<reference key="parent" ref="1045559310"/>
+						<int key="objectID">384</int>
+						<reference key="object" ref="616492372"/>
+						<reference key="parent" ref="341113515"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">100372</int>
-						<reference key="object" ref="1072420481"/>
-						<reference key="parent" ref="67626595"/>
+						<int key="objectID">383</int>
+						<reference key="object" ref="543935434"/>
+						<reference key="parent" ref="341113515"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">100382</int>
-						<reference key="object" ref="301142744"/>
+						<int key="objectID">381</int>
+						<reference key="object" ref="836673018"/>
+						<reference key="parent" ref="341113515"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">300296</int>
+						<reference key="object" ref="915448994"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="1071781177"/>
+							<reference ref="117056849"/>
 						</object>
-						<reference key="parent" ref="300224954"/>
+						<reference key="parent" ref="596750588"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">100385</int>
-						<reference key="object" ref="749756205"/>
-						<reference key="parent" ref="717889178"/>
+						<int key="objectID">300297</int>
+						<reference key="object" ref="117056849"/>
+						<reference key="parent" ref="915448994"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">100386</int>
-						<reference key="object" ref="725554783"/>
-						<reference key="parent" ref="114173823"/>
+						<int key="objectID">300298</int>
+						<reference key="object" ref="707276799"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="318286890"/>
+						</object>
+						<reference key="parent" ref="596750588"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">100541</int>
-						<reference key="object" ref="100363081"/>
-						<reference key="parent" ref="817420822"/>
+						<int key="objectID">300299</int>
+						<reference key="object" ref="318286890"/>
+						<reference key="parent" ref="707276799"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">100543</int>
-						<reference key="object" ref="550432669"/>
-						<reference key="parent" ref="959270736"/>
+						<int key="objectID">295</int>
+						<reference key="object" ref="1063387772"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="792419186"/>
+							<reference ref="17278747"/>
+							<reference ref="842897584"/>
+							<reference ref="905092943"/>
+						</object>
+						<reference key="parent" ref="85544634"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">100374</int>
-						<reference key="object" ref="891925158"/>
-						<reference key="parent" ref="137435489"/>
+						<int key="objectID">300295</int>
+						<reference key="object" ref="792419186"/>
+						<reference key="parent" ref="1063387772"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">100375</int>
-						<reference key="object" ref="836703945"/>
-						<reference key="parent" ref="663154230"/>
+						<int key="objectID">200295</int>
+						<reference key="object" ref="17278747"/>
+						<reference key="parent" ref="1063387772"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">100376</int>
-						<reference key="object" ref="935570098"/>
-						<reference key="parent" ref="417801719"/>
+						<int key="objectID">100295</int>
+						<reference key="object" ref="842897584"/>
+						<reference key="parent" ref="1063387772"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">100377</int>
-						<reference key="object" ref="144257898"/>
-						<reference key="parent" ref="115954190"/>
+						<int key="objectID">296</int>
+						<reference key="object" ref="905092943"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="242608782"/>
+							<reference ref="938444323"/>
+							<reference ref="84282687"/>
+						</object>
+						<reference key="parent" ref="1063387772"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">100379</int>
-						<reference key="object" ref="703874672"/>
-						<reference key="parent" ref="1067279202"/>
+						<int key="objectID">535</int>
+						<reference key="object" ref="242608782"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="34714764"/>
+						</object>
+						<reference key="parent" ref="905092943"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">100291</int>
-						<reference key="object" ref="558394524"/>
-						<reference key="parent" ref="1002101696"/>
+						<int key="objectID">575</int>
+						<reference key="object" ref="34714764"/>
+						<reference key="parent" ref="242608782"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">100292</int>
-						<reference key="object" ref="413164923"/>
-						<reference key="parent" ref="711288662"/>
+						<int key="objectID">298</int>
+						<reference key="object" ref="938444323"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="825378892"/>
+						</object>
+						<reference key="parent" ref="905092943"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">100293</int>
-						<reference key="object" ref="26248495"/>
-						<reference key="parent" ref="634701477"/>
+						<int key="objectID">573</int>
+						<reference key="object" ref="825378892"/>
+						<reference key="parent" ref="938444323"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">100299</int>
-						<reference key="object" ref="537937846"/>
-						<reference key="parent" ref="859414998"/>
+						<int key="objectID">297</int>
+						<reference key="object" ref="84282687"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="432610585"/>
+						</object>
+						<reference key="parent" ref="905092943"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">574</int>
+						<reference key="object" ref="432610585"/>
+						<reference key="parent" ref="84282687"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">310</int>
+						<reference key="object" ref="758204686"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="1025474039"/>
+						</object>
+						<reference key="parent" ref="85544634"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">100310</int>
-						<reference key="object" ref="99903682"/>
-						<reference key="parent" ref="381268760"/>
+						<reference key="object" ref="1025474039"/>
+						<reference key="parent" ref="758204686"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">380</int>
-						<reference key="object" ref="1071781177"/>
+						<int key="objectID">292</int>
+						<reference key="object" ref="671954382"/>
 						<object class="NSMutableArray" key="children">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="827519886"/>
-							<reference ref="473657062"/>
-							<reference ref="247508345"/>
-							<reference ref="611307925"/>
+							<reference ref="143554520"/>
 						</object>
-						<reference key="parent" ref="301142744"/>
+						<reference key="parent" ref="85544634"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">435</int>
-						<reference key="object" ref="827519886"/>
-						<reference key="parent" ref="1071781177"/>
+						<int key="objectID">100292</int>
+						<reference key="object" ref="143554520"/>
+						<reference key="parent" ref="671954382"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">384</int>
-						<reference key="object" ref="473657062"/>
-						<reference key="parent" ref="1071781177"/>
+						<int key="objectID">293</int>
+						<reference key="object" ref="492358940"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="8201128"/>
+						</object>
+						<reference key="parent" ref="85544634"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">383</int>
-						<reference key="object" ref="247508345"/>
-						<reference key="parent" ref="1071781177"/>
+						<int key="objectID">100293</int>
+						<reference key="object" ref="8201128"/>
+						<reference key="parent" ref="492358940"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">381</int>
-						<reference key="object" ref="611307925"/>
-						<reference key="parent" ref="1071781177"/>
+						<int key="objectID">299</int>
+						<reference key="object" ref="125703429"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="892296813"/>
+						</object>
+						<reference key="parent" ref="85544634"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">100295</int>
-						<reference key="object" ref="152467947"/>
-						<reference key="parent" ref="1011512617"/>
+						<int key="objectID">100299</int>
+						<reference key="object" ref="892296813"/>
+						<reference key="parent" ref="125703429"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">200295</int>
-						<reference key="object" ref="208024104"/>
-						<reference key="parent" ref="1011512617"/>
+						<int key="objectID">291</int>
+						<reference key="object" ref="724002248"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="809610613"/>
+						</object>
+						<reference key="parent" ref="85544634"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">300295</int>
-						<reference key="object" ref="526973850"/>
-						<reference key="parent" ref="1011512617"/>
+						<int key="objectID">100291</int>
+						<reference key="object" ref="809610613"/>
+						<reference key="parent" ref="724002248"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">300330</int>
+						<reference key="object" ref="444952046"/>
+						<reference key="parent" ref="96874957"/>
 					</object>
 				</object>
 			</object>
@@ -2801,6 +2897,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 					<string>164.ImportedFromIB2</string>
 					<string>169.IBPluginDependency</string>
 					<string>169.ImportedFromIB2</string>
+					<string>169.editorWindowContentRectSynchronizationRect</string>
 					<string>171.IBPluginDependency</string>
 					<string>171.ImportedFromIB2</string>
 					<string>172.IBPluginDependency</string>
@@ -2816,14 +2913,15 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 					<string>203.ImportedFromIB2</string>
 					<string>204.IBPluginDependency</string>
 					<string>204.ImportedFromIB2</string>
-					<string>208.IBPluginDependency</string>
-					<string>208.ImportedFromIB2</string>
 					<string>23.IBPluginDependency</string>
 					<string>23.ImportedFromIB2</string>
 					<string>24.IBPluginDependency</string>
 					<string>24.ImportedFromIB2</string>
+					<string>24.editorWindowContentRectSynchronizationRect</string>
 					<string>244.IBPluginDependency</string>
+					<string>244.IBWindowTemplateEditedContentRect</string>
 					<string>244.ImportedFromIB2</string>
+					<string>244.editorWindowContentRectSynchronizationRect</string>
 					<string>244.windowTemplate.hasMaxSize</string>
 					<string>244.windowTemplate.hasMinSize</string>
 					<string>244.windowTemplate.maxSize</string>
@@ -2834,10 +2932,15 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 					<string>269.ImportedFromIB2</string>
 					<string>270.IBPluginDependency</string>
 					<string>270.ImportedFromIB2</string>
+					<string>270.editorWindowContentRectSynchronizationRect</string>
 					<string>272.IBPluginDependency</string>
 					<string>272.ImportedFromIB2</string>
 					<string>285.IBPluginDependency</string>
+					<string>285.IBViewEditorWindowController.showingBoundsRectangles</string>
+					<string>285.IBViewEditorWindowController.showingLayoutRectangles</string>
+					<string>285.IBWindowTemplateEditedContentRect</string>
 					<string>285.ImportedFromIB2</string>
+					<string>285.editorWindowContentRectSynchronizationRect</string>
 					<string>285.windowTemplate.hasMaxSize</string>
 					<string>285.windowTemplate.hasMinSize</string>
 					<string>285.windowTemplate.maxSize</string>
@@ -2846,6 +2949,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 					<string>286.ImportedFromIB2</string>
 					<string>29.IBPluginDependency</string>
 					<string>29.ImportedFromIB2</string>
+					<string>29.editorWindowContentRectSynchronizationRect</string>
 					<string>291.IBPluginDependency</string>
 					<string>291.ImportedFromIB2</string>
 					<string>292.IBPluginDependency</string>
@@ -2863,6 +2967,12 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 					<string>299.IBPluginDependency</string>
 					<string>299.ImportedFromIB2</string>
 					<string>300295.IBShouldRemoveOnLegacySave</string>
+					<string>300296.IBPluginDependency</string>
+					<string>300296.ImportedFromIB2</string>
+					<string>300298.IBPluginDependency</string>
+					<string>300298.ImportedFromIB2</string>
+					<string>300330.IBPluginDependency</string>
+					<string>300330.ImportedFromIB2</string>
 					<string>305.IBPluginDependency</string>
 					<string>305.ImportedFromIB2</string>
 					<string>310.IBPluginDependency</string>
@@ -2963,6 +3073,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 					<string>56.ImportedFromIB2</string>
 					<string>57.IBPluginDependency</string>
 					<string>57.ImportedFromIB2</string>
+					<string>57.editorWindowContentRectSynchronizationRect</string>
 					<string>573.IBPluginDependency</string>
 					<string>573.ImportedFromIB2</string>
 					<string>574.IBPluginDependency</string>
@@ -2976,217 +3087,232 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 				</object>
 				<object class="NSMutableArray" key="dict.values">
 					<bool key="EncodedWithXMLCoder">YES</bool>
-					<reference ref="874199827"/>
-					<reference ref="874199827"/>
-					<reference ref="874199827"/>
-					<integer value="1" id="5"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="5"/>
-					<reference ref="5"/>
-					<string>{3.40282e+38, 3.40282e+38}</string>
-					<string>{213, 107}</string>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="5"/>
-					<reference ref="5"/>
-					<string>{3.40282e+38, 3.40282e+38}</string>
-					<string>{213, 107}</string>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
-					<reference ref="874199827"/>
-					<reference ref="5"/>
+					<reference ref="1013584587"/>
+					<reference ref="1013584587"/>
+					<reference ref="1013584587"/>
+					<integer value="1" id="9"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<string>{{202, 626}, {154, 153}}</string>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<string>{{271, 666}, {301, 153}}</string>
+					<reference ref="1013584587"/>
+					<string>{{184, 290}, {481, 345}}</string>
+					<reference ref="9"/>
+					<string>{{184, 290}, {481, 345}}</string>
+					<reference ref="9"/>
+					<reference ref="9"/>
+					<string id="169660368">{3.40282e+38, 3.40282e+38}</string>
+					<string id="432763037">{213, 107}</string>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<string>{{100, 746}, {155, 33}}</string>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="9"/>
+					<string id="678991548">{{433, 406}, {486, 327}}</string>
+					<reference ref="9"/>
+					<reference ref="678991548"/>
+					<reference ref="9"/>
+					<reference ref="9"/>
+					<reference ref="169660368"/>
+					<reference ref="432763037"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<string>{{67, 819}, {336, 20}}</string>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<string>{{79, 616}, {218, 203}}</string>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
+					<reference ref="1013584587"/>
+					<reference ref="9"/>
 				</object>
 			</object>
 			<object class="NSMutableDictionary" key="unlocalizedProperties">
@@ -3209,13 +3335,13 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 				</object>
 			</object>
 			<nil key="sourceID"/>
-			<int key="maxID">300295</int>
+			<int key="maxID">300334</int>
 		</object>
 		<object class="IBClassDescriber" key="IBDocument.Classes">
 			<object class="NSMutableArray" key="referencedPartialClassDescriptions">
 				<bool key="EncodedWithXMLCoder">YES</bool>
 				<object class="IBPartialClassDescription">
-					<string key="className">NSFormatter</string>
+					<reference key="className" ref="671773319"/>
 					<nil key="superclassName"/>
 					<object class="NSMutableDictionary" key="actions">
 						<bool key="EncodedWithXMLCoder">YES</bool>
@@ -3236,196 +3362,8 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 						</object>
 					</object>
 					<object class="IBClassDescriptionSource" key="sourceIdentifier">
-						<string key="majorKey" id="3826605">IBUserSource</string>
-						<string key="minorKey" id="25614681"/>
-					</object>
-				</object>
-				<object class="IBPartialClassDescription">
-					<string key="className">FirstResponder</string>
-					<nil key="superclassName"/>
-					<object class="NSMutableDictionary" key="actions">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSMutableArray" key="dict.sortedKeys">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>alignCenter:</string>
-							<string>alignJustified:</string>
-							<string>alignLeft:</string>
-							<string>alignRight:</string>
-							<string>arrangeInFront:</string>
-							<string>centerSelectionInVisibleArea:</string>
-							<string>changeFont:</string>
-							<string>checkSpelling:</string>
-							<string>clear:</string>
-							<string>clearRecentDocuments:</string>
-							<string>complete:</string>
-							<string>copy:</string>
-							<string>copyFont:</string>
-							<string>copyRuler:</string>
-							<string>cut:</string>
-							<string>delete:</string>
-							<string>deminiaturize:</string>
-							<string>fax:</string>
-							<string>hide:</string>
-							<string>hideOtherApplications:</string>
-							<string>loosenKerning:</string>
-							<string>lowerBaseline:</string>
-							<string>makeKeyAndOrderFront:</string>
-							<string>miniaturize:</string>
-							<string>newDocument:</string>
-							<string>openDocument:</string>
-							<string>orderBack:</string>
-							<string>orderFront:</string>
-							<string>orderFrontColorPanel:</string>
-							<string>orderFrontHelpPanel:</string>
-							<string>orderOut:</string>
-							<string>outline:</string>
-							<string>paste:</string>
-							<string>pasteAsPlainText:</string>
-							<string>pasteAsRichText:</string>
-							<string>pasteFont:</string>
-							<string>pasteRuler:</string>
-							<string>pause:</string>
-							<string>performClose:</string>
-							<string>performFindPanelAction:</string>
-							<string>performMiniaturize:</string>
-							<string>performZoom:</string>
-							<string>play:</string>
-							<string>print:</string>
-							<string>printDocument:</string>
-							<string>raiseBaseline:</string>
-							<string>record:</string>
-							<string>redo:</string>
-							<string>resume:</string>
-							<string>revertDocumentToSaved:</string>
-							<string>run:</string>
-							<string>runPageLayout:</string>
-							<string>runToolbarCustomizationPalette:</string>
-							<string>saveAllDocuments:</string>
-							<string>saveDocument:</string>
-							<string>saveDocumentAs:</string>
-							<string>saveDocumentTo:</string>
-							<string>selectAll:</string>
-							<string>selectText:</string>
-							<string>showGuessPanel:</string>
-							<string>showHelp:</string>
-							<string>start:</string>
-							<string>startSpeaking:</string>
-							<string>stop:</string>
-							<string>stopSpeaking:</string>
-							<string>subscript:</string>
-							<string>superscript:</string>
-							<string>terminate:</string>
-							<string>tightenKerning:</string>
-							<string>toggleContinuousSpellChecking:</string>
-							<string>toggleRuler:</string>
-							<string>toggleToolbarShown:</string>
-							<string>turnOffKerning:</string>
-							<string>turnOffLigatures:</string>
-							<string>underline:</string>
-							<string>undo:</string>
-							<string>unhideAllApplications:</string>
-							<string>unscript:</string>
-							<string>useAllLigatures:</string>
-							<string>useStandardKerning:</string>
-							<string>useStandardLigatures:</string>
-						</object>
-						<object class="NSMutableArray" key="dict.values">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string id="663201829">id</string>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-						</object>
-					</object>
-					<object class="NSMutableDictionary" key="outlets">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSArray" key="dict.sortedKeys">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-						</object>
-						<object class="NSMutableArray" key="dict.values">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-						</object>
-					</object>
-					<object class="IBClassDescriptionSource" key="sourceIdentifier">
-						<reference key="majorKey" ref="3826605"/>
-						<reference key="minorKey" ref="25614681"/>
+						<string key="majorKey" id="360524387">IBUserSource</string>
+						<reference key="minorKey" ref="331740794"/>
 					</object>
 				</object>
 				<object class="IBPartialClassDescription">
@@ -3449,29 +3387,31 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 							<string>prefs_changed:</string>
 							<string>prefs_show:</string>
 							<string>previous_window:</string>
+							<string>quit:</string>
 							<string>toggle_fullscreen:</string>
 							<string>x11_help:</string>
 							<string>zoom_window:</string>
 						</object>
 						<object class="NSMutableArray" key="dict.values">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
+							<string id="678582588">id</string>
+							<reference ref="678582588"/>
+							<reference ref="678582588"/>
+							<reference ref="678582588"/>
+							<reference ref="678582588"/>
+							<reference ref="678582588"/>
+							<reference ref="678582588"/>
+							<reference ref="678582588"/>
+							<reference ref="678582588"/>
+							<reference ref="678582588"/>
+							<reference ref="678582588"/>
+							<reference ref="678582588"/>
+							<reference ref="678582588"/>
+							<reference ref="678582588"/>
+							<reference ref="678582588"/>
+							<reference ref="678582588"/>
+							<reference ref="678582588"/>
+							<reference ref="678582588"/>
 						</object>
 					</object>
 					<object class="NSMutableDictionary" key="outlets">
@@ -3480,6 +3420,7 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 							<bool key="EncodedWithXMLCoder">YES</bool>
 							<string>apps_separator</string>
 							<string>apps_table</string>
+							<string>click_through</string>
 							<string>depth</string>
 							<string>dock_apps_menu</string>
 							<string>dock_menu</string>
@@ -3498,28 +3439,55 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 						</object>
 						<object class="NSMutableArray" key="dict.values">
 							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
-							<reference ref="663201829"/>
+							<string id="133216019">NSMenuItem</string>
+							<string>NSTableView</string>
+							<string id="623744785">NSButton</string>
+							<string>NSPopUpButton</string>
+							<string id="455827649">NSMenu</string>
+							<reference ref="455827649"/>
+							<reference ref="133216019"/>
+							<reference ref="623744785"/>
+							<reference ref="623744785"/>
+							<reference ref="623744785"/>
+							<reference ref="623744785"/>
+							<reference ref="623744785"/>
+							<string>NSPanel</string>
+							<reference ref="623744785"/>
+							<reference ref="133216019"/>
+							<reference ref="623744785"/>
+							<reference ref="133216019"/>
+							<reference ref="133216019"/>
+						</object>
+					</object>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBUserSource</string>
+						<string key="minorKey"/>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">NSFormatter</string>
+					<nil key="superclassName"/>
+					<object class="NSMutableDictionary" key="actions">
+						<bool key="EncodedWithXMLCoder">YES</bool>
+						<object class="NSArray" key="dict.sortedKeys">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+						</object>
+						<object class="NSMutableArray" key="dict.values">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+						</object>
+					</object>
+					<object class="NSMutableDictionary" key="outlets">
+						<bool key="EncodedWithXMLCoder">YES</bool>
+						<object class="NSArray" key="dict.sortedKeys">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+						</object>
+						<object class="NSMutableArray" key="dict.values">
+							<bool key="EncodedWithXMLCoder">YES</bool>
 						</object>
 					</object>
 					<object class="IBClassDescriptionSource" key="sourceIdentifier">
-						<reference key="majorKey" ref="3826605"/>
-						<reference key="minorKey" ref="25614681"/>
+						<reference key="majorKey" ref="360524387"/>
+						<reference key="minorKey" ref="331740794"/>
 					</object>
 				</object>
 			</object>
@@ -3529,570 +3497,595 @@ d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
 		<int key="IBDocument.defaultPropertyAccessControl">3</int>
 		<object class="NSMutableData" key="IBDocument.RunnableNib">
 			<bytes key="NS.bytes">YnBsaXN0MDDUAAEAAgADAAQABQAGAAkAClgkdmVyc2lvblQkdG9wWSRhcmNoaXZlclgkb2JqZWN0cxIA
-AYag0QAHAAhdSUIub2JqZWN0ZGF0YYABXxAPTlNLZXllZEFyY2hpdmVyrxEDKQALAAwAMQA1ADkAQABD
-AEQASABMAIYAjACcAKEAogCjAKgAqQCqAK0AsQCyALUAtgC6AMAAzgDUANUA7wDwAPgA+QD8AQABAQEE
-AQgBDgERARIBEwEXAR4BHwEgASEBJgEnASoBLwE0ATUBOgFFAVABUQFSAVYBWwFkAWsBbAFwAXIBcwF4
-AX8BhQGGAY4BjwGUAZsBoAGhAakBqgGrAbABsQG2Ab0BvgHWAdoB3AHeAesB7wHwAfEB9AH7AgUB8AIG
-AhAB8AIRAhsB8AIcAiACIwIoAjECNgI3AjwCRQJJAkoCTwJWAlcCXwJgAmECZgJnAmwCiAKJAooCiwKO
-Ao8CkAKWApoCqgKuArgCvwLAAsoCywLQAtoC2wLcAuAC4gLnAugC6wLuAvEC+AL5AwADAQMIAwkDEAMR
-AxgDGQMhAyIDKQMqAzEDMgMzAzUDNgM8A0UDSANRA1gDWQNgA2EDaANpA3ADcQN4A3kDgQOCA4kDigOR
-AzIDkgOTA5YDnQOgA6EDpwOvAlYDtgO+A78DxgPHA84DzwPWA9cD3gPfA+YD5wPuAzID7wPwA/ID8wP0
-Ao4D9QP2A/kD+gP+BAUEBgQHBAgEDQQSBBkEGgQfBCYEKwQsBC0EMgQ5BDoEOwRABEcESARJBEoETwRX
-BFgEWQReBF8EZARrBGwEbQRxBHgEeQR6BHsEgASHBIgEiQSKBI4ElQSWBJcEmASdBKQEpQSmBKsEsgS2
-BLcEuAS9BMIEwwTIBNAE1QTWBOAE4QTkBOUE5wTpBOoE7wTwBPUE/AT9BQUFBgUIBQoFCwUQBREFFgUX
-BRwFIwUkBSUFJgUrBTMFNAU9BT4FQAVBBUYFSwVMBVEFbAV7BXwFgwWMBY0FkAWVBakFqgWtBbMFxQXM
-Bc0F0AXVBdYF2QXgBeMF5gXvBfUF9gX8BgUGCwYMBhEGEgYZBh0GIgYjBigGKQYsBi4GLwY0BjwGPQY+
-Bj8GRAZLBkwGTQZRBlgGWQZaBlsGYAZnBmgGcAZxBnMGdQZ2BnsGfAaBBogGiQaKBosGkAaRBpYGlwac
-Bp0GoganBq4GrwawBrEGtga9Br4GvwbABsUGzAbNBtUG1gbYBtoG2wbgBuEG5QbsBu0G7gbvB28HeAeA
-B4QHhQeIB5EHkgeTB5YHngefB6MHpAelB6gHqQeuB7cHvAFRB70HzAfVB94BUQffB+QH5gfpB+oH8wf8
-CAUIBgFRCA8IEggeCCcIMAgxCDIIOghDAVEIRAhPCFgIEQFRCGEIagFRCGsIbwhwADgIcwiBCIIIgwKO
-Ao8D8wP0Ao4IhQiGCIgJCAmJCgoKCwoMCg0KDgoPChAKEQoSChMKFAoVChYKFwoYChkKGgobChwKHQoe
-Ch8KIAohCiIKIwokCiUKJgonCigKKQoqCisKLAotCi4KLwowCjEKMgozCjQKNQo2CjcKOAo5CjoKOwo8
-Cj0KPgo/CkAKQQpCCkMKRApFCkYKRwpICkkKSgpLCkwKTQpOCk8KUApRClIKUwpUClUKVgpXClgKWQpa
-ClsKXApdCl4KXwpgCmEKYgpjCmQKZQpmCmcKaAppCmoKawpsCm0KbgpvCnAKcQpyAo0Kcwp0CnUKdgp3
-CngKeQp6CnsKfAp9Cn4KfwqACoEKggqDCoQKhQqICosLQwv7C/wL/Qv+C/8MAAwBDAIMAwwEDAUMBgwH
-DAgMCQwKDAsMDAwNDA4MDwwQDBEMEgwTDBQMFQwWDBcMGAwZDBoMGwwcDB0MHgwfDCAMIQwiDCMMJAwl
-DCYMJwIaBTAMKAwpDCoMKwwsDC0MLgwvDDAMMQwyDDMMNAw1DDYMNww4DDkMOgw7DDwMPQw+DD8MQAxB
-DEIMQwxEDEUMRgxHDEgMSQxKDEsMTAxNDE4MTwxQDFEMUgxTDFQMVQxWDFcMWAxZDFoMWwxcDF0MXgxf
-DGAMYQxiDGMMZAxlDGYMZwxoDGkMagxrDGwMbQxuDG8McAxxDHIMcwx0DHUMdgx3BM0MeAx5DHoMewx8
-DH0Mfgx/DIAMgQyCDIMMhAyFDIYMhwyIDIkMigyLDIwMjQyODI8MkAyRDJIMkwyUDJUMlgyXDJgMmQya
-DJsMnAydDJ4MnwygDKEMogyjDKQMpQymDKcMqAypDKoMqwysDK0MsAyzDLZVJG51bGzfEBIADQAOAA8A
-EAARABIAEwAUABUAFgAXABgAGQAaABsAHAAdAB4AHwAgACEAIgAjACQAJQAmACcAKAApACoAKwAsAC0A
-LgAvADBWTlNSb290ViRjbGFzc11OU09iamVjdHNLZXlzXxAPTlNDbGFzc2VzVmFsdWVzXxAZTlNBY2Nl
-c3NpYmlsaXR5T2lkc1ZhbHVlc11OU0Nvbm5lY3Rpb25zW05TTmFtZXNLZXlzW05TRnJhbWV3b3JrXU5T
-Q2xhc3Nlc0tleXNaTlNPaWRzS2V5c11OU05hbWVzVmFsdWVzXxAZTlNBY2Nlc3NpYmlsaXR5Q29ubmVj
-dG9yc11OU0ZvbnRNYW5hZ2VyXxAQTlNWaXNpYmxlV2luZG93c18QD05TT2JqZWN0c1ZhbHVlc18QF05T
-QWNjZXNzaWJpbGl0eU9pZHNLZXlzWU5TTmV4dE9pZFxOU09pZHNWYWx1ZXOAAoEDKIEBp4ECbYEDJ4AJ
-gQHugAaBAmyBAm6BAe+BAyWAAIAHgQHtgQMmEgAElQiBAm/SAA4AMgAzADRbTlNDbGFzc05hbWWABYAD
-0gAOADYANwA4WU5TLnN0cmluZ4AEXU5TQXBwbGljYXRpb27SADoAOwA8AD1YJGNsYXNzZXNaJGNsYXNz
-bmFtZaMAPQA+AD9fEA9OU011dGFibGVTdHJpbmdYTlNTdHJpbmdYTlNPYmplY3TSADoAOwBBAEKiAEIA
-P15OU0N1c3RvbU9iamVjdF8QEElCQ29jb2FGcmFtZXdvcmvSAA4ARQBGAEdaTlMub2JqZWN0c4AIoNIA
-OgA7AEkASqMASgBLAD9cTlNNdXRhYmxlU2V0VU5TU2V00gAOAEUATQBOgD6vEDcATwBQAFEAUgBTAFQA
-VQBWAFcAWABZAFoAWwBcAF0AXgBfAGAAYQBiAGMAZABlAGYAZwBoAGkAagBrAGwAbQBuAG8AcABxAHIA
-cwB0AHUAdgB3AHgAeQB6AHsAfAB9AH4AfwCAAIEAggCDAIQAhYAKgBiAKYAugDGAQYBHgE6AUIBogGyA
-cIB2gHiA3YDigOOA5oDrgO+A9ID4gPqA/oEBA4EBCIEBDYEBEYEBFoEBF4EBGYEBJIEBJoEBLoEBMIEB
-MoEBN4EBPoEBP4EBQYEBaoEBb4EBc4EBeIEBgIEBgoEBh4EBiYEBi4EBjYEBjoEBk4EBmIEBoIEBotMA
-DgCHAIgAiQCKAItYTlNTb3VyY2VXTlNMYWJlbIAXgAuAFtgADgCNAI4AjwCQAJEAkgCTAJQAlQCWAJcA
-mACZAJoAm1dOU1RpdGxlXxARTlNLZXlFcXVpdk1vZE1hc2taTlNLZXlFcXVpdl1OU01uZW1vbmljTG9j
-WU5TT25JbWFnZVxOU01peGVkSW1hZ2VWTlNNZW51gBWADRIAEAAAgA4Sf////4APgBOADNMADgCNAJ0A
-ngCfAKBbTlNNZW51SXRlbXOAP4EB1IEB1lZEZWxldGVQ0wAOADIApAClAKYAp15OU1Jlc291cmNlTmFt
-ZYASgBCAEVdOU0ltYWdlXxAPTlNNZW51Q2hlY2ttYXJr0gA6ADsAqwCsogCsAD9fEBBOU0N1c3RvbVJl
-c291cmNl0wAOADIApAClAKYAsIASgBCAFF8QEE5TTWVudU1peGVkU3RhdGXSADoAOwCzALSiALQAP1pO
-U01lbnVJdGVtV2RlbGV0ZTrSADoAOwC3ALijALgAuQA/XxAVTlNOaWJDb250cm9sQ29ubmVjdG9yXk5T
-TmliQ29ubmVjdG9y1AAOALsAhwCIAIkAvQC+AL9dTlNEZXN0aW5hdGlvboAXgCaAGYAo1wDBAA4AwgDD
-AMQAxQDGAMcAyADJAMoAywDMAMdfEA9OU05leHRSZXNwb25kZXJXTlNGcmFtZVZOU0NlbGxYTlN2Rmxh
-Z3NZTlNFbmFibGVkW05TU3VwZXJ2aWV3gBqAJYAbgBwRAQAJgBrVAMEADgDCAM8AxAArANEA0gDTAMta
-TlNTdWJ2aWV3c4AAgKWAu4CqXxAWe3sxOCwgMTUzfSwgezQwMiwgMTh9fd0A1gAOANcA2ADZANoA2wDc
-AN0A3gDfAOAA4QDiAOMAlwDlAOYA5wCXAOkA6gC+AOwA7QDuW05TQ2VsbEZsYWdzXxATTlNBbHRlcm5h
-dGVDb250ZW50c18QEk5TUGVyaW9kaWNJbnRlcnZhbF5OU0J1dHRvbkZsYWdzMl8QEE5TQWx0ZXJuYXRl
-SW1hZ2VfEA9OU0tleUVxdWl2YWxlbnRaTlNDb250ZW50c1lOU1N1cHBvcnRdTlNDb250cm9sVmlld18Q
-D05TUGVyaW9kaWNEZWxheVxOU0NlbGxGbGFnczJdTlNCdXR0b25GbGFncxIEAf4AgCSADhAZEAKAIYAO
-gB2AHoAZEMgQABJIPFH/XxAdRm9sbG93IHN5c3RlbSBrZXlib2FyZCBsYXlvdXTUAA4A8QDyAPMA9AD1
-APYA91ZOU1NpemVWTlNOYW1lWE5TZkZsYWdzgCAjQCoAAAAAAACAHxEEFFxMdWNpZGFHcmFuZGXSADoA
-OwD6APuiAPsAP1ZOU0ZvbnTSAA4A/QD+AP9bTlNJbWFnZU5hbWWAI4AiWE5TU3dpdGNo0gA6ADsBAgED
-ogEDAD9fEBNOU0J1dHRvbkltYWdlU291cmNl0gA6ADsBBQEGpAEGAQcAwwA/XE5TQnV0dG9uQ2VsbFxO
-U0FjdGlvbkNlbGzSADoAOwEJAQqlAQoBCwEMAQ0AP1hOU0J1dHRvbllOU0NvbnRyb2xWTlNWaWV3W05T
-UmVzcG9uZGVy0gAOADIAMwEQgAWAJ11YMTFDb250cm9sbGVyXnByZWZzX2NoYW5nZWQ60wAOAIcAiACJ
-ARUBFoAXgCqALdgADgCNAI4AjwCQAJEAkgCTAJQBGQCWARoAmACZAJoAm4AVgCuALIAPgBOADFpTZWxl
-Y3QgQWxsUWFac2VsZWN0QWxsOtQADgC7AIcAiAEiAL0AHwElgDCAJoACgC9YZGVsZWdhdGXSADoAOwEo
-ASmjASkAuQA/XxAUTlNOaWJPdXRsZXRDb25uZWN0b3LUAA4AuwCHAIgBIgEsAB8BLoAwgDKAAoBA1AAO
-AI0A8gCdAJ4BMQCXATOAP4AzgA6ANFRNZW510gAOAEUATQE3gD6iATgBOYA1gDbaAA4AjQCOATsAjwE8
-AJAAkQCSAJMAlACXAJYAzACXAMwAmACZAJoBLF1OU0lzU2VwYXJhdG9yXE5TSXNEaXNhYmxlZIAVgA4J
-gA4JgA+AE4Ay2gAOAUYAjQCOAI8AkACRAJIAkwFHAJQBSQFKAJYAlwCYAJkAmgEsAU9ZTlNTdWJtZW51
-WE5TQWN0aW9ugBWAOYA3gA6AD4ATgDKAOFxBcHBsaWNhdGlvbnNec3VibWVudUFjdGlvbjrTAA4AjQCd
-AJ4BSgFVgD+AN4A60gAOAEUATQFYgD6iAVkBWoA7gDzaAA4AjQCOATsAjwE8AJAAkQCSAJMAlACXAJYA
-zACXAMwAmACZAJoBSYAVgA4JgA4JgA+AE4A52AAOAI0AjgCPAJAAkQCSAJMAlAFmAJYAlwCYAJkAmgFJ
-gBWAPYAOgA+AE4A5agBDAHUAcwB0AG8AbQBpAHoAZSAm0gA6ADsBbQFuowFuAW8AP15OU011dGFibGVB
-cnJheVdOU0FycmF50gA6ADsBcQCTogCTAD9YZG9ja01lbnXUAA4AuwCHAIgAiQC9AXYAv4AXgCaAQoAo
-1wDBAA4AwgDDAMQAxQDGAXkAyAF7AXwAywDMAXmAQ4AlgESARQmAQ9YAwQAOAMIAzwDEAMYBgADRAYIB
-gwDLAYCAgoClgKSAhICCXxAVe3sxOCwgOTB9LCB7NDAyLCAxOH193QDWAA4A1wDYANkA2gDbANwA3QDe
-AN8A4ADhAOIA4wCXAOUA5gDnAJcBiwDqAXYA7ADtAO6AJIAOgCGADoBGgB6AQl8QF1VzZSBzeXN0ZW0g
-YWxlcnQgZWZmZWN01AAOALsAhwCIASIBkQC9AZOAMIBIgCaATdcAwQAOAMIAwwDEAMUAxgGVAMgBlwGY
-AMsAzAGVgEmAJYBKgEsJgEnVAMEADgDCAM8AxAArANEBngGfAMuAAIClgNOAwl8QFnt7MTgsIDE0MH0s
-IHs0MDIsIDE4fX3dANYADgDXANgA2QDaANsA3ADdAN4A3wDgAOEA4gDjAJcA5QDmAOcAlwGmAOoBkQDs
-AO0A7oAkgA6AIYAOgEyAHoBIXxAmQWxsb3cgY29ubmVjdGlvbnMgZnJvbSBuZXR3b3JrIGNsaWVudHNa
-ZW5hYmxlX3RjcNQADgC7AIcAiACJAL0BWgGvgBeAJoA8gE9fEBBhcHBzX3RhYmxlX3Nob3c61AAOALsA
-hwCIAIkAvQG0AL+AF4AmgFGAKNcAwQAOAMIAwwDEAMUAxgF5AbgBuQG6AMsAzAF5gEOAZ4BSgFMJgENf
-EBZ7ezc0LCAyMDl9LCB7MTI4LCAyNn193xATANYBvwHAANcA2AAOANkA2gDbAN0AtADeAcEBwgHDAN8A
-4ACTAOEBxADMAcYBxwHIAckBxgHKAcsA6gHNAbQBzwDMAMwB0gHTAdQB1V8QGk5TTWVudUl0ZW1SZXNw
-ZWN0QWxpZ25tZW50XxAPTlNBcnJvd1Bvc2l0aW9uXxAPTlNQcmVmZXJyZWRFZGdlXxASTlNVc2VzSXRl
-bUZyb21NZW51XU5TQWx0ZXJzU3RhdGUT/////4RB/kAJEAGAVRBLgGaAVIBWgB6AV4BREAMJCREBkBEE
-AIBYEgaCQP/UAA4A8QDyAPMA9AD1APYB2YAggB8QENIADgA2ADcAooAE0gAOADYANwCigATcAd8ADgCN
-AI4AjwCQAJEAkgCTAUcB4AHhAboAlAHkAJYAlwCYAJkAmgHUAekB6gHGWE5TVGFyZ2V0VU5TVGFnV05T
-U3RhdGWAU4AVgFmADoAPgBOAWIBaE///////////0wAOAI0AnQCeAe0B7oA/gFuAXFxGcm9tIERpc3Bs
-YXlfEBFfcG9wVXBJdGVtQWN0aW9uOtIADgA2ADcB84AEWk90aGVyVmlld3PSAA4ARQBNAfaAPqQBzQH4
-AfkB+oBXgF2AYIBj2wHfAA4AjQCOAI8AkACRAJIAkwFHAeABugCUAf4AlgCXAJgAmQCaAdQCAwIEgFOA
-FYBegA6AD4ATgFiAXxAIWjI1NiBDb2xvcnPbAd8ADgCNAI4AjwCQAJEAkgCTAUcB4AG6AJQCCQCWAJcA
-mACZAJoB1AIOAg+AU4AVgGGADoAPgBOAWIBiEA9ZVGhvdXNhbmRz2wHfAA4AjQCOAI8AkACRAJIAkwFH
-AeABugCUAhQAlgCXAJgAmQCaAdQCGQIagFOAFYBkgA6AD4ATgFiAZRAYWE1pbGxpb25z0gA6ADsCHQIe
-pgIeAh8BBgEHAMMAP18QEU5TUG9wVXBCdXR0b25DZWxsXk5TTWVudUl0ZW1DZWxs0gA6ADsCIQIipgIi
-AQoBCwEMAQ0AP11OU1BvcFVwQnV0dG9u1AAOALsAhwCIASICJQC9AieAMIBpgCaAa9oADgCNAI4BOwCP
-ATwAkACRAJIAkwCUAJcAlgDMAJcAzACYAJkAmgIwgBWADgmADgmAD4ATgGrUAA4AjQDyAJ0AngIzAjQC
-NYA/gQHMgQHQgQHNXxAQd2luZG93X3NlcGFyYXRvctQADgC7AIcAiAEiAjkAvQI7gDCAbYAmgG/aAA4A
-jQCOATsAjwE8AJAAkQCSAJMAlACXAJYAzACXAMwAmACZAJoCRIAVgA4JgA4JgA+AE4Bu0wAOAI0AnQCe
-AUoCSIA/gDeBAbheYXBwc19zZXBhcmF0b3LUAA4AuwCHAIgBIgJMAL0CToAwgHGAJoB11wDBAA4AwgDD
-AMQAxQDGAMcAyAJSAlMAywDMAMeAGoAlgHKAcwmAGl8QFnt7MTgsIDIxN30sIHs0MDIsIDE4fX3dANYA
-DgDXANgA2QDaANsA3ADdAN4A3wDgAOEA4gDjAJcA5QDmAOcAlwJcAOoCTADsAO0A7oAkgA6AIYAOgHSA
-HoBxXxAaRW11bGF0ZSB0aHJlZSBidXR0b24gbW91c2VcZmFrZV9idXR0b25z1AAOALsAhwCIASIBtAC9
-AmWAMIBRgCaAd1VkZXB0aNQADgC7AIcAiAEiAmkAvQJrgDCAeYAmgNzfEA8CbQAOAm4CbwJwAnECcgJz
-AnQCdQJ2AncCeAJ5AnoCewJ8An0CfgJ/AoACgQKCAoMChAKFAOYBzwKGAodcTlNXaW5kb3dWaWV3XxAW
-TlNXaW5kb3dDb250ZW50TWF4U2l6ZVxOU1NjcmVlblJlY3RfEBNOU0ZyYW1lQXV0b3NhdmVOYW1lXU5T
-V2luZG93VGl0bGVZTlNXVEZsYWdzXU5TV2luZG93Q2xhc3NfEBZOU1dpbmRvd0NvbnRlbnRNaW5TaXpl
-XE5TV2luZG93UmVjdFlOU01heFNpemVfEA9OU1dpbmRvd0JhY2tpbmdfEBFOU1dpbmRvd1N0eWxlTWFz
-a1lOU01pblNpemVbTlNWaWV3Q2xhc3OAgIDbgH6A14DagHsSUHgAAIB8gH+AeoDZgNiAfV8QGHt7MzE5
-LCAzMjN9LCB7NDc4LCAzMTZ9fV8QD1gxMSBQcmVmZXJlbmNlc1dOU1BhbmVs0gAOADYANwKNgARUVmll
-d18QGnszLjQwMjgyZSszOCwgMy40MDI4MmUrMzh9WnsyMTMsIDEwN33VAMEADgDPAMQCkQArANEClADL
-ApVbTlNGcmFtZVNpemWAAIClgIGA1tIADgBFAE0CmIA+oQGAgILcAMEADgKbApwAwgD7AM8AxAKdAMYC
-ngKfAnsCoQKiAO0CowDqAqUAywDMAnsAzAKpXk5TVGFiVmlld0l0ZW1zWU5TVHZGbGFnc18QEU5TRHJh
-d3NCYWNrZ3JvdW5kXxAWTlNBbGxvd1RydW5jYXRlZExhYmVsc18QFU5TU2VsZWN0ZWRUYWJWaWV3SXRl
-bYCAgNWAp4CmgB6AgwmAgAmAvtIADgBFAE0CrIA+oQF5gEPSAA4ARQBNArCAPqcBdgKyAbQCtAK1ArYC
-t4BCgIWAUYCUgJiAnICg1wDBAA4AwgDDAMQAxQDGAXkCugK7ArwAywDMAXmAQ4CTgIaAhwmAQ18QFXt7
-MzYsIDU2fSwgezM4NSwgMjh9fdgA1gAOAsEA3ADdAN4A4ALCAOICwwLEAsUCxgKyAsgCyV8QEU5TQmFj
-a2dyb3VuZENvbG9yW05TVGV4dENvbG9ygJKAioCIgImAhRIAQAAAgI9fEGdYMTEgYmVlcHMgd2lsbCB1
-c2UgdGhlIHN0YW5kYXJkIHN5c3RlbSBhbGVydCwgYXMgZGVmaW5lZCBpbiB0aGUgU291bmQgRWZmZWN0
-cyBzeXN0ZW0gcHJlZmVyZW5jZXMgcGFuZWwu1AAOAPEA8gDzAPQCzQD2As+AICNAJgAAAAAAAIAfEQwc
-1QAOAtEC0gLTAtQC1QLWAtcC2ALZV05TQ29sb3JcTlNDb2xvclNwYWNlW05TQ29sb3JOYW1lXU5TQ2F0
-YWxvZ05hbWWAjoCNEAaAjICLVlN5c3RlbVxjb250cm9sQ29sb3LTAA4C0gLdAtUBzwLfV05TV2hpdGWA
-jkswLjY2NjY2NjY5ANIAOgA7AuEC0aIC0QA/1QAOAtEC0gLTAtQC1QLkAtcC5QLZgI6AkYCQgItfEBBj
-b250cm9sVGV4dENvbG9y0wAOAtIC3QLVAc8C6oCOQjAA0gA6ADsC7ALtpALtAQcAwwA/XxAPTlNUZXh0
-RmllbGRDZWxs0gA6ADsC7wLwpQLwAQsBDAENAD9bTlNUZXh0RmllbGTXAMEADgDCAMMAxADFAMYBeQK6
-AvQC9QDLAMwBeYBDgJOAlYCWCYBDXxAVe3sxNywgMjEyfSwgezU1LCAyMH192ADWAA4CwQDcAN0A3gDg
-AsIA4gLDAsQC/ADqArQCyALJgJKAioCXgB6AlICPWENvbG9yczoK1wDBAA4AwgDDAMQAxQDGAXkCugME
-AwUAywDMAXmAQ4CTgJmAmgmAQ18QFnt7MzYsIDE5MH0sIHszOTIsIDE0fX3YANYADgLBANwA3QDeAOAC
-wgDiAsMCxAMMAsYCtQLIAsmAkoCKgJuAiYCYgI9fEDRUaGlzIG9wdGlvbiB0YWtlcyBlZmZlY3Qgd2hl
-biBYMTEgaXMgbGF1bmNoZWQgYWdhaW4u1wDBAA4AwgDDAMQAxQDGAXkAyAMUAxUAywDMAXmAQ4AlgJ2A
-ngmAQ18QFnt7MTgsIDE1Nn0sIHs0MDksIDIzfX3dANYADgDXANgA2QDaANsA3ADdAN4A3wDgAOEA4gDj
-AJcA5QDmAOcAlwMeAOoCtgDsAO0A7oAkgA6AIYAOgJ+AHoCcXxAQRnVsbCBzY3JlZW4gbW9kZdcAwQAO
-AMIAwwDEAMUAxgF5AroDJQMmAMsAzAF5gEOAk4ChgKIJgENfEBZ7ezM2LCAxMTl9LCB7Mzg1LCAzMX19
-2ADWAA4CwQDcAN0A3gDgAsIA4gLDAsQDLQLGArcCyALJgJKAioCjgImAoICPXxBkRW5hYmxlcyB0aGUg
-WDExIHJvb3Qgd2luZG93LiBVc2UgdGhlIENvbW1hbmQtT3B0aW9uLUEga2V5c3Ryb2tlIHRvIGVudGVy
-IGFuZCBsZWF2ZSBmdWxsIHNjcmVlbiBtb2RlLl8QFnt7MTAsIDMzfSwgezQzOCwgMjUzfX3SADoAOwM0
-AQyjAQwBDQA/XxAVe3sxMCwgN30sIHs0NTgsIDI5OX190gAOAEUATQM4gD6jAzkCqQM7gKiAvoDB1gAO
-Az0BDAM+AtEAiAM/A0AAxwGAAsQDRFxOU0lkZW50aWZpZXJZTlNUYWJWaWV3gL2AqYAagIKAioC80gAO
-ADYANwNHgARRMdIADgBFAE0DSoA+pgJMA0wDTQNOA08AvoBxgKuAr4CzgLeAGdcAwQAOAMIAwwDEAMUA
-xgDHAroDVANVAMsAzADHgBqAk4CsgK0JgBpfEBV7ezM2LCA2N30sIHszODUsIDMxfX3YANYADgLBANwA
-3QDeAOACwgDiAsMCxANcAsYDTALIAsmAkoCKgK6AiYCrgI9fEGZXaGVuIGVuYWJsZWQsIG1lbnUgYmFy
+AYag0QAHAAhdSUIub2JqZWN0ZGF0YYABXxAPTlNLZXllZEFyY2hpdmVyrxEDQgALAAwAMQA1ADkAQABD
+AEQASABMAIkAkQCZAJoAnwCyALMAuAC5ALoAvQDBAMIAxQDQANEA0gDWANsA5ADrAOwA8ADyAPMA9wD8
+AQoBEgETAS0BLgE1ATYBOQE9AT4BQAFCAUYBTAFPAVABUQFUAVkBYAFlAWYBZwFsAXMBeAF5AXoBewGA
+AYcBjQGOAZkBmgGeAZ8BogGjAagBrwGwAbgBuQG6Ab8BwAHFAcwB0QHSAekB7AHuAfAB/QIBAgICAwIG
+Ag0CFwICAhgCIgICAiMCLQICAi4CMgI1AjYCOwJDAkQCRQJKAlMCVwJYAl0CZAJlAm0CbgJzAnsCfAJ9
+An4CgwKIAo8ClAKVAp0CngKjAqoCqwKzArQCuQLBAsICwwLEAskC0QLSAtMC1ALZAtoC3wLgAuQC6wLv
+AvAC8QL1AvwC/QL+Av8DBAMJAwoDEgMbANEDHAMrAzIDMwM0Az0DRgDRA0cDTANOA1EDUgNbA2QDawNs
+A20DdAN1A34DhQOGA4cDiADRA5EDlgOdA54DpwDRA6gDswO6A7sDvAPDA8QDxQPOA9UD1gPXA94D3wPg
+A+cD6APxANED8gP0BAAEBwQIBAkEEAQRBBoEIwQqBCsENAQ1BD4A0QQ/BEMERwROBE8EUARRBFYEWwRi
+BGMEawRsBG0EcgRzBHgEfwSABIgEiQSLBI0EjgSSBJMEmASZBJ4EnwSkBMAEwQTCBMMExgTHBMgEzQTR
+BOEE5QTwBPcE+AUCBQMFCAUSBRMFFAUYBRoFHwUgBSMFJgUpBTAFMQU4BTkFQAVBBUgFSQVQBVEFWAVZ
+BVoFXAVdBWMFbAVvBXAFcwV6BX0FhwWOBY8FlwWYBZ8FoAWnBagFrwWwBbcFuAW/BcAFxwXIBc8F0AXX
+BVkF2AXZBd8F5wKqBe4F9gX3Bf4F/wYGBgcGDgYPBhYGFwYeBh8GJgVZBicGKAYqBisGLATGBi0GLgYx
+BjIGNwY4Bj0GPgZDBkQGSQZKBk8GVwZYBmEGYgZkBmYGZwZsBnEGcgZ2BncGfAaDBoQGjAaNBo8GkQaS
+BpcGmAadBrgGxwbIBs8G2AbZBtwG4Qb2BvcG+gcABxIHGQcaBx0HIgcjByYHLgcvBzIHNQc+B0QHRQdM
+B1UHWwdcB2EHYgdqB24Hcwd0B3kHegd9B38HgAeFB4YHiweMB5EHkgeXB5sHnAehB6IHpwesB60HsQey
+B7cHuAe9B74HwwfEB8kHygfPB9AH1AfVB9oH2wfgB+cH6AfwB/EH8wf0CHgIgAiECIUIiAiRCJIIkwiW
+CJ4InwijCKQIpQioCLYItwi4BMYExwi6CMMGKwYsBMYIxAjFADgIyAjKCU4J0wpYClkKWgpbClwKXQpe
+Cl8KYAphCmIKYwpkCmUKZgpnCmgKaQpqCmsKbAptCm4KbwpwCnEKcgpzCnQKdQp2CncKeAp5CnoKewp8
+Cn0Kfgp/CoAKgQqCCoMKhAqFCoYKhwqICokKigqLBMUKjAqNCo4KjwqQCpEKkgqTCpQKlQqWCpcKmAqZ
+CpoKmwqcCp0KngqfCqAKoQqiCqMKpAqlCqYKpwqoCqkKqgqrCqwKrQquCq8KsAqxCrIKswq0CrUKtgq3
+CrgKuQq6CrsKvAq9Cr4KvwrACsEKwgrDCsQKxQrGCscKyArJCsoKywrMCs0KzgrPCtAK0QrSCtMK1ArV
+CtYK1wraCt0LnAxbDFwMXQxeDF8MYAxhDGIMYwxkDGUMZgxnDGgMaQxqDGsMbAxtDG4MbwxwDHEMcgxz
+DHQMdQx2DHcMeAx5DHoMewx8DH0Mfgx/DIAMgQyCDIMMhAyFDIYMhwyIDIkMigyLDIwMjQyODI8MkAyR
+DJIMkwyUDJUMlgyXDJgMmQyaDJsMnAydDJ4MnwygDKEMogyjDKQMpQymDKcMqAypDKoMqwysDK0Mrgyv
+DLAMsQyyDLMMtAy1DLYMtwy4DLkMugy7DLwMvQy+DL8MwAzBDMIMwwzEDMUMxgzHDMgMyQzKDMsMzAzN
+AiwMzgzPDNAM0QzSDNMM1AzVDNYM1wzYDNkM2gzbDNwM3QzeDN8M4AzhDOIM4wzkDOUM5gznDOgM6Qzq
+DOsM7AztDO4M7wzwDPEM8gzzDPQM9Qz2DPcM+Az5DPoBBwz7DPwM/Qz+DP8NAA0BDQINAw0EDQUGVA0G
+DQcNCA0JDQoNCw0MDQ0NDg0PDRANEQ0SDRMNFA0XDRoNHVUkbnVsbN8QEgANAA4ADwAQABEAEgATABQA
+FQAWABcAGAAZABoAGwAcAB0AHgAfACAAIQAiACMAJAAlACYAJwAoACkAKgArACwALQAuAC8AMFZOU1Jv
+b3RWJGNsYXNzXU5TT2JqZWN0c0tleXNfEA9OU0NsYXNzZXNWYWx1ZXNfEBlOU0FjY2Vzc2liaWxpdHlP
+aWRzVmFsdWVzXU5TQ29ubmVjdGlvbnNbTlNOYW1lc0tleXNbTlNGcmFtZXdvcmtdTlNDbGFzc2VzS2V5
+c1pOU09pZHNLZXlzXU5TTmFtZXNWYWx1ZXNfEBlOU0FjY2Vzc2liaWxpdHlDb25uZWN0b3JzXU5TRm9u
+dE1hbmFnZXJfEBBOU1Zpc2libGVXaW5kb3dzXxAPTlNPYmplY3RzVmFsdWVzXxAXTlNBY2Nlc3NpYmls
+aXR5T2lkc0tleXNZTlNOZXh0T2lkXE5TT2lkc1ZhbHVlc4ACgQNBgQHdgQJ/gQNAgAmBAfyABoECfoEC
+gIEB/YEDPoAAgAeBAfuBAz8SAASVMIECgdIADgAyADMANFtOU0NsYXNzTmFtZYAFgAPSAA4ANgA3ADhZ
+TlMuc3RyaW5ngARdTlNBcHBsaWNhdGlvbtIAOgA7ADwAPVgkY2xhc3Nlc1okY2xhc3NuYW1lowA9AD4A
+P18QD05TTXV0YWJsZVN0cmluZ1hOU1N0cmluZ1hOU09iamVjdNIAOgA7AEEAQqIAQgA/Xk5TQ3VzdG9t
+T2JqZWN0XxAQSUJDb2NvYUZyYW1ld29ya9IADgBFAEYAR1pOUy5vYmplY3RzgAig0gA6ADsASQBKowBK
+AEsAP1xOU011dGFibGVTZXRVTlNTZXTSAA4ARQBNAE6AH68QOgBPAFAAUQBSAFMAVABVAFYAVwBYAFkA
+WgBbAFwAXQBeAF8AYABhAGIAYwBkAGUAZgBnAGgAaQBqAGsAbABtAG4AbwBwAHEAcgBzAHQAdQB2AHcA
+eAB5AHoAewB8AH0AfgB/AIAAgQCCAIMAhACFAIYAhwCIgAqAI4A2gDuAQYBLgFGAU4BtgHGAdYB6gH+A
+gICGgIuAkICVgJeAmYCegKOA84D0gPqA/IEBBIEBBoEBCIEBCoEBb4EBcYEBc4EBdYEBd4EBf4EBgIEB
+goEBhIEBjIEBjoEBuIEBuoEBvIEBvoEBv4EBwYEBw4EBxIEBxoEByIEByoEBzIEBzoEB0IEB0oEB1IEB
+1tQADgCKAIsAjACNAI4AHwCQXU5TRGVzdGluYXRpb25YTlNTb3VyY2VXTlNMYWJlbIAigAuAAoAh1AAO
+AJIAkwCUAJUAlgCXAJhXTlNUaXRsZVZOU05hbWVbTlNNZW51SXRlbXOAIIAMgA+ADVRNZW510gAOAEUA
+TQCcgB+iAJ0AnoAOgBfaAA4AkgCgAKEAogCjAKQApQCmAKcAqACXAKoAqwCXAKsArgCvALAAjl8QEU5T
+S2V5RXF1aXZNb2RNYXNrXU5TSXNTZXBhcmF0b3JaTlNLZXlFcXVpdlxOU0lzRGlzYWJsZWRdTlNNbmVt
+b25pY0xvY1lOU09uSW1hZ2VcTlNNaXhlZEltYWdlVk5TTWVudYAWgA8SABAAAAmADwkSf////4AQgBSA
+C1DTAA4AMgC0ALUAtgC3Xk5TUmVzb3VyY2VOYW1lgBOAEYASV05TSW1hZ2VfEA9OU01lbnVDaGVja21h
+cmvSADoAOwC7ALyiALwAP18QEE5TQ3VzdG9tUmVzb3VyY2XTAA4AMgC0ALUAtgDAgBOAEYAVXxAQTlNN
+ZW51TWl4ZWRTdGF0ZdIAOgA7AMMAxKIAxAA/Wk5TTWVudUl0ZW3aAA4AxgCSAKAAogCkAKUApgCnAMcA
+qADJAMoAqgCXAK4ArwCwAI4Az1lOU1N1Ym1lbnVYTlNBY3Rpb26AFoAagBiAD4AQgBSAC4AZXEFwcGxp
+Y2F0aW9uc15zdWJtZW51QWN0aW9uOtMADgCSAJQAlQDKANWAIIAYgBvSAA4ARQBNANiAH6IA2QDagByA
+HdoADgCSAKAAoQCiAKMApAClAKYApwCoAJcAqgCrAJcAqwCuAK8AsADJgBaADwmADwmAEIAUgBrYAA4A
+kgCgAKIApAClAKYApwCoAOYAqgCXAK4ArwCwAMmAFoAegA+AEIAUgBpqAEMAdQBzAHQAbwBtAGkAegBl
+ICbSADoAOwDtAO6jAO4A7wA/Xk5TTXV0YWJsZUFycmF5V05TQXJyYXnSADoAOwDxAKeiAKcAP1hkb2Nr
+TWVuddIAOgA7APQA9aMA9QD2AD9fEBROU05pYk91dGxldENvbm5lY3Rvcl5OU05pYkNvbm5lY3RvctQA
+DgCKAIsAjAD4APkA+gD7gDWAMoAkgDTXAP0ADgD+AP8BAAEBAQIBAwEEAQUBBgEHAKsBA18QD05TTmV4
+dFJlc3BvbmRlcldOU0ZyYW1lVk5TQ2VsbFhOU3ZGbGFnc1lOU0VuYWJsZWRbTlNTdXBlcnZpZXeAJYAx
+gCaAJxEBLQmAJdUA/QAOAQsBAAEMACsBDgEPARABEVpOU1N1YnZpZXdzW05TRnJhbWVTaXplgACBATOB
+AfIRAQCBAfNfEBd7ezM3MiwgMjc5fSwgezEwMCwgMzJ9fd0BFAAOARUBFgEXARgBGQEaARsBHAEdAR4B
+HwEgASEBIgEjASQBJQEmAScBKAD6ASoBKwEsW05TQ2VsbEZsYWdzXxATTlNBbHRlcm5hdGVDb250ZW50
+c18QEk5TUGVyaW9kaWNJbnRlcnZhbF5OU0J1dHRvbkZsYWdzMl8QEE5TQWx0ZXJuYXRlSW1hZ2VfEA9O
+U0tleUVxdWl2YWxlbnRaTlNDb250ZW50c1lOU1N1cHBvcnRdTlNDb250cm9sVmlld18QD05TUGVyaW9k
+aWNEZWxheVxOU0NlbGxGbGFnczJdTlNCdXR0b25GbGFncxIEAf4AgDCALhAZEAGALIAvgCiAKYAkEMgS
+CDgAABP/////hoJA/1hBZGQgSXRlbdQADgEvAJMBMAExATIBMwE0Vk5TU2l6ZVhOU2ZGbGFnc4ArI0Aq
+AAAAAAAAgCoRBBRcTHVjaWRhR3JhbmRl0gA6ADsBNwE4ogE4AD9WTlNGb2501AAOAS8AkwEwATEBMgE7
+ATyAK4AtEBBZSGVsdmV0aWNh0gAOADYANwCygATSAA4ANgA3ALKABNIAOgA7AUMBRKQBRAFFAP8AP1xO
+U0J1dHRvbkNlbGxcTlNBY3Rpb25DZWxs0gA6ADsBRwFIpQFIAUkBSgFLAD9YTlNCdXR0b25ZTlNDb250
+cm9sVk5TVmlld1tOU1Jlc3BvbmRlctIADgAyADMBToAFgDNdWDExQ29udHJvbGxlcl8QD2FwcHNfdGFi
+bGVfbmV3OtIAOgA7AVIBU6MBUwD2AD9fEBVOU05pYkNvbnRyb2xDb25uZWN0b3LUAA4AigCLAIwA+AAf
+AVcBWIA1gAKAN4A61wAOAJIAogCkAKUApgCnAKgBWwCXAK4ArwCwAV+AFoA5gA+AEIAUgDjUAA4AkgCT
+AJQAlQFiAWMBZIAggKiAwYCqWUFib3V0IFgxMV8QHW9yZGVyRnJvbnRTdGFuZGFyZEFib3V0UGFuZWw6
+1AAOAIoAiwCMAPgA+QFqAWuANYAygDyAQNgADgCSAKAAogCkAKUApgCnAKgBbgCqAW8ArgCvALABcoAW
+gD6AP4AQgBSAPdQADgCSAJMAlACVAXUBdgF3gCCA3YDpgN5VQ2xvc2VRd11jbG9zZV93aW5kb3c61AAO
+AIoAiwCMAI0BfQD5AX+AIoBCgDKAStcA/QAOAP4A/wEAAQEBAgGBAQQBgwGEARAAqwGBgEOAMYBEgEUJ
+gEPWAP0ADgD+AQsBAAECAYgBDgGKAYsBEAGIgQEUgQEzgQEygQEWgQEUXxAWe3sxOCwgMTMwfSwgezQw
+MiwgMTh9fd0BFAAOARUBFgEXARgBGQEaARsBHAEdAR4BHwEgASEAlwEjAZEBkgCXAZQBKAF9ASoBlwGY
+gDCADxACgEeAD4BGgCmAQhAAEkg8Uf9fECBFbmFibGUga2V5IGVxdWl2YWxlbnRzIHVuZGVyIFgxMdIA
+DgGbAZwBnVtOU0ltYWdlTmFtZYBJgEhYTlNTd2l0Y2jSADoAOwGgAaGiAaEAP18QE05TQnV0dG9uSW1h
+Z2VTb3VyY2VfEBBlbmFibGVfa2V5ZXF1aXZz1AAOAIoAiwCMAPgA+QGmAaeANYAygEyAUNcA/QAOAP4A
+/wEAAQEBAgGBAQQBqwGsARAAqwGBgEOAMYBNgE4JgENfEBZ7ezE4LCAxNzl9LCB7NDAyLCAxOH193QEU
+AA4BFQEWARcBGAEZARoBGwEcAR0BHgEfASABIQCXASMBkQGSAJcBtQEoAaYBKgGXAZiAMIAPgEeAD4BP
+gCmATF8QHUZvbGxvdyBzeXN0ZW0ga2V5Ym9hcmQgbGF5b3V0XnByZWZzX2NoYW5nZWQ61AAOAIoAiwCM
+AI0AjgD5Ab6AIoALgDKAUllkb2NrX21lbnXUAA4AigCLAIwAjQHCAPkBxIAigFSAMoBs1wD9AA4A/gD/
+AQABAQECAcYBxwHIAckBEACrAcaAVYBrgFaAVwmAVdUA/QAOAP4BCwEAACsBDgHPAdABEIAAgQEzgQFR
+gQE8XxAWe3s3NCwgMjM1fSwgezEyOCwgMjZ9fd8QEwEUAdMB1AEVARYADgEXARgBGQEbAMQBHAHVAdYB
+1wEdAR4ApwEfAdgAqwEkAdoB2wHcASQB3QHeASgB4AHCAeIAqwCrAeUB5gHnAehfEBpOU01lbnVJdGVt
+UmVzcGVjdEFsaWdubWVudF8QD05TQXJyb3dQb3NpdGlvbl8QD05TUHJlZmVycmVkRWRnZV8QEk5TVXNl
+c0l0ZW1Gcm9tTWVudV1OU0FsdGVyc1N0YXRlE/////+EQf5ACYBZEEuAaoBYgFqAKYBbgFQQAwkJEQGQ
+EQQAgFwSBoJA/9QADgEvAJMBMAExATIBMwE8gCuAKtIADgA2ADcAsoAE0gAOADYANwCygATcAfEADgCS
+AKAAogCkAKUApgCnAMcB8gHzAckAqAH2AKoAlwCuAK8AsAHnAfsB/AEkWE5TVGFyZ2V0VU5TVGFnV05T
+U3RhdGWAV4AWgF2AD4AQgBSAXIBeE///////////0wAOAJIAlACVAf8CAIAggF+AYFxGcm9tIERpc3Bs
+YXlfEBFfcG9wVXBJdGVtQWN0aW9uOtIADgA2ADcCBYAEWk90aGVyVmlld3PSAA4ARQBNAgiAH6QB4AIK
+AgsCDIBbgGGAZIBn2wHxAA4AkgCgAKIApAClAKYApwDHAfIByQCoAhAAqgCXAK4ArwCwAecCFQIWgFeA
+FoBigA+AEIAUgFyAYxAIWjI1NiBDb2xvcnPbAfEADgCSAKAAogCkAKUApgCnAMcB8gHJAKgCGwCqAJcA
+rgCvALAB5wIgAiGAV4AWgGWAD4AQgBSAXIBmEA9ZVGhvdXNhbmRz2wHxAA4AkgCgAKIApAClAKYApwDH
+AfIByQCoAiYAqgCXAK4ArwCwAecCKwIsgFeAFoBogA+AEIAUgFyAaRAYWE1pbGxpb25z0gA6ADsCLwIw
+pgIwAjEBRAFFAP8AP18QEU5TUG9wVXBCdXR0b25DZWxsXk5TTWVudUl0ZW1DZWxs0gA6ADsCMwI0pgI0
+AUgBSQFKAUsAP11OU1BvcFVwQnV0dG9uVWRlcHRo1AAOAIoAiwCMAPgAHwI5AjqANYACgG6AcNkADgCS
+AKAAogCkAKUApgCnAfIAqAI9AKoAlwCuAK8AsAFfAkKAFoBvgA+AEIAUgDgQKlhTaG93IEFsbF8QFnVu
+aGlkZUFsbEFwcGxpY2F0aW9uczrUAA4AigCLAIwAjQJHAPkCSYAigHKAMoB02gAOAJIAoAChAKIAowCk
+AKUApgCnAKgAlwCqAKsAlwCrAK4ArwCwAlKAFoAPCYAPCYAQgBSAc9MADgCSAJQAlQDKAlaAIIAYgMRe
+YXBwc19zZXBhcmF0b3LUAA4AigCLAIwA+AD5AlsBp4A1gDKAdoBQ1wD9AA4A/gD/AQABAQECAYEBBAJg
+AmEBEACrAYGAQ4AxgHeAeAmAQ18QFXt7MTgsIDY5fSwgezQwMiwgMTh9fd0BFAAOARUBFgEXARgBGQEa
+ARsBHAEdAR4BHwEgASEAlwEjAZEBkgCXAmoBKAJbASoBlwGYgDCAD4BHgA+AeYApgHZfEB5DbGljay10
+aHJvdWdoIEluYWN0aXZlIFdpbmRvd3PUAA4AigCLAIwA+AD5AnECcoA1gDKAe4B+2AAOAJIAoACiAKQA
+pQCmAKcAqAJ1AnYCdwCuAK8AsAFygBaAfBIAEAEIgH2AEIAUgD1fEBVDeWNsZSBUaHJvdWdoIFdpbmRv
+d3NRYFxuZXh0X3dpbmRvdzrUAA4AigCLAIwA+AD5AcIBp4A1gDKAVIBQ1AAOAIoAiwCMAPgA+QKGAaeA
+NYAygIGAUNcA/QAOAP4A/wEAAQEBAgKJAQQCiwKMARAAqwKJgIKAMYCDgIQJgILVAP0ADgD+AQsBAAAr
+AQ4CkgKTARCAAIEBM4EBZYEBVF8QFnt7MTgsIDE2Nn0sIHs0MDIsIDE4fX3dARQADgEVARYBFwEYARkB
+GgEbARwBHQEeAR8BIAEhAJcBIwGRAZIAlwKaASgChgEqAZcBmIAwgA+AR4APgIWAKYCBXxAmQWxsb3cg
+Y29ubmVjdGlvbnMgZnJvbSBuZXR3b3JrIGNsaWVudHPUAA4AigCLAIwA+AD5AqEBp4A1gDKAh4BQ1wD9
+AA4A/gD/AQABAQECAYEBBAKmAqcBEACrAYGAQ4AxgIiAiQmAQ18QFnt7MTgsIDI0M30sIHs0MDIsIDE4
+fX3dARQADgEVARYBFwEYARkBGgEbARwBHQEeAR8BIAEhAJcBIwGRAZIAlwKwASgCoQEqAZcBmIAwgA+A
+R4APgIqAKYCHXxAaRW11bGF0ZSB0aHJlZSBidXR0b24gbW91c2XUAA4AigCLAIwAjQK2APkCuIAigIyA
+MoCP2AAOAJIAoACiAKQApQCmAKcAqAK7ArwCvQCuAK8AsAFfgBaAjRIAGAAAgI6AEIAUgDhfEBJUb2dn
+bGUgRnVsbCBTY3JlZW5RYV8QFnRvZ2dsZV9mdWxsc2NyZWVuX2l0ZW3UAA4AigCLAIwA+AD5AscCyIA1
+gDKAkYCU2AAOAJIAoACiAKQApQCmAKcAqALLAswCzQCuAK8AsAFygBaAkhIAEgEKgJOAEIAUgD1fEB1S
+ZXZlcnNlIEN5Y2xlIFRocm91Z2ggV2luZG93c1F+XxAQcHJldmlvdXNfd2luZG93OtQADgCKAIsAjACN
+AVcA+QLYgCKAN4AygJZeeDExX2Fib3V0X2l0ZW3UAA4AigCLAIwAjQDJAPkC3oAigBqAMoCYXmRvY2tf
+YXBwc19tZW510wAOAIsAjAD4AuIC44A1gJqAndgADgCSAKAAogCkAKUApgCnAKgC5gCqAr0ArgCvALAC
+6oAWgJyAjoAQgBSAm9MADgCSAJQAlQLtAu6AIIDIgMpaU2VsZWN0IEFsbFpzZWxlY3RBbGw60wAOAIsA
+jAD4AvMC9IA1gJ+AotgADgCSAKAAogCkAKUApgCnAKgC9wCqAvgArgCvALAC6oAWgKCAoYAQgBSAm1RD
+b3B5UWNVY29weTrUAA4AigCLAIwAjQMBAB8DA4AigKSAAoDy1AAOAJIAkwCUAJUDBgMHAwiAIIClgPGA
+plhNYWluTWVuddIADgBFAE0DDIAfpQMNAw4DDwMQAxGAp4DCgMeA2oDq2gAOAMYAkgCgAKIApAClAKYA
+pwDHAKgBXwFiAKoAlwCuAK8AsAMBAxqAFoA4gKiAD4AQgBSApICpU1gxMdIADgBFAE0DHoAfrAFXAyAD
+IQMiAyMCtgMlAyYDJwI5AykDKoA3gKuAroCvgLaAjIC3gLiAu4BugL2AvtgADgCSAKAAogCkAKUApgCn
+AKgDLQCqAy4ArgCvALABX4AWgKyArYAQgBSAOF5QcmVmZXJlbmNlcy4uLlEs2gAOAJIAoAChAKIAowCk
+AKUApgCnAKgAlwCqAKsAlwCrAK4ArwCwAV+AFoAPCYAPCYAQgBSAONoADgDGAJIAoACiAKQApQCmAKcA
+xwCoAz8DQACqAJcArgCvALABXwNFgBaAsoCwgA+AEIAUgDiAsVhTZXJ2aWNlc9QADgCSAJMAlACVA0kD
+SgNLgCCAs4C1gLTSAA4ANgA3A0aABNIADgBFAE0DUIAfoF8QD19OU1NlcnZpY2VzTWVuddoADgCSAKAA
+oQCiAKMApAClAKYApwCoAJcAqgCrAJcAqwCuAK8AsAFfgBaADwmADwmAEIAUgDjaAA4AkgCgAKEAogCj
+AKQApQCmAKcAqACXAKoAqwCXAKsArgCvALABX4AWgA8JgA8JgBCAFIA42QAOAJIAoACiAKQApQCmAKcB
+8gCoA2YAqgNnAK4ArwCwAV8CQoAWgLmAuoAQgBSAOFhIaWRlIFgxMVFo2AAOAJIAoACiAKQApQCmAKcA
+qANvAKoAlwCuAK8AsAFfgBaAvIAPgBCAFIA4W0hpZGUgT3RoZXJz2gAOAJIAoAChAKIAowCkAKUApgCn
+AKgAlwCqAKsAlwCrAK4ArwCwAV+AFoAPCYAPCYAQgBSAONgADgCSAKAAogCkAKUApgCnAKgDgACqA4EA
+rgCvALABX4AWgL+AwIAQgBSAOFhRdWl0IFgxMVFxXF9OU0FwcGxlTWVuddoADgDGAJIAoACiAKQApQCm
+AKcAxwCoAlIAygCqAJcArgCvALADAQOQgBaAc4AYgA+AEIAUgKSAw9IADgBFAE0Dk4AfogJHA5WAcoDF
+2AAOAJIAoACiAKQApQCmAKcAqAOYAKoAlwCuAK8AsAJSgBaAxoAPgBCAFIBzXEN1c3RvbWl6ZS4uLtoA
+DgDGAJIAoACiAKQApQCmAKcAxwCoAuoC7QCqAJcArgCvALADAQOmgBaAm4DIgA+AEIAUgKSAyVRFZGl0
+0gAOAEUATQOqgB+oA6sDrAOtA64C8wOwA7EC4oDLgM6A0YDSgJ+A1YDYgJrYAA4AkgCgAKIApAClAKYA
+pwCoA7UAqgO2AK4ArwCwAuqAFoDMgM2AEIAUgJtUVW5kb1F62AAOAJIAoACiAKQApQCmAKcAqAO+AKoD
+vwCuAK8AsALqgBaAz4DQgBCAFICbVFJlZG9RWtoADgCSAKAAoQCiAKMApAClAKYApwCoAJcAqgCrAJcA
+qwCuAK8AsALqgBaADwmADwmAEIAUgJvYAA4AkgCgAKIApAClAKYApwCoA9AAqgPRAK4ArwCwAuqAFoDT
+gNSAEIAUgJtTQ3V0UXjYAA4AkgCgAKIApAClAKYApwCoA9kAqgPaAK4ArwCwAuqAFoDWgNeAEIAUgJtV
+UGFzdGVRdtgADgCSAKAAogCkAKUApgCnAKgD4gCqAJcArgCvALAC6oAWgNmAD4AQgBSAm1ZEZWxldGXa
+AA4AxgCSAKAAogCkAKUApgCnAMcAqAFyA+sAqgCXAK4ArwCwAwED8IAWgD2A24APgBCAFICkgNxWV2lu
+ZG930gAOADYANwPxgATSAA4ARQBNA/aAH6kD9wP4AnECxwP7AWoD/QP+A/+A34DigHuAkYDkgDyA5YDm
+gOjYAA4AkgCgAKIApAClAKYApwCoBAIAqgQDAK4ArwCwAXKAFoDggOGAEIAUgD1YTWluaW1pemVRbdgA
+DgCSAKAAogCkAKUApgCnAKgECwCqAJcArgCvALABcoAWgOOAD4AQgBSAPVRab29t2gAOAJIAoAChAKIA
+owCkAKUApgCnAKgAlwCqAKsAlwCrAK4ArwCwAXKAFoAPCYAPCYAQgBSAPdoADgCSAKAAoQCiAKMApACl
+AKYApwCoAJcAqgCrAJcAqwCuAK8AsAFygBaADwmADwmAEIAUgD3YAA4AkgCgAKIApAClAKYApwCoBCUA
+qgCXAK4ArwCwAXKAFoDngA+AEIAUgD1fEBJCcmluZyBBbGwgdG8gRnJvbnTaAA4AkgCgAKEAogCjAKQA
+pQCmAKcAqACXAKoAqwCXAKsArgCvALABcoAWgA8JgA8JgBCAFIA9Xl9OU1dpbmRvd3NNZW512gAOAMYA
+kgCgAKIApAClAKYApwDHAKgENwQ4AKoAlwCuAK8AsAMBBD2AFoDtgOuAD4AQgBSApIDsVEhlbHDTAA4A
+kgCUAJUEOARCgCCA64Du0gAOAEUATQRFgB+hBEaA79gADgCSAKAAogCkAKUApgCnAKgESQCqAJcArgCv
+ALAEN4AWgPCAD4AQgBSA7VhYMTEgSGVscFtfTlNNYWluTWVudVRtZW511AAOAIoAiwCMAPgA+QF9AaeA
+NYAygEKAUNQADgCKAIsAjACNBFgA+QRagCKA9YAygPnXAP0ADgD+AP8BAAEBAQIBxgEEBF4EXwEQAKsB
+xoBVgDGA9oD3CYBVXxAWe3sxOCwgMTgyfSwgezQwOSwgMjN9fd0BFAAOARUBFgEXARgBGQEaARsBHAEd
+AR4BHwEgASEAlwEjAZEBkgCXBGgBKARYASoBlwGYgDCAD4BHgA+A+IApgPVfEBBGdWxsIHNjcmVlbiBt
+b2RlXxARZW5hYmxlX2Z1bGxzY3JlZW7UAA4AigCLAIwA+AD5BFgEcYA1gDKA9YD7XxAaZW5hYmxlX2Z1
+bGxzY3JlZW5fY2hhbmdlZDrUAA4AigCLAIwA+AD5BHYEd4A1gDKA/YEBA9cA/QAOAP4A/wEAAQEBAgED
+AQQEewR8AQcAqwEDgCWAMYD+gP8JgCVfEBd7ezM3MiwgMjE1fSwgezEwMCwgMzJ9fd0BFAAOARUBFgEX
+ARgBGQEaARsBHAEdAR4BHwEgASEEggEjASQBJQSEBIUBKAR2ASoBKwEsgDCBAQGALIEBAoEBAIApgP1W
+UmVtb3Zl0gAOADYANwCygATSAA4ANgA3ALKABF8QEmFwcHNfdGFibGVfZGVsZXRlOtMADgCLAIwA+AOr
+BJGANYDLgQEFVXVuZG861AAOAIoAiwCMAPgA+QMgBJeANYAygKuBAQdbcHJlZnNfc2hvdzrUAA4AigCL
+AIwA+AD5ArYEnYA1gDKAjIEBCV8QEnRvZ2dsZV9mdWxsc2NyZWVuOtQADgCKAIsAjACNBKEA+QSjgCKB
+AQuAMoEBbt8QDwSlAA4EpgSnBKgEqQSqBKsErAStBK4ErwSwBLEEsgSzBLQEtQS2BLcEuAS5BLoEuwS8
+BL0BkQHiBL4Ev1xOU1dpbmRvd1ZpZXdfEBZOU1dpbmRvd0NvbnRlbnRNYXhTaXplXE5TU2NyZWVuUmVj
+dF8QE05TRnJhbWVBdXRvc2F2ZU5hbWVdTlNXaW5kb3dUaXRsZVlOU1dURmxhZ3NdTlNXaW5kb3dDbGFz
+c18QFk5TV2luZG93Q29udGVudE1pblNpemVcTlNXaW5kb3dSZWN0WU5TTWF4U2l6ZV8QD05TV2luZG93
+QmFja2luZ18QEU5TV2luZG93U3R5bGVNYXNrWU5TTWluU2l6ZVtOU1ZpZXdDbGFzc4EBEoEBbYEBEIEB
+aYEBbIEBDRJQeAAAgQEOgQERgQEMgQFrgQFqgQEPXxAYe3szMTksIDI5NH0sIHs0ODEsIDM0NX19XxAP
+WDExIFByZWZlcmVuY2VzV05TUGFuZWzSAA4ANgA3BMWABFRWaWV3XxAaezMuNDAyODJlKzM4LCAzLjQw
+MjgyZSszOH1aezIxMywgMTA3fdUA/QAOAQsBAAEMACsBDgTLARAEzIAAgQEzgQETgQFo0gAOAEUATQTP
+gB+hAYiBARTcAP0ADgTSBNMA/gE4AQsBAATUAQIE1QTWBLME2ATZAZcE2gEoBNwBEACrBLMAqwTgXk5T
+VGFiVmlld0l0ZW1zWU5TVHZGbGFnc18QEU5TRHJhd3NCYWNrZ3JvdW5kXxAWTlNBbGxvd1RydW5jYXRl
+ZExhYmVsc18QFU5TU2VsZWN0ZWRUYWJWaWV3SXRlbYEBEoEBZ4EBNYEBNIApgQEVCYEBEgmBATbSAA4A
+RQBNBOOAH6EBgYBD0gAOAEUATQTngB+oAqEE6QTqAX0E7AGmAlsE74CHgQEXgQEmgEKBASqATIB2gQEu
+1wD9AA4A/gD/AQABAQECAYEE8gTzBPQBEACrAYGAQ4EBJYEBGIEBGQmAQ18QFXt7MzYsIDkzfSwgezM4
+NSwgMzF9fdgBFAAOBPkBGgEbARwBHgT6ASAE+wT8BP0E/gTpBQAFAV8QEU5TQmFja2dyb3VuZENvbG9y
+W05TVGV4dENvbG9ygQEkgQEcgQEagQEbgQEXEgBAAACBASFfEGZXaGVuIGVuYWJsZWQsIG1lbnUgYmFy
 IGtleSBlcXVpdmFsZW50cyBtYXkgaW50ZXJmZXJlIHdpdGggWDExIGFwcGxpY2F0aW9ucyB0aGF0IHVz
-ZSB0aGUgTWV0YSBtb2RpZmllci7XAMEADgDCAMMAxADFAMYAxwK6A2QDZQDLAMwAx4AagJOAsICxCYAa
-XxAWe3szNiwgMTgyfSwgezM4NSwgMjl9fdgA1gAOAsEA3ADdAN4A4ALCAOICwwLEA2wCxgNNAsgCyYCS
-gIqAsoCJgK+Aj18QV0hvbGQgT3B0aW9uIGFuZCBDb21tYW5kIHdoaWxlIGNsaWNraW5nIHRvIGFjdGl2
-YXRlIHRoZSBtaWRkbGUgYW5kIHJpZ2h0IG1vdXNlIGJ1dHRvbnMuCtcAwQAOAMIAwwDEAMUAxgDHAMgD
-dAN1AMsAzADHgBqAJYC0gLUJgBpfEBZ7ezE4LCAxMDR9LCB7NDAyLCAxOH193QDWAA4A1wDYANkA2gDb
-ANwA3QDeAN8A4ADhAOIA4wCXAOUA5gDnAJcDfgDqA04A7ADtAO6AJIAOgCGADoC2gB6As18QIEVuYWJs
-ZSBrZXkgZXF1aXZhbGVudHMgdW5kZXIgWDEx1wDBAA4AwgDDAMQAxQDGAMcCugOFA4YAywDMAMeAGoCT
-gLiAuQmAGl8QFnt7MzYsIDEzM30sIHszODUsIDE0fX3YANYADgLBANwA3QDeAOACwgDiAsMCxAONAsYD
-TwLIAsmAkoCKgLqAiYC3gI9fED5BbGxvd3MgaW5wdXQgbWVudSBjaGFuZ2VzIHRvIG92ZXJ3cml0ZSB0
-aGUgY3VycmVudCBYMTEga2V5bWFwLlVJbnB1dNIAOgA7A5QDlaIDlQA/XU5TVGFiVmlld0l0ZW3WAA4D
-PQEMAz4C0QCIAz8DmAF5AYACxAOcgL2Av4BDgIKAioDA0gAOADYANwOfgARRMlZPdXRwdXTVAA4BDAM+
-AtEAiAM/AZUBgALEA6aAvYBJgIKAioDU0gAOAEUATQOpgD6lA6oBkQOsA60DroDDgEiAx4DLgM/XAMEA
-DgDCAMMAxADFAMYBlQDIA7IDswDLAMwBlYBJgCWAxIDFCYBJ3QDWAA4A1wDYANkA2gDbANwA3QDeAN8A
-4ADhAOIA4wCXAOUA5gDnAJcDuwDqA6oA7ADtAO6AJIAOgCGADoDGgB6Aw18QGEF1dGhlbnRpY2F0ZSBj
-b25uZWN0aW9uc9cAwQAOAMIAwwDEAMUAxgGVAroDwgPDAMsAzAGVgEmAk4DIgMkJgElfEBZ7ezM2LCAx
-Njl9LCB7Mzg1LCA0Mn192ADWAA4CwQDcAN0A3gDgAsIA4gLDAsQDygLGA6wCyALJgJKAioDKgImAx4CP
-XxCqTGF1bmNoaW5nIFgxMSB3aWxsIGNyZWF0ZSBYYXV0aG9yaXR5IGFjY2Vzcy1jb250cm9sIGtleXMu
-IElmIHRoZSBzeXN0ZW0ncyBJUCBhZGRyZXNzIGNoYW5nZXMsIHRoZXNlIGtleXMgYmVjb21lIGludmFs
-aWQgd2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy7XAMEADgDC
-AMMAxADFAMYBlQK6A9ID0wDLAMwBlYBJgJOAzIDNCYBJXxAVe3szNiwgOTJ9LCB7Mzg1LCA0Mn192ADW
-AA4CwQDcAN0A3gDgAsIA4gLDAsQD2gLGA60CyALJgJKAioDOgImAy4CPXxCZSWYgZW5hYmxlZCwgQXV0
-aGVudGljYXRlIGNvbm5lY3Rpb25zIG11c3QgYWxzbyBiZSBlbmFibGVkIHRvIGVuc3VyZSBzeXN0ZW0g
-c2VjdXJpdHkuIFdoZW4gZGlzYWJsZWQsIGNvbm5lY3Rpb25zIGZyb20gcmVtb3RlIGFwcGxpY2F0aW9u
-cyBhcmUgbm90IGFsbG93ZWQu1wDBAA4AwgDDAMQAxQDGAZUCugPiA+MAywDMAZWASYCTgNCA0QmASV8Q
-FXt7MTcsIDIwfSwgezQwNCwgMTR9fdgA1gAOAsEA3ADdAN4A4ALCAOICwwLEA+oCxgOuAsgCyYCSgIqA
-0oCJgM+Aj18QNFRoZXNlIG9wdGlvbnMgdGFrZSBlZmZlY3Qgd2hlbiBYMTEgaXMgbmV4dCBsYXVuY2hl
-ZC5YU2VjdXJpdHnSADoAOwPxAz6kAz4BDAENAD9aezQ3OCwgMzE2fV8QFXt7MCwgMH0sIHsxNDQwLCA4
-Nzh9fVp7MjEzLCAxMjl9WXgxMV9wcmVmc9IAOgA7A/cD+KID+AA/XxAQTlNXaW5kb3dUZW1wbGF0ZVtw
-cmVmc19wYW5lbNMADgCHAIgAiQP8A/2AF4DegOHYAA4AjQCOAI8AkACRAJIAkwCUBAAAlgQBAJgAmQCa
-AJuAFYDfgOCAD4ATgAxTQ3V0UXhUY3V0OtQADgC7AIcAiACJAL0BkQC/gBeAJoBIgCjUAA4AuwCHAIgA
-iQC9BBABr4AXgCaA5IBP2AAOAI0AjgCPAJAAkQCSAJMAlAQUAJYAlwCYAJkAmgJEgBWA5YAOgA+AE4Bu
-XEN1c3RvbWl6ZS4uLtQADgC7AIcAiAEiBBwAvQQegDCA54AmgOrXAA4AjQCPAJAAkQCSAJMAlAQhAJcA
-mACZAJoEJYAVgOmADoAPgBOA6NQADgCNAPIAnQCeBCgEKQQqgD+BAbuBAcmBAb1ZQWJvdXQgWDExXngx
-MV9hYm91dF9pdGVt1AAOALsAhwCIAIkAvQQwBDGAF4AmgOyA7tgADgCNAI4AjwCQAJEAkgCTAJQENACW
-AJcAmACZAJoCMIAVgO2ADoAPgBOAal8QEkJyaW5nIEFsbCB0byBGcm9udF8QD2JyaW5nX3RvX2Zyb250
-OtQADgC7AIcAiACJAL0EPgQ/gBeAJoDwgPPYAA4AjQCOAI8AkACRAJIAkwCUBEIAlgRDAJgAmQCaAjCA
-FYDxgPKAD4ATgGpcQ2xvc2UgV2luZG93UXddY2xvc2Vfd2luZG93OtQADgC7AIcAiAEiBEwAvQROgDCA
-9YAmgPfYAA4AjQCOAI8AkACRAJIAkwCUBFEEUgEaAJgAmQCaBCWAFYD2EgAYAACALIAPgBOA6F8QElRv
-Z2dsZSBGdWxsIFNjcmVlbl8QFnRvZ2dsZV9mdWxsc2NyZWVuX2l0ZW3UAA4AuwCHAIgBIgK2AL0EXYAw
-gJyAJoD5XxARZW5hYmxlX2Z1bGxzY3JlZW7UAA4AuwCHAIgAiQC9BGIEY4AXgCaA+4D92AAOAI0AjgCP
-AJAAkQCSAJMAlARmAJYAlwCYAJkAmgIwgBWA/IAOgA+AE4BqW1pvb20gV2luZG93XHpvb21fd2luZG93
-OtMADgCHAIgAiQRvBHCAF4D/gQEC2AAOAI0AjgCPAJAAkQCSAJMAlARzAJYEdACYAJkAmgCbgBWBAQCB
-AQGAD4ATgAxUUmVkb1FaVXJlZG861AAOALsAhwCIAIkAHwR+BH+AF4ACgQEEgQEH2AAOAI0AjgCPAJAA
-kQCSAJMAlASCAJYEgwCYAJkAmgQlgBWBAQWBAQaAD4ATgOhYUXVpdCBYMTFRcVp0ZXJtaW5hdGU60wAO
-AIcAiACJBIwEjYAXgQEJgQEM2AAOAI0AjgCPAJAAkQCSAJMAlASQAJYEkQCYAJkAmgCbgBWBAQqBAQuA
-D4ATgAxUVW5kb1F6VXVuZG861AAOALsAhwCIAIkAHwSbBJyAF4ACgQEOgQEQ2AAOAI0AjgCPAJAAkQCS
-AJMAlASfAJYAlwCYAJkAmgQlgBWBAQ+ADoAPgBOA6FtIaWRlIE90aGVyc18QFmhpZGVPdGhlckFwcGxp
-Y2F0aW9uczrUAA4AuwCHAIgAiQC9BKkEqoAXgCaBARKBARXYAA4AjQCOAI8AkACRAJIAkwCUBK0AlgCX
-AJgAmQCaBLGAFYEBFIAOgA+AE4EBE9MADgCNAJ0AngS0BLWAP4EB3IEB3lhYMTEgSGVscFl4MTFfaGVs
-cDrUAA4AuwCHAIgAiQC9A04Av4AXgCaAs4Ao1AAOALsAhwCIASIDTgC9BMGAMICzgCaBARhfEBBlbmFi
-bGVfa2V5ZXF1aXZz1AAOALsAhwCIAIkAvQTGBMeAF4AmgQEagQEj1wDBAA4AwgDDAMQAxQDGBMkAyATL
-BMwEzQDMBMmBARuAJYEBHIEBHREBLQmBARvVAMEADgDCAM8AxAArANEE0wTUAMuAAIClgQG3gQGoXxAX
-e3szNzIsIDIzMH0sIHsxMDAsIDMyfX3dANYADgDXANgA2QDaANsA3ADdAN4A3wDgAOEA4gDjBNgA5QHG
-BNkE2gTbAOoExgDsBN4E34AkgQEhgQEfgQEigQEegB6BARoSCDgAABP/////hoJA/1lEdXBsaWNhdGXU
-AA4A8QDyAPMA9AD1BOMB2YAggQEgWUhlbHZldGljYdIADgA2ADcAooAE0gAOADYANwCigARfEBVhcHBz
-X3RhYmxlX2R1cGxpY2F0ZTrUAA4AuwCHAIgBIgFJAL0E7oAwgDmAJoEBJV5kb2NrX2FwcHNfbWVuddQA
-DgC7AIcAiACJAL0E8wT0gBeAJoEBJ4EBLdcAwQAOAMIAwwDEAMUAxgTJAMgE+AT5BM0AzATJgQEbgCWB
-ASiBASkJgQEbXxAXe3szNzIsIDI2Mn0sIHsxMDAsIDMyfX3dANYADgDXANgA2QDaANsA3ADdAN4A3wDg
-AOEA4gDjBP8A5QHGBNkFAQUCAOoE8wDsBN4E34AkgQErgQEfgQEsgQEqgB6BASdYQWRkIEl0ZW3SAA4A
-NgA3AKKABNIADgA2ADcAooAEXxAPYXBwc190YWJsZV9uZXc61AAOALsAhwCIAIkAHwQcBQ+AF4ACgOeB
-AS9fEB1vcmRlckZyb250U3RhbmRhcmRBYm91dFBhbmVsOtQADgC7AIcAiAEiASwAvQUVgDCAMoAmgQEx
-WWRvY2tfbWVuddQADgC7AIcAiACJAL0FGgUbgBeAJoEBM4EBNtgADgCNAI4AjwCQAJEAkgCTAJQFHgCW
-BR8AmACZAJoCMIAVgQE0gQE1gA+AE4BqW05leHQgV2luZG93YfcDXG5leHRfd2luZG93OtQADgC7AIcA
-iACJAL0FKQUqgBeAJoEBOIEBPdcAwQAOAMIAwwDEAMUAxgTJAMgFLgUvBTAAzATJgQEbgCWBATmBAToR
-AS8JgQEbXxAVe3szODgsIDEyfSwgezg0LCAzMn193QDWAA4A1wDYANkA2gDbANwA3QDeAN8A4ADhBTUA
-4wCXAOUBxgTZBTkFOgDqBSkA7ATeBN8T/////4QB/gCAJIAOgQEfgQE8gQE7gB6BAThURG9uZdIADgA2
-ADcAooAEXxAQYXBwc190YWJsZV9kb25lOtQADgC7AIcAiACJAL0DqgC/gBeAJoDDgCjUAA4AuwCHAIgB
-IgOqAL0FSoAwgMOAJoEBQFtlbmFibGVfYXV0aNQADgC7AIcAiAEiBU4AvQVQgDCBAUKAJoEBad8QEwDB
-BVIADgKcBVMCwQVUBVUFVgVXBVgAxAKRAMUFWQVaAMYFWwVcBV0A7QVeBV8FYAVhAMwFYwVkAcYFZQDL
-BWYAzAVoAeoFXQVqBWtfEB9OU0RyYWdnaW5nU291cmNlTWFza0Zvck5vbkxvY2FsXE5TSGVhZGVyVmll
-d18QEk5TQWxsb3dzVHlwZVNlbGVjdFxOU0Nvcm5lclZpZXdfEBdOU0ludGVyY2VsbFNwYWNpbmdXaWR0
-aF8QGU5TQ29sdW1uQXV0b3Jlc2l6aW5nU3R5bGVfEBhOU0ludGVyY2VsbFNwYWNpbmdIZWlnaHRbTlNH
-cmlkQ29sb3JfEBxOU0RyYWdnaW5nU291cmNlTWFza0ZvckxvY2FsXk5TVGFibGVDb2x1bW5zW05TUm93
-SGVpZ2h0gQFDgQFoElJAgACBAUWBAVYJgQFJI0AIAAAAAAAAI0AAAAAAAAAAgQFECYEBZYEBQ4EBTSNA
-MQAAAAAAANoAwQAOAMIFbQDPAMQFbgVvAMYFcAVxBXIFcwV0BXUFdgVOBXgFcQVOWU5TY3ZGbGFnc1lO
-U0RvY1ZpZXdZTlNCR0NvbG9yXU5TTmV4dEtleVZpZXeBAUqBAayBAasQBIEBqhEJAIEBQoEBY4EBSoEB
-Qlp7MzMzLCAxOTd91gDBAA4AxAKRAMYFfQV+BX8AywWABX4FTltOU1RhYmxlVmlld4EBRoEBSIEBR4EB
-RoEBQtoAwQAOAMIFbQDPAMQFbgVvAMYFcAVxBXIFhgV0BYcFdgVgBXgFcQVggQFKgQGsgQG0gQGzgQFF
-gQFjgQFKgQFFWXszMzMsIDE3fdIAOgA7BY4Fj6QFjwEMAQ0AP18QEU5TVGFibGVIZWFkZXJWaWV31QDB
-AA4AwgDEAMYFcQWSBZMAywVxgQFKgQFMgQFLgQFK3QDBBZYADgDCBZcFmADPBZkAxADGBZoFcAWbBMkF
-nQWeBZ8FoAV+BaIFowWkBMkFpgVdBV1bTlNIU2Nyb2xsZXJYTlNzRmxhZ3NfEBBOU0hlYWRlckNsaXBW
-aWV3XE5TU2Nyb2xsQW10c1tOU1ZTY3JvbGxlcl1OU0NvbnRlbnRWaWV3gQEbgQGxgQG2gQG1EDKBAUaB
-AalPEBBBIAAAQSAAAEGYAABBmAAAEQEzgQEbgQGtgQFDgQFDXxAUe3szMzQsIDB9LCB7MTYsIDE3fX3S
-ADoAOwWrBaykBawBDAENAD9dX05TQ29ybmVyVmlld9IADgBFAE0Fr4A+owWwBbEFsoEBToEBWIEBXNoF
-tAAOBbUFtgW3BbgFuQW6BbsFfQDMBb0FvgW/BcABzwXBBcIAzAVOXk5TSXNSZXNpemVhYmxlXE5TSGVh
-ZGVyQ2VsbFdOU1dpZHRoWk5TRGF0YUNlbGxeTlNSZXNpemluZ01hc2taTlNNaW5XaWR0aFpOU01heFdp
-ZHRoXE5TSXNFZGl0YWJsZQmBAVeBAU8jQFPAAAAAAACBAVUjQEQAAAAAAAAjQI9AAAAAAAAJgQFC1wDW
-AA4CwQDcAN0A4ALCBcYFxwXIBckCxgDtBcsSBIH+AIEBVIEBUYEBUICJgQFSVE5hbWXTAA4C0gLdAtUB
-zwXPgI5LMC4zMzMzMzI5OQDVAA4C0QLSAtMC1ALVAuQC1wXTAtmAjoCRgQFTgItfEA9oZWFkZXJUZXh0
-Q29sb3LSADoAOwXXBdilBdgC7QEHAMMAP18QEU5TVGFibGVIZWFkZXJDZWxs1wDWAA4CwQDdAN4A4ALC
-BdoCwwVhAOoFTgHTAskSFDH+QICSgQFWgB6BAUKAj9MADgLSAt0C1QHPBeKAjkIxANIAOgA7BeQF5aIF
-5QA/XU5TVGFibGVDb2x1bW7aBbQADgW1BbYFtwW4BbkFugW7BX0AzAW9BekF6gXrAc8F7AXCAMwFTgmB
-AVeBAVkjQGg3ZGAAAACBAVsjQE9dkWAAAAAJgQFC1wDWAA4CwQDcAN0A4ALCBcYFxwXIBfICxgDtBcuB
-AVSBAVGBAVqAiYEBUldDb21tYW5k1wDWAA4CwQDdAN4A4ALCBdoCwwVhAOoFTgHTAsmAkoEBVoAegQFC
-gI/aBbQADgW1BbYFtwW4BbkFugW7BX0AzAW9Bf8GAAYBAc8GAgXCAMwFTgmBAVeBAV0jQEmAAAAAAACB
-AWEjQCQAAAAAAAAJgQFC1wDWAA4CwQDcAN0A4ALCAOIFxwYHBggCxgDtBcuBAVSBAV+BAV6AiYEBUlhT
-aG9ydGN1dNUADgLRAtIC0wLUAtUFYQLXBg8C2YCOgQFWgQFggItbaGVhZGVyQ29sb3LYANYADgLBAN0A
-3gDgAp0CwgXaAsMFeAYVBU4B0wDMAsmAkoEBY4EBYoEBQgmAj9QADgDxAPIA8wD0BhsA9gHZgCAjQCgA
-AAAAAACAH9UADgLRAtIC0wLUAtUC1gLXBiAC2YCOgI2BAWSAi18QFmNvbnRyb2xCYWNrZ3JvdW5kQ29s
-b3LVAA4C0QLSAtMC1ALVBiUC1wYmAtmAjoEBZ4EBZoCLWWdyaWRDb2xvctMADgLSAt0C1QHPBiuAjkQw
-LjUA0gA6ADsGLQV9pQV9AQsBDAENAD9aYXBwc190YWJsZdQADgC7AIcAiACJAB8GMgYzgBeAAoEBa4EB
-btkADgCNAI4AjwCQAJEAkgCTAeAAlAY2AJYGNwCYAJkAmgQlBjuAFYEBbIEBbYAPgBOA6BAqWEhpZGUg
-WDExUWhVaGlkZTrUAA4AuwCHAIgAiQAfBkIGQ4AXgAKBAXCBAXLZAA4AjQCOAI8AkACRAJIAkwHgAJQG
-RgCWAJcAmACZAJoEJQY7gBWBAXGADoAPgBOA6FhTaG93IEFsbF8QFnVuaGlkZUFsbEFwcGxpY2F0aW9u
-czrTAA4AhwCIAIkGTwZQgBeBAXSBAXfYAA4AjQCOAI8AkACRAJIAkwCUBlMAlgZUAJgAmQCaAJuAFYEB
-dYEBdoAPgBOADFVQYXN0ZVF2VnBhc3RlOtQADgC7AIcAiACJAL0GXgZfgBeAJoEBeYEBf9cAwQAOAMIA
-wwDEAMUAxgTJAMgGYwZkBM0AzATJgQEbgCWBAXqBAXsJgQEbXxAXe3szNzIsIDE5OH0sIHsxMDAsIDMy
-fX3dANYADgDXANgA2QDaANsA3ADdAN4A3wDgAOEA4gDjBmoA5QHGBNkGbAZtAOoGXgDsBN4E34AkgQF9
-gQEfgQF+gQF8gB6BAXlWUmVtb3Zl0gAOADYANwCigATSAA4ANgA3AKKABF8QEmFwcHNfdGFibGVfZGVs
-ZXRlOtQADgC7AIcAiAEiAL4AvQZ6gDCAGYAmgQGBW3N5bmNfa2V5bWFw1AAOALsAhwCIAIkAvQZ/BoCA
-F4AmgQGDgQGG2AAOAI0AjgCPAJAAkQCSAJMAlAaDAJYGhACYAJkAmgQlgBWBAYSBAYWAD4ATgOheUHJl
-ZmVyZW5jZXMuLi5RLFtwcmVmc19zaG93OtQADgC7AIcAiACJAL0ETAaPgBeAJoD1gQGIXxASdG9nZ2xl
-X2Z1bGxzY3JlZW461AAOALsAhwCIAIkAvQK2BpWAF4AmgJyBAYpfEBplbmFibGVfZnVsbHNjcmVlbl9j
-aGFuZ2VkOtQADgC7AIcAiAEiATgAvQabgDCANYAmgQGMXxAVZG9ja193aW5kb3dfc2VwYXJhdG9y1AAO
-ALsAhwCIAIkAvQJMAL+AF4AmgHGAKNQADgC7AIcAiACJAL0GpQamgBeAJoEBj4EBktgADgCNAI4AjwCQ
-AJEAkgCTAJQGqQCWBqoAmACZAJoCMIAVgQGQgQGRgA+AE4BqXxAPUHJldmlvdXMgV2luZG93YfcCXxAQ
-cHJldmlvdXNfd2luZG93OtQADgC7AIcAiACJAL0GtAa1gBeAJoEBlIEBl9gADgCNAI4AjwCQAJEAkgCT
-AJQGuACWBrkAmACZAJoCMIAVgQGVgQGWgA+AE4BqXxAPTWluaW1pemUgV2luZG93UW1fEBBtaW5pbWl6
-ZV93aW5kb3c61AAOALsAhwCIAIkAvQbDBsSAF4AmgQGZgQGf1wDBAA4AwgDDAMQAxQDGBMkAyAbIBskF
-MADMBMmBARuAJYEBmoEBmwmBARtfEBV7ezMwNCwgMTJ9LCB7ODQsIDMyfX3dANYADgDXANgA2QDaANsA
-3ADdAN4A3wDgAOEA4gDjBs8A5QHGBNkG0QbSAOoGwwDsBN4E34AkgQGdgQEfgQGegQGcgB6BAZlWQ2Fu
-Y2Vs0gAOADYANwCigATSAA4ANgA3AKKABF8QEmFwcHNfdGFibGVfY2FuY2VsOtQADgC7AIcAiAEiAXYA
-vQbfgDCAQoAmgQGhW3VzZV9zeXNiZWVw0wAOAIcAiACJBuMG5IAXgQGjgQGm2AAOAI0AjgCPAJAAkQCS
-AJMAlAbnAJYG6ACYAJkAmgCbgBWBAaSBAaWAD4ATgAxUQ29weVFjVWNvcHk60gAOAEUG8AbxgQHsrxB9
-BsMEyQG6AZECRAH6BBwGtAMVAyYBeQC+Bv4EfgNNAZUFKQcDBZ0HBQcGBBABOQOuASwDZQK3Ac0BdgWy
-BJsC9QZeAjACewQ+A04DdQF8A/wHGgHUBxwHHQYyA8MHIAJpBMYGyQNPBk8E8wK0BGIGfwcqAwUHLAIl
-AUkGQgcwArwCTAC9AYAFcQRMBbEE+QQwA7MBOAVOBbADOQNVAIoCOQdCBaYBWgdFBKkEjAH4BuMHSgKy
-BWADOwK1AlMD4wYBAqkFwAOGB1UBtAOsA60BFQK2A9MAxwZkBqUHXwSxA6oEJQdjBMwF6wFZBRoB+QGY
-BS8AmwDKA0wEb4EBmYEBG4BTgEiAboBjgOeBAZSAnoCigEOAGYEBuYEBBICvgEmBATiBAb+BAbGBAcaB
-AcqA5IA2gM+AMoCxgKCAV4BCgQFcgQEOgJaBAXmAaoCAgPCAs4C1gEWA3oEBuoBYgQHbgQHHgQFrgMmB
-AdeAeYEBGoEBm4C3gQF0gQEngJSA+4EBg4EBzoCagQHggGmAOYEBcIEBvoCHgHGAJoCCgQFKgPWBAViB
-ASmA7IDFgDWBAUKBAU6AqICtgAuAbYEB4oEBrYA8gQHYgQESgQEJgF2BAaOBAdOAhYEBRYDBgJiAc4DR
-gQFhgL6BAVWAuYEBz4BRgMeAy4AqgJyAzYAagQF7gQGPgQHIgQETgMOA6IEBwoEBHYEBW4A7gQEzgGCA
-S4EBOoAMgByAq4D/0gAOAEUATQdxgD6mBSkExgZeBXEGwwTzgQE4gQEagQF5gQFKgQGZgQEn0gAOAEUA
-TQd6gD6lBV0FpgWdBX4FY4EBQ4EBrYEBsYEBRoEBSdIADgBFAE0HgoA+oQVOgQFCXxAVe3sxLCAxN30s
-IHszMzMsIDE5N3190gA6ADsHhgeHpAeHAQwBDQA/Wk5TQ2xpcFZpZXfYAMEB3wAOAMIAxAFHAMYHiQVx
-BXEHjAeNAMsHjgVxB5BZTlNQZXJjZW50gQFKgQFKgQGwgQGugQGvgQFKIz/v1mqAAAAAXxAWe3szMzQs
-IDE3fSwgezE1LCAxOTd9fVxfZG9TY3JvbGxlcjrSADoAOweUB5WlB5UBCwEMAQ0AP1pOU1Njcm9sbGVy
-2QDBAd8ADgDCBZcAxAFHAMYHiQVxBXEHjAeaAcYAyweOBXEHnYEBSoEBSoEBsIEBsoEBr4EBSiM/788X
-wAAAAF8QFXt7MSwgMjE0fSwgezMzMywgMTV9fdIADgBFAE0HoYA+oQVggQFFXxATe3sxLCAwfSwgezMz
-MywgMTd9fV8QFnt7MjAsIDYwfSwgezM1MCwgMjMwfX3SADoAOwemB6ekB6cBDAENAD9cTlNTY3JvbGxW
-aWV3XxAUe3sxLCAxfSwgezQ4NiwgMzEwfX3SAA4ARQBNB6uAPqICOQQQgG2A5NoADgFGAI0AjgCPAJAA
-kQCSAJMBRwCUBCUEKACWAJcAmACZAJoHGge2gBWA6IEBu4AOgA+AE4EBuoEBvNQADgCNAPIAnQCeB7kH
-uge7gD+BAdGBAd+BAdJTWDEx0gAOAEUATQe/gD6sBBwGfwcwBwMHBQRMBx0GMgSbBkIHXwR+gOeBAYOB
-Ab6BAb+BAcaA9YEBx4EBa4EBDoEBcIEByIEBBNoADgCNAI4BOwCPATwAkACRAJIAkwCUAJcAlgDMAJcA
-zACYAJkAmgQlgBWADgmADgmAD4ATgOjaAA4BRgCNAI4AjwCQAJEAkgCTAUcAlAdjB9gAlgCXAJgAmQCa
-BCUH3YAVgQHCgQHAgA6AD4ATgOiBAcFYU2VydmljZXPUAA4AjQDyAJ0AngfhB+IH44A/gQHDgQHFgQHE
-0gAOADYANwfegATSAA4ARQBNB+iAPqBfEA9fTlNTZXJ2aWNlc01lbnXaAA4AjQCOATsAjwE8AJAAkQCS
-AJMAlACXAJYAzACXAMwAmACZAJoEJYAVgA4JgA4JgA+AE4Do2gAOAI0AjgE7AI8BPACQAJEAkgCTAJQA
-lwCWAMwAlwDMAJgAmQCaBCWAFYAOCYAOCYAPgBOA6NoADgCNAI4BOwCPATwAkACRAJIAkwCUAJcAlgDM
-AJcAzACYAJkAmgQlgBWADgmADgmAD4ATgOhcX05TQXBwbGVNZW512gAOAUYAjQCOAI8AkACRAJIAkwFH
-AJQCRAFKAJYAlwCYAJkAmgcaCA6AFYBugDeADoAPgBOBAbqBAcvSAA4ANgA3CBGABFZXaW5kb3fSAA4A
-RQBNCBSAPqkGtAQ+BGIHKgUaBqUHVQQwAiWBAZSA8ID7gQHOgQEzgQGPgQHPgOyAadoADgCNAI4BOwCP
-ATwAkACRAJIAkwCUAJcAlgDMAJcAzACYAJkAmgIwgBWADgmADgmAD4ATgGraAA4AjQCOATsAjwE8AJAA
-kQCSAJMAlACXAJYAzACXAMwAmACZAJoCMIAVgA4JgA4JgA+AE4BqXl9OU1dpbmRvd3NNZW51WE1haW5N
-ZW510gAOAEUATQg0gD6lBv4HBgdKB0UHHIEBuYEByoEB04EB2IEB29oADgFGAI0AjgCPAJAAkQCSAJMB
-RwCUAJsAnwCWAJcAmACZAJoHGghCgBWADIEB1IAOgA+AE4EBuoEB1VRFZGl00gAOAEUATQhGgD6oBIwE
-bwcgA/wG4wZPAIoBFYEBCYD/gQHXgN6BAaOBAXSAC4Aq2gAOAI0AjgE7AI8BPACQAJEAkgCTAJQAlwCW
-AMwAlwDMAJgAmQCaAJuAFYAOCYAOCYAPgBOADNoADgFGAI0AjgCPAJAAkQCSAJMBRwCUAjAIWwCWAJcA
-mACZAJoHGghggBWAaoEB2YAOgA+AE4EBuoEB2toADgFGAI0AjgCPAJAAkQCSAJMBRwCUBLEEtACWAJcA
-mACZAJoHGghpgBWBAROBAdyADoAPgBOBAbqBAd1USGVscNIADgBFAE0IbYA+oQSpgQESW19OU01haW5N
-ZW510gAOADIAMwhygAWBAeHfEA8CbQAOAm4CbwJwAnECcgJzAnQCdQJ2AncCeAJ5AnoEyQJ8CHYIdwh4
-CHkCgQKCCHsIfAh9AOYIfgh/CICBARuA24EB5oEB6IEB64EB5IB8gQHngQHjgQHqEAuBAemBAeVfEBh7
-ezI3OSwgMjcwfSwgezQ4NiwgMzEwfX1fEBRYMTEgQXBwbGljYXRpb24gTWVuddIADgA2ADcCjYAEWHgx
-MV9hcHBz0gA6ADsIhwFvogFvAD/SAA4ARQbwCIqBAeyvEH0EyQdCAbQBlQcGAdQEJQIwArYCtwKpAMcH
-GgQlAMcDOwTJBCUFcQQlBxoCRAEsAZUAHwNNAXkB1AF5BU4EJQK0BMkHRQJpAjAAxwNOAXYAmwAfAboH
-GgQlBCUDrACbAB8EyQbDAMcAmwTJAXkCMAQlAjACtQAfAjABOQQlBCUCsgDHAB8CewTJBCUFTgTzAjAD
-qgEsBXEFTgGAA0wAmwJEAB8FcQFJBxoEsQCbAdQAmwcaAXkFcQGAAXkCTAOuBbIBgAWwA08CMAF5AZUB
-lQCbAXkDrQM5Bl4CMAQlBxwBlQb+BwMExgWxAUkCMAHUAZEFKQdKAL4AxwCbgQEbgQHigFGASYEByoBY
-gOiAaoCcgKCAvoAagQG6gOiAGoDBgQEbgOiBAUqA6IEBuoBugDKASYACgK+AQ4BYgEOBAUKA6ICUgQEb
-gQHYgHmAaoAagLOAQoAMgAKAU4EBuoDogOiAx4AMgAKBARuBAZmAGoAMgQEbgEOAaoDogGqAmIACgGqA
-NoDogOiAhYAagAKAgIEBG4DogQFCgQEngGqAw4AygQFKgQFCgIKAq4AMgG6AAoEBSoA5gQG6gQETgAyA
-WIAMgQG6gEOBAUqAgoBDgHGAz4EBXICCgQFOgLeAaoBDgEmASYAMgEOAy4CogQF5gGqA6IEB24BJgQG5
-gQG/gQEagQFYgDmAaoBYgEiBATiBAdOAGYAagAzSAA4ARQbwCQqBAeyvEH4GwwTJAboBkQJEAfoEHAa0
-AxUDJgAfAXkBlQb+BH4FKQWdAL4HAwNNBwYHBQQQATkDrgEsA2UCtwHNBbIBdgSbBl4C9QIwAnsEPgNO
-A3UBfAP8BxoB1AccBMYHHQYyAmkHIAbJBPMDTwZPA8MCtARiBn8HKgMFAiUHLAFJBkIHMAK8AkwAvQGA
-BXEETAT5BbEEMAE4A7MFTgWwB0IDOQCKAjkFpgNVAVoHRQSpBIwB+AbjB0oFYAKyAzsCtQYBAlMD4wKp
-BcADhgdVA6wBtAOtARUCtgZkAMcD0wSxB18GpQOqBCUBWQTMB2MF6wUaAZgB+QUvAJsAygNMBG+BAZmB
-ARuAU4BIgG6AY4DngQGUgJ6AooACgEOASYEBuYEBBIEBOIEBsYAZgQG/gK+BAcqBAcaA5IA2gM+AMoCx
-gKCAV4EBXIBCgQEOgQF5gJaAaoCAgPCAs4C1gEWA3oEBuoBYgQHbgQEagQHHgQFrgHmBAdeBAZuBASeA
-t4EBdIDJgJSA+4EBg4EBzoCagGmBAeCAOYEBcIEBvoCHgHGAJoCCgQFKgPWBASmBAViA7IA1gMWBAUKB
-AU6BAeKAqIALgG2BAa2ArYA8gQHYgQESgQEJgF2BAaOBAdOBAUWAhYDBgJiBAWGAc4DRgL6BAVWAuYEB
-z4DHgFGAy4AqgJyBAXuAGoDNgQETgQHIgQGPgMOA6IA7gQEdgQHCgQFbgQEzgEuAYIEBOoAMgByAq4D/
-0gAOAEUG8AmLgQHsrxB+CYwJjQmOCY8JkAmRCZIJkwmUCZUJlgmXCZgJmQmaCZsJnAmdCZ4JnwmgCaEJ
-ogmjCaQJpQmmCacJqAmpCaoJqwmsCa0JrgmvCbAJsQmyCbMJtAe5CbYJtwm4CbkJugm7CbwJvQm+Cb8J
-wAnBCcIJwwnECcUJxgnHCcgJyQnKCcsJzAnNARAJzwnQCdEJ0gnTCdQJ1QnWCdcJ2AnZCdoJ2wncCd0J
-3gnfCeAJ4QniCeMJ5AnlCeYJ5wnoCekJ6gnrCewJ7QnuCe8J8AnxCfIJ8wn0CfUJ9gn3CfgJ+Qn6CfsJ
-/An9Cf4J/woACgEKAgoDCgQKBQoGCgcKCAoJgQHwgQHxgQHygQHzgQH0gQH1gQH2gQH3gQH4gQH5gQH6
-gQH7gQH8gQH9gQH+gQH/gQIAgQIBgQICgQIDgQIEgQIFgQIGgQIHgQIIgQIJgQIKgQILgQIMgQINgQIO
-gQIPgQIQgQIRgQISgQITgQIUgQIVgQIWgQIXgQIYgQHRgQIZgQIagQIbgQIcgQIdgQIegQIfgQIggQIh
-gQIigQIjgQIkgQIlgQImgQIngQIogQIpgQIqgQIrgQIsgQItgQIugQIvgQIwgCeBAjGBAjKBAjOBAjSB
-AjWBAjaBAjeBAjiBAjmBAjqBAjuBAjyBAj2BAj6BAj+BAkCBAkGBAkKBAkOBAkSBAkWBAkaBAkeBAkiB
-AkmBAkqBAkuBAkyBAk2BAk6BAk+BAlCBAlGBAlKBAlOBAlSBAlWBAlaBAleBAliBAlmBAlqBAluBAlyB
-Al2BAl6BAl+BAmCBAmGBAmKBAmOBAmSBAmWBAmaBAmeBAmiBAmmBAmqBAmtfEBRQdXNoIEJ1dHRvbiAo
-Q2FuY2VsKV5Db250ZW50IFZpZXctMV8QIVBvcCBVcCBCdXR0b24gQ2VsbCAoRnJvbSBEaXNwbGF5KV8Q
-MkNoZWNrIEJveCAoQWxsb3cgY29ubmVjdGlvbnMgZnJvbSBuZXR3b3JrIGNsaWVudHMpXxATTWVudSAo
-QXBwbGljYXRpb25zKV8QFE1lbnUgSXRlbSAoTWlsbGlvbnMpXxAVTWVudSBJdGVtIChBYm91dCBYMTEp
-XxAbTWVudSBJdGVtIChNaW5pbWl6ZSBXaW5kb3cpXxAeQnV0dG9uIENlbGwgKEZ1bGwgc2NyZWVuIG1v
-ZGUpXxB2VGV4dCBGaWVsZCBDZWxsIChFbmFibGVzIHRoZSBYMTEgcm9vdCB3aW5kb3cuIFVzZSB0aGUg
-Q29tbWFuZC1PcHRpb24tQSBrZXlzdHJva2UgdG8gZW50ZXIgYW5kIGxlYXZlIGZ1bGwgc2NyZWVuIG1v
-ZGUuKVxGaWxlJ3MgT3duZXJWVmlldy0yVlZpZXctMV8QD01lbnUgSXRlbSAoWDExKV8QFE1lbnUgSXRl
-bSAoUXVpdCBYMTEpXxASUHVzaCBCdXR0b24gKERvbmUpXxATSG9yaXpvbnRhbCBTY3JvbGxlcl8QKUNo
-ZWNrIEJveCAoRm9sbG93IHN5c3RlbSBrZXlib2FyZCBsYXlvdXQpXxAUTWVudSBJdGVtIChTZXJ2aWNl
-cylfEGVTdGF0aWMgVGV4dCAoSG9sZCBPcHRpb24gYW5kIENvbW1hbmQgd2hpbGUgY2xpY2tpbmcgdG8g
-YWN0aXZhdGUgdGhlIG1pZGRsZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KKV8QGE1lbnUgSXRlbSAo
-QXBwbGljYXRpb25zKVtTZXBhcmF0b3ItMV8QGE1lbnUgSXRlbSAoQ3VzdG9taXplLi4uKV8QGk1lbnUg
-SXRlbSAoQXBwbGljYXRpb25zKS0xXxBCU3RhdGljIFRleHQgKFRoZXNlIG9wdGlvbnMgdGFrZSBlZmZl
-Y3Qgd2hlbiBYMTEgaXMgbmV4dCBsYXVuY2hlZC4pWERvY2tNZW51XxBpVGV4dCBGaWVsZCBDZWxsIChI
-b2xkIE9wdGlvbiBhbmQgQ29tbWFuZCB3aGlsZSBjbGlja2luZyB0byBhY3RpdmF0ZSB0aGUgbWlkZGxl
-IGFuZCByaWdodCBtb3VzZSBidXR0b25zLgopXxByU3RhdGljIFRleHQgKEVuYWJsZXMgdGhlIFgxMSBy
-b290IHdpbmRvdy4gVXNlIHRoZSBDb21tYW5kLU9wdGlvbi1BIGtleXN0cm9rZSB0byBlbnRlciBhbmQg
-bGVhdmUgZnVsbCBzY3JlZW4gbW9kZS4pXxAYTWVudSBJdGVtIChGcm9tIERpc3BsYXkpXxAXVGFibGUg
-Q29sdW1uIChTaG9ydGN1dClfECNDaGVjayBCb3ggKFVzZSBzeXN0ZW0gYWxlcnQgZWZmZWN0KV8QF01l
-bnUgSXRlbSAoSGlkZSBPdGhlcnMpXxAUUHVzaCBCdXR0b24gKFJlbW92ZSlfEBpUZXh0IEZpZWxkIENl
-bGwgKENvbG9yczoKKV1NZW51IChXaW5kb3cpXENvbnRlbnQgVmlld18QGE1lbnUgSXRlbSAoQ2xvc2Ug
-V2luZG93KV8QLENoZWNrIEJveCAoRW5hYmxlIGtleSBlcXVpdmFsZW50cyB1bmRlciBYMTEpXxAuQnV0
-dG9uIENlbGwgKEVuYWJsZSBrZXkgZXF1aXZhbGVudHMgdW5kZXIgWDExKV8QJUJ1dHRvbiBDZWxsIChV
-c2Ugc3lzdGVtIGFsZXJ0IGVmZmVjdClfEA9NZW51IEl0ZW0gKEN1dClfEBFNZW51IChPdGhlclZpZXdz
-KV8QEE1lbnUgSXRlbSAoSGVscClfEBdQdXNoIEJ1dHRvbiAoRHVwbGljYXRlKVtTZXBhcmF0b3ItMl8Q
-FE1lbnUgSXRlbSAoSGlkZSBYMTEpWlByZWZzUGFuZWxbU2VwYXJhdG9yLTlfEBRCdXR0b24gQ2VsbCAo
-Q2FuY2VsKV8QFlB1c2ggQnV0dG9uIChBZGQgSXRlbSlfEExTdGF0aWMgVGV4dCAoQWxsb3dzIGlucHV0
-IG1lbnUgY2hhbmdlcyB0byBvdmVyd3JpdGUgdGhlIGN1cnJlbnQgWDExIGtleW1hcC4pXxARTWVudSBJ
-dGVtIChQYXN0ZSlfELxUZXh0IEZpZWxkIENlbGwgKExhdW5jaGluZyBYMTEgd2lsbCBjcmVhdGUgWGF1
-dGhvcml0eSBhY2Nlc3MtY29udHJvbCBrZXlzLiBJZiB0aGUgc3lzdGVtJ3MgSVAgYWRkcmVzcyBjaGFu
-Z2VzLCB0aGVzZSBrZXlzIGJlY29tZSBpbnZhbGlkIHdoaWNoIG1heSBwcmV2ZW50IFgxMSBhcHBsaWNh
-dGlvbnMgZnJvbSBsYXVuY2hpbmcuKV8QFlN0YXRpYyBUZXh0IChDb2xvcnM6CilfEBdNZW51IEl0ZW0g
-KFpvb20gV2luZG93KV8QGk1lbnUgSXRlbSAoUHJlZmVyZW5jZXMuLi4pW1NlcGFyYXRvci02XxBGVGV4
-dCBGaWVsZCBDZWxsIChUaGlzIG9wdGlvbiB0YWtlcyBlZmZlY3Qgd2hlbiBYMTEgaXMgbGF1bmNoZWQg
-YWdhaW4uKVtTZXBhcmF0b3ItN1tBcHBsaWNhdGlvbl8QFU1lbnUgKEFwcGxpY2F0aW9ucyktMV8QFE1l
-bnUgSXRlbSAoU2hvdyBBbGwpW1NlcGFyYXRvci0zXxB5VGV4dCBGaWVsZCBDZWxsIChYMTEgYmVlcHMg
-d2lsbCB1c2UgdGhlIHN0YW5kYXJkIHN5c3RlbSBhbGVydCwgYXMgZGVmaW5lZCBpbiB0aGUgU291bmQg
-RWZmZWN0cyBzeXN0ZW0gcHJlZmVyZW5jZXMgcGFuZWwuKV8QJkNoZWNrIEJveCAoRW11bGF0ZSB0aHJl
-ZSBidXR0b24gbW91c2UpXxAmVG9wIFRhYiBWaWV3IChJbnB1dCwgT3V0cHV0LCBTZWN1cml0eSlbU2Ny
-b2xsIFZpZXdfEB5NZW51IEl0ZW0gKFRvZ2dsZSBGdWxsIFNjcmVlbilfEBZCdXR0b24gQ2VsbCAoQWRk
-IEl0ZW0pXxAWVGFibGUgQ29sdW1uIChDb21tYW5kKV8QHk1lbnUgSXRlbSAoQnJpbmcgQWxsIHRvIEZy
-b250KVlTZXBhcmF0b3JfECZCdXR0b24gQ2VsbCAoQXV0aGVudGljYXRlIGNvbm5lY3Rpb25zKV8QJFRh
-YmxlIFZpZXcgKE5hbWUsIENvbW1hbmQsIFNob3J0Y3V0KV8QE1RhYmxlIENvbHVtbiAoTmFtZSlcRWRp
-dFByb2dyYW1zXxAVVGFiIFZpZXcgSXRlbSAoSW5wdXQpXxASTWVudSBJdGVtIChEZWxldGUpW1NlcGFy
-YXRvci01XxARVmVydGljYWwgU2Nyb2xsZXJfEHhUZXh0IEZpZWxkIENlbGwgKFdoZW4gZW5hYmxlZCwg
-bWVudSBiYXIga2V5IGVxdWl2YWxlbnRzIG1heSBpbnRlcmZlcmUgd2l0aCBYMTEgYXBwbGljYXRpb25z
-IHRoYXQgdXNlIHRoZSBNZXRhIG1vZGlmaWVyLilvEBYATQBlAG4AdQAgAEkAdABlAG0AIAAoAEMAdQBz
-AHQAbwBtAGkAegBlICYAKV8QEk1lbnUgSXRlbSAoV2luZG93KV8QFE1lbnUgSXRlbSAoWDExIEhlbHAp
-XxAQTWVudSBJdGVtIChVbmRvKV8QFk1lbnUgSXRlbSAoMjU2IENvbG9ycylfEBBNZW51IEl0ZW0gKENv
-cHkpXxAQTWVudSBJdGVtIChFZGl0KV8QEVRhYmxlIEhlYWRlciBWaWV3XxB1U3RhdGljIFRleHQgKFgx
-MSBiZWVwcyB3aWxsIHVzZSB0aGUgc3RhbmRhcmQgc3lzdGVtIGFsZXJ0LCBhcyBkZWZpbmVkIGluIHRo
-ZSBTb3VuZCBFZmZlY3RzIHN5c3RlbSBwcmVmZXJlbmNlcyBwYW5lbC4pXxAYVGFiIFZpZXcgSXRlbSAo
-U2VjdXJpdHkpXxBCU3RhdGljIFRleHQgKFRoaXMgb3B0aW9uIHRha2VzIGVmZmVjdCB3aGVuIFgxMSBp
-cyBsYXVuY2hlZCBhZ2Fpbi4pXxAPVGV4dCBGaWVsZCBDZWxsXxAoQnV0dG9uIENlbGwgKEVtdWxhdGUg
-dGhyZWUgYnV0dG9uIG1vdXNlKV8QRlRleHQgRmllbGQgQ2VsbCAoVGhlc2Ugb3B0aW9ucyB0YWtlIGVm
-ZmVjdCB3aGVuIFgxMSBpcyBuZXh0IGxhdW5jaGVkLilfEBZUYWIgVmlldyBJdGVtIChPdXRwdXQpXxAR
-VGV4dCBGaWVsZCBDZWxsLTJfEFBUZXh0IEZpZWxkIENlbGwgKEFsbG93cyBpbnB1dCBtZW51IGNoYW5n
-ZXMgdG8gb3ZlcndyaXRlIHRoZSBjdXJyZW50IFgxMSBrZXltYXAuKVtTZXBhcmF0b3ItOF8QuFN0YXRp
-YyBUZXh0IChMYXVuY2hpbmcgWDExIHdpbGwgY3JlYXRlIFhhdXRob3JpdHkgYWNjZXNzLWNvbnRyb2wg
-a2V5cy4gSWYgdGhlIHN5c3RlbSdzIElQIGFkZHJlc3MgY2hhbmdlcywgdGhlc2Uga2V5cyBiZWNvbWUg
-aW52YWxpZCB3aGljaCBtYXkgcHJldmVudCBYMTEgYXBwbGljYXRpb25zIGZyb20gbGF1bmNoaW5nLilf
-EBtQb3B1cCBCdXR0b24gKEZyb20gRGlzcGxheSlfEKdTdGF0aWMgVGV4dCAoSWYgZW5hYmxlZCwgQXV0
-aGVudGljYXRlIGNvbm5lY3Rpb25zIG11c3QgYWxzbyBiZSBlbmFibGVkIHRvIGVuc3VyZSBzeXN0ZW0g
-c2VjdXJpdHkuIFdoZW4gZGlzYWJsZWQsIGNvbm5lY3Rpb25zIGZyb20gcmVtb3RlIGFwcGxpY2F0aW9u
-cyBhcmUgbm90IGFsbG93ZWQuKV8QFk1lbnUgSXRlbSAoU2VsZWN0IEFsbClfEBxDaGVjayBCb3ggKEZ1
-bGwgc2NyZWVuIG1vZGUpXxAUQnV0dG9uIENlbGwgKFJlbW92ZSlfEKtUZXh0IEZpZWxkIENlbGwgKElm
-IGVuYWJsZWQsIEF1dGhlbnRpY2F0ZSBjb25uZWN0aW9ucyBtdXN0IGFsc28gYmUgZW5hYmxlZCB0byBl
-bnN1cmUgc3lzdGVtIHNlY3VyaXR5LiBXaGVuIGRpc2FibGVkLCBjb25uZWN0aW9ucyBmcm9tIHJlbW90
-ZSBhcHBsaWNhdGlvbnMgYXJlIG5vdCBhbGxvd2VkLilbTWVudSAoSGVscClbU2VwYXJhdG9yLTRfEBtN
-ZW51IEl0ZW0gKFByZXZpb3VzIFdpbmRvdylfECRDaGVjayBCb3ggKEF1dGhlbnRpY2F0ZSBjb25uZWN0
-aW9ucylaTWVudSAoWDExKVxTZXBhcmF0b3ItMTBfEBdCdXR0b24gQ2VsbCAoRHVwbGljYXRlKV8QD01l
-bnUgKFNlcnZpY2VzKV8QEVRleHQgRmllbGQgQ2VsbC0xXxAXTWVudSBJdGVtIChOZXh0IFdpbmRvdylf
-EDRCdXR0b24gQ2VsbCAoQWxsb3cgY29ubmVjdGlvbnMgZnJvbSBuZXR3b3JrIGNsaWVudHMpXxAVTWVu
-dSBJdGVtIChUaG91c2FuZHMpXxASQnV0dG9uIENlbGwgKERvbmUpW01lbnUgKEVkaXQpXxArQnV0dG9u
-IENlbGwgKEZvbGxvdyBzeXN0ZW0ga2V5Ym9hcmQgbGF5b3V0KV8QdFN0YXRpYyBUZXh0IChXaGVuIGVu
-YWJsZWQsIG1lbnUgYmFyIGtleSBlcXVpdmFsZW50cyBtYXkgaW50ZXJmZXJlIHdpdGggWDExIGFwcGxp
-Y2F0aW9ucyB0aGF0IHVzZSB0aGUgTWV0YSBtb2RpZmllci4pXxAQTWVudSBJdGVtIChSZWRvKdIADgBF
-BvAKh4EB7KDSAA4ARQbwCoqBAeyg0gAOAEUG8AqNgQHsrxC1BsMAbgTJAboBkQJEAfoAhAQcAFYGtAMV
-AyYAHwBpAXkAvgb+BH4DTQGVBSkHAwWdBwUHBgQQAFIAVQB4AH4BOQCAA64BLANlArcBzQBTAXYFsgSb
-AGsC9QZeAjAAegBQAnsEPgNOA3UBfABnAH0D/ACBAE8HGgHUBxwAYwB7AHEHHQYyA8MHIAJpBMYGyQNP
-Bk8E8wBcAGwAUQBeArQEYgBZAGUGfwcqAwUHLAIlAIMBSQZCAG8HMAK8AkwAVABiAHcAvQGABXEETAWx
-BPkEMAOzATgFTgWwAFgDOQNVAIoCOQdCBaYAZABbAVoAagBtB0UAcgCCBKkEjAB0AfgAdgB5BuMHSgKy
-BWADOwK1AHACUwPjBgECqQXAA4YHVQCFAGYBtAOsA60BFQK2A9MAxwZkAGAAYQBzBqUHXwSxA6oAVwB/
-BCUHYwTMBesBWQBaBRoAXwBoAfkBmAB8BS8AdQCbAMoDTARvAF2BAZmBASSBARuAU4BIgG6AY4EBoIDn
-gE6BAZSAnoCigAKBAQ2AQ4AZgQG5gQEEgK+ASYEBOIEBv4EBsYEBxoEByoDkgC6AR4EBb4EBiYA2gQGN
-gM+AMoCxgKCAV4AxgEKBAVyBAQ6BARaAloEBeYBqgQF4gBiAgIDwgLOAtYBFgQEDgQGHgN6BAY6ACoEB
-uoBYgQHbgPSBAYCBATCBAceBAWuAyYEB14B5gQEagQGbgLeBAXSBASeAeIEBF4ApgOKAlID7gGyA+oEB
-g4EBzoCagQHggGmBAZiAOYEBcIEBJoEBvoCHgHGAQYDvgQFqgCaAgoEBSoD1gQFYgQEpgOyAxYA1gQFC
-gQFOgGiAqICtgAuAbYEB4oEBrYD4gHaAPIEBEYEBGYEB2IEBMoEBk4EBEoEBCYEBPoBdgQFBgQFzgQGj
-gQHTgIWBAUWAwYCYgQEugHOA0YEBYYC+gQFVgLmBAc+BAaKA/oBRgMeAy4AqgJyAzYAagQF7gOaA64EB
-N4EBj4EByIEBE4DDgFCBAYuA6IEBwoEBHYEBW4A7gHCBATOA44EBCIBggEuBAYKBATqBAT+ADIAcgKuA
-/4Dd0gAOAEUG8AtFgQHsrxC1C0YLRwtIC0kLSgtLC0wLTQtOC08LUAtRC1ILUwtUC1ULVgtXC1gLWQta
-C1sLXAtdC14LXwtgC2ELYgtjC2QLZQtmC2cLaAtpC2oLawtsC20LbgtvC3ALcQtyC3MLdAt1C3YLdwt4
-C3kLegt7C3wLfQt+C38LgAuBC4ILgwuEC4ULhguHC4gLiQuKC4sLjAuNC44LjwuQC5ELkguTC5QLlQuW
-C5cLmAuZC5oLmwucC50LngufC6ALoQuiC6MLpAulC6YLpwuoC6kLqgurC6wLrQuuC68LsAuxC7ILswu0
-C7ULtgu3C7gLuQu6C7sLvAu9C74LvwvAC8ELwgvDC8QLxQvGC8cLyAvJC8oLywvMC80LzgvPC9AL0QvS
-C9ML1AvVC9YL1wvYC9kL2gvbC9wL3QveC98L4AvhC+IL4wvkC+UL5gvnC+gL6QvqC+sL7AvtC+4L7wvw
-C/EL8gvzC/QL9Qv2C/cL+Av5C/qBAnCBAnGBAnKBAnOBAnSBAnWBAnaBAneBAniBAnmBAnqBAnuBAnyB
-An2BAn6BAn+BAoCBAoGBAoKBAoOBAoSBAoWBAoaBAoeBAoiBAomBAoqBAouBAoyBAo2BAo6BAo+BApCB
-ApGBApKBApOBApSBApWBApaBApeBApiBApmBApqBApuBApyBAp2BAp6BAp+BAqCBAqGBAqKBAqOBAqSB
-AqWBAqaBAqeBAqiBAqmBAqqBAquBAqyBAq2BAq6BAq+BArCBArGBArKBArOBArSBArWBAraBAreBAriB
-ArmBArqBAruBAryBAr2BAr6BAr+BAsCBAsGBAsKBAsOBAsSBAsWBAsaBAseBAsiBAsmBAsqBAsuBAsyB
-As2BAs6BAs+BAtCBAtGBAtKBAtOBAtSBAtWBAtaBAteBAtiBAtmBAtqBAtuBAtyBAt2BAt6BAt+BAuCB
-AuGBAuKBAuOBAuSBAuWBAuaBAueBAuiBAumBAuqBAuuBAuyBAu2BAu6BAu+BAvCBAvGBAvKBAvOBAvSB
-AvWBAvaBAveBAviBAvmBAvqBAvuBAvyBAv2BAv6BAv+BAwCBAwGBAwKBAwOBAwSBAwWBAwaBAweBAwiB
-AwmBAwqBAwuBAwyBAw2BAw6BAw+BAxCBAxGBAxKBAxOBAxSBAxWBAxaBAxeBAxiBAxmBAxqBAxuBAxyB
-Ax2BAx6BAx+BAyCBAyGBAyKBAyOBAyQRASsRAhIRAR4SAAGIHhEBdxEBDhEBfREBhhA6EQIWEBcSAAGI
-vRIAAYi/EQJDEQEHEQFeEQFyEDgQiBEBbREBYhEBIxCDEgADDmcQkBEBDREBMREBrREBhBEBrxECIxEC
-DhEBihEBexEBpxIAAYgNEQIfEQGAEQGqEQFzEQIXEJERAYwSAAGIIREBJREBixD1EMsRAXASAAGIEBIA
-AYgTEQGwEQIkEKARAhwQwxAdEQF8EQGjEQIlEQGIEQGsEQIhEIYSAAGIGBCcEPQRASQSAAGHyxEBcRCr
-EQE2EQGSEQGJELMRAZERAYEQzBEBERDOEIEQXBIAAYgiE//////////9ENARATURAg8QlhEBNxCPEgAB
-iBQRAWsRAY0QzREBrhDEEQFcEQEnEQIgEQEqEgABh9YQBRIAAYgWEQIMEQEoEQEpEQEEEQFdEgABiAwQ
-pBEBEBEBHRIAAYfHEQIiEQGFEQIUEQGmEQEwEBMRAhsQyhEBpRCeEQGPEQGzELAQnRCjEQF0EgAElQcR
-AWERAYIRAbESAAGICxIAAYgbEQI/EQFgEQI+EgABiBERAhgQtRCyEQF+EQF4EQF5EKwRAh0SAAGIGREB
-XxIAAYfFEQFBEM8RAS4RAhoQlREBpBEBdhEBjhECExA5EIISAAGHxBECPRECFREBhxECGREBNBC0EQF/
-EgABiBcRAT4SAAGHwxEBgxCpEgABiBIRAWwQrRCv0gAOAEUATQyvgD6g0gAOAEUG8AyygQHsoNIADgBF
-BvAMtYEB7KDSADoAOwy3DLiiDLgAP15OU0lCT2JqZWN0RGF0YQAIABkAIgAnADEAOgA/AEQAUgBUAGYG
-vAbCBw0HFAcbBykHOwdXB2UHcQd9B4sHlgekB8AHzgfhB/MIDQgXCCQIJggpCCwILwgyCDQINwg5CDwI
-PwhCCEUIRwhJCEwITwhUCFcIYAhsCG4IcAh5CIMIhQiTCJwIpQiwCLcIyQjSCNsI5AjpCPgJCwkUCR8J
-IQkiCSsJMgk/CUUJTglQCcEJwwnFCccJyQnLCc0JzwnRCdMJ1QnXCdkJ2wndCd8J4QnjCeUJ5wnpCesJ
-7QnvCfEJ9An3CfoJ/QoACgMKBgoJCgwKDwoSChUKGAobCh4KIQokCicKKgotCjAKMwo2CjkKPAo/CkIK
-RQpICksKTgpbCmQKbApuCnAKcgqTCpsKrwq6CsgK0grfCuYK6ArqCu8K8Qr2CvgK+gr8CwkLFQsXCxoL
-HQskCyULMgtBC0MLRQtHC08LYQtqC28LgguPC5ELkwuVC6gLsQu2C8ELyQvSC9kL8QwADBEMHwwhDCMM
-JQwnDEQMVgxeDGUMbgx4DIQMhgyIDIoMjAyPDJAMkgynDLIMtAy2DLgMugzTDQgNFA0qDT8NTg1hDXMN
-fg2IDZYNqA21DcMNyA3KDcwNzg3QDdIN1A3WDdgN2g3cDd4N4w4DDhQOGw4iDisOLQ42DjgOOw5IDlEO
-Vg5dDmYOcg50DnYOfw6IDo0Oow6sDrUOwg7PDtgO4w7sDvYO/Q8JDxIPFA8WDyQPMw9AD0IPRA9GD2cP
-aQ9rD20Pbw9xD3MPfg+AD4sPnA+eD6APog+kD60Ptg+9D9QP5Q/nD+kP6w/tD/4QABACEAQQBhALEBQQ
-FhAbEB0QHxBIEFYQYxBlEGcQaBBqEGsQbRBvEHEQmhCkEK0QrxCxELMQtRC3ELkQuxC9EMoQ2RDmEOgQ
-6hDsEPUQ9xD8EP4RABEpESsRLREuETARMREzETURNxFYEVoRXBFeEWARYhFkEXkRghGJEZgRoBGpEa4R
-txHIEcoRzBHOEdAR7RHvEfER8xH1EfYR+BIREhMSFRIXEhkSGxIzEmgSahJsEm4ScBJyEnQSdhKQEqES
-oxKlEqcSqRLGEsgSyhLMEs4SzxLREuYS6BLqEuwS7hMHEzwTPhNAE0ITRBNGE0gTShNzE34TjxORE5MT
-lROXE6oTuxO9E78TwRPDE+AT4hPkE+YT6BPpE+sUBBRTFHAUghSUFKkUtxTAFMEUwxTFFMcUyRTLFM0U
-zxTRFNMU1RTWFNcU2hTdFN8U5BT1FPcU+RT7FQQVBhUPFREVQhVLFVEVWRVbFV0VXxVhFWMVZRVnFWkV
-chV/FYEVgxWFFZIVphWvFbEVvBXFFccV0BXSFdQV1hXYFgUWBxYJFgsWDRYPFhEWExYVFhcWIhZPFlEW
-UxZVFlcWWRZbFl0WXxZhFmsWmBaaFpwWnhagFqIWpBamFqgWqhazFrwWyRbdFuwW9RcCFxAXIRcjFyUX
-JxcpF1IXVBdWF1cXWRdaF1wXXhdgF3EXcxd2F3kXfBePF6AXohekF6YXqBfRF9MX1RfWF9gX2RfbF90X
-3xfsF+4X8BfzGAIYExgVGBcYGRgbGDgYOhg8GD4YQBhBGEMYXBiRGJMYlRiXGJkYmxidGJ8YvBjJGNoY
-3BjeGOAY4hjoGPkY+xj9GP8ZARlAGU0ZZhlzGYkZlxmhGa8ZyBnVGd8Z8RoFGg8aGxodGh8aIRojGiUa
-JxosGi4aMBoyGjQaNho4GlMaZRptGnYaeBp9GpoapRq6GsYayBrKGswazhrXGtka3BreGw8bHhsoGzwb
-VRttG28bcRtzG3Ubdxt5G3obfBt9G38biBuKG40bjxuYG5obqRurG60brxuxG7MbtRu3G9Qb1hvYG9ob
-3BvdG98b9xwYHCwcOBw6HDwcPhxAHEIcRxxJHLMcxBzGHM8c0RzUHOkc8Rz+HQodGB0aHRwdHh0gHSId
-KR02HUMdSx1NHVkdYh1nHXwdfh2AHYIdhB2XHaQdph2pHbIdux3NHdYd4R3tHgoeDB4OHhAeEh4THhUe
-LR5OHlAeUh5UHlYeWB5aHmMegB6CHoQehh6IHokeix6kHsUexx7JHssezR7PHtEfCB8lHycfKR8rHy0f
-Lh8wH0kffh+AH4IfhB+GH4gfih+MH58fvB++H8Afwh/EH8Ufxx/gIAEgAyAFIAcgCSALIA0gdCCNIJYg
-nSC1IL4gwCDHIMkgyyDNIOYg8yD9IP8hASEDIQUhByEJIRIhFCEWIR8hISEuITAhMiE0ITYhOCE6IVch
-WSFbIV0hXyFgIWIheiGbIZ0hnyGhIaMhpSGnIhAiLSIvIjEiMyI1IjYiOCJRInIidCJ2IngieiJ8In4i
-2CL1Ivci+SL7Iv0i/iMAIxkjTiNQI1IjVCNWI1gjWiNcI38jnCOeI6AjoiOkI6UjpyPAI+Ej4yPlI+cj
-6SPrI+0kLiQ0JD0kQiRQJGkkayRtJG8kcSRzJHUkfiSAJIIkiSSeJKAkoiSkJKYkqCSxJLMkviTAJMIk
-xCTGJMgk5STnJOkk6yTtJO4k8CUlJSclKSUrJS0lLyUxJTMlTiVrJW0lbyVxJXMldCV2JY8lsCWyJbQl
-tiW4JbolvCZpJoYmiCaKJowmjiaPJpEmqSbKJswmzibQJtIm1CbWJ3InjyeRJ5MnlSeXJ5gnmieyJ9Mn
-1SfXJ9kn2yfdJ98oFigfKCgoMSg8KFQoXyhpKHIodyiKKJYooyilKKcoqSjKKMwozijQKNIo1CjWKNoo
-3CjhKPIo9Cj2KPgo+ikLKQ0pDykRKRMpNCk2KTgpOik8KT4pQClNKV4pYCliKWQpZimDKYUphymJKYsp
-jSmPKaApoimlKagpqym1KcQp1SnXKdkp2yndKf4qACoCKgQqBioIKgoqHyoxKkIqRCpGKkgqSiprKm0q
-bypxKnMqdSp3KoQqhiqUKqUqpyqpKqsqrSrOKtAq0irXKtkq2yrdKt8q9CsNKx4rICsiKyQrJis6K0sr
-TStPK1ErUyt0K3YreCt6K3wrfiuAK4wrmSumK6grqiutK84r0CvTK9Yr2CvaK9wr4SvjK+kr+iv8K/4s
-ASwELCUsJywqLC0sLywxLDMsPCw+LEksVixYLFssXix/LIEshCyHLIksiyyNLJIslCyaLKssrSyvLLIs
-tSzWLNgs2yzdLN8s4SzjLO8tCC0ZLRstHS0gLSMtRC1GLUktSy1NLU8tUi1fLWEtZC1nLXAtei2LLY0t
-jy2RLZMtpC2mLagtqi2tLcAt0S3TLdUt2C3bLfgt+y39LgAuAy4GLgcuCi4fLiEuIy4mLikuQy54Lnou
-fS6ALoMuhi6ILosukC6ZLqMutC62Lrkuwy7MLs4u1y7ZLvEvAi8ELwYvCC8LLxovKy8tLy8vMi81L1Iv
-VS9XL1ovXS9eL2Evey+wL7IvtS+4L7svvi/AL8MvzC/VL9cv4C/iL/QwBTAHMAkwCzAOMC4wPzBBMEMw
-RTBIMFIwYzBlMGcwajBtMI4wkDCTMJYwmDCaMJwwqDCrMLgwyTDLMM0w0DDTMPAw8zD1MPgw+zD+MP8x
-AjEaMU8xWDFaMVwxXzFiMWUxZzFqMW8xeDF6MY0xnjGgMaIxpDGmMbcxuTG7Mb0xwDHMMd0x3zHiMeQx
-5zI2MlgyZTJ6MocyoTK9Mtgy5DMDMxIzHjMhMyQzKTMsMy8zMDMzMzwzRTNIM0kzTDNPM1IzWzOEM44z
-mDOiM7AzszO2M7kzuzO+M8EzxDPHM8ozzTPYM/Ez/TQANAM0BjQJNAw0NTQ4NDs0PjRBNEQ0RzRKNE00
-VzRgNGk0fTSSNJU0mDSbNJ400zTfNOg0+zUINRQ1IjUlNSg1KzUuNTA1MzU2NUk1TDVPNVI1VTVYNW81
-eDWBNY81mDWaNaE1pDWnNao10zXiNe819zYCNhE2HDYnNjQ2NTY4Njs2RDZHNlA2WTZaNl02ejZ/NoI2
-hTaINoo2jTaSNp82oTatNsI2xDbGNsk2yzbdNuY28TcFNyI3JzcpNyw3LjcxNzM3QDdCN0U3TjdTN2E3
-ijeLN443kTeaN503pjenN6o3xzfKN8030DfSN9U33Tf6N/w3/zgBOAQ4BjgvODA4Mzg2OD84QjhLOEw4
-TzhsOG84cjh1OHc4ejiDOJg4mjidOKA4ojiuOM840TjUONc42jjbON047jjwOPk4+zkQORI5FDkXORk5
-MjlHOUk5TDlPOVE5WzloOWo5bzl4OYM5jjmfOaE5ozmmOak5zjnQOdM51jnYOdo53DneOec56TnvOgA6
-AjoEOgc6CjovOjE6NDo2Ojg6Ojo8OkU6XjprOm06cDpzOpQ6ljqZOpw6njqgOqI6qDqqOrE6wjrEOsY6
-yTrMOuk67DruOvE69Dr1Ovg7EjtHO0k7TDtPO1I7VTtXO1o7YTtqO2w7dTt3O4w7nTufO6E7ozumO7I7
-wzvFO8c7yjvNO+478DvzO/Y7+Dv6O/w8CzwNPBk8KjwsPC48MDwzPEg8WTxbPF08XzxiPH88kDySPJQ8
-ljyZPLE8wjzEPMY8yDzKPNs83TzfPOI85T0GPQg9Cz0OPRA9Ej0UPSY9KT08PU09Tz1RPVQ9Vz14PXo9
-fT2APYI9hD2GPZg9mj2tPb49wD3CPcU9yD3lPeg96j3tPfA98T30Pgw+QT5DPkY+ST5MPk8+UT5UPls+
-ZD5mPm8+cT6GPpc+mT6bPp0+oD6sPrk+uz6+PsE+4j7kPuc+6j7sPu4+8D71Pvc+/T8GPwlABkAJQAxA
-DkAQQBJAFEAWQBlAG0AdQB9AIUAkQCdAKUArQC5AMUA0QDdAOkA8QD5AQEBCQERARkBIQEpATUBQQFJA
-VUBXQFlAW0BdQF9AYUBjQGZAaEBrQG5AcUBzQHZAeEB7QH5AgECDQIZAiECKQI1AkECSQJVAl0CZQJxA
-n0ChQKNApUCnQKpArECvQLJAtEC2QLhAu0C+QMBAwkDEQMZAyUDMQM5A0UDUQNdA2UDcQN9A4UDkQOZA
-6EDqQOxA70DxQPRA9kD5QPtA/UD/QQFBA0EFQQdBCkENQRBBE0EVQRdBGkEdQSBBIkElQSdBKUEsQS5B
-MEEyQTRBPUE/QUxBT0FSQVVBWEFbQV5BZ0FpQXRBd0F6QX1BgEGDQYxBjkGRQZRBrEG1Qb5ByUHqQfRB
-90H6Qf1CAEIDQgZCD0IoQjVCPkJJQlRCeUJ8Qn9CgkKFQohCi0KUQqxCtUK3QrpCvULTQuxC9UL+QwtD
-IkMrQy1DMkM0QzZDX0NhQ2NDZkNoQ2pDbENvQ3JDg0OFQ4hDi0OOQ5JDm0OdQ7ZDuEO7Q75DwUPEQ8ZD
-yUPMQ89D0kPVQ9hEAUQDRAVEBkQIRAlEC0QNRA9EOEQ6RD1EQERCRERERkRIREtEVERlRGdEakRtRHBE
-eUR7RIREhkSHRJlEwkTERMZEx0TJRMpEzETORNBE+UT7RP1E/kUARQFFA0UFRQdFMEUyRTRFNUU3RThF
-OkU8RT5FS0V0RXZFeEV6RXxFfkWARYNFhkWPRZFFmEWhRaNFtkW5RbtFvUXARcNFxkXJRctFzUX2RfhF
-+kX7Rf1F/kYARgJGBEYtRi9GMUYyRjRGNUY3RjlGO0ZKRlNGXEZeRmlGbEZvRnJGdUZ4RqFGo0alRqhG
-qkasRq5GsUa0RrlGwkbERtVG2EbaRt1G30biRuVG50bpRxJHFEcWRxdHGUcaRxxHHkcgR0lHS0dNR1BH
-UkdUR1ZHWUdcR4VHh0eKR41Hj0eRR5NHlkeZR55Hp0epR6xHr0e7R8RHxkfJSAhIC0gNSBBIE0gWSBlI
-G0geSCFIJEgmSClILEhHSF5IZ0hpSHJIe0iASIlIjEmJSYxJj0mRSZNJlkmYSZpJnEmeSaBJokmkSadJ
-qUmrSa1JsEmySbVJt0m6SbxJvknAScJJxEnGSchJyknNSc9J0UnUSddJ2UnbSd1J30nhSeNJ5UnnSepJ
-7EnuSfBJ8kn0SfdJ+kn8Sf5KAUoDSgVKB0oJSgtKDUoPShFKE0oVShdKGUobSh1KIEoiSiVKKEoqSixK
-LkoxSjRKNko4SjpKPEo+SkFKQ0pGSklKS0pNSk9KUkpUSldKWUpbSl1KX0piSmRKZ0ppSmtKbUpvSnFK
-c0p1SndKeUp8Sn5KgEqDSoVKiEqLSo5KkUqTSpVKl0qZSpxKn0qhSqNKpUquSrFLsEuzS7ZLuEu6S7xL
-vkvAS8NLxUvHS8lLy0vNS9BL00vWS9lL20veS+BL40vmS+hL6kvsS+5L8EvyS/RL90v5S/xL/0wBTANM
-BUwHTAlMC0wNTA9MEkwUTBdMGkwdTCBMIkwlTChMK0wtTDBMMkw0TDZMOUw8TD5MQExDTEVMSExLTE1M
-T0xRTFNMVkxYTFtMXkxgTGJMZExnTGpMbUxvTHFMc0x2THhMekx9TIBMg0yFTIhMi0yOTJBMkkyUTJdM
-mUybTJ1MoEyiTKVMp0ypTKtMrUyvTLJMtEy2TLlMvEy/TMFMw0zFTMhMy0zOTNFM00zVTNhM2kzcTN5M
-4EzpTOxN603uTfFN9E33TfpN/U4ATgNOBk4JTgxOD04SThVOGE4bTh5OIU4kTidOKk4tTjBOM042TjlO
-PE4/TkJORU5ITktOTk5RTlROV05aTl1OYE5jTmZOaU5sTm9Ock51TnhOe05+ToFOhE6HTopOjU6QTpNO
-lk6ZTpxOn06iTqVOqE6rTq5OsU6zTrZOuU68Tr9Owk7FTshOy07OTtFO1E7XTtpO3U7gTuNO5k7pTuxO
-707yTvVO+E77Tv5PAU8ETwdPCk8NTxBPE08WTxlPHE8fTyJPJU8oTytPLk8xTzRPN086Tz1PQE9DT0ZP
-SU9MT09PUk9VT1hPW09eT2FPZE97T4pPrk/jT/lQEFAoUEZQZ1DgUO1Q9FD7UQ1RJFE5UU9Re1GSUfpS
-FVIhUjxSWVKeUqdTE1OIU6NTvVPjU/1UFFQxVD9UTFRnVJZUx1TvVQFVFVUoVUJVTlVlVXBVfFWTVaxV
-+1YPVs5W51cBVx5XKldzV39Xi1ejV7pXxlhCWGtYlFigWMFY2ljzWRRZHllHWW5ZhFmRWalZvlnKWd5a
-WVqIWp1atFrHWuBa81sGWxpbklutW/JcBFwvXHhckVylXPhdBF2/Xd1eh16gXr9e1l+EX5BfnF+6X+Ff
-7F/5YBNgJWA5YFNgimCiYLdgw2DxYWhhe2GEYYdhiGGRYZRhlWGeYaFjDmMRYxRjF2MZYxtjHWMfYyJj
-JGMmYyljK2MtYy9jMmM0YzZjOWM8Yz5jQGNDY0ZjSWNMY09jUWNTY1VjWGNbY11jYGNiY2RjZmNoY2pj
-bGNuY3FjdGN3Y3ljfGN+Y4Fjg2OFY4djiWOLY41jkGOTY5VjmGOaY51jn2OiY6Rjp2OqY61jsGOyY7Vj
-t2O6Y71jv2PCY8Vjx2PKY8xjzmPQY9Jj1GPWY9lj3GPeY+Fj42PmY+hj62PuY/Fj82P1Y/dj+WP8Y/5k
-AGQDZAVkCGQLZA1kD2QRZBRkF2QZZBtkHWQfZCFkJGQnZClkK2QtZDBkM2Q2ZDlkPGQ/ZEJkRWRHZEpk
-TWRQZFNkVWRYZFpkXGRfZGFkY2RmZGhka2RtZHBkc2R1ZHdkeWR7ZH1kf2SBZINkhmSIZIpkjWSQZJNk
-lmSYZJpknWSfZKJkpWSoZKpkrGSvZLFktGS2ZLhku2S+ZMFkw2TFZMdkyWTLZNRk12ZEZkdmSmZNZlBm
-U2ZWZllmXGZfZmJmZWZoZmtmbmZxZnRmd2Z6Zn1mgGaDZoZmiWaMZo9mkmaVZphmm2aeZqFmpGanZqpm
-rWawZrNmtma5Zrxmv2bCZsVmyGbLZs5m0WbUZtdm2mbdZuBm42bmZulm7GbvZvJm9Wb4Zvtm/mcBZwRn
-B2cKZw1nEGcTZxZnGWccZx9nImclZyhnK2cuZzFnNGc3ZzpnPWdAZ0NnRmdJZ0xnT2dSZ1VnWGdbZ15n
-YWdkZ2dnamdtZ3Bnc2d2Z3lnfGd/Z4JnhWeIZ4tnjmeRZ5Rnl2eaZ51noGejZ6ZnqWesZ69nsme1Z7hn
-u2e+Z8FnxGfHZ8pnzWfQZ9Nn1mfZZ9xn32fiZ+Vn6GfrZ+5n8Wf0Z/dn+mf9aABoA2gGaAloDGgPaBJo
-FWgYaBtoHmghaCRoJ2gqaC1oMGgzaDZoOWg8aD9oQmhFaEhoS2hOaFFoVGhXaFpoXWhgaGNoZmhpaGxo
-cWh0aHdoemh9aH9ogmiEaIlojmiRaJRol2iaaJxonmihaKRop2ipaK5osGizaLZouWi8aL9owmjFaMho
-y2jOaNNo1mjZaNxo32jiaORo52jsaO9o8mj0aPZo+Wj+aQNpBmkJaQtpDmkQaRJpFWkYaRtpHmkhaSRp
-JmkraS1pL2kyaTdpOmk8aT9pQmlFaUdpSmlNaU9pUmlUaVZpWGldaWZpaGlraW5pcGlzaXVpeml9aYBp
-gmmFaYdpimmNaZBpk2mYaZppn2miaaVpqGmraa5ps2m1abhpu2nAacNpxmnJacxpz2nRadRp1mnZadtp
-3mnhaeNp5Wnnaepp72nyafVp+Gn9agJqBWoIagtqEGoTahVqF2oaah1qIGoiaiVqKmotajJqNWo3ajpq
-PWo/akJqRWpIaktqTWpPalRqV2paal1qYGpjamVqaGptanBqdWp4anpqf2qCaoRqhmqPapFqkmqbap5q
-n2qoaqtqrGq1aroAAAAAAAACAgAAAAAAAAy5AAAAAAAAAAAAAAAAAABqyQ</bytes>
+ZSB0aGUgTWV0YSBtb2RpZmllci7UAA4BLwCTATABMQUFATMFB4ArI0AmAAAAAAAAgCoRDBzVAA4FCQUK
+BQsFDAUNBQ4FDwUQBRFXTlNDb2xvclxOU0NvbG9yU3BhY2VbTlNDb2xvck5hbWVdTlNDYXRhbG9nTmFt
+ZYEBIIEBHxAGgQEegQEdVlN5c3RlbVxjb250cm9sQ29sb3LTAA4FCgUVBQ0B4gUXV05TV2hpdGWBASBL
+MC42NjY2NjY2OQDSADoAOwUZBQmiBQkAP9UADgUJBQoFCwUMBQ0FHAUPBR0FEYEBIIEBI4EBIoEBHV8Q
+EGNvbnRyb2xUZXh0Q29sb3LTAA4FCgUVBQ0B4gUigQEgQjAA0gA6ADsFJAUlpAUlAUUA/wA/XxAPTlNU
+ZXh0RmllbGRDZWxs0gA6ADsFJwUopQUoAUkBSgFLAD9bTlNUZXh0RmllbGTXAP0ADgD+AP8BAAEBAQIB
+gQTyBSwFLQEQAKsBgYBDgQElgQEngQEoCYBDXxAWe3szNiwgMjA4fSwgezM4NSwgMjl9fdgBFAAOBPkB
+GgEbARwBHgT6ASAE+wT8BTQE/gTqBQAFAYEBJIEBHIEBKYEBG4EBJoEBIV8QV0hvbGQgT3B0aW9uIGFu
+ZCBDb21tYW5kIHdoaWxlIGNsaWNraW5nIHRvIGFjdGl2YXRlIHRoZSBtaWRkbGUgYW5kIHJpZ2h0IG1v
+dXNlIGJ1dHRvbnMuCtcA/QAOAP4A/wEAAQEBAgGBBPIFPAU9ARAAqwGBgEOBASWBASuBASwJgENfEBZ7
+ezM2LCAxNTl9LCB7Mzg1LCAxNH192AEUAA4E+QEaARsBHAEeBPoBIAT7BPwFRAT+BOwFAAUBgQEkgQEc
+gQEtgQEbgQEqgQEhXxA+QWxsb3dzIGlucHV0IG1lbnUgY2hhbmdlcyB0byBvdmVyd3JpdGUgdGhlIGN1
+cnJlbnQgWDExIGtleW1hcC7XAP0ADgD+AP8BAAEBAQIBgQTyBUwFTQEQAKsBgYBDgQElgQEvgQEwCYBD
+XxAVe3szMywgMzJ9LCB7Mzg1LCAzMX192AEUAA4E+QEaARsBHAEeBPoBIAT7BPwFVAT+BO8FAAUBgQEk
+gQEcgQExgQEbgQEugQEhXxCFV2hlbiBlbmFibGVkLCBjbGlja2luZyBvbiBhbiBpbmFjdGl2ZSB3aW5k
+b3cgd2lsbCBjYXVzZSB0aGF0IG1vdXNlIGNsaWNrIHRvIHBhc3MgdGhyb3VnaCB0byB0aGF0IHdpbmRv
+dyBpbiBhZGRpdGlvbiB0byBhY3RpdmF0aW5nIGl0Ll8QFnt7MTAsIDMzfSwgezQzOCwgMjc5fX3SADoA
+OwVbAUqjAUoBSwA/XxAWe3sxMCwgMTB9LCB7NDU4LCAzMjV9fdIADgBFAE0FX4AfowTgBWEFYoEBNoEB
+OoEBU9YADgVkAUoFZQUJAIwFZgVnAYEBiAT8BWtcTlNJZGVudGlmaWVyWU5TVGFiVmlld4EBOYEBN4BD
+gQEUgQEcgQE40gAOADYANwVugARRMVVJbnB1dNIAOgA7BXEFcqIFcgA/XU5TVGFiVmlld0l0ZW3WAA4F
+ZAFKBWUFCQCMBWYFdQHGAYgE/AV5gQE5gQE7gFWBARSBARyBAVLSAA4ANgA3BXyABFEy0gAOAEUATQV/
+gB+nBYAFgQHCBYMFhARYBYaBAT2BAUGAVIEBRYEBSYD1gQFN1wD9AA4A/gD/AQABAQECAcYBBAWKBYsB
+EACrAcaAVYAxgQE+gQE/CYBVXxAWe3sxOCwgMTE2fSwgezQwMiwgMTh9fd0BFAAOARUBFgEXARgBGQEa
+ARsBHAEdAR4BHwEgASEAlwEjAZEBkgCXBZQBKAWAASoBlwGYgDCAD4BHgA+BAUCAKYEBPV8QF1VzZSBz
+eXN0ZW0gYWxlcnQgZWZmZWN01wD9AA4A/gD/AQABAQECAcYE8gWbBZwBEACrAcaAVYEBJYEBQoEBQwmA
+VV8QFXt7MzYsIDgyfSwgezM4NSwgMjh9fdgBFAAOBPkBGgEbARwBHgT6ASAE+wT8BaME/gWBBQAFAYEB
+JIEBHIEBRIEBG4EBQYEBIV8QZ1gxMSBiZWVwcyB3aWxsIHVzZSB0aGUgc3RhbmRhcmQgc3lzdGVtIGFs
+ZXJ0LCBhcyBkZWZpbmVkIGluIHRoZSBTb3VuZCBFZmZlY3RzIHN5c3RlbSBwcmVmZXJlbmNlcyBwYW5l
+bC7XAP0ADgD+AP8BAAEBAQIBxgTyBasFrAEQAKsBxoBVgQElgQFGgQFHCYBVXxAVe3sxNywgMjM4fSwg
+ezU1LCAyMH192AEUAA4E+QEaARsBHAEeBPoBIAT7BPwFswEoBYMFAAUBgQEkgQEcgQFIgCmBAUWBASFY
+Q29sb3JzOgrXAP0ADgD+AP8BAAEBAQIBxgTyBbsFvAEQAKsBxoBVgQElgQFKgQFLCYBVXxAWe3szNiwg
+MjE2fSwgezM5MiwgMTR9fdgBFAAOBPkBGgEbARwBHgT6ASAE+wT8BcME/gWEBQAFAYEBJIEBHIEBTIEB
+G4EBSYEBIV8QNFRoaXMgb3B0aW9uIHRha2VzIGVmZmVjdCB3aGVuIFgxMSBpcyBsYXVuY2hlZCBhZ2Fp
+bi7XAP0ADgD+AP8BAAEBAQIBxgTyBcsFzAEQAKsBxoBVgQElgQFOgQFPCYBVXxAWe3szNiwgMTQ1fSwg
+ezM4NSwgMzF9fdgBFAAOBPkBGgEbARwBHgT6ASAE+wT8BdME/gWGBQAFAYEBJIEBHIEBUIEBG4EBTYEB
+IV8QZEVuYWJsZXMgdGhlIFgxMSByb290IHdpbmRvdy4gVXNlIHRoZSBDb21tYW5kLU9wdGlvbi1BIGtl
+eXN0cm9rZSB0byBlbnRlciBhbmQgbGVhdmUgZnVsbCBzY3JlZW4gbW9kZS5WT3V0cHV01QAOAUoFZQUJ
+AIwFZgKJAYgE/AXegQE5gIKBARSBARyBAWbSAA4ARQBNBeGAH6UF4gKGBeQF5QXmgQFVgIGBAVmBAV2B
+AWHXAP0ADgD+AP8BAAEBAQICiQEEBeoF6wEQAKsCiYCCgDGBAVaBAVcJgILdARQADgEVARYBFwEYARkB
+GgEbARwBHQEeAR8BIAEhAJcBIwGRAZIAlwXzASgF4gEqAZcBmIAwgA+AR4APgQFYgCmBAVVfEBhBdXRo
+ZW50aWNhdGUgY29ubmVjdGlvbnPXAP0ADgD+AP8BAAEBAQICiQTyBfoF+wEQAKsCiYCCgQElgQFagQFb
+CYCCXxAWe3szNiwgMTk1fSwgezM4NSwgNDJ9fdgBFAAOBPkBGgEbARwBHgT6ASAE+wT8BgIE/gXkBQAF
+AYEBJIEBHIEBXIEBG4EBWYEBIV8QqkxhdW5jaGluZyBYMTEgd2lsbCBjcmVhdGUgWGF1dGhvcml0eSBh
+Y2Nlc3MtY29udHJvbCBrZXlzLiBJZiB0aGUgc3lzdGVtJ3MgSVAgYWRkcmVzcyBjaGFuZ2VzLCB0aGVz
+ZSBrZXlzIGJlY29tZSBpbnZhbGlkIHdoaWNoIG1heSBwcmV2ZW50IFgxMSBhcHBsaWNhdGlvbnMgZnJv
+bSBsYXVuY2hpbmcu1wD9AA4A/gD/AQABAQECAokE8gYKBgsBEACrAomAgoEBJYEBXoEBXwmAgl8QFnt7
+MzYsIDExOH0sIHszODUsIDQyfX3YARQADgT5ARoBGwEcAR4E+gEgBPsE/AYSBP4F5QUABQGBASSBARyB
+AWCBARuBAV2BASFfEJlJZiBlbmFibGVkLCBBdXRoZW50aWNhdGUgY29ubmVjdGlvbnMgbXVzdCBhbHNv
+IGJlIGVuYWJsZWQgdG8gZW5zdXJlIHN5c3RlbSBzZWN1cml0eS4gV2hlbiBkaXNhYmxlZCwgY29ubmVj
+dGlvbnMgZnJvbSByZW1vdGUgYXBwbGljYXRpb25zIGFyZSBub3QgYWxsb3dlZC7XAP0ADgD+AP8BAAEB
+AQICiQTyBhoGGwEQAKsCiYCCgQElgQFigQFjCYCCXxAVe3syMCwgMTd9LCB7NDA0LCAxNH192AEUAA4E
++QEaARsBHAEeBPoBIAT7BPwGIgT+BeYFAAUBgQEkgQEcgQFkgQEbgQFhgQEhXxA0VGhlc2Ugb3B0aW9u
+cyB0YWtlIGVmZmVjdCB3aGVuIFgxMSBpcyBuZXh0IGxhdW5jaGVkLlhTZWN1cml0edIAOgA7BikFZaQF
+ZQFKAUsAP1p7NDgxLCAzNDV9XxAVe3swLCAwfSwgezE0NDAsIDg3OH19WnsyMTMsIDEyOX1ZeDExX3By
+ZWZz0gA6ADsGLwYwogYwAD9fEBBOU1dpbmRvd1RlbXBsYXRlW3ByZWZzX3BhbmVs1AAOAIoAiwCMAPgA
++QDaBjaANYAygB2BAXBfEBBhcHBzX3RhYmxlX3Nob3c61AAOAIoAiwCMAI0A+QAfBjyAIoAygAKBAXJY
+ZGVsZWdhdGXUAA4AigCLAIwAjQXiAPkGQoAigQFVgDKBAXRbZW5hYmxlX2F1dGjUAA4AigCLAIwA+AAf
+AycGSIA1gAKAu4EBdl8QFmhpZGVPdGhlckFwcGxpY2F0aW9uczrUAA4AigCLAIwA+AD5Bk0GToA1gDKB
+AXiBAX7XAP0ADgD+AP8BAAEBAQIBAwEEBlIGUwZUAKsBA4AlgDGBAXmBAXoRAS8JgCVfEBV7ezM1Miwg
+MTJ9LCB7ODQsIDMyfX3dARQADgEVARYBFwEYARkBGgEbARwBHQEeAR8GWQEhBlsBIwEkASUGXQZeASgG
+TQEqASsBLBP/////hAH+AIAwgQF8gCyBAX2BAXuAKYEBeFZDYW5jZWzSAA4ANgA3ALKABNIADgA2ADcA
+soAEXxASYXBwc190YWJsZV9jYW5jZWw61AAOAIoAiwCMAPgA+QOVBjaANYAygMWBAXDUAA4AigCLAIwA
++AD5A/cGcIA1gDKA34EBgV8QEG1pbmltaXplX3dpbmRvdzrTAA4AiwCMAPgDrgZ1gDWA0oEBg1RjdXQ6
+1AAOAIoAiwCMAPgA+QZ6BnuANYAygQGFgQGL1wD9AA4A/gD/AQABAQECAQMBBAZ/BoABBwCrAQOAJYAx
+gQGGgQGHCYAlXxAXe3szNzIsIDI0N30sIHsxMDAsIDMyfX3dARQADgEVARYBFwEYARkBGgEbARwBHQEe
+AR8BIAEhBoYBIwEkASUGiAaJASgGegEqASsBLIAwgQGJgCyBAYqBAYiAKYEBhVlEdXBsaWNhdGXSAA4A
+NgA3ALKABNIADgA2ADcAsoAEXxAVYXBwc190YWJsZV9kdXBsaWNhdGU61AAOAIoAiwCMAI0FgAD5BpaA
+IoEBPYAygQGNW3VzZV9zeXNiZWVw1AAOAIoAiwCMAI0GmgD5BpyAIoEBj4AygQG33xATAP0GngAOBNMG
+nwT5BqAGoQaiBqMGpAEAAQwBAQalBqYBAganBqgGqQGXBqoGqwasBq0AqwavBrABJAaxARAGsgCrBrQB
+/AapBrYGt18QH05TRHJhZ2dpbmdTb3VyY2VNYXNrRm9yTm9uTG9jYWxcTlNIZWFkZXJWaWV3XxASTlNB
+bGxvd3NUeXBlU2VsZWN0XE5TQ29ybmVyVmlld18QF05TSW50ZXJjZWxsU3BhY2luZ1dpZHRoXxAZTlND
+b2x1bW5BdXRvcmVzaXppbmdTdHlsZV8QGE5TSW50ZXJjZWxsU3BhY2luZ0hlaWdodFtOU0dyaWRDb2xv
+cl8QHE5TRHJhZ2dpbmdTb3VyY2VNYXNrRm9yTG9jYWxeTlNUYWJsZUNvbHVtbnNbTlNSb3dIZWlnaHSB
+AZCBAbYSUkCAAIEBkoEBpAmBAZYjQAgAAAAAAAAjQAAAAAAAAACBAZEJgQGzgQGQgQGaI0AxAAAAAAAA
+2gD9AA4A/ga5AQsBAAa6BrsBAga8Br0Gvga/BsAGwQbCBpoGxAa9BppZTlNjdkZsYWdzWU5TRG9jVmll
+d1lOU0JHQ29sb3JdTlNOZXh0S2V5Vmlld4EBl4EB4YEB4BAEgQHfEQkAgQGPgQGxgQGXgQGPWnszMzMs
+IDE5N33WAP0ADgEAAQwBAgbJBsoGywEQBswGygaaW05TVGFibGVWaWV3gQGTgQGVgQGUgQGTgQGP2gD9
+AA4A/ga5AQsBAAa6BrsBAga8Br0GvgbSBsAG0wbCBqwGxAa9BqyBAZeBAeGBAemBAeiBAZKBAbGBAZeB
+AZJZezMzMywgMTd90gA6ADsG2gbbpAbbAUoBSwA/XxARTlNUYWJsZUhlYWRlclZpZXfVAP0ADgD+AQAB
+Aga9Bt4G3wEQBr2BAZeBAZmBAZiBAZfeAP0G4gAOAP4G4wahBuQBCwblAQABAgbmBrwG5wEDBukG6gbr
+BuwGrwbKBu8G8AbxAQMG8wapBqlbTlNIU2Nyb2xsZXJYTlNzRmxhZ3NfEBBOU0hlYWRlckNsaXBWaWV3
+XE5TU2Nyb2xsQW10c1tOU1ZTY3JvbGxlcl1OU0NvbnRlbnRWaWV3gCWBAeaBAeuBAeoQMoEBloEBk4EB
+3k8QEEEgAABBIAAAQZgAAEGYAAARATOAJYEB4oEBkIEBkF8QFHt7MzM0LCAwfSwgezE2LCAxN3190gA6
+ADsG+Ab5pAb5AUoBSwA/XV9OU0Nvcm5lclZpZXfSAA4ARQBNBvyAH6MG/Qb+Bv+BAZuBAaaBAaraBwEA
+DgcCBwMHBAcFBwYHBwcIBskAqwcKBwsHDAcNAeIHDgcPAKsGml5OU0lzUmVzaXplYWJsZVxOU0hlYWRl
+ckNlbGxXTlNXaWR0aFpOU0RhdGFDZWxsXk5TUmVzaXppbmdNYXNrWk5TTWluV2lkdGhaTlNNYXhXaWR0
+aFxOU0lzRWRpdGFibGUJgQGlgQGcI0BbwAAAAAAAgQGiI0BEAAAAAAAAI0CPQAAAAAAACYEBj9cBFAAO
+BPkBGgEbAR4E+gcTBxQHFQcWBP4BlwcYEgSB/gCBAaGBAZ6BAZ2BARuBAZ9UTmFtZdMADgUKBRUFDQHi
+BxyBASBLMC4zMzMzMzI5OQDVAA4FCQUKBQsFDAUNBRwFDwcgBRGBASCBASOBAaCBAR1fEA9oZWFkZXJU
+ZXh0Q29sb3LSADoAOwckByWlByUFJQFFAP8AP18QEU5TVGFibGVIZWFkZXJDZWxs2AEUAA4E+QEaARsB
+HAEeBPoHJwT7Bq0HKgEoBpoB5gUBEhQx/kCBASSBAaSBAaOAKYEBj4EBIVlUZXh0IENlbGzTAA4FCgUV
+BQ0B4gcxgQEgQjEA0gA6ADsHMwc0ogc0AD9dTlNUYWJsZUNvbHVtbtoHAQAOBwIHAwcEBwUHBgcHBwgG
+yQCrBwoHOAc5BzoB4gc7Bw8AqwaaCYEBpYEBpyNAYJdkYAAAAIEBqSNAT12RYAAAAAmBAY/XARQADgT5
+ARoBGwEeBPoHEwcUBxUHQQT+AZcHGIEBoYEBnoEBqIEBG4EBn1dDb21tYW5k2AEUAA4E+QEaARsBHAEe
+BPoHJwT7Bq0HKgEoBpoB5gUBgQEkgQGkgQGjgCmBAY+BASHaBwEADgcCBwMHBAcFBwYHBwcIBskAqwcK
+B08HUAdRAeIHUgcPAKsGmgmBAaWBAasjQFQAAAAAAACBAa8jQCQAAAAAAAAJgQGP1wEUAA4E+QEaARsB
+HgT6ASAHFAdXB1gE/gGXBxiBAaGBAa2BAayBARuBAZ9YU2hvcnRjdXTVAA4FCQUKBQsFDAUNBq0FDwdf
+BRGBASCBAaSBAa6BAR1baGVhZGVyQ29sb3LZARQADgT5ARoBGwEcAR4E1AT6BycE+wbEByoHZgaaAeYA
+qwUBgQEkgQGxgQGjgQGwgQGPCYEBIdQADgEvAJMBMAExB2wBMwE8gCsjQCgAAAAAAACAKtUADgUJBQoF
+CwUMBQ0FDgUPB3EFEYEBIIEBH4EBsoEBHV8QFmNvbnRyb2xCYWNrZ3JvdW5kQ29sb3LVAA4FCQUKBQsF
+DAUNB3YFDwd3BRGBASCBAbWBAbSBAR1ZZ3JpZENvbG9y0wAOBQoFFQUNAeIHfIEBIEQwLjUA0gA6ADsH
+fgbJpQbJAUkBSgFLAD9aYXBwc190YWJsZdQADgCKAIsAjAD4AB8DJgeEgDWAAoC4gQG5VWhpZGU61AAO
+AIoAiwCMAPgA+QP4B4qANYAygOKBAbtcem9vbV93aW5kb3c61AAOAIoAiwCMAPgA+QP+B5CANYAygOaB
+Ab1fEA9icmluZ190b19mcm9udDrUAA4AigCLAIwA+AD5BeIBp4A1gDKBAVWAUNMADgCLAIwA+AOxB5qA
+NYDYgQHAV2RlbGV0ZTrUAA4AigCLAIwAjQGmAPkHoIAigEyAMoEBwltzeW5jX2tleW1hcNQADgCKAIsA
+jAD4APkFgAGngDWAMoEBPYBQ1AAOAIoAiwCMAPgA+QRGB6uANYAygO+BAcVZeDExX2hlbHA60wAOAIsA
+jAD4A7AHsIA1gNWBAcdWcGFzdGU61AAOAIoAiwCMAI0CWwD5B7aAIoB2gDKBAcldY2xpY2tfdGhyb3Vn
+aNQADgCKAIsAjACNA/8A+Qe8gCKA6IAygQHLXxAQd2luZG93X3NlcGFyYXRvctQADgCKAIsAjAD4APkD
+KgfCgDWAMoC+gQHNVXF1aXQ61AAOAIoAiwCMAI0CoQD5B8iAIoCHgDKBAc9cZmFrZV9idXR0b25z1AAO
+AIoAiwCMAI0AnQD5B86AIoAOgDKBAdFfEBVkb2NrX3dpbmRvd19zZXBhcmF0b3LTAA4AiwCMAPgDrAfT
+gDWAzoEB01VyZWRvOtQADgCKAIsAjACNAoYA+QfZgCKAgYAygQHVWmVuYWJsZV90Y3DUAA4AigCLAIwA
++AD5B94H34A1gDKBAdeBAdzXAP0ADgD+AP8BAAEBAQIBAwEEB+MH5AZUAKsBA4AlgDGBAdiBAdkJgCVf
+EBV7ezI2OCwgMTJ9LCB7ODQsIDMyfX3dARQADgEVARYBFwEYARkBGgEbARwBHQEeAR8GWQEhAJcBIwEk
+ASUH7AftASgH3gEqASsBLIAwgA+ALIEB24EB2oApgQHXVERvbmXSAA4ANgA3ALKABF8QEGFwcHNfdGFi
+bGVfZG9uZTrSAA4ARQf1B/aBAfqvEIEDIAOsAecG/wXmAscCWwa9APkF+wUtAgsCDATvAYED/QMmAyoD
+lQGmAawF6wR8Bk0A2QTsAxEFnACdAmEFYQaABv0CcQGIBeIGrAEGB94CpwMQBeUFgAHCA/cAngK2A60C
+4gWBAMkFiwHGBgsDPwJHA/sGegOrA/4DDwMhANoDJwTqBzoAjgYbCDsCoQTgBYQHUQb+AuoCOQShAlIE
+RgFyA/gDAQbzAeABAwOuAPoFTQWGBWIBhAFXBukBXwfkBeQDJQKGAgoE6QW8CFwFPQOxBcwDIgF9BF8E
+swHJBlMC8wT0Aw0HDQR2BDcFgwMjBFgGmgMOA7AFrAP/AowBagMpAomAq4DOgFyBAaqBAWGAkYB2gQGX
+gDKBAVuBASiAZIBngQEugEOA5YC4gL6AxYBMgE6BAVeA/4EBeIAcgQEqgOqBAUOADoB4gQE6gQGHgQGb
+gHuBARSBAVWBAZKAJ4EB14CJgNqBAV2BAT2AVIDfgBeAjIDRgJqBAUGAGoEBP4BVgQFfgLKAcoDkgQGF
+gMuA5oDHgK6AHYC7gQEmgQGpgAuBAWOBAeyAh4EBNoEBSYEBr4EBpoCbgG6BAQuAc4DvgD2A4oCkgQHi
+gFuAJYDSgCSBATCBAU2BAVOARYA3gQHmgDiBAdmBAVmAt4CBgGGBAReBAUuBAfiBASyA2IEBT4CvgEKA
+94EBEoBXgQF6gJ+BARmAp4EBooD9gO2BAUWAtoD1gQGPgMKA1YEBR4DogISAPIC9gILSAA4ARQBNCHqA
+H6UGqQbzBukGygavgQGQgQHigQHmgQGTgQGW0gAOAEUATQiCgB+hBpqBAY9fEBV7ezEsIDE3fSwgezMz
+MywgMTk3fX3SADoAOwiGCIekCIcBSgFLAD9aTlNDbGlwVmlld9gA/QHxAA4A/gEAAMcBAgiJBr0GvQiM
+CI0BEAiOBr0IkFlOU1BlcmNlbnSBAZeBAZeBAeWBAeOBAeSBAZcjP+/WamAAAABfEBZ7ezMzNCwgMTd9
+LCB7MTUsIDE5N319XF9kb1Njcm9sbGVyOtIAOgA7CJQIlaUIlQFJAUoBSwA/Wk5TU2Nyb2xsZXLZAP0B
+8QAOAP4G4wEAAMcBAgiJBr0GvQiMCJoBJAEQCI4GvQidgQGXgQGXgQHlgQHngQHkgQGXIz/mCGTAAAAA
+XxAVe3sxLCAyMTR9LCB7MzMzLCAxNX190gAOAEUATQihgB+hBqyBAZJfEBN7ezEsIDB9LCB7MzMzLCAx
+N319XxAWe3syMCwgNzd9LCB7MzUwLCAyMzB9fdIAOgA7CKYIp6QIpwFKAUsAP1xOU1Njcm9sbFZpZXff
+EA8EpQAOBKYEpwSoBKkEqgSrBKwErQSuBK8EsASxBLIBAwS0CKsIrAitCK4EuQS6CLAIsQiyAZEIswi0
+CLWAJYEBbYEB8IEB9IEB94EB7oEBDoEB8YEB7YEB9hALgQH1gQHvXxAYe3syNzksIDI1M30sIHs0ODYs
+IDMyN319XxAUWDExIEFwcGxpY2F0aW9uIE1lbnXSAA4ANgA3BMWABNIADgBFAE0IvIAfpgfeBnoEdga9
+Bk0A+oEB14EBhYD9gQGXgQF4gCRaezQ4NiwgMzI3fVh4MTFfYXBwc9IADgAyADMIx4AFgQH50gA6ADsI
+yQDvogDvAD/SAA4ARQf1CMyBAfqvEIEBXwLqAckGmgKJAXIBgQEDAB8F5ATqAecB5wGBBOABcgFfAV8C
+UgGBAaYF4gR2AQMAyQGBAwEFgQCOAlsBiAZ6BpoBcgSzAokGvQD6AQMCoQMBAokBxgHGAXIAjgFfAuoC
+6gHGAJ4FgAVhBeUDIgJSAXIBAwLqAXIDAQFfAMkBXwGBBv4AHwXmAB8BgQGIAcYG/waaAw8BXwAfAw4E
+NwMQAXIAHwa9AecIOwLqAQME7wHGAYgBfQFfBr0DDQfeAokBXwKJAecBgQWEAB8E7ALqBYYBXwGBBFgE
+oQHCBk0C6gTpAwEG/QEDAxEBxgFfAcYGvQMBAuoFgwFyAoYBcgFfBWKAOICbgFeBAY+AgoA9gEOAJYAC
+gQFZgQEmgFyAXIBDgQE2gD2AOIA4gHOAQ4BMgQFVgP2AJYAagEOApIEBQYALgHaBARSBAYWBAY+APYEB
+EoCCgQGXgCSAJYCHgKSAgoBVgFWAPYALgDiAm4CbgFWAF4EBPYEBOoEBXYCvgHOAPYAlgJuAPYCkgDiA
+GoA4gEOBAaaAAoEBYYACgEOBARSAVYEBqoEBj4DHgDiAAoDCgO2A2oA9gAKBAZeAXIEB7ICbgCWBAS6A
+VYEBFIBCgDiBAZeAp4EB14CCgDiAgoBcgEOBAUmAAoEBKoCbgQFNgDiAQ4D1gQELgFSBAXiAm4EBF4Ck
+gQGbgCWA6oBVgDiAVYEBl4CkgJuBAUWAPYCBgD2AOIEBU9IADgBFB/UJUIEB+q8QggMgA6wG/wHnBeYC
+xwa9AlsA+QX7BS0CCwIMBO8BgQP9AyYDKgOVBHwBpgGsBesGTQDZBOwDEQWcAJ0FYQaAAmEG/QGIAnEF
+4gasAQYH3gKnAxAF5QWAAJ4D9wHCArYAHwOtAuIFgQDJBYsBxgYLAz8CRwZ6A/sDqwP+Aw8DIQDaAycE
+6gCOBzoGGwg7AqEE4AWEB1EG/gLqAjkEoQJSBEYBcgP4AwEG8wEDAeADrgD6BWIFhgVNBukBVwfkAV8B
+hAXkAyUChgIKBOkFvAhcBcwDsQU9AyIBfQRfBLMByQZTAvMHDQMNBPQEdgQ3BYMDIwRYBpoDDgOwBawD
+/wKMAWoDKQKJgKuAzoEBqoBcgQFhgJGBAZeAdoAygQFbgQEogGSAZ4EBLoBDgOWAuIC+gMWA/4BMgE6B
+AVeBAXiAHIEBKoDqgQFDgA6BATqBAYeAeIEBm4EBFIB7gQFVgQGSgCeBAdeAiYDagQFdgQE9gBeA34BU
+gIyAAoDRgJqBAUGAGoEBP4BVgQFfgLKAcoEBhYDkgMuA5oDHgK6AHYC7gQEmgAuBAamBAWOBAeyAh4EB
+NoEBSYEBr4EBpoCbgG6BAQuAc4DvgD2A4oCkgQHigCWAW4DSgCSBAVOBAU2BATCBAeaAN4EB2YA4gEWB
+AVmAt4CBgGGBAReBAUuBAfiBAU+A2IEBLICvgEKA94EBEoBXgQF6gJ+BAaKAp4EBGYD9gO2BAUWAtoD1
+gQGPgMKA1YEBR4DogISAPIC9gILSAA4ARQf1CdWBAfqvEIIJ1gnXCdgJ2QnaCdsJ3AndAU4J3wngCeEJ
+4gnjCeQJ5QnmCecJ6AnpCeoJ6wnsCe0J7gnvCfAJ8QnyCfMJ9An1CfYJ9wn4CfkJ+gn7CfwJ/Qn+Cf8K
+AAoBCgIKAwoECgUKBgoHCggKCQoKCgsKDAoNCg4KDwoQChEKEgoTChQKFQoWChcKGAoZChoKGwocCh0K
+HgofCiAKIQoiCiMKJAolCiYKJwMGCikKKgorCiwKLQouCi8KMAoxCjIKMwo0CjUKNgo3CjgKOQo6CjsK
+PAo9Cj4KPwpACkEKQgpDCkQKRQpGCkcKSApJCkoKSwpMCk0KTgpPClAKUQpSClMKVApVClYKV4EB/oEB
+/4ECAIECAYECAoECA4ECBIECBYAzgQIGgQIHgQIIgQIJgQIKgQILgQIMgQINgQIOgQIPgQIQgQIRgQIS
+gQITgQIUgQIVgQIWgQIXgQIYgQIZgQIagQIbgQIcgQIdgQIegQIfgQIggQIhgQIigQIjgQIkgQIlgQIm
+gQIngQIogQIpgQIqgQIrgQIsgQItgQIugQIvgQIwgQIxgQIygQIzgQI0gQI1gQI2gQI3gQI4gQI5gQI6
+gQI7gQI8gQI9gQI+gQI/gQJAgQJBgQJCgQJDgQJEgQJFgQJGgQJHgQJIgQJJgQJKgQJLgQJMgQJNgQJO
+gKWBAk+BAlCBAlGBAlKBAlOBAlSBAlWBAlaBAleBAliBAlmBAlqBAluBAlyBAl2BAl6BAl+BAmCBAmGB
+AmKBAmOBAmSBAmWBAmaBAmeBAmiBAmmBAmqBAmuBAmyBAm2BAm6BAm+BAnCBAnGBAnKBAnOBAnSBAnWB
+AnaBAneBAniBAnmBAnqBAnuBAnyBAn1fEBpNZW51IEl0ZW0gKFByZWZlcmVuY2VzLi4uKV8QEE1lbnUg
+SXRlbSAoUmVkbylfEBdUYWJsZSBDb2x1bW4gKFNob3J0Y3V0KV8QEU1lbnUgKE90aGVyVmlld3MpXxBC
+U3RhdGljIFRleHQgKFRoZXNlIG9wdGlvbnMgdGFrZSBlZmZlY3Qgd2hlbiBYMTEgaXMgbmV4dCBsYXVu
+Y2hlZC4pXxApTWVudSBJdGVtIChSZXZlcnNlIEN5Y2xlIFRocm91Z2ggV2luZG93cylbU2Nyb2xsIFZp
+ZXdfECpDaGVjayBCb3ggKENsaWNrLXRocm91Z2ggSW5hY3RpdmUgV2luZG93cylfELxUZXh0IEZpZWxk
+IENlbGwgKExhdW5jaGluZyBYMTEgd2lsbCBjcmVhdGUgWGF1dGhvcml0eSBhY2Nlc3MtY29udHJvbCBr
+ZXlzLiBJZiB0aGUgc3lzdGVtJ3MgSVAgYWRkcmVzcyBjaGFuZ2VzLCB0aGVzZSBrZXlzIGJlY29tZSBp
+bnZhbGlkIHdoaWNoIG1heSBwcmV2ZW50IFgxMSBhcHBsaWNhdGlvbnMgZnJvbSBsYXVuY2hpbmcuKV8Q
+aVRleHQgRmllbGQgQ2VsbCAoSG9sZCBPcHRpb24gYW5kIENvbW1hbmQgd2hpbGUgY2xpY2tpbmcgdG8g
+YWN0aXZhdGUgdGhlIG1pZGRsZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KKV8QFU1lbnUgSXRlbSAo
+VGhvdXNhbmRzKV8QFE1lbnUgSXRlbSAoTWlsbGlvbnMpXxCTU3RhdGljIFRleHQgKFdoZW4gZW5hYmxl
+ZCwgY2xpY2tpbmcgb24gYW4gaW5hY3RpdmUgd2luZG93IHdpbGwgY2F1c2UgdGhhdCBtb3VzZSBjbGlj
+ayB0byBwYXNzIHRocm91Z2ggdG8gdGhhdCB3aW5kb3cgaW4gYWRkaXRpb24gdG8gYWN0aXZhdGluZyBp
+dC4pVlZpZXctMVtTZXBhcmF0b3ItMV8QFE1lbnUgSXRlbSAoSGlkZSBYMTEpXxAUTWVudSBJdGVtIChR
+dWl0IFgxMSlfEBhNZW51IEl0ZW0gKEN1c3RvbWl6ZS4uLilfEBRCdXR0b24gQ2VsbCAoUmVtb3ZlKV8Q
+KUNoZWNrIEJveCAoRm9sbG93IHN5c3RlbSBrZXlib2FyZCBsYXlvdXQpXxArQnV0dG9uIENlbGwgKEZv
+bGxvdyBzeXN0ZW0ga2V5Ym9hcmQgbGF5b3V0KV8QJkJ1dHRvbiBDZWxsIChBdXRoZW50aWNhdGUgY29u
+bmVjdGlvbnMpXxAUUHVzaCBCdXR0b24gKENhbmNlbClcU2VwYXJhdG9yLTEwXxBMU3RhdGljIFRleHQg
+KEFsbG93cyBpbnB1dCBtZW51IGNoYW5nZXMgdG8gb3ZlcndyaXRlIHRoZSBjdXJyZW50IFgxMSBrZXlt
+YXAuKV8QEE1lbnUgSXRlbSAoSGVscClfEHlUZXh0IEZpZWxkIENlbGwgKFgxMSBiZWVwcyB3aWxsIHVz
+ZSB0aGUgc3RhbmRhcmQgc3lzdGVtIGFsZXJ0LCBhcyBkZWZpbmVkIGluIHRoZSBTb3VuZCBFZmZlY3Rz
+IHN5c3RlbSBwcmVmZXJlbmNlcyBwYW5lbC4pWVNlcGFyYXRvcl8QFlRhYiBWaWV3IEl0ZW0gKE91dHB1
+dClfEBdCdXR0b24gQ2VsbCAoRHVwbGljYXRlKV8QLEJ1dHRvbiBDZWxsIChDbGljay10aHJvdWdoIElu
+YWN0aXZlIFdpbmRvd3MpXxATVGFibGUgQ29sdW1uIChOYW1lKV8QJlRvcCBUYWIgVmlldyAoSW5wdXQs
+IE91dHB1dCwgU2VjdXJpdHkpXxAhTWVudSBJdGVtIChDeWNsZSBUaHJvdWdoIFdpbmRvd3MpXxAkQ2hl
+Y2sgQm94IChBdXRoZW50aWNhdGUgY29ubmVjdGlvbnMpXxARVGFibGUgSGVhZGVyIFZpZXdfEBZCdXR0
+b24gQ2VsbCAoQWRkIEl0ZW0pXxASUHVzaCBCdXR0b24gKERvbmUpXxAoQnV0dG9uIENlbGwgKEVtdWxh
+dGUgdGhyZWUgYnV0dG9uIG1vdXNlKV8QEk1lbnUgSXRlbSAoV2luZG93KV8Qp1N0YXRpYyBUZXh0IChJ
+ZiBlbmFibGVkLCBBdXRoZW50aWNhdGUgY29ubmVjdGlvbnMgbXVzdCBhbHNvIGJlIGVuYWJsZWQgdG8g
+ZW5zdXJlIHN5c3RlbSBzZWN1cml0eS4gV2hlbiBkaXNhYmxlZCwgY29ubmVjdGlvbnMgZnJvbSByZW1v
+dGUgYXBwbGljYXRpb25zIGFyZSBub3QgYWxsb3dlZC4pXxAjQ2hlY2sgQm94IChVc2Ugc3lzdGVtIGFs
+ZXJ0IGVmZmVjdClfEBpNZW51IEl0ZW0gKEFwcGxpY2F0aW9ucyktMV8QFE1lbnUgSXRlbSAoTWluaW1p
+emUpXxAbUG9wdXAgQnV0dG9uIChGcm9tIERpc3BsYXkpXxAeTWVudSBJdGVtIChUb2dnbGUgRnVsbCBT
+Y3JlZW4pXEZpbGUncyBPd25lcltTZXBhcmF0b3ItNF8QFk1lbnUgSXRlbSAoU2VsZWN0IEFsbClfEHVT
+dGF0aWMgVGV4dCAoWDExIGJlZXBzIHdpbGwgdXNlIHRoZSBzdGFuZGFyZCBzeXN0ZW0gYWxlcnQsIGFz
+IGRlZmluZWQgaW4gdGhlIFNvdW5kIEVmZmVjdHMgc3lzdGVtIHByZWZlcmVuY2VzIHBhbmVsLilfEBVN
+ZW51IChBcHBsaWNhdGlvbnMpLTFfECVCdXR0b24gQ2VsbCAoVXNlIHN5c3RlbSBhbGVydCBlZmZlY3Qp
+XxCrVGV4dCBGaWVsZCBDZWxsIChJZiBlbmFibGVkLCBBdXRoZW50aWNhdGUgY29ubmVjdGlvbnMgbXVz
+dCBhbHNvIGJlIGVuYWJsZWQgdG8gZW5zdXJlIHN5c3RlbSBzZWN1cml0eS4gV2hlbiBkaXNhYmxlZCwg
+Y29ubmVjdGlvbnMgZnJvbSByZW1vdGUgYXBwbGljYXRpb25zIGFyZSBub3QgYWxsb3dlZC4pXxAPTWVu
+dSAoU2VydmljZXMpW1NlcGFyYXRvci05XxAXUHVzaCBCdXR0b24gKER1cGxpY2F0ZSlbU2VwYXJhdG9y
+LTJfEBBNZW51IEl0ZW0gKFVuZG8pXxAeTWVudSBJdGVtIChCcmluZyBBbGwgdG8gRnJvbnQpXxAQTWVu
+dSBJdGVtIChFZGl0KVtTZXBhcmF0b3ItNW8QFgBNAGUAbgB1ACAASQB0AGUAbQAgACgAQwB1AHMAdABv
+AG0AaQB6AGUgJgApXxAXTWVudSBJdGVtIChIaWRlIE90aGVycylfEGVTdGF0aWMgVGV4dCAoSG9sZCBP
+cHRpb24gYW5kIENvbW1hbmQgd2hpbGUgY2xpY2tpbmcgdG8gYWN0aXZhdGUgdGhlIG1pZGRsZSBhbmQg
+cmlnaHQgbW91c2UgYnV0dG9ucy4KKVhEb2NrTWVudV8QHVRleHQgRmllbGQgQ2VsbCAoVGV4dCBDZWxs
+KS0yXxBGVGV4dCBGaWVsZCBDZWxsIChUaGVzZSBvcHRpb25zIHRha2UgZWZmZWN0IHdoZW4gWDExIGlz
+IG5leHQgbGF1bmNoZWQuKVxFZGl0UHJvZ3JhbXNfECZDaGVjayBCb3ggKEVtdWxhdGUgdGhyZWUgYnV0
+dG9uIG1vdXNlKV8QFVRhYiBWaWV3IEl0ZW0gKElucHV0KV8QQlN0YXRpYyBUZXh0IChUaGlzIG9wdGlv
+biB0YWtlcyBlZmZlY3Qgd2hlbiBYMTEgaXMgbGF1bmNoZWQgYWdhaW4uKV8QG1RleHQgRmllbGQgQ2Vs
+bCAoVGV4dCBDZWxsKV8QFlRhYmxlIENvbHVtbiAoQ29tbWFuZClbTWVudSAoRWRpdClfEBRNZW51IEl0
+ZW0gKFNob3cgQWxsKVpQcmVmc1BhbmVsXxATTWVudSAoQXBwbGljYXRpb25zKV8QFE1lbnUgSXRlbSAo
+WDExIEhlbHApXU1lbnUgKFdpbmRvdylfEBBNZW51IEl0ZW0gKFpvb20pXxARVmVydGljYWwgU2Nyb2xs
+ZXJeQ29udGVudCBWaWV3LTFfEBhNZW51IEl0ZW0gKEZyb20gRGlzcGxheSlfEA9NZW51IEl0ZW0gKEN1
+dClfEBZQdXNoIEJ1dHRvbiAoQWRkIEl0ZW0pXxAYVGFiIFZpZXcgSXRlbSAoU2VjdXJpdHkpXxByU3Rh
+dGljIFRleHQgKEVuYWJsZXMgdGhlIFgxMSByb290IHdpbmRvdy4gVXNlIHRoZSBDb21tYW5kLU9wdGlv
+bi1BIGtleXN0cm9rZSB0byBlbnRlciBhbmQgbGVhdmUgZnVsbCBzY3JlZW4gbW9kZS4pXxCXVGV4dCBG
+aWVsZCBDZWxsIChXaGVuIGVuYWJsZWQsIGNsaWNraW5nIG9uIGFuIGluYWN0aXZlIHdpbmRvdyB3aWxs
+IGNhdXNlIHRoYXQgbW91c2UgY2xpY2sgdG8gcGFzcyB0aHJvdWdoIHRvIHRoYXQgd2luZG93IGluIGFk
+ZGl0aW9uIHRvIGFjdGl2YXRpbmcgaXQuKV8QE0hvcml6b250YWwgU2Nyb2xsZXJfEBVNZW51IEl0ZW0g
+KEFib3V0IFgxMSlfEBJCdXR0b24gQ2VsbCAoRG9uZSlaTWVudSAoWDExKV8QLkJ1dHRvbiBDZWxsIChF
+bmFibGUga2V5IGVxdWl2YWxlbnRzIHVuZGVyIFgxMSlfELhTdGF0aWMgVGV4dCAoTGF1bmNoaW5nIFgx
+MSB3aWxsIGNyZWF0ZSBYYXV0aG9yaXR5IGFjY2Vzcy1jb250cm9sIGtleXMuIElmIHRoZSBzeXN0ZW0n
+cyBJUCBhZGRyZXNzIGNoYW5nZXMsIHRoZXNlIGtleXMgYmVjb21lIGludmFsaWQgd2hpY2ggbWF5IHBy
+ZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4pW1NlcGFyYXRvci02XxAyQ2hlY2sg
+Qm94IChBbGxvdyBjb25uZWN0aW9ucyBmcm9tIG5ldHdvcmsgY2xpZW50cylfEBZNZW51IEl0ZW0gKDI1
+NiBDb2xvcnMpXxB0U3RhdGljIFRleHQgKFdoZW4gZW5hYmxlZCwgbWVudSBiYXIga2V5IGVxdWl2YWxl
+bnRzIG1heSBpbnRlcmZlcmUgd2l0aCBYMTEgYXBwbGljYXRpb25zIHRoYXQgdXNlIHRoZSBNZXRhIG1v
+ZGlmaWVyLilfEEZUZXh0IEZpZWxkIENlbGwgKFRoaXMgb3B0aW9uIHRha2VzIGVmZmVjdCB3aGVuIFgx
+MSBpcyBsYXVuY2hlZCBhZ2Fpbi4pW0FwcGxpY2F0aW9uXxB2VGV4dCBGaWVsZCBDZWxsIChFbmFibGVz
+IHRoZSBYMTEgcm9vdCB3aW5kb3cuIFVzZSB0aGUgQ29tbWFuZC1PcHRpb24tQSBrZXlzdHJva2UgdG8g
+ZW50ZXIgYW5kIGxlYXZlIGZ1bGwgc2NyZWVuIG1vZGUuKV8QEk1lbnUgSXRlbSAoRGVsZXRlKV8QUFRl
+eHQgRmllbGQgQ2VsbCAoQWxsb3dzIGlucHV0IG1lbnUgY2hhbmdlcyB0byBvdmVyd3JpdGUgdGhlIGN1
+cnJlbnQgWDExIGtleW1hcC4pXxAUTWVudSBJdGVtIChTZXJ2aWNlcylfECxDaGVjayBCb3ggKEVuYWJs
+ZSBrZXkgZXF1aXZhbGVudHMgdW5kZXIgWDExKV8QHkJ1dHRvbiBDZWxsIChGdWxsIHNjcmVlbiBtb2Rl
+KVxDb250ZW50IFZpZXdfECFQb3AgVXAgQnV0dG9uIENlbGwgKEZyb20gRGlzcGxheSlfEBRCdXR0b24g
+Q2VsbCAoQ2FuY2VsKV8QEE1lbnUgSXRlbSAoQ29weSlfEB1UZXh0IEZpZWxkIENlbGwgKFRleHQgQ2Vs
+bCktMV8QD01lbnUgSXRlbSAoWDExKV8QeFRleHQgRmllbGQgQ2VsbCAoV2hlbiBlbmFibGVkLCBtZW51
+IGJhciBrZXkgZXF1aXZhbGVudHMgbWF5IGludGVyZmVyZSB3aXRoIFgxMSBhcHBsaWNhdGlvbnMgdGhh
+dCB1c2UgdGhlIE1ldGEgbW9kaWZpZXIuKV8QFFB1c2ggQnV0dG9uIChSZW1vdmUpW01lbnUgKEhlbHAp
+XxAWU3RhdGljIFRleHQgKENvbG9yczoKKVtTZXBhcmF0b3ItN18QHENoZWNrIEJveCAoRnVsbCBzY3Jl
+ZW4gbW9kZSlfECRUYWJsZSBWaWV3IChOYW1lLCBDb21tYW5kLCBTaG9ydGN1dClfEBhNZW51IEl0ZW0g
+KEFwcGxpY2F0aW9ucylfEBFNZW51IEl0ZW0gKFBhc3RlKV8QGlRleHQgRmllbGQgQ2VsbCAoQ29sb3Jz
+OgopW1NlcGFyYXRvci0zXxA0QnV0dG9uIENlbGwgKEFsbG93IGNvbm5lY3Rpb25zIGZyb20gbmV0d29y
+ayBjbGllbnRzKV8QEU1lbnUgSXRlbSAoQ2xvc2UpW1NlcGFyYXRvci04VlZpZXctMtIADgBFB/UK2YEB
++qDSAA4ARQf1CtyBAfqg0gAOAEUH9QrfgQH6rxC8AyADrAHnBv8F5gLHAHICWwa9APkAagCHBfsFLQIL
+AgwE7wGBA/0DJgMqA5UBpgGsBesEfABZAFwAXQBgAGkGTQDZBOwDEQWcAJ0AUwBwAHYCYQVhBoAAXwb9
+AnEBiAXiAGcAWAasAF4BBgBkB94CpwCBAH8AhACFAxAF5QWAAcID9wCeArYAVQBtAB8AdAOtAuIFgQDJ
+BYsATwBXAcYGCwBmAz8CRwP7BnoDqwB8A/4DDwMhANoDJwTqBzoAjgYbAFoIOwKhAFsE4ACCBYQHUQb+
+AuoCOQShAFIAVgJSAGwAYwB4BEYBcgBUA/gAeQMBBvMAhgHgAQMDrgD6BU0FhgViAYQBVwbpAV8H5AXk
+AyUAYgBuAHoAfgCDAoYAcwIKAIgAYQB9BOkFvAhcBT0DsQXMAFADIgBxAX0EXwCABLMByQB3BlMAdQLz
+BPQDDQcNAGUEdgQ3BYMDIwBoAG8AawRYAFEGmgMOA7AFrAP/AowBagMpAHsCiYCrgM6AXIEBqoEBYYCR
+gQF/gHaBAZeAMoEBBoEB1IEBW4EBKIBkgGeBAS6AQ4DlgLiAvoDFgEyAToEBV4D/gHWAgICGgJWBAQSB
+AXiAHIEBKoDqgQFDgA6AQYEBdYEBjIB4gQE6gQGHgJCBAZuAe4EBFIEBVYD6gHGBAZKAi4AngKOBAdeA
+iYEByIEBxIEBzoEB0IDagQFdgQE9gFSA34AXgIyAUYEBb4ACgQGCgNGAmoEBQYAagQE/gAqAbYBVgQFf
+gPSAsoBygOSBAYWAy4EBv4DmgMeAroAdgLuBASaBAamAC4EBY4B6gQHsgIeAf4EBNoEByoEBSYEBr4EB
+poCbgG6BAQuAO4BTgHOBAQqAnoEBuIDvgD2AS4DigQG6gKSBAeKBAdKAW4AlgNKAJIEBMIEBTYEBU4BF
+gDeBAeaAOIEB2YEBWYC3gJmBAXGBAbyBAcOBAcyAgYEBgIBhgQHWgJeBAcGBAReBAUuBAfiBASyA2IEB
+T4AjgK+BAXeAQoD3gQHGgQESgFeBAY6BAXqBAYSAn4EBGYCngQGigPOA/YDtgQFFgLaA/IEBc4EBCID1
+gDaBAY+AwoDVgQFHgOiAhIA8gL2BAb6AgtIADgBFB/ULnoEB+q8QvAufC6ALoQuiC6MLpAulC6YLpwuo
+C6kLqgurC6wLrQuuC68LsAuxC7ILswu0C7ULtgu3C7gLuQu6C7sLvAu9C74LvwvAC8ELwgvDC8QLxQvG
+C8cLyAvJC8oLywvMC80LzgvPC9AL0QvSC9ML1AvVC9YL1wvYC9kL2gvbC9wL3QveC98L4AvhC+IL4wvk
+C+UL5gvnC+gL6QvqC+sL7AvtC+4L7wvwC/EL8gvzC/QL9Qv2C/cL+Av5C/oL+wv8C/0L/gv/DAAMAQwC
+DAMMBAwFDAYMBwwIDAkMCgwLDAwMDQwODA8MEAwRDBIMEwwUDBUMFgwXDBgMGQwaDBsMHAwdDB4MHwwg
+DCEMIgwjDCQMJQwmDCcMKAwpDCoMKwwsDC0MLgwvDDAMMQwyDDMMNAw1DDYMNww4DDkMOgw7DDwMPQw+
+DD8MQAxBDEIMQwxEDEUMRgxHDEgMSQxKDEsMTAxNDE4MTwxQDFEMUgxTDFQMVQxWDFcMWAxZDFqBAoKB
+AoOBAoSBAoWBAoaBAoeBAoiBAomBAoqBAouBAoyBAo2BAo6BAo+BApCBApGBApKBApOBApSBApWBApaB
+ApeBApiBApmBApqBApuBApyBAp2BAp6BAp+BAqCBAqGBAqKBAqOBAqSBAqWBAqaBAqeBAqiBAqmBAqqB
+AquBAqyBAq2BAq6BAq+BArCBArGBArKBArOBArSBArWBAraBAreBAriBArmBArqBAruBAryBAr2BAr6B
+Ar+BAsCBAsGBAsKBAsOBAsSBAsWBAsaBAseBAsiBAsmBAsqBAsuBAsyBAs2BAs6BAs+BAtCBAtGBAtKB
+AtOBAtSBAtWBAtaBAteBAtiBAtmBAtqBAtuBAtyBAt2BAt6BAt+BAuCBAuGBAuKBAuOBAuSBAuWBAuaB
+AueBAuiBAumBAuqBAuuBAuyBAu2BAu6BAu+BAvCBAvGBAvKBAvOBAvSBAvWBAvaBAveBAviBAvmBAvqB
+AvuBAvyBAv2BAv6BAv+BAwCBAwGBAwKBAwOBAwSBAwWBAwaBAweBAwiBAwmBAwqBAwuBAwyBAw2BAw6B
+Aw+BAxCBAxGBAxKBAxOBAxSBAxWBAxaBAxeBAxiBAxmBAxqBAxuBAxyBAx2BAx6BAx+BAyCBAyGBAyKB
+AyOBAySBAyWBAyaBAyeBAyiBAymBAyqBAyuBAyyBAy2BAy6BAy+BAzCBAzGBAzKBAzOBAzSBAzWBAzaB
+AzeBAziBAzmBAzqBAzuBAzyBAz0QgRCtEQF8EQIXEQF7EQIaEQE0EgAElQgRAScQxBEBPhEBhBIAAYgY
+EgABiA0RAX8RAX0SAASVChEBXxECGBCGEIgRATERAXISAAGIEhIAAYgWEgABh8USAASVDBEBkREBihEB
+QRC0EQErEQIVEQFxEQGjEgABiBQRAgwRAYkRAQcRAYYSAASVCREBYBIAAYfEEQIcEQEpEQIZEQFcEQF2
+EQIjEQEREgAElQcRAiUSAAGH1hIABJUuEQEjEgABiAsSAASVLBEBphEBhxECExATEQF5EQFzEQF+EBcR
+Ag4RAiARAawRAhYSAASVLxCvEJwQrBEBdBECDxIAAYgTEQGqEQGvEQFeEgABiBkRAiIQghEBEBBcEQEk
+EJ4QwxAFEKMQjxECFBCREQFtEQI9EQGnEgABiBsRAhsRAR0RAWsRAY4RAV0SAASVKxEBghECPxEBKhCp
+EJYQ9BDNEQGFEQEOEQGSELURAa4RAaURAYsQzBDOEB0SAAGHxxCyEQGAEQEeEKARATYSAASVCxECHxEB
+YRIAAYgQEDoSAAMOZxA5EgABh8MRAXgRAiEQsxEBrRDPEQGNEgAElS0RAXcQyhEBsxEBLhECEhEBiBEB
+bBIAAYgiE//////////9EgABiBEQpBIAAYi/EQE3EIMRATURAXASAAGIvRCwEPUSAAGIHhIAAYfLEQEw
+EJ0SAAGIDBA4EQI+EQGMEQElEQGkEQGBEJARAYMRAiQRAh0RAbERASgRAQ0QqxIAAYghEgAElSoSAAGI
+FxDLEJURAY8RAWLSAA4ARQBNDRaAH6DSAA4ARQf1DRmBAfqg0gAOAEUH9Q0cgQH6oNIAOgA7DR4NH6IN
+HwA/Xk5TSUJPYmplY3REYXRhAAgAGQAiACcAMQA6AD8ARABSAFQAZgbuBvQHPwdGB00HWwdtB4kHlwej
+B68HvQfIB9YH8ggACBMIJQg/CEkIVghYCFsIXghhCGQIZghpCGsIbghxCHQIdwh5CHsIfgiBCIYIiQiS
+CJ4IoAiiCKsItQi3CMUIzgjXCOII6Qj7CQQJDQkWCRsJKgk9CUYJUQlTCVQJXQlkCXEJdwmACYIJ+Qn7
+Cf0J/woBCgMKBQoHCgkKCwoNCg8KEQoTChUKFwoZChsKHQofCiEKIwolCicKKQorCi0KMAozCjYKOQo8
+Cj8KQgpFCkgKSwpOClEKVApXCloKXQpgCmMKZgppCmwKbwpyCnUKeAp7Cn4KgQqECocKigqNCp4KrAq1
+Cr0KvwrBCsMKxQrWCt4K5QrxCvMK9Qr3CvkK/gsHCwkLDgsQCxILOwtPC10LaAt1C4MLjQuaC6ELowul
+C6oLqwutC64Lswu1C7cLuQu6C8cL1gvYC9oL3AvkC/YL/wwEDBcMJAwmDCgMKgw9DEYMSwxWDH8MiQyS
+DJQMlgyYDJoMnAyeDKAMogyvDL4MywzNDM8M0QzaDNwM4QzjDOUNDg0QDRINEw0VDRYNGA0aDRwNPQ0/
+DUENQw1FDUcNSQ1eDWcNbg19DYUNjg2TDZwNpQ2sDcMN0g3jDeUN5w3pDesOCA4aDiIOKQ4yDjwOSA5K
+DkwOTg5QDlMOVA5WDmsOdg6CDoQOhw6KDo0OkA6qDt8O6w8BDxYPJQ84D0oPVQ9fD20Pfw+MD5oPnw+h
+D6MPpQ+nD6kPqw+tD68PsQ+zD7gPwQ/KD9sP4g/rD+0P9g/4D/sQCBAREBYQHRAuEDAQMhA0ED4QRxBJ
+EFIQVBBdEGYQcxCAEIkQlBCdEKcQrhC6EMMQxRDHENUQ5xDwEPcRDxEgESIRJBEmESgRRRFHEUkRSxFN
+EU8RURFiEWQRZhFoEWoRdBGUEaURpxGpEasRrRHOEdAR0hHUEdYR2BHaEesR7RHvEfER8xH5EfsSCRIa
+EhwSHhIgEiISPxJBEkMSRRJHEkgSShJjEmYSaRJsEm8SchKLEsASwhLEEsYSyBLKEswSzhLQEtIS1xL6
+EwMTDxMRExMTHBMlEyoTQBNTE2QTZhNoE2oTbBOJE4sTjROPE5ETkhOUE60T4hPkE+YT6BPqE+wT7hPw
+FBAUHxQwFDIUNBQ2FDgUQhRTFFUUVxRZFFsUeBR6FHwUfhSAFIEUgxSYFJoUnRSgFKMUvBULFSgVOhVM
+FWEVbxV4FXkVexV9FX8VgRWDFYUVhxWJFYsVjBWNFZAVkxWVFZoVqxWtFa8VuBW6FcMVxRX2Ff8WBRYN
+Fg8WERYTFhUWFxYZFhsWHRYmFjMWNRY3FjkWRhZaFmMWZRZwFnkWexaEFoYWiBaKFowWuRa7Fr0WvxbB
+FsMWxRbHFskWyxbWFwMXBRcHFwkXCxcNFw8XERcTFxUXHxdMF04XUBdSF1QXVhdYF1oXXBdeF2cXcBd9
+F5EXoBepF7YXxBfKF9sX3RffF+EX4xgIGAoYDBgOGBAYEhgUGBYYHxg4GEkYSxhNGE8YURh6GHwYfhh/
+GIEYghiEGIYYiBiVGJcYmRibGKoYuxi9GL8YwRjDGOAY4hjkGOYY6BjpGOsZAxk4GToZPBk+GUAZQhlE
+GUYZZxl4GXoZfBl+GYAZoRmjGaUZqhmsGa4ZsBmyGcoZzBnZGeoZ7BnuGfAZ8hoDGgUaBxoJGgsaKBoq
+GiwaLhowGjEaMxpIGkoaTRpQGlMabBqhGqMapRqnGqkaqxqtGq8a2BrpGusa7RrvGvEbDhsQGxIbFBsW
+GxcbGRsyG2cbaRtrG20bbxtxG3MbdRuSG6MbpRunG6kbqxvMG84b0BvVG9cb2RvbG90b8hv0HA0cHhwg
+HCIcJBwmHEccSRxLHFAcUhxUHFYcWBx4HHocjRyeHKAcohykHKYctRzGHMgcyhzMHM4c3RzqHOwc7hzw
+HREdEx0VHRcdGR0bHR0dKh0sHS4dMB07HUYdUx1VHVcdWR16HXwdfh2AHYIdhB2GHYsdjR2THaQdph2o
+HaodrB29Hb8dwR3DHcUdzh3XHdkd5B3mHegd6h3sHe4eFx4ZHhseHR4fHiEeIx4lHiceKx40HjYeTx5R
+HlMeVR5XHlkeWx5dHl8eYR5jHmUeZx6IHooejB6OHpAekh6UHqMepR7OHtAe0h7THtUe1h7YHtoe3B8F
+HwcfCR8LHw0fDx8RHxMfFR8eHy8fMR8zHzUfNx9AH0IfSx9NH04fYB+JH4sfjR+OH5AfkR+TH5Uflx/A
+H8IfxB/FH8cfyB/KH8wfzh/zH/Uf9x/5H/sf/R//IAggCiArIC0gLyAxIDMgNSA3IEMgbCBuIHAgcSBz
+IHQgdiB4IHogmyCdIJ8goSCjIKUgpyCwILIgvyDoIOog7CDuIPAg8iD0IPYg+CEBIQMhCCEKIQwhLSEv
+ITEhMyE1ITchOSFGIW8hcSFzIXUhdyF5IXshfSF/IYQhjSGPIaAhoiGkIaYhqCGqIawhriGwIdEh0yHV
+Idch2SHbId0h4iHkIgUiByIJIgsiDSIPIhEiFiIYIkEiQyJFIkYiSCJJIksiTSJPInAiciJ0InYieCJ6
+InwigCKCIqMipSKnIqkiqyKtIq8itSK3Itgi2iLcIt4i4CLiIuQi6yMUIxYjGCMaIxwjHiMgIyIjJCMr
+IzQjNiM/I0EjVCNWI1gjWiNcI14jYCNiI2QjZiOHI4kjiyONI48jkSOTI5wjniO/I8EjwyPFI8cjySPL
+I9Aj+SP7I/0j/iQAJAEkAyQFJAckMCQyJDQkNSQ3JDgkOiQ8JD4kXyRhJGMkZSRnJGkkaySAJKkkqySt
+JK4ksCSxJLMktSS3JMYk7yTxJPMk9ST3JPkk+yT9JP8lBCURJRMlFSUXJSAlIiUlJSclSCVKJUwlTiVQ
+JVIlVCVdJWklbiV/JYElgyWFJYclmCWaJZwlniWgJb0lvyXBJcMlxSXGJcgl4SYWJhgmGiYcJh4mICYi
+JiQmNyZLJlwmXiZgJmImZCaBJpImlCaWJpgmmya4JromvCa+JsAmwSbDJt0nEicUJxcnGSccJx8nIScj
+JyonMyc1Jz4nQCdVJ2InZCdmJ2knbyeAJ4InhCeGJ4knlSemJ6gnqiesJ68nxCfVJ9cn2ifcJ98oHigr
+KEQoUShnKHUofyiNKKYosyi9KM8o4yjtKPko/Cj/KQIpBSkIKQspECkTKRYpGSkcKR8pIik9KU8pVylg
+KWIpZymEKY8ppCmmKakprCmvKbgpuim9KcAp8SoAKgoqHio3Kk8qUipVKlgqWypdKmAqYSpkKmUqaCpx
+KnMqdip4KoEqgyqUKpYqmSqcKp4qoSqjKqUqqCrFKscqyirNKtAq0SrTKusrDCsgKywrLysyKzUrOCs7
+K0ArQyusK70rvyvIK8orzSviK+or9ywDLBEsFCwXLBksHCwfLCYsMyxALEgsSyxXLGAsZSx6LH0sgCyD
+LIYsmSymLKksrCy1LL4s0CzZLOQs8C0NLQ8tEi0VLRgtGS0bLTQtVS1YLVstXi1hLWQtZy3BLd4t4C3j
+LeYt6S3qLewuBS4mLikuLC4vLjIuNS44Lnkuli6YLpsuni6hLqIupC68Lt0u4C7jLuYu6S7sLu8vdy+Q
+L5kvoC+5L8IvxC/LL84v0S/UL+0v+jAEMAcwCjAMMA8wEjAVMB4wIDAiMCgwMTA2MEQwXTBgMGMwZTBo
+MGswbjB3MHkwezCEMIYwlTCYMJswnTCgMKMwpTCoMMUwxzDJMMwwzzDQMNIw6zEgMSIxJDEmMSgxKzEt
+MTAxSjFnMWkxbDFvMXIxczF1MY0xrjGxMbQxtzG6Mb0xwDIqMkcySTJMMk8yUjJTMlUybTKOMpEylDKX
+MpkynDKfMqgyxTLHMsoyzTLQMtEy0zLsMw0zEDMTMxYzGTMcMx8zVjNzM3UzeDN7M34zfzOBM5ozuzO+
+M8EzxDPHM8ozzTQ0NDs0UDRTNFU0WDRbNF40ZzRpNHQ0dzR5NHw0fzSCNJ80oTSjNKY0qTSqNKw04TTj
+NOU05zTpNOw07jTxNQw1KTUrNS41MTU0NTU1NzVQNXE1dDV3NXo1fTWANYM2MDZNNk82UjZVNlg2WTZb
+NnQ2lTaYNps2njahNqQ2pzdDN2A3YjdlN2g3azdsN243hjenN6o3rTewN7M3tje5N/A3+TgCOAs4Fjgu
+ODk4QzhMOFE4ZDhwOIE4gziFOIc4ijidOK44sDiyOLQ4tzjAONE40zjWONg42zjnOPg4+jj8OP45ATka
+OSs5LTkvOTI5NTlSOVQ5VjlZOVw5XzlgOWI5ejmvObg5ujm9Ob85wjnFOcc5yjnROdo53DnlOec5/DoN
+Og86EToTOhY6JzopOis6LTowOkM6UDpSOlQ6VzpcOm06bzpxOnQ6dzqUOpY6mDqbOp46nzqhOrs68Dry
+OvU69zr6Ov06/zsCOww7FTsXOyA7Ijs6O0s7TTtQO1I7VTthO3I7dDt3O3k7fDvLO+07+jwPPBw8NjxS
+PG08eTyYPKc8szy2PLk8vjzBPMQ8xTzIPNE82jzdPN484TzkPOc88D0ZPSM9LT03PUU9SD1LPU49UD1T
+PVY9WT1cPV89Yj1tPYY9kj2VPZg9mz2ePaE9yj3NPdA90z3WPdk93D3fPeI97D31Pf4+Ej4nPio+LT4w
+PjM+bD54PoE+lD6hPq0+uz69PsA+wz7GPsg+yz7OPtE+5D7nPuk+7D7vPvI/CT8SPxs/KT8yPzQ/Oz8+
+P0E/RD9tP3w/iT+RP5w/qz+2P8E/zj/PP9I/1T/eP+E/6j/zP/Q/90AUQBlAHEAfQCJAJUAoQC1AOkA9
+QElAXkBhQGRAZ0BqQHxAhUCQQKRAxUDKQM1A0EDTQNVA2EDbQOVA8kD1QPhBAUEGQRRBPUE+QUFBREFN
+QVBBWUFaQV1BekF9QYBBg0GGQYlBkUGyQbVBuEG7Qb1BwEHDQexB7UHwQfNB/EH/QghCCUIMQilCLEIv
+QjJCNUI4QkFCVkJZQlxCX0JiQm5Ck0KWQplCnEKfQqJCo0KmQrdCuULCQsRC2ULcQt9C4kLlQv5DE0MW
+QxlDHEMfQylDNkM5Qz5DR0NSQ11DbkNwQ3JDdEN3Q31DjkOQQ5JDlEOXQ6RDtUO3Q7lDu0O+Q9BD4UPj
+Q+VD6EPqQ/dD+UP7Q/5EBkQXRBlEG0QdRCBELEQ9RD9EQUREREZEV0RZRFtEXURgRGpEd0R5RHtEfkSF
+RJZEmESaRJxEn0StRL5EwETCRMREx0TaROtE7UTvRPFE9ET6RQtFDUUPRRFFFEUhRTJFNEU2RThFO0VT
+RWBFYkVkRWdFbUV+RYBFgkWERYdFkkWjRaVFp0WqRa1FykXMRc5F0UXURdVF10XvRiRGJkYoRipGLUYw
+RjJGNUY6RkNGRUZYRmFGZEdpR2tHbUdvR3JHdUd3R3lHfEd+R4FHhEeGR4hHi0eNR49HkUeTR5VHl0eZ
+R5xHnkehR6NHpkeoR6tHrUevR7JHtUe4R7pHvUfAR8NHxUfIR8pHzEfPR9JH1EfWR9hH2kfcR95H4Ufj
+R+ZH6EfrR+1H70fxR/RH9kf4R/pH/Ef+SABIA0gGSAhIC0gOSBBIE0gWSBlIHEgeSCBII0glSCdIKUgr
+SC1IMEgySDRINkg4SDtIPkhBSENIRUhISEpITUhQSFJIVEhWSFlIXEhfSGJIZEhnSGlIa0htSHBIckh1
+SHdIekh8SH9IgUiDSIZIiEiKSI1Ij0iRSJRIlkiYSJpInEieSKdIqUi0SLdIuki9SMBIw0jMSM5I0UjU
+SOxI9Uj+SQlJKkk0STdJOkk9SUBJQ0lGSU9JaEl1SX5JiUmUSblJvEm/ScJJxUnISctJ1EnsSfVJ90n6
+Sf1KE0osSjVKPkpLSopKjEqPSpJKlUqYSptKnkqhSqRKp0qpSqxKr0rKSuFK6krsSvVK90sESwdLCksM
+Sw9LEksUSx9LKEsxSzNLNks/S0RLTUtQTFVMV0xZTFtMXkxgTGJMZExmTGhMa0xuTHBMckx0THdMeUx7
+TH1Mf0yBTINMhkyITIpMjEyOTJBMk0yVTJdMmkydTKBMokylTKdMqkysTK5MsEyyTLRMtky4TLpMvEy+
+TMBMwkzETMZMyUzMTM9M0UzTTNVM10zZTNtM3UzfTOFM40zlTOhM6kztTO9M8Uz0TPZM+Uz8TP5NAE0C
+TQRNBk0ITQpNDE0PTRFNFE0WTRhNG00dTSBNIk0kTSdNKU0sTS5NME0yTTRNNk05TTtNPk1ATUNNRU1H
+TUlNTE1OTVFNU01WTVhNW01dTV9NYU1jTWVNaE1qTWxNb01xTXNNdU13TXpNg02GTo1Oj06RTpROlk6Z
+TptOnk6gTqJOpU6oTqpOrE6vTrFOs061TrdOuU67Tr1Ov07CTsVOx07KTsxOz07RTtRO107ZTtxO307h
+TuRO507pTuxO7k7wTvNO9k74TvpO/E7+TwBPAk8ETwdPCU8MTw5PEU8TTxVPGE8aTxxPHk8gTyJPJE8m
+TylPK08uTzFPNE82TzlPPE8/T0JPRE9GT0lPS09NT09PUU9TT1ZPWE9aT1xPXk9hT2RPZ09qT2xPb09x
+T3NPdk94T3pPfE9/T4JPhU+IT4pPjU+PT5FPk0+WT5hPm0+dT6BPok+lT6dPqU+sT65PsE+zT7VPt0+6
+T7xPvk/AT8JPxE/NT9BQ11DaUN1Q4FDjUOZQ6VDsUO9Q8VD0UPdQ+lD9UQBRA1EGUQlRDFEPURJRFVEY
+URtRHlEhUSRRJ1EqUS1RMFEzUTZROVE8UT9RQlFFUUhRS1FOUVFRVFFXUVpRXVFgUWNRZlFpUWxRb1Fy
+UXVReFF7UX5RgVGEUYdRilGNUZBRk1GWUZlRnFGfUaJRpVGoUatRrlGxUbRRt1G6Ub1RwFHDUcZRyVHM
+Uc5R0VHUUddR2lHdUeBR41HmUelR7FHvUfJR9VH4UftR/lIBUgRSB1IKUg1SEFITUhZSGVIcUh9SIlIl
+UihSK1IuUjFSNFI3UjpSPVJAUkNSRlJJUkxST1JSUlVSWFJbUnhSi1KlUrlS/lMqUzZTY1QiVI5UplS9
+VVNVWlVmVX1VlFWvVcZV8lYgVklWYFZtVrxWz1dLV1VXbleIV7dXzVf2WBpYQVhVWG5Yg1iuWMNZbVmT
+WbBZx1nlWgZaE1ofWjhasFrIWvBbnluwW7xb1lviW/VcFlwpXDVcZFx+XOZc710PXVhdZV2OXaZd614J
+XiJeLl5FXlBeZl59Xotenl6yXsFe3F7uXwdfIl+XYDFgR2BfYHRgf2CwYWthd2GsYcViPGKFYpFjCmMf
+Y3JjiWO4Y9lj5mQKZCFkNGRUZGZk4WT4ZQRlHWUpZUhlb2WKZZ5lu2XHZf5mEmYeZiVmLmYxZjJmO2Y+
+Zj9mSGZLZ8ZnyGfKZ8xnz2fSZ9Rn12fZZ9xn3mfhZ+Rn52fqZ+xn7mfxZ/Nn9Wf3Z/ln+2f9Z/9oAmgE
+aAZoCGgKaAxoD2gSaBRoF2gZaBxoHmggaCNoJmgoaCtoLmgwaDNoNWg4aDtoPWg/aEJoRGhGaEhoS2hN
+aFBoU2hWaFloW2heaGFoY2hlaGdoaWhraG5ocGhzaHVod2h6aHxof2iBaINohWiIaIpojGiOaJBok2iV
+aJhommicaJ5ooGiiaKVoqGiqaK1or2iyaLRotmi5aLxov2jCaMVox2jJaMxozmjQaNJo1WjXaNpo3Gje
+aOBo4mjlaOdo6mjtaO9o8WjzaPVo+Gj7aP5pAGkCaQVpB2kKaQ1pD2kRaRRpF2kaaR1pH2kiaSRpJ2kp
+aSxpL2kyaTVpOGk6aT1pP2lBaURpRmlIaUtpTmlQaVNpVmlZaVtpXmlgaWNpZWlnaWlpbGluaXBpc2l2
+aXhpeml9aX9pgWmEaYZpiGmKaYxpj2mRaZppnWsYaxtrHmshayRrJ2sqay1rMGszazZrOWs8az9rQmtF
+a0hrS2tOa1FrVGtXa1prXWtga2NrZmtpa2xrb2tya3VreGt7a35rgWuEa4drimuNa5Brk2uWa5lrnGuf
+a6JrpWuoa6trrmuxa7Rrt2u6a71rwGvDa8ZryWvMa89r0mvVa9hr22vea+Fr5Gvna+pr7Wvwa/Nr9mv5
+a/xr/2wCbAVsCGwLbA5sEWwUbBdsGmwdbCBsI2wmbClsLGwvbDJsNWw4bDtsPmxBbERsR2xKbE1sUGxT
+bFZsWWxcbF9sYmxlbGhsa2xubHFsdGx3bHpsfWyAbINshmyJbIxsj2ySbJVsmGybbJ5soWykbKdsqmyt
+bLBss2y2bLlsvGy/bMJsxWzIbMtszmzRbNRs12zabN1s4GzjbOZs6WzsbO9s8mz1bPhs+2z+bQFtBG0H
+bQptDW0QbRNtFm0ZbRxtH20ibSVtKG0rbS5tMW00bTdtOm09bUBtQ21GbUltTG1ObVBtU21WbVltXG1f
+bWRtZ21pbWxtb210bXltfG1/bYRth22KbYxtjm2RbZRtmW2ebaNtqG2rba5tsW2zbbZtuW28bb9txG3H
+bcptzW3QbdVt2G3dbeBt423mbelt7G3vbfJt9236bf9uBG4HbgxuEW4UbhduGm4cbh9uIm4lbiduKm4t
+bjBuM244bjpuPG4+bkFuRG5JbkxuT25SblduWm5cbl9uYW5kbmZuaG5qbmxubm5xbnNudm55bnxugW6E
+boduim6NbpBulW6Ybptunm6gbqJupG6mbqlurG6vbrFutG63brpuvG6+bsBuxW7HbspuzW7PbtJu127a
+bt1u4m7kbulu627wbvNu9m74bvtu/W8AbwVvCG8Kbw1vEG8TbxZvGW8ebydvLG8ubzNvNm84bztvPm9D
+b0VvR29Mb1FvVG9Wb1tvXW9gb2NvZm9pb2xvbm9xb3Rvd296b31vgG+Cb4dvjG+Rb5NvlW+Yb5tvpG+m
+b6dvsG+zb7RvvW/Ab8Fvym/PAAAAAAAAAgIAAAAAAAANIAAAAAAAAAAAAAAAAAAAb94</bytes>
 		</object>
 	</data>
 </archive>
diff --git a/hw/xquartz/bundle/English.lproj/main.nib/keyedobjects.nib b/hw/xquartz/bundle/English.lproj/main.nib/keyedobjects.nib
index 194f4df..4306102 100644
Binary files a/hw/xquartz/bundle/English.lproj/main.nib/keyedobjects.nib and b/hw/xquartz/bundle/English.lproj/main.nib/keyedobjects.nib differ
commit fb52ef7c86d549991b4557438c252c6008ccbb5c
Author: Jeremy Huddleston <jeremy at tifa.local>
Date:   Sun Feb 10 16:34:40 2008 -0800

    XQuartz: Converted interface to nib 3.x format
    (cherry picked from commit 656aaab95773bd70fc3504b68bf7e1d292891d93)

diff --git a/hw/xquartz/bundle/English.lproj/main.nib/classes.nib b/hw/xquartz/bundle/English.lproj/main.nib/classes.nib
deleted file mode 100644
index a82159b..0000000
--- a/hw/xquartz/bundle/English.lproj/main.nib/classes.nib
+++ /dev/null
@@ -1,318 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>IBClasses</key>
-	<array>
-		<dict>
-			<key>CLASS</key>
-			<string>IBLibraryObjectTemplate</string>
-			<key>LANGUAGE</key>
-			<string>ObjC</string>
-			<key>OUTLETS</key>
-			<dict>
-				<key>draggedView</key>
-				<string>NSView</string>
-				<key>representedObject</key>
-				<string>NSObject</string>
-			</dict>
-			<key>SUPERCLASS</key>
-			<string>NSView</string>
-		</dict>
-		<dict>
-			<key>CLASS</key>
-			<string>IBInspector</string>
-			<key>LANGUAGE</key>
-			<string>ObjC</string>
-			<key>OUTLETS</key>
-			<dict>
-				<key>inspectorView</key>
-				<string>NSView</string>
-			</dict>
-			<key>SUPERCLASS</key>
-			<string>NSObject</string>
-		</dict>
-		<dict>
-			<key>CLASS</key>
-			<string>NSDateFormatter</string>
-			<key>LANGUAGE</key>
-			<string>ObjC</string>
-			<key>SUPERCLASS</key>
-			<string>NSFormatter</string>
-		</dict>
-		<dict>
-			<key>ACTIONS</key>
-			<dict>
-				<key>apps_table_cancel</key>
-				<string>id</string>
-				<key>apps_table_delete</key>
-				<string>id</string>
-				<key>apps_table_done</key>
-				<string>id</string>
-				<key>apps_table_duplicate</key>
-				<string>id</string>
-				<key>apps_table_new</key>
-				<string>id</string>
-				<key>apps_table_show</key>
-				<string>id</string>
-				<key>bring_to_front</key>
-				<string>id</string>
-				<key>close_window</key>
-				<string>id</string>
-				<key>enable_fullscreen_changed</key>
-				<string>id</string>
-				<key>minimize_window</key>
-				<string>id</string>
-				<key>next_window</key>
-				<string>id</string>
-				<key>prefs_changed</key>
-				<string>id</string>
-				<key>prefs_show</key>
-				<string>id</string>
-				<key>previous_window</key>
-				<string>id</string>
-				<key>toggle_fullscreen</key>
-				<string>id</string>
-				<key>x11_help</key>
-				<string>id</string>
-				<key>zoom_window</key>
-				<string>id</string>
-			</dict>
-			<key>CLASS</key>
-			<string>X11Controller</string>
-			<key>LANGUAGE</key>
-			<string>ObjC</string>
-			<key>OUTLETS</key>
-			<dict>
-				<key>apps_separator</key>
-				<string>id</string>
-				<key>apps_table</key>
-				<string>id</string>
-				<key>depth</key>
-				<string>id</string>
-				<key>dock_apps_menu</key>
-				<string>id</string>
-				<key>dock_menu</key>
-				<string>id</string>
-				<key>dock_window_separator</key>
-				<string>id</string>
-				<key>enable_auth</key>
-				<string>id</string>
-				<key>enable_fullscreen</key>
-				<string>id</string>
-				<key>enable_keyequivs</key>
-				<string>id</string>
-				<key>enable_tcp</key>
-				<string>id</string>
-				<key>fake_buttons</key>
-				<string>id</string>
-				<key>prefs_panel</key>
-				<string>id</string>
-				<key>sync_keymap</key>
-				<string>id</string>
-				<key>toggle_fullscreen_item</key>
-				<string>id</string>
-				<key>use_sysbeep</key>
-				<string>id</string>
-				<key>window_separator</key>
-				<string>id</string>
-				<key>x11_about_item</key>
-				<string>id</string>
-			</dict>
-			<key>SUPERCLASS</key>
-			<string>NSObject</string>
-		</dict>
-		<dict>
-			<key>CLASS</key>
-			<string>NSNumberFormatter</string>
-			<key>LANGUAGE</key>
-			<string>ObjC</string>
-			<key>SUPERCLASS</key>
-			<string>NSFormatter</string>
-		</dict>
-		<dict>
-			<key>CLASS</key>
-			<string>NSFormatter</string>
-			<key>LANGUAGE</key>
-			<string>ObjC</string>
-			<key>SUPERCLASS</key>
-			<string>NSObject</string>
-		</dict>
-		<dict>
-			<key>ACTIONS</key>
-			<dict>
-				<key>alignCenter:</key>
-				<string>id</string>
-				<key>alignJustified:</key>
-				<string>id</string>
-				<key>alignLeft:</key>
-				<string>id</string>
-				<key>alignRight:</key>
-				<string>id</string>
-				<key>arrangeInFront:</key>
-				<string>id</string>
-				<key>centerSelectionInVisibleArea:</key>
-				<string>id</string>
-				<key>changeFont:</key>
-				<string>id</string>
-				<key>checkSpelling:</key>
-				<string>id</string>
-				<key>clear:</key>
-				<string>id</string>
-				<key>clearRecentDocuments:</key>
-				<string>id</string>
-				<key>complete:</key>
-				<string>id</string>
-				<key>copy:</key>
-				<string>id</string>
-				<key>copyFont:</key>
-				<string>id</string>
-				<key>copyRuler:</key>
-				<string>id</string>
-				<key>cut:</key>
-				<string>id</string>
-				<key>delete:</key>
-				<string>id</string>
-				<key>deminiaturize:</key>
-				<string>id</string>
-				<key>fax:</key>
-				<string>id</string>
-				<key>hide:</key>
-				<string>id</string>
-				<key>hideOtherApplications:</key>
-				<string>id</string>
-				<key>loosenKerning:</key>
-				<string>id</string>
-				<key>lowerBaseline:</key>
-				<string>id</string>
-				<key>makeKeyAndOrderFront:</key>
-				<string>id</string>
-				<key>miniaturize:</key>
-				<string>id</string>
-				<key>newDocument:</key>
-				<string>id</string>
-				<key>openDocument:</key>
-				<string>id</string>
-				<key>orderBack:</key>
-				<string>id</string>
-				<key>orderFront:</key>
-				<string>id</string>
-				<key>orderFrontColorPanel:</key>
-				<string>id</string>
-				<key>orderFrontHelpPanel:</key>
-				<string>id</string>
-				<key>orderOut:</key>
-				<string>id</string>
-				<key>outline:</key>
-				<string>id</string>
-				<key>paste:</key>
-				<string>id</string>
-				<key>pasteAsPlainText:</key>
-				<string>id</string>
-				<key>pasteAsRichText:</key>
-				<string>id</string>
-				<key>pasteFont:</key>
-				<string>id</string>
-				<key>pasteRuler:</key>
-				<string>id</string>
-				<key>pause:</key>
-				<string>id</string>
-				<key>performClose:</key>
-				<string>id</string>
-				<key>performFindPanelAction:</key>
-				<string>id</string>
-				<key>performMiniaturize:</key>
-				<string>id</string>
-				<key>performZoom:</key>
-				<string>id</string>
-				<key>play:</key>
-				<string>id</string>
-				<key>print:</key>
-				<string>id</string>
-				<key>printDocument:</key>
-				<string>id</string>
-				<key>raiseBaseline:</key>
-				<string>id</string>
-				<key>record:</key>
-				<string>id</string>
-				<key>redo:</key>
-				<string>id</string>
-				<key>resume:</key>
-				<string>id</string>
-				<key>revertDocumentToSaved:</key>
-				<string>id</string>
-				<key>run:</key>
-				<string>id</string>
-				<key>runPageLayout:</key>
-				<string>id</string>
-				<key>runToolbarCustomizationPalette:</key>
-				<string>id</string>
-				<key>saveAllDocuments:</key>
-				<string>id</string>
-				<key>saveDocument:</key>
-				<string>id</string>
-				<key>saveDocumentAs:</key>
-				<string>id</string>
-				<key>saveDocumentTo:</key>
-				<string>id</string>
-				<key>selectAll:</key>
-				<string>id</string>
-				<key>selectText:</key>
-				<string>id</string>
-				<key>showGuessPanel:</key>
-				<string>id</string>
-				<key>showHelp:</key>
-				<string>id</string>
-				<key>start:</key>
-				<string>id</string>
-				<key>startSpeaking:</key>
-				<string>id</string>
-				<key>stop:</key>
-				<string>id</string>
-				<key>stopSpeaking:</key>
-				<string>id</string>
-				<key>subscript:</key>
-				<string>id</string>
-				<key>superscript:</key>
-				<string>id</string>
-				<key>terminate:</key>
-				<string>id</string>
-				<key>tightenKerning:</key>
-				<string>id</string>
-				<key>toggleContinuousSpellChecking:</key>
-				<string>id</string>
-				<key>toggleRuler:</key>
-				<string>id</string>
-				<key>toggleToolbarShown:</key>
-				<string>id</string>
-				<key>turnOffKerning:</key>
-				<string>id</string>
-				<key>turnOffLigatures:</key>
-				<string>id</string>
-				<key>underline:</key>
-				<string>id</string>
-				<key>undo:</key>
-				<string>id</string>
-				<key>unhideAllApplications:</key>
-				<string>id</string>
-				<key>unscript:</key>
-				<string>id</string>
-				<key>useAllLigatures:</key>
-				<string>id</string>
-				<key>useStandardKerning:</key>
-				<string>id</string>
-				<key>useStandardLigatures:</key>
-				<string>id</string>
-			</dict>
-			<key>CLASS</key>
-			<string>FirstResponder</string>
-			<key>LANGUAGE</key>
-			<string>ObjC</string>
-			<key>SUPERCLASS</key>
-			<string>NSObject</string>
-		</dict>
-	</array>
-	<key>IBVersion</key>
-	<integer>1</integer>
-</dict>
-</plist>
diff --git a/hw/xquartz/bundle/English.lproj/main.nib/designable.nib b/hw/xquartz/bundle/English.lproj/main.nib/designable.nib
new file mode 100644
index 0000000..c267e45
--- /dev/null
+++ b/hw/xquartz/bundle/English.lproj/main.nib/designable.nib
@@ -0,0 +1,4098 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.01">
+	<data>
+		<int key="IBDocument.SystemTarget">1050</int>
+		<string key="IBDocument.SystemVersion">9C31</string>
+		<string key="IBDocument.InterfaceBuilderVersion">629</string>
+		<string key="IBDocument.AppKitVersion">949.26</string>
+		<string key="IBDocument.HIToolboxVersion">352.00</string>
+		<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
+			<bool key="EncodedWithXMLCoder">YES</bool>
+		</object>
+		<object class="NSArray" key="IBDocument.PluginDependencies">
+			<bool key="EncodedWithXMLCoder">YES</bool>
+			<string id="874199827">com.apple.InterfaceBuilder.CocoaPlugin</string>
+		</object>
+		<object class="NSMutableArray" key="IBDocument.RootObjects" id="874420287">
+			<bool key="EncodedWithXMLCoder">YES</bool>
+			<object class="NSCustomObject" id="584863936">
+				<object class="NSMutableString" key="NSClassName">
+					<characters key="NS.bytes">NSApplication</characters>
+				</object>
+			</object>
+			<object class="NSCustomObject" id="518703249">
+				<string key="NSClassName">FirstResponder</string>
+			</object>
+			<object class="NSCustomObject" id="166373373">
+				<string key="NSClassName">NSApplication</string>
+			</object>
+			<object class="NSMenu" id="496556081">
+				<string key="NSTitle" id="414137626">MainMenu</string>
+				<object class="NSMutableArray" key="NSMenuItems">
+					<bool key="EncodedWithXMLCoder">YES</bool>
+					<object class="NSMenuItem" id="385138428">
+						<reference key="NSMenu" ref="496556081"/>
+						<string key="NSTitle" id="845099910">X11</string>
+						<string key="NSKeyEquiv" id="1005878359"/>
+						<int key="NSKeyEquivModMask">1048576</int>
+						<int key="NSMnemonicLoc">2147483647</int>
+						<object class="NSCustomResource" key="NSOnImage" id="732862070">
+							<string key="NSClassName" id="642323532">NSImage</string>
+							<string key="NSResourceName">NSMenuCheckmark</string>
+						</object>
+						<object class="NSCustomResource" key="NSMixedImage" id="154462367">
+							<reference key="NSClassName" ref="642323532"/>
+							<string key="NSResourceName">NSMenuMixedState</string>
+						</object>
+						<string key="NSAction">submenuAction:</string>
+						<object class="NSMenu" key="NSSubmenu" id="856655711">
+							<reference key="NSTitle" ref="845099910"/>
+							<object class="NSMutableArray" key="NSMenuItems">
+								<bool key="EncodedWithXMLCoder">YES</bool>
+								<object class="NSMenuItem" id="588913325">
+									<reference key="NSMenu" ref="856655711"/>
+									<string key="NSTitle">About X11</string>
+									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="732862070"/>
+									<reference key="NSMixedImage" ref="154462367"/>
+								</object>
+								<object class="NSMenuItem" id="836585695">
+									<reference key="NSMenu" ref="856655711"/>
+									<string key="NSTitle">Preferences...</string>
+									<string key="NSKeyEquiv">,</string>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="732862070"/>
+									<reference key="NSMixedImage" ref="154462367"/>
+								</object>
+								<object class="NSMenuItem" id="562920394">
+									<reference key="NSMenu" ref="856655711"/>
+									<bool key="NSIsDisabled">YES</bool>
+									<bool key="NSIsSeparator">YES</bool>
+									<reference key="NSTitle" ref="1005878359"/>
+									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="732862070"/>
+									<reference key="NSMixedImage" ref="154462367"/>
+								</object>
+								<object class="NSMenuItem" id="63158341">
+									<reference key="NSMenu" ref="856655711"/>
+									<string key="NSTitle">Services</string>
+									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="732862070"/>
+									<reference key="NSMixedImage" ref="154462367"/>
+									<string key="NSAction">submenuAction:</string>
+									<object class="NSMenu" key="NSSubmenu" id="502073457">
+										<object class="NSMutableString" key="NSTitle">
+											<characters key="NS.bytes">Services</characters>
+										</object>
+										<object class="NSMutableArray" key="NSMenuItems">
+											<bool key="EncodedWithXMLCoder">YES</bool>
+										</object>
+										<string key="NSName">_NSServicesMenu</string>
+									</object>
+								</object>
+								<object class="NSMenuItem" id="635454008">
+									<reference key="NSMenu" ref="856655711"/>
+									<bool key="NSIsDisabled">YES</bool>
+									<bool key="NSIsSeparator">YES</bool>
+									<reference key="NSTitle" ref="1005878359"/>
+									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="732862070"/>
+									<reference key="NSMixedImage" ref="154462367"/>
+								</object>
+								<object class="NSMenuItem" id="101686423">
+									<reference key="NSMenu" ref="856655711"/>
+									<string key="NSTitle">Toggle Full Screen</string>
+									<string key="NSKeyEquiv" id="982375500">a</string>
+									<int key="NSKeyEquivModMask">1572864</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="732862070"/>
+									<reference key="NSMixedImage" ref="154462367"/>
+								</object>
+								<object class="NSMenuItem" id="754231570">
+									<reference key="NSMenu" ref="856655711"/>
+									<bool key="NSIsDisabled">YES</bool>
+									<bool key="NSIsSeparator">YES</bool>
+									<reference key="NSTitle" ref="1005878359"/>
+									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="732862070"/>
+									<reference key="NSMixedImage" ref="154462367"/>
+								</object>
+								<object class="NSMenuItem" id="147703239">
+									<reference key="NSMenu" ref="856655711"/>
+									<string key="NSTitle">Hide X11</string>
+									<string key="NSKeyEquiv">h</string>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="732862070"/>
+									<reference key="NSMixedImage" ref="154462367"/>
+									<int key="NSTag">42</int>
+								</object>
+								<object class="NSMenuItem" id="191312176">
+									<reference key="NSMenu" ref="856655711"/>
+									<string key="NSTitle">Hide Others</string>
+									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="732862070"/>
+									<reference key="NSMixedImage" ref="154462367"/>
+								</object>
+								<object class="NSMenuItem" id="392807560">
+									<reference key="NSMenu" ref="856655711"/>
+									<string key="NSTitle">Show All</string>
+									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="732862070"/>
+									<reference key="NSMixedImage" ref="154462367"/>
+									<int key="NSTag">42</int>
+								</object>
+								<object class="NSMenuItem" id="648021277">
+									<reference key="NSMenu" ref="856655711"/>
+									<bool key="NSIsDisabled">YES</bool>
+									<bool key="NSIsSeparator">YES</bool>
+									<reference key="NSTitle" ref="1005878359"/>
+									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="732862070"/>
+									<reference key="NSMixedImage" ref="154462367"/>
+								</object>
+								<object class="NSMenuItem" id="275459236">
+									<reference key="NSMenu" ref="856655711"/>
+									<string key="NSTitle">Quit X11</string>
+									<string key="NSKeyEquiv">q</string>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="732862070"/>
+									<reference key="NSMixedImage" ref="154462367"/>
+								</object>
+							</object>
+							<string key="NSName">_NSAppleMenu</string>
+						</object>
+					</object>
+					<object class="NSMenuItem" id="940914550">
+						<reference key="NSMenu" ref="496556081"/>
+						<string key="NSTitle" id="942587293">Applications</string>
+						<reference key="NSKeyEquiv" ref="1005878359"/>
+						<int key="NSKeyEquivModMask">1048576</int>
+						<int key="NSMnemonicLoc">2147483647</int>
+						<reference key="NSOnImage" ref="732862070"/>
+						<reference key="NSMixedImage" ref="154462367"/>
+						<string key="NSAction">submenuAction:</string>
+						<object class="NSMenu" key="NSSubmenu" id="684156653">
+							<reference key="NSTitle" ref="942587293"/>
+							<object class="NSMutableArray" key="NSMenuItems">
+								<bool key="EncodedWithXMLCoder">YES</bool>
+								<object class="NSMenuItem" id="940363272">
+									<reference key="NSMenu" ref="684156653"/>
+									<bool key="NSIsDisabled">YES</bool>
+									<bool key="NSIsSeparator">YES</bool>
+									<reference key="NSTitle" ref="1005878359"/>
+									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="732862070"/>
+									<reference key="NSMixedImage" ref="154462367"/>
+								</object>
+								<object class="NSMenuItem" id="767830074">
+									<reference key="NSMenu" ref="684156653"/>
+									<string key="NSTitle">Customize...</string>
+									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="732862070"/>
+									<reference key="NSMixedImage" ref="154462367"/>
+								</object>
+							</object>
+						</object>
+					</object>
+					<object class="NSMenuItem" id="326076563">
+						<reference key="NSMenu" ref="496556081"/>
+						<string key="NSTitle" id="38701994">Edit</string>
+						<reference key="NSKeyEquiv" ref="1005878359"/>
+						<int key="NSKeyEquivModMask">1048576</int>
+						<int key="NSMnemonicLoc">2147483647</int>
+						<reference key="NSOnImage" ref="732862070"/>
+						<reference key="NSMixedImage" ref="154462367"/>
+						<string key="NSAction">submenuAction:</string>
+						<object class="NSMenu" key="NSSubmenu" id="932839819">
+							<reference key="NSTitle" ref="38701994"/>
+							<object class="NSMutableArray" key="NSMenuItems">
+								<bool key="EncodedWithXMLCoder">YES</bool>
+								<object class="NSMenuItem" id="159704190">
+									<reference key="NSMenu" ref="932839819"/>
+									<string key="NSTitle">Undo</string>
+									<string key="NSKeyEquiv">z</string>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="732862070"/>
+									<reference key="NSMixedImage" ref="154462367"/>
+								</object>
+								<object class="NSMenuItem" id="634656440">
+									<reference key="NSMenu" ref="932839819"/>
+									<string key="NSTitle">Redo</string>
+									<string key="NSKeyEquiv">Z</string>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="732862070"/>
+									<reference key="NSMixedImage" ref="154462367"/>
+								</object>
+								<object class="NSMenuItem" id="342107529">
+									<reference key="NSMenu" ref="932839819"/>
+									<bool key="NSIsDisabled">YES</bool>
+									<bool key="NSIsSeparator">YES</bool>
+									<reference key="NSTitle" ref="1005878359"/>
+									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="732862070"/>
+									<reference key="NSMixedImage" ref="154462367"/>
+								</object>
+								<object class="NSMenuItem" id="590926585">
+									<reference key="NSMenu" ref="932839819"/>
+									<string key="NSTitle">Cut</string>
+									<string key="NSKeyEquiv">x</string>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="732862070"/>
+									<reference key="NSMixedImage" ref="154462367"/>
+								</object>
+								<object class="NSMenuItem" id="204575684">
+									<reference key="NSMenu" ref="932839819"/>
+									<string key="NSTitle">Copy</string>
+									<string key="NSKeyEquiv">c</string>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="732862070"/>
+									<reference key="NSMixedImage" ref="154462367"/>
+								</object>
+								<object class="NSMenuItem" id="739720090">
+									<reference key="NSMenu" ref="932839819"/>
+									<string key="NSTitle">Paste</string>
+									<string key="NSKeyEquiv">v</string>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="732862070"/>
+									<reference key="NSMixedImage" ref="154462367"/>
+								</object>
+								<object class="NSMenuItem" id="549812830">
+									<reference key="NSMenu" ref="932839819"/>
+									<string key="NSTitle">Delete</string>
+									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="732862070"/>
+									<reference key="NSMixedImage" ref="154462367"/>
+								</object>
+								<object class="NSMenuItem" id="584461964">
+									<reference key="NSMenu" ref="932839819"/>
+									<string key="NSTitle">Select All</string>
+									<reference key="NSKeyEquiv" ref="982375500"/>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="732862070"/>
+									<reference key="NSMixedImage" ref="154462367"/>
+								</object>
+							</object>
+						</object>
+					</object>
+					<object class="NSMenuItem" id="736341863">
+						<reference key="NSMenu" ref="496556081"/>
+						<string key="NSTitle">Window</string>
+						<reference key="NSKeyEquiv" ref="1005878359"/>
+						<int key="NSKeyEquivModMask">1048576</int>
+						<int key="NSMnemonicLoc">2147483647</int>
+						<reference key="NSOnImage" ref="732862070"/>
+						<reference key="NSMixedImage" ref="154462367"/>
+						<string key="NSAction">submenuAction:</string>
+						<object class="NSMenu" key="NSSubmenu" id="943404979">
+							<object class="NSMutableString" key="NSTitle">
+								<characters key="NS.bytes">Window</characters>
+							</object>
+							<object class="NSMutableArray" key="NSMenuItems">
+								<bool key="EncodedWithXMLCoder">YES</bool>
+								<object class="NSMenuItem" id="915861349">
+									<reference key="NSMenu" ref="943404979"/>
+									<string key="NSTitle">Minimize Window</string>
+									<string key="NSKeyEquiv">m</string>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="732862070"/>
+									<reference key="NSMixedImage" ref="154462367"/>
+								</object>
+								<object class="NSMenuItem" id="442007350">
+									<reference key="NSMenu" ref="943404979"/>
+									<string key="NSTitle">Close Window</string>
+									<string key="NSKeyEquiv">w</string>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="732862070"/>
+									<reference key="NSMixedImage" ref="154462367"/>
+								</object>
+								<object class="NSMenuItem" id="722764538">
+									<reference key="NSMenu" ref="943404979"/>
+									<string key="NSTitle">Zoom Window</string>
+									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="732862070"/>
+									<reference key="NSMixedImage" ref="154462367"/>
+								</object>
+								<object class="NSMenuItem" id="783034074">
+									<reference key="NSMenu" ref="943404979"/>
+									<bool key="NSIsDisabled">YES</bool>
+									<bool key="NSIsSeparator">YES</bool>
+									<reference key="NSTitle" ref="1005878359"/>
+									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="732862070"/>
+									<reference key="NSMixedImage" ref="154462367"/>
+								</object>
+								<object class="NSMenuItem" id="283496700">
+									<reference key="NSMenu" ref="943404979"/>
+									<string key="NSTitle">Next Window</string>
+									<string type="base64-UTF8" key="NSKeyEquiv">75yDA</string>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="732862070"/>
+									<reference key="NSMixedImage" ref="154462367"/>
+								</object>
+								<object class="NSMenuItem" id="500397106">
+									<reference key="NSMenu" ref="943404979"/>
+									<string key="NSTitle">Previous Window</string>
+									<string type="base64-UTF8" key="NSKeyEquiv">75yCA</string>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="732862070"/>
+									<reference key="NSMixedImage" ref="154462367"/>
+								</object>
+								<object class="NSMenuItem" id="303213786">
+									<reference key="NSMenu" ref="943404979"/>
+									<bool key="NSIsDisabled">YES</bool>
+									<bool key="NSIsSeparator">YES</bool>
+									<reference key="NSTitle" ref="1005878359"/>
+									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="732862070"/>
+									<reference key="NSMixedImage" ref="154462367"/>
+								</object>
+								<object class="NSMenuItem" id="853630143">
+									<reference key="NSMenu" ref="943404979"/>
+									<string key="NSTitle">Bring All to Front</string>
+									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="732862070"/>
+									<reference key="NSMixedImage" ref="154462367"/>
+								</object>
+								<object class="NSMenuItem" id="332241222">
+									<reference key="NSMenu" ref="943404979"/>
+									<bool key="NSIsDisabled">YES</bool>
+									<bool key="NSIsSeparator">YES</bool>
+									<reference key="NSTitle" ref="1005878359"/>
+									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="732862070"/>
+									<reference key="NSMixedImage" ref="154462367"/>
+								</object>
+							</object>
+							<string key="NSName">_NSWindowsMenu</string>
+						</object>
+					</object>
+					<object class="NSMenuItem" id="934950259">
+						<reference key="NSMenu" ref="496556081"/>
+						<string key="NSTitle" id="955297347">Help</string>
+						<reference key="NSKeyEquiv" ref="1005878359"/>
+						<int key="NSKeyEquivModMask">1048576</int>
+						<int key="NSMnemonicLoc">2147483647</int>
+						<reference key="NSOnImage" ref="732862070"/>
+						<reference key="NSMixedImage" ref="154462367"/>
+						<string key="NSAction">submenuAction:</string>
+						<object class="NSMenu" key="NSSubmenu" id="1052262524">
+							<reference key="NSTitle" ref="955297347"/>
+							<object class="NSMutableArray" key="NSMenuItems">
+								<bool key="EncodedWithXMLCoder">YES</bool>
+								<object class="NSMenuItem" id="122992289">
+									<reference key="NSMenu" ref="1052262524"/>
+									<string key="NSTitle">X11 Help</string>
+									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="732862070"/>
+									<reference key="NSMixedImage" ref="154462367"/>
+								</object>
+							</object>
+						</object>
+					</object>
+				</object>
+				<string key="NSName">_NSMainMenu</string>
+			</object>
+			<object class="NSCustomObject" id="88064061">
+				<string key="NSClassName" id="517073442">X11Controller</string>
+			</object>
+			<object class="NSWindowTemplate" id="210544761">
+				<int key="NSWindowStyleMask">3</int>
+				<int key="NSWindowBacking">2</int>
+				<string key="NSWindowRect">{{319, 323}, {478, 316}}</string>
+				<int key="NSWTFlags">1350041600</int>
+				<string key="NSWindowTitle">X11 Preferences</string>
+				<string key="NSWindowClass" id="643663067">NSPanel</string>
+				<object class="NSMutableString" key="NSViewClass">
+					<characters key="NS.bytes">View</characters>
+				</object>
+				<string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string>
+				<string key="NSWindowContentMinSize">{213, 107}</string>
+				<object class="NSView" key="NSWindowView" id="404125972">
+					<nil key="NSNextResponder"/>
+					<int key="NSvFlags">256</int>
+					<object class="NSMutableArray" key="NSSubviews">
+						<bool key="EncodedWithXMLCoder">YES</bool>
+						<object class="NSTabView" id="75927203">
+							<reference key="NSNextResponder" ref="404125972"/>
+							<int key="NSvFlags">256</int>
+							<object class="NSMutableArray" key="NSSubviews">
+								<bool key="EncodedWithXMLCoder">YES</bool>
+								<object class="NSView" id="527709877">
+									<reference key="NSNextResponder" ref="75927203"/>
+									<int key="NSvFlags">256</int>
+									<object class="NSMutableArray" key="NSSubviews">
+										<bool key="EncodedWithXMLCoder">YES</bool>
+										<object class="NSButton" id="1045559310">
+											<reference key="NSNextResponder" ref="527709877"/>
+											<int key="NSvFlags">256</int>
+											<string key="NSFrame">{{18, 90}, {402, 18}}</string>
+											<reference key="NSSuperview" ref="527709877"/>
+											<bool key="NSEnabled">YES</bool>
+											<object class="NSButtonCell" key="NSCell" id="225158677">
+												<int key="NSCellFlags">67239424</int>
+												<int key="NSCellFlags2">0</int>
+												<string key="NSContents">Use system alert effect</string>
+												<object class="NSFont" key="NSSupport" id="706343604">
+													<string key="NSName" id="508374773">LucidaGrande</string>
+													<double key="NSSize">1.300000e+01</double>
+													<int key="NSfFlags">1044</int>
+												</object>
+												<reference key="NSControlView" ref="1045559310"/>
+												<int key="NSButtonFlags">1211912703</int>
+												<int key="NSButtonFlags2">2</int>
+												<object class="NSButtonImageSource" key="NSAlternateImage" id="876172194">
+													<string key="NSImageName">NSSwitch</string>
+												</object>
+												<reference key="NSAlternateContents" ref="1005878359"/>
+												<reference key="NSKeyEquivalent" ref="1005878359"/>
+												<int key="NSPeriodicDelay">200</int>
+												<int key="NSPeriodicInterval">25</int>
+											</object>
+										</object>
+										<object class="NSTextField" id="67626595">
+											<reference key="NSNextResponder" ref="527709877"/>
+											<int key="NSvFlags">256</int>
+											<string key="NSFrame">{{36, 56}, {385, 28}}</string>
+											<reference key="NSSuperview" ref="527709877"/>
+											<bool key="NSEnabled">YES</bool>
+											<object class="NSTextFieldCell" key="NSCell" id="1072420481">
+												<int key="NSCellFlags">67239424</int>
+												<int key="NSCellFlags2">4194304</int>
+												<string key="NSContents">X11 beeps will use the standard system alert, as defined in the Sound Effects system preferences panel.</string>
+												<object class="NSFont" key="NSSupport" id="26">
+													<reference key="NSName" ref="508374773"/>
+													<double key="NSSize">1.100000e+01</double>
+													<int key="NSfFlags">3100</int>
+												</object>
+												<reference key="NSControlView" ref="67626595"/>
+												<object class="NSColor" key="NSBackgroundColor" id="320865741">
+													<int key="NSColorSpace">6</int>
+													<string key="NSCatalogName" id="1000587476">System</string>
+													<string key="NSColorName">controlColor</string>
+													<object class="NSColor" key="NSColor" id="1000384962">
+														<int key="NSColorSpace">3</int>
+														<bytes key="NSWhite">MC42NjY2NjY2OQA</bytes>
+													</object>
+												</object>
+												<object class="NSColor" key="NSTextColor" id="233849662">
+													<int key="NSColorSpace">6</int>
+													<reference key="NSCatalogName" ref="1000587476"/>
+													<string key="NSColorName">controlTextColor</string>
+													<object class="NSColor" key="NSColor" id="608123050">
+														<int key="NSColorSpace">3</int>
+														<bytes key="NSWhite">MAA</bytes>
+													</object>
+												</object>
+											</object>
+										</object>
+										<object class="NSPopUpButton" id="300224954">
+											<reference key="NSNextResponder" ref="527709877"/>
+											<int key="NSvFlags">256</int>
+											<string key="NSFrame">{{74, 209}, {128, 26}}</string>
+											<reference key="NSSuperview" ref="527709877"/>
+											<bool key="NSEnabled">YES</bool>
+											<object class="NSPopUpButtonCell" key="NSCell" id="301142744">
+												<int key="NSCellFlags">-2076049856</int>
+												<int key="NSCellFlags2">1024</int>
+												<reference key="NSSupport" ref="706343604"/>
+												<reference key="NSControlView" ref="300224954"/>
+												<int key="NSButtonFlags">109199615</int>
+												<int key="NSButtonFlags2">1</int>
+												<object class="NSFont" key="NSAlternateImage">
+													<reference key="NSName" ref="508374773"/>
+													<double key="NSSize">1.300000e+01</double>
+													<int key="NSfFlags">16</int>
+												</object>
+												<object class="NSMutableString" key="NSAlternateContents">
+													<characters key="NS.bytes"/>
+												</object>
+												<object class="NSMutableString" key="NSKeyEquivalent">
+													<characters key="NS.bytes"/>
+												</object>
+												<int key="NSPeriodicDelay">400</int>
+												<int key="NSPeriodicInterval">75</int>
+												<object class="NSMenuItem" key="NSMenuItem" id="473657062">
+													<reference key="NSMenu" ref="1071781177"/>
+													<string key="NSTitle">From Display</string>
+													<reference key="NSKeyEquiv" ref="1005878359"/>
+													<int key="NSKeyEquivModMask">1048576</int>
+													<int key="NSMnemonicLoc">2147483647</int>
+													<int key="NSState">1</int>
+													<reference key="NSOnImage" ref="732862070"/>
+													<reference key="NSMixedImage" ref="154462367"/>
+													<string key="NSAction">_popUpItemAction:</string>
+													<int key="NSTag">-1</int>
+													<reference key="NSTarget" ref="301142744"/>
+												</object>
+												<bool key="NSMenuItemRespectAlignment">YES</bool>
+												<object class="NSMenu" key="NSMenu" id="1071781177">
+													<object class="NSMutableString" key="NSTitle">
+														<characters key="NS.bytes">OtherViews</characters>
+													</object>
+													<object class="NSMutableArray" key="NSMenuItems">
+														<bool key="EncodedWithXMLCoder">YES</bool>
+														<reference ref="473657062"/>
+														<object class="NSMenuItem" id="827519886">
+															<reference key="NSMenu" ref="1071781177"/>
+															<string key="NSTitle">256 Colors</string>
+															<reference key="NSKeyEquiv" ref="1005878359"/>
+															<int key="NSKeyEquivModMask">1048576</int>
+															<int key="NSMnemonicLoc">2147483647</int>
+															<reference key="NSOnImage" ref="732862070"/>
+															<reference key="NSMixedImage" ref="154462367"/>
+															<string key="NSAction">_popUpItemAction:</string>
+															<int key="NSTag">8</int>
+															<reference key="NSTarget" ref="301142744"/>
+														</object>
+														<object class="NSMenuItem" id="247508345">
+															<reference key="NSMenu" ref="1071781177"/>
+															<string key="NSTitle">Thousands</string>
+															<reference key="NSKeyEquiv" ref="1005878359"/>
+															<int key="NSKeyEquivModMask">1048576</int>
+															<int key="NSMnemonicLoc">2147483647</int>
+															<reference key="NSOnImage" ref="732862070"/>
+															<reference key="NSMixedImage" ref="154462367"/>
+															<string key="NSAction">_popUpItemAction:</string>
+															<int key="NSTag">15</int>
+															<reference key="NSTarget" ref="301142744"/>
+														</object>
+														<object class="NSMenuItem" id="611307925">
+															<reference key="NSMenu" ref="1071781177"/>
+															<string key="NSTitle">Millions</string>
+															<reference key="NSKeyEquiv" ref="1005878359"/>
+															<int key="NSKeyEquivModMask">1048576</int>
+															<int key="NSMnemonicLoc">2147483647</int>
+															<reference key="NSOnImage" ref="732862070"/>
+															<reference key="NSMixedImage" ref="154462367"/>
+															<string key="NSAction">_popUpItemAction:</string>
+															<int key="NSTag">24</int>
+															<reference key="NSTarget" ref="301142744"/>
+														</object>
+													</object>
+												</object>
+												<int key="NSPreferredEdge">3</int>
+												<bool key="NSUsesItemFromMenu">YES</bool>
+												<bool key="NSAltersState">YES</bool>
+												<int key="NSArrowPosition">1</int>
+											</object>
+										</object>
+										<object class="NSTextField" id="717889178">
+											<reference key="NSNextResponder" ref="527709877"/>
+											<int key="NSvFlags">256</int>
+											<string key="NSFrame">{{17, 212}, {55, 20}}</string>
+											<reference key="NSSuperview" ref="527709877"/>
+											<bool key="NSEnabled">YES</bool>
+											<object class="NSTextFieldCell" key="NSCell" id="749756205">
+												<int key="NSCellFlags">67239424</int>
+												<int key="NSCellFlags2">4194304</int>
+												<string type="base64-UTF8" key="NSContents">Q29sb3JzOgo</string>
+												<reference key="NSSupport" ref="706343604"/>
+												<reference key="NSControlView" ref="717889178"/>
+												<reference key="NSBackgroundColor" ref="320865741"/>
+												<reference key="NSTextColor" ref="233849662"/>
+											</object>
+										</object>
+										<object class="NSTextField" id="114173823">
+											<reference key="NSNextResponder" ref="527709877"/>
+											<int key="NSvFlags">256</int>
+											<string key="NSFrame">{{36, 190}, {392, 14}}</string>
+											<reference key="NSSuperview" ref="527709877"/>
+											<bool key="NSEnabled">YES</bool>
+											<object class="NSTextFieldCell" key="NSCell" id="725554783">
+												<int key="NSCellFlags">67239424</int>
+												<int key="NSCellFlags2">4194304</int>
+												<string key="NSContents">This option takes effect when X11 is launched again.</string>
+												<reference key="NSSupport" ref="26"/>
+												<reference key="NSControlView" ref="114173823"/>
+												<reference key="NSBackgroundColor" ref="320865741"/>
+												<reference key="NSTextColor" ref="233849662"/>
+											</object>
+										</object>
+										<object class="NSButton" id="817420822">
+											<reference key="NSNextResponder" ref="527709877"/>
+											<int key="NSvFlags">256</int>
+											<string key="NSFrame">{{18, 156}, {409, 23}}</string>
+											<reference key="NSSuperview" ref="527709877"/>
+											<bool key="NSEnabled">YES</bool>
+											<object class="NSButtonCell" key="NSCell" id="100363081">
+												<int key="NSCellFlags">67239424</int>
+												<int key="NSCellFlags2">0</int>
+												<string key="NSContents">Full screen mode</string>
+												<reference key="NSSupport" ref="706343604"/>
+												<reference key="NSControlView" ref="817420822"/>
+												<int key="NSButtonFlags">1211912703</int>
+												<int key="NSButtonFlags2">2</int>
+												<reference key="NSAlternateImage" ref="876172194"/>
+												<reference key="NSAlternateContents" ref="1005878359"/>
+												<reference key="NSKeyEquivalent" ref="1005878359"/>
+												<int key="NSPeriodicDelay">200</int>
+												<int key="NSPeriodicInterval">25</int>
+											</object>
+										</object>
+										<object class="NSTextField" id="959270736">
+											<reference key="NSNextResponder" ref="527709877"/>
+											<int key="NSvFlags">256</int>
+											<string key="NSFrame">{{36, 119}, {385, 31}}</string>
+											<reference key="NSSuperview" ref="527709877"/>
+											<bool key="NSEnabled">YES</bool>
+											<object class="NSTextFieldCell" key="NSCell" id="550432669">
+												<int key="NSCellFlags">67239424</int>
+												<int key="NSCellFlags2">4194304</int>
+												<string key="NSContents">Enables the X11 root window. Use the Command-Option-A keystroke to enter and leave full screen mode.</string>
+												<reference key="NSSupport" ref="26"/>
+												<reference key="NSControlView" ref="959270736"/>
+												<reference key="NSBackgroundColor" ref="320865741"/>
+												<reference key="NSTextColor" ref="233849662"/>
+											</object>
+										</object>
+									</object>
+									<string key="NSFrame">{{10, 33}, {438, 253}}</string>
+									<reference key="NSSuperview" ref="75927203"/>
+								</object>
+							</object>
+							<string key="NSFrame">{{10, 7}, {458, 299}}</string>
+							<reference key="NSSuperview" ref="404125972"/>
+							<object class="NSMutableArray" key="NSTabViewItems">
+								<bool key="EncodedWithXMLCoder">YES</bool>
+								<object class="NSTabViewItem" id="17244958">
+									<object class="NSMutableString" key="NSIdentifier">
+										<characters key="NS.bytes">1</characters>
+									</object>
+									<object class="NSView" key="NSView" id="600332710">
+										<nil key="NSNextResponder"/>
+										<int key="NSvFlags">256</int>
+										<object class="NSMutableArray" key="NSSubviews">
+											<bool key="EncodedWithXMLCoder">YES</bool>
+											<object class="NSButton" id="808306730">
+												<reference key="NSNextResponder" ref="600332710"/>
+												<int key="NSvFlags">256</int>
+												<string key="NSFrame">{{18, 217}, {402, 18}}</string>
+												<reference key="NSSuperview" ref="600332710"/>
+												<bool key="NSEnabled">YES</bool>
+												<object class="NSButtonCell" key="NSCell" id="727617204">
+													<int key="NSCellFlags">67239424</int>
+													<int key="NSCellFlags2">0</int>
+													<string key="NSContents">Emulate three button mouse</string>
+													<reference key="NSSupport" ref="706343604"/>
+													<reference key="NSControlView" ref="808306730"/>
+													<int key="NSButtonFlags">1211912703</int>
+													<int key="NSButtonFlags2">2</int>
+													<reference key="NSAlternateImage" ref="876172194"/>
+													<reference key="NSAlternateContents" ref="1005878359"/>
+													<reference key="NSKeyEquivalent" ref="1005878359"/>
+													<int key="NSPeriodicDelay">200</int>
+													<int key="NSPeriodicInterval">25</int>
+												</object>
+											</object>
+											<object class="NSTextField" id="618388983">
+												<reference key="NSNextResponder" ref="600332710"/>
+												<int key="NSvFlags">256</int>
+												<string key="NSFrame">{{36, 67}, {385, 31}}</string>
+												<reference key="NSSuperview" ref="600332710"/>
+												<bool key="NSEnabled">YES</bool>
+												<object class="NSTextFieldCell" key="NSCell" id="140236247">
+													<int key="NSCellFlags">67239424</int>
+													<int key="NSCellFlags2">4194304</int>
+													<string key="NSContents">When enabled, menu bar key equivalents may interfere with X11 applications that use the Meta modifier.</string>
+													<reference key="NSSupport" ref="26"/>
+													<reference key="NSControlView" ref="618388983"/>
+													<reference key="NSBackgroundColor" ref="320865741"/>
+													<reference key="NSTextColor" ref="233849662"/>
+												</object>
+											</object>
+											<object class="NSTextField" id="754792079">
+												<reference key="NSNextResponder" ref="600332710"/>
+												<int key="NSvFlags">256</int>
+												<string key="NSFrame">{{36, 182}, {385, 29}}</string>
+												<reference key="NSSuperview" ref="600332710"/>
+												<bool key="NSEnabled">YES</bool>
+												<object class="NSTextFieldCell" key="NSCell" id="110537159">
+													<int key="NSCellFlags">67239424</int>
+													<int key="NSCellFlags2">4194304</int>
+													<string type="base64-UTF8" key="NSContents">SG9sZCBPcHRpb24gYW5kIENvbW1hbmQgd2hpbGUgY2xpY2tpbmcgdG8gYWN0aXZhdGUgdGhlIG1pZGRs
+ZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KA</string>
+													<reference key="NSSupport" ref="26"/>
+													<reference key="NSControlView" ref="754792079"/>
+													<reference key="NSBackgroundColor" ref="320865741"/>
+													<reference key="NSTextColor" ref="233849662"/>
+												</object>
+											</object>
+											<object class="NSButton" id="677150201">
+												<reference key="NSNextResponder" ref="600332710"/>
+												<int key="NSvFlags">256</int>
+												<string key="NSFrame">{{18, 104}, {402, 18}}</string>
+												<reference key="NSSuperview" ref="600332710"/>
+												<bool key="NSEnabled">YES</bool>
+												<object class="NSButtonCell" key="NSCell" id="46680941">
+													<int key="NSCellFlags">67239424</int>
+													<int key="NSCellFlags2">0</int>
+													<string key="NSContents">Enable key equivalents under X11</string>
+													<reference key="NSSupport" ref="706343604"/>
+													<reference key="NSControlView" ref="677150201"/>
+													<int key="NSButtonFlags">1211912703</int>
+													<int key="NSButtonFlags2">2</int>
+													<reference key="NSAlternateImage" ref="876172194"/>
+													<reference key="NSAlternateContents" ref="1005878359"/>
+													<reference key="NSKeyEquivalent" ref="1005878359"/>
+													<int key="NSPeriodicDelay">200</int>
+													<int key="NSPeriodicInterval">25</int>
+												</object>
+											</object>
+											<object class="NSTextField" id="228801813">
+												<reference key="NSNextResponder" ref="600332710"/>
+												<int key="NSvFlags">256</int>
+												<string key="NSFrame">{{36, 133}, {385, 14}}</string>
+												<reference key="NSSuperview" ref="600332710"/>
+												<bool key="NSEnabled">YES</bool>
+												<object class="NSTextFieldCell" key="NSCell" id="415694484">
+													<int key="NSCellFlags">67239424</int>
+													<int key="NSCellFlags2">4194304</int>
+													<string key="NSContents">Allows input menu changes to overwrite the current X11 keymap.</string>
+													<reference key="NSSupport" ref="26"/>
+													<reference key="NSControlView" ref="228801813"/>
+													<reference key="NSBackgroundColor" ref="320865741"/>
+													<reference key="NSTextColor" ref="233849662"/>
+												</object>
+											</object>
+											<object class="NSButton" id="793493073">
+												<reference key="NSNextResponder" ref="600332710"/>
+												<int key="NSvFlags">256</int>
+												<string key="NSFrame">{{18, 153}, {402, 18}}</string>
+												<reference key="NSSuperview" ref="600332710"/>
+												<bool key="NSEnabled">YES</bool>
+												<object class="NSButtonCell" key="NSCell" id="466260504">
+													<int key="NSCellFlags">67239424</int>
+													<int key="NSCellFlags2">0</int>
+													<string key="NSContents">Follow system keyboard layout</string>
+													<reference key="NSSupport" ref="706343604"/>
+													<reference key="NSControlView" ref="793493073"/>
+													<int key="NSButtonFlags">1211912703</int>
+													<int key="NSButtonFlags2">2</int>
+													<reference key="NSAlternateImage" ref="876172194"/>
+													<reference key="NSAlternateContents" ref="1005878359"/>
+													<reference key="NSKeyEquivalent" ref="1005878359"/>
+													<int key="NSPeriodicDelay">200</int>
+													<int key="NSPeriodicInterval">25</int>
+												</object>
+											</object>
+										</object>
+										<string key="NSFrame">{{10, 33}, {438, 253}}</string>
+									</object>
+									<string key="NSLabel">Input</string>
+									<reference key="NSColor" ref="320865741"/>
+									<reference key="NSTabView" ref="75927203"/>
+								</object>
+								<object class="NSTabViewItem" id="493727923">
+									<object class="NSMutableString" key="NSIdentifier">
+										<characters key="NS.bytes">2</characters>
+									</object>
+									<reference key="NSView" ref="527709877"/>
+									<string key="NSLabel">Output</string>
+									<reference key="NSColor" ref="320865741"/>
+									<reference key="NSTabView" ref="75927203"/>
+								</object>
+								<object class="NSTabViewItem" id="1036577743">
+									<object class="NSView" key="NSView" id="536248195">
+										<nil key="NSNextResponder"/>
+										<int key="NSvFlags">256</int>
+										<object class="NSMutableArray" key="NSSubviews">
+											<bool key="EncodedWithXMLCoder">YES</bool>
+											<object class="NSButton" id="137435489">
+												<reference key="NSNextResponder" ref="536248195"/>
+												<int key="NSvFlags">256</int>
+												<string key="NSFrame">{{18, 217}, {402, 18}}</string>
+												<reference key="NSSuperview" ref="536248195"/>
+												<bool key="NSEnabled">YES</bool>
+												<object class="NSButtonCell" key="NSCell" id="891925158">
+													<int key="NSCellFlags">67239424</int>
+													<int key="NSCellFlags2">0</int>
+													<string key="NSContents">Authenticate connections</string>
+													<reference key="NSSupport" ref="706343604"/>
+													<reference key="NSControlView" ref="137435489"/>
+													<int key="NSButtonFlags">1211912703</int>
+													<int key="NSButtonFlags2">2</int>
+													<reference key="NSAlternateImage" ref="876172194"/>
+													<reference key="NSAlternateContents" ref="1005878359"/>
+													<reference key="NSKeyEquivalent" ref="1005878359"/>
+													<int key="NSPeriodicDelay">200</int>
+													<int key="NSPeriodicInterval">25</int>
+												</object>
+											</object>
+											<object class="NSButton" id="663154230">
+												<reference key="NSNextResponder" ref="536248195"/>
+												<int key="NSvFlags">256</int>
+												<string key="NSFrame">{{18, 140}, {402, 18}}</string>
+												<reference key="NSSuperview" ref="536248195"/>
+												<bool key="NSEnabled">YES</bool>
+												<object class="NSButtonCell" key="NSCell" id="836703945">
+													<int key="NSCellFlags">67239424</int>
+													<int key="NSCellFlags2">0</int>
+													<string key="NSContents">Allow connections from network clients</string>
+													<reference key="NSSupport" ref="706343604"/>
+													<reference key="NSControlView" ref="663154230"/>
+													<int key="NSButtonFlags">1211912703</int>
+													<int key="NSButtonFlags2">2</int>
+													<reference key="NSAlternateImage" ref="876172194"/>
+													<reference key="NSAlternateContents" ref="1005878359"/>
+													<reference key="NSKeyEquivalent" ref="1005878359"/>
+													<int key="NSPeriodicDelay">200</int>
+													<int key="NSPeriodicInterval">25</int>
+												</object>
+											</object>
+											<object class="NSTextField" id="417801719">
+												<reference key="NSNextResponder" ref="536248195"/>
+												<int key="NSvFlags">256</int>
+												<string key="NSFrame">{{36, 169}, {385, 42}}</string>
+												<reference key="NSSuperview" ref="536248195"/>
+												<bool key="NSEnabled">YES</bool>
+												<object class="NSTextFieldCell" key="NSCell" id="935570098">
+													<int key="NSCellFlags">67239424</int>
+													<int key="NSCellFlags2">4194304</int>
+													<string type="base64-UTF8" key="NSContents">TGF1bmNoaW5nIFgxMSB3aWxsIGNyZWF0ZSBYYXV0aG9yaXR5IGFjY2Vzcy1jb250cm9sIGtleXMuIElm
+IHRoZSBzeXN0ZW0ncyBJUCBhZGRyZXNzIGNoYW5nZXMsIHRoZXNlIGtleXMgYmVjb21lIGludmFsaWQg
+d2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy4</string>
+													<reference key="NSSupport" ref="26"/>
+													<reference key="NSControlView" ref="417801719"/>
+													<reference key="NSBackgroundColor" ref="320865741"/>
+													<reference key="NSTextColor" ref="233849662"/>
+												</object>
+											</object>
+											<object class="NSTextField" id="115954190">
+												<reference key="NSNextResponder" ref="536248195"/>
+												<int key="NSvFlags">256</int>
+												<string key="NSFrame">{{36, 92}, {385, 42}}</string>
+												<reference key="NSSuperview" ref="536248195"/>
+												<bool key="NSEnabled">YES</bool>
+												<object class="NSTextFieldCell" key="NSCell" id="144257898">
+													<int key="NSCellFlags">67239424</int>
+													<int key="NSCellFlags2">4194304</int>
+													<string key="NSContents">If enabled, Authenticate connections must also be enabled to ensure system security. When disabled, connections from remote applications are not allowed.</string>
+													<reference key="NSSupport" ref="26"/>
+													<reference key="NSControlView" ref="115954190"/>
+													<reference key="NSBackgroundColor" ref="320865741"/>
+													<reference key="NSTextColor" ref="233849662"/>
+												</object>
+											</object>
+											<object class="NSTextField" id="1067279202">
+												<reference key="NSNextResponder" ref="536248195"/>
+												<int key="NSvFlags">256</int>
+												<string key="NSFrame">{{17, 20}, {404, 14}}</string>
+												<reference key="NSSuperview" ref="536248195"/>
+												<bool key="NSEnabled">YES</bool>
+												<object class="NSTextFieldCell" key="NSCell" id="703874672">
+													<int key="NSCellFlags">67239424</int>
+													<int key="NSCellFlags2">4194304</int>
+													<string key="NSContents">These options take effect when X11 is next launched.</string>
+													<reference key="NSSupport" ref="26"/>
+													<reference key="NSControlView" ref="1067279202"/>
+													<reference key="NSBackgroundColor" ref="320865741"/>
+													<reference key="NSTextColor" ref="233849662"/>
+												</object>
+											</object>
+										</object>
+										<string key="NSFrame">{{10, 33}, {438, 253}}</string>
+									</object>
+									<string key="NSLabel">Security</string>
+									<reference key="NSColor" ref="320865741"/>
+									<reference key="NSTabView" ref="75927203"/>
+								</object>
+							</object>
+							<reference key="NSSelectedTabViewItem" ref="493727923"/>
+							<reference key="NSFont" ref="706343604"/>
+							<int key="NSTvFlags">0</int>
+							<bool key="NSAllowTruncatedLabels">YES</bool>
+							<bool key="NSDrawsBackground">YES</bool>
+						</object>
+					</object>
+					<string key="NSFrameSize">{478, 316}</string>
+				</object>
+				<string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
+				<string key="NSMinSize">{213, 129}</string>
+				<string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
+				<string key="NSFrameAutosaveName">x11_prefs</string>
+			</object>
+			<object class="NSWindowTemplate" id="796776534">
+				<int key="NSWindowStyleMask">11</int>
+				<int key="NSWindowBacking">2</int>
+				<string key="NSWindowRect">{{279, 270}, {486, 310}}</string>
+				<int key="NSWTFlags">1350041600</int>
+				<string key="NSWindowTitle">X11 Application Menu</string>
+				<reference key="NSWindowClass" ref="643663067"/>
+				<object class="NSMutableString" key="NSViewClass">
+					<characters key="NS.bytes">View</characters>
+				</object>
+				<string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string>
+				<string key="NSWindowContentMinSize">{213, 107}</string>
+				<object class="NSView" key="NSWindowView" id="1039094689">
+					<nil key="NSNextResponder"/>
+					<int key="NSvFlags">256</int>
+					<object class="NSMutableArray" key="NSSubviews">
+						<bool key="EncodedWithXMLCoder">YES</bool>
+						<object class="NSButton" id="1002101696">
+							<reference key="NSNextResponder" ref="1039094689"/>
+							<int key="NSvFlags">303</int>
+							<string key="NSFrame">{{388, 12}, {84, 32}}</string>
+							<reference key="NSSuperview" ref="1039094689"/>
+							<bool key="NSEnabled">YES</bool>
+							<object class="NSButtonCell" key="NSCell" id="558394524">
+								<int key="NSCellFlags">-2080244224</int>
+								<int key="NSCellFlags2">137887744</int>
+								<string key="NSContents">Done</string>
+								<reference key="NSSupport" ref="706343604"/>
+								<reference key="NSControlView" ref="1002101696"/>
+								<int key="NSButtonFlags">-2038284033</int>
+								<int key="NSButtonFlags2">1</int>
+								<object class="NSFont" key="NSAlternateImage" id="965938342">
+									<string key="NSName">Helvetica</string>
+									<double key="NSSize">1.300000e+01</double>
+									<int key="NSfFlags">16</int>
+								</object>
+								<reference key="NSAlternateContents" ref="1005878359"/>
+								<object class="NSMutableString" key="NSKeyEquivalent">
+									<characters key="NS.bytes"/>
+								</object>
+								<int key="NSPeriodicDelay">200</int>
+								<int key="NSPeriodicInterval">25</int>
+							</object>
+						</object>
+						<object class="NSButton" id="711288662">
+							<reference key="NSNextResponder" ref="1039094689"/>
+							<int key="NSvFlags">301</int>
+							<string key="NSFrame">{{372, 230}, {100, 32}}</string>
+							<reference key="NSSuperview" ref="1039094689"/>
+							<bool key="NSEnabled">YES</bool>
+							<object class="NSButtonCell" key="NSCell" id="413164923">
+								<int key="NSCellFlags">67239424</int>
+								<int key="NSCellFlags2">137887744</int>
+								<string key="NSContents">Duplicate</string>
+								<reference key="NSSupport" ref="706343604"/>
+								<reference key="NSControlView" ref="711288662"/>
+								<int key="NSButtonFlags">-2038284033</int>
+								<int key="NSButtonFlags2">1</int>
+								<reference key="NSAlternateImage" ref="965938342"/>
+								<object class="NSMutableString" key="NSAlternateContents">
+									<characters key="NS.bytes"/>
+								</object>
+								<object class="NSMutableString" key="NSKeyEquivalent">
+									<characters key="NS.bytes"/>
+								</object>
+								<int key="NSPeriodicDelay">200</int>
+								<int key="NSPeriodicInterval">25</int>
+							</object>
+						</object>
+						<object class="NSButton" id="634701477">
+							<reference key="NSNextResponder" ref="1039094689"/>
+							<int key="NSvFlags">301</int>
+							<string key="NSFrame">{{372, 198}, {100, 32}}</string>
+							<reference key="NSSuperview" ref="1039094689"/>
+							<bool key="NSEnabled">YES</bool>
+							<object class="NSButtonCell" key="NSCell" id="26248495">
+								<int key="NSCellFlags">67239424</int>
+								<int key="NSCellFlags2">137887744</int>
+								<string key="NSContents">Remove</string>
+								<reference key="NSSupport" ref="706343604"/>
+								<reference key="NSControlView" ref="634701477"/>
+								<int key="NSButtonFlags">-2038284033</int>
+								<int key="NSButtonFlags2">1</int>
+								<reference key="NSAlternateImage" ref="965938342"/>
+								<object class="NSMutableString" key="NSAlternateContents">
+									<characters key="NS.bytes"/>
+								</object>
+								<object class="NSMutableString" key="NSKeyEquivalent">
+									<characters key="NS.bytes"/>
+								</object>
+								<int key="NSPeriodicDelay">200</int>
+								<int key="NSPeriodicInterval">25</int>
+							</object>
+						</object>
+						<object class="NSScrollView" id="1011512617">
+							<reference key="NSNextResponder" ref="1039094689"/>
+							<int key="NSvFlags">307</int>
+							<object class="NSMutableArray" key="NSSubviews">
+								<bool key="EncodedWithXMLCoder">YES</bool>
+								<object class="NSClipView" id="963977695">
+									<reference key="NSNextResponder" ref="1011512617"/>
+									<int key="NSvFlags">2304</int>
+									<object class="NSMutableArray" key="NSSubviews">
+										<bool key="EncodedWithXMLCoder">YES</bool>
+										<object class="NSTableView" id="411425856">
+											<reference key="NSNextResponder" ref="963977695"/>
+											<int key="NSvFlags">256</int>
+											<string key="NSFrameSize">{333, 197}</string>
+											<reference key="NSSuperview" ref="963977695"/>
+											<bool key="NSEnabled">YES</bool>
+											<object class="NSTableHeaderView" key="NSHeaderView" id="526973850">
+												<reference key="NSNextResponder" ref="935843221"/>
+												<int key="NSvFlags">256</int>
+												<string key="NSFrameSize">{333, 17}</string>
+												<reference key="NSSuperview" ref="935843221"/>
+												<reference key="NSTableView" ref="411425856"/>
+											</object>
+											<object class="_NSCornerView" key="NSCornerView" id="182265797">
+												<reference key="NSNextResponder" ref="1011512617"/>
+												<int key="NSvFlags">256</int>
+												<string key="NSFrame">{{334, 0}, {16, 17}}</string>
+												<reference key="NSSuperview" ref="1011512617"/>
+											</object>
+											<object class="NSMutableArray" key="NSTableColumns">
+												<bool key="EncodedWithXMLCoder">YES</bool>
+												<object class="NSTableColumn" id="621551865">
+													<double key="NSWidth">7.900000e+01</double>
+													<double key="NSMinWidth">4.000000e+01</double>
+													<double key="NSMaxWidth">1.000000e+03</double>
+													<object class="NSTableHeaderCell" key="NSHeaderCell">
+														<int key="NSCellFlags">75628032</int>
+														<int key="NSCellFlags2">0</int>
+														<string key="NSContents">Name</string>
+														<reference key="NSSupport" ref="26"/>
+														<object class="NSColor" key="NSBackgroundColor" id="182967138">
+															<int key="NSColorSpace">3</int>
+															<bytes key="NSWhite">MC4zMzMzMzI5OQA</bytes>
+														</object>
+														<object class="NSColor" key="NSTextColor" id="645274518">
+															<int key="NSColorSpace">6</int>
+															<reference key="NSCatalogName" ref="1000587476"/>
+															<string key="NSColorName">headerTextColor</string>
+															<reference key="NSColor" ref="608123050"/>
+														</object>
+													</object>
+													<object class="NSTextFieldCell" key="NSDataCell" id="195831317">
+														<int key="NSCellFlags">338820672</int>
+														<int key="NSCellFlags2">1024</int>
+														<reference key="NSSupport" ref="706343604"/>
+														<reference key="NSControlView" ref="411425856"/>
+														<object class="NSColor" key="NSBackgroundColor" id="722293876">
+															<int key="NSColorSpace">3</int>
+															<bytes key="NSWhite">MQA</bytes>
+														</object>
+														<reference key="NSTextColor" ref="233849662"/>
+													</object>
+													<int key="NSResizingMask">3</int>
+													<bool key="NSIsResizeable">YES</bool>
+													<bool key="NSIsEditable">YES</bool>
+													<reference key="NSTableView" ref="411425856"/>
+												</object>
+												<object class="NSTableColumn" id="976084317">
+													<double key="NSWidth">1.937310e+02</double>
+													<double key="NSMinWidth">6.273100e+01</double>
+													<double key="NSMaxWidth">1.000000e+03</double>
+													<object class="NSTableHeaderCell" key="NSHeaderCell">
+														<int key="NSCellFlags">75628032</int>
+														<int key="NSCellFlags2">0</int>
+														<string key="NSContents">Command</string>
+														<reference key="NSSupport" ref="26"/>
+														<reference key="NSBackgroundColor" ref="182967138"/>
+														<reference key="NSTextColor" ref="645274518"/>
+													</object>
+													<object class="NSTextFieldCell" key="NSDataCell" id="656574062">
+														<int key="NSCellFlags">338820672</int>
+														<int key="NSCellFlags2">1024</int>
+														<reference key="NSSupport" ref="706343604"/>
+														<reference key="NSControlView" ref="411425856"/>
+														<reference key="NSBackgroundColor" ref="722293876"/>
+														<reference key="NSTextColor" ref="233849662"/>
+													</object>
+													<int key="NSResizingMask">3</int>
+													<bool key="NSIsResizeable">YES</bool>
+													<bool key="NSIsEditable">YES</bool>
+													<reference key="NSTableView" ref="411425856"/>
+												</object>
+												<object class="NSTableColumn" id="661701503">
+													<double key="NSWidth">5.100000e+01</double>
+													<double key="NSMinWidth">1.000000e+01</double>
+													<double key="NSMaxWidth">1.000000e+03</double>
+													<object class="NSTableHeaderCell" key="NSHeaderCell">
+														<int key="NSCellFlags">67239424</int>
+														<int key="NSCellFlags2">0</int>
+														<string key="NSContents">Shortcut</string>
+														<reference key="NSSupport" ref="26"/>
+														<object class="NSColor" key="NSBackgroundColor">
+															<int key="NSColorSpace">6</int>
+															<reference key="NSCatalogName" ref="1000587476"/>
+															<string key="NSColorName">headerColor</string>
+															<reference key="NSColor" ref="722293876"/>
+														</object>
+														<reference key="NSTextColor" ref="645274518"/>
+													</object>
+													<object class="NSTextFieldCell" key="NSDataCell" id="90031137">
+														<int key="NSCellFlags">338820672</int>
+														<int key="NSCellFlags2">1024</int>
+														<object class="NSFont" key="NSSupport">
+															<reference key="NSName" ref="508374773"/>
+															<double key="NSSize">1.200000e+01</double>
+															<int key="NSfFlags">16</int>
+														</object>
+														<reference key="NSControlView" ref="411425856"/>
+														<bool key="NSDrawsBackground">YES</bool>
+														<object class="NSColor" key="NSBackgroundColor" id="447702889">
+															<int key="NSColorSpace">6</int>
+															<reference key="NSCatalogName" ref="1000587476"/>
+															<string key="NSColorName">controlBackgroundColor</string>
+															<reference key="NSColor" ref="1000384962"/>
+														</object>
+														<reference key="NSTextColor" ref="233849662"/>
+													</object>
+													<int key="NSResizingMask">3</int>
+													<bool key="NSIsResizeable">YES</bool>
+													<bool key="NSIsEditable">YES</bool>
+													<reference key="NSTableView" ref="411425856"/>
+												</object>
+											</object>
+											<double key="NSIntercellSpacingWidth">3.000000e+00</double>
+											<double key="NSIntercellSpacingHeight">2.000000e+00</double>
+											<reference key="NSBackgroundColor" ref="722293876"/>
+											<object class="NSColor" key="NSGridColor">
+												<int key="NSColorSpace">6</int>
+												<reference key="NSCatalogName" ref="1000587476"/>
+												<string key="NSColorName">gridColor</string>
+												<object class="NSColor" key="NSColor">
+													<int key="NSColorSpace">3</int>
+													<bytes key="NSWhite">MC41AA</bytes>
+												</object>
+											</object>
+											<double key="NSRowHeight">1.700000e+01</double>
+											<int key="NSTvFlags">1379958784</int>
+											<int key="NSColumnAutoresizingStyle">1</int>
+											<int key="NSDraggingSourceMaskForLocal">-1</int>
+											<int key="NSDraggingSourceMaskForNonLocal">0</int>
+											<bool key="NSAllowsTypeSelect">YES</bool>
+										</object>
+									</object>
+									<string key="NSFrame">{{1, 17}, {333, 197}}</string>
+									<reference key="NSSuperview" ref="1011512617"/>
+									<reference key="NSNextKeyView" ref="411425856"/>
+									<reference key="NSDocView" ref="411425856"/>
+									<reference key="NSBGColor" ref="447702889"/>
+									<int key="NScvFlags">4</int>
+								</object>
+								<object class="NSScroller" id="152467947">
+									<reference key="NSNextResponder" ref="1011512617"/>
+									<int key="NSvFlags">256</int>
+									<string key="NSFrame">{{334, 17}, {15, 197}}</string>
+									<reference key="NSSuperview" ref="1011512617"/>
+									<reference key="NSTarget" ref="1011512617"/>
+									<string key="NSAction" id="607822787">_doScroller:</string>
+									<double key="NSPercent">9.949238e-01</double>
+								</object>
+								<object class="NSScroller" id="208024104">
+									<reference key="NSNextResponder" ref="1011512617"/>
+									<int key="NSvFlags">256</int>
+									<string key="NSFrame">{{1, 214}, {333, 15}}</string>
+									<reference key="NSSuperview" ref="1011512617"/>
+									<int key="NSsFlags">1</int>
+									<reference key="NSTarget" ref="1011512617"/>
+									<reference key="NSAction" ref="607822787"/>
+									<double key="NSPercent">9.940299e-01</double>
+								</object>
+								<object class="NSClipView" id="935843221">
+									<reference key="NSNextResponder" ref="1011512617"/>
+									<int key="NSvFlags">2304</int>
+									<object class="NSMutableArray" key="NSSubviews">
+										<bool key="EncodedWithXMLCoder">YES</bool>
+										<reference ref="526973850"/>
+									</object>
+									<string key="NSFrame">{{1, 0}, {333, 17}}</string>
+									<reference key="NSSuperview" ref="1011512617"/>
+									<reference key="NSNextKeyView" ref="526973850"/>
+									<reference key="NSDocView" ref="526973850"/>
+									<reference key="NSBGColor" ref="447702889"/>
+									<int key="NScvFlags">4</int>
+								</object>
+								<reference ref="182265797"/>
+							</object>
+							<string key="NSFrame">{{20, 60}, {350, 230}}</string>
+							<reference key="NSSuperview" ref="1039094689"/>
+							<reference key="NSNextKeyView" ref="963977695"/>
+							<int key="NSsFlags">50</int>
+							<reference key="NSVScroller" ref="152467947"/>
+							<reference key="NSHScroller" ref="208024104"/>
+							<reference key="NSContentView" ref="963977695"/>
+							<reference key="NSHeaderClipView" ref="935843221"/>
+							<bytes key="NSScrollAmts">QSAAAEEgAABBmAAAQZgAAA</bytes>
+						</object>
+						<object class="NSButton" id="859414998">
+							<reference key="NSNextResponder" ref="1039094689"/>
+							<int key="NSvFlags">303</int>
+							<string key="NSFrame">{{304, 12}, {84, 32}}</string>
+							<reference key="NSSuperview" ref="1039094689"/>
+							<bool key="NSEnabled">YES</bool>
+							<object class="NSButtonCell" key="NSCell" id="537937846">
+								<int key="NSCellFlags">67239424</int>
+								<int key="NSCellFlags2">137887744</int>
+								<string key="NSContents">Cancel</string>
+								<reference key="NSSupport" ref="706343604"/>
+								<reference key="NSControlView" ref="859414998"/>
+								<int key="NSButtonFlags">-2038284033</int>
+								<int key="NSButtonFlags2">1</int>
+								<reference key="NSAlternateImage" ref="965938342"/>
+								<object class="NSMutableString" key="NSAlternateContents">
+									<characters key="NS.bytes"/>
+								</object>
+								<object class="NSMutableString" key="NSKeyEquivalent">
+									<characters key="NS.bytes"/>
+								</object>
+								<int key="NSPeriodicDelay">200</int>
+								<int key="NSPeriodicInterval">25</int>
+							</object>
+						</object>
+						<object class="NSButton" id="381268760">
+							<reference key="NSNextResponder" ref="1039094689"/>
+							<int key="NSvFlags">301</int>
+							<string key="NSFrame">{{372, 262}, {100, 32}}</string>
+							<reference key="NSSuperview" ref="1039094689"/>
+							<bool key="NSEnabled">YES</bool>
+							<object class="NSButtonCell" key="NSCell" id="99903682">
+								<int key="NSCellFlags">67239424</int>
+								<int key="NSCellFlags2">137887744</int>
+								<string key="NSContents">Add Item</string>
+								<reference key="NSSupport" ref="706343604"/>
+								<reference key="NSControlView" ref="381268760"/>
+								<int key="NSButtonFlags">-2038284033</int>
+								<int key="NSButtonFlags2">1</int>
+								<reference key="NSAlternateImage" ref="965938342"/>
+								<object class="NSMutableString" key="NSAlternateContents">
+									<characters key="NS.bytes"/>
+								</object>
+								<object class="NSMutableString" key="NSKeyEquivalent">
+									<characters key="NS.bytes"/>
+								</object>
+								<int key="NSPeriodicDelay">200</int>
+								<int key="NSPeriodicInterval">25</int>
+							</object>
+						</object>
+					</object>
+					<string key="NSFrame">{{1, 1}, {486, 310}}</string>
+				</object>
+				<string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
+				<string key="NSMinSize">{213, 129}</string>
+				<string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
+				<string key="NSFrameAutosaveName">x11_apps</string>
+			</object>
+			<object class="NSMenu" id="1001514180">
+				<string key="NSTitle">Menu</string>
+				<object class="NSMutableArray" key="NSMenuItems">
+					<bool key="EncodedWithXMLCoder">YES</bool>
+					<object class="NSMenuItem" id="355724345">
+						<reference key="NSMenu" ref="1001514180"/>
+						<bool key="NSIsDisabled">YES</bool>
+						<bool key="NSIsSeparator">YES</bool>
+						<reference key="NSTitle" ref="1005878359"/>
+						<reference key="NSKeyEquiv" ref="1005878359"/>
+						<int key="NSKeyEquivModMask">1048576</int>
+						<int key="NSMnemonicLoc">2147483647</int>
+						<reference key="NSOnImage" ref="732862070"/>
+						<reference key="NSMixedImage" ref="154462367"/>
+					</object>
+					<object class="NSMenuItem" id="107275095">
+						<reference key="NSMenu" ref="1001514180"/>
+						<reference key="NSTitle" ref="942587293"/>
+						<reference key="NSKeyEquiv" ref="1005878359"/>
+						<int key="NSKeyEquivModMask">1048576</int>
+						<int key="NSMnemonicLoc">2147483647</int>
+						<reference key="NSOnImage" ref="732862070"/>
+						<reference key="NSMixedImage" ref="154462367"/>
+						<string key="NSAction">submenuAction:</string>
+						<object class="NSMenu" key="NSSubmenu" id="321919370">
+							<reference key="NSTitle" ref="942587293"/>
+							<object class="NSMutableArray" key="NSMenuItems">
+								<bool key="EncodedWithXMLCoder">YES</bool>
+								<object class="NSMenuItem" id="500771766">
+									<reference key="NSMenu" ref="321919370"/>
+									<bool key="NSIsDisabled">YES</bool>
+									<bool key="NSIsSeparator">YES</bool>
+									<reference key="NSTitle" ref="1005878359"/>
+									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="732862070"/>
+									<reference key="NSMixedImage" ref="154462367"/>
+								</object>
+								<object class="NSMenuItem" id="656726997">
+									<reference key="NSMenu" ref="321919370"/>
+									<string type="base64-UTF8" key="NSTitle">Q3VzdG9taXpl4oCmA</string>
+									<reference key="NSKeyEquiv" ref="1005878359"/>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<reference key="NSOnImage" ref="732862070"/>
+									<reference key="NSMixedImage" ref="154462367"/>
+								</object>
+							</object>
+						</object>
+					</object>
+				</object>
+				<reference key="NSName" ref="1005878359"/>
+			</object>
+		</object>
+		<object class="IBObjectContainer" key="IBDocument.Objects">
+			<object class="NSMutableArray" key="connectionRecords">
+				<bool key="EncodedWithXMLCoder">YES</bool>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">cut:</string>
+						<reference key="source" ref="518703249"/>
+						<reference key="destination" ref="590926585"/>
+					</object>
+					<int key="connectionID">175</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">paste:</string>
+						<reference key="source" ref="518703249"/>
+						<reference key="destination" ref="739720090"/>
+					</object>
+					<int key="connectionID">176</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">redo:</string>
+						<reference key="source" ref="518703249"/>
+						<reference key="destination" ref="634656440"/>
+					</object>
+					<int key="connectionID">178</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">selectAll:</string>
+						<reference key="source" ref="518703249"/>
+						<reference key="destination" ref="584461964"/>
+					</object>
+					<int key="connectionID">179</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">undo:</string>
+						<reference key="source" ref="518703249"/>
+						<reference key="destination" ref="159704190"/>
+					</object>
+					<int key="connectionID">180</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">copy:</string>
+						<reference key="source" ref="518703249"/>
+						<reference key="destination" ref="204575684"/>
+					</object>
+					<int key="connectionID">181</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">delete:</string>
+						<reference key="source" ref="518703249"/>
+						<reference key="destination" ref="549812830"/>
+					</object>
+					<int key="connectionID">195</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">minimize_window:</string>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="915861349"/>
+					</object>
+					<int key="connectionID">202</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">close_window:</string>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="442007350"/>
+					</object>
+					<int key="connectionID">205</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">zoom_window:</string>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="722764538"/>
+					</object>
+					<int key="connectionID">206</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">bring_to_front:</string>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="853630143"/>
+					</object>
+					<int key="connectionID">207</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBOutletConnection" key="connection">
+						<string key="label">window_separator</string>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="332241222"/>
+					</object>
+					<int key="connectionID">260</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">hideOtherApplications:</string>
+						<reference key="source" ref="584863936"/>
+						<reference key="destination" ref="191312176"/>
+					</object>
+					<int key="connectionID">263</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBOutletConnection" key="connection">
+						<string key="label">apps_separator</string>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="940363272"/>
+					</object>
+					<int key="connectionID">273</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBOutletConnection" key="connection">
+						<string key="label">apps_table</string>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="411425856"/>
+					</object>
+					<int key="connectionID">301</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">apps_table_done:</string>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="1002101696"/>
+					</object>
+					<int key="connectionID">302</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">apps_table_delete:</string>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="634701477"/>
+					</object>
+					<int key="connectionID">303</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">apps_table_duplicate:</string>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="711288662"/>
+					</object>
+					<int key="connectionID">304</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label" id="178478735">apps_table_show:</string>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="767830074"/>
+					</object>
+					<int key="connectionID">308</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">apps_table_cancel:</string>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="859414998"/>
+					</object>
+					<int key="connectionID">309</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">apps_table_new:</string>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="381268760"/>
+					</object>
+					<int key="connectionID">311</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">prefs_show:</string>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="836585695"/>
+					</object>
+					<int key="connectionID">318</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBOutletConnection" key="connection">
+						<string key="label">x11_about_item</string>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="588913325"/>
+					</object>
+					<int key="connectionID">321</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBOutletConnection" key="connection">
+						<string key="label">enable_auth</string>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="137435489"/>
+					</object>
+					<int key="connectionID">387</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBOutletConnection" key="connection">
+						<string key="label">enable_tcp</string>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="663154230"/>
+					</object>
+					<int key="connectionID">388</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBOutletConnection" key="connection">
+						<string key="label">depth</string>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="300224954"/>
+					</object>
+					<int key="connectionID">389</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBOutletConnection" key="connection">
+						<string key="label">use_sysbeep</string>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="1045559310"/>
+					</object>
+					<int key="connectionID">390</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBOutletConnection" key="connection">
+						<string key="label">fake_buttons</string>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="808306730"/>
+					</object>
+					<int key="connectionID">391</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBOutletConnection" key="connection">
+						<string key="label">sync_keymap</string>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="793493073"/>
+					</object>
+					<int key="connectionID">392</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBOutletConnection" key="connection">
+						<string key="label">enable_keyequivs</string>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="677150201"/>
+					</object>
+					<int key="connectionID">393</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label" id="694471214">prefs_changed:</string>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="808306730"/>
+					</object>
+					<int key="connectionID">394</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<reference key="label" ref="694471214"/>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="793493073"/>
+					</object>
+					<int key="connectionID">395</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<reference key="label" ref="694471214"/>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="677150201"/>
+					</object>
+					<int key="connectionID">396</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<reference key="label" ref="694471214"/>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="1045559310"/>
+					</object>
+					<int key="connectionID">397</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<reference key="label" ref="694471214"/>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="300224954"/>
+					</object>
+					<int key="connectionID">398</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<reference key="label" ref="694471214"/>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="137435489"/>
+					</object>
+					<int key="connectionID">399</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<reference key="label" ref="694471214"/>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="663154230"/>
+					</object>
+					<int key="connectionID">401</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBOutletConnection" key="connection">
+						<string key="label">prefs_panel</string>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="210544761"/>
+					</object>
+					<int key="connectionID">402</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">x11_help:</string>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="122992289"/>
+					</object>
+					<int key="connectionID">422</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBOutletConnection" key="connection">
+						<string key="label">dockMenu</string>
+						<reference key="source" ref="584863936"/>
+						<reference key="destination" ref="1001514180"/>
+					</object>
+					<int key="connectionID">426</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBOutletConnection" key="connection">
+						<string key="label">dock_menu</string>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="1001514180"/>
+					</object>
+					<int key="connectionID">428</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBOutletConnection" key="connection">
+						<string key="label">delegate</string>
+						<reference key="source" ref="584863936"/>
+						<reference key="destination" ref="88064061"/>
+					</object>
+					<int key="connectionID">429</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">hide:</string>
+						<reference key="source" ref="584863936"/>
+						<reference key="destination" ref="147703239"/>
+					</object>
+					<int key="connectionID">430</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">unhideAllApplications:</string>
+						<reference key="source" ref="584863936"/>
+						<reference key="destination" ref="392807560"/>
+					</object>
+					<int key="connectionID">431</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">terminate:</string>
+						<reference key="source" ref="584863936"/>
+						<reference key="destination" ref="275459236"/>
+					</object>
+					<int key="connectionID">432</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">orderFrontStandardAboutPanel:</string>
+						<reference key="source" ref="584863936"/>
+						<reference key="destination" ref="588913325"/>
+					</object>
+					<int key="connectionID">433</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBOutletConnection" key="connection">
+						<string key="label">dock_apps_menu</string>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="321919370"/>
+					</object>
+					<int key="connectionID">530</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBOutletConnection" key="connection">
+						<string key="label">dock_window_separator</string>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="355724345"/>
+					</object>
+					<int key="connectionID">531</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<reference key="label" ref="178478735"/>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="656726997"/>
+					</object>
+					<int key="connectionID">534</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">next_window:</string>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="283496700"/>
+					</object>
+					<int key="connectionID">539</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">previous_window:</string>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="500397106"/>
+					</object>
+					<int key="connectionID">540</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBOutletConnection" key="connection">
+						<string key="label">enable_fullscreen</string>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="817420822"/>
+					</object>
+					<int key="connectionID">546</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">enable_fullscreen_changed:</string>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="817420822"/>
+					</object>
+					<int key="connectionID">547</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">toggle_fullscreen:</string>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="101686423"/>
+					</object>
+					<int key="connectionID">548</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBOutletConnection" key="connection">
+						<string key="label">toggle_fullscreen_item</string>
+						<reference key="source" ref="88064061"/>
+						<reference key="destination" ref="101686423"/>
+					</object>
+					<int key="connectionID">549</int>
+				</object>
+			</object>
+			<object class="IBMutableOrderedSet" key="objectRecords">
+				<object class="NSArray" key="orderedObjects">
+					<bool key="EncodedWithXMLCoder">YES</bool>
+					<object class="IBObjectRecord">
+						<int key="objectID">0</int>
+						<object class="NSArray" key="object" id="0">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+						</object>
+						<reference key="children" ref="874420287"/>
+						<nil key="parent"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">-2</int>
+						<reference key="object" ref="584863936"/>
+						<reference key="parent" ref="0"/>
+						<string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">-1</int>
+						<reference key="object" ref="518703249"/>
+						<reference key="parent" ref="0"/>
+						<string key="objectName">First Responder</string>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">-3</int>
+						<reference key="object" ref="166373373"/>
+						<reference key="parent" ref="0"/>
+						<string key="objectName">Application</string>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">29</int>
+						<reference key="object" ref="496556081"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="736341863"/>
+							<reference ref="385138428"/>
+							<reference ref="326076563"/>
+							<reference ref="940914550"/>
+							<reference ref="934950259"/>
+						</object>
+						<reference key="parent" ref="0"/>
+						<reference key="objectName" ref="414137626"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">19</int>
+						<reference key="object" ref="736341863"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="943404979"/>
+						</object>
+						<reference key="parent" ref="496556081"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">24</int>
+						<reference key="object" ref="943404979"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="853630143"/>
+							<reference ref="915861349"/>
+							<reference ref="783034074"/>
+							<reference ref="442007350"/>
+							<reference ref="722764538"/>
+							<reference ref="332241222"/>
+							<reference ref="303213786"/>
+							<reference ref="283496700"/>
+							<reference ref="500397106"/>
+						</object>
+						<reference key="parent" ref="736341863"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">5</int>
+						<reference key="object" ref="853630143"/>
+						<reference key="parent" ref="943404979"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">23</int>
+						<reference key="object" ref="915861349"/>
+						<reference key="parent" ref="943404979"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">92</int>
+						<reference key="object" ref="783034074"/>
+						<reference key="parent" ref="943404979"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">203</int>
+						<reference key="object" ref="442007350"/>
+						<reference key="parent" ref="943404979"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">204</int>
+						<reference key="object" ref="722764538"/>
+						<reference key="parent" ref="943404979"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">208</int>
+						<reference key="object" ref="332241222"/>
+						<reference key="parent" ref="943404979"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">536</int>
+						<reference key="object" ref="303213786"/>
+						<reference key="parent" ref="943404979"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">537</int>
+						<reference key="object" ref="283496700"/>
+						<reference key="parent" ref="943404979"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">538</int>
+						<reference key="object" ref="500397106"/>
+						<reference key="parent" ref="943404979"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">56</int>
+						<reference key="object" ref="385138428"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="856655711"/>
+						</object>
+						<reference key="parent" ref="496556081"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">57</int>
+						<reference key="object" ref="856655711"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="588913325"/>
+							<reference ref="836585695"/>
+							<reference ref="63158341"/>
+							<reference ref="147703239"/>
+							<reference ref="275459236"/>
+							<reference ref="562920394"/>
+							<reference ref="635454008"/>
+							<reference ref="191312176"/>
+							<reference ref="648021277"/>
+							<reference ref="392807560"/>
+							<reference ref="101686423"/>
+							<reference ref="754231570"/>
+						</object>
+						<reference key="parent" ref="385138428"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">58</int>
+						<reference key="object" ref="588913325"/>
+						<reference key="parent" ref="856655711"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">129</int>
+						<reference key="object" ref="836585695"/>
+						<reference key="parent" ref="856655711"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">131</int>
+						<reference key="object" ref="63158341"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="502073457"/>
+						</object>
+						<reference key="parent" ref="856655711"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">130</int>
+						<reference key="object" ref="502073457"/>
+						<reference key="parent" ref="63158341"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">134</int>
+						<reference key="object" ref="147703239"/>
+						<reference key="parent" ref="856655711"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">136</int>
+						<reference key="object" ref="275459236"/>
+						<reference key="parent" ref="856655711"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">143</int>
+						<reference key="object" ref="562920394"/>
+						<reference key="parent" ref="856655711"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">144</int>
+						<reference key="object" ref="635454008"/>
+						<reference key="parent" ref="856655711"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">145</int>
+						<reference key="object" ref="191312176"/>
+						<reference key="parent" ref="856655711"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">149</int>
+						<reference key="object" ref="648021277"/>
+						<reference key="parent" ref="856655711"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">150</int>
+						<reference key="object" ref="392807560"/>
+						<reference key="parent" ref="856655711"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">544</int>
+						<reference key="object" ref="101686423"/>
+						<reference key="parent" ref="856655711"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">545</int>
+						<reference key="object" ref="754231570"/>
+						<reference key="parent" ref="856655711"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">163</int>
+						<reference key="object" ref="326076563"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="932839819"/>
+						</object>
+						<reference key="parent" ref="496556081"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">169</int>
+						<reference key="object" ref="932839819"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="342107529"/>
+							<reference ref="204575684"/>
+							<reference ref="159704190"/>
+							<reference ref="590926585"/>
+							<reference ref="549812830"/>
+							<reference ref="739720090"/>
+							<reference ref="584461964"/>
+							<reference ref="634656440"/>
+						</object>
+						<reference key="parent" ref="326076563"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">156</int>
+						<reference key="object" ref="342107529"/>
+						<reference key="parent" ref="932839819"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">157</int>
+						<reference key="object" ref="204575684"/>
+						<reference key="parent" ref="932839819"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">158</int>
+						<reference key="object" ref="159704190"/>
+						<reference key="parent" ref="932839819"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">160</int>
+						<reference key="object" ref="590926585"/>
+						<reference key="parent" ref="932839819"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">164</int>
+						<reference key="object" ref="549812830"/>
+						<reference key="parent" ref="932839819"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">171</int>
+						<reference key="object" ref="739720090"/>
+						<reference key="parent" ref="932839819"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">172</int>
+						<reference key="object" ref="584461964"/>
+						<reference key="parent" ref="932839819"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">173</int>
+						<reference key="object" ref="634656440"/>
+						<reference key="parent" ref="932839819"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">269</int>
+						<reference key="object" ref="940914550"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="684156653"/>
+						</object>
+						<reference key="parent" ref="496556081"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">270</int>
+						<reference key="object" ref="684156653"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="940363272"/>
+							<reference ref="767830074"/>
+						</object>
+						<reference key="parent" ref="940914550"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">272</int>
+						<reference key="object" ref="940363272"/>
+						<reference key="parent" ref="684156653"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">305</int>
+						<reference key="object" ref="767830074"/>
+						<reference key="parent" ref="684156653"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">419</int>
+						<reference key="object" ref="934950259"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="1052262524"/>
+						</object>
+						<reference key="parent" ref="496556081"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">420</int>
+						<reference key="object" ref="1052262524"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="122992289"/>
+						</object>
+						<reference key="parent" ref="934950259"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">421</int>
+						<reference key="object" ref="122992289"/>
+						<reference key="parent" ref="1052262524"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">196</int>
+						<reference key="object" ref="88064061"/>
+						<reference key="parent" ref="0"/>
+						<reference key="objectName" ref="517073442"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">244</int>
+						<reference key="object" ref="210544761"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="404125972"/>
+						</object>
+						<reference key="parent" ref="0"/>
+						<string key="objectName">PrefsPanel</string>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">245</int>
+						<reference key="object" ref="404125972"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="75927203"/>
+						</object>
+						<reference key="parent" ref="210544761"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">348</int>
+						<reference key="object" ref="75927203"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="17244958"/>
+							<reference ref="493727923"/>
+							<reference ref="1036577743"/>
+						</object>
+						<reference key="parent" ref="404125972"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">349</int>
+						<reference key="object" ref="17244958"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="600332710"/>
+						</object>
+						<reference key="parent" ref="75927203"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">351</int>
+						<reference key="object" ref="600332710"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="808306730"/>
+							<reference ref="618388983"/>
+							<reference ref="754792079"/>
+							<reference ref="677150201"/>
+							<reference ref="228801813"/>
+							<reference ref="793493073"/>
+						</object>
+						<reference key="parent" ref="17244958"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">363</int>
+						<reference key="object" ref="808306730"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="727617204"/>
+						</object>
+						<reference key="parent" ref="600332710"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">364</int>
+						<reference key="object" ref="618388983"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="140236247"/>
+						</object>
+						<reference key="parent" ref="600332710"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">365</int>
+						<reference key="object" ref="754792079"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="110537159"/>
+						</object>
+						<reference key="parent" ref="600332710"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">368</int>
+						<reference key="object" ref="677150201"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="46680941"/>
+						</object>
+						<reference key="parent" ref="600332710"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">369</int>
+						<reference key="object" ref="228801813"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="415694484"/>
+						</object>
+						<reference key="parent" ref="600332710"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">370</int>
+						<reference key="object" ref="793493073"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="466260504"/>
+						</object>
+						<reference key="parent" ref="600332710"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">352</int>
+						<reference key="object" ref="493727923"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="527709877"/>
+						</object>
+						<reference key="parent" ref="75927203"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">350</int>
+						<reference key="object" ref="527709877"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="1045559310"/>
+							<reference ref="67626595"/>
+							<reference ref="300224954"/>
+							<reference ref="717889178"/>
+							<reference ref="114173823"/>
+							<reference ref="817420822"/>
+							<reference ref="959270736"/>
+						</object>
+						<reference key="parent" ref="493727923"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">371</int>
+						<reference key="object" ref="1045559310"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="225158677"/>
+						</object>
+						<reference key="parent" ref="527709877"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">372</int>
+						<reference key="object" ref="67626595"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="1072420481"/>
+						</object>
+						<reference key="parent" ref="527709877"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">382</int>
+						<reference key="object" ref="300224954"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="301142744"/>
+						</object>
+						<reference key="parent" ref="527709877"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">385</int>
+						<reference key="object" ref="717889178"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="749756205"/>
+						</object>
+						<reference key="parent" ref="527709877"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">386</int>
+						<reference key="object" ref="114173823"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="725554783"/>
+						</object>
+						<reference key="parent" ref="527709877"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">541</int>
+						<reference key="object" ref="817420822"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="100363081"/>
+						</object>
+						<reference key="parent" ref="527709877"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">543</int>
+						<reference key="object" ref="959270736"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="550432669"/>
+						</object>
+						<reference key="parent" ref="527709877"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">353</int>
+						<reference key="object" ref="1036577743"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="536248195"/>
+						</object>
+						<reference key="parent" ref="75927203"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">354</int>
+						<reference key="object" ref="536248195"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="137435489"/>
+							<reference ref="663154230"/>
+							<reference ref="417801719"/>
+							<reference ref="115954190"/>
+							<reference ref="1067279202"/>
+						</object>
+						<reference key="parent" ref="1036577743"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">374</int>
+						<reference key="object" ref="137435489"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="891925158"/>
+						</object>
+						<reference key="parent" ref="536248195"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">375</int>
+						<reference key="object" ref="663154230"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="836703945"/>
+						</object>
+						<reference key="parent" ref="536248195"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">376</int>
+						<reference key="object" ref="417801719"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="935570098"/>
+						</object>
+						<reference key="parent" ref="536248195"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">377</int>
+						<reference key="object" ref="115954190"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="144257898"/>
+						</object>
+						<reference key="parent" ref="536248195"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">379</int>
+						<reference key="object" ref="1067279202"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="703874672"/>
+						</object>
+						<reference key="parent" ref="536248195"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">285</int>
+						<reference key="object" ref="796776534"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="1039094689"/>
+						</object>
+						<reference key="parent" ref="0"/>
+						<string key="objectName">EditPrograms</string>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">286</int>
+						<reference key="object" ref="1039094689"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="1002101696"/>
+							<reference ref="711288662"/>
+							<reference ref="634701477"/>
+							<reference ref="1011512617"/>
+							<reference ref="859414998"/>
+							<reference ref="381268760"/>
+						</object>
+						<reference key="parent" ref="796776534"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">291</int>
+						<reference key="object" ref="1002101696"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="558394524"/>
+						</object>
+						<reference key="parent" ref="1039094689"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">292</int>
+						<reference key="object" ref="711288662"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="413164923"/>
+						</object>
+						<reference key="parent" ref="1039094689"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">293</int>
+						<reference key="object" ref="634701477"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="26248495"/>
+						</object>
+						<reference key="parent" ref="1039094689"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">295</int>
+						<reference key="object" ref="1011512617"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="411425856"/>
+							<reference ref="152467947"/>
+							<reference ref="208024104"/>
+							<reference ref="526973850"/>
+						</object>
+						<reference key="parent" ref="1039094689"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">296</int>
+						<reference key="object" ref="411425856"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="621551865"/>
+							<reference ref="976084317"/>
+							<reference ref="661701503"/>
+						</object>
+						<reference key="parent" ref="1011512617"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">297</int>
+						<reference key="object" ref="621551865"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="195831317"/>
+						</object>
+						<reference key="parent" ref="411425856"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">574</int>
+						<reference key="object" ref="195831317"/>
+						<reference key="parent" ref="621551865"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">298</int>
+						<reference key="object" ref="976084317"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="656574062"/>
+						</object>
+						<reference key="parent" ref="411425856"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">573</int>
+						<reference key="object" ref="656574062"/>
+						<reference key="parent" ref="976084317"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">535</int>
+						<reference key="object" ref="661701503"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="90031137"/>
+						</object>
+						<reference key="parent" ref="411425856"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">575</int>
+						<reference key="object" ref="90031137"/>
+						<reference key="parent" ref="661701503"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">299</int>
+						<reference key="object" ref="859414998"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="537937846"/>
+						</object>
+						<reference key="parent" ref="1039094689"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">310</int>
+						<reference key="object" ref="381268760"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="99903682"/>
+						</object>
+						<reference key="parent" ref="1039094689"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">423</int>
+						<reference key="object" ref="1001514180"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="355724345"/>
+							<reference ref="107275095"/>
+						</object>
+						<reference key="parent" ref="0"/>
+						<string key="objectName">DockMenu</string>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">524</int>
+						<reference key="object" ref="355724345"/>
+						<reference key="parent" ref="1001514180"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">526</int>
+						<reference key="object" ref="107275095"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="321919370"/>
+						</object>
+						<reference key="parent" ref="1001514180"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">527</int>
+						<reference key="object" ref="321919370"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="656726997"/>
+							<reference ref="500771766"/>
+						</object>
+						<reference key="parent" ref="107275095"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">532</int>
+						<reference key="object" ref="656726997"/>
+						<reference key="parent" ref="321919370"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">533</int>
+						<reference key="object" ref="500771766"/>
+						<reference key="parent" ref="321919370"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">100363</int>
+						<reference key="object" ref="727617204"/>
+						<reference key="parent" ref="808306730"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">100364</int>
+						<reference key="object" ref="140236247"/>
+						<reference key="parent" ref="618388983"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">100365</int>
+						<reference key="object" ref="110537159"/>
+						<reference key="parent" ref="754792079"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">100368</int>
+						<reference key="object" ref="46680941"/>
+						<reference key="parent" ref="677150201"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">100369</int>
+						<reference key="object" ref="415694484"/>
+						<reference key="parent" ref="228801813"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">100370</int>
+						<reference key="object" ref="466260504"/>
+						<reference key="parent" ref="793493073"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">100371</int>
+						<reference key="object" ref="225158677"/>
+						<reference key="parent" ref="1045559310"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">100372</int>
+						<reference key="object" ref="1072420481"/>
+						<reference key="parent" ref="67626595"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">100382</int>
+						<reference key="object" ref="301142744"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="1071781177"/>
+						</object>
+						<reference key="parent" ref="300224954"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">100385</int>
+						<reference key="object" ref="749756205"/>
+						<reference key="parent" ref="717889178"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">100386</int>
+						<reference key="object" ref="725554783"/>
+						<reference key="parent" ref="114173823"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">100541</int>
+						<reference key="object" ref="100363081"/>
+						<reference key="parent" ref="817420822"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">100543</int>
+						<reference key="object" ref="550432669"/>
+						<reference key="parent" ref="959270736"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">100374</int>
+						<reference key="object" ref="891925158"/>
+						<reference key="parent" ref="137435489"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">100375</int>
+						<reference key="object" ref="836703945"/>
+						<reference key="parent" ref="663154230"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">100376</int>
+						<reference key="object" ref="935570098"/>
+						<reference key="parent" ref="417801719"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">100377</int>
+						<reference key="object" ref="144257898"/>
+						<reference key="parent" ref="115954190"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">100379</int>
+						<reference key="object" ref="703874672"/>
+						<reference key="parent" ref="1067279202"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">100291</int>
+						<reference key="object" ref="558394524"/>
+						<reference key="parent" ref="1002101696"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">100292</int>
+						<reference key="object" ref="413164923"/>
+						<reference key="parent" ref="711288662"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">100293</int>
+						<reference key="object" ref="26248495"/>
+						<reference key="parent" ref="634701477"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">100299</int>
+						<reference key="object" ref="537937846"/>
+						<reference key="parent" ref="859414998"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">100310</int>
+						<reference key="object" ref="99903682"/>
+						<reference key="parent" ref="381268760"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">380</int>
+						<reference key="object" ref="1071781177"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="827519886"/>
+							<reference ref="473657062"/>
+							<reference ref="247508345"/>
+							<reference ref="611307925"/>
+						</object>
+						<reference key="parent" ref="301142744"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">435</int>
+						<reference key="object" ref="827519886"/>
+						<reference key="parent" ref="1071781177"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">384</int>
+						<reference key="object" ref="473657062"/>
+						<reference key="parent" ref="1071781177"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">383</int>
+						<reference key="object" ref="247508345"/>
+						<reference key="parent" ref="1071781177"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">381</int>
+						<reference key="object" ref="611307925"/>
+						<reference key="parent" ref="1071781177"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">100295</int>
+						<reference key="object" ref="152467947"/>
+						<reference key="parent" ref="1011512617"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">200295</int>
+						<reference key="object" ref="208024104"/>
+						<reference key="parent" ref="1011512617"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">300295</int>
+						<reference key="object" ref="526973850"/>
+						<reference key="parent" ref="1011512617"/>
+					</object>
+				</object>
+			</object>
+			<object class="NSMutableDictionary" key="flattenedProperties">
+				<bool key="EncodedWithXMLCoder">YES</bool>
+				<object class="NSMutableArray" key="dict.sortedKeys">
+					<bool key="EncodedWithXMLCoder">YES</bool>
+					<string>-1.IBPluginDependency</string>
+					<string>-2.IBPluginDependency</string>
+					<string>-3.IBPluginDependency</string>
+					<string>-3.ImportedFromIB2</string>
+					<string>100295.IBShouldRemoveOnLegacySave</string>
+					<string>129.IBPluginDependency</string>
+					<string>129.ImportedFromIB2</string>
+					<string>130.IBPluginDependency</string>
+					<string>130.ImportedFromIB2</string>
+					<string>131.IBPluginDependency</string>
+					<string>131.ImportedFromIB2</string>
+					<string>134.IBPluginDependency</string>
+					<string>134.ImportedFromIB2</string>
+					<string>136.IBPluginDependency</string>
+					<string>136.ImportedFromIB2</string>
+					<string>143.IBPluginDependency</string>
+					<string>143.ImportedFromIB2</string>
+					<string>144.IBPluginDependency</string>
+					<string>144.ImportedFromIB2</string>
+					<string>145.IBPluginDependency</string>
+					<string>145.ImportedFromIB2</string>
+					<string>149.IBPluginDependency</string>
+					<string>149.ImportedFromIB2</string>
+					<string>150.IBPluginDependency</string>
+					<string>150.ImportedFromIB2</string>
+					<string>156.IBPluginDependency</string>
+					<string>156.ImportedFromIB2</string>
+					<string>157.IBPluginDependency</string>
+					<string>157.ImportedFromIB2</string>
+					<string>158.IBPluginDependency</string>
+					<string>158.ImportedFromIB2</string>
+					<string>160.IBPluginDependency</string>
+					<string>160.ImportedFromIB2</string>
+					<string>163.IBPluginDependency</string>
+					<string>163.ImportedFromIB2</string>
+					<string>164.IBPluginDependency</string>
+					<string>164.ImportedFromIB2</string>
+					<string>169.IBPluginDependency</string>
+					<string>169.ImportedFromIB2</string>
+					<string>171.IBPluginDependency</string>
+					<string>171.ImportedFromIB2</string>
+					<string>172.IBPluginDependency</string>
+					<string>172.ImportedFromIB2</string>
+					<string>173.IBPluginDependency</string>
+					<string>173.ImportedFromIB2</string>
+					<string>19.IBPluginDependency</string>
+					<string>19.ImportedFromIB2</string>
+					<string>196.IBPluginDependency</string>
+					<string>196.ImportedFromIB2</string>
+					<string>200295.IBShouldRemoveOnLegacySave</string>
+					<string>203.IBPluginDependency</string>
+					<string>203.ImportedFromIB2</string>
+					<string>204.IBPluginDependency</string>
+					<string>204.ImportedFromIB2</string>
+					<string>208.IBPluginDependency</string>
+					<string>208.ImportedFromIB2</string>
+					<string>23.IBPluginDependency</string>
+					<string>23.ImportedFromIB2</string>
+					<string>24.IBPluginDependency</string>
+					<string>24.ImportedFromIB2</string>
+					<string>244.IBPluginDependency</string>
+					<string>244.ImportedFromIB2</string>
+					<string>244.windowTemplate.hasMaxSize</string>
+					<string>244.windowTemplate.hasMinSize</string>
+					<string>244.windowTemplate.maxSize</string>
+					<string>244.windowTemplate.minSize</string>
+					<string>245.IBPluginDependency</string>
+					<string>245.ImportedFromIB2</string>
+					<string>269.IBPluginDependency</string>
+					<string>269.ImportedFromIB2</string>
+					<string>270.IBPluginDependency</string>
+					<string>270.ImportedFromIB2</string>
+					<string>272.IBPluginDependency</string>
+					<string>272.ImportedFromIB2</string>
+					<string>285.IBPluginDependency</string>
+					<string>285.ImportedFromIB2</string>
+					<string>285.windowTemplate.hasMaxSize</string>
+					<string>285.windowTemplate.hasMinSize</string>
+					<string>285.windowTemplate.maxSize</string>
+					<string>285.windowTemplate.minSize</string>
+					<string>286.IBPluginDependency</string>
+					<string>286.ImportedFromIB2</string>
+					<string>29.IBPluginDependency</string>
+					<string>29.ImportedFromIB2</string>
+					<string>291.IBPluginDependency</string>
+					<string>291.ImportedFromIB2</string>
+					<string>292.IBPluginDependency</string>
+					<string>292.ImportedFromIB2</string>
+					<string>293.IBPluginDependency</string>
+					<string>293.ImportedFromIB2</string>
+					<string>295.IBPluginDependency</string>
+					<string>295.ImportedFromIB2</string>
+					<string>296.IBPluginDependency</string>
+					<string>296.ImportedFromIB2</string>
+					<string>297.IBPluginDependency</string>
+					<string>297.ImportedFromIB2</string>
+					<string>298.IBPluginDependency</string>
+					<string>298.ImportedFromIB2</string>
+					<string>299.IBPluginDependency</string>
+					<string>299.ImportedFromIB2</string>
+					<string>300295.IBShouldRemoveOnLegacySave</string>
+					<string>305.IBPluginDependency</string>
+					<string>305.ImportedFromIB2</string>
+					<string>310.IBPluginDependency</string>
+					<string>310.ImportedFromIB2</string>
+					<string>348.IBPluginDependency</string>
+					<string>348.ImportedFromIB2</string>
+					<string>349.IBPluginDependency</string>
+					<string>349.ImportedFromIB2</string>
+					<string>350.IBPluginDependency</string>
+					<string>350.ImportedFromIB2</string>
+					<string>351.IBPluginDependency</string>
+					<string>351.ImportedFromIB2</string>
+					<string>352.IBPluginDependency</string>
+					<string>352.ImportedFromIB2</string>
+					<string>353.IBPluginDependency</string>
+					<string>353.ImportedFromIB2</string>
+					<string>354.IBPluginDependency</string>
+					<string>354.ImportedFromIB2</string>
+					<string>363.IBPluginDependency</string>
+					<string>363.ImportedFromIB2</string>
+					<string>364.IBPluginDependency</string>
+					<string>364.ImportedFromIB2</string>
+					<string>365.IBPluginDependency</string>
+					<string>365.ImportedFromIB2</string>
+					<string>368.IBPluginDependency</string>
+					<string>368.ImportedFromIB2</string>
+					<string>369.IBPluginDependency</string>
+					<string>369.ImportedFromIB2</string>
+					<string>370.IBPluginDependency</string>
+					<string>370.ImportedFromIB2</string>
+					<string>371.IBPluginDependency</string>
+					<string>371.ImportedFromIB2</string>
+					<string>372.IBPluginDependency</string>
+					<string>372.ImportedFromIB2</string>
+					<string>374.IBPluginDependency</string>
+					<string>374.ImportedFromIB2</string>
+					<string>375.IBPluginDependency</string>
+					<string>375.ImportedFromIB2</string>
+					<string>376.IBPluginDependency</string>
+					<string>376.ImportedFromIB2</string>
+					<string>377.IBPluginDependency</string>
+					<string>377.ImportedFromIB2</string>
+					<string>379.IBPluginDependency</string>
+					<string>379.ImportedFromIB2</string>
+					<string>380.IBPluginDependency</string>
+					<string>380.ImportedFromIB2</string>
+					<string>381.IBPluginDependency</string>
+					<string>381.ImportedFromIB2</string>
+					<string>382.IBPluginDependency</string>
+					<string>382.ImportedFromIB2</string>
+					<string>383.IBPluginDependency</string>
+					<string>383.ImportedFromIB2</string>
+					<string>384.IBPluginDependency</string>
+					<string>384.ImportedFromIB2</string>
+					<string>385.IBPluginDependency</string>
+					<string>385.ImportedFromIB2</string>
+					<string>386.IBPluginDependency</string>
+					<string>386.ImportedFromIB2</string>
+					<string>419.IBPluginDependency</string>
+					<string>419.ImportedFromIB2</string>
+					<string>420.IBPluginDependency</string>
+					<string>420.ImportedFromIB2</string>
+					<string>421.IBPluginDependency</string>
+					<string>421.ImportedFromIB2</string>
+					<string>423.IBPluginDependency</string>
+					<string>423.ImportedFromIB2</string>
+					<string>435.IBPluginDependency</string>
+					<string>435.ImportedFromIB2</string>
+					<string>5.IBPluginDependency</string>
+					<string>5.ImportedFromIB2</string>
+					<string>524.IBPluginDependency</string>
+					<string>524.ImportedFromIB2</string>
+					<string>526.IBPluginDependency</string>
+					<string>526.ImportedFromIB2</string>
+					<string>527.IBPluginDependency</string>
+					<string>527.ImportedFromIB2</string>
+					<string>532.IBPluginDependency</string>
+					<string>532.ImportedFromIB2</string>
+					<string>533.IBPluginDependency</string>
+					<string>533.ImportedFromIB2</string>
+					<string>535.IBPluginDependency</string>
+					<string>535.ImportedFromIB2</string>
+					<string>536.IBPluginDependency</string>
+					<string>536.ImportedFromIB2</string>
+					<string>537.IBPluginDependency</string>
+					<string>537.ImportedFromIB2</string>
+					<string>538.IBPluginDependency</string>
+					<string>538.ImportedFromIB2</string>
+					<string>541.IBPluginDependency</string>
+					<string>541.ImportedFromIB2</string>
+					<string>543.IBPluginDependency</string>
+					<string>543.ImportedFromIB2</string>
+					<string>544.IBPluginDependency</string>
+					<string>544.ImportedFromIB2</string>
+					<string>545.IBPluginDependency</string>
+					<string>545.ImportedFromIB2</string>
+					<string>56.IBPluginDependency</string>
+					<string>56.ImportedFromIB2</string>
+					<string>57.IBPluginDependency</string>
+					<string>57.ImportedFromIB2</string>
+					<string>573.IBPluginDependency</string>
+					<string>573.ImportedFromIB2</string>
+					<string>574.IBPluginDependency</string>
+					<string>574.ImportedFromIB2</string>
+					<string>575.IBPluginDependency</string>
+					<string>575.ImportedFromIB2</string>
+					<string>58.IBPluginDependency</string>
+					<string>58.ImportedFromIB2</string>
+					<string>92.IBPluginDependency</string>
+					<string>92.ImportedFromIB2</string>
+				</object>
+				<object class="NSMutableArray" key="dict.values">
+					<bool key="EncodedWithXMLCoder">YES</bool>
+					<reference ref="874199827"/>
+					<reference ref="874199827"/>
+					<reference ref="874199827"/>
+					<integer value="1" id="5"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="5"/>
+					<reference ref="5"/>
+					<string>{3.40282e+38, 3.40282e+38}</string>
+					<string>{213, 107}</string>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="5"/>
+					<reference ref="5"/>
+					<string>{3.40282e+38, 3.40282e+38}</string>
+					<string>{213, 107}</string>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+					<reference ref="874199827"/>
+					<reference ref="5"/>
+				</object>
+			</object>
+			<object class="NSMutableDictionary" key="unlocalizedProperties">
+				<bool key="EncodedWithXMLCoder">YES</bool>
+				<object class="NSArray" key="dict.sortedKeys">
+					<bool key="EncodedWithXMLCoder">YES</bool>
+				</object>
+				<object class="NSMutableArray" key="dict.values">
+					<bool key="EncodedWithXMLCoder">YES</bool>
+				</object>
+			</object>
+			<nil key="activeLocalization"/>
+			<object class="NSMutableDictionary" key="localizations">
+				<bool key="EncodedWithXMLCoder">YES</bool>
+				<object class="NSArray" key="dict.sortedKeys">
+					<bool key="EncodedWithXMLCoder">YES</bool>
+				</object>
+				<object class="NSMutableArray" key="dict.values">
+					<bool key="EncodedWithXMLCoder">YES</bool>
+				</object>
+			</object>
+			<nil key="sourceID"/>
+			<int key="maxID">300295</int>
+		</object>
+		<object class="IBClassDescriber" key="IBDocument.Classes">
+			<object class="NSMutableArray" key="referencedPartialClassDescriptions">
+				<bool key="EncodedWithXMLCoder">YES</bool>
+				<object class="IBPartialClassDescription">
+					<string key="className">NSFormatter</string>
+					<nil key="superclassName"/>
+					<object class="NSMutableDictionary" key="actions">
+						<bool key="EncodedWithXMLCoder">YES</bool>
+						<object class="NSArray" key="dict.sortedKeys">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+						</object>
+						<object class="NSMutableArray" key="dict.values">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+						</object>
+					</object>
+					<object class="NSMutableDictionary" key="outlets">
+						<bool key="EncodedWithXMLCoder">YES</bool>
+						<object class="NSArray" key="dict.sortedKeys">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+						</object>
+						<object class="NSMutableArray" key="dict.values">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+						</object>
+					</object>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey" id="3826605">IBUserSource</string>
+						<string key="minorKey" id="25614681"/>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">FirstResponder</string>
+					<nil key="superclassName"/>
+					<object class="NSMutableDictionary" key="actions">
+						<bool key="EncodedWithXMLCoder">YES</bool>
+						<object class="NSMutableArray" key="dict.sortedKeys">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<string>alignCenter:</string>
+							<string>alignJustified:</string>
+							<string>alignLeft:</string>
+							<string>alignRight:</string>
+							<string>arrangeInFront:</string>
+							<string>centerSelectionInVisibleArea:</string>
+							<string>changeFont:</string>
+							<string>checkSpelling:</string>
+							<string>clear:</string>
+							<string>clearRecentDocuments:</string>
+							<string>complete:</string>
+							<string>copy:</string>
+							<string>copyFont:</string>
+							<string>copyRuler:</string>
+							<string>cut:</string>
+							<string>delete:</string>
+							<string>deminiaturize:</string>
+							<string>fax:</string>
+							<string>hide:</string>
+							<string>hideOtherApplications:</string>
+							<string>loosenKerning:</string>
+							<string>lowerBaseline:</string>
+							<string>makeKeyAndOrderFront:</string>
+							<string>miniaturize:</string>
+							<string>newDocument:</string>
+							<string>openDocument:</string>
+							<string>orderBack:</string>
+							<string>orderFront:</string>
+							<string>orderFrontColorPanel:</string>
+							<string>orderFrontHelpPanel:</string>
+							<string>orderOut:</string>
+							<string>outline:</string>
+							<string>paste:</string>
+							<string>pasteAsPlainText:</string>
+							<string>pasteAsRichText:</string>
+							<string>pasteFont:</string>
+							<string>pasteRuler:</string>
+							<string>pause:</string>
+							<string>performClose:</string>
+							<string>performFindPanelAction:</string>
+							<string>performMiniaturize:</string>
+							<string>performZoom:</string>
+							<string>play:</string>
+							<string>print:</string>
+							<string>printDocument:</string>
+							<string>raiseBaseline:</string>
+							<string>record:</string>
+							<string>redo:</string>
+							<string>resume:</string>
+							<string>revertDocumentToSaved:</string>
+							<string>run:</string>
+							<string>runPageLayout:</string>
+							<string>runToolbarCustomizationPalette:</string>
+							<string>saveAllDocuments:</string>
+							<string>saveDocument:</string>
+							<string>saveDocumentAs:</string>
+							<string>saveDocumentTo:</string>
+							<string>selectAll:</string>
+							<string>selectText:</string>
+							<string>showGuessPanel:</string>
+							<string>showHelp:</string>
+							<string>start:</string>
+							<string>startSpeaking:</string>
+							<string>stop:</string>
+							<string>stopSpeaking:</string>
+							<string>subscript:</string>
+							<string>superscript:</string>
+							<string>terminate:</string>
+							<string>tightenKerning:</string>
+							<string>toggleContinuousSpellChecking:</string>
+							<string>toggleRuler:</string>
+							<string>toggleToolbarShown:</string>
+							<string>turnOffKerning:</string>
+							<string>turnOffLigatures:</string>
+							<string>underline:</string>
+							<string>undo:</string>
+							<string>unhideAllApplications:</string>
+							<string>unscript:</string>
+							<string>useAllLigatures:</string>
+							<string>useStandardKerning:</string>
+							<string>useStandardLigatures:</string>
+						</object>
+						<object class="NSMutableArray" key="dict.values">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<string id="663201829">id</string>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+						</object>
+					</object>
+					<object class="NSMutableDictionary" key="outlets">
+						<bool key="EncodedWithXMLCoder">YES</bool>
+						<object class="NSArray" key="dict.sortedKeys">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+						</object>
+						<object class="NSMutableArray" key="dict.values">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+						</object>
+					</object>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<reference key="majorKey" ref="3826605"/>
+						<reference key="minorKey" ref="25614681"/>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">X11Controller</string>
+					<string key="superclassName">NSObject</string>
+					<object class="NSMutableDictionary" key="actions">
+						<bool key="EncodedWithXMLCoder">YES</bool>
+						<object class="NSMutableArray" key="dict.sortedKeys">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<string>apps_table_cancel:</string>
+							<string>apps_table_delete:</string>
+							<string>apps_table_done:</string>
+							<string>apps_table_duplicate:</string>
+							<string>apps_table_new:</string>
+							<string>apps_table_show:</string>
+							<string>bring_to_front:</string>
+							<string>close_window:</string>
+							<string>enable_fullscreen_changed:</string>
+							<string>minimize_window:</string>
+							<string>next_window:</string>
+							<string>prefs_changed:</string>
+							<string>prefs_show:</string>
+							<string>previous_window:</string>
+							<string>toggle_fullscreen:</string>
+							<string>x11_help:</string>
+							<string>zoom_window:</string>
+						</object>
+						<object class="NSMutableArray" key="dict.values">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+						</object>
+					</object>
+					<object class="NSMutableDictionary" key="outlets">
+						<bool key="EncodedWithXMLCoder">YES</bool>
+						<object class="NSMutableArray" key="dict.sortedKeys">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<string>apps_separator</string>
+							<string>apps_table</string>
+							<string>depth</string>
+							<string>dock_apps_menu</string>
+							<string>dock_menu</string>
+							<string>dock_window_separator</string>
+							<string>enable_auth</string>
+							<string>enable_fullscreen</string>
+							<string>enable_keyequivs</string>
+							<string>enable_tcp</string>
+							<string>fake_buttons</string>
+							<string>prefs_panel</string>
+							<string>sync_keymap</string>
+							<string>toggle_fullscreen_item</string>
+							<string>use_sysbeep</string>
+							<string>window_separator</string>
+							<string>x11_about_item</string>
+						</object>
+						<object class="NSMutableArray" key="dict.values">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+							<reference ref="663201829"/>
+						</object>
+					</object>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<reference key="majorKey" ref="3826605"/>
+						<reference key="minorKey" ref="25614681"/>
+					</object>
+				</object>
+			</object>
+		</object>
+		<int key="IBDocument.localizationMode">0</int>
+		<nil key="IBDocument.LastKnownRelativeProjectPath"/>
+		<int key="IBDocument.defaultPropertyAccessControl">3</int>
+		<object class="NSMutableData" key="IBDocument.RunnableNib">
+			<bytes key="NS.bytes">YnBsaXN0MDDUAAEAAgADAAQABQAGAAkAClgkdmVyc2lvblQkdG9wWSRhcmNoaXZlclgkb2JqZWN0cxIA
+AYag0QAHAAhdSUIub2JqZWN0ZGF0YYABXxAPTlNLZXllZEFyY2hpdmVyrxEDKQALAAwAMQA1ADkAQABD
+AEQASABMAIYAjACcAKEAogCjAKgAqQCqAK0AsQCyALUAtgC6AMAAzgDUANUA7wDwAPgA+QD8AQABAQEE
+AQgBDgERARIBEwEXAR4BHwEgASEBJgEnASoBLwE0ATUBOgFFAVABUQFSAVYBWwFkAWsBbAFwAXIBcwF4
+AX8BhQGGAY4BjwGUAZsBoAGhAakBqgGrAbABsQG2Ab0BvgHWAdoB3AHeAesB7wHwAfEB9AH7AgUB8AIG
+AhAB8AIRAhsB8AIcAiACIwIoAjECNgI3AjwCRQJJAkoCTwJWAlcCXwJgAmECZgJnAmwCiAKJAooCiwKO
+Ao8CkAKWApoCqgKuArgCvwLAAsoCywLQAtoC2wLcAuAC4gLnAugC6wLuAvEC+AL5AwADAQMIAwkDEAMR
+AxgDGQMhAyIDKQMqAzEDMgMzAzUDNgM8A0UDSANRA1gDWQNgA2EDaANpA3ADcQN4A3kDgQOCA4kDigOR
+AzIDkgOTA5YDnQOgA6EDpwOvAlYDtgO+A78DxgPHA84DzwPWA9cD3gPfA+YD5wPuAzID7wPwA/ID8wP0
+Ao4D9QP2A/kD+gP+BAUEBgQHBAgEDQQSBBkEGgQfBCYEKwQsBC0EMgQ5BDoEOwRABEcESARJBEoETwRX
+BFgEWQReBF8EZARrBGwEbQRxBHgEeQR6BHsEgASHBIgEiQSKBI4ElQSWBJcEmASdBKQEpQSmBKsEsgS2
+BLcEuAS9BMIEwwTIBNAE1QTWBOAE4QTkBOUE5wTpBOoE7wTwBPUE/AT9BQUFBgUIBQoFCwUQBREFFgUX
+BRwFIwUkBSUFJgUrBTMFNAU9BT4FQAVBBUYFSwVMBVEFbAV7BXwFgwWMBY0FkAWVBakFqgWtBbMFxQXM
+Bc0F0AXVBdYF2QXgBeMF5gXvBfUF9gX8BgUGCwYMBhEGEgYZBh0GIgYjBigGKQYsBi4GLwY0BjwGPQY+
+Bj8GRAZLBkwGTQZRBlgGWQZaBlsGYAZnBmgGcAZxBnMGdQZ2BnsGfAaBBogGiQaKBosGkAaRBpYGlwac
+Bp0GoganBq4GrwawBrEGtga9Br4GvwbABsUGzAbNBtUG1gbYBtoG2wbgBuEG5QbsBu0G7gbvB28HeAeA
+B4QHhQeIB5EHkgeTB5YHngefB6MHpAelB6gHqQeuB7cHvAFRB70HzAfVB94BUQffB+QH5gfpB+oH8wf8
+CAUIBgFRCA8IEggeCCcIMAgxCDIIOghDAVEIRAhPCFgIEQFRCGEIagFRCGsIbwhwADgIcwiBCIIIgwKO
+Ao8D8wP0Ao4IhQiGCIgJCAmJCgoKCwoMCg0KDgoPChAKEQoSChMKFAoVChYKFwoYChkKGgobChwKHQoe
+Ch8KIAohCiIKIwokCiUKJgonCigKKQoqCisKLAotCi4KLwowCjEKMgozCjQKNQo2CjcKOAo5CjoKOwo8
+Cj0KPgo/CkAKQQpCCkMKRApFCkYKRwpICkkKSgpLCkwKTQpOCk8KUApRClIKUwpUClUKVgpXClgKWQpa
+ClsKXApdCl4KXwpgCmEKYgpjCmQKZQpmCmcKaAppCmoKawpsCm0KbgpvCnAKcQpyAo0Kcwp0CnUKdgp3
+CngKeQp6CnsKfAp9Cn4KfwqACoEKggqDCoQKhQqICosLQwv7C/wL/Qv+C/8MAAwBDAIMAwwEDAUMBgwH
+DAgMCQwKDAsMDAwNDA4MDwwQDBEMEgwTDBQMFQwWDBcMGAwZDBoMGwwcDB0MHgwfDCAMIQwiDCMMJAwl
+DCYMJwIaBTAMKAwpDCoMKwwsDC0MLgwvDDAMMQwyDDMMNAw1DDYMNww4DDkMOgw7DDwMPQw+DD8MQAxB
+DEIMQwxEDEUMRgxHDEgMSQxKDEsMTAxNDE4MTwxQDFEMUgxTDFQMVQxWDFcMWAxZDFoMWwxcDF0MXgxf
+DGAMYQxiDGMMZAxlDGYMZwxoDGkMagxrDGwMbQxuDG8McAxxDHIMcwx0DHUMdgx3BM0MeAx5DHoMewx8
+DH0Mfgx/DIAMgQyCDIMMhAyFDIYMhwyIDIkMigyLDIwMjQyODI8MkAyRDJIMkwyUDJUMlgyXDJgMmQya
+DJsMnAydDJ4MnwygDKEMogyjDKQMpQymDKcMqAypDKoMqwysDK0MsAyzDLZVJG51bGzfEBIADQAOAA8A
+EAARABIAEwAUABUAFgAXABgAGQAaABsAHAAdAB4AHwAgACEAIgAjACQAJQAmACcAKAApACoAKwAsAC0A
+LgAvADBWTlNSb290ViRjbGFzc11OU09iamVjdHNLZXlzXxAPTlNDbGFzc2VzVmFsdWVzXxAZTlNBY2Nl
+c3NpYmlsaXR5T2lkc1ZhbHVlc11OU0Nvbm5lY3Rpb25zW05TTmFtZXNLZXlzW05TRnJhbWV3b3JrXU5T
+Q2xhc3Nlc0tleXNaTlNPaWRzS2V5c11OU05hbWVzVmFsdWVzXxAZTlNBY2Nlc3NpYmlsaXR5Q29ubmVj
+dG9yc11OU0ZvbnRNYW5hZ2VyXxAQTlNWaXNpYmxlV2luZG93c18QD05TT2JqZWN0c1ZhbHVlc18QF05T
+QWNjZXNzaWJpbGl0eU9pZHNLZXlzWU5TTmV4dE9pZFxOU09pZHNWYWx1ZXOAAoEDKIEBp4ECbYEDJ4AJ
+gQHugAaBAmyBAm6BAe+BAyWAAIAHgQHtgQMmEgAElQiBAm/SAA4AMgAzADRbTlNDbGFzc05hbWWABYAD
+0gAOADYANwA4WU5TLnN0cmluZ4AEXU5TQXBwbGljYXRpb27SADoAOwA8AD1YJGNsYXNzZXNaJGNsYXNz
+bmFtZaMAPQA+AD9fEA9OU011dGFibGVTdHJpbmdYTlNTdHJpbmdYTlNPYmplY3TSADoAOwBBAEKiAEIA
+P15OU0N1c3RvbU9iamVjdF8QEElCQ29jb2FGcmFtZXdvcmvSAA4ARQBGAEdaTlMub2JqZWN0c4AIoNIA
+OgA7AEkASqMASgBLAD9cTlNNdXRhYmxlU2V0VU5TU2V00gAOAEUATQBOgD6vEDcATwBQAFEAUgBTAFQA
+VQBWAFcAWABZAFoAWwBcAF0AXgBfAGAAYQBiAGMAZABlAGYAZwBoAGkAagBrAGwAbQBuAG8AcABxAHIA
+cwB0AHUAdgB3AHgAeQB6AHsAfAB9AH4AfwCAAIEAggCDAIQAhYAKgBiAKYAugDGAQYBHgE6AUIBogGyA
+cIB2gHiA3YDigOOA5oDrgO+A9ID4gPqA/oEBA4EBCIEBDYEBEYEBFoEBF4EBGYEBJIEBJoEBLoEBMIEB
+MoEBN4EBPoEBP4EBQYEBaoEBb4EBc4EBeIEBgIEBgoEBh4EBiYEBi4EBjYEBjoEBk4EBmIEBoIEBotMA
+DgCHAIgAiQCKAItYTlNTb3VyY2VXTlNMYWJlbIAXgAuAFtgADgCNAI4AjwCQAJEAkgCTAJQAlQCWAJcA
+mACZAJoAm1dOU1RpdGxlXxARTlNLZXlFcXVpdk1vZE1hc2taTlNLZXlFcXVpdl1OU01uZW1vbmljTG9j
+WU5TT25JbWFnZVxOU01peGVkSW1hZ2VWTlNNZW51gBWADRIAEAAAgA4Sf////4APgBOADNMADgCNAJ0A
+ngCfAKBbTlNNZW51SXRlbXOAP4EB1IEB1lZEZWxldGVQ0wAOADIApAClAKYAp15OU1Jlc291cmNlTmFt
+ZYASgBCAEVdOU0ltYWdlXxAPTlNNZW51Q2hlY2ttYXJr0gA6ADsAqwCsogCsAD9fEBBOU0N1c3RvbVJl
+c291cmNl0wAOADIApAClAKYAsIASgBCAFF8QEE5TTWVudU1peGVkU3RhdGXSADoAOwCzALSiALQAP1pO
+U01lbnVJdGVtV2RlbGV0ZTrSADoAOwC3ALijALgAuQA/XxAVTlNOaWJDb250cm9sQ29ubmVjdG9yXk5T
+TmliQ29ubmVjdG9y1AAOALsAhwCIAIkAvQC+AL9dTlNEZXN0aW5hdGlvboAXgCaAGYAo1wDBAA4AwgDD
+AMQAxQDGAMcAyADJAMoAywDMAMdfEA9OU05leHRSZXNwb25kZXJXTlNGcmFtZVZOU0NlbGxYTlN2Rmxh
+Z3NZTlNFbmFibGVkW05TU3VwZXJ2aWV3gBqAJYAbgBwRAQAJgBrVAMEADgDCAM8AxAArANEA0gDTAMta
+TlNTdWJ2aWV3c4AAgKWAu4CqXxAWe3sxOCwgMTUzfSwgezQwMiwgMTh9fd0A1gAOANcA2ADZANoA2wDc
+AN0A3gDfAOAA4QDiAOMAlwDlAOYA5wCXAOkA6gC+AOwA7QDuW05TQ2VsbEZsYWdzXxATTlNBbHRlcm5h
+dGVDb250ZW50c18QEk5TUGVyaW9kaWNJbnRlcnZhbF5OU0J1dHRvbkZsYWdzMl8QEE5TQWx0ZXJuYXRl
+SW1hZ2VfEA9OU0tleUVxdWl2YWxlbnRaTlNDb250ZW50c1lOU1N1cHBvcnRdTlNDb250cm9sVmlld18Q
+D05TUGVyaW9kaWNEZWxheVxOU0NlbGxGbGFnczJdTlNCdXR0b25GbGFncxIEAf4AgCSADhAZEAKAIYAO
+gB2AHoAZEMgQABJIPFH/XxAdRm9sbG93IHN5c3RlbSBrZXlib2FyZCBsYXlvdXTUAA4A8QDyAPMA9AD1
+APYA91ZOU1NpemVWTlNOYW1lWE5TZkZsYWdzgCAjQCoAAAAAAACAHxEEFFxMdWNpZGFHcmFuZGXSADoA
+OwD6APuiAPsAP1ZOU0ZvbnTSAA4A/QD+AP9bTlNJbWFnZU5hbWWAI4AiWE5TU3dpdGNo0gA6ADsBAgED
+ogEDAD9fEBNOU0J1dHRvbkltYWdlU291cmNl0gA6ADsBBQEGpAEGAQcAwwA/XE5TQnV0dG9uQ2VsbFxO
+U0FjdGlvbkNlbGzSADoAOwEJAQqlAQoBCwEMAQ0AP1hOU0J1dHRvbllOU0NvbnRyb2xWTlNWaWV3W05T
+UmVzcG9uZGVy0gAOADIAMwEQgAWAJ11YMTFDb250cm9sbGVyXnByZWZzX2NoYW5nZWQ60wAOAIcAiACJ
+ARUBFoAXgCqALdgADgCNAI4AjwCQAJEAkgCTAJQBGQCWARoAmACZAJoAm4AVgCuALIAPgBOADFpTZWxl
+Y3QgQWxsUWFac2VsZWN0QWxsOtQADgC7AIcAiAEiAL0AHwElgDCAJoACgC9YZGVsZWdhdGXSADoAOwEo
+ASmjASkAuQA/XxAUTlNOaWJPdXRsZXRDb25uZWN0b3LUAA4AuwCHAIgBIgEsAB8BLoAwgDKAAoBA1AAO
+AI0A8gCdAJ4BMQCXATOAP4AzgA6ANFRNZW510gAOAEUATQE3gD6iATgBOYA1gDbaAA4AjQCOATsAjwE8
+AJAAkQCSAJMAlACXAJYAzACXAMwAmACZAJoBLF1OU0lzU2VwYXJhdG9yXE5TSXNEaXNhYmxlZIAVgA4J
+gA4JgA+AE4Ay2gAOAUYAjQCOAI8AkACRAJIAkwFHAJQBSQFKAJYAlwCYAJkAmgEsAU9ZTlNTdWJtZW51
+WE5TQWN0aW9ugBWAOYA3gA6AD4ATgDKAOFxBcHBsaWNhdGlvbnNec3VibWVudUFjdGlvbjrTAA4AjQCd
+AJ4BSgFVgD+AN4A60gAOAEUATQFYgD6iAVkBWoA7gDzaAA4AjQCOATsAjwE8AJAAkQCSAJMAlACXAJYA
+zACXAMwAmACZAJoBSYAVgA4JgA4JgA+AE4A52AAOAI0AjgCPAJAAkQCSAJMAlAFmAJYAlwCYAJkAmgFJ
+gBWAPYAOgA+AE4A5agBDAHUAcwB0AG8AbQBpAHoAZSAm0gA6ADsBbQFuowFuAW8AP15OU011dGFibGVB
+cnJheVdOU0FycmF50gA6ADsBcQCTogCTAD9YZG9ja01lbnXUAA4AuwCHAIgAiQC9AXYAv4AXgCaAQoAo
+1wDBAA4AwgDDAMQAxQDGAXkAyAF7AXwAywDMAXmAQ4AlgESARQmAQ9YAwQAOAMIAzwDEAMYBgADRAYIB
+gwDLAYCAgoClgKSAhICCXxAVe3sxOCwgOTB9LCB7NDAyLCAxOH193QDWAA4A1wDYANkA2gDbANwA3QDe
+AN8A4ADhAOIA4wCXAOUA5gDnAJcBiwDqAXYA7ADtAO6AJIAOgCGADoBGgB6AQl8QF1VzZSBzeXN0ZW0g
+YWxlcnQgZWZmZWN01AAOALsAhwCIASIBkQC9AZOAMIBIgCaATdcAwQAOAMIAwwDEAMUAxgGVAMgBlwGY
+AMsAzAGVgEmAJYBKgEsJgEnVAMEADgDCAM8AxAArANEBngGfAMuAAIClgNOAwl8QFnt7MTgsIDE0MH0s
+IHs0MDIsIDE4fX3dANYADgDXANgA2QDaANsA3ADdAN4A3wDgAOEA4gDjAJcA5QDmAOcAlwGmAOoBkQDs
+AO0A7oAkgA6AIYAOgEyAHoBIXxAmQWxsb3cgY29ubmVjdGlvbnMgZnJvbSBuZXR3b3JrIGNsaWVudHNa
+ZW5hYmxlX3RjcNQADgC7AIcAiACJAL0BWgGvgBeAJoA8gE9fEBBhcHBzX3RhYmxlX3Nob3c61AAOALsA
+hwCIAIkAvQG0AL+AF4AmgFGAKNcAwQAOAMIAwwDEAMUAxgF5AbgBuQG6AMsAzAF5gEOAZ4BSgFMJgENf
+EBZ7ezc0LCAyMDl9LCB7MTI4LCAyNn193xATANYBvwHAANcA2AAOANkA2gDbAN0AtADeAcEBwgHDAN8A
+4ACTAOEBxADMAcYBxwHIAckBxgHKAcsA6gHNAbQBzwDMAMwB0gHTAdQB1V8QGk5TTWVudUl0ZW1SZXNw
+ZWN0QWxpZ25tZW50XxAPTlNBcnJvd1Bvc2l0aW9uXxAPTlNQcmVmZXJyZWRFZGdlXxASTlNVc2VzSXRl
+bUZyb21NZW51XU5TQWx0ZXJzU3RhdGUT/////4RB/kAJEAGAVRBLgGaAVIBWgB6AV4BREAMJCREBkBEE
+AIBYEgaCQP/UAA4A8QDyAPMA9AD1APYB2YAggB8QENIADgA2ADcAooAE0gAOADYANwCigATcAd8ADgCN
+AI4AjwCQAJEAkgCTAUcB4AHhAboAlAHkAJYAlwCYAJkAmgHUAekB6gHGWE5TVGFyZ2V0VU5TVGFnV05T
+U3RhdGWAU4AVgFmADoAPgBOAWIBaE///////////0wAOAI0AnQCeAe0B7oA/gFuAXFxGcm9tIERpc3Bs
+YXlfEBFfcG9wVXBJdGVtQWN0aW9uOtIADgA2ADcB84AEWk90aGVyVmlld3PSAA4ARQBNAfaAPqQBzQH4
+AfkB+oBXgF2AYIBj2wHfAA4AjQCOAI8AkACRAJIAkwFHAeABugCUAf4AlgCXAJgAmQCaAdQCAwIEgFOA
+FYBegA6AD4ATgFiAXxAIWjI1NiBDb2xvcnPbAd8ADgCNAI4AjwCQAJEAkgCTAUcB4AG6AJQCCQCWAJcA
+mACZAJoB1AIOAg+AU4AVgGGADoAPgBOAWIBiEA9ZVGhvdXNhbmRz2wHfAA4AjQCOAI8AkACRAJIAkwFH
+AeABugCUAhQAlgCXAJgAmQCaAdQCGQIagFOAFYBkgA6AD4ATgFiAZRAYWE1pbGxpb25z0gA6ADsCHQIe
+pgIeAh8BBgEHAMMAP18QEU5TUG9wVXBCdXR0b25DZWxsXk5TTWVudUl0ZW1DZWxs0gA6ADsCIQIipgIi
+AQoBCwEMAQ0AP11OU1BvcFVwQnV0dG9u1AAOALsAhwCIASICJQC9AieAMIBpgCaAa9oADgCNAI4BOwCP
+ATwAkACRAJIAkwCUAJcAlgDMAJcAzACYAJkAmgIwgBWADgmADgmAD4ATgGrUAA4AjQDyAJ0AngIzAjQC
+NYA/gQHMgQHQgQHNXxAQd2luZG93X3NlcGFyYXRvctQADgC7AIcAiAEiAjkAvQI7gDCAbYAmgG/aAA4A
+jQCOATsAjwE8AJAAkQCSAJMAlACXAJYAzACXAMwAmACZAJoCRIAVgA4JgA4JgA+AE4Bu0wAOAI0AnQCe
+AUoCSIA/gDeBAbheYXBwc19zZXBhcmF0b3LUAA4AuwCHAIgBIgJMAL0CToAwgHGAJoB11wDBAA4AwgDD
+AMQAxQDGAMcAyAJSAlMAywDMAMeAGoAlgHKAcwmAGl8QFnt7MTgsIDIxN30sIHs0MDIsIDE4fX3dANYA
+DgDXANgA2QDaANsA3ADdAN4A3wDgAOEA4gDjAJcA5QDmAOcAlwJcAOoCTADsAO0A7oAkgA6AIYAOgHSA
+HoBxXxAaRW11bGF0ZSB0aHJlZSBidXR0b24gbW91c2VcZmFrZV9idXR0b25z1AAOALsAhwCIASIBtAC9
+AmWAMIBRgCaAd1VkZXB0aNQADgC7AIcAiAEiAmkAvQJrgDCAeYAmgNzfEA8CbQAOAm4CbwJwAnECcgJz
+AnQCdQJ2AncCeAJ5AnoCewJ8An0CfgJ/AoACgQKCAoMChAKFAOYBzwKGAodcTlNXaW5kb3dWaWV3XxAW
+TlNXaW5kb3dDb250ZW50TWF4U2l6ZVxOU1NjcmVlblJlY3RfEBNOU0ZyYW1lQXV0b3NhdmVOYW1lXU5T
+V2luZG93VGl0bGVZTlNXVEZsYWdzXU5TV2luZG93Q2xhc3NfEBZOU1dpbmRvd0NvbnRlbnRNaW5TaXpl
+XE5TV2luZG93UmVjdFlOU01heFNpemVfEA9OU1dpbmRvd0JhY2tpbmdfEBFOU1dpbmRvd1N0eWxlTWFz
+a1lOU01pblNpemVbTlNWaWV3Q2xhc3OAgIDbgH6A14DagHsSUHgAAIB8gH+AeoDZgNiAfV8QGHt7MzE5
+LCAzMjN9LCB7NDc4LCAzMTZ9fV8QD1gxMSBQcmVmZXJlbmNlc1dOU1BhbmVs0gAOADYANwKNgARUVmll
+d18QGnszLjQwMjgyZSszOCwgMy40MDI4MmUrMzh9WnsyMTMsIDEwN33VAMEADgDPAMQCkQArANEClADL
+ApVbTlNGcmFtZVNpemWAAIClgIGA1tIADgBFAE0CmIA+oQGAgILcAMEADgKbApwAwgD7AM8AxAKdAMYC
+ngKfAnsCoQKiAO0CowDqAqUAywDMAnsAzAKpXk5TVGFiVmlld0l0ZW1zWU5TVHZGbGFnc18QEU5TRHJh
+d3NCYWNrZ3JvdW5kXxAWTlNBbGxvd1RydW5jYXRlZExhYmVsc18QFU5TU2VsZWN0ZWRUYWJWaWV3SXRl
+bYCAgNWAp4CmgB6AgwmAgAmAvtIADgBFAE0CrIA+oQF5gEPSAA4ARQBNArCAPqcBdgKyAbQCtAK1ArYC
+t4BCgIWAUYCUgJiAnICg1wDBAA4AwgDDAMQAxQDGAXkCugK7ArwAywDMAXmAQ4CTgIaAhwmAQ18QFXt7
+MzYsIDU2fSwgezM4NSwgMjh9fdgA1gAOAsEA3ADdAN4A4ALCAOICwwLEAsUCxgKyAsgCyV8QEU5TQmFj
+a2dyb3VuZENvbG9yW05TVGV4dENvbG9ygJKAioCIgImAhRIAQAAAgI9fEGdYMTEgYmVlcHMgd2lsbCB1
+c2UgdGhlIHN0YW5kYXJkIHN5c3RlbSBhbGVydCwgYXMgZGVmaW5lZCBpbiB0aGUgU291bmQgRWZmZWN0
+cyBzeXN0ZW0gcHJlZmVyZW5jZXMgcGFuZWwu1AAOAPEA8gDzAPQCzQD2As+AICNAJgAAAAAAAIAfEQwc
+1QAOAtEC0gLTAtQC1QLWAtcC2ALZV05TQ29sb3JcTlNDb2xvclNwYWNlW05TQ29sb3JOYW1lXU5TQ2F0
+YWxvZ05hbWWAjoCNEAaAjICLVlN5c3RlbVxjb250cm9sQ29sb3LTAA4C0gLdAtUBzwLfV05TV2hpdGWA
+jkswLjY2NjY2NjY5ANIAOgA7AuEC0aIC0QA/1QAOAtEC0gLTAtQC1QLkAtcC5QLZgI6AkYCQgItfEBBj
+b250cm9sVGV4dENvbG9y0wAOAtIC3QLVAc8C6oCOQjAA0gA6ADsC7ALtpALtAQcAwwA/XxAPTlNUZXh0
+RmllbGRDZWxs0gA6ADsC7wLwpQLwAQsBDAENAD9bTlNUZXh0RmllbGTXAMEADgDCAMMAxADFAMYBeQK6
+AvQC9QDLAMwBeYBDgJOAlYCWCYBDXxAVe3sxNywgMjEyfSwgezU1LCAyMH192ADWAA4CwQDcAN0A3gDg
+AsIA4gLDAsQC/ADqArQCyALJgJKAioCXgB6AlICPWENvbG9yczoK1wDBAA4AwgDDAMQAxQDGAXkCugME
+AwUAywDMAXmAQ4CTgJmAmgmAQ18QFnt7MzYsIDE5MH0sIHszOTIsIDE0fX3YANYADgLBANwA3QDeAOAC
+wgDiAsMCxAMMAsYCtQLIAsmAkoCKgJuAiYCYgI9fEDRUaGlzIG9wdGlvbiB0YWtlcyBlZmZlY3Qgd2hl
+biBYMTEgaXMgbGF1bmNoZWQgYWdhaW4u1wDBAA4AwgDDAMQAxQDGAXkAyAMUAxUAywDMAXmAQ4AlgJ2A
+ngmAQ18QFnt7MTgsIDE1Nn0sIHs0MDksIDIzfX3dANYADgDXANgA2QDaANsA3ADdAN4A3wDgAOEA4gDj
+AJcA5QDmAOcAlwMeAOoCtgDsAO0A7oAkgA6AIYAOgJ+AHoCcXxAQRnVsbCBzY3JlZW4gbW9kZdcAwQAO
+AMIAwwDEAMUAxgF5AroDJQMmAMsAzAF5gEOAk4ChgKIJgENfEBZ7ezM2LCAxMTl9LCB7Mzg1LCAzMX19
+2ADWAA4CwQDcAN0A3gDgAsIA4gLDAsQDLQLGArcCyALJgJKAioCjgImAoICPXxBkRW5hYmxlcyB0aGUg
+WDExIHJvb3Qgd2luZG93LiBVc2UgdGhlIENvbW1hbmQtT3B0aW9uLUEga2V5c3Ryb2tlIHRvIGVudGVy
+IGFuZCBsZWF2ZSBmdWxsIHNjcmVlbiBtb2RlLl8QFnt7MTAsIDMzfSwgezQzOCwgMjUzfX3SADoAOwM0
+AQyjAQwBDQA/XxAVe3sxMCwgN30sIHs0NTgsIDI5OX190gAOAEUATQM4gD6jAzkCqQM7gKiAvoDB1gAO
+Az0BDAM+AtEAiAM/A0AAxwGAAsQDRFxOU0lkZW50aWZpZXJZTlNUYWJWaWV3gL2AqYAagIKAioC80gAO
+ADYANwNHgARRMdIADgBFAE0DSoA+pgJMA0wDTQNOA08AvoBxgKuAr4CzgLeAGdcAwQAOAMIAwwDEAMUA
+xgDHAroDVANVAMsAzADHgBqAk4CsgK0JgBpfEBV7ezM2LCA2N30sIHszODUsIDMxfX3YANYADgLBANwA
+3QDeAOACwgDiAsMCxANcAsYDTALIAsmAkoCKgK6AiYCrgI9fEGZXaGVuIGVuYWJsZWQsIG1lbnUgYmFy
+IGtleSBlcXVpdmFsZW50cyBtYXkgaW50ZXJmZXJlIHdpdGggWDExIGFwcGxpY2F0aW9ucyB0aGF0IHVz
+ZSB0aGUgTWV0YSBtb2RpZmllci7XAMEADgDCAMMAxADFAMYAxwK6A2QDZQDLAMwAx4AagJOAsICxCYAa
+XxAWe3szNiwgMTgyfSwgezM4NSwgMjl9fdgA1gAOAsEA3ADdAN4A4ALCAOICwwLEA2wCxgNNAsgCyYCS
+gIqAsoCJgK+Aj18QV0hvbGQgT3B0aW9uIGFuZCBDb21tYW5kIHdoaWxlIGNsaWNraW5nIHRvIGFjdGl2
+YXRlIHRoZSBtaWRkbGUgYW5kIHJpZ2h0IG1vdXNlIGJ1dHRvbnMuCtcAwQAOAMIAwwDEAMUAxgDHAMgD
+dAN1AMsAzADHgBqAJYC0gLUJgBpfEBZ7ezE4LCAxMDR9LCB7NDAyLCAxOH193QDWAA4A1wDYANkA2gDb
+ANwA3QDeAN8A4ADhAOIA4wCXAOUA5gDnAJcDfgDqA04A7ADtAO6AJIAOgCGADoC2gB6As18QIEVuYWJs
+ZSBrZXkgZXF1aXZhbGVudHMgdW5kZXIgWDEx1wDBAA4AwgDDAMQAxQDGAMcCugOFA4YAywDMAMeAGoCT
+gLiAuQmAGl8QFnt7MzYsIDEzM30sIHszODUsIDE0fX3YANYADgLBANwA3QDeAOACwgDiAsMCxAONAsYD
+TwLIAsmAkoCKgLqAiYC3gI9fED5BbGxvd3MgaW5wdXQgbWVudSBjaGFuZ2VzIHRvIG92ZXJ3cml0ZSB0
+aGUgY3VycmVudCBYMTEga2V5bWFwLlVJbnB1dNIAOgA7A5QDlaIDlQA/XU5TVGFiVmlld0l0ZW3WAA4D
+PQEMAz4C0QCIAz8DmAF5AYACxAOcgL2Av4BDgIKAioDA0gAOADYANwOfgARRMlZPdXRwdXTVAA4BDAM+
+AtEAiAM/AZUBgALEA6aAvYBJgIKAioDU0gAOAEUATQOpgD6lA6oBkQOsA60DroDDgEiAx4DLgM/XAMEA
+DgDCAMMAxADFAMYBlQDIA7IDswDLAMwBlYBJgCWAxIDFCYBJ3QDWAA4A1wDYANkA2gDbANwA3QDeAN8A
+4ADhAOIA4wCXAOUA5gDnAJcDuwDqA6oA7ADtAO6AJIAOgCGADoDGgB6Aw18QGEF1dGhlbnRpY2F0ZSBj
+b25uZWN0aW9uc9cAwQAOAMIAwwDEAMUAxgGVAroDwgPDAMsAzAGVgEmAk4DIgMkJgElfEBZ7ezM2LCAx
+Njl9LCB7Mzg1LCA0Mn192ADWAA4CwQDcAN0A3gDgAsIA4gLDAsQDygLGA6wCyALJgJKAioDKgImAx4CP
+XxCqTGF1bmNoaW5nIFgxMSB3aWxsIGNyZWF0ZSBYYXV0aG9yaXR5IGFjY2Vzcy1jb250cm9sIGtleXMu
+IElmIHRoZSBzeXN0ZW0ncyBJUCBhZGRyZXNzIGNoYW5nZXMsIHRoZXNlIGtleXMgYmVjb21lIGludmFs
+aWQgd2hpY2ggbWF5IHByZXZlbnQgWDExIGFwcGxpY2F0aW9ucyBmcm9tIGxhdW5jaGluZy7XAMEADgDC
+AMMAxADFAMYBlQK6A9ID0wDLAMwBlYBJgJOAzIDNCYBJXxAVe3szNiwgOTJ9LCB7Mzg1LCA0Mn192ADW
+AA4CwQDcAN0A3gDgAsIA4gLDAsQD2gLGA60CyALJgJKAioDOgImAy4CPXxCZSWYgZW5hYmxlZCwgQXV0
+aGVudGljYXRlIGNvbm5lY3Rpb25zIG11c3QgYWxzbyBiZSBlbmFibGVkIHRvIGVuc3VyZSBzeXN0ZW0g
+c2VjdXJpdHkuIFdoZW4gZGlzYWJsZWQsIGNvbm5lY3Rpb25zIGZyb20gcmVtb3RlIGFwcGxpY2F0aW9u
+cyBhcmUgbm90IGFsbG93ZWQu1wDBAA4AwgDDAMQAxQDGAZUCugPiA+MAywDMAZWASYCTgNCA0QmASV8Q
+FXt7MTcsIDIwfSwgezQwNCwgMTR9fdgA1gAOAsEA3ADdAN4A4ALCAOICwwLEA+oCxgOuAsgCyYCSgIqA
+0oCJgM+Aj18QNFRoZXNlIG9wdGlvbnMgdGFrZSBlZmZlY3Qgd2hlbiBYMTEgaXMgbmV4dCBsYXVuY2hl
+ZC5YU2VjdXJpdHnSADoAOwPxAz6kAz4BDAENAD9aezQ3OCwgMzE2fV8QFXt7MCwgMH0sIHsxNDQwLCA4
+Nzh9fVp7MjEzLCAxMjl9WXgxMV9wcmVmc9IAOgA7A/cD+KID+AA/XxAQTlNXaW5kb3dUZW1wbGF0ZVtw
+cmVmc19wYW5lbNMADgCHAIgAiQP8A/2AF4DegOHYAA4AjQCOAI8AkACRAJIAkwCUBAAAlgQBAJgAmQCa
+AJuAFYDfgOCAD4ATgAxTQ3V0UXhUY3V0OtQADgC7AIcAiACJAL0BkQC/gBeAJoBIgCjUAA4AuwCHAIgA
+iQC9BBABr4AXgCaA5IBP2AAOAI0AjgCPAJAAkQCSAJMAlAQUAJYAlwCYAJkAmgJEgBWA5YAOgA+AE4Bu
+XEN1c3RvbWl6ZS4uLtQADgC7AIcAiAEiBBwAvQQegDCA54AmgOrXAA4AjQCPAJAAkQCSAJMAlAQhAJcA
+mACZAJoEJYAVgOmADoAPgBOA6NQADgCNAPIAnQCeBCgEKQQqgD+BAbuBAcmBAb1ZQWJvdXQgWDExXngx
+MV9hYm91dF9pdGVt1AAOALsAhwCIAIkAvQQwBDGAF4AmgOyA7tgADgCNAI4AjwCQAJEAkgCTAJQENACW
+AJcAmACZAJoCMIAVgO2ADoAPgBOAal8QEkJyaW5nIEFsbCB0byBGcm9udF8QD2JyaW5nX3RvX2Zyb250
+OtQADgC7AIcAiACJAL0EPgQ/gBeAJoDwgPPYAA4AjQCOAI8AkACRAJIAkwCUBEIAlgRDAJgAmQCaAjCA
+FYDxgPKAD4ATgGpcQ2xvc2UgV2luZG93UXddY2xvc2Vfd2luZG93OtQADgC7AIcAiAEiBEwAvQROgDCA
+9YAmgPfYAA4AjQCOAI8AkACRAJIAkwCUBFEEUgEaAJgAmQCaBCWAFYD2EgAYAACALIAPgBOA6F8QElRv
+Z2dsZSBGdWxsIFNjcmVlbl8QFnRvZ2dsZV9mdWxsc2NyZWVuX2l0ZW3UAA4AuwCHAIgBIgK2AL0EXYAw
+gJyAJoD5XxARZW5hYmxlX2Z1bGxzY3JlZW7UAA4AuwCHAIgAiQC9BGIEY4AXgCaA+4D92AAOAI0AjgCP
+AJAAkQCSAJMAlARmAJYAlwCYAJkAmgIwgBWA/IAOgA+AE4BqW1pvb20gV2luZG93XHpvb21fd2luZG93
+OtMADgCHAIgAiQRvBHCAF4D/gQEC2AAOAI0AjgCPAJAAkQCSAJMAlARzAJYEdACYAJkAmgCbgBWBAQCB
+AQGAD4ATgAxUUmVkb1FaVXJlZG861AAOALsAhwCIAIkAHwR+BH+AF4ACgQEEgQEH2AAOAI0AjgCPAJAA
+kQCSAJMAlASCAJYEgwCYAJkAmgQlgBWBAQWBAQaAD4ATgOhYUXVpdCBYMTFRcVp0ZXJtaW5hdGU60wAO
+AIcAiACJBIwEjYAXgQEJgQEM2AAOAI0AjgCPAJAAkQCSAJMAlASQAJYEkQCYAJkAmgCbgBWBAQqBAQuA
+D4ATgAxUVW5kb1F6VXVuZG861AAOALsAhwCIAIkAHwSbBJyAF4ACgQEOgQEQ2AAOAI0AjgCPAJAAkQCS
+AJMAlASfAJYAlwCYAJkAmgQlgBWBAQ+ADoAPgBOA6FtIaWRlIE90aGVyc18QFmhpZGVPdGhlckFwcGxp
+Y2F0aW9uczrUAA4AuwCHAIgAiQC9BKkEqoAXgCaBARKBARXYAA4AjQCOAI8AkACRAJIAkwCUBK0AlgCX
+AJgAmQCaBLGAFYEBFIAOgA+AE4EBE9MADgCNAJ0AngS0BLWAP4EB3IEB3lhYMTEgSGVscFl4MTFfaGVs
+cDrUAA4AuwCHAIgAiQC9A04Av4AXgCaAs4Ao1AAOALsAhwCIASIDTgC9BMGAMICzgCaBARhfEBBlbmFi
+bGVfa2V5ZXF1aXZz1AAOALsAhwCIAIkAvQTGBMeAF4AmgQEagQEj1wDBAA4AwgDDAMQAxQDGBMkAyATL
+BMwEzQDMBMmBARuAJYEBHIEBHREBLQmBARvVAMEADgDCAM8AxAArANEE0wTUAMuAAIClgQG3gQGoXxAX
+e3szNzIsIDIzMH0sIHsxMDAsIDMyfX3dANYADgDXANgA2QDaANsA3ADdAN4A3wDgAOEA4gDjBNgA5QHG
+BNkE2gTbAOoExgDsBN4E34AkgQEhgQEfgQEigQEegB6BARoSCDgAABP/////hoJA/1lEdXBsaWNhdGXU
+AA4A8QDyAPMA9AD1BOMB2YAggQEgWUhlbHZldGljYdIADgA2ADcAooAE0gAOADYANwCigARfEBVhcHBz
+X3RhYmxlX2R1cGxpY2F0ZTrUAA4AuwCHAIgBIgFJAL0E7oAwgDmAJoEBJV5kb2NrX2FwcHNfbWVuddQA
+DgC7AIcAiACJAL0E8wT0gBeAJoEBJ4EBLdcAwQAOAMIAwwDEAMUAxgTJAMgE+AT5BM0AzATJgQEbgCWB
+ASiBASkJgQEbXxAXe3szNzIsIDI2Mn0sIHsxMDAsIDMyfX3dANYADgDXANgA2QDaANsA3ADdAN4A3wDg
+AOEA4gDjBP8A5QHGBNkFAQUCAOoE8wDsBN4E34AkgQErgQEfgQEsgQEqgB6BASdYQWRkIEl0ZW3SAA4A
+NgA3AKKABNIADgA2ADcAooAEXxAPYXBwc190YWJsZV9uZXc61AAOALsAhwCIAIkAHwQcBQ+AF4ACgOeB
+AS9fEB1vcmRlckZyb250U3RhbmRhcmRBYm91dFBhbmVsOtQADgC7AIcAiAEiASwAvQUVgDCAMoAmgQEx
+WWRvY2tfbWVuddQADgC7AIcAiACJAL0FGgUbgBeAJoEBM4EBNtgADgCNAI4AjwCQAJEAkgCTAJQFHgCW
+BR8AmACZAJoCMIAVgQE0gQE1gA+AE4BqW05leHQgV2luZG93YfcDXG5leHRfd2luZG93OtQADgC7AIcA
+iACJAL0FKQUqgBeAJoEBOIEBPdcAwQAOAMIAwwDEAMUAxgTJAMgFLgUvBTAAzATJgQEbgCWBATmBAToR
+AS8JgQEbXxAVe3szODgsIDEyfSwgezg0LCAzMn193QDWAA4A1wDYANkA2gDbANwA3QDeAN8A4ADhBTUA
+4wCXAOUBxgTZBTkFOgDqBSkA7ATeBN8T/////4QB/gCAJIAOgQEfgQE8gQE7gB6BAThURG9uZdIADgA2
+ADcAooAEXxAQYXBwc190YWJsZV9kb25lOtQADgC7AIcAiACJAL0DqgC/gBeAJoDDgCjUAA4AuwCHAIgB
+IgOqAL0FSoAwgMOAJoEBQFtlbmFibGVfYXV0aNQADgC7AIcAiAEiBU4AvQVQgDCBAUKAJoEBad8QEwDB
+BVIADgKcBVMCwQVUBVUFVgVXBVgAxAKRAMUFWQVaAMYFWwVcBV0A7QVeBV8FYAVhAMwFYwVkAcYFZQDL
+BWYAzAVoAeoFXQVqBWtfEB9OU0RyYWdnaW5nU291cmNlTWFza0Zvck5vbkxvY2FsXE5TSGVhZGVyVmll
+d18QEk5TQWxsb3dzVHlwZVNlbGVjdFxOU0Nvcm5lclZpZXdfEBdOU0ludGVyY2VsbFNwYWNpbmdXaWR0
+aF8QGU5TQ29sdW1uQXV0b3Jlc2l6aW5nU3R5bGVfEBhOU0ludGVyY2VsbFNwYWNpbmdIZWlnaHRbTlNH
+cmlkQ29sb3JfEBxOU0RyYWdnaW5nU291cmNlTWFza0ZvckxvY2FsXk5TVGFibGVDb2x1bW5zW05TUm93
+SGVpZ2h0gQFDgQFoElJAgACBAUWBAVYJgQFJI0AIAAAAAAAAI0AAAAAAAAAAgQFECYEBZYEBQ4EBTSNA
+MQAAAAAAANoAwQAOAMIFbQDPAMQFbgVvAMYFcAVxBXIFcwV0BXUFdgVOBXgFcQVOWU5TY3ZGbGFnc1lO
+U0RvY1ZpZXdZTlNCR0NvbG9yXU5TTmV4dEtleVZpZXeBAUqBAayBAasQBIEBqhEJAIEBQoEBY4EBSoEB
+Qlp7MzMzLCAxOTd91gDBAA4AxAKRAMYFfQV+BX8AywWABX4FTltOU1RhYmxlVmlld4EBRoEBSIEBR4EB
+RoEBQtoAwQAOAMIFbQDPAMQFbgVvAMYFcAVxBXIFhgV0BYcFdgVgBXgFcQVggQFKgQGsgQG0gQGzgQFF
+gQFjgQFKgQFFWXszMzMsIDE3fdIAOgA7BY4Fj6QFjwEMAQ0AP18QEU5TVGFibGVIZWFkZXJWaWV31QDB
+AA4AwgDEAMYFcQWSBZMAywVxgQFKgQFMgQFLgQFK3QDBBZYADgDCBZcFmADPBZkAxADGBZoFcAWbBMkF
+nQWeBZ8FoAV+BaIFowWkBMkFpgVdBV1bTlNIU2Nyb2xsZXJYTlNzRmxhZ3NfEBBOU0hlYWRlckNsaXBW
+aWV3XE5TU2Nyb2xsQW10c1tOU1ZTY3JvbGxlcl1OU0NvbnRlbnRWaWV3gQEbgQGxgQG2gQG1EDKBAUaB
+AalPEBBBIAAAQSAAAEGYAABBmAAAEQEzgQEbgQGtgQFDgQFDXxAUe3szMzQsIDB9LCB7MTYsIDE3fX3S
+ADoAOwWrBaykBawBDAENAD9dX05TQ29ybmVyVmlld9IADgBFAE0Fr4A+owWwBbEFsoEBToEBWIEBXNoF
+tAAOBbUFtgW3BbgFuQW6BbsFfQDMBb0FvgW/BcABzwXBBcIAzAVOXk5TSXNSZXNpemVhYmxlXE5TSGVh
+ZGVyQ2VsbFdOU1dpZHRoWk5TRGF0YUNlbGxeTlNSZXNpemluZ01hc2taTlNNaW5XaWR0aFpOU01heFdp
+ZHRoXE5TSXNFZGl0YWJsZQmBAVeBAU8jQFPAAAAAAACBAVUjQEQAAAAAAAAjQI9AAAAAAAAJgQFC1wDW
+AA4CwQDcAN0A4ALCBcYFxwXIBckCxgDtBcsSBIH+AIEBVIEBUYEBUICJgQFSVE5hbWXTAA4C0gLdAtUB
+zwXPgI5LMC4zMzMzMzI5OQDVAA4C0QLSAtMC1ALVAuQC1wXTAtmAjoCRgQFTgItfEA9oZWFkZXJUZXh0
+Q29sb3LSADoAOwXXBdilBdgC7QEHAMMAP18QEU5TVGFibGVIZWFkZXJDZWxs1wDWAA4CwQDdAN4A4ALC
+BdoCwwVhAOoFTgHTAskSFDH+QICSgQFWgB6BAUKAj9MADgLSAt0C1QHPBeKAjkIxANIAOgA7BeQF5aIF
+5QA/XU5TVGFibGVDb2x1bW7aBbQADgW1BbYFtwW4BbkFugW7BX0AzAW9BekF6gXrAc8F7AXCAMwFTgmB
+AVeBAVkjQGg3ZGAAAACBAVsjQE9dkWAAAAAJgQFC1wDWAA4CwQDcAN0A4ALCBcYFxwXIBfICxgDtBcuB
+AVSBAVGBAVqAiYEBUldDb21tYW5k1wDWAA4CwQDdAN4A4ALCBdoCwwVhAOoFTgHTAsmAkoEBVoAegQFC
+gI/aBbQADgW1BbYFtwW4BbkFugW7BX0AzAW9Bf8GAAYBAc8GAgXCAMwFTgmBAVeBAV0jQEmAAAAAAACB
+AWEjQCQAAAAAAAAJgQFC1wDWAA4CwQDcAN0A4ALCAOIFxwYHBggCxgDtBcuBAVSBAV+BAV6AiYEBUlhT
+aG9ydGN1dNUADgLRAtIC0wLUAtUFYQLXBg8C2YCOgQFWgQFggItbaGVhZGVyQ29sb3LYANYADgLBAN0A
+3gDgAp0CwgXaAsMFeAYVBU4B0wDMAsmAkoEBY4EBYoEBQgmAj9QADgDxAPIA8wD0BhsA9gHZgCAjQCgA
+AAAAAACAH9UADgLRAtIC0wLUAtUC1gLXBiAC2YCOgI2BAWSAi18QFmNvbnRyb2xCYWNrZ3JvdW5kQ29s
+b3LVAA4C0QLSAtMC1ALVBiUC1wYmAtmAjoEBZ4EBZoCLWWdyaWRDb2xvctMADgLSAt0C1QHPBiuAjkQw
+LjUA0gA6ADsGLQV9pQV9AQsBDAENAD9aYXBwc190YWJsZdQADgC7AIcAiACJAB8GMgYzgBeAAoEBa4EB
+btkADgCNAI4AjwCQAJEAkgCTAeAAlAY2AJYGNwCYAJkAmgQlBjuAFYEBbIEBbYAPgBOA6BAqWEhpZGUg
+WDExUWhVaGlkZTrUAA4AuwCHAIgAiQAfBkIGQ4AXgAKBAXCBAXLZAA4AjQCOAI8AkACRAJIAkwHgAJQG
+RgCWAJcAmACZAJoEJQY7gBWBAXGADoAPgBOA6FhTaG93IEFsbF8QFnVuaGlkZUFsbEFwcGxpY2F0aW9u
+czrTAA4AhwCIAIkGTwZQgBeBAXSBAXfYAA4AjQCOAI8AkACRAJIAkwCUBlMAlgZUAJgAmQCaAJuAFYEB
+dYEBdoAPgBOADFVQYXN0ZVF2VnBhc3RlOtQADgC7AIcAiACJAL0GXgZfgBeAJoEBeYEBf9cAwQAOAMIA
+wwDEAMUAxgTJAMgGYwZkBM0AzATJgQEbgCWBAXqBAXsJgQEbXxAXe3szNzIsIDE5OH0sIHsxMDAsIDMy
+fX3dANYADgDXANgA2QDaANsA3ADdAN4A3wDgAOEA4gDjBmoA5QHGBNkGbAZtAOoGXgDsBN4E34AkgQF9
+gQEfgQF+gQF8gB6BAXlWUmVtb3Zl0gAOADYANwCigATSAA4ANgA3AKKABF8QEmFwcHNfdGFibGVfZGVs
+ZXRlOtQADgC7AIcAiAEiAL4AvQZ6gDCAGYAmgQGBW3N5bmNfa2V5bWFw1AAOALsAhwCIAIkAvQZ/BoCA
+F4AmgQGDgQGG2AAOAI0AjgCPAJAAkQCSAJMAlAaDAJYGhACYAJkAmgQlgBWBAYSBAYWAD4ATgOheUHJl
+ZmVyZW5jZXMuLi5RLFtwcmVmc19zaG93OtQADgC7AIcAiACJAL0ETAaPgBeAJoD1gQGIXxASdG9nZ2xl
+X2Z1bGxzY3JlZW461AAOALsAhwCIAIkAvQK2BpWAF4AmgJyBAYpfEBplbmFibGVfZnVsbHNjcmVlbl9j
+aGFuZ2VkOtQADgC7AIcAiAEiATgAvQabgDCANYAmgQGMXxAVZG9ja193aW5kb3dfc2VwYXJhdG9y1AAO
+ALsAhwCIAIkAvQJMAL+AF4AmgHGAKNQADgC7AIcAiACJAL0GpQamgBeAJoEBj4EBktgADgCNAI4AjwCQ
+AJEAkgCTAJQGqQCWBqoAmACZAJoCMIAVgQGQgQGRgA+AE4BqXxAPUHJldmlvdXMgV2luZG93YfcCXxAQ
+cHJldmlvdXNfd2luZG93OtQADgC7AIcAiACJAL0GtAa1gBeAJoEBlIEBl9gADgCNAI4AjwCQAJEAkgCT
+AJQGuACWBrkAmACZAJoCMIAVgQGVgQGWgA+AE4BqXxAPTWluaW1pemUgV2luZG93UW1fEBBtaW5pbWl6
+ZV93aW5kb3c61AAOALsAhwCIAIkAvQbDBsSAF4AmgQGZgQGf1wDBAA4AwgDDAMQAxQDGBMkAyAbIBskF
+MADMBMmBARuAJYEBmoEBmwmBARtfEBV7ezMwNCwgMTJ9LCB7ODQsIDMyfX3dANYADgDXANgA2QDaANsA
+3ADdAN4A3wDgAOEA4gDjBs8A5QHGBNkG0QbSAOoGwwDsBN4E34AkgQGdgQEfgQGegQGcgB6BAZlWQ2Fu
+Y2Vs0gAOADYANwCigATSAA4ANgA3AKKABF8QEmFwcHNfdGFibGVfY2FuY2VsOtQADgC7AIcAiAEiAXYA
+vQbfgDCAQoAmgQGhW3VzZV9zeXNiZWVw0wAOAIcAiACJBuMG5IAXgQGjgQGm2AAOAI0AjgCPAJAAkQCS
+AJMAlAbnAJYG6ACYAJkAmgCbgBWBAaSBAaWAD4ATgAxUQ29weVFjVWNvcHk60gAOAEUG8AbxgQHsrxB9
+BsMEyQG6AZECRAH6BBwGtAMVAyYBeQC+Bv4EfgNNAZUFKQcDBZ0HBQcGBBABOQOuASwDZQK3Ac0BdgWy
+BJsC9QZeAjACewQ+A04DdQF8A/wHGgHUBxwHHQYyA8MHIAJpBMYGyQNPBk8E8wK0BGIGfwcqAwUHLAIl
+AUkGQgcwArwCTAC9AYAFcQRMBbEE+QQwA7MBOAVOBbADOQNVAIoCOQdCBaYBWgdFBKkEjAH4BuMHSgKy
+BWADOwK1AlMD4wYBAqkFwAOGB1UBtAOsA60BFQK2A9MAxwZkBqUHXwSxA6oEJQdjBMwF6wFZBRoB+QGY
+BS8AmwDKA0wEb4EBmYEBG4BTgEiAboBjgOeBAZSAnoCigEOAGYEBuYEBBICvgEmBATiBAb+BAbGBAcaB
+AcqA5IA2gM+AMoCxgKCAV4BCgQFcgQEOgJaBAXmAaoCAgPCAs4C1gEWA3oEBuoBYgQHbgQHHgQFrgMmB
+AdeAeYEBGoEBm4C3gQF0gQEngJSA+4EBg4EBzoCagQHggGmAOYEBcIEBvoCHgHGAJoCCgQFKgPWBAViB
+ASmA7IDFgDWBAUKBAU6AqICtgAuAbYEB4oEBrYA8gQHYgQESgQEJgF2BAaOBAdOAhYEBRYDBgJiAc4DR
+gQFhgL6BAVWAuYEBz4BRgMeAy4AqgJyAzYAagQF7gQGPgQHIgQETgMOA6IEBwoEBHYEBW4A7gQEzgGCA
+S4EBOoAMgByAq4D/0gAOAEUATQdxgD6mBSkExgZeBXEGwwTzgQE4gQEagQF5gQFKgQGZgQEn0gAOAEUA
+TQd6gD6lBV0FpgWdBX4FY4EBQ4EBrYEBsYEBRoEBSdIADgBFAE0HgoA+oQVOgQFCXxAVe3sxLCAxN30s
+IHszMzMsIDE5N3190gA6ADsHhgeHpAeHAQwBDQA/Wk5TQ2xpcFZpZXfYAMEB3wAOAMIAxAFHAMYHiQVx
+BXEHjAeNAMsHjgVxB5BZTlNQZXJjZW50gQFKgQFKgQGwgQGugQGvgQFKIz/v1mqAAAAAXxAWe3szMzQs
+IDE3fSwgezE1LCAxOTd9fVxfZG9TY3JvbGxlcjrSADoAOweUB5WlB5UBCwEMAQ0AP1pOU1Njcm9sbGVy
+2QDBAd8ADgDCBZcAxAFHAMYHiQVxBXEHjAeaAcYAyweOBXEHnYEBSoEBSoEBsIEBsoEBr4EBSiM/788X
+wAAAAF8QFXt7MSwgMjE0fSwgezMzMywgMTV9fdIADgBFAE0HoYA+oQVggQFFXxATe3sxLCAwfSwgezMz
+MywgMTd9fV8QFnt7MjAsIDYwfSwgezM1MCwgMjMwfX3SADoAOwemB6ekB6cBDAENAD9cTlNTY3JvbGxW
+aWV3XxAUe3sxLCAxfSwgezQ4NiwgMzEwfX3SAA4ARQBNB6uAPqICOQQQgG2A5NoADgFGAI0AjgCPAJAA
+kQCSAJMBRwCUBCUEKACWAJcAmACZAJoHGge2gBWA6IEBu4AOgA+AE4EBuoEBvNQADgCNAPIAnQCeB7kH
+uge7gD+BAdGBAd+BAdJTWDEx0gAOAEUATQe/gD6sBBwGfwcwBwMHBQRMBx0GMgSbBkIHXwR+gOeBAYOB
+Ab6BAb+BAcaA9YEBx4EBa4EBDoEBcIEByIEBBNoADgCNAI4BOwCPATwAkACRAJIAkwCUAJcAlgDMAJcA
+zACYAJkAmgQlgBWADgmADgmAD4ATgOjaAA4BRgCNAI4AjwCQAJEAkgCTAUcAlAdjB9gAlgCXAJgAmQCa
+BCUH3YAVgQHCgQHAgA6AD4ATgOiBAcFYU2VydmljZXPUAA4AjQDyAJ0AngfhB+IH44A/gQHDgQHFgQHE
+0gAOADYANwfegATSAA4ARQBNB+iAPqBfEA9fTlNTZXJ2aWNlc01lbnXaAA4AjQCOATsAjwE8AJAAkQCS
+AJMAlACXAJYAzACXAMwAmACZAJoEJYAVgA4JgA4JgA+AE4Do2gAOAI0AjgE7AI8BPACQAJEAkgCTAJQA
+lwCWAMwAlwDMAJgAmQCaBCWAFYAOCYAOCYAPgBOA6NoADgCNAI4BOwCPATwAkACRAJIAkwCUAJcAlgDM
+AJcAzACYAJkAmgQlgBWADgmADgmAD4ATgOhcX05TQXBwbGVNZW512gAOAUYAjQCOAI8AkACRAJIAkwFH
+AJQCRAFKAJYAlwCYAJkAmgcaCA6AFYBugDeADoAPgBOBAbqBAcvSAA4ANgA3CBGABFZXaW5kb3fSAA4A
+RQBNCBSAPqkGtAQ+BGIHKgUaBqUHVQQwAiWBAZSA8ID7gQHOgQEzgQGPgQHPgOyAadoADgCNAI4BOwCP
+ATwAkACRAJIAkwCUAJcAlgDMAJcAzACYAJkAmgIwgBWADgmADgmAD4ATgGraAA4AjQCOATsAjwE8AJAA
+kQCSAJMAlACXAJYAzACXAMwAmACZAJoCMIAVgA4JgA4JgA+AE4BqXl9OU1dpbmRvd3NNZW51WE1haW5N
+ZW510gAOAEUATQg0gD6lBv4HBgdKB0UHHIEBuYEByoEB04EB2IEB29oADgFGAI0AjgCPAJAAkQCSAJMB
+RwCUAJsAnwCWAJcAmACZAJoHGghCgBWADIEB1IAOgA+AE4EBuoEB1VRFZGl00gAOAEUATQhGgD6oBIwE
+bwcgA/wG4wZPAIoBFYEBCYD/gQHXgN6BAaOBAXSAC4Aq2gAOAI0AjgE7AI8BPACQAJEAkgCTAJQAlwCW
+AMwAlwDMAJgAmQCaAJuAFYAOCYAOCYAPgBOADNoADgFGAI0AjgCPAJAAkQCSAJMBRwCUAjAIWwCWAJcA
+mACZAJoHGghggBWAaoEB2YAOgA+AE4EBuoEB2toADgFGAI0AjgCPAJAAkQCSAJMBRwCUBLEEtACWAJcA
+mACZAJoHGghpgBWBAROBAdyADoAPgBOBAbqBAd1USGVscNIADgBFAE0IbYA+oQSpgQESW19OU01haW5N
+ZW510gAOADIAMwhygAWBAeHfEA8CbQAOAm4CbwJwAnECcgJzAnQCdQJ2AncCeAJ5AnoEyQJ8CHYIdwh4
+CHkCgQKCCHsIfAh9AOYIfgh/CICBARuA24EB5oEB6IEB64EB5IB8gQHngQHjgQHqEAuBAemBAeVfEBh7
+ezI3OSwgMjcwfSwgezQ4NiwgMzEwfX1fEBRYMTEgQXBwbGljYXRpb24gTWVuddIADgA2ADcCjYAEWHgx
+MV9hcHBz0gA6ADsIhwFvogFvAD/SAA4ARQbwCIqBAeyvEH0EyQdCAbQBlQcGAdQEJQIwArYCtwKpAMcH
+GgQlAMcDOwTJBCUFcQQlBxoCRAEsAZUAHwNNAXkB1AF5BU4EJQK0BMkHRQJpAjAAxwNOAXYAmwAfAboH
+GgQlBCUDrACbAB8EyQbDAMcAmwTJAXkCMAQlAjACtQAfAjABOQQlBCUCsgDHAB8CewTJBCUFTgTzAjAD
+qgEsBXEFTgGAA0wAmwJEAB8FcQFJBxoEsQCbAdQAmwcaAXkFcQGAAXkCTAOuBbIBgAWwA08CMAF5AZUB
+lQCbAXkDrQM5Bl4CMAQlBxwBlQb+BwMExgWxAUkCMAHUAZEFKQdKAL4AxwCbgQEbgQHigFGASYEByoBY
+gOiAaoCcgKCAvoAagQG6gOiAGoDBgQEbgOiBAUqA6IEBuoBugDKASYACgK+AQ4BYgEOBAUKA6ICUgQEb
+gQHYgHmAaoAagLOAQoAMgAKAU4EBuoDogOiAx4AMgAKBARuBAZmAGoAMgQEbgEOAaoDogGqAmIACgGqA
+NoDogOiAhYAagAKAgIEBG4DogQFCgQEngGqAw4AygQFKgQFCgIKAq4AMgG6AAoEBSoA5gQG6gQETgAyA
+WIAMgQG6gEOBAUqAgoBDgHGAz4EBXICCgQFOgLeAaoBDgEmASYAMgEOAy4CogQF5gGqA6IEB24BJgQG5
+gQG/gQEagQFYgDmAaoBYgEiBATiBAdOAGYAagAzSAA4ARQbwCQqBAeyvEH4GwwTJAboBkQJEAfoEHAa0
+AxUDJgAfAXkBlQb+BH4FKQWdAL4HAwNNBwYHBQQQATkDrgEsA2UCtwHNBbIBdgSbBl4C9QIwAnsEPgNO
+A3UBfAP8BxoB1AccBMYHHQYyAmkHIAbJBPMDTwZPA8MCtARiBn8HKgMFAiUHLAFJBkIHMAK8AkwAvQGA
+BXEETAT5BbEEMAE4A7MFTgWwB0IDOQCKAjkFpgNVAVoHRQSpBIwB+AbjB0oFYAKyAzsCtQYBAlMD4wKp
+BcADhgdVA6wBtAOtARUCtgZkAMcD0wSxB18GpQOqBCUBWQTMB2MF6wUaAZgB+QUvAJsAygNMBG+BAZmB
+ARuAU4BIgG6AY4DngQGUgJ6AooACgEOASYEBuYEBBIEBOIEBsYAZgQG/gK+BAcqBAcaA5IA2gM+AMoCx
+gKCAV4EBXIBCgQEOgQF5gJaAaoCAgPCAs4C1gEWA3oEBuoBYgQHbgQEagQHHgQFrgHmBAdeBAZuBASeA
+t4EBdIDJgJSA+4EBg4EBzoCagGmBAeCAOYEBcIEBvoCHgHGAJoCCgQFKgPWBASmBAViA7IA1gMWBAUKB
+AU6BAeKAqIALgG2BAa2ArYA8gQHYgQESgQEJgF2BAaOBAdOBAUWAhYDBgJiBAWGAc4DRgL6BAVWAuYEB
+z4DHgFGAy4AqgJyBAXuAGoDNgQETgQHIgQGPgMOA6IA7gQEdgQHCgQFbgQEzgEuAYIEBOoAMgByAq4D/
+0gAOAEUG8AmLgQHsrxB+CYwJjQmOCY8JkAmRCZIJkwmUCZUJlgmXCZgJmQmaCZsJnAmdCZ4JnwmgCaEJ
+ogmjCaQJpQmmCacJqAmpCaoJqwmsCa0JrgmvCbAJsQmyCbMJtAe5CbYJtwm4CbkJugm7CbwJvQm+Cb8J
+wAnBCcIJwwnECcUJxgnHCcgJyQnKCcsJzAnNARAJzwnQCdEJ0gnTCdQJ1QnWCdcJ2AnZCdoJ2wncCd0J
+3gnfCeAJ4QniCeMJ5AnlCeYJ5wnoCekJ6gnrCewJ7QnuCe8J8AnxCfIJ8wn0CfUJ9gn3CfgJ+Qn6CfsJ
+/An9Cf4J/woACgEKAgoDCgQKBQoGCgcKCAoJgQHwgQHxgQHygQHzgQH0gQH1gQH2gQH3gQH4gQH5gQH6
+gQH7gQH8gQH9gQH+gQH/gQIAgQIBgQICgQIDgQIEgQIFgQIGgQIHgQIIgQIJgQIKgQILgQIMgQINgQIO
+gQIPgQIQgQIRgQISgQITgQIUgQIVgQIWgQIXgQIYgQHRgQIZgQIagQIbgQIcgQIdgQIegQIfgQIggQIh
+gQIigQIjgQIkgQIlgQImgQIngQIogQIpgQIqgQIrgQIsgQItgQIugQIvgQIwgCeBAjGBAjKBAjOBAjSB
+AjWBAjaBAjeBAjiBAjmBAjqBAjuBAjyBAj2BAj6BAj+BAkCBAkGBAkKBAkOBAkSBAkWBAkaBAkeBAkiB
+AkmBAkqBAkuBAkyBAk2BAk6BAk+BAlCBAlGBAlKBAlOBAlSBAlWBAlaBAleBAliBAlmBAlqBAluBAlyB
+Al2BAl6BAl+BAmCBAmGBAmKBAmOBAmSBAmWBAmaBAmeBAmiBAmmBAmqBAmtfEBRQdXNoIEJ1dHRvbiAo
+Q2FuY2VsKV5Db250ZW50IFZpZXctMV8QIVBvcCBVcCBCdXR0b24gQ2VsbCAoRnJvbSBEaXNwbGF5KV8Q
+MkNoZWNrIEJveCAoQWxsb3cgY29ubmVjdGlvbnMgZnJvbSBuZXR3b3JrIGNsaWVudHMpXxATTWVudSAo
+QXBwbGljYXRpb25zKV8QFE1lbnUgSXRlbSAoTWlsbGlvbnMpXxAVTWVudSBJdGVtIChBYm91dCBYMTEp
+XxAbTWVudSBJdGVtIChNaW5pbWl6ZSBXaW5kb3cpXxAeQnV0dG9uIENlbGwgKEZ1bGwgc2NyZWVuIG1v
+ZGUpXxB2VGV4dCBGaWVsZCBDZWxsIChFbmFibGVzIHRoZSBYMTEgcm9vdCB3aW5kb3cuIFVzZSB0aGUg
+Q29tbWFuZC1PcHRpb24tQSBrZXlzdHJva2UgdG8gZW50ZXIgYW5kIGxlYXZlIGZ1bGwgc2NyZWVuIG1v
+ZGUuKVxGaWxlJ3MgT3duZXJWVmlldy0yVlZpZXctMV8QD01lbnUgSXRlbSAoWDExKV8QFE1lbnUgSXRl
+bSAoUXVpdCBYMTEpXxASUHVzaCBCdXR0b24gKERvbmUpXxATSG9yaXpvbnRhbCBTY3JvbGxlcl8QKUNo
+ZWNrIEJveCAoRm9sbG93IHN5c3RlbSBrZXlib2FyZCBsYXlvdXQpXxAUTWVudSBJdGVtIChTZXJ2aWNl
+cylfEGVTdGF0aWMgVGV4dCAoSG9sZCBPcHRpb24gYW5kIENvbW1hbmQgd2hpbGUgY2xpY2tpbmcgdG8g
+YWN0aXZhdGUgdGhlIG1pZGRsZSBhbmQgcmlnaHQgbW91c2UgYnV0dG9ucy4KKV8QGE1lbnUgSXRlbSAo
+QXBwbGljYXRpb25zKVtTZXBhcmF0b3ItMV8QGE1lbnUgSXRlbSAoQ3VzdG9taXplLi4uKV8QGk1lbnUg
+SXRlbSAoQXBwbGljYXRpb25zKS0xXxBCU3RhdGljIFRleHQgKFRoZXNlIG9wdGlvbnMgdGFrZSBlZmZl
+Y3Qgd2hlbiBYMTEgaXMgbmV4dCBsYXVuY2hlZC4pWERvY2tNZW51XxBpVGV4dCBGaWVsZCBDZWxsIChI
+b2xkIE9wdGlvbiBhbmQgQ29tbWFuZCB3aGlsZSBjbGlja2luZyB0byBhY3RpdmF0ZSB0aGUgbWlkZGxl
+IGFuZCByaWdodCBtb3VzZSBidXR0b25zLgopXxByU3RhdGljIFRleHQgKEVuYWJsZXMgdGhlIFgxMSBy
+b290IHdpbmRvdy4gVXNlIHRoZSBDb21tYW5kLU9wdGlvbi1BIGtleXN0cm9rZSB0byBlbnRlciBhbmQg
+bGVhdmUgZnVsbCBzY3JlZW4gbW9kZS4pXxAYTWVudSBJdGVtIChGcm9tIERpc3BsYXkpXxAXVGFibGUg
+Q29sdW1uIChTaG9ydGN1dClfECNDaGVjayBCb3ggKFVzZSBzeXN0ZW0gYWxlcnQgZWZmZWN0KV8QF01l
+bnUgSXRlbSAoSGlkZSBPdGhlcnMpXxAUUHVzaCBCdXR0b24gKFJlbW92ZSlfEBpUZXh0IEZpZWxkIENl
+bGwgKENvbG9yczoKKV1NZW51IChXaW5kb3cpXENvbnRlbnQgVmlld18QGE1lbnUgSXRlbSAoQ2xvc2Ug
+V2luZG93KV8QLENoZWNrIEJveCAoRW5hYmxlIGtleSBlcXVpdmFsZW50cyB1bmRlciBYMTEpXxAuQnV0
+dG9uIENlbGwgKEVuYWJsZSBrZXkgZXF1aXZhbGVudHMgdW5kZXIgWDExKV8QJUJ1dHRvbiBDZWxsIChV
+c2Ugc3lzdGVtIGFsZXJ0IGVmZmVjdClfEA9NZW51IEl0ZW0gKEN1dClfEBFNZW51IChPdGhlclZpZXdz
+KV8QEE1lbnUgSXRlbSAoSGVscClfEBdQdXNoIEJ1dHRvbiAoRHVwbGljYXRlKVtTZXBhcmF0b3ItMl8Q
+FE1lbnUgSXRlbSAoSGlkZSBYMTEpWlByZWZzUGFuZWxbU2VwYXJhdG9yLTlfEBRCdXR0b24gQ2VsbCAo
+Q2FuY2VsKV8QFlB1c2ggQnV0dG9uIChBZGQgSXRlbSlfEExTdGF0aWMgVGV4dCAoQWxsb3dzIGlucHV0
+IG1lbnUgY2hhbmdlcyB0byBvdmVyd3JpdGUgdGhlIGN1cnJlbnQgWDExIGtleW1hcC4pXxARTWVudSBJ
+dGVtIChQYXN0ZSlfELxUZXh0IEZpZWxkIENlbGwgKExhdW5jaGluZyBYMTEgd2lsbCBjcmVhdGUgWGF1
+dGhvcml0eSBhY2Nlc3MtY29udHJvbCBrZXlzLiBJZiB0aGUgc3lzdGVtJ3MgSVAgYWRkcmVzcyBjaGFu
+Z2VzLCB0aGVzZSBrZXlzIGJlY29tZSBpbnZhbGlkIHdoaWNoIG1heSBwcmV2ZW50IFgxMSBhcHBsaWNh
+dGlvbnMgZnJvbSBsYXVuY2hpbmcuKV8QFlN0YXRpYyBUZXh0IChDb2xvcnM6CilfEBdNZW51IEl0ZW0g
+KFpvb20gV2luZG93KV8QGk1lbnUgSXRlbSAoUHJlZmVyZW5jZXMuLi4pW1NlcGFyYXRvci02XxBGVGV4
+dCBGaWVsZCBDZWxsIChUaGlzIG9wdGlvbiB0YWtlcyBlZmZlY3Qgd2hlbiBYMTEgaXMgbGF1bmNoZWQg
+YWdhaW4uKVtTZXBhcmF0b3ItN1tBcHBsaWNhdGlvbl8QFU1lbnUgKEFwcGxpY2F0aW9ucyktMV8QFE1l
+bnUgSXRlbSAoU2hvdyBBbGwpW1NlcGFyYXRvci0zXxB5VGV4dCBGaWVsZCBDZWxsIChYMTEgYmVlcHMg
+d2lsbCB1c2UgdGhlIHN0YW5kYXJkIHN5c3RlbSBhbGVydCwgYXMgZGVmaW5lZCBpbiB0aGUgU291bmQg
+RWZmZWN0cyBzeXN0ZW0gcHJlZmVyZW5jZXMgcGFuZWwuKV8QJkNoZWNrIEJveCAoRW11bGF0ZSB0aHJl
+ZSBidXR0b24gbW91c2UpXxAmVG9wIFRhYiBWaWV3IChJbnB1dCwgT3V0cHV0LCBTZWN1cml0eSlbU2Ny
+b2xsIFZpZXdfEB5NZW51IEl0ZW0gKFRvZ2dsZSBGdWxsIFNjcmVlbilfEBZCdXR0b24gQ2VsbCAoQWRk
+IEl0ZW0pXxAWVGFibGUgQ29sdW1uIChDb21tYW5kKV8QHk1lbnUgSXRlbSAoQnJpbmcgQWxsIHRvIEZy
+b250KVlTZXBhcmF0b3JfECZCdXR0b24gQ2VsbCAoQXV0aGVudGljYXRlIGNvbm5lY3Rpb25zKV8QJFRh
+YmxlIFZpZXcgKE5hbWUsIENvbW1hbmQsIFNob3J0Y3V0KV8QE1RhYmxlIENvbHVtbiAoTmFtZSlcRWRp
+dFByb2dyYW1zXxAVVGFiIFZpZXcgSXRlbSAoSW5wdXQpXxASTWVudSBJdGVtIChEZWxldGUpW1NlcGFy
+YXRvci01XxARVmVydGljYWwgU2Nyb2xsZXJfEHhUZXh0IEZpZWxkIENlbGwgKFdoZW4gZW5hYmxlZCwg
+bWVudSBiYXIga2V5IGVxdWl2YWxlbnRzIG1heSBpbnRlcmZlcmUgd2l0aCBYMTEgYXBwbGljYXRpb25z
+IHRoYXQgdXNlIHRoZSBNZXRhIG1vZGlmaWVyLilvEBYATQBlAG4AdQAgAEkAdABlAG0AIAAoAEMAdQBz
+AHQAbwBtAGkAegBlICYAKV8QEk1lbnUgSXRlbSAoV2luZG93KV8QFE1lbnUgSXRlbSAoWDExIEhlbHAp
+XxAQTWVudSBJdGVtIChVbmRvKV8QFk1lbnUgSXRlbSAoMjU2IENvbG9ycylfEBBNZW51IEl0ZW0gKENv
+cHkpXxAQTWVudSBJdGVtIChFZGl0KV8QEVRhYmxlIEhlYWRlciBWaWV3XxB1U3RhdGljIFRleHQgKFgx
+MSBiZWVwcyB3aWxsIHVzZSB0aGUgc3RhbmRhcmQgc3lzdGVtIGFsZXJ0LCBhcyBkZWZpbmVkIGluIHRo
+ZSBTb3VuZCBFZmZlY3RzIHN5c3RlbSBwcmVmZXJlbmNlcyBwYW5lbC4pXxAYVGFiIFZpZXcgSXRlbSAo
+U2VjdXJpdHkpXxBCU3RhdGljIFRleHQgKFRoaXMgb3B0aW9uIHRha2VzIGVmZmVjdCB3aGVuIFgxMSBp
+cyBsYXVuY2hlZCBhZ2Fpbi4pXxAPVGV4dCBGaWVsZCBDZWxsXxAoQnV0dG9uIENlbGwgKEVtdWxhdGUg
+dGhyZWUgYnV0dG9uIG1vdXNlKV8QRlRleHQgRmllbGQgQ2VsbCAoVGhlc2Ugb3B0aW9ucyB0YWtlIGVm
+ZmVjdCB3aGVuIFgxMSBpcyBuZXh0IGxhdW5jaGVkLilfEBZUYWIgVmlldyBJdGVtIChPdXRwdXQpXxAR
+VGV4dCBGaWVsZCBDZWxsLTJfEFBUZXh0IEZpZWxkIENlbGwgKEFsbG93cyBpbnB1dCBtZW51IGNoYW5n
+ZXMgdG8gb3ZlcndyaXRlIHRoZSBjdXJyZW50IFgxMSBrZXltYXAuKVtTZXBhcmF0b3ItOF8QuFN0YXRp
+YyBUZXh0IChMYXVuY2hpbmcgWDExIHdpbGwgY3JlYXRlIFhhdXRob3JpdHkgYWNjZXNzLWNvbnRyb2wg
+a2V5cy4gSWYgdGhlIHN5c3RlbSdzIElQIGFkZHJlc3MgY2hhbmdlcywgdGhlc2Uga2V5cyBiZWNvbWUg
+aW52YWxpZCB3aGljaCBtYXkgcHJldmVudCBYMTEgYXBwbGljYXRpb25zIGZyb20gbGF1bmNoaW5nLilf
+EBtQb3B1cCBCdXR0b24gKEZyb20gRGlzcGxheSlfEKdTdGF0aWMgVGV4dCAoSWYgZW5hYmxlZCwgQXV0
+aGVudGljYXRlIGNvbm5lY3Rpb25zIG11c3QgYWxzbyBiZSBlbmFibGVkIHRvIGVuc3VyZSBzeXN0ZW0g
+c2VjdXJpdHkuIFdoZW4gZGlzYWJsZWQsIGNvbm5lY3Rpb25zIGZyb20gcmVtb3RlIGFwcGxpY2F0aW9u
+cyBhcmUgbm90IGFsbG93ZWQuKV8QFk1lbnUgSXRlbSAoU2VsZWN0IEFsbClfEBxDaGVjayBCb3ggKEZ1
+bGwgc2NyZWVuIG1vZGUpXxAUQnV0dG9uIENlbGwgKFJlbW92ZSlfEKtUZXh0IEZpZWxkIENlbGwgKElm
+IGVuYWJsZWQsIEF1dGhlbnRpY2F0ZSBjb25uZWN0aW9ucyBtdXN0IGFsc28gYmUgZW5hYmxlZCB0byBl
+bnN1cmUgc3lzdGVtIHNlY3VyaXR5LiBXaGVuIGRpc2FibGVkLCBjb25uZWN0aW9ucyBmcm9tIHJlbW90
+ZSBhcHBsaWNhdGlvbnMgYXJlIG5vdCBhbGxvd2VkLilbTWVudSAoSGVscClbU2VwYXJhdG9yLTRfEBtN
+ZW51IEl0ZW0gKFByZXZpb3VzIFdpbmRvdylfECRDaGVjayBCb3ggKEF1dGhlbnRpY2F0ZSBjb25uZWN0
+aW9ucylaTWVudSAoWDExKVxTZXBhcmF0b3ItMTBfEBdCdXR0b24gQ2VsbCAoRHVwbGljYXRlKV8QD01l
+bnUgKFNlcnZpY2VzKV8QEVRleHQgRmllbGQgQ2VsbC0xXxAXTWVudSBJdGVtIChOZXh0IFdpbmRvdylf
+EDRCdXR0b24gQ2VsbCAoQWxsb3cgY29ubmVjdGlvbnMgZnJvbSBuZXR3b3JrIGNsaWVudHMpXxAVTWVu
+dSBJdGVtIChUaG91c2FuZHMpXxASQnV0dG9uIENlbGwgKERvbmUpW01lbnUgKEVkaXQpXxArQnV0dG9u
+IENlbGwgKEZvbGxvdyBzeXN0ZW0ga2V5Ym9hcmQgbGF5b3V0KV8QdFN0YXRpYyBUZXh0IChXaGVuIGVu
+YWJsZWQsIG1lbnUgYmFyIGtleSBlcXVpdmFsZW50cyBtYXkgaW50ZXJmZXJlIHdpdGggWDExIGFwcGxp
+Y2F0aW9ucyB0aGF0IHVzZSB0aGUgTWV0YSBtb2RpZmllci4pXxAQTWVudSBJdGVtIChSZWRvKdIADgBF
+BvAKh4EB7KDSAA4ARQbwCoqBAeyg0gAOAEUG8AqNgQHsrxC1BsMAbgTJAboBkQJEAfoAhAQcAFYGtAMV
+AyYAHwBpAXkAvgb+BH4DTQGVBSkHAwWdBwUHBgQQAFIAVQB4AH4BOQCAA64BLANlArcBzQBTAXYFsgSb
+AGsC9QZeAjAAegBQAnsEPgNOA3UBfABnAH0D/ACBAE8HGgHUBxwAYwB7AHEHHQYyA8MHIAJpBMYGyQNP
+Bk8E8wBcAGwAUQBeArQEYgBZAGUGfwcqAwUHLAIlAIMBSQZCAG8HMAK8AkwAVABiAHcAvQGABXEETAWx
+BPkEMAOzATgFTgWwAFgDOQNVAIoCOQdCBaYAZABbAVoAagBtB0UAcgCCBKkEjAB0AfgAdgB5BuMHSgKy
+BWADOwK1AHACUwPjBgECqQXAA4YHVQCFAGYBtAOsA60BFQK2A9MAxwZkAGAAYQBzBqUHXwSxA6oAVwB/
+BCUHYwTMBesBWQBaBRoAXwBoAfkBmAB8BS8AdQCbAMoDTARvAF2BAZmBASSBARuAU4BIgG6AY4EBoIDn
+gE6BAZSAnoCigAKBAQ2AQ4AZgQG5gQEEgK+ASYEBOIEBv4EBsYEBxoEByoDkgC6AR4EBb4EBiYA2gQGN
+gM+AMoCxgKCAV4AxgEKBAVyBAQ6BARaAloEBeYBqgQF4gBiAgIDwgLOAtYBFgQEDgQGHgN6BAY6ACoEB
+uoBYgQHbgPSBAYCBATCBAceBAWuAyYEB14B5gQEagQGbgLeBAXSBASeAeIEBF4ApgOKAlID7gGyA+oEB
+g4EBzoCagQHggGmBAZiAOYEBcIEBJoEBvoCHgHGAQYDvgQFqgCaAgoEBSoD1gQFYgQEpgOyAxYA1gQFC
+gQFOgGiAqICtgAuAbYEB4oEBrYD4gHaAPIEBEYEBGYEB2IEBMoEBk4EBEoEBCYEBPoBdgQFBgQFzgQGj
+gQHTgIWBAUWAwYCYgQEugHOA0YEBYYC+gQFVgLmBAc+BAaKA/oBRgMeAy4AqgJyAzYAagQF7gOaA64EB
+N4EBj4EByIEBE4DDgFCBAYuA6IEBwoEBHYEBW4A7gHCBATOA44EBCIBggEuBAYKBATqBAT+ADIAcgKuA
+/4Dd0gAOAEUG8AtFgQHsrxC1C0YLRwtIC0kLSgtLC0wLTQtOC08LUAtRC1ILUwtUC1ULVgtXC1gLWQta
+C1sLXAtdC14LXwtgC2ELYgtjC2QLZQtmC2cLaAtpC2oLawtsC20LbgtvC3ALcQtyC3MLdAt1C3YLdwt4
+C3kLegt7C3wLfQt+C38LgAuBC4ILgwuEC4ULhguHC4gLiQuKC4sLjAuNC44LjwuQC5ELkguTC5QLlQuW
+C5cLmAuZC5oLmwucC50LngufC6ALoQuiC6MLpAulC6YLpwuoC6kLqgurC6wLrQuuC68LsAuxC7ILswu0
+C7ULtgu3C7gLuQu6C7sLvAu9C74LvwvAC8ELwgvDC8QLxQvGC8cLyAvJC8oLywvMC80LzgvPC9AL0QvS
+C9ML1AvVC9YL1wvYC9kL2gvbC9wL3QveC98L4AvhC+IL4wvkC+UL5gvnC+gL6QvqC+sL7AvtC+4L7wvw
+C/EL8gvzC/QL9Qv2C/cL+Av5C/qBAnCBAnGBAnKBAnOBAnSBAnWBAnaBAneBAniBAnmBAnqBAnuBAnyB
+An2BAn6BAn+BAoCBAoGBAoKBAoOBAoSBAoWBAoaBAoeBAoiBAomBAoqBAouBAoyBAo2BAo6BAo+BApCB
+ApGBApKBApOBApSBApWBApaBApeBApiBApmBApqBApuBApyBAp2BAp6BAp+BAqCBAqGBAqKBAqOBAqSB
+AqWBAqaBAqeBAqiBAqmBAqqBAquBAqyBAq2BAq6BAq+BArCBArGBArKBArOBArSBArWBAraBAreBAriB
+ArmBArqBAruBAryBAr2BAr6BAr+BAsCBAsGBAsKBAsOBAsSBAsWBAsaBAseBAsiBAsmBAsqBAsuBAsyB
+As2BAs6BAs+BAtCBAtGBAtKBAtOBAtSBAtWBAtaBAteBAtiBAtmBAtqBAtuBAtyBAt2BAt6BAt+BAuCB
+AuGBAuKBAuOBAuSBAuWBAuaBAueBAuiBAumBAuqBAuuBAuyBAu2BAu6BAu+BAvCBAvGBAvKBAvOBAvSB
+AvWBAvaBAveBAviBAvmBAvqBAvuBAvyBAv2BAv6BAv+BAwCBAwGBAwKBAwOBAwSBAwWBAwaBAweBAwiB
+AwmBAwqBAwuBAwyBAw2BAw6BAw+BAxCBAxGBAxKBAxOBAxSBAxWBAxaBAxeBAxiBAxmBAxqBAxuBAxyB
+Ax2BAx6BAx+BAyCBAyGBAyKBAyOBAyQRASsRAhIRAR4SAAGIHhEBdxEBDhEBfREBhhA6EQIWEBcSAAGI
+vRIAAYi/EQJDEQEHEQFeEQFyEDgQiBEBbREBYhEBIxCDEgADDmcQkBEBDREBMREBrREBhBEBrxECIxEC
+DhEBihEBexEBpxIAAYgNEQIfEQGAEQGqEQFzEQIXEJERAYwSAAGIIREBJREBixD1EMsRAXASAAGIEBIA
+AYgTEQGwEQIkEKARAhwQwxAdEQF8EQGjEQIlEQGIEQGsEQIhEIYSAAGIGBCcEPQRASQSAAGHyxEBcRCr
+EQE2EQGSEQGJELMRAZERAYEQzBEBERDOEIEQXBIAAYgiE//////////9ENARATURAg8QlhEBNxCPEgAB
+iBQRAWsRAY0QzREBrhDEEQFcEQEnEQIgEQEqEgABh9YQBRIAAYgWEQIMEQEoEQEpEQEEEQFdEgABiAwQ
+pBEBEBEBHRIAAYfHEQIiEQGFEQIUEQGmEQEwEBMRAhsQyhEBpRCeEQGPEQGzELAQnRCjEQF0EgAElQcR
+AWERAYIRAbESAAGICxIAAYgbEQI/EQFgEQI+EgABiBERAhgQtRCyEQF+EQF4EQF5EKwRAh0SAAGIGREB
+XxIAAYfFEQFBEM8RAS4RAhoQlREBpBEBdhEBjhECExA5EIISAAGHxBECPRECFREBhxECGREBNBC0EQF/
+EgABiBcRAT4SAAGHwxEBgxCpEgABiBIRAWwQrRCv0gAOAEUATQyvgD6g0gAOAEUG8AyygQHsoNIADgBF
+BvAMtYEB7KDSADoAOwy3DLiiDLgAP15OU0lCT2JqZWN0RGF0YQAIABkAIgAnADEAOgA/AEQAUgBUAGYG
+vAbCBw0HFAcbBykHOwdXB2UHcQd9B4sHlgekB8AHzgfhB/MIDQgXCCQIJggpCCwILwgyCDQINwg5CDwI
+PwhCCEUIRwhJCEwITwhUCFcIYAhsCG4IcAh5CIMIhQiTCJwIpQiwCLcIyQjSCNsI5AjpCPgJCwkUCR8J
+IQkiCSsJMgk/CUUJTglQCcEJwwnFCccJyQnLCc0JzwnRCdMJ1QnXCdkJ2wndCd8J4QnjCeUJ5wnpCesJ
+7QnvCfEJ9An3CfoJ/QoACgMKBgoJCgwKDwoSChUKGAobCh4KIQokCicKKgotCjAKMwo2CjkKPAo/CkIK
+RQpICksKTgpbCmQKbApuCnAKcgqTCpsKrwq6CsgK0grfCuYK6ArqCu8K8Qr2CvgK+gr8CwkLFQsXCxoL
+HQskCyULMgtBC0MLRQtHC08LYQtqC28LgguPC5ELkwuVC6gLsQu2C8ELyQvSC9kL8QwADBEMHwwhDCMM
+JQwnDEQMVgxeDGUMbgx4DIQMhgyIDIoMjAyPDJAMkgynDLIMtAy2DLgMugzTDQgNFA0qDT8NTg1hDXMN
+fg2IDZYNqA21DcMNyA3KDcwNzg3QDdIN1A3WDdgN2g3cDd4N4w4DDhQOGw4iDisOLQ42DjgOOw5IDlEO
+Vg5dDmYOcg50DnYOfw6IDo0Oow6sDrUOwg7PDtgO4w7sDvYO/Q8JDxIPFA8WDyQPMw9AD0IPRA9GD2cP
+aQ9rD20Pbw9xD3MPfg+AD4sPnA+eD6APog+kD60Ptg+9D9QP5Q/nD+kP6w/tD/4QABACEAQQBhALEBQQ
+FhAbEB0QHxBIEFYQYxBlEGcQaBBqEGsQbRBvEHEQmhCkEK0QrxCxELMQtRC3ELkQuxC9EMoQ2RDmEOgQ
+6hDsEPUQ9xD8EP4RABEpESsRLREuETARMREzETURNxFYEVoRXBFeEWARYhFkEXkRghGJEZgRoBGpEa4R
+txHIEcoRzBHOEdAR7RHvEfER8xH1EfYR+BIREhMSFRIXEhkSGxIzEmgSahJsEm4ScBJyEnQSdhKQEqES
+oxKlEqcSqRLGEsgSyhLMEs4SzxLREuYS6BLqEuwS7hMHEzwTPhNAE0ITRBNGE0gTShNzE34TjxORE5MT
+lROXE6oTuxO9E78TwRPDE+AT4hPkE+YT6BPpE+sUBBRTFHAUghSUFKkUtxTAFMEUwxTFFMcUyRTLFM0U
+zxTRFNMU1RTWFNcU2hTdFN8U5BT1FPcU+RT7FQQVBhUPFREVQhVLFVEVWRVbFV0VXxVhFWMVZRVnFWkV
+chV/FYEVgxWFFZIVphWvFbEVvBXFFccV0BXSFdQV1hXYFgUWBxYJFgsWDRYPFhEWExYVFhcWIhZPFlEW
+UxZVFlcWWRZbFl0WXxZhFmsWmBaaFpwWnhagFqIWpBamFqgWqhazFrwWyRbdFuwW9RcCFxAXIRcjFyUX
+JxcpF1IXVBdWF1cXWRdaF1wXXhdgF3EXcxd2F3kXfBePF6AXohekF6YXqBfRF9MX1RfWF9gX2RfbF90X
+3xfsF+4X8BfzGAIYExgVGBcYGRgbGDgYOhg8GD4YQBhBGEMYXBiRGJMYlRiXGJkYmxidGJ8YvBjJGNoY
+3BjeGOAY4hjoGPkY+xj9GP8ZARlAGU0ZZhlzGYkZlxmhGa8ZyBnVGd8Z8RoFGg8aGxodGh8aIRojGiUa
+JxosGi4aMBoyGjQaNho4GlMaZRptGnYaeBp9GpoapRq6GsYayBrKGswazhrXGtka3BreGw8bHhsoGzwb
+VRttG28bcRtzG3Ubdxt5G3obfBt9G38biBuKG40bjxuYG5obqRurG60brxuxG7MbtRu3G9Qb1hvYG9ob
+3BvdG98b9xwYHCwcOBw6HDwcPhxAHEIcRxxJHLMcxBzGHM8c0RzUHOkc8Rz+HQodGB0aHRwdHh0gHSId
+KR02HUMdSx1NHVkdYh1nHXwdfh2AHYIdhB2XHaQdph2pHbIdux3NHdYd4R3tHgoeDB4OHhAeEh4THhUe
+LR5OHlAeUh5UHlYeWB5aHmMegB6CHoQehh6IHokeix6kHsUexx7JHssezR7PHtEfCB8lHycfKR8rHy0f
+Lh8wH0kffh+AH4IfhB+GH4gfih+MH58fvB++H8Afwh/EH8Ufxx/gIAEgAyAFIAcgCSALIA0gdCCNIJYg
+nSC1IL4gwCDHIMkgyyDNIOYg8yD9IP8hASEDIQUhByEJIRIhFCEWIR8hISEuITAhMiE0ITYhOCE6IVch
+WSFbIV0hXyFgIWIheiGbIZ0hnyGhIaMhpSGnIhAiLSIvIjEiMyI1IjYiOCJRInIidCJ2IngieiJ8In4i
+2CL1Ivci+SL7Iv0i/iMAIxkjTiNQI1IjVCNWI1gjWiNcI38jnCOeI6AjoiOkI6UjpyPAI+Ej4yPlI+cj
+6SPrI+0kLiQ0JD0kQiRQJGkkayRtJG8kcSRzJHUkfiSAJIIkiSSeJKAkoiSkJKYkqCSxJLMkviTAJMIk
+xCTGJMgk5STnJOkk6yTtJO4k8CUlJSclKSUrJS0lLyUxJTMlTiVrJW0lbyVxJXMldCV2JY8lsCWyJbQl
+tiW4JbolvCZpJoYmiCaKJowmjiaPJpEmqSbKJswmzibQJtIm1CbWJ3InjyeRJ5MnlSeXJ5gnmieyJ9Mn
+1SfXJ9kn2yfdJ98oFigfKCgoMSg8KFQoXyhpKHIodyiKKJYooyilKKcoqSjKKMwozijQKNIo1CjWKNoo
+3CjhKPIo9Cj2KPgo+ikLKQ0pDykRKRMpNCk2KTgpOik8KT4pQClNKV4pYCliKWQpZimDKYUphymJKYsp
+jSmPKaApoimlKagpqym1KcQp1SnXKdkp2yndKf4qACoCKgQqBioIKgoqHyoxKkIqRCpGKkgqSiprKm0q
+bypxKnMqdSp3KoQqhiqUKqUqpyqpKqsqrSrOKtAq0irXKtkq2yrdKt8q9CsNKx4rICsiKyQrJis6K0sr
+TStPK1ErUyt0K3YreCt6K3wrfiuAK4wrmSumK6grqiutK84r0CvTK9Yr2CvaK9wr4SvjK+kr+iv8K/4s
+ASwELCUsJywqLC0sLywxLDMsPCw+LEksVixYLFssXix/LIEshCyHLIksiyyNLJIslCyaLKssrSyvLLIs
+tSzWLNgs2yzdLN8s4SzjLO8tCC0ZLRstHS0gLSMtRC1GLUktSy1NLU8tUi1fLWEtZC1nLXAtei2LLY0t
+jy2RLZMtpC2mLagtqi2tLcAt0S3TLdUt2C3bLfgt+y39LgAuAy4GLgcuCi4fLiEuIy4mLikuQy54Lnou
+fS6ALoMuhi6ILosukC6ZLqMutC62Lrkuwy7MLs4u1y7ZLvEvAi8ELwYvCC8LLxovKy8tLy8vMi81L1Iv
+VS9XL1ovXS9eL2Evey+wL7IvtS+4L7svvi/AL8MvzC/VL9cv4C/iL/QwBTAHMAkwCzAOMC4wPzBBMEMw
+RTBIMFIwYzBlMGcwajBtMI4wkDCTMJYwmDCaMJwwqDCrMLgwyTDLMM0w0DDTMPAw8zD1MPgw+zD+MP8x
+AjEaMU8xWDFaMVwxXzFiMWUxZzFqMW8xeDF6MY0xnjGgMaIxpDGmMbcxuTG7Mb0xwDHMMd0x3zHiMeQx
+5zI2MlgyZTJ6MocyoTK9Mtgy5DMDMxIzHjMhMyQzKTMsMy8zMDMzMzwzRTNIM0kzTDNPM1IzWzOEM44z
+mDOiM7AzszO2M7kzuzO+M8EzxDPHM8ozzTPYM/Ez/TQANAM0BjQJNAw0NTQ4NDs0PjRBNEQ0RzRKNE00
+VzRgNGk0fTSSNJU0mDSbNJ400zTfNOg0+zUINRQ1IjUlNSg1KzUuNTA1MzU2NUk1TDVPNVI1VTVYNW81
+eDWBNY81mDWaNaE1pDWnNao10zXiNe819zYCNhE2HDYnNjQ2NTY4Njs2RDZHNlA2WTZaNl02ejZ/NoI2
+hTaINoo2jTaSNp82oTatNsI2xDbGNsk2yzbdNuY28TcFNyI3JzcpNyw3LjcxNzM3QDdCN0U3TjdTN2E3
+ijeLN443kTeaN503pjenN6o3xzfKN8030DfSN9U33Tf6N/w3/zgBOAQ4BjgvODA4Mzg2OD84QjhLOEw4
+TzhsOG84cjh1OHc4ejiDOJg4mjidOKA4ojiuOM840TjUONc42jjbON047jjwOPk4+zkQORI5FDkXORk5
+MjlHOUk5TDlPOVE5WzloOWo5bzl4OYM5jjmfOaE5ozmmOak5zjnQOdM51jnYOdo53DneOec56TnvOgA6
+AjoEOgc6CjovOjE6NDo2Ojg6Ojo8OkU6XjprOm06cDpzOpQ6ljqZOpw6njqgOqI6qDqqOrE6wjrEOsY6
+yTrMOuk67DruOvE69Dr1Ovg7EjtHO0k7TDtPO1I7VTtXO1o7YTtqO2w7dTt3O4w7nTufO6E7ozumO7I7
+wzvFO8c7yjvNO+478DvzO/Y7+Dv6O/w8CzwNPBk8KjwsPC48MDwzPEg8WTxbPF08XzxiPH88kDySPJQ8
+ljyZPLE8wjzEPMY8yDzKPNs83TzfPOI85T0GPQg9Cz0OPRA9Ej0UPSY9KT08PU09Tz1RPVQ9Vz14PXo9
+fT2APYI9hD2GPZg9mj2tPb49wD3CPcU9yD3lPeg96j3tPfA98T30Pgw+QT5DPkY+ST5MPk8+UT5UPls+
+ZD5mPm8+cT6GPpc+mT6bPp0+oD6sPrk+uz6+PsE+4j7kPuc+6j7sPu4+8D71Pvc+/T8GPwlABkAJQAxA
+DkAQQBJAFEAWQBlAG0AdQB9AIUAkQCdAKUArQC5AMUA0QDdAOkA8QD5AQEBCQERARkBIQEpATUBQQFJA
+VUBXQFlAW0BdQF9AYUBjQGZAaEBrQG5AcUBzQHZAeEB7QH5AgECDQIZAiECKQI1AkECSQJVAl0CZQJxA
+n0ChQKNApUCnQKpArECvQLJAtEC2QLhAu0C+QMBAwkDEQMZAyUDMQM5A0UDUQNdA2UDcQN9A4UDkQOZA
+6EDqQOxA70DxQPRA9kD5QPtA/UD/QQFBA0EFQQdBCkENQRBBE0EVQRdBGkEdQSBBIkElQSdBKUEsQS5B
+MEEyQTRBPUE/QUxBT0FSQVVBWEFbQV5BZ0FpQXRBd0F6QX1BgEGDQYxBjkGRQZRBrEG1Qb5ByUHqQfRB
+90H6Qf1CAEIDQgZCD0IoQjVCPkJJQlRCeUJ8Qn9CgkKFQohCi0KUQqxCtUK3QrpCvULTQuxC9UL+QwtD
+IkMrQy1DMkM0QzZDX0NhQ2NDZkNoQ2pDbENvQ3JDg0OFQ4hDi0OOQ5JDm0OdQ7ZDuEO7Q75DwUPEQ8ZD
+yUPMQ89D0kPVQ9hEAUQDRAVEBkQIRAlEC0QNRA9EOEQ6RD1EQERCRERERkRIREtEVERlRGdEakRtRHBE
+eUR7RIREhkSHRJlEwkTERMZEx0TJRMpEzETORNBE+UT7RP1E/kUARQFFA0UFRQdFMEUyRTRFNUU3RThF
+OkU8RT5FS0V0RXZFeEV6RXxFfkWARYNFhkWPRZFFmEWhRaNFtkW5RbtFvUXARcNFxkXJRctFzUX2RfhF
++kX7Rf1F/kYARgJGBEYtRi9GMUYyRjRGNUY3RjlGO0ZKRlNGXEZeRmlGbEZvRnJGdUZ4RqFGo0alRqhG
+qkasRq5GsUa0RrlGwkbERtVG2EbaRt1G30biRuVG50bpRxJHFEcWRxdHGUcaRxxHHkcgR0lHS0dNR1BH
+UkdUR1ZHWUdcR4VHh0eKR41Hj0eRR5NHlkeZR55Hp0epR6xHr0e7R8RHxkfJSAhIC0gNSBBIE0gWSBlI
+G0geSCFIJEgmSClILEhHSF5IZ0hpSHJIe0iASIlIjEmJSYxJj0mRSZNJlkmYSZpJnEmeSaBJokmkSadJ
+qUmrSa1JsEmySbVJt0m6SbxJvknAScJJxEnGSchJyknNSc9J0UnUSddJ2UnbSd1J30nhSeNJ5UnnSepJ
+7EnuSfBJ8kn0SfdJ+kn8Sf5KAUoDSgVKB0oJSgtKDUoPShFKE0oVShdKGUobSh1KIEoiSiVKKEoqSixK
+LkoxSjRKNko4SjpKPEo+SkFKQ0pGSklKS0pNSk9KUkpUSldKWUpbSl1KX0piSmRKZ0ppSmtKbUpvSnFK
+c0p1SndKeUp8Sn5KgEqDSoVKiEqLSo5KkUqTSpVKl0qZSpxKn0qhSqNKpUquSrFLsEuzS7ZLuEu6S7xL
+vkvAS8NLxUvHS8lLy0vNS9BL00vWS9lL20veS+BL40vmS+hL6kvsS+5L8EvyS/RL90v5S/xL/0wBTANM
+BUwHTAlMC0wNTA9MEkwUTBdMGkwdTCBMIkwlTChMK0wtTDBMMkw0TDZMOUw8TD5MQExDTEVMSExLTE1M
+T0xRTFNMVkxYTFtMXkxgTGJMZExnTGpMbUxvTHFMc0x2THhMekx9TIBMg0yFTIhMi0yOTJBMkkyUTJdM
+mUybTJ1MoEyiTKVMp0ypTKtMrUyvTLJMtEy2TLlMvEy/TMFMw0zFTMhMy0zOTNFM00zVTNhM2kzcTN5M
+4EzpTOxN603uTfFN9E33TfpN/U4ATgNOBk4JTgxOD04SThVOGE4bTh5OIU4kTidOKk4tTjBOM042TjlO
+PE4/TkJORU5ITktOTk5RTlROV05aTl1OYE5jTmZOaU5sTm9Ock51TnhOe05+ToFOhE6HTopOjU6QTpNO
+lk6ZTpxOn06iTqVOqE6rTq5OsU6zTrZOuU68Tr9Owk7FTshOy07OTtFO1E7XTtpO3U7gTuNO5k7pTuxO
+707yTvVO+E77Tv5PAU8ETwdPCk8NTxBPE08WTxlPHE8fTyJPJU8oTytPLk8xTzRPN086Tz1PQE9DT0ZP
+SU9MT09PUk9VT1hPW09eT2FPZE97T4pPrk/jT/lQEFAoUEZQZ1DgUO1Q9FD7UQ1RJFE5UU9Re1GSUfpS
+FVIhUjxSWVKeUqdTE1OIU6NTvVPjU/1UFFQxVD9UTFRnVJZUx1TvVQFVFVUoVUJVTlVlVXBVfFWTVaxV
++1YPVs5W51cBVx5XKldzV39Xi1ejV7pXxlhCWGtYlFigWMFY2ljzWRRZHllHWW5ZhFmRWalZvlnKWd5a
+WVqIWp1atFrHWuBa81sGWxpbklutW/JcBFwvXHhckVylXPhdBF2/Xd1eh16gXr9e1l+EX5BfnF+6X+Ff
+7F/5YBNgJWA5YFNgimCiYLdgw2DxYWhhe2GEYYdhiGGRYZRhlWGeYaFjDmMRYxRjF2MZYxtjHWMfYyJj
+JGMmYyljK2MtYy9jMmM0YzZjOWM8Yz5jQGNDY0ZjSWNMY09jUWNTY1VjWGNbY11jYGNiY2RjZmNoY2pj
+bGNuY3FjdGN3Y3ljfGN+Y4Fjg2OFY4djiWOLY41jkGOTY5VjmGOaY51jn2OiY6Rjp2OqY61jsGOyY7Vj
+t2O6Y71jv2PCY8Vjx2PKY8xjzmPQY9Jj1GPWY9lj3GPeY+Fj42PmY+hj62PuY/Fj82P1Y/dj+WP8Y/5k
+AGQDZAVkCGQLZA1kD2QRZBRkF2QZZBtkHWQfZCFkJGQnZClkK2QtZDBkM2Q2ZDlkPGQ/ZEJkRWRHZEpk
+TWRQZFNkVWRYZFpkXGRfZGFkY2RmZGhka2RtZHBkc2R1ZHdkeWR7ZH1kf2SBZINkhmSIZIpkjWSQZJNk
+lmSYZJpknWSfZKJkpWSoZKpkrGSvZLFktGS2ZLhku2S+ZMFkw2TFZMdkyWTLZNRk12ZEZkdmSmZNZlBm
+U2ZWZllmXGZfZmJmZWZoZmtmbmZxZnRmd2Z6Zn1mgGaDZoZmiWaMZo9mkmaVZphmm2aeZqFmpGanZqpm
+rWawZrNmtma5Zrxmv2bCZsVmyGbLZs5m0WbUZtdm2mbdZuBm42bmZulm7GbvZvJm9Wb4Zvtm/mcBZwRn
+B2cKZw1nEGcTZxZnGWccZx9nImclZyhnK2cuZzFnNGc3ZzpnPWdAZ0NnRmdJZ0xnT2dSZ1VnWGdbZ15n
+YWdkZ2dnamdtZ3Bnc2d2Z3lnfGd/Z4JnhWeIZ4tnjmeRZ5Rnl2eaZ51noGejZ6ZnqWesZ69nsme1Z7hn
+u2e+Z8FnxGfHZ8pnzWfQZ9Nn1mfZZ9xn32fiZ+Vn6GfrZ+5n8Wf0Z/dn+mf9aABoA2gGaAloDGgPaBJo
+FWgYaBtoHmghaCRoJ2gqaC1oMGgzaDZoOWg8aD9oQmhFaEhoS2hOaFFoVGhXaFpoXWhgaGNoZmhpaGxo
+cWh0aHdoemh9aH9ogmiEaIlojmiRaJRol2iaaJxonmihaKRop2ipaK5osGizaLZouWi8aL9owmjFaMho
+y2jOaNNo1mjZaNxo32jiaORo52jsaO9o8mj0aPZo+Wj+aQNpBmkJaQtpDmkQaRJpFWkYaRtpHmkhaSRp
+JmkraS1pL2kyaTdpOmk8aT9pQmlFaUdpSmlNaU9pUmlUaVZpWGldaWZpaGlraW5pcGlzaXVpeml9aYBp
+gmmFaYdpimmNaZBpk2mYaZppn2miaaVpqGmraa5ps2m1abhpu2nAacNpxmnJacxpz2nRadRp1mnZadtp
+3mnhaeNp5Wnnaepp72nyafVp+Gn9agJqBWoIagtqEGoTahVqF2oaah1qIGoiaiVqKmotajJqNWo3ajpq
+PWo/akJqRWpIaktqTWpPalRqV2paal1qYGpjamVqaGptanBqdWp4anpqf2qCaoRqhmqPapFqkmqbap5q
+n2qoaqtqrGq1aroAAAAAAAACAgAAAAAAAAy5AAAAAAAAAAAAAAAAAABqyQ</bytes>
+		</object>
+	</data>
+</archive>
diff --git a/hw/xquartz/bundle/English.lproj/main.nib/info.nib b/hw/xquartz/bundle/English.lproj/main.nib/info.nib
deleted file mode 100644
index 88bc626..0000000
--- a/hw/xquartz/bundle/English.lproj/main.nib/info.nib
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>IBFramework Version</key>
-	<string>588</string>
-	<key>IBOpenObjects</key>
-	<array>
-		<integer>244</integer>
-		<integer>29</integer>
-		<integer>423</integer>
-	</array>
-	<key>IBSystem Version</key>
-	<string>9A356</string>
-	<key>targetFramework</key>
-	<string>IBCocoaFramework</string>
-</dict>
-</plist>
diff --git a/hw/xquartz/bundle/English.lproj/main.nib/keyedobjects.nib b/hw/xquartz/bundle/English.lproj/main.nib/keyedobjects.nib
index 8b31450..194f4df 100644
Binary files a/hw/xquartz/bundle/English.lproj/main.nib/keyedobjects.nib and b/hw/xquartz/bundle/English.lproj/main.nib/keyedobjects.nib differ
commit bc72ef3a159efd67067322c043bba444869dc356
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Wed Jan 30 10:39:54 2008 +1030

    xkb: don't update LEDs if they don't exist. (Bug #13961)
    
    In some weird cases we call this function when there is no SrvLedInfo on the
    device. And it turns out null-pointer dereferences are bad.
    
    X.Org Bug 13961 <http://bugs.freedesktop.org/show_bug.cgi?id=13961>
    (cherry picked from commit d954f9c80348de294602d931d387e5cd1ef4b9a5)

diff --git a/xkb/xkbLEDs.c b/xkb/xkbLEDs.c
index d607d90..d28973c 100644
--- a/xkb/xkbLEDs.c
+++ b/xkb/xkbLEDs.c
@@ -63,6 +63,9 @@ XkbSrvLedInfoPtr	sli;
 
     sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
 
+    if (!sli)
+        return update;
+
     if (state_changes&(XkbModifierStateMask|XkbGroupStateMask))
 	update|= sli->usesEffective;
     if (state_changes&(XkbModifierBaseMask|XkbGroupBaseMask))
commit e98027c3ac7195fec665ef393d980b02870ca1b8
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Tue Dec 18 13:57:07 2007 +1030

    dix: set the correct number of valuators in valuator events.
    
    (first_valuator + num_valuators) must never be larger than the number of axes,
    otherwise DIX freaks out. And from looking at libXI, anything larger than 6 is
    wrong too.
    (cherry picked from commit 9f6ae61ad12cc2813d04405458e1ca5aed8a539e)

diff --git a/dix/getevents.c b/dix/getevents.c
index 12d8189..b7ba69b 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -344,7 +344,7 @@ getValuatorEvents(xEvent *events, DeviceIntPtr pDev, int first_valuator,
     for (i = first_valuator; i < final_valuator; i += 6, xv++, events++) {
         xv->type = DeviceValuator;
         xv->first_valuator = i;
-        xv->num_valuators = num_valuators;
+        xv->num_valuators = ((num_valuators - i) > 6) ? 6 : (num_valuators - i);
         xv->deviceid = pDev->id;
         switch (final_valuator - i) {
         case 6:
commit b6aa41b56b76fbd317342a01d3ef43adbfd8fccc
Author: Jeremy Huddleston <jeremy at tifa.local>
Date:   Mon Jan 28 12:18:43 2008 -0800

    Rootless: RootlessEnsureFrame: Added check for !IsRoot
    This was causing an issue with Apple-DRI and was reported here:
    http://trac.macosforge.org/projects/xquartz/ticket/51
    (cherry picked from commit 116800279d2ec783c63f43d3902627edde6a4cff)

diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index 82f54d6..bf0380f 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -473,7 +473,7 @@ RootlessEnsureFrame(WindowPtr pWin)
     if (WINREC(pWin) != NULL)
         return WINREC(pWin);
 
-    if (!IsTopLevel(pWin))
+    if (!IsTopLevel(pWin) && !IsRoot(pWin))
         return NULL;
 
     if (pWin->drawable.class != InputOutput)
commit b6d4cdf64f43ae805beada6122c8be2ed138742c
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri Jan 18 14:41:20 2008 -0500

    CVE-2007-6429: Don't spuriously reject <8bpp shm pixmaps.
    
    Move size validation after depth validation, and only validate size if
    the bpp of the pixmap format is > 8.  If bpp < 8 then we're already
    protected from overflow by the width and height checks.
    (cherry picked from commit e9fa7c1c88a8130a48f772c92b186b8b777986b5)

diff --git a/Xext/shm.c b/Xext/shm.c
index 5633be9..6f99e90 100644
--- a/Xext/shm.c
+++ b/Xext/shm.c
@@ -737,14 +737,6 @@ ProcPanoramiXShmCreatePixmap(
     }
     if (width > 32767 || height > 32767)
         return BadAlloc;
-    size = PixmapBytePad(width, depth) * height;
-    if (sizeof(size) == 4) {
-        if (size < width * height)
-            return BadAlloc;
-        /* thankfully, offset is unsigned */
-        if (stuff->offset + size < size)
-            return BadAlloc;
-    }
 
     if (stuff->depth != 1)
     {
@@ -755,7 +747,17 @@ ProcPanoramiXShmCreatePixmap(
 	client->errorValue = stuff->depth;
         return BadValue;
     }
+
 CreatePmap:
+    size = PixmapBytePad(width, depth) * height;
+    if (sizeof(size) == 4 && BitsPerPixel(depth) > 8) {
+        if (size < width * height)
+            return BadAlloc;
+        /* thankfully, offset is unsigned */
+        if (stuff->offset + size < size)
+            return BadAlloc;
+    }
+
     VERIFY_SHMSIZE(shmdesc, stuff->offset, size, client);
 
     if(!(newPix = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes))))
@@ -1080,14 +1082,6 @@ ProcShmCreatePixmap(client)
     }
     if (width > 32767 || height > 32767)
 	return BadAlloc;
-    size = PixmapBytePad(width, depth) * height;
-    if (sizeof(size) == 4) {
-	if (size < width * height)
-	    return BadAlloc;
-	/* thankfully, offset is unsigned */
-	if (stuff->offset + size < size)
-	    return BadAlloc;
-    }
 
     if (stuff->depth != 1)
     {
@@ -1098,7 +1092,17 @@ ProcShmCreatePixmap(client)
 	client->errorValue = stuff->depth;
         return BadValue;
     }
+
 CreatePmap:
+    size = PixmapBytePad(width, depth) * height;
+    if (sizeof(size) == 4 && BitsPerPixel(depth) > 8) {
+	if (size < width * height)
+	    return BadAlloc;
+	/* thankfully, offset is unsigned */
+	if (stuff->offset + size < size)
+	    return BadAlloc;
+    }
+
     VERIFY_SHMSIZE(shmdesc, stuff->offset, size, client);
     pMap = (*shmFuncs[pDraw->pScreen->myNum]->CreatePixmap)(
 			    pDraw->pScreen, stuff->width,
commit d6e234f96d5fbbbbc5ad4f3a4c2f878d78570d00
Merge: 7429379... 19b95cd...
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Thu Jan 17 09:48:14 2008 -0800

    Merge branch 'server-1.4-branch' into xorg-server-1.4-apple

commit 19b95cdd1d14a1e7d1abba1880ab023c96f19bf5
Author: Matthieu Herrb <matthieu at bluenote.herrb.com>
Date:   Thu Jan 17 17:03:39 2008 +0100

    Fix for CVE-2007-5958 - File existence disclosure.

diff --git a/Xext/security.c b/Xext/security.c
index ba057de..e9d48c9 100644
--- a/Xext/security.c
+++ b/Xext/security.c
@@ -1563,7 +1563,7 @@ SecurityLoadPropertyAccessList(void)
     if (!SecurityPolicyFile)
 	return;
 
-    f = fopen(SecurityPolicyFile, "r");
+    f = Fopen(SecurityPolicyFile, "r");
     if (!f)
     {
 	ErrorF("error opening security policy file %s\n",
@@ -1646,7 +1646,7 @@ SecurityLoadPropertyAccessList(void)
     }
 #endif /* PROPDEBUG */
 
-    fclose(f);
+    Fclose(f);
 } /* SecurityLoadPropertyAccessList */
 
 
commit f09b8007e7f6e60e0b9c9665ec632b578ae08b6f
Author: Matthieu Herrb <matthieu at bluenote.herrb.com>
Date:   Thu Jan 17 15:29:06 2008 +0100

    Fix for CVE-2008-0006 - PCF Font parser buffer overflow.

diff --git a/dix/dixfonts.c b/dix/dixfonts.c
index c21b3ec..7bb2404 100644
--- a/dix/dixfonts.c
+++ b/dix/dixfonts.c
@@ -325,6 +325,13 @@ doOpenFont(ClientPtr client, OFclosurePtr c)
 	err = BadFontName;
 	goto bail;
     }
+    /* check values for firstCol, lastCol, firstRow, and lastRow */
+    if (pfont->info.firstCol > pfont->info.lastCol ||
+       pfont->info.firstRow > pfont->info.lastRow ||
+       pfont->info.lastCol - pfont->info.firstCol > 255) {
+       err = AllocError;
+       goto bail;
+    }
     if (!pfont->fpe)
 	pfont->fpe = fpe;
     pfont->refcnt++;
commit 8b14f7b74284900b95a319ec80c4333e63af2296
Author: Matthieu Herrb <matthieu at bluenote.herrb.com>
Date:   Thu Jan 17 15:28:42 2008 +0100

    Fix for CVE-2007-6429 - MIT-SHM and EVI extensions integer overflows.

diff --git a/Xext/EVI.c b/Xext/EVI.c
index 8fe3481..13bd32a 100644
--- a/Xext/EVI.c
+++ b/Xext/EVI.c
@@ -34,6 +34,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include <X11/extensions/XEVIstr.h>
 #include "EVIstruct.h"
 #include "modinit.h"
+#include "scrnintstr.h"
 
 #if 0
 static unsigned char XEVIReqCode = 0;
@@ -87,10 +88,22 @@ ProcEVIGetVisualInfo(ClientPtr client)
 {
     REQUEST(xEVIGetVisualInfoReq);
     xEVIGetVisualInfoReply rep;
-    int n, n_conflict, n_info, sz_info, sz_conflict;
+    int i, n, n_conflict, n_info, sz_info, sz_conflict;
     VisualID32 *conflict;
+    unsigned int total_visuals = 0;
     xExtendedVisualInfo *eviInfo;
     int status;
+
+    /*
+     * do this first, otherwise REQUEST_FIXED_SIZE can overflow.  we assume
+     * here that you don't have more than 2^32 visuals over all your screens;
+     * this seems like a safe assumption.
+     */
+    for (i = 0; i < screenInfo.numScreens; i++)
+	total_visuals += screenInfo.screens[i]->numVisuals;
+    if (stuff->n_visual > total_visuals)
+	return BadValue;
+
     REQUEST_FIXED_SIZE(xEVIGetVisualInfoReq, stuff->n_visual * sz_VisualID32);
     status = eviPriv->getVisualInfo((VisualID32 *)&stuff[1], (int)stuff->n_visual,
 		&eviInfo, &n_info, &conflict, &n_conflict);
diff --git a/Xext/sampleEVI.c b/Xext/sampleEVI.c
index 7508aa7..b871bfd 100644
--- a/Xext/sampleEVI.c
+++ b/Xext/sampleEVI.c
@@ -34,6 +34,13 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include <X11/extensions/XEVIstr.h>
 #include "EVIstruct.h"
 #include "scrnintstr.h"
+
+#if HAVE_STDINT_H
+#include <stdint.h>
+#elif !defined(UINT32_MAX)
+#define UINT32_MAX 0xffffffffU
+#endif
+
 static int sampleGetVisualInfo(
     VisualID32 *visual,
     int n_visual,
@@ -42,24 +49,36 @@ static int sampleGetVisualInfo(
     VisualID32 **conflict_rn,
     int *n_conflict_rn)
 {
-    int max_sz_evi = n_visual * sz_xExtendedVisualInfo * screenInfo.numScreens;
+    unsigned int max_sz_evi;
     VisualID32 *temp_conflict;
     xExtendedVisualInfo *evi;
-    int max_visuals = 0, max_sz_conflict, sz_conflict = 0;
+    unsigned int max_visuals = 0, max_sz_conflict, sz_conflict = 0;
     register int visualI, scrI, sz_evi = 0, conflictI, n_conflict;
-    *evi_rn = evi = (xExtendedVisualInfo *)xalloc(max_sz_evi);
-    if (!*evi_rn)
-         return BadAlloc;
+
+    if (n_visual > UINT32_MAX/(sz_xExtendedVisualInfo * screenInfo.numScreens))
+	return BadAlloc;
+    max_sz_evi = n_visual * sz_xExtendedVisualInfo * screenInfo.numScreens;
+    
     for (scrI = 0; scrI < screenInfo.numScreens; scrI++) {
         if (screenInfo.screens[scrI]->numVisuals > max_visuals)
             max_visuals = screenInfo.screens[scrI]->numVisuals;
     }
+
+    if (n_visual > UINT32_MAX/(sz_VisualID32 * screenInfo.numScreens 
+			       * max_visuals)) 
+	return BadAlloc;
     max_sz_conflict = n_visual * sz_VisualID32 * screenInfo.numScreens * max_visuals;
+
+    *evi_rn = evi = (xExtendedVisualInfo *)xalloc(max_sz_evi);
+    if (!*evi_rn)
+         return BadAlloc;
+
     temp_conflict = (VisualID32 *)xalloc(max_sz_conflict);
     if (!temp_conflict) {
         xfree(*evi_rn);
         return BadAlloc;
     }
+
     for (scrI = 0; scrI < screenInfo.numScreens; scrI++) {
         for (visualI = 0; visualI < n_visual; visualI++) {
 	    evi[sz_evi].core_visual_id = visual[visualI];
diff --git a/Xext/shm.c b/Xext/shm.c
index ac587be..5633be9 100644
--- a/Xext/shm.c
+++ b/Xext/shm.c
@@ -711,6 +711,8 @@ ProcPanoramiXShmCreatePixmap(
     int i, j, result, rc;
     ShmDescPtr shmdesc;
     REQUEST(xShmCreatePixmapReq);
+    unsigned int width, height, depth;
+    unsigned long size;
     PanoramiXRes *newPix;
 
     REQUEST_SIZE_MATCH(xShmCreatePixmapReq);
@@ -724,11 +726,26 @@ ProcPanoramiXShmCreatePixmap(
 	return rc;
 
     VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client);
-    if (!stuff->width || !stuff->height)
+
+    width = stuff->width;
+    height = stuff->height;
+    depth = stuff->depth;
+    if (!width || !height || !depth)
     {
 	client->errorValue = 0;
         return BadValue;
     }
+    if (width > 32767 || height > 32767)
+        return BadAlloc;
+    size = PixmapBytePad(width, depth) * height;
+    if (sizeof(size) == 4) {
+        if (size < width * height)
+            return BadAlloc;
+        /* thankfully, offset is unsigned */
+        if (stuff->offset + size < size)
+            return BadAlloc;
+    }
+
     if (stuff->depth != 1)
     {
         pDepth = pDraw->pScreen->allowedDepths;
@@ -739,9 +756,7 @@ ProcPanoramiXShmCreatePixmap(
         return BadValue;
     }
 CreatePmap:
-    VERIFY_SHMSIZE(shmdesc, stuff->offset,
-		   PixmapBytePad(stuff->width, stuff->depth) * stuff->height,
-		   client);
+    VERIFY_SHMSIZE(shmdesc, stuff->offset, size, client);
 
     if(!(newPix = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes))))
 	return BadAlloc;
@@ -1040,6 +1055,8 @@ ProcShmCreatePixmap(client)
     register int i, rc;
     ShmDescPtr shmdesc;
     REQUEST(xShmCreatePixmapReq);
+    unsigned int width, height, depth;
+    unsigned long size;
 
     REQUEST_SIZE_MATCH(xShmCreatePixmapReq);
     client->errorValue = stuff->pid;
@@ -1052,11 +1069,26 @@ ProcShmCreatePixmap(client)
 	return rc;
 
     VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client);
-    if (!stuff->width || !stuff->height)
+    
+    width = stuff->width;
+    height = stuff->height;
+    depth = stuff->depth;
+    if (!width || !height || !depth)
     {
 	client->errorValue = 0;
         return BadValue;
     }
+    if (width > 32767 || height > 32767)
+	return BadAlloc;
+    size = PixmapBytePad(width, depth) * height;
+    if (sizeof(size) == 4) {
+	if (size < width * height)
+	    return BadAlloc;
+	/* thankfully, offset is unsigned */
+	if (stuff->offset + size < size)
+	    return BadAlloc;
+    }
+
     if (stuff->depth != 1)
     {
         pDepth = pDraw->pScreen->allowedDepths;
@@ -1067,9 +1099,7 @@ ProcShmCreatePixmap(client)
         return BadValue;
     }
 CreatePmap:
-    VERIFY_SHMSIZE(shmdesc, stuff->offset,
-		   PixmapBytePad(stuff->width, stuff->depth) * stuff->height,
-		   client);
+    VERIFY_SHMSIZE(shmdesc, stuff->offset, size, client);
     pMap = (*shmFuncs[pDraw->pScreen->myNum]->CreatePixmap)(
 			    pDraw->pScreen, stuff->width,
 			    stuff->height, stuff->depth,
commit d244c8272e0ac47c41a9416e37293903b842a78b
Author: Matthieu Herrb <matthieu at bluenote.herrb.com>
Date:   Thu Jan 17 15:27:34 2008 +0100

    Fix for CVE-2007-6427 - Xinput extension memory corruption.

diff --git a/Xi/chgfctl.c b/Xi/chgfctl.c
index 2e0e13c..235d659 100644
--- a/Xi/chgfctl.c
+++ b/Xi/chgfctl.c
@@ -327,18 +327,13 @@ ChangeStringFeedback(ClientPtr client, DeviceIntPtr dev,
 		     xStringFeedbackCtl * f)
 {
     char n;
-    long *p;
     int i, j;
     KeySym *syms, *sup_syms;
 
     syms = (KeySym *) (f + 1);
     if (client->swapped) {
 	swaps(&f->length, n);	/* swapped num_keysyms in calling proc */
-	p = (long *)(syms);
-	for (i = 0; i < f->num_keysyms; i++) {
-	    swapl(p, n);
-	    p++;
-	}
+	SwapLongs((CARD32 *) syms, f->num_keysyms);
     }
 
     if (f->num_keysyms > s->ctrl.max_symbols) {
diff --git a/Xi/chgkmap.c b/Xi/chgkmap.c
index eac520f..f8f85bc 100644
--- a/Xi/chgkmap.c
+++ b/Xi/chgkmap.c
@@ -79,18 +79,14 @@ int
 SProcXChangeDeviceKeyMapping(ClientPtr client)
 {
     char n;
-    long *p;
-    int i, count;
+    unsigned int count;
 
     REQUEST(xChangeDeviceKeyMappingReq);
     swaps(&stuff->length, n);
     REQUEST_AT_LEAST_SIZE(xChangeDeviceKeyMappingReq);
-    p = (long *)&stuff[1];
     count = stuff->keyCodes * stuff->keySymsPerKeyCode;
-    for (i = 0; i < count; i++) {
-	swapl(p, n);
-	p++;
-    }
+    REQUEST_FIXED_SIZE(xChangeDeviceKeyMappingReq, count * sizeof(CARD32));
+    SwapLongs((CARD32 *) (&stuff[1]), count);
     return (ProcXChangeDeviceKeyMapping(client));
 }
 
@@ -106,10 +102,13 @@ ProcXChangeDeviceKeyMapping(ClientPtr client)
     int ret;
     unsigned len;
     DeviceIntPtr dev;
+    unsigned int count;
 
     REQUEST(xChangeDeviceKeyMappingReq);
     REQUEST_AT_LEAST_SIZE(xChangeDeviceKeyMappingReq);
 
+    count = stuff->keyCodes * stuff->keySymsPerKeyCode;
+    REQUEST_FIXED_SIZE(xChangeDeviceKeyMappingReq, count * sizeof(CARD32));
     dev = LookupDeviceIntRec(stuff->deviceid);
     if (dev == NULL) {
 	SendErrorToClient(client, IReqCode, X_ChangeDeviceKeyMapping, 0,
diff --git a/Xi/chgprop.c b/Xi/chgprop.c
index 59a93c6..21bda5b 100644
--- a/Xi/chgprop.c
+++ b/Xi/chgprop.c
@@ -81,19 +81,15 @@ int
 SProcXChangeDeviceDontPropagateList(ClientPtr client)
 {
     char n;
-    long *p;
-    int i;
 
     REQUEST(xChangeDeviceDontPropagateListReq);
     swaps(&stuff->length, n);
     REQUEST_AT_LEAST_SIZE(xChangeDeviceDontPropagateListReq);
     swapl(&stuff->window, n);
     swaps(&stuff->count, n);
-    p = (long *)&stuff[1];
-    for (i = 0; i < stuff->count; i++) {
-	swapl(p, n);
-	p++;
-    }
+    REQUEST_FIXED_SIZE(xChangeDeviceDontPropagateListReq,
+                      stuff->count * sizeof(CARD32));
+    SwapLongs((CARD32 *) (&stuff[1]), stuff->count);
     return (ProcXChangeDeviceDontPropagateList(client));
 }
 
diff --git a/Xi/grabdev.c b/Xi/grabdev.c
index e2809ef..d0b4ae7 100644
--- a/Xi/grabdev.c
+++ b/Xi/grabdev.c
@@ -82,8 +82,6 @@ int
 SProcXGrabDevice(ClientPtr client)
 {
     char n;
-    long *p;
-    int i;
 
     REQUEST(xGrabDeviceReq);
     swaps(&stuff->length, n);
@@ -91,11 +89,11 @@ SProcXGrabDevice(ClientPtr client)
     swapl(&stuff->grabWindow, n);
     swapl(&stuff->time, n);
     swaps(&stuff->event_count, n);
-    p = (long *)&stuff[1];
-    for (i = 0; i < stuff->event_count; i++) {
-	swapl(p, n);
-	p++;
-    }
+
+    if (stuff->length != (sizeof(xGrabDeviceReq) >> 2) + stuff->event_count)
+       return BadLength;
+    
+    SwapLongs((CARD32 *) (&stuff[1]), stuff->event_count);
 
     return (ProcXGrabDevice(client));
 }
diff --git a/Xi/grabdevb.c b/Xi/grabdevb.c
index df62d0c..18db1f7 100644
--- a/Xi/grabdevb.c
+++ b/Xi/grabdevb.c
@@ -80,8 +80,6 @@ int
 SProcXGrabDeviceButton(ClientPtr client)
 {
     char n;
-    long *p;
-    int i;
 
     REQUEST(xGrabDeviceButtonReq);
     swaps(&stuff->length, n);
@@ -89,11 +87,9 @@ SProcXGrabDeviceButton(ClientPtr client)
     swapl(&stuff->grabWindow, n);
     swaps(&stuff->modifiers, n);
     swaps(&stuff->event_count, n);
-    p = (long *)&stuff[1];
-    for (i = 0; i < stuff->event_count; i++) {
-	swapl(p, n);
-	p++;
-    }
+    REQUEST_FIXED_SIZE(xGrabDeviceButtonReq,
+                      stuff->event_count * sizeof(CARD32));
+    SwapLongs((CARD32 *) (&stuff[1]), stuff->event_count);
 
     return (ProcXGrabDeviceButton(client));
 }
diff --git a/Xi/grabdevk.c b/Xi/grabdevk.c
index b74592f..429b2f7 100644
--- a/Xi/grabdevk.c
+++ b/Xi/grabdevk.c
@@ -80,8 +80,6 @@ int
 SProcXGrabDeviceKey(ClientPtr client)
 {
     char n;
-    long *p;
-    int i;
 
     REQUEST(xGrabDeviceKeyReq);
     swaps(&stuff->length, n);
@@ -89,11 +87,8 @@ SProcXGrabDeviceKey(ClientPtr client)
     swapl(&stuff->grabWindow, n);
     swaps(&stuff->modifiers, n);
     swaps(&stuff->event_count, n);
-    p = (long *)&stuff[1];
-    for (i = 0; i < stuff->event_count; i++) {
-	swapl(p, n);
-	p++;
-    }
+    REQUEST_FIXED_SIZE(xGrabDeviceKeyReq, stuff->event_count * sizeof(CARD32));
+    SwapLongs((CARD32 *) (&stuff[1]), stuff->event_count);
     return (ProcXGrabDeviceKey(client));
 }
 
diff --git a/Xi/selectev.c b/Xi/selectev.c
index d52db1b..19415c5 100644
--- a/Xi/selectev.c
+++ b/Xi/selectev.c
@@ -131,19 +131,16 @@ int
 SProcXSelectExtensionEvent(ClientPtr client)
 {
     char n;
-    long *p;
-    int i;
 
     REQUEST(xSelectExtensionEventReq);
     swaps(&stuff->length, n);
     REQUEST_AT_LEAST_SIZE(xSelectExtensionEventReq);
     swapl(&stuff->window, n);
     swaps(&stuff->count, n);
-    p = (long *)&stuff[1];
-    for (i = 0; i < stuff->count; i++) {
-	swapl(p, n);
-	p++;
-    }
+    REQUEST_FIXED_SIZE(xSelectExtensionEventReq,
+                      stuff->count * sizeof(CARD32));
+    SwapLongs((CARD32 *) (&stuff[1]), stuff->count);
+
     return (ProcXSelectExtensionEvent(client));
 }
 
diff --git a/Xi/sendexev.c b/Xi/sendexev.c
index eac9abe..9803cf3 100644
--- a/Xi/sendexev.c
+++ b/Xi/sendexev.c
@@ -83,7 +83,7 @@ int
 SProcXSendExtensionEvent(ClientPtr client)
 {
     char n;
-    long *p;
+    CARD32 *p;
     int i;
     xEvent eventT;
     xEvent *eventP;
@@ -94,6 +94,11 @@ SProcXSendExtensionEvent(ClientPtr client)
     REQUEST_AT_LEAST_SIZE(xSendExtensionEventReq);
     swapl(&stuff->destination, n);
     swaps(&stuff->count, n);
+
+    if (stuff->length != (sizeof(xSendExtensionEventReq) >> 2) + stuff->count +
+       (stuff->num_events * (sizeof(xEvent) >> 2)))
+       return BadLength;
+
     eventP = (xEvent *) & stuff[1];
     for (i = 0; i < stuff->num_events; i++, eventP++) {
 	proc = EventSwapVector[eventP->u.u.type & 0177];
@@ -103,11 +108,8 @@ SProcXSendExtensionEvent(ClientPtr client)
 	*eventP = eventT;
     }
 
-    p = (long *)(((xEvent *) & stuff[1]) + stuff->num_events);
-    for (i = 0; i < stuff->count; i++) {
-	swapl(p, n);
-	p++;
-    }
+    p = (CARD32 *)(((xEvent *) & stuff[1]) + stuff->num_events);
+    SwapLongs(p, stuff->count);
     return (ProcXSendExtensionEvent(client));
 }
 
commit 4848d49d05a318559afe7a17a19ba055947ee1f5
Author: Matthieu Herrb <matthieu at bluenote.herrb.com>
Date:   Thu Jan 17 15:28:03 2008 +0100

    Fix for CVE-2007-6428 - TOG-cup extension memory corruption.

diff --git a/Xext/cup.c b/Xext/cup.c
index 6bfa278..781b9ce 100644
--- a/Xext/cup.c
+++ b/Xext/cup.c
@@ -196,6 +196,9 @@ int ProcGetReservedColormapEntries(
 
     REQUEST_SIZE_MATCH (xXcupGetReservedColormapEntriesReq);
 
+    if (stuff->screen >= screenInfo.numScreens)
+	return BadValue;
+
 #ifndef HAVE_SPECIAL_DESKTOP_COLORS
     citems[CUP_BLACK_PIXEL].pixel = 
 	screenInfo.screens[stuff->screen]->blackPixel;
commit 59a3b83922c810316a374a19484b24901c7437ae
Author: Matthieu Herrb <matthieu at bluenote.herrb.com>
Date:   Thu Jan 17 15:26:41 2008 +0100

    Fix for CVE-2007-5760 - XFree86 Misc extension out of bounds array index

diff --git a/hw/xfree86/common/xf86MiscExt.c b/hw/xfree86/common/xf86MiscExt.c
index c1b9c60..40c196a 100644
--- a/hw/xfree86/common/xf86MiscExt.c
+++ b/hw/xfree86/common/xf86MiscExt.c
@@ -548,6 +548,10 @@ MiscExtPassMessage(int scrnIndex, const char *msgtype, const char *msgval,
 {
     ScrnInfoPtr pScr = xf86Screens[scrnIndex];
 
+    /* should check this in the protocol, but xf86NumScreens isn't exported */
+    if (scrnIndex >= xf86NumScreens)
+	return BadValue;
+
     if (*pScr->HandleMessage == NULL)
 	    return BadImplementation;
     return (*pScr->HandleMessage)(scrnIndex, msgtype, msgval, retstr);
commit 636aa9e7be2822a0148067a11499ad48fe682cd9
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Jan 5 10:47:39 2008 +0200

    Xephyr: One-time keyboard leak fix
    
    Don't leak the originally-allocated keysym map.
    (cherry picked from commit e85130c85f727466fc27be1cfa46c88b257499fb)

diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index 27165a5..86e8f1f 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -915,6 +915,7 @@ EphyrKeyboardInit (KdKeyboardInfo *ki)
   ki->minScanCode = ki->keySyms.minKeyCode;
   ki->maxScanCode = ki->keySyms.maxKeyCode;
   ki->keySyms.mapWidth = ephyrKeySyms.mapWidth;
+  xfree(ki->keySyms.map);
   ki->keySyms.map = ephyrKeySyms.map;
   ki->name = KdSaveString("Xephyr virtual keyboard");
   ephyrKbd = ki;
commit 8a3acd3ec41b887b4aeaa0b2932265522c1e2836
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Jan 5 10:43:53 2008 +0200

    XKB: XkbCopyKeymap: Don't leak all the sections
    
    Previously, we'd just keep num_sections at 0, which would break the
    geometry and lead us to leak sections.  Don't do that.
    (cherry picked from commit 0137b0394a248f694448a7d97c9a1a3efcf24e81)

diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index c7f9a26..e90df0d 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -1770,6 +1770,7 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies)
             if (!tmp)
                 return FALSE;
             dst->geom->sections = tmp;
+            dst->geom->num_sections = src->geom->num_sections;
 
             for (i = 0,
                   ssection = src->geom->sections,
commit 02e805f0ff4b6af551372ba5fc5fb369c8834d1d
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Jan 5 10:38:16 2008 +0200

    OS: IO: Zero out client buffers
    
    For alignment reasons, we can write out uninitialised bytes, so allocate
    the whole thing with xcalloc.
    (cherry picked from commit b99a43dfe97c1813e1c61f298b1c83c5d5ca88a2)

diff --git a/os/io.c b/os/io.c
index 9de75ee..a8b84fb 100644
--- a/os/io.c
+++ b/os/io.c
@@ -1197,7 +1197,7 @@ AllocateOutputBuffer(void)
     oco = (ConnectionOutputPtr)xalloc(sizeof(ConnectionOutput));
     if (!oco)
 	return (ConnectionOutputPtr)NULL;
-    oco->buf = (unsigned char *) xalloc(BUFSIZE);
+    oco->buf = (unsigned char *) xcalloc(1, BUFSIZE);
     if (!oco->buf)
     {
 	xfree(oco);
commit 7429379eb1001ee3dc769daa8fe6b3aef1b9cc8a
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Sun Jan 13 14:00:25 2008 -0800

    XQuartz: Moved SetFrontProcess haco to set_front_process
    So it is done by the other thread...

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 61a1c1d..65c7d0a 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -318,7 +318,11 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
 }
 
 - (void) set_front_process:unused {
-//    [self activateX:YES];
+    /* Hackery needed due to argv[0] hackery */
+    //    [self activateX:YES];
+    ProcessSerialNumber psn = { 0, kCurrentProcess };
+    SetFrontProcess(&psn);
+
     QuartzMessageServerThread(kXDarwinBringAllToFront, 0);
 }
 
@@ -715,10 +719,6 @@ void X11ApplicationSetWindowMenuCheck (int idx) {
 
 void X11ApplicationSetFrontProcess (void) {
     message_kit_thread (@selector (set_front_process:), nil);
-
-    /* Hackery needed due to argv[0] hackery */
-    ProcessSerialNumber psn = { 0, kCurrentProcess };
-    SetFrontProcess(&psn);
 }
 
 void X11ApplicationSetCanQuit (int state) {
commit a459dde0b46d1daf08f8cd2eee0fc854df5e1f1d
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Sat Jan 12 21:24:34 2008 -0800

    XQuartz: Fixed copy-paste error with login_shell commit
    (cherry picked from commit 6deec3acc6f8010b5b53a1e55a0a2c4080ba69d2)

diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m
index e13edc1..d3f8365 100644
--- a/hw/xquartz/X11Controller.m
+++ b/hw/xquartz/X11Controller.m
@@ -302,7 +302,7 @@
   argv[0] = "/usr/bin/login";
   argv[1] = "-fp";
   argv[2] = getlogin();
-  argv[3] = [X11App prefs_get_string:@PREFS_FAKE_BUTTON2 default:"/bin/sh"];
+  argv[3] = [X11App prefs_get_string:@PREFS_LOGIN_SHELL default:"/bin/sh"];
   argv[4] = "-c";
   argv[5] = command;
   argv[6] = NULL;
commit 7899c5bebfd69a8d6abab0a43464299b9817202b
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Sat Jan 12 11:56:00 2008 -0800

    XQuartz: Corrected copyright X.org Project -> X.org Foundation
    (cherry picked from commit f21631444816fc12b8a534c2cf79e6ac6c2af7c9)

diff --git a/hw/xquartz/bundle/Info.plist b/hw/xquartz/bundle/Info.plist
index 5babdfe..6ba02dd 100644
--- a/hw/xquartz/bundle/Info.plist
+++ b/hw/xquartz/bundle/Info.plist
@@ -27,7 +27,7 @@
 	<key>NSHumanReadableCopyright</key>
 		<string>Copyright © 2003-2008, Apple Inc.
 Copyright © 2003, XFree86 Project, Inc.
-Copyright © 2003-2008, X.org Project, Inc.
+Copyright © 2003-2008, X.org Foundation, Inc.
 </string>
 	<key>NSMainNibFile</key>
 		<string>main</string>
commit 95a103bc60765e9387db1e086e0df6e10efc90e8
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Sat Jan 12 11:35:48 2008 -0800

    XQuartz: added 'login_shell' option to defaults
    so the user can choose something other than /bin/sh
    (cherry picked from commit b549cf18cebd3435d70f62855239484974c455a1)

diff --git a/hw/xquartz/X11Application.h b/hw/xquartz/X11Application.h
index a1be751..af5aea2 100644
--- a/hw/xquartz/X11Application.h
+++ b/hw/xquartz/X11Application.h
@@ -97,5 +97,6 @@ extern int quartzHasRoot, quartzEnableRootless;
 #define PREFS_SWAP_ALT_META         "swap_alt_meta"
 #define PREFS_XP_OPTIONS            "xp_options"
 #define PREFS_ENABLE_STEREO         "enable_stereo"
+#define PREFS_LOGIN_SHELL           "login_shell"
 
 #endif /* X11APPLICATION_H */
diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m
index 6b7c351..e13edc1 100644
--- a/hw/xquartz/X11Controller.m
+++ b/hw/xquartz/X11Controller.m
@@ -302,7 +302,7 @@
   argv[0] = "/usr/bin/login";
   argv[1] = "-fp";
   argv[2] = getlogin();
-  argv[3] = "/bin/sh";
+  argv[3] = [X11App prefs_get_string:@PREFS_FAKE_BUTTON2 default:"/bin/sh"];
   argv[4] = "-c";
   argv[5] = command;
   argv[6] = NULL;
diff --git a/hw/xquartz/bundle/Makefile.am b/hw/xquartz/bundle/Makefile.am
index 9511670..00d540f 100644
--- a/hw/xquartz/bundle/Makefile.am
+++ b/hw/xquartz/bundle/Makefile.am
@@ -18,8 +18,6 @@ EXTRA_DIST = \
 	Info.plist \
 	X11.icns \
 	bundle-main.c \
-	launcher-main.c \
-	server-main.c \
 	English.lproj/InfoPlist.strings \
 	English.lproj/Localizable.strings \
 	English.lproj/main.nib/classes.nib \
diff --git a/hw/xquartz/bundle/bundle-main.c b/hw/xquartz/bundle/bundle-main.c
index df78d7f..54d0136 100644
--- a/hw/xquartz/bundle/bundle-main.c
+++ b/hw/xquartz/bundle/bundle-main.c
@@ -38,6 +38,7 @@
 
 #define DEFAULT_CLIENT "/usr/X11/bin/xterm"
 #define DEFAULT_STARTX "/usr/X11/bin/startx"
+#define DEFAULT_SHELL  "/bin/sh"
 
 static int execute(const char *command);
 static char *command_from_prefs(const char *key, const char *default_value);
@@ -82,7 +83,7 @@ static int execute(const char *command) {
     newargv[0] = "/usr/bin/login";
     newargv[1] = "-fp";
     newargv[2] = getlogin();
-    newargv[3] = "/bin/sh";
+    newargv[3] = command_from_prefs("login_shell", DEFAULT_SHELL);
     newargv[4] = "-c";
     newargv[5] = command;
     newargv[6] = NULL;
commit 627ed60ce5d7499761028edf379ebd95250d3e04
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Sun Jan 6 18:29:54 2008 -0800

    XQuartz: Fixed switching into XQuartz via expose.

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index e45160e..61a1c1d 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -168,7 +168,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
 	 have it activated while X is active (unless using the old
 	 keymapping files) */
     static TSMDocumentID x11_document;
-	
+	DEBUG_LOG("state=%d, _x_active=%d, \n", state, _x_active)
     if (state) {
       QuartzMessageServerThread (kXDarwinActivate, 0);
       
@@ -318,6 +318,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
 }
 
 - (void) set_front_process:unused {
+//    [self activateX:YES];
     QuartzMessageServerThread(kXDarwinBringAllToFront, 0);
 }
 
@@ -714,6 +715,10 @@ void X11ApplicationSetWindowMenuCheck (int idx) {
 
 void X11ApplicationSetFrontProcess (void) {
     message_kit_thread (@selector (set_front_process:), nil);
+
+    /* Hackery needed due to argv[0] hackery */
+    ProcessSerialNumber psn = { 0, kCurrentProcess };
+    SetFrontProcess(&psn);
 }
 
 void X11ApplicationSetCanQuit (int state) {
commit 4c5c30a4beb7a427b00b18097f548876ad3c11d7
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Sat Jan 5 03:14:07 2008 -0800

    XQuartz: Cleanup for strict-prototyping
    Also fixed DarwinEQEnqueue to match changes to the callback
    And also use dpmsstubs.c rather than copying the code into darwin.c

diff --git a/hw/xquartz/Makefile.am b/hw/xquartz/Makefile.am
index 9ac6e0a..99d23eb 100644
--- a/hw/xquartz/Makefile.am
+++ b/hw/xquartz/Makefile.am
@@ -19,6 +19,7 @@ DIST_SUBDIRS = xpr bundle
 libXquartz_la_SOURCES = \
 	$(top_srcdir)/fb/fbcmap_mi.c \
 	$(top_srcdir)/mi/miinitext.c \
+	$(top_srcdir)/Xext/dpmsstubs.c \
 	X11Application.m \
 	X11Controller.m \
 	applewm.c \
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 4203324..e45160e 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -859,7 +859,7 @@ static void send_nsevent (NSEventType type, NSEvent *e) {
     NSWindow *window;
     int pointer_x, pointer_y, ev_button, ev_type; 
     //    int num_events=0, i=0, state;
-    xEvent xe;
+    // xEvent xe;
 	
     /* convert location to global top-left coordinates */
     location = [e locationInWindow];
diff --git a/hw/xquartz/applewm.c b/hw/xquartz/applewm.c
index 72dca28..c460ec6 100644
--- a/hw/xquartz/applewm.c
+++ b/hw/xquartz/applewm.c
@@ -264,8 +264,7 @@ WMFreeEvents (data, id)
 }
 
 static int
-ProcAppleWMSelectInput (client)
-    register ClientPtr  client;
+ProcAppleWMSelectInput (register ClientPtr client)
 {
     REQUEST(xAppleWMSelectInputReq);
     WMEventPtr      pEvent, pNewEvent, *pHead;
@@ -479,13 +478,11 @@ ProcAppleWMSetFrontProcess(
 }
 
 static int
-ProcAppleWMSetWindowLevel(
-    register ClientPtr client
-)
+ProcAppleWMSetWindowLevel(register ClientPtr client)
 {
     REQUEST(xAppleWMSetWindowLevelReq);
     WindowPtr pWin;
-    int errno;
+    int err;
 
     REQUEST_SIZE_MATCH(xAppleWMSetWindowLevelReq);
 
@@ -497,9 +494,9 @@ ProcAppleWMSetWindowLevel(
         return BadValue;
     }
 
-     errno = appleWMProcs->SetWindowLevel(pWin, stuff->level);
-     if (errno != Success) {
-        return errno;
+     err = appleWMProcs->SetWindowLevel(pWin, stuff->level);
+     if (err != Success) {
+        return err;
     }
 
     return (client->noClientException);
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index 08013a2..873f709 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -886,24 +886,6 @@ void AbortDDX( void )
     ddxGiveUp();
 }
 
-
-/*
- * DPMS extension stubs
- */
-Bool DPMSSupported(void)
-{
-    return FALSE;
-}
-
-void DPMSSet(int level)
-{
-}
-
-int DPMSGet(int *level)
-{
-    return -1;
-}
-
 #include "mivalidate.h" // for union _Validate used by windowstr.h
 #include "windowstr.h"  // for struct _Window
 #include "scrnintstr.h" // for struct _Screen
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 1d09e09..b212e98 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -45,6 +45,7 @@ in this Software without prior written authorization from The Open Group.
 #include "darwin.h"
 #include "quartz.h"
 #include "darwinKeyboard.h"
+#include "darwinEvents.h"
 
 #include <sys/types.h>
 #include <sys/uio.h>
@@ -213,9 +214,8 @@ Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr) {
  * 
  * This should be deprecated in favor of miEQEnqueue -- BB
  */
-void DarwinEQEnqueue(const xEvent *e) {
+void DarwinEQEnqueue(const xEventPtr e) {
     HWEventQueueType oldtail, newtail;
-    char byte = 0;
 
     oldtail = darwinEventQueue.tail;
 
@@ -253,7 +253,7 @@ void DarwinEQEnqueue(const xEvent *e) {
  * DarwinEQPointerPost
  *  Post a pointer event. Used by the mipointer.c routines.
  */
-void DarwinEQPointerPost(xEvent *e) {
+void DarwinEQPointerPost(DeviceIntPtr pdev, xEventPtr e) {
     (*darwinEventQueue.pPtr->processInputProc)
             (e, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
 }
@@ -274,7 +274,6 @@ void ProcessInputEvents(void) {
     EventRec *e;
     int     x, y;
     xEvent  xe;
-    static int  old_flags = 0;  // last known modifier state
     // button number and modifier mask of currently pressed fake button
     input_check_flag=0;
 
diff --git a/hw/xquartz/darwinEvents.h b/hw/xquartz/darwinEvents.h
index d6cab2e..82cc26b 100644
--- a/hw/xquartz/darwinEvents.h
+++ b/hw/xquartz/darwinEvents.h
@@ -28,12 +28,13 @@
 #define _DARWIN_EVENTS_H
 
 Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr);
-void DarwinEQEnqueue(const xEvent *e);
-void DarwinEQPointerPost(xEvent *e);
+void DarwinEQEnqueue(const xEventPtr e);
+void DarwinEQPointerPost(DeviceIntPtr pDev, xEventPtr e);
 void DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX);
 void DarwinPokeEQ(void);
 void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int pointer_y);
 void DarwinSendKeyboardEvents(int ev_type, int keycode);
 void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y);
+void DarwinUpdateModKeys(int flags);
 
 #endif  /* _DARWIN_EVENTS_H */
diff --git a/hw/xquartz/darwinKeyboard.c b/hw/xquartz/darwinKeyboard.c
index f1b90b7..b368fe9 100644
--- a/hw/xquartz/darwinKeyboard.c
+++ b/hw/xquartz/darwinKeyboard.c
@@ -330,7 +330,7 @@ static void parse_next_char_code(DataStream *s, KeySym *k) {
  * DarwinReadKeymapFile
  *      Read the appropriate keymapping from a keymapping file.
  */
-Bool DarwinReadKeymapFile(NXKeyMapping *keyMap) {
+static Bool DarwinReadKeymapFile(NXKeyMapping *keyMap) {
     struct stat         st;
     NXEventSystemDevice info[20];
     int                 interface = 0, handler_id = 0;
@@ -439,7 +439,7 @@ Bool DarwinReadKeymapFile(NXKeyMapping *keyMap) {
 /*
  * DarwinParseNXKeyMapping
  */
-Bool DarwinParseNXKeyMapping(darwinKeyboardInfo  *info) {
+static Bool DarwinParseNXKeyMapping(darwinKeyboardInfo  *info) {
     KeySym              *k;
     int                 i;
     short               numMods, numKeys, numPadKeys = 0;
@@ -933,7 +933,7 @@ int DarwinModifierNXMaskToNXKey(int mask) {
     return -1;
 }
 
-const char *DarwinModifierNXMaskTostring(int mask) {
+static const char *DarwinModifierNXMaskTostring(int mask) {
     switch (mask) {
         case NX_ALPHASHIFTMASK:      return "NX_ALPHASHIFTMASK";
         case NX_SHIFTMASK:           return "NX_SHIFTMASK";
diff --git a/hw/xquartz/darwinXinput.c b/hw/xquartz/darwinXinput.c
index ee456a4..e62ec0a 100644
--- a/hw/xquartz/darwinXinput.c
+++ b/hw/xquartz/darwinXinput.c
@@ -63,6 +63,7 @@ SOFTWARE.
 #include <X11/extensions/XI.h>
 #include <X11/extensions/XIproto.h>
 #include "XIstubs.h"
+#include "chgkbd.h"
 
 /***********************************************************************
  *
@@ -88,16 +89,12 @@ SOFTWARE.
  *
  */
 
-int
-ChangeKeyboardDevice (old_dev, new_dev)
-    DeviceIntPtr	old_dev;
-    DeviceIntPtr	new_dev;
-    {
+int ChangeKeyboardDevice (DeviceIntPtr old_dev, DeviceIntPtr new_dev) {
     /***********************************************************************
      DeleteFocusClassDeviceStruct(old_dev);	 * defined in xchgptr.c *
     **********************************************************************/
     return BadMatch;
-    }
+}
 
 
 /***********************************************************************
diff --git a/hw/xquartz/quartzAudio.c b/hw/xquartz/quartzAudio.c
index 86bb200..5dee32f 100644
--- a/hw/xquartz/quartzAudio.c
+++ b/hw/xquartz/quartzAudio.c
@@ -50,7 +50,7 @@
 #include <X11/extensions/XI.h>
 #include <assert.h>
 
-void NSBeep();
+void NSBeep(void);
 
 typedef struct QuartzAudioRec {
     double frequency;
diff --git a/hw/xquartz/quartzCocoa.m b/hw/xquartz/quartzCocoa.m
index 0086c5c..53e3f08 100644
--- a/hw/xquartz/quartzCocoa.m
+++ b/hw/xquartz/quartzCocoa.m
@@ -37,6 +37,7 @@
 #endif
 
 #include "quartzCommon.h"
+#include "quartzPasteboard.h"
 
 #define BOOL xBOOL
 #include "darwin.h"
diff --git a/hw/xquartz/quartzForeground.c b/hw/xquartz/quartzForeground.c
index bfea642..0e724de 100644
--- a/hw/xquartz/quartzForeground.c
+++ b/hw/xquartz/quartzForeground.c
@@ -32,6 +32,8 @@
 #include <ApplicationServices/ApplicationServices.h>
 #include <stdio.h>
 
+#include "quartzForeground.h"
+
 int QuartzMoveToForeground() {
    ProcessSerialNumber psn = { 0, kCurrentProcess };
    OSStatus returnCode = TransformProcessType(& psn, kProcessTransformToForegroundApplication);
diff --git a/hw/xquartz/quartzForeground.h b/hw/xquartz/quartzForeground.h
index 4fc21c7..b5422ff 100644
--- a/hw/xquartz/quartzForeground.h
+++ b/hw/xquartz/quartzForeground.h
@@ -32,6 +32,6 @@
 #ifndef _QUARTZ_FOREGROUND_H_
 #define _QUARTZ_FOREGROUND_H_
 
-int QuartzMoveToForeground();
+int QuartzMoveToForeground(void);
 
 #endif /* _QUARTZ_FOREGROUND_H_ */
diff --git a/hw/xquartz/quartzPasteboard.h b/hw/xquartz/quartzPasteboard.h
index afcb6e5..d6a8ee8 100644
--- a/hw/xquartz/quartzPasteboard.h
+++ b/hw/xquartz/quartzPasteboard.h
@@ -34,11 +34,11 @@
 #define _QUARTZPASTEBOARD_H
 
 // Aqua->X 
-void QuartzReadPasteboard();
+void QuartzReadPasteboard(void);
 char * QuartzReadCocoaPasteboard(void);	// caller must free string
 
 // X->Aqua
-void QuartzWritePasteboard();
+void QuartzWritePasteboard(void);
 void QuartzWriteCocoaPasteboard(char *text);
 
 #endif	/* _QUARTZPASTEBOARD_H */
diff --git a/hw/xquartz/quartzStartup.c b/hw/xquartz/quartzStartup.c
index 1b2a226..e25e155 100644
--- a/hw/xquartz/quartzStartup.c
+++ b/hw/xquartz/quartzStartup.c
@@ -52,8 +52,11 @@
 char **envpGlobal;      // argcGlobal and argvGlobal
                         // are from dix/globals.c
 
+int main(int argc, char **argv, char **envp);
+void _InitHLTB(void);
+void DarwinHandleGUI(int argc, char **argv, char **envp);
+
 static void server_thread (void *arg) {
-  extern int main(int argc, char **argv, char **envp);
   exit (main (argcGlobal, argvGlobal, envpGlobal));
 }
 
@@ -103,8 +106,6 @@ void DarwinHandleGUI(int argc, char **argv, char **envp) {
        before the main thread when we're _not_ prebound, things fail,
        so initialize by hand. */
 
-    extern void _InitHLTB(void);
-    
     _InitHLTB();    
     X11ControllerMain(argc, (const char **)argv, server_thread, NULL);
     exit(0);
diff --git a/hw/xquartz/xpr/appledri.c b/hw/xquartz/xpr/appledri.c
index 95a4439..b4a4725 100644
--- a/hw/xquartz/xpr/appledri.c
+++ b/hw/xquartz/xpr/appledri.c
@@ -55,6 +55,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "swaprep.h"
 #include "dri.h"
 #include "dristruct.h"
+#include "xpr.h"
 
 static int DRIErrorBase = 0;
 
commit fab82c097c738def12ea70c38635b07ada8581c5
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Fri Jan 4 22:51:12 2008 -0800

    XQuartz: Fixed copyright in About box for 2008.  Happy New Year!

diff --git a/hw/xquartz/Makefile.am b/hw/xquartz/Makefile.am
index 1f19102..9ac6e0a 100644
--- a/hw/xquartz/Makefile.am
+++ b/hw/xquartz/Makefile.am
@@ -3,6 +3,7 @@ AM_CFLAGS = $(XSERVER_CFLAGS) $(DIX_CFLAGS)
 AM_OBJCFLAGS = $(XSERVER_CFLAGS) $(DIX_CFLAGS)
 AM_CPPFLAGS = \
 	-DBUILD_DATE=\"$(BUILD_DATE)\" \
+	-DXSERVER_VERSION=\"$(VERSION)\" \
 	-DINXQUARTZ \
 	-DUSE_NEW_CLUT \
 	-DXFree86Server \
diff --git a/hw/xquartz/bundle/Info.plist b/hw/xquartz/bundle/Info.plist
index fce8c96..5babdfe 100644
--- a/hw/xquartz/bundle/Info.plist
+++ b/hw/xquartz/bundle/Info.plist
@@ -25,9 +25,9 @@
 	<key>CSResourcesFileMapped</key>
 		<true/>
 	<key>NSHumanReadableCopyright</key>
-		<string>Copyright © 2003-2007, Apple Inc.
+		<string>Copyright © 2003-2008, Apple Inc.
 Copyright © 2003, XFree86 Project, Inc.
-Copyright © 2003-2007, X.org Project, Inc.
+Copyright © 2003-2008, X.org Project, Inc.
 </string>
 	<key>NSMainNibFile</key>
 		<string>main</string>
commit 4790016cc2e90103e308dc87c41df3912e46a1f9
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Fri Jan 4 12:23:09 2008 -0800

    XQuartz: Flush the debug log for easier debugging
    Also cleaned up formatting in xpr's eventHandler
    (cherry picked from commit 16861d6d4239c7f3918332ef07752f1e211afb23)

diff --git a/hw/xquartz/darwin.h b/hw/xquartz/darwin.h
index 365f5b7..f516432 100644
--- a/hw/xquartz/darwin.h
+++ b/hw/xquartz/darwin.h
@@ -124,7 +124,7 @@ enum {
 #ifdef ENABLE_DEBUG_LOG
 extern FILE *debug_log_fp;
 #define DEBUG_LOG_NAME "x11-debug.txt"
-#define DEBUG_LOG(msg, args...) if (debug_log_fp) fprintf(debug_log_fp, "%s:%d: " msg, __FUNCTION__, __LINE__, ##args )
+#define DEBUG_LOG(msg, args...) if (debug_log_fp) fprintf(debug_log_fp, "%s:%s:%d " msg, __FILE__, __FUNCTION__, __LINE__, ##args ); fflush(debug_log_fp);
 #else
 #define DEBUG_LOG(msg, args...) 
 #endif
diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c
index 29179e5..e4e1fda 100644
--- a/hw/xquartz/xpr/xprScreen.c
+++ b/hw/xquartz/xpr/xprScreen.c
@@ -62,53 +62,52 @@ static const char *xprOpenGLBundle = "glxCGL.bundle";
  * eventHandler
  *  Callback handler for Xplugin events.
  */
-static void
-eventHandler(unsigned int type, const void *arg,
-             unsigned int arg_size, void *data)
-{
+static void eventHandler(unsigned int type, const void *arg,
+                         unsigned int arg_size, void *data) {
     switch (type) {
-    case XP_EVENT_DISPLAY_CHANGED:
-      DEBUG_LOG("XP_EVENT_DISPLAY_CHANGED\n");
-      QuartzMessageServerThread(kXDarwinDisplayChanged, 0);
-      break;
-
-    case XP_EVENT_WINDOW_STATE_CHANGED:
-      DEBUG_LOG("XP_EVENT_WINDOW_STATE_CHANGED\n");
-      if (arg_size >= sizeof(xp_window_state_event)) {
-	const xp_window_state_event *ws_arg = arg;
-	
-	QuartzMessageServerThread(kXDarwinWindowState, 2,
-				  ws_arg->id, ws_arg->state);
-      }
-      break;
-
-    case XP_EVENT_WINDOW_MOVED:
-      DEBUG_LOG("XP_EVENT_WINDOW_MOVED\n");
-      if (arg_size == sizeof(xp_window_id))  {
-	xp_window_id id = * (xp_window_id *) arg;
-	WindowPtr pWin = xprGetXWindow(id);
-	QuartzMessageServerThread(kXDarwinWindowMoved, 1, pWin);
-      }
-      break;
-      
-    case XP_EVENT_SURFACE_DESTROYED:
-      DEBUG_LOG("XP_EVENT_SURFACE_DESTROYED\n");
-    case XP_EVENT_SURFACE_CHANGED:
-      DEBUG_LOG("XP_EVENT_SURFACE_CHANGED\n");
-        if (arg_size == sizeof(xp_surface_id)) {
-	  int kind;
-	  
-	  if (type == XP_EVENT_SURFACE_DESTROYED)
-	    kind = AppleDRISurfaceNotifyDestroyed;
-	  else
-	    kind = AppleDRISurfaceNotifyChanged;
-	  
-	  DRISurfaceNotify(*(xp_surface_id *) arg, kind);
-        }
-        break;
-    default:
-      ErrorF("Unknown XP_EVENT type (%d) in xprScreen:eventHandler\n",
-	     type);
+        case XP_EVENT_DISPLAY_CHANGED:
+            DEBUG_LOG("XP_EVENT_DISPLAY_CHANGED\n");
+            QuartzMessageServerThread(kXDarwinDisplayChanged, 0);
+            break;
+            
+        case XP_EVENT_WINDOW_STATE_CHANGED:
+            if (arg_size >= sizeof(xp_window_state_event)) {
+                const xp_window_state_event *ws_arg = arg;
+                
+                DEBUG_LOG("XP_EVENT_WINDOW_STATE_CHANGED: id=%d, state=%d\n", ws_arg->id, ws_arg->state);
+                QuartzMessageServerThread(kXDarwinWindowState, 2,
+                                          ws_arg->id, ws_arg->state);
+            } else {
+                DEBUG_LOG("XP_EVENT_WINDOW_STATE_CHANGED: ignored\n");
+            }
+            break;
+            
+        case XP_EVENT_WINDOW_MOVED:
+            DEBUG_LOG("XP_EVENT_WINDOW_MOVED\n");
+            if (arg_size == sizeof(xp_window_id))  {
+                xp_window_id id = * (xp_window_id *) arg;
+                WindowPtr pWin = xprGetXWindow(id);
+                QuartzMessageServerThread(kXDarwinWindowMoved, 1, pWin);
+            }
+            break;
+            
+        case XP_EVENT_SURFACE_DESTROYED:
+            DEBUG_LOG("XP_EVENT_SURFACE_DESTROYED\n");
+        case XP_EVENT_SURFACE_CHANGED:
+            DEBUG_LOG("XP_EVENT_SURFACE_CHANGED\n");
+            if (arg_size == sizeof(xp_surface_id)) {
+                int kind;
+                
+                if (type == XP_EVENT_SURFACE_DESTROYED)
+                    kind = AppleDRISurfaceNotifyDestroyed;
+                else
+                    kind = AppleDRISurfaceNotifyChanged;
+                
+                DRISurfaceNotify(*(xp_surface_id *) arg, kind);
+            }
+            break;
+        default:
+            ErrorF("Unknown XP_EVENT type (%d) in xprScreen:eventHandler\n", type);
     }
 }
 
commit c9dff90ce869131e2d4e020c2f80674ec9ef2ccb
Merge: 8e4c28e... 60144ac...
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Thu Jan 3 13:26:22 2008 -0800

    Merge branch 'server-1.4-branch' into xorg-server-1.4-apple

commit 8e4c28ec2a72619bd47af4286b9bbf0c019dc6da
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Sat Dec 22 15:09:12 2007 -0800

    XQuartz: Cleaned up color map configuration.
    8 bit color still doesn't work, but the -depth command line argument now works properly.
    (cherry picked from commit 6765949c27c053d22882f54337cfd09203aa5383)

diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index 5353893..08013a2 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -78,7 +78,7 @@
 #include "darwinEvents.h"
 #include "darwinKeyboard.h"
 #include "quartz.h"
-#include "darwinClut8.h"
+//#include "darwinClut8.h"
 
 #ifdef ENABLE_DEBUG_LOG
 FILE *debug_log_fp = NULL;
@@ -176,17 +176,10 @@ static Bool DarwinSaveScreen(ScreenPtr pScreen, int on)
  *  This is a callback from dix during AddScreen() from InitOutput().
  *  Initialize the screen and communicate information about it back to dix.
  */
-static Bool DarwinAddScreen(
-    int         index,
-    ScreenPtr   pScreen,
-    int         argc,
-    char        **argv )
-{
-    int         bitsPerRGB, i, dpi;
+static Bool DarwinAddScreen(int index, ScreenPtr pScreen, int argc, char **argv) {
+    int         dpi;
     static int  foundIndex = 0;
     Bool        ret;
-    VisualPtr   visual;
-    ColormapPtr pmap;
     DarwinFramebufferPtr dfb;
 
     // reset index of found screens for each server generation
@@ -204,28 +197,13 @@ static Bool DarwinAddScreen(
     if (! ret)
         return FALSE;
 
-    bitsPerRGB = dfb->bitsPerComponent;
-
     // reset the visual list
     miClearVisualTypes();
 
     // setup a single visual appropriate for our pixel type
-    if (dfb->colorType == TrueColor) {
-        if (!miSetVisualTypes( dfb->colorBitsPerPixel, TrueColorMask,
-                               bitsPerRGB, TrueColor )) {
-            return FALSE;
-        }
-    } else if (dfb->colorType == PseudoColor) {
-        if (!miSetVisualTypes( dfb->colorBitsPerPixel, PseudoColorMask,
-                               bitsPerRGB, PseudoColor )) {
-            return FALSE;
-        }
-    } else if (dfb->colorType == StaticColor) {
-        if (!miSetVisualTypes( dfb->colorBitsPerPixel, StaticColorMask,
-                               bitsPerRGB, StaticColor )) {
-            return FALSE;
-        }
-    } else {
+    if(!miSetVisualTypesAndMasks(dfb->depth, dfb->visuals, dfb->bitsPerRGB,
+                                 dfb->preferredCVC, dfb->redMask,
+                                 dfb->greenMask, dfb->blueMask)) {
         return FALSE;
     }
 
@@ -249,20 +227,28 @@ static Bool DarwinAddScreen(
         return FALSE;
     }
 
+//    ErrorF("Screen type: %d, %d=%d, %d=%d, %d=%d, %x=%x=%x, %x=%x=%x, %x=%x=%x\n", pScreen->visuals->class,
+//           pScreen->visuals->offsetRed, dfb->bitsPerRGB * 2,
+//           pScreen->visuals->offsetGreen, dfb->bitsPerRGB,
+//           pScreen->visuals->offsetBlue, 0,
+//           pScreen->visuals->redMask, dfb->redMask, ((1<<dfb->bitsPerRGB)-1) << pScreen->visuals->offsetRed,
+//           pScreen->visuals->greenMask, dfb->greenMask, ((1<<dfb->bitsPerRGB)-1) << pScreen->visuals->offsetGreen,
+//           pScreen->visuals->blueMask, dfb->blueMask, ((1<<dfb->bitsPerRGB)-1) << pScreen->visuals->offsetBlue);
+
     // set the RGB order correctly for TrueColor
-    if (dfb->bitsPerPixel > 8) {
-        for (i = 0, visual = pScreen->visuals;  // someday we may have more than 1
-            i < pScreen->numVisuals; i++, visual++) {
-            if (visual->class == TrueColor) {
-                visual->offsetRed = bitsPerRGB * 2;
-                visual->offsetGreen = bitsPerRGB;
-                visual->offsetBlue = 0;
-                visual->redMask = ((1<<bitsPerRGB)-1) << visual->offsetRed;
-                visual->greenMask = ((1<<bitsPerRGB)-1) << visual->offsetGreen;
-                visual->blueMask = ((1<<bitsPerRGB)-1) << visual->offsetBlue;
-            }
-        }
-    }
+//    if (dfb->bitsPerPixel > 8) {
+//        for (i = 0, visual = pScreen->visuals;  // someday we may have more than 1
+//            i < pScreen->numVisuals; i++, visual++) {
+//            if (visual->class == TrueColor) {
+//                visual->offsetRed = bitsPerRGB * 2;
+//                visual->offsetGreen = bitsPerRGB;
+//                visual->offsetBlue = 0;
+//                visual->redMask = ((1<<bitsPerRGB)-1) << visual->offsetRed;
+//                visual->greenMask = ((1<<bitsPerRGB)-1) << visual->offsetGreen;
+//                visual->blueMask = ((1<<bitsPerRGB)-1) << visual->offsetBlue;
+//            }
+//        }
+//    }
 
 #ifdef RENDER
     if (! fbPictureInit(pScreen, 0, 0)) {
@@ -292,17 +278,16 @@ static Bool DarwinAddScreen(
      * mode and we're using a fixed color map.  Essentially this translates
      * to Darwin/x86 in 8-bit mode.
      */
-    if( (dfb->colorBitsPerPixel == 8) &&
-                (dfb->colorType == StaticColor) )
-    {
-        pmap = miInstalledMaps[pScreen->myNum];
-        visual = pmap->pVisual;
-        for( i = 0; i < visual->ColormapEntries; i++ ) {
-            pmap->red[i].co.local.red   = darwinClut8[i].red;
-            pmap->red[i].co.local.green = darwinClut8[i].green;
-            pmap->red[i].co.local.blue  = darwinClut8[i].blue;
-        }
-    }
+//    if(dfb->depth == 8) {
+//        ColormapPtr map = RootlessGetColormap (pScreen);
+//        for( i = 0; i < map->pVisual->ColormapEntries; i++ ) {
+//            Entry *ent = map->red + i;
+//            ErrorF("Setting lo %d -> r: %04x g: %04x b: %04x\n", i, darwinClut8[i].red, darwinClut8[i].green, darwinClut8[i].blue);
+//            ent->co.local.red   = darwinClut8[i].red;
+//            ent->co.local.green = darwinClut8[i].green;
+//            ent->co.local.blue  = darwinClut8[i].blue;
+//        }
+//    }
 
     dixScreenOrigins[index].x = dfb->x;
     dixScreenOrigins[index].y = dfb->y;
@@ -800,24 +785,21 @@ int ddxProcessArgument( int argc, char *argv[], int i )
     }
 
     if ( !strcmp( argv[i], "-depth" ) ) {
-        int     bitDepth;
-
         if ( i == argc-1 ) {
             FatalError( "-depth must be followed by a number\n" );
         }
 #ifdef OLD_POWERBOOK_G3
         ErrorF( "Ignoring unsupported -depth option on old PowerBook G3\n");
 #else
-        bitDepth = atoi( argv[i+1] );
-        if (bitDepth == 8)
-            darwinDesiredDepth = 0;
-        else if (bitDepth == 15)
-            darwinDesiredDepth = 1;
-        else if (bitDepth == 24)
-            darwinDesiredDepth = 2;
-        else
+        darwinDesiredDepth = atoi( argv[i+1] );
+        if(darwinDesiredDepth != -1 &&
+           darwinDesiredDepth != 8 &&
+           darwinDesiredDepth != 15 &&
+           darwinDesiredDepth != 24) {
             FatalError( "Unsupported pixel depth. Use 8, 15, or 24 bits\n" );
-        ErrorF( "Attempting to use pixel depth of %i\n", bitDepth );
+        }
+
+        ErrorF( "Attempting to use pixel depth of %i\n", darwinDesiredDepth );
 #endif
         return 2;
     }
diff --git a/hw/xquartz/darwin.h b/hw/xquartz/darwin.h
index f835ae0..365f5b7 100644
--- a/hw/xquartz/darwin.h
+++ b/hw/xquartz/darwin.h
@@ -40,10 +40,14 @@ typedef struct {
     int                 width;
     int                 height;
     int                 pitch;
-    int                 colorType;
+    int                 depth;
+    int                 visuals;
+    int                 bitsPerRGB;
     int                 bitsPerPixel;
-    int                 colorBitsPerPixel;
-    int                 bitsPerComponent;
+    int                 preferredCVC;
+    Pixel               redMask;
+    Pixel               greenMask;
+    Pixel               blueMask;
 } DarwinFramebufferRec, *DarwinFramebufferPtr;
 
 // From darwin.c
diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c
index 068b7b1..29179e5 100644
--- a/hw/xquartz/xpr/xprScreen.c
+++ b/hw/xquartz/xpr/xprScreen.c
@@ -42,6 +42,7 @@
 #include "globals.h"
 #include "Xplugin.h"
 #include "applewmExt.h"
+#include "micmap.h"
 
 // From xprFrame.c
 WindowPtr xprGetXWindow(xp_window_id wid);
@@ -249,35 +250,59 @@ static Bool
 xprAddScreen(int index, ScreenPtr pScreen)
 {
     DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen);
-
-    /* If no specific depth chosen, look for the depth of the main display.
-       Else if 16bpp specified, use that. Else use 32bpp. */
-
-    dfb->colorType = TrueColor;
-    dfb->bitsPerComponent = 8;
-    dfb->bitsPerPixel = 32;
-    dfb->colorBitsPerPixel = 24;
-
-    if (darwinDesiredDepth == -1)
-    {
-        dfb->bitsPerComponent = CGDisplayBitsPerSample(kCGDirectMainDisplay);
-        dfb->bitsPerPixel = CGDisplayBitsPerPixel(kCGDirectMainDisplay);
-        dfb->colorBitsPerPixel =
-                CGDisplaySamplesPerPixel(kCGDirectMainDisplay) *
-                dfb->bitsPerComponent;
+    int depth = darwinDesiredDepth;
+    
+    if(depth == -1) {
+        depth = CGDisplaySamplesPerPixel(kCGDirectMainDisplay) * CGDisplayBitsPerSample(kCGDirectMainDisplay);
+        //dfb->depth = CGDisplaySamplesPerPixel(kCGDirectMainDisplay) * CGDisplayBitsPerSample(kCGDirectMainDisplay);
+        //dfb->bitsPerRGB = CGDisplayBitsPerSample(kCGDirectMainDisplay);
+        //dfb->bitsPerPixel = CGDisplayBitsPerPixel(kCGDirectMainDisplay);
     }
-    else if (darwinDesiredDepth == 15)
-    {
-        dfb->bitsPerComponent = 5;
-        dfb->bitsPerPixel = 16;
-        dfb->colorBitsPerPixel = 15;
-    }
-    else if (darwinDesiredDepth == 8)
-    {
-        dfb->colorType = PseudoColor;
-        dfb->bitsPerComponent = 8;
-        dfb->bitsPerPixel = 8;
-        dfb->colorBitsPerPixel = 8;
+    
+    switch(depth) {
+        case -8: // broken
+            FatalError("Unsupported color depth %d\n", darwinDesiredDepth);
+            dfb->visuals = (1 << StaticGray) | (1 << GrayScale);
+            dfb->preferredCVC = GrayScale;
+            dfb->depth = 8;
+            dfb->bitsPerRGB = 8;
+            dfb->bitsPerPixel = 8;
+            dfb->redMask = 0;
+            dfb->greenMask = 0;
+            dfb->blueMask = 0;
+            break;
+        case 8: // broken
+            dfb->visuals = PseudoColorMask;
+            dfb->preferredCVC = PseudoColor;
+            dfb->depth = 8;
+            dfb->bitsPerRGB = 8;
+            dfb->bitsPerPixel = 8;
+            dfb->redMask = 0;
+            dfb->greenMask = 0;
+            dfb->blueMask = 0;
+            break;
+        case 15:
+            dfb->visuals = LARGE_VISUALS;
+            dfb->preferredCVC = TrueColor;
+            dfb->depth = 15;
+            dfb->bitsPerRGB = 5;
+            dfb->bitsPerPixel = 16;
+            dfb->redMask   = 0x7c00;
+            dfb->greenMask = 0x03e0;
+            dfb->blueMask  = 0x001f;
+            break;
+        case 24:
+            dfb->visuals = LARGE_VISUALS;
+            dfb->preferredCVC = TrueColor;
+            dfb->depth = 24;
+            dfb->bitsPerRGB = 8;
+            dfb->bitsPerPixel = 32;
+            dfb->redMask   = 0x00ff0000;
+            dfb->greenMask = 0x0000ff00;
+            dfb->blueMask  = 0x000000ff;
+            break;
+        default:
+            FatalError("Unsupported color depth %d\n", darwinDesiredDepth);
     }
 
     if (noPseudoramiXExtension)
commit 60144ac814ee26e151186f7c93cb1a273468d497
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Wed Dec 19 16:20:36 2007 +1030

    include: never overwrite realInputProc with enqueueInputProc. Bug #13511
    
    In some cases (triggered by a key repeat during a sync grab) XKB unwrapping
    can overwrite the device's realInputProc with the enqueueInputProc. When the
    grab is released and the events are replayed, we end up in an infinite loop.
    Each event is replayed and in replaying pushed to the end of the queue again.
    
    This fix is a hack only. It ensures that the realInputProc is never
    overwritten with the enqueueInputProc.
    
    This fixes Bug #13511 (https://bugs.freedesktop.org/show_bug.cgi?id=13511)
    (cherry picked from commit eace88989c3b65d5c20e9f37ea9b23c7c8e19335)
    (cherry picked from commit 50e80c39870adfdc84fdbc00dddf1362117ad443)

diff --git a/include/xkbsrv.h b/include/xkbsrv.h
index 167dbec..9174eb6 100644
--- a/include/xkbsrv.h
+++ b/include/xkbsrv.h
@@ -258,7 +258,8 @@ typedef struct
 	    device->public.processInputProc = proc; \
 	oldprocs->processInputProc = \
 	oldprocs->realInputProc = device->public.realInputProc; \
-	device->public.realInputProc = proc; \
+	if (proc != device->public.enqueueInputProc) \
+		device->public.realInputProc = proc; \
 	oldprocs->unwrapProc = device->unwrapProc; \
 	device->unwrapProc = unwrapproc;
 
commit 102c012c206cbb3bbf0fa5b0c8f0ce2ce9bba72a
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Dec 28 15:49:50 2007 +0200

    Input: Don't reinit devices
    
    If a device is already initialised (i.e. the virtual core devices) during
    IASD, don't init them again.  This fixes a leak.
    (cherry picked from commit 1f6015c8fe62c28cfaa82cc855b5b9c28fd34607)

diff --git a/dix/devices.c b/dix/devices.c
index 287d730..f6f3c8e 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -473,7 +473,8 @@ InitAndStartDevices(void)
 
     for (dev = inputInfo.off_devices; dev; dev = dev->next) {
         DebugF("(dix) initialising device %d\n", dev->id);
-	ActivateDevice(dev);
+        if (!dev->inited)
+            ActivateDevice(dev);
     }
     for (dev = inputInfo.off_devices; dev; dev = next)
     {
commit a304fc1d4a7062f65161ef8748fd358639ec73de
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Dec 28 15:48:57 2007 +0200

    KDrive: Xephyr: Don't leak screen damage structure
    (cherry picked from commit 0b03d97a244540824c922c300adbc3d3ae4855d5)

diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index e8001df..27165a5 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -394,6 +394,7 @@ ephyrUnsetInternalDamage (ScreenPtr pScreen)
   
   pPixmap = (*pScreen->GetScreenPixmap) (pScreen);
   DamageUnregister (&pPixmap->drawable, scrpriv->pDamage);
+  DamageDestroy (scrpriv->pDamage);
   
   RemoveBlockAndWakeupHandlers (ephyrInternalDamageBlockHandler,
 				ephyrInternalDamageWakeupHandler,
commit 38d8cfaaff0ae6273d9e921aae08b2706355f0d2
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Dec 28 15:48:25 2007 +0200

    OS: Don't leak connection translation table on regeneration
    (cherry picked from commit e868e0bc0d2318e62707d3ae68532b0029959154)

diff --git a/os/connection.c b/os/connection.c
index b944593..d1ba845 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -353,7 +353,8 @@ InitConnectionLimits(void)
 #endif
 
 #if !defined(WIN32)
-    ConnectionTranslation = (int *)xnfalloc(sizeof(int)*(lastfdesc + 1));
+    if (!ConnectionTranslation)
+        ConnectionTranslation = (int *)xnfalloc(sizeof(int)*(lastfdesc + 1));
 #else
     InitConnectionTranslation();
 #endif
commit 30fc8053a5e734c3b70156bdae94fd7d5d7865a5
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Dec 28 15:47:57 2007 +0200

    Config: HAL: Don't leak options on failure to add device
    
    This showed up in Xephyr in particular, which denies new device requests.
    (cherry picked from commit 2bb199056edf6c63cf978d1a8ad49a57ce1938f3)

diff --git a/config/hal.c b/config/hal.c
index 4427deb..16f16ec 100644
--- a/config/hal.c
+++ b/config/hal.c
@@ -92,6 +92,8 @@ add_option(InputOption **options, const char *key, const char *value)
     for (; *options; options = &(*options)->next)
         ;
     *options = xcalloc(sizeof(**options), 1);
+    if (!*options) /* Yeesh. */
+        return;
     (*options)->key = xstrdup(key);
     (*options)->value = xstrdup(value);
     (*options)->next = NULL;
@@ -156,7 +158,7 @@ device_added(LibHalContext *hal_ctx, const char *udi)
     char *path = NULL, *driver = NULL, *name = NULL, *xkb_rules = NULL;
     char *xkb_model = NULL, *xkb_layout = NULL, *xkb_variant = NULL;
     char *xkb_options = NULL, *config_info = NULL;
-    InputOption *options = NULL;
+    InputOption *options = NULL, *tmpo = NULL;
     DeviceIntPtr dev;
     DBusError error;
     int type = TYPE_NONE;
@@ -232,6 +234,7 @@ device_added(LibHalContext *hal_ctx, const char *udi)
 
     if (NewInputDeviceRequest(options, &dev) != Success) {
         DebugF("[config/hal] NewInputDeviceRequest failed\n");
+        dev = NULL;
         goto unwind;
     }
 
@@ -255,6 +258,12 @@ unwind:
         xfree(xkb_options);
     if (config_info)
         xfree(config_info);
+    while (!dev && (tmpo = options)) {
+        options = tmpo->next;
+        xfree(tmpo->key);
+        xfree(tmpo->value);
+        xfree(tmpo);
+    }
 
 out_error:
     dbus_error_free(&error);
commit 81c5950d0af8d5859f850b98c98a532784e9a757
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Dec 28 15:47:21 2007 +0200

    Config: D-Bus: Don't leak timers
    
    TimerCancel doesn't free the timer: you need TimerFree for that.
    (cherry picked from commit 25deaa7e6b29b3913b35efa39b9c8b25de5e6d95)

diff --git a/config/dbus-core.c b/config/dbus-core.c
index eab72a5..9cf1530 100644
--- a/config/dbus-core.c
+++ b/config/dbus-core.c
@@ -76,7 +76,7 @@ teardown(void)
     struct config_dbus_core_hook *hook;
 
     if (bus_info.timer) {
-        TimerCancel(bus_info.timer);
+        TimerFree(bus_info.timer);
         bus_info.timer = NULL;
     }
 
@@ -116,6 +116,8 @@ message_filter(DBusConnection *connection, DBusMessage *message, void *data)
         bus_info.connection = NULL;
         teardown();
 
+        if (bus_info.timer)
+            TimerFree(bus_info.timer);
         bus_info.timer = TimerSet(NULL, 0, 1, reconnect_timer, NULL);
 
         return DBUS_HANDLER_RESULT_HANDLED;
@@ -186,6 +188,7 @@ static CARD32
 reconnect_timer(OsTimerPtr timer, CARD32 time, pointer arg)
 {
     if (connect_to_bus()) {
+        TimerFree(bus_info.timer);
         bus_info.timer = NULL;
         return 0;
     }
commit 61cc57c5101571edad80549e60623236a1a8bedd
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Fri Dec 21 02:09:01 2007 -0800

    XQuartz: *REALLY* use CFStringCreateWithCString
    I need sleep!  Why am I making these stupid mistakes... sorry for pointless commit spam.  ugg.
    (cherry picked from commit b16351fc6457aabead328472d16dc25789032940)

diff --git a/hw/xquartz/bundle/bundle-main.c b/hw/xquartz/bundle/bundle-main.c
index c668567..df78d7f 100644
--- a/hw/xquartz/bundle/bundle-main.c
+++ b/hw/xquartz/bundle/bundle-main.c
@@ -104,7 +104,7 @@ static char *command_from_prefs(const char *key, const char *default_value) {
     CFPropertyListRef PlistRef = CFPreferencesCopyAppValue(cfKey, kCFPreferencesCurrentApplication);
     
     if ((PlistRef == NULL) || (CFGetTypeID(PlistRef) != CFStringGetTypeID())) {
-        CFStringRef cfDefaultValue = CFStringCreateWithPascalString(NULL, default_value, kCFStringEncodingASCII);
+        CFStringRef cfDefaultValue = CFStringCreateWithCString(NULL, default_value, kCFStringEncodingASCII);
 
         CFPreferencesSetAppValue(cfKey, cfDefaultValue, kCFPreferencesCurrentApplication);
         CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
commit 6562b8d4f730b1d8390604abfcaae78bb0813005
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Fri Dec 21 02:06:47 2007 -0800

    XQuartz: Use CFStringCreateWithCString
    (cherry picked from commit 79782b0e14761dcf5d6635b8eec161b74f06763a)

diff --git a/hw/xquartz/bundle/bundle-main.c b/hw/xquartz/bundle/bundle-main.c
index a7b00d6..c668567 100644
--- a/hw/xquartz/bundle/bundle-main.c
+++ b/hw/xquartz/bundle/bundle-main.c
@@ -100,7 +100,7 @@ static int execute(const char *command) {
 static char *command_from_prefs(const char *key, const char *default_value) {
     char *command = NULL;
     
-    CFStringRef cfKey = CFStringCreateWithPascalString(NULL, key, kCFStringEncodingASCII);
+    CFStringRef cfKey = CFStringCreateWithCString(NULL, key, kCFStringEncodingASCII);
     CFPropertyListRef PlistRef = CFPreferencesCopyAppValue(cfKey, kCFPreferencesCurrentApplication);
     
     if ((PlistRef == NULL) || (CFGetTypeID(PlistRef) != CFStringGetTypeID())) {
commit 628c9c708a079249fd1ccc982bf2d9b5c40f4b50
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Fri Dec 21 01:57:43 2007 -0800

    XQuartz: Reduce code duplication in X11.app
    (cherry picked from commit b81809cd91a9f90b7f2de77b1dcf514cee87c32d)

diff --git a/hw/xquartz/bundle/bundle-main.c b/hw/xquartz/bundle/bundle-main.c
index cd74cea..a7b00d6 100644
--- a/hw/xquartz/bundle/bundle-main.c
+++ b/hw/xquartz/bundle/bundle-main.c
@@ -39,8 +39,8 @@
 #define DEFAULT_CLIENT "/usr/X11/bin/xterm"
 #define DEFAULT_STARTX "/usr/X11/bin/startx"
 
-static int launcher_main(int argc, char **argv);
-static int server_main(int argc, char **argv);
+static int execute(const char *command);
+static char *command_from_prefs(const char *key, const char *default_value);
 
 int main(int argc, char **argv) {
     Display *display;
@@ -50,7 +50,7 @@ int main(int argc, char **argv) {
     for(i=0; i < argc; i++) {
         fprintf(stderr, "\targv[%u] = %s\n", (unsigned)i, argv[i]);
     }
-    
+
     /* If we have a process serial number and it's our only arg, act as if
      * the user double clicked the app bundle: launch app_to_run if possible
      */
@@ -61,32 +61,32 @@ int main(int argc, char **argv) {
             fprintf(stderr, "X11.app: Closing the display and sleeping for 2s to allow the X server to start up.\n");
             /* Could open the display, start the launcher */
             XCloseDisplay(display);
-            
+
             /* Give 2 seconds for the server to start... 
              * TODO: *Really* fix this race condition
              */
             usleep(2000);
-            return launcher_main(argc, argv);
+            return execute(command_from_prefs("app_to_run", DEFAULT_CLIENT));
         }
     }
-    
+
     /* Start the server */
     fprintf(stderr, "X11.app: Could not connect to server.  Starting X server.");
-    return server_main(argc, argv);
+    return execute(command_from_prefs("startx_script", DEFAULT_STARTX));
 }
 
-static int myexecvp(const char *command) {
+static int execute(const char *command) {
     const char *newargv[7];
     const char **s;
 
-	newargv[0] = "/usr/bin/login";
-	newargv[1] = "-fp";
-	newargv[2] = getlogin();
-	newargv[3] = "/bin/sh";
-	newargv[4] = "-c";
-	newargv[5] = command;
-	newargv[6] = NULL;
-
+    newargv[0] = "/usr/bin/login";
+    newargv[1] = "-fp";
+    newargv[2] = getlogin();
+    newargv[3] = "/bin/sh";
+    newargv[4] = "-c";
+    newargv[5] = command;
+    newargv[6] = NULL;
+    
     fprintf(stderr, "X11.app: Launching %s:\n", command);
     for(s=newargv; *s; s++) {
         fprintf(stderr, "\targv[%d] = %s\n", s - newargv, *s);
@@ -97,42 +97,33 @@ static int myexecvp(const char *command) {
     return(1);
 }
 
-int launcher_main (int argc, char **argv) {
-    char *command = DEFAULT_CLIENT;
+static char *command_from_prefs(const char *key, const char *default_value) {
+    char *command = NULL;
     
-	CFPropertyListRef PlistRef = CFPreferencesCopyAppValue(CFSTR("app_to_run"), kCFPreferencesCurrentApplication);
-	
-	if ((PlistRef == NULL) || (CFGetTypeID(PlistRef) != CFStringGetTypeID())) {
-		CFPreferencesSetAppValue(CFSTR("app_to_run"), CFSTR(DEFAULT_CLIENT), kCFPreferencesCurrentApplication);
-		CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
-	} else {
-        int len = CFStringGetLength((CFStringRef)PlistRef)+1;
-		command = (char *)malloc(len);
-		CFStringGetCString((CFStringRef)PlistRef, command, len,  kCFStringEncodingASCII);
-	}
-
-	if (PlistRef)
-        CFRelease(PlistRef);
-
-    return myexecvp(command);
-}
-
-int server_main (int argc, char **argv) {
-    char *command = DEFAULT_STARTX;
+    CFStringRef cfKey = CFStringCreateWithPascalString(NULL, key, kCFStringEncodingASCII);
+    CFPropertyListRef PlistRef = CFPreferencesCopyAppValue(cfKey, kCFPreferencesCurrentApplication);
+    
+    if ((PlistRef == NULL) || (CFGetTypeID(PlistRef) != CFStringGetTypeID())) {
+        CFStringRef cfDefaultValue = CFStringCreateWithPascalString(NULL, default_value, kCFStringEncodingASCII);
 
-	CFPropertyListRef PlistRef = CFPreferencesCopyAppValue(CFSTR("startx_script"), kCFPreferencesCurrentApplication);
-	
-	if ((PlistRef == NULL) || (CFGetTypeID(PlistRef) != CFStringGetTypeID())) {
-		CFPreferencesSetAppValue(CFSTR("startx_script"), CFSTR(DEFAULT_STARTX), kCFPreferencesCurrentApplication);
-		CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
-	} else {
-        int len = CFStringGetLength((CFStringRef)PlistRef)+1;
-		command = (char *)malloc(len);
-		CFStringGetCString((CFStringRef)PlistRef, command, len,  kCFStringEncodingASCII);
+        CFPreferencesSetAppValue(cfKey, cfDefaultValue, kCFPreferencesCurrentApplication);
+        CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
+        
+        int len = strlen(default_value) + 1;
+        command = (char *)malloc(len * sizeof(char));
+        if(!command)
+            return NULL;
+        strcpy(command, default_value);
+    } else {
+        int len = CFStringGetLength((CFStringRef)PlistRef) + 1;
+        command = (char *)malloc(len * sizeof(char));
+        if(!command)
+            return NULL;
+        CFStringGetCString((CFStringRef)PlistRef, command, len,  kCFStringEncodingASCII);
 	}
     
-	if (PlistRef)
+    if (PlistRef)
         CFRelease(PlistRef);
     
-    return myexecvp(command);
+    return command;
 }
commit b585e48cff517916fc7d694811e4ee7b54f72e66
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Fri Dec 21 01:24:06 2007 -0800

    XQuartz: Handle Pseudorami init in miinitext
    (cherry picked from commit a585c94fedd4ecbc87524703c01bb128fc2aa951)

diff --git a/hw/xquartz/pseudoramiX.c b/hw/xquartz/pseudoramiX.c
index b19c605..4a9d8e1 100644
--- a/hw/xquartz/pseudoramiX.c
+++ b/hw/xquartz/pseudoramiX.c
@@ -44,7 +44,7 @@ Equipment Corporation.
 #include <X11/extensions/panoramiXproto.h>
 #include "globals.h"
 
-extern int noPseudoramiXExtension;
+Bool noPseudoramiXExtension = FALSE;
 extern int noPanoramiXExtension;
 
 extern int ProcPanoramiXQueryVersion (ClientPtr client);
diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index 549ad09..81c3325 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -39,11 +39,13 @@
 #include "quartzAudio.h"
 #include "pseudoramiX.h"
 #define _APPLEWM_SERVER_
-#include "X11/extensions/applewm.h"
 #include "applewmExt.h"
 
 #include "X11Application.h"
 
+#include <X11/extensions/applewm.h>
+#include <X11/extensions/randr.h>
+
 // X headers
 #include "scrnintstr.h"
 #include "windowstr.h"
@@ -69,7 +71,6 @@ int                     quartzServerVisible = TRUE;
 int                     quartzServerQuitting = FALSE;
 int                     quartzScreenIndex = 0;
 int                     aquaMenuBarHeight = 0;
-int                     noPseudoramiXExtension = FALSE;
 QuartzModeProcsPtr      quartzProcs = NULL;
 const char             *quartzOpenGLBundle = NULL;
 
@@ -173,13 +174,6 @@ void QuartzInitOutput(
 
     // Do display mode specific initialization
     quartzProcs->DisplayInit();
-
-    // Init PseudoramiX implementation of Xinerama.
-    // This should be in InitExtensions, but that causes link errors
-    // for servers that don't link in pseudoramiX.c.
-    if (!noPseudoramiXExtension) {
-        PseudoramiXExtensionInit(argc, argv);
-    }
 }
 
 
diff --git a/hw/xquartz/quartzStartup.c b/hw/xquartz/quartzStartup.c
index 8600ec8..1b2a226 100644
--- a/hw/xquartz/quartzStartup.c
+++ b/hw/xquartz/quartzStartup.c
@@ -106,6 +106,6 @@ void DarwinHandleGUI(int argc, char **argv, char **envp) {
     extern void _InitHLTB(void);
     
     _InitHLTB();    
-    X11ControllerMain(argc, argv, server_thread, NULL);
+    X11ControllerMain(argc, (const char **)argv, server_thread, NULL);
     exit(0);
 }
diff --git a/mi/miinitext.c b/mi/miinitext.c
index 02000ef..6c11622 100644
--- a/mi/miinitext.c
+++ b/mi/miinitext.c
@@ -206,6 +206,9 @@ extern Bool noXkbExtension;
 #ifdef PANORAMIX
 extern Bool noPanoramiXExtension;
 #endif
+#ifdef INXQUARTZ
+extern Bool noPseudoramiXExtension;
+#endif
 #ifdef XINPUT
 extern Bool noXInputExtension;
 #endif
@@ -271,6 +274,9 @@ extern void MultibufferExtensionInit(INITARGS);
 #ifdef PANORAMIX
 extern void PanoramiXExtensionInit(INITARGS);
 #endif
+#ifdef INXQUARTZ
+extern void PseudoramiXExtensionInit(INITARGS);
+#endif
 #ifdef XINPUT
 extern void XInputExtensionInit(INITARGS);
 #endif
@@ -532,6 +538,9 @@ InitExtensions(argc, argv)
   if (!noPanoramiXExtension) PanoramiXExtensionInit();
 # endif
 #endif
+#ifdef INXQUARTZ
+    if(!noPseudoramiXExtension) PseudoramiXExtensionInit();
+#endif
 #ifdef SHAPE
     if (!noShapeExtension) ShapeExtensionInit();
 #endif
commit 60d28ff8dfccc165802da669e04c04e07617402d
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Thu Dec 20 19:38:20 2007 -0800

    XQuartz: Added localization.
    (cherry picked from commit 7a5cc7bfbb296a2c41a580b063324c448f7131db)

diff --git a/hw/xquartz/bundle/Dutch.lproj/InfoPlist.strings b/hw/xquartz/bundle/Dutch.lproj/InfoPlist.strings
new file mode 100644
index 0000000..8f978d6
Binary files /dev/null and b/hw/xquartz/bundle/Dutch.lproj/InfoPlist.strings differ
diff --git a/hw/xquartz/bundle/Dutch.lproj/Localizable.strings b/hw/xquartz/bundle/Dutch.lproj/Localizable.strings
new file mode 100644
index 0000000..1ff39fe
Binary files /dev/null and b/hw/xquartz/bundle/Dutch.lproj/Localizable.strings differ
diff --git a/hw/xquartz/bundle/Dutch.lproj/main.nib/keyedobjects.nib b/hw/xquartz/bundle/Dutch.lproj/main.nib/keyedobjects.nib
new file mode 100644
index 0000000..95c26d7
Binary files /dev/null and b/hw/xquartz/bundle/Dutch.lproj/main.nib/keyedobjects.nib differ
diff --git a/hw/xquartz/bundle/French.lproj/InfoPlist.strings b/hw/xquartz/bundle/French.lproj/InfoPlist.strings
new file mode 100644
index 0000000..88e1f04
Binary files /dev/null and b/hw/xquartz/bundle/French.lproj/InfoPlist.strings differ
diff --git a/hw/xquartz/bundle/French.lproj/Localizable.strings b/hw/xquartz/bundle/French.lproj/Localizable.strings
new file mode 100644
index 0000000..2770dfb
Binary files /dev/null and b/hw/xquartz/bundle/French.lproj/Localizable.strings differ
diff --git a/hw/xquartz/bundle/French.lproj/main.nib/keyedobjects.nib b/hw/xquartz/bundle/French.lproj/main.nib/keyedobjects.nib
new file mode 100644
index 0000000..9f9a7da
Binary files /dev/null and b/hw/xquartz/bundle/French.lproj/main.nib/keyedobjects.nib differ
diff --git a/hw/xquartz/bundle/German.lproj/InfoPlist.strings b/hw/xquartz/bundle/German.lproj/InfoPlist.strings
new file mode 100644
index 0000000..aa37e75
Binary files /dev/null and b/hw/xquartz/bundle/German.lproj/InfoPlist.strings differ
diff --git a/hw/xquartz/bundle/German.lproj/Localizable.strings b/hw/xquartz/bundle/German.lproj/Localizable.strings
new file mode 100644
index 0000000..a5489ab
Binary files /dev/null and b/hw/xquartz/bundle/German.lproj/Localizable.strings differ
diff --git a/hw/xquartz/bundle/German.lproj/main.nib/keyedobjects.nib b/hw/xquartz/bundle/German.lproj/main.nib/keyedobjects.nib
new file mode 100644
index 0000000..19532a9
Binary files /dev/null and b/hw/xquartz/bundle/German.lproj/main.nib/keyedobjects.nib differ
diff --git a/hw/xquartz/bundle/Italian.lproj/InfoPlist.strings b/hw/xquartz/bundle/Italian.lproj/InfoPlist.strings
new file mode 100644
index 0000000..4121698
Binary files /dev/null and b/hw/xquartz/bundle/Italian.lproj/InfoPlist.strings differ
diff --git a/hw/xquartz/bundle/Italian.lproj/Localizable.strings b/hw/xquartz/bundle/Italian.lproj/Localizable.strings
new file mode 100644
index 0000000..d05d73d
Binary files /dev/null and b/hw/xquartz/bundle/Italian.lproj/Localizable.strings differ
diff --git a/hw/xquartz/bundle/Italian.lproj/main.nib/keyedobjects.nib b/hw/xquartz/bundle/Italian.lproj/main.nib/keyedobjects.nib
new file mode 100644
index 0000000..b6e2e1b
Binary files /dev/null and b/hw/xquartz/bundle/Italian.lproj/main.nib/keyedobjects.nib differ
diff --git a/hw/xquartz/bundle/Japanese.lproj/InfoPlist.strings b/hw/xquartz/bundle/Japanese.lproj/InfoPlist.strings
new file mode 100644
index 0000000..2d6330f
Binary files /dev/null and b/hw/xquartz/bundle/Japanese.lproj/InfoPlist.strings differ
diff --git a/hw/xquartz/bundle/Japanese.lproj/Localizable.strings b/hw/xquartz/bundle/Japanese.lproj/Localizable.strings
new file mode 100644
index 0000000..99821ea
Binary files /dev/null and b/hw/xquartz/bundle/Japanese.lproj/Localizable.strings differ
diff --git a/hw/xquartz/bundle/Japanese.lproj/main.nib/keyedobjects.nib b/hw/xquartz/bundle/Japanese.lproj/main.nib/keyedobjects.nib
new file mode 100644
index 0000000..523fd08
Binary files /dev/null and b/hw/xquartz/bundle/Japanese.lproj/main.nib/keyedobjects.nib differ
diff --git a/hw/xquartz/bundle/Spanish.lproj/InfoPlist.strings b/hw/xquartz/bundle/Spanish.lproj/InfoPlist.strings
new file mode 100644
index 0000000..0e4287d
Binary files /dev/null and b/hw/xquartz/bundle/Spanish.lproj/InfoPlist.strings differ
diff --git a/hw/xquartz/bundle/Spanish.lproj/Localizable.strings b/hw/xquartz/bundle/Spanish.lproj/Localizable.strings
new file mode 100644
index 0000000..652f432
Binary files /dev/null and b/hw/xquartz/bundle/Spanish.lproj/Localizable.strings differ
diff --git a/hw/xquartz/bundle/Spanish.lproj/main.nib/keyedobjects.nib b/hw/xquartz/bundle/Spanish.lproj/main.nib/keyedobjects.nib
new file mode 100644
index 0000000..029349d
Binary files /dev/null and b/hw/xquartz/bundle/Spanish.lproj/main.nib/keyedobjects.nib differ
diff --git a/hw/xquartz/bundle/X11.xcodeproj/project.pbxproj b/hw/xquartz/bundle/X11.xcodeproj/project.pbxproj
index ddb6f83..ae8ec07 100644
--- a/hw/xquartz/bundle/X11.xcodeproj/project.pbxproj
+++ b/hw/xquartz/bundle/X11.xcodeproj/project.pbxproj
@@ -20,6 +20,57 @@
 /* Begin PBXFileReference section */
 		0867D6ABFE840B52C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
 		1870340FFE93FCAF11CA0CD7 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/main.nib; sourceTree = "<group>"; };
+		3FB03E460D1B6C05005958A5 /* da */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = da; path = da.lproj/Localizable.strings; sourceTree = "<group>"; };
+		3FB03E470D1B6C05005958A5 /* Dutch */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Dutch; path = Dutch.lproj/Localizable.strings; sourceTree = "<group>"; };
+		3FB03E480D1B6C05005958A5 /* fi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fi; path = fi.lproj/Localizable.strings; sourceTree = "<group>"; };
+		3FB03E490D1B6C05005958A5 /* French */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = French; path = French.lproj/Localizable.strings; sourceTree = "<group>"; };
+		3FB03E4A0D1B6C05005958A5 /* German */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = German; path = German.lproj/Localizable.strings; sourceTree = "<group>"; };
+		3FB03E4B0D1B6C05005958A5 /* Italian */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Italian; path = Italian.lproj/Localizable.strings; sourceTree = "<group>"; };
+		3FB03E4C0D1B6C05005958A5 /* Japanese */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Japanese; path = Japanese.lproj/Localizable.strings; sourceTree = "<group>"; };
+		3FB03E4D0D1B6C05005958A5 /* ko */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ko; path = ko.lproj/Localizable.strings; sourceTree = "<group>"; };
+		3FB03E4E0D1B6C05005958A5 /* no */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = no; path = no.lproj/Localizable.strings; sourceTree = "<group>"; };
+		3FB03E4F0D1B6C05005958A5 /* pl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pl; path = pl.lproj/Localizable.strings; sourceTree = "<group>"; };
+		3FB03E500D1B6C05005958A5 /* pt */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pt; path = pt.lproj/Localizable.strings; sourceTree = "<group>"; };
+		3FB03E510D1B6C05005958A5 /* pt_PT */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pt_PT; path = pt_PT.lproj/Localizable.strings; sourceTree = "<group>"; };
+		3FB03E520D1B6C05005958A5 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/Localizable.strings; sourceTree = "<group>"; };
+		3FB03E530D1B6C05005958A5 /* Spanish */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Spanish; path = Spanish.lproj/Localizable.strings; sourceTree = "<group>"; };
+		3FB03E540D1B6C05005958A5 /* sv */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sv; path = sv.lproj/Localizable.strings; sourceTree = "<group>"; };
+		3FB03E550D1B6C05005958A5 /* zh_CN */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = zh_CN; path = zh_CN.lproj/Localizable.strings; sourceTree = "<group>"; };
+		3FB03E560D1B6C05005958A5 /* zh_TW */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = zh_TW; path = zh_TW.lproj/Localizable.strings; sourceTree = "<group>"; };
+		3FB03E570D1B6C17005958A5 /* da */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = da; path = da.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+		3FB03E580D1B6C17005958A5 /* Dutch */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Dutch; path = Dutch.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+		3FB03E590D1B6C17005958A5 /* fi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fi; path = fi.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+		3FB03E5A0D1B6C17005958A5 /* French */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = French; path = French.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+		3FB03E5B0D1B6C17005958A5 /* German */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = German; path = German.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+		3FB03E5C0D1B6C17005958A5 /* Italian */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Italian; path = Italian.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+		3FB03E5D0D1B6C17005958A5 /* Japanese */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Japanese; path = Japanese.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+		3FB03E5E0D1B6C17005958A5 /* ko */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ko; path = ko.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+		3FB03E5F0D1B6C17005958A5 /* no */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = no; path = no.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+		3FB03E600D1B6C17005958A5 /* pl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pl; path = pl.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+		3FB03E610D1B6C17005958A5 /* pt */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pt; path = pt.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+		3FB03E620D1B6C17005958A5 /* pt_PT */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pt_PT; path = pt_PT.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+		3FB03E630D1B6C17005958A5 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+		3FB03E640D1B6C17005958A5 /* Spanish */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Spanish; path = Spanish.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+		3FB03E650D1B6C17005958A5 /* sv */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sv; path = sv.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+		3FB03E660D1B6C17005958A5 /* zh_CN */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = zh_CN; path = zh_CN.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+		3FB03E670D1B6C17005958A5 /* zh_TW */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = zh_TW; path = zh_TW.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+		3FB03E680D1B6C34005958A5 /* da */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = da; path = da.lproj/main.nib; sourceTree = "<group>"; };
+		3FB03E690D1B6C34005958A5 /* Dutch */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = Dutch; path = Dutch.lproj/main.nib; sourceTree = "<group>"; };
+		3FB03E6A0D1B6C34005958A5 /* fi */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = fi; path = fi.lproj/main.nib; sourceTree = "<group>"; };
+		3FB03E6B0D1B6C34005958A5 /* French */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = French; path = French.lproj/main.nib; sourceTree = "<group>"; };
+		3FB03E6C0D1B6C34005958A5 /* German */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = German; path = German.lproj/main.nib; sourceTree = "<group>"; };
+		3FB03E6D0D1B6C34005958A5 /* Italian */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = Italian; path = Italian.lproj/main.nib; sourceTree = "<group>"; };
+		3FB03E6E0D1B6C34005958A5 /* Japanese */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = Japanese; path = Japanese.lproj/main.nib; sourceTree = "<group>"; };
+		3FB03E6F0D1B6C34005958A5 /* ko */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = ko; path = ko.lproj/main.nib; sourceTree = "<group>"; };
+		3FB03E700D1B6C34005958A5 /* no */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = no; path = no.lproj/main.nib; sourceTree = "<group>"; };
+		3FB03E710D1B6C34005958A5 /* pl */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = pl; path = pl.lproj/main.nib; sourceTree = "<group>"; };
+		3FB03E720D1B6C34005958A5 /* pt */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = pt; path = pt.lproj/main.nib; sourceTree = "<group>"; };
+		3FB03E730D1B6C34005958A5 /* pt_PT */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = pt_PT; path = pt_PT.lproj/main.nib; sourceTree = "<group>"; };
+		3FB03E740D1B6C34005958A5 /* ru */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = ru; path = ru.lproj/main.nib; sourceTree = "<group>"; };
+		3FB03E750D1B6C34005958A5 /* Spanish */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = Spanish; path = Spanish.lproj/main.nib; sourceTree = "<group>"; };
+		3FB03E760D1B6C34005958A5 /* sv */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = sv; path = sv.lproj/main.nib; sourceTree = "<group>"; };
+		3FB03E770D1B6C34005958A5 /* zh_CN */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = zh_CN; path = zh_CN.lproj/main.nib; sourceTree = "<group>"; };
+		3FB03E780D1B6C34005958A5 /* zh_TW */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = zh_TW; path = zh_TW.lproj/main.nib; sourceTree = "<group>"; };
 		50459C5F038587C60ECA21EC /* X11.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = X11.icns; sourceTree = "<group>"; };
 		50EE2AB703849F0B0ECA21EC /* bundle-main.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = "bundle-main.c"; sourceTree = "<group>"; };
 		50F4F0A7039D6ACA0E82C0CB /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = "<absolute>"; };
@@ -130,6 +181,26 @@
 			buildConfigurationList = 527F24080B5D8FFC007840A7 /* Build configuration list for PBXProject "X11" */;
 			compatibilityVersion = "Xcode 2.4";
 			hasScannedForEncodings = 1;
+			knownRegions = (
+				English,
+				Japanese,
+				French,
+				German,
+				da,
+				Dutch,
+				fi,
+				Italian,
+				ko,
+				no,
+				pl,
+				pt,
+				pt_PT,
+				ru,
+				Spanish,
+				sv,
+				zh_CN,
+				zh_TW,
+			);
 			mainGroup = 20286C29FDCF999611CA2CEA /* X11 */;
 			projectDirPath = "";
 			projectRoot = "";
@@ -180,6 +251,23 @@
 			isa = PBXVariantGroup;
 			children = (
 				1870340FFE93FCAF11CA0CD7 /* English */,
+				3FB03E680D1B6C34005958A5 /* da */,
+				3FB03E690D1B6C34005958A5 /* Dutch */,
+				3FB03E6A0D1B6C34005958A5 /* fi */,
+				3FB03E6B0D1B6C34005958A5 /* French */,
+				3FB03E6C0D1B6C34005958A5 /* German */,
+				3FB03E6D0D1B6C34005958A5 /* Italian */,
+				3FB03E6E0D1B6C34005958A5 /* Japanese */,
+				3FB03E6F0D1B6C34005958A5 /* ko */,
+				3FB03E700D1B6C34005958A5 /* no */,
+				3FB03E710D1B6C34005958A5 /* pl */,
+				3FB03E720D1B6C34005958A5 /* pt */,
+				3FB03E730D1B6C34005958A5 /* pt_PT */,
+				3FB03E740D1B6C34005958A5 /* ru */,
+				3FB03E750D1B6C34005958A5 /* Spanish */,
+				3FB03E760D1B6C34005958A5 /* sv */,
+				3FB03E770D1B6C34005958A5 /* zh_CN */,
+				3FB03E780D1B6C34005958A5 /* zh_TW */,
 			);
 			name = main.nib;
 			sourceTree = "<group>";
@@ -188,6 +276,23 @@
 			isa = PBXVariantGroup;
 			children = (
 				0867D6ABFE840B52C02AAC07 /* English */,
+				3FB03E570D1B6C17005958A5 /* da */,
+				3FB03E580D1B6C17005958A5 /* Dutch */,
+				3FB03E590D1B6C17005958A5 /* fi */,
+				3FB03E5A0D1B6C17005958A5 /* French */,
+				3FB03E5B0D1B6C17005958A5 /* German */,
+				3FB03E5C0D1B6C17005958A5 /* Italian */,
+				3FB03E5D0D1B6C17005958A5 /* Japanese */,
+				3FB03E5E0D1B6C17005958A5 /* ko */,
+				3FB03E5F0D1B6C17005958A5 /* no */,
+				3FB03E600D1B6C17005958A5 /* pl */,
+				3FB03E610D1B6C17005958A5 /* pt */,
+				3FB03E620D1B6C17005958A5 /* pt_PT */,
+				3FB03E630D1B6C17005958A5 /* ru */,
+				3FB03E640D1B6C17005958A5 /* Spanish */,
+				3FB03E650D1B6C17005958A5 /* sv */,
+				3FB03E660D1B6C17005958A5 /* zh_CN */,
+				3FB03E670D1B6C17005958A5 /* zh_TW */,
 			);
 			name = InfoPlist.strings;
 			sourceTree = "<group>";
@@ -196,6 +301,23 @@
 			isa = PBXVariantGroup;
 			children = (
 				52D9C0EC0BCDDF6B00CD2AFC /* English */,
+				3FB03E460D1B6C05005958A5 /* da */,
+				3FB03E470D1B6C05005958A5 /* Dutch */,
+				3FB03E480D1B6C05005958A5 /* fi */,
+				3FB03E490D1B6C05005958A5 /* French */,
+				3FB03E4A0D1B6C05005958A5 /* German */,
+				3FB03E4B0D1B6C05005958A5 /* Italian */,
+				3FB03E4C0D1B6C05005958A5 /* Japanese */,
+				3FB03E4D0D1B6C05005958A5 /* ko */,
+				3FB03E4E0D1B6C05005958A5 /* no */,
+				3FB03E4F0D1B6C05005958A5 /* pl */,
+				3FB03E500D1B6C05005958A5 /* pt */,
+				3FB03E510D1B6C05005958A5 /* pt_PT */,
+				3FB03E520D1B6C05005958A5 /* ru */,
+				3FB03E530D1B6C05005958A5 /* Spanish */,
+				3FB03E540D1B6C05005958A5 /* sv */,
+				3FB03E550D1B6C05005958A5 /* zh_CN */,
+				3FB03E560D1B6C05005958A5 /* zh_TW */,
 			);
 			name = Localizable.strings;
 			sourceTree = "<group>";
diff --git a/hw/xquartz/bundle/da.lproj/InfoPlist.strings b/hw/xquartz/bundle/da.lproj/InfoPlist.strings
new file mode 100644
index 0000000..88e1f04
Binary files /dev/null and b/hw/xquartz/bundle/da.lproj/InfoPlist.strings differ
diff --git a/hw/xquartz/bundle/da.lproj/Localizable.strings b/hw/xquartz/bundle/da.lproj/Localizable.strings
new file mode 100644
index 0000000..9608a2e
Binary files /dev/null and b/hw/xquartz/bundle/da.lproj/Localizable.strings differ
diff --git a/hw/xquartz/bundle/da.lproj/main.nib/keyedobjects.nib b/hw/xquartz/bundle/da.lproj/main.nib/keyedobjects.nib
new file mode 100644
index 0000000..4a2bd4b
Binary files /dev/null and b/hw/xquartz/bundle/da.lproj/main.nib/keyedobjects.nib differ
diff --git a/hw/xquartz/bundle/fi.lproj/InfoPlist.strings b/hw/xquartz/bundle/fi.lproj/InfoPlist.strings
new file mode 100644
index 0000000..8e4f647
Binary files /dev/null and b/hw/xquartz/bundle/fi.lproj/InfoPlist.strings differ
diff --git a/hw/xquartz/bundle/fi.lproj/Localizable.strings b/hw/xquartz/bundle/fi.lproj/Localizable.strings
new file mode 100644
index 0000000..e8420fb
Binary files /dev/null and b/hw/xquartz/bundle/fi.lproj/Localizable.strings differ
diff --git a/hw/xquartz/bundle/fi.lproj/main.nib/keyedobjects.nib b/hw/xquartz/bundle/fi.lproj/main.nib/keyedobjects.nib
new file mode 100644
index 0000000..b5039fd
Binary files /dev/null and b/hw/xquartz/bundle/fi.lproj/main.nib/keyedobjects.nib differ
diff --git a/hw/xquartz/bundle/ko.lproj/InfoPlist.strings b/hw/xquartz/bundle/ko.lproj/InfoPlist.strings
new file mode 100644
index 0000000..4c738f8
Binary files /dev/null and b/hw/xquartz/bundle/ko.lproj/InfoPlist.strings differ
diff --git a/hw/xquartz/bundle/ko.lproj/Localizable.strings b/hw/xquartz/bundle/ko.lproj/Localizable.strings
new file mode 100644
index 0000000..56a3358
Binary files /dev/null and b/hw/xquartz/bundle/ko.lproj/Localizable.strings differ
diff --git a/hw/xquartz/bundle/ko.lproj/main.nib/keyedobjects.nib b/hw/xquartz/bundle/ko.lproj/main.nib/keyedobjects.nib
new file mode 100644
index 0000000..925945c
Binary files /dev/null and b/hw/xquartz/bundle/ko.lproj/main.nib/keyedobjects.nib differ
diff --git a/hw/xquartz/bundle/no.lproj/InfoPlist.strings b/hw/xquartz/bundle/no.lproj/InfoPlist.strings
new file mode 100644
index 0000000..eb1cfb0
Binary files /dev/null and b/hw/xquartz/bundle/no.lproj/InfoPlist.strings differ
diff --git a/hw/xquartz/bundle/no.lproj/Localizable.strings b/hw/xquartz/bundle/no.lproj/Localizable.strings
new file mode 100644
index 0000000..5157a67
Binary files /dev/null and b/hw/xquartz/bundle/no.lproj/Localizable.strings differ
diff --git a/hw/xquartz/bundle/no.lproj/main.nib/keyedobjects.nib b/hw/xquartz/bundle/no.lproj/main.nib/keyedobjects.nib
new file mode 100644
index 0000000..ca25327
Binary files /dev/null and b/hw/xquartz/bundle/no.lproj/main.nib/keyedobjects.nib differ
diff --git a/hw/xquartz/bundle/pl.lproj/InfoPlist.strings b/hw/xquartz/bundle/pl.lproj/InfoPlist.strings
new file mode 100644
index 0000000..b9c9502
Binary files /dev/null and b/hw/xquartz/bundle/pl.lproj/InfoPlist.strings differ
diff --git a/hw/xquartz/bundle/pl.lproj/Localizable.strings b/hw/xquartz/bundle/pl.lproj/Localizable.strings
new file mode 100644
index 0000000..4ae12d7
Binary files /dev/null and b/hw/xquartz/bundle/pl.lproj/Localizable.strings differ
diff --git a/hw/xquartz/bundle/pl.lproj/main.nib/keyedobjects.nib b/hw/xquartz/bundle/pl.lproj/main.nib/keyedobjects.nib
new file mode 100644
index 0000000..e9ca540
Binary files /dev/null and b/hw/xquartz/bundle/pl.lproj/main.nib/keyedobjects.nib differ
diff --git a/hw/xquartz/bundle/pt.lproj/InfoPlist.strings b/hw/xquartz/bundle/pt.lproj/InfoPlist.strings
new file mode 100644
index 0000000..33c6374
Binary files /dev/null and b/hw/xquartz/bundle/pt.lproj/InfoPlist.strings differ
diff --git a/hw/xquartz/bundle/pt.lproj/Localizable.strings b/hw/xquartz/bundle/pt.lproj/Localizable.strings
new file mode 100644
index 0000000..23ea968
Binary files /dev/null and b/hw/xquartz/bundle/pt.lproj/Localizable.strings differ
diff --git a/hw/xquartz/bundle/pt.lproj/main.nib/keyedobjects.nib b/hw/xquartz/bundle/pt.lproj/main.nib/keyedobjects.nib
new file mode 100644
index 0000000..e88cccd
Binary files /dev/null and b/hw/xquartz/bundle/pt.lproj/main.nib/keyedobjects.nib differ
diff --git a/hw/xquartz/bundle/pt_PT.lproj/InfoPlist.strings b/hw/xquartz/bundle/pt_PT.lproj/InfoPlist.strings
new file mode 100644
index 0000000..33c6374
Binary files /dev/null and b/hw/xquartz/bundle/pt_PT.lproj/InfoPlist.strings differ
diff --git a/hw/xquartz/bundle/pt_PT.lproj/Localizable.strings b/hw/xquartz/bundle/pt_PT.lproj/Localizable.strings
new file mode 100644
index 0000000..71c33ad
Binary files /dev/null and b/hw/xquartz/bundle/pt_PT.lproj/Localizable.strings differ
diff --git a/hw/xquartz/bundle/pt_PT.lproj/main.nib/keyedobjects.nib b/hw/xquartz/bundle/pt_PT.lproj/main.nib/keyedobjects.nib
new file mode 100644
index 0000000..a619334
Binary files /dev/null and b/hw/xquartz/bundle/pt_PT.lproj/main.nib/keyedobjects.nib differ
diff --git a/hw/xquartz/bundle/ru.lproj/InfoPlist.strings b/hw/xquartz/bundle/ru.lproj/InfoPlist.strings
new file mode 100644
index 0000000..7f722e4
Binary files /dev/null and b/hw/xquartz/bundle/ru.lproj/InfoPlist.strings differ
diff --git a/hw/xquartz/bundle/ru.lproj/Localizable.strings b/hw/xquartz/bundle/ru.lproj/Localizable.strings
new file mode 100644
index 0000000..3b38112
Binary files /dev/null and b/hw/xquartz/bundle/ru.lproj/Localizable.strings differ
diff --git a/hw/xquartz/bundle/ru.lproj/main.nib/keyedobjects.nib b/hw/xquartz/bundle/ru.lproj/main.nib/keyedobjects.nib
new file mode 100644
index 0000000..9354e02
Binary files /dev/null and b/hw/xquartz/bundle/ru.lproj/main.nib/keyedobjects.nib differ
diff --git a/hw/xquartz/bundle/sv.lproj/InfoPlist.strings b/hw/xquartz/bundle/sv.lproj/InfoPlist.strings
new file mode 100644
index 0000000..655d5ff
Binary files /dev/null and b/hw/xquartz/bundle/sv.lproj/InfoPlist.strings differ
diff --git a/hw/xquartz/bundle/sv.lproj/Localizable.strings b/hw/xquartz/bundle/sv.lproj/Localizable.strings
new file mode 100644
index 0000000..796f06c
Binary files /dev/null and b/hw/xquartz/bundle/sv.lproj/Localizable.strings differ
diff --git a/hw/xquartz/bundle/sv.lproj/main.nib/keyedobjects.nib b/hw/xquartz/bundle/sv.lproj/main.nib/keyedobjects.nib
new file mode 100644
index 0000000..bd01c2d
Binary files /dev/null and b/hw/xquartz/bundle/sv.lproj/main.nib/keyedobjects.nib differ
diff --git a/hw/xquartz/bundle/zh_CN.lproj/InfoPlist.strings b/hw/xquartz/bundle/zh_CN.lproj/InfoPlist.strings
new file mode 100644
index 0000000..b5df368
Binary files /dev/null and b/hw/xquartz/bundle/zh_CN.lproj/InfoPlist.strings differ
diff --git a/hw/xquartz/bundle/zh_CN.lproj/Localizable.strings b/hw/xquartz/bundle/zh_CN.lproj/Localizable.strings
new file mode 100644
index 0000000..f88a6da
Binary files /dev/null and b/hw/xquartz/bundle/zh_CN.lproj/Localizable.strings differ
diff --git a/hw/xquartz/bundle/zh_CN.lproj/main.nib/keyedobjects.nib b/hw/xquartz/bundle/zh_CN.lproj/main.nib/keyedobjects.nib
new file mode 100644
index 0000000..e36c15f
Binary files /dev/null and b/hw/xquartz/bundle/zh_CN.lproj/main.nib/keyedobjects.nib differ
diff --git a/hw/xquartz/bundle/zh_TW.lproj/InfoPlist.strings b/hw/xquartz/bundle/zh_TW.lproj/InfoPlist.strings
new file mode 100644
index 0000000..92d5473
Binary files /dev/null and b/hw/xquartz/bundle/zh_TW.lproj/InfoPlist.strings differ
diff --git a/hw/xquartz/bundle/zh_TW.lproj/Localizable.strings b/hw/xquartz/bundle/zh_TW.lproj/Localizable.strings
new file mode 100644
index 0000000..f009302
Binary files /dev/null and b/hw/xquartz/bundle/zh_TW.lproj/Localizable.strings differ
diff --git a/hw/xquartz/bundle/zh_TW.lproj/main.nib/keyedobjects.nib b/hw/xquartz/bundle/zh_TW.lproj/main.nib/keyedobjects.nib
new file mode 100644
index 0000000..36602c5
Binary files /dev/null and b/hw/xquartz/bundle/zh_TW.lproj/main.nib/keyedobjects.nib differ
commit 9f5507a3c59f16282b99a271a71a780ab60e013b
Merge: 82c97a5... d988da6...
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Thu Dec 20 19:04:33 2007 -0800

    Merge branch 'server-1.4-branch' into xorg-server-1.4-apple

commit 82c97a5475d3562b1894a0e6273aa2492f707bd2
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Thu Dec 20 18:29:57 2007 -0800

    XQuartz: Cleaned up command line arguments.
    (cherry picked from commit 603a8b73d46d59e5f9f0be39be8317f3fadfe7e6)

diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index ad46a3f..5353893 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -708,20 +708,15 @@ void ddxInitGlobals(void)
  */
 int ddxProcessArgument( int argc, char *argv[], int i )
 {
-    if( !strcmp( argv[i], "-launchd" ) ) {
-        ErrorF( "Launchd command line argument noticed.\n" );
-        return 1;
-    }
-
-    if ( !strcmp( argv[i], "-fullscreen" ) ) {
-        ErrorF( "Running full screen in parallel with Mac OS X Quartz window server.\n" );
-        return 1;
-    }
+//    if ( !strcmp( argv[i], "-fullscreen" ) ) {
+//        ErrorF( "Running full screen in parallel with Mac OS X Quartz window server.\n" );
+//        return 1;
+//    }
 
-    if ( !strcmp( argv[i], "-rootless" ) ) {
-        ErrorF( "Running rootless inside Mac OS X window server.\n" );
-        return 1;
-    }
+//    if ( !strcmp( argv[i], "-rootless" ) ) {
+//        ErrorF( "Running rootless inside Mac OS X window server.\n" );
+//        return 1;
+//    }
 
     // This command line arg is passed when launched from the Aqua GUI.
     if ( !strncmp( argv[i], "-psn_", 5 ) ) {
@@ -845,12 +840,6 @@ int ddxProcessArgument( int argc, char *argv[], int i )
         exit(0);
     }
 
-    // XDarwinStartup uses this argument to indicate the IOKit X server
-    // should be started. Ignore it here.
-    if ( !strcmp( argv[i], "-iokit" ) ) {
-        return 1;
-    }
-
     return 0;
 }
 
commit 2a3f6ce7e8ff904f108dbfb70bd3fc99a6d3eb32
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Thu Dec 20 18:08:40 2007 -0800

    XQuartz: Kill off server-main.c and launcher-main.c
    Now using xinit
    (cherry picked from commit 5d6ae3d299f72df714117948b3d31dcbddf6c0bc)

diff --git a/hw/xquartz/bundle/X11.xcodeproj/project.pbxproj b/hw/xquartz/bundle/X11.xcodeproj/project.pbxproj
index 9d5c5d6..ddb6f83 100644
--- a/hw/xquartz/bundle/X11.xcodeproj/project.pbxproj
+++ b/hw/xquartz/bundle/X11.xcodeproj/project.pbxproj
@@ -7,7 +7,6 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
-		3F5E1BE10D04BF110020CA24 /* server-main.c in Sources */ = {isa = PBXBuildFile; fileRef = 3F5E1BDF0D04BF110020CA24 /* server-main.c */; };
 		527F24190B5D938C007840A7 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0867D6AAFE840B52C02AAC07 /* InfoPlist.strings */; };
 		527F241A0B5D938C007840A7 /* main.nib in Resources */ = {isa = PBXBuildFile; fileRef = 02345980000FD03B11CA0E72 /* main.nib */; };
 		527F241B0B5D938C007840A7 /* X11.icns in Resources */ = {isa = PBXBuildFile; fileRef = 50459C5F038587C60ECA21EC /* X11.icns */; };
@@ -21,7 +20,6 @@
 /* Begin PBXFileReference section */
 		0867D6ABFE840B52C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
 		1870340FFE93FCAF11CA0CD7 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/main.nib; sourceTree = "<group>"; };
-		3F5E1BDF0D04BF110020CA24 /* server-main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "server-main.c"; sourceTree = "<group>"; };
 		50459C5F038587C60ECA21EC /* X11.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = X11.icns; sourceTree = "<group>"; };
 		50EE2AB703849F0B0ECA21EC /* bundle-main.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = "bundle-main.c"; sourceTree = "<group>"; };
 		50F4F0A7039D6ACA0E82C0CB /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = "<absolute>"; };
@@ -67,7 +65,6 @@
 		20286C2AFDCF999611CA2CEA /* Sources */ = {
 			isa = PBXGroup;
 			children = (
-				3F5E1BDF0D04BF110020CA24 /* server-main.c */,
 				50EE2AB703849F0B0ECA21EC /* bundle-main.c */,
 			);
 			name = Sources;
@@ -173,7 +170,6 @@
 			buildActionMask = 2147483647;
 			files = (
 				527F241D0B5D938C007840A7 /* bundle-main.c in Sources */,
-				3F5E1BE10D04BF110020CA24 /* server-main.c in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/hw/xquartz/bundle/bundle-main.c b/hw/xquartz/bundle/bundle-main.c
index ed41e68..cd74cea 100644
--- a/hw/xquartz/bundle/bundle-main.c
+++ b/hw/xquartz/bundle/bundle-main.c
@@ -36,10 +36,11 @@
 
 #include <CoreFoundation/CoreFoundation.h>
 
-#define DEFAULT_APP "/usr/X11/bin/xterm"
+#define DEFAULT_CLIENT "/usr/X11/bin/xterm"
+#define DEFAULT_STARTX "/usr/X11/bin/startx"
 
 static int launcher_main(int argc, char **argv);
-int server_main(int argc, char **argv);
+static int server_main(int argc, char **argv);
 
 int main(int argc, char **argv) {
     Display *display;
@@ -57,7 +58,7 @@ int main(int argc, char **argv) {
         /* Now, try to open a display, if so, run the launcher */
         display = XOpenDisplay(NULL);
         if(display) {
-            fprintf(stderr, "X11.app: closing the display and sleeping for 2s to allow the X server to start up.\n");
+            fprintf(stderr, "X11.app: Closing the display and sleeping for 2s to allow the X server to start up.\n");
             /* Could open the display, start the launcher */
             XCloseDisplay(display);
             
@@ -70,29 +71,13 @@ int main(int argc, char **argv) {
     }
     
     /* Start the server */
-    fprintf(stderr, "X11.app: main(): running server_main()");
+    fprintf(stderr, "X11.app: Could not connect to server.  Starting X server.");
     return server_main(argc, argv);
 }
 
-int launcher_main (int argc, char **argv) {
-    char *command = DEFAULT_APP;
+static int myexecvp(const char *command) {
     const char *newargv[7];
-    int child;
     const char **s;
-    
-	CFPropertyListRef PlistRef = CFPreferencesCopyAppValue(CFSTR("app_to_run"), kCFPreferencesCurrentApplication);
-	
-	if ((PlistRef == NULL) || (CFGetTypeID(PlistRef) != CFStringGetTypeID())) {
-		CFPreferencesSetAppValue(CFSTR("app_to_run"), CFSTR(DEFAULT_APP), kCFPreferencesCurrentApplication);
-		CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
-	} else {
-		int len = CFStringGetLength((CFStringRef)PlistRef)+1;
-		command = (char *)malloc(len);
-		CFStringGetCString((CFStringRef)PlistRef, command, len,  kCFStringEncodingASCII);
-		fprintf(stderr, "command=%s\n", command);
-	}
-
-	if (PlistRef) CFRelease(PlistRef);
 
 	newargv[0] = "/usr/bin/login";
 	newargv[1] = "-fp";
@@ -102,7 +87,7 @@ int launcher_main (int argc, char **argv) {
 	newargv[5] = command;
 	newargv[6] = NULL;
 
-    fprintf(stderr, "X11.app: Launching X11 Application:\n");
+    fprintf(stderr, "X11.app: Launching %s:\n", command);
     for(s=newargv; *s; s++) {
         fprintf(stderr, "\targv[%d] = %s\n", s - newargv, *s);
     }
@@ -111,3 +96,43 @@ int launcher_main (int argc, char **argv) {
     perror ("X11.app: Couldn't exec.");
     return(1);
 }
+
+int launcher_main (int argc, char **argv) {
+    char *command = DEFAULT_CLIENT;
+    
+	CFPropertyListRef PlistRef = CFPreferencesCopyAppValue(CFSTR("app_to_run"), kCFPreferencesCurrentApplication);
+	
+	if ((PlistRef == NULL) || (CFGetTypeID(PlistRef) != CFStringGetTypeID())) {
+		CFPreferencesSetAppValue(CFSTR("app_to_run"), CFSTR(DEFAULT_CLIENT), kCFPreferencesCurrentApplication);
+		CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
+	} else {
+        int len = CFStringGetLength((CFStringRef)PlistRef)+1;
+		command = (char *)malloc(len);
+		CFStringGetCString((CFStringRef)PlistRef, command, len,  kCFStringEncodingASCII);
+	}
+
+	if (PlistRef)
+        CFRelease(PlistRef);
+
+    return myexecvp(command);
+}
+
+int server_main (int argc, char **argv) {
+    char *command = DEFAULT_STARTX;
+
+	CFPropertyListRef PlistRef = CFPreferencesCopyAppValue(CFSTR("startx_script"), kCFPreferencesCurrentApplication);
+	
+	if ((PlistRef == NULL) || (CFGetTypeID(PlistRef) != CFStringGetTypeID())) {
+		CFPreferencesSetAppValue(CFSTR("startx_script"), CFSTR(DEFAULT_STARTX), kCFPreferencesCurrentApplication);
+		CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
+	} else {
+        int len = CFStringGetLength((CFStringRef)PlistRef)+1;
+		command = (char *)malloc(len);
+		CFStringGetCString((CFStringRef)PlistRef, command, len,  kCFStringEncodingASCII);
+	}
+    
+	if (PlistRef)
+        CFRelease(PlistRef);
+    
+    return myexecvp(command);
+}
diff --git a/hw/xquartz/bundle/launcher-main.c b/hw/xquartz/bundle/launcher-main.c
deleted file mode 100644
index 60a1624..0000000
--- a/hw/xquartz/bundle/launcher-main.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/* main.c -- X application launcher
- 
- Copyright (c) 2007 Apple Inc.
- 
- 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 <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-
-#include <CoreFoundation/CoreFoundation.h>
-
-#define DEFAULT_APP "/usr/X11/bin/xterm"
-
-int launcher_main (int argc, char **argv) {
-  char *command = DEFAULT_APP;
-  const char *newargv[7];
-  int child;
-  
-
-	CFPropertyListRef PlistRef = CFPreferencesCopyAppValue(CFSTR("app_to_run"),
-									kCFPreferencesCurrentApplication);
-	
-	if ((PlistRef == NULL) || (CFGetTypeID(PlistRef) != CFStringGetTypeID())) {
-		CFPreferencesSetAppValue(CFSTR("app_to_run"), CFSTR(DEFAULT_APP), 
-								 kCFPreferencesCurrentApplication);
-		CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
-	} else {
-		int len = CFStringGetLength((CFStringRef)PlistRef)+1;
-		command = (char *) malloc(len);
-		CFStringGetCString((CFStringRef)PlistRef, command, len,  kCFStringEncodingASCII);
-		fprintf(stderr, "command=%s\n", command);
-	}
-	
-	if (PlistRef) CFRelease(PlistRef);
-	
-	newargv[0] = "/usr/bin/login";
-	newargv[1] = "-fp";
-	newargv[2] = getlogin();
-	newargv[3] = "/bin/sh";
-	newargv[4] = "-c";
-	newargv[5] = command;
-	newargv[6] = NULL;
-
-    child = fork();
-	
-    switch (child) {
-    case -1:				/* error */
-      perror ("fork");
-      return EXIT_FAILURE;		
-    case 0:				    /* child */
-      execvp (newargv[0], (char **const) newargv);
-      perror ("Couldn't exec");
-      _exit (1);
-   }
-	
-    return 0;
-}
diff --git a/hw/xquartz/bundle/server-main.c b/hw/xquartz/bundle/server-main.c
deleted file mode 100644
index 7e1bd70..0000000
--- a/hw/xquartz/bundle/server-main.c
+++ /dev/null
@@ -1,903 +0,0 @@
-/* bundle-main.c -- X server launcher
- 
- Copyright (c) 2002-2007 Apple Inc. 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 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.
- 
- Parts of this file are derived from xdm, which has this copyright:
- 
- Copyright 1988, 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. */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/socket.h>
-#include <sys/utsname.h>
-#include <ifaddrs.h>
-#include <netdb.h>
-#include <netinet/in.h>
-#include <time.h>
-#include <sys/wait.h>
-#include <setjmp.h>
-#include <sys/ioctl.h>
-
-#include <X11/Xlib.h>
-#include <X11/Xauth.h>
-#include <xcb/xcb.h>
-
-#include <CoreFoundation/CoreFoundation.h>
-#include <SystemConfiguration/SystemConfiguration.h>
-
-#define X_SERVER "/usr/X11/bin/Xquartz"
-#define XTERM_PATH "/usr/X11/bin/xterm"
-#define WM_PATH "/usr/bin/quartz-wm"
-#define DEFAULT_XINITRC "/usr/X11/lib/X11/xinit/xinitrc"
-#define DEFAULT_PATH "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11/bin"
-
-/* what xinit does */
-#ifndef SHELL
-# define SHELL "sh"
-#endif
-
-#undef FALSE
-#define FALSE 0
-#undef TRUE
-#define TRUE 1
-
-#define MAX_DISPLAYS 64
-
-static int server_pid = -1, client_pid = -1;
-static int xinit_kills_server = FALSE;
-static jmp_buf exit_continuation;
-static const char *server_name = NULL;
-static Display *server_dpy;
-
-static char *auth_file;
-
-typedef struct addr_list_struct addr_list;
-
-struct addr_list_struct {
-    addr_list *next;
-    Xauth auth;
-};
-
-static addr_list *addresses;
-
-
-/* Utility functions. */
-
-/* Return the current host name. Matches what Xlib does. */
-static char *
-host_name (void)
-{
-#ifdef NEED_UTSNAME
-    static struct utsname name;
-	
-    uname(&name);
-	
-    return name.nodename;
-#else
-    static char buf[100];
-	
-    gethostname(buf, sizeof(buf));
-	
-    return buf;
-#endif
-}
-
-static int
-read_boolean_pref (CFStringRef name, int default_)
-{
-    int value;
-    Boolean ok;
-	
-    value = CFPreferencesGetAppBooleanValue (name, CFSTR ("org.x.X11"), &ok);
-    return ok ? value : default_;
-}
-
-static inline int
-binary_equal (const void *a, const void *b, int length)
-{
-    return memcmp (a, b, length) == 0;
-}
-
-static inline void *
-binary_dup (const void *a, int length)
-{
-    void *b = malloc (length);
-    if (b != NULL)
-		memcpy (b, a, length);
-    return b;
-}
-
-static inline void
-binary_free (void *data, int length)
-{
-    if (data != NULL)
-		free (data);
-}
-
-
-/* Functions for managing the authentication entries. */
-
-/* Returns true if something matching AUTH is in our list of auth items */
-static int
-check_auth_item (Xauth *auth)
-{
-    addr_list *a;
-	
-    for (a = addresses; a != NULL; a = a->next)
-    {
-		if (a->auth.family == auth->family
-			&& a->auth.address_length == auth->address_length
-			&& binary_equal (a->auth.address, auth->address, auth->address_length)
-			&& a->auth.number_length == auth->number_length
-			&& binary_equal (a->auth.number, auth->number, auth->number_length)
-			&& a->auth.name_length == auth->name_length
-			&& binary_equal (a->auth.name, auth->name, auth->name_length))
-		{
-			return TRUE;
-		}
-    }
-	
-    return FALSE;
-}
-
-/* Add one item to our list of auth items. */
-static void
-add_auth_item (Xauth *auth)
-{
-    addr_list *a = malloc (sizeof (addr_list));
-	
-    a->auth.family = auth->family;
-    a->auth.address_length = auth->address_length;
-    a->auth.address = binary_dup (auth->address, auth->address_length);
-    a->auth.number_length = auth->number_length;
-    a->auth.number = binary_dup (auth->number, auth->number_length);
-    a->auth.name_length = auth->name_length;
-    a->auth.name = binary_dup (auth->name, auth->name_length);
-    a->auth.data_length = auth->data_length;
-    a->auth.data = binary_dup (auth->data, auth->data_length);
-	
-    a->next = addresses;
-    addresses = a;
-}
-
-/* Free all allocated auth items. */
-static void
-free_auth_items (void)
-{
-    addr_list *a;
-	
-    while ((a = addresses) != NULL)
-    {
-		addresses = a->next;
-		
-		binary_free (a->auth.address, a->auth.address_length);
-		binary_free (a->auth.number, a->auth.number_length);
-		binary_free (a->auth.name, a->auth.name_length);
-		binary_free (a->auth.data, a->auth.data_length);
-		free (a);
-    }
-}
-
-/* Add the unix domain auth item. */
-static void
-define_local (Xauth *auth)
-{
-    char *host = host_name ();
-	
-#ifdef DEBUG
-    fprintf (stderr, "x11: hostname is %s\n", host);
-#endif
-	
-    auth->family = FamilyLocal;
-    auth->address_length = strlen (host);
-    auth->address = host;
-	
-    add_auth_item (auth);
-}
-
-/* Add the tcp auth item. */
-static void
-define_named (Xauth *auth, const char *name)
-{
-    struct ifaddrs *addrs, *ptr;
-	
-    if (getifaddrs (&addrs) != 0)
-		return;
-	
-    for (ptr = addrs; ptr != NULL; ptr = ptr->ifa_next)
-    {
-		if (ptr->ifa_addr->sa_family != AF_INET)
-			continue;
-		
-		auth->family = FamilyInternet;
-		auth->address_length = sizeof (struct in_addr);
-		auth->address = (char *) &(((struct sockaddr_in *) ptr->ifa_addr)->sin_addr);
-		
-#ifdef DEBUG
-		fprintf (stderr, "x11: ipaddr is %d.%d.%d.%d\n",
-				 (unsigned char) auth->address[0],
-				 (unsigned char) auth->address[1],
-				 (unsigned char) auth->address[2],
-				 (unsigned char) auth->address[3]);
-#endif
-		
-		add_auth_item (auth);
-    }
-	
-    freeifaddrs (addrs);
-}
-
-/* Parse the display number from NAME and add it to AUTH. */
-static void
-set_auth_number (Xauth *auth, const char *name)
-{
-    char *colon;
-    char *dot, *number;
-	
-    colon = strrchr(name, ':');
-    if (colon != NULL)
-    {
-		colon++;
-		dot = strchr(colon, '.');
-		
-		if (dot != NULL)
-			auth->number_length = dot - colon;
-		else
-			auth->number_length = strlen (colon);
-		
-		number = malloc (auth->number_length + 1);
-		if (number != NULL)
-		{
-			strncpy (number, colon, auth->number_length);
-			number[auth->number_length] = '\0';
-		}
-		else
-		{
-			auth->number_length = 0;
-		}
-		
-		auth->number = number;
-    }
-}
-
-/* Put 128 bits of random data into DATA. If possible, it will be "high
- quality" */
-static int
-generate_mit_magic_cookie (char data[16])
-{
-    int fd, ret, i;
-    long *ldata = (long *) data;
-	
-    fd = open ("/dev/random", O_RDONLY);
-    if (fd > 0) {
-		ret = read (fd, data, 16);
-		close (fd);
-		if (ret == 16) return TRUE;
-    }
-	
-    /* fall back to the usual crappy rng */
-	
-    srand48 (getpid () ^ time (NULL));
-	
-    for (i = 0; i < 4; i++)
-		ldata[i] = lrand48 ();
-	
-    return TRUE;
-}
-
-/* Create the keys we'll be using for the display named NAME. */
-static int
-make_auth_keys (const char *name)
-{
-    Xauth auth;
-    char key[16];
-	
-    if (auth_file == NULL)
-		return FALSE;
-	
-    auth.name = "MIT-MAGIC-COOKIE-1";
-    auth.name_length = strlen (auth.name);
-	
-    if (!generate_mit_magic_cookie (key))
-    {
-		auth_file = NULL;
-		return FALSE;
-    }
-	
-    auth.data = key;
-    auth.data_length = 16;
-	
-    set_auth_number (&auth, name);
-	
-    define_named (&auth, host_name ());
-    define_local (&auth);
-	
-    free (auth.number);
-	
-    return TRUE;
-}
-
-/* If ADD-ENTRIES is true, merge our auth entries into the existing
- Xauthority file. If ADD-ENTRIES is false, remove our entries. */
-static int
-write_auth_file (int add_entries)
-{
-    char *home, newname[1024];
-    int fd, ret;
-    FILE *new_fh, *old_fh;
-    addr_list *addr;
-    Xauth *auth;
-	
-    if (auth_file == NULL)
-		return FALSE;
-	
-    home = getenv ("HOME");
-    if (home == NULL)
-    {
-		auth_file = NULL;
-		return FALSE;
-    }
-	
-    snprintf (newname, sizeof (newname), "%s/.XauthorityXXXXXX", home);
-    mktemp (newname);
-	
-    if (XauLockAuth (auth_file, 1, 2, 10) != LOCK_SUCCESS)
-    {
-		/* FIXME: do something here? */
-		
-		auth_file = NULL;
-		return FALSE;
-    }
-	
-    fd = open (newname, O_WRONLY | O_CREAT | O_TRUNC, 0600);
-    if (fd >= 0)
-    {
-		new_fh = fdopen (fd, "w");
-		if (new_fh != NULL)
-		{
-			if (add_entries)
-			{
-				for (addr = addresses; addr != NULL; addr = addr->next)
-				{
-					XauWriteAuth (new_fh, &addr->auth);
-				}
-			}
-			
-			old_fh = fopen (auth_file, "r");
-			if (old_fh != NULL)
-			{
-				while ((auth = XauReadAuth (old_fh)) != NULL)
-				{
-					if (!check_auth_item (auth))
-						XauWriteAuth (new_fh, auth);
-					XauDisposeAuth (auth);
-				}
-				fclose (old_fh);
-			}
-			
-			fclose (new_fh);
-			unlink (auth_file);
-			
-			ret = rename (newname, auth_file);
-			
-			if (ret != 0)
-				auth_file = NULL;
-			
-			XauUnlockAuth (auth_file);
-			return ret == 0;
-		}
-		
-		close (fd);
-    }
-	
-    XauUnlockAuth (auth_file);
-    auth_file = NULL;
-    return FALSE;
-}
-
-
-/* Subprocess management functions. */
-
-static int
-start_server (char **xargv)
-{
-    int child;
-	
-    child = fork ();
-	
-    switch (child)
-    {
-    case -1:				/* error */
-		perror ("fork");
-		return FALSE;
-		
-    case 0:				/* child */
-		execv (X_SERVER, xargv);
-		perror ("Couldn't exec " X_SERVER);
-		_exit (1);
-		
-    default:				/* parent */
-		server_pid = child;
-		return TRUE;
-    }
-}
-
-static int
-wait_for_server (void)
-{
-    int count = 100;
-	
-    while (count-- > 0)
-    {
-		int status;
-		
-		server_dpy = XOpenDisplay (server_name);
-		if (server_dpy != NULL)
-			return TRUE;
-		
-		if (waitpid (server_pid, &status, WNOHANG) == server_pid)
-			return FALSE;
-		
-		sleep (1);
-    }
-	
-    return FALSE;
-}
-
-static int
-start_client (void)
-{
-    int child;
-	
-    child = fork();
-	
-    switch (child) {
-		char *temp, buf[1024];		
-
-	case -1:				/* error */
-		perror("fork");
-		return FALSE;
-
-	case 0:					/* child */
-		/* Setup environment */
-		temp = getenv("DISPLAY");
-//		if (temp == NULL && temp[0] != 0)
-			setenv("DISPLAY", server_name, TRUE);
-
-		temp = getenv("PATH");
-		if (temp == NULL || temp[0] == 0) 
-			setenv ("PATH", DEFAULT_PATH, TRUE);
-		else if (strnstr(temp, "/usr/X11/bin", sizeof(temp)) == NULL) {
-			snprintf(buf, sizeof(buf), "%s:/usr/X11/bin", temp);		
-			setenv("PATH", buf, TRUE);	
-		}
-		
-		/* First try value of $XINITRC, if set. */
-		temp = getenv("XINITRC");
-		if (temp != NULL && temp[0] != 0 && access(temp, R_OK) == 0)
-			execlp (SHELL, SHELL, temp, NULL);
-
-		/* Then look for .xinitrc in user's home directory. */
-		temp = getenv("HOME");
-		if (temp != NULL && temp[0] != 0) {
-			chdir(temp);
-			snprintf (buf, sizeof (buf), "%s/.xinitrc", temp);
-			if (access(buf, R_OK) == 0)
-				execlp(SHELL, SHELL, buf, NULL);
-		}
-		
-		/* Then try the default xinitrc in the lib directory. */
-		
-		if (access(DEFAULT_XINITRC, R_OK) == 0)
-			execlp(SHELL, SHELL, DEFAULT_XINITRC, NULL);
-		
-		/* Then fallback to hardcoding an xterm and the window manager. */
-		
-		//		system(XTERM_PATH " &");
-		execl(WM_PATH, WM_PATH, NULL);
-		
-		perror("exec");
-		_exit(1);
-		
-    default:				/* parent */
-		client_pid = child;
-		return TRUE;
-    }
-}
-
-static void
-sigchld_handler (int sig)
-{
-    int pid, status;
-	
-	again:
-    pid = waitpid (WAIT_ANY, &status, WNOHANG);
-	
-    if (pid > 0)
-    {
-		if (pid == server_pid)
-		{
-			server_pid = -1;
-			
-			if (client_pid >= 0)
-				kill (client_pid, SIGTERM);
-		}
-		else if (pid == client_pid)
-		{
-			client_pid = -1;
-			
-			if (server_pid >= 0 && xinit_kills_server)
-				kill (server_pid, SIGTERM);
-		}
-		goto again;
-    }
-	
-    if (server_pid == -1 && client_pid == -1)
-		longjmp (exit_continuation, 1);
-	
-    signal (SIGCHLD, sigchld_handler);
-}
-
-
-/* Server utilities. */
-
-static Boolean
-display_exists_p (int number)
-{
-    char buf[64];
-    xcb_connection_t *conn;
-    char *fullname = NULL;
-    int idisplay, iscreen;
-    char *conn_auth_name, *conn_auth_data;
-    int conn_auth_namelen, conn_auth_datalen;
-    
-    //    extern void *_X11TransConnectDisplay ();
-    //    extern void _XDisconnectDisplay ();
-	
-    /* Since connecting to the display waits for a few seconds if the
-	 display doesn't exist, check for trivial non-existence - if the
-	 socket in /tmp exists or not.. (note: if the socket exists, the
-	 server may still not, so we need to try to connect in that case..) */
-	
-    sprintf (buf, "/tmp/.X11-unix/X%d", number);
-    if (access (buf, F_OK) != 0)
-		return FALSE;
-    
-    sprintf (buf, ":%d", number);
-    conn = xcb_connect(buf, NULL);
-    if (xcb_connection_has_error(conn)) return FALSE;
-	
-    xcb_disconnect(conn);
-    return TRUE;
-}
-
-
-/* Monitoring when the system's ip addresses change. */
-
-static Boolean pending_timer;
-
-static void
-timer_callback (CFRunLoopTimerRef timer, void *info)
-{
-    pending_timer = FALSE;
-	
-    /* Update authentication names. Need to write .Xauthority file first
-	 without the existing entries, then again with the new entries.. */
-	
-    write_auth_file (FALSE);
-	
-    free_auth_items ();
-    make_auth_keys (server_name);
-	
-    write_auth_file (TRUE);
-}
-
-/* This function is called when the system's ip addresses may have changed. */
-static void
-ipaddr_callback (SCDynamicStoreRef store, CFArrayRef changed_keys, void *info)
-{
-#if DEBUG
-    if (changed_keys != NULL) {
-		fprintf (stderr, "x11: changed sc keys: ");
-		CFShow (changed_keys);
-    }
-#endif
-
-    if (auth_file != NULL && !pending_timer)
-    {
-		CFRunLoopTimerRef timer;
-		
-		timer = CFRunLoopTimerCreate (NULL, CFAbsoluteTimeGetCurrent () + 1.0,
-									  0.0, 0, 0, timer_callback, NULL);
-		CFRunLoopAddTimer (CFRunLoopGetCurrent (), timer,
-						   kCFRunLoopDefaultMode);
-		CFRelease (timer);
-		
-		pending_timer = TRUE;
-    }
-}
-
-/* This code adapted from "Living in a Dynamic TCP/IP Environment" technote. */
-static Boolean
-install_ipaddr_source (void)
-{
-    CFRunLoopSourceRef source = NULL;
-	
-    SCDynamicStoreContext context = {0};
-    SCDynamicStoreRef ref;
-	
-    ref = SCDynamicStoreCreate (NULL,
-								CFSTR ("AddIPAddressListChangeCallbackSCF"),
-								ipaddr_callback, &context);
-	
-    if (ref != NULL)
-    {
-		const void *keys[4], *patterns[2];
-		int i;
-		
-		keys[0] = SCDynamicStoreKeyCreateNetworkGlobalEntity (NULL, kSCDynamicStoreDomainState, kSCEntNetIPv4);
-		keys[1] = SCDynamicStoreKeyCreateNetworkGlobalEntity (NULL, kSCDynamicStoreDomainState, kSCEntNetIPv6);
-		keys[2] = SCDynamicStoreKeyCreateComputerName (NULL);
-		keys[3] = SCDynamicStoreKeyCreateHostNames (NULL);
-		
-		patterns[0] = SCDynamicStoreKeyCreateNetworkInterfaceEntity (NULL, kSCDynamicStoreDomainState, kSCCompAnyRegex, kSCEntNetIPv4);
-		patterns[1] = SCDynamicStoreKeyCreateNetworkInterfaceEntity (NULL, kSCDynamicStoreDomainState, kSCCompAnyRegex, kSCEntNetIPv6);
-		
-		if (keys[0] != NULL && keys[1] != NULL && keys[2] != NULL
-			&& keys[3] != NULL && patterns[0] != NULL && patterns[1] != NULL)
-		{
-			CFArrayRef key_array, pattern_array;
-			
-			key_array = CFArrayCreate (NULL, keys, 4, &kCFTypeArrayCallBacks);
-			pattern_array = CFArrayCreate (NULL, patterns, 2, &kCFTypeArrayCallBacks);
-			
-			if (key_array != NULL || pattern_array != NULL)
-			{
-				SCDynamicStoreSetNotificationKeys (ref, key_array, pattern_array);
-				source = SCDynamicStoreCreateRunLoopSource (NULL, ref, 0);
-			}
-			
-			if (key_array != NULL)
-				CFRelease (key_array);
-			if (pattern_array != NULL)
-				CFRelease (pattern_array);
-		}
-		
-		
-		for (i = 0; i < 4; i++)
-			if (keys[i] != NULL)
-			CFRelease (keys[i]);
-		for (i = 0; i < 2; i++)
-			if (patterns[i] != NULL)
-			CFRelease (patterns[i]);
-		
-		CFRelease (ref); 
-    }
-	
-    if (source != NULL)
-    {
-		CFRunLoopAddSource (CFRunLoopGetCurrent (),
-							source, kCFRunLoopDefaultMode);
-		CFRelease (source);
-    }
-	
-    return source != NULL;
-}
-
-
-/* Entrypoint. */
-
-void
-termination_signal_handler (int unused_sig)
-{
-    signal (SIGTERM, SIG_DFL);
-    signal (SIGHUP, SIG_DFL);
-    signal (SIGINT, SIG_DFL);
-    signal (SIGQUIT, SIG_DFL);
-
-    longjmp (exit_continuation, 1);
-}
-
-int
-server_main (int argc, char **argv)
-{
-    char **xargv;
-    int i, j;
-    int fd;
-	
-    xargv = alloca (sizeof (char *) * (argc + 32));
-	
-    if (!read_boolean_pref (CFSTR ("no_auth"), FALSE))
-		auth_file = XauFileName ();
-	
-    /* The standard X11 behaviour is for the server to quit when the first
-	 client exits. But it can be useful for debugging (and to mimic our
-	 behaviour in the beta releases) to not do that. */
-	
-    xinit_kills_server = read_boolean_pref (CFSTR ("xinit_kills_server"), TRUE);
-	
-    for (i = 1; i < argc; i++)
-    {
-		if (argv[i][0] == ':')
-			server_name = argv[i];
-    }
-	
-    if (server_name == NULL)
-    {
-		static char name[8];
-		
-		/* No display number specified, so search for the first unused.
-		 
-		 There's a big old race condition here if two servers start at
-		 the same time, but that's fairly unlikely. We could create
-		 lockfiles or something, but that's seems more likely to cause
-		 problems than the race condition itself.. */
-		
-		for (i = 0; i < MAX_DISPLAYS; i++)
-		{
-			if (!display_exists_p (i))
-				break;
-		}
-		
-		if (i == MAX_DISPLAYS)
-		{
-			fprintf (stderr, "%s: couldn't allocate a display number", argv[0]);
-			exit (1);
-		}
-		
-		sprintf (name, ":%d", i);
-		server_name = name;
-    }
-	
-    if (auth_file != NULL)
-    {
-		/* Create new Xauth keys and add them to the .Xauthority file */
-		
-		make_auth_keys (server_name);
-		write_auth_file (TRUE);
-    }
-	
-    /* Construct our new argv */
-	
-    i = j = 0;
-	
-    xargv[i++] = argv[j++];
-	
-    if (auth_file != NULL)
-    {
-		xargv[i++] = "-auth";
-		xargv[i++] = auth_file;
-    }
-	
-    /* By default, don't listen on tcp sockets if Xauth is disabled. */
-	
-    if (read_boolean_pref (CFSTR ("nolisten_tcp"), auth_file == NULL))
-    {
-		xargv[i++] = "-nolisten";
-		xargv[i++] = "tcp";
-    }
-	
-    while (j < argc)
-    {
-		if (argv[j++][0] != ':')
-			xargv[i++] = argv[j-1];
-    }
-	
-    xargv[i++] = (char *) server_name;
-    xargv[i++] = NULL;
-	
-    /* Detach from any controlling terminal and connect stdin to /dev/null */
-	
-#ifdef TIOCNOTTY
-    fd = open ("/dev/tty", O_RDONLY);
-    if (fd != -1)
-    {
-		ioctl (fd, TIOCNOTTY, 0);
-		close (fd);
-    }
-#endif
-	
-    fd = open ("/dev/null", O_RDWR, 0);
-    if (fd >= 0)
-    {
-		dup2 (fd, 0);
-		if (fd > 0)
-			close (fd);
-    }
-	
-    if (!start_server (xargv))
-		return 1;
-	
-    if (!wait_for_server ())
-    {
-		kill (server_pid, SIGTERM);
-		return 1;
-    }
-	
-    if (!start_client ())
-    {
-		kill (server_pid, SIGTERM);
-		return 1;
-    }
-	
-    signal (SIGCHLD, sigchld_handler);
-	
-    signal (SIGTERM, termination_signal_handler);
-    signal (SIGHUP, termination_signal_handler);
-    signal (SIGINT, termination_signal_handler);
-    signal (SIGQUIT, termination_signal_handler);
-
-    if (setjmp (exit_continuation) == 0)
-    {
-		if (install_ipaddr_source ())
-			CFRunLoopRun ();
-		else
-			while (1) pause ();
-    }
-	
-    signal (SIGCHLD, SIG_IGN);
-
-    if (client_pid >= 0) kill (client_pid, SIGTERM);
-    if (server_pid >= 0) kill (server_pid, SIGTERM);
-	
-    if (auth_file != NULL)
-    {
-		/* Remove our Xauth keys */
-		
-		write_auth_file (FALSE);
-    }
-	
-    free_auth_items ();
-	
-    return 0;
-}
commit ea716249c39f8481148f05e817c442042a620ff8
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Thu Dec 20 17:33:38 2007 -0800

    XQuartz: Don't fork to exec app_to_run.
    Plus other housecleaning...
    (cherry picked from commit ae302db472f127be082d05b418ede332fae8ccc5)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 242f98d..4203324 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -157,7 +157,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
 	
     tem = [infoDict objectForKey:@"CFBundleShortVersionString"];
 	
-    [dict setObject:[NSString stringWithFormat:@"X11.app %@ - (xorg-server %s)", tem, XSERVER_VERSION] 
+    [dict setObject:[NSString stringWithFormat:@"XQuartz %@ - (xorg-server %s)", tem, XSERVER_VERSION] 
 	  forKey:@"ApplicationVersion"];
 	
     [self orderFrontStandardAboutPanelWithOptions: dict];
diff --git a/hw/xquartz/bundle/X11.xcodeproj/project.pbxproj b/hw/xquartz/bundle/X11.xcodeproj/project.pbxproj
index 225f371..9d5c5d6 100644
--- a/hw/xquartz/bundle/X11.xcodeproj/project.pbxproj
+++ b/hw/xquartz/bundle/X11.xcodeproj/project.pbxproj
@@ -7,7 +7,6 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
-		3F5E1BE00D04BF110020CA24 /* launcher-main.c in Sources */ = {isa = PBXBuildFile; fileRef = 3F5E1BDE0D04BF110020CA24 /* launcher-main.c */; };
 		3F5E1BE10D04BF110020CA24 /* server-main.c in Sources */ = {isa = PBXBuildFile; fileRef = 3F5E1BDF0D04BF110020CA24 /* server-main.c */; };
 		527F24190B5D938C007840A7 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0867D6AAFE840B52C02AAC07 /* InfoPlist.strings */; };
 		527F241A0B5D938C007840A7 /* main.nib in Resources */ = {isa = PBXBuildFile; fileRef = 02345980000FD03B11CA0E72 /* main.nib */; };
@@ -22,7 +21,6 @@
 /* Begin PBXFileReference section */
 		0867D6ABFE840B52C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
 		1870340FFE93FCAF11CA0CD7 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/main.nib; sourceTree = "<group>"; };
-		3F5E1BDE0D04BF110020CA24 /* launcher-main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "launcher-main.c"; sourceTree = "<group>"; };
 		3F5E1BDF0D04BF110020CA24 /* server-main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "server-main.c"; sourceTree = "<group>"; };
 		50459C5F038587C60ECA21EC /* X11.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = X11.icns; sourceTree = "<group>"; };
 		50EE2AB703849F0B0ECA21EC /* bundle-main.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = "bundle-main.c"; sourceTree = "<group>"; };
@@ -69,7 +67,6 @@
 		20286C2AFDCF999611CA2CEA /* Sources */ = {
 			isa = PBXGroup;
 			children = (
-				3F5E1BDE0D04BF110020CA24 /* launcher-main.c */,
 				3F5E1BDF0D04BF110020CA24 /* server-main.c */,
 				50EE2AB703849F0B0ECA21EC /* bundle-main.c */,
 			);
@@ -176,7 +173,6 @@
 			buildActionMask = 2147483647;
 			files = (
 				527F241D0B5D938C007840A7 /* bundle-main.c in Sources */,
-				3F5E1BE00D04BF110020CA24 /* launcher-main.c in Sources */,
 				3F5E1BE10D04BF110020CA24 /* server-main.c in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
diff --git a/hw/xquartz/bundle/bundle-main.c b/hw/xquartz/bundle/bundle-main.c
index 681e1a8..ed41e68 100644
--- a/hw/xquartz/bundle/bundle-main.c
+++ b/hw/xquartz/bundle/bundle-main.c
@@ -32,18 +32,23 @@
 #include <unistd.h>
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
 
-int launcher_main(int argc, char **argv);
+#include <CoreFoundation/CoreFoundation.h>
+
+#define DEFAULT_APP "/usr/X11/bin/xterm"
+
+static int launcher_main(int argc, char **argv);
 int server_main(int argc, char **argv);
 
 int main(int argc, char **argv) {
     Display *display;
 
-    //size_t i;
-    //fprintf(stderr, "X11.app: main(): argc=%d\n", argc);
-    //for(i=0; i < argc; i++) {
-    //    fprintf(stderr, "\targv[%u] = %s\n", (unsigned)i, argv[i]);
-    //}
+    size_t i;
+    fprintf(stderr, "X11.app: main(): argc=%d\n", argc);
+    for(i=0; i < argc; i++) {
+        fprintf(stderr, "\targv[%u] = %s\n", (unsigned)i, argv[i]);
+    }
     
     /* If we have a process serial number and it's our only arg, act as if
      * the user double clicked the app bundle: launch app_to_run if possible
@@ -52,7 +57,7 @@ int main(int argc, char **argv) {
         /* Now, try to open a display, if so, run the launcher */
         display = XOpenDisplay(NULL);
         if(display) {
-            fprintf(stderr, "X11.app: main(): closing the display and sleeping");
+            fprintf(stderr, "X11.app: closing the display and sleeping for 2s to allow the X server to start up.\n");
             /* Could open the display, start the launcher */
             XCloseDisplay(display);
             
@@ -60,13 +65,49 @@ int main(int argc, char **argv) {
              * TODO: *Really* fix this race condition
              */
             usleep(2000);
-            //fprintf(stderr, "X11.app: main(): running launcher_main()");
             return launcher_main(argc, argv);
         }
     }
     
     /* Start the server */
-    //fprintf(stderr, "X11.app: main(): running server_main()");
+    fprintf(stderr, "X11.app: main(): running server_main()");
     return server_main(argc, argv);
 }
 
+int launcher_main (int argc, char **argv) {
+    char *command = DEFAULT_APP;
+    const char *newargv[7];
+    int child;
+    const char **s;
+    
+	CFPropertyListRef PlistRef = CFPreferencesCopyAppValue(CFSTR("app_to_run"), kCFPreferencesCurrentApplication);
+	
+	if ((PlistRef == NULL) || (CFGetTypeID(PlistRef) != CFStringGetTypeID())) {
+		CFPreferencesSetAppValue(CFSTR("app_to_run"), CFSTR(DEFAULT_APP), kCFPreferencesCurrentApplication);
+		CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
+	} else {
+		int len = CFStringGetLength((CFStringRef)PlistRef)+1;
+		command = (char *)malloc(len);
+		CFStringGetCString((CFStringRef)PlistRef, command, len,  kCFStringEncodingASCII);
+		fprintf(stderr, "command=%s\n", command);
+	}
+
+	if (PlistRef) CFRelease(PlistRef);
+
+	newargv[0] = "/usr/bin/login";
+	newargv[1] = "-fp";
+	newargv[2] = getlogin();
+	newargv[3] = "/bin/sh";
+	newargv[4] = "-c";
+	newargv[5] = command;
+	newargv[6] = NULL;
+
+    fprintf(stderr, "X11.app: Launching X11 Application:\n");
+    for(s=newargv; *s; s++) {
+        fprintf(stderr, "\targv[%d] = %s\n", s - newargv, *s);
+    }
+
+    execvp (newargv[0], (const char **) newargv);
+    perror ("X11.app: Couldn't exec.");
+    return(1);
+}
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index 43f2712..ad46a3f 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -150,8 +150,9 @@ void
 DarwinPrintBanner(void)
 { 
   // this should change depending on which specific server we are building
-  ErrorF("X11.app starting:\n");
-  ErrorF("X.Org Xquartz X Server %s\nBuild Date: %s\n", XSERVER_VERSION, BUILD_DATE );
+  ErrorF("XQuartz starting:\n");
+  ErrorF("X.org Release 7.2\n"); // This is here to help fink until they fix their packages.
+  ErrorF("X.Org X Server %s\nBuild Date: %s\n", XSERVER_VERSION, BUILD_DATE );
 }
 
 
commit 47a5869ba378e10ad6f0599249fb5cd8b2e833c0
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Thu Dec 20 15:46:40 2007 -0800

    Xquartz: Use X11ControllerMain()
    (cherry picked from commit a9ac932543374aa2540f5a12cc85ef82c85b0e0c)

diff --git a/hw/xquartz/X11Application.h b/hw/xquartz/X11Application.h
index c42e6a5..a1be751 100644
--- a/hw/xquartz/X11Application.h
+++ b/hw/xquartz/X11Application.h
@@ -72,7 +72,7 @@ void X11ApplicationSetCanQuit (int state);
 void X11ApplicationServerReady (void);
 void X11ApplicationShowHideMenubar (int state);
 
-void X11ApplicationMain(int argc, char **argv, void (*server_thread) (void *), void *server_arg);
+void X11ApplicationMain(int argc, const char **argv, void (*server_thread) (void *), void *server_arg);
 
 extern int X11EnableKeyEquivalents;
 extern int quartzHasRoot, quartzEnableRootless;
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 571c707..242f98d 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -794,7 +794,7 @@ environment?", @"Startup xinitrc dialog");
     [X11App prefs_synchronize];
 }
 
-void X11ApplicationMain (int argc, char **argv, void (*server_thread) (void *), void *server_arg) {
+void X11ApplicationMain (int argc, const char **argv, void (*server_thread) (void *), void *server_arg) {
     NSAutoreleasePool *pool;
 
 #ifdef DEBUG
diff --git a/hw/xquartz/X11Controller.h b/hw/xquartz/X11Controller.h
index bfbb04f..47f5220 100644
--- a/hw/xquartz/X11Controller.h
+++ b/hw/xquartz/X11Controller.h
@@ -78,4 +78,6 @@
 
 #endif /* __OBJC__ */
 
+void X11ControllerMain(int argc, const char **argv, void (*server_thread) (void *), void *server_arg);
+
 #endif /* X11CONTROLLER_H */
diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m
index ecd88ab..6b7c351 100644
--- a/hw/xquartz/X11Controller.m
+++ b/hw/xquartz/X11Controller.m
@@ -741,3 +741,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
 }
 
 @end
+
+void X11ControllerMain(int argc, const char **argv, void (*server_thread) (void *), void *server_arg) {
+    X11ApplicationMain (argc, argv, server_thread, server_arg);
+}
diff --git a/hw/xquartz/quartzStartup.c b/hw/xquartz/quartzStartup.c
index 50ce2a6..8600ec8 100644
--- a/hw/xquartz/quartzStartup.c
+++ b/hw/xquartz/quartzStartup.c
@@ -35,7 +35,7 @@
 #include <unistd.h>
 #include <CoreFoundation/CoreFoundation.h>
 #include "quartzCommon.h"
-#include "X11Application.h"
+#include "X11Controller.h"
 #include "darwin.h"
 #include "quartz.h"
 #include "opaque.h"
@@ -106,6 +106,6 @@ void DarwinHandleGUI(int argc, char **argv, char **envp) {
     extern void _InitHLTB(void);
     
     _InitHLTB();    
-    X11ApplicationMain(argc, argv, server_thread, NULL);
+    X11ControllerMain(argc, argv, server_thread, NULL);
     exit(0);
 }
commit be027ea7ea1b31e824535de2411e8cc8affeb82c
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Thu Dec 20 13:17:30 2007 -0800

    Xquartz: General Cleanup
    General code cleanup, whitespace, dead code removal, added missing prototypes.
    Made Xquartz come to foreground later in startup, so it doesn't appear for Xquartz -version
    (cherry picked from commit 36922e8ff4316c93843aa3fe959cf8df3c7d5892)

diff --git a/dix/main.c b/dix/main.c
index 06f022b..8b57e12 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -241,6 +241,10 @@ static int indexForScanlinePad[ 65 ] = {
 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
 #endif
 
+#ifdef __APPLE__
+void DarwinHandleGUI(int argc, char **argv, char **envp);
+#endif
+
 int
 main(int argc, char *argv[], char *envp[])
 {
diff --git a/hw/xquartz/X11Application.h b/hw/xquartz/X11Application.h
index 8615657..c42e6a5 100644
--- a/hw/xquartz/X11Application.h
+++ b/hw/xquartz/X11Application.h
@@ -64,40 +64,38 @@ extern X11Application *X11App;
 
 #endif /* __OBJC__ */
 
-extern void X11ApplicationSetWindowMenu (int nitems, const char **items,
+void X11ApplicationSetWindowMenu (int nitems, const char **items,
 					 const char *shortcuts);
-extern void X11ApplicationSetWindowMenuCheck (int idx);
-extern void X11ApplicationSetFrontProcess (void);
-extern void X11ApplicationSetCanQuit (int state);
-extern void X11ApplicationServerReady (void);
-extern void X11ApplicationShowHideMenubar (int state);
+void X11ApplicationSetWindowMenuCheck (int idx);
+void X11ApplicationSetFrontProcess (void);
+void X11ApplicationSetCanQuit (int state);
+void X11ApplicationServerReady (void);
+void X11ApplicationShowHideMenubar (int state);
 
-extern void X11ApplicationMain (int argc, const char *argv[],
-				void (*server_thread) (void *),
-				void *server_arg);
+void X11ApplicationMain(int argc, char **argv, void (*server_thread) (void *), void *server_arg);
 
 extern int X11EnableKeyEquivalents;
 extern int quartzHasRoot, quartzEnableRootless;
 
 #define APP_PREFS "org.x.X11"
 
-#define PREFS_APPSMENU		"apps_menu"
-#define PREFS_FAKEBUTTONS	"enable_fake_buttons"
-#define PREFS_SYSBEEP		"enable_system_beep"
-#define PREFS_KEYEQUIVS		"enable_key_equivalents"
-#define PREFS_KEYMAP_FILE	"keymap_file"
-#define PREFS_SYNC_KEYMAP	"sync_keymap"
-#define PREFS_DEPTH		"depth"
-#define PREFS_NO_AUTH		"no_auth"
-#define PREFS_NO_TCP		"nolisten_tcp"
-#define PREFS_DONE_XINIT_CHECK	"done_xinit_check"
-#define PREFS_NO_QUIT_ALERT	"no_quit_alert"
-#define PREFS_FAKE_BUTTON2	"fake_button2"
-#define PREFS_FAKE_BUTTON3	"fake_button3"
-#define PREFS_ROOTLESS		"rootless"
-#define PREFS_FULLSCREEN_HOTKEYS "fullscreen_hotkeys"
-#define PREFS_SWAP_ALT_META	"swap_alt_meta"
-#define PREFS_XP_OPTIONS	"xp_options"
-#define PREFS_ENABLE_STEREO	"enable_stereo"
+#define PREFS_APPSMENU              "apps_menu"
+#define PREFS_FAKEBUTTONS           "enable_fake_buttons"
+#define PREFS_SYSBEEP               "enable_system_beep"
+#define PREFS_KEYEQUIVS             "enable_key_equivalents"
+#define PREFS_KEYMAP_FILE           "keymap_file"
+#define PREFS_SYNC_KEYMAP           "sync_keymap"
+#define PREFS_DEPTH                 "depth"
+#define PREFS_NO_AUTH               "no_auth"
+#define PREFS_NO_TCP                "nolisten_tcp"
+#define PREFS_DONE_XINIT_CHECK      "done_xinit_check"
+#define PREFS_NO_QUIT_ALERT         "no_quit_alert"
+#define PREFS_FAKE_BUTTON2          "fake_button2"
+#define PREFS_FAKE_BUTTON3          "fake_button3"
+#define PREFS_ROOTLESS              "rootless"
+#define PREFS_FULLSCREEN_HOTKEYS    "fullscreen_hotkeys"
+#define PREFS_SWAP_ALT_META         "swap_alt_meta"
+#define PREFS_XP_OPTIONS            "xp_options"
+#define PREFS_ENABLE_STEREO         "enable_stereo"
 
 #endif /* X11APPLICATION_H */
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index aaecd0d..571c707 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -32,6 +32,7 @@
 #endif
 
 #include "quartzCommon.h"
+#include "quartzForeground.h"
 
 #import "X11Application.h"
 #include <Carbon/Carbon.h>
@@ -86,8 +87,8 @@ static mach_port_t _port;
 static void send_nsevent (NSEventType type, NSEvent *e);
 
 /* Quartz mode initialization routine. This is often dynamically loaded
- but is statically linked into this X server. */
-extern Bool QuartzModeBundleInit(void);
+   but is statically linked into this X server. */
+Bool QuartzModeBundleInit(void);
 
 static void init_ports (void) {
     kern_return_t r;
@@ -793,44 +794,43 @@ environment?", @"Startup xinitrc dialog");
     [X11App prefs_synchronize];
 }
 
-void X11ApplicationMain (int argc, const char *argv[],
-			 void (*server_thread) (void *), void *server_arg) {
-  NSAutoreleasePool *pool;
-  
+void X11ApplicationMain (int argc, char **argv, void (*server_thread) (void *), void *server_arg) {
+    NSAutoreleasePool *pool;
+
 #ifdef DEBUG
-  while (access ("/tmp/x11-block", F_OK) == 0) sleep (1);
+    while (access ("/tmp/x11-block", F_OK) == 0) sleep (1);
 #endif
   
-  pool = [[NSAutoreleasePool alloc] init];
-  X11App = (X11Application *) [X11Application sharedApplication];
-  init_ports ();
-  [NSApp read_defaults];
-  [NSBundle loadNibNamed:@"main" owner:NSApp];
-  [[NSNotificationCenter defaultCenter] addObserver:NSApp
+    pool = [[NSAutoreleasePool alloc] init];
+    X11App = (X11Application *) [X11Application sharedApplication];
+    init_ports ();
+    [NSApp read_defaults];
+    [NSBundle loadNibNamed:@"main" owner:NSApp];
+    [[NSNotificationCenter defaultCenter] addObserver:NSApp
 					selector:@selector (became_key:)
 					name:NSWindowDidBecomeKeyNotification object:nil];
-  check_xinitrc ();
-	
-  /*
-   * The xpr Quartz mode is statically linked into this server.
-   * Initialize all the Quartz functions.
-   */
-  QuartzModeBundleInit();
-  
-  /* Calculate the height of the menubar so we can avoid it. */
-  aquaMenuBarHeight = NSHeight([[NSScreen mainScreen] frame]) -
+    check_xinitrc ();
+
+    /*
+     * The xpr Quartz mode is statically linked into this server.
+     * Initialize all the Quartz functions.
+     */
+    QuartzModeBundleInit();
+
+    /* Calculate the height of the menubar so we can avoid it. */
+    aquaMenuBarHeight = NSHeight([[NSScreen mainScreen] frame]) -
     NSMaxY([[NSScreen mainScreen] visibleFrame]);
   
-  if (!create_thread (server_thread, server_arg)) {
-    ErrorF("can't create secondary thread\n");
-    exit (1);
-  }
-  
-  [NSApp run];
-  
-  /* not reached */
-}
+    if (!create_thread (server_thread, server_arg)) {
+        ErrorF("can't create secondary thread\n");
+        exit (1);
+    }
+
+    QuartzMoveToForeground();
 
+    [NSApp run];
+    /* not reached */
+}
 
 /* event conversion */
 
diff --git a/hw/xquartz/X11Controller.h b/hw/xquartz/X11Controller.h
index f1399dc..bfbb04f 100644
--- a/hw/xquartz/X11Controller.h
+++ b/hw/xquartz/X11Controller.h
@@ -78,8 +78,4 @@
 
 #endif /* __OBJC__ */
 
-extern void X11ControllerMain (int argc, const char *argv[],
-			       void (*server_thread) (void *),
-			       void *server_arg);
-
 #endif /* X11CONTROLLER_H */
diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m
index 0f64e45..ecd88ab 100644
--- a/hw/xquartz/X11Controller.m
+++ b/hw/xquartz/X11Controller.m
@@ -337,7 +337,7 @@
       /* Setup environment */
       temp = getenv("DISPLAY");
       if (temp == NULL || temp[0] == 0) {
-	snprintf(buf, sizeof(buf), ":%s", display);
+    snprintf(buf, sizeof(buf), ":%s", display);
 	setenv("DISPLAY", buf, TRUE);
       }
 	
@@ -741,9 +741,3 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
 }
 
 @end
-
-void X11ControllerMain (int argc, const char *argv[],
-			void (*server_thread) (void *), void *server_arg)
-{
-  X11ApplicationMain (argc, argv, server_thread, server_arg);
-}
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index aaed261..43f2712 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -722,16 +722,6 @@ int ddxProcessArgument( int argc, char *argv[], int i )
         return 1;
     }
 
-    if ( !strcmp( argv[i], "-quartz" ) ) {
-        ErrorF( "Running in parallel with Mac OS X Quartz window server.\n" );
-        return 1;
-    }
-
-    // The Mac OS X front end uses this argument, which we just ignore here.
-    if ( !strcmp( argv[i], "-nostartx" ) ) {
-        return 1;
-    }
-
     // This command line arg is passed when launched from the Aqua GUI.
     if ( !strncmp( argv[i], "-psn_", 5 ) ) {
         return 1;
@@ -883,9 +873,9 @@ void ddxUseMsg( void )
     ErrorF("-keymap <file> : read the keymapping from a file instead of the kernel.\n");
     ErrorF("-version : show the server version.\n");
     ErrorF("\n");
-    ErrorF("Quartz modes (Experimental / In Development):\n");
-    ErrorF("-fullscreen : run full screen in parallel with Mac OS X window server.\n");
-    ErrorF("-rootless : run rootless inside Mac OS X window server.\n");
+//    ErrorF("Quartz modes (Experimental / In Development):\n");
+//    ErrorF("-fullscreen : run full screen in parallel with Mac OS X window server.\n");
+//    ErrorF("-rootless : run rootless inside Mac OS X window server.\n");
     ErrorF("\n");
     ErrorF("Options ignored in rootless mode:\n");
     ErrorF("-size <height> <width> : use a screen resolution of <height> x <width>.\n");
@@ -903,7 +893,8 @@ void ddxGiveUp( void )
 {
     ErrorF( "Quitting XQuartz...\n" );
 
-    QuartzGiveUp();
+    //if (!quartzRootless)
+    //    quartzProcs->ReleaseScreens();
 }
 
 
diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index 7be91ec..549ad09 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -61,7 +61,6 @@
 
 // Shared global variables for Quartz modes
 int                     quartzEventWriteFD = -1;
-int                     quartzStartClients = 1;
 int                     quartzRootless = -1;
 int                     quartzUseSysBeep = 0;
 int                     quartzUseAGL = 1;
@@ -416,12 +415,10 @@ QuartzMessageServerThread(
  * QuartzProcessEvent
  *  Process Quartz specific events.
  */
-void QuartzProcessEvent(
-    xEvent *xe)
-{
+void QuartzProcessEvent(xEvent *xe) {
     switch (xe->u.u.type) {
         case kXDarwinControllerNotify:
-	  DEBUG_LOG("kXDarwinControllerNotify\n");
+            DEBUG_LOG("kXDarwinControllerNotify\n");
             AppleWMSendEvent(AppleWMControllerNotify,
                              AppleWMControllerNotifyMask,
                              xe->u.clientMessage.u.l.longs0,
@@ -429,7 +426,7 @@ void QuartzProcessEvent(
             break;
 
         case kXDarwinPasteboardNotify:
-	  DEBUG_LOG("kXDarwinPasteboardNotify\n");
+            DEBUG_LOG("kXDarwinPasteboardNotify\n");
             AppleWMSendEvent(AppleWMPasteboardNotify,
                              AppleWMPasteboardNotifyMask,
                              xe->u.clientMessage.u.l.longs0,
@@ -437,7 +434,7 @@ void QuartzProcessEvent(
             break;
 
         case kXDarwinActivate:
-	  DEBUG_LOG("kXDarwinActivate\n");
+            DEBUG_LOG("kXDarwinActivate\n");
             QuartzShow(xe->u.keyButtonPointer.rootX,
                        xe->u.keyButtonPointer.rootY);
             AppleWMSendEvent(AppleWMActivationNotify,
@@ -446,7 +443,7 @@ void QuartzProcessEvent(
             break;
 
         case kXDarwinDeactivate:
-  	  DEBUG_LOG("kXDarwinDeactivate\n");
+            DEBUG_LOG("kXDarwinDeactivate\n");
             AppleWMSendEvent(AppleWMActivationNotify,
                              AppleWMActivationNotifyMask,
                              AppleWMIsInactive, 0);
@@ -454,23 +451,23 @@ void QuartzProcessEvent(
             break;
 
         case kXDarwinDisplayChanged:
-	    DEBUG_LOG("kXDarwinDisplayChanged\n");
+            DEBUG_LOG("kXDarwinDisplayChanged\n");
             QuartzUpdateScreens();
             break;
 
         case kXDarwinWindowState:
-	  DEBUG_LOG("kXDarwinWindowState\n");
+            DEBUG_LOG("kXDarwinWindowState\n");
             RootlessNativeWindowStateChanged(xe->u.clientMessage.u.l.longs0,
 		  			     xe->u.clientMessage.u.l.longs1);
 	    break;
 	  
         case kXDarwinWindowMoved:
-	  DEBUG_LOG("kXDarwinWindowMoved\n");
-	  RootlessNativeWindowMoved ((WindowPtr)xe->u.clientMessage.u.l.longs0);
+            DEBUG_LOG("kXDarwinWindowMoved\n");
+            RootlessNativeWindowMoved ((WindowPtr)xe->u.clientMessage.u.l.longs0);
 	    break;
 
         case kXDarwinToggleFullscreen:
-	  DEBUG_LOG("kXDarwinToggleFullscreen\n");
+            DEBUG_LOG("kXDarwinToggleFullscreen\n");
 #ifdef DARWIN_DDX_MISSING
             if (quartzEnableRootless) QuartzSetFullscreen(!quartzHasRoot);
             else if (quartzHasRoot) QuartzHide();
@@ -481,6 +478,7 @@ void QuartzProcessEvent(
             break;
 
         case kXDarwinSetRootless:
+            DEBUG_LOG("kXDarwinSetRootless\n");
 #ifdef DARWIN_DDX_MISSING
             QuartzSetRootless(xe->u.clientMessage.u.l.longs0);
             if (!quartzEnableRootless && !quartzHasRoot) QuartzHide();
@@ -506,34 +504,11 @@ void QuartzProcessEvent(
             break;
 
         case kXDarwinBringAllToFront:
-  	  DEBUG_LOG("kXDarwinBringAllToFront\n");
-	    RootlessOrderAllWindows();
+            DEBUG_LOG("kXDarwinBringAllToFront\n");
+            RootlessOrderAllWindows();
             break;
 
         default:
             ErrorF("Unknown application defined event type %d.\n", xe->u.u.type);
     }
 }
-
-
-/*
- * QuartzGiveUp
- *  Cleanup before X server shutdown
- *  Release the screen and restore the Aqua cursor.
- */
-void QuartzGiveUp(void)
-{
-#if 0
-// Trying to switch cursors when quitting causes deadlock
-    int i;
-
-    for (i = 0; i < screenInfo.numScreens; i++) {
-        if (screenInfo.screens[i]) {
-            QuartzSuspendXCursor(screenInfo.screens[i]);
-        }
-    }
-#endif
-
-    if (!quartzRootless)
-        quartzProcs->ReleaseScreens();
-}
diff --git a/hw/xquartz/quartzCommon.h b/hw/xquartz/quartzCommon.h
index f0d5a7a..6379f92 100644
--- a/hw/xquartz/quartzCommon.h
+++ b/hw/xquartz/quartzCommon.h
@@ -63,7 +63,6 @@ typedef struct {
 
 // Data stored at startup for Cocoa front end
 extern int              quartzEventWriteFD;
-extern int              quartzStartClients;
 
 // User preferences used by Quartz modes
 extern int              quartzRootless;
diff --git a/hw/xquartz/quartzStartup.c b/hw/xquartz/quartzStartup.c
index 87bcada..50ce2a6 100644
--- a/hw/xquartz/quartzStartup.c
+++ b/hw/xquartz/quartzStartup.c
@@ -34,8 +34,8 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <CoreFoundation/CoreFoundation.h>
-#include "quartzForeground.h"
 #include "quartzCommon.h"
+#include "X11Application.h"
 #include "darwin.h"
 #include "quartz.h"
 #include "opaque.h"
@@ -52,9 +52,6 @@
 char **envpGlobal;      // argcGlobal and argvGlobal
                         // are from dix/globals.c
 
-
-void X11ControllerMain(int argc, char *argv[], void (*server_thread) (void *), void *server_arg);
-
 static void server_thread (void *arg) {
   extern int main(int argc, char **argv, char **envp);
   exit (main (argcGlobal, argvGlobal, envpGlobal));
@@ -68,22 +65,16 @@ static void server_thread (void *arg) {
  *  server. On the second call this function loads the user
  *  preferences set by the Mac OS X front end.
  */
-void DarwinHandleGUI(
-    int         argc,
-    char        *argv[],
-    char        *envp[] )
-{
+void DarwinHandleGUI(int argc, char **argv, char **envp) {
     static Bool been_here = FALSE;
     int         i;
     int         fd[2];
 
-    QuartzMoveToForeground();
-    
     if (been_here) {
         return;
     }
     been_here = TRUE;
-
+    
     // Make a pipe to pass events
     assert( pipe(fd) == 0 );
     darwinEventReadFD = fd[0];
@@ -95,26 +86,14 @@ void DarwinHandleGUI(
     argvGlobal = argv;
     envpGlobal = envp;
 
-    quartzStartClients = 1;
     for (i = 1; i < argc; i++) {
         // Display version info without starting Mac OS X UI if requested
         if (!strcmp( argv[i], "-showconfig" ) || !strcmp( argv[i], "-version" )) {
             DarwinPrintBanner();
             exit(0);
         }
-
-        // Determine if we need to start X clients
-        // and what display mode to use
-        if (!strcmp(argv[i], "-nostartx")) {
-            quartzStartClients = 0;    
-        } else if (!strcmp( argv[i], "-fullscreen")) {
-            quartzRootless = 0;
-        } else if (!strcmp( argv[i], "-rootless")) {
-            quartzRootless = 1;
-        }
     }
 
-
     /* Initially I ran the X server on the main thread, and received
        events on the second thread. But now we may be using Carbon,
        that needs to run on the main thread. (Otherwise, when it's
@@ -127,6 +106,6 @@ void DarwinHandleGUI(
     extern void _InitHLTB(void);
     
     _InitHLTB();    
-    X11ControllerMain(argc, argv, server_thread, NULL);
+    X11ApplicationMain(argc, argv, server_thread, NULL);
     exit(0);
 }
diff --git a/hw/xquartz/xpr/xpr.h b/hw/xquartz/xpr/xpr.h
index ddc6d0c..b8c69df 100644
--- a/hw/xquartz/xpr/xpr.h
+++ b/hw/xquartz/xpr/xpr.h
@@ -31,7 +31,7 @@
 
 #include "screenint.h"
 
-extern Bool QuartzModeBundleInit(void);
+Bool QuartzModeBundleInit(void);
 
 void AppleDRIExtensionInit(void);
 void xprAppleWMInit(void);
commit 17c0ad3d959f30d06c226fa04aade5579d109c83
Author: Ben Byer <bbyer at bbyer.local>
Date:   Sun Dec 16 04:20:19 2007 -0800

    adding default prefix to autogen script

diff --git a/autogen.sh b/autogen.sh
index 904cd67..98d22ea 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -9,4 +9,4 @@ cd $srcdir
 autoreconf -v --install || exit 1
 cd $ORIGDIR || exit $?
 
-$srcdir/configure --enable-maintainer-mode "$@"
+$srcdir/configure --prefix=/usr/X11 --enable-maintainer-mode "$@"
commit 88f289dd1ca595d2741662b5cd230012e4388abe
Author: Ben Byer <bbyer at bbyer.local>
Date:   Sun Dec 16 04:19:01 2007 -0800

    adding AM_OBJCFLAGS

diff --git a/hw/xquartz/Makefile.am b/hw/xquartz/Makefile.am
index b026ee1..1f19102 100644
--- a/hw/xquartz/Makefile.am
+++ b/hw/xquartz/Makefile.am
@@ -1,5 +1,6 @@
 noinst_LTLIBRARIES = libXquartz.la
 AM_CFLAGS = $(XSERVER_CFLAGS) $(DIX_CFLAGS)
+AM_OBJCFLAGS = $(XSERVER_CFLAGS) $(DIX_CFLAGS)
 AM_CPPFLAGS = \
 	-DBUILD_DATE=\"$(BUILD_DATE)\" \
 	-DINXQUARTZ \
commit 39b20011b7f0c77da5719053c19cd2dea21a206a
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Sun Dec 16 01:14:32 2007 -0800

    Xquartz: Removed launchd plist and x11-exec.  The relevant code is now in xinit.
    (cherry picked from commit 767b4c9d9daa5d0ea59ac1f0d70146798da631cb)

diff --git a/hw/xquartz/Makefile.am b/hw/xquartz/Makefile.am
index 69a5c91..b026ee1 100644
--- a/hw/xquartz/Makefile.am
+++ b/hw/xquartz/Makefile.am
@@ -9,12 +9,6 @@ AM_CPPFLAGS = \
 
 if X11APP
 X11APP_SUBDIRS = bundle
-
-if LAUNCHD
-libexec_PROGRAMS = x11-exec
-x11_exec_LDFLAGS = -framework CoreServices
-endif
-
 endif
 
 SUBDIRS = . xpr $(X11APP_SUBDIRS)
diff --git a/hw/xquartz/bundle/Makefile.am b/hw/xquartz/bundle/Makefile.am
index da297e9..9511670 100644
--- a/hw/xquartz/bundle/Makefile.am
+++ b/hw/xquartz/bundle/Makefile.am
@@ -8,17 +8,6 @@ x11app:
 install-data-hook:
 	xcodebuild install DSTROOT="/$(DESTDIR)" INSTALL_PATH="$(APPLE_APPLICATIONS_DIR)" DEPLOYMENT_LOCATION=YES SKIP_INSTALL=NO ARCHS="$(X11APP_ARCHS)"
 
-if LAUNCHD
-launchagents_PRE = org.x.X11.plist.pre
-launchagents_DATA = $(launchagents_PRE:plist.pre=plist)
-
-CPP_FILES_FLAGS = -D__libexecdir__="${libexecdir}"
-
-CLEANFILES = $(launchagents_DATA)
-endif
-
-include $(top_srcdir)/cpprules.in
-
 clean-local:
 	rm -rf build
 
@@ -26,7 +15,6 @@ resourcedir=$(libdir)/X11/xserver
 resource_DATA = Xquartz.plist
 
 EXTRA_DIST = \
-	org.x.X11.plist \
 	Info.plist \
 	X11.icns \
 	bundle-main.c \
diff --git a/hw/xquartz/bundle/org.x.X11.plist.pre b/hw/xquartz/bundle/org.x.X11.plist.pre
deleted file mode 100644
index 83d8b2f..0000000
--- a/hw/xquartz/bundle/org.x.X11.plist.pre
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>Label</key>
-		<string>org.x.X11</string>
-	<key>ProgramArguments</key>
-		<array>
-		<string>__libexecdir__/x11-exec</string>
-		<string>-launchd</string>
-		</array>
-	<key>Sockets</key>
-		<dict>
-		<key>:0</key>
-			<dict>
-			<key>SecureSocketWithKey</key>
-				<string>DISPLAY</string>
-			</dict>
-		</dict>
-	<key>ServiceIPC</key>
-		<true/>
-</dict>
-</plist>
diff --git a/hw/xquartz/x11-exec.c b/hw/xquartz/x11-exec.c
deleted file mode 100644
index 105fd72..0000000
--- a/hw/xquartz/x11-exec.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/* x11-exec.c -- Find X11.app by bundle-id and exec it.  This is so launchd
-   can correctly find X11.app, even if the user moved it.
-
- Copyright (c) 2007 Apple, Inc.
- 
- 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 <CoreServices/CoreServices.h>
-#include <stdio.h>
-
-#define kX11AppBundleId "org.x.X11"
-#define kX11AppBundlePath "/Contents/MacOS/X11"
-
-int main(int argc, char **argv) {
-  char x11_path[PATH_MAX];
-  char** args = NULL;
-  CFURLRef appURL = NULL;
-  OSStatus osstatus = LSFindApplicationForInfo(kLSUnknownCreator, CFSTR(kX11AppBundleId), 
-					       nil, nil, &appURL);
-  
-  switch (osstatus) {
-  case noErr:
-    if (appURL == NULL) {
-      fprintf(stderr, "%s: Invalid response from LSFindApplicationForInfo(%s)\n", 
-	      argv[0], kX11AppBundleId);
-      exit(1);
-    }
-    if (!CFURLGetFileSystemRepresentation(appURL, true, (unsigned char *)x11_path, sizeof(x11_path))) {
-      fprintf(stderr, "%s: Error resolving URL for %s\n", argv[0], kX11AppBundleId);
-      exit(2);
-    }
-    
-    args = (char**)malloc(sizeof (char*) * (argc + 1));
-    strlcat(x11_path, kX11AppBundlePath, sizeof(x11_path));
-    if (args) {
-      int i;
-      args[0] = x11_path;
-      for (i = 1; i < argc; ++i) {
-        args[i] = argv[i];
-      }
-      args[i] = NULL;
-    }
-    
-    fprintf(stderr, "X11.app = %s\n", x11_path);
-    execv(x11_path, args);
-    fprintf(stderr, "Error executing X11.app (%s):", x11_path);
-    perror(NULL);
-    exit(3);
-    break;
-  case kLSApplicationNotFoundErr:
-    fprintf(stderr, "%s: Unable to find application for %s\n", argv[0], kX11AppBundleId);
-    exit(4);
-  default:
-    fprintf(stderr, "%s: Unable to find application for %s, error code = %d\n", 
-	    argv[0], kX11AppBundleId, osstatus);
-    exit(5);
-  }
-  /* not reached */
-}
-
-    
commit 641227883c1901e581cd3b9dbbf615078140dce2
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Sat Dec 15 14:00:56 2007 -0800

    Xquartz: Fixed launchd detection

diff --git a/configure.ac b/configure.ac
index eee0d23..f95d0de 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1796,6 +1796,7 @@ if test "x$LAUNCHD" = "xauto"; then
 	if test "x$XQUARTZ" = "xyes" ; then
 		LAUNCHD=yes
 	else
+		unset LAUNCHD
 		AC_CHECK_PROG(LAUNCHD, [launchd], [yes], [no])
 	fi
 fi
commit b709718a6983dbd0d3badcde60be271d0d7aff52
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Thu Dec 13 20:46:33 2007 -0800

    Silence FPE error message; according to ajax, this bug is known
    but not worth fixing.
    (cherry picked from commit 1033eb03368701dc4a52f40a737341b2931ab986)

diff --git a/dix/dixfonts.c b/dix/dixfonts.c
index c21b3ec..e7c349d 100644
--- a/dix/dixfonts.c
+++ b/dix/dixfonts.c
@@ -1628,9 +1628,9 @@ FreeFontPath(FontPathElementPtr *list, int n, Bool force)
 		    found++;
 	    }
 	    if (list[i]->refcount != found) {
-		ErrorF("FreeFontPath: FPE \"%.*s\" refcount is %d, should be %d; fixing.\n",
+      /*		ErrorF("FreeFontPath: FPE \"%.*s\" refcount is %d, should be %d; fixing.\n",
 		       list[i]->name_length, list[i]->name,
-		       list[i]->refcount, found);
+		       list[i]->refcount, found); */
 		list[i]->refcount = found; /* ensure it will get freed */
 	    }
 	}
commit 16c032a602f404d09e028608457222171bc17d61
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Thu Dec 13 20:45:14 2007 -0800

    clarified debug message to indicate that we're sleeping
    (in case we get reports about slow launch times, this will
    help clarify what's happening)
    (cherry picked from commit 2eea3483cf893f8f81bacd434b31408dfb38cb06)

diff --git a/hw/xquartz/bundle/bundle-main.c b/hw/xquartz/bundle/bundle-main.c
index 53f60a3..681e1a8 100644
--- a/hw/xquartz/bundle/bundle-main.c
+++ b/hw/xquartz/bundle/bundle-main.c
@@ -52,7 +52,7 @@ int main(int argc, char **argv) {
         /* Now, try to open a display, if so, run the launcher */
         display = XOpenDisplay(NULL);
         if(display) {
-            fprintf(stderr, "X11.app: main(): closing the display");
+            fprintf(stderr, "X11.app: main(): closing the display and sleeping");
             /* Could open the display, start the launcher */
             XCloseDisplay(display);
             
commit 4346e6b5dd7d51efab01f6a6fc4d6ba180661c91
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Thu Dec 13 20:44:33 2007 -0800

    we need to link against CoreServices, not ApplicationServices
    (cherry picked from commit ba4d2096e7953ef5b971682f0e28535da968acb1)

diff --git a/hw/xquartz/Makefile.am b/hw/xquartz/Makefile.am
index b40a4f5..69a5c91 100644
--- a/hw/xquartz/Makefile.am
+++ b/hw/xquartz/Makefile.am
@@ -12,7 +12,7 @@ X11APP_SUBDIRS = bundle
 
 if LAUNCHD
 libexec_PROGRAMS = x11-exec
-x11_exec_LDFLAGS = -framework ApplicationServices
+x11_exec_LDFLAGS = -framework CoreServices
 endif
 
 endif
commit 077d54c6892d24d4d5f7359d7af800e19d610fd7
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Thu Dec 13 20:40:27 2007 -0800

    fixed bug in x11-exec that prevent icon from showing up
    (cherry picked from commit e1f4a0c20d3a52d98954c4b28d0ec4d44564bc32)

diff --git a/hw/xquartz/x11-exec.c b/hw/xquartz/x11-exec.c
index d0b5c49..105fd72 100644
--- a/hw/xquartz/x11-exec.c
+++ b/hw/xquartz/x11-exec.c
@@ -28,7 +28,7 @@
  promote the sale, use or other dealings in this Software without
  prior written authorization. */
 
-#include <ApplicationServices/ApplicationServices.h>
+#include <CoreServices/CoreServices.h>
 #include <stdio.h>
 
 #define kX11AppBundleId "org.x.X11"
@@ -36,10 +36,10 @@
 
 int main(int argc, char **argv) {
   char x11_path[PATH_MAX];
+  char** args = NULL;
   CFURLRef appURL = NULL;
-  OSStatus osstatus = 
-    LSFindApplicationForInfo(kLSUnknownCreator, CFSTR(kX11AppBundleId), 
-			     nil, nil, &appURL);
+  OSStatus osstatus = LSFindApplicationForInfo(kLSUnknownCreator, CFSTR(kX11AppBundleId), 
+					       nil, nil, &appURL);
   
   switch (osstatus) {
   case noErr:
@@ -52,10 +52,20 @@ int main(int argc, char **argv) {
       fprintf(stderr, "%s: Error resolving URL for %s\n", argv[0], kX11AppBundleId);
       exit(2);
     }
-    strlcpy(argv[0], "X11", strlen(argv[0])+1);
+    
+    args = (char**)malloc(sizeof (char*) * (argc + 1));
     strlcat(x11_path, kX11AppBundlePath, sizeof(x11_path));
-//  fprintf(stderr, "X11.app = %s\n", x11_path);
-    execv(x11_path, argv);
+    if (args) {
+      int i;
+      args[0] = x11_path;
+      for (i = 1; i < argc; ++i) {
+        args[i] = argv[i];
+      }
+      args[i] = NULL;
+    }
+    
+    fprintf(stderr, "X11.app = %s\n", x11_path);
+    execv(x11_path, args);
     fprintf(stderr, "Error executing X11.app (%s):", x11_path);
     perror(NULL);
     exit(3);
commit fcb97a55a096009f1ce552b1c27e9dfcf85b2ce2
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Fri Dec 14 15:21:40 2007 -0800

    Xquartz: Fixed cpprules include
    (cherry picked from commit 95c02adea80a14e18bb51876bc1418eccdade31d)

diff --git a/hw/xquartz/bundle/Makefile.am b/hw/xquartz/bundle/Makefile.am
index 775e1aa..da297e9 100644
--- a/hw/xquartz/bundle/Makefile.am
+++ b/hw/xquartz/bundle/Makefile.am
@@ -15,9 +15,9 @@ launchagents_DATA = $(launchagents_PRE:plist.pre=plist)
 CPP_FILES_FLAGS = -D__libexecdir__="${libexecdir}"
 
 CLEANFILES = $(launchagents_DATA)
+endif
 
 include $(top_srcdir)/cpprules.in
-endif
 
 clean-local:
 	rm -rf build
commit 32e74d744cd1a84108b8e04c1b69e2a688a5b396
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Thu Dec 13 16:23:46 2007 -0800

    Xquartz: Don't hardcode libexec dir
    (cherry picked from commit 67b479ef80cb740a24981335eb8d596744168a62)

diff --git a/configure.ac b/configure.ac
index 06f1ff5..eee0d23 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2147,7 +2147,6 @@ hw/xnest/Makefile
 hw/xwin/Makefile
 hw/xquartz/Makefile
 hw/xquartz/bundle/Makefile
-hw/xquartz/bundle/org.x.X11.plist
 hw/xquartz/xpr/Makefile
 hw/kdrive/Makefile
 hw/kdrive/ati/Makefile
diff --git a/hw/xquartz/Makefile.am b/hw/xquartz/Makefile.am
index 846beae..b40a4f5 100644
--- a/hw/xquartz/Makefile.am
+++ b/hw/xquartz/Makefile.am
@@ -1,7 +1,3 @@
-libexec_PROGRAMS = x11-exec
-
-x11_exec_LDFLAGS = -framework ApplicationServices
-
 noinst_LTLIBRARIES = libXquartz.la
 AM_CFLAGS = $(XSERVER_CFLAGS) $(DIX_CFLAGS)
 AM_CPPFLAGS = \
@@ -13,6 +9,12 @@ AM_CPPFLAGS = \
 
 if X11APP
 X11APP_SUBDIRS = bundle
+
+if LAUNCHD
+libexec_PROGRAMS = x11-exec
+x11_exec_LDFLAGS = -framework ApplicationServices
+endif
+
 endif
 
 SUBDIRS = . xpr $(X11APP_SUBDIRS)
diff --git a/hw/xquartz/bundle/Makefile.am b/hw/xquartz/bundle/Makefile.am
index 8aa2357..775e1aa 100644
--- a/hw/xquartz/bundle/Makefile.am
+++ b/hw/xquartz/bundle/Makefile.am
@@ -9,7 +9,14 @@ install-data-hook:
 	xcodebuild install DSTROOT="/$(DESTDIR)" INSTALL_PATH="$(APPLE_APPLICATIONS_DIR)" DEPLOYMENT_LOCATION=YES SKIP_INSTALL=NO ARCHS="$(X11APP_ARCHS)"
 
 if LAUNCHD
-launchagents_DATA = org.x.X11.plist
+launchagents_PRE = org.x.X11.plist.pre
+launchagents_DATA = $(launchagents_PRE:plist.pre=plist)
+
+CPP_FILES_FLAGS = -D__libexecdir__="${libexecdir}"
+
+CLEANFILES = $(launchagents_DATA)
+
+include $(top_srcdir)/cpprules.in
 endif
 
 clean-local:
diff --git a/hw/xquartz/bundle/org.x.X11.plist b/hw/xquartz/bundle/org.x.X11.plist
deleted file mode 100644
index 1e646ac..0000000
--- a/hw/xquartz/bundle/org.x.X11.plist
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>Label</key>
-		<string>org.x.X11</string>
-	<key>ProgramArguments</key>
-		<array>
-		<string>/usr/libexec/x11-exec</string>
-		<string>-launchd</string>
-		</array>
-	<key>Sockets</key>
-		<dict>
-		<key>:0</key>
-			<dict>
-			<key>SecureSocketWithKey</key>
-				<string>DISPLAY</string>
-			</dict>
-		</dict>
-	<key>ServiceIPC</key>
-		<true/>
-</dict>
-</plist>
diff --git a/hw/xquartz/bundle/org.x.X11.plist.pre b/hw/xquartz/bundle/org.x.X11.plist.pre
new file mode 100644
index 0000000..83d8b2f
--- /dev/null
+++ b/hw/xquartz/bundle/org.x.X11.plist.pre
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>Label</key>
+		<string>org.x.X11</string>
+	<key>ProgramArguments</key>
+		<array>
+		<string>__libexecdir__/x11-exec</string>
+		<string>-launchd</string>
+		</array>
+	<key>Sockets</key>
+		<dict>
+		<key>:0</key>
+			<dict>
+			<key>SecureSocketWithKey</key>
+				<string>DISPLAY</string>
+			</dict>
+		</dict>
+	<key>ServiceIPC</key>
+		<true/>
+</dict>
+</plist>
commit 8eb15256ecfad3d968b664122d0d118a2f232cb8
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Thu Dec 13 15:56:31 2007 -0800

    Xquartz: Don't hardcode LaunchAgents dir
    (cherry picked from commit 07a12d71fefd78c380078efa835700f2868ab204)

diff --git a/configure.ac b/configure.ac
index 0fab244..06f1ff5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -454,13 +454,15 @@ AC_ARG_WITH(rgb-path,         AS_HELP_STRING([--with-rgb-path=PATH], [Path to RG
 AC_ARG_WITH(serverconfig-path, AS_HELP_STRING([--with-serverconfig-path=PATH], [Path to server config (default: ${libdir}/xserver)]),
 				[ SERVERCONFIG="$withval" ],
 				[ SERVERCONFIG="${libdir}/xserver" ])
-APPLE_APPLICATIONS_DIR="/Applications/Utilities"
 AC_ARG_WITH(apple-applications-dir,AS_HELP_STRING([--with-apple-applications-dir=PATH], [Path to the Applications directory (default: /Applications/Utilities)]),
-				[ APPLE_APPLICATIONS_DIR="${withval}" ].
+				[ APPLE_APPLICATIONS_DIR="${withval}" ],
 				[ APPLE_APPLICATIONS_DIR="/Applications/Utilities" ])
-
+AC_SUBST([APPLE_APPLICATIONS_DIR])
 AC_ARG_WITH(launchd,          AS_HELP_STRING([--with-launchd], [Build with support for Apple's launchd (default: auto)]), [LAUNCHD=$withval], [LAUNCHD=auto])
-
+AC_ARG_WITH(launchagents-dir,AS_HELP_STRING([--with-launchagents-dir=PATH], [Path to launchd's LaunchAgents directory (default: /Library/LaunchAgents)]),
+				[ launchagentsdir="${withval}" ],
+				[ launchagentsdir="/Library/LaunchAgents" ])
+AC_SUBST([launchagentsdir])
 AC_ARG_ENABLE(builddocs,      AS_HELP_STRING([--enable-builddocs], [Build docs (default: disabled)]),
                                 [BUILDDOCS=$enableval],
                                 [BUILDDOCS=no])
@@ -1745,7 +1747,6 @@ if test "x$XQUARTZ" = xyes; then
 	DARWIN_LIBS="$MI_LIB $OS_LIB $DIX_LIB $FB_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB $DARWIN_GLX_LIBS"
 	AC_SUBST([DARWIN_LIBS])
 	AC_CHECK_LIB([Xplugin],[xp_init],[:])
-	AC_SUBST([APPLE_APPLICATIONS_DIR])
 	CFLAGS="${CFLAGS} -DROOTLESS_WORKAROUND -DNO_ALLOCA"
 	if test "x$XF86MISC" = xyes || test "x$XF86MISC" = xauto; then
 		AC_MSG_NOTICE([Disabling XF86Misc extension])
@@ -1791,22 +1792,18 @@ if test "x$X11APP" = xauto; then
 fi
 AM_CONDITIONAL(X11APP,[test "X$X11APP" = Xyes]) 
 
-if test "x$LAUNCHD" = xauto; then
-	# Do we want to have this default to on for Xquartz builds only or any time we have launchd (like Xnest or Xvfb on OS-X)
-	#AC_CHECK_PROG(LAUNCHD, [launchd], [yes], [no])
-	AC_MSG_CHECKING([whether to support launchd])
-	if test "x$XQUARTZ" = xyes ; then
+if test "x$LAUNCHD" = "xauto"; then
+	if test "x$XQUARTZ" = "xyes" ; then
 		LAUNCHD=yes
 	else
-		LAUNCHD=no
+		AC_CHECK_PROG(LAUNCHD, [launchd], [yes], [no])
 	fi
-	AC_MSG_RESULT([$LAUNCHD])
 fi
 
-if test "x$LAUNCHD" = xyes ; then
+if test "x$LAUNCHD" = "xyes" ; then
 	AC_DEFINE(HAVE_LAUNCHD, 1, [launchd support available])
 fi
-AM_CONDITIONAL(LAUNCHD, [test "x$LAUNCHD" = xyes])
+AM_CONDITIONAL(LAUNCHD, [test "x$LAUNCHD" = "xyes"])
 
 dnl kdrive DDX
 
diff --git a/hw/xquartz/bundle/Makefile.am b/hw/xquartz/bundle/Makefile.am
index 5734434..8aa2357 100644
--- a/hw/xquartz/bundle/Makefile.am
+++ b/hw/xquartz/bundle/Makefile.am
@@ -7,9 +7,9 @@ x11app:
 
 install-data-hook:
 	xcodebuild install DSTROOT="/$(DESTDIR)" INSTALL_PATH="$(APPLE_APPLICATIONS_DIR)" DEPLOYMENT_LOCATION=YES SKIP_INSTALL=NO ARCHS="$(X11APP_ARCHS)"
+
 if LAUNCHD
-	$(MKDIR_P) "$(DESTDIR)/System/Library/LaunchAgents/"
-	$(INSTALL) org.x.X11.plist "$(DESTDIR)/System/Library/LaunchAgents/"
+launchagents_DATA = org.x.X11.plist
 endif
 
 clean-local:
commit fa3ccf4c2a7449895449765a5a9bf9b14ac1da26
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Thu Dec 13 15:57:39 2007 -0800

    Modified X11 plist to use x11-exec
    (cherry picked from commit 7d9a11329e476f45e4d9f9aebcb43469321347c7)

diff --git a/.gitignore b/.gitignore
index 37f35f4..2e60d58 100644
--- a/.gitignore
+++ b/.gitignore
@@ -275,7 +275,6 @@ hw/xprint/doc/Xprt.1x
 hw/xprint/doc/Xprt.man
 hw/xprint/dpmsstubs-wrapper.c
 hw/xprint/miinitext-wrapper.c
-hw/xquartz/bundle/org.x.X11.plist
 include/dix-config.h
 include/kdrive-config.h
 include/xgl-config.h
diff --git a/hw/xquartz/bundle/org.x.X11.plist b/hw/xquartz/bundle/org.x.X11.plist
new file mode 100644
index 0000000..1e646ac
--- /dev/null
+++ b/hw/xquartz/bundle/org.x.X11.plist
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>Label</key>
+		<string>org.x.X11</string>
+	<key>ProgramArguments</key>
+		<array>
+		<string>/usr/libexec/x11-exec</string>
+		<string>-launchd</string>
+		</array>
+	<key>Sockets</key>
+		<dict>
+		<key>:0</key>
+			<dict>
+			<key>SecureSocketWithKey</key>
+				<string>DISPLAY</string>
+			</dict>
+		</dict>
+	<key>ServiceIPC</key>
+		<true/>
+</dict>
+</plist>
diff --git a/hw/xquartz/bundle/org.x.X11.plist.in b/hw/xquartz/bundle/org.x.X11.plist.in
deleted file mode 100644
index 26eca96..0000000
--- a/hw/xquartz/bundle/org.x.X11.plist.in
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>Label</key>
-		<string>org.x.X11</string>
-	<key>ProgramArguments</key>
-		<array>
-		<string>@APPLE_APPLICATIONS_DIR@/X11.app/Contents/MacOS/X11</string>
-		<string>-launchd</string>
-		</array>
-	<key>Sockets</key>
-		<dict>
-		<key>:0</key>
-			<dict>
-			<key>SecureSocketWithKey</key>
-				<string>DISPLAY</string>
-			</dict>
-		</dict>
-	<key>ServiceIPC</key>
-		<true/>
-</dict>
-</plist>
commit eb141e05f38b268f5b578aae59ad355bc76b1214
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Thu Dec 13 15:55:28 2007 -0800

    created x11-exec wrapper, which uses LaunchServices to find
    (and then exec) X11.app
    (cherry picked from commit fc04c9759b30d062111d4a7f3f411ed0f18cbde4)

diff --git a/hw/xquartz/Makefile.am b/hw/xquartz/Makefile.am
index b026ee1..846beae 100644
--- a/hw/xquartz/Makefile.am
+++ b/hw/xquartz/Makefile.am
@@ -1,3 +1,7 @@
+libexec_PROGRAMS = x11-exec
+
+x11_exec_LDFLAGS = -framework ApplicationServices
+
 noinst_LTLIBRARIES = libXquartz.la
 AM_CFLAGS = $(XSERVER_CFLAGS) $(DIX_CFLAGS)
 AM_CPPFLAGS = \
diff --git a/hw/xquartz/x11-exec.c b/hw/xquartz/x11-exec.c
new file mode 100644
index 0000000..d0b5c49
--- /dev/null
+++ b/hw/xquartz/x11-exec.c
@@ -0,0 +1,74 @@
+/* x11-exec.c -- Find X11.app by bundle-id and exec it.  This is so launchd
+   can correctly find X11.app, even if the user moved it.
+
+ Copyright (c) 2007 Apple, Inc.
+ 
+ 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 <ApplicationServices/ApplicationServices.h>
+#include <stdio.h>
+
+#define kX11AppBundleId "org.x.X11"
+#define kX11AppBundlePath "/Contents/MacOS/X11"
+
+int main(int argc, char **argv) {
+  char x11_path[PATH_MAX];
+  CFURLRef appURL = NULL;
+  OSStatus osstatus = 
+    LSFindApplicationForInfo(kLSUnknownCreator, CFSTR(kX11AppBundleId), 
+			     nil, nil, &appURL);
+  
+  switch (osstatus) {
+  case noErr:
+    if (appURL == NULL) {
+      fprintf(stderr, "%s: Invalid response from LSFindApplicationForInfo(%s)\n", 
+	      argv[0], kX11AppBundleId);
+      exit(1);
+    }
+    if (!CFURLGetFileSystemRepresentation(appURL, true, (unsigned char *)x11_path, sizeof(x11_path))) {
+      fprintf(stderr, "%s: Error resolving URL for %s\n", argv[0], kX11AppBundleId);
+      exit(2);
+    }
+    strlcpy(argv[0], "X11", strlen(argv[0])+1);
+    strlcat(x11_path, kX11AppBundlePath, sizeof(x11_path));
+//  fprintf(stderr, "X11.app = %s\n", x11_path);
+    execv(x11_path, argv);
+    fprintf(stderr, "Error executing X11.app (%s):", x11_path);
+    perror(NULL);
+    exit(3);
+    break;
+  case kLSApplicationNotFoundErr:
+    fprintf(stderr, "%s: Unable to find application for %s\n", argv[0], kX11AppBundleId);
+    exit(4);
+  default:
+    fprintf(stderr, "%s: Unable to find application for %s, error code = %d\n", 
+	    argv[0], kX11AppBundleId, osstatus);
+    exit(5);
+  }
+  /* not reached */
+}
+
+    
commit d988da6eee8422774dff364050bf431b843a714a
Author: Arkadiusz Miskiewicz <arekm at maven.pl>
Date:   Thu Dec 13 00:09:08 2007 +0200

    Xprint: Clean up generated files
    
    Remember to clean generated wrapper files.
    (cherry picked from commit 977fcdea8198906936a64b8117e6a6d027c617e3)

diff --git a/hw/xprint/Makefile.am b/hw/xprint/Makefile.am
index dc8764a..f834966 100644
--- a/hw/xprint/Makefile.am
+++ b/hw/xprint/Makefile.am
@@ -41,3 +41,5 @@ Xprt_SOURCES =			\
         $(top_srcdir)/fb/fbcmap_mi.c
 
 EXTRA_DIST = ValTree.c
+
+CLEANFILES = miinitext-wrapper.c dpmsstubs-wrapper.c
commit 41f735fbe02f59bc7bcca335c6e743c72c2fc44c
Author: Hong Liu <hong.liu at intel.com>
Date:   Tue Sep 4 08:46:46 2007 +0100

    bgPixel (unsigned long) is 64-bit on x86_64, so -1 != 0xffffffff
    
    This patch should fix bug 8080.
    (cherry picked from commit 9adea807038b64292403ede982075fe1dcfd4c9a)

diff --git a/hw/xfree86/xaa/xaaGC.c b/hw/xfree86/xaa/xaaGC.c
index f3434c9..b3dc83a 100644
--- a/hw/xfree86/xaa/xaaGC.c
+++ b/hw/xfree86/xaa/xaaGC.c
@@ -80,10 +80,11 @@ XAAValidateGC(
     }
 
     if(pGC->depth != 32) {
-	if(pGC->bgPixel == -1) /* -1 is reserved for transparency */
-	    pGC->bgPixel = 0x7fffffff; 
-	if(pGC->fgPixel == -1) /* -1 is reserved for transparency */
-	    pGC->fgPixel = 0x7fffffff; 
+	/* 0xffffffff is reserved for transparency */
+	if(pGC->bgPixel == 0xffffffff)
+	    pGC->bgPixel = 0x7fffffff;
+	if(pGC->fgPixel == 0xffffffff)
+	    pGC->fgPixel = 0x7fffffff;
     }
 
     if((pDraw->type == DRAWABLE_PIXMAP) && !IS_OFFSCREEN_PIXMAP(pDraw)){
commit f4bcb53e86bb103b6bcf8a3a170a36137c34d272
Author: Hong Liu <hong.liu at intel.com>
Date:   Wed Dec 5 17:48:28 2007 +0100

    Bug 13308: Verify and reject obviously broken modes.
    (cherry picked from commit c6cfcd408df3e44d0094946c0a7d2fa944b4d2d1)

diff --git a/hw/xfree86/modes/xf86EdidModes.c b/hw/xfree86/modes/xf86EdidModes.c
index 8b5e69d..e2ae665 100644
--- a/hw/xfree86/modes/xf86EdidModes.c
+++ b/hw/xfree86/modes/xf86EdidModes.c
@@ -239,6 +239,12 @@ DDCModeFromDetailedTiming(int scrnIndex, struct detailed_timings *timing,
     Mode->VSyncEnd = Mode->VSyncStart + timing->v_sync_width;
     Mode->VTotal = timing->v_active + timing->v_blanking;
 
+    /* perform basic check on the detail timing */
+    if (Mode->HSyncEnd > Mode->HTotal || Mode->VSyncEnd > Mode->VTotal) {
+	xfree(Mode);
+	return NULL;
+    }
+
     xf86SetModeDefaultName(Mode);
 
     /* We ignore h/v_size and h/v_border for now. */
commit d63efecc9471ac53535932b80a85b7f408f06fb9
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Dec 12 21:57:59 2007 +0200

    Bump to 1.4.0.90

diff --git a/configure.ac b/configure.ac
index dedc5f1..72d9819 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,7 +26,7 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ(2.57)
-AC_INIT([xorg-server], 1.4, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+AC_INIT([xorg-server], 1.4.0.90, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([dist-bzip2 foreign])
 AM_MAINTAINER_MODE
commit ffa66f8e7417d19cf7bda5020901e6713205090b
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Mon Dec 10 20:57:24 2007 -0800

    Xquartz: Pre-process Xquartz man page
    (cherry picked from commit dec2633c41dd0adf73264afdf251a6522d6ae76a)

diff --git a/hw/xquartz/xpr/Makefile.am b/hw/xquartz/xpr/Makefile.am
index 87ed195..ae1b192 100644
--- a/hw/xquartz/xpr/Makefile.am
+++ b/hw/xquartz/xpr/Makefile.am
@@ -1,8 +1,5 @@
 bin_PROGRAMS = Xquartz
 
-# TODO: This man page needs sed magic and cleanup
-man1_MANS = Xquartz.man
-
 AM_CFLAGS =  $(XSERVER_CFLAGS) $(DIX_CFLAGS)
 AM_CPPFLAGS = \
 	-I$(srcdir) -I$(srcdir)/.. \
@@ -58,8 +55,19 @@ Xquartz_LDFLAGS =  \
 	-Wl,-framework,CoreAudio \
 	-Wl,-framework,IOKit
 
+appmandir = $(APP_MAN_DIR)
+appman_PRE = Xquartz.man.pre
+appman_PROCESSED = $(appman_PRE:man.pre=man)
+appman_DATA = $(appman_PRE:man.pre=@APP_MAN_SUFFIX@)
+
+CLEANFILES = $(appman_PROCESSED) $(appman_DATA)
+
+include $(top_srcdir)/cpprules.in
+
+.man.$(APP_MAN_SUFFIX):
+	cp $< $@
+
 EXTRA_DIST = \
-	Xquartz.man \
 	dri.h \
 	dristruct.h \
 	appledri.h \
diff --git a/hw/xquartz/xpr/Xquartz.man b/hw/xquartz/xpr/Xquartz.man
deleted file mode 100644
index 37a7f1a..0000000
--- a/hw/xquartz/xpr/Xquartz.man
+++ /dev/null
@@ -1,156 +0,0 @@
-.TH XQUARTZ 1 __vendorversion__
-.SH NAME
-Xquartz \- X window system server for Quartz operating system
-.SH SYNOPSIS
-.B Xquartz
-[ options ] ...
-.SH DESCRIPTION
-.I Xquartz
-is the X window server for Mac OS X provided by Apple.
-.I Xquartz
-runs in parallel with Aqua in rootless mode. In rootless mode, the X
-window system and Mac OS X share your display.  The root window of the
-X11 display is the size of the screen and contains all the other
-windows. The X11 root window is not displayed in rootless mode as Mac
-OS X handles the desktop background.
-.SH OPTIONS
-.PP
-In addition to the normal server options described in the \fIXserver(1)\fP
-manual page, \fIXquartz\fP accepts the following command line switches:
-.TP 8
-.B \-fakebuttons
-Emulates a 3 button mouse using modifier keys. By default, the Command modifier
-is used to emulate button 2 and Option is used for button 3. Thus, clicking the
-first mouse button while holding down Command will act like clicking
-button 2. Holding down Option will simulate button 3.
-.TP 8
-.B \-nofakebuttons
-Do not emulate a 3 button mouse. This is the default.
-.TP 8
-.B "\-fakemouse2 \fImodifiers\fP"
-Change the modifier keys used to emulate the second mouse button. By default,
-Command is used to emulate the second button. Any combination of the following
-modifier names may be used: Shift, Option, Control, Command, Fn. For example,
-.B \-fakemouse2 """Option,Shift""
-will set holding Option, Shift and clicking on button one as equivalent to
-clicking the second mouse button.
-.TP 8
-.B "\-fakemouse3 \fImodifiers\fP"
-Change the modifier keys used to emulate the third mouse button. By default,
-Option is used to emulate the third button. Any combination of the following
-modifier names may be used: Shift, Option, Control, Command, Fn. For example,
-.B \-fakemouse3 """Control,Shift""
-will set holding Control, Shift and clicking on button one as equivalent to
-clicking the third mouse button.
-.TP 8
-.B "\-swapAltMeta"
-Swaps the meaning of the Alt and Meta modifier keys.
-.TP 8
-.B "\-keymap \fIfile\fP"
-On startup \fIXquartz\fP translates a Darwin keymapping into an X keymap.
-The default is to read this keymapping from USA.keymapping. With this option
-the keymapping will be read from \fIfile\fP instead. If the file's path is
-not specified, it will be searched for in Library/Keyboards/ underneath the
-following directories (in order): ~, /, /Network, /System.
-.TP 8
-.B \-nokeymap
-On startup \fIXquartz\fP translates a Darwin keymapping into an X keymap.
-With this option \fIXquartz\fP queries the kernel for the current keymapping
-instead of reading it from a file. This will often fail on newer kernels.
-.TP 8
-.B "\-depth \fIdepth\fP"
-Specifies the color bit depth to use. Currently only 15, and 24 color
-bits per pixel are supported. If not specified, defaults to the depth
-of the main display.
-.SH CUSTOMIZATION
-\fIXquartz\fP can also be customized using the defaults(1) command. The available options are:
-.TP 8
-.B defaults write com.apple.x11 enable_fake_buttons -boolean true
-Equivalent to the \fB-fakebuttons\fP command line option.
-.TP 8
-.B defaults write com.apple.x11 fake_button2 \fImodifiers\fP
-Equivalent to the \fB-fakemouse2\fP option.
-.TP 8
-.B defaults write com.apple.x11 fake_button3 \fImodifiers\fP
-Equivalent to the \fB-fakemouse3\fP option.
-.TP 8
-.B defaults write com.apple.x11 swap_alt_meta -boolean true
-Equivalent to the \fB-swapAltMeta\fP option.
-.TP 8
-.B defaults write com.apple.x11 keymap_file \fIfilename\fP
-Equivalent to the \fB-keymap\fP option.
-.TP 8
-.B defaults write com.apple.x11 no_quit_alert -boolean true
-Disables the alert dialog displayed when attempting to quit X11.
-.TP 8
-.B defaults write com.apple.x11 no_auth -boolean true
-Stops the X server requiring that clients authenticate themselves when
-connecting. See Xsecurity(__miscmansuffix__).
-.TP 8
-.B defaults write com.apple.x11 nolisten_tcp -boolean true
-Prevents the X server accepting remote connections.
-.TP 8
-.B defaults write com.apple.x11 xinit_kills_server -boolean false
-Stops the X server exiting when the xinitrc script terminates.
-.TP 8
-.B defaults write com.apple.x11 fullscreen_hotkeys -boolean false
-Allows system hotkeys to be handled while in X11 fullscreen mode.
-.TP 8
-.B defaults write com.apple.x11 enable_system_beep -boolean false
-Don't use the standard system beep effect for X11 alerts.
-.TP 8
-.B defaults write com.apple.x11 enable_key_equivalents -boolean false
-Disable menu keyboard equivalents while X11 windows are focused.
-.TP 8
-.B defaults write com.apple.x11 depth \fIdepth\fP
-Equivalent to the \fB-depth\fP option.
-.SH "SEE ALSO"
-.PP
-X(__miscmansuffix__), XFree86(1), Xserver(1), xdm(1), xinit(1)
-.PP
-.SH AUTHORS
-XFree86 was originally ported to Mac OS X Server by John Carmack. Dave
-Zarzycki used this as the basis of his port of XFree86 4.0 to Darwin 1.0.
-Torrey T. Lyons improved and integrated this code into the XFree86
-Project's mainline for the 4.0.2 release.
-.PP
-The following members of the XonX Team contributed to the following
-releases (in alphabetical order):
-.TP 4
-XFree86 4.1.0:
-.br
-Rob Braun - Darwin x86 support
-.br
-Torrey T. Lyons - Project Lead
-.br
-Andreas Monitzer - Cocoa version of XDarwin front end
-.br
-Gregory Robert Parker - Original Quartz implementation
-.br
-Christoph Pfisterer - Dynamic shared X libraries
-.br
-Toshimitsu Tanaka - Japanese localization
-.TP 4
-XFree86 4.2.0:
-.br
-Rob Braun - Darwin x86 support
-.br
-Pablo Di Noto - Spanish localization
-.br
-Paul Edens - Dutch localization
-.br
-Kyunghwan Kim - Korean localization
-.br
-Mario Klebsch - Non-US keyboard support
-.br
-Torrey T. Lyons - Project Lead
-.br
-Andreas Monitzer - German localization
-.br
-Patrik Montgomery - Swedish localization
-.br
-Greg Parker - Rootless support
-.br
-Toshimitsu Tanaka - Japanese localization
-.br
-Olivier Verdier - French localization
diff --git a/hw/xquartz/xpr/Xquartz.man.pre b/hw/xquartz/xpr/Xquartz.man.pre
new file mode 100644
index 0000000..315db1c
--- /dev/null
+++ b/hw/xquartz/xpr/Xquartz.man.pre
@@ -0,0 +1,156 @@
+.TH XQUARTZ 1 __vendorversion__
+.SH NAME
+Xquartz \- X window system server for Quartz operating system
+.SH SYNOPSIS
+.B Xquartz
+[ options ] ...
+.SH DESCRIPTION
+.I Xquartz
+is the X window server for Mac OS X provided by Apple.
+.I Xquartz
+runs in parallel with Aqua in rootless mode. In rootless mode, the X
+window system and Mac OS X share your display.  The root window of the
+X11 display is the size of the screen and contains all the other
+windows. The X11 root window is not displayed in rootless mode as Mac
+OS X handles the desktop background.
+.SH OPTIONS
+.PP
+In addition to the normal server options described in the \fIXserver(1)\fP
+manual page, \fIXquartz\fP accepts the following command line switches:
+.TP 8
+.B \-fakebuttons
+Emulates a 3 button mouse using modifier keys. By default, the Command modifier
+is used to emulate button 2 and Option is used for button 3. Thus, clicking the
+first mouse button while holding down Command will act like clicking
+button 2. Holding down Option will simulate button 3.
+.TP 8
+.B \-nofakebuttons
+Do not emulate a 3 button mouse. This is the default.
+.TP 8
+.B "\-fakemouse2 \fImodifiers\fP"
+Change the modifier keys used to emulate the second mouse button. By default,
+Command is used to emulate the second button. Any combination of the following
+modifier names may be used: Shift, Option, Control, Command, Fn. For example,
+.B \-fakemouse2 """Option,Shift""
+will set holding Option, Shift and clicking on button one as equivalent to
+clicking the second mouse button.
+.TP 8
+.B "\-fakemouse3 \fImodifiers\fP"
+Change the modifier keys used to emulate the third mouse button. By default,
+Option is used to emulate the third button. Any combination of the following
+modifier names may be used: Shift, Option, Control, Command, Fn. For example,
+.B \-fakemouse3 """Control,Shift""
+will set holding Control, Shift and clicking on button one as equivalent to
+clicking the third mouse button.
+.TP 8
+.B "\-swapAltMeta"
+Swaps the meaning of the Alt and Meta modifier keys.
+.TP 8
+.B "\-keymap \fIfile\fP"
+On startup \fIXquartz\fP translates a Darwin keymapping into an X keymap.
+The default is to read this keymapping from USA.keymapping. With this option
+the keymapping will be read from \fIfile\fP instead. If the file's path is
+not specified, it will be searched for in Library/Keyboards/ underneath the
+following directories (in order): ~, /, /Network, /System.
+.TP 8
+.B \-nokeymap
+On startup \fIXquartz\fP translates a Darwin keymapping into an X keymap.
+With this option \fIXquartz\fP queries the kernel for the current keymapping
+instead of reading it from a file. This will often fail on newer kernels.
+.TP 8
+.B "\-depth \fIdepth\fP"
+Specifies the color bit depth to use. Currently only 15, and 24 color
+bits per pixel are supported. If not specified, defaults to the depth
+of the main display.
+.SH CUSTOMIZATION
+\fIXquartz\fP can also be customized using the defaults(1) command. The available options are:
+.TP 8
+.B defaults write org.x.X11 enable_fake_buttons -boolean true
+Equivalent to the \fB-fakebuttons\fP command line option.
+.TP 8
+.B defaults write org.x.X11 fake_button2 \fImodifiers\fP
+Equivalent to the \fB-fakemouse2\fP option.
+.TP 8
+.B defaults write org.x.X11 fake_button3 \fImodifiers\fP
+Equivalent to the \fB-fakemouse3\fP option.
+.TP 8
+.B defaults write org.x.X11 swap_alt_meta -boolean true
+Equivalent to the \fB-swapAltMeta\fP option.
+.TP 8
+.B defaults write org.x.X11 keymap_file \fIfilename\fP
+Equivalent to the \fB-keymap\fP option.
+.TP 8
+.B defaults write org.x.X11 no_quit_alert -boolean true
+Disables the alert dialog displayed when attempting to quit X11.
+.TP 8
+.B defaults write org.x.X11 no_auth -boolean true
+Stops the X server requiring that clients authenticate themselves when
+connecting. See Xsecurity(__miscmansuffix__).
+.TP 8
+.B defaults write org.x.X11 nolisten_tcp -boolean true
+Prevents the X server accepting remote connections.
+.TP 8
+.B defaults write org.x.X11 xinit_kills_server -boolean false
+Stops the X server exiting when the xinitrc script terminates.
+.TP 8
+.B defaults write org.x.X11 fullscreen_hotkeys -boolean false
+Allows system hotkeys to be handled while in X11 fullscreen mode.
+.TP 8
+.B defaults write org.x.X11 enable_system_beep -boolean false
+Don't use the standard system beep effect for X11 alerts.
+.TP 8
+.B defaults write org.x.X11 enable_key_equivalents -boolean false
+Disable menu keyboard equivalents while X11 windows are focused.
+.TP 8
+.B defaults write org.x.X11 depth \fIdepth\fP
+Equivalent to the \fB-depth\fP option.
+.SH "SEE ALSO"
+.PP
+X(__miscmansuffix__), Xserver(1), xdm(1), xinit(1)
+.PP
+.SH AUTHORS
+XFree86 was originally ported to Mac OS X Server by John Carmack. Dave
+Zarzycki used this as the basis of his port of XFree86 4.0 to Darwin 1.0.
+Torrey T. Lyons improved and integrated this code into the XFree86
+Project's mainline for the 4.0.2 release.
+.PP
+The following members of the XonX Team contributed to the following
+releases (in alphabetical order):
+.TP 4
+XFree86 4.1.0:
+.br
+Rob Braun - Darwin x86 support
+.br
+Torrey T. Lyons - Project Lead
+.br
+Andreas Monitzer - Cocoa version of XDarwin front end
+.br
+Gregory Robert Parker - Original Quartz implementation
+.br
+Christoph Pfisterer - Dynamic shared X libraries
+.br
+Toshimitsu Tanaka - Japanese localization
+.TP 4
+XFree86 4.2.0:
+.br
+Rob Braun - Darwin x86 support
+.br
+Pablo Di Noto - Spanish localization
+.br
+Paul Edens - Dutch localization
+.br
+Kyunghwan Kim - Korean localization
+.br
+Mario Klebsch - Non-US keyboard support
+.br
+Torrey T. Lyons - Project Lead
+.br
+Andreas Monitzer - German localization
+.br
+Patrik Montgomery - Swedish localization
+.br
+Greg Parker - Rootless support
+.br
+Toshimitsu Tanaka - Japanese localization
+.br
+Olivier Verdier - French localization
commit ea713786b3d8ff1902ef3cf6896d879d82ce715d
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Mon Dec 10 20:47:48 2007 -0800

    Xquartz: Make Alt work with Xmodmap again
    (cherry picked from commit 0e017177dcca7185716ca760dcce9ddedc7bfef9)

diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index ae82f5b..1d09e09 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -424,7 +424,7 @@ void DarwinSendKeyboardEvents(int ev_type, int keycode) {
     static unsigned int last_seed;
     unsigned int this_seed;
 
-    this_seed = DarwinModeSystemKeymapSeed();
+    this_seed = QuartzSystemKeymapSeed();
     if (this_seed != last_seed) {
       last_seed = this_seed;
       DarwinKeyboardReload(darwinKeyboard);
diff --git a/hw/xquartz/darwinKeyboard.c b/hw/xquartz/darwinKeyboard.c
index f6dcfb3..f1b90b7 100644
--- a/hw/xquartz/darwinKeyboard.c
+++ b/hw/xquartz/darwinKeyboard.c
@@ -507,8 +507,9 @@ Bool DarwinParseNXKeyMapping(darwinKeyboardInfo  *info) {
                                 (left ? XK_Control_L : XK_Control_R);
                         break;
                     case NX_MODIFIERKEY_ALTERNATE:
-                        info->keyMap[keyCode * GLYPHS_PER_KEY] = XK_Mode_switch;
-                                // (left ? XK_Alt_L : XK_Alt_R);
+                        // info->keyMap[keyCode * GLYPHS_PER_KEY] = XK_Mode_switch;
+                        info->keyMap[keyCode * GLYPHS_PER_KEY] =
+                                (left ? XK_Alt_L : XK_Alt_R);
                         break;
                     case NX_MODIFIERKEY_COMMAND:
                         info->keyMap[keyCode * GLYPHS_PER_KEY] =
@@ -685,6 +686,7 @@ static void DarwinBuildModifierMaps(darwinKeyboardInfo *info) {
             case XK_Alt_L:
                 info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
                 info->modMap[MIN_KEYCODE + i] = Mod1Mask;
+                *k = XK_Mode_switch; // Yes, this is ugly.  This needs to be cleaned up when we integrate quartzKeyboard with this code and refactor.
                 break;
 
             case XK_Alt_R:
@@ -693,15 +695,11 @@ static void DarwinBuildModifierMaps(darwinKeyboardInfo *info) {
 #else
                 info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
 #endif
+                *k = XK_Mode_switch; // Yes, this is ugly.  This needs to be cleaned up when we integrate quartzKeyboard with this code and refactor.
                 info->modMap[MIN_KEYCODE + i] = Mod1Mask;
                 break;
 
             case XK_Mode_switch:
-                // Yes, this is ugly.  This needs to be cleaned up when we integrate quartzKeyboard with this code and refactor.
-#ifdef NX_MODIFIERKEY_RALTERNATE
-                info->modifierKeycodes[NX_MODIFIERKEY_RALTERNATE][0] = i;
-#endif
-                info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
                 info->modMap[MIN_KEYCODE + i] = Mod1Mask;
                 break;
 
@@ -735,12 +733,12 @@ static void DarwinLoadKeyboardMapping(KeySymsRec *keySyms) {
     memset(keyInfo.keyMap, 0, sizeof(keyInfo.keyMap));
 
     /* TODO: Clean this up
-     * DarwinModeReadSystemKeymap is in quartz/quartzKeyboard.c
+     * QuartzReadSystemKeymap is in quartz/quartzKeyboard.c
      * DarwinParseNXKeyMapping is here
      */
     if (!DarwinParseNXKeyMapping(&keyInfo)) {
-        DEBUG_LOG("DarwinParseNXKeyMapping returned 0... running DarwinModeReadSystemKeymap().\n");
-        if (!DarwinModeReadSystemKeymap(&keyInfo)) {
+        DEBUG_LOG("DarwinParseNXKeyMapping returned 0... running QuartzReadSystemKeymap().\n");
+        if (!QuartzReadSystemKeymap(&keyInfo)) {
             FatalError("Could not build a valid keymap.");
         }
     }
@@ -790,7 +788,7 @@ void DarwinKeyboardInit(DeviceIntPtr pDev) {
     //    DarwinKeyboardReload(pDev);
     /* Initialize the seed, so we don't reload the keymap unnecessarily
        (and possibly overwrite xinitrc changes) */
-    DarwinModeSystemKeymapSeed();
+    QuartzSystemKeymapSeed();
 
     assert( InitKeyboardDeviceStruct( (DevicePtr)pDev, &keySyms,
                                       keyInfo.modMap, QuartzBell,
diff --git a/hw/xquartz/quartzKeyboard.c b/hw/xquartz/quartzKeyboard.c
index 0a50d06..9b899ca 100644
--- a/hw/xquartz/quartzKeyboard.c
+++ b/hw/xquartz/quartzKeyboard.c
@@ -66,11 +66,11 @@ const static struct {
     {55,  XK_Meta_L},
     {56,  XK_Shift_L},
     {57,  XK_Caps_Lock},
-    {58,  XK_Mode_switch},
+    {58,  XK_Alt_L},
     {59,  XK_Control_L},
 
     {60,  XK_Shift_R},
-    {61,  XK_Mode_switch},
+    {61,  XK_Alt_R},
     {62,  XK_Control_R},
     {63,  XK_Meta_R},
 
@@ -146,7 +146,7 @@ const static struct {
     {UKEYSYM (0x31b), XK_dead_horn},		/* COMBINING HORN */
 };
 
-unsigned int DarwinModeSystemKeymapSeed(void) {
+unsigned int QuartzSystemKeymapSeed(void) {
     static unsigned int seed;
     static KeyboardLayoutRef last_key_layout;
     KeyboardLayoutRef key_layout;
@@ -195,7 +195,7 @@ static KeySym make_dead_key(KeySym in) {
     return in;
 }
 
-Bool DarwinModeReadSystemKeymap(darwinKeyboardInfo *info) {
+Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) {
     KeyboardLayoutRef key_layout;
     const void *chr_data = NULL;
     int num_keycodes = NUM_KEYCODES;
diff --git a/hw/xquartz/quartzKeyboard.h b/hw/xquartz/quartzKeyboard.h
index c5f22bf..0c7e70e 100644
--- a/hw/xquartz/quartzKeyboard.h
+++ b/hw/xquartz/quartzKeyboard.h
@@ -47,7 +47,7 @@ typedef struct darwinKeyboardInfo_struct {
 
 /* These functions need to be implemented by XQuartz, XDarwin, etc. */
 void DarwinKeyboardReload(DeviceIntPtr pDev);
-Bool DarwinModeReadSystemKeymap(darwinKeyboardInfo *info);
-unsigned int DarwinModeSystemKeymapSeed(void);
+Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info);
+unsigned int QuartzSystemKeymapSeed(void);
 
 #endif /* QUARTZ_KEYBOARD_H */
commit 80089a20edf3c00bc4ffcf6a4808c9c5cf813f33
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Mon Dec 10 20:33:30 2007 -0800

    Xquartz: Removed Xplugin.h from EXTRA_DIST
    (cherry picked from commit a746383eca77c9b9ea2cba0cf1c8fc39c0f7d536)

diff --git a/hw/xquartz/bundle/Makefile.am b/hw/xquartz/bundle/Makefile.am
index e8d5167..5734434 100644
--- a/hw/xquartz/bundle/Makefile.am
+++ b/hw/xquartz/bundle/Makefile.am
@@ -15,6 +15,9 @@ endif
 clean-local:
 	rm -rf build
 
+resourcedir=$(libdir)/X11/xserver
+resource_DATA = Xquartz.plist
+
 EXTRA_DIST = \
 	org.x.X11.plist \
 	Info.plist \
diff --git a/hw/xquartz/bundle/Xquartz.plist b/hw/xquartz/bundle/Xquartz.plist
new file mode 100644
index 0000000..e157045
--- /dev/null
+++ b/hw/xquartz/bundle/Xquartz.plist
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+
+<!-- This file contains system-wide defaults for the Apple X11 server -->
+
+<plist version="1.0">
+<dict>
+	<key>apps_menu</key>
+	<array>
+		<array>
+			<string>Terminal</string>
+			<string>xterm</string>
+			<string>n</string>
+		</array>
+		<array>
+			<string>xman</string>
+			<string>xman</string>
+			<string></string>
+		</array>
+		<array>
+			<string>xlogo</string>
+			<string>xlogo</string>
+			<string></string>
+		</array>
+	</array>
+</dict>
+</plist>
diff --git a/hw/xquartz/bundle/org.x.X11.plist.in b/hw/xquartz/bundle/org.x.X11.plist.in
index 36849cf..26eca96 100644
--- a/hw/xquartz/bundle/org.x.X11.plist.in
+++ b/hw/xquartz/bundle/org.x.X11.plist.in
@@ -4,8 +4,6 @@
 <dict>
 	<key>Label</key>
 		<string>org.x.X11</string>
-	<key>Program</key>
-		<string>@APPLE_APPLICATIONS_DIR@/X11.app/Contents/MacOS/X11</string>
 	<key>ProgramArguments</key>
 		<array>
 		<string>@APPLE_APPLICATIONS_DIR@/X11.app/Contents/MacOS/X11</string>
diff --git a/hw/xquartz/xpr/Makefile.am b/hw/xquartz/xpr/Makefile.am
index c2419ca..87ed195 100644
--- a/hw/xquartz/xpr/Makefile.am
+++ b/hw/xquartz/xpr/Makefile.am
@@ -67,5 +67,4 @@ EXTRA_DIST = \
 	x-hash.h \
 	x-hook.h \
 	x-list.h \
-	Xplugin.h \
 	xpr.h
commit 247f7dcb87ccbe7625621c3ec0ce46d6d4cd6e63
Author: Ben Byer <bbyer at bbyer.local>
Date:   Sat Dec 8 23:33:27 2007 -0800

    Fixed bad calculation of dstEnd, which caused truncation of some bitblts
    (cherry picked from commit 8a057bc9e2eadd5b3296643e1b2337a5ef647cb2)

diff --git a/fb/fbbltone.c b/fb/fbbltone.c
index e636665..88ada9d 100644
--- a/fb/fbbltone.c
+++ b/fb/fbbltone.c
@@ -191,7 +191,7 @@ fbBltOne (FbStip    *src,
      * Do not read or write past the end of the buffer!
      */
     srcEnd = src + height * srcStride;
-    dstEnd = dst + height * dstStride;
+    dstEnd = dst + dstX + height * dstStride;
 
     /*
      * Number of destination units in FbBits == number of stipple pixels
@@ -612,7 +612,7 @@ fbBltOne24 (FbStip	*srcLine,
      * Do not read or write past the end of the buffer!
      */
     srcEnd = srcLine + height * srcStride;
-    dstEnd = dst + height * dstStride;
+    dstEnd = dst + dstX + height * dstStride;
 
     srcLine += srcX >> FB_STIP_SHIFT;
     dst += dstX >> FB_SHIFT;
commit 83c0f69aa19ff274f00878323bb7d7fdb030bc85
Author: Ben Byer <bbyer at bbyer.local>
Date:   Sat Dec 8 23:34:40 2007 -0800

    remove Xplugin.h, because we should use the one in /usr/include
    (cherry picked from commit 3e881032f35f774ff9638678d7e3f77c81f62976)

diff --git a/hw/xquartz/xpr/Xplugin.h b/hw/xquartz/xpr/Xplugin.h
deleted file mode 100644
index a10b1b8..0000000
--- a/hw/xquartz/xpr/Xplugin.h
+++ /dev/null
@@ -1,589 +0,0 @@
-/* Xplugin.h -- windowing API for rootless X11 server
-
-   Copyright (c) 2002 Apple Computer, Inc. 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 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.
-
-   Note that these interfaces are provided solely for the use of the
-   X11 server. Any other uses are unsupported and strongly discouraged. */
-
-#ifndef XPLUGIN_H
-#define XPLUGIN_H 1
-
-#include <stdint.h>
-
-/* By default we use the X server definition of BoxRec to define xp_box,
-   so that the compiler can silently convert between the two. But if
-   XP_NO_X_HEADERS is defined, we'll define it ourselves. */
-
-#ifndef XP_NO_X_HEADERS
-# include "miscstruct.h"
-  typedef BoxRec xp_box;
-#else
-  struct xp_box_struct {
-      short x1, y1, x2, y2;
-  };
-  typedef struct xp_box_struct xp_box;
-#endif
-
-typedef unsigned int xp_resource_id;
-typedef xp_resource_id xp_window_id;
-typedef xp_resource_id xp_surface_id;
-typedef unsigned int xp_client_id;
-typedef unsigned int xp_request_type;
-typedef int xp_error;
-typedef int xp_bool;
-
-
-/* Error codes that the functions declared here may return. They all
-   numerically match their X equivalents, i.e. the XP_ can be dropped
-   if <X11/X.h> has been included. */
-
-enum xp_error_enum {
-    XP_Success			= 0,
-    XP_BadRequest		= 1,
-    XP_BadValue			= 2,
-    XP_BadWindow		= 3,
-    XP_BadMatch			= 8,
-    XP_BadAccess		= 10,
-    XP_BadImplementation	= 17,
-};    
-
-
-/* Event types generated by the plugin. */
-
-enum xp_event_type_enum {
-    /* The global display configuration changed somehow. */
-    XP_EVENT_DISPLAY_CHANGED	= 1 << 0,
-
-    /* A window changed state. Argument is xp_window_state_event */
-    XP_EVENT_WINDOW_STATE_CHANGED = 1 << 1,
-
-    /* An async request encountered an error. Argument is of type
-       xp_async_error_event */
-    XP_EVENT_ASYNC_ERROR	= 1 << 2,
-
-    /* Sent when a surface is destroyed as a side effect of destroying
-       a window. Arg is of type xp_surface_id. */
-    XP_EVENT_SURFACE_DESTROYED	= 1 << 3,
-
-    /* Sent when any GL contexts pointing at the given surface need to
-       call xp_update_gl_context () to refresh their state (because the
-       window moved or was resized. Arg is of type xp_surface_id. */
-    XP_EVENT_SURFACE_CHANGED	= 1 << 4,
-
-    /* Sent when a window has been moved. Arg is of type xp_window_id. */
-    XP_EVENT_WINDOW_MOVED	= 1 << 5,
-};
-
-/* Function type used to receive events. */
-
-typedef void (xp_event_fun) (unsigned int type, const void *arg,
-			     unsigned int arg_size, void *user_data);
-
-
-/* Operation types. Used when reporting errors asynchronously. */
-
-enum xp_request_type_enum {
-    XP_REQUEST_NIL = 0,
-    XP_REQUEST_DESTROY_WINDOW = 1,
-    XP_REQUEST_CONFIGURE_WINDOW = 2,
-    XP_REQUEST_FLUSH_WINDOW = 3,
-    XP_REQUEST_COPY_WINDOW = 4,
-    XP_REQUEST_UNLOCK_WINDOW = 5,
-    XP_REQUEST_DISABLE_UPDATE = 6,
-    XP_REQUEST_REENABLE_UPDATE = 7,
-    XP_REQUEST_HIDE_CURSOR = 8,
-    XP_REQUEST_SHOW_CURSOR = 9,
-    XP_REQUEST_FRAME_DRAW = 10,
-};
-
-/* Structure used to report an error asynchronously. Passed as the "arg"
-   of an XP_EVENT_ASYNC_ERROR event. */
-
-struct xp_async_error_event_struct {
-    xp_request_type request_type;
-    xp_resource_id id;
-    xp_error error;
-};
-
-typedef struct xp_async_error_event_struct xp_async_error_event;
-
-
-/* Possible window states. */
-
-enum xp_window_state_enum {
-    /* The window is not in the global list of possibly-visible windows. */
-    XP_WINDOW_STATE_OFFSCREEN	= 1 << 0,
-
-    /* Parts of the window may be obscured by other windows. */
-    XP_WINDOW_STATE_OBSCURED	= 1 << 1,
-};
-
-/* Structure passed as argument of an XP_EVENT_WINDOW_STATE_CHANGED event. */
-
-struct xp_window_state_event_struct {
-    xp_window_id id;
-    unsigned int state;
-};
-
-typedef struct xp_window_state_event_struct xp_window_state_event;
-
-
-/* Function type used to supply a colormap for indexed drawables. */
-
-typedef xp_error (xp_colormap_fun) (void *data, int first_color,
-				    int n_colors, uint32_t *colors);
-
-
-/* Window attributes structure. Used when creating and configuring windows.
-   Also used when configuring surfaces attached to windows. Functions that
-   take one of these structures also take a bit mask defining which
-   fields are set to meaningful values. */
-
-enum xp_window_changes_enum {
-    XP_ORIGIN			= 1 << 0,
-    XP_SIZE			= 1 << 1,
-    XP_BOUNDS			= XP_ORIGIN | XP_SIZE,
-    XP_SHAPE			= 1 << 2,
-    XP_STACKING			= 1 << 3,
-    XP_DEPTH			= 1 << 4,
-    XP_COLORMAP			= 1 << 5,
-    XP_WINDOW_LEVEL		= 1 << 6,
-};
-
-struct xp_window_changes_struct {
-    /* XP_ORIGIN */
-    int x, y;
-
-    /* XP_SIZE */
-    unsigned int width, height;
-    int bit_gravity;			/* how to resize the backing store */
-
-    /* XP_SHAPE */
-    int shape_nrects;			/* -1 = remove shape */
-    xp_box *shape_rects;
-    int shape_tx, shape_ty;		/* translation for shape */
-
-    /* XP_STACKING */
-    int stack_mode;
-    xp_window_id sibling;		/* may be zero; in ABOVE/BELOW modes
-					   it may specify a relative window */
-    /* XP_DEPTH, window-only */
-    unsigned int depth;
-
-    /* XP_COLORMAP, window-only */
-    xp_colormap_fun *colormap;
-    void *colormap_data;
-
-    /* XP_WINDOW_LEVEL, window-only */
-    int window_level;
-};
-
-typedef struct xp_window_changes_struct xp_window_changes;
-
-/* Values for bit_gravity field */
-
-enum xp_bit_gravity_enum {
-    XP_GRAVITY_NONE		= 0,	/* no gravity, fill everything */
-    XP_GRAVITY_NORTH_WEST	= 1,	/* anchor to top-left corner */
-    XP_GRAVITY_NORTH_EAST	= 2,	/* anchor to top-right corner */
-    XP_GRAVITY_SOUTH_EAST	= 3,	/* anchor to bottom-right corner */
-    XP_GRAVITY_SOUTH_WEST	= 4,	/* anchor to bottom-left corner */
-};
-
-/* Values for stack_mode field */
-
-enum xp_window_stack_mode_enum {
-    XP_UNMAPPED			= 0,	/* remove the window */
-    XP_MAPPED_ABOVE		= 1,	/* display the window on top */
-    XP_MAPPED_BELOW		= 2,	/* display the window at bottom */
-};
-
-/* Data formats for depth field and composite functions */
-
-enum xp_depth_enum {
-    XP_DEPTH_NIL = 0,			/* null source when compositing */
-    XP_DEPTH_ARGB8888,
-    XP_DEPTH_RGB555,
-    XP_DEPTH_A8,			/* for masks when compositing */
-    XP_DEPTH_INDEX8,
-};
-
-/* Options that may be passed to the xp_init () function. */
-
-enum xp_init_options_enum {
-    /* Don't mark that this process can be in the foreground. */
-    XP_IN_BACKGROUND		= 1 << 0,
-
-    /* Deliver background pointer events to this process. */
-    XP_BACKGROUND_EVENTS	= 1 << 1,
-};
-
-
-
-/* Miscellaneous functions */
-
-/* Initialize the plugin library. Only the copy/fill/composite functions
-   may be called without having previously called xp_init () */
-
-extern xp_error xp_init (unsigned int options);
-
-/* Sets the current set of requested notifications to MASK. When any of
-   these arrive, CALLBACK will be invoked with CALLBACK-DATA. Note that
-   calling this function cancels any previously requested notifications
-   that aren't set in MASK. */
-
-extern xp_error xp_select_events (unsigned int mask,
-				  xp_event_fun *callback,
-				  void *callback_data);
-
-/* Waits for all initiated operations to complete. */
-
-extern xp_error xp_synchronize (void);
-
-/* Causes any display update initiated through the plugin libary to be
-   queued until update is reenabled. Note that calls to these functions
-   nest. */
-  
-extern xp_error xp_disable_update (void);
-extern xp_error xp_reenable_update (void);
-
-
-
-/* Cursor functions. */
-
-/* Installs the specified cursor. ARGB-DATA should point to 32-bit
-   premultiplied big-endian ARGB data. The HOT-X,HOT-Y parameters
-   specify the offset to the cursor's hot spot from its top-left
-   corner. */
-
-extern xp_error xp_set_cursor (unsigned int width, unsigned int height,
-			       unsigned int hot_x, unsigned int hot_y,
-			       const uint32_t *argb_data,
-			       unsigned int rowbytes);
-
-/* Hide and show the cursor if it's owned by the current process. Calls
-   to these functions nest. */
-
-extern xp_error xp_hide_cursor (void);
-extern xp_error xp_show_cursor (void);
-
-
-
-/* Window functions. */
-
-/* Create a new window as defined by MASK and VALUES. MASK must contain
-   XP_BOUNDS or an error is raised. The id of the newly created window
-   is stored in *RET-ID if this function returns XP_Success. */
-
-extern xp_error xp_create_window (unsigned int mask,
-				  const xp_window_changes *values,
-				  xp_window_id *ret_id);
-
-/* Destroys the window identified by ID. */
-
-extern xp_error xp_destroy_window (xp_window_id id);
-
-/* Reconfigures the given window according to MASK and VALUES. */
-
-extern xp_error xp_configure_window (xp_window_id id, unsigned int mask,
-				     const xp_window_changes *values);
-
-
-/* Returns true if NATIVE-ID is a window created by the plugin library.
-   If so and RET-ID is non-null, stores the id of the window in *RET-ID. */
-
-extern xp_bool xp_lookup_native_window (unsigned int native_id,
-					xp_window_id *ret_id);
-
-/* If ID names a window created by the plugin library, stores it's native
-   window id in *RET-NATIVE-ID. */
-
-extern xp_error xp_get_native_window (xp_window_id id,
-				      unsigned int *ret_native_id);
-
-
-/* Locks the rectangle IN-RECT (or, if null, the entire window) of the
-   given window's backing store. Any other non-null parameters are filled
-   in as follows:
-
-   DEPTH = format of returned data. Currently either XP_DEPTH_ARGB8888
-   or XP_DEPTH_RGB565 (possibly with 8 bit planar alpha). Data is
-   always stored in native byte order.
-
-   BITS[0] = pointer to top-left pixel of locked color data
-   BITS[1] = pointer to top-left of locked alpha data, or null if window
-   has no alpha. If the alpha data is meshed, then BITS[1] = BITS[0].
-
-   ROWBYTES[0,1] = size in bytes of each row of color,alpha data
-
-   OUT-RECT = rectangle specifying the current position and size of the
-   locked region relative to the window origin.
-
-   Note that an error is raised when trying to lock an already locked
-   window. While the window is locked, the only operations that may
-   be performed on it are to modify, access or flush its marked region. */
-
-extern xp_error xp_lock_window (xp_window_id id,
-				const xp_box *in_rect,
-				unsigned int *depth,
-				void *bits[2],
-				unsigned int rowbytes[2],
-				xp_box *out_rect);
-
-/* Mark that the region specified by SHAPE-NRECTS, SHAPE-RECTS,
-   SHAPE-TX, and SHAPE-TY in the specified window has been updated, and
-   will need to subsequently be redisplayed. */
-
-extern xp_error xp_mark_window (xp_window_id id, int shape_nrects,
-				const xp_box *shape_rects,
-				int shape_tx, int shape_ty);
-
-/* Unlocks the specified window. If FLUSH is true, then any marked
-   regions are immediately redisplayed. Note that it's an error to
-   unlock an already unlocked window. */
-
-extern xp_error xp_unlock_window (xp_window_id id, xp_bool flush);
-
-/* If anything is marked in the given window for redisplay, do it now. */
-
-extern xp_error xp_flush_window (xp_window_id id);
-
-/* Moves the contents of the region DX,DY pixels away from that specified
-   by DST_RECTS and DST_NRECTS in the window with SRC-ID to the
-   destination region in the window DST-ID. Note that currently source
-   and destination windows must be the same. */
-
-extern xp_error xp_copy_window (xp_window_id src_id, xp_window_id dst_id,
-				int dst_nrects, const xp_box *dst_rects,
-				int dx, int dy);
-
-/* Returns true if the given window has any regions marked for
-   redisplay. */
-
-extern xp_bool xp_is_window_marked (xp_window_id id);
-
-/* If successful returns a superset of the region marked for update in
-   the given window. Use xp_free_region () to release the returned data. */
-
-extern xp_error xp_get_marked_shape (xp_window_id id,
-				     int *ret_nrects, xp_box **ret_rects);
-
-extern void xp_free_shape (int nrects, xp_box *rects);
-
-/* Searches for the first window below ABOVE-ID containing the point X,Y,
-   and returns it's window id in *RET-ID. If no window is found, *RET-ID
-   is set to zero. If ABOVE-ID is zero, finds the topmost window
-   containing the given point. */
-
-extern xp_error xp_find_window (int x, int y, xp_window_id above_id,
-				xp_window_id *ret_id);
-
-/* Returns the current origin and size of the window ID in *BOUNDS-RET if
-   successful. */
-extern xp_error xp_get_window_bounds (xp_window_id id, xp_box *bounds_ret);
-
-
-
-/* Window surface functions. */
-
-/* Create a new VRAM surface on the specified window. If successful,
-   returns the identifier of the new surface in *RET-SID. */
-
-extern xp_error xp_create_surface (xp_window_id id, xp_surface_id *ret_sid);
-
-/* Destroys the specified surface. */
-
-extern xp_error xp_destroy_surface (xp_surface_id sid);
-
-/* Reconfigures the specified surface as defined by MASK and VALUES.
-   Note that specifying XP_DEPTH is an error. */
-
-extern xp_error xp_configure_surface (xp_surface_id sid, unsigned int mask,
-				      const xp_window_changes *values);
-
-/* If successful, places the client identifier of the current process
-   in *RET-CLIENT. */
-
-extern xp_error xp_get_client_id (xp_client_id *ret_client);
-
-/* Given a valid window,surface combination created by the current
-   process, attempts to allow the specified external client access
-   to that surface. If successful, returns two integers in RET-KEY
-   which the client can use to import the surface into their process. */
-
-extern xp_error xp_export_surface (xp_window_id wid, xp_surface_id sid,
-				   xp_client_id client,
-				   unsigned int ret_key[2]);
-
-/* Given a two integer key returned from xp_export_surface (), tries
-   to import the surface into the current process. If successful the
-   local surface identifier is stored in *SID-RET. */
-
-extern xp_error xp_import_surface (const unsigned int key[2],
-				   xp_surface_id *sid_ret);
-
-/* If successful, stores the number of surfaces attached to the
-   specified window in *RET. */
-
-extern xp_error xp_get_window_surface_count (xp_window_id id,
-					     unsigned int *ret);
-
-/* Attaches the CGLContextObj CGL-CTX to the specified surface. */
-
-extern xp_error xp_attach_gl_context (void *cgl_ctx, xp_surface_id sid);
-
-/* Updates the CGLContextObj CGL-CTX to reflect any recent changes to
-   the surface it's attached to. */
-
-extern xp_error xp_update_gl_context (void *cgl_ctx);
-
-
-
-/* Window frame functions. */
-
-/* Possible arguments to xp_frame_get_rect (). */
-
-enum xp_frame_rect_enum {
-    XP_FRAME_RECT_TITLEBAR		= 1,
-    XP_FRAME_RECT_TRACKING		= 2,
-    XP_FRAME_RECT_GROWBOX		= 3,
-};
-
-/* Classes of window frame. */
-
-enum xp_frame_class_enum {
-    XP_FRAME_CLASS_DOCUMENT		= 1 << 0,
-    XP_FRAME_CLASS_DIALOG		= 1 << 1,
-    XP_FRAME_CLASS_MODAL_DIALOG		= 1 << 2,
-    XP_FRAME_CLASS_SYSTEM_MODAL_DIALOG	= 1 << 3,
-    XP_FRAME_CLASS_UTILITY		= 1 << 4,
-    XP_FRAME_CLASS_TOOLBAR		= 1 << 5,
-    XP_FRAME_CLASS_MENU			= 1 << 6,
-    XP_FRAME_CLASS_SPLASH		= 1 << 7,
-    XP_FRAME_CLASS_BORDERLESS		= 1 << 8,
-};
-
-/* Attributes of window frames. */
-
-enum xp_frame_attr_enum {
-    XP_FRAME_ACTIVE			= 0x0001,
-    XP_FRAME_URGENT			= 0x0002,
-    XP_FRAME_TITLE			= 0x0004,
-    XP_FRAME_PRELIGHT			= 0x0008,
-    XP_FRAME_SHADED			= 0x0010,
-    XP_FRAME_CLOSE_BOX			= 0x0100,
-    XP_FRAME_COLLAPSE			= 0x0200,
-    XP_FRAME_ZOOM			= 0x0400,
-    XP_FRAME_ANY_BUTTON			= 0x0700,
-    XP_FRAME_CLOSE_BOX_CLICKED		= 0x0800,
-    XP_FRAME_COLLAPSE_BOX_CLICKED	= 0x1000,
-    XP_FRAME_ZOOM_BOX_CLICKED		= 0x2000,
-    XP_FRAME_ANY_CLICKED		= 0x3800,
-    XP_FRAME_GROW_BOX			= 0x4000,
-};
-
-#define XP_FRAME_ATTR_IS_SET(a,b)	(((a) & (b)) == (b))
-#define XP_FRAME_ATTR_IS_CLICKED(a,m)	((a) & ((m) << 3))
-#define XP_FRAME_ATTR_SET_CLICKED(a,m)	((a) |= ((m) << 3))
-#define XP_FRAME_ATTR_UNSET_CLICKED(a,m) ((a) &= ~((m) << 3))
-
-#define XP_FRAME_POINTER_ATTRS		(XP_FRAME_PRELIGHT		\
-					 | XP_FRAME_ANY_BUTTON		\
-					 | XP_FRAME_ANY_CLICKED)
-
-extern xp_error xp_frame_get_rect (int type, int class, const xp_box *outer,
-				   const xp_box *inner, xp_box *ret);
-extern xp_error xp_frame_hit_test (int class, int x, int y,
-				   const xp_box *outer,
-				   const xp_box *inner, int *ret);
-extern xp_error xp_frame_draw (xp_window_id wid, int class, unsigned int attr,
-			       const xp_box *outer, const xp_box *inner,
-			       unsigned int title_len,
-			       const unsigned char *title_bytes);
-
-
-
-/* Memory manipulation functions. */
-
-enum xp_composite_op_enum {
-    XP_COMPOSITE_SRC = 0,
-    XP_COMPOSITE_OVER,
-};
-
-#define XP_COMPOSITE_FUNCTION(op, src_depth, mask_depth, dest_depth) \
-    (((op) << 24) | ((src_depth) << 16) \
-     | ((mask_depth) << 8) | ((dest_depth) << 0))
-
-#define XP_COMPOSITE_FUNCTION_OP(f)         (((f) >> 24) & 255)
-#define XP_COMPOSITE_FUNCTION_SRC_DEPTH(f)  (((f) >> 16) & 255)
-#define XP_COMPOSITE_FUNCTION_MASK_DEPTH(f) (((f) >>  8) & 255)
-#define XP_COMPOSITE_FUNCTION_DEST_DEPTH(f) (((f) >>  0) & 255)
-
-/* Composite WIDTH by HEIGHT pixels from source and mask to destination
-   using a specified function (if source and destination overlap,
-   undefined behavior results).
-
-   For SRC and DEST, the first element of the array is the color data. If
-   the second element is non-null it implies that there is alpha data
-   (which may be meshed or planar). Data without alpha is assumed to be
-   opaque.
-
-   Passing a null SRC-ROWBYTES pointer implies that the data SRC points
-   to is a single element.
-
-   Operations that are not supported will return XP_BadImplementation. */
-
-extern xp_error xp_composite_pixels (unsigned int width, unsigned int height,
-				     unsigned int function,
-				     void *src[2], unsigned int src_rowbytes[2],
-				     void *mask, unsigned int mask_rowbytes,
-				     void *dest[2], unsigned int dest_rowbytes[2]);
-
-/* Fill HEIGHT rows of data starting at DST. Each row will have WIDTH
-   bytes filled with the 32-bit pattern VALUE. Each row is DST-ROWBYTES
-   wide in total. */
-
-extern void xp_fill_bytes (unsigned int width,
-			   unsigned int height, uint32_t value,
-			   void *dst, unsigned int dst_rowbytes);
-
-/* Copy HEIGHT rows of bytes from SRC to DST. Each row will have WIDTH
-   bytes copied. SRC and DST may overlap, and the right thing will happen. */
-
-extern void xp_copy_bytes (unsigned int width, unsigned int height,
-			   const void *src, unsigned int src_rowbytes,
-			   void *dst, unsigned int dst_rowbytes);
-
-/* Suggestions for the minimum number of bytes or pixels for which it
-   makes sense to use some of the xp_ functions */
-
-extern unsigned int xp_fill_bytes_threshold, xp_copy_bytes_threshold,
-    xp_composite_area_threshold, xp_scroll_area_threshold;
-
-
-#endif /* XPLUGIN_H */
commit 14ec1cf1cb7ebc183c05e13f9c2b4b4eed679ff3
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Sun Dec 9 12:02:04 2007 -0800

    Xquartz: Added missing link to libconfig.a

diff --git a/hw/xquartz/xpr/Makefile.am b/hw/xquartz/xpr/Makefile.am
index 3cc2aba..c2419ca 100644
--- a/hw/xquartz/xpr/Makefile.am
+++ b/hw/xquartz/xpr/Makefile.am
@@ -24,6 +24,7 @@ Xquartz_SOURCES = \
 Xquartz_LDADD = \
 	$(top_builddir)/hw/xquartz/libXquartz.la \
 	$(top_builddir)/dix/dixfonts.lo \
+	$(top_builddir)/config/libconfig.a \
 	$(top_builddir)/dix/libdix.la \
 	$(top_builddir)/os/libos.la \
 	$(top_builddir)/dix/libxpstubs.la \
commit 3d9e4ebfe3937b03bafa535a9971632749ee3df8
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Sat Dec 8 13:18:17 2007 -0800

    .gitignore: added hw/xquartz/bundle/org.x.X11.plist
    (cherry picked from commit cd13c4ba5b7a1bdfb419cb492a96a72dccf2681e)

diff --git a/.gitignore b/.gitignore
index 2e60d58..37f35f4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -275,6 +275,7 @@ hw/xprint/doc/Xprt.1x
 hw/xprint/doc/Xprt.man
 hw/xprint/dpmsstubs-wrapper.c
 hw/xprint/miinitext-wrapper.c
+hw/xquartz/bundle/org.x.X11.plist
 include/dix-config.h
 include/kdrive-config.h
 include/xgl-config.h
commit 8a056b8e0906dbfaaba2dcf59cf4ff0af1d922e3
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Sat Dec 8 11:49:37 2007 -0800

    Xquartz Added quartzKeyboard.h to EXTRA_DIST
    (cherry picked from commit 37c9781fdb672229ceab101b080762e15512943f)

diff --git a/hw/xquartz/Makefile.am b/hw/xquartz/Makefile.am
index 43200f4..b026ee1 100644
--- a/hw/xquartz/Makefile.am
+++ b/hw/xquartz/Makefile.am
@@ -44,10 +44,11 @@ EXTRA_DIST = \
 	darwinKeyboard.h \
 	keysym2ucs.h \
 	pseudoramiX.h \
+	quartz.h \
 	quartzAudio.h \
 	quartzCommon.h \
 	quartzCursor.c \
 	quartzCursor.h \
 	quartzForeground.h \
-	quartz.h \
+	quartzKeyboard.h \
 	quartzPasteboard.h
commit 3ea32bac43269b88aa367efab435b7b744fa4850
Author: Ben Byer <bbyer at bbyer.local>
Date:   Sat Dec 8 06:12:46 2007 -0800

    Added darwinEvents.h to EXTRA_DIST
    (cherry picked from commit 45e5247564c423a2bf02cfec1993155858c91a14)

diff --git a/hw/xquartz/Makefile.am b/hw/xquartz/Makefile.am
index b6a1de9..43200f4 100644
--- a/hw/xquartz/Makefile.am
+++ b/hw/xquartz/Makefile.am
@@ -40,6 +40,7 @@ EXTRA_DIST = \
 	applewmExt.h \
 	darwinClut8.h \
 	darwin.h \
+	darwinEvents.h \
 	darwinKeyboard.h \
 	keysym2ucs.h \
 	pseudoramiX.h \
commit b72e8fa49939e241c872b2c2a49aac757ef88604
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Sat Dec 8 01:41:37 2007 -0800

    Xquartz: Actually add quartzForeground.[hc]
    Sorry for the commit spam... I'm tired and was overly quick to commit... forgot to include a neccessary file.
    (cherry picked from commit e564b7aeaab63e4c943445275af680b3b5898a94)

diff --git a/hw/xquartz/quartzForeground.c b/hw/xquartz/quartzForeground.c
new file mode 100644
index 0000000..bfea642
--- /dev/null
+++ b/hw/xquartz/quartzForeground.c
@@ -0,0 +1,45 @@
+/* foreground.c - Push the current process into the foreground.
+
+ This is in a separate file because of Quartz/X type conflicts.
+
+ Copyright (c) 2007 Jeremy Huddleston
+ 
+ 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 <ApplicationServices/ApplicationServices.h>
+#include <stdio.h>
+
+int QuartzMoveToForeground() {
+   ProcessSerialNumber psn = { 0, kCurrentProcess };
+   OSStatus returnCode = TransformProcessType(& psn, kProcessTransformToForegroundApplication);
+   if( returnCode == 0) {
+       fprintf(stderr, "TransformProcessType: Success\n");
+       SetFrontProcess(&psn);
+   } else {
+       fprintf(stderr, "TransformProcessType: Failure\n");
+   }
+   return (int)returnCode;
+}
diff --git a/hw/xquartz/quartzForeground.h b/hw/xquartz/quartzForeground.h
new file mode 100644
index 0000000..4fc21c7
--- /dev/null
+++ b/hw/xquartz/quartzForeground.h
@@ -0,0 +1,37 @@
+/* foreground.h - Push the current process into the foreground.
+ 
+ This is in a separate file because of Quartz/X type conflicts.
+ 
+ Copyright (c) 2007 Jeremy Huddleston
+ 
+ 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 _QUARTZ_FOREGROUND_H_
+#define _QUARTZ_FOREGROUND_H_
+
+int QuartzMoveToForeground();
+
+#endif /* _QUARTZ_FOREGROUND_H_ */
commit 2c7c378619e0e8d81ea2df4f7d5221d709099079
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Sat Dec 8 01:28:26 2007 -0800

    Xquartz: Actually, it should be org.x.X11 for case-sensitive FS
    (cherry picked from commit c5ccb98d5d461c8a22fc0f3942a607ac90e1e37e)

diff --git a/hw/xquartz/bundle/server-main.c b/hw/xquartz/bundle/server-main.c
index 205e87c..7e1bd70 100644
--- a/hw/xquartz/bundle/server-main.c
+++ b/hw/xquartz/bundle/server-main.c
@@ -138,7 +138,7 @@ read_boolean_pref (CFStringRef name, int default_)
     int value;
     Boolean ok;
 	
-    value = CFPreferencesGetAppBooleanValue (name, CFSTR ("org.x.x11"), &ok);
+    value = CFPreferencesGetAppBooleanValue (name, CFSTR ("org.x.X11"), &ok);
     return ok ? value : default_;
 }
 
commit 3357ef0f40b4d6c1c93c3c54bfc6e9a5168b056f
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Sat Dec 8 01:24:58 2007 -0800

    Xquartz: Use org.x.X11 instead of com.apple.X11 for preferences
    Fixed inconsistency so preferences get read from the correct source.
    (cherry picked from commit a74c38bd9f28735acd602d359d7ca6357aed1e93)

diff --git a/hw/xquartz/bundle/server-main.c b/hw/xquartz/bundle/server-main.c
index 26fcbb0..205e87c 100644
--- a/hw/xquartz/bundle/server-main.c
+++ b/hw/xquartz/bundle/server-main.c
@@ -138,8 +138,7 @@ read_boolean_pref (CFStringRef name, int default_)
     int value;
     Boolean ok;
 	
-    value = CFPreferencesGetAppBooleanValue (name,
-											 CFSTR ("com.apple.x11"), &ok);
+    value = CFPreferencesGetAppBooleanValue (name, CFSTR ("org.x.x11"), &ok);
     return ok ? value : default_;
 }
 
commit 743b266c17c68146bd5e4148a667220ae03ce603
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Sat Dec 8 00:13:47 2007 -0800

    XQuartz: Fixed "Multiple Dock Icons"
    BAM!
    (cherry picked from commit d0dca8a88506f50b51f41f99a2f1feb6954c8a31)
    (cherry picked from commit 0502955a2af487b51bf22916ac02e497c2d96aba)

diff --git a/hw/xquartz/Makefile.am b/hw/xquartz/Makefile.am
index fff7c4b..b6a1de9 100644
--- a/hw/xquartz/Makefile.am
+++ b/hw/xquartz/Makefile.am
@@ -29,6 +29,7 @@ libXquartz_la_SOURCES = \
 	quartz.c \
 	quartzAudio.c \
 	quartzCocoa.m \
+	quartzForeground.c \
 	quartzKeyboard.c \
 	quartzPasteboard.c \
 	quartzStartup.c
@@ -46,5 +47,6 @@ EXTRA_DIST = \
 	quartzCommon.h \
 	quartzCursor.c \
 	quartzCursor.h \
+	quartzForeground.h \
 	quartz.h \
 	quartzPasteboard.h
diff --git a/hw/xquartz/bundle/Info.plist b/hw/xquartz/bundle/Info.plist
index 66f1f6b..fce8c96 100644
--- a/hw/xquartz/bundle/Info.plist
+++ b/hw/xquartz/bundle/Info.plist
@@ -3,33 +3,37 @@
 <plist version="1.0">
 <dict>
 	<key>CFBundleDevelopmentRegion</key>
-	<string>English</string>
+		<string>English</string>
 	<key>CFBundleExecutable</key>
-	<string>X11</string>
+		<string>X11</string>
 	<key>CFBundleGetInfoString</key>
-	<string>X11</string>
+		<string>X11</string>
 	<key>CFBundleIconFile</key>
-	<string>X11.icns</string>
+		<string>X11.icns</string>
 	<key>CFBundleIdentifier</key>
-	<string>org.x.X11</string>
+		<string>org.x.X11</string>
 	<key>CFBundleInfoDictionaryVersion</key>
-	<string>6.0</string>
+		<string>6.0</string>
 	<key>CFBundleName</key>
-	<string>X11</string>
+		<string>X11</string>
 	<key>CFBundlePackageType</key>
-	<string>APPL</string>
+		<string>APPL</string>
 	<key>CFBundleShortVersionString</key>
-	<string>2.0</string>
+		<string>2.2.0</string>
 	<key>CFBundleSignature</key>
-	<string>x11a</string>
+		<string>x11a</string>
 	<key>CSResourcesFileMapped</key>
-	<true/>
+		<true/>
 	<key>NSHumanReadableCopyright</key>
-	<string>Copyright © 2003-2007, Apple Inc.
-Copyright © 2003, XFree86 Project, Inc.</string>
+		<string>Copyright © 2003-2007, Apple Inc.
+Copyright © 2003, XFree86 Project, Inc.
+Copyright © 2003-2007, X.org Project, Inc.
+</string>
 	<key>NSMainNibFile</key>
-	<string>main</string>
+		<string>main</string>
 	<key>NSPrincipalClass</key>
-	<string>X11Application</string>
+		<string>X11Application</string>
+	<key>LSBackgroundOnly</key>
+		<true/>
 </dict>
 </plist>
diff --git a/hw/xquartz/bundle/bundle-main.c b/hw/xquartz/bundle/bundle-main.c
index 6f9744c..53f60a3 100644
--- a/hw/xquartz/bundle/bundle-main.c
+++ b/hw/xquartz/bundle/bundle-main.c
@@ -38,22 +38,13 @@ int server_main(int argc, char **argv);
 
 int main(int argc, char **argv) {
     Display *display;
-  
-    fprintf(stderr, "X11.app: main(): argc=%d\n", argc);
-    int i;
-    for(i=0; i < argc; i++) {
-        fprintf(stderr, "\targv[%d] = %s\n", i, argv[i]);
-    }
-    
-    /* First check if launchd started us */
-    if(argc == 2 && !strncmp(argv[1], "-launchd", 8)) {
-        argc--;
-        argv[1] = argv[0];
-        argv++;
-        fprintf(stderr, "X11.app: main(): launchd called us, running server_main()");
-        return server_main(argc, argv);
-    }
 
+    //size_t i;
+    //fprintf(stderr, "X11.app: main(): argc=%d\n", argc);
+    //for(i=0; i < argc; i++) {
+    //    fprintf(stderr, "\targv[%u] = %s\n", (unsigned)i, argv[i]);
+    //}
+    
     /* If we have a process serial number and it's our only arg, act as if
      * the user double clicked the app bundle: launch app_to_run if possible
      */
@@ -64,19 +55,18 @@ int main(int argc, char **argv) {
             fprintf(stderr, "X11.app: main(): closing the display");
             /* Could open the display, start the launcher */
             XCloseDisplay(display);
-
+            
             /* Give 2 seconds for the server to start... 
              * TODO: *Really* fix this race condition
              */
             usleep(2000);
-            fprintf(stderr, "X11.app: main(): running launcher_main()");
+            //fprintf(stderr, "X11.app: main(): running launcher_main()");
             return launcher_main(argc, argv);
         }
     }
-
-    /* Couldn't open the display or we were called with arguments,
-     * just want to start a server.
-     */
-    fprintf(stderr, "X11.app: main(): running server_main()");
+    
+    /* Start the server */
+    //fprintf(stderr, "X11.app: main(): running server_main()");
     return server_main(argc, argv);
 }
+
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index a106cca..aaed261 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -707,6 +707,11 @@ void ddxInitGlobals(void)
  */
 int ddxProcessArgument( int argc, char *argv[], int i )
 {
+    if( !strcmp( argv[i], "-launchd" ) ) {
+        ErrorF( "Launchd command line argument noticed.\n" );
+        return 1;
+    }
+
     if ( !strcmp( argv[i], "-fullscreen" ) ) {
         ErrorF( "Running full screen in parallel with Mac OS X Quartz window server.\n" );
         return 1;
diff --git a/hw/xquartz/quartzStartup.c b/hw/xquartz/quartzStartup.c
index e20c16b..87bcada 100644
--- a/hw/xquartz/quartzStartup.c
+++ b/hw/xquartz/quartzStartup.c
@@ -34,6 +34,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <CoreFoundation/CoreFoundation.h>
+#include "quartzForeground.h"
 #include "quartzCommon.h"
 #include "darwin.h"
 #include "quartz.h"
@@ -76,6 +77,8 @@ void DarwinHandleGUI(
     int         i;
     int         fd[2];
 
+    QuartzMoveToForeground();
+    
     if (been_here) {
         return;
     }
commit 5676ba6fc07022adcc6368218237fcb812b8d25d
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Fri Dec 7 23:21:08 2007 -0800

    XQuartz: Cleaned up configure, X11.app path in launchd script
    Don't hardcode X11.app's path in the launchd plist.
    Only install the launchd plist if we --enable-launchd.
    (cherry picked from commit 6b74c535dc331d1d621b2541492a3336f69d70a2)

diff --git a/configure.ac b/configure.ac
index 7297dc7..0fab244 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1730,47 +1730,56 @@ fi
 if test "x$XQUARTZ" = xyes; then
 	AC_DEFINE([XQUARTZ],[1],[Have Quartz])
 
-#	       glxAGL / glxCGL don't work yet
-#               AC_CACHE_CHECK([for AGL framework],xorg_cv_AGL_framework,[
-#               save_LDFLAGS=$LDFLAGS
-#               LDFLAGS="$LDFLAGS -framework AGL"
-#               AC_LINK_IFELSE([char aglEnable();
-#int main() {
-#aglEnable();
-#return 0;}
-#               ],[xorg_cv_AGL_framework=yes],
-#               [xorg_cv_AGL_framework=no])
-#               LDFLAGS=$save_LDFLAGS
-#               ])
-               xorg_cv_AGL_framework=no
-	       DARWIN_GLX_LIBS='$(top_builddir)/GL/apple/indirect.o $(top_builddir)/GL/glx/libglx.la'
-	       DARWIN_LIBS="$MI_LIB $OS_LIB $DIX_LIB $FB_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB $DARWIN_GLX_LIBS"
-	       AC_SUBST([DARWIN_LIBS])
-               AC_CHECK_LIB([Xplugin],[xp_init],[:])
-               AC_SUBST([APPLE_APPLICATIONS_DIR])
-               CFLAGS="${CFLAGS} -DROOTLESS_WORKAROUND -DNO_ALLOCA"
-               PLIST_VERSION_STRING=$PACKAGE_VERSION
-               AC_SUBST([PLIST_VERSION_STRING])
-               PLIST_VENDOR_WEB=$VENDOR_WEB
-               AC_SUBST([PLIST_VENDOR_WEB])
-               if test "x$XF86MISC" = xyes || test "x$XF86MISC" = xauto; then
-                       AC_MSG_NOTICE([Disabling XF86Misc extension])
-                       XF86MISC=no
-               fi
-               if test "x$XF86VIDMODE" = xyes || test "x$XF86VIDMODE" = xauto; then
-                       AC_MSG_NOTICE([Disabling XF86VidMode extension])
-                       XF86VIDMODE=no
-               fi
-               if test "x$XF86BIGFONT" = xyes || test "x$XF86BIGFONT" = xauto; then
-                       AC_MSG_NOTICE([Disabling XF86BigFont extension])
-                       XF86BIGFONT=no
-               fi
-               if test "x$DGA" = xyes || test "x$DGA" = xauto; then
-                       AC_MSG_NOTICE([Disabling DGA extension])
-                       DGA=no
-               fi
+#glxAGL / glxCGL don't work yet
+#	AC_CACHE_CHECK([for AGL framework],xorg_cv_AGL_framework,[
+#		save_LDFLAGS=$LDFLAGS
+#		LDFLAGS="$LDFLAGS -framework AGL"
+#		AC_LINK_IFELSE(
+#			[char aglEnable(); int main() { aglEnable(); return 0;}],
+#			[xorg_cv_AGL_framework=yes],
+#			[xorg_cv_AGL_framework=no])
+#		LDFLAGS=$save_LDFLAGS
+#	])
+	xorg_cv_AGL_framework=no
+	DARWIN_GLX_LIBS='$(top_builddir)/GL/apple/indirect.o $(top_builddir)/GL/glx/libglx.la'
+	DARWIN_LIBS="$MI_LIB $OS_LIB $DIX_LIB $FB_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB $DARWIN_GLX_LIBS"
+	AC_SUBST([DARWIN_LIBS])
+	AC_CHECK_LIB([Xplugin],[xp_init],[:])
+	AC_SUBST([APPLE_APPLICATIONS_DIR])
+	CFLAGS="${CFLAGS} -DROOTLESS_WORKAROUND -DNO_ALLOCA"
+	if test "x$XF86MISC" = xyes || test "x$XF86MISC" = xauto; then
+		AC_MSG_NOTICE([Disabling XF86Misc extension])
+		XF86MISC=no
+	fi
+	if test "x$XF86VIDMODE" = xyes || test "x$XF86VIDMODE" = xauto; then
+		AC_MSG_NOTICE([Disabling XF86VidMode extension])
+		XF86VIDMODE=no
+	fi
+	if test "x$XF86BIGFONT" = xyes || test "x$XF86BIGFONT" = xauto; then
+		AC_MSG_NOTICE([Disabling XF86BigFont extension])
+		XF86BIGFONT=no
+	fi
+	if test "x$DGA" = xyes || test "x$DGA" = xauto; then
+		AC_MSG_NOTICE([Disabling DGA extension])
+		DGA=no
+	fi
 fi
 
+# Support for objc in autotools is minimal and not documented.
+OBJC='$(CC)'
+OBJCLD='$(CCLD)'
+OBJCLINK='$(LINK)'
+OBJCFLAGS='$(CFLAGS)'
+AC_SUBST([OBJC])
+AC_SUBST([OBJCCLD])
+AC_SUBST([OBJCLINK])
+AC_SUBST([OBJCFLAGS])
+# internal, undocumented automake func follows :(
+_AM_DEPENDENCIES([OBJC])
+AM_CONDITIONAL(HAVE_XPLUGIN, [test "x$ac_cv_lib_Xplugin_xp_init" = xyes])
+AM_CONDITIONAL(HAVE_AGL_FRAMEWORK, [test "x$xorg_cv_AGL_framework" = xyes])
+AM_CONDITIONAL(XQUARTZ, [test "x$XQUARTZ" = xyes])
+
 if test "x$X11APP" = xauto; then
 	AC_MSG_CHECKING([whether to build X11.app])
 	if test "x$XQUARTZ" = xyes ; then
@@ -1780,6 +1789,7 @@ if test "x$X11APP" = xauto; then
 	fi
 	AC_MSG_RESULT([$X11APP])
 fi
+AM_CONDITIONAL(X11APP,[test "X$X11APP" = Xyes]) 
 
 if test "x$LAUNCHD" = xauto; then
 	# Do we want to have this default to on for Xquartz builds only or any time we have launchd (like Xnest or Xvfb on OS-X)
@@ -1796,22 +1806,7 @@ fi
 if test "x$LAUNCHD" = xyes ; then
 	AC_DEFINE(HAVE_LAUNCHD, 1, [launchd support available])
 fi
-
-# Support for objc in autotools is minimal and not documented.
-OBJC='$(CC)'
-OBJCLD='$(CCLD)'
-OBJCLINK='$(LINK)'
-OBJCFLAGS='$(CFLAGS)'
-AC_SUBST([OBJC])
-AC_SUBST([OBJCCLD])
-AC_SUBST([OBJCLINK])
-AC_SUBST([OBJCFLAGS])
-# internal, undocumented automake func follows :(
-_AM_DEPENDENCIES([OBJC])
-AM_CONDITIONAL(HAVE_XPLUGIN, [test "x$ac_cv_lib_Xplugin_xp_init" = xyes])
-AM_CONDITIONAL(HAVE_AGL_FRAMEWORK, [test "x$xorg_cv_AGL_framework" = xyes])
-AM_CONDITIONAL(XQUARTZ, [test "x$XQUARTZ" = xyes])
-AM_CONDITIONAL(X11APP,[test "X$X11APP" = Xyes]) 
+AM_CONDITIONAL(LAUNCHD, [test "x$LAUNCHD" = xyes])
 
 dnl kdrive DDX
 
@@ -2155,6 +2150,7 @@ hw/xnest/Makefile
 hw/xwin/Makefile
 hw/xquartz/Makefile
 hw/xquartz/bundle/Makefile
+hw/xquartz/bundle/org.x.X11.plist
 hw/xquartz/xpr/Makefile
 hw/kdrive/Makefile
 hw/kdrive/ati/Makefile
diff --git a/hw/xquartz/bundle/Makefile.am b/hw/xquartz/bundle/Makefile.am
index a6e2dfb..e8d5167 100644
--- a/hw/xquartz/bundle/Makefile.am
+++ b/hw/xquartz/bundle/Makefile.am
@@ -7,8 +7,10 @@ x11app:
 
 install-data-hook:
 	xcodebuild install DSTROOT="/$(DESTDIR)" INSTALL_PATH="$(APPLE_APPLICATIONS_DIR)" DEPLOYMENT_LOCATION=YES SKIP_INSTALL=NO ARCHS="$(X11APP_ARCHS)"
+if LAUNCHD
 	$(MKDIR_P) "$(DESTDIR)/System/Library/LaunchAgents/"
 	$(INSTALL) org.x.X11.plist "$(DESTDIR)/System/Library/LaunchAgents/"
+endif
 
 clean-local:
 	rm -rf build
diff --git a/hw/xquartz/bundle/bundle-main.c b/hw/xquartz/bundle/bundle-main.c
index c436d51..6f9744c 100644
--- a/hw/xquartz/bundle/bundle-main.c
+++ b/hw/xquartz/bundle/bundle-main.c
@@ -46,7 +46,7 @@ int main(int argc, char **argv) {
     }
     
     /* First check if launchd started us */
-    if(argc == 2 && !strncmp(argv[1], "--launchd", 9)) {
+    if(argc == 2 && !strncmp(argv[1], "-launchd", 8)) {
         argc--;
         argv[1] = argv[0];
         argv++;
diff --git a/hw/xquartz/bundle/org.x.X11.plist b/hw/xquartz/bundle/org.x.X11.plist
deleted file mode 100644
index 6c6be91..0000000
--- a/hw/xquartz/bundle/org.x.X11.plist
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>Label</key>
-		<string>org.x.X11</string>
-	<key>Program</key>
-		<string>/Applications/Utilities/X11.app/Contents/MacOS/X11</string>
-	<key>ProgramArguments</key>
-		<array>
-		<string>/Applications/Utilities/X11.app/Contents/MacOS/X11</string>
-		<string>--launchd</string>
-		</array>
-	<key>Sockets</key>
-		<dict>
-		<key>:0</key>
-			<dict>
-			<key>SecureSocketWithKey</key>
-				<string>DISPLAY</string>
-			</dict>
-		</dict>
-	<key>ServiceIPC</key>
-		<true/>
-</dict>
-</plist>
diff --git a/hw/xquartz/bundle/org.x.X11.plist.in b/hw/xquartz/bundle/org.x.X11.plist.in
new file mode 100644
index 0000000..36849cf
--- /dev/null
+++ b/hw/xquartz/bundle/org.x.X11.plist.in
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>Label</key>
+		<string>org.x.X11</string>
+	<key>Program</key>
+		<string>@APPLE_APPLICATIONS_DIR@/X11.app/Contents/MacOS/X11</string>
+	<key>ProgramArguments</key>
+		<array>
+		<string>@APPLE_APPLICATIONS_DIR@/X11.app/Contents/MacOS/X11</string>
+		<string>-launchd</string>
+		</array>
+	<key>Sockets</key>
+		<dict>
+		<key>:0</key>
+			<dict>
+			<key>SecureSocketWithKey</key>
+				<string>DISPLAY</string>
+			</dict>
+		</dict>
+	<key>ServiceIPC</key>
+		<true/>
+</dict>
+</plist>
commit f5e857e35b4773740b017b28ffe77374d3f57e67
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Fri Dec 7 22:48:34 2007 -0800

    FB: Formatting cleanup that got missed in the last commit...

diff --git a/fb/fbbltone.c b/fb/fbbltone.c
index 6dcc982..e636665 100644
--- a/fb/fbbltone.c
+++ b/fb/fbbltone.c
@@ -691,7 +691,7 @@ fbBltOne24 (FbStip	*srcLine,
 		{
 		    mask = fbStipple24Bits[rot >> 3][stip] & leftMask;
 		    CHECK_BOUNDS(dst, dstEnd);
-			WRITE(dst, (READ(dst) & ~mask) | (FbRot24(fgxor, rot) & mask));
+		    WRITE(dst, (READ(dst) & ~mask) | (FbRot24(fgxor, rot) & mask));
 		}
 		dst++;
 		fbNextStipBits (rot, stip);
@@ -702,7 +702,7 @@ fbBltOne24 (FbStip	*srcLine,
 		if (stip)
 		{
 		    mask = fbStipple24Bits[rot>>3][stip];
-			CHECK_BOUNDS(dst, dstEnd);
+		    CHECK_BOUNDS(dst, dstEnd);
 		    WRITE(dst, (READ(dst) & ~mask) | (FbRot24(fgxor,rot) & mask));
 		}
 		dst++;
@@ -713,7 +713,7 @@ fbBltOne24 (FbStip	*srcLine,
 		if (stip)
 		{
 		    mask = fbStipple24Bits[rot >> 3][stip] & rightMask;
-			CHECK_BOUNDS(dst, dstEnd);
+		    CHECK_BOUNDS(dst, dstEnd);
 		    WRITE(dst, (READ(dst) & ~mask) | (FbRot24(fgxor, rot) & mask));
 		}
 	    }
commit 1e1073334af05288158469e0241367144634fe4e
Author: Ben Byer <bbyer at bbyer.local>
Date:   Fri Dec 7 22:26:17 2007 -0800

    Added code to check for null pointers on fb* invocations
    (cherry picked from commit 6f441d79c7c884c8cd9315f490f7833a877344aa)

diff --git a/fb/fb.h b/fb/fb.h
index df430b8..65fa173 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -168,6 +168,11 @@ typedef CARD32		    FbStip;
 
 typedef int		    FbStride;
 
+#define CHECK_NULL(ptr) \
+  if ((ptr) == NULL) {\
+    ErrorF("%s:%d: null pointer\n", __FILE__, __LINE__); \
+    return; \
+  }
 
 #ifdef FB_DEBUG
 extern void fbValidateDrawable(DrawablePtr d);
@@ -717,6 +722,7 @@ typedef struct {
     (pointer) = (FbBits *) _pPix->devPrivate.ptr; \
     (stride) = ((int) _pPix->devKind) / sizeof (FbBits); (void)(stride); \
     (bpp) = _pPix->drawable.bitsPerPixel;  (void)(bpp); \
+    CHECK_NULL(pointer); \
 }
 
 #define fbGetStipDrawable(pDrawable, pointer, stride, bpp, xoff, yoff) { \
@@ -734,6 +740,7 @@ typedef struct {
     (pointer) = (FbStip *) _pPix->devPrivate.ptr; \
     (stride) = ((int) _pPix->devKind) / sizeof (FbStip); (void)(stride); \
     (bpp) = _pPix->drawable.bitsPerPixel; (void)(bpp); \
+    CHECK_NULL(pointer); \
 }
 
 /*
commit 24c54f53ff97b7bc814f7cb33d88e28b9bf536dc
Author: Ben Byer <bbyer at bbyer.local>
Date:   Fri Dec 7 21:56:45 2007 -0800

    Added checks to avoid writing past the end of the buffer in fbBltOne
    (cherry picked from commit e5f54f122b2068ff7b94a979ebadac4cf8eef20f)

diff --git a/fb/fbbltone.c b/fb/fbbltone.c
index ffe6977..6dcc982 100644
--- a/fb/fbbltone.c
+++ b/fb/fbbltone.c
@@ -56,6 +56,13 @@
     } else \
 	bits = (src < srcEnd ? READ(src++) : 0); \
 }
+
+#define CHECK_BOUNDS(pointer, limit) \
+  if (dst > dstEnd) { \
+    ErrorF("WARNING: fbbltone tried to write over end of buffer (dst=%p dstEnd=%p)\n", \
+	   dst, dstEnd); \
+    return; \
+  }
     
 #ifndef FBNOPIXADDR
     
@@ -148,7 +155,7 @@ fbBltOne (FbStip    *src,
 	  FbBits    bgxor)
 {
     const FbBits    *fbBits;
-    FbBits	    *srcEnd;
+    FbBits	    *srcEnd, *dstEnd;
     int		    pixelsPerDst;		/* dst pixels per FbBits */
     int		    unitsPerSrc;		/* src patterns per FbStip */
     int		    leftShift, rightShift;	/* align source with dest */
@@ -181,9 +188,10 @@ fbBltOne (FbStip    *src,
 #endif
 
     /*
-     * Do not read past the end of the buffer!
+     * Do not read or write past the end of the buffer!
      */
     srcEnd = src + height * srcStride;
+    dstEnd = dst + height * dstStride;
 
     /*
      * Number of destination units in FbBits == number of stipple pixels
@@ -296,6 +304,7 @@ fbBltOne (FbStip    *src,
 	     */
 	    if (startmask)
 	    {
+	      CHECK_BOUNDS(dst, dstEnd);
 #if FB_UNIT > 32
 		if (pixelsPerDst == 16)
 		    mask = FbStipple16Bits(FbLeftStipBits(bits,16));
@@ -336,6 +345,7 @@ fbBltOne (FbStip    *src,
 			else
 #endif
 			    mask = fbBits[FbLeftStipBits(bits,pixelsPerDst)];
+			CHECK_BOUNDS(dst, dstEnd);
 			WRITE(dst, FbOpaqueStipple (mask, fgxor, bgxor));
 			dst++;
 			bits = FbStipLeft(bits, pixelsPerDst);
@@ -346,6 +356,7 @@ fbBltOne (FbStip    *src,
 #ifndef FBNOPIXADDR
 		    if (fbLane)
 		    {
+		      CHECK_BOUNDS(dst, dstEnd);
 			while (bits && n)
 			{
 			    switch (fbLane[FbLeftStipBits(bits,pixelsPerDst)]) {
@@ -366,6 +377,7 @@ fbBltOne (FbStip    *src,
 			    if (left || !transparent)
 			    {
 				mask = fbBits[left];
+				CHECK_BOUNDS(dst, dstEnd);
 				WRITE(dst, FbStippleRRop (READ(dst), mask,
 						          fgand, fgxor, bgand, bgxor));
 			    }
@@ -586,7 +598,7 @@ fbBltOne24 (FbStip	*srcLine,
 	    FbBits	bgand,
 	    FbBits	bgxor)
 {
-    FbStip	*src, *srcEnd;
+    FbStip	*src, *srcEnd, *dstEnd;
     FbBits	leftMask, rightMask, mask;
     int		nlMiddle, nl;
     FbStip	stip, bits;
@@ -597,9 +609,10 @@ fbBltOne24 (FbStip	*srcLine,
     int		nDst;
     
     /*
-     * Do not read past the end of the buffer!
+     * Do not read or write past the end of the buffer!
      */
     srcEnd = srcLine + height * srcStride;
+    dstEnd = dst + height * dstStride;
 
     srcLine += srcX >> FB_STIP_SHIFT;
     dst += dstX >> FB_SHIFT;
@@ -629,6 +642,7 @@ fbBltOne24 (FbStip	*srcLine,
 	    if (leftMask)
 	    {
 		mask = fbStipple24Bits[rot >> 3][stip];
+		CHECK_BOUNDS(dst, dstEnd);
 		WRITE(dst, (READ(dst) & ~leftMask) |
 			    (FbOpaqueStipple (mask,
 					      FbRot24(fgxor, rot),
@@ -641,6 +655,7 @@ fbBltOne24 (FbStip	*srcLine,
 	    while (nl--)
 	    {
 		mask = fbStipple24Bits[rot>>3][stip];
+		CHECK_BOUNDS(dst, dstEnd);
 		WRITE(dst, FbOpaqueStipple (mask,
 					    FbRot24(fgxor, rot),
 					    FbRot24(bgxor, rot)));
@@ -650,6 +665,7 @@ fbBltOne24 (FbStip	*srcLine,
 	    if (rightMask)
 	    {
 		mask = fbStipple24Bits[rot >> 3][stip];
+		CHECK_BOUNDS(dst, dstEnd);
 		WRITE(dst, (READ(dst) & ~rightMask) |
 			    (FbOpaqueStipple (mask,
 					      FbRot24(fgxor, rot),
@@ -674,7 +690,8 @@ fbBltOne24 (FbStip	*srcLine,
 		if (stip)
 		{
 		    mask = fbStipple24Bits[rot >> 3][stip] & leftMask;
-		    WRITE(dst, (READ(dst) & ~mask) | (FbRot24(fgxor, rot) & mask));
+		    CHECK_BOUNDS(dst, dstEnd);
+			WRITE(dst, (READ(dst) & ~mask) | (FbRot24(fgxor, rot) & mask));
 		}
 		dst++;
 		fbNextStipBits (rot, stip);
@@ -685,6 +702,7 @@ fbBltOne24 (FbStip	*srcLine,
 		if (stip)
 		{
 		    mask = fbStipple24Bits[rot>>3][stip];
+			CHECK_BOUNDS(dst, dstEnd);
 		    WRITE(dst, (READ(dst) & ~mask) | (FbRot24(fgxor,rot) & mask));
 		}
 		dst++;
@@ -695,6 +713,7 @@ fbBltOne24 (FbStip	*srcLine,
 		if (stip)
 		{
 		    mask = fbStipple24Bits[rot >> 3][stip] & rightMask;
+			CHECK_BOUNDS(dst, dstEnd);
 		    WRITE(dst, (READ(dst) & ~mask) | (FbRot24(fgxor, rot) & mask));
 		}
 	    }
@@ -712,6 +731,7 @@ fbBltOne24 (FbStip	*srcLine,
 	    if (leftMask)
 	    {
 		mask = fbStipple24Bits[rot >> 3][stip];
+		CHECK_BOUNDS(dst, dstEnd);
 		WRITE(dst, FbStippleRRopMask (READ(dst), mask,
 					      FbRot24(fgand, rot),
 					      FbRot24(fgxor, rot),
@@ -725,6 +745,7 @@ fbBltOne24 (FbStip	*srcLine,
 	    while (nl--)
 	    {
 		mask = fbStipple24Bits[rot >> 3][stip];
+		CHECK_BOUNDS(dst, dstEnd);
 		WRITE(dst, FbStippleRRop (READ(dst), mask,
 					  FbRot24(fgand, rot),
 					  FbRot24(fgxor, rot),
@@ -736,6 +757,7 @@ fbBltOne24 (FbStip	*srcLine,
 	    if (rightMask)
 	    {
 		mask = fbStipple24Bits[rot >> 3][stip];
+		CHECK_BOUNDS(dst, dstEnd);
 		WRITE(dst, FbStippleRRopMask (READ(dst), mask,
 					      FbRot24(fgand, rot),
 					      FbRot24(fgxor, rot),
commit c8161d482adfbdf97be8482e985f1afe0bec24a9
Author: Ben Byer <bbyer at bbyer.local>
Date:   Fri Dec 7 21:55:42 2007 -0800

    Just a couple of small uninitialized pointer fixes
    (cherry picked from commit d12b650362da100ceaecb7e859cd4ef1908d4407)

diff --git a/miext/rootless/rootlessScreen.c b/miext/rootless/rootlessScreen.c
index 4af395e..503d57c 100644
--- a/miext/rootless/rootlessScreen.c
+++ b/miext/rootless/rootlessScreen.c
@@ -725,6 +725,8 @@ Bool RootlessInit(ScreenPtr pScreen, RootlessFrameProcsPtr procs)
         pScreen->devPrivates[rootlessScreenPrivateIndex].ptr;
 
     s->imp = procs;
+    s->colormap = NULL;
+    s->redisplay_expired = FALSE;
 
     RootlessWrap(pScreen);
 
commit aed01c4a8bd97e5aa8f52329940e509d946e6616
Author: Jeremy Huddleston <jeremy at dhcp-38-248.EECS.Berkeley.EDU>
Date:   Fri Dec 7 18:53:08 2007 -0800

    Darwin: Use __APPLE__ instead of __DARWIN__
    (cherry picked from commit 54654815fa5e59b25cfd1fa72610120b72c10175)

diff --git a/GL/glx/glxscreens.c b/GL/glx/glxscreens.c
index 43447a4..a2d14d5 100644
--- a/GL/glx/glxscreens.c
+++ b/GL/glx/glxscreens.c
@@ -170,7 +170,7 @@ static char GLXServerExtensions[] =
                         "GLX_EXT_texture_from_pixmap "
 			"GLX_OML_swap_method "
 			"GLX_SGI_make_current_read "
-#ifndef __DARWIN__
+#ifndef __APPLE__
 			"GLX_SGIS_multisample "
                         "GLX_SGIX_hyperpipe "
                         "GLX_SGIX_swap_barrier "
diff --git a/configure.ac b/configure.ac
index 1df3745..7297dc7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1748,7 +1748,7 @@ if test "x$XQUARTZ" = xyes; then
 	       AC_SUBST([DARWIN_LIBS])
                AC_CHECK_LIB([Xplugin],[xp_init],[:])
                AC_SUBST([APPLE_APPLICATIONS_DIR])
-               CFLAGS="${CFLAGS} -D__DARWIN__ -DROOTLESS_WORKAROUND -DNO_ALLOCA"
+               CFLAGS="${CFLAGS} -DROOTLESS_WORKAROUND -DNO_ALLOCA"
                PLIST_VERSION_STRING=$PACKAGE_VERSION
                AC_SUBST([PLIST_VERSION_STRING])
                PLIST_VENDOR_WEB=$VENDOR_WEB
diff --git a/hw/Makefile.am b/hw/Makefile.am
index 753d6a9..d3a3571 100644
--- a/hw/Makefile.am
+++ b/hw/Makefile.am
@@ -23,7 +23,7 @@ XPRINT_SUBDIRS = xprint
 endif
 
 if XQUARTZ
-DARWIN_SUBDIRS = xquartz
+XQUARTZ_SUBDIRS = xquartz
 endif
 
 SUBDIRS =			\
@@ -32,9 +32,9 @@ SUBDIRS =			\
 	$(XWIN_SUBDIRS)		\
 	$(XVFB_SUBDIRS)		\
 	$(XNEST_SUBDIRS)	\
-	$(DMX_SUBDIRS)          \
-        $(KDRIVE_SUBDIRS)	\
-        $(DARWIN_SUBDIRS)	\
+	$(DMX_SUBDIRS)		\
+	$(KDRIVE_SUBDIRS)	\
+	$(XQUARTZ_SUBDIRS)	\
 	$(XPRINT_SUBDIRS)
 
 DIST_SUBDIRS = dmx xfree86 vfb xnest xwin xquartz kdrive xgl xprint
diff --git a/hw/vfb/InitOutput.c b/hw/vfb/InitOutput.c
index a2d8661..e10076f 100644
--- a/hw/vfb/InitOutput.c
+++ b/hw/vfb/InitOutput.c
@@ -220,7 +220,7 @@ AbortDDX()
     ddxGiveUp();
 }
 
-#ifdef __DARWIN__
+#ifdef __APPLE__
 void
 DarwinHandleGUI(int argc, char *argv[])
 {
diff --git a/hw/xnest/Init.c b/hw/xnest/Init.c
index 5bf0300..2795c81 100644
--- a/hw/xnest/Init.c
+++ b/hw/xnest/Init.c
@@ -124,7 +124,7 @@ void ddxGiveUp()
   AbortDDX();
 }
 
-#ifdef __DARWIN__
+#ifdef __APPLE__
 void
 DarwinHandleGUI(int argc, char *argv[])
 {
diff --git a/hw/xprint/attributes.c b/hw/xprint/attributes.c
index d8ee5ad..4c6ad46 100644
--- a/hw/xprint/attributes.c
+++ b/hw/xprint/attributes.c
@@ -1378,7 +1378,7 @@ ReplaceAllKeywords(
     defined(ISC) || \
     defined(Lynx) || \
     defined(__QNX__) || \
-    defined(__DARWIN__)
+    defined(__APPLE__)
 #define iswspace(c) (isascii(c) && isspace(toascii(c)))
 #endif
 
diff --git a/hw/xprint/ddxInit.c b/hw/xprint/ddxInit.c
index a465c4c..2f08a84 100644
--- a/hw/xprint/ddxInit.c
+++ b/hw/xprint/ddxInit.c
@@ -205,7 +205,7 @@ ProcessInputEvents(void)
 {
 }
 
-#ifdef __DARWIN__
+#ifdef __APPLE__
 #include "micmap.h"
 
 void GlxExtensionInit(void);
diff --git a/include/cursor.h b/include/cursor.h
index bdf4fd3..dc0810c 100644
--- a/include/cursor.h
+++ b/include/cursor.h
@@ -70,7 +70,7 @@ extern int FreeCursor(
 
 /* Quartz support on Mac OS X pulls in the QuickDraw
    framework whose AllocCursor function conflicts here. */ 
-#ifdef __DARWIN__
+#ifdef __APPLE__
 #define AllocCursor Darwin_X_AllocCursor
 #endif
 extern CursorPtr AllocCursor(
diff --git a/include/dixfont.h b/include/dixfont.h
index 709da62..d6d13b4 100644
--- a/include/dixfont.h
+++ b/include/dixfont.h
@@ -118,7 +118,7 @@ extern void DeleteClientFontStuff(ClientPtr /*client*/);
 
 /* Quartz support on Mac OS X pulls in the QuickDraw
    framework whose InitFonts function conflicts here. */
-#ifdef __DARWIN__
+#ifdef __APPLE__
 #define InitFonts Darwin_X_InitFonts
 #endif
 extern void InitFonts(void);
diff --git a/include/resource.h b/include/resource.h
index 3231e8c..6c0d5dc 100644
--- a/include/resource.h
+++ b/include/resource.h
@@ -153,7 +153,7 @@ extern XID FakeClientID(
 
 /* Quartz support on Mac OS X uses the CarbonCore
    framework whose AddResource function conflicts here. */
-#ifdef __DARWIN__
+#ifdef __APPLE__
 #define AddResource Darwin_X_AddResource
 #endif
 extern Bool AddResource(
diff --git a/include/window.h b/include/window.h
index 312b75e..58e2c49 100644
--- a/include/window.h
+++ b/include/window.h
@@ -125,7 +125,7 @@ extern void DestroySubwindows(
 
 /* Quartz support on Mac OS X uses the HIToolbox
    framework whose ChangeWindowAttributes function conflicts here. */
-#ifdef __DARWIN__
+#ifdef __APPLE__
 #define ChangeWindowAttributes Darwin_X_ChangeWindowAttributes
 #endif
 extern int ChangeWindowAttributes(
@@ -136,7 +136,7 @@ extern int ChangeWindowAttributes(
 
 /* Quartz support on Mac OS X uses the HIToolbox
    framework whose GetWindowAttributes function conflicts here. */
-#ifdef __DARWIN__
+#ifdef __APPLE__
 #define GetWindowAttributes(w,c,x) Darwin_X_GetWindowAttributes(w,c,x)
 extern void Darwin_X_GetWindowAttributes(
 #else
diff --git a/miext/rootless/rootlessConfig.h b/miext/rootless/rootlessConfig.h
index 3e326bf..ab0187e 100644
--- a/miext/rootless/rootlessConfig.h
+++ b/miext/rootless/rootlessConfig.h
@@ -34,7 +34,7 @@
 #ifndef _ROOTLESSCONFIG_H
 #define _ROOTLESSCONFIG_H
 
-#ifdef __DARWIN__
+#ifdef __APPLE__
 
 # define ROOTLESS_ACCEL TRUE
 # define ROOTLESS_GLOBAL_COORDS TRUE
@@ -48,7 +48,7 @@
    alpha for 16bpp. */
 # define RootlessAlphaMask(bpp) ((bpp) == 32 ? 0xFF000000 : 0)
 
-#endif /* __DARWIN__ */
+#endif /* __APPLE__ */
 
 #if defined(__CYGWIN__) || defined(WIN32)
 
commit 4ae562166460507c0b51dea03ac1b3dc4b731160
Merge: be59012... 9f46891...
Author: Jeremy Huddleston <jeremy at spr-wlan-199.AirBears.Berkeley.EDU>
Date:   Fri Dec 7 14:14:32 2007 -0800

    Merge branch 'server-1.4-branch' into xorg-server-1.4-apple

commit be590129210d93a73180475d2756b3fa971b3af3
Author: Ben Byer <bbyer at bbyer.local>
Date:   Fri Dec 7 01:51:53 2007 -0800

    fixed pathname in GL/apple/Makefile.am
    (cherry picked from commit b6357cec6d837226009c0d2b69026027da36656e)

diff --git a/GL/apple/Makefile.am b/GL/apple/Makefile.am
index f1e02cc..7ad9140 100644
--- a/GL/apple/Makefile.am
+++ b/GL/apple/Makefile.am
@@ -4,8 +4,8 @@ AM_CPPFLAGS = \
 	-I$(top_srcdir)/GL/glx \
 	-I$(top_srcdir)/GL/include \
 	-I$(top_srcdir)/GL/mesa/glapi \
-	-I$(top_srcdir)/hw/darwin/quartz \
-	-I$(top_srcdir)/hw/darwin/quartz/xpr \
+	-I$(top_srcdir)/hw/xquartz \
+	-I$(top_srcdir)/hw/xquartz/xpr \
 	-I$(top_srcdir)/miext/damage
 
 noinst_LIBRARIES = libCGLcore.a 
commit dc56305e16e776c947747403f8ee472ec7b76b0a
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Thu Dec 6 20:51:32 2007 -0800

    ALLOCATE_LOCAL is dangerous on Darwin due to memory layout differences
    from Linux, so let's define NO_ALLOCA.
    (cherry picked from commit 7caf51d1a5a86ae884e0087795636222c082962c)

diff --git a/configure.ac b/configure.ac
index 62fd4a9..1df3745 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1748,7 +1748,7 @@ if test "x$XQUARTZ" = xyes; then
 	       AC_SUBST([DARWIN_LIBS])
                AC_CHECK_LIB([Xplugin],[xp_init],[:])
                AC_SUBST([APPLE_APPLICATIONS_DIR])
-               CFLAGS="${CFLAGS} -D__DARWIN__ -DROOTLESS_WORKAROUND"
+               CFLAGS="${CFLAGS} -D__DARWIN__ -DROOTLESS_WORKAROUND -DNO_ALLOCA"
                PLIST_VERSION_STRING=$PACKAGE_VERSION
                AC_SUBST([PLIST_VERSION_STRING])
                PLIST_VENDOR_WEB=$VENDOR_WEB
commit 06c46ec050c97cc395af9e11520f2b0488ac4354
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Wed Dec 5 21:36:34 2007 -0800

    Darwin: Dead coded removal
    Kill off assert macro
    (cherry picked from commit d6493abedb2caf03b2bc3a6440b637df67eff081)

diff --git a/hw/xquartz/darwin.h b/hw/xquartz/darwin.h
index a332229..f835ae0 100644
--- a/hw/xquartz/darwin.h
+++ b/hw/xquartz/darwin.h
@@ -52,12 +52,6 @@ int DarwinParseModifierList(const char *constmodifiers);
 void DarwinAdjustScreenOrigins(ScreenInfo *pScreenInfo);
 void xf86SetRootClip (ScreenPtr pScreen, BOOL enable);
 
-#undef assert
-#define assert(x) { if ((x) == 0) \
-    FatalError("assert failed on line %d of %s!\n", __LINE__, __FILE__); }
-#define kern_assert(x) { if ((x) != KERN_SUCCESS) \
-    FatalError("assert failed on line %d of %s with kernel return 0x%x!\n", \
-                __LINE__, __FILE__, x); }
 #define SCREEN_PRIV(pScreen) \
     ((DarwinFramebufferPtr)pScreen->devPrivates[darwinScreenIndex].ptr)
 
commit 446efcc554195970cb3ddcd992f7aac617d45b1d
Author: Bartosz Fabianowski <freebsd at chillt.de>
Date:   Fri Dec 7 02:38:14 2007 +0000

    Input: Fix proximity events with valuators
    
    Initialise num_events to 1, so we always send a proximity event, and then
    optionally valuator events.  Also make sure mieq can deal with valuator
    events sent after proximity events.
    (cherry picked from commit 2dcfab37d38c0c72e9be7cc724047405c8029e88)

diff --git a/dix/getevents.c b/dix/getevents.c
index b70653d..12d8189 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -705,7 +705,7 @@ _X_EXPORT int
 GetProximityEvents(xEvent *events, DeviceIntPtr pDev, int type,
                    int first_valuator, int num_valuators, int *valuators)
 {
-    int num_events = 0;
+    int num_events = 1;
     deviceKeyButtonPointer *kbp = (deviceKeyButtonPointer *) events;
 
     /* Sanity checks. */
diff --git a/mi/mieq.c b/mi/mieq.c
index 20c4b62..e644090 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -128,7 +128,9 @@ mieqEnqueue(DeviceIntPtr pDev, xEvent *e)
         if (oldtail == miEventQueue.head ||
             !(lastkbp->type == DeviceMotionNotify ||
               lastkbp->type == DeviceButtonPress ||
-              lastkbp->type == DeviceButtonRelease) ||
+              lastkbp->type == DeviceButtonRelease ||
+              lastkbp->type == ProximityIn ||
+              lastkbp->type == ProximityOut) ||
             ((lastkbp->deviceid & DEVICE_BITS) !=
              (v->deviceid & DEVICE_BITS))) {
             ErrorF("mieqEnequeue: out-of-order valuator event; dropping.\n");
commit 898b03775e5c4c0ae6ec4feb4f70f390234ebab7
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Wed Dec 5 21:23:36 2007 -0800

    Darwin: Renamed DarwinModeBlah to QuartzBlah
    (cherry picked from commit 08ebf86d379b1ddfb08df65d29aea5df66de4327)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index c976b63..aaecd0d 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -39,6 +39,7 @@
 /* ouch! */
 #define BOOL X_BOOL
 # include "darwin.h"
+# include "darwinEvents.h"
 # include "quartz.h"
 # define _APPLEWM_SERVER_
 # include "X11/extensions/applewm.h"
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index d5d3037..a106cca 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -75,6 +75,9 @@
 #endif
 
 #include "darwin.h"
+#include "darwinEvents.h"
+#include "darwinKeyboard.h"
+#include "quartz.h"
 #include "darwinClut8.h"
 
 #ifdef ENABLE_DEBUG_LOG
@@ -195,7 +198,7 @@ static Bool DarwinAddScreen(
     pScreen->devPrivates[darwinScreenIndex].ptr = dfb;
 
     // setup hardware/mode specific details
-    ret = DarwinModeAddScreen(foundIndex, pScreen);
+    ret = QuartzAddScreen(foundIndex, pScreen);
     foundIndex++;
     if (! ret)
         return FALSE;
@@ -274,7 +277,7 @@ static Bool DarwinAddScreen(
     pScreen->SaveScreen = DarwinSaveScreen;
 
     // finish mode dependent screen setup including cursor support
-    if (!DarwinModeSetupScreen(index, pScreen)) {
+    if (!QuartzSetupScreen(index, pScreen)) {
         return FALSE;
     }
 
@@ -539,7 +542,7 @@ void InitInput( int argc, char **argv )
 
     DarwinEQInit( (DevicePtr)darwinKeyboard, (DevicePtr)darwinPointer );
 
-    DarwinModeInitInput(argc, argv);
+    QuartzInitInput(argc, argv);
 }
 
 
@@ -629,7 +632,7 @@ void InitOutput( ScreenInfo *pScreenInfo, int argc, char **argv )
     }
 
     // Discover screens and do mode specific initialization
-    DarwinModeInitOutput(argc, argv);
+    QuartzInitOutput(argc, argv);
 
     // Add screens
     for (i = 0; i < darwinScreensFound; i++) {
@@ -895,7 +898,7 @@ void ddxGiveUp( void )
 {
     ErrorF( "Quitting XQuartz...\n" );
 
-    DarwinModeGiveUp();
+    QuartzGiveUp();
 }
 
 
diff --git a/hw/xquartz/darwin.h b/hw/xquartz/darwin.h
index 0f5f492..a332229 100644
--- a/hw/xquartz/darwin.h
+++ b/hw/xquartz/darwin.h
@@ -52,26 +52,6 @@ int DarwinParseModifierList(const char *constmodifiers);
 void DarwinAdjustScreenOrigins(ScreenInfo *pScreenInfo);
 void xf86SetRootClip (ScreenPtr pScreen, BOOL enable);
 
-// From darwinEvents.c
-Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr);
-void DarwinEQEnqueue(const xEvent *e);
-void DarwinEQPointerPost(xEvent *e);
-void DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX);
-void DarwinPokeEQ(void);
-void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int pointer_y);
-void DarwinSendKeyboardEvents(int ev_type, int keycode);
-void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y);
-
-// Mode specific functions
-Bool DarwinModeAddScreen(int index, ScreenPtr pScreen);
-Bool DarwinModeSetupScreen(int index, ScreenPtr pScreen);
-void DarwinModeInitOutput(int argc,char **argv);
-void DarwinModeInitInput(int argc, char **argv);
-void DarwinModeProcessEvent(xEvent *xe);
-void DarwinModeGiveUp(void);
-void DarwinModeBell(int volume, DeviceIntPtr pDevice, pointer ctrl, int class);
-
-
 #undef assert
 #define assert(x) { if ((x) == 0) \
     FatalError("assert failed on line %d of %s!\n", __LINE__, __FILE__); }
@@ -81,10 +61,6 @@ void DarwinModeBell(int volume, DeviceIntPtr pDevice, pointer ctrl, int class);
 #define SCREEN_PRIV(pScreen) \
     ((DarwinFramebufferPtr)pScreen->devPrivates[darwinScreenIndex].ptr)
 
-
-#define MIN_KEYCODE XkbMinLegalKeyCode     // unfortunately, this isn't 0...
-
-
 /*
  * Global variables from darwin.c
  */
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 629fb2c..ae82f5b 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -43,6 +43,7 @@ in this Software without prior written authorization from The Open Group.
 #include   "mipointer.h"
 
 #include "darwin.h"
+#include "quartz.h"
 #include "darwinKeyboard.h"
 
 #include <sys/types.h>
@@ -361,7 +362,7 @@ void ProcessInputEvents(void) {
 				// fall through
             default:
                 // Check for mode specific event
-                DarwinModeProcessEvent(&xe);
+                QuartzProcessEvent(&xe);
             }
         }
     }
diff --git a/hw/xquartz/darwinEvents.h b/hw/xquartz/darwinEvents.h
new file mode 100644
index 0000000..d6cab2e
--- /dev/null
+++ b/hw/xquartz/darwinEvents.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2001-2004 Torrey T. Lyons. 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
+ * 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 _DARWIN_EVENTS_H
+#define _DARWIN_EVENTS_H
+
+Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr);
+void DarwinEQEnqueue(const xEvent *e);
+void DarwinEQPointerPost(xEvent *e);
+void DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX);
+void DarwinPokeEQ(void);
+void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int pointer_y);
+void DarwinSendKeyboardEvents(int ev_type, int keycode);
+void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y);
+
+#endif  /* _DARWIN_EVENTS_H */
diff --git a/hw/xquartz/darwinKeyboard.c b/hw/xquartz/darwinKeyboard.c
index 1c83cbc..f6dcfb3 100644
--- a/hw/xquartz/darwinKeyboard.c
+++ b/hw/xquartz/darwinKeyboard.c
@@ -73,6 +73,8 @@
 #include <architecture/byte_order.h>  // For the NXSwap*
 #include "darwin.h"
 #include "darwinKeyboard.h"
+#include "quartzKeyboard.h"
+#include "quartzAudio.h"
 
 #ifdef NDEBUG
 #undef NDEBUG
@@ -791,7 +793,7 @@ void DarwinKeyboardInit(DeviceIntPtr pDev) {
     DarwinModeSystemKeymapSeed();
 
     assert( InitKeyboardDeviceStruct( (DevicePtr)pDev, &keySyms,
-                                      keyInfo.modMap, DarwinModeBell,
+                                      keyInfo.modMap, QuartzBell,
                                       DarwinChangeKeyboardControl ));
 }
 
diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index 2483d12..7be91ec 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -35,6 +35,7 @@
 #include "quartzCommon.h"
 #include "quartz.h"
 #include "darwin.h"
+#include "darwinEvents.h"
 #include "quartzAudio.h"
 #include "pseudoramiX.h"
 #define _APPLEWM_SERVER_
@@ -74,25 +75,25 @@ QuartzModeProcsPtr      quartzProcs = NULL;
 const char             *quartzOpenGLBundle = NULL;
 
 #if defined(RANDR) && !defined(FAKE_RANDR)
-Bool DarwinModeRandRGetInfo (ScreenPtr pScreen, Rotation *rotations) {
+Bool QuartzRandRGetInfo (ScreenPtr pScreen, Rotation *rotations) {
   return FALSE;
 }
 
-Bool DarwinModeRandRSetConfig (ScreenPtr           pScreen,
+Bool QuartzRandRSetConfig (ScreenPtr           pScreen,
 			       Rotation            randr,
 			       int                 rate,
 			       RRScreenSizePtr     pSize) {
   return FALSE;
 }
 
-Bool DarwinModeRandRInit (ScreenPtr pScreen) {
+Bool QuartzRandRInit (ScreenPtr pScreen) {
   rrScrPrivPtr    pScrPriv;
     
   if (!RRScreenInit (pScreen)) return FALSE;
 
   pScrPriv = rrGetScrPriv(pScreen);
-  pScrPriv->rrGetInfo = DarwinModeRandRGetInfo;
-  pScrPriv->rrSetConfig = DarwinModeRandRSetConfig;
+  pScrPriv->rrGetInfo = QuartzRandRGetInfo;
+  pScrPriv->rrSetConfig = QuartzRandRSetConfig;
   return TRUE;
 }
 #endif
@@ -106,10 +107,10 @@ Bool DarwinModeRandRInit (ScreenPtr pScreen) {
 */
 
 /*
- * DarwinModeAddScreen
+ * QuartzAddScreen
  *  Do mode dependent initialization of each screen for Quartz.
  */
-Bool DarwinModeAddScreen(
+Bool QuartzAddScreen(
     int index,
     ScreenPtr pScreen)
 {
@@ -125,10 +126,10 @@ Bool DarwinModeAddScreen(
 
 
 /*
- * DarwinModeSetupScreen
+ * QuartzSetupScreen
  *  Finalize mode specific setup of each screen.
  */
-Bool DarwinModeSetupScreen(
+Bool QuartzSetupScreen(
     int index,
     ScreenPtr pScreen)
 {
@@ -145,10 +146,10 @@ Bool DarwinModeSetupScreen(
 
 
 /*
- * DarwinModeInitOutput
+ * QuartzInitOutput
  *  Quartz display initialization.
  */
-void DarwinModeInitOutput(
+void QuartzInitOutput(
     int argc,
     char **argv )
 {
@@ -184,10 +185,10 @@ void DarwinModeInitOutput(
 
 
 /*
- * DarwinModeInitInput
+ * QuartzInitInput
  *  Inform the main thread the X server is ready to handle events.
  */
-void DarwinModeInitInput(
+void QuartzInitInput(
     int argc,
     char **argv )
 {
@@ -279,7 +280,7 @@ static void QuartzUpdateScreens(void)
     pScreen->height = height;
     
 #ifndef FAKE_RANDR
-    if(!DarwinModeRandRInit(pScreen))
+    if(!QuartzRandRInit(pScreen))
       FatalError("Failed to init RandR extension.\n");
 #endif
 
@@ -412,10 +413,10 @@ QuartzMessageServerThread(
 
 
 /*
- * DarwinModeProcessEvent
+ * QuartzProcessEvent
  *  Process Quartz specific events.
  */
-void DarwinModeProcessEvent(
+void QuartzProcessEvent(
     xEvent *xe)
 {
     switch (xe->u.u.type) {
@@ -516,11 +517,11 @@ void DarwinModeProcessEvent(
 
 
 /*
- * DarwinModeGiveUp
+ * QuartzGiveUp
  *  Cleanup before X server shutdown
  *  Release the screen and restore the Aqua cursor.
  */
-void DarwinModeGiveUp(void)
+void QuartzGiveUp(void)
 {
 #if 0
 // Trying to switch cursors when quitting causes deadlock
diff --git a/hw/xquartz/quartz.h b/hw/xquartz/quartz.h
index e74a108..fbe308a 100644
--- a/hw/xquartz/quartz.h
+++ b/hw/xquartz/quartz.h
@@ -124,4 +124,11 @@ typedef struct _QuartzModeProcs {
 extern QuartzModeProcsPtr quartzProcs;
 extern int quartzHasRoot, quartzEnableRootless;
 
+Bool QuartzAddScreen(int index, ScreenPtr pScreen);
+Bool QuartzSetupScreen(int index, ScreenPtr pScreen);
+void QuartzInitOutput(int argc,char **argv);
+void QuartzInitInput(int argc, char **argv);
+void QuartzGiveUp(void);
+void QuartzProcessEvent(xEvent *xe);
+
 #endif
diff --git a/hw/xquartz/quartzAudio.c b/hw/xquartz/quartzAudio.c
index 1eb099b..86bb200 100644
--- a/hw/xquartz/quartzAudio.c
+++ b/hw/xquartz/quartzAudio.c
@@ -246,10 +246,10 @@ static void QuartzCoreAudioBell(
 
 
 /*
- * DarwinModeBell
+ * QuartzBell
  *  Ring the bell
  */
-void DarwinModeBell(
+void QuartzBell(
     int volume,             // volume in percent of max
     DeviceIntPtr pDevice,
     pointer ctrl,
diff --git a/hw/xquartz/quartzKeyboard.h b/hw/xquartz/quartzKeyboard.h
index f27fcde..c5f22bf 100644
--- a/hw/xquartz/quartzKeyboard.h
+++ b/hw/xquartz/quartzKeyboard.h
@@ -36,6 +36,7 @@
 // unshifted, shifted, modeswitch unshifted, modeswitch shifted
 #define GLYPHS_PER_KEY  4
 #define NUM_KEYCODES    248	// NX_NUMKEYCODES might be better
+#define MIN_KEYCODE     XkbMinLegalKeyCode     // unfortunately, this isn't 0...
 #define MAX_KEYCODE     NUM_KEYCODES + MIN_KEYCODE - 1
 
 typedef struct darwinKeyboardInfo_struct {
diff --git a/hw/xquartz/xpr/xprCursor.c b/hw/xquartz/xpr/xprCursor.c
index db195a8..dc7a73e 100644
--- a/hw/xquartz/xpr/xprCursor.c
+++ b/hw/xquartz/xpr/xprCursor.c
@@ -36,6 +36,7 @@
 #include "quartzCommon.h"
 #include "xpr.h"
 #include "darwin.h"
+#include "darwinEvents.h"
 #include "Xplugin.h"
 
 #include "mi.h"
commit ab8d35d257559dabe11989070a663d70d24b8183
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Wed Dec 5 20:55:48 2007 -0800

    .gitignore: synced from master

diff --git a/.gitignore b/.gitignore
index 887e4ad..2e60d58 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,6 +9,8 @@ Makefile.in
 *.o
 *~
 .*.swp
+*.pbxuser
+*.mode1v3
 obj*
 build*
 aclocal.m4
@@ -19,6 +21,7 @@ config.log
 config.status
 config.sub
 configure
+configure.lineno
 depcomp
 install-sh
 libtool
@@ -94,6 +97,8 @@ cfb32/cfbzerarcG.c
 cfb32/cfbzerarcX.c
 doc/Xserver.1x
 doc/Xserver.man
+doc/SecurityPolicy.5
+doc/SecurityPolicy.man
 hw/dmx/Xdmx
 hw/dmx/Xdmx.1x
 hw/dmx/config/dmxtodmx
@@ -209,31 +214,58 @@ hw/xfree86/xaa/mf3-xaaBitmap.c
 hw/xfree86/xaa/mf3-xaaStipple.c
 hw/xfree86/xaa/s-xaaDashLine.c
 hw/xfree86/xaa/s-xaaLine.c
+hw/xfree86/xf1bpp/maskbits.c
+hw/xfree86/xf1bpp/mfbbitblt.c
 hw/xfree86/xf1bpp/mfbbltC.c
 hw/xfree86/xf1bpp/mfbbltCI.c
 hw/xfree86/xf1bpp/mfbbltG.c
 hw/xfree86/xf1bpp/mfbbltO.c
 hw/xfree86/xf1bpp/mfbbltX.c
+hw/xfree86/xf1bpp/mfbbres.c
+hw/xfree86/xf1bpp/mfbbresd.c
+hw/xfree86/xf1bpp/mfbclip.c
+hw/xfree86/xf1bpp/mfbcmap.c
+hw/xfree86/xf1bpp/mfbfillarc.c
+hw/xfree86/xf1bpp/mfbfillrct.c
+hw/xfree86/xf1bpp/mfbfillsp.c
+hw/xfree86/xf1bpp/mfbfont.c
+hw/xfree86/xf1bpp/mfbgc.c
+hw/xfree86/xf1bpp/mfbgetsp.c
 hw/xfree86/xf1bpp/mfbigbblak.c
 hw/xfree86/xf1bpp/mfbigbwht.c
+hw/xfree86/xf1bpp/mfbhrzvert.c
+hw/xfree86/xf1bpp/mfbimage.c
+hw/xfree86/xf1bpp/mfbline.c
+hw/xfree86/xf1bpp/mfbmisc.c
 hw/xfree86/xf1bpp/mfbpablack.c
 hw/xfree86/xf1bpp/mfbpainv.c
 hw/xfree86/xf1bpp/mfbpawhite.c
 hw/xfree86/xf1bpp/mfbpgbblak.c
 hw/xfree86/xf1bpp/mfbpgbinv.c
 hw/xfree86/xf1bpp/mfbpgbwht.c
+hw/xfree86/xf1bpp/mfbpixmap.c
 hw/xfree86/xf1bpp/mfbplyblack.c
 hw/xfree86/xf1bpp/mfbplyinv.c
 hw/xfree86/xf1bpp/mfbplywhite.c
+hw/xfree86/xf1bpp/mfbpntwin.c
+hw/xfree86/xf1bpp/mfbpolypnt.c
+hw/xfree86/xf1bpp/mfbpushpxl.c
+hw/xfree86/xf1bpp/mfbscrclse.c
+hw/xfree86/xf1bpp/mfbscrinit.c
 hw/xfree86/xf1bpp/mfbseg.c
+hw/xfree86/xf1bpp/mfbsetsp.c
 hw/xfree86/xf1bpp/mfbteblack.c
 hw/xfree86/xf1bpp/mfbtewhite.c
 hw/xfree86/xf1bpp/mfbtileC.c
 hw/xfree86/xf1bpp/mfbtileG.c
+hw/xfree86/xf1bpp/mfbwindow.c
+hw/xfree86/xf1bpp/mfbzerarc.c
 hw/xfree86/xf4bpp/mfbseg.c
 hw/xfree86/xf8_32bpp/cfbgc32.c
 hw/xfree86/xf8_32bpp/cfbgc8.c
 hw/xfree86/xorg.c
+hw/xfree86/xorg.conf.example
+hw/xfree86/xorg.conf.example.pre
 hw/xnest/Xnest
 hw/xnest/Xnest.1x
 hw/xnest/Xnest.man
commit 15add97723f2ddffce018a01e2c771bea7454358
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Wed Dec 5 20:29:23 2007 -0800

    Darwin: Be more precise in version information shown.

diff --git a/hw/xquartz/Makefile.am b/hw/xquartz/Makefile.am
index 725d20f..fff7c4b 100644
--- a/hw/xquartz/Makefile.am
+++ b/hw/xquartz/Makefile.am
@@ -15,7 +15,7 @@ SUBDIRS = . xpr $(X11APP_SUBDIRS)
 DIST_SUBDIRS = xpr bundle
 
 libXquartz_la_SOURCES = \
-	$(top_srcdir)/fb/fbcmap.c \
+	$(top_srcdir)/fb/fbcmap_mi.c \
 	$(top_srcdir)/mi/miinitext.c \
 	X11Application.m \
 	X11Controller.m \
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 3e37dd4..c976b63 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -55,6 +55,10 @@ WindowPtr xprGetXWindowFromAppKit(int windowNumber); // xpr/xprFrame.c
 
 #define DEFAULTS_FILE "/usr/X11/lib/X11/xserver/Xquartz.plist"
 
+#ifndef XSERVER_VERSION
+#define XSERVER_VERSION "?"
+#endif
+
 int X11EnableKeyEquivalents = TRUE;
 int quartzHasRoot = FALSE, quartzEnableRootless = TRUE;
 
@@ -151,7 +155,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
 	
     tem = [infoDict objectForKey:@"CFBundleShortVersionString"];
 	
-    [dict setObject:[NSString stringWithFormat:@"X11.app %@ - X.org X11R7.3", tem] 
+    [dict setObject:[NSString stringWithFormat:@"X11.app %@ - (xorg-server %s)", tem, XSERVER_VERSION] 
 	  forKey:@"ApplicationVersion"];
 	
     [self orderFrontStandardAboutPanelWithOptions: dict];
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index b46b768..d5d3037 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -135,8 +135,8 @@ const int NUMFORMATS = sizeof(formats)/sizeof(formats[0]);
 #ifndef BUILD_DATE
 #define BUILD_DATE ""
 #endif
-#ifndef XORG_RELEASE
-#define XORG_RELEASE "?"
+#ifndef XSERVER_VERSION
+#define XSERVER_VERSION "?"
 #endif
 
 void DDXRingBell(int volume, int pitch, int duration) {
@@ -148,7 +148,7 @@ DarwinPrintBanner(void)
 { 
   // this should change depending on which specific server we are building
   ErrorF("X11.app starting:\n");
-  ErrorF("Xquartz server based on X.org %s, built on %s\n", XORG_RELEASE, BUILD_DATE );
+  ErrorF("X.Org Xquartz X Server %s\nBuild Date: %s\n", XSERVER_VERSION, BUILD_DATE );
 }
 
 
commit df5c9fef3cb208713868058be0c3e0559cfc9efc
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Wed Dec 5 19:43:49 2007 -0800

    Darwin: Flattened quartz into darwin, renamed darwin xquartz
    Leaving xpr unflattened since we want modularity to replace that with xpc (XPluginComposite) at some point
    (cherry picked from commit 48e6a75fbdd0fee86e364f02ace83f20b312a2b2)

diff --git a/configure.ac b/configure.ac
index 6841462..62fd4a9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2153,10 +2153,9 @@ hw/xgl/glxext/Makefile
 hw/xgl/glxext/module/Makefile
 hw/xnest/Makefile
 hw/xwin/Makefile
-hw/darwin/Makefile
-hw/darwin/quartz/Makefile
-hw/darwin/quartz/apple/Makefile
-hw/darwin/quartz/xpr/Makefile
+hw/xquartz/Makefile
+hw/xquartz/bundle/Makefile
+hw/xquartz/xpr/Makefile
 hw/kdrive/Makefile
 hw/kdrive/ati/Makefile
 hw/kdrive/chips/Makefile
diff --git a/hw/Makefile.am b/hw/Makefile.am
index 6a15820..753d6a9 100644
--- a/hw/Makefile.am
+++ b/hw/Makefile.am
@@ -23,7 +23,7 @@ XPRINT_SUBDIRS = xprint
 endif
 
 if XQUARTZ
-DARWIN_SUBDIRS = darwin
+DARWIN_SUBDIRS = xquartz
 endif
 
 SUBDIRS =			\
@@ -37,7 +37,7 @@ SUBDIRS =			\
         $(DARWIN_SUBDIRS)	\
 	$(XPRINT_SUBDIRS)
 
-DIST_SUBDIRS = dmx xfree86 vfb xnest xwin darwin kdrive xgl xprint
+DIST_SUBDIRS = dmx xfree86 vfb xnest xwin xquartz kdrive xgl xprint
 
 relink:
 	for i in $(SUBDIRS) ; do $(MAKE) -C $$i relink ; done
diff --git a/hw/darwin/Makefile.am b/hw/darwin/Makefile.am
deleted file mode 100644
index 3f29a81..0000000
--- a/hw/darwin/Makefile.am
+++ /dev/null
@@ -1,21 +0,0 @@
-noinst_LTLIBRARIES = libXdarwin.la
-AM_CFLAGS = $(XSERVER_CFLAGS) $(DIX_CFLAGS)
-AM_CPPFLAGS = \
-	-DINXQUARTZ \
-	-DUSE_NEW_CLUT \
-	-DXFree86Server
-
-SUBDIRS = . quartz
-
-libXdarwin_la_SOURCES = \
-	darwin.c \
-	darwinEvents.c \
-	darwinKeyboard.c \
-	darwinXinput.c \
-	$(top_srcdir)/fb/fbcmap_mi.c \
-	$(top_srcdir)/mi/miinitext.c
-
-EXTRA_DIST = \
-	darwinClut8.h \
-	darwin.h \
-	darwinKeyboard.h
diff --git a/hw/darwin/darwin.c b/hw/darwin/darwin.c
deleted file mode 100644
index b46b768..0000000
--- a/hw/darwin/darwin.c
+++ /dev/null
@@ -1,1080 +0,0 @@
-/**************************************************************
- *
- * Shared code for the Darwin X Server
- * running with Quartz or IOKit display mode
- *
- * Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
- * Copyright (c) 2007 Apple Inc.
- *
- * 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "os.h"
-#include "servermd.h"
-#include "inputstr.h"
-#include "scrnintstr.h"
-#include "mibstore.h"		// mi backing store implementation
-#include "mipointer.h"		// mi software cursor
-#include "micmap.h"		// mi colormap code
-#include "fb.h"			// fb framebuffer code
-#include "site.h"
-#include "globals.h"
-#include "dix.h"
-
-#ifdef XINPUT
-# include <X11/extensions/XI.h>
-# include <X11/extensions/XIproto.h>
-# include "exevents.h"
-# include "extinit.h"
-#endif
-
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/syslimits.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-#define HAS_UTSNAME 1
-#include <sys/utsname.h>
-
-#define NO_CFPLUGIN
-#include <IOKit/IOKitLib.h>
-#include <IOKit/hidsystem/IOHIDLib.h>
-#include <IOKit/hidsystem/ev_keymap.h>
-
-#ifdef MITSHM
-#define _XSHM_SERVER_
-#include <X11/extensions/XShm.h>
-#endif
-
-#include "darwin.h"
-#include "darwinClut8.h"
-
-#ifdef ENABLE_DEBUG_LOG
-FILE *debug_log_fp = NULL;
-#endif
-
-/*
- * X server shared global variables
- */
-int                     darwinScreensFound = 0;
-int                     darwinScreenIndex = 0;
-io_connect_t            darwinParamConnect = 0;
-int                     darwinEventReadFD = -1;
-int                     darwinEventWriteFD = -1;
-// int                     darwinMouseAccelChange = 1;
-int                     darwinFakeButtons = 0;
-
-// location of X11's (0,0) point in global screen coordinates
-int                     darwinMainScreenX = 0;
-int                     darwinMainScreenY = 0;
-
-// parameters read from the command line or user preferences
-unsigned int            darwinDesiredWidth = 0, darwinDesiredHeight = 0;
-int                     darwinDesiredDepth = -1;
-int                     darwinDesiredRefresh = -1;
-char                    *darwinKeymapFile = "USA.keymapping";
-int                     darwinSyncKeymap = FALSE;
-
-// modifier masks for faking mouse buttons
-int                     darwinFakeMouse2Mask = NX_ALTERNATEMASK;
-int                     darwinFakeMouse3Mask = NX_COMMANDMASK;
-
-// devices
-DeviceIntPtr            darwinPointer = NULL;
-DeviceIntPtr            darwinKeyboard = NULL;
-
-// Common pixmap formats
-static PixmapFormatRec formats[] = {
-        { 1,    1,      BITMAP_SCANLINE_PAD },
-        { 4,    8,      BITMAP_SCANLINE_PAD },
-        { 8,    8,      BITMAP_SCANLINE_PAD },
-        { 15,   16,     BITMAP_SCANLINE_PAD },
-        { 16,   16,     BITMAP_SCANLINE_PAD },
-        { 24,   32,     BITMAP_SCANLINE_PAD },
-        { 32,   32,     BITMAP_SCANLINE_PAD }
-};
-const int NUMFORMATS = sizeof(formats)/sizeof(formats[0]);
-
-#ifndef OSNAME
-#define OSNAME " Darwin"
-#endif
-#ifndef OSVENDOR
-#define OSVENDOR ""
-#endif
-#ifndef PRE_RELEASE
-#define PRE_RELEASE XORG_VERSION_SNAP
-#endif
-#ifndef BUILD_DATE
-#define BUILD_DATE ""
-#endif
-#ifndef XORG_RELEASE
-#define XORG_RELEASE "?"
-#endif
-
-void DDXRingBell(int volume, int pitch, int duration) {
-  // FIXME -- make some noise, yo
-}
-
-void
-DarwinPrintBanner(void)
-{ 
-  // this should change depending on which specific server we are building
-  ErrorF("X11.app starting:\n");
-  ErrorF("Xquartz server based on X.org %s, built on %s\n", XORG_RELEASE, BUILD_DATE );
-}
-
-
-/*
- * DarwinSaveScreen
- *  X screensaver support. Not implemented.
- */
-static Bool DarwinSaveScreen(ScreenPtr pScreen, int on)
-{
-    // FIXME
-    if (on == SCREEN_SAVER_FORCER) {
-    } else if (on == SCREEN_SAVER_ON) {
-    } else {
-    }
-    return TRUE;
-}
-
-
-/*
- * DarwinAddScreen
- *  This is a callback from dix during AddScreen() from InitOutput().
- *  Initialize the screen and communicate information about it back to dix.
- */
-static Bool DarwinAddScreen(
-    int         index,
-    ScreenPtr   pScreen,
-    int         argc,
-    char        **argv )
-{
-    int         bitsPerRGB, i, dpi;
-    static int  foundIndex = 0;
-    Bool        ret;
-    VisualPtr   visual;
-    ColormapPtr pmap;
-    DarwinFramebufferPtr dfb;
-
-    // reset index of found screens for each server generation
-    if (index == 0) foundIndex = 0;
-
-    // allocate space for private per screen storage
-    dfb = xalloc(sizeof(DarwinFramebufferRec));
-
-    // SCREEN_PRIV(pScreen) = dfb;
-    pScreen->devPrivates[darwinScreenIndex].ptr = dfb;
-
-    // setup hardware/mode specific details
-    ret = DarwinModeAddScreen(foundIndex, pScreen);
-    foundIndex++;
-    if (! ret)
-        return FALSE;
-
-    bitsPerRGB = dfb->bitsPerComponent;
-
-    // reset the visual list
-    miClearVisualTypes();
-
-    // setup a single visual appropriate for our pixel type
-    if (dfb->colorType == TrueColor) {
-        if (!miSetVisualTypes( dfb->colorBitsPerPixel, TrueColorMask,
-                               bitsPerRGB, TrueColor )) {
-            return FALSE;
-        }
-    } else if (dfb->colorType == PseudoColor) {
-        if (!miSetVisualTypes( dfb->colorBitsPerPixel, PseudoColorMask,
-                               bitsPerRGB, PseudoColor )) {
-            return FALSE;
-        }
-    } else if (dfb->colorType == StaticColor) {
-        if (!miSetVisualTypes( dfb->colorBitsPerPixel, StaticColorMask,
-                               bitsPerRGB, StaticColor )) {
-            return FALSE;
-        }
-    } else {
-        return FALSE;
-    }
-
-    miSetPixmapDepths();
-
-    // machine independent screen init
-    // setup _Screen structure in pScreen
-    if (monitorResolution)
-        dpi = monitorResolution;
-    else
-        dpi = 75;
-
-    // initialize fb
-    if (! fbScreenInit(pScreen,
-                dfb->framebuffer,                 // pointer to screen bitmap
-                dfb->width, dfb->height,          // screen size in pixels
-                dpi, dpi,                         // dots per inch
-                dfb->pitch/(dfb->bitsPerPixel/8), // pixel width of framebuffer
-                dfb->bitsPerPixel))               // bits per pixel for screen
-    {
-        return FALSE;
-    }
-
-    // set the RGB order correctly for TrueColor
-    if (dfb->bitsPerPixel > 8) {
-        for (i = 0, visual = pScreen->visuals;  // someday we may have more than 1
-            i < pScreen->numVisuals; i++, visual++) {
-            if (visual->class == TrueColor) {
-                visual->offsetRed = bitsPerRGB * 2;
-                visual->offsetGreen = bitsPerRGB;
-                visual->offsetBlue = 0;
-                visual->redMask = ((1<<bitsPerRGB)-1) << visual->offsetRed;
-                visual->greenMask = ((1<<bitsPerRGB)-1) << visual->offsetGreen;
-                visual->blueMask = ((1<<bitsPerRGB)-1) << visual->offsetBlue;
-            }
-        }
-    }
-
-#ifdef RENDER
-    if (! fbPictureInit(pScreen, 0, 0)) {
-        return FALSE;
-    }
-#endif
-
-#ifdef MITSHM
-    ShmRegisterFbFuncs(pScreen);
-#endif
-
-    // this must be initialized (why doesn't X have a default?)
-    pScreen->SaveScreen = DarwinSaveScreen;
-
-    // finish mode dependent screen setup including cursor support
-    if (!DarwinModeSetupScreen(index, pScreen)) {
-        return FALSE;
-    }
-
-    // create and install the default colormap and
-    // set pScreen->blackPixel / pScreen->white
-    if (!miCreateDefColormap( pScreen )) {
-        return FALSE;
-    }
-
-    /* Set the colormap to the statically defined one if we're in 8 bit
-     * mode and we're using a fixed color map.  Essentially this translates
-     * to Darwin/x86 in 8-bit mode.
-     */
-    if( (dfb->colorBitsPerPixel == 8) &&
-                (dfb->colorType == StaticColor) )
-    {
-        pmap = miInstalledMaps[pScreen->myNum];
-        visual = pmap->pVisual;
-        for( i = 0; i < visual->ColormapEntries; i++ ) {
-            pmap->red[i].co.local.red   = darwinClut8[i].red;
-            pmap->red[i].co.local.green = darwinClut8[i].green;
-            pmap->red[i].co.local.blue  = darwinClut8[i].blue;
-        }
-    }
-
-    dixScreenOrigins[index].x = dfb->x;
-    dixScreenOrigins[index].y = dfb->y;
-
-    /*    ErrorF("Screen %d added: %dx%d @ (%d,%d)\n",
-	  index, dfb->width, dfb->height, dfb->x, dfb->y); */
-
-    return TRUE;
-}
-
-/*
- =============================================================================
-
- mouse and keyboard callbacks
-
- =============================================================================
-*/
-
-#if 0
-/*
- * DarwinChangePointerControl
- *  Set mouse acceleration and thresholding
- *  FIXME: We currently ignore the threshold in ctrl->threshold.
- */
-static void DarwinChangePointerControl(
-    DeviceIntPtr    device,
-    PtrCtrl         *ctrl )
-{
-    kern_return_t   kr;
-    double          acceleration;
-
-    if (!darwinMouseAccelChange)
-        return;
-
-    acceleration = ctrl->num / ctrl->den;
-    kr = IOHIDSetMouseAcceleration( darwinParamConnect, acceleration );
-    if (kr != KERN_SUCCESS)
-        ErrorF( "Could not set mouse acceleration with kernel return = 0x%x.\n", kr );
-}
-#endif
-
-/*
- * DarwinMouseProc
- *  Handle the initialization, etc. of a mouse
- */
-static int DarwinMouseProc(
-    DeviceIntPtr    pPointer,
-    int             what )
-{
-    CARD8 map[6];
-
-    switch (what) {
-
-        case DEVICE_INIT:
-            pPointer->public.on = FALSE;
-
-            // Set button map.
-            map[1] = 1;
-            map[2] = 2;
-            map[3] = 3;
-            map[4] = 4;
-            map[5] = 5;
-            InitPointerDeviceStruct( (DevicePtr)pPointer, map, 5,
-				     GetMotionHistory,
-				     (PtrCtrlProcPtr)NoopDDA,
-				     GetMotionHistorySize(), 2);
-
-#ifdef XINPUT
-            InitValuatorAxisStruct( pPointer,
-                                    0,     // X axis
-                                    0,     // min value
-                                    16000, // max value (fixme screen size?)
-                                    1,     // resolution (fixme ?)
-                                    1,     // min resolution
-                                    1 );   // max resolution
-            InitValuatorAxisStruct( pPointer,
-                                    1,     // X axis
-                                    0,     // min value
-                                    16000, // max value (fixme screen size?)
-                                    1,     // resolution (fixme ?)
-                                    1,     // min resolution
-                                    1 );   // max resolution
-#endif
-            break;
-
-        case DEVICE_ON:
-            pPointer->public.on = TRUE;
-            AddEnabledDevice( darwinEventReadFD );
-            return Success;
-
-        case DEVICE_CLOSE:
-        case DEVICE_OFF:
-            pPointer->public.on = FALSE;
-            RemoveEnabledDevice( darwinEventReadFD );
-            return Success;
-    }
-
-    return Success;
-}
-
-
-/*
- * DarwinKeybdProc
- *  Callback from X
- */
-static int DarwinKeybdProc( DeviceIntPtr pDev, int onoff )
-{
-    switch ( onoff ) {
-        case DEVICE_INIT:
-            DarwinKeyboardInit( pDev );
-            break;
-        case DEVICE_ON:
-            pDev->public.on = TRUE;
-            AddEnabledDevice( darwinEventReadFD );
-            break;
-        case DEVICE_OFF:
-            pDev->public.on = FALSE;
-            RemoveEnabledDevice( darwinEventReadFD );
-            break;
-        case DEVICE_CLOSE:
-            break;
-    }
-
-    return Success;
-}
-
-/*
-===========================================================================
-
- Utility routines
-
-===========================================================================
-*/
-
-/*
- * DarwinFindLibraryFile
- *  Search for a file in the standard Library paths, which are (in order):
- *
- *      ~/Library/              user specific
- *      /Library/               host specific
- *      /Network/Library/       LAN specific
- *      /System/Library/        OS specific
- *
- *  A sub-path can be specified to search in below the various Library
- *  directories. Returns a new character string (owned by the caller)
- *  containing the full path to the first file found.
- */
-static char * DarwinFindLibraryFile(
-    const char *file,
-    const char *pathext )
-{
-    // Library search paths
-    char *pathList[] = {
-        "",
-        "/Network",
-        "/System",
-        NULL
-    };
-    char *home;
-    char *fullPath;
-    int i = 0;
-
-    // Return the file name as is if it is already a fully qualified path.
-    if (!access(file, F_OK)) {
-        fullPath = xalloc(strlen(file)+1);
-        strcpy(fullPath, file);
-        return fullPath;
-    }
-
-    fullPath = xalloc(PATH_MAX);
-
-    home = getenv("HOME");
-    if (home) {
-        snprintf(fullPath, PATH_MAX, "%s/Library/%s/%s", home, pathext, file);
-        if (!access(fullPath, F_OK))
-            return fullPath;
-    }
-
-    while (pathList[i]) {
-        snprintf(fullPath, PATH_MAX, "%s/Library/%s/%s", pathList[i++],
-                 pathext, file);
-        if (!access(fullPath, F_OK))
-            return fullPath;
-    }
-
-    xfree(fullPath);
-    return NULL;
-}
-
-
-/*
- * DarwinParseModifierList
- *  Parse a list of modifier names and return a corresponding modifier mask
- */
-int DarwinParseModifierList(
-    const char *constmodifiers) // string containing list of modifier names
-{
-    int result = 0;
-
-    if (constmodifiers) {
-        char *modifiers = strdup(constmodifiers);
-        char *modifier;
-        int nxkey;
-        char *p = modifiers;
-
-        while (p) {
-            modifier = strsep(&p, " ,+&|/"); // allow lots of separators
-            nxkey = DarwinModifierStringToNXKey(modifier);
-            if (nxkey != -1)
-                result |= DarwinModifierNXKeyToNXMask(nxkey);
-            else
-                ErrorF("fakebuttons: Unknown modifier \"%s\"\n", modifier);
-        }
-        free(modifiers);
-    }
-    return result;
-}
-
-/*
-===========================================================================
-
- Functions needed to link against device independent X
-
-===========================================================================
-*/
-
-/*
- * InitInput
- *  Register the keyboard and mouse devices
- */
-void InitInput( int argc, char **argv )
-{
-    darwinPointer = AddInputDevice(DarwinMouseProc, TRUE);
-    RegisterPointerDevice( darwinPointer );
-
-    darwinKeyboard = AddInputDevice(DarwinKeybdProc, TRUE);
-    RegisterKeyboardDevice( darwinKeyboard );
-
-    DarwinEQInit( (DevicePtr)darwinKeyboard, (DevicePtr)darwinPointer );
-
-    DarwinModeInitInput(argc, argv);
-}
-
-
-/*
- * DarwinAdjustScreenOrigins
- *  Shift all screens so the X11 (0, 0) coordinate is at the top
- *  left of the global screen coordinates.
- *
- *  Screens can be arranged so the top left isn't on any screen, so
- *  instead use the top left of the leftmost screen as (0,0). This
- *  may mean some screen space is in -y, but it's better that (0,0)
- *  be onscreen, or else default xterms disappear. It's better that
- *  -y be used than -x, because when popup menus are forced
- *  "onscreen" by dumb window managers like twm, they'll shift the
- *  menus down instead of left, which still looks funny but is an
- *  easier target to hit.
- */
-void
-DarwinAdjustScreenOrigins(ScreenInfo *pScreenInfo)
-{
-    int i, left, top;
-
-    left = dixScreenOrigins[0].x;
-    top  = dixScreenOrigins[0].y;
-
-    /* Find leftmost screen. If there's a tie, take the topmost of the two. */
-    for (i = 1; i < pScreenInfo->numScreens; i++) {
-        if (dixScreenOrigins[i].x < left  ||
-            (dixScreenOrigins[i].x == left &&
-             dixScreenOrigins[i].y < top))
-        {
-            left = dixScreenOrigins[i].x;
-            top = dixScreenOrigins[i].y;
-        }
-    }
-
-    darwinMainScreenX = left;
-    darwinMainScreenY = top;
-
-    /* Shift all screens so that there is a screen whose top left
-       is at X11 (0,0) and at global screen coordinate
-       (darwinMainScreenX, darwinMainScreenY). */
-
-    if (darwinMainScreenX != 0 || darwinMainScreenY != 0) {
-        for (i = 0; i < pScreenInfo->numScreens; i++) {
-            dixScreenOrigins[i].x -= darwinMainScreenX;
-            dixScreenOrigins[i].y -= darwinMainScreenY;
-    /*            ErrorF("Screen %d placed at X11 coordinate (%d,%d).\n",
-		  i, dixScreenOrigins[i].x, dixScreenOrigins[i].y); */
-        }
-    }
-}
-
-
-/*
- * InitOutput
- *  Initialize screenInfo for all actually accessible framebuffers.
- *
- *  The display mode dependent code gets called three times. The mode
- *  specific InitOutput routines are expected to discover the number
- *  of potentially useful screens and cache routes to them internally.
- *  Inside DarwinAddScreen are two other mode specific calls.
- *  A mode specific AddScreen routine is called for each screen to
- *  actually initialize the screen with the ScreenPtr structure.
- *  After other screen setup has been done, a mode specific
- *  SetupScreen function can be called to finalize screen setup.
- */
-void InitOutput( ScreenInfo *pScreenInfo, int argc, char **argv )
-{
-    int i;
-    static unsigned long generation = 0;
-
-    pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
-    pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
-    pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
-    pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
-
-    // List how we want common pixmap formats to be padded
-    pScreenInfo->numPixmapFormats = NUMFORMATS;
-    for (i = 0; i < NUMFORMATS; i++)
-        pScreenInfo->formats[i] = formats[i];
-
-    // Allocate private storage for each screen's Darwin specific info
-    if (generation != serverGeneration) {
-        darwinScreenIndex = AllocateScreenPrivateIndex();
-        generation = serverGeneration;
-    }
-
-    // Discover screens and do mode specific initialization
-    DarwinModeInitOutput(argc, argv);
-
-    // Add screens
-    for (i = 0; i < darwinScreensFound; i++) {
-        AddScreen( DarwinAddScreen, argc, argv );
-    }
-
-    DarwinAdjustScreenOrigins(pScreenInfo);
-}
-
-
-/*
- * OsVendorFataError
- */
-void OsVendorFatalError( void )
-{
-    ErrorF( "   OsVendorFatalError\n" );
-}
-
-
-/*
- * OsVendorInit
- *  Initialization of Darwin OS support.
- */
-void OsVendorInit(void)
-{
-    if (serverGeneration == 1) {
-        DarwinPrintBanner();
-#ifdef ENABLE_DEBUG_LOG
-	{
-	  char *home_dir=NULL, *log_file_path=NULL;
-	  home_dir = getenv("HOME");
-	  if (home_dir) asprintf(&log_file_path, "%s/%s", home_dir, DEBUG_LOG_NAME);
-	  if (log_file_path) {
-	    if (!access(log_file_path, F_OK)) {
-	      debug_log_fp = fopen(log_file_path, "a");
-	      if (debug_log_fp) ErrorF("Debug logging enabled to %s\n", log_file_path);
-	    }
-	    free(log_file_path);
-	  }
-	}
-#endif
-    }
-    //    DEBUG_LOG("Xquartz started at %s\n", ctime(time(NULL)));
-
-    // Find the full path to the keymapping file.
-    if ( darwinKeymapFile ) {
-        char *tempStr = DarwinFindLibraryFile(darwinKeymapFile, "Keyboards");
-        if ( !tempStr ) {
-            ErrorF("Could not find keymapping file %s.\n", darwinKeymapFile);
-        } else {
-            ErrorF("Using keymapping provided in %s.\n", tempStr);
-        }
-        darwinKeymapFile = tempStr;
-    }
-}
-
-
-/*
- * ddxInitGlobals
- *  Called by InitGlobals() from os/util.c.
- */
-void ddxInitGlobals(void)
-{
-}
-
-
-/*
- * ddxProcessArgument
- *  Process device-dependent command line args. Returns 0 if argument is
- *  not device dependent, otherwise Count of number of elements of argv
- *  that are part of a device dependent commandline option.
- */
-int ddxProcessArgument( int argc, char *argv[], int i )
-{
-    if ( !strcmp( argv[i], "-fullscreen" ) ) {
-        ErrorF( "Running full screen in parallel with Mac OS X Quartz window server.\n" );
-        return 1;
-    }
-
-    if ( !strcmp( argv[i], "-rootless" ) ) {
-        ErrorF( "Running rootless inside Mac OS X window server.\n" );
-        return 1;
-    }
-
-    if ( !strcmp( argv[i], "-quartz" ) ) {
-        ErrorF( "Running in parallel with Mac OS X Quartz window server.\n" );
-        return 1;
-    }
-
-    // The Mac OS X front end uses this argument, which we just ignore here.
-    if ( !strcmp( argv[i], "-nostartx" ) ) {
-        return 1;
-    }
-
-    // This command line arg is passed when launched from the Aqua GUI.
-    if ( !strncmp( argv[i], "-psn_", 5 ) ) {
-        return 1;
-    }
-
-    if ( !strcmp( argv[i], "-fakebuttons" ) ) {
-        darwinFakeButtons = TRUE;
-        ErrorF( "Faking a three button mouse\n" );
-        return 1;
-    }
-
-    if ( !strcmp( argv[i], "-nofakebuttons" ) ) {
-        darwinFakeButtons = FALSE;
-        ErrorF( "Not faking a three button mouse\n" );
-        return 1;
-    }
-
-    if (!strcmp( argv[i], "-fakemouse2" ) ) {
-        if ( i == argc-1 ) {
-            FatalError( "-fakemouse2 must be followed by a modifer list\n" );
-        }
-        if (!strcasecmp(argv[i+1], "none") || !strcmp(argv[i+1], ""))
-            darwinFakeMouse2Mask = 0;
-        else
-            darwinFakeMouse2Mask = DarwinParseModifierList(argv[i+1]);
-        ErrorF("Modifier mask to fake mouse button 2 = 0x%x\n",
-               darwinFakeMouse2Mask);
-        return 2;
-    }
-
-    if (!strcmp( argv[i], "-fakemouse3" ) ) {
-        if ( i == argc-1 ) {
-            FatalError( "-fakemouse3 must be followed by a modifer list\n" );
-        }
-        if (!strcasecmp(argv[i+1], "none") || !strcmp(argv[i+1], ""))
-            darwinFakeMouse3Mask = 0;
-        else
-            darwinFakeMouse3Mask = DarwinParseModifierList(argv[i+1]);
-        ErrorF("Modifier mask to fake mouse button 3 = 0x%x\n",
-               darwinFakeMouse3Mask);
-        return 2;
-    }
-
-    if ( !strcmp( argv[i], "-keymap" ) ) {
-        if ( i == argc-1 ) {
-            FatalError( "-keymap must be followed by a filename\n" );
-        }
-        darwinKeymapFile = argv[i+1];
-        return 2;
-    }
-
-    if ( !strcmp( argv[i], "-nokeymap" ) ) {
-        darwinKeymapFile = NULL;
-        return 1;
-    }
-
-    if ( !strcmp( argv[i], "+synckeymap" ) ) {
-        darwinSyncKeymap = TRUE;
-        return 1;
-    }
-
-    if ( !strcmp( argv[i], "-synckeymap" ) ) {
-        darwinSyncKeymap = FALSE;
-        return 1;
-    }
-
-    if ( !strcmp( argv[i], "-size" ) ) {
-        if ( i >= argc-2 ) {
-            FatalError( "-size must be followed by two numbers\n" );
-        }
-#ifdef OLD_POWERBOOK_G3
-        ErrorF( "Ignoring unsupported -size option on old PowerBook G3\n" );
-#else
-        darwinDesiredWidth = atoi( argv[i+1] );
-        darwinDesiredHeight = atoi( argv[i+2] );
-        ErrorF( "Attempting to use width x height = %i x %i\n",
-                darwinDesiredWidth, darwinDesiredHeight );
-#endif
-        return 3;
-    }
-
-    if ( !strcmp( argv[i], "-depth" ) ) {
-        int     bitDepth;
-
-        if ( i == argc-1 ) {
-            FatalError( "-depth must be followed by a number\n" );
-        }
-#ifdef OLD_POWERBOOK_G3
-        ErrorF( "Ignoring unsupported -depth option on old PowerBook G3\n");
-#else
-        bitDepth = atoi( argv[i+1] );
-        if (bitDepth == 8)
-            darwinDesiredDepth = 0;
-        else if (bitDepth == 15)
-            darwinDesiredDepth = 1;
-        else if (bitDepth == 24)
-            darwinDesiredDepth = 2;
-        else
-            FatalError( "Unsupported pixel depth. Use 8, 15, or 24 bits\n" );
-        ErrorF( "Attempting to use pixel depth of %i\n", bitDepth );
-#endif
-        return 2;
-    }
-
-    if ( !strcmp( argv[i], "-refresh" ) ) {
-        if ( i == argc-1 ) {
-            FatalError( "-refresh must be followed by a number\n" );
-        }
-#ifdef OLD_POWERBOOK_G3
-        ErrorF( "Ignoring unsupported -refresh option on old PowerBook G3\n");
-#else
-        darwinDesiredRefresh = atoi( argv[i+1] );
-        ErrorF( "Attempting to use refresh rate of %i\n", darwinDesiredRefresh );
-#endif
-        return 2;
-    }
-
-    if (!strcmp( argv[i], "-showconfig" ) || !strcmp( argv[i], "-version" )) {
-        DarwinPrintBanner();
-        exit(0);
-    }
-
-    // XDarwinStartup uses this argument to indicate the IOKit X server
-    // should be started. Ignore it here.
-    if ( !strcmp( argv[i], "-iokit" ) ) {
-        return 1;
-    }
-
-    return 0;
-}
-
-
-/*
- * ddxUseMsg --
- *  Print out correct use of device dependent commandline options.
- *  Maybe the user now knows what really to do ...
- */
-void ddxUseMsg( void )
-{
-    ErrorF("\n");
-    ErrorF("\n");
-    ErrorF("Device Dependent Usage:\n");
-    ErrorF("\n");
-    ErrorF("-fakebuttons : fake a three button mouse with Command and Option keys.\n");
-    ErrorF("-nofakebuttons : don't fake a three button mouse.\n");
-    ErrorF("-fakemouse2 <modifiers> : fake middle mouse button with modifier keys.\n");
-    ErrorF("-fakemouse3 <modifiers> : fake right mouse button with modifier keys.\n");
-    ErrorF("  ex: -fakemouse2 \"option,shift\" = option-shift-click is middle button.\n");
-    ErrorF("-keymap <file> : read the keymapping from a file instead of the kernel.\n");
-    ErrorF("-version : show the server version.\n");
-    ErrorF("\n");
-    ErrorF("Quartz modes (Experimental / In Development):\n");
-    ErrorF("-fullscreen : run full screen in parallel with Mac OS X window server.\n");
-    ErrorF("-rootless : run rootless inside Mac OS X window server.\n");
-    ErrorF("\n");
-    ErrorF("Options ignored in rootless mode:\n");
-    ErrorF("-size <height> <width> : use a screen resolution of <height> x <width>.\n");
-    ErrorF("-depth <8,15,24> : use this bit depth.\n");
-    ErrorF("-refresh <rate> : use a monitor refresh rate of <rate> Hz.\n");
-    ErrorF("\n");
-}
-
-
-/*
- * ddxGiveUp --
- *      Device dependent cleanup. Called by dix before normal server death.
- */
-void ddxGiveUp( void )
-{
-    ErrorF( "Quitting XQuartz...\n" );
-
-    DarwinModeGiveUp();
-}
-
-
-/*
- * AbortDDX --
- *      DDX - specific abort routine.  Called by AbortServer(). The attempt is
- *      made to restore all original setting of the displays. Also all devices
- *      are closed.
- */
-void AbortDDX( void )
-{
-    ErrorF( "   AbortDDX\n" );
-    /*
-     * This is needed for a abnormal server exit, since the normal exit stuff
-     * MUST also be performed (i.e. the vt must be left in a defined state)
-     */
-    ddxGiveUp();
-}
-
-
-/*
- * DPMS extension stubs
- */
-Bool DPMSSupported(void)
-{
-    return FALSE;
-}
-
-void DPMSSet(int level)
-{
-}
-
-int DPMSGet(int *level)
-{
-    return -1;
-}
-
-#include "mivalidate.h" // for union _Validate used by windowstr.h
-#include "windowstr.h"  // for struct _Window
-#include "scrnintstr.h" // for struct _Screen
-
-// This is copied from Xserver/hw/xfree86/common/xf86Helper.c.
-// Quartz mode uses this when switching in and out of Quartz.
-// Quartz or IOKit can use this when waking from sleep.
-// Copyright (c) 1997-1998 by The XFree86 Project, Inc.
-
-/*
- * xf86SetRootClip --
- *	Enable or disable rendering to the screen by
- *	setting the root clip list and revalidating
- *	all of the windows
- */
-
-void
-xf86SetRootClip (ScreenPtr pScreen, BOOL enable)
-{
-    WindowPtr	pWin = WindowTable[pScreen->myNum];
-    WindowPtr	pChild;
-    Bool	WasViewable = (Bool)(pWin->viewable);
-    Bool	anyMarked = TRUE;
-    RegionPtr	pOldClip = NULL, bsExposed;
-#ifdef DO_SAVE_UNDERS
-    Bool	dosave = FALSE;
-#endif
-    WindowPtr   pLayerWin;
-    BoxRec	box;
-
-    if (WasViewable)
-    {
-	for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib)
-	{
-	    (void) (*pScreen->MarkOverlappedWindows)(pChild,
-						     pChild,
-						     &pLayerWin);
-	}
-	(*pScreen->MarkWindow) (pWin);
-	anyMarked = TRUE;
-	if (pWin->valdata)
-	{
-	    if (HasBorder (pWin))
-	    {
-		RegionPtr	borderVisible;
-
-		borderVisible = REGION_CREATE(pScreen, NullBox, 1);
-		REGION_SUBTRACT(pScreen, borderVisible,
-				&pWin->borderClip, &pWin->winSize);
-		pWin->valdata->before.borderVisible = borderVisible;
-	    }
-	    pWin->valdata->before.resized = TRUE;
-	}
-    }
-
-    /*
-     * Use REGION_BREAK to avoid optimizations in ValidateTree
-     * that assume the root borderClip can't change well, normally
-     * it doesn't...)
-     */
-    if (enable)
-    {
-	box.x1 = 0;
-	box.y1 = 0;
-	box.x2 = pScreen->width;
-	box.y2 = pScreen->height;
-	REGION_RESET(pScreen, &pWin->borderClip, &box);
-	REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
-    }
-    else
-    {
-	REGION_EMPTY(pScreen, &pWin->borderClip);
-	REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
-    }
-
-    ResizeChildrenWinSize (pWin, 0, 0, 0, 0);
-
-    if (WasViewable)
-    {
-	if (pWin->backStorage)
-	{
-	    pOldClip = REGION_CREATE(pScreen, NullBox, 1);
-	    REGION_COPY(pScreen, pOldClip, &pWin->clipList);
-	}
-
-	if (pWin->firstChild)
-	{
-	    anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin->firstChild,
-							   pWin->firstChild,
-							   (WindowPtr *)NULL);
-	}
-	else
-	{
-	    (*pScreen->MarkWindow) (pWin);
-	    anyMarked = TRUE;
-	}
-
-#ifdef DO_SAVE_UNDERS
-	if (DO_SAVE_UNDERS(pWin))
-	{
-	    dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pLayerWin);
-	}
-#endif /* DO_SAVE_UNDERS */
-
-	if (anyMarked)
-	    (*pScreen->ValidateTree)(pWin, NullWindow, VTOther);
-    }
-
-    if (pWin->backStorage &&
-	((pWin->backingStore == Always) || WasViewable))
-    {
-	if (!WasViewable)
-	    pOldClip = &pWin->clipList; /* a convenient empty region */
-	bsExposed = (*pScreen->TranslateBackingStore)
-			     (pWin, 0, 0, pOldClip,
-			      pWin->drawable.x, pWin->drawable.y);
-	if (WasViewable)
-	    REGION_DESTROY(pScreen, pOldClip);
-	if (bsExposed)
-	{
-	    RegionPtr	valExposed = NullRegion;
-
-	    if (pWin->valdata)
-		valExposed = &pWin->valdata->after.exposed;
-	    (*pScreen->WindowExposures) (pWin, valExposed, bsExposed);
-	    if (valExposed)
-		REGION_EMPTY(pScreen, valExposed);
-	    REGION_DESTROY(pScreen, bsExposed);
-	}
-    }
-    if (WasViewable)
-    {
-	if (anyMarked)
-	    (*pScreen->HandleExposures)(pWin);
-#ifdef DO_SAVE_UNDERS
-	if (dosave)
-	    (*pScreen->PostChangeSaveUnder)(pLayerWin, pLayerWin);
-#endif /* DO_SAVE_UNDERS */
-	if (anyMarked && pScreen->PostValidateTree)
-	    (*pScreen->PostValidateTree)(pWin, NullWindow, VTOther);
-    }
-    if (pWin->realized)
-	WindowsRestructured ();
-    FlushAllOutput ();
-}
diff --git a/hw/darwin/darwin.h b/hw/darwin/darwin.h
deleted file mode 100644
index 0f5f492..0000000
--- a/hw/darwin/darwin.h
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Copyright (c) 2001-2004 Torrey T. Lyons. 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
- * 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 _DARWIN_H
-#define _DARWIN_H
-
-#include <IOKit/IOTypes.h>
-#include "inputstr.h"
-#include "scrnintstr.h"
-#include <X11/extensions/XKB.h>
-#include <assert.h>
-
-typedef struct {
-    void                *framebuffer;
-    int                 x;
-    int                 y;
-    int                 width;
-    int                 height;
-    int                 pitch;
-    int                 colorType;
-    int                 bitsPerPixel;
-    int                 colorBitsPerPixel;
-    int                 bitsPerComponent;
-} DarwinFramebufferRec, *DarwinFramebufferPtr;
-
-// From darwin.c
-void DarwinPrintBanner(void);
-int DarwinParseModifierList(const char *constmodifiers);
-void DarwinAdjustScreenOrigins(ScreenInfo *pScreenInfo);
-void xf86SetRootClip (ScreenPtr pScreen, BOOL enable);
-
-// From darwinEvents.c
-Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr);
-void DarwinEQEnqueue(const xEvent *e);
-void DarwinEQPointerPost(xEvent *e);
-void DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX);
-void DarwinPokeEQ(void);
-void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int pointer_y);
-void DarwinSendKeyboardEvents(int ev_type, int keycode);
-void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y);
-
-// Mode specific functions
-Bool DarwinModeAddScreen(int index, ScreenPtr pScreen);
-Bool DarwinModeSetupScreen(int index, ScreenPtr pScreen);
-void DarwinModeInitOutput(int argc,char **argv);
-void DarwinModeInitInput(int argc, char **argv);
-void DarwinModeProcessEvent(xEvent *xe);
-void DarwinModeGiveUp(void);
-void DarwinModeBell(int volume, DeviceIntPtr pDevice, pointer ctrl, int class);
-
-
-#undef assert
-#define assert(x) { if ((x) == 0) \
-    FatalError("assert failed on line %d of %s!\n", __LINE__, __FILE__); }
-#define kern_assert(x) { if ((x) != KERN_SUCCESS) \
-    FatalError("assert failed on line %d of %s with kernel return 0x%x!\n", \
-                __LINE__, __FILE__, x); }
-#define SCREEN_PRIV(pScreen) \
-    ((DarwinFramebufferPtr)pScreen->devPrivates[darwinScreenIndex].ptr)
-
-
-#define MIN_KEYCODE XkbMinLegalKeyCode     // unfortunately, this isn't 0...
-
-
-/*
- * Global variables from darwin.c
- */
-extern int              darwinScreenIndex; // index into pScreen.devPrivates
-extern int              darwinScreensFound;
-extern io_connect_t     darwinParamConnect;
-extern int              darwinEventReadFD;
-extern int              darwinEventWriteFD;
-extern DeviceIntPtr     darwinPointer;
-extern DeviceIntPtr     darwinKeyboard;
-
-// User preferences
-extern int              darwinMouseAccelChange;
-extern int              darwinFakeButtons;
-extern int              darwinFakeMouse2Mask;
-extern int              darwinFakeMouse3Mask;
-extern char            *darwinKeymapFile;
-extern int              darwinSyncKeymap;
-extern unsigned int     darwinDesiredWidth, darwinDesiredHeight;
-extern int              darwinDesiredDepth;
-extern int              darwinDesiredRefresh;
-
-// location of X11's (0,0) point in global screen coordinates
-extern int              darwinMainScreenX;
-extern int              darwinMainScreenY;
-
-
-/*
- * Special ddx events understood by the X server
- */
-enum {
-    kXDarwinUpdateModifiers   // update all modifier keys
-            = LASTEvent+1,    // (from X.h list of event names)
-    kXDarwinUpdateButtons,    // update state of mouse buttons 2 and up
-    kXDarwinScrollWheel,      // scroll wheel event
-    /*
-     * Quartz-specific events -- not used in IOKit mode
-     */
-    kXDarwinActivate,         // restore X drawing and cursor
-    kXDarwinDeactivate,       // clip X drawing and switch to Aqua cursor
-    kXDarwinSetRootClip,      // enable or disable drawing to the X screen
-    kXDarwinQuit,             // kill the X server and release the display
-    kXDarwinReadPasteboard,   // copy Mac OS X pasteboard into X cut buffer
-    kXDarwinWritePasteboard,  // copy X cut buffer onto Mac OS X pasteboard
-    kXDarwinBringAllToFront,  // bring all X windows to front
-    kXDarwinToggleFullscreen, // Enable/Disable fullscreen mode
-    kXDarwinSetRootless,      // Set rootless mode
-    /*
-     * AppleWM events
-     */
-    kXDarwinControllerNotify, // send an AppleWMControllerNotify event
-    kXDarwinPasteboardNotify, // notify the WM to copy or paste
-    /*
-     * Xplugin notification events
-     */
-    kXDarwinDisplayChanged,   // display configuration has changed
-    kXDarwinWindowState,      // window visibility state has changed
-    kXDarwinWindowMoved       // window has moved on screen
-};
-
-#define ENABLE_DEBUG_LOG 1
-
-#ifdef ENABLE_DEBUG_LOG
-extern FILE *debug_log_fp;
-#define DEBUG_LOG_NAME "x11-debug.txt"
-#define DEBUG_LOG(msg, args...) if (debug_log_fp) fprintf(debug_log_fp, "%s:%d: " msg, __FUNCTION__, __LINE__, ##args )
-#else
-#define DEBUG_LOG(msg, args...) 
-#endif
-
-#endif  /* _DARWIN_H */
diff --git a/hw/darwin/darwinClut8.h b/hw/darwin/darwinClut8.h
deleted file mode 100644
index 8e914f3..0000000
--- a/hw/darwin/darwinClut8.h
+++ /dev/null
@@ -1,531 +0,0 @@
-/*
- * Darwin default 8-bit Colormap for StaticColor
- */
-
-#ifndef _DARWIN_CLUT8_
-#define _DARWIN_CLUT8_
-
-#ifdef USE_NEW_CLUT
-
-static xColorItem darwinClut8[] = {    
-    { 0, 0xffff, 0xffff, 0xffff,  0, 0 },
-    { 1, 0xfefe, 0xfefe, 0xfefe,  0, 0 },
-    { 2, 0xfdfd, 0xfdfd, 0xfdfd,  0, 0 },
-    { 3, 0xb8b8, 0x2727, 0x2b2b,  0, 0 },
-    { 4, 0xfcfc, 0xfcfc, 0xfcfc,  0, 0 },
-    { 5, 0xffff, 0xffff, 0x0,  0, 0 },
-    { 6, 0xfafa, 0xfafa, 0xfafa,  0, 0 },
-    { 7, 0xf9f9, 0xf9f9, 0xf9f9,  0, 0 },
-    { 8, 0xf8f8, 0xf8f8, 0xf8f8,  0, 0 },
-    { 9, 0xf7f7, 0xf7f7, 0xf7f7,  0, 0 },
-    { 10, 0xf6f6, 0xf6f6, 0xf6f6,  0, 0 },
-    { 11, 0xf5f5, 0xf5f5, 0xf5f5,  0, 0 },
-    { 12, 0xf4f4, 0xf4f4, 0xf4f4,  0, 0 },
-    { 13, 0xf2f2, 0xf2f2, 0xf2f2,  0, 0 },
-    { 14, 0xf1f1, 0xf1f1, 0xf1f1,  0, 0 },
-    { 15, 0x0, 0x0, 0x0,  0, 0 },
-    { 16, 0xefef, 0xefef, 0xefef,  0, 0 },
-    { 17, 0xeeee, 0xeeee, 0xeeee,  0, 0 },
-    { 18, 0xeded, 0xeded, 0xeded,  0, 0 },
-    { 19, 0xebeb, 0xebeb, 0xebeb,  0, 0 },
-    { 20, 0xe8e8, 0xe8e8, 0xe8e8,  0, 0 },
-    { 21, 0xe7e7, 0xe7e7, 0xe7e7,  0, 0 },
-    { 22, 0xc9c9, 0x3838, 0x3e3e,  0, 0 },
-    { 23, 0xe5e5, 0xe5e5, 0xe5e5,  0, 0 },
-    { 24, 0xffff, 0x0, 0xffff,  0, 0 },
-    { 25, 0xfbfb, 0xfbfb, 0xfbfb,  0, 0 },
-    { 26, 0xdede, 0x6c6c, 0x7272,  0, 0 },
-    { 27, 0xe0e0, 0xe0e0, 0xe0e0,  0, 0 },
-    { 28, 0xe8e8, 0x8686, 0x9090,  0, 0 },
-    { 29, 0xdede, 0xdede, 0xdede,  0, 0 },
-    { 30, 0xdddd, 0xdddd, 0xdddd,  0, 0 },
-    { 31, 0xd3d3, 0x7e7e, 0x8d8d,  0, 0 },
-    { 32, 0xd9d9, 0xd9d9, 0xd9d9,  0, 0 },
-    { 33, 0xf3f3, 0x9696, 0xa6a6,  0, 0 },
-    { 34, 0xb1b1, 0x1c1c, 0x3939,  0, 0 },
-    { 35, 0xffff, 0x0, 0x0,  0, 0 },
-    { 36, 0xbebe, 0x5e5e, 0x7272,  0, 0 },
-    { 37, 0xd3d3, 0xd3d3, 0xd3d3,  0, 0 },
-    { 38, 0xc6c6, 0x2e2e, 0x6767,  0, 0 },
-    { 39, 0xd1d1, 0xd1d1, 0xd1d1,  0, 0 },
-    { 40, 0xa3a3, 0x606, 0x4545,  0, 0 },
-    { 41, 0xcece, 0xcece, 0xcece,  0, 0 },
-    { 42, 0xcccc, 0xcccc, 0xffff,  0, 0 },
-    { 43, 0xcccc, 0xcccc, 0xcccc,  0, 0 },
-    { 44, 0xc6c6, 0x8f8f, 0xa7a7,  0, 0 },
-    { 45, 0xe1e1, 0xd3d3, 0xd9d9,  0, 0 },
-    { 46, 0xcece, 0x9e9e, 0xb4b4,  0, 0 },
-    { 47, 0xcaca, 0xcaca, 0xcaca,  0, 0 },
-    { 48, 0xbfbf, 0x3f3f, 0x7d7d,  0, 0 },
-    { 49, 0xc9c9, 0xc9c9, 0xc9c9,  0, 0 },
-    { 50, 0xf4f4, 0x8989, 0xbebe,  0, 0 },
-    { 51, 0xc6c6, 0xc6c6, 0xc6c6,  0, 0 },
-    { 52, 0xd6d6, 0x5151, 0x9797,  0, 0 },
-    { 53, 0xc9c9, 0x2c2c, 0x8484,  0, 0 },
-    { 54, 0x9696, 0x1a1a, 0x6a6a,  0, 0 },
-    { 55, 0xc2c2, 0xc2c2, 0xc2c2,  0, 0 },
-    { 56, 0xf3f3, 0x6f6f, 0xc6c6,  0, 0 },
-    { 57, 0xe5e5, 0x4c4c, 0xbbbb,  0, 0 },
-    { 58, 0xb7b7, 0x5a5a, 0x9c9c,  0, 0 },
-    { 59, 0xbfbf, 0xbfbf, 0xbfbf,  0, 0 },
-    { 60, 0xbebe, 0xbebe, 0xbebe,  0, 0 },
-    { 61, 0xbdbd, 0xbdbd, 0xbdbd,  0, 0 },
-    { 62, 0xb8b8, 0x2121, 0xa2a2,  0, 0 },
-    { 63, 0xd3d3, 0x4444, 0xc0c0,  0, 0 },
-    { 64, 0xc2c2, 0x6666, 0xb7b7,  0, 0 },
-    { 65, 0xf4f4, 0x6666, 0xe6e6,  0, 0 },
-    { 66, 0xfcfc, 0x7373, 0xfdfd,  0, 0 },
-    { 67, 0xb9b9, 0xb9b9, 0xb9b9,  0, 0 },
-    { 68, 0xeaea, 0xdfdf, 0xeaea,  0, 0 },
-    { 69, 0xd4d4, 0x7171, 0xd5d5,  0, 0 },
-    { 70, 0xf9f9, 0x8b8b, 0xffff,  0, 0 },
-    { 71, 0xf5f5, 0xadad, 0xffff,  0, 0 },
-    { 72, 0xbcbc, 0x9292, 0xc2c2,  0, 0 },
-    { 73, 0xc7c7, 0x4f4f, 0xd9d9,  0, 0 },
-    { 74, 0xa0a0, 0x4444, 0xafaf,  0, 0 },
-    { 75, 0xc8c8, 0x8c8c, 0xd5d5,  0, 0 },
-    { 76, 0xd7d7, 0x7474, 0xf7f7,  0, 0 },
-    { 77, 0xb4b4, 0xb4b4, 0xb4b4,  0, 0 },
-    { 78, 0xdada, 0x9595, 0xf9f9,  0, 0 },
-    { 79, 0xeded, 0xcbcb, 0xffff,  0, 0 },
-    { 80, 0xb2b2, 0xb2b2, 0xb2b2,  0, 0 },
-    { 81, 0xa1a1, 0x6161, 0xd7d7,  0, 0 },
-    { 82, 0xb2b2, 0x8585, 0xe2e2,  0, 0 },
-    { 83, 0x5959, 0x2626, 0x9c9c,  0, 0 },
-    { 84, 0x7c7c, 0x5151, 0xcccc,  0, 0 },
-    { 85, 0xb0b0, 0xb0b0, 0xb0b0,  0, 0 },
-    { 86, 0xb4b4, 0x8e8e, 0xfcfc,  0, 0 },
-    { 87, 0xd5d5, 0xc0c0, 0xffff,  0, 0 },
-    { 88, 0x5d5d, 0x3232, 0xcccc,  0, 0 },
-    { 89, 0x7b7b, 0x5c5c, 0xe5e5,  0, 0 },
-    { 90, 0xc0c0, 0xb0b0, 0xfdfd,  0, 0 },
-    { 91, 0x6060, 0x5353, 0xadad,  0, 0 },
-    { 92, 0x1212, 0xc0c, 0x7e7e,  0, 0 },
-    { 93, 0x2e2e, 0x2929, 0x9999,  0, 0 },
-    { 94, 0x7979, 0x7878, 0xe9e9,  0, 0 },
-    { 95, 0x5b5b, 0x5c5c, 0xd0d0,  0, 0 },
-    { 96, 0x6969, 0x6a6a, 0xcccc,  0, 0 },
-    { 97, 0x9393, 0x9494, 0xf8f8,  0, 0 },
-    { 98, 0x9292, 0x9292, 0xc3c3,  0, 0 },
-    { 99, 0x4141, 0x4444, 0xbaba,  0, 0 },
-    { 100, 0xa8a8, 0xabab, 0xffff,  0, 0 },
-    { 101, 0xa3a3, 0xa3a3, 0xa3a3,  0, 0 },
-    { 102, 0xdbdb, 0xdddd, 0xeaea,  0, 0 },
-    { 103, 0x3131, 0x4949, 0xaaaa,  0, 0 },
-    { 104, 0x7070, 0x8f8f, 0xf9f9,  0, 0 },
-    { 105, 0x4848, 0x6666, 0xc1c1,  0, 0 },
-    { 106, 0x5c5c, 0x7e7e, 0xe9e9,  0, 0 },
-    { 107, 0xe2e2, 0xe5e5, 0xebeb,  0, 0 },
-    { 108, 0xb0b0, 0xcdcd, 0xffff,  0, 0 },
-    { 109, 0x6c6c, 0x8989, 0xb7b7,  0, 0 },
-    { 110, 0x3434, 0x6565, 0xafaf,  0, 0 },
-    { 111, 0x8c8c, 0xb9b9, 0xffff,  0, 0 },
-    { 112, 0x3737, 0x7979, 0xd4d4,  0, 0 },
-    { 113, 0x5a5a, 0x9999, 0xeaea,  0, 0 },
-    { 114, 0xe0e, 0x4c4c, 0x9595,  0, 0 },
-    { 115, 0x7979, 0xb9b9, 0xffff,  0, 0 },
-    { 116, 0x8a8a, 0xa3a3, 0xbcbc,  0, 0 },
-    { 117, 0x2020, 0x6161, 0x9d9d,  0, 0 },
-    { 118, 0x8f8f, 0xaeae, 0xcaca,  0, 0 },
-    { 119, 0xa0a, 0x6060, 0xa8a8,  0, 0 },
-    { 120, 0x3f3f, 0x9494, 0xd9d9,  0, 0 },
-    { 121, 0x6363, 0xb5b5, 0xf9f9,  0, 0 },
-    { 122, 0xe2e2, 0xe8e8, 0xeded,  0, 0 },
-    { 123, 0x2828, 0x6a6a, 0x9999,  0, 0 },
-    { 124, 0x5555, 0xb2b2, 0xe7e7,  0, 0 },
-    { 125, 0x3232, 0x8989, 0xa9a9,  0, 0 },
-    { 126, 0xcfcf, 0xdada, 0xdede,  0, 0 },
-    { 127, 0x2929, 0xa1a1, 0xc7c7,  0, 0 },
-    { 128, 0x8686, 0xa9a9, 0xb4b4,  0, 0 },
-    { 129, 0x0, 0x5f5f, 0x7979,  0, 0 },
-    { 130, 0xc0c, 0x7777, 0x8e8e,  0, 0 },
-    { 131, 0x1212, 0x8f8f, 0xabab,  0, 0 },
-    { 132, 0x4141, 0xbaba, 0xd5d5,  0, 0 },
-    { 133, 0x2424, 0x8282, 0x8383,  0, 0 },
-    { 134, 0x2c2c, 0xc4c4, 0xc3c3,  0, 0 },
-    { 135, 0x1a1a, 0xabab, 0xa6a6,  0, 0 },
-    { 136, 0x4b4b, 0xa8a8, 0xa2a2,  0, 0 },
-    { 137, 0xa0a, 0x9393, 0x8585,  0, 0 },
-    { 138, 0xd0d, 0xa5a5, 0x9696,  0, 0 },
-    { 139, 0x2626, 0xbcbc, 0xacac,  0, 0 },
-    { 140, 0x404, 0x8181, 0x7272,  0, 0 },
-    { 141, 0x1919, 0xb3b3, 0x8686,  0, 0 },
-    { 142, 0x2929, 0xc1c1, 0x9494,  0, 0 },
-    { 143, 0x2121, 0x9c9c, 0x7171,  0, 0 },
-    { 144, 0x202, 0x8c8c, 0x5050,  0, 0 },
-    { 145, 0x3535, 0xd0d0, 0x8989,  0, 0 },
-    { 146, 0x4646, 0xa5a5, 0x7676,  0, 0 },
-    { 147, 0x202, 0x7d7d, 0x3939,  0, 0 },
-    { 148, 0x2929, 0xc9c9, 0x7171,  0, 0 },
-    { 149, 0x5757, 0xd6d6, 0x8f8f,  0, 0 },
-    { 150, 0xa2a2, 0xb5b5, 0xaaaa,  0, 0 },
-    { 151, 0x101, 0x8888, 0x2a2a,  0, 0 },
-    { 152, 0x7474, 0xbebe, 0x8a8a,  0, 0 },
-    { 153, 0x1919, 0xb6b6, 0x4747,  0, 0 },
-    { 154, 0x2d2d, 0xc6c6, 0x5151,  0, 0 },
-    { 155, 0x3838, 0xdede, 0x5d5d,  0, 0 },
-    { 156, 0x4c4c, 0xf4f4, 0x6f6f,  0, 0 },
-    { 157, 0x9191, 0x9c9c, 0x9393,  0, 0 },
-    { 158, 0x0, 0x8e8e, 0x1919,  0, 0 },
-    { 159, 0x1010, 0xafaf, 0x2828,  0, 0 },
-    { 160, 0xe3e3, 0xe3e3, 0xe3e3,  0, 0 },
-    { 161, 0x808, 0xa1a1, 0x1a1a,  0, 0 },
-    { 162, 0x5959, 0xc2c2, 0x6161,  0, 0 },
-    { 163, 0xf0f0, 0xf0f0, 0xf0f0,  0, 0 },
-    { 164, 0x8f8f, 0x9c9c, 0x9090,  0, 0 },
-    { 165, 0x2323, 0xcece, 0x2a2a,  0, 0 },
-    { 166, 0x1212, 0xbaba, 0x1717,  0, 0 },
-    { 167, 0x101, 0x8a8a, 0x202,  0, 0 },
-    { 168, 0x303, 0x9a9a, 0x202,  0, 0 },
-    { 169, 0x4040, 0xe4e4, 0x4040,  0, 0 },
-    { 170, 0x808, 0xb2b2, 0x505,  0, 0 },
-    { 171, 0x1313, 0xcccc, 0xf0f,  0, 0 },
-    { 172, 0x3636, 0xd7d7, 0x3232,  0, 0 },
-    { 173, 0x2828, 0xe9e9, 0x1f1f,  0, 0 },
-    { 174, 0x5353, 0xfbfb, 0x4c4c,  0, 0 },
-    { 175, 0x6f6f, 0xafaf, 0x6a6a,  0, 0 },
-    { 176, 0x7171, 0xe0e0, 0x6767,  0, 0 },
-    { 177, 0x3232, 0xc0c0, 0x1212,  0, 0 },
-    { 178, 0x2929, 0xa5a5, 0x808,  0, 0 },
-    { 179, 0x5c5c, 0xdddd, 0x3535,  0, 0 },
-    { 180, 0x0, 0xffff, 0xffff,  0, 0 },
-    { 181, 0x6363, 0xc8c8, 0x4545,  0, 0 },
-    { 182, 0x8686, 0xfdfd, 0x5b5b,  0, 0 },
-    { 183, 0x7171, 0xf6f6, 0x3939,  0, 0 },
-    { 184, 0x5555, 0xcccc, 0x1515,  0, 0 },
-    { 185, 0x0, 0xffff, 0x0,  0, 0 },
-    { 186, 0x9090, 0xcaca, 0x6e6e,  0, 0 },
-    { 187, 0x4343, 0xa7a7, 0x101,  0, 0 },
-    { 188, 0x8d8d, 0xe4e4, 0x3737,  0, 0 },
-    { 189, 0xb3b3, 0xf0f0, 0x6464,  0, 0 },
-    { 190, 0x8585, 0x8e8e, 0x7a7a,  0, 0 },
-    { 191, 0xb0b0, 0xfafa, 0x4d4d,  0, 0 },
-    { 192, 0xd6d6, 0xd6d6, 0xd6d6,  0, 0 },
-    { 193, 0x8888, 0xd0d0, 0x1a1a,  0, 0 },
-    { 194, 0x6a6a, 0xa7a7, 0x303,  0, 0 },
-    { 195, 0x9898, 0xbfbf, 0x4141,  0, 0 },
-    { 196, 0xcdcd, 0xf8f8, 0x5151,  0, 0 },
-    { 197, 0x9494, 0xa4a4, 0x5555,  0, 0 },
-    { 198, 0x9191, 0xb0b0, 0xa0a,  0, 0 },
-    { 199, 0xdada, 0xf1f1, 0x3c3c,  0, 0 },
-    { 200, 0xbaba, 0xcaca, 0x5353,  0, 0 },
-    { 201, 0xb9b9, 0xc3c3, 0x2828,  0, 0 },
-    { 202, 0xb1b1, 0xbaba, 0x1212,  0, 0 },
-    { 203, 0xd2d2, 0xd9d9, 0x2626,  0, 0 },
-    { 204, 0xe8e8, 0xecec, 0x2d2d,  0, 0 },
-    { 205, 0x9898, 0x9696, 0x202,  0, 0 },
-    { 206, 0xadad, 0xadad, 0x5c5c,  0, 0 },
-    { 207, 0xe2e2, 0xd8d8, 0x3838,  0, 0 },
-    { 208, 0xd9d9, 0xc4c4, 0x3838,  0, 0 },
-    { 209, 0xa8a8, 0x9a9a, 0x5050,  0, 0 },
-    { 210, 0x0, 0x0, 0xffff,  0, 0 },
-    { 211, 0xbebe, 0xaeae, 0x5e5e,  0, 0 },
-    { 212, 0x9a9a, 0x9898, 0x8e8e,  0, 0 },
-    { 213, 0xacac, 0x8d8d, 0xd0d,  0, 0 },
-    { 214, 0xc5c5, 0xa0a0, 0x2b2b,  0, 0 },
-    { 215, 0xdbdb, 0xb5b5, 0x4848,  0, 0 },
-    { 216, 0xdddd, 0x0, 0x0,  0, 0 },
-    { 217, 0x9c9c, 0x6d6d, 0x303,  0, 0 },
-    { 218, 0xd4d4, 0xa8a8, 0x4747,  0, 0 },
-    { 219, 0xb7b7, 0x7171, 0x1717,  0, 0 },
-    { 220, 0xdcdc, 0xa1a1, 0x5a5a,  0, 0 },
-    { 221, 0xb9b9, 0x9c9c, 0x7c7c,  0, 0 },
-    { 222, 0xb4b4, 0xabab, 0xa2a2,  0, 0 },
-    { 223, 0x9e9e, 0x4b4b, 0x101,  0, 0 },
-    { 224, 0xc8c8, 0x7878, 0x3535,  0, 0 },
-    { 225, 0xd2d2, 0x8d8d, 0x5151,  0, 0 },
-    { 226, 0xadad, 0x5252, 0xf0f,  0, 0 },
-    { 227, 0x0, 0xbbbb, 0x0,  0, 0 },
-    { 228, 0xb2b2, 0x6666, 0x3838,  0, 0 },
-    { 229, 0xb1b1, 0xa6a6, 0x9f9f,  0, 0 },
-    { 230, 0xb1b1, 0x8787, 0x6f6f,  0, 0 },
-    { 231, 0xa4a4, 0x3434, 0x303,  0, 0 },
-    { 232, 0xeeee, 0x9e9e, 0x8585,  0, 0 },
-    { 233, 0xc9c9, 0x7373, 0x5a5a,  0, 0 },
-    { 234, 0xe6e6, 0x9494, 0x7c7c,  0, 0 },
-    { 235, 0xa9a9, 0x2222, 0x606,  0, 0 },
-    { 236, 0xdbdb, 0x8787, 0x7474,  0, 0 },
-    { 237, 0xb0b0, 0x2e2e, 0x1515,  0, 0 },
-    { 238, 0xb7b7, 0x5a5a, 0x5050,  0, 0 },
-    { 239, 0xb2b2, 0x4242, 0x3b3b,  0, 0 },
-    { 240, 0xcdcd, 0x7373, 0x6e6e,  0, 0 },
-    { 241, 0xd9d9, 0x5858, 0x5858,  0, 0 },
-    { 242, 0xacac, 0xacac, 0xacac,  0, 0 },
-    { 243, 0xa0a0, 0xa0a0, 0xa0a0,  0, 0 },
-    { 244, 0x9a9a, 0x9a9a, 0x9a9a,  0, 0 },
-    { 245, 0x9292, 0x9292, 0x9292,  0, 0 },
-    { 246, 0x8e8e, 0x8e8e, 0x8e8e,  0, 0 },
-    { 247, 0xbbbb, 0xbbbb, 0xbbbb,  0, 0 },
-    { 248, 0x8181, 0x8181, 0x8181,  0, 0 },
-    { 249, 0x8888, 0x8888, 0x8888,  0, 0 },
-    { 250, 0x7777, 0x7777, 0x7777,  0, 0 },
-    { 251, 0x5555, 0x5555, 0x5555,  0, 0 },
-    { 252, 0x4444, 0x4444, 0x4444,  0, 0 },
-    { 253, 0x2222, 0x2222, 0x2222,  0, 0 },
-    { 254, 0x7b7b, 0x7b7b, 0x7b7b,  0, 0 },
-    { 255, 0x0, 0x0, 0x0,  0, 0 },
-};
-
-#else /* !USE_NEW_CLUT */
-
-static xColorItem darwinClut8[] = {
-    { 0, 0x0000, 0x0000, 0x0000,  0, 0 },
-    { 1, 0xffff, 0xffff, 0xcccc,  0, 0 },
-    { 2, 0xffff, 0xffff, 0x9999,  0, 0 },
-    { 3, 0xffff, 0xffff, 0x6666,  0, 0 },
-    { 4, 0xffff, 0xffff, 0x3333,  0, 0 },
-    { 5, 0xffff, 0xffff, 0x0000,  0, 0 },
-    { 6, 0xffff, 0xcccc, 0xffff,  0, 0 },
-    { 7, 0xffff, 0xcccc, 0xcccc,  0, 0 },
-    { 8, 0xffff, 0xcccc, 0x9999,  0, 0 },
-    { 9, 0xffff, 0xcccc, 0x6666,  0, 0 },
-    { 10, 0xffff, 0xcccc, 0x3333,  0, 0 },
-    { 11, 0xffff, 0xcccc, 0x0000,  0, 0 },
-    { 12, 0xffff, 0x9999, 0xffff,  0, 0 },
-    { 13, 0xffff, 0x9999, 0xcccc,  0, 0 },
-    { 14, 0xffff, 0x9999, 0x9999,  0, 0 },
-    { 15, 0xffff, 0x9999, 0x6666,  0, 0 },
-    { 16, 0xffff, 0x9999, 0x3333,  0, 0 },
-    { 17, 0xffff, 0x9999, 0x0000,  0, 0 },
-    { 18, 0xffff, 0x6666, 0xffff,  0, 0 },
-    { 19, 0xffff, 0x6666, 0xcccc,  0, 0 },
-    { 20, 0xffff, 0x6666, 0x9999,  0, 0 },
-    { 21, 0xffff, 0x6666, 0x6666,  0, 0 },
-    { 22, 0xffff, 0x6666, 0x3333,  0, 0 },
-    { 23, 0xffff, 0x6666, 0x0000,  0, 0 },
-    { 24, 0xffff, 0x3333, 0xffff,  0, 0 },
-    { 25, 0xffff, 0x3333, 0xcccc,  0, 0 },
-    { 26, 0xffff, 0x3333, 0x9999,  0, 0 },
-    { 27, 0xffff, 0x3333, 0x6666,  0, 0 },
-    { 28, 0xffff, 0x3333, 0x3333,  0, 0 },
-    { 29, 0xffff, 0x3333, 0x0000,  0, 0 },
-    { 30, 0xffff, 0x0000, 0xffff,  0, 0 },
-    { 31, 0xffff, 0x0000, 0xcccc,  0, 0 },
-    { 32, 0xffff, 0x0000, 0x9999,  0, 0 },
-    { 33, 0xffff, 0x0000, 0x6666,  0, 0 },
-    { 34, 0xffff, 0x0000, 0x3333,  0, 0 },
-    { 35, 0xffff, 0x0000, 0x0000,  0, 0 },
-    { 36, 0xcccc, 0xffff, 0xffff,  0, 0 },
-    { 37, 0xcccc, 0xffff, 0xcccc,  0, 0 },
-    { 38, 0xcccc, 0xffff, 0x9999,  0, 0 },
-    { 39, 0xcccc, 0xffff, 0x6666,  0, 0 },
-    { 40, 0xcccc, 0xffff, 0x3333,  0, 0 },
-    { 41, 0xcccc, 0xffff, 0x0000,  0, 0 },
-    { 42, 0xcccc, 0xcccc, 0xffff,  0, 0 },
-    { 43, 0xcccc, 0xcccc, 0xcccc,  0, 0 },
-    { 44, 0xcccc, 0xcccc, 0x9999,  0, 0 },
-    { 45, 0xcccc, 0xcccc, 0x6666,  0, 0 },
-    { 46, 0xcccc, 0xcccc, 0x3333,  0, 0 },
-    { 47, 0xcccc, 0xcccc, 0x0000,  0, 0 },
-    { 48, 0xcccc, 0x9999, 0xffff,  0, 0 },
-    { 49, 0xcccc, 0x9999, 0xcccc,  0, 0 },
-    { 50, 0xcccc, 0x9999, 0x9999,  0, 0 },
-    { 51, 0xcccc, 0x9999, 0x6666,  0, 0 },
-    { 52, 0xcccc, 0x9999, 0x3333,  0, 0 },
-    { 53, 0xcccc, 0x9999, 0x0000,  0, 0 },
-    { 54, 0xcccc, 0x6666, 0xffff,  0, 0 },
-    { 55, 0xcccc, 0x6666, 0xcccc,  0, 0 },
-    { 56, 0xcccc, 0x6666, 0x9999,  0, 0 },
-    { 57, 0xcccc, 0x6666, 0x6666,  0, 0 },
-    { 58, 0xcccc, 0x6666, 0x3333,  0, 0 },
-    { 59, 0xcccc, 0x6666, 0x0000,  0, 0 },
-    { 60, 0xcccc, 0x3333, 0xffff,  0, 0 },
-    { 61, 0xcccc, 0x3333, 0xcccc,  0, 0 },
-    { 62, 0xcccc, 0x3333, 0x9999,  0, 0 },
-    { 63, 0xcccc, 0x3333, 0x6666,  0, 0 },
-    { 64, 0xcccc, 0x3333, 0x3333,  0, 0 },
-    { 65, 0xcccc, 0x3333, 0x0000,  0, 0 },
-    { 66, 0xcccc, 0x0000, 0xffff,  0, 0 },
-    { 67, 0xcccc, 0x0000, 0xcccc,  0, 0 },
-    { 68, 0xcccc, 0x0000, 0x9999,  0, 0 },
-    { 69, 0xcccc, 0x0000, 0x6666,  0, 0 },
-    { 70, 0xcccc, 0x0000, 0x3333,  0, 0 },
-    { 71, 0xcccc, 0x0000, 0x0000,  0, 0 },
-    { 72, 0x9999, 0xffff, 0xffff,  0, 0 },
-    { 73, 0x9999, 0xffff, 0xcccc,  0, 0 },
-    { 74, 0x9999, 0xffff, 0x9999,  0, 0 },
-    { 75, 0x9999, 0xffff, 0x6666,  0, 0 },
-    { 76, 0x9999, 0xffff, 0x3333,  0, 0 },
-    { 77, 0x9999, 0xffff, 0x0000,  0, 0 },
-    { 78, 0x9999, 0xcccc, 0xffff,  0, 0 },
-    { 79, 0x9999, 0xcccc, 0xcccc,  0, 0 },
-    { 80, 0x9999, 0xcccc, 0x9999,  0, 0 },
-    { 81, 0x9999, 0xcccc, 0x6666,  0, 0 },
-    { 82, 0x9999, 0xcccc, 0x3333,  0, 0 },
-    { 83, 0x9999, 0xcccc, 0x0000,  0, 0 },
-    { 84, 0x9999, 0x9999, 0xffff,  0, 0 },
-    { 85, 0x9999, 0x9999, 0xcccc,  0, 0 },
-    { 86, 0x9999, 0x9999, 0x9999,  0, 0 },
-    { 87, 0x9999, 0x9999, 0x6666,  0, 0 },
-    { 88, 0x9999, 0x9999, 0x3333,  0, 0 },
-    { 89, 0x9999, 0x9999, 0x0000,  0, 0 },
-    { 90, 0x9999, 0x6666, 0xffff,  0, 0 },
-    { 91, 0x9999, 0x6666, 0xcccc,  0, 0 },
-    { 92, 0x9999, 0x6666, 0x9999,  0, 0 },
-    { 93, 0x9999, 0x6666, 0x6666,  0, 0 },
-    { 94, 0x9999, 0x6666, 0x3333,  0, 0 },
-    { 95, 0x9999, 0x6666, 0x0000,  0, 0 },
-    { 96, 0x9999, 0x3333, 0xffff,  0, 0 },
-    { 97, 0x9999, 0x3333, 0xcccc,  0, 0 },
-    { 98, 0x9999, 0x3333, 0x9999,  0, 0 },
-    { 99, 0x9999, 0x3333, 0x6666,  0, 0 },
-    { 100, 0x9999, 0x3333, 0x3333,  0, 0 },
-    { 101, 0x9999, 0x3333, 0x0000,  0, 0 },
-    { 102, 0x9999, 0x0000, 0xffff,  0, 0 },
-    { 103, 0x9999, 0x0000, 0xcccc,  0, 0 },
-    { 104, 0x9999, 0x0000, 0x9999,  0, 0 },
-    { 105, 0x9999, 0x0000, 0x6666,  0, 0 },
-    { 106, 0x9999, 0x0000, 0x3333,  0, 0 },
-    { 107, 0x9999, 0x0000, 0x0000,  0, 0 },
-    { 108, 0x6666, 0xffff, 0xffff,  0, 0 },
-    { 109, 0x6666, 0xffff, 0xcccc,  0, 0 },
-    { 110, 0x6666, 0xffff, 0x9999,  0, 0 },
-    { 111, 0x6666, 0xffff, 0x6666,  0, 0 },
-    { 112, 0x6666, 0xffff, 0x3333,  0, 0 },
-    { 113, 0x6666, 0xffff, 0x0000,  0, 0 },
-    { 114, 0x6666, 0xcccc, 0xffff,  0, 0 },
-    { 115, 0x6666, 0xcccc, 0xcccc,  0, 0 },
-    { 116, 0x6666, 0xcccc, 0x9999,  0, 0 },
-    { 117, 0x6666, 0xcccc, 0x6666,  0, 0 },
-    { 118, 0x6666, 0xcccc, 0x3333,  0, 0 },
-    { 119, 0x6666, 0xcccc, 0x0000,  0, 0 },
-    { 120, 0x6666, 0x9999, 0xffff,  0, 0 },
-    { 121, 0x6666, 0x9999, 0xcccc,  0, 0 },
-    { 122, 0x6666, 0x9999, 0x9999,  0, 0 },
-    { 123, 0x6666, 0x9999, 0x6666,  0, 0 },
-    { 124, 0x6666, 0x9999, 0x3333,  0, 0 },
-    { 125, 0x6666, 0x9999, 0x0000,  0, 0 },
-    { 126, 0x6666, 0x6666, 0xffff,  0, 0 },
-    { 127, 0x6666, 0x6666, 0xcccc,  0, 0 },
-    { 128, 0x6666, 0x6666, 0x9999,  0, 0 },
-    { 129, 0x6666, 0x6666, 0x6666,  0, 0 },
-    { 130, 0x6666, 0x6666, 0x3333,  0, 0 },
-    { 131, 0x6666, 0x6666, 0x0000,  0, 0 },
-    { 132, 0x6666, 0x3333, 0xffff,  0, 0 },
-    { 133, 0x6666, 0x3333, 0xcccc,  0, 0 },
-    { 134, 0x6666, 0x3333, 0x9999,  0, 0 },
-    { 135, 0x6666, 0x3333, 0x6666,  0, 0 },
-    { 136, 0x6666, 0x3333, 0x3333,  0, 0 },
-    { 137, 0x6666, 0x3333, 0x0000,  0, 0 },
-    { 138, 0x6666, 0x0000, 0xffff,  0, 0 },
-    { 139, 0x6666, 0x0000, 0xcccc,  0, 0 },
-    { 140, 0x6666, 0x0000, 0x9999,  0, 0 },
-    { 141, 0x6666, 0x0000, 0x6666,  0, 0 },
-    { 142, 0x6666, 0x0000, 0x3333,  0, 0 },
-    { 143, 0x6666, 0x0000, 0x0000,  0, 0 },
-    { 144, 0x3333, 0xffff, 0xffff,  0, 0 },
-    { 145, 0x3333, 0xffff, 0xcccc,  0, 0 },
-    { 146, 0x3333, 0xffff, 0x9999,  0, 0 },
-    { 147, 0x3333, 0xffff, 0x6666,  0, 0 },
-    { 148, 0x3333, 0xffff, 0x3333,  0, 0 },
-    { 149, 0x3333, 0xffff, 0x0000,  0, 0 },
-    { 150, 0x3333, 0xcccc, 0xffff,  0, 0 },
-    { 151, 0x3333, 0xcccc, 0xcccc,  0, 0 },
-    { 152, 0x3333, 0xcccc, 0x9999,  0, 0 },
-    { 153, 0x3333, 0xcccc, 0x6666,  0, 0 },
-    { 154, 0x3333, 0xcccc, 0x3333,  0, 0 },
-    { 155, 0x3333, 0xcccc, 0x0000,  0, 0 },
-    { 156, 0x3333, 0x9999, 0xffff,  0, 0 },
-    { 157, 0x3333, 0x9999, 0xcccc,  0, 0 },
-    { 158, 0x3333, 0x9999, 0x9999,  0, 0 },
-    { 159, 0x3333, 0x9999, 0x6666,  0, 0 },
-    { 160, 0x3333, 0x9999, 0x3333,  0, 0 },
-    { 161, 0x3333, 0x9999, 0x0000,  0, 0 },
-    { 162, 0x3333, 0x6666, 0xffff,  0, 0 },
-    { 163, 0x3333, 0x6666, 0xcccc,  0, 0 },
-    { 164, 0x3333, 0x6666, 0x9999,  0, 0 },
-    { 165, 0x3333, 0x6666, 0x6666,  0, 0 },
-    { 166, 0x3333, 0x6666, 0x3333,  0, 0 },
-    { 167, 0x3333, 0x6666, 0x0000,  0, 0 },
-    { 168, 0x3333, 0x3333, 0xffff,  0, 0 },
-    { 169, 0x3333, 0x3333, 0xcccc,  0, 0 },
-    { 170, 0x3333, 0x3333, 0x9999,  0, 0 },
-    { 171, 0x3333, 0x3333, 0x6666,  0, 0 },
-    { 172, 0x3333, 0x3333, 0x3333,  0, 0 },
-    { 173, 0x3333, 0x3333, 0x0000,  0, 0 },
-    { 174, 0x3333, 0x0000, 0xffff,  0, 0 },
-    { 175, 0x3333, 0x0000, 0xcccc,  0, 0 },
-    { 176, 0x3333, 0x0000, 0x9999,  0, 0 },
-    { 177, 0x3333, 0x0000, 0x6666,  0, 0 },
-    { 178, 0x3333, 0x0000, 0x3333,  0, 0 },
-    { 179, 0x3333, 0x0000, 0x0000,  0, 0 },
-    { 180, 0x0000, 0xffff, 0xffff,  0, 0 },
-    { 181, 0x0000, 0xffff, 0xcccc,  0, 0 },
-    { 182, 0x0000, 0xffff, 0x9999,  0, 0 },
-    { 183, 0x0000, 0xffff, 0x6666,  0, 0 },
-    { 184, 0x0000, 0xffff, 0x3333,  0, 0 },
-    { 185, 0x0000, 0xffff, 0x0000,  0, 0 },
-    { 186, 0x0000, 0xcccc, 0xffff,  0, 0 },
-    { 187, 0x0000, 0xcccc, 0xcccc,  0, 0 },
-    { 188, 0x0000, 0xcccc, 0x9999,  0, 0 },
-    { 189, 0x0000, 0xcccc, 0x6666,  0, 0 },
-    { 190, 0x0000, 0xcccc, 0x3333,  0, 0 },
-    { 191, 0x0000, 0xcccc, 0x0000,  0, 0 },
-    { 192, 0x0000, 0x9999, 0xffff,  0, 0 },
-    { 193, 0x0000, 0x9999, 0xcccc,  0, 0 },
-    { 194, 0x0000, 0x9999, 0x9999,  0, 0 },
-    { 195, 0x0000, 0x9999, 0x6666,  0, 0 },
-    { 196, 0x0000, 0x9999, 0x3333,  0, 0 },
-    { 197, 0x0000, 0x9999, 0x0000,  0, 0 },
-    { 198, 0x0000, 0x6666, 0xffff,  0, 0 },
-    { 199, 0x0000, 0x6666, 0xcccc,  0, 0 },
-    { 200, 0x0000, 0x6666, 0x9999,  0, 0 },
-    { 201, 0x0000, 0x6666, 0x6666,  0, 0 },
-    { 202, 0x0000, 0x6666, 0x3333,  0, 0 },
-    { 203, 0x0000, 0x6666, 0x0000,  0, 0 },
-    { 204, 0x0000, 0x3333, 0xffff,  0, 0 },
-    { 205, 0x0000, 0x3333, 0xcccc,  0, 0 },
-    { 206, 0x0000, 0x3333, 0x9999,  0, 0 },
-    { 207, 0x0000, 0x3333, 0x6666,  0, 0 },
-    { 208, 0x0000, 0x3333, 0x3333,  0, 0 },
-    { 209, 0x0000, 0x3333, 0x0000,  0, 0 },
-    { 210, 0x0000, 0x0000, 0xffff,  0, 0 },
-    { 211, 0x0000, 0x0000, 0xcccc,  0, 0 },
-    { 212, 0x0000, 0x0000, 0x9999,  0, 0 },
-    { 213, 0x0000, 0x0000, 0x6666,  0, 0 },
-    { 214, 0x0000, 0x0000, 0x3333,  0, 0 },
-    { 215, 0xeeee, 0x0000, 0x0000,  0, 0 },
-    { 216, 0xdddd, 0x0000, 0x0000,  0, 0 },
-    { 217, 0xbbbb, 0x0000, 0x0000,  0, 0 },
-    { 218, 0xaaaa, 0x0000, 0x0000,  0, 0 },
-    { 219, 0x8888, 0x0000, 0x0000,  0, 0 },
-    { 220, 0x7777, 0x0000, 0x0000,  0, 0 },
-    { 221, 0x5555, 0x0000, 0x0000,  0, 0 },
-    { 222, 0x4444, 0x0000, 0x0000,  0, 0 },
-    { 223, 0x2222, 0x0000, 0x0000,  0, 0 },
-    { 224, 0x1111, 0x0000, 0x0000,  0, 0 },
-    { 225, 0x0000, 0xeeee, 0x0000,  0, 0 },
-    { 226, 0x0000, 0xdddd, 0x0000,  0, 0 },
-    { 227, 0x0000, 0xbbbb, 0x0000,  0, 0 },
-    { 228, 0x0000, 0xaaaa, 0x0000,  0, 0 },
-    { 229, 0x0000, 0x8888, 0x0000,  0, 0 },
-    { 230, 0x0000, 0x7777, 0x0000,  0, 0 },
-    { 231, 0x0000, 0x5555, 0x0000,  0, 0 },
-    { 232, 0x0000, 0x4444, 0x0000,  0, 0 },
-    { 233, 0x0000, 0x2222, 0x0000,  0, 0 },
-    { 234, 0x0000, 0x1111, 0x0000,  0, 0 },
-    { 235, 0x0000, 0x0000, 0xeeee,  0, 0 },
-    { 236, 0x0000, 0x0000, 0xdddd,  0, 0 },
-    { 237, 0x0000, 0x0000, 0xbbbb,  0, 0 },
-    { 238, 0x0000, 0x0000, 0xaaaa,  0, 0 },
-    { 239, 0x0000, 0x0000, 0x8888,  0, 0 },
-    { 240, 0x0000, 0x0000, 0x7777,  0, 0 },
-    { 241, 0x0000, 0x0000, 0x5555,  0, 0 },
-    { 242, 0x0000, 0x0000, 0x4444,  0, 0 },
-    { 243, 0x0000, 0x0000, 0x2222,  0, 0 },
-    { 244, 0x0000, 0x0000, 0x1111,  0, 0 },
-    { 245, 0xeeee, 0xeeee, 0xeeee,  0, 0 },
-    { 246, 0xdddd, 0xdddd, 0xdddd,  0, 0 },
-    { 247, 0xbbbb, 0xbbbb, 0xbbbb,  0, 0 },
-    { 248, 0xaaaa, 0xaaaa, 0xaaaa,  0, 0 },
-    { 249, 0x8888, 0x8888, 0x8888,  0, 0 },
-    { 250, 0x7777, 0x7777, 0x7777,  0, 0 },
-    { 251, 0x5555, 0x5555, 0x5555,  0, 0 },
-    { 252, 0x4444, 0x4444, 0x4444,  0, 0 },
-    { 253, 0x2222, 0x2222, 0x2222,  0, 0 },
-    { 254, 0x1111, 0x1111, 0x1111,  0, 0 },
-    { 255, 0xffff, 0xffff, 0xffff,  0, 0 }
-};
-#endif /* USE_NEW_CLUT */
-
-#endif /* _DARWIN_CLUT8_ */
diff --git a/hw/darwin/darwinEvents.c b/hw/darwin/darwinEvents.c
deleted file mode 100644
index 629fb2c..0000000
--- a/hw/darwin/darwinEvents.c
+++ /dev/null
@@ -1,461 +0,0 @@
-/*
-Darwin event queue and event handling
-
-Copyright 2007 Apple Inc.
-Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
-Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved.
-
-This file is based on mieq.c by Keith Packard,
-which contains the following copyright:
-Copyright 1990, 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.
- */
-
-#define NEED_EVENTS
-#include   <X11/X.h>
-#include   <X11/Xmd.h>
-#include   <X11/Xproto.h>
-#include   "misc.h"
-#include   "windowstr.h"
-#include   "pixmapstr.h"
-#include   "inputstr.h"
-#include   "mi.h"
-#include   "scrnintstr.h"
-#include   "mipointer.h"
-
-#include "darwin.h"
-#include "darwinKeyboard.h"
-
-#include <sys/types.h>
-#include <sys/uio.h>
-#include <unistd.h>
-#include <IOKit/hidsystem/IOLLEvent.h>
-
-/* Fake button press/release for scroll wheel move. */
-#define SCROLLWHEELUPFAKE   4
-#define SCROLLWHEELDOWNFAKE 5
-
-#define QUEUE_SIZE 256
-
-typedef struct _Event {
-    xEvent      event;
-    ScreenPtr   pScreen;
-} EventRec, *EventPtr;
-
-int input_check_zero, input_check_flag;
-
-static int old_flags = 0;  // last known modifier state
-
-typedef struct _EventQueue {
-    HWEventQueueType    head, tail; /* long for SetInputCheck */
-    CARD32      lastEventTime;      /* to avoid time running backwards */
-    Bool        lastMotion;
-    EventRec    events[QUEUE_SIZE]; /* static allocation for signals */
-    DevicePtr   pKbd, pPtr;         /* device pointer, to get funcs */
-    ScreenPtr   pEnqueueScreen;     /* screen events are being delivered to */
-    ScreenPtr   pDequeueScreen;     /* screen events are being dispatched to */
-} EventQueueRec, *EventQueuePtr;
-
-static EventQueueRec darwinEventQueue;
-xEvent *darwinEvents;
-
-/*
- * DarwinPressModifierMask
- *  Press or release the given modifier key, specified by its mask.
- */
-static void DarwinPressModifierMask(
-    int pressed,				    
-    int mask)       // one of NX_*MASK constants
-{
-    int key = DarwinModifierNXMaskToNXKey(mask);
-
-    if (key != -1) {
-        int keycode = DarwinModifierNXKeyToNXKeycode(key, 0);
-        if (keycode != 0)
-	  DarwinSendKeyboardEvents(pressed, keycode);
-    }
-}
-
-#ifdef NX_DEVICELCTLKEYMASK
-#define CONTROL_MASK(flags) (flags & (NX_DEVICELCTLKEYMASK|NX_DEVICERCTLKEYMASK))
-#else
-#define CONTROL_MASK(flags) (NX_CONTROLMASK)
-#endif /* NX_DEVICELCTLKEYMASK */
-
-#ifdef NX_DEVICELSHIFTKEYMASK
-#define SHIFT_MASK(flags) (flags & (NX_DEVICELSHIFTKEYMASK|NX_DEVICERSHIFTKEYMASK))
-#else
-#define SHIFT_MASK(flags) (NX_SHIFTMASK)
-#endif /* NX_DEVICELSHIFTKEYMASK */
-
-#ifdef NX_DEVICELCMDKEYMASK
-#define COMMAND_MASK(flags) (flags & (NX_DEVICELCMDKEYMASK|NX_DEVICERCMDKEYMASK))
-#else
-#define COMMAND_MASK(flags) (NX_COMMANDMASK)
-#endif /* NX_DEVICELCMDKEYMASK */
-
-#ifdef NX_DEVICELALTKEYMASK
-#define ALTERNATE_MASK(flags) (flags & (NX_DEVICELALTKEYMASK|NX_DEVICERALTKEYMASK))
-#else
-#define ALTERNATE_MASK(flags) (NX_ALTERNATEMASK)
-#endif /* NX_DEVICELALTKEYMASK */
-
-/*
- * DarwinUpdateModifiers
- *  Send events to update the modifier state.
- */
-static void DarwinUpdateModifiers(
-    int pressed,        // KeyPress or KeyRelease
-    int flags )         // modifier flags that have changed
-{
-    if (flags & NX_ALPHASHIFTMASK) {
-        DarwinPressModifierMask(pressed, NX_ALPHASHIFTMASK);
-    }
-    if (flags & NX_COMMANDMASK) {
-        DarwinPressModifierMask(pressed, COMMAND_MASK(flags));
-    }
-    if (flags & NX_CONTROLMASK) {
-        DarwinPressModifierMask(pressed, CONTROL_MASK(flags));
-    }
-    if (flags & NX_ALTERNATEMASK) {
-        DarwinPressModifierMask(pressed, ALTERNATE_MASK(flags));
-    }
-    if (flags & NX_SHIFTMASK) {
-        DarwinPressModifierMask(pressed, SHIFT_MASK(flags));
-    }
-    if (flags & NX_SECONDARYFNMASK) {
-        DarwinPressModifierMask(pressed, NX_SECONDARYFNMASK);
-    }
-}
-
-/*
- * DarwinReleaseModifiers
- * This hacky function releases all modifier keys.  It should be called when X11.app
- * is deactivated (kXDarwinDeactivate) to prevent modifiers from getting stuck if they
- * are held down during a "context" switch -- otherwise, we would miss the KeyUp.
- */
-static void DarwinReleaseModifiers(void) {
-	DarwinUpdateModifiers(KeyRelease, COMMAND_MASK(-1) | CONTROL_MASK(-1) | ALTERNATE_MASK(-1) | SHIFT_MASK(-1));
-}
-
-/*
- * DarwinSimulateMouseClick
- *  Send a mouse click to X when multiple mouse buttons are simulated
- *  with modifier-clicks, such as command-click for button 2. The dix
- *  layer is told that the previously pressed modifier key(s) are
- *  released, the simulated click event is sent. After the mouse button
- *  is released, the modifier keys are reverted to their actual state,
- *  which may or may not be pressed at that point. This is usually
- *  closest to what the user wants. Ie. the user typically wants to
- *  simulate a button 2 press instead of Command-button 2.
- */
-static void DarwinSimulateMouseClick(
-    int pointer_x,
-    int pointer_y,
-    int whichButton,    // mouse button to be pressed
-    int modifierMask)   // modifiers used for the fake click
-{
-    // first fool X into forgetting about the keys
-	// for some reason, it's not enough to tell X we released the Command key -- 
-	// it has to be the *left* Command key.
-	if (modifierMask & NX_COMMANDMASK) modifierMask |=NX_DEVICELCMDKEYMASK ;
-    DarwinUpdateModifiers(KeyRelease, modifierMask);
-
-    // push the mouse button
-    DarwinSendPointerEvents(ButtonPress, whichButton, pointer_x, pointer_y);
-    DarwinSendPointerEvents(ButtonRelease, whichButton, pointer_x, pointer_y);
-
-    // restore old modifiers
-    DarwinUpdateModifiers(KeyPress, modifierMask);
-}
-
-
-Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr) { 
-    darwinEvents = (xEvent *)malloc(sizeof(xEvent) * GetMaximumEventsNum());
-    mieqInit();
-    darwinEventQueue.head = darwinEventQueue.tail = 0;
-    darwinEventQueue.lastEventTime = GetTimeInMillis ();
-    darwinEventQueue.pKbd = pKbd;
-    darwinEventQueue.pPtr = pPtr;
-    darwinEventQueue.pEnqueueScreen = screenInfo.screens[0];
-    darwinEventQueue.pDequeueScreen = darwinEventQueue.pEnqueueScreen;
-    SetInputCheck(&input_check_zero, &input_check_flag);
-    return TRUE;
-}
-
-
-/*
- * DarwinEQEnqueue
- *  Must be thread safe with ProcessInputEvents.
- *    DarwinEQEnqueue    - called from event gathering thread
- *    ProcessInputEvents - called from X server thread
- *  DarwinEQEnqueue should never be called from more than one thread.
- * 
- * This should be deprecated in favor of miEQEnqueue -- BB
- */
-void DarwinEQEnqueue(const xEvent *e) {
-    HWEventQueueType oldtail, newtail;
-    char byte = 0;
-
-    oldtail = darwinEventQueue.tail;
-
-    // mieqEnqueue() collapses successive motion events into one event.
-    // This is difficult to do in a thread-safe way and rarely useful.
-
-    newtail = oldtail + 1;
-    if (newtail == QUEUE_SIZE) newtail = 0;
-    /* Toss events which come in late */
-    if (newtail == darwinEventQueue.head) return;
-
-    darwinEventQueue.events[oldtail].event = *e;
-
-    /*
-     * Make sure that event times don't go backwards - this
-     * is "unnecessary", but very useful
-     */
-    if (e->u.keyButtonPointer.time < darwinEventQueue.lastEventTime &&
-        darwinEventQueue.lastEventTime - e->u.keyButtonPointer.time < 10000)
-    {
-        darwinEventQueue.events[oldtail].event.u.keyButtonPointer.time =
-        darwinEventQueue.lastEventTime;
-    }
-    darwinEventQueue.events[oldtail].pScreen = darwinEventQueue.pEnqueueScreen;
-
-    // Update the tail after the event is prepared
-    darwinEventQueue.tail = newtail;
-
-    // Signal there is an event ready to handle
-    DarwinPokeEQ();
-}
-
-
-/*
- * DarwinEQPointerPost
- *  Post a pointer event. Used by the mipointer.c routines.
- */
-void DarwinEQPointerPost(xEvent *e) {
-    (*darwinEventQueue.pPtr->processInputProc)
-            (e, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
-}
-
-
-void DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX) {
-    darwinEventQueue.pEnqueueScreen = pScreen;
-    if (fromDIX)
-        darwinEventQueue.pDequeueScreen = pScreen;
-}
-
-
-/*
- * ProcessInputEvents
- *  Read and process events from the event queue until it is empty.
- */
-void ProcessInputEvents(void) {
-    EventRec *e;
-    int     x, y;
-    xEvent  xe;
-    static int  old_flags = 0;  // last known modifier state
-    // button number and modifier mask of currently pressed fake button
-    input_check_flag=0;
-
-    //    ErrorF("calling mieqProcessInputEvents\n");
-    mieqProcessInputEvents();
-
-    // Empty the signaling pipe
-    x = sizeof(xe);
-    while (x == sizeof(xe)) 
-        x = read(darwinEventReadFD, &xe, sizeof(xe));
-
-    while (darwinEventQueue.head != darwinEventQueue.tail)
-    {
-        if (screenIsSaved == SCREEN_SAVER_ON)
-            SaveScreens (SCREEN_SAVER_OFF, ScreenSaverReset);
-
-        e = &darwinEventQueue.events[darwinEventQueue.head];
-        xe = e->event;
-
-        // Shift from global screen coordinates to coordinates relative to
-        // the origin of the current screen.
-        xe.u.keyButtonPointer.rootX -= darwinMainScreenX +
-                dixScreenOrigins[miPointerCurrentScreen()->myNum].x;
-        xe.u.keyButtonPointer.rootY -= darwinMainScreenY +
-                dixScreenOrigins[miPointerCurrentScreen()->myNum].y;
-	
-	/*	ErrorF("old rootX = (%d,%d) darwinMainScreen = (%d,%d) dixScreenOrigins[%d]=(%d,%d)\n",
-	       xe.u.keyButtonPointer.rootX, xe.u.keyButtonPointer.rootY,
-	       darwinMainScreenX, darwinMainScreenY,
-	       miPointerCurrentScreen()->myNum,
-	       dixScreenOrigins[miPointerCurrentScreen()->myNum].x,
-	       dixScreenOrigins[miPointerCurrentScreen()->myNum].y); */
-
-	//Assumption - screen switching can only occur on motion events
-
-        if (e->pScreen != darwinEventQueue.pDequeueScreen)
-        {
-            darwinEventQueue.pDequeueScreen = e->pScreen;
-            x = xe.u.keyButtonPointer.rootX;
-            y = xe.u.keyButtonPointer.rootY;
-            if (darwinEventQueue.head == QUEUE_SIZE - 1)
-                darwinEventQueue.head = 0;
-            else
-                ++darwinEventQueue.head;
-            NewCurrentScreen (darwinEventQueue.pDequeueScreen, x, y);
-        }
-        else
-        {
-            if (darwinEventQueue.head == QUEUE_SIZE - 1)
-                darwinEventQueue.head = 0;
-            else
-                ++darwinEventQueue.head;
-            switch (xe.u.u.type) {
-            case KeyPress:
-            case KeyRelease:
-	      ErrorF("Unexpected Keyboard event in DarwinProcessInputEvents\n");
-	      break;
-
-            case ButtonPress:
-	      ErrorF("Unexpected ButtonPress event in DarwinProcessInputEvents\n");
-                break;
-
-            case ButtonRelease:
-	      ErrorF("Unexpected ButtonRelease event in DarwinProcessInputEvents\n");
-                break;
-
-            case MotionNotify:
-	      ErrorF("Unexpected ButtonRelease event in DarwinProcessInputEvents\n");
-                break;
-
-            case kXDarwinUpdateModifiers:
-	      ErrorF("Unexpected ButtonRelease event in DarwinProcessInputEvents\n");
-	      break;
-
-            case kXDarwinUpdateButtons:
-	      ErrorF("Unexpected XDarwinScrollWheel event in DarwinProcessInputEvents\n");
-	      break;
-
-            case kXDarwinScrollWheel: 
-	      ErrorF("Unexpected XDarwinScrollWheel event in DarwinProcessInputEvents\n");
-	      break;
-
-			case kXDarwinDeactivate:
-				DarwinReleaseModifiers();
-				// fall through
-            default:
-                // Check for mode specific event
-                DarwinModeProcessEvent(&xe);
-            }
-        }
-    }
-
-    //    miPointerUpdate();
-}
-
-/* Sends a null byte down darwinEventWriteFD, which will cause the
-   Dispatch() event loop to check out event queue */
-void DarwinPokeEQ(void) {
-  char nullbyte=0;
-  input_check_flag++;
-  //  <daniels> bushing: oh, i ... er ... christ.
-  write(darwinEventWriteFD, &nullbyte, 1);
-}
-
-void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int pointer_y) {
-  static int darwinFakeMouseButtonDown = 0;
-  static int darwinFakeMouseButtonMask = 0;
-  int i, num_events;
-  int valuators[2] = {pointer_x, pointer_y};
-  if (ev_type == ButtonPress && darwinFakeButtons && ev_button == 1) {
-    // Mimic multi-button mouse with modifier-clicks
-    // If both sets of modifiers are pressed,
-    // button 2 is clicked.
-    if ((old_flags & darwinFakeMouse2Mask) == darwinFakeMouse2Mask) {
-      DarwinSimulateMouseClick(pointer_x, pointer_y, 2, darwinFakeMouse2Mask);
-      darwinFakeMouseButtonDown = 2;
-      darwinFakeMouseButtonMask = darwinFakeMouse2Mask;
-    } else if ((old_flags & darwinFakeMouse3Mask) == darwinFakeMouse3Mask) {
-      DarwinSimulateMouseClick(pointer_x, pointer_y, 3, darwinFakeMouse3Mask);
-      darwinFakeMouseButtonDown = 3;
-      darwinFakeMouseButtonMask = darwinFakeMouse3Mask;
-    }
-  }
-  if (ev_type == ButtonRelease && darwinFakeButtons && darwinFakeMouseButtonDown) {
-    // If last mousedown was a fake click, don't check for
-    // mouse modifiers here. The user may have released the
-    // modifiers before the mouse button.
-    ev_button = darwinFakeMouseButtonDown;
-    darwinFakeMouseButtonDown = 0;
-    // Bring modifiers back up to date
-    DarwinUpdateModifiers(KeyPress, darwinFakeMouseButtonMask & old_flags);
-    darwinFakeMouseButtonMask = 0;
-  } 
-
-  num_events = GetPointerEvents(darwinEvents, darwinPointer, ev_type, ev_button, 
-				POINTER_ABSOLUTE, 0, 2, valuators);
-      
-  for(i=0; i<num_events; i++) mieqEnqueue (darwinPointer,&darwinEvents[i]);
-  DarwinPokeEQ();
-}
-
-void DarwinSendKeyboardEvents(int ev_type, int keycode) {
-  int i, num_events;
-  if (old_flags == 0 && darwinSyncKeymap && darwinKeymapFile == NULL) {
-    /* See if keymap has changed. */
-
-    static unsigned int last_seed;
-    unsigned int this_seed;
-
-    this_seed = DarwinModeSystemKeymapSeed();
-    if (this_seed != last_seed) {
-      last_seed = this_seed;
-      DarwinKeyboardReload(darwinKeyboard);
-    }
-  }
-
-  num_events = GetKeyboardEvents(darwinEvents, darwinKeyboard, ev_type, keycode + MIN_KEYCODE);
-  for(i=0; i<num_events; i++) mieqEnqueue(darwinKeyboard,&darwinEvents[i]);
-  DarwinPokeEQ();
-}
-
-/* Send the appropriate number of button 4 / 5 clicks to emulate scroll wheel */
-void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y) {
-  int i;
-  int ev_button = count > 0.0f ? 4 : 5;
-  int valuators[2] = {pointer_x, pointer_y};
-
-  for (count = fabs(count); count > 0.0; count = count - 1.0f) {
-    int num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonPress, ev_button, 
-				      POINTER_ABSOLUTE, 0, 2, valuators);
-    for(i=0; i<num_events; i++) mieqEnqueue(darwinPointer,&darwinEvents[i]);
-    num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonRelease, ev_button, 
-				      POINTER_ABSOLUTE, 0, 2, valuators);
-    for(i=0; i<num_events; i++) mieqEnqueue(darwinPointer,&darwinEvents[i]);
-  }
-  DarwinPokeEQ();
-}
-
-/* Send the appropriate KeyPress/KeyRelease events to GetKeyboardEvents to
-   reflect changing modifier flags (alt, control, meta, etc) */
-void DarwinUpdateModKeys(int flags) {
-  DarwinUpdateModifiers(KeyRelease, old_flags & ~flags);
-  DarwinUpdateModifiers(KeyPress, ~old_flags & flags);
-  old_flags = flags;
-}
diff --git a/hw/darwin/darwinKeyboard.c b/hw/darwin/darwinKeyboard.c
deleted file mode 100644
index 1c83cbc..0000000
--- a/hw/darwin/darwinKeyboard.c
+++ /dev/null
@@ -1,1009 +0,0 @@
-//=============================================================================
-//
-// Keyboard support for the Darwin X Server
-//
-// Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
-// Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved.
-// Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
-//
-// The code to parse the Darwin keymap is derived from dumpkeymap.c
-// by Eric Sunshine, which includes the following copyright:
-//
-// Copyright (C) 1999,2000 by Eric Sunshine <sunshine at sunshineco.com>
-// All rights reserved.
-//
-//-----------------------------------------------------------------------------
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-//   1. Redistributions of source code must retain the above copyright
-//      notice, this list of conditions and the following disclaimer.
-//   2. Redistributions in binary form must reproduce the above copyright
-//      notice, this list of conditions and the following disclaimer in the
-//      documentation and/or other materials provided with the distribution.
-//   3. The name of the author may not be used to endorse or promote products
-//      derived from this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
-// NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
-// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-//=============================================================================
-
-
-/*
-===========================================================================
-
- An X keyCode must be in the range XkbMinLegalKeyCode (8) to
- XkbMaxLegalKeyCode(255).
-
- The keyCodes we get from the kernel range from 0 to 127, so we need to
- offset the range before passing the keyCode to X.
-
- An X KeySym is an extended ascii code that is device independent.
-
- The modifier map is accessed by the keyCode, but the normal map is
- accessed by keyCode - MIN_KEYCODE.  Sigh.
-
-===========================================================================
-*/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-// Define this to get a diagnostic output to stderr which is helpful
-// in determining how the X server is interpreting the Darwin keymap.
-// #define DUMP_DARWIN_KEYMAP
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <IOKit/hidsystem/event_status_driver.h>
-#include <IOKit/hidsystem/ev_keymap.h>
-#include <architecture/byte_order.h>  // For the NXSwap*
-#include "darwin.h"
-#include "darwinKeyboard.h"
-
-#ifdef NDEBUG
-#undef NDEBUG
-#include <assert.h>
-#define NDEBUG 1
-#else
-#include <assert.h>
-#endif
-
-#define AltMask         Mod1Mask
-#define MetaMask        Mod2Mask
-#define FunctionMask    Mod3Mask
-
-#define UK(a)           NoSymbol    // unknown symbol
-
-static KeySym const next_to_x[256] = {
-	NoSymbol,	NoSymbol,	NoSymbol,	XK_KP_Enter,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_BackSpace,	XK_Tab,		XK_Linefeed,	NoSymbol,
-	NoSymbol,	XK_Return,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	XK_Escape,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_space,	XK_exclam,	XK_quotedbl,	XK_numbersign,
-	XK_dollar,	XK_percent,	XK_ampersand,	XK_apostrophe,
-	XK_parenleft,	XK_parenright,	XK_asterisk,	XK_plus,
-	XK_comma,	XK_minus,	XK_period,	XK_slash,
-	XK_0,		XK_1,		XK_2,		XK_3,
-	XK_4,		XK_5,		XK_6,		XK_7,
-	XK_8,		XK_9,		XK_colon,	XK_semicolon,
-	XK_less,	XK_equal,	XK_greater,	XK_question,
-	XK_at,		XK_A,		XK_B,		XK_C,
-	XK_D,		XK_E,		XK_F,		XK_G,
-	XK_H,		XK_I,		XK_J,		XK_K,
-	XK_L,		XK_M,		XK_N,		XK_O,
-	XK_P,		XK_Q,		XK_R,		XK_S,
-	XK_T,		XK_U,		XK_V,		XK_W,
-	XK_X,		XK_Y,		XK_Z,		XK_bracketleft,
-	XK_backslash,	XK_bracketright,XK_asciicircum,	XK_underscore,
-	XK_grave,	XK_a,		XK_b,		XK_c,
-	XK_d,		XK_e,		XK_f,		XK_g,
-	XK_h,		XK_i,		XK_j,		XK_k,
-	XK_l,		XK_m,		XK_n,		XK_o,
-	XK_p,		XK_q,		XK_r,		XK_s,
-	XK_t,		XK_u,		XK_v,		XK_w,
-	XK_x,		XK_y,		XK_z,		XK_braceleft,
-	XK_bar,		XK_braceright,	XK_asciitilde,	XK_BackSpace,
-// 128
-	NoSymbol,	XK_Agrave,	XK_Aacute,	XK_Acircumflex,
-	XK_Atilde,	XK_Adiaeresis,	XK_Aring,	XK_Ccedilla,
-	XK_Egrave,	XK_Eacute,	XK_Ecircumflex,	XK_Ediaeresis,
-	XK_Igrave,	XK_Iacute,	XK_Icircumflex,	XK_Idiaeresis,
-// 144
-	XK_ETH,		XK_Ntilde,	XK_Ograve,	XK_Oacute,
-	XK_Ocircumflex,	XK_Otilde,	XK_Odiaeresis,	XK_Ugrave,
-	XK_Uacute,	XK_Ucircumflex,	XK_Udiaeresis,	XK_Yacute,
-	XK_THORN,	XK_mu,		XK_multiply,	XK_division,
-// 160
-	XK_copyright,	XK_exclamdown,	XK_cent,	XK_sterling,
-	UK(fraction),	XK_yen,		UK(fhook),	XK_section,
-	XK_currency,	XK_rightsinglequotemark,
-					XK_leftdoublequotemark,
-							XK_guillemotleft,
-	XK_leftanglebracket,
-			XK_rightanglebracket,
-					UK(filigature),	UK(flligature),
-// 176
-	XK_registered,	XK_endash,	XK_dagger,	XK_doubledagger,
-	XK_periodcentered,XK_brokenbar,	XK_paragraph,	UK(bullet),
-	XK_singlelowquotemark,
-			XK_doublelowquotemark,
-					XK_rightdoublequotemark,
-							XK_guillemotright,
-	XK_ellipsis,	UK(permille),	XK_notsign,	XK_questiondown,
-// 192
-	XK_onesuperior,	XK_dead_grave,	XK_dead_acute,	XK_dead_circumflex,
-	XK_dead_tilde,	XK_dead_macron,	XK_dead_breve,	XK_dead_abovedot,
-	XK_dead_diaeresis,
-			XK_twosuperior,	XK_dead_abovering,
-							XK_dead_cedilla,
-	XK_threesuperior,
-			XK_dead_doubleacute,
-					XK_dead_ogonek,	XK_dead_caron,
-// 208
-	XK_emdash,	XK_plusminus,	XK_onequarter,	XK_onehalf,
-	XK_threequarters,
-			XK_agrave,	XK_aacute,	XK_acircumflex,
-	XK_atilde,	XK_adiaeresis,	XK_aring,	XK_ccedilla,
-	XK_egrave,	XK_eacute,	XK_ecircumflex,	XK_ediaeresis,
-// 224
-	XK_igrave,	XK_AE,		XK_iacute,	XK_ordfeminine,
-	XK_icircumflex,	XK_idiaeresis,	XK_eth,		XK_ntilde,
-	XK_Lstroke,	XK_Ooblique,	XK_OE,		XK_masculine,
-	XK_ograve,	XK_oacute,	XK_ocircumflex, XK_otilde,
-// 240
-	XK_odiaeresis,	XK_ae,		XK_ugrave,	XK_uacute,
-	XK_ucircumflex,	XK_idotless,	XK_udiaeresis,	XK_ygrave,
-	XK_lstroke,	XK_ooblique,	XK_oe,		XK_ssharp,
-	XK_thorn,	XK_ydiaeresis,	NoSymbol,	NoSymbol,
-  };
-
-#define MIN_SYMBOL      0xAC
-static KeySym const symbol_to_x[] = {
-    XK_Left,        XK_Up,          XK_Right,      XK_Down
-  };
-static int const NUM_SYMBOL = sizeof(symbol_to_x) / sizeof(symbol_to_x[0]);
-
-#define MIN_FUNCKEY     0x20
-static KeySym const funckey_to_x[] = {
-    XK_F1,          XK_F2,          XK_F3,          XK_F4,
-    XK_F5,          XK_F6,          XK_F7,          XK_F8,
-    XK_F9,          XK_F10,         XK_F11,         XK_F12,
-    XK_Insert,      XK_Delete,      XK_Home,        XK_End,
-    XK_Page_Up,     XK_Page_Down,   XK_F13,         XK_F14,
-    XK_F15
-  };
-static int const NUM_FUNCKEY = sizeof(funckey_to_x) / sizeof(funckey_to_x[0]);
-
-typedef struct {
-    KeySym      normalSym;
-    KeySym      keypadSym;
-} darwinKeyPad_t;
-
-static darwinKeyPad_t const normal_to_keypad[] = {
-    { XK_0,         XK_KP_0 },
-    { XK_1,         XK_KP_1 },
-    { XK_2,         XK_KP_2 },
-    { XK_3,         XK_KP_3 },
-    { XK_4,         XK_KP_4 },
-    { XK_5,         XK_KP_5 },
-    { XK_6,         XK_KP_6 },
-    { XK_7,         XK_KP_7 },
-    { XK_8,         XK_KP_8 },
-    { XK_9,         XK_KP_9 },
-    { XK_equal,     XK_KP_Equal },
-    { XK_asterisk,  XK_KP_Multiply },
-    { XK_plus,      XK_KP_Add },
-    { XK_comma,     XK_KP_Separator },
-    { XK_minus,     XK_KP_Subtract },
-    { XK_period,    XK_KP_Decimal },
-    { XK_slash,     XK_KP_Divide }
-};
-static int const NUM_KEYPAD = sizeof(normal_to_keypad) / sizeof(normal_to_keypad[0]);
-
-static void DarwinChangeKeyboardControl( DeviceIntPtr device, KeybdCtrl *ctrl )
-{
-    // keyclick, bell volume / pitch, autorepead, LED's
-}
-
-darwinKeyboardInfo keyInfo;
-static FILE *fref = NULL;
-static char *inBuffer = NULL;
-
-//-----------------------------------------------------------------------------
-// Data Stream Object
-//      Can be configured to treat embedded "numbers" as being composed of
-//      either 1, 2, or 4 bytes, apiece.
-//-----------------------------------------------------------------------------
-typedef struct _DataStream {
-    unsigned char const *data;
-    unsigned char const *data_end;
-    short number_size;  // Size in bytes of a "number" in the stream.
-} DataStream;
-
-static DataStream* new_data_stream(unsigned char const* data, int size) {
-    DataStream* s = (DataStream*)xalloc( sizeof(DataStream) );
-    if(s) {
-        s->data = data;
-        s->data_end = data + size;
-        s->number_size = 1; // Default to byte-sized numbers.
-    }
-    return s;
-}
-
-static void destroy_data_stream(DataStream* s) {
-    xfree(s);
-}
-
-static unsigned char get_byte(DataStream* s) {
-    assert(s->data + 1 <= s->data_end);
-    return *s->data++;
-}
-
-static short get_word(DataStream* s) {
-    short hi, lo;
-    assert(s->data + 2 <= s->data_end);
-    hi = *s->data++;
-    lo = *s->data++;
-    return ((hi << 8) | lo);
-}
-
-static int get_dword(DataStream* s) {
-    int b1, b2, b3, b4;
-    assert(s->data + 4 <= s->data_end);
-    b4 = *s->data++;
-    b3 = *s->data++;
-    b2 = *s->data++;
-    b1 = *s->data++;
-    return ((b4 << 24) | (b3 << 16) | (b2 << 8) | b1);
-}
-
-static int get_number(DataStream* s) {
-    switch (s->number_size) {
-        case 4:  return get_dword(s);
-        case 2:  return get_word(s);
-        default: return get_byte(s);
-    }
-}
-
-//-----------------------------------------------------------------------------
-// Utility functions to help parse Darwin keymap
-//-----------------------------------------------------------------------------
-
-/*
- * bits_set
- *      Calculate number of bits set in the modifier mask.
- */
-static short bits_set(short mask) {
-    short n = 0;
-
-    for ( ; mask != 0; mask >>= 1)
-        if ((mask & 0x01) != 0)
-            n++;
-    return n;
-}
-
-/*
- * parse_next_char_code
- *      Read the next character code from the Darwin keymapping
- *      and write it to the X keymap.
- */
-static void parse_next_char_code(DataStream *s, KeySym *k) {
-    const short charSet = get_number(s);
-    const short charCode = get_number(s);
-
-    if (charSet == 0) {                 // ascii character
-        if (charCode >= 0 && charCode < 256)
-            *k = next_to_x[charCode];
-    } else if (charSet == 0x01) {       // symbol character
-        if (charCode >= MIN_SYMBOL &&
-            charCode <= MIN_SYMBOL + NUM_SYMBOL)
-            *k = symbol_to_x[charCode - MIN_SYMBOL];
-    } else if (charSet == 0xFE) {       // function key
-        if (charCode >= MIN_FUNCKEY &&
-            charCode <= MIN_FUNCKEY + NUM_FUNCKEY)
-            *k = funckey_to_x[charCode - MIN_FUNCKEY];
-    }
-}
-
-
-/*
- * DarwinReadKeymapFile
- *      Read the appropriate keymapping from a keymapping file.
- */
-Bool DarwinReadKeymapFile(NXKeyMapping *keyMap) {
-    struct stat         st;
-    NXEventSystemDevice info[20];
-    int                 interface = 0, handler_id = 0;
-    int                 map_interface, map_handler_id, map_size = 0;
-    unsigned int        i, size;
-    int                 *bufferEnd;
-    union km_tag {
-        int             *intP;
-        char            *charP;
-    } km;
-
-    fref = fopen( darwinKeymapFile, "rb" );
-    if (fref == NULL) {
-        ErrorF("Unable to open keymapping file '%s' (errno %d).\n",
-               darwinKeymapFile, errno);
-        return FALSE;
-    }
-    if (fstat(fileno(fref), &st) == -1) {
-        ErrorF("Could not stat keymapping file '%s' (errno %d).\n",
-               darwinKeymapFile, errno);
-        return FALSE;
-    }
-
-    // check to make sure we don't crash later
-    if (st.st_size <= 16*sizeof(int)) {
-        ErrorF("Keymapping file '%s' is invalid (too small).\n",
-               darwinKeymapFile);
-        return FALSE;
-    }
-
-    inBuffer = (char*) xalloc( st.st_size );
-    bufferEnd = (int *) (inBuffer + st.st_size);
-    if (fread(inBuffer, st.st_size, 1, fref) != 1) {
-        ErrorF("Could not read %qd bytes from keymapping file '%s' (errno %d).\n",
-               st.st_size, darwinKeymapFile, errno);
-        return FALSE;
-    }
-
-    if (strncmp( inBuffer, "KYM1", 4 ) == 0) {
-        // Magic number OK.
-    } else if (strncmp( inBuffer, "KYMP", 4 ) == 0) {
-        ErrorF("Keymapping file '%s' is intended for use with the original NeXT keyboards and cannot be used by XDarwin.\n", darwinKeymapFile);
-        return FALSE;
-    } else {
-        ErrorF("Keymapping file '%s' has a bad magic number and cannot be used by XDarwin.\n", darwinKeymapFile);
-        return FALSE;
-    }
-
-    // find the keyboard interface and handler id
-    size = sizeof( info ) / sizeof( int );
-    if (!NXEventSystemInfo( darwinParamConnect, NX_EVS_DEVICE_INFO,
-                            (NXEventSystemInfoType) info, &size )) {
-        ErrorF("Error reading event status driver info.\n");
-        return FALSE;
-    }
-
-    size = size * sizeof( int ) / sizeof( info[0] );
-    for( i = 0; i < size; i++) {
-        if (info[i].dev_type == NX_EVS_DEVICE_TYPE_KEYBOARD) {
-            Bool hasInterface = FALSE;
-            Bool hasMatch = FALSE;
-
-            interface = info[i].interface;
-            handler_id = info[i].id;
-
-            // Find an appropriate keymapping:
-            // The first time we try to match both interface and handler_id.
-            // If we can't match both, we take the first match for interface.
-
-            do {
-                km.charP = inBuffer;
-                km.intP++;
-                while (km.intP+3 < bufferEnd) {
-                    map_interface = NXSwapBigIntToHost(*(km.intP++));
-                    map_handler_id = NXSwapBigIntToHost(*(km.intP++));
-                    map_size = NXSwapBigIntToHost(*(km.intP++));
-                    if (map_interface == interface) {
-                        if (map_handler_id == handler_id || hasInterface) {
-                            hasMatch = TRUE;
-                            break;
-                        } else {
-                            hasInterface = TRUE;
-                        }
-                    }
-                    km.charP += map_size;
-                }
-            } while (hasInterface && !hasMatch);
-
-            if (hasMatch) {
-                // fill in NXKeyMapping structure
-                keyMap->size = map_size;
-                keyMap->mapping = (char*) xalloc(map_size);
-                memcpy(keyMap->mapping, km.charP, map_size);
-                return TRUE;
-            }
-        } // if dev_id == keyboard device
-    } // foreach info struct
-
-    // The keymapping file didn't match any of the info structs
-    // returned by NXEventSystemInfo.
-    ErrorF("Keymapping file '%s' did not contain appropriate keyboard interface.\n", darwinKeymapFile);
-    return FALSE;
-}
-
-
-/*
- * DarwinParseNXKeyMapping
- */
-Bool DarwinParseNXKeyMapping(darwinKeyboardInfo  *info) {
-    KeySym              *k;
-    int                 i;
-    short               numMods, numKeys, numPadKeys = 0;
-    Bool                haveKeymap = FALSE;
-    NXKeyMapping        keyMap;
-    DataStream          *keyMapStream;
-    unsigned char const *numPadStart = 0;
-
-    if (darwinKeymapFile) {
-        haveKeymap = DarwinReadKeymapFile(&keyMap);
-        if (fref)
-            fclose(fref);
-        if (inBuffer)
-            xfree(inBuffer);
-        if (!haveKeymap) {
-            ErrorF("Reverting to kernel keymapping.\n");
-        }
-    }
-
-    if (!haveKeymap) {
-        // get the Darwin keyboard map
-        keyMap.size = NXKeyMappingLength( darwinParamConnect );
-        keyMap.mapping = (char*) xalloc( keyMap.size );
-        if (!NXGetKeyMapping( darwinParamConnect, &keyMap )) {
-            return FALSE;
-        }
-    }
-
-    keyMapStream = new_data_stream( (unsigned char const*)keyMap.mapping,
-                                    keyMap.size );
-
-    // check the type of map
-    if (get_word(keyMapStream)) {
-        keyMapStream->number_size = 2;
-        ErrorF("Current 16-bit keymapping may not be interpreted correctly.\n");
-    }
-
-    // Insert X modifier KeySyms into the keyboard map.
-    numMods = get_number(keyMapStream);
-    while (numMods-- > 0) {
-        int             left = 1;               // first keycode is left
-        short const     charCode = get_number(keyMapStream);
-        short           numKeyCodes = get_number(keyMapStream);
-
-        // This is just a marker, not a real modifier.
-        // Store numeric keypad keys for later.
-        if (charCode == NX_MODIFIERKEY_NUMERICPAD) {
-            numPadStart = keyMapStream->data;
-            numPadKeys = numKeyCodes;
-        }
-
-        while (numKeyCodes-- > 0) {
-            const short keyCode = get_number(keyMapStream);
-            if (charCode != NX_MODIFIERKEY_NUMERICPAD) {
-                switch (charCode) {
-                    case NX_MODIFIERKEY_ALPHALOCK:
-                        info->keyMap[keyCode * GLYPHS_PER_KEY] = XK_Caps_Lock;
-                        break;
-                    case NX_MODIFIERKEY_SHIFT:
-                        info->keyMap[keyCode * GLYPHS_PER_KEY] =
-                                (left ? XK_Shift_L : XK_Shift_R);
-                        break;
-                    case NX_MODIFIERKEY_CONTROL:
-                        info->keyMap[keyCode * GLYPHS_PER_KEY] =
-                                (left ? XK_Control_L : XK_Control_R);
-                        break;
-                    case NX_MODIFIERKEY_ALTERNATE:
-                        info->keyMap[keyCode * GLYPHS_PER_KEY] = XK_Mode_switch;
-                                // (left ? XK_Alt_L : XK_Alt_R);
-                        break;
-                    case NX_MODIFIERKEY_COMMAND:
-                        info->keyMap[keyCode * GLYPHS_PER_KEY] =
-                                (left ? XK_Meta_L : XK_Meta_R);
-                        break;
-                    case NX_MODIFIERKEY_SECONDARYFN:
-                        info->keyMap[keyCode * GLYPHS_PER_KEY] =
-                                (left ? XK_Control_L : XK_Control_R);
-                        break;
-                    case NX_MODIFIERKEY_HELP:
-                        // Help is not an X11 modifier; treat as normal key
-                        info->keyMap[keyCode * GLYPHS_PER_KEY] = XK_Help;
-                        break;
-                }
-            }
-            left = 0;
-        }
-    }
-
-    // Convert the Darwin keyboard mapping to an X keyboard map.
-    // A key can have a different character code for each combination of
-    // modifiers. We currently ignore all modifier combinations except
-    // those with Shift, AlphaLock, and Alt.
-    numKeys = get_number(keyMapStream);
-    for (i = 0, k = info->keyMap; i < numKeys; i++, k += GLYPHS_PER_KEY) {
-        short const     charGenMask = get_number(keyMapStream);
-        if (charGenMask != 0xFF) {              // is key bound?
-            short       numKeyCodes = 1 << bits_set(charGenMask);
-
-            // Record unmodified case
-            parse_next_char_code( keyMapStream, k );
-            numKeyCodes--;
-
-            // If AlphaLock and Shift modifiers produce different codes,
-            // we record the Shift case since X handles AlphaLock.
-            if (charGenMask & 0x01) {       // AlphaLock
-                parse_next_char_code( keyMapStream, k+1 );
-                numKeyCodes--;
-            }
-
-            if (charGenMask & 0x02) {       // Shift
-                parse_next_char_code( keyMapStream, k+1 );
-                numKeyCodes--;
-
-                if (charGenMask & 0x01) {   // Shift-AlphaLock
-                    get_number(keyMapStream); get_number(keyMapStream);
-                    numKeyCodes--;
-                }
-            }
-
-            // Skip the Control cases
-            if (charGenMask & 0x04) {       // Control
-                get_number(keyMapStream); get_number(keyMapStream);
-                numKeyCodes--;
-
-                if (charGenMask & 0x01) {   // Control-AlphaLock
-                    get_number(keyMapStream); get_number(keyMapStream);
-                    numKeyCodes--;
-                }
-
-                if (charGenMask & 0x02) {   // Control-Shift
-                    get_number(keyMapStream); get_number(keyMapStream);
-                    numKeyCodes--;
-
-                    if (charGenMask & 0x01) {   // Shift-Control-AlphaLock
-                        get_number(keyMapStream); get_number(keyMapStream);
-                        numKeyCodes--;
-                    }
-                }
-            }
-
-            // Process Alt cases
-            if (charGenMask & 0x08) {       // Alt
-                parse_next_char_code( keyMapStream, k+2 );
-                numKeyCodes--;
-
-                if (charGenMask & 0x01) {   // Alt-AlphaLock
-                    parse_next_char_code( keyMapStream, k+3 );
-                    numKeyCodes--;
-                }
-
-                if (charGenMask & 0x02) {   // Alt-Shift
-                    parse_next_char_code( keyMapStream, k+3 );
-                    numKeyCodes--;
-
-                    if (charGenMask & 0x01) {   // Alt-Shift-AlphaLock
-                        get_number(keyMapStream); get_number(keyMapStream);
-                        numKeyCodes--;
-                    }
-                }
-            }
-
-            while (numKeyCodes-- > 0) {
-                get_number(keyMapStream); get_number(keyMapStream);
-            }
-
-            if (k[3] == k[2]) k[3] = NoSymbol;
-            if (k[2] == k[1]) k[2] = NoSymbol;
-            if (k[1] == k[0]) k[1] = NoSymbol;
-            if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol;
-        }
-    }
-
-    // Now we have to go back through the list of keycodes that are on the
-    // numeric keypad and update the X keymap.
-    keyMapStream->data = numPadStart;
-    while(numPadKeys-- > 0) {
-        const short keyCode = get_number(keyMapStream);
-        k = &info->keyMap[keyCode * GLYPHS_PER_KEY];
-        for (i = 0; i < NUM_KEYPAD; i++) {
-            if (*k == normal_to_keypad[i].normalSym) {
-                k[0] = normal_to_keypad[i].keypadSym;
-                break;
-            }
-        }
-    }
-
-    // free Darwin keyboard map
-    destroy_data_stream( keyMapStream );
-    xfree( keyMap.mapping );
-
-    return TRUE;
-}
-
-/*
- * DarwinBuildModifierMaps
- *      Use the keyMap field of keyboard info structure to populate
- *      the modMap and modifierKeycodes fields.
- */
-static void DarwinBuildModifierMaps(darwinKeyboardInfo *info) {
-    int i;
-    KeySym *k;
-
-    memset(info->modMap, NoSymbol, sizeof(info->modMap));
-    memset(info->modifierKeycodes, 0, sizeof(info->modifierKeycodes));
-
-    for (i = 0; i < NUM_KEYCODES; i++) {
-        k = info->keyMap + i * GLYPHS_PER_KEY;
-
-        switch (*k) {
-            case XK_Shift_L:
-                info->modifierKeycodes[NX_MODIFIERKEY_SHIFT][0] = i;
-                info->modMap[MIN_KEYCODE + i] = ShiftMask;
-                break;
-
-            case XK_Shift_R:
-#ifdef NX_MODIFIERKEY_RSHIFT
-                info->modifierKeycodes[NX_MODIFIERKEY_RSHIFT][0] = i;
-#else
-                info->modifierKeycodes[NX_MODIFIERKEY_SHIFT][0] = i;
-#endif
-                info->modMap[MIN_KEYCODE + i] = ShiftMask;
-                break;
-
-            case XK_Control_L:
-                info->modifierKeycodes[NX_MODIFIERKEY_CONTROL][0] = i;
-                info->modMap[MIN_KEYCODE + i] = ControlMask;
-                break;
-
-            case XK_Control_R:
-#ifdef NX_MODIFIERKEY_RCONTROL
-                info->modifierKeycodes[NX_MODIFIERKEY_RCONTROL][0] = i;
-#else
-                info->modifierKeycodes[NX_MODIFIERKEY_CONTROL][0] = i;
-#endif
-                info->modMap[MIN_KEYCODE + i] = ControlMask;
-                break;
-
-            case XK_Caps_Lock:
-                info->modifierKeycodes[NX_MODIFIERKEY_ALPHALOCK][0] = i;
-                info->modMap[MIN_KEYCODE + i] = LockMask;
-                break;
-
-            case XK_Alt_L:
-                info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
-                info->modMap[MIN_KEYCODE + i] = Mod1Mask;
-                break;
-
-            case XK_Alt_R:
-#ifdef NX_MODIFIERKEY_RALTERNATE
-                info->modifierKeycodes[NX_MODIFIERKEY_RALTERNATE][0] = i;
-#else
-                info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
-#endif
-                info->modMap[MIN_KEYCODE + i] = Mod1Mask;
-                break;
-
-            case XK_Mode_switch:
-                // Yes, this is ugly.  This needs to be cleaned up when we integrate quartzKeyboard with this code and refactor.
-#ifdef NX_MODIFIERKEY_RALTERNATE
-                info->modifierKeycodes[NX_MODIFIERKEY_RALTERNATE][0] = i;
-#endif
-                info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
-                info->modMap[MIN_KEYCODE + i] = Mod1Mask;
-                break;
-
-            case XK_Meta_L:
-                info->modifierKeycodes[NX_MODIFIERKEY_COMMAND][0] = i;
-                info->modMap[MIN_KEYCODE + i] = Mod2Mask;
-                break;
-
-            case XK_Meta_R:
-#ifdef NX_MODIFIERKEY_RCOMMAND
-                info->modifierKeycodes[NX_MODIFIERKEY_RCOMMAND][0] = i;
-#else
-                info->modifierKeycodes[NX_MODIFIERKEY_COMMAND][0] = i;
-#endif
-                info->modMap[MIN_KEYCODE + i] = Mod2Mask;
-                break;
-
-            case XK_Num_Lock:
-                info->modMap[MIN_KEYCODE + i] = Mod3Mask;
-                break;
-        }
-    }
-}
-
-/*
- * DarwinLoadKeyboardMapping
- *  Load the keyboard map from a file or system and convert
- *  it to an equivalent X keyboard map and modifier map.
- */
-static void DarwinLoadKeyboardMapping(KeySymsRec *keySyms) {
-    memset(keyInfo.keyMap, 0, sizeof(keyInfo.keyMap));
-
-    /* TODO: Clean this up
-     * DarwinModeReadSystemKeymap is in quartz/quartzKeyboard.c
-     * DarwinParseNXKeyMapping is here
-     */
-    if (!DarwinParseNXKeyMapping(&keyInfo)) {
-        DEBUG_LOG("DarwinParseNXKeyMapping returned 0... running DarwinModeReadSystemKeymap().\n");
-        if (!DarwinModeReadSystemKeymap(&keyInfo)) {
-            FatalError("Could not build a valid keymap.");
-        }
-    }
-
-    DarwinBuildModifierMaps(&keyInfo);
-
-#ifdef DUMP_DARWIN_KEYMAP
-    int i;
-    KeySym *k;
-    DEBUG_LOG("Darwin -> X converted keyboard map\n");
-    for (i = 0, k = keyInfo.keyMap; i < NX_NUMKEYCODES;
-         i++, k += GLYPHS_PER_KEY)
-    {
-        int j;
-        for (j = 0; j < GLYPHS_PER_KEY; j++) {
-            if (k[j] == NoSymbol) {
-                DEBUG_LOG("0x%02x:\tNoSym\n", i);
-            } else {
-                DEBUG_LOG("0x%02x:\t0x%lx\n", i, k[j]);
-            }
-        }
-    }
-#endif
-
-    keySyms->map        = keyInfo.keyMap;
-    keySyms->mapWidth   = GLYPHS_PER_KEY;
-    keySyms->minKeyCode = MIN_KEYCODE;
-    keySyms->maxKeyCode = MAX_KEYCODE;
-}
-
-
-/*
- * DarwinKeyboardInit
- *      Get the Darwin keyboard map and compute an equivalent
- *      X keyboard map and modifier map. Set the new keyboard
- *      device structure.
- */
-void DarwinKeyboardInit(DeviceIntPtr pDev) {
-    KeySymsRec          keySyms;
-
-    // Open a shared connection to the HID System.
-    // Note that the Event Status Driver is really just a wrapper
-    // for a kIOHIDParamConnectType connection.
-    assert( darwinParamConnect = NXOpenEventStatus() );
-
-    DarwinLoadKeyboardMapping(&keySyms);
-    //    DarwinKeyboardReload(pDev);
-    /* Initialize the seed, so we don't reload the keymap unnecessarily
-       (and possibly overwrite xinitrc changes) */
-    DarwinModeSystemKeymapSeed();
-
-    assert( InitKeyboardDeviceStruct( (DevicePtr)pDev, &keySyms,
-                                      keyInfo.modMap, DarwinModeBell,
-                                      DarwinChangeKeyboardControl ));
-}
-
-
-/* Borrowed from dix/devices.c */
-static Bool InitModMap(register KeyClassPtr keyc) {
-    int i, j;
-    CARD8 keysPerModifier[8];
-    CARD8 mask;
-
-    //    darwinKeyc = keyc;
-    if (keyc->modifierKeyMap != NULL)
-        xfree (keyc->modifierKeyMap);
-
-    keyc->maxKeysPerModifier = 0;
-    for (i = 0; i < 8; i++)
-        keysPerModifier[i] = 0;
-    for (i = 8; i < MAP_LENGTH; i++)
-    {
-        for (j = 0, mask = 1; j < 8; j++, mask <<= 1)
-        {
-            if (mask & keyc->modifierMap[i])
-            {
-                if (++keysPerModifier[j] > keyc->maxKeysPerModifier)
-                    keyc->maxKeysPerModifier = keysPerModifier[j];
-            }
-        }
-    }
-    keyc->modifierKeyMap = (KeyCode *)xalloc(8*keyc->maxKeysPerModifier);
-    if (!keyc->modifierKeyMap && keyc->maxKeysPerModifier)
-        return (FALSE);
-    bzero((char *)keyc->modifierKeyMap, 8*(int)keyc->maxKeysPerModifier);
-    for (i = 0; i < 8; i++)
-        keysPerModifier[i] = 0;
-    for (i = 8; i < MAP_LENGTH; i++)
-    {
-        for (j = 0, mask = 1; j < 8; j++, mask <<= 1)
-        {
-            if (mask & keyc->modifierMap[i])
-            {
-                keyc->modifierKeyMap[(j*keyc->maxKeysPerModifier) +
-                         keysPerModifier[j]] = i;
-                keysPerModifier[j]++;
-            }
-        }
-    }
-    return TRUE;
-}
-
-
-void DarwinKeyboardReload(DeviceIntPtr pDev) {
-    KeySymsRec keySyms;
-
-    DarwinLoadKeyboardMapping(&keySyms);
-
-    if (SetKeySymsMap(&pDev->key->curKeySyms, &keySyms)) {
-        /* now try to update modifiers. */
-
-        memmove(pDev->key->modifierMap, keyInfo.modMap, MAP_LENGTH);
-        InitModMap(pDev->key);
-    } else DEBUG_LOG("SetKeySymsMap=0\n");
-
-    SendMappingNotify(MappingKeyboard, MIN_KEYCODE, NUM_KEYCODES, 0);
-    SendMappingNotify(MappingModifier, 0, 0, 0);
-}
-
-
-//-----------------------------------------------------------------------------
-// Modifier translation functions
-//
-// There are three different ways to specify a Mac modifier key:
-// keycode - specifies hardware key, read from keymapping
-// key     - NX_MODIFIERKEY_*, really an index
-// mask    - NX_*MASK, mask for modifier flags in event record
-// Left and right side have different keycodes but the same key and mask.
-//-----------------------------------------------------------------------------
-
-/*
- * DarwinModifierNXKeyToNXKeycode
- *      Return the keycode for an NX_MODIFIERKEY_* modifier.
- *      side = 0 for left or 1 for right.
- *      Returns 0 if key+side is not a known modifier.
- */
-int DarwinModifierNXKeyToNXKeycode(int key, int side) {
-    return keyInfo.modifierKeycodes[key][side];
-}
-
-/*
- * DarwinModifierNXKeycodeToNXKey
- *      Returns -1 if keycode+side is not a modifier key
- *      outSide may be NULL, else it gets 0 for left and 1 for right.
- */
-int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide) {
-    int key, side;
-
-    keycode += MIN_KEYCODE;
-    // search modifierKeycodes for this keycode+side
-    for (key = 0; key < NX_NUMMODIFIERS; key++) {
-        for (side = 0; side <= 1; side++) {
-            if (keyInfo.modifierKeycodes[key][side] == keycode) break;
-        }
-    }
-    if (key == NX_NUMMODIFIERS) return -1;
-    if (outSide) *outSide = side;
-    return key;
-}
-
-/*
- * DarwinModifierNXMaskToNXKey
- *      Returns -1 if mask is not a known modifier mask.
- */
-int DarwinModifierNXMaskToNXKey(int mask) {
-    switch (mask) {
-        case NX_ALPHASHIFTMASK:       return NX_MODIFIERKEY_ALPHALOCK;
-        case NX_SHIFTMASK:            return NX_MODIFIERKEY_SHIFT;
-#ifdef NX_DEVICELSHIFTKEYMASK
-        case NX_DEVICELSHIFTKEYMASK:  return NX_MODIFIERKEY_SHIFT;
-        case NX_DEVICERSHIFTKEYMASK:  return NX_MODIFIERKEY_RSHIFT;
-#endif
-        case NX_CONTROLMASK:          return NX_MODIFIERKEY_CONTROL;
-#ifdef NX_DEVICELCTLKEYMASK
-        case NX_DEVICELCTLKEYMASK:    return NX_MODIFIERKEY_CONTROL;
-        case NX_DEVICERCTLKEYMASK:    return NX_MODIFIERKEY_RCONTROL;
-#endif
-        case NX_ALTERNATEMASK:        return NX_MODIFIERKEY_ALTERNATE;
-#ifdef NX_DEVICELALTKEYMASK
-        case NX_DEVICELALTKEYMASK:    return NX_MODIFIERKEY_ALTERNATE;
-        case NX_DEVICERALTKEYMASK:    return NX_MODIFIERKEY_RALTERNATE;
-#endif
-        case NX_COMMANDMASK:          return NX_MODIFIERKEY_COMMAND;
-#ifdef NX_DEVICELCMDKEYMASK
-        case NX_DEVICELCMDKEYMASK:    return NX_MODIFIERKEY_COMMAND;
-        case NX_DEVICERCMDKEYMASK:    return NX_MODIFIERKEY_RCOMMAND;
-#endif
-        case NX_NUMERICPADMASK:       return NX_MODIFIERKEY_NUMERICPAD;
-        case NX_HELPMASK:             return NX_MODIFIERKEY_HELP;
-        case NX_SECONDARYFNMASK:      return NX_MODIFIERKEY_SECONDARYFN;
-    }
-    return -1;
-}
-
-const char *DarwinModifierNXMaskTostring(int mask) {
-    switch (mask) {
-        case NX_ALPHASHIFTMASK:      return "NX_ALPHASHIFTMASK";
-        case NX_SHIFTMASK:           return "NX_SHIFTMASK";
-        case NX_DEVICELSHIFTKEYMASK: return "NX_DEVICELSHIFTKEYMASK";
-        case NX_DEVICERSHIFTKEYMASK: return "NX_DEVICERSHIFTKEYMASK";
-        case NX_CONTROLMASK:         return "NX_CONTROLMASK";
-        case NX_DEVICELCTLKEYMASK:   return "NX_DEVICELCTLKEYMASK";
-        case NX_DEVICERCTLKEYMASK:   return "NX_DEVICERCTLKEYMASK";
-        case NX_ALTERNATEMASK:       return "NX_ALTERNATEMASK";
-        case NX_DEVICELALTKEYMASK:   return "NX_DEVICELALTKEYMASK";
-        case NX_DEVICERALTKEYMASK:   return "NX_DEVICERALTKEYMASK";
-        case NX_COMMANDMASK:         return "NX_COMMANDMASK";
-        case NX_DEVICELCMDKEYMASK:   return "NX_DEVICELCMDKEYMASK";
-        case NX_DEVICERCMDKEYMASK:   return "NX_DEVICERCMDKEYMASK";
-        case NX_NUMERICPADMASK:      return "NX_NUMERICPADMASK";
-        case NX_HELPMASK:            return "NX_HELPMASK";
-        case NX_SECONDARYFNMASK:     return "NX_SECONDARYFNMASK";
-    }
-    return "unknown mask";
-}
-
-/*
- * DarwinModifierNXKeyToNXMask
- *      Returns 0 if key is not a known modifier key.
- */
-int DarwinModifierNXKeyToNXMask(int key) {
-    switch (key) {
-        case NX_MODIFIERKEY_ALPHALOCK:   return NX_ALPHASHIFTMASK;
-        case NX_MODIFIERKEY_SHIFT:       return NX_SHIFTMASK;
-#ifdef NX_MODIFIERKEY_RSHIFT
-        case NX_MODIFIERKEY_RSHIFT:      return NX_SHIFTMASK;
-#endif
-        case NX_MODIFIERKEY_CONTROL:     return NX_CONTROLMASK;
-#ifdef NX_MODIFIERKEY_RCONTROL
-        case NX_MODIFIERKEY_RCONTROL:    return NX_CONTROLMASK;
-#endif
-        case NX_MODIFIERKEY_ALTERNATE:   return NX_ALTERNATEMASK;
-#ifdef NX_MODIFIERKEY_RALTERNATE
-        case NX_MODIFIERKEY_RALTERNATE:  return NX_ALTERNATEMASK;
-#endif
-        case NX_MODIFIERKEY_COMMAND:     return NX_COMMANDMASK;
-#ifdef NX_MODIFIERKEY_RCOMMAND
-        case NX_MODIFIERKEY_RCOMMAND:    return NX_COMMANDMASK;
-#endif
-        case NX_MODIFIERKEY_NUMERICPAD:  return NX_NUMERICPADMASK;
-        case NX_MODIFIERKEY_HELP:        return NX_HELPMASK;
-        case NX_MODIFIERKEY_SECONDARYFN: return NX_SECONDARYFNMASK;
-    }
-    return 0;
-}
-
-/*
- * DarwinModifierStringToNXKey
- *      Returns -1 if string is not a known modifier.
- */
-int DarwinModifierStringToNXKey(const char *str) {
-    if      (!strcasecmp(str, "shift"))   return NX_MODIFIERKEY_SHIFT;
-    else if (!strcasecmp(str, "control")) return NX_MODIFIERKEY_CONTROL;
-    else if (!strcasecmp(str, "option"))  return NX_MODIFIERKEY_ALTERNATE;
-    else if (!strcasecmp(str, "command")) return NX_MODIFIERKEY_COMMAND;
-    else if (!strcasecmp(str, "fn"))      return NX_MODIFIERKEY_SECONDARYFN;
-    else return -1;
-}
-
-/*
- * LegalModifier
- *      This allows the ddx layer to prevent some keys from being remapped
- *      as modifier keys.
- */
-Bool LegalModifier(unsigned int key, DeviceIntPtr pDev)
-{
-    return 1;
-}
diff --git a/hw/darwin/darwinKeyboard.h b/hw/darwin/darwinKeyboard.h
deleted file mode 100644
index 1210441..0000000
--- a/hw/darwin/darwinKeyboard.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2003-2004 Torrey T. Lyons. 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
- * 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 DARWIN_KEYBOARD_H
-#define DARWIN_KEYBOARD_H 1
-
-#include "darwinKeyboard_interface.h"
-
-/* Provided for darwinEvents.c */
-extern darwinKeyboardInfo keyInfo;
-void DarwinKeyboardReload(DeviceIntPtr pDev);
-void DarwinKeyboardInit(DeviceIntPtr pDev);
-int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide);
-int DarwinModifierNXKeyToNXKeycode(int key, int side);
-int DarwinModifierNXKeyToNXMask(int key);
-int DarwinModifierNXMaskToNXKey(int mask);
-int DarwinModifierStringToNXKey(const char *string);
-
-/* Provided for darwin.c */
-void DarwinKeyboardInit(DeviceIntPtr pDev);
-
-#endif /* DARWIN_KEYBOARD_H */
diff --git a/hw/darwin/darwinKeyboard_interface.h b/hw/darwin/darwinKeyboard_interface.h
deleted file mode 100644
index f41f463..0000000
--- a/hw/darwin/darwinKeyboard_interface.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2003-2004 Torrey T. Lyons. 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
- * 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 DARWIN_KEYBOARD_INTERFACE_H
-#define DARWIN_KEYBOARD_INTERFACE_H 1
-
-#define XK_TECHNICAL		// needed to get XK_Escape
-#define XK_PUBLISHING
-#include "X11/keysym.h"
-#include "inputstr.h"
-
-// Each key can generate 4 glyphs. They are, in order:
-// unshifted, shifted, modeswitch unshifted, modeswitch shifted
-#define GLYPHS_PER_KEY  4
-#define NUM_KEYCODES    248	// NX_NUMKEYCODES might be better
-#define MAX_KEYCODE     NUM_KEYCODES + MIN_KEYCODE - 1
-
-typedef struct darwinKeyboardInfo_struct {
-    CARD8 modMap[MAP_LENGTH];
-    KeySym keyMap[MAP_LENGTH * GLYPHS_PER_KEY];
-    unsigned char modifierKeycodes[32][2];
-} darwinKeyboardInfo;
-
-/* These functions need to be implemented by XQuartz, XDarwin, etc. */
-void DarwinKeyboardReload(DeviceIntPtr pDev);
-Bool DarwinModeReadSystemKeymap(darwinKeyboardInfo *info);
-unsigned int DarwinModeSystemKeymapSeed(void);
-
-#endif /* DARWIN_KEYBOARD_INTERFACE_H */
diff --git a/hw/darwin/darwinXinput.c b/hw/darwin/darwinXinput.c
deleted file mode 100644
index ee456a4..0000000
--- a/hw/darwin/darwinXinput.c
+++ /dev/null
@@ -1,312 +0,0 @@
-
-/*
- * X server support of the XINPUT extension for Darwin
- *
- * This is currently a copy of mi/stubs.c, but eventually this
- * should include more complete XINPUT support.
- */
-
-/************************************************************
-
-Copyright 1989, 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.
-
-Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
-
-			All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its
-documentation for any purpose and without fee is hereby granted,
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in
-supporting documentation, and that the name of Hewlett-Packard not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.
-
-HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-HEWLETT-PACKARD 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.
-
-********************************************************/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#define	 NEED_EVENTS
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "inputstr.h"
-#include <X11/extensions/XI.h>
-#include <X11/extensions/XIproto.h>
-#include "XIstubs.h"
-
-/***********************************************************************
- *
- * Caller:	ProcXChangeKeyboardDevice
- *
- * This procedure does the implementation-dependent portion of the work
- * needed to change the keyboard device.
- *
- * The X keyboard device has a FocusRec.  If the device that has been 
- * made into the new X keyboard did not have a FocusRec, 
- * ProcXChangeKeyboardDevice will allocate one for it.
- *
- * If you do not want clients to be able to focus the old X keyboard
- * device, call DeleteFocusClassDeviceStruct to free the FocusRec.
- *
- * If you support input devices with keys that you do not want to be 
- * used as the X keyboard, you need to check for them here and return 
- * a BadDevice error.
- *
- * The default implementation is to do nothing (assume you do want
- * clients to be able to focus the old X keyboard).  The commented-out
- * sample code shows what you might do if you don't want the default.
- *
- */
-
-int
-ChangeKeyboardDevice (old_dev, new_dev)
-    DeviceIntPtr	old_dev;
-    DeviceIntPtr	new_dev;
-    {
-    /***********************************************************************
-     DeleteFocusClassDeviceStruct(old_dev);	 * defined in xchgptr.c *
-    **********************************************************************/
-    return BadMatch;
-    }
-
-
-/***********************************************************************
- *
- * Caller:	ProcXChangePointerDevice
- *
- * This procedure does the implementation-dependent portion of the work
- * needed to change the pointer device.
- *
- * The X pointer device does not have a FocusRec.  If the device that
- * has been made into the new X pointer had a FocusRec, 
- * ProcXChangePointerDevice will free it.
- *
- * If you want clients to be able to focus the old pointer device that
- * has now become accessible through the input extension, you need to 
- * add a FocusRec to it here.
- *
- * The XChangePointerDevice protocol request also allows the client
- * to choose which axes of the new pointer device are used to move 
- * the X cursor in the X- and Y- directions.  If the axes are different
- * than the default ones, you need to keep track of that here.
- *
- * If you support input devices with valuators that you do not want to be 
- * used as the X pointer, you need to check for them here and return a 
- * BadDevice error.
- *
- * The default implementation is to do nothing (assume you don't want
- * clients to be able to focus the old X pointer).  The commented-out
- * sample code shows what you might do if you don't want the default.
- *
- */
-
-int
-ChangePointerDevice (
-    DeviceIntPtr	old_dev,
-    DeviceIntPtr	new_dev,
-    unsigned char	x,
-    unsigned char	y)
-    {
-    /***********************************************************************
-    InitFocusClassDeviceStruct(old_dev);	* allow focusing old ptr*
-
-    x_axis = x;					* keep track of new x-axis*
-    y_axis = y;					* keep track of new y-axis*
-    if (x_axis != 0 || y_axis != 1)
-	axes_changed = TRUE;			* remember axes have changed*
-    else
-	axes_changed = FALSE;
-    *************************************************************************/
-    return BadMatch;
-    }
-
-/***********************************************************************
- *
- * Caller:	ProcXCloseDevice
- *
- * Take care of implementation-dependent details of closing a device.
- * Some implementations may actually close the device, others may just
- * remove this clients interest in that device.
- *
- * The default implementation is to do nothing (assume all input devices
- * are initialized during X server initialization and kept open).
- *
- */
-
-void
-CloseInputDevice (d, client)
-    DeviceIntPtr d;
-    ClientPtr client;
-    {
-    }
-
-/***********************************************************************
- *
- * Caller:	ProcXListInputDevices
- *
- * This is the implementation-dependent routine to initialize an input 
- * device to the point that information about it can be listed.
- * Some implementations open all input devices when the server is first
- * initialized, and never close them.  Other implementations open only
- * the X pointer and keyboard devices during server initialization,
- * and only open other input devices when some client makes an
- * XOpenDevice request.  If some other process has the device open, the
- * server may not be able to get information about the device to list it.
- *
- * This procedure should be used by implementations that do not initialize
- * all input devices at server startup.  It should do device-dependent
- * initialization for any devices not previously initialized, and call
- * AddInputDevice for each of those devices so that a DeviceIntRec will be 
- * created for them.
- *
- * The default implementation is to do nothing (assume all input devices
- * are initialized during X server initialization and kept open).
- * The commented-out sample code shows what you might do if you don't want 
- * the default.
- *
- */
-
-void
-AddOtherInputDevices ()
-    {
-    /**********************************************************************
-     for each uninitialized device, do something like: 
-
-    DeviceIntPtr dev;
-    DeviceProc deviceProc;
-    pointer private;
-
-    dev = (DeviceIntPtr) AddInputDevice(deviceProc, TRUE);
-    dev->public.devicePrivate = private;
-    RegisterOtherDevice(dev);
-    dev->inited = ((*dev->deviceProc)(dev, DEVICE_INIT) == Success);
-    ************************************************************************/
-
-    }
-
-/***********************************************************************
- *
- * Caller:	ProcXOpenDevice
- *
- * This is the implementation-dependent routine to open an input device.
- * Some implementations open all input devices when the server is first
- * initialized, and never close them.  Other implementations open only
- * the X pointer and keyboard devices during server initialization,
- * and only open other input devices when some client makes an
- * XOpenDevice request.  This entry point is for the latter type of 
- * implementation.
- *
- * If the physical device is not already open, do it here.  In this case,
- * you need to keep track of the fact that one or more clients has the
- * device open, and physically close it when the last client that has
- * it open does an XCloseDevice.
- *
- * The default implementation is to do nothing (assume all input devices
- * are opened during X server initialization and kept open).
- *
- */
-
-void
-OpenInputDevice (dev, client, status)
-    DeviceIntPtr dev;
-    ClientPtr client;
-    int *status;
-    {
-    }
-
-/****************************************************************************
- *
- * Caller:	ProcXSetDeviceMode
- *
- * Change the mode of an extension device.
- * This function is used to change the mode of a device from reporting
- * relative motion to reporting absolute positional information, and
- * vice versa.
- * The default implementation below is that no such devices are supported.
- *
- */
-
-int
-SetDeviceMode (client, dev, mode)
-    register	ClientPtr	client;
-    DeviceIntPtr dev;
-    int		mode;
-    {
-    return BadMatch;
-    }
-
-/****************************************************************************
- *
- * Caller:	ProcXSetDeviceValuators
- *
- * Set the value of valuators on an extension input device.
- * This function is used to set the initial value of valuators on
- * those input devices that are capable of reporting either relative
- * motion or an absolute position, and allow an initial position to be set.
- * The default implementation below is that no such devices are supported.
- *
- */
-
-int
-SetDeviceValuators (client, dev, valuators, first_valuator, num_valuators)
-    register	ClientPtr	client;
-    DeviceIntPtr dev;
-    int		*valuators;
-    int		first_valuator;
-    int		num_valuators;
-    {
-    return BadMatch;
-    }
-
-/****************************************************************************
- *
- * Caller:	ProcXChangeDeviceControl
- *
- * Change the specified device controls on an extension input device.
- *
- */
-
-int
-ChangeDeviceControl (client, dev, control)
-    register	ClientPtr	client;
-    DeviceIntPtr dev;
-    xDeviceCtl	*control;
-    {
-    switch (control->control)
-	{
-	case DEVICE_RESOLUTION:
-	    return (BadMatch);
-	default:
-	    return (BadMatch);
-	}
-    }
diff --git a/hw/darwin/quartz/Makefile.am b/hw/darwin/quartz/Makefile.am
deleted file mode 100644
index 38f48d0..0000000
--- a/hw/darwin/quartz/Makefile.am
+++ /dev/null
@@ -1,42 +0,0 @@
-noinst_LTLIBRARIES = libXQuartz.la
-
-AM_CFLAGS = $(XSERVER_CFLAGS) $(DIX_CFLAGS)
-AM_OBJCFLAGS = $(XSERVER_CFLAGS) $(DIX_CFLAGS)
-
-# TODO: This should not pull in rootless... rootless should all be in xpr
-AM_CPPFLAGS = \
-	-I$(srcdir) -I$(srcdir)/.. \
-	-I$(top_srcdir)/miext/rootless
-
-if X11APP
-X11APP_SUBDIRS = apple
-endif
-
-SUBDIRS = . xpr $(X11APP_SUBDIRS)
-DIST_SUBDIRS = xpr apple
-
-libXQuartz_la_SOURCES = \
-	X11Application.m \
-	X11Controller.m \
-	applewm.c \
-	keysym2ucs.c \
-	pseudoramiX.c \
-	quartz.c \
-	quartzAudio.c \
-	quartzCocoa.m \
-	quartzKeyboard.c \
-	quartzPasteboard.c \
-	quartzStartup.c
-
-EXTRA_DIST = \
-	X11Application.h \
-	X11Controller.h \
-	applewmExt.h \
-	keysym2ucs.h \
-	pseudoramiX.h \
-	quartzAudio.h \
-	quartzCommon.h \
-	quartzCursor.c \
-	quartzCursor.h \
-	quartz.h \
-	quartzPasteboard.h
diff --git a/hw/darwin/quartz/X11Application.h b/hw/darwin/quartz/X11Application.h
deleted file mode 100644
index 8615657..0000000
--- a/hw/darwin/quartz/X11Application.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/* X11Application.h -- subclass of NSApplication to multiplex events
-
-   Copyright (c) 2002-2007 Apple Inc. 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 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 X11APPLICATION_H
-#define X11APPLICATION_H 1
-
-#if __OBJC__
-
-#import <Cocoa/Cocoa.h>
-#import "X11Controller.h"
-
- at interface X11Application : NSApplication {
-    X11Controller *_controller;
-
-    unsigned int _x_active :1;
-}
-
-- (void) set_controller:controller;
-- (void) set_window_menu:(NSArray *)list;
-
-- (int) prefs_get_integer:(NSString *)key default:(int)def;
-- (const char *) prefs_get_string:(NSString *)key default:(const char *)def;
-- (float) prefs_get_float:(NSString *)key default:(float)def;
-- (int) prefs_get_boolean:(NSString *)key default:(int)def;
-- (NSArray *) prefs_get_array:(NSString *)key;
-- (void) prefs_set_integer:(NSString *)key value:(int)value;
-- (void) prefs_set_float:(NSString *)key value:(float)value;
-- (void) prefs_set_boolean:(NSString *)key value:(int)value;
-- (void) prefs_set_array:(NSString *)key value:(NSArray *)value;
-- (void) prefs_set_string:(NSString *)key value:(NSString *)value;
-- (void) prefs_synchronize;
-
-- (BOOL) x_active;
-
- at end
-
-extern X11Application *X11App;
-
-#endif /* __OBJC__ */
-
-extern void X11ApplicationSetWindowMenu (int nitems, const char **items,
-					 const char *shortcuts);
-extern void X11ApplicationSetWindowMenuCheck (int idx);
-extern void X11ApplicationSetFrontProcess (void);
-extern void X11ApplicationSetCanQuit (int state);
-extern void X11ApplicationServerReady (void);
-extern void X11ApplicationShowHideMenubar (int state);
-
-extern void X11ApplicationMain (int argc, const char *argv[],
-				void (*server_thread) (void *),
-				void *server_arg);
-
-extern int X11EnableKeyEquivalents;
-extern int quartzHasRoot, quartzEnableRootless;
-
-#define APP_PREFS "org.x.X11"
-
-#define PREFS_APPSMENU		"apps_menu"
-#define PREFS_FAKEBUTTONS	"enable_fake_buttons"
-#define PREFS_SYSBEEP		"enable_system_beep"
-#define PREFS_KEYEQUIVS		"enable_key_equivalents"
-#define PREFS_KEYMAP_FILE	"keymap_file"
-#define PREFS_SYNC_KEYMAP	"sync_keymap"
-#define PREFS_DEPTH		"depth"
-#define PREFS_NO_AUTH		"no_auth"
-#define PREFS_NO_TCP		"nolisten_tcp"
-#define PREFS_DONE_XINIT_CHECK	"done_xinit_check"
-#define PREFS_NO_QUIT_ALERT	"no_quit_alert"
-#define PREFS_FAKE_BUTTON2	"fake_button2"
-#define PREFS_FAKE_BUTTON3	"fake_button3"
-#define PREFS_ROOTLESS		"rootless"
-#define PREFS_FULLSCREEN_HOTKEYS "fullscreen_hotkeys"
-#define PREFS_SWAP_ALT_META	"swap_alt_meta"
-#define PREFS_XP_OPTIONS	"xp_options"
-#define PREFS_ENABLE_STEREO	"enable_stereo"
-
-#endif /* X11APPLICATION_H */
diff --git a/hw/darwin/quartz/X11Application.m b/hw/darwin/quartz/X11Application.m
deleted file mode 100644
index 3e37dd4..0000000
--- a/hw/darwin/quartz/X11Application.m
+++ /dev/null
@@ -1,916 +0,0 @@
-/* X11Application.m -- subclass of NSApplication to multiplex events
- 
- Copyright (c) 2002-2007 Apple Inc.
- 
- 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. */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "quartzCommon.h"
-
-#import "X11Application.h"
-#include <Carbon/Carbon.h>
-
-/* ouch! */
-#define BOOL X_BOOL
-# include "darwin.h"
-# include "quartz.h"
-# define _APPLEWM_SERVER_
-# include "X11/extensions/applewm.h"
-# include "micmap.h"
-#undef BOOL
-
-#include <mach/mach.h>
-#include <unistd.h>
-#include <pthread.h>
-
-#include "rootlessCommon.h"
-
-WindowPtr xprGetXWindowFromAppKit(int windowNumber); // xpr/xprFrame.c
-
-#define DEFAULTS_FILE "/usr/X11/lib/X11/xserver/Xquartz.plist"
-
-int X11EnableKeyEquivalents = TRUE;
-int quartzHasRoot = FALSE, quartzEnableRootless = TRUE;
-
-extern int darwinFakeButtons, input_check_flag;
-extern Bool enable_stereo; 
-
-extern xEvent *darwinEvents;
-
-X11Application *X11App;
-
-#define ALL_KEY_MASKS (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask)
-
- at implementation X11Application
-
-typedef struct message_struct message;
-struct message_struct {
-    mach_msg_header_t hdr;
-    SEL selector;
-    NSObject *arg;
-};
-
-static mach_port_t _port;
-
-static void send_nsevent (NSEventType type, NSEvent *e);
-
-/* Quartz mode initialization routine. This is often dynamically loaded
- but is statically linked into this X server. */
-extern Bool QuartzModeBundleInit(void);
-
-static void init_ports (void) {
-    kern_return_t r;
-    NSPort *p;
-	
-    if (_port != MACH_PORT_NULL) return;
-	
-    r = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, &_port);
-    if (r != KERN_SUCCESS) return;
-	
-    p = [NSMachPort portWithMachPort:_port];
-    [p setDelegate:NSApp];
-    [p scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
-}
-
-static void message_kit_thread (SEL selector, NSObject *arg) {
-    message msg;
-    kern_return_t r;
-	
-    msg.hdr.msgh_bits = MACH_MSGH_BITS (MACH_MSG_TYPE_MAKE_SEND, 0);
-    msg.hdr.msgh_size = sizeof (msg);
-    msg.hdr.msgh_remote_port = _port;
-    msg.hdr.msgh_local_port = MACH_PORT_NULL;
-    msg.hdr.msgh_reserved = 0;
-    msg.hdr.msgh_id = 0;
-	
-    msg.selector = selector;
-    msg.arg = [arg retain];
-	
-    r = mach_msg (&msg.hdr, MACH_SEND_MSG, msg.hdr.msgh_size,
-		  0, MACH_PORT_NULL, 0, MACH_PORT_NULL);
-    if (r != KERN_SUCCESS)
-		ErrorF("%s: mach_msg failed: %x\n", __FUNCTION__, r);
-}
-
-- (void) handleMachMessage:(void *)_msg {
-    message *msg = _msg;
-	
-    [self performSelector:msg->selector withObject:msg->arg];
-    [msg->arg release];
-}
-
-- (void) set_controller:obj {
-    if (_controller == nil) _controller = [obj retain];
-}
-
-- (void) dealloc {
-    if (_controller != nil) [_controller release];
-	
-    if (_port != MACH_PORT_NULL)
-		mach_port_deallocate (mach_task_self (), _port);
-	
-    [super dealloc];
-}
-
-- (void) orderFrontStandardAboutPanel: (id) sender {
-    NSMutableDictionary *dict;
-    NSDictionary *infoDict;
-    NSString *tem;
-	
-    dict = [NSMutableDictionary dictionaryWithCapacity:2];
-    infoDict = [[NSBundle mainBundle] infoDictionary];
-	
-    [dict setObject: NSLocalizedString (@"The X Window System", @"About panel")
-			 forKey:@"ApplicationName"];
-	
-    tem = [infoDict objectForKey:@"CFBundleShortVersionString"];
-	
-    [dict setObject:[NSString stringWithFormat:@"X11.app %@ - X.org X11R7.3", tem] 
-	  forKey:@"ApplicationVersion"];
-	
-    [self orderFrontStandardAboutPanelWithOptions: dict];
-}
-
-- (void) activateX:(BOOL)state {
-    /* Create a TSM document that supports full Unicode input, and
-	 have it activated while X is active (unless using the old
-	 keymapping files) */
-    static TSMDocumentID x11_document;
-	
-    if (state) {
-      QuartzMessageServerThread (kXDarwinActivate, 0);
-      
-      if (!_x_active) {
-	if (x11_document == 0 && darwinKeymapFile == NULL) {
-	  OSType types[1];
-	  types[0] = kUnicodeDocument;
-	  NewTSMDocument (1, types, &x11_document, 0);
-	}
-	
-	if (x11_document != 0)	ActivateTSMDocument (x11_document);
-      }
-    } else {
-      QuartzMessageServerThread (kXDarwinDeactivate, 0);
-      
-      if (_x_active && x11_document != 0)
-	DeactivateTSMDocument (x11_document);
-    }
-    
-    _x_active = state;
-}
-
-- (void) became_key:(NSWindow *)win {
-    [self activateX:NO];
-}
-
-- (void) sendEvent:(NSEvent *)e {
-  NSEventType type;
-  BOOL for_appkit, for_x;
-  
-  type = [e type];
-  
-  /* By default pass down the responder chain and to X. */
-  for_appkit = YES;
-  for_x = YES;
-  
-  switch (type) {
-  case NSLeftMouseDown: case NSRightMouseDown: case NSOtherMouseDown:
-  case NSLeftMouseUp: case NSRightMouseUp: case NSOtherMouseUp:
-    if ([e window] != nil) {
-      /* Pointer event has an (AppKit) window. Probably something for the kit. */
-      for_x = NO;
-      if (_x_active) [self activateX:NO];
-    } else if ([self modalWindow] == nil) {
-      /* Must be an X window. Tell appkit it doesn't have focus. */
-      WindowPtr pWin = xprGetXWindowFromAppKit([e windowNumber]);
-      if (pWin) RootlessReorderWindow(pWin);
-      for_appkit = NO;
-      
-      if ([self isActive]) {
-	[self deactivate];
-	
-	if (!_x_active && quartzProcs->IsX11Window([e window],
-						   [e windowNumber]))
-	  [self activateX:YES];
-      }
-    }
-    break;
-      
-  case NSKeyDown: case NSKeyUp:
-    if (_x_active) {
-      static int swallow_up;
-      
-      /* No kit window is focused, so send it to X. */
-      for_appkit = NO;
-      if (type == NSKeyDown) {
-	/* Before that though, see if there are any global
-	   shortcuts bound to it. */
-	
-	if (X11EnableKeyEquivalents
-	    && [[self mainMenu] performKeyEquivalent:e]) {
-	  swallow_up = [e keyCode];
-	  for_x = NO;
-	} else if (!quartzEnableRootless
-		   && ([e modifierFlags] & ALL_KEY_MASKS)
-		   == (NSCommandKeyMask | NSAlternateKeyMask)
-		   && ([e keyCode] == 0 /*a*/
-		    || [e keyCode] == 53 /*Esc*/)) {
-	  swallow_up = 0;
-	  for_x = NO;
-#ifdef DARWIN_DDX_MISSING
-	  QuartzMessageServerThread (kXDarwinToggleFullscreen, 0);
-#endif
-	}
-      } else {
-	/* If we saw a key equivalent on the down, don't pass
-	   the up through to X. */
-	
-	if (swallow_up != 0 && [e keyCode] == swallow_up) {
-	  swallow_up = 0;
-	  for_x = NO;
-	}
-      }
-    } else for_x = NO;
-    break;
-    
-  case NSFlagsChanged:
-    /* For the l33t X users who remap modifier keys to normal keysyms. */
-    if (!_x_active) for_x = NO;
-    break;
-    
-  case NSAppKitDefined:
-    switch ([e subtype]) {
-    case NSApplicationActivatedEventType:
-      for_x = NO;
-      if ([self modalWindow] == nil) {
-	for_appkit = NO;
-	
-	/* FIXME: hack to avoid having to pass the event to appkit,
-	   which would cause it to raise one of its windows. */
-	_appFlags._active = YES;
-	
-	[self activateX:YES];
-	if ([e data2] & 0x10) X11ApplicationSetFrontProcess();
-      }
-      break;
-      
-    case 18: /* ApplicationDidReactivate */
-      if (quartzHasRoot) for_appkit = NO;
-      break;
-      
-    case NSApplicationDeactivatedEventType:
-      for_x = NO;
-      [self activateX:NO];
-      break;
-    }
-    break;
-    
-  default: break; /* for gcc */
-  }
-  
-  if (for_appkit) [super sendEvent:e];
-  
-  if (for_x) send_nsevent (type, e);
-}
-
-- (void) set_window_menu:(NSArray *)list {
-    [_controller set_window_menu:list];
-}
-
-- (void) set_window_menu_check:(NSNumber *)n {
-    [_controller set_window_menu_check:n];
-}
-
-- (void) set_apps_menu:(NSArray *)list {
-    [_controller set_apps_menu:list];
-}
-
-- (void) set_front_process:unused {
-    QuartzMessageServerThread(kXDarwinBringAllToFront, 0);
-}
-
-- (void) set_can_quit:(NSNumber *)state {
-    [_controller set_can_quit:[state boolValue]];
-}
-
-- (void) server_ready:unused {
-    [_controller server_ready];
-}
-
-- (void) show_hide_menubar:(NSNumber *)state {
-    if ([state boolValue]) ShowMenuBar ();
-    else HideMenuBar ();
-}
-
-
-/* user preferences */
-
-/* Note that these functions only work for arrays whose elements
- can be toll-free-bridged between NS and CF worlds. */
-
-static const void *cfretain (CFAllocatorRef a, const void *b) {
-    return CFRetain (b);
-}
-
-static void cfrelease (CFAllocatorRef a, const void *b) {
-    CFRelease (b);
-}
-
-static CFMutableArrayRef nsarray_to_cfarray (NSArray *in) {
-    CFMutableArrayRef out;
-    CFArrayCallBacks cb;
-    NSObject *ns;
-    const CFTypeRef *cf;
-    int i, count;
-	
-    memset (&cb, 0, sizeof (cb));
-    cb.version = 0;
-    cb.retain = cfretain;
-    cb.release = cfrelease;
-	
-    count = [in count];
-    out = CFArrayCreateMutable (NULL, count, &cb);
-	
-    for (i = 0; i < count; i++) {
-      ns = [in objectAtIndex:i];
-      
-      if ([ns isKindOfClass:[NSArray class]])
-	cf = (CFTypeRef) nsarray_to_cfarray ((NSArray *) ns);
-      else
-	cf = CFRetain ((CFTypeRef) ns);
-      
-      CFArrayAppendValue (out, cf);
-      CFRelease (cf);
-    }
-    
-    return out;
-}
-
-static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
-    NSMutableArray *out;
-    const CFTypeRef *cf;
-    NSObject *ns;
-    int i, count;
-	
-    count = CFArrayGetCount (in);
-    out = [[NSMutableArray alloc] initWithCapacity:count];
-	
-    for (i = 0; i < count; i++) {
-      cf = CFArrayGetValueAtIndex (in, i);
-		
-      if (CFGetTypeID (cf) == CFArrayGetTypeID ())
-	ns = cfarray_to_nsarray ((CFArrayRef) cf);
-      else
-	ns = [(id)cf retain];
-      
-      [out addObject:ns];
-      [ns release];
-    }
-    
-    return out;
-}
-
-- (CFPropertyListRef) prefs_get:(NSString *)key {
-    CFPropertyListRef value;
-	
-    value = CFPreferencesCopyAppValue ((CFStringRef) key, CFSTR (APP_PREFS));
-	
-    if (value == NULL) {
-      static CFDictionaryRef defaults;
-      
-      if (defaults == NULL) {
-	CFStringRef error = NULL;
-	CFDataRef data;
-	CFURLRef url;
-	SInt32 error_code;
-	
-	url = (CFURLCreateFromFileSystemRepresentation
-	       (NULL, (unsigned char *)DEFAULTS_FILE, strlen (DEFAULTS_FILE), false));
-	if (CFURLCreateDataAndPropertiesFromResource (NULL, url, &data,
-						      NULL, NULL, &error_code)) {
-	  defaults = (CFPropertyListCreateFromXMLData
-		      (NULL, data, kCFPropertyListMutableContainersAndLeaves, &error));
-	  if (error != NULL) CFRelease (error);
-	  CFRelease (data);
-	}
-	CFRelease (url);
-			
-	if (defaults != NULL) {
-	  NSMutableArray *apps, *elt;
-	  int count, i;
-	  NSString *name, *nname;
-	  
-	  /* Localize the names in the default apps menu. */
-	  
-	  apps = [(NSDictionary *)defaults objectForKey:@PREFS_APPSMENU];
-	  if (apps != nil) {
-	    count = [apps count];
-	    for (i = 0; i < count; i++)	{
-	      elt = [apps objectAtIndex:i];
-	      if (elt != nil && [elt isKindOfClass:[NSArray class]]) {
-		name = [elt objectAtIndex:0];
-		if (name != nil) {
-		  nname = NSLocalizedString (name, nil);
-		  if (nname != nil && nname != name)
-		    [elt replaceObjectAtIndex:0 withObject:nname];
-		}
-	      }
-	    }
-	  }
-	}
-      }
-		
-      if (defaults != NULL) value = CFDictionaryGetValue (defaults, key);
-      if (value != NULL) CFRetain (value);
-    }
-	
-    return value;
-}
-
-- (int) prefs_get_integer:(NSString *)key default:(int)def {
-  CFPropertyListRef value;
-  int ret;
-  
-  value = [self prefs_get:key];
-  
-  if (value != NULL && CFGetTypeID (value) == CFNumberGetTypeID ())
-    CFNumberGetValue (value, kCFNumberIntType, &ret);
-  else if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ())
-    ret = CFStringGetIntValue (value);
-  else
-    ret = def;
-  
-  if (value != NULL) CFRelease (value);
-  
-  return ret;
-}
-
-- (const char *) prefs_get_string:(NSString *)key default:(const char *)def {
-  CFPropertyListRef value;
-  const char *ret = NULL;
-  
-  value = [self prefs_get:key];
-  
-  if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ()) {
-    NSString *s = (NSString *) value;
-    
-    ret = [s UTF8String];
-  }
-  
-  if (value != NULL) CFRelease (value);
-  
-  return ret != NULL ? ret : def;
-}
-
-- (float) prefs_get_float:(NSString *)key default:(float)def {
-  CFPropertyListRef value;
-  float ret = def;
-  
-  value = [self prefs_get:key];
-  
-  if (value != NULL
-      && CFGetTypeID (value) == CFNumberGetTypeID ()
-      && CFNumberIsFloatType (value)) 
-    CFNumberGetValue (value, kCFNumberFloatType, &ret);
-  else if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ())
-    ret = CFStringGetDoubleValue (value);
-	
-  if (value != NULL) CFRelease (value);
-  
-  return ret;
-}
-
-- (int) prefs_get_boolean:(NSString *)key default:(int)def {
-  CFPropertyListRef value;
-  int ret = def;
-  
-  value = [self prefs_get:key];
-  
-  if (value != NULL) {
-    if (CFGetTypeID (value) == CFNumberGetTypeID ())
-      CFNumberGetValue (value, kCFNumberIntType, &ret);
-    else if (CFGetTypeID (value) == CFBooleanGetTypeID ())
-      ret = CFBooleanGetValue (value);
-    else if (CFGetTypeID (value) == CFStringGetTypeID ()) {
-      const char *tem = [(NSString *) value UTF8String];
-      if (strcasecmp (tem, "true") == 0 || strcasecmp (tem, "yes") == 0)
-	ret = YES;
-      else
-	ret = NO;
-    }
-    
-    CFRelease (value);
-  }
-  return ret;
-}
-
-- (NSArray *) prefs_get_array:(NSString *)key {
-  NSArray *ret = nil;
-  CFPropertyListRef value;
-  
-  value = [self prefs_get:key];
-  
-  if (value != NULL) {
-    if (CFGetTypeID (value) == CFArrayGetTypeID ())
-      ret = [cfarray_to_nsarray (value) autorelease];
-    
-    CFRelease (value);
-  }
-  
-  return ret;
-}
-
-- (void) prefs_set_integer:(NSString *)key value:(int)value {
-    CFNumberRef x;
-	
-    x = CFNumberCreate (NULL, kCFNumberIntType, &value);
-	
-    CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) x, CFSTR (APP_PREFS),
-			   kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
-	
-    CFRelease (x);
-}
-
-- (void) prefs_set_float:(NSString *)key value:(float)value {
-    CFNumberRef x;
-	
-    x = CFNumberCreate (NULL, kCFNumberFloatType, &value);
-	
-    CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) x, CFSTR (APP_PREFS),
-			   kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
-	
-    CFRelease (x);
-}
-
-- (void) prefs_set_boolean:(NSString *)key value:(int)value {
-  CFPreferencesSetValue ((CFStringRef) key,
-			 (CFTypeRef) value ? kCFBooleanTrue
-			 : kCFBooleanFalse, CFSTR (APP_PREFS),
-			 kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
-  
-}
-
-- (void) prefs_set_array:(NSString *)key value:(NSArray *)value {
-  CFArrayRef cfarray;
-  
-  cfarray = nsarray_to_cfarray (value);
-  CFPreferencesSetValue ((CFStringRef) key,
-			 (CFTypeRef) cfarray,
-			 CFSTR (APP_PREFS),
-			 kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
-  CFRelease (cfarray);
-}
-
-- (void) prefs_set_string:(NSString *)key value:(NSString *)value {
-  CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) value,
-			 CFSTR (APP_PREFS), kCFPreferencesCurrentUser,
-			 kCFPreferencesAnyHost);
-}
-
-- (void) prefs_synchronize {
-    CFPreferencesAppSynchronize (kCFPreferencesCurrentApplication);
-}
-
-- (void) read_defaults
-{
-    const char *tem;
-	
-    quartzUseSysBeep = [self prefs_get_boolean:@PREFS_SYSBEEP
-                        default:quartzUseSysBeep];
-    quartzEnableRootless = [self prefs_get_boolean:@PREFS_ROOTLESS
-                        default:quartzEnableRootless];
-#ifdef DARWIN_DDX_MISSING
-    quartzFullscreenDisableHotkeys = ![self prefs_get_boolean:
-					      @PREFS_FULLSCREEN_HOTKEYS default:
-					      !quartzFullscreenDisableHotkeys];
-    quartzXpluginOptions = [self prefs_get_integer:@PREFS_XP_OPTIONS
-                            default:quartzXpluginOptions];
-#endif
-    darwinFakeButtons = [self prefs_get_boolean:@PREFS_FAKEBUTTONS
-                         default:darwinFakeButtons];
-    if (darwinFakeButtons) {
-      const char *fake2, *fake3;
-      
-      fake2 = [self prefs_get_string:@PREFS_FAKE_BUTTON2 default:NULL];
-      fake3 = [self prefs_get_string:@PREFS_FAKE_BUTTON3 default:NULL];
-      
-      if (fake2 != NULL) darwinFakeMouse2Mask = DarwinParseModifierList(fake2);
-      if (fake3 != NULL) darwinFakeMouse3Mask = DarwinParseModifierList(fake3);
-    }
-	
-    X11EnableKeyEquivalents = [self prefs_get_boolean:@PREFS_KEYEQUIVS
-                               default:X11EnableKeyEquivalents];
-	
-    darwinSyncKeymap = [self prefs_get_boolean:@PREFS_SYNC_KEYMAP
-                        default:darwinSyncKeymap];
-	
-    tem = [self prefs_get_string:@PREFS_KEYMAP_FILE default:NULL];
-    if (tem != NULL) darwinKeymapFile = strdup (tem);
-    else             darwinKeymapFile = NULL;
-	
-    darwinDesiredDepth = [self prefs_get_integer:@PREFS_DEPTH
-                          default:darwinDesiredDepth];
-	
-    enable_stereo = [self prefs_get_boolean:@PREFS_ENABLE_STEREO
-                     default:false];
-}
-
-/* This will end up at the end of the responder chain. */
-- (void) copy:sender {
-  QuartzMessageServerThread (kXDarwinPasteboardNotify, 1,
-			     AppleWMCopyToPasteboard);
-}
-
-- (BOOL) x_active {
-    return _x_active;
-}
-
- at end
-
-static NSArray *
-array_with_strings_and_numbers (int nitems, const char **items,
-				const char *numbers) {
-  NSMutableArray *array, *subarray;
-  NSString *string, *number;
-  int i;
-	
-  /* (Can't autorelease on the X server thread) */
-  
-  array = [[NSMutableArray alloc] initWithCapacity:nitems];
-  
-  for (i = 0; i < nitems; i++) {
-    subarray = [[NSMutableArray alloc] initWithCapacity:2];
-    
-    string = [[NSString alloc] initWithUTF8String:items[i]];
-    [subarray addObject:string];
-    [string release];
-    
-    if (numbers[i] != 0) {
-      number = [[NSString alloc] initWithFormat:@"%d", numbers[i]];
-      [subarray addObject:number];
-      [number release];
-    } else
-      [subarray addObject:@""];
-    
-    [array addObject:subarray];
-    [subarray release];
-  }
-  
-  return array;
-}
-
-void X11ApplicationSetWindowMenu (int nitems, const char **items,
-				  const char *shortcuts) {
-  NSArray *array;
-  array = array_with_strings_and_numbers (nitems, items, shortcuts);
-  
-  /* Send the array of strings over to the appkit thread */
-  
-  message_kit_thread (@selector (set_window_menu:), array);
-  [array release];
-}
-
-void X11ApplicationSetWindowMenuCheck (int idx) {
-  NSNumber *n;
-  
-  n = [[NSNumber alloc] initWithInt:idx];
-  
-  message_kit_thread (@selector (set_window_menu_check:), n);
-  
-  [n release];
-}
-
-void X11ApplicationSetFrontProcess (void) {
-    message_kit_thread (@selector (set_front_process:), nil);
-}
-
-void X11ApplicationSetCanQuit (int state) {
-    NSNumber *n;
-	
-    n = [[NSNumber alloc] initWithBool:state];
-	
-    message_kit_thread (@selector (set_can_quit:), n);
-	
-    [n release];
-}
-
-void X11ApplicationServerReady (void) {
-    message_kit_thread (@selector (server_ready:), nil);
-}
-
-void X11ApplicationShowHideMenubar (int state) {
-    NSNumber *n;
-	
-    n = [[NSNumber alloc] initWithBool:state];
-	
-    message_kit_thread (@selector (show_hide_menubar:), n);
-	
-    [n release];
-}
-
-static void * create_thread (void *func, void *arg) {
-    pthread_attr_t attr;
-    pthread_t tid;
-	
-    pthread_attr_init (&attr);
-    pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM);
-    pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
-    pthread_create (&tid, &attr, func, arg);
-    pthread_attr_destroy (&attr);
-	
-    return (void *) tid;
-}
-
-static void check_xinitrc (void) {
-    char *tem, buf[1024];
-    NSString *msg;
-	
-    if ([X11App prefs_get_boolean:@PREFS_DONE_XINIT_CHECK default:NO])
-		return;
-	
-    tem = getenv ("HOME");
-    if (tem == NULL) goto done;
-	
-    snprintf (buf, sizeof (buf), "%s/.xinitrc", tem);
-    if (access (buf, F_OK) != 0)
-		goto done;
-	
-    /* FIXME: put localized strings into Resources/English.lproj */
-	
-    msg = NSLocalizedString (@"You have an existing ~/.xinitrc file.\n\n\
-Windows displayed by X11 applications may not have titlebars, or may look \
-different to windows displayed by native applications.\n\n\
-Would you like to move aside the existing file and use the standard X11 \
-environment?", @"Startup xinitrc dialog");
-	
-    if (NSRunAlertPanel (nil, msg, NSLocalizedString (@"Yes", @""),
-			 NSLocalizedString (@"No", @""), nil)
-	== NSAlertDefaultReturn) {
-      char buf2[1024];
-      int i = -1;
-      
-      snprintf (buf2, sizeof (buf2), "%s.old", buf);
-      
-      for (i = 1; access (buf2, F_OK) == 0; i++)
-	snprintf (buf2, sizeof (buf2), "%s.old.%d", buf, i);
-      
-      rename (buf, buf2);
-    }
-    
- done:
-    [X11App prefs_set_boolean:@PREFS_DONE_XINIT_CHECK value:YES];
-    [X11App prefs_synchronize];
-}
-
-void X11ApplicationMain (int argc, const char *argv[],
-			 void (*server_thread) (void *), void *server_arg) {
-  NSAutoreleasePool *pool;
-  
-#ifdef DEBUG
-  while (access ("/tmp/x11-block", F_OK) == 0) sleep (1);
-#endif
-  
-  pool = [[NSAutoreleasePool alloc] init];
-  X11App = (X11Application *) [X11Application sharedApplication];
-  init_ports ();
-  [NSApp read_defaults];
-  [NSBundle loadNibNamed:@"main" owner:NSApp];
-  [[NSNotificationCenter defaultCenter] addObserver:NSApp
-					selector:@selector (became_key:)
-					name:NSWindowDidBecomeKeyNotification object:nil];
-  check_xinitrc ();
-	
-  /*
-   * The xpr Quartz mode is statically linked into this server.
-   * Initialize all the Quartz functions.
-   */
-  QuartzModeBundleInit();
-  
-  /* Calculate the height of the menubar so we can avoid it. */
-  aquaMenuBarHeight = NSHeight([[NSScreen mainScreen] frame]) -
-    NSMaxY([[NSScreen mainScreen] visibleFrame]);
-  
-  if (!create_thread (server_thread, server_arg)) {
-    ErrorF("can't create secondary thread\n");
-    exit (1);
-  }
-  
-  [NSApp run];
-  
-  /* not reached */
-}
-
-
-/* event conversion */
-
-static inline unsigned short
-convert_flags (unsigned int nsflags) {
-    unsigned int xflags = 0;
-	
-    if (nsflags == ~0) return 0xffff;
-	
-    if (nsflags & NSAlphaShiftKeyMask)	xflags |= LockMask;
-    if (nsflags & NSShiftKeyMask)	xflags |= ShiftMask;
-    if (nsflags & NSControlKeyMask)	xflags |= ControlMask;
-    if (nsflags & NSAlternateKeyMask)	xflags |= Mod1Mask;
-    if (nsflags & NSCommandKeyMask)	xflags |= Mod2Mask;
-    /* FIXME: secondaryfn? */
-	
-    return xflags;
-}
-
-
-// This code should probably be merged with that in XDarwin's XServer.m - BB
-static void send_nsevent (NSEventType type, NSEvent *e) {
-  //    static unsigned int button_state = 0;
-    NSRect screen;
-    NSPoint location;
-    NSWindow *window;
-    int pointer_x, pointer_y, ev_button, ev_type; 
-    //    int num_events=0, i=0, state;
-    xEvent xe;
-	
-    /* convert location to global top-left coordinates */
-    location = [e locationInWindow];
-    window = [e window];
-    screen = [[[NSScreen screens] objectAtIndex:0] frame];
-		
-    if (window != nil)	{
-      NSRect frame = [window frame];
-      pointer_x = location.x + frame.origin.x;
-      pointer_y = (((screen.origin.y + screen.size.height)
-		    - location.y) - frame.origin.y);
-    } else {
-      pointer_x = location.x;
-      pointer_y = (screen.origin.y + screen.size.height) - location.y;
-    }
-    
-    pointer_y -= aquaMenuBarHeight;
-    //    state = convert_flags ([e modifierFlags]);
-    
-    switch (type) {
-    case NSLeftMouseDown:    ev_button=1; ev_type=ButtonPress; goto handle_mouse;
-    case NSOtherMouseDown:   ev_button=2; ev_type=ButtonPress; goto handle_mouse;
-    case NSRightMouseDown:   ev_button=3; ev_type=ButtonPress; goto handle_mouse;
-    case NSLeftMouseUp:      ev_button=1; ev_type=ButtonRelease; goto handle_mouse;
-    case NSOtherMouseUp:     ev_button=2; ev_type=ButtonRelease; goto handle_mouse;
-    case NSRightMouseUp:     ev_button=3; ev_type=ButtonRelease; goto handle_mouse;
-    case NSLeftMouseDragged:  ev_button=1; ev_type=MotionNotify; goto handle_mouse;
-    case NSOtherMouseDragged: ev_button=2; ev_type=MotionNotify; goto handle_mouse;
-    case NSRightMouseDragged: ev_button=3; ev_type=MotionNotify; goto handle_mouse;
-    case NSMouseMoved: ev_button=0; ev_type=MotionNotify; goto handle_mouse;
-    handle_mouse:
-      
-      /* I'm not sure the below code is necessary or useful (-bb)
-	if(ev_type==ButtonPress) {
-	if (!quartzProcs->IsX11Window([e window], [e windowNumber])) {
-	  fprintf(stderr, "Dropping event because it's not a window\n");
-	  break;
-	}
-	button_state |= (1 << ev_button);
-	DarwinSendPointerEvents(ev_type, ev_button, pointer_x, pointer_y);
-      } else if (ev_type==ButtonRelease && (button_state & (1 << ev_button)) == 0) break;
-      */
-      DarwinSendPointerEvents(ev_type, ev_button, pointer_x, pointer_y);
-      break;
-    case NSScrollWheel: 
-      DarwinSendScrollEvents([e deltaY], pointer_x, pointer_y);
-      break;
-      
-    case NSKeyDown:  // do we need to translate these keyCodes?
-    case NSKeyUp:
-      DarwinSendKeyboardEvents((type == NSKeyDown)?KeyPress:KeyRelease, [e keyCode]);
-      break;
-
-    case NSFlagsChanged:
-      DarwinUpdateModKeys([e modifierFlags]);
-      break;
-    default: break; /* for gcc */
-    }	
-}
diff --git a/hw/darwin/quartz/X11Controller.h b/hw/darwin/quartz/X11Controller.h
deleted file mode 100644
index f1399dc..0000000
--- a/hw/darwin/quartz/X11Controller.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* X11Controller.h -- connect the IB ui
-
-   Copyright (c) 2002 Apple Computer, Inc. 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 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 X11CONTROLLER_H
-#define X11CONTROLLER_H 1
-
-#if __OBJC__
-
-#import <Cocoa/Cocoa.h>
-#include "xpr/x-list.h"
-
- at interface X11Controller : NSObject
-{
-    NSPanel *prefs_panel;
-
-    NSButton *fake_buttons;
-    NSButton *enable_fullscreen;
-    NSButton *use_sysbeep;
-    NSButton *enable_keyequivs;
-    NSButton *sync_keymap;
-    NSButton *enable_auth;
-    NSButton *enable_tcp;
-    NSPopUpButton *depth;
-
-    NSMenuItem *x11_about_item;
-    NSMenuItem *window_separator;
-    NSMenuItem *dock_window_separator;
-    NSMenuItem *apps_separator;
-    NSMenuItem *toggle_fullscreen_item;
-    NSMenu *dock_apps_menu;
-    NSTableView *apps_table;
-
-    NSArray *apps;
-    NSMutableArray *table_apps;
-
-    NSMenu *dock_menu;
-
-    int checked_window_item;
-    x_list *pending_apps;
-
-    BOOL finished_launching;
-    BOOL can_quit;
-}
-
-- (void) set_window_menu:(NSArray *)list;
-- (void) set_window_menu_check:(NSNumber *)n;
-- (void) set_apps_menu:(NSArray *)list;
-- (void) set_can_quit:(BOOL)state;
-- (void) server_ready;
-
- at end
-
-#endif /* __OBJC__ */
-
-extern void X11ControllerMain (int argc, const char *argv[],
-			       void (*server_thread) (void *),
-			       void *server_arg);
-
-#endif /* X11CONTROLLER_H */
diff --git a/hw/darwin/quartz/X11Controller.m b/hw/darwin/quartz/X11Controller.m
deleted file mode 100644
index 0f64e45..0000000
--- a/hw/darwin/quartz/X11Controller.m
+++ /dev/null
@@ -1,749 +0,0 @@
-/* X11Controller.m -- connect the IB ui, also the NSApp delegate
- 
-   Copyright (c) 2002-2007 Apple Inc. 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 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. */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#define DEFAULT_PATH "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11/bin"
-
-#include "quartzCommon.h"
-
-#import "X11Controller.h"
-#import "X11Application.h"
-#import <Carbon/Carbon.h>
-
-/* ouch! */
-#define BOOL X_BOOL
-#include "opaque.h"
-# include "darwin.h"
-# include "quartz.h"
-# define _APPLEWM_SERVER_
-# include "X11/extensions/applewm.h"
-# include "applewmExt.h"
-#undef BOOL
-
-#include <stdio.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-
- at implementation X11Controller
-
-- (void) awakeFromNib
-{
-  X11Application *xapp = NSApp;
-  NSArray *array;
-	
-  /* Point X11Application at ourself. */
-  [xapp set_controller:self];
-	
-  array = [xapp prefs_get_array:@PREFS_APPSMENU];
-  if (array != nil)
-    {
-      int count;
-		
-      /* convert from [TITLE1 COMMAND1 TITLE2 COMMAND2 ...]
-	 to [[TITLE1 COMMAND1] [TITLE2 COMMAND2] ...] format. */
-		
-      count = [array count];
-      if (count > 0
-	  && ![[array objectAtIndex:0] isKindOfClass:[NSArray class]])
-	{
-	  int i;
-	  NSMutableArray *copy, *sub;
-			
-	  copy = [NSMutableArray arrayWithCapacity:(count / 2)];
-			
-	  for (i = 0; i < count / 2; i++)
-	    {
-	      sub = [[NSMutableArray alloc] initWithCapacity:3];
-	      [sub addObject:[array objectAtIndex:i*2]];
-	      [sub addObject:[array objectAtIndex:i*2+1]];
-	      [sub addObject:@""];
-	      [copy addObject:sub];
-	      [sub release];
-	    }
-			
-	  array = copy;
-	}
-		
-      [self set_apps_menu:array];
-    }
-}
-
-- (void) item_selected:sender
-{
-  [NSApp activateIgnoringOtherApps:YES];
-	
-  QuartzMessageServerThread (kXDarwinControllerNotify, 2,
-			     AppleWMWindowMenuItem, [sender tag]);
-}
-
-- (void) remove_window_menu
-{
-  NSMenu *menu;
-  int first, count, i;
-	
-  /* Work backwards so we don't mess up the indices */
-  menu = [window_separator menu];
-  first = [menu indexOfItem:window_separator] + 1;
-  count = [menu numberOfItems];
-  for (i = count - 1; i >= first; i--)
-    [menu removeItemAtIndex:i];
-	
-  menu = [dock_window_separator menu];
-  count = [menu indexOfItem:dock_window_separator];
-  for (i = 0; i < count; i++)
-    [dock_menu removeItemAtIndex:0];
-}
-
-- (void) install_window_menu:(NSArray *)list
-{
-  NSMenu *menu;
-  NSMenuItem *item;
-  int first, count, i;
-	
-  menu = [window_separator menu];
-  first = [menu indexOfItem:window_separator] + 1;
-  count = [list count];
-  for (i = 0; i < count; i++)
-    {
-      NSString *name, *shortcut;
-		
-      name = [[list objectAtIndex:i] objectAtIndex:0];
-      shortcut = [[list objectAtIndex:i] objectAtIndex:1];
-		
-      item = (NSMenuItem *) [menu addItemWithTitle:name action:@selector
-				  (item_selected:) keyEquivalent:shortcut];
-      [item setTarget:self];
-      [item setTag:i];
-      [item setEnabled:YES];
-		
-      item = (NSMenuItem *) [dock_menu insertItemWithTitle:name
-				       action:@selector
-				       (item_selected:) keyEquivalent:shortcut
-				       atIndex:i];
-      [item setTarget:self];
-      [item setTag:i];
-      [item setEnabled:YES];
-    }
-	
-  if (checked_window_item >= 0 && checked_window_item < count)
-    {
-      item = (NSMenuItem *) [menu itemAtIndex:first + checked_window_item];
-      [item setState:NSOnState];
-      item = (NSMenuItem *) [dock_menu itemAtIndex:checked_window_item];
-      [item setState:NSOnState];
-    }
-}
-
-- (void) remove_apps_menu
-{
-  NSMenu *menu;
-  NSMenuItem *item;
-  int i;
-	
-  if (apps == nil || apps_separator == nil) return;
-	
-  menu = [apps_separator menu];
-	
-  if (menu != nil)
-    {
-      for (i = [menu numberOfItems] - 1; i >= 0; i--)
-	{
-	  item = (NSMenuItem *) [menu itemAtIndex:i];
-	  if ([item tag] != 0)
-	    [menu removeItemAtIndex:i];
-	}
-    }
-    
-  if (dock_apps_menu != nil)
-    {
-      for (i = [dock_apps_menu numberOfItems] - 1; i >= 0; i--)
-	{
-	  item = (NSMenuItem *) [dock_apps_menu itemAtIndex:i];
-	  if ([item tag] != 0)
-	    [dock_apps_menu removeItemAtIndex:i];
-	}
-    }
-    
-  [apps release];
-  apps = nil;
-}
-
-- (void) prepend_apps_item:(NSArray *)list index:(int)i menu:(NSMenu *)menu
-{
-  NSString *title, *shortcut = @"";
-  NSArray *group;
-  NSMenuItem *item;
-	
-  group = [list objectAtIndex:i];
-  title = [group objectAtIndex:0];
-  if ([group count] >= 3)
-    shortcut = [group objectAtIndex:2];
-	
-  if ([title length] != 0)
-    {
-      item = (NSMenuItem *) [menu insertItemWithTitle:title
-				  action:@selector (app_selected:)
-				  keyEquivalent:shortcut atIndex:0];
-      [item setTarget:self];
-      [item setEnabled:YES];
-    }
-  else
-    {
-      item = (NSMenuItem *) [NSMenuItem separatorItem];
-      [menu insertItem:item atIndex:0];
-    }
-	
-  [item setTag:i+1];			/* can't be zero, so add one */
-}
-
-- (void) install_apps_menu:(NSArray *)list
-{
-  NSMenu *menu;
-  int i, count;
-	
-  count = [list count];
-	
-  if (count == 0 || apps_separator == nil) return;
-	
-  menu = [apps_separator menu];
-	
-  for (i = count - 1; i >= 0; i--)
-    {
-      if (menu != nil)
-	[self prepend_apps_item:list index:i menu:menu];
-      if (dock_apps_menu != nil)
-	[self prepend_apps_item:list index:i menu:dock_apps_menu];
-    }
-	
-  apps = [list retain];
-}
-
-- (void) set_window_menu:(NSArray *)list
-{
-  [self remove_window_menu];
-  [self install_window_menu:list];
-	
-  QuartzMessageServerThread (kXDarwinControllerNotify, 1,
-			     AppleWMWindowMenuNotify);
-}
-
-- (void) set_window_menu_check:(NSNumber *)nn
-{
-  NSMenu *menu;
-  NSMenuItem *item;
-  int first, count;
-  int n = [nn intValue];
-
-  menu = [window_separator menu];
-  first = [menu indexOfItem:window_separator] + 1;
-  count = [menu numberOfItems] - first;
-	
-  if (checked_window_item >= 0 && checked_window_item < count)
-    {
-      item = (NSMenuItem *) [menu itemAtIndex:first + checked_window_item];
-      [item setState:NSOffState];
-      item = (NSMenuItem *) [dock_menu itemAtIndex:checked_window_item];
-      [item setState:NSOffState];
-    }
-  if (n >= 0 && n < count)
-    {
-      item = (NSMenuItem *) [menu itemAtIndex:first + n];
-      [item setState:NSOnState];
-      item = (NSMenuItem *) [dock_menu itemAtIndex:n];
-      [item setState:NSOnState];
-    }
-  checked_window_item = n;
-}
-
-- (void) set_apps_menu:(NSArray *)list
-{
-  [self remove_apps_menu];
-  [self install_apps_menu:list];
-}
-
-- (void) launch_client:(NSString *)filename
-{
-  const char *command = [filename UTF8String];
-  const char *argv[7];
-  int child1, child2 = 0;
-  int status;
-	
-  argv[0] = "/usr/bin/login";
-  argv[1] = "-fp";
-  argv[2] = getlogin();
-  argv[3] = "/bin/sh";
-  argv[4] = "-c";
-  argv[5] = command;
-  argv[6] = NULL;
-
-  /* Do the fork-twice trick to avoid having to reap zombies */
-    
-  child1 = fork();
-    
-  switch (child1) {
-  case -1:                                /* error */
-    break;
-      
-  case 0:                                 /* child1 */
-    child2 = fork();
-      
-    switch (child2) {
-      int max_files, i;
-      char buf[1024], *temp;
-	
-    case -1:                            /* error */
-      _exit(1);
-	
-    case 0:                             /* child2 */
-      /* close all open files except for standard streams */
-      max_files = sysconf(_SC_OPEN_MAX);
-      for (i = 3; i < max_files; i++)	close(i);
-	
-      /* ensure stdin is on /dev/null */
-      close(0);
-      open("/dev/null", O_RDONLY);
-	
-      /* Setup environment */
-      temp = getenv("DISPLAY");
-      if (temp == NULL || temp[0] == 0) {
-	snprintf(buf, sizeof(buf), ":%s", display);
-	setenv("DISPLAY", buf, TRUE);
-      }
-	
-      temp = getenv("PATH");
-      if (temp == NULL || temp[0] == 0) 
-	setenv ("PATH", DEFAULT_PATH, TRUE);
-      else if (strnstr(temp, "/usr/X11/bin", sizeof(temp)) == NULL) {
-	snprintf(buf, sizeof(buf), "%s:/usr/X11/bin", temp);            
-	setenv("PATH", buf, TRUE);      
-      }
-      /* cd $HOME */
-      temp = getenv("HOME");
-      if (temp != NULL && temp[0]!=0) chdir(temp);
-	
-      execvp(argv[0], (char **const) argv);
-	
-      _exit(2);
-	
-    default:                            /* parent (child1) */
-      _exit(0);
-    }
-    break;
-      
-  default:                                /* parent */
-    waitpid(child1, &status, 0);
-  }
-}
-
-- (void) app_selected:sender
-{
-  int tag;
-  NSString *item;
-  
-  tag = [sender tag] - 1;
-  if (apps == nil || tag < 0 || tag >= [apps count])
-    return;
-  
-  item = [[apps objectAtIndex:tag] objectAtIndex:1];
-  
-  [self launch_client:item];
-}
-
-- (IBAction) apps_table_show:sender
-{
-  NSArray *columns;
-	
-  if (table_apps == nil) {
-    table_apps = [[NSMutableArray alloc] initWithCapacity:1];
-      
-    if (apps != nil)[table_apps addObjectsFromArray:apps];
-  }
-	
-  columns = [apps_table tableColumns];
-  [[columns objectAtIndex:0] setIdentifier:@"0"];
-  [[columns objectAtIndex:1] setIdentifier:@"1"];
-  [[columns objectAtIndex:2] setIdentifier:@"2"];
-	
-  [apps_table setDataSource:self];
-  [apps_table selectRow:0 byExtendingSelection:NO];
-	
-  [[apps_table window] makeKeyAndOrderFront:sender];
-}
-
-- (IBAction) apps_table_cancel:sender
-{
-  [[apps_table window] orderOut:sender];
-  [apps_table reloadData];
-	
-  [table_apps release];
-  table_apps = nil;
-}
-
-- (IBAction) apps_table_done:sender
-{
-  [apps_table deselectAll:sender];	/* flush edits? */
-	
-  [self remove_apps_menu];
-  [self install_apps_menu:table_apps];
-	
-  [NSApp prefs_set_array:@PREFS_APPSMENU value:table_apps];
-  [NSApp prefs_synchronize];
-	
-  [[apps_table window] orderOut:sender];
-	
-  [table_apps release];
-  table_apps = nil;
-}
-
-- (IBAction) apps_table_new:sender
-{
-  NSMutableArray *item;
-	
-  int row = [apps_table selectedRow], i;
-	
-  if (row < 0) row = 0;
-  else row = row + 1;
-	
-  i = row;
-  if (i > [table_apps count])
-    return;				/* avoid exceptions */
-	
-  [apps_table deselectAll:sender];
-	
-  item = [[NSMutableArray alloc] initWithCapacity:3];
-  [item addObject:@""];
-  [item addObject:@""];
-  [item addObject:@""];
-	
-  [table_apps insertObject:item atIndex:i];
-  [item release];
-	
-  [apps_table reloadData];
-  [apps_table selectRow:row byExtendingSelection:NO];
-}
-
-- (IBAction) apps_table_duplicate:sender
-{
-  int row = [apps_table selectedRow], i;
-  NSObject *item;
-	
-  if (row < 0) {
-    [self apps_table_new:sender];
-    return;
-  }
-	
-  i = row;
-  if (i > [table_apps count] - 1) return;				/* avoid exceptions */
-    
-  [apps_table deselectAll:sender];
-	
-  item = [[table_apps objectAtIndex:i] mutableCopy];
-  [table_apps insertObject:item atIndex:i];
-  [item release];
-	
-  [apps_table reloadData];
-  [apps_table selectRow:row+1 byExtendingSelection:NO];
-}
-
-- (IBAction) apps_table_delete:sender
-{
-  int row = [apps_table selectedRow];
-	
-  if (row >= 0)
-    {
-      int i = row;
-      
-      if (i > [table_apps count] - 1) return;			/* avoid exceptions */
-      
-      [apps_table deselectAll:sender];
-      
-      [table_apps removeObjectAtIndex:i];
-    }
-	
-  [apps_table reloadData];
-	
-  row = MIN (row, [table_apps count] - 1);
-  if (row >= 0)
-    [apps_table selectRow:row byExtendingSelection:NO];
-}
-
-- (int) numberOfRowsInTableView:(NSTableView *)tableView
-{
-  if (table_apps == nil) return 0;
-  
-  return [table_apps count];
-}
-
-- (id) tableView:(NSTableView *)tableView
-objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
-{
-  NSArray *item;
-  int col;
-	
-  if (table_apps == nil) return nil;
-	
-  col = [[tableColumn identifier] intValue];
-	
-  item = [table_apps objectAtIndex:row];
-  if ([item count] > col)
-    return [item objectAtIndex:col];
-  else
-    return @"";
-}
-
-- (void) tableView:(NSTableView *)tableView setObjectValue:(id)object
-    forTableColumn:(NSTableColumn *)tableColumn row:(int)row
-{
-  NSMutableArray *item;
-  int col;
-	
-  if (table_apps == nil) return;
-	
-  col = [[tableColumn identifier] intValue];
-	
-  item = [table_apps objectAtIndex:row];
-  [item replaceObjectAtIndex:col withObject:object];
-}
-
-- (void) hide_window:sender
-{
-  if ([X11App x_active])
-    QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMHideWindow);
-  else
-    NSBeep ();			/* FIXME: something here */
-}
-
-- (IBAction)bring_to_front:sender
-{
-  QuartzMessageServerThread(kXDarwinControllerNotify, 1, AppleWMBringAllToFront);
-}
-
-- (IBAction)close_window:sender
-{
-  if ([X11App x_active])
-    QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMCloseWindow);
-  else
-    [[NSApp keyWindow] performClose:sender];
-}
-
-- (IBAction)minimize_window:sender
-{
-  if ([X11App x_active])
-    QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMMinimizeWindow);
-  else
-    [[NSApp keyWindow] performMiniaturize:sender];
-}
-
-- (IBAction)zoom_window:sender
-{
-  if ([X11App x_active])
-    QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMZoomWindow);
-  else
-    [[NSApp keyWindow] performZoom:sender];
-}
-
-- (IBAction) next_window:sender
-{
-  QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMNextWindow);
-}
-
-- (IBAction) previous_window:sender
-{
-  QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMPreviousWindow);
-}
-
-- (IBAction) enable_fullscreen_changed:sender
-{
-  int value = ![enable_fullscreen intValue];
-	
-#ifdef DARWIN_DDX_MISSING
-  QuartzMessageServerThread (kXDarwinSetRootless, 1, value);
-#endif
-	
-  [NSApp prefs_set_boolean:@PREFS_ROOTLESS value:value];
-  [NSApp prefs_synchronize];
-}
-
-- (IBAction) toggle_fullscreen:sender
-{
-#ifdef DARWIN_DDX_MISSING
-  QuartzMessageServerThread (kXDarwinToggleFullscreen, 0);
-#endif
-}
-
-- (void) set_can_quit:(BOOL)state
-{
-  can_quit = state;
-}
-
-- (IBAction)prefs_changed:sender
-{
-  darwinFakeButtons = [fake_buttons intValue];
-  quartzUseSysBeep = [use_sysbeep intValue];
-  X11EnableKeyEquivalents = [enable_keyequivs intValue];
-  darwinSyncKeymap = [sync_keymap intValue];
-	
-  /* after adding prefs here, also add to [X11Application read_defaults]
-     and below */
-	
-  [NSApp prefs_set_boolean:@PREFS_FAKEBUTTONS value:darwinFakeButtons];
-  [NSApp prefs_set_boolean:@PREFS_SYSBEEP value:quartzUseSysBeep];
-  [NSApp prefs_set_boolean:@PREFS_KEYEQUIVS value:X11EnableKeyEquivalents];
-  [NSApp prefs_set_boolean:@PREFS_SYNC_KEYMAP value:darwinSyncKeymap];
-  [NSApp prefs_set_boolean:@PREFS_NO_AUTH value:![enable_auth intValue]];
-  [NSApp prefs_set_boolean:@PREFS_NO_TCP value:![enable_tcp intValue]];
-  [NSApp prefs_set_integer:@PREFS_DEPTH value:[depth selectedTag]];
-	
-  [NSApp prefs_synchronize];
-}
-
-- (IBAction) prefs_show:sender
-{
-  [fake_buttons setIntValue:darwinFakeButtons];
-  [use_sysbeep setIntValue:quartzUseSysBeep];
-  [enable_keyequivs setIntValue:X11EnableKeyEquivalents];
-  [sync_keymap setIntValue:darwinSyncKeymap];
-  [sync_keymap setEnabled:darwinKeymapFile == NULL];
-	
-  [enable_auth setIntValue:![NSApp prefs_get_boolean:@PREFS_NO_AUTH default:NO]];
-  [enable_tcp setIntValue:![NSApp prefs_get_boolean:@PREFS_NO_TCP default:NO]];
-  [depth selectItemAtIndex:[depth indexOfItemWithTag:[NSApp prefs_get_integer:@PREFS_DEPTH default:-1]]];
-	
-  [enable_fullscreen setIntValue:!quartzEnableRootless];
-	
-  [prefs_panel makeKeyAndOrderFront:sender];
-}
-
-- (IBAction) quit:sender
-{
-  QuartzMessageServerThread (kXDarwinQuit, 0);
-}
-
-- (IBAction) x11_help:sender
-{
-  AHLookupAnchor ((CFStringRef)NSLocalizedString(@"Mac Help", no comment), CFSTR ("mchlp2276"));
-}
-
-- (BOOL) validateMenuItem:(NSMenuItem *)item
-{
-  NSMenu *menu = [item menu];
-	
-  if (item == toggle_fullscreen_item)
-    return !quartzEnableRootless;
-  else if (menu == [window_separator menu] || menu == dock_menu
-	   || (menu == [x11_about_item menu] && [item tag] == 42))
-    return (AppleWMSelectedEvents () & AppleWMControllerNotifyMask) != 0;
-  else
-    return TRUE;
-}
-
-- (void) applicationDidHide:(NSNotification *)notify
-{
-  QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMHideAll);
-}
-
-- (void) applicationDidUnhide:(NSNotification *)notify
-{
-  QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMShowAll);
-}
-
-- (NSApplicationTerminateReply) applicationShouldTerminate:sender
-{
-  NSString *msg;
-	
-  if (can_quit || [X11App prefs_get_boolean:@PREFS_NO_QUIT_ALERT default:NO])
-    return NSTerminateNow;
-	
-  /* Make sure we're frontmost. */
-  [NSApp activateIgnoringOtherApps:YES];
-	
-  msg = NSLocalizedString (@"Are you sure you want to quit X11?\n\nIf you quit X11, any X11 applications you are running will stop immediately and you will lose any changes you have not saved.", @"Dialog when quitting");
-	
-  /* FIXME: safe to run the alert in here? Or should we return Later
-     and then run the alert on a timer? It seems to work here, so.. */
-	
-  return (NSRunAlertPanel (nil, msg, NSLocalizedString (@"Quit", @""),
-			   NSLocalizedString (@"Cancel", @""), nil)
-	  == NSAlertDefaultReturn) ? NSTerminateNow : NSTerminateCancel;
-}
-
-- (void) applicationWillTerminate:(NSNotification *)aNotification
-{
-  [X11App prefs_synchronize];
-	
-  /* shutdown the X server, it will exit () for us. */
-  QuartzMessageServerThread (kXDarwinQuit, 0);
-	
-  /* In case it doesn't, exit anyway after a while. */
-  while (sleep (10) != 0) ;
-  exit (1);
-}
-
-- (void) server_ready
-{
-  x_list *node;
-	
-  finished_launching = YES;
-	
-  for (node = pending_apps; node != NULL; node = node->next)
-    {
-      NSString *filename = node->data;
-      [self launch_client:filename];
-      [filename release];
-    }
-	
-  x_list_free (pending_apps);
-  pending_apps = NULL;
-}
-
-- (BOOL) application:(NSApplication *)app openFile:(NSString *)filename
-{
-  const char *name = [filename UTF8String];
-	
-  if (finished_launching)
-    [self launch_client:filename];
-  else if (name[0] != ':')		/* ignore display names */
-    pending_apps = x_list_prepend (pending_apps, [filename retain]);
-	
-  /* FIXME: report failures. */
-  return YES;
-}
-
- at end
-
-void X11ControllerMain (int argc, const char *argv[],
-			void (*server_thread) (void *), void *server_arg)
-{
-  X11ApplicationMain (argc, argv, server_thread, server_arg);
-}
diff --git a/hw/darwin/quartz/apple/English.lproj/InfoPlist.strings b/hw/darwin/quartz/apple/English.lproj/InfoPlist.strings
deleted file mode 100644
index 88e1f04..0000000
Binary files a/hw/darwin/quartz/apple/English.lproj/InfoPlist.strings and /dev/null differ
diff --git a/hw/darwin/quartz/apple/English.lproj/Localizable.strings b/hw/darwin/quartz/apple/English.lproj/Localizable.strings
deleted file mode 100644
index c83b085..0000000
Binary files a/hw/darwin/quartz/apple/English.lproj/Localizable.strings and /dev/null differ
diff --git a/hw/darwin/quartz/apple/English.lproj/main.nib/classes.nib b/hw/darwin/quartz/apple/English.lproj/main.nib/classes.nib
deleted file mode 100644
index a82159b..0000000
--- a/hw/darwin/quartz/apple/English.lproj/main.nib/classes.nib
+++ /dev/null
@@ -1,318 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>IBClasses</key>
-	<array>
-		<dict>
-			<key>CLASS</key>
-			<string>IBLibraryObjectTemplate</string>
-			<key>LANGUAGE</key>
-			<string>ObjC</string>
-			<key>OUTLETS</key>
-			<dict>
-				<key>draggedView</key>
-				<string>NSView</string>
-				<key>representedObject</key>
-				<string>NSObject</string>
-			</dict>
-			<key>SUPERCLASS</key>
-			<string>NSView</string>
-		</dict>
-		<dict>
-			<key>CLASS</key>
-			<string>IBInspector</string>
-			<key>LANGUAGE</key>
-			<string>ObjC</string>
-			<key>OUTLETS</key>
-			<dict>
-				<key>inspectorView</key>
-				<string>NSView</string>
-			</dict>
-			<key>SUPERCLASS</key>
-			<string>NSObject</string>
-		</dict>
-		<dict>
-			<key>CLASS</key>
-			<string>NSDateFormatter</string>
-			<key>LANGUAGE</key>
-			<string>ObjC</string>
-			<key>SUPERCLASS</key>
-			<string>NSFormatter</string>
-		</dict>
-		<dict>
-			<key>ACTIONS</key>
-			<dict>
-				<key>apps_table_cancel</key>
-				<string>id</string>
-				<key>apps_table_delete</key>
-				<string>id</string>
-				<key>apps_table_done</key>
-				<string>id</string>
-				<key>apps_table_duplicate</key>
-				<string>id</string>
-				<key>apps_table_new</key>
-				<string>id</string>
-				<key>apps_table_show</key>
-				<string>id</string>
-				<key>bring_to_front</key>
-				<string>id</string>
-				<key>close_window</key>
-				<string>id</string>
-				<key>enable_fullscreen_changed</key>
-				<string>id</string>
-				<key>minimize_window</key>
-				<string>id</string>
-				<key>next_window</key>
-				<string>id</string>
-				<key>prefs_changed</key>
-				<string>id</string>
-				<key>prefs_show</key>
-				<string>id</string>
-				<key>previous_window</key>
-				<string>id</string>
-				<key>toggle_fullscreen</key>
-				<string>id</string>
-				<key>x11_help</key>
-				<string>id</string>
-				<key>zoom_window</key>
-				<string>id</string>
-			</dict>
-			<key>CLASS</key>
-			<string>X11Controller</string>
-			<key>LANGUAGE</key>
-			<string>ObjC</string>
-			<key>OUTLETS</key>
-			<dict>
-				<key>apps_separator</key>
-				<string>id</string>
-				<key>apps_table</key>
-				<string>id</string>
-				<key>depth</key>
-				<string>id</string>
-				<key>dock_apps_menu</key>
-				<string>id</string>
-				<key>dock_menu</key>
-				<string>id</string>
-				<key>dock_window_separator</key>
-				<string>id</string>
-				<key>enable_auth</key>
-				<string>id</string>
-				<key>enable_fullscreen</key>
-				<string>id</string>
-				<key>enable_keyequivs</key>
-				<string>id</string>
-				<key>enable_tcp</key>
-				<string>id</string>
-				<key>fake_buttons</key>
-				<string>id</string>
-				<key>prefs_panel</key>
-				<string>id</string>
-				<key>sync_keymap</key>
-				<string>id</string>
-				<key>toggle_fullscreen_item</key>
-				<string>id</string>
-				<key>use_sysbeep</key>
-				<string>id</string>
-				<key>window_separator</key>
-				<string>id</string>
-				<key>x11_about_item</key>
-				<string>id</string>
-			</dict>
-			<key>SUPERCLASS</key>
-			<string>NSObject</string>
-		</dict>
-		<dict>
-			<key>CLASS</key>
-			<string>NSNumberFormatter</string>
-			<key>LANGUAGE</key>
-			<string>ObjC</string>
-			<key>SUPERCLASS</key>
-			<string>NSFormatter</string>
-		</dict>
-		<dict>
-			<key>CLASS</key>
-			<string>NSFormatter</string>
-			<key>LANGUAGE</key>
-			<string>ObjC</string>
-			<key>SUPERCLASS</key>
-			<string>NSObject</string>
-		</dict>
-		<dict>
-			<key>ACTIONS</key>
-			<dict>
-				<key>alignCenter:</key>
-				<string>id</string>
-				<key>alignJustified:</key>
-				<string>id</string>
-				<key>alignLeft:</key>
-				<string>id</string>
-				<key>alignRight:</key>
-				<string>id</string>
-				<key>arrangeInFront:</key>
-				<string>id</string>
-				<key>centerSelectionInVisibleArea:</key>
-				<string>id</string>
-				<key>changeFont:</key>
-				<string>id</string>
-				<key>checkSpelling:</key>
-				<string>id</string>
-				<key>clear:</key>
-				<string>id</string>
-				<key>clearRecentDocuments:</key>
-				<string>id</string>
-				<key>complete:</key>
-				<string>id</string>
-				<key>copy:</key>
-				<string>id</string>
-				<key>copyFont:</key>
-				<string>id</string>
-				<key>copyRuler:</key>
-				<string>id</string>
-				<key>cut:</key>
-				<string>id</string>
-				<key>delete:</key>
-				<string>id</string>
-				<key>deminiaturize:</key>
-				<string>id</string>
-				<key>fax:</key>
-				<string>id</string>
-				<key>hide:</key>
-				<string>id</string>
-				<key>hideOtherApplications:</key>
-				<string>id</string>
-				<key>loosenKerning:</key>
-				<string>id</string>
-				<key>lowerBaseline:</key>
-				<string>id</string>
-				<key>makeKeyAndOrderFront:</key>
-				<string>id</string>
-				<key>miniaturize:</key>
-				<string>id</string>
-				<key>newDocument:</key>
-				<string>id</string>
-				<key>openDocument:</key>
-				<string>id</string>
-				<key>orderBack:</key>
-				<string>id</string>
-				<key>orderFront:</key>
-				<string>id</string>
-				<key>orderFrontColorPanel:</key>
-				<string>id</string>
-				<key>orderFrontHelpPanel:</key>
-				<string>id</string>
-				<key>orderOut:</key>
-				<string>id</string>
-				<key>outline:</key>
-				<string>id</string>
-				<key>paste:</key>
-				<string>id</string>
-				<key>pasteAsPlainText:</key>
-				<string>id</string>
-				<key>pasteAsRichText:</key>
-				<string>id</string>
-				<key>pasteFont:</key>
-				<string>id</string>
-				<key>pasteRuler:</key>
-				<string>id</string>
-				<key>pause:</key>
-				<string>id</string>
-				<key>performClose:</key>
-				<string>id</string>
-				<key>performFindPanelAction:</key>
-				<string>id</string>
-				<key>performMiniaturize:</key>
-				<string>id</string>
-				<key>performZoom:</key>
-				<string>id</string>
-				<key>play:</key>
-				<string>id</string>
-				<key>print:</key>
-				<string>id</string>
-				<key>printDocument:</key>
-				<string>id</string>
-				<key>raiseBaseline:</key>
-				<string>id</string>
-				<key>record:</key>
-				<string>id</string>
-				<key>redo:</key>
-				<string>id</string>
-				<key>resume:</key>
-				<string>id</string>
-				<key>revertDocumentToSaved:</key>
-				<string>id</string>
-				<key>run:</key>
-				<string>id</string>
-				<key>runPageLayout:</key>
-				<string>id</string>
-				<key>runToolbarCustomizationPalette:</key>
-				<string>id</string>
-				<key>saveAllDocuments:</key>
-				<string>id</string>
-				<key>saveDocument:</key>
-				<string>id</string>
-				<key>saveDocumentAs:</key>
-				<string>id</string>
-				<key>saveDocumentTo:</key>
-				<string>id</string>
-				<key>selectAll:</key>
-				<string>id</string>
-				<key>selectText:</key>
-				<string>id</string>
-				<key>showGuessPanel:</key>
-				<string>id</string>
-				<key>showHelp:</key>
-				<string>id</string>
-				<key>start:</key>
-				<string>id</string>
-				<key>startSpeaking:</key>
-				<string>id</string>
-				<key>stop:</key>
-				<string>id</string>
-				<key>stopSpeaking:</key>
-				<string>id</string>
-				<key>subscript:</key>
-				<string>id</string>
-				<key>superscript:</key>
-				<string>id</string>
-				<key>terminate:</key>
-				<string>id</string>
-				<key>tightenKerning:</key>
-				<string>id</string>
-				<key>toggleContinuousSpellChecking:</key>
-				<string>id</string>
-				<key>toggleRuler:</key>
-				<string>id</string>
-				<key>toggleToolbarShown:</key>
-				<string>id</string>
-				<key>turnOffKerning:</key>
-				<string>id</string>
-				<key>turnOffLigatures:</key>
-				<string>id</string>
-				<key>underline:</key>
-				<string>id</string>
-				<key>undo:</key>
-				<string>id</string>
-				<key>unhideAllApplications:</key>
-				<string>id</string>
-				<key>unscript:</key>
-				<string>id</string>
-				<key>useAllLigatures:</key>
-				<string>id</string>
-				<key>useStandardKerning:</key>
-				<string>id</string>
-				<key>useStandardLigatures:</key>
-				<string>id</string>
-			</dict>
-			<key>CLASS</key>
-			<string>FirstResponder</string>
-			<key>LANGUAGE</key>
-			<string>ObjC</string>
-			<key>SUPERCLASS</key>
-			<string>NSObject</string>
-		</dict>
-	</array>
-	<key>IBVersion</key>
-	<integer>1</integer>
-</dict>
-</plist>
diff --git a/hw/darwin/quartz/apple/English.lproj/main.nib/info.nib b/hw/darwin/quartz/apple/English.lproj/main.nib/info.nib
deleted file mode 100644
index 88bc626..0000000
--- a/hw/darwin/quartz/apple/English.lproj/main.nib/info.nib
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>IBFramework Version</key>
-	<string>588</string>
-	<key>IBOpenObjects</key>
-	<array>
-		<integer>244</integer>
-		<integer>29</integer>
-		<integer>423</integer>
-	</array>
-	<key>IBSystem Version</key>
-	<string>9A356</string>
-	<key>targetFramework</key>
-	<string>IBCocoaFramework</string>
-</dict>
-</plist>
diff --git a/hw/darwin/quartz/apple/English.lproj/main.nib/keyedobjects.nib b/hw/darwin/quartz/apple/English.lproj/main.nib/keyedobjects.nib
deleted file mode 100644
index 8b31450..0000000
Binary files a/hw/darwin/quartz/apple/English.lproj/main.nib/keyedobjects.nib and /dev/null differ
diff --git a/hw/darwin/quartz/apple/Info.plist b/hw/darwin/quartz/apple/Info.plist
deleted file mode 100644
index 66f1f6b..0000000
--- a/hw/darwin/quartz/apple/Info.plist
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>CFBundleDevelopmentRegion</key>
-	<string>English</string>
-	<key>CFBundleExecutable</key>
-	<string>X11</string>
-	<key>CFBundleGetInfoString</key>
-	<string>X11</string>
-	<key>CFBundleIconFile</key>
-	<string>X11.icns</string>
-	<key>CFBundleIdentifier</key>
-	<string>org.x.X11</string>
-	<key>CFBundleInfoDictionaryVersion</key>
-	<string>6.0</string>
-	<key>CFBundleName</key>
-	<string>X11</string>
-	<key>CFBundlePackageType</key>
-	<string>APPL</string>
-	<key>CFBundleShortVersionString</key>
-	<string>2.0</string>
-	<key>CFBundleSignature</key>
-	<string>x11a</string>
-	<key>CSResourcesFileMapped</key>
-	<true/>
-	<key>NSHumanReadableCopyright</key>
-	<string>Copyright © 2003-2007, Apple Inc.
-Copyright © 2003, XFree86 Project, Inc.</string>
-	<key>NSMainNibFile</key>
-	<string>main</string>
-	<key>NSPrincipalClass</key>
-	<string>X11Application</string>
-</dict>
-</plist>
diff --git a/hw/darwin/quartz/apple/Makefile.am b/hw/darwin/quartz/apple/Makefile.am
deleted file mode 100644
index a6e2dfb..0000000
--- a/hw/darwin/quartz/apple/Makefile.am
+++ /dev/null
@@ -1,28 +0,0 @@
-bin_SCRIPTS = x11app
-
-.PHONY: x11app
-
-x11app:
-	xcodebuild CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" ARCHS="$(X11APP_ARCHS)"
-
-install-data-hook:
-	xcodebuild install DSTROOT="/$(DESTDIR)" INSTALL_PATH="$(APPLE_APPLICATIONS_DIR)" DEPLOYMENT_LOCATION=YES SKIP_INSTALL=NO ARCHS="$(X11APP_ARCHS)"
-	$(MKDIR_P) "$(DESTDIR)/System/Library/LaunchAgents/"
-	$(INSTALL) org.x.X11.plist "$(DESTDIR)/System/Library/LaunchAgents/"
-
-clean-local:
-	rm -rf build
-
-EXTRA_DIST = \
-	org.x.X11.plist \
-	Info.plist \
-	X11.icns \
-	bundle-main.c \
-	launcher-main.c \
-	server-main.c \
-	English.lproj/InfoPlist.strings \
-	English.lproj/Localizable.strings \
-	English.lproj/main.nib/classes.nib \
-	English.lproj/main.nib/info.nib \
-	English.lproj/main.nib/keyedobjects.nib \
-	X11.xcodeproj/project.pbxproj
diff --git a/hw/darwin/quartz/apple/X11.icns b/hw/darwin/quartz/apple/X11.icns
deleted file mode 100644
index d770e61..0000000
Binary files a/hw/darwin/quartz/apple/X11.icns and /dev/null differ
diff --git a/hw/darwin/quartz/apple/X11.xcodeproj/project.pbxproj b/hw/darwin/quartz/apple/X11.xcodeproj/project.pbxproj
deleted file mode 100644
index 225f371..0000000
--- a/hw/darwin/quartz/apple/X11.xcodeproj/project.pbxproj
+++ /dev/null
@@ -1,344 +0,0 @@
-// !$*UTF8*$!
-{
-	archiveVersion = 1;
-	classes = {
-	};
-	objectVersion = 42;
-	objects = {
-
-/* Begin PBXBuildFile section */
-		3F5E1BE00D04BF110020CA24 /* launcher-main.c in Sources */ = {isa = PBXBuildFile; fileRef = 3F5E1BDE0D04BF110020CA24 /* launcher-main.c */; };
-		3F5E1BE10D04BF110020CA24 /* server-main.c in Sources */ = {isa = PBXBuildFile; fileRef = 3F5E1BDF0D04BF110020CA24 /* server-main.c */; };
-		527F24190B5D938C007840A7 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0867D6AAFE840B52C02AAC07 /* InfoPlist.strings */; };
-		527F241A0B5D938C007840A7 /* main.nib in Resources */ = {isa = PBXBuildFile; fileRef = 02345980000FD03B11CA0E72 /* main.nib */; };
-		527F241B0B5D938C007840A7 /* X11.icns in Resources */ = {isa = PBXBuildFile; fileRef = 50459C5F038587C60ECA21EC /* X11.icns */; };
-		527F241D0B5D938C007840A7 /* bundle-main.c in Sources */ = {isa = PBXBuildFile; fileRef = 50EE2AB703849F0B0ECA21EC /* bundle-main.c */; };
-		527F241F0B5D938C007840A7 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50F4F0A7039D6ACA0E82C0CB /* CoreFoundation.framework */; };
-		527F24200B5D938C007840A7 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 570C5748047186C400ACF82F /* SystemConfiguration.framework */; };
-		527F24370B5D9D89007840A7 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 527F24260B5D938C007840A7 /* Info.plist */; };
-		52D9C0ED0BCDDF6B00CD2AFC /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 52D9C0EB0BCDDF6B00CD2AFC /* Localizable.strings */; };
-/* End PBXBuildFile section */
-
-/* Begin PBXFileReference section */
-		0867D6ABFE840B52C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
-		1870340FFE93FCAF11CA0CD7 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/main.nib; sourceTree = "<group>"; };
-		3F5E1BDE0D04BF110020CA24 /* launcher-main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "launcher-main.c"; sourceTree = "<group>"; };
-		3F5E1BDF0D04BF110020CA24 /* server-main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "server-main.c"; sourceTree = "<group>"; };
-		50459C5F038587C60ECA21EC /* X11.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = X11.icns; sourceTree = "<group>"; };
-		50EE2AB703849F0B0ECA21EC /* bundle-main.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = "bundle-main.c"; sourceTree = "<group>"; };
-		50F4F0A7039D6ACA0E82C0CB /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = "<absolute>"; };
-		527F24260B5D938C007840A7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = Info.plist; sourceTree = "<group>"; };
-		527F24270B5D938C007840A7 /* X11.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = X11.app; sourceTree = BUILT_PRODUCTS_DIR; };
-		52D9C0EC0BCDDF6B00CD2AFC /* English */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/Localizable.strings; sourceTree = "<group>"; };
-		570C5748047186C400ACF82F /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = /System/Library/Frameworks/SystemConfiguration.framework; sourceTree = "<absolute>"; };
-/* End PBXFileReference section */
-
-/* Begin PBXFrameworksBuildPhase section */
-		527F241E0B5D938C007840A7 /* Frameworks */ = {
-			isa = PBXFrameworksBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-				527F241F0B5D938C007840A7 /* CoreFoundation.framework in Frameworks */,
-				527F24200B5D938C007840A7 /* SystemConfiguration.framework in Frameworks */,
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-/* End PBXFrameworksBuildPhase section */
-
-/* Begin PBXGroup section */
-		195DF8CFFE9D517E11CA2CBB /* Products */ = {
-			isa = PBXGroup;
-			children = (
-				527F24270B5D938C007840A7 /* X11.app */,
-			);
-			name = Products;
-			sourceTree = "<group>";
-		};
-		20286C29FDCF999611CA2CEA /* X11 */ = {
-			isa = PBXGroup;
-			children = (
-				20286C2AFDCF999611CA2CEA /* Sources */,
-				20286C2CFDCF999611CA2CEA /* Resources */,
-				20286C32FDCF999611CA2CEA /* External Frameworks and Libraries */,
-				195DF8CFFE9D517E11CA2CBB /* Products */,
-				527F24260B5D938C007840A7 /* Info.plist */,
-			);
-			name = X11;
-			sourceTree = "<group>";
-		};
-		20286C2AFDCF999611CA2CEA /* Sources */ = {
-			isa = PBXGroup;
-			children = (
-				3F5E1BDE0D04BF110020CA24 /* launcher-main.c */,
-				3F5E1BDF0D04BF110020CA24 /* server-main.c */,
-				50EE2AB703849F0B0ECA21EC /* bundle-main.c */,
-			);
-			name = Sources;
-			sourceTree = "<group>";
-		};
-		20286C2CFDCF999611CA2CEA /* Resources */ = {
-			isa = PBXGroup;
-			children = (
-				52D9C0EB0BCDDF6B00CD2AFC /* Localizable.strings */,
-				50459C5F038587C60ECA21EC /* X11.icns */,
-				0867D6AAFE840B52C02AAC07 /* InfoPlist.strings */,
-				02345980000FD03B11CA0E72 /* main.nib */,
-			);
-			name = Resources;
-			sourceTree = "<group>";
-		};
-		20286C32FDCF999611CA2CEA /* External Frameworks and Libraries */ = {
-			isa = PBXGroup;
-			children = (
-				50F4F0A7039D6ACA0E82C0CB /* CoreFoundation.framework */,
-				570C5748047186C400ACF82F /* SystemConfiguration.framework */,
-			);
-			name = "External Frameworks and Libraries";
-			sourceTree = "<group>";
-		};
-/* End PBXGroup section */
-
-/* Begin PBXHeadersBuildPhase section */
-		527F24170B5D938C007840A7 /* Headers */ = {
-			isa = PBXHeadersBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-/* End PBXHeadersBuildPhase section */
-
-/* Begin PBXNativeTarget section */
-		527F24160B5D938C007840A7 /* X11 */ = {
-			isa = PBXNativeTarget;
-			buildConfigurationList = 527F24220B5D938C007840A7 /* Build configuration list for PBXNativeTarget "X11" */;
-			buildPhases = (
-				527F24170B5D938C007840A7 /* Headers */,
-				527F24180B5D938C007840A7 /* Resources */,
-				527F241C0B5D938C007840A7 /* Sources */,
-				527F241E0B5D938C007840A7 /* Frameworks */,
-				527F24210B5D938C007840A7 /* Rez */,
-			);
-			buildRules = (
-			);
-			dependencies = (
-			);
-			name = X11;
-			productName = X11;
-			productReference = 527F24270B5D938C007840A7 /* X11.app */;
-			productType = "com.apple.product-type.application";
-		};
-/* End PBXNativeTarget section */
-
-/* Begin PBXProject section */
-		20286C28FDCF999611CA2CEA /* Project object */ = {
-			isa = PBXProject;
-			buildConfigurationList = 527F24080B5D8FFC007840A7 /* Build configuration list for PBXProject "X11" */;
-			compatibilityVersion = "Xcode 2.4";
-			hasScannedForEncodings = 1;
-			mainGroup = 20286C29FDCF999611CA2CEA /* X11 */;
-			projectDirPath = "";
-			projectRoot = "";
-			targets = (
-				527F24160B5D938C007840A7 /* X11 */,
-			);
-		};
-/* End PBXProject section */
-
-/* Begin PBXResourcesBuildPhase section */
-		527F24180B5D938C007840A7 /* Resources */ = {
-			isa = PBXResourcesBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-				527F24370B5D9D89007840A7 /* Info.plist in Resources */,
-				527F24190B5D938C007840A7 /* InfoPlist.strings in Resources */,
-				527F241A0B5D938C007840A7 /* main.nib in Resources */,
-				527F241B0B5D938C007840A7 /* X11.icns in Resources */,
-				52D9C0ED0BCDDF6B00CD2AFC /* Localizable.strings in Resources */,
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-/* End PBXResourcesBuildPhase section */
-
-/* Begin PBXRezBuildPhase section */
-		527F24210B5D938C007840A7 /* Rez */ = {
-			isa = PBXRezBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-/* End PBXRezBuildPhase section */
-
-/* Begin PBXSourcesBuildPhase section */
-		527F241C0B5D938C007840A7 /* Sources */ = {
-			isa = PBXSourcesBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-				527F241D0B5D938C007840A7 /* bundle-main.c in Sources */,
-				3F5E1BE00D04BF110020CA24 /* launcher-main.c in Sources */,
-				3F5E1BE10D04BF110020CA24 /* server-main.c in Sources */,
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-/* End PBXSourcesBuildPhase section */
-
-/* Begin PBXVariantGroup section */
-		02345980000FD03B11CA0E72 /* main.nib */ = {
-			isa = PBXVariantGroup;
-			children = (
-				1870340FFE93FCAF11CA0CD7 /* English */,
-			);
-			name = main.nib;
-			sourceTree = "<group>";
-		};
-		0867D6AAFE840B52C02AAC07 /* InfoPlist.strings */ = {
-			isa = PBXVariantGroup;
-			children = (
-				0867D6ABFE840B52C02AAC07 /* English */,
-			);
-			name = InfoPlist.strings;
-			sourceTree = "<group>";
-		};
-		52D9C0EB0BCDDF6B00CD2AFC /* Localizable.strings */ = {
-			isa = PBXVariantGroup;
-			children = (
-				52D9C0EC0BCDDF6B00CD2AFC /* English */,
-			);
-			name = Localizable.strings;
-			sourceTree = "<group>";
-		};
-/* End PBXVariantGroup section */
-
-/* Begin XCBuildConfiguration section */
-		527F24090B5D8FFC007840A7 /* Development */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				INSTALL_MODE_FLAG = "a+rX";
-			};
-			name = Development;
-		};
-		527F240A0B5D8FFC007840A7 /* Deployment */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				INSTALL_MODE_FLAG = "a+rX";
-			};
-			name = Deployment;
-		};
-		527F240B0B5D8FFC007840A7 /* Default */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				INSTALL_MODE_FLAG = "a+rX";
-			};
-			name = Default;
-		};
-		527F24230B5D938C007840A7 /* Development */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				COPY_PHASE_STRIP = NO;
-				FRAMEWORK_SEARCH_PATHS = "";
-				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
-				HEADER_SEARCH_PATHS = /usr/X11/include;
-				INFOPLIST_FILE = Info.plist;
-				INSTALL_PATH = /usr/X11;
-				LIBRARY_SEARCH_PATHS = /usr/X11/lib;
-				OTHER_CFLAGS = "";
-				OTHER_LDFLAGS = (
-					"-lXau",
-					"-lxcb",
-					"-lX11",
-				);
-				OTHER_REZFLAGS = "";
-				PRODUCT_NAME = X11;
-				SECTORDER_FLAGS = "";
-				WARNING_CFLAGS = (
-					"-Wmost",
-					"-Wno-four-char-constants",
-					"-Wno-unknown-pragmas",
-				);
-				WRAPPER_EXTENSION = app;
-			};
-			name = Development;
-		};
-		527F24240B5D938C007840A7 /* Deployment */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				COPY_PHASE_STRIP = YES;
-				FRAMEWORK_SEARCH_PATHS = "";
-				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
-				HEADER_SEARCH_PATHS = /usr/X11/include;
-				INFOPLIST_FILE = Info.plist;
-				INSTALL_PATH = /usr/X11;
-				LIBRARY_SEARCH_PATHS = /usr/X11/lib;
-				OTHER_CFLAGS = "";
-				OTHER_LDFLAGS = (
-					"-lXau",
-					"-lxcb",
-					"-lX11",
-				);
-				OTHER_REZFLAGS = "";
-				PRODUCT_NAME = X11;
-				SECTORDER_FLAGS = "";
-				WARNING_CFLAGS = (
-					"-Wmost",
-					"-Wno-four-char-constants",
-					"-Wno-unknown-pragmas",
-				);
-				WRAPPER_EXTENSION = app;
-			};
-			name = Deployment;
-		};
-		527F24250B5D938C007840A7 /* Default */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				FRAMEWORK_SEARCH_PATHS = "";
-				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
-				HEADER_SEARCH_PATHS = /usr/X11/include;
-				INFOPLIST_FILE = Info.plist;
-				INSTALL_PATH = /usr/X11;
-				LIBRARY_SEARCH_PATHS = /usr/X11/lib;
-				OTHER_CFLAGS = "";
-				OTHER_LDFLAGS = (
-					"-lXau",
-					"-lxcb",
-					"-lX11",
-				);
-				OTHER_REZFLAGS = "";
-				PRODUCT_NAME = X11;
-				SECTORDER_FLAGS = "";
-				WARNING_CFLAGS = (
-					"-Wmost",
-					"-Wno-four-char-constants",
-					"-Wno-unknown-pragmas",
-				);
-				WRAPPER_EXTENSION = app;
-			};
-			name = Default;
-		};
-/* End XCBuildConfiguration section */
-
-/* Begin XCConfigurationList section */
-		527F24080B5D8FFC007840A7 /* Build configuration list for PBXProject "X11" */ = {
-			isa = XCConfigurationList;
-			buildConfigurations = (
-				527F24090B5D8FFC007840A7 /* Development */,
-				527F240A0B5D8FFC007840A7 /* Deployment */,
-				527F240B0B5D8FFC007840A7 /* Default */,
-			);
-			defaultConfigurationIsVisible = 0;
-			defaultConfigurationName = Default;
-		};
-		527F24220B5D938C007840A7 /* Build configuration list for PBXNativeTarget "X11" */ = {
-			isa = XCConfigurationList;
-			buildConfigurations = (
-				527F24230B5D938C007840A7 /* Development */,
-				527F24240B5D938C007840A7 /* Deployment */,
-				527F24250B5D938C007840A7 /* Default */,
-			);
-			defaultConfigurationIsVisible = 0;
-			defaultConfigurationName = Default;
-		};
-/* End XCConfigurationList section */
-	};
-	rootObject = 20286C28FDCF999611CA2CEA /* Project object */;
-}
diff --git a/hw/darwin/quartz/apple/bundle-main.c b/hw/darwin/quartz/apple/bundle-main.c
deleted file mode 100644
index c436d51..0000000
--- a/hw/darwin/quartz/apple/bundle-main.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/* main.c -- X application launcher
- 
- Copyright (c) 2007 Jeremy Huddleston
- Copyright (c) 2007 Apple Inc
- 
- 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 <X11/Xlib.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <string.h>
-
-int launcher_main(int argc, char **argv);
-int server_main(int argc, char **argv);
-
-int main(int argc, char **argv) {
-    Display *display;
-  
-    fprintf(stderr, "X11.app: main(): argc=%d\n", argc);
-    int i;
-    for(i=0; i < argc; i++) {
-        fprintf(stderr, "\targv[%d] = %s\n", i, argv[i]);
-    }
-    
-    /* First check if launchd started us */
-    if(argc == 2 && !strncmp(argv[1], "--launchd", 9)) {
-        argc--;
-        argv[1] = argv[0];
-        argv++;
-        fprintf(stderr, "X11.app: main(): launchd called us, running server_main()");
-        return server_main(argc, argv);
-    }
-
-    /* If we have a process serial number and it's our only arg, act as if
-     * the user double clicked the app bundle: launch app_to_run if possible
-     */
-    if(argc == 1 || (argc == 2 && !strncmp(argv[1], "-psn_", 5))) {
-        /* Now, try to open a display, if so, run the launcher */
-        display = XOpenDisplay(NULL);
-        if(display) {
-            fprintf(stderr, "X11.app: main(): closing the display");
-            /* Could open the display, start the launcher */
-            XCloseDisplay(display);
-
-            /* Give 2 seconds for the server to start... 
-             * TODO: *Really* fix this race condition
-             */
-            usleep(2000);
-            fprintf(stderr, "X11.app: main(): running launcher_main()");
-            return launcher_main(argc, argv);
-        }
-    }
-
-    /* Couldn't open the display or we were called with arguments,
-     * just want to start a server.
-     */
-    fprintf(stderr, "X11.app: main(): running server_main()");
-    return server_main(argc, argv);
-}
diff --git a/hw/darwin/quartz/apple/launcher-main.c b/hw/darwin/quartz/apple/launcher-main.c
deleted file mode 100644
index 60a1624..0000000
--- a/hw/darwin/quartz/apple/launcher-main.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/* main.c -- X application launcher
- 
- Copyright (c) 2007 Apple Inc.
- 
- 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 <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-
-#include <CoreFoundation/CoreFoundation.h>
-
-#define DEFAULT_APP "/usr/X11/bin/xterm"
-
-int launcher_main (int argc, char **argv) {
-  char *command = DEFAULT_APP;
-  const char *newargv[7];
-  int child;
-  
-
-	CFPropertyListRef PlistRef = CFPreferencesCopyAppValue(CFSTR("app_to_run"),
-									kCFPreferencesCurrentApplication);
-	
-	if ((PlistRef == NULL) || (CFGetTypeID(PlistRef) != CFStringGetTypeID())) {
-		CFPreferencesSetAppValue(CFSTR("app_to_run"), CFSTR(DEFAULT_APP), 
-								 kCFPreferencesCurrentApplication);
-		CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
-	} else {
-		int len = CFStringGetLength((CFStringRef)PlistRef)+1;
-		command = (char *) malloc(len);
-		CFStringGetCString((CFStringRef)PlistRef, command, len,  kCFStringEncodingASCII);
-		fprintf(stderr, "command=%s\n", command);
-	}
-	
-	if (PlistRef) CFRelease(PlistRef);
-	
-	newargv[0] = "/usr/bin/login";
-	newargv[1] = "-fp";
-	newargv[2] = getlogin();
-	newargv[3] = "/bin/sh";
-	newargv[4] = "-c";
-	newargv[5] = command;
-	newargv[6] = NULL;
-
-    child = fork();
-	
-    switch (child) {
-    case -1:				/* error */
-      perror ("fork");
-      return EXIT_FAILURE;		
-    case 0:				    /* child */
-      execvp (newargv[0], (char **const) newargv);
-      perror ("Couldn't exec");
-      _exit (1);
-   }
-	
-    return 0;
-}
diff --git a/hw/darwin/quartz/apple/org.x.X11.plist b/hw/darwin/quartz/apple/org.x.X11.plist
deleted file mode 100644
index 6c6be91..0000000
--- a/hw/darwin/quartz/apple/org.x.X11.plist
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>Label</key>
-		<string>org.x.X11</string>
-	<key>Program</key>
-		<string>/Applications/Utilities/X11.app/Contents/MacOS/X11</string>
-	<key>ProgramArguments</key>
-		<array>
-		<string>/Applications/Utilities/X11.app/Contents/MacOS/X11</string>
-		<string>--launchd</string>
-		</array>
-	<key>Sockets</key>
-		<dict>
-		<key>:0</key>
-			<dict>
-			<key>SecureSocketWithKey</key>
-				<string>DISPLAY</string>
-			</dict>
-		</dict>
-	<key>ServiceIPC</key>
-		<true/>
-</dict>
-</plist>
diff --git a/hw/darwin/quartz/apple/server-main.c b/hw/darwin/quartz/apple/server-main.c
deleted file mode 100644
index 26fcbb0..0000000
--- a/hw/darwin/quartz/apple/server-main.c
+++ /dev/null
@@ -1,904 +0,0 @@
-/* bundle-main.c -- X server launcher
- 
- Copyright (c) 2002-2007 Apple Inc. 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 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.
- 
- Parts of this file are derived from xdm, which has this copyright:
- 
- Copyright 1988, 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. */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/socket.h>
-#include <sys/utsname.h>
-#include <ifaddrs.h>
-#include <netdb.h>
-#include <netinet/in.h>
-#include <time.h>
-#include <sys/wait.h>
-#include <setjmp.h>
-#include <sys/ioctl.h>
-
-#include <X11/Xlib.h>
-#include <X11/Xauth.h>
-#include <xcb/xcb.h>
-
-#include <CoreFoundation/CoreFoundation.h>
-#include <SystemConfiguration/SystemConfiguration.h>
-
-#define X_SERVER "/usr/X11/bin/Xquartz"
-#define XTERM_PATH "/usr/X11/bin/xterm"
-#define WM_PATH "/usr/bin/quartz-wm"
-#define DEFAULT_XINITRC "/usr/X11/lib/X11/xinit/xinitrc"
-#define DEFAULT_PATH "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11/bin"
-
-/* what xinit does */
-#ifndef SHELL
-# define SHELL "sh"
-#endif
-
-#undef FALSE
-#define FALSE 0
-#undef TRUE
-#define TRUE 1
-
-#define MAX_DISPLAYS 64
-
-static int server_pid = -1, client_pid = -1;
-static int xinit_kills_server = FALSE;
-static jmp_buf exit_continuation;
-static const char *server_name = NULL;
-static Display *server_dpy;
-
-static char *auth_file;
-
-typedef struct addr_list_struct addr_list;
-
-struct addr_list_struct {
-    addr_list *next;
-    Xauth auth;
-};
-
-static addr_list *addresses;
-
-
-/* Utility functions. */
-
-/* Return the current host name. Matches what Xlib does. */
-static char *
-host_name (void)
-{
-#ifdef NEED_UTSNAME
-    static struct utsname name;
-	
-    uname(&name);
-	
-    return name.nodename;
-#else
-    static char buf[100];
-	
-    gethostname(buf, sizeof(buf));
-	
-    return buf;
-#endif
-}
-
-static int
-read_boolean_pref (CFStringRef name, int default_)
-{
-    int value;
-    Boolean ok;
-	
-    value = CFPreferencesGetAppBooleanValue (name,
-											 CFSTR ("com.apple.x11"), &ok);
-    return ok ? value : default_;
-}
-
-static inline int
-binary_equal (const void *a, const void *b, int length)
-{
-    return memcmp (a, b, length) == 0;
-}
-
-static inline void *
-binary_dup (const void *a, int length)
-{
-    void *b = malloc (length);
-    if (b != NULL)
-		memcpy (b, a, length);
-    return b;
-}
-
-static inline void
-binary_free (void *data, int length)
-{
-    if (data != NULL)
-		free (data);
-}
-
-
-/* Functions for managing the authentication entries. */
-
-/* Returns true if something matching AUTH is in our list of auth items */
-static int
-check_auth_item (Xauth *auth)
-{
-    addr_list *a;
-	
-    for (a = addresses; a != NULL; a = a->next)
-    {
-		if (a->auth.family == auth->family
-			&& a->auth.address_length == auth->address_length
-			&& binary_equal (a->auth.address, auth->address, auth->address_length)
-			&& a->auth.number_length == auth->number_length
-			&& binary_equal (a->auth.number, auth->number, auth->number_length)
-			&& a->auth.name_length == auth->name_length
-			&& binary_equal (a->auth.name, auth->name, auth->name_length))
-		{
-			return TRUE;
-		}
-    }
-	
-    return FALSE;
-}
-
-/* Add one item to our list of auth items. */
-static void
-add_auth_item (Xauth *auth)
-{
-    addr_list *a = malloc (sizeof (addr_list));
-	
-    a->auth.family = auth->family;
-    a->auth.address_length = auth->address_length;
-    a->auth.address = binary_dup (auth->address, auth->address_length);
-    a->auth.number_length = auth->number_length;
-    a->auth.number = binary_dup (auth->number, auth->number_length);
-    a->auth.name_length = auth->name_length;
-    a->auth.name = binary_dup (auth->name, auth->name_length);
-    a->auth.data_length = auth->data_length;
-    a->auth.data = binary_dup (auth->data, auth->data_length);
-	
-    a->next = addresses;
-    addresses = a;
-}
-
-/* Free all allocated auth items. */
-static void
-free_auth_items (void)
-{
-    addr_list *a;
-	
-    while ((a = addresses) != NULL)
-    {
-		addresses = a->next;
-		
-		binary_free (a->auth.address, a->auth.address_length);
-		binary_free (a->auth.number, a->auth.number_length);
-		binary_free (a->auth.name, a->auth.name_length);
-		binary_free (a->auth.data, a->auth.data_length);
-		free (a);
-    }
-}
-
-/* Add the unix domain auth item. */
-static void
-define_local (Xauth *auth)
-{
-    char *host = host_name ();
-	
-#ifdef DEBUG
-    fprintf (stderr, "x11: hostname is %s\n", host);
-#endif
-	
-    auth->family = FamilyLocal;
-    auth->address_length = strlen (host);
-    auth->address = host;
-	
-    add_auth_item (auth);
-}
-
-/* Add the tcp auth item. */
-static void
-define_named (Xauth *auth, const char *name)
-{
-    struct ifaddrs *addrs, *ptr;
-	
-    if (getifaddrs (&addrs) != 0)
-		return;
-	
-    for (ptr = addrs; ptr != NULL; ptr = ptr->ifa_next)
-    {
-		if (ptr->ifa_addr->sa_family != AF_INET)
-			continue;
-		
-		auth->family = FamilyInternet;
-		auth->address_length = sizeof (struct in_addr);
-		auth->address = (char *) &(((struct sockaddr_in *) ptr->ifa_addr)->sin_addr);
-		
-#ifdef DEBUG
-		fprintf (stderr, "x11: ipaddr is %d.%d.%d.%d\n",
-				 (unsigned char) auth->address[0],
-				 (unsigned char) auth->address[1],
-				 (unsigned char) auth->address[2],
-				 (unsigned char) auth->address[3]);
-#endif
-		
-		add_auth_item (auth);
-    }
-	
-    freeifaddrs (addrs);
-}
-
-/* Parse the display number from NAME and add it to AUTH. */
-static void
-set_auth_number (Xauth *auth, const char *name)
-{
-    char *colon;
-    char *dot, *number;
-	
-    colon = strrchr(name, ':');
-    if (colon != NULL)
-    {
-		colon++;
-		dot = strchr(colon, '.');
-		
-		if (dot != NULL)
-			auth->number_length = dot - colon;
-		else
-			auth->number_length = strlen (colon);
-		
-		number = malloc (auth->number_length + 1);
-		if (number != NULL)
-		{
-			strncpy (number, colon, auth->number_length);
-			number[auth->number_length] = '\0';
-		}
-		else
-		{
-			auth->number_length = 0;
-		}
-		
-		auth->number = number;
-    }
-}
-
-/* Put 128 bits of random data into DATA. If possible, it will be "high
- quality" */
-static int
-generate_mit_magic_cookie (char data[16])
-{
-    int fd, ret, i;
-    long *ldata = (long *) data;
-	
-    fd = open ("/dev/random", O_RDONLY);
-    if (fd > 0) {
-		ret = read (fd, data, 16);
-		close (fd);
-		if (ret == 16) return TRUE;
-    }
-	
-    /* fall back to the usual crappy rng */
-	
-    srand48 (getpid () ^ time (NULL));
-	
-    for (i = 0; i < 4; i++)
-		ldata[i] = lrand48 ();
-	
-    return TRUE;
-}
-
-/* Create the keys we'll be using for the display named NAME. */
-static int
-make_auth_keys (const char *name)
-{
-    Xauth auth;
-    char key[16];
-	
-    if (auth_file == NULL)
-		return FALSE;
-	
-    auth.name = "MIT-MAGIC-COOKIE-1";
-    auth.name_length = strlen (auth.name);
-	
-    if (!generate_mit_magic_cookie (key))
-    {
-		auth_file = NULL;
-		return FALSE;
-    }
-	
-    auth.data = key;
-    auth.data_length = 16;
-	
-    set_auth_number (&auth, name);
-	
-    define_named (&auth, host_name ());
-    define_local (&auth);
-	
-    free (auth.number);
-	
-    return TRUE;
-}
-
-/* If ADD-ENTRIES is true, merge our auth entries into the existing
- Xauthority file. If ADD-ENTRIES is false, remove our entries. */
-static int
-write_auth_file (int add_entries)
-{
-    char *home, newname[1024];
-    int fd, ret;
-    FILE *new_fh, *old_fh;
-    addr_list *addr;
-    Xauth *auth;
-	
-    if (auth_file == NULL)
-		return FALSE;
-	
-    home = getenv ("HOME");
-    if (home == NULL)
-    {
-		auth_file = NULL;
-		return FALSE;
-    }
-	
-    snprintf (newname, sizeof (newname), "%s/.XauthorityXXXXXX", home);
-    mktemp (newname);
-	
-    if (XauLockAuth (auth_file, 1, 2, 10) != LOCK_SUCCESS)
-    {
-		/* FIXME: do something here? */
-		
-		auth_file = NULL;
-		return FALSE;
-    }
-	
-    fd = open (newname, O_WRONLY | O_CREAT | O_TRUNC, 0600);
-    if (fd >= 0)
-    {
-		new_fh = fdopen (fd, "w");
-		if (new_fh != NULL)
-		{
-			if (add_entries)
-			{
-				for (addr = addresses; addr != NULL; addr = addr->next)
-				{
-					XauWriteAuth (new_fh, &addr->auth);
-				}
-			}
-			
-			old_fh = fopen (auth_file, "r");
-			if (old_fh != NULL)
-			{
-				while ((auth = XauReadAuth (old_fh)) != NULL)
-				{
-					if (!check_auth_item (auth))
-						XauWriteAuth (new_fh, auth);
-					XauDisposeAuth (auth);
-				}
-				fclose (old_fh);
-			}
-			
-			fclose (new_fh);
-			unlink (auth_file);
-			
-			ret = rename (newname, auth_file);
-			
-			if (ret != 0)
-				auth_file = NULL;
-			
-			XauUnlockAuth (auth_file);
-			return ret == 0;
-		}
-		
-		close (fd);
-    }
-	
-    XauUnlockAuth (auth_file);
-    auth_file = NULL;
-    return FALSE;
-}
-
-
-/* Subprocess management functions. */
-
-static int
-start_server (char **xargv)
-{
-    int child;
-	
-    child = fork ();
-	
-    switch (child)
-    {
-    case -1:				/* error */
-		perror ("fork");
-		return FALSE;
-		
-    case 0:				/* child */
-		execv (X_SERVER, xargv);
-		perror ("Couldn't exec " X_SERVER);
-		_exit (1);
-		
-    default:				/* parent */
-		server_pid = child;
-		return TRUE;
-    }
-}
-
-static int
-wait_for_server (void)
-{
-    int count = 100;
-	
-    while (count-- > 0)
-    {
-		int status;
-		
-		server_dpy = XOpenDisplay (server_name);
-		if (server_dpy != NULL)
-			return TRUE;
-		
-		if (waitpid (server_pid, &status, WNOHANG) == server_pid)
-			return FALSE;
-		
-		sleep (1);
-    }
-	
-    return FALSE;
-}
-
-static int
-start_client (void)
-{
-    int child;
-	
-    child = fork();
-	
-    switch (child) {
-		char *temp, buf[1024];		
-
-	case -1:				/* error */
-		perror("fork");
-		return FALSE;
-
-	case 0:					/* child */
-		/* Setup environment */
-		temp = getenv("DISPLAY");
-//		if (temp == NULL && temp[0] != 0)
-			setenv("DISPLAY", server_name, TRUE);
-
-		temp = getenv("PATH");
-		if (temp == NULL || temp[0] == 0) 
-			setenv ("PATH", DEFAULT_PATH, TRUE);
-		else if (strnstr(temp, "/usr/X11/bin", sizeof(temp)) == NULL) {
-			snprintf(buf, sizeof(buf), "%s:/usr/X11/bin", temp);		
-			setenv("PATH", buf, TRUE);	
-		}
-		
-		/* First try value of $XINITRC, if set. */
-		temp = getenv("XINITRC");
-		if (temp != NULL && temp[0] != 0 && access(temp, R_OK) == 0)
-			execlp (SHELL, SHELL, temp, NULL);
-
-		/* Then look for .xinitrc in user's home directory. */
-		temp = getenv("HOME");
-		if (temp != NULL && temp[0] != 0) {
-			chdir(temp);
-			snprintf (buf, sizeof (buf), "%s/.xinitrc", temp);
-			if (access(buf, R_OK) == 0)
-				execlp(SHELL, SHELL, buf, NULL);
-		}
-		
-		/* Then try the default xinitrc in the lib directory. */
-		
-		if (access(DEFAULT_XINITRC, R_OK) == 0)
-			execlp(SHELL, SHELL, DEFAULT_XINITRC, NULL);
-		
-		/* Then fallback to hardcoding an xterm and the window manager. */
-		
-		//		system(XTERM_PATH " &");
-		execl(WM_PATH, WM_PATH, NULL);
-		
-		perror("exec");
-		_exit(1);
-		
-    default:				/* parent */
-		client_pid = child;
-		return TRUE;
-    }
-}
-
-static void
-sigchld_handler (int sig)
-{
-    int pid, status;
-	
-	again:
-    pid = waitpid (WAIT_ANY, &status, WNOHANG);
-	
-    if (pid > 0)
-    {
-		if (pid == server_pid)
-		{
-			server_pid = -1;
-			
-			if (client_pid >= 0)
-				kill (client_pid, SIGTERM);
-		}
-		else if (pid == client_pid)
-		{
-			client_pid = -1;
-			
-			if (server_pid >= 0 && xinit_kills_server)
-				kill (server_pid, SIGTERM);
-		}
-		goto again;
-    }
-	
-    if (server_pid == -1 && client_pid == -1)
-		longjmp (exit_continuation, 1);
-	
-    signal (SIGCHLD, sigchld_handler);
-}
-
-
-/* Server utilities. */
-
-static Boolean
-display_exists_p (int number)
-{
-    char buf[64];
-    xcb_connection_t *conn;
-    char *fullname = NULL;
-    int idisplay, iscreen;
-    char *conn_auth_name, *conn_auth_data;
-    int conn_auth_namelen, conn_auth_datalen;
-    
-    //    extern void *_X11TransConnectDisplay ();
-    //    extern void _XDisconnectDisplay ();
-	
-    /* Since connecting to the display waits for a few seconds if the
-	 display doesn't exist, check for trivial non-existence - if the
-	 socket in /tmp exists or not.. (note: if the socket exists, the
-	 server may still not, so we need to try to connect in that case..) */
-	
-    sprintf (buf, "/tmp/.X11-unix/X%d", number);
-    if (access (buf, F_OK) != 0)
-		return FALSE;
-    
-    sprintf (buf, ":%d", number);
-    conn = xcb_connect(buf, NULL);
-    if (xcb_connection_has_error(conn)) return FALSE;
-	
-    xcb_disconnect(conn);
-    return TRUE;
-}
-
-
-/* Monitoring when the system's ip addresses change. */
-
-static Boolean pending_timer;
-
-static void
-timer_callback (CFRunLoopTimerRef timer, void *info)
-{
-    pending_timer = FALSE;
-	
-    /* Update authentication names. Need to write .Xauthority file first
-	 without the existing entries, then again with the new entries.. */
-	
-    write_auth_file (FALSE);
-	
-    free_auth_items ();
-    make_auth_keys (server_name);
-	
-    write_auth_file (TRUE);
-}
-
-/* This function is called when the system's ip addresses may have changed. */
-static void
-ipaddr_callback (SCDynamicStoreRef store, CFArrayRef changed_keys, void *info)
-{
-#if DEBUG
-    if (changed_keys != NULL) {
-		fprintf (stderr, "x11: changed sc keys: ");
-		CFShow (changed_keys);
-    }
-#endif
-
-    if (auth_file != NULL && !pending_timer)
-    {
-		CFRunLoopTimerRef timer;
-		
-		timer = CFRunLoopTimerCreate (NULL, CFAbsoluteTimeGetCurrent () + 1.0,
-									  0.0, 0, 0, timer_callback, NULL);
-		CFRunLoopAddTimer (CFRunLoopGetCurrent (), timer,
-						   kCFRunLoopDefaultMode);
-		CFRelease (timer);
-		
-		pending_timer = TRUE;
-    }
-}
-
-/* This code adapted from "Living in a Dynamic TCP/IP Environment" technote. */
-static Boolean
-install_ipaddr_source (void)
-{
-    CFRunLoopSourceRef source = NULL;
-	
-    SCDynamicStoreContext context = {0};
-    SCDynamicStoreRef ref;
-	
-    ref = SCDynamicStoreCreate (NULL,
-								CFSTR ("AddIPAddressListChangeCallbackSCF"),
-								ipaddr_callback, &context);
-	
-    if (ref != NULL)
-    {
-		const void *keys[4], *patterns[2];
-		int i;
-		
-		keys[0] = SCDynamicStoreKeyCreateNetworkGlobalEntity (NULL, kSCDynamicStoreDomainState, kSCEntNetIPv4);
-		keys[1] = SCDynamicStoreKeyCreateNetworkGlobalEntity (NULL, kSCDynamicStoreDomainState, kSCEntNetIPv6);
-		keys[2] = SCDynamicStoreKeyCreateComputerName (NULL);
-		keys[3] = SCDynamicStoreKeyCreateHostNames (NULL);
-		
-		patterns[0] = SCDynamicStoreKeyCreateNetworkInterfaceEntity (NULL, kSCDynamicStoreDomainState, kSCCompAnyRegex, kSCEntNetIPv4);
-		patterns[1] = SCDynamicStoreKeyCreateNetworkInterfaceEntity (NULL, kSCDynamicStoreDomainState, kSCCompAnyRegex, kSCEntNetIPv6);
-		
-		if (keys[0] != NULL && keys[1] != NULL && keys[2] != NULL
-			&& keys[3] != NULL && patterns[0] != NULL && patterns[1] != NULL)
-		{
-			CFArrayRef key_array, pattern_array;
-			
-			key_array = CFArrayCreate (NULL, keys, 4, &kCFTypeArrayCallBacks);
-			pattern_array = CFArrayCreate (NULL, patterns, 2, &kCFTypeArrayCallBacks);
-			
-			if (key_array != NULL || pattern_array != NULL)
-			{
-				SCDynamicStoreSetNotificationKeys (ref, key_array, pattern_array);
-				source = SCDynamicStoreCreateRunLoopSource (NULL, ref, 0);
-			}
-			
-			if (key_array != NULL)
-				CFRelease (key_array);
-			if (pattern_array != NULL)
-				CFRelease (pattern_array);
-		}
-		
-		
-		for (i = 0; i < 4; i++)
-			if (keys[i] != NULL)
-			CFRelease (keys[i]);
-		for (i = 0; i < 2; i++)
-			if (patterns[i] != NULL)
-			CFRelease (patterns[i]);
-		
-		CFRelease (ref); 
-    }
-	
-    if (source != NULL)
-    {
-		CFRunLoopAddSource (CFRunLoopGetCurrent (),
-							source, kCFRunLoopDefaultMode);
-		CFRelease (source);
-    }
-	
-    return source != NULL;
-}
-
-
-/* Entrypoint. */
-
-void
-termination_signal_handler (int unused_sig)
-{
-    signal (SIGTERM, SIG_DFL);
-    signal (SIGHUP, SIG_DFL);
-    signal (SIGINT, SIG_DFL);
-    signal (SIGQUIT, SIG_DFL);
-
-    longjmp (exit_continuation, 1);
-}
-
-int
-server_main (int argc, char **argv)
-{
-    char **xargv;
-    int i, j;
-    int fd;
-	
-    xargv = alloca (sizeof (char *) * (argc + 32));
-	
-    if (!read_boolean_pref (CFSTR ("no_auth"), FALSE))
-		auth_file = XauFileName ();
-	
-    /* The standard X11 behaviour is for the server to quit when the first
-	 client exits. But it can be useful for debugging (and to mimic our
-	 behaviour in the beta releases) to not do that. */
-	
-    xinit_kills_server = read_boolean_pref (CFSTR ("xinit_kills_server"), TRUE);
-	
-    for (i = 1; i < argc; i++)
-    {
-		if (argv[i][0] == ':')
-			server_name = argv[i];
-    }
-	
-    if (server_name == NULL)
-    {
-		static char name[8];
-		
-		/* No display number specified, so search for the first unused.
-		 
-		 There's a big old race condition here if two servers start at
-		 the same time, but that's fairly unlikely. We could create
-		 lockfiles or something, but that's seems more likely to cause
-		 problems than the race condition itself.. */
-		
-		for (i = 0; i < MAX_DISPLAYS; i++)
-		{
-			if (!display_exists_p (i))
-				break;
-		}
-		
-		if (i == MAX_DISPLAYS)
-		{
-			fprintf (stderr, "%s: couldn't allocate a display number", argv[0]);
-			exit (1);
-		}
-		
-		sprintf (name, ":%d", i);
-		server_name = name;
-    }
-	
-    if (auth_file != NULL)
-    {
-		/* Create new Xauth keys and add them to the .Xauthority file */
-		
-		make_auth_keys (server_name);
-		write_auth_file (TRUE);
-    }
-	
-    /* Construct our new argv */
-	
-    i = j = 0;
-	
-    xargv[i++] = argv[j++];
-	
-    if (auth_file != NULL)
-    {
-		xargv[i++] = "-auth";
-		xargv[i++] = auth_file;
-    }
-	
-    /* By default, don't listen on tcp sockets if Xauth is disabled. */
-	
-    if (read_boolean_pref (CFSTR ("nolisten_tcp"), auth_file == NULL))
-    {
-		xargv[i++] = "-nolisten";
-		xargv[i++] = "tcp";
-    }
-	
-    while (j < argc)
-    {
-		if (argv[j++][0] != ':')
-			xargv[i++] = argv[j-1];
-    }
-	
-    xargv[i++] = (char *) server_name;
-    xargv[i++] = NULL;
-	
-    /* Detach from any controlling terminal and connect stdin to /dev/null */
-	
-#ifdef TIOCNOTTY
-    fd = open ("/dev/tty", O_RDONLY);
-    if (fd != -1)
-    {
-		ioctl (fd, TIOCNOTTY, 0);
-		close (fd);
-    }
-#endif
-	
-    fd = open ("/dev/null", O_RDWR, 0);
-    if (fd >= 0)
-    {
-		dup2 (fd, 0);
-		if (fd > 0)
-			close (fd);
-    }
-	
-    if (!start_server (xargv))
-		return 1;
-	
-    if (!wait_for_server ())
-    {
-		kill (server_pid, SIGTERM);
-		return 1;
-    }
-	
-    if (!start_client ())
-    {
-		kill (server_pid, SIGTERM);
-		return 1;
-    }
-	
-    signal (SIGCHLD, sigchld_handler);
-	
-    signal (SIGTERM, termination_signal_handler);
-    signal (SIGHUP, termination_signal_handler);
-    signal (SIGINT, termination_signal_handler);
-    signal (SIGQUIT, termination_signal_handler);
-
-    if (setjmp (exit_continuation) == 0)
-    {
-		if (install_ipaddr_source ())
-			CFRunLoopRun ();
-		else
-			while (1) pause ();
-    }
-	
-    signal (SIGCHLD, SIG_IGN);
-
-    if (client_pid >= 0) kill (client_pid, SIGTERM);
-    if (server_pid >= 0) kill (server_pid, SIGTERM);
-	
-    if (auth_file != NULL)
-    {
-		/* Remove our Xauth keys */
-		
-		write_auth_file (FALSE);
-    }
-	
-    free_auth_items ();
-	
-    return 0;
-}
diff --git a/hw/darwin/quartz/applewm.c b/hw/darwin/quartz/applewm.c
deleted file mode 100644
index 72dca28..0000000
--- a/hw/darwin/quartz/applewm.c
+++ /dev/null
@@ -1,714 +0,0 @@
-/**************************************************************************
-
-Copyright (c) 2002-2007 Apple Inc. All Rights Reserved.
-Copyright (c) 2003 Torrey T. Lyons. 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, sub license, 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 PRECISION INSIGHT AND/OR ITS 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.
-
-**************************************************************************/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "quartzCommon.h"
-
-#define NEED_REPLIES
-#define NEED_EVENTS
-#include "misc.h"
-#include "dixstruct.h"
-#include "globals.h"
-#include "extnsionst.h"
-#include "colormapst.h"
-#include "cursorstr.h"
-#include "scrnintstr.h"
-#include "windowstr.h"
-#include "servermd.h"
-#include "swaprep.h"
-#include "propertyst.h"
-#include <X11/Xatom.h>
-#include "darwin.h"
-#define _APPLEWM_SERVER_
-#include "X11/extensions/applewmstr.h"
-#include "applewmExt.h"
-#include "X11Application.h"
-
-#define DEFINE_ATOM_HELPER(func,atom_name)                      \
-static Atom func (void) {                                       \
-    static int generation;                                      \
-    static Atom atom;                                           \
-    if (generation != serverGeneration) {                       \
-        generation = serverGeneration;                          \
-        atom = MakeAtom (atom_name, strlen (atom_name), TRUE);  \
-    }                                                           \
-    return atom;                                                \
-}
-
-DEFINE_ATOM_HELPER(xa_native_screen_origin, "_NATIVE_SCREEN_ORIGIN")
-DEFINE_ATOM_HELPER (xa_apple_no_order_in, "_APPLE_NO_ORDER_IN")
-
-static AppleWMProcsPtr appleWMProcs;
-
-static int WMErrorBase;
-
-static DISPATCH_PROC(ProcAppleWMDispatch);
-static DISPATCH_PROC(SProcAppleWMDispatch);
-
-static void AppleWMResetProc(ExtensionEntry* extEntry);
-
-static unsigned char WMReqCode = 0;
-static int WMEventBase = 0;
-
-static RESTYPE ClientType, EventType; /* resource types for event masks */
-static XID eventResource;
-
-/* Currently selected events */
-static unsigned int eventMask = 0;
-
-static int WMFreeClient (pointer data, XID id);
-static int WMFreeEvents (pointer data, XID id);
-static void SNotifyEvent(xAppleWMNotifyEvent *from, xAppleWMNotifyEvent *to);
-
-typedef struct _WMEvent *WMEventPtr;
-typedef struct _WMEvent {
-    WMEventPtr      next;
-    ClientPtr       client;
-    XID             clientResource;
-    unsigned int    mask;
-} WMEventRec;
-
-static inline BoxRec
-make_box (int x, int y, int w, int h)
-{
-    BoxRec r;
-    r.x1 = x;
-    r.y1 = y;
-    r.x2 = x + w;
-    r.y2 = y + h;
-    return r;
-}
-
-void
-AppleWMExtensionInit(
-    AppleWMProcsPtr procsPtr)
-{
-    ExtensionEntry* extEntry;
-
-    ClientType = CreateNewResourceType(WMFreeClient);
-    EventType = CreateNewResourceType(WMFreeEvents);
-    eventResource = FakeClientID(0);
-
-    if (ClientType && EventType &&
-        (extEntry = AddExtension(APPLEWMNAME,
-                                 AppleWMNumberEvents,
-                                 AppleWMNumberErrors,
-                                 ProcAppleWMDispatch,
-                                 SProcAppleWMDispatch,
-                                 AppleWMResetProc,
-                                 StandardMinorOpcode)))
-    {
-        WMReqCode = (unsigned char)extEntry->base;
-        WMErrorBase = extEntry->errorBase;
-        WMEventBase = extEntry->eventBase;
-        EventSwapVector[WMEventBase] = (EventSwapPtr) SNotifyEvent;
-        appleWMProcs = procsPtr;
-    }
-}
-
-/*ARGSUSED*/
-static void
-AppleWMResetProc (
-    ExtensionEntry* extEntry
-)
-{
-}
-
-/* Updates the _NATIVE_SCREEN_ORIGIN property on the given root window. */
-void
-AppleWMSetScreenOrigin(
-    WindowPtr pWin
-)
-{
-    long data[2];
-
-    data[0] = (dixScreenOrigins[pWin->drawable.pScreen->myNum].x
-                + darwinMainScreenX);
-    data[1] = (dixScreenOrigins[pWin->drawable.pScreen->myNum].y
-                + darwinMainScreenY);
-
-    ChangeWindowProperty(pWin, xa_native_screen_origin(), XA_INTEGER,
-                         32, PropModeReplace, 2, data, TRUE);
-}
-
-/* Window managers can set the _APPLE_NO_ORDER_IN property on windows
-   that are being genie-restored from the Dock. We want them to
-   be mapped but remain ordered-out until the animation
-   completes (when the Dock will order them in). */
-Bool
-AppleWMDoReorderWindow(
-    WindowPtr pWin
-)
-{
-    Atom atom;
-    PropertyPtr prop;
-
-    atom = xa_apple_no_order_in();
-    for (prop = wUserProps(pWin); prop != NULL; prop = prop->next)
-    {
-        if (prop->propertyName == atom && prop->type == atom)
-            return FALSE;
-    }
-
-    return TRUE;
-}
-
-
-static int
-ProcAppleWMQueryVersion(
-    register ClientPtr client
-)
-{
-    xAppleWMQueryVersionReply rep;
-    register int n;
-
-    REQUEST_SIZE_MATCH(xAppleWMQueryVersionReq);
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-    rep.majorVersion = APPLE_WM_MAJOR_VERSION;
-    rep.minorVersion = APPLE_WM_MINOR_VERSION;
-    rep.patchVersion = APPLE_WM_PATCH_VERSION;
-    if (client->swapped) {
-        swaps(&rep.sequenceNumber, n);
-        swapl(&rep.length, n);
-    }
-    WriteToClient(client, sizeof(xAppleWMQueryVersionReply), (char *)&rep);
-    return (client->noClientException);
-}
-
-
-/* events */
-
-static inline void
-updateEventMask (WMEventPtr *pHead)
-{
-    WMEventPtr pCur;
-
-    eventMask = 0;
-    for (pCur = *pHead; pCur != NULL; pCur = pCur->next)
-        eventMask |= pCur->mask;
-}
-
-/*ARGSUSED*/
-static int
-WMFreeClient (data, id)
-    pointer     data;
-    XID         id;
-{
-    WMEventPtr   pEvent;
-    WMEventPtr   *pHead, pCur, pPrev;
-
-    pEvent = (WMEventPtr) data;
-    pHead = (WMEventPtr *) LookupIDByType(eventResource, EventType);
-    if (pHead) {
-        pPrev = 0;
-        for (pCur = *pHead; pCur && pCur != pEvent; pCur=pCur->next)
-            pPrev = pCur;
-        if (pCur) {
-            if (pPrev)
-                pPrev->next = pEvent->next;
-            else
-                *pHead = pEvent->next;
-        }
-        updateEventMask (pHead);
-    }
-    xfree ((pointer) pEvent);
-    return 1;
-}
-
-/*ARGSUSED*/
-static int
-WMFreeEvents (data, id)
-    pointer     data;
-    XID         id;
-{
-    WMEventPtr   *pHead, pCur, pNext;
-
-    pHead = (WMEventPtr *) data;
-    for (pCur = *pHead; pCur; pCur = pNext) {
-        pNext = pCur->next;
-        FreeResource (pCur->clientResource, ClientType);
-        xfree ((pointer) pCur);
-    }
-    xfree ((pointer) pHead);
-    eventMask = 0;
-    return 1;
-}
-
-static int
-ProcAppleWMSelectInput (client)
-    register ClientPtr  client;
-{
-    REQUEST(xAppleWMSelectInputReq);
-    WMEventPtr      pEvent, pNewEvent, *pHead;
-    XID             clientResource;
-
-    REQUEST_SIZE_MATCH (xAppleWMSelectInputReq);
-    pHead = (WMEventPtr *)SecurityLookupIDByType(client,
-                        eventResource, EventType, DixWriteAccess);
-    if (stuff->mask != 0) {
-        if (pHead) {
-            /* check for existing entry. */
-            for (pEvent = *pHead; pEvent; pEvent = pEvent->next)
-            {
-                if (pEvent->client == client)
-                {
-                    pEvent->mask = stuff->mask;
-                    updateEventMask (pHead);
-                    return Success;
-                }
-            }
-        }
-
-        /* build the entry */
-        pNewEvent = (WMEventPtr) xalloc (sizeof (WMEventRec));
-        if (!pNewEvent)
-            return BadAlloc;
-        pNewEvent->next = 0;
-        pNewEvent->client = client;
-        pNewEvent->mask = stuff->mask;
-        /*
-         * add a resource that will be deleted when
-         * the client goes away
-         */
-        clientResource = FakeClientID (client->index);
-        pNewEvent->clientResource = clientResource;
-        if (!AddResource (clientResource, ClientType, (pointer)pNewEvent))
-            return BadAlloc;
-        /*
-         * create a resource to contain a pointer to the list
-         * of clients selecting input.  This must be indirect as
-         * the list may be arbitrarily rearranged which cannot be
-         * done through the resource database.
-         */
-        if (!pHead)
-        {
-            pHead = (WMEventPtr *) xalloc (sizeof (WMEventPtr));
-            if (!pHead ||
-                !AddResource (eventResource, EventType, (pointer)pHead))
-            {
-                FreeResource (clientResource, RT_NONE);
-                return BadAlloc;
-            }
-            *pHead = 0;
-        }
-        pNewEvent->next = *pHead;
-        *pHead = pNewEvent;
-        updateEventMask (pHead);
-    } else if (stuff->mask == 0) {
-        /* delete the interest */
-        if (pHead) {
-            pNewEvent = 0;
-            for (pEvent = *pHead; pEvent; pEvent = pEvent->next) {
-                if (pEvent->client == client)
-                    break;
-                pNewEvent = pEvent;
-            }
-            if (pEvent) {
-                FreeResource (pEvent->clientResource, ClientType);
-                if (pNewEvent)
-                    pNewEvent->next = pEvent->next;
-                else
-                    *pHead = pEvent->next;
-                xfree (pEvent);
-                updateEventMask (pHead);
-            }
-        }
-    } else {
-        client->errorValue = stuff->mask;
-        return BadValue;
-    }
-    return Success;
-}
-
-/*
- * deliver the event
- */
-
-void
-AppleWMSendEvent (type, mask, which, arg)
-    int type, which, arg;
-    unsigned int mask;
-{
-    WMEventPtr      *pHead, pEvent;
-    ClientPtr       client;
-    xAppleWMNotifyEvent se;
-
-    pHead = (WMEventPtr *) LookupIDByType(eventResource, EventType);
-    if (!pHead)
-        return;
-    for (pEvent = *pHead; pEvent; pEvent = pEvent->next) {
-        client = pEvent->client;
-        if ((pEvent->mask & mask) == 0
-            || client == serverClient || client->clientGone)
-        {
-            continue;
-        }
-        se.type = type + WMEventBase;
-        se.kind = which;
-        se.arg = arg;
-        se.sequenceNumber = client->sequence;
-        se.time = currentTime.milliseconds;
-        WriteEventsToClient (client, 1, (xEvent *) &se);
-    }
-}
-
-/* Safe to call from any thread. */
-unsigned int
-AppleWMSelectedEvents (void)
-{
-    return eventMask;
-}
-
-
-/* general utility functions */
-
-static int
-ProcAppleWMDisableUpdate(
-    register ClientPtr client
-)
-{
-    REQUEST_SIZE_MATCH(xAppleWMDisableUpdateReq);
-
-    appleWMProcs->DisableUpdate();
-
-    return (client->noClientException);
-}
-
-static int
-ProcAppleWMReenableUpdate(
-    register ClientPtr client
-)
-{
-    REQUEST_SIZE_MATCH(xAppleWMReenableUpdateReq);
-
-    appleWMProcs->EnableUpdate();
-
-    return (client->noClientException);
-}
-
-
-/* window functions */
-
-static int
-ProcAppleWMSetWindowMenu(
-    register ClientPtr client
-)
-{
-    const char *bytes, **items;
-    char *shortcuts;
-    int max_len, nitems, i, j;
-    REQUEST(xAppleWMSetWindowMenuReq);
-
-    REQUEST_AT_LEAST_SIZE(xAppleWMSetWindowMenuReq);
-
-    nitems = stuff->nitems;
-    items = xalloc (sizeof (char *) * nitems);
-    shortcuts = xalloc (sizeof (char) * nitems);
-
-    max_len = (stuff->length << 2) - sizeof(xAppleWMSetWindowMenuReq);
-    bytes = (char *) &stuff[1];
-
-    for (i = j = 0; i < max_len && j < nitems;)
-    {
-        shortcuts[j] = bytes[i++];
-        items[j++] = bytes + i;
-
-        while (i < max_len)
-        {
-            if (bytes[i++] == 0)
-                break;
-        }
-    }
-    X11ApplicationSetWindowMenu (nitems, items, shortcuts);
-    free(items);
-    free(shortcuts);
-
-    return (client->noClientException);
-}
-
-static int
-ProcAppleWMSetWindowMenuCheck(
-    register ClientPtr client
-)
-{
-    REQUEST(xAppleWMSetWindowMenuCheckReq);
-
-    REQUEST_SIZE_MATCH(xAppleWMSetWindowMenuCheckReq);
-    X11ApplicationSetWindowMenuCheck(stuff->index);
-    return (client->noClientException);
-}
-
-static int
-ProcAppleWMSetFrontProcess(
-    register ClientPtr client
-)
-{
-    REQUEST_SIZE_MATCH(xAppleWMSetFrontProcessReq);
-
-    X11ApplicationSetFrontProcess();
-    return (client->noClientException);
-}
-
-static int
-ProcAppleWMSetWindowLevel(
-    register ClientPtr client
-)
-{
-    REQUEST(xAppleWMSetWindowLevelReq);
-    WindowPtr pWin;
-    int errno;
-
-    REQUEST_SIZE_MATCH(xAppleWMSetWindowLevelReq);
-
-    if (Success != dixLookupWindow(&pWin, stuff->window, client,
-				   DixReadAccess))
-        return BadValue;
-
-    if (stuff->level < 0 || stuff->level >= AppleWMNumWindowLevels) {
-        return BadValue;
-    }
-
-     errno = appleWMProcs->SetWindowLevel(pWin, stuff->level);
-     if (errno != Success) {
-        return errno;
-    }
-
-    return (client->noClientException);
-}
-
-static int
-ProcAppleWMSetCanQuit(
-    register ClientPtr client
-)
-{
-    REQUEST(xAppleWMSetCanQuitReq);
-
-    REQUEST_SIZE_MATCH(xAppleWMSetCanQuitReq);
-
-    X11ApplicationSetCanQuit(stuff->state);
-    return (client->noClientException);
-}
-
-
-/* frame functions */
-
-static int
-ProcAppleWMFrameGetRect(
-    register ClientPtr client
-)
-{
-    xAppleWMFrameGetRectReply rep;
-    BoxRec ir, or, rr;
-    REQUEST(xAppleWMFrameGetRectReq);
-
-    REQUEST_SIZE_MATCH(xAppleWMFrameGetRectReq);
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-
-    ir = make_box (stuff->ix, stuff->iy, stuff->iw, stuff->ih);
-    or = make_box (stuff->ox, stuff->oy, stuff->ow, stuff->oh);
-
-    if (appleWMProcs->FrameGetRect(stuff->frame_rect,
-                                   stuff->frame_class,
-                                   &or, &ir, &rr) != Success)
-    {
-        return BadValue;
-    }
-
-    rep.x = rr.x1;
-    rep.y = rr.y1;
-    rep.w = rr.x2 - rr.x1;
-    rep.h = rr.y2 - rr.y1;
-
-    WriteToClient(client, sizeof(xAppleWMFrameGetRectReply), (char *)&rep);
-    return (client->noClientException);
-}
-
-static int
-ProcAppleWMFrameHitTest(
-    register ClientPtr client
-)
-{
-    xAppleWMFrameHitTestReply rep;
-    BoxRec ir, or;
-    int ret;
-    REQUEST(xAppleWMFrameHitTestReq);
-
-    REQUEST_SIZE_MATCH(xAppleWMFrameHitTestReq);
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-
-    ir = make_box (stuff->ix, stuff->iy, stuff->iw, stuff->ih);
-    or = make_box (stuff->ox, stuff->oy, stuff->ow, stuff->oh);
-
-    if (appleWMProcs->FrameHitTest(stuff->frame_class, stuff->px,
-                                   stuff->py, &or, &ir, &ret) != Success)
-    {
-        return BadValue;
-    }
-
-    rep.ret = ret;
-
-    WriteToClient(client, sizeof(xAppleWMFrameHitTestReply), (char *)&rep);
-    return (client->noClientException);
-}
-
-static int
-ProcAppleWMFrameDraw(
-    register ClientPtr client
-)
-{
-    BoxRec ir, or;
-    unsigned int title_length, title_max;
-    unsigned char *title_bytes;
-    REQUEST(xAppleWMFrameDrawReq);
-    WindowPtr pWin;
-
-    REQUEST_AT_LEAST_SIZE(xAppleWMFrameDrawReq);
-
-    if (Success != dixLookupWindow(&pWin, stuff->window, client,
-				   DixReadAccess))
-        return BadValue;
-
-    ir = make_box (stuff->ix, stuff->iy, stuff->iw, stuff->ih);
-    or = make_box (stuff->ox, stuff->oy, stuff->ow, stuff->oh);
-
-    title_length = stuff->title_length;
-    title_max = (stuff->length << 2) - sizeof(xAppleWMFrameDrawReq);
-
-    if (title_max < title_length)
-        return BadValue;
-
-    title_bytes = (unsigned char *) &stuff[1];
-
-    errno = appleWMProcs->FrameDraw(pWin, stuff->frame_class,
-                                    stuff->frame_attr, &or, &ir,
-                                    title_length, title_bytes);
-    if (errno != Success) {
-        return errno;
-    }
-
-    return (client->noClientException);
-}
-
-
-/* dispatch */
-
-static int
-ProcAppleWMDispatch (
-    register ClientPtr  client
-)
-{
-    REQUEST(xReq);
-
-    switch (stuff->data)
-    {
-    case X_AppleWMQueryVersion:
-        return ProcAppleWMQueryVersion(client);
-    }
-
-    if (!LocalClient(client))
-        return WMErrorBase + AppleWMClientNotLocal;
-
-    switch (stuff->data)
-    {
-    case X_AppleWMSelectInput:
-        return ProcAppleWMSelectInput(client);
-    case X_AppleWMDisableUpdate:
-        return ProcAppleWMDisableUpdate(client);
-    case X_AppleWMReenableUpdate:
-        return ProcAppleWMReenableUpdate(client);
-    case X_AppleWMSetWindowMenu:
-        return ProcAppleWMSetWindowMenu(client);
-    case X_AppleWMSetWindowMenuCheck:
-        return ProcAppleWMSetWindowMenuCheck(client);
-    case X_AppleWMSetFrontProcess:
-        return ProcAppleWMSetFrontProcess(client);
-    case X_AppleWMSetWindowLevel:
-        return ProcAppleWMSetWindowLevel(client);
-    case X_AppleWMSetCanQuit:
-        return ProcAppleWMSetCanQuit(client);
-    case X_AppleWMFrameGetRect:
-        return ProcAppleWMFrameGetRect(client);
-    case X_AppleWMFrameHitTest:
-        return ProcAppleWMFrameHitTest(client);
-    case X_AppleWMFrameDraw:
-        return ProcAppleWMFrameDraw(client);
-    default:
-        return BadRequest;
-    }
-}
-
-static void
-SNotifyEvent(from, to)
-    xAppleWMNotifyEvent *from, *to;
-{
-    to->type = from->type;
-    to->kind = from->kind;
-    cpswaps (from->sequenceNumber, to->sequenceNumber);
-    cpswapl (from->time, to->time);
-    cpswapl (from->arg, to->arg);
-}
-
-static int
-SProcAppleWMQueryVersion(
-    register ClientPtr  client
-)
-{
-    register int n;
-    REQUEST(xAppleWMQueryVersionReq);
-    swaps(&stuff->length, n);
-    return ProcAppleWMQueryVersion(client);
-}
-
-static int
-SProcAppleWMDispatch (
-    register ClientPtr  client
-)
-{
-    REQUEST(xReq);
-
-    /* It is bound to be non-local when there is byte swapping */
-    if (!LocalClient(client))
-        return WMErrorBase + AppleWMClientNotLocal;
-
-    /* only local clients are allowed WM access */
-    switch (stuff->data)
-    {
-    case X_AppleWMQueryVersion:
-        return SProcAppleWMQueryVersion(client);
-    default:
-        return BadRequest;
-    }
-}
diff --git a/hw/darwin/quartz/applewmExt.h b/hw/darwin/quartz/applewmExt.h
deleted file mode 100644
index 60d49ef..0000000
--- a/hw/darwin/quartz/applewmExt.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * External interface for the server's AppleWM support
- */
-/**************************************************************************
-
-Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved.
-Copyright (c) 2003-2004 Torrey T. Lyons. 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, sub license, 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 PRECISION INSIGHT AND/OR ITS 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.
-
-**************************************************************************/
-
-#ifndef _APPLEWMEXT_H_
-#define _APPLEWMEXT_H_
-
-#include "window.h"
-
-typedef int (*DisableUpdateProc)(void);
-typedef int (*EnableUpdateProc)(void);
-typedef int (*SetWindowLevelProc)(WindowPtr pWin, int level);
-typedef int (*FrameGetRectProc)(int type, int class, const BoxRec *outer,
-                                const BoxRec *inner, BoxRec *ret);
-typedef int (*FrameHitTestProc)(int class, int x, int y,
-                                const BoxRec *outer,
-                                const BoxRec *inner, int *ret);
-typedef int (*FrameDrawProc)(WindowPtr pWin, int class, unsigned int attr,
-                             const BoxRec *outer, const BoxRec *inner,
-                             unsigned int title_len,
-                             const unsigned char *title_bytes);
-
-/*
- * AppleWM implementation function list
- */
-typedef struct _AppleWMProcs {
-    DisableUpdateProc DisableUpdate;
-    EnableUpdateProc EnableUpdate;
-    SetWindowLevelProc SetWindowLevel;
-    FrameGetRectProc FrameGetRect;
-    FrameHitTestProc FrameHitTest;
-    FrameDrawProc FrameDraw;
-} AppleWMProcsRec, *AppleWMProcsPtr;
-
-void AppleWMExtensionInit(
-    AppleWMProcsPtr procsPtr
-);
-
-void AppleWMSetScreenOrigin(
-    WindowPtr pWin
-);
-
-Bool AppleWMDoReorderWindow(
-    WindowPtr pWin
-);
-
-void AppleWMSendEvent(
-    int             /* type */,
-    unsigned int    /* mask */,
-    int             /* which */,
-    int             /* arg */
-);
-
-unsigned int AppleWMSelectedEvents(
-    void
-);
-
-#endif /* _APPLEWMEXT_H_ */
diff --git a/hw/darwin/quartz/keysym2ucs.c b/hw/darwin/quartz/keysym2ucs.c
deleted file mode 100644
index 8626ebc..0000000
--- a/hw/darwin/quartz/keysym2ucs.c
+++ /dev/null
@@ -1,909 +0,0 @@
-/* 
- *
- * This module converts keysym values into the corresponding ISO 10646
- * (UCS, Unicode) values.
- *
- * The array keysymtab[] contains pairs of X11 keysym values for graphical
- * characters and the corresponding Unicode value. The function
- * keysym2ucs() maps a keysym onto a Unicode value using a binary search,
- * therefore keysymtab[] must remain SORTED by keysym value.
- *
- * The keysym -> UTF-8 conversion will hopefully one day be provided
- * by Xlib via XmbLookupString() and should ideally not have to be
- * done in X applications. But we are not there yet.
- *
- * We allow to represent any UCS character in the range U-00000000 to
- * U-00FFFFFF by a keysym value in the range 0x01000000 to 0x01ffffff.
- * This admittedly does not cover the entire 31-bit space of UCS, but
- * it does cover all of the characters up to U-10FFFF, which can be
- * represented by UTF-16, and more, and it is very unlikely that higher
- * UCS codes will ever be assigned by ISO. So to get Unicode character
- * U+ABCD you can directly use keysym 0x0100abcd.
- *
- * NOTE: The comments in the table below contain the actual character
- * encoded in UTF-8, so for viewing and editing best use an editor in
- * UTF-8 mode.
- *
- * Author: Markus G. Kuhn <mkuhn at acm.org>, University of Cambridge, April 2001
- *
- * Special thanks to Richard Verhoeven <river at win.tue.nl> for preparing
- * an initial draft of the mapping table.
- *
- * This software is in the public domain. Share and enjoy!
- *
- * AUTOMATICALLY GENERATED FILE, DO NOT EDIT !!! (unicode/convmap.pl)
- */
-
-#include "keysym2ucs.h"
-
-#include <stdlib.h>
-#include <string.h>
-
-struct codepair {
-  unsigned short keysym;
-  unsigned short ucs;
-};
-
-const static struct codepair keysymtab[] = {
-  { 0x01a1, 0x0104 },
-  { 0x01a2, 0x02d8 },
-  { 0x01a3, 0x0141 },
-  { 0x01a5, 0x013d },
-  { 0x01a6, 0x015a },
-  { 0x01a9, 0x0160 },
-  { 0x01aa, 0x015e },
-  { 0x01ab, 0x0164 },
-  { 0x01ac, 0x0179 },
-  { 0x01ae, 0x017d },
-  { 0x01af, 0x017b },
-  { 0x01b1, 0x0105 },
-  { 0x01b2, 0x02db },
-  { 0x01b3, 0x0142 },
-  { 0x01b5, 0x013e },
-  { 0x01b6, 0x015b },
-  { 0x01b7, 0x02c7 },
-  { 0x01b9, 0x0161 },
-  { 0x01ba, 0x015f },
-  { 0x01bb, 0x0165 },
-  { 0x01bc, 0x017a },
-  { 0x01bd, 0x02dd },
-  { 0x01be, 0x017e },
-  { 0x01bf, 0x017c },
-  { 0x01c0, 0x0154 },
-  { 0x01c3, 0x0102 },
-  { 0x01c5, 0x0139 },
-  { 0x01c6, 0x0106 },
-  { 0x01c8, 0x010c },
-  { 0x01ca, 0x0118 },
-  { 0x01cc, 0x011a },
-  { 0x01cf, 0x010e },
-  { 0x01d0, 0x0110 },
-  { 0x01d1, 0x0143 },
-  { 0x01d2, 0x0147 },
-  { 0x01d5, 0x0150 },
-  { 0x01d8, 0x0158 },
-  { 0x01d9, 0x016e },
-  { 0x01db, 0x0170 },
-  { 0x01de, 0x0162 },
-  { 0x01e0, 0x0155 },
-  { 0x01e3, 0x0103 },
-  { 0x01e5, 0x013a },
-  { 0x01e6, 0x0107 },
-  { 0x01e8, 0x010d },
-  { 0x01ea, 0x0119 },
-  { 0x01ec, 0x011b },
-  { 0x01ef, 0x010f },
-  { 0x01f0, 0x0111 },
-  { 0x01f1, 0x0144 },
-  { 0x01f2, 0x0148 },
-  { 0x01f5, 0x0151 },
-  { 0x01f8, 0x0159 },
-  { 0x01f9, 0x016f },
-  { 0x01fb, 0x0171 },
-  { 0x01fe, 0x0163 },
-  { 0x01ff, 0x02d9 },
-  { 0x02a1, 0x0126 },
-  { 0x02a6, 0x0124 },
-  { 0x02a9, 0x0130 },
-  { 0x02ab, 0x011e },
-  { 0x02ac, 0x0134 },
-  { 0x02b1, 0x0127 },
-  { 0x02b6, 0x0125 },
-  { 0x02b9, 0x0131 },
-  { 0x02bb, 0x011f },
-  { 0x02bc, 0x0135 },
-  { 0x02c5, 0x010a },
-  { 0x02c6, 0x0108 },
-  { 0x02d5, 0x0120 },
-  { 0x02d8, 0x011c },
-  { 0x02dd, 0x016c },
-  { 0x02de, 0x015c },
-  { 0x02e5, 0x010b },
-  { 0x02e6, 0x0109 },
-  { 0x02f5, 0x0121 },
-  { 0x02f8, 0x011d },
-  { 0x02fd, 0x016d },
-  { 0x02fe, 0x015d },
-  { 0x03a2, 0x0138 },
-  { 0x03a3, 0x0156 },
-  { 0x03a5, 0x0128 },
-  { 0x03a6, 0x013b },
-  { 0x03aa, 0x0112 },
-  { 0x03ab, 0x0122 },
-  { 0x03ac, 0x0166 },
-  { 0x03b3, 0x0157 },
-  { 0x03b5, 0x0129 },
-  { 0x03b6, 0x013c },
-  { 0x03ba, 0x0113 },
-  { 0x03bb, 0x0123 },
-  { 0x03bc, 0x0167 },
-  { 0x03bd, 0x014a },
-  { 0x03bf, 0x014b },
-  { 0x03c0, 0x0100 },
-  { 0x03c7, 0x012e },
-  { 0x03cc, 0x0116 },
-  { 0x03cf, 0x012a },
-  { 0x03d1, 0x0145 },
-  { 0x03d2, 0x014c },
-  { 0x03d3, 0x0136 },
-  { 0x03d9, 0x0172 },
-  { 0x03dd, 0x0168 },
-  { 0x03de, 0x016a },
-  { 0x03e0, 0x0101 },
-  { 0x03e7, 0x012f },
-  { 0x03ec, 0x0117 },
-  { 0x03ef, 0x012b },
-  { 0x03f1, 0x0146 },
-  { 0x03f2, 0x014d },
-  { 0x03f3, 0x0137 },
-  { 0x03f9, 0x0173 },
-  { 0x03fd, 0x0169 },
-  { 0x03fe, 0x016b },
-  { 0x047e, 0x203e },
-  { 0x04a1, 0x3002 },
-  { 0x04a2, 0x300c },
-  { 0x04a3, 0x300d },
-  { 0x04a4, 0x3001 },
-  { 0x04a5, 0x30fb },
-  { 0x04a6, 0x30f2 },
-  { 0x04a7, 0x30a1 },
-  { 0x04a8, 0x30a3 },
-  { 0x04a9, 0x30a5 },
-  { 0x04aa, 0x30a7 },
-  { 0x04ab, 0x30a9 },
-  { 0x04ac, 0x30e3 },
-  { 0x04ad, 0x30e5 },
-  { 0x04ae, 0x30e7 },
-  { 0x04af, 0x30c3 },
-  { 0x04b0, 0x30fc },
-  { 0x04b1, 0x30a2 },
-  { 0x04b2, 0x30a4 },
-  { 0x04b3, 0x30a6 },
-  { 0x04b4, 0x30a8 },
-  { 0x04b5, 0x30aa },
-  { 0x04b6, 0x30ab },
-  { 0x04b7, 0x30ad },
-  { 0x04b8, 0x30af },
-  { 0x04b9, 0x30b1 },
-  { 0x04ba, 0x30b3 },
-  { 0x04bb, 0x30b5 },
-  { 0x04bc, 0x30b7 },
-  { 0x04bd, 0x30b9 },
-  { 0x04be, 0x30bb },
-  { 0x04bf, 0x30bd },
-  { 0x04c0, 0x30bf },
-  { 0x04c1, 0x30c1 },
-  { 0x04c2, 0x30c4 },
-  { 0x04c3, 0x30c6 },
-  { 0x04c4, 0x30c8 },
-  { 0x04c5, 0x30ca },
-  { 0x04c6, 0x30cb },
-  { 0x04c7, 0x30cc },
-  { 0x04c8, 0x30cd },
-  { 0x04c9, 0x30ce },
-  { 0x04ca, 0x30cf },
-  { 0x04cb, 0x30d2 },
-  { 0x04cc, 0x30d5 },
-  { 0x04cd, 0x30d8 },
-  { 0x04ce, 0x30db },
-  { 0x04cf, 0x30de },
-  { 0x04d0, 0x30df },
-  { 0x04d1, 0x30e0 },
-  { 0x04d2, 0x30e1 },
-  { 0x04d3, 0x30e2 },
-  { 0x04d4, 0x30e4 },
-  { 0x04d5, 0x30e6 },
-  { 0x04d6, 0x30e8 },
-  { 0x04d7, 0x30e9 },
-  { 0x04d8, 0x30ea },
-  { 0x04d9, 0x30eb },
-  { 0x04da, 0x30ec },
-  { 0x04db, 0x30ed },
-  { 0x04dc, 0x30ef },
-  { 0x04dd, 0x30f3 },
-  { 0x04de, 0x309b },
-  { 0x04df, 0x309c },
-  { 0x05ac, 0x060c },
-  { 0x05bb, 0x061b },
-  { 0x05bf, 0x061f },
-  { 0x05c1, 0x0621 },
-  { 0x05c2, 0x0622 },
-  { 0x05c3, 0x0623 },
-  { 0x05c4, 0x0624 },
-  { 0x05c5, 0x0625 },
-  { 0x05c6, 0x0626 },
-  { 0x05c7, 0x0627 },
-  { 0x05c8, 0x0628 },
-  { 0x05c9, 0x0629 },
-  { 0x05ca, 0x062a },
-  { 0x05cb, 0x062b },
-  { 0x05cc, 0x062c },
-  { 0x05cd, 0x062d },
-  { 0x05ce, 0x062e },
-  { 0x05cf, 0x062f },
-  { 0x05d0, 0x0630 },
-  { 0x05d1, 0x0631 },
-  { 0x05d2, 0x0632 },
-  { 0x05d3, 0x0633 },
-  { 0x05d4, 0x0634 },
-  { 0x05d5, 0x0635 },
-  { 0x05d6, 0x0636 },
-  { 0x05d7, 0x0637 },
-  { 0x05d8, 0x0638 },
-  { 0x05d9, 0x0639 },
-  { 0x05da, 0x063a },
-  { 0x05e0, 0x0640 },
-  { 0x05e1, 0x0641 },
-  { 0x05e2, 0x0642 },
-  { 0x05e3, 0x0643 },
-  { 0x05e4, 0x0644 },
-  { 0x05e5, 0x0645 },
-  { 0x05e6, 0x0646 },
-  { 0x05e7, 0x0647 },
-  { 0x05e8, 0x0648 },
-  { 0x05e9, 0x0649 },
-  { 0x05ea, 0x064a },
-  { 0x05eb, 0x064b },
-  { 0x05ec, 0x064c },
-  { 0x05ed, 0x064d },
-  { 0x05ee, 0x064e },
-  { 0x05ef, 0x064f },
-  { 0x05f0, 0x0650 },
-  { 0x05f1, 0x0651 },
-  { 0x05f2, 0x0652 },
-  { 0x06a1, 0x0452 },
-  { 0x06a2, 0x0453 },
-  { 0x06a3, 0x0451 },
-  { 0x06a4, 0x0454 },
-  { 0x06a5, 0x0455 },
-  { 0x06a6, 0x0456 },
-  { 0x06a7, 0x0457 },
-  { 0x06a8, 0x0458 },
-  { 0x06a9, 0x0459 },
-  { 0x06aa, 0x045a },
-  { 0x06ab, 0x045b },
-  { 0x06ac, 0x045c },
-  { 0x06ae, 0x045e },
-  { 0x06af, 0x045f },
-  { 0x06b0, 0x2116 },
-  { 0x06b1, 0x0402 },
-  { 0x06b2, 0x0403 },
-  { 0x06b3, 0x0401 },
-  { 0x06b4, 0x0404 },
-  { 0x06b5, 0x0405 },
-  { 0x06b6, 0x0406 },
-  { 0x06b7, 0x0407 },
-  { 0x06b8, 0x0408 },
-  { 0x06b9, 0x0409 },
-  { 0x06ba, 0x040a },
-  { 0x06bb, 0x040b },
-  { 0x06bc, 0x040c },
-  { 0x06be, 0x040e },
-  { 0x06bf, 0x040f },
-  { 0x06c0, 0x044e },
-  { 0x06c1, 0x0430 },
-  { 0x06c2, 0x0431 },
-  { 0x06c3, 0x0446 },
-  { 0x06c4, 0x0434 },
-  { 0x06c5, 0x0435 },
-  { 0x06c6, 0x0444 },
-  { 0x06c7, 0x0433 },
-  { 0x06c8, 0x0445 },
-  { 0x06c9, 0x0438 },
-  { 0x06ca, 0x0439 },
-  { 0x06cb, 0x043a },
-  { 0x06cc, 0x043b },
-  { 0x06cd, 0x043c },
-  { 0x06ce, 0x043d },
-  { 0x06cf, 0x043e },
-  { 0x06d0, 0x043f },
-  { 0x06d1, 0x044f },
-  { 0x06d2, 0x0440 },
-  { 0x06d3, 0x0441 },
-  { 0x06d4, 0x0442 },
-  { 0x06d5, 0x0443 },
-  { 0x06d6, 0x0436 },
-  { 0x06d7, 0x0432 },
-  { 0x06d8, 0x044c },
-  { 0x06d9, 0x044b },
-  { 0x06da, 0x0437 },
-  { 0x06db, 0x0448 },
-  { 0x06dc, 0x044d },
-  { 0x06dd, 0x0449 },
-  { 0x06de, 0x0447 },
-  { 0x06df, 0x044a },
-  { 0x06e0, 0x042e },
-  { 0x06e1, 0x0410 },
-  { 0x06e2, 0x0411 },
-  { 0x06e3, 0x0426 },
-  { 0x06e4, 0x0414 },
-  { 0x06e5, 0x0415 },
-  { 0x06e6, 0x0424 },
-  { 0x06e7, 0x0413 },
-  { 0x06e8, 0x0425 },
-  { 0x06e9, 0x0418 },
-  { 0x06ea, 0x0419 },
-  { 0x06eb, 0x041a },
-  { 0x06ec, 0x041b },
-  { 0x06ed, 0x041c },
-  { 0x06ee, 0x041d },
-  { 0x06ef, 0x041e },
-  { 0x06f0, 0x041f },
-  { 0x06f1, 0x042f },
-  { 0x06f2, 0x0420 },
-  { 0x06f3, 0x0421 },
-  { 0x06f4, 0x0422 },
-  { 0x06f5, 0x0423 },
-  { 0x06f6, 0x0416 },
-  { 0x06f7, 0x0412 },
-  { 0x06f8, 0x042c },
-  { 0x06f9, 0x042b },
-  { 0x06fa, 0x0417 },
-  { 0x06fb, 0x0428 },
-  { 0x06fc, 0x042d },
-  { 0x06fd, 0x0429 },
-  { 0x06fe, 0x0427 },
-  { 0x06ff, 0x042a },
-  { 0x07a1, 0x0386 },
-  { 0x07a2, 0x0388 },
-  { 0x07a3, 0x0389 },
-  { 0x07a4, 0x038a },
-  { 0x07a5, 0x03aa },
-  { 0x07a7, 0x038c },
-  { 0x07a8, 0x038e },
-  { 0x07a9, 0x03ab },
-  { 0x07ab, 0x038f },
-  { 0x07ae, 0x0385 },
-  { 0x07af, 0x2015 },
-  { 0x07b1, 0x03ac },
-  { 0x07b2, 0x03ad },
-  { 0x07b3, 0x03ae },
-  { 0x07b4, 0x03af },
-  { 0x07b5, 0x03ca },
-  { 0x07b6, 0x0390 },
-  { 0x07b7, 0x03cc },
-  { 0x07b8, 0x03cd },
-  { 0x07b9, 0x03cb },
-  { 0x07ba, 0x03b0 },
-  { 0x07bb, 0x03ce },
-  { 0x07c1, 0x0391 },
-  { 0x07c2, 0x0392 },
-  { 0x07c3, 0x0393 },
-  { 0x07c4, 0x0394 },
-  { 0x07c5, 0x0395 },
-  { 0x07c6, 0x0396 },
-  { 0x07c7, 0x0397 },
-  { 0x07c8, 0x0398 },
-  { 0x07c9, 0x0399 },
-  { 0x07ca, 0x039a },
-  { 0x07cb, 0x039b },
-  { 0x07cc, 0x039c },
-  { 0x07cd, 0x039d },
-  { 0x07ce, 0x039e },
-  { 0x07cf, 0x039f },
-  { 0x07d0, 0x03a0 },
-  { 0x07d1, 0x03a1 },
-  { 0x07d2, 0x03a3 },
-  { 0x07d4, 0x03a4 },
-  { 0x07d5, 0x03a5 },
-  { 0x07d6, 0x03a6 },
-  { 0x07d7, 0x03a7 },
-  { 0x07d8, 0x03a8 },
-  { 0x07d9, 0x03a9 },
-  { 0x07e1, 0x03b1 },
-  { 0x07e2, 0x03b2 },
-  { 0x07e3, 0x03b3 },
-  { 0x07e4, 0x03b4 },
-  { 0x07e5, 0x03b5 },
-  { 0x07e6, 0x03b6 },
-  { 0x07e7, 0x03b7 },
-  { 0x07e8, 0x03b8 },
-  { 0x07e9, 0x03b9 },
-  { 0x07ea, 0x03ba },
-  { 0x07eb, 0x03bb },
-  { 0x07ec, 0x03bc },
-  { 0x07ed, 0x03bd },
-  { 0x07ee, 0x03be },
-  { 0x07ef, 0x03bf },
-  { 0x07f0, 0x03c0 },
-  { 0x07f1, 0x03c1 },
-  { 0x07f2, 0x03c3 },
-  { 0x07f3, 0x03c2 },
-  { 0x07f4, 0x03c4 },
-  { 0x07f5, 0x03c5 },
-  { 0x07f6, 0x03c6 },
-  { 0x07f7, 0x03c7 },
-  { 0x07f8, 0x03c8 },
-  { 0x07f9, 0x03c9 },
-  { 0x08a1, 0x23b7 },
-  { 0x08a2, 0x250c },
-  { 0x08a3, 0x2500 },
-  { 0x08a4, 0x2320 },
-  { 0x08a5, 0x2321 },
-  { 0x08a6, 0x2502 },
-  { 0x08a7, 0x23a1 },
-  { 0x08a8, 0x23a3 },
-  { 0x08a9, 0x23a4 },
-  { 0x08aa, 0x23a6 },
-  { 0x08ab, 0x239b },
-  { 0x08ac, 0x239d },
-  { 0x08ad, 0x239e },
-  { 0x08ae, 0x23a0 },
-  { 0x08af, 0x23a8 },
-  { 0x08b0, 0x23ac },
-  { 0x08bc, 0x2264 },
-  { 0x08bd, 0x2260 },
-  { 0x08be, 0x2265 },
-  { 0x08bf, 0x222b },
-  { 0x08c0, 0x2234 },
-  { 0x08c1, 0x221d },
-  { 0x08c2, 0x221e },
-  { 0x08c5, 0x2207 },
-  { 0x08c8, 0x223c },
-  { 0x08c9, 0x2243 },
-  { 0x08cd, 0x21d4 },
-  { 0x08ce, 0x21d2 },
-  { 0x08cf, 0x2261 },
-  { 0x08d6, 0x221a },
-  { 0x08da, 0x2282 },
-  { 0x08db, 0x2283 },
-  { 0x08dc, 0x2229 },
-  { 0x08dd, 0x222a },
-  { 0x08de, 0x2227 },
-  { 0x08df, 0x2228 },
-  { 0x08ef, 0x2202 },
-  { 0x08f6, 0x0192 },
-  { 0x08fb, 0x2190 },
-  { 0x08fc, 0x2191 },
-  { 0x08fd, 0x2192 },
-  { 0x08fe, 0x2193 },
-  { 0x09e0, 0x25c6 },
-  { 0x09e1, 0x2592 },
-  { 0x09e2, 0x2409 },
-  { 0x09e3, 0x240c },
-  { 0x09e4, 0x240d },
-  { 0x09e5, 0x240a },
-  { 0x09e8, 0x2424 },
-  { 0x09e9, 0x240b },
-  { 0x09ea, 0x2518 },
-  { 0x09eb, 0x2510 },
-  { 0x09ec, 0x250c },
-  { 0x09ed, 0x2514 },
-  { 0x09ee, 0x253c },
-  { 0x09ef, 0x23ba },
-  { 0x09f0, 0x23bb },
-  { 0x09f1, 0x2500 },
-  { 0x09f2, 0x23bc },
-  { 0x09f3, 0x23bd },
-  { 0x09f4, 0x251c },
-  { 0x09f5, 0x2524 },
-  { 0x09f6, 0x2534 },
-  { 0x09f7, 0x252c },
-  { 0x09f8, 0x2502 },
-  { 0x0aa1, 0x2003 },
-  { 0x0aa2, 0x2002 },
-  { 0x0aa3, 0x2004 },
-  { 0x0aa4, 0x2005 },
-  { 0x0aa5, 0x2007 },
-  { 0x0aa6, 0x2008 },
-  { 0x0aa7, 0x2009 },
-  { 0x0aa8, 0x200a },
-  { 0x0aa9, 0x2014 },
-  { 0x0aaa, 0x2013 },
-  { 0x0aae, 0x2026 },
-  { 0x0aaf, 0x2025 },
-  { 0x0ab0, 0x2153 },
-  { 0x0ab1, 0x2154 },
-  { 0x0ab2, 0x2155 },
-  { 0x0ab3, 0x2156 },
-  { 0x0ab4, 0x2157 },
-  { 0x0ab5, 0x2158 },
-  { 0x0ab6, 0x2159 },
-  { 0x0ab7, 0x215a },
-  { 0x0ab8, 0x2105 },
-  { 0x0abb, 0x2012 },
-  { 0x0abc, 0x2329 },
-  { 0x0abe, 0x232a },
-  { 0x0ac3, 0x215b },
-  { 0x0ac4, 0x215c },
-  { 0x0ac5, 0x215d },
-  { 0x0ac6, 0x215e },
-  { 0x0ac9, 0x2122 },
-  { 0x0aca, 0x2613 },
-  { 0x0acc, 0x25c1 },
-  { 0x0acd, 0x25b7 },
-  { 0x0ace, 0x25cb },
-  { 0x0acf, 0x25af },
-  { 0x0ad0, 0x2018 },
-  { 0x0ad1, 0x2019 },
-  { 0x0ad2, 0x201c },
-  { 0x0ad3, 0x201d },
-  { 0x0ad4, 0x211e },
-  { 0x0ad6, 0x2032 },
-  { 0x0ad7, 0x2033 },
-  { 0x0ad9, 0x271d },
-  { 0x0adb, 0x25ac },
-  { 0x0adc, 0x25c0 },
-  { 0x0add, 0x25b6 },
-  { 0x0ade, 0x25cf },
-  { 0x0adf, 0x25ae },
-  { 0x0ae0, 0x25e6 },
-  { 0x0ae1, 0x25ab },
-  { 0x0ae2, 0x25ad },
-  { 0x0ae3, 0x25b3 },
-  { 0x0ae4, 0x25bd },
-  { 0x0ae5, 0x2606 },
-  { 0x0ae6, 0x2022 },
-  { 0x0ae7, 0x25aa },
-  { 0x0ae8, 0x25b2 },
-  { 0x0ae9, 0x25bc },
-  { 0x0aea, 0x261c },
-  { 0x0aeb, 0x261e },
-  { 0x0aec, 0x2663 },
-  { 0x0aed, 0x2666 },
-  { 0x0aee, 0x2665 },
-  { 0x0af0, 0x2720 },
-  { 0x0af1, 0x2020 },
-  { 0x0af2, 0x2021 },
-  { 0x0af3, 0x2713 },
-  { 0x0af4, 0x2717 },
-  { 0x0af5, 0x266f },
-  { 0x0af6, 0x266d },
-  { 0x0af7, 0x2642 },
-  { 0x0af8, 0x2640 },
-  { 0x0af9, 0x260e },
-  { 0x0afa, 0x2315 },
-  { 0x0afb, 0x2117 },
-  { 0x0afc, 0x2038 },
-  { 0x0afd, 0x201a },
-  { 0x0afe, 0x201e },
-  { 0x0ba3, 0x003c },
-  { 0x0ba6, 0x003e },
-  { 0x0ba8, 0x2228 },
-  { 0x0ba9, 0x2227 },
-  { 0x0bc0, 0x00af },
-  { 0x0bc2, 0x22a5 },
-  { 0x0bc3, 0x2229 },
-  { 0x0bc4, 0x230a },
-  { 0x0bc6, 0x005f },
-  { 0x0bca, 0x2218 },
-  { 0x0bcc, 0x2395 },
-  { 0x0bce, 0x22a4 },
-  { 0x0bcf, 0x25cb },
-  { 0x0bd3, 0x2308 },
-  { 0x0bd6, 0x222a },
-  { 0x0bd8, 0x2283 },
-  { 0x0bda, 0x2282 },
-  { 0x0bdc, 0x22a2 },
-  { 0x0bfc, 0x22a3 },
-  { 0x0cdf, 0x2017 },
-  { 0x0ce0, 0x05d0 },
-  { 0x0ce1, 0x05d1 },
-  { 0x0ce2, 0x05d2 },
-  { 0x0ce3, 0x05d3 },
-  { 0x0ce4, 0x05d4 },
-  { 0x0ce5, 0x05d5 },
-  { 0x0ce6, 0x05d6 },
-  { 0x0ce7, 0x05d7 },
-  { 0x0ce8, 0x05d8 },
-  { 0x0ce9, 0x05d9 },
-  { 0x0cea, 0x05da },
-  { 0x0ceb, 0x05db },
-  { 0x0cec, 0x05dc },
-  { 0x0ced, 0x05dd },
-  { 0x0cee, 0x05de },
-  { 0x0cef, 0x05df },
-  { 0x0cf0, 0x05e0 },
-  { 0x0cf1, 0x05e1 },
-  { 0x0cf2, 0x05e2 },
-  { 0x0cf3, 0x05e3 },
-  { 0x0cf4, 0x05e4 },
-  { 0x0cf5, 0x05e5 },
-  { 0x0cf6, 0x05e6 },
-  { 0x0cf7, 0x05e7 },
-  { 0x0cf8, 0x05e8 },
-  { 0x0cf9, 0x05e9 },
-  { 0x0cfa, 0x05ea },
-  { 0x0da1, 0x0e01 },
-  { 0x0da2, 0x0e02 },
-  { 0x0da3, 0x0e03 },
-  { 0x0da4, 0x0e04 },
-  { 0x0da5, 0x0e05 },
-  { 0x0da6, 0x0e06 },
-  { 0x0da7, 0x0e07 },
-  { 0x0da8, 0x0e08 },
-  { 0x0da9, 0x0e09 },
-  { 0x0daa, 0x0e0a },
-  { 0x0dab, 0x0e0b },
-  { 0x0dac, 0x0e0c },
-  { 0x0dad, 0x0e0d },
-  { 0x0dae, 0x0e0e },
-  { 0x0daf, 0x0e0f },
-  { 0x0db0, 0x0e10 },
-  { 0x0db1, 0x0e11 },
-  { 0x0db2, 0x0e12 },
-  { 0x0db3, 0x0e13 },
-  { 0x0db4, 0x0e14 },
-  { 0x0db5, 0x0e15 },
-  { 0x0db6, 0x0e16 },
-  { 0x0db7, 0x0e17 },
-  { 0x0db8, 0x0e18 },
-  { 0x0db9, 0x0e19 },
-  { 0x0dba, 0x0e1a },
-  { 0x0dbb, 0x0e1b },
-  { 0x0dbc, 0x0e1c },
-  { 0x0dbd, 0x0e1d },
-  { 0x0dbe, 0x0e1e },
-  { 0x0dbf, 0x0e1f },
-  { 0x0dc0, 0x0e20 },
-  { 0x0dc1, 0x0e21 },
-  { 0x0dc2, 0x0e22 },
-  { 0x0dc3, 0x0e23 },
-  { 0x0dc4, 0x0e24 },
-  { 0x0dc5, 0x0e25 },
-  { 0x0dc6, 0x0e26 },
-  { 0x0dc7, 0x0e27 },
-  { 0x0dc8, 0x0e28 },
-  { 0x0dc9, 0x0e29 },
-  { 0x0dca, 0x0e2a },
-  { 0x0dcb, 0x0e2b },
-  { 0x0dcc, 0x0e2c },
-  { 0x0dcd, 0x0e2d },
-  { 0x0dce, 0x0e2e },
-  { 0x0dcf, 0x0e2f },
-  { 0x0dd0, 0x0e30 },
-  { 0x0dd1, 0x0e31 },
-  { 0x0dd2, 0x0e32 },
-  { 0x0dd3, 0x0e33 },
-  { 0x0dd4, 0x0e34 },
-  { 0x0dd5, 0x0e35 },
-  { 0x0dd6, 0x0e36 },
-  { 0x0dd7, 0x0e37 },
-  { 0x0dd8, 0x0e38 },
-  { 0x0dd9, 0x0e39 },
-  { 0x0dda, 0x0e3a },
-  { 0x0ddf, 0x0e3f },
-  { 0x0de0, 0x0e40 },
-  { 0x0de1, 0x0e41 },
-  { 0x0de2, 0x0e42 },
-  { 0x0de3, 0x0e43 },
-  { 0x0de4, 0x0e44 },
-  { 0x0de5, 0x0e45 },
-  { 0x0de6, 0x0e46 },
-  { 0x0de7, 0x0e47 },
-  { 0x0de8, 0x0e48 },
-  { 0x0de9, 0x0e49 },
-  { 0x0dea, 0x0e4a },
-  { 0x0deb, 0x0e4b },
-  { 0x0dec, 0x0e4c },
-  { 0x0ded, 0x0e4d },
-  { 0x0df0, 0x0e50 },
-  { 0x0df1, 0x0e51 },
-  { 0x0df2, 0x0e52 },
-  { 0x0df3, 0x0e53 },
-  { 0x0df4, 0x0e54 },
-  { 0x0df5, 0x0e55 },
-  { 0x0df6, 0x0e56 },
-  { 0x0df7, 0x0e57 },
-  { 0x0df8, 0x0e58 },
-  { 0x0df9, 0x0e59 },
-  { 0x0ea1, 0x3131 },
-  { 0x0ea2, 0x3132 },
-  { 0x0ea3, 0x3133 },
-  { 0x0ea4, 0x3134 },
-  { 0x0ea5, 0x3135 },
-  { 0x0ea6, 0x3136 },
-  { 0x0ea7, 0x3137 },
-  { 0x0ea8, 0x3138 },
-  { 0x0ea9, 0x3139 },
-  { 0x0eaa, 0x313a },
-  { 0x0eab, 0x313b },
-  { 0x0eac, 0x313c },
-  { 0x0ead, 0x313d },
-  { 0x0eae, 0x313e },
-  { 0x0eaf, 0x313f },
-  { 0x0eb0, 0x3140 },
-  { 0x0eb1, 0x3141 },
-  { 0x0eb2, 0x3142 },
-  { 0x0eb3, 0x3143 },
-  { 0x0eb4, 0x3144 },
-  { 0x0eb5, 0x3145 },
-  { 0x0eb6, 0x3146 },
-  { 0x0eb7, 0x3147 },
-  { 0x0eb8, 0x3148 },
-  { 0x0eb9, 0x3149 },
-  { 0x0eba, 0x314a },
-  { 0x0ebb, 0x314b },
-  { 0x0ebc, 0x314c },
-  { 0x0ebd, 0x314d },
-  { 0x0ebe, 0x314e },
-  { 0x0ebf, 0x314f },
-  { 0x0ec0, 0x3150 },
-  { 0x0ec1, 0x3151 },
-  { 0x0ec2, 0x3152 },
-  { 0x0ec3, 0x3153 },
-  { 0x0ec4, 0x3154 },
-  { 0x0ec5, 0x3155 },
-  { 0x0ec6, 0x3156 },
-  { 0x0ec7, 0x3157 },
-  { 0x0ec8, 0x3158 },
-  { 0x0ec9, 0x3159 },
-  { 0x0eca, 0x315a },
-  { 0x0ecb, 0x315b },
-  { 0x0ecc, 0x315c },
-  { 0x0ecd, 0x315d },
-  { 0x0ece, 0x315e },
-  { 0x0ecf, 0x315f },
-  { 0x0ed0, 0x3160 },
-  { 0x0ed1, 0x3161 },
-  { 0x0ed2, 0x3162 },
-  { 0x0ed3, 0x3163 },
-  { 0x0ed4, 0x11a8 },
-  { 0x0ed5, 0x11a9 },
-  { 0x0ed6, 0x11aa },
-  { 0x0ed7, 0x11ab },
-  { 0x0ed8, 0x11ac },
-  { 0x0ed9, 0x11ad },
-  { 0x0eda, 0x11ae },
-  { 0x0edb, 0x11af },
-  { 0x0edc, 0x11b0 },
-  { 0x0edd, 0x11b1 },
-  { 0x0ede, 0x11b2 },
-  { 0x0edf, 0x11b3 },
-  { 0x0ee0, 0x11b4 },
-  { 0x0ee1, 0x11b5 },
-  { 0x0ee2, 0x11b6 },
-  { 0x0ee3, 0x11b7 },
-  { 0x0ee4, 0x11b8 },
-  { 0x0ee5, 0x11b9 },
-  { 0x0ee6, 0x11ba },
-  { 0x0ee7, 0x11bb },
-  { 0x0ee8, 0x11bc },
-  { 0x0ee9, 0x11bd },
-  { 0x0eea, 0x11be },
-  { 0x0eeb, 0x11bf },
-  { 0x0eec, 0x11c0 },
-  { 0x0eed, 0x11c1 },
-  { 0x0eee, 0x11c2 },
-  { 0x0eef, 0x316d },
-  { 0x0ef0, 0x3171 },
-  { 0x0ef1, 0x3178 },
-  { 0x0ef2, 0x317f },
-  { 0x0ef3, 0x3181 },
-  { 0x0ef4, 0x3184 },
-  { 0x0ef5, 0x3186 },
-  { 0x0ef6, 0x318d },
-  { 0x0ef7, 0x318e },
-  { 0x0ef8, 0x11eb },
-  { 0x0ef9, 0x11f0 },
-  { 0x0efa, 0x11f9 },
-  { 0x0eff, 0x20a9 },
-#if 0
-  /* FIXME: there is no keysym 0x13a4? But 0x20ac is EuroSign in both
-     keysym and Unicode */
-  { 0x13a4, 0x20ac },
-#endif
-  { 0x13bc, 0x0152 },
-  { 0x13bd, 0x0153 },
-  { 0x13be, 0x0178 },
-  { 0x20ac, 0x20ac },
-
-  /* Special function keys. */
-
-  { 0xff08, 0x0008 },			/* XK_BackSpace */
-  { 0xff09, 0x0009 },			/* XK_Tab */
-  { 0xff0a, 0x000a },			/* XK_Linefeed */
-  { 0xff0d, 0x000d },			/* XK_Return */
-  { 0xff13, 0x0013 },			/* XK_Pause */
-  { 0xff1b, 0x001b },			/* XK_Escape */
-  { 0xff50, 0x0001 },			/* XK_Home */
-  { 0xff51, 0x001c },			/* XK_Left */
-  { 0xff52, 0x001e },			/* XK_Up */
-  { 0xff53, 0x001d },			/* XK_Right */
-  { 0xff54, 0x001f },			/* XK_Down */
-  { 0xff55, 0x000b },			/* XK_Prior */
-  { 0xff56, 0x000c },			/* XK_Next */
-  { 0xff57, 0x0004 },			/* XK_End */
-  { 0xff6a, 0x0005 },			/* XK_Help */
-  { 0xffff, 0x007f },			/* XK_Delete */
-};
-
-long keysym2ucs(int keysym)
-{
-    int min = 0;
-    int max = sizeof(keysymtab) / sizeof(struct codepair) - 1;
-    int mid;
-
-    /* first check for Latin-1 characters (1:1 mapping) */
-    if ((keysym >= 0x0020 && keysym <= 0x007e) ||
-        (keysym >= 0x00a0 && keysym <= 0x00ff))
-        return keysym;
-
-    /* also check for directly encoded 24-bit UCS characters */
-    if ((keysym & 0xff000000) == 0x01000000)
-	return keysym & 0x00ffffff;
-
-    /* binary search in table */
-    while (max >= min) {
-	mid = (min + max) / 2;
-	if (keysymtab[mid].keysym < keysym)
-	    min = mid + 1;
-	else if (keysymtab[mid].keysym > keysym)
-	    max = mid - 1;
-	else {
-	    /* found it */
-	    return keysymtab[mid].ucs;
-	}
-    }
-
-    /* no matching Unicode value found */
-    return -1;
-}
-
-static int reverse_compare (const void *a, const void *b)
-{
-    const struct codepair *ca = a, *cb = b;
-
-    return ca->ucs - cb->ucs;
-}
-
-int ucs2keysym(long ucs)
-{
-    static struct codepair *reverse_keysymtab;
-
-    int min = 0;
-    int max = sizeof(keysymtab) / sizeof(struct codepair) - 1;
-    int mid;
-
-    if (reverse_keysymtab == NULL)
-    {
-	reverse_keysymtab = malloc (sizeof (keysymtab));
-	memcpy (reverse_keysymtab, keysymtab, sizeof (keysymtab));
-
-	qsort (reverse_keysymtab,
-	       sizeof (keysymtab) / sizeof (struct codepair),
-	       sizeof (struct codepair),
-	       reverse_compare);
-    }
-
-    /* first check for Latin-1 characters (1:1 mapping) */
-    if ((ucs >= 0x0020 && ucs <= 0x007e) ||
-        (ucs >= 0x00a0 && ucs <= 0x00ff))
-        return ucs;
-
-    /* binary search in table */
-    while (max >= min) {
-	mid = (min + max) / 2;
-	if (reverse_keysymtab[mid].ucs < ucs)
-	    min = mid + 1;
-	else if (reverse_keysymtab[mid].ucs > ucs)
-	    max = mid - 1;
-	else {
-	    /* found it */
-	    return reverse_keysymtab[mid].keysym;
-	}
-    }
-
-    /* finally, assume a directly encoded 24-bit UCS character */
-    return ucs | 0x01000000;
-}
diff --git a/hw/darwin/quartz/keysym2ucs.h b/hw/darwin/quartz/keysym2ucs.h
deleted file mode 100644
index f5b7a18..0000000
--- a/hw/darwin/quartz/keysym2ucs.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * This module converts keysym values into the corresponding ISO 10646
- * (UCS, Unicode) values.
- *
- * The array keysymtab[] contains pairs of X11 keysym values for graphical
- * characters and the corresponding Unicode value. The function
- * keysym2ucs() maps a keysym onto a Unicode value using a binary search,
- * therefore keysymtab[] must remain SORTED by keysym value.
- *
- * The keysym -> UTF-8 conversion will hopefully one day be provided
- * by Xlib via XmbLookupString() and should ideally not have to be
- * done in X applications. But we are not there yet.
- *
- * We allow to represent any UCS character in the range U-00000000 to
- * U-00FFFFFF by a keysym value in the range 0x01000000 to 0x01ffffff.
- * This admittedly does not cover the entire 31-bit space of UCS, but
- * it does cover all of the characters up to U-10FFFF, which can be
- * represented by UTF-16, and more, and it is very unlikely that higher
- * UCS codes will ever be assigned by ISO. So to get Unicode character
- * U+ABCD you can directly use keysym 0x0100abcd.
- *
- * Author: Markus G. Kuhn <mkuhn at acm.org>, University of Cambridge, April 2001
- *
- * Special thanks to Richard Verhoeven <river at win.tue.nl> for preparing
- * an initial draft of the mapping table.
- *
- * This software is in the public domain. Share and enjoy!
- */
-
-#ifndef KEYSYM2UCS_H
-#define KEYSYM2UCS_H 1
-
-extern long keysym2ucs(int keysym);
-extern int ucs2keysym(long ucs);
-
-#endif /* KEYSYM2UCS_H */
diff --git a/hw/darwin/quartz/pseudoramiX.c b/hw/darwin/quartz/pseudoramiX.c
deleted file mode 100644
index b19c605..0000000
--- a/hw/darwin/quartz/pseudoramiX.c
+++ /dev/null
@@ -1,438 +0,0 @@
-/*
- * Minimal implementation of PanoramiX/Xinerama
- *
- * This is used in rootless mode where the underlying window server
- * already provides an abstracted view of multiple screens as one
- * large screen area.
- *
- * This code is largely based on panoramiX.c, which contains the
- * following copyright notice:
- */
-/*****************************************************************
-Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
-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.
-
-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
-DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
-BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL 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 Digital Equipment Corporation
-shall not be used in advertising or otherwise to promote the sale, use or other
-dealings in this Software without prior written authorization from Digital
-Equipment Corporation.
-******************************************************************/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "pseudoramiX.h"
-#include "extnsionst.h"
-#include "dixstruct.h"
-#include "window.h"
-#include <X11/extensions/panoramiXproto.h>
-#include "globals.h"
-
-extern int noPseudoramiXExtension;
-extern int noPanoramiXExtension;
-
-extern int ProcPanoramiXQueryVersion (ClientPtr client);
-
-static void PseudoramiXResetProc(ExtensionEntry *extEntry);
-
-static int ProcPseudoramiXQueryVersion(ClientPtr client);
-static int ProcPseudoramiXGetState(ClientPtr client);
-static int ProcPseudoramiXGetScreenCount(ClientPtr client);
-static int ProcPseudoramiXGetScreenSize(ClientPtr client);
-static int ProcPseudoramiXIsActive(ClientPtr client);
-static int ProcPseudoramiXQueryScreens(ClientPtr client);
-static int ProcPseudoramiXDispatch(ClientPtr client);
-
-static int SProcPseudoramiXQueryVersion(ClientPtr client);
-static int SProcPseudoramiXGetState(ClientPtr client);
-static int SProcPseudoramiXGetScreenCount(ClientPtr client);
-static int SProcPseudoramiXGetScreenSize(ClientPtr client);
-static int SProcPseudoramiXIsActive(ClientPtr client);
-static int SProcPseudoramiXQueryScreens(ClientPtr client);
-static int SProcPseudoramiXDispatch(ClientPtr client);
-
-
-typedef struct {
-    int x;
-    int y;
-    int w;
-    int h;
-} PseudoramiXScreenRec;
-
-static PseudoramiXScreenRec *pseudoramiXScreens = NULL;
-static int pseudoramiXScreensAllocated = 0;
-static int pseudoramiXNumScreens = 0;
-static unsigned long pseudoramiXGeneration = 0;
-
-
-// Add a PseudoramiX screen.
-// The rest of the X server will know nothing about this screen.
-// Can be called before or after extension init.
-// Screens must be re-added once per generation.
-void
-PseudoramiXAddScreen(int x, int y, int w, int h)
-{
-    PseudoramiXScreenRec *s;
-
-    if (noPseudoramiXExtension) return;
-
-    if (pseudoramiXNumScreens == pseudoramiXScreensAllocated) {
-        pseudoramiXScreensAllocated += pseudoramiXScreensAllocated + 1;
-        pseudoramiXScreens = xrealloc(pseudoramiXScreens,
-                                      pseudoramiXScreensAllocated *
-                                      sizeof(PseudoramiXScreenRec));
-    }
-
-    s = &pseudoramiXScreens[pseudoramiXNumScreens++];
-    s->x = x;
-    s->y = y;
-    s->w = w;
-    s->h = h;
-}
-
-
-// Initialize PseudoramiX.
-// Copied from PanoramiXExtensionInit
-void PseudoramiXExtensionInit(int argc, char *argv[])
-{
-    Bool	     	success = FALSE;
-    ExtensionEntry 	*extEntry;
-
-    if (noPseudoramiXExtension) return;
-
-    /* Even with only one screen we need to enable PseudoramiX to allow
-       dynamic screen configuration changes. */
-#if 0
-    if (pseudoramiXNumScreens == 1) {
-        // Only one screen - disable Xinerama extension.
-        noPseudoramiXExtension = TRUE;
-        return;
-    }
-#endif
-
-    // The server must not run the PanoramiX operations.
-    noPanoramiXExtension = TRUE;
-
-    if (pseudoramiXGeneration != serverGeneration) {
-        extEntry = AddExtension(PANORAMIX_PROTOCOL_NAME, 0, 0,
-                                ProcPseudoramiXDispatch,
-                                SProcPseudoramiXDispatch,
-                                PseudoramiXResetProc,
-                                StandardMinorOpcode);
-        if (!extEntry) {
-            ErrorF("PseudoramiXExtensionInit(): AddExtension failed\n");
-        } else {
-            pseudoramiXGeneration = serverGeneration;
-            success = TRUE;
-        }
-    }
-
-    if (!success) {
-        ErrorF("%s Extension (PseudoramiX) failed to initialize\n",
-               PANORAMIX_PROTOCOL_NAME);
-        return;
-    }
-}
-
-
-void PseudoramiXResetScreens(void)
-{
-    pseudoramiXNumScreens = 0;
-}
-
-
-static void PseudoramiXResetProc(ExtensionEntry *extEntry)
-{
-    PseudoramiXResetScreens();
-}
-
-
-// was PanoramiX
-static int ProcPseudoramiXQueryVersion(ClientPtr client)
-{
-    return ProcPanoramiXQueryVersion(client);
-}
-
-
-// was PanoramiX
-static int ProcPseudoramiXGetState(ClientPtr client)
-{
-    REQUEST(xPanoramiXGetStateReq);
-    WindowPtr pWin;
-    xPanoramiXGetStateReply rep;
-    register int n, rc;
-
-    REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
-    rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
-    if (rc != Success)
-	return rc;
-
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-    rep.state = !noPseudoramiXExtension;
-    if (client->swapped) {
-        swaps (&rep.sequenceNumber, n);
-        swapl (&rep.length, n);
-        swaps (&rep.state, n);
-    }
-    WriteToClient (client, sizeof (xPanoramiXGetStateReply), (char *) &rep);
-    return client->noClientException;
-}
-
-
-// was PanoramiX
-static int ProcPseudoramiXGetScreenCount(ClientPtr client)
-{
-    REQUEST(xPanoramiXGetScreenCountReq);
-    WindowPtr pWin;
-    xPanoramiXGetScreenCountReply rep;
-    register int n, rc;
-
-    REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
-    rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
-    if (rc != Success)
-	return rc;
-
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-    rep.ScreenCount = pseudoramiXNumScreens;
-    if (client->swapped) {
-        swaps (&rep.sequenceNumber, n);
-        swapl (&rep.length, n);
-        swaps (&rep.ScreenCount, n);
-    }
-    WriteToClient (client, sizeof(xPanoramiXGetScreenCountReply), (char *)&rep);
-    return client->noClientException;
-}
-
-
-// was PanoramiX
-static int ProcPseudoramiXGetScreenSize(ClientPtr client)
-{
-    REQUEST(xPanoramiXGetScreenSizeReq);
-    WindowPtr			pWin;
-    xPanoramiXGetScreenSizeReply	rep;
-    register int			n, rc;
-
-    REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
-    rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
-    if (rc != Success)
-	return rc;
-
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-    /* screen dimensions */
-    rep.width  = pseudoramiXScreens[stuff->screen].w;
-    // was panoramiXdataPtr[stuff->screen].width;
-    rep.height = pseudoramiXScreens[stuff->screen].h;
-    // was panoramiXdataPtr[stuff->screen].height;
-    if (client->swapped) {
-        swaps (&rep.sequenceNumber, n);
-        swapl (&rep.length, n);
-        swaps (&rep.width, n);
-        swaps (&rep.height, n);
-    }
-    WriteToClient (client, sizeof(xPanoramiXGetScreenSizeReply), (char *)&rep);
-    return client->noClientException;
-}
-
-
-// was Xinerama
-static int ProcPseudoramiXIsActive(ClientPtr client)
-{
-    /* REQUEST(xXineramaIsActiveReq); */
-    xXineramaIsActiveReply	rep;
-
-    REQUEST_SIZE_MATCH(xXineramaIsActiveReq);
-
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-    rep.state = !noPseudoramiXExtension;
-    if (client->swapped) {
-	register int n;
-	swaps (&rep.sequenceNumber, n);
-	swapl (&rep.length, n);
-	swapl (&rep.state, n);
-    }
-    WriteToClient (client, sizeof (xXineramaIsActiveReply), (char *) &rep);
-    return client->noClientException;
-}
-
-
-// was Xinerama
-static int ProcPseudoramiXQueryScreens(ClientPtr client)
-{
-    /* REQUEST(xXineramaQueryScreensReq); */
-    xXineramaQueryScreensReply	rep;
-
-    REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
-
-    rep.type = X_Reply;
-    rep.sequenceNumber = client->sequence;
-    rep.number = noPseudoramiXExtension ? 0 : pseudoramiXNumScreens;
-    rep.length = rep.number * sz_XineramaScreenInfo >> 2;
-    if (client->swapped) {
-	register int n;
-	swaps (&rep.sequenceNumber, n);
-	swapl (&rep.length, n);
-	swapl (&rep.number, n);
-    }
-    WriteToClient (client, sizeof (xXineramaQueryScreensReply), (char *) &rep);
-
-    if (!noPseudoramiXExtension) {
-	xXineramaScreenInfo scratch;
-	int i;
-
-	for(i = 0; i < pseudoramiXNumScreens; i++) {
-	    scratch.x_org  = pseudoramiXScreens[i].x;
-	    scratch.y_org  = pseudoramiXScreens[i].y;
-	    scratch.width  = pseudoramiXScreens[i].w;
-	    scratch.height = pseudoramiXScreens[i].h;
-
-	    if(client->swapped) {
-		register int n;
-		swaps (&scratch.x_org, n);
-		swaps (&scratch.y_org, n);
-		swaps (&scratch.width, n);
-		swaps (&scratch.height, n);
-	    }
-	    WriteToClient (client, sz_XineramaScreenInfo, (char *) &scratch);
-	}
-    }
-
-    return client->noClientException;
-}
-
-
-// was PanoramiX
-static int ProcPseudoramiXDispatch (ClientPtr client)
-{   REQUEST(xReq);
-    switch (stuff->data)
-    {
-	case X_PanoramiXQueryVersion:
-	     return ProcPseudoramiXQueryVersion(client);
-	case X_PanoramiXGetState:
-	     return ProcPseudoramiXGetState(client);
-	case X_PanoramiXGetScreenCount:
-	     return ProcPseudoramiXGetScreenCount(client);
-	case X_PanoramiXGetScreenSize:
-	     return ProcPseudoramiXGetScreenSize(client);
-	case X_XineramaIsActive:
-	     return ProcPseudoramiXIsActive(client);
-	case X_XineramaQueryScreens:
-	     return ProcPseudoramiXQueryScreens(client);
-    }
-    return BadRequest;
-}
-
-
-
-static int
-SProcPseudoramiXQueryVersion (ClientPtr client)
-{
-	REQUEST(xPanoramiXQueryVersionReq);
-	register int n;
-
-	swaps(&stuff->length,n);
-	REQUEST_SIZE_MATCH (xPanoramiXQueryVersionReq);
-	return ProcPseudoramiXQueryVersion(client);
-}
-
-static int
-SProcPseudoramiXGetState(ClientPtr client)
-{
-	REQUEST(xPanoramiXGetStateReq);
-	register int n;
-
- 	swaps (&stuff->length, n);
-	REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
-	return ProcPseudoramiXGetState(client);
-}
-
-static int
-SProcPseudoramiXGetScreenCount(ClientPtr client)
-{
-	REQUEST(xPanoramiXGetScreenCountReq);
-	register int n;
-
-	swaps (&stuff->length, n);
-	REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
-	return ProcPseudoramiXGetScreenCount(client);
-}
-
-static int
-SProcPseudoramiXGetScreenSize(ClientPtr client)
-{
-	REQUEST(xPanoramiXGetScreenSizeReq);
-	register int n;
-
-	swaps (&stuff->length, n);
-	REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
-	return ProcPseudoramiXGetScreenSize(client);
-}
-
-
-static int
-SProcPseudoramiXIsActive(ClientPtr client)
-{
-	REQUEST(xXineramaIsActiveReq);
-	register int n;
-
-	swaps (&stuff->length, n);
-	REQUEST_SIZE_MATCH(xXineramaIsActiveReq);
-	return ProcPseudoramiXIsActive(client);
-}
-
-
-static int
-SProcPseudoramiXQueryScreens(ClientPtr client)
-{
-	REQUEST(xXineramaQueryScreensReq);
-	register int n;
-
-	swaps (&stuff->length, n);
-	REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
-	return ProcPseudoramiXQueryScreens(client);
-}
-
-
-static int
-SProcPseudoramiXDispatch (ClientPtr client)
-{   REQUEST(xReq);
-    switch (stuff->data)
-    {
-	case X_PanoramiXQueryVersion:
-	     return SProcPseudoramiXQueryVersion(client);
-	case X_PanoramiXGetState:
-	     return SProcPseudoramiXGetState(client);
-	case X_PanoramiXGetScreenCount:
-	     return SProcPseudoramiXGetScreenCount(client);
-	case X_PanoramiXGetScreenSize:
-	     return SProcPseudoramiXGetScreenSize(client);
-	case X_XineramaIsActive:
-	     return SProcPseudoramiXIsActive(client);
-	case X_XineramaQueryScreens:
-	     return SProcPseudoramiXQueryScreens(client);
-    }
-    return BadRequest;
-}
diff --git a/hw/darwin/quartz/pseudoramiX.h b/hw/darwin/quartz/pseudoramiX.h
deleted file mode 100644
index df5010d..0000000
--- a/hw/darwin/quartz/pseudoramiX.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/*
- * Minimal implementation of PanoramiX/Xinerama
- */
-
-extern int noPseudoramiXExtension;
-
-void PseudoramiXAddScreen(int x, int y, int w, int h);
-void PseudoramiXExtensionInit(int argc, char *argv[]);
-void PseudoramiXResetScreens(void);
diff --git a/hw/darwin/quartz/quartz.c b/hw/darwin/quartz/quartz.c
deleted file mode 100644
index 2483d12..0000000
--- a/hw/darwin/quartz/quartz.c
+++ /dev/null
@@ -1,538 +0,0 @@
-/*
- *
- * Quartz-specific support for the Darwin X Server
- *
- * Copyright (c) 2001-2004 Greg Parker and Torrey T. Lyons.
- *                 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
- * 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "quartzCommon.h"
-#include "quartz.h"
-#include "darwin.h"
-#include "quartzAudio.h"
-#include "pseudoramiX.h"
-#define _APPLEWM_SERVER_
-#include "X11/extensions/applewm.h"
-#include "applewmExt.h"
-
-#include "X11Application.h"
-
-// X headers
-#include "scrnintstr.h"
-#include "windowstr.h"
-#include "colormapst.h"
-#include "globals.h"
-#include "rootlessWindow.h"
-
-// System headers
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <IOKit/pwr_mgt/IOPMLib.h>
-
-#define FAKE_RANDR 1
-
-// Shared global variables for Quartz modes
-int                     quartzEventWriteFD = -1;
-int                     quartzStartClients = 1;
-int                     quartzRootless = -1;
-int                     quartzUseSysBeep = 0;
-int                     quartzUseAGL = 1;
-int                     quartzEnableKeyEquivalents = 1;
-int                     quartzServerVisible = TRUE;
-int                     quartzServerQuitting = FALSE;
-int                     quartzScreenIndex = 0;
-int                     aquaMenuBarHeight = 0;
-int                     noPseudoramiXExtension = FALSE;
-QuartzModeProcsPtr      quartzProcs = NULL;
-const char             *quartzOpenGLBundle = NULL;
-
-#if defined(RANDR) && !defined(FAKE_RANDR)
-Bool DarwinModeRandRGetInfo (ScreenPtr pScreen, Rotation *rotations) {
-  return FALSE;
-}
-
-Bool DarwinModeRandRSetConfig (ScreenPtr           pScreen,
-			       Rotation            randr,
-			       int                 rate,
-			       RRScreenSizePtr     pSize) {
-  return FALSE;
-}
-
-Bool DarwinModeRandRInit (ScreenPtr pScreen) {
-  rrScrPrivPtr    pScrPriv;
-    
-  if (!RRScreenInit (pScreen)) return FALSE;
-
-  pScrPriv = rrGetScrPriv(pScreen);
-  pScrPriv->rrGetInfo = DarwinModeRandRGetInfo;
-  pScrPriv->rrSetConfig = DarwinModeRandRSetConfig;
-  return TRUE;
-}
-#endif
-
-/*
-===========================================================================
-
- Screen functions
-
-===========================================================================
-*/
-
-/*
- * DarwinModeAddScreen
- *  Do mode dependent initialization of each screen for Quartz.
- */
-Bool DarwinModeAddScreen(
-    int index,
-    ScreenPtr pScreen)
-{
-    // allocate space for private per screen Quartz specific storage
-    QuartzScreenPtr displayInfo = xcalloc(sizeof(QuartzScreenRec), 1);
-
-    // QUARTZ_PRIV(pScreen) = displayInfo;
-    pScreen->devPrivates[quartzScreenIndex].ptr = displayInfo;
-
-    // do Quartz mode specific initialization
-    return quartzProcs->AddScreen(index, pScreen);
-}
-
-
-/*
- * DarwinModeSetupScreen
- *  Finalize mode specific setup of each screen.
- */
-Bool DarwinModeSetupScreen(
-    int index,
-    ScreenPtr pScreen)
-{
-    // do Quartz mode specific setup
-    if (! quartzProcs->SetupScreen(index, pScreen))
-        return FALSE;
-
-    // setup cursor support
-    if (! quartzProcs->InitCursor(pScreen))
-        return FALSE;
-
-    return TRUE;
-}
-
-
-/*
- * DarwinModeInitOutput
- *  Quartz display initialization.
- */
-void DarwinModeInitOutput(
-    int argc,
-    char **argv )
-{
-    static unsigned long generation = 0;
-
-    // Allocate private storage for each screen's Quartz specific info
-    if (generation != serverGeneration) {
-        quartzScreenIndex = AllocateScreenPrivateIndex();
-        generation = serverGeneration;
-    }
-
-    if (serverGeneration == 0) {
-        QuartzAudioInit();
-    }
-
-    if (!RegisterBlockAndWakeupHandlers(QuartzBlockHandler,
-                                        QuartzWakeupHandler,
-                                        NULL))
-    {
-        FatalError("Could not register block and wakeup handlers.");
-    }
-
-    // Do display mode specific initialization
-    quartzProcs->DisplayInit();
-
-    // Init PseudoramiX implementation of Xinerama.
-    // This should be in InitExtensions, but that causes link errors
-    // for servers that don't link in pseudoramiX.c.
-    if (!noPseudoramiXExtension) {
-        PseudoramiXExtensionInit(argc, argv);
-    }
-}
-
-
-/*
- * DarwinModeInitInput
- *  Inform the main thread the X server is ready to handle events.
- */
-void DarwinModeInitInput(
-    int argc,
-    char **argv )
-{
-    X11ApplicationSetCanQuit(1);
-    X11ApplicationServerReady();
-    // Do final display mode specific initialization before handling events
-    if (quartzProcs->InitInput)
-        quartzProcs->InitInput(argc, argv);
-}
-
-
-#ifdef FAKE_RANDR
-extern char	*ConnectionInfo;
-
-static int padlength[4] = {0, 3, 2, 1};
-
-static void
-RREditConnectionInfo (ScreenPtr pScreen)
-{
-    xConnSetup	    *connSetup;
-    char	    *vendor;
-    xPixmapFormat   *formats;
-    xWindowRoot	    *root;
-    xDepth	    *depth;
-    xVisualType	    *visual;
-    int		    screen = 0;
-    int		    d;
-
-    connSetup = (xConnSetup *) ConnectionInfo;
-    vendor = (char *) connSetup + sizeof (xConnSetup);
-    formats = (xPixmapFormat *) ((char *) vendor +
-				 connSetup->nbytesVendor +
-				 padlength[connSetup->nbytesVendor & 3]);
-    root = (xWindowRoot *) ((char *) formats +
-			    sizeof (xPixmapFormat) * screenInfo.numPixmapFormats);
-    while (screen != pScreen->myNum)
-    {
-	depth = (xDepth *) ((char *) root + 
-			    sizeof (xWindowRoot));
-	for (d = 0; d < root->nDepths; d++)
-	{
-	    visual = (xVisualType *) ((char *) depth +
-				      sizeof (xDepth));
-	    depth = (xDepth *) ((char *) visual +
-				depth->nVisuals * sizeof (xVisualType));
-	}
-	root = (xWindowRoot *) ((char *) depth);
-	screen++;
-    }
-    root->pixWidth = pScreen->width;
-    root->pixHeight = pScreen->height;
-    root->mmWidth = pScreen->mmWidth;
-    root->mmHeight = pScreen->mmHeight;
-}
-#endif
-
-/*
- * QuartzUpdateScreens
- *  Adjust for screen arrangement changes.
- */
-static void QuartzUpdateScreens(void)
-{
-    ScreenPtr pScreen;
-    WindowPtr pRoot;
-    int x, y, width, height, sx, sy;
-    xEvent e;
-
-    DEBUG_LOG("QuartzUpdateScreens()\n");
-    if (noPseudoramiXExtension || screenInfo.numScreens != 1)
-    {
-        /* FIXME: if not using Xinerama, we have multiple screens, and
-           to do this properly may need to add or remove screens. Which
-           isn't possible. So don't do anything. Another reason why
-           we default to running with Xinerama. */
-
-        return;
-    }
-
-    pScreen = screenInfo.screens[0];
-
-    PseudoramiXResetScreens();
-    quartzProcs->AddPseudoramiXScreens(&x, &y, &width, &height);
-
-    dixScreenOrigins[pScreen->myNum].x = x;
-    dixScreenOrigins[pScreen->myNum].y = y;
-    pScreen->mmWidth = pScreen->mmWidth * ((double) width / pScreen->width);
-    pScreen->mmHeight = pScreen->mmHeight * ((double) height / pScreen->height);
-    pScreen->width = width;
-    pScreen->height = height;
-    
-#ifndef FAKE_RANDR
-    if(!DarwinModeRandRInit(pScreen))
-      FatalError("Failed to init RandR extension.\n");
-#endif
-
-    DarwinAdjustScreenOrigins(&screenInfo);
-    quartzProcs->UpdateScreen(pScreen);
-
-    sx = dixScreenOrigins[pScreen->myNum].x + darwinMainScreenX;
-    sy = dixScreenOrigins[pScreen->myNum].y + darwinMainScreenY;
-
-    /* Adjust the root window. */
-    pRoot = WindowTable[pScreen->myNum];
-    AppleWMSetScreenOrigin(pRoot);
-    pScreen->ResizeWindow(pRoot, x - sx, y - sy, width, height, NULL);
-    miPaintWindow(pRoot, &pRoot->borderClip,  PW_BACKGROUND);
-//    QuartzIgnoreNextWarpCursor();
-    DefineInitialRootWindow(pRoot);
-
-    /* Send an event for the root reconfigure */
-    e.u.u.type = ConfigureNotify;
-    e.u.configureNotify.window = pRoot->drawable.id;
-    e.u.configureNotify.aboveSibling = None;
-    e.u.configureNotify.x = x - sx;
-    e.u.configureNotify.y = y - sy;
-    e.u.configureNotify.width = width;
-    e.u.configureNotify.height = height;
-    e.u.configureNotify.borderWidth = wBorderWidth(pRoot);
-    e.u.configureNotify.override = pRoot->overrideRedirect;
-    DeliverEvents(pRoot, &e, 1, NullWindow);
-
-#ifdef FAKE_RANDR
-    RREditConnectionInfo(pScreen);
-#endif
-}
-
-
-/*
- * QuartzShow
- *  Show the X server on screen. Does nothing if already shown.
- *  Calls mode specific screen resume to restore the X clip regions
- *  (if needed) and the X server cursor state.
- */
-static void QuartzShow(
-    int x,      // cursor location
-    int y )
-{
-    int i;
-
-    if (!quartzServerVisible) {
-        quartzServerVisible = TRUE;
-        for (i = 0; i < screenInfo.numScreens; i++) {
-            if (screenInfo.screens[i]) {
-                quartzProcs->ResumeScreen(screenInfo.screens[i], x, y);
-            }
-        }
-    }
-}
-
-
-/*
- * QuartzHide
- *  Remove the X server display from the screen. Does nothing if already
- *  hidden. Calls mode specific screen suspend to set X clip regions to
- *  prevent drawing (if needed) and restore the Aqua cursor.
- */
-static void QuartzHide(void)
-{
-    int i;
-
-    if (quartzServerVisible) {
-        for (i = 0; i < screenInfo.numScreens; i++) {
-            if (screenInfo.screens[i]) {
-                quartzProcs->SuspendScreen(screenInfo.screens[i]);
-            }
-        }
-    }
-    quartzServerVisible = FALSE;
-}
-
-
-/*
- * QuartzSetRootClip
- *  Enable or disable rendering to the X screen.
- */
-static void QuartzSetRootClip(
-    BOOL enable)
-{
-    int i;
-
-    if (!quartzServerVisible)
-        return;
-
-    for (i = 0; i < screenInfo.numScreens; i++) {
-        if (screenInfo.screens[i]) {
-            xf86SetRootClip(screenInfo.screens[i], enable);
-        }
-    }
-}
-
-
-/*
- * QuartzMessageServerThread
- *  Send the X server thread a message by placing it on the event queue.
- */
-void
-QuartzMessageServerThread(
-    int type,
-    int argc, ...)
-{
-    xEvent xe;
-    INT32 *argv;
-    int i, max_args;
-    va_list args;
-
-    memset(&xe, 0, sizeof(xe));
-    xe.u.u.type = type;
-    xe.u.clientMessage.u.l.type = type;
-
-    argv = &xe.u.clientMessage.u.l.longs0;
-    max_args = 4;
-
-    if (argc > 0 && argc <= max_args) {
-        va_start (args, argc);
-        for (i = 0; i < argc; i++)
-            argv[i] = (int) va_arg (args, int);
-        va_end (args);
-    }
-
-    DarwinEQEnqueue(&xe);
-}
-
-
-/*
- * DarwinModeProcessEvent
- *  Process Quartz specific events.
- */
-void DarwinModeProcessEvent(
-    xEvent *xe)
-{
-    switch (xe->u.u.type) {
-        case kXDarwinControllerNotify:
-	  DEBUG_LOG("kXDarwinControllerNotify\n");
-            AppleWMSendEvent(AppleWMControllerNotify,
-                             AppleWMControllerNotifyMask,
-                             xe->u.clientMessage.u.l.longs0,
-                             xe->u.clientMessage.u.l.longs1);
-            break;
-
-        case kXDarwinPasteboardNotify:
-	  DEBUG_LOG("kXDarwinPasteboardNotify\n");
-            AppleWMSendEvent(AppleWMPasteboardNotify,
-                             AppleWMPasteboardNotifyMask,
-                             xe->u.clientMessage.u.l.longs0,
-                             xe->u.clientMessage.u.l.longs1);
-            break;
-
-        case kXDarwinActivate:
-	  DEBUG_LOG("kXDarwinActivate\n");
-            QuartzShow(xe->u.keyButtonPointer.rootX,
-                       xe->u.keyButtonPointer.rootY);
-            AppleWMSendEvent(AppleWMActivationNotify,
-                             AppleWMActivationNotifyMask,
-                             AppleWMIsActive, 0);
-            break;
-
-        case kXDarwinDeactivate:
-  	  DEBUG_LOG("kXDarwinDeactivate\n");
-            AppleWMSendEvent(AppleWMActivationNotify,
-                             AppleWMActivationNotifyMask,
-                             AppleWMIsInactive, 0);
-            QuartzHide();
-            break;
-
-        case kXDarwinDisplayChanged:
-	    DEBUG_LOG("kXDarwinDisplayChanged\n");
-            QuartzUpdateScreens();
-            break;
-
-        case kXDarwinWindowState:
-	  DEBUG_LOG("kXDarwinWindowState\n");
-            RootlessNativeWindowStateChanged(xe->u.clientMessage.u.l.longs0,
-		  			     xe->u.clientMessage.u.l.longs1);
-	    break;
-	  
-        case kXDarwinWindowMoved:
-	  DEBUG_LOG("kXDarwinWindowMoved\n");
-	  RootlessNativeWindowMoved ((WindowPtr)xe->u.clientMessage.u.l.longs0);
-	    break;
-
-        case kXDarwinToggleFullscreen:
-	  DEBUG_LOG("kXDarwinToggleFullscreen\n");
-#ifdef DARWIN_DDX_MISSING
-            if (quartzEnableRootless) QuartzSetFullscreen(!quartzHasRoot);
-            else if (quartzHasRoot) QuartzHide();
-            else QuartzShow();
-#else
-    //	    ErrorF("kXDarwinToggleFullscreen not implemented\n");
-#endif
-            break;
-
-        case kXDarwinSetRootless:
-#ifdef DARWIN_DDX_MISSING
-            QuartzSetRootless(xe->u.clientMessage.u.l.longs0);
-            if (!quartzEnableRootless && !quartzHasRoot) QuartzHide();
-#else
-    //	    ErrorF("kXDarwinSetRootless not implemented\n");
-#endif
-            break;
-
-        case kXDarwinSetRootClip:
-            QuartzSetRootClip((BOOL)xe->u.clientMessage.u.l.longs0);
-            break;
-
-        case kXDarwinQuit:
-            GiveUp(0);
-            break;
-
-        case kXDarwinReadPasteboard:
-            QuartzReadPasteboard();
-            break;
-
-        case kXDarwinWritePasteboard:
-            QuartzWritePasteboard();
-            break;
-
-        case kXDarwinBringAllToFront:
-  	  DEBUG_LOG("kXDarwinBringAllToFront\n");
-	    RootlessOrderAllWindows();
-            break;
-
-        default:
-            ErrorF("Unknown application defined event type %d.\n", xe->u.u.type);
-    }
-}
-
-
-/*
- * DarwinModeGiveUp
- *  Cleanup before X server shutdown
- *  Release the screen and restore the Aqua cursor.
- */
-void DarwinModeGiveUp(void)
-{
-#if 0
-// Trying to switch cursors when quitting causes deadlock
-    int i;
-
-    for (i = 0; i < screenInfo.numScreens; i++) {
-        if (screenInfo.screens[i]) {
-            QuartzSuspendXCursor(screenInfo.screens[i]);
-        }
-    }
-#endif
-
-    if (!quartzRootless)
-        quartzProcs->ReleaseScreens();
-}
diff --git a/hw/darwin/quartz/quartz.h b/hw/darwin/quartz/quartz.h
deleted file mode 100644
index e74a108..0000000
--- a/hw/darwin/quartz/quartz.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * quartz.h
- *
- * External interface of the Quartz display modes seen by the generic, mode
- * independent parts of the Darwin X server.
- *
- * Copyright (c) 2001-2003 Greg Parker and Torrey T. Lyons.
- *                 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
- * 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 _QUARTZ_H
-#define _QUARTZ_H
-
-#include "quartzPasteboard.h"
-
-#include "screenint.h"
-#include "window.h"
-
-/*------------------------------------------
-   Quartz display mode function types
-  ------------------------------------------*/
-
-/*
- * Display mode initialization
- */
-typedef void (*DisplayInitProc)(void);
-typedef Bool (*AddScreenProc)(int index, ScreenPtr pScreen);
-typedef Bool (*SetupScreenProc)(int index, ScreenPtr pScreen);
-typedef void (*InitInputProc)(int argc, char **argv);
-
-/*
- * Cursor functions
- */
-typedef Bool (*InitCursorProc)(ScreenPtr pScreen);
-typedef void (*CursorUpdateProc)(void);
-
-/*
- * Suspend and resume X11 activity
- */
-typedef void (*SuspendScreenProc)(ScreenPtr pScreen);
-typedef void (*ResumeScreenProc)(ScreenPtr pScreen, int x, int y);
-typedef void (*CaptureScreensProc)(void);
-typedef void (*ReleaseScreensProc)(void);
-
-/*
- * Screen state change support
- */
-typedef void (*ScreenChangedProc)(void);
-typedef void (*AddPseudoramiXScreensProc)(int *x, int *y, int *width, int *height);
-typedef void (*UpdateScreenProc)(ScreenPtr pScreen);
-
-/*
- * Rootless helper functions
- */
-typedef Bool (*IsX11WindowProc)(void *nsWindow, int windowNumber);
-typedef void (*HideWindowsProc)(Bool hide);
-
-/*
- * Rootless functions for optional export to GLX layer
- */
-typedef void * (*FrameForWindowProc)(WindowPtr pWin, Bool create);
-typedef WindowPtr (*TopLevelParentProc)(WindowPtr pWindow);
-typedef Bool (*CreateSurfaceProc)
-    (ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable,
-     unsigned int client_id, unsigned int *surface_id,
-     unsigned int key[2], void (*notify) (void *arg, void *data),
-     void *notify_data);
-typedef Bool (*DestroySurfaceProc)
-    (ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable,
-     void (*notify) (void *arg, void *data), void *notify_data);
-
-/*
- * Quartz display mode function list
- */
-typedef struct _QuartzModeProcs {
-    DisplayInitProc DisplayInit;
-    AddScreenProc AddScreen;
-    SetupScreenProc SetupScreen;
-    InitInputProc InitInput;
-
-    InitCursorProc InitCursor;
-    CursorUpdateProc CursorUpdate;	// Not used if NULL
-
-    SuspendScreenProc SuspendScreen;
-    ResumeScreenProc ResumeScreen;
-    CaptureScreensProc CaptureScreens;	// Only called in fullscreen
-    ReleaseScreensProc ReleaseScreens;	// Only called in fullscreen
-
-    ScreenChangedProc ScreenChanged;
-    AddPseudoramiXScreensProc AddPseudoramiXScreens;
-    UpdateScreenProc UpdateScreen;
-
-    IsX11WindowProc IsX11Window;
-    HideWindowsProc HideWindows;
-
-    FrameForWindowProc FrameForWindow;
-    TopLevelParentProc TopLevelParent;
-    CreateSurfaceProc CreateSurface;
-    DestroySurfaceProc DestroySurface;
-} QuartzModeProcsRec, *QuartzModeProcsPtr;
-
-extern QuartzModeProcsPtr quartzProcs;
-extern int quartzHasRoot, quartzEnableRootless;
-
-#endif
diff --git a/hw/darwin/quartz/quartzAudio.c b/hw/darwin/quartz/quartzAudio.c
deleted file mode 100644
index 1eb099b..0000000
--- a/hw/darwin/quartz/quartzAudio.c
+++ /dev/null
@@ -1,346 +0,0 @@
-//
-// QuartzAudio.m
-//
-// X Window bell support using CoreAudio or AppKit.
-// Greg Parker  gparker at cs.stanford.edu  19 Feb 2001
-//
-// Info about sine wave sound playback:
-// CoreAudio code derived from macosx-dev posting by Tim Wood
-//  http://www.omnigroup.com/mailman/archive/macosx-dev/2000-May/002004.html
-// Smoothing transitions between sounds
-//  http://www.wam.umd.edu/~mphoenix/dss/dss.html
-//
-/*
- * Copyright (c) 2001 Greg Parker. 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
- * 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "quartzCommon.h"
-#include "quartzAudio.h"
-
-#include <CoreAudio/CoreAudio.h>
-#include <pthread.h>
-
-#include "inputstr.h"
-#include <X11/extensions/XI.h>
-#include <assert.h>
-
-void NSBeep();
-
-typedef struct QuartzAudioRec {
-    double frequency;
-    double amplitude;
-
-    UInt32 curFrame;
-    UInt32 remainingFrames;
-    UInt32 totalFrames;
-    UInt32 bytesPerFrame;
-    double sampleRate;
-    UInt32 fadeLength;
-
-    UInt32 bufferByteCount;
-    Boolean playing;
-    pthread_mutex_t lock;
-
-    // used to fade out interrupted sound and avoid 'pop'
-    double prevFrequency;
-    double prevAmplitude;
-    UInt32 prevFrame; 
-} QuartzAudioRec;
-
-static AudioDeviceID quartzAudioDevice = kAudioDeviceUnknown;
-static QuartzAudioRec data;
-
-
-/*
- * QuartzAudioEnvelope
- *  Fade sound in and out to avoid pop.
- *  Sounds with shorter duration will never reach full amplitude. Deal.
- */
-static double QuartzAudioEnvelope(
-    UInt32 curFrame,
-    UInt32 totalFrames,
-    UInt32 fadeLength )
-{
-    double fadeFrames = min(fadeLength, totalFrames / 2);
-    if (fadeFrames < 1) return 0;
-
-    if (curFrame < fadeFrames) {
-        return curFrame / fadeFrames;
-    } else if (curFrame > totalFrames - fadeFrames) {
-        return (totalFrames-curFrame) / fadeFrames;
-    } else {
-        return 1.0;
-    }
-}
-
-
-/*
- * QuartzFillBuffer
- *  Fill this buffer with data and update the data position.
- *  FIXME: this is ugly
- */
-static void QuartzFillBuffer(
-    AudioBuffer *audiobuffer,
-    QuartzAudioRec *data )
-{
-    float *buffer, *b;
-    unsigned int frame, frameCount;
-    unsigned int bufferFrameCount;
-    float multiplier, v;
-    int i;
-
-    buffer = (float *)audiobuffer->mData;
-    bufferFrameCount = audiobuffer->mDataByteSize / data->bytesPerFrame;
-
-    frameCount = min(bufferFrameCount, data->remainingFrames);
-
-    // Fade out previous sine wave, if any.
-    b = buffer;
-    if (data->prevFrame) {
-        multiplier = 2*M_PI*(data->prevFrequency/data->sampleRate);
-        for (frame = 0; frame < data->fadeLength; frame++) {
-            v = data->prevAmplitude *
-                QuartzAudioEnvelope(frame+data->fadeLength,
-                                    2*data->fadeLength,
-                                    data->fadeLength) *
-                sin(multiplier * (data->prevFrame+frame));
-            for (i = 0; i < audiobuffer->mNumberChannels; i++) {
-                *b++ = v;
-            }
-        }
-        // no more prev fade
-        data->prevFrame = 0;
-
-        // adjust for space eaten by prev fade
-        buffer += audiobuffer->mNumberChannels*frame;
-        bufferFrameCount -= frame;
-        frameCount = min(bufferFrameCount, data->remainingFrames);
-    }
-
-    // Write a sine wave with the specified frequency and amplitude
-    multiplier = 2*M_PI*(data->frequency/data->sampleRate);
-    for (frame = 0; frame < frameCount; frame++) {
-        v = data->amplitude * 
-            QuartzAudioEnvelope(data->curFrame+frame, data->totalFrames,
-                                data->fadeLength) *
-            sin(multiplier * (data->curFrame+frame));
-        for (i = 0; i < audiobuffer->mNumberChannels; i++) {
-            *b++ = v;
-        }
-    }
-
-    // Zero out the rest of the buffer, if any
-    memset(b, 0, sizeof(float) * audiobuffer->mNumberChannels *
-           (bufferFrameCount-frame));
-
-    data->curFrame += frameCount;
-    data->remainingFrames -= frameCount;
-    if (data->remainingFrames == 0) {
-        data->playing = FALSE;
-        data->curFrame = 0;
-    }
-}
-
-
-/*
- * QuartzAudioIOProc
- *  Callback function for audio playback.
- *  FIXME: use inOutputTime to correct for skipping
- */
-static OSStatus 
-QuartzAudioIOProc(
-    AudioDeviceID inDevice, 
-    const AudioTimeStamp *inNow, 
-    const AudioBufferList *inInputData, 
-    const AudioTimeStamp *inInputTime, 
-    AudioBufferList *outOutputData, 
-    const AudioTimeStamp *inOutputTime, 
-    void *inClientData )
-{
-    QuartzAudioRec *data = (QuartzAudioRec *)inClientData;
-    int i;
-    Boolean wasPlaying;
-
-    pthread_mutex_lock(&data->lock);
-    wasPlaying = data->playing;
-    for (i = 0; i < outOutputData->mNumberBuffers; i++) {
-        if (data->playing) {
-            QuartzFillBuffer(outOutputData->mBuffers+i, data); 
-        }
-        else {
-            memset(outOutputData->mBuffers[i].mData, 0, 
-                   outOutputData->mBuffers[i].mDataByteSize);
-        }
-    }
-    if (wasPlaying  &&  !data->playing) {
-        OSStatus err;
-        err = AudioDeviceStop(inDevice, QuartzAudioIOProc);
-    }
-    pthread_mutex_unlock(&data->lock);
-    return 0;
-}
-
-
-/*
- * QuartzCoreAudioBell
- *  Play a tone using the CoreAudio API
- */
-static void QuartzCoreAudioBell(
-    int volume,         // volume is % of max
-    int pitch,          // pitch is Hz
-    int duration )      // duration is milliseconds
-{
-    if (quartzAudioDevice == kAudioDeviceUnknown) return;
-
-    pthread_mutex_lock(&data.lock);
-
-    // fade previous sound, if any
-    data.prevFrequency = data.frequency;
-    data.prevAmplitude = data.amplitude;
-    data.prevFrame = data.curFrame;
-
-    // set new sound
-    data.frequency = pitch;
-    data.amplitude = volume / 100.0;
-    data.curFrame = 0;
-    data.totalFrames = (int)(data.sampleRate * duration / 1000.0);
-    data.remainingFrames = data.totalFrames;
-
-    if (! data.playing) {
-        OSStatus status;
-        status = AudioDeviceStart(quartzAudioDevice, QuartzAudioIOProc);
-        if (status) {
-            ErrorF("QuartzAudioBell: AudioDeviceStart returned %ld\n", status);
-        } else {
-            data.playing = TRUE;
-        }
-    }
-    pthread_mutex_unlock(&data.lock);
-}
-
-
-/*
- * DarwinModeBell
- *  Ring the bell
- */
-void DarwinModeBell(
-    int volume,             // volume in percent of max
-    DeviceIntPtr pDevice,
-    pointer ctrl,
-    int class )
-{
-    int pitch;              // pitch in Hz
-    int duration;           // duration in milliseconds
-
-    if (class == BellFeedbackClass) {
-        pitch = ((BellCtrl*)ctrl)->pitch;
-        duration = ((BellCtrl*)ctrl)->duration;
-    } else if (class == KbdFeedbackClass) {
-        pitch = ((KeybdCtrl*)ctrl)->bell_pitch;
-        duration = ((KeybdCtrl*)ctrl)->bell_duration;    
-    } else {
-        ErrorF("QuartzBell: bad bell class %d\n", class);
-        return;
-    }
-
-    if (quartzUseSysBeep) {
-        if (volume)
-            NSBeep();
-    } else {
-        QuartzCoreAudioBell(volume, pitch, duration);
-    }
-}
-
-
-/*
- * QuartzAudioInit
- *  Prepare to play the bell with the CoreAudio API
- */
-void QuartzAudioInit(void) 
-{
-    UInt32 propertySize;
-    OSStatus status;
-    AudioDeviceID outputDevice;
-    AudioStreamBasicDescription outputStreamDescription;
-    double sampleRate;
-
-    // Get the default output device
-    propertySize = sizeof(outputDevice);
-    status = AudioHardwareGetProperty(
-                    kAudioHardwarePropertyDefaultOutputDevice, 
-                    &propertySize, &outputDevice);
-    if (status) {
-        ErrorF("QuartzAudioInit: AudioHardwareGetProperty returned %ld\n",
-               status);
-        return;
-    }
-    if (outputDevice == kAudioDeviceUnknown) {
-        ErrorF("QuartzAudioInit: No audio output devices available.\n");
-        return;
-    }
-
-    // Get the basic device description
-    propertySize = sizeof(outputStreamDescription);
-    status = AudioDeviceGetProperty(outputDevice, 0, FALSE, 
-                                    kAudioDevicePropertyStreamFormat, 
-                                    &propertySize, &outputStreamDescription);
-    if (status) {
-        ErrorF("QuartzAudioInit: GetProperty(stream format) returned %ld\n",
-               status);
-        return;
-    }
-    sampleRate = outputStreamDescription.mSampleRate;
-
-    // Fill in the playback data
-    data.frequency = 0;
-    data.amplitude = 0;
-    data.curFrame = 0;
-    data.remainingFrames = 0; 
-    data.bytesPerFrame = outputStreamDescription.mBytesPerFrame;
-    data.sampleRate = sampleRate;
-    // data.bufferByteCount = bufferByteCount;
-    data.playing = FALSE;
-    data.prevAmplitude = 0;
-    data.prevFrame = 0;
-    data.prevFrequency = 0;
-    data.fadeLength = data.sampleRate / 200;
-    pthread_mutex_init(&data.lock, NULL); // fixme error check
-
-    // fixme assert fadeLength<framesPerBuffer
-
-    // Prepare for playback
-    status = AudioDeviceAddIOProc(outputDevice, QuartzAudioIOProc, &data);
-    if (status) {
-        ErrorF("QuartzAudioInit: AddIOProc returned %ld\n", status);
-        return;
-    }
-
-    // success!
-    quartzAudioDevice = outputDevice;
-}
diff --git a/hw/darwin/quartz/quartzAudio.h b/hw/darwin/quartz/quartzAudio.h
deleted file mode 100644
index c406bbc..0000000
--- a/hw/darwin/quartz/quartzAudio.h
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-// QuartzAudio.h
-//
-// X Window bell support using CoreAudio or AppKit.
-// Greg Parker   gparker at cs.stanford.edu   19 Feb 2001
-/*
- * Copyright (c) 2001 Greg Parker. 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
- * 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 _QUARTZAUDIO_H
-#define _QUARTZAUDIO_H
-
-#include "input.h"
-
-void QuartzAudioInit(void);
-void QuartzBell(int volume, DeviceIntPtr pDevice, pointer ctrl, int class);
-
-#endif
diff --git a/hw/darwin/quartz/quartzCocoa.m b/hw/darwin/quartz/quartzCocoa.m
deleted file mode 100644
index 0086c5c..0000000
--- a/hw/darwin/quartz/quartzCocoa.m
+++ /dev/null
@@ -1,145 +0,0 @@
-/**************************************************************
- *
- * Quartz-specific support for the Darwin X Server
- * that requires Cocoa and Objective-C.
- *
- * This file is separate from the parts of Quartz support
- * that use X include files to avoid symbol collisions.
- *
- * Copyright (c) 2001-2004 Torrey T. Lyons and Greg Parker.
- *                 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
- * 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "quartzCommon.h"
-
-#define BOOL xBOOL
-#include "darwin.h"
-#undef BOOL
-
-#include <Cocoa/Cocoa.h>
-
-#include "pseudoramiX.h"
-
-extern void FatalError(const char *, ...);
-extern char *display;
-extern int noPanoramiXExtension;
-
-/*
- * QuartzWriteCocoaPasteboard
- *  Write text to the Mac OS X pasteboard.
- */
-void QuartzWriteCocoaPasteboard(
-    char *text)
-{
-    NSPasteboard *pasteboard;
-    NSArray *pasteboardTypes;
-    NSString *string;
-
-    if (! text) return;
-    pasteboard = [NSPasteboard generalPasteboard];
-    if (! pasteboard) return;
-    string = [NSString stringWithCString:text];
-    if (! string) return;
-    pasteboardTypes = [NSArray arrayWithObject:NSStringPboardType];
-
-    // nil owner because we don't provide type translations
-    [pasteboard declareTypes:pasteboardTypes owner:nil];
-    [pasteboard setString:string forType:NSStringPboardType];
-}
-
-
-/*
- * QuartzReadCocoaPasteboard
- *  Read text from the Mac OS X pasteboard and return it as a heap string.
- *  The caller must free the string.
- */
-char *QuartzReadCocoaPasteboard(void)
-{
-    NSPasteboard *pasteboard;
-    NSArray *pasteboardTypes;
-    NSString *existingType;
-    char *text = NULL;
-
-    pasteboardTypes = [NSArray arrayWithObject:NSStringPboardType];
-    pasteboard = [NSPasteboard generalPasteboard];
-    if (! pasteboard) return NULL;
-
-    existingType = [pasteboard availableTypeFromArray:pasteboardTypes];
-    if (existingType) {
-        NSString *string = [pasteboard stringForType:existingType];
-        char *buffer;
-
-        if (! string) return NULL;
-        buffer = (char *) [string UTF8String];
-        text = (char *) malloc(strlen(buffer)+1);
-        if (text)
-            strcpy(text, buffer);
-    }
-
-    return text;
-}
-
-
-/*
- * QuartzFSUseQDCursor
- *  Return whether the screen should use a QuickDraw cursor.
- */
-int QuartzFSUseQDCursor(
-    int depth)  // screen depth
-{
-    return TRUE;
-}
-
-
-/*
- * QuartzBlockHandler
- *  Clean out any autoreleased objects.
- */
-void QuartzBlockHandler(
-    pointer blockData,
-    OSTimePtr pTimeout,
-    pointer pReadmask)
-{
-    static NSAutoreleasePool *aPool = nil;
-
-    [aPool release];
-    aPool = [[NSAutoreleasePool alloc] init];
-}
-
-
-/*
- * QuartzWakeupHandler
- */
-void QuartzWakeupHandler(
-    pointer blockData,
-    int result,
-    pointer pReadmask)
-{
-    // nothing here
-}
diff --git a/hw/darwin/quartz/quartzCommon.h b/hw/darwin/quartz/quartzCommon.h
deleted file mode 100644
index f0d5a7a..0000000
--- a/hw/darwin/quartz/quartzCommon.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * quartzCommon.h
- *
- * Common definitions used internally by all Quartz modes
- *
- * This file should be included before any X11 or IOKit headers
- * so that it can avoid symbol conflicts.
- *
- * Copyright (c) 2001-2004 Torrey T. Lyons and Greg Parker.
- *                 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
- * 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 _QUARTZCOMMON_H
-#define _QUARTZCOMMON_H
-
-// QuickDraw in ApplicationServices has the following conflicts with
-// the basic X server headers. Use QD_<name> to use the QuickDraw
-// definition of any of these symbols, or the normal name for the
-// X11 definition.
-#define Cursor       QD_Cursor
-#define WindowPtr    QD_WindowPtr
-#define Picture      QD_Picture
-#include <ApplicationServices/ApplicationServices.h>
-#undef Cursor
-#undef WindowPtr
-#undef Picture
-#include <X11/Xdefs.h>
-
-// Quartz specific per screen storage structure
-typedef struct {
-    // List of CoreGraphics displays that this X11 screen covers.
-    // This is more than one CG display for video mirroring and
-    // rootless PseudoramiX mode.
-    // No CG display will be covered by more than one X11 screen.
-    int displayCount;
-    CGDirectDisplayID *displayIDs;
-} QuartzScreenRec, *QuartzScreenPtr;
-
-#define QUARTZ_PRIV(pScreen) \
-    ((QuartzScreenPtr)pScreen->devPrivates[quartzScreenIndex].ptr)
-
-// Data stored at startup for Cocoa front end
-extern int              quartzEventWriteFD;
-extern int              quartzStartClients;
-
-// User preferences used by Quartz modes
-extern int              quartzRootless;
-extern int              quartzUseSysBeep;
-extern int              quartzUseAGL;
-extern int              quartzEnableKeyEquivalents;
-
-// Other shared data
-extern int              quartzServerVisible;
-extern int              quartzServerQuitting;
-extern int              quartzScreenIndex;
-extern int              aquaMenuBarHeight;
-
-// Name of GLX bundle for native OpenGL
-extern const char      *quartzOpenGLBundle;
-
-void QuartzReadPreferences(void);
-void QuartzMessageMainThread(unsigned msg, void *data, unsigned length);
-void QuartzMessageServerThread(int type, int argc, ...);
-void QuartzSetWindowMenu(int nitems, const char **items,
-                         const char *shortcuts);
-void QuartzFSCapture(void);
-void QuartzFSRelease(void);
-int  QuartzFSUseQDCursor(int depth);
-void QuartzBlockHandler(pointer blockData, OSTimePtr pTimeout, pointer pReadmask);
-void QuartzWakeupHandler(pointer blockData, int result, pointer pReadmask);
-
-// Messages that can be sent to the main thread.
-enum {
-    kQuartzServerHidden,
-    kQuartzServerStarted,
-    kQuartzServerDied,
-    kQuartzCursorUpdate,
-    kQuartzPostEvent,
-    kQuartzSetWindowMenu,
-    kQuartzSetWindowMenuCheck,
-    kQuartzSetFrontProcess,
-    kQuartzSetCanQuit
-};
-
-#endif  /* _QUARTZCOMMON_H */
diff --git a/hw/darwin/quartz/quartzCursor.c b/hw/darwin/quartz/quartzCursor.c
deleted file mode 100644
index 6e86acb..0000000
--- a/hw/darwin/quartz/quartzCursor.c
+++ /dev/null
@@ -1,654 +0,0 @@
-/**************************************************************
- *
- * Support for using the Quartz Window Manager cursor
- *
- * Copyright (c) 2001-2003 Torrey T. Lyons and Greg Parker.
- *                 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
- * 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "quartzCommon.h"
-#include "quartzCursor.h"
-#include "darwin.h"
-
-#include <pthread.h>
-
-#include "mi.h"
-#include "scrnintstr.h"
-#include "cursorstr.h"
-#include "mipointrst.h"
-#include "globals.h"
-
-// Size of the QuickDraw cursor
-#define CURSORWIDTH 16
-#define CURSORHEIGHT 16
-
-typedef struct {
-    int                     qdCursorMode;
-    int                     qdCursorVisible;
-    int                     useQDCursor;
-    QueryBestSizeProcPtr    QueryBestSize;
-    miPointerSpriteFuncPtr  spriteFuncs;
-} QuartzCursorScreenRec, *QuartzCursorScreenPtr;
-
-static int darwinCursorScreenIndex = -1;
-static unsigned long darwinCursorGeneration = 0;
-static CursorPtr quartzLatentCursor = NULL;
-static QD_Cursor gQDArrow; // QuickDraw arrow cursor
-
-// Cursor for the main thread to set (NULL = arrow cursor).
-static CCrsrHandle currentCursor = NULL;
-static pthread_mutex_t cursorMutex;
-static pthread_cond_t cursorCondition;
-
-#define CURSOR_PRIV(pScreen) \
-    ((QuartzCursorScreenPtr)pScreen->devPrivates[darwinCursorScreenIndex].ptr)
-
-#define HIDE_QD_CURSOR(pScreen, visible)                                \
-    if (visible) {                                                      \
-        int ix;                                                         \
-        for (ix = 0; ix < QUARTZ_PRIV(pScreen)->displayCount; ix++) {   \
-            CGDisplayHideCursor(QUARTZ_PRIV(pScreen)->displayIDs[ix]);  \
-        }                                                               \
-        visible = FALSE;                                                \
-    } ((void)0)
-
-#define SHOW_QD_CURSOR(pScreen, visible)                                \
-    {                                                                   \
-        int ix;                                                         \
-        for (ix = 0; ix < QUARTZ_PRIV(pScreen)->displayCount; ix++) {   \
-            CGDisplayShowCursor(QUARTZ_PRIV(pScreen)->displayIDs[ix]);  \
-        }                                                               \
-        visible = TRUE;                                                 \
-    } ((void)0)
-
-#define CHANGE_QD_CURSOR(cursorH)                                       \
-    if (!quartzServerQuitting) {                                        \
-        /* Acquire lock and tell the main thread to change cursor */    \
-        pthread_mutex_lock(&cursorMutex);                               \
-        currentCursor = (CCrsrHandle) (cursorH);                        \
-        QuartzMessageMainThread(kQuartzCursorUpdate, NULL, 0);          \
-                                                                        \
-        /* Wait for the main thread to change the cursor */             \
-        pthread_cond_wait(&cursorCondition, &cursorMutex);              \
-        pthread_mutex_unlock(&cursorMutex);                             \
-    } ((void)0)
-
-
-/*
- * MakeQDCursor helpers: CTAB_ENTER, interleave
- */
-
-// Add a color entry to a ctab
-#define CTAB_ENTER(ctab, index, r, g, b)                                \
-    ctab->ctTable[index].value = index;                                 \
-    ctab->ctTable[index].rgb.red = r;                                   \
-    ctab->ctTable[index].rgb.green = g;                                 \
-    ctab->ctTable[index].rgb.blue = b
-
-// Make an unsigned short by interleaving the bits of bytes c1 and c2.
-// High bit of c1 is first; low bit of c2 is last.
-// Interleave is a built-in INTERCAL operator.
-static unsigned short
-interleave(
-    unsigned char c1,
-    unsigned char c2 )
-{
-    return
-        ((c1 & 0x80) << 8) | ((c2 & 0x80) << 7) |
-        ((c1 & 0x40) << 7) | ((c2 & 0x40) << 6) |
-        ((c1 & 0x20) << 6) | ((c2 & 0x20) << 5) |
-        ((c1 & 0x10) << 5) | ((c2 & 0x10) << 4) |
-        ((c1 & 0x08) << 4) | ((c2 & 0x08) << 3) |
-        ((c1 & 0x04) << 3) | ((c2 & 0x04) << 2) |
-        ((c1 & 0x02) << 2) | ((c2 & 0x02) << 1) |
-        ((c1 & 0x01) << 1) | ((c2 & 0x01) << 0) ;
-}
-
-/*
- * MakeQDCursor
- * Make a QuickDraw color cursor from the given X11 cursor.
- * Warning: This code is nasty. Color cursors were meant to be read
- * from resources; constructing the structures programmatically is messy.
- */
-/*
-    QuickDraw cursor representation:
-    Our color cursor is a 2 bit per pixel pixmap.
-    Each pixel's bits are (source<<1 | mask) from the original X cursor pixel.
-    The cursor's color table maps the colors like this:
-    (2-bit value | X result    | colortable | Mac result)
-             00  | transparent | white      | transparent (white outside mask)
-             01  | back color  | back color | back color
-             10  | undefined   | black      | invert background (just for fun)
-             11  | fore color  | fore color | fore color
-*/
-static CCrsrHandle
-MakeQDCursor(
-    CursorPtr pCursor )
-{
-    CCrsrHandle result;
-    CCrsrPtr curs;
-    int i, w, h;
-    unsigned short rowMask;
-    PixMap *pix;
-    ColorTable *ctab;
-    unsigned short *image;
-
-    result = (CCrsrHandle) NewHandleClear(sizeof(CCrsr));
-    if (!result) return NULL;
-    HLock((Handle)result);
-    curs = *result;
-
-    // Initialize CCrsr
-    curs->crsrType = 0x8001;     // 0x8000 = b&w, 0x8001 = color
-    curs->crsrMap = (PixMapHandle) NewHandleClear(sizeof(PixMap));
-    if (!curs->crsrMap) goto pixAllocFailed;
-    HLock((Handle)curs->crsrMap);
-    pix = *curs->crsrMap;
-    curs->crsrData = NULL;       // raw cursor image data (set below)
-    curs->crsrXData = NULL;      // QD's processed data
-    curs->crsrXValid = 0;        // zero means QD must re-process cursor data
-    curs->crsrXHandle = NULL;    // reserved
-    memset(curs->crsr1Data, 0, CURSORWIDTH*CURSORHEIGHT/8); // b&w data
-    memset(curs->crsrMask,  0, CURSORWIDTH*CURSORHEIGHT/8); // b&w & color mask
-    curs->crsrHotSpot.h = min(CURSORWIDTH,  pCursor->bits->xhot); // hot spot
-    curs->crsrHotSpot.v = min(CURSORHEIGHT, pCursor->bits->yhot); // hot spot
-    curs->crsrXTable = 0;        // reserved
-    curs->crsrID = GetCTSeed();  // unique ID from Color Manager
-
-    // Set the b&w data and mask
-    w = min(pCursor->bits->width,  CURSORWIDTH);
-    h = min(pCursor->bits->height, CURSORHEIGHT);
-    rowMask = ~((1 << (CURSORWIDTH - w)) - 1);
-    for (i = 0; i < h; i++) {
-        curs->crsr1Data[i] = rowMask &
-        ((pCursor->bits->source[i*4]<<8) | pCursor->bits->source[i*4+1]);
-        curs->crsrMask[i] = rowMask &
-        ((pCursor->bits->mask[i*4]<<8)   | pCursor->bits->mask[i*4+1]);
-    }
-
-    // Set the color data and mask
-    // crsrMap: defines bit depth and size and colortable only
-    pix->rowBytes = (CURSORWIDTH * 2 / 8) | 0x8000; // last bit on means PixMap
-    SetRect(&pix->bounds, 0, 0, CURSORWIDTH, CURSORHEIGHT); // see TN 1020
-    pix->pixelSize = 2;
-    pix->cmpCount = 1;
-    pix->cmpSize = 2;
-    // pix->pmTable set below
-
-    // crsrData is the pixel data. crsrMap's baseAddr is not used.
-    curs->crsrData = NewHandleClear(CURSORWIDTH*CURSORHEIGHT * 2 / 8);
-    if (!curs->crsrData) goto imageAllocFailed;
-    HLock((Handle)curs->crsrData);
-    image = (unsigned short *) *curs->crsrData;
-    // Pixel data is just 1-bit data and mask interleaved (see above)
-    for (i = 0; i < h; i++) {
-        unsigned char s, m;
-        s = pCursor->bits->source[i*4] & (rowMask >> 8);
-        m = pCursor->bits->mask[i*4] & (rowMask >> 8);
-        image[2*i] = interleave(s, m);
-        s = pCursor->bits->source[i*4+1] & (rowMask & 0x00ff);
-        m = pCursor->bits->mask[i*4+1] & (rowMask & 0x00ff);
-        image[2*i+1] = interleave(s, m);
-    }
-
-    // Build the color table (entries described above)
-    // NewPixMap allocates a color table handle.
-    pix->pmTable = (CTabHandle) NewHandleClear(sizeof(ColorTable) + 3
-                    * sizeof(ColorSpec));
-    if (!pix->pmTable) goto ctabAllocFailed;
-    HLock((Handle)pix->pmTable);
-    ctab = *pix->pmTable;
-    ctab->ctSeed = GetCTSeed();
-    ctab->ctFlags = 0;
-    ctab->ctSize = 3; // color count - 1
-    CTAB_ENTER(ctab, 0, 0xffff, 0xffff, 0xffff);
-    CTAB_ENTER(ctab, 1, pCursor->backRed, pCursor->backGreen,
-               pCursor->backBlue);
-    CTAB_ENTER(ctab, 2, 0x0000, 0x0000, 0x0000);
-    CTAB_ENTER(ctab, 3, pCursor->foreRed, pCursor->foreGreen,
-               pCursor->foreBlue);
-
-    HUnlock((Handle)pix->pmTable); // ctab
-    HUnlock((Handle)curs->crsrData); // image data
-    HUnlock((Handle)curs->crsrMap); // pix
-    HUnlock((Handle)result); // cursor
-
-    return result;
-
-    // "What we have here is a failure to allocate"
-ctabAllocFailed:
-    HUnlock((Handle)curs->crsrData);
-    DisposeHandle((Handle)curs->crsrData);
-imageAllocFailed:
-    HUnlock((Handle)curs->crsrMap);
-    DisposeHandle((Handle)curs->crsrMap);
-pixAllocFailed:
-    HUnlock((Handle)result);
-    DisposeHandle((Handle)result);
-    return NULL;
-}
-
-
-/*
- * FreeQDCursor
- * Destroy a QuickDraw color cursor created with MakeQDCursor().
- * The cursor must not currently be on screen.
- */
-static void FreeQDCursor(CCrsrHandle cursHandle)
-{
-    CCrsrPtr curs;
-    PixMap *pix;
-
-    HLock((Handle)cursHandle);
-    curs = *cursHandle;
-    HLock((Handle)curs->crsrMap);
-    pix = *curs->crsrMap;
-    DisposeHandle((Handle)pix->pmTable);
-    HUnlock((Handle)curs->crsrMap);
-    DisposeHandle((Handle)curs->crsrMap);
-    DisposeHandle((Handle)curs->crsrData);
-    HUnlock((Handle)cursHandle);
-    DisposeHandle((Handle)cursHandle);
-}
-
-
-/*
-===========================================================================
-
- Pointer sprite functions
-
-===========================================================================
-*/
-
-/*
- * QuartzRealizeCursor
- * Convert the X cursor representation to QuickDraw format if possible.
- */
-Bool
-QuartzRealizeCursor(
-    ScreenPtr pScreen,
-    CursorPtr pCursor )
-{
-    CCrsrHandle qdCursor;
-    QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
-
-    if(!pCursor || !pCursor->bits)
-        return FALSE;
-
-    // if the cursor is too big we use a software cursor
-    if ((pCursor->bits->height > CURSORHEIGHT) ||
-        (pCursor->bits->width > CURSORWIDTH) || !ScreenPriv->useQDCursor)
-    {
-        if (quartzRootless) {
-            // rootless can't use a software cursor
-            return TRUE;
-        } else {
-            return (*ScreenPriv->spriteFuncs->RealizeCursor)
-                        (pScreen, pCursor);
-        }
-    }
-
-    // make new cursor image
-    qdCursor = MakeQDCursor(pCursor);
-    if (!qdCursor) return FALSE;
-
-    // save the result
-    pCursor->devPriv[pScreen->myNum] = (pointer) qdCursor;
-
-    return TRUE;
-}
-
-
-/*
- * QuartzUnrealizeCursor
- * Free the storage space associated with a realized cursor.
- */
-Bool
-QuartzUnrealizeCursor(
-    ScreenPtr pScreen,
-    CursorPtr pCursor )
-{
-    QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
-
-    if ((pCursor->bits->height > CURSORHEIGHT) ||
-        (pCursor->bits->width > CURSORWIDTH) || !ScreenPriv->useQDCursor)
-    {
-        if (quartzRootless) {
-            return TRUE;
-        } else {
-            return (*ScreenPriv->spriteFuncs->UnrealizeCursor)
-                        (pScreen, pCursor);
-        }
-    } else {
-        CCrsrHandle oldCursor = (CCrsrHandle) pCursor->devPriv[pScreen->myNum];
-
-        if (currentCursor != oldCursor) {
-            // This should only fail when quitting, in which case we just leak.
-            FreeQDCursor(oldCursor);
-        }
-        pCursor->devPriv[pScreen->myNum] = NULL;
-        return TRUE;
-    }
-}
-
-
-/*
- * QuartzSetCursor
- * Set the cursor sprite and position.
- * Use QuickDraw cursor if possible.
- */
-static void
-QuartzSetCursor(
-    ScreenPtr       pScreen,
-    CursorPtr       pCursor,
-    int             x,
-    int             y)
-{
-    QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
-
-    quartzLatentCursor = pCursor;
-
-    // Don't touch Mac OS cursor if X is hidden!
-    if (!quartzServerVisible)
-        return;
-
-    if (!pCursor) {
-        // Remove the cursor completely.
-        HIDE_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
-        if (! ScreenPriv->qdCursorMode)
-            (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, 0, x, y);
-    }
-    else if ((pCursor->bits->height <= CURSORHEIGHT) &&
-             (pCursor->bits->width <= CURSORWIDTH) && ScreenPriv->useQDCursor)
-    {
-        // Cursor is small enough to use QuickDraw directly.
-        if (! ScreenPriv->qdCursorMode)    // remove the X cursor
-            (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, 0, x, y);
-        ScreenPriv->qdCursorMode = TRUE;
-
-        CHANGE_QD_CURSOR(pCursor->devPriv[pScreen->myNum]);
-        SHOW_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
-    }
-    else if (quartzRootless) {
-        // Rootless can't use a software cursor, so we just use Mac OS arrow.
-        CHANGE_QD_CURSOR(NULL);
-        SHOW_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
-    }
-    else {
-        // Cursor is too big for QuickDraw. Use X software cursor.
-        HIDE_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
-        ScreenPriv->qdCursorMode = FALSE;
-        (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, pCursor, x, y);
-    }
-}
-
-
-/*
- * QuartzReallySetCursor
- * Set the QuickDraw cursor. Called from the main thread since changing the
- * cursor with QuickDraw is not thread safe on dual processor machines.
- */
-void
-QuartzReallySetCursor()
-{
-    pthread_mutex_lock(&cursorMutex);
-
-    if (currentCursor) {
-        SetCCursor(currentCursor);
-    } else {
-        SetCursor(&gQDArrow);
-    }
-
-    pthread_cond_signal(&cursorCondition);
-    pthread_mutex_unlock(&cursorMutex);
-}
-
-
-/*
- * QuartzMoveCursor
- * Move the cursor. This is a noop for QuickDraw.
- */
-static void
-QuartzMoveCursor(
-    ScreenPtr   pScreen,
-    int         x,
-    int         y)
-{
-    QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
-
-    // only the X cursor needs to be explicitly moved
-    if (!ScreenPriv->qdCursorMode)
-        (*ScreenPriv->spriteFuncs->MoveCursor)(pScreen, x, y);
-}
-
-
-static miPointerSpriteFuncRec quartzSpriteFuncsRec = {
-    QuartzRealizeCursor,
-    QuartzUnrealizeCursor,
-    QuartzSetCursor,
-    QuartzMoveCursor
-};
-
-
-/*
-===========================================================================
-
- Pointer screen functions
-
-===========================================================================
-*/
-
-/*
- * QuartzCursorOffScreen
- */
-static Bool QuartzCursorOffScreen(ScreenPtr *pScreen, int *x, int *y)
-{
-    return FALSE;
-}
-
-
-/*
- * QuartzCrossScreen
- */
-static void QuartzCrossScreen(ScreenPtr pScreen, Bool entering)
-{
-    return;
-}
-
-
-/*
- * QuartzWarpCursor
- *  Change the cursor position without generating an event or motion history.
- *  The input coordinates (x,y) are in pScreen-local X11 coordinates.
- *
- */
-static void
-QuartzWarpCursor(
-    ScreenPtr               pScreen,
-    int                     x,
-    int                     y)
-{
-    static int              neverMoved = TRUE;
-
-    if (neverMoved) {
-        // Don't move the cursor the first time. This is the jump-to-center
-        // initialization, and it's annoying because we may still be in MacOS.
-        neverMoved = FALSE;
-        return;
-    }
-
-    if (quartzServerVisible) {
-        CGDisplayErr        cgErr;
-        CGPoint             cgPoint;
-        // Only need to do this for one display. Any display will do.
-        CGDirectDisplayID   cgID = QUARTZ_PRIV(pScreen)->displayIDs[0];
-        CGRect              cgRect = CGDisplayBounds(cgID);
-
-        // Convert (x,y) to CoreGraphics screen-local CG coordinates.
-        // This is necessary because the X11 screen and CG screen may not
-        // coincide. (e.g. X11 screen may be moved to dodge the menu bar)
-
-        // Make point in X11 global coordinates
-        cgPoint = CGPointMake(x + dixScreenOrigins[pScreen->myNum].x,
-                              y + dixScreenOrigins[pScreen->myNum].y);
-        // Shift to CoreGraphics global screen coordinates
-        cgPoint.x += darwinMainScreenX;
-        cgPoint.y += darwinMainScreenY;
-        // Shift to CoreGraphics screen-local coordinates
-        cgPoint.x -= cgRect.origin.x;
-        cgPoint.y -= cgRect.origin.y;
-
-        cgErr = CGDisplayMoveCursorToPoint(cgID, cgPoint);
-        if (cgErr != CGDisplayNoErr) {
-            ErrorF("Could not set cursor position with error code 0x%x.\n",
-                    cgErr);
-        }
-    }
-
-    miPointerWarpCursor(pScreen, x, y);
-    miPointerUpdate();
-}
-
-
-static miPointerScreenFuncRec quartzScreenFuncsRec = {
-    QuartzCursorOffScreen,
-    QuartzCrossScreen,
-    QuartzWarpCursor,
-    DarwinEQPointerPost,
-    DarwinEQSwitchScreen
-};
-
-
-/*
-===========================================================================
-
- Other screen functions
-
-===========================================================================
-*/
-
-/*
- * QuartzCursorQueryBestSize
- * Handle queries for best cursor size
- */
-static void
-QuartzCursorQueryBestSize(
-   int              class,
-   unsigned short   *width,
-   unsigned short   *height,
-   ScreenPtr        pScreen)
-{
-    QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
-
-    if (class == CursorShape) {
-        *width = CURSORWIDTH;
-        *height = CURSORHEIGHT;
-    } else {
-        (*ScreenPriv->QueryBestSize)(class, width, height, pScreen);
-    }
-}
-
-
-/*
- * QuartzInitCursor
- * Initialize cursor support
- */
-Bool
-QuartzInitCursor(
-    ScreenPtr   pScreen )
-{
-    QuartzCursorScreenPtr   ScreenPriv;
-    miPointerScreenPtr      PointPriv;
-    DarwinFramebufferPtr    dfb = SCREEN_PRIV(pScreen);
-
-    // initialize software cursor handling (always needed as backup)
-    if (!miDCInitialize(pScreen, &quartzScreenFuncsRec)) {
-        return FALSE;
-    }
-
-    // allocate private storage for this screen's QuickDraw cursor info
-    if (darwinCursorGeneration != serverGeneration) {
-        if ((darwinCursorScreenIndex = AllocateScreenPrivateIndex()) < 0)
-            return FALSE;
-        darwinCursorGeneration = serverGeneration;
-    }
-
-    ScreenPriv = xcalloc( 1, sizeof(QuartzCursorScreenRec) );
-    if (!ScreenPriv) return FALSE;
-
-    CURSOR_PRIV(pScreen) = ScreenPriv;
-
-    // override some screen procedures
-    ScreenPriv->QueryBestSize = pScreen->QueryBestSize;
-    pScreen->QueryBestSize = QuartzCursorQueryBestSize;
-
-    // initialize QuickDraw cursor handling
-    GetQDGlobalsArrow(&gQDArrow);
-    PointPriv = (miPointerScreenPtr)
-                    pScreen->devPrivates[miPointerScreenIndex].ptr;
-
-    ScreenPriv->spriteFuncs = PointPriv->spriteFuncs;
-    PointPriv->spriteFuncs = &quartzSpriteFuncsRec;
-
-    if (!quartzRootless)
-        ScreenPriv->useQDCursor = QuartzFSUseQDCursor(dfb->colorBitsPerPixel);
-    else
-        ScreenPriv->useQDCursor = TRUE;
-    ScreenPriv->qdCursorMode = TRUE;
-    ScreenPriv->qdCursorVisible = TRUE;
-
-    // initialize cursor mutex lock
-    pthread_mutex_init(&cursorMutex, NULL);
-
-    // initialize condition for waiting
-    pthread_cond_init(&cursorCondition, NULL);
-
-    return TRUE;
-}
-
-
-// X server is hiding. Restore the Aqua cursor.
-void QuartzSuspendXCursor(
-    ScreenPtr pScreen )
-{
-    QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
-
-    CHANGE_QD_CURSOR(NULL);
-    SHOW_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
-}
-
-
-// X server is showing. Restore the X cursor.
-void QuartzResumeXCursor(
-    ScreenPtr pScreen,
-    int x,
-    int y )
-{
-    QuartzSetCursor(pScreen, quartzLatentCursor, x, y);
-}
diff --git a/hw/darwin/quartz/quartzCursor.h b/hw/darwin/quartz/quartzCursor.h
deleted file mode 100644
index 56a0209..0000000
--- a/hw/darwin/quartz/quartzCursor.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * quartzCursor.h
- *
- * External interface for Quartz hardware cursor
- *
- * Copyright (c) 2001 Torrey T. Lyons and Greg Parker.
- *                 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
- * 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 QUARTZCURSOR_H
-#define QUARTZCURSOR_H
-
-#include "screenint.h"
-
-Bool QuartzInitCursor(ScreenPtr pScreen);
-void QuartzReallySetCursor(void);
-void QuartzSuspendXCursor(ScreenPtr pScreen);
-void QuartzResumeXCursor(ScreenPtr pScreen, int x, int y);
-
-#endif
diff --git a/hw/darwin/quartz/quartzKeyboard.c b/hw/darwin/quartz/quartzKeyboard.c
deleted file mode 100644
index c69fb9f..0000000
--- a/hw/darwin/quartz/quartzKeyboard.c
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
-   quartzKeyboard.c
-
-   Code to build a keymap using the Carbon Keyboard Layout API.
-
-   Copyright (c) 2003-2007 Apple Inc.
-
-   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.
-*/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "quartzCommon.h"
-
-#include <CoreServices/CoreServices.h>
-#include <Carbon/Carbon.h>
-
-#include "darwinKeyboard_interface.h"
-#include "X11/keysym.h"
-#include "keysym2ucs.h"
-
-#define HACK_MISSING 1
-#define HACK_KEYPAD 1
-
-enum {
-    MOD_COMMAND = 256,
-    MOD_SHIFT = 512,
-    MOD_OPTION = 2048,
-    MOD_CONTROL = 4096,
-};
-
-#define UKEYSYM(u) ((u) | 0x01000000)
-
-/* Table of keycode->keysym mappings we use to fallback on for important
-   keys that are often not in the Unicode mapping. */
-
-const static struct {
-    unsigned short keycode;
-    KeySym keysym;
-} known_keys[] = {
-    {55,  XK_Meta_L},
-    {56,  XK_Shift_L},
-    {57,  XK_Caps_Lock},
-    {58,  XK_Mode_switch},
-    {59,  XK_Control_L},
-
-    {60,  XK_Shift_R},
-    {61,  XK_Mode_switch},
-    {62,  XK_Control_R},
-    {63,  XK_Meta_R},
-
-    {122, XK_F1},
-    {120, XK_F2},
-    {99,  XK_F3},
-    {118, XK_F4},
-    {96,  XK_F5},
-    {97,  XK_F6},
-    {98,  XK_F7},
-    {100, XK_F8},
-    {101, XK_F9},
-    {109, XK_F10},
-    {103, XK_F11},
-    {111, XK_F12},
-    {105, XK_F13},
-    {107, XK_F14},
-    {113, XK_F15},
-};
-
-/* Table of keycode->old,new-keysym mappings we use to fixup the numeric
-   keypad entries. */
-
-const static struct {
-    unsigned short keycode;
-    KeySym normal, keypad;
-} known_numeric_keys[] = {
-    {65, XK_period, XK_KP_Decimal},
-    {67, XK_asterisk, XK_KP_Multiply},
-    {69, XK_plus, XK_KP_Add},
-    {75, XK_slash, XK_KP_Divide},
-    {76, 0x01000003, XK_KP_Enter},
-    {78, XK_minus, XK_KP_Subtract},
-    {81, XK_equal, XK_KP_Equal},
-    {82, XK_0, XK_KP_0},
-    {83, XK_1, XK_KP_1},
-    {84, XK_2, XK_KP_2},
-    {85, XK_3, XK_KP_3},
-    {86, XK_4, XK_KP_4},
-    {87, XK_5, XK_KP_5},
-    {88, XK_6, XK_KP_6},
-    {89, XK_7, XK_KP_7},
-    {91, XK_8, XK_KP_8},
-    {92, XK_9, XK_KP_9},
-};
-
-/* Table mapping normal keysyms to their dead equivalents.
-   FIXME: all the unicode keysyms (apart from circumflex) were guessed. */
-
-const static struct {
-    KeySym normal, dead;
-} dead_keys[] = {
-    {XK_grave, XK_dead_grave},
-    {XK_acute, XK_dead_acute},
-    {XK_asciicircum, XK_dead_circumflex},
-    {UKEYSYM (0x2c6), XK_dead_circumflex},	/* MODIFIER LETTER CIRCUMFLEX ACCENT */
-    {XK_asciitilde, XK_dead_tilde},
-    {UKEYSYM (0x2dc), XK_dead_tilde},		/* SMALL TILDE */
-    {XK_macron, XK_dead_macron},
-    {XK_breve, XK_dead_breve},
-    {XK_abovedot, XK_dead_abovedot},
-    {XK_diaeresis, XK_dead_diaeresis},
-    {UKEYSYM (0x2da), XK_dead_abovering},	/* DOT ABOVE */
-    {XK_doubleacute, XK_dead_doubleacute},
-    {XK_caron, XK_dead_caron},
-    {XK_cedilla, XK_dead_cedilla},
-    {XK_ogonek, XK_dead_ogonek},
-    {UKEYSYM (0x269), XK_dead_iota},		/* LATIN SMALL LETTER IOTA */
-    {UKEYSYM (0x2ec), XK_dead_voiced_sound},	/* MODIFIER LETTER VOICING */
-/*  {XK_semivoiced_sound, XK_dead_semivoiced_sound}, */
-    {UKEYSYM (0x323), XK_dead_belowdot},	/* COMBINING DOT BELOW */
-    {UKEYSYM (0x309), XK_dead_hook}, 		/* COMBINING HOOK ABOVE */
-    {UKEYSYM (0x31b), XK_dead_horn},		/* COMBINING HORN */
-};
-
-unsigned int DarwinModeSystemKeymapSeed(void) {
-    static unsigned int seed;
-    static KeyboardLayoutRef last_key_layout;
-    KeyboardLayoutRef key_layout;
-
-    KLGetCurrentKeyboardLayout (&key_layout);
-    if (key_layout != last_key_layout) seed++;
-    last_key_layout = key_layout;
-
-    return seed;
-}
-
-static inline UniChar macroman2ucs(unsigned char c) {
-    /* Precalculated table mapping MacRoman-128 to Unicode. Generated
-       by creating single element CFStringRefs then extracting the
-       first character. */
-
-    static const unsigned short table[128] = {
-        0xc4, 0xc5, 0xc7, 0xc9, 0xd1, 0xd6, 0xdc, 0xe1,
-        0xe0, 0xe2, 0xe4, 0xe3, 0xe5, 0xe7, 0xe9, 0xe8,
-        0xea, 0xeb, 0xed, 0xec, 0xee, 0xef, 0xf1, 0xf3,
-        0xf2, 0xf4, 0xf6, 0xf5, 0xfa, 0xf9, 0xfb, 0xfc,
-        0x2020, 0xb0, 0xa2, 0xa3, 0xa7, 0x2022, 0xb6, 0xdf,
-        0xae, 0xa9, 0x2122, 0xb4, 0xa8, 0x2260, 0xc6, 0xd8,
-        0x221e, 0xb1, 0x2264, 0x2265, 0xa5, 0xb5, 0x2202, 0x2211,
-        0x220f, 0x3c0, 0x222b, 0xaa, 0xba, 0x3a9, 0xe6, 0xf8,
-        0xbf, 0xa1, 0xac, 0x221a, 0x192, 0x2248, 0x2206, 0xab,
-        0xbb, 0x2026, 0xa0, 0xc0, 0xc3, 0xd5, 0x152, 0x153,
-        0x2013, 0x2014, 0x201c, 0x201d, 0x2018, 0x2019, 0xf7, 0x25ca,
-        0xff, 0x178, 0x2044, 0x20ac, 0x2039, 0x203a, 0xfb01, 0xfb02,
-        0x2021, 0xb7, 0x201a, 0x201e, 0x2030, 0xc2, 0xca, 0xc1,
-        0xcb, 0xc8, 0xcd, 0xce, 0xcf, 0xcc, 0xd3, 0xd4,
-        0xf8ff, 0xd2, 0xda, 0xdb, 0xd9, 0x131, 0x2c6, 0x2dc,
-        0xaf, 0x2d8, 0x2d9, 0x2da, 0xb8, 0x2dd, 0x2db, 0x2c7,
-    };
-
-    if (c < 128) return c;
-    else         return table[c - 128];
-}
-
-static KeySym make_dead_key(KeySym in) {
-    int i;
-
-    for (i = 0; i < sizeof (dead_keys) / sizeof (dead_keys[0]); i++)
-        if (dead_keys[i].normal == in) return dead_keys[i].dead;
-
-    return in;
-}
-
-Bool DarwinModeReadSystemKeymap(darwinKeyboardInfo *info) {
-    KeyboardLayoutRef key_layout;
-    const void *chr_data = NULL;
-    int num_keycodes = NUM_KEYCODES;
-    UInt32 keyboard_type = 0;
-    int is_uchr = 1, i, j;
-    OSStatus err;
-    KeySym *k;
-
-    TISInputSourceRef currentKeyLayoutRef = TISCopyCurrentKeyboardLayoutInputSource();
-    keyboard_type = LMGetKbdType ();
-    if (currentKeyLayoutRef) {
-      CFDataRef currentKeyLayoutDataRef = (CFDataRef )TISGetInputSourceProperty(currentKeyLayoutRef, kTISPropertyUnicodeKeyLayoutData);
-      if (currentKeyLayoutDataRef) chr_data = CFDataGetBytePtr(currentKeyLayoutDataRef);
-    }
-    
-    if (chr_data == NULL) {
-      KLGetCurrentKeyboardLayout (&key_layout);
-      KLGetKeyboardLayoutProperty (key_layout, kKLuchrData, &chr_data);
-    }
-    
-    if (chr_data == NULL) {
-      KLGetKeyboardLayoutProperty (key_layout, kKLKCHRData, &chr_data);
-      is_uchr = 0;
-      num_keycodes = 128;
-    }
-    
-    if (chr_data == NULL) {
-      ErrorF ( "Couldn't get uchr or kchr resource\n");
-      return FALSE;
-    }
-
-    /* Scan the keycode range for the Unicode character that each
-       key produces in the four shift states. Then convert that to
-       an X11 keysym (which may just the bit that says "this is
-       Unicode" if it can't find the real symbol.) */
-
-    for (i = 0; i < num_keycodes; i++) {
-        static const int mods[4] = {0, MOD_SHIFT, MOD_OPTION,
-                                    MOD_OPTION | MOD_SHIFT};
-
-        k = info->keyMap + i * GLYPHS_PER_KEY;
-
-        for (j = 0; j < 4; j++) {
-            if (is_uchr)  {
-                UniChar s[8];
-                UniCharCount len;
-                UInt32 dead_key_state = 0, extra_dead = 0;
-
-                err = UCKeyTranslate (chr_data, i, kUCKeyActionDown,
-                                      mods[j] >> 8, keyboard_type, 0,
-                                      &dead_key_state, 8, &len, s);
-                if (err != noErr) continue;
-
-                if (len == 0 && dead_key_state != 0) {
-                    /* Found a dead key. Work out which one it is, but
-                       remembering that it's dead. */
-                    err = UCKeyTranslate (chr_data, i, kUCKeyActionDown,
-                                          mods[j] >> 8, keyboard_type,
-                                          kUCKeyTranslateNoDeadKeysMask,
-                                          &extra_dead, 8, &len, s);
-                    if (err != noErr) continue;
-                }
-
-                if (len > 0 && s[0] != 0x0010) {
-                    k[j] = ucs2keysym (s[0]);
-                    if (dead_key_state != 0) k[j] = make_dead_key (k[j]);
-                }
-            } else { // kchr
-	      UInt32 c, state = 0, state2 = 0;
-                UInt16 code;
-
-                code = i | mods[j];
-                c = KeyTranslate (chr_data, code, &state);
-
-                /* Dead keys are only processed on key-down, so ask
-                   to translate those events. When we find a dead key,
-                   translating the matching key up event will give
-                   us the actual dead character. */
-
-                if (state != 0)
-                    c = KeyTranslate (chr_data, code | 128, &state2);
-
-                /* Characters seem to be in MacRoman encoding. */
-
-                if (c != 0 && c != 0x0010) {
-                    k[j] = ucs2keysym (macroman2ucs (c & 255));
-
-                    if (state != 0) k[j] = make_dead_key (k[j]);
-                }
-            }
-        }
-	
-        if (k[3] == k[2]) k[3] = NoSymbol;
-        if (k[2] == k[1]) k[2] = NoSymbol;
-        if (k[1] == k[0]) k[1] = NoSymbol;
-        if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol;
-    }
-
-    /* Fix up some things that are normally missing.. */
-
-    if (HACK_MISSING) {
-        for (i = 0; i < sizeof (known_keys) / sizeof (known_keys[0]); i++) {
-            k = info->keyMap + known_keys[i].keycode * GLYPHS_PER_KEY;
-
-            if    (k[0] == NoSymbol && k[1] == NoSymbol
-                && k[2] == NoSymbol && k[3] == NoSymbol)
-	      k[0] = known_keys[i].keysym;
-        }
-    }
-
-    /* And some more things. We find the right symbols for the numeric
-       keypad, but not the KP_ keysyms. So try to convert known keycodes. */
-
-    if (HACK_KEYPAD) {
-        for (i = 0; i < sizeof (known_numeric_keys)
-                        / sizeof (known_numeric_keys[0]); i++) {
-            k = info->keyMap + known_numeric_keys[i].keycode * GLYPHS_PER_KEY;
-
-            if (k[0] == known_numeric_keys[i].normal)
-                k[0] = known_numeric_keys[i].keypad;
-        }
-    }
-    if(currentKeyLayoutRef)	CFRelease(currentKeyLayoutRef);
-    
-    return TRUE;
-}
diff --git a/hw/darwin/quartz/quartzPasteboard.c b/hw/darwin/quartz/quartzPasteboard.c
deleted file mode 100644
index 0cecff5..0000000
--- a/hw/darwin/quartz/quartzPasteboard.c
+++ /dev/null
@@ -1,153 +0,0 @@
-/**************************************************************
- * quartzPasteboard.c
- *
- * Aqua pasteboard <-> X cut buffer
- * Greg Parker     gparker at cs.stanford.edu     March 8, 2001
- **************************************************************/
-/*
- * Copyright (c) 2001 Greg Parker. 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
- * 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "quartzPasteboard.h"
-
-#include <X11/Xatom.h>
-#include "windowstr.h"
-#include "propertyst.h"
-#include "scrnintstr.h"
-#include "selection.h"
-#include "globals.h"
-
-extern Selection *CurrentSelections;
-extern int NumCurrentSelections;
-
-
-// Helper function to read the X11 cut buffer
-// FIXME: What about multiple screens? Currently, this reads the first
-// CUT_BUFFER0 from the first screen where the buffer content is a string.
-// Returns a string on the heap that the caller must free.
-// Returns NULL if there is no cut text or there is not enough memory.
-static char * QuartzReadCutBuffer(void)
-{
-    int i;
-    char *text = NULL;
-
-    for (i = 0; i < screenInfo.numScreens; i++) {
-        ScreenPtr pScreen = screenInfo.screens[i];
-        PropertyPtr pProp;
-
-        pProp = wUserProps (WindowTable[pScreen->myNum]);
-        while (pProp && pProp->propertyName != XA_CUT_BUFFER0) {
-	    pProp = pProp->next;
-        }
-        if (! pProp) continue;
-        if (pProp->type != XA_STRING) continue;
-        if (pProp->format != 8) continue;
-
-        text = xalloc(1 + pProp->size);
-        if (! text) continue;
-        memcpy(text, pProp->data, pProp->size);
-        text[pProp->size] = '\0';
-        return text;
-    }
-
-    // didn't find any text
-    return NULL;
-}
-
-// Write X cut buffer to Mac OS X pasteboard
-// Called by ProcessInputEvents() in response to request from X server thread.
-void QuartzWritePasteboard(void)
-{
-    char *text;
-    text = QuartzReadCutBuffer();
-    if (text) {
-        QuartzWriteCocoaPasteboard(text);
-        free(text);
-    }
-}
-
-#define strequal(a, b) (0 == strcmp((a), (b)))
-
-// Read Mac OS X pasteboard into X cut buffer
-// Called by ProcessInputEvents() in response to request from X server thread.
-void QuartzReadPasteboard(void)
-{
-    char *oldText = QuartzReadCutBuffer();
-    char *text = QuartzReadCocoaPasteboard();
-
-    // Compare text with current cut buffer contents.
-    // Change the buffer if both exist and are different
-    //   OR if there is new text but no old text.
-    // Otherwise, don't clear the selection unnecessarily.
-
-    if ((text && oldText && !strequal(text, oldText)) ||
-        (text && !oldText)) {
-        int scrn, sel;
-
-        for (scrn = 0; scrn < screenInfo.numScreens; scrn++) {
-	    ScreenPtr pScreen = screenInfo.screens[scrn];
-	    // Set the cut buffers on each screen
-	    // fixme really on each screen?
-	    ChangeWindowProperty(WindowTable[pScreen->myNum], XA_CUT_BUFFER0,
-				 XA_STRING, 8, PropModeReplace,
-				 strlen(text), (pointer)text, TRUE);
-        }
-
-        // Undo any current X selection (similar to code in dispatch.c)
-        // FIXME: what about secondary selection?
-        // FIXME: only touch first XA_PRIMARY selection?
-        sel = 0;
-        while ((sel < NumCurrentSelections)  &&
-	       CurrentSelections[sel].selection != XA_PRIMARY)
-	    sel++;
-        if (sel < NumCurrentSelections) {
-	    // Notify client if necessary
-	    if (CurrentSelections[sel].client) {
-	        xEvent event;
-
-	        event.u.u.type = SelectionClear;
-		event.u.selectionClear.time = GetTimeInMillis();
-		event.u.selectionClear.window = CurrentSelections[sel].window;
-		event.u.selectionClear.atom = CurrentSelections[sel].selection;
-		TryClientEvents(CurrentSelections[sel].client, &event, 1,
-				NoEventMask, NoEventMask /*CantBeFiltered*/,
-				NullGrab);
-	    }
-
-	    // Erase it
-	    // FIXME: need to erase .selection too? dispatch.c doesn't
-	    CurrentSelections[sel].pWin = NullWindow;
-	    CurrentSelections[sel].window = None;
-	    CurrentSelections[sel].client = NullClient;
-        }
-    }
-
-    if (text) free(text);
-    if (oldText) free(oldText);
-}
diff --git a/hw/darwin/quartz/quartzPasteboard.h b/hw/darwin/quartz/quartzPasteboard.h
deleted file mode 100644
index afcb6e5..0000000
--- a/hw/darwin/quartz/quartzPasteboard.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* 
-   QuartzPasteboard.h
-
-   Mac OS X pasteboard <-> X cut buffer
-   Greg Parker     gparker at cs.stanford.edu     March 8, 2001
-*/
-/*
- * Copyright (c) 2001 Greg Parker. 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
- * 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 _QUARTZPASTEBOARD_H
-#define _QUARTZPASTEBOARD_H
-
-// Aqua->X 
-void QuartzReadPasteboard();
-char * QuartzReadCocoaPasteboard(void);	// caller must free string
-
-// X->Aqua
-void QuartzWritePasteboard();
-void QuartzWriteCocoaPasteboard(char *text);
-
-#endif	/* _QUARTZPASTEBOARD_H */
diff --git a/hw/darwin/quartz/quartzStartup.c b/hw/darwin/quartz/quartzStartup.c
deleted file mode 100644
index e20c16b..0000000
--- a/hw/darwin/quartz/quartzStartup.c
+++ /dev/null
@@ -1,129 +0,0 @@
-/**************************************************************
- *
- * Startup code for the Quartz Darwin X Server
- *
- * Copyright (c) 2001-2004 Torrey T. Lyons. 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
- * 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <fcntl.h>
-#include <unistd.h>
-#include <CoreFoundation/CoreFoundation.h>
-#include "quartzCommon.h"
-#include "darwin.h"
-#include "quartz.h"
-#include "opaque.h"
-#include "micmap.h"
-
-#ifdef NDEBUG
-#undef NDEBUG
-#include <assert.h>
-#define NDEBUG 1
-#else
-#include <assert.h>
-#endif
-
-char **envpGlobal;      // argcGlobal and argvGlobal
-                        // are from dix/globals.c
-
-
-void X11ControllerMain(int argc, char *argv[], void (*server_thread) (void *), void *server_arg);
-
-static void server_thread (void *arg) {
-  extern int main(int argc, char **argv, char **envp);
-  exit (main (argcGlobal, argvGlobal, envpGlobal));
-}
-
-/*
- * DarwinHandleGUI
- *  This function is called first from main(). The first time
- *  it is called we start the Mac OS X front end. The front end
- *  will call main() again from another thread to run the X
- *  server. On the second call this function loads the user
- *  preferences set by the Mac OS X front end.
- */
-void DarwinHandleGUI(
-    int         argc,
-    char        *argv[],
-    char        *envp[] )
-{
-    static Bool been_here = FALSE;
-    int         i;
-    int         fd[2];
-
-    if (been_here) {
-        return;
-    }
-    been_here = TRUE;
-
-    // Make a pipe to pass events
-    assert( pipe(fd) == 0 );
-    darwinEventReadFD = fd[0];
-    darwinEventWriteFD = fd[1];
-    fcntl(darwinEventReadFD, F_SETFL, O_NONBLOCK);
-
-    // Store command line arguments to pass back to main()
-    argcGlobal = argc;
-    argvGlobal = argv;
-    envpGlobal = envp;
-
-    quartzStartClients = 1;
-    for (i = 1; i < argc; i++) {
-        // Display version info without starting Mac OS X UI if requested
-        if (!strcmp( argv[i], "-showconfig" ) || !strcmp( argv[i], "-version" )) {
-            DarwinPrintBanner();
-            exit(0);
-        }
-
-        // Determine if we need to start X clients
-        // and what display mode to use
-        if (!strcmp(argv[i], "-nostartx")) {
-            quartzStartClients = 0;    
-        } else if (!strcmp( argv[i], "-fullscreen")) {
-            quartzRootless = 0;
-        } else if (!strcmp( argv[i], "-rootless")) {
-            quartzRootless = 1;
-        }
-    }
-
-
-    /* Initially I ran the X server on the main thread, and received
-       events on the second thread. But now we may be using Carbon,
-       that needs to run on the main thread. (Otherwise, when it's
-       prebound, it will initialize itself on the wrong thread)
-       
-       grr.. but doing that means that if the X thread gets scheduled
-       before the main thread when we're _not_ prebound, things fail,
-       so initialize by hand. */
-
-    extern void _InitHLTB(void);
-    
-    _InitHLTB();    
-    X11ControllerMain(argc, argv, server_thread, NULL);
-    exit(0);
-}
diff --git a/hw/darwin/quartz/xpr/Makefile.am b/hw/darwin/quartz/xpr/Makefile.am
deleted file mode 100644
index 7696622..0000000
--- a/hw/darwin/quartz/xpr/Makefile.am
+++ /dev/null
@@ -1,71 +0,0 @@
-bin_PROGRAMS = Xquartz
-
-# TODO: This man page needs sed magic and cleanup
-man1_MANS = Xquartz.man
-
-AM_CFLAGS =  $(XSERVER_CFLAGS) $(DIX_CFLAGS)
-AM_CPPFLAGS = \
-	-I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../.. \
-	-I$(top_srcdir)/miext \
-	-I$(top_srcdir)/miext/rootless \
-	-I$(top_srcdir)/miext/rootless/safeAlpha
-
-Xquartz_SOURCES = \
-	appledri.c \
-	dri.c \
-	xprAppleWM.c \
-	xprCursor.c \
-	xprFrame.c \
-	xprScreen.c \
-	x-hash.c \
-	x-hook.c \
-	x-list.c
-
-Xquartz_LDADD = \
-	$(top_builddir)/hw/darwin/quartz/libXquartz.la \
-	$(top_builddir)/hw/darwin/libXdarwin.la \
-	$(top_builddir)/dix/dixfonts.lo \
-	$(top_builddir)/dix/libdix.la \
-	$(top_builddir)/os/libos.la \
-	$(top_builddir)/dix/libxpstubs.la \
-	$(top_builddir)/miext/shadow/libshadow.la \
-	$(top_builddir)/fb/libfb.la \
-	$(top_builddir)/mi/libmi.la \
-	$(top_builddir)/composite/libcomposite.la \
-	$(top_builddir)/damageext/libdamageext.la \
-	$(top_builddir)/miext/damage/libdamage.la \
-	$(top_builddir)/xfixes/libxfixes.la \
-	$(top_builddir)/miext/cw/libcw.la \
-	$(top_builddir)/Xext/libXext.la \
-	$(top_builddir)/xkb/libxkb.la \
-	$(top_builddir)/xkb/libxkbstubs.la \
-	$(top_builddir)/Xi/libXi.la \
-	$(top_builddir)/dbe/libdbe.la \
-	$(top_builddir)/record/librecord.la \
-	$(top_builddir)/XTrap/libxtrap.la \
-	$(top_builddir)/miext/rootless/librootless.la \
-	$(top_builddir)/miext/rootless/safeAlpha/libsafeAlpha.la \
-	$(top_builddir)/miext/rootless/accel/librlAccel.la \
-	$(DARWIN_LIBS) $(XSERVER_LIBS) $(XSERVER_SYS_LIBS) -lXplugin
-
-Xquartz_LDFLAGS =  \
-	-XCClinker -Objc \
-	-Wl,-u,_miDCInitialize \
-	-Wl,-framework,Carbon \
-	-L/System/Library/Frameworks/OpenGL.framework/Libraries -lGL \
-	-Wl,-framework,OpenGL \
-	-Wl,-framework,Cocoa \
-	-Wl,-framework,CoreAudio \
-	-Wl,-framework,IOKit
-
-EXTRA_DIST = \
-	Xquartz.man \
-	dri.h \
-	dristruct.h \
-	appledri.h \
-	appledristr.h \
-	x-hash.h \
-	x-hook.h \
-	x-list.h \
-	Xplugin.h \
-	xpr.h
diff --git a/hw/darwin/quartz/xpr/Xplugin.h b/hw/darwin/quartz/xpr/Xplugin.h
deleted file mode 100644
index a10b1b8..0000000
--- a/hw/darwin/quartz/xpr/Xplugin.h
+++ /dev/null
@@ -1,589 +0,0 @@
-/* Xplugin.h -- windowing API for rootless X11 server
-
-   Copyright (c) 2002 Apple Computer, Inc. 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 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.
-
-   Note that these interfaces are provided solely for the use of the
-   X11 server. Any other uses are unsupported and strongly discouraged. */
-
-#ifndef XPLUGIN_H
-#define XPLUGIN_H 1
-
-#include <stdint.h>
-
-/* By default we use the X server definition of BoxRec to define xp_box,
-   so that the compiler can silently convert between the two. But if
-   XP_NO_X_HEADERS is defined, we'll define it ourselves. */
-
-#ifndef XP_NO_X_HEADERS
-# include "miscstruct.h"
-  typedef BoxRec xp_box;
-#else
-  struct xp_box_struct {
-      short x1, y1, x2, y2;
-  };
-  typedef struct xp_box_struct xp_box;
-#endif
-
-typedef unsigned int xp_resource_id;
-typedef xp_resource_id xp_window_id;
-typedef xp_resource_id xp_surface_id;
-typedef unsigned int xp_client_id;
-typedef unsigned int xp_request_type;
-typedef int xp_error;
-typedef int xp_bool;
-
-
-/* Error codes that the functions declared here may return. They all
-   numerically match their X equivalents, i.e. the XP_ can be dropped
-   if <X11/X.h> has been included. */
-
-enum xp_error_enum {
-    XP_Success			= 0,
-    XP_BadRequest		= 1,
-    XP_BadValue			= 2,
-    XP_BadWindow		= 3,
-    XP_BadMatch			= 8,
-    XP_BadAccess		= 10,
-    XP_BadImplementation	= 17,
-};    
-
-
-/* Event types generated by the plugin. */
-
-enum xp_event_type_enum {
-    /* The global display configuration changed somehow. */
-    XP_EVENT_DISPLAY_CHANGED	= 1 << 0,
-
-    /* A window changed state. Argument is xp_window_state_event */
-    XP_EVENT_WINDOW_STATE_CHANGED = 1 << 1,
-
-    /* An async request encountered an error. Argument is of type
-       xp_async_error_event */
-    XP_EVENT_ASYNC_ERROR	= 1 << 2,
-
-    /* Sent when a surface is destroyed as a side effect of destroying
-       a window. Arg is of type xp_surface_id. */
-    XP_EVENT_SURFACE_DESTROYED	= 1 << 3,
-
-    /* Sent when any GL contexts pointing at the given surface need to
-       call xp_update_gl_context () to refresh their state (because the
-       window moved or was resized. Arg is of type xp_surface_id. */
-    XP_EVENT_SURFACE_CHANGED	= 1 << 4,
-
-    /* Sent when a window has been moved. Arg is of type xp_window_id. */
-    XP_EVENT_WINDOW_MOVED	= 1 << 5,
-};
-
-/* Function type used to receive events. */
-
-typedef void (xp_event_fun) (unsigned int type, const void *arg,
-			     unsigned int arg_size, void *user_data);
-
-
-/* Operation types. Used when reporting errors asynchronously. */
-
-enum xp_request_type_enum {
-    XP_REQUEST_NIL = 0,
-    XP_REQUEST_DESTROY_WINDOW = 1,
-    XP_REQUEST_CONFIGURE_WINDOW = 2,
-    XP_REQUEST_FLUSH_WINDOW = 3,
-    XP_REQUEST_COPY_WINDOW = 4,
-    XP_REQUEST_UNLOCK_WINDOW = 5,
-    XP_REQUEST_DISABLE_UPDATE = 6,
-    XP_REQUEST_REENABLE_UPDATE = 7,
-    XP_REQUEST_HIDE_CURSOR = 8,
-    XP_REQUEST_SHOW_CURSOR = 9,
-    XP_REQUEST_FRAME_DRAW = 10,
-};
-
-/* Structure used to report an error asynchronously. Passed as the "arg"
-   of an XP_EVENT_ASYNC_ERROR event. */
-
-struct xp_async_error_event_struct {
-    xp_request_type request_type;
-    xp_resource_id id;
-    xp_error error;
-};
-
-typedef struct xp_async_error_event_struct xp_async_error_event;
-
-
-/* Possible window states. */
-
-enum xp_window_state_enum {
-    /* The window is not in the global list of possibly-visible windows. */
-    XP_WINDOW_STATE_OFFSCREEN	= 1 << 0,
-
-    /* Parts of the window may be obscured by other windows. */
-    XP_WINDOW_STATE_OBSCURED	= 1 << 1,
-};
-
-/* Structure passed as argument of an XP_EVENT_WINDOW_STATE_CHANGED event. */
-
-struct xp_window_state_event_struct {
-    xp_window_id id;
-    unsigned int state;
-};
-
-typedef struct xp_window_state_event_struct xp_window_state_event;
-
-
-/* Function type used to supply a colormap for indexed drawables. */
-
-typedef xp_error (xp_colormap_fun) (void *data, int first_color,
-				    int n_colors, uint32_t *colors);
-
-
-/* Window attributes structure. Used when creating and configuring windows.
-   Also used when configuring surfaces attached to windows. Functions that
-   take one of these structures also take a bit mask defining which
-   fields are set to meaningful values. */
-
-enum xp_window_changes_enum {
-    XP_ORIGIN			= 1 << 0,
-    XP_SIZE			= 1 << 1,
-    XP_BOUNDS			= XP_ORIGIN | XP_SIZE,
-    XP_SHAPE			= 1 << 2,
-    XP_STACKING			= 1 << 3,
-    XP_DEPTH			= 1 << 4,
-    XP_COLORMAP			= 1 << 5,
-    XP_WINDOW_LEVEL		= 1 << 6,
-};
-
-struct xp_window_changes_struct {
-    /* XP_ORIGIN */
-    int x, y;
-
-    /* XP_SIZE */
-    unsigned int width, height;
-    int bit_gravity;			/* how to resize the backing store */
-
-    /* XP_SHAPE */
-    int shape_nrects;			/* -1 = remove shape */
-    xp_box *shape_rects;
-    int shape_tx, shape_ty;		/* translation for shape */
-
-    /* XP_STACKING */
-    int stack_mode;
-    xp_window_id sibling;		/* may be zero; in ABOVE/BELOW modes
-					   it may specify a relative window */
-    /* XP_DEPTH, window-only */
-    unsigned int depth;
-
-    /* XP_COLORMAP, window-only */
-    xp_colormap_fun *colormap;
-    void *colormap_data;
-
-    /* XP_WINDOW_LEVEL, window-only */
-    int window_level;
-};
-
-typedef struct xp_window_changes_struct xp_window_changes;
-
-/* Values for bit_gravity field */
-
-enum xp_bit_gravity_enum {
-    XP_GRAVITY_NONE		= 0,	/* no gravity, fill everything */
-    XP_GRAVITY_NORTH_WEST	= 1,	/* anchor to top-left corner */
-    XP_GRAVITY_NORTH_EAST	= 2,	/* anchor to top-right corner */
-    XP_GRAVITY_SOUTH_EAST	= 3,	/* anchor to bottom-right corner */
-    XP_GRAVITY_SOUTH_WEST	= 4,	/* anchor to bottom-left corner */
-};
-
-/* Values for stack_mode field */
-
-enum xp_window_stack_mode_enum {
-    XP_UNMAPPED			= 0,	/* remove the window */
-    XP_MAPPED_ABOVE		= 1,	/* display the window on top */
-    XP_MAPPED_BELOW		= 2,	/* display the window at bottom */
-};
-
-/* Data formats for depth field and composite functions */
-
-enum xp_depth_enum {
-    XP_DEPTH_NIL = 0,			/* null source when compositing */
-    XP_DEPTH_ARGB8888,
-    XP_DEPTH_RGB555,
-    XP_DEPTH_A8,			/* for masks when compositing */
-    XP_DEPTH_INDEX8,
-};
-
-/* Options that may be passed to the xp_init () function. */
-
-enum xp_init_options_enum {
-    /* Don't mark that this process can be in the foreground. */
-    XP_IN_BACKGROUND		= 1 << 0,
-
-    /* Deliver background pointer events to this process. */
-    XP_BACKGROUND_EVENTS	= 1 << 1,
-};
-
-
-
-/* Miscellaneous functions */
-
-/* Initialize the plugin library. Only the copy/fill/composite functions
-   may be called without having previously called xp_init () */
-
-extern xp_error xp_init (unsigned int options);
-
-/* Sets the current set of requested notifications to MASK. When any of
-   these arrive, CALLBACK will be invoked with CALLBACK-DATA. Note that
-   calling this function cancels any previously requested notifications
-   that aren't set in MASK. */
-
-extern xp_error xp_select_events (unsigned int mask,
-				  xp_event_fun *callback,
-				  void *callback_data);
-
-/* Waits for all initiated operations to complete. */
-
-extern xp_error xp_synchronize (void);
-
-/* Causes any display update initiated through the plugin libary to be
-   queued until update is reenabled. Note that calls to these functions
-   nest. */
-  
-extern xp_error xp_disable_update (void);
-extern xp_error xp_reenable_update (void);
-
-
-
-/* Cursor functions. */
-
-/* Installs the specified cursor. ARGB-DATA should point to 32-bit
-   premultiplied big-endian ARGB data. The HOT-X,HOT-Y parameters
-   specify the offset to the cursor's hot spot from its top-left
-   corner. */
-
-extern xp_error xp_set_cursor (unsigned int width, unsigned int height,
-			       unsigned int hot_x, unsigned int hot_y,
-			       const uint32_t *argb_data,
-			       unsigned int rowbytes);
-
-/* Hide and show the cursor if it's owned by the current process. Calls
-   to these functions nest. */
-
-extern xp_error xp_hide_cursor (void);
-extern xp_error xp_show_cursor (void);
-
-
-
-/* Window functions. */
-
-/* Create a new window as defined by MASK and VALUES. MASK must contain
-   XP_BOUNDS or an error is raised. The id of the newly created window
-   is stored in *RET-ID if this function returns XP_Success. */
-
-extern xp_error xp_create_window (unsigned int mask,
-				  const xp_window_changes *values,
-				  xp_window_id *ret_id);
-
-/* Destroys the window identified by ID. */
-
-extern xp_error xp_destroy_window (xp_window_id id);
-
-/* Reconfigures the given window according to MASK and VALUES. */
-
-extern xp_error xp_configure_window (xp_window_id id, unsigned int mask,
-				     const xp_window_changes *values);
-
-
-/* Returns true if NATIVE-ID is a window created by the plugin library.
-   If so and RET-ID is non-null, stores the id of the window in *RET-ID. */
-
-extern xp_bool xp_lookup_native_window (unsigned int native_id,
-					xp_window_id *ret_id);
-
-/* If ID names a window created by the plugin library, stores it's native
-   window id in *RET-NATIVE-ID. */
-
-extern xp_error xp_get_native_window (xp_window_id id,
-				      unsigned int *ret_native_id);
-
-
-/* Locks the rectangle IN-RECT (or, if null, the entire window) of the
-   given window's backing store. Any other non-null parameters are filled
-   in as follows:
-
-   DEPTH = format of returned data. Currently either XP_DEPTH_ARGB8888
-   or XP_DEPTH_RGB565 (possibly with 8 bit planar alpha). Data is
-   always stored in native byte order.
-
-   BITS[0] = pointer to top-left pixel of locked color data
-   BITS[1] = pointer to top-left of locked alpha data, or null if window
-   has no alpha. If the alpha data is meshed, then BITS[1] = BITS[0].
-
-   ROWBYTES[0,1] = size in bytes of each row of color,alpha data
-
-   OUT-RECT = rectangle specifying the current position and size of the
-   locked region relative to the window origin.
-
-   Note that an error is raised when trying to lock an already locked
-   window. While the window is locked, the only operations that may
-   be performed on it are to modify, access or flush its marked region. */
-
-extern xp_error xp_lock_window (xp_window_id id,
-				const xp_box *in_rect,
-				unsigned int *depth,
-				void *bits[2],
-				unsigned int rowbytes[2],
-				xp_box *out_rect);
-
-/* Mark that the region specified by SHAPE-NRECTS, SHAPE-RECTS,
-   SHAPE-TX, and SHAPE-TY in the specified window has been updated, and
-   will need to subsequently be redisplayed. */
-
-extern xp_error xp_mark_window (xp_window_id id, int shape_nrects,
-				const xp_box *shape_rects,
-				int shape_tx, int shape_ty);
-
-/* Unlocks the specified window. If FLUSH is true, then any marked
-   regions are immediately redisplayed. Note that it's an error to
-   unlock an already unlocked window. */
-
-extern xp_error xp_unlock_window (xp_window_id id, xp_bool flush);
-
-/* If anything is marked in the given window for redisplay, do it now. */
-
-extern xp_error xp_flush_window (xp_window_id id);
-
-/* Moves the contents of the region DX,DY pixels away from that specified
-   by DST_RECTS and DST_NRECTS in the window with SRC-ID to the
-   destination region in the window DST-ID. Note that currently source
-   and destination windows must be the same. */
-
-extern xp_error xp_copy_window (xp_window_id src_id, xp_window_id dst_id,
-				int dst_nrects, const xp_box *dst_rects,
-				int dx, int dy);
-
-/* Returns true if the given window has any regions marked for
-   redisplay. */
-
-extern xp_bool xp_is_window_marked (xp_window_id id);
-
-/* If successful returns a superset of the region marked for update in
-   the given window. Use xp_free_region () to release the returned data. */
-
-extern xp_error xp_get_marked_shape (xp_window_id id,
-				     int *ret_nrects, xp_box **ret_rects);
-
-extern void xp_free_shape (int nrects, xp_box *rects);
-
-/* Searches for the first window below ABOVE-ID containing the point X,Y,
-   and returns it's window id in *RET-ID. If no window is found, *RET-ID
-   is set to zero. If ABOVE-ID is zero, finds the topmost window
-   containing the given point. */
-
-extern xp_error xp_find_window (int x, int y, xp_window_id above_id,
-				xp_window_id *ret_id);
-
-/* Returns the current origin and size of the window ID in *BOUNDS-RET if
-   successful. */
-extern xp_error xp_get_window_bounds (xp_window_id id, xp_box *bounds_ret);
-
-
-
-/* Window surface functions. */
-
-/* Create a new VRAM surface on the specified window. If successful,
-   returns the identifier of the new surface in *RET-SID. */
-
-extern xp_error xp_create_surface (xp_window_id id, xp_surface_id *ret_sid);
-
-/* Destroys the specified surface. */
-
-extern xp_error xp_destroy_surface (xp_surface_id sid);
-
-/* Reconfigures the specified surface as defined by MASK and VALUES.
-   Note that specifying XP_DEPTH is an error. */
-
-extern xp_error xp_configure_surface (xp_surface_id sid, unsigned int mask,
-				      const xp_window_changes *values);
-
-/* If successful, places the client identifier of the current process
-   in *RET-CLIENT. */
-
-extern xp_error xp_get_client_id (xp_client_id *ret_client);
-
-/* Given a valid window,surface combination created by the current
-   process, attempts to allow the specified external client access
-   to that surface. If successful, returns two integers in RET-KEY
-   which the client can use to import the surface into their process. */
-
-extern xp_error xp_export_surface (xp_window_id wid, xp_surface_id sid,
-				   xp_client_id client,
-				   unsigned int ret_key[2]);
-
-/* Given a two integer key returned from xp_export_surface (), tries
-   to import the surface into the current process. If successful the
-   local surface identifier is stored in *SID-RET. */
-
-extern xp_error xp_import_surface (const unsigned int key[2],
-				   xp_surface_id *sid_ret);
-
-/* If successful, stores the number of surfaces attached to the
-   specified window in *RET. */
-
-extern xp_error xp_get_window_surface_count (xp_window_id id,
-					     unsigned int *ret);
-
-/* Attaches the CGLContextObj CGL-CTX to the specified surface. */
-
-extern xp_error xp_attach_gl_context (void *cgl_ctx, xp_surface_id sid);
-
-/* Updates the CGLContextObj CGL-CTX to reflect any recent changes to
-   the surface it's attached to. */
-
-extern xp_error xp_update_gl_context (void *cgl_ctx);
-
-
-
-/* Window frame functions. */
-
-/* Possible arguments to xp_frame_get_rect (). */
-
-enum xp_frame_rect_enum {
-    XP_FRAME_RECT_TITLEBAR		= 1,
-    XP_FRAME_RECT_TRACKING		= 2,
-    XP_FRAME_RECT_GROWBOX		= 3,
-};
-
-/* Classes of window frame. */
-
-enum xp_frame_class_enum {
-    XP_FRAME_CLASS_DOCUMENT		= 1 << 0,
-    XP_FRAME_CLASS_DIALOG		= 1 << 1,
-    XP_FRAME_CLASS_MODAL_DIALOG		= 1 << 2,
-    XP_FRAME_CLASS_SYSTEM_MODAL_DIALOG	= 1 << 3,
-    XP_FRAME_CLASS_UTILITY		= 1 << 4,
-    XP_FRAME_CLASS_TOOLBAR		= 1 << 5,
-    XP_FRAME_CLASS_MENU			= 1 << 6,
-    XP_FRAME_CLASS_SPLASH		= 1 << 7,
-    XP_FRAME_CLASS_BORDERLESS		= 1 << 8,
-};
-
-/* Attributes of window frames. */
-
-enum xp_frame_attr_enum {
-    XP_FRAME_ACTIVE			= 0x0001,
-    XP_FRAME_URGENT			= 0x0002,
-    XP_FRAME_TITLE			= 0x0004,
-    XP_FRAME_PRELIGHT			= 0x0008,
-    XP_FRAME_SHADED			= 0x0010,
-    XP_FRAME_CLOSE_BOX			= 0x0100,
-    XP_FRAME_COLLAPSE			= 0x0200,
-    XP_FRAME_ZOOM			= 0x0400,
-    XP_FRAME_ANY_BUTTON			= 0x0700,
-    XP_FRAME_CLOSE_BOX_CLICKED		= 0x0800,
-    XP_FRAME_COLLAPSE_BOX_CLICKED	= 0x1000,
-    XP_FRAME_ZOOM_BOX_CLICKED		= 0x2000,
-    XP_FRAME_ANY_CLICKED		= 0x3800,
-    XP_FRAME_GROW_BOX			= 0x4000,
-};
-
-#define XP_FRAME_ATTR_IS_SET(a,b)	(((a) & (b)) == (b))
-#define XP_FRAME_ATTR_IS_CLICKED(a,m)	((a) & ((m) << 3))
-#define XP_FRAME_ATTR_SET_CLICKED(a,m)	((a) |= ((m) << 3))
-#define XP_FRAME_ATTR_UNSET_CLICKED(a,m) ((a) &= ~((m) << 3))
-
-#define XP_FRAME_POINTER_ATTRS		(XP_FRAME_PRELIGHT		\
-					 | XP_FRAME_ANY_BUTTON		\
-					 | XP_FRAME_ANY_CLICKED)
-
-extern xp_error xp_frame_get_rect (int type, int class, const xp_box *outer,
-				   const xp_box *inner, xp_box *ret);
-extern xp_error xp_frame_hit_test (int class, int x, int y,
-				   const xp_box *outer,
-				   const xp_box *inner, int *ret);
-extern xp_error xp_frame_draw (xp_window_id wid, int class, unsigned int attr,
-			       const xp_box *outer, const xp_box *inner,
-			       unsigned int title_len,
-			       const unsigned char *title_bytes);
-
-
-
-/* Memory manipulation functions. */
-
-enum xp_composite_op_enum {
-    XP_COMPOSITE_SRC = 0,
-    XP_COMPOSITE_OVER,
-};
-
-#define XP_COMPOSITE_FUNCTION(op, src_depth, mask_depth, dest_depth) \
-    (((op) << 24) | ((src_depth) << 16) \
-     | ((mask_depth) << 8) | ((dest_depth) << 0))
-
-#define XP_COMPOSITE_FUNCTION_OP(f)         (((f) >> 24) & 255)
-#define XP_COMPOSITE_FUNCTION_SRC_DEPTH(f)  (((f) >> 16) & 255)
-#define XP_COMPOSITE_FUNCTION_MASK_DEPTH(f) (((f) >>  8) & 255)
-#define XP_COMPOSITE_FUNCTION_DEST_DEPTH(f) (((f) >>  0) & 255)
-
-/* Composite WIDTH by HEIGHT pixels from source and mask to destination
-   using a specified function (if source and destination overlap,
-   undefined behavior results).
-
-   For SRC and DEST, the first element of the array is the color data. If
-   the second element is non-null it implies that there is alpha data
-   (which may be meshed or planar). Data without alpha is assumed to be
-   opaque.
-
-   Passing a null SRC-ROWBYTES pointer implies that the data SRC points
-   to is a single element.
-
-   Operations that are not supported will return XP_BadImplementation. */
-
-extern xp_error xp_composite_pixels (unsigned int width, unsigned int height,
-				     unsigned int function,
-				     void *src[2], unsigned int src_rowbytes[2],
-				     void *mask, unsigned int mask_rowbytes,
-				     void *dest[2], unsigned int dest_rowbytes[2]);
-
-/* Fill HEIGHT rows of data starting at DST. Each row will have WIDTH
-   bytes filled with the 32-bit pattern VALUE. Each row is DST-ROWBYTES
-   wide in total. */
-
-extern void xp_fill_bytes (unsigned int width,
-			   unsigned int height, uint32_t value,
-			   void *dst, unsigned int dst_rowbytes);
-
-/* Copy HEIGHT rows of bytes from SRC to DST. Each row will have WIDTH
-   bytes copied. SRC and DST may overlap, and the right thing will happen. */
-
-extern void xp_copy_bytes (unsigned int width, unsigned int height,
-			   const void *src, unsigned int src_rowbytes,
-			   void *dst, unsigned int dst_rowbytes);
-
-/* Suggestions for the minimum number of bytes or pixels for which it
-   makes sense to use some of the xp_ functions */
-
-extern unsigned int xp_fill_bytes_threshold, xp_copy_bytes_threshold,
-    xp_composite_area_threshold, xp_scroll_area_threshold;
-
-
-#endif /* XPLUGIN_H */
diff --git a/hw/darwin/quartz/xpr/Xquartz.man b/hw/darwin/quartz/xpr/Xquartz.man
deleted file mode 100644
index 37a7f1a..0000000
--- a/hw/darwin/quartz/xpr/Xquartz.man
+++ /dev/null
@@ -1,156 +0,0 @@
-.TH XQUARTZ 1 __vendorversion__
-.SH NAME
-Xquartz \- X window system server for Quartz operating system
-.SH SYNOPSIS
-.B Xquartz
-[ options ] ...
-.SH DESCRIPTION
-.I Xquartz
-is the X window server for Mac OS X provided by Apple.
-.I Xquartz
-runs in parallel with Aqua in rootless mode. In rootless mode, the X
-window system and Mac OS X share your display.  The root window of the
-X11 display is the size of the screen and contains all the other
-windows. The X11 root window is not displayed in rootless mode as Mac
-OS X handles the desktop background.
-.SH OPTIONS
-.PP
-In addition to the normal server options described in the \fIXserver(1)\fP
-manual page, \fIXquartz\fP accepts the following command line switches:
-.TP 8
-.B \-fakebuttons
-Emulates a 3 button mouse using modifier keys. By default, the Command modifier
-is used to emulate button 2 and Option is used for button 3. Thus, clicking the
-first mouse button while holding down Command will act like clicking
-button 2. Holding down Option will simulate button 3.
-.TP 8
-.B \-nofakebuttons
-Do not emulate a 3 button mouse. This is the default.
-.TP 8
-.B "\-fakemouse2 \fImodifiers\fP"
-Change the modifier keys used to emulate the second mouse button. By default,
-Command is used to emulate the second button. Any combination of the following
-modifier names may be used: Shift, Option, Control, Command, Fn. For example,
-.B \-fakemouse2 """Option,Shift""
-will set holding Option, Shift and clicking on button one as equivalent to
-clicking the second mouse button.
-.TP 8
-.B "\-fakemouse3 \fImodifiers\fP"
-Change the modifier keys used to emulate the third mouse button. By default,
-Option is used to emulate the third button. Any combination of the following
-modifier names may be used: Shift, Option, Control, Command, Fn. For example,
-.B \-fakemouse3 """Control,Shift""
-will set holding Control, Shift and clicking on button one as equivalent to
-clicking the third mouse button.
-.TP 8
-.B "\-swapAltMeta"
-Swaps the meaning of the Alt and Meta modifier keys.
-.TP 8
-.B "\-keymap \fIfile\fP"
-On startup \fIXquartz\fP translates a Darwin keymapping into an X keymap.
-The default is to read this keymapping from USA.keymapping. With this option
-the keymapping will be read from \fIfile\fP instead. If the file's path is
-not specified, it will be searched for in Library/Keyboards/ underneath the
-following directories (in order): ~, /, /Network, /System.
-.TP 8
-.B \-nokeymap
-On startup \fIXquartz\fP translates a Darwin keymapping into an X keymap.
-With this option \fIXquartz\fP queries the kernel for the current keymapping
-instead of reading it from a file. This will often fail on newer kernels.
-.TP 8
-.B "\-depth \fIdepth\fP"
-Specifies the color bit depth to use. Currently only 15, and 24 color
-bits per pixel are supported. If not specified, defaults to the depth
-of the main display.
-.SH CUSTOMIZATION
-\fIXquartz\fP can also be customized using the defaults(1) command. The available options are:
-.TP 8
-.B defaults write com.apple.x11 enable_fake_buttons -boolean true
-Equivalent to the \fB-fakebuttons\fP command line option.
-.TP 8
-.B defaults write com.apple.x11 fake_button2 \fImodifiers\fP
-Equivalent to the \fB-fakemouse2\fP option.
-.TP 8
-.B defaults write com.apple.x11 fake_button3 \fImodifiers\fP
-Equivalent to the \fB-fakemouse3\fP option.
-.TP 8
-.B defaults write com.apple.x11 swap_alt_meta -boolean true
-Equivalent to the \fB-swapAltMeta\fP option.
-.TP 8
-.B defaults write com.apple.x11 keymap_file \fIfilename\fP
-Equivalent to the \fB-keymap\fP option.
-.TP 8
-.B defaults write com.apple.x11 no_quit_alert -boolean true
-Disables the alert dialog displayed when attempting to quit X11.
-.TP 8
-.B defaults write com.apple.x11 no_auth -boolean true
-Stops the X server requiring that clients authenticate themselves when
-connecting. See Xsecurity(__miscmansuffix__).
-.TP 8
-.B defaults write com.apple.x11 nolisten_tcp -boolean true
-Prevents the X server accepting remote connections.
-.TP 8
-.B defaults write com.apple.x11 xinit_kills_server -boolean false
-Stops the X server exiting when the xinitrc script terminates.
-.TP 8
-.B defaults write com.apple.x11 fullscreen_hotkeys -boolean false
-Allows system hotkeys to be handled while in X11 fullscreen mode.
-.TP 8
-.B defaults write com.apple.x11 enable_system_beep -boolean false
-Don't use the standard system beep effect for X11 alerts.
-.TP 8
-.B defaults write com.apple.x11 enable_key_equivalents -boolean false
-Disable menu keyboard equivalents while X11 windows are focused.
-.TP 8
-.B defaults write com.apple.x11 depth \fIdepth\fP
-Equivalent to the \fB-depth\fP option.
-.SH "SEE ALSO"
-.PP
-X(__miscmansuffix__), XFree86(1), Xserver(1), xdm(1), xinit(1)
-.PP
-.SH AUTHORS
-XFree86 was originally ported to Mac OS X Server by John Carmack. Dave
-Zarzycki used this as the basis of his port of XFree86 4.0 to Darwin 1.0.
-Torrey T. Lyons improved and integrated this code into the XFree86
-Project's mainline for the 4.0.2 release.
-.PP
-The following members of the XonX Team contributed to the following
-releases (in alphabetical order):
-.TP 4
-XFree86 4.1.0:
-.br
-Rob Braun - Darwin x86 support
-.br
-Torrey T. Lyons - Project Lead
-.br
-Andreas Monitzer - Cocoa version of XDarwin front end
-.br
-Gregory Robert Parker - Original Quartz implementation
-.br
-Christoph Pfisterer - Dynamic shared X libraries
-.br
-Toshimitsu Tanaka - Japanese localization
-.TP 4
-XFree86 4.2.0:
-.br
-Rob Braun - Darwin x86 support
-.br
-Pablo Di Noto - Spanish localization
-.br
-Paul Edens - Dutch localization
-.br
-Kyunghwan Kim - Korean localization
-.br
-Mario Klebsch - Non-US keyboard support
-.br
-Torrey T. Lyons - Project Lead
-.br
-Andreas Monitzer - German localization
-.br
-Patrik Montgomery - Swedish localization
-.br
-Greg Parker - Rootless support
-.br
-Toshimitsu Tanaka - Japanese localization
-.br
-Olivier Verdier - French localization
diff --git a/hw/darwin/quartz/xpr/appledri.c b/hw/darwin/quartz/xpr/appledri.c
deleted file mode 100644
index 95a4439..0000000
--- a/hw/darwin/quartz/xpr/appledri.c
+++ /dev/null
@@ -1,351 +0,0 @@
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-Copyright 2000 VA Linux Systems, Inc.
-Copyright (c) 2002 Apple Computer, Inc.
-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, sub license, 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 PRECISION INSIGHT AND/OR ITS 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 <martin at valinux.com>
- *   Jens Owen <jens at valinux.com>
- *   Rickard E. (Rik) Faith <faith at valinux.com>
- *
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#define NEED_REPLIES
-#define NEED_EVENTS
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "misc.h"
-#include "dixstruct.h"
-#include "extnsionst.h"
-#include "colormapst.h"
-#include "cursorstr.h"
-#include "scrnintstr.h"
-#include "servermd.h"
-#define _APPLEDRI_SERVER_
-#include "appledristr.h"
-#include "swaprep.h"
-#include "dri.h"
-#include "dristruct.h"
-
-static int DRIErrorBase = 0;
-
-static DISPATCH_PROC(ProcAppleDRIDispatch);
-static DISPATCH_PROC(SProcAppleDRIDispatch);
-
-static void AppleDRIResetProc(ExtensionEntry* extEntry);
-
-static unsigned char DRIReqCode = 0;
-static int DRIEventBase = 0;
-
-static void SNotifyEvent(xAppleDRINotifyEvent *from, xAppleDRINotifyEvent *to);
-
-typedef struct _DRIEvent *DRIEventPtr;
-typedef struct _DRIEvent {
-    DRIEventPtr     next;
-    ClientPtr       client;
-    XID             clientResource;
-    unsigned int    mask;
-} DRIEventRec;
-
-
-void
-AppleDRIExtensionInit(void)
-{
-    ExtensionEntry* extEntry;
-
-    if (DRIExtensionInit() &&
-        (extEntry = AddExtension(APPLEDRINAME,
-                                 AppleDRINumberEvents,
-                                 AppleDRINumberErrors,
-                                 ProcAppleDRIDispatch,
-                                 SProcAppleDRIDispatch,
-                                 AppleDRIResetProc,
-                                 StandardMinorOpcode))) {
-        DRIReqCode = (unsigned char)extEntry->base;
-        DRIErrorBase = extEntry->errorBase;
-        DRIEventBase = extEntry->eventBase;
-        EventSwapVector[DRIEventBase] = (EventSwapPtr) SNotifyEvent;
-    }
-}
-
-/*ARGSUSED*/
-static void
-AppleDRIResetProc (
-    ExtensionEntry* extEntry
-)
-{
-    DRIReset();
-}
-
-static int
-ProcAppleDRIQueryVersion(
-    register ClientPtr client
-)
-{
-    xAppleDRIQueryVersionReply rep;
-    register int n;
-
-    REQUEST_SIZE_MATCH(xAppleDRIQueryVersionReq);
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-    rep.majorVersion = APPLE_DRI_MAJOR_VERSION;
-    rep.minorVersion = APPLE_DRI_MINOR_VERSION;
-    rep.patchVersion = APPLE_DRI_PATCH_VERSION;
-    if (client->swapped) {
-        swaps(&rep.sequenceNumber, n);
-        swapl(&rep.length, n);
-    }
-    WriteToClient(client, sizeof(xAppleDRIQueryVersionReply), (char *)&rep);
-    return (client->noClientException);
-}
-
-
-/* surfaces */
-
-static int
-ProcAppleDRIQueryDirectRenderingCapable(
-    register ClientPtr client
-)
-{
-    xAppleDRIQueryDirectRenderingCapableReply rep;
-    Bool isCapable;
-
-    REQUEST(xAppleDRIQueryDirectRenderingCapableReq);
-    REQUEST_SIZE_MATCH(xAppleDRIQueryDirectRenderingCapableReq);
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-
-    if (!DRIQueryDirectRenderingCapable( screenInfo.screens[stuff->screen], 
-                                         &isCapable)) {
-        return BadValue;
-    }
-    rep.isCapable = isCapable;
-
-    if (!LocalClient(client))
-        rep.isCapable = 0;
-
-    WriteToClient(client, 
-        sizeof(xAppleDRIQueryDirectRenderingCapableReply), (char *)&rep);
-    return (client->noClientException);
-}
-
-static int
-ProcAppleDRIAuthConnection(
-    register ClientPtr client
-)
-{
-    xAppleDRIAuthConnectionReply rep;
-    
-    REQUEST(xAppleDRIAuthConnectionReq);
-    REQUEST_SIZE_MATCH(xAppleDRIAuthConnectionReq);
-
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-    rep.authenticated = 1;
-
-    if (!DRIAuthConnection( screenInfo.screens[stuff->screen], stuff->magic)) {
-        ErrorF("Failed to authenticate %u\n", (unsigned int)stuff->magic);
-        rep.authenticated = 0;
-    }
-    WriteToClient(client, sizeof(xAppleDRIAuthConnectionReply), (char *)&rep);
-    return (client->noClientException);
-}
-
-static void surface_notify(
-    void *_arg,
-    void *data
-)
-{
-    DRISurfaceNotifyArg *arg = _arg;
-    int client_index = (int) data;
-    ClientPtr client;
-    xAppleDRINotifyEvent se;
-
-    if (client_index < 0 || client_index >= currentMaxClients)
-        return;
-
-    client = clients[client_index];
-    if (client == NULL || client == serverClient || client->clientGone)
-        return;
-
-    se.type = DRIEventBase + AppleDRISurfaceNotify;
-    se.kind = arg->kind;
-    se.arg = arg->id;
-    se.sequenceNumber = client->sequence;
-    se.time = currentTime.milliseconds;
-    WriteEventsToClient (client, 1, (xEvent *) &se);
-}
-
-static int
-ProcAppleDRICreateSurface(
-    ClientPtr client
-)
-{
-    xAppleDRICreateSurfaceReply rep;
-    DrawablePtr pDrawable;
-    xp_surface_id sid;
-    unsigned int key[2];
-    int rc;
-
-    REQUEST(xAppleDRICreateSurfaceReq);
-    REQUEST_SIZE_MATCH(xAppleDRICreateSurfaceReq);
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-
-    rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
-			   DixReadAccess);
-    if (rc != Success)
-	return rc;
-
-    rep.key_0 = rep.key_1 = rep.uid = 0;
-
-    if (!DRICreateSurface( screenInfo.screens[stuff->screen],
-                           (Drawable)stuff->drawable, pDrawable,
-                           stuff->client_id, &sid, key,
-                           surface_notify, (void *) client->index)) {
-        return BadValue;
-    }
-
-    rep.key_0 = key[0];
-    rep.key_1 = key[1];
-    rep.uid = sid;
-
-    WriteToClient(client, sizeof(xAppleDRICreateSurfaceReply), (char *)&rep);
-    return (client->noClientException);
-}
-
-static int
-ProcAppleDRIDestroySurface(
-    register ClientPtr client
-)
-{
-    REQUEST(xAppleDRIDestroySurfaceReq);
-    DrawablePtr pDrawable;
-    REQUEST_SIZE_MATCH(xAppleDRIDestroySurfaceReq);
-    int rc;
-
-    rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
-			   DixReadAccess);
-    if (rc != Success)
-	return rc;
-
-    if (!DRIDestroySurface( screenInfo.screens[stuff->screen], 
-                            (Drawable)stuff->drawable,
-                            pDrawable, NULL, NULL)) {
-        return BadValue;
-    }
-
-    return (client->noClientException);
-}
-
-
-/* dispatch */
-
-static int
-ProcAppleDRIDispatch (
-    register ClientPtr client
-)
-{
-    REQUEST(xReq);
-
-    switch (stuff->data)
-    {
-    case X_AppleDRIQueryVersion:
-        return ProcAppleDRIQueryVersion(client);
-    case X_AppleDRIQueryDirectRenderingCapable:
-        return ProcAppleDRIQueryDirectRenderingCapable(client);
-    }
-
-    if (!LocalClient(client))
-        return DRIErrorBase + AppleDRIClientNotLocal;
-
-    switch (stuff->data)
-    {
-    case X_AppleDRIAuthConnection:
-        return ProcAppleDRIAuthConnection(client);
-    case X_AppleDRICreateSurface:
-        return ProcAppleDRICreateSurface(client);
-    case X_AppleDRIDestroySurface:
-        return ProcAppleDRIDestroySurface(client);
-    default:
-        return BadRequest;
-    }
-}
-
-static void
-SNotifyEvent(
-    xAppleDRINotifyEvent *from,
-    xAppleDRINotifyEvent *to
-)
-{
-    to->type = from->type;
-    to->kind = from->kind;
-    cpswaps (from->sequenceNumber, to->sequenceNumber);
-    cpswapl (from->time, to->time);
-    cpswapl (from->arg, to->arg);
-}
-
-static int
-SProcAppleDRIQueryVersion(
-    register ClientPtr client
-)
-{
-    register int n;
-    REQUEST(xAppleDRIQueryVersionReq);
-    swaps(&stuff->length, n);
-    return ProcAppleDRIQueryVersion(client);
-}
-
-static int
-SProcAppleDRIDispatch (
-    register ClientPtr client
-)
-{
-    REQUEST(xReq);
-
-    /* It is bound to be non-local when there is byte swapping */
-    if (!LocalClient(client))
-        return DRIErrorBase + AppleDRIClientNotLocal;
-
-    /* only local clients are allowed DRI access */
-    switch (stuff->data)
-    {
-    case X_AppleDRIQueryVersion:
-        return SProcAppleDRIQueryVersion(client);
-    default:
-        return BadRequest;
-    }
-}
diff --git a/hw/darwin/quartz/xpr/appledri.h b/hw/darwin/quartz/xpr/appledri.h
deleted file mode 100644
index c4e43be..0000000
--- a/hw/darwin/quartz/xpr/appledri.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-Copyright 2000 VA Linux Systems, Inc.
-Copyright (c) 2002 Apple Computer, Inc.
-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, sub license, 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 PRECISION INSIGHT AND/OR ITS 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 <martin at valinux.com>
- *   Jens Owen <jens at valinux.com>
- *   Rickard E. (Rik) Faith <faith at valinux.com>
- *
- */
-
-#ifndef _APPLEDRI_H_
-#define _APPLEDRI_H_
-
-#include <X11/Xfuncproto.h>
-
-#define X_AppleDRIQueryVersion			0
-#define X_AppleDRIQueryDirectRenderingCapable	1
-#define X_AppleDRICreateSurface			2
-#define X_AppleDRIDestroySurface		3
-#define X_AppleDRIAuthConnection                4
-/* Requests up to and including 18 were used in a previous version */
-
-/* Events */
-#define AppleDRIObsoleteEvent1		0
-#define AppleDRIObsoleteEvent2		1
-#define AppleDRIObsoleteEvent3		2
-#define AppleDRISurfaceNotify		3
-#define AppleDRINumberEvents		4
-
-/* Errors */
-#define AppleDRIClientNotLocal		0
-#define AppleDRIOperationNotSupported	1
-#define AppleDRINumberErrors		(AppleDRIOperationNotSupported + 1)
-
-/* Kinds of SurfaceNotify events: */
-#define AppleDRISurfaceNotifyChanged	0
-#define AppleDRISurfaceNotifyDestroyed	1
-
-#ifndef _APPLEDRI_SERVER_
-
-typedef struct {
-    int	type;		    /* of event */
-    unsigned long serial;   /* # of last request processed by server */
-    Bool send_event;	    /* true if this came frome a SendEvent request */
-    Display *display;	    /* Display the event was read from */
-    Window window;	    /* window of event */
-    Time time;		    /* server timestamp when event happened */
-    int kind;		    /* subtype of event */
-    int arg;
-} XAppleDRINotifyEvent;
-
-_XFUNCPROTOBEGIN
-
-Bool XAppleDRIQueryExtension (Display *dpy, int *event_base, int *error_base);
-
-Bool XAppleDRIQueryVersion (Display *dpy, int *majorVersion,
-			    int *minorVersion, int *patchVersion);
-
-Bool XAppleDRIQueryDirectRenderingCapable (Display *dpy, int screen,
-					   Bool *isCapable);
-
-void *XAppleDRISetSurfaceNotifyHandler (void (*fun) (Display *dpy,
-						     unsigned uid, int kind));
-
-Bool XAppleDRIAuthConnection (Display *dpy, int screen, unsigned int magic);
-
-Bool XAppleDRICreateSurface (Display *dpy, int screen, Drawable drawable,
-			     unsigned int client_id, unsigned int key[2],
-			     unsigned int* uid);
-
-Bool XAppleDRIDestroySurface (Display *dpy, int screen, Drawable drawable);
-
-Bool XAppleDRISynchronizeSurfaces (Display *dpy);
-
-_XFUNCPROTOEND
-
-#endif /* _APPLEDRI_SERVER_ */
-#endif /* _APPLEDRI_H_ */
-
diff --git a/hw/darwin/quartz/xpr/appledristr.h b/hw/darwin/quartz/xpr/appledristr.h
deleted file mode 100644
index 8649fd3..0000000
--- a/hw/darwin/quartz/xpr/appledristr.h
+++ /dev/null
@@ -1,175 +0,0 @@
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-Copyright 2000 VA Linux Systems, Inc.
-Copyright (c) 2002 Apple Computer, Inc.
-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, sub license, 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 PRECISION INSIGHT AND/OR ITS 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 <martin at valinux.com>
- *   Jens Owen <jens at valinux.com>
- *   Rickard E. (Rik) Fiath <faith at valinux.com>
- *
- */
-
-#ifndef _APPLEDRISTR_H_
-#define _APPLEDRISTR_H_
-
-#include "appledri.h"
-
-#define APPLEDRINAME "Apple-DRI"
-
-#define APPLE_DRI_MAJOR_VERSION	1	/* current version numbers */
-#define APPLE_DRI_MINOR_VERSION	0
-#define APPLE_DRI_PATCH_VERSION	0
-
-typedef struct _AppleDRIQueryVersion {
-    CARD8	reqType;		/* always DRIReqCode */
-    CARD8	driReqType;		/* always X_DRIQueryVersion */
-    CARD16	length B16;
-} xAppleDRIQueryVersionReq;
-#define sz_xAppleDRIQueryVersionReq	4
-
-typedef struct {
-    BYTE	type;			/* X_Reply */
-    BOOL	pad1;
-    CARD16	sequenceNumber B16;
-    CARD32	length B32;
-    CARD16	majorVersion B16;	/* major version of DRI protocol */
-    CARD16	minorVersion B16;	/* minor version of DRI protocol */
-    CARD32	patchVersion B32;       /* patch version of DRI protocol */
-    CARD32	pad3 B32;
-    CARD32	pad4 B32;
-    CARD32	pad5 B32;
-    CARD32	pad6 B32;
-} xAppleDRIQueryVersionReply;
-#define sz_xAppleDRIQueryVersionReply	32
-
-typedef struct _AppleDRIQueryDirectRenderingCapable {
-    CARD8	reqType;		/* always DRIReqCode */
-    CARD8	driReqType;		/* X_DRIQueryDirectRenderingCapable */
-    CARD16	length B16;
-    CARD32	screen B32;
-} xAppleDRIQueryDirectRenderingCapableReq;
-#define sz_xAppleDRIQueryDirectRenderingCapableReq	8
-
-typedef struct {
-    BYTE	type;			/* X_Reply */
-    BOOL	pad1;
-    CARD16	sequenceNumber B16;
-    CARD32	length B32;
-    BOOL	isCapable;
-    BOOL	pad2;
-    BOOL	pad3;
-    BOOL	pad4;
-    CARD32	pad5 B32;
-    CARD32	pad6 B32;
-    CARD32	pad7 B32;
-    CARD32	pad8 B32;
-    CARD32	pad9 B32;
-} xAppleDRIQueryDirectRenderingCapableReply;
-#define sz_xAppleDRIQueryDirectRenderingCapableReply	32
-
-typedef struct _AppleDRIAuthConnection {
-    CARD8	reqType;		/* always DRIReqCode */
-    CARD8	driReqType;		/* always X_DRICloseConnection */
-    CARD16	length B16;
-    CARD32	screen B32;
-    CARD32      magic B32;
-} xAppleDRIAuthConnectionReq;
-#define sz_xAppleDRIAuthConnectionReq	12
-
-typedef struct {
-    BYTE        type;
-    BOOL        pad1;
-    CARD16      sequenceNumber B16;
-    CARD32      length B32;
-    CARD32      authenticated B32;
-    CARD32      pad2 B32;
-    CARD32      pad3 B32;
-    CARD32      pad4 B32;
-    CARD32      pad5 B32;
-    CARD32      pad6 B32;
-} xAppleDRIAuthConnectionReply;
-#define zx_xAppleDRIAuthConnectionReply  32
-
-typedef struct _AppleDRICreateSurface {
-    CARD8	reqType;		/* always DRIReqCode */
-    CARD8	driReqType;		/* always X_DRICreateSurface */
-    CARD16	length B16;
-    CARD32	screen B32;
-    CARD32	drawable B32;
-    CARD32	client_id B32;
-} xAppleDRICreateSurfaceReq;
-#define sz_xAppleDRICreateSurfaceReq	16
-
-typedef struct {
-    BYTE	type;			/* X_Reply */
-    BOOL	pad1;
-    CARD16	sequenceNumber B16;
-    CARD32	length B32;
-    CARD32	key_0 B32;
-    CARD32	key_1 B32;
-    CARD32	uid B32;
-    CARD32	pad4 B32;
-    CARD32	pad5 B32;
-    CARD32	pad6 B32;
-} xAppleDRICreateSurfaceReply;
-#define sz_xAppleDRICreateSurfaceReply	32
-
-typedef struct _AppleDRIDestroySurface {
-    CARD8	reqType;		/* always DRIReqCode */
-    CARD8	driReqType;		/* always X_DRIDestroySurface */
-    CARD16	length B16;
-    CARD32	screen B32;
-    CARD32	drawable B32;
-} xAppleDRIDestroySurfaceReq;
-#define sz_xAppleDRIDestroySurfaceReq	12
-
-typedef struct _AppleDRINotify {
-	BYTE	type;		/* always eventBase + event type */
-	BYTE	kind;
-	CARD16	sequenceNumber B16;
-	Time	time B32;	/* time of change */
-	CARD16	pad1 B16;
-	CARD32	arg B32;
-	CARD32	pad3 B32;
-} xAppleDRINotifyEvent;
-#define sz_xAppleDRINotifyEvent	20
-
-#ifdef _APPLEDRI_SERVER_
-
-void AppleDRISendEvent (
-#if NeedFunctionPrototypes
-    int			/* type */,
-    unsigned int	/* mask */,
-    int			/* which */,
-    int			/* arg */
-#endif
-);
-
-#endif /* _APPLEDRI_SERVER_ */
-#endif /* _APPLEDRISTR_H_ */
diff --git a/hw/darwin/quartz/xpr/dri.c b/hw/darwin/quartz/xpr/dri.c
deleted file mode 100644
index e5591ab..0000000
--- a/hw/darwin/quartz/xpr/dri.c
+++ /dev/null
@@ -1,760 +0,0 @@
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-Copyright 2000 VA Linux Systems, Inc.
-Copyright (c) 2002 Apple Computer, Inc.
-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, sub license, 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 PRECISION INSIGHT AND/OR ITS 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:
- *   Jens Owen <jens at valinux.com>
- *   Rickard E. (Rik) Faith <faith at valinux.com>
- *
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#ifdef XFree86LOADER
-#include "xf86.h"
-#include "xf86_ansic.h"
-#else
-#include <sys/time.h>
-#include <unistd.h>
-#endif
-
-#define NEED_REPLIES
-#define NEED_EVENTS
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "misc.h"
-#include "dixstruct.h"
-#include "extnsionst.h"
-#include "colormapst.h"
-#include "cursorstr.h"
-#include "scrnintstr.h"
-#include "windowstr.h"
-#include "servermd.h"
-#define _APPLEDRI_SERVER_
-#include "appledristr.h"
-#include "swaprep.h"
-#include "dri.h"
-#include "dristruct.h"
-#include "mi.h"
-#include "mipointer.h"
-#include "rootless.h"
-#include "x-hash.h"
-#include "x-hook.h"
-
-#include <AvailabilityMacros.h>
-
-static int DRIScreenPrivIndex = -1;
-static int DRIWindowPrivIndex = -1;
-static int DRIPixmapPrivIndex = -1;
-
-static RESTYPE DRIDrawablePrivResType;
-
-static x_hash_table *surface_hash;      /* maps surface ids -> drawablePrivs */
-
-/* FIXME: don't hardcode this? */
-#define CG_INFO_FILE "/System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreGraphics.framework/Resources/Info-macos.plist"
-
-/* Corresponds to SU Jaguar Green */
-#define CG_REQUIRED_MAJOR 1
-#define CG_REQUIRED_MINOR 157
-#define CG_REQUIRED_MICRO 11
-
-/* Returns version as major.minor.micro in 10.10.10 fixed form */
-static unsigned int
-get_cg_version (void)
-{
-    static unsigned int version;
-
-    FILE *fh;
-    char *ptr;
-
-    if (version != 0)
-        return version;
-
-    /* I tried CFBundleGetVersion, but it returns zero, so.. */
-
-    fh = fopen (CG_INFO_FILE, "r");
-    if (fh != NULL)
-    {
-        char buf[256];
-
-        while (fgets (buf, sizeof (buf), fh) != NULL)
-        {
-            unsigned char c;
-
-            if (!strstr (buf, "<key>CFBundleShortVersionString</key>")
-                || fgets (buf, sizeof (buf), fh) == NULL)
-            {
-                continue;
-            }
-
-            ptr = strstr (buf, "<string>");
-            if (ptr == NULL)
-                continue;
-
-            ptr += strlen ("<string>");
-
-            /* Now PTR points to "MAJOR.MINOR.MICRO". */
-
-            version = 0;
-
-        again:
-            switch ((c = *ptr++))
-            {
-            case '.':
-                version = version * 1024;
-                goto again;
-
-            case '0': case '1': case '2': case '3': case '4':
-            case '5': case '6': case '7': case '8': case '9':
-                version = ((version & ~0x3ff)
-                          + (version & 0x3ff) * 10 + (c - '0'));
-                goto again;
-            }
-            break;
-        }
-
-        fclose (fh);
-    }
-
-    return version;
-}
-
-static Bool
-test_cg_version (unsigned int major, unsigned int minor, unsigned int micro)
-{
-    unsigned int cg_ver = get_cg_version ();
-
-    unsigned int cg_major = (cg_ver >> 20) & 0x3ff;
-    unsigned int cg_minor = (cg_ver >> 10) & 0x3ff;
-    unsigned int cg_micro =  cg_ver        & 0x3ff;
-
-    if (cg_major > major)
-        return TRUE;
-    else if (cg_major < major)
-        return FALSE;
-
-    /* cg_major == major */
-
-    if (cg_minor > minor)
-        return TRUE;
-    else if (cg_minor < minor)
-        return FALSE;
-
-    /* cg_minor == minor */
-
-    if (cg_micro < micro)
-        return FALSE;
-
-    return TRUE;
-}
-
-Bool
-DRIScreenInit(ScreenPtr pScreen)
-{
-    DRIScreenPrivPtr    pDRIPriv;
-    int                 i;
-
-    pDRIPriv = (DRIScreenPrivPtr) xcalloc(1, sizeof(DRIScreenPrivRec));
-    if (!pDRIPriv) {
-        pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
-        return FALSE;
-    }
-
-    pScreen->devPrivates[DRIScreenPrivIndex].ptr = (pointer) pDRIPriv;
-    pDRIPriv->directRenderingSupport = TRUE;
-    pDRIPriv->nrWindows = 0;
-
-    /* Need recent cg for window access update */
-    if (!test_cg_version (CG_REQUIRED_MAJOR,
-                          CG_REQUIRED_MINOR,
-                          CG_REQUIRED_MICRO))
-    {
-        ErrorF ("[DRI] disabled direct rendering; requires CoreGraphics %d.%d.%d\n",
-                CG_REQUIRED_MAJOR, CG_REQUIRED_MINOR, CG_REQUIRED_MICRO);
-
-        pDRIPriv->directRenderingSupport = FALSE;
-
-        /* Note we don't nuke the dri private, since we need it for
-           managing indirect surfaces. */
-    }
-
-    /* Initialize drawable tables */
-    for (i = 0; i < DRI_MAX_DRAWABLES; i++) {
-        pDRIPriv->DRIDrawables[i] = NULL;
-    }
-
-    return TRUE;
-}
-
-Bool
-DRIFinishScreenInit(ScreenPtr pScreen)
-{
-    DRIScreenPrivPtr  pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
-    /* Allocate zero sized private area for each window. Should a window
-     * become a DRI window, we'll hang a DRIWindowPrivateRec off of this
-     * private index.
-     */
-    if (!AllocateWindowPrivate(pScreen, DRIWindowPrivIndex, 0))
-        return FALSE;
-
-    /* Wrap DRI support */
-    pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree;
-    pScreen->ValidateTree = DRIValidateTree;
-
-    pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree;
-    pScreen->PostValidateTree = DRIPostValidateTree;
-
-    pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures;
-    pScreen->WindowExposures = DRIWindowExposures;
-
-    pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow;
-    pScreen->CopyWindow = DRICopyWindow;
-
-    pDRIPriv->wrap.ClipNotify = pScreen->ClipNotify;
-    pScreen->ClipNotify = DRIClipNotify;
-
-    //    ErrorF("[DRI] screen %d installation complete\n", pScreen->myNum);
-
-    return TRUE;
-}
-
-void
-DRICloseScreen(ScreenPtr pScreen)
-{
-    DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
-    if (pDRIPriv && pDRIPriv->directRenderingSupport) {
-        xfree(pDRIPriv);
-        pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
-    }
-}
-
-Bool
-DRIExtensionInit(void)
-{
-    static unsigned long DRIGeneration = 0;
-
-    if (DRIGeneration != serverGeneration) {
-        if ((DRIScreenPrivIndex = AllocateScreenPrivateIndex()) < 0)
-            return FALSE;
-        DRIGeneration = serverGeneration;
-    }
-
-    /*
-     * Allocate a window private index with a zero sized private area for
-     * each window, then should a window become a DRI window, we'll hang
-     * a DRIWindowPrivateRec off of this private index. Do same for pixmaps.
-     */
-    if ((DRIWindowPrivIndex = AllocateWindowPrivateIndex()) < 0)
-        return FALSE;
-    if ((DRIPixmapPrivIndex = AllocatePixmapPrivateIndex()) < 0)
-        return FALSE;
-
-    DRIDrawablePrivResType = CreateNewResourceType(DRIDrawablePrivDelete);
-
-    return TRUE;
-}
-
-void
-DRIReset(void)
-{
-    /*
-     * This stub routine is called when the X Server recycles, resources
-     * allocated by DRIExtensionInit need to be managed here.
-     *
-     * Currently this routine is a stub because all the interesting resources
-     * are managed via the screen init process.
-     */
-}
-
-Bool
-DRIQueryDirectRenderingCapable(ScreenPtr pScreen, Bool* isCapable)
-{
-    DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
-    if (pDRIPriv)
-        *isCapable = pDRIPriv->directRenderingSupport;
-    else
-        *isCapable = FALSE;
-
-    return TRUE;
-}
-
-Bool
-DRIAuthConnection(ScreenPtr pScreen, unsigned int magic)
-{
-#if 0
-    /* FIXME: something? */
-
-    DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
-    if (drmAuthMagic(pDRIPriv->drmFD, magic)) return FALSE;
-#endif
-    return TRUE;
-}
-
-static void
-DRIUpdateSurface(DRIDrawablePrivPtr pDRIDrawablePriv, DrawablePtr pDraw)
-{
-    xp_window_changes wc;
-    unsigned int flags = 0;
-
-    if (pDRIDrawablePriv->sid == 0)
-        return;
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
-    wc.depth = (pDraw->bitsPerPixel == 32 ? XP_DEPTH_ARGB8888
-                : pDraw->bitsPerPixel == 16 ? XP_DEPTH_RGB555 : XP_DEPTH_NIL);
-    if (wc.depth != XP_DEPTH_NIL)
-        flags |= XP_DEPTH;
-#endif
-
-    if (pDraw->type == DRAWABLE_WINDOW) {
-        WindowPtr pWin = (WindowPtr) pDraw;
-        WindowPtr pTopWin = TopLevelParent(pWin);
-
-        wc.x = pWin->drawable.x - (pTopWin->drawable.x - pTopWin->borderWidth);
-        wc.y = pWin->drawable.y - (pTopWin->drawable.y - pTopWin->borderWidth);
-        wc.width = pWin->drawable.width + 2 * pWin->borderWidth;
-        wc.height = pWin->drawable.height + 2 * pWin->borderWidth;
-        wc.bit_gravity = XP_GRAVITY_NONE;
-
-        wc.shape_nrects = REGION_NUM_RECTS(&pWin->clipList);
-        wc.shape_rects = REGION_RECTS(&pWin->clipList);
-        wc.shape_tx = - (pTopWin->drawable.x - pTopWin->borderWidth);
-        wc.shape_ty = - (pTopWin->drawable.y - pTopWin->borderWidth);
-
-        flags |= XP_BOUNDS | XP_SHAPE;
-
-    } else if (pDraw->type == DRAWABLE_PIXMAP) {
-        wc.x = 0;
-        wc.y = 0;
-        wc.width = pDraw->width;
-        wc.height = pDraw->height;
-        wc.bit_gravity = XP_GRAVITY_NONE;
-        flags |= XP_BOUNDS;
-    }
-
-    xp_configure_surface(pDRIDrawablePriv->sid, flags, &wc);
-}
-
-Bool
-DRICreateSurface(ScreenPtr pScreen, Drawable id,
-                 DrawablePtr pDrawable, xp_client_id client_id,
-                 xp_surface_id *surface_id, unsigned int ret_key[2],
-                 void (*notify) (void *arg, void *data), void *notify_data)
-{
-    DRIScreenPrivPtr    pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-    DRIDrawablePrivPtr  pDRIDrawablePriv;
-    xp_window_id        wid = 0;
-
-    if (pDrawable->type == DRAWABLE_WINDOW) {
-        WindowPtr pWin = (WindowPtr)pDrawable;
-
-        pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
-        if (pDRIDrawablePriv == NULL) {
-            xp_error err;
-            xp_window_changes wc;
-
-            /* allocate a DRI Window Private record */
-            if (!(pDRIDrawablePriv = xalloc(sizeof(DRIDrawablePrivRec)))) {
-                return FALSE;
-            }
-
-            pDRIDrawablePriv->pDraw = pDrawable;
-            pDRIDrawablePriv->pScreen = pScreen;
-            pDRIDrawablePriv->refCount = 0;
-            pDRIDrawablePriv->drawableIndex = -1;
-            pDRIDrawablePriv->notifiers = NULL;
-
-            /* find the physical window */
-            wid = (xp_window_id) RootlessFrameForWindow(pWin, TRUE);
-            if (wid == 0) {
-                xfree(pDRIDrawablePriv);
-                return FALSE;
-            }
-
-            /* allocate the physical surface */
-            err = xp_create_surface(wid, &pDRIDrawablePriv->sid);
-            if (err != Success) {
-                xfree(pDRIDrawablePriv);
-                return FALSE;
-            }
-
-            /* Make it visible */
-            wc.stack_mode = XP_MAPPED_ABOVE;
-            wc.sibling = 0;
-            err = xp_configure_surface(pDRIDrawablePriv->sid, XP_STACKING, &wc);
-            if (err != Success)
-            {
-                xp_destroy_surface(pDRIDrawablePriv->sid);
-                xfree(pDRIDrawablePriv);
-                return FALSE;
-            }
-
-            /* save private off of preallocated index */
-            pWin->devPrivates[DRIWindowPrivIndex].ptr = (pointer)pDRIDrawablePriv;
-        }
-    }
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
-    else if (pDrawable->type == DRAWABLE_PIXMAP) {
-        PixmapPtr pPix = (PixmapPtr)pDrawable;
-
-        pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix);
-        if (pDRIDrawablePriv == NULL) {
-            xp_error err;
-
-            /* allocate a DRI Window Private record */
-            if (!(pDRIDrawablePriv = xcalloc(1, sizeof(DRIDrawablePrivRec)))) {
-                return FALSE;
-            }
-
-            pDRIDrawablePriv->pDraw = pDrawable;
-            pDRIDrawablePriv->pScreen = pScreen;
-            pDRIDrawablePriv->refCount = 0;
-            pDRIDrawablePriv->drawableIndex = -1;
-            pDRIDrawablePriv->notifiers = NULL;
-
-            /* Passing a null window id to Xplugin in 10.3+ asks for
-               an accelerated offscreen surface. */
-
-            err = xp_create_surface(0, &pDRIDrawablePriv->sid);
-            if (err != Success) {
-                xfree(pDRIDrawablePriv);
-                return FALSE;
-            }
-
-            /* save private off of preallocated index */
-            pPix->devPrivates[DRIPixmapPrivIndex].ptr = (pointer)pDRIDrawablePriv;
-        }
-    }
-#endif
-
-    else { /* for GLX 1.3, a PBuffer */
-        /* NOT_DONE */
-        return FALSE;
-    }
-
-    /* Finish initialization of new surfaces */
-    if (pDRIDrawablePriv->refCount == 0) {
-        unsigned int key[2] = {0};
-        xp_error err;
-
-        /* try to give the client access to the surface */
-        if (client_id != 0 && wid != 0)
-        {
-            err = xp_export_surface(wid, pDRIDrawablePriv->sid,
-                                    client_id, key);
-            if (err != Success) {
-                xp_destroy_surface(pDRIDrawablePriv->sid);
-                xfree(pDRIDrawablePriv);
-                return FALSE;
-            }
-        }
-
-        pDRIDrawablePriv->key[0] = key[0];
-        pDRIDrawablePriv->key[1] = key[1];
-
-        ++pDRIPriv->nrWindows;
-
-        /* and stash it by surface id */
-        if (surface_hash == NULL)
-            surface_hash = x_hash_table_new(NULL, NULL, NULL, NULL);
-        x_hash_table_insert(surface_hash,
-                            (void *) pDRIDrawablePriv->sid, pDRIDrawablePriv);
-
-        /* track this in case this window is destroyed */
-        AddResource(id, DRIDrawablePrivResType, (pointer)pDrawable);
-
-        /* Initialize shape */
-        DRIUpdateSurface(pDRIDrawablePriv, pDrawable);
-    }
-
-    pDRIDrawablePriv->refCount++;
-
-    *surface_id = pDRIDrawablePriv->sid;
-
-    if (ret_key != NULL) {
-        ret_key[0] = pDRIDrawablePriv->key[0];
-        ret_key[1] = pDRIDrawablePriv->key[1];
-    }
-
-    if (notify != NULL) {
-        pDRIDrawablePriv->notifiers = x_hook_add(pDRIDrawablePriv->notifiers,
-                                                 notify, notify_data);
-    }
-
-    return TRUE;
-}
-
-Bool
-DRIDestroySurface(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable,
-                  void (*notify) (void *, void *), void *notify_data)
-{
-    DRIDrawablePrivPtr  pDRIDrawablePriv;
-
-    if (pDrawable->type == DRAWABLE_WINDOW) {
-        pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW((WindowPtr)pDrawable);
-    } else if (pDrawable->type == DRAWABLE_PIXMAP) {
-        pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP((PixmapPtr)pDrawable);
-    } else {
-        return FALSE;
-    }
-
-    if (pDRIDrawablePriv != NULL) {
-        if (notify != NULL) {
-            pDRIDrawablePriv->notifiers = x_hook_remove(pDRIDrawablePriv->notifiers,
-                                                        notify, notify_data);
-        }
-        if (--pDRIDrawablePriv->refCount <= 0) {
-            /* This calls back to DRIDrawablePrivDelete
-               which frees the private area */
-            FreeResourceByType(id, DRIDrawablePrivResType, FALSE);
-        }
-    }
-
-    return TRUE;
-}
-
-Bool
-DRIDrawablePrivDelete(pointer pResource, XID id)
-{
-    DrawablePtr         pDrawable = (DrawablePtr)pResource;
-    DRIScreenPrivPtr    pDRIPriv = DRI_SCREEN_PRIV(pDrawable->pScreen);
-    DRIDrawablePrivPtr  pDRIDrawablePriv = NULL;
-    WindowPtr           pWin = NULL;
-    PixmapPtr           pPix = NULL;
-
-    if (pDrawable->type == DRAWABLE_WINDOW) {
-        pWin = (WindowPtr)pDrawable;
-        pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
-    } else if (pDrawable->type == DRAWABLE_PIXMAP) {
-        pPix = (PixmapPtr)pDrawable;
-        pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix);
-    }
-
-    if (pDRIDrawablePriv == NULL)
-        return FALSE;
-
-    if (pDRIDrawablePriv->drawableIndex != -1) {
-        /* release drawable table entry */
-        pDRIPriv->DRIDrawables[pDRIDrawablePriv->drawableIndex] = NULL;
-    }
-
-    if (pDRIDrawablePriv->sid != 0) {
-        xp_destroy_surface(pDRIDrawablePriv->sid);
-        x_hash_table_remove(surface_hash, (void *) pDRIDrawablePriv->sid);
-    }
-
-    if (pDRIDrawablePriv->notifiers != NULL)
-        x_hook_free(pDRIDrawablePriv->notifiers);
-
-    xfree(pDRIDrawablePriv);
-
-    if (pDrawable->type == DRAWABLE_WINDOW) {
-        pWin->devPrivates[DRIWindowPrivIndex].ptr = NULL;
-    } else if (pDrawable->type == DRAWABLE_PIXMAP) {
-        pPix->devPrivates[DRIPixmapPrivIndex].ptr = NULL;
-    }
-
-    --pDRIPriv->nrWindows;
-
-    return TRUE;
-}
-
-void
-DRIWindowExposures(WindowPtr pWin, RegionPtr prgn, RegionPtr bsreg)
-{
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-    DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-    DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
-
-    if (pDRIDrawablePriv) {
-        /* FIXME: something? */
-    }
-
-    pScreen->WindowExposures = pDRIPriv->wrap.WindowExposures;
-
-    (*pScreen->WindowExposures)(pWin, prgn, bsreg);
-
-    pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures;
-    pScreen->WindowExposures = DRIWindowExposures;
-}
-
-void
-DRICopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
-{
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-    DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-    DRIDrawablePrivPtr pDRIDrawablePriv;
-
-    if (pDRIPriv->nrWindows > 0) {
-       pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
-       if (pDRIDrawablePriv != NULL) {
-            DRIUpdateSurface(pDRIDrawablePriv, &pWin->drawable);
-       }
-    }
-
-    /* unwrap */
-    pScreen->CopyWindow = pDRIPriv->wrap.CopyWindow;
-
-    /* call lower layers */
-    (*pScreen->CopyWindow)(pWin, ptOldOrg, prgnSrc);
-
-    /* rewrap */
-    pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow;
-    pScreen->CopyWindow = DRICopyWindow;
-}
-
-int
-DRIValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
-{
-    ScreenPtr pScreen = pParent->drawable.pScreen;
-    DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-    int returnValue;
-
-    /* unwrap */
-    pScreen->ValidateTree = pDRIPriv->wrap.ValidateTree;
-
-    /* call lower layers */
-    returnValue = (*pScreen->ValidateTree)(pParent, pChild, kind);
-
-    /* rewrap */
-    pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree;
-    pScreen->ValidateTree = DRIValidateTree;
-
-    return returnValue;
-}
-
-void
-DRIPostValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
-{
-    ScreenPtr pScreen;
-    DRIScreenPrivPtr pDRIPriv;
-
-    if (pParent) {
-        pScreen = pParent->drawable.pScreen;
-    } else {
-        pScreen = pChild->drawable.pScreen;
-    }
-    pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
-    if (pDRIPriv->wrap.PostValidateTree) {
-        /* unwrap */
-        pScreen->PostValidateTree = pDRIPriv->wrap.PostValidateTree;
-
-        /* call lower layers */
-        (*pScreen->PostValidateTree)(pParent, pChild, kind);
-
-        /* rewrap */
-        pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree;
-        pScreen->PostValidateTree = DRIPostValidateTree;
-    }
-}
-
-void
-DRIClipNotify(WindowPtr pWin, int dx, int dy)
-{
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-    DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-    DRIDrawablePrivPtr  pDRIDrawablePriv;
-
-    if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) {
-        DRIUpdateSurface(pDRIDrawablePriv, &pWin->drawable);
-    }
-
-    if (pDRIPriv->wrap.ClipNotify) {
-        pScreen->ClipNotify = pDRIPriv->wrap.ClipNotify;
-
-        (*pScreen->ClipNotify)(pWin, dx, dy);
-
-        pDRIPriv->wrap.ClipNotify = pScreen->ClipNotify;
-        pScreen->ClipNotify = DRIClipNotify;
-    }
-}
-
-/* This lets us get at the unwrapped functions so that they can correctly
- * call the lower level functions, and choose whether they will be
- * called at every level of recursion (eg in validatetree).
- */
-DRIWrappedFuncsRec *
-DRIGetWrappedFuncs(ScreenPtr pScreen)
-{
-    return &(DRI_SCREEN_PRIV(pScreen)->wrap);
-}
-
-void
-DRIQueryVersion(int *majorVersion,
-                int *minorVersion,
-                int *patchVersion)
-{
-    *majorVersion = APPLE_DRI_MAJOR_VERSION;
-    *minorVersion = APPLE_DRI_MINOR_VERSION;
-    *patchVersion = APPLE_DRI_PATCH_VERSION;
-}
-
-void
-DRISurfaceNotify(xp_surface_id id, int kind)
-{
-    DRIDrawablePrivPtr pDRIDrawablePriv = NULL;
-    DRISurfaceNotifyArg arg;
-
-    arg.id = id;
-    arg.kind = kind;
-
-    if (surface_hash != NULL)
-    {
-        pDRIDrawablePriv = x_hash_table_lookup(surface_hash,
-                                               (void *) id, NULL);
-    }
-
-    if (pDRIDrawablePriv == NULL)
-        return;
-
-    if (kind == AppleDRISurfaceNotifyDestroyed)
-    {
-        pDRIDrawablePriv->sid = 0;
-        x_hash_table_remove(surface_hash, (void *) id);
-    }
-
-    x_hook_run(pDRIDrawablePriv->notifiers, &arg);
-
-    if (kind == AppleDRISurfaceNotifyDestroyed)
-    {
-        /* Kill off the handle. */
-
-        FreeResourceByType(pDRIDrawablePriv->pDraw->id,
-                           DRIDrawablePrivResType, FALSE);
-    }
-}
diff --git a/hw/darwin/quartz/xpr/dri.h b/hw/darwin/quartz/xpr/dri.h
deleted file mode 100644
index cf2638a..0000000
--- a/hw/darwin/quartz/xpr/dri.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-Copyright (c) 2002 Apple Computer, Inc.
-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, sub license, 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 PRECISION INSIGHT AND/OR ITS 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:
- *   Jens Owen <jens at precisioninsight.com>
- *
- */
-
-/* Prototypes for AppleDRI functions */
-
-#ifndef _DRI_H_
-#define _DRI_H_
-
-#include <X11/Xdefs.h>
-#include "scrnintstr.h"
-#define _APPLEDRI_SERVER_
-#include "appledri.h"
-#include "Xplugin.h"
-
-typedef void (*ClipNotifyPtr)( WindowPtr, int, int );
-
-
-/*
- * These functions can be wrapped by the DRI.  Each of these have
- * generic default funcs (initialized in DRICreateInfoRec) and can be
- * overridden by the driver in its [driver]DRIScreenInit function.
- */
-typedef struct {
-    WindowExposuresProcPtr       WindowExposures;
-    CopyWindowProcPtr            CopyWindow;
-    ValidateTreeProcPtr          ValidateTree;
-    PostValidateTreeProcPtr      PostValidateTree;
-    ClipNotifyProcPtr            ClipNotify;
-} DRIWrappedFuncsRec, *DRIWrappedFuncsPtr;
-
-typedef struct {
-    xp_surface_id id;
-    int kind;
-} DRISurfaceNotifyArg;
-
-extern Bool DRIScreenInit(ScreenPtr pScreen);
-
-extern Bool DRIFinishScreenInit(ScreenPtr pScreen);
-
-extern void DRICloseScreen(ScreenPtr pScreen);
-
-extern Bool DRIExtensionInit(void);
-
-extern void DRIReset(void);
-
-extern Bool DRIQueryDirectRenderingCapable(ScreenPtr pScreen,
-                                           Bool *isCapable);
-
-extern Bool DRIAuthConnection(ScreenPtr pScreen, unsigned int magic);
-
-extern Bool DRICreateSurface(ScreenPtr pScreen,
-                             Drawable id,
-                             DrawablePtr pDrawable,
-                             xp_client_id client_id,
-                             xp_surface_id *surface_id,
-                             unsigned int key[2],
-                             void (*notify) (void *arg, void *data),
-                             void *notify_data);
-
-extern Bool DRIDestroySurface(ScreenPtr pScreen,
-                             Drawable id,
-                             DrawablePtr pDrawable,
-                             void (*notify) (void *arg, void *data),
-                             void *notify_data);
-
-extern Bool DRIDrawablePrivDelete(pointer pResource,
-                                  XID id);
-
-extern DRIWrappedFuncsRec *DRIGetWrappedFuncs(ScreenPtr pScreen);
-
-extern void DRICopyWindow(WindowPtr pWin,
-                          DDXPointRec ptOldOrg,
-                          RegionPtr prgnSrc);
-
-extern int DRIValidateTree(WindowPtr pParent,
-                           WindowPtr pChild,
-                           VTKind    kind);
-
-extern void DRIPostValidateTree(WindowPtr pParent,
-                                WindowPtr pChild,
-                                VTKind    kind);
-
-extern void DRIClipNotify(WindowPtr pWin,
-                          int dx,
-                          int dy);
-
-extern void DRIWindowExposures(WindowPtr pWin,
-                              RegionPtr prgn,
-                              RegionPtr bsreg);
-
-extern void DRISurfaceNotify (xp_surface_id id, int kind);
-
-extern void DRIQueryVersion(int *majorVersion,
-                            int *minorVersion,
-                            int *patchVersion);
-
-#endif
diff --git a/hw/darwin/quartz/xpr/dristruct.h b/hw/darwin/quartz/xpr/dristruct.h
deleted file mode 100644
index 9a3d01c..0000000
--- a/hw/darwin/quartz/xpr/dristruct.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-Copyright (c) 2002 Apple Computer, Inc.
-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, sub license, 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 PRECISION INSIGHT AND/OR ITS 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:
- *   Jens Owen <jens at precisioninsight.com>
- *
- */
-
-#ifndef DRI_STRUCT_H
-#define DRI_STRUCT_H
-
-#include "dri.h"
-#include "x-list.h"
-
-#define DRI_MAX_DRAWABLES 256
-
-#define DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin) \
-    ((DRIWindowPrivIndex < 0) ? \
-     NULL : \
-     ((DRIDrawablePrivPtr)((pWin)->devPrivates[DRIWindowPrivIndex].ptr)))
-
-#define DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix) \
-    ((DRIPixmapPrivIndex < 0) ? \
-     NULL : \
-     ((DRIDrawablePrivPtr)((pPix)->devPrivates[DRIPixmapPrivIndex].ptr)))
-
-typedef struct _DRIDrawablePrivRec
-{
-    xp_surface_id   sid;
-    int             drawableIndex;
-    DrawablePtr     pDraw;
-    ScreenPtr       pScreen;
-    int             refCount;
-    unsigned int    key[2];
-    x_list          *notifiers;     /* list of (FUN . DATA) */
-} DRIDrawablePrivRec, *DRIDrawablePrivPtr;
-
-#define DRI_SCREEN_PRIV(pScreen) \
-    ((DRIScreenPrivIndex < 0) ? \
-     NULL : \
-     ((DRIScreenPrivPtr)((pScreen)->devPrivates[DRIScreenPrivIndex].ptr)))
-
-#define DRI_SCREEN_PRIV_FROM_INDEX(screenIndex) ((DRIScreenPrivPtr) \
-    (screenInfo.screens[screenIndex]->devPrivates[DRIScreenPrivIndex].ptr))
-
-
-typedef struct _DRIScreenPrivRec
-{
-    Bool                directRenderingSupport;
-    int                 nrWindows;
-    DRIWrappedFuncsRec  wrap;
-    DrawablePtr         DRIDrawables[DRI_MAX_DRAWABLES];
-} DRIScreenPrivRec, *DRIScreenPrivPtr;
-
-#endif /* DRI_STRUCT_H */
diff --git a/hw/darwin/quartz/xpr/x-hash.c b/hw/darwin/quartz/xpr/x-hash.c
deleted file mode 100644
index 55d28ba..0000000
--- a/hw/darwin/quartz/xpr/x-hash.c
+++ /dev/null
@@ -1,343 +0,0 @@
-/* x-hash.c - basic hash tables
-
-   Copyright (c) 2002 Apple Computer, Inc. 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 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. */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "x-hash.h"
-#include "x-list.h"
-#include <stdlib.h>
-#include <assert.h>
-
-struct x_hash_table_struct {
-    unsigned int bucket_index;
-    unsigned int total_keys;
-    x_list **buckets;
-
-    x_hash_fun *hash_key;
-    x_compare_fun *compare_keys;
-    x_destroy_fun *destroy_key;
-    x_destroy_fun *destroy_value;
-};
-
-#define ITEM_NEW(k, v) X_PFX (list_prepend) ((x_list *) (k), v)
-#define ITEM_FREE(i) X_PFX (list_free_1) (i)
-#define ITEM_KEY(i) ((void *) (i)->next)
-#define ITEM_VALUE(i) ((i)->data)
-
-#define SPLIT_THRESHOLD_FACTOR 2
-
-/* http://planetmath.org/?op=getobj&from=objects&name=GoodHashTablePrimes */
-static const unsigned int bucket_sizes[] = {
-    29, 53, 97, 193, 389, 769, 1543, 3079, 6151, 12289, 24593, 49157,
-    98317, 196613, 393241, 786433, 1572869, 3145739, 6291469, 12582917,
-    25165843, 50331653, 100663319, 201326611, 402653189, 805306457,
-    1610612741
-};
-
-#define N_BUCKET_SIZES (sizeof (bucket_sizes) / sizeof (bucket_sizes[0]))
-
-static inline unsigned int
-hash_table_total_buckets (x_hash_table *h)
-{
-    return bucket_sizes[h->bucket_index];
-}
-
-static inline void
-hash_table_destroy_item (x_hash_table *h, void *k, void *v)
-{
-    if (h->destroy_key != 0)
-        (*h->destroy_key) (k);
-
-    if (h->destroy_value != 0)
-        (*h->destroy_value) (v);
-}
-
-static inline unsigned int
-hash_table_hash_key (x_hash_table *h, void *k)
-{
-    if (h->hash_key != 0)
-        return (*h->hash_key) (k);
-    else
-        return (unsigned int) k;
-}
-
-static inline int
-hash_table_compare_keys (x_hash_table *h, void *k1, void *k2)
-{
-    if (h->compare_keys == 0)
-        return k1 == k2;
-    else
-        return (*h->compare_keys) (k1, k2) == 0;
-}
-
-static void
-hash_table_split (x_hash_table *h)
-{
-    x_list **new, **old;
-    x_list *node, *item, *next;
-    int new_size, old_size;
-    unsigned int b;
-    int i;
-
-    if (h->bucket_index == N_BUCKET_SIZES - 1)
-        return;
-
-    old_size = hash_table_total_buckets (h);
-    old = h->buckets;
-
-    h->bucket_index++;
-
-    new_size = hash_table_total_buckets (h);
-    new = calloc (new_size, sizeof (x_list *));
-
-    if (new == 0)
-    {
-        h->bucket_index--;
-        return;
-    }
-
-    for (i = 0; i < old_size; i++)
-    {
-        for (node = old[i]; node != 0; node = next)
-        {
-            next = node->next;
-            item = node->data;
-
-            b = hash_table_hash_key (h, ITEM_KEY (item)) % new_size;
-
-            node->next = new[b];
-            new[b] = node;
-        }
-    }
-
-    h->buckets = new;
-    free (old);
-}
-
-X_EXTERN x_hash_table *
-X_PFX (hash_table_new) (x_hash_fun *hash,
-                        x_compare_fun *compare,
-                        x_destroy_fun *key_destroy,
-                        x_destroy_fun *value_destroy)
-{
-    x_hash_table *h;
-
-    h = calloc (1, sizeof (x_hash_table));
-    if (h == 0)
-        return 0;
-
-    h->bucket_index = 0;
-    h->buckets = calloc (hash_table_total_buckets (h), sizeof (x_list *));
-
-    if (h->buckets == 0)
-    {
-        free (h);
-        return 0;
-    }
-    
-    h->hash_key = hash;
-    h->compare_keys = compare;
-    h->destroy_key = key_destroy;
-    h->destroy_value = value_destroy;
-
-    return h;
-}
-
-X_EXTERN void
-X_PFX (hash_table_free) (x_hash_table *h)
-{
-    int n, i;
-    x_list *node, *item;
-
-    assert (h != NULL);
-
-    n = hash_table_total_buckets (h);
-
-    for (i = 0; i < n; i++)
-    {
-        for (node = h->buckets[i]; node != 0; node = node->next)
-        {
-            item = node->data;
-            hash_table_destroy_item (h, ITEM_KEY (item), ITEM_VALUE (item));
-            ITEM_FREE (item);
-        }
-        X_PFX (list_free) (h->buckets[i]);
-    }
-
-    free (h->buckets);
-    free (h);
-}
-
-X_EXTERN unsigned int
-X_PFX (hash_table_size) (x_hash_table *h)
-{
-    assert (h != NULL);
-
-    return h->total_keys;
-}
-
-static void
-hash_table_modify (x_hash_table *h, void *k, void *v, int replace)
-{
-    unsigned int hash_value;
-    x_list *node, *item;
-
-    assert (h != NULL);
-
-    hash_value = hash_table_hash_key (h, k);
-
-    for (node = h->buckets[hash_value % hash_table_total_buckets (h)];
-         node != 0; node = node->next)
-    {
-        item = node->data;
-
-        if (hash_table_compare_keys (h, ITEM_KEY (item), k))
-        {
-            if (replace)
-            {
-                hash_table_destroy_item (h, ITEM_KEY (item),
-                                         ITEM_VALUE (item));
-                item->next = k;
-                ITEM_VALUE (item) = v;
-            }
-            else
-            {
-                hash_table_destroy_item (h, k, ITEM_VALUE (item));
-                ITEM_VALUE (item) = v;
-            }
-            return;
-        }
-    }
-
-    /* Key isn't already in the table. Insert it. */
-
-    if (h->total_keys + 1
-        > hash_table_total_buckets (h) * SPLIT_THRESHOLD_FACTOR)
-    {
-        hash_table_split (h);
-    }
-
-    hash_value = hash_value % hash_table_total_buckets (h);
-    h->buckets[hash_value] = X_PFX (list_prepend) (h->buckets[hash_value],
-                                                   ITEM_NEW (k, v));
-    h->total_keys++;
-}
-
-X_EXTERN void
-X_PFX (hash_table_insert) (x_hash_table *h, void *k, void *v)
-{
-    hash_table_modify (h, k, v, 0);
-}
-
-X_EXTERN void
-X_PFX (hash_table_replace) (x_hash_table *h, void *k, void *v)
-{
-    hash_table_modify (h, k, v, 1);
-}
-
-X_EXTERN void
-X_PFX (hash_table_remove) (x_hash_table *h, void *k)
-{
-    unsigned int hash_value;
-    x_list **ptr, *item;
-
-    assert (h != NULL);
-
-    hash_value = hash_table_hash_key (h, k);
-
-    for (ptr = &h->buckets[hash_value % hash_table_total_buckets (h)];
-         *ptr != 0; ptr = &((*ptr)->next))
-    {
-        item = (*ptr)->data;
-
-        if (hash_table_compare_keys (h, ITEM_KEY (item), k))
-        {
-            hash_table_destroy_item (h, ITEM_KEY (item), ITEM_VALUE (item));
-            ITEM_FREE (item);
-            item = *ptr;
-            *ptr = item->next;
-            X_PFX (list_free_1) (item);
-            h->total_keys--;
-            return;
-        }
-    }
-}
-
-X_EXTERN void *
-X_PFX (hash_table_lookup) (x_hash_table *h, void *k, void **k_ret)
-{
-    unsigned int hash_value;
-    x_list *node, *item;
-
-    assert (h != NULL);
-
-    hash_value = hash_table_hash_key (h, k);
-
-    for (node = h->buckets[hash_value % hash_table_total_buckets (h)];
-         node != 0; node = node->next)
-    {
-        item = node->data;
-
-        if (hash_table_compare_keys (h, ITEM_KEY (item), k))
-        {
-            if (k_ret != 0)
-            *k_ret = ITEM_KEY (item);
-
-            return ITEM_VALUE (item);
-        }
-    }
-
-    if (k_ret != 0)
-        *k_ret = 0;
-
-    return 0;
-}
-
-X_EXTERN void
-X_PFX (hash_table_foreach) (x_hash_table *h,
-                            x_hash_foreach_fun *fun, void *data)
-{
-    int i, n;
-    x_list *node, *item;
-
-    assert (h != NULL);
-
-    n = hash_table_total_buckets (h);
-
-    for (i = 0; i < n; i++)
-    {
-        for (node = h->buckets[i]; node != 0; node = node->next)
-        {
-            item = node->data;
-            (*fun) (ITEM_KEY (item), ITEM_VALUE (item), data);
-        }
-    }
-}
diff --git a/hw/darwin/quartz/xpr/x-hash.h b/hw/darwin/quartz/xpr/x-hash.h
deleted file mode 100644
index 3456dbe..0000000
--- a/hw/darwin/quartz/xpr/x-hash.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* x-hash.h -- basic hash table class
-
-   Copyright (c) 2002 Apple Computer, Inc. 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 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 X_HASH_H
-#define X_HASH_H 1
-
-typedef struct x_hash_table_struct x_hash_table;
-
-typedef int (x_compare_fun) (const void *a, const void *b);
-typedef unsigned int (x_hash_fun) (const void *k);
-typedef void (x_destroy_fun) (void *x);
-typedef void (x_hash_foreach_fun) (void *k, void *v, void *data);
-
-/* for X_PFX and X_EXTERN */
-#include "x-list.h"
-
-X_EXTERN x_hash_table *X_PFX (hash_table_new) (x_hash_fun *hash,
-					       x_compare_fun *compare,
-					       x_destroy_fun *key_destroy,
-					       x_destroy_fun *value_destroy);
-X_EXTERN void X_PFX (hash_table_free) (x_hash_table *h);
-
-X_EXTERN unsigned int X_PFX (hash_table_size) (x_hash_table *h);
-
-X_EXTERN void X_PFX (hash_table_insert) (x_hash_table *h, void *k, void *v);
-X_EXTERN void X_PFX (hash_table_replace) (x_hash_table *h, void *k, void *v);
-X_EXTERN void X_PFX (hash_table_remove) (x_hash_table *h, void *k);
-X_EXTERN void *X_PFX (hash_table_lookup) (x_hash_table *h,
-					  void *k, void **k_ret);
-X_EXTERN void X_PFX (hash_table_foreach) (x_hash_table *h,
-					  x_hash_foreach_fun *fun,
-					  void *data);
-
-#endif /* X_HASH_H */
diff --git a/hw/darwin/quartz/xpr/x-hook.c b/hw/darwin/quartz/xpr/x-hook.c
deleted file mode 100644
index bb873bb..0000000
--- a/hw/darwin/quartz/xpr/x-hook.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/* x-hook.c
-
-   Copyright (c) 2003 Apple Computer, Inc. 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 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. */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "x-hook.h"
-#include <stdlib.h>
-#include <assert.h>
-
-#define CELL_NEW(f,d) X_PFX (list_prepend) ((x_list *) (f), (d))
-#define CELL_FREE(c)  X_PFX (list_free_1) (c)
-#define CELL_FUN(c)   ((x_hook_function *) ((c)->next))
-#define CELL_DATA(c)  ((c)->data)
-
-X_EXTERN x_list *
-X_PFX (hook_add) (x_list *lst, x_hook_function *fun, void *data)
-{
-    return X_PFX (list_prepend) (lst, CELL_NEW (fun, data));
-}
-
-X_EXTERN x_list *
-X_PFX (hook_remove) (x_list *lst, x_hook_function *fun, void *data)
-{
-    x_list *node, *cell;
-    x_list *to_delete = NULL;
-
-    for (node = lst; node != NULL; node = node->next)
-    {
-	cell = node->data;
-	if (CELL_FUN (cell) == fun && CELL_DATA (cell) == data)
-	    to_delete = X_PFX (list_prepend) (to_delete, cell);
-    }
-
-    for (node = to_delete; node != NULL; node = node->next)
-    {
-	cell = node->data;
-	lst = X_PFX (list_remove) (lst, cell);
-	CELL_FREE (cell);
-    }
-
-    X_PFX (list_free) (to_delete);
-    return lst;
-}
-
-X_EXTERN void
-X_PFX (hook_run) (x_list *lst, void *arg)
-{
-    x_list *node, *cell;
-    x_hook_function **fun;
-    void **data;
-    int length, i;
-
-    length = X_PFX (list_length) (lst);
-    fun = alloca (sizeof (x_hook_function *) * length);
-    data = alloca (sizeof (void *) * length);
-
-    for (i = 0, node = lst; node != NULL; node = node->next, i++)
-    {
-	cell = node->data;
-	fun[i] = CELL_FUN (cell);
-	data[i] = CELL_DATA (cell);
-    }
-
-    for (i = 0; i < length; i++)
-    {
-	(*fun[i]) (arg, data[i]);
-    }
-}
-
-X_EXTERN void
-X_PFX (hook_free) (x_list *lst)
-{
-    x_list *node;
-
-    for (node = lst; node != NULL; node = node->next)
-    {
-	CELL_FREE (node->data);
-    }
-
-    X_PFX (list_free) (lst);
-}
diff --git a/hw/darwin/quartz/xpr/x-hook.h b/hw/darwin/quartz/xpr/x-hook.h
deleted file mode 100644
index 392352d..0000000
--- a/hw/darwin/quartz/xpr/x-hook.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* x-hook.h -- lists of function,data pairs to call.
-
-   Copyright (c) 2003 Apple Computer, Inc. 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 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 X_HOOK_H
-#define X_HOOK_H 1
-
-#include "x-list.h"
-
-typedef void x_hook_function (void *arg, void *data);
-
-X_EXTERN x_list *X_PFX (hook_add) (x_list *lst, x_hook_function *fun, void *data);
-X_EXTERN x_list *X_PFX (hook_remove) (x_list *lst, x_hook_function *fun, void *data);
-X_EXTERN void X_PFX (hook_run) (x_list *lst, void *arg);
-X_EXTERN void X_PFX (hook_free) (x_list *lst);
-
-#endif /* X_HOOK_H */
diff --git a/hw/darwin/quartz/xpr/x-list.c b/hw/darwin/quartz/xpr/x-list.c
deleted file mode 100644
index 3596dd3..0000000
--- a/hw/darwin/quartz/xpr/x-list.c
+++ /dev/null
@@ -1,337 +0,0 @@
-/* x-list.c
-
-   Copyright (c) 2002 Apple Computer, Inc. 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 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. */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "x-list.h"
-#include <stdlib.h>
-#include <assert.h>
-#include <pthread.h>
-
-/* Allocate in ~4k blocks */
-#define NODES_PER_BLOCK 508
-
-typedef struct x_list_block_struct x_list_block;
-
-struct x_list_block_struct {
-    x_list l[NODES_PER_BLOCK];
-};
-
-static x_list *freelist;
-
-static pthread_mutex_t freelist_lock = PTHREAD_MUTEX_INITIALIZER;
-
-static inline void
-list_free_1 (x_list *node)
-{
-    node->next = freelist;
-    freelist = node;
-}
-
-X_EXTERN void
-X_PFX (list_free_1) (x_list *node)
-{
-    assert (node != NULL);
-
-    pthread_mutex_lock (&freelist_lock);
-
-    list_free_1 (node);
-
-    pthread_mutex_unlock (&freelist_lock);
-}
-
-X_EXTERN void
-X_PFX (list_free) (x_list *lst)
-{
-    x_list *next;
-
-    pthread_mutex_lock (&freelist_lock);
-
-    for (; lst != NULL; lst = next)
-    {
-        next = lst->next;
-        list_free_1 (lst);
-    }
-
-    pthread_mutex_unlock (&freelist_lock);
-}
-
-X_EXTERN x_list *
-X_PFX (list_prepend) (x_list *lst, void *data)
-{
-    x_list *node;
-
-    pthread_mutex_lock (&freelist_lock);
-
-    if (freelist == NULL)
-    {
-        x_list_block *b;
-        int i;
-
-        b = malloc (sizeof (x_list_block));
-
-        for (i = 0; i < NODES_PER_BLOCK - 1; i++)
-            b->l[i].next = &(b->l[i+1]);
-        b->l[i].next = NULL;
-
-        freelist = b->l;
-    }
-
-    node = freelist;
-    freelist = node->next;
-
-    pthread_mutex_unlock (&freelist_lock);
-
-    node->next = lst;
-    node->data = data;
-
-    return node;
-}
-
-X_EXTERN x_list *
-X_PFX (list_append) (x_list *lst, void *data)
-{
-    x_list *head = lst;
-
-    if (lst == NULL)
-        return X_PFX (list_prepend) (NULL, data);
-
-    while (lst->next != NULL)
-        lst = lst->next;
-
-    lst->next = X_PFX (list_prepend) (NULL, data);
-
-    return head;
-}
-
-X_EXTERN x_list *
-X_PFX (list_reverse) (x_list *lst)
-{
-    x_list *head = NULL, *next;
-    
-    while (lst != NULL)
-    {
-        next = lst->next;
-        lst->next = head;
-        head = lst;
-        lst = next;
-    }
-
-    return head;
-}
-
-X_EXTERN x_list *
-X_PFX (list_find) (x_list *lst, void *data)
-{
-    for (; lst != NULL; lst = lst->next)
-    {
-        if (lst->data == data)
-            return lst;
-    }
-
-    return NULL;
-}
-
-X_EXTERN x_list *
-X_PFX (list_nth) (x_list *lst, int n)
-{
-    while (n-- > 0 && lst != NULL)
-        lst = lst->next;
-
-    return lst;
-}
-
-X_EXTERN x_list *
-X_PFX (list_pop) (x_list *lst, void **data_ret)
-{
-    void *data = NULL;
-
-    if (lst != NULL)
-    {
-        x_list *tem = lst;
-        data = lst->data;
-        lst = lst->next;
-        X_PFX (list_free_1) (tem);
-    }
-
-    if (data_ret != NULL)
-        *data_ret = data;
-
-    return lst;
-}
-
-X_EXTERN x_list *
-X_PFX (list_filter) (x_list *lst,
-                     int (*pred) (void *item, void *data), void *data)
-{
-    x_list *ret = NULL, *node;
-
-    for (node = lst; node != NULL; node = node->next)
-    {
-        if ((*pred) (node->data, data))
-            ret = X_PFX (list_prepend) (ret, node->data);
-    }
-
-    return X_PFX (list_reverse) (ret);
-}
-
-X_EXTERN x_list *
-X_PFX (list_map) (x_list *lst,
-                  void *(*fun) (void *item, void *data), void *data)
-{
-    x_list *ret = NULL, *node;
-
-    for (node = lst; node != NULL; node = node->next)
-    {
-        X_PFX (list_prepend) (ret, fun (node->data, data));
-    }
-
-    return X_PFX (list_reverse) (ret);
-}
-
-X_EXTERN x_list *
-X_PFX (list_copy) (x_list *lst)
-{
-    x_list *copy = NULL;
-
-    for (; lst != NULL; lst = lst->next)
-    {
-        copy = X_PFX (list_prepend) (copy, lst->data);
-    }
-
-    return X_PFX (list_reverse) (copy);
-}
-
-X_EXTERN x_list *
-X_PFX (list_remove) (x_list *lst, void *data)
-{
-    x_list **ptr, *node;
-
-    for (ptr = &lst; *ptr != NULL;)
-    {
-        node = *ptr;
-
-        if (node->data == data)
-        {
-            *ptr = node->next;
-            X_PFX (list_free_1) (node);
-        }
-        else
-            ptr = &((*ptr)->next);
-    }
-
-    return lst;
-}
-
-X_EXTERN unsigned int
-X_PFX (list_length) (x_list *lst)
-{
-    unsigned int n;
-
-    n = 0;
-    for (; lst != NULL; lst = lst->next)
-        n++;
-
-    return n;
-}
-
-X_EXTERN void
-X_PFX (list_foreach) (x_list *lst,
-                      void (*fun) (void *data, void *user_data),
-                      void *user_data)
-{
-    for (; lst != NULL; lst = lst->next)
-    {
-        (*fun) (lst->data, user_data);
-    }
-}
-
-static x_list *
-list_sort_1 (x_list *lst, int length,
-             int (*less) (const void *, const void *))
-{
-    x_list *mid, *ptr;
-    x_list *out_head, *out;
-    int mid_point, i;
-
-    /* This is a standard (stable) list merge sort */
-
-    if (length < 2)
-        return lst;
-
-    /* Calculate the halfway point. Split the list into two sub-lists. */
-
-    mid_point = length / 2;
-    ptr = lst;
-    for (i = mid_point - 1; i > 0; i--)
-        ptr = ptr->next;
-    mid = ptr->next;
-    ptr->next = NULL;
-
-    /* Sort each sub-list. */
-
-    lst = list_sort_1 (lst, mid_point, less);
-    mid = list_sort_1 (mid, length - mid_point, less);
-
-    /* Then merge them back together. */
-
-    assert (lst != NULL && mid != NULL);
-
-    if ((*less) (mid->data, lst->data))
-        out = out_head = mid, mid = mid->next;
-    else
-        out = out_head = lst, lst = lst->next;
-
-    while (lst != NULL && mid != NULL)
-    {
-        if ((*less) (mid->data, lst->data))
-            out = out->next = mid, mid = mid->next;
-        else
-            out = out->next = lst, lst = lst->next;
-    }
-
-    if (lst != NULL)
-        out->next = lst;
-    else
-        out->next = mid;
-
-    return out_head;
-}
-
-X_EXTERN x_list *
-X_PFX (list_sort) (x_list *lst, int (*less) (const void *, const void *))
-{
-    int length;
-
-    length = X_PFX (list_length) (lst);
-
-    return list_sort_1 (lst, length, less);
-}
diff --git a/hw/darwin/quartz/xpr/x-list.h b/hw/darwin/quartz/xpr/x-list.h
deleted file mode 100644
index 04af024..0000000
--- a/hw/darwin/quartz/xpr/x-list.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* x-list.h -- simple list type
-
-   Copyright (c) 2002 Apple Computer, Inc. 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 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 X_LIST_H
-#define X_LIST_H 1
-
-/* This is just a cons. */
-
-typedef struct x_list_struct x_list;
-
-struct x_list_struct {
-    void *data;
-    x_list *next;
-};
-
-#ifndef X_PFX
-# define X_PFX(x) x_ ## x
-#endif
-
-#ifndef X_EXTERN
-# define X_EXTERN __private_extern__
-#endif
-
-X_EXTERN void X_PFX (list_free_1) (x_list *node);
-X_EXTERN x_list *X_PFX (list_prepend) (x_list *lst, void *data);
-
-X_EXTERN x_list *X_PFX (list_append) (x_list *lst, void *data);
-X_EXTERN x_list *X_PFX (list_remove) (x_list *lst, void *data);
-X_EXTERN void X_PFX (list_free) (x_list *lst);
-X_EXTERN x_list *X_PFX (list_pop) (x_list *lst, void **data_ret);
-
-X_EXTERN x_list *X_PFX (list_copy) (x_list *lst);
-X_EXTERN x_list *X_PFX (list_reverse) (x_list *lst);
-X_EXTERN x_list *X_PFX (list_find) (x_list *lst, void *data);
-X_EXTERN x_list *X_PFX (list_nth) (x_list *lst, int n);
-X_EXTERN x_list *X_PFX (list_filter) (x_list *src,
-                                      int (*pred) (void *item, void *data),
-                                      void *data);
-X_EXTERN x_list *X_PFX (list_map) (x_list *src,
-                                   void *(*fun) (void *item, void *data),
-                                   void *data);
-
-X_EXTERN unsigned int X_PFX (list_length) (x_list *lst);
-X_EXTERN void X_PFX (list_foreach) (x_list *lst, void (*fun)
-                                    (void *data, void *user_data),
-                                    void *user_data);
-
-X_EXTERN x_list *X_PFX (list_sort) (x_list *lst, int (*less) (const void *,
-                                    const void *));
-
-#endif /* X_LIST_H */
diff --git a/hw/darwin/quartz/xpr/xpr.h b/hw/darwin/quartz/xpr/xpr.h
deleted file mode 100644
index ddc6d0c..0000000
--- a/hw/darwin/quartz/xpr/xpr.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Xplugin rootless implementation
- *
- * Copyright (c) 2003 Torrey T. Lyons. 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
- * 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 XPR_H
-#define XPR_H
-
-#include "screenint.h"
-
-extern Bool QuartzModeBundleInit(void);
-
-void AppleDRIExtensionInit(void);
-void xprAppleWMInit(void);
-Bool xprInit(ScreenPtr pScreen);
-Bool xprIsX11Window(void *nsWindow, int windowNumber);
-
-void xprHideWindows(Bool hide);
-
-Bool QuartzInitCursor(ScreenPtr pScreen);
-void QuartzSuspendXCursor(ScreenPtr pScreen);
-void QuartzResumeXCursor(ScreenPtr pScreen, int x, int y);
-
-#endif /* XPR_H */
diff --git a/hw/darwin/quartz/xpr/xprAppleWM.c b/hw/darwin/quartz/xpr/xprAppleWM.c
deleted file mode 100644
index 5539c51..0000000
--- a/hw/darwin/quartz/xpr/xprAppleWM.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Xplugin rootless implementation functions for AppleWM extension
- *
- * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
- * Copyright (c) 2003 Torrey T. Lyons. 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
- * 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "xpr.h"
-#include "quartz/applewmExt.h"
-#include "rootless.h"
-#include "Xplugin.h"
-#include <X11/X.h>
-
-static int xprSetWindowLevel(
-    WindowPtr pWin,
-    int level)
-{
-    xp_window_id wid;
-    xp_window_changes wc;
-
-    wid = (xp_window_id) RootlessFrameForWindow (pWin, TRUE);
-    if (wid == 0)
-        return BadWindow;
-
-    RootlessStopDrawing (pWin, FALSE);
-
-    wc.window_level = level;
-    if (xp_configure_window (wid, XP_WINDOW_LEVEL, &wc) != Success) {
-        return BadValue;
-    }
-
-    return Success;
-}
-
-
-static int xprFrameDraw(
-    WindowPtr pWin,
-    int class,
-    unsigned int attr,
-    const BoxRec *outer,
-    const BoxRec *inner,
-    unsigned int title_len,
-    const unsigned char *title_bytes)
-{
-    xp_window_id wid;
-
-    wid = (xp_window_id) RootlessFrameForWindow (pWin, FALSE);
-    if (wid == 0)
-        return BadWindow;
-
-    if (xp_frame_draw (wid, class, attr, outer, inner,
-                       title_len, title_bytes) != Success)
-    {
-        return BadValue;
-    }
-
-    return Success;
-}
-
-
-static AppleWMProcsRec xprAppleWMProcs = {
-    xp_disable_update,
-    xp_reenable_update,
-    xprSetWindowLevel,
-    xp_frame_get_rect,
-    xp_frame_hit_test,
-    xprFrameDraw
-};
-
-
-void xprAppleWMInit(void)
-{
-    AppleWMExtensionInit(&xprAppleWMProcs);
-}
diff --git a/hw/darwin/quartz/xpr/xprCursor.c b/hw/darwin/quartz/xpr/xprCursor.c
deleted file mode 100644
index 160b5d9..0000000
--- a/hw/darwin/quartz/xpr/xprCursor.c
+++ /dev/null
@@ -1,431 +0,0 @@
-/**************************************************************
- *
- * Xplugin cursor support
- *
- * Copyright (c) 2001 Torrey T. Lyons and Greg Parker.
- * Copyright (c) 2002 Apple Computer, Inc.
- *                 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
- * 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "quartz/quartzCommon.h"
-#include "xpr.h"
-#include "darwin.h"
-#include "Xplugin.h"
-
-#include "mi.h"
-#include "scrnintstr.h"
-#include "cursorstr.h"
-#include "mipointrst.h"
-#include "windowstr.h"
-#include "globals.h"
-#include "servermd.h"
-#include "dixevents.h"
-
-typedef struct {
-    int                     cursorVisible;
-    QueryBestSizeProcPtr    QueryBestSize;
-    miPointerSpriteFuncPtr  spriteFuncs;
-} QuartzCursorScreenRec, *QuartzCursorScreenPtr;
-
-static int darwinCursorScreenIndex = -1;
-static unsigned long darwinCursorGeneration = 0;
-
-#define CURSOR_PRIV(pScreen) \
-    ((QuartzCursorScreenPtr)pScreen->devPrivates[darwinCursorScreenIndex].ptr)
-
-
-static Bool
-load_cursor(CursorPtr src, int screen)
-{
-    uint32_t *data;
-    uint32_t rowbytes;
-    int width, height;
-    int hot_x, hot_y;
-
-    uint32_t fg_color, bg_color;
-    uint8_t *srow, *sptr;
-    uint8_t *mrow, *mptr;
-    uint32_t *drow, *dptr;
-    unsigned xcount, ycount;
-
-    xp_error err;
-
-    width = src->bits->width;
-    height = src->bits->height;
-    hot_x = src->bits->xhot;
-    hot_y = src->bits->yhot;
-
-#ifdef ARGB_CURSOR
-    if (src->bits->argb != NULL)
-    {
-#if BITMAP_BIT_ORDER == MSBFirst
-        rowbytes = src->bits->width * sizeof (CARD32);
-        data = (uint32_t *) src->bits->argb;
-#else
-        const uint32_t *be_data=(uint32_t *) src->bits->argb;
-        unsigned i;
-        rowbytes = src->bits->width * sizeof (CARD32);
-        data=alloca (rowbytes * src->bits->height);
-        for(i=0;i<(src->bits->width*src->bits->height);i++)
-            data[i]=ntohl(be_data[i]);
-#endif
-    }
-    else
-#endif
-    {
-        fg_color = 0xFF00 | (src->foreRed >> 8);
-        fg_color <<= 16;
-        fg_color |= src->foreGreen & 0xFF00;
-        fg_color |= src->foreBlue >> 8;
-
-        bg_color = 0xFF00 | (src->backRed >> 8);
-        bg_color <<= 16;
-        bg_color |= src->backGreen & 0xFF00;
-        bg_color |= src->backBlue >> 8;
-
-        fg_color = htonl(fg_color);
-        bg_color = htonl(bg_color);
-
-        /* round up to 8 pixel boundary so we can convert whole bytes */
-        rowbytes = ((src->bits->width * 4) + 31) & ~31;
-        data = alloca(rowbytes * src->bits->height);
-
-        if (!src->bits->emptyMask)
-        {
-            ycount = src->bits->height;
-            srow = src->bits->source; mrow = src->bits->mask;
-            drow = data;
-
-            while (ycount-- > 0)
-            {
-                xcount = (src->bits->width + 7) / 8;
-                sptr = srow; mptr = mrow;
-                dptr = drow;
-
-                while (xcount-- > 0)
-                {
-                    uint8_t s, m;
-                    int i;
-
-                    s = *sptr++; m = *mptr++;
-                    for (i = 0; i < 8; i++)
-                    {
-#if BITMAP_BIT_ORDER == MSBFirst
-                        if (m & 128)
-                            *dptr++ = (s & 128) ? fg_color : bg_color;
-                        else
-                            *dptr++ = 0;
-                        s <<= 1; m <<= 1;
-#else
-                        if (m & 1)
-                            *dptr++ = (s & 1) ? fg_color : bg_color;
-                        else
-                            *dptr++ = 0;
-                        s >>= 1; m >>= 1;
-#endif
-                    }
-                }
-
-                srow += BitmapBytePad(src->bits->width);
-                mrow += BitmapBytePad(src->bits->width);
-                drow = (uint32_t *) ((char *) drow + rowbytes);
-            }
-        }
-        else
-        {
-            memset(data, 0, src->bits->height * rowbytes);
-        }
-    }
-
-    err = xp_set_cursor(width, height, hot_x, hot_y, data, rowbytes);
-    return err == Success;
-}
-
-
-/*
-===========================================================================
-
- Pointer sprite functions
-
-===========================================================================
-*/
-
-/*
- * QuartzRealizeCursor
- *  Convert the X cursor representation to native format if possible.
- */
-static Bool
-QuartzRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
-{
-    if(pCursor == NULL || pCursor->bits == NULL)
-        return FALSE;
-
-    /* FIXME: cache ARGB8888 representation? */
-
-    return TRUE;
-}
-
-
-/*
- * QuartzUnrealizeCursor
- *  Free the storage space associated with a realized cursor.
- */
-static Bool
-QuartzUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
-{
-    return TRUE;
-}
-
-
-/*
- * QuartzSetCursor
- *  Set the cursor sprite and position.
- */
-static void
-QuartzSetCursor(ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
-{
-    QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
-
-    if (!quartzServerVisible)
-        return;
-
-    if (pCursor == NULL)
-    {
-        if (ScreenPriv->cursorVisible)
-        {
-            xp_hide_cursor();
-            ScreenPriv->cursorVisible = FALSE;
-        }
-    }
-    else
-    {
-        load_cursor(pCursor, pScreen->myNum);
-
-        if (!ScreenPriv->cursorVisible)
-        {
-            xp_show_cursor();
-            ScreenPriv->cursorVisible = TRUE;
-        }
-    }
-}
-
-
-/*
- * QuartzMoveCursor
- *  Move the cursor. This is a noop for us.
- */
-static void
-QuartzMoveCursor(ScreenPtr pScreen, int x, int y)
-{
-}
-
-
-static miPointerSpriteFuncRec quartzSpriteFuncsRec = {
-    QuartzRealizeCursor,
-    QuartzUnrealizeCursor,
-    QuartzSetCursor,
-    QuartzMoveCursor
-};
-
-
-/*
-===========================================================================
-
- Pointer screen functions
-
-===========================================================================
-*/
-
-/*
- * QuartzCursorOffScreen
- */
-static Bool
-QuartzCursorOffScreen(ScreenPtr *pScreen, int *x, int *y)
-{
-    return FALSE;
-}
-
-
-/*
- * QuartzCrossScreen
- */
-static void
-QuartzCrossScreen(ScreenPtr pScreen, Bool entering)
-{
-    return;
-}
-
-
-/*
- * QuartzWarpCursor
- *  Change the cursor position without generating an event or motion history.
- *  The input coordinates (x,y) are in pScreen-local X11 coordinates.
- *
- */
-static void
-QuartzWarpCursor(ScreenPtr pScreen, int x, int y)
-{
-    static Bool neverMoved = TRUE;
-
-    if (neverMoved)
-    {
-        /* Don't move the cursor the first time. This is the
-           jump-to-center initialization, and it's annoying. */
-        neverMoved = FALSE;
-        return;
-    }
-
-    if (quartzServerVisible)
-    {
-        int sx, sy;
-
-        sx = dixScreenOrigins[pScreen->myNum].x + darwinMainScreenX;
-        sy = dixScreenOrigins[pScreen->myNum].y + darwinMainScreenY;
-
-        CGWarpMouseCursorPosition(CGPointMake(sx + x, sy + y));
-    }
-
-    miPointerWarpCursor(pScreen, x, y);
-    miPointerUpdate();
-}
-
-
-static miPointerScreenFuncRec quartzScreenFuncsRec = {
-    QuartzCursorOffScreen,
-    QuartzCrossScreen,
-    QuartzWarpCursor,
-    DarwinEQPointerPost,
-    DarwinEQSwitchScreen
-};
-
-
-/*
-===========================================================================
-
- Other screen functions
-
-===========================================================================
-*/
-
-/*
- * QuartzCursorQueryBestSize
- *  Handle queries for best cursor size
- */
-static void
-QuartzCursorQueryBestSize(int class, unsigned short *width,
-                          unsigned short *height, ScreenPtr pScreen)
-{
-    QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
-
-    if (class == CursorShape)
-    {
-        /* FIXME: query window server? */
-        *width = 32;
-        *height = 32;
-    }
-    else
-    {
-        (*ScreenPriv->QueryBestSize)(class, width, height, pScreen);
-    }
-}
-
-/*
- * QuartzInitCursor
- *  Initialize cursor support
- */
-Bool
-QuartzInitCursor(ScreenPtr pScreen)
-{
-    QuartzCursorScreenPtr ScreenPriv;
-    miPointerScreenPtr PointPriv;
-
-    /* initialize software cursor handling (always needed as backup) */
-    if (!miDCInitialize(pScreen, &quartzScreenFuncsRec))
-        return FALSE;
-
-    /* allocate private storage for this screen's QuickDraw cursor info */
-    if (darwinCursorGeneration != serverGeneration)
-    {
-        if ((darwinCursorScreenIndex = AllocateScreenPrivateIndex()) < 0)
-            return FALSE;
-
-        darwinCursorGeneration = serverGeneration;
-    }
-
-    ScreenPriv = xcalloc(1, sizeof(QuartzCursorScreenRec));
-    if (ScreenPriv == NULL)
-        return FALSE;
-
-    /* CURSOR_PRIV(pScreen) = ScreenPriv; */
-    pScreen->devPrivates[darwinCursorScreenIndex].ptr = ScreenPriv;
-
-    /* override some screen procedures */
-    ScreenPriv->QueryBestSize = pScreen->QueryBestSize;
-    pScreen->QueryBestSize = QuartzCursorQueryBestSize;
-
-    PointPriv = (miPointerScreenPtr) pScreen->devPrivates[miPointerScreenIndex].ptr;
-
-    ScreenPriv->spriteFuncs = PointPriv->spriteFuncs;
-    PointPriv->spriteFuncs = &quartzSpriteFuncsRec;
-
-    ScreenPriv->cursorVisible = TRUE;
-    return TRUE;
-}
-
-
-/*
- * QuartzSuspendXCursor
- *  X server is hiding. Restore the Aqua cursor.
- */
-void
-QuartzSuspendXCursor(ScreenPtr pScreen)
-{
-}
-
-
-/*
- * QuartzResumeXCursor
- *  X server is showing. Restore the X cursor.
- */
-void
-QuartzResumeXCursor(ScreenPtr pScreen, int x, int y)
-{
-    WindowPtr pWin;
-    CursorPtr pCursor;
-
-    pWin = GetSpriteWindow();
-    if (pWin->drawable.pScreen != pScreen)
-        return;
-
-    pCursor = GetSpriteCursor();
-    if (pCursor == NULL)
-        return;
-
-    QuartzSetCursor(pScreen, pCursor, x, y);
-}
diff --git a/hw/darwin/quartz/xpr/xprFrame.c b/hw/darwin/quartz/xpr/xprFrame.c
deleted file mode 100644
index 1b0ba91..0000000
--- a/hw/darwin/quartz/xpr/xprFrame.c
+++ /dev/null
@@ -1,528 +0,0 @@
-/*
- * Xplugin rootless implementation frame functions
- *
- * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
- * Copyright (c) 2003 Torrey T. Lyons. 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
- * 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "xpr.h"
-#include "rootlessCommon.h"
-#include "Xplugin.h"
-#include "x-hash.h"
-#include "x-list.h"
-#include "quartz/applewmExt.h"
-
-#include "propertyst.h"
-#include "dix.h"
-#include <X11/Xatom.h>
-#include "windowstr.h"
-
-#include <pthread.h>
-
-#define DEFINE_ATOM_HELPER(func,atom_name)                      \
-static Atom func (void) {                                       \
-    static int generation;                                      \
-    static Atom atom;                                           \
-    if (generation != serverGeneration) {                       \
-        generation = serverGeneration;                          \
-        atom = MakeAtom (atom_name, strlen (atom_name), TRUE);  \
-    }                                                           \
-    return atom;                                                \
-}
-
-DEFINE_ATOM_HELPER(xa_native_window_id, "_NATIVE_WINDOW_ID")
-
-/* Maps xp_window_id -> RootlessWindowRec */
-static x_hash_table *window_hash;
-static pthread_mutex_t window_hash_mutex;
-
-static Bool no_configure_window;
-
-
-static inline xp_error
-xprConfigureWindow(xp_window_id id, unsigned int mask,
-                   const xp_window_changes *values)
-{
-  //  ErrorF("xprConfigureWindow()\n");
-    if (!no_configure_window)
-        return xp_configure_window(id, mask, values);
-    else
-        return XP_Success;
-}
-
-
-static void
-xprSetNativeProperty(RootlessWindowPtr pFrame)
-{
-    xp_error err;
-    unsigned int native_id;
-    long data;
-
-    err = xp_get_native_window((xp_window_id) pFrame->wid, &native_id);
-    if (err == Success)
-    {
-        /* FIXME: move this to AppleWM extension */
-
-        data = native_id;
-        ChangeWindowProperty(pFrame->win, xa_native_window_id(),
-                             XA_INTEGER, 32, PropModeReplace, 1, &data, TRUE);
-    }
-}
-
-
-/*
- * Create and display a new frame.
- */
-Bool
-xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
-               int newX, int newY, RegionPtr pShape)
-{
-    WindowPtr pWin = pFrame->win;
-    xp_window_changes wc;
-    unsigned int mask = 0;
-    xp_error err;
-
-    wc.x = newX;
-    wc.y = newY;
-    wc.width = pFrame->width;
-    wc.height = pFrame->height;
-    wc.bit_gravity = XP_GRAVITY_NONE;
-    mask |= XP_BOUNDS;
-
-    if (pWin->drawable.depth == 8)
-    {
-        wc.depth = XP_DEPTH_INDEX8;
-#if 0
-        wc.colormap = xprColormapCallback;
-        wc.colormap_data = pScreen;
-        mask |= XP_COLORMAP;
-#endif
-    }
-    else if (pWin->drawable.depth == 15)
-        wc.depth = XP_DEPTH_RGB555;
-    else if (pWin->drawable.depth == 24)
-        wc.depth = XP_DEPTH_ARGB8888;
-    else
-        wc.depth = XP_DEPTH_NIL;
-    mask |= XP_DEPTH;
-
-    if (pShape != NULL)
-    {
-        wc.shape_nrects = REGION_NUM_RECTS(pShape);
-        wc.shape_rects = REGION_RECTS(pShape);
-        wc.shape_tx = wc.shape_ty = 0;
-        mask |= XP_SHAPE;
-    }
-
-    err = xp_create_window(mask, &wc, (xp_window_id *) &pFrame->wid);
-
-    if (err != Success)
-    {
-        return FALSE;
-    }
-
-    if (window_hash == NULL)
-    {
-        window_hash = x_hash_table_new(NULL, NULL, NULL, NULL);
-        pthread_mutex_init(&window_hash_mutex, NULL);
-    }
-
-    pthread_mutex_lock(&window_hash_mutex);
-    x_hash_table_insert(window_hash, pFrame->wid, pFrame);
-    pthread_mutex_unlock(&window_hash_mutex);
-
-    xprSetNativeProperty(pFrame);
-
-    return TRUE;
-}
-
-
-/*
- * Destroy a frame.
- */
-void
-xprDestroyFrame(RootlessFrameID wid)
-{
-    pthread_mutex_lock(&window_hash_mutex);
-    x_hash_table_remove(window_hash, wid);
-    pthread_mutex_unlock(&window_hash_mutex);
-
-    xp_destroy_window((xp_window_id) wid);
-}
-
-
-/*
- * Move a frame on screen.
- */
-void
-xprMoveFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY)
-{
-    xp_window_changes wc;
-
-    wc.x = newX;
-    wc.y = newY;
-    //    ErrorF("xprMoveFrame(%d, %p, %d, %d)\n", wid, pScreen, newX, newY);
-    xprConfigureWindow((xp_window_id) wid, XP_ORIGIN, &wc);
-}
-
-
-/*
- * Resize and move a frame.
- */
-void
-xprResizeFrame(RootlessFrameID wid, ScreenPtr pScreen,
-               int newX, int newY, unsigned int newW, unsigned int newH,
-               unsigned int gravity)
-{
-    xp_window_changes wc;
-
-    wc.x = newX;
-    wc.y = newY;
-    wc.width = newW;
-    wc.height = newH;
-    wc.bit_gravity = gravity;
-
-    /* It's unlikely that being async will save us anything here.
-       But it can't hurt. */
-
-    xprConfigureWindow((xp_window_id) wid, XP_BOUNDS, &wc);
-}
-
-
-/*
- * Change frame stacking.
- */
-void
-xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid)
-{
-    xp_window_changes wc;
-
-    /* Stack frame below nextWid it if it exists, or raise
-       frame above everything otherwise. */
-
-    if (nextWid == NULL)
-    {
-        wc.stack_mode = XP_MAPPED_ABOVE;
-        wc.sibling = 0;
-    }
-    else
-    {
-        wc.stack_mode = XP_MAPPED_BELOW;
-        wc.sibling = (xp_window_id) nextWid;
-    }
-
-    xprConfigureWindow((xp_window_id) wid, XP_STACKING, &wc);
-}
-
-
-/*
- * Change the frame's shape.
- */
-void
-xprReshapeFrame(RootlessFrameID wid, RegionPtr pShape)
-{
-    xp_window_changes wc;
-
-    if (pShape != NULL)
-    {
-        wc.shape_nrects = REGION_NUM_RECTS(pShape);
-        wc.shape_rects = REGION_RECTS(pShape);
-    }
-    else
-    {
-        wc.shape_nrects = -1;
-        wc.shape_rects = NULL;
-    }
-
-    wc.shape_tx = wc.shape_ty = 0;
-
-    xprConfigureWindow((xp_window_id) wid, XP_SHAPE, &wc);
-}
-
-
-/*
- * Unmap a frame.
- */
-void
-xprUnmapFrame(RootlessFrameID wid)
-{
-    xp_window_changes wc;
-
-    wc.stack_mode = XP_UNMAPPED;
-    wc.sibling = 0;
-
-    xprConfigureWindow((xp_window_id) wid, XP_STACKING, &wc);
-}
-
-
-/*
- * Start drawing to a frame.
- *  Prepare for direct access to its backing buffer.
- */
-void
-xprStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPerRow)
-{
-    void *data[2];
-    unsigned int rowbytes[2];
-    xp_error err;
-
-    err = xp_lock_window((xp_window_id) wid, NULL, NULL, data, rowbytes, NULL);
-    if (err != Success)
-        FatalError("Could not lock window %i for drawing.", (int) wid);
-
-    *pixelData = data[0];
-    *bytesPerRow = rowbytes[0];
-}
-
-
-/*
- * Stop drawing to a frame.
- */
-void
-xprStopDrawing(RootlessFrameID wid, Bool flush)
-{
-    xp_unlock_window((xp_window_id) wid, flush);
-}
-
-
-/*
- * Flush drawing updates to the screen.
- */
-void
-xprUpdateRegion(RootlessFrameID wid, RegionPtr pDamage)
-{
-    xp_flush_window((xp_window_id) wid);
-}
-
-
-/*
- * Mark damaged rectangles as requiring redisplay to screen.
- */
-void
-xprDamageRects(RootlessFrameID wid, int nrects, const BoxRec *rects,
-               int shift_x, int shift_y)
-{
-    xp_mark_window((xp_window_id) wid, nrects, rects, shift_x, shift_y);
-}
-
-
-/*
- * Called after the window associated with a frame has been switched
- * to a new top-level parent.
- */
-void
-xprSwitchWindow(RootlessWindowPtr pFrame, WindowPtr oldWin)
-{
-    DeleteProperty(oldWin, xa_native_window_id());
-
-    xprSetNativeProperty(pFrame);
-}
-
-
-/*
- * Called to check if the frame should be reordered when it is restacked.
- */
-Bool xprDoReorderWindow(RootlessWindowPtr pFrame)
-{
-    WindowPtr pWin = pFrame->win;
-
-    return AppleWMDoReorderWindow(pWin);
-}
-
-
-/*
- * Copy area in frame to another part of frame.
- *  Used to accelerate scrolling.
- */
-void
-xprCopyWindow(RootlessFrameID wid, int dstNrects, const BoxRec *dstRects,
-              int dx, int dy)
-{
-    xp_copy_window((xp_window_id) wid, (xp_window_id) wid,
-                   dstNrects, dstRects, dx, dy);
-}
-
-
-static RootlessFrameProcsRec xprRootlessProcs = {
-    xprCreateFrame,
-    xprDestroyFrame,
-    xprMoveFrame,
-    xprResizeFrame,
-    xprRestackFrame,
-    xprReshapeFrame,
-    xprUnmapFrame,
-    xprStartDrawing,
-    xprStopDrawing,
-    xprUpdateRegion,
-    xprDamageRects,
-    xprSwitchWindow,
-    xprDoReorderWindow,
-    xp_copy_bytes,
-    xp_fill_bytes,
-    xp_composite_pixels,
-    xprCopyWindow
-};
-
-
-/*
- * Initialize XPR implementation
- */
-Bool
-xprInit(ScreenPtr pScreen)
-{
-    RootlessInit(pScreen, &xprRootlessProcs);
-
-    rootless_CopyBytes_threshold = xp_copy_bytes_threshold;
-    rootless_FillBytes_threshold = xp_fill_bytes_threshold;
-    rootless_CompositePixels_threshold = xp_composite_area_threshold;
-    rootless_CopyWindow_threshold = xp_scroll_area_threshold;
-
-    no_configure_window = FALSE;
-
-    return TRUE;
-}
-
-
-/*
- * Given the id of a physical window, try to find the top-level (or root)
- * X window that it represents.
- */
-WindowPtr
-xprGetXWindow(xp_window_id wid)
-{
-    RootlessWindowRec *winRec;
-
-    if (window_hash == NULL)
-        return NULL;
-
-    winRec = x_hash_table_lookup(window_hash, (void *) wid, NULL);
-
-    return winRec != NULL ? winRec->win : NULL;
-}
-
-/*
- * Given the id of a physical window, try to find the top-level (or root)
- * X window that it represents.
- */
-WindowPtr
-xprGetXWindowFromAppKit(int windowNumber)
-{
-    RootlessWindowRec *winRec;
-    Bool ret;
-    xp_window_id wid;
-
-    if (window_hash == NULL)
-        return FALSE;
-
-    /* need to lock, since this function can be called by any thread */
-
-    pthread_mutex_lock(&window_hash_mutex);
-
-    if (xp_lookup_native_window(windowNumber, &wid))
-        ret = xprGetXWindow(wid) != NULL;
-    else
-        ret = FALSE;
-
-    pthread_mutex_unlock(&window_hash_mutex);
-
-    if (!ret) return NULL;
-    winRec = x_hash_table_lookup(window_hash, (void *) wid, NULL);
-
-    return winRec != NULL ? winRec->win : NULL;
-}
-
-
-/*
- * The windowNumber is an AppKit window number. Returns TRUE if xpr is
- * displaying a window with that number.
- */
-Bool
-xprIsX11Window(void *nsWindow, int windowNumber)
-{
-    Bool ret;
-    xp_window_id wid;
-
-    if (window_hash == NULL)
-        return FALSE;
-
-    /* need to lock, since this function can be called by any thread */
-
-    pthread_mutex_lock(&window_hash_mutex);
-
-    if (xp_lookup_native_window(windowNumber, &wid))
-        ret = xprGetXWindow(wid) != NULL;
-    else
-        ret = FALSE;
-
-    pthread_mutex_unlock(&window_hash_mutex);
-
-    return ret;
-}
-
-
-/*
- * xprHideWindows
- *  Hide or unhide all top level windows. This is called for application hide/
- *  unhide events if the window manager is not Apple-WM aware. Xplugin windows
- *  do not hide or unhide themselves.
- */
-void
-xprHideWindows(Bool hide)
-{
-    int screen;
-    WindowPtr pRoot, pWin;
-
-    for (screen = 0; screen < screenInfo.numScreens; screen++) {
-        pRoot = WindowTable[screenInfo.screens[screen]->myNum];
-        RootlessFrameID prevWid = NULL;
-
-        for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib) {
-            RootlessWindowRec *winRec = WINREC(pWin);
-
-            if (winRec != NULL) {
-                if (hide) {
-                    xprUnmapFrame(winRec->wid);
-                } else {
-                    BoxRec box;
-
-                    xprRestackFrame(winRec->wid, prevWid);
-                    prevWid = winRec->wid;
-
-                    box.x1 = 0;
-                    box.y1 = 0;
-                    box.x2 = winRec->width;
-                    box.y2 = winRec->height;
-
-                    xprDamageRects(winRec->wid, 1, &box, 0, 0);
-                    RootlessQueueRedisplay(screenInfo.screens[screen]);
-                }
-            }
-        }
-    }
-}
diff --git a/hw/darwin/quartz/xpr/xprScreen.c b/hw/darwin/quartz/xpr/xprScreen.c
deleted file mode 100644
index 28ed159..0000000
--- a/hw/darwin/quartz/xpr/xprScreen.c
+++ /dev/null
@@ -1,414 +0,0 @@
-/*
- * Xplugin rootless implementation screen functions
- *
- * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved.
- * Copyright (c) 2004 Torrey T. Lyons. 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
- * 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "quartz/quartzCommon.h"
-#include "quartz/quartz.h"
-#include "xpr.h"
-#include "quartz/pseudoramiX.h"
-#include "darwin.h"
-#include "rootless.h"
-#include "safeAlpha/safeAlpha.h"
-#include "dri.h"
-#include "globals.h"
-#include "Xplugin.h"
-#include "quartz/applewmExt.h"
-
-// From xprFrame.c
-WindowPtr xprGetXWindow(xp_window_id wid);
-
-#ifdef DAMAGE
-# include "damage.h"
-#endif
-
-/* 10.4's deferred update makes X slower.. have to live with the tearing
-   for now.. */
-#define XP_NO_DEFERRED_UPDATES 8
-
-// Name of GLX bundle for native OpenGL
-static const char *xprOpenGLBundle = "glxCGL.bundle";
-
-/*
- * eventHandler
- *  Callback handler for Xplugin events.
- */
-static void
-eventHandler(unsigned int type, const void *arg,
-             unsigned int arg_size, void *data)
-{
-    switch (type) {
-    case XP_EVENT_DISPLAY_CHANGED:
-      DEBUG_LOG("XP_EVENT_DISPLAY_CHANGED\n");
-      QuartzMessageServerThread(kXDarwinDisplayChanged, 0);
-      break;
-
-    case XP_EVENT_WINDOW_STATE_CHANGED:
-      DEBUG_LOG("XP_EVENT_WINDOW_STATE_CHANGED\n");
-      if (arg_size >= sizeof(xp_window_state_event)) {
-	const xp_window_state_event *ws_arg = arg;
-	
-	QuartzMessageServerThread(kXDarwinWindowState, 2,
-				  ws_arg->id, ws_arg->state);
-      }
-      break;
-
-    case XP_EVENT_WINDOW_MOVED:
-      DEBUG_LOG("XP_EVENT_WINDOW_MOVED\n");
-      if (arg_size == sizeof(xp_window_id))  {
-	xp_window_id id = * (xp_window_id *) arg;
-	WindowPtr pWin = xprGetXWindow(id);
-	QuartzMessageServerThread(kXDarwinWindowMoved, 1, pWin);
-      }
-      break;
-      
-    case XP_EVENT_SURFACE_DESTROYED:
-      DEBUG_LOG("XP_EVENT_SURFACE_DESTROYED\n");
-    case XP_EVENT_SURFACE_CHANGED:
-      DEBUG_LOG("XP_EVENT_SURFACE_CHANGED\n");
-        if (arg_size == sizeof(xp_surface_id)) {
-	  int kind;
-	  
-	  if (type == XP_EVENT_SURFACE_DESTROYED)
-	    kind = AppleDRISurfaceNotifyDestroyed;
-	  else
-	    kind = AppleDRISurfaceNotifyChanged;
-	  
-	  DRISurfaceNotify(*(xp_surface_id *) arg, kind);
-        }
-        break;
-    default:
-      ErrorF("Unknown XP_EVENT type (%d) in xprScreen:eventHandler\n",
-	     type);
-    }
-}
-
-/*
- * displayAtIndex
- *  Return the display ID for a particular display index.
- */
-static CGDirectDisplayID
-displayAtIndex(int index)
-{
-    CGError err;
-    CGDisplayCount cnt;
-    CGDirectDisplayID dpy[index+1];
-
-    err = CGGetActiveDisplayList(index + 1, dpy, &cnt);
-    if (err == kCGErrorSuccess && cnt == index + 1)
-        return dpy[index];
-    else
-        return kCGNullDirectDisplay;
-}
-
-/*
- * displayScreenBounds
- *  Return the bounds of a particular display.
- */
-static CGRect
-displayScreenBounds(CGDirectDisplayID id)
-{
-    CGRect frame;
-
-    frame = CGDisplayBounds(id);
-
-    /* Remove menubar to help standard X11 window managers. */
-
-    if (frame.origin.x == 0 && frame.origin.y == 0)
-    {
-        frame.origin.y += aquaMenuBarHeight;
-        frame.size.height -= aquaMenuBarHeight;
-    }
-
-    return frame;
-}
-
-/*
- * xprAddPseudoramiXScreens
- *  Add a single virtual screen encompassing all the physical screens
- *  with PseudoramiX.
- */
-static void
-xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height)
-{
-    CGDisplayCount i, displayCount;
-    CGDirectDisplayID *displayList = NULL;
-    CGRect unionRect = CGRectNull, frame;
-
-    // Find all the CoreGraphics displays
-    CGGetActiveDisplayList(0, NULL, &displayCount);
-    displayList = xalloc(displayCount * sizeof(CGDirectDisplayID));
-    CGGetActiveDisplayList(displayCount, displayList, &displayCount);
-
-    /* Get the union of all screens */
-    for (i = 0; i < displayCount; i++)
-    {
-        CGDirectDisplayID dpy = displayList[i];
-        frame = displayScreenBounds(dpy);
-        unionRect = CGRectUnion(unionRect, frame);
-    }
-
-    /* Use unionRect as the screen size for the X server. */
-    *x = unionRect.origin.x;
-    *y = unionRect.origin.y;
-    *width = unionRect.size.width;
-    *height = unionRect.size.height;
-
-    /* Tell PseudoramiX about the real screens. */
-    for (i = 0; i < displayCount; i++)
-    {
-        CGDirectDisplayID dpy = displayList[i];
-
-        frame = displayScreenBounds(dpy);
-
-	/*        ErrorF("PseudoramiX screen %d added: %dx%d @ (%d,%d).\n", i,
-               (int)frame.size.width, (int)frame.size.height,
-               (int)frame.origin.x, (int)frame.origin.y); */
-
-        frame.origin.x -= unionRect.origin.x;
-        frame.origin.y -= unionRect.origin.y;
-
-	/*        ErrorF("PseudoramiX screen %d placed at X11 coordinate (%d,%d).\n",
-		  i, (int)frame.origin.x, (int)frame.origin.y); */
-
-        PseudoramiXAddScreen(frame.origin.x, frame.origin.y,
-                             frame.size.width, frame.size.height);
-    }
-
-    xfree(displayList);
-}
-
-/*
- * xprDisplayInit
- *  Find number of CoreGraphics displays and initialize Xplugin.
- */
-static void
-xprDisplayInit(void)
-{
-    CGDisplayCount displayCount;
-
-    //    ErrorF("Display mode: Rootless Quartz -- Xplugin implementation\n");
-
-    CGGetActiveDisplayList(0, NULL, &displayCount);
-
-    /* With PseudoramiX, the X server only sees one screen; only PseudoramiX
-       itself knows about all of the screens. */
-
-    if (noPseudoramiXExtension)
-        darwinScreensFound = displayCount;
-    else
-        darwinScreensFound =  1;
-
-    if (xp_init(XP_BACKGROUND_EVENTS | XP_NO_DEFERRED_UPDATES) != Success)
-        FatalError("Could not initialize the Xplugin library.");
-
-    xp_select_events(XP_EVENT_DISPLAY_CHANGED
-                     | XP_EVENT_WINDOW_STATE_CHANGED
-                     | XP_EVENT_WINDOW_MOVED
-                     | XP_EVENT_SURFACE_CHANGED
-                     | XP_EVENT_SURFACE_DESTROYED,
-                     eventHandler, NULL);
-
-    AppleDRIExtensionInit();
-    xprAppleWMInit();
-}
-
-/*
- * xprAddScreen
- *  Init the framebuffer and record pixmap parameters for the screen.
- */
-static Bool
-xprAddScreen(int index, ScreenPtr pScreen)
-{
-    DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen);
-
-    /* If no specific depth chosen, look for the depth of the main display.
-       Else if 16bpp specified, use that. Else use 32bpp. */
-
-    dfb->colorType = TrueColor;
-    dfb->bitsPerComponent = 8;
-    dfb->bitsPerPixel = 32;
-    dfb->colorBitsPerPixel = 24;
-
-    if (darwinDesiredDepth == -1)
-    {
-        dfb->bitsPerComponent = CGDisplayBitsPerSample(kCGDirectMainDisplay);
-        dfb->bitsPerPixel = CGDisplayBitsPerPixel(kCGDirectMainDisplay);
-        dfb->colorBitsPerPixel =
-                CGDisplaySamplesPerPixel(kCGDirectMainDisplay) *
-                dfb->bitsPerComponent;
-    }
-    else if (darwinDesiredDepth == 15)
-    {
-        dfb->bitsPerComponent = 5;
-        dfb->bitsPerPixel = 16;
-        dfb->colorBitsPerPixel = 15;
-    }
-    else if (darwinDesiredDepth == 8)
-    {
-        dfb->colorType = PseudoColor;
-        dfb->bitsPerComponent = 8;
-        dfb->bitsPerPixel = 8;
-        dfb->colorBitsPerPixel = 8;
-    }
-
-    if (noPseudoramiXExtension)
-    {
-        CGDirectDisplayID dpy;
-        CGRect frame;
-
-        dpy = displayAtIndex(index);
-
-        frame = displayScreenBounds(dpy);
-
-        dfb->x = frame.origin.x;
-        dfb->y = frame.origin.y;
-        dfb->width =  frame.size.width;
-        dfb->height = frame.size.height;
-    }
-    else
-    {
-        xprAddPseudoramiXScreens(&dfb->x, &dfb->y, &dfb->width, &dfb->height);
-    }
-
-    /* Passing zero width (pitch) makes miCreateScreenResources set the
-       screen pixmap to the framebuffer pointer, i.e. NULL. The generic
-       rootless code takes care of making this work. */
-    dfb->pitch = 0;
-    dfb->framebuffer = NULL;
-
-    DRIScreenInit(pScreen);
-
-    return TRUE;
-}
-
-/*
- * xprSetupScreen
- *  Setup the screen for rootless access.
- */
-static Bool
-xprSetupScreen(int index, ScreenPtr pScreen)
-{
-    // Add alpha protecting replacements for fb screen functions
-
-#ifdef RENDER
-    {
-        PictureScreenPtr ps = GetPictureScreen(pScreen);
-        ps->Composite = SafeAlphaComposite;
-    }
-#endif /* RENDER */
-
-    // Initialize accelerated rootless drawing
-    // Note that this must be done before DamageSetup().
-    RootlessAccelInit(pScreen);
-
-#ifdef DAMAGE
-    // The Damage extension needs to wrap underneath the
-    // generic rootless layer, so do it now.
-    if (!DamageSetup(pScreen))
-        return FALSE;
-#endif
-
-    // Initialize generic rootless code
-    if (!xprInit(pScreen))
-        return FALSE;
-
-    return DRIFinishScreenInit(pScreen);
-}
-
-/*
- * xprUpdateScreen
- *  Update screen after configuation change.
- */
-static void
-xprUpdateScreen(ScreenPtr pScreen)
-{
-    rootlessGlobalOffsetX = darwinMainScreenX;
-    rootlessGlobalOffsetY = darwinMainScreenY;
-
-    AppleWMSetScreenOrigin(WindowTable[pScreen->myNum]);
-
-    RootlessRepositionWindows(pScreen);
-    RootlessUpdateScreenPixmap(pScreen);
-}
-
-/*
- * xprInitInput
- *  Finalize xpr specific setup.
- */
-static void
-xprInitInput(int argc, char **argv)
-{
-    int i;
-
-    rootlessGlobalOffsetX = darwinMainScreenX;
-    rootlessGlobalOffsetY = darwinMainScreenY;
-
-    for (i = 0; i < screenInfo.numScreens; i++)
-        AppleWMSetScreenOrigin(WindowTable[i]);
-}
-
-/*
- * Quartz display mode function list.
- */
-static QuartzModeProcsRec xprModeProcs = {
-    xprDisplayInit,
-    xprAddScreen,
-    xprSetupScreen,
-    xprInitInput,
-    QuartzInitCursor,
-    NULL,               // No need to update cursor
-    QuartzSuspendXCursor,
-    QuartzResumeXCursor,
-    NULL,               // No capture or release in rootless mode
-    NULL,
-    NULL,               // Xplugin sends screen change events directly
-    xprAddPseudoramiXScreens,
-    xprUpdateScreen,
-    xprIsX11Window,
-    xprHideWindows,
-    RootlessFrameForWindow,
-    TopLevelParent,
-    DRICreateSurface,
-    DRIDestroySurface
-};
-
-/*
- * QuartzModeBundleInit
- *  Initialize the display mode bundle after loading.
- */
-Bool
-QuartzModeBundleInit(void)
-{
-    quartzProcs = &xprModeProcs;
-    quartzOpenGLBundle = xprOpenGLBundle;
-    return TRUE;
-}
diff --git a/hw/xquartz/Makefile.am b/hw/xquartz/Makefile.am
new file mode 100644
index 0000000..725d20f
--- /dev/null
+++ b/hw/xquartz/Makefile.am
@@ -0,0 +1,50 @@
+noinst_LTLIBRARIES = libXquartz.la
+AM_CFLAGS = $(XSERVER_CFLAGS) $(DIX_CFLAGS)
+AM_CPPFLAGS = \
+	-DBUILD_DATE=\"$(BUILD_DATE)\" \
+	-DINXQUARTZ \
+	-DUSE_NEW_CLUT \
+	-DXFree86Server \
+	-I$(top_srcdir)/miext/rootless
+
+if X11APP
+X11APP_SUBDIRS = bundle
+endif
+
+SUBDIRS = . xpr $(X11APP_SUBDIRS)
+DIST_SUBDIRS = xpr bundle
+
+libXquartz_la_SOURCES = \
+	$(top_srcdir)/fb/fbcmap.c \
+	$(top_srcdir)/mi/miinitext.c \
+	X11Application.m \
+	X11Controller.m \
+	applewm.c \
+	darwin.c \
+	darwinEvents.c \
+	darwinKeyboard.c \
+	darwinXinput.c \
+	keysym2ucs.c \
+	pseudoramiX.c \
+	quartz.c \
+	quartzAudio.c \
+	quartzCocoa.m \
+	quartzKeyboard.c \
+	quartzPasteboard.c \
+	quartzStartup.c
+
+EXTRA_DIST = \
+	X11Application.h \
+	X11Controller.h \
+	applewmExt.h \
+	darwinClut8.h \
+	darwin.h \
+	darwinKeyboard.h \
+	keysym2ucs.h \
+	pseudoramiX.h \
+	quartzAudio.h \
+	quartzCommon.h \
+	quartzCursor.c \
+	quartzCursor.h \
+	quartz.h \
+	quartzPasteboard.h
diff --git a/hw/xquartz/X11Application.h b/hw/xquartz/X11Application.h
new file mode 100644
index 0000000..8615657
--- /dev/null
+++ b/hw/xquartz/X11Application.h
@@ -0,0 +1,103 @@
+/* X11Application.h -- subclass of NSApplication to multiplex events
+
+   Copyright (c) 2002-2007 Apple Inc. 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 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 X11APPLICATION_H
+#define X11APPLICATION_H 1
+
+#if __OBJC__
+
+#import <Cocoa/Cocoa.h>
+#import "X11Controller.h"
+
+ at interface X11Application : NSApplication {
+    X11Controller *_controller;
+
+    unsigned int _x_active :1;
+}
+
+- (void) set_controller:controller;
+- (void) set_window_menu:(NSArray *)list;
+
+- (int) prefs_get_integer:(NSString *)key default:(int)def;
+- (const char *) prefs_get_string:(NSString *)key default:(const char *)def;
+- (float) prefs_get_float:(NSString *)key default:(float)def;
+- (int) prefs_get_boolean:(NSString *)key default:(int)def;
+- (NSArray *) prefs_get_array:(NSString *)key;
+- (void) prefs_set_integer:(NSString *)key value:(int)value;
+- (void) prefs_set_float:(NSString *)key value:(float)value;
+- (void) prefs_set_boolean:(NSString *)key value:(int)value;
+- (void) prefs_set_array:(NSString *)key value:(NSArray *)value;
+- (void) prefs_set_string:(NSString *)key value:(NSString *)value;
+- (void) prefs_synchronize;
+
+- (BOOL) x_active;
+
+ at end
+
+extern X11Application *X11App;
+
+#endif /* __OBJC__ */
+
+extern void X11ApplicationSetWindowMenu (int nitems, const char **items,
+					 const char *shortcuts);
+extern void X11ApplicationSetWindowMenuCheck (int idx);
+extern void X11ApplicationSetFrontProcess (void);
+extern void X11ApplicationSetCanQuit (int state);
+extern void X11ApplicationServerReady (void);
+extern void X11ApplicationShowHideMenubar (int state);
+
+extern void X11ApplicationMain (int argc, const char *argv[],
+				void (*server_thread) (void *),
+				void *server_arg);
+
+extern int X11EnableKeyEquivalents;
+extern int quartzHasRoot, quartzEnableRootless;
+
+#define APP_PREFS "org.x.X11"
+
+#define PREFS_APPSMENU		"apps_menu"
+#define PREFS_FAKEBUTTONS	"enable_fake_buttons"
+#define PREFS_SYSBEEP		"enable_system_beep"
+#define PREFS_KEYEQUIVS		"enable_key_equivalents"
+#define PREFS_KEYMAP_FILE	"keymap_file"
+#define PREFS_SYNC_KEYMAP	"sync_keymap"
+#define PREFS_DEPTH		"depth"
+#define PREFS_NO_AUTH		"no_auth"
+#define PREFS_NO_TCP		"nolisten_tcp"
+#define PREFS_DONE_XINIT_CHECK	"done_xinit_check"
+#define PREFS_NO_QUIT_ALERT	"no_quit_alert"
+#define PREFS_FAKE_BUTTON2	"fake_button2"
+#define PREFS_FAKE_BUTTON3	"fake_button3"
+#define PREFS_ROOTLESS		"rootless"
+#define PREFS_FULLSCREEN_HOTKEYS "fullscreen_hotkeys"
+#define PREFS_SWAP_ALT_META	"swap_alt_meta"
+#define PREFS_XP_OPTIONS	"xp_options"
+#define PREFS_ENABLE_STEREO	"enable_stereo"
+
+#endif /* X11APPLICATION_H */
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
new file mode 100644
index 0000000..3e37dd4
--- /dev/null
+++ b/hw/xquartz/X11Application.m
@@ -0,0 +1,916 @@
+/* X11Application.m -- subclass of NSApplication to multiplex events
+ 
+ Copyright (c) 2002-2007 Apple Inc.
+ 
+ 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. */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "quartzCommon.h"
+
+#import "X11Application.h"
+#include <Carbon/Carbon.h>
+
+/* ouch! */
+#define BOOL X_BOOL
+# include "darwin.h"
+# include "quartz.h"
+# define _APPLEWM_SERVER_
+# include "X11/extensions/applewm.h"
+# include "micmap.h"
+#undef BOOL
+
+#include <mach/mach.h>
+#include <unistd.h>
+#include <pthread.h>
+
+#include "rootlessCommon.h"
+
+WindowPtr xprGetXWindowFromAppKit(int windowNumber); // xpr/xprFrame.c
+
+#define DEFAULTS_FILE "/usr/X11/lib/X11/xserver/Xquartz.plist"
+
+int X11EnableKeyEquivalents = TRUE;
+int quartzHasRoot = FALSE, quartzEnableRootless = TRUE;
+
+extern int darwinFakeButtons, input_check_flag;
+extern Bool enable_stereo; 
+
+extern xEvent *darwinEvents;
+
+X11Application *X11App;
+
+#define ALL_KEY_MASKS (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask)
+
+ at implementation X11Application
+
+typedef struct message_struct message;
+struct message_struct {
+    mach_msg_header_t hdr;
+    SEL selector;
+    NSObject *arg;
+};
+
+static mach_port_t _port;
+
+static void send_nsevent (NSEventType type, NSEvent *e);
+
+/* Quartz mode initialization routine. This is often dynamically loaded
+ but is statically linked into this X server. */
+extern Bool QuartzModeBundleInit(void);
+
+static void init_ports (void) {
+    kern_return_t r;
+    NSPort *p;
+	
+    if (_port != MACH_PORT_NULL) return;
+	
+    r = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, &_port);
+    if (r != KERN_SUCCESS) return;
+	
+    p = [NSMachPort portWithMachPort:_port];
+    [p setDelegate:NSApp];
+    [p scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
+}
+
+static void message_kit_thread (SEL selector, NSObject *arg) {
+    message msg;
+    kern_return_t r;
+	
+    msg.hdr.msgh_bits = MACH_MSGH_BITS (MACH_MSG_TYPE_MAKE_SEND, 0);
+    msg.hdr.msgh_size = sizeof (msg);
+    msg.hdr.msgh_remote_port = _port;
+    msg.hdr.msgh_local_port = MACH_PORT_NULL;
+    msg.hdr.msgh_reserved = 0;
+    msg.hdr.msgh_id = 0;
+	
+    msg.selector = selector;
+    msg.arg = [arg retain];
+	
+    r = mach_msg (&msg.hdr, MACH_SEND_MSG, msg.hdr.msgh_size,
+		  0, MACH_PORT_NULL, 0, MACH_PORT_NULL);
+    if (r != KERN_SUCCESS)
+		ErrorF("%s: mach_msg failed: %x\n", __FUNCTION__, r);
+}
+
+- (void) handleMachMessage:(void *)_msg {
+    message *msg = _msg;
+	
+    [self performSelector:msg->selector withObject:msg->arg];
+    [msg->arg release];
+}
+
+- (void) set_controller:obj {
+    if (_controller == nil) _controller = [obj retain];
+}
+
+- (void) dealloc {
+    if (_controller != nil) [_controller release];
+	
+    if (_port != MACH_PORT_NULL)
+		mach_port_deallocate (mach_task_self (), _port);
+	
+    [super dealloc];
+}
+
+- (void) orderFrontStandardAboutPanel: (id) sender {
+    NSMutableDictionary *dict;
+    NSDictionary *infoDict;
+    NSString *tem;
+	
+    dict = [NSMutableDictionary dictionaryWithCapacity:2];
+    infoDict = [[NSBundle mainBundle] infoDictionary];
+	
+    [dict setObject: NSLocalizedString (@"The X Window System", @"About panel")
+			 forKey:@"ApplicationName"];
+	
+    tem = [infoDict objectForKey:@"CFBundleShortVersionString"];
+	
+    [dict setObject:[NSString stringWithFormat:@"X11.app %@ - X.org X11R7.3", tem] 
+	  forKey:@"ApplicationVersion"];
+	
+    [self orderFrontStandardAboutPanelWithOptions: dict];
+}
+
+- (void) activateX:(BOOL)state {
+    /* Create a TSM document that supports full Unicode input, and
+	 have it activated while X is active (unless using the old
+	 keymapping files) */
+    static TSMDocumentID x11_document;
+	
+    if (state) {
+      QuartzMessageServerThread (kXDarwinActivate, 0);
+      
+      if (!_x_active) {
+	if (x11_document == 0 && darwinKeymapFile == NULL) {
+	  OSType types[1];
+	  types[0] = kUnicodeDocument;
+	  NewTSMDocument (1, types, &x11_document, 0);
+	}
+	
+	if (x11_document != 0)	ActivateTSMDocument (x11_document);
+      }
+    } else {
+      QuartzMessageServerThread (kXDarwinDeactivate, 0);
+      
+      if (_x_active && x11_document != 0)
+	DeactivateTSMDocument (x11_document);
+    }
+    
+    _x_active = state;
+}
+
+- (void) became_key:(NSWindow *)win {
+    [self activateX:NO];
+}
+
+- (void) sendEvent:(NSEvent *)e {
+  NSEventType type;
+  BOOL for_appkit, for_x;
+  
+  type = [e type];
+  
+  /* By default pass down the responder chain and to X. */
+  for_appkit = YES;
+  for_x = YES;
+  
+  switch (type) {
+  case NSLeftMouseDown: case NSRightMouseDown: case NSOtherMouseDown:
+  case NSLeftMouseUp: case NSRightMouseUp: case NSOtherMouseUp:
+    if ([e window] != nil) {
+      /* Pointer event has an (AppKit) window. Probably something for the kit. */
+      for_x = NO;
+      if (_x_active) [self activateX:NO];
+    } else if ([self modalWindow] == nil) {
+      /* Must be an X window. Tell appkit it doesn't have focus. */
+      WindowPtr pWin = xprGetXWindowFromAppKit([e windowNumber]);
+      if (pWin) RootlessReorderWindow(pWin);
+      for_appkit = NO;
+      
+      if ([self isActive]) {
+	[self deactivate];
+	
+	if (!_x_active && quartzProcs->IsX11Window([e window],
+						   [e windowNumber]))
+	  [self activateX:YES];
+      }
+    }
+    break;
+      
+  case NSKeyDown: case NSKeyUp:
+    if (_x_active) {
+      static int swallow_up;
+      
+      /* No kit window is focused, so send it to X. */
+      for_appkit = NO;
+      if (type == NSKeyDown) {
+	/* Before that though, see if there are any global
+	   shortcuts bound to it. */
+	
+	if (X11EnableKeyEquivalents
+	    && [[self mainMenu] performKeyEquivalent:e]) {
+	  swallow_up = [e keyCode];
+	  for_x = NO;
+	} else if (!quartzEnableRootless
+		   && ([e modifierFlags] & ALL_KEY_MASKS)
+		   == (NSCommandKeyMask | NSAlternateKeyMask)
+		   && ([e keyCode] == 0 /*a*/
+		    || [e keyCode] == 53 /*Esc*/)) {
+	  swallow_up = 0;
+	  for_x = NO;
+#ifdef DARWIN_DDX_MISSING
+	  QuartzMessageServerThread (kXDarwinToggleFullscreen, 0);
+#endif
+	}
+      } else {
+	/* If we saw a key equivalent on the down, don't pass
+	   the up through to X. */
+	
+	if (swallow_up != 0 && [e keyCode] == swallow_up) {
+	  swallow_up = 0;
+	  for_x = NO;
+	}
+      }
+    } else for_x = NO;
+    break;
+    
+  case NSFlagsChanged:
+    /* For the l33t X users who remap modifier keys to normal keysyms. */
+    if (!_x_active) for_x = NO;
+    break;
+    
+  case NSAppKitDefined:
+    switch ([e subtype]) {
+    case NSApplicationActivatedEventType:
+      for_x = NO;
+      if ([self modalWindow] == nil) {
+	for_appkit = NO;
+	
+	/* FIXME: hack to avoid having to pass the event to appkit,
+	   which would cause it to raise one of its windows. */
+	_appFlags._active = YES;
+	
+	[self activateX:YES];
+	if ([e data2] & 0x10) X11ApplicationSetFrontProcess();
+      }
+      break;
+      
+    case 18: /* ApplicationDidReactivate */
+      if (quartzHasRoot) for_appkit = NO;
+      break;
+      
+    case NSApplicationDeactivatedEventType:
+      for_x = NO;
+      [self activateX:NO];
+      break;
+    }
+    break;
+    
+  default: break; /* for gcc */
+  }
+  
+  if (for_appkit) [super sendEvent:e];
+  
+  if (for_x) send_nsevent (type, e);
+}
+
+- (void) set_window_menu:(NSArray *)list {
+    [_controller set_window_menu:list];
+}
+
+- (void) set_window_menu_check:(NSNumber *)n {
+    [_controller set_window_menu_check:n];
+}
+
+- (void) set_apps_menu:(NSArray *)list {
+    [_controller set_apps_menu:list];
+}
+
+- (void) set_front_process:unused {
+    QuartzMessageServerThread(kXDarwinBringAllToFront, 0);
+}
+
+- (void) set_can_quit:(NSNumber *)state {
+    [_controller set_can_quit:[state boolValue]];
+}
+
+- (void) server_ready:unused {
+    [_controller server_ready];
+}
+
+- (void) show_hide_menubar:(NSNumber *)state {
+    if ([state boolValue]) ShowMenuBar ();
+    else HideMenuBar ();
+}
+
+
+/* user preferences */
+
+/* Note that these functions only work for arrays whose elements
+ can be toll-free-bridged between NS and CF worlds. */
+
+static const void *cfretain (CFAllocatorRef a, const void *b) {
+    return CFRetain (b);
+}
+
+static void cfrelease (CFAllocatorRef a, const void *b) {
+    CFRelease (b);
+}
+
+static CFMutableArrayRef nsarray_to_cfarray (NSArray *in) {
+    CFMutableArrayRef out;
+    CFArrayCallBacks cb;
+    NSObject *ns;
+    const CFTypeRef *cf;
+    int i, count;
+	
+    memset (&cb, 0, sizeof (cb));
+    cb.version = 0;
+    cb.retain = cfretain;
+    cb.release = cfrelease;
+	
+    count = [in count];
+    out = CFArrayCreateMutable (NULL, count, &cb);
+	
+    for (i = 0; i < count; i++) {
+      ns = [in objectAtIndex:i];
+      
+      if ([ns isKindOfClass:[NSArray class]])
+	cf = (CFTypeRef) nsarray_to_cfarray ((NSArray *) ns);
+      else
+	cf = CFRetain ((CFTypeRef) ns);
+      
+      CFArrayAppendValue (out, cf);
+      CFRelease (cf);
+    }
+    
+    return out;
+}
+
+static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
+    NSMutableArray *out;
+    const CFTypeRef *cf;
+    NSObject *ns;
+    int i, count;
+	
+    count = CFArrayGetCount (in);
+    out = [[NSMutableArray alloc] initWithCapacity:count];
+	
+    for (i = 0; i < count; i++) {
+      cf = CFArrayGetValueAtIndex (in, i);
+		
+      if (CFGetTypeID (cf) == CFArrayGetTypeID ())
+	ns = cfarray_to_nsarray ((CFArrayRef) cf);
+      else
+	ns = [(id)cf retain];
+      
+      [out addObject:ns];
+      [ns release];
+    }
+    
+    return out;
+}
+
+- (CFPropertyListRef) prefs_get:(NSString *)key {
+    CFPropertyListRef value;
+	
+    value = CFPreferencesCopyAppValue ((CFStringRef) key, CFSTR (APP_PREFS));
+	
+    if (value == NULL) {
+      static CFDictionaryRef defaults;
+      
+      if (defaults == NULL) {
+	CFStringRef error = NULL;
+	CFDataRef data;
+	CFURLRef url;
+	SInt32 error_code;
+	
+	url = (CFURLCreateFromFileSystemRepresentation
+	       (NULL, (unsigned char *)DEFAULTS_FILE, strlen (DEFAULTS_FILE), false));
+	if (CFURLCreateDataAndPropertiesFromResource (NULL, url, &data,
+						      NULL, NULL, &error_code)) {
+	  defaults = (CFPropertyListCreateFromXMLData
+		      (NULL, data, kCFPropertyListMutableContainersAndLeaves, &error));
+	  if (error != NULL) CFRelease (error);
+	  CFRelease (data);
+	}
+	CFRelease (url);
+			
+	if (defaults != NULL) {
+	  NSMutableArray *apps, *elt;
+	  int count, i;
+	  NSString *name, *nname;
+	  
+	  /* Localize the names in the default apps menu. */
+	  
+	  apps = [(NSDictionary *)defaults objectForKey:@PREFS_APPSMENU];
+	  if (apps != nil) {
+	    count = [apps count];
+	    for (i = 0; i < count; i++)	{
+	      elt = [apps objectAtIndex:i];
+	      if (elt != nil && [elt isKindOfClass:[NSArray class]]) {
+		name = [elt objectAtIndex:0];
+		if (name != nil) {
+		  nname = NSLocalizedString (name, nil);
+		  if (nname != nil && nname != name)
+		    [elt replaceObjectAtIndex:0 withObject:nname];
+		}
+	      }
+	    }
+	  }
+	}
+      }
+		
+      if (defaults != NULL) value = CFDictionaryGetValue (defaults, key);
+      if (value != NULL) CFRetain (value);
+    }
+	
+    return value;
+}
+
+- (int) prefs_get_integer:(NSString *)key default:(int)def {
+  CFPropertyListRef value;
+  int ret;
+  
+  value = [self prefs_get:key];
+  
+  if (value != NULL && CFGetTypeID (value) == CFNumberGetTypeID ())
+    CFNumberGetValue (value, kCFNumberIntType, &ret);
+  else if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ())
+    ret = CFStringGetIntValue (value);
+  else
+    ret = def;
+  
+  if (value != NULL) CFRelease (value);
+  
+  return ret;
+}
+
+- (const char *) prefs_get_string:(NSString *)key default:(const char *)def {
+  CFPropertyListRef value;
+  const char *ret = NULL;
+  
+  value = [self prefs_get:key];
+  
+  if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ()) {
+    NSString *s = (NSString *) value;
+    
+    ret = [s UTF8String];
+  }
+  
+  if (value != NULL) CFRelease (value);
+  
+  return ret != NULL ? ret : def;
+}
+
+- (float) prefs_get_float:(NSString *)key default:(float)def {
+  CFPropertyListRef value;
+  float ret = def;
+  
+  value = [self prefs_get:key];
+  
+  if (value != NULL
+      && CFGetTypeID (value) == CFNumberGetTypeID ()
+      && CFNumberIsFloatType (value)) 
+    CFNumberGetValue (value, kCFNumberFloatType, &ret);
+  else if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ())
+    ret = CFStringGetDoubleValue (value);
+	
+  if (value != NULL) CFRelease (value);
+  
+  return ret;
+}
+
+- (int) prefs_get_boolean:(NSString *)key default:(int)def {
+  CFPropertyListRef value;
+  int ret = def;
+  
+  value = [self prefs_get:key];
+  
+  if (value != NULL) {
+    if (CFGetTypeID (value) == CFNumberGetTypeID ())
+      CFNumberGetValue (value, kCFNumberIntType, &ret);
+    else if (CFGetTypeID (value) == CFBooleanGetTypeID ())
+      ret = CFBooleanGetValue (value);
+    else if (CFGetTypeID (value) == CFStringGetTypeID ()) {
+      const char *tem = [(NSString *) value UTF8String];
+      if (strcasecmp (tem, "true") == 0 || strcasecmp (tem, "yes") == 0)
+	ret = YES;
+      else
+	ret = NO;
+    }
+    
+    CFRelease (value);
+  }
+  return ret;
+}
+
+- (NSArray *) prefs_get_array:(NSString *)key {
+  NSArray *ret = nil;
+  CFPropertyListRef value;
+  
+  value = [self prefs_get:key];
+  
+  if (value != NULL) {
+    if (CFGetTypeID (value) == CFArrayGetTypeID ())
+      ret = [cfarray_to_nsarray (value) autorelease];
+    
+    CFRelease (value);
+  }
+  
+  return ret;
+}
+
+- (void) prefs_set_integer:(NSString *)key value:(int)value {
+    CFNumberRef x;
+	
+    x = CFNumberCreate (NULL, kCFNumberIntType, &value);
+	
+    CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) x, CFSTR (APP_PREFS),
+			   kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+	
+    CFRelease (x);
+}
+
+- (void) prefs_set_float:(NSString *)key value:(float)value {
+    CFNumberRef x;
+	
+    x = CFNumberCreate (NULL, kCFNumberFloatType, &value);
+	
+    CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) x, CFSTR (APP_PREFS),
+			   kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+	
+    CFRelease (x);
+}
+
+- (void) prefs_set_boolean:(NSString *)key value:(int)value {
+  CFPreferencesSetValue ((CFStringRef) key,
+			 (CFTypeRef) value ? kCFBooleanTrue
+			 : kCFBooleanFalse, CFSTR (APP_PREFS),
+			 kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+  
+}
+
+- (void) prefs_set_array:(NSString *)key value:(NSArray *)value {
+  CFArrayRef cfarray;
+  
+  cfarray = nsarray_to_cfarray (value);
+  CFPreferencesSetValue ((CFStringRef) key,
+			 (CFTypeRef) cfarray,
+			 CFSTR (APP_PREFS),
+			 kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+  CFRelease (cfarray);
+}
+
+- (void) prefs_set_string:(NSString *)key value:(NSString *)value {
+  CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) value,
+			 CFSTR (APP_PREFS), kCFPreferencesCurrentUser,
+			 kCFPreferencesAnyHost);
+}
+
+- (void) prefs_synchronize {
+    CFPreferencesAppSynchronize (kCFPreferencesCurrentApplication);
+}
+
+- (void) read_defaults
+{
+    const char *tem;
+	
+    quartzUseSysBeep = [self prefs_get_boolean:@PREFS_SYSBEEP
+                        default:quartzUseSysBeep];
+    quartzEnableRootless = [self prefs_get_boolean:@PREFS_ROOTLESS
+                        default:quartzEnableRootless];
+#ifdef DARWIN_DDX_MISSING
+    quartzFullscreenDisableHotkeys = ![self prefs_get_boolean:
+					      @PREFS_FULLSCREEN_HOTKEYS default:
+					      !quartzFullscreenDisableHotkeys];
+    quartzXpluginOptions = [self prefs_get_integer:@PREFS_XP_OPTIONS
+                            default:quartzXpluginOptions];
+#endif
+    darwinFakeButtons = [self prefs_get_boolean:@PREFS_FAKEBUTTONS
+                         default:darwinFakeButtons];
+    if (darwinFakeButtons) {
+      const char *fake2, *fake3;
+      
+      fake2 = [self prefs_get_string:@PREFS_FAKE_BUTTON2 default:NULL];
+      fake3 = [self prefs_get_string:@PREFS_FAKE_BUTTON3 default:NULL];
+      
+      if (fake2 != NULL) darwinFakeMouse2Mask = DarwinParseModifierList(fake2);
+      if (fake3 != NULL) darwinFakeMouse3Mask = DarwinParseModifierList(fake3);
+    }
+	
+    X11EnableKeyEquivalents = [self prefs_get_boolean:@PREFS_KEYEQUIVS
+                               default:X11EnableKeyEquivalents];
+	
+    darwinSyncKeymap = [self prefs_get_boolean:@PREFS_SYNC_KEYMAP
+                        default:darwinSyncKeymap];
+	
+    tem = [self prefs_get_string:@PREFS_KEYMAP_FILE default:NULL];
+    if (tem != NULL) darwinKeymapFile = strdup (tem);
+    else             darwinKeymapFile = NULL;
+	
+    darwinDesiredDepth = [self prefs_get_integer:@PREFS_DEPTH
+                          default:darwinDesiredDepth];
+	
+    enable_stereo = [self prefs_get_boolean:@PREFS_ENABLE_STEREO
+                     default:false];
+}
+
+/* This will end up at the end of the responder chain. */
+- (void) copy:sender {
+  QuartzMessageServerThread (kXDarwinPasteboardNotify, 1,
+			     AppleWMCopyToPasteboard);
+}
+
+- (BOOL) x_active {
+    return _x_active;
+}
+
+ at end
+
+static NSArray *
+array_with_strings_and_numbers (int nitems, const char **items,
+				const char *numbers) {
+  NSMutableArray *array, *subarray;
+  NSString *string, *number;
+  int i;
+	
+  /* (Can't autorelease on the X server thread) */
+  
+  array = [[NSMutableArray alloc] initWithCapacity:nitems];
+  
+  for (i = 0; i < nitems; i++) {
+    subarray = [[NSMutableArray alloc] initWithCapacity:2];
+    
+    string = [[NSString alloc] initWithUTF8String:items[i]];
+    [subarray addObject:string];
+    [string release];
+    
+    if (numbers[i] != 0) {
+      number = [[NSString alloc] initWithFormat:@"%d", numbers[i]];
+      [subarray addObject:number];
+      [number release];
+    } else
+      [subarray addObject:@""];
+    
+    [array addObject:subarray];
+    [subarray release];
+  }
+  
+  return array;
+}
+
+void X11ApplicationSetWindowMenu (int nitems, const char **items,
+				  const char *shortcuts) {
+  NSArray *array;
+  array = array_with_strings_and_numbers (nitems, items, shortcuts);
+  
+  /* Send the array of strings over to the appkit thread */
+  
+  message_kit_thread (@selector (set_window_menu:), array);
+  [array release];
+}
+
+void X11ApplicationSetWindowMenuCheck (int idx) {
+  NSNumber *n;
+  
+  n = [[NSNumber alloc] initWithInt:idx];
+  
+  message_kit_thread (@selector (set_window_menu_check:), n);
+  
+  [n release];
+}
+
+void X11ApplicationSetFrontProcess (void) {
+    message_kit_thread (@selector (set_front_process:), nil);
+}
+
+void X11ApplicationSetCanQuit (int state) {
+    NSNumber *n;
+	
+    n = [[NSNumber alloc] initWithBool:state];
+	
+    message_kit_thread (@selector (set_can_quit:), n);
+	
+    [n release];
+}
+
+void X11ApplicationServerReady (void) {
+    message_kit_thread (@selector (server_ready:), nil);
+}
+
+void X11ApplicationShowHideMenubar (int state) {
+    NSNumber *n;
+	
+    n = [[NSNumber alloc] initWithBool:state];
+	
+    message_kit_thread (@selector (show_hide_menubar:), n);
+	
+    [n release];
+}
+
+static void * create_thread (void *func, void *arg) {
+    pthread_attr_t attr;
+    pthread_t tid;
+	
+    pthread_attr_init (&attr);
+    pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM);
+    pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
+    pthread_create (&tid, &attr, func, arg);
+    pthread_attr_destroy (&attr);
+	
+    return (void *) tid;
+}
+
+static void check_xinitrc (void) {
+    char *tem, buf[1024];
+    NSString *msg;
+	
+    if ([X11App prefs_get_boolean:@PREFS_DONE_XINIT_CHECK default:NO])
+		return;
+	
+    tem = getenv ("HOME");
+    if (tem == NULL) goto done;
+	
+    snprintf (buf, sizeof (buf), "%s/.xinitrc", tem);
+    if (access (buf, F_OK) != 0)
+		goto done;
+	
+    /* FIXME: put localized strings into Resources/English.lproj */
+	
+    msg = NSLocalizedString (@"You have an existing ~/.xinitrc file.\n\n\
+Windows displayed by X11 applications may not have titlebars, or may look \
+different to windows displayed by native applications.\n\n\
+Would you like to move aside the existing file and use the standard X11 \
+environment?", @"Startup xinitrc dialog");
+	
+    if (NSRunAlertPanel (nil, msg, NSLocalizedString (@"Yes", @""),
+			 NSLocalizedString (@"No", @""), nil)
+	== NSAlertDefaultReturn) {
+      char buf2[1024];
+      int i = -1;
+      
+      snprintf (buf2, sizeof (buf2), "%s.old", buf);
+      
+      for (i = 1; access (buf2, F_OK) == 0; i++)
+	snprintf (buf2, sizeof (buf2), "%s.old.%d", buf, i);
+      
+      rename (buf, buf2);
+    }
+    
+ done:
+    [X11App prefs_set_boolean:@PREFS_DONE_XINIT_CHECK value:YES];
+    [X11App prefs_synchronize];
+}
+
+void X11ApplicationMain (int argc, const char *argv[],
+			 void (*server_thread) (void *), void *server_arg) {
+  NSAutoreleasePool *pool;
+  
+#ifdef DEBUG
+  while (access ("/tmp/x11-block", F_OK) == 0) sleep (1);
+#endif
+  
+  pool = [[NSAutoreleasePool alloc] init];
+  X11App = (X11Application *) [X11Application sharedApplication];
+  init_ports ();
+  [NSApp read_defaults];
+  [NSBundle loadNibNamed:@"main" owner:NSApp];
+  [[NSNotificationCenter defaultCenter] addObserver:NSApp
+					selector:@selector (became_key:)
+					name:NSWindowDidBecomeKeyNotification object:nil];
+  check_xinitrc ();
+	
+  /*
+   * The xpr Quartz mode is statically linked into this server.
+   * Initialize all the Quartz functions.
+   */
+  QuartzModeBundleInit();
+  
+  /* Calculate the height of the menubar so we can avoid it. */
+  aquaMenuBarHeight = NSHeight([[NSScreen mainScreen] frame]) -
+    NSMaxY([[NSScreen mainScreen] visibleFrame]);
+  
+  if (!create_thread (server_thread, server_arg)) {
+    ErrorF("can't create secondary thread\n");
+    exit (1);
+  }
+  
+  [NSApp run];
+  
+  /* not reached */
+}
+
+
+/* event conversion */
+
+static inline unsigned short
+convert_flags (unsigned int nsflags) {
+    unsigned int xflags = 0;
+	
+    if (nsflags == ~0) return 0xffff;
+	
+    if (nsflags & NSAlphaShiftKeyMask)	xflags |= LockMask;
+    if (nsflags & NSShiftKeyMask)	xflags |= ShiftMask;
+    if (nsflags & NSControlKeyMask)	xflags |= ControlMask;
+    if (nsflags & NSAlternateKeyMask)	xflags |= Mod1Mask;
+    if (nsflags & NSCommandKeyMask)	xflags |= Mod2Mask;
+    /* FIXME: secondaryfn? */
+	
+    return xflags;
+}
+
+
+// This code should probably be merged with that in XDarwin's XServer.m - BB
+static void send_nsevent (NSEventType type, NSEvent *e) {
+  //    static unsigned int button_state = 0;
+    NSRect screen;
+    NSPoint location;
+    NSWindow *window;
+    int pointer_x, pointer_y, ev_button, ev_type; 
+    //    int num_events=0, i=0, state;
+    xEvent xe;
+	
+    /* convert location to global top-left coordinates */
+    location = [e locationInWindow];
+    window = [e window];
+    screen = [[[NSScreen screens] objectAtIndex:0] frame];
+		
+    if (window != nil)	{
+      NSRect frame = [window frame];
+      pointer_x = location.x + frame.origin.x;
+      pointer_y = (((screen.origin.y + screen.size.height)
+		    - location.y) - frame.origin.y);
+    } else {
+      pointer_x = location.x;
+      pointer_y = (screen.origin.y + screen.size.height) - location.y;
+    }
+    
+    pointer_y -= aquaMenuBarHeight;
+    //    state = convert_flags ([e modifierFlags]);
+    
+    switch (type) {
+    case NSLeftMouseDown:    ev_button=1; ev_type=ButtonPress; goto handle_mouse;
+    case NSOtherMouseDown:   ev_button=2; ev_type=ButtonPress; goto handle_mouse;
+    case NSRightMouseDown:   ev_button=3; ev_type=ButtonPress; goto handle_mouse;
+    case NSLeftMouseUp:      ev_button=1; ev_type=ButtonRelease; goto handle_mouse;
+    case NSOtherMouseUp:     ev_button=2; ev_type=ButtonRelease; goto handle_mouse;
+    case NSRightMouseUp:     ev_button=3; ev_type=ButtonRelease; goto handle_mouse;
+    case NSLeftMouseDragged:  ev_button=1; ev_type=MotionNotify; goto handle_mouse;
+    case NSOtherMouseDragged: ev_button=2; ev_type=MotionNotify; goto handle_mouse;
+    case NSRightMouseDragged: ev_button=3; ev_type=MotionNotify; goto handle_mouse;
+    case NSMouseMoved: ev_button=0; ev_type=MotionNotify; goto handle_mouse;
+    handle_mouse:
+      
+      /* I'm not sure the below code is necessary or useful (-bb)
+	if(ev_type==ButtonPress) {
+	if (!quartzProcs->IsX11Window([e window], [e windowNumber])) {
+	  fprintf(stderr, "Dropping event because it's not a window\n");
+	  break;
+	}
+	button_state |= (1 << ev_button);
+	DarwinSendPointerEvents(ev_type, ev_button, pointer_x, pointer_y);
+      } else if (ev_type==ButtonRelease && (button_state & (1 << ev_button)) == 0) break;
+      */
+      DarwinSendPointerEvents(ev_type, ev_button, pointer_x, pointer_y);
+      break;
+    case NSScrollWheel: 
+      DarwinSendScrollEvents([e deltaY], pointer_x, pointer_y);
+      break;
+      
+    case NSKeyDown:  // do we need to translate these keyCodes?
+    case NSKeyUp:
+      DarwinSendKeyboardEvents((type == NSKeyDown)?KeyPress:KeyRelease, [e keyCode]);
+      break;
+
+    case NSFlagsChanged:
+      DarwinUpdateModKeys([e modifierFlags]);
+      break;
+    default: break; /* for gcc */
+    }	
+}
diff --git a/hw/xquartz/X11Controller.h b/hw/xquartz/X11Controller.h
new file mode 100644
index 0000000..f1399dc
--- /dev/null
+++ b/hw/xquartz/X11Controller.h
@@ -0,0 +1,85 @@
+/* X11Controller.h -- connect the IB ui
+
+   Copyright (c) 2002 Apple Computer, Inc. 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 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 X11CONTROLLER_H
+#define X11CONTROLLER_H 1
+
+#if __OBJC__
+
+#import <Cocoa/Cocoa.h>
+#include "xpr/x-list.h"
+
+ at interface X11Controller : NSObject
+{
+    NSPanel *prefs_panel;
+
+    NSButton *fake_buttons;
+    NSButton *enable_fullscreen;
+    NSButton *use_sysbeep;
+    NSButton *enable_keyequivs;
+    NSButton *sync_keymap;
+    NSButton *enable_auth;
+    NSButton *enable_tcp;
+    NSPopUpButton *depth;
+
+    NSMenuItem *x11_about_item;
+    NSMenuItem *window_separator;
+    NSMenuItem *dock_window_separator;
+    NSMenuItem *apps_separator;
+    NSMenuItem *toggle_fullscreen_item;
+    NSMenu *dock_apps_menu;
+    NSTableView *apps_table;
+
+    NSArray *apps;
+    NSMutableArray *table_apps;
+
+    NSMenu *dock_menu;
+
+    int checked_window_item;
+    x_list *pending_apps;
+
+    BOOL finished_launching;
+    BOOL can_quit;
+}
+
+- (void) set_window_menu:(NSArray *)list;
+- (void) set_window_menu_check:(NSNumber *)n;
+- (void) set_apps_menu:(NSArray *)list;
+- (void) set_can_quit:(BOOL)state;
+- (void) server_ready;
+
+ at end
+
+#endif /* __OBJC__ */
+
+extern void X11ControllerMain (int argc, const char *argv[],
+			       void (*server_thread) (void *),
+			       void *server_arg);
+
+#endif /* X11CONTROLLER_H */
diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m
new file mode 100644
index 0000000..0f64e45
--- /dev/null
+++ b/hw/xquartz/X11Controller.m
@@ -0,0 +1,749 @@
+/* X11Controller.m -- connect the IB ui, also the NSApp delegate
+ 
+   Copyright (c) 2002-2007 Apple Inc. 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 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. */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#define DEFAULT_PATH "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11/bin"
+
+#include "quartzCommon.h"
+
+#import "X11Controller.h"
+#import "X11Application.h"
+#import <Carbon/Carbon.h>
+
+/* ouch! */
+#define BOOL X_BOOL
+#include "opaque.h"
+# include "darwin.h"
+# include "quartz.h"
+# define _APPLEWM_SERVER_
+# include "X11/extensions/applewm.h"
+# include "applewmExt.h"
+#undef BOOL
+
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+ at implementation X11Controller
+
+- (void) awakeFromNib
+{
+  X11Application *xapp = NSApp;
+  NSArray *array;
+	
+  /* Point X11Application at ourself. */
+  [xapp set_controller:self];
+	
+  array = [xapp prefs_get_array:@PREFS_APPSMENU];
+  if (array != nil)
+    {
+      int count;
+		
+      /* convert from [TITLE1 COMMAND1 TITLE2 COMMAND2 ...]
+	 to [[TITLE1 COMMAND1] [TITLE2 COMMAND2] ...] format. */
+		
+      count = [array count];
+      if (count > 0
+	  && ![[array objectAtIndex:0] isKindOfClass:[NSArray class]])
+	{
+	  int i;
+	  NSMutableArray *copy, *sub;
+			
+	  copy = [NSMutableArray arrayWithCapacity:(count / 2)];
+			
+	  for (i = 0; i < count / 2; i++)
+	    {
+	      sub = [[NSMutableArray alloc] initWithCapacity:3];
+	      [sub addObject:[array objectAtIndex:i*2]];
+	      [sub addObject:[array objectAtIndex:i*2+1]];
+	      [sub addObject:@""];
+	      [copy addObject:sub];
+	      [sub release];
+	    }
+			
+	  array = copy;
+	}
+		
+      [self set_apps_menu:array];
+    }
+}
+
+- (void) item_selected:sender
+{
+  [NSApp activateIgnoringOtherApps:YES];
+	
+  QuartzMessageServerThread (kXDarwinControllerNotify, 2,
+			     AppleWMWindowMenuItem, [sender tag]);
+}
+
+- (void) remove_window_menu
+{
+  NSMenu *menu;
+  int first, count, i;
+	
+  /* Work backwards so we don't mess up the indices */
+  menu = [window_separator menu];
+  first = [menu indexOfItem:window_separator] + 1;
+  count = [menu numberOfItems];
+  for (i = count - 1; i >= first; i--)
+    [menu removeItemAtIndex:i];
+	
+  menu = [dock_window_separator menu];
+  count = [menu indexOfItem:dock_window_separator];
+  for (i = 0; i < count; i++)
+    [dock_menu removeItemAtIndex:0];
+}
+
+- (void) install_window_menu:(NSArray *)list
+{
+  NSMenu *menu;
+  NSMenuItem *item;
+  int first, count, i;
+	
+  menu = [window_separator menu];
+  first = [menu indexOfItem:window_separator] + 1;
+  count = [list count];
+  for (i = 0; i < count; i++)
+    {
+      NSString *name, *shortcut;
+		
+      name = [[list objectAtIndex:i] objectAtIndex:0];
+      shortcut = [[list objectAtIndex:i] objectAtIndex:1];
+		
+      item = (NSMenuItem *) [menu addItemWithTitle:name action:@selector
+				  (item_selected:) keyEquivalent:shortcut];
+      [item setTarget:self];
+      [item setTag:i];
+      [item setEnabled:YES];
+		
+      item = (NSMenuItem *) [dock_menu insertItemWithTitle:name
+				       action:@selector
+				       (item_selected:) keyEquivalent:shortcut
+				       atIndex:i];
+      [item setTarget:self];
+      [item setTag:i];
+      [item setEnabled:YES];
+    }
+	
+  if (checked_window_item >= 0 && checked_window_item < count)
+    {
+      item = (NSMenuItem *) [menu itemAtIndex:first + checked_window_item];
+      [item setState:NSOnState];
+      item = (NSMenuItem *) [dock_menu itemAtIndex:checked_window_item];
+      [item setState:NSOnState];
+    }
+}
+
+- (void) remove_apps_menu
+{
+  NSMenu *menu;
+  NSMenuItem *item;
+  int i;
+	
+  if (apps == nil || apps_separator == nil) return;
+	
+  menu = [apps_separator menu];
+	
+  if (menu != nil)
+    {
+      for (i = [menu numberOfItems] - 1; i >= 0; i--)
+	{
+	  item = (NSMenuItem *) [menu itemAtIndex:i];
+	  if ([item tag] != 0)
+	    [menu removeItemAtIndex:i];
+	}
+    }
+    
+  if (dock_apps_menu != nil)
+    {
+      for (i = [dock_apps_menu numberOfItems] - 1; i >= 0; i--)
+	{
+	  item = (NSMenuItem *) [dock_apps_menu itemAtIndex:i];
+	  if ([item tag] != 0)
+	    [dock_apps_menu removeItemAtIndex:i];
+	}
+    }
+    
+  [apps release];
+  apps = nil;
+}
+
+- (void) prepend_apps_item:(NSArray *)list index:(int)i menu:(NSMenu *)menu
+{
+  NSString *title, *shortcut = @"";
+  NSArray *group;
+  NSMenuItem *item;
+	
+  group = [list objectAtIndex:i];
+  title = [group objectAtIndex:0];
+  if ([group count] >= 3)
+    shortcut = [group objectAtIndex:2];
+	
+  if ([title length] != 0)
+    {
+      item = (NSMenuItem *) [menu insertItemWithTitle:title
+				  action:@selector (app_selected:)
+				  keyEquivalent:shortcut atIndex:0];
+      [item setTarget:self];
+      [item setEnabled:YES];
+    }
+  else
+    {
+      item = (NSMenuItem *) [NSMenuItem separatorItem];
+      [menu insertItem:item atIndex:0];
+    }
+	
+  [item setTag:i+1];			/* can't be zero, so add one */
+}
+
+- (void) install_apps_menu:(NSArray *)list
+{
+  NSMenu *menu;
+  int i, count;
+	
+  count = [list count];
+	
+  if (count == 0 || apps_separator == nil) return;
+	
+  menu = [apps_separator menu];
+	
+  for (i = count - 1; i >= 0; i--)
+    {
+      if (menu != nil)
+	[self prepend_apps_item:list index:i menu:menu];
+      if (dock_apps_menu != nil)
+	[self prepend_apps_item:list index:i menu:dock_apps_menu];
+    }
+	
+  apps = [list retain];
+}
+
+- (void) set_window_menu:(NSArray *)list
+{
+  [self remove_window_menu];
+  [self install_window_menu:list];
+	
+  QuartzMessageServerThread (kXDarwinControllerNotify, 1,
+			     AppleWMWindowMenuNotify);
+}
+
+- (void) set_window_menu_check:(NSNumber *)nn
+{
+  NSMenu *menu;
+  NSMenuItem *item;
+  int first, count;
+  int n = [nn intValue];
+
+  menu = [window_separator menu];
+  first = [menu indexOfItem:window_separator] + 1;
+  count = [menu numberOfItems] - first;
+	
+  if (checked_window_item >= 0 && checked_window_item < count)
+    {
+      item = (NSMenuItem *) [menu itemAtIndex:first + checked_window_item];
+      [item setState:NSOffState];
+      item = (NSMenuItem *) [dock_menu itemAtIndex:checked_window_item];
+      [item setState:NSOffState];
+    }
+  if (n >= 0 && n < count)
+    {
+      item = (NSMenuItem *) [menu itemAtIndex:first + n];
+      [item setState:NSOnState];
+      item = (NSMenuItem *) [dock_menu itemAtIndex:n];
+      [item setState:NSOnState];
+    }
+  checked_window_item = n;
+}
+
+- (void) set_apps_menu:(NSArray *)list
+{
+  [self remove_apps_menu];
+  [self install_apps_menu:list];
+}
+
+- (void) launch_client:(NSString *)filename
+{
+  const char *command = [filename UTF8String];
+  const char *argv[7];
+  int child1, child2 = 0;
+  int status;
+	
+  argv[0] = "/usr/bin/login";
+  argv[1] = "-fp";
+  argv[2] = getlogin();
+  argv[3] = "/bin/sh";
+  argv[4] = "-c";
+  argv[5] = command;
+  argv[6] = NULL;
+
+  /* Do the fork-twice trick to avoid having to reap zombies */
+    
+  child1 = fork();
+    
+  switch (child1) {
+  case -1:                                /* error */
+    break;
+      
+  case 0:                                 /* child1 */
+    child2 = fork();
+      
+    switch (child2) {
+      int max_files, i;
+      char buf[1024], *temp;
+	
+    case -1:                            /* error */
+      _exit(1);
+	
+    case 0:                             /* child2 */
+      /* close all open files except for standard streams */
+      max_files = sysconf(_SC_OPEN_MAX);
+      for (i = 3; i < max_files; i++)	close(i);
+	
+      /* ensure stdin is on /dev/null */
+      close(0);
+      open("/dev/null", O_RDONLY);
+	
+      /* Setup environment */
+      temp = getenv("DISPLAY");
+      if (temp == NULL || temp[0] == 0) {
+	snprintf(buf, sizeof(buf), ":%s", display);
+	setenv("DISPLAY", buf, TRUE);
+      }
+	
+      temp = getenv("PATH");
+      if (temp == NULL || temp[0] == 0) 
+	setenv ("PATH", DEFAULT_PATH, TRUE);
+      else if (strnstr(temp, "/usr/X11/bin", sizeof(temp)) == NULL) {
+	snprintf(buf, sizeof(buf), "%s:/usr/X11/bin", temp);            
+	setenv("PATH", buf, TRUE);      
+      }
+      /* cd $HOME */
+      temp = getenv("HOME");
+      if (temp != NULL && temp[0]!=0) chdir(temp);
+	
+      execvp(argv[0], (char **const) argv);
+	
+      _exit(2);
+	
+    default:                            /* parent (child1) */
+      _exit(0);
+    }
+    break;
+      
+  default:                                /* parent */
+    waitpid(child1, &status, 0);
+  }
+}
+
+- (void) app_selected:sender
+{
+  int tag;
+  NSString *item;
+  
+  tag = [sender tag] - 1;
+  if (apps == nil || tag < 0 || tag >= [apps count])
+    return;
+  
+  item = [[apps objectAtIndex:tag] objectAtIndex:1];
+  
+  [self launch_client:item];
+}
+
+- (IBAction) apps_table_show:sender
+{
+  NSArray *columns;
+	
+  if (table_apps == nil) {
+    table_apps = [[NSMutableArray alloc] initWithCapacity:1];
+      
+    if (apps != nil)[table_apps addObjectsFromArray:apps];
+  }
+	
+  columns = [apps_table tableColumns];
+  [[columns objectAtIndex:0] setIdentifier:@"0"];
+  [[columns objectAtIndex:1] setIdentifier:@"1"];
+  [[columns objectAtIndex:2] setIdentifier:@"2"];
+	
+  [apps_table setDataSource:self];
+  [apps_table selectRow:0 byExtendingSelection:NO];
+	
+  [[apps_table window] makeKeyAndOrderFront:sender];
+}
+
+- (IBAction) apps_table_cancel:sender
+{
+  [[apps_table window] orderOut:sender];
+  [apps_table reloadData];
+	
+  [table_apps release];
+  table_apps = nil;
+}
+
+- (IBAction) apps_table_done:sender
+{
+  [apps_table deselectAll:sender];	/* flush edits? */
+	
+  [self remove_apps_menu];
+  [self install_apps_menu:table_apps];
+	
+  [NSApp prefs_set_array:@PREFS_APPSMENU value:table_apps];
+  [NSApp prefs_synchronize];
+	
+  [[apps_table window] orderOut:sender];
+	
+  [table_apps release];
+  table_apps = nil;
+}
+
+- (IBAction) apps_table_new:sender
+{
+  NSMutableArray *item;
+	
+  int row = [apps_table selectedRow], i;
+	
+  if (row < 0) row = 0;
+  else row = row + 1;
+	
+  i = row;
+  if (i > [table_apps count])
+    return;				/* avoid exceptions */
+	
+  [apps_table deselectAll:sender];
+	
+  item = [[NSMutableArray alloc] initWithCapacity:3];
+  [item addObject:@""];
+  [item addObject:@""];
+  [item addObject:@""];
+	
+  [table_apps insertObject:item atIndex:i];
+  [item release];
+	
+  [apps_table reloadData];
+  [apps_table selectRow:row byExtendingSelection:NO];
+}
+
+- (IBAction) apps_table_duplicate:sender
+{
+  int row = [apps_table selectedRow], i;
+  NSObject *item;
+	
+  if (row < 0) {
+    [self apps_table_new:sender];
+    return;
+  }
+	
+  i = row;
+  if (i > [table_apps count] - 1) return;				/* avoid exceptions */
+    
+  [apps_table deselectAll:sender];
+	
+  item = [[table_apps objectAtIndex:i] mutableCopy];
+  [table_apps insertObject:item atIndex:i];
+  [item release];
+	
+  [apps_table reloadData];
+  [apps_table selectRow:row+1 byExtendingSelection:NO];
+}
+
+- (IBAction) apps_table_delete:sender
+{
+  int row = [apps_table selectedRow];
+	
+  if (row >= 0)
+    {
+      int i = row;
+      
+      if (i > [table_apps count] - 1) return;			/* avoid exceptions */
+      
+      [apps_table deselectAll:sender];
+      
+      [table_apps removeObjectAtIndex:i];
+    }
+	
+  [apps_table reloadData];
+	
+  row = MIN (row, [table_apps count] - 1);
+  if (row >= 0)
+    [apps_table selectRow:row byExtendingSelection:NO];
+}
+
+- (int) numberOfRowsInTableView:(NSTableView *)tableView
+{
+  if (table_apps == nil) return 0;
+  
+  return [table_apps count];
+}
+
+- (id) tableView:(NSTableView *)tableView
+objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
+{
+  NSArray *item;
+  int col;
+	
+  if (table_apps == nil) return nil;
+	
+  col = [[tableColumn identifier] intValue];
+	
+  item = [table_apps objectAtIndex:row];
+  if ([item count] > col)
+    return [item objectAtIndex:col];
+  else
+    return @"";
+}
+
+- (void) tableView:(NSTableView *)tableView setObjectValue:(id)object
+    forTableColumn:(NSTableColumn *)tableColumn row:(int)row
+{
+  NSMutableArray *item;
+  int col;
+	
+  if (table_apps == nil) return;
+	
+  col = [[tableColumn identifier] intValue];
+	
+  item = [table_apps objectAtIndex:row];
+  [item replaceObjectAtIndex:col withObject:object];
+}
+
+- (void) hide_window:sender
+{
+  if ([X11App x_active])
+    QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMHideWindow);
+  else
+    NSBeep ();			/* FIXME: something here */
+}
+
+- (IBAction)bring_to_front:sender
+{
+  QuartzMessageServerThread(kXDarwinControllerNotify, 1, AppleWMBringAllToFront);
+}
+
+- (IBAction)close_window:sender
+{
+  if ([X11App x_active])
+    QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMCloseWindow);
+  else
+    [[NSApp keyWindow] performClose:sender];
+}
+
+- (IBAction)minimize_window:sender
+{
+  if ([X11App x_active])
+    QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMMinimizeWindow);
+  else
+    [[NSApp keyWindow] performMiniaturize:sender];
+}
+
+- (IBAction)zoom_window:sender
+{
+  if ([X11App x_active])
+    QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMZoomWindow);
+  else
+    [[NSApp keyWindow] performZoom:sender];
+}
+
+- (IBAction) next_window:sender
+{
+  QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMNextWindow);
+}
+
+- (IBAction) previous_window:sender
+{
+  QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMPreviousWindow);
+}
+
+- (IBAction) enable_fullscreen_changed:sender
+{
+  int value = ![enable_fullscreen intValue];
+	
+#ifdef DARWIN_DDX_MISSING
+  QuartzMessageServerThread (kXDarwinSetRootless, 1, value);
+#endif
+	
+  [NSApp prefs_set_boolean:@PREFS_ROOTLESS value:value];
+  [NSApp prefs_synchronize];
+}
+
+- (IBAction) toggle_fullscreen:sender
+{
+#ifdef DARWIN_DDX_MISSING
+  QuartzMessageServerThread (kXDarwinToggleFullscreen, 0);
+#endif
+}
+
+- (void) set_can_quit:(BOOL)state
+{
+  can_quit = state;
+}
+
+- (IBAction)prefs_changed:sender
+{
+  darwinFakeButtons = [fake_buttons intValue];
+  quartzUseSysBeep = [use_sysbeep intValue];
+  X11EnableKeyEquivalents = [enable_keyequivs intValue];
+  darwinSyncKeymap = [sync_keymap intValue];
+	
+  /* after adding prefs here, also add to [X11Application read_defaults]
+     and below */
+	
+  [NSApp prefs_set_boolean:@PREFS_FAKEBUTTONS value:darwinFakeButtons];
+  [NSApp prefs_set_boolean:@PREFS_SYSBEEP value:quartzUseSysBeep];
+  [NSApp prefs_set_boolean:@PREFS_KEYEQUIVS value:X11EnableKeyEquivalents];
+  [NSApp prefs_set_boolean:@PREFS_SYNC_KEYMAP value:darwinSyncKeymap];
+  [NSApp prefs_set_boolean:@PREFS_NO_AUTH value:![enable_auth intValue]];
+  [NSApp prefs_set_boolean:@PREFS_NO_TCP value:![enable_tcp intValue]];
+  [NSApp prefs_set_integer:@PREFS_DEPTH value:[depth selectedTag]];
+	
+  [NSApp prefs_synchronize];
+}
+
+- (IBAction) prefs_show:sender
+{
+  [fake_buttons setIntValue:darwinFakeButtons];
+  [use_sysbeep setIntValue:quartzUseSysBeep];
+  [enable_keyequivs setIntValue:X11EnableKeyEquivalents];
+  [sync_keymap setIntValue:darwinSyncKeymap];
+  [sync_keymap setEnabled:darwinKeymapFile == NULL];
+	
+  [enable_auth setIntValue:![NSApp prefs_get_boolean:@PREFS_NO_AUTH default:NO]];
+  [enable_tcp setIntValue:![NSApp prefs_get_boolean:@PREFS_NO_TCP default:NO]];
+  [depth selectItemAtIndex:[depth indexOfItemWithTag:[NSApp prefs_get_integer:@PREFS_DEPTH default:-1]]];
+	
+  [enable_fullscreen setIntValue:!quartzEnableRootless];
+	
+  [prefs_panel makeKeyAndOrderFront:sender];
+}
+
+- (IBAction) quit:sender
+{
+  QuartzMessageServerThread (kXDarwinQuit, 0);
+}
+
+- (IBAction) x11_help:sender
+{
+  AHLookupAnchor ((CFStringRef)NSLocalizedString(@"Mac Help", no comment), CFSTR ("mchlp2276"));
+}
+
+- (BOOL) validateMenuItem:(NSMenuItem *)item
+{
+  NSMenu *menu = [item menu];
+	
+  if (item == toggle_fullscreen_item)
+    return !quartzEnableRootless;
+  else if (menu == [window_separator menu] || menu == dock_menu
+	   || (menu == [x11_about_item menu] && [item tag] == 42))
+    return (AppleWMSelectedEvents () & AppleWMControllerNotifyMask) != 0;
+  else
+    return TRUE;
+}
+
+- (void) applicationDidHide:(NSNotification *)notify
+{
+  QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMHideAll);
+}
+
+- (void) applicationDidUnhide:(NSNotification *)notify
+{
+  QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMShowAll);
+}
+
+- (NSApplicationTerminateReply) applicationShouldTerminate:sender
+{
+  NSString *msg;
+	
+  if (can_quit || [X11App prefs_get_boolean:@PREFS_NO_QUIT_ALERT default:NO])
+    return NSTerminateNow;
+	
+  /* Make sure we're frontmost. */
+  [NSApp activateIgnoringOtherApps:YES];
+	
+  msg = NSLocalizedString (@"Are you sure you want to quit X11?\n\nIf you quit X11, any X11 applications you are running will stop immediately and you will lose any changes you have not saved.", @"Dialog when quitting");
+	
+  /* FIXME: safe to run the alert in here? Or should we return Later
+     and then run the alert on a timer? It seems to work here, so.. */
+	
+  return (NSRunAlertPanel (nil, msg, NSLocalizedString (@"Quit", @""),
+			   NSLocalizedString (@"Cancel", @""), nil)
+	  == NSAlertDefaultReturn) ? NSTerminateNow : NSTerminateCancel;
+}
+
+- (void) applicationWillTerminate:(NSNotification *)aNotification
+{
+  [X11App prefs_synchronize];
+	
+  /* shutdown the X server, it will exit () for us. */
+  QuartzMessageServerThread (kXDarwinQuit, 0);
+	
+  /* In case it doesn't, exit anyway after a while. */
+  while (sleep (10) != 0) ;
+  exit (1);
+}
+
+- (void) server_ready
+{
+  x_list *node;
+	
+  finished_launching = YES;
+	
+  for (node = pending_apps; node != NULL; node = node->next)
+    {
+      NSString *filename = node->data;
+      [self launch_client:filename];
+      [filename release];
+    }
+	
+  x_list_free (pending_apps);
+  pending_apps = NULL;
+}
+
+- (BOOL) application:(NSApplication *)app openFile:(NSString *)filename
+{
+  const char *name = [filename UTF8String];
+	
+  if (finished_launching)
+    [self launch_client:filename];
+  else if (name[0] != ':')		/* ignore display names */
+    pending_apps = x_list_prepend (pending_apps, [filename retain]);
+	
+  /* FIXME: report failures. */
+  return YES;
+}
+
+ at end
+
+void X11ControllerMain (int argc, const char *argv[],
+			void (*server_thread) (void *), void *server_arg)
+{
+  X11ApplicationMain (argc, argv, server_thread, server_arg);
+}
diff --git a/hw/xquartz/applewm.c b/hw/xquartz/applewm.c
new file mode 100644
index 0000000..72dca28
--- /dev/null
+++ b/hw/xquartz/applewm.c
@@ -0,0 +1,714 @@
+/**************************************************************************
+
+Copyright (c) 2002-2007 Apple Inc. All Rights Reserved.
+Copyright (c) 2003 Torrey T. Lyons. 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, sub license, 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 PRECISION INSIGHT AND/OR ITS 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.
+
+**************************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "quartzCommon.h"
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include "misc.h"
+#include "dixstruct.h"
+#include "globals.h"
+#include "extnsionst.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "servermd.h"
+#include "swaprep.h"
+#include "propertyst.h"
+#include <X11/Xatom.h>
+#include "darwin.h"
+#define _APPLEWM_SERVER_
+#include "X11/extensions/applewmstr.h"
+#include "applewmExt.h"
+#include "X11Application.h"
+
+#define DEFINE_ATOM_HELPER(func,atom_name)                      \
+static Atom func (void) {                                       \
+    static int generation;                                      \
+    static Atom atom;                                           \
+    if (generation != serverGeneration) {                       \
+        generation = serverGeneration;                          \
+        atom = MakeAtom (atom_name, strlen (atom_name), TRUE);  \
+    }                                                           \
+    return atom;                                                \
+}
+
+DEFINE_ATOM_HELPER(xa_native_screen_origin, "_NATIVE_SCREEN_ORIGIN")
+DEFINE_ATOM_HELPER (xa_apple_no_order_in, "_APPLE_NO_ORDER_IN")
+
+static AppleWMProcsPtr appleWMProcs;
+
+static int WMErrorBase;
+
+static DISPATCH_PROC(ProcAppleWMDispatch);
+static DISPATCH_PROC(SProcAppleWMDispatch);
+
+static void AppleWMResetProc(ExtensionEntry* extEntry);
+
+static unsigned char WMReqCode = 0;
+static int WMEventBase = 0;
+
+static RESTYPE ClientType, EventType; /* resource types for event masks */
+static XID eventResource;
+
+/* Currently selected events */
+static unsigned int eventMask = 0;
+
+static int WMFreeClient (pointer data, XID id);
+static int WMFreeEvents (pointer data, XID id);
+static void SNotifyEvent(xAppleWMNotifyEvent *from, xAppleWMNotifyEvent *to);
+
+typedef struct _WMEvent *WMEventPtr;
+typedef struct _WMEvent {
+    WMEventPtr      next;
+    ClientPtr       client;
+    XID             clientResource;
+    unsigned int    mask;
+} WMEventRec;
+
+static inline BoxRec
+make_box (int x, int y, int w, int h)
+{
+    BoxRec r;
+    r.x1 = x;
+    r.y1 = y;
+    r.x2 = x + w;
+    r.y2 = y + h;
+    return r;
+}
+
+void
+AppleWMExtensionInit(
+    AppleWMProcsPtr procsPtr)
+{
+    ExtensionEntry* extEntry;
+
+    ClientType = CreateNewResourceType(WMFreeClient);
+    EventType = CreateNewResourceType(WMFreeEvents);
+    eventResource = FakeClientID(0);
+
+    if (ClientType && EventType &&
+        (extEntry = AddExtension(APPLEWMNAME,
+                                 AppleWMNumberEvents,
+                                 AppleWMNumberErrors,
+                                 ProcAppleWMDispatch,
+                                 SProcAppleWMDispatch,
+                                 AppleWMResetProc,
+                                 StandardMinorOpcode)))
+    {
+        WMReqCode = (unsigned char)extEntry->base;
+        WMErrorBase = extEntry->errorBase;
+        WMEventBase = extEntry->eventBase;
+        EventSwapVector[WMEventBase] = (EventSwapPtr) SNotifyEvent;
+        appleWMProcs = procsPtr;
+    }
+}
+
+/*ARGSUSED*/
+static void
+AppleWMResetProc (
+    ExtensionEntry* extEntry
+)
+{
+}
+
+/* Updates the _NATIVE_SCREEN_ORIGIN property on the given root window. */
+void
+AppleWMSetScreenOrigin(
+    WindowPtr pWin
+)
+{
+    long data[2];
+
+    data[0] = (dixScreenOrigins[pWin->drawable.pScreen->myNum].x
+                + darwinMainScreenX);
+    data[1] = (dixScreenOrigins[pWin->drawable.pScreen->myNum].y
+                + darwinMainScreenY);
+
+    ChangeWindowProperty(pWin, xa_native_screen_origin(), XA_INTEGER,
+                         32, PropModeReplace, 2, data, TRUE);
+}
+
+/* Window managers can set the _APPLE_NO_ORDER_IN property on windows
+   that are being genie-restored from the Dock. We want them to
+   be mapped but remain ordered-out until the animation
+   completes (when the Dock will order them in). */
+Bool
+AppleWMDoReorderWindow(
+    WindowPtr pWin
+)
+{
+    Atom atom;
+    PropertyPtr prop;
+
+    atom = xa_apple_no_order_in();
+    for (prop = wUserProps(pWin); prop != NULL; prop = prop->next)
+    {
+        if (prop->propertyName == atom && prop->type == atom)
+            return FALSE;
+    }
+
+    return TRUE;
+}
+
+
+static int
+ProcAppleWMQueryVersion(
+    register ClientPtr client
+)
+{
+    xAppleWMQueryVersionReply rep;
+    register int n;
+
+    REQUEST_SIZE_MATCH(xAppleWMQueryVersionReq);
+    rep.type = X_Reply;
+    rep.length = 0;
+    rep.sequenceNumber = client->sequence;
+    rep.majorVersion = APPLE_WM_MAJOR_VERSION;
+    rep.minorVersion = APPLE_WM_MINOR_VERSION;
+    rep.patchVersion = APPLE_WM_PATCH_VERSION;
+    if (client->swapped) {
+        swaps(&rep.sequenceNumber, n);
+        swapl(&rep.length, n);
+    }
+    WriteToClient(client, sizeof(xAppleWMQueryVersionReply), (char *)&rep);
+    return (client->noClientException);
+}
+
+
+/* events */
+
+static inline void
+updateEventMask (WMEventPtr *pHead)
+{
+    WMEventPtr pCur;
+
+    eventMask = 0;
+    for (pCur = *pHead; pCur != NULL; pCur = pCur->next)
+        eventMask |= pCur->mask;
+}
+
+/*ARGSUSED*/
+static int
+WMFreeClient (data, id)
+    pointer     data;
+    XID         id;
+{
+    WMEventPtr   pEvent;
+    WMEventPtr   *pHead, pCur, pPrev;
+
+    pEvent = (WMEventPtr) data;
+    pHead = (WMEventPtr *) LookupIDByType(eventResource, EventType);
+    if (pHead) {
+        pPrev = 0;
+        for (pCur = *pHead; pCur && pCur != pEvent; pCur=pCur->next)
+            pPrev = pCur;
+        if (pCur) {
+            if (pPrev)
+                pPrev->next = pEvent->next;
+            else
+                *pHead = pEvent->next;
+        }
+        updateEventMask (pHead);
+    }
+    xfree ((pointer) pEvent);
+    return 1;
+}
+
+/*ARGSUSED*/
+static int
+WMFreeEvents (data, id)
+    pointer     data;
+    XID         id;
+{
+    WMEventPtr   *pHead, pCur, pNext;
+
+    pHead = (WMEventPtr *) data;
+    for (pCur = *pHead; pCur; pCur = pNext) {
+        pNext = pCur->next;
+        FreeResource (pCur->clientResource, ClientType);
+        xfree ((pointer) pCur);
+    }
+    xfree ((pointer) pHead);
+    eventMask = 0;
+    return 1;
+}
+
+static int
+ProcAppleWMSelectInput (client)
+    register ClientPtr  client;
+{
+    REQUEST(xAppleWMSelectInputReq);
+    WMEventPtr      pEvent, pNewEvent, *pHead;
+    XID             clientResource;
+
+    REQUEST_SIZE_MATCH (xAppleWMSelectInputReq);
+    pHead = (WMEventPtr *)SecurityLookupIDByType(client,
+                        eventResource, EventType, DixWriteAccess);
+    if (stuff->mask != 0) {
+        if (pHead) {
+            /* check for existing entry. */
+            for (pEvent = *pHead; pEvent; pEvent = pEvent->next)
+            {
+                if (pEvent->client == client)
+                {
+                    pEvent->mask = stuff->mask;
+                    updateEventMask (pHead);
+                    return Success;
+                }
+            }
+        }
+
+        /* build the entry */
+        pNewEvent = (WMEventPtr) xalloc (sizeof (WMEventRec));
+        if (!pNewEvent)
+            return BadAlloc;
+        pNewEvent->next = 0;
+        pNewEvent->client = client;
+        pNewEvent->mask = stuff->mask;
+        /*
+         * add a resource that will be deleted when
+         * the client goes away
+         */
+        clientResource = FakeClientID (client->index);
+        pNewEvent->clientResource = clientResource;
+        if (!AddResource (clientResource, ClientType, (pointer)pNewEvent))
+            return BadAlloc;
+        /*
+         * create a resource to contain a pointer to the list
+         * of clients selecting input.  This must be indirect as
+         * the list may be arbitrarily rearranged which cannot be
+         * done through the resource database.
+         */
+        if (!pHead)
+        {
+            pHead = (WMEventPtr *) xalloc (sizeof (WMEventPtr));
+            if (!pHead ||
+                !AddResource (eventResource, EventType, (pointer)pHead))
+            {
+                FreeResource (clientResource, RT_NONE);
+                return BadAlloc;
+            }
+            *pHead = 0;
+        }
+        pNewEvent->next = *pHead;
+        *pHead = pNewEvent;
+        updateEventMask (pHead);
+    } else if (stuff->mask == 0) {
+        /* delete the interest */
+        if (pHead) {
+            pNewEvent = 0;
+            for (pEvent = *pHead; pEvent; pEvent = pEvent->next) {
+                if (pEvent->client == client)
+                    break;
+                pNewEvent = pEvent;
+            }
+            if (pEvent) {
+                FreeResource (pEvent->clientResource, ClientType);
+                if (pNewEvent)
+                    pNewEvent->next = pEvent->next;
+                else
+                    *pHead = pEvent->next;
+                xfree (pEvent);
+                updateEventMask (pHead);
+            }
+        }
+    } else {
+        client->errorValue = stuff->mask;
+        return BadValue;
+    }
+    return Success;
+}
+
+/*
+ * deliver the event
+ */
+
+void
+AppleWMSendEvent (type, mask, which, arg)
+    int type, which, arg;
+    unsigned int mask;
+{
+    WMEventPtr      *pHead, pEvent;
+    ClientPtr       client;
+    xAppleWMNotifyEvent se;
+
+    pHead = (WMEventPtr *) LookupIDByType(eventResource, EventType);
+    if (!pHead)
+        return;
+    for (pEvent = *pHead; pEvent; pEvent = pEvent->next) {
+        client = pEvent->client;
+        if ((pEvent->mask & mask) == 0
+            || client == serverClient || client->clientGone)
+        {
+            continue;
+        }
+        se.type = type + WMEventBase;
+        se.kind = which;
+        se.arg = arg;
+        se.sequenceNumber = client->sequence;
+        se.time = currentTime.milliseconds;
+        WriteEventsToClient (client, 1, (xEvent *) &se);
+    }
+}
+
+/* Safe to call from any thread. */
+unsigned int
+AppleWMSelectedEvents (void)
+{
+    return eventMask;
+}
+
+
+/* general utility functions */
+
+static int
+ProcAppleWMDisableUpdate(
+    register ClientPtr client
+)
+{
+    REQUEST_SIZE_MATCH(xAppleWMDisableUpdateReq);
+
+    appleWMProcs->DisableUpdate();
+
+    return (client->noClientException);
+}
+
+static int
+ProcAppleWMReenableUpdate(
+    register ClientPtr client
+)
+{
+    REQUEST_SIZE_MATCH(xAppleWMReenableUpdateReq);
+
+    appleWMProcs->EnableUpdate();
+
+    return (client->noClientException);
+}
+
+
+/* window functions */
+
+static int
+ProcAppleWMSetWindowMenu(
+    register ClientPtr client
+)
+{
+    const char *bytes, **items;
+    char *shortcuts;
+    int max_len, nitems, i, j;
+    REQUEST(xAppleWMSetWindowMenuReq);
+
+    REQUEST_AT_LEAST_SIZE(xAppleWMSetWindowMenuReq);
+
+    nitems = stuff->nitems;
+    items = xalloc (sizeof (char *) * nitems);
+    shortcuts = xalloc (sizeof (char) * nitems);
+
+    max_len = (stuff->length << 2) - sizeof(xAppleWMSetWindowMenuReq);
+    bytes = (char *) &stuff[1];
+
+    for (i = j = 0; i < max_len && j < nitems;)
+    {
+        shortcuts[j] = bytes[i++];
+        items[j++] = bytes + i;
+
+        while (i < max_len)
+        {
+            if (bytes[i++] == 0)
+                break;
+        }
+    }
+    X11ApplicationSetWindowMenu (nitems, items, shortcuts);
+    free(items);
+    free(shortcuts);
+
+    return (client->noClientException);
+}
+
+static int
+ProcAppleWMSetWindowMenuCheck(
+    register ClientPtr client
+)
+{
+    REQUEST(xAppleWMSetWindowMenuCheckReq);
+
+    REQUEST_SIZE_MATCH(xAppleWMSetWindowMenuCheckReq);
+    X11ApplicationSetWindowMenuCheck(stuff->index);
+    return (client->noClientException);
+}
+
+static int
+ProcAppleWMSetFrontProcess(
+    register ClientPtr client
+)
+{
+    REQUEST_SIZE_MATCH(xAppleWMSetFrontProcessReq);
+
+    X11ApplicationSetFrontProcess();
+    return (client->noClientException);
+}
+
+static int
+ProcAppleWMSetWindowLevel(
+    register ClientPtr client
+)
+{
+    REQUEST(xAppleWMSetWindowLevelReq);
+    WindowPtr pWin;
+    int errno;
+
+    REQUEST_SIZE_MATCH(xAppleWMSetWindowLevelReq);
+
+    if (Success != dixLookupWindow(&pWin, stuff->window, client,
+				   DixReadAccess))
+        return BadValue;
+
+    if (stuff->level < 0 || stuff->level >= AppleWMNumWindowLevels) {
+        return BadValue;
+    }
+
+     errno = appleWMProcs->SetWindowLevel(pWin, stuff->level);
+     if (errno != Success) {
+        return errno;
+    }
+
+    return (client->noClientException);
+}
+
+static int
+ProcAppleWMSetCanQuit(
+    register ClientPtr client
+)
+{
+    REQUEST(xAppleWMSetCanQuitReq);
+
+    REQUEST_SIZE_MATCH(xAppleWMSetCanQuitReq);
+
+    X11ApplicationSetCanQuit(stuff->state);
+    return (client->noClientException);
+}
+
+
+/* frame functions */
+
+static int
+ProcAppleWMFrameGetRect(
+    register ClientPtr client
+)
+{
+    xAppleWMFrameGetRectReply rep;
+    BoxRec ir, or, rr;
+    REQUEST(xAppleWMFrameGetRectReq);
+
+    REQUEST_SIZE_MATCH(xAppleWMFrameGetRectReq);
+    rep.type = X_Reply;
+    rep.length = 0;
+    rep.sequenceNumber = client->sequence;
+
+    ir = make_box (stuff->ix, stuff->iy, stuff->iw, stuff->ih);
+    or = make_box (stuff->ox, stuff->oy, stuff->ow, stuff->oh);
+
+    if (appleWMProcs->FrameGetRect(stuff->frame_rect,
+                                   stuff->frame_class,
+                                   &or, &ir, &rr) != Success)
+    {
+        return BadValue;
+    }
+
+    rep.x = rr.x1;
+    rep.y = rr.y1;
+    rep.w = rr.x2 - rr.x1;
+    rep.h = rr.y2 - rr.y1;
+
+    WriteToClient(client, sizeof(xAppleWMFrameGetRectReply), (char *)&rep);
+    return (client->noClientException);
+}
+
+static int
+ProcAppleWMFrameHitTest(
+    register ClientPtr client
+)
+{
+    xAppleWMFrameHitTestReply rep;
+    BoxRec ir, or;
+    int ret;
+    REQUEST(xAppleWMFrameHitTestReq);
+
+    REQUEST_SIZE_MATCH(xAppleWMFrameHitTestReq);
+    rep.type = X_Reply;
+    rep.length = 0;
+    rep.sequenceNumber = client->sequence;
+
+    ir = make_box (stuff->ix, stuff->iy, stuff->iw, stuff->ih);
+    or = make_box (stuff->ox, stuff->oy, stuff->ow, stuff->oh);
+
+    if (appleWMProcs->FrameHitTest(stuff->frame_class, stuff->px,
+                                   stuff->py, &or, &ir, &ret) != Success)
+    {
+        return BadValue;
+    }
+
+    rep.ret = ret;
+
+    WriteToClient(client, sizeof(xAppleWMFrameHitTestReply), (char *)&rep);
+    return (client->noClientException);
+}
+
+static int
+ProcAppleWMFrameDraw(
+    register ClientPtr client
+)
+{
+    BoxRec ir, or;
+    unsigned int title_length, title_max;
+    unsigned char *title_bytes;
+    REQUEST(xAppleWMFrameDrawReq);
+    WindowPtr pWin;
+
+    REQUEST_AT_LEAST_SIZE(xAppleWMFrameDrawReq);
+
+    if (Success != dixLookupWindow(&pWin, stuff->window, client,
+				   DixReadAccess))
+        return BadValue;
+
+    ir = make_box (stuff->ix, stuff->iy, stuff->iw, stuff->ih);
+    or = make_box (stuff->ox, stuff->oy, stuff->ow, stuff->oh);
+
+    title_length = stuff->title_length;
+    title_max = (stuff->length << 2) - sizeof(xAppleWMFrameDrawReq);
+
+    if (title_max < title_length)
+        return BadValue;
+
+    title_bytes = (unsigned char *) &stuff[1];
+
+    errno = appleWMProcs->FrameDraw(pWin, stuff->frame_class,
+                                    stuff->frame_attr, &or, &ir,
+                                    title_length, title_bytes);
+    if (errno != Success) {
+        return errno;
+    }
+
+    return (client->noClientException);
+}
+
+
+/* dispatch */
+
+static int
+ProcAppleWMDispatch (
+    register ClientPtr  client
+)
+{
+    REQUEST(xReq);
+
+    switch (stuff->data)
+    {
+    case X_AppleWMQueryVersion:
+        return ProcAppleWMQueryVersion(client);
+    }
+
+    if (!LocalClient(client))
+        return WMErrorBase + AppleWMClientNotLocal;
+
+    switch (stuff->data)
+    {
+    case X_AppleWMSelectInput:
+        return ProcAppleWMSelectInput(client);
+    case X_AppleWMDisableUpdate:
+        return ProcAppleWMDisableUpdate(client);
+    case X_AppleWMReenableUpdate:
+        return ProcAppleWMReenableUpdate(client);
+    case X_AppleWMSetWindowMenu:
+        return ProcAppleWMSetWindowMenu(client);
+    case X_AppleWMSetWindowMenuCheck:
+        return ProcAppleWMSetWindowMenuCheck(client);
+    case X_AppleWMSetFrontProcess:
+        return ProcAppleWMSetFrontProcess(client);
+    case X_AppleWMSetWindowLevel:
+        return ProcAppleWMSetWindowLevel(client);
+    case X_AppleWMSetCanQuit:
+        return ProcAppleWMSetCanQuit(client);
+    case X_AppleWMFrameGetRect:
+        return ProcAppleWMFrameGetRect(client);
+    case X_AppleWMFrameHitTest:
+        return ProcAppleWMFrameHitTest(client);
+    case X_AppleWMFrameDraw:
+        return ProcAppleWMFrameDraw(client);
+    default:
+        return BadRequest;
+    }
+}
+
+static void
+SNotifyEvent(from, to)
+    xAppleWMNotifyEvent *from, *to;
+{
+    to->type = from->type;
+    to->kind = from->kind;
+    cpswaps (from->sequenceNumber, to->sequenceNumber);
+    cpswapl (from->time, to->time);
+    cpswapl (from->arg, to->arg);
+}
+
+static int
+SProcAppleWMQueryVersion(
+    register ClientPtr  client
+)
+{
+    register int n;
+    REQUEST(xAppleWMQueryVersionReq);
+    swaps(&stuff->length, n);
+    return ProcAppleWMQueryVersion(client);
+}
+
+static int
+SProcAppleWMDispatch (
+    register ClientPtr  client
+)
+{
+    REQUEST(xReq);
+
+    /* It is bound to be non-local when there is byte swapping */
+    if (!LocalClient(client))
+        return WMErrorBase + AppleWMClientNotLocal;
+
+    /* only local clients are allowed WM access */
+    switch (stuff->data)
+    {
+    case X_AppleWMQueryVersion:
+        return SProcAppleWMQueryVersion(client);
+    default:
+        return BadRequest;
+    }
+}
diff --git a/hw/xquartz/applewmExt.h b/hw/xquartz/applewmExt.h
new file mode 100644
index 0000000..60d49ef
--- /dev/null
+++ b/hw/xquartz/applewmExt.h
@@ -0,0 +1,84 @@
+/*
+ * External interface for the server's AppleWM support
+ */
+/**************************************************************************
+
+Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved.
+Copyright (c) 2003-2004 Torrey T. Lyons. 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, sub license, 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 PRECISION INSIGHT AND/OR ITS 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.
+
+**************************************************************************/
+
+#ifndef _APPLEWMEXT_H_
+#define _APPLEWMEXT_H_
+
+#include "window.h"
+
+typedef int (*DisableUpdateProc)(void);
+typedef int (*EnableUpdateProc)(void);
+typedef int (*SetWindowLevelProc)(WindowPtr pWin, int level);
+typedef int (*FrameGetRectProc)(int type, int class, const BoxRec *outer,
+                                const BoxRec *inner, BoxRec *ret);
+typedef int (*FrameHitTestProc)(int class, int x, int y,
+                                const BoxRec *outer,
+                                const BoxRec *inner, int *ret);
+typedef int (*FrameDrawProc)(WindowPtr pWin, int class, unsigned int attr,
+                             const BoxRec *outer, const BoxRec *inner,
+                             unsigned int title_len,
+                             const unsigned char *title_bytes);
+
+/*
+ * AppleWM implementation function list
+ */
+typedef struct _AppleWMProcs {
+    DisableUpdateProc DisableUpdate;
+    EnableUpdateProc EnableUpdate;
+    SetWindowLevelProc SetWindowLevel;
+    FrameGetRectProc FrameGetRect;
+    FrameHitTestProc FrameHitTest;
+    FrameDrawProc FrameDraw;
+} AppleWMProcsRec, *AppleWMProcsPtr;
+
+void AppleWMExtensionInit(
+    AppleWMProcsPtr procsPtr
+);
+
+void AppleWMSetScreenOrigin(
+    WindowPtr pWin
+);
+
+Bool AppleWMDoReorderWindow(
+    WindowPtr pWin
+);
+
+void AppleWMSendEvent(
+    int             /* type */,
+    unsigned int    /* mask */,
+    int             /* which */,
+    int             /* arg */
+);
+
+unsigned int AppleWMSelectedEvents(
+    void
+);
+
+#endif /* _APPLEWMEXT_H_ */
diff --git a/hw/xquartz/bundle/English.lproj/InfoPlist.strings b/hw/xquartz/bundle/English.lproj/InfoPlist.strings
new file mode 100644
index 0000000..88e1f04
Binary files /dev/null and b/hw/xquartz/bundle/English.lproj/InfoPlist.strings differ
diff --git a/hw/xquartz/bundle/English.lproj/Localizable.strings b/hw/xquartz/bundle/English.lproj/Localizable.strings
new file mode 100644
index 0000000..c83b085
Binary files /dev/null and b/hw/xquartz/bundle/English.lproj/Localizable.strings differ
diff --git a/hw/xquartz/bundle/English.lproj/main.nib/classes.nib b/hw/xquartz/bundle/English.lproj/main.nib/classes.nib
new file mode 100644
index 0000000..a82159b
--- /dev/null
+++ b/hw/xquartz/bundle/English.lproj/main.nib/classes.nib
@@ -0,0 +1,318 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>IBClasses</key>
+	<array>
+		<dict>
+			<key>CLASS</key>
+			<string>IBLibraryObjectTemplate</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>OUTLETS</key>
+			<dict>
+				<key>draggedView</key>
+				<string>NSView</string>
+				<key>representedObject</key>
+				<string>NSObject</string>
+			</dict>
+			<key>SUPERCLASS</key>
+			<string>NSView</string>
+		</dict>
+		<dict>
+			<key>CLASS</key>
+			<string>IBInspector</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>OUTLETS</key>
+			<dict>
+				<key>inspectorView</key>
+				<string>NSView</string>
+			</dict>
+			<key>SUPERCLASS</key>
+			<string>NSObject</string>
+		</dict>
+		<dict>
+			<key>CLASS</key>
+			<string>NSDateFormatter</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>SUPERCLASS</key>
+			<string>NSFormatter</string>
+		</dict>
+		<dict>
+			<key>ACTIONS</key>
+			<dict>
+				<key>apps_table_cancel</key>
+				<string>id</string>
+				<key>apps_table_delete</key>
+				<string>id</string>
+				<key>apps_table_done</key>
+				<string>id</string>
+				<key>apps_table_duplicate</key>
+				<string>id</string>
+				<key>apps_table_new</key>
+				<string>id</string>
+				<key>apps_table_show</key>
+				<string>id</string>
+				<key>bring_to_front</key>
+				<string>id</string>
+				<key>close_window</key>
+				<string>id</string>
+				<key>enable_fullscreen_changed</key>
+				<string>id</string>
+				<key>minimize_window</key>
+				<string>id</string>
+				<key>next_window</key>
+				<string>id</string>
+				<key>prefs_changed</key>
+				<string>id</string>
+				<key>prefs_show</key>
+				<string>id</string>
+				<key>previous_window</key>
+				<string>id</string>
+				<key>toggle_fullscreen</key>
+				<string>id</string>
+				<key>x11_help</key>
+				<string>id</string>
+				<key>zoom_window</key>
+				<string>id</string>
+			</dict>
+			<key>CLASS</key>
+			<string>X11Controller</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>OUTLETS</key>
+			<dict>
+				<key>apps_separator</key>
+				<string>id</string>
+				<key>apps_table</key>
+				<string>id</string>
+				<key>depth</key>
+				<string>id</string>
+				<key>dock_apps_menu</key>
+				<string>id</string>
+				<key>dock_menu</key>
+				<string>id</string>
+				<key>dock_window_separator</key>
+				<string>id</string>
+				<key>enable_auth</key>
+				<string>id</string>
+				<key>enable_fullscreen</key>
+				<string>id</string>
+				<key>enable_keyequivs</key>
+				<string>id</string>
+				<key>enable_tcp</key>
+				<string>id</string>
+				<key>fake_buttons</key>
+				<string>id</string>
+				<key>prefs_panel</key>
+				<string>id</string>
+				<key>sync_keymap</key>
+				<string>id</string>
+				<key>toggle_fullscreen_item</key>
+				<string>id</string>
+				<key>use_sysbeep</key>
+				<string>id</string>
+				<key>window_separator</key>
+				<string>id</string>
+				<key>x11_about_item</key>
+				<string>id</string>
+			</dict>
+			<key>SUPERCLASS</key>
+			<string>NSObject</string>
+		</dict>
+		<dict>
+			<key>CLASS</key>
+			<string>NSNumberFormatter</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>SUPERCLASS</key>
+			<string>NSFormatter</string>
+		</dict>
+		<dict>
+			<key>CLASS</key>
+			<string>NSFormatter</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>SUPERCLASS</key>
+			<string>NSObject</string>
+		</dict>
+		<dict>
+			<key>ACTIONS</key>
+			<dict>
+				<key>alignCenter:</key>
+				<string>id</string>
+				<key>alignJustified:</key>
+				<string>id</string>
+				<key>alignLeft:</key>
+				<string>id</string>
+				<key>alignRight:</key>
+				<string>id</string>
+				<key>arrangeInFront:</key>
+				<string>id</string>
+				<key>centerSelectionInVisibleArea:</key>
+				<string>id</string>
+				<key>changeFont:</key>
+				<string>id</string>
+				<key>checkSpelling:</key>
+				<string>id</string>
+				<key>clear:</key>
+				<string>id</string>
+				<key>clearRecentDocuments:</key>
+				<string>id</string>
+				<key>complete:</key>
+				<string>id</string>
+				<key>copy:</key>
+				<string>id</string>
+				<key>copyFont:</key>
+				<string>id</string>
+				<key>copyRuler:</key>
+				<string>id</string>
+				<key>cut:</key>
+				<string>id</string>
+				<key>delete:</key>
+				<string>id</string>
+				<key>deminiaturize:</key>
+				<string>id</string>
+				<key>fax:</key>
+				<string>id</string>
+				<key>hide:</key>
+				<string>id</string>
+				<key>hideOtherApplications:</key>
+				<string>id</string>
+				<key>loosenKerning:</key>
+				<string>id</string>
+				<key>lowerBaseline:</key>
+				<string>id</string>
+				<key>makeKeyAndOrderFront:</key>
+				<string>id</string>
+				<key>miniaturize:</key>
+				<string>id</string>
+				<key>newDocument:</key>
+				<string>id</string>
+				<key>openDocument:</key>
+				<string>id</string>
+				<key>orderBack:</key>
+				<string>id</string>
+				<key>orderFront:</key>
+				<string>id</string>
+				<key>orderFrontColorPanel:</key>
+				<string>id</string>
+				<key>orderFrontHelpPanel:</key>
+				<string>id</string>
+				<key>orderOut:</key>
+				<string>id</string>
+				<key>outline:</key>
+				<string>id</string>
+				<key>paste:</key>
+				<string>id</string>
+				<key>pasteAsPlainText:</key>
+				<string>id</string>
+				<key>pasteAsRichText:</key>
+				<string>id</string>
+				<key>pasteFont:</key>
+				<string>id</string>
+				<key>pasteRuler:</key>
+				<string>id</string>
+				<key>pause:</key>
+				<string>id</string>
+				<key>performClose:</key>
+				<string>id</string>
+				<key>performFindPanelAction:</key>
+				<string>id</string>
+				<key>performMiniaturize:</key>
+				<string>id</string>
+				<key>performZoom:</key>
+				<string>id</string>
+				<key>play:</key>
+				<string>id</string>
+				<key>print:</key>
+				<string>id</string>
+				<key>printDocument:</key>
+				<string>id</string>
+				<key>raiseBaseline:</key>
+				<string>id</string>
+				<key>record:</key>
+				<string>id</string>
+				<key>redo:</key>
+				<string>id</string>
+				<key>resume:</key>
+				<string>id</string>
+				<key>revertDocumentToSaved:</key>
+				<string>id</string>
+				<key>run:</key>
+				<string>id</string>
+				<key>runPageLayout:</key>
+				<string>id</string>
+				<key>runToolbarCustomizationPalette:</key>
+				<string>id</string>
+				<key>saveAllDocuments:</key>
+				<string>id</string>
+				<key>saveDocument:</key>
+				<string>id</string>
+				<key>saveDocumentAs:</key>
+				<string>id</string>
+				<key>saveDocumentTo:</key>
+				<string>id</string>
+				<key>selectAll:</key>
+				<string>id</string>
+				<key>selectText:</key>
+				<string>id</string>
+				<key>showGuessPanel:</key>
+				<string>id</string>
+				<key>showHelp:</key>
+				<string>id</string>
+				<key>start:</key>
+				<string>id</string>
+				<key>startSpeaking:</key>
+				<string>id</string>
+				<key>stop:</key>
+				<string>id</string>
+				<key>stopSpeaking:</key>
+				<string>id</string>
+				<key>subscript:</key>
+				<string>id</string>
+				<key>superscript:</key>
+				<string>id</string>
+				<key>terminate:</key>
+				<string>id</string>
+				<key>tightenKerning:</key>
+				<string>id</string>
+				<key>toggleContinuousSpellChecking:</key>
+				<string>id</string>
+				<key>toggleRuler:</key>
+				<string>id</string>
+				<key>toggleToolbarShown:</key>
+				<string>id</string>
+				<key>turnOffKerning:</key>
+				<string>id</string>
+				<key>turnOffLigatures:</key>
+				<string>id</string>
+				<key>underline:</key>
+				<string>id</string>
+				<key>undo:</key>
+				<string>id</string>
+				<key>unhideAllApplications:</key>
+				<string>id</string>
+				<key>unscript:</key>
+				<string>id</string>
+				<key>useAllLigatures:</key>
+				<string>id</string>
+				<key>useStandardKerning:</key>
+				<string>id</string>
+				<key>useStandardLigatures:</key>
+				<string>id</string>
+			</dict>
+			<key>CLASS</key>
+			<string>FirstResponder</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>SUPERCLASS</key>
+			<string>NSObject</string>
+		</dict>
+	</array>
+	<key>IBVersion</key>
+	<integer>1</integer>
+</dict>
+</plist>
diff --git a/hw/xquartz/bundle/English.lproj/main.nib/info.nib b/hw/xquartz/bundle/English.lproj/main.nib/info.nib
new file mode 100644
index 0000000..88bc626
--- /dev/null
+++ b/hw/xquartz/bundle/English.lproj/main.nib/info.nib
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>IBFramework Version</key>
+	<string>588</string>
+	<key>IBOpenObjects</key>
+	<array>
+		<integer>244</integer>
+		<integer>29</integer>
+		<integer>423</integer>
+	</array>
+	<key>IBSystem Version</key>
+	<string>9A356</string>
+	<key>targetFramework</key>
+	<string>IBCocoaFramework</string>
+</dict>
+</plist>
diff --git a/hw/xquartz/bundle/English.lproj/main.nib/keyedobjects.nib b/hw/xquartz/bundle/English.lproj/main.nib/keyedobjects.nib
new file mode 100644
index 0000000..8b31450
Binary files /dev/null and b/hw/xquartz/bundle/English.lproj/main.nib/keyedobjects.nib differ
diff --git a/hw/xquartz/bundle/Info.plist b/hw/xquartz/bundle/Info.plist
new file mode 100644
index 0000000..66f1f6b
--- /dev/null
+++ b/hw/xquartz/bundle/Info.plist
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>English</string>
+	<key>CFBundleExecutable</key>
+	<string>X11</string>
+	<key>CFBundleGetInfoString</key>
+	<string>X11</string>
+	<key>CFBundleIconFile</key>
+	<string>X11.icns</string>
+	<key>CFBundleIdentifier</key>
+	<string>org.x.X11</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundleName</key>
+	<string>X11</string>
+	<key>CFBundlePackageType</key>
+	<string>APPL</string>
+	<key>CFBundleShortVersionString</key>
+	<string>2.0</string>
+	<key>CFBundleSignature</key>
+	<string>x11a</string>
+	<key>CSResourcesFileMapped</key>
+	<true/>
+	<key>NSHumanReadableCopyright</key>
+	<string>Copyright © 2003-2007, Apple Inc.
+Copyright © 2003, XFree86 Project, Inc.</string>
+	<key>NSMainNibFile</key>
+	<string>main</string>
+	<key>NSPrincipalClass</key>
+	<string>X11Application</string>
+</dict>
+</plist>
diff --git a/hw/xquartz/bundle/Makefile.am b/hw/xquartz/bundle/Makefile.am
new file mode 100644
index 0000000..a6e2dfb
--- /dev/null
+++ b/hw/xquartz/bundle/Makefile.am
@@ -0,0 +1,28 @@
+bin_SCRIPTS = x11app
+
+.PHONY: x11app
+
+x11app:
+	xcodebuild CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" ARCHS="$(X11APP_ARCHS)"
+
+install-data-hook:
+	xcodebuild install DSTROOT="/$(DESTDIR)" INSTALL_PATH="$(APPLE_APPLICATIONS_DIR)" DEPLOYMENT_LOCATION=YES SKIP_INSTALL=NO ARCHS="$(X11APP_ARCHS)"
+	$(MKDIR_P) "$(DESTDIR)/System/Library/LaunchAgents/"
+	$(INSTALL) org.x.X11.plist "$(DESTDIR)/System/Library/LaunchAgents/"
+
+clean-local:
+	rm -rf build
+
+EXTRA_DIST = \
+	org.x.X11.plist \
+	Info.plist \
+	X11.icns \
+	bundle-main.c \
+	launcher-main.c \
+	server-main.c \
+	English.lproj/InfoPlist.strings \
+	English.lproj/Localizable.strings \
+	English.lproj/main.nib/classes.nib \
+	English.lproj/main.nib/info.nib \
+	English.lproj/main.nib/keyedobjects.nib \
+	X11.xcodeproj/project.pbxproj
diff --git a/hw/xquartz/bundle/X11.icns b/hw/xquartz/bundle/X11.icns
new file mode 100644
index 0000000..d770e61
Binary files /dev/null and b/hw/xquartz/bundle/X11.icns differ
diff --git a/hw/xquartz/bundle/X11.xcodeproj/project.pbxproj b/hw/xquartz/bundle/X11.xcodeproj/project.pbxproj
new file mode 100644
index 0000000..225f371
--- /dev/null
+++ b/hw/xquartz/bundle/X11.xcodeproj/project.pbxproj
@@ -0,0 +1,344 @@
+// !$*UTF8*$!
+{
+	archiveVersion = 1;
+	classes = {
+	};
+	objectVersion = 42;
+	objects = {
+
+/* Begin PBXBuildFile section */
+		3F5E1BE00D04BF110020CA24 /* launcher-main.c in Sources */ = {isa = PBXBuildFile; fileRef = 3F5E1BDE0D04BF110020CA24 /* launcher-main.c */; };
+		3F5E1BE10D04BF110020CA24 /* server-main.c in Sources */ = {isa = PBXBuildFile; fileRef = 3F5E1BDF0D04BF110020CA24 /* server-main.c */; };
+		527F24190B5D938C007840A7 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0867D6AAFE840B52C02AAC07 /* InfoPlist.strings */; };
+		527F241A0B5D938C007840A7 /* main.nib in Resources */ = {isa = PBXBuildFile; fileRef = 02345980000FD03B11CA0E72 /* main.nib */; };
+		527F241B0B5D938C007840A7 /* X11.icns in Resources */ = {isa = PBXBuildFile; fileRef = 50459C5F038587C60ECA21EC /* X11.icns */; };
+		527F241D0B5D938C007840A7 /* bundle-main.c in Sources */ = {isa = PBXBuildFile; fileRef = 50EE2AB703849F0B0ECA21EC /* bundle-main.c */; };
+		527F241F0B5D938C007840A7 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50F4F0A7039D6ACA0E82C0CB /* CoreFoundation.framework */; };
+		527F24200B5D938C007840A7 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 570C5748047186C400ACF82F /* SystemConfiguration.framework */; };
+		527F24370B5D9D89007840A7 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 527F24260B5D938C007840A7 /* Info.plist */; };
+		52D9C0ED0BCDDF6B00CD2AFC /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 52D9C0EB0BCDDF6B00CD2AFC /* Localizable.strings */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+		0867D6ABFE840B52C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+		1870340FFE93FCAF11CA0CD7 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/main.nib; sourceTree = "<group>"; };
+		3F5E1BDE0D04BF110020CA24 /* launcher-main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "launcher-main.c"; sourceTree = "<group>"; };
+		3F5E1BDF0D04BF110020CA24 /* server-main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "server-main.c"; sourceTree = "<group>"; };
+		50459C5F038587C60ECA21EC /* X11.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = X11.icns; sourceTree = "<group>"; };
+		50EE2AB703849F0B0ECA21EC /* bundle-main.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = "bundle-main.c"; sourceTree = "<group>"; };
+		50F4F0A7039D6ACA0E82C0CB /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = "<absolute>"; };
+		527F24260B5D938C007840A7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = Info.plist; sourceTree = "<group>"; };
+		527F24270B5D938C007840A7 /* X11.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = X11.app; sourceTree = BUILT_PRODUCTS_DIR; };
+		52D9C0EC0BCDDF6B00CD2AFC /* English */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/Localizable.strings; sourceTree = "<group>"; };
+		570C5748047186C400ACF82F /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = /System/Library/Frameworks/SystemConfiguration.framework; sourceTree = "<absolute>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+		527F241E0B5D938C007840A7 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				527F241F0B5D938C007840A7 /* CoreFoundation.framework in Frameworks */,
+				527F24200B5D938C007840A7 /* SystemConfiguration.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+		195DF8CFFE9D517E11CA2CBB /* Products */ = {
+			isa = PBXGroup;
+			children = (
+				527F24270B5D938C007840A7 /* X11.app */,
+			);
+			name = Products;
+			sourceTree = "<group>";
+		};
+		20286C29FDCF999611CA2CEA /* X11 */ = {
+			isa = PBXGroup;
+			children = (
+				20286C2AFDCF999611CA2CEA /* Sources */,
+				20286C2CFDCF999611CA2CEA /* Resources */,
+				20286C32FDCF999611CA2CEA /* External Frameworks and Libraries */,
+				195DF8CFFE9D517E11CA2CBB /* Products */,
+				527F24260B5D938C007840A7 /* Info.plist */,
+			);
+			name = X11;
+			sourceTree = "<group>";
+		};
+		20286C2AFDCF999611CA2CEA /* Sources */ = {
+			isa = PBXGroup;
+			children = (
+				3F5E1BDE0D04BF110020CA24 /* launcher-main.c */,
+				3F5E1BDF0D04BF110020CA24 /* server-main.c */,
+				50EE2AB703849F0B0ECA21EC /* bundle-main.c */,
+			);
+			name = Sources;
+			sourceTree = "<group>";
+		};
+		20286C2CFDCF999611CA2CEA /* Resources */ = {
+			isa = PBXGroup;
+			children = (
+				52D9C0EB0BCDDF6B00CD2AFC /* Localizable.strings */,
+				50459C5F038587C60ECA21EC /* X11.icns */,
+				0867D6AAFE840B52C02AAC07 /* InfoPlist.strings */,
+				02345980000FD03B11CA0E72 /* main.nib */,
+			);
+			name = Resources;
+			sourceTree = "<group>";
+		};
+		20286C32FDCF999611CA2CEA /* External Frameworks and Libraries */ = {
+			isa = PBXGroup;
+			children = (
+				50F4F0A7039D6ACA0E82C0CB /* CoreFoundation.framework */,
+				570C5748047186C400ACF82F /* SystemConfiguration.framework */,
+			);
+			name = "External Frameworks and Libraries";
+			sourceTree = "<group>";
+		};
+/* End PBXGroup section */
+
+/* Begin PBXHeadersBuildPhase section */
+		527F24170B5D938C007840A7 /* Headers */ = {
+			isa = PBXHeadersBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXHeadersBuildPhase section */
+
+/* Begin PBXNativeTarget section */
+		527F24160B5D938C007840A7 /* X11 */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 527F24220B5D938C007840A7 /* Build configuration list for PBXNativeTarget "X11" */;
+			buildPhases = (
+				527F24170B5D938C007840A7 /* Headers */,
+				527F24180B5D938C007840A7 /* Resources */,
+				527F241C0B5D938C007840A7 /* Sources */,
+				527F241E0B5D938C007840A7 /* Frameworks */,
+				527F24210B5D938C007840A7 /* Rez */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = X11;
+			productName = X11;
+			productReference = 527F24270B5D938C007840A7 /* X11.app */;
+			productType = "com.apple.product-type.application";
+		};
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+		20286C28FDCF999611CA2CEA /* Project object */ = {
+			isa = PBXProject;
+			buildConfigurationList = 527F24080B5D8FFC007840A7 /* Build configuration list for PBXProject "X11" */;
+			compatibilityVersion = "Xcode 2.4";
+			hasScannedForEncodings = 1;
+			mainGroup = 20286C29FDCF999611CA2CEA /* X11 */;
+			projectDirPath = "";
+			projectRoot = "";
+			targets = (
+				527F24160B5D938C007840A7 /* X11 */,
+			);
+		};
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+		527F24180B5D938C007840A7 /* Resources */ = {
+			isa = PBXResourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				527F24370B5D9D89007840A7 /* Info.plist in Resources */,
+				527F24190B5D938C007840A7 /* InfoPlist.strings in Resources */,
+				527F241A0B5D938C007840A7 /* main.nib in Resources */,
+				527F241B0B5D938C007840A7 /* X11.icns in Resources */,
+				52D9C0ED0BCDDF6B00CD2AFC /* Localizable.strings in Resources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXRezBuildPhase section */
+		527F24210B5D938C007840A7 /* Rez */ = {
+			isa = PBXRezBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXRezBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+		527F241C0B5D938C007840A7 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				527F241D0B5D938C007840A7 /* bundle-main.c in Sources */,
+				3F5E1BE00D04BF110020CA24 /* launcher-main.c in Sources */,
+				3F5E1BE10D04BF110020CA24 /* server-main.c in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXVariantGroup section */
+		02345980000FD03B11CA0E72 /* main.nib */ = {
+			isa = PBXVariantGroup;
+			children = (
+				1870340FFE93FCAF11CA0CD7 /* English */,
+			);
+			name = main.nib;
+			sourceTree = "<group>";
+		};
+		0867D6AAFE840B52C02AAC07 /* InfoPlist.strings */ = {
+			isa = PBXVariantGroup;
+			children = (
+				0867D6ABFE840B52C02AAC07 /* English */,
+			);
+			name = InfoPlist.strings;
+			sourceTree = "<group>";
+		};
+		52D9C0EB0BCDDF6B00CD2AFC /* Localizable.strings */ = {
+			isa = PBXVariantGroup;
+			children = (
+				52D9C0EC0BCDDF6B00CD2AFC /* English */,
+			);
+			name = Localizable.strings;
+			sourceTree = "<group>";
+		};
+/* End PBXVariantGroup section */
+
+/* Begin XCBuildConfiguration section */
+		527F24090B5D8FFC007840A7 /* Development */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				INSTALL_MODE_FLAG = "a+rX";
+			};
+			name = Development;
+		};
+		527F240A0B5D8FFC007840A7 /* Deployment */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				INSTALL_MODE_FLAG = "a+rX";
+			};
+			name = Deployment;
+		};
+		527F240B0B5D8FFC007840A7 /* Default */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				INSTALL_MODE_FLAG = "a+rX";
+			};
+			name = Default;
+		};
+		527F24230B5D938C007840A7 /* Development */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				COPY_PHASE_STRIP = NO;
+				FRAMEWORK_SEARCH_PATHS = "";
+				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+				HEADER_SEARCH_PATHS = /usr/X11/include;
+				INFOPLIST_FILE = Info.plist;
+				INSTALL_PATH = /usr/X11;
+				LIBRARY_SEARCH_PATHS = /usr/X11/lib;
+				OTHER_CFLAGS = "";
+				OTHER_LDFLAGS = (
+					"-lXau",
+					"-lxcb",
+					"-lX11",
+				);
+				OTHER_REZFLAGS = "";
+				PRODUCT_NAME = X11;
+				SECTORDER_FLAGS = "";
+				WARNING_CFLAGS = (
+					"-Wmost",
+					"-Wno-four-char-constants",
+					"-Wno-unknown-pragmas",
+				);
+				WRAPPER_EXTENSION = app;
+			};
+			name = Development;
+		};
+		527F24240B5D938C007840A7 /* Deployment */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				COPY_PHASE_STRIP = YES;
+				FRAMEWORK_SEARCH_PATHS = "";
+				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+				HEADER_SEARCH_PATHS = /usr/X11/include;
+				INFOPLIST_FILE = Info.plist;
+				INSTALL_PATH = /usr/X11;
+				LIBRARY_SEARCH_PATHS = /usr/X11/lib;
+				OTHER_CFLAGS = "";
+				OTHER_LDFLAGS = (
+					"-lXau",
+					"-lxcb",
+					"-lX11",
+				);
+				OTHER_REZFLAGS = "";
+				PRODUCT_NAME = X11;
+				SECTORDER_FLAGS = "";
+				WARNING_CFLAGS = (
+					"-Wmost",
+					"-Wno-four-char-constants",
+					"-Wno-unknown-pragmas",
+				);
+				WRAPPER_EXTENSION = app;
+			};
+			name = Deployment;
+		};
+		527F24250B5D938C007840A7 /* Default */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				FRAMEWORK_SEARCH_PATHS = "";
+				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+				HEADER_SEARCH_PATHS = /usr/X11/include;
+				INFOPLIST_FILE = Info.plist;
+				INSTALL_PATH = /usr/X11;
+				LIBRARY_SEARCH_PATHS = /usr/X11/lib;
+				OTHER_CFLAGS = "";
+				OTHER_LDFLAGS = (
+					"-lXau",
+					"-lxcb",
+					"-lX11",
+				);
+				OTHER_REZFLAGS = "";
+				PRODUCT_NAME = X11;
+				SECTORDER_FLAGS = "";
+				WARNING_CFLAGS = (
+					"-Wmost",
+					"-Wno-four-char-constants",
+					"-Wno-unknown-pragmas",
+				);
+				WRAPPER_EXTENSION = app;
+			};
+			name = Default;
+		};
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+		527F24080B5D8FFC007840A7 /* Build configuration list for PBXProject "X11" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				527F24090B5D8FFC007840A7 /* Development */,
+				527F240A0B5D8FFC007840A7 /* Deployment */,
+				527F240B0B5D8FFC007840A7 /* Default */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Default;
+		};
+		527F24220B5D938C007840A7 /* Build configuration list for PBXNativeTarget "X11" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				527F24230B5D938C007840A7 /* Development */,
+				527F24240B5D938C007840A7 /* Deployment */,
+				527F24250B5D938C007840A7 /* Default */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Default;
+		};
+/* End XCConfigurationList section */
+	};
+	rootObject = 20286C28FDCF999611CA2CEA /* Project object */;
+}
diff --git a/hw/xquartz/bundle/bundle-main.c b/hw/xquartz/bundle/bundle-main.c
new file mode 100644
index 0000000..c436d51
--- /dev/null
+++ b/hw/xquartz/bundle/bundle-main.c
@@ -0,0 +1,82 @@
+/* main.c -- X application launcher
+ 
+ Copyright (c) 2007 Jeremy Huddleston
+ Copyright (c) 2007 Apple Inc
+ 
+ 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 <X11/Xlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+
+int launcher_main(int argc, char **argv);
+int server_main(int argc, char **argv);
+
+int main(int argc, char **argv) {
+    Display *display;
+  
+    fprintf(stderr, "X11.app: main(): argc=%d\n", argc);
+    int i;
+    for(i=0; i < argc; i++) {
+        fprintf(stderr, "\targv[%d] = %s\n", i, argv[i]);
+    }
+    
+    /* First check if launchd started us */
+    if(argc == 2 && !strncmp(argv[1], "--launchd", 9)) {
+        argc--;
+        argv[1] = argv[0];
+        argv++;
+        fprintf(stderr, "X11.app: main(): launchd called us, running server_main()");
+        return server_main(argc, argv);
+    }
+
+    /* If we have a process serial number and it's our only arg, act as if
+     * the user double clicked the app bundle: launch app_to_run if possible
+     */
+    if(argc == 1 || (argc == 2 && !strncmp(argv[1], "-psn_", 5))) {
+        /* Now, try to open a display, if so, run the launcher */
+        display = XOpenDisplay(NULL);
+        if(display) {
+            fprintf(stderr, "X11.app: main(): closing the display");
+            /* Could open the display, start the launcher */
+            XCloseDisplay(display);
+
+            /* Give 2 seconds for the server to start... 
+             * TODO: *Really* fix this race condition
+             */
+            usleep(2000);
+            fprintf(stderr, "X11.app: main(): running launcher_main()");
+            return launcher_main(argc, argv);
+        }
+    }
+
+    /* Couldn't open the display or we were called with arguments,
+     * just want to start a server.
+     */
+    fprintf(stderr, "X11.app: main(): running server_main()");
+    return server_main(argc, argv);
+}
diff --git a/hw/xquartz/bundle/launcher-main.c b/hw/xquartz/bundle/launcher-main.c
new file mode 100644
index 0000000..60a1624
--- /dev/null
+++ b/hw/xquartz/bundle/launcher-main.c
@@ -0,0 +1,81 @@
+/* main.c -- X application launcher
+ 
+ Copyright (c) 2007 Apple Inc.
+ 
+ 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 <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+#include <CoreFoundation/CoreFoundation.h>
+
+#define DEFAULT_APP "/usr/X11/bin/xterm"
+
+int launcher_main (int argc, char **argv) {
+  char *command = DEFAULT_APP;
+  const char *newargv[7];
+  int child;
+  
+
+	CFPropertyListRef PlistRef = CFPreferencesCopyAppValue(CFSTR("app_to_run"),
+									kCFPreferencesCurrentApplication);
+	
+	if ((PlistRef == NULL) || (CFGetTypeID(PlistRef) != CFStringGetTypeID())) {
+		CFPreferencesSetAppValue(CFSTR("app_to_run"), CFSTR(DEFAULT_APP), 
+								 kCFPreferencesCurrentApplication);
+		CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
+	} else {
+		int len = CFStringGetLength((CFStringRef)PlistRef)+1;
+		command = (char *) malloc(len);
+		CFStringGetCString((CFStringRef)PlistRef, command, len,  kCFStringEncodingASCII);
+		fprintf(stderr, "command=%s\n", command);
+	}
+	
+	if (PlistRef) CFRelease(PlistRef);
+	
+	newargv[0] = "/usr/bin/login";
+	newargv[1] = "-fp";
+	newargv[2] = getlogin();
+	newargv[3] = "/bin/sh";
+	newargv[4] = "-c";
+	newargv[5] = command;
+	newargv[6] = NULL;
+
+    child = fork();
+	
+    switch (child) {
+    case -1:				/* error */
+      perror ("fork");
+      return EXIT_FAILURE;		
+    case 0:				    /* child */
+      execvp (newargv[0], (char **const) newargv);
+      perror ("Couldn't exec");
+      _exit (1);
+   }
+	
+    return 0;
+}
diff --git a/hw/xquartz/bundle/org.x.X11.plist b/hw/xquartz/bundle/org.x.X11.plist
new file mode 100644
index 0000000..6c6be91
--- /dev/null
+++ b/hw/xquartz/bundle/org.x.X11.plist
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>Label</key>
+		<string>org.x.X11</string>
+	<key>Program</key>
+		<string>/Applications/Utilities/X11.app/Contents/MacOS/X11</string>
+	<key>ProgramArguments</key>
+		<array>
+		<string>/Applications/Utilities/X11.app/Contents/MacOS/X11</string>
+		<string>--launchd</string>
+		</array>
+	<key>Sockets</key>
+		<dict>
+		<key>:0</key>
+			<dict>
+			<key>SecureSocketWithKey</key>
+				<string>DISPLAY</string>
+			</dict>
+		</dict>
+	<key>ServiceIPC</key>
+		<true/>
+</dict>
+</plist>
diff --git a/hw/xquartz/bundle/server-main.c b/hw/xquartz/bundle/server-main.c
new file mode 100644
index 0000000..26fcbb0
--- /dev/null
+++ b/hw/xquartz/bundle/server-main.c
@@ -0,0 +1,904 @@
+/* bundle-main.c -- X server launcher
+ 
+ Copyright (c) 2002-2007 Apple Inc. 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 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.
+ 
+ Parts of this file are derived from xdm, which has this copyright:
+ 
+ Copyright 1988, 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. */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <sys/utsname.h>
+#include <ifaddrs.h>
+#include <netdb.h>
+#include <netinet/in.h>
+#include <time.h>
+#include <sys/wait.h>
+#include <setjmp.h>
+#include <sys/ioctl.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xauth.h>
+#include <xcb/xcb.h>
+
+#include <CoreFoundation/CoreFoundation.h>
+#include <SystemConfiguration/SystemConfiguration.h>
+
+#define X_SERVER "/usr/X11/bin/Xquartz"
+#define XTERM_PATH "/usr/X11/bin/xterm"
+#define WM_PATH "/usr/bin/quartz-wm"
+#define DEFAULT_XINITRC "/usr/X11/lib/X11/xinit/xinitrc"
+#define DEFAULT_PATH "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11/bin"
+
+/* what xinit does */
+#ifndef SHELL
+# define SHELL "sh"
+#endif
+
+#undef FALSE
+#define FALSE 0
+#undef TRUE
+#define TRUE 1
+
+#define MAX_DISPLAYS 64
+
+static int server_pid = -1, client_pid = -1;
+static int xinit_kills_server = FALSE;
+static jmp_buf exit_continuation;
+static const char *server_name = NULL;
+static Display *server_dpy;
+
+static char *auth_file;
+
+typedef struct addr_list_struct addr_list;
+
+struct addr_list_struct {
+    addr_list *next;
+    Xauth auth;
+};
+
+static addr_list *addresses;
+
+
+/* Utility functions. */
+
+/* Return the current host name. Matches what Xlib does. */
+static char *
+host_name (void)
+{
+#ifdef NEED_UTSNAME
+    static struct utsname name;
+	
+    uname(&name);
+	
+    return name.nodename;
+#else
+    static char buf[100];
+	
+    gethostname(buf, sizeof(buf));
+	
+    return buf;
+#endif
+}
+
+static int
+read_boolean_pref (CFStringRef name, int default_)
+{
+    int value;
+    Boolean ok;
+	
+    value = CFPreferencesGetAppBooleanValue (name,
+											 CFSTR ("com.apple.x11"), &ok);
+    return ok ? value : default_;
+}
+
+static inline int
+binary_equal (const void *a, const void *b, int length)
+{
+    return memcmp (a, b, length) == 0;
+}
+
+static inline void *
+binary_dup (const void *a, int length)
+{
+    void *b = malloc (length);
+    if (b != NULL)
+		memcpy (b, a, length);
+    return b;
+}
+
+static inline void
+binary_free (void *data, int length)
+{
+    if (data != NULL)
+		free (data);
+}
+
+
+/* Functions for managing the authentication entries. */
+
+/* Returns true if something matching AUTH is in our list of auth items */
+static int
+check_auth_item (Xauth *auth)
+{
+    addr_list *a;
+	
+    for (a = addresses; a != NULL; a = a->next)
+    {
+		if (a->auth.family == auth->family
+			&& a->auth.address_length == auth->address_length
+			&& binary_equal (a->auth.address, auth->address, auth->address_length)
+			&& a->auth.number_length == auth->number_length
+			&& binary_equal (a->auth.number, auth->number, auth->number_length)
+			&& a->auth.name_length == auth->name_length
+			&& binary_equal (a->auth.name, auth->name, auth->name_length))
+		{
+			return TRUE;
+		}
+    }
+	
+    return FALSE;
+}
+
+/* Add one item to our list of auth items. */
+static void
+add_auth_item (Xauth *auth)
+{
+    addr_list *a = malloc (sizeof (addr_list));
+	
+    a->auth.family = auth->family;
+    a->auth.address_length = auth->address_length;
+    a->auth.address = binary_dup (auth->address, auth->address_length);
+    a->auth.number_length = auth->number_length;
+    a->auth.number = binary_dup (auth->number, auth->number_length);
+    a->auth.name_length = auth->name_length;
+    a->auth.name = binary_dup (auth->name, auth->name_length);
+    a->auth.data_length = auth->data_length;
+    a->auth.data = binary_dup (auth->data, auth->data_length);
+	
+    a->next = addresses;
+    addresses = a;
+}
+
+/* Free all allocated auth items. */
+static void
+free_auth_items (void)
+{
+    addr_list *a;
+	
+    while ((a = addresses) != NULL)
+    {
+		addresses = a->next;
+		
+		binary_free (a->auth.address, a->auth.address_length);
+		binary_free (a->auth.number, a->auth.number_length);
+		binary_free (a->auth.name, a->auth.name_length);
+		binary_free (a->auth.data, a->auth.data_length);
+		free (a);
+    }
+}
+
+/* Add the unix domain auth item. */
+static void
+define_local (Xauth *auth)
+{
+    char *host = host_name ();
+	
+#ifdef DEBUG
+    fprintf (stderr, "x11: hostname is %s\n", host);
+#endif
+	
+    auth->family = FamilyLocal;
+    auth->address_length = strlen (host);
+    auth->address = host;
+	
+    add_auth_item (auth);
+}
+
+/* Add the tcp auth item. */
+static void
+define_named (Xauth *auth, const char *name)
+{
+    struct ifaddrs *addrs, *ptr;
+	
+    if (getifaddrs (&addrs) != 0)
+		return;
+	
+    for (ptr = addrs; ptr != NULL; ptr = ptr->ifa_next)
+    {
+		if (ptr->ifa_addr->sa_family != AF_INET)
+			continue;
+		
+		auth->family = FamilyInternet;
+		auth->address_length = sizeof (struct in_addr);
+		auth->address = (char *) &(((struct sockaddr_in *) ptr->ifa_addr)->sin_addr);
+		
+#ifdef DEBUG
+		fprintf (stderr, "x11: ipaddr is %d.%d.%d.%d\n",
+				 (unsigned char) auth->address[0],
+				 (unsigned char) auth->address[1],
+				 (unsigned char) auth->address[2],
+				 (unsigned char) auth->address[3]);
+#endif
+		
+		add_auth_item (auth);
+    }
+	
+    freeifaddrs (addrs);
+}
+
+/* Parse the display number from NAME and add it to AUTH. */
+static void
+set_auth_number (Xauth *auth, const char *name)
+{
+    char *colon;
+    char *dot, *number;
+	
+    colon = strrchr(name, ':');
+    if (colon != NULL)
+    {
+		colon++;
+		dot = strchr(colon, '.');
+		
+		if (dot != NULL)
+			auth->number_length = dot - colon;
+		else
+			auth->number_length = strlen (colon);
+		
+		number = malloc (auth->number_length + 1);
+		if (number != NULL)
+		{
+			strncpy (number, colon, auth->number_length);
+			number[auth->number_length] = '\0';
+		}
+		else
+		{
+			auth->number_length = 0;
+		}
+		
+		auth->number = number;
+    }
+}
+
+/* Put 128 bits of random data into DATA. If possible, it will be "high
+ quality" */
+static int
+generate_mit_magic_cookie (char data[16])
+{
+    int fd, ret, i;
+    long *ldata = (long *) data;
+	
+    fd = open ("/dev/random", O_RDONLY);
+    if (fd > 0) {
+		ret = read (fd, data, 16);
+		close (fd);
+		if (ret == 16) return TRUE;
+    }
+	
+    /* fall back to the usual crappy rng */
+	
+    srand48 (getpid () ^ time (NULL));
+	
+    for (i = 0; i < 4; i++)
+		ldata[i] = lrand48 ();
+	
+    return TRUE;
+}
+
+/* Create the keys we'll be using for the display named NAME. */
+static int
+make_auth_keys (const char *name)
+{
+    Xauth auth;
+    char key[16];
+	
+    if (auth_file == NULL)
+		return FALSE;
+	
+    auth.name = "MIT-MAGIC-COOKIE-1";
+    auth.name_length = strlen (auth.name);
+	
+    if (!generate_mit_magic_cookie (key))
+    {
+		auth_file = NULL;
+		return FALSE;
+    }
+	
+    auth.data = key;
+    auth.data_length = 16;
+	
+    set_auth_number (&auth, name);
+	
+    define_named (&auth, host_name ());
+    define_local (&auth);
+	
+    free (auth.number);
+	
+    return TRUE;
+}
+
+/* If ADD-ENTRIES is true, merge our auth entries into the existing
+ Xauthority file. If ADD-ENTRIES is false, remove our entries. */
+static int
+write_auth_file (int add_entries)
+{
+    char *home, newname[1024];
+    int fd, ret;
+    FILE *new_fh, *old_fh;
+    addr_list *addr;
+    Xauth *auth;
+	
+    if (auth_file == NULL)
+		return FALSE;
+	
+    home = getenv ("HOME");
+    if (home == NULL)
+    {
+		auth_file = NULL;
+		return FALSE;
+    }
+	
+    snprintf (newname, sizeof (newname), "%s/.XauthorityXXXXXX", home);
+    mktemp (newname);
+	
+    if (XauLockAuth (auth_file, 1, 2, 10) != LOCK_SUCCESS)
+    {
+		/* FIXME: do something here? */
+		
+		auth_file = NULL;
+		return FALSE;
+    }
+	
+    fd = open (newname, O_WRONLY | O_CREAT | O_TRUNC, 0600);
+    if (fd >= 0)
+    {
+		new_fh = fdopen (fd, "w");
+		if (new_fh != NULL)
+		{
+			if (add_entries)
+			{
+				for (addr = addresses; addr != NULL; addr = addr->next)
+				{
+					XauWriteAuth (new_fh, &addr->auth);
+				}
+			}
+			
+			old_fh = fopen (auth_file, "r");
+			if (old_fh != NULL)
+			{
+				while ((auth = XauReadAuth (old_fh)) != NULL)
+				{
+					if (!check_auth_item (auth))
+						XauWriteAuth (new_fh, auth);
+					XauDisposeAuth (auth);
+				}
+				fclose (old_fh);
+			}
+			
+			fclose (new_fh);
+			unlink (auth_file);
+			
+			ret = rename (newname, auth_file);
+			
+			if (ret != 0)
+				auth_file = NULL;
+			
+			XauUnlockAuth (auth_file);
+			return ret == 0;
+		}
+		
+		close (fd);
+    }
+	
+    XauUnlockAuth (auth_file);
+    auth_file = NULL;
+    return FALSE;
+}
+
+
+/* Subprocess management functions. */
+
+static int
+start_server (char **xargv)
+{
+    int child;
+	
+    child = fork ();
+	
+    switch (child)
+    {
+    case -1:				/* error */
+		perror ("fork");
+		return FALSE;
+		
+    case 0:				/* child */
+		execv (X_SERVER, xargv);
+		perror ("Couldn't exec " X_SERVER);
+		_exit (1);
+		
+    default:				/* parent */
+		server_pid = child;
+		return TRUE;
+    }
+}
+
+static int
+wait_for_server (void)
+{
+    int count = 100;
+	
+    while (count-- > 0)
+    {
+		int status;
+		
+		server_dpy = XOpenDisplay (server_name);
+		if (server_dpy != NULL)
+			return TRUE;
+		
+		if (waitpid (server_pid, &status, WNOHANG) == server_pid)
+			return FALSE;
+		
+		sleep (1);
+    }
+	
+    return FALSE;
+}
+
+static int
+start_client (void)
+{
+    int child;
+	
+    child = fork();
+	
+    switch (child) {
+		char *temp, buf[1024];		
+
+	case -1:				/* error */
+		perror("fork");
+		return FALSE;
+
+	case 0:					/* child */
+		/* Setup environment */
+		temp = getenv("DISPLAY");
+//		if (temp == NULL && temp[0] != 0)
+			setenv("DISPLAY", server_name, TRUE);
+
+		temp = getenv("PATH");
+		if (temp == NULL || temp[0] == 0) 
+			setenv ("PATH", DEFAULT_PATH, TRUE);
+		else if (strnstr(temp, "/usr/X11/bin", sizeof(temp)) == NULL) {
+			snprintf(buf, sizeof(buf), "%s:/usr/X11/bin", temp);		
+			setenv("PATH", buf, TRUE);	
+		}
+		
+		/* First try value of $XINITRC, if set. */
+		temp = getenv("XINITRC");
+		if (temp != NULL && temp[0] != 0 && access(temp, R_OK) == 0)
+			execlp (SHELL, SHELL, temp, NULL);
+
+		/* Then look for .xinitrc in user's home directory. */
+		temp = getenv("HOME");
+		if (temp != NULL && temp[0] != 0) {
+			chdir(temp);
+			snprintf (buf, sizeof (buf), "%s/.xinitrc", temp);
+			if (access(buf, R_OK) == 0)
+				execlp(SHELL, SHELL, buf, NULL);
+		}
+		
+		/* Then try the default xinitrc in the lib directory. */
+		
+		if (access(DEFAULT_XINITRC, R_OK) == 0)
+			execlp(SHELL, SHELL, DEFAULT_XINITRC, NULL);
+		
+		/* Then fallback to hardcoding an xterm and the window manager. */
+		
+		//		system(XTERM_PATH " &");
+		execl(WM_PATH, WM_PATH, NULL);
+		
+		perror("exec");
+		_exit(1);
+		
+    default:				/* parent */
+		client_pid = child;
+		return TRUE;
+    }
+}
+
+static void
+sigchld_handler (int sig)
+{
+    int pid, status;
+	
+	again:
+    pid = waitpid (WAIT_ANY, &status, WNOHANG);
+	
+    if (pid > 0)
+    {
+		if (pid == server_pid)
+		{
+			server_pid = -1;
+			
+			if (client_pid >= 0)
+				kill (client_pid, SIGTERM);
+		}
+		else if (pid == client_pid)
+		{
+			client_pid = -1;
+			
+			if (server_pid >= 0 && xinit_kills_server)
+				kill (server_pid, SIGTERM);
+		}
+		goto again;
+    }
+	
+    if (server_pid == -1 && client_pid == -1)
+		longjmp (exit_continuation, 1);
+	
+    signal (SIGCHLD, sigchld_handler);
+}
+
+
+/* Server utilities. */
+
+static Boolean
+display_exists_p (int number)
+{
+    char buf[64];
+    xcb_connection_t *conn;
+    char *fullname = NULL;
+    int idisplay, iscreen;
+    char *conn_auth_name, *conn_auth_data;
+    int conn_auth_namelen, conn_auth_datalen;
+    
+    //    extern void *_X11TransConnectDisplay ();
+    //    extern void _XDisconnectDisplay ();
+	
+    /* Since connecting to the display waits for a few seconds if the
+	 display doesn't exist, check for trivial non-existence - if the
+	 socket in /tmp exists or not.. (note: if the socket exists, the
+	 server may still not, so we need to try to connect in that case..) */
+	
+    sprintf (buf, "/tmp/.X11-unix/X%d", number);
+    if (access (buf, F_OK) != 0)
+		return FALSE;
+    
+    sprintf (buf, ":%d", number);
+    conn = xcb_connect(buf, NULL);
+    if (xcb_connection_has_error(conn)) return FALSE;
+	
+    xcb_disconnect(conn);
+    return TRUE;
+}
+
+
+/* Monitoring when the system's ip addresses change. */
+
+static Boolean pending_timer;
+
+static void
+timer_callback (CFRunLoopTimerRef timer, void *info)
+{
+    pending_timer = FALSE;
+	
+    /* Update authentication names. Need to write .Xauthority file first
+	 without the existing entries, then again with the new entries.. */
+	
+    write_auth_file (FALSE);
+	
+    free_auth_items ();
+    make_auth_keys (server_name);
+	
+    write_auth_file (TRUE);
+}
+
+/* This function is called when the system's ip addresses may have changed. */
+static void
+ipaddr_callback (SCDynamicStoreRef store, CFArrayRef changed_keys, void *info)
+{
+#if DEBUG
+    if (changed_keys != NULL) {
+		fprintf (stderr, "x11: changed sc keys: ");
+		CFShow (changed_keys);
+    }
+#endif
+
+    if (auth_file != NULL && !pending_timer)
+    {
+		CFRunLoopTimerRef timer;
+		
+		timer = CFRunLoopTimerCreate (NULL, CFAbsoluteTimeGetCurrent () + 1.0,
+									  0.0, 0, 0, timer_callback, NULL);
+		CFRunLoopAddTimer (CFRunLoopGetCurrent (), timer,
+						   kCFRunLoopDefaultMode);
+		CFRelease (timer);
+		
+		pending_timer = TRUE;
+    }
+}
+
+/* This code adapted from "Living in a Dynamic TCP/IP Environment" technote. */
+static Boolean
+install_ipaddr_source (void)
+{
+    CFRunLoopSourceRef source = NULL;
+	
+    SCDynamicStoreContext context = {0};
+    SCDynamicStoreRef ref;
+	
+    ref = SCDynamicStoreCreate (NULL,
+								CFSTR ("AddIPAddressListChangeCallbackSCF"),
+								ipaddr_callback, &context);
+	
+    if (ref != NULL)
+    {
+		const void *keys[4], *patterns[2];
+		int i;
+		
+		keys[0] = SCDynamicStoreKeyCreateNetworkGlobalEntity (NULL, kSCDynamicStoreDomainState, kSCEntNetIPv4);
+		keys[1] = SCDynamicStoreKeyCreateNetworkGlobalEntity (NULL, kSCDynamicStoreDomainState, kSCEntNetIPv6);
+		keys[2] = SCDynamicStoreKeyCreateComputerName (NULL);
+		keys[3] = SCDynamicStoreKeyCreateHostNames (NULL);
+		
+		patterns[0] = SCDynamicStoreKeyCreateNetworkInterfaceEntity (NULL, kSCDynamicStoreDomainState, kSCCompAnyRegex, kSCEntNetIPv4);
+		patterns[1] = SCDynamicStoreKeyCreateNetworkInterfaceEntity (NULL, kSCDynamicStoreDomainState, kSCCompAnyRegex, kSCEntNetIPv6);
+		
+		if (keys[0] != NULL && keys[1] != NULL && keys[2] != NULL
+			&& keys[3] != NULL && patterns[0] != NULL && patterns[1] != NULL)
+		{
+			CFArrayRef key_array, pattern_array;
+			
+			key_array = CFArrayCreate (NULL, keys, 4, &kCFTypeArrayCallBacks);
+			pattern_array = CFArrayCreate (NULL, patterns, 2, &kCFTypeArrayCallBacks);
+			
+			if (key_array != NULL || pattern_array != NULL)
+			{
+				SCDynamicStoreSetNotificationKeys (ref, key_array, pattern_array);
+				source = SCDynamicStoreCreateRunLoopSource (NULL, ref, 0);
+			}
+			
+			if (key_array != NULL)
+				CFRelease (key_array);
+			if (pattern_array != NULL)
+				CFRelease (pattern_array);
+		}
+		
+		
+		for (i = 0; i < 4; i++)
+			if (keys[i] != NULL)
+			CFRelease (keys[i]);
+		for (i = 0; i < 2; i++)
+			if (patterns[i] != NULL)
+			CFRelease (patterns[i]);
+		
+		CFRelease (ref); 
+    }
+	
+    if (source != NULL)
+    {
+		CFRunLoopAddSource (CFRunLoopGetCurrent (),
+							source, kCFRunLoopDefaultMode);
+		CFRelease (source);
+    }
+	
+    return source != NULL;
+}
+
+
+/* Entrypoint. */
+
+void
+termination_signal_handler (int unused_sig)
+{
+    signal (SIGTERM, SIG_DFL);
+    signal (SIGHUP, SIG_DFL);
+    signal (SIGINT, SIG_DFL);
+    signal (SIGQUIT, SIG_DFL);
+
+    longjmp (exit_continuation, 1);
+}
+
+int
+server_main (int argc, char **argv)
+{
+    char **xargv;
+    int i, j;
+    int fd;
+	
+    xargv = alloca (sizeof (char *) * (argc + 32));
+	
+    if (!read_boolean_pref (CFSTR ("no_auth"), FALSE))
+		auth_file = XauFileName ();
+	
+    /* The standard X11 behaviour is for the server to quit when the first
+	 client exits. But it can be useful for debugging (and to mimic our
+	 behaviour in the beta releases) to not do that. */
+	
+    xinit_kills_server = read_boolean_pref (CFSTR ("xinit_kills_server"), TRUE);
+	
+    for (i = 1; i < argc; i++)
+    {
+		if (argv[i][0] == ':')
+			server_name = argv[i];
+    }
+	
+    if (server_name == NULL)
+    {
+		static char name[8];
+		
+		/* No display number specified, so search for the first unused.
+		 
+		 There's a big old race condition here if two servers start at
+		 the same time, but that's fairly unlikely. We could create
+		 lockfiles or something, but that's seems more likely to cause
+		 problems than the race condition itself.. */
+		
+		for (i = 0; i < MAX_DISPLAYS; i++)
+		{
+			if (!display_exists_p (i))
+				break;
+		}
+		
+		if (i == MAX_DISPLAYS)
+		{
+			fprintf (stderr, "%s: couldn't allocate a display number", argv[0]);
+			exit (1);
+		}
+		
+		sprintf (name, ":%d", i);
+		server_name = name;
+    }
+	
+    if (auth_file != NULL)
+    {
+		/* Create new Xauth keys and add them to the .Xauthority file */
+		
+		make_auth_keys (server_name);
+		write_auth_file (TRUE);
+    }
+	
+    /* Construct our new argv */
+	
+    i = j = 0;
+	
+    xargv[i++] = argv[j++];
+	
+    if (auth_file != NULL)
+    {
+		xargv[i++] = "-auth";
+		xargv[i++] = auth_file;
+    }
+	
+    /* By default, don't listen on tcp sockets if Xauth is disabled. */
+	
+    if (read_boolean_pref (CFSTR ("nolisten_tcp"), auth_file == NULL))
+    {
+		xargv[i++] = "-nolisten";
+		xargv[i++] = "tcp";
+    }
+	
+    while (j < argc)
+    {
+		if (argv[j++][0] != ':')
+			xargv[i++] = argv[j-1];
+    }
+	
+    xargv[i++] = (char *) server_name;
+    xargv[i++] = NULL;
+	
+    /* Detach from any controlling terminal and connect stdin to /dev/null */
+	
+#ifdef TIOCNOTTY
+    fd = open ("/dev/tty", O_RDONLY);
+    if (fd != -1)
+    {
+		ioctl (fd, TIOCNOTTY, 0);
+		close (fd);
+    }
+#endif
+	
+    fd = open ("/dev/null", O_RDWR, 0);
+    if (fd >= 0)
+    {
+		dup2 (fd, 0);
+		if (fd > 0)
+			close (fd);
+    }
+	
+    if (!start_server (xargv))
+		return 1;
+	
+    if (!wait_for_server ())
+    {
+		kill (server_pid, SIGTERM);
+		return 1;
+    }
+	
+    if (!start_client ())
+    {
+		kill (server_pid, SIGTERM);
+		return 1;
+    }
+	
+    signal (SIGCHLD, sigchld_handler);
+	
+    signal (SIGTERM, termination_signal_handler);
+    signal (SIGHUP, termination_signal_handler);
+    signal (SIGINT, termination_signal_handler);
+    signal (SIGQUIT, termination_signal_handler);
+
+    if (setjmp (exit_continuation) == 0)
+    {
+		if (install_ipaddr_source ())
+			CFRunLoopRun ();
+		else
+			while (1) pause ();
+    }
+	
+    signal (SIGCHLD, SIG_IGN);
+
+    if (client_pid >= 0) kill (client_pid, SIGTERM);
+    if (server_pid >= 0) kill (server_pid, SIGTERM);
+	
+    if (auth_file != NULL)
+    {
+		/* Remove our Xauth keys */
+		
+		write_auth_file (FALSE);
+    }
+	
+    free_auth_items ();
+	
+    return 0;
+}
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
new file mode 100644
index 0000000..b46b768
--- /dev/null
+++ b/hw/xquartz/darwin.c
@@ -0,0 +1,1080 @@
+/**************************************************************
+ *
+ * Shared code for the Darwin X Server
+ * running with Quartz or IOKit display mode
+ *
+ * Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
+ * Copyright (c) 2007 Apple Inc.
+ *
+ * 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "os.h"
+#include "servermd.h"
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "mibstore.h"		// mi backing store implementation
+#include "mipointer.h"		// mi software cursor
+#include "micmap.h"		// mi colormap code
+#include "fb.h"			// fb framebuffer code
+#include "site.h"
+#include "globals.h"
+#include "dix.h"
+
+#ifdef XINPUT
+# include <X11/extensions/XI.h>
+# include <X11/extensions/XIproto.h>
+# include "exevents.h"
+# include "extinit.h"
+#endif
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/syslimits.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#define HAS_UTSNAME 1
+#include <sys/utsname.h>
+
+#define NO_CFPLUGIN
+#include <IOKit/IOKitLib.h>
+#include <IOKit/hidsystem/IOHIDLib.h>
+#include <IOKit/hidsystem/ev_keymap.h>
+
+#ifdef MITSHM
+#define _XSHM_SERVER_
+#include <X11/extensions/XShm.h>
+#endif
+
+#include "darwin.h"
+#include "darwinClut8.h"
+
+#ifdef ENABLE_DEBUG_LOG
+FILE *debug_log_fp = NULL;
+#endif
+
+/*
+ * X server shared global variables
+ */
+int                     darwinScreensFound = 0;
+int                     darwinScreenIndex = 0;
+io_connect_t            darwinParamConnect = 0;
+int                     darwinEventReadFD = -1;
+int                     darwinEventWriteFD = -1;
+// int                     darwinMouseAccelChange = 1;
+int                     darwinFakeButtons = 0;
+
+// location of X11's (0,0) point in global screen coordinates
+int                     darwinMainScreenX = 0;
+int                     darwinMainScreenY = 0;
+
+// parameters read from the command line or user preferences
+unsigned int            darwinDesiredWidth = 0, darwinDesiredHeight = 0;
+int                     darwinDesiredDepth = -1;
+int                     darwinDesiredRefresh = -1;
+char                    *darwinKeymapFile = "USA.keymapping";
+int                     darwinSyncKeymap = FALSE;
+
+// modifier masks for faking mouse buttons
+int                     darwinFakeMouse2Mask = NX_ALTERNATEMASK;
+int                     darwinFakeMouse3Mask = NX_COMMANDMASK;
+
+// devices
+DeviceIntPtr            darwinPointer = NULL;
+DeviceIntPtr            darwinKeyboard = NULL;
+
+// Common pixmap formats
+static PixmapFormatRec formats[] = {
+        { 1,    1,      BITMAP_SCANLINE_PAD },
+        { 4,    8,      BITMAP_SCANLINE_PAD },
+        { 8,    8,      BITMAP_SCANLINE_PAD },
+        { 15,   16,     BITMAP_SCANLINE_PAD },
+        { 16,   16,     BITMAP_SCANLINE_PAD },
+        { 24,   32,     BITMAP_SCANLINE_PAD },
+        { 32,   32,     BITMAP_SCANLINE_PAD }
+};
+const int NUMFORMATS = sizeof(formats)/sizeof(formats[0]);
+
+#ifndef OSNAME
+#define OSNAME " Darwin"
+#endif
+#ifndef OSVENDOR
+#define OSVENDOR ""
+#endif
+#ifndef PRE_RELEASE
+#define PRE_RELEASE XORG_VERSION_SNAP
+#endif
+#ifndef BUILD_DATE
+#define BUILD_DATE ""
+#endif
+#ifndef XORG_RELEASE
+#define XORG_RELEASE "?"
+#endif
+
+void DDXRingBell(int volume, int pitch, int duration) {
+  // FIXME -- make some noise, yo
+}
+
+void
+DarwinPrintBanner(void)
+{ 
+  // this should change depending on which specific server we are building
+  ErrorF("X11.app starting:\n");
+  ErrorF("Xquartz server based on X.org %s, built on %s\n", XORG_RELEASE, BUILD_DATE );
+}
+
+
+/*
+ * DarwinSaveScreen
+ *  X screensaver support. Not implemented.
+ */
+static Bool DarwinSaveScreen(ScreenPtr pScreen, int on)
+{
+    // FIXME
+    if (on == SCREEN_SAVER_FORCER) {
+    } else if (on == SCREEN_SAVER_ON) {
+    } else {
+    }
+    return TRUE;
+}
+
+
+/*
+ * DarwinAddScreen
+ *  This is a callback from dix during AddScreen() from InitOutput().
+ *  Initialize the screen and communicate information about it back to dix.
+ */
+static Bool DarwinAddScreen(
+    int         index,
+    ScreenPtr   pScreen,
+    int         argc,
+    char        **argv )
+{
+    int         bitsPerRGB, i, dpi;
+    static int  foundIndex = 0;
+    Bool        ret;
+    VisualPtr   visual;
+    ColormapPtr pmap;
+    DarwinFramebufferPtr dfb;
+
+    // reset index of found screens for each server generation
+    if (index == 0) foundIndex = 0;
+
+    // allocate space for private per screen storage
+    dfb = xalloc(sizeof(DarwinFramebufferRec));
+
+    // SCREEN_PRIV(pScreen) = dfb;
+    pScreen->devPrivates[darwinScreenIndex].ptr = dfb;
+
+    // setup hardware/mode specific details
+    ret = DarwinModeAddScreen(foundIndex, pScreen);
+    foundIndex++;
+    if (! ret)
+        return FALSE;
+
+    bitsPerRGB = dfb->bitsPerComponent;
+
+    // reset the visual list
+    miClearVisualTypes();
+
+    // setup a single visual appropriate for our pixel type
+    if (dfb->colorType == TrueColor) {
+        if (!miSetVisualTypes( dfb->colorBitsPerPixel, TrueColorMask,
+                               bitsPerRGB, TrueColor )) {
+            return FALSE;
+        }
+    } else if (dfb->colorType == PseudoColor) {
+        if (!miSetVisualTypes( dfb->colorBitsPerPixel, PseudoColorMask,
+                               bitsPerRGB, PseudoColor )) {
+            return FALSE;
+        }
+    } else if (dfb->colorType == StaticColor) {
+        if (!miSetVisualTypes( dfb->colorBitsPerPixel, StaticColorMask,
+                               bitsPerRGB, StaticColor )) {
+            return FALSE;
+        }
+    } else {
+        return FALSE;
+    }
+
+    miSetPixmapDepths();
+
+    // machine independent screen init
+    // setup _Screen structure in pScreen
+    if (monitorResolution)
+        dpi = monitorResolution;
+    else
+        dpi = 75;
+
+    // initialize fb
+    if (! fbScreenInit(pScreen,
+                dfb->framebuffer,                 // pointer to screen bitmap
+                dfb->width, dfb->height,          // screen size in pixels
+                dpi, dpi,                         // dots per inch
+                dfb->pitch/(dfb->bitsPerPixel/8), // pixel width of framebuffer
+                dfb->bitsPerPixel))               // bits per pixel for screen
+    {
+        return FALSE;
+    }
+
+    // set the RGB order correctly for TrueColor
+    if (dfb->bitsPerPixel > 8) {
+        for (i = 0, visual = pScreen->visuals;  // someday we may have more than 1
+            i < pScreen->numVisuals; i++, visual++) {
+            if (visual->class == TrueColor) {
+                visual->offsetRed = bitsPerRGB * 2;
+                visual->offsetGreen = bitsPerRGB;
+                visual->offsetBlue = 0;
+                visual->redMask = ((1<<bitsPerRGB)-1) << visual->offsetRed;
+                visual->greenMask = ((1<<bitsPerRGB)-1) << visual->offsetGreen;
+                visual->blueMask = ((1<<bitsPerRGB)-1) << visual->offsetBlue;
+            }
+        }
+    }
+
+#ifdef RENDER
+    if (! fbPictureInit(pScreen, 0, 0)) {
+        return FALSE;
+    }
+#endif
+
+#ifdef MITSHM
+    ShmRegisterFbFuncs(pScreen);
+#endif
+
+    // this must be initialized (why doesn't X have a default?)
+    pScreen->SaveScreen = DarwinSaveScreen;
+
+    // finish mode dependent screen setup including cursor support
+    if (!DarwinModeSetupScreen(index, pScreen)) {
+        return FALSE;
+    }
+
+    // create and install the default colormap and
+    // set pScreen->blackPixel / pScreen->white
+    if (!miCreateDefColormap( pScreen )) {
+        return FALSE;
+    }
+
+    /* Set the colormap to the statically defined one if we're in 8 bit
+     * mode and we're using a fixed color map.  Essentially this translates
+     * to Darwin/x86 in 8-bit mode.
+     */
+    if( (dfb->colorBitsPerPixel == 8) &&
+                (dfb->colorType == StaticColor) )
+    {
+        pmap = miInstalledMaps[pScreen->myNum];
+        visual = pmap->pVisual;
+        for( i = 0; i < visual->ColormapEntries; i++ ) {
+            pmap->red[i].co.local.red   = darwinClut8[i].red;
+            pmap->red[i].co.local.green = darwinClut8[i].green;
+            pmap->red[i].co.local.blue  = darwinClut8[i].blue;
+        }
+    }
+
+    dixScreenOrigins[index].x = dfb->x;
+    dixScreenOrigins[index].y = dfb->y;
+
+    /*    ErrorF("Screen %d added: %dx%d @ (%d,%d)\n",
+	  index, dfb->width, dfb->height, dfb->x, dfb->y); */
+
+    return TRUE;
+}
+
+/*
+ =============================================================================
+
+ mouse and keyboard callbacks
+
+ =============================================================================
+*/
+
+#if 0
+/*
+ * DarwinChangePointerControl
+ *  Set mouse acceleration and thresholding
+ *  FIXME: We currently ignore the threshold in ctrl->threshold.
+ */
+static void DarwinChangePointerControl(
+    DeviceIntPtr    device,
+    PtrCtrl         *ctrl )
+{
+    kern_return_t   kr;
+    double          acceleration;
+
+    if (!darwinMouseAccelChange)
+        return;
+
+    acceleration = ctrl->num / ctrl->den;
+    kr = IOHIDSetMouseAcceleration( darwinParamConnect, acceleration );
+    if (kr != KERN_SUCCESS)
+        ErrorF( "Could not set mouse acceleration with kernel return = 0x%x.\n", kr );
+}
+#endif
+
+/*
+ * DarwinMouseProc
+ *  Handle the initialization, etc. of a mouse
+ */
+static int DarwinMouseProc(
+    DeviceIntPtr    pPointer,
+    int             what )
+{
+    CARD8 map[6];
+
+    switch (what) {
+
+        case DEVICE_INIT:
+            pPointer->public.on = FALSE;
+
+            // Set button map.
+            map[1] = 1;
+            map[2] = 2;
+            map[3] = 3;
+            map[4] = 4;
+            map[5] = 5;
+            InitPointerDeviceStruct( (DevicePtr)pPointer, map, 5,
+				     GetMotionHistory,
+				     (PtrCtrlProcPtr)NoopDDA,
+				     GetMotionHistorySize(), 2);
+
+#ifdef XINPUT
+            InitValuatorAxisStruct( pPointer,
+                                    0,     // X axis
+                                    0,     // min value
+                                    16000, // max value (fixme screen size?)
+                                    1,     // resolution (fixme ?)
+                                    1,     // min resolution
+                                    1 );   // max resolution
+            InitValuatorAxisStruct( pPointer,
+                                    1,     // X axis
+                                    0,     // min value
+                                    16000, // max value (fixme screen size?)
+                                    1,     // resolution (fixme ?)
+                                    1,     // min resolution
+                                    1 );   // max resolution
+#endif
+            break;
+
+        case DEVICE_ON:
+            pPointer->public.on = TRUE;
+            AddEnabledDevice( darwinEventReadFD );
+            return Success;
+
+        case DEVICE_CLOSE:
+        case DEVICE_OFF:
+            pPointer->public.on = FALSE;
+            RemoveEnabledDevice( darwinEventReadFD );
+            return Success;
+    }
+
+    return Success;
+}
+
+
+/*
+ * DarwinKeybdProc
+ *  Callback from X
+ */
+static int DarwinKeybdProc( DeviceIntPtr pDev, int onoff )
+{
+    switch ( onoff ) {
+        case DEVICE_INIT:
+            DarwinKeyboardInit( pDev );
+            break;
+        case DEVICE_ON:
+            pDev->public.on = TRUE;
+            AddEnabledDevice( darwinEventReadFD );
+            break;
+        case DEVICE_OFF:
+            pDev->public.on = FALSE;
+            RemoveEnabledDevice( darwinEventReadFD );
+            break;
+        case DEVICE_CLOSE:
+            break;
+    }
+
+    return Success;
+}
+
+/*
+===========================================================================
+
+ Utility routines
+
+===========================================================================
+*/
+
+/*
+ * DarwinFindLibraryFile
+ *  Search for a file in the standard Library paths, which are (in order):
+ *
+ *      ~/Library/              user specific
+ *      /Library/               host specific
+ *      /Network/Library/       LAN specific
+ *      /System/Library/        OS specific
+ *
+ *  A sub-path can be specified to search in below the various Library
+ *  directories. Returns a new character string (owned by the caller)
+ *  containing the full path to the first file found.
+ */
+static char * DarwinFindLibraryFile(
+    const char *file,
+    const char *pathext )
+{
+    // Library search paths
+    char *pathList[] = {
+        "",
+        "/Network",
+        "/System",
+        NULL
+    };
+    char *home;
+    char *fullPath;
+    int i = 0;
+
+    // Return the file name as is if it is already a fully qualified path.
+    if (!access(file, F_OK)) {
+        fullPath = xalloc(strlen(file)+1);
+        strcpy(fullPath, file);
+        return fullPath;
+    }
+
+    fullPath = xalloc(PATH_MAX);
+
+    home = getenv("HOME");
+    if (home) {
+        snprintf(fullPath, PATH_MAX, "%s/Library/%s/%s", home, pathext, file);
+        if (!access(fullPath, F_OK))
+            return fullPath;
+    }
+
+    while (pathList[i]) {
+        snprintf(fullPath, PATH_MAX, "%s/Library/%s/%s", pathList[i++],
+                 pathext, file);
+        if (!access(fullPath, F_OK))
+            return fullPath;
+    }
+
+    xfree(fullPath);
+    return NULL;
+}
+
+
+/*
+ * DarwinParseModifierList
+ *  Parse a list of modifier names and return a corresponding modifier mask
+ */
+int DarwinParseModifierList(
+    const char *constmodifiers) // string containing list of modifier names
+{
+    int result = 0;
+
+    if (constmodifiers) {
+        char *modifiers = strdup(constmodifiers);
+        char *modifier;
+        int nxkey;
+        char *p = modifiers;
+
+        while (p) {
+            modifier = strsep(&p, " ,+&|/"); // allow lots of separators
+            nxkey = DarwinModifierStringToNXKey(modifier);
+            if (nxkey != -1)
+                result |= DarwinModifierNXKeyToNXMask(nxkey);
+            else
+                ErrorF("fakebuttons: Unknown modifier \"%s\"\n", modifier);
+        }
+        free(modifiers);
+    }
+    return result;
+}
+
+/*
+===========================================================================
+
+ Functions needed to link against device independent X
+
+===========================================================================
+*/
+
+/*
+ * InitInput
+ *  Register the keyboard and mouse devices
+ */
+void InitInput( int argc, char **argv )
+{
+    darwinPointer = AddInputDevice(DarwinMouseProc, TRUE);
+    RegisterPointerDevice( darwinPointer );
+
+    darwinKeyboard = AddInputDevice(DarwinKeybdProc, TRUE);
+    RegisterKeyboardDevice( darwinKeyboard );
+
+    DarwinEQInit( (DevicePtr)darwinKeyboard, (DevicePtr)darwinPointer );
+
+    DarwinModeInitInput(argc, argv);
+}
+
+
+/*
+ * DarwinAdjustScreenOrigins
+ *  Shift all screens so the X11 (0, 0) coordinate is at the top
+ *  left of the global screen coordinates.
+ *
+ *  Screens can be arranged so the top left isn't on any screen, so
+ *  instead use the top left of the leftmost screen as (0,0). This
+ *  may mean some screen space is in -y, but it's better that (0,0)
+ *  be onscreen, or else default xterms disappear. It's better that
+ *  -y be used than -x, because when popup menus are forced
+ *  "onscreen" by dumb window managers like twm, they'll shift the
+ *  menus down instead of left, which still looks funny but is an
+ *  easier target to hit.
+ */
+void
+DarwinAdjustScreenOrigins(ScreenInfo *pScreenInfo)
+{
+    int i, left, top;
+
+    left = dixScreenOrigins[0].x;
+    top  = dixScreenOrigins[0].y;
+
+    /* Find leftmost screen. If there's a tie, take the topmost of the two. */
+    for (i = 1; i < pScreenInfo->numScreens; i++) {
+        if (dixScreenOrigins[i].x < left  ||
+            (dixScreenOrigins[i].x == left &&
+             dixScreenOrigins[i].y < top))
+        {
+            left = dixScreenOrigins[i].x;
+            top = dixScreenOrigins[i].y;
+        }
+    }
+
+    darwinMainScreenX = left;
+    darwinMainScreenY = top;
+
+    /* Shift all screens so that there is a screen whose top left
+       is at X11 (0,0) and at global screen coordinate
+       (darwinMainScreenX, darwinMainScreenY). */
+
+    if (darwinMainScreenX != 0 || darwinMainScreenY != 0) {
+        for (i = 0; i < pScreenInfo->numScreens; i++) {
+            dixScreenOrigins[i].x -= darwinMainScreenX;
+            dixScreenOrigins[i].y -= darwinMainScreenY;
+    /*            ErrorF("Screen %d placed at X11 coordinate (%d,%d).\n",
+		  i, dixScreenOrigins[i].x, dixScreenOrigins[i].y); */
+        }
+    }
+}
+
+
+/*
+ * InitOutput
+ *  Initialize screenInfo for all actually accessible framebuffers.
+ *
+ *  The display mode dependent code gets called three times. The mode
+ *  specific InitOutput routines are expected to discover the number
+ *  of potentially useful screens and cache routes to them internally.
+ *  Inside DarwinAddScreen are two other mode specific calls.
+ *  A mode specific AddScreen routine is called for each screen to
+ *  actually initialize the screen with the ScreenPtr structure.
+ *  After other screen setup has been done, a mode specific
+ *  SetupScreen function can be called to finalize screen setup.
+ */
+void InitOutput( ScreenInfo *pScreenInfo, int argc, char **argv )
+{
+    int i;
+    static unsigned long generation = 0;
+
+    pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
+    pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
+    pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
+    pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
+
+    // List how we want common pixmap formats to be padded
+    pScreenInfo->numPixmapFormats = NUMFORMATS;
+    for (i = 0; i < NUMFORMATS; i++)
+        pScreenInfo->formats[i] = formats[i];
+
+    // Allocate private storage for each screen's Darwin specific info
+    if (generation != serverGeneration) {
+        darwinScreenIndex = AllocateScreenPrivateIndex();
+        generation = serverGeneration;
+    }
+
+    // Discover screens and do mode specific initialization
+    DarwinModeInitOutput(argc, argv);
+
+    // Add screens
+    for (i = 0; i < darwinScreensFound; i++) {
+        AddScreen( DarwinAddScreen, argc, argv );
+    }
+
+    DarwinAdjustScreenOrigins(pScreenInfo);
+}
+
+
+/*
+ * OsVendorFataError
+ */
+void OsVendorFatalError( void )
+{
+    ErrorF( "   OsVendorFatalError\n" );
+}
+
+
+/*
+ * OsVendorInit
+ *  Initialization of Darwin OS support.
+ */
+void OsVendorInit(void)
+{
+    if (serverGeneration == 1) {
+        DarwinPrintBanner();
+#ifdef ENABLE_DEBUG_LOG
+	{
+	  char *home_dir=NULL, *log_file_path=NULL;
+	  home_dir = getenv("HOME");
+	  if (home_dir) asprintf(&log_file_path, "%s/%s", home_dir, DEBUG_LOG_NAME);
+	  if (log_file_path) {
+	    if (!access(log_file_path, F_OK)) {
+	      debug_log_fp = fopen(log_file_path, "a");
+	      if (debug_log_fp) ErrorF("Debug logging enabled to %s\n", log_file_path);
+	    }
+	    free(log_file_path);
+	  }
+	}
+#endif
+    }
+    //    DEBUG_LOG("Xquartz started at %s\n", ctime(time(NULL)));
+
+    // Find the full path to the keymapping file.
+    if ( darwinKeymapFile ) {
+        char *tempStr = DarwinFindLibraryFile(darwinKeymapFile, "Keyboards");
+        if ( !tempStr ) {
+            ErrorF("Could not find keymapping file %s.\n", darwinKeymapFile);
+        } else {
+            ErrorF("Using keymapping provided in %s.\n", tempStr);
+        }
+        darwinKeymapFile = tempStr;
+    }
+}
+
+
+/*
+ * ddxInitGlobals
+ *  Called by InitGlobals() from os/util.c.
+ */
+void ddxInitGlobals(void)
+{
+}
+
+
+/*
+ * ddxProcessArgument
+ *  Process device-dependent command line args. Returns 0 if argument is
+ *  not device dependent, otherwise Count of number of elements of argv
+ *  that are part of a device dependent commandline option.
+ */
+int ddxProcessArgument( int argc, char *argv[], int i )
+{
+    if ( !strcmp( argv[i], "-fullscreen" ) ) {
+        ErrorF( "Running full screen in parallel with Mac OS X Quartz window server.\n" );
+        return 1;
+    }
+
+    if ( !strcmp( argv[i], "-rootless" ) ) {
+        ErrorF( "Running rootless inside Mac OS X window server.\n" );
+        return 1;
+    }
+
+    if ( !strcmp( argv[i], "-quartz" ) ) {
+        ErrorF( "Running in parallel with Mac OS X Quartz window server.\n" );
+        return 1;
+    }
+
+    // The Mac OS X front end uses this argument, which we just ignore here.
+    if ( !strcmp( argv[i], "-nostartx" ) ) {
+        return 1;
+    }
+
+    // This command line arg is passed when launched from the Aqua GUI.
+    if ( !strncmp( argv[i], "-psn_", 5 ) ) {
+        return 1;
+    }
+
+    if ( !strcmp( argv[i], "-fakebuttons" ) ) {
+        darwinFakeButtons = TRUE;
+        ErrorF( "Faking a three button mouse\n" );
+        return 1;
+    }
+
+    if ( !strcmp( argv[i], "-nofakebuttons" ) ) {
+        darwinFakeButtons = FALSE;
+        ErrorF( "Not faking a three button mouse\n" );
+        return 1;
+    }
+
+    if (!strcmp( argv[i], "-fakemouse2" ) ) {
+        if ( i == argc-1 ) {
+            FatalError( "-fakemouse2 must be followed by a modifer list\n" );
+        }
+        if (!strcasecmp(argv[i+1], "none") || !strcmp(argv[i+1], ""))
+            darwinFakeMouse2Mask = 0;
+        else
+            darwinFakeMouse2Mask = DarwinParseModifierList(argv[i+1]);
+        ErrorF("Modifier mask to fake mouse button 2 = 0x%x\n",
+               darwinFakeMouse2Mask);
+        return 2;
+    }
+
+    if (!strcmp( argv[i], "-fakemouse3" ) ) {
+        if ( i == argc-1 ) {
+            FatalError( "-fakemouse3 must be followed by a modifer list\n" );
+        }
+        if (!strcasecmp(argv[i+1], "none") || !strcmp(argv[i+1], ""))
+            darwinFakeMouse3Mask = 0;
+        else
+            darwinFakeMouse3Mask = DarwinParseModifierList(argv[i+1]);
+        ErrorF("Modifier mask to fake mouse button 3 = 0x%x\n",
+               darwinFakeMouse3Mask);
+        return 2;
+    }
+
+    if ( !strcmp( argv[i], "-keymap" ) ) {
+        if ( i == argc-1 ) {
+            FatalError( "-keymap must be followed by a filename\n" );
+        }
+        darwinKeymapFile = argv[i+1];
+        return 2;
+    }
+
+    if ( !strcmp( argv[i], "-nokeymap" ) ) {
+        darwinKeymapFile = NULL;
+        return 1;
+    }
+
+    if ( !strcmp( argv[i], "+synckeymap" ) ) {
+        darwinSyncKeymap = TRUE;
+        return 1;
+    }
+
+    if ( !strcmp( argv[i], "-synckeymap" ) ) {
+        darwinSyncKeymap = FALSE;
+        return 1;
+    }
+
+    if ( !strcmp( argv[i], "-size" ) ) {
+        if ( i >= argc-2 ) {
+            FatalError( "-size must be followed by two numbers\n" );
+        }
+#ifdef OLD_POWERBOOK_G3
+        ErrorF( "Ignoring unsupported -size option on old PowerBook G3\n" );
+#else
+        darwinDesiredWidth = atoi( argv[i+1] );
+        darwinDesiredHeight = atoi( argv[i+2] );
+        ErrorF( "Attempting to use width x height = %i x %i\n",
+                darwinDesiredWidth, darwinDesiredHeight );
+#endif
+        return 3;
+    }
+
+    if ( !strcmp( argv[i], "-depth" ) ) {
+        int     bitDepth;
+
+        if ( i == argc-1 ) {
+            FatalError( "-depth must be followed by a number\n" );
+        }
+#ifdef OLD_POWERBOOK_G3
+        ErrorF( "Ignoring unsupported -depth option on old PowerBook G3\n");
+#else
+        bitDepth = atoi( argv[i+1] );
+        if (bitDepth == 8)
+            darwinDesiredDepth = 0;
+        else if (bitDepth == 15)
+            darwinDesiredDepth = 1;
+        else if (bitDepth == 24)
+            darwinDesiredDepth = 2;
+        else
+            FatalError( "Unsupported pixel depth. Use 8, 15, or 24 bits\n" );
+        ErrorF( "Attempting to use pixel depth of %i\n", bitDepth );
+#endif
+        return 2;
+    }
+
+    if ( !strcmp( argv[i], "-refresh" ) ) {
+        if ( i == argc-1 ) {
+            FatalError( "-refresh must be followed by a number\n" );
+        }
+#ifdef OLD_POWERBOOK_G3
+        ErrorF( "Ignoring unsupported -refresh option on old PowerBook G3\n");
+#else
+        darwinDesiredRefresh = atoi( argv[i+1] );
+        ErrorF( "Attempting to use refresh rate of %i\n", darwinDesiredRefresh );
+#endif
+        return 2;
+    }
+
+    if (!strcmp( argv[i], "-showconfig" ) || !strcmp( argv[i], "-version" )) {
+        DarwinPrintBanner();
+        exit(0);
+    }
+
+    // XDarwinStartup uses this argument to indicate the IOKit X server
+    // should be started. Ignore it here.
+    if ( !strcmp( argv[i], "-iokit" ) ) {
+        return 1;
+    }
+
+    return 0;
+}
+
+
+/*
+ * ddxUseMsg --
+ *  Print out correct use of device dependent commandline options.
+ *  Maybe the user now knows what really to do ...
+ */
+void ddxUseMsg( void )
+{
+    ErrorF("\n");
+    ErrorF("\n");
+    ErrorF("Device Dependent Usage:\n");
+    ErrorF("\n");
+    ErrorF("-fakebuttons : fake a three button mouse with Command and Option keys.\n");
+    ErrorF("-nofakebuttons : don't fake a three button mouse.\n");
+    ErrorF("-fakemouse2 <modifiers> : fake middle mouse button with modifier keys.\n");
+    ErrorF("-fakemouse3 <modifiers> : fake right mouse button with modifier keys.\n");
+    ErrorF("  ex: -fakemouse2 \"option,shift\" = option-shift-click is middle button.\n");
+    ErrorF("-keymap <file> : read the keymapping from a file instead of the kernel.\n");
+    ErrorF("-version : show the server version.\n");
+    ErrorF("\n");
+    ErrorF("Quartz modes (Experimental / In Development):\n");
+    ErrorF("-fullscreen : run full screen in parallel with Mac OS X window server.\n");
+    ErrorF("-rootless : run rootless inside Mac OS X window server.\n");
+    ErrorF("\n");
+    ErrorF("Options ignored in rootless mode:\n");
+    ErrorF("-size <height> <width> : use a screen resolution of <height> x <width>.\n");
+    ErrorF("-depth <8,15,24> : use this bit depth.\n");
+    ErrorF("-refresh <rate> : use a monitor refresh rate of <rate> Hz.\n");
+    ErrorF("\n");
+}
+
+
+/*
+ * ddxGiveUp --
+ *      Device dependent cleanup. Called by dix before normal server death.
+ */
+void ddxGiveUp( void )
+{
+    ErrorF( "Quitting XQuartz...\n" );
+
+    DarwinModeGiveUp();
+}
+
+
+/*
+ * AbortDDX --
+ *      DDX - specific abort routine.  Called by AbortServer(). The attempt is
+ *      made to restore all original setting of the displays. Also all devices
+ *      are closed.
+ */
+void AbortDDX( void )
+{
+    ErrorF( "   AbortDDX\n" );
+    /*
+     * This is needed for a abnormal server exit, since the normal exit stuff
+     * MUST also be performed (i.e. the vt must be left in a defined state)
+     */
+    ddxGiveUp();
+}
+
+
+/*
+ * DPMS extension stubs
+ */
+Bool DPMSSupported(void)
+{
+    return FALSE;
+}
+
+void DPMSSet(int level)
+{
+}
+
+int DPMSGet(int *level)
+{
+    return -1;
+}
+
+#include "mivalidate.h" // for union _Validate used by windowstr.h
+#include "windowstr.h"  // for struct _Window
+#include "scrnintstr.h" // for struct _Screen
+
+// This is copied from Xserver/hw/xfree86/common/xf86Helper.c.
+// Quartz mode uses this when switching in and out of Quartz.
+// Quartz or IOKit can use this when waking from sleep.
+// Copyright (c) 1997-1998 by The XFree86 Project, Inc.
+
+/*
+ * xf86SetRootClip --
+ *	Enable or disable rendering to the screen by
+ *	setting the root clip list and revalidating
+ *	all of the windows
+ */
+
+void
+xf86SetRootClip (ScreenPtr pScreen, BOOL enable)
+{
+    WindowPtr	pWin = WindowTable[pScreen->myNum];
+    WindowPtr	pChild;
+    Bool	WasViewable = (Bool)(pWin->viewable);
+    Bool	anyMarked = TRUE;
+    RegionPtr	pOldClip = NULL, bsExposed;
+#ifdef DO_SAVE_UNDERS
+    Bool	dosave = FALSE;
+#endif
+    WindowPtr   pLayerWin;
+    BoxRec	box;
+
+    if (WasViewable)
+    {
+	for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib)
+	{
+	    (void) (*pScreen->MarkOverlappedWindows)(pChild,
+						     pChild,
+						     &pLayerWin);
+	}
+	(*pScreen->MarkWindow) (pWin);
+	anyMarked = TRUE;
+	if (pWin->valdata)
+	{
+	    if (HasBorder (pWin))
+	    {
+		RegionPtr	borderVisible;
+
+		borderVisible = REGION_CREATE(pScreen, NullBox, 1);
+		REGION_SUBTRACT(pScreen, borderVisible,
+				&pWin->borderClip, &pWin->winSize);
+		pWin->valdata->before.borderVisible = borderVisible;
+	    }
+	    pWin->valdata->before.resized = TRUE;
+	}
+    }
+
+    /*
+     * Use REGION_BREAK to avoid optimizations in ValidateTree
+     * that assume the root borderClip can't change well, normally
+     * it doesn't...)
+     */
+    if (enable)
+    {
+	box.x1 = 0;
+	box.y1 = 0;
+	box.x2 = pScreen->width;
+	box.y2 = pScreen->height;
+	REGION_RESET(pScreen, &pWin->borderClip, &box);
+	REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
+    }
+    else
+    {
+	REGION_EMPTY(pScreen, &pWin->borderClip);
+	REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
+    }
+
+    ResizeChildrenWinSize (pWin, 0, 0, 0, 0);
+
+    if (WasViewable)
+    {
+	if (pWin->backStorage)
+	{
+	    pOldClip = REGION_CREATE(pScreen, NullBox, 1);
+	    REGION_COPY(pScreen, pOldClip, &pWin->clipList);
+	}
+
+	if (pWin->firstChild)
+	{
+	    anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin->firstChild,
+							   pWin->firstChild,
+							   (WindowPtr *)NULL);
+	}
+	else
+	{
+	    (*pScreen->MarkWindow) (pWin);
+	    anyMarked = TRUE;
+	}
+
+#ifdef DO_SAVE_UNDERS
+	if (DO_SAVE_UNDERS(pWin))
+	{
+	    dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pLayerWin);
+	}
+#endif /* DO_SAVE_UNDERS */
+
+	if (anyMarked)
+	    (*pScreen->ValidateTree)(pWin, NullWindow, VTOther);
+    }
+
+    if (pWin->backStorage &&
+	((pWin->backingStore == Always) || WasViewable))
+    {
+	if (!WasViewable)
+	    pOldClip = &pWin->clipList; /* a convenient empty region */
+	bsExposed = (*pScreen->TranslateBackingStore)
+			     (pWin, 0, 0, pOldClip,
+			      pWin->drawable.x, pWin->drawable.y);
+	if (WasViewable)
+	    REGION_DESTROY(pScreen, pOldClip);
+	if (bsExposed)
+	{
+	    RegionPtr	valExposed = NullRegion;
+
+	    if (pWin->valdata)
+		valExposed = &pWin->valdata->after.exposed;
+	    (*pScreen->WindowExposures) (pWin, valExposed, bsExposed);
+	    if (valExposed)
+		REGION_EMPTY(pScreen, valExposed);
+	    REGION_DESTROY(pScreen, bsExposed);
+	}
+    }
+    if (WasViewable)
+    {
+	if (anyMarked)
+	    (*pScreen->HandleExposures)(pWin);
+#ifdef DO_SAVE_UNDERS
+	if (dosave)
+	    (*pScreen->PostChangeSaveUnder)(pLayerWin, pLayerWin);
+#endif /* DO_SAVE_UNDERS */
+	if (anyMarked && pScreen->PostValidateTree)
+	    (*pScreen->PostValidateTree)(pWin, NullWindow, VTOther);
+    }
+    if (pWin->realized)
+	WindowsRestructured ();
+    FlushAllOutput ();
+}
diff --git a/hw/xquartz/darwin.h b/hw/xquartz/darwin.h
new file mode 100644
index 0000000..0f5f492
--- /dev/null
+++ b/hw/xquartz/darwin.h
@@ -0,0 +1,158 @@
+/*
+ * Copyright (c) 2001-2004 Torrey T. Lyons. 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
+ * 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 _DARWIN_H
+#define _DARWIN_H
+
+#include <IOKit/IOTypes.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include <X11/extensions/XKB.h>
+#include <assert.h>
+
+typedef struct {
+    void                *framebuffer;
+    int                 x;
+    int                 y;
+    int                 width;
+    int                 height;
+    int                 pitch;
+    int                 colorType;
+    int                 bitsPerPixel;
+    int                 colorBitsPerPixel;
+    int                 bitsPerComponent;
+} DarwinFramebufferRec, *DarwinFramebufferPtr;
+
+// From darwin.c
+void DarwinPrintBanner(void);
+int DarwinParseModifierList(const char *constmodifiers);
+void DarwinAdjustScreenOrigins(ScreenInfo *pScreenInfo);
+void xf86SetRootClip (ScreenPtr pScreen, BOOL enable);
+
+// From darwinEvents.c
+Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr);
+void DarwinEQEnqueue(const xEvent *e);
+void DarwinEQPointerPost(xEvent *e);
+void DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX);
+void DarwinPokeEQ(void);
+void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int pointer_y);
+void DarwinSendKeyboardEvents(int ev_type, int keycode);
+void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y);
+
+// Mode specific functions
+Bool DarwinModeAddScreen(int index, ScreenPtr pScreen);
+Bool DarwinModeSetupScreen(int index, ScreenPtr pScreen);
+void DarwinModeInitOutput(int argc,char **argv);
+void DarwinModeInitInput(int argc, char **argv);
+void DarwinModeProcessEvent(xEvent *xe);
+void DarwinModeGiveUp(void);
+void DarwinModeBell(int volume, DeviceIntPtr pDevice, pointer ctrl, int class);
+
+
+#undef assert
+#define assert(x) { if ((x) == 0) \
+    FatalError("assert failed on line %d of %s!\n", __LINE__, __FILE__); }
+#define kern_assert(x) { if ((x) != KERN_SUCCESS) \
+    FatalError("assert failed on line %d of %s with kernel return 0x%x!\n", \
+                __LINE__, __FILE__, x); }
+#define SCREEN_PRIV(pScreen) \
+    ((DarwinFramebufferPtr)pScreen->devPrivates[darwinScreenIndex].ptr)
+
+
+#define MIN_KEYCODE XkbMinLegalKeyCode     // unfortunately, this isn't 0...
+
+
+/*
+ * Global variables from darwin.c
+ */
+extern int              darwinScreenIndex; // index into pScreen.devPrivates
+extern int              darwinScreensFound;
+extern io_connect_t     darwinParamConnect;
+extern int              darwinEventReadFD;
+extern int              darwinEventWriteFD;
+extern DeviceIntPtr     darwinPointer;
+extern DeviceIntPtr     darwinKeyboard;
+
+// User preferences
+extern int              darwinMouseAccelChange;
+extern int              darwinFakeButtons;
+extern int              darwinFakeMouse2Mask;
+extern int              darwinFakeMouse3Mask;
+extern char            *darwinKeymapFile;
+extern int              darwinSyncKeymap;
+extern unsigned int     darwinDesiredWidth, darwinDesiredHeight;
+extern int              darwinDesiredDepth;
+extern int              darwinDesiredRefresh;
+
+// location of X11's (0,0) point in global screen coordinates
+extern int              darwinMainScreenX;
+extern int              darwinMainScreenY;
+
+
+/*
+ * Special ddx events understood by the X server
+ */
+enum {
+    kXDarwinUpdateModifiers   // update all modifier keys
+            = LASTEvent+1,    // (from X.h list of event names)
+    kXDarwinUpdateButtons,    // update state of mouse buttons 2 and up
+    kXDarwinScrollWheel,      // scroll wheel event
+    /*
+     * Quartz-specific events -- not used in IOKit mode
+     */
+    kXDarwinActivate,         // restore X drawing and cursor
+    kXDarwinDeactivate,       // clip X drawing and switch to Aqua cursor
+    kXDarwinSetRootClip,      // enable or disable drawing to the X screen
+    kXDarwinQuit,             // kill the X server and release the display
+    kXDarwinReadPasteboard,   // copy Mac OS X pasteboard into X cut buffer
+    kXDarwinWritePasteboard,  // copy X cut buffer onto Mac OS X pasteboard
+    kXDarwinBringAllToFront,  // bring all X windows to front
+    kXDarwinToggleFullscreen, // Enable/Disable fullscreen mode
+    kXDarwinSetRootless,      // Set rootless mode
+    /*
+     * AppleWM events
+     */
+    kXDarwinControllerNotify, // send an AppleWMControllerNotify event
+    kXDarwinPasteboardNotify, // notify the WM to copy or paste
+    /*
+     * Xplugin notification events
+     */
+    kXDarwinDisplayChanged,   // display configuration has changed
+    kXDarwinWindowState,      // window visibility state has changed
+    kXDarwinWindowMoved       // window has moved on screen
+};
+
+#define ENABLE_DEBUG_LOG 1
+
+#ifdef ENABLE_DEBUG_LOG
+extern FILE *debug_log_fp;
+#define DEBUG_LOG_NAME "x11-debug.txt"
+#define DEBUG_LOG(msg, args...) if (debug_log_fp) fprintf(debug_log_fp, "%s:%d: " msg, __FUNCTION__, __LINE__, ##args )
+#else
+#define DEBUG_LOG(msg, args...) 
+#endif
+
+#endif  /* _DARWIN_H */
diff --git a/hw/xquartz/darwinClut8.h b/hw/xquartz/darwinClut8.h
new file mode 100644
index 0000000..8e914f3
--- /dev/null
+++ b/hw/xquartz/darwinClut8.h
@@ -0,0 +1,531 @@
+/*
+ * Darwin default 8-bit Colormap for StaticColor
+ */
+
+#ifndef _DARWIN_CLUT8_
+#define _DARWIN_CLUT8_
+
+#ifdef USE_NEW_CLUT
+
+static xColorItem darwinClut8[] = {    
+    { 0, 0xffff, 0xffff, 0xffff,  0, 0 },
+    { 1, 0xfefe, 0xfefe, 0xfefe,  0, 0 },
+    { 2, 0xfdfd, 0xfdfd, 0xfdfd,  0, 0 },
+    { 3, 0xb8b8, 0x2727, 0x2b2b,  0, 0 },
+    { 4, 0xfcfc, 0xfcfc, 0xfcfc,  0, 0 },
+    { 5, 0xffff, 0xffff, 0x0,  0, 0 },
+    { 6, 0xfafa, 0xfafa, 0xfafa,  0, 0 },
+    { 7, 0xf9f9, 0xf9f9, 0xf9f9,  0, 0 },
+    { 8, 0xf8f8, 0xf8f8, 0xf8f8,  0, 0 },
+    { 9, 0xf7f7, 0xf7f7, 0xf7f7,  0, 0 },
+    { 10, 0xf6f6, 0xf6f6, 0xf6f6,  0, 0 },
+    { 11, 0xf5f5, 0xf5f5, 0xf5f5,  0, 0 },
+    { 12, 0xf4f4, 0xf4f4, 0xf4f4,  0, 0 },
+    { 13, 0xf2f2, 0xf2f2, 0xf2f2,  0, 0 },
+    { 14, 0xf1f1, 0xf1f1, 0xf1f1,  0, 0 },
+    { 15, 0x0, 0x0, 0x0,  0, 0 },
+    { 16, 0xefef, 0xefef, 0xefef,  0, 0 },
+    { 17, 0xeeee, 0xeeee, 0xeeee,  0, 0 },
+    { 18, 0xeded, 0xeded, 0xeded,  0, 0 },
+    { 19, 0xebeb, 0xebeb, 0xebeb,  0, 0 },
+    { 20, 0xe8e8, 0xe8e8, 0xe8e8,  0, 0 },
+    { 21, 0xe7e7, 0xe7e7, 0xe7e7,  0, 0 },
+    { 22, 0xc9c9, 0x3838, 0x3e3e,  0, 0 },
+    { 23, 0xe5e5, 0xe5e5, 0xe5e5,  0, 0 },
+    { 24, 0xffff, 0x0, 0xffff,  0, 0 },
+    { 25, 0xfbfb, 0xfbfb, 0xfbfb,  0, 0 },
+    { 26, 0xdede, 0x6c6c, 0x7272,  0, 0 },
+    { 27, 0xe0e0, 0xe0e0, 0xe0e0,  0, 0 },
+    { 28, 0xe8e8, 0x8686, 0x9090,  0, 0 },
+    { 29, 0xdede, 0xdede, 0xdede,  0, 0 },
+    { 30, 0xdddd, 0xdddd, 0xdddd,  0, 0 },
+    { 31, 0xd3d3, 0x7e7e, 0x8d8d,  0, 0 },
+    { 32, 0xd9d9, 0xd9d9, 0xd9d9,  0, 0 },
+    { 33, 0xf3f3, 0x9696, 0xa6a6,  0, 0 },
+    { 34, 0xb1b1, 0x1c1c, 0x3939,  0, 0 },
+    { 35, 0xffff, 0x0, 0x0,  0, 0 },
+    { 36, 0xbebe, 0x5e5e, 0x7272,  0, 0 },
+    { 37, 0xd3d3, 0xd3d3, 0xd3d3,  0, 0 },
+    { 38, 0xc6c6, 0x2e2e, 0x6767,  0, 0 },
+    { 39, 0xd1d1, 0xd1d1, 0xd1d1,  0, 0 },
+    { 40, 0xa3a3, 0x606, 0x4545,  0, 0 },
+    { 41, 0xcece, 0xcece, 0xcece,  0, 0 },
+    { 42, 0xcccc, 0xcccc, 0xffff,  0, 0 },
+    { 43, 0xcccc, 0xcccc, 0xcccc,  0, 0 },
+    { 44, 0xc6c6, 0x8f8f, 0xa7a7,  0, 0 },
+    { 45, 0xe1e1, 0xd3d3, 0xd9d9,  0, 0 },
+    { 46, 0xcece, 0x9e9e, 0xb4b4,  0, 0 },
+    { 47, 0xcaca, 0xcaca, 0xcaca,  0, 0 },
+    { 48, 0xbfbf, 0x3f3f, 0x7d7d,  0, 0 },
+    { 49, 0xc9c9, 0xc9c9, 0xc9c9,  0, 0 },
+    { 50, 0xf4f4, 0x8989, 0xbebe,  0, 0 },
+    { 51, 0xc6c6, 0xc6c6, 0xc6c6,  0, 0 },
+    { 52, 0xd6d6, 0x5151, 0x9797,  0, 0 },
+    { 53, 0xc9c9, 0x2c2c, 0x8484,  0, 0 },
+    { 54, 0x9696, 0x1a1a, 0x6a6a,  0, 0 },
+    { 55, 0xc2c2, 0xc2c2, 0xc2c2,  0, 0 },
+    { 56, 0xf3f3, 0x6f6f, 0xc6c6,  0, 0 },
+    { 57, 0xe5e5, 0x4c4c, 0xbbbb,  0, 0 },
+    { 58, 0xb7b7, 0x5a5a, 0x9c9c,  0, 0 },
+    { 59, 0xbfbf, 0xbfbf, 0xbfbf,  0, 0 },
+    { 60, 0xbebe, 0xbebe, 0xbebe,  0, 0 },
+    { 61, 0xbdbd, 0xbdbd, 0xbdbd,  0, 0 },
+    { 62, 0xb8b8, 0x2121, 0xa2a2,  0, 0 },
+    { 63, 0xd3d3, 0x4444, 0xc0c0,  0, 0 },
+    { 64, 0xc2c2, 0x6666, 0xb7b7,  0, 0 },
+    { 65, 0xf4f4, 0x6666, 0xe6e6,  0, 0 },
+    { 66, 0xfcfc, 0x7373, 0xfdfd,  0, 0 },
+    { 67, 0xb9b9, 0xb9b9, 0xb9b9,  0, 0 },
+    { 68, 0xeaea, 0xdfdf, 0xeaea,  0, 0 },
+    { 69, 0xd4d4, 0x7171, 0xd5d5,  0, 0 },
+    { 70, 0xf9f9, 0x8b8b, 0xffff,  0, 0 },
+    { 71, 0xf5f5, 0xadad, 0xffff,  0, 0 },
+    { 72, 0xbcbc, 0x9292, 0xc2c2,  0, 0 },
+    { 73, 0xc7c7, 0x4f4f, 0xd9d9,  0, 0 },
+    { 74, 0xa0a0, 0x4444, 0xafaf,  0, 0 },
+    { 75, 0xc8c8, 0x8c8c, 0xd5d5,  0, 0 },
+    { 76, 0xd7d7, 0x7474, 0xf7f7,  0, 0 },
+    { 77, 0xb4b4, 0xb4b4, 0xb4b4,  0, 0 },
+    { 78, 0xdada, 0x9595, 0xf9f9,  0, 0 },
+    { 79, 0xeded, 0xcbcb, 0xffff,  0, 0 },
+    { 80, 0xb2b2, 0xb2b2, 0xb2b2,  0, 0 },
+    { 81, 0xa1a1, 0x6161, 0xd7d7,  0, 0 },
+    { 82, 0xb2b2, 0x8585, 0xe2e2,  0, 0 },
+    { 83, 0x5959, 0x2626, 0x9c9c,  0, 0 },
+    { 84, 0x7c7c, 0x5151, 0xcccc,  0, 0 },
+    { 85, 0xb0b0, 0xb0b0, 0xb0b0,  0, 0 },
+    { 86, 0xb4b4, 0x8e8e, 0xfcfc,  0, 0 },
+    { 87, 0xd5d5, 0xc0c0, 0xffff,  0, 0 },
+    { 88, 0x5d5d, 0x3232, 0xcccc,  0, 0 },
+    { 89, 0x7b7b, 0x5c5c, 0xe5e5,  0, 0 },
+    { 90, 0xc0c0, 0xb0b0, 0xfdfd,  0, 0 },
+    { 91, 0x6060, 0x5353, 0xadad,  0, 0 },
+    { 92, 0x1212, 0xc0c, 0x7e7e,  0, 0 },
+    { 93, 0x2e2e, 0x2929, 0x9999,  0, 0 },
+    { 94, 0x7979, 0x7878, 0xe9e9,  0, 0 },
+    { 95, 0x5b5b, 0x5c5c, 0xd0d0,  0, 0 },
+    { 96, 0x6969, 0x6a6a, 0xcccc,  0, 0 },
+    { 97, 0x9393, 0x9494, 0xf8f8,  0, 0 },
+    { 98, 0x9292, 0x9292, 0xc3c3,  0, 0 },
+    { 99, 0x4141, 0x4444, 0xbaba,  0, 0 },
+    { 100, 0xa8a8, 0xabab, 0xffff,  0, 0 },
+    { 101, 0xa3a3, 0xa3a3, 0xa3a3,  0, 0 },
+    { 102, 0xdbdb, 0xdddd, 0xeaea,  0, 0 },
+    { 103, 0x3131, 0x4949, 0xaaaa,  0, 0 },
+    { 104, 0x7070, 0x8f8f, 0xf9f9,  0, 0 },
+    { 105, 0x4848, 0x6666, 0xc1c1,  0, 0 },
+    { 106, 0x5c5c, 0x7e7e, 0xe9e9,  0, 0 },
+    { 107, 0xe2e2, 0xe5e5, 0xebeb,  0, 0 },
+    { 108, 0xb0b0, 0xcdcd, 0xffff,  0, 0 },
+    { 109, 0x6c6c, 0x8989, 0xb7b7,  0, 0 },
+    { 110, 0x3434, 0x6565, 0xafaf,  0, 0 },
+    { 111, 0x8c8c, 0xb9b9, 0xffff,  0, 0 },
+    { 112, 0x3737, 0x7979, 0xd4d4,  0, 0 },
+    { 113, 0x5a5a, 0x9999, 0xeaea,  0, 0 },
+    { 114, 0xe0e, 0x4c4c, 0x9595,  0, 0 },
+    { 115, 0x7979, 0xb9b9, 0xffff,  0, 0 },
+    { 116, 0x8a8a, 0xa3a3, 0xbcbc,  0, 0 },
+    { 117, 0x2020, 0x6161, 0x9d9d,  0, 0 },
+    { 118, 0x8f8f, 0xaeae, 0xcaca,  0, 0 },
+    { 119, 0xa0a, 0x6060, 0xa8a8,  0, 0 },
+    { 120, 0x3f3f, 0x9494, 0xd9d9,  0, 0 },
+    { 121, 0x6363, 0xb5b5, 0xf9f9,  0, 0 },
+    { 122, 0xe2e2, 0xe8e8, 0xeded,  0, 0 },
+    { 123, 0x2828, 0x6a6a, 0x9999,  0, 0 },
+    { 124, 0x5555, 0xb2b2, 0xe7e7,  0, 0 },
+    { 125, 0x3232, 0x8989, 0xa9a9,  0, 0 },
+    { 126, 0xcfcf, 0xdada, 0xdede,  0, 0 },
+    { 127, 0x2929, 0xa1a1, 0xc7c7,  0, 0 },
+    { 128, 0x8686, 0xa9a9, 0xb4b4,  0, 0 },
+    { 129, 0x0, 0x5f5f, 0x7979,  0, 0 },
+    { 130, 0xc0c, 0x7777, 0x8e8e,  0, 0 },
+    { 131, 0x1212, 0x8f8f, 0xabab,  0, 0 },
+    { 132, 0x4141, 0xbaba, 0xd5d5,  0, 0 },
+    { 133, 0x2424, 0x8282, 0x8383,  0, 0 },
+    { 134, 0x2c2c, 0xc4c4, 0xc3c3,  0, 0 },
+    { 135, 0x1a1a, 0xabab, 0xa6a6,  0, 0 },
+    { 136, 0x4b4b, 0xa8a8, 0xa2a2,  0, 0 },
+    { 137, 0xa0a, 0x9393, 0x8585,  0, 0 },
+    { 138, 0xd0d, 0xa5a5, 0x9696,  0, 0 },
+    { 139, 0x2626, 0xbcbc, 0xacac,  0, 0 },
+    { 140, 0x404, 0x8181, 0x7272,  0, 0 },
+    { 141, 0x1919, 0xb3b3, 0x8686,  0, 0 },
+    { 142, 0x2929, 0xc1c1, 0x9494,  0, 0 },
+    { 143, 0x2121, 0x9c9c, 0x7171,  0, 0 },
+    { 144, 0x202, 0x8c8c, 0x5050,  0, 0 },
+    { 145, 0x3535, 0xd0d0, 0x8989,  0, 0 },
+    { 146, 0x4646, 0xa5a5, 0x7676,  0, 0 },
+    { 147, 0x202, 0x7d7d, 0x3939,  0, 0 },
+    { 148, 0x2929, 0xc9c9, 0x7171,  0, 0 },
+    { 149, 0x5757, 0xd6d6, 0x8f8f,  0, 0 },
+    { 150, 0xa2a2, 0xb5b5, 0xaaaa,  0, 0 },
+    { 151, 0x101, 0x8888, 0x2a2a,  0, 0 },
+    { 152, 0x7474, 0xbebe, 0x8a8a,  0, 0 },
+    { 153, 0x1919, 0xb6b6, 0x4747,  0, 0 },
+    { 154, 0x2d2d, 0xc6c6, 0x5151,  0, 0 },
+    { 155, 0x3838, 0xdede, 0x5d5d,  0, 0 },
+    { 156, 0x4c4c, 0xf4f4, 0x6f6f,  0, 0 },
+    { 157, 0x9191, 0x9c9c, 0x9393,  0, 0 },
+    { 158, 0x0, 0x8e8e, 0x1919,  0, 0 },
+    { 159, 0x1010, 0xafaf, 0x2828,  0, 0 },
+    { 160, 0xe3e3, 0xe3e3, 0xe3e3,  0, 0 },
+    { 161, 0x808, 0xa1a1, 0x1a1a,  0, 0 },
+    { 162, 0x5959, 0xc2c2, 0x6161,  0, 0 },
+    { 163, 0xf0f0, 0xf0f0, 0xf0f0,  0, 0 },
+    { 164, 0x8f8f, 0x9c9c, 0x9090,  0, 0 },
+    { 165, 0x2323, 0xcece, 0x2a2a,  0, 0 },
+    { 166, 0x1212, 0xbaba, 0x1717,  0, 0 },
+    { 167, 0x101, 0x8a8a, 0x202,  0, 0 },
+    { 168, 0x303, 0x9a9a, 0x202,  0, 0 },
+    { 169, 0x4040, 0xe4e4, 0x4040,  0, 0 },
+    { 170, 0x808, 0xb2b2, 0x505,  0, 0 },
+    { 171, 0x1313, 0xcccc, 0xf0f,  0, 0 },
+    { 172, 0x3636, 0xd7d7, 0x3232,  0, 0 },
+    { 173, 0x2828, 0xe9e9, 0x1f1f,  0, 0 },
+    { 174, 0x5353, 0xfbfb, 0x4c4c,  0, 0 },
+    { 175, 0x6f6f, 0xafaf, 0x6a6a,  0, 0 },
+    { 176, 0x7171, 0xe0e0, 0x6767,  0, 0 },
+    { 177, 0x3232, 0xc0c0, 0x1212,  0, 0 },
+    { 178, 0x2929, 0xa5a5, 0x808,  0, 0 },
+    { 179, 0x5c5c, 0xdddd, 0x3535,  0, 0 },
+    { 180, 0x0, 0xffff, 0xffff,  0, 0 },
+    { 181, 0x6363, 0xc8c8, 0x4545,  0, 0 },
+    { 182, 0x8686, 0xfdfd, 0x5b5b,  0, 0 },
+    { 183, 0x7171, 0xf6f6, 0x3939,  0, 0 },
+    { 184, 0x5555, 0xcccc, 0x1515,  0, 0 },
+    { 185, 0x0, 0xffff, 0x0,  0, 0 },
+    { 186, 0x9090, 0xcaca, 0x6e6e,  0, 0 },
+    { 187, 0x4343, 0xa7a7, 0x101,  0, 0 },
+    { 188, 0x8d8d, 0xe4e4, 0x3737,  0, 0 },
+    { 189, 0xb3b3, 0xf0f0, 0x6464,  0, 0 },
+    { 190, 0x8585, 0x8e8e, 0x7a7a,  0, 0 },
+    { 191, 0xb0b0, 0xfafa, 0x4d4d,  0, 0 },
+    { 192, 0xd6d6, 0xd6d6, 0xd6d6,  0, 0 },
+    { 193, 0x8888, 0xd0d0, 0x1a1a,  0, 0 },
+    { 194, 0x6a6a, 0xa7a7, 0x303,  0, 0 },
+    { 195, 0x9898, 0xbfbf, 0x4141,  0, 0 },
+    { 196, 0xcdcd, 0xf8f8, 0x5151,  0, 0 },
+    { 197, 0x9494, 0xa4a4, 0x5555,  0, 0 },
+    { 198, 0x9191, 0xb0b0, 0xa0a,  0, 0 },
+    { 199, 0xdada, 0xf1f1, 0x3c3c,  0, 0 },
+    { 200, 0xbaba, 0xcaca, 0x5353,  0, 0 },
+    { 201, 0xb9b9, 0xc3c3, 0x2828,  0, 0 },
+    { 202, 0xb1b1, 0xbaba, 0x1212,  0, 0 },
+    { 203, 0xd2d2, 0xd9d9, 0x2626,  0, 0 },
+    { 204, 0xe8e8, 0xecec, 0x2d2d,  0, 0 },
+    { 205, 0x9898, 0x9696, 0x202,  0, 0 },
+    { 206, 0xadad, 0xadad, 0x5c5c,  0, 0 },
+    { 207, 0xe2e2, 0xd8d8, 0x3838,  0, 0 },
+    { 208, 0xd9d9, 0xc4c4, 0x3838,  0, 0 },
+    { 209, 0xa8a8, 0x9a9a, 0x5050,  0, 0 },
+    { 210, 0x0, 0x0, 0xffff,  0, 0 },
+    { 211, 0xbebe, 0xaeae, 0x5e5e,  0, 0 },
+    { 212, 0x9a9a, 0x9898, 0x8e8e,  0, 0 },
+    { 213, 0xacac, 0x8d8d, 0xd0d,  0, 0 },
+    { 214, 0xc5c5, 0xa0a0, 0x2b2b,  0, 0 },
+    { 215, 0xdbdb, 0xb5b5, 0x4848,  0, 0 },
+    { 216, 0xdddd, 0x0, 0x0,  0, 0 },
+    { 217, 0x9c9c, 0x6d6d, 0x303,  0, 0 },
+    { 218, 0xd4d4, 0xa8a8, 0x4747,  0, 0 },
+    { 219, 0xb7b7, 0x7171, 0x1717,  0, 0 },
+    { 220, 0xdcdc, 0xa1a1, 0x5a5a,  0, 0 },
+    { 221, 0xb9b9, 0x9c9c, 0x7c7c,  0, 0 },
+    { 222, 0xb4b4, 0xabab, 0xa2a2,  0, 0 },
+    { 223, 0x9e9e, 0x4b4b, 0x101,  0, 0 },
+    { 224, 0xc8c8, 0x7878, 0x3535,  0, 0 },
+    { 225, 0xd2d2, 0x8d8d, 0x5151,  0, 0 },
+    { 226, 0xadad, 0x5252, 0xf0f,  0, 0 },
+    { 227, 0x0, 0xbbbb, 0x0,  0, 0 },
+    { 228, 0xb2b2, 0x6666, 0x3838,  0, 0 },
+    { 229, 0xb1b1, 0xa6a6, 0x9f9f,  0, 0 },
+    { 230, 0xb1b1, 0x8787, 0x6f6f,  0, 0 },
+    { 231, 0xa4a4, 0x3434, 0x303,  0, 0 },
+    { 232, 0xeeee, 0x9e9e, 0x8585,  0, 0 },
+    { 233, 0xc9c9, 0x7373, 0x5a5a,  0, 0 },
+    { 234, 0xe6e6, 0x9494, 0x7c7c,  0, 0 },
+    { 235, 0xa9a9, 0x2222, 0x606,  0, 0 },
+    { 236, 0xdbdb, 0x8787, 0x7474,  0, 0 },
+    { 237, 0xb0b0, 0x2e2e, 0x1515,  0, 0 },
+    { 238, 0xb7b7, 0x5a5a, 0x5050,  0, 0 },
+    { 239, 0xb2b2, 0x4242, 0x3b3b,  0, 0 },
+    { 240, 0xcdcd, 0x7373, 0x6e6e,  0, 0 },
+    { 241, 0xd9d9, 0x5858, 0x5858,  0, 0 },
+    { 242, 0xacac, 0xacac, 0xacac,  0, 0 },
+    { 243, 0xa0a0, 0xa0a0, 0xa0a0,  0, 0 },
+    { 244, 0x9a9a, 0x9a9a, 0x9a9a,  0, 0 },
+    { 245, 0x9292, 0x9292, 0x9292,  0, 0 },
+    { 246, 0x8e8e, 0x8e8e, 0x8e8e,  0, 0 },
+    { 247, 0xbbbb, 0xbbbb, 0xbbbb,  0, 0 },
+    { 248, 0x8181, 0x8181, 0x8181,  0, 0 },
+    { 249, 0x8888, 0x8888, 0x8888,  0, 0 },
+    { 250, 0x7777, 0x7777, 0x7777,  0, 0 },
+    { 251, 0x5555, 0x5555, 0x5555,  0, 0 },
+    { 252, 0x4444, 0x4444, 0x4444,  0, 0 },
+    { 253, 0x2222, 0x2222, 0x2222,  0, 0 },
+    { 254, 0x7b7b, 0x7b7b, 0x7b7b,  0, 0 },
+    { 255, 0x0, 0x0, 0x0,  0, 0 },
+};
+
+#else /* !USE_NEW_CLUT */
+
+static xColorItem darwinClut8[] = {
+    { 0, 0x0000, 0x0000, 0x0000,  0, 0 },
+    { 1, 0xffff, 0xffff, 0xcccc,  0, 0 },
+    { 2, 0xffff, 0xffff, 0x9999,  0, 0 },
+    { 3, 0xffff, 0xffff, 0x6666,  0, 0 },
+    { 4, 0xffff, 0xffff, 0x3333,  0, 0 },
+    { 5, 0xffff, 0xffff, 0x0000,  0, 0 },
+    { 6, 0xffff, 0xcccc, 0xffff,  0, 0 },
+    { 7, 0xffff, 0xcccc, 0xcccc,  0, 0 },
+    { 8, 0xffff, 0xcccc, 0x9999,  0, 0 },
+    { 9, 0xffff, 0xcccc, 0x6666,  0, 0 },
+    { 10, 0xffff, 0xcccc, 0x3333,  0, 0 },
+    { 11, 0xffff, 0xcccc, 0x0000,  0, 0 },
+    { 12, 0xffff, 0x9999, 0xffff,  0, 0 },
+    { 13, 0xffff, 0x9999, 0xcccc,  0, 0 },
+    { 14, 0xffff, 0x9999, 0x9999,  0, 0 },
+    { 15, 0xffff, 0x9999, 0x6666,  0, 0 },
+    { 16, 0xffff, 0x9999, 0x3333,  0, 0 },
+    { 17, 0xffff, 0x9999, 0x0000,  0, 0 },
+    { 18, 0xffff, 0x6666, 0xffff,  0, 0 },
+    { 19, 0xffff, 0x6666, 0xcccc,  0, 0 },
+    { 20, 0xffff, 0x6666, 0x9999,  0, 0 },
+    { 21, 0xffff, 0x6666, 0x6666,  0, 0 },
+    { 22, 0xffff, 0x6666, 0x3333,  0, 0 },
+    { 23, 0xffff, 0x6666, 0x0000,  0, 0 },
+    { 24, 0xffff, 0x3333, 0xffff,  0, 0 },
+    { 25, 0xffff, 0x3333, 0xcccc,  0, 0 },
+    { 26, 0xffff, 0x3333, 0x9999,  0, 0 },
+    { 27, 0xffff, 0x3333, 0x6666,  0, 0 },
+    { 28, 0xffff, 0x3333, 0x3333,  0, 0 },
+    { 29, 0xffff, 0x3333, 0x0000,  0, 0 },
+    { 30, 0xffff, 0x0000, 0xffff,  0, 0 },
+    { 31, 0xffff, 0x0000, 0xcccc,  0, 0 },
+    { 32, 0xffff, 0x0000, 0x9999,  0, 0 },
+    { 33, 0xffff, 0x0000, 0x6666,  0, 0 },
+    { 34, 0xffff, 0x0000, 0x3333,  0, 0 },
+    { 35, 0xffff, 0x0000, 0x0000,  0, 0 },
+    { 36, 0xcccc, 0xffff, 0xffff,  0, 0 },
+    { 37, 0xcccc, 0xffff, 0xcccc,  0, 0 },
+    { 38, 0xcccc, 0xffff, 0x9999,  0, 0 },
+    { 39, 0xcccc, 0xffff, 0x6666,  0, 0 },
+    { 40, 0xcccc, 0xffff, 0x3333,  0, 0 },
+    { 41, 0xcccc, 0xffff, 0x0000,  0, 0 },
+    { 42, 0xcccc, 0xcccc, 0xffff,  0, 0 },
+    { 43, 0xcccc, 0xcccc, 0xcccc,  0, 0 },
+    { 44, 0xcccc, 0xcccc, 0x9999,  0, 0 },
+    { 45, 0xcccc, 0xcccc, 0x6666,  0, 0 },
+    { 46, 0xcccc, 0xcccc, 0x3333,  0, 0 },
+    { 47, 0xcccc, 0xcccc, 0x0000,  0, 0 },
+    { 48, 0xcccc, 0x9999, 0xffff,  0, 0 },
+    { 49, 0xcccc, 0x9999, 0xcccc,  0, 0 },
+    { 50, 0xcccc, 0x9999, 0x9999,  0, 0 },
+    { 51, 0xcccc, 0x9999, 0x6666,  0, 0 },
+    { 52, 0xcccc, 0x9999, 0x3333,  0, 0 },
+    { 53, 0xcccc, 0x9999, 0x0000,  0, 0 },
+    { 54, 0xcccc, 0x6666, 0xffff,  0, 0 },
+    { 55, 0xcccc, 0x6666, 0xcccc,  0, 0 },
+    { 56, 0xcccc, 0x6666, 0x9999,  0, 0 },
+    { 57, 0xcccc, 0x6666, 0x6666,  0, 0 },
+    { 58, 0xcccc, 0x6666, 0x3333,  0, 0 },
+    { 59, 0xcccc, 0x6666, 0x0000,  0, 0 },
+    { 60, 0xcccc, 0x3333, 0xffff,  0, 0 },
+    { 61, 0xcccc, 0x3333, 0xcccc,  0, 0 },
+    { 62, 0xcccc, 0x3333, 0x9999,  0, 0 },
+    { 63, 0xcccc, 0x3333, 0x6666,  0, 0 },
+    { 64, 0xcccc, 0x3333, 0x3333,  0, 0 },
+    { 65, 0xcccc, 0x3333, 0x0000,  0, 0 },
+    { 66, 0xcccc, 0x0000, 0xffff,  0, 0 },
+    { 67, 0xcccc, 0x0000, 0xcccc,  0, 0 },
+    { 68, 0xcccc, 0x0000, 0x9999,  0, 0 },
+    { 69, 0xcccc, 0x0000, 0x6666,  0, 0 },
+    { 70, 0xcccc, 0x0000, 0x3333,  0, 0 },
+    { 71, 0xcccc, 0x0000, 0x0000,  0, 0 },
+    { 72, 0x9999, 0xffff, 0xffff,  0, 0 },
+    { 73, 0x9999, 0xffff, 0xcccc,  0, 0 },
+    { 74, 0x9999, 0xffff, 0x9999,  0, 0 },
+    { 75, 0x9999, 0xffff, 0x6666,  0, 0 },
+    { 76, 0x9999, 0xffff, 0x3333,  0, 0 },
+    { 77, 0x9999, 0xffff, 0x0000,  0, 0 },
+    { 78, 0x9999, 0xcccc, 0xffff,  0, 0 },
+    { 79, 0x9999, 0xcccc, 0xcccc,  0, 0 },
+    { 80, 0x9999, 0xcccc, 0x9999,  0, 0 },
+    { 81, 0x9999, 0xcccc, 0x6666,  0, 0 },
+    { 82, 0x9999, 0xcccc, 0x3333,  0, 0 },
+    { 83, 0x9999, 0xcccc, 0x0000,  0, 0 },
+    { 84, 0x9999, 0x9999, 0xffff,  0, 0 },
+    { 85, 0x9999, 0x9999, 0xcccc,  0, 0 },
+    { 86, 0x9999, 0x9999, 0x9999,  0, 0 },
+    { 87, 0x9999, 0x9999, 0x6666,  0, 0 },
+    { 88, 0x9999, 0x9999, 0x3333,  0, 0 },
+    { 89, 0x9999, 0x9999, 0x0000,  0, 0 },
+    { 90, 0x9999, 0x6666, 0xffff,  0, 0 },
+    { 91, 0x9999, 0x6666, 0xcccc,  0, 0 },
+    { 92, 0x9999, 0x6666, 0x9999,  0, 0 },
+    { 93, 0x9999, 0x6666, 0x6666,  0, 0 },
+    { 94, 0x9999, 0x6666, 0x3333,  0, 0 },
+    { 95, 0x9999, 0x6666, 0x0000,  0, 0 },
+    { 96, 0x9999, 0x3333, 0xffff,  0, 0 },
+    { 97, 0x9999, 0x3333, 0xcccc,  0, 0 },
+    { 98, 0x9999, 0x3333, 0x9999,  0, 0 },
+    { 99, 0x9999, 0x3333, 0x6666,  0, 0 },
+    { 100, 0x9999, 0x3333, 0x3333,  0, 0 },
+    { 101, 0x9999, 0x3333, 0x0000,  0, 0 },
+    { 102, 0x9999, 0x0000, 0xffff,  0, 0 },
+    { 103, 0x9999, 0x0000, 0xcccc,  0, 0 },
+    { 104, 0x9999, 0x0000, 0x9999,  0, 0 },
+    { 105, 0x9999, 0x0000, 0x6666,  0, 0 },
+    { 106, 0x9999, 0x0000, 0x3333,  0, 0 },
+    { 107, 0x9999, 0x0000, 0x0000,  0, 0 },
+    { 108, 0x6666, 0xffff, 0xffff,  0, 0 },
+    { 109, 0x6666, 0xffff, 0xcccc,  0, 0 },
+    { 110, 0x6666, 0xffff, 0x9999,  0, 0 },
+    { 111, 0x6666, 0xffff, 0x6666,  0, 0 },
+    { 112, 0x6666, 0xffff, 0x3333,  0, 0 },
+    { 113, 0x6666, 0xffff, 0x0000,  0, 0 },
+    { 114, 0x6666, 0xcccc, 0xffff,  0, 0 },
+    { 115, 0x6666, 0xcccc, 0xcccc,  0, 0 },
+    { 116, 0x6666, 0xcccc, 0x9999,  0, 0 },
+    { 117, 0x6666, 0xcccc, 0x6666,  0, 0 },
+    { 118, 0x6666, 0xcccc, 0x3333,  0, 0 },
+    { 119, 0x6666, 0xcccc, 0x0000,  0, 0 },
+    { 120, 0x6666, 0x9999, 0xffff,  0, 0 },
+    { 121, 0x6666, 0x9999, 0xcccc,  0, 0 },
+    { 122, 0x6666, 0x9999, 0x9999,  0, 0 },
+    { 123, 0x6666, 0x9999, 0x6666,  0, 0 },
+    { 124, 0x6666, 0x9999, 0x3333,  0, 0 },
+    { 125, 0x6666, 0x9999, 0x0000,  0, 0 },
+    { 126, 0x6666, 0x6666, 0xffff,  0, 0 },
+    { 127, 0x6666, 0x6666, 0xcccc,  0, 0 },
+    { 128, 0x6666, 0x6666, 0x9999,  0, 0 },
+    { 129, 0x6666, 0x6666, 0x6666,  0, 0 },
+    { 130, 0x6666, 0x6666, 0x3333,  0, 0 },
+    { 131, 0x6666, 0x6666, 0x0000,  0, 0 },
+    { 132, 0x6666, 0x3333, 0xffff,  0, 0 },
+    { 133, 0x6666, 0x3333, 0xcccc,  0, 0 },
+    { 134, 0x6666, 0x3333, 0x9999,  0, 0 },
+    { 135, 0x6666, 0x3333, 0x6666,  0, 0 },
+    { 136, 0x6666, 0x3333, 0x3333,  0, 0 },
+    { 137, 0x6666, 0x3333, 0x0000,  0, 0 },
+    { 138, 0x6666, 0x0000, 0xffff,  0, 0 },
+    { 139, 0x6666, 0x0000, 0xcccc,  0, 0 },
+    { 140, 0x6666, 0x0000, 0x9999,  0, 0 },
+    { 141, 0x6666, 0x0000, 0x6666,  0, 0 },
+    { 142, 0x6666, 0x0000, 0x3333,  0, 0 },
+    { 143, 0x6666, 0x0000, 0x0000,  0, 0 },
+    { 144, 0x3333, 0xffff, 0xffff,  0, 0 },
+    { 145, 0x3333, 0xffff, 0xcccc,  0, 0 },
+    { 146, 0x3333, 0xffff, 0x9999,  0, 0 },
+    { 147, 0x3333, 0xffff, 0x6666,  0, 0 },
+    { 148, 0x3333, 0xffff, 0x3333,  0, 0 },
+    { 149, 0x3333, 0xffff, 0x0000,  0, 0 },
+    { 150, 0x3333, 0xcccc, 0xffff,  0, 0 },
+    { 151, 0x3333, 0xcccc, 0xcccc,  0, 0 },
+    { 152, 0x3333, 0xcccc, 0x9999,  0, 0 },
+    { 153, 0x3333, 0xcccc, 0x6666,  0, 0 },
+    { 154, 0x3333, 0xcccc, 0x3333,  0, 0 },
+    { 155, 0x3333, 0xcccc, 0x0000,  0, 0 },
+    { 156, 0x3333, 0x9999, 0xffff,  0, 0 },
+    { 157, 0x3333, 0x9999, 0xcccc,  0, 0 },
+    { 158, 0x3333, 0x9999, 0x9999,  0, 0 },
+    { 159, 0x3333, 0x9999, 0x6666,  0, 0 },
+    { 160, 0x3333, 0x9999, 0x3333,  0, 0 },
+    { 161, 0x3333, 0x9999, 0x0000,  0, 0 },
+    { 162, 0x3333, 0x6666, 0xffff,  0, 0 },
+    { 163, 0x3333, 0x6666, 0xcccc,  0, 0 },
+    { 164, 0x3333, 0x6666, 0x9999,  0, 0 },
+    { 165, 0x3333, 0x6666, 0x6666,  0, 0 },
+    { 166, 0x3333, 0x6666, 0x3333,  0, 0 },
+    { 167, 0x3333, 0x6666, 0x0000,  0, 0 },
+    { 168, 0x3333, 0x3333, 0xffff,  0, 0 },
+    { 169, 0x3333, 0x3333, 0xcccc,  0, 0 },
+    { 170, 0x3333, 0x3333, 0x9999,  0, 0 },
+    { 171, 0x3333, 0x3333, 0x6666,  0, 0 },
+    { 172, 0x3333, 0x3333, 0x3333,  0, 0 },
+    { 173, 0x3333, 0x3333, 0x0000,  0, 0 },
+    { 174, 0x3333, 0x0000, 0xffff,  0, 0 },
+    { 175, 0x3333, 0x0000, 0xcccc,  0, 0 },
+    { 176, 0x3333, 0x0000, 0x9999,  0, 0 },
+    { 177, 0x3333, 0x0000, 0x6666,  0, 0 },
+    { 178, 0x3333, 0x0000, 0x3333,  0, 0 },
+    { 179, 0x3333, 0x0000, 0x0000,  0, 0 },
+    { 180, 0x0000, 0xffff, 0xffff,  0, 0 },
+    { 181, 0x0000, 0xffff, 0xcccc,  0, 0 },
+    { 182, 0x0000, 0xffff, 0x9999,  0, 0 },
+    { 183, 0x0000, 0xffff, 0x6666,  0, 0 },
+    { 184, 0x0000, 0xffff, 0x3333,  0, 0 },
+    { 185, 0x0000, 0xffff, 0x0000,  0, 0 },
+    { 186, 0x0000, 0xcccc, 0xffff,  0, 0 },
+    { 187, 0x0000, 0xcccc, 0xcccc,  0, 0 },
+    { 188, 0x0000, 0xcccc, 0x9999,  0, 0 },
+    { 189, 0x0000, 0xcccc, 0x6666,  0, 0 },
+    { 190, 0x0000, 0xcccc, 0x3333,  0, 0 },
+    { 191, 0x0000, 0xcccc, 0x0000,  0, 0 },
+    { 192, 0x0000, 0x9999, 0xffff,  0, 0 },
+    { 193, 0x0000, 0x9999, 0xcccc,  0, 0 },
+    { 194, 0x0000, 0x9999, 0x9999,  0, 0 },
+    { 195, 0x0000, 0x9999, 0x6666,  0, 0 },
+    { 196, 0x0000, 0x9999, 0x3333,  0, 0 },
+    { 197, 0x0000, 0x9999, 0x0000,  0, 0 },
+    { 198, 0x0000, 0x6666, 0xffff,  0, 0 },
+    { 199, 0x0000, 0x6666, 0xcccc,  0, 0 },
+    { 200, 0x0000, 0x6666, 0x9999,  0, 0 },
+    { 201, 0x0000, 0x6666, 0x6666,  0, 0 },
+    { 202, 0x0000, 0x6666, 0x3333,  0, 0 },
+    { 203, 0x0000, 0x6666, 0x0000,  0, 0 },
+    { 204, 0x0000, 0x3333, 0xffff,  0, 0 },
+    { 205, 0x0000, 0x3333, 0xcccc,  0, 0 },
+    { 206, 0x0000, 0x3333, 0x9999,  0, 0 },
+    { 207, 0x0000, 0x3333, 0x6666,  0, 0 },
+    { 208, 0x0000, 0x3333, 0x3333,  0, 0 },
+    { 209, 0x0000, 0x3333, 0x0000,  0, 0 },
+    { 210, 0x0000, 0x0000, 0xffff,  0, 0 },
+    { 211, 0x0000, 0x0000, 0xcccc,  0, 0 },
+    { 212, 0x0000, 0x0000, 0x9999,  0, 0 },
+    { 213, 0x0000, 0x0000, 0x6666,  0, 0 },
+    { 214, 0x0000, 0x0000, 0x3333,  0, 0 },
+    { 215, 0xeeee, 0x0000, 0x0000,  0, 0 },
+    { 216, 0xdddd, 0x0000, 0x0000,  0, 0 },
+    { 217, 0xbbbb, 0x0000, 0x0000,  0, 0 },
+    { 218, 0xaaaa, 0x0000, 0x0000,  0, 0 },
+    { 219, 0x8888, 0x0000, 0x0000,  0, 0 },
+    { 220, 0x7777, 0x0000, 0x0000,  0, 0 },
+    { 221, 0x5555, 0x0000, 0x0000,  0, 0 },
+    { 222, 0x4444, 0x0000, 0x0000,  0, 0 },
+    { 223, 0x2222, 0x0000, 0x0000,  0, 0 },
+    { 224, 0x1111, 0x0000, 0x0000,  0, 0 },
+    { 225, 0x0000, 0xeeee, 0x0000,  0, 0 },
+    { 226, 0x0000, 0xdddd, 0x0000,  0, 0 },
+    { 227, 0x0000, 0xbbbb, 0x0000,  0, 0 },
+    { 228, 0x0000, 0xaaaa, 0x0000,  0, 0 },
+    { 229, 0x0000, 0x8888, 0x0000,  0, 0 },
+    { 230, 0x0000, 0x7777, 0x0000,  0, 0 },
+    { 231, 0x0000, 0x5555, 0x0000,  0, 0 },
+    { 232, 0x0000, 0x4444, 0x0000,  0, 0 },
+    { 233, 0x0000, 0x2222, 0x0000,  0, 0 },
+    { 234, 0x0000, 0x1111, 0x0000,  0, 0 },
+    { 235, 0x0000, 0x0000, 0xeeee,  0, 0 },
+    { 236, 0x0000, 0x0000, 0xdddd,  0, 0 },
+    { 237, 0x0000, 0x0000, 0xbbbb,  0, 0 },
+    { 238, 0x0000, 0x0000, 0xaaaa,  0, 0 },
+    { 239, 0x0000, 0x0000, 0x8888,  0, 0 },
+    { 240, 0x0000, 0x0000, 0x7777,  0, 0 },
+    { 241, 0x0000, 0x0000, 0x5555,  0, 0 },
+    { 242, 0x0000, 0x0000, 0x4444,  0, 0 },
+    { 243, 0x0000, 0x0000, 0x2222,  0, 0 },
+    { 244, 0x0000, 0x0000, 0x1111,  0, 0 },
+    { 245, 0xeeee, 0xeeee, 0xeeee,  0, 0 },
+    { 246, 0xdddd, 0xdddd, 0xdddd,  0, 0 },
+    { 247, 0xbbbb, 0xbbbb, 0xbbbb,  0, 0 },
+    { 248, 0xaaaa, 0xaaaa, 0xaaaa,  0, 0 },
+    { 249, 0x8888, 0x8888, 0x8888,  0, 0 },
+    { 250, 0x7777, 0x7777, 0x7777,  0, 0 },
+    { 251, 0x5555, 0x5555, 0x5555,  0, 0 },
+    { 252, 0x4444, 0x4444, 0x4444,  0, 0 },
+    { 253, 0x2222, 0x2222, 0x2222,  0, 0 },
+    { 254, 0x1111, 0x1111, 0x1111,  0, 0 },
+    { 255, 0xffff, 0xffff, 0xffff,  0, 0 }
+};
+#endif /* USE_NEW_CLUT */
+
+#endif /* _DARWIN_CLUT8_ */
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
new file mode 100644
index 0000000..629fb2c
--- /dev/null
+++ b/hw/xquartz/darwinEvents.c
@@ -0,0 +1,461 @@
+/*
+Darwin event queue and event handling
+
+Copyright 2007 Apple Inc.
+Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
+Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved.
+
+This file is based on mieq.c by Keith Packard,
+which contains the following copyright:
+Copyright 1990, 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.
+ */
+
+#define NEED_EVENTS
+#include   <X11/X.h>
+#include   <X11/Xmd.h>
+#include   <X11/Xproto.h>
+#include   "misc.h"
+#include   "windowstr.h"
+#include   "pixmapstr.h"
+#include   "inputstr.h"
+#include   "mi.h"
+#include   "scrnintstr.h"
+#include   "mipointer.h"
+
+#include "darwin.h"
+#include "darwinKeyboard.h"
+
+#include <sys/types.h>
+#include <sys/uio.h>
+#include <unistd.h>
+#include <IOKit/hidsystem/IOLLEvent.h>
+
+/* Fake button press/release for scroll wheel move. */
+#define SCROLLWHEELUPFAKE   4
+#define SCROLLWHEELDOWNFAKE 5
+
+#define QUEUE_SIZE 256
+
+typedef struct _Event {
+    xEvent      event;
+    ScreenPtr   pScreen;
+} EventRec, *EventPtr;
+
+int input_check_zero, input_check_flag;
+
+static int old_flags = 0;  // last known modifier state
+
+typedef struct _EventQueue {
+    HWEventQueueType    head, tail; /* long for SetInputCheck */
+    CARD32      lastEventTime;      /* to avoid time running backwards */
+    Bool        lastMotion;
+    EventRec    events[QUEUE_SIZE]; /* static allocation for signals */
+    DevicePtr   pKbd, pPtr;         /* device pointer, to get funcs */
+    ScreenPtr   pEnqueueScreen;     /* screen events are being delivered to */
+    ScreenPtr   pDequeueScreen;     /* screen events are being dispatched to */
+} EventQueueRec, *EventQueuePtr;
+
+static EventQueueRec darwinEventQueue;
+xEvent *darwinEvents;
+
+/*
+ * DarwinPressModifierMask
+ *  Press or release the given modifier key, specified by its mask.
+ */
+static void DarwinPressModifierMask(
+    int pressed,				    
+    int mask)       // one of NX_*MASK constants
+{
+    int key = DarwinModifierNXMaskToNXKey(mask);
+
+    if (key != -1) {
+        int keycode = DarwinModifierNXKeyToNXKeycode(key, 0);
+        if (keycode != 0)
+	  DarwinSendKeyboardEvents(pressed, keycode);
+    }
+}
+
+#ifdef NX_DEVICELCTLKEYMASK
+#define CONTROL_MASK(flags) (flags & (NX_DEVICELCTLKEYMASK|NX_DEVICERCTLKEYMASK))
+#else
+#define CONTROL_MASK(flags) (NX_CONTROLMASK)
+#endif /* NX_DEVICELCTLKEYMASK */
+
+#ifdef NX_DEVICELSHIFTKEYMASK
+#define SHIFT_MASK(flags) (flags & (NX_DEVICELSHIFTKEYMASK|NX_DEVICERSHIFTKEYMASK))
+#else
+#define SHIFT_MASK(flags) (NX_SHIFTMASK)
+#endif /* NX_DEVICELSHIFTKEYMASK */
+
+#ifdef NX_DEVICELCMDKEYMASK
+#define COMMAND_MASK(flags) (flags & (NX_DEVICELCMDKEYMASK|NX_DEVICERCMDKEYMASK))
+#else
+#define COMMAND_MASK(flags) (NX_COMMANDMASK)
+#endif /* NX_DEVICELCMDKEYMASK */
+
+#ifdef NX_DEVICELALTKEYMASK
+#define ALTERNATE_MASK(flags) (flags & (NX_DEVICELALTKEYMASK|NX_DEVICERALTKEYMASK))
+#else
+#define ALTERNATE_MASK(flags) (NX_ALTERNATEMASK)
+#endif /* NX_DEVICELALTKEYMASK */
+
+/*
+ * DarwinUpdateModifiers
+ *  Send events to update the modifier state.
+ */
+static void DarwinUpdateModifiers(
+    int pressed,        // KeyPress or KeyRelease
+    int flags )         // modifier flags that have changed
+{
+    if (flags & NX_ALPHASHIFTMASK) {
+        DarwinPressModifierMask(pressed, NX_ALPHASHIFTMASK);
+    }
+    if (flags & NX_COMMANDMASK) {
+        DarwinPressModifierMask(pressed, COMMAND_MASK(flags));
+    }
+    if (flags & NX_CONTROLMASK) {
+        DarwinPressModifierMask(pressed, CONTROL_MASK(flags));
+    }
+    if (flags & NX_ALTERNATEMASK) {
+        DarwinPressModifierMask(pressed, ALTERNATE_MASK(flags));
+    }
+    if (flags & NX_SHIFTMASK) {
+        DarwinPressModifierMask(pressed, SHIFT_MASK(flags));
+    }
+    if (flags & NX_SECONDARYFNMASK) {
+        DarwinPressModifierMask(pressed, NX_SECONDARYFNMASK);
+    }
+}
+
+/*
+ * DarwinReleaseModifiers
+ * This hacky function releases all modifier keys.  It should be called when X11.app
+ * is deactivated (kXDarwinDeactivate) to prevent modifiers from getting stuck if they
+ * are held down during a "context" switch -- otherwise, we would miss the KeyUp.
+ */
+static void DarwinReleaseModifiers(void) {
+	DarwinUpdateModifiers(KeyRelease, COMMAND_MASK(-1) | CONTROL_MASK(-1) | ALTERNATE_MASK(-1) | SHIFT_MASK(-1));
+}
+
+/*
+ * DarwinSimulateMouseClick
+ *  Send a mouse click to X when multiple mouse buttons are simulated
+ *  with modifier-clicks, such as command-click for button 2. The dix
+ *  layer is told that the previously pressed modifier key(s) are
+ *  released, the simulated click event is sent. After the mouse button
+ *  is released, the modifier keys are reverted to their actual state,
+ *  which may or may not be pressed at that point. This is usually
+ *  closest to what the user wants. Ie. the user typically wants to
+ *  simulate a button 2 press instead of Command-button 2.
+ */
+static void DarwinSimulateMouseClick(
+    int pointer_x,
+    int pointer_y,
+    int whichButton,    // mouse button to be pressed
+    int modifierMask)   // modifiers used for the fake click
+{
+    // first fool X into forgetting about the keys
+	// for some reason, it's not enough to tell X we released the Command key -- 
+	// it has to be the *left* Command key.
+	if (modifierMask & NX_COMMANDMASK) modifierMask |=NX_DEVICELCMDKEYMASK ;
+    DarwinUpdateModifiers(KeyRelease, modifierMask);
+
+    // push the mouse button
+    DarwinSendPointerEvents(ButtonPress, whichButton, pointer_x, pointer_y);
+    DarwinSendPointerEvents(ButtonRelease, whichButton, pointer_x, pointer_y);
+
+    // restore old modifiers
+    DarwinUpdateModifiers(KeyPress, modifierMask);
+}
+
+
+Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr) { 
+    darwinEvents = (xEvent *)malloc(sizeof(xEvent) * GetMaximumEventsNum());
+    mieqInit();
+    darwinEventQueue.head = darwinEventQueue.tail = 0;
+    darwinEventQueue.lastEventTime = GetTimeInMillis ();
+    darwinEventQueue.pKbd = pKbd;
+    darwinEventQueue.pPtr = pPtr;
+    darwinEventQueue.pEnqueueScreen = screenInfo.screens[0];
+    darwinEventQueue.pDequeueScreen = darwinEventQueue.pEnqueueScreen;
+    SetInputCheck(&input_check_zero, &input_check_flag);
+    return TRUE;
+}
+
+
+/*
+ * DarwinEQEnqueue
+ *  Must be thread safe with ProcessInputEvents.
+ *    DarwinEQEnqueue    - called from event gathering thread
+ *    ProcessInputEvents - called from X server thread
+ *  DarwinEQEnqueue should never be called from more than one thread.
+ * 
+ * This should be deprecated in favor of miEQEnqueue -- BB
+ */
+void DarwinEQEnqueue(const xEvent *e) {
+    HWEventQueueType oldtail, newtail;
+    char byte = 0;
+
+    oldtail = darwinEventQueue.tail;
+
+    // mieqEnqueue() collapses successive motion events into one event.
+    // This is difficult to do in a thread-safe way and rarely useful.
+
+    newtail = oldtail + 1;
+    if (newtail == QUEUE_SIZE) newtail = 0;
+    /* Toss events which come in late */
+    if (newtail == darwinEventQueue.head) return;
+
+    darwinEventQueue.events[oldtail].event = *e;
+
+    /*
+     * Make sure that event times don't go backwards - this
+     * is "unnecessary", but very useful
+     */
+    if (e->u.keyButtonPointer.time < darwinEventQueue.lastEventTime &&
+        darwinEventQueue.lastEventTime - e->u.keyButtonPointer.time < 10000)
+    {
+        darwinEventQueue.events[oldtail].event.u.keyButtonPointer.time =
+        darwinEventQueue.lastEventTime;
+    }
+    darwinEventQueue.events[oldtail].pScreen = darwinEventQueue.pEnqueueScreen;
+
+    // Update the tail after the event is prepared
+    darwinEventQueue.tail = newtail;
+
+    // Signal there is an event ready to handle
+    DarwinPokeEQ();
+}
+
+
+/*
+ * DarwinEQPointerPost
+ *  Post a pointer event. Used by the mipointer.c routines.
+ */
+void DarwinEQPointerPost(xEvent *e) {
+    (*darwinEventQueue.pPtr->processInputProc)
+            (e, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
+}
+
+
+void DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX) {
+    darwinEventQueue.pEnqueueScreen = pScreen;
+    if (fromDIX)
+        darwinEventQueue.pDequeueScreen = pScreen;
+}
+
+
+/*
+ * ProcessInputEvents
+ *  Read and process events from the event queue until it is empty.
+ */
+void ProcessInputEvents(void) {
+    EventRec *e;
+    int     x, y;
+    xEvent  xe;
+    static int  old_flags = 0;  // last known modifier state
+    // button number and modifier mask of currently pressed fake button
+    input_check_flag=0;
+
+    //    ErrorF("calling mieqProcessInputEvents\n");
+    mieqProcessInputEvents();
+
+    // Empty the signaling pipe
+    x = sizeof(xe);
+    while (x == sizeof(xe)) 
+        x = read(darwinEventReadFD, &xe, sizeof(xe));
+
+    while (darwinEventQueue.head != darwinEventQueue.tail)
+    {
+        if (screenIsSaved == SCREEN_SAVER_ON)
+            SaveScreens (SCREEN_SAVER_OFF, ScreenSaverReset);
+
+        e = &darwinEventQueue.events[darwinEventQueue.head];
+        xe = e->event;
+
+        // Shift from global screen coordinates to coordinates relative to
+        // the origin of the current screen.
+        xe.u.keyButtonPointer.rootX -= darwinMainScreenX +
+                dixScreenOrigins[miPointerCurrentScreen()->myNum].x;
+        xe.u.keyButtonPointer.rootY -= darwinMainScreenY +
+                dixScreenOrigins[miPointerCurrentScreen()->myNum].y;
+	
+	/*	ErrorF("old rootX = (%d,%d) darwinMainScreen = (%d,%d) dixScreenOrigins[%d]=(%d,%d)\n",
+	       xe.u.keyButtonPointer.rootX, xe.u.keyButtonPointer.rootY,
+	       darwinMainScreenX, darwinMainScreenY,
+	       miPointerCurrentScreen()->myNum,
+	       dixScreenOrigins[miPointerCurrentScreen()->myNum].x,
+	       dixScreenOrigins[miPointerCurrentScreen()->myNum].y); */
+
+	//Assumption - screen switching can only occur on motion events
+
+        if (e->pScreen != darwinEventQueue.pDequeueScreen)
+        {
+            darwinEventQueue.pDequeueScreen = e->pScreen;
+            x = xe.u.keyButtonPointer.rootX;
+            y = xe.u.keyButtonPointer.rootY;
+            if (darwinEventQueue.head == QUEUE_SIZE - 1)
+                darwinEventQueue.head = 0;
+            else
+                ++darwinEventQueue.head;
+            NewCurrentScreen (darwinEventQueue.pDequeueScreen, x, y);
+        }
+        else
+        {
+            if (darwinEventQueue.head == QUEUE_SIZE - 1)
+                darwinEventQueue.head = 0;
+            else
+                ++darwinEventQueue.head;
+            switch (xe.u.u.type) {
+            case KeyPress:
+            case KeyRelease:
+	      ErrorF("Unexpected Keyboard event in DarwinProcessInputEvents\n");
+	      break;
+
+            case ButtonPress:
+	      ErrorF("Unexpected ButtonPress event in DarwinProcessInputEvents\n");
+                break;
+
+            case ButtonRelease:
+	      ErrorF("Unexpected ButtonRelease event in DarwinProcessInputEvents\n");
+                break;
+
+            case MotionNotify:
+	      ErrorF("Unexpected ButtonRelease event in DarwinProcessInputEvents\n");
+                break;
+
+            case kXDarwinUpdateModifiers:
+	      ErrorF("Unexpected ButtonRelease event in DarwinProcessInputEvents\n");
+	      break;
+
+            case kXDarwinUpdateButtons:
+	      ErrorF("Unexpected XDarwinScrollWheel event in DarwinProcessInputEvents\n");
+	      break;
+
+            case kXDarwinScrollWheel: 
+	      ErrorF("Unexpected XDarwinScrollWheel event in DarwinProcessInputEvents\n");
+	      break;
+
+			case kXDarwinDeactivate:
+				DarwinReleaseModifiers();
+				// fall through
+            default:
+                // Check for mode specific event
+                DarwinModeProcessEvent(&xe);
+            }
+        }
+    }
+
+    //    miPointerUpdate();
+}
+
+/* Sends a null byte down darwinEventWriteFD, which will cause the
+   Dispatch() event loop to check out event queue */
+void DarwinPokeEQ(void) {
+  char nullbyte=0;
+  input_check_flag++;
+  //  <daniels> bushing: oh, i ... er ... christ.
+  write(darwinEventWriteFD, &nullbyte, 1);
+}
+
+void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int pointer_y) {
+  static int darwinFakeMouseButtonDown = 0;
+  static int darwinFakeMouseButtonMask = 0;
+  int i, num_events;
+  int valuators[2] = {pointer_x, pointer_y};
+  if (ev_type == ButtonPress && darwinFakeButtons && ev_button == 1) {
+    // Mimic multi-button mouse with modifier-clicks
+    // If both sets of modifiers are pressed,
+    // button 2 is clicked.
+    if ((old_flags & darwinFakeMouse2Mask) == darwinFakeMouse2Mask) {
+      DarwinSimulateMouseClick(pointer_x, pointer_y, 2, darwinFakeMouse2Mask);
+      darwinFakeMouseButtonDown = 2;
+      darwinFakeMouseButtonMask = darwinFakeMouse2Mask;
+    } else if ((old_flags & darwinFakeMouse3Mask) == darwinFakeMouse3Mask) {
+      DarwinSimulateMouseClick(pointer_x, pointer_y, 3, darwinFakeMouse3Mask);
+      darwinFakeMouseButtonDown = 3;
+      darwinFakeMouseButtonMask = darwinFakeMouse3Mask;
+    }
+  }
+  if (ev_type == ButtonRelease && darwinFakeButtons && darwinFakeMouseButtonDown) {
+    // If last mousedown was a fake click, don't check for
+    // mouse modifiers here. The user may have released the
+    // modifiers before the mouse button.
+    ev_button = darwinFakeMouseButtonDown;
+    darwinFakeMouseButtonDown = 0;
+    // Bring modifiers back up to date
+    DarwinUpdateModifiers(KeyPress, darwinFakeMouseButtonMask & old_flags);
+    darwinFakeMouseButtonMask = 0;
+  } 
+
+  num_events = GetPointerEvents(darwinEvents, darwinPointer, ev_type, ev_button, 
+				POINTER_ABSOLUTE, 0, 2, valuators);
+      
+  for(i=0; i<num_events; i++) mieqEnqueue (darwinPointer,&darwinEvents[i]);
+  DarwinPokeEQ();
+}
+
+void DarwinSendKeyboardEvents(int ev_type, int keycode) {
+  int i, num_events;
+  if (old_flags == 0 && darwinSyncKeymap && darwinKeymapFile == NULL) {
+    /* See if keymap has changed. */
+
+    static unsigned int last_seed;
+    unsigned int this_seed;
+
+    this_seed = DarwinModeSystemKeymapSeed();
+    if (this_seed != last_seed) {
+      last_seed = this_seed;
+      DarwinKeyboardReload(darwinKeyboard);
+    }
+  }
+
+  num_events = GetKeyboardEvents(darwinEvents, darwinKeyboard, ev_type, keycode + MIN_KEYCODE);
+  for(i=0; i<num_events; i++) mieqEnqueue(darwinKeyboard,&darwinEvents[i]);
+  DarwinPokeEQ();
+}
+
+/* Send the appropriate number of button 4 / 5 clicks to emulate scroll wheel */
+void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y) {
+  int i;
+  int ev_button = count > 0.0f ? 4 : 5;
+  int valuators[2] = {pointer_x, pointer_y};
+
+  for (count = fabs(count); count > 0.0; count = count - 1.0f) {
+    int num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonPress, ev_button, 
+				      POINTER_ABSOLUTE, 0, 2, valuators);
+    for(i=0; i<num_events; i++) mieqEnqueue(darwinPointer,&darwinEvents[i]);
+    num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonRelease, ev_button, 
+				      POINTER_ABSOLUTE, 0, 2, valuators);
+    for(i=0; i<num_events; i++) mieqEnqueue(darwinPointer,&darwinEvents[i]);
+  }
+  DarwinPokeEQ();
+}
+
+/* Send the appropriate KeyPress/KeyRelease events to GetKeyboardEvents to
+   reflect changing modifier flags (alt, control, meta, etc) */
+void DarwinUpdateModKeys(int flags) {
+  DarwinUpdateModifiers(KeyRelease, old_flags & ~flags);
+  DarwinUpdateModifiers(KeyPress, ~old_flags & flags);
+  old_flags = flags;
+}
diff --git a/hw/xquartz/darwinKeyboard.c b/hw/xquartz/darwinKeyboard.c
new file mode 100644
index 0000000..1c83cbc
--- /dev/null
+++ b/hw/xquartz/darwinKeyboard.c
@@ -0,0 +1,1009 @@
+//=============================================================================
+//
+// Keyboard support for the Darwin X Server
+//
+// Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
+// Copyright (c) 2003 Apple Computer, Inc. All Rights Reserved.
+// Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
+//
+// The code to parse the Darwin keymap is derived from dumpkeymap.c
+// by Eric Sunshine, which includes the following copyright:
+//
+// Copyright (C) 1999,2000 by Eric Sunshine <sunshine at sunshineco.com>
+// All rights reserved.
+//
+//-----------------------------------------------------------------------------
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+//   1. Redistributions of source code must retain the above copyright
+//      notice, this list of conditions and the following disclaimer.
+//   2. Redistributions in binary form must reproduce the above copyright
+//      notice, this list of conditions and the following disclaimer in the
+//      documentation and/or other materials provided with the distribution.
+//   3. The name of the author may not be used to endorse or promote products
+//      derived from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+// NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+//=============================================================================
+
+
+/*
+===========================================================================
+
+ An X keyCode must be in the range XkbMinLegalKeyCode (8) to
+ XkbMaxLegalKeyCode(255).
+
+ The keyCodes we get from the kernel range from 0 to 127, so we need to
+ offset the range before passing the keyCode to X.
+
+ An X KeySym is an extended ascii code that is device independent.
+
+ The modifier map is accessed by the keyCode, but the normal map is
+ accessed by keyCode - MIN_KEYCODE.  Sigh.
+
+===========================================================================
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+// Define this to get a diagnostic output to stderr which is helpful
+// in determining how the X server is interpreting the Darwin keymap.
+// #define DUMP_DARWIN_KEYMAP
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <IOKit/hidsystem/event_status_driver.h>
+#include <IOKit/hidsystem/ev_keymap.h>
+#include <architecture/byte_order.h>  // For the NXSwap*
+#include "darwin.h"
+#include "darwinKeyboard.h"
+
+#ifdef NDEBUG
+#undef NDEBUG
+#include <assert.h>
+#define NDEBUG 1
+#else
+#include <assert.h>
+#endif
+
+#define AltMask         Mod1Mask
+#define MetaMask        Mod2Mask
+#define FunctionMask    Mod3Mask
+
+#define UK(a)           NoSymbol    // unknown symbol
+
+static KeySym const next_to_x[256] = {
+	NoSymbol,	NoSymbol,	NoSymbol,	XK_KP_Enter,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+	XK_BackSpace,	XK_Tab,		XK_Linefeed,	NoSymbol,
+	NoSymbol,	XK_Return,	NoSymbol,	NoSymbol,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+	NoSymbol,	NoSymbol,	NoSymbol,	XK_Escape,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+	XK_space,	XK_exclam,	XK_quotedbl,	XK_numbersign,
+	XK_dollar,	XK_percent,	XK_ampersand,	XK_apostrophe,
+	XK_parenleft,	XK_parenright,	XK_asterisk,	XK_plus,
+	XK_comma,	XK_minus,	XK_period,	XK_slash,
+	XK_0,		XK_1,		XK_2,		XK_3,
+	XK_4,		XK_5,		XK_6,		XK_7,
+	XK_8,		XK_9,		XK_colon,	XK_semicolon,
+	XK_less,	XK_equal,	XK_greater,	XK_question,
+	XK_at,		XK_A,		XK_B,		XK_C,
+	XK_D,		XK_E,		XK_F,		XK_G,
+	XK_H,		XK_I,		XK_J,		XK_K,
+	XK_L,		XK_M,		XK_N,		XK_O,
+	XK_P,		XK_Q,		XK_R,		XK_S,
+	XK_T,		XK_U,		XK_V,		XK_W,
+	XK_X,		XK_Y,		XK_Z,		XK_bracketleft,
+	XK_backslash,	XK_bracketright,XK_asciicircum,	XK_underscore,
+	XK_grave,	XK_a,		XK_b,		XK_c,
+	XK_d,		XK_e,		XK_f,		XK_g,
+	XK_h,		XK_i,		XK_j,		XK_k,
+	XK_l,		XK_m,		XK_n,		XK_o,
+	XK_p,		XK_q,		XK_r,		XK_s,
+	XK_t,		XK_u,		XK_v,		XK_w,
+	XK_x,		XK_y,		XK_z,		XK_braceleft,
+	XK_bar,		XK_braceright,	XK_asciitilde,	XK_BackSpace,
+// 128
+	NoSymbol,	XK_Agrave,	XK_Aacute,	XK_Acircumflex,
+	XK_Atilde,	XK_Adiaeresis,	XK_Aring,	XK_Ccedilla,
+	XK_Egrave,	XK_Eacute,	XK_Ecircumflex,	XK_Ediaeresis,
+	XK_Igrave,	XK_Iacute,	XK_Icircumflex,	XK_Idiaeresis,
+// 144
+	XK_ETH,		XK_Ntilde,	XK_Ograve,	XK_Oacute,
+	XK_Ocircumflex,	XK_Otilde,	XK_Odiaeresis,	XK_Ugrave,
+	XK_Uacute,	XK_Ucircumflex,	XK_Udiaeresis,	XK_Yacute,
+	XK_THORN,	XK_mu,		XK_multiply,	XK_division,
+// 160
+	XK_copyright,	XK_exclamdown,	XK_cent,	XK_sterling,
+	UK(fraction),	XK_yen,		UK(fhook),	XK_section,
+	XK_currency,	XK_rightsinglequotemark,
+					XK_leftdoublequotemark,
+							XK_guillemotleft,
+	XK_leftanglebracket,
+			XK_rightanglebracket,
+					UK(filigature),	UK(flligature),
+// 176
+	XK_registered,	XK_endash,	XK_dagger,	XK_doubledagger,
+	XK_periodcentered,XK_brokenbar,	XK_paragraph,	UK(bullet),
+	XK_singlelowquotemark,
+			XK_doublelowquotemark,
+					XK_rightdoublequotemark,
+							XK_guillemotright,
+	XK_ellipsis,	UK(permille),	XK_notsign,	XK_questiondown,
+// 192
+	XK_onesuperior,	XK_dead_grave,	XK_dead_acute,	XK_dead_circumflex,
+	XK_dead_tilde,	XK_dead_macron,	XK_dead_breve,	XK_dead_abovedot,
+	XK_dead_diaeresis,
+			XK_twosuperior,	XK_dead_abovering,
+							XK_dead_cedilla,
+	XK_threesuperior,
+			XK_dead_doubleacute,
+					XK_dead_ogonek,	XK_dead_caron,
+// 208
+	XK_emdash,	XK_plusminus,	XK_onequarter,	XK_onehalf,
+	XK_threequarters,
+			XK_agrave,	XK_aacute,	XK_acircumflex,
+	XK_atilde,	XK_adiaeresis,	XK_aring,	XK_ccedilla,
+	XK_egrave,	XK_eacute,	XK_ecircumflex,	XK_ediaeresis,
+// 224
+	XK_igrave,	XK_AE,		XK_iacute,	XK_ordfeminine,
+	XK_icircumflex,	XK_idiaeresis,	XK_eth,		XK_ntilde,
+	XK_Lstroke,	XK_Ooblique,	XK_OE,		XK_masculine,
+	XK_ograve,	XK_oacute,	XK_ocircumflex, XK_otilde,
+// 240
+	XK_odiaeresis,	XK_ae,		XK_ugrave,	XK_uacute,
+	XK_ucircumflex,	XK_idotless,	XK_udiaeresis,	XK_ygrave,
+	XK_lstroke,	XK_ooblique,	XK_oe,		XK_ssharp,
+	XK_thorn,	XK_ydiaeresis,	NoSymbol,	NoSymbol,
+  };
+
+#define MIN_SYMBOL      0xAC
+static KeySym const symbol_to_x[] = {
+    XK_Left,        XK_Up,          XK_Right,      XK_Down
+  };
+static int const NUM_SYMBOL = sizeof(symbol_to_x) / sizeof(symbol_to_x[0]);
+
+#define MIN_FUNCKEY     0x20
+static KeySym const funckey_to_x[] = {
+    XK_F1,          XK_F2,          XK_F3,          XK_F4,
+    XK_F5,          XK_F6,          XK_F7,          XK_F8,
+    XK_F9,          XK_F10,         XK_F11,         XK_F12,
+    XK_Insert,      XK_Delete,      XK_Home,        XK_End,
+    XK_Page_Up,     XK_Page_Down,   XK_F13,         XK_F14,
+    XK_F15
+  };
+static int const NUM_FUNCKEY = sizeof(funckey_to_x) / sizeof(funckey_to_x[0]);
+
+typedef struct {
+    KeySym      normalSym;
+    KeySym      keypadSym;
+} darwinKeyPad_t;
+
+static darwinKeyPad_t const normal_to_keypad[] = {
+    { XK_0,         XK_KP_0 },
+    { XK_1,         XK_KP_1 },
+    { XK_2,         XK_KP_2 },
+    { XK_3,         XK_KP_3 },
+    { XK_4,         XK_KP_4 },
+    { XK_5,         XK_KP_5 },
+    { XK_6,         XK_KP_6 },
+    { XK_7,         XK_KP_7 },
+    { XK_8,         XK_KP_8 },
+    { XK_9,         XK_KP_9 },
+    { XK_equal,     XK_KP_Equal },
+    { XK_asterisk,  XK_KP_Multiply },
+    { XK_plus,      XK_KP_Add },
+    { XK_comma,     XK_KP_Separator },
+    { XK_minus,     XK_KP_Subtract },
+    { XK_period,    XK_KP_Decimal },
+    { XK_slash,     XK_KP_Divide }
+};
+static int const NUM_KEYPAD = sizeof(normal_to_keypad) / sizeof(normal_to_keypad[0]);
+
+static void DarwinChangeKeyboardControl( DeviceIntPtr device, KeybdCtrl *ctrl )
+{
+    // keyclick, bell volume / pitch, autorepead, LED's
+}
+
+darwinKeyboardInfo keyInfo;
+static FILE *fref = NULL;
+static char *inBuffer = NULL;
+
+//-----------------------------------------------------------------------------
+// Data Stream Object
+//      Can be configured to treat embedded "numbers" as being composed of
+//      either 1, 2, or 4 bytes, apiece.
+//-----------------------------------------------------------------------------
+typedef struct _DataStream {
+    unsigned char const *data;
+    unsigned char const *data_end;
+    short number_size;  // Size in bytes of a "number" in the stream.
+} DataStream;
+
+static DataStream* new_data_stream(unsigned char const* data, int size) {
+    DataStream* s = (DataStream*)xalloc( sizeof(DataStream) );
+    if(s) {
+        s->data = data;
+        s->data_end = data + size;
+        s->number_size = 1; // Default to byte-sized numbers.
+    }
+    return s;
+}
+
+static void destroy_data_stream(DataStream* s) {
+    xfree(s);
+}
+
+static unsigned char get_byte(DataStream* s) {
+    assert(s->data + 1 <= s->data_end);
+    return *s->data++;
+}
+
+static short get_word(DataStream* s) {
+    short hi, lo;
+    assert(s->data + 2 <= s->data_end);
+    hi = *s->data++;
+    lo = *s->data++;
+    return ((hi << 8) | lo);
+}
+
+static int get_dword(DataStream* s) {
+    int b1, b2, b3, b4;
+    assert(s->data + 4 <= s->data_end);
+    b4 = *s->data++;
+    b3 = *s->data++;
+    b2 = *s->data++;
+    b1 = *s->data++;
+    return ((b4 << 24) | (b3 << 16) | (b2 << 8) | b1);
+}
+
+static int get_number(DataStream* s) {
+    switch (s->number_size) {
+        case 4:  return get_dword(s);
+        case 2:  return get_word(s);
+        default: return get_byte(s);
+    }
+}
+
+//-----------------------------------------------------------------------------
+// Utility functions to help parse Darwin keymap
+//-----------------------------------------------------------------------------
+
+/*
+ * bits_set
+ *      Calculate number of bits set in the modifier mask.
+ */
+static short bits_set(short mask) {
+    short n = 0;
+
+    for ( ; mask != 0; mask >>= 1)
+        if ((mask & 0x01) != 0)
+            n++;
+    return n;
+}
+
+/*
+ * parse_next_char_code
+ *      Read the next character code from the Darwin keymapping
+ *      and write it to the X keymap.
+ */
+static void parse_next_char_code(DataStream *s, KeySym *k) {
+    const short charSet = get_number(s);
+    const short charCode = get_number(s);
+
+    if (charSet == 0) {                 // ascii character
+        if (charCode >= 0 && charCode < 256)
+            *k = next_to_x[charCode];
+    } else if (charSet == 0x01) {       // symbol character
+        if (charCode >= MIN_SYMBOL &&
+            charCode <= MIN_SYMBOL + NUM_SYMBOL)
+            *k = symbol_to_x[charCode - MIN_SYMBOL];
+    } else if (charSet == 0xFE) {       // function key
+        if (charCode >= MIN_FUNCKEY &&
+            charCode <= MIN_FUNCKEY + NUM_FUNCKEY)
+            *k = funckey_to_x[charCode - MIN_FUNCKEY];
+    }
+}
+
+
+/*
+ * DarwinReadKeymapFile
+ *      Read the appropriate keymapping from a keymapping file.
+ */
+Bool DarwinReadKeymapFile(NXKeyMapping *keyMap) {
+    struct stat         st;
+    NXEventSystemDevice info[20];
+    int                 interface = 0, handler_id = 0;
+    int                 map_interface, map_handler_id, map_size = 0;
+    unsigned int        i, size;
+    int                 *bufferEnd;
+    union km_tag {
+        int             *intP;
+        char            *charP;
+    } km;
+
+    fref = fopen( darwinKeymapFile, "rb" );
+    if (fref == NULL) {
+        ErrorF("Unable to open keymapping file '%s' (errno %d).\n",
+               darwinKeymapFile, errno);
+        return FALSE;
+    }
+    if (fstat(fileno(fref), &st) == -1) {
+        ErrorF("Could not stat keymapping file '%s' (errno %d).\n",
+               darwinKeymapFile, errno);
+        return FALSE;
+    }
+
+    // check to make sure we don't crash later
+    if (st.st_size <= 16*sizeof(int)) {
+        ErrorF("Keymapping file '%s' is invalid (too small).\n",
+               darwinKeymapFile);
+        return FALSE;
+    }
+
+    inBuffer = (char*) xalloc( st.st_size );
+    bufferEnd = (int *) (inBuffer + st.st_size);
+    if (fread(inBuffer, st.st_size, 1, fref) != 1) {
+        ErrorF("Could not read %qd bytes from keymapping file '%s' (errno %d).\n",
+               st.st_size, darwinKeymapFile, errno);
+        return FALSE;
+    }
+
+    if (strncmp( inBuffer, "KYM1", 4 ) == 0) {
+        // Magic number OK.
+    } else if (strncmp( inBuffer, "KYMP", 4 ) == 0) {
+        ErrorF("Keymapping file '%s' is intended for use with the original NeXT keyboards and cannot be used by XDarwin.\n", darwinKeymapFile);
+        return FALSE;
+    } else {
+        ErrorF("Keymapping file '%s' has a bad magic number and cannot be used by XDarwin.\n", darwinKeymapFile);
+        return FALSE;
+    }
+
+    // find the keyboard interface and handler id
+    size = sizeof( info ) / sizeof( int );
+    if (!NXEventSystemInfo( darwinParamConnect, NX_EVS_DEVICE_INFO,
+                            (NXEventSystemInfoType) info, &size )) {
+        ErrorF("Error reading event status driver info.\n");
+        return FALSE;
+    }
+
+    size = size * sizeof( int ) / sizeof( info[0] );
+    for( i = 0; i < size; i++) {
+        if (info[i].dev_type == NX_EVS_DEVICE_TYPE_KEYBOARD) {
+            Bool hasInterface = FALSE;
+            Bool hasMatch = FALSE;
+
+            interface = info[i].interface;
+            handler_id = info[i].id;
+
+            // Find an appropriate keymapping:
+            // The first time we try to match both interface and handler_id.
+            // If we can't match both, we take the first match for interface.
+
+            do {
+                km.charP = inBuffer;
+                km.intP++;
+                while (km.intP+3 < bufferEnd) {
+                    map_interface = NXSwapBigIntToHost(*(km.intP++));
+                    map_handler_id = NXSwapBigIntToHost(*(km.intP++));
+                    map_size = NXSwapBigIntToHost(*(km.intP++));
+                    if (map_interface == interface) {
+                        if (map_handler_id == handler_id || hasInterface) {
+                            hasMatch = TRUE;
+                            break;
+                        } else {
+                            hasInterface = TRUE;
+                        }
+                    }
+                    km.charP += map_size;
+                }
+            } while (hasInterface && !hasMatch);
+
+            if (hasMatch) {
+                // fill in NXKeyMapping structure
+                keyMap->size = map_size;
+                keyMap->mapping = (char*) xalloc(map_size);
+                memcpy(keyMap->mapping, km.charP, map_size);
+                return TRUE;
+            }
+        } // if dev_id == keyboard device
+    } // foreach info struct
+
+    // The keymapping file didn't match any of the info structs
+    // returned by NXEventSystemInfo.
+    ErrorF("Keymapping file '%s' did not contain appropriate keyboard interface.\n", darwinKeymapFile);
+    return FALSE;
+}
+
+
+/*
+ * DarwinParseNXKeyMapping
+ */
+Bool DarwinParseNXKeyMapping(darwinKeyboardInfo  *info) {
+    KeySym              *k;
+    int                 i;
+    short               numMods, numKeys, numPadKeys = 0;
+    Bool                haveKeymap = FALSE;
+    NXKeyMapping        keyMap;
+    DataStream          *keyMapStream;
+    unsigned char const *numPadStart = 0;
+
+    if (darwinKeymapFile) {
+        haveKeymap = DarwinReadKeymapFile(&keyMap);
+        if (fref)
+            fclose(fref);
+        if (inBuffer)
+            xfree(inBuffer);
+        if (!haveKeymap) {
+            ErrorF("Reverting to kernel keymapping.\n");
+        }
+    }
+
+    if (!haveKeymap) {
+        // get the Darwin keyboard map
+        keyMap.size = NXKeyMappingLength( darwinParamConnect );
+        keyMap.mapping = (char*) xalloc( keyMap.size );
+        if (!NXGetKeyMapping( darwinParamConnect, &keyMap )) {
+            return FALSE;
+        }
+    }
+
+    keyMapStream = new_data_stream( (unsigned char const*)keyMap.mapping,
+                                    keyMap.size );
+
+    // check the type of map
+    if (get_word(keyMapStream)) {
+        keyMapStream->number_size = 2;
+        ErrorF("Current 16-bit keymapping may not be interpreted correctly.\n");
+    }
+
+    // Insert X modifier KeySyms into the keyboard map.
+    numMods = get_number(keyMapStream);
+    while (numMods-- > 0) {
+        int             left = 1;               // first keycode is left
+        short const     charCode = get_number(keyMapStream);
+        short           numKeyCodes = get_number(keyMapStream);
+
+        // This is just a marker, not a real modifier.
+        // Store numeric keypad keys for later.
+        if (charCode == NX_MODIFIERKEY_NUMERICPAD) {
+            numPadStart = keyMapStream->data;
+            numPadKeys = numKeyCodes;
+        }
+
+        while (numKeyCodes-- > 0) {
+            const short keyCode = get_number(keyMapStream);
+            if (charCode != NX_MODIFIERKEY_NUMERICPAD) {
+                switch (charCode) {
+                    case NX_MODIFIERKEY_ALPHALOCK:
+                        info->keyMap[keyCode * GLYPHS_PER_KEY] = XK_Caps_Lock;
+                        break;
+                    case NX_MODIFIERKEY_SHIFT:
+                        info->keyMap[keyCode * GLYPHS_PER_KEY] =
+                                (left ? XK_Shift_L : XK_Shift_R);
+                        break;
+                    case NX_MODIFIERKEY_CONTROL:
+                        info->keyMap[keyCode * GLYPHS_PER_KEY] =
+                                (left ? XK_Control_L : XK_Control_R);
+                        break;
+                    case NX_MODIFIERKEY_ALTERNATE:
+                        info->keyMap[keyCode * GLYPHS_PER_KEY] = XK_Mode_switch;
+                                // (left ? XK_Alt_L : XK_Alt_R);
+                        break;
+                    case NX_MODIFIERKEY_COMMAND:
+                        info->keyMap[keyCode * GLYPHS_PER_KEY] =
+                                (left ? XK_Meta_L : XK_Meta_R);
+                        break;
+                    case NX_MODIFIERKEY_SECONDARYFN:
+                        info->keyMap[keyCode * GLYPHS_PER_KEY] =
+                                (left ? XK_Control_L : XK_Control_R);
+                        break;
+                    case NX_MODIFIERKEY_HELP:
+                        // Help is not an X11 modifier; treat as normal key
+                        info->keyMap[keyCode * GLYPHS_PER_KEY] = XK_Help;
+                        break;
+                }
+            }
+            left = 0;
+        }
+    }
+
+    // Convert the Darwin keyboard mapping to an X keyboard map.
+    // A key can have a different character code for each combination of
+    // modifiers. We currently ignore all modifier combinations except
+    // those with Shift, AlphaLock, and Alt.
+    numKeys = get_number(keyMapStream);
+    for (i = 0, k = info->keyMap; i < numKeys; i++, k += GLYPHS_PER_KEY) {
+        short const     charGenMask = get_number(keyMapStream);
+        if (charGenMask != 0xFF) {              // is key bound?
+            short       numKeyCodes = 1 << bits_set(charGenMask);
+
+            // Record unmodified case
+            parse_next_char_code( keyMapStream, k );
+            numKeyCodes--;
+
+            // If AlphaLock and Shift modifiers produce different codes,
+            // we record the Shift case since X handles AlphaLock.
+            if (charGenMask & 0x01) {       // AlphaLock
+                parse_next_char_code( keyMapStream, k+1 );
+                numKeyCodes--;
+            }
+
+            if (charGenMask & 0x02) {       // Shift
+                parse_next_char_code( keyMapStream, k+1 );
+                numKeyCodes--;
+
+                if (charGenMask & 0x01) {   // Shift-AlphaLock
+                    get_number(keyMapStream); get_number(keyMapStream);
+                    numKeyCodes--;
+                }
+            }
+
+            // Skip the Control cases
+            if (charGenMask & 0x04) {       // Control
+                get_number(keyMapStream); get_number(keyMapStream);
+                numKeyCodes--;
+
+                if (charGenMask & 0x01) {   // Control-AlphaLock
+                    get_number(keyMapStream); get_number(keyMapStream);
+                    numKeyCodes--;
+                }
+
+                if (charGenMask & 0x02) {   // Control-Shift
+                    get_number(keyMapStream); get_number(keyMapStream);
+                    numKeyCodes--;
+
+                    if (charGenMask & 0x01) {   // Shift-Control-AlphaLock
+                        get_number(keyMapStream); get_number(keyMapStream);
+                        numKeyCodes--;
+                    }
+                }
+            }
+
+            // Process Alt cases
+            if (charGenMask & 0x08) {       // Alt
+                parse_next_char_code( keyMapStream, k+2 );
+                numKeyCodes--;
+
+                if (charGenMask & 0x01) {   // Alt-AlphaLock
+                    parse_next_char_code( keyMapStream, k+3 );
+                    numKeyCodes--;
+                }
+
+                if (charGenMask & 0x02) {   // Alt-Shift
+                    parse_next_char_code( keyMapStream, k+3 );
+                    numKeyCodes--;
+
+                    if (charGenMask & 0x01) {   // Alt-Shift-AlphaLock
+                        get_number(keyMapStream); get_number(keyMapStream);
+                        numKeyCodes--;
+                    }
+                }
+            }
+
+            while (numKeyCodes-- > 0) {
+                get_number(keyMapStream); get_number(keyMapStream);
+            }
+
+            if (k[3] == k[2]) k[3] = NoSymbol;
+            if (k[2] == k[1]) k[2] = NoSymbol;
+            if (k[1] == k[0]) k[1] = NoSymbol;
+            if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol;
+        }
+    }
+
+    // Now we have to go back through the list of keycodes that are on the
+    // numeric keypad and update the X keymap.
+    keyMapStream->data = numPadStart;
+    while(numPadKeys-- > 0) {
+        const short keyCode = get_number(keyMapStream);
+        k = &info->keyMap[keyCode * GLYPHS_PER_KEY];
+        for (i = 0; i < NUM_KEYPAD; i++) {
+            if (*k == normal_to_keypad[i].normalSym) {
+                k[0] = normal_to_keypad[i].keypadSym;
+                break;
+            }
+        }
+    }
+
+    // free Darwin keyboard map
+    destroy_data_stream( keyMapStream );
+    xfree( keyMap.mapping );
+
+    return TRUE;
+}
+
+/*
+ * DarwinBuildModifierMaps
+ *      Use the keyMap field of keyboard info structure to populate
+ *      the modMap and modifierKeycodes fields.
+ */
+static void DarwinBuildModifierMaps(darwinKeyboardInfo *info) {
+    int i;
+    KeySym *k;
+
+    memset(info->modMap, NoSymbol, sizeof(info->modMap));
+    memset(info->modifierKeycodes, 0, sizeof(info->modifierKeycodes));
+
+    for (i = 0; i < NUM_KEYCODES; i++) {
+        k = info->keyMap + i * GLYPHS_PER_KEY;
+
+        switch (*k) {
+            case XK_Shift_L:
+                info->modifierKeycodes[NX_MODIFIERKEY_SHIFT][0] = i;
+                info->modMap[MIN_KEYCODE + i] = ShiftMask;
+                break;
+
+            case XK_Shift_R:
+#ifdef NX_MODIFIERKEY_RSHIFT
+                info->modifierKeycodes[NX_MODIFIERKEY_RSHIFT][0] = i;
+#else
+                info->modifierKeycodes[NX_MODIFIERKEY_SHIFT][0] = i;
+#endif
+                info->modMap[MIN_KEYCODE + i] = ShiftMask;
+                break;
+
+            case XK_Control_L:
+                info->modifierKeycodes[NX_MODIFIERKEY_CONTROL][0] = i;
+                info->modMap[MIN_KEYCODE + i] = ControlMask;
+                break;
+
+            case XK_Control_R:
+#ifdef NX_MODIFIERKEY_RCONTROL
+                info->modifierKeycodes[NX_MODIFIERKEY_RCONTROL][0] = i;
+#else
+                info->modifierKeycodes[NX_MODIFIERKEY_CONTROL][0] = i;
+#endif
+                info->modMap[MIN_KEYCODE + i] = ControlMask;
+                break;
+
+            case XK_Caps_Lock:
+                info->modifierKeycodes[NX_MODIFIERKEY_ALPHALOCK][0] = i;
+                info->modMap[MIN_KEYCODE + i] = LockMask;
+                break;
+
+            case XK_Alt_L:
+                info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
+                info->modMap[MIN_KEYCODE + i] = Mod1Mask;
+                break;
+
+            case XK_Alt_R:
+#ifdef NX_MODIFIERKEY_RALTERNATE
+                info->modifierKeycodes[NX_MODIFIERKEY_RALTERNATE][0] = i;
+#else
+                info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
+#endif
+                info->modMap[MIN_KEYCODE + i] = Mod1Mask;
+                break;
+
+            case XK_Mode_switch:
+                // Yes, this is ugly.  This needs to be cleaned up when we integrate quartzKeyboard with this code and refactor.
+#ifdef NX_MODIFIERKEY_RALTERNATE
+                info->modifierKeycodes[NX_MODIFIERKEY_RALTERNATE][0] = i;
+#endif
+                info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
+                info->modMap[MIN_KEYCODE + i] = Mod1Mask;
+                break;
+
+            case XK_Meta_L:
+                info->modifierKeycodes[NX_MODIFIERKEY_COMMAND][0] = i;
+                info->modMap[MIN_KEYCODE + i] = Mod2Mask;
+                break;
+
+            case XK_Meta_R:
+#ifdef NX_MODIFIERKEY_RCOMMAND
+                info->modifierKeycodes[NX_MODIFIERKEY_RCOMMAND][0] = i;
+#else
+                info->modifierKeycodes[NX_MODIFIERKEY_COMMAND][0] = i;
+#endif
+                info->modMap[MIN_KEYCODE + i] = Mod2Mask;
+                break;
+
+            case XK_Num_Lock:
+                info->modMap[MIN_KEYCODE + i] = Mod3Mask;
+                break;
+        }
+    }
+}
+
+/*
+ * DarwinLoadKeyboardMapping
+ *  Load the keyboard map from a file or system and convert
+ *  it to an equivalent X keyboard map and modifier map.
+ */
+static void DarwinLoadKeyboardMapping(KeySymsRec *keySyms) {
+    memset(keyInfo.keyMap, 0, sizeof(keyInfo.keyMap));
+
+    /* TODO: Clean this up
+     * DarwinModeReadSystemKeymap is in quartz/quartzKeyboard.c
+     * DarwinParseNXKeyMapping is here
+     */
+    if (!DarwinParseNXKeyMapping(&keyInfo)) {
+        DEBUG_LOG("DarwinParseNXKeyMapping returned 0... running DarwinModeReadSystemKeymap().\n");
+        if (!DarwinModeReadSystemKeymap(&keyInfo)) {
+            FatalError("Could not build a valid keymap.");
+        }
+    }
+
+    DarwinBuildModifierMaps(&keyInfo);
+
+#ifdef DUMP_DARWIN_KEYMAP
+    int i;
+    KeySym *k;
+    DEBUG_LOG("Darwin -> X converted keyboard map\n");
+    for (i = 0, k = keyInfo.keyMap; i < NX_NUMKEYCODES;
+         i++, k += GLYPHS_PER_KEY)
+    {
+        int j;
+        for (j = 0; j < GLYPHS_PER_KEY; j++) {
+            if (k[j] == NoSymbol) {
+                DEBUG_LOG("0x%02x:\tNoSym\n", i);
+            } else {
+                DEBUG_LOG("0x%02x:\t0x%lx\n", i, k[j]);
+            }
+        }
+    }
+#endif
+
+    keySyms->map        = keyInfo.keyMap;
+    keySyms->mapWidth   = GLYPHS_PER_KEY;
+    keySyms->minKeyCode = MIN_KEYCODE;
+    keySyms->maxKeyCode = MAX_KEYCODE;
+}
+
+
+/*
+ * DarwinKeyboardInit
+ *      Get the Darwin keyboard map and compute an equivalent
+ *      X keyboard map and modifier map. Set the new keyboard
+ *      device structure.
+ */
+void DarwinKeyboardInit(DeviceIntPtr pDev) {
+    KeySymsRec          keySyms;
+
+    // Open a shared connection to the HID System.
+    // Note that the Event Status Driver is really just a wrapper
+    // for a kIOHIDParamConnectType connection.
+    assert( darwinParamConnect = NXOpenEventStatus() );
+
+    DarwinLoadKeyboardMapping(&keySyms);
+    //    DarwinKeyboardReload(pDev);
+    /* Initialize the seed, so we don't reload the keymap unnecessarily
+       (and possibly overwrite xinitrc changes) */
+    DarwinModeSystemKeymapSeed();
+
+    assert( InitKeyboardDeviceStruct( (DevicePtr)pDev, &keySyms,
+                                      keyInfo.modMap, DarwinModeBell,
+                                      DarwinChangeKeyboardControl ));
+}
+
+
+/* Borrowed from dix/devices.c */
+static Bool InitModMap(register KeyClassPtr keyc) {
+    int i, j;
+    CARD8 keysPerModifier[8];
+    CARD8 mask;
+
+    //    darwinKeyc = keyc;
+    if (keyc->modifierKeyMap != NULL)
+        xfree (keyc->modifierKeyMap);
+
+    keyc->maxKeysPerModifier = 0;
+    for (i = 0; i < 8; i++)
+        keysPerModifier[i] = 0;
+    for (i = 8; i < MAP_LENGTH; i++)
+    {
+        for (j = 0, mask = 1; j < 8; j++, mask <<= 1)
+        {
+            if (mask & keyc->modifierMap[i])
+            {
+                if (++keysPerModifier[j] > keyc->maxKeysPerModifier)
+                    keyc->maxKeysPerModifier = keysPerModifier[j];
+            }
+        }
+    }
+    keyc->modifierKeyMap = (KeyCode *)xalloc(8*keyc->maxKeysPerModifier);
+    if (!keyc->modifierKeyMap && keyc->maxKeysPerModifier)
+        return (FALSE);
+    bzero((char *)keyc->modifierKeyMap, 8*(int)keyc->maxKeysPerModifier);
+    for (i = 0; i < 8; i++)
+        keysPerModifier[i] = 0;
+    for (i = 8; i < MAP_LENGTH; i++)
+    {
+        for (j = 0, mask = 1; j < 8; j++, mask <<= 1)
+        {
+            if (mask & keyc->modifierMap[i])
+            {
+                keyc->modifierKeyMap[(j*keyc->maxKeysPerModifier) +
+                         keysPerModifier[j]] = i;
+                keysPerModifier[j]++;
+            }
+        }
+    }
+    return TRUE;
+}
+
+
+void DarwinKeyboardReload(DeviceIntPtr pDev) {
+    KeySymsRec keySyms;
+
+    DarwinLoadKeyboardMapping(&keySyms);
+
+    if (SetKeySymsMap(&pDev->key->curKeySyms, &keySyms)) {
+        /* now try to update modifiers. */
+
+        memmove(pDev->key->modifierMap, keyInfo.modMap, MAP_LENGTH);
+        InitModMap(pDev->key);
+    } else DEBUG_LOG("SetKeySymsMap=0\n");
+
+    SendMappingNotify(MappingKeyboard, MIN_KEYCODE, NUM_KEYCODES, 0);
+    SendMappingNotify(MappingModifier, 0, 0, 0);
+}
+
+
+//-----------------------------------------------------------------------------
+// Modifier translation functions
+//
+// There are three different ways to specify a Mac modifier key:
+// keycode - specifies hardware key, read from keymapping
+// key     - NX_MODIFIERKEY_*, really an index
+// mask    - NX_*MASK, mask for modifier flags in event record
+// Left and right side have different keycodes but the same key and mask.
+//-----------------------------------------------------------------------------
+
+/*
+ * DarwinModifierNXKeyToNXKeycode
+ *      Return the keycode for an NX_MODIFIERKEY_* modifier.
+ *      side = 0 for left or 1 for right.
+ *      Returns 0 if key+side is not a known modifier.
+ */
+int DarwinModifierNXKeyToNXKeycode(int key, int side) {
+    return keyInfo.modifierKeycodes[key][side];
+}
+
+/*
+ * DarwinModifierNXKeycodeToNXKey
+ *      Returns -1 if keycode+side is not a modifier key
+ *      outSide may be NULL, else it gets 0 for left and 1 for right.
+ */
+int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide) {
+    int key, side;
+
+    keycode += MIN_KEYCODE;
+    // search modifierKeycodes for this keycode+side
+    for (key = 0; key < NX_NUMMODIFIERS; key++) {
+        for (side = 0; side <= 1; side++) {
+            if (keyInfo.modifierKeycodes[key][side] == keycode) break;
+        }
+    }
+    if (key == NX_NUMMODIFIERS) return -1;
+    if (outSide) *outSide = side;
+    return key;
+}
+
+/*
+ * DarwinModifierNXMaskToNXKey
+ *      Returns -1 if mask is not a known modifier mask.
+ */
+int DarwinModifierNXMaskToNXKey(int mask) {
+    switch (mask) {
+        case NX_ALPHASHIFTMASK:       return NX_MODIFIERKEY_ALPHALOCK;
+        case NX_SHIFTMASK:            return NX_MODIFIERKEY_SHIFT;
+#ifdef NX_DEVICELSHIFTKEYMASK
+        case NX_DEVICELSHIFTKEYMASK:  return NX_MODIFIERKEY_SHIFT;
+        case NX_DEVICERSHIFTKEYMASK:  return NX_MODIFIERKEY_RSHIFT;
+#endif
+        case NX_CONTROLMASK:          return NX_MODIFIERKEY_CONTROL;
+#ifdef NX_DEVICELCTLKEYMASK
+        case NX_DEVICELCTLKEYMASK:    return NX_MODIFIERKEY_CONTROL;
+        case NX_DEVICERCTLKEYMASK:    return NX_MODIFIERKEY_RCONTROL;
+#endif
+        case NX_ALTERNATEMASK:        return NX_MODIFIERKEY_ALTERNATE;
+#ifdef NX_DEVICELALTKEYMASK
+        case NX_DEVICELALTKEYMASK:    return NX_MODIFIERKEY_ALTERNATE;
+        case NX_DEVICERALTKEYMASK:    return NX_MODIFIERKEY_RALTERNATE;
+#endif
+        case NX_COMMANDMASK:          return NX_MODIFIERKEY_COMMAND;
+#ifdef NX_DEVICELCMDKEYMASK
+        case NX_DEVICELCMDKEYMASK:    return NX_MODIFIERKEY_COMMAND;
+        case NX_DEVICERCMDKEYMASK:    return NX_MODIFIERKEY_RCOMMAND;
+#endif
+        case NX_NUMERICPADMASK:       return NX_MODIFIERKEY_NUMERICPAD;
+        case NX_HELPMASK:             return NX_MODIFIERKEY_HELP;
+        case NX_SECONDARYFNMASK:      return NX_MODIFIERKEY_SECONDARYFN;
+    }
+    return -1;
+}
+
+const char *DarwinModifierNXMaskTostring(int mask) {
+    switch (mask) {
+        case NX_ALPHASHIFTMASK:      return "NX_ALPHASHIFTMASK";
+        case NX_SHIFTMASK:           return "NX_SHIFTMASK";
+        case NX_DEVICELSHIFTKEYMASK: return "NX_DEVICELSHIFTKEYMASK";
+        case NX_DEVICERSHIFTKEYMASK: return "NX_DEVICERSHIFTKEYMASK";
+        case NX_CONTROLMASK:         return "NX_CONTROLMASK";
+        case NX_DEVICELCTLKEYMASK:   return "NX_DEVICELCTLKEYMASK";
+        case NX_DEVICERCTLKEYMASK:   return "NX_DEVICERCTLKEYMASK";
+        case NX_ALTERNATEMASK:       return "NX_ALTERNATEMASK";
+        case NX_DEVICELALTKEYMASK:   return "NX_DEVICELALTKEYMASK";
+        case NX_DEVICERALTKEYMASK:   return "NX_DEVICERALTKEYMASK";
+        case NX_COMMANDMASK:         return "NX_COMMANDMASK";
+        case NX_DEVICELCMDKEYMASK:   return "NX_DEVICELCMDKEYMASK";
+        case NX_DEVICERCMDKEYMASK:   return "NX_DEVICERCMDKEYMASK";
+        case NX_NUMERICPADMASK:      return "NX_NUMERICPADMASK";
+        case NX_HELPMASK:            return "NX_HELPMASK";
+        case NX_SECONDARYFNMASK:     return "NX_SECONDARYFNMASK";
+    }
+    return "unknown mask";
+}
+
+/*
+ * DarwinModifierNXKeyToNXMask
+ *      Returns 0 if key is not a known modifier key.
+ */
+int DarwinModifierNXKeyToNXMask(int key) {
+    switch (key) {
+        case NX_MODIFIERKEY_ALPHALOCK:   return NX_ALPHASHIFTMASK;
+        case NX_MODIFIERKEY_SHIFT:       return NX_SHIFTMASK;
+#ifdef NX_MODIFIERKEY_RSHIFT
+        case NX_MODIFIERKEY_RSHIFT:      return NX_SHIFTMASK;
+#endif
+        case NX_MODIFIERKEY_CONTROL:     return NX_CONTROLMASK;
+#ifdef NX_MODIFIERKEY_RCONTROL
+        case NX_MODIFIERKEY_RCONTROL:    return NX_CONTROLMASK;
+#endif
+        case NX_MODIFIERKEY_ALTERNATE:   return NX_ALTERNATEMASK;
+#ifdef NX_MODIFIERKEY_RALTERNATE
+        case NX_MODIFIERKEY_RALTERNATE:  return NX_ALTERNATEMASK;
+#endif
+        case NX_MODIFIERKEY_COMMAND:     return NX_COMMANDMASK;
+#ifdef NX_MODIFIERKEY_RCOMMAND
+        case NX_MODIFIERKEY_RCOMMAND:    return NX_COMMANDMASK;
+#endif
+        case NX_MODIFIERKEY_NUMERICPAD:  return NX_NUMERICPADMASK;
+        case NX_MODIFIERKEY_HELP:        return NX_HELPMASK;
+        case NX_MODIFIERKEY_SECONDARYFN: return NX_SECONDARYFNMASK;
+    }
+    return 0;
+}
+
+/*
+ * DarwinModifierStringToNXKey
+ *      Returns -1 if string is not a known modifier.
+ */
+int DarwinModifierStringToNXKey(const char *str) {
+    if      (!strcasecmp(str, "shift"))   return NX_MODIFIERKEY_SHIFT;
+    else if (!strcasecmp(str, "control")) return NX_MODIFIERKEY_CONTROL;
+    else if (!strcasecmp(str, "option"))  return NX_MODIFIERKEY_ALTERNATE;
+    else if (!strcasecmp(str, "command")) return NX_MODIFIERKEY_COMMAND;
+    else if (!strcasecmp(str, "fn"))      return NX_MODIFIERKEY_SECONDARYFN;
+    else return -1;
+}
+
+/*
+ * LegalModifier
+ *      This allows the ddx layer to prevent some keys from being remapped
+ *      as modifier keys.
+ */
+Bool LegalModifier(unsigned int key, DeviceIntPtr pDev)
+{
+    return 1;
+}
diff --git a/hw/xquartz/darwinKeyboard.h b/hw/xquartz/darwinKeyboard.h
new file mode 100644
index 0000000..5cf64c7
--- /dev/null
+++ b/hw/xquartz/darwinKeyboard.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2003-2004 Torrey T. Lyons. 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
+ * 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 DARWIN_KEYBOARD_H
+#define DARWIN_KEYBOARD_H 1
+
+#include "quartzKeyboard.h"
+
+/* Provided for darwinEvents.c */
+extern darwinKeyboardInfo keyInfo;
+void DarwinKeyboardReload(DeviceIntPtr pDev);
+void DarwinKeyboardInit(DeviceIntPtr pDev);
+int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide);
+int DarwinModifierNXKeyToNXKeycode(int key, int side);
+int DarwinModifierNXKeyToNXMask(int key);
+int DarwinModifierNXMaskToNXKey(int mask);
+int DarwinModifierStringToNXKey(const char *string);
+
+/* Provided for darwin.c */
+void DarwinKeyboardInit(DeviceIntPtr pDev);
+
+#endif /* DARWIN_KEYBOARD_H */
diff --git a/hw/xquartz/darwinXinput.c b/hw/xquartz/darwinXinput.c
new file mode 100644
index 0000000..ee456a4
--- /dev/null
+++ b/hw/xquartz/darwinXinput.c
@@ -0,0 +1,312 @@
+
+/*
+ * X server support of the XINPUT extension for Darwin
+ *
+ * This is currently a copy of mi/stubs.c, but eventually this
+ * should include more complete XINPUT support.
+ */
+
+/************************************************************
+
+Copyright 1989, 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.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+			All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#define	 NEED_EVENTS
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "inputstr.h"
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "XIstubs.h"
+
+/***********************************************************************
+ *
+ * Caller:	ProcXChangeKeyboardDevice
+ *
+ * This procedure does the implementation-dependent portion of the work
+ * needed to change the keyboard device.
+ *
+ * The X keyboard device has a FocusRec.  If the device that has been 
+ * made into the new X keyboard did not have a FocusRec, 
+ * ProcXChangeKeyboardDevice will allocate one for it.
+ *
+ * If you do not want clients to be able to focus the old X keyboard
+ * device, call DeleteFocusClassDeviceStruct to free the FocusRec.
+ *
+ * If you support input devices with keys that you do not want to be 
+ * used as the X keyboard, you need to check for them here and return 
+ * a BadDevice error.
+ *
+ * The default implementation is to do nothing (assume you do want
+ * clients to be able to focus the old X keyboard).  The commented-out
+ * sample code shows what you might do if you don't want the default.
+ *
+ */
+
+int
+ChangeKeyboardDevice (old_dev, new_dev)
+    DeviceIntPtr	old_dev;
+    DeviceIntPtr	new_dev;
+    {
+    /***********************************************************************
+     DeleteFocusClassDeviceStruct(old_dev);	 * defined in xchgptr.c *
+    **********************************************************************/
+    return BadMatch;
+    }
+
+
+/***********************************************************************
+ *
+ * Caller:	ProcXChangePointerDevice
+ *
+ * This procedure does the implementation-dependent portion of the work
+ * needed to change the pointer device.
+ *
+ * The X pointer device does not have a FocusRec.  If the device that
+ * has been made into the new X pointer had a FocusRec, 
+ * ProcXChangePointerDevice will free it.
+ *
+ * If you want clients to be able to focus the old pointer device that
+ * has now become accessible through the input extension, you need to 
+ * add a FocusRec to it here.
+ *
+ * The XChangePointerDevice protocol request also allows the client
+ * to choose which axes of the new pointer device are used to move 
+ * the X cursor in the X- and Y- directions.  If the axes are different
+ * than the default ones, you need to keep track of that here.
+ *
+ * If you support input devices with valuators that you do not want to be 
+ * used as the X pointer, you need to check for them here and return a 
+ * BadDevice error.
+ *
+ * The default implementation is to do nothing (assume you don't want
+ * clients to be able to focus the old X pointer).  The commented-out
+ * sample code shows what you might do if you don't want the default.
+ *
+ */
+
+int
+ChangePointerDevice (
+    DeviceIntPtr	old_dev,
+    DeviceIntPtr	new_dev,
+    unsigned char	x,
+    unsigned char	y)
+    {
+    /***********************************************************************
+    InitFocusClassDeviceStruct(old_dev);	* allow focusing old ptr*
+
+    x_axis = x;					* keep track of new x-axis*
+    y_axis = y;					* keep track of new y-axis*
+    if (x_axis != 0 || y_axis != 1)
+	axes_changed = TRUE;			* remember axes have changed*
+    else
+	axes_changed = FALSE;
+    *************************************************************************/
+    return BadMatch;
+    }
+
+/***********************************************************************
+ *
+ * Caller:	ProcXCloseDevice
+ *
+ * Take care of implementation-dependent details of closing a device.
+ * Some implementations may actually close the device, others may just
+ * remove this clients interest in that device.
+ *
+ * The default implementation is to do nothing (assume all input devices
+ * are initialized during X server initialization and kept open).
+ *
+ */
+
+void
+CloseInputDevice (d, client)
+    DeviceIntPtr d;
+    ClientPtr client;
+    {
+    }
+
+/***********************************************************************
+ *
+ * Caller:	ProcXListInputDevices
+ *
+ * This is the implementation-dependent routine to initialize an input 
+ * device to the point that information about it can be listed.
+ * Some implementations open all input devices when the server is first
+ * initialized, and never close them.  Other implementations open only
+ * the X pointer and keyboard devices during server initialization,
+ * and only open other input devices when some client makes an
+ * XOpenDevice request.  If some other process has the device open, the
+ * server may not be able to get information about the device to list it.
+ *
+ * This procedure should be used by implementations that do not initialize
+ * all input devices at server startup.  It should do device-dependent
+ * initialization for any devices not previously initialized, and call
+ * AddInputDevice for each of those devices so that a DeviceIntRec will be 
+ * created for them.
+ *
+ * The default implementation is to do nothing (assume all input devices
+ * are initialized during X server initialization and kept open).
+ * The commented-out sample code shows what you might do if you don't want 
+ * the default.
+ *
+ */
+
+void
+AddOtherInputDevices ()
+    {
+    /**********************************************************************
+     for each uninitialized device, do something like: 
+
+    DeviceIntPtr dev;
+    DeviceProc deviceProc;
+    pointer private;
+
+    dev = (DeviceIntPtr) AddInputDevice(deviceProc, TRUE);
+    dev->public.devicePrivate = private;
+    RegisterOtherDevice(dev);
+    dev->inited = ((*dev->deviceProc)(dev, DEVICE_INIT) == Success);
+    ************************************************************************/
+
+    }
+
+/***********************************************************************
+ *
+ * Caller:	ProcXOpenDevice
+ *
+ * This is the implementation-dependent routine to open an input device.
+ * Some implementations open all input devices when the server is first
+ * initialized, and never close them.  Other implementations open only
+ * the X pointer and keyboard devices during server initialization,
+ * and only open other input devices when some client makes an
+ * XOpenDevice request.  This entry point is for the latter type of 
+ * implementation.
+ *
+ * If the physical device is not already open, do it here.  In this case,
+ * you need to keep track of the fact that one or more clients has the
+ * device open, and physically close it when the last client that has
+ * it open does an XCloseDevice.
+ *
+ * The default implementation is to do nothing (assume all input devices
+ * are opened during X server initialization and kept open).
+ *
+ */
+
+void
+OpenInputDevice (dev, client, status)
+    DeviceIntPtr dev;
+    ClientPtr client;
+    int *status;
+    {
+    }
+
+/****************************************************************************
+ *
+ * Caller:	ProcXSetDeviceMode
+ *
+ * Change the mode of an extension device.
+ * This function is used to change the mode of a device from reporting
+ * relative motion to reporting absolute positional information, and
+ * vice versa.
+ * The default implementation below is that no such devices are supported.
+ *
+ */
+
+int
+SetDeviceMode (client, dev, mode)
+    register	ClientPtr	client;
+    DeviceIntPtr dev;
+    int		mode;
+    {
+    return BadMatch;
+    }
+
+/****************************************************************************
+ *
+ * Caller:	ProcXSetDeviceValuators
+ *
+ * Set the value of valuators on an extension input device.
+ * This function is used to set the initial value of valuators on
+ * those input devices that are capable of reporting either relative
+ * motion or an absolute position, and allow an initial position to be set.
+ * The default implementation below is that no such devices are supported.
+ *
+ */
+
+int
+SetDeviceValuators (client, dev, valuators, first_valuator, num_valuators)
+    register	ClientPtr	client;
+    DeviceIntPtr dev;
+    int		*valuators;
+    int		first_valuator;
+    int		num_valuators;
+    {
+    return BadMatch;
+    }
+
+/****************************************************************************
+ *
+ * Caller:	ProcXChangeDeviceControl
+ *
+ * Change the specified device controls on an extension input device.
+ *
+ */
+
+int
+ChangeDeviceControl (client, dev, control)
+    register	ClientPtr	client;
+    DeviceIntPtr dev;
+    xDeviceCtl	*control;
+    {
+    switch (control->control)
+	{
+	case DEVICE_RESOLUTION:
+	    return (BadMatch);
+	default:
+	    return (BadMatch);
+	}
+    }
diff --git a/hw/xquartz/keysym2ucs.c b/hw/xquartz/keysym2ucs.c
new file mode 100644
index 0000000..8626ebc
--- /dev/null
+++ b/hw/xquartz/keysym2ucs.c
@@ -0,0 +1,909 @@
+/* 
+ *
+ * This module converts keysym values into the corresponding ISO 10646
+ * (UCS, Unicode) values.
+ *
+ * The array keysymtab[] contains pairs of X11 keysym values for graphical
+ * characters and the corresponding Unicode value. The function
+ * keysym2ucs() maps a keysym onto a Unicode value using a binary search,
+ * therefore keysymtab[] must remain SORTED by keysym value.
+ *
+ * The keysym -> UTF-8 conversion will hopefully one day be provided
+ * by Xlib via XmbLookupString() and should ideally not have to be
+ * done in X applications. But we are not there yet.
+ *
+ * We allow to represent any UCS character in the range U-00000000 to
+ * U-00FFFFFF by a keysym value in the range 0x01000000 to 0x01ffffff.
+ * This admittedly does not cover the entire 31-bit space of UCS, but
+ * it does cover all of the characters up to U-10FFFF, which can be
+ * represented by UTF-16, and more, and it is very unlikely that higher
+ * UCS codes will ever be assigned by ISO. So to get Unicode character
+ * U+ABCD you can directly use keysym 0x0100abcd.
+ *
+ * NOTE: The comments in the table below contain the actual character
+ * encoded in UTF-8, so for viewing and editing best use an editor in
+ * UTF-8 mode.
+ *
+ * Author: Markus G. Kuhn <mkuhn at acm.org>, University of Cambridge, April 2001
+ *
+ * Special thanks to Richard Verhoeven <river at win.tue.nl> for preparing
+ * an initial draft of the mapping table.
+ *
+ * This software is in the public domain. Share and enjoy!
+ *
+ * AUTOMATICALLY GENERATED FILE, DO NOT EDIT !!! (unicode/convmap.pl)
+ */
+
+#include "keysym2ucs.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+struct codepair {
+  unsigned short keysym;
+  unsigned short ucs;
+};
+
+const static struct codepair keysymtab[] = {
+  { 0x01a1, 0x0104 },
+  { 0x01a2, 0x02d8 },
+  { 0x01a3, 0x0141 },
+  { 0x01a5, 0x013d },
+  { 0x01a6, 0x015a },
+  { 0x01a9, 0x0160 },
+  { 0x01aa, 0x015e },
+  { 0x01ab, 0x0164 },
+  { 0x01ac, 0x0179 },
+  { 0x01ae, 0x017d },
+  { 0x01af, 0x017b },
+  { 0x01b1, 0x0105 },
+  { 0x01b2, 0x02db },
+  { 0x01b3, 0x0142 },
+  { 0x01b5, 0x013e },
+  { 0x01b6, 0x015b },
+  { 0x01b7, 0x02c7 },
+  { 0x01b9, 0x0161 },
+  { 0x01ba, 0x015f },
+  { 0x01bb, 0x0165 },
+  { 0x01bc, 0x017a },
+  { 0x01bd, 0x02dd },
+  { 0x01be, 0x017e },
+  { 0x01bf, 0x017c },
+  { 0x01c0, 0x0154 },
+  { 0x01c3, 0x0102 },
+  { 0x01c5, 0x0139 },
+  { 0x01c6, 0x0106 },
+  { 0x01c8, 0x010c },
+  { 0x01ca, 0x0118 },
+  { 0x01cc, 0x011a },
+  { 0x01cf, 0x010e },
+  { 0x01d0, 0x0110 },
+  { 0x01d1, 0x0143 },
+  { 0x01d2, 0x0147 },
+  { 0x01d5, 0x0150 },
+  { 0x01d8, 0x0158 },
+  { 0x01d9, 0x016e },
+  { 0x01db, 0x0170 },
+  { 0x01de, 0x0162 },
+  { 0x01e0, 0x0155 },
+  { 0x01e3, 0x0103 },
+  { 0x01e5, 0x013a },
+  { 0x01e6, 0x0107 },
+  { 0x01e8, 0x010d },
+  { 0x01ea, 0x0119 },
+  { 0x01ec, 0x011b },
+  { 0x01ef, 0x010f },
+  { 0x01f0, 0x0111 },
+  { 0x01f1, 0x0144 },
+  { 0x01f2, 0x0148 },
+  { 0x01f5, 0x0151 },
+  { 0x01f8, 0x0159 },
+  { 0x01f9, 0x016f },
+  { 0x01fb, 0x0171 },
+  { 0x01fe, 0x0163 },
+  { 0x01ff, 0x02d9 },
+  { 0x02a1, 0x0126 },
+  { 0x02a6, 0x0124 },
+  { 0x02a9, 0x0130 },
+  { 0x02ab, 0x011e },
+  { 0x02ac, 0x0134 },
+  { 0x02b1, 0x0127 },
+  { 0x02b6, 0x0125 },
+  { 0x02b9, 0x0131 },
+  { 0x02bb, 0x011f },
+  { 0x02bc, 0x0135 },
+  { 0x02c5, 0x010a },
+  { 0x02c6, 0x0108 },
+  { 0x02d5, 0x0120 },
+  { 0x02d8, 0x011c },
+  { 0x02dd, 0x016c },
+  { 0x02de, 0x015c },
+  { 0x02e5, 0x010b },
+  { 0x02e6, 0x0109 },
+  { 0x02f5, 0x0121 },
+  { 0x02f8, 0x011d },
+  { 0x02fd, 0x016d },
+  { 0x02fe, 0x015d },
+  { 0x03a2, 0x0138 },
+  { 0x03a3, 0x0156 },
+  { 0x03a5, 0x0128 },
+  { 0x03a6, 0x013b },
+  { 0x03aa, 0x0112 },
+  { 0x03ab, 0x0122 },
+  { 0x03ac, 0x0166 },
+  { 0x03b3, 0x0157 },
+  { 0x03b5, 0x0129 },
+  { 0x03b6, 0x013c },
+  { 0x03ba, 0x0113 },
+  { 0x03bb, 0x0123 },
+  { 0x03bc, 0x0167 },
+  { 0x03bd, 0x014a },
+  { 0x03bf, 0x014b },
+  { 0x03c0, 0x0100 },
+  { 0x03c7, 0x012e },
+  { 0x03cc, 0x0116 },
+  { 0x03cf, 0x012a },
+  { 0x03d1, 0x0145 },
+  { 0x03d2, 0x014c },
+  { 0x03d3, 0x0136 },
+  { 0x03d9, 0x0172 },
+  { 0x03dd, 0x0168 },
+  { 0x03de, 0x016a },
+  { 0x03e0, 0x0101 },
+  { 0x03e7, 0x012f },
+  { 0x03ec, 0x0117 },
+  { 0x03ef, 0x012b },
+  { 0x03f1, 0x0146 },
+  { 0x03f2, 0x014d },
+  { 0x03f3, 0x0137 },
+  { 0x03f9, 0x0173 },
+  { 0x03fd, 0x0169 },
+  { 0x03fe, 0x016b },
+  { 0x047e, 0x203e },
+  { 0x04a1, 0x3002 },
+  { 0x04a2, 0x300c },
+  { 0x04a3, 0x300d },
+  { 0x04a4, 0x3001 },
+  { 0x04a5, 0x30fb },
+  { 0x04a6, 0x30f2 },
+  { 0x04a7, 0x30a1 },
+  { 0x04a8, 0x30a3 },
+  { 0x04a9, 0x30a5 },
+  { 0x04aa, 0x30a7 },
+  { 0x04ab, 0x30a9 },
+  { 0x04ac, 0x30e3 },
+  { 0x04ad, 0x30e5 },
+  { 0x04ae, 0x30e7 },
+  { 0x04af, 0x30c3 },
+  { 0x04b0, 0x30fc },
+  { 0x04b1, 0x30a2 },
+  { 0x04b2, 0x30a4 },
+  { 0x04b3, 0x30a6 },
+  { 0x04b4, 0x30a8 },
+  { 0x04b5, 0x30aa },
+  { 0x04b6, 0x30ab },
+  { 0x04b7, 0x30ad },
+  { 0x04b8, 0x30af },
+  { 0x04b9, 0x30b1 },
+  { 0x04ba, 0x30b3 },
+  { 0x04bb, 0x30b5 },
+  { 0x04bc, 0x30b7 },
+  { 0x04bd, 0x30b9 },
+  { 0x04be, 0x30bb },
+  { 0x04bf, 0x30bd },
+  { 0x04c0, 0x30bf },
+  { 0x04c1, 0x30c1 },
+  { 0x04c2, 0x30c4 },
+  { 0x04c3, 0x30c6 },
+  { 0x04c4, 0x30c8 },
+  { 0x04c5, 0x30ca },
+  { 0x04c6, 0x30cb },
+  { 0x04c7, 0x30cc },
+  { 0x04c8, 0x30cd },
+  { 0x04c9, 0x30ce },
+  { 0x04ca, 0x30cf },
+  { 0x04cb, 0x30d2 },
+  { 0x04cc, 0x30d5 },
+  { 0x04cd, 0x30d8 },
+  { 0x04ce, 0x30db },
+  { 0x04cf, 0x30de },
+  { 0x04d0, 0x30df },
+  { 0x04d1, 0x30e0 },
+  { 0x04d2, 0x30e1 },
+  { 0x04d3, 0x30e2 },
+  { 0x04d4, 0x30e4 },
+  { 0x04d5, 0x30e6 },
+  { 0x04d6, 0x30e8 },
+  { 0x04d7, 0x30e9 },
+  { 0x04d8, 0x30ea },
+  { 0x04d9, 0x30eb },
+  { 0x04da, 0x30ec },
+  { 0x04db, 0x30ed },
+  { 0x04dc, 0x30ef },
+  { 0x04dd, 0x30f3 },
+  { 0x04de, 0x309b },
+  { 0x04df, 0x309c },
+  { 0x05ac, 0x060c },
+  { 0x05bb, 0x061b },
+  { 0x05bf, 0x061f },
+  { 0x05c1, 0x0621 },
+  { 0x05c2, 0x0622 },
+  { 0x05c3, 0x0623 },
+  { 0x05c4, 0x0624 },
+  { 0x05c5, 0x0625 },
+  { 0x05c6, 0x0626 },
+  { 0x05c7, 0x0627 },
+  { 0x05c8, 0x0628 },
+  { 0x05c9, 0x0629 },
+  { 0x05ca, 0x062a },
+  { 0x05cb, 0x062b },
+  { 0x05cc, 0x062c },
+  { 0x05cd, 0x062d },
+  { 0x05ce, 0x062e },
+  { 0x05cf, 0x062f },
+  { 0x05d0, 0x0630 },
+  { 0x05d1, 0x0631 },
+  { 0x05d2, 0x0632 },
+  { 0x05d3, 0x0633 },
+  { 0x05d4, 0x0634 },
+  { 0x05d5, 0x0635 },
+  { 0x05d6, 0x0636 },
+  { 0x05d7, 0x0637 },
+  { 0x05d8, 0x0638 },
+  { 0x05d9, 0x0639 },
+  { 0x05da, 0x063a },
+  { 0x05e0, 0x0640 },
+  { 0x05e1, 0x0641 },
+  { 0x05e2, 0x0642 },
+  { 0x05e3, 0x0643 },
+  { 0x05e4, 0x0644 },
+  { 0x05e5, 0x0645 },
+  { 0x05e6, 0x0646 },
+  { 0x05e7, 0x0647 },
+  { 0x05e8, 0x0648 },
+  { 0x05e9, 0x0649 },
+  { 0x05ea, 0x064a },
+  { 0x05eb, 0x064b },
+  { 0x05ec, 0x064c },
+  { 0x05ed, 0x064d },
+  { 0x05ee, 0x064e },
+  { 0x05ef, 0x064f },
+  { 0x05f0, 0x0650 },
+  { 0x05f1, 0x0651 },
+  { 0x05f2, 0x0652 },
+  { 0x06a1, 0x0452 },
+  { 0x06a2, 0x0453 },
+  { 0x06a3, 0x0451 },
+  { 0x06a4, 0x0454 },
+  { 0x06a5, 0x0455 },
+  { 0x06a6, 0x0456 },
+  { 0x06a7, 0x0457 },
+  { 0x06a8, 0x0458 },
+  { 0x06a9, 0x0459 },
+  { 0x06aa, 0x045a },
+  { 0x06ab, 0x045b },
+  { 0x06ac, 0x045c },
+  { 0x06ae, 0x045e },
+  { 0x06af, 0x045f },
+  { 0x06b0, 0x2116 },
+  { 0x06b1, 0x0402 },
+  { 0x06b2, 0x0403 },
+  { 0x06b3, 0x0401 },
+  { 0x06b4, 0x0404 },
+  { 0x06b5, 0x0405 },
+  { 0x06b6, 0x0406 },
+  { 0x06b7, 0x0407 },
+  { 0x06b8, 0x0408 },
+  { 0x06b9, 0x0409 },
+  { 0x06ba, 0x040a },
+  { 0x06bb, 0x040b },
+  { 0x06bc, 0x040c },
+  { 0x06be, 0x040e },
+  { 0x06bf, 0x040f },
+  { 0x06c0, 0x044e },
+  { 0x06c1, 0x0430 },
+  { 0x06c2, 0x0431 },
+  { 0x06c3, 0x0446 },
+  { 0x06c4, 0x0434 },
+  { 0x06c5, 0x0435 },
+  { 0x06c6, 0x0444 },
+  { 0x06c7, 0x0433 },
+  { 0x06c8, 0x0445 },
+  { 0x06c9, 0x0438 },
+  { 0x06ca, 0x0439 },
+  { 0x06cb, 0x043a },
+  { 0x06cc, 0x043b },
+  { 0x06cd, 0x043c },
+  { 0x06ce, 0x043d },
+  { 0x06cf, 0x043e },
+  { 0x06d0, 0x043f },
+  { 0x06d1, 0x044f },
+  { 0x06d2, 0x0440 },
+  { 0x06d3, 0x0441 },
+  { 0x06d4, 0x0442 },
+  { 0x06d5, 0x0443 },
+  { 0x06d6, 0x0436 },
+  { 0x06d7, 0x0432 },
+  { 0x06d8, 0x044c },
+  { 0x06d9, 0x044b },
+  { 0x06da, 0x0437 },
+  { 0x06db, 0x0448 },
+  { 0x06dc, 0x044d },
+  { 0x06dd, 0x0449 },
+  { 0x06de, 0x0447 },
+  { 0x06df, 0x044a },
+  { 0x06e0, 0x042e },
+  { 0x06e1, 0x0410 },
+  { 0x06e2, 0x0411 },
+  { 0x06e3, 0x0426 },
+  { 0x06e4, 0x0414 },
+  { 0x06e5, 0x0415 },
+  { 0x06e6, 0x0424 },
+  { 0x06e7, 0x0413 },
+  { 0x06e8, 0x0425 },
+  { 0x06e9, 0x0418 },
+  { 0x06ea, 0x0419 },
+  { 0x06eb, 0x041a },
+  { 0x06ec, 0x041b },
+  { 0x06ed, 0x041c },
+  { 0x06ee, 0x041d },
+  { 0x06ef, 0x041e },
+  { 0x06f0, 0x041f },
+  { 0x06f1, 0x042f },
+  { 0x06f2, 0x0420 },
+  { 0x06f3, 0x0421 },
+  { 0x06f4, 0x0422 },
+  { 0x06f5, 0x0423 },
+  { 0x06f6, 0x0416 },
+  { 0x06f7, 0x0412 },
+  { 0x06f8, 0x042c },
+  { 0x06f9, 0x042b },
+  { 0x06fa, 0x0417 },
+  { 0x06fb, 0x0428 },
+  { 0x06fc, 0x042d },
+  { 0x06fd, 0x0429 },
+  { 0x06fe, 0x0427 },
+  { 0x06ff, 0x042a },
+  { 0x07a1, 0x0386 },
+  { 0x07a2, 0x0388 },
+  { 0x07a3, 0x0389 },
+  { 0x07a4, 0x038a },
+  { 0x07a5, 0x03aa },
+  { 0x07a7, 0x038c },
+  { 0x07a8, 0x038e },
+  { 0x07a9, 0x03ab },
+  { 0x07ab, 0x038f },
+  { 0x07ae, 0x0385 },
+  { 0x07af, 0x2015 },
+  { 0x07b1, 0x03ac },
+  { 0x07b2, 0x03ad },
+  { 0x07b3, 0x03ae },
+  { 0x07b4, 0x03af },
+  { 0x07b5, 0x03ca },
+  { 0x07b6, 0x0390 },
+  { 0x07b7, 0x03cc },
+  { 0x07b8, 0x03cd },
+  { 0x07b9, 0x03cb },
+  { 0x07ba, 0x03b0 },
+  { 0x07bb, 0x03ce },
+  { 0x07c1, 0x0391 },
+  { 0x07c2, 0x0392 },
+  { 0x07c3, 0x0393 },
+  { 0x07c4, 0x0394 },
+  { 0x07c5, 0x0395 },
+  { 0x07c6, 0x0396 },
+  { 0x07c7, 0x0397 },
+  { 0x07c8, 0x0398 },
+  { 0x07c9, 0x0399 },
+  { 0x07ca, 0x039a },
+  { 0x07cb, 0x039b },
+  { 0x07cc, 0x039c },
+  { 0x07cd, 0x039d },
+  { 0x07ce, 0x039e },
+  { 0x07cf, 0x039f },
+  { 0x07d0, 0x03a0 },
+  { 0x07d1, 0x03a1 },
+  { 0x07d2, 0x03a3 },
+  { 0x07d4, 0x03a4 },
+  { 0x07d5, 0x03a5 },
+  { 0x07d6, 0x03a6 },
+  { 0x07d7, 0x03a7 },
+  { 0x07d8, 0x03a8 },
+  { 0x07d9, 0x03a9 },
+  { 0x07e1, 0x03b1 },
+  { 0x07e2, 0x03b2 },
+  { 0x07e3, 0x03b3 },
+  { 0x07e4, 0x03b4 },
+  { 0x07e5, 0x03b5 },
+  { 0x07e6, 0x03b6 },
+  { 0x07e7, 0x03b7 },
+  { 0x07e8, 0x03b8 },
+  { 0x07e9, 0x03b9 },
+  { 0x07ea, 0x03ba },
+  { 0x07eb, 0x03bb },
+  { 0x07ec, 0x03bc },
+  { 0x07ed, 0x03bd },
+  { 0x07ee, 0x03be },
+  { 0x07ef, 0x03bf },
+  { 0x07f0, 0x03c0 },
+  { 0x07f1, 0x03c1 },
+  { 0x07f2, 0x03c3 },
+  { 0x07f3, 0x03c2 },
+  { 0x07f4, 0x03c4 },
+  { 0x07f5, 0x03c5 },
+  { 0x07f6, 0x03c6 },
+  { 0x07f7, 0x03c7 },
+  { 0x07f8, 0x03c8 },
+  { 0x07f9, 0x03c9 },
+  { 0x08a1, 0x23b7 },
+  { 0x08a2, 0x250c },
+  { 0x08a3, 0x2500 },
+  { 0x08a4, 0x2320 },
+  { 0x08a5, 0x2321 },
+  { 0x08a6, 0x2502 },
+  { 0x08a7, 0x23a1 },
+  { 0x08a8, 0x23a3 },
+  { 0x08a9, 0x23a4 },
+  { 0x08aa, 0x23a6 },
+  { 0x08ab, 0x239b },
+  { 0x08ac, 0x239d },
+  { 0x08ad, 0x239e },
+  { 0x08ae, 0x23a0 },
+  { 0x08af, 0x23a8 },
+  { 0x08b0, 0x23ac },
+  { 0x08bc, 0x2264 },
+  { 0x08bd, 0x2260 },
+  { 0x08be, 0x2265 },
+  { 0x08bf, 0x222b },
+  { 0x08c0, 0x2234 },
+  { 0x08c1, 0x221d },
+  { 0x08c2, 0x221e },
+  { 0x08c5, 0x2207 },
+  { 0x08c8, 0x223c },
+  { 0x08c9, 0x2243 },
+  { 0x08cd, 0x21d4 },
+  { 0x08ce, 0x21d2 },
+  { 0x08cf, 0x2261 },
+  { 0x08d6, 0x221a },
+  { 0x08da, 0x2282 },
+  { 0x08db, 0x2283 },
+  { 0x08dc, 0x2229 },
+  { 0x08dd, 0x222a },
+  { 0x08de, 0x2227 },
+  { 0x08df, 0x2228 },
+  { 0x08ef, 0x2202 },
+  { 0x08f6, 0x0192 },
+  { 0x08fb, 0x2190 },
+  { 0x08fc, 0x2191 },
+  { 0x08fd, 0x2192 },
+  { 0x08fe, 0x2193 },
+  { 0x09e0, 0x25c6 },
+  { 0x09e1, 0x2592 },
+  { 0x09e2, 0x2409 },
+  { 0x09e3, 0x240c },
+  { 0x09e4, 0x240d },
+  { 0x09e5, 0x240a },
+  { 0x09e8, 0x2424 },
+  { 0x09e9, 0x240b },
+  { 0x09ea, 0x2518 },
+  { 0x09eb, 0x2510 },
+  { 0x09ec, 0x250c },
+  { 0x09ed, 0x2514 },
+  { 0x09ee, 0x253c },
+  { 0x09ef, 0x23ba },
+  { 0x09f0, 0x23bb },
+  { 0x09f1, 0x2500 },
+  { 0x09f2, 0x23bc },
+  { 0x09f3, 0x23bd },
+  { 0x09f4, 0x251c },
+  { 0x09f5, 0x2524 },
+  { 0x09f6, 0x2534 },
+  { 0x09f7, 0x252c },
+  { 0x09f8, 0x2502 },
+  { 0x0aa1, 0x2003 },
+  { 0x0aa2, 0x2002 },
+  { 0x0aa3, 0x2004 },
+  { 0x0aa4, 0x2005 },
+  { 0x0aa5, 0x2007 },
+  { 0x0aa6, 0x2008 },
+  { 0x0aa7, 0x2009 },
+  { 0x0aa8, 0x200a },
+  { 0x0aa9, 0x2014 },
+  { 0x0aaa, 0x2013 },
+  { 0x0aae, 0x2026 },
+  { 0x0aaf, 0x2025 },
+  { 0x0ab0, 0x2153 },
+  { 0x0ab1, 0x2154 },
+  { 0x0ab2, 0x2155 },
+  { 0x0ab3, 0x2156 },
+  { 0x0ab4, 0x2157 },
+  { 0x0ab5, 0x2158 },
+  { 0x0ab6, 0x2159 },
+  { 0x0ab7, 0x215a },
+  { 0x0ab8, 0x2105 },
+  { 0x0abb, 0x2012 },
+  { 0x0abc, 0x2329 },
+  { 0x0abe, 0x232a },
+  { 0x0ac3, 0x215b },
+  { 0x0ac4, 0x215c },
+  { 0x0ac5, 0x215d },
+  { 0x0ac6, 0x215e },
+  { 0x0ac9, 0x2122 },
+  { 0x0aca, 0x2613 },
+  { 0x0acc, 0x25c1 },
+  { 0x0acd, 0x25b7 },
+  { 0x0ace, 0x25cb },
+  { 0x0acf, 0x25af },
+  { 0x0ad0, 0x2018 },
+  { 0x0ad1, 0x2019 },
+  { 0x0ad2, 0x201c },
+  { 0x0ad3, 0x201d },
+  { 0x0ad4, 0x211e },
+  { 0x0ad6, 0x2032 },
+  { 0x0ad7, 0x2033 },
+  { 0x0ad9, 0x271d },
+  { 0x0adb, 0x25ac },
+  { 0x0adc, 0x25c0 },
+  { 0x0add, 0x25b6 },
+  { 0x0ade, 0x25cf },
+  { 0x0adf, 0x25ae },
+  { 0x0ae0, 0x25e6 },
+  { 0x0ae1, 0x25ab },
+  { 0x0ae2, 0x25ad },
+  { 0x0ae3, 0x25b3 },
+  { 0x0ae4, 0x25bd },
+  { 0x0ae5, 0x2606 },
+  { 0x0ae6, 0x2022 },
+  { 0x0ae7, 0x25aa },
+  { 0x0ae8, 0x25b2 },
+  { 0x0ae9, 0x25bc },
+  { 0x0aea, 0x261c },
+  { 0x0aeb, 0x261e },
+  { 0x0aec, 0x2663 },
+  { 0x0aed, 0x2666 },
+  { 0x0aee, 0x2665 },
+  { 0x0af0, 0x2720 },
+  { 0x0af1, 0x2020 },
+  { 0x0af2, 0x2021 },
+  { 0x0af3, 0x2713 },
+  { 0x0af4, 0x2717 },
+  { 0x0af5, 0x266f },
+  { 0x0af6, 0x266d },
+  { 0x0af7, 0x2642 },
+  { 0x0af8, 0x2640 },
+  { 0x0af9, 0x260e },
+  { 0x0afa, 0x2315 },
+  { 0x0afb, 0x2117 },
+  { 0x0afc, 0x2038 },
+  { 0x0afd, 0x201a },
+  { 0x0afe, 0x201e },
+  { 0x0ba3, 0x003c },
+  { 0x0ba6, 0x003e },
+  { 0x0ba8, 0x2228 },
+  { 0x0ba9, 0x2227 },
+  { 0x0bc0, 0x00af },
+  { 0x0bc2, 0x22a5 },
+  { 0x0bc3, 0x2229 },
+  { 0x0bc4, 0x230a },
+  { 0x0bc6, 0x005f },
+  { 0x0bca, 0x2218 },
+  { 0x0bcc, 0x2395 },
+  { 0x0bce, 0x22a4 },
+  { 0x0bcf, 0x25cb },
+  { 0x0bd3, 0x2308 },
+  { 0x0bd6, 0x222a },
+  { 0x0bd8, 0x2283 },
+  { 0x0bda, 0x2282 },
+  { 0x0bdc, 0x22a2 },
+  { 0x0bfc, 0x22a3 },
+  { 0x0cdf, 0x2017 },
+  { 0x0ce0, 0x05d0 },
+  { 0x0ce1, 0x05d1 },
+  { 0x0ce2, 0x05d2 },
+  { 0x0ce3, 0x05d3 },
+  { 0x0ce4, 0x05d4 },
+  { 0x0ce5, 0x05d5 },
+  { 0x0ce6, 0x05d6 },
+  { 0x0ce7, 0x05d7 },
+  { 0x0ce8, 0x05d8 },
+  { 0x0ce9, 0x05d9 },
+  { 0x0cea, 0x05da },
+  { 0x0ceb, 0x05db },
+  { 0x0cec, 0x05dc },
+  { 0x0ced, 0x05dd },
+  { 0x0cee, 0x05de },
+  { 0x0cef, 0x05df },
+  { 0x0cf0, 0x05e0 },
+  { 0x0cf1, 0x05e1 },
+  { 0x0cf2, 0x05e2 },
+  { 0x0cf3, 0x05e3 },
+  { 0x0cf4, 0x05e4 },
+  { 0x0cf5, 0x05e5 },
+  { 0x0cf6, 0x05e6 },
+  { 0x0cf7, 0x05e7 },
+  { 0x0cf8, 0x05e8 },
+  { 0x0cf9, 0x05e9 },
+  { 0x0cfa, 0x05ea },
+  { 0x0da1, 0x0e01 },
+  { 0x0da2, 0x0e02 },
+  { 0x0da3, 0x0e03 },
+  { 0x0da4, 0x0e04 },
+  { 0x0da5, 0x0e05 },
+  { 0x0da6, 0x0e06 },
+  { 0x0da7, 0x0e07 },
+  { 0x0da8, 0x0e08 },
+  { 0x0da9, 0x0e09 },
+  { 0x0daa, 0x0e0a },
+  { 0x0dab, 0x0e0b },
+  { 0x0dac, 0x0e0c },
+  { 0x0dad, 0x0e0d },
+  { 0x0dae, 0x0e0e },
+  { 0x0daf, 0x0e0f },
+  { 0x0db0, 0x0e10 },
+  { 0x0db1, 0x0e11 },
+  { 0x0db2, 0x0e12 },
+  { 0x0db3, 0x0e13 },
+  { 0x0db4, 0x0e14 },
+  { 0x0db5, 0x0e15 },
+  { 0x0db6, 0x0e16 },
+  { 0x0db7, 0x0e17 },
+  { 0x0db8, 0x0e18 },
+  { 0x0db9, 0x0e19 },
+  { 0x0dba, 0x0e1a },
+  { 0x0dbb, 0x0e1b },
+  { 0x0dbc, 0x0e1c },
+  { 0x0dbd, 0x0e1d },
+  { 0x0dbe, 0x0e1e },
+  { 0x0dbf, 0x0e1f },
+  { 0x0dc0, 0x0e20 },
+  { 0x0dc1, 0x0e21 },
+  { 0x0dc2, 0x0e22 },
+  { 0x0dc3, 0x0e23 },
+  { 0x0dc4, 0x0e24 },
+  { 0x0dc5, 0x0e25 },
+  { 0x0dc6, 0x0e26 },
+  { 0x0dc7, 0x0e27 },
+  { 0x0dc8, 0x0e28 },
+  { 0x0dc9, 0x0e29 },
+  { 0x0dca, 0x0e2a },
+  { 0x0dcb, 0x0e2b },
+  { 0x0dcc, 0x0e2c },
+  { 0x0dcd, 0x0e2d },
+  { 0x0dce, 0x0e2e },
+  { 0x0dcf, 0x0e2f },
+  { 0x0dd0, 0x0e30 },
+  { 0x0dd1, 0x0e31 },
+  { 0x0dd2, 0x0e32 },
+  { 0x0dd3, 0x0e33 },
+  { 0x0dd4, 0x0e34 },
+  { 0x0dd5, 0x0e35 },
+  { 0x0dd6, 0x0e36 },
+  { 0x0dd7, 0x0e37 },
+  { 0x0dd8, 0x0e38 },
+  { 0x0dd9, 0x0e39 },
+  { 0x0dda, 0x0e3a },
+  { 0x0ddf, 0x0e3f },
+  { 0x0de0, 0x0e40 },
+  { 0x0de1, 0x0e41 },
+  { 0x0de2, 0x0e42 },
+  { 0x0de3, 0x0e43 },
+  { 0x0de4, 0x0e44 },
+  { 0x0de5, 0x0e45 },
+  { 0x0de6, 0x0e46 },
+  { 0x0de7, 0x0e47 },
+  { 0x0de8, 0x0e48 },
+  { 0x0de9, 0x0e49 },
+  { 0x0dea, 0x0e4a },
+  { 0x0deb, 0x0e4b },
+  { 0x0dec, 0x0e4c },
+  { 0x0ded, 0x0e4d },
+  { 0x0df0, 0x0e50 },
+  { 0x0df1, 0x0e51 },
+  { 0x0df2, 0x0e52 },
+  { 0x0df3, 0x0e53 },
+  { 0x0df4, 0x0e54 },
+  { 0x0df5, 0x0e55 },
+  { 0x0df6, 0x0e56 },
+  { 0x0df7, 0x0e57 },
+  { 0x0df8, 0x0e58 },
+  { 0x0df9, 0x0e59 },
+  { 0x0ea1, 0x3131 },
+  { 0x0ea2, 0x3132 },
+  { 0x0ea3, 0x3133 },
+  { 0x0ea4, 0x3134 },
+  { 0x0ea5, 0x3135 },
+  { 0x0ea6, 0x3136 },
+  { 0x0ea7, 0x3137 },
+  { 0x0ea8, 0x3138 },
+  { 0x0ea9, 0x3139 },
+  { 0x0eaa, 0x313a },
+  { 0x0eab, 0x313b },
+  { 0x0eac, 0x313c },
+  { 0x0ead, 0x313d },
+  { 0x0eae, 0x313e },
+  { 0x0eaf, 0x313f },
+  { 0x0eb0, 0x3140 },
+  { 0x0eb1, 0x3141 },
+  { 0x0eb2, 0x3142 },
+  { 0x0eb3, 0x3143 },
+  { 0x0eb4, 0x3144 },
+  { 0x0eb5, 0x3145 },
+  { 0x0eb6, 0x3146 },
+  { 0x0eb7, 0x3147 },
+  { 0x0eb8, 0x3148 },
+  { 0x0eb9, 0x3149 },
+  { 0x0eba, 0x314a },
+  { 0x0ebb, 0x314b },
+  { 0x0ebc, 0x314c },
+  { 0x0ebd, 0x314d },
+  { 0x0ebe, 0x314e },
+  { 0x0ebf, 0x314f },
+  { 0x0ec0, 0x3150 },
+  { 0x0ec1, 0x3151 },
+  { 0x0ec2, 0x3152 },
+  { 0x0ec3, 0x3153 },
+  { 0x0ec4, 0x3154 },
+  { 0x0ec5, 0x3155 },
+  { 0x0ec6, 0x3156 },
+  { 0x0ec7, 0x3157 },
+  { 0x0ec8, 0x3158 },
+  { 0x0ec9, 0x3159 },
+  { 0x0eca, 0x315a },
+  { 0x0ecb, 0x315b },
+  { 0x0ecc, 0x315c },
+  { 0x0ecd, 0x315d },
+  { 0x0ece, 0x315e },
+  { 0x0ecf, 0x315f },
+  { 0x0ed0, 0x3160 },
+  { 0x0ed1, 0x3161 },
+  { 0x0ed2, 0x3162 },
+  { 0x0ed3, 0x3163 },
+  { 0x0ed4, 0x11a8 },
+  { 0x0ed5, 0x11a9 },
+  { 0x0ed6, 0x11aa },
+  { 0x0ed7, 0x11ab },
+  { 0x0ed8, 0x11ac },
+  { 0x0ed9, 0x11ad },
+  { 0x0eda, 0x11ae },
+  { 0x0edb, 0x11af },
+  { 0x0edc, 0x11b0 },
+  { 0x0edd, 0x11b1 },
+  { 0x0ede, 0x11b2 },
+  { 0x0edf, 0x11b3 },
+  { 0x0ee0, 0x11b4 },
+  { 0x0ee1, 0x11b5 },
+  { 0x0ee2, 0x11b6 },
+  { 0x0ee3, 0x11b7 },
+  { 0x0ee4, 0x11b8 },
+  { 0x0ee5, 0x11b9 },
+  { 0x0ee6, 0x11ba },
+  { 0x0ee7, 0x11bb },
+  { 0x0ee8, 0x11bc },
+  { 0x0ee9, 0x11bd },
+  { 0x0eea, 0x11be },
+  { 0x0eeb, 0x11bf },
+  { 0x0eec, 0x11c0 },
+  { 0x0eed, 0x11c1 },
+  { 0x0eee, 0x11c2 },
+  { 0x0eef, 0x316d },
+  { 0x0ef0, 0x3171 },
+  { 0x0ef1, 0x3178 },
+  { 0x0ef2, 0x317f },
+  { 0x0ef3, 0x3181 },
+  { 0x0ef4, 0x3184 },
+  { 0x0ef5, 0x3186 },
+  { 0x0ef6, 0x318d },
+  { 0x0ef7, 0x318e },
+  { 0x0ef8, 0x11eb },
+  { 0x0ef9, 0x11f0 },
+  { 0x0efa, 0x11f9 },
+  { 0x0eff, 0x20a9 },
+#if 0
+  /* FIXME: there is no keysym 0x13a4? But 0x20ac is EuroSign in both
+     keysym and Unicode */
+  { 0x13a4, 0x20ac },
+#endif
+  { 0x13bc, 0x0152 },
+  { 0x13bd, 0x0153 },
+  { 0x13be, 0x0178 },
+  { 0x20ac, 0x20ac },
+
+  /* Special function keys. */
+
+  { 0xff08, 0x0008 },			/* XK_BackSpace */
+  { 0xff09, 0x0009 },			/* XK_Tab */
+  { 0xff0a, 0x000a },			/* XK_Linefeed */
+  { 0xff0d, 0x000d },			/* XK_Return */
+  { 0xff13, 0x0013 },			/* XK_Pause */
+  { 0xff1b, 0x001b },			/* XK_Escape */
+  { 0xff50, 0x0001 },			/* XK_Home */
+  { 0xff51, 0x001c },			/* XK_Left */
+  { 0xff52, 0x001e },			/* XK_Up */
+  { 0xff53, 0x001d },			/* XK_Right */
+  { 0xff54, 0x001f },			/* XK_Down */
+  { 0xff55, 0x000b },			/* XK_Prior */
+  { 0xff56, 0x000c },			/* XK_Next */
+  { 0xff57, 0x0004 },			/* XK_End */
+  { 0xff6a, 0x0005 },			/* XK_Help */
+  { 0xffff, 0x007f },			/* XK_Delete */
+};
+
+long keysym2ucs(int keysym)
+{
+    int min = 0;
+    int max = sizeof(keysymtab) / sizeof(struct codepair) - 1;
+    int mid;
+
+    /* first check for Latin-1 characters (1:1 mapping) */
+    if ((keysym >= 0x0020 && keysym <= 0x007e) ||
+        (keysym >= 0x00a0 && keysym <= 0x00ff))
+        return keysym;
+
+    /* also check for directly encoded 24-bit UCS characters */
+    if ((keysym & 0xff000000) == 0x01000000)
+	return keysym & 0x00ffffff;
+
+    /* binary search in table */
+    while (max >= min) {
+	mid = (min + max) / 2;
+	if (keysymtab[mid].keysym < keysym)
+	    min = mid + 1;
+	else if (keysymtab[mid].keysym > keysym)
+	    max = mid - 1;
+	else {
+	    /* found it */
+	    return keysymtab[mid].ucs;
+	}
+    }
+
+    /* no matching Unicode value found */
+    return -1;
+}
+
+static int reverse_compare (const void *a, const void *b)
+{
+    const struct codepair *ca = a, *cb = b;
+
+    return ca->ucs - cb->ucs;
+}
+
+int ucs2keysym(long ucs)
+{
+    static struct codepair *reverse_keysymtab;
+
+    int min = 0;
+    int max = sizeof(keysymtab) / sizeof(struct codepair) - 1;
+    int mid;
+
+    if (reverse_keysymtab == NULL)
+    {
+	reverse_keysymtab = malloc (sizeof (keysymtab));
+	memcpy (reverse_keysymtab, keysymtab, sizeof (keysymtab));
+
+	qsort (reverse_keysymtab,
+	       sizeof (keysymtab) / sizeof (struct codepair),
+	       sizeof (struct codepair),
+	       reverse_compare);
+    }
+
+    /* first check for Latin-1 characters (1:1 mapping) */
+    if ((ucs >= 0x0020 && ucs <= 0x007e) ||
+        (ucs >= 0x00a0 && ucs <= 0x00ff))
+        return ucs;
+
+    /* binary search in table */
+    while (max >= min) {
+	mid = (min + max) / 2;
+	if (reverse_keysymtab[mid].ucs < ucs)
+	    min = mid + 1;
+	else if (reverse_keysymtab[mid].ucs > ucs)
+	    max = mid - 1;
+	else {
+	    /* found it */
+	    return reverse_keysymtab[mid].keysym;
+	}
+    }
+
+    /* finally, assume a directly encoded 24-bit UCS character */
+    return ucs | 0x01000000;
+}
diff --git a/hw/xquartz/keysym2ucs.h b/hw/xquartz/keysym2ucs.h
new file mode 100644
index 0000000..f5b7a18
--- /dev/null
+++ b/hw/xquartz/keysym2ucs.h
@@ -0,0 +1,36 @@
+/*
+ * This module converts keysym values into the corresponding ISO 10646
+ * (UCS, Unicode) values.
+ *
+ * The array keysymtab[] contains pairs of X11 keysym values for graphical
+ * characters and the corresponding Unicode value. The function
+ * keysym2ucs() maps a keysym onto a Unicode value using a binary search,
+ * therefore keysymtab[] must remain SORTED by keysym value.
+ *
+ * The keysym -> UTF-8 conversion will hopefully one day be provided
+ * by Xlib via XmbLookupString() and should ideally not have to be
+ * done in X applications. But we are not there yet.
+ *
+ * We allow to represent any UCS character in the range U-00000000 to
+ * U-00FFFFFF by a keysym value in the range 0x01000000 to 0x01ffffff.
+ * This admittedly does not cover the entire 31-bit space of UCS, but
+ * it does cover all of the characters up to U-10FFFF, which can be
+ * represented by UTF-16, and more, and it is very unlikely that higher
+ * UCS codes will ever be assigned by ISO. So to get Unicode character
+ * U+ABCD you can directly use keysym 0x0100abcd.
+ *
+ * Author: Markus G. Kuhn <mkuhn at acm.org>, University of Cambridge, April 2001
+ *
+ * Special thanks to Richard Verhoeven <river at win.tue.nl> for preparing
+ * an initial draft of the mapping table.
+ *
+ * This software is in the public domain. Share and enjoy!
+ */
+
+#ifndef KEYSYM2UCS_H
+#define KEYSYM2UCS_H 1
+
+extern long keysym2ucs(int keysym);
+extern int ucs2keysym(long ucs);
+
+#endif /* KEYSYM2UCS_H */
diff --git a/hw/xquartz/pseudoramiX.c b/hw/xquartz/pseudoramiX.c
new file mode 100644
index 0000000..b19c605
--- /dev/null
+++ b/hw/xquartz/pseudoramiX.c
@@ -0,0 +1,438 @@
+/*
+ * Minimal implementation of PanoramiX/Xinerama
+ *
+ * This is used in rootless mode where the underlying window server
+ * already provides an abstracted view of multiple screens as one
+ * large screen area.
+ *
+ * This code is largely based on panoramiX.c, which contains the
+ * following copyright notice:
+ */
+/*****************************************************************
+Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
+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.
+
+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
+DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
+BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL 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 Digital Equipment Corporation
+shall not be used in advertising or otherwise to promote the sale, use or other
+dealings in this Software without prior written authorization from Digital
+Equipment Corporation.
+******************************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "pseudoramiX.h"
+#include "extnsionst.h"
+#include "dixstruct.h"
+#include "window.h"
+#include <X11/extensions/panoramiXproto.h>
+#include "globals.h"
+
+extern int noPseudoramiXExtension;
+extern int noPanoramiXExtension;
+
+extern int ProcPanoramiXQueryVersion (ClientPtr client);
+
+static void PseudoramiXResetProc(ExtensionEntry *extEntry);
+
+static int ProcPseudoramiXQueryVersion(ClientPtr client);
+static int ProcPseudoramiXGetState(ClientPtr client);
+static int ProcPseudoramiXGetScreenCount(ClientPtr client);
+static int ProcPseudoramiXGetScreenSize(ClientPtr client);
+static int ProcPseudoramiXIsActive(ClientPtr client);
+static int ProcPseudoramiXQueryScreens(ClientPtr client);
+static int ProcPseudoramiXDispatch(ClientPtr client);
+
+static int SProcPseudoramiXQueryVersion(ClientPtr client);
+static int SProcPseudoramiXGetState(ClientPtr client);
+static int SProcPseudoramiXGetScreenCount(ClientPtr client);
+static int SProcPseudoramiXGetScreenSize(ClientPtr client);
+static int SProcPseudoramiXIsActive(ClientPtr client);
+static int SProcPseudoramiXQueryScreens(ClientPtr client);
+static int SProcPseudoramiXDispatch(ClientPtr client);
+
+
+typedef struct {
+    int x;
+    int y;
+    int w;
+    int h;
+} PseudoramiXScreenRec;
+
+static PseudoramiXScreenRec *pseudoramiXScreens = NULL;
+static int pseudoramiXScreensAllocated = 0;
+static int pseudoramiXNumScreens = 0;
+static unsigned long pseudoramiXGeneration = 0;
+
+
+// Add a PseudoramiX screen.
+// The rest of the X server will know nothing about this screen.
+// Can be called before or after extension init.
+// Screens must be re-added once per generation.
+void
+PseudoramiXAddScreen(int x, int y, int w, int h)
+{
+    PseudoramiXScreenRec *s;
+
+    if (noPseudoramiXExtension) return;
+
+    if (pseudoramiXNumScreens == pseudoramiXScreensAllocated) {
+        pseudoramiXScreensAllocated += pseudoramiXScreensAllocated + 1;
+        pseudoramiXScreens = xrealloc(pseudoramiXScreens,
+                                      pseudoramiXScreensAllocated *
+                                      sizeof(PseudoramiXScreenRec));
+    }
+
+    s = &pseudoramiXScreens[pseudoramiXNumScreens++];
+    s->x = x;
+    s->y = y;
+    s->w = w;
+    s->h = h;
+}
+
+
+// Initialize PseudoramiX.
+// Copied from PanoramiXExtensionInit
+void PseudoramiXExtensionInit(int argc, char *argv[])
+{
+    Bool	     	success = FALSE;
+    ExtensionEntry 	*extEntry;
+
+    if (noPseudoramiXExtension) return;
+
+    /* Even with only one screen we need to enable PseudoramiX to allow
+       dynamic screen configuration changes. */
+#if 0
+    if (pseudoramiXNumScreens == 1) {
+        // Only one screen - disable Xinerama extension.
+        noPseudoramiXExtension = TRUE;
+        return;
+    }
+#endif
+
+    // The server must not run the PanoramiX operations.
+    noPanoramiXExtension = TRUE;
+
+    if (pseudoramiXGeneration != serverGeneration) {
+        extEntry = AddExtension(PANORAMIX_PROTOCOL_NAME, 0, 0,
+                                ProcPseudoramiXDispatch,
+                                SProcPseudoramiXDispatch,
+                                PseudoramiXResetProc,
+                                StandardMinorOpcode);
+        if (!extEntry) {
+            ErrorF("PseudoramiXExtensionInit(): AddExtension failed\n");
+        } else {
+            pseudoramiXGeneration = serverGeneration;
+            success = TRUE;
+        }
+    }
+
+    if (!success) {
+        ErrorF("%s Extension (PseudoramiX) failed to initialize\n",
+               PANORAMIX_PROTOCOL_NAME);
+        return;
+    }
+}
+
+
+void PseudoramiXResetScreens(void)
+{
+    pseudoramiXNumScreens = 0;
+}
+
+
+static void PseudoramiXResetProc(ExtensionEntry *extEntry)
+{
+    PseudoramiXResetScreens();
+}
+
+
+// was PanoramiX
+static int ProcPseudoramiXQueryVersion(ClientPtr client)
+{
+    return ProcPanoramiXQueryVersion(client);
+}
+
+
+// was PanoramiX
+static int ProcPseudoramiXGetState(ClientPtr client)
+{
+    REQUEST(xPanoramiXGetStateReq);
+    WindowPtr pWin;
+    xPanoramiXGetStateReply rep;
+    register int n, rc;
+
+    REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+    if (rc != Success)
+	return rc;
+
+    rep.type = X_Reply;
+    rep.length = 0;
+    rep.sequenceNumber = client->sequence;
+    rep.state = !noPseudoramiXExtension;
+    if (client->swapped) {
+        swaps (&rep.sequenceNumber, n);
+        swapl (&rep.length, n);
+        swaps (&rep.state, n);
+    }
+    WriteToClient (client, sizeof (xPanoramiXGetStateReply), (char *) &rep);
+    return client->noClientException;
+}
+
+
+// was PanoramiX
+static int ProcPseudoramiXGetScreenCount(ClientPtr client)
+{
+    REQUEST(xPanoramiXGetScreenCountReq);
+    WindowPtr pWin;
+    xPanoramiXGetScreenCountReply rep;
+    register int n, rc;
+
+    REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+    if (rc != Success)
+	return rc;
+
+    rep.type = X_Reply;
+    rep.length = 0;
+    rep.sequenceNumber = client->sequence;
+    rep.ScreenCount = pseudoramiXNumScreens;
+    if (client->swapped) {
+        swaps (&rep.sequenceNumber, n);
+        swapl (&rep.length, n);
+        swaps (&rep.ScreenCount, n);
+    }
+    WriteToClient (client, sizeof(xPanoramiXGetScreenCountReply), (char *)&rep);
+    return client->noClientException;
+}
+
+
+// was PanoramiX
+static int ProcPseudoramiXGetScreenSize(ClientPtr client)
+{
+    REQUEST(xPanoramiXGetScreenSizeReq);
+    WindowPtr			pWin;
+    xPanoramiXGetScreenSizeReply	rep;
+    register int			n, rc;
+
+    REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
+    rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
+    if (rc != Success)
+	return rc;
+
+    rep.type = X_Reply;
+    rep.length = 0;
+    rep.sequenceNumber = client->sequence;
+    /* screen dimensions */
+    rep.width  = pseudoramiXScreens[stuff->screen].w;
+    // was panoramiXdataPtr[stuff->screen].width;
+    rep.height = pseudoramiXScreens[stuff->screen].h;
+    // was panoramiXdataPtr[stuff->screen].height;
+    if (client->swapped) {
+        swaps (&rep.sequenceNumber, n);
+        swapl (&rep.length, n);
+        swaps (&rep.width, n);
+        swaps (&rep.height, n);
+    }
+    WriteToClient (client, sizeof(xPanoramiXGetScreenSizeReply), (char *)&rep);
+    return client->noClientException;
+}
+
+
+// was Xinerama
+static int ProcPseudoramiXIsActive(ClientPtr client)
+{
+    /* REQUEST(xXineramaIsActiveReq); */
+    xXineramaIsActiveReply	rep;
+
+    REQUEST_SIZE_MATCH(xXineramaIsActiveReq);
+
+    rep.type = X_Reply;
+    rep.length = 0;
+    rep.sequenceNumber = client->sequence;
+    rep.state = !noPseudoramiXExtension;
+    if (client->swapped) {
+	register int n;
+	swaps (&rep.sequenceNumber, n);
+	swapl (&rep.length, n);
+	swapl (&rep.state, n);
+    }
+    WriteToClient (client, sizeof (xXineramaIsActiveReply), (char *) &rep);
+    return client->noClientException;
+}
+
+
+// was Xinerama
+static int ProcPseudoramiXQueryScreens(ClientPtr client)
+{
+    /* REQUEST(xXineramaQueryScreensReq); */
+    xXineramaQueryScreensReply	rep;
+
+    REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
+
+    rep.type = X_Reply;
+    rep.sequenceNumber = client->sequence;
+    rep.number = noPseudoramiXExtension ? 0 : pseudoramiXNumScreens;
+    rep.length = rep.number * sz_XineramaScreenInfo >> 2;
+    if (client->swapped) {
+	register int n;
+	swaps (&rep.sequenceNumber, n);
+	swapl (&rep.length, n);
+	swapl (&rep.number, n);
+    }
+    WriteToClient (client, sizeof (xXineramaQueryScreensReply), (char *) &rep);
+
+    if (!noPseudoramiXExtension) {
+	xXineramaScreenInfo scratch;
+	int i;
+
+	for(i = 0; i < pseudoramiXNumScreens; i++) {
+	    scratch.x_org  = pseudoramiXScreens[i].x;
+	    scratch.y_org  = pseudoramiXScreens[i].y;
+	    scratch.width  = pseudoramiXScreens[i].w;
+	    scratch.height = pseudoramiXScreens[i].h;
+
+	    if(client->swapped) {
+		register int n;
+		swaps (&scratch.x_org, n);
+		swaps (&scratch.y_org, n);
+		swaps (&scratch.width, n);
+		swaps (&scratch.height, n);
+	    }
+	    WriteToClient (client, sz_XineramaScreenInfo, (char *) &scratch);
+	}
+    }
+
+    return client->noClientException;
+}
+
+
+// was PanoramiX
+static int ProcPseudoramiXDispatch (ClientPtr client)
+{   REQUEST(xReq);
+    switch (stuff->data)
+    {
+	case X_PanoramiXQueryVersion:
+	     return ProcPseudoramiXQueryVersion(client);
+	case X_PanoramiXGetState:
+	     return ProcPseudoramiXGetState(client);
+	case X_PanoramiXGetScreenCount:
+	     return ProcPseudoramiXGetScreenCount(client);
+	case X_PanoramiXGetScreenSize:
+	     return ProcPseudoramiXGetScreenSize(client);
+	case X_XineramaIsActive:
+	     return ProcPseudoramiXIsActive(client);
+	case X_XineramaQueryScreens:
+	     return ProcPseudoramiXQueryScreens(client);
+    }
+    return BadRequest;
+}
+
+
+
+static int
+SProcPseudoramiXQueryVersion (ClientPtr client)
+{
+	REQUEST(xPanoramiXQueryVersionReq);
+	register int n;
+
+	swaps(&stuff->length,n);
+	REQUEST_SIZE_MATCH (xPanoramiXQueryVersionReq);
+	return ProcPseudoramiXQueryVersion(client);
+}
+
+static int
+SProcPseudoramiXGetState(ClientPtr client)
+{
+	REQUEST(xPanoramiXGetStateReq);
+	register int n;
+
+ 	swaps (&stuff->length, n);
+	REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
+	return ProcPseudoramiXGetState(client);
+}
+
+static int
+SProcPseudoramiXGetScreenCount(ClientPtr client)
+{
+	REQUEST(xPanoramiXGetScreenCountReq);
+	register int n;
+
+	swaps (&stuff->length, n);
+	REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
+	return ProcPseudoramiXGetScreenCount(client);
+}
+
+static int
+SProcPseudoramiXGetScreenSize(ClientPtr client)
+{
+	REQUEST(xPanoramiXGetScreenSizeReq);
+	register int n;
+
+	swaps (&stuff->length, n);
+	REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
+	return ProcPseudoramiXGetScreenSize(client);
+}
+
+
+static int
+SProcPseudoramiXIsActive(ClientPtr client)
+{
+	REQUEST(xXineramaIsActiveReq);
+	register int n;
+
+	swaps (&stuff->length, n);
+	REQUEST_SIZE_MATCH(xXineramaIsActiveReq);
+	return ProcPseudoramiXIsActive(client);
+}
+
+
+static int
+SProcPseudoramiXQueryScreens(ClientPtr client)
+{
+	REQUEST(xXineramaQueryScreensReq);
+	register int n;
+
+	swaps (&stuff->length, n);
+	REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
+	return ProcPseudoramiXQueryScreens(client);
+}
+
+
+static int
+SProcPseudoramiXDispatch (ClientPtr client)
+{   REQUEST(xReq);
+    switch (stuff->data)
+    {
+	case X_PanoramiXQueryVersion:
+	     return SProcPseudoramiXQueryVersion(client);
+	case X_PanoramiXGetState:
+	     return SProcPseudoramiXGetState(client);
+	case X_PanoramiXGetScreenCount:
+	     return SProcPseudoramiXGetScreenCount(client);
+	case X_PanoramiXGetScreenSize:
+	     return SProcPseudoramiXGetScreenSize(client);
+	case X_XineramaIsActive:
+	     return SProcPseudoramiXIsActive(client);
+	case X_XineramaQueryScreens:
+	     return SProcPseudoramiXQueryScreens(client);
+    }
+    return BadRequest;
+}
diff --git a/hw/xquartz/pseudoramiX.h b/hw/xquartz/pseudoramiX.h
new file mode 100644
index 0000000..df5010d
--- /dev/null
+++ b/hw/xquartz/pseudoramiX.h
@@ -0,0 +1,9 @@
+/*
+ * Minimal implementation of PanoramiX/Xinerama
+ */
+
+extern int noPseudoramiXExtension;
+
+void PseudoramiXAddScreen(int x, int y, int w, int h);
+void PseudoramiXExtensionInit(int argc, char *argv[]);
+void PseudoramiXResetScreens(void);
diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
new file mode 100644
index 0000000..2483d12
--- /dev/null
+++ b/hw/xquartz/quartz.c
@@ -0,0 +1,538 @@
+/*
+ *
+ * Quartz-specific support for the Darwin X Server
+ *
+ * Copyright (c) 2001-2004 Greg Parker and Torrey T. Lyons.
+ *                 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
+ * 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "quartzCommon.h"
+#include "quartz.h"
+#include "darwin.h"
+#include "quartzAudio.h"
+#include "pseudoramiX.h"
+#define _APPLEWM_SERVER_
+#include "X11/extensions/applewm.h"
+#include "applewmExt.h"
+
+#include "X11Application.h"
+
+// X headers
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "colormapst.h"
+#include "globals.h"
+#include "rootlessWindow.h"
+
+// System headers
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <IOKit/pwr_mgt/IOPMLib.h>
+
+#define FAKE_RANDR 1
+
+// Shared global variables for Quartz modes
+int                     quartzEventWriteFD = -1;
+int                     quartzStartClients = 1;
+int                     quartzRootless = -1;
+int                     quartzUseSysBeep = 0;
+int                     quartzUseAGL = 1;
+int                     quartzEnableKeyEquivalents = 1;
+int                     quartzServerVisible = TRUE;
+int                     quartzServerQuitting = FALSE;
+int                     quartzScreenIndex = 0;
+int                     aquaMenuBarHeight = 0;
+int                     noPseudoramiXExtension = FALSE;
+QuartzModeProcsPtr      quartzProcs = NULL;
+const char             *quartzOpenGLBundle = NULL;
+
+#if defined(RANDR) && !defined(FAKE_RANDR)
+Bool DarwinModeRandRGetInfo (ScreenPtr pScreen, Rotation *rotations) {
+  return FALSE;
+}
+
+Bool DarwinModeRandRSetConfig (ScreenPtr           pScreen,
+			       Rotation            randr,
+			       int                 rate,
+			       RRScreenSizePtr     pSize) {
+  return FALSE;
+}
+
+Bool DarwinModeRandRInit (ScreenPtr pScreen) {
+  rrScrPrivPtr    pScrPriv;
+    
+  if (!RRScreenInit (pScreen)) return FALSE;
+
+  pScrPriv = rrGetScrPriv(pScreen);
+  pScrPriv->rrGetInfo = DarwinModeRandRGetInfo;
+  pScrPriv->rrSetConfig = DarwinModeRandRSetConfig;
+  return TRUE;
+}
+#endif
+
+/*
+===========================================================================
+
+ Screen functions
+
+===========================================================================
+*/
+
+/*
+ * DarwinModeAddScreen
+ *  Do mode dependent initialization of each screen for Quartz.
+ */
+Bool DarwinModeAddScreen(
+    int index,
+    ScreenPtr pScreen)
+{
+    // allocate space for private per screen Quartz specific storage
+    QuartzScreenPtr displayInfo = xcalloc(sizeof(QuartzScreenRec), 1);
+
+    // QUARTZ_PRIV(pScreen) = displayInfo;
+    pScreen->devPrivates[quartzScreenIndex].ptr = displayInfo;
+
+    // do Quartz mode specific initialization
+    return quartzProcs->AddScreen(index, pScreen);
+}
+
+
+/*
+ * DarwinModeSetupScreen
+ *  Finalize mode specific setup of each screen.
+ */
+Bool DarwinModeSetupScreen(
+    int index,
+    ScreenPtr pScreen)
+{
+    // do Quartz mode specific setup
+    if (! quartzProcs->SetupScreen(index, pScreen))
+        return FALSE;
+
+    // setup cursor support
+    if (! quartzProcs->InitCursor(pScreen))
+        return FALSE;
+
+    return TRUE;
+}
+
+
+/*
+ * DarwinModeInitOutput
+ *  Quartz display initialization.
+ */
+void DarwinModeInitOutput(
+    int argc,
+    char **argv )
+{
+    static unsigned long generation = 0;
+
+    // Allocate private storage for each screen's Quartz specific info
+    if (generation != serverGeneration) {
+        quartzScreenIndex = AllocateScreenPrivateIndex();
+        generation = serverGeneration;
+    }
+
+    if (serverGeneration == 0) {
+        QuartzAudioInit();
+    }
+
+    if (!RegisterBlockAndWakeupHandlers(QuartzBlockHandler,
+                                        QuartzWakeupHandler,
+                                        NULL))
+    {
+        FatalError("Could not register block and wakeup handlers.");
+    }
+
+    // Do display mode specific initialization
+    quartzProcs->DisplayInit();
+
+    // Init PseudoramiX implementation of Xinerama.
+    // This should be in InitExtensions, but that causes link errors
+    // for servers that don't link in pseudoramiX.c.
+    if (!noPseudoramiXExtension) {
+        PseudoramiXExtensionInit(argc, argv);
+    }
+}
+
+
+/*
+ * DarwinModeInitInput
+ *  Inform the main thread the X server is ready to handle events.
+ */
+void DarwinModeInitInput(
+    int argc,
+    char **argv )
+{
+    X11ApplicationSetCanQuit(1);
+    X11ApplicationServerReady();
+    // Do final display mode specific initialization before handling events
+    if (quartzProcs->InitInput)
+        quartzProcs->InitInput(argc, argv);
+}
+
+
+#ifdef FAKE_RANDR
+extern char	*ConnectionInfo;
+
+static int padlength[4] = {0, 3, 2, 1};
+
+static void
+RREditConnectionInfo (ScreenPtr pScreen)
+{
+    xConnSetup	    *connSetup;
+    char	    *vendor;
+    xPixmapFormat   *formats;
+    xWindowRoot	    *root;
+    xDepth	    *depth;
+    xVisualType	    *visual;
+    int		    screen = 0;
+    int		    d;
+
+    connSetup = (xConnSetup *) ConnectionInfo;
+    vendor = (char *) connSetup + sizeof (xConnSetup);
+    formats = (xPixmapFormat *) ((char *) vendor +
+				 connSetup->nbytesVendor +
+				 padlength[connSetup->nbytesVendor & 3]);
+    root = (xWindowRoot *) ((char *) formats +
+			    sizeof (xPixmapFormat) * screenInfo.numPixmapFormats);
+    while (screen != pScreen->myNum)
+    {
+	depth = (xDepth *) ((char *) root + 
+			    sizeof (xWindowRoot));
+	for (d = 0; d < root->nDepths; d++)
+	{
+	    visual = (xVisualType *) ((char *) depth +
+				      sizeof (xDepth));
+	    depth = (xDepth *) ((char *) visual +
+				depth->nVisuals * sizeof (xVisualType));
+	}
+	root = (xWindowRoot *) ((char *) depth);
+	screen++;
+    }
+    root->pixWidth = pScreen->width;
+    root->pixHeight = pScreen->height;
+    root->mmWidth = pScreen->mmWidth;
+    root->mmHeight = pScreen->mmHeight;
+}
+#endif
+
+/*
+ * QuartzUpdateScreens
+ *  Adjust for screen arrangement changes.
+ */
+static void QuartzUpdateScreens(void)
+{
+    ScreenPtr pScreen;
+    WindowPtr pRoot;
+    int x, y, width, height, sx, sy;
+    xEvent e;
+
+    DEBUG_LOG("QuartzUpdateScreens()\n");
+    if (noPseudoramiXExtension || screenInfo.numScreens != 1)
+    {
+        /* FIXME: if not using Xinerama, we have multiple screens, and
+           to do this properly may need to add or remove screens. Which
+           isn't possible. So don't do anything. Another reason why
+           we default to running with Xinerama. */
+
+        return;
+    }
+
+    pScreen = screenInfo.screens[0];
+
+    PseudoramiXResetScreens();
+    quartzProcs->AddPseudoramiXScreens(&x, &y, &width, &height);
+
+    dixScreenOrigins[pScreen->myNum].x = x;
+    dixScreenOrigins[pScreen->myNum].y = y;
+    pScreen->mmWidth = pScreen->mmWidth * ((double) width / pScreen->width);
+    pScreen->mmHeight = pScreen->mmHeight * ((double) height / pScreen->height);
+    pScreen->width = width;
+    pScreen->height = height;
+    
+#ifndef FAKE_RANDR
+    if(!DarwinModeRandRInit(pScreen))
+      FatalError("Failed to init RandR extension.\n");
+#endif
+
+    DarwinAdjustScreenOrigins(&screenInfo);
+    quartzProcs->UpdateScreen(pScreen);
+
+    sx = dixScreenOrigins[pScreen->myNum].x + darwinMainScreenX;
+    sy = dixScreenOrigins[pScreen->myNum].y + darwinMainScreenY;
+
+    /* Adjust the root window. */
+    pRoot = WindowTable[pScreen->myNum];
+    AppleWMSetScreenOrigin(pRoot);
+    pScreen->ResizeWindow(pRoot, x - sx, y - sy, width, height, NULL);
+    miPaintWindow(pRoot, &pRoot->borderClip,  PW_BACKGROUND);
+//    QuartzIgnoreNextWarpCursor();
+    DefineInitialRootWindow(pRoot);
+
+    /* Send an event for the root reconfigure */
+    e.u.u.type = ConfigureNotify;
+    e.u.configureNotify.window = pRoot->drawable.id;
+    e.u.configureNotify.aboveSibling = None;
+    e.u.configureNotify.x = x - sx;
+    e.u.configureNotify.y = y - sy;
+    e.u.configureNotify.width = width;
+    e.u.configureNotify.height = height;
+    e.u.configureNotify.borderWidth = wBorderWidth(pRoot);
+    e.u.configureNotify.override = pRoot->overrideRedirect;
+    DeliverEvents(pRoot, &e, 1, NullWindow);
+
+#ifdef FAKE_RANDR
+    RREditConnectionInfo(pScreen);
+#endif
+}
+
+
+/*
+ * QuartzShow
+ *  Show the X server on screen. Does nothing if already shown.
+ *  Calls mode specific screen resume to restore the X clip regions
+ *  (if needed) and the X server cursor state.
+ */
+static void QuartzShow(
+    int x,      // cursor location
+    int y )
+{
+    int i;
+
+    if (!quartzServerVisible) {
+        quartzServerVisible = TRUE;
+        for (i = 0; i < screenInfo.numScreens; i++) {
+            if (screenInfo.screens[i]) {
+                quartzProcs->ResumeScreen(screenInfo.screens[i], x, y);
+            }
+        }
+    }
+}
+
+
+/*
+ * QuartzHide
+ *  Remove the X server display from the screen. Does nothing if already
+ *  hidden. Calls mode specific screen suspend to set X clip regions to
+ *  prevent drawing (if needed) and restore the Aqua cursor.
+ */
+static void QuartzHide(void)
+{
+    int i;
+
+    if (quartzServerVisible) {
+        for (i = 0; i < screenInfo.numScreens; i++) {
+            if (screenInfo.screens[i]) {
+                quartzProcs->SuspendScreen(screenInfo.screens[i]);
+            }
+        }
+    }
+    quartzServerVisible = FALSE;
+}
+
+
+/*
+ * QuartzSetRootClip
+ *  Enable or disable rendering to the X screen.
+ */
+static void QuartzSetRootClip(
+    BOOL enable)
+{
+    int i;
+
+    if (!quartzServerVisible)
+        return;
+
+    for (i = 0; i < screenInfo.numScreens; i++) {
+        if (screenInfo.screens[i]) {
+            xf86SetRootClip(screenInfo.screens[i], enable);
+        }
+    }
+}
+
+
+/*
+ * QuartzMessageServerThread
+ *  Send the X server thread a message by placing it on the event queue.
+ */
+void
+QuartzMessageServerThread(
+    int type,
+    int argc, ...)
+{
+    xEvent xe;
+    INT32 *argv;
+    int i, max_args;
+    va_list args;
+
+    memset(&xe, 0, sizeof(xe));
+    xe.u.u.type = type;
+    xe.u.clientMessage.u.l.type = type;
+
+    argv = &xe.u.clientMessage.u.l.longs0;
+    max_args = 4;
+
+    if (argc > 0 && argc <= max_args) {
+        va_start (args, argc);
+        for (i = 0; i < argc; i++)
+            argv[i] = (int) va_arg (args, int);
+        va_end (args);
+    }
+
+    DarwinEQEnqueue(&xe);
+}
+
+
+/*
+ * DarwinModeProcessEvent
+ *  Process Quartz specific events.
+ */
+void DarwinModeProcessEvent(
+    xEvent *xe)
+{
+    switch (xe->u.u.type) {
+        case kXDarwinControllerNotify:
+	  DEBUG_LOG("kXDarwinControllerNotify\n");
+            AppleWMSendEvent(AppleWMControllerNotify,
+                             AppleWMControllerNotifyMask,
+                             xe->u.clientMessage.u.l.longs0,
+                             xe->u.clientMessage.u.l.longs1);
+            break;
+
+        case kXDarwinPasteboardNotify:
+	  DEBUG_LOG("kXDarwinPasteboardNotify\n");
+            AppleWMSendEvent(AppleWMPasteboardNotify,
+                             AppleWMPasteboardNotifyMask,
+                             xe->u.clientMessage.u.l.longs0,
+                             xe->u.clientMessage.u.l.longs1);
+            break;
+
+        case kXDarwinActivate:
+	  DEBUG_LOG("kXDarwinActivate\n");
+            QuartzShow(xe->u.keyButtonPointer.rootX,
+                       xe->u.keyButtonPointer.rootY);
+            AppleWMSendEvent(AppleWMActivationNotify,
+                             AppleWMActivationNotifyMask,
+                             AppleWMIsActive, 0);
+            break;
+
+        case kXDarwinDeactivate:
+  	  DEBUG_LOG("kXDarwinDeactivate\n");
+            AppleWMSendEvent(AppleWMActivationNotify,
+                             AppleWMActivationNotifyMask,
+                             AppleWMIsInactive, 0);
+            QuartzHide();
+            break;
+
+        case kXDarwinDisplayChanged:
+	    DEBUG_LOG("kXDarwinDisplayChanged\n");
+            QuartzUpdateScreens();
+            break;
+
+        case kXDarwinWindowState:
+	  DEBUG_LOG("kXDarwinWindowState\n");
+            RootlessNativeWindowStateChanged(xe->u.clientMessage.u.l.longs0,
+		  			     xe->u.clientMessage.u.l.longs1);
+	    break;
+	  
+        case kXDarwinWindowMoved:
+	  DEBUG_LOG("kXDarwinWindowMoved\n");
+	  RootlessNativeWindowMoved ((WindowPtr)xe->u.clientMessage.u.l.longs0);
+	    break;
+
+        case kXDarwinToggleFullscreen:
+	  DEBUG_LOG("kXDarwinToggleFullscreen\n");
+#ifdef DARWIN_DDX_MISSING
+            if (quartzEnableRootless) QuartzSetFullscreen(!quartzHasRoot);
+            else if (quartzHasRoot) QuartzHide();
+            else QuartzShow();
+#else
+    //	    ErrorF("kXDarwinToggleFullscreen not implemented\n");
+#endif
+            break;
+
+        case kXDarwinSetRootless:
+#ifdef DARWIN_DDX_MISSING
+            QuartzSetRootless(xe->u.clientMessage.u.l.longs0);
+            if (!quartzEnableRootless && !quartzHasRoot) QuartzHide();
+#else
+    //	    ErrorF("kXDarwinSetRootless not implemented\n");
+#endif
+            break;
+
+        case kXDarwinSetRootClip:
+            QuartzSetRootClip((BOOL)xe->u.clientMessage.u.l.longs0);
+            break;
+
+        case kXDarwinQuit:
+            GiveUp(0);
+            break;
+
+        case kXDarwinReadPasteboard:
+            QuartzReadPasteboard();
+            break;
+
+        case kXDarwinWritePasteboard:
+            QuartzWritePasteboard();
+            break;
+
+        case kXDarwinBringAllToFront:
+  	  DEBUG_LOG("kXDarwinBringAllToFront\n");
+	    RootlessOrderAllWindows();
+            break;
+
+        default:
+            ErrorF("Unknown application defined event type %d.\n", xe->u.u.type);
+    }
+}
+
+
+/*
+ * DarwinModeGiveUp
+ *  Cleanup before X server shutdown
+ *  Release the screen and restore the Aqua cursor.
+ */
+void DarwinModeGiveUp(void)
+{
+#if 0
+// Trying to switch cursors when quitting causes deadlock
+    int i;
+
+    for (i = 0; i < screenInfo.numScreens; i++) {
+        if (screenInfo.screens[i]) {
+            QuartzSuspendXCursor(screenInfo.screens[i]);
+        }
+    }
+#endif
+
+    if (!quartzRootless)
+        quartzProcs->ReleaseScreens();
+}
diff --git a/hw/xquartz/quartz.h b/hw/xquartz/quartz.h
new file mode 100644
index 0000000..e74a108
--- /dev/null
+++ b/hw/xquartz/quartz.h
@@ -0,0 +1,127 @@
+/*
+ * quartz.h
+ *
+ * External interface of the Quartz display modes seen by the generic, mode
+ * independent parts of the Darwin X server.
+ *
+ * Copyright (c) 2001-2003 Greg Parker and Torrey T. Lyons.
+ *                 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
+ * 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 _QUARTZ_H
+#define _QUARTZ_H
+
+#include "quartzPasteboard.h"
+
+#include "screenint.h"
+#include "window.h"
+
+/*------------------------------------------
+   Quartz display mode function types
+  ------------------------------------------*/
+
+/*
+ * Display mode initialization
+ */
+typedef void (*DisplayInitProc)(void);
+typedef Bool (*AddScreenProc)(int index, ScreenPtr pScreen);
+typedef Bool (*SetupScreenProc)(int index, ScreenPtr pScreen);
+typedef void (*InitInputProc)(int argc, char **argv);
+
+/*
+ * Cursor functions
+ */
+typedef Bool (*InitCursorProc)(ScreenPtr pScreen);
+typedef void (*CursorUpdateProc)(void);
+
+/*
+ * Suspend and resume X11 activity
+ */
+typedef void (*SuspendScreenProc)(ScreenPtr pScreen);
+typedef void (*ResumeScreenProc)(ScreenPtr pScreen, int x, int y);
+typedef void (*CaptureScreensProc)(void);
+typedef void (*ReleaseScreensProc)(void);
+
+/*
+ * Screen state change support
+ */
+typedef void (*ScreenChangedProc)(void);
+typedef void (*AddPseudoramiXScreensProc)(int *x, int *y, int *width, int *height);
+typedef void (*UpdateScreenProc)(ScreenPtr pScreen);
+
+/*
+ * Rootless helper functions
+ */
+typedef Bool (*IsX11WindowProc)(void *nsWindow, int windowNumber);
+typedef void (*HideWindowsProc)(Bool hide);
+
+/*
+ * Rootless functions for optional export to GLX layer
+ */
+typedef void * (*FrameForWindowProc)(WindowPtr pWin, Bool create);
+typedef WindowPtr (*TopLevelParentProc)(WindowPtr pWindow);
+typedef Bool (*CreateSurfaceProc)
+    (ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable,
+     unsigned int client_id, unsigned int *surface_id,
+     unsigned int key[2], void (*notify) (void *arg, void *data),
+     void *notify_data);
+typedef Bool (*DestroySurfaceProc)
+    (ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable,
+     void (*notify) (void *arg, void *data), void *notify_data);
+
+/*
+ * Quartz display mode function list
+ */
+typedef struct _QuartzModeProcs {
+    DisplayInitProc DisplayInit;
+    AddScreenProc AddScreen;
+    SetupScreenProc SetupScreen;
+    InitInputProc InitInput;
+
+    InitCursorProc InitCursor;
+    CursorUpdateProc CursorUpdate;	// Not used if NULL
+
+    SuspendScreenProc SuspendScreen;
+    ResumeScreenProc ResumeScreen;
+    CaptureScreensProc CaptureScreens;	// Only called in fullscreen
+    ReleaseScreensProc ReleaseScreens;	// Only called in fullscreen
+
+    ScreenChangedProc ScreenChanged;
+    AddPseudoramiXScreensProc AddPseudoramiXScreens;
+    UpdateScreenProc UpdateScreen;
+
+    IsX11WindowProc IsX11Window;
+    HideWindowsProc HideWindows;
+
+    FrameForWindowProc FrameForWindow;
+    TopLevelParentProc TopLevelParent;
+    CreateSurfaceProc CreateSurface;
+    DestroySurfaceProc DestroySurface;
+} QuartzModeProcsRec, *QuartzModeProcsPtr;
+
+extern QuartzModeProcsPtr quartzProcs;
+extern int quartzHasRoot, quartzEnableRootless;
+
+#endif
diff --git a/hw/xquartz/quartzAudio.c b/hw/xquartz/quartzAudio.c
new file mode 100644
index 0000000..1eb099b
--- /dev/null
+++ b/hw/xquartz/quartzAudio.c
@@ -0,0 +1,346 @@
+//
+// QuartzAudio.m
+//
+// X Window bell support using CoreAudio or AppKit.
+// Greg Parker  gparker at cs.stanford.edu  19 Feb 2001
+//
+// Info about sine wave sound playback:
+// CoreAudio code derived from macosx-dev posting by Tim Wood
+//  http://www.omnigroup.com/mailman/archive/macosx-dev/2000-May/002004.html
+// Smoothing transitions between sounds
+//  http://www.wam.umd.edu/~mphoenix/dss/dss.html
+//
+/*
+ * Copyright (c) 2001 Greg Parker. 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
+ * 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "quartzCommon.h"
+#include "quartzAudio.h"
+
+#include <CoreAudio/CoreAudio.h>
+#include <pthread.h>
+
+#include "inputstr.h"
+#include <X11/extensions/XI.h>
+#include <assert.h>
+
+void NSBeep();
+
+typedef struct QuartzAudioRec {
+    double frequency;
+    double amplitude;
+
+    UInt32 curFrame;
+    UInt32 remainingFrames;
+    UInt32 totalFrames;
+    UInt32 bytesPerFrame;
+    double sampleRate;
+    UInt32 fadeLength;
+
+    UInt32 bufferByteCount;
+    Boolean playing;
+    pthread_mutex_t lock;
+
+    // used to fade out interrupted sound and avoid 'pop'
+    double prevFrequency;
+    double prevAmplitude;
+    UInt32 prevFrame; 
+} QuartzAudioRec;
+
+static AudioDeviceID quartzAudioDevice = kAudioDeviceUnknown;
+static QuartzAudioRec data;
+
+
+/*
+ * QuartzAudioEnvelope
+ *  Fade sound in and out to avoid pop.
+ *  Sounds with shorter duration will never reach full amplitude. Deal.
+ */
+static double QuartzAudioEnvelope(
+    UInt32 curFrame,
+    UInt32 totalFrames,
+    UInt32 fadeLength )
+{
+    double fadeFrames = min(fadeLength, totalFrames / 2);
+    if (fadeFrames < 1) return 0;
+
+    if (curFrame < fadeFrames) {
+        return curFrame / fadeFrames;
+    } else if (curFrame > totalFrames - fadeFrames) {
+        return (totalFrames-curFrame) / fadeFrames;
+    } else {
+        return 1.0;
+    }
+}
+
+
+/*
+ * QuartzFillBuffer
+ *  Fill this buffer with data and update the data position.
+ *  FIXME: this is ugly
+ */
+static void QuartzFillBuffer(
+    AudioBuffer *audiobuffer,
+    QuartzAudioRec *data )
+{
+    float *buffer, *b;
+    unsigned int frame, frameCount;
+    unsigned int bufferFrameCount;
+    float multiplier, v;
+    int i;
+
+    buffer = (float *)audiobuffer->mData;
+    bufferFrameCount = audiobuffer->mDataByteSize / data->bytesPerFrame;
+
+    frameCount = min(bufferFrameCount, data->remainingFrames);
+
+    // Fade out previous sine wave, if any.
+    b = buffer;
+    if (data->prevFrame) {
+        multiplier = 2*M_PI*(data->prevFrequency/data->sampleRate);
+        for (frame = 0; frame < data->fadeLength; frame++) {
+            v = data->prevAmplitude *
+                QuartzAudioEnvelope(frame+data->fadeLength,
+                                    2*data->fadeLength,
+                                    data->fadeLength) *
+                sin(multiplier * (data->prevFrame+frame));
+            for (i = 0; i < audiobuffer->mNumberChannels; i++) {
+                *b++ = v;
+            }
+        }
+        // no more prev fade
+        data->prevFrame = 0;
+
+        // adjust for space eaten by prev fade
+        buffer += audiobuffer->mNumberChannels*frame;
+        bufferFrameCount -= frame;
+        frameCount = min(bufferFrameCount, data->remainingFrames);
+    }
+
+    // Write a sine wave with the specified frequency and amplitude
+    multiplier = 2*M_PI*(data->frequency/data->sampleRate);
+    for (frame = 0; frame < frameCount; frame++) {
+        v = data->amplitude * 
+            QuartzAudioEnvelope(data->curFrame+frame, data->totalFrames,
+                                data->fadeLength) *
+            sin(multiplier * (data->curFrame+frame));
+        for (i = 0; i < audiobuffer->mNumberChannels; i++) {
+            *b++ = v;
+        }
+    }
+
+    // Zero out the rest of the buffer, if any
+    memset(b, 0, sizeof(float) * audiobuffer->mNumberChannels *
+           (bufferFrameCount-frame));
+
+    data->curFrame += frameCount;
+    data->remainingFrames -= frameCount;
+    if (data->remainingFrames == 0) {
+        data->playing = FALSE;
+        data->curFrame = 0;
+    }
+}
+
+
+/*
+ * QuartzAudioIOProc
+ *  Callback function for audio playback.
+ *  FIXME: use inOutputTime to correct for skipping
+ */
+static OSStatus 
+QuartzAudioIOProc(
+    AudioDeviceID inDevice, 
+    const AudioTimeStamp *inNow, 
+    const AudioBufferList *inInputData, 
+    const AudioTimeStamp *inInputTime, 
+    AudioBufferList *outOutputData, 
+    const AudioTimeStamp *inOutputTime, 
+    void *inClientData )
+{
+    QuartzAudioRec *data = (QuartzAudioRec *)inClientData;
+    int i;
+    Boolean wasPlaying;
+
+    pthread_mutex_lock(&data->lock);
+    wasPlaying = data->playing;
+    for (i = 0; i < outOutputData->mNumberBuffers; i++) {
+        if (data->playing) {
+            QuartzFillBuffer(outOutputData->mBuffers+i, data); 
+        }
+        else {
+            memset(outOutputData->mBuffers[i].mData, 0, 
+                   outOutputData->mBuffers[i].mDataByteSize);
+        }
+    }
+    if (wasPlaying  &&  !data->playing) {
+        OSStatus err;
+        err = AudioDeviceStop(inDevice, QuartzAudioIOProc);
+    }
+    pthread_mutex_unlock(&data->lock);
+    return 0;
+}
+
+
+/*
+ * QuartzCoreAudioBell
+ *  Play a tone using the CoreAudio API
+ */
+static void QuartzCoreAudioBell(
+    int volume,         // volume is % of max
+    int pitch,          // pitch is Hz
+    int duration )      // duration is milliseconds
+{
+    if (quartzAudioDevice == kAudioDeviceUnknown) return;
+
+    pthread_mutex_lock(&data.lock);
+
+    // fade previous sound, if any
+    data.prevFrequency = data.frequency;
+    data.prevAmplitude = data.amplitude;
+    data.prevFrame = data.curFrame;
+
+    // set new sound
+    data.frequency = pitch;
+    data.amplitude = volume / 100.0;
+    data.curFrame = 0;
+    data.totalFrames = (int)(data.sampleRate * duration / 1000.0);
+    data.remainingFrames = data.totalFrames;
+
+    if (! data.playing) {
+        OSStatus status;
+        status = AudioDeviceStart(quartzAudioDevice, QuartzAudioIOProc);
+        if (status) {
+            ErrorF("QuartzAudioBell: AudioDeviceStart returned %ld\n", status);
+        } else {
+            data.playing = TRUE;
+        }
+    }
+    pthread_mutex_unlock(&data.lock);
+}
+
+
+/*
+ * DarwinModeBell
+ *  Ring the bell
+ */
+void DarwinModeBell(
+    int volume,             // volume in percent of max
+    DeviceIntPtr pDevice,
+    pointer ctrl,
+    int class )
+{
+    int pitch;              // pitch in Hz
+    int duration;           // duration in milliseconds
+
+    if (class == BellFeedbackClass) {
+        pitch = ((BellCtrl*)ctrl)->pitch;
+        duration = ((BellCtrl*)ctrl)->duration;
+    } else if (class == KbdFeedbackClass) {
+        pitch = ((KeybdCtrl*)ctrl)->bell_pitch;
+        duration = ((KeybdCtrl*)ctrl)->bell_duration;    
+    } else {
+        ErrorF("QuartzBell: bad bell class %d\n", class);
+        return;
+    }
+
+    if (quartzUseSysBeep) {
+        if (volume)
+            NSBeep();
+    } else {
+        QuartzCoreAudioBell(volume, pitch, duration);
+    }
+}
+
+
+/*
+ * QuartzAudioInit
+ *  Prepare to play the bell with the CoreAudio API
+ */
+void QuartzAudioInit(void) 
+{
+    UInt32 propertySize;
+    OSStatus status;
+    AudioDeviceID outputDevice;
+    AudioStreamBasicDescription outputStreamDescription;
+    double sampleRate;
+
+    // Get the default output device
+    propertySize = sizeof(outputDevice);
+    status = AudioHardwareGetProperty(
+                    kAudioHardwarePropertyDefaultOutputDevice, 
+                    &propertySize, &outputDevice);
+    if (status) {
+        ErrorF("QuartzAudioInit: AudioHardwareGetProperty returned %ld\n",
+               status);
+        return;
+    }
+    if (outputDevice == kAudioDeviceUnknown) {
+        ErrorF("QuartzAudioInit: No audio output devices available.\n");
+        return;
+    }
+
+    // Get the basic device description
+    propertySize = sizeof(outputStreamDescription);
+    status = AudioDeviceGetProperty(outputDevice, 0, FALSE, 
+                                    kAudioDevicePropertyStreamFormat, 
+                                    &propertySize, &outputStreamDescription);
+    if (status) {
+        ErrorF("QuartzAudioInit: GetProperty(stream format) returned %ld\n",
+               status);
+        return;
+    }
+    sampleRate = outputStreamDescription.mSampleRate;
+
+    // Fill in the playback data
+    data.frequency = 0;
+    data.amplitude = 0;
+    data.curFrame = 0;
+    data.remainingFrames = 0; 
+    data.bytesPerFrame = outputStreamDescription.mBytesPerFrame;
+    data.sampleRate = sampleRate;
+    // data.bufferByteCount = bufferByteCount;
+    data.playing = FALSE;
+    data.prevAmplitude = 0;
+    data.prevFrame = 0;
+    data.prevFrequency = 0;
+    data.fadeLength = data.sampleRate / 200;
+    pthread_mutex_init(&data.lock, NULL); // fixme error check
+
+    // fixme assert fadeLength<framesPerBuffer
+
+    // Prepare for playback
+    status = AudioDeviceAddIOProc(outputDevice, QuartzAudioIOProc, &data);
+    if (status) {
+        ErrorF("QuartzAudioInit: AddIOProc returned %ld\n", status);
+        return;
+    }
+
+    // success!
+    quartzAudioDevice = outputDevice;
+}
diff --git a/hw/xquartz/quartzAudio.h b/hw/xquartz/quartzAudio.h
new file mode 100644
index 0000000..c406bbc
--- /dev/null
+++ b/hw/xquartz/quartzAudio.h
@@ -0,0 +1,40 @@
+//
+// QuartzAudio.h
+//
+// X Window bell support using CoreAudio or AppKit.
+// Greg Parker   gparker at cs.stanford.edu   19 Feb 2001
+/*
+ * Copyright (c) 2001 Greg Parker. 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
+ * 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 _QUARTZAUDIO_H
+#define _QUARTZAUDIO_H
+
+#include "input.h"
+
+void QuartzAudioInit(void);
+void QuartzBell(int volume, DeviceIntPtr pDevice, pointer ctrl, int class);
+
+#endif
diff --git a/hw/xquartz/quartzCocoa.m b/hw/xquartz/quartzCocoa.m
new file mode 100644
index 0000000..0086c5c
--- /dev/null
+++ b/hw/xquartz/quartzCocoa.m
@@ -0,0 +1,145 @@
+/**************************************************************
+ *
+ * Quartz-specific support for the Darwin X Server
+ * that requires Cocoa and Objective-C.
+ *
+ * This file is separate from the parts of Quartz support
+ * that use X include files to avoid symbol collisions.
+ *
+ * Copyright (c) 2001-2004 Torrey T. Lyons and Greg Parker.
+ *                 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
+ * 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "quartzCommon.h"
+
+#define BOOL xBOOL
+#include "darwin.h"
+#undef BOOL
+
+#include <Cocoa/Cocoa.h>
+
+#include "pseudoramiX.h"
+
+extern void FatalError(const char *, ...);
+extern char *display;
+extern int noPanoramiXExtension;
+
+/*
+ * QuartzWriteCocoaPasteboard
+ *  Write text to the Mac OS X pasteboard.
+ */
+void QuartzWriteCocoaPasteboard(
+    char *text)
+{
+    NSPasteboard *pasteboard;
+    NSArray *pasteboardTypes;
+    NSString *string;
+
+    if (! text) return;
+    pasteboard = [NSPasteboard generalPasteboard];
+    if (! pasteboard) return;
+    string = [NSString stringWithCString:text];
+    if (! string) return;
+    pasteboardTypes = [NSArray arrayWithObject:NSStringPboardType];
+
+    // nil owner because we don't provide type translations
+    [pasteboard declareTypes:pasteboardTypes owner:nil];
+    [pasteboard setString:string forType:NSStringPboardType];
+}
+
+
+/*
+ * QuartzReadCocoaPasteboard
+ *  Read text from the Mac OS X pasteboard and return it as a heap string.
+ *  The caller must free the string.
+ */
+char *QuartzReadCocoaPasteboard(void)
+{
+    NSPasteboard *pasteboard;
+    NSArray *pasteboardTypes;
+    NSString *existingType;
+    char *text = NULL;
+
+    pasteboardTypes = [NSArray arrayWithObject:NSStringPboardType];
+    pasteboard = [NSPasteboard generalPasteboard];
+    if (! pasteboard) return NULL;
+
+    existingType = [pasteboard availableTypeFromArray:pasteboardTypes];
+    if (existingType) {
+        NSString *string = [pasteboard stringForType:existingType];
+        char *buffer;
+
+        if (! string) return NULL;
+        buffer = (char *) [string UTF8String];
+        text = (char *) malloc(strlen(buffer)+1);
+        if (text)
+            strcpy(text, buffer);
+    }
+
+    return text;
+}
+
+
+/*
+ * QuartzFSUseQDCursor
+ *  Return whether the screen should use a QuickDraw cursor.
+ */
+int QuartzFSUseQDCursor(
+    int depth)  // screen depth
+{
+    return TRUE;
+}
+
+
+/*
+ * QuartzBlockHandler
+ *  Clean out any autoreleased objects.
+ */
+void QuartzBlockHandler(
+    pointer blockData,
+    OSTimePtr pTimeout,
+    pointer pReadmask)
+{
+    static NSAutoreleasePool *aPool = nil;
+
+    [aPool release];
+    aPool = [[NSAutoreleasePool alloc] init];
+}
+
+
+/*
+ * QuartzWakeupHandler
+ */
+void QuartzWakeupHandler(
+    pointer blockData,
+    int result,
+    pointer pReadmask)
+{
+    // nothing here
+}
diff --git a/hw/xquartz/quartzCommon.h b/hw/xquartz/quartzCommon.h
new file mode 100644
index 0000000..f0d5a7a
--- /dev/null
+++ b/hw/xquartz/quartzCommon.h
@@ -0,0 +1,107 @@
+/*
+ * quartzCommon.h
+ *
+ * Common definitions used internally by all Quartz modes
+ *
+ * This file should be included before any X11 or IOKit headers
+ * so that it can avoid symbol conflicts.
+ *
+ * Copyright (c) 2001-2004 Torrey T. Lyons and Greg Parker.
+ *                 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
+ * 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 _QUARTZCOMMON_H
+#define _QUARTZCOMMON_H
+
+// QuickDraw in ApplicationServices has the following conflicts with
+// the basic X server headers. Use QD_<name> to use the QuickDraw
+// definition of any of these symbols, or the normal name for the
+// X11 definition.
+#define Cursor       QD_Cursor
+#define WindowPtr    QD_WindowPtr
+#define Picture      QD_Picture
+#include <ApplicationServices/ApplicationServices.h>
+#undef Cursor
+#undef WindowPtr
+#undef Picture
+#include <X11/Xdefs.h>
+
+// Quartz specific per screen storage structure
+typedef struct {
+    // List of CoreGraphics displays that this X11 screen covers.
+    // This is more than one CG display for video mirroring and
+    // rootless PseudoramiX mode.
+    // No CG display will be covered by more than one X11 screen.
+    int displayCount;
+    CGDirectDisplayID *displayIDs;
+} QuartzScreenRec, *QuartzScreenPtr;
+
+#define QUARTZ_PRIV(pScreen) \
+    ((QuartzScreenPtr)pScreen->devPrivates[quartzScreenIndex].ptr)
+
+// Data stored at startup for Cocoa front end
+extern int              quartzEventWriteFD;
+extern int              quartzStartClients;
+
+// User preferences used by Quartz modes
+extern int              quartzRootless;
+extern int              quartzUseSysBeep;
+extern int              quartzUseAGL;
+extern int              quartzEnableKeyEquivalents;
+
+// Other shared data
+extern int              quartzServerVisible;
+extern int              quartzServerQuitting;
+extern int              quartzScreenIndex;
+extern int              aquaMenuBarHeight;
+
+// Name of GLX bundle for native OpenGL
+extern const char      *quartzOpenGLBundle;
+
+void QuartzReadPreferences(void);
+void QuartzMessageMainThread(unsigned msg, void *data, unsigned length);
+void QuartzMessageServerThread(int type, int argc, ...);
+void QuartzSetWindowMenu(int nitems, const char **items,
+                         const char *shortcuts);
+void QuartzFSCapture(void);
+void QuartzFSRelease(void);
+int  QuartzFSUseQDCursor(int depth);
+void QuartzBlockHandler(pointer blockData, OSTimePtr pTimeout, pointer pReadmask);
+void QuartzWakeupHandler(pointer blockData, int result, pointer pReadmask);
+
+// Messages that can be sent to the main thread.
+enum {
+    kQuartzServerHidden,
+    kQuartzServerStarted,
+    kQuartzServerDied,
+    kQuartzCursorUpdate,
+    kQuartzPostEvent,
+    kQuartzSetWindowMenu,
+    kQuartzSetWindowMenuCheck,
+    kQuartzSetFrontProcess,
+    kQuartzSetCanQuit
+};
+
+#endif  /* _QUARTZCOMMON_H */
diff --git a/hw/xquartz/quartzCursor.c b/hw/xquartz/quartzCursor.c
new file mode 100644
index 0000000..6e86acb
--- /dev/null
+++ b/hw/xquartz/quartzCursor.c
@@ -0,0 +1,654 @@
+/**************************************************************
+ *
+ * Support for using the Quartz Window Manager cursor
+ *
+ * Copyright (c) 2001-2003 Torrey T. Lyons and Greg Parker.
+ *                 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
+ * 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "quartzCommon.h"
+#include "quartzCursor.h"
+#include "darwin.h"
+
+#include <pthread.h>
+
+#include "mi.h"
+#include "scrnintstr.h"
+#include "cursorstr.h"
+#include "mipointrst.h"
+#include "globals.h"
+
+// Size of the QuickDraw cursor
+#define CURSORWIDTH 16
+#define CURSORHEIGHT 16
+
+typedef struct {
+    int                     qdCursorMode;
+    int                     qdCursorVisible;
+    int                     useQDCursor;
+    QueryBestSizeProcPtr    QueryBestSize;
+    miPointerSpriteFuncPtr  spriteFuncs;
+} QuartzCursorScreenRec, *QuartzCursorScreenPtr;
+
+static int darwinCursorScreenIndex = -1;
+static unsigned long darwinCursorGeneration = 0;
+static CursorPtr quartzLatentCursor = NULL;
+static QD_Cursor gQDArrow; // QuickDraw arrow cursor
+
+// Cursor for the main thread to set (NULL = arrow cursor).
+static CCrsrHandle currentCursor = NULL;
+static pthread_mutex_t cursorMutex;
+static pthread_cond_t cursorCondition;
+
+#define CURSOR_PRIV(pScreen) \
+    ((QuartzCursorScreenPtr)pScreen->devPrivates[darwinCursorScreenIndex].ptr)
+
+#define HIDE_QD_CURSOR(pScreen, visible)                                \
+    if (visible) {                                                      \
+        int ix;                                                         \
+        for (ix = 0; ix < QUARTZ_PRIV(pScreen)->displayCount; ix++) {   \
+            CGDisplayHideCursor(QUARTZ_PRIV(pScreen)->displayIDs[ix]);  \
+        }                                                               \
+        visible = FALSE;                                                \
+    } ((void)0)
+
+#define SHOW_QD_CURSOR(pScreen, visible)                                \
+    {                                                                   \
+        int ix;                                                         \
+        for (ix = 0; ix < QUARTZ_PRIV(pScreen)->displayCount; ix++) {   \
+            CGDisplayShowCursor(QUARTZ_PRIV(pScreen)->displayIDs[ix]);  \
+        }                                                               \
+        visible = TRUE;                                                 \
+    } ((void)0)
+
+#define CHANGE_QD_CURSOR(cursorH)                                       \
+    if (!quartzServerQuitting) {                                        \
+        /* Acquire lock and tell the main thread to change cursor */    \
+        pthread_mutex_lock(&cursorMutex);                               \
+        currentCursor = (CCrsrHandle) (cursorH);                        \
+        QuartzMessageMainThread(kQuartzCursorUpdate, NULL, 0);          \
+                                                                        \
+        /* Wait for the main thread to change the cursor */             \
+        pthread_cond_wait(&cursorCondition, &cursorMutex);              \
+        pthread_mutex_unlock(&cursorMutex);                             \
+    } ((void)0)
+
+
+/*
+ * MakeQDCursor helpers: CTAB_ENTER, interleave
+ */
+
+// Add a color entry to a ctab
+#define CTAB_ENTER(ctab, index, r, g, b)                                \
+    ctab->ctTable[index].value = index;                                 \
+    ctab->ctTable[index].rgb.red = r;                                   \
+    ctab->ctTable[index].rgb.green = g;                                 \
+    ctab->ctTable[index].rgb.blue = b
+
+// Make an unsigned short by interleaving the bits of bytes c1 and c2.
+// High bit of c1 is first; low bit of c2 is last.
+// Interleave is a built-in INTERCAL operator.
+static unsigned short
+interleave(
+    unsigned char c1,
+    unsigned char c2 )
+{
+    return
+        ((c1 & 0x80) << 8) | ((c2 & 0x80) << 7) |
+        ((c1 & 0x40) << 7) | ((c2 & 0x40) << 6) |
+        ((c1 & 0x20) << 6) | ((c2 & 0x20) << 5) |
+        ((c1 & 0x10) << 5) | ((c2 & 0x10) << 4) |
+        ((c1 & 0x08) << 4) | ((c2 & 0x08) << 3) |
+        ((c1 & 0x04) << 3) | ((c2 & 0x04) << 2) |
+        ((c1 & 0x02) << 2) | ((c2 & 0x02) << 1) |
+        ((c1 & 0x01) << 1) | ((c2 & 0x01) << 0) ;
+}
+
+/*
+ * MakeQDCursor
+ * Make a QuickDraw color cursor from the given X11 cursor.
+ * Warning: This code is nasty. Color cursors were meant to be read
+ * from resources; constructing the structures programmatically is messy.
+ */
+/*
+    QuickDraw cursor representation:
+    Our color cursor is a 2 bit per pixel pixmap.
+    Each pixel's bits are (source<<1 | mask) from the original X cursor pixel.
+    The cursor's color table maps the colors like this:
+    (2-bit value | X result    | colortable | Mac result)
+             00  | transparent | white      | transparent (white outside mask)
+             01  | back color  | back color | back color
+             10  | undefined   | black      | invert background (just for fun)
+             11  | fore color  | fore color | fore color
+*/
+static CCrsrHandle
+MakeQDCursor(
+    CursorPtr pCursor )
+{
+    CCrsrHandle result;
+    CCrsrPtr curs;
+    int i, w, h;
+    unsigned short rowMask;
+    PixMap *pix;
+    ColorTable *ctab;
+    unsigned short *image;
+
+    result = (CCrsrHandle) NewHandleClear(sizeof(CCrsr));
+    if (!result) return NULL;
+    HLock((Handle)result);
+    curs = *result;
+
+    // Initialize CCrsr
+    curs->crsrType = 0x8001;     // 0x8000 = b&w, 0x8001 = color
+    curs->crsrMap = (PixMapHandle) NewHandleClear(sizeof(PixMap));
+    if (!curs->crsrMap) goto pixAllocFailed;
+    HLock((Handle)curs->crsrMap);
+    pix = *curs->crsrMap;
+    curs->crsrData = NULL;       // raw cursor image data (set below)
+    curs->crsrXData = NULL;      // QD's processed data
+    curs->crsrXValid = 0;        // zero means QD must re-process cursor data
+    curs->crsrXHandle = NULL;    // reserved
+    memset(curs->crsr1Data, 0, CURSORWIDTH*CURSORHEIGHT/8); // b&w data
+    memset(curs->crsrMask,  0, CURSORWIDTH*CURSORHEIGHT/8); // b&w & color mask
+    curs->crsrHotSpot.h = min(CURSORWIDTH,  pCursor->bits->xhot); // hot spot
+    curs->crsrHotSpot.v = min(CURSORHEIGHT, pCursor->bits->yhot); // hot spot
+    curs->crsrXTable = 0;        // reserved
+    curs->crsrID = GetCTSeed();  // unique ID from Color Manager
+
+    // Set the b&w data and mask
+    w = min(pCursor->bits->width,  CURSORWIDTH);
+    h = min(pCursor->bits->height, CURSORHEIGHT);
+    rowMask = ~((1 << (CURSORWIDTH - w)) - 1);
+    for (i = 0; i < h; i++) {
+        curs->crsr1Data[i] = rowMask &
+        ((pCursor->bits->source[i*4]<<8) | pCursor->bits->source[i*4+1]);
+        curs->crsrMask[i] = rowMask &
+        ((pCursor->bits->mask[i*4]<<8)   | pCursor->bits->mask[i*4+1]);
+    }
+
+    // Set the color data and mask
+    // crsrMap: defines bit depth and size and colortable only
+    pix->rowBytes = (CURSORWIDTH * 2 / 8) | 0x8000; // last bit on means PixMap
+    SetRect(&pix->bounds, 0, 0, CURSORWIDTH, CURSORHEIGHT); // see TN 1020
+    pix->pixelSize = 2;
+    pix->cmpCount = 1;
+    pix->cmpSize = 2;
+    // pix->pmTable set below
+
+    // crsrData is the pixel data. crsrMap's baseAddr is not used.
+    curs->crsrData = NewHandleClear(CURSORWIDTH*CURSORHEIGHT * 2 / 8);
+    if (!curs->crsrData) goto imageAllocFailed;
+    HLock((Handle)curs->crsrData);
+    image = (unsigned short *) *curs->crsrData;
+    // Pixel data is just 1-bit data and mask interleaved (see above)
+    for (i = 0; i < h; i++) {
+        unsigned char s, m;
+        s = pCursor->bits->source[i*4] & (rowMask >> 8);
+        m = pCursor->bits->mask[i*4] & (rowMask >> 8);
+        image[2*i] = interleave(s, m);
+        s = pCursor->bits->source[i*4+1] & (rowMask & 0x00ff);
+        m = pCursor->bits->mask[i*4+1] & (rowMask & 0x00ff);
+        image[2*i+1] = interleave(s, m);
+    }
+
+    // Build the color table (entries described above)
+    // NewPixMap allocates a color table handle.
+    pix->pmTable = (CTabHandle) NewHandleClear(sizeof(ColorTable) + 3
+                    * sizeof(ColorSpec));
+    if (!pix->pmTable) goto ctabAllocFailed;
+    HLock((Handle)pix->pmTable);
+    ctab = *pix->pmTable;
+    ctab->ctSeed = GetCTSeed();
+    ctab->ctFlags = 0;
+    ctab->ctSize = 3; // color count - 1
+    CTAB_ENTER(ctab, 0, 0xffff, 0xffff, 0xffff);
+    CTAB_ENTER(ctab, 1, pCursor->backRed, pCursor->backGreen,
+               pCursor->backBlue);
+    CTAB_ENTER(ctab, 2, 0x0000, 0x0000, 0x0000);
+    CTAB_ENTER(ctab, 3, pCursor->foreRed, pCursor->foreGreen,
+               pCursor->foreBlue);
+
+    HUnlock((Handle)pix->pmTable); // ctab
+    HUnlock((Handle)curs->crsrData); // image data
+    HUnlock((Handle)curs->crsrMap); // pix
+    HUnlock((Handle)result); // cursor
+
+    return result;
+
+    // "What we have here is a failure to allocate"
+ctabAllocFailed:
+    HUnlock((Handle)curs->crsrData);
+    DisposeHandle((Handle)curs->crsrData);
+imageAllocFailed:
+    HUnlock((Handle)curs->crsrMap);
+    DisposeHandle((Handle)curs->crsrMap);
+pixAllocFailed:
+    HUnlock((Handle)result);
+    DisposeHandle((Handle)result);
+    return NULL;
+}
+
+
+/*
+ * FreeQDCursor
+ * Destroy a QuickDraw color cursor created with MakeQDCursor().
+ * The cursor must not currently be on screen.
+ */
+static void FreeQDCursor(CCrsrHandle cursHandle)
+{
+    CCrsrPtr curs;
+    PixMap *pix;
+
+    HLock((Handle)cursHandle);
+    curs = *cursHandle;
+    HLock((Handle)curs->crsrMap);
+    pix = *curs->crsrMap;
+    DisposeHandle((Handle)pix->pmTable);
+    HUnlock((Handle)curs->crsrMap);
+    DisposeHandle((Handle)curs->crsrMap);
+    DisposeHandle((Handle)curs->crsrData);
+    HUnlock((Handle)cursHandle);
+    DisposeHandle((Handle)cursHandle);
+}
+
+
+/*
+===========================================================================
+
+ Pointer sprite functions
+
+===========================================================================
+*/
+
+/*
+ * QuartzRealizeCursor
+ * Convert the X cursor representation to QuickDraw format if possible.
+ */
+Bool
+QuartzRealizeCursor(
+    ScreenPtr pScreen,
+    CursorPtr pCursor )
+{
+    CCrsrHandle qdCursor;
+    QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
+
+    if(!pCursor || !pCursor->bits)
+        return FALSE;
+
+    // if the cursor is too big we use a software cursor
+    if ((pCursor->bits->height > CURSORHEIGHT) ||
+        (pCursor->bits->width > CURSORWIDTH) || !ScreenPriv->useQDCursor)
+    {
+        if (quartzRootless) {
+            // rootless can't use a software cursor
+            return TRUE;
+        } else {
+            return (*ScreenPriv->spriteFuncs->RealizeCursor)
+                        (pScreen, pCursor);
+        }
+    }
+
+    // make new cursor image
+    qdCursor = MakeQDCursor(pCursor);
+    if (!qdCursor) return FALSE;
+
+    // save the result
+    pCursor->devPriv[pScreen->myNum] = (pointer) qdCursor;
+
+    return TRUE;
+}
+
+
+/*
+ * QuartzUnrealizeCursor
+ * Free the storage space associated with a realized cursor.
+ */
+Bool
+QuartzUnrealizeCursor(
+    ScreenPtr pScreen,
+    CursorPtr pCursor )
+{
+    QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
+
+    if ((pCursor->bits->height > CURSORHEIGHT) ||
+        (pCursor->bits->width > CURSORWIDTH) || !ScreenPriv->useQDCursor)
+    {
+        if (quartzRootless) {
+            return TRUE;
+        } else {
+            return (*ScreenPriv->spriteFuncs->UnrealizeCursor)
+                        (pScreen, pCursor);
+        }
+    } else {
+        CCrsrHandle oldCursor = (CCrsrHandle) pCursor->devPriv[pScreen->myNum];
+
+        if (currentCursor != oldCursor) {
+            // This should only fail when quitting, in which case we just leak.
+            FreeQDCursor(oldCursor);
+        }
+        pCursor->devPriv[pScreen->myNum] = NULL;
+        return TRUE;
+    }
+}
+
+
+/*
+ * QuartzSetCursor
+ * Set the cursor sprite and position.
+ * Use QuickDraw cursor if possible.
+ */
+static void
+QuartzSetCursor(
+    ScreenPtr       pScreen,
+    CursorPtr       pCursor,
+    int             x,
+    int             y)
+{
+    QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
+
+    quartzLatentCursor = pCursor;
+
+    // Don't touch Mac OS cursor if X is hidden!
+    if (!quartzServerVisible)
+        return;
+
+    if (!pCursor) {
+        // Remove the cursor completely.
+        HIDE_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
+        if (! ScreenPriv->qdCursorMode)
+            (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, 0, x, y);
+    }
+    else if ((pCursor->bits->height <= CURSORHEIGHT) &&
+             (pCursor->bits->width <= CURSORWIDTH) && ScreenPriv->useQDCursor)
+    {
+        // Cursor is small enough to use QuickDraw directly.
+        if (! ScreenPriv->qdCursorMode)    // remove the X cursor
+            (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, 0, x, y);
+        ScreenPriv->qdCursorMode = TRUE;
+
+        CHANGE_QD_CURSOR(pCursor->devPriv[pScreen->myNum]);
+        SHOW_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
+    }
+    else if (quartzRootless) {
+        // Rootless can't use a software cursor, so we just use Mac OS arrow.
+        CHANGE_QD_CURSOR(NULL);
+        SHOW_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
+    }
+    else {
+        // Cursor is too big for QuickDraw. Use X software cursor.
+        HIDE_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
+        ScreenPriv->qdCursorMode = FALSE;
+        (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, pCursor, x, y);
+    }
+}
+
+
+/*
+ * QuartzReallySetCursor
+ * Set the QuickDraw cursor. Called from the main thread since changing the
+ * cursor with QuickDraw is not thread safe on dual processor machines.
+ */
+void
+QuartzReallySetCursor()
+{
+    pthread_mutex_lock(&cursorMutex);
+
+    if (currentCursor) {
+        SetCCursor(currentCursor);
+    } else {
+        SetCursor(&gQDArrow);
+    }
+
+    pthread_cond_signal(&cursorCondition);
+    pthread_mutex_unlock(&cursorMutex);
+}
+
+
+/*
+ * QuartzMoveCursor
+ * Move the cursor. This is a noop for QuickDraw.
+ */
+static void
+QuartzMoveCursor(
+    ScreenPtr   pScreen,
+    int         x,
+    int         y)
+{
+    QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
+
+    // only the X cursor needs to be explicitly moved
+    if (!ScreenPriv->qdCursorMode)
+        (*ScreenPriv->spriteFuncs->MoveCursor)(pScreen, x, y);
+}
+
+
+static miPointerSpriteFuncRec quartzSpriteFuncsRec = {
+    QuartzRealizeCursor,
+    QuartzUnrealizeCursor,
+    QuartzSetCursor,
+    QuartzMoveCursor
+};
+
+
+/*
+===========================================================================
+
+ Pointer screen functions
+
+===========================================================================
+*/
+
+/*
+ * QuartzCursorOffScreen
+ */
+static Bool QuartzCursorOffScreen(ScreenPtr *pScreen, int *x, int *y)
+{
+    return FALSE;
+}
+
+
+/*
+ * QuartzCrossScreen
+ */
+static void QuartzCrossScreen(ScreenPtr pScreen, Bool entering)
+{
+    return;
+}
+
+
+/*
+ * QuartzWarpCursor
+ *  Change the cursor position without generating an event or motion history.
+ *  The input coordinates (x,y) are in pScreen-local X11 coordinates.
+ *
+ */
+static void
+QuartzWarpCursor(
+    ScreenPtr               pScreen,
+    int                     x,
+    int                     y)
+{
+    static int              neverMoved = TRUE;
+
+    if (neverMoved) {
+        // Don't move the cursor the first time. This is the jump-to-center
+        // initialization, and it's annoying because we may still be in MacOS.
+        neverMoved = FALSE;
+        return;
+    }
+
+    if (quartzServerVisible) {
+        CGDisplayErr        cgErr;
+        CGPoint             cgPoint;
+        // Only need to do this for one display. Any display will do.
+        CGDirectDisplayID   cgID = QUARTZ_PRIV(pScreen)->displayIDs[0];
+        CGRect              cgRect = CGDisplayBounds(cgID);
+
+        // Convert (x,y) to CoreGraphics screen-local CG coordinates.
+        // This is necessary because the X11 screen and CG screen may not
+        // coincide. (e.g. X11 screen may be moved to dodge the menu bar)
+
+        // Make point in X11 global coordinates
+        cgPoint = CGPointMake(x + dixScreenOrigins[pScreen->myNum].x,
+                              y + dixScreenOrigins[pScreen->myNum].y);
+        // Shift to CoreGraphics global screen coordinates
+        cgPoint.x += darwinMainScreenX;
+        cgPoint.y += darwinMainScreenY;
+        // Shift to CoreGraphics screen-local coordinates
+        cgPoint.x -= cgRect.origin.x;
+        cgPoint.y -= cgRect.origin.y;
+
+        cgErr = CGDisplayMoveCursorToPoint(cgID, cgPoint);
+        if (cgErr != CGDisplayNoErr) {
+            ErrorF("Could not set cursor position with error code 0x%x.\n",
+                    cgErr);
+        }
+    }
+
+    miPointerWarpCursor(pScreen, x, y);
+    miPointerUpdate();
+}
+
+
+static miPointerScreenFuncRec quartzScreenFuncsRec = {
+    QuartzCursorOffScreen,
+    QuartzCrossScreen,
+    QuartzWarpCursor,
+    DarwinEQPointerPost,
+    DarwinEQSwitchScreen
+};
+
+
+/*
+===========================================================================
+
+ Other screen functions
+
+===========================================================================
+*/
+
+/*
+ * QuartzCursorQueryBestSize
+ * Handle queries for best cursor size
+ */
+static void
+QuartzCursorQueryBestSize(
+   int              class,
+   unsigned short   *width,
+   unsigned short   *height,
+   ScreenPtr        pScreen)
+{
+    QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
+
+    if (class == CursorShape) {
+        *width = CURSORWIDTH;
+        *height = CURSORHEIGHT;
+    } else {
+        (*ScreenPriv->QueryBestSize)(class, width, height, pScreen);
+    }
+}
+
+
+/*
+ * QuartzInitCursor
+ * Initialize cursor support
+ */
+Bool
+QuartzInitCursor(
+    ScreenPtr   pScreen )
+{
+    QuartzCursorScreenPtr   ScreenPriv;
+    miPointerScreenPtr      PointPriv;
+    DarwinFramebufferPtr    dfb = SCREEN_PRIV(pScreen);
+
+    // initialize software cursor handling (always needed as backup)
+    if (!miDCInitialize(pScreen, &quartzScreenFuncsRec)) {
+        return FALSE;
+    }
+
+    // allocate private storage for this screen's QuickDraw cursor info
+    if (darwinCursorGeneration != serverGeneration) {
+        if ((darwinCursorScreenIndex = AllocateScreenPrivateIndex()) < 0)
+            return FALSE;
+        darwinCursorGeneration = serverGeneration;
+    }
+
+    ScreenPriv = xcalloc( 1, sizeof(QuartzCursorScreenRec) );
+    if (!ScreenPriv) return FALSE;
+
+    CURSOR_PRIV(pScreen) = ScreenPriv;
+
+    // override some screen procedures
+    ScreenPriv->QueryBestSize = pScreen->QueryBestSize;
+    pScreen->QueryBestSize = QuartzCursorQueryBestSize;
+
+    // initialize QuickDraw cursor handling
+    GetQDGlobalsArrow(&gQDArrow);
+    PointPriv = (miPointerScreenPtr)
+                    pScreen->devPrivates[miPointerScreenIndex].ptr;
+
+    ScreenPriv->spriteFuncs = PointPriv->spriteFuncs;
+    PointPriv->spriteFuncs = &quartzSpriteFuncsRec;
+
+    if (!quartzRootless)
+        ScreenPriv->useQDCursor = QuartzFSUseQDCursor(dfb->colorBitsPerPixel);
+    else
+        ScreenPriv->useQDCursor = TRUE;
+    ScreenPriv->qdCursorMode = TRUE;
+    ScreenPriv->qdCursorVisible = TRUE;
+
+    // initialize cursor mutex lock
+    pthread_mutex_init(&cursorMutex, NULL);
+
+    // initialize condition for waiting
+    pthread_cond_init(&cursorCondition, NULL);
+
+    return TRUE;
+}
+
+
+// X server is hiding. Restore the Aqua cursor.
+void QuartzSuspendXCursor(
+    ScreenPtr pScreen )
+{
+    QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
+
+    CHANGE_QD_CURSOR(NULL);
+    SHOW_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
+}
+
+
+// X server is showing. Restore the X cursor.
+void QuartzResumeXCursor(
+    ScreenPtr pScreen,
+    int x,
+    int y )
+{
+    QuartzSetCursor(pScreen, quartzLatentCursor, x, y);
+}
diff --git a/hw/xquartz/quartzCursor.h b/hw/xquartz/quartzCursor.h
new file mode 100644
index 0000000..56a0209
--- /dev/null
+++ b/hw/xquartz/quartzCursor.h
@@ -0,0 +1,42 @@
+/*
+ * quartzCursor.h
+ *
+ * External interface for Quartz hardware cursor
+ *
+ * Copyright (c) 2001 Torrey T. Lyons and Greg Parker.
+ *                 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
+ * 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 QUARTZCURSOR_H
+#define QUARTZCURSOR_H
+
+#include "screenint.h"
+
+Bool QuartzInitCursor(ScreenPtr pScreen);
+void QuartzReallySetCursor(void);
+void QuartzSuspendXCursor(ScreenPtr pScreen);
+void QuartzResumeXCursor(ScreenPtr pScreen, int x, int y);
+
+#endif
diff --git a/hw/xquartz/quartzKeyboard.c b/hw/xquartz/quartzKeyboard.c
new file mode 100644
index 0000000..0a50d06
--- /dev/null
+++ b/hw/xquartz/quartzKeyboard.c
@@ -0,0 +1,324 @@
+/*
+   quartzKeyboard.c
+
+   Code to build a keymap using the Carbon Keyboard Layout API.
+
+   Copyright (c) 2003-2007 Apple Inc.
+
+   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.
+*/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "quartzCommon.h"
+
+#include <CoreServices/CoreServices.h>
+#include <Carbon/Carbon.h>
+
+#include "quartzKeyboard.h"
+#include "X11/keysym.h"
+#include "keysym2ucs.h"
+
+#define HACK_MISSING 1
+#define HACK_KEYPAD 1
+
+enum {
+    MOD_COMMAND = 256,
+    MOD_SHIFT = 512,
+    MOD_OPTION = 2048,
+    MOD_CONTROL = 4096,
+};
+
+#define UKEYSYM(u) ((u) | 0x01000000)
+
+/* Table of keycode->keysym mappings we use to fallback on for important
+   keys that are often not in the Unicode mapping. */
+
+const static struct {
+    unsigned short keycode;
+    KeySym keysym;
+} known_keys[] = {
+    {55,  XK_Meta_L},
+    {56,  XK_Shift_L},
+    {57,  XK_Caps_Lock},
+    {58,  XK_Mode_switch},
+    {59,  XK_Control_L},
+
+    {60,  XK_Shift_R},
+    {61,  XK_Mode_switch},
+    {62,  XK_Control_R},
+    {63,  XK_Meta_R},
+
+    {122, XK_F1},
+    {120, XK_F2},
+    {99,  XK_F3},
+    {118, XK_F4},
+    {96,  XK_F5},
+    {97,  XK_F6},
+    {98,  XK_F7},
+    {100, XK_F8},
+    {101, XK_F9},
+    {109, XK_F10},
+    {103, XK_F11},
+    {111, XK_F12},
+    {105, XK_F13},
+    {107, XK_F14},
+    {113, XK_F15},
+};
+
+/* Table of keycode->old,new-keysym mappings we use to fixup the numeric
+   keypad entries. */
+
+const static struct {
+    unsigned short keycode;
+    KeySym normal, keypad;
+} known_numeric_keys[] = {
+    {65, XK_period, XK_KP_Decimal},
+    {67, XK_asterisk, XK_KP_Multiply},
+    {69, XK_plus, XK_KP_Add},
+    {75, XK_slash, XK_KP_Divide},
+    {76, 0x01000003, XK_KP_Enter},
+    {78, XK_minus, XK_KP_Subtract},
+    {81, XK_equal, XK_KP_Equal},
+    {82, XK_0, XK_KP_0},
+    {83, XK_1, XK_KP_1},
+    {84, XK_2, XK_KP_2},
+    {85, XK_3, XK_KP_3},
+    {86, XK_4, XK_KP_4},
+    {87, XK_5, XK_KP_5},
+    {88, XK_6, XK_KP_6},
+    {89, XK_7, XK_KP_7},
+    {91, XK_8, XK_KP_8},
+    {92, XK_9, XK_KP_9},
+};
+
+/* Table mapping normal keysyms to their dead equivalents.
+   FIXME: all the unicode keysyms (apart from circumflex) were guessed. */
+
+const static struct {
+    KeySym normal, dead;
+} dead_keys[] = {
+    {XK_grave, XK_dead_grave},
+    {XK_acute, XK_dead_acute},
+    {XK_asciicircum, XK_dead_circumflex},
+    {UKEYSYM (0x2c6), XK_dead_circumflex},	/* MODIFIER LETTER CIRCUMFLEX ACCENT */
+    {XK_asciitilde, XK_dead_tilde},
+    {UKEYSYM (0x2dc), XK_dead_tilde},		/* SMALL TILDE */
+    {XK_macron, XK_dead_macron},
+    {XK_breve, XK_dead_breve},
+    {XK_abovedot, XK_dead_abovedot},
+    {XK_diaeresis, XK_dead_diaeresis},
+    {UKEYSYM (0x2da), XK_dead_abovering},	/* DOT ABOVE */
+    {XK_doubleacute, XK_dead_doubleacute},
+    {XK_caron, XK_dead_caron},
+    {XK_cedilla, XK_dead_cedilla},
+    {XK_ogonek, XK_dead_ogonek},
+    {UKEYSYM (0x269), XK_dead_iota},		/* LATIN SMALL LETTER IOTA */
+    {UKEYSYM (0x2ec), XK_dead_voiced_sound},	/* MODIFIER LETTER VOICING */
+/*  {XK_semivoiced_sound, XK_dead_semivoiced_sound}, */
+    {UKEYSYM (0x323), XK_dead_belowdot},	/* COMBINING DOT BELOW */
+    {UKEYSYM (0x309), XK_dead_hook}, 		/* COMBINING HOOK ABOVE */
+    {UKEYSYM (0x31b), XK_dead_horn},		/* COMBINING HORN */
+};
+
+unsigned int DarwinModeSystemKeymapSeed(void) {
+    static unsigned int seed;
+    static KeyboardLayoutRef last_key_layout;
+    KeyboardLayoutRef key_layout;
+
+    KLGetCurrentKeyboardLayout (&key_layout);
+    if (key_layout != last_key_layout) seed++;
+    last_key_layout = key_layout;
+
+    return seed;
+}
+
+static inline UniChar macroman2ucs(unsigned char c) {
+    /* Precalculated table mapping MacRoman-128 to Unicode. Generated
+       by creating single element CFStringRefs then extracting the
+       first character. */
+
+    static const unsigned short table[128] = {
+        0xc4, 0xc5, 0xc7, 0xc9, 0xd1, 0xd6, 0xdc, 0xe1,
+        0xe0, 0xe2, 0xe4, 0xe3, 0xe5, 0xe7, 0xe9, 0xe8,
+        0xea, 0xeb, 0xed, 0xec, 0xee, 0xef, 0xf1, 0xf3,
+        0xf2, 0xf4, 0xf6, 0xf5, 0xfa, 0xf9, 0xfb, 0xfc,
+        0x2020, 0xb0, 0xa2, 0xa3, 0xa7, 0x2022, 0xb6, 0xdf,
+        0xae, 0xa9, 0x2122, 0xb4, 0xa8, 0x2260, 0xc6, 0xd8,
+        0x221e, 0xb1, 0x2264, 0x2265, 0xa5, 0xb5, 0x2202, 0x2211,
+        0x220f, 0x3c0, 0x222b, 0xaa, 0xba, 0x3a9, 0xe6, 0xf8,
+        0xbf, 0xa1, 0xac, 0x221a, 0x192, 0x2248, 0x2206, 0xab,
+        0xbb, 0x2026, 0xa0, 0xc0, 0xc3, 0xd5, 0x152, 0x153,
+        0x2013, 0x2014, 0x201c, 0x201d, 0x2018, 0x2019, 0xf7, 0x25ca,
+        0xff, 0x178, 0x2044, 0x20ac, 0x2039, 0x203a, 0xfb01, 0xfb02,
+        0x2021, 0xb7, 0x201a, 0x201e, 0x2030, 0xc2, 0xca, 0xc1,
+        0xcb, 0xc8, 0xcd, 0xce, 0xcf, 0xcc, 0xd3, 0xd4,
+        0xf8ff, 0xd2, 0xda, 0xdb, 0xd9, 0x131, 0x2c6, 0x2dc,
+        0xaf, 0x2d8, 0x2d9, 0x2da, 0xb8, 0x2dd, 0x2db, 0x2c7,
+    };
+
+    if (c < 128) return c;
+    else         return table[c - 128];
+}
+
+static KeySym make_dead_key(KeySym in) {
+    int i;
+
+    for (i = 0; i < sizeof (dead_keys) / sizeof (dead_keys[0]); i++)
+        if (dead_keys[i].normal == in) return dead_keys[i].dead;
+
+    return in;
+}
+
+Bool DarwinModeReadSystemKeymap(darwinKeyboardInfo *info) {
+    KeyboardLayoutRef key_layout;
+    const void *chr_data = NULL;
+    int num_keycodes = NUM_KEYCODES;
+    UInt32 keyboard_type = 0;
+    int is_uchr = 1, i, j;
+    OSStatus err;
+    KeySym *k;
+
+    TISInputSourceRef currentKeyLayoutRef = TISCopyCurrentKeyboardLayoutInputSource();
+    keyboard_type = LMGetKbdType ();
+    if (currentKeyLayoutRef) {
+      CFDataRef currentKeyLayoutDataRef = (CFDataRef )TISGetInputSourceProperty(currentKeyLayoutRef, kTISPropertyUnicodeKeyLayoutData);
+      if (currentKeyLayoutDataRef) chr_data = CFDataGetBytePtr(currentKeyLayoutDataRef);
+    }
+    
+    if (chr_data == NULL) {
+      KLGetCurrentKeyboardLayout (&key_layout);
+      KLGetKeyboardLayoutProperty (key_layout, kKLuchrData, &chr_data);
+    }
+    
+    if (chr_data == NULL) {
+      KLGetKeyboardLayoutProperty (key_layout, kKLKCHRData, &chr_data);
+      is_uchr = 0;
+      num_keycodes = 128;
+    }
+    
+    if (chr_data == NULL) {
+      ErrorF ( "Couldn't get uchr or kchr resource\n");
+      return FALSE;
+    }
+
+    /* Scan the keycode range for the Unicode character that each
+       key produces in the four shift states. Then convert that to
+       an X11 keysym (which may just the bit that says "this is
+       Unicode" if it can't find the real symbol.) */
+
+    for (i = 0; i < num_keycodes; i++) {
+        static const int mods[4] = {0, MOD_SHIFT, MOD_OPTION,
+                                    MOD_OPTION | MOD_SHIFT};
+
+        k = info->keyMap + i * GLYPHS_PER_KEY;
+
+        for (j = 0; j < 4; j++) {
+            if (is_uchr)  {
+                UniChar s[8];
+                UniCharCount len;
+                UInt32 dead_key_state = 0, extra_dead = 0;
+
+                err = UCKeyTranslate (chr_data, i, kUCKeyActionDown,
+                                      mods[j] >> 8, keyboard_type, 0,
+                                      &dead_key_state, 8, &len, s);
+                if (err != noErr) continue;
+
+                if (len == 0 && dead_key_state != 0) {
+                    /* Found a dead key. Work out which one it is, but
+                       remembering that it's dead. */
+                    err = UCKeyTranslate (chr_data, i, kUCKeyActionDown,
+                                          mods[j] >> 8, keyboard_type,
+                                          kUCKeyTranslateNoDeadKeysMask,
+                                          &extra_dead, 8, &len, s);
+                    if (err != noErr) continue;
+                }
+
+                if (len > 0 && s[0] != 0x0010) {
+                    k[j] = ucs2keysym (s[0]);
+                    if (dead_key_state != 0) k[j] = make_dead_key (k[j]);
+                }
+            } else { // kchr
+	      UInt32 c, state = 0, state2 = 0;
+                UInt16 code;
+
+                code = i | mods[j];
+                c = KeyTranslate (chr_data, code, &state);
+
+                /* Dead keys are only processed on key-down, so ask
+                   to translate those events. When we find a dead key,
+                   translating the matching key up event will give
+                   us the actual dead character. */
+
+                if (state != 0)
+                    c = KeyTranslate (chr_data, code | 128, &state2);
+
+                /* Characters seem to be in MacRoman encoding. */
+
+                if (c != 0 && c != 0x0010) {
+                    k[j] = ucs2keysym (macroman2ucs (c & 255));
+
+                    if (state != 0) k[j] = make_dead_key (k[j]);
+                }
+            }
+        }
+	
+        if (k[3] == k[2]) k[3] = NoSymbol;
+        if (k[2] == k[1]) k[2] = NoSymbol;
+        if (k[1] == k[0]) k[1] = NoSymbol;
+        if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol;
+    }
+
+    /* Fix up some things that are normally missing.. */
+
+    if (HACK_MISSING) {
+        for (i = 0; i < sizeof (known_keys) / sizeof (known_keys[0]); i++) {
+            k = info->keyMap + known_keys[i].keycode * GLYPHS_PER_KEY;
+
+            if    (k[0] == NoSymbol && k[1] == NoSymbol
+                && k[2] == NoSymbol && k[3] == NoSymbol)
+	      k[0] = known_keys[i].keysym;
+        }
+    }
+
+    /* And some more things. We find the right symbols for the numeric
+       keypad, but not the KP_ keysyms. So try to convert known keycodes. */
+
+    if (HACK_KEYPAD) {
+        for (i = 0; i < sizeof (known_numeric_keys)
+                        / sizeof (known_numeric_keys[0]); i++) {
+            k = info->keyMap + known_numeric_keys[i].keycode * GLYPHS_PER_KEY;
+
+            if (k[0] == known_numeric_keys[i].normal)
+                k[0] = known_numeric_keys[i].keypad;
+        }
+    }
+    if(currentKeyLayoutRef)	CFRelease(currentKeyLayoutRef);
+    
+    return TRUE;
+}
diff --git a/hw/xquartz/quartzKeyboard.h b/hw/xquartz/quartzKeyboard.h
new file mode 100644
index 0000000..f27fcde
--- /dev/null
+++ b/hw/xquartz/quartzKeyboard.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2003-2004 Torrey T. Lyons. 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
+ * 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 QUARTZ_KEYBOARD_H
+#define QUARTZ_KEYBOARD_H 1
+
+#define XK_TECHNICAL		// needed to get XK_Escape
+#define XK_PUBLISHING
+#include "X11/keysym.h"
+#include "inputstr.h"
+
+// Each key can generate 4 glyphs. They are, in order:
+// unshifted, shifted, modeswitch unshifted, modeswitch shifted
+#define GLYPHS_PER_KEY  4
+#define NUM_KEYCODES    248	// NX_NUMKEYCODES might be better
+#define MAX_KEYCODE     NUM_KEYCODES + MIN_KEYCODE - 1
+
+typedef struct darwinKeyboardInfo_struct {
+    CARD8 modMap[MAP_LENGTH];
+    KeySym keyMap[MAP_LENGTH * GLYPHS_PER_KEY];
+    unsigned char modifierKeycodes[32][2];
+} darwinKeyboardInfo;
+
+/* These functions need to be implemented by XQuartz, XDarwin, etc. */
+void DarwinKeyboardReload(DeviceIntPtr pDev);
+Bool DarwinModeReadSystemKeymap(darwinKeyboardInfo *info);
+unsigned int DarwinModeSystemKeymapSeed(void);
+
+#endif /* QUARTZ_KEYBOARD_H */
diff --git a/hw/xquartz/quartzPasteboard.c b/hw/xquartz/quartzPasteboard.c
new file mode 100644
index 0000000..0cecff5
--- /dev/null
+++ b/hw/xquartz/quartzPasteboard.c
@@ -0,0 +1,153 @@
+/**************************************************************
+ * quartzPasteboard.c
+ *
+ * Aqua pasteboard <-> X cut buffer
+ * Greg Parker     gparker at cs.stanford.edu     March 8, 2001
+ **************************************************************/
+/*
+ * Copyright (c) 2001 Greg Parker. 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
+ * 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "quartzPasteboard.h"
+
+#include <X11/Xatom.h>
+#include "windowstr.h"
+#include "propertyst.h"
+#include "scrnintstr.h"
+#include "selection.h"
+#include "globals.h"
+
+extern Selection *CurrentSelections;
+extern int NumCurrentSelections;
+
+
+// Helper function to read the X11 cut buffer
+// FIXME: What about multiple screens? Currently, this reads the first
+// CUT_BUFFER0 from the first screen where the buffer content is a string.
+// Returns a string on the heap that the caller must free.
+// Returns NULL if there is no cut text or there is not enough memory.
+static char * QuartzReadCutBuffer(void)
+{
+    int i;
+    char *text = NULL;
+
+    for (i = 0; i < screenInfo.numScreens; i++) {
+        ScreenPtr pScreen = screenInfo.screens[i];
+        PropertyPtr pProp;
+
+        pProp = wUserProps (WindowTable[pScreen->myNum]);
+        while (pProp && pProp->propertyName != XA_CUT_BUFFER0) {
+	    pProp = pProp->next;
+        }
+        if (! pProp) continue;
+        if (pProp->type != XA_STRING) continue;
+        if (pProp->format != 8) continue;
+
+        text = xalloc(1 + pProp->size);
+        if (! text) continue;
+        memcpy(text, pProp->data, pProp->size);
+        text[pProp->size] = '\0';
+        return text;
+    }
+
+    // didn't find any text
+    return NULL;
+}
+
+// Write X cut buffer to Mac OS X pasteboard
+// Called by ProcessInputEvents() in response to request from X server thread.
+void QuartzWritePasteboard(void)
+{
+    char *text;
+    text = QuartzReadCutBuffer();
+    if (text) {
+        QuartzWriteCocoaPasteboard(text);
+        free(text);
+    }
+}
+
+#define strequal(a, b) (0 == strcmp((a), (b)))
+
+// Read Mac OS X pasteboard into X cut buffer
+// Called by ProcessInputEvents() in response to request from X server thread.
+void QuartzReadPasteboard(void)
+{
+    char *oldText = QuartzReadCutBuffer();
+    char *text = QuartzReadCocoaPasteboard();
+
+    // Compare text with current cut buffer contents.
+    // Change the buffer if both exist and are different
+    //   OR if there is new text but no old text.
+    // Otherwise, don't clear the selection unnecessarily.
+
+    if ((text && oldText && !strequal(text, oldText)) ||
+        (text && !oldText)) {
+        int scrn, sel;
+
+        for (scrn = 0; scrn < screenInfo.numScreens; scrn++) {
+	    ScreenPtr pScreen = screenInfo.screens[scrn];
+	    // Set the cut buffers on each screen
+	    // fixme really on each screen?
+	    ChangeWindowProperty(WindowTable[pScreen->myNum], XA_CUT_BUFFER0,
+				 XA_STRING, 8, PropModeReplace,
+				 strlen(text), (pointer)text, TRUE);
+        }
+
+        // Undo any current X selection (similar to code in dispatch.c)
+        // FIXME: what about secondary selection?
+        // FIXME: only touch first XA_PRIMARY selection?
+        sel = 0;
+        while ((sel < NumCurrentSelections)  &&
+	       CurrentSelections[sel].selection != XA_PRIMARY)
+	    sel++;
+        if (sel < NumCurrentSelections) {
+	    // Notify client if necessary
+	    if (CurrentSelections[sel].client) {
+	        xEvent event;
+
+	        event.u.u.type = SelectionClear;
+		event.u.selectionClear.time = GetTimeInMillis();
+		event.u.selectionClear.window = CurrentSelections[sel].window;
+		event.u.selectionClear.atom = CurrentSelections[sel].selection;
+		TryClientEvents(CurrentSelections[sel].client, &event, 1,
+				NoEventMask, NoEventMask /*CantBeFiltered*/,
+				NullGrab);
+	    }
+
+	    // Erase it
+	    // FIXME: need to erase .selection too? dispatch.c doesn't
+	    CurrentSelections[sel].pWin = NullWindow;
+	    CurrentSelections[sel].window = None;
+	    CurrentSelections[sel].client = NullClient;
+        }
+    }
+
+    if (text) free(text);
+    if (oldText) free(oldText);
+}
diff --git a/hw/xquartz/quartzPasteboard.h b/hw/xquartz/quartzPasteboard.h
new file mode 100644
index 0000000..afcb6e5
--- /dev/null
+++ b/hw/xquartz/quartzPasteboard.h
@@ -0,0 +1,44 @@
+/* 
+   QuartzPasteboard.h
+
+   Mac OS X pasteboard <-> X cut buffer
+   Greg Parker     gparker at cs.stanford.edu     March 8, 2001
+*/
+/*
+ * Copyright (c) 2001 Greg Parker. 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
+ * 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 _QUARTZPASTEBOARD_H
+#define _QUARTZPASTEBOARD_H
+
+// Aqua->X 
+void QuartzReadPasteboard();
+char * QuartzReadCocoaPasteboard(void);	// caller must free string
+
+// X->Aqua
+void QuartzWritePasteboard();
+void QuartzWriteCocoaPasteboard(char *text);
+
+#endif	/* _QUARTZPASTEBOARD_H */
diff --git a/hw/xquartz/quartzStartup.c b/hw/xquartz/quartzStartup.c
new file mode 100644
index 0000000..e20c16b
--- /dev/null
+++ b/hw/xquartz/quartzStartup.c
@@ -0,0 +1,129 @@
+/**************************************************************
+ *
+ * Startup code for the Quartz Darwin X Server
+ *
+ * Copyright (c) 2001-2004 Torrey T. Lyons. 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
+ * 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <fcntl.h>
+#include <unistd.h>
+#include <CoreFoundation/CoreFoundation.h>
+#include "quartzCommon.h"
+#include "darwin.h"
+#include "quartz.h"
+#include "opaque.h"
+#include "micmap.h"
+
+#ifdef NDEBUG
+#undef NDEBUG
+#include <assert.h>
+#define NDEBUG 1
+#else
+#include <assert.h>
+#endif
+
+char **envpGlobal;      // argcGlobal and argvGlobal
+                        // are from dix/globals.c
+
+
+void X11ControllerMain(int argc, char *argv[], void (*server_thread) (void *), void *server_arg);
+
+static void server_thread (void *arg) {
+  extern int main(int argc, char **argv, char **envp);
+  exit (main (argcGlobal, argvGlobal, envpGlobal));
+}
+
+/*
+ * DarwinHandleGUI
+ *  This function is called first from main(). The first time
+ *  it is called we start the Mac OS X front end. The front end
+ *  will call main() again from another thread to run the X
+ *  server. On the second call this function loads the user
+ *  preferences set by the Mac OS X front end.
+ */
+void DarwinHandleGUI(
+    int         argc,
+    char        *argv[],
+    char        *envp[] )
+{
+    static Bool been_here = FALSE;
+    int         i;
+    int         fd[2];
+
+    if (been_here) {
+        return;
+    }
+    been_here = TRUE;
+
+    // Make a pipe to pass events
+    assert( pipe(fd) == 0 );
+    darwinEventReadFD = fd[0];
+    darwinEventWriteFD = fd[1];
+    fcntl(darwinEventReadFD, F_SETFL, O_NONBLOCK);
+
+    // Store command line arguments to pass back to main()
+    argcGlobal = argc;
+    argvGlobal = argv;
+    envpGlobal = envp;
+
+    quartzStartClients = 1;
+    for (i = 1; i < argc; i++) {
+        // Display version info without starting Mac OS X UI if requested
+        if (!strcmp( argv[i], "-showconfig" ) || !strcmp( argv[i], "-version" )) {
+            DarwinPrintBanner();
+            exit(0);
+        }
+
+        // Determine if we need to start X clients
+        // and what display mode to use
+        if (!strcmp(argv[i], "-nostartx")) {
+            quartzStartClients = 0;    
+        } else if (!strcmp( argv[i], "-fullscreen")) {
+            quartzRootless = 0;
+        } else if (!strcmp( argv[i], "-rootless")) {
+            quartzRootless = 1;
+        }
+    }
+
+
+    /* Initially I ran the X server on the main thread, and received
+       events on the second thread. But now we may be using Carbon,
+       that needs to run on the main thread. (Otherwise, when it's
+       prebound, it will initialize itself on the wrong thread)
+       
+       grr.. but doing that means that if the X thread gets scheduled
+       before the main thread when we're _not_ prebound, things fail,
+       so initialize by hand. */
+
+    extern void _InitHLTB(void);
+    
+    _InitHLTB();    
+    X11ControllerMain(argc, argv, server_thread, NULL);
+    exit(0);
+}
diff --git a/hw/xquartz/xpr/Makefile.am b/hw/xquartz/xpr/Makefile.am
new file mode 100644
index 0000000..3cc2aba
--- /dev/null
+++ b/hw/xquartz/xpr/Makefile.am
@@ -0,0 +1,70 @@
+bin_PROGRAMS = Xquartz
+
+# TODO: This man page needs sed magic and cleanup
+man1_MANS = Xquartz.man
+
+AM_CFLAGS =  $(XSERVER_CFLAGS) $(DIX_CFLAGS)
+AM_CPPFLAGS = \
+	-I$(srcdir) -I$(srcdir)/.. \
+	-I$(top_srcdir)/miext \
+	-I$(top_srcdir)/miext/rootless \
+	-I$(top_srcdir)/miext/rootless/safeAlpha
+
+Xquartz_SOURCES = \
+	appledri.c \
+	dri.c \
+	xprAppleWM.c \
+	xprCursor.c \
+	xprFrame.c \
+	xprScreen.c \
+	x-hash.c \
+	x-hook.c \
+	x-list.c
+
+Xquartz_LDADD = \
+	$(top_builddir)/hw/xquartz/libXquartz.la \
+	$(top_builddir)/dix/dixfonts.lo \
+	$(top_builddir)/dix/libdix.la \
+	$(top_builddir)/os/libos.la \
+	$(top_builddir)/dix/libxpstubs.la \
+	$(top_builddir)/miext/shadow/libshadow.la \
+	$(top_builddir)/fb/libfb.la \
+	$(top_builddir)/mi/libmi.la \
+	$(top_builddir)/composite/libcomposite.la \
+	$(top_builddir)/damageext/libdamageext.la \
+	$(top_builddir)/miext/damage/libdamage.la \
+	$(top_builddir)/xfixes/libxfixes.la \
+	$(top_builddir)/miext/cw/libcw.la \
+	$(top_builddir)/Xext/libXext.la \
+	$(top_builddir)/xkb/libxkb.la \
+	$(top_builddir)/xkb/libxkbstubs.la \
+	$(top_builddir)/Xi/libXi.la \
+	$(top_builddir)/dbe/libdbe.la \
+	$(top_builddir)/record/librecord.la \
+	$(top_builddir)/XTrap/libxtrap.la \
+	$(top_builddir)/miext/rootless/librootless.la \
+	$(top_builddir)/miext/rootless/safeAlpha/libsafeAlpha.la \
+	$(top_builddir)/miext/rootless/accel/librlAccel.la \
+	$(DARWIN_LIBS) $(XSERVER_LIBS) $(XSERVER_SYS_LIBS) -lXplugin
+
+Xquartz_LDFLAGS =  \
+	-XCClinker -Objc \
+	-Wl,-u,_miDCInitialize \
+	-Wl,-framework,Carbon \
+	-L/System/Library/Frameworks/OpenGL.framework/Libraries -lGL \
+	-Wl,-framework,OpenGL \
+	-Wl,-framework,Cocoa \
+	-Wl,-framework,CoreAudio \
+	-Wl,-framework,IOKit
+
+EXTRA_DIST = \
+	Xquartz.man \
+	dri.h \
+	dristruct.h \
+	appledri.h \
+	appledristr.h \
+	x-hash.h \
+	x-hook.h \
+	x-list.h \
+	Xplugin.h \
+	xpr.h
diff --git a/hw/xquartz/xpr/Xplugin.h b/hw/xquartz/xpr/Xplugin.h
new file mode 100644
index 0000000..a10b1b8
--- /dev/null
+++ b/hw/xquartz/xpr/Xplugin.h
@@ -0,0 +1,589 @@
+/* Xplugin.h -- windowing API for rootless X11 server
+
+   Copyright (c) 2002 Apple Computer, Inc. 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 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.
+
+   Note that these interfaces are provided solely for the use of the
+   X11 server. Any other uses are unsupported and strongly discouraged. */
+
+#ifndef XPLUGIN_H
+#define XPLUGIN_H 1
+
+#include <stdint.h>
+
+/* By default we use the X server definition of BoxRec to define xp_box,
+   so that the compiler can silently convert between the two. But if
+   XP_NO_X_HEADERS is defined, we'll define it ourselves. */
+
+#ifndef XP_NO_X_HEADERS
+# include "miscstruct.h"
+  typedef BoxRec xp_box;
+#else
+  struct xp_box_struct {
+      short x1, y1, x2, y2;
+  };
+  typedef struct xp_box_struct xp_box;
+#endif
+
+typedef unsigned int xp_resource_id;
+typedef xp_resource_id xp_window_id;
+typedef xp_resource_id xp_surface_id;
+typedef unsigned int xp_client_id;
+typedef unsigned int xp_request_type;
+typedef int xp_error;
+typedef int xp_bool;
+
+
+/* Error codes that the functions declared here may return. They all
+   numerically match their X equivalents, i.e. the XP_ can be dropped
+   if <X11/X.h> has been included. */
+
+enum xp_error_enum {
+    XP_Success			= 0,
+    XP_BadRequest		= 1,
+    XP_BadValue			= 2,
+    XP_BadWindow		= 3,
+    XP_BadMatch			= 8,
+    XP_BadAccess		= 10,
+    XP_BadImplementation	= 17,
+};    
+
+
+/* Event types generated by the plugin. */
+
+enum xp_event_type_enum {
+    /* The global display configuration changed somehow. */
+    XP_EVENT_DISPLAY_CHANGED	= 1 << 0,
+
+    /* A window changed state. Argument is xp_window_state_event */
+    XP_EVENT_WINDOW_STATE_CHANGED = 1 << 1,
+
+    /* An async request encountered an error. Argument is of type
+       xp_async_error_event */
+    XP_EVENT_ASYNC_ERROR	= 1 << 2,
+
+    /* Sent when a surface is destroyed as a side effect of destroying
+       a window. Arg is of type xp_surface_id. */
+    XP_EVENT_SURFACE_DESTROYED	= 1 << 3,
+
+    /* Sent when any GL contexts pointing at the given surface need to
+       call xp_update_gl_context () to refresh their state (because the
+       window moved or was resized. Arg is of type xp_surface_id. */
+    XP_EVENT_SURFACE_CHANGED	= 1 << 4,
+
+    /* Sent when a window has been moved. Arg is of type xp_window_id. */
+    XP_EVENT_WINDOW_MOVED	= 1 << 5,
+};
+
+/* Function type used to receive events. */
+
+typedef void (xp_event_fun) (unsigned int type, const void *arg,
+			     unsigned int arg_size, void *user_data);
+
+
+/* Operation types. Used when reporting errors asynchronously. */
+
+enum xp_request_type_enum {
+    XP_REQUEST_NIL = 0,
+    XP_REQUEST_DESTROY_WINDOW = 1,
+    XP_REQUEST_CONFIGURE_WINDOW = 2,
+    XP_REQUEST_FLUSH_WINDOW = 3,
+    XP_REQUEST_COPY_WINDOW = 4,
+    XP_REQUEST_UNLOCK_WINDOW = 5,
+    XP_REQUEST_DISABLE_UPDATE = 6,
+    XP_REQUEST_REENABLE_UPDATE = 7,
+    XP_REQUEST_HIDE_CURSOR = 8,
+    XP_REQUEST_SHOW_CURSOR = 9,
+    XP_REQUEST_FRAME_DRAW = 10,
+};
+
+/* Structure used to report an error asynchronously. Passed as the "arg"
+   of an XP_EVENT_ASYNC_ERROR event. */
+
+struct xp_async_error_event_struct {
+    xp_request_type request_type;
+    xp_resource_id id;
+    xp_error error;
+};
+
+typedef struct xp_async_error_event_struct xp_async_error_event;
+
+
+/* Possible window states. */
+
+enum xp_window_state_enum {
+    /* The window is not in the global list of possibly-visible windows. */
+    XP_WINDOW_STATE_OFFSCREEN	= 1 << 0,
+
+    /* Parts of the window may be obscured by other windows. */
+    XP_WINDOW_STATE_OBSCURED	= 1 << 1,
+};
+
+/* Structure passed as argument of an XP_EVENT_WINDOW_STATE_CHANGED event. */
+
+struct xp_window_state_event_struct {
+    xp_window_id id;
+    unsigned int state;
+};
+
+typedef struct xp_window_state_event_struct xp_window_state_event;
+
+
+/* Function type used to supply a colormap for indexed drawables. */
+
+typedef xp_error (xp_colormap_fun) (void *data, int first_color,
+				    int n_colors, uint32_t *colors);
+
+
+/* Window attributes structure. Used when creating and configuring windows.
+   Also used when configuring surfaces attached to windows. Functions that
+   take one of these structures also take a bit mask defining which
+   fields are set to meaningful values. */
+
+enum xp_window_changes_enum {
+    XP_ORIGIN			= 1 << 0,
+    XP_SIZE			= 1 << 1,
+    XP_BOUNDS			= XP_ORIGIN | XP_SIZE,
+    XP_SHAPE			= 1 << 2,
+    XP_STACKING			= 1 << 3,
+    XP_DEPTH			= 1 << 4,
+    XP_COLORMAP			= 1 << 5,
+    XP_WINDOW_LEVEL		= 1 << 6,
+};
+
+struct xp_window_changes_struct {
+    /* XP_ORIGIN */
+    int x, y;
+
+    /* XP_SIZE */
+    unsigned int width, height;
+    int bit_gravity;			/* how to resize the backing store */
+
+    /* XP_SHAPE */
+    int shape_nrects;			/* -1 = remove shape */
+    xp_box *shape_rects;
+    int shape_tx, shape_ty;		/* translation for shape */
+
+    /* XP_STACKING */
+    int stack_mode;
+    xp_window_id sibling;		/* may be zero; in ABOVE/BELOW modes
+					   it may specify a relative window */
+    /* XP_DEPTH, window-only */
+    unsigned int depth;
+
+    /* XP_COLORMAP, window-only */
+    xp_colormap_fun *colormap;
+    void *colormap_data;
+
+    /* XP_WINDOW_LEVEL, window-only */
+    int window_level;
+};
+
+typedef struct xp_window_changes_struct xp_window_changes;
+
+/* Values for bit_gravity field */
+
+enum xp_bit_gravity_enum {
+    XP_GRAVITY_NONE		= 0,	/* no gravity, fill everything */
+    XP_GRAVITY_NORTH_WEST	= 1,	/* anchor to top-left corner */
+    XP_GRAVITY_NORTH_EAST	= 2,	/* anchor to top-right corner */
+    XP_GRAVITY_SOUTH_EAST	= 3,	/* anchor to bottom-right corner */
+    XP_GRAVITY_SOUTH_WEST	= 4,	/* anchor to bottom-left corner */
+};
+
+/* Values for stack_mode field */
+
+enum xp_window_stack_mode_enum {
+    XP_UNMAPPED			= 0,	/* remove the window */
+    XP_MAPPED_ABOVE		= 1,	/* display the window on top */
+    XP_MAPPED_BELOW		= 2,	/* display the window at bottom */
+};
+
+/* Data formats for depth field and composite functions */
+
+enum xp_depth_enum {
+    XP_DEPTH_NIL = 0,			/* null source when compositing */
+    XP_DEPTH_ARGB8888,
+    XP_DEPTH_RGB555,
+    XP_DEPTH_A8,			/* for masks when compositing */
+    XP_DEPTH_INDEX8,
+};
+
+/* Options that may be passed to the xp_init () function. */
+
+enum xp_init_options_enum {
+    /* Don't mark that this process can be in the foreground. */
+    XP_IN_BACKGROUND		= 1 << 0,
+
+    /* Deliver background pointer events to this process. */
+    XP_BACKGROUND_EVENTS	= 1 << 1,
+};
+
+
+
+/* Miscellaneous functions */
+
+/* Initialize the plugin library. Only the copy/fill/composite functions
+   may be called without having previously called xp_init () */
+
+extern xp_error xp_init (unsigned int options);
+
+/* Sets the current set of requested notifications to MASK. When any of
+   these arrive, CALLBACK will be invoked with CALLBACK-DATA. Note that
+   calling this function cancels any previously requested notifications
+   that aren't set in MASK. */
+
+extern xp_error xp_select_events (unsigned int mask,
+				  xp_event_fun *callback,
+				  void *callback_data);
+
+/* Waits for all initiated operations to complete. */
+
+extern xp_error xp_synchronize (void);
+
+/* Causes any display update initiated through the plugin libary to be
+   queued until update is reenabled. Note that calls to these functions
+   nest. */
+  
+extern xp_error xp_disable_update (void);
+extern xp_error xp_reenable_update (void);
+
+
+
+/* Cursor functions. */
+
+/* Installs the specified cursor. ARGB-DATA should point to 32-bit
+   premultiplied big-endian ARGB data. The HOT-X,HOT-Y parameters
+   specify the offset to the cursor's hot spot from its top-left
+   corner. */
+
+extern xp_error xp_set_cursor (unsigned int width, unsigned int height,
+			       unsigned int hot_x, unsigned int hot_y,
+			       const uint32_t *argb_data,
+			       unsigned int rowbytes);
+
+/* Hide and show the cursor if it's owned by the current process. Calls
+   to these functions nest. */
+
+extern xp_error xp_hide_cursor (void);
+extern xp_error xp_show_cursor (void);
+
+
+
+/* Window functions. */
+
+/* Create a new window as defined by MASK and VALUES. MASK must contain
+   XP_BOUNDS or an error is raised. The id of the newly created window
+   is stored in *RET-ID if this function returns XP_Success. */
+
+extern xp_error xp_create_window (unsigned int mask,
+				  const xp_window_changes *values,
+				  xp_window_id *ret_id);
+
+/* Destroys the window identified by ID. */
+
+extern xp_error xp_destroy_window (xp_window_id id);
+
+/* Reconfigures the given window according to MASK and VALUES. */
+
+extern xp_error xp_configure_window (xp_window_id id, unsigned int mask,
+				     const xp_window_changes *values);
+
+
+/* Returns true if NATIVE-ID is a window created by the plugin library.
+   If so and RET-ID is non-null, stores the id of the window in *RET-ID. */
+
+extern xp_bool xp_lookup_native_window (unsigned int native_id,
+					xp_window_id *ret_id);
+
+/* If ID names a window created by the plugin library, stores it's native
+   window id in *RET-NATIVE-ID. */
+
+extern xp_error xp_get_native_window (xp_window_id id,
+				      unsigned int *ret_native_id);
+
+
+/* Locks the rectangle IN-RECT (or, if null, the entire window) of the
+   given window's backing store. Any other non-null parameters are filled
+   in as follows:
+
+   DEPTH = format of returned data. Currently either XP_DEPTH_ARGB8888
+   or XP_DEPTH_RGB565 (possibly with 8 bit planar alpha). Data is
+   always stored in native byte order.
+
+   BITS[0] = pointer to top-left pixel of locked color data
+   BITS[1] = pointer to top-left of locked alpha data, or null if window
+   has no alpha. If the alpha data is meshed, then BITS[1] = BITS[0].
+
+   ROWBYTES[0,1] = size in bytes of each row of color,alpha data
+
+   OUT-RECT = rectangle specifying the current position and size of the
+   locked region relative to the window origin.
+
+   Note that an error is raised when trying to lock an already locked
+   window. While the window is locked, the only operations that may
+   be performed on it are to modify, access or flush its marked region. */
+
+extern xp_error xp_lock_window (xp_window_id id,
+				const xp_box *in_rect,
+				unsigned int *depth,
+				void *bits[2],
+				unsigned int rowbytes[2],
+				xp_box *out_rect);
+
+/* Mark that the region specified by SHAPE-NRECTS, SHAPE-RECTS,
+   SHAPE-TX, and SHAPE-TY in the specified window has been updated, and
+   will need to subsequently be redisplayed. */
+
+extern xp_error xp_mark_window (xp_window_id id, int shape_nrects,
+				const xp_box *shape_rects,
+				int shape_tx, int shape_ty);
+
+/* Unlocks the specified window. If FLUSH is true, then any marked
+   regions are immediately redisplayed. Note that it's an error to
+   unlock an already unlocked window. */
+
+extern xp_error xp_unlock_window (xp_window_id id, xp_bool flush);
+
+/* If anything is marked in the given window for redisplay, do it now. */
+
+extern xp_error xp_flush_window (xp_window_id id);
+
+/* Moves the contents of the region DX,DY pixels away from that specified
+   by DST_RECTS and DST_NRECTS in the window with SRC-ID to the
+   destination region in the window DST-ID. Note that currently source
+   and destination windows must be the same. */
+
+extern xp_error xp_copy_window (xp_window_id src_id, xp_window_id dst_id,
+				int dst_nrects, const xp_box *dst_rects,
+				int dx, int dy);
+
+/* Returns true if the given window has any regions marked for
+   redisplay. */
+
+extern xp_bool xp_is_window_marked (xp_window_id id);
+
+/* If successful returns a superset of the region marked for update in
+   the given window. Use xp_free_region () to release the returned data. */
+
+extern xp_error xp_get_marked_shape (xp_window_id id,
+				     int *ret_nrects, xp_box **ret_rects);
+
+extern void xp_free_shape (int nrects, xp_box *rects);
+
+/* Searches for the first window below ABOVE-ID containing the point X,Y,
+   and returns it's window id in *RET-ID. If no window is found, *RET-ID
+   is set to zero. If ABOVE-ID is zero, finds the topmost window
+   containing the given point. */
+
+extern xp_error xp_find_window (int x, int y, xp_window_id above_id,
+				xp_window_id *ret_id);
+
+/* Returns the current origin and size of the window ID in *BOUNDS-RET if
+   successful. */
+extern xp_error xp_get_window_bounds (xp_window_id id, xp_box *bounds_ret);
+
+
+
+/* Window surface functions. */
+
+/* Create a new VRAM surface on the specified window. If successful,
+   returns the identifier of the new surface in *RET-SID. */
+
+extern xp_error xp_create_surface (xp_window_id id, xp_surface_id *ret_sid);
+
+/* Destroys the specified surface. */
+
+extern xp_error xp_destroy_surface (xp_surface_id sid);
+
+/* Reconfigures the specified surface as defined by MASK and VALUES.
+   Note that specifying XP_DEPTH is an error. */
+
+extern xp_error xp_configure_surface (xp_surface_id sid, unsigned int mask,
+				      const xp_window_changes *values);
+
+/* If successful, places the client identifier of the current process
+   in *RET-CLIENT. */
+
+extern xp_error xp_get_client_id (xp_client_id *ret_client);
+
+/* Given a valid window,surface combination created by the current
+   process, attempts to allow the specified external client access
+   to that surface. If successful, returns two integers in RET-KEY
+   which the client can use to import the surface into their process. */
+
+extern xp_error xp_export_surface (xp_window_id wid, xp_surface_id sid,
+				   xp_client_id client,
+				   unsigned int ret_key[2]);
+
+/* Given a two integer key returned from xp_export_surface (), tries
+   to import the surface into the current process. If successful the
+   local surface identifier is stored in *SID-RET. */
+
+extern xp_error xp_import_surface (const unsigned int key[2],
+				   xp_surface_id *sid_ret);
+
+/* If successful, stores the number of surfaces attached to the
+   specified window in *RET. */
+
+extern xp_error xp_get_window_surface_count (xp_window_id id,
+					     unsigned int *ret);
+
+/* Attaches the CGLContextObj CGL-CTX to the specified surface. */
+
+extern xp_error xp_attach_gl_context (void *cgl_ctx, xp_surface_id sid);
+
+/* Updates the CGLContextObj CGL-CTX to reflect any recent changes to
+   the surface it's attached to. */
+
+extern xp_error xp_update_gl_context (void *cgl_ctx);
+
+
+
+/* Window frame functions. */
+
+/* Possible arguments to xp_frame_get_rect (). */
+
+enum xp_frame_rect_enum {
+    XP_FRAME_RECT_TITLEBAR		= 1,
+    XP_FRAME_RECT_TRACKING		= 2,
+    XP_FRAME_RECT_GROWBOX		= 3,
+};
+
+/* Classes of window frame. */
+
+enum xp_frame_class_enum {
+    XP_FRAME_CLASS_DOCUMENT		= 1 << 0,
+    XP_FRAME_CLASS_DIALOG		= 1 << 1,
+    XP_FRAME_CLASS_MODAL_DIALOG		= 1 << 2,
+    XP_FRAME_CLASS_SYSTEM_MODAL_DIALOG	= 1 << 3,
+    XP_FRAME_CLASS_UTILITY		= 1 << 4,
+    XP_FRAME_CLASS_TOOLBAR		= 1 << 5,
+    XP_FRAME_CLASS_MENU			= 1 << 6,
+    XP_FRAME_CLASS_SPLASH		= 1 << 7,
+    XP_FRAME_CLASS_BORDERLESS		= 1 << 8,
+};
+
+/* Attributes of window frames. */
+
+enum xp_frame_attr_enum {
+    XP_FRAME_ACTIVE			= 0x0001,
+    XP_FRAME_URGENT			= 0x0002,
+    XP_FRAME_TITLE			= 0x0004,
+    XP_FRAME_PRELIGHT			= 0x0008,
+    XP_FRAME_SHADED			= 0x0010,
+    XP_FRAME_CLOSE_BOX			= 0x0100,
+    XP_FRAME_COLLAPSE			= 0x0200,
+    XP_FRAME_ZOOM			= 0x0400,
+    XP_FRAME_ANY_BUTTON			= 0x0700,
+    XP_FRAME_CLOSE_BOX_CLICKED		= 0x0800,
+    XP_FRAME_COLLAPSE_BOX_CLICKED	= 0x1000,
+    XP_FRAME_ZOOM_BOX_CLICKED		= 0x2000,
+    XP_FRAME_ANY_CLICKED		= 0x3800,
+    XP_FRAME_GROW_BOX			= 0x4000,
+};
+
+#define XP_FRAME_ATTR_IS_SET(a,b)	(((a) & (b)) == (b))
+#define XP_FRAME_ATTR_IS_CLICKED(a,m)	((a) & ((m) << 3))
+#define XP_FRAME_ATTR_SET_CLICKED(a,m)	((a) |= ((m) << 3))
+#define XP_FRAME_ATTR_UNSET_CLICKED(a,m) ((a) &= ~((m) << 3))
+
+#define XP_FRAME_POINTER_ATTRS		(XP_FRAME_PRELIGHT		\
+					 | XP_FRAME_ANY_BUTTON		\
+					 | XP_FRAME_ANY_CLICKED)
+
+extern xp_error xp_frame_get_rect (int type, int class, const xp_box *outer,
+				   const xp_box *inner, xp_box *ret);
+extern xp_error xp_frame_hit_test (int class, int x, int y,
+				   const xp_box *outer,
+				   const xp_box *inner, int *ret);
+extern xp_error xp_frame_draw (xp_window_id wid, int class, unsigned int attr,
+			       const xp_box *outer, const xp_box *inner,
+			       unsigned int title_len,
+			       const unsigned char *title_bytes);
+
+
+
+/* Memory manipulation functions. */
+
+enum xp_composite_op_enum {
+    XP_COMPOSITE_SRC = 0,
+    XP_COMPOSITE_OVER,
+};
+
+#define XP_COMPOSITE_FUNCTION(op, src_depth, mask_depth, dest_depth) \
+    (((op) << 24) | ((src_depth) << 16) \
+     | ((mask_depth) << 8) | ((dest_depth) << 0))
+
+#define XP_COMPOSITE_FUNCTION_OP(f)         (((f) >> 24) & 255)
+#define XP_COMPOSITE_FUNCTION_SRC_DEPTH(f)  (((f) >> 16) & 255)
+#define XP_COMPOSITE_FUNCTION_MASK_DEPTH(f) (((f) >>  8) & 255)
+#define XP_COMPOSITE_FUNCTION_DEST_DEPTH(f) (((f) >>  0) & 255)
+
+/* Composite WIDTH by HEIGHT pixels from source and mask to destination
+   using a specified function (if source and destination overlap,
+   undefined behavior results).
+
+   For SRC and DEST, the first element of the array is the color data. If
+   the second element is non-null it implies that there is alpha data
+   (which may be meshed or planar). Data without alpha is assumed to be
+   opaque.
+
+   Passing a null SRC-ROWBYTES pointer implies that the data SRC points
+   to is a single element.
+
+   Operations that are not supported will return XP_BadImplementation. */
+
+extern xp_error xp_composite_pixels (unsigned int width, unsigned int height,
+				     unsigned int function,
+				     void *src[2], unsigned int src_rowbytes[2],
+				     void *mask, unsigned int mask_rowbytes,
+				     void *dest[2], unsigned int dest_rowbytes[2]);
+
+/* Fill HEIGHT rows of data starting at DST. Each row will have WIDTH
+   bytes filled with the 32-bit pattern VALUE. Each row is DST-ROWBYTES
+   wide in total. */
+
+extern void xp_fill_bytes (unsigned int width,
+			   unsigned int height, uint32_t value,
+			   void *dst, unsigned int dst_rowbytes);
+
+/* Copy HEIGHT rows of bytes from SRC to DST. Each row will have WIDTH
+   bytes copied. SRC and DST may overlap, and the right thing will happen. */
+
+extern void xp_copy_bytes (unsigned int width, unsigned int height,
+			   const void *src, unsigned int src_rowbytes,
+			   void *dst, unsigned int dst_rowbytes);
+
+/* Suggestions for the minimum number of bytes or pixels for which it
+   makes sense to use some of the xp_ functions */
+
+extern unsigned int xp_fill_bytes_threshold, xp_copy_bytes_threshold,
+    xp_composite_area_threshold, xp_scroll_area_threshold;
+
+
+#endif /* XPLUGIN_H */
diff --git a/hw/xquartz/xpr/Xquartz.man b/hw/xquartz/xpr/Xquartz.man
new file mode 100644
index 0000000..37a7f1a
--- /dev/null
+++ b/hw/xquartz/xpr/Xquartz.man
@@ -0,0 +1,156 @@
+.TH XQUARTZ 1 __vendorversion__
+.SH NAME
+Xquartz \- X window system server for Quartz operating system
+.SH SYNOPSIS
+.B Xquartz
+[ options ] ...
+.SH DESCRIPTION
+.I Xquartz
+is the X window server for Mac OS X provided by Apple.
+.I Xquartz
+runs in parallel with Aqua in rootless mode. In rootless mode, the X
+window system and Mac OS X share your display.  The root window of the
+X11 display is the size of the screen and contains all the other
+windows. The X11 root window is not displayed in rootless mode as Mac
+OS X handles the desktop background.
+.SH OPTIONS
+.PP
+In addition to the normal server options described in the \fIXserver(1)\fP
+manual page, \fIXquartz\fP accepts the following command line switches:
+.TP 8
+.B \-fakebuttons
+Emulates a 3 button mouse using modifier keys. By default, the Command modifier
+is used to emulate button 2 and Option is used for button 3. Thus, clicking the
+first mouse button while holding down Command will act like clicking
+button 2. Holding down Option will simulate button 3.
+.TP 8
+.B \-nofakebuttons
+Do not emulate a 3 button mouse. This is the default.
+.TP 8
+.B "\-fakemouse2 \fImodifiers\fP"
+Change the modifier keys used to emulate the second mouse button. By default,
+Command is used to emulate the second button. Any combination of the following
+modifier names may be used: Shift, Option, Control, Command, Fn. For example,
+.B \-fakemouse2 """Option,Shift""
+will set holding Option, Shift and clicking on button one as equivalent to
+clicking the second mouse button.
+.TP 8
+.B "\-fakemouse3 \fImodifiers\fP"
+Change the modifier keys used to emulate the third mouse button. By default,
+Option is used to emulate the third button. Any combination of the following
+modifier names may be used: Shift, Option, Control, Command, Fn. For example,
+.B \-fakemouse3 """Control,Shift""
+will set holding Control, Shift and clicking on button one as equivalent to
+clicking the third mouse button.
+.TP 8
+.B "\-swapAltMeta"
+Swaps the meaning of the Alt and Meta modifier keys.
+.TP 8
+.B "\-keymap \fIfile\fP"
+On startup \fIXquartz\fP translates a Darwin keymapping into an X keymap.
+The default is to read this keymapping from USA.keymapping. With this option
+the keymapping will be read from \fIfile\fP instead. If the file's path is
+not specified, it will be searched for in Library/Keyboards/ underneath the
+following directories (in order): ~, /, /Network, /System.
+.TP 8
+.B \-nokeymap
+On startup \fIXquartz\fP translates a Darwin keymapping into an X keymap.
+With this option \fIXquartz\fP queries the kernel for the current keymapping
+instead of reading it from a file. This will often fail on newer kernels.
+.TP 8
+.B "\-depth \fIdepth\fP"
+Specifies the color bit depth to use. Currently only 15, and 24 color
+bits per pixel are supported. If not specified, defaults to the depth
+of the main display.
+.SH CUSTOMIZATION
+\fIXquartz\fP can also be customized using the defaults(1) command. The available options are:
+.TP 8
+.B defaults write com.apple.x11 enable_fake_buttons -boolean true
+Equivalent to the \fB-fakebuttons\fP command line option.
+.TP 8
+.B defaults write com.apple.x11 fake_button2 \fImodifiers\fP
+Equivalent to the \fB-fakemouse2\fP option.
+.TP 8
+.B defaults write com.apple.x11 fake_button3 \fImodifiers\fP
+Equivalent to the \fB-fakemouse3\fP option.
+.TP 8
+.B defaults write com.apple.x11 swap_alt_meta -boolean true
+Equivalent to the \fB-swapAltMeta\fP option.
+.TP 8
+.B defaults write com.apple.x11 keymap_file \fIfilename\fP
+Equivalent to the \fB-keymap\fP option.
+.TP 8
+.B defaults write com.apple.x11 no_quit_alert -boolean true
+Disables the alert dialog displayed when attempting to quit X11.
+.TP 8
+.B defaults write com.apple.x11 no_auth -boolean true
+Stops the X server requiring that clients authenticate themselves when
+connecting. See Xsecurity(__miscmansuffix__).
+.TP 8
+.B defaults write com.apple.x11 nolisten_tcp -boolean true
+Prevents the X server accepting remote connections.
+.TP 8
+.B defaults write com.apple.x11 xinit_kills_server -boolean false
+Stops the X server exiting when the xinitrc script terminates.
+.TP 8
+.B defaults write com.apple.x11 fullscreen_hotkeys -boolean false
+Allows system hotkeys to be handled while in X11 fullscreen mode.
+.TP 8
+.B defaults write com.apple.x11 enable_system_beep -boolean false
+Don't use the standard system beep effect for X11 alerts.
+.TP 8
+.B defaults write com.apple.x11 enable_key_equivalents -boolean false
+Disable menu keyboard equivalents while X11 windows are focused.
+.TP 8
+.B defaults write com.apple.x11 depth \fIdepth\fP
+Equivalent to the \fB-depth\fP option.
+.SH "SEE ALSO"
+.PP
+X(__miscmansuffix__), XFree86(1), Xserver(1), xdm(1), xinit(1)
+.PP
+.SH AUTHORS
+XFree86 was originally ported to Mac OS X Server by John Carmack. Dave
+Zarzycki used this as the basis of his port of XFree86 4.0 to Darwin 1.0.
+Torrey T. Lyons improved and integrated this code into the XFree86
+Project's mainline for the 4.0.2 release.
+.PP
+The following members of the XonX Team contributed to the following
+releases (in alphabetical order):
+.TP 4
+XFree86 4.1.0:
+.br
+Rob Braun - Darwin x86 support
+.br
+Torrey T. Lyons - Project Lead
+.br
+Andreas Monitzer - Cocoa version of XDarwin front end
+.br
+Gregory Robert Parker - Original Quartz implementation
+.br
+Christoph Pfisterer - Dynamic shared X libraries
+.br
+Toshimitsu Tanaka - Japanese localization
+.TP 4
+XFree86 4.2.0:
+.br
+Rob Braun - Darwin x86 support
+.br
+Pablo Di Noto - Spanish localization
+.br
+Paul Edens - Dutch localization
+.br
+Kyunghwan Kim - Korean localization
+.br
+Mario Klebsch - Non-US keyboard support
+.br
+Torrey T. Lyons - Project Lead
+.br
+Andreas Monitzer - German localization
+.br
+Patrik Montgomery - Swedish localization
+.br
+Greg Parker - Rootless support
+.br
+Toshimitsu Tanaka - Japanese localization
+.br
+Olivier Verdier - French localization
diff --git a/hw/xquartz/xpr/appledri.c b/hw/xquartz/xpr/appledri.c
new file mode 100644
index 0000000..95a4439
--- /dev/null
+++ b/hw/xquartz/xpr/appledri.c
@@ -0,0 +1,351 @@
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, Inc.
+Copyright (c) 2002 Apple Computer, Inc.
+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, sub license, 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 PRECISION INSIGHT AND/OR ITS 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 <martin at valinux.com>
+ *   Jens Owen <jens at valinux.com>
+ *   Rickard E. (Rik) Faith <faith at valinux.com>
+ *
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+#include "scrnintstr.h"
+#include "servermd.h"
+#define _APPLEDRI_SERVER_
+#include "appledristr.h"
+#include "swaprep.h"
+#include "dri.h"
+#include "dristruct.h"
+
+static int DRIErrorBase = 0;
+
+static DISPATCH_PROC(ProcAppleDRIDispatch);
+static DISPATCH_PROC(SProcAppleDRIDispatch);
+
+static void AppleDRIResetProc(ExtensionEntry* extEntry);
+
+static unsigned char DRIReqCode = 0;
+static int DRIEventBase = 0;
+
+static void SNotifyEvent(xAppleDRINotifyEvent *from, xAppleDRINotifyEvent *to);
+
+typedef struct _DRIEvent *DRIEventPtr;
+typedef struct _DRIEvent {
+    DRIEventPtr     next;
+    ClientPtr       client;
+    XID             clientResource;
+    unsigned int    mask;
+} DRIEventRec;
+
+
+void
+AppleDRIExtensionInit(void)
+{
+    ExtensionEntry* extEntry;
+
+    if (DRIExtensionInit() &&
+        (extEntry = AddExtension(APPLEDRINAME,
+                                 AppleDRINumberEvents,
+                                 AppleDRINumberErrors,
+                                 ProcAppleDRIDispatch,
+                                 SProcAppleDRIDispatch,
+                                 AppleDRIResetProc,
+                                 StandardMinorOpcode))) {
+        DRIReqCode = (unsigned char)extEntry->base;
+        DRIErrorBase = extEntry->errorBase;
+        DRIEventBase = extEntry->eventBase;
+        EventSwapVector[DRIEventBase] = (EventSwapPtr) SNotifyEvent;
+    }
+}
+
+/*ARGSUSED*/
+static void
+AppleDRIResetProc (
+    ExtensionEntry* extEntry
+)
+{
+    DRIReset();
+}
+
+static int
+ProcAppleDRIQueryVersion(
+    register ClientPtr client
+)
+{
+    xAppleDRIQueryVersionReply rep;
+    register int n;
+
+    REQUEST_SIZE_MATCH(xAppleDRIQueryVersionReq);
+    rep.type = X_Reply;
+    rep.length = 0;
+    rep.sequenceNumber = client->sequence;
+    rep.majorVersion = APPLE_DRI_MAJOR_VERSION;
+    rep.minorVersion = APPLE_DRI_MINOR_VERSION;
+    rep.patchVersion = APPLE_DRI_PATCH_VERSION;
+    if (client->swapped) {
+        swaps(&rep.sequenceNumber, n);
+        swapl(&rep.length, n);
+    }
+    WriteToClient(client, sizeof(xAppleDRIQueryVersionReply), (char *)&rep);
+    return (client->noClientException);
+}
+
+
+/* surfaces */
+
+static int
+ProcAppleDRIQueryDirectRenderingCapable(
+    register ClientPtr client
+)
+{
+    xAppleDRIQueryDirectRenderingCapableReply rep;
+    Bool isCapable;
+
+    REQUEST(xAppleDRIQueryDirectRenderingCapableReq);
+    REQUEST_SIZE_MATCH(xAppleDRIQueryDirectRenderingCapableReq);
+    rep.type = X_Reply;
+    rep.length = 0;
+    rep.sequenceNumber = client->sequence;
+
+    if (!DRIQueryDirectRenderingCapable( screenInfo.screens[stuff->screen], 
+                                         &isCapable)) {
+        return BadValue;
+    }
+    rep.isCapable = isCapable;
+
+    if (!LocalClient(client))
+        rep.isCapable = 0;
+
+    WriteToClient(client, 
+        sizeof(xAppleDRIQueryDirectRenderingCapableReply), (char *)&rep);
+    return (client->noClientException);
+}
+
+static int
+ProcAppleDRIAuthConnection(
+    register ClientPtr client
+)
+{
+    xAppleDRIAuthConnectionReply rep;
+    
+    REQUEST(xAppleDRIAuthConnectionReq);
+    REQUEST_SIZE_MATCH(xAppleDRIAuthConnectionReq);
+
+    rep.type = X_Reply;
+    rep.length = 0;
+    rep.sequenceNumber = client->sequence;
+    rep.authenticated = 1;
+
+    if (!DRIAuthConnection( screenInfo.screens[stuff->screen], stuff->magic)) {
+        ErrorF("Failed to authenticate %u\n", (unsigned int)stuff->magic);
+        rep.authenticated = 0;
+    }
+    WriteToClient(client, sizeof(xAppleDRIAuthConnectionReply), (char *)&rep);
+    return (client->noClientException);
+}
+
+static void surface_notify(
+    void *_arg,
+    void *data
+)
+{
+    DRISurfaceNotifyArg *arg = _arg;
+    int client_index = (int) data;
+    ClientPtr client;
+    xAppleDRINotifyEvent se;
+
+    if (client_index < 0 || client_index >= currentMaxClients)
+        return;
+
+    client = clients[client_index];
+    if (client == NULL || client == serverClient || client->clientGone)
+        return;
+
+    se.type = DRIEventBase + AppleDRISurfaceNotify;
+    se.kind = arg->kind;
+    se.arg = arg->id;
+    se.sequenceNumber = client->sequence;
+    se.time = currentTime.milliseconds;
+    WriteEventsToClient (client, 1, (xEvent *) &se);
+}
+
+static int
+ProcAppleDRICreateSurface(
+    ClientPtr client
+)
+{
+    xAppleDRICreateSurfaceReply rep;
+    DrawablePtr pDrawable;
+    xp_surface_id sid;
+    unsigned int key[2];
+    int rc;
+
+    REQUEST(xAppleDRICreateSurfaceReq);
+    REQUEST_SIZE_MATCH(xAppleDRICreateSurfaceReq);
+    rep.type = X_Reply;
+    rep.length = 0;
+    rep.sequenceNumber = client->sequence;
+
+    rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
+			   DixReadAccess);
+    if (rc != Success)
+	return rc;
+
+    rep.key_0 = rep.key_1 = rep.uid = 0;
+
+    if (!DRICreateSurface( screenInfo.screens[stuff->screen],
+                           (Drawable)stuff->drawable, pDrawable,
+                           stuff->client_id, &sid, key,
+                           surface_notify, (void *) client->index)) {
+        return BadValue;
+    }
+
+    rep.key_0 = key[0];
+    rep.key_1 = key[1];
+    rep.uid = sid;
+
+    WriteToClient(client, sizeof(xAppleDRICreateSurfaceReply), (char *)&rep);
+    return (client->noClientException);
+}
+
+static int
+ProcAppleDRIDestroySurface(
+    register ClientPtr client
+)
+{
+    REQUEST(xAppleDRIDestroySurfaceReq);
+    DrawablePtr pDrawable;
+    REQUEST_SIZE_MATCH(xAppleDRIDestroySurfaceReq);
+    int rc;
+
+    rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
+			   DixReadAccess);
+    if (rc != Success)
+	return rc;
+
+    if (!DRIDestroySurface( screenInfo.screens[stuff->screen], 
+                            (Drawable)stuff->drawable,
+                            pDrawable, NULL, NULL)) {
+        return BadValue;
+    }
+
+    return (client->noClientException);
+}
+
+
+/* dispatch */
+
+static int
+ProcAppleDRIDispatch (
+    register ClientPtr client
+)
+{
+    REQUEST(xReq);
+
+    switch (stuff->data)
+    {
+    case X_AppleDRIQueryVersion:
+        return ProcAppleDRIQueryVersion(client);
+    case X_AppleDRIQueryDirectRenderingCapable:
+        return ProcAppleDRIQueryDirectRenderingCapable(client);
+    }
+
+    if (!LocalClient(client))
+        return DRIErrorBase + AppleDRIClientNotLocal;
+
+    switch (stuff->data)
+    {
+    case X_AppleDRIAuthConnection:
+        return ProcAppleDRIAuthConnection(client);
+    case X_AppleDRICreateSurface:
+        return ProcAppleDRICreateSurface(client);
+    case X_AppleDRIDestroySurface:
+        return ProcAppleDRIDestroySurface(client);
+    default:
+        return BadRequest;
+    }
+}
+
+static void
+SNotifyEvent(
+    xAppleDRINotifyEvent *from,
+    xAppleDRINotifyEvent *to
+)
+{
+    to->type = from->type;
+    to->kind = from->kind;
+    cpswaps (from->sequenceNumber, to->sequenceNumber);
+    cpswapl (from->time, to->time);
+    cpswapl (from->arg, to->arg);
+}
+
+static int
+SProcAppleDRIQueryVersion(
+    register ClientPtr client
+)
+{
+    register int n;
+    REQUEST(xAppleDRIQueryVersionReq);
+    swaps(&stuff->length, n);
+    return ProcAppleDRIQueryVersion(client);
+}
+
+static int
+SProcAppleDRIDispatch (
+    register ClientPtr client
+)
+{
+    REQUEST(xReq);
+
+    /* It is bound to be non-local when there is byte swapping */
+    if (!LocalClient(client))
+        return DRIErrorBase + AppleDRIClientNotLocal;
+
+    /* only local clients are allowed DRI access */
+    switch (stuff->data)
+    {
+    case X_AppleDRIQueryVersion:
+        return SProcAppleDRIQueryVersion(client);
+    default:
+        return BadRequest;
+    }
+}
diff --git a/hw/xquartz/xpr/appledri.h b/hw/xquartz/xpr/appledri.h
new file mode 100644
index 0000000..c4e43be
--- /dev/null
+++ b/hw/xquartz/xpr/appledri.h
@@ -0,0 +1,106 @@
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, Inc.
+Copyright (c) 2002 Apple Computer, Inc.
+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, sub license, 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 PRECISION INSIGHT AND/OR ITS 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 <martin at valinux.com>
+ *   Jens Owen <jens at valinux.com>
+ *   Rickard E. (Rik) Faith <faith at valinux.com>
+ *
+ */
+
+#ifndef _APPLEDRI_H_
+#define _APPLEDRI_H_
+
+#include <X11/Xfuncproto.h>
+
+#define X_AppleDRIQueryVersion			0
+#define X_AppleDRIQueryDirectRenderingCapable	1
+#define X_AppleDRICreateSurface			2
+#define X_AppleDRIDestroySurface		3
+#define X_AppleDRIAuthConnection                4
+/* Requests up to and including 18 were used in a previous version */
+
+/* Events */
+#define AppleDRIObsoleteEvent1		0
+#define AppleDRIObsoleteEvent2		1
+#define AppleDRIObsoleteEvent3		2
+#define AppleDRISurfaceNotify		3
+#define AppleDRINumberEvents		4
+
+/* Errors */
+#define AppleDRIClientNotLocal		0
+#define AppleDRIOperationNotSupported	1
+#define AppleDRINumberErrors		(AppleDRIOperationNotSupported + 1)
+
+/* Kinds of SurfaceNotify events: */
+#define AppleDRISurfaceNotifyChanged	0
+#define AppleDRISurfaceNotifyDestroyed	1
+
+#ifndef _APPLEDRI_SERVER_
+
+typedef struct {
+    int	type;		    /* of event */
+    unsigned long serial;   /* # of last request processed by server */
+    Bool send_event;	    /* true if this came frome a SendEvent request */
+    Display *display;	    /* Display the event was read from */
+    Window window;	    /* window of event */
+    Time time;		    /* server timestamp when event happened */
+    int kind;		    /* subtype of event */
+    int arg;
+} XAppleDRINotifyEvent;
+
+_XFUNCPROTOBEGIN
+
+Bool XAppleDRIQueryExtension (Display *dpy, int *event_base, int *error_base);
+
+Bool XAppleDRIQueryVersion (Display *dpy, int *majorVersion,
+			    int *minorVersion, int *patchVersion);
+
+Bool XAppleDRIQueryDirectRenderingCapable (Display *dpy, int screen,
+					   Bool *isCapable);
+
+void *XAppleDRISetSurfaceNotifyHandler (void (*fun) (Display *dpy,
+						     unsigned uid, int kind));
+
+Bool XAppleDRIAuthConnection (Display *dpy, int screen, unsigned int magic);
+
+Bool XAppleDRICreateSurface (Display *dpy, int screen, Drawable drawable,
+			     unsigned int client_id, unsigned int key[2],
+			     unsigned int* uid);
+
+Bool XAppleDRIDestroySurface (Display *dpy, int screen, Drawable drawable);
+
+Bool XAppleDRISynchronizeSurfaces (Display *dpy);
+
+_XFUNCPROTOEND
+
+#endif /* _APPLEDRI_SERVER_ */
+#endif /* _APPLEDRI_H_ */
+
diff --git a/hw/xquartz/xpr/appledristr.h b/hw/xquartz/xpr/appledristr.h
new file mode 100644
index 0000000..8649fd3
--- /dev/null
+++ b/hw/xquartz/xpr/appledristr.h
@@ -0,0 +1,175 @@
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, Inc.
+Copyright (c) 2002 Apple Computer, Inc.
+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, sub license, 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 PRECISION INSIGHT AND/OR ITS 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 <martin at valinux.com>
+ *   Jens Owen <jens at valinux.com>
+ *   Rickard E. (Rik) Fiath <faith at valinux.com>
+ *
+ */
+
+#ifndef _APPLEDRISTR_H_
+#define _APPLEDRISTR_H_
+
+#include "appledri.h"
+
+#define APPLEDRINAME "Apple-DRI"
+
+#define APPLE_DRI_MAJOR_VERSION	1	/* current version numbers */
+#define APPLE_DRI_MINOR_VERSION	0
+#define APPLE_DRI_PATCH_VERSION	0
+
+typedef struct _AppleDRIQueryVersion {
+    CARD8	reqType;		/* always DRIReqCode */
+    CARD8	driReqType;		/* always X_DRIQueryVersion */
+    CARD16	length B16;
+} xAppleDRIQueryVersionReq;
+#define sz_xAppleDRIQueryVersionReq	4
+
+typedef struct {
+    BYTE	type;			/* X_Reply */
+    BOOL	pad1;
+    CARD16	sequenceNumber B16;
+    CARD32	length B32;
+    CARD16	majorVersion B16;	/* major version of DRI protocol */
+    CARD16	minorVersion B16;	/* minor version of DRI protocol */
+    CARD32	patchVersion B32;       /* patch version of DRI protocol */
+    CARD32	pad3 B32;
+    CARD32	pad4 B32;
+    CARD32	pad5 B32;
+    CARD32	pad6 B32;
+} xAppleDRIQueryVersionReply;
+#define sz_xAppleDRIQueryVersionReply	32
+
+typedef struct _AppleDRIQueryDirectRenderingCapable {
+    CARD8	reqType;		/* always DRIReqCode */
+    CARD8	driReqType;		/* X_DRIQueryDirectRenderingCapable */
+    CARD16	length B16;
+    CARD32	screen B32;
+} xAppleDRIQueryDirectRenderingCapableReq;
+#define sz_xAppleDRIQueryDirectRenderingCapableReq	8
+
+typedef struct {
+    BYTE	type;			/* X_Reply */
+    BOOL	pad1;
+    CARD16	sequenceNumber B16;
+    CARD32	length B32;
+    BOOL	isCapable;
+    BOOL	pad2;
+    BOOL	pad3;
+    BOOL	pad4;
+    CARD32	pad5 B32;
+    CARD32	pad6 B32;
+    CARD32	pad7 B32;
+    CARD32	pad8 B32;
+    CARD32	pad9 B32;
+} xAppleDRIQueryDirectRenderingCapableReply;
+#define sz_xAppleDRIQueryDirectRenderingCapableReply	32
+
+typedef struct _AppleDRIAuthConnection {
+    CARD8	reqType;		/* always DRIReqCode */
+    CARD8	driReqType;		/* always X_DRICloseConnection */
+    CARD16	length B16;
+    CARD32	screen B32;
+    CARD32      magic B32;
+} xAppleDRIAuthConnectionReq;
+#define sz_xAppleDRIAuthConnectionReq	12
+
+typedef struct {
+    BYTE        type;
+    BOOL        pad1;
+    CARD16      sequenceNumber B16;
+    CARD32      length B32;
+    CARD32      authenticated B32;
+    CARD32      pad2 B32;
+    CARD32      pad3 B32;
+    CARD32      pad4 B32;
+    CARD32      pad5 B32;
+    CARD32      pad6 B32;
+} xAppleDRIAuthConnectionReply;
+#define zx_xAppleDRIAuthConnectionReply  32
+
+typedef struct _AppleDRICreateSurface {
+    CARD8	reqType;		/* always DRIReqCode */
+    CARD8	driReqType;		/* always X_DRICreateSurface */
+    CARD16	length B16;
+    CARD32	screen B32;
+    CARD32	drawable B32;
+    CARD32	client_id B32;
+} xAppleDRICreateSurfaceReq;
+#define sz_xAppleDRICreateSurfaceReq	16
+
+typedef struct {
+    BYTE	type;			/* X_Reply */
+    BOOL	pad1;
+    CARD16	sequenceNumber B16;
+    CARD32	length B32;
+    CARD32	key_0 B32;
+    CARD32	key_1 B32;
+    CARD32	uid B32;
+    CARD32	pad4 B32;
+    CARD32	pad5 B32;
+    CARD32	pad6 B32;
+} xAppleDRICreateSurfaceReply;
+#define sz_xAppleDRICreateSurfaceReply	32
+
+typedef struct _AppleDRIDestroySurface {
+    CARD8	reqType;		/* always DRIReqCode */
+    CARD8	driReqType;		/* always X_DRIDestroySurface */
+    CARD16	length B16;
+    CARD32	screen B32;
+    CARD32	drawable B32;
+} xAppleDRIDestroySurfaceReq;
+#define sz_xAppleDRIDestroySurfaceReq	12
+
+typedef struct _AppleDRINotify {
+	BYTE	type;		/* always eventBase + event type */
+	BYTE	kind;
+	CARD16	sequenceNumber B16;
+	Time	time B32;	/* time of change */
+	CARD16	pad1 B16;
+	CARD32	arg B32;
+	CARD32	pad3 B32;
+} xAppleDRINotifyEvent;
+#define sz_xAppleDRINotifyEvent	20
+
+#ifdef _APPLEDRI_SERVER_
+
+void AppleDRISendEvent (
+#if NeedFunctionPrototypes
+    int			/* type */,
+    unsigned int	/* mask */,
+    int			/* which */,
+    int			/* arg */
+#endif
+);
+
+#endif /* _APPLEDRI_SERVER_ */
+#endif /* _APPLEDRISTR_H_ */
diff --git a/hw/xquartz/xpr/dri.c b/hw/xquartz/xpr/dri.c
new file mode 100644
index 0000000..e5591ab
--- /dev/null
+++ b/hw/xquartz/xpr/dri.c
@@ -0,0 +1,760 @@
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, Inc.
+Copyright (c) 2002 Apple Computer, Inc.
+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, sub license, 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 PRECISION INSIGHT AND/OR ITS 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:
+ *   Jens Owen <jens at valinux.com>
+ *   Rickard E. (Rik) Faith <faith at valinux.com>
+ *
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef XFree86LOADER
+#include "xf86.h"
+#include "xf86_ansic.h"
+#else
+#include <sys/time.h>
+#include <unistd.h>
+#endif
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "servermd.h"
+#define _APPLEDRI_SERVER_
+#include "appledristr.h"
+#include "swaprep.h"
+#include "dri.h"
+#include "dristruct.h"
+#include "mi.h"
+#include "mipointer.h"
+#include "rootless.h"
+#include "x-hash.h"
+#include "x-hook.h"
+
+#include <AvailabilityMacros.h>
+
+static int DRIScreenPrivIndex = -1;
+static int DRIWindowPrivIndex = -1;
+static int DRIPixmapPrivIndex = -1;
+
+static RESTYPE DRIDrawablePrivResType;
+
+static x_hash_table *surface_hash;      /* maps surface ids -> drawablePrivs */
+
+/* FIXME: don't hardcode this? */
+#define CG_INFO_FILE "/System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreGraphics.framework/Resources/Info-macos.plist"
+
+/* Corresponds to SU Jaguar Green */
+#define CG_REQUIRED_MAJOR 1
+#define CG_REQUIRED_MINOR 157
+#define CG_REQUIRED_MICRO 11
+
+/* Returns version as major.minor.micro in 10.10.10 fixed form */
+static unsigned int
+get_cg_version (void)
+{
+    static unsigned int version;
+
+    FILE *fh;
+    char *ptr;
+
+    if (version != 0)
+        return version;
+
+    /* I tried CFBundleGetVersion, but it returns zero, so.. */
+
+    fh = fopen (CG_INFO_FILE, "r");
+    if (fh != NULL)
+    {
+        char buf[256];
+
+        while (fgets (buf, sizeof (buf), fh) != NULL)
+        {
+            unsigned char c;
+
+            if (!strstr (buf, "<key>CFBundleShortVersionString</key>")
+                || fgets (buf, sizeof (buf), fh) == NULL)
+            {
+                continue;
+            }
+
+            ptr = strstr (buf, "<string>");
+            if (ptr == NULL)
+                continue;
+
+            ptr += strlen ("<string>");
+
+            /* Now PTR points to "MAJOR.MINOR.MICRO". */
+
+            version = 0;
+
+        again:
+            switch ((c = *ptr++))
+            {
+            case '.':
+                version = version * 1024;
+                goto again;
+
+            case '0': case '1': case '2': case '3': case '4':
+            case '5': case '6': case '7': case '8': case '9':
+                version = ((version & ~0x3ff)
+                          + (version & 0x3ff) * 10 + (c - '0'));
+                goto again;
+            }
+            break;
+        }
+
+        fclose (fh);
+    }
+
+    return version;
+}
+
+static Bool
+test_cg_version (unsigned int major, unsigned int minor, unsigned int micro)
+{
+    unsigned int cg_ver = get_cg_version ();
+
+    unsigned int cg_major = (cg_ver >> 20) & 0x3ff;
+    unsigned int cg_minor = (cg_ver >> 10) & 0x3ff;
+    unsigned int cg_micro =  cg_ver        & 0x3ff;
+
+    if (cg_major > major)
+        return TRUE;
+    else if (cg_major < major)
+        return FALSE;
+
+    /* cg_major == major */
+
+    if (cg_minor > minor)
+        return TRUE;
+    else if (cg_minor < minor)
+        return FALSE;
+
+    /* cg_minor == minor */
+
+    if (cg_micro < micro)
+        return FALSE;
+
+    return TRUE;
+}
+
+Bool
+DRIScreenInit(ScreenPtr pScreen)
+{
+    DRIScreenPrivPtr    pDRIPriv;
+    int                 i;
+
+    pDRIPriv = (DRIScreenPrivPtr) xcalloc(1, sizeof(DRIScreenPrivRec));
+    if (!pDRIPriv) {
+        pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
+        return FALSE;
+    }
+
+    pScreen->devPrivates[DRIScreenPrivIndex].ptr = (pointer) pDRIPriv;
+    pDRIPriv->directRenderingSupport = TRUE;
+    pDRIPriv->nrWindows = 0;
+
+    /* Need recent cg for window access update */
+    if (!test_cg_version (CG_REQUIRED_MAJOR,
+                          CG_REQUIRED_MINOR,
+                          CG_REQUIRED_MICRO))
+    {
+        ErrorF ("[DRI] disabled direct rendering; requires CoreGraphics %d.%d.%d\n",
+                CG_REQUIRED_MAJOR, CG_REQUIRED_MINOR, CG_REQUIRED_MICRO);
+
+        pDRIPriv->directRenderingSupport = FALSE;
+
+        /* Note we don't nuke the dri private, since we need it for
+           managing indirect surfaces. */
+    }
+
+    /* Initialize drawable tables */
+    for (i = 0; i < DRI_MAX_DRAWABLES; i++) {
+        pDRIPriv->DRIDrawables[i] = NULL;
+    }
+
+    return TRUE;
+}
+
+Bool
+DRIFinishScreenInit(ScreenPtr pScreen)
+{
+    DRIScreenPrivPtr  pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+    /* Allocate zero sized private area for each window. Should a window
+     * become a DRI window, we'll hang a DRIWindowPrivateRec off of this
+     * private index.
+     */
+    if (!AllocateWindowPrivate(pScreen, DRIWindowPrivIndex, 0))
+        return FALSE;
+
+    /* Wrap DRI support */
+    pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree;
+    pScreen->ValidateTree = DRIValidateTree;
+
+    pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree;
+    pScreen->PostValidateTree = DRIPostValidateTree;
+
+    pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures;
+    pScreen->WindowExposures = DRIWindowExposures;
+
+    pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow;
+    pScreen->CopyWindow = DRICopyWindow;
+
+    pDRIPriv->wrap.ClipNotify = pScreen->ClipNotify;
+    pScreen->ClipNotify = DRIClipNotify;
+
+    //    ErrorF("[DRI] screen %d installation complete\n", pScreen->myNum);
+
+    return TRUE;
+}
+
+void
+DRICloseScreen(ScreenPtr pScreen)
+{
+    DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+    if (pDRIPriv && pDRIPriv->directRenderingSupport) {
+        xfree(pDRIPriv);
+        pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
+    }
+}
+
+Bool
+DRIExtensionInit(void)
+{
+    static unsigned long DRIGeneration = 0;
+
+    if (DRIGeneration != serverGeneration) {
+        if ((DRIScreenPrivIndex = AllocateScreenPrivateIndex()) < 0)
+            return FALSE;
+        DRIGeneration = serverGeneration;
+    }
+
+    /*
+     * Allocate a window private index with a zero sized private area for
+     * each window, then should a window become a DRI window, we'll hang
+     * a DRIWindowPrivateRec off of this private index. Do same for pixmaps.
+     */
+    if ((DRIWindowPrivIndex = AllocateWindowPrivateIndex()) < 0)
+        return FALSE;
+    if ((DRIPixmapPrivIndex = AllocatePixmapPrivateIndex()) < 0)
+        return FALSE;
+
+    DRIDrawablePrivResType = CreateNewResourceType(DRIDrawablePrivDelete);
+
+    return TRUE;
+}
+
+void
+DRIReset(void)
+{
+    /*
+     * This stub routine is called when the X Server recycles, resources
+     * allocated by DRIExtensionInit need to be managed here.
+     *
+     * Currently this routine is a stub because all the interesting resources
+     * are managed via the screen init process.
+     */
+}
+
+Bool
+DRIQueryDirectRenderingCapable(ScreenPtr pScreen, Bool* isCapable)
+{
+    DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+    if (pDRIPriv)
+        *isCapable = pDRIPriv->directRenderingSupport;
+    else
+        *isCapable = FALSE;
+
+    return TRUE;
+}
+
+Bool
+DRIAuthConnection(ScreenPtr pScreen, unsigned int magic)
+{
+#if 0
+    /* FIXME: something? */
+
+    DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+    if (drmAuthMagic(pDRIPriv->drmFD, magic)) return FALSE;
+#endif
+    return TRUE;
+}
+
+static void
+DRIUpdateSurface(DRIDrawablePrivPtr pDRIDrawablePriv, DrawablePtr pDraw)
+{
+    xp_window_changes wc;
+    unsigned int flags = 0;
+
+    if (pDRIDrawablePriv->sid == 0)
+        return;
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
+    wc.depth = (pDraw->bitsPerPixel == 32 ? XP_DEPTH_ARGB8888
+                : pDraw->bitsPerPixel == 16 ? XP_DEPTH_RGB555 : XP_DEPTH_NIL);
+    if (wc.depth != XP_DEPTH_NIL)
+        flags |= XP_DEPTH;
+#endif
+
+    if (pDraw->type == DRAWABLE_WINDOW) {
+        WindowPtr pWin = (WindowPtr) pDraw;
+        WindowPtr pTopWin = TopLevelParent(pWin);
+
+        wc.x = pWin->drawable.x - (pTopWin->drawable.x - pTopWin->borderWidth);
+        wc.y = pWin->drawable.y - (pTopWin->drawable.y - pTopWin->borderWidth);
+        wc.width = pWin->drawable.width + 2 * pWin->borderWidth;
+        wc.height = pWin->drawable.height + 2 * pWin->borderWidth;
+        wc.bit_gravity = XP_GRAVITY_NONE;
+
+        wc.shape_nrects = REGION_NUM_RECTS(&pWin->clipList);
+        wc.shape_rects = REGION_RECTS(&pWin->clipList);
+        wc.shape_tx = - (pTopWin->drawable.x - pTopWin->borderWidth);
+        wc.shape_ty = - (pTopWin->drawable.y - pTopWin->borderWidth);
+
+        flags |= XP_BOUNDS | XP_SHAPE;
+
+    } else if (pDraw->type == DRAWABLE_PIXMAP) {
+        wc.x = 0;
+        wc.y = 0;
+        wc.width = pDraw->width;
+        wc.height = pDraw->height;
+        wc.bit_gravity = XP_GRAVITY_NONE;
+        flags |= XP_BOUNDS;
+    }
+
+    xp_configure_surface(pDRIDrawablePriv->sid, flags, &wc);
+}
+
+Bool
+DRICreateSurface(ScreenPtr pScreen, Drawable id,
+                 DrawablePtr pDrawable, xp_client_id client_id,
+                 xp_surface_id *surface_id, unsigned int ret_key[2],
+                 void (*notify) (void *arg, void *data), void *notify_data)
+{
+    DRIScreenPrivPtr    pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+    DRIDrawablePrivPtr  pDRIDrawablePriv;
+    xp_window_id        wid = 0;
+
+    if (pDrawable->type == DRAWABLE_WINDOW) {
+        WindowPtr pWin = (WindowPtr)pDrawable;
+
+        pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
+        if (pDRIDrawablePriv == NULL) {
+            xp_error err;
+            xp_window_changes wc;
+
+            /* allocate a DRI Window Private record */
+            if (!(pDRIDrawablePriv = xalloc(sizeof(DRIDrawablePrivRec)))) {
+                return FALSE;
+            }
+
+            pDRIDrawablePriv->pDraw = pDrawable;
+            pDRIDrawablePriv->pScreen = pScreen;
+            pDRIDrawablePriv->refCount = 0;
+            pDRIDrawablePriv->drawableIndex = -1;
+            pDRIDrawablePriv->notifiers = NULL;
+
+            /* find the physical window */
+            wid = (xp_window_id) RootlessFrameForWindow(pWin, TRUE);
+            if (wid == 0) {
+                xfree(pDRIDrawablePriv);
+                return FALSE;
+            }
+
+            /* allocate the physical surface */
+            err = xp_create_surface(wid, &pDRIDrawablePriv->sid);
+            if (err != Success) {
+                xfree(pDRIDrawablePriv);
+                return FALSE;
+            }
+
+            /* Make it visible */
+            wc.stack_mode = XP_MAPPED_ABOVE;
+            wc.sibling = 0;
+            err = xp_configure_surface(pDRIDrawablePriv->sid, XP_STACKING, &wc);
+            if (err != Success)
+            {
+                xp_destroy_surface(pDRIDrawablePriv->sid);
+                xfree(pDRIDrawablePriv);
+                return FALSE;
+            }
+
+            /* save private off of preallocated index */
+            pWin->devPrivates[DRIWindowPrivIndex].ptr = (pointer)pDRIDrawablePriv;
+        }
+    }
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
+    else if (pDrawable->type == DRAWABLE_PIXMAP) {
+        PixmapPtr pPix = (PixmapPtr)pDrawable;
+
+        pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix);
+        if (pDRIDrawablePriv == NULL) {
+            xp_error err;
+
+            /* allocate a DRI Window Private record */
+            if (!(pDRIDrawablePriv = xcalloc(1, sizeof(DRIDrawablePrivRec)))) {
+                return FALSE;
+            }
+
+            pDRIDrawablePriv->pDraw = pDrawable;
+            pDRIDrawablePriv->pScreen = pScreen;
+            pDRIDrawablePriv->refCount = 0;
+            pDRIDrawablePriv->drawableIndex = -1;
+            pDRIDrawablePriv->notifiers = NULL;
+
+            /* Passing a null window id to Xplugin in 10.3+ asks for
+               an accelerated offscreen surface. */
+
+            err = xp_create_surface(0, &pDRIDrawablePriv->sid);
+            if (err != Success) {
+                xfree(pDRIDrawablePriv);
+                return FALSE;
+            }
+
+            /* save private off of preallocated index */
+            pPix->devPrivates[DRIPixmapPrivIndex].ptr = (pointer)pDRIDrawablePriv;
+        }
+    }
+#endif
+
+    else { /* for GLX 1.3, a PBuffer */
+        /* NOT_DONE */
+        return FALSE;
+    }
+
+    /* Finish initialization of new surfaces */
+    if (pDRIDrawablePriv->refCount == 0) {
+        unsigned int key[2] = {0};
+        xp_error err;
+
+        /* try to give the client access to the surface */
+        if (client_id != 0 && wid != 0)
+        {
+            err = xp_export_surface(wid, pDRIDrawablePriv->sid,
+                                    client_id, key);
+            if (err != Success) {
+                xp_destroy_surface(pDRIDrawablePriv->sid);
+                xfree(pDRIDrawablePriv);
+                return FALSE;
+            }
+        }
+
+        pDRIDrawablePriv->key[0] = key[0];
+        pDRIDrawablePriv->key[1] = key[1];
+
+        ++pDRIPriv->nrWindows;
+
+        /* and stash it by surface id */
+        if (surface_hash == NULL)
+            surface_hash = x_hash_table_new(NULL, NULL, NULL, NULL);
+        x_hash_table_insert(surface_hash,
+                            (void *) pDRIDrawablePriv->sid, pDRIDrawablePriv);
+
+        /* track this in case this window is destroyed */
+        AddResource(id, DRIDrawablePrivResType, (pointer)pDrawable);
+
+        /* Initialize shape */
+        DRIUpdateSurface(pDRIDrawablePriv, pDrawable);
+    }
+
+    pDRIDrawablePriv->refCount++;
+
+    *surface_id = pDRIDrawablePriv->sid;
+
+    if (ret_key != NULL) {
+        ret_key[0] = pDRIDrawablePriv->key[0];
+        ret_key[1] = pDRIDrawablePriv->key[1];
+    }
+
+    if (notify != NULL) {
+        pDRIDrawablePriv->notifiers = x_hook_add(pDRIDrawablePriv->notifiers,
+                                                 notify, notify_data);
+    }
+
+    return TRUE;
+}
+
+Bool
+DRIDestroySurface(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable,
+                  void (*notify) (void *, void *), void *notify_data)
+{
+    DRIDrawablePrivPtr  pDRIDrawablePriv;
+
+    if (pDrawable->type == DRAWABLE_WINDOW) {
+        pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW((WindowPtr)pDrawable);
+    } else if (pDrawable->type == DRAWABLE_PIXMAP) {
+        pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP((PixmapPtr)pDrawable);
+    } else {
+        return FALSE;
+    }
+
+    if (pDRIDrawablePriv != NULL) {
+        if (notify != NULL) {
+            pDRIDrawablePriv->notifiers = x_hook_remove(pDRIDrawablePriv->notifiers,
+                                                        notify, notify_data);
+        }
+        if (--pDRIDrawablePriv->refCount <= 0) {
+            /* This calls back to DRIDrawablePrivDelete
+               which frees the private area */
+            FreeResourceByType(id, DRIDrawablePrivResType, FALSE);
+        }
+    }
+
+    return TRUE;
+}
+
+Bool
+DRIDrawablePrivDelete(pointer pResource, XID id)
+{
+    DrawablePtr         pDrawable = (DrawablePtr)pResource;
+    DRIScreenPrivPtr    pDRIPriv = DRI_SCREEN_PRIV(pDrawable->pScreen);
+    DRIDrawablePrivPtr  pDRIDrawablePriv = NULL;
+    WindowPtr           pWin = NULL;
+    PixmapPtr           pPix = NULL;
+
+    if (pDrawable->type == DRAWABLE_WINDOW) {
+        pWin = (WindowPtr)pDrawable;
+        pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
+    } else if (pDrawable->type == DRAWABLE_PIXMAP) {
+        pPix = (PixmapPtr)pDrawable;
+        pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix);
+    }
+
+    if (pDRIDrawablePriv == NULL)
+        return FALSE;
+
+    if (pDRIDrawablePriv->drawableIndex != -1) {
+        /* release drawable table entry */
+        pDRIPriv->DRIDrawables[pDRIDrawablePriv->drawableIndex] = NULL;
+    }
+
+    if (pDRIDrawablePriv->sid != 0) {
+        xp_destroy_surface(pDRIDrawablePriv->sid);
+        x_hash_table_remove(surface_hash, (void *) pDRIDrawablePriv->sid);
+    }
+
+    if (pDRIDrawablePriv->notifiers != NULL)
+        x_hook_free(pDRIDrawablePriv->notifiers);
+
+    xfree(pDRIDrawablePriv);
+
+    if (pDrawable->type == DRAWABLE_WINDOW) {
+        pWin->devPrivates[DRIWindowPrivIndex].ptr = NULL;
+    } else if (pDrawable->type == DRAWABLE_PIXMAP) {
+        pPix->devPrivates[DRIPixmapPrivIndex].ptr = NULL;
+    }
+
+    --pDRIPriv->nrWindows;
+
+    return TRUE;
+}
+
+void
+DRIWindowExposures(WindowPtr pWin, RegionPtr prgn, RegionPtr bsreg)
+{
+    ScreenPtr pScreen = pWin->drawable.pScreen;
+    DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+    DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
+
+    if (pDRIDrawablePriv) {
+        /* FIXME: something? */
+    }
+
+    pScreen->WindowExposures = pDRIPriv->wrap.WindowExposures;
+
+    (*pScreen->WindowExposures)(pWin, prgn, bsreg);
+
+    pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures;
+    pScreen->WindowExposures = DRIWindowExposures;
+}
+
+void
+DRICopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+{
+    ScreenPtr pScreen = pWin->drawable.pScreen;
+    DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+    DRIDrawablePrivPtr pDRIDrawablePriv;
+
+    if (pDRIPriv->nrWindows > 0) {
+       pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
+       if (pDRIDrawablePriv != NULL) {
+            DRIUpdateSurface(pDRIDrawablePriv, &pWin->drawable);
+       }
+    }
+
+    /* unwrap */
+    pScreen->CopyWindow = pDRIPriv->wrap.CopyWindow;
+
+    /* call lower layers */
+    (*pScreen->CopyWindow)(pWin, ptOldOrg, prgnSrc);
+
+    /* rewrap */
+    pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow;
+    pScreen->CopyWindow = DRICopyWindow;
+}
+
+int
+DRIValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
+{
+    ScreenPtr pScreen = pParent->drawable.pScreen;
+    DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+    int returnValue;
+
+    /* unwrap */
+    pScreen->ValidateTree = pDRIPriv->wrap.ValidateTree;
+
+    /* call lower layers */
+    returnValue = (*pScreen->ValidateTree)(pParent, pChild, kind);
+
+    /* rewrap */
+    pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree;
+    pScreen->ValidateTree = DRIValidateTree;
+
+    return returnValue;
+}
+
+void
+DRIPostValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
+{
+    ScreenPtr pScreen;
+    DRIScreenPrivPtr pDRIPriv;
+
+    if (pParent) {
+        pScreen = pParent->drawable.pScreen;
+    } else {
+        pScreen = pChild->drawable.pScreen;
+    }
+    pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+    if (pDRIPriv->wrap.PostValidateTree) {
+        /* unwrap */
+        pScreen->PostValidateTree = pDRIPriv->wrap.PostValidateTree;
+
+        /* call lower layers */
+        (*pScreen->PostValidateTree)(pParent, pChild, kind);
+
+        /* rewrap */
+        pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree;
+        pScreen->PostValidateTree = DRIPostValidateTree;
+    }
+}
+
+void
+DRIClipNotify(WindowPtr pWin, int dx, int dy)
+{
+    ScreenPtr pScreen = pWin->drawable.pScreen;
+    DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+    DRIDrawablePrivPtr  pDRIDrawablePriv;
+
+    if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) {
+        DRIUpdateSurface(pDRIDrawablePriv, &pWin->drawable);
+    }
+
+    if (pDRIPriv->wrap.ClipNotify) {
+        pScreen->ClipNotify = pDRIPriv->wrap.ClipNotify;
+
+        (*pScreen->ClipNotify)(pWin, dx, dy);
+
+        pDRIPriv->wrap.ClipNotify = pScreen->ClipNotify;
+        pScreen->ClipNotify = DRIClipNotify;
+    }
+}
+
+/* This lets us get at the unwrapped functions so that they can correctly
+ * call the lower level functions, and choose whether they will be
+ * called at every level of recursion (eg in validatetree).
+ */
+DRIWrappedFuncsRec *
+DRIGetWrappedFuncs(ScreenPtr pScreen)
+{
+    return &(DRI_SCREEN_PRIV(pScreen)->wrap);
+}
+
+void
+DRIQueryVersion(int *majorVersion,
+                int *minorVersion,
+                int *patchVersion)
+{
+    *majorVersion = APPLE_DRI_MAJOR_VERSION;
+    *minorVersion = APPLE_DRI_MINOR_VERSION;
+    *patchVersion = APPLE_DRI_PATCH_VERSION;
+}
+
+void
+DRISurfaceNotify(xp_surface_id id, int kind)
+{
+    DRIDrawablePrivPtr pDRIDrawablePriv = NULL;
+    DRISurfaceNotifyArg arg;
+
+    arg.id = id;
+    arg.kind = kind;
+
+    if (surface_hash != NULL)
+    {
+        pDRIDrawablePriv = x_hash_table_lookup(surface_hash,
+                                               (void *) id, NULL);
+    }
+
+    if (pDRIDrawablePriv == NULL)
+        return;
+
+    if (kind == AppleDRISurfaceNotifyDestroyed)
+    {
+        pDRIDrawablePriv->sid = 0;
+        x_hash_table_remove(surface_hash, (void *) id);
+    }
+
+    x_hook_run(pDRIDrawablePriv->notifiers, &arg);
+
+    if (kind == AppleDRISurfaceNotifyDestroyed)
+    {
+        /* Kill off the handle. */
+
+        FreeResourceByType(pDRIDrawablePriv->pDraw->id,
+                           DRIDrawablePrivResType, FALSE);
+    }
+}
diff --git a/hw/xquartz/xpr/dri.h b/hw/xquartz/xpr/dri.h
new file mode 100644
index 0000000..cf2638a
--- /dev/null
+++ b/hw/xquartz/xpr/dri.h
@@ -0,0 +1,128 @@
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright (c) 2002 Apple Computer, Inc.
+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, sub license, 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 PRECISION INSIGHT AND/OR ITS 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:
+ *   Jens Owen <jens at precisioninsight.com>
+ *
+ */
+
+/* Prototypes for AppleDRI functions */
+
+#ifndef _DRI_H_
+#define _DRI_H_
+
+#include <X11/Xdefs.h>
+#include "scrnintstr.h"
+#define _APPLEDRI_SERVER_
+#include "appledri.h"
+#include "Xplugin.h"
+
+typedef void (*ClipNotifyPtr)( WindowPtr, int, int );
+
+
+/*
+ * These functions can be wrapped by the DRI.  Each of these have
+ * generic default funcs (initialized in DRICreateInfoRec) and can be
+ * overridden by the driver in its [driver]DRIScreenInit function.
+ */
+typedef struct {
+    WindowExposuresProcPtr       WindowExposures;
+    CopyWindowProcPtr            CopyWindow;
+    ValidateTreeProcPtr          ValidateTree;
+    PostValidateTreeProcPtr      PostValidateTree;
+    ClipNotifyProcPtr            ClipNotify;
+} DRIWrappedFuncsRec, *DRIWrappedFuncsPtr;
+
+typedef struct {
+    xp_surface_id id;
+    int kind;
+} DRISurfaceNotifyArg;
+
+extern Bool DRIScreenInit(ScreenPtr pScreen);
+
+extern Bool DRIFinishScreenInit(ScreenPtr pScreen);
+
+extern void DRICloseScreen(ScreenPtr pScreen);
+
+extern Bool DRIExtensionInit(void);
+
+extern void DRIReset(void);
+
+extern Bool DRIQueryDirectRenderingCapable(ScreenPtr pScreen,
+                                           Bool *isCapable);
+
+extern Bool DRIAuthConnection(ScreenPtr pScreen, unsigned int magic);
+
+extern Bool DRICreateSurface(ScreenPtr pScreen,
+                             Drawable id,
+                             DrawablePtr pDrawable,
+                             xp_client_id client_id,
+                             xp_surface_id *surface_id,
+                             unsigned int key[2],
+                             void (*notify) (void *arg, void *data),
+                             void *notify_data);
+
+extern Bool DRIDestroySurface(ScreenPtr pScreen,
+                             Drawable id,
+                             DrawablePtr pDrawable,
+                             void (*notify) (void *arg, void *data),
+                             void *notify_data);
+
+extern Bool DRIDrawablePrivDelete(pointer pResource,
+                                  XID id);
+
+extern DRIWrappedFuncsRec *DRIGetWrappedFuncs(ScreenPtr pScreen);
+
+extern void DRICopyWindow(WindowPtr pWin,
+                          DDXPointRec ptOldOrg,
+                          RegionPtr prgnSrc);
+
+extern int DRIValidateTree(WindowPtr pParent,
+                           WindowPtr pChild,
+                           VTKind    kind);
+
+extern void DRIPostValidateTree(WindowPtr pParent,
+                                WindowPtr pChild,
+                                VTKind    kind);
+
+extern void DRIClipNotify(WindowPtr pWin,
+                          int dx,
+                          int dy);
+
+extern void DRIWindowExposures(WindowPtr pWin,
+                              RegionPtr prgn,
+                              RegionPtr bsreg);
+
+extern void DRISurfaceNotify (xp_surface_id id, int kind);
+
+extern void DRIQueryVersion(int *majorVersion,
+                            int *minorVersion,
+                            int *patchVersion);
+
+#endif
diff --git a/hw/xquartz/xpr/dristruct.h b/hw/xquartz/xpr/dristruct.h
new file mode 100644
index 0000000..9a3d01c
--- /dev/null
+++ b/hw/xquartz/xpr/dristruct.h
@@ -0,0 +1,81 @@
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright (c) 2002 Apple Computer, Inc.
+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, sub license, 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 PRECISION INSIGHT AND/OR ITS 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:
+ *   Jens Owen <jens at precisioninsight.com>
+ *
+ */
+
+#ifndef DRI_STRUCT_H
+#define DRI_STRUCT_H
+
+#include "dri.h"
+#include "x-list.h"
+
+#define DRI_MAX_DRAWABLES 256
+
+#define DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin) \
+    ((DRIWindowPrivIndex < 0) ? \
+     NULL : \
+     ((DRIDrawablePrivPtr)((pWin)->devPrivates[DRIWindowPrivIndex].ptr)))
+
+#define DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix) \
+    ((DRIPixmapPrivIndex < 0) ? \
+     NULL : \
+     ((DRIDrawablePrivPtr)((pPix)->devPrivates[DRIPixmapPrivIndex].ptr)))
+
+typedef struct _DRIDrawablePrivRec
+{
+    xp_surface_id   sid;
+    int             drawableIndex;
+    DrawablePtr     pDraw;
+    ScreenPtr       pScreen;
+    int             refCount;
+    unsigned int    key[2];
+    x_list          *notifiers;     /* list of (FUN . DATA) */
+} DRIDrawablePrivRec, *DRIDrawablePrivPtr;
+
+#define DRI_SCREEN_PRIV(pScreen) \
+    ((DRIScreenPrivIndex < 0) ? \
+     NULL : \
+     ((DRIScreenPrivPtr)((pScreen)->devPrivates[DRIScreenPrivIndex].ptr)))
+
+#define DRI_SCREEN_PRIV_FROM_INDEX(screenIndex) ((DRIScreenPrivPtr) \
+    (screenInfo.screens[screenIndex]->devPrivates[DRIScreenPrivIndex].ptr))
+
+
+typedef struct _DRIScreenPrivRec
+{
+    Bool                directRenderingSupport;
+    int                 nrWindows;
+    DRIWrappedFuncsRec  wrap;
+    DrawablePtr         DRIDrawables[DRI_MAX_DRAWABLES];
+} DRIScreenPrivRec, *DRIScreenPrivPtr;
+
+#endif /* DRI_STRUCT_H */
diff --git a/hw/xquartz/xpr/x-hash.c b/hw/xquartz/xpr/x-hash.c
new file mode 100644
index 0000000..55d28ba
--- /dev/null
+++ b/hw/xquartz/xpr/x-hash.c
@@ -0,0 +1,343 @@
+/* x-hash.c - basic hash tables
+
+   Copyright (c) 2002 Apple Computer, Inc. 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 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. */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "x-hash.h"
+#include "x-list.h"
+#include <stdlib.h>
+#include <assert.h>
+
+struct x_hash_table_struct {
+    unsigned int bucket_index;
+    unsigned int total_keys;
+    x_list **buckets;
+
+    x_hash_fun *hash_key;
+    x_compare_fun *compare_keys;
+    x_destroy_fun *destroy_key;
+    x_destroy_fun *destroy_value;
+};
+
+#define ITEM_NEW(k, v) X_PFX (list_prepend) ((x_list *) (k), v)
+#define ITEM_FREE(i) X_PFX (list_free_1) (i)
+#define ITEM_KEY(i) ((void *) (i)->next)
+#define ITEM_VALUE(i) ((i)->data)
+
+#define SPLIT_THRESHOLD_FACTOR 2
+
+/* http://planetmath.org/?op=getobj&from=objects&name=GoodHashTablePrimes */
+static const unsigned int bucket_sizes[] = {
+    29, 53, 97, 193, 389, 769, 1543, 3079, 6151, 12289, 24593, 49157,
+    98317, 196613, 393241, 786433, 1572869, 3145739, 6291469, 12582917,
+    25165843, 50331653, 100663319, 201326611, 402653189, 805306457,
+    1610612741
+};
+
+#define N_BUCKET_SIZES (sizeof (bucket_sizes) / sizeof (bucket_sizes[0]))
+
+static inline unsigned int
+hash_table_total_buckets (x_hash_table *h)
+{
+    return bucket_sizes[h->bucket_index];
+}
+
+static inline void
+hash_table_destroy_item (x_hash_table *h, void *k, void *v)
+{
+    if (h->destroy_key != 0)
+        (*h->destroy_key) (k);
+
+    if (h->destroy_value != 0)
+        (*h->destroy_value) (v);
+}
+
+static inline unsigned int
+hash_table_hash_key (x_hash_table *h, void *k)
+{
+    if (h->hash_key != 0)
+        return (*h->hash_key) (k);
+    else
+        return (unsigned int) k;
+}
+
+static inline int
+hash_table_compare_keys (x_hash_table *h, void *k1, void *k2)
+{
+    if (h->compare_keys == 0)
+        return k1 == k2;
+    else
+        return (*h->compare_keys) (k1, k2) == 0;
+}
+
+static void
+hash_table_split (x_hash_table *h)
+{
+    x_list **new, **old;
+    x_list *node, *item, *next;
+    int new_size, old_size;
+    unsigned int b;
+    int i;
+
+    if (h->bucket_index == N_BUCKET_SIZES - 1)
+        return;
+
+    old_size = hash_table_total_buckets (h);
+    old = h->buckets;
+
+    h->bucket_index++;
+
+    new_size = hash_table_total_buckets (h);
+    new = calloc (new_size, sizeof (x_list *));
+
+    if (new == 0)
+    {
+        h->bucket_index--;
+        return;
+    }
+
+    for (i = 0; i < old_size; i++)
+    {
+        for (node = old[i]; node != 0; node = next)
+        {
+            next = node->next;
+            item = node->data;
+
+            b = hash_table_hash_key (h, ITEM_KEY (item)) % new_size;
+
+            node->next = new[b];
+            new[b] = node;
+        }
+    }
+
+    h->buckets = new;
+    free (old);
+}
+
+X_EXTERN x_hash_table *
+X_PFX (hash_table_new) (x_hash_fun *hash,
+                        x_compare_fun *compare,
+                        x_destroy_fun *key_destroy,
+                        x_destroy_fun *value_destroy)
+{
+    x_hash_table *h;
+
+    h = calloc (1, sizeof (x_hash_table));
+    if (h == 0)
+        return 0;
+
+    h->bucket_index = 0;
+    h->buckets = calloc (hash_table_total_buckets (h), sizeof (x_list *));
+
+    if (h->buckets == 0)
+    {
+        free (h);
+        return 0;
+    }
+    
+    h->hash_key = hash;
+    h->compare_keys = compare;
+    h->destroy_key = key_destroy;
+    h->destroy_value = value_destroy;
+
+    return h;
+}
+
+X_EXTERN void
+X_PFX (hash_table_free) (x_hash_table *h)
+{
+    int n, i;
+    x_list *node, *item;
+
+    assert (h != NULL);
+
+    n = hash_table_total_buckets (h);
+
+    for (i = 0; i < n; i++)
+    {
+        for (node = h->buckets[i]; node != 0; node = node->next)
+        {
+            item = node->data;
+            hash_table_destroy_item (h, ITEM_KEY (item), ITEM_VALUE (item));
+            ITEM_FREE (item);
+        }
+        X_PFX (list_free) (h->buckets[i]);
+    }
+
+    free (h->buckets);
+    free (h);
+}
+
+X_EXTERN unsigned int
+X_PFX (hash_table_size) (x_hash_table *h)
+{
+    assert (h != NULL);
+
+    return h->total_keys;
+}
+
+static void
+hash_table_modify (x_hash_table *h, void *k, void *v, int replace)
+{
+    unsigned int hash_value;
+    x_list *node, *item;
+
+    assert (h != NULL);
+
+    hash_value = hash_table_hash_key (h, k);
+
+    for (node = h->buckets[hash_value % hash_table_total_buckets (h)];
+         node != 0; node = node->next)
+    {
+        item = node->data;
+
+        if (hash_table_compare_keys (h, ITEM_KEY (item), k))
+        {
+            if (replace)
+            {
+                hash_table_destroy_item (h, ITEM_KEY (item),
+                                         ITEM_VALUE (item));
+                item->next = k;
+                ITEM_VALUE (item) = v;
+            }
+            else
+            {
+                hash_table_destroy_item (h, k, ITEM_VALUE (item));
+                ITEM_VALUE (item) = v;
+            }
+            return;
+        }
+    }
+
+    /* Key isn't already in the table. Insert it. */
+
+    if (h->total_keys + 1
+        > hash_table_total_buckets (h) * SPLIT_THRESHOLD_FACTOR)
+    {
+        hash_table_split (h);
+    }
+
+    hash_value = hash_value % hash_table_total_buckets (h);
+    h->buckets[hash_value] = X_PFX (list_prepend) (h->buckets[hash_value],
+                                                   ITEM_NEW (k, v));
+    h->total_keys++;
+}
+
+X_EXTERN void
+X_PFX (hash_table_insert) (x_hash_table *h, void *k, void *v)
+{
+    hash_table_modify (h, k, v, 0);
+}
+
+X_EXTERN void
+X_PFX (hash_table_replace) (x_hash_table *h, void *k, void *v)
+{
+    hash_table_modify (h, k, v, 1);
+}
+
+X_EXTERN void
+X_PFX (hash_table_remove) (x_hash_table *h, void *k)
+{
+    unsigned int hash_value;
+    x_list **ptr, *item;
+
+    assert (h != NULL);
+
+    hash_value = hash_table_hash_key (h, k);
+
+    for (ptr = &h->buckets[hash_value % hash_table_total_buckets (h)];
+         *ptr != 0; ptr = &((*ptr)->next))
+    {
+        item = (*ptr)->data;
+
+        if (hash_table_compare_keys (h, ITEM_KEY (item), k))
+        {
+            hash_table_destroy_item (h, ITEM_KEY (item), ITEM_VALUE (item));
+            ITEM_FREE (item);
+            item = *ptr;
+            *ptr = item->next;
+            X_PFX (list_free_1) (item);
+            h->total_keys--;
+            return;
+        }
+    }
+}
+
+X_EXTERN void *
+X_PFX (hash_table_lookup) (x_hash_table *h, void *k, void **k_ret)
+{
+    unsigned int hash_value;
+    x_list *node, *item;
+
+    assert (h != NULL);
+
+    hash_value = hash_table_hash_key (h, k);
+
+    for (node = h->buckets[hash_value % hash_table_total_buckets (h)];
+         node != 0; node = node->next)
+    {
+        item = node->data;
+
+        if (hash_table_compare_keys (h, ITEM_KEY (item), k))
+        {
+            if (k_ret != 0)
+            *k_ret = ITEM_KEY (item);
+
+            return ITEM_VALUE (item);
+        }
+    }
+
+    if (k_ret != 0)
+        *k_ret = 0;
+
+    return 0;
+}
+
+X_EXTERN void
+X_PFX (hash_table_foreach) (x_hash_table *h,
+                            x_hash_foreach_fun *fun, void *data)
+{
+    int i, n;
+    x_list *node, *item;
+
+    assert (h != NULL);
+
+    n = hash_table_total_buckets (h);
+
+    for (i = 0; i < n; i++)
+    {
+        for (node = h->buckets[i]; node != 0; node = node->next)
+        {
+            item = node->data;
+            (*fun) (ITEM_KEY (item), ITEM_VALUE (item), data);
+        }
+    }
+}
diff --git a/hw/xquartz/xpr/x-hash.h b/hw/xquartz/xpr/x-hash.h
new file mode 100644
index 0000000..3456dbe
--- /dev/null
+++ b/hw/xquartz/xpr/x-hash.h
@@ -0,0 +1,60 @@
+/* x-hash.h -- basic hash table class
+
+   Copyright (c) 2002 Apple Computer, Inc. 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 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 X_HASH_H
+#define X_HASH_H 1
+
+typedef struct x_hash_table_struct x_hash_table;
+
+typedef int (x_compare_fun) (const void *a, const void *b);
+typedef unsigned int (x_hash_fun) (const void *k);
+typedef void (x_destroy_fun) (void *x);
+typedef void (x_hash_foreach_fun) (void *k, void *v, void *data);
+
+/* for X_PFX and X_EXTERN */
+#include "x-list.h"
+
+X_EXTERN x_hash_table *X_PFX (hash_table_new) (x_hash_fun *hash,
+					       x_compare_fun *compare,
+					       x_destroy_fun *key_destroy,
+					       x_destroy_fun *value_destroy);
+X_EXTERN void X_PFX (hash_table_free) (x_hash_table *h);
+
+X_EXTERN unsigned int X_PFX (hash_table_size) (x_hash_table *h);
+
+X_EXTERN void X_PFX (hash_table_insert) (x_hash_table *h, void *k, void *v);
+X_EXTERN void X_PFX (hash_table_replace) (x_hash_table *h, void *k, void *v);
+X_EXTERN void X_PFX (hash_table_remove) (x_hash_table *h, void *k);
+X_EXTERN void *X_PFX (hash_table_lookup) (x_hash_table *h,
+					  void *k, void **k_ret);
+X_EXTERN void X_PFX (hash_table_foreach) (x_hash_table *h,
+					  x_hash_foreach_fun *fun,
+					  void *data);
+
+#endif /* X_HASH_H */
diff --git a/hw/xquartz/xpr/x-hook.c b/hw/xquartz/xpr/x-hook.c
new file mode 100644
index 0000000..bb873bb
--- /dev/null
+++ b/hw/xquartz/xpr/x-hook.c
@@ -0,0 +1,109 @@
+/* x-hook.c
+
+   Copyright (c) 2003 Apple Computer, Inc. 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 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. */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "x-hook.h"
+#include <stdlib.h>
+#include <assert.h>
+
+#define CELL_NEW(f,d) X_PFX (list_prepend) ((x_list *) (f), (d))
+#define CELL_FREE(c)  X_PFX (list_free_1) (c)
+#define CELL_FUN(c)   ((x_hook_function *) ((c)->next))
+#define CELL_DATA(c)  ((c)->data)
+
+X_EXTERN x_list *
+X_PFX (hook_add) (x_list *lst, x_hook_function *fun, void *data)
+{
+    return X_PFX (list_prepend) (lst, CELL_NEW (fun, data));
+}
+
+X_EXTERN x_list *
+X_PFX (hook_remove) (x_list *lst, x_hook_function *fun, void *data)
+{
+    x_list *node, *cell;
+    x_list *to_delete = NULL;
+
+    for (node = lst; node != NULL; node = node->next)
+    {
+	cell = node->data;
+	if (CELL_FUN (cell) == fun && CELL_DATA (cell) == data)
+	    to_delete = X_PFX (list_prepend) (to_delete, cell);
+    }
+
+    for (node = to_delete; node != NULL; node = node->next)
+    {
+	cell = node->data;
+	lst = X_PFX (list_remove) (lst, cell);
+	CELL_FREE (cell);
+    }
+
+    X_PFX (list_free) (to_delete);
+    return lst;
+}
+
+X_EXTERN void
+X_PFX (hook_run) (x_list *lst, void *arg)
+{
+    x_list *node, *cell;
+    x_hook_function **fun;
+    void **data;
+    int length, i;
+
+    length = X_PFX (list_length) (lst);
+    fun = alloca (sizeof (x_hook_function *) * length);
+    data = alloca (sizeof (void *) * length);
+
+    for (i = 0, node = lst; node != NULL; node = node->next, i++)
+    {
+	cell = node->data;
+	fun[i] = CELL_FUN (cell);
+	data[i] = CELL_DATA (cell);
+    }
+
+    for (i = 0; i < length; i++)
+    {
+	(*fun[i]) (arg, data[i]);
+    }
+}
+
+X_EXTERN void
+X_PFX (hook_free) (x_list *lst)
+{
+    x_list *node;
+
+    for (node = lst; node != NULL; node = node->next)
+    {
+	CELL_FREE (node->data);
+    }
+
+    X_PFX (list_free) (lst);
+}
diff --git a/hw/xquartz/xpr/x-hook.h b/hw/xquartz/xpr/x-hook.h
new file mode 100644
index 0000000..392352d
--- /dev/null
+++ b/hw/xquartz/xpr/x-hook.h
@@ -0,0 +1,42 @@
+/* x-hook.h -- lists of function,data pairs to call.
+
+   Copyright (c) 2003 Apple Computer, Inc. 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 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 X_HOOK_H
+#define X_HOOK_H 1
+
+#include "x-list.h"
+
+typedef void x_hook_function (void *arg, void *data);
+
+X_EXTERN x_list *X_PFX (hook_add) (x_list *lst, x_hook_function *fun, void *data);
+X_EXTERN x_list *X_PFX (hook_remove) (x_list *lst, x_hook_function *fun, void *data);
+X_EXTERN void X_PFX (hook_run) (x_list *lst, void *arg);
+X_EXTERN void X_PFX (hook_free) (x_list *lst);
+
+#endif /* X_HOOK_H */
diff --git a/hw/xquartz/xpr/x-list.c b/hw/xquartz/xpr/x-list.c
new file mode 100644
index 0000000..3596dd3
--- /dev/null
+++ b/hw/xquartz/xpr/x-list.c
@@ -0,0 +1,337 @@
+/* x-list.c
+
+   Copyright (c) 2002 Apple Computer, Inc. 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 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. */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "x-list.h"
+#include <stdlib.h>
+#include <assert.h>
+#include <pthread.h>
+
+/* Allocate in ~4k blocks */
+#define NODES_PER_BLOCK 508
+
+typedef struct x_list_block_struct x_list_block;
+
+struct x_list_block_struct {
+    x_list l[NODES_PER_BLOCK];
+};
+
+static x_list *freelist;
+
+static pthread_mutex_t freelist_lock = PTHREAD_MUTEX_INITIALIZER;
+
+static inline void
+list_free_1 (x_list *node)
+{
+    node->next = freelist;
+    freelist = node;
+}
+
+X_EXTERN void
+X_PFX (list_free_1) (x_list *node)
+{
+    assert (node != NULL);
+
+    pthread_mutex_lock (&freelist_lock);
+
+    list_free_1 (node);
+
+    pthread_mutex_unlock (&freelist_lock);
+}
+
+X_EXTERN void
+X_PFX (list_free) (x_list *lst)
+{
+    x_list *next;
+
+    pthread_mutex_lock (&freelist_lock);
+
+    for (; lst != NULL; lst = next)
+    {
+        next = lst->next;
+        list_free_1 (lst);
+    }
+
+    pthread_mutex_unlock (&freelist_lock);
+}
+
+X_EXTERN x_list *
+X_PFX (list_prepend) (x_list *lst, void *data)
+{
+    x_list *node;
+
+    pthread_mutex_lock (&freelist_lock);
+
+    if (freelist == NULL)
+    {
+        x_list_block *b;
+        int i;
+
+        b = malloc (sizeof (x_list_block));
+
+        for (i = 0; i < NODES_PER_BLOCK - 1; i++)
+            b->l[i].next = &(b->l[i+1]);
+        b->l[i].next = NULL;
+
+        freelist = b->l;
+    }
+
+    node = freelist;
+    freelist = node->next;
+
+    pthread_mutex_unlock (&freelist_lock);
+
+    node->next = lst;
+    node->data = data;
+
+    return node;
+}
+
+X_EXTERN x_list *
+X_PFX (list_append) (x_list *lst, void *data)
+{
+    x_list *head = lst;
+
+    if (lst == NULL)
+        return X_PFX (list_prepend) (NULL, data);
+
+    while (lst->next != NULL)
+        lst = lst->next;
+
+    lst->next = X_PFX (list_prepend) (NULL, data);
+
+    return head;
+}
+
+X_EXTERN x_list *
+X_PFX (list_reverse) (x_list *lst)
+{
+    x_list *head = NULL, *next;
+    
+    while (lst != NULL)
+    {
+        next = lst->next;
+        lst->next = head;
+        head = lst;
+        lst = next;
+    }
+
+    return head;
+}
+
+X_EXTERN x_list *
+X_PFX (list_find) (x_list *lst, void *data)
+{
+    for (; lst != NULL; lst = lst->next)
+    {
+        if (lst->data == data)
+            return lst;
+    }
+
+    return NULL;
+}
+
+X_EXTERN x_list *
+X_PFX (list_nth) (x_list *lst, int n)
+{
+    while (n-- > 0 && lst != NULL)
+        lst = lst->next;
+
+    return lst;
+}
+
+X_EXTERN x_list *
+X_PFX (list_pop) (x_list *lst, void **data_ret)
+{
+    void *data = NULL;
+
+    if (lst != NULL)
+    {
+        x_list *tem = lst;
+        data = lst->data;
+        lst = lst->next;
+        X_PFX (list_free_1) (tem);
+    }
+
+    if (data_ret != NULL)
+        *data_ret = data;
+
+    return lst;
+}
+
+X_EXTERN x_list *
+X_PFX (list_filter) (x_list *lst,
+                     int (*pred) (void *item, void *data), void *data)
+{
+    x_list *ret = NULL, *node;
+
+    for (node = lst; node != NULL; node = node->next)
+    {
+        if ((*pred) (node->data, data))
+            ret = X_PFX (list_prepend) (ret, node->data);
+    }
+
+    return X_PFX (list_reverse) (ret);
+}
+
+X_EXTERN x_list *
+X_PFX (list_map) (x_list *lst,
+                  void *(*fun) (void *item, void *data), void *data)
+{
+    x_list *ret = NULL, *node;
+
+    for (node = lst; node != NULL; node = node->next)
+    {
+        X_PFX (list_prepend) (ret, fun (node->data, data));
+    }
+
+    return X_PFX (list_reverse) (ret);
+}
+
+X_EXTERN x_list *
+X_PFX (list_copy) (x_list *lst)
+{
+    x_list *copy = NULL;
+
+    for (; lst != NULL; lst = lst->next)
+    {
+        copy = X_PFX (list_prepend) (copy, lst->data);
+    }
+
+    return X_PFX (list_reverse) (copy);
+}
+
+X_EXTERN x_list *
+X_PFX (list_remove) (x_list *lst, void *data)
+{
+    x_list **ptr, *node;
+
+    for (ptr = &lst; *ptr != NULL;)
+    {
+        node = *ptr;
+
+        if (node->data == data)
+        {
+            *ptr = node->next;
+            X_PFX (list_free_1) (node);
+        }
+        else
+            ptr = &((*ptr)->next);
+    }
+
+    return lst;
+}
+
+X_EXTERN unsigned int
+X_PFX (list_length) (x_list *lst)
+{
+    unsigned int n;
+
+    n = 0;
+    for (; lst != NULL; lst = lst->next)
+        n++;
+
+    return n;
+}
+
+X_EXTERN void
+X_PFX (list_foreach) (x_list *lst,
+                      void (*fun) (void *data, void *user_data),
+                      void *user_data)
+{
+    for (; lst != NULL; lst = lst->next)
+    {
+        (*fun) (lst->data, user_data);
+    }
+}
+
+static x_list *
+list_sort_1 (x_list *lst, int length,
+             int (*less) (const void *, const void *))
+{
+    x_list *mid, *ptr;
+    x_list *out_head, *out;
+    int mid_point, i;
+
+    /* This is a standard (stable) list merge sort */
+
+    if (length < 2)
+        return lst;
+
+    /* Calculate the halfway point. Split the list into two sub-lists. */
+
+    mid_point = length / 2;
+    ptr = lst;
+    for (i = mid_point - 1; i > 0; i--)
+        ptr = ptr->next;
+    mid = ptr->next;
+    ptr->next = NULL;
+
+    /* Sort each sub-list. */
+
+    lst = list_sort_1 (lst, mid_point, less);
+    mid = list_sort_1 (mid, length - mid_point, less);
+
+    /* Then merge them back together. */
+
+    assert (lst != NULL && mid != NULL);
+
+    if ((*less) (mid->data, lst->data))
+        out = out_head = mid, mid = mid->next;
+    else
+        out = out_head = lst, lst = lst->next;
+
+    while (lst != NULL && mid != NULL)
+    {
+        if ((*less) (mid->data, lst->data))
+            out = out->next = mid, mid = mid->next;
+        else
+            out = out->next = lst, lst = lst->next;
+    }
+
+    if (lst != NULL)
+        out->next = lst;
+    else
+        out->next = mid;
+
+    return out_head;
+}
+
+X_EXTERN x_list *
+X_PFX (list_sort) (x_list *lst, int (*less) (const void *, const void *))
+{
+    int length;
+
+    length = X_PFX (list_length) (lst);
+
+    return list_sort_1 (lst, length, less);
+}
diff --git a/hw/xquartz/xpr/x-list.h b/hw/xquartz/xpr/x-list.h
new file mode 100644
index 0000000..04af024
--- /dev/null
+++ b/hw/xquartz/xpr/x-list.h
@@ -0,0 +1,77 @@
+/* x-list.h -- simple list type
+
+   Copyright (c) 2002 Apple Computer, Inc. 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 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 X_LIST_H
+#define X_LIST_H 1
+
+/* This is just a cons. */
+
+typedef struct x_list_struct x_list;
+
+struct x_list_struct {
+    void *data;
+    x_list *next;
+};
+
+#ifndef X_PFX
+# define X_PFX(x) x_ ## x
+#endif
+
+#ifndef X_EXTERN
+# define X_EXTERN __private_extern__
+#endif
+
+X_EXTERN void X_PFX (list_free_1) (x_list *node);
+X_EXTERN x_list *X_PFX (list_prepend) (x_list *lst, void *data);
+
+X_EXTERN x_list *X_PFX (list_append) (x_list *lst, void *data);
+X_EXTERN x_list *X_PFX (list_remove) (x_list *lst, void *data);
+X_EXTERN void X_PFX (list_free) (x_list *lst);
+X_EXTERN x_list *X_PFX (list_pop) (x_list *lst, void **data_ret);
+
+X_EXTERN x_list *X_PFX (list_copy) (x_list *lst);
+X_EXTERN x_list *X_PFX (list_reverse) (x_list *lst);
+X_EXTERN x_list *X_PFX (list_find) (x_list *lst, void *data);
+X_EXTERN x_list *X_PFX (list_nth) (x_list *lst, int n);
+X_EXTERN x_list *X_PFX (list_filter) (x_list *src,
+                                      int (*pred) (void *item, void *data),
+                                      void *data);
+X_EXTERN x_list *X_PFX (list_map) (x_list *src,
+                                   void *(*fun) (void *item, void *data),
+                                   void *data);
+
+X_EXTERN unsigned int X_PFX (list_length) (x_list *lst);
+X_EXTERN void X_PFX (list_foreach) (x_list *lst, void (*fun)
+                                    (void *data, void *user_data),
+                                    void *user_data);
+
+X_EXTERN x_list *X_PFX (list_sort) (x_list *lst, int (*less) (const void *,
+                                    const void *));
+
+#endif /* X_LIST_H */
diff --git a/hw/xquartz/xpr/xpr.h b/hw/xquartz/xpr/xpr.h
new file mode 100644
index 0000000..ddc6d0c
--- /dev/null
+++ b/hw/xquartz/xpr/xpr.h
@@ -0,0 +1,47 @@
+/*
+ * Xplugin rootless implementation
+ *
+ * Copyright (c) 2003 Torrey T. Lyons. 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
+ * 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 XPR_H
+#define XPR_H
+
+#include "screenint.h"
+
+extern Bool QuartzModeBundleInit(void);
+
+void AppleDRIExtensionInit(void);
+void xprAppleWMInit(void);
+Bool xprInit(ScreenPtr pScreen);
+Bool xprIsX11Window(void *nsWindow, int windowNumber);
+
+void xprHideWindows(Bool hide);
+
+Bool QuartzInitCursor(ScreenPtr pScreen);
+void QuartzSuspendXCursor(ScreenPtr pScreen);
+void QuartzResumeXCursor(ScreenPtr pScreen, int x, int y);
+
+#endif /* XPR_H */
diff --git a/hw/xquartz/xpr/xprAppleWM.c b/hw/xquartz/xpr/xprAppleWM.c
new file mode 100644
index 0000000..bd82df0
--- /dev/null
+++ b/hw/xquartz/xpr/xprAppleWM.c
@@ -0,0 +1,100 @@
+/*
+ * Xplugin rootless implementation functions for AppleWM extension
+ *
+ * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2003 Torrey T. Lyons. 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
+ * 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "xpr.h"
+#include "applewmExt.h"
+#include "rootless.h"
+#include "Xplugin.h"
+#include <X11/X.h>
+
+static int xprSetWindowLevel(
+    WindowPtr pWin,
+    int level)
+{
+    xp_window_id wid;
+    xp_window_changes wc;
+
+    wid = (xp_window_id) RootlessFrameForWindow (pWin, TRUE);
+    if (wid == 0)
+        return BadWindow;
+
+    RootlessStopDrawing (pWin, FALSE);
+
+    wc.window_level = level;
+    if (xp_configure_window (wid, XP_WINDOW_LEVEL, &wc) != Success) {
+        return BadValue;
+    }
+
+    return Success;
+}
+
+
+static int xprFrameDraw(
+    WindowPtr pWin,
+    int class,
+    unsigned int attr,
+    const BoxRec *outer,
+    const BoxRec *inner,
+    unsigned int title_len,
+    const unsigned char *title_bytes)
+{
+    xp_window_id wid;
+
+    wid = (xp_window_id) RootlessFrameForWindow (pWin, FALSE);
+    if (wid == 0)
+        return BadWindow;
+
+    if (xp_frame_draw (wid, class, attr, outer, inner,
+                       title_len, title_bytes) != Success)
+    {
+        return BadValue;
+    }
+
+    return Success;
+}
+
+
+static AppleWMProcsRec xprAppleWMProcs = {
+    xp_disable_update,
+    xp_reenable_update,
+    xprSetWindowLevel,
+    xp_frame_get_rect,
+    xp_frame_hit_test,
+    xprFrameDraw
+};
+
+
+void xprAppleWMInit(void)
+{
+    AppleWMExtensionInit(&xprAppleWMProcs);
+}
diff --git a/hw/xquartz/xpr/xprCursor.c b/hw/xquartz/xpr/xprCursor.c
new file mode 100644
index 0000000..db195a8
--- /dev/null
+++ b/hw/xquartz/xpr/xprCursor.c
@@ -0,0 +1,431 @@
+/**************************************************************
+ *
+ * Xplugin cursor support
+ *
+ * Copyright (c) 2001 Torrey T. Lyons and Greg Parker.
+ * Copyright (c) 2002 Apple Computer, Inc.
+ *                 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
+ * 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "quartzCommon.h"
+#include "xpr.h"
+#include "darwin.h"
+#include "Xplugin.h"
+
+#include "mi.h"
+#include "scrnintstr.h"
+#include "cursorstr.h"
+#include "mipointrst.h"
+#include "windowstr.h"
+#include "globals.h"
+#include "servermd.h"
+#include "dixevents.h"
+
+typedef struct {
+    int                     cursorVisible;
+    QueryBestSizeProcPtr    QueryBestSize;
+    miPointerSpriteFuncPtr  spriteFuncs;
+} QuartzCursorScreenRec, *QuartzCursorScreenPtr;
+
+static int darwinCursorScreenIndex = -1;
+static unsigned long darwinCursorGeneration = 0;
+
+#define CURSOR_PRIV(pScreen) \
+    ((QuartzCursorScreenPtr)pScreen->devPrivates[darwinCursorScreenIndex].ptr)
+
+
+static Bool
+load_cursor(CursorPtr src, int screen)
+{
+    uint32_t *data;
+    uint32_t rowbytes;
+    int width, height;
+    int hot_x, hot_y;
+
+    uint32_t fg_color, bg_color;
+    uint8_t *srow, *sptr;
+    uint8_t *mrow, *mptr;
+    uint32_t *drow, *dptr;
+    unsigned xcount, ycount;
+
+    xp_error err;
+
+    width = src->bits->width;
+    height = src->bits->height;
+    hot_x = src->bits->xhot;
+    hot_y = src->bits->yhot;
+
+#ifdef ARGB_CURSOR
+    if (src->bits->argb != NULL)
+    {
+#if BITMAP_BIT_ORDER == MSBFirst
+        rowbytes = src->bits->width * sizeof (CARD32);
+        data = (uint32_t *) src->bits->argb;
+#else
+        const uint32_t *be_data=(uint32_t *) src->bits->argb;
+        unsigned i;
+        rowbytes = src->bits->width * sizeof (CARD32);
+        data=alloca (rowbytes * src->bits->height);
+        for(i=0;i<(src->bits->width*src->bits->height);i++)
+            data[i]=ntohl(be_data[i]);
+#endif
+    }
+    else
+#endif
+    {
+        fg_color = 0xFF00 | (src->foreRed >> 8);
+        fg_color <<= 16;
+        fg_color |= src->foreGreen & 0xFF00;
+        fg_color |= src->foreBlue >> 8;
+
+        bg_color = 0xFF00 | (src->backRed >> 8);
+        bg_color <<= 16;
+        bg_color |= src->backGreen & 0xFF00;
+        bg_color |= src->backBlue >> 8;
+
+        fg_color = htonl(fg_color);
+        bg_color = htonl(bg_color);
+
+        /* round up to 8 pixel boundary so we can convert whole bytes */
+        rowbytes = ((src->bits->width * 4) + 31) & ~31;
+        data = alloca(rowbytes * src->bits->height);
+
+        if (!src->bits->emptyMask)
+        {
+            ycount = src->bits->height;
+            srow = src->bits->source; mrow = src->bits->mask;
+            drow = data;
+
+            while (ycount-- > 0)
+            {
+                xcount = (src->bits->width + 7) / 8;
+                sptr = srow; mptr = mrow;
+                dptr = drow;
+
+                while (xcount-- > 0)
+                {
+                    uint8_t s, m;
+                    int i;
+
+                    s = *sptr++; m = *mptr++;
+                    for (i = 0; i < 8; i++)
+                    {
+#if BITMAP_BIT_ORDER == MSBFirst
+                        if (m & 128)
+                            *dptr++ = (s & 128) ? fg_color : bg_color;
+                        else
+                            *dptr++ = 0;
+                        s <<= 1; m <<= 1;
+#else
+                        if (m & 1)
+                            *dptr++ = (s & 1) ? fg_color : bg_color;
+                        else
+                            *dptr++ = 0;
+                        s >>= 1; m >>= 1;
+#endif
+                    }
+                }
+
+                srow += BitmapBytePad(src->bits->width);
+                mrow += BitmapBytePad(src->bits->width);
+                drow = (uint32_t *) ((char *) drow + rowbytes);
+            }
+        }
+        else
+        {
+            memset(data, 0, src->bits->height * rowbytes);
+        }
+    }
+
+    err = xp_set_cursor(width, height, hot_x, hot_y, data, rowbytes);
+    return err == Success;
+}
+
+
+/*
+===========================================================================
+
+ Pointer sprite functions
+
+===========================================================================
+*/
+
+/*
+ * QuartzRealizeCursor
+ *  Convert the X cursor representation to native format if possible.
+ */
+static Bool
+QuartzRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
+{
+    if(pCursor == NULL || pCursor->bits == NULL)
+        return FALSE;
+
+    /* FIXME: cache ARGB8888 representation? */
+
+    return TRUE;
+}
+
+
+/*
+ * QuartzUnrealizeCursor
+ *  Free the storage space associated with a realized cursor.
+ */
+static Bool
+QuartzUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
+{
+    return TRUE;
+}
+
+
+/*
+ * QuartzSetCursor
+ *  Set the cursor sprite and position.
+ */
+static void
+QuartzSetCursor(ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
+{
+    QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
+
+    if (!quartzServerVisible)
+        return;
+
+    if (pCursor == NULL)
+    {
+        if (ScreenPriv->cursorVisible)
+        {
+            xp_hide_cursor();
+            ScreenPriv->cursorVisible = FALSE;
+        }
+    }
+    else
+    {
+        load_cursor(pCursor, pScreen->myNum);
+
+        if (!ScreenPriv->cursorVisible)
+        {
+            xp_show_cursor();
+            ScreenPriv->cursorVisible = TRUE;
+        }
+    }
+}
+
+
+/*
+ * QuartzMoveCursor
+ *  Move the cursor. This is a noop for us.
+ */
+static void
+QuartzMoveCursor(ScreenPtr pScreen, int x, int y)
+{
+}
+
+
+static miPointerSpriteFuncRec quartzSpriteFuncsRec = {
+    QuartzRealizeCursor,
+    QuartzUnrealizeCursor,
+    QuartzSetCursor,
+    QuartzMoveCursor
+};
+
+
+/*
+===========================================================================
+
+ Pointer screen functions
+
+===========================================================================
+*/
+
+/*
+ * QuartzCursorOffScreen
+ */
+static Bool
+QuartzCursorOffScreen(ScreenPtr *pScreen, int *x, int *y)
+{
+    return FALSE;
+}
+
+
+/*
+ * QuartzCrossScreen
+ */
+static void
+QuartzCrossScreen(ScreenPtr pScreen, Bool entering)
+{
+    return;
+}
+
+
+/*
+ * QuartzWarpCursor
+ *  Change the cursor position without generating an event or motion history.
+ *  The input coordinates (x,y) are in pScreen-local X11 coordinates.
+ *
+ */
+static void
+QuartzWarpCursor(ScreenPtr pScreen, int x, int y)
+{
+    static Bool neverMoved = TRUE;
+
+    if (neverMoved)
+    {
+        /* Don't move the cursor the first time. This is the
+           jump-to-center initialization, and it's annoying. */
+        neverMoved = FALSE;
+        return;
+    }
+
+    if (quartzServerVisible)
+    {
+        int sx, sy;
+
+        sx = dixScreenOrigins[pScreen->myNum].x + darwinMainScreenX;
+        sy = dixScreenOrigins[pScreen->myNum].y + darwinMainScreenY;
+
+        CGWarpMouseCursorPosition(CGPointMake(sx + x, sy + y));
+    }
+
+    miPointerWarpCursor(pScreen, x, y);
+    miPointerUpdate();
+}
+
+
+static miPointerScreenFuncRec quartzScreenFuncsRec = {
+    QuartzCursorOffScreen,
+    QuartzCrossScreen,
+    QuartzWarpCursor,
+    DarwinEQPointerPost,
+    DarwinEQSwitchScreen
+};
+
+
+/*
+===========================================================================
+
+ Other screen functions
+
+===========================================================================
+*/
+
+/*
+ * QuartzCursorQueryBestSize
+ *  Handle queries for best cursor size
+ */
+static void
+QuartzCursorQueryBestSize(int class, unsigned short *width,
+                          unsigned short *height, ScreenPtr pScreen)
+{
+    QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
+
+    if (class == CursorShape)
+    {
+        /* FIXME: query window server? */
+        *width = 32;
+        *height = 32;
+    }
+    else
+    {
+        (*ScreenPriv->QueryBestSize)(class, width, height, pScreen);
+    }
+}
+
+/*
+ * QuartzInitCursor
+ *  Initialize cursor support
+ */
+Bool
+QuartzInitCursor(ScreenPtr pScreen)
+{
+    QuartzCursorScreenPtr ScreenPriv;
+    miPointerScreenPtr PointPriv;
+
+    /* initialize software cursor handling (always needed as backup) */
+    if (!miDCInitialize(pScreen, &quartzScreenFuncsRec))
+        return FALSE;
+
+    /* allocate private storage for this screen's QuickDraw cursor info */
+    if (darwinCursorGeneration != serverGeneration)
+    {
+        if ((darwinCursorScreenIndex = AllocateScreenPrivateIndex()) < 0)
+            return FALSE;
+
+        darwinCursorGeneration = serverGeneration;
+    }
+
+    ScreenPriv = xcalloc(1, sizeof(QuartzCursorScreenRec));
+    if (ScreenPriv == NULL)
+        return FALSE;
+
+    /* CURSOR_PRIV(pScreen) = ScreenPriv; */
+    pScreen->devPrivates[darwinCursorScreenIndex].ptr = ScreenPriv;
+
+    /* override some screen procedures */
+    ScreenPriv->QueryBestSize = pScreen->QueryBestSize;
+    pScreen->QueryBestSize = QuartzCursorQueryBestSize;
+
+    PointPriv = (miPointerScreenPtr) pScreen->devPrivates[miPointerScreenIndex].ptr;
+
+    ScreenPriv->spriteFuncs = PointPriv->spriteFuncs;
+    PointPriv->spriteFuncs = &quartzSpriteFuncsRec;
+
+    ScreenPriv->cursorVisible = TRUE;
+    return TRUE;
+}
+
+
+/*
+ * QuartzSuspendXCursor
+ *  X server is hiding. Restore the Aqua cursor.
+ */
+void
+QuartzSuspendXCursor(ScreenPtr pScreen)
+{
+}
+
+
+/*
+ * QuartzResumeXCursor
+ *  X server is showing. Restore the X cursor.
+ */
+void
+QuartzResumeXCursor(ScreenPtr pScreen, int x, int y)
+{
+    WindowPtr pWin;
+    CursorPtr pCursor;
+
+    pWin = GetSpriteWindow();
+    if (pWin->drawable.pScreen != pScreen)
+        return;
+
+    pCursor = GetSpriteCursor();
+    if (pCursor == NULL)
+        return;
+
+    QuartzSetCursor(pScreen, pCursor, x, y);
+}
diff --git a/hw/xquartz/xpr/xprFrame.c b/hw/xquartz/xpr/xprFrame.c
new file mode 100644
index 0000000..2d97f27
--- /dev/null
+++ b/hw/xquartz/xpr/xprFrame.c
@@ -0,0 +1,528 @@
+/*
+ * Xplugin rootless implementation frame functions
+ *
+ * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2003 Torrey T. Lyons. 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
+ * 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "xpr.h"
+#include "rootlessCommon.h"
+#include "Xplugin.h"
+#include "x-hash.h"
+#include "x-list.h"
+#include "applewmExt.h"
+
+#include "propertyst.h"
+#include "dix.h"
+#include <X11/Xatom.h>
+#include "windowstr.h"
+
+#include <pthread.h>
+
+#define DEFINE_ATOM_HELPER(func,atom_name)                      \
+static Atom func (void) {                                       \
+    static int generation;                                      \
+    static Atom atom;                                           \
+    if (generation != serverGeneration) {                       \
+        generation = serverGeneration;                          \
+        atom = MakeAtom (atom_name, strlen (atom_name), TRUE);  \
+    }                                                           \
+    return atom;                                                \
+}
+
+DEFINE_ATOM_HELPER(xa_native_window_id, "_NATIVE_WINDOW_ID")
+
+/* Maps xp_window_id -> RootlessWindowRec */
+static x_hash_table *window_hash;
+static pthread_mutex_t window_hash_mutex;
+
+static Bool no_configure_window;
+
+
+static inline xp_error
+xprConfigureWindow(xp_window_id id, unsigned int mask,
+                   const xp_window_changes *values)
+{
+  //  ErrorF("xprConfigureWindow()\n");
+    if (!no_configure_window)
+        return xp_configure_window(id, mask, values);
+    else
+        return XP_Success;
+}
+
+
+static void
+xprSetNativeProperty(RootlessWindowPtr pFrame)
+{
+    xp_error err;
+    unsigned int native_id;
+    long data;
+
+    err = xp_get_native_window((xp_window_id) pFrame->wid, &native_id);
+    if (err == Success)
+    {
+        /* FIXME: move this to AppleWM extension */
+
+        data = native_id;
+        ChangeWindowProperty(pFrame->win, xa_native_window_id(),
+                             XA_INTEGER, 32, PropModeReplace, 1, &data, TRUE);
+    }
+}
+
+
+/*
+ * Create and display a new frame.
+ */
+Bool
+xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
+               int newX, int newY, RegionPtr pShape)
+{
+    WindowPtr pWin = pFrame->win;
+    xp_window_changes wc;
+    unsigned int mask = 0;
+    xp_error err;
+
+    wc.x = newX;
+    wc.y = newY;
+    wc.width = pFrame->width;
+    wc.height = pFrame->height;
+    wc.bit_gravity = XP_GRAVITY_NONE;
+    mask |= XP_BOUNDS;
+
+    if (pWin->drawable.depth == 8)
+    {
+        wc.depth = XP_DEPTH_INDEX8;
+#if 0
+        wc.colormap = xprColormapCallback;
+        wc.colormap_data = pScreen;
+        mask |= XP_COLORMAP;
+#endif
+    }
+    else if (pWin->drawable.depth == 15)
+        wc.depth = XP_DEPTH_RGB555;
+    else if (pWin->drawable.depth == 24)
+        wc.depth = XP_DEPTH_ARGB8888;
+    else
+        wc.depth = XP_DEPTH_NIL;
+    mask |= XP_DEPTH;
+
+    if (pShape != NULL)
+    {
+        wc.shape_nrects = REGION_NUM_RECTS(pShape);
+        wc.shape_rects = REGION_RECTS(pShape);
+        wc.shape_tx = wc.shape_ty = 0;
+        mask |= XP_SHAPE;
+    }
+
+    err = xp_create_window(mask, &wc, (xp_window_id *) &pFrame->wid);
+
+    if (err != Success)
+    {
+        return FALSE;
+    }
+
+    if (window_hash == NULL)
+    {
+        window_hash = x_hash_table_new(NULL, NULL, NULL, NULL);
+        pthread_mutex_init(&window_hash_mutex, NULL);
+    }
+
+    pthread_mutex_lock(&window_hash_mutex);
+    x_hash_table_insert(window_hash, pFrame->wid, pFrame);
+    pthread_mutex_unlock(&window_hash_mutex);
+
+    xprSetNativeProperty(pFrame);
+
+    return TRUE;
+}
+
+
+/*
+ * Destroy a frame.
+ */
+void
+xprDestroyFrame(RootlessFrameID wid)
+{
+    pthread_mutex_lock(&window_hash_mutex);
+    x_hash_table_remove(window_hash, wid);
+    pthread_mutex_unlock(&window_hash_mutex);
+
+    xp_destroy_window((xp_window_id) wid);
+}
+
+
+/*
+ * Move a frame on screen.
+ */
+void
+xprMoveFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY)
+{
+    xp_window_changes wc;
+
+    wc.x = newX;
+    wc.y = newY;
+    //    ErrorF("xprMoveFrame(%d, %p, %d, %d)\n", wid, pScreen, newX, newY);
+    xprConfigureWindow((xp_window_id) wid, XP_ORIGIN, &wc);
+}
+
+
+/*
+ * Resize and move a frame.
+ */
+void
+xprResizeFrame(RootlessFrameID wid, ScreenPtr pScreen,
+               int newX, int newY, unsigned int newW, unsigned int newH,
+               unsigned int gravity)
+{
+    xp_window_changes wc;
+
+    wc.x = newX;
+    wc.y = newY;
+    wc.width = newW;
+    wc.height = newH;
+    wc.bit_gravity = gravity;
+
+    /* It's unlikely that being async will save us anything here.
+       But it can't hurt. */
+
+    xprConfigureWindow((xp_window_id) wid, XP_BOUNDS, &wc);
+}
+
+
+/*
+ * Change frame stacking.
+ */
+void
+xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid)
+{
+    xp_window_changes wc;
+
+    /* Stack frame below nextWid it if it exists, or raise
+       frame above everything otherwise. */
+
+    if (nextWid == NULL)
+    {
+        wc.stack_mode = XP_MAPPED_ABOVE;
+        wc.sibling = 0;
+    }
+    else
+    {
+        wc.stack_mode = XP_MAPPED_BELOW;
+        wc.sibling = (xp_window_id) nextWid;
+    }
+
+    xprConfigureWindow((xp_window_id) wid, XP_STACKING, &wc);
+}
+
+
+/*
+ * Change the frame's shape.
+ */
+void
+xprReshapeFrame(RootlessFrameID wid, RegionPtr pShape)
+{
+    xp_window_changes wc;
+
+    if (pShape != NULL)
+    {
+        wc.shape_nrects = REGION_NUM_RECTS(pShape);
+        wc.shape_rects = REGION_RECTS(pShape);
+    }
+    else
+    {
+        wc.shape_nrects = -1;
+        wc.shape_rects = NULL;
+    }
+
+    wc.shape_tx = wc.shape_ty = 0;
+
+    xprConfigureWindow((xp_window_id) wid, XP_SHAPE, &wc);
+}
+
+
+/*
+ * Unmap a frame.
+ */
+void
+xprUnmapFrame(RootlessFrameID wid)
+{
+    xp_window_changes wc;
+
+    wc.stack_mode = XP_UNMAPPED;
+    wc.sibling = 0;
+
+    xprConfigureWindow((xp_window_id) wid, XP_STACKING, &wc);
+}
+
+
+/*
+ * Start drawing to a frame.
+ *  Prepare for direct access to its backing buffer.
+ */
+void
+xprStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPerRow)
+{
+    void *data[2];
+    unsigned int rowbytes[2];
+    xp_error err;
+
+    err = xp_lock_window((xp_window_id) wid, NULL, NULL, data, rowbytes, NULL);
+    if (err != Success)
+        FatalError("Could not lock window %i for drawing.", (int) wid);
+
+    *pixelData = data[0];
+    *bytesPerRow = rowbytes[0];
+}
+
+
+/*
+ * Stop drawing to a frame.
+ */
+void
+xprStopDrawing(RootlessFrameID wid, Bool flush)
+{
+    xp_unlock_window((xp_window_id) wid, flush);
+}
+
+
+/*
+ * Flush drawing updates to the screen.
+ */
+void
+xprUpdateRegion(RootlessFrameID wid, RegionPtr pDamage)
+{
+    xp_flush_window((xp_window_id) wid);
+}
+
+
+/*
+ * Mark damaged rectangles as requiring redisplay to screen.
+ */
+void
+xprDamageRects(RootlessFrameID wid, int nrects, const BoxRec *rects,
+               int shift_x, int shift_y)
+{
+    xp_mark_window((xp_window_id) wid, nrects, rects, shift_x, shift_y);
+}
+
+
+/*
+ * Called after the window associated with a frame has been switched
+ * to a new top-level parent.
+ */
+void
+xprSwitchWindow(RootlessWindowPtr pFrame, WindowPtr oldWin)
+{
+    DeleteProperty(oldWin, xa_native_window_id());
+
+    xprSetNativeProperty(pFrame);
+}
+
+
+/*
+ * Called to check if the frame should be reordered when it is restacked.
+ */
+Bool xprDoReorderWindow(RootlessWindowPtr pFrame)
+{
+    WindowPtr pWin = pFrame->win;
+
+    return AppleWMDoReorderWindow(pWin);
+}
+
+
+/*
+ * Copy area in frame to another part of frame.
+ *  Used to accelerate scrolling.
+ */
+void
+xprCopyWindow(RootlessFrameID wid, int dstNrects, const BoxRec *dstRects,
+              int dx, int dy)
+{
+    xp_copy_window((xp_window_id) wid, (xp_window_id) wid,
+                   dstNrects, dstRects, dx, dy);
+}
+
+
+static RootlessFrameProcsRec xprRootlessProcs = {
+    xprCreateFrame,
+    xprDestroyFrame,
+    xprMoveFrame,
+    xprResizeFrame,
+    xprRestackFrame,
+    xprReshapeFrame,
+    xprUnmapFrame,
+    xprStartDrawing,
+    xprStopDrawing,
+    xprUpdateRegion,
+    xprDamageRects,
+    xprSwitchWindow,
+    xprDoReorderWindow,
+    xp_copy_bytes,
+    xp_fill_bytes,
+    xp_composite_pixels,
+    xprCopyWindow
+};
+
+
+/*
+ * Initialize XPR implementation
+ */
+Bool
+xprInit(ScreenPtr pScreen)
+{
+    RootlessInit(pScreen, &xprRootlessProcs);
+
+    rootless_CopyBytes_threshold = xp_copy_bytes_threshold;
+    rootless_FillBytes_threshold = xp_fill_bytes_threshold;
+    rootless_CompositePixels_threshold = xp_composite_area_threshold;
+    rootless_CopyWindow_threshold = xp_scroll_area_threshold;
+
+    no_configure_window = FALSE;
+
+    return TRUE;
+}
+
+
+/*
+ * Given the id of a physical window, try to find the top-level (or root)
+ * X window that it represents.
+ */
+WindowPtr
+xprGetXWindow(xp_window_id wid)
+{
+    RootlessWindowRec *winRec;
+
+    if (window_hash == NULL)
+        return NULL;
+
+    winRec = x_hash_table_lookup(window_hash, (void *) wid, NULL);
+
+    return winRec != NULL ? winRec->win : NULL;
+}
+
+/*
+ * Given the id of a physical window, try to find the top-level (or root)
+ * X window that it represents.
+ */
+WindowPtr
+xprGetXWindowFromAppKit(int windowNumber)
+{
+    RootlessWindowRec *winRec;
+    Bool ret;
+    xp_window_id wid;
+
+    if (window_hash == NULL)
+        return FALSE;
+
+    /* need to lock, since this function can be called by any thread */
+
+    pthread_mutex_lock(&window_hash_mutex);
+
+    if (xp_lookup_native_window(windowNumber, &wid))
+        ret = xprGetXWindow(wid) != NULL;
+    else
+        ret = FALSE;
+
+    pthread_mutex_unlock(&window_hash_mutex);
+
+    if (!ret) return NULL;
+    winRec = x_hash_table_lookup(window_hash, (void *) wid, NULL);
+
+    return winRec != NULL ? winRec->win : NULL;
+}
+
+
+/*
+ * The windowNumber is an AppKit window number. Returns TRUE if xpr is
+ * displaying a window with that number.
+ */
+Bool
+xprIsX11Window(void *nsWindow, int windowNumber)
+{
+    Bool ret;
+    xp_window_id wid;
+
+    if (window_hash == NULL)
+        return FALSE;
+
+    /* need to lock, since this function can be called by any thread */
+
+    pthread_mutex_lock(&window_hash_mutex);
+
+    if (xp_lookup_native_window(windowNumber, &wid))
+        ret = xprGetXWindow(wid) != NULL;
+    else
+        ret = FALSE;
+
+    pthread_mutex_unlock(&window_hash_mutex);
+
+    return ret;
+}
+
+
+/*
+ * xprHideWindows
+ *  Hide or unhide all top level windows. This is called for application hide/
+ *  unhide events if the window manager is not Apple-WM aware. Xplugin windows
+ *  do not hide or unhide themselves.
+ */
+void
+xprHideWindows(Bool hide)
+{
+    int screen;
+    WindowPtr pRoot, pWin;
+
+    for (screen = 0; screen < screenInfo.numScreens; screen++) {
+        pRoot = WindowTable[screenInfo.screens[screen]->myNum];
+        RootlessFrameID prevWid = NULL;
+
+        for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib) {
+            RootlessWindowRec *winRec = WINREC(pWin);
+
+            if (winRec != NULL) {
+                if (hide) {
+                    xprUnmapFrame(winRec->wid);
+                } else {
+                    BoxRec box;
+
+                    xprRestackFrame(winRec->wid, prevWid);
+                    prevWid = winRec->wid;
+
+                    box.x1 = 0;
+                    box.y1 = 0;
+                    box.x2 = winRec->width;
+                    box.y2 = winRec->height;
+
+                    xprDamageRects(winRec->wid, 1, &box, 0, 0);
+                    RootlessQueueRedisplay(screenInfo.screens[screen]);
+                }
+            }
+        }
+    }
+}
diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c
new file mode 100644
index 0000000..068b7b1
--- /dev/null
+++ b/hw/xquartz/xpr/xprScreen.c
@@ -0,0 +1,414 @@
+/*
+ * Xplugin rootless implementation screen functions
+ *
+ * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved.
+ * Copyright (c) 2004 Torrey T. Lyons. 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
+ * 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "quartzCommon.h"
+#include "quartz.h"
+#include "xpr.h"
+#include "pseudoramiX.h"
+#include "darwin.h"
+#include "rootless.h"
+#include "safeAlpha/safeAlpha.h"
+#include "dri.h"
+#include "globals.h"
+#include "Xplugin.h"
+#include "applewmExt.h"
+
+// From xprFrame.c
+WindowPtr xprGetXWindow(xp_window_id wid);
+
+#ifdef DAMAGE
+# include "damage.h"
+#endif
+
+/* 10.4's deferred update makes X slower.. have to live with the tearing
+   for now.. */
+#define XP_NO_DEFERRED_UPDATES 8
+
+// Name of GLX bundle for native OpenGL
+static const char *xprOpenGLBundle = "glxCGL.bundle";
+
+/*
+ * eventHandler
+ *  Callback handler for Xplugin events.
+ */
+static void
+eventHandler(unsigned int type, const void *arg,
+             unsigned int arg_size, void *data)
+{
+    switch (type) {
+    case XP_EVENT_DISPLAY_CHANGED:
+      DEBUG_LOG("XP_EVENT_DISPLAY_CHANGED\n");
+      QuartzMessageServerThread(kXDarwinDisplayChanged, 0);
+      break;
+
+    case XP_EVENT_WINDOW_STATE_CHANGED:
+      DEBUG_LOG("XP_EVENT_WINDOW_STATE_CHANGED\n");
+      if (arg_size >= sizeof(xp_window_state_event)) {
+	const xp_window_state_event *ws_arg = arg;
+	
+	QuartzMessageServerThread(kXDarwinWindowState, 2,
+				  ws_arg->id, ws_arg->state);
+      }
+      break;
+
+    case XP_EVENT_WINDOW_MOVED:
+      DEBUG_LOG("XP_EVENT_WINDOW_MOVED\n");
+      if (arg_size == sizeof(xp_window_id))  {
+	xp_window_id id = * (xp_window_id *) arg;
+	WindowPtr pWin = xprGetXWindow(id);
+	QuartzMessageServerThread(kXDarwinWindowMoved, 1, pWin);
+      }
+      break;
+      
+    case XP_EVENT_SURFACE_DESTROYED:
+      DEBUG_LOG("XP_EVENT_SURFACE_DESTROYED\n");
+    case XP_EVENT_SURFACE_CHANGED:
+      DEBUG_LOG("XP_EVENT_SURFACE_CHANGED\n");
+        if (arg_size == sizeof(xp_surface_id)) {
+	  int kind;
+	  
+	  if (type == XP_EVENT_SURFACE_DESTROYED)
+	    kind = AppleDRISurfaceNotifyDestroyed;
+	  else
+	    kind = AppleDRISurfaceNotifyChanged;
+	  
+	  DRISurfaceNotify(*(xp_surface_id *) arg, kind);
+        }
+        break;
+    default:
+      ErrorF("Unknown XP_EVENT type (%d) in xprScreen:eventHandler\n",
+	     type);
+    }
+}
+
+/*
+ * displayAtIndex
+ *  Return the display ID for a particular display index.
+ */
+static CGDirectDisplayID
+displayAtIndex(int index)
+{
+    CGError err;
+    CGDisplayCount cnt;
+    CGDirectDisplayID dpy[index+1];
+
+    err = CGGetActiveDisplayList(index + 1, dpy, &cnt);
+    if (err == kCGErrorSuccess && cnt == index + 1)
+        return dpy[index];
+    else
+        return kCGNullDirectDisplay;
+}
+
+/*
+ * displayScreenBounds
+ *  Return the bounds of a particular display.
+ */
+static CGRect
+displayScreenBounds(CGDirectDisplayID id)
+{
+    CGRect frame;
+
+    frame = CGDisplayBounds(id);
+
+    /* Remove menubar to help standard X11 window managers. */
+
+    if (frame.origin.x == 0 && frame.origin.y == 0)
+    {
+        frame.origin.y += aquaMenuBarHeight;
+        frame.size.height -= aquaMenuBarHeight;
+    }
+
+    return frame;
+}
+
+/*
+ * xprAddPseudoramiXScreens
+ *  Add a single virtual screen encompassing all the physical screens
+ *  with PseudoramiX.
+ */
+static void
+xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height)
+{
+    CGDisplayCount i, displayCount;
+    CGDirectDisplayID *displayList = NULL;
+    CGRect unionRect = CGRectNull, frame;
+
+    // Find all the CoreGraphics displays
+    CGGetActiveDisplayList(0, NULL, &displayCount);
+    displayList = xalloc(displayCount * sizeof(CGDirectDisplayID));
+    CGGetActiveDisplayList(displayCount, displayList, &displayCount);
+
+    /* Get the union of all screens */
+    for (i = 0; i < displayCount; i++)
+    {
+        CGDirectDisplayID dpy = displayList[i];
+        frame = displayScreenBounds(dpy);
+        unionRect = CGRectUnion(unionRect, frame);
+    }
+
+    /* Use unionRect as the screen size for the X server. */
+    *x = unionRect.origin.x;
+    *y = unionRect.origin.y;
+    *width = unionRect.size.width;
+    *height = unionRect.size.height;
+
+    /* Tell PseudoramiX about the real screens. */
+    for (i = 0; i < displayCount; i++)
+    {
+        CGDirectDisplayID dpy = displayList[i];
+
+        frame = displayScreenBounds(dpy);
+
+	/*        ErrorF("PseudoramiX screen %d added: %dx%d @ (%d,%d).\n", i,
+               (int)frame.size.width, (int)frame.size.height,
+               (int)frame.origin.x, (int)frame.origin.y); */
+
+        frame.origin.x -= unionRect.origin.x;
+        frame.origin.y -= unionRect.origin.y;
+
+	/*        ErrorF("PseudoramiX screen %d placed at X11 coordinate (%d,%d).\n",
+		  i, (int)frame.origin.x, (int)frame.origin.y); */
+
+        PseudoramiXAddScreen(frame.origin.x, frame.origin.y,
+                             frame.size.width, frame.size.height);
+    }
+
+    xfree(displayList);
+}
+
+/*
+ * xprDisplayInit
+ *  Find number of CoreGraphics displays and initialize Xplugin.
+ */
+static void
+xprDisplayInit(void)
+{
+    CGDisplayCount displayCount;
+
+    //    ErrorF("Display mode: Rootless Quartz -- Xplugin implementation\n");
+
+    CGGetActiveDisplayList(0, NULL, &displayCount);
+
+    /* With PseudoramiX, the X server only sees one screen; only PseudoramiX
+       itself knows about all of the screens. */
+
+    if (noPseudoramiXExtension)
+        darwinScreensFound = displayCount;
+    else
+        darwinScreensFound =  1;
+
+    if (xp_init(XP_BACKGROUND_EVENTS | XP_NO_DEFERRED_UPDATES) != Success)
+        FatalError("Could not initialize the Xplugin library.");
+
+    xp_select_events(XP_EVENT_DISPLAY_CHANGED
+                     | XP_EVENT_WINDOW_STATE_CHANGED
+                     | XP_EVENT_WINDOW_MOVED
+                     | XP_EVENT_SURFACE_CHANGED
+                     | XP_EVENT_SURFACE_DESTROYED,
+                     eventHandler, NULL);
+
+    AppleDRIExtensionInit();
+    xprAppleWMInit();
+}
+
+/*
+ * xprAddScreen
+ *  Init the framebuffer and record pixmap parameters for the screen.
+ */
+static Bool
+xprAddScreen(int index, ScreenPtr pScreen)
+{
+    DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen);
+
+    /* If no specific depth chosen, look for the depth of the main display.
+       Else if 16bpp specified, use that. Else use 32bpp. */
+
+    dfb->colorType = TrueColor;
+    dfb->bitsPerComponent = 8;
+    dfb->bitsPerPixel = 32;
+    dfb->colorBitsPerPixel = 24;
+
+    if (darwinDesiredDepth == -1)
+    {
+        dfb->bitsPerComponent = CGDisplayBitsPerSample(kCGDirectMainDisplay);
+        dfb->bitsPerPixel = CGDisplayBitsPerPixel(kCGDirectMainDisplay);
+        dfb->colorBitsPerPixel =
+                CGDisplaySamplesPerPixel(kCGDirectMainDisplay) *
+                dfb->bitsPerComponent;
+    }
+    else if (darwinDesiredDepth == 15)
+    {
+        dfb->bitsPerComponent = 5;
+        dfb->bitsPerPixel = 16;
+        dfb->colorBitsPerPixel = 15;
+    }
+    else if (darwinDesiredDepth == 8)
+    {
+        dfb->colorType = PseudoColor;
+        dfb->bitsPerComponent = 8;
+        dfb->bitsPerPixel = 8;
+        dfb->colorBitsPerPixel = 8;
+    }
+
+    if (noPseudoramiXExtension)
+    {
+        CGDirectDisplayID dpy;
+        CGRect frame;
+
+        dpy = displayAtIndex(index);
+
+        frame = displayScreenBounds(dpy);
+
+        dfb->x = frame.origin.x;
+        dfb->y = frame.origin.y;
+        dfb->width =  frame.size.width;
+        dfb->height = frame.size.height;
+    }
+    else
+    {
+        xprAddPseudoramiXScreens(&dfb->x, &dfb->y, &dfb->width, &dfb->height);
+    }
+
+    /* Passing zero width (pitch) makes miCreateScreenResources set the
+       screen pixmap to the framebuffer pointer, i.e. NULL. The generic
+       rootless code takes care of making this work. */
+    dfb->pitch = 0;
+    dfb->framebuffer = NULL;
+
+    DRIScreenInit(pScreen);
+
+    return TRUE;
+}
+
+/*
+ * xprSetupScreen
+ *  Setup the screen for rootless access.
+ */
+static Bool
+xprSetupScreen(int index, ScreenPtr pScreen)
+{
+    // Add alpha protecting replacements for fb screen functions
+
+#ifdef RENDER
+    {
+        PictureScreenPtr ps = GetPictureScreen(pScreen);
+        ps->Composite = SafeAlphaComposite;
+    }
+#endif /* RENDER */
+
+    // Initialize accelerated rootless drawing
+    // Note that this must be done before DamageSetup().
+    RootlessAccelInit(pScreen);
+
+#ifdef DAMAGE
+    // The Damage extension needs to wrap underneath the
+    // generic rootless layer, so do it now.
+    if (!DamageSetup(pScreen))
+        return FALSE;
+#endif
+
+    // Initialize generic rootless code
+    if (!xprInit(pScreen))
+        return FALSE;
+
+    return DRIFinishScreenInit(pScreen);
+}
+
+/*
+ * xprUpdateScreen
+ *  Update screen after configuation change.
+ */
+static void
+xprUpdateScreen(ScreenPtr pScreen)
+{
+    rootlessGlobalOffsetX = darwinMainScreenX;
+    rootlessGlobalOffsetY = darwinMainScreenY;
+
+    AppleWMSetScreenOrigin(WindowTable[pScreen->myNum]);
+
+    RootlessRepositionWindows(pScreen);
+    RootlessUpdateScreenPixmap(pScreen);
+}
+
+/*
+ * xprInitInput
+ *  Finalize xpr specific setup.
+ */
+static void
+xprInitInput(int argc, char **argv)
+{
+    int i;
+
+    rootlessGlobalOffsetX = darwinMainScreenX;
+    rootlessGlobalOffsetY = darwinMainScreenY;
+
+    for (i = 0; i < screenInfo.numScreens; i++)
+        AppleWMSetScreenOrigin(WindowTable[i]);
+}
+
+/*
+ * Quartz display mode function list.
+ */
+static QuartzModeProcsRec xprModeProcs = {
+    xprDisplayInit,
+    xprAddScreen,
+    xprSetupScreen,
+    xprInitInput,
+    QuartzInitCursor,
+    NULL,               // No need to update cursor
+    QuartzSuspendXCursor,
+    QuartzResumeXCursor,
+    NULL,               // No capture or release in rootless mode
+    NULL,
+    NULL,               // Xplugin sends screen change events directly
+    xprAddPseudoramiXScreens,
+    xprUpdateScreen,
+    xprIsX11Window,
+    xprHideWindows,
+    RootlessFrameForWindow,
+    TopLevelParent,
+    DRICreateSurface,
+    DRIDestroySurface
+};
+
+/*
+ * QuartzModeBundleInit
+ *  Initialize the display mode bundle after loading.
+ */
+Bool
+QuartzModeBundleInit(void)
+{
+    quartzProcs = &xprModeProcs;
+    quartzOpenGLBundle = xprOpenGLBundle;
+    return TRUE;
+}
commit 2c68f4aa3ae4b96a65c5ffbc21bec7c619f11806
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Tue Dec 4 23:18:37 2007 -0800

    Darwin: Cleaned up keyboard interface headers
    (cherry picked from commit 141f69dc3d8d6e7d8ff65607f43700ac11243041)

diff --git a/hw/darwin/darwin.h b/hw/darwin/darwin.h
index d7d2af4..0f5f492 100644
--- a/hw/darwin/darwin.h
+++ b/hw/darwin/darwin.h
@@ -46,7 +46,6 @@ typedef struct {
     int                 bitsPerComponent;
 } DarwinFramebufferRec, *DarwinFramebufferPtr;
 
-
 // From darwin.c
 void DarwinPrintBanner(void);
 int DarwinParseModifierList(const char *constmodifiers);
@@ -63,14 +62,6 @@ void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int poin
 void DarwinSendKeyboardEvents(int ev_type, int keycode);
 void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y);
 
-// From darwinKeyboard.c
-int DarwinModifierNXKeyToNXKeycode(int key, int side);
-void DarwinKeyboardInit(DeviceIntPtr pDev);
-int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide);
-int DarwinModifierNXKeyToNXMask(int key);
-int DarwinModifierNXMaskToNXKey(int mask);
-int DarwinModifierStringToNXKey(const char *string);
-
 // Mode specific functions
 Bool DarwinModeAddScreen(int index, ScreenPtr pScreen);
 Bool DarwinModeSetupScreen(int index, ScreenPtr pScreen);
diff --git a/hw/darwin/darwinKeyboard.c b/hw/darwin/darwinKeyboard.c
index 851a10f..1c83cbc 100644
--- a/hw/darwin/darwinKeyboard.c
+++ b/hw/darwin/darwinKeyboard.c
@@ -179,7 +179,7 @@ static KeySym const next_to_x[256] = {
 static KeySym const symbol_to_x[] = {
     XK_Left,        XK_Up,          XK_Right,      XK_Down
   };
-int const NUM_SYMBOL = sizeof(symbol_to_x) / sizeof(symbol_to_x[0]);
+static int const NUM_SYMBOL = sizeof(symbol_to_x) / sizeof(symbol_to_x[0]);
 
 #define MIN_FUNCKEY     0x20
 static KeySym const funckey_to_x[] = {
@@ -190,7 +190,7 @@ static KeySym const funckey_to_x[] = {
     XK_Page_Up,     XK_Page_Down,   XK_F13,         XK_F14,
     XK_F15
   };
-int const NUM_FUNCKEY = sizeof(funckey_to_x) / sizeof(funckey_to_x[0]);
+static int const NUM_FUNCKEY = sizeof(funckey_to_x) / sizeof(funckey_to_x[0]);
 
 typedef struct {
     KeySym      normalSym;
@@ -216,7 +216,7 @@ static darwinKeyPad_t const normal_to_keypad[] = {
     { XK_period,    XK_KP_Decimal },
     { XK_slash,     XK_KP_Divide }
 };
-int const NUM_KEYPAD = sizeof(normal_to_keypad) / sizeof(normal_to_keypad[0]);
+static int const NUM_KEYPAD = sizeof(normal_to_keypad) / sizeof(normal_to_keypad[0]);
 
 static void DarwinChangeKeyboardControl( DeviceIntPtr device, KeybdCtrl *ctrl )
 {
@@ -232,35 +232,32 @@ static char *inBuffer = NULL;
 //      Can be configured to treat embedded "numbers" as being composed of
 //      either 1, 2, or 4 bytes, apiece.
 //-----------------------------------------------------------------------------
-typedef struct _DataStream
-{
+typedef struct _DataStream {
     unsigned char const *data;
     unsigned char const *data_end;
     short number_size;  // Size in bytes of a "number" in the stream.
 } DataStream;
 
-static DataStream* new_data_stream( unsigned char const* data, int size )
-{
+static DataStream* new_data_stream(unsigned char const* data, int size) {
     DataStream* s = (DataStream*)xalloc( sizeof(DataStream) );
-    s->data = data;
-    s->data_end = data + size;
-    s->number_size = 1; // Default to byte-sized numbers.
+    if(s) {
+        s->data = data;
+        s->data_end = data + size;
+        s->number_size = 1; // Default to byte-sized numbers.
+    }
     return s;
 }
 
-static void destroy_data_stream( DataStream* s )
-{
+static void destroy_data_stream(DataStream* s) {
     xfree(s);
 }
 
-static unsigned char get_byte( DataStream* s )
-{
+static unsigned char get_byte(DataStream* s) {
     assert(s->data + 1 <= s->data_end);
     return *s->data++;
 }
 
-static short get_word( DataStream* s )
-{
+static short get_word(DataStream* s) {
     short hi, lo;
     assert(s->data + 2 <= s->data_end);
     hi = *s->data++;
@@ -268,8 +265,7 @@ static short get_word( DataStream* s )
     return ((hi << 8) | lo);
 }
 
-static int get_dword( DataStream* s )
-{
+static int get_dword(DataStream* s) {
     int b1, b2, b3, b4;
     assert(s->data + 4 <= s->data_end);
     b4 = *s->data++;
@@ -279,8 +275,7 @@ static int get_dword( DataStream* s )
     return ((b4 << 24) | (b3 << 16) | (b2 << 8) | b1);
 }
 
-static int get_number( DataStream* s )
-{
+static int get_number(DataStream* s) {
     switch (s->number_size) {
         case 4:  return get_dword(s);
         case 2:  return get_word(s);
@@ -296,8 +291,7 @@ static int get_number( DataStream* s )
  * bits_set
  *      Calculate number of bits set in the modifier mask.
  */
-static short bits_set( short mask )
-{
+static short bits_set(short mask) {
     short n = 0;
 
     for ( ; mask != 0; mask >>= 1)
@@ -311,10 +305,7 @@ static short bits_set( short mask )
  *      Read the next character code from the Darwin keymapping
  *      and write it to the X keymap.
  */
-static void parse_next_char_code(
-    DataStream  *s,
-    KeySym      *k )
-{
+static void parse_next_char_code(DataStream *s, KeySym *k) {
     const short charSet = get_number(s);
     const short charCode = get_number(s);
 
@@ -337,9 +328,7 @@ static void parse_next_char_code(
  * DarwinReadKeymapFile
  *      Read the appropriate keymapping from a keymapping file.
  */
-Bool DarwinReadKeymapFile(
-    NXKeyMapping        *keyMap)
-{
+Bool DarwinReadKeymapFile(NXKeyMapping *keyMap) {
     struct stat         st;
     NXEventSystemDevice info[20];
     int                 interface = 0, handler_id = 0;
@@ -448,9 +437,7 @@ Bool DarwinReadKeymapFile(
 /*
  * DarwinParseNXKeyMapping
  */
-Bool DarwinParseNXKeyMapping(
-    darwinKeyboardInfo  *info)
-{
+Bool DarwinParseNXKeyMapping(darwinKeyboardInfo  *info) {
     KeySym              *k;
     int                 i;
     short               numMods, numKeys, numPadKeys = 0;
@@ -649,8 +636,7 @@ Bool DarwinParseNXKeyMapping(
  *      Use the keyMap field of keyboard info structure to populate
  *      the modMap and modifierKeycodes fields.
  */
-static void
-DarwinBuildModifierMaps(darwinKeyboardInfo *info) {
+static void DarwinBuildModifierMaps(darwinKeyboardInfo *info) {
     int i;
     KeySym *k;
 
@@ -743,12 +729,7 @@ DarwinBuildModifierMaps(darwinKeyboardInfo *info) {
  *  Load the keyboard map from a file or system and convert
  *  it to an equivalent X keyboard map and modifier map.
  */
-static void
-DarwinLoadKeyboardMapping(KeySymsRec *keySyms)
-{
-    int i;
-    KeySym *k;
-
+static void DarwinLoadKeyboardMapping(KeySymsRec *keySyms) {
     memset(keyInfo.keyMap, 0, sizeof(keyInfo.keyMap));
 
     /* TODO: Clean this up
@@ -765,6 +746,8 @@ DarwinLoadKeyboardMapping(KeySymsRec *keySyms)
     DarwinBuildModifierMaps(&keyInfo);
 
 #ifdef DUMP_DARWIN_KEYMAP
+    int i;
+    KeySym *k;
     DEBUG_LOG("Darwin -> X converted keyboard map\n");
     for (i = 0, k = keyInfo.keyMap; i < NX_NUMKEYCODES;
          i++, k += GLYPHS_PER_KEY)
@@ -793,9 +776,7 @@ DarwinLoadKeyboardMapping(KeySymsRec *keySyms)
  *      X keyboard map and modifier map. Set the new keyboard
  *      device structure.
  */
-void DarwinKeyboardInit(
-    DeviceIntPtr        pDev )
-{
+void DarwinKeyboardInit(DeviceIntPtr pDev) {
     KeySymsRec          keySyms;
 
     // Open a shared connection to the HID System.
@@ -816,9 +797,7 @@ void DarwinKeyboardInit(
 
 
 /* Borrowed from dix/devices.c */
-static Bool
-InitModMap(register KeyClassPtr keyc)
-{
+static Bool InitModMap(register KeyClassPtr keyc) {
     int i, j;
     CARD8 keysPerModifier[8];
     CARD8 mask;
@@ -863,9 +842,7 @@ InitModMap(register KeyClassPtr keyc)
 }
 
 
-void
-DarwinKeyboardReload(DeviceIntPtr pDev)
-{
+void DarwinKeyboardReload(DeviceIntPtr pDev) {
     KeySymsRec keySyms;
 
     DarwinLoadKeyboardMapping(&keySyms);
@@ -898,8 +875,7 @@ DarwinKeyboardReload(DeviceIntPtr pDev)
  *      side = 0 for left or 1 for right.
  *      Returns 0 if key+side is not a known modifier.
  */
-int DarwinModifierNXKeyToNXKeycode(int key, int side)
-{
+int DarwinModifierNXKeyToNXKeycode(int key, int side) {
     return keyInfo.modifierKeycodes[key][side];
 }
 
@@ -908,8 +884,7 @@ int DarwinModifierNXKeyToNXKeycode(int key, int side)
  *      Returns -1 if keycode+side is not a modifier key
  *      outSide may be NULL, else it gets 0 for left and 1 for right.
  */
-int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide)
-{
+int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide) {
     int key, side;
 
     keycode += MIN_KEYCODE;
@@ -928,8 +903,7 @@ int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide)
  * DarwinModifierNXMaskToNXKey
  *      Returns -1 if mask is not a known modifier mask.
  */
-int DarwinModifierNXMaskToNXKey(int mask)
-{
+int DarwinModifierNXMaskToNXKey(int mask) {
     switch (mask) {
         case NX_ALPHASHIFTMASK:       return NX_MODIFIERKEY_ALPHALOCK;
         case NX_SHIFTMASK:            return NX_MODIFIERKEY_SHIFT;
@@ -959,8 +933,7 @@ int DarwinModifierNXMaskToNXKey(int mask)
     return -1;
 }
 
-const char *DarwinModifierNXMaskTostring(int mask)
-{
+const char *DarwinModifierNXMaskTostring(int mask) {
     switch (mask) {
         case NX_ALPHASHIFTMASK:      return "NX_ALPHASHIFTMASK";
         case NX_SHIFTMASK:           return "NX_SHIFTMASK";
@@ -986,8 +959,7 @@ const char *DarwinModifierNXMaskTostring(int mask)
  * DarwinModifierNXKeyToNXMask
  *      Returns 0 if key is not a known modifier key.
  */
-int DarwinModifierNXKeyToNXMask(int key)
-{
+int DarwinModifierNXKeyToNXMask(int key) {
     switch (key) {
         case NX_MODIFIERKEY_ALPHALOCK:   return NX_ALPHASHIFTMASK;
         case NX_MODIFIERKEY_SHIFT:       return NX_SHIFTMASK;
@@ -1017,8 +989,7 @@ int DarwinModifierNXKeyToNXMask(int key)
  * DarwinModifierStringToNXKey
  *      Returns -1 if string is not a known modifier.
  */
-int DarwinModifierStringToNXKey(const char *str)
-{
+int DarwinModifierStringToNXKey(const char *str) {
     if      (!strcasecmp(str, "shift"))   return NX_MODIFIERKEY_SHIFT;
     else if (!strcasecmp(str, "control")) return NX_MODIFIERKEY_CONTROL;
     else if (!strcasecmp(str, "option"))  return NX_MODIFIERKEY_ALTERNATE;
diff --git a/hw/darwin/darwinKeyboard.h b/hw/darwin/darwinKeyboard.h
index 368aee9..1210441 100644
--- a/hw/darwin/darwinKeyboard.h
+++ b/hw/darwin/darwinKeyboard.h
@@ -27,25 +27,19 @@
 #ifndef DARWIN_KEYBOARD_H
 #define DARWIN_KEYBOARD_H 1
 
-#define XK_TECHNICAL		// needed to get XK_Escape
-#define XK_PUBLISHING
-#include "X11/keysym.h"
-#include "inputstr.h"
-
-// Each key can generate 4 glyphs. They are, in order:
-// unshifted, shifted, modeswitch unshifted, modeswitch shifted
-#define GLYPHS_PER_KEY  4
-#define NUM_KEYCODES    248	// NX_NUMKEYCODES might be better
-#define MAX_KEYCODE     NUM_KEYCODES + MIN_KEYCODE - 1
-
-typedef struct darwinKeyboardInfo_struct {
-    CARD8 modMap[MAP_LENGTH];
-    KeySym keyMap[MAP_LENGTH * GLYPHS_PER_KEY];
-    unsigned char modifierKeycodes[32][2];
-} darwinKeyboardInfo;
+#include "darwinKeyboard_interface.h"
 
+/* Provided for darwinEvents.c */
+extern darwinKeyboardInfo keyInfo;
 void DarwinKeyboardReload(DeviceIntPtr pDev);
-unsigned int DarwinModeSystemKeymapSeed(void);
-Bool DarwinModeReadSystemKeymap(darwinKeyboardInfo *info);
+void DarwinKeyboardInit(DeviceIntPtr pDev);
+int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide);
+int DarwinModifierNXKeyToNXKeycode(int key, int side);
+int DarwinModifierNXKeyToNXMask(int key);
+int DarwinModifierNXMaskToNXKey(int mask);
+int DarwinModifierStringToNXKey(const char *string);
+
+/* Provided for darwin.c */
+void DarwinKeyboardInit(DeviceIntPtr pDev);
 
 #endif /* DARWIN_KEYBOARD_H */
diff --git a/hw/darwin/darwinKeyboard_interface.h b/hw/darwin/darwinKeyboard_interface.h
new file mode 100644
index 0000000..f41f463
--- /dev/null
+++ b/hw/darwin/darwinKeyboard_interface.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2003-2004 Torrey T. Lyons. 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
+ * 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 DARWIN_KEYBOARD_INTERFACE_H
+#define DARWIN_KEYBOARD_INTERFACE_H 1
+
+#define XK_TECHNICAL		// needed to get XK_Escape
+#define XK_PUBLISHING
+#include "X11/keysym.h"
+#include "inputstr.h"
+
+// Each key can generate 4 glyphs. They are, in order:
+// unshifted, shifted, modeswitch unshifted, modeswitch shifted
+#define GLYPHS_PER_KEY  4
+#define NUM_KEYCODES    248	// NX_NUMKEYCODES might be better
+#define MAX_KEYCODE     NUM_KEYCODES + MIN_KEYCODE - 1
+
+typedef struct darwinKeyboardInfo_struct {
+    CARD8 modMap[MAP_LENGTH];
+    KeySym keyMap[MAP_LENGTH * GLYPHS_PER_KEY];
+    unsigned char modifierKeycodes[32][2];
+} darwinKeyboardInfo;
+
+/* These functions need to be implemented by XQuartz, XDarwin, etc. */
+void DarwinKeyboardReload(DeviceIntPtr pDev);
+Bool DarwinModeReadSystemKeymap(darwinKeyboardInfo *info);
+unsigned int DarwinModeSystemKeymapSeed(void);
+
+#endif /* DARWIN_KEYBOARD_INTERFACE_H */
diff --git a/hw/darwin/quartz/quartzKeyboard.c b/hw/darwin/quartz/quartzKeyboard.c
index ee485b8..c69fb9f 100644
--- a/hw/darwin/quartz/quartzKeyboard.c
+++ b/hw/darwin/quartz/quartzKeyboard.c
@@ -40,7 +40,7 @@
 #include <CoreServices/CoreServices.h>
 #include <Carbon/Carbon.h>
 
-#include "darwinKeyboard.h"
+#include "darwinKeyboard_interface.h"
 #include "X11/keysym.h"
 #include "keysym2ucs.h"
 
@@ -146,9 +146,7 @@ const static struct {
     {UKEYSYM (0x31b), XK_dead_horn},		/* COMBINING HORN */
 };
 
-unsigned int
-DarwinModeSystemKeymapSeed (void)
-{
+unsigned int DarwinModeSystemKeymapSeed(void) {
     static unsigned int seed;
     static KeyboardLayoutRef last_key_layout;
     KeyboardLayoutRef key_layout;
@@ -160,9 +158,7 @@ DarwinModeSystemKeymapSeed (void)
     return seed;
 }
 
-static inline UniChar
-macroman2ucs (unsigned char c)
-{
+static inline UniChar macroman2ucs(unsigned char c) {
     /* Precalculated table mapping MacRoman-128 to Unicode. Generated
        by creating single element CFStringRefs then extracting the
        first character. */
@@ -190,9 +186,7 @@ macroman2ucs (unsigned char c)
     else         return table[c - 128];
 }
 
-static KeySym
-make_dead_key (KeySym in)
-{
+static KeySym make_dead_key(KeySym in) {
     int i;
 
     for (i = 0; i < sizeof (dead_keys) / sizeof (dead_keys[0]); i++)
@@ -201,9 +195,7 @@ make_dead_key (KeySym in)
     return in;
 }
 
-Bool
-DarwinModeReadSystemKeymap (darwinKeyboardInfo *info)
-{
+Bool DarwinModeReadSystemKeymap(darwinKeyboardInfo *info) {
     KeyboardLayoutRef key_layout;
     const void *chr_data = NULL;
     int num_keycodes = NUM_KEYCODES;
commit 9f4689173ef9db080592497dc2212ae79b8d6e02
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Dec 6 00:46:32 2007 +0000

    KDrive: Xephyr: Fix non-GLX builds
    
    Only set noGlxExtension if we're actually building GLX.

diff --git a/hw/kdrive/ephyr/ephyrinit.c b/hw/kdrive/ephyr/ephyrinit.c
index c33892c..e4ff975 100644
--- a/hw/kdrive/ephyr/ephyrinit.c
+++ b/hw/kdrive/ephyr/ephyrinit.c
@@ -47,7 +47,9 @@ InitCard (char *name)
 void
 InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
 {
+#ifdef GLXEXT
   noGlxExtension=TRUE;
+#endif
   KdInitOutput (pScreenInfo, argc, argv);
 }
 
commit d37351308b255d5f9bff3438b6767c62974902da
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Dec 5 19:37:48 2007 +0000

    XKB: Actions: Don't run certain actions on the core keyboard
    
    Don't run VT switches, terminations, or anything, on the core keyboard: only
    run actions which affect the keyboard state.  If we get an action such as VT
    switch, just swallow the event.
    (cherry picked from commit 320abd7d1d906807448fa01ad3377daf707f46cc)

diff --git a/hw/xfree86/dixmods/xkbKillSrv.c b/hw/xfree86/dixmods/xkbKillSrv.c
index b3399db..9074fd3 100644
--- a/hw/xfree86/dixmods/xkbKillSrv.c
+++ b/hw/xfree86/dixmods/xkbKillSrv.c
@@ -48,6 +48,8 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 int
 XkbDDXTerminateServer(DeviceIntPtr dev,KeyCode key,XkbAction *act)
 {
-    xf86ProcessActionEvent(ACTION_TERMINATE, NULL);
+    if (dev != inputInfo.keyboard)
+        xf86ProcessActionEvent(ACTION_TERMINATE, NULL);
+
     return 0;
 }
diff --git a/xkb/ddxKillSrv.c b/xkb/ddxKillSrv.c
index a573ecb..3b5fd53 100644
--- a/xkb/ddxKillSrv.c
+++ b/xkb/ddxKillSrv.c
@@ -41,6 +41,8 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 int
 XkbDDXTerminateServer(DeviceIntPtr dev,KeyCode key,XkbAction *act)
 {
-    GiveUp(1);
+    if (dev != inputInfo.keyboard)
+        GiveUp(1);
+
     return 0;
 }
diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
index 8ddbdba..6edac29 100644
--- a/xkb/xkbActions.c
+++ b/xkb/xkbActions.c
@@ -561,6 +561,9 @@ _XkbFilterPointerMove(	XkbSrvInfoPtr	xkbi,
 int	x,y;
 Bool	accel;
 
+    if (xkbi->device == inputInfo.keyboard)
+        return 0;
+
     if (filter->keycode==0) {		/* initial press */
 	filter->keycode = keycode;
 	filter->active = 1;
@@ -601,6 +604,9 @@ _XkbFilterPointerBtn(	XkbSrvInfoPtr	xkbi,
 			unsigned	keycode,
 			XkbAction *	pAction)
 {
+    if (xkbi->device == inputInfo.keyboard)
+        return 0;
+
     if (filter->keycode==0) {		/* initial press */
 	int	button= pAction->btn.button;
 
@@ -980,8 +986,11 @@ _XkbFilterSwitchScreen(	XkbSrvInfoPtr	xkbi,
 			unsigned	keycode,
 			XkbAction *	pAction)
 {
+    DeviceIntPtr dev = xkbi->device;
+    if (dev == inputInfo.keyboard)
+        return 0;
+
     if (filter->keycode==0) {		/* initial press */
-        DeviceIntPtr	dev = xkbi->device;
 	filter->keycode = keycode;
 	filter->active = 1;
 	filter->filterOthers = 0;
@@ -1003,8 +1012,11 @@ _XkbFilterXF86Private(	XkbSrvInfoPtr	xkbi,
 			unsigned	keycode,
 			XkbAction *	pAction)
 {
+    DeviceIntPtr dev = xkbi->device;
+    if (dev == inputInfo.keyboard)
+        return 0;
+
     if (filter->keycode==0) {		/* initial press */
-        DeviceIntPtr	dev = xkbi->device;
 	filter->keycode = keycode;
 	filter->active = 1;
 	filter->filterOthers = 0;
@@ -1029,6 +1041,9 @@ _XkbFilterDeviceBtn(	XkbSrvInfoPtr	xkbi,
 DeviceIntPtr	dev;
 int		button;
 
+    if (dev == inputInfo.keyboard)
+        return 0;
+
     if (filter->keycode==0) {		/* initial press */
 	dev= _XkbLookupButtonDevice(pAction->devbtn.device,NULL);
 	if ((!dev)||(!dev->public.on)||(&dev->public==LookupPointerDevice()))
commit 27da1367c9ea143946b8b8d3dbd0f9d44c4a9039
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Dec 5 19:36:59 2007 +0000

    WaitForSomething: Ignore EAGAIN
    
    If select ever returns EAGAIN, don't bother complaining.
    (cherry picked from commit 85dd8efac1bc0715f03c99d261b1c5d0980623e1)

diff --git a/os/WaitFor.c b/os/WaitFor.c
index ec1592c..65f53c5 100644
--- a/os/WaitFor.c
+++ b/os/WaitFor.c
@@ -262,7 +262,7 @@ WaitForSomething(int *pClientsReady)
 		    FatalError("WaitForSomething(): select: errno=%d\n",
 			selecterr);
             }
-		else if (selecterr != EINTR)
+		else if (selecterr != EINTR && selecterr != EAGAIN)
 		{
 		    ErrorF("WaitForSomething(): select: errno=%d\n",
 			selecterr);
commit 259f86b13b453f3503afd3d523de32b43996d334
Author: Rich Coe <Richard.Coe at med.ge.com>
Date:   Wed Dec 5 19:36:37 2007 +0000

    OS: Connection: Keep trying select while it gets interrupted (bug #9240)
    
    If we got interrupted (EINTR or EAGAIN) during select, just try again, rather
    than shutting clients down on either of these errors.
    (cherry picked from commit b7f3618f3933a810778093fd47564a1e3bf3fde6)

diff --git a/os/connection.c b/os/connection.c
index 135dd2c..b944593 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -1006,7 +1006,9 @@ CheckConnections(void)
 	    curclient = curoff + (i * (sizeof(fd_mask)*8));
             FD_ZERO(&tmask);
             FD_SET(curclient, &tmask);
-            r = Select (curclient + 1, &tmask, NULL, NULL, &notime);
+            do {
+                r = Select (curclient + 1, &tmask, NULL, NULL, &notime);
+            } while (r < 0 && (errno == EINTR || errno == EAGAIN));
             if (r < 0)
                 if (ConnectionTranslation[curclient] > 0)
                     CloseDownClient(clients[ConnectionTranslation[curclient]]);
@@ -1020,9 +1022,12 @@ CheckConnections(void)
 	curclient = XFD_FD(&savedAllClients, i);
 	FD_ZERO(&tmask);
 	FD_SET(curclient, &tmask);
-	r = Select (curclient + 1, &tmask, NULL, NULL, &notime);
-	if (r < 0 && GetConnectionTranslation(curclient) > 0)
-	    CloseDownClient(clients[GetConnectionTranslation(curclient)]);
+        do {
+            r = Select (curclient + 1, &tmask, NULL, NULL, &notime);
+        } while (r < 0 && (errno == EINTR || errno == EAGAIN));
+	if (r < 0)
+            if (GetConnectionTranslation(curclient) > 0)
+                CloseDownClient(clients[GetConnectionTranslation(curclient)]);
     }	
 #endif
 }
commit 90649e6a39dc6caad8313b25ef869a089f81aba7
Author: Rich Coe <Richard.Coe at med.ge.com>
Date:   Wed Dec 5 19:31:07 2007 +0000

    OS: Connection: Don't shut down disappeared clients (bug #7876)
    
    If a client disappears in the middle of CheckConnections (presumably
    because its appgroup leader disappears), then don't attempt to shut it down
    a second time, when it's already vanished.
    (cherry picked from commit d8b2cad3771a09860e7be1726f67e684cf7caeec)

diff --git a/os/connection.c b/os/connection.c
index d975f87..135dd2c 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -1008,7 +1008,8 @@ CheckConnections(void)
             FD_SET(curclient, &tmask);
             r = Select (curclient + 1, &tmask, NULL, NULL, &notime);
             if (r < 0)
-		CloseDownClient(clients[ConnectionTranslation[curclient]]);
+                if (ConnectionTranslation[curclient] > 0)
+                    CloseDownClient(clients[ConnectionTranslation[curclient]]);
 	    mask &= ~((fd_mask)1 << curoff);
 	}
     }	
commit 3f60656eb330ea40f85d87b1b5aa3383c2281373
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Tue Dec 4 17:59:13 2007 -0800

    Darwin: Rework build system to more accurately reveal code infrastructure and facilitate future modularity.
    (cherry picked from commit e8399fd4d66a2b77b770c277e2fa424229a721b2)

diff --git a/configure.ac b/configure.ac
index 0e72d04..6841462 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2154,8 +2154,8 @@ hw/xgl/glxext/module/Makefile
 hw/xnest/Makefile
 hw/xwin/Makefile
 hw/darwin/Makefile
-hw/darwin/apple/Makefile
 hw/darwin/quartz/Makefile
+hw/darwin/quartz/apple/Makefile
 hw/darwin/quartz/xpr/Makefile
 hw/kdrive/Makefile
 hw/kdrive/ati/Makefile
diff --git a/hw/darwin/Makefile.am b/hw/darwin/Makefile.am
index f5b9e75..3f29a81 100644
--- a/hw/darwin/Makefile.am
+++ b/hw/darwin/Makefile.am
@@ -1,21 +1,13 @@
+noinst_LTLIBRARIES = libXdarwin.la
 AM_CFLAGS = $(XSERVER_CFLAGS) $(DIX_CFLAGS)
 AM_CPPFLAGS = \
 	-DINXQUARTZ \
 	-DUSE_NEW_CLUT \
-	-DXFree86Server \
-	-I$(top_srcdir)/miext/rootless
+	-DXFree86Server
 
-if X11APP
-X11APP_SUBDIRS = apple
-endif
+SUBDIRS = . quartz
 
-SUBDIRS = quartz $(X11APP_SUBDIRS)
-DIST_SUBDIRS = quartz apple
-
-bin_PROGRAMS = Xquartz
-man1_MANS = Xquartz.man
-
-Xquartz_SOURCES = \
+libXdarwin_la_SOURCES = \
 	darwin.c \
 	darwinEvents.c \
 	darwinKeyboard.c \
@@ -23,49 +15,7 @@ Xquartz_SOURCES = \
 	$(top_srcdir)/fb/fbcmap_mi.c \
 	$(top_srcdir)/mi/miinitext.c
 
-#		We should probably add these once they're working, or are these obsolete and to be removed?
-#		./quartz/cr/libcr.a
-#		./quartz/fullscreen/libfullscreen.a
-
-Xquartz_LDADD = \
-	./quartz/libXquartz.a \
-	./quartz/xpr/libxpr.a \
-	$(top_builddir)/dix/dixfonts.lo \
-	$(top_builddir)/dix/libdix.la \
-	$(top_builddir)/os/libos.la \
-	$(top_builddir)/dix/libxpstubs.la \
-	$(top_builddir)/miext/shadow/libshadow.la \
-	$(top_builddir)/fb/libfb.la \
-	$(top_builddir)/mi/libmi.la \
-	$(top_builddir)/composite/libcomposite.la \
-	$(top_builddir)/damageext/libdamageext.la \
-	$(top_builddir)/miext/damage/libdamage.la \
-	$(top_builddir)/xfixes/libxfixes.la \
-	$(top_builddir)/miext/cw/libcw.la \
-	$(top_builddir)/Xext/libXext.la \
-	$(top_builddir)/xkb/libxkb.la \
-	$(top_builddir)/xkb/libxkbstubs.la \
-	$(top_builddir)/Xi/libXi.la \
-	$(top_builddir)/dbe/libdbe.la \
-	$(top_builddir)/record/librecord.la \
-	$(top_builddir)/XTrap/libxtrap.la \
-	$(top_builddir)/miext/rootless/librootless.la \
-	$(top_builddir)/miext/rootless/safeAlpha/libsafeAlpha.la \
-	$(top_builddir)/miext/rootless/accel/librlAccel.la \
-	$(DARWIN_LIBS) $(XSERVER_LIBS) $(XSERVER_SYS_LIBS) -lXplugin
-
-Xquartz_LDFLAGS =  \
-	-XCClinker -Objc \
-	-Wl,-u,_miDCInitialize \
-	-Wl,-framework,Carbon \
-	-L/System/Library/Frameworks/OpenGL.framework/Libraries -lGL \
-	-Wl,-framework,OpenGL \
-	-Wl,-framework,Cocoa \
-	-Wl,-framework,CoreAudio \
-	-Wl,-framework,IOKit
-
 EXTRA_DIST = \
-	Xquartz.man \
 	darwinClut8.h \
 	darwin.h \
 	darwinKeyboard.h
diff --git a/hw/darwin/Xquartz.man b/hw/darwin/Xquartz.man
deleted file mode 100644
index 37a7f1a..0000000
--- a/hw/darwin/Xquartz.man
+++ /dev/null
@@ -1,156 +0,0 @@
-.TH XQUARTZ 1 __vendorversion__
-.SH NAME
-Xquartz \- X window system server for Quartz operating system
-.SH SYNOPSIS
-.B Xquartz
-[ options ] ...
-.SH DESCRIPTION
-.I Xquartz
-is the X window server for Mac OS X provided by Apple.
-.I Xquartz
-runs in parallel with Aqua in rootless mode. In rootless mode, the X
-window system and Mac OS X share your display.  The root window of the
-X11 display is the size of the screen and contains all the other
-windows. The X11 root window is not displayed in rootless mode as Mac
-OS X handles the desktop background.
-.SH OPTIONS
-.PP
-In addition to the normal server options described in the \fIXserver(1)\fP
-manual page, \fIXquartz\fP accepts the following command line switches:
-.TP 8
-.B \-fakebuttons
-Emulates a 3 button mouse using modifier keys. By default, the Command modifier
-is used to emulate button 2 and Option is used for button 3. Thus, clicking the
-first mouse button while holding down Command will act like clicking
-button 2. Holding down Option will simulate button 3.
-.TP 8
-.B \-nofakebuttons
-Do not emulate a 3 button mouse. This is the default.
-.TP 8
-.B "\-fakemouse2 \fImodifiers\fP"
-Change the modifier keys used to emulate the second mouse button. By default,
-Command is used to emulate the second button. Any combination of the following
-modifier names may be used: Shift, Option, Control, Command, Fn. For example,
-.B \-fakemouse2 """Option,Shift""
-will set holding Option, Shift and clicking on button one as equivalent to
-clicking the second mouse button.
-.TP 8
-.B "\-fakemouse3 \fImodifiers\fP"
-Change the modifier keys used to emulate the third mouse button. By default,
-Option is used to emulate the third button. Any combination of the following
-modifier names may be used: Shift, Option, Control, Command, Fn. For example,
-.B \-fakemouse3 """Control,Shift""
-will set holding Control, Shift and clicking on button one as equivalent to
-clicking the third mouse button.
-.TP 8
-.B "\-swapAltMeta"
-Swaps the meaning of the Alt and Meta modifier keys.
-.TP 8
-.B "\-keymap \fIfile\fP"
-On startup \fIXquartz\fP translates a Darwin keymapping into an X keymap.
-The default is to read this keymapping from USA.keymapping. With this option
-the keymapping will be read from \fIfile\fP instead. If the file's path is
-not specified, it will be searched for in Library/Keyboards/ underneath the
-following directories (in order): ~, /, /Network, /System.
-.TP 8
-.B \-nokeymap
-On startup \fIXquartz\fP translates a Darwin keymapping into an X keymap.
-With this option \fIXquartz\fP queries the kernel for the current keymapping
-instead of reading it from a file. This will often fail on newer kernels.
-.TP 8
-.B "\-depth \fIdepth\fP"
-Specifies the color bit depth to use. Currently only 15, and 24 color
-bits per pixel are supported. If not specified, defaults to the depth
-of the main display.
-.SH CUSTOMIZATION
-\fIXquartz\fP can also be customized using the defaults(1) command. The available options are:
-.TP 8
-.B defaults write com.apple.x11 enable_fake_buttons -boolean true
-Equivalent to the \fB-fakebuttons\fP command line option.
-.TP 8
-.B defaults write com.apple.x11 fake_button2 \fImodifiers\fP
-Equivalent to the \fB-fakemouse2\fP option.
-.TP 8
-.B defaults write com.apple.x11 fake_button3 \fImodifiers\fP
-Equivalent to the \fB-fakemouse3\fP option.
-.TP 8
-.B defaults write com.apple.x11 swap_alt_meta -boolean true
-Equivalent to the \fB-swapAltMeta\fP option.
-.TP 8
-.B defaults write com.apple.x11 keymap_file \fIfilename\fP
-Equivalent to the \fB-keymap\fP option.
-.TP 8
-.B defaults write com.apple.x11 no_quit_alert -boolean true
-Disables the alert dialog displayed when attempting to quit X11.
-.TP 8
-.B defaults write com.apple.x11 no_auth -boolean true
-Stops the X server requiring that clients authenticate themselves when
-connecting. See Xsecurity(__miscmansuffix__).
-.TP 8
-.B defaults write com.apple.x11 nolisten_tcp -boolean true
-Prevents the X server accepting remote connections.
-.TP 8
-.B defaults write com.apple.x11 xinit_kills_server -boolean false
-Stops the X server exiting when the xinitrc script terminates.
-.TP 8
-.B defaults write com.apple.x11 fullscreen_hotkeys -boolean false
-Allows system hotkeys to be handled while in X11 fullscreen mode.
-.TP 8
-.B defaults write com.apple.x11 enable_system_beep -boolean false
-Don't use the standard system beep effect for X11 alerts.
-.TP 8
-.B defaults write com.apple.x11 enable_key_equivalents -boolean false
-Disable menu keyboard equivalents while X11 windows are focused.
-.TP 8
-.B defaults write com.apple.x11 depth \fIdepth\fP
-Equivalent to the \fB-depth\fP option.
-.SH "SEE ALSO"
-.PP
-X(__miscmansuffix__), XFree86(1), Xserver(1), xdm(1), xinit(1)
-.PP
-.SH AUTHORS
-XFree86 was originally ported to Mac OS X Server by John Carmack. Dave
-Zarzycki used this as the basis of his port of XFree86 4.0 to Darwin 1.0.
-Torrey T. Lyons improved and integrated this code into the XFree86
-Project's mainline for the 4.0.2 release.
-.PP
-The following members of the XonX Team contributed to the following
-releases (in alphabetical order):
-.TP 4
-XFree86 4.1.0:
-.br
-Rob Braun - Darwin x86 support
-.br
-Torrey T. Lyons - Project Lead
-.br
-Andreas Monitzer - Cocoa version of XDarwin front end
-.br
-Gregory Robert Parker - Original Quartz implementation
-.br
-Christoph Pfisterer - Dynamic shared X libraries
-.br
-Toshimitsu Tanaka - Japanese localization
-.TP 4
-XFree86 4.2.0:
-.br
-Rob Braun - Darwin x86 support
-.br
-Pablo Di Noto - Spanish localization
-.br
-Paul Edens - Dutch localization
-.br
-Kyunghwan Kim - Korean localization
-.br
-Mario Klebsch - Non-US keyboard support
-.br
-Torrey T. Lyons - Project Lead
-.br
-Andreas Monitzer - German localization
-.br
-Patrik Montgomery - Swedish localization
-.br
-Greg Parker - Rootless support
-.br
-Toshimitsu Tanaka - Japanese localization
-.br
-Olivier Verdier - French localization
diff --git a/hw/darwin/apple/English.lproj/InfoPlist.strings b/hw/darwin/apple/English.lproj/InfoPlist.strings
deleted file mode 100644
index 88e1f04..0000000
Binary files a/hw/darwin/apple/English.lproj/InfoPlist.strings and /dev/null differ
diff --git a/hw/darwin/apple/English.lproj/Localizable.strings b/hw/darwin/apple/English.lproj/Localizable.strings
deleted file mode 100644
index c83b085..0000000
Binary files a/hw/darwin/apple/English.lproj/Localizable.strings and /dev/null differ
diff --git a/hw/darwin/apple/English.lproj/main.nib/classes.nib b/hw/darwin/apple/English.lproj/main.nib/classes.nib
deleted file mode 100644
index a82159b..0000000
--- a/hw/darwin/apple/English.lproj/main.nib/classes.nib
+++ /dev/null
@@ -1,318 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>IBClasses</key>
-	<array>
-		<dict>
-			<key>CLASS</key>
-			<string>IBLibraryObjectTemplate</string>
-			<key>LANGUAGE</key>
-			<string>ObjC</string>
-			<key>OUTLETS</key>
-			<dict>
-				<key>draggedView</key>
-				<string>NSView</string>
-				<key>representedObject</key>
-				<string>NSObject</string>
-			</dict>
-			<key>SUPERCLASS</key>
-			<string>NSView</string>
-		</dict>
-		<dict>
-			<key>CLASS</key>
-			<string>IBInspector</string>
-			<key>LANGUAGE</key>
-			<string>ObjC</string>
-			<key>OUTLETS</key>
-			<dict>
-				<key>inspectorView</key>
-				<string>NSView</string>
-			</dict>
-			<key>SUPERCLASS</key>
-			<string>NSObject</string>
-		</dict>
-		<dict>
-			<key>CLASS</key>
-			<string>NSDateFormatter</string>
-			<key>LANGUAGE</key>
-			<string>ObjC</string>
-			<key>SUPERCLASS</key>
-			<string>NSFormatter</string>
-		</dict>
-		<dict>
-			<key>ACTIONS</key>
-			<dict>
-				<key>apps_table_cancel</key>
-				<string>id</string>
-				<key>apps_table_delete</key>
-				<string>id</string>
-				<key>apps_table_done</key>
-				<string>id</string>
-				<key>apps_table_duplicate</key>
-				<string>id</string>
-				<key>apps_table_new</key>
-				<string>id</string>
-				<key>apps_table_show</key>
-				<string>id</string>
-				<key>bring_to_front</key>
-				<string>id</string>
-				<key>close_window</key>
-				<string>id</string>
-				<key>enable_fullscreen_changed</key>
-				<string>id</string>
-				<key>minimize_window</key>
-				<string>id</string>
-				<key>next_window</key>
-				<string>id</string>
-				<key>prefs_changed</key>
-				<string>id</string>
-				<key>prefs_show</key>
-				<string>id</string>
-				<key>previous_window</key>
-				<string>id</string>
-				<key>toggle_fullscreen</key>
-				<string>id</string>
-				<key>x11_help</key>
-				<string>id</string>
-				<key>zoom_window</key>
-				<string>id</string>
-			</dict>
-			<key>CLASS</key>
-			<string>X11Controller</string>
-			<key>LANGUAGE</key>
-			<string>ObjC</string>
-			<key>OUTLETS</key>
-			<dict>
-				<key>apps_separator</key>
-				<string>id</string>
-				<key>apps_table</key>
-				<string>id</string>
-				<key>depth</key>
-				<string>id</string>
-				<key>dock_apps_menu</key>
-				<string>id</string>
-				<key>dock_menu</key>
-				<string>id</string>
-				<key>dock_window_separator</key>
-				<string>id</string>
-				<key>enable_auth</key>
-				<string>id</string>
-				<key>enable_fullscreen</key>
-				<string>id</string>
-				<key>enable_keyequivs</key>
-				<string>id</string>
-				<key>enable_tcp</key>
-				<string>id</string>
-				<key>fake_buttons</key>
-				<string>id</string>
-				<key>prefs_panel</key>
-				<string>id</string>
-				<key>sync_keymap</key>
-				<string>id</string>
-				<key>toggle_fullscreen_item</key>
-				<string>id</string>
-				<key>use_sysbeep</key>
-				<string>id</string>
-				<key>window_separator</key>
-				<string>id</string>
-				<key>x11_about_item</key>
-				<string>id</string>
-			</dict>
-			<key>SUPERCLASS</key>
-			<string>NSObject</string>
-		</dict>
-		<dict>
-			<key>CLASS</key>
-			<string>NSNumberFormatter</string>
-			<key>LANGUAGE</key>
-			<string>ObjC</string>
-			<key>SUPERCLASS</key>
-			<string>NSFormatter</string>
-		</dict>
-		<dict>
-			<key>CLASS</key>
-			<string>NSFormatter</string>
-			<key>LANGUAGE</key>
-			<string>ObjC</string>
-			<key>SUPERCLASS</key>
-			<string>NSObject</string>
-		</dict>
-		<dict>
-			<key>ACTIONS</key>
-			<dict>
-				<key>alignCenter:</key>
-				<string>id</string>
-				<key>alignJustified:</key>
-				<string>id</string>
-				<key>alignLeft:</key>
-				<string>id</string>
-				<key>alignRight:</key>
-				<string>id</string>
-				<key>arrangeInFront:</key>
-				<string>id</string>
-				<key>centerSelectionInVisibleArea:</key>
-				<string>id</string>
-				<key>changeFont:</key>
-				<string>id</string>
-				<key>checkSpelling:</key>
-				<string>id</string>
-				<key>clear:</key>
-				<string>id</string>
-				<key>clearRecentDocuments:</key>
-				<string>id</string>
-				<key>complete:</key>
-				<string>id</string>
-				<key>copy:</key>
-				<string>id</string>
-				<key>copyFont:</key>
-				<string>id</string>
-				<key>copyRuler:</key>
-				<string>id</string>
-				<key>cut:</key>
-				<string>id</string>
-				<key>delete:</key>
-				<string>id</string>
-				<key>deminiaturize:</key>
-				<string>id</string>
-				<key>fax:</key>
-				<string>id</string>
-				<key>hide:</key>
-				<string>id</string>
-				<key>hideOtherApplications:</key>
-				<string>id</string>
-				<key>loosenKerning:</key>
-				<string>id</string>
-				<key>lowerBaseline:</key>
-				<string>id</string>
-				<key>makeKeyAndOrderFront:</key>
-				<string>id</string>
-				<key>miniaturize:</key>
-				<string>id</string>
-				<key>newDocument:</key>
-				<string>id</string>
-				<key>openDocument:</key>
-				<string>id</string>
-				<key>orderBack:</key>
-				<string>id</string>
-				<key>orderFront:</key>
-				<string>id</string>
-				<key>orderFrontColorPanel:</key>
-				<string>id</string>
-				<key>orderFrontHelpPanel:</key>
-				<string>id</string>
-				<key>orderOut:</key>
-				<string>id</string>
-				<key>outline:</key>
-				<string>id</string>
-				<key>paste:</key>
-				<string>id</string>
-				<key>pasteAsPlainText:</key>
-				<string>id</string>
-				<key>pasteAsRichText:</key>
-				<string>id</string>
-				<key>pasteFont:</key>
-				<string>id</string>
-				<key>pasteRuler:</key>
-				<string>id</string>
-				<key>pause:</key>
-				<string>id</string>
-				<key>performClose:</key>
-				<string>id</string>
-				<key>performFindPanelAction:</key>
-				<string>id</string>
-				<key>performMiniaturize:</key>
-				<string>id</string>
-				<key>performZoom:</key>
-				<string>id</string>
-				<key>play:</key>
-				<string>id</string>
-				<key>print:</key>
-				<string>id</string>
-				<key>printDocument:</key>
-				<string>id</string>
-				<key>raiseBaseline:</key>
-				<string>id</string>
-				<key>record:</key>
-				<string>id</string>
-				<key>redo:</key>
-				<string>id</string>
-				<key>resume:</key>
-				<string>id</string>
-				<key>revertDocumentToSaved:</key>
-				<string>id</string>
-				<key>run:</key>
-				<string>id</string>
-				<key>runPageLayout:</key>
-				<string>id</string>
-				<key>runToolbarCustomizationPalette:</key>
-				<string>id</string>
-				<key>saveAllDocuments:</key>
-				<string>id</string>
-				<key>saveDocument:</key>
-				<string>id</string>
-				<key>saveDocumentAs:</key>
-				<string>id</string>
-				<key>saveDocumentTo:</key>
-				<string>id</string>
-				<key>selectAll:</key>
-				<string>id</string>
-				<key>selectText:</key>
-				<string>id</string>
-				<key>showGuessPanel:</key>
-				<string>id</string>
-				<key>showHelp:</key>
-				<string>id</string>
-				<key>start:</key>
-				<string>id</string>
-				<key>startSpeaking:</key>
-				<string>id</string>
-				<key>stop:</key>
-				<string>id</string>
-				<key>stopSpeaking:</key>
-				<string>id</string>
-				<key>subscript:</key>
-				<string>id</string>
-				<key>superscript:</key>
-				<string>id</string>
-				<key>terminate:</key>
-				<string>id</string>
-				<key>tightenKerning:</key>
-				<string>id</string>
-				<key>toggleContinuousSpellChecking:</key>
-				<string>id</string>
-				<key>toggleRuler:</key>
-				<string>id</string>
-				<key>toggleToolbarShown:</key>
-				<string>id</string>
-				<key>turnOffKerning:</key>
-				<string>id</string>
-				<key>turnOffLigatures:</key>
-				<string>id</string>
-				<key>underline:</key>
-				<string>id</string>
-				<key>undo:</key>
-				<string>id</string>
-				<key>unhideAllApplications:</key>
-				<string>id</string>
-				<key>unscript:</key>
-				<string>id</string>
-				<key>useAllLigatures:</key>
-				<string>id</string>
-				<key>useStandardKerning:</key>
-				<string>id</string>
-				<key>useStandardLigatures:</key>
-				<string>id</string>
-			</dict>
-			<key>CLASS</key>
-			<string>FirstResponder</string>
-			<key>LANGUAGE</key>
-			<string>ObjC</string>
-			<key>SUPERCLASS</key>
-			<string>NSObject</string>
-		</dict>
-	</array>
-	<key>IBVersion</key>
-	<integer>1</integer>
-</dict>
-</plist>
diff --git a/hw/darwin/apple/English.lproj/main.nib/info.nib b/hw/darwin/apple/English.lproj/main.nib/info.nib
deleted file mode 100644
index 88bc626..0000000
--- a/hw/darwin/apple/English.lproj/main.nib/info.nib
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>IBFramework Version</key>
-	<string>588</string>
-	<key>IBOpenObjects</key>
-	<array>
-		<integer>244</integer>
-		<integer>29</integer>
-		<integer>423</integer>
-	</array>
-	<key>IBSystem Version</key>
-	<string>9A356</string>
-	<key>targetFramework</key>
-	<string>IBCocoaFramework</string>
-</dict>
-</plist>
diff --git a/hw/darwin/apple/English.lproj/main.nib/keyedobjects.nib b/hw/darwin/apple/English.lproj/main.nib/keyedobjects.nib
deleted file mode 100644
index 8b31450..0000000
Binary files a/hw/darwin/apple/English.lproj/main.nib/keyedobjects.nib and /dev/null differ
diff --git a/hw/darwin/apple/Info.plist b/hw/darwin/apple/Info.plist
deleted file mode 100644
index 66f1f6b..0000000
--- a/hw/darwin/apple/Info.plist
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>CFBundleDevelopmentRegion</key>
-	<string>English</string>
-	<key>CFBundleExecutable</key>
-	<string>X11</string>
-	<key>CFBundleGetInfoString</key>
-	<string>X11</string>
-	<key>CFBundleIconFile</key>
-	<string>X11.icns</string>
-	<key>CFBundleIdentifier</key>
-	<string>org.x.X11</string>
-	<key>CFBundleInfoDictionaryVersion</key>
-	<string>6.0</string>
-	<key>CFBundleName</key>
-	<string>X11</string>
-	<key>CFBundlePackageType</key>
-	<string>APPL</string>
-	<key>CFBundleShortVersionString</key>
-	<string>2.0</string>
-	<key>CFBundleSignature</key>
-	<string>x11a</string>
-	<key>CSResourcesFileMapped</key>
-	<true/>
-	<key>NSHumanReadableCopyright</key>
-	<string>Copyright © 2003-2007, Apple Inc.
-Copyright © 2003, XFree86 Project, Inc.</string>
-	<key>NSMainNibFile</key>
-	<string>main</string>
-	<key>NSPrincipalClass</key>
-	<string>X11Application</string>
-</dict>
-</plist>
diff --git a/hw/darwin/apple/Makefile.am b/hw/darwin/apple/Makefile.am
deleted file mode 100644
index a6e2dfb..0000000
--- a/hw/darwin/apple/Makefile.am
+++ /dev/null
@@ -1,28 +0,0 @@
-bin_SCRIPTS = x11app
-
-.PHONY: x11app
-
-x11app:
-	xcodebuild CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" ARCHS="$(X11APP_ARCHS)"
-
-install-data-hook:
-	xcodebuild install DSTROOT="/$(DESTDIR)" INSTALL_PATH="$(APPLE_APPLICATIONS_DIR)" DEPLOYMENT_LOCATION=YES SKIP_INSTALL=NO ARCHS="$(X11APP_ARCHS)"
-	$(MKDIR_P) "$(DESTDIR)/System/Library/LaunchAgents/"
-	$(INSTALL) org.x.X11.plist "$(DESTDIR)/System/Library/LaunchAgents/"
-
-clean-local:
-	rm -rf build
-
-EXTRA_DIST = \
-	org.x.X11.plist \
-	Info.plist \
-	X11.icns \
-	bundle-main.c \
-	launcher-main.c \
-	server-main.c \
-	English.lproj/InfoPlist.strings \
-	English.lproj/Localizable.strings \
-	English.lproj/main.nib/classes.nib \
-	English.lproj/main.nib/info.nib \
-	English.lproj/main.nib/keyedobjects.nib \
-	X11.xcodeproj/project.pbxproj
diff --git a/hw/darwin/apple/X11.icns b/hw/darwin/apple/X11.icns
deleted file mode 100644
index d770e61..0000000
Binary files a/hw/darwin/apple/X11.icns and /dev/null differ
diff --git a/hw/darwin/apple/X11.xcodeproj/project.pbxproj b/hw/darwin/apple/X11.xcodeproj/project.pbxproj
deleted file mode 100644
index 225f371..0000000
--- a/hw/darwin/apple/X11.xcodeproj/project.pbxproj
+++ /dev/null
@@ -1,344 +0,0 @@
-// !$*UTF8*$!
-{
-	archiveVersion = 1;
-	classes = {
-	};
-	objectVersion = 42;
-	objects = {
-
-/* Begin PBXBuildFile section */
-		3F5E1BE00D04BF110020CA24 /* launcher-main.c in Sources */ = {isa = PBXBuildFile; fileRef = 3F5E1BDE0D04BF110020CA24 /* launcher-main.c */; };
-		3F5E1BE10D04BF110020CA24 /* server-main.c in Sources */ = {isa = PBXBuildFile; fileRef = 3F5E1BDF0D04BF110020CA24 /* server-main.c */; };
-		527F24190B5D938C007840A7 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0867D6AAFE840B52C02AAC07 /* InfoPlist.strings */; };
-		527F241A0B5D938C007840A7 /* main.nib in Resources */ = {isa = PBXBuildFile; fileRef = 02345980000FD03B11CA0E72 /* main.nib */; };
-		527F241B0B5D938C007840A7 /* X11.icns in Resources */ = {isa = PBXBuildFile; fileRef = 50459C5F038587C60ECA21EC /* X11.icns */; };
-		527F241D0B5D938C007840A7 /* bundle-main.c in Sources */ = {isa = PBXBuildFile; fileRef = 50EE2AB703849F0B0ECA21EC /* bundle-main.c */; };
-		527F241F0B5D938C007840A7 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50F4F0A7039D6ACA0E82C0CB /* CoreFoundation.framework */; };
-		527F24200B5D938C007840A7 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 570C5748047186C400ACF82F /* SystemConfiguration.framework */; };
-		527F24370B5D9D89007840A7 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 527F24260B5D938C007840A7 /* Info.plist */; };
-		52D9C0ED0BCDDF6B00CD2AFC /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 52D9C0EB0BCDDF6B00CD2AFC /* Localizable.strings */; };
-/* End PBXBuildFile section */
-
-/* Begin PBXFileReference section */
-		0867D6ABFE840B52C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
-		1870340FFE93FCAF11CA0CD7 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/main.nib; sourceTree = "<group>"; };
-		3F5E1BDE0D04BF110020CA24 /* launcher-main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "launcher-main.c"; sourceTree = "<group>"; };
-		3F5E1BDF0D04BF110020CA24 /* server-main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "server-main.c"; sourceTree = "<group>"; };
-		50459C5F038587C60ECA21EC /* X11.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = X11.icns; sourceTree = "<group>"; };
-		50EE2AB703849F0B0ECA21EC /* bundle-main.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = "bundle-main.c"; sourceTree = "<group>"; };
-		50F4F0A7039D6ACA0E82C0CB /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = "<absolute>"; };
-		527F24260B5D938C007840A7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = Info.plist; sourceTree = "<group>"; };
-		527F24270B5D938C007840A7 /* X11.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = X11.app; sourceTree = BUILT_PRODUCTS_DIR; };
-		52D9C0EC0BCDDF6B00CD2AFC /* English */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/Localizable.strings; sourceTree = "<group>"; };
-		570C5748047186C400ACF82F /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = /System/Library/Frameworks/SystemConfiguration.framework; sourceTree = "<absolute>"; };
-/* End PBXFileReference section */
-
-/* Begin PBXFrameworksBuildPhase section */
-		527F241E0B5D938C007840A7 /* Frameworks */ = {
-			isa = PBXFrameworksBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-				527F241F0B5D938C007840A7 /* CoreFoundation.framework in Frameworks */,
-				527F24200B5D938C007840A7 /* SystemConfiguration.framework in Frameworks */,
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-/* End PBXFrameworksBuildPhase section */
-
-/* Begin PBXGroup section */
-		195DF8CFFE9D517E11CA2CBB /* Products */ = {
-			isa = PBXGroup;
-			children = (
-				527F24270B5D938C007840A7 /* X11.app */,
-			);
-			name = Products;
-			sourceTree = "<group>";
-		};
-		20286C29FDCF999611CA2CEA /* X11 */ = {
-			isa = PBXGroup;
-			children = (
-				20286C2AFDCF999611CA2CEA /* Sources */,
-				20286C2CFDCF999611CA2CEA /* Resources */,
-				20286C32FDCF999611CA2CEA /* External Frameworks and Libraries */,
-				195DF8CFFE9D517E11CA2CBB /* Products */,
-				527F24260B5D938C007840A7 /* Info.plist */,
-			);
-			name = X11;
-			sourceTree = "<group>";
-		};
-		20286C2AFDCF999611CA2CEA /* Sources */ = {
-			isa = PBXGroup;
-			children = (
-				3F5E1BDE0D04BF110020CA24 /* launcher-main.c */,
-				3F5E1BDF0D04BF110020CA24 /* server-main.c */,
-				50EE2AB703849F0B0ECA21EC /* bundle-main.c */,
-			);
-			name = Sources;
-			sourceTree = "<group>";
-		};
-		20286C2CFDCF999611CA2CEA /* Resources */ = {
-			isa = PBXGroup;
-			children = (
-				52D9C0EB0BCDDF6B00CD2AFC /* Localizable.strings */,
-				50459C5F038587C60ECA21EC /* X11.icns */,
-				0867D6AAFE840B52C02AAC07 /* InfoPlist.strings */,
-				02345980000FD03B11CA0E72 /* main.nib */,
-			);
-			name = Resources;
-			sourceTree = "<group>";
-		};
-		20286C32FDCF999611CA2CEA /* External Frameworks and Libraries */ = {
-			isa = PBXGroup;
-			children = (
-				50F4F0A7039D6ACA0E82C0CB /* CoreFoundation.framework */,
-				570C5748047186C400ACF82F /* SystemConfiguration.framework */,
-			);
-			name = "External Frameworks and Libraries";
-			sourceTree = "<group>";
-		};
-/* End PBXGroup section */
-
-/* Begin PBXHeadersBuildPhase section */
-		527F24170B5D938C007840A7 /* Headers */ = {
-			isa = PBXHeadersBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-/* End PBXHeadersBuildPhase section */
-
-/* Begin PBXNativeTarget section */
-		527F24160B5D938C007840A7 /* X11 */ = {
-			isa = PBXNativeTarget;
-			buildConfigurationList = 527F24220B5D938C007840A7 /* Build configuration list for PBXNativeTarget "X11" */;
-			buildPhases = (
-				527F24170B5D938C007840A7 /* Headers */,
-				527F24180B5D938C007840A7 /* Resources */,
-				527F241C0B5D938C007840A7 /* Sources */,
-				527F241E0B5D938C007840A7 /* Frameworks */,
-				527F24210B5D938C007840A7 /* Rez */,
-			);
-			buildRules = (
-			);
-			dependencies = (
-			);
-			name = X11;
-			productName = X11;
-			productReference = 527F24270B5D938C007840A7 /* X11.app */;
-			productType = "com.apple.product-type.application";
-		};
-/* End PBXNativeTarget section */
-
-/* Begin PBXProject section */
-		20286C28FDCF999611CA2CEA /* Project object */ = {
-			isa = PBXProject;
-			buildConfigurationList = 527F24080B5D8FFC007840A7 /* Build configuration list for PBXProject "X11" */;
-			compatibilityVersion = "Xcode 2.4";
-			hasScannedForEncodings = 1;
-			mainGroup = 20286C29FDCF999611CA2CEA /* X11 */;
-			projectDirPath = "";
-			projectRoot = "";
-			targets = (
-				527F24160B5D938C007840A7 /* X11 */,
-			);
-		};
-/* End PBXProject section */
-
-/* Begin PBXResourcesBuildPhase section */
-		527F24180B5D938C007840A7 /* Resources */ = {
-			isa = PBXResourcesBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-				527F24370B5D9D89007840A7 /* Info.plist in Resources */,
-				527F24190B5D938C007840A7 /* InfoPlist.strings in Resources */,
-				527F241A0B5D938C007840A7 /* main.nib in Resources */,
-				527F241B0B5D938C007840A7 /* X11.icns in Resources */,
-				52D9C0ED0BCDDF6B00CD2AFC /* Localizable.strings in Resources */,
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-/* End PBXResourcesBuildPhase section */
-
-/* Begin PBXRezBuildPhase section */
-		527F24210B5D938C007840A7 /* Rez */ = {
-			isa = PBXRezBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-/* End PBXRezBuildPhase section */
-
-/* Begin PBXSourcesBuildPhase section */
-		527F241C0B5D938C007840A7 /* Sources */ = {
-			isa = PBXSourcesBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-				527F241D0B5D938C007840A7 /* bundle-main.c in Sources */,
-				3F5E1BE00D04BF110020CA24 /* launcher-main.c in Sources */,
-				3F5E1BE10D04BF110020CA24 /* server-main.c in Sources */,
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-/* End PBXSourcesBuildPhase section */
-
-/* Begin PBXVariantGroup section */
-		02345980000FD03B11CA0E72 /* main.nib */ = {
-			isa = PBXVariantGroup;
-			children = (
-				1870340FFE93FCAF11CA0CD7 /* English */,
-			);
-			name = main.nib;
-			sourceTree = "<group>";
-		};
-		0867D6AAFE840B52C02AAC07 /* InfoPlist.strings */ = {
-			isa = PBXVariantGroup;
-			children = (
-				0867D6ABFE840B52C02AAC07 /* English */,
-			);
-			name = InfoPlist.strings;
-			sourceTree = "<group>";
-		};
-		52D9C0EB0BCDDF6B00CD2AFC /* Localizable.strings */ = {
-			isa = PBXVariantGroup;
-			children = (
-				52D9C0EC0BCDDF6B00CD2AFC /* English */,
-			);
-			name = Localizable.strings;
-			sourceTree = "<group>";
-		};
-/* End PBXVariantGroup section */
-
-/* Begin XCBuildConfiguration section */
-		527F24090B5D8FFC007840A7 /* Development */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				INSTALL_MODE_FLAG = "a+rX";
-			};
-			name = Development;
-		};
-		527F240A0B5D8FFC007840A7 /* Deployment */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				INSTALL_MODE_FLAG = "a+rX";
-			};
-			name = Deployment;
-		};
-		527F240B0B5D8FFC007840A7 /* Default */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				INSTALL_MODE_FLAG = "a+rX";
-			};
-			name = Default;
-		};
-		527F24230B5D938C007840A7 /* Development */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				COPY_PHASE_STRIP = NO;
-				FRAMEWORK_SEARCH_PATHS = "";
-				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
-				HEADER_SEARCH_PATHS = /usr/X11/include;
-				INFOPLIST_FILE = Info.plist;
-				INSTALL_PATH = /usr/X11;
-				LIBRARY_SEARCH_PATHS = /usr/X11/lib;
-				OTHER_CFLAGS = "";
-				OTHER_LDFLAGS = (
-					"-lXau",
-					"-lxcb",
-					"-lX11",
-				);
-				OTHER_REZFLAGS = "";
-				PRODUCT_NAME = X11;
-				SECTORDER_FLAGS = "";
-				WARNING_CFLAGS = (
-					"-Wmost",
-					"-Wno-four-char-constants",
-					"-Wno-unknown-pragmas",
-				);
-				WRAPPER_EXTENSION = app;
-			};
-			name = Development;
-		};
-		527F24240B5D938C007840A7 /* Deployment */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				COPY_PHASE_STRIP = YES;
-				FRAMEWORK_SEARCH_PATHS = "";
-				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
-				HEADER_SEARCH_PATHS = /usr/X11/include;
-				INFOPLIST_FILE = Info.plist;
-				INSTALL_PATH = /usr/X11;
-				LIBRARY_SEARCH_PATHS = /usr/X11/lib;
-				OTHER_CFLAGS = "";
-				OTHER_LDFLAGS = (
-					"-lXau",
-					"-lxcb",
-					"-lX11",
-				);
-				OTHER_REZFLAGS = "";
-				PRODUCT_NAME = X11;
-				SECTORDER_FLAGS = "";
-				WARNING_CFLAGS = (
-					"-Wmost",
-					"-Wno-four-char-constants",
-					"-Wno-unknown-pragmas",
-				);
-				WRAPPER_EXTENSION = app;
-			};
-			name = Deployment;
-		};
-		527F24250B5D938C007840A7 /* Default */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				FRAMEWORK_SEARCH_PATHS = "";
-				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
-				HEADER_SEARCH_PATHS = /usr/X11/include;
-				INFOPLIST_FILE = Info.plist;
-				INSTALL_PATH = /usr/X11;
-				LIBRARY_SEARCH_PATHS = /usr/X11/lib;
-				OTHER_CFLAGS = "";
-				OTHER_LDFLAGS = (
-					"-lXau",
-					"-lxcb",
-					"-lX11",
-				);
-				OTHER_REZFLAGS = "";
-				PRODUCT_NAME = X11;
-				SECTORDER_FLAGS = "";
-				WARNING_CFLAGS = (
-					"-Wmost",
-					"-Wno-four-char-constants",
-					"-Wno-unknown-pragmas",
-				);
-				WRAPPER_EXTENSION = app;
-			};
-			name = Default;
-		};
-/* End XCBuildConfiguration section */
-
-/* Begin XCConfigurationList section */
-		527F24080B5D8FFC007840A7 /* Build configuration list for PBXProject "X11" */ = {
-			isa = XCConfigurationList;
-			buildConfigurations = (
-				527F24090B5D8FFC007840A7 /* Development */,
-				527F240A0B5D8FFC007840A7 /* Deployment */,
-				527F240B0B5D8FFC007840A7 /* Default */,
-			);
-			defaultConfigurationIsVisible = 0;
-			defaultConfigurationName = Default;
-		};
-		527F24220B5D938C007840A7 /* Build configuration list for PBXNativeTarget "X11" */ = {
-			isa = XCConfigurationList;
-			buildConfigurations = (
-				527F24230B5D938C007840A7 /* Development */,
-				527F24240B5D938C007840A7 /* Deployment */,
-				527F24250B5D938C007840A7 /* Default */,
-			);
-			defaultConfigurationIsVisible = 0;
-			defaultConfigurationName = Default;
-		};
-/* End XCConfigurationList section */
-	};
-	rootObject = 20286C28FDCF999611CA2CEA /* Project object */;
-}
diff --git a/hw/darwin/apple/bundle-main.c b/hw/darwin/apple/bundle-main.c
deleted file mode 100644
index c436d51..0000000
--- a/hw/darwin/apple/bundle-main.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/* main.c -- X application launcher
- 
- Copyright (c) 2007 Jeremy Huddleston
- Copyright (c) 2007 Apple Inc
- 
- 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 <X11/Xlib.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <string.h>
-
-int launcher_main(int argc, char **argv);
-int server_main(int argc, char **argv);
-
-int main(int argc, char **argv) {
-    Display *display;
-  
-    fprintf(stderr, "X11.app: main(): argc=%d\n", argc);
-    int i;
-    for(i=0; i < argc; i++) {
-        fprintf(stderr, "\targv[%d] = %s\n", i, argv[i]);
-    }
-    
-    /* First check if launchd started us */
-    if(argc == 2 && !strncmp(argv[1], "--launchd", 9)) {
-        argc--;
-        argv[1] = argv[0];
-        argv++;
-        fprintf(stderr, "X11.app: main(): launchd called us, running server_main()");
-        return server_main(argc, argv);
-    }
-
-    /* If we have a process serial number and it's our only arg, act as if
-     * the user double clicked the app bundle: launch app_to_run if possible
-     */
-    if(argc == 1 || (argc == 2 && !strncmp(argv[1], "-psn_", 5))) {
-        /* Now, try to open a display, if so, run the launcher */
-        display = XOpenDisplay(NULL);
-        if(display) {
-            fprintf(stderr, "X11.app: main(): closing the display");
-            /* Could open the display, start the launcher */
-            XCloseDisplay(display);
-
-            /* Give 2 seconds for the server to start... 
-             * TODO: *Really* fix this race condition
-             */
-            usleep(2000);
-            fprintf(stderr, "X11.app: main(): running launcher_main()");
-            return launcher_main(argc, argv);
-        }
-    }
-
-    /* Couldn't open the display or we were called with arguments,
-     * just want to start a server.
-     */
-    fprintf(stderr, "X11.app: main(): running server_main()");
-    return server_main(argc, argv);
-}
diff --git a/hw/darwin/apple/launcher-main.c b/hw/darwin/apple/launcher-main.c
deleted file mode 100644
index 60a1624..0000000
--- a/hw/darwin/apple/launcher-main.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/* main.c -- X application launcher
- 
- Copyright (c) 2007 Apple Inc.
- 
- 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 <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-
-#include <CoreFoundation/CoreFoundation.h>
-
-#define DEFAULT_APP "/usr/X11/bin/xterm"
-
-int launcher_main (int argc, char **argv) {
-  char *command = DEFAULT_APP;
-  const char *newargv[7];
-  int child;
-  
-
-	CFPropertyListRef PlistRef = CFPreferencesCopyAppValue(CFSTR("app_to_run"),
-									kCFPreferencesCurrentApplication);
-	
-	if ((PlistRef == NULL) || (CFGetTypeID(PlistRef) != CFStringGetTypeID())) {
-		CFPreferencesSetAppValue(CFSTR("app_to_run"), CFSTR(DEFAULT_APP), 
-								 kCFPreferencesCurrentApplication);
-		CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
-	} else {
-		int len = CFStringGetLength((CFStringRef)PlistRef)+1;
-		command = (char *) malloc(len);
-		CFStringGetCString((CFStringRef)PlistRef, command, len,  kCFStringEncodingASCII);
-		fprintf(stderr, "command=%s\n", command);
-	}
-	
-	if (PlistRef) CFRelease(PlistRef);
-	
-	newargv[0] = "/usr/bin/login";
-	newargv[1] = "-fp";
-	newargv[2] = getlogin();
-	newargv[3] = "/bin/sh";
-	newargv[4] = "-c";
-	newargv[5] = command;
-	newargv[6] = NULL;
-
-    child = fork();
-	
-    switch (child) {
-    case -1:				/* error */
-      perror ("fork");
-      return EXIT_FAILURE;		
-    case 0:				    /* child */
-      execvp (newargv[0], (char **const) newargv);
-      perror ("Couldn't exec");
-      _exit (1);
-   }
-	
-    return 0;
-}
diff --git a/hw/darwin/apple/org.x.X11.plist b/hw/darwin/apple/org.x.X11.plist
deleted file mode 100644
index 6c6be91..0000000
--- a/hw/darwin/apple/org.x.X11.plist
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>Label</key>
-		<string>org.x.X11</string>
-	<key>Program</key>
-		<string>/Applications/Utilities/X11.app/Contents/MacOS/X11</string>
-	<key>ProgramArguments</key>
-		<array>
-		<string>/Applications/Utilities/X11.app/Contents/MacOS/X11</string>
-		<string>--launchd</string>
-		</array>
-	<key>Sockets</key>
-		<dict>
-		<key>:0</key>
-			<dict>
-			<key>SecureSocketWithKey</key>
-				<string>DISPLAY</string>
-			</dict>
-		</dict>
-	<key>ServiceIPC</key>
-		<true/>
-</dict>
-</plist>
diff --git a/hw/darwin/apple/server-main.c b/hw/darwin/apple/server-main.c
deleted file mode 100644
index 26fcbb0..0000000
--- a/hw/darwin/apple/server-main.c
+++ /dev/null
@@ -1,904 +0,0 @@
-/* bundle-main.c -- X server launcher
- 
- Copyright (c) 2002-2007 Apple Inc. 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 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.
- 
- Parts of this file are derived from xdm, which has this copyright:
- 
- Copyright 1988, 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. */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/socket.h>
-#include <sys/utsname.h>
-#include <ifaddrs.h>
-#include <netdb.h>
-#include <netinet/in.h>
-#include <time.h>
-#include <sys/wait.h>
-#include <setjmp.h>
-#include <sys/ioctl.h>
-
-#include <X11/Xlib.h>
-#include <X11/Xauth.h>
-#include <xcb/xcb.h>
-
-#include <CoreFoundation/CoreFoundation.h>
-#include <SystemConfiguration/SystemConfiguration.h>
-
-#define X_SERVER "/usr/X11/bin/Xquartz"
-#define XTERM_PATH "/usr/X11/bin/xterm"
-#define WM_PATH "/usr/bin/quartz-wm"
-#define DEFAULT_XINITRC "/usr/X11/lib/X11/xinit/xinitrc"
-#define DEFAULT_PATH "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11/bin"
-
-/* what xinit does */
-#ifndef SHELL
-# define SHELL "sh"
-#endif
-
-#undef FALSE
-#define FALSE 0
-#undef TRUE
-#define TRUE 1
-
-#define MAX_DISPLAYS 64
-
-static int server_pid = -1, client_pid = -1;
-static int xinit_kills_server = FALSE;
-static jmp_buf exit_continuation;
-static const char *server_name = NULL;
-static Display *server_dpy;
-
-static char *auth_file;
-
-typedef struct addr_list_struct addr_list;
-
-struct addr_list_struct {
-    addr_list *next;
-    Xauth auth;
-};
-
-static addr_list *addresses;
-
-
-/* Utility functions. */
-
-/* Return the current host name. Matches what Xlib does. */
-static char *
-host_name (void)
-{
-#ifdef NEED_UTSNAME
-    static struct utsname name;
-	
-    uname(&name);
-	
-    return name.nodename;
-#else
-    static char buf[100];
-	
-    gethostname(buf, sizeof(buf));
-	
-    return buf;
-#endif
-}
-
-static int
-read_boolean_pref (CFStringRef name, int default_)
-{
-    int value;
-    Boolean ok;
-	
-    value = CFPreferencesGetAppBooleanValue (name,
-											 CFSTR ("com.apple.x11"), &ok);
-    return ok ? value : default_;
-}
-
-static inline int
-binary_equal (const void *a, const void *b, int length)
-{
-    return memcmp (a, b, length) == 0;
-}
-
-static inline void *
-binary_dup (const void *a, int length)
-{
-    void *b = malloc (length);
-    if (b != NULL)
-		memcpy (b, a, length);
-    return b;
-}
-
-static inline void
-binary_free (void *data, int length)
-{
-    if (data != NULL)
-		free (data);
-}
-
-
-/* Functions for managing the authentication entries. */
-
-/* Returns true if something matching AUTH is in our list of auth items */
-static int
-check_auth_item (Xauth *auth)
-{
-    addr_list *a;
-	
-    for (a = addresses; a != NULL; a = a->next)
-    {
-		if (a->auth.family == auth->family
-			&& a->auth.address_length == auth->address_length
-			&& binary_equal (a->auth.address, auth->address, auth->address_length)
-			&& a->auth.number_length == auth->number_length
-			&& binary_equal (a->auth.number, auth->number, auth->number_length)
-			&& a->auth.name_length == auth->name_length
-			&& binary_equal (a->auth.name, auth->name, auth->name_length))
-		{
-			return TRUE;
-		}
-    }
-	
-    return FALSE;
-}
-
-/* Add one item to our list of auth items. */
-static void
-add_auth_item (Xauth *auth)
-{
-    addr_list *a = malloc (sizeof (addr_list));
-	
-    a->auth.family = auth->family;
-    a->auth.address_length = auth->address_length;
-    a->auth.address = binary_dup (auth->address, auth->address_length);
-    a->auth.number_length = auth->number_length;
-    a->auth.number = binary_dup (auth->number, auth->number_length);
-    a->auth.name_length = auth->name_length;
-    a->auth.name = binary_dup (auth->name, auth->name_length);
-    a->auth.data_length = auth->data_length;
-    a->auth.data = binary_dup (auth->data, auth->data_length);
-	
-    a->next = addresses;
-    addresses = a;
-}
-
-/* Free all allocated auth items. */
-static void
-free_auth_items (void)
-{
-    addr_list *a;
-	
-    while ((a = addresses) != NULL)
-    {
-		addresses = a->next;
-		
-		binary_free (a->auth.address, a->auth.address_length);
-		binary_free (a->auth.number, a->auth.number_length);
-		binary_free (a->auth.name, a->auth.name_length);
-		binary_free (a->auth.data, a->auth.data_length);
-		free (a);
-    }
-}
-
-/* Add the unix domain auth item. */
-static void
-define_local (Xauth *auth)
-{
-    char *host = host_name ();
-	
-#ifdef DEBUG
-    fprintf (stderr, "x11: hostname is %s\n", host);
-#endif
-	
-    auth->family = FamilyLocal;
-    auth->address_length = strlen (host);
-    auth->address = host;
-	
-    add_auth_item (auth);
-}
-
-/* Add the tcp auth item. */
-static void
-define_named (Xauth *auth, const char *name)
-{
-    struct ifaddrs *addrs, *ptr;
-	
-    if (getifaddrs (&addrs) != 0)
-		return;
-	
-    for (ptr = addrs; ptr != NULL; ptr = ptr->ifa_next)
-    {
-		if (ptr->ifa_addr->sa_family != AF_INET)
-			continue;
-		
-		auth->family = FamilyInternet;
-		auth->address_length = sizeof (struct in_addr);
-		auth->address = (char *) &(((struct sockaddr_in *) ptr->ifa_addr)->sin_addr);
-		
-#ifdef DEBUG
-		fprintf (stderr, "x11: ipaddr is %d.%d.%d.%d\n",
-				 (unsigned char) auth->address[0],
-				 (unsigned char) auth->address[1],
-				 (unsigned char) auth->address[2],
-				 (unsigned char) auth->address[3]);
-#endif
-		
-		add_auth_item (auth);
-    }
-	
-    freeifaddrs (addrs);
-}
-
-/* Parse the display number from NAME and add it to AUTH. */
-static void
-set_auth_number (Xauth *auth, const char *name)
-{
-    char *colon;
-    char *dot, *number;
-	
-    colon = strrchr(name, ':');
-    if (colon != NULL)
-    {
-		colon++;
-		dot = strchr(colon, '.');
-		
-		if (dot != NULL)
-			auth->number_length = dot - colon;
-		else
-			auth->number_length = strlen (colon);
-		
-		number = malloc (auth->number_length + 1);
-		if (number != NULL)
-		{
-			strncpy (number, colon, auth->number_length);
-			number[auth->number_length] = '\0';
-		}
-		else
-		{
-			auth->number_length = 0;
-		}
-		
-		auth->number = number;
-    }
-}
-
-/* Put 128 bits of random data into DATA. If possible, it will be "high
- quality" */
-static int
-generate_mit_magic_cookie (char data[16])
-{
-    int fd, ret, i;
-    long *ldata = (long *) data;
-	
-    fd = open ("/dev/random", O_RDONLY);
-    if (fd > 0) {
-		ret = read (fd, data, 16);
-		close (fd);
-		if (ret == 16) return TRUE;
-    }
-	
-    /* fall back to the usual crappy rng */
-	
-    srand48 (getpid () ^ time (NULL));
-	
-    for (i = 0; i < 4; i++)
-		ldata[i] = lrand48 ();
-	
-    return TRUE;
-}
-
-/* Create the keys we'll be using for the display named NAME. */
-static int
-make_auth_keys (const char *name)
-{
-    Xauth auth;
-    char key[16];
-	
-    if (auth_file == NULL)
-		return FALSE;
-	
-    auth.name = "MIT-MAGIC-COOKIE-1";
-    auth.name_length = strlen (auth.name);
-	
-    if (!generate_mit_magic_cookie (key))
-    {
-		auth_file = NULL;
-		return FALSE;
-    }
-	
-    auth.data = key;
-    auth.data_length = 16;
-	
-    set_auth_number (&auth, name);
-	
-    define_named (&auth, host_name ());
-    define_local (&auth);
-	
-    free (auth.number);
-	
-    return TRUE;
-}
-
-/* If ADD-ENTRIES is true, merge our auth entries into the existing
- Xauthority file. If ADD-ENTRIES is false, remove our entries. */
-static int
-write_auth_file (int add_entries)
-{
-    char *home, newname[1024];
-    int fd, ret;
-    FILE *new_fh, *old_fh;
-    addr_list *addr;
-    Xauth *auth;
-	
-    if (auth_file == NULL)
-		return FALSE;
-	
-    home = getenv ("HOME");
-    if (home == NULL)
-    {
-		auth_file = NULL;
-		return FALSE;
-    }
-	
-    snprintf (newname, sizeof (newname), "%s/.XauthorityXXXXXX", home);
-    mktemp (newname);
-	
-    if (XauLockAuth (auth_file, 1, 2, 10) != LOCK_SUCCESS)
-    {
-		/* FIXME: do something here? */
-		
-		auth_file = NULL;
-		return FALSE;
-    }
-	
-    fd = open (newname, O_WRONLY | O_CREAT | O_TRUNC, 0600);
-    if (fd >= 0)
-    {
-		new_fh = fdopen (fd, "w");
-		if (new_fh != NULL)
-		{
-			if (add_entries)
-			{
-				for (addr = addresses; addr != NULL; addr = addr->next)
-				{
-					XauWriteAuth (new_fh, &addr->auth);
-				}
-			}
-			
-			old_fh = fopen (auth_file, "r");
-			if (old_fh != NULL)
-			{
-				while ((auth = XauReadAuth (old_fh)) != NULL)
-				{
-					if (!check_auth_item (auth))
-						XauWriteAuth (new_fh, auth);
-					XauDisposeAuth (auth);
-				}
-				fclose (old_fh);
-			}
-			
-			fclose (new_fh);
-			unlink (auth_file);
-			
-			ret = rename (newname, auth_file);
-			
-			if (ret != 0)
-				auth_file = NULL;
-			
-			XauUnlockAuth (auth_file);
-			return ret == 0;
-		}
-		
-		close (fd);
-    }
-	
-    XauUnlockAuth (auth_file);
-    auth_file = NULL;
-    return FALSE;
-}
-
-
-/* Subprocess management functions. */
-
-static int
-start_server (char **xargv)
-{
-    int child;
-	
-    child = fork ();
-	
-    switch (child)
-    {
-    case -1:				/* error */
-		perror ("fork");
-		return FALSE;
-		
-    case 0:				/* child */
-		execv (X_SERVER, xargv);
-		perror ("Couldn't exec " X_SERVER);
-		_exit (1);
-		
-    default:				/* parent */
-		server_pid = child;
-		return TRUE;
-    }
-}
-
-static int
-wait_for_server (void)
-{
-    int count = 100;
-	
-    while (count-- > 0)
-    {
-		int status;
-		
-		server_dpy = XOpenDisplay (server_name);
-		if (server_dpy != NULL)
-			return TRUE;
-		
-		if (waitpid (server_pid, &status, WNOHANG) == server_pid)
-			return FALSE;
-		
-		sleep (1);
-    }
-	
-    return FALSE;
-}
-
-static int
-start_client (void)
-{
-    int child;
-	
-    child = fork();
-	
-    switch (child) {
-		char *temp, buf[1024];		
-
-	case -1:				/* error */
-		perror("fork");
-		return FALSE;
-
-	case 0:					/* child */
-		/* Setup environment */
-		temp = getenv("DISPLAY");
-//		if (temp == NULL && temp[0] != 0)
-			setenv("DISPLAY", server_name, TRUE);
-
-		temp = getenv("PATH");
-		if (temp == NULL || temp[0] == 0) 
-			setenv ("PATH", DEFAULT_PATH, TRUE);
-		else if (strnstr(temp, "/usr/X11/bin", sizeof(temp)) == NULL) {
-			snprintf(buf, sizeof(buf), "%s:/usr/X11/bin", temp);		
-			setenv("PATH", buf, TRUE);	
-		}
-		
-		/* First try value of $XINITRC, if set. */
-		temp = getenv("XINITRC");
-		if (temp != NULL && temp[0] != 0 && access(temp, R_OK) == 0)
-			execlp (SHELL, SHELL, temp, NULL);
-
-		/* Then look for .xinitrc in user's home directory. */
-		temp = getenv("HOME");
-		if (temp != NULL && temp[0] != 0) {
-			chdir(temp);
-			snprintf (buf, sizeof (buf), "%s/.xinitrc", temp);
-			if (access(buf, R_OK) == 0)
-				execlp(SHELL, SHELL, buf, NULL);
-		}
-		
-		/* Then try the default xinitrc in the lib directory. */
-		
-		if (access(DEFAULT_XINITRC, R_OK) == 0)
-			execlp(SHELL, SHELL, DEFAULT_XINITRC, NULL);
-		
-		/* Then fallback to hardcoding an xterm and the window manager. */
-		
-		//		system(XTERM_PATH " &");
-		execl(WM_PATH, WM_PATH, NULL);
-		
-		perror("exec");
-		_exit(1);
-		
-    default:				/* parent */
-		client_pid = child;
-		return TRUE;
-    }
-}
-
-static void
-sigchld_handler (int sig)
-{
-    int pid, status;
-	
-	again:
-    pid = waitpid (WAIT_ANY, &status, WNOHANG);
-	
-    if (pid > 0)
-    {
-		if (pid == server_pid)
-		{
-			server_pid = -1;
-			
-			if (client_pid >= 0)
-				kill (client_pid, SIGTERM);
-		}
-		else if (pid == client_pid)
-		{
-			client_pid = -1;
-			
-			if (server_pid >= 0 && xinit_kills_server)
-				kill (server_pid, SIGTERM);
-		}
-		goto again;
-    }
-	
-    if (server_pid == -1 && client_pid == -1)
-		longjmp (exit_continuation, 1);
-	
-    signal (SIGCHLD, sigchld_handler);
-}
-
-
-/* Server utilities. */
-
-static Boolean
-display_exists_p (int number)
-{
-    char buf[64];
-    xcb_connection_t *conn;
-    char *fullname = NULL;
-    int idisplay, iscreen;
-    char *conn_auth_name, *conn_auth_data;
-    int conn_auth_namelen, conn_auth_datalen;
-    
-    //    extern void *_X11TransConnectDisplay ();
-    //    extern void _XDisconnectDisplay ();
-	
-    /* Since connecting to the display waits for a few seconds if the
-	 display doesn't exist, check for trivial non-existence - if the
-	 socket in /tmp exists or not.. (note: if the socket exists, the
-	 server may still not, so we need to try to connect in that case..) */
-	
-    sprintf (buf, "/tmp/.X11-unix/X%d", number);
-    if (access (buf, F_OK) != 0)
-		return FALSE;
-    
-    sprintf (buf, ":%d", number);
-    conn = xcb_connect(buf, NULL);
-    if (xcb_connection_has_error(conn)) return FALSE;
-	
-    xcb_disconnect(conn);
-    return TRUE;
-}
-
-
-/* Monitoring when the system's ip addresses change. */
-
-static Boolean pending_timer;
-
-static void
-timer_callback (CFRunLoopTimerRef timer, void *info)
-{
-    pending_timer = FALSE;
-	
-    /* Update authentication names. Need to write .Xauthority file first
-	 without the existing entries, then again with the new entries.. */
-	
-    write_auth_file (FALSE);
-	
-    free_auth_items ();
-    make_auth_keys (server_name);
-	
-    write_auth_file (TRUE);
-}
-
-/* This function is called when the system's ip addresses may have changed. */
-static void
-ipaddr_callback (SCDynamicStoreRef store, CFArrayRef changed_keys, void *info)
-{
-#if DEBUG
-    if (changed_keys != NULL) {
-		fprintf (stderr, "x11: changed sc keys: ");
-		CFShow (changed_keys);
-    }
-#endif
-
-    if (auth_file != NULL && !pending_timer)
-    {
-		CFRunLoopTimerRef timer;
-		
-		timer = CFRunLoopTimerCreate (NULL, CFAbsoluteTimeGetCurrent () + 1.0,
-									  0.0, 0, 0, timer_callback, NULL);
-		CFRunLoopAddTimer (CFRunLoopGetCurrent (), timer,
-						   kCFRunLoopDefaultMode);
-		CFRelease (timer);
-		
-		pending_timer = TRUE;
-    }
-}
-
-/* This code adapted from "Living in a Dynamic TCP/IP Environment" technote. */
-static Boolean
-install_ipaddr_source (void)
-{
-    CFRunLoopSourceRef source = NULL;
-	
-    SCDynamicStoreContext context = {0};
-    SCDynamicStoreRef ref;
-	
-    ref = SCDynamicStoreCreate (NULL,
-								CFSTR ("AddIPAddressListChangeCallbackSCF"),
-								ipaddr_callback, &context);
-	
-    if (ref != NULL)
-    {
-		const void *keys[4], *patterns[2];
-		int i;
-		
-		keys[0] = SCDynamicStoreKeyCreateNetworkGlobalEntity (NULL, kSCDynamicStoreDomainState, kSCEntNetIPv4);
-		keys[1] = SCDynamicStoreKeyCreateNetworkGlobalEntity (NULL, kSCDynamicStoreDomainState, kSCEntNetIPv6);
-		keys[2] = SCDynamicStoreKeyCreateComputerName (NULL);
-		keys[3] = SCDynamicStoreKeyCreateHostNames (NULL);
-		
-		patterns[0] = SCDynamicStoreKeyCreateNetworkInterfaceEntity (NULL, kSCDynamicStoreDomainState, kSCCompAnyRegex, kSCEntNetIPv4);
-		patterns[1] = SCDynamicStoreKeyCreateNetworkInterfaceEntity (NULL, kSCDynamicStoreDomainState, kSCCompAnyRegex, kSCEntNetIPv6);
-		
-		if (keys[0] != NULL && keys[1] != NULL && keys[2] != NULL
-			&& keys[3] != NULL && patterns[0] != NULL && patterns[1] != NULL)
-		{
-			CFArrayRef key_array, pattern_array;
-			
-			key_array = CFArrayCreate (NULL, keys, 4, &kCFTypeArrayCallBacks);
-			pattern_array = CFArrayCreate (NULL, patterns, 2, &kCFTypeArrayCallBacks);
-			
-			if (key_array != NULL || pattern_array != NULL)
-			{
-				SCDynamicStoreSetNotificationKeys (ref, key_array, pattern_array);
-				source = SCDynamicStoreCreateRunLoopSource (NULL, ref, 0);
-			}
-			
-			if (key_array != NULL)
-				CFRelease (key_array);
-			if (pattern_array != NULL)
-				CFRelease (pattern_array);
-		}
-		
-		
-		for (i = 0; i < 4; i++)
-			if (keys[i] != NULL)
-			CFRelease (keys[i]);
-		for (i = 0; i < 2; i++)
-			if (patterns[i] != NULL)
-			CFRelease (patterns[i]);
-		
-		CFRelease (ref); 
-    }
-	
-    if (source != NULL)
-    {
-		CFRunLoopAddSource (CFRunLoopGetCurrent (),
-							source, kCFRunLoopDefaultMode);
-		CFRelease (source);
-    }
-	
-    return source != NULL;
-}
-
-
-/* Entrypoint. */
-
-void
-termination_signal_handler (int unused_sig)
-{
-    signal (SIGTERM, SIG_DFL);
-    signal (SIGHUP, SIG_DFL);
-    signal (SIGINT, SIG_DFL);
-    signal (SIGQUIT, SIG_DFL);
-
-    longjmp (exit_continuation, 1);
-}
-
-int
-server_main (int argc, char **argv)
-{
-    char **xargv;
-    int i, j;
-    int fd;
-	
-    xargv = alloca (sizeof (char *) * (argc + 32));
-	
-    if (!read_boolean_pref (CFSTR ("no_auth"), FALSE))
-		auth_file = XauFileName ();
-	
-    /* The standard X11 behaviour is for the server to quit when the first
-	 client exits. But it can be useful for debugging (and to mimic our
-	 behaviour in the beta releases) to not do that. */
-	
-    xinit_kills_server = read_boolean_pref (CFSTR ("xinit_kills_server"), TRUE);
-	
-    for (i = 1; i < argc; i++)
-    {
-		if (argv[i][0] == ':')
-			server_name = argv[i];
-    }
-	
-    if (server_name == NULL)
-    {
-		static char name[8];
-		
-		/* No display number specified, so search for the first unused.
-		 
-		 There's a big old race condition here if two servers start at
-		 the same time, but that's fairly unlikely. We could create
-		 lockfiles or something, but that's seems more likely to cause
-		 problems than the race condition itself.. */
-		
-		for (i = 0; i < MAX_DISPLAYS; i++)
-		{
-			if (!display_exists_p (i))
-				break;
-		}
-		
-		if (i == MAX_DISPLAYS)
-		{
-			fprintf (stderr, "%s: couldn't allocate a display number", argv[0]);
-			exit (1);
-		}
-		
-		sprintf (name, ":%d", i);
-		server_name = name;
-    }
-	
-    if (auth_file != NULL)
-    {
-		/* Create new Xauth keys and add them to the .Xauthority file */
-		
-		make_auth_keys (server_name);
-		write_auth_file (TRUE);
-    }
-	
-    /* Construct our new argv */
-	
-    i = j = 0;
-	
-    xargv[i++] = argv[j++];
-	
-    if (auth_file != NULL)
-    {
-		xargv[i++] = "-auth";
-		xargv[i++] = auth_file;
-    }
-	
-    /* By default, don't listen on tcp sockets if Xauth is disabled. */
-	
-    if (read_boolean_pref (CFSTR ("nolisten_tcp"), auth_file == NULL))
-    {
-		xargv[i++] = "-nolisten";
-		xargv[i++] = "tcp";
-    }
-	
-    while (j < argc)
-    {
-		if (argv[j++][0] != ':')
-			xargv[i++] = argv[j-1];
-    }
-	
-    xargv[i++] = (char *) server_name;
-    xargv[i++] = NULL;
-	
-    /* Detach from any controlling terminal and connect stdin to /dev/null */
-	
-#ifdef TIOCNOTTY
-    fd = open ("/dev/tty", O_RDONLY);
-    if (fd != -1)
-    {
-		ioctl (fd, TIOCNOTTY, 0);
-		close (fd);
-    }
-#endif
-	
-    fd = open ("/dev/null", O_RDWR, 0);
-    if (fd >= 0)
-    {
-		dup2 (fd, 0);
-		if (fd > 0)
-			close (fd);
-    }
-	
-    if (!start_server (xargv))
-		return 1;
-	
-    if (!wait_for_server ())
-    {
-		kill (server_pid, SIGTERM);
-		return 1;
-    }
-	
-    if (!start_client ())
-    {
-		kill (server_pid, SIGTERM);
-		return 1;
-    }
-	
-    signal (SIGCHLD, sigchld_handler);
-	
-    signal (SIGTERM, termination_signal_handler);
-    signal (SIGHUP, termination_signal_handler);
-    signal (SIGINT, termination_signal_handler);
-    signal (SIGQUIT, termination_signal_handler);
-
-    if (setjmp (exit_continuation) == 0)
-    {
-		if (install_ipaddr_source ())
-			CFRunLoopRun ();
-		else
-			while (1) pause ();
-    }
-	
-    signal (SIGCHLD, SIG_IGN);
-
-    if (client_pid >= 0) kill (client_pid, SIGTERM);
-    if (server_pid >= 0) kill (server_pid, SIGTERM);
-	
-    if (auth_file != NULL)
-    {
-		/* Remove our Xauth keys */
-		
-		write_auth_file (FALSE);
-    }
-	
-    free_auth_items ();
-	
-    return 0;
-}
diff --git a/hw/darwin/quartz/Makefile.am b/hw/darwin/quartz/Makefile.am
index f5199df..38f48d0 100644
--- a/hw/darwin/quartz/Makefile.am
+++ b/hw/darwin/quartz/Makefile.am
@@ -1,14 +1,21 @@
-noinst_LIBRARIES = libXQuartz.a
+noinst_LTLIBRARIES = libXQuartz.la
 
 AM_CFLAGS = $(XSERVER_CFLAGS) $(DIX_CFLAGS)
 AM_OBJCFLAGS = $(XSERVER_CFLAGS) $(DIX_CFLAGS)
+
+# TODO: This should not pull in rootless... rootless should all be in xpr
 AM_CPPFLAGS = \
 	-I$(srcdir) -I$(srcdir)/.. \
 	-I$(top_srcdir)/miext/rootless
 
-SUBDIRS = xpr
+if X11APP
+X11APP_SUBDIRS = apple
+endif
+
+SUBDIRS = . xpr $(X11APP_SUBDIRS)
+DIST_SUBDIRS = xpr apple
 
-libXQuartz_a_SOURCES = \
+libXQuartz_la_SOURCES = \
 	X11Application.m \
 	X11Controller.m \
 	applewm.c \
diff --git a/hw/darwin/quartz/X11Application.m b/hw/darwin/quartz/X11Application.m
index aef0699..3e37dd4 100644
--- a/hw/darwin/quartz/X11Application.m
+++ b/hw/darwin/quartz/X11Application.m
@@ -59,8 +59,7 @@ int X11EnableKeyEquivalents = TRUE;
 int quartzHasRoot = FALSE, quartzEnableRootless = TRUE;
 
 extern int darwinFakeButtons, input_check_flag;
-// extern Bool enable_stereo; 
-Bool enable_stereo;  //<-- this needs to go back to being an extern once glxCGL is fixed
+extern Bool enable_stereo; 
 
 extern xEvent *darwinEvents;
 
diff --git a/hw/darwin/quartz/apple/English.lproj/InfoPlist.strings b/hw/darwin/quartz/apple/English.lproj/InfoPlist.strings
new file mode 100644
index 0000000..88e1f04
Binary files /dev/null and b/hw/darwin/quartz/apple/English.lproj/InfoPlist.strings differ
diff --git a/hw/darwin/quartz/apple/English.lproj/Localizable.strings b/hw/darwin/quartz/apple/English.lproj/Localizable.strings
new file mode 100644
index 0000000..c83b085
Binary files /dev/null and b/hw/darwin/quartz/apple/English.lproj/Localizable.strings differ
diff --git a/hw/darwin/quartz/apple/English.lproj/main.nib/classes.nib b/hw/darwin/quartz/apple/English.lproj/main.nib/classes.nib
new file mode 100644
index 0000000..a82159b
--- /dev/null
+++ b/hw/darwin/quartz/apple/English.lproj/main.nib/classes.nib
@@ -0,0 +1,318 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>IBClasses</key>
+	<array>
+		<dict>
+			<key>CLASS</key>
+			<string>IBLibraryObjectTemplate</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>OUTLETS</key>
+			<dict>
+				<key>draggedView</key>
+				<string>NSView</string>
+				<key>representedObject</key>
+				<string>NSObject</string>
+			</dict>
+			<key>SUPERCLASS</key>
+			<string>NSView</string>
+		</dict>
+		<dict>
+			<key>CLASS</key>
+			<string>IBInspector</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>OUTLETS</key>
+			<dict>
+				<key>inspectorView</key>
+				<string>NSView</string>
+			</dict>
+			<key>SUPERCLASS</key>
+			<string>NSObject</string>
+		</dict>
+		<dict>
+			<key>CLASS</key>
+			<string>NSDateFormatter</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>SUPERCLASS</key>
+			<string>NSFormatter</string>
+		</dict>
+		<dict>
+			<key>ACTIONS</key>
+			<dict>
+				<key>apps_table_cancel</key>
+				<string>id</string>
+				<key>apps_table_delete</key>
+				<string>id</string>
+				<key>apps_table_done</key>
+				<string>id</string>
+				<key>apps_table_duplicate</key>
+				<string>id</string>
+				<key>apps_table_new</key>
+				<string>id</string>
+				<key>apps_table_show</key>
+				<string>id</string>
+				<key>bring_to_front</key>
+				<string>id</string>
+				<key>close_window</key>
+				<string>id</string>
+				<key>enable_fullscreen_changed</key>
+				<string>id</string>
+				<key>minimize_window</key>
+				<string>id</string>
+				<key>next_window</key>
+				<string>id</string>
+				<key>prefs_changed</key>
+				<string>id</string>
+				<key>prefs_show</key>
+				<string>id</string>
+				<key>previous_window</key>
+				<string>id</string>
+				<key>toggle_fullscreen</key>
+				<string>id</string>
+				<key>x11_help</key>
+				<string>id</string>
+				<key>zoom_window</key>
+				<string>id</string>
+			</dict>
+			<key>CLASS</key>
+			<string>X11Controller</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>OUTLETS</key>
+			<dict>
+				<key>apps_separator</key>
+				<string>id</string>
+				<key>apps_table</key>
+				<string>id</string>
+				<key>depth</key>
+				<string>id</string>
+				<key>dock_apps_menu</key>
+				<string>id</string>
+				<key>dock_menu</key>
+				<string>id</string>
+				<key>dock_window_separator</key>
+				<string>id</string>
+				<key>enable_auth</key>
+				<string>id</string>
+				<key>enable_fullscreen</key>
+				<string>id</string>
+				<key>enable_keyequivs</key>
+				<string>id</string>
+				<key>enable_tcp</key>
+				<string>id</string>
+				<key>fake_buttons</key>
+				<string>id</string>
+				<key>prefs_panel</key>
+				<string>id</string>
+				<key>sync_keymap</key>
+				<string>id</string>
+				<key>toggle_fullscreen_item</key>
+				<string>id</string>
+				<key>use_sysbeep</key>
+				<string>id</string>
+				<key>window_separator</key>
+				<string>id</string>
+				<key>x11_about_item</key>
+				<string>id</string>
+			</dict>
+			<key>SUPERCLASS</key>
+			<string>NSObject</string>
+		</dict>
+		<dict>
+			<key>CLASS</key>
+			<string>NSNumberFormatter</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>SUPERCLASS</key>
+			<string>NSFormatter</string>
+		</dict>
+		<dict>
+			<key>CLASS</key>
+			<string>NSFormatter</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>SUPERCLASS</key>
+			<string>NSObject</string>
+		</dict>
+		<dict>
+			<key>ACTIONS</key>
+			<dict>
+				<key>alignCenter:</key>
+				<string>id</string>
+				<key>alignJustified:</key>
+				<string>id</string>
+				<key>alignLeft:</key>
+				<string>id</string>
+				<key>alignRight:</key>
+				<string>id</string>
+				<key>arrangeInFront:</key>
+				<string>id</string>
+				<key>centerSelectionInVisibleArea:</key>
+				<string>id</string>
+				<key>changeFont:</key>
+				<string>id</string>
+				<key>checkSpelling:</key>
+				<string>id</string>
+				<key>clear:</key>
+				<string>id</string>
+				<key>clearRecentDocuments:</key>
+				<string>id</string>
+				<key>complete:</key>
+				<string>id</string>
+				<key>copy:</key>
+				<string>id</string>
+				<key>copyFont:</key>
+				<string>id</string>
+				<key>copyRuler:</key>
+				<string>id</string>
+				<key>cut:</key>
+				<string>id</string>
+				<key>delete:</key>
+				<string>id</string>
+				<key>deminiaturize:</key>
+				<string>id</string>
+				<key>fax:</key>
+				<string>id</string>
+				<key>hide:</key>
+				<string>id</string>
+				<key>hideOtherApplications:</key>
+				<string>id</string>
+				<key>loosenKerning:</key>
+				<string>id</string>
+				<key>lowerBaseline:</key>
+				<string>id</string>
+				<key>makeKeyAndOrderFront:</key>
+				<string>id</string>
+				<key>miniaturize:</key>
+				<string>id</string>
+				<key>newDocument:</key>
+				<string>id</string>
+				<key>openDocument:</key>
+				<string>id</string>
+				<key>orderBack:</key>
+				<string>id</string>
+				<key>orderFront:</key>
+				<string>id</string>
+				<key>orderFrontColorPanel:</key>
+				<string>id</string>
+				<key>orderFrontHelpPanel:</key>
+				<string>id</string>
+				<key>orderOut:</key>
+				<string>id</string>
+				<key>outline:</key>
+				<string>id</string>
+				<key>paste:</key>
+				<string>id</string>
+				<key>pasteAsPlainText:</key>
+				<string>id</string>
+				<key>pasteAsRichText:</key>
+				<string>id</string>
+				<key>pasteFont:</key>
+				<string>id</string>
+				<key>pasteRuler:</key>
+				<string>id</string>
+				<key>pause:</key>
+				<string>id</string>
+				<key>performClose:</key>
+				<string>id</string>
+				<key>performFindPanelAction:</key>
+				<string>id</string>
+				<key>performMiniaturize:</key>
+				<string>id</string>
+				<key>performZoom:</key>
+				<string>id</string>
+				<key>play:</key>
+				<string>id</string>
+				<key>print:</key>
+				<string>id</string>
+				<key>printDocument:</key>
+				<string>id</string>
+				<key>raiseBaseline:</key>
+				<string>id</string>
+				<key>record:</key>
+				<string>id</string>
+				<key>redo:</key>
+				<string>id</string>
+				<key>resume:</key>
+				<string>id</string>
+				<key>revertDocumentToSaved:</key>
+				<string>id</string>
+				<key>run:</key>
+				<string>id</string>
+				<key>runPageLayout:</key>
+				<string>id</string>
+				<key>runToolbarCustomizationPalette:</key>
+				<string>id</string>
+				<key>saveAllDocuments:</key>
+				<string>id</string>
+				<key>saveDocument:</key>
+				<string>id</string>
+				<key>saveDocumentAs:</key>
+				<string>id</string>
+				<key>saveDocumentTo:</key>
+				<string>id</string>
+				<key>selectAll:</key>
+				<string>id</string>
+				<key>selectText:</key>
+				<string>id</string>
+				<key>showGuessPanel:</key>
+				<string>id</string>
+				<key>showHelp:</key>
+				<string>id</string>
+				<key>start:</key>
+				<string>id</string>
+				<key>startSpeaking:</key>
+				<string>id</string>
+				<key>stop:</key>
+				<string>id</string>
+				<key>stopSpeaking:</key>
+				<string>id</string>
+				<key>subscript:</key>
+				<string>id</string>
+				<key>superscript:</key>
+				<string>id</string>
+				<key>terminate:</key>
+				<string>id</string>
+				<key>tightenKerning:</key>
+				<string>id</string>
+				<key>toggleContinuousSpellChecking:</key>
+				<string>id</string>
+				<key>toggleRuler:</key>
+				<string>id</string>
+				<key>toggleToolbarShown:</key>
+				<string>id</string>
+				<key>turnOffKerning:</key>
+				<string>id</string>
+				<key>turnOffLigatures:</key>
+				<string>id</string>
+				<key>underline:</key>
+				<string>id</string>
+				<key>undo:</key>
+				<string>id</string>
+				<key>unhideAllApplications:</key>
+				<string>id</string>
+				<key>unscript:</key>
+				<string>id</string>
+				<key>useAllLigatures:</key>
+				<string>id</string>
+				<key>useStandardKerning:</key>
+				<string>id</string>
+				<key>useStandardLigatures:</key>
+				<string>id</string>
+			</dict>
+			<key>CLASS</key>
+			<string>FirstResponder</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>SUPERCLASS</key>
+			<string>NSObject</string>
+		</dict>
+	</array>
+	<key>IBVersion</key>
+	<integer>1</integer>
+</dict>
+</plist>
diff --git a/hw/darwin/quartz/apple/English.lproj/main.nib/info.nib b/hw/darwin/quartz/apple/English.lproj/main.nib/info.nib
new file mode 100644
index 0000000..88bc626
--- /dev/null
+++ b/hw/darwin/quartz/apple/English.lproj/main.nib/info.nib
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>IBFramework Version</key>
+	<string>588</string>
+	<key>IBOpenObjects</key>
+	<array>
+		<integer>244</integer>
+		<integer>29</integer>
+		<integer>423</integer>
+	</array>
+	<key>IBSystem Version</key>
+	<string>9A356</string>
+	<key>targetFramework</key>
+	<string>IBCocoaFramework</string>
+</dict>
+</plist>
diff --git a/hw/darwin/quartz/apple/English.lproj/main.nib/keyedobjects.nib b/hw/darwin/quartz/apple/English.lproj/main.nib/keyedobjects.nib
new file mode 100644
index 0000000..8b31450
Binary files /dev/null and b/hw/darwin/quartz/apple/English.lproj/main.nib/keyedobjects.nib differ
diff --git a/hw/darwin/quartz/apple/Info.plist b/hw/darwin/quartz/apple/Info.plist
new file mode 100644
index 0000000..66f1f6b
--- /dev/null
+++ b/hw/darwin/quartz/apple/Info.plist
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>English</string>
+	<key>CFBundleExecutable</key>
+	<string>X11</string>
+	<key>CFBundleGetInfoString</key>
+	<string>X11</string>
+	<key>CFBundleIconFile</key>
+	<string>X11.icns</string>
+	<key>CFBundleIdentifier</key>
+	<string>org.x.X11</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundleName</key>
+	<string>X11</string>
+	<key>CFBundlePackageType</key>
+	<string>APPL</string>
+	<key>CFBundleShortVersionString</key>
+	<string>2.0</string>
+	<key>CFBundleSignature</key>
+	<string>x11a</string>
+	<key>CSResourcesFileMapped</key>
+	<true/>
+	<key>NSHumanReadableCopyright</key>
+	<string>Copyright © 2003-2007, Apple Inc.
+Copyright © 2003, XFree86 Project, Inc.</string>
+	<key>NSMainNibFile</key>
+	<string>main</string>
+	<key>NSPrincipalClass</key>
+	<string>X11Application</string>
+</dict>
+</plist>
diff --git a/hw/darwin/quartz/apple/Makefile.am b/hw/darwin/quartz/apple/Makefile.am
new file mode 100644
index 0000000..a6e2dfb
--- /dev/null
+++ b/hw/darwin/quartz/apple/Makefile.am
@@ -0,0 +1,28 @@
+bin_SCRIPTS = x11app
+
+.PHONY: x11app
+
+x11app:
+	xcodebuild CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" ARCHS="$(X11APP_ARCHS)"
+
+install-data-hook:
+	xcodebuild install DSTROOT="/$(DESTDIR)" INSTALL_PATH="$(APPLE_APPLICATIONS_DIR)" DEPLOYMENT_LOCATION=YES SKIP_INSTALL=NO ARCHS="$(X11APP_ARCHS)"
+	$(MKDIR_P) "$(DESTDIR)/System/Library/LaunchAgents/"
+	$(INSTALL) org.x.X11.plist "$(DESTDIR)/System/Library/LaunchAgents/"
+
+clean-local:
+	rm -rf build
+
+EXTRA_DIST = \
+	org.x.X11.plist \
+	Info.plist \
+	X11.icns \
+	bundle-main.c \
+	launcher-main.c \
+	server-main.c \
+	English.lproj/InfoPlist.strings \
+	English.lproj/Localizable.strings \
+	English.lproj/main.nib/classes.nib \
+	English.lproj/main.nib/info.nib \
+	English.lproj/main.nib/keyedobjects.nib \
+	X11.xcodeproj/project.pbxproj
diff --git a/hw/darwin/quartz/apple/X11.icns b/hw/darwin/quartz/apple/X11.icns
new file mode 100644
index 0000000..d770e61
Binary files /dev/null and b/hw/darwin/quartz/apple/X11.icns differ
diff --git a/hw/darwin/quartz/apple/X11.xcodeproj/project.pbxproj b/hw/darwin/quartz/apple/X11.xcodeproj/project.pbxproj
new file mode 100644
index 0000000..225f371
--- /dev/null
+++ b/hw/darwin/quartz/apple/X11.xcodeproj/project.pbxproj
@@ -0,0 +1,344 @@
+// !$*UTF8*$!
+{
+	archiveVersion = 1;
+	classes = {
+	};
+	objectVersion = 42;
+	objects = {
+
+/* Begin PBXBuildFile section */
+		3F5E1BE00D04BF110020CA24 /* launcher-main.c in Sources */ = {isa = PBXBuildFile; fileRef = 3F5E1BDE0D04BF110020CA24 /* launcher-main.c */; };
+		3F5E1BE10D04BF110020CA24 /* server-main.c in Sources */ = {isa = PBXBuildFile; fileRef = 3F5E1BDF0D04BF110020CA24 /* server-main.c */; };
+		527F24190B5D938C007840A7 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0867D6AAFE840B52C02AAC07 /* InfoPlist.strings */; };
+		527F241A0B5D938C007840A7 /* main.nib in Resources */ = {isa = PBXBuildFile; fileRef = 02345980000FD03B11CA0E72 /* main.nib */; };
+		527F241B0B5D938C007840A7 /* X11.icns in Resources */ = {isa = PBXBuildFile; fileRef = 50459C5F038587C60ECA21EC /* X11.icns */; };
+		527F241D0B5D938C007840A7 /* bundle-main.c in Sources */ = {isa = PBXBuildFile; fileRef = 50EE2AB703849F0B0ECA21EC /* bundle-main.c */; };
+		527F241F0B5D938C007840A7 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50F4F0A7039D6ACA0E82C0CB /* CoreFoundation.framework */; };
+		527F24200B5D938C007840A7 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 570C5748047186C400ACF82F /* SystemConfiguration.framework */; };
+		527F24370B5D9D89007840A7 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 527F24260B5D938C007840A7 /* Info.plist */; };
+		52D9C0ED0BCDDF6B00CD2AFC /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 52D9C0EB0BCDDF6B00CD2AFC /* Localizable.strings */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+		0867D6ABFE840B52C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+		1870340FFE93FCAF11CA0CD7 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/main.nib; sourceTree = "<group>"; };
+		3F5E1BDE0D04BF110020CA24 /* launcher-main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "launcher-main.c"; sourceTree = "<group>"; };
+		3F5E1BDF0D04BF110020CA24 /* server-main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "server-main.c"; sourceTree = "<group>"; };
+		50459C5F038587C60ECA21EC /* X11.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = X11.icns; sourceTree = "<group>"; };
+		50EE2AB703849F0B0ECA21EC /* bundle-main.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = "bundle-main.c"; sourceTree = "<group>"; };
+		50F4F0A7039D6ACA0E82C0CB /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = "<absolute>"; };
+		527F24260B5D938C007840A7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = Info.plist; sourceTree = "<group>"; };
+		527F24270B5D938C007840A7 /* X11.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = X11.app; sourceTree = BUILT_PRODUCTS_DIR; };
+		52D9C0EC0BCDDF6B00CD2AFC /* English */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/Localizable.strings; sourceTree = "<group>"; };
+		570C5748047186C400ACF82F /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = /System/Library/Frameworks/SystemConfiguration.framework; sourceTree = "<absolute>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+		527F241E0B5D938C007840A7 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				527F241F0B5D938C007840A7 /* CoreFoundation.framework in Frameworks */,
+				527F24200B5D938C007840A7 /* SystemConfiguration.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+		195DF8CFFE9D517E11CA2CBB /* Products */ = {
+			isa = PBXGroup;
+			children = (
+				527F24270B5D938C007840A7 /* X11.app */,
+			);
+			name = Products;
+			sourceTree = "<group>";
+		};
+		20286C29FDCF999611CA2CEA /* X11 */ = {
+			isa = PBXGroup;
+			children = (
+				20286C2AFDCF999611CA2CEA /* Sources */,
+				20286C2CFDCF999611CA2CEA /* Resources */,
+				20286C32FDCF999611CA2CEA /* External Frameworks and Libraries */,
+				195DF8CFFE9D517E11CA2CBB /* Products */,
+				527F24260B5D938C007840A7 /* Info.plist */,
+			);
+			name = X11;
+			sourceTree = "<group>";
+		};
+		20286C2AFDCF999611CA2CEA /* Sources */ = {
+			isa = PBXGroup;
+			children = (
+				3F5E1BDE0D04BF110020CA24 /* launcher-main.c */,
+				3F5E1BDF0D04BF110020CA24 /* server-main.c */,
+				50EE2AB703849F0B0ECA21EC /* bundle-main.c */,
+			);
+			name = Sources;
+			sourceTree = "<group>";
+		};
+		20286C2CFDCF999611CA2CEA /* Resources */ = {
+			isa = PBXGroup;
+			children = (
+				52D9C0EB0BCDDF6B00CD2AFC /* Localizable.strings */,
+				50459C5F038587C60ECA21EC /* X11.icns */,
+				0867D6AAFE840B52C02AAC07 /* InfoPlist.strings */,
+				02345980000FD03B11CA0E72 /* main.nib */,
+			);
+			name = Resources;
+			sourceTree = "<group>";
+		};
+		20286C32FDCF999611CA2CEA /* External Frameworks and Libraries */ = {
+			isa = PBXGroup;
+			children = (
+				50F4F0A7039D6ACA0E82C0CB /* CoreFoundation.framework */,
+				570C5748047186C400ACF82F /* SystemConfiguration.framework */,
+			);
+			name = "External Frameworks and Libraries";
+			sourceTree = "<group>";
+		};
+/* End PBXGroup section */
+
+/* Begin PBXHeadersBuildPhase section */
+		527F24170B5D938C007840A7 /* Headers */ = {
+			isa = PBXHeadersBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXHeadersBuildPhase section */
+
+/* Begin PBXNativeTarget section */
+		527F24160B5D938C007840A7 /* X11 */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 527F24220B5D938C007840A7 /* Build configuration list for PBXNativeTarget "X11" */;
+			buildPhases = (
+				527F24170B5D938C007840A7 /* Headers */,
+				527F24180B5D938C007840A7 /* Resources */,
+				527F241C0B5D938C007840A7 /* Sources */,
+				527F241E0B5D938C007840A7 /* Frameworks */,
+				527F24210B5D938C007840A7 /* Rez */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = X11;
+			productName = X11;
+			productReference = 527F24270B5D938C007840A7 /* X11.app */;
+			productType = "com.apple.product-type.application";
+		};
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+		20286C28FDCF999611CA2CEA /* Project object */ = {
+			isa = PBXProject;
+			buildConfigurationList = 527F24080B5D8FFC007840A7 /* Build configuration list for PBXProject "X11" */;
+			compatibilityVersion = "Xcode 2.4";
+			hasScannedForEncodings = 1;
+			mainGroup = 20286C29FDCF999611CA2CEA /* X11 */;
+			projectDirPath = "";
+			projectRoot = "";
+			targets = (
+				527F24160B5D938C007840A7 /* X11 */,
+			);
+		};
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+		527F24180B5D938C007840A7 /* Resources */ = {
+			isa = PBXResourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				527F24370B5D9D89007840A7 /* Info.plist in Resources */,
+				527F24190B5D938C007840A7 /* InfoPlist.strings in Resources */,
+				527F241A0B5D938C007840A7 /* main.nib in Resources */,
+				527F241B0B5D938C007840A7 /* X11.icns in Resources */,
+				52D9C0ED0BCDDF6B00CD2AFC /* Localizable.strings in Resources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXRezBuildPhase section */
+		527F24210B5D938C007840A7 /* Rez */ = {
+			isa = PBXRezBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXRezBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+		527F241C0B5D938C007840A7 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				527F241D0B5D938C007840A7 /* bundle-main.c in Sources */,
+				3F5E1BE00D04BF110020CA24 /* launcher-main.c in Sources */,
+				3F5E1BE10D04BF110020CA24 /* server-main.c in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXVariantGroup section */
+		02345980000FD03B11CA0E72 /* main.nib */ = {
+			isa = PBXVariantGroup;
+			children = (
+				1870340FFE93FCAF11CA0CD7 /* English */,
+			);
+			name = main.nib;
+			sourceTree = "<group>";
+		};
+		0867D6AAFE840B52C02AAC07 /* InfoPlist.strings */ = {
+			isa = PBXVariantGroup;
+			children = (
+				0867D6ABFE840B52C02AAC07 /* English */,
+			);
+			name = InfoPlist.strings;
+			sourceTree = "<group>";
+		};
+		52D9C0EB0BCDDF6B00CD2AFC /* Localizable.strings */ = {
+			isa = PBXVariantGroup;
+			children = (
+				52D9C0EC0BCDDF6B00CD2AFC /* English */,
+			);
+			name = Localizable.strings;
+			sourceTree = "<group>";
+		};
+/* End PBXVariantGroup section */
+
+/* Begin XCBuildConfiguration section */
+		527F24090B5D8FFC007840A7 /* Development */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				INSTALL_MODE_FLAG = "a+rX";
+			};
+			name = Development;
+		};
+		527F240A0B5D8FFC007840A7 /* Deployment */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				INSTALL_MODE_FLAG = "a+rX";
+			};
+			name = Deployment;
+		};
+		527F240B0B5D8FFC007840A7 /* Default */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				INSTALL_MODE_FLAG = "a+rX";
+			};
+			name = Default;
+		};
+		527F24230B5D938C007840A7 /* Development */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				COPY_PHASE_STRIP = NO;
+				FRAMEWORK_SEARCH_PATHS = "";
+				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+				HEADER_SEARCH_PATHS = /usr/X11/include;
+				INFOPLIST_FILE = Info.plist;
+				INSTALL_PATH = /usr/X11;
+				LIBRARY_SEARCH_PATHS = /usr/X11/lib;
+				OTHER_CFLAGS = "";
+				OTHER_LDFLAGS = (
+					"-lXau",
+					"-lxcb",
+					"-lX11",
+				);
+				OTHER_REZFLAGS = "";
+				PRODUCT_NAME = X11;
+				SECTORDER_FLAGS = "";
+				WARNING_CFLAGS = (
+					"-Wmost",
+					"-Wno-four-char-constants",
+					"-Wno-unknown-pragmas",
+				);
+				WRAPPER_EXTENSION = app;
+			};
+			name = Development;
+		};
+		527F24240B5D938C007840A7 /* Deployment */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				COPY_PHASE_STRIP = YES;
+				FRAMEWORK_SEARCH_PATHS = "";
+				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+				HEADER_SEARCH_PATHS = /usr/X11/include;
+				INFOPLIST_FILE = Info.plist;
+				INSTALL_PATH = /usr/X11;
+				LIBRARY_SEARCH_PATHS = /usr/X11/lib;
+				OTHER_CFLAGS = "";
+				OTHER_LDFLAGS = (
+					"-lXau",
+					"-lxcb",
+					"-lX11",
+				);
+				OTHER_REZFLAGS = "";
+				PRODUCT_NAME = X11;
+				SECTORDER_FLAGS = "";
+				WARNING_CFLAGS = (
+					"-Wmost",
+					"-Wno-four-char-constants",
+					"-Wno-unknown-pragmas",
+				);
+				WRAPPER_EXTENSION = app;
+			};
+			name = Deployment;
+		};
+		527F24250B5D938C007840A7 /* Default */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				FRAMEWORK_SEARCH_PATHS = "";
+				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+				HEADER_SEARCH_PATHS = /usr/X11/include;
+				INFOPLIST_FILE = Info.plist;
+				INSTALL_PATH = /usr/X11;
+				LIBRARY_SEARCH_PATHS = /usr/X11/lib;
+				OTHER_CFLAGS = "";
+				OTHER_LDFLAGS = (
+					"-lXau",
+					"-lxcb",
+					"-lX11",
+				);
+				OTHER_REZFLAGS = "";
+				PRODUCT_NAME = X11;
+				SECTORDER_FLAGS = "";
+				WARNING_CFLAGS = (
+					"-Wmost",
+					"-Wno-four-char-constants",
+					"-Wno-unknown-pragmas",
+				);
+				WRAPPER_EXTENSION = app;
+			};
+			name = Default;
+		};
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+		527F24080B5D8FFC007840A7 /* Build configuration list for PBXProject "X11" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				527F24090B5D8FFC007840A7 /* Development */,
+				527F240A0B5D8FFC007840A7 /* Deployment */,
+				527F240B0B5D8FFC007840A7 /* Default */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Default;
+		};
+		527F24220B5D938C007840A7 /* Build configuration list for PBXNativeTarget "X11" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				527F24230B5D938C007840A7 /* Development */,
+				527F24240B5D938C007840A7 /* Deployment */,
+				527F24250B5D938C007840A7 /* Default */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Default;
+		};
+/* End XCConfigurationList section */
+	};
+	rootObject = 20286C28FDCF999611CA2CEA /* Project object */;
+}
diff --git a/hw/darwin/quartz/apple/bundle-main.c b/hw/darwin/quartz/apple/bundle-main.c
new file mode 100644
index 0000000..c436d51
--- /dev/null
+++ b/hw/darwin/quartz/apple/bundle-main.c
@@ -0,0 +1,82 @@
+/* main.c -- X application launcher
+ 
+ Copyright (c) 2007 Jeremy Huddleston
+ Copyright (c) 2007 Apple Inc
+ 
+ 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 <X11/Xlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+
+int launcher_main(int argc, char **argv);
+int server_main(int argc, char **argv);
+
+int main(int argc, char **argv) {
+    Display *display;
+  
+    fprintf(stderr, "X11.app: main(): argc=%d\n", argc);
+    int i;
+    for(i=0; i < argc; i++) {
+        fprintf(stderr, "\targv[%d] = %s\n", i, argv[i]);
+    }
+    
+    /* First check if launchd started us */
+    if(argc == 2 && !strncmp(argv[1], "--launchd", 9)) {
+        argc--;
+        argv[1] = argv[0];
+        argv++;
+        fprintf(stderr, "X11.app: main(): launchd called us, running server_main()");
+        return server_main(argc, argv);
+    }
+
+    /* If we have a process serial number and it's our only arg, act as if
+     * the user double clicked the app bundle: launch app_to_run if possible
+     */
+    if(argc == 1 || (argc == 2 && !strncmp(argv[1], "-psn_", 5))) {
+        /* Now, try to open a display, if so, run the launcher */
+        display = XOpenDisplay(NULL);
+        if(display) {
+            fprintf(stderr, "X11.app: main(): closing the display");
+            /* Could open the display, start the launcher */
+            XCloseDisplay(display);
+
+            /* Give 2 seconds for the server to start... 
+             * TODO: *Really* fix this race condition
+             */
+            usleep(2000);
+            fprintf(stderr, "X11.app: main(): running launcher_main()");
+            return launcher_main(argc, argv);
+        }
+    }
+
+    /* Couldn't open the display or we were called with arguments,
+     * just want to start a server.
+     */
+    fprintf(stderr, "X11.app: main(): running server_main()");
+    return server_main(argc, argv);
+}
diff --git a/hw/darwin/quartz/apple/launcher-main.c b/hw/darwin/quartz/apple/launcher-main.c
new file mode 100644
index 0000000..60a1624
--- /dev/null
+++ b/hw/darwin/quartz/apple/launcher-main.c
@@ -0,0 +1,81 @@
+/* main.c -- X application launcher
+ 
+ Copyright (c) 2007 Apple Inc.
+ 
+ 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 <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+#include <CoreFoundation/CoreFoundation.h>
+
+#define DEFAULT_APP "/usr/X11/bin/xterm"
+
+int launcher_main (int argc, char **argv) {
+  char *command = DEFAULT_APP;
+  const char *newargv[7];
+  int child;
+  
+
+	CFPropertyListRef PlistRef = CFPreferencesCopyAppValue(CFSTR("app_to_run"),
+									kCFPreferencesCurrentApplication);
+	
+	if ((PlistRef == NULL) || (CFGetTypeID(PlistRef) != CFStringGetTypeID())) {
+		CFPreferencesSetAppValue(CFSTR("app_to_run"), CFSTR(DEFAULT_APP), 
+								 kCFPreferencesCurrentApplication);
+		CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
+	} else {
+		int len = CFStringGetLength((CFStringRef)PlistRef)+1;
+		command = (char *) malloc(len);
+		CFStringGetCString((CFStringRef)PlistRef, command, len,  kCFStringEncodingASCII);
+		fprintf(stderr, "command=%s\n", command);
+	}
+	
+	if (PlistRef) CFRelease(PlistRef);
+	
+	newargv[0] = "/usr/bin/login";
+	newargv[1] = "-fp";
+	newargv[2] = getlogin();
+	newargv[3] = "/bin/sh";
+	newargv[4] = "-c";
+	newargv[5] = command;
+	newargv[6] = NULL;
+
+    child = fork();
+	
+    switch (child) {
+    case -1:				/* error */
+      perror ("fork");
+      return EXIT_FAILURE;		
+    case 0:				    /* child */
+      execvp (newargv[0], (char **const) newargv);
+      perror ("Couldn't exec");
+      _exit (1);
+   }
+	
+    return 0;
+}
diff --git a/hw/darwin/quartz/apple/org.x.X11.plist b/hw/darwin/quartz/apple/org.x.X11.plist
new file mode 100644
index 0000000..6c6be91
--- /dev/null
+++ b/hw/darwin/quartz/apple/org.x.X11.plist
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>Label</key>
+		<string>org.x.X11</string>
+	<key>Program</key>
+		<string>/Applications/Utilities/X11.app/Contents/MacOS/X11</string>
+	<key>ProgramArguments</key>
+		<array>
+		<string>/Applications/Utilities/X11.app/Contents/MacOS/X11</string>
+		<string>--launchd</string>
+		</array>
+	<key>Sockets</key>
+		<dict>
+		<key>:0</key>
+			<dict>
+			<key>SecureSocketWithKey</key>
+				<string>DISPLAY</string>
+			</dict>
+		</dict>
+	<key>ServiceIPC</key>
+		<true/>
+</dict>
+</plist>
diff --git a/hw/darwin/quartz/apple/server-main.c b/hw/darwin/quartz/apple/server-main.c
new file mode 100644
index 0000000..26fcbb0
--- /dev/null
+++ b/hw/darwin/quartz/apple/server-main.c
@@ -0,0 +1,904 @@
+/* bundle-main.c -- X server launcher
+ 
+ Copyright (c) 2002-2007 Apple Inc. 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 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.
+ 
+ Parts of this file are derived from xdm, which has this copyright:
+ 
+ Copyright 1988, 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. */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <sys/utsname.h>
+#include <ifaddrs.h>
+#include <netdb.h>
+#include <netinet/in.h>
+#include <time.h>
+#include <sys/wait.h>
+#include <setjmp.h>
+#include <sys/ioctl.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xauth.h>
+#include <xcb/xcb.h>
+
+#include <CoreFoundation/CoreFoundation.h>
+#include <SystemConfiguration/SystemConfiguration.h>
+
+#define X_SERVER "/usr/X11/bin/Xquartz"
+#define XTERM_PATH "/usr/X11/bin/xterm"
+#define WM_PATH "/usr/bin/quartz-wm"
+#define DEFAULT_XINITRC "/usr/X11/lib/X11/xinit/xinitrc"
+#define DEFAULT_PATH "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11/bin"
+
+/* what xinit does */
+#ifndef SHELL
+# define SHELL "sh"
+#endif
+
+#undef FALSE
+#define FALSE 0
+#undef TRUE
+#define TRUE 1
+
+#define MAX_DISPLAYS 64
+
+static int server_pid = -1, client_pid = -1;
+static int xinit_kills_server = FALSE;
+static jmp_buf exit_continuation;
+static const char *server_name = NULL;
+static Display *server_dpy;
+
+static char *auth_file;
+
+typedef struct addr_list_struct addr_list;
+
+struct addr_list_struct {
+    addr_list *next;
+    Xauth auth;
+};
+
+static addr_list *addresses;
+
+
+/* Utility functions. */
+
+/* Return the current host name. Matches what Xlib does. */
+static char *
+host_name (void)
+{
+#ifdef NEED_UTSNAME
+    static struct utsname name;
+	
+    uname(&name);
+	
+    return name.nodename;
+#else
+    static char buf[100];
+	
+    gethostname(buf, sizeof(buf));
+	
+    return buf;
+#endif
+}
+
+static int
+read_boolean_pref (CFStringRef name, int default_)
+{
+    int value;
+    Boolean ok;
+	
+    value = CFPreferencesGetAppBooleanValue (name,
+											 CFSTR ("com.apple.x11"), &ok);
+    return ok ? value : default_;
+}
+
+static inline int
+binary_equal (const void *a, const void *b, int length)
+{
+    return memcmp (a, b, length) == 0;
+}
+
+static inline void *
+binary_dup (const void *a, int length)
+{
+    void *b = malloc (length);
+    if (b != NULL)
+		memcpy (b, a, length);
+    return b;
+}
+
+static inline void
+binary_free (void *data, int length)
+{
+    if (data != NULL)
+		free (data);
+}
+
+
+/* Functions for managing the authentication entries. */
+
+/* Returns true if something matching AUTH is in our list of auth items */
+static int
+check_auth_item (Xauth *auth)
+{
+    addr_list *a;
+	
+    for (a = addresses; a != NULL; a = a->next)
+    {
+		if (a->auth.family == auth->family
+			&& a->auth.address_length == auth->address_length
+			&& binary_equal (a->auth.address, auth->address, auth->address_length)
+			&& a->auth.number_length == auth->number_length
+			&& binary_equal (a->auth.number, auth->number, auth->number_length)
+			&& a->auth.name_length == auth->name_length
+			&& binary_equal (a->auth.name, auth->name, auth->name_length))
+		{
+			return TRUE;
+		}
+    }
+	
+    return FALSE;
+}
+
+/* Add one item to our list of auth items. */
+static void
+add_auth_item (Xauth *auth)
+{
+    addr_list *a = malloc (sizeof (addr_list));
+	
+    a->auth.family = auth->family;
+    a->auth.address_length = auth->address_length;
+    a->auth.address = binary_dup (auth->address, auth->address_length);
+    a->auth.number_length = auth->number_length;
+    a->auth.number = binary_dup (auth->number, auth->number_length);
+    a->auth.name_length = auth->name_length;
+    a->auth.name = binary_dup (auth->name, auth->name_length);
+    a->auth.data_length = auth->data_length;
+    a->auth.data = binary_dup (auth->data, auth->data_length);
+	
+    a->next = addresses;
+    addresses = a;
+}
+
+/* Free all allocated auth items. */
+static void
+free_auth_items (void)
+{
+    addr_list *a;
+	
+    while ((a = addresses) != NULL)
+    {
+		addresses = a->next;
+		
+		binary_free (a->auth.address, a->auth.address_length);
+		binary_free (a->auth.number, a->auth.number_length);
+		binary_free (a->auth.name, a->auth.name_length);
+		binary_free (a->auth.data, a->auth.data_length);
+		free (a);
+    }
+}
+
+/* Add the unix domain auth item. */
+static void
+define_local (Xauth *auth)
+{
+    char *host = host_name ();
+	
+#ifdef DEBUG
+    fprintf (stderr, "x11: hostname is %s\n", host);
+#endif
+	
+    auth->family = FamilyLocal;
+    auth->address_length = strlen (host);
+    auth->address = host;
+	
+    add_auth_item (auth);
+}
+
+/* Add the tcp auth item. */
+static void
+define_named (Xauth *auth, const char *name)
+{
+    struct ifaddrs *addrs, *ptr;
+	
+    if (getifaddrs (&addrs) != 0)
+		return;
+	
+    for (ptr = addrs; ptr != NULL; ptr = ptr->ifa_next)
+    {
+		if (ptr->ifa_addr->sa_family != AF_INET)
+			continue;
+		
+		auth->family = FamilyInternet;
+		auth->address_length = sizeof (struct in_addr);
+		auth->address = (char *) &(((struct sockaddr_in *) ptr->ifa_addr)->sin_addr);
+		
+#ifdef DEBUG
+		fprintf (stderr, "x11: ipaddr is %d.%d.%d.%d\n",
+				 (unsigned char) auth->address[0],
+				 (unsigned char) auth->address[1],
+				 (unsigned char) auth->address[2],
+				 (unsigned char) auth->address[3]);
+#endif
+		
+		add_auth_item (auth);
+    }
+	
+    freeifaddrs (addrs);
+}
+
+/* Parse the display number from NAME and add it to AUTH. */
+static void
+set_auth_number (Xauth *auth, const char *name)
+{
+    char *colon;
+    char *dot, *number;
+	
+    colon = strrchr(name, ':');
+    if (colon != NULL)
+    {
+		colon++;
+		dot = strchr(colon, '.');
+		
+		if (dot != NULL)
+			auth->number_length = dot - colon;
+		else
+			auth->number_length = strlen (colon);
+		
+		number = malloc (auth->number_length + 1);
+		if (number != NULL)
+		{
+			strncpy (number, colon, auth->number_length);
+			number[auth->number_length] = '\0';
+		}
+		else
+		{
+			auth->number_length = 0;
+		}
+		
+		auth->number = number;
+    }
+}
+
+/* Put 128 bits of random data into DATA. If possible, it will be "high
+ quality" */
+static int
+generate_mit_magic_cookie (char data[16])
+{
+    int fd, ret, i;
+    long *ldata = (long *) data;
+	
+    fd = open ("/dev/random", O_RDONLY);
+    if (fd > 0) {
+		ret = read (fd, data, 16);
+		close (fd);
+		if (ret == 16) return TRUE;
+    }
+	
+    /* fall back to the usual crappy rng */
+	
+    srand48 (getpid () ^ time (NULL));
+	
+    for (i = 0; i < 4; i++)
+		ldata[i] = lrand48 ();
+	
+    return TRUE;
+}
+
+/* Create the keys we'll be using for the display named NAME. */
+static int
+make_auth_keys (const char *name)
+{
+    Xauth auth;
+    char key[16];
+	
+    if (auth_file == NULL)
+		return FALSE;
+	
+    auth.name = "MIT-MAGIC-COOKIE-1";
+    auth.name_length = strlen (auth.name);
+	
+    if (!generate_mit_magic_cookie (key))
+    {
+		auth_file = NULL;
+		return FALSE;
+    }
+	
+    auth.data = key;
+    auth.data_length = 16;
+	
+    set_auth_number (&auth, name);
+	
+    define_named (&auth, host_name ());
+    define_local (&auth);
+	
+    free (auth.number);
+	
+    return TRUE;
+}
+
+/* If ADD-ENTRIES is true, merge our auth entries into the existing
+ Xauthority file. If ADD-ENTRIES is false, remove our entries. */
+static int
+write_auth_file (int add_entries)
+{
+    char *home, newname[1024];
+    int fd, ret;
+    FILE *new_fh, *old_fh;
+    addr_list *addr;
+    Xauth *auth;
+	
+    if (auth_file == NULL)
+		return FALSE;
+	
+    home = getenv ("HOME");
+    if (home == NULL)
+    {
+		auth_file = NULL;
+		return FALSE;
+    }
+	
+    snprintf (newname, sizeof (newname), "%s/.XauthorityXXXXXX", home);
+    mktemp (newname);
+	
+    if (XauLockAuth (auth_file, 1, 2, 10) != LOCK_SUCCESS)
+    {
+		/* FIXME: do something here? */
+		
+		auth_file = NULL;
+		return FALSE;
+    }
+	
+    fd = open (newname, O_WRONLY | O_CREAT | O_TRUNC, 0600);
+    if (fd >= 0)
+    {
+		new_fh = fdopen (fd, "w");
+		if (new_fh != NULL)
+		{
+			if (add_entries)
+			{
+				for (addr = addresses; addr != NULL; addr = addr->next)
+				{
+					XauWriteAuth (new_fh, &addr->auth);
+				}
+			}
+			
+			old_fh = fopen (auth_file, "r");
+			if (old_fh != NULL)
+			{
+				while ((auth = XauReadAuth (old_fh)) != NULL)
+				{
+					if (!check_auth_item (auth))
+						XauWriteAuth (new_fh, auth);
+					XauDisposeAuth (auth);
+				}
+				fclose (old_fh);
+			}
+			
+			fclose (new_fh);
+			unlink (auth_file);
+			
+			ret = rename (newname, auth_file);
+			
+			if (ret != 0)
+				auth_file = NULL;
+			
+			XauUnlockAuth (auth_file);
+			return ret == 0;
+		}
+		
+		close (fd);
+    }
+	
+    XauUnlockAuth (auth_file);
+    auth_file = NULL;
+    return FALSE;
+}
+
+
+/* Subprocess management functions. */
+
+static int
+start_server (char **xargv)
+{
+    int child;
+	
+    child = fork ();
+	
+    switch (child)
+    {
+    case -1:				/* error */
+		perror ("fork");
+		return FALSE;
+		
+    case 0:				/* child */
+		execv (X_SERVER, xargv);
+		perror ("Couldn't exec " X_SERVER);
+		_exit (1);
+		
+    default:				/* parent */
+		server_pid = child;
+		return TRUE;
+    }
+}
+
+static int
+wait_for_server (void)
+{
+    int count = 100;
+	
+    while (count-- > 0)
+    {
+		int status;
+		
+		server_dpy = XOpenDisplay (server_name);
+		if (server_dpy != NULL)
+			return TRUE;
+		
+		if (waitpid (server_pid, &status, WNOHANG) == server_pid)
+			return FALSE;
+		
+		sleep (1);
+    }
+	
+    return FALSE;
+}
+
+static int
+start_client (void)
+{
+    int child;
+	
+    child = fork();
+	
+    switch (child) {
+		char *temp, buf[1024];		
+
+	case -1:				/* error */
+		perror("fork");
+		return FALSE;
+
+	case 0:					/* child */
+		/* Setup environment */
+		temp = getenv("DISPLAY");
+//		if (temp == NULL && temp[0] != 0)
+			setenv("DISPLAY", server_name, TRUE);
+
+		temp = getenv("PATH");
+		if (temp == NULL || temp[0] == 0) 
+			setenv ("PATH", DEFAULT_PATH, TRUE);
+		else if (strnstr(temp, "/usr/X11/bin", sizeof(temp)) == NULL) {
+			snprintf(buf, sizeof(buf), "%s:/usr/X11/bin", temp);		
+			setenv("PATH", buf, TRUE);	
+		}
+		
+		/* First try value of $XINITRC, if set. */
+		temp = getenv("XINITRC");
+		if (temp != NULL && temp[0] != 0 && access(temp, R_OK) == 0)
+			execlp (SHELL, SHELL, temp, NULL);
+
+		/* Then look for .xinitrc in user's home directory. */
+		temp = getenv("HOME");
+		if (temp != NULL && temp[0] != 0) {
+			chdir(temp);
+			snprintf (buf, sizeof (buf), "%s/.xinitrc", temp);
+			if (access(buf, R_OK) == 0)
+				execlp(SHELL, SHELL, buf, NULL);
+		}
+		
+		/* Then try the default xinitrc in the lib directory. */
+		
+		if (access(DEFAULT_XINITRC, R_OK) == 0)
+			execlp(SHELL, SHELL, DEFAULT_XINITRC, NULL);
+		
+		/* Then fallback to hardcoding an xterm and the window manager. */
+		
+		//		system(XTERM_PATH " &");
+		execl(WM_PATH, WM_PATH, NULL);
+		
+		perror("exec");
+		_exit(1);
+		
+    default:				/* parent */
+		client_pid = child;
+		return TRUE;
+    }
+}
+
+static void
+sigchld_handler (int sig)
+{
+    int pid, status;
+	
+	again:
+    pid = waitpid (WAIT_ANY, &status, WNOHANG);
+	
+    if (pid > 0)
+    {
+		if (pid == server_pid)
+		{
+			server_pid = -1;
+			
+			if (client_pid >= 0)
+				kill (client_pid, SIGTERM);
+		}
+		else if (pid == client_pid)
+		{
+			client_pid = -1;
+			
+			if (server_pid >= 0 && xinit_kills_server)
+				kill (server_pid, SIGTERM);
+		}
+		goto again;
+    }
+	
+    if (server_pid == -1 && client_pid == -1)
+		longjmp (exit_continuation, 1);
+	
+    signal (SIGCHLD, sigchld_handler);
+}
+
+
+/* Server utilities. */
+
+static Boolean
+display_exists_p (int number)
+{
+    char buf[64];
+    xcb_connection_t *conn;
+    char *fullname = NULL;
+    int idisplay, iscreen;
+    char *conn_auth_name, *conn_auth_data;
+    int conn_auth_namelen, conn_auth_datalen;
+    
+    //    extern void *_X11TransConnectDisplay ();
+    //    extern void _XDisconnectDisplay ();
+	
+    /* Since connecting to the display waits for a few seconds if the
+	 display doesn't exist, check for trivial non-existence - if the
+	 socket in /tmp exists or not.. (note: if the socket exists, the
+	 server may still not, so we need to try to connect in that case..) */
+	
+    sprintf (buf, "/tmp/.X11-unix/X%d", number);
+    if (access (buf, F_OK) != 0)
+		return FALSE;
+    
+    sprintf (buf, ":%d", number);
+    conn = xcb_connect(buf, NULL);
+    if (xcb_connection_has_error(conn)) return FALSE;
+	
+    xcb_disconnect(conn);
+    return TRUE;
+}
+
+
+/* Monitoring when the system's ip addresses change. */
+
+static Boolean pending_timer;
+
+static void
+timer_callback (CFRunLoopTimerRef timer, void *info)
+{
+    pending_timer = FALSE;
+	
+    /* Update authentication names. Need to write .Xauthority file first
+	 without the existing entries, then again with the new entries.. */
+	
+    write_auth_file (FALSE);
+	
+    free_auth_items ();
+    make_auth_keys (server_name);
+	
+    write_auth_file (TRUE);
+}
+
+/* This function is called when the system's ip addresses may have changed. */
+static void
+ipaddr_callback (SCDynamicStoreRef store, CFArrayRef changed_keys, void *info)
+{
+#if DEBUG
+    if (changed_keys != NULL) {
+		fprintf (stderr, "x11: changed sc keys: ");
+		CFShow (changed_keys);
+    }
+#endif
+
+    if (auth_file != NULL && !pending_timer)
+    {
+		CFRunLoopTimerRef timer;
+		
+		timer = CFRunLoopTimerCreate (NULL, CFAbsoluteTimeGetCurrent () + 1.0,
+									  0.0, 0, 0, timer_callback, NULL);
+		CFRunLoopAddTimer (CFRunLoopGetCurrent (), timer,
+						   kCFRunLoopDefaultMode);
+		CFRelease (timer);
+		
+		pending_timer = TRUE;
+    }
+}
+
+/* This code adapted from "Living in a Dynamic TCP/IP Environment" technote. */
+static Boolean
+install_ipaddr_source (void)
+{
+    CFRunLoopSourceRef source = NULL;
+	
+    SCDynamicStoreContext context = {0};
+    SCDynamicStoreRef ref;
+	
+    ref = SCDynamicStoreCreate (NULL,
+								CFSTR ("AddIPAddressListChangeCallbackSCF"),
+								ipaddr_callback, &context);
+	
+    if (ref != NULL)
+    {
+		const void *keys[4], *patterns[2];
+		int i;
+		
+		keys[0] = SCDynamicStoreKeyCreateNetworkGlobalEntity (NULL, kSCDynamicStoreDomainState, kSCEntNetIPv4);
+		keys[1] = SCDynamicStoreKeyCreateNetworkGlobalEntity (NULL, kSCDynamicStoreDomainState, kSCEntNetIPv6);
+		keys[2] = SCDynamicStoreKeyCreateComputerName (NULL);
+		keys[3] = SCDynamicStoreKeyCreateHostNames (NULL);
+		
+		patterns[0] = SCDynamicStoreKeyCreateNetworkInterfaceEntity (NULL, kSCDynamicStoreDomainState, kSCCompAnyRegex, kSCEntNetIPv4);
+		patterns[1] = SCDynamicStoreKeyCreateNetworkInterfaceEntity (NULL, kSCDynamicStoreDomainState, kSCCompAnyRegex, kSCEntNetIPv6);
+		
+		if (keys[0] != NULL && keys[1] != NULL && keys[2] != NULL
+			&& keys[3] != NULL && patterns[0] != NULL && patterns[1] != NULL)
+		{
+			CFArrayRef key_array, pattern_array;
+			
+			key_array = CFArrayCreate (NULL, keys, 4, &kCFTypeArrayCallBacks);
+			pattern_array = CFArrayCreate (NULL, patterns, 2, &kCFTypeArrayCallBacks);
+			
+			if (key_array != NULL || pattern_array != NULL)
+			{
+				SCDynamicStoreSetNotificationKeys (ref, key_array, pattern_array);
+				source = SCDynamicStoreCreateRunLoopSource (NULL, ref, 0);
+			}
+			
+			if (key_array != NULL)
+				CFRelease (key_array);
+			if (pattern_array != NULL)
+				CFRelease (pattern_array);
+		}
+		
+		
+		for (i = 0; i < 4; i++)
+			if (keys[i] != NULL)
+			CFRelease (keys[i]);
+		for (i = 0; i < 2; i++)
+			if (patterns[i] != NULL)
+			CFRelease (patterns[i]);
+		
+		CFRelease (ref); 
+    }
+	
+    if (source != NULL)
+    {
+		CFRunLoopAddSource (CFRunLoopGetCurrent (),
+							source, kCFRunLoopDefaultMode);
+		CFRelease (source);
+    }
+	
+    return source != NULL;
+}
+
+
+/* Entrypoint. */
+
+void
+termination_signal_handler (int unused_sig)
+{
+    signal (SIGTERM, SIG_DFL);
+    signal (SIGHUP, SIG_DFL);
+    signal (SIGINT, SIG_DFL);
+    signal (SIGQUIT, SIG_DFL);
+
+    longjmp (exit_continuation, 1);
+}
+
+int
+server_main (int argc, char **argv)
+{
+    char **xargv;
+    int i, j;
+    int fd;
+	
+    xargv = alloca (sizeof (char *) * (argc + 32));
+	
+    if (!read_boolean_pref (CFSTR ("no_auth"), FALSE))
+		auth_file = XauFileName ();
+	
+    /* The standard X11 behaviour is for the server to quit when the first
+	 client exits. But it can be useful for debugging (and to mimic our
+	 behaviour in the beta releases) to not do that. */
+	
+    xinit_kills_server = read_boolean_pref (CFSTR ("xinit_kills_server"), TRUE);
+	
+    for (i = 1; i < argc; i++)
+    {
+		if (argv[i][0] == ':')
+			server_name = argv[i];
+    }
+	
+    if (server_name == NULL)
+    {
+		static char name[8];
+		
+		/* No display number specified, so search for the first unused.
+		 
+		 There's a big old race condition here if two servers start at
+		 the same time, but that's fairly unlikely. We could create
+		 lockfiles or something, but that's seems more likely to cause
+		 problems than the race condition itself.. */
+		
+		for (i = 0; i < MAX_DISPLAYS; i++)
+		{
+			if (!display_exists_p (i))
+				break;
+		}
+		
+		if (i == MAX_DISPLAYS)
+		{
+			fprintf (stderr, "%s: couldn't allocate a display number", argv[0]);
+			exit (1);
+		}
+		
+		sprintf (name, ":%d", i);
+		server_name = name;
+    }
+	
+    if (auth_file != NULL)
+    {
+		/* Create new Xauth keys and add them to the .Xauthority file */
+		
+		make_auth_keys (server_name);
+		write_auth_file (TRUE);
+    }
+	
+    /* Construct our new argv */
+	
+    i = j = 0;
+	
+    xargv[i++] = argv[j++];
+	
+    if (auth_file != NULL)
+    {
+		xargv[i++] = "-auth";
+		xargv[i++] = auth_file;
+    }
+	
+    /* By default, don't listen on tcp sockets if Xauth is disabled. */
+	
+    if (read_boolean_pref (CFSTR ("nolisten_tcp"), auth_file == NULL))
+    {
+		xargv[i++] = "-nolisten";
+		xargv[i++] = "tcp";
+    }
+	
+    while (j < argc)
+    {
+		if (argv[j++][0] != ':')
+			xargv[i++] = argv[j-1];
+    }
+	
+    xargv[i++] = (char *) server_name;
+    xargv[i++] = NULL;
+	
+    /* Detach from any controlling terminal and connect stdin to /dev/null */
+	
+#ifdef TIOCNOTTY
+    fd = open ("/dev/tty", O_RDONLY);
+    if (fd != -1)
+    {
+		ioctl (fd, TIOCNOTTY, 0);
+		close (fd);
+    }
+#endif
+	
+    fd = open ("/dev/null", O_RDWR, 0);
+    if (fd >= 0)
+    {
+		dup2 (fd, 0);
+		if (fd > 0)
+			close (fd);
+    }
+	
+    if (!start_server (xargv))
+		return 1;
+	
+    if (!wait_for_server ())
+    {
+		kill (server_pid, SIGTERM);
+		return 1;
+    }
+	
+    if (!start_client ())
+    {
+		kill (server_pid, SIGTERM);
+		return 1;
+    }
+	
+    signal (SIGCHLD, sigchld_handler);
+	
+    signal (SIGTERM, termination_signal_handler);
+    signal (SIGHUP, termination_signal_handler);
+    signal (SIGINT, termination_signal_handler);
+    signal (SIGQUIT, termination_signal_handler);
+
+    if (setjmp (exit_continuation) == 0)
+    {
+		if (install_ipaddr_source ())
+			CFRunLoopRun ();
+		else
+			while (1) pause ();
+    }
+	
+    signal (SIGCHLD, SIG_IGN);
+
+    if (client_pid >= 0) kill (client_pid, SIGTERM);
+    if (server_pid >= 0) kill (server_pid, SIGTERM);
+	
+    if (auth_file != NULL)
+    {
+		/* Remove our Xauth keys */
+		
+		write_auth_file (FALSE);
+    }
+	
+    free_auth_items ();
+	
+    return 0;
+}
diff --git a/hw/darwin/quartz/xpr/Makefile.am b/hw/darwin/quartz/xpr/Makefile.am
index 8980ad7..7696622 100644
--- a/hw/darwin/quartz/xpr/Makefile.am
+++ b/hw/darwin/quartz/xpr/Makefile.am
@@ -1,12 +1,16 @@
-noinst_LIBRARIES = libxpr.a
+bin_PROGRAMS = Xquartz
+
+# TODO: This man page needs sed magic and cleanup
+man1_MANS = Xquartz.man
+
 AM_CFLAGS =  $(XSERVER_CFLAGS) $(DIX_CFLAGS)
 AM_CPPFLAGS = \
-	   -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../.. \
-	   -I$(top_srcdir)/miext \
-	   -I$(top_srcdir)/miext/rootless \
-	   -I$(top_srcdir)/miext/rootless/safeAlpha
+	-I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../.. \
+	-I$(top_srcdir)/miext \
+	-I$(top_srcdir)/miext/rootless \
+	-I$(top_srcdir)/miext/rootless/safeAlpha
 
-libxpr_a_SOURCES = \
+Xquartz_SOURCES = \
 	appledri.c \
 	dri.c \
 	xprAppleWM.c \
@@ -17,7 +21,45 @@ libxpr_a_SOURCES = \
 	x-hook.c \
 	x-list.c
 
+Xquartz_LDADD = \
+	$(top_builddir)/hw/darwin/quartz/libXquartz.la \
+	$(top_builddir)/hw/darwin/libXdarwin.la \
+	$(top_builddir)/dix/dixfonts.lo \
+	$(top_builddir)/dix/libdix.la \
+	$(top_builddir)/os/libos.la \
+	$(top_builddir)/dix/libxpstubs.la \
+	$(top_builddir)/miext/shadow/libshadow.la \
+	$(top_builddir)/fb/libfb.la \
+	$(top_builddir)/mi/libmi.la \
+	$(top_builddir)/composite/libcomposite.la \
+	$(top_builddir)/damageext/libdamageext.la \
+	$(top_builddir)/miext/damage/libdamage.la \
+	$(top_builddir)/xfixes/libxfixes.la \
+	$(top_builddir)/miext/cw/libcw.la \
+	$(top_builddir)/Xext/libXext.la \
+	$(top_builddir)/xkb/libxkb.la \
+	$(top_builddir)/xkb/libxkbstubs.la \
+	$(top_builddir)/Xi/libXi.la \
+	$(top_builddir)/dbe/libdbe.la \
+	$(top_builddir)/record/librecord.la \
+	$(top_builddir)/XTrap/libxtrap.la \
+	$(top_builddir)/miext/rootless/librootless.la \
+	$(top_builddir)/miext/rootless/safeAlpha/libsafeAlpha.la \
+	$(top_builddir)/miext/rootless/accel/librlAccel.la \
+	$(DARWIN_LIBS) $(XSERVER_LIBS) $(XSERVER_SYS_LIBS) -lXplugin
+
+Xquartz_LDFLAGS =  \
+	-XCClinker -Objc \
+	-Wl,-u,_miDCInitialize \
+	-Wl,-framework,Carbon \
+	-L/System/Library/Frameworks/OpenGL.framework/Libraries -lGL \
+	-Wl,-framework,OpenGL \
+	-Wl,-framework,Cocoa \
+	-Wl,-framework,CoreAudio \
+	-Wl,-framework,IOKit
+
 EXTRA_DIST = \
+	Xquartz.man \
 	dri.h \
 	dristruct.h \
 	appledri.h \
diff --git a/hw/darwin/quartz/xpr/Xquartz.man b/hw/darwin/quartz/xpr/Xquartz.man
new file mode 100644
index 0000000..37a7f1a
--- /dev/null
+++ b/hw/darwin/quartz/xpr/Xquartz.man
@@ -0,0 +1,156 @@
+.TH XQUARTZ 1 __vendorversion__
+.SH NAME
+Xquartz \- X window system server for Quartz operating system
+.SH SYNOPSIS
+.B Xquartz
+[ options ] ...
+.SH DESCRIPTION
+.I Xquartz
+is the X window server for Mac OS X provided by Apple.
+.I Xquartz
+runs in parallel with Aqua in rootless mode. In rootless mode, the X
+window system and Mac OS X share your display.  The root window of the
+X11 display is the size of the screen and contains all the other
+windows. The X11 root window is not displayed in rootless mode as Mac
+OS X handles the desktop background.
+.SH OPTIONS
+.PP
+In addition to the normal server options described in the \fIXserver(1)\fP
+manual page, \fIXquartz\fP accepts the following command line switches:
+.TP 8
+.B \-fakebuttons
+Emulates a 3 button mouse using modifier keys. By default, the Command modifier
+is used to emulate button 2 and Option is used for button 3. Thus, clicking the
+first mouse button while holding down Command will act like clicking
+button 2. Holding down Option will simulate button 3.
+.TP 8
+.B \-nofakebuttons
+Do not emulate a 3 button mouse. This is the default.
+.TP 8
+.B "\-fakemouse2 \fImodifiers\fP"
+Change the modifier keys used to emulate the second mouse button. By default,
+Command is used to emulate the second button. Any combination of the following
+modifier names may be used: Shift, Option, Control, Command, Fn. For example,
+.B \-fakemouse2 """Option,Shift""
+will set holding Option, Shift and clicking on button one as equivalent to
+clicking the second mouse button.
+.TP 8
+.B "\-fakemouse3 \fImodifiers\fP"
+Change the modifier keys used to emulate the third mouse button. By default,
+Option is used to emulate the third button. Any combination of the following
+modifier names may be used: Shift, Option, Control, Command, Fn. For example,
+.B \-fakemouse3 """Control,Shift""
+will set holding Control, Shift and clicking on button one as equivalent to
+clicking the third mouse button.
+.TP 8
+.B "\-swapAltMeta"
+Swaps the meaning of the Alt and Meta modifier keys.
+.TP 8
+.B "\-keymap \fIfile\fP"
+On startup \fIXquartz\fP translates a Darwin keymapping into an X keymap.
+The default is to read this keymapping from USA.keymapping. With this option
+the keymapping will be read from \fIfile\fP instead. If the file's path is
+not specified, it will be searched for in Library/Keyboards/ underneath the
+following directories (in order): ~, /, /Network, /System.
+.TP 8
+.B \-nokeymap
+On startup \fIXquartz\fP translates a Darwin keymapping into an X keymap.
+With this option \fIXquartz\fP queries the kernel for the current keymapping
+instead of reading it from a file. This will often fail on newer kernels.
+.TP 8
+.B "\-depth \fIdepth\fP"
+Specifies the color bit depth to use. Currently only 15, and 24 color
+bits per pixel are supported. If not specified, defaults to the depth
+of the main display.
+.SH CUSTOMIZATION
+\fIXquartz\fP can also be customized using the defaults(1) command. The available options are:
+.TP 8
+.B defaults write com.apple.x11 enable_fake_buttons -boolean true
+Equivalent to the \fB-fakebuttons\fP command line option.
+.TP 8
+.B defaults write com.apple.x11 fake_button2 \fImodifiers\fP
+Equivalent to the \fB-fakemouse2\fP option.
+.TP 8
+.B defaults write com.apple.x11 fake_button3 \fImodifiers\fP
+Equivalent to the \fB-fakemouse3\fP option.
+.TP 8
+.B defaults write com.apple.x11 swap_alt_meta -boolean true
+Equivalent to the \fB-swapAltMeta\fP option.
+.TP 8
+.B defaults write com.apple.x11 keymap_file \fIfilename\fP
+Equivalent to the \fB-keymap\fP option.
+.TP 8
+.B defaults write com.apple.x11 no_quit_alert -boolean true
+Disables the alert dialog displayed when attempting to quit X11.
+.TP 8
+.B defaults write com.apple.x11 no_auth -boolean true
+Stops the X server requiring that clients authenticate themselves when
+connecting. See Xsecurity(__miscmansuffix__).
+.TP 8
+.B defaults write com.apple.x11 nolisten_tcp -boolean true
+Prevents the X server accepting remote connections.
+.TP 8
+.B defaults write com.apple.x11 xinit_kills_server -boolean false
+Stops the X server exiting when the xinitrc script terminates.
+.TP 8
+.B defaults write com.apple.x11 fullscreen_hotkeys -boolean false
+Allows system hotkeys to be handled while in X11 fullscreen mode.
+.TP 8
+.B defaults write com.apple.x11 enable_system_beep -boolean false
+Don't use the standard system beep effect for X11 alerts.
+.TP 8
+.B defaults write com.apple.x11 enable_key_equivalents -boolean false
+Disable menu keyboard equivalents while X11 windows are focused.
+.TP 8
+.B defaults write com.apple.x11 depth \fIdepth\fP
+Equivalent to the \fB-depth\fP option.
+.SH "SEE ALSO"
+.PP
+X(__miscmansuffix__), XFree86(1), Xserver(1), xdm(1), xinit(1)
+.PP
+.SH AUTHORS
+XFree86 was originally ported to Mac OS X Server by John Carmack. Dave
+Zarzycki used this as the basis of his port of XFree86 4.0 to Darwin 1.0.
+Torrey T. Lyons improved and integrated this code into the XFree86
+Project's mainline for the 4.0.2 release.
+.PP
+The following members of the XonX Team contributed to the following
+releases (in alphabetical order):
+.TP 4
+XFree86 4.1.0:
+.br
+Rob Braun - Darwin x86 support
+.br
+Torrey T. Lyons - Project Lead
+.br
+Andreas Monitzer - Cocoa version of XDarwin front end
+.br
+Gregory Robert Parker - Original Quartz implementation
+.br
+Christoph Pfisterer - Dynamic shared X libraries
+.br
+Toshimitsu Tanaka - Japanese localization
+.TP 4
+XFree86 4.2.0:
+.br
+Rob Braun - Darwin x86 support
+.br
+Pablo Di Noto - Spanish localization
+.br
+Paul Edens - Dutch localization
+.br
+Kyunghwan Kim - Korean localization
+.br
+Mario Klebsch - Non-US keyboard support
+.br
+Torrey T. Lyons - Project Lead
+.br
+Andreas Monitzer - German localization
+.br
+Patrik Montgomery - Swedish localization
+.br
+Greg Parker - Rootless support
+.br
+Toshimitsu Tanaka - Japanese localization
+.br
+Olivier Verdier - French localization
commit 345e21a4b1796cd09e6255763028fa6573828165
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Mon Dec 3 23:59:19 2007 -0800

    Darwin: RIP dumpkeymap, cr, and fullscreen
    Taking out the trash.
    We don't need dumpkeymap since we'll be getting keymaps straight from the OS. .Xmodmap should be sufficient for any user-needed changes.  If this is not
    the case, please let us know, so we can address any problems you have.
    fullscreen never worked AFAIK
    cr isn't being used and xpr is much better.
    (cherry picked from commit e41af2967e885466c4d194fa4c3b358e6be37c30)

diff --git a/configure.ac b/configure.ac
index b8d5271..0e72d04 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2157,7 +2157,6 @@ hw/darwin/Makefile
 hw/darwin/apple/Makefile
 hw/darwin/quartz/Makefile
 hw/darwin/quartz/xpr/Makefile
-hw/darwin/utils/Makefile
 hw/kdrive/Makefile
 hw/kdrive/ati/Makefile
 hw/kdrive/chips/Makefile
diff --git a/hw/darwin/Makefile.am b/hw/darwin/Makefile.am
index 136c41a..f5b9e75 100644
--- a/hw/darwin/Makefile.am
+++ b/hw/darwin/Makefile.am
@@ -9,8 +9,8 @@ if X11APP
 X11APP_SUBDIRS = apple
 endif
 
-SUBDIRS = quartz utils $(X11APP_SUBDIRS)
-DIST_SUBDIRS = quartz utils apple launcher
+SUBDIRS = quartz $(X11APP_SUBDIRS)
+DIST_SUBDIRS = quartz apple
 
 bin_PROGRAMS = Xquartz
 man1_MANS = Xquartz.man
diff --git a/hw/darwin/quartz/cr/XView.h b/hw/darwin/quartz/cr/XView.h
deleted file mode 100644
index 26f789d..0000000
--- a/hw/darwin/quartz/cr/XView.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * NSView subclass for Mac OS X rootless X server
- *
- * Copyright (c) 2001 Greg Parker. 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
- * 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.
- */
-
-#import <Cocoa/Cocoa.h>
-
- at interface XView : NSQuickDrawView
-
-- (BOOL)isFlipped;
-- (BOOL)isOpaque;
-- (BOOL)acceptsFirstResponder;
-- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent;
-- (BOOL)shouldDelayWindowOrderingForEvent:(NSEvent *)theEvent;
-
-- (void)mouseDown:(NSEvent *)anEvent;
-
- at end
diff --git a/hw/darwin/quartz/cr/XView.m b/hw/darwin/quartz/cr/XView.m
deleted file mode 100644
index 130b15f..0000000
--- a/hw/darwin/quartz/cr/XView.m
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * NSView subclass for Mac OS X rootless X server
- *
- * Each rootless window contains an instance of this class.
- * This class handles events while drawing is handled by Carbon
- * code in the rootless Aqua implementation.
- *
- * Copyright (c) 2001 Greg Parker. 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
- * 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#import "XView.h"
-
-
- at implementation XView
-
-- (BOOL)isFlipped
-{
-    return NO;
-}
-
-- (BOOL)isOpaque
-{
-    return YES;
-}
-
-- (BOOL)acceptsFirstResponder
-{
-    return YES;
-}
-
-- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
-{
-    return YES;
-}
-
-- (BOOL)shouldDelayWindowOrderingForEvent:(NSEvent *)theEvent
-{
-    return YES;
-}
-
-- (void)mouseDown:(NSEvent *)anEvent
-{
-    // Only X is allowed to restack windows.
-    [NSApp preventWindowOrdering];
-    if (! [NSApp isActive]) {
-        [NSApp activateIgnoringOtherApps:YES];
-    }
-    [[self nextResponder] mouseDown:anEvent];
-}
-
- at end
diff --git a/hw/darwin/quartz/cr/cr.h b/hw/darwin/quartz/cr/cr.h
deleted file mode 100644
index 0ebad5d..0000000
--- a/hw/darwin/quartz/cr/cr.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Internal definitions of the Cocoa rootless implementation
- *
- * Copyright (c) 2003 Torrey T. Lyons. 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
- * 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 _CR_H
-#define _CR_H
-
-#ifdef __OBJC__
-#import <Cocoa/Cocoa.h>
-#import "XView.h"
-#else
-typedef struct OpaqueNSWindow NSWindow;
-typedef struct OpaqueXView XView;
-#endif
-
-#undef BOOL
-#define BOOL xBOOL
-#include "screenint.h"
-#include "window.h"
-#undef BOOL
-
-// Predefined style for the window which is about to be framed
-extern WindowPtr nextWindowToFrame;
-extern unsigned int nextWindowStyle;
-
-typedef struct {
-    NSWindow *window;
-    XView *view;
-    GrafPtr port;
-    CGContextRef context;
-} CRWindowRec, *CRWindowPtr;
-
-Bool CRInit(ScreenPtr pScreen);
-void CRAppleWMInit(void);
-
-#endif /* _CR_H */
diff --git a/hw/darwin/quartz/cr/crAppleWM.m b/hw/darwin/quartz/cr/crAppleWM.m
deleted file mode 100644
index 246f521..0000000
--- a/hw/darwin/quartz/cr/crAppleWM.m
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Cocoa rootless implementation functions for AppleWM extension
- *
- * Copyright (c) 2003 Torrey T. Lyons. 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
- * 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "quartz/quartzCommon.h"
-#include "quartz/cr/cr.h"
-
-#undef BOOL
-#define BOOL xBOOL
-#include "rootless.h"
-#include "X11/X.h"
-#define _APPLEWM_SERVER_
-#include "X11/extensions/applewm.h"
-#include "quartz/applewmExt.h"
-#undef BOOL
-
-#define StdDocumentStyleMask (NSTitledWindowMask | \
-                              NSClosableWindowMask | \
-                              NSMiniaturizableWindowMask | \
-                              NSResizableWindowMask)
-
-static int
-CRDisableUpdate(void)
-{
-    return Success;
-}
-
-
-static int
-CREnableUpdate(void)
-{
-    return Success;
-}
-
-
-static int CRSetWindowLevel(
-    WindowPtr pWin,
-    int level)
-{
-    CRWindowPtr crWinPtr;
-
-    crWinPtr = (CRWindowPtr) RootlessFrameForWindow(pWin, TRUE);
-    if (crWinPtr == 0)
-        return BadWindow;
-
-    RootlessStopDrawing(pWin, FALSE);
-
-    [crWinPtr->window setLevel:level];
-
-    return Success;
-}
-
-
-static int CRFrameGetRect(
-    int type,
-    int class,
-    const BoxRec *outer,
-    const BoxRec *inner,
-    BoxRec *ret)
-{
-    return Success;
-}
-
-
-static int CRFrameHitTest(
-    int class,
-    int x,
-    int y,
-    const BoxRec *outer,
-    const BoxRec *inner,
-    int *ret)
-{
-    return 0;
-}
-
-
-static int CRFrameDraw(
-    WindowPtr pWin,
-    int class,
-    unsigned int attr,
-    const BoxRec *outer,
-    const BoxRec *inner,
-    unsigned int title_len,
-    const unsigned char *title_bytes)
-{
-    CRWindowPtr crWinPtr;
-    NSWindow *window;
-    Bool hasResizeIndicator;
-
-    /* We assume the window has not yet been framed so
-       RootlessFrameForWindow() will cause it to be. Record the window
-       style so that the appropriate one will be used when it is framed.
-       If the window is already framed, we can't change the window
-       style and the following will have no effect. */
-
-    nextWindowToFrame = pWin;
-    if (class == AppleWMFrameClassDocument)
-        nextWindowStyle = StdDocumentStyleMask;
-    else
-        nextWindowStyle = NSBorderlessWindowMask;
-
-    crWinPtr = (CRWindowPtr) RootlessFrameForWindow(pWin, TRUE);
-    if (crWinPtr == 0)
-        return BadWindow;
-
-    window = crWinPtr->window;
-
-    [window setTitle:[NSString stringWithCString:title_bytes
-                               length:title_len]];
-
-    hasResizeIndicator = (attr & AppleWMFrameGrowBox) ? YES : NO;
-    [window setShowsResizeIndicator:hasResizeIndicator];
-
-    return Success;
-}
-
-
-static AppleWMProcsRec crAppleWMProcs = {
-    CRDisableUpdate,
-    CREnableUpdate,
-    CRSetWindowLevel,
-    CRFrameGetRect,
-    CRFrameHitTest,
-    CRFrameDraw
-};
-
-
-void CRAppleWMInit(void)
-{
-    AppleWMExtensionInit(&crAppleWMProcs);
-}
diff --git a/hw/darwin/quartz/cr/crFrame.m b/hw/darwin/quartz/cr/crFrame.m
deleted file mode 100644
index 86c75d2..0000000
--- a/hw/darwin/quartz/cr/crFrame.m
+++ /dev/null
@@ -1,440 +0,0 @@
-/*
- * Cocoa rootless implementation frame functions
- *
- * Copyright (c) 2001 Greg Parker. All Rights Reserved.
- * Copyright (c) 2002-2003 Torrey T. Lyons. 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
- * 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "quartz/quartzCommon.h"
-#include "quartz/cr/cr.h"
-
-#undef BOOL
-#define BOOL xBOOL
-#include "rootless.h"
-#include "quartz/applewmExt.h"
-#include "windowstr.h"
-#undef BOOL
-
-WindowPtr nextWindowToFrame = NULL;
-unsigned int nextWindowStyle = 0;
-
-static void CRReshapeFrame(RootlessFrameID wid, RegionPtr pShape);
-
-
-/*
- * CRCreateFrame
- *  Create a new physical window.
- *  Rootless windows must not autodisplay! Autodisplay can cause a deadlock.
- *    Event thread - autodisplay: locks view hierarchy, then window
- *    X Server thread - window resize: locks window, then view hierarchy
- *  Deadlock occurs if each thread gets one lock and waits for the other.
- */
-static Bool
-CRCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
-              int newX, int newY, RegionPtr pShape)
-{
-    CRWindowPtr crWinPtr;
-    NSRect bounds;
-    NSWindow *theWindow;
-    XView *theView;
-    unsigned int theStyleMask = NSBorderlessWindowMask;
-
-    crWinPtr = (CRWindowPtr) xalloc(sizeof(CRWindowRec));
-
-    bounds = NSMakeRect(newX,
-                        NSHeight([[NSScreen mainScreen] frame]) -
-                        newY - pFrame->height,
-                        pFrame->width, pFrame->height);
-
-    // Check if AppleWM has specified a style for this window
-    if (pFrame->win == nextWindowToFrame) {
-        theStyleMask = nextWindowStyle;
-    }
-    nextWindowToFrame = NULL;
-
-    // Create an NSWindow for the new X11 window
-    theWindow = [[NSWindow alloc] initWithContentRect:bounds
-                                  styleMask:theStyleMask
-                                  backing:NSBackingStoreBuffered
-#ifdef DEFER_NSWINDOW
-                                  defer:YES];
-#else
-                                  defer:NO];
-#endif
-
-    if (!theWindow) return FALSE;
-
-    [theWindow setBackgroundColor:[NSColor clearColor]];  // erase transparent
-    [theWindow setAlphaValue:1.0];       // draw opaque
-    [theWindow setOpaque:YES];           // changed when window is shaped
-
-    [theWindow useOptimizedDrawing:YES]; // Has no overlapping sub-views
-    [theWindow setAutodisplay:NO];       // See comment above
-    [theWindow disableFlushWindow];      // We do all the flushing manually
-    [theWindow setHasShadow:YES];        // All windows have shadows
-    [theWindow setReleasedWhenClosed:YES]; // Default, but we want to be sure
-
-    theView = [[XView alloc] initWithFrame:bounds];
-    [theWindow setContentView:theView];
-    [theWindow setInitialFirstResponder:theView];
-
-#ifdef DEFER_NSWINDOW
-    // We need the NSWindow to actually be created now.
-    // If we had to defer creating it, we have to order it
-    // onto the screen to force it to be created.
-
-    if (pFrame->win->prevSib) {
-        CRWindowPtr crWinPtr = (CRWindowPtr) RootlessFrameForWindow(
-                                                pFrame->win->prevSib, FALSE);
-        int upperNum = [crWinPtr->window windowNumber];
-        [theWindow orderWindow:NSWindowBelow relativeTo:upperNum];
-    } else {
-        [theWindow orderFront:nil];
-    }
-#endif
-
-    [theWindow setAcceptsMouseMovedEvents:YES];
-
-    crWinPtr->window = theWindow;
-    crWinPtr->view = theView;
-
-    [theView lockFocus];
-    // Fill the window with white to make sure alpha channel is set
-    NSEraseRect(bounds);
-    crWinPtr->port = [theView qdPort];
-    crWinPtr->context = [[NSGraphicsContext currentContext] graphicsPort];
-    // CreateCGContextForPort(crWinPtr->port, &crWinPtr->context);
-    [theView unlockFocus];
-
-    // Store the implementation private frame ID
-    pFrame->wid = (RootlessFrameID) crWinPtr;
-
-    // Reshape the frame if it was created shaped.
-    if (pShape != NULL)
-        CRReshapeFrame(pFrame->wid, pShape);
-
-    return TRUE;
-}
-
-
-/*
- * CRDestroyFrame
- *  Destroy a frame.
- */
-static void
-CRDestroyFrame(RootlessFrameID wid)
-{
-    CRWindowPtr crWinPtr = (CRWindowPtr) wid;
-
-    [crWinPtr->window orderOut:nil];
-    [crWinPtr->window close];
-    [crWinPtr->view release];
-    free(crWinPtr);
-}
-
-
-/*
- * CRMoveFrame
- *  Move a frame on screen.
- */
-static void
-CRMoveFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY)
-{
-    CRWindowPtr crWinPtr = (CRWindowPtr) wid;
-    NSPoint topLeft;
-
-    topLeft = NSMakePoint(newX,
-                          NSHeight([[NSScreen mainScreen] frame]) - newY);
-
-    [crWinPtr->window setFrameTopLeftPoint:topLeft];
-}
-
-
-/*
- * CRResizeFrame
- *  Move and resize a frame.
- */
-static void
-CRResizeFrame(RootlessFrameID wid, ScreenPtr pScreen,
-              int newX, int newY, unsigned int newW, unsigned int newH,
-              unsigned int gravity)
-{
-    CRWindowPtr crWinPtr = (CRWindowPtr) wid;
-    NSRect bounds = NSMakeRect(newX, NSHeight([[NSScreen mainScreen] frame]) -
-                               newY - newH, newW, newH);
-
-    [crWinPtr->window setFrame:bounds display:NO];
-}
-
-
-/*
- * CRRestackFrame
- *  Change the frame order. Put the frame behind nextWid or on top if
- *  it is NULL. Unmapped frames are mapped by restacking them.
- */
-static void
-CRRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid)
-{
-    CRWindowPtr crWinPtr = (CRWindowPtr) wid;
-    CRWindowPtr crNextWinPtr = (CRWindowPtr) nextWid;
-
-    if (crNextWinPtr) {
-        int upperNum = [crNextWinPtr->window windowNumber];
-
-        [crWinPtr->window orderWindow:NSWindowBelow relativeTo:upperNum];
-    } else {
-        [crWinPtr->window makeKeyAndOrderFront:nil];
-    }
-}
-
-
-/*
- * CRReshapeFrame
- *  Set the shape of a frame.
- */
-static void
-CRReshapeFrame(RootlessFrameID wid, RegionPtr pShape)
-{
-    CRWindowPtr crWinPtr = (CRWindowPtr) wid;
-    NSRect bounds = [crWinPtr->view frame];
-    int winHeight = NSHeight(bounds);
-    BoxRec localBox = {0, 0, NSWidth(bounds), winHeight};
-
-    [crWinPtr->view lockFocus];
-
-    if (pShape != NULL) {
-        // Calculate the region outside the new shape.
-        miInverse(pShape, pShape, &localBox);
-    }
-
-    // If window is currently shaped we need to undo the previous shape.
-    if (![crWinPtr->window isOpaque]) {
-        [[NSColor whiteColor] set];
-        NSRectFillUsingOperation(bounds, NSCompositeDestinationAtop);
-    }
-
-    if (pShape != NULL) {
-        int count = REGION_NUM_RECTS(pShape);
-        BoxRec *extRects = REGION_RECTS(pShape);
-        BoxRec *rects, *end;
-
-        // Make transparent if window is now shaped.
-        [crWinPtr->window setOpaque:NO];
-
-        // Clear the areas outside the window shape
-        [[NSColor clearColor] set];
-        for (rects = extRects, end = extRects+count; rects < end; rects++) {
-            int rectHeight = rects->y2 - rects->y1;
-            NSRectFill( NSMakeRect(rects->x1,
-                                   winHeight - rects->y1 - rectHeight,
-                                   rects->x2 - rects->x1, rectHeight) );
-        }
-        [[NSGraphicsContext currentContext] flushGraphics];
-
-        // force update of window shadow
-        [crWinPtr->window setHasShadow:NO];
-        [crWinPtr->window setHasShadow:YES];
-
-    } else {
-        [crWinPtr->window setOpaque:YES];
-        [[NSGraphicsContext currentContext] flushGraphics];
-    }
-
-    [crWinPtr->view unlockFocus];
-}
-
-
-/*
- * CRUnmapFrame
- *  Unmap a frame.
- */
-static void
-CRUnmapFrame(RootlessFrameID wid)
-{
-    CRWindowPtr crWinPtr = (CRWindowPtr) wid;
-
-    [crWinPtr->window orderOut:nil];
-}
-
-
-/*
- * CRStartDrawing
- *  When a window's buffer is not being drawn to, the CoreGraphics
- *  window server may compress or move it. Call this routine
- *  to lock down the buffer during direct drawing. It returns
- *  a pointer to the backing buffer.
- */
-static void
-CRStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPerRow)
-{
-    CRWindowPtr crWinPtr = (CRWindowPtr) wid;
-    PixMapHandle pix;
-
-    [crWinPtr->view lockFocus];
-    crWinPtr->port = [crWinPtr->view qdPort];
-    LockPortBits(crWinPtr->port);
-    [crWinPtr->view unlockFocus];
-    pix = GetPortPixMap(crWinPtr->port);
-
-    *pixelData = GetPixBaseAddr(pix);
-    *bytesPerRow = GetPixRowBytes(pix) & 0x3fff; // fixme is mask needed?
-}
-
-
-/*
- * CRStopDrawing
- *  When direct access to a window's buffer is no longer needed, this
- *  routine should be called to allow CoreGraphics to compress or
- *  move it.
- */
-static void
-CRStopDrawing(RootlessFrameID wid, Bool flush)
-{
-    CRWindowPtr crWinPtr = (CRWindowPtr) wid;
-
-    UnlockPortBits(crWinPtr->port);
-
-    if (flush) {
-        QDFlushPortBuffer(crWinPtr->port, NULL);
-    }
-}
-
-
-/*
- * CRUpdateRegion
- *  Flush a region from a window's backing buffer to the screen.
- */
-static void
-CRUpdateRegion(RootlessFrameID wid, RegionPtr pDamage)
-{
-    CRWindowPtr crWinPtr = (CRWindowPtr) wid;
-
-#ifdef ROOTLESS_TRACK_DAMAGE
-    int count = REGION_NUM_RECTS(pDamage);
-    BoxRec *rects = REGION_RECTS(pDamage);
-    BoxRec *end;
-
-    static RgnHandle rgn = NULL;
-    static RgnHandle box = NULL;
-
-    if (!rgn) rgn = NewRgn();
-    if (!box) box = NewRgn();
-
-    for (end = rects+count; rects < end; rects++) {
-        Rect qdRect;
-        qdRect.left = rects->x1;
-        qdRect.top = rects->y1;
-        qdRect.right = rects->x2;
-        qdRect.bottom = rects->y2;
-
-        RectRgn(box, &qdRect);
-        UnionRgn(rgn, box, rgn);
-    }
-
-    QDFlushPortBuffer(crWinPtr->port, rgn);
-
-    SetEmptyRgn(rgn);
-    SetEmptyRgn(box);
-
-#else	/* !ROOTLESS_TRACK_DAMAGE */
-    QDFlushPortBuffer(crWinPtr->port, NULL);
-#endif
-}
-
-
-/*
- * CRDamageRects
- *  Mark damaged rectangles as requiring redisplay to screen.
- */
-static void
-CRDamageRects(RootlessFrameID wid, int count, const BoxRec *rects,
-               int shift_x, int shift_y)
-{
-    CRWindowPtr crWinPtr = (CRWindowPtr) wid;
-    const BoxRec *end;
-
-    for (end = rects + count; rects < end; rects++) {
-        Rect qdRect;
-        qdRect.left = rects->x1 + shift_x;
-        qdRect.top = rects->y1 + shift_y;
-        qdRect.right = rects->x2 + shift_x;
-        qdRect.bottom = rects->y2 + shift_y;
-
-        QDAddRectToDirtyRegion(crWinPtr->port, &qdRect);
-    }
-}
-
-
-/*
- * Called to check if the frame should be reordered when it is restacked.
- */
-Bool CRDoReorderWindow(RootlessWindowPtr pFrame)
-{
-    WindowPtr pWin = pFrame->win;
-
-    return AppleWMDoReorderWindow(pWin);
-}
-
-
-static RootlessFrameProcsRec CRRootlessProcs = {
-    CRCreateFrame,
-    CRDestroyFrame,
-    CRMoveFrame,
-    CRResizeFrame,
-    CRRestackFrame,
-    CRReshapeFrame,
-    CRUnmapFrame,
-    CRStartDrawing,
-    CRStopDrawing,
-    CRUpdateRegion,
-    CRDamageRects,
-    NULL,
-    CRDoReorderWindow,
-    NULL,
-    NULL,
-    NULL,
-    NULL
-};
-
-
-/*
- * Initialize CR implementation
- */
-Bool
-CRInit(ScreenPtr pScreen)
-{
-    RootlessInit(pScreen, &CRRootlessProcs);
-
-    rootless_CopyBytes_threshold = 0;
-    rootless_FillBytes_threshold = 0;
-    rootless_CompositePixels_threshold = 0;
-    rootless_CopyWindow_threshold = 0;
-
-    return TRUE;
-}
diff --git a/hw/darwin/quartz/cr/crScreen.m b/hw/darwin/quartz/cr/crScreen.m
deleted file mode 100644
index cc82afb..0000000
--- a/hw/darwin/quartz/cr/crScreen.m
+++ /dev/null
@@ -1,382 +0,0 @@
-/*
- * Cocoa rootless implementation initialization
- *
- * Copyright (c) 2001 Greg Parker. All Rights Reserved.
- * Copyright (c) 2002-2004 Torrey T. Lyons. 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
- * 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "quartz/quartzCommon.h"
-#include "quartz/cr/cr.h"
-
-#undef BOOL
-#define BOOL xBOOL
-#include "darwin.h"
-#include "quartz/quartz.h"
-#include "quartz/quartzCursor.h"
-#include "rootless.h"
-#include "safeAlpha/safeAlpha.h"
-#include "quartz/pseudoramiX.h"
-#include "quartz/applewmExt.h"
-
-#include "regionstr.h"
-#include "scrnintstr.h"
-#include "picturestr.h"
-#include "globals.h"
-#ifdef DAMAGE
-# include "damage.h"
-#endif
-#undef BOOL
-
-// Name of GLX bundle using AGL framework
-static const char *crOpenGLBundle = "glxAGL.bundle";
-
-static Class classXView = nil;
-
-
-/*
- * CRDisplayInit
- *  Find all screens.
- *
- *  Multihead note: When rootless mode uses PseudoramiX, the
- *  X server only sees one screen; only PseudoramiX itself knows
- *  about all of the screens.
- */
-static void
-CRDisplayInit(void)
-{
-    ErrorF("Display mode: Rootless Quartz -- Cocoa implementation\n");
-
-    if (noPseudoramiXExtension) {
-        darwinScreensFound = [[NSScreen screens] count];
-    } else {
-        darwinScreensFound = 1; // only PseudoramiX knows about the rest
-    }
-
-    CRAppleWMInit();
-}
-
-
-/*
- * CRAddPseudoramiXScreens
- *  Add a single virtual screen encompassing all the physical screens
- *  with PseudoramiX.
- */
-static void
-CRAddPseudoramiXScreens(int *x, int *y, int *width, int *height)
-{
-    int i;
-    NSRect unionRect = NSMakeRect(0, 0, 0, 0);
-    NSArray *screens = [NSScreen screens];
-
-    // Get the union of all screens (minus the menu bar on main screen)
-    for (i = 0; i < [screens count]; i++) {
-        NSScreen *screen = [screens objectAtIndex:i];
-        NSRect frame = [screen frame];
-        frame.origin.y = [[NSScreen mainScreen] frame].size.height -
-                         frame.size.height - frame.origin.y;
-        if (NSEqualRects([screen frame], [[NSScreen mainScreen] frame])) {
-            frame.origin.y    += aquaMenuBarHeight;
-            frame.size.height -= aquaMenuBarHeight;
-        }
-        unionRect = NSUnionRect(unionRect, frame);
-    }
-
-    // Use unionRect as the screen size for the X server.
-    *x = unionRect.origin.x;
-    *y = unionRect.origin.y;
-    *width = unionRect.size.width;
-    *height = unionRect.size.height;
-
-    // Tell PseudoramiX about the real screens.
-    // InitOutput() will move the big screen to (0,0),
-    // so compensate for that here.
-    for (i = 0; i < [screens count]; i++) {
-        NSScreen *screen = [screens objectAtIndex:i];
-        NSRect frame = [screen frame];
-        int j;
-
-        // Skip this screen if it's a mirrored copy of an earlier screen.
-        for (j = 0; j < i; j++) {
-            if (NSEqualRects(frame, [[screens objectAtIndex:j] frame])) {
-                ErrorF("PseudoramiX screen %d is a mirror of screen %d.\n",
-                       i, j);
-                break;
-            }
-        }
-        if (j < i) continue; // this screen is a mirrored copy
-
-        frame.origin.y = [[NSScreen mainScreen] frame].size.height -
-                         frame.size.height - frame.origin.y;
-
-        if (NSEqualRects([screen frame], [[NSScreen mainScreen] frame])) {
-            frame.origin.y    += aquaMenuBarHeight;
-            frame.size.height -= aquaMenuBarHeight;
-        }
-
-        ErrorF("PseudoramiX screen %d added: %dx%d @ (%d,%d).\n", i,
-               (int)frame.size.width, (int)frame.size.height,
-               (int)frame.origin.x, (int)frame.origin.y);
-
-        frame.origin.x -= unionRect.origin.x;
-        frame.origin.y -= unionRect.origin.y;
-
-        ErrorF("PseudoramiX screen %d placed at X11 coordinate (%d,%d).\n",
-               i, (int)frame.origin.x, (int)frame.origin.y);
-
-        PseudoramiXAddScreen(frame.origin.x, frame.origin.y,
-                             frame.size.width, frame.size.height);
-    }
-}
-
-
-/*
- * CRScreenParams
- *  Set the basic screen parameters.
- */
-static void
-CRScreenParams(int index, DarwinFramebufferPtr dfb)
-{
-    dfb->bitsPerComponent = CGDisplayBitsPerSample(kCGDirectMainDisplay);
-    dfb->bitsPerPixel = CGDisplayBitsPerPixel(kCGDirectMainDisplay);
-    dfb->colorBitsPerPixel = 3 * dfb->bitsPerComponent;
-
-    if (noPseudoramiXExtension) {
-        NSScreen *screen = [[NSScreen screens] objectAtIndex:index];
-        NSRect frame = [screen frame];
-
-        // set x, y so (0,0) is top left of main screen
-        dfb->x = NSMinX(frame);
-        dfb->y = NSHeight([[NSScreen mainScreen] frame]) -
-                 NSHeight(frame) - NSMinY(frame);
-
-        dfb->width =  NSWidth(frame);
-        dfb->height = NSHeight(frame);
-
-        // Shift the usable part of main screen down to avoid the menu bar.
-        if (NSEqualRects(frame, [[NSScreen mainScreen] frame])) {
-            dfb->y      += aquaMenuBarHeight;
-            dfb->height -= aquaMenuBarHeight;
-        }
-
-    } else {
-        CRAddPseudoramiXScreens(&dfb->x, &dfb->y, &dfb->width, &dfb->height);
-    }
-}
-
-
-/*
- * CRAddScreen
- *  Init the framebuffer and record pixmap parameters for the screen.
- */
-static Bool
-CRAddScreen(int index, ScreenPtr pScreen)
-{
-    DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen);
-    QuartzScreenPtr displayInfo = QUARTZ_PRIV(pScreen);
-    CGRect cgRect;
-    CGDisplayCount numDisplays;
-    CGDisplayCount allocatedDisplays = 0;
-    CGDirectDisplayID *displays = NULL;
-    CGDisplayErr cgErr;
-
-    CRScreenParams(index, dfb);
-
-    dfb->colorType = TrueColor;
-
-    /* Passing zero width (pitch) makes miCreateScreenResources set the
-       screen pixmap to the framebuffer pointer, i.e. NULL. The generic
-       rootless code takes care of making this work. */
-    dfb->pitch = 0;
-    dfb->framebuffer = NULL;
-
-    // Get all CoreGraphics displays covered by this X11 display.
-    cgRect = CGRectMake(dfb->x, dfb->y, dfb->width, dfb->height);
-    do {
-        cgErr = CGGetDisplaysWithRect(cgRect, 0, NULL, &numDisplays);
-        if (cgErr) break;
-        allocatedDisplays = numDisplays;
-        displays = xrealloc(displays,
-                            numDisplays * sizeof(CGDirectDisplayID));
-        cgErr = CGGetDisplaysWithRect(cgRect, allocatedDisplays, displays,
-                                      &numDisplays);
-        if (cgErr != CGDisplayNoErr) break;
-    } while (numDisplays > allocatedDisplays);
-
-    if (cgErr != CGDisplayNoErr || numDisplays == 0) {
-        ErrorF("Could not find CGDirectDisplayID(s) for X11 screen %d: %dx%d @ %d,%d.\n",
-               index, dfb->width, dfb->height, dfb->x, dfb->y);
-        return FALSE;
-    }
-
-    // This X11 screen covers all CoreGraphics displays we just found.
-    // If there's more than one CG display, then video mirroring is on
-    // or PseudoramiX is on.
-    displayInfo->displayCount = allocatedDisplays;
-    displayInfo->displayIDs = displays;
-
-    return TRUE;
-}
-
-
-/*
- * CRSetupScreen
- *  Setup the screen for rootless access.
- */
-static Bool
-CRSetupScreen(int index, ScreenPtr pScreen)
-{
-    // Add alpha protecting replacements for fb screen functions
-    pScreen->PaintWindowBackground = SafeAlphaPaintWindow;
-    pScreen->PaintWindowBorder = SafeAlphaPaintWindow;
-
-#ifdef RENDER
-    {
-        PictureScreenPtr ps = GetPictureScreen(pScreen);
-        ps->Composite = SafeAlphaComposite;
-    }
-#endif /* RENDER */
-
-    // Initialize accelerated rootless drawing
-    // Note that this must be done before DamageSetup().
-    RootlessAccelInit(pScreen);
-
-#ifdef DAMAGE
-    // The Damage extension needs to wrap underneath the
-    // generic rootless layer, so do it now.
-    if (!DamageSetup(pScreen))
-        return FALSE;
-#endif
-
-    // Initialize generic rootless code
-    return CRInit(pScreen);
-}
-
-
-/*
- * CRScreenChanged
- *  Configuration of displays has changed.
- */
-static void
-CRScreenChanged(void)
-{
-    QuartzMessageServerThread(kXDarwinDisplayChanged, 0);
-}
-
-
-/*
- * CRUpdateScreen
- *  Update screen after configuation change.
- */
-static void
-CRUpdateScreen(ScreenPtr pScreen)
-{
-    rootlessGlobalOffsetX = darwinMainScreenX;
-    rootlessGlobalOffsetY = darwinMainScreenY;
-
-    AppleWMSetScreenOrigin(WindowTable[pScreen->myNum]);
-
-    RootlessRepositionWindows(pScreen);
-    RootlessUpdateScreenPixmap(pScreen);
-}
-
-
-/*
- * CRInitInput
- *  Finalize CR specific setup.
- */
-static void
-CRInitInput(int argc, char **argv)
-{
-    int i;
-
-    rootlessGlobalOffsetX = darwinMainScreenX;
-    rootlessGlobalOffsetY = darwinMainScreenY;
-
-    for (i = 0; i < screenInfo.numScreens; i++)
-        AppleWMSetScreenOrigin(WindowTable[i]);
-}
-
-
-/*
- * CRIsX11Window
- *  Returns TRUE if cr is displaying this window.
- */
-static Bool
-CRIsX11Window(void *nsWindow, int windowNumber)
-{
-    NSWindow *theWindow = nsWindow;
-
-    if (!theWindow)
-        return FALSE;
-
-    if ([[theWindow contentView] isKindOfClass:classXView])
-        return TRUE;
-    else
-        return FALSE;
-}
-
-
-/*
- * Quartz display mode function list.
- */
-static QuartzModeProcsRec crModeProcs = {
-    CRDisplayInit,
-    CRAddScreen,
-    CRSetupScreen,
-    CRInitInput,
-    QuartzInitCursor,
-    QuartzReallySetCursor,
-    QuartzSuspendXCursor,
-    QuartzResumeXCursor,
-    NULL,               // No capture or release in rootless mode
-    NULL,
-    CRScreenChanged,
-    CRAddPseudoramiXScreens,
-    CRUpdateScreen,
-    CRIsX11Window,
-    NULL,               // Cocoa NSWindows hide themselves
-    RootlessFrameForWindow,
-    TopLevelParent,
-    NULL,               // No support for DRI surfaces
-    NULL
-};
-
-
-/*
- * QuartzModeBundleInit
- *  Initialize the display mode bundle after loading.
- */
-Bool
-QuartzModeBundleInit(void)
-{
-    quartzProcs = &crModeProcs;
-    quartzOpenGLBundle = crOpenGLBundle;
-    classXView = [XView class];
-    return TRUE;
-}
diff --git a/hw/darwin/quartz/fullscreen/fullscreen.c b/hw/darwin/quartz/fullscreen/fullscreen.c
deleted file mode 100644
index c4a049f..0000000
--- a/hw/darwin/quartz/fullscreen/fullscreen.c
+++ /dev/null
@@ -1,571 +0,0 @@
-/*
- * Screen routines for full screen Quartz mode
- *
- * Copyright (c) 2002-2003 Torrey T. Lyons. 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
- * TORREY T. LYONS 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "quartz/quartzCommon.h"
-#include "darwin.h"
-#include "quartz/quartz.h"
-#include "quartz/quartzCursor.h"
-#include "colormapst.h"
-#include "scrnintstr.h"
-#include "micmap.h"
-#include "shadow.h"
-
-// Full screen specific per screen storage structure
-typedef struct {
-    CGDirectDisplayID   displayID;
-    CFDictionaryRef     xDisplayMode;
-    CFDictionaryRef     aquaDisplayMode;
-    CGDirectPaletteRef  xPalette;
-    CGDirectPaletteRef  aquaPalette;
-    unsigned char      *framebuffer;
-    unsigned char      *shadowPtr;
-} FSScreenRec, *FSScreenPtr;
-
-#define FULLSCREEN_PRIV(pScreen) \
-    ((FSScreenPtr)pScreen->devPrivates[fsScreenIndex].ptr)
-
-static int                  fsScreenIndex;
-static CGDirectDisplayID   *quartzDisplayList = NULL;
-static int                  quartzNumScreens = 0;
-static FSScreenPtr          quartzScreens[MAXSCREENS];
-
-static int                  darwinCmapPrivateIndex = -1;
-static unsigned long        darwinCmapGeneration = 0;
-
-#define CMAP_PRIV(pCmap) \
-    ((CGDirectPaletteRef) (pCmap)->devPrivates[darwinCmapPrivateIndex].ptr)
-
-/*
- =============================================================================
-
- Colormap handling
-
- =============================================================================
-*/
-
-/*
- * FSInitCmapPrivates
- *  Colormap privates may be allocated after the default colormap has
- *  already been created for some screens.  This initialization procedure
- *  is called for each default colormap that is found.
- */
-static Bool
-FSInitCmapPrivates(
-    ColormapPtr         pCmap)
-{
-    return TRUE;
-}
-
-
-/*
- * FSCreateColormap
- *  This is a callback from X after a new colormap is created.
- *  We allocate a new CoreGraphics pallete for each colormap.
- */
-static Bool
-FSCreateColormap(
-    ColormapPtr         pCmap)
-{
-    CGDirectPaletteRef  pallete;
-
-    // Allocate private storage for the hardware dependent colormap info.
-    if (darwinCmapGeneration != serverGeneration) {
-        if ((darwinCmapPrivateIndex =
-                AllocateColormapPrivateIndex(FSInitCmapPrivates)) < 0)
-        {
-            return FALSE;
-        }
-        darwinCmapGeneration = serverGeneration;
-    }
-
-    pallete = CGPaletteCreateDefaultColorPalette();
-    if (!pallete) return FALSE;
-
-    CMAP_PRIV(pCmap) = pallete;
-    return TRUE;
-}
-
-
-/*
- * FSDestroyColormap
- *  This is called by DIX FreeColormap after it has uninstalled a colormap
- *  and notified all interested parties. We deallocated the corresponding
- *  CoreGraphics pallete.
- */
-static void
-FSDestroyColormap(
-    ColormapPtr         pCmap)
-{
-    CGPaletteRelease( CMAP_PRIV(pCmap) );
-}
-
-
-/*
- * FSInstallColormap
- *  Set the current CoreGraphics pallete to the pallete corresponding
- *  to the provided colormap.
- */
-static void
-FSInstallColormap(
-    ColormapPtr         pCmap)
-{
-    CGDirectPaletteRef  palette = CMAP_PRIV(pCmap);
-    ScreenPtr           pScreen = pCmap->pScreen;
-    FSScreenPtr         fsDisplayInfo = FULLSCREEN_PRIV(pScreen);
-
-    // Inform all interested parties that the map is being changed.
-    miInstallColormap(pCmap);
-
-    if (quartzServerVisible)
-        CGDisplaySetPalette(fsDisplayInfo->displayID, palette);
-
-    fsDisplayInfo->xPalette = palette;
-}
-
-
-/*
- * FSStoreColors
- *  This is a callback from X to change the hardware colormap
- *  when using PsuedoColor in full screen mode.
- */
-static void
-FSStoreColors(
-    ColormapPtr         pCmap,
-    int                 numEntries,
-    xColorItem          *pdefs)
-{
-    CGDirectPaletteRef  palette = CMAP_PRIV(pCmap);
-    ScreenPtr           pScreen = pCmap->pScreen;
-    FSScreenPtr         fsDisplayInfo = FULLSCREEN_PRIV(pScreen);
-    CGDeviceColor       color;
-    int                 i;
-
-    if (! palette)
-        return;
-
-    for (i = 0; i < numEntries; i++) {
-        color.red   = pdefs[i].red   / 65535.0;
-        color.green = pdefs[i].green / 65535.0;
-        color.blue  = pdefs[i].blue  / 65535.0;
-        CGPaletteSetColorAtIndex(palette, color, pdefs[i].pixel);
-    }
-
-    // Update hardware colormap
-    if (quartzServerVisible)
-        CGDisplaySetPalette(fsDisplayInfo->displayID, palette);
-}
-
-
-/*
- =============================================================================
-
- Switching between Aqua and X
-
- =============================================================================
-*/
-
-/*
- * FSCapture
- *  Capture the screen so we can draw. Called directly from the main thread
- *  to synchronize with hiding the menubar.
- */
-static void FSCapture(void)
-{
-    int i;
-
-    if (quartzRootless) return;
-
-    for (i = 0; i < quartzNumScreens; i++) {
-        FSScreenPtr fsDisplayInfo = quartzScreens[i];
-        CGDirectDisplayID cgID = fsDisplayInfo->displayID;
-
-        if (!CGDisplayIsCaptured(cgID)) {
-            CGDisplayCapture(cgID);
-            fsDisplayInfo->aquaDisplayMode = CGDisplayCurrentMode(cgID);
-            if (fsDisplayInfo->xDisplayMode != fsDisplayInfo->aquaDisplayMode)
-                CGDisplaySwitchToMode(cgID, fsDisplayInfo->xDisplayMode);
-            if (fsDisplayInfo->xPalette)
-                CGDisplaySetPalette(cgID, fsDisplayInfo->xPalette);
-        }
-    }
-}
-
-
-/*
- * FSRelease
- *  Release the screen so others can draw.
- */
-static void FSRelease(void)
-{
-    int i;
-
-    if (quartzRootless) return;
-
-    for (i = 0; i < quartzNumScreens; i++) {
-        FSScreenPtr fsDisplayInfo = quartzScreens[i];
-        CGDirectDisplayID cgID = fsDisplayInfo->displayID;
-
-        if (CGDisplayIsCaptured(cgID)) {
-            if (fsDisplayInfo->xDisplayMode != fsDisplayInfo->aquaDisplayMode)
-                CGDisplaySwitchToMode(cgID, fsDisplayInfo->aquaDisplayMode);
-            if (fsDisplayInfo->aquaPalette)
-                CGDisplaySetPalette(cgID, fsDisplayInfo->aquaPalette);
-            CGDisplayRelease(cgID);
-        }
-    }
-}
-
-
-/*
- * FSSuspendScreen
- *  Suspend X11 cursor and drawing to the screen.
- */
-static void FSSuspendScreen(
-    ScreenPtr pScreen)
-{
-    QuartzSuspendXCursor(pScreen);
-    xf86SetRootClip(pScreen, FALSE);
-}
-
-
-/*
- * FSResumeScreen
- *  Resume X11 cursor and drawing to the screen.
- */
-static void FSResumeScreen(
-    ScreenPtr pScreen,
-    int x,              // cursor location
-    int y )
-{
-    QuartzResumeXCursor(pScreen, x, y);
-    xf86SetRootClip(pScreen, TRUE);
-}
-
-
-/*
- =============================================================================
-
- Screen initialization
-
- =============================================================================
-*/
-
-/*
- * FSDisplayInit
- *  Full screen specific initialization called from InitOutput.
- */
-static void FSDisplayInit(void)
-{
-    static unsigned long generation = 0;
-    CGDisplayCount quartzDisplayCount = 0;
-
-    ErrorF("Display mode: Full screen Quartz -- Direct Display\n");
-
-    // Allocate private storage for each screen's mode specific info
-    if (generation != serverGeneration) {
-        fsScreenIndex = AllocateScreenPrivateIndex();
-        generation = serverGeneration;
-    }
-
-    // Find all the CoreGraphics displays
-    CGGetActiveDisplayList(0, NULL, &quartzDisplayCount);
-    quartzDisplayList = xalloc(quartzDisplayCount * sizeof(CGDirectDisplayID));
-    CGGetActiveDisplayList(quartzDisplayCount, quartzDisplayList,
-                           &quartzDisplayCount);
-
-    darwinScreensFound = quartzDisplayCount;
-    atexit(FSRelease);
-}
-
-
-/*
- * FSFindDisplayMode
- *  Find the appropriate display mode to use in full screen mode.
- *  If display mode is not the same as the current Aqua mode, switch
- *  to the new mode.
- */
-static Bool FSFindDisplayMode(
-    FSScreenPtr fsDisplayInfo)
-{
-    CGDirectDisplayID cgID = fsDisplayInfo->displayID;
-    size_t height, width, bpp;
-    boolean_t exactMatch;
-
-    fsDisplayInfo->aquaDisplayMode = CGDisplayCurrentMode(cgID);
-
-    // If no user options, use current display mode
-    if (darwinDesiredWidth == 0 && darwinDesiredDepth == -1 &&
-        darwinDesiredRefresh == -1)
-    {
-        fsDisplayInfo->xDisplayMode = fsDisplayInfo->aquaDisplayMode;
-        return TRUE;
-    }
-
-    // If the user has no choice for size, use current
-    if (darwinDesiredWidth == 0) {
-        width = CGDisplayPixelsWide(cgID);
-        height = CGDisplayPixelsHigh(cgID);
-    } else {
-        width = darwinDesiredWidth;
-        height = darwinDesiredHeight;
-    }
-
-    switch (darwinDesiredDepth) {
-        case 0:
-            bpp = 8;
-            break;
-        case 1:
-            bpp = 16;
-            break;
-        case 2:
-            bpp = 32;
-            break;
-        default:
-            bpp = CGDisplayBitsPerPixel(cgID);
-    }
-
-    if (darwinDesiredRefresh == -1) {
-        fsDisplayInfo->xDisplayMode =
-                CGDisplayBestModeForParameters(cgID, bpp, width, height,
-                        &exactMatch);
-    } else {
-        fsDisplayInfo->xDisplayMode =
-                CGDisplayBestModeForParametersAndRefreshRate(cgID, bpp,
-                        width, height, darwinDesiredRefresh, &exactMatch);
-    }
-    if (!exactMatch) {
-        fsDisplayInfo->xDisplayMode = fsDisplayInfo->aquaDisplayMode;
-        return FALSE;
-    }
-
-    // Switch to the new display mode
-    CGDisplaySwitchToMode(cgID, fsDisplayInfo->xDisplayMode);
-    return TRUE;
-}
-
-
-/*
- * FSAddScreen
- *  Do initialization of each screen for Quartz in full screen mode.
- */
-static Bool FSAddScreen(
-    int index,
-    ScreenPtr pScreen)
-{
-    DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen);
-    QuartzScreenPtr displayInfo = QUARTZ_PRIV(pScreen);
-    CGDirectDisplayID cgID = quartzDisplayList[index];
-    CGRect bounds;
-    FSScreenPtr fsDisplayInfo;
-
-    // Allocate space for private per screen fullscreen specific storage.
-    fsDisplayInfo = xalloc(sizeof(FSScreenRec));
-    FULLSCREEN_PRIV(pScreen) = fsDisplayInfo;
-
-    displayInfo->displayCount = 1;
-    displayInfo->displayIDs = xrealloc(displayInfo->displayIDs,
-                                      1 * sizeof(CGDirectDisplayID));
-    displayInfo->displayIDs[0] = cgID;
-
-    fsDisplayInfo->displayID = cgID;
-    fsDisplayInfo->xDisplayMode = 0;
-    fsDisplayInfo->aquaDisplayMode = 0;
-    fsDisplayInfo->xPalette = 0;
-    fsDisplayInfo->aquaPalette = 0;
-
-    // Capture full screen because X doesn't like read-only framebuffer.
-    // We need to do this before we (potentially) switch the display mode.
-    CGDisplayCapture(cgID);
-
-    if (! FSFindDisplayMode(fsDisplayInfo)) {
-        ErrorF("Could not support specified display mode on screen %i.\n",
-               index);
-        xfree(fsDisplayInfo);
-        return FALSE;
-    }
-
-    // Don't need to flip y-coordinate as CoreGraphics treats (0, 0)
-    // as the top left of main screen.
-    bounds = CGDisplayBounds(cgID);
-    dfb->x = bounds.origin.x;
-    dfb->y = bounds.origin.y;
-    dfb->width  = bounds.size.width;
-    dfb->height = bounds.size.height;
-    dfb->pitch = CGDisplayBytesPerRow(cgID);
-    dfb->bitsPerPixel = CGDisplayBitsPerPixel(cgID);
-
-    if (dfb->bitsPerPixel == 8) {
-        if (CGDisplayCanSetPalette(cgID)) {
-            dfb->colorType = PseudoColor;
-        } else {
-            dfb->colorType = StaticColor;
-        }
-        dfb->bitsPerComponent = 8;
-        dfb->colorBitsPerPixel = 8;
-    } else {
-        dfb->colorType = TrueColor;
-        dfb->bitsPerComponent = CGDisplayBitsPerSample(cgID);
-        dfb->colorBitsPerPixel = CGDisplaySamplesPerPixel(cgID) *
-                                 dfb->bitsPerComponent;
-    }
-
-    fsDisplayInfo->framebuffer = CGDisplayBaseAddress(cgID);
-
-    // allocate shadow framebuffer
-    fsDisplayInfo->shadowPtr = xalloc(dfb->pitch * dfb->height);
-    dfb->framebuffer = fsDisplayInfo->shadowPtr;
-
-    return TRUE;
-}
-
-
-/*
- * FSShadowUpdate
- *  Update the damaged regions of the shadow framebuffer on the display.
- */
-static void FSShadowUpdate(
-    ScreenPtr pScreen,
-    shadowBufPtr pBuf)
-{
-    DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen);
-    FSScreenPtr fsDisplayInfo = FULLSCREEN_PRIV(pScreen);
-    RegionPtr damage = &pBuf->damage;
-    int numBox = REGION_NUM_RECTS(damage);
-    BoxPtr pBox = REGION_RECTS(damage);
-    int pitch = dfb->pitch;
-    int bpp = dfb->bitsPerPixel/8;
-
-    // Don't update if the X server is not visible
-    if (!quartzServerVisible)
-        return;
-
-    // Loop through all the damaged boxes
-    while (numBox--) {
-        int width, height, offset;
-        unsigned char *src, *dst;
-
-        width = (pBox->x2 - pBox->x1) * bpp;
-        height = pBox->y2 - pBox->y1;
-        offset = (pBox->y1 * pitch) + (pBox->x1 * bpp);
-        src = fsDisplayInfo->shadowPtr + offset;
-        dst = fsDisplayInfo->framebuffer + offset;
-
-        while (height--) {
-            memcpy(dst, src, width);
-            dst += pitch;
-            src += pitch;
-        }
-
-        // Get the next box
-        pBox++;
-    }
-}
-
-
-/*
- * FSSetupScreen
- *  Finalize full screen specific setup of each screen.
- */
-static Bool FSSetupScreen(
-    int index,
-    ScreenPtr pScreen)
-{
-    DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen);
-    FSScreenPtr fsDisplayInfo = FULLSCREEN_PRIV(pScreen);
-    CGDirectDisplayID cgID = fsDisplayInfo->displayID;
-
-    // Initialize shadow framebuffer support
-    if (! shadowInit(pScreen, FSShadowUpdate, NULL)) {
-        ErrorF("Failed to initalize shadow framebuffer for screen %i.\n",
-               index);
-        return FALSE;
-    }
-
-    if (dfb->colorType == PseudoColor) {
-        // Initialize colormap handling
-        size_t aquaBpp;
-
-        // If Aqua is using 8 bits we need to keep track of its pallete.
-        CFNumberGetValue(CFDictionaryGetValue(fsDisplayInfo->aquaDisplayMode,
-                         kCGDisplayBitsPerPixel), kCFNumberLongType, &aquaBpp);
-        if (aquaBpp <= 8)
-            fsDisplayInfo->aquaPalette = CGPaletteCreateWithDisplay(cgID);
-
-        pScreen->CreateColormap = FSCreateColormap;
-        pScreen->DestroyColormap = FSDestroyColormap;
-        pScreen->InstallColormap = FSInstallColormap;
-        pScreen->StoreColors = FSStoreColors;
-
-    }
-
-    quartzScreens[quartzNumScreens++] = fsDisplayInfo;
-    return TRUE;
-}
-
-
-/*
- * Quartz display mode function list.
- */
-static QuartzModeProcsRec fsModeProcs = {
-    FSDisplayInit,
-    FSAddScreen,
-    FSSetupScreen,
-    NULL,                   // Not needed
-    QuartzInitCursor,
-    QuartzReallySetCursor,
-    FSSuspendScreen,
-    FSResumeScreen,
-    FSCapture,
-    FSRelease,
-    NULL,                   // No dynamic screen change support
-    NULL,
-    NULL,
-    NULL,                   // No rootless code in fullscreen
-    NULL,
-    NULL,
-    NULL,
-    NULL,                   // No support for DRI surfaces
-    NULL
-};
-
-
-/*
- * QuartzModeBundleInit
- *  Initialize the display mode bundle after loading.
- */
-Bool
-QuartzModeBundleInit(void)
-{
-    quartzProcs = &fsModeProcs;
-    quartzOpenGLBundle = NULL;  // Only Mesa support for now
-    return TRUE;
-}
diff --git a/hw/darwin/quartz/fullscreen/quartzCursor.c b/hw/darwin/quartz/fullscreen/quartzCursor.c
deleted file mode 100644
index 3ffa1c3..0000000
--- a/hw/darwin/quartz/fullscreen/quartzCursor.c
+++ /dev/null
@@ -1,654 +0,0 @@
-/**************************************************************
- *
- * Support for using the Quartz Window Manager cursor
- *
- * Copyright (c) 2001-2003 Torrey T. Lyons and Greg Parker.
- *                 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
- * 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "quartz/quartzCommon.h"
-#include "quartz/quartzCursor.h"
-#include "darwin.h"
-
-#include <pthread.h>
-
-#include "mi.h"
-#include "scrnintstr.h"
-#include "cursorstr.h"
-#include "mipointrst.h"
-#include "globals.h"
-
-// Size of the QuickDraw cursor
-#define CURSORWIDTH 16
-#define CURSORHEIGHT 16
-
-typedef struct {
-    int                     qdCursorMode;
-    int                     qdCursorVisible;
-    int                     useQDCursor;
-    QueryBestSizeProcPtr    QueryBestSize;
-    miPointerSpriteFuncPtr  spriteFuncs;
-} QuartzCursorScreenRec, *QuartzCursorScreenPtr;
-
-static int darwinCursorScreenIndex = -1;
-static unsigned long darwinCursorGeneration = 0;
-static CursorPtr quartzLatentCursor = NULL;
-static QD_Cursor gQDArrow; // QuickDraw arrow cursor
-
-// Cursor for the main thread to set (NULL = arrow cursor).
-static CCrsrHandle currentCursor = NULL;
-static pthread_mutex_t cursorMutex;
-static pthread_cond_t cursorCondition;
-
-#define CURSOR_PRIV(pScreen) \
-    ((QuartzCursorScreenPtr)pScreen->devPrivates[darwinCursorScreenIndex].ptr)
-
-#define HIDE_QD_CURSOR(pScreen, visible)                                \
-    if (visible) {                                                      \
-        int ix;                                                         \
-        for (ix = 0; ix < QUARTZ_PRIV(pScreen)->displayCount; ix++) {   \
-            CGDisplayHideCursor(QUARTZ_PRIV(pScreen)->displayIDs[ix]);  \
-        }                                                               \
-        visible = FALSE;                                                \
-    } ((void)0)
-
-#define SHOW_QD_CURSOR(pScreen, visible)                                \
-    {                                                                   \
-        int ix;                                                         \
-        for (ix = 0; ix < QUARTZ_PRIV(pScreen)->displayCount; ix++) {   \
-            CGDisplayShowCursor(QUARTZ_PRIV(pScreen)->displayIDs[ix]);  \
-        }                                                               \
-        visible = TRUE;                                                 \
-    } ((void)0)
-
-#define CHANGE_QD_CURSOR(cursorH)                                       \
-    if (!quartzServerQuitting) {                                        \
-        /* Acquire lock and tell the main thread to change cursor */    \
-        pthread_mutex_lock(&cursorMutex);                               \
-        currentCursor = (CCrsrHandle) (cursorH);                        \
-        QuartzMessageMainThread(kQuartzCursorUpdate, NULL, 0);          \
-                                                                        \
-        /* Wait for the main thread to change the cursor */             \
-        pthread_cond_wait(&cursorCondition, &cursorMutex);              \
-        pthread_mutex_unlock(&cursorMutex);                             \
-    } ((void)0)
-
-
-/*
- * MakeQDCursor helpers: CTAB_ENTER, interleave
- */
-
-// Add a color entry to a ctab
-#define CTAB_ENTER(ctab, index, r, g, b)                                \
-    ctab->ctTable[index].value = index;                                 \
-    ctab->ctTable[index].rgb.red = r;                                   \
-    ctab->ctTable[index].rgb.green = g;                                 \
-    ctab->ctTable[index].rgb.blue = b
-
-// Make an unsigned short by interleaving the bits of bytes c1 and c2.
-// High bit of c1 is first; low bit of c2 is last.
-// Interleave is a built-in INTERCAL operator.
-static unsigned short
-interleave(
-    unsigned char c1,
-    unsigned char c2 )
-{
-    return
-        ((c1 & 0x80) << 8) | ((c2 & 0x80) << 7) |
-        ((c1 & 0x40) << 7) | ((c2 & 0x40) << 6) |
-        ((c1 & 0x20) << 6) | ((c2 & 0x20) << 5) |
-        ((c1 & 0x10) << 5) | ((c2 & 0x10) << 4) |
-        ((c1 & 0x08) << 4) | ((c2 & 0x08) << 3) |
-        ((c1 & 0x04) << 3) | ((c2 & 0x04) << 2) |
-        ((c1 & 0x02) << 2) | ((c2 & 0x02) << 1) |
-        ((c1 & 0x01) << 1) | ((c2 & 0x01) << 0) ;
-}
-
-/*
- * MakeQDCursor
- * Make a QuickDraw color cursor from the given X11 cursor.
- * Warning: This code is nasty. Color cursors were meant to be read
- * from resources; constructing the structures programmatically is messy.
- */
-/*
-    QuickDraw cursor representation:
-    Our color cursor is a 2 bit per pixel pixmap.
-    Each pixel's bits are (source<<1 | mask) from the original X cursor pixel.
-    The cursor's color table maps the colors like this:
-    (2-bit value | X result    | colortable | Mac result)
-             00  | transparent | white      | transparent (white outside mask)
-             01  | back color  | back color | back color
-             10  | undefined   | black      | invert background (just for fun)
-             11  | fore color  | fore color | fore color
-*/
-static CCrsrHandle
-MakeQDCursor(
-    CursorPtr pCursor )
-{
-    CCrsrHandle result;
-    CCrsrPtr curs;
-    int i, w, h;
-    unsigned short rowMask;
-    PixMap *pix;
-    ColorTable *ctab;
-    unsigned short *image;
-
-    result = (CCrsrHandle) NewHandleClear(sizeof(CCrsr));
-    if (!result) return NULL;
-    HLock((Handle)result);
-    curs = *result;
-
-    // Initialize CCrsr
-    curs->crsrType = 0x8001;     // 0x8000 = b&w, 0x8001 = color
-    curs->crsrMap = (PixMapHandle) NewHandleClear(sizeof(PixMap));
-    if (!curs->crsrMap) goto pixAllocFailed;
-    HLock((Handle)curs->crsrMap);
-    pix = *curs->crsrMap;
-    curs->crsrData = NULL;       // raw cursor image data (set below)
-    curs->crsrXData = NULL;      // QD's processed data
-    curs->crsrXValid = 0;        // zero means QD must re-process cursor data
-    curs->crsrXHandle = NULL;    // reserved
-    memset(curs->crsr1Data, 0, CURSORWIDTH*CURSORHEIGHT/8); // b&w data
-    memset(curs->crsrMask,  0, CURSORWIDTH*CURSORHEIGHT/8); // b&w & color mask
-    curs->crsrHotSpot.h = min(CURSORWIDTH,  pCursor->bits->xhot); // hot spot
-    curs->crsrHotSpot.v = min(CURSORHEIGHT, pCursor->bits->yhot); // hot spot
-    curs->crsrXTable = 0;        // reserved
-    curs->crsrID = GetCTSeed();  // unique ID from Color Manager
-
-    // Set the b&w data and mask
-    w = min(pCursor->bits->width,  CURSORWIDTH);
-    h = min(pCursor->bits->height, CURSORHEIGHT);
-    rowMask = ~((1 << (CURSORWIDTH - w)) - 1);
-    for (i = 0; i < h; i++) {
-        curs->crsr1Data[i] = rowMask &
-        ((pCursor->bits->source[i*4]<<8) | pCursor->bits->source[i*4+1]);
-        curs->crsrMask[i] = rowMask &
-        ((pCursor->bits->mask[i*4]<<8)   | pCursor->bits->mask[i*4+1]);
-    }
-
-    // Set the color data and mask
-    // crsrMap: defines bit depth and size and colortable only
-    pix->rowBytes = (CURSORWIDTH * 2 / 8) | 0x8000; // last bit on means PixMap
-    SetRect(&pix->bounds, 0, 0, CURSORWIDTH, CURSORHEIGHT); // see TN 1020
-    pix->pixelSize = 2;
-    pix->cmpCount = 1;
-    pix->cmpSize = 2;
-    // pix->pmTable set below
-
-    // crsrData is the pixel data. crsrMap's baseAddr is not used.
-    curs->crsrData = NewHandleClear(CURSORWIDTH*CURSORHEIGHT * 2 / 8);
-    if (!curs->crsrData) goto imageAllocFailed;
-    HLock((Handle)curs->crsrData);
-    image = (unsigned short *) *curs->crsrData;
-    // Pixel data is just 1-bit data and mask interleaved (see above)
-    for (i = 0; i < h; i++) {
-        unsigned char s, m;
-        s = pCursor->bits->source[i*4] & (rowMask >> 8);
-        m = pCursor->bits->mask[i*4] & (rowMask >> 8);
-        image[2*i] = interleave(s, m);
-        s = pCursor->bits->source[i*4+1] & (rowMask & 0x00ff);
-        m = pCursor->bits->mask[i*4+1] & (rowMask & 0x00ff);
-        image[2*i+1] = interleave(s, m);
-    }
-
-    // Build the color table (entries described above)
-    // NewPixMap allocates a color table handle.
-    pix->pmTable = (CTabHandle) NewHandleClear(sizeof(ColorTable) + 3
-                    * sizeof(ColorSpec));
-    if (!pix->pmTable) goto ctabAllocFailed;
-    HLock((Handle)pix->pmTable);
-    ctab = *pix->pmTable;
-    ctab->ctSeed = GetCTSeed();
-    ctab->ctFlags = 0;
-    ctab->ctSize = 3; // color count - 1
-    CTAB_ENTER(ctab, 0, 0xffff, 0xffff, 0xffff);
-    CTAB_ENTER(ctab, 1, pCursor->backRed, pCursor->backGreen,
-               pCursor->backBlue);
-    CTAB_ENTER(ctab, 2, 0x0000, 0x0000, 0x0000);
-    CTAB_ENTER(ctab, 3, pCursor->foreRed, pCursor->foreGreen,
-               pCursor->foreBlue);
-
-    HUnlock((Handle)pix->pmTable); // ctab
-    HUnlock((Handle)curs->crsrData); // image data
-    HUnlock((Handle)curs->crsrMap); // pix
-    HUnlock((Handle)result); // cursor
-
-    return result;
-
-    // "What we have here is a failure to allocate"
-ctabAllocFailed:
-    HUnlock((Handle)curs->crsrData);
-    DisposeHandle((Handle)curs->crsrData);
-imageAllocFailed:
-    HUnlock((Handle)curs->crsrMap);
-    DisposeHandle((Handle)curs->crsrMap);
-pixAllocFailed:
-    HUnlock((Handle)result);
-    DisposeHandle((Handle)result);
-    return NULL;
-}
-
-
-/*
- * FreeQDCursor
- * Destroy a QuickDraw color cursor created with MakeQDCursor().
- * The cursor must not currently be on screen.
- */
-static void FreeQDCursor(CCrsrHandle cursHandle)
-{
-    CCrsrPtr curs;
-    PixMap *pix;
-
-    HLock((Handle)cursHandle);
-    curs = *cursHandle;
-    HLock((Handle)curs->crsrMap);
-    pix = *curs->crsrMap;
-    DisposeHandle((Handle)pix->pmTable);
-    HUnlock((Handle)curs->crsrMap);
-    DisposeHandle((Handle)curs->crsrMap);
-    DisposeHandle((Handle)curs->crsrData);
-    HUnlock((Handle)cursHandle);
-    DisposeHandle((Handle)cursHandle);
-}
-
-
-/*
-===========================================================================
-
- Pointer sprite functions
-
-===========================================================================
-*/
-
-/*
- * QuartzRealizeCursor
- * Convert the X cursor representation to QuickDraw format if possible.
- */
-Bool
-QuartzRealizeCursor(
-    ScreenPtr pScreen,
-    CursorPtr pCursor )
-{
-    CCrsrHandle qdCursor;
-    QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
-
-    if(!pCursor || !pCursor->bits)
-        return FALSE;
-
-    // if the cursor is too big we use a software cursor
-    if ((pCursor->bits->height > CURSORHEIGHT) ||
-        (pCursor->bits->width > CURSORWIDTH) || !ScreenPriv->useQDCursor)
-    {
-        if (quartzRootless) {
-            // rootless can't use a software cursor
-            return TRUE;
-        } else {
-            return (*ScreenPriv->spriteFuncs->RealizeCursor)
-                        (pScreen, pCursor);
-        }
-    }
-
-    // make new cursor image
-    qdCursor = MakeQDCursor(pCursor);
-    if (!qdCursor) return FALSE;
-
-    // save the result
-    pCursor->devPriv[pScreen->myNum] = (pointer) qdCursor;
-
-    return TRUE;
-}
-
-
-/*
- * QuartzUnrealizeCursor
- * Free the storage space associated with a realized cursor.
- */
-Bool
-QuartzUnrealizeCursor(
-    ScreenPtr pScreen,
-    CursorPtr pCursor )
-{
-    QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
-
-    if ((pCursor->bits->height > CURSORHEIGHT) ||
-        (pCursor->bits->width > CURSORWIDTH) || !ScreenPriv->useQDCursor)
-    {
-        if (quartzRootless) {
-            return TRUE;
-        } else {
-            return (*ScreenPriv->spriteFuncs->UnrealizeCursor)
-                        (pScreen, pCursor);
-        }
-    } else {
-        CCrsrHandle oldCursor = (CCrsrHandle) pCursor->devPriv[pScreen->myNum];
-
-        if (currentCursor != oldCursor) {
-            // This should only fail when quitting, in which case we just leak.
-            FreeQDCursor(oldCursor);
-        }
-        pCursor->devPriv[pScreen->myNum] = NULL;
-        return TRUE;
-    }
-}
-
-
-/*
- * QuartzSetCursor
- * Set the cursor sprite and position.
- * Use QuickDraw cursor if possible.
- */
-static void
-QuartzSetCursor(
-    ScreenPtr       pScreen,
-    CursorPtr       pCursor,
-    int             x,
-    int             y)
-{
-    QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
-
-    quartzLatentCursor = pCursor;
-
-    // Don't touch Mac OS cursor if X is hidden!
-    if (!quartzServerVisible)
-        return;
-
-    if (!pCursor) {
-        // Remove the cursor completely.
-        HIDE_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
-        if (! ScreenPriv->qdCursorMode)
-            (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, 0, x, y);
-    }
-    else if ((pCursor->bits->height <= CURSORHEIGHT) &&
-             (pCursor->bits->width <= CURSORWIDTH) && ScreenPriv->useQDCursor)
-    {
-        // Cursor is small enough to use QuickDraw directly.
-        if (! ScreenPriv->qdCursorMode)    // remove the X cursor
-            (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, 0, x, y);
-        ScreenPriv->qdCursorMode = TRUE;
-
-        CHANGE_QD_CURSOR(pCursor->devPriv[pScreen->myNum]);
-        SHOW_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
-    }
-    else if (quartzRootless) {
-        // Rootless can't use a software cursor, so we just use Mac OS arrow.
-        CHANGE_QD_CURSOR(NULL);
-        SHOW_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
-    }
-    else {
-        // Cursor is too big for QuickDraw. Use X software cursor.
-        HIDE_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
-        ScreenPriv->qdCursorMode = FALSE;
-        (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, pCursor, x, y);
-    }
-}
-
-
-/*
- * QuartzReallySetCursor
- * Set the QuickDraw cursor. Called from the main thread since changing the
- * cursor with QuickDraw is not thread safe on dual processor machines.
- */
-void
-QuartzReallySetCursor()
-{
-    pthread_mutex_lock(&cursorMutex);
-
-    if (currentCursor) {
-        SetCCursor(currentCursor);
-    } else {
-        SetCursor(&gQDArrow);
-    }
-
-    pthread_cond_signal(&cursorCondition);
-    pthread_mutex_unlock(&cursorMutex);
-}
-
-
-/*
- * QuartzMoveCursor
- * Move the cursor. This is a noop for QuickDraw.
- */
-static void
-QuartzMoveCursor(
-    ScreenPtr   pScreen,
-    int         x,
-    int         y)
-{
-    QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
-
-    // only the X cursor needs to be explicitly moved
-    if (!ScreenPriv->qdCursorMode)
-        (*ScreenPriv->spriteFuncs->MoveCursor)(pScreen, x, y);
-}
-
-
-static miPointerSpriteFuncRec quartzSpriteFuncsRec = {
-    QuartzRealizeCursor,
-    QuartzUnrealizeCursor,
-    QuartzSetCursor,
-    QuartzMoveCursor
-};
-
-
-/*
-===========================================================================
-
- Pointer screen functions
-
-===========================================================================
-*/
-
-/*
- * QuartzCursorOffScreen
- */
-static Bool QuartzCursorOffScreen(ScreenPtr *pScreen, int *x, int *y)
-{
-    return FALSE;
-}
-
-
-/*
- * QuartzCrossScreen
- */
-static void QuartzCrossScreen(ScreenPtr pScreen, Bool entering)
-{
-    return;
-}
-
-
-/*
- * QuartzWarpCursor
- *  Change the cursor position without generating an event or motion history.
- *  The input coordinates (x,y) are in pScreen-local X11 coordinates.
- *
- */
-static void
-QuartzWarpCursor(
-    ScreenPtr               pScreen,
-    int                     x,
-    int                     y)
-{
-    static int              neverMoved = TRUE;
-
-    if (neverMoved) {
-        // Don't move the cursor the first time. This is the jump-to-center
-        // initialization, and it's annoying because we may still be in MacOS.
-        neverMoved = FALSE;
-        return;
-    }
-
-    if (quartzServerVisible) {
-        CGDisplayErr        cgErr;
-        CGPoint             cgPoint;
-        // Only need to do this for one display. Any display will do.
-        CGDirectDisplayID   cgID = QUARTZ_PRIV(pScreen)->displayIDs[0];
-        CGRect              cgRect = CGDisplayBounds(cgID);
-
-        // Convert (x,y) to CoreGraphics screen-local CG coordinates.
-        // This is necessary because the X11 screen and CG screen may not
-        // coincide. (e.g. X11 screen may be moved to dodge the menu bar)
-
-        // Make point in X11 global coordinates
-        cgPoint = CGPointMake(x + dixScreenOrigins[pScreen->myNum].x,
-                              y + dixScreenOrigins[pScreen->myNum].y);
-        // Shift to CoreGraphics global screen coordinates
-        cgPoint.x += darwinMainScreenX;
-        cgPoint.y += darwinMainScreenY;
-        // Shift to CoreGraphics screen-local coordinates
-        cgPoint.x -= cgRect.origin.x;
-        cgPoint.y -= cgRect.origin.y;
-
-        cgErr = CGDisplayMoveCursorToPoint(cgID, cgPoint);
-        if (cgErr != CGDisplayNoErr) {
-            ErrorF("Could not set cursor position with error code 0x%x.\n",
-                    cgErr);
-        }
-    }
-
-    miPointerWarpCursor(pScreen, x, y);
-    miPointerUpdate();
-}
-
-
-static miPointerScreenFuncRec quartzScreenFuncsRec = {
-    QuartzCursorOffScreen,
-    QuartzCrossScreen,
-    QuartzWarpCursor,
-    DarwinEQPointerPost,
-    DarwinEQSwitchScreen
-};
-
-
-/*
-===========================================================================
-
- Other screen functions
-
-===========================================================================
-*/
-
-/*
- * QuartzCursorQueryBestSize
- * Handle queries for best cursor size
- */
-static void
-QuartzCursorQueryBestSize(
-   int              class,
-   unsigned short   *width,
-   unsigned short   *height,
-   ScreenPtr        pScreen)
-{
-    QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
-
-    if (class == CursorShape) {
-        *width = CURSORWIDTH;
-        *height = CURSORHEIGHT;
-    } else {
-        (*ScreenPriv->QueryBestSize)(class, width, height, pScreen);
-    }
-}
-
-
-/*
- * QuartzInitCursor
- * Initialize cursor support
- */
-Bool
-QuartzInitCursor(
-    ScreenPtr   pScreen )
-{
-    QuartzCursorScreenPtr   ScreenPriv;
-    miPointerScreenPtr      PointPriv;
-    DarwinFramebufferPtr    dfb = SCREEN_PRIV(pScreen);
-
-    // initialize software cursor handling (always needed as backup)
-    if (!miDCInitialize(pScreen, &quartzScreenFuncsRec)) {
-        return FALSE;
-    }
-
-    // allocate private storage for this screen's QuickDraw cursor info
-    if (darwinCursorGeneration != serverGeneration) {
-        if ((darwinCursorScreenIndex = AllocateScreenPrivateIndex()) < 0)
-            return FALSE;
-        darwinCursorGeneration = serverGeneration;
-    }
-
-    ScreenPriv = xcalloc( 1, sizeof(QuartzCursorScreenRec) );
-    if (!ScreenPriv) return FALSE;
-
-    CURSOR_PRIV(pScreen) = ScreenPriv;
-
-    // override some screen procedures
-    ScreenPriv->QueryBestSize = pScreen->QueryBestSize;
-    pScreen->QueryBestSize = QuartzCursorQueryBestSize;
-
-    // initialize QuickDraw cursor handling
-    GetQDGlobalsArrow(&gQDArrow);
-    PointPriv = (miPointerScreenPtr)
-                    pScreen->devPrivates[miPointerScreenIndex].ptr;
-
-    ScreenPriv->spriteFuncs = PointPriv->spriteFuncs;
-    PointPriv->spriteFuncs = &quartzSpriteFuncsRec;
-
-    if (!quartzRootless)
-        ScreenPriv->useQDCursor = QuartzFSUseQDCursor(dfb->colorBitsPerPixel);
-    else
-        ScreenPriv->useQDCursor = TRUE;
-    ScreenPriv->qdCursorMode = TRUE;
-    ScreenPriv->qdCursorVisible = TRUE;
-
-    // initialize cursor mutex lock
-    pthread_mutex_init(&cursorMutex, NULL);
-
-    // initialize condition for waiting
-    pthread_cond_init(&cursorCondition, NULL);
-
-    return TRUE;
-}
-
-
-// X server is hiding. Restore the Aqua cursor.
-void QuartzSuspendXCursor(
-    ScreenPtr pScreen )
-{
-    QuartzCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
-
-    CHANGE_QD_CURSOR(NULL);
-    SHOW_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible);
-}
-
-
-// X server is showing. Restore the X cursor.
-void QuartzResumeXCursor(
-    ScreenPtr pScreen,
-    int x,
-    int y )
-{
-    QuartzSetCursor(pScreen, quartzLatentCursor, x, y);
-}
diff --git a/hw/darwin/quartz/fullscreen/quartzCursor.h b/hw/darwin/quartz/fullscreen/quartzCursor.h
deleted file mode 100644
index 56a0209..0000000
--- a/hw/darwin/quartz/fullscreen/quartzCursor.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * quartzCursor.h
- *
- * External interface for Quartz hardware cursor
- *
- * Copyright (c) 2001 Torrey T. Lyons and Greg Parker.
- *                 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
- * 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 QUARTZCURSOR_H
-#define QUARTZCURSOR_H
-
-#include "screenint.h"
-
-Bool QuartzInitCursor(ScreenPtr pScreen);
-void QuartzReallySetCursor(void);
-void QuartzSuspendXCursor(ScreenPtr pScreen);
-void QuartzResumeXCursor(ScreenPtr pScreen, int x, int y);
-
-#endif
diff --git a/hw/darwin/utils/Makefile.am b/hw/darwin/utils/Makefile.am
deleted file mode 100644
index 911e14d..0000000
--- a/hw/darwin/utils/Makefile.am
+++ /dev/null
@@ -1,11 +0,0 @@
-bin_PROGRAMS = dumpkeymap
-
-dumpkeymap_SOURCES = dumpkeymap.c
-
-dumpkeymap_LDFLAGS = -Wl,-framework,IOKit
-
-man1_MANS = dumpkeymap.man
-
-EXTRA_DIST = \
-	     README.txt \
-	     dumpkeymap.man
diff --git a/hw/darwin/utils/README.txt b/hw/darwin/utils/README.txt
deleted file mode 100644
index 1dd6479..0000000
--- a/hw/darwin/utils/README.txt
+++ /dev/null
@@ -1,107 +0,0 @@
-dumpkeymap - Diagnostic dump and detailed description of .keymapping files
-Version 4
-
-Copyright (C)1999,2000 by Eric Sunshine <sunshine at sunshineco.com>
-Eric Sunshine, 1 December 2000
-
-OVERVIEW
-========
-This package contains the diagnostic utility dumpkeymap, as well as highly
-detailed documentation describing the internal layout of the Apple/NeXT
-.keymapping file.
-
-The dumpkeymap utility displays detailed information about each .keymapping
-file mentioned on the command-line.  On Apple and NeXT platforms, if no
-.keymapping files are mentioned on the command-line, then it will instead
-dissect the key mapping currently in use by the WindowServer and AppKit.
-
-Documentation includes a thorough and detailed description of the internal
-layout of the .keymapping file, as well as an explanation of how to interpret
-the output of dumpkeymap.
-
-The complete set of documentation is available for perusal via dumpkeymap's
-manual page (dumpkeymap.1), as well as via the command-line options described
-below.
-
-    --help
-	Usage summary.
-    --help-keymapping
-	Detailed discussion of the internal format of a .keymapping file.
-    --help-output
-	Explanation of dumpkeymap's output.
-    --help-files
-	List of key mapping-related files and directories.
-    --help-diagnostics
-	Explanation of diagnostic messages.
-
-Once the manual page is been installed, documentation can also be accessed
-with the Unix `man' command:
-
-    % man dumpkeymap
-
-
-COMPILATION
-===========
-MacOS/X, Darwin
-
-    cc -Wall -o dumpkeymap dumpkeymap.c -framework IOKit
-
-MacOS/X DP4 (Developer Preview 4)
-
-    cc -Wall -o dumpkeymap dumpkeymap.c -FKernel -framework IOKit
-
-MacOS/X Server, OpenStep, NextStep
-
-    cc -Wall -o dumpkeymap dumpkeymap.c
-
-By default, dumpkeymap is configured to interface with the HID driver (Apple)
-or event-status driver (NeXT), thus allowing it to dump the key mapping which
-is currently in use by the WindowServer and AppKit.  However, these facilities
-are specific to Apple/NeXT.  In order to build dumpkeymap for non-Apple/NeXT
-platforms, you must define the DUMPKEYMAP_FILE_ONLY flag when compiling the
-program.  This flag inhibits use of the HID and event-status drivers and
-configures dumpkeymap to work strictly with raw key mapping files.
-
-For example, to compile for Linux:
-
-    gcc -Wall -DDUMPKEYMAP_FILE_ONLY -o dumpkeymap dumpkeymap.c
-
-
-INSTALLATION
-============
-Install the dumpkeymap executable image in a location mentioned in the PATH
-environment variable.  Typicall locations for executable files are:
-
-    /usr/local/bin
-    $(HOME)/bin
-
-Install the manual page, dumpkeymap.1, in the `man1' subdirectory one of the
-standard manual page locations or in any other location mentioned by the
-MANPATH environment variable.
-
-Typical locations for manual pages on most Unix platforms are:
-
-    /usr/local/man/man1
-
-Typical locations for manual pages on MacOS/X, Darwin, and MacOS/X Server are:
-
-    /usr/local/man/man1
-    /Local/Documentation/ManPages/man1
-    /Network/Documentation/ManPages/man1
-
-Typical locations for manual pages on OpenStep and NextStep are:
-
-    /usr/local/man/man1
-    /LocalLibrary/Documentation/ManPages/man1
-    /LocalDeveloper/Documentation/ManPages/man1
-
-
-CONCLUSION
-==========
-This program and its accompanying documentation were written by Eric Sunshine
-and are copyright (C)1999,2000 by Eric Sunshine <sunshine at sunshineco.com>.
-
-The implementation of dumpkeymap is based upon information gathered on
-September 3, 1997 by Eric Sunshine <sunshine at sunshineco.com> and Paul S.
-McCarthy <zarnuk at zarnuk.com> during an effort to reverse engineer the format
-of the NeXT .keymapping file.
diff --git a/hw/darwin/utils/dumpkeymap.c b/hw/darwin/utils/dumpkeymap.c
deleted file mode 100644
index 0c8bdcd..0000000
--- a/hw/darwin/utils/dumpkeymap.c
+++ /dev/null
@@ -1,1453 +0,0 @@
-//=============================================================================
-//
-// Copyright (C) 1999,2000 by Eric Sunshine <sunshine at sunshineco.com>
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-//   1. Redistributions of source code must retain the above copyright
-//      notice, this list of conditions and the following disclaimer.
-//   2. Redistributions in binary form must reproduce the above copyright
-//      notice, this list of conditions and the following disclaimer in the
-//      documentation and/or other materials provided with the distribution.
-//   3. The name of the author may not be used to endorse or promote products
-//      derived from this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
-// NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
-// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-//=============================================================================
-//-----------------------------------------------------------------------------
-// dumpkeymap.c
-//
-//	Prints a textual representation of each Apple/NeXT .keymapping file
-//	mentioned on the command-line.  If no files are mentioned and if the
-//	local machine is an Apple or NeXT installation, then the key mapping
-//	currently in use by the WindowServer and the AppKit is printed
-//	instead.
-//
-//	Invoke dumpkeymap with one of the options listed below in order to
-//	view detailed documentation about .keymapping files and the use of
-//	this program.
-//
-//	--help: Usage summary.
-//	--help-keymapping: Detailed discussion of the internal format of a
-//	    .keymapping file.
-//	--help-output: Explanation of dumpkeymap's output.
-//	--help-files: List of key mapping-related files and directories.
-//	--help-diagnostics: Explanation of diagnostic messages.
-//
-// COMPILATION INSTRUCTIONS
-//
-//	MacOS/X, Darwin
-//	cc -Wall -o dumpkeymap dumpkeymap.c -framework IOKit
-//
-//	MacOS/X DP4 (Developer Preview 4)
-//	cc -Wall -o dumpkeymap dumpkeymap.c -FKernel -framework IOKit
-//
-//	MacOS/X Server, OpenStep, NextStep
-//	cc -Wall -o dumpkeymap dumpkeymap.c
-//
-//	By default, dumpkeymap is configured to interface with the HID driver
-//	(Apple) or event-status driver (NeXT), thus allowing it to dump the
-//	key mapping which is currently in use by the WindowServer and AppKit.
-//	However, these facilities are specific to Apple/NeXT.  In order to
-//	build dumpkeymap for non-Apple/NeXT platforms, you must define the
-//	DUMPKEYMAP_FILE_ONLY flag when compiling the program.  This flag
-//	inhibits use of the HID and event-status drivers and configures
-//	dumpkeymap to work strictly with raw key mapping files.
-//
-//	For example, to compile for Linux:
-//	gcc -Wall -DDUMPKEYMAP_FILE_ONLY -o dumpkeymap dumpkeymap.c
-//
-// CONCLUSION
-//
-//	This program and its accompanying documentation were written by Eric
-//	Sunshine and are copyright (C)1999,2000 by Eric Sunshine
-//	<sunshine at sunshineco.com>.
-//
-//	The implementation of dumpkeymap is based upon information gathered
-//	on September 3, 1997 by Eric Sunshine <sunshine at sunshineco.com> and
-//	Paul S. McCarthy <zarnuk at zarnuk.com> during an effort to reverse
-//	engineer the format of the NeXT .keymapping file.
-//
-// HISTORY
-//
-//	v4 2000/12/01 Eric Sunshine <sunshine at sunshineco.com>
-//	    Updated manual page to work with `rman', the `man' to `HTML'
-//		translator.  Unfortunately, however, rman is missing important
-//		roff features such as diversions, indentation, and tab stops,
-//		and is also hideously buggy, so getting the manual to work with
-//		rman required quite a few work-arounds.
-//	    The manual page has now been tested with nroff (plain text), troff
-//		(PostScript, etc.), groff (PostScript), and rman (HTML, etc.)
-//
-//	v3 2000/11/28 Eric Sunshine <sunshine at sunshineco.com>
-//	    Considerably expanded the documentation.
-//	    Augmented the existing description of .keymapping internals.
-//	    Added these new documentation topics:
-//		- Output: Very important section describing how to interpret
-//		  the output of dumpkeymap.
-//		- Files: Lists files and directories related to key mappings.
-//		- Diagnostics: Explains diagnostic messages issued by
-//		  dumpkeymap.
-//	    Created a manual page (dumpkeymap.1) which contains the complete
-//		set of documentation for key mapping files and dumpkeymap.
-//	    Added command-line options (--help, --help-keymapping,
-//		--help-output, --help-files, --help-diagnostics) which allow
-//		access to all key mapping documentation.  Previously the
-//		description of the internal layout of a .keymapping file was
-//		only available as source code comments.
-//	    Added --version option.
-//	    Ported to non-Apple/NeXT platforms.  Defining the pre-processor
-//		flag DUMPKEYMAP_FILE_ONLY at compilation time inhibits use of
-//		Apple/NeXT-specific API.
-//	    Added a README file.
-//
-//	v2 2000/11/13 Eric Sunshine <sunshine at sunshineco.com>
-//	    Converted from C++ to plain-C.
-//	    Now parses and takes into account the "number-size" flag stored
-//		with each key map.  This flag indicates the size, in bytes, of
-//		all remaining numeric values in the mapping.  Updated all code
-//		to respect this flag.  (Previously, the purpose of this field
-//		was unknown, and it was thus denoted as
-//		`KeyMapping::fill[2]'.)
-//	    Updated all documentation; especially the "KEY MAPPING
-//		DESCRIPTION" section.  Added discussion of the "number-size"
-//		flag and revamped all structure definitions to use the generic
-//		data type `number' instead of `uchar' or 'byte'.  Clarified
-//		several sections of the documentation and added missing
-//		discussions about type definitions and the relationship of
-//		`interface' and `handler_id' to .keymapping and .keyboard
-//		files.
-//	    Updated compilation instructions to include directions for all
-//		platforms on which this program might be built.
-//	    Now published under the formal BSD license rather than a
-//		home-grown license.
-//
-//	v1 1999/09/08 Eric Sunshine <sunshine at sunshineco.com>
-//	    Created.
-//-----------------------------------------------------------------------------
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-#if !defined(DUMPKEYMAP_FILE_ONLY)
-#include <IOKit/hidsystem/event_status_driver.h>
-#endif
-
-#define PROG_NAME "dumpkeymap"
-#define PROG_VERSION "4"
-#define AUTHOR_NAME "Eric Sunshine"
-#define AUTHOR_EMAIL "sunshine at sunshineco.com"
-#define AUTHOR_INFO AUTHOR_NAME " <" AUTHOR_EMAIL ">"
-#define COPYRIGHT "Copyright (C) 1999,2000 by " AUTHOR_INFO
-
-typedef unsigned char byte;
-typedef unsigned short word;
-typedef unsigned int natural;
-typedef unsigned long dword;
-typedef dword number;
-
-#define ASCII_SET 0x00
-#define BIND_FUNCTION 0xfe
-#define BIND_SPECIAL 0xff
-
-#define OPT_SWITCH(X) { char const* switched_str__=(X); if (0) {
-#define OPT_CASE(X,Y) } else if (strcmp(switched_str__,(#X)) == 0 || \
-    strcmp(switched_str__,(#Y)) == 0) {
-#define OPT_DEFAULT } else {
-#define OPT_SWITCH_END }}
-
-//-----------------------------------------------------------------------------
-// Translation Tables
-//-----------------------------------------------------------------------------
-static char const* const SPECIAL_CODE[] =
-    {
-    "sound-up",
-    "sound-down",
-    "brightness-up",
-    "brightness-down",
-    "alpha-lock",
-    "help",
-    "power",
-    "secondary-up-arrow",
-    "secondary-down-arrow"
-    };
-#define N_SPECIAL_CODE (sizeof(SPECIAL_CODE) / sizeof(SPECIAL_CODE[0]))
-
-static char const* const MODIFIER_CODE[] =
-    {
-    "alpha-lock",
-    "shift",
-    "control",
-    "alternate",
-    "command",
-    "keypad",
-    "help"
-    };
-#define N_MODIFIER_CODE (sizeof(MODIFIER_CODE) / sizeof(MODIFIER_CODE[0]))
-
-static char const* const MODIFIER_MASK[] =
-    {
-    "-----",	// R = carriage-return
-    "----L",	// A = alternate
-    "---S-",	// C = control
-    "---SL",	// S = shift
-    "--C--",	// L = alpha-lock
-    "--C-L",
-    "--CS-",
-    "--CSL",
-    "-A---",
-    "-A--L",
-    "-A-S-",
-    "-A-SL",
-    "-AC--",
-    "-AC-L",
-    "-ACS-",
-    "-ACSL",
-    "R----",
-    "R---L",
-    "R--S-",
-    "R--SL",
-    "R-C--",
-    "R-C-L",
-    "R-CS-",
-    "R-CSL",
-    "RA---",
-    "RA--L",
-    "RA-S-",
-    "RA-SL",
-    "RAC--",
-    "RAC-L",
-    "RACS-",
-    "RACSL",
-    };
-#define N_MODIFIER_MASK (sizeof(MODIFIER_MASK) / sizeof(MODIFIER_MASK[0]))
-
-#define FUNCTION_KEY_FIRST 0x20
-static char const* const FUNCTION_KEY[] =
-    {
-    "F1",			// 0x20
-    "F2",			// 0x21
-    "F3",			// 0x22
-    "F4",			// 0x23
-    "F5",			// 0x24
-    "F6",			// 0x25
-    "F7",			// 0x26
-    "F8",			// 0x27
-    "F9",			// 0x28
-    "F10",			// 0x29
-    "F11",			// 0x2a
-    "F12",			// 0x2b
-    "insert",			// 0x2c
-    "delete",			// 0x2d
-    "home",			// 0x2e
-    "end",			// 0x2f
-    "page up",			// 0x30
-    "page down",		// 0x31
-    "print screen",		// 0x32
-    "scroll lock",		// 0x33
-    "pause",			// 0x34
-    "sys-request",		// 0x35
-    "break",			// 0x36
-    "reset (HIL)",		// 0x37
-    "stop (HIL)",		// 0x38
-    "menu (HIL)",		// 0x39
-    "user (HIL)",		// 0x3a
-    "system (HIL)",		// 0x3b
-    "print (HIL)",		// 0x3c
-    "clear line (HIL)",		// 0x3d
-    "clear display (HIL)",	// 0x3e
-    "insert line (HIL)",	// 0x3f
-    "delete line (HIL)",	// 0x40
-    "insert char (HIL)",	// 0x41
-    "delete char (HIL)",	// 0x42
-    "prev (HIL)",		// 0x43
-    "next (HIL)",		// 0x44
-    "select (HIL)",		// 0x45
-    };
-#define N_FUNCTION_KEY (sizeof(FUNCTION_KEY) / sizeof(FUNCTION_KEY[0]))
-
-
-//-----------------------------------------------------------------------------
-// Data Stream Object
-//	Can be configured to treat embedded "numbers" as being composed of
-//	either 1, 2, or 4 bytes, apiece.
-//-----------------------------------------------------------------------------
-typedef struct _DataStream
-    {
-    byte const* data;
-    byte const* data_end;
-    natural number_size; // Size in bytes of a "number" in the stream.
-    } DataStream;
-
-static DataStream* new_data_stream( byte const* data, int size )
-    {
-    DataStream* s = (DataStream*)malloc( sizeof(DataStream) );
-    s->data = data;
-    s->data_end = data + size;
-    s->number_size = 1; // Default to byte-sized numbers.
-    return s;
-    }
-
-static void destroy_data_stream( DataStream* s )
-    {
-    free(s);
-    }
-
-static int end_of_stream( DataStream* s )
-    {
-    return (s->data >= s->data_end);
-    }
-
-static void expect_nbytes( DataStream* s, int nbytes )
-    {
-    if (s->data + nbytes > s->data_end)
-	{
-	fputs( "Insufficient data in keymapping data stream.\n", stderr );
-	exit(-1);
-	}
-    }
-
-static byte get_byte( DataStream* s )
-    {
-    expect_nbytes( s, 1 );
-    return *s->data++;
-    }
-
-static word get_word( DataStream* s )
-    {
-    word hi, lo;
-    expect_nbytes( s, 2 );
-    hi = *s->data++;
-    lo = *s->data++;
-    return ((hi << 8) | lo);
-    }
-
-static dword get_dword( DataStream* s )
-    {
-    dword b1, b2, b3, b4;
-    expect_nbytes( s, 4 );
-    b4 = *s->data++;
-    b3 = *s->data++;
-    b2 = *s->data++;
-    b1 = *s->data++;
-    return ((b4 << 24) | (b3 << 16) | (b2 << 8) | b1);
-    }
-
-static number get_number( DataStream* s )
-    {
-    switch (s->number_size)
-	{
-	case 4:  return get_dword(s);
-	case 2:  return get_word(s);
-	default: return get_byte(s);
-	}
-    }
-
-
-//-----------------------------------------------------------------------------
-// Translation Utility Functions
-//-----------------------------------------------------------------------------
-static char const* special_code_desc( number n )
-    {
-    if (n < N_SPECIAL_CODE)
-	return SPECIAL_CODE[n];
-    else
-	return "invalid";
-    }
-
-static char const* modifier_code_desc( number n )
-    {
-    if (n < N_MODIFIER_CODE)
-	return MODIFIER_CODE[n];
-    else
-	return "invalid";
-    }
-
-static char const* modifier_mask_desc( number n )
-    {
-    if (n < N_MODIFIER_MASK)
-	return MODIFIER_MASK[n];
-    else
-	return "?????";
-    }
-
-static char const* function_key_desc( number n )
-    {
-    if (n >= FUNCTION_KEY_FIRST && n < N_FUNCTION_KEY + FUNCTION_KEY_FIRST)
-	return FUNCTION_KEY[ n - FUNCTION_KEY_FIRST ];
-    else
-	return "unknown";
-    }
-
-static number bits_set( number mask )
-    {
-    number n = 0;
-    for ( ; mask != 0; mask >>= 1)
-	if ((mask & 0x01) != 0)
-	    n++;
-    return n;
-    }
-
-
-//-----------------------------------------------------------------------------
-// Unparse a list of Modifier records.
-//-----------------------------------------------------------------------------
-static void unparse_modifiers( DataStream* s )
-    {
-    number nmod = get_number(s); // Modifier count
-    printf( "MODIFIERS [%lu]\n", nmod );
-    while (nmod-- > 0)
-	{
-	number nscan;
-	number const code = get_number(s);
-	printf( "%s:", modifier_code_desc(code) );
-	nscan = get_number(s);
-	while (nscan-- > 0)
-	    printf( " 0x%02x", (natural)get_number(s) );
-	putchar( '\n' );
-	}
-    putchar( '\n' );
-    }
-
-
-//-----------------------------------------------------------------------------
-// Unparse a list of Character records.
-//-----------------------------------------------------------------------------
-typedef void (*UnparseSpecialFunc)( number code );
-
-static void unparse_char_codes(
-    DataStream* s, number ncodes, UnparseSpecialFunc unparse_special )
-    {
-    if (ncodes != 0)
-	{
-	while (ncodes-- > 0)
-	    {
-	    number const char_set = get_number(s);
-	    number const code = get_number(s);
-	    putchar(' ');
-	    switch (char_set)
-		{
-		case ASCII_SET:
-		    {
-		    int const c = (int)code;
-		    if (isprint(c))
-			printf( "\"%c\"", c );
-		    else if (code < ' ')
-			printf( "\"^%c\"", c + '@' );
-		    else
-			printf( "%02x", c );
-		    break;
-		    }
-		case BIND_FUNCTION:
-		    printf( "[%s]", function_key_desc(code) );
-		    break;
-		case BIND_SPECIAL:
-		    unparse_special( code );
-		    break;
-		default:
-		    printf( "%02x/%02x", (natural)char_set, (natural)code );
-		    break;
-		}
-	    }
-	}
-    }
-
-
-//-----------------------------------------------------------------------------
-// Unparse a list of scan code bindings.
-//-----------------------------------------------------------------------------
-static void unparse_key_special( number code )
-    {
-    printf( "{seq#%lu}", code );
-    }
-
-static void unparse_characters( DataStream* s )
-    {
-    number const NOT_BOUND = 0xff;
-    number const nscans = get_number(s);
-    number scan;
-    printf( "CHARACTERS [%lu]\n", nscans );
-    for (scan = 0; scan < nscans; scan++)
-	{
-	number const mask = get_number(s);
-	printf( "scan 0x%02x: ", (natural)scan );
-	if (mask == NOT_BOUND)
-	    fputs( "not-bound\n", stdout );
-	else
-	    {
-	    number const bits = bits_set( mask );
-	    number const codes = 1 << bits;
-	    printf( "%s ", modifier_mask_desc(mask) );
-	    unparse_char_codes( s, codes, unparse_key_special );
-	    putchar( '\n' );
-	    }
-	}
-    putchar( '\n' );
-    }
-
-
-//-----------------------------------------------------------------------------
-// Unparse a list of key sequences.
-//-----------------------------------------------------------------------------
-static void unparse_sequence_special( number code )
-    {
-    printf( "{%s}", (code == 0 ? "unmodify" : modifier_code_desc(code)) );
-    }
-
-static void unparse_sequences( DataStream* s )
-    {
-    number const nseqs = get_number(s);
-    number seq;
-    printf( "SEQUENCES [%lu]\n", nseqs );
-    for (seq = 0; seq < nseqs; seq++)
-	{
-	number const nchars = get_number(s);
-	printf( "sequence %lu:", seq );
-	unparse_char_codes( s, nchars, unparse_sequence_special );
-	putchar( '\n' );
-	}
-    putchar( '\n' );
-    }
-
-
-//-----------------------------------------------------------------------------
-// Unparse a list of special keys.
-//-----------------------------------------------------------------------------
-static void unparse_specials( DataStream* s )
-    {
-    number nspecials = get_number(s);
-    printf( "SPECIALS [%lu]\n", nspecials );
-    while (nspecials-- > 0)
-	{
-	number const special = get_number(s);
-	number const scan = get_number(s);
-	printf( "%s: 0x%02x\n", special_code_desc(special), (natural)scan );
-	}
-    putchar( '\n' );
-    }
-
-
-//-----------------------------------------------------------------------------
-// Unparse the number-size flag.
-//-----------------------------------------------------------------------------
-static void unparse_numeric_size( DataStream* s )
-    {
-    word const numbers_are_shorts = get_word(s);
-    s->number_size = numbers_are_shorts ? 2 : 1;
-    }
-
-
-//-----------------------------------------------------------------------------
-// Unparse an entire key map.
-//-----------------------------------------------------------------------------
-static void unparse_keymap_data( DataStream* s )
-    {
-    unparse_numeric_size(s);
-    unparse_modifiers(s);
-    unparse_characters(s);
-    unparse_sequences(s);
-    unparse_specials(s);
-    }
-
-
-//-----------------------------------------------------------------------------
-// Unparse the active key map.
-//-----------------------------------------------------------------------------
-#if !defined(DUMPKEYMAP_FILE_ONLY)
-static int unparse_active_keymap( void )
-    {
-    int rc = 1;
-    NXEventHandle const h = NXOpenEventStatus();
-    if (h == 0)
-	fputs( "Unable to open event status driver.\n", stderr );
-    else
-	{
-	NXKeyMapping km;
-	km.size = NXKeyMappingLength(h);
-	if (km.size <= 0)
-	    fprintf( stderr, "Bad key mapping length (%d).\n", km.size );
-	else
-	    {
-	    km.mapping = (char*)malloc( km.size );
-	    if (NXGetKeyMapping( h, &km ) == 0)
-		fputs( "Unable to get current key mapping.\n", stderr );
-	    else
-		{
-		DataStream* stream =
-		    new_data_stream( (byte const*)km.mapping, km.size );
-		fputs( "=============\nACTIVE KEYMAP\n=============\n\n",
-		    stdout);
-		unparse_keymap_data( stream );
-		destroy_data_stream( stream );
-		rc = 0;
-		}
-	    free( km.mapping );
-	    }
-	NXCloseEventStatus(h);
-	}
-    return rc;
-    }
-#endif
-
-
-//-----------------------------------------------------------------------------
-// Unparse one key map from a keymapping file.
-//-----------------------------------------------------------------------------
-static void unparse_keymap( DataStream* s )
-    {
-    dword const interface = get_dword(s);
-    dword const handler_id = get_dword(s);
-    dword const map_size = get_dword(s);
-    printf( "interface: 0x%02lx\nhandler_id: 0x%02lx\nmap_size: %lu bytes\n\n",
-	interface, handler_id, map_size );
-    unparse_keymap_data(s);
-    }
-
-
-//-----------------------------------------------------------------------------
-// Check the magic number of a keymapping file.
-//-----------------------------------------------------------------------------
-static int check_magic_number( DataStream* s )
-    {
-    return (get_byte(s) == 'K' &&
-	    get_byte(s) == 'Y' &&
-	    get_byte(s) == 'M' &&
-	    get_byte(s) == '1');
-    }
-
-
-//-----------------------------------------------------------------------------
-// Unparse all key maps within a keymapping file.
-//-----------------------------------------------------------------------------
-static int unparse_keymaps( DataStream* s )
-    {
-    int rc = 0;
-    if (check_magic_number(s))
-	{
-	int n = 1;
-	while (!end_of_stream(s))
-	    {
-	    printf( "---------\nKEYMAP #%d\n---------\n", n++ );
-	    unparse_keymap(s);
-	    }
-	}
-    else
-	{
-	fputs( "Bad magic number.\n", stderr );
-	rc = 1;
-	}
-    return rc;
-    }
-
-
-//-----------------------------------------------------------------------------
-// Unparse a keymapping file.
-//-----------------------------------------------------------------------------
-static int unparse_keymap_file( char const* const path )
-    {
-    int rc = 1;
-    FILE* file;
-    printf( "===========\nKEYMAP FILE\n===========\n%s\n\n", path );
-    file = fopen( path, "rb" );
-    if (file == 0)
-	perror( "Unable to open key mapping file" );
-    else
-	{
-	struct stat st;
-	if (fstat( fileno(file), &st ) != 0)
-	    perror( "Unable to determine key mapping file size" );
-	else
-	    {
-	    byte* buffer = (byte*)malloc( st.st_size );
-	    if (fread( buffer, st.st_size, 1, file ) != 1)
-		perror( "Unable to read key mapping file" );
-	    else
-		{
-		DataStream* stream = new_data_stream(buffer, (int)st.st_size);
-		fclose( file ); file = 0;
-		rc = unparse_keymaps( stream );
-		destroy_data_stream( stream );
-		}
-	    free( buffer );
-	    }
-	if (file != 0)
-	    fclose( file );
-	}
-    return rc;
-    }
-
-
-//-----------------------------------------------------------------------------
-// Handle the case when no documents are mentioned on the command-line.  For
-// Apple/NeXT platforms, dump the currently active key mapping; else display
-// an error message.
-//-----------------------------------------------------------------------------
-static int handle_empty_document_list( void )
-    {
-#if !defined(DUMPKEYMAP_FILE_ONLY)
-    return unparse_active_keymap();
-#else
-    fputs( "ERROR: Must specify at least one .keymapping file.\n\n", stderr );
-    return 1;
-#endif
-    }
-
-
-//-----------------------------------------------------------------------------
-// Print a detailed description of the internal layout of a key mapping.
-//-----------------------------------------------------------------------------
-static void print_internal_layout_info( FILE* f )
-    {
-    fputs(
-"What follows is a detailed descriptions of the internal layout of an\n"
-"Apple/NeXT .keymapping file.\n"
-"\n"
-"Types and Data\n"
-"--------------\n"
-"The following type definitions are employed throughout this discussion:\n"
-"\n"
-"    typedef unsigned char  byte;\n"
-"    typedef unsigned short word;\n"
-"    typedef unsigned long  dword;\n"
-"\n"
-"Additionally, the type definition `number' is used generically to indicate\n"
-"a numeric value.  The actual size of the `number' type may be one or two\n"
-"bytes depending upon how the data is stored in the key map.  Although most\n"
-"key maps use byte-sized numeric values, word-sized values are also allowed.\n"
-"\n"
-"Multi-byte values in a key mapping file are stored in big-endian byte\n"
-"order.\n"
-"\n"
-"Key Mapping File and Device Mapping\n"
-"-----------------------------------\n"
-"A key mapping file begins with a magic-number and continues with a variable\n"
-"number of device-specific key mappings.\n"
-"\n"
-"    struct KeyMappingFile {\n"
-"        char magic_number[4];    // `KYM1'\n"
-"        DeviceMapping maps[...]; // Variable number of maps\n"
-"    };\n"
-"\n"
-"    struct DeviceMapping {\n"
-"        dword interface;  // Interface type\n"
-"        dword handler_id; // Interface subtype\n"
-"        dword map_size;   // Byte count of `map' (below)\n"
-"        KeyMapping map;\n"
-"    };\n"
-"\n"
-"The value of `interface' represents a family of keyboard device types\n"
-"(such as Intel PC, ADB, NeXT, Sun Type5, etc.), and is generally\n"
-"specified as one of the constant values NX_EVS_DEVICE_INTERFACE_ADB,\n"
-"NX_EVS_DEVICE_INTERFACE_ACE, etc., which are are defined in IOHIDTypes.h on\n"
-"MacOS/X and Darwin, and in ev_types.h on MacOS/X Server, OpenStep, and\n"
-"NextStep.\n"
-"\n"
-"The value of `handler_id' represents a specific keyboard layout within the\n"
-"much broader `interface' family.  For instance, for a 101-key Intel PC\n"
-"keyboard (of type NX_EVS_DEVICE_INTERFACE_ACE) the `handler_id' is '0',\n"
-"whereas for a 102-key keyboard it is `1'.\n"
-"\n"
-"Together, `interface' and `handler_id' identify the exact keyboard hardware\n"
-"to which this mapping applies.  Programs which display a visual\n"
-"representation of a keyboard layout, match `interface' and `handler_id'\n"
-"from the .keymapping file against the `interface' and `handler_id' values\n"
-"found in each .keyboard file.\n"
-"\n"
-"Key Mapping\n"
-"-----------\n"
-"A key mapping completely defines the relationship of all scan codes with\n"
-"their associated functionality.  A KeyMapping structure is embedded within\n"
-"the DeviceMapping structure in a KeyMappingFile.  The key mapping currently\n"
-"in use by the WindowServer and AppKit is also represented by a KeyMapping\n"
-"structure, and can be referred to directly by calling NXGetKeyMapping() and\n"
-"accessing the `mapping' data member of the returned NXKeyMapping structure.\n"
-"\n"
-"    struct KeyMapping {\n"
-"        word number_size;                   // 0=1 byte, non-zero=2 bytes\n"
-"        number num_modifier_groups;         // Modifier groups\n"
-"        ModifierGroup modifier_groups[...];\n"
-"        number num_scan_codes;              // Scan groups\n"
-"        ScanGroup scan_table[...];\n"
-"        number num_sequence_lists;          // Sequence lists\n"
-"        Sequence sequence_lists[...];\n"
-"        number num_special_keys;            // Special keys\n"
-"        SpecialKey special_key[...];\n"
-"    };\n"
-"\n"
-"The `number_size' flag determines the size, in bytes, of all remaining\n"
-"numeric values (denoted by the type definition `number') within the key\n"
-"mapping.  If its value is zero, then numbers are represented by a single\n"
-"byte.  If it is non-zero, then numbers are represented by a word (two\n"
-"bytes).\n"
-"\n"
-"Modifier Group\n"
-"--------------\n"
-"A modifier group defines all scan codes which map to a particular type of\n"
-"modifier, such as `shift', `control', etc.\n"
-"\n"
-"    enum Modifier {\n"
-"        ALPHALOCK = 0,\n"
-"        SHIFT,\n"
-"        CONTROL,\n"
-"        ALTERNATE,\n"
-"        COMMAND,\n"
-"        KEYPAD,\n"
-"        HELP\n"
-"    };\n"
-"\n"
-"    struct ModifierGroup {\n"
-"        number modifier;        // A Modifier constant\n"
-"        number num_scan_codes;\n"
-"        number scan_codes[...]; // Variable number of scan codes\n"
-"    };\n"
-"\n"
-"The scan_codes[] array contains a list of all scan codes which map to the\n"
-"specified modifier.  The `shift', `command', and `alternate' modifiers are\n"
-"frequently mapped to two different scan codes, apiece, since these\n"
-"modifiers often appear on both the left and right sides of the keyboard.\n"
-"\n"
-"Scan Group\n"
-"----------\n"
-"There is one ScanGroup for each scan code generated by the given keyboard.\n"
-"This number is given by KeyMapping::num_scan_codes.  The first scan group\n"
-"represents hardware scan code 0, the second represents scan code 1, etc.\n"
-"\n"
-"    enum ModifierMask {\n"
-"        ALPHALOCK_MASK       = 1 << 0,\n"
-"        SHIFT_MASK           = 1 << 1,\n"
-"        CONTROL_MASK         = 1 << 2,\n"
-"        ALTERNATE_MASK       = 1 << 3,\n"
-"        CARRIAGE_RETURN_MASK = 1 << 4\n"
-"    };\n"
-"    #define NOT_BOUND 0xff\n"
-"\n"
-"    struct ScanGroup {\n"
-"        number mask;\n"
-"        Character characters[...];\n"
-"    };\n"
-"\n"
-"For each scan code, `mask' defines which modifier combinations generate\n"
-"characters.  If `mask' is NOT_BOUND (0xff) then then this scan code does\n"
-"not generate any characters ever, and its characters[] array is zero\n"
-"length.  Otherwise, the characters[] array contains one Character record\n"
-"for each modifier combination.\n"
-"\n"
-"The number of records in characters[] is determined by computing (1 <<\n"
-"bits_set_in_mask).  In other words, if mask is zero, then zero bits are\n"
-"set, so characters[] contains only one record.  If `mask' is (SHIFT_MASK |\n"
-"CONTROL_MASK), then two bits are set, so characters[] contains four\n"
-"records.\n"
-"\n"
-"The first record always represents the character which is generated by that\n"
-"key when no modifiers are active.  The remaining records represent\n"
-"characters generated by the various modifier combinations.  Using the\n"
-"example with the `shift' and `control' masks set, record two would\n"
-"represent the character with the `shift' modifier active; record three, the\n"
-"`control' modifier active; and record four, both the `shift' and `control'\n"
-"modifiers active.\n"
-"\n"
-"As a special case, ALPHALOCK_MASK implies SHIFT_MASK, though only\n"
-"ALPHALOCK_MASK appears in `mask'.  In this case the same character is\n"
-"generated for both the `shift' and `alpha-lock' modifiers, but only needs\n"
-"to appear once in the characters[] array.\n"
-"\n"
-"CARRIAGE_RETURN_MASK does not actually refer to a modifier key.  Instead,\n"
-"it is used to distinguish the scan code which is given the special\n"
-"pseudo-designation of `carriage return' key.  Typically, this mask appears\n"
-"solo in a ScanGroup record and only the two Character records for control-M\n"
-"and control-C follow.  This flag may be a throwback to an earlier time or\n"
-"may be specially interpreted by the low-level keyboard driver, but its\n"
-"purpose is otherwise enigmatic.\n"
-"Character\n"
-"---------\n"
-"Each Character record indicates the character generated when this key is\n"
-"pressed, as well as the character set which contains the character.  Well\n"
-"known character sets are `ASCII' and `Symbol'.  The character set can also\n"
-"be one of the meta values FUNCTION_KEY or KEY_SEQUENCE.  If it is\n"
-"FUNCTION_KEY then `char_code' represents a generally well-known function\n"
-"key such as those enumerated by FunctionKey.  If the character set is\n"
-"KEY_SEQUENCE then `char_code' represents a zero-base index into\n"
-"KeyMapping::sequence_lists[].\n"
-"\n"
-"    enum CharacterSet {\n"
-"        ASCII        = 0x00,\n"
-"        SYMBOL       = 0x01,\n"
-"        ...\n"
-"        FUNCTION_KEY = 0xfe,\n"
-"        KEY_SEQUENCE = 0xff\n"
-"    };\n"
-"\n"
-"    struct Character {\n"
-"        number set;       // CharacterSet of generated character\n"
-"        number char_code; // Actual character generated\n"
-"    };\n"
-"\n"
-"    enum FunctionKey {\n"
-"        F1 = 0x20, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12,\n"
-"        INSERT, DELETE, HOME, END, PAGE_UP, PAGE_DOWN, PRINT_SCREEN,\n"
-"        SCROLL_LOCK, PAUSE, SYS_REQUEST, BREAK, RESET, STOP, MENU, USER,\n"
-"        SYSTEM, PRINT, CLEAR_LINE, CLEAR_DISPLAY, INSERT_LINE,\n"
-"        DELETE_LINE, INSERT_CHAR, DELETE_CHAR, PREV, NEXT, SELECT\n"
-"    };\n"
-"\n"
-"Sequence\n"
-"--------\n"
-"When Character::set contains the meta value KEY_SEQUENCE, the scan code is\n"
-"bound to a sequence of keys rather than a single character.  A sequence is\n"
-"a series of modifiers and characters which are automatically generated when\n"
-"the associated key is depressed.\n"
-"\n"
-"    #define MODIFIER_KEY 0xff\n"
-"\n"
-"    struct Sequence {\n"
-"        number num_chars;\n"
-"        Character characters[...];\n"
-"    };\n"
-"\n"
-"Each generated Character is represented as previously described, with the\n"
-"exception that MODIFIER_KEY may appear in place of KEY_SEQUENCE.  When the\n"
-"value of Character::set is MODIFIER_KEY then Character::char_code\n"
-"represents a modifier key rather than an actual character.  If the modifier\n"
-"represented by `char_code' is non-zero, then it indicates that the\n"
-"associated modifier key has been depressed.  In this case, the value is one\n"
-"of the constants enumerated by Modifier (SHIFT, CONTROL, ALTERNATE, etc.).\n"
-"If the value is zero then it means that the modifier keys have been\n"
-"released.\n"
-"\n"
-"Special Key\n"
-"-----------\n"
-"A special key is one which is scanned directly by the Mach kernel rather\n"
-"than by the WindowServer.  In general, events are not generated for special\n"
-"keys.\n"
-"\n"
-"    enum SpecialKeyType {\n"
-"        VOLUME_UP = 0,\n"
-"        VOLUME_DOWN,\n"
-"        BRIGHTNESS_UP,\n"
-"        BRIGHTNESS_DOWN,\n"
-"        ALPHA_LOCK,\n"
-"        HELP,\n"
-"        POWER,\n"
-"        SECONDARY_ARROW_UP,\n"
-"        SECONDARY_ARROW_DOWN\n"
-"    };\n"
-"\n"
-"    struct SpecialKey {\n"
-"        number type;      // A SpecialKeyType constant\n"
-"        number scan_code; // Actual scan code\n"
-"    };\n"
-"\n", f );
-    }
-
-
-//-----------------------------------------------------------------------------
-// Print an explanation of the output generated by this program.
-//-----------------------------------------------------------------------------
-static void print_output_info( FILE* f )
-    {
-    fputs(
-"What follows is an explanation and description of the various pieces of\n"
-"information emitted by dumpkeymap.\n"
-"\n"
-"For a more thorough discussion of any particular piece of information\n"
-"described here, refer to the detailed description of the internal layout of\n"
-"a key mapping given by the --help-layout option.\n"
-"\n"
-"Conventions\n"
-"-----------\n"
-"Depending upon context, some numeric values are displayed in decimal\n"
-"notation, whereas others are displayed in hexadecimal notation.\n"
-"Hexadecimal numbers are denoted by a `0x' prefix (for instance, `0x7b'),\n"
-"except when explicitly noted otherwise.\n"
-"\n"
-"Key Mapping Source\n"
-"------------------\n"
-"The first piece of information presented about a particular key mapping is\n"
-"the source from which the data was gleaned.  For a .keymapping file, the\n"
-"title `KEYMAP FILE' is emitted along with the path and name of the file in\n"
-"question.  For the key mapping currently in use by the WindowServer and\n"
-"AppKit, the title `ACTIVE KEYMAP' is emitted instead.\n"
-"\n"
-"Device Information\n"
-"------------------\n"
-"Each .keymapping file may contain one or more raw key mappings.  For\n"
-"example, a file which maps keys to a Dvorak-style layout might contain raw\n"
-"mappings for Intel PC, ADB, NeXT, and Sun Type5 keyboards.\n"
-"\n"
-"For each raw mapping, the following information is emitted:\n"
-"\n"
-"    o The title `KEYMAP' along with the mapping's relative position in the\n"
-"      .keymapping file.\n"
-"    o The `interface' identifier.\n"
-"    o The `handler_id' sub-identifier.\n"
-"    o The size of the raw mapping resource counted in bytes.\n"
-"\n"
-"The `interface' and `handler_id' values, taken together, define a specific\n"
-"keyboard device.  A .keyboard file, which describes the visual layout of a\n"
-"keyboard, also contains `interface' and `handler_id' identifiers.  The\n"
-".keyboard file corresponding to a particular key mapping can be found by\n"
-"matching the `interface' and `handler_id' values from each resource.\n"
-"\n"
-"Modifiers\n"
-"---------\n"
-"Each mapping may contain zero or more modifier records which associate\n"
-"hardware scan codes with modifier descriptions such as `shift', `control',\n"
-"`alternate', etc.  The title `MODIFIERS' is printed along with the count of\n"
-"modifier records which follow.  For each modifier record, the modifier's\n"
-"name is printed along with a list of scan codes, in hexadecimal format,\n"
-"which generate that modifier value.  For example:\n"
-"\n"
-"    MODIFIERS [4]\n"
-"    alternate: 0x1d 0x60\n"
-"    control: 0x3a\n"
-"    keypad: 0x52 0x53 ... 0x63 0x62\n"
-"    shift: 0x2a 0x36\n"
-"\n"
-"Characters\n"
-"----------\n"
-"Each mapping may contain zero or more character records which associate\n"
-"hardware scan codes with the actual characters generated by those scan\n"
-"codes in the presence or absence of various modifier combinations.  The\n"
-"title `CHARACTERS' is printed along with the count of character records\n"
-"which follow.  Here is a highly abbreviated example:\n"
-"\n"
-"    CHARACTERS [9]\n"
-"    scan 0x00: -AC-L  \"a\" \"A\" \"^A\" \"^A\" ca c7 \"^A\" \"^A\"\n"
-"    scan 0x07: -AC-L  \"x\" \"X\" \"^X\" \"^X\" 01/b4 01/ce \"^X\" \"^X\"\n"
-"    scan 0x0a: ---S-  \"<\" \">\"\n"
-"    scan 0x13: -ACS-  \"2\" \"@\" \"^@\" \"^@\" b2 b3 \"^@\" \"^@\"\n"
-"    scan 0x24: R----  \"^M\" \"^C\"\n"
-"    scan 0x3e: -----  [F4]\n"
-"    scan 0x4a: -----  [page up]\n"
-"    scan 0x60: -----  {seq#3}\n"
-"    scan 0x68: not-bound\n"
-"\n"
-"For each record, the hexadecimal value of the hardware scan code is\n"
-"printed, followed by a list of modifier flag combinations and the actual\n"
-"characters generated by this scan code with and without modifiers applied.\n"
-"\n"
-"The modifier flags field is composed of a combination of single letter\n"
-"representations of the various modifier types.  The letters stand for:\n"
-"\n"
-"    L - alpha-lock\n"
-"    S - shift\n"
-"    C - control\n"
-"    A - alternate\n"
-"    R - carriage-return\n"
-"\n"
-"As a special case, the `alpha-lock' flag also implies the `shift' flag, so\n"
-"these two flags never appear together in the same record.\n"
-"\n"
-"The combination of modifier flags determines the meaning and number of\n"
-"fields which follow.  The first field after the modifier flags always\n"
-"represents the character that will be generated if no modifier keys are\n"
-"depressed.  The remaining fields represent characters generated by the\n"
-"various modifier combinations.  The order of the fields follows this\n"
-"general pattern:\n"
-"\n"
-"    o The character generated by this scan code when no modifiers are in\n"
-"      effect is listed first.\n"
-"\n"
-"    o If the `L' or `S' flag is active, then the shifted character\n"
-"      generated by this scan code is listed next.\n"
-"\n"
-"    o If the `C' flag is active, then the control-character generated by\n"
-"      this scan code is listed next.  Furthermore, if the `L' or `S' flag\n"
-"      is also active, then the shifted control-character is listed after\n"
-"      that.\n"
-"\n"
-"    o If the `A' flag is active, then the alternate-character generated by\n"
-"      this scan code is listed next.  Furthermore, if the `L' or `S' flag\n"
-"      is active, then the shifted alternate-character is listed after that.\n"
-"      If the `C' flag is also active, then the alternate-control-character\n"
-"      is listed next.  Finally, if the `C' and `L' or `C' and `S' flags are\n"
-"      also active, then the shifted alternate-control-character is listed.\n"
-"\n"
-"The `R' flag does not actually refer to a modifier key.  Instead, it is\n"
-"used to distinguish the scan code which is given the special\n"
-"pseudo-designation of `carriage return' key.  Typically, this mask appears\n"
-"solo and only the two fields for control-M and control-C follow.  This flag\n"
-"may be a throwback to an earlier time or may be specially interpreted by\n"
-"the low-level keyboard driver, but its purpose is otherwise enigmatic.\n"
-"\n"
-"Recalling the example from above, the following fields can be identified:\n"
-"\n"
-"    scan 0x00: -AC-L  \"a\" \"A\" \"^A\" \"^A\" ca c7 \"^A\" \"^A\"\n"
-"\n"
-"    o Lower-case `a' is generated when no modifiers are active.\n"
-"    o Upper-case `A' is generated when `shift' or `alpha-lock' are active.\n"
-"    o Control-A is generated when `control' is active.\n"
-"    o Control-A is generated when `control' and `shift' are active.\n"
-"    o The character represented by the hexadecimal code 0xca is generated\n"
-"      when `alternate' is active.\n"
-"    o The character represented by 0xc7 is generated when `alternate' and\n"
-"      `shift' (or `alpha-lock') are active.\n"
-"    o Control-A is generated when `alternate' and `control' are active.\n"
-"    o Control-A is generated when `alternate', `control' and `shift' (or\n"
-"      `alpha-lock') are active.\n"
-"\n"
-"The notation used to represent a particular generated character varies.\n"
-"\n"
-"    o Printable ASCII characters are quoted, as in \"x\" or \"X\".\n"
-"\n"
-"    o Control-characters are quoted and prefixed with `^', as in \"^X\".\n"
-"\n"
-"    o Characters with values greater than 127 (0x7f) are displayed as\n"
-"      hexadecimal values without the `0x' prefix.\n"
-"\n"
-"    o Characters in a non-ASCII character set (such as `Symbol') are\n"
-"      displayed as two hexadecimal numbers separated by a slash, as in\n"
-"      `01/4a'.  The first number is the character set's identification code\n"
-"      (such as `01' for the `Symbol' set), and the second number is the\n"
-"      value of the generated character.\n"
-"\n"
-"    o Non-printing special function characters are displayed with the\n"
-"      function's common name enclosed in brackets, as in `[page up]' or\n"
-"      `[F4]'.\n"
-"\n"
-"    o If the binding represents a key sequence rather than a single\n"
-"      character, then the sequence's identification number is enclosed in\n"
-"      braces, as in `{seq#3}'.\n"
-"\n"
-"Recalling a few examples from above, the following interpretations can be\n"
-"made:\n"
-"\n"
-"    scan 0x07: -AC-L  \"x\" \"X\" \"^X\" \"^X\" 01/b4 01/ce \"^X\" \"^X\"\n"
-"    scan 0x3e: -----  [F4]\n"
-"    scan 0x4a: -----  [page up]\n"
-"    scan 0x60: -----  {seq#3}\n"
-"\n"
-"    o \"x\" and \"X\" are printable ASCII characters.\n"
-"    o \"^X\" is a control-character.\n"
-"    o `01/b4' and `01/ce' represent the character codes 0xb4 and 0xce in\n"
-"      the `Symbol' character set.\n"
-"    o Scan code 0x3e generates function-key `F4', and scan code 0x4a\n"
-"      generates function-key `page up'.\n"
-"    o Scan code 0x60 is bound to key sequence #3.\n"
-"\n"
-"Finally, if a scan code is not bound to any characters, then it is\n"
-"annotated with the label `not-bound', as with example scan code 0x68 from\n"
-"above.\n"
-"\n"
-"Sequences\n"
-"---------\n"
-"A scan code (modified and unmodified) can be bound to a key sequence rather\n"
-"than generating a single character or acting as a modifier.  When it is\n"
-"bound to a key sequence, a series of character invocations and modifier\n"
-"actions are automatically generated rather than a single keystroke.\n"
-"\n"
-"Each mapping may contain zero or more key sequence records.  The title\n"
-"`SEQUENCES' is printed along with the count of sequence records which\n"
-"follow.  For example:\n"
-"\n"
-"    SEQUENCES [3]\n"
-"    sequence 0: \"f\" \"o\" \"o\"\n"
-"    sequence 1: {alternate} \"b\" \"a\" \"r\" {unmodify}\n"
-"    sequence 2: [home] \"b\" \"a\" \"z\"\n"
-"\n"
-"The notation used to represent the sequence of generated characters is\n"
-"identical to the notation already described in the `Characters' section\n"
-"above, with the exception that modifier actions may be interposed between\n"
-"generated characters.  Such modifier actions are represented by the\n"
-"modifier's name enclosed in braces.  The special name `{unmodify}'\n"
-"indicates the release of the modifier keys.\n"
-"\n"
-"Thus, the sequences in the above example can be interpreted as follows:\n"
-"\n"
-"    o Sequence #0 generates `foo'.\n"
-"    o Sequence #1 invokes the `alternate' modifier, generates `bar', and\n"
-"      then releases `alternate'.\n"
-"    o Sequence #2 invokes the `home' key and then generates `baz'.  In a\n"
-"      text editor, this would probably result in `baz' being prepended to\n"
-"      the line of text on which the cursor resides.\n"
-"\n"
-"Special Keys\n"
-"------------\n"
-"Certain keyboards feature keys which perform some type of special purpose\n"
-"function rather than generating a character or acting as a modifier.  For\n"
-"instance, Apple keyboards often contain a `power' key, and NeXT keyboards\n"
-"have historically featured screen brightness and volume control keys.\n"
-"\n"
-"Each mapping may contain zero or more special-key records which associate\n"
-"hardware scan codes with such special purpose functions.  The title\n"
-"`SPECIALS' is printed along with the count of records which follow.  For\n"
-"each record, the special function's name is printed along with a list of\n"
-"scan codes, in hexadecimal format, which are bound to that function.  For\n"
-"example:\n"
-"\n"
-"    SPECIALS [6]\n"
-"    alpha-lock: 0x39\n"
-"    brightness-down: 0x79\n"
-"    brightness-up: 0x74\n"
-"    power: 0x7f\n"
-"    sound-down: 0x77\n"
-"    sound-up: 0x73\n"
-"\n", f );
-    }
-
-
-//-----------------------------------------------------------------------------
-// Print a summary of the various files and directories which are related to
-// key mappings.
-//-----------------------------------------------------------------------------
-static void print_files_info( FILE* f )
-    {
-    fputs(
-"This is a summary of the various files and directories which are related to\n"
-"key mappings.\n"
-"\n"
-"*.keymapping\n"
-"    A key mapping file which precisely defines the relationship of all\n"
-"    hardware-specific keyboard scan-codes with their associated\n"
-"    functionality.\n"
-"\n"
-"*.keyboard\n"
-"    A file describing the physical layout of keys on a particular type of\n"
-"    keyboard.  Each `key' token in this file defines the position and shape\n"
-"    of the key on the keyboard, as well as the associated scan code which\n"
-"    that key generates.  A .keymapping file, on the other hand, defines the\n"
-"    characters which are generated by a particular scan code depending upon\n"
-"    the state of the various modifier keys (such as shift, control, etc.).\n"
-"    The `interface' and `handler_id' values from a .keymapping file are\n"
-"    matched against those in each .keyboard file in order to associate a\n"
-"    particular .keyboard file with a key mapping.  Various GUI programs use\n"
-"    the .keyboard file to display a visual representation of a keyboard for\n"
-"    the user.  Since these files are just plain text, they can be easily\n"
-"    viewed and interpreted without the aid of a specialized program, thus\n"
-"    dumpkeymap leaves these files alone.\n"
-"\n"
-"/System/Library/Keyboards\n"
-"/Network/Library/Keyboards\n"
-"/Local/Library/Keyboards\n"
-"/Library/Keyboards\n"
-"    Repositories for .keymapping and .keyboard files for MacOS/X, Darwin,\n"
-"    and MacOS/X Server.\n"
-"\n"
-"/NextLibrary/Keyboards\n"
-"/LocalLibrary/Keyboards\n"
-"    Repositories for .keymapping and .keyboard files for OpenStep and\n"
-"    NextStep.\n"
-"\n"
-"$(HOME)/Library/Keyboards\n"
-"    Repository for personal .keymapping and .keyboard files.\n"
-"\n", f );
-    }
-
-
-//-----------------------------------------------------------------------------
-// Print a list of the various diagnostic messages which may be emitted.
-//-----------------------------------------------------------------------------
-static void print_diagnostics_info( FILE* f )
-    {
-    fputs(
-"The following diagnostic messages may be issued to the standard error\n"
-"stream.\n"
-"\n"
-"Unrecognized option.\n"
-"    An unrecognized option was specified on the command-line.  Invoke\n"
-"    dumpkeymap with the --help option to view a list of valid options.\n"
-"\n"
-"Insufficient data in keymapping data stream.\n"
-"    The key mapping file or data stream is corrupt.  Either the file has\n"
-"    been incorrectly truncated or a field, such as those which indicates\n"
-"    the number of variable records which follow, contains a corrupt value.\n"
-"\n"
-"The following diagnostic messages have significance only when trying to\n"
-"print .keymapping files mentioned on the command-line.\n"
-"\n"
-"Bad magic number.\n"
-"    The mentioned file is not a .keymapping file.  The file's content does\n"
-"    not start with the string `KYM1'.\n"
-"\n"
-"Unable to open key mapping file.\n"
-"    The call to fopen() failed; probably because the specified path is\n"
-"    invalid or dumpkeymap does not have permission to read the file.\n"
-"\n"
-"Unable to determine key mapping file size.\n"
-"    The call to fstat() failed, thus memory can not be allocated for\n"
-"    loading the file.\n"
-"\n"
-"Unable to read key mapping file.\n"
-"    The call to fread() failed.\n"
-"\n"
-"The following diagnostic messages have significance only when trying to\n"
-"print the currently active key mapping when no .keymapping files have been\n"
-"mentioned on the command-line.\n"
-"\n"
-"Unable to open event status driver.\n"
-"    The call to NXOpenEventStatus() failed.\n"
-"\n"
-"Bad key mapping length.\n"
-"    The call to NXKeyMappingLength() returned a bogus value.\n"
-"\n"
-"Unable to get current key mapping.\n"
-"    The call to NXGetKeyMapping() failed.\n"
-"\n"
-"The following diagnostic messages have significance only when using\n"
-"dumpkeymap on a non-Apple/NeXT platform.\n"
-"\n"
-"Must specify at least one .keymapping file.\n"
-"    No .keymapping files were mentioned on the command-line.  On\n"
-"    non-Apple/NeXT platforms, there is no concept of a currently active\n"
-"    .keymapping file, so at least one file must be mentioned on the\n"
-"    command-line.\n"
-"\n", f );
-    }
-
-
-//-----------------------------------------------------------------------------
-// Print warranty.
-//-----------------------------------------------------------------------------
-static void print_warranty( FILE* f )
-    {
-    fputs(
-"This software is provided by the author `AS IS' and any express or implied\n"
-"WARRANTIES, including, but not limited to, the implied warranties of\n"
-"MERCHANTABILITY and FITNESS FOR A PARTICULAR PURPOSE are DISCLAIMED.  In NO\n"
-"EVENT shall the author be LIABLE for any DIRECT, INDIRECT, INCIDENTAL,\n"
-"SPECIAL, EXEMPLARY, or CONSEQUENTIAL damages (including, but not limited\n"
-"to, procurement of substitute goods or services; loss of use, data, or\n"
-"profits; or business interruption) however caused and on any theory of\n"
-"liability, whether in contract, strict liability, or tort (including\n"
-"negligence or otherwise) arising in any way out of the use of this\n"
-"software, even if advised of the possibility of such damage.\n"
-"\n", f );
-    }
-
-
-//-----------------------------------------------------------------------------
-// Print this program's version number.
-//-----------------------------------------------------------------------------
-static void print_version( FILE* f )
-    {
-    fputs( "Version " PROG_VERSION " (built " __DATE__ ")\n\n", f );
-    }
-
-
-//-----------------------------------------------------------------------------
-// Print a usage summary.
-//-----------------------------------------------------------------------------
-static void print_usage( FILE* f )
-    {
-    fputs(
-"Usage: dumpkeymap [options] [-] [file ...]\n"
-"\n"
-"Prints a textual representation of each Apple/NeXT .keymapping file\n"
-"mentioned on the command-line.  If no files are mentioned and if the local\n"
-"machine is an Apple or NeXT installation, then the key mapping currently in\n"
-"use by the WindowServer and the AppKit is printed instead.\n"
-"\n"
-"Options:\n"
-"    -h --help\n"
-"        Display general program instructions and option summary.\n"
-"\n"
-"    -k --help-keymapping\n"
-"        Display a detailed description of the internal layout of a\n"
-"        .keymapping file.\n"
-"\n"
-"    -o --help-output\n"
-"        Display an explanation of the output generated by dumpkeymap when\n"
-"        dissecting a .keymapping file.\n"
-"\n"
-"    -f --help-files\n"
-"        Display a summary of the various files and directories which are\n"
-"        related to key mappings.\n"
-"\n"
-"    -d --help-diagnostics\n"
-"        Display a list of the various diagnostic messages which may be\n"
-"        emitted by dumpkeymap.\n"
-"\n"
-"    -v --version\n"
-"        Display the dumpkeymap version number and warranty information.\n"
-"\n"
-"    - --\n"
-"        Inhibit processing of options at this point in the argument list.\n"
-"        An occurrence of `-' or `--' in the argument list causes all\n"
-"        following arguments to be treated as file names even if an argument\n"
-"        begins with a `-' character.\n"
-"\n", f );
-    }
-
-
-//-----------------------------------------------------------------------------
-// Print an informational banner.
-//-----------------------------------------------------------------------------
-static void print_banner( FILE* f )
-    {
-    fputs( "\n" PROG_NAME " v" PROG_VERSION " by " AUTHOR_INFO "\n"
-	COPYRIGHT "\n\n", f );
-    }
-
-
-//-----------------------------------------------------------------------------
-// Process command-line arguments.  Examine options first; collecting files
-// along the way.  If all is well, process collected file list.
-//-----------------------------------------------------------------------------
-int main( int const argc, char const* const argv[] )
-    {
-    int rc = 0, i, nfiles = 0, more_options = 1, process_files = 1;
-    int* files = (int*)calloc( argc - 1, sizeof(int) );
-    print_banner( stdout );
-
-    for (i = 1; i < argc; i++)
-	{
-	char const* const s = argv[i];
-	if (!more_options || *s != '-')
-	    files[ nfiles++ ] = i;
-	else
-	    {
-	    OPT_SWITCH(s)
-		OPT_CASE(-,--)
-		    more_options = 0;
-		OPT_CASE(-h,--help)
-		    print_usage( stdout );
-		    process_files = 0;
-		OPT_CASE(-k,--help-keymapping)
-		    print_internal_layout_info( stdout );
-		    process_files = 0;
-		OPT_CASE(-o,--help-output)
-		    print_output_info( stdout );
-		    process_files = 0;
-		OPT_CASE(-f,--help-files)
-		    print_files_info( stdout );
-		    process_files = 0;
-		OPT_CASE(-d,--help-diagnostics)
-		    print_diagnostics_info( stdout );
-		    process_files = 0;
-		OPT_CASE(-v,--version)
-		    print_version( stdout );
-		    print_warranty( stdout );
-		    process_files = 0;
-		OPT_DEFAULT
-		    fprintf( stderr, "ERROR: Unrecognized option: %s\n\n", s );
-		    process_files = 0;
-		    rc = 1;
-	    OPT_SWITCH_END
-	    }
-	}
-
-    if (process_files)
-	{
-	if (nfiles == 0)
-	    rc = handle_empty_document_list();
-	else
-	    for (i = 0; i < nfiles; i++)
-		rc |= unparse_keymap_file( argv[files[i]] );
-	}
-
-    free( files );
-    return rc;
-    }
diff --git a/hw/darwin/utils/dumpkeymap.man b/hw/darwin/utils/dumpkeymap.man
deleted file mode 100644
index 02b09e6..0000000
--- a/hw/darwin/utils/dumpkeymap.man
+++ /dev/null
@@ -1,1002 +0,0 @@
-.ig
-//=============================================================================
-//
-// Manual page for `dumpkeymap'.
-//
-// Copyright (C) 1999,2000 by Eric Sunshine <sunshine at sunshineco.com>
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-//   1. Redistributions of source code must retain the above copyright
-//      notice, this list of conditions and the following disclaimer.
-//   2. Redistributions in binary form must reproduce the above copyright
-//      notice, this list of conditions and the following disclaimer in the
-//      documentation and/or other materials provided with the distribution.
-//   3. The name of the author may not be used to endorse or promote products
-//      derived from this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
-// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
-// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-//=============================================================================
-//
-..
-.ig
-//-----------------------------------------------------------------------------
-// Local identification information.
-//-----------------------------------------------------------------------------
-..
-.nr VE 4 \" Version number
-.TH DUMPKEYMAP 1 "v\n(VE \-\- 1 December 2000" "Version \n(VE"
-.de UP
-1 December 2000
-..
-.ig
-//-----------------------------------------------------------------------------
-// Annotation Macros
-// -----------------
-//	Facilitate creation of annotated, non-filled blocks of text.  An
-//	annotated block is initiated with the `AS' macro.  Each annotated,
-//	non-filled line within the block must be introduced with the `AN' macro
-//	which takes three arguments.  The first argument is the detail text to
-//	be annotated.  The second is a string of spaces used to align the
-//	annotations by certain (broken) roff interpreters which fail to
-//	implement the proper set of roff commands (such as diversions,
-//	indentation, and tab stops).  It is assumed that the spaces will be
-//	used with fixed-point font.  The third argument is the annotation
-//	itself.  The block should be terminated with the `AE' macro.  For all
-//	roff interpreters which properly implement diversions, indentation, and
-//	tab stops, all annotations within the block are automatically aligned at
-//	the same horizontal position.  This position is guaranteed to be just
-//	to the right of the widest `AN' detail line.  For broken roff
-//	interpreters, such as `rman', the string of spaces from the second
-//	argument are used to align the annotations.  Finally, the `AZ' macro,
-//	which takes a single argument, can be used to to insert a non-annotated
-//	line into the block which does not play a part in the calculation of
-//	the horizontal annotation alignment.
-//
-// Implementation Notes
-// --------------------
-// *1*	These macros utilize a diversion (named `AD').  Since the prevailing
-//	indentation is stored along with the diverted text, we must muck with
-//	the indentation level in order to prevent the indentation from being
-//	applied to the text a second time when `AD' is finally emitted.
-//
-// *2*	Unfortunately, `.if' strips leading whitespace from following text, so
-//	`AN' uses \& to preserve the whitespace.
-//
-// *3*	This manual page has been tested for proper formatting with troff,
-//	groff, nroff and rman (the `man' to `HTML' converter).  Unfortunately,
-//	rman fails to implement many useful features such as diversions,
-//	indentation, and tab stops, and is also hideously buggy.  Furthermore
-//	it identifies itself as nroff and fails to provide any further
-//	identification, so there is no way to create macros which specifically
-//	work around its limitations.  Following is a list of several bugs in
-//	rman which the implementation of these macros must avoid:
-//	    o Fails with multi-line conditionals within macros.
-//	    o Fails on macro definition within multi-line conditionals.
-//	    o Fails when macro arguments are not delimited by exactly 1 space.
-//	    o String definition `.ds' ignores the value; uses empty "" instead.
-//	As a consequence of these problems, the following macros are written
-//	using a series of ugly single-line `.if' conditionals rather than the
-//	more natural multi-line `.if' and `.ie' conditionals.  Also, rman fails
-//	to understand the common idiom of `.\"' to introduce a comment, which
-//	is why all comments in this file are wrapped in ignore `.ig' blocks.
-//-----------------------------------------------------------------------------
-..
-.de AS
-.if t .nr AW 0
-.if t .nr AI \\n(.i
-.if t .in -\\n(AI
-.nf
-..
-.de AN
-.if t .if \w'\\$1'>\\n(AW .nr AW \w'\\$1'
-.if t .da AD
-.if t \\&\\$1\\t\\$3
-.if t .da
-.if n \\&\\$1 \\$2\\$3
-..
-.de AZ
-.if t .da AD
-\\$1
-.if t .da
-..
-.de AE
-.if t .in +\\n(AIu
-.if t .if \\n(AW .ta \\n(AWu+\w'\\(em'u
-.if t .AD
-.if t .DT
-.if t .rm AD
-.if t .rm AW
-.fi
-..
-.ig
-//-----------------------------------------------------------------------------
-// Bulleted list macros -- `BG' begins a bulleted list; `BU' delimits
-//	bulleted entries; `BE' ends a bulleted list.
-//-----------------------------------------------------------------------------
-..
-.de BG
-.PP
-.RS
-..
-.de BU
-.HP
-\\(bu\\ \\c
-..
-.de BE
-.RE
-.PP
-..
-.ig
-//-----------------------------------------------------------------------------
-// Indented paragraph with stylized hanging tag macro.  `TG' takes a single
-//	argument and treats it as the hanging tag of the indented paragraph.
-//	The tag is italicized in troff but not in nroff.
-//-----------------------------------------------------------------------------
-..
-.de TG
-.TP
-.ie t .I "\\$1"
-.el \\$1
-..
-.ig
-//-----------------------------------------------------------------------------
-// Manual page for `dumpkeymap'.
-//-----------------------------------------------------------------------------
-..
-.SH NAME
-dumpkeymap \- Dianostic dump of a .keymapping file
-.SH SYNOPSIS
-.B dumpkeymap
-.RI [ options "] [-] [" file "...]"
-.SH DESCRIPTION
-.I dumpkeymap
-prints a textual representation of each Apple/\c
-.SM NeXT
-.I .keymapping
-file mentioned on the command-line.  If no files are mentioned and if the
-local machine is an Apple or
-.SM NeXT
-installation, then the key mapping currently in use by the WindowServer and the
-AppKit is printed instead.
-.SH OPTIONS
-.TP
-.B "\-h \-\^\-help"
-Display general program instructions and option summary.
-.TP
-.B "\-k \-\^\-help\-keymapping"
-Display a detailed description of the internal layout of a
-.I .keymapping
-file.  This is the same information as that presented in the
-.I "Key Mapping Description"
-section of this document.
-.TP
-.B "\-o \-\^\-help\-output"
-Display an explanation of the output generated by
-.I dumpkeymap
-when dissecting a
-.I .keymapping
-file.  This is the same information as that presented in the
-.I "Output Description"
-section of this document.
-.TP
-.B "\-f \-\^\-help\-files"
-Display a summary of the various files and directories which are related to
-key mappings.  This is the same information as that presented in the
-.I "Files"
-section of this document.
-.TP
-.B "\-d \-\^\-help\-diagnostics"
-Display a list of the various diagnostic messages which may be emitted by
-.I dumpkeymap.
-This is the same information as that presented in the
-.I "Diagnostics"
-section of this document.
-.TP
-.B "\-v \-\^\-version"
-Display the
-.I dumpkeymap
-version number and warranty information.
-.TP
-.B "\- \-\^\-"
-Inhibit processing of options at this point in the argument list.  An
-occurrence of `\-' or `\-\^\-' in the argument list causes all following
-arguments to be treated as file names even if an argument begins with a `\-'
-character.
-.SH "KEY MAPPING DESCRIPTION"
-The following sections describe, in complete detail, the format of a raw key
-mapping resource, as well as the format of the
-.I .keymapping
-file which encapsulates one or more raw mappings.
-.SH "Types and Data"
-The following type definitions are employed throughout this discussion:
-.PP
-.RS
-.AS
-.AZ "typedef unsigned char byte;"
-.AZ "typedef unsigned short word;"
-.AZ "typedef unsigned long dword;"
-.AE
-.RE
-.PP
-Additionally, the type definition
-.RI ` number '
-is used generically to
-indicate a numeric value.  The actual size of the
-.RI ` number '
-type may be one or two bytes depending upon how the data is stored in the key
-map.  Although most key maps use byte-sized numeric values, word-sized values
-are also allowed.
-.PP
-Multi-byte values in a key mapping file are stored in big-endian byte order.
-.SH "Key Mapping File and Device Mapping"
-A key mapping file begins with a magic-number and continues with a
-variable number of device-specific key mappings.
-.PP
-.RS
-.AS
-.AZ "struct KeyMappingFile {"
-.AN "    char magic_number[4];" "   " "// `KYM1'"
-.AN "    DeviceMapping maps[...];" "" "// Variable number of maps"
-.AZ };
-.AE
-.PP
-.AS
-.AZ "struct DeviceMapping {"
-.AN "    dword interface;" " " "// Interface type"
-.AN "    dword handler_id;" "" "// Interface subtype"
-.AN "    dword map_size;" "  " "// Byte count of `map' (below)"
-.AN "    KeyMapping map;"
-.AZ };
-.AE
-.RE
-.PP
-The value of `interface' represents a family of keyboard device types
-(such as Intel
-.SM "PC, ADB, NeXT,"
-Sun Type5, etc.), and is generally specified as one of the constant values
-.SM "NX_EVS_DEVICE_INTERFACE_ADB, NX_EVS_DEVICE_INTERFACE_ACE,"
-etc., which are are defined in IOHIDTypes.h on MacOS/X and Darwin, and in
-ev_types.h on MacOS/X Server, OpenStep, and NextStep.
-.PP
-The value of `handler_id' represents a specific keyboard layout within the
-much broader `interface' family.  For instance, for a 101-key Intel
-.SM PC
-keyboard (of type
-.SM NX_EVS_DEVICE_INTERFACE_ACE\c
-) the `handler_id' is '0', whereas for a 102-key keyboard it is `1'.
-.PP
-Together, `interface' and `handler_id' identify the exact keyboard hardware to
-which this mapping applies.  Programs which display a visual representation of
-a keyboard layout, match `interface' and `handler_id' from the
-.I .keymapping
-file against the `interface' and `handler_id' values found in each
-.I .keyboard
-file.
-.SH "Key Mapping"
-A key mapping completely defines the relationship of all scan codes with their
-associated functionality.  A
-.I KeyMapping
-structure is embedded within the
-.I DeviceMapping
-structure in a
-.IR KeyMappingFile .
-The key mapping currently in use by the WindowServer and AppKit is also
-represented by a
-.I KeyMapping
-structure, and can be referred to directly by calling NXGetKeyMapping() and
-accessing the `mapping' data member of the returned
-.I NXKeyMapping
-structure.
-.PP
-.RS
-.AS
-.AZ "struct KeyMapping {"
-.AN "    word number_size;" "          " "// 0=1 byte, non-zero=2 bytes"
-.AN "    number num_modifier_groups;" "" "// Modifier groups"
-.AZ "    ModifierGroup modifier_groups[...];"
-.AN "    number num_scan_codes;" "     " "// Scan groups"
-.AN "    ScanGroup scan_table[...];"
-.AN "    number num_sequence_lists;" " " "// Sequence lists"
-.AN "    Sequence sequence_lists[...];"
-.AN "    number num_special_keys;" "   " "// Special keys"
-.AN "    SpecialKey special_key[...];"
-.AZ };
-.AE
-.RE
-.PP
-The `number_size' flag determines the size, in bytes, of all remaining numeric
-values (denoted by the type definition
-.RI ` number ')
-within the
-key mapping.  If its value is zero, then numbers are represented by a single
-byte.  If it is non-zero, then numbers are represented by a word (two bytes).
-.SH "Modifier Group"
-A modifier group defines all scan codes which map to a particular type of
-modifier, such as
-.IR shift ,
-.IR control ,
-etc.
-.PP
-.RS
-.AS
-.AZ "enum Modifier {"
-.AZ "    ALPHALOCK = 0,"
-.AZ "    SHIFT,"
-.AZ "    CONTROL,"
-.AZ "    ALTERNATE,"
-.AZ "    COMMAND,"
-.AZ "    KEYPAD,"
-.AZ "    HELP"
-.AZ };
-.AE
-.PP
-.AS
-.AZ "struct ModifierGroup {"
-.AN "    number modifier;" "       " "// A Modifier constant"
-.AN "    number num_scan_codes;"
-.AN "    number scan_codes[...];" "" "// Variable number of scan codes"
-.AZ };
-.AE
-.RE
-.PP
-The scan_codes[] array contains a list of all scan codes which map to the
-specified modifier.  The
-.IR shift ", " command ", and " alternate
-modifiers are frequently mapped to two different scan codes, apiece,
-since these modifiers often appear on both the left and right sides of
-the keyboard.
-.SH "Scan Group"
-There is one
-.I ScanGroup
-for each scan code generated by the given keyboard.  This number is given by
-KeyMapping::num_scan_codes.  The first scan group represents hardware scan
-code 0, the second represents scan code 1, etc.
-.PP
-.RS
-.AS
-.AZ "enum ModifierMask {"
-.AN "    ALPHALOCK_MASK" "      " "= 1 << 0,"
-.AN "    SHIFT_MASK" "          " "= 1 << 1,"
-.AN "    CONTROL_MASK" "        " "= 1 << 2,"
-.AN "    ALTERNATE_MASK" "      " "= 1 << 3,"
-.AN "    CARRIAGE_RETURN_MASK" "" "= 1 << 4"
-.AZ };
-.AZ "#define NOT_BOUND 0xff"
-.AE
-.PP
-.AS
-.AZ "struct ScanGroup {"
-.AN "    number mask;"
-.AN "    Character characters[...];"
-.AZ };
-.AE
-.RE
-.PP
-For each scan code, `mask' defines which modifier combinations generate
-characters.  If `mask' is
-.SM NOT_BOUND
-(0xff) then then this scan code does not generate any characters ever, and its
-characters[] array is zero length.  Otherwise, the characters[] array contains
-one
-.I Character
-record for each modifier combination.
-.PP
-The number of records in characters[] is determined by computing (1 <<
-bits_set_in_mask).  In other words, if mask is zero, then zero bits are set,
-so characters[] contains only one record.  If `mask' is
-.SM "(SHIFT_MASK | CONTROL_MASK),"
-then two bits are set, so characters[] contains four records.
-.PP
-The first record always represents the character which is generated by that
-key when no modifiers are active.  The remaining records represent characters
-generated by the various modifier combinations.  Using the example with the
-.I shift
-and
-.I control
-masks set, record two would represent the character with the
-.I shift
-modifier active; record three, the
-.I control
-modifier active; and record four, both the
-.I shift
-and
-.I control
-modifiers active.
-.PP
-As a special case,
-.SM ALPHALOCK_MASK
-implies
-.SM SHIFT_MASK,
-though only
-.SM ALPHALOCK_MASK
-appears in `mask'.  In this case the same character is generated for both the
-.I shift
-and
-.I alpha-lock
-modifiers, but only needs to appear once in the characters[] array.
-.PP
-.SM CARRIAGE_RETURN_MASK
-does not actually refer to a modifier key.  Instead, it is used to
-distinguish the scan code which is given the special pseudo-designation of
-.I "carriage return"
-key.  Typically, this mask appears solo in a
-.I ScanGroup
-record and only the two
-.I Character
-records for control-M and control-C follow.  This flag may be a throwback to
-an earlier time or may be specially interpreted by the low-level keyboard
-driver, but its purpose is otherwise enigmatic.
-.SH Character
-Each
-.I Character
-record indicates the character generated when this key is pressed, as well as
-the character set which contains the character.  Well known character sets are
-.SM `ASCII'
-and `Symbol'.  The character set can also be one of the meta values
-.SM FUNCTION_KEY
-or
-.SM KEY_SEQUENCE.
-If it is
-.SM FUNCTION_KEY
-then `char_code' represents a generally well-known function key such as those
-enumerated by
-.I FunctionKey.
-If the character set is
-.SM KEY_SEQUENCE
-then `char_code' represents is a zero-base index into
-KeyMapping::sequence_lists[].
-.PP
-.RS
-.AS
-.AZ "enum CharacterSet {"
-.AN "    ASCII" "       " "= 0x00,"
-.AN "    SYMBOL" "      " "= 0x01,"
-.AN "    ..."
-.AN "    FUNCTION_KEY" "" "= 0xfe,"
-.AN "    KEY_SEQUENCE" "" "= 0xff"
-.AZ };
-.AE
-.PP
-.AS
-.AZ "struct Character {"
-.AN "    number set;" "      " "// CharacterSet of generated character"
-.AN "    number char_code;" "" "// Actual character generated"
-.AZ };
-.AE
-.PP
-.AS
-.AZ "enum FunctionKey {"
-.AZ "    F1 = 0x20, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12,"
-.AZ "    INSERT, DELETE, HOME, END, PAGE_UP, PAGE_DOWN, PRINT_SCREEN,"
-.AZ "    SCROLL_LOCK, PAUSE, SYS_REQUEST, BREAK, RESET, STOP, MENU,"
-.AZ "    USER, SYSTEM, PRINT, CLEAR_LINE, CLEAR_DISPLAY, INSERT_LINE,"
-.AZ "    DELETE_LINE, INSERT_CHAR, DELETE_CHAR, PREV, NEXT, SELECT"
-.AZ };
-.AE
-.RE
-.SH Sequence
-When Character::set contains the meta value
-.SM KEY_SEQUENCE,
-the scan code is bound to a sequence of keys rather than a single character.
-A sequence is a series of modifiers and characters which are automatically
-generated when the associated key is depressed.
-.PP
-.RS
-.AS
-.AZ "#define MODIFIER_KEY 0xff"
-.AE
-.PP
-.AS
-.AZ "struct Sequence {"
-.AN "    number num_chars;"
-.AN "    Character characters[...];"
-.AZ };
-.AE
-.RE
-.PP
-Each generated
-.I Character
-is represented as previously described, with the exception that
-.SM MODIFIER_KEY
-may appear in place of
-.SM KEY_SEQUENCE.
-When the value of Character::set is
-.SM MODIFIER_KEY
-then Character::char_code represents a modifier key rather than an actual
-character.  If the modifier represented by `char_code' is non-zero, then it
-indicates that the associated modifier key has been depressed.  In this case,
-the value is one of the constants enumerated by
-.I Modifier
-(\c
-.SM "SHIFT, CONTROL, ALTERNATE,"
-etc.).  If the value is zero then it means that the modifier keys have been
-released.
-.SH "Special Key"
-A special key is one which is scanned directly by the Mach kernel rather than
-by the WindowServer.  In general, events are not generated for special keys.
-.PP
-.RS
-.AS
-.AZ "enum SpecialKeyType {"
-.AZ "    VOLUME_UP = 0,"
-.AZ "    VOLUME_DOWN,"
-.AZ "    BRIGHTNESS_UP,"
-.AZ "    BRIGHTNESS_DOWN,"
-.AZ "    ALPHA_LOCK,"
-.AZ "    HELP,"
-.AZ "    POWER,"
-.AZ "    SECONDARY_ARROW_UP,"
-.AZ "    SECONDARY_ARROW_DOWN"
-.AZ };
-.AE
-.PP
-.AS
-.AZ "struct SpecialKey {"
-.AN "    number type;" "     " "// A SpecialKeyType constant"
-.AN "    number scan_code;" "" "// Actual scan code"
-.AZ };
-.AE
-.RE
-.SH OUTPUT
-What follows is an explanation and description of the various pieces of
-information emitted by
-.I dumpkeymap.
-.PP
-For a more thorough discussion of any particular piece of information described
-here, refer to the detailed description of the internal layout of a key mapping
-provided by the
-.I "Key Mapping Description"
-section above.
-.SH Conventions
-Depending upon context, some numeric values are displayed in decimal
-notation, whereas others are displayed in hexadecimal notation.
-Hexadecimal numbers are denoted by a `0x' prefix (for instance, `0x7b'),
-except when explicitly noted otherwise.
-.SH "Key Mapping Source"
-The first piece of information presented about a particular key mapping is the
-source from which the data was gleaned.  For a
-.I .keymapping
-file, the title
-.SM "`KEYMAP FILE'"
-is emitted along with the path and name of the file in question.  For the key
-mapping currently in use by the WindowServer and AppKit, the title
-.SM "`ACTIVE KEYMAP'"
-is emitted instead.
-.SH "Device Information"
-Each
-.I .keymapping
-file may contain one or more raw key mappings.  For example, a file which maps
-keys to a Dvorak-style layout might contain raw mappings for Intel
-.SM "PC, ADB, NeXT,"
-and Sun Type5 keyboards.
-.PP
-For each raw mapping, the following information is emitted:
-.BG
-.BU
-The title
-.SM `KEYMAP'
-along with the mapping's relative position in the
-.I .keymapping
-file.
-.BU
-The `interface' identifier.
-.BU
-The `handler_id' sub-identifier.
-.BU
-The size of the raw mapping resource counted in bytes.
-.BE
-The `interface' and `handler_id' values, taken together, define a specific
-keyboard device.  A
-.I .keyboard
-file, which describes the visual layout of a keyboard, also contains
-`interface' and `handler_id' identifiers.  The
-.I .keyboard
-file corresponding to a particular key mapping can be found by matching the
-`interface' and `handler_id' values from each resource.
-.SH Modifiers
-Each mapping may contain zero or more modifier records which associate hardware
-scan codes with modifier descriptions such as
-.I "shift, control, alternate,"
-etc.  The title
-.SM `MODIFIERS'
-is printed along with the count of modifier records which follow.  For each
-modifier record, the modifier's name is printed along with a list of scan
-codes, in hexadecimal format, which generate that modifier value.  For example:
-.PP
-.RS
-.nf
-MODIFIERS [4]
-alternate: 0x1d 0x60
-control: 0x3a
-keypad: 0x52 0x53 ... 0x63 0x62
-shift: 0x2a 0x36
-.fi
-.RE
-.SH Characters
-Each mapping may contain zero or more character records which associate
-hardware scan codes with the actual characters generated by those scan
-codes in the presence or absence of various modifier combinations.  The
-title
-.SM `CHARACTERS'
-is printed along with the count of character records which follow.  Here is a
-highly abbreviated example:
-.PP
-.RS
-.nf
-CHARACTERS [9]
-scan 0x00: -AC-L  "a" "A" "^A" "^A" ca c7 "^A" "^A"
-scan 0x07: -AC-L  "x" "X" "^X" "^X" 01/b4 01/ce "^X" "^X"
-scan 0x0a: ---S-  "<" ">"
-scan 0x13: -ACS-  "2" "@" "^@" "^@" b2 b3 "^@" "^@"
-scan 0x24: R----  "^M" "^C"
-scan 0x3e: -----  [F4]
-scan 0x4a: -----  [page up]
-scan 0x60: -----  {seq#3}
-scan 0x68: not-bound
-.fi
-.RE
-.PP
-For each record, the hexadecimal value of the hardware scan code is printed,
-followed by a list of modifier flag combinations and the actual characters
-generated by this scan code with and without modifiers applied.
-.PP
-The modifier flags field is composed of a combination of single letter
-representations of the various modifier types.  The letters stand for:
-.PP
-.RS
-.nf
-L \- alpha-lock
-S \- shift
-C \- control
-A \- alternate
-R \- carriage-return
-.fi
-.RE
-.PP
-As a special case, the
-.I alpha-lock
-flag also implies the
-.I shift
-flag, so these two flags never appear together in the same record.
-.PP
-The combination of modifier flags determines the meaning and number of fields
-which follow.  The first field after the modifier flags always represents the
-character that will be generated if no modifier keys are depressed.  The
-remaining fields represent characters generated by the various modifier
-combinations.  The order of the fields follows this general pattern:
-.BG
-.BU
-The character generated by this scan code when no modifiers are in effect is
-listed first.
-.BU
-If the `L' or `S' flag is active, then the shifted character generated by this
-scan code is listed next.
-.BU
-If the `C' flag is active, then the control-character generated by this scan
-code is listed next.  Furthermore, if the `L' or `S' flag is also active, then
-the shifted control-character is listed after that.
-.BU
-If the `A' flag is active, then the alternate-character generated by this scan
-code is listed next.  Furthermore, if the `L' or `S' flag is active, then the
-shifted alternate-character is listed after that.  If the `C' flag is also
-active, then the alternate-control-character is listed next.  Finally, if the
-`C' and `L' or `C' and `S' flags are also active, then the shifted
-alternate-control-character is listed.
-.BE
-The `R' flag does not actually refer to a modifier key.  Instead, it is used to
-distinguish the scan code which is given the special pseudo-designation of
-.I "carriage return"
-key.  Typically, this mask appears solo and only the two fields for control-M
-and control-C follow.  This flag may be a throwback to an earlier time or may
-be specially interpreted by the low-level keyboard driver, but its purpose is
-otherwise enigmatic.
-.PP
-Recalling the example from above, the following fields can be identified:
-.PP
-.RS
-.nf
-scan 0x00: -AC-L  "a" "A" "^A" "^A" ca c7 "^A" "^A"
-.fi
-.RE
-.BG
-.BU
-Lower-case `a' is generated when no modifiers are active.
-.BU
-Upper-case `A' is generated when
-.IR shift " or " alpha-lock
-are active.
-.BU
-Control-A is generated when
-.I control
-is active.
-.BU
-Control-A is generated when
-.IR control " and " shift
-are active.
-.BU
-The character represented by the hexadecimal code 0xca is generated when
-.I alternate
-is active.
-.BU
-The character represented by 0xc7 is generated when
-.IR alternate " and " shift " (or " alpha-lock ") are active."
-.BU
-Control-A is generated when
-.IR alternate " and " control
-are active.
-.BU
-Control-A is generated when
-.IR "alternate, control" " and " shift " (or " alpha-lock ") are active."
-.BE
-The notation used to represent a particular generated character varies.
-.BG
-.BU
-Printable
-.SM ASCII
-characters are quoted, as in "x" or "X".
-.BU
-Control-characters are quoted and prefixed with `^', as in "^X".
-.BU
-Characters with values greater than 127 (0x7f) are displayed as hexadecimal
-values without the `0x' prefix.
-.BU
-Characters in a non-\c
-.SM ASCII
-character set (such as `Symbol') are displayed as two hexadecimal numbers
-separated by a slash, as in `01/4a'.  The first number is the character set's
-identification code (such as `01' for the `Symbol' set), and the second number
-is the value of the generated character.
-.BU
-Non-printing special function characters are displayed with the function's
-common name enclosed in brackets, as in `[page up]' or `[F4]'.
-.BU
-If the binding represents a key sequence rather than a single character, then
-the sequence's identification number is enclosed in braces, as in `{seq#3}'.
-.BE
-Recalling a few examples from above, the following interpretations can be made:
-.PP
-.RS
-.nf
-scan 0x07: -AC-L  "x" "X" "^X" "^X" 01/b4 01/ce "^X" "^X"
-scan 0x3e: -----  [F4]
-scan 0x4a: -----  [page up]
-scan 0x60: -----  {seq#3}
-.fi
-.RE
-.BG
-.BU
-"x" and "X" are printable
-.SM ASCII
-characters.
-.BU
-"^X" is a control-character.
-.BU
-`01/b4' and `01/ce' represent the character codes 0xb4 and 0xce in the `Symbol'
-character set.
-.BU
-Scan code 0x3e generates function-key `F4', and scan code 0x4a generates
-function-key `page up'.
-.BU
-Scan code 0x60 is bound to key sequence #3.
-.BE
-Finally, if a scan code is not bound to any characters, then it is annotated
-with the label `not-bound', as with example scan code 0x68 from above.
-.SH Sequences
-A scan code (modified and unmodified) can be bound to a key sequence rather
-than generating a single character or acting as a modifier.  When it is bound
-to a key sequence, a series of character invocations and modifier actions are
-automatically generated rather than a single keystroke.
-.PP
-Each mapping may contain zero or more key sequence records.  The title
-.SM `SEQUENCES'
-is printed along with the count of sequence records which follow.  For example:
-.PP
-.RS
-.nf
-SEQUENCES [3]
-sequence 0: "f" "o" "o"
-sequence 1: {alternate} "b" "a" "r" {unmodify}
-sequence 2: [home] "b" "a" "z"
-.fi
-.RE
-.PP
-The notation used to represent the sequence of generated characters is
-identical to the notation already described in the
-.I Characters
-section above, with the exception that modifier actions may be interposed
-between generated characters.  Such modifier actions are represented by the
-modifier's name enclosed in braces.  The special name `{unmodify}' indicates
-the release of the modifier keys.
-.PP
-Thus, the sequences in the above example can be interpreted as follows:
-.BG
-.BU
-Sequence\ #0 generates `foo'.
-.BU
-Sequence\ #1 invokes the
-.I alternate
-modifier, generates `bar', and then releases
-.I alternate.
-.BU
-Sequence\ #2 invokes the
-.I home
-key and then generates `baz'.  In a text editor, this would probably result in
-`baz' being prepended to the line of text on which the cursor resides.
-.BE
-.SH Special Keys
-Certain keyboards feature keys which perform some type of special purpose
-function rather than generating a character or acting as a modifier.  For
-instance, Apple keyboards often contain a
-.I power
-key, and
-.SM NeXT
-keyboards have historically featured screen brightness and volume control keys.
-.PP
-Each mapping may contain zero or more special-key records which associate
-hardware scan codes with such special purpose functions.  The title
-.SM `SPECIALS'
-is printed along with the count of records which follow.  For each record, the
-special function's name is printed along with a list of scan codes, in
-hexadecimal format, which are bound to that function.  For example:
-.PP
-.RS
-.nf
-SPECIALS [6]
-alpha-lock: 0x39
-brightness-down: 0x79
-brightness-up: 0x74
-power: 0x7f
-sound-down: 0x77
-sound-up: 0x73
-.fi
-.RE
-.SH FILES
-.IP *.keymapping
-A key mapping file which precisely defines the relationship of all
-hardware-specific keyboard scan-codes with their associated functionality.
-.IP *.keyboard
-A file describing the physical layout of keys on a particular type of
-keyboard.  Each `key' token in this file defines the position and shape of the
-key on the keyboard, as well as the associated scan code which that key
-generates.  A
-.I .keymapping
-file, on the other hand, defines the characters which are generated by a
-particular scan code depending upon the state of the various modifier keys
-(such as
-.I shift,
-.I control,
-etc.).  The `interface' and `handler_id' values from a
-.I .keymapping
-file are matched against those in each
-.I .keyboard
-file in order to associate a particular
-.I .keyboard
-file with a key mapping.  Various
-.SM GUI
-programs use the
-.I .keyboard
-file to display a visual representation of a keyboard for the user.  Since
-these files are just plain text, they can be easily viewed and interpreted
-without the aid of a specialized program, thus
-.I dumpkeymap
-leaves these files alone.
-.PP
-/System/Library/Keyboards
-.br
-/Network/Library/Keyboards
-.br
-/Local/Library/Keyboards
-.br
-/Library/Keyboards
-.RS
-Repositories for
-.I .keymapping
-and
-.I .keyboard
-files for MacOS/X, Darwin, and MacOS/X Server.
-.RE
-.PP
-/NextLibrary/Keyboards
-.br
-/LocalLibrary/Keyboards
-.RS
-Repositories for
-.I .keymapping
-and
-.I .keyboard
-files for OpenStep and NextStep.
-.RE
-.IP $(HOME)/Library/Keyboards
-Repository for personal
-.I .keymapping
-and
-.I .keyboard
-files.
-.SH DIGANOSTICS
-The following diagnostic messages may be issued to the standard error stream.
-.TG "Unrecognized option."
-An unrecognized option was specified on the command-line.  Invoke
-.I dumpkeymap
-with the
-.B "\-\^\-help"
-option to view a list of valid options.
-.TG "Insufficient data in keymapping data stream."
-The key mapping file or data stream is corrupt.  Either the file has been
-incorrectly truncated or a field, such as those which indicates the number of
-variable records which follow, contains a corrupt value.
-.PP
-The following diagnostic messages have significance only when trying to print
-.I .keymapping
-files mentioned on the command-line.
-.TG "Bad magic number."
-The mentioned file is not a
-.I .keymapping
-file.  The file's content does not start with the string `KYM1'.
-.TG "Unable to open key mapping file."
-The call to fopen() failed; probably because the specified path is invalid or
-.I dumpkeymap
-does not have permission to read the file.
-.TG "Unable to determine key mapping file size."
-The call to fstat() failed, thus memory can not be allocated for loading the
-file.
-.TG "Unable to read key mapping file."
-The call to fread() failed.
-.PP
-The following diagnostic messages have significance only when trying to print
-the currently active key mapping when no
-.I .keymapping
-files have been mentioned on the command-line.
-.TG "Unable to open event status driver."
-The call to NXOpenEventStatus() failed.
-.TG "Bad key mapping length."
-The call to NXKeyMappingLength() returned a bogus value.
-.TG "Unable to get current key mapping."
-The call to NXGetKeyMapping() failed.
-.PP
-The following diagnostic messages have significance only when using
-.I dumpkeymap
-on a non-Apple/\c
-.SM NeXT
-platform.
-.TG "Must specify at least one .keymapping file."
-No
-.I .keymapping
-files were mentioned on the command-line.  On non-Apple/\c
-.SM NeXT
-platforms, there is no concept of a currently active
-.I .keymapping
-file, so at least one file must be mentioned on the command-line.
-.SH AUTHOR
-Eric Sunshine <sunshine at sunshineco.com> wrote
-.I dumpkeymap
-and this document, the
-.I "dumpkeymap user's manual."
-Both
-.I dumpkeymap
-and this document are copyright \(co1999,2000 by Eric Sunshine
-<sunshine at sunshineco.com>.  All rights reserved.
-.PP
-The implementation of
-.I dumpkeymap
-is based upon information gathered on September 3, 1997 by Eric Sunshine
-<sunshine at sunshineco.com> and Paul S. McCarthy <zarnuk at zarnuk.com> during an
-effort to reverse engineer the format of the
-.SM NeXT
-.I .keymapping
-file.
-.if n .PP
-.if n Version \n(VE \-\-
-.if n .UP
commit e7026216ccaa8e4fb073800ba947c9909d4faada
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Mon Dec 3 20:20:05 2007 -0800

    Darwin: Combine launcher and server X11.app
    This should hopefully eliminate confusion some people have over which X11.app is which.
    Now BOTH are in /A/U/X11.app and we intelligently determine whether to execute our app_to_run
    or launch the server.  If arguments are given, we launch the server.  Otherwise if we can
    connect to an X DISPLAY, we execute app_to_run.  Otherwise, we launch the server.
    
    (cherry picked from commit 0284b3631a4c501d7b3f39774dbc2416c4121c58)
    (cherry picked from commit b0349d5b6cb7a83a696760e6ffd2bf1129ca755f)
    (cherry picked from commit c3c71a882f8c60435718c83d353890e3cd5812db)

diff --git a/configure.ac b/configure.ac
index a70d310..b8d5271 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2155,7 +2155,6 @@ hw/xnest/Makefile
 hw/xwin/Makefile
 hw/darwin/Makefile
 hw/darwin/apple/Makefile
-hw/darwin/launcher/Makefile
 hw/darwin/quartz/Makefile
 hw/darwin/quartz/xpr/Makefile
 hw/darwin/utils/Makefile
diff --git a/hw/darwin/Makefile.am b/hw/darwin/Makefile.am
index 1faedcb..136c41a 100644
--- a/hw/darwin/Makefile.am
+++ b/hw/darwin/Makefile.am
@@ -6,7 +6,7 @@ AM_CPPFLAGS = \
 	-I$(top_srcdir)/miext/rootless
 
 if X11APP
-X11APP_SUBDIRS = apple launcher
+X11APP_SUBDIRS = apple
 endif
 
 SUBDIRS = quartz utils $(X11APP_SUBDIRS)
diff --git a/hw/darwin/apple/Makefile.am b/hw/darwin/apple/Makefile.am
index 02a2c25..a6e2dfb 100644
--- a/hw/darwin/apple/Makefile.am
+++ b/hw/darwin/apple/Makefile.am
@@ -6,15 +6,20 @@ x11app:
 	xcodebuild CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" ARCHS="$(X11APP_ARCHS)"
 
 install-data-hook:
-	xcodebuild install DSTROOT=$(DESTDIR) INSTALL_PATH=$(prefix) DEPLOYMENT_LOCATION=YES SKIP_INSTALL=NO ARCHS="$(X11APP_ARCHS)"
+	xcodebuild install DSTROOT="/$(DESTDIR)" INSTALL_PATH="$(APPLE_APPLICATIONS_DIR)" DEPLOYMENT_LOCATION=YES SKIP_INSTALL=NO ARCHS="$(X11APP_ARCHS)"
+	$(MKDIR_P) "$(DESTDIR)/System/Library/LaunchAgents/"
+	$(INSTALL) org.x.X11.plist "$(DESTDIR)/System/Library/LaunchAgents/"
 
 clean-local:
 	rm -rf build
 
 EXTRA_DIST = \
+	org.x.X11.plist \
 	Info.plist \
 	X11.icns \
 	bundle-main.c \
+	launcher-main.c \
+	server-main.c \
 	English.lproj/InfoPlist.strings \
 	English.lproj/Localizable.strings \
 	English.lproj/main.nib/classes.nib \
diff --git a/hw/darwin/apple/X11.xcodeproj/project.pbxproj b/hw/darwin/apple/X11.xcodeproj/project.pbxproj
index 217f07e..225f371 100644
--- a/hw/darwin/apple/X11.xcodeproj/project.pbxproj
+++ b/hw/darwin/apple/X11.xcodeproj/project.pbxproj
@@ -7,6 +7,8 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
+		3F5E1BE00D04BF110020CA24 /* launcher-main.c in Sources */ = {isa = PBXBuildFile; fileRef = 3F5E1BDE0D04BF110020CA24 /* launcher-main.c */; };
+		3F5E1BE10D04BF110020CA24 /* server-main.c in Sources */ = {isa = PBXBuildFile; fileRef = 3F5E1BDF0D04BF110020CA24 /* server-main.c */; };
 		527F24190B5D938C007840A7 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0867D6AAFE840B52C02AAC07 /* InfoPlist.strings */; };
 		527F241A0B5D938C007840A7 /* main.nib in Resources */ = {isa = PBXBuildFile; fileRef = 02345980000FD03B11CA0E72 /* main.nib */; };
 		527F241B0B5D938C007840A7 /* X11.icns in Resources */ = {isa = PBXBuildFile; fileRef = 50459C5F038587C60ECA21EC /* X11.icns */; };
@@ -20,6 +22,8 @@
 /* Begin PBXFileReference section */
 		0867D6ABFE840B52C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
 		1870340FFE93FCAF11CA0CD7 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/main.nib; sourceTree = "<group>"; };
+		3F5E1BDE0D04BF110020CA24 /* launcher-main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "launcher-main.c"; sourceTree = "<group>"; };
+		3F5E1BDF0D04BF110020CA24 /* server-main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "server-main.c"; sourceTree = "<group>"; };
 		50459C5F038587C60ECA21EC /* X11.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = X11.icns; sourceTree = "<group>"; };
 		50EE2AB703849F0B0ECA21EC /* bundle-main.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = "bundle-main.c"; sourceTree = "<group>"; };
 		50F4F0A7039D6ACA0E82C0CB /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = "<absolute>"; };
@@ -65,6 +69,8 @@
 		20286C2AFDCF999611CA2CEA /* Sources */ = {
 			isa = PBXGroup;
 			children = (
+				3F5E1BDE0D04BF110020CA24 /* launcher-main.c */,
+				3F5E1BDF0D04BF110020CA24 /* server-main.c */,
 				50EE2AB703849F0B0ECA21EC /* bundle-main.c */,
 			);
 			name = Sources;
@@ -133,7 +139,6 @@
 			mainGroup = 20286C29FDCF999611CA2CEA /* X11 */;
 			projectDirPath = "";
 			projectRoot = "";
-			shouldCheckCompatibility = 1;
 			targets = (
 				527F24160B5D938C007840A7 /* X11 */,
 			);
@@ -171,6 +176,8 @@
 			buildActionMask = 2147483647;
 			files = (
 				527F241D0B5D938C007840A7 /* bundle-main.c in Sources */,
+				3F5E1BE00D04BF110020CA24 /* launcher-main.c in Sources */,
+				3F5E1BE10D04BF110020CA24 /* server-main.c in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/hw/darwin/apple/bundle-main.c b/hw/darwin/apple/bundle-main.c
index 10d2f20..c436d51 100644
--- a/hw/darwin/apple/bundle-main.c
+++ b/hw/darwin/apple/bundle-main.c
@@ -1,6 +1,7 @@
-/* bundle-main.c -- X server launcher
+/* main.c -- X application launcher
  
- Copyright (c) 2002-2007 Apple Inc. All rights reserved.
+ Copyright (c) 2007 Jeremy Huddleston
+ Copyright (c) 2007 Apple Inc
  
  Permission is hereby granted, free of charge, to any person
  obtaining a copy of this software and associated documentation files
@@ -25,880 +26,57 @@
  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.
- 
- Parts of this file are derived from xdm, which has this copyright:
- 
- Copyright 1988, 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. */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/socket.h>
-#include <sys/utsname.h>
-#include <ifaddrs.h>
-#include <netdb.h>
-#include <netinet/in.h>
-#include <time.h>
-#include <sys/wait.h>
-#include <setjmp.h>
-#include <sys/ioctl.h>
+ prior written authorization. */
 
 #include <X11/Xlib.h>
-#include <X11/Xauth.h>
-#include <xcb/xcb.h>
-
-#include <CoreFoundation/CoreFoundation.h>
-#include <SystemConfiguration/SystemConfiguration.h>
-
-#define X_SERVER "/usr/X11/bin/Xquartz"
-#define XTERM_PATH "/usr/X11/bin/xterm"
-#define WM_PATH "/usr/bin/quartz-wm"
-#define DEFAULT_XINITRC "/usr/X11/lib/X11/xinit/xinitrc"
-#define DEFAULT_PATH "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11/bin"
-
-/* what xinit does */
-#ifndef SHELL
-# define SHELL "sh"
-#endif
-
-#undef FALSE
-#define FALSE 0
-#undef TRUE
-#define TRUE 1
-
-#define MAX_DISPLAYS 64
-
-static int server_pid = -1, client_pid = -1;
-static int xinit_kills_server = FALSE;
-static jmp_buf exit_continuation;
-static const char *server_name = NULL;
-static Display *server_dpy;
-
-static char *auth_file;
-
-typedef struct addr_list_struct addr_list;
-
-struct addr_list_struct {
-    addr_list *next;
-    Xauth auth;
-};
-
-static addr_list *addresses;
-
-
-/* Utility functions. */
-
-/* Return the current host name. Matches what Xlib does. */
-static char *
-host_name (void)
-{
-#ifdef NEED_UTSNAME
-    static struct utsname name;
-	
-    uname(&name);
-	
-    return name.nodename;
-#else
-    static char buf[100];
-	
-    gethostname(buf, sizeof(buf));
-	
-    return buf;
-#endif
-}
-
-static int
-read_boolean_pref (CFStringRef name, int default_)
-{
-    int value;
-    Boolean ok;
-	
-    value = CFPreferencesGetAppBooleanValue (name,
-											 CFSTR ("com.apple.x11"), &ok);
-    return ok ? value : default_;
-}
-
-static inline int
-binary_equal (const void *a, const void *b, int length)
-{
-    return memcmp (a, b, length) == 0;
-}
-
-static inline void *
-binary_dup (const void *a, int length)
-{
-    void *b = malloc (length);
-    if (b != NULL)
-		memcpy (b, a, length);
-    return b;
-}
-
-static inline void
-binary_free (void *data, int length)
-{
-    if (data != NULL)
-		free (data);
-}
-
-
-/* Functions for managing the authentication entries. */
-
-/* Returns true if something matching AUTH is in our list of auth items */
-static int
-check_auth_item (Xauth *auth)
-{
-    addr_list *a;
-	
-    for (a = addresses; a != NULL; a = a->next)
-    {
-		if (a->auth.family == auth->family
-			&& a->auth.address_length == auth->address_length
-			&& binary_equal (a->auth.address, auth->address, auth->address_length)
-			&& a->auth.number_length == auth->number_length
-			&& binary_equal (a->auth.number, auth->number, auth->number_length)
-			&& a->auth.name_length == auth->name_length
-			&& binary_equal (a->auth.name, auth->name, auth->name_length))
-		{
-			return TRUE;
-		}
-    }
-	
-    return FALSE;
-}
-
-/* Add one item to our list of auth items. */
-static void
-add_auth_item (Xauth *auth)
-{
-    addr_list *a = malloc (sizeof (addr_list));
-	
-    a->auth.family = auth->family;
-    a->auth.address_length = auth->address_length;
-    a->auth.address = binary_dup (auth->address, auth->address_length);
-    a->auth.number_length = auth->number_length;
-    a->auth.number = binary_dup (auth->number, auth->number_length);
-    a->auth.name_length = auth->name_length;
-    a->auth.name = binary_dup (auth->name, auth->name_length);
-    a->auth.data_length = auth->data_length;
-    a->auth.data = binary_dup (auth->data, auth->data_length);
-	
-    a->next = addresses;
-    addresses = a;
-}
-
-/* Free all allocated auth items. */
-static void
-free_auth_items (void)
-{
-    addr_list *a;
-	
-    while ((a = addresses) != NULL)
-    {
-		addresses = a->next;
-		
-		binary_free (a->auth.address, a->auth.address_length);
-		binary_free (a->auth.number, a->auth.number_length);
-		binary_free (a->auth.name, a->auth.name_length);
-		binary_free (a->auth.data, a->auth.data_length);
-		free (a);
-    }
-}
-
-/* Add the unix domain auth item. */
-static void
-define_local (Xauth *auth)
-{
-    char *host = host_name ();
-	
-#ifdef DEBUG
-    fprintf (stderr, "x11: hostname is %s\n", host);
-#endif
-	
-    auth->family = FamilyLocal;
-    auth->address_length = strlen (host);
-    auth->address = host;
-	
-    add_auth_item (auth);
-}
-
-/* Add the tcp auth item. */
-static void
-define_named (Xauth *auth, const char *name)
-{
-    struct ifaddrs *addrs, *ptr;
-	
-    if (getifaddrs (&addrs) != 0)
-		return;
-	
-    for (ptr = addrs; ptr != NULL; ptr = ptr->ifa_next)
-    {
-		if (ptr->ifa_addr->sa_family != AF_INET)
-			continue;
-		
-		auth->family = FamilyInternet;
-		auth->address_length = sizeof (struct in_addr);
-		auth->address = (char *) &(((struct sockaddr_in *) ptr->ifa_addr)->sin_addr);
-		
-#ifdef DEBUG
-		fprintf (stderr, "x11: ipaddr is %d.%d.%d.%d\n",
-				 (unsigned char) auth->address[0],
-				 (unsigned char) auth->address[1],
-				 (unsigned char) auth->address[2],
-				 (unsigned char) auth->address[3]);
-#endif
-		
-		add_auth_item (auth);
-    }
-	
-    freeifaddrs (addrs);
-}
-
-/* Parse the display number from NAME and add it to AUTH. */
-static void
-set_auth_number (Xauth *auth, const char *name)
-{
-    char *colon;
-    char *dot, *number;
-	
-    colon = strrchr(name, ':');
-    if (colon != NULL)
-    {
-		colon++;
-		dot = strchr(colon, '.');
-		
-		if (dot != NULL)
-			auth->number_length = dot - colon;
-		else
-			auth->number_length = strlen (colon);
-		
-		number = malloc (auth->number_length + 1);
-		if (number != NULL)
-		{
-			strncpy (number, colon, auth->number_length);
-			number[auth->number_length] = '\0';
-		}
-		else
-		{
-			auth->number_length = 0;
-		}
-		
-		auth->number = number;
-    }
-}
-
-/* Put 128 bits of random data into DATA. If possible, it will be "high
- quality" */
-static int
-generate_mit_magic_cookie (char data[16])
-{
-    int fd, ret, i;
-    long *ldata = (long *) data;
-	
-    fd = open ("/dev/random", O_RDONLY);
-    if (fd > 0) {
-		ret = read (fd, data, 16);
-		close (fd);
-		if (ret == 16) return TRUE;
-    }
-	
-    /* fall back to the usual crappy rng */
-	
-    srand48 (getpid () ^ time (NULL));
-	
-    for (i = 0; i < 4; i++)
-		ldata[i] = lrand48 ();
-	
-    return TRUE;
-}
-
-/* Create the keys we'll be using for the display named NAME. */
-static int
-make_auth_keys (const char *name)
-{
-    Xauth auth;
-    char key[16];
-	
-    if (auth_file == NULL)
-		return FALSE;
-	
-    auth.name = "MIT-MAGIC-COOKIE-1";
-    auth.name_length = strlen (auth.name);
-	
-    if (!generate_mit_magic_cookie (key))
-    {
-		auth_file = NULL;
-		return FALSE;
-    }
-	
-    auth.data = key;
-    auth.data_length = 16;
-	
-    set_auth_number (&auth, name);
-	
-    define_named (&auth, host_name ());
-    define_local (&auth);
-	
-    free (auth.number);
-	
-    return TRUE;
-}
-
-/* If ADD-ENTRIES is true, merge our auth entries into the existing
- Xauthority file. If ADD-ENTRIES is false, remove our entries. */
-static int
-write_auth_file (int add_entries)
-{
-    char *home, newname[1024];
-    int fd, ret;
-    FILE *new_fh, *old_fh;
-    addr_list *addr;
-    Xauth *auth;
-	
-    if (auth_file == NULL)
-		return FALSE;
-	
-    home = getenv ("HOME");
-    if (home == NULL)
-    {
-		auth_file = NULL;
-		return FALSE;
-    }
-	
-    snprintf (newname, sizeof (newname), "%s/.XauthorityXXXXXX", home);
-    mktemp (newname);
-	
-    if (XauLockAuth (auth_file, 1, 2, 10) != LOCK_SUCCESS)
-    {
-		/* FIXME: do something here? */
-		
-		auth_file = NULL;
-		return FALSE;
-    }
-	
-    fd = open (newname, O_WRONLY | O_CREAT | O_TRUNC, 0600);
-    if (fd >= 0)
-    {
-		new_fh = fdopen (fd, "w");
-		if (new_fh != NULL)
-		{
-			if (add_entries)
-			{
-				for (addr = addresses; addr != NULL; addr = addr->next)
-				{
-					XauWriteAuth (new_fh, &addr->auth);
-				}
-			}
-			
-			old_fh = fopen (auth_file, "r");
-			if (old_fh != NULL)
-			{
-				while ((auth = XauReadAuth (old_fh)) != NULL)
-				{
-					if (!check_auth_item (auth))
-						XauWriteAuth (new_fh, auth);
-					XauDisposeAuth (auth);
-				}
-				fclose (old_fh);
-			}
-			
-			fclose (new_fh);
-			unlink (auth_file);
-			
-			ret = rename (newname, auth_file);
-			
-			if (ret != 0)
-				auth_file = NULL;
-			
-			XauUnlockAuth (auth_file);
-			return ret == 0;
-		}
-		
-		close (fd);
-    }
-	
-    XauUnlockAuth (auth_file);
-    auth_file = NULL;
-    return FALSE;
-}
-
-
-/* Subprocess management functions. */
-
-static int
-start_server (char **xargv)
-{
-    int child;
-	
-    child = fork ();
-	
-    switch (child)
-    {
-    case -1:				/* error */
-		perror ("fork");
-		return FALSE;
-		
-    case 0:				/* child */
-		execv (X_SERVER, xargv);
-		perror ("Couldn't exec " X_SERVER);
-		_exit (1);
-		
-    default:				/* parent */
-		server_pid = child;
-		return TRUE;
-    }
-}
-
-static int
-wait_for_server (void)
-{
-    int count = 100;
-	
-    while (count-- > 0)
-    {
-		int status;
-		
-		server_dpy = XOpenDisplay (server_name);
-		if (server_dpy != NULL)
-			return TRUE;
-		
-		if (waitpid (server_pid, &status, WNOHANG) == server_pid)
-			return FALSE;
-		
-		sleep (1);
-    }
-	
-    return FALSE;
-}
-
-static int
-start_client (void)
-{
-    int child;
-	
-    child = fork();
-	
-    switch (child) {
-		char *temp, buf[1024];		
-
-	case -1:				/* error */
-		perror("fork");
-		return FALSE;
-
-	case 0:					/* child */
-		/* Setup environment */
-		temp = getenv("DISPLAY");
-		if (temp != NULL && temp[0] != 0)
-			setenv("DISPLAY", server_name, TRUE);
-
-		temp = getenv("PATH");
-		if (temp == NULL || temp[0] == 0) 
-			setenv ("PATH", DEFAULT_PATH, TRUE);
-		else if (strnstr(temp, "/usr/X11/bin", sizeof(temp)) == NULL) {
-			snprintf(buf, sizeof(buf), "%s:/usr/X11/bin", temp);		
-			setenv("PATH", buf, TRUE);	
-		}
-		
-		/* First try value of $XINITRC, if set. */
-		temp = getenv("XINITRC");
-		if (temp != NULL && temp[0] != 0 && access(temp, R_OK) == 0)
-			execlp (SHELL, SHELL, temp, NULL);
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
 
-		/* Then look for .xinitrc in user's home directory. */
-		temp = getenv("HOME");
-		if (temp != NULL && temp[0] != 0) {
-			chdir(temp);
-			snprintf (buf, sizeof (buf), "%s/.xinitrc", temp);
-			if (access(buf, R_OK) == 0)
-				execlp(SHELL, SHELL, buf, NULL);
-		}
-		
-		/* Then try the default xinitrc in the lib directory. */
-		
-		if (access(DEFAULT_XINITRC, R_OK) == 0)
-			execlp(SHELL, SHELL, DEFAULT_XINITRC, NULL);
-		
-		/* Then fallback to hardcoding an xterm and the window manager. */
-		
-		//		system(XTERM_PATH " &");
-		execl(WM_PATH, WM_PATH, NULL);
-		
-		perror("exec");
-		_exit(1);
-		
-    default:				/* parent */
-		client_pid = child;
-		return TRUE;
-    }
-}
+int launcher_main(int argc, char **argv);
+int server_main(int argc, char **argv);
 
-static void
-sigchld_handler (int sig)
-{
-    int pid, status;
-	
-	again:
-    pid = waitpid (WAIT_ANY, &status, WNOHANG);
-	
-    if (pid > 0)
-    {
-		if (pid == server_pid)
-		{
-			server_pid = -1;
-			
-			if (client_pid >= 0)
-				kill (client_pid, SIGTERM);
-		}
-		else if (pid == client_pid)
-		{
-			client_pid = -1;
-			
-			if (server_pid >= 0 && xinit_kills_server)
-				kill (server_pid, SIGTERM);
-		}
-		goto again;
+int main(int argc, char **argv) {
+    Display *display;
+  
+    fprintf(stderr, "X11.app: main(): argc=%d\n", argc);
+    int i;
+    for(i=0; i < argc; i++) {
+        fprintf(stderr, "\targv[%d] = %s\n", i, argv[i]);
     }
-	
-    if (server_pid == -1 && client_pid == -1)
-		longjmp (exit_continuation, 1);
-	
-    signal (SIGCHLD, sigchld_handler);
-}
-
-
-/* Server utilities. */
-
-static Boolean
-display_exists_p (int number)
-{
-    char buf[64];
-    xcb_connection_t *conn;
-    char *fullname = NULL;
-    int idisplay, iscreen;
-    char *conn_auth_name, *conn_auth_data;
-    int conn_auth_namelen, conn_auth_datalen;
-    
-    //    extern void *_X11TransConnectDisplay ();
-    //    extern void _XDisconnectDisplay ();
-	
-    /* Since connecting to the display waits for a few seconds if the
-	 display doesn't exist, check for trivial non-existence - if the
-	 socket in /tmp exists or not.. (note: if the socket exists, the
-	 server may still not, so we need to try to connect in that case..) */
-	
-    sprintf (buf, "/tmp/.X11-unix/X%d", number);
-    if (access (buf, F_OK) != 0)
-		return FALSE;
     
-    sprintf (buf, ":%d", number);
-    conn = xcb_connect(buf, NULL);
-    if (xcb_connection_has_error(conn)) return FALSE;
-	
-    xcb_disconnect(conn);
-    return TRUE;
-}
-
-
-/* Monitoring when the system's ip addresses change. */
-
-static Boolean pending_timer;
-
-static void
-timer_callback (CFRunLoopTimerRef timer, void *info)
-{
-    pending_timer = FALSE;
-	
-    /* Update authentication names. Need to write .Xauthority file first
-	 without the existing entries, then again with the new entries.. */
-	
-    write_auth_file (FALSE);
-	
-    free_auth_items ();
-    make_auth_keys (server_name);
-	
-    write_auth_file (TRUE);
-}
-
-/* This function is called when the system's ip addresses may have changed. */
-static void
-ipaddr_callback (SCDynamicStoreRef store, CFArrayRef changed_keys, void *info)
-{
-#if DEBUG
-    if (changed_keys != NULL) {
-		fprintf (stderr, "x11: changed sc keys: ");
-		CFShow (changed_keys);
-    }
-#endif
-
-    if (auth_file != NULL && !pending_timer)
-    {
-		CFRunLoopTimerRef timer;
-		
-		timer = CFRunLoopTimerCreate (NULL, CFAbsoluteTimeGetCurrent () + 1.0,
-									  0.0, 0, 0, timer_callback, NULL);
-		CFRunLoopAddTimer (CFRunLoopGetCurrent (), timer,
-						   kCFRunLoopDefaultMode);
-		CFRelease (timer);
-		
-		pending_timer = TRUE;
-    }
-}
-
-/* This code adapted from "Living in a Dynamic TCP/IP Environment" technote. */
-static Boolean
-install_ipaddr_source (void)
-{
-    CFRunLoopSourceRef source = NULL;
-	
-    SCDynamicStoreContext context = {0};
-    SCDynamicStoreRef ref;
-	
-    ref = SCDynamicStoreCreate (NULL,
-								CFSTR ("AddIPAddressListChangeCallbackSCF"),
-								ipaddr_callback, &context);
-	
-    if (ref != NULL)
-    {
-		const void *keys[4], *patterns[2];
-		int i;
-		
-		keys[0] = SCDynamicStoreKeyCreateNetworkGlobalEntity (NULL, kSCDynamicStoreDomainState, kSCEntNetIPv4);
-		keys[1] = SCDynamicStoreKeyCreateNetworkGlobalEntity (NULL, kSCDynamicStoreDomainState, kSCEntNetIPv6);
-		keys[2] = SCDynamicStoreKeyCreateComputerName (NULL);
-		keys[3] = SCDynamicStoreKeyCreateHostNames (NULL);
-		
-		patterns[0] = SCDynamicStoreKeyCreateNetworkInterfaceEntity (NULL, kSCDynamicStoreDomainState, kSCCompAnyRegex, kSCEntNetIPv4);
-		patterns[1] = SCDynamicStoreKeyCreateNetworkInterfaceEntity (NULL, kSCDynamicStoreDomainState, kSCCompAnyRegex, kSCEntNetIPv6);
-		
-		if (keys[0] != NULL && keys[1] != NULL && keys[2] != NULL
-			&& keys[3] != NULL && patterns[0] != NULL && patterns[1] != NULL)
-		{
-			CFArrayRef key_array, pattern_array;
-			
-			key_array = CFArrayCreate (NULL, keys, 4, &kCFTypeArrayCallBacks);
-			pattern_array = CFArrayCreate (NULL, patterns, 2, &kCFTypeArrayCallBacks);
-			
-			if (key_array != NULL || pattern_array != NULL)
-			{
-				SCDynamicStoreSetNotificationKeys (ref, key_array, pattern_array);
-				source = SCDynamicStoreCreateRunLoopSource (NULL, ref, 0);
-			}
-			
-			if (key_array != NULL)
-				CFRelease (key_array);
-			if (pattern_array != NULL)
-				CFRelease (pattern_array);
-		}
-		
-		
-		for (i = 0; i < 4; i++)
-			if (keys[i] != NULL)
-			CFRelease (keys[i]);
-		for (i = 0; i < 2; i++)
-			if (patterns[i] != NULL)
-			CFRelease (patterns[i]);
-		
-		CFRelease (ref); 
-    }
-	
-    if (source != NULL)
-    {
-		CFRunLoopAddSource (CFRunLoopGetCurrent (),
-							source, kCFRunLoopDefaultMode);
-		CFRelease (source);
-    }
-	
-    return source != NULL;
-}
-
-
-/* Entrypoint. */
-
-void
-termination_signal_handler (int unused_sig)
-{
-    signal (SIGTERM, SIG_DFL);
-    signal (SIGHUP, SIG_DFL);
-    signal (SIGINT, SIG_DFL);
-    signal (SIGQUIT, SIG_DFL);
-
-    longjmp (exit_continuation, 1);
-}
-
-int
-main (int argc, char **argv)
-{
-    char **xargv;
-    int i, j;
-    int fd;
-	
-    xargv = alloca (sizeof (char *) * (argc + 32));
-	
-    if (!read_boolean_pref (CFSTR ("no_auth"), FALSE))
-		auth_file = XauFileName ();
-	
-    /* The standard X11 behaviour is for the server to quit when the first
-	 client exits. But it can be useful for debugging (and to mimic our
-	 behaviour in the beta releases) to not do that. */
-	
-    xinit_kills_server = read_boolean_pref (CFSTR ("xinit_kills_server"), TRUE);
-	
-    for (i = 1; i < argc; i++)
-    {
-		if (argv[i][0] == ':')
-			server_name = argv[i];
-    }
-	
-    if (server_name == NULL)
-    {
-		static char name[8];
-		
-		/* No display number specified, so search for the first unused.
-		 
-		 There's a big old race condition here if two servers start at
-		 the same time, but that's fairly unlikely. We could create
-		 lockfiles or something, but that's seems more likely to cause
-		 problems than the race condition itself.. */
-		
-		for (i = 0; i < MAX_DISPLAYS; i++)
-		{
-			if (!display_exists_p (i))
-				break;
-		}
-		
-		if (i == MAX_DISPLAYS)
-		{
-			fprintf (stderr, "%s: couldn't allocate a display number", argv[0]);
-			exit (1);
-		}
-		
-		sprintf (name, ":%d", i);
-		server_name = name;
-    }
-	
-    if (auth_file != NULL)
-    {
-		/* Create new Xauth keys and add them to the .Xauthority file */
-		
-		make_auth_keys (server_name);
-		write_auth_file (TRUE);
-    }
-	
-    /* Construct our new argv */
-	
-    i = j = 0;
-	
-    xargv[i++] = argv[j++];
-	
-    if (auth_file != NULL)
-    {
-		xargv[i++] = "-auth";
-		xargv[i++] = auth_file;
-    }
-	
-    /* By default, don't listen on tcp sockets if Xauth is disabled. */
-	
-    if (read_boolean_pref (CFSTR ("nolisten_tcp"), auth_file == NULL))
-    {
-		xargv[i++] = "-nolisten";
-		xargv[i++] = "tcp";
-    }
-	
-    while (j < argc)
-    {
-		if (argv[j++][0] != ':')
-			xargv[i++] = argv[j-1];
-    }
-	
-    xargv[i++] = (char *) server_name;
-    xargv[i++] = NULL;
-	
-    /* Detach from any controlling terminal and connect stdin to /dev/null */
-	
-#ifdef TIOCNOTTY
-    fd = open ("/dev/tty", O_RDONLY);
-    if (fd != -1)
-    {
-		ioctl (fd, TIOCNOTTY, 0);
-		close (fd);
-    }
-#endif
-	
-    fd = open ("/dev/null", O_RDWR, 0);
-    if (fd >= 0)
-    {
-		dup2 (fd, 0);
-		if (fd > 0)
-			close (fd);
-    }
-	
-    if (!start_server (xargv))
-		return 1;
-	
-    if (!wait_for_server ())
-    {
-		kill (server_pid, SIGTERM);
-		return 1;
-    }
-	
-    if (!start_client ())
-    {
-		kill (server_pid, SIGTERM);
-		return 1;
-    }
-	
-    signal (SIGCHLD, sigchld_handler);
-	
-    signal (SIGTERM, termination_signal_handler);
-    signal (SIGHUP, termination_signal_handler);
-    signal (SIGINT, termination_signal_handler);
-    signal (SIGQUIT, termination_signal_handler);
-
-    if (setjmp (exit_continuation) == 0)
-    {
-		if (install_ipaddr_source ())
-			CFRunLoopRun ();
-		else
-			while (1) pause ();
-    }
-	
-    signal (SIGCHLD, SIG_IGN);
-
-    if (client_pid >= 0) kill (client_pid, SIGTERM);
-    if (server_pid >= 0) kill (server_pid, SIGTERM);
-	
-    if (auth_file != NULL)
-    {
-		/* Remove our Xauth keys */
-		
-		write_auth_file (FALSE);
-    }
-	
-    free_auth_items ();
-	
-    return 0;
+    /* First check if launchd started us */
+    if(argc == 2 && !strncmp(argv[1], "--launchd", 9)) {
+        argc--;
+        argv[1] = argv[0];
+        argv++;
+        fprintf(stderr, "X11.app: main(): launchd called us, running server_main()");
+        return server_main(argc, argv);
+    }
+
+    /* If we have a process serial number and it's our only arg, act as if
+     * the user double clicked the app bundle: launch app_to_run if possible
+     */
+    if(argc == 1 || (argc == 2 && !strncmp(argv[1], "-psn_", 5))) {
+        /* Now, try to open a display, if so, run the launcher */
+        display = XOpenDisplay(NULL);
+        if(display) {
+            fprintf(stderr, "X11.app: main(): closing the display");
+            /* Could open the display, start the launcher */
+            XCloseDisplay(display);
+
+            /* Give 2 seconds for the server to start... 
+             * TODO: *Really* fix this race condition
+             */
+            usleep(2000);
+            fprintf(stderr, "X11.app: main(): running launcher_main()");
+            return launcher_main(argc, argv);
+        }
+    }
+
+    /* Couldn't open the display or we were called with arguments,
+     * just want to start a server.
+     */
+    fprintf(stderr, "X11.app: main(): running server_main()");
+    return server_main(argc, argv);
 }
diff --git a/hw/darwin/apple/launcher-main.c b/hw/darwin/apple/launcher-main.c
new file mode 100644
index 0000000..60a1624
--- /dev/null
+++ b/hw/darwin/apple/launcher-main.c
@@ -0,0 +1,81 @@
+/* main.c -- X application launcher
+ 
+ Copyright (c) 2007 Apple Inc.
+ 
+ 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 <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+#include <CoreFoundation/CoreFoundation.h>
+
+#define DEFAULT_APP "/usr/X11/bin/xterm"
+
+int launcher_main (int argc, char **argv) {
+  char *command = DEFAULT_APP;
+  const char *newargv[7];
+  int child;
+  
+
+	CFPropertyListRef PlistRef = CFPreferencesCopyAppValue(CFSTR("app_to_run"),
+									kCFPreferencesCurrentApplication);
+	
+	if ((PlistRef == NULL) || (CFGetTypeID(PlistRef) != CFStringGetTypeID())) {
+		CFPreferencesSetAppValue(CFSTR("app_to_run"), CFSTR(DEFAULT_APP), 
+								 kCFPreferencesCurrentApplication);
+		CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
+	} else {
+		int len = CFStringGetLength((CFStringRef)PlistRef)+1;
+		command = (char *) malloc(len);
+		CFStringGetCString((CFStringRef)PlistRef, command, len,  kCFStringEncodingASCII);
+		fprintf(stderr, "command=%s\n", command);
+	}
+	
+	if (PlistRef) CFRelease(PlistRef);
+	
+	newargv[0] = "/usr/bin/login";
+	newargv[1] = "-fp";
+	newargv[2] = getlogin();
+	newargv[3] = "/bin/sh";
+	newargv[4] = "-c";
+	newargv[5] = command;
+	newargv[6] = NULL;
+
+    child = fork();
+	
+    switch (child) {
+    case -1:				/* error */
+      perror ("fork");
+      return EXIT_FAILURE;		
+    case 0:				    /* child */
+      execvp (newargv[0], (char **const) newargv);
+      perror ("Couldn't exec");
+      _exit (1);
+   }
+	
+    return 0;
+}
diff --git a/hw/darwin/apple/org.x.X11.plist b/hw/darwin/apple/org.x.X11.plist
new file mode 100644
index 0000000..6c6be91
--- /dev/null
+++ b/hw/darwin/apple/org.x.X11.plist
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>Label</key>
+		<string>org.x.X11</string>
+	<key>Program</key>
+		<string>/Applications/Utilities/X11.app/Contents/MacOS/X11</string>
+	<key>ProgramArguments</key>
+		<array>
+		<string>/Applications/Utilities/X11.app/Contents/MacOS/X11</string>
+		<string>--launchd</string>
+		</array>
+	<key>Sockets</key>
+		<dict>
+		<key>:0</key>
+			<dict>
+			<key>SecureSocketWithKey</key>
+				<string>DISPLAY</string>
+			</dict>
+		</dict>
+	<key>ServiceIPC</key>
+		<true/>
+</dict>
+</plist>
diff --git a/hw/darwin/apple/server-main.c b/hw/darwin/apple/server-main.c
new file mode 100644
index 0000000..26fcbb0
--- /dev/null
+++ b/hw/darwin/apple/server-main.c
@@ -0,0 +1,904 @@
+/* bundle-main.c -- X server launcher
+ 
+ Copyright (c) 2002-2007 Apple Inc. 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 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.
+ 
+ Parts of this file are derived from xdm, which has this copyright:
+ 
+ Copyright 1988, 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. */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <sys/utsname.h>
+#include <ifaddrs.h>
+#include <netdb.h>
+#include <netinet/in.h>
+#include <time.h>
+#include <sys/wait.h>
+#include <setjmp.h>
+#include <sys/ioctl.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xauth.h>
+#include <xcb/xcb.h>
+
+#include <CoreFoundation/CoreFoundation.h>
+#include <SystemConfiguration/SystemConfiguration.h>
+
+#define X_SERVER "/usr/X11/bin/Xquartz"
+#define XTERM_PATH "/usr/X11/bin/xterm"
+#define WM_PATH "/usr/bin/quartz-wm"
+#define DEFAULT_XINITRC "/usr/X11/lib/X11/xinit/xinitrc"
+#define DEFAULT_PATH "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11/bin"
+
+/* what xinit does */
+#ifndef SHELL
+# define SHELL "sh"
+#endif
+
+#undef FALSE
+#define FALSE 0
+#undef TRUE
+#define TRUE 1
+
+#define MAX_DISPLAYS 64
+
+static int server_pid = -1, client_pid = -1;
+static int xinit_kills_server = FALSE;
+static jmp_buf exit_continuation;
+static const char *server_name = NULL;
+static Display *server_dpy;
+
+static char *auth_file;
+
+typedef struct addr_list_struct addr_list;
+
+struct addr_list_struct {
+    addr_list *next;
+    Xauth auth;
+};
+
+static addr_list *addresses;
+
+
+/* Utility functions. */
+
+/* Return the current host name. Matches what Xlib does. */
+static char *
+host_name (void)
+{
+#ifdef NEED_UTSNAME
+    static struct utsname name;
+	
+    uname(&name);
+	
+    return name.nodename;
+#else
+    static char buf[100];
+	
+    gethostname(buf, sizeof(buf));
+	
+    return buf;
+#endif
+}
+
+static int
+read_boolean_pref (CFStringRef name, int default_)
+{
+    int value;
+    Boolean ok;
+	
+    value = CFPreferencesGetAppBooleanValue (name,
+											 CFSTR ("com.apple.x11"), &ok);
+    return ok ? value : default_;
+}
+
+static inline int
+binary_equal (const void *a, const void *b, int length)
+{
+    return memcmp (a, b, length) == 0;
+}
+
+static inline void *
+binary_dup (const void *a, int length)
+{
+    void *b = malloc (length);
+    if (b != NULL)
+		memcpy (b, a, length);
+    return b;
+}
+
+static inline void
+binary_free (void *data, int length)
+{
+    if (data != NULL)
+		free (data);
+}
+
+
+/* Functions for managing the authentication entries. */
+
+/* Returns true if something matching AUTH is in our list of auth items */
+static int
+check_auth_item (Xauth *auth)
+{
+    addr_list *a;
+	
+    for (a = addresses; a != NULL; a = a->next)
+    {
+		if (a->auth.family == auth->family
+			&& a->auth.address_length == auth->address_length
+			&& binary_equal (a->auth.address, auth->address, auth->address_length)
+			&& a->auth.number_length == auth->number_length
+			&& binary_equal (a->auth.number, auth->number, auth->number_length)
+			&& a->auth.name_length == auth->name_length
+			&& binary_equal (a->auth.name, auth->name, auth->name_length))
+		{
+			return TRUE;
+		}
+    }
+	
+    return FALSE;
+}
+
+/* Add one item to our list of auth items. */
+static void
+add_auth_item (Xauth *auth)
+{
+    addr_list *a = malloc (sizeof (addr_list));
+	
+    a->auth.family = auth->family;
+    a->auth.address_length = auth->address_length;
+    a->auth.address = binary_dup (auth->address, auth->address_length);
+    a->auth.number_length = auth->number_length;
+    a->auth.number = binary_dup (auth->number, auth->number_length);
+    a->auth.name_length = auth->name_length;
+    a->auth.name = binary_dup (auth->name, auth->name_length);
+    a->auth.data_length = auth->data_length;
+    a->auth.data = binary_dup (auth->data, auth->data_length);
+	
+    a->next = addresses;
+    addresses = a;
+}
+
+/* Free all allocated auth items. */
+static void
+free_auth_items (void)
+{
+    addr_list *a;
+	
+    while ((a = addresses) != NULL)
+    {
+		addresses = a->next;
+		
+		binary_free (a->auth.address, a->auth.address_length);
+		binary_free (a->auth.number, a->auth.number_length);
+		binary_free (a->auth.name, a->auth.name_length);
+		binary_free (a->auth.data, a->auth.data_length);
+		free (a);
+    }
+}
+
+/* Add the unix domain auth item. */
+static void
+define_local (Xauth *auth)
+{
+    char *host = host_name ();
+	
+#ifdef DEBUG
+    fprintf (stderr, "x11: hostname is %s\n", host);
+#endif
+	
+    auth->family = FamilyLocal;
+    auth->address_length = strlen (host);
+    auth->address = host;
+	
+    add_auth_item (auth);
+}
+
+/* Add the tcp auth item. */
+static void
+define_named (Xauth *auth, const char *name)
+{
+    struct ifaddrs *addrs, *ptr;
+	
+    if (getifaddrs (&addrs) != 0)
+		return;
+	
+    for (ptr = addrs; ptr != NULL; ptr = ptr->ifa_next)
+    {
+		if (ptr->ifa_addr->sa_family != AF_INET)
+			continue;
+		
+		auth->family = FamilyInternet;
+		auth->address_length = sizeof (struct in_addr);
+		auth->address = (char *) &(((struct sockaddr_in *) ptr->ifa_addr)->sin_addr);
+		
+#ifdef DEBUG
+		fprintf (stderr, "x11: ipaddr is %d.%d.%d.%d\n",
+				 (unsigned char) auth->address[0],
+				 (unsigned char) auth->address[1],
+				 (unsigned char) auth->address[2],
+				 (unsigned char) auth->address[3]);
+#endif
+		
+		add_auth_item (auth);
+    }
+	
+    freeifaddrs (addrs);
+}
+
+/* Parse the display number from NAME and add it to AUTH. */
+static void
+set_auth_number (Xauth *auth, const char *name)
+{
+    char *colon;
+    char *dot, *number;
+	
+    colon = strrchr(name, ':');
+    if (colon != NULL)
+    {
+		colon++;
+		dot = strchr(colon, '.');
+		
+		if (dot != NULL)
+			auth->number_length = dot - colon;
+		else
+			auth->number_length = strlen (colon);
+		
+		number = malloc (auth->number_length + 1);
+		if (number != NULL)
+		{
+			strncpy (number, colon, auth->number_length);
+			number[auth->number_length] = '\0';
+		}
+		else
+		{
+			auth->number_length = 0;
+		}
+		
+		auth->number = number;
+    }
+}
+
+/* Put 128 bits of random data into DATA. If possible, it will be "high
+ quality" */
+static int
+generate_mit_magic_cookie (char data[16])
+{
+    int fd, ret, i;
+    long *ldata = (long *) data;
+	
+    fd = open ("/dev/random", O_RDONLY);
+    if (fd > 0) {
+		ret = read (fd, data, 16);
+		close (fd);
+		if (ret == 16) return TRUE;
+    }
+	
+    /* fall back to the usual crappy rng */
+	
+    srand48 (getpid () ^ time (NULL));
+	
+    for (i = 0; i < 4; i++)
+		ldata[i] = lrand48 ();
+	
+    return TRUE;
+}
+
+/* Create the keys we'll be using for the display named NAME. */
+static int
+make_auth_keys (const char *name)
+{
+    Xauth auth;
+    char key[16];
+	
+    if (auth_file == NULL)
+		return FALSE;
+	
+    auth.name = "MIT-MAGIC-COOKIE-1";
+    auth.name_length = strlen (auth.name);
+	
+    if (!generate_mit_magic_cookie (key))
+    {
+		auth_file = NULL;
+		return FALSE;
+    }
+	
+    auth.data = key;
+    auth.data_length = 16;
+	
+    set_auth_number (&auth, name);
+	
+    define_named (&auth, host_name ());
+    define_local (&auth);
+	
+    free (auth.number);
+	
+    return TRUE;
+}
+
+/* If ADD-ENTRIES is true, merge our auth entries into the existing
+ Xauthority file. If ADD-ENTRIES is false, remove our entries. */
+static int
+write_auth_file (int add_entries)
+{
+    char *home, newname[1024];
+    int fd, ret;
+    FILE *new_fh, *old_fh;
+    addr_list *addr;
+    Xauth *auth;
+	
+    if (auth_file == NULL)
+		return FALSE;
+	
+    home = getenv ("HOME");
+    if (home == NULL)
+    {
+		auth_file = NULL;
+		return FALSE;
+    }
+	
+    snprintf (newname, sizeof (newname), "%s/.XauthorityXXXXXX", home);
+    mktemp (newname);
+	
+    if (XauLockAuth (auth_file, 1, 2, 10) != LOCK_SUCCESS)
+    {
+		/* FIXME: do something here? */
+		
+		auth_file = NULL;
+		return FALSE;
+    }
+	
+    fd = open (newname, O_WRONLY | O_CREAT | O_TRUNC, 0600);
+    if (fd >= 0)
+    {
+		new_fh = fdopen (fd, "w");
+		if (new_fh != NULL)
+		{
+			if (add_entries)
+			{
+				for (addr = addresses; addr != NULL; addr = addr->next)
+				{
+					XauWriteAuth (new_fh, &addr->auth);
+				}
+			}
+			
+			old_fh = fopen (auth_file, "r");
+			if (old_fh != NULL)
+			{
+				while ((auth = XauReadAuth (old_fh)) != NULL)
+				{
+					if (!check_auth_item (auth))
+						XauWriteAuth (new_fh, auth);
+					XauDisposeAuth (auth);
+				}
+				fclose (old_fh);
+			}
+			
+			fclose (new_fh);
+			unlink (auth_file);
+			
+			ret = rename (newname, auth_file);
+			
+			if (ret != 0)
+				auth_file = NULL;
+			
+			XauUnlockAuth (auth_file);
+			return ret == 0;
+		}
+		
+		close (fd);
+    }
+	
+    XauUnlockAuth (auth_file);
+    auth_file = NULL;
+    return FALSE;
+}
+
+
+/* Subprocess management functions. */
+
+static int
+start_server (char **xargv)
+{
+    int child;
+	
+    child = fork ();
+	
+    switch (child)
+    {
+    case -1:				/* error */
+		perror ("fork");
+		return FALSE;
+		
+    case 0:				/* child */
+		execv (X_SERVER, xargv);
+		perror ("Couldn't exec " X_SERVER);
+		_exit (1);
+		
+    default:				/* parent */
+		server_pid = child;
+		return TRUE;
+    }
+}
+
+static int
+wait_for_server (void)
+{
+    int count = 100;
+	
+    while (count-- > 0)
+    {
+		int status;
+		
+		server_dpy = XOpenDisplay (server_name);
+		if (server_dpy != NULL)
+			return TRUE;
+		
+		if (waitpid (server_pid, &status, WNOHANG) == server_pid)
+			return FALSE;
+		
+		sleep (1);
+    }
+	
+    return FALSE;
+}
+
+static int
+start_client (void)
+{
+    int child;
+	
+    child = fork();
+	
+    switch (child) {
+		char *temp, buf[1024];		
+
+	case -1:				/* error */
+		perror("fork");
+		return FALSE;
+
+	case 0:					/* child */
+		/* Setup environment */
+		temp = getenv("DISPLAY");
+//		if (temp == NULL && temp[0] != 0)
+			setenv("DISPLAY", server_name, TRUE);
+
+		temp = getenv("PATH");
+		if (temp == NULL || temp[0] == 0) 
+			setenv ("PATH", DEFAULT_PATH, TRUE);
+		else if (strnstr(temp, "/usr/X11/bin", sizeof(temp)) == NULL) {
+			snprintf(buf, sizeof(buf), "%s:/usr/X11/bin", temp);		
+			setenv("PATH", buf, TRUE);	
+		}
+		
+		/* First try value of $XINITRC, if set. */
+		temp = getenv("XINITRC");
+		if (temp != NULL && temp[0] != 0 && access(temp, R_OK) == 0)
+			execlp (SHELL, SHELL, temp, NULL);
+
+		/* Then look for .xinitrc in user's home directory. */
+		temp = getenv("HOME");
+		if (temp != NULL && temp[0] != 0) {
+			chdir(temp);
+			snprintf (buf, sizeof (buf), "%s/.xinitrc", temp);
+			if (access(buf, R_OK) == 0)
+				execlp(SHELL, SHELL, buf, NULL);
+		}
+		
+		/* Then try the default xinitrc in the lib directory. */
+		
+		if (access(DEFAULT_XINITRC, R_OK) == 0)
+			execlp(SHELL, SHELL, DEFAULT_XINITRC, NULL);
+		
+		/* Then fallback to hardcoding an xterm and the window manager. */
+		
+		//		system(XTERM_PATH " &");
+		execl(WM_PATH, WM_PATH, NULL);
+		
+		perror("exec");
+		_exit(1);
+		
+    default:				/* parent */
+		client_pid = child;
+		return TRUE;
+    }
+}
+
+static void
+sigchld_handler (int sig)
+{
+    int pid, status;
+	
+	again:
+    pid = waitpid (WAIT_ANY, &status, WNOHANG);
+	
+    if (pid > 0)
+    {
+		if (pid == server_pid)
+		{
+			server_pid = -1;
+			
+			if (client_pid >= 0)
+				kill (client_pid, SIGTERM);
+		}
+		else if (pid == client_pid)
+		{
+			client_pid = -1;
+			
+			if (server_pid >= 0 && xinit_kills_server)
+				kill (server_pid, SIGTERM);
+		}
+		goto again;
+    }
+	
+    if (server_pid == -1 && client_pid == -1)
+		longjmp (exit_continuation, 1);
+	
+    signal (SIGCHLD, sigchld_handler);
+}
+
+
+/* Server utilities. */
+
+static Boolean
+display_exists_p (int number)
+{
+    char buf[64];
+    xcb_connection_t *conn;
+    char *fullname = NULL;
+    int idisplay, iscreen;
+    char *conn_auth_name, *conn_auth_data;
+    int conn_auth_namelen, conn_auth_datalen;
+    
+    //    extern void *_X11TransConnectDisplay ();
+    //    extern void _XDisconnectDisplay ();
+	
+    /* Since connecting to the display waits for a few seconds if the
+	 display doesn't exist, check for trivial non-existence - if the
+	 socket in /tmp exists or not.. (note: if the socket exists, the
+	 server may still not, so we need to try to connect in that case..) */
+	
+    sprintf (buf, "/tmp/.X11-unix/X%d", number);
+    if (access (buf, F_OK) != 0)
+		return FALSE;
+    
+    sprintf (buf, ":%d", number);
+    conn = xcb_connect(buf, NULL);
+    if (xcb_connection_has_error(conn)) return FALSE;
+	
+    xcb_disconnect(conn);
+    return TRUE;
+}
+
+
+/* Monitoring when the system's ip addresses change. */
+
+static Boolean pending_timer;
+
+static void
+timer_callback (CFRunLoopTimerRef timer, void *info)
+{
+    pending_timer = FALSE;
+	
+    /* Update authentication names. Need to write .Xauthority file first
+	 without the existing entries, then again with the new entries.. */
+	
+    write_auth_file (FALSE);
+	
+    free_auth_items ();
+    make_auth_keys (server_name);
+	
+    write_auth_file (TRUE);
+}
+
+/* This function is called when the system's ip addresses may have changed. */
+static void
+ipaddr_callback (SCDynamicStoreRef store, CFArrayRef changed_keys, void *info)
+{
+#if DEBUG
+    if (changed_keys != NULL) {
+		fprintf (stderr, "x11: changed sc keys: ");
+		CFShow (changed_keys);
+    }
+#endif
+
+    if (auth_file != NULL && !pending_timer)
+    {
+		CFRunLoopTimerRef timer;
+		
+		timer = CFRunLoopTimerCreate (NULL, CFAbsoluteTimeGetCurrent () + 1.0,
+									  0.0, 0, 0, timer_callback, NULL);
+		CFRunLoopAddTimer (CFRunLoopGetCurrent (), timer,
+						   kCFRunLoopDefaultMode);
+		CFRelease (timer);
+		
+		pending_timer = TRUE;
+    }
+}
+
+/* This code adapted from "Living in a Dynamic TCP/IP Environment" technote. */
+static Boolean
+install_ipaddr_source (void)
+{
+    CFRunLoopSourceRef source = NULL;
+	
+    SCDynamicStoreContext context = {0};
+    SCDynamicStoreRef ref;
+	
+    ref = SCDynamicStoreCreate (NULL,
+								CFSTR ("AddIPAddressListChangeCallbackSCF"),
+								ipaddr_callback, &context);
+	
+    if (ref != NULL)
+    {
+		const void *keys[4], *patterns[2];
+		int i;
+		
+		keys[0] = SCDynamicStoreKeyCreateNetworkGlobalEntity (NULL, kSCDynamicStoreDomainState, kSCEntNetIPv4);
+		keys[1] = SCDynamicStoreKeyCreateNetworkGlobalEntity (NULL, kSCDynamicStoreDomainState, kSCEntNetIPv6);
+		keys[2] = SCDynamicStoreKeyCreateComputerName (NULL);
+		keys[3] = SCDynamicStoreKeyCreateHostNames (NULL);
+		
+		patterns[0] = SCDynamicStoreKeyCreateNetworkInterfaceEntity (NULL, kSCDynamicStoreDomainState, kSCCompAnyRegex, kSCEntNetIPv4);
+		patterns[1] = SCDynamicStoreKeyCreateNetworkInterfaceEntity (NULL, kSCDynamicStoreDomainState, kSCCompAnyRegex, kSCEntNetIPv6);
+		
+		if (keys[0] != NULL && keys[1] != NULL && keys[2] != NULL
+			&& keys[3] != NULL && patterns[0] != NULL && patterns[1] != NULL)
+		{
+			CFArrayRef key_array, pattern_array;
+			
+			key_array = CFArrayCreate (NULL, keys, 4, &kCFTypeArrayCallBacks);
+			pattern_array = CFArrayCreate (NULL, patterns, 2, &kCFTypeArrayCallBacks);
+			
+			if (key_array != NULL || pattern_array != NULL)
+			{
+				SCDynamicStoreSetNotificationKeys (ref, key_array, pattern_array);
+				source = SCDynamicStoreCreateRunLoopSource (NULL, ref, 0);
+			}
+			
+			if (key_array != NULL)
+				CFRelease (key_array);
+			if (pattern_array != NULL)
+				CFRelease (pattern_array);
+		}
+		
+		
+		for (i = 0; i < 4; i++)
+			if (keys[i] != NULL)
+			CFRelease (keys[i]);
+		for (i = 0; i < 2; i++)
+			if (patterns[i] != NULL)
+			CFRelease (patterns[i]);
+		
+		CFRelease (ref); 
+    }
+	
+    if (source != NULL)
+    {
+		CFRunLoopAddSource (CFRunLoopGetCurrent (),
+							source, kCFRunLoopDefaultMode);
+		CFRelease (source);
+    }
+	
+    return source != NULL;
+}
+
+
+/* Entrypoint. */
+
+void
+termination_signal_handler (int unused_sig)
+{
+    signal (SIGTERM, SIG_DFL);
+    signal (SIGHUP, SIG_DFL);
+    signal (SIGINT, SIG_DFL);
+    signal (SIGQUIT, SIG_DFL);
+
+    longjmp (exit_continuation, 1);
+}
+
+int
+server_main (int argc, char **argv)
+{
+    char **xargv;
+    int i, j;
+    int fd;
+	
+    xargv = alloca (sizeof (char *) * (argc + 32));
+	
+    if (!read_boolean_pref (CFSTR ("no_auth"), FALSE))
+		auth_file = XauFileName ();
+	
+    /* The standard X11 behaviour is for the server to quit when the first
+	 client exits. But it can be useful for debugging (and to mimic our
+	 behaviour in the beta releases) to not do that. */
+	
+    xinit_kills_server = read_boolean_pref (CFSTR ("xinit_kills_server"), TRUE);
+	
+    for (i = 1; i < argc; i++)
+    {
+		if (argv[i][0] == ':')
+			server_name = argv[i];
+    }
+	
+    if (server_name == NULL)
+    {
+		static char name[8];
+		
+		/* No display number specified, so search for the first unused.
+		 
+		 There's a big old race condition here if two servers start at
+		 the same time, but that's fairly unlikely. We could create
+		 lockfiles or something, but that's seems more likely to cause
+		 problems than the race condition itself.. */
+		
+		for (i = 0; i < MAX_DISPLAYS; i++)
+		{
+			if (!display_exists_p (i))
+				break;
+		}
+		
+		if (i == MAX_DISPLAYS)
+		{
+			fprintf (stderr, "%s: couldn't allocate a display number", argv[0]);
+			exit (1);
+		}
+		
+		sprintf (name, ":%d", i);
+		server_name = name;
+    }
+	
+    if (auth_file != NULL)
+    {
+		/* Create new Xauth keys and add them to the .Xauthority file */
+		
+		make_auth_keys (server_name);
+		write_auth_file (TRUE);
+    }
+	
+    /* Construct our new argv */
+	
+    i = j = 0;
+	
+    xargv[i++] = argv[j++];
+	
+    if (auth_file != NULL)
+    {
+		xargv[i++] = "-auth";
+		xargv[i++] = auth_file;
+    }
+	
+    /* By default, don't listen on tcp sockets if Xauth is disabled. */
+	
+    if (read_boolean_pref (CFSTR ("nolisten_tcp"), auth_file == NULL))
+    {
+		xargv[i++] = "-nolisten";
+		xargv[i++] = "tcp";
+    }
+	
+    while (j < argc)
+    {
+		if (argv[j++][0] != ':')
+			xargv[i++] = argv[j-1];
+    }
+	
+    xargv[i++] = (char *) server_name;
+    xargv[i++] = NULL;
+	
+    /* Detach from any controlling terminal and connect stdin to /dev/null */
+	
+#ifdef TIOCNOTTY
+    fd = open ("/dev/tty", O_RDONLY);
+    if (fd != -1)
+    {
+		ioctl (fd, TIOCNOTTY, 0);
+		close (fd);
+    }
+#endif
+	
+    fd = open ("/dev/null", O_RDWR, 0);
+    if (fd >= 0)
+    {
+		dup2 (fd, 0);
+		if (fd > 0)
+			close (fd);
+    }
+	
+    if (!start_server (xargv))
+		return 1;
+	
+    if (!wait_for_server ())
+    {
+		kill (server_pid, SIGTERM);
+		return 1;
+    }
+	
+    if (!start_client ())
+    {
+		kill (server_pid, SIGTERM);
+		return 1;
+    }
+	
+    signal (SIGCHLD, sigchld_handler);
+	
+    signal (SIGTERM, termination_signal_handler);
+    signal (SIGHUP, termination_signal_handler);
+    signal (SIGINT, termination_signal_handler);
+    signal (SIGQUIT, termination_signal_handler);
+
+    if (setjmp (exit_continuation) == 0)
+    {
+		if (install_ipaddr_source ())
+			CFRunLoopRun ();
+		else
+			while (1) pause ();
+    }
+	
+    signal (SIGCHLD, SIG_IGN);
+
+    if (client_pid >= 0) kill (client_pid, SIGTERM);
+    if (server_pid >= 0) kill (server_pid, SIGTERM);
+	
+    if (auth_file != NULL)
+    {
+		/* Remove our Xauth keys */
+		
+		write_auth_file (FALSE);
+    }
+	
+    free_auth_items ();
+	
+    return 0;
+}
diff --git a/hw/darwin/launcher/Info.plist b/hw/darwin/launcher/Info.plist
deleted file mode 100644
index b5385b6..0000000
--- a/hw/darwin/launcher/Info.plist
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>CFBundleDevelopmentRegion</key>
-	<string>English</string>
-	<key>CFBundleExecutable</key>
-	<string>X11</string>
-	<key>CFBundleGetInfoString</key>
-	<string>2.0, Copyright © 2003-2007, Apple Inc.</string>
-	<key>CFBundleIconFile</key>
-	<string>X11.icns</string>
-	<key>CFBundleIdentifier</key>
-	<string>org.x.X11_launcher</string>
-	<key>CFBundleInfoDictionaryVersion</key>
-	<string>6.0</string>
-	<key>CFBundleName</key>
-	<string>X11</string>
-	<key>CFBundlePackageType</key>
-	<string>APPL</string>
-	<key>CFBundleShortVersionString</key>
-	<string>2.0</string>
-	<key>CFBundleSignature</key>
-	<string>x11l</string>
-	<key>LSUIElement</key>
-	<string>1</string>
-	<key>NSHumanReadableCopyright</key>
-	<string>Copyright © 2007, Apple Inc.</string>
-</dict>
-</plist>
diff --git a/hw/darwin/launcher/Makefile.am b/hw/darwin/launcher/Makefile.am
deleted file mode 100644
index c291731..0000000
--- a/hw/darwin/launcher/Makefile.am
+++ /dev/null
@@ -1,18 +0,0 @@
-bin_SCRIPTS = x11launcher
-
-.PHONY: x11launcher
-
-x11launcher:
-	xcodebuild CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" ARCHS="$(X11APP_ARCHS)"
-
-install-data-hook:
-	xcodebuild install DSTROOT=$(DESTDIR) INSTALL_PATH=$(APPLE_APPLICATIONS_DIR) DEPLOYMENT_LOCATION=YES SKIP_INSTALL=NO ARCHS="$(X11APP_ARCHS)"
-
-clean-local:
-	rm -rf build
-
-EXTRA_DIST = \
-	bundle-main.c \
-	Info.plist \
-	X11.icns \
-	X11.xcodeproj/project.pbxproj
diff --git a/hw/darwin/launcher/X11.icns b/hw/darwin/launcher/X11.icns
deleted file mode 100644
index d770e61..0000000
Binary files a/hw/darwin/launcher/X11.icns and /dev/null differ
diff --git a/hw/darwin/launcher/X11.xcodeproj/project.pbxproj b/hw/darwin/launcher/X11.xcodeproj/project.pbxproj
deleted file mode 100644
index 34b76da..0000000
--- a/hw/darwin/launcher/X11.xcodeproj/project.pbxproj
+++ /dev/null
@@ -1,290 +0,0 @@
-// !$*UTF8*$!
-{
-	archiveVersion = 1;
-	classes = {
-	};
-	objectVersion = 42;
-	objects = {
-
-/* Begin PBXBuildFile section */
-		527F241B0B5D938C007840A7 /* X11.icns in Resources */ = {isa = PBXBuildFile; fileRef = 50459C5F038587C60ECA21EC /* X11.icns */; };
-		527F241D0B5D938C007840A7 /* bundle-main.c in Sources */ = {isa = PBXBuildFile; fileRef = 50EE2AB703849F0B0ECA21EC /* bundle-main.c */; };
-		527F241F0B5D938C007840A7 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50F4F0A7039D6ACA0E82C0CB /* CoreFoundation.framework */; };
-		527F24370B5D9D89007840A7 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 527F24260B5D938C007840A7 /* Info.plist */; };
-/* End PBXBuildFile section */
-
-/* Begin PBXFileReference section */
-		50459C5F038587C60ECA21EC /* X11.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = X11.icns; sourceTree = "<group>"; };
-		50EE2AB703849F0B0ECA21EC /* bundle-main.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = "bundle-main.c"; sourceTree = "<group>"; };
-		50F4F0A7039D6ACA0E82C0CB /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = "<absolute>"; };
-		527F24260B5D938C007840A7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = Info.plist; sourceTree = "<group>"; };
-		527F24270B5D938C007840A7 /* X11.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = X11.app; sourceTree = BUILT_PRODUCTS_DIR; };
-/* End PBXFileReference section */
-
-/* Begin PBXFrameworksBuildPhase section */
-		527F241E0B5D938C007840A7 /* Frameworks */ = {
-			isa = PBXFrameworksBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-				527F241F0B5D938C007840A7 /* CoreFoundation.framework in Frameworks */,
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-/* End PBXFrameworksBuildPhase section */
-
-/* Begin PBXGroup section */
-		195DF8CFFE9D517E11CA2CBB /* Products */ = {
-			isa = PBXGroup;
-			children = (
-				527F24270B5D938C007840A7 /* X11.app */,
-			);
-			name = Products;
-			sourceTree = "<group>";
-		};
-		20286C29FDCF999611CA2CEA /* X11 */ = {
-			isa = PBXGroup;
-			children = (
-				20286C2AFDCF999611CA2CEA /* Sources */,
-				20286C2CFDCF999611CA2CEA /* Resources */,
-				20286C32FDCF999611CA2CEA /* External Frameworks and Libraries */,
-				195DF8CFFE9D517E11CA2CBB /* Products */,
-				527F24260B5D938C007840A7 /* Info.plist */,
-			);
-			name = X11;
-			sourceTree = "<group>";
-		};
-		20286C2AFDCF999611CA2CEA /* Sources */ = {
-			isa = PBXGroup;
-			children = (
-				50EE2AB703849F0B0ECA21EC /* bundle-main.c */,
-			);
-			name = Sources;
-			sourceTree = "<group>";
-		};
-		20286C2CFDCF999611CA2CEA /* Resources */ = {
-			isa = PBXGroup;
-			children = (
-				50459C5F038587C60ECA21EC /* X11.icns */,
-			);
-			name = Resources;
-			sourceTree = "<group>";
-		};
-		20286C32FDCF999611CA2CEA /* External Frameworks and Libraries */ = {
-			isa = PBXGroup;
-			children = (
-				50F4F0A7039D6ACA0E82C0CB /* CoreFoundation.framework */,
-			);
-			name = "External Frameworks and Libraries";
-			sourceTree = "<group>";
-		};
-/* End PBXGroup section */
-
-/* Begin PBXHeadersBuildPhase section */
-		527F24170B5D938C007840A7 /* Headers */ = {
-			isa = PBXHeadersBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-/* End PBXHeadersBuildPhase section */
-
-/* Begin PBXNativeTarget section */
-		527F24160B5D938C007840A7 /* X11 */ = {
-			isa = PBXNativeTarget;
-			buildConfigurationList = 527F24220B5D938C007840A7 /* Build configuration list for PBXNativeTarget "X11" */;
-			buildPhases = (
-				527F24170B5D938C007840A7 /* Headers */,
-				527F24180B5D938C007840A7 /* Resources */,
-				527F241C0B5D938C007840A7 /* Sources */,
-				527F241E0B5D938C007840A7 /* Frameworks */,
-				527F24210B5D938C007840A7 /* Rez */,
-			);
-			buildRules = (
-			);
-			dependencies = (
-			);
-			name = X11;
-			productName = X11;
-			productReference = 527F24270B5D938C007840A7 /* X11.app */;
-			productType = "com.apple.product-type.application";
-		};
-/* End PBXNativeTarget section */
-
-/* Begin PBXProject section */
-		20286C28FDCF999611CA2CEA /* Project object */ = {
-			isa = PBXProject;
-			buildConfigurationList = 527F24080B5D8FFC007840A7 /* Build configuration list for PBXProject "X11" */;
-			compatibilityVersion = "Xcode 2.4";
-			hasScannedForEncodings = 1;
-			mainGroup = 20286C29FDCF999611CA2CEA /* X11 */;
-			projectDirPath = "";
-			projectRoot = "";
-			shouldCheckCompatibility = 1;
-			targets = (
-				527F24160B5D938C007840A7 /* X11 */,
-			);
-		};
-/* End PBXProject section */
-
-/* Begin PBXResourcesBuildPhase section */
-		527F24180B5D938C007840A7 /* Resources */ = {
-			isa = PBXResourcesBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-				527F24370B5D9D89007840A7 /* Info.plist in Resources */,
-				527F241B0B5D938C007840A7 /* X11.icns in Resources */,
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-/* End PBXResourcesBuildPhase section */
-
-/* Begin PBXRezBuildPhase section */
-		527F24210B5D938C007840A7 /* Rez */ = {
-			isa = PBXRezBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-/* End PBXRezBuildPhase section */
-
-/* Begin PBXSourcesBuildPhase section */
-		527F241C0B5D938C007840A7 /* Sources */ = {
-			isa = PBXSourcesBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-				527F241D0B5D938C007840A7 /* bundle-main.c in Sources */,
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-/* End PBXSourcesBuildPhase section */
-
-/* Begin XCBuildConfiguration section */
-		527F24090B5D8FFC007840A7 /* Development */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				INSTALL_MODE_FLAG = "a+rX";
-			};
-			name = Development;
-		};
-		527F240A0B5D8FFC007840A7 /* Deployment */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				INSTALL_MODE_FLAG = "a+rX";
-			};
-			name = Deployment;
-		};
-		527F240B0B5D8FFC007840A7 /* Default */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				INSTALL_MODE_FLAG = "a+rX";
-			};
-			name = Default;
-		};
-		527F24230B5D938C007840A7 /* Development */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				COPY_PHASE_STRIP = NO;
-				FRAMEWORK_SEARCH_PATHS = "";
-				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
-				HEADER_SEARCH_PATHS = /usr/X11/include;
-				INFOPLIST_FILE = Info.plist;
-				INSTALL_PATH = $DSTROOT/Applications/Utilties;
-				LIBRARY_SEARCH_PATHS = /usr/X11/lib;
-				OTHER_CFLAGS = "";
-				OTHER_LDFLAGS = (
-					"-lXau",
-					"-lxcb",
-					"-lX11",
-				);
-				OTHER_REZFLAGS = "";
-				PRODUCT_NAME = X11;
-				SECTORDER_FLAGS = "";
-				WARNING_CFLAGS = (
-					"-Wmost",
-					"-Wno-four-char-constants",
-					"-Wno-unknown-pragmas",
-				);
-				WRAPPER_EXTENSION = app;
-			};
-			name = Development;
-		};
-		527F24240B5D938C007840A7 /* Deployment */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				COPY_PHASE_STRIP = YES;
-				FRAMEWORK_SEARCH_PATHS = "";
-				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
-				HEADER_SEARCH_PATHS = /usr/X11/include;
-				INFOPLIST_FILE = Info.plist;
-				INSTALL_PATH = /Applications/Utilties;
-				LIBRARY_SEARCH_PATHS = /usr/X11/lib;
-				OTHER_CFLAGS = "";
-				OTHER_LDFLAGS = "";
-				OTHER_REZFLAGS = "";
-				PRODUCT_NAME = X11;
-				SECTORDER_FLAGS = "";
-				WARNING_CFLAGS = (
-					"-Wmost",
-					"-Wno-four-char-constants",
-					"-Wno-unknown-pragmas",
-				);
-				WRAPPER_EXTENSION = app;
-			};
-			name = Deployment;
-		};
-		527F24250B5D938C007840A7 /* Default */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				FRAMEWORK_SEARCH_PATHS = "";
-				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
-				HEADER_SEARCH_PATHS = /usr/X11/include;
-				INFOPLIST_FILE = Info.plist;
-				INSTALL_PATH = /Applications/Utilties;
-				LIBRARY_SEARCH_PATHS = /usr/X11/lib;
-				OTHER_CFLAGS = "";
-				OTHER_LDFLAGS = (
-					"-lXau",
-					"-lxcb",
-					"-lX11",
-				);
-				OTHER_REZFLAGS = "";
-				PRODUCT_NAME = X11;
-				SECTORDER_FLAGS = "";
-				WARNING_CFLAGS = (
-					"-Wmost",
-					"-Wno-four-char-constants",
-					"-Wno-unknown-pragmas",
-				);
-				WRAPPER_EXTENSION = app;
-			};
-			name = Default;
-		};
-/* End XCBuildConfiguration section */
-
-/* Begin XCConfigurationList section */
-		527F24080B5D8FFC007840A7 /* Build configuration list for PBXProject "X11" */ = {
-			isa = XCConfigurationList;
-			buildConfigurations = (
-				527F24090B5D8FFC007840A7 /* Development */,
-				527F240A0B5D8FFC007840A7 /* Deployment */,
-				527F240B0B5D8FFC007840A7 /* Default */,
-			);
-			defaultConfigurationIsVisible = 0;
-			defaultConfigurationName = Default;
-		};
-		527F24220B5D938C007840A7 /* Build configuration list for PBXNativeTarget "X11" */ = {
-			isa = XCConfigurationList;
-			buildConfigurations = (
-				527F24230B5D938C007840A7 /* Development */,
-				527F24240B5D938C007840A7 /* Deployment */,
-				527F24250B5D938C007840A7 /* Default */,
-			);
-			defaultConfigurationIsVisible = 0;
-			defaultConfigurationName = Default;
-		};
-/* End XCConfigurationList section */
-	};
-	rootObject = 20286C28FDCF999611CA2CEA /* Project object */;
-}
diff --git a/hw/darwin/launcher/bundle-main.c b/hw/darwin/launcher/bundle-main.c
deleted file mode 100644
index ca62553..0000000
--- a/hw/darwin/launcher/bundle-main.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/* main.c -- X application launcher
- 
- Copyright (c) 2007 Apple Inc.
- 
- 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 <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-
-#include <CoreFoundation/CoreFoundation.h>
-
-#define DEFAULT_APP "/usr/X11/bin/xterm"
-
-int main (int argc, char **argv) {
-  char *command = DEFAULT_APP;
-  const char *newargv[7];
-  int child;
-  
-
-	CFPropertyListRef PlistRef = CFPreferencesCopyAppValue(CFSTR("app_to_run"),
-									kCFPreferencesCurrentApplication);
-	
-	if ((PlistRef == NULL) || (CFGetTypeID(PlistRef) != CFStringGetTypeID())) {
-		CFPreferencesSetAppValue(CFSTR("app_to_run"), CFSTR(DEFAULT_APP), 
-								 kCFPreferencesCurrentApplication);
-		CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
-	} else {
-		int len = CFStringGetLength((CFStringRef)PlistRef)+1;
-		command = (char *) malloc(len);
-		CFStringGetCString((CFStringRef)PlistRef, command, len,  kCFStringEncodingASCII);
-		fprintf(stderr, "command=%s\n", command);
-	}
-	
-	if (PlistRef) CFRelease(PlistRef);
-	
-	newargv[0] = "/usr/bin/login";
-	newargv[1] = "-fp";
-	newargv[2] = getlogin();
-	newargv[3] = "/bin/sh";
-	newargv[4] = "-c";
-	newargv[5] = command;
-	newargv[6] = NULL;
-
-    child = fork();
-	
-    switch (child) {
-    case -1:				/* error */
-      perror ("fork");
-      return EXIT_FAILURE;		
-    case 0:				    /* child */
-      execvp (newargv[0], (char **const) newargv);
-      perror ("Couldn't exec");
-      _exit (1);
-   }
-	
-    return 0;
-}
commit 25d26b55e74b50a2fd0632329cb0bdca017fe8e6
Author: Kanru Chen <koster at debian.org.tw>
Date:   Mon Dec 3 12:46:45 2007 +0000

    Config: HAL: Fix XKB option parsing
    
    Actually combine the XKB options into a string, rather than just repeatedly
    writing a comma.
    (cherry picked from commit da893908feb2dcf7c22420b3426ab3ac65c7ca99)

diff --git a/config/hal.c b/config/hal.c
index 6bb449d..4427deb 100644
--- a/config/hal.c
+++ b/config/hal.c
@@ -134,10 +134,11 @@ get_prop_string_array(LibHalContext *hal_ctx, const char *udi, const char *prop)
 
         str = ret;
         for (i = 0; props[i]; i++) {
-            str = strcpy(str, props[i]);
+            strcpy(str, props[i]);
+            str += strlen(props[i]);
             *str++ = ',';
         }
-        *str = '\0';
+        *(str-1) = '\0';
 
         libhal_free_string_array(props);
     }
commit b0069b04dddaa2df6d4cdf86f96fd8a2a257e47e
Author: Jeremy Huddleston <jeremy at tifa.local>
Date:   Sun Dec 2 18:21:40 2007 -0800

    Darwin: Added {/,/System/}Library/Fonts to DEFAULT_FONT_PATH

diff --git a/configure.ac b/configure.ac
index c7d78d4..a70d310 100644
--- a/configure.ac
+++ b/configure.ac
@@ -436,6 +436,9 @@ AC_ARG_WITH(fontdir,         AS_HELP_STRING([--with-fontdir=FONTDIR], [Path to t
                                 [ FONTDIR="$withval" ],
                                 [ FONTDIR="${libdir}/X11/fonts" ])
 DEFAULT_FONT_PATH="${FONTDIR}/misc/,${FONTDIR}/TTF/,${FONTDIR}/OTF,${FONTDIR}/Type1/,${FONTDIR}/100dpi/,${FONTDIR}/75dpi/"
+case $host_os in
+	darwin*)    DEFAULT_FONT_PATH="${DEFAULT_FONT_PATH},/Library/Fonts,/System/Library/Fonts" ;;
+esac
 AC_ARG_WITH(default-font-path, AS_HELP_STRING([--with-default-font-path=PATH], [Comma separated list of font dirs]),
 				[ FONTPATH="$withval" ],
 				[ FONTPATH="${DEFAULT_FONT_PATH}" ])
commit 39d3a87c6cb3e1db1321fb71000507bc4d4b7cfb
Author: Ben Byer <bbyer at bbyer.local>
Date:   Sat Dec 1 18:28:19 2007 -0800

    added missing call to xcb_connect()
    (cherry picked from commit dc2fb323ee11f081d447605be151024f9e2487f9)

diff --git a/hw/darwin/apple/bundle-main.c b/hw/darwin/apple/bundle-main.c
index d46e7b2..10d2f20 100644
--- a/hw/darwin/apple/bundle-main.c
+++ b/hw/darwin/apple/bundle-main.c
@@ -613,8 +613,9 @@ display_exists_p (int number)
     sprintf (buf, "/tmp/.X11-unix/X%d", number);
     if (access (buf, F_OK) != 0)
 		return FALSE;
-	
+    
     sprintf (buf, ":%d", number);
+    conn = xcb_connect(buf, NULL);
     if (xcb_connection_has_error(conn)) return FALSE;
 	
     xcb_disconnect(conn);
commit ed66724b3a2ba14da76728e55ad79768e546ece9
Author: Jeremy Huddleston <jeremy at tifa.local>
Date:   Sat Dec 1 16:23:23 2007 -0800

    Darwin: Alt is Mode_switch Switching to Mode_switch to maintain compatibility with Tiger X11.
    (cherry picked from commit 8a76c99c0ebbaf7375f3a9c75c4f7921a79024da)

diff --git a/hw/darwin/darwinKeyboard.c b/hw/darwin/darwinKeyboard.c
index 7f7b7c7..851a10f 100644
--- a/hw/darwin/darwinKeyboard.c
+++ b/hw/darwin/darwinKeyboard.c
@@ -518,8 +518,8 @@ Bool DarwinParseNXKeyMapping(
                                 (left ? XK_Control_L : XK_Control_R);
                         break;
                     case NX_MODIFIERKEY_ALTERNATE:
-                        info->keyMap[keyCode * GLYPHS_PER_KEY] =
-                                (left ? XK_Alt_L : XK_Alt_R);
+                        info->keyMap[keyCode * GLYPHS_PER_KEY] = XK_Mode_switch;
+                                // (left ? XK_Alt_L : XK_Alt_R);
                         break;
                     case NX_MODIFIERKEY_COMMAND:
                         info->keyMap[keyCode * GLYPHS_PER_KEY] =
@@ -709,6 +709,11 @@ DarwinBuildModifierMaps(darwinKeyboardInfo *info) {
                 break;
 
             case XK_Mode_switch:
+                // Yes, this is ugly.  This needs to be cleaned up when we integrate quartzKeyboard with this code and refactor.
+#ifdef NX_MODIFIERKEY_RALTERNATE
+                info->modifierKeycodes[NX_MODIFIERKEY_RALTERNATE][0] = i;
+#endif
+                info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
                 info->modMap[MIN_KEYCODE + i] = Mod1Mask;
                 break;
 
diff --git a/hw/darwin/quartz/Makefile.am b/hw/darwin/quartz/Makefile.am
index fe66429..f5199df 100644
--- a/hw/darwin/quartz/Makefile.am
+++ b/hw/darwin/quartz/Makefile.am
@@ -3,7 +3,6 @@ noinst_LIBRARIES = libXQuartz.a
 AM_CFLAGS = $(XSERVER_CFLAGS) $(DIX_CFLAGS)
 AM_OBJCFLAGS = $(XSERVER_CFLAGS) $(DIX_CFLAGS)
 AM_CPPFLAGS = \
-	-DHAS_KL_API \
 	-I$(srcdir) -I$(srcdir)/.. \
 	-I$(top_srcdir)/miext/rootless
 
diff --git a/hw/darwin/quartz/quartzKeyboard.c b/hw/darwin/quartz/quartzKeyboard.c
index b87249f..ee485b8 100644
--- a/hw/darwin/quartz/quartzKeyboard.c
+++ b/hw/darwin/quartz/quartzKeyboard.c
@@ -44,8 +44,6 @@
 #include "X11/keysym.h"
 #include "keysym2ucs.h"
 
-#ifdef HAS_KL_API
-
 #define HACK_MISSING 1
 #define HACK_KEYPAD 1
 
@@ -68,11 +66,11 @@ const static struct {
     {55,  XK_Meta_L},
     {56,  XK_Shift_L},
     {57,  XK_Caps_Lock},
-    {58,  XK_Alt_L},
+    {58,  XK_Mode_switch},
     {59,  XK_Control_L},
 
     {60,  XK_Shift_R},
-    {61,  XK_Alt_R},
+    {61,  XK_Mode_switch},
     {62,  XK_Control_R},
     {63,  XK_Meta_R},
 
@@ -332,19 +330,3 @@ DarwinModeReadSystemKeymap (darwinKeyboardInfo *info)
     
     return TRUE;
 }
-
-#else /* !HAS_KL_API */
-
-unsigned int
-DarwinModeSystemKeymapSeed (void)
-{
-    return 0;
-}
-
-Bool
-DarwinModeReadSystemKeymap (darwinKeyboardInfo *info)
-{
-    return FALSE;
-}
-
-#endif /* HAS_KL_API */
commit bf1f49c5304db6c4bfcfc83f9d47944f48024f82
Author: Ben Byer <bbyer at bbyer.local>
Date:   Fri Nov 30 11:18:46 2007 -0800

    properly implemented xcb check for stale sockets
    (cherry picked from commit f543cb8fbb3d9213cb03396f4252ab9821319993)

diff --git a/hw/darwin/apple/bundle-main.c b/hw/darwin/apple/bundle-main.c
index 34cbcba..d46e7b2 100644
--- a/hw/darwin/apple/bundle-main.c
+++ b/hw/darwin/apple/bundle-main.c
@@ -614,20 +614,9 @@ display_exists_p (int number)
     if (access (buf, F_OK) != 0)
 		return FALSE;
 	
-    /* This is a private function that we shouldn't really be calling,
-	 but it's the best way to see if the server exists (without
-	 needing to hold the necessary authentication to use it) */
-	
     sprintf (buf, ":%d", number);
-    /*    conn = _X11TransConnectDisplay (buf, &fullname, &idisplay, &iscreen,
-									&conn_auth_name, &conn_auth_namelen,
-									&conn_auth_data, &conn_auth_datalen); */
-    conn = xcb_connect(buf, NULL);
-
-    if (conn == NULL)
-		return FALSE;
+    if (xcb_connection_has_error(conn)) return FALSE;
 	
-    //    _XDisconnectDisplay (conn);
     xcb_disconnect(conn);
     return TRUE;
 }
commit be05ef82d5d598025d193f1732947f6f29502a65
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Fri Nov 30 16:09:23 2007 -0800

    Darwin: Undo focus-hack which didn't work right.
    (cherry picked from commit f54b28eeba119c42d0fcccfbe295306dd670221a)

diff --git a/hw/darwin/quartz/X11Application.m b/hw/darwin/quartz/X11Application.m
index 514bc49..aef0699 100644
--- a/hw/darwin/quartz/X11Application.m
+++ b/hw/darwin/quartz/X11Application.m
@@ -313,9 +313,6 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
 }
 
 - (void) set_front_process:unused {
-    [NSApp activateIgnoringOtherApps:YES];
-	
-    if ([self modalWindow] == nil) [self activateX:YES];
     QuartzMessageServerThread(kXDarwinBringAllToFront, 0);
 }
 
commit b037e4a5abb878ad89e7f27c2b6c23004625f6c3
Author: Peter Harris <peter.harris at hummingbird.com>
Date:   Mon Oct 29 18:05:19 2007 -0400

    Add missing swaps in panoramiXSwap.c
    (cherry picked from commit cb67a10b7f6f564e0345de19316934361ea28720)

diff --git a/Xext/panoramiXSwap.c b/Xext/panoramiXSwap.c
index da445ff..0487471 100644
--- a/Xext/panoramiXSwap.c
+++ b/Xext/panoramiXSwap.c
@@ -70,6 +70,7 @@ SProcPanoramiXGetState(ClientPtr client)
 
  	swaps (&stuff->length, n);	
 	REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
+	swapl (&stuff->window, n);
 	return ProcPanoramiXGetState(client);
 }
 
@@ -81,6 +82,7 @@ SProcPanoramiXGetScreenCount(ClientPtr client)
 
 	swaps (&stuff->length, n);
 	REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
+	swapl (&stuff->window, n);
 	return ProcPanoramiXGetScreenCount(client);
 }
 
@@ -92,6 +94,8 @@ SProcPanoramiXGetScreenSize(ClientPtr client)
 
 	swaps (&stuff->length, n);
 	REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
+	swapl (&stuff->window, n);
+	swapl (&stuff->screen, n);
 	return ProcPanoramiXGetScreenSize(client);
 }
 
commit 3e0993fcf38e47dd42c27a2dcb5dde7d23222ca8
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Nov 30 20:35:26 2007 +0200

    ProcessOtherEvent: Don't do double translation of button events
    
    We already deal with the button mapping in GetPointerEvents, so don't
    do the remapping again in ProcessOtherEvent.
    (cherry picked from commit 7ff002fe3e229330216d7f2ff16cdabe63014bcd)

diff --git a/Xi/exevents.c b/Xi/exevents.c
index 377311e..7cf0c50 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -244,7 +244,7 @@ ProcessOtherEvent(xEventPtr xE, DeviceIntPtr other, int count)
 	    other->valuator->motionHintWindow = NullWindow;
 	b->buttonsDown++;
 	b->motionMask = DeviceButtonMotionMask;
-	xE->u.u.detail = b->map[key];
+	xE->u.u.detail = key;
 	if (xE->u.u.detail == 0)
 	    return;
 	if (xE->u.u.detail <= 5)
@@ -266,7 +266,7 @@ ProcessOtherEvent(xEventPtr xE, DeviceIntPtr other, int count)
 	    other->valuator->motionHintWindow = NullWindow;
         if (b->buttonsDown >= 1 && !--b->buttonsDown)
 	    b->motionMask = 0;
-	xE->u.u.detail = b->map[key];
+	xE->u.u.detail = key;
 	if (xE->u.u.detail == 0)
 	    return;
 	if (xE->u.u.detail <= 5)
commit d2b768890f0878ae4e3fec8f7219e82b79256133
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Thu Nov 29 02:19:22 2007 -0800

    Darwin: #ifdefs around dix-config.h include and NDEBUG/assert.h workaround.

diff --git a/hw/darwin/darwin.c b/hw/darwin/darwin.c
index 87edd9a..b46b768 100644
--- a/hw/darwin/darwin.c
+++ b/hw/darwin/darwin.c
@@ -29,7 +29,9 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
+#ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
+#endif
 
 #include <X11/X.h>
 #include <X11/Xproto.h>
diff --git a/hw/darwin/darwin.h b/hw/darwin/darwin.h
index 4f11847..d7d2af4 100644
--- a/hw/darwin/darwin.h
+++ b/hw/darwin/darwin.h
@@ -27,9 +27,6 @@
 #ifndef _DARWIN_H
 #define _DARWIN_H
 
-//#include "dix-config.h" // This crashes us for some reason...
-#define SHAPE
-
 #include <IOKit/IOTypes.h>
 #include "inputstr.h"
 #include "scrnintstr.h"
diff --git a/hw/darwin/darwinKeyboard.c b/hw/darwin/darwinKeyboard.c
index b51e2da..7f7b7c7 100644
--- a/hw/darwin/darwinKeyboard.c
+++ b/hw/darwin/darwinKeyboard.c
@@ -56,9 +56,13 @@
 ===========================================================================
 */
 
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
 // Define this to get a diagnostic output to stderr which is helpful
 // in determining how the X server is interpreting the Darwin keymap.
-#define DUMP_DARWIN_KEYMAP
+// #define DUMP_DARWIN_KEYMAP
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -69,7 +73,15 @@
 #include <architecture/byte_order.h>  // For the NXSwap*
 #include "darwin.h"
 #include "darwinKeyboard.h"
+
+#ifdef NDEBUG
+#undef NDEBUG
 #include <assert.h>
+#define NDEBUG 1
+#else
+#include <assert.h>
+#endif
+
 #define AltMask         Mod1Mask
 #define MetaMask        Mod2Mask
 #define FunctionMask    Mod3Mask
diff --git a/hw/darwin/darwinXinput.c b/hw/darwin/darwinXinput.c
index 260d72a..ee456a4 100644
--- a/hw/darwin/darwinXinput.c
+++ b/hw/darwin/darwinXinput.c
@@ -52,6 +52,10 @@ SOFTWARE.
 
 ********************************************************/
 
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
 #define	 NEED_EVENTS
 #include <X11/X.h>
 #include <X11/Xproto.h>
diff --git a/hw/darwin/quartz/X11Application.m b/hw/darwin/quartz/X11Application.m
index a43d536..514bc49 100644
--- a/hw/darwin/quartz/X11Application.m
+++ b/hw/darwin/quartz/X11Application.m
@@ -27,6 +27,10 @@
  promote the sale, use or other dealings in this Software without
  prior written authorization. */
 
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
 #include "quartzCommon.h"
 
 #import "X11Application.h"
diff --git a/hw/darwin/quartz/X11Controller.m b/hw/darwin/quartz/X11Controller.m
index 6929566..0f64e45 100644
--- a/hw/darwin/quartz/X11Controller.m
+++ b/hw/darwin/quartz/X11Controller.m
@@ -27,6 +27,10 @@
    promote the sale, use or other dealings in this Software without
    prior written authorization. */
 
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
 #define DEFAULT_PATH "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11/bin"
 
 #include "quartzCommon.h"
diff --git a/hw/darwin/quartz/applewm.c b/hw/darwin/quartz/applewm.c
index 20d1b4f..72dca28 100644
--- a/hw/darwin/quartz/applewm.c
+++ b/hw/darwin/quartz/applewm.c
@@ -25,7 +25,9 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 **************************************************************************/
 
+#ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
+#endif
 
 #include "quartzCommon.h"
 
diff --git a/hw/darwin/quartz/cr/XView.m b/hw/darwin/quartz/cr/XView.m
index 8379f94..130b15f 100644
--- a/hw/darwin/quartz/cr/XView.m
+++ b/hw/darwin/quartz/cr/XView.m
@@ -30,10 +30,13 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
+#ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
+#endif
 
 #import "XView.h"
 
+
 @implementation XView
 
 - (BOOL)isFlipped
diff --git a/hw/darwin/quartz/cr/crAppleWM.m b/hw/darwin/quartz/cr/crAppleWM.m
index a0259c3..246f521 100644
--- a/hw/darwin/quartz/cr/crAppleWM.m
+++ b/hw/darwin/quartz/cr/crAppleWM.m
@@ -26,7 +26,9 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
+#ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
+#endif
 
 #include "quartz/quartzCommon.h"
 #include "quartz/cr/cr.h"
diff --git a/hw/darwin/quartz/cr/crFrame.m b/hw/darwin/quartz/cr/crFrame.m
index 79697fb..86c75d2 100644
--- a/hw/darwin/quartz/cr/crFrame.m
+++ b/hw/darwin/quartz/cr/crFrame.m
@@ -27,7 +27,9 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
+#ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
+#endif
 
 #include "quartz/quartzCommon.h"
 #include "quartz/cr/cr.h"
diff --git a/hw/darwin/quartz/cr/crScreen.m b/hw/darwin/quartz/cr/crScreen.m
index 504e7b3..cc82afb 100644
--- a/hw/darwin/quartz/cr/crScreen.m
+++ b/hw/darwin/quartz/cr/crScreen.m
@@ -27,7 +27,9 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
+#ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
+#endif
 
 #include "quartz/quartzCommon.h"
 #include "quartz/cr/cr.h"
diff --git a/hw/darwin/quartz/fullscreen/fullscreen.c b/hw/darwin/quartz/fullscreen/fullscreen.c
index 2021ea2..c4a049f 100644
--- a/hw/darwin/quartz/fullscreen/fullscreen.c
+++ b/hw/darwin/quartz/fullscreen/fullscreen.c
@@ -26,7 +26,9 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
+#ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
+#endif
 
 #include "quartz/quartzCommon.h"
 #include "darwin.h"
diff --git a/hw/darwin/quartz/fullscreen/quartzCursor.c b/hw/darwin/quartz/fullscreen/quartzCursor.c
index 5247781..3ffa1c3 100644
--- a/hw/darwin/quartz/fullscreen/quartzCursor.c
+++ b/hw/darwin/quartz/fullscreen/quartzCursor.c
@@ -28,7 +28,9 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
+#ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
+#endif
 
 #include "quartz/quartzCommon.h"
 #include "quartz/quartzCursor.h"
diff --git a/hw/darwin/quartz/pseudoramiX.c b/hw/darwin/quartz/pseudoramiX.c
index 787601b..b19c605 100644
--- a/hw/darwin/quartz/pseudoramiX.c
+++ b/hw/darwin/quartz/pseudoramiX.c
@@ -33,10 +33,11 @@ dealings in this Software without prior written authorization from Digital
 Equipment Corporation.
 ******************************************************************/
 
-#include "pseudoramiX.h"
-
+#ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
+#endif
 
+#include "pseudoramiX.h"
 #include "extnsionst.h"
 #include "dixstruct.h"
 #include "window.h"
diff --git a/hw/darwin/quartz/quartz.c b/hw/darwin/quartz/quartz.c
index c95880c..2483d12 100644
--- a/hw/darwin/quartz/quartz.c
+++ b/hw/darwin/quartz/quartz.c
@@ -28,7 +28,9 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
+#ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
+#endif
 
 #include "quartzCommon.h"
 #include "quartz.h"
diff --git a/hw/darwin/quartz/quartzAudio.c b/hw/darwin/quartz/quartzAudio.c
index 8a337da..1eb099b 100644
--- a/hw/darwin/quartz/quartzAudio.c
+++ b/hw/darwin/quartz/quartzAudio.c
@@ -36,7 +36,9 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
+#ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
+#endif
 
 #include "quartzCommon.h"
 #include "quartzAudio.h"
diff --git a/hw/darwin/quartz/quartzCocoa.m b/hw/darwin/quartz/quartzCocoa.m
index 48cadc6..0086c5c 100644
--- a/hw/darwin/quartz/quartzCocoa.m
+++ b/hw/darwin/quartz/quartzCocoa.m
@@ -32,7 +32,9 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
+#ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
+#endif
 
 #include "quartzCommon.h"
 
diff --git a/hw/darwin/quartz/quartzCursor.c b/hw/darwin/quartz/quartzCursor.c
index 15f5553..6e86acb 100644
--- a/hw/darwin/quartz/quartzCursor.c
+++ b/hw/darwin/quartz/quartzCursor.c
@@ -28,7 +28,9 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
+#ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
+#endif
 
 #include "quartzCommon.h"
 #include "quartzCursor.h"
diff --git a/hw/darwin/quartz/quartzKeyboard.c b/hw/darwin/quartz/quartzKeyboard.c
index 49c5bfd..b87249f 100644
--- a/hw/darwin/quartz/quartzKeyboard.c
+++ b/hw/darwin/quartz/quartzKeyboard.c
@@ -31,7 +31,9 @@
    prior written authorization.
 */
 
+#ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
+#endif
 
 #include "quartzCommon.h"
 
diff --git a/hw/darwin/quartz/quartzPasteboard.c b/hw/darwin/quartz/quartzPasteboard.c
index 2130197..0cecff5 100644
--- a/hw/darwin/quartz/quartzPasteboard.c
+++ b/hw/darwin/quartz/quartzPasteboard.c
@@ -30,7 +30,9 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
+#ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
+#endif
 
 #include "quartzPasteboard.h"
 
diff --git a/hw/darwin/quartz/quartzStartup.c b/hw/darwin/quartz/quartzStartup.c
index 6f45949..e20c16b 100644
--- a/hw/darwin/quartz/quartzStartup.c
+++ b/hw/darwin/quartz/quartzStartup.c
@@ -27,6 +27,10 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
 #include <fcntl.h>
 #include <unistd.h>
 #include <CoreFoundation/CoreFoundation.h>
@@ -35,7 +39,14 @@
 #include "quartz.h"
 #include "opaque.h"
 #include "micmap.h"
+
+#ifdef NDEBUG
+#undef NDEBUG
+#include <assert.h>
+#define NDEBUG 1
+#else
 #include <assert.h>
+#endif
 
 char **envpGlobal;      // argcGlobal and argvGlobal
                         // are from dix/globals.c
diff --git a/hw/darwin/quartz/xpr/Makefile.am b/hw/darwin/quartz/xpr/Makefile.am
index 8f482f1..8980ad7 100644
--- a/hw/darwin/quartz/xpr/Makefile.am
+++ b/hw/darwin/quartz/xpr/Makefile.am
@@ -1,7 +1,6 @@
 noinst_LIBRARIES = libxpr.a
 AM_CFLAGS =  $(XSERVER_CFLAGS) $(DIX_CFLAGS)
 AM_CPPFLAGS = \
-	   -DHAVE_XORG_CONFIG_H \
 	   -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../.. \
 	   -I$(top_srcdir)/miext \
 	   -I$(top_srcdir)/miext/rootless \
diff --git a/hw/darwin/quartz/xpr/appledri.c b/hw/darwin/quartz/xpr/appledri.c
index 45d1a7e..95a4439 100644
--- a/hw/darwin/quartz/xpr/appledri.c
+++ b/hw/darwin/quartz/xpr/appledri.c
@@ -35,7 +35,9 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  */
 
+#ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
+#endif
 
 #define NEED_REPLIES
 #define NEED_EVENTS
diff --git a/hw/darwin/quartz/xpr/dri.c b/hw/darwin/quartz/xpr/dri.c
index 4ade249..e5591ab 100644
--- a/hw/darwin/quartz/xpr/dri.c
+++ b/hw/darwin/quartz/xpr/dri.c
@@ -34,7 +34,9 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  */
 
+#ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
+#endif
 
 #ifdef XFree86LOADER
 #include "xf86.h"
diff --git a/hw/darwin/quartz/xpr/x-hash.c b/hw/darwin/quartz/xpr/x-hash.c
index d24e05c..55d28ba 100644
--- a/hw/darwin/quartz/xpr/x-hash.c
+++ b/hw/darwin/quartz/xpr/x-hash.c
@@ -27,7 +27,9 @@
    promote the sale, use or other dealings in this Software without
    prior written authorization. */
 
+#ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
+#endif
 
 #include "x-hash.h"
 #include "x-list.h"
diff --git a/hw/darwin/quartz/xpr/x-hook.c b/hw/darwin/quartz/xpr/x-hook.c
index e38d0ed..bb873bb 100644
--- a/hw/darwin/quartz/xpr/x-hook.c
+++ b/hw/darwin/quartz/xpr/x-hook.c
@@ -27,7 +27,9 @@
    promote the sale, use or other dealings in this Software without
    prior written authorization. */
 
+#ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
+#endif
 
 #include "x-hook.h"
 #include <stdlib.h>
diff --git a/hw/darwin/quartz/xpr/x-list.c b/hw/darwin/quartz/xpr/x-list.c
index 356bb79..3596dd3 100644
--- a/hw/darwin/quartz/xpr/x-list.c
+++ b/hw/darwin/quartz/xpr/x-list.c
@@ -27,7 +27,9 @@
    promote the sale, use or other dealings in this Software without
    prior written authorization. */
 
+#ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
+#endif
 
 #include "x-list.h"
 #include <stdlib.h>
diff --git a/hw/darwin/quartz/xpr/xprAppleWM.c b/hw/darwin/quartz/xpr/xprAppleWM.c
index f639b55..5539c51 100644
--- a/hw/darwin/quartz/xpr/xprAppleWM.c
+++ b/hw/darwin/quartz/xpr/xprAppleWM.c
@@ -27,7 +27,9 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
+#ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
+#endif
 
 #include "xpr.h"
 #include "quartz/applewmExt.h"
diff --git a/hw/darwin/quartz/xpr/xprCursor.c b/hw/darwin/quartz/xpr/xprCursor.c
index 9892bcd..160b5d9 100644
--- a/hw/darwin/quartz/xpr/xprCursor.c
+++ b/hw/darwin/quartz/xpr/xprCursor.c
@@ -29,7 +29,9 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
+#ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
+#endif
 
 #include "quartz/quartzCommon.h"
 #include "xpr.h"
diff --git a/hw/darwin/quartz/xpr/xprFrame.c b/hw/darwin/quartz/xpr/xprFrame.c
index ddb6d2d..1b0ba91 100644
--- a/hw/darwin/quartz/xpr/xprFrame.c
+++ b/hw/darwin/quartz/xpr/xprFrame.c
@@ -27,7 +27,9 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
+#ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
+#endif
 
 #include "xpr.h"
 #include "rootlessCommon.h"
diff --git a/hw/darwin/quartz/xpr/xprScreen.c b/hw/darwin/quartz/xpr/xprScreen.c
index b5f382e..28ed159 100644
--- a/hw/darwin/quartz/xpr/xprScreen.c
+++ b/hw/darwin/quartz/xpr/xprScreen.c
@@ -27,7 +27,9 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
+#ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
+#endif
 
 #include "quartz/quartzCommon.h"
 #include "quartz/quartz.h"
commit 3d153c8fa40986d194b7701f5eafa0080e32399a
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Wed Nov 28 23:07:41 2007 -0800

    Darwin: Removed support for darwinSwapAltMeta

diff --git a/hw/darwin/darwin.c b/hw/darwin/darwin.c
index b08770c..87edd9a 100644
--- a/hw/darwin/darwin.c
+++ b/hw/darwin/darwin.c
@@ -100,7 +100,6 @@ int                     darwinDesiredDepth = -1;
 int                     darwinDesiredRefresh = -1;
 char                    *darwinKeymapFile = "USA.keymapping";
 int                     darwinSyncKeymap = FALSE;
-int                     darwinSwapAltMeta = FALSE;
 
 // modifier masks for faking mouse buttons
 int                     darwinFakeMouse2Mask = NX_ALTERNATEMASK;
@@ -766,11 +765,6 @@ int ddxProcessArgument( int argc, char *argv[], int i )
         return 2;
     }
 
-    if ( !strcmp( argv[i], "-swapAltMeta" ) ) {
-        darwinSwapAltMeta = 1;
-        return 1;
-    }
-
     if ( !strcmp( argv[i], "-keymap" ) ) {
         if ( i == argc-1 ) {
             FatalError( "-keymap must be followed by a filename\n" );
diff --git a/hw/darwin/darwin.h b/hw/darwin/darwin.h
index e2e4829..4f11847 100644
--- a/hw/darwin/darwin.h
+++ b/hw/darwin/darwin.h
@@ -27,7 +27,7 @@
 #ifndef _DARWIN_H
 #define _DARWIN_H
 
-// #include "dix-config.h" // This makes us crash for some reason...
+//#include "dix-config.h" // This crashes us for some reason...
 #define SHAPE
 
 #include <IOKit/IOTypes.h>
@@ -113,7 +113,6 @@ extern int              darwinMouseAccelChange;
 extern int              darwinFakeButtons;
 extern int              darwinFakeMouse2Mask;
 extern int              darwinFakeMouse3Mask;
-extern int              darwinSwapAltMeta;
 extern char            *darwinKeymapFile;
 extern int              darwinSyncKeymap;
 extern unsigned int     darwinDesiredWidth, darwinDesiredHeight;
diff --git a/hw/darwin/darwinKeyboard.c b/hw/darwin/darwinKeyboard.c
index 47acb65..b51e2da 100644
--- a/hw/darwin/darwinKeyboard.c
+++ b/hw/darwin/darwinKeyboard.c
@@ -58,10 +58,7 @@
 
 // Define this to get a diagnostic output to stderr which is helpful
 // in determining how the X server is interpreting the Darwin keymap.
-#undef DUMP_DARWIN_KEYMAP
-
-/* Define this to use Alt for Mode_switch. */
-//#define ALT_IS_MODE_SWITCH 1
+#define DUMP_DARWIN_KEYMAP
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -77,9 +74,6 @@
 #define MetaMask        Mod2Mask
 #define FunctionMask    Mod3Mask
 
-// FIXME: It would be nice to support some of the extra keys in XF86keysym.h,
-// at least the volume controls that now ship on every Apple keyboard.
-
 #define UK(a)           NoSymbol    // unknown symbol
 
 static KeySym const next_to_x[256] = {
@@ -513,7 +507,7 @@ Bool DarwinParseNXKeyMapping(
                         break;
                     case NX_MODIFIERKEY_ALTERNATE:
                         info->keyMap[keyCode * GLYPHS_PER_KEY] =
-                                (left ? XK_Mode_switch : XK_Alt_R);
+                                (left ? XK_Alt_L : XK_Alt_R);
                         break;
                     case NX_MODIFIERKEY_COMMAND:
                         info->keyMap[keyCode * GLYPHS_PER_KEY] =
@@ -638,27 +632,23 @@ Bool DarwinParseNXKeyMapping(
     return TRUE;
 }
 
-
 /*
  * DarwinBuildModifierMaps
  *      Use the keyMap field of keyboard info structure to populate
  *      the modMap and modifierKeycodes fields.
  */
 static void
-DarwinBuildModifierMaps(
-    darwinKeyboardInfo *info)
-{
+DarwinBuildModifierMaps(darwinKeyboardInfo *info) {
     int i;
     KeySym *k;
 
     memset(info->modMap, NoSymbol, sizeof(info->modMap));
     memset(info->modifierKeycodes, 0, sizeof(info->modifierKeycodes));
 
-    for (i = 0; i < NUM_KEYCODES; i++)
-    {
+    for (i = 0; i < NUM_KEYCODES; i++) {
         k = info->keyMap + i * GLYPHS_PER_KEY;
 
-        switch (k[0]) {
+        switch (*k) {
             case XK_Shift_L:
                 info->modifierKeycodes[NX_MODIFIERKEY_SHIFT][0] = i;
                 info->modMap[MIN_KEYCODE + i] = ShiftMask;
@@ -728,34 +718,9 @@ DarwinBuildModifierMaps(
                 info->modMap[MIN_KEYCODE + i] = Mod3Mask;
                 break;
         }
-
-        if (darwinSwapAltMeta)
-        {
-            switch (k[0])
-            {
-            case XK_Alt_L:
-                k[0] = XK_Meta_L;
-                break;
-            case XK_Alt_R:
-                k[0] = XK_Meta_R;
-                break;
-            case XK_Meta_L:
-                k[0] = XK_Alt_L;
-                break;
-            case XK_Meta_R:
-                k[0] = XK_Alt_R;
-                break;
-            }
-        }
-
-#if ALT_IS_MODE_SWITCH
-        if (k[0] == XK_Alt_L)
-            k[0] = XK_Mode_switch;
-#endif
     }
 }
 
-
 /*
  * DarwinLoadKeyboardMapping
  *  Load the keyboard map from a file or system and convert
@@ -764,9 +729,17 @@ DarwinBuildModifierMaps(
 static void
 DarwinLoadKeyboardMapping(KeySymsRec *keySyms)
 {
+    int i;
+    KeySym *k;
+
     memset(keyInfo.keyMap, 0, sizeof(keyInfo.keyMap));
 
+    /* TODO: Clean this up
+     * DarwinModeReadSystemKeymap is in quartz/quartzKeyboard.c
+     * DarwinParseNXKeyMapping is here
+     */
     if (!DarwinParseNXKeyMapping(&keyInfo)) {
+        DEBUG_LOG("DarwinParseNXKeyMapping returned 0... running DarwinModeReadSystemKeymap().\n");
         if (!DarwinModeReadSystemKeymap(&keyInfo)) {
             FatalError("Could not build a valid keymap.");
         }
@@ -775,20 +748,18 @@ DarwinLoadKeyboardMapping(KeySymsRec *keySyms)
     DarwinBuildModifierMaps(&keyInfo);
 
 #ifdef DUMP_DARWIN_KEYMAP
-    ErrorF("Darwin -> X converted keyboard map\n");
-    for (i = 0, k = info->keyMap; i < NX_NUMKEYCODES;
+    DEBUG_LOG("Darwin -> X converted keyboard map\n");
+    for (i = 0, k = keyInfo.keyMap; i < NX_NUMKEYCODES;
          i++, k += GLYPHS_PER_KEY)
     {
         int j;
-        ErrorF("0x%02x:", i);
         for (j = 0; j < GLYPHS_PER_KEY; j++) {
             if (k[j] == NoSymbol) {
-                ErrorF("\tNoSym");
+                DEBUG_LOG("0x%02x:\tNoSym\n", i);
             } else {
-                ErrorF("\t0x%x", k[j]);
+                DEBUG_LOG("0x%02x:\t0x%lx\n", i, k[j]);
             }
         }
-        ErrorF("\n");
     }
 #endif
 
@@ -937,32 +908,6 @@ int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide)
 }
 
 /*
- * DarwinModifierNXMaskToNXKeyCode
- *      Returns 0 if mask is not a known modifier mask.
- */
-int DarwinModifierNXMaskToNXKeyCode(int mask)
-{
-  switch (mask) {
-  case NX_ALPHASHIFTMASK:       return XK_Caps_Lock;
-  case NX_SHIFTMASK: ErrorF("Warning: Received NX_SHIFTMASK, treating as NX_DEVICELSHIFTKEYMASK\n");
-  case NX_DEVICELSHIFTKEYMASK:  return NX_MODIFIERKEY_SHIFT; //XK_Shift_L;
-  case NX_DEVICERSHIFTKEYMASK:  return NX_MODIFIERKEY_RSHIFT; //XK_Shift_R;
-  case NX_CONTROLMASK: ErrorF("Warning: Received NX_CONTROLMASK, treating as NX_DEVICELCTLKEYMASK\n");
-  case NX_DEVICELCTLKEYMASK:    return XK_Control_L;
-  case NX_DEVICERCTLKEYMASK:    return XK_Control_R;
-  case NX_ALTERNATEMASK: ErrorF("Warning: Received NX_ALTERNATEMASK, treating as NX_DEVICELALTKEYMASK\n");
-  case NX_DEVICELALTKEYMASK:    return XK_Alt_L;
-  case NX_DEVICERALTKEYMASK:    return XK_Alt_R;
-  case NX_COMMANDMASK: ErrorF("Warning: Received NX_COMMANDMASK, treating as NX_DEVICELCMDKEYMASK\n");
-  case NX_DEVICELCMDKEYMASK:    return XK_Meta_L;
-  case NX_DEVICERCMDKEYMASK:    return XK_Meta_R;
-  case NX_NUMERICPADMASK:       return XK_Num_Lock;
-  case NX_HELPMASK:             return XK_Help;
-  case NX_SECONDARYFNMASK:      return XK_Control_L; // this seems very wrong, but is what the old code did
-    }
-}
-
-/*
  * DarwinModifierNXMaskToNXKey
  *      Returns -1 if mask is not a known modifier mask.
  */
@@ -997,25 +942,25 @@ int DarwinModifierNXMaskToNXKey(int mask)
     return -1;
 }
 
-char * DarwinModifierNXMaskTostring(int mask)
+const char *DarwinModifierNXMaskTostring(int mask)
 {
     switch (mask) {
-    case NX_ALPHASHIFTMASK: return "NX_ALPHASHIFTMASK";
-    case NX_SHIFTMASK: return "NX_SHIFTMASK";
-    case NX_DEVICELSHIFTKEYMASK: return "NX_DEVICELSHIFTKEYMASK";
-    case NX_DEVICERSHIFTKEYMASK: return "NX_DEVICERSHIFTKEYMASK";
-    case NX_CONTROLMASK: return "NX_CONTROLMASK";
-    case NX_DEVICELCTLKEYMASK: return "NX_DEVICELCTLKEYMASK";
-    case NX_DEVICERCTLKEYMASK: return "NX_DEVICERCTLKEYMASK";
-    case NX_ALTERNATEMASK: return "NX_ALTERNATEMASK";
-    case NX_DEVICELALTKEYMASK: return "NX_DEVICELALTKEYMASK";
-    case NX_DEVICERALTKEYMASK: return "NX_DEVICERALTKEYMASK";
-    case NX_COMMANDMASK: return "NX_COMMANDMASK";
-    case NX_DEVICELCMDKEYMASK: return "NX_DEVICELCMDKEYMASK";
-    case NX_DEVICERCMDKEYMASK: return "NX_DEVICERCMDKEYMASK";
-    case NX_NUMERICPADMASK: return "NX_NUMERICPADMASK";
-    case NX_HELPMASK: return "NX_HELPMASK";
-    case NX_SECONDARYFNMASK: return "NX_SECONDARYFNMASK";
+        case NX_ALPHASHIFTMASK:      return "NX_ALPHASHIFTMASK";
+        case NX_SHIFTMASK:           return "NX_SHIFTMASK";
+        case NX_DEVICELSHIFTKEYMASK: return "NX_DEVICELSHIFTKEYMASK";
+        case NX_DEVICERSHIFTKEYMASK: return "NX_DEVICERSHIFTKEYMASK";
+        case NX_CONTROLMASK:         return "NX_CONTROLMASK";
+        case NX_DEVICELCTLKEYMASK:   return "NX_DEVICELCTLKEYMASK";
+        case NX_DEVICERCTLKEYMASK:   return "NX_DEVICERCTLKEYMASK";
+        case NX_ALTERNATEMASK:       return "NX_ALTERNATEMASK";
+        case NX_DEVICELALTKEYMASK:   return "NX_DEVICELALTKEYMASK";
+        case NX_DEVICERALTKEYMASK:   return "NX_DEVICERALTKEYMASK";
+        case NX_COMMANDMASK:         return "NX_COMMANDMASK";
+        case NX_DEVICELCMDKEYMASK:   return "NX_DEVICELCMDKEYMASK";
+        case NX_DEVICERCMDKEYMASK:   return "NX_DEVICERCMDKEYMASK";
+        case NX_NUMERICPADMASK:      return "NX_NUMERICPADMASK";
+        case NX_HELPMASK:            return "NX_HELPMASK";
+        case NX_SECONDARYFNMASK:     return "NX_SECONDARYFNMASK";
     }
     return "unknown mask";
 }
diff --git a/hw/darwin/quartz/X11Application.m b/hw/darwin/quartz/X11Application.m
index 60d11c5..a43d536 100644
--- a/hw/darwin/quartz/X11Application.m
+++ b/hw/darwin/quartz/X11Application.m
@@ -612,9 +612,6 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
     quartzXpluginOptions = [self prefs_get_integer:@PREFS_XP_OPTIONS
                             default:quartzXpluginOptions];
 #endif
-	
-    darwinSwapAltMeta = [self prefs_get_boolean:@PREFS_SWAP_ALT_META
-                         default:darwinSwapAltMeta];
     darwinFakeButtons = [self prefs_get_boolean:@PREFS_FAKEBUTTONS
                          default:darwinFakeButtons];
     if (darwinFakeButtons) {
commit aa1fedbd69a20d54b9c12e371da2710239ba1bcc
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Mon Nov 26 14:54:51 2007 -0800

    Darwin: Added missing function prototypes.

diff --git a/hw/darwin/darwin.h b/hw/darwin/darwin.h
index e85013d..e2e4829 100644
--- a/hw/darwin/darwin.h
+++ b/hw/darwin/darwin.h
@@ -61,6 +61,10 @@ Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr);
 void DarwinEQEnqueue(const xEvent *e);
 void DarwinEQPointerPost(xEvent *e);
 void DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX);
+void DarwinPokeEQ(void);
+void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int pointer_y);
+void DarwinSendKeyboardEvents(int ev_type, int keycode);
+void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y);
 
 // From darwinKeyboard.c
 int DarwinModifierNXKeyToNXKeycode(int key, int side);
commit b8ccca70ffc9a96332a56724ebcdb78b8c73e1a9
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Mon Nov 26 14:29:07 2007 -0800

    Darwin: Workaround weird crash in keyboard events
    Somehow including dix-config.h in darwin.h is crashing us... just defining
    SHAPE as a workaround for now.

diff --git a/hw/darwin/darwin.h b/hw/darwin/darwin.h
index a8c670b..e85013d 100644
--- a/hw/darwin/darwin.h
+++ b/hw/darwin/darwin.h
@@ -27,7 +27,8 @@
 #ifndef _DARWIN_H
 #define _DARWIN_H
 
-#include "dix-config.h"
+// #include "dix-config.h" // This makes us crash for some reason...
+#define SHAPE
 
 #include <IOKit/IOTypes.h>
 #include "inputstr.h"
diff --git a/hw/darwin/launcher/Makefile.am b/hw/darwin/launcher/Makefile.am
index f2d9ede..c291731 100644
--- a/hw/darwin/launcher/Makefile.am
+++ b/hw/darwin/launcher/Makefile.am
@@ -6,7 +6,7 @@ x11launcher:
 	xcodebuild CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" ARCHS="$(X11APP_ARCHS)"
 
 install-data-hook:
-	cd launcher && xcodebuild install DSTROOT=$(DESTDIR) INSTALL_PATH=$(APPLE_APPLICATIONS_DIR) DEPLOYMENT_LOCATION=YES SKIP_INSTALL=NO ARCHS="$(X11APP_ARCHS)"
+	xcodebuild install DSTROOT=$(DESTDIR) INSTALL_PATH=$(APPLE_APPLICATIONS_DIR) DEPLOYMENT_LOCATION=YES SKIP_INSTALL=NO ARCHS="$(X11APP_ARCHS)"
 
 clean-local:
 	rm -rf build
diff --git a/hw/darwin/quartz/xpr/Makefile.am b/hw/darwin/quartz/xpr/Makefile.am
index f610f73..8f482f1 100644
--- a/hw/darwin/quartz/xpr/Makefile.am
+++ b/hw/darwin/quartz/xpr/Makefile.am
@@ -9,14 +9,14 @@ AM_CPPFLAGS = \
 
 libxpr_a_SOURCES = \
 	appledri.c \
-        dri.c \
-        xprAppleWM.c \
-        xprCursor.c \
-        xprFrame.c \
-        xprScreen.c \
-        x-hash.c \
-        x-hook.c \
-        x-list.c
+	dri.c \
+	xprAppleWM.c \
+	xprCursor.c \
+	xprFrame.c \
+	xprScreen.c \
+	x-hash.c \
+	x-hook.c \
+	x-list.c
 
 EXTRA_DIST = \
 	dri.h \
commit e4933212e1a1e15b37b0d68e733ee91bb406db7a
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Mon Nov 26 13:05:48 2007 -0800

    Darwin: Switched to expirimental darwinEvents.c from master

diff --git a/hw/darwin/darwinEvents.c b/hw/darwin/darwinEvents.c
index 4201e0e..629fb2c 100644
--- a/hw/darwin/darwinEvents.c
+++ b/hw/darwin/darwinEvents.c
@@ -1,9 +1,9 @@
 /*
- * Darwin event queue and event handling
- */
-/*
-Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved.
+Darwin event queue and event handling
+
+Copyright 2007 Apple Inc.
 Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
+Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved.
 
 This file is based on mieq.c by Keith Packard,
 which contains the following copyright:
@@ -41,6 +41,7 @@ in this Software without prior written authorization from The Open Group.
 #include   "mi.h"
 #include   "scrnintstr.h"
 #include   "mipointer.h"
+
 #include "darwin.h"
 #include "darwinKeyboard.h"
 
@@ -60,6 +61,10 @@ typedef struct _Event {
     ScreenPtr   pScreen;
 } EventRec, *EventPtr;
 
+int input_check_zero, input_check_flag;
+
+static int old_flags = 0;  // last known modifier state
+
 typedef struct _EventQueue {
     HWEventQueueType    head, tail; /* long for SetInputCheck */
     CARD32      lastEventTime;      /* to avoid time running backwards */
@@ -71,8 +76,24 @@ typedef struct _EventQueue {
 } EventQueueRec, *EventQueuePtr;
 
 static EventQueueRec darwinEventQueue;
-extern darwinKeyboardInfo keyInfo;
-#define KeyPressed(k) (((DeviceIntPtr)darwinEventQueue.pKbd)->key->down[k >> 3] & (1 << (k & 7)))
+xEvent *darwinEvents;
+
+/*
+ * DarwinPressModifierMask
+ *  Press or release the given modifier key, specified by its mask.
+ */
+static void DarwinPressModifierMask(
+    int pressed,				    
+    int mask)       // one of NX_*MASK constants
+{
+    int key = DarwinModifierNXMaskToNXKey(mask);
+
+    if (key != -1) {
+        int keycode = DarwinModifierNXKeyToNXKeycode(key, 0);
+        if (keycode != 0)
+	  DarwinSendKeyboardEvents(pressed, keycode);
+    }
+}
 
 #ifdef NX_DEVICELCTLKEYMASK
 #define CONTROL_MASK(flags) (flags & (NX_DEVICELCTLKEYMASK|NX_DEVICERCTLKEYMASK))
@@ -98,132 +119,32 @@ extern darwinKeyboardInfo keyInfo;
 #define ALTERNATE_MASK(flags) (NX_ALTERNATEMASK)
 #endif /* NX_DEVICELALTKEYMASK */
 
-#define KEYBOARD_MASK (NX_COMMANDMASK | NX_CONTROLMASK | NX_ALTERNATEMASK | NX_SHIFTMASK | \
-                       NX_SECONDARYFNMASK | NX_ALPHASHIFTMASK | NX_NUMERICPADMASK | \
-                       NX_HELPMASK | NX_DEVICELCTLKEYMASK | NX_DEVICELSHIFTKEYMASK | \
-		       NX_DEVICERSHIFTKEYMASK | NX_DEVICELCMDKEYMASK | NX_DEVICERCMDKEYMASK | \
-		       NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK | NX_DEVICERCTLKEYMASK)
-                      
-char * decode_event_flags(unsigned int modifiers) {
-  char buf[1024];
-  buf[0]='\0';
-  if (modifiers & NX_DEVICELCTLKEYMASK)   strcat(buf, "NX_DEVICELCTLKEYMASK | ");
-  if (modifiers & NX_DEVICELSHIFTKEYMASK) strcat(buf, "NX_DEVICELSHIFTKEYMASK | ");
-  if (modifiers & NX_DEVICERSHIFTKEYMASK) strcat(buf, "NX_DEVICERSHIFTKEYMASK | ");
-  if (modifiers & NX_DEVICELCMDKEYMASK)   strcat(buf, "NX_DEVICELCMDKEYMASK | ");
-  if (modifiers & NX_DEVICERCMDKEYMASK)   strcat(buf, "NX_DEVICERCMDKEYMASK | ");
-  if (modifiers & NX_DEVICELALTKEYMASK)   strcat(buf, "NX_DEVICELALTKEYMASK | ");
-  if (modifiers & NX_DEVICERALTKEYMASK)   strcat(buf, "NX_DEVICERALTKEYMASK | ");
-  if (modifiers & NX_DEVICERCTLKEYMASK)   strcat(buf, "NX_DEVICERCTLKEYMASK | ");
-
-  if (modifiers & NX_ALPHASHIFTMASK)      strcat(buf, "NX_ALPHASHIFTMASK | ");
-  if (modifiers & NX_SHIFTMASK)           strcat(buf, "NX_SHIFTMASK | ");
-  if (modifiers & NX_CONTROLMASK)         strcat(buf, "NX_CONTROLMASK | ");
-  if (modifiers & NX_ALTERNATEMASK)       strcat(buf, "NX_ALTERNATEMASK | ");
-  if (modifiers & NX_COMMANDMASK)         strcat(buf, "NX_COMMANDMASK | ");
-  if (modifiers & NX_NUMERICPADMASK)      strcat(buf, "NX_NUMERICPADMASK | ");
-  if (modifiers & NX_HELPMASK)            strcat(buf, "NX_HELPMASK | ");
-  if (modifiers & NX_SECONDARYFNMASK)     strcat(buf, "NX_SECONDARYFNMASK | ");
-
-  if (modifiers & NX_STYLUSPROXIMITYMASK) strcat(buf, "NX_STYLUSPROXIMITYMASK | ");
-  if (modifiers & NX_NONCOALSESCEDMASK)   strcat(buf, "NX_NONCOALSESCEDMASK | ");
-  if (modifiers & NX_NULLEVENTMASK)       strcat(buf, "NX_NULLEVENTMASK | ");
-  //  if (modifiers & NX_LMOUSEDOWNMASK)      strcat(buf, "NX_LMOUSEDOWNMASK | ");
-  //  if (modifiers & NX_LMOUSEUPMASK)        strcat(buf, "NX_LMOUSEUPMASK | ");
-  //  if (modifiers & NX_RMOUSEDOWNMASK)      strcat(buf, "NX_RMOUSEDOWNMASK | ");
-  //  if (modifiers & NX_RMOUSEUPMASK)        strcat(buf, "NX_RMOUSEUPMASK | ");
-  //  if (modifiers & NX_OMOUSEDOWNMASK)      strcat(buf, "NX_OMOUSEDOWNMASK | ");
-  //  if (modifiers & NX_OMOUSEUPMASK)        strcat(buf, "NX_OMOUSEUPMASK | ");
-  //  if (modifiers & NX_MOUSEMOVEDMASK)      strcat(buf, "NX_MOUSEMOVEDMASK | ");
-  // if (modifiers & NX_LMOUSEDRAGGEDMASK)   strcat(buf, "NX_LMOUSEDRAGGEDMASK | ");
-  //if (modifiers & NX_RMOUSEDRAGGEDMASK)   strcat(buf, "NX_RMOUSEDRAGGEDMASK | ");
-  //if (modifiers & NX_OMOUSEDRAGGEDMASK)   strcat(buf, "NX_OMOUSEDRAGGEDMASK | ");
-  //if (modifiers & NX_MOUSEENTEREDMASK)    strcat(buf, "NX_MOUSEENTEREDMASK | ");
-  //if (modifiers & NX_MOUSEEXITEDMASK)     strcat(buf, "NX_MOUSEEXITEDMASK | ");
-  if (modifiers & NX_KEYDOWNMASK)         strcat(buf, "NX_KEYDOWNMASK | ");
-  if (modifiers & NX_KEYUPMASK)           strcat(buf, "NX_KEYUPMASK | ");
-  if (modifiers & NX_FLAGSCHANGEDMASK)    strcat(buf, "NX_FLAGSCHANGEDMASK | ");
-  if (modifiers & NX_KITDEFINEDMASK)      strcat(buf, "NX_KITDEFINEDMASK | ");
-  if (modifiers & NX_SYSDEFINEDMASK)      strcat(buf, "NX_SYSDEFINEDMASK | ");
-  if (modifiers & NX_APPDEFINEDMASK)      strcat(buf, "NX_APPDEFINEDMASK | ");
-  
-  if (strlen(buf) < 5) strcpy(buf, "(empty)");
-  else buf[strlen(buf)-3]='\0';
-  return strdup(buf);
-}
-
-char * get_keysym_name(int ks) {
-  switch(ks) {
-  case XK_Alt_L: return "XK_Alt_L";
-  case XK_Alt_R: return "XK_Alt_R";
-  case XK_Meta_L: return "XK_Meta_L";
-  case XK_Meta_R: return "XK_Meta_R";
-  case XK_Control_L: return "XK_Control_L";
-  case XK_Control_R: return "XK_Control_R";
-  case XK_Shift_L: return "XK_Shift_L";
-  case XK_Shift_R: return "XK_Shift_R";
-  case XK_Mode_switch: return "XK_Mode_switch";
-  case XK_Caps_Lock: return "XK_Caps_Lock";
-  }
-  return "???";
-}
-
-/*
- * DarwinPressModifierMask
- *  Press or release the given modifier key, specified by its mask.
- */
-static void DarwinPressModifierMask(
-    xEvent *xe,     // must already have type, time and mouse location
-    int mask)       // one of NX_*MASK constants
-{
-  int key, keycode;
-  key = DarwinModifierNXMaskToNXKey(mask);
-  if (key == -1) {
-    ErrorF("DarwinPressModifierMask: can't find key for mask %x\n", mask);
-    return;
-  }
-  keycode = DarwinModifierNXKeyToNXKeycode(key, 0);    
-  if (keycode == 0) {
-    ErrorF("DarwinPressModifierMask: can't find keycode for mask %x\n", mask);
-    return;
-  }
-  
-  DEBUG_LOG("%x: %s %s\n", mask, xe->u.u.type==KeyPress?"pressing":"releasing",
-	    decode_event_flags(mask));
-  
-  xe->u.u.detail = keycode + MIN_KEYCODE;
-  (*darwinEventQueue.pKbd->processInputProc)(xe,
-           (DeviceIntPtr)darwinEventQueue.pKbd, 1);
-}
-
 /*
  * DarwinUpdateModifiers
  *  Send events to update the modifier state.
  */
 static void DarwinUpdateModifiers(
-    xEvent *xe,         // event template with time and mouse position set
     int pressed,        // KeyPress or KeyRelease
-    unsigned int flags )         // modifier flags that have changed
+    int flags )         // modifier flags that have changed
 {
-  int i;
-  DEBUG_LOG("DarwinUpdateModifiers(%p, %d, %x, %s)\n", xe, pressed, flags, decode_event_flags(flags));
-  xe->u.u.type = pressed;
-  /* If we have "device specific" flags -- meaning, left or right -- then strip out the generic flag */
-  if (flags & (NX_DEVICELCTLKEYMASK | NX_DEVICERCTLKEYMASK)) flags &= ~NX_CONTROLMASK;
-  if (flags & (NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK)) flags &= ~NX_ALTERNATEMASK;
-  if (flags & (NX_DEVICELCMDKEYMASK | NX_DEVICERCMDKEYMASK)) flags &= ~NX_COMMANDMASK;
-  if (flags & (NX_DEVICELSHIFTKEYMASK | NX_DEVICERSHIFTKEYMASK)) flags &= ~NX_SHIFTMASK;
-  if (flags == NX_ALPHASHIFTMASK) {
-    // Alpha shift only sees KeyDown when enabled and KeyUp when disabled,
-    // but X11 wants to see a up/down pair to enable, and again to disable
-    xe->u.u.type = KeyPress;
-    DarwinPressModifierMask(xe, NX_ALPHASHIFTMASK);
-    xe->u.u.type = KeyRelease;
-    DarwinPressModifierMask(xe, NX_ALPHASHIFTMASK);
-    flags &= ~NX_ALPHASHIFTMASK;
-  }
-  for(i=0; i < (sizeof(flags)*8); i++) 
-    if (flags & (1 << i)) DarwinPressModifierMask(xe, flags & (1 << i));
+    if (flags & NX_ALPHASHIFTMASK) {
+        DarwinPressModifierMask(pressed, NX_ALPHASHIFTMASK);
+    }
+    if (flags & NX_COMMANDMASK) {
+        DarwinPressModifierMask(pressed, COMMAND_MASK(flags));
+    }
+    if (flags & NX_CONTROLMASK) {
+        DarwinPressModifierMask(pressed, CONTROL_MASK(flags));
+    }
+    if (flags & NX_ALTERNATEMASK) {
+        DarwinPressModifierMask(pressed, ALTERNATE_MASK(flags));
+    }
+    if (flags & NX_SHIFTMASK) {
+        DarwinPressModifierMask(pressed, SHIFT_MASK(flags));
+    }
+    if (flags & NX_SECONDARYFNMASK) {
+        DarwinPressModifierMask(pressed, NX_SECONDARYFNMASK);
+    }
 }
 
 /*
@@ -232,39 +153,8 @@ static void DarwinUpdateModifiers(
  * is deactivated (kXDarwinDeactivate) to prevent modifiers from getting stuck if they
  * are held down during a "context" switch -- otherwise, we would miss the KeyUp.
  */
-void DarwinReleaseModifiers(void) {
-  KeySym *map = NULL;
-  xEvent ke;
-  int i = 0; 
- 
-  DEBUG_LOG("DarwinReleaseModifiers(%p)\n", &keyInfo.keyMap);
-  
-  for (i = MIN_KEYCODE, map =keyInfo.keyMap;
-       i < MAX_KEYCODE;
-       i++, map += GLYPHS_PER_KEY) {
-    if (KeyPressed(i)) {
-      switch (*map) {
-	/* Don't release the lock keys */
-      case XK_Caps_Lock:
-      case XK_Shift_Lock:
-      case XK_Num_Lock:
-      case XK_Scroll_Lock:
-      case XK_Kana_Lock:
-	break;
-      default:
-	DEBUG_LOG("DarwinReleaseModifiers: releasing key %d (%s)\n", i, get_keysym_name(*map));
-	  ke.u.keyButtonPointer.time = GetTimeInMillis();
-	  ke.u.keyButtonPointer.rootX = 0;
-	  ke.u.keyButtonPointer.rootY = 0;
-	  ke.u.u.type = KeyRelease;
-	  ke.u.u.detail = i;
-	  (*darwinEventQueue.pKbd->processInputProc)(&ke,
-		    (DeviceIntPtr)darwinEventQueue.pKbd, 1);
-	break;
-      }
-    }
-  }
-  ProcessInputEvents();
+static void DarwinReleaseModifiers(void) {
+	DarwinUpdateModifiers(KeyRelease, COMMAND_MASK(-1) | CONTROL_MASK(-1) | ALTERNATE_MASK(-1) | SHIFT_MASK(-1));
 }
 
 /*
@@ -279,38 +169,36 @@ void DarwinReleaseModifiers(void) {
  *  simulate a button 2 press instead of Command-button 2.
  */
 static void DarwinSimulateMouseClick(
-    xEvent *xe,         // event template with time and
-                        // mouse position filled in
+    int pointer_x,
+    int pointer_y,
     int whichButton,    // mouse button to be pressed
     int modifierMask)   // modifiers used for the fake click
 {
-  DEBUG_LOG("DarwinSimulateMouseClick(%p, %d, %x)\n", xe, whichButton, modifierMask);
     // first fool X into forgetting about the keys
 	// for some reason, it's not enough to tell X we released the Command key -- 
 	// it has to be the *left* Command key.
 	if (modifierMask & NX_COMMANDMASK) modifierMask |=NX_DEVICELCMDKEYMASK ;
-    DarwinUpdateModifiers(xe, KeyRelease, modifierMask);
+    DarwinUpdateModifiers(KeyRelease, modifierMask);
 
     // push the mouse button
-    xe->u.u.type = ButtonPress;
-    xe->u.u.detail = whichButton;
-    (*darwinEventQueue.pPtr->processInputProc)
-            (xe, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
+    DarwinSendPointerEvents(ButtonPress, whichButton, pointer_x, pointer_y);
+    DarwinSendPointerEvents(ButtonRelease, whichButton, pointer_x, pointer_y);
+
+    // restore old modifiers
+    DarwinUpdateModifiers(KeyPress, modifierMask);
 }
 
 
-Bool
-DarwinEQInit(
-    DevicePtr pKbd,
-    DevicePtr pPtr)
-{
+Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr) { 
+    darwinEvents = (xEvent *)malloc(sizeof(xEvent) * GetMaximumEventsNum());
+    mieqInit();
     darwinEventQueue.head = darwinEventQueue.tail = 0;
     darwinEventQueue.lastEventTime = GetTimeInMillis ();
     darwinEventQueue.pKbd = pKbd;
     darwinEventQueue.pPtr = pPtr;
     darwinEventQueue.pEnqueueScreen = screenInfo.screens[0];
     darwinEventQueue.pDequeueScreen = darwinEventQueue.pEnqueueScreen;
-    SetInputCheck (&darwinEventQueue.head, &darwinEventQueue.tail);
+    SetInputCheck(&input_check_zero, &input_check_flag);
     return TRUE;
 }
 
@@ -321,11 +209,10 @@ DarwinEQInit(
  *    DarwinEQEnqueue    - called from event gathering thread
  *    ProcessInputEvents - called from X server thread
  *  DarwinEQEnqueue should never be called from more than one thread.
+ * 
+ * This should be deprecated in favor of miEQEnqueue -- BB
  */
-void
-DarwinEQEnqueue(
-    const xEvent *e)
-{
+void DarwinEQEnqueue(const xEvent *e) {
     HWEventQueueType oldtail, newtail;
     char byte = 0;
 
@@ -335,13 +222,12 @@ DarwinEQEnqueue(
     // This is difficult to do in a thread-safe way and rarely useful.
 
     newtail = oldtail + 1;
-    if (newtail == QUEUE_SIZE)
-        newtail = 0;
+    if (newtail == QUEUE_SIZE) newtail = 0;
     /* Toss events which come in late */
-    if (newtail == darwinEventQueue.head)
-        return;
+    if (newtail == darwinEventQueue.head) return;
 
     darwinEventQueue.events[oldtail].event = *e;
+
     /*
      * Make sure that event times don't go backwards - this
      * is "unnecessary", but very useful
@@ -358,7 +244,7 @@ DarwinEQEnqueue(
     darwinEventQueue.tail = newtail;
 
     // Signal there is an event ready to handle
-    write(darwinEventWriteFD, &byte, 1);
+    DarwinPokeEQ();
 }
 
 
@@ -366,20 +252,13 @@ DarwinEQEnqueue(
  * DarwinEQPointerPost
  *  Post a pointer event. Used by the mipointer.c routines.
  */
-void
-DarwinEQPointerPost(
-    xEvent *e)
-{
+void DarwinEQPointerPost(xEvent *e) {
     (*darwinEventQueue.pPtr->processInputProc)
             (e, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
 }
 
 
-void
-DarwinEQSwitchScreen(
-    ScreenPtr   pScreen,
-    Bool        fromDIX)
-{
+void DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX) {
     darwinEventQueue.pEnqueueScreen = pScreen;
     if (fromDIX)
         darwinEventQueue.pDequeueScreen = pScreen;
@@ -390,21 +269,21 @@ DarwinEQSwitchScreen(
  * ProcessInputEvents
  *  Read and process events from the event queue until it is empty.
  */
-void ProcessInputEvents(void)
-{
+void ProcessInputEvents(void) {
     EventRec *e;
     int     x, y;
     xEvent  xe;
     static int  old_flags = 0;  // last known modifier state
     // button number and modifier mask of currently pressed fake button
-    static int darwinFakeMouseButtonDown = 0;
-    static int darwinFakeMouseButtonMask = 0;
+    input_check_flag=0;
+
+    //    ErrorF("calling mieqProcessInputEvents\n");
+    mieqProcessInputEvents();
 
     // Empty the signaling pipe
     x = sizeof(xe);
-    while (x == sizeof(xe)) {
+    while (x == sizeof(xe)) 
         x = read(darwinEventReadFD, &xe, sizeof(xe));
-    }
 
     while (darwinEventQueue.head != darwinEventQueue.tail)
     {
@@ -420,10 +299,16 @@ void ProcessInputEvents(void)
                 dixScreenOrigins[miPointerCurrentScreen()->myNum].x;
         xe.u.keyButtonPointer.rootY -= darwinMainScreenY +
                 dixScreenOrigins[miPointerCurrentScreen()->myNum].y;
+	
+	/*	ErrorF("old rootX = (%d,%d) darwinMainScreen = (%d,%d) dixScreenOrigins[%d]=(%d,%d)\n",
+	       xe.u.keyButtonPointer.rootX, xe.u.keyButtonPointer.rootY,
+	       darwinMainScreenX, darwinMainScreenY,
+	       miPointerCurrentScreen()->myNum,
+	       dixScreenOrigins[miPointerCurrentScreen()->myNum].x,
+	       dixScreenOrigins[miPointerCurrentScreen()->myNum].y); */
+
+	//Assumption - screen switching can only occur on motion events
 
-        /*
-         * Assumption - screen switching can only occur on motion events
-         */
         if (e->pScreen != darwinEventQueue.pDequeueScreen)
         {
             darwinEventQueue.pDequeueScreen = e->pScreen;
@@ -441,164 +326,39 @@ void ProcessInputEvents(void)
                 darwinEventQueue.head = 0;
             else
                 ++darwinEventQueue.head;
-            switch (xe.u.u.type)
-            {
+            switch (xe.u.u.type) {
             case KeyPress:
-                if (old_flags == 0
-                    && darwinSyncKeymap && darwinKeymapFile == NULL)
-                {
-                    /* See if keymap has changed. */
-
-                    static unsigned int last_seed;
-                    unsigned int this_seed;
-
-                    this_seed = DarwinModeSystemKeymapSeed();
-                    if (this_seed != last_seed)
-                    {
-                        last_seed = this_seed;
-                        DarwinKeyboardReload(darwinKeyboard);
-                    }
-                }
-                /* fall through */
-
             case KeyRelease:
-                xe.u.u.detail += MIN_KEYCODE;
-                (*darwinEventQueue.pKbd->processInputProc)
-                    (&xe, (DeviceIntPtr)darwinEventQueue.pKbd, 1);
-                break;
+	      ErrorF("Unexpected Keyboard event in DarwinProcessInputEvents\n");
+	      break;
 
             case ButtonPress:
-                miPointerAbsoluteCursor(xe.u.keyButtonPointer.rootX,
-                                        xe.u.keyButtonPointer.rootY,
-                                        xe.u.keyButtonPointer.time);
-                if (darwinFakeButtons && xe.u.u.detail == 1) {
-                    // Mimic multi-button mouse with modifier-clicks
-                    // If both sets of modifiers are pressed,
-                    // button 2 is clicked.
-                    if ((old_flags & darwinFakeMouse2Mask) ==
-                        darwinFakeMouse2Mask)
-                    {
-                        DarwinSimulateMouseClick(&xe, 2, darwinFakeMouse2Mask);
-                        darwinFakeMouseButtonDown = 2;
-                        darwinFakeMouseButtonMask = darwinFakeMouse2Mask;
-                        break;
-                    }
-                    else if ((old_flags & darwinFakeMouse3Mask) ==
-                             darwinFakeMouse3Mask)
-                    {
-                        DarwinSimulateMouseClick(&xe, 3, darwinFakeMouse3Mask);
-                        darwinFakeMouseButtonDown = 3;
-                        darwinFakeMouseButtonMask = darwinFakeMouse3Mask;
-                        break;
-                    }
-                }
-                (*darwinEventQueue.pPtr->processInputProc)
-                        (&xe, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
+	      ErrorF("Unexpected ButtonPress event in DarwinProcessInputEvents\n");
                 break;
 
             case ButtonRelease:
-                miPointerAbsoluteCursor(xe.u.keyButtonPointer.rootX,
-                                        xe.u.keyButtonPointer.rootY,
-                                        xe.u.keyButtonPointer.time);
-                if (darwinFakeButtons && xe.u.u.detail == 1 &&
-                    darwinFakeMouseButtonDown)
-                {
-                    // If last mousedown was a fake click, don't check for
-                    // mouse modifiers here. The user may have released the
-                    // modifiers before the mouse button.
-                    xe.u.u.detail = darwinFakeMouseButtonDown;
-                    darwinFakeMouseButtonDown = 0;
-                    (*darwinEventQueue.pPtr->processInputProc)
-                            (&xe, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
-
-                    // Bring modifiers back up to date
-                    DarwinUpdateModifiers(&xe, KeyPress,
-                            darwinFakeMouseButtonMask & old_flags);
-                    darwinFakeMouseButtonMask = 0;
-                } else {
-                    (*darwinEventQueue.pPtr->processInputProc)
-                            (&xe, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
-                }
+	      ErrorF("Unexpected ButtonRelease event in DarwinProcessInputEvents\n");
                 break;
 
             case MotionNotify:
-                miPointerAbsoluteCursor(xe.u.keyButtonPointer.rootX,
-                                        xe.u.keyButtonPointer.rootY,
-                                        xe.u.keyButtonPointer.time);
+	      ErrorF("Unexpected ButtonRelease event in DarwinProcessInputEvents\n");
                 break;
 
             case kXDarwinUpdateModifiers:
-            {
-                // Update modifier state.
-                // Any amount of modifiers may have changed.
-	      unsigned int flags = xe.u.clientMessage.u.l.longs0 & ~NX_NONCOALSESCEDMASK; // ignore that one
-		DEBUG_LOG("kxDarwinUpdateModifiers(%x, %x, %s)\n", old_flags, flags, decode_event_flags(flags));
-		//		DEBUG_LOG("Ignoring these flags: %x %s\n", flags & ~KEYBOARD_MASK, decode_event_flags(flags & ~KEYBOARD_MASK));
-		flags &= KEYBOARD_MASK;
-                if (old_flags & ~flags) DarwinUpdateModifiers(&xe, KeyRelease,
-							      old_flags & ~flags);
-                if (~old_flags & flags) DarwinUpdateModifiers(&xe, KeyPress,
-							      ~old_flags & flags);
-                old_flags = flags;
-                break;
-            }
+	      ErrorF("Unexpected ButtonRelease event in DarwinProcessInputEvents\n");
+	      break;
 
             case kXDarwinUpdateButtons:
-            {
-                long hwDelta = xe.u.clientMessage.u.l.longs0;
-                long hwButtons = xe.u.clientMessage.u.l.longs1;
-                int i;
-
-                for (i = 1; i < 5; i++) {
-                    if (hwDelta & (1 << i)) {
-                        // IOKit and X have different numbering for the
-                        // middle and right mouse buttons.
-                        if (i == 1) {
-                            xe.u.u.detail = 3;
-                        } else if (i == 2) {
-                            xe.u.u.detail = 2;
-                        } else {
-                            xe.u.u.detail = i + 1;
-                        }
-                        if (hwButtons & (1 << i)) {
-                            xe.u.u.type = ButtonPress;
-                        } else {
-                            xe.u.u.type = ButtonRelease;
-                        }
-                        (*darwinEventQueue.pPtr->processInputProc)
-                    (&xe, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
-                    }
-                }
-                break;
-            }
+	      ErrorF("Unexpected XDarwinScrollWheel event in DarwinProcessInputEvents\n");
+	      break;
 
-            case kXDarwinScrollWheel:
-            {
-                short count = xe.u.clientMessage.u.s.shorts0;
-
-                if (count > 0) {
-                    xe.u.u.detail = SCROLLWHEELUPFAKE;
-                } else {
-                    xe.u.u.detail = SCROLLWHEELDOWNFAKE;
-                    count = -count;
-                }
-
-                for (; count; --count) {
-                    xe.u.u.type = ButtonPress;
-                    (*darwinEventQueue.pPtr->processInputProc)
-                            (&xe, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
-                    xe.u.u.type = ButtonRelease;
-                    (*darwinEventQueue.pPtr->processInputProc)
-                            (&xe, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
-                }
-                break;
-            }
+            case kXDarwinScrollWheel: 
+	      ErrorF("Unexpected XDarwinScrollWheel event in DarwinProcessInputEvents\n");
+	      break;
 
-	    case kXDarwinDeactivate:
-	      DEBUG_LOG("kxDarwinDeactivate\n");
-	      DarwinReleaseModifiers();
-	      old_flags=0;
-	      // fall through
+			case kXDarwinDeactivate:
+				DarwinReleaseModifiers();
+				// fall through
             default:
                 // Check for mode specific event
                 DarwinModeProcessEvent(&xe);
@@ -606,5 +366,96 @@ void ProcessInputEvents(void)
         }
     }
 
-    miPointerUpdate();
+    //    miPointerUpdate();
+}
+
+/* Sends a null byte down darwinEventWriteFD, which will cause the
+   Dispatch() event loop to check out event queue */
+void DarwinPokeEQ(void) {
+  char nullbyte=0;
+  input_check_flag++;
+  //  <daniels> bushing: oh, i ... er ... christ.
+  write(darwinEventWriteFD, &nullbyte, 1);
+}
+
+void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int pointer_y) {
+  static int darwinFakeMouseButtonDown = 0;
+  static int darwinFakeMouseButtonMask = 0;
+  int i, num_events;
+  int valuators[2] = {pointer_x, pointer_y};
+  if (ev_type == ButtonPress && darwinFakeButtons && ev_button == 1) {
+    // Mimic multi-button mouse with modifier-clicks
+    // If both sets of modifiers are pressed,
+    // button 2 is clicked.
+    if ((old_flags & darwinFakeMouse2Mask) == darwinFakeMouse2Mask) {
+      DarwinSimulateMouseClick(pointer_x, pointer_y, 2, darwinFakeMouse2Mask);
+      darwinFakeMouseButtonDown = 2;
+      darwinFakeMouseButtonMask = darwinFakeMouse2Mask;
+    } else if ((old_flags & darwinFakeMouse3Mask) == darwinFakeMouse3Mask) {
+      DarwinSimulateMouseClick(pointer_x, pointer_y, 3, darwinFakeMouse3Mask);
+      darwinFakeMouseButtonDown = 3;
+      darwinFakeMouseButtonMask = darwinFakeMouse3Mask;
+    }
+  }
+  if (ev_type == ButtonRelease && darwinFakeButtons && darwinFakeMouseButtonDown) {
+    // If last mousedown was a fake click, don't check for
+    // mouse modifiers here. The user may have released the
+    // modifiers before the mouse button.
+    ev_button = darwinFakeMouseButtonDown;
+    darwinFakeMouseButtonDown = 0;
+    // Bring modifiers back up to date
+    DarwinUpdateModifiers(KeyPress, darwinFakeMouseButtonMask & old_flags);
+    darwinFakeMouseButtonMask = 0;
+  } 
+
+  num_events = GetPointerEvents(darwinEvents, darwinPointer, ev_type, ev_button, 
+				POINTER_ABSOLUTE, 0, 2, valuators);
+      
+  for(i=0; i<num_events; i++) mieqEnqueue (darwinPointer,&darwinEvents[i]);
+  DarwinPokeEQ();
+}
+
+void DarwinSendKeyboardEvents(int ev_type, int keycode) {
+  int i, num_events;
+  if (old_flags == 0 && darwinSyncKeymap && darwinKeymapFile == NULL) {
+    /* See if keymap has changed. */
+
+    static unsigned int last_seed;
+    unsigned int this_seed;
+
+    this_seed = DarwinModeSystemKeymapSeed();
+    if (this_seed != last_seed) {
+      last_seed = this_seed;
+      DarwinKeyboardReload(darwinKeyboard);
+    }
+  }
+
+  num_events = GetKeyboardEvents(darwinEvents, darwinKeyboard, ev_type, keycode + MIN_KEYCODE);
+  for(i=0; i<num_events; i++) mieqEnqueue(darwinKeyboard,&darwinEvents[i]);
+  DarwinPokeEQ();
+}
+
+/* Send the appropriate number of button 4 / 5 clicks to emulate scroll wheel */
+void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y) {
+  int i;
+  int ev_button = count > 0.0f ? 4 : 5;
+  int valuators[2] = {pointer_x, pointer_y};
+
+  for (count = fabs(count); count > 0.0; count = count - 1.0f) {
+    int num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonPress, ev_button, 
+				      POINTER_ABSOLUTE, 0, 2, valuators);
+    for(i=0; i<num_events; i++) mieqEnqueue(darwinPointer,&darwinEvents[i]);
+    num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonRelease, ev_button, 
+				      POINTER_ABSOLUTE, 0, 2, valuators);
+    for(i=0; i<num_events; i++) mieqEnqueue(darwinPointer,&darwinEvents[i]);
+  }
+  DarwinPokeEQ();
+}
+
+/* Send the appropriate KeyPress/KeyRelease events to GetKeyboardEvents to
+   reflect changing modifier flags (alt, control, meta, etc) */
+void DarwinUpdateModKeys(int flags) {
+  DarwinUpdateModifiers(KeyRelease, old_flags & ~flags);
+  DarwinUpdateModifiers(KeyPress, ~old_flags & flags);
+  old_flags = flags;
 }
commit 9c6d8a035b712b219833653ac637b89703a9b0c3
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Mon Nov 26 13:04:57 2007 -0800

    Darwin,Rootless: Makefile cleanup

diff --git a/GL/apple/Makefile.am b/GL/apple/Makefile.am
index 411dfdf..f1e02cc 100644
--- a/GL/apple/Makefile.am
+++ b/GL/apple/Makefile.am
@@ -1,12 +1,14 @@
-AM_CFLAGS = -I$(top_srcdir) \
-	 -I$(top_srcdir)/GL/glx \
-	 -I$(top_srcdir)/GL/include \
-	 -I$(top_srcdir)/GL/mesa/glapi \
-	 -I$(top_srcdir)/hw/darwin/quartz \
-	 -I$(top_srcdir)/hw/darwin/quartz/xpr \
-	 -I$(top_srcdir)/miext/damage \
-	 $(PIXMAN_CFLAGS)
+AM_CFLAGS = $(DIX_CFLAGS)
+AM_CPPFLAGS = \
+	-I$(top_srcdir) \
+	-I$(top_srcdir)/GL/glx \
+	-I$(top_srcdir)/GL/include \
+	-I$(top_srcdir)/GL/mesa/glapi \
+	-I$(top_srcdir)/hw/darwin/quartz \
+	-I$(top_srcdir)/hw/darwin/quartz/xpr \
+	-I$(top_srcdir)/miext/damage
 
 noinst_LIBRARIES = libCGLcore.a 
-libCGLcore_a_SOURCES = indirect.c \
-		       $(top_srcdir)/hw/dmx/glxProxy/compsize.c
+libCGLcore_a_SOURCES = \
+	indirect.c \
+	$(top_srcdir)/hw/dmx/glxProxy/compsize.c
diff --git a/configure.ac b/configure.ac
index 2cad021..c7d78d4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2151,6 +2151,8 @@ hw/xgl/glxext/module/Makefile
 hw/xnest/Makefile
 hw/xwin/Makefile
 hw/darwin/Makefile
+hw/darwin/apple/Makefile
+hw/darwin/launcher/Makefile
 hw/darwin/quartz/Makefile
 hw/darwin/quartz/xpr/Makefile
 hw/darwin/utils/Makefile
diff --git a/hw/darwin/Makefile.am b/hw/darwin/Makefile.am
index 62cbecf..1faedcb 100644
--- a/hw/darwin/Makefile.am
+++ b/hw/darwin/Makefile.am
@@ -1,11 +1,16 @@
-AM_CFLAGS = $(XORG_CFLAGS) $(DIX_CFLAGS)
-AM_CPPFLAGS = $(XORG_INCS) \
+AM_CFLAGS = $(XSERVER_CFLAGS) $(DIX_CFLAGS)
+AM_CPPFLAGS = \
 	-DINXQUARTZ \
 	-DUSE_NEW_CLUT \
 	-DXFree86Server \
 	-I$(top_srcdir)/miext/rootless
 
-SUBDIRS = quartz utils
+if X11APP
+X11APP_SUBDIRS = apple launcher
+endif
+
+SUBDIRS = quartz utils $(X11APP_SUBDIRS)
+DIST_SUBDIRS = quartz utils apple launcher
 
 bin_PROGRAMS = Xquartz
 man1_MANS = Xquartz.man
@@ -26,7 +31,6 @@ Xquartz_LDADD = \
 	./quartz/libXquartz.a \
 	./quartz/xpr/libxpr.a \
 	$(top_builddir)/dix/dixfonts.lo \
-	$(top_builddir)/config/libconfig.a \
 	$(top_builddir)/dix/libdix.la \
 	$(top_builddir)/os/libos.la \
 	$(top_builddir)/dix/libxpstubs.la \
@@ -60,47 +64,8 @@ Xquartz_LDFLAGS =  \
 	-Wl,-framework,CoreAudio \
 	-Wl,-framework,IOKit
 
-if X11APP
-bin_SCRIPTS = x11app x11launcher
-
-x11app:
-	cd apple && xcodebuild CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" ARCHS="$(X11APP_ARCHS)"
-
-x11launcher:
-	cd launcher && xcodebuild CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" ARCHS="$(X11APP_ARCHS)"
-
-x11app-install:
-	cd apple && xcodebuild install DSTROOT=$(DESTDIR) INSTALL_PATH=$(prefix) DEPLOYMENT_LOCATION=YES SKIP_INSTALL=NO ARCHS="$(X11APP_ARCHS)"
-
-x11launcher-install:
-	cd launcher && xcodebuild install DSTROOT=$(DESTDIR) INSTALL_PATH=$(APPLE_APPLICATIONS_DIR) DEPLOYMENT_LOCATION=YES SKIP_INSTALL=NO ARCHS="$(X11APP_ARCHS)"
-
-x11app-clean:
-	rm -rf apple/build
-
-x11launcher-clean:
-	rm -rf launcher/build
-
-install-data-hook: x11app-install x11launcher-install
-clean-local: x11app-clean x11launcher-clean
-
-endif
-
 EXTRA_DIST = \
 	Xquartz.man \
 	darwinClut8.h \
 	darwin.h \
-	darwinKeyboard.h \
-	apple/Info.plist \
-	apple/X11.icns \
-	apple/bundle-main.c \
-	apple/English.lproj/InfoPlist.strings \
-	apple/English.lproj/Localizable.strings \
-	apple/English.lproj/main.nib/classes.nib \
-	apple/English.lproj/main.nib/info.nib \
-	apple/English.lproj/main.nib/keyedobjects.nib \
-	apple/X11.xcodeproj/project.pbxproj \
-	launcher/bundle-main.c \
-	launcher/Info.plist \
-	launcher/X11.icns \
-	launcher/X11.xcodeproj/project.pbxproj
+	darwinKeyboard.h
diff --git a/hw/darwin/apple/Makefile.am b/hw/darwin/apple/Makefile.am
new file mode 100644
index 0000000..02a2c25
--- /dev/null
+++ b/hw/darwin/apple/Makefile.am
@@ -0,0 +1,23 @@
+bin_SCRIPTS = x11app
+
+.PHONY: x11app
+
+x11app:
+	xcodebuild CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" ARCHS="$(X11APP_ARCHS)"
+
+install-data-hook:
+	xcodebuild install DSTROOT=$(DESTDIR) INSTALL_PATH=$(prefix) DEPLOYMENT_LOCATION=YES SKIP_INSTALL=NO ARCHS="$(X11APP_ARCHS)"
+
+clean-local:
+	rm -rf build
+
+EXTRA_DIST = \
+	Info.plist \
+	X11.icns \
+	bundle-main.c \
+	English.lproj/InfoPlist.strings \
+	English.lproj/Localizable.strings \
+	English.lproj/main.nib/classes.nib \
+	English.lproj/main.nib/info.nib \
+	English.lproj/main.nib/keyedobjects.nib \
+	X11.xcodeproj/project.pbxproj
diff --git a/hw/darwin/launcher/Makefile.am b/hw/darwin/launcher/Makefile.am
new file mode 100644
index 0000000..f2d9ede
--- /dev/null
+++ b/hw/darwin/launcher/Makefile.am
@@ -0,0 +1,18 @@
+bin_SCRIPTS = x11launcher
+
+.PHONY: x11launcher
+
+x11launcher:
+	xcodebuild CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" ARCHS="$(X11APP_ARCHS)"
+
+install-data-hook:
+	cd launcher && xcodebuild install DSTROOT=$(DESTDIR) INSTALL_PATH=$(APPLE_APPLICATIONS_DIR) DEPLOYMENT_LOCATION=YES SKIP_INSTALL=NO ARCHS="$(X11APP_ARCHS)"
+
+clean-local:
+	rm -rf build
+
+EXTRA_DIST = \
+	bundle-main.c \
+	Info.plist \
+	X11.icns \
+	X11.xcodeproj/project.pbxproj
diff --git a/hw/darwin/quartz/Makefile.am b/hw/darwin/quartz/Makefile.am
index 54e6c30..fe66429 100644
--- a/hw/darwin/quartz/Makefile.am
+++ b/hw/darwin/quartz/Makefile.am
@@ -1,8 +1,8 @@
 noinst_LIBRARIES = libXQuartz.a
 
-AM_CFLAGS = $(XORG_CFLAGS) $(DIX_CFLAGS)
-AM_OBJCFLAGS = $(XORG_CFLAGS) $(DIX_CFLAGS)
-AM_CPPFLAGS = $(XORG_INCS) \
+AM_CFLAGS = $(XSERVER_CFLAGS) $(DIX_CFLAGS)
+AM_OBJCFLAGS = $(XSERVER_CFLAGS) $(DIX_CFLAGS)
+AM_CPPFLAGS = \
 	-DHAS_KL_API \
 	-I$(srcdir) -I$(srcdir)/.. \
 	-I$(top_srcdir)/miext/rootless
diff --git a/hw/darwin/quartz/xpr/Makefile.am b/hw/darwin/quartz/xpr/Makefile.am
index 4fe6e23..f610f73 100644
--- a/hw/darwin/quartz/xpr/Makefile.am
+++ b/hw/darwin/quartz/xpr/Makefile.am
@@ -1,6 +1,6 @@
 noinst_LIBRARIES = libxpr.a
-AM_CFLAGS =  $(XORG_CFLAGS) $(DIX_CFLAGS)
-AM_CPPFLAGS = $(XORG_INCS) \
+AM_CFLAGS =  $(XSERVER_CFLAGS) $(DIX_CFLAGS)
+AM_CPPFLAGS = \
 	   -DHAVE_XORG_CONFIG_H \
 	   -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../.. \
 	   -I$(top_srcdir)/miext \
diff --git a/miext/rootless/Makefile.am b/miext/rootless/Makefile.am
index 8dae6d2..aa8528e 100644
--- a/miext/rootless/Makefile.am
+++ b/miext/rootless/Makefile.am
@@ -1,22 +1,19 @@
-AM_CFLAGS =  \
-	    $(DIX_CFLAGS) \
-	    $(XORG_CFLAGS)
-
-INCLUDES = -I$(top_srcdir)/hw/xfree86/os-support
+AM_CFLAGS = $(DIX_CFLAGS) $(XSERVER_CFLAGS)
+AM_CPPFLAGS = -I$(top_srcdir)/hw/xfree86/os-support
 
 SUBDIRS = safeAlpha accel
 
 noinst_LTLIBRARIES = librootless.la
 librootless_la_SOURCES = \
 	rootlessCommon.c \
-	rootlessCommon.h \
-	rootlessConfig.h \
 	rootlessGC.c \
-	rootless.h \
 	rootlessScreen.c \
 	rootlessValTree.c \
-	rootlessWindow.c \
-	rootlessWindow.h 
+	rootlessWindow.c
 
 EXTRA_DIST = \
-	README.txt
+	README.txt \
+	rootless.h \
+	rootlessCommon.h \
+	rootlessConfig.h \
+	rootlessWindow.h 
diff --git a/miext/rootless/accel/Makefile.am b/miext/rootless/accel/Makefile.am
index c49d5fb..ca41653 100644
--- a/miext/rootless/accel/Makefile.am
+++ b/miext/rootless/accel/Makefile.am
@@ -1,18 +1,15 @@
-AM_CFLAGS =  \
-	    $(DIX_CFLAGS) \
-	    $(XORG_CFLAGS)
-
-INCLUDES = -I$(srcdir)/.. -I$(top_srcdir)/hw/xfree86/os-support
-
+AM_CFLAGS = $(DIX_CFLAGS) $(XSERVER_CFLAGS)
+AM_CPPFLAGS = -I$(srcdir)/.. -I$(top_srcdir)/hw/xfree86/os-support
 
 noinst_LTLIBRARIES = librlAccel.la
-librlAccel_la_SOURCES = rlAccel.c \
-	             rlBlt.c \
-	             rlCopy.c \
-	             rlFill.c \
-	             rlFillRect.c \
-	             rlFillSpans.c \
-	             rlGlyph.c \
-	             rlSolid.c
+librlAccel_la_SOURCES = \
+	rlAccel.c \
+	rlBlt.c \
+	rlCopy.c \
+	rlFill.c \
+	rlFillRect.c \
+	rlFillSpans.c \
+	rlGlyph.c \
+	rlSolid.c
 
 EXTRA_DIST = rlAccel.h
diff --git a/miext/rootless/safeAlpha/Makefile.am b/miext/rootless/safeAlpha/Makefile.am
index 7592c18..d264393 100644
--- a/miext/rootless/safeAlpha/Makefile.am
+++ b/miext/rootless/safeAlpha/Makefile.am
@@ -1,12 +1,9 @@
-AM_CFLAGS = \
-	    $(DIX_CFLAGS) \
-            $(XORG_CFLAGS)
-
-INCLUDES = -I$(srcdir)/.. -I$(top_srcdir)/hw/xfree86/os-support
-
+AM_CFLAGS = $(DIX_CFLAGS) $(XSERVER_CFLAGS)
+AM_CPPFLAGS = -I$(srcdir)/.. -I$(top_srcdir)/hw/xfree86/os-support
 
 noinst_LTLIBRARIES = libsafeAlpha.la
-libsafeAlpha_la_SOURCES = safeAlphaPicture.c \
-		       safeAlphaWindow.c
+libsafeAlpha_la_SOURCES = \
+	safeAlphaPicture.c \
+	safeAlphaWindow.c
 
 EXTRA_DIST = safeAlpha.h
commit 78b053b8599f54d8abf5aaa2f4b3ff48e0bfb9bb
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Sat Nov 24 03:34:48 2007 -0800

    Darwin: Formatting cleanup

diff --git a/hw/darwin/quartz/X11Application.m b/hw/darwin/quartz/X11Application.m
index ae6f4bc..60d11c5 100644
--- a/hw/darwin/quartz/X11Application.m
+++ b/hw/darwin/quartz/X11Application.m
@@ -1,6 +1,6 @@
 /* X11Application.m -- subclass of NSApplication to multiplex events
  
- Copyright (c) 2002-2007 Apple Inc. All rights reserved.
+ Copyright (c) 2002-2007 Apple Inc.
  
  Permission is hereby granted, free of charge, to any person
  obtaining a copy of this software and associated documentation files
@@ -27,19 +27,17 @@
  promote the sale, use or other dealings in this Software without
  prior written authorization. */
 
-#include "../quartz/quartzCommon.h"
+#include "quartzCommon.h"
 
 #import "X11Application.h"
 #include <Carbon/Carbon.h>
 
 /* ouch! */
 #define BOOL X_BOOL
-//# include "Xproto.h"
 # include "darwin.h"
-# include "../quartz/quartz.h"
+# include "quartz.h"
 # define _APPLEWM_SERVER_
 # include "X11/extensions/applewm.h"
-//# include "X.h"
 # include "micmap.h"
 #undef BOOL
 
@@ -56,13 +54,15 @@ WindowPtr xprGetXWindowFromAppKit(int windowNumber); // xpr/xprFrame.c
 int X11EnableKeyEquivalents = TRUE;
 int quartzHasRoot = FALSE, quartzEnableRootless = TRUE;
 
-extern int darwinFakeButtons;
-extern Bool enable_stereo; 
+extern int darwinFakeButtons, input_check_flag;
+// extern Bool enable_stereo; 
+Bool enable_stereo;  //<-- this needs to go back to being an extern once glxCGL is fixed
+
+extern xEvent *darwinEvents;
 
 X11Application *X11App;
 
-#define ALL_KEY_MASKS (NSShiftKeyMask | NSControlKeyMask \
-| NSAlternateKeyMask | NSCommandKeyMask)
+#define ALL_KEY_MASKS (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask)
 
 @implementation X11Application
 
@@ -81,27 +81,21 @@ static void send_nsevent (NSEventType type, NSEvent *e);
  but is statically linked into this X server. */
 extern Bool QuartzModeBundleInit(void);
 
-static void
-init_ports (void)
-{
+static void init_ports (void) {
     kern_return_t r;
     NSPort *p;
 	
-    if (_port != MACH_PORT_NULL)
-		return;
+    if (_port != MACH_PORT_NULL) return;
 	
     r = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, &_port);
-    if (r != KERN_SUCCESS)
-		return;
+    if (r != KERN_SUCCESS) return;
 	
     p = [NSMachPort portWithMachPort:_port];
     [p setDelegate:NSApp];
     [p scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
 }
 
-static void
-message_kit_thread (SEL selector, NSObject *arg)
-{
+static void message_kit_thread (SEL selector, NSObject *arg) {
     message msg;
     kern_return_t r;
 	
@@ -116,29 +110,24 @@ message_kit_thread (SEL selector, NSObject *arg)
     msg.arg = [arg retain];
 	
     r = mach_msg (&msg.hdr, MACH_SEND_MSG, msg.hdr.msgh_size,
-				  0, MACH_PORT_NULL, 0, MACH_PORT_NULL);
+		  0, MACH_PORT_NULL, 0, MACH_PORT_NULL);
     if (r != KERN_SUCCESS)
-		fprintf (stderr, "%s: mach_msg failed: %x\n", __FUNCTION__, r);
+		ErrorF("%s: mach_msg failed: %x\n", __FUNCTION__, r);
 }
 
-- (void) handleMachMessage:(void *)_msg
-{
+- (void) handleMachMessage:(void *)_msg {
     message *msg = _msg;
 	
     [self performSelector:msg->selector withObject:msg->arg];
     [msg->arg release];
 }
 
-- (void) set_controller:obj
-{
-    if (_controller == nil)
-		_controller = [obj retain];
+- (void) set_controller:obj {
+    if (_controller == nil) _controller = [obj retain];
 }
 
-- (void) dealloc
-{
-    if (_controller != nil)
-		[_controller release];
+- (void) dealloc {
+    if (_controller != nil) [_controller release];
 	
     if (_port != MACH_PORT_NULL)
 		mach_port_deallocate (mach_task_self (), _port);
@@ -146,8 +135,7 @@ message_kit_thread (SEL selector, NSObject *arg)
     [super dealloc];
 }
 
-- (void) orderFrontStandardAboutPanel: (id) sender
-{
+- (void) orderFrontStandardAboutPanel: (id) sender {
     NSMutableDictionary *dict;
     NSDictionary *infoDict;
     NSString *tem;
@@ -160,57 +148,45 @@ message_kit_thread (SEL selector, NSObject *arg)
 	
     tem = [infoDict objectForKey:@"CFBundleShortVersionString"];
 	
-    [dict setObject:[NSString stringWithFormat:@"X11.app %@ - X.org X11R7.2",
-					 tem] forKey:@"ApplicationVersion"];
+    [dict setObject:[NSString stringWithFormat:@"X11.app %@ - X.org X11R7.3", tem] 
+	  forKey:@"ApplicationVersion"];
 	
     [self orderFrontStandardAboutPanelWithOptions: dict];
 }
 
-- (void) activateX:(BOOL)state
-{
+- (void) activateX:(BOOL)state {
     /* Create a TSM document that supports full Unicode input, and
 	 have it activated while X is active (unless using the old
 	 keymapping files) */
     static TSMDocumentID x11_document;
 	
-    if (state)
-    {
-		QuartzMessageServerThread (kXDarwinActivate, 0);
-		
-		if (!_x_active)
-		{
-			if (x11_document == 0 && darwinKeymapFile == NULL)
-			{
-				OSType types[1];
-				types[0] = kUnicodeDocument;
-				NewTSMDocument (1, types, &x11_document, 0);
-			}
-			
-			if (x11_document != 0)
-				ActivateTSMDocument (x11_document);
-		}
-    }
-    else
-    {
-		QuartzMessageServerThread (kXDarwinDeactivate, 0);
-		
-		if (_x_active)
-		{
-			if (x11_document != 0)
-				DeactivateTSMDocument (x11_document);
-		}
-    }
+    if (state) {
+      QuartzMessageServerThread (kXDarwinActivate, 0);
+      
+      if (!_x_active) {
+	if (x11_document == 0 && darwinKeymapFile == NULL) {
+	  OSType types[1];
+	  types[0] = kUnicodeDocument;
+	  NewTSMDocument (1, types, &x11_document, 0);
+	}
 	
+	if (x11_document != 0)	ActivateTSMDocument (x11_document);
+      }
+    } else {
+      QuartzMessageServerThread (kXDarwinDeactivate, 0);
+      
+      if (_x_active && x11_document != 0)
+	DeactivateTSMDocument (x11_document);
+    }
+    
     _x_active = state;
 }
 
-- (void) became_key:(NSWindow *)win
-{
+- (void) became_key:(NSWindow *)win {
     [self activateX:NO];
 }
 
-- (void) sendEvent:(NSEvent *)e
-{
+- (void) sendEvent:(NSEvent *)e {
   NSEventType type;
   BOOL for_appkit, for_x;
   
@@ -242,44 +218,44 @@ message_kit_thread (SEL selector, NSObject *arg)
       }
     }
     break;
-		
-    case NSKeyDown: case NSKeyUp:
-      if (_x_active) {
-	static int swallow_up;
-	
-	/* No kit window is focused, so send it to X. */
-	for_appkit = NO;
-	if (type == NSKeyDown) {
-	  /* Before that though, see if there are any global
-	     shortcuts bound to it. */
-	  
-	  if (X11EnableKeyEquivalents
-	      && [[self mainMenu] performKeyEquivalent:e]) {
-	    swallow_up = [e keyCode];
-	    for_x = NO;
-	  } else if (!quartzEnableRootless
-		     && ([e modifierFlags] & ALL_KEY_MASKS)
-		     == (NSCommandKeyMask | NSAlternateKeyMask)
-		     && ([e keyCode] == 0 /*a*/
-		      || [e keyCode] == 53 /*Esc*/)) {
-	    swallow_up = 0;
-	    for_x = NO;
+      
+  case NSKeyDown: case NSKeyUp:
+    if (_x_active) {
+      static int swallow_up;
+      
+      /* No kit window is focused, so send it to X. */
+      for_appkit = NO;
+      if (type == NSKeyDown) {
+	/* Before that though, see if there are any global
+	   shortcuts bound to it. */
+	
+	if (X11EnableKeyEquivalents
+	    && [[self mainMenu] performKeyEquivalent:e]) {
+	  swallow_up = [e keyCode];
+	  for_x = NO;
+	} else if (!quartzEnableRootless
+		   && ([e modifierFlags] & ALL_KEY_MASKS)
+		   == (NSCommandKeyMask | NSAlternateKeyMask)
+		   && ([e keyCode] == 0 /*a*/
+		    || [e keyCode] == 53 /*Esc*/)) {
+	  swallow_up = 0;
+	  for_x = NO;
 #ifdef DARWIN_DDX_MISSING
-	    QuartzMessageServerThread (kXDarwinToggleFullscreen, 0);
+	  QuartzMessageServerThread (kXDarwinToggleFullscreen, 0);
 #endif
-	  }
-	} else  {
-	  /* If we saw a key equivalent on the down, don't pass
-	     the up through to X. */
-	  
-	  if (swallow_up != 0 && [e keyCode] == swallow_up) {
-	    swallow_up = 0;
-	    for_x = NO;
-	  }
 	}
-      } else for_x = NO;
-      break;
-      
+      } else {
+	/* If we saw a key equivalent on the down, don't pass
+	   the up through to X. */
+	
+	if (swallow_up != 0 && [e keyCode] == swallow_up) {
+	  swallow_up = 0;
+	  for_x = NO;
+	}
+      }
+    } else for_x = NO;
+    break;
+    
   case NSFlagsChanged:
     /* For the l33t X users who remap modifier keys to normal keysyms. */
     if (!_x_active) for_x = NO;
@@ -295,16 +271,16 @@ message_kit_thread (SEL selector, NSObject *arg)
 	/* FIXME: hack to avoid having to pass the event to appkit,
 	   which would cause it to raise one of its windows. */
 	_appFlags._active = YES;
-	    
+	
 	[self activateX:YES];
 	if ([e data2] & 0x10) X11ApplicationSetFrontProcess();
       }
       break;
-	
-      case 18: /* ApplicationDidReactivate */
-	if (quartzHasRoot) for_appkit = NO;
-	break;
-	
+      
+    case 18: /* ApplicationDidReactivate */
+      if (quartzHasRoot) for_appkit = NO;
+      break;
+      
     case NSApplicationDeactivatedEventType:
       for_x = NO;
       [self activateX:NO];
@@ -320,42 +296,36 @@ message_kit_thread (SEL selector, NSObject *arg)
   if (for_x) send_nsevent (type, e);
 }
 
-- (void) set_window_menu:(NSArray *)list
-{
+- (void) set_window_menu:(NSArray *)list {
     [_controller set_window_menu:list];
 }
 
-- (void) set_window_menu_check:(NSNumber *)n
-{
+- (void) set_window_menu_check:(NSNumber *)n {
     [_controller set_window_menu_check:n];
 }
 
-- (void) set_apps_menu:(NSArray *)list
-{
+- (void) set_apps_menu:(NSArray *)list {
     [_controller set_apps_menu:list];
 }
 
-- (void) set_front_process:unused
-{
+- (void) set_front_process:unused {
+    [NSApp activateIgnoringOtherApps:YES];
+	
+    if ([self modalWindow] == nil) [self activateX:YES];
     QuartzMessageServerThread(kXDarwinBringAllToFront, 0);
 }
 
-- (void) set_can_quit:(NSNumber *)state
-{
+- (void) set_can_quit:(NSNumber *)state {
     [_controller set_can_quit:[state boolValue]];
 }
 
-- (void) server_ready:unused
-{
+- (void) server_ready:unused {
     [_controller server_ready];
 }
 
-- (void) show_hide_menubar:(NSNumber *)state
-{
-    if ([state boolValue])
-		ShowMenuBar ();
-    else
-		HideMenuBar ();
+- (void) show_hide_menubar:(NSNumber *)state {
+    if ([state boolValue]) ShowMenuBar ();
+    else HideMenuBar ();
 }
 
 
@@ -372,9 +342,7 @@ static void cfrelease (CFAllocatorRef a, const void *b) {
     CFRelease (b);
 }
 
-static CFMutableArrayRef
-nsarray_to_cfarray (NSArray *in)
-{
+static CFMutableArrayRef nsarray_to_cfarray (NSArray *in) {
     CFMutableArrayRef out;
     CFArrayCallBacks cb;
     NSObject *ns;
@@ -389,24 +357,22 @@ nsarray_to_cfarray (NSArray *in)
     count = [in count];
     out = CFArrayCreateMutable (NULL, count, &cb);
 	
-    for (i = 0; i < count; i++)
-    {
-		ns = [in objectAtIndex:i];
-		
-		if ([ns isKindOfClass:[NSArray class]])
-			cf = (CFTypeRef) nsarray_to_cfarray ((NSArray *) ns);
-		else
-			cf = CFRetain ((CFTypeRef) ns);
-		
-		CFArrayAppendValue (out, cf);
-		CFRelease (cf);
+    for (i = 0; i < count; i++) {
+      ns = [in objectAtIndex:i];
+      
+      if ([ns isKindOfClass:[NSArray class]])
+	cf = (CFTypeRef) nsarray_to_cfarray ((NSArray *) ns);
+      else
+	cf = CFRetain ((CFTypeRef) ns);
+      
+      CFArrayAppendValue (out, cf);
+      CFRelease (cf);
     }
-	
+    
     return out;
 }
-static NSMutableArray *
-cfarray_to_nsarray (CFArrayRef in)
-{
+
+static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
     NSMutableArray *out;
     const CFTypeRef *cf;
     NSObject *ns;
@@ -415,257 +381,219 @@ cfarray_to_nsarray (CFArrayRef in)
     count = CFArrayGetCount (in);
     out = [[NSMutableArray alloc] initWithCapacity:count];
 	
-    for (i = 0; i < count; i++)
-    {
-		cf = CFArrayGetValueAtIndex (in, i);
-		
-		if (CFGetTypeID (cf) == CFArrayGetTypeID ())
-			ns = cfarray_to_nsarray ((CFArrayRef) cf);
-		else
-			ns = [(id)cf retain];
+    for (i = 0; i < count; i++) {
+      cf = CFArrayGetValueAtIndex (in, i);
 		
-		[out addObject:ns];
-		[ns release];
+      if (CFGetTypeID (cf) == CFArrayGetTypeID ())
+	ns = cfarray_to_nsarray ((CFArrayRef) cf);
+      else
+	ns = [(id)cf retain];
+      
+      [out addObject:ns];
+      [ns release];
     }
-	
+    
     return out;
 }
 
-- (CFPropertyListRef) prefs_get:(NSString *)key
-{
+- (CFPropertyListRef) prefs_get:(NSString *)key {
     CFPropertyListRef value;
 	
     value = CFPreferencesCopyAppValue ((CFStringRef) key, CFSTR (APP_PREFS));
 	
-    if (value == NULL)
-    {
-		static CFDictionaryRef defaults;
-		
-		if (defaults == NULL)
-		{
-			CFStringRef error = NULL;
-			CFDataRef data;
-			CFURLRef url;
-			SInt32 error_code;
-			
-			url = (CFURLCreateFromFileSystemRepresentation
-				   (NULL, (unsigned char *)DEFAULTS_FILE, strlen (DEFAULTS_FILE), false));
-			if (CFURLCreateDataAndPropertiesFromResource (NULL, url, &data,
-														  NULL, NULL,
-														  &error_code))
-			{
-				defaults = (CFPropertyListCreateFromXMLData
-							(NULL, data, kCFPropertyListMutableContainersAndLeaves, &error));
-				if (error != NULL)
-					CFRelease (error);
-				CFRelease (data);
-			}
-			CFRelease (url);
+    if (value == NULL) {
+      static CFDictionaryRef defaults;
+      
+      if (defaults == NULL) {
+	CFStringRef error = NULL;
+	CFDataRef data;
+	CFURLRef url;
+	SInt32 error_code;
+	
+	url = (CFURLCreateFromFileSystemRepresentation
+	       (NULL, (unsigned char *)DEFAULTS_FILE, strlen (DEFAULTS_FILE), false));
+	if (CFURLCreateDataAndPropertiesFromResource (NULL, url, &data,
+						      NULL, NULL, &error_code)) {
+	  defaults = (CFPropertyListCreateFromXMLData
+		      (NULL, data, kCFPropertyListMutableContainersAndLeaves, &error));
+	  if (error != NULL) CFRelease (error);
+	  CFRelease (data);
+	}
+	CFRelease (url);
 			
-			if (defaults != NULL)
-			{
-				NSMutableArray *apps, *elt;
-				int count, i;
-				NSString *name, *nname;
-				
-				/* Localize the names in the default apps menu. */
-				
-				apps = [(NSDictionary *)defaults objectForKey:@PREFS_APPSMENU];
-				if (apps != nil)
-				{
-					count = [apps count];
-					for (i = 0; i < count; i++)
-					{
-						elt = [apps objectAtIndex:i];
-						if (elt != nil && [elt isKindOfClass:[NSArray class]])
-						{
-							name = [elt objectAtIndex:0];
-							if (name != nil)
-							{
-								nname = NSLocalizedString (name, nil);
-								if (nname != nil && nname != name)
-									[elt replaceObjectAtIndex:0 withObject:nname];
-							}
-						}
-					}
-				}
-			}
+	if (defaults != NULL) {
+	  NSMutableArray *apps, *elt;
+	  int count, i;
+	  NSString *name, *nname;
+	  
+	  /* Localize the names in the default apps menu. */
+	  
+	  apps = [(NSDictionary *)defaults objectForKey:@PREFS_APPSMENU];
+	  if (apps != nil) {
+	    count = [apps count];
+	    for (i = 0; i < count; i++)	{
+	      elt = [apps objectAtIndex:i];
+	      if (elt != nil && [elt isKindOfClass:[NSArray class]]) {
+		name = [elt objectAtIndex:0];
+		if (name != nil) {
+		  nname = NSLocalizedString (name, nil);
+		  if (nname != nil && nname != name)
+		    [elt replaceObjectAtIndex:0 withObject:nname];
 		}
+	      }
+	    }
+	  }
+	}
+      }
 		
-		if (defaults != NULL)
-			value = CFDictionaryGetValue (defaults, key);
-		
-		if (value != NULL)
-			CFRetain (value);
+      if (defaults != NULL) value = CFDictionaryGetValue (defaults, key);
+      if (value != NULL) CFRetain (value);
     }
 	
     return value;
 }
 
-- (int) prefs_get_integer:(NSString *)key default:(int)def
-{
-    CFPropertyListRef value;
-    int ret;
-	
-    value = [self prefs_get:key];
-	
-    if (value != NULL && CFGetTypeID (value) == CFNumberGetTypeID ())
-		CFNumberGetValue (value, kCFNumberIntType, &ret);
-    else if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ())
-		ret = CFStringGetIntValue (value);
-    else
-		ret = def;
-	
-    if (value != NULL)
-		CFRelease (value);
-	
-    return ret;
+- (int) prefs_get_integer:(NSString *)key default:(int)def {
+  CFPropertyListRef value;
+  int ret;
+  
+  value = [self prefs_get:key];
+  
+  if (value != NULL && CFGetTypeID (value) == CFNumberGetTypeID ())
+    CFNumberGetValue (value, kCFNumberIntType, &ret);
+  else if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ())
+    ret = CFStringGetIntValue (value);
+  else
+    ret = def;
+  
+  if (value != NULL) CFRelease (value);
+  
+  return ret;
 }
 
-- (const char *) prefs_get_string:(NSString *)key default:(const char *)def
-{
-    CFPropertyListRef value;
-    const char *ret = NULL;
-	
-    value = [self prefs_get:key];
-	
-    if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ())
-    {
-		NSString *s = (NSString *) value;
-		
-		ret = [s UTF8String];
-    }
-	
-    if (value != NULL)
-		CFRelease (value);
-	
-    return ret != NULL ? ret : def;
+- (const char *) prefs_get_string:(NSString *)key default:(const char *)def {
+  CFPropertyListRef value;
+  const char *ret = NULL;
+  
+  value = [self prefs_get:key];
+  
+  if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ()) {
+    NSString *s = (NSString *) value;
+    
+    ret = [s UTF8String];
+  }
+  
+  if (value != NULL) CFRelease (value);
+  
+  return ret != NULL ? ret : def;
 }
 
-- (float) prefs_get_float:(NSString *)key default:(float)def
-{
-    CFPropertyListRef value;
-    float ret = def;
-	
-    value = [self prefs_get:key];
-	
-    if (value != NULL
-		&& CFGetTypeID (value) == CFNumberGetTypeID ()
-		&& CFNumberIsFloatType (value))
-    {
-		CFNumberGetValue (value, kCFNumberFloatType, &ret);
-    }
-    else if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ())
-    {
-		ret = CFStringGetDoubleValue (value);
-    }
-	
-    if (value != NULL)
-		CFRelease (value);
-	
-    return ret;
+- (float) prefs_get_float:(NSString *)key default:(float)def {
+  CFPropertyListRef value;
+  float ret = def;
+  
+  value = [self prefs_get:key];
+  
+  if (value != NULL
+      && CFGetTypeID (value) == CFNumberGetTypeID ()
+      && CFNumberIsFloatType (value)) 
+    CFNumberGetValue (value, kCFNumberFloatType, &ret);
+  else if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ())
+    ret = CFStringGetDoubleValue (value);
+	
+  if (value != NULL) CFRelease (value);
+  
+  return ret;
 }
 
-- (int) prefs_get_boolean:(NSString *)key default:(int)def
-{
-    CFPropertyListRef value;
-    int ret = def;
-	
-    value = [self prefs_get:key];
-	
-    if (value != NULL)
-    {
-		if (CFGetTypeID (value) == CFNumberGetTypeID ())
-			CFNumberGetValue (value, kCFNumberIntType, &ret);
-		else if (CFGetTypeID (value) == CFBooleanGetTypeID ())
-			ret = CFBooleanGetValue (value);
-		else if (CFGetTypeID (value) == CFStringGetTypeID ())
-		{
-			const char *tem = [(NSString *) value UTF8String];
-			if (strcasecmp (tem, "true") == 0 || strcasecmp (tem, "yes") == 0)
-				ret = YES;
-			else
-				ret = NO;
-		}
-		
-		CFRelease (value);
+- (int) prefs_get_boolean:(NSString *)key default:(int)def {
+  CFPropertyListRef value;
+  int ret = def;
+  
+  value = [self prefs_get:key];
+  
+  if (value != NULL) {
+    if (CFGetTypeID (value) == CFNumberGetTypeID ())
+      CFNumberGetValue (value, kCFNumberIntType, &ret);
+    else if (CFGetTypeID (value) == CFBooleanGetTypeID ())
+      ret = CFBooleanGetValue (value);
+    else if (CFGetTypeID (value) == CFStringGetTypeID ()) {
+      const char *tem = [(NSString *) value UTF8String];
+      if (strcasecmp (tem, "true") == 0 || strcasecmp (tem, "yes") == 0)
+	ret = YES;
+      else
+	ret = NO;
     }
-	
-    return ret;
+    
+    CFRelease (value);
+  }
+  return ret;
 }
 
-- (NSArray *) prefs_get_array:(NSString *)key
-{
-    NSArray *ret = nil;
-    CFPropertyListRef value;
-	
-    value = [self prefs_get:key];
-	
-    if (value != NULL)
-    {
-		if (CFGetTypeID (value) == CFArrayGetTypeID ())
-			ret = [cfarray_to_nsarray (value) autorelease];
-		
-		CFRelease (value);
-    }
-	
-    return ret;
+- (NSArray *) prefs_get_array:(NSString *)key {
+  NSArray *ret = nil;
+  CFPropertyListRef value;
+  
+  value = [self prefs_get:key];
+  
+  if (value != NULL) {
+    if (CFGetTypeID (value) == CFArrayGetTypeID ())
+      ret = [cfarray_to_nsarray (value) autorelease];
+    
+    CFRelease (value);
+  }
+  
+  return ret;
 }
 
-- (void) prefs_set_integer:(NSString *)key value:(int)value
-{
+- (void) prefs_set_integer:(NSString *)key value:(int)value {
     CFNumberRef x;
 	
     x = CFNumberCreate (NULL, kCFNumberIntType, &value);
 	
     CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) x, CFSTR (APP_PREFS),
-						   kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+			   kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
 	
     CFRelease (x);
 }
 
-- (void) prefs_set_float:(NSString *)key value:(float)value
-{
+- (void) prefs_set_float:(NSString *)key value:(float)value {
     CFNumberRef x;
 	
     x = CFNumberCreate (NULL, kCFNumberFloatType, &value);
 	
     CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) x, CFSTR (APP_PREFS),
-						   kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+			   kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
 	
     CFRelease (x);
 }
 
-- (void) prefs_set_boolean:(NSString *)key value:(int)value
-{
-    CFPreferencesSetValue ((CFStringRef) key,
-						   (CFTypeRef) value ? kCFBooleanTrue
-						   : kCFBooleanFalse, CFSTR (APP_PREFS),
-						   kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
-	
+- (void) prefs_set_boolean:(NSString *)key value:(int)value {
+  CFPreferencesSetValue ((CFStringRef) key,
+			 (CFTypeRef) value ? kCFBooleanTrue
+			 : kCFBooleanFalse, CFSTR (APP_PREFS),
+			 kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+  
 }
 
-- (void) prefs_set_array:(NSString *)key value:(NSArray *)value
-{
-    CFArrayRef cfarray;
-	
-    cfarray = nsarray_to_cfarray (value);
-    CFPreferencesSetValue ((CFStringRef) key,
-						   (CFTypeRef) cfarray,
-						   CFSTR (APP_PREFS),
-						   kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
-    CFRelease (cfarray);
+- (void) prefs_set_array:(NSString *)key value:(NSArray *)value {
+  CFArrayRef cfarray;
+  
+  cfarray = nsarray_to_cfarray (value);
+  CFPreferencesSetValue ((CFStringRef) key,
+			 (CFTypeRef) cfarray,
+			 CFSTR (APP_PREFS),
+			 kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+  CFRelease (cfarray);
 }
 
-- (void) prefs_set_string:(NSString *)key value:(NSString *)value
-{
-    CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) value,
-						   CFSTR (APP_PREFS), kCFPreferencesCurrentUser,
-						   kCFPreferencesAnyHost);
+- (void) prefs_set_string:(NSString *)key value:(NSString *)value {
+  CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) value,
+			 CFSTR (APP_PREFS), kCFPreferencesCurrentUser,
+			 kCFPreferencesAnyHost);
 }
 
-- (void) prefs_synchronize
-{
+- (void) prefs_synchronize {
     CFPreferencesAppSynchronize (kCFPreferencesCurrentApplication);
 }
 
@@ -717,14 +645,12 @@ cfarray_to_nsarray (CFArrayRef in)
 }
 
 /* This will end up at the end of the responder chain. */
-- (void) copy:sender
-{
-    QuartzMessageServerThread (kXDarwinPasteboardNotify, 1,
-			       AppleWMCopyToPasteboard);
+- (void) copy:sender {
+  QuartzMessageServerThread (kXDarwinPasteboardNotify, 1,
+			     AppleWMCopyToPasteboard);
 }
 
-- (BOOL) x_active
-{
+- (BOOL) x_active {
     return _x_active;
 }
 
@@ -732,75 +658,62 @@ cfarray_to_nsarray (CFArrayRef in)
 
 static NSArray *
 array_with_strings_and_numbers (int nitems, const char **items,
-								const char *numbers)
-{
-    NSMutableArray *array, *subarray;
-    NSString *string;
-    NSString *number;
-    int i;
+				const char *numbers) {
+  NSMutableArray *array, *subarray;
+  NSString *string, *number;
+  int i;
 	
-    /* (Can't autorelease on the X server thread) */
-	
-    array = [[NSMutableArray alloc] initWithCapacity:nitems];
-	
-    for (i = 0; i < nitems; i++)
-    {
-		subarray = [[NSMutableArray alloc] initWithCapacity:2];
-		
-		string = [[NSString alloc] initWithUTF8String:items[i]];
-		[subarray addObject:string];
-		[string release];
-		
-		if (numbers[i] != 0)
-		{
-			number = [[NSString alloc] initWithFormat:@"%d", numbers[i]];
-			[subarray addObject:number];
-			[number release];
-		}
-		else
-			[subarray addObject:@""];
-		
-		[array addObject:subarray];
-		[subarray release];
-    }
-	
-    return array;
+  /* (Can't autorelease on the X server thread) */
+  
+  array = [[NSMutableArray alloc] initWithCapacity:nitems];
+  
+  for (i = 0; i < nitems; i++) {
+    subarray = [[NSMutableArray alloc] initWithCapacity:2];
+    
+    string = [[NSString alloc] initWithUTF8String:items[i]];
+    [subarray addObject:string];
+    [string release];
+    
+    if (numbers[i] != 0) {
+      number = [[NSString alloc] initWithFormat:@"%d", numbers[i]];
+      [subarray addObject:number];
+      [number release];
+    } else
+      [subarray addObject:@""];
+    
+    [array addObject:subarray];
+    [subarray release];
+  }
+  
+  return array;
 }
 
-void
-X11ApplicationSetWindowMenu (int nitems, const char **items,
-							 const char *shortcuts)
-{
-    NSArray *array;
-    array = array_with_strings_and_numbers (nitems, items, shortcuts);
-	
-    /* Send the array of strings over to the appkit thread */
-	
-    message_kit_thread (@selector (set_window_menu:), array);
-    [array release];
+void X11ApplicationSetWindowMenu (int nitems, const char **items,
+				  const char *shortcuts) {
+  NSArray *array;
+  array = array_with_strings_and_numbers (nitems, items, shortcuts);
+  
+  /* Send the array of strings over to the appkit thread */
+  
+  message_kit_thread (@selector (set_window_menu:), array);
+  [array release];
 }
 
-void
-X11ApplicationSetWindowMenuCheck (int idx)
-{
-    NSNumber *n;
-	
-    n = [[NSNumber alloc] initWithInt:idx];
-	
-    message_kit_thread (@selector (set_window_menu_check:), n);
-	
-    [n release];
+void X11ApplicationSetWindowMenuCheck (int idx) {
+  NSNumber *n;
+  
+  n = [[NSNumber alloc] initWithInt:idx];
+  
+  message_kit_thread (@selector (set_window_menu_check:), n);
+  
+  [n release];
 }
 
-void
-X11ApplicationSetFrontProcess (void)
-{
+void X11ApplicationSetFrontProcess (void) {
     message_kit_thread (@selector (set_front_process:), nil);
 }
 
-void
-X11ApplicationSetCanQuit (int state)
-{
+void X11ApplicationSetCanQuit (int state) {
     NSNumber *n;
 	
     n = [[NSNumber alloc] initWithBool:state];
@@ -810,15 +723,11 @@ X11ApplicationSetCanQuit (int state)
     [n release];
 }
 
-void
-X11ApplicationServerReady (void)
-{
+void X11ApplicationServerReady (void) {
     message_kit_thread (@selector (server_ready:), nil);
 }
 
-void
-X11ApplicationShowHideMenubar (int state)
-{
+void X11ApplicationShowHideMenubar (int state) {
     NSNumber *n;
 	
     n = [[NSNumber alloc] initWithBool:state];
@@ -828,27 +737,20 @@ X11ApplicationShowHideMenubar (int state)
     [n release];
 }
 
-static void *
-create_thread (void *func, void *arg)
-{
+static void * create_thread (void *func, void *arg) {
     pthread_attr_t attr;
     pthread_t tid;
 	
     pthread_attr_init (&attr);
-	
     pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM);
     pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
-	
     pthread_create (&tid, &attr, func, arg);
-	
     pthread_attr_destroy (&attr);
 	
     return (void *) tid;
 }
 
-static void
-check_xinitrc (void)
-{
+static void check_xinitrc (void) {
     char *tem, buf[1024];
     NSString *msg;
 	
@@ -856,8 +758,7 @@ check_xinitrc (void)
 		return;
 	
     tem = getenv ("HOME");
-    if (tem == NULL)
-		goto done;
+    if (tem == NULL) goto done;
 	
     snprintf (buf, sizeof (buf), "%s/.xinitrc", tem);
     if (access (buf, F_OK) != 0)
@@ -872,29 +773,26 @@ Would you like to move aside the existing file and use the standard X11 \
 environment?", @"Startup xinitrc dialog");
 	
     if (NSRunAlertPanel (nil, msg, NSLocalizedString (@"Yes", @""),
-						 NSLocalizedString (@"No", @""), nil)
-		== NSAlertDefaultReturn)
-    {
-		char buf2[1024];
-		int i = -1;
-		
-		snprintf (buf2, sizeof (buf2), "%s.old", buf);
-		
-		for (i = 1; access (buf2, F_OK) == 0; i++)
-			snprintf (buf2, sizeof (buf2), "%s.old.%d", buf, i);
-		
-		rename (buf, buf2);
+			 NSLocalizedString (@"No", @""), nil)
+	== NSAlertDefaultReturn) {
+      char buf2[1024];
+      int i = -1;
+      
+      snprintf (buf2, sizeof (buf2), "%s.old", buf);
+      
+      for (i = 1; access (buf2, F_OK) == 0; i++)
+	snprintf (buf2, sizeof (buf2), "%s.old.%d", buf, i);
+      
+      rename (buf, buf2);
     }
     
-	done:
+ done:
     [X11App prefs_set_boolean:@PREFS_DONE_XINIT_CHECK value:YES];
     [X11App prefs_synchronize];
 }
 
-void
-X11ApplicationMain (int argc, const char *argv[],
-		    void (*server_thread) (void *), void *server_arg)
-{
+void X11ApplicationMain (int argc, const char *argv[],
+			 void (*server_thread) (void *), void *server_arg) {
   NSAutoreleasePool *pool;
   
 #ifdef DEBUG
@@ -935,154 +833,87 @@ X11ApplicationMain (int argc, const char *argv[],
 /* event conversion */
 
 static inline unsigned short
-convert_flags (unsigned int nsflags)
-{
-    unsigned int xflags;
+convert_flags (unsigned int nsflags) {
+    unsigned int xflags = 0;
 	
     if (nsflags == ~0) return 0xffff;
 	
-    xflags = 0;
-	
     if (nsflags & NSAlphaShiftKeyMask)	xflags |= LockMask;
-    if (nsflags & NSShiftKeyMask)		xflags |= ShiftMask;
-    if (nsflags & NSControlKeyMask)		xflags |= ControlMask;
+    if (nsflags & NSShiftKeyMask)	xflags |= ShiftMask;
+    if (nsflags & NSControlKeyMask)	xflags |= ControlMask;
     if (nsflags & NSAlternateKeyMask)	xflags |= Mod1Mask;
-    if (nsflags & NSCommandKeyMask)		xflags |= Mod2Mask;
+    if (nsflags & NSCommandKeyMask)	xflags |= Mod2Mask;
     /* FIXME: secondaryfn? */
 	
     return xflags;
 }
 
-static void
-send_nsevent (NSEventType type, NSEvent *e)
-{
-  static unsigned int button_state = 0;
-  NSRect screen;
-  NSPoint location;
-  NSWindow *window;
-  int pointer_x, pointer_y;
-  xEvent xe;
-  
-  memset (&xe, 0, sizeof (xe));
-  
-  /* This field should be filled in for every event */
-  xe.u.keyButtonPointer.time = GetTimeInMillis();
-  
-  /* convert location to global top-left coordinates */
-  location = [e locationInWindow];
-  window = [e window];
-  screen = [[[NSScreen screens] objectAtIndex:0] frame];
-  
-  if (window != nil)	{
-    NSRect frame = [window frame];
-    pointer_x = location.x + frame.origin.x;
-    pointer_y = (((screen.origin.y + screen.size.height)
-		  - location.y) - frame.origin.y);
-  } else {
-    pointer_x = location.x;
-    pointer_y = (screen.origin.y + screen.size.height) - location.y;
-  }
-  
-  xe.u.keyButtonPointer.rootX = pointer_x;
-  xe.u.keyButtonPointer.rootY = pointer_y;
-  
-  switch (type) {
-    float count;
-    
-  case NSLeftMouseDown:
-    xe.u.u.type = ButtonPress;
-    xe.u.u.detail = 1;
-    goto do_press_event;
-    
-  case NSRightMouseDown:
-    xe.u.u.type = ButtonPress;
-    xe.u.u.detail = 3;
-    goto do_press_event;
+
+// This code should probably be merged with that in XDarwin's XServer.m - BB
+static void send_nsevent (NSEventType type, NSEvent *e) {
+  //    static unsigned int button_state = 0;
+    NSRect screen;
+    NSPoint location;
+    NSWindow *window;
+    int pointer_x, pointer_y, ev_button, ev_type; 
+    //    int num_events=0, i=0, state;
+    xEvent xe;
+	
+    /* convert location to global top-left coordinates */
+    location = [e locationInWindow];
+    window = [e window];
+    screen = [[[NSScreen screens] objectAtIndex:0] frame];
+		
+    if (window != nil)	{
+      NSRect frame = [window frame];
+      pointer_x = location.x + frame.origin.x;
+      pointer_y = (((screen.origin.y + screen.size.height)
+		    - location.y) - frame.origin.y);
+    } else {
+      pointer_x = location.x;
+      pointer_y = (screen.origin.y + screen.size.height) - location.y;
+    }
     
-  case NSOtherMouseDown:
-    xe.u.u.type = ButtonPress;
-    xe.u.u.detail = 2; /* FIXME? */
-    goto do_press_event;
+    pointer_y -= aquaMenuBarHeight;
+    //    state = convert_flags ([e modifierFlags]);
     
-  do_press_event:
-    if (!quartzProcs->IsX11Window([e window], [e windowNumber])) {
-      /* X server doesn't grok this window, drop the event.
-	 
-	 Note: theoretically this isn't necessary, but if I click
-	 on the menubar, we get sent a LeftMouseDown when the
-	 release happens, but no LeftMouseUp is ever seen! */
+    switch (type) {
+    case NSLeftMouseDown:    ev_button=1; ev_type=ButtonPress; goto handle_mouse;
+    case NSOtherMouseDown:   ev_button=2; ev_type=ButtonPress; goto handle_mouse;
+    case NSRightMouseDown:   ev_button=3; ev_type=ButtonPress; goto handle_mouse;
+    case NSLeftMouseUp:      ev_button=1; ev_type=ButtonRelease; goto handle_mouse;
+    case NSOtherMouseUp:     ev_button=2; ev_type=ButtonRelease; goto handle_mouse;
+    case NSRightMouseUp:     ev_button=3; ev_type=ButtonRelease; goto handle_mouse;
+    case NSLeftMouseDragged:  ev_button=1; ev_type=MotionNotify; goto handle_mouse;
+    case NSOtherMouseDragged: ev_button=2; ev_type=MotionNotify; goto handle_mouse;
+    case NSRightMouseDragged: ev_button=3; ev_type=MotionNotify; goto handle_mouse;
+    case NSMouseMoved: ev_button=0; ev_type=MotionNotify; goto handle_mouse;
+    handle_mouse:
       
+      /* I'm not sure the below code is necessary or useful (-bb)
+	if(ev_type==ButtonPress) {
+	if (!quartzProcs->IsX11Window([e window], [e windowNumber])) {
+	  fprintf(stderr, "Dropping event because it's not a window\n");
+	  break;
+	}
+	button_state |= (1 << ev_button);
+	DarwinSendPointerEvents(ev_type, ev_button, pointer_x, pointer_y);
+      } else if (ev_type==ButtonRelease && (button_state & (1 << ev_button)) == 0) break;
+      */
+      DarwinSendPointerEvents(ev_type, ev_button, pointer_x, pointer_y);
       break;
-    }
-    goto do_event;
-    
-  case NSLeftMouseUp:
-    xe.u.u.type = ButtonRelease;
-    xe.u.u.detail = 1;
-    goto do_release_event;
-    
-  case NSRightMouseUp:
-    xe.u.u.type = ButtonRelease;
-    xe.u.u.detail = 3;
-    goto do_release_event;
-    
-  case NSOtherMouseUp:
-    xe.u.u.type = ButtonRelease;
-    xe.u.u.detail = 2; /* FIXME? */
-    goto do_release_event;
-    
-  do_release_event:
-    if ((button_state & (1 << xe.u.u.detail)) == 0)
-      {
-	/* X didn't see the button press for this release, so skip it */
-	break;
-      }
-    goto do_event;
-    
-  case NSMouseMoved:
-  case NSLeftMouseDragged:
-  case NSRightMouseDragged:
-  case NSOtherMouseDragged:
-    xe.u.u.type = MotionNotify;
-    goto do_event;
-    
-  case NSKeyDown:
-    xe.u.u.type = KeyPress;
-    xe.u.u.detail = [e keyCode];
-    goto do_event;
-    
-  case NSKeyUp:
-    xe.u.u.type = KeyRelease;
-    xe.u.u.detail = [e keyCode];
-    goto do_event;
-    
-  case NSScrollWheel:
-    xe.u.keyButtonPointer.state = convert_flags ([e modifierFlags]);
-    count = [e deltaY];
-    xe.u.u.detail = count > 0.0f ? 4 : 5;
-    for (count = fabs(count); count > 0.0; count = count - 1.0f) {
-      xe.u.u.type = ButtonPress;
-      DarwinEQEnqueue(&xe);
-      xe.u.u.type = ButtonRelease;
-      DarwinEQEnqueue(&xe);
-    }
-    xe.u.u.type = 0;
-    break;
-    
-  case NSFlagsChanged:
-    xe.u.u.type = kXDarwinUpdateModifiers;
-    xe.u.clientMessage.u.l.longs0 = [e modifierFlags];
-    DarwinEQEnqueue (&xe);
-    break;
-    
-  do_event:
-    //	xe.u.keyButtonPointer.state = convert_flags ([e modifierFlags]);
-    DarwinEQEnqueue (&xe);
-    break;
-    
-  default: break; /* for gcc */
-  }
-  
-  if (xe.u.u.type == ButtonPress) button_state |= (1 << xe.u.u.detail);
-  else if (xe.u.u.type == ButtonRelease) button_state &= ~(1 << xe.u.u.detail);
+    case NSScrollWheel: 
+      DarwinSendScrollEvents([e deltaY], pointer_x, pointer_y);
+      break;
+      
+    case NSKeyDown:  // do we need to translate these keyCodes?
+    case NSKeyUp:
+      DarwinSendKeyboardEvents((type == NSKeyDown)?KeyPress:KeyRelease, [e keyCode]);
+      break;
+
+    case NSFlagsChanged:
+      DarwinUpdateModKeys([e modifierFlags]);
+      break;
+    default: break; /* for gcc */
+    }	
 }
commit 28ae09f3555f8d07deff4725477f21b50b07abad
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Fri Nov 23 14:18:04 2007 -0800

    Darwin: Sync-up to master and xorg-server-1.2-apple where appropriate

diff --git a/configure.ac b/configure.ac
index e73d12b..2cad021 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2152,8 +2152,6 @@ hw/xnest/Makefile
 hw/xwin/Makefile
 hw/darwin/Makefile
 hw/darwin/quartz/Makefile
-hw/darwin/quartz/cr/Makefile
-hw/darwin/quartz/fullscreen/Makefile
 hw/darwin/quartz/xpr/Makefile
 hw/darwin/utils/Makefile
 hw/kdrive/Makefile
diff --git a/hw/darwin/Makefile.am b/hw/darwin/Makefile.am
index 4a86fa3..62cbecf 100644
--- a/hw/darwin/Makefile.am
+++ b/hw/darwin/Makefile.am
@@ -1,61 +1,64 @@
-AM_CFLAGS = $(XORG_CFLAGS) $(PIXMAN_CFLAGS)
-AM_CPPFLAGS = $(XORG_INCS) -DUSE_NEW_CLUT -DBUILD_DATE=\"$(BUILD_DATE)\" -DHAVE_XORG_CONFIG_H -DXFree86Server -DINXQUARTZ \
-	-I$(top_srcdir)/fb \
-	-I$(top_srcdir)/mi \
-	-I$(top_srcdir)/miext/rootless \
-	-I$(top_srcdir)/render \
-	-I$(top_srcdir)/Xext
+AM_CFLAGS = $(XORG_CFLAGS) $(DIX_CFLAGS)
+AM_CPPFLAGS = $(XORG_INCS) \
+	-DINXQUARTZ \
+	-DUSE_NEW_CLUT \
+	-DXFree86Server \
+	-I$(top_srcdir)/miext/rootless
 
 SUBDIRS = quartz utils
 
 bin_PROGRAMS = Xquartz
 man1_MANS = Xquartz.man
 
-Xquartz_SOURCES = darwin.c \
-		  darwinEvents.c \
-		  darwinKeyboard.c \
-		  darwinXinput.c \
-		  $(top_srcdir)/fb/fbcmap_mi.c \
-		  $(top_srcdir)/mi/miinitext.c
+Xquartz_SOURCES = \
+	darwin.c \
+	darwinEvents.c \
+	darwinKeyboard.c \
+	darwinXinput.c \
+	$(top_srcdir)/fb/fbcmap_mi.c \
+	$(top_srcdir)/mi/miinitext.c
 
 #		We should probably add these once they're working, or are these obsolete and to be removed?
 #		./quartz/cr/libcr.a
 #		./quartz/fullscreen/libfullscreen.a
 
-Xquartz_LDADD = ./quartz/libXquartz.a \
-		./quartz/xpr/libxpr.a \
-		$(top_builddir)/dix/dixfonts.lo \
-		$(top_builddir)/dix/libdix.la \
-		$(top_builddir)/os/libos.la \
-		$(top_builddir)/dix/libxpstubs.la \
-		$(top_builddir)/miext/shadow/libshadow.la \
-		$(top_builddir)/fb/libfb.la \
-		$(top_builddir)/mi/libmi.la \
-		$(top_builddir)/composite/libcomposite.la \
-		$(top_builddir)/damageext/libdamageext.la \
-		$(top_builddir)/miext/damage/libdamage.la \
-		$(top_builddir)/xfixes/libxfixes.la \
-		$(top_builddir)/miext/cw/libcw.la \
-		$(top_builddir)/Xext/libXext.la \
-		$(top_builddir)/xkb/libxkb.la \
-		$(top_builddir)/xkb/libxkbstubs.la \
-		$(top_builddir)/Xi/libXi.la \
-		$(top_builddir)/dbe/libdbe.la \
-		$(top_builddir)/record/librecord.la \
-		$(top_builddir)/XTrap/libxtrap.la \
-		$(top_builddir)/miext/rootless/librootless.la \
-		$(top_builddir)/miext/rootless/safeAlpha/libsafeAlpha.la \
-		$(top_builddir)/miext/rootless/accel/librlAccel.la \
-		$(DARWIN_LIBS) $(XSERVER_LIBS) $(PIXMAN_LIBS) -lXplugin
-
-Xquartz_LDFLAGS =  -XCClinker -Objc \
-		   -Wl,-u,_miDCInitialize \
-		   -Wl,-framework,Carbon \
-		   -L/System/Library/Frameworks/OpenGL.framework/Libraries -lGL \
-		   -Wl,-framework,OpenGL \
-		   -Wl,-framework,Cocoa \
-		   -Wl,-framework,CoreAudio \
-	  	   -Wl,-framework,IOKit
+Xquartz_LDADD = \
+	./quartz/libXquartz.a \
+	./quartz/xpr/libxpr.a \
+	$(top_builddir)/dix/dixfonts.lo \
+	$(top_builddir)/config/libconfig.a \
+	$(top_builddir)/dix/libdix.la \
+	$(top_builddir)/os/libos.la \
+	$(top_builddir)/dix/libxpstubs.la \
+	$(top_builddir)/miext/shadow/libshadow.la \
+	$(top_builddir)/fb/libfb.la \
+	$(top_builddir)/mi/libmi.la \
+	$(top_builddir)/composite/libcomposite.la \
+	$(top_builddir)/damageext/libdamageext.la \
+	$(top_builddir)/miext/damage/libdamage.la \
+	$(top_builddir)/xfixes/libxfixes.la \
+	$(top_builddir)/miext/cw/libcw.la \
+	$(top_builddir)/Xext/libXext.la \
+	$(top_builddir)/xkb/libxkb.la \
+	$(top_builddir)/xkb/libxkbstubs.la \
+	$(top_builddir)/Xi/libXi.la \
+	$(top_builddir)/dbe/libdbe.la \
+	$(top_builddir)/record/librecord.la \
+	$(top_builddir)/XTrap/libxtrap.la \
+	$(top_builddir)/miext/rootless/librootless.la \
+	$(top_builddir)/miext/rootless/safeAlpha/libsafeAlpha.la \
+	$(top_builddir)/miext/rootless/accel/librlAccel.la \
+	$(DARWIN_LIBS) $(XSERVER_LIBS) $(XSERVER_SYS_LIBS) -lXplugin
+
+Xquartz_LDFLAGS =  \
+	-XCClinker -Objc \
+	-Wl,-u,_miDCInitialize \
+	-Wl,-framework,Carbon \
+	-L/System/Library/Frameworks/OpenGL.framework/Libraries -lGL \
+	-Wl,-framework,OpenGL \
+	-Wl,-framework,Cocoa \
+	-Wl,-framework,CoreAudio \
+	-Wl,-framework,IOKit
 
 if X11APP
 bin_SCRIPTS = x11app x11launcher
@@ -80,6 +83,7 @@ x11launcher-clean:
 
 install-data-hook: x11app-install x11launcher-install
 clean-local: x11app-clean x11launcher-clean
+
 endif
 
 EXTRA_DIST = \
diff --git a/hw/darwin/darwin.c b/hw/darwin/darwin.c
index 80d879b..b08770c 100644
--- a/hw/darwin/darwin.c
+++ b/hw/darwin/darwin.c
@@ -3,8 +3,6 @@
  * Shared code for the Darwin X Server
  * running with Quartz or IOKit display mode
  *
- **************************************************************/
-/*
  * Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
  * Copyright (c) 2007 Apple Inc.
  *
@@ -362,10 +360,11 @@ static int DarwinMouseProc(
             map[3] = 3;
             map[4] = 4;
             map[5] = 5;
-            InitPointerDeviceStruct((DevicePtr)pPointer, map, 5,
-                                    GetMotionHistory,
-                                    (PtrCtrlProcPtr)NoopDDA,
-                                    GetMotionHistorySize(), 2);
+            InitPointerDeviceStruct( (DevicePtr)pPointer, map, 5,
+				     GetMotionHistory,
+				     (PtrCtrlProcPtr)NoopDDA,
+				     GetMotionHistorySize(), 2);
+
 #ifdef XINPUT
             InitValuatorAxisStruct( pPointer,
                                     0,     // X axis
diff --git a/hw/darwin/darwin.h b/hw/darwin/darwin.h
index 14443b9..a8c670b 100644
--- a/hw/darwin/darwin.h
+++ b/hw/darwin/darwin.h
@@ -27,6 +27,8 @@
 #ifndef _DARWIN_H
 #define _DARWIN_H
 
+#include "dix-config.h"
+
 #include <IOKit/IOTypes.h>
 #include "inputstr.h"
 #include "scrnintstr.h"
@@ -48,7 +50,7 @@ typedef struct {
 
 
 // From darwin.c
-void DarwinPrintBanner();
+void DarwinPrintBanner(void);
 int DarwinParseModifierList(const char *constmodifiers);
 void DarwinAdjustScreenOrigins(ScreenInfo *pScreenInfo);
 void xf86SetRootClip (ScreenPtr pScreen, BOOL enable);
diff --git a/hw/darwin/quartz/Makefile.am b/hw/darwin/quartz/Makefile.am
index d90b2bf..54e6c30 100644
--- a/hw/darwin/quartz/Makefile.am
+++ b/hw/darwin/quartz/Makefile.am
@@ -1,28 +1,26 @@
 noinst_LIBRARIES = libXQuartz.a
 
-AM_CFLAGS = $(XORG_CFLAGS) $(PIXMAN_CFLAGS)
-AM_OBJCFLAGS = $(XORG_CFLAGS) $(PIXMAN_CFLAGS)
-AM_CPPFLAGS = $(XORG_INCS) -DXBINDIR=\"${bindir}\" -DHAS_KL_API -DHAVE_XORG_CONFIG_H \
+AM_CFLAGS = $(XORG_CFLAGS) $(DIX_CFLAGS)
+AM_OBJCFLAGS = $(XORG_CFLAGS) $(DIX_CFLAGS)
+AM_CPPFLAGS = $(XORG_INCS) \
+	-DHAS_KL_API \
 	-I$(srcdir) -I$(srcdir)/.. \
-	-I$(top_srcdir)/fb \
-	-I$(top_srcdir)/mi \
-	-I$(top_srcdir)/miext/rootless \
-	-I$(top_srcdir)/render
+	-I$(top_srcdir)/miext/rootless
 
-SUBDIRS = cr fullscreen xpr
+SUBDIRS = xpr
 
 libXQuartz_a_SOURCES = \
-		  X11Application.m \
-		  X11Controller.m \
-	          applewm.c \
-	          keysym2ucs.c \
-	          pseudoramiX.c \
-	          quartz.c \
-	          quartzAudio.c \
-	          quartzCocoa.m \
-	          quartzKeyboard.c \
-	          quartzPasteboard.c \
-	          quartzStartup.c
+	X11Application.m \
+	X11Controller.m \
+	applewm.c \
+	keysym2ucs.c \
+	pseudoramiX.c \
+	quartz.c \
+	quartzAudio.c \
+	quartzCocoa.m \
+	quartzKeyboard.c \
+	quartzPasteboard.c \
+	quartzStartup.c
 
 EXTRA_DIST = \
 	X11Application.h \
diff --git a/hw/darwin/quartz/X11Application.h b/hw/darwin/quartz/X11Application.h
index fb153e7..8615657 100644
--- a/hw/darwin/quartz/X11Application.h
+++ b/hw/darwin/quartz/X11Application.h
@@ -1,5 +1,4 @@
 /* X11Application.h -- subclass of NSApplication to multiplex events
-   $Id: X11Application.h,v 1.26 2003/08/08 19:16:13 jharper Exp $
 
    Copyright (c) 2002-2007 Apple Inc. All rights reserved.
 
diff --git a/hw/darwin/quartz/X11Controller.h b/hw/darwin/quartz/X11Controller.h
index 954d0ab..f1399dc 100644
--- a/hw/darwin/quartz/X11Controller.h
+++ b/hw/darwin/quartz/X11Controller.h
@@ -1,5 +1,4 @@
 /* X11Controller.h -- connect the IB ui
-   $Id: X11Controller.h,v 1.21 2003/07/24 17:52:29 jharper Exp $
 
    Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
 
@@ -34,7 +33,7 @@
 #if __OBJC__
 
 #import <Cocoa/Cocoa.h>
-#include "../quartz/xpr/x-list.h"
+#include "xpr/x-list.h"
 
 @interface X11Controller : NSObject
 {
diff --git a/hw/darwin/quartz/X11Controller.m b/hw/darwin/quartz/X11Controller.m
index df90049..6929566 100644
--- a/hw/darwin/quartz/X11Controller.m
+++ b/hw/darwin/quartz/X11Controller.m
@@ -1,5 +1,4 @@
 /* X11Controller.m -- connect the IB ui, also the NSApp delegate
-   $Id: X11Controller.m,v 1.40 2006/09/06 21:19:32 jharper Exp $
  
    Copyright (c) 2002-2007 Apple Inc. All rights reserved.
  
@@ -30,7 +29,7 @@
 
 #define DEFAULT_PATH "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11/bin"
 
-#include "../quartz/quartzCommon.h"
+#include "quartzCommon.h"
 
 #import "X11Controller.h"
 #import "X11Application.h"
@@ -38,14 +37,12 @@
 
 /* ouch! */
 #define BOOL X_BOOL
-//# include "Xproto.h"
 #include "opaque.h"
 # include "darwin.h"
-# include "../quartz/quartz.h"
+# include "quartz.h"
 # define _APPLEWM_SERVER_
 # include "X11/extensions/applewm.h"
-# include "../quartz/applewmExt.h"
-//# include "X.h"
+# include "applewmExt.h"
 #undef BOOL
 
 #include <stdio.h>
@@ -305,7 +302,7 @@
   argv[4] = "-c";
   argv[5] = command;
   argv[6] = NULL;
-    
+
   /* Do the fork-twice trick to avoid having to reap zombies */
     
   child1 = fork();
diff --git a/hw/darwin/quartz/applewm.c b/hw/darwin/quartz/applewm.c
index 2346303..20d1b4f 100644
--- a/hw/darwin/quartz/applewm.c
+++ b/hw/darwin/quartz/applewm.c
@@ -24,9 +24,9 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 **************************************************************************/
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+
+#include <dix-config.h>
+
 #include "quartzCommon.h"
 
 #define NEED_REPLIES
@@ -461,7 +461,7 @@ ProcAppleWMSetWindowMenuCheck(
     REQUEST(xAppleWMSetWindowMenuCheckReq);
 
     REQUEST_SIZE_MATCH(xAppleWMSetWindowMenuCheckReq);
-    X11ApplicationSetWindowMenuCheck (stuff->index);
+    X11ApplicationSetWindowMenuCheck(stuff->index);
     return (client->noClientException);
 }
 
diff --git a/hw/darwin/quartz/cr/Makefile.am b/hw/darwin/quartz/cr/Makefile.am
deleted file mode 100644
index 03f2e24..0000000
--- a/hw/darwin/quartz/cr/Makefile.am
+++ /dev/null
@@ -1,23 +0,0 @@
-noinst_LIBRARIES = libcr.a
-AM_CFLAGS = $(XORG_CFLAGS)
-AM_OBJCFLAGS = $(XORG_CFLAGS)
-AM_CPPFLAGS = -DDEFER_NSWINDOW \
-	   $(XORG_INCS) \
-	   -I../fullscreen \
-	   -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../.. \
-	   -I$(top_srcdir)/mi \
-	   -I$(top_srcdir)/miext/rootless \
-	   -I$(top_srcdir)/miext/rootless/safeAlpha \
-	   -I$(top_srcdir)/render \
-	   $(PIXMAN_CFLAGS)
-
-libcr_a_SOURCES = crAppleWM.m \
-	           crFrame.m \
-	           crScreen.m \
-	           ../fullscreen/quartzCursor.c \
-	           XView.m
-
-EXTRA_DIST = \
-	cr.h \
-	XView.h 
-
diff --git a/hw/darwin/quartz/cr/XView.m b/hw/darwin/quartz/cr/XView.m
index 488f88a..8379f94 100644
--- a/hw/darwin/quartz/cr/XView.m
+++ b/hw/darwin/quartz/cr/XView.m
@@ -30,11 +30,9 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-#import "XView.h"
+#include <dix-config.h>
 
+#import "XView.h"
 
 @implementation XView
 
diff --git a/hw/darwin/quartz/cr/crAppleWM.m b/hw/darwin/quartz/cr/crAppleWM.m
index da05fed..a0259c3 100644
--- a/hw/darwin/quartz/cr/crAppleWM.m
+++ b/hw/darwin/quartz/cr/crAppleWM.m
@@ -26,11 +26,10 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-#include "quartzCommon.h"
-#include "cr.h"
+#include <dix-config.h>
+
+#include "quartz/quartzCommon.h"
+#include "quartz/cr/cr.h"
 
 #undef BOOL
 #define BOOL xBOOL
@@ -38,7 +37,7 @@
 #include "X11/X.h"
 #define _APPLEWM_SERVER_
 #include "X11/extensions/applewm.h"
-#include "applewmExt.h"
+#include "quartz/applewmExt.h"
 #undef BOOL
 
 #define StdDocumentStyleMask (NSTitledWindowMask | \
diff --git a/hw/darwin/quartz/cr/crFrame.m b/hw/darwin/quartz/cr/crFrame.m
index f54afc9..79697fb 100644
--- a/hw/darwin/quartz/cr/crFrame.m
+++ b/hw/darwin/quartz/cr/crFrame.m
@@ -27,11 +27,10 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-#include "quartzCommon.h"
-#include "cr.h"
+#include <dix-config.h>
+
+#include "quartz/quartzCommon.h"
+#include "quartz/cr/cr.h"
 
 #undef BOOL
 #define BOOL xBOOL
diff --git a/hw/darwin/quartz/cr/crScreen.m b/hw/darwin/quartz/cr/crScreen.m
index 0e358ab..504e7b3 100644
--- a/hw/darwin/quartz/cr/crScreen.m
+++ b/hw/darwin/quartz/cr/crScreen.m
@@ -27,11 +27,10 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-#include "quartzCommon.h"
-#include "cr.h"
+#include <dix-config.h>
+
+#include "quartz/quartzCommon.h"
+#include "quartz/cr/cr.h"
 
 #undef BOOL
 #define BOOL xBOOL
diff --git a/hw/darwin/quartz/fullscreen/Makefile.am b/hw/darwin/quartz/fullscreen/Makefile.am
deleted file mode 100644
index 510c0c2..0000000
--- a/hw/darwin/quartz/fullscreen/Makefile.am
+++ /dev/null
@@ -1,12 +0,0 @@
-noinst_LIBRARIES = libfullscreen.a
-AM_CFLAGS = $(XORG_CFLAGS) $(PIXMAN_CFLAGS)
-AM_CPPFLAGS = $(XORG_INCS) -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../.. \
-	-I$(top_srcdir)/miext/damage \
-	-I$(top_srcdir)/miext/shadow \
-	-I$(top_srcdir)/mi
-
-libfullscreen_a_SOURCES = fullscreen.c \
-			   quartzCursor.c
-
-EXTRA_DIST = \
-	quartzCursor.h
diff --git a/hw/darwin/quartz/fullscreen/fullscreen.c b/hw/darwin/quartz/fullscreen/fullscreen.c
index ce3036f..2021ea2 100644
--- a/hw/darwin/quartz/fullscreen/fullscreen.c
+++ b/hw/darwin/quartz/fullscreen/fullscreen.c
@@ -26,10 +26,9 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-#include "quartzCommon.h"
+#include <dix-config.h>
+
+#include "quartz/quartzCommon.h"
 #include "darwin.h"
 #include "quartz/quartz.h"
 #include "quartz/quartzCursor.h"
diff --git a/hw/darwin/quartz/fullscreen/quartzCursor.c b/hw/darwin/quartz/fullscreen/quartzCursor.c
index a5483ee..5247781 100644
--- a/hw/darwin/quartz/fullscreen/quartzCursor.c
+++ b/hw/darwin/quartz/fullscreen/quartzCursor.c
@@ -28,11 +28,10 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-#include "quartzCommon.h"
-#include "quartzCursor.h"
+#include <dix-config.h>
+
+#include "quartz/quartzCommon.h"
+#include "quartz/quartzCursor.h"
 #include "darwin.h"
 
 #include <pthread.h>
diff --git a/hw/darwin/quartz/keysym2ucs.h b/hw/darwin/quartz/keysym2ucs.h
index e167d6a..f5b7a18 100644
--- a/hw/darwin/quartz/keysym2ucs.h
+++ b/hw/darwin/quartz/keysym2ucs.h
@@ -1,4 +1,4 @@
-/* 
+/*
  * This module converts keysym values into the corresponding ISO 10646
  * (UCS, Unicode) values.
  *
diff --git a/hw/darwin/quartz/pseudoramiX.c b/hw/darwin/quartz/pseudoramiX.c
index e65be69..787601b 100644
--- a/hw/darwin/quartz/pseudoramiX.c
+++ b/hw/darwin/quartz/pseudoramiX.c
@@ -34,9 +34,9 @@ Equipment Corporation.
 ******************************************************************/
 
 #include "pseudoramiX.h"
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+
+#include <dix-config.h>
+
 #include "extnsionst.h"
 #include "dixstruct.h"
 #include "window.h"
diff --git a/hw/darwin/quartz/quartz.c b/hw/darwin/quartz/quartz.c
index d1eb724..c95880c 100644
--- a/hw/darwin/quartz/quartz.c
+++ b/hw/darwin/quartz/quartz.c
@@ -28,9 +28,8 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+#include <dix-config.h>
+
 #include "quartzCommon.h"
 #include "quartz.h"
 #include "darwin.h"
@@ -292,7 +291,7 @@ static void QuartzUpdateScreens(void)
     pRoot = WindowTable[pScreen->myNum];
     AppleWMSetScreenOrigin(pRoot);
     pScreen->ResizeWindow(pRoot, x - sx, y - sy, width, height, NULL);
-    pScreen->PaintWindowBackground(pRoot, &pRoot->borderClip,  PW_BACKGROUND);
+    miPaintWindow(pRoot, &pRoot->borderClip,  PW_BACKGROUND);
 //    QuartzIgnoreNextWarpCursor();
     DefineInitialRootWindow(pRoot);
 
diff --git a/hw/darwin/quartz/quartzAudio.c b/hw/darwin/quartz/quartzAudio.c
index 1980cd2..8a337da 100644
--- a/hw/darwin/quartz/quartzAudio.c
+++ b/hw/darwin/quartz/quartzAudio.c
@@ -36,9 +36,8 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+#include <dix-config.h>
+
 #include "quartzCommon.h"
 #include "quartzAudio.h"
 
diff --git a/hw/darwin/quartz/quartzCocoa.m b/hw/darwin/quartz/quartzCocoa.m
index bff3772..48cadc6 100644
--- a/hw/darwin/quartz/quartzCocoa.m
+++ b/hw/darwin/quartz/quartzCocoa.m
@@ -6,7 +6,6 @@
  * This file is separate from the parts of Quartz support
  * that use X include files to avoid symbol collisions.
  *
- *
  * Copyright (c) 2001-2004 Torrey T. Lyons and Greg Parker.
  *                 All Rights Reserved.
  *
@@ -33,9 +32,7 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+#include <dix-config.h>
 
 #include "quartzCommon.h"
 
diff --git a/hw/darwin/quartz/quartzCursor.c b/hw/darwin/quartz/quartzCursor.c
index a5483ee..15f5553 100644
--- a/hw/darwin/quartz/quartzCursor.c
+++ b/hw/darwin/quartz/quartzCursor.c
@@ -28,9 +28,8 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+#include <dix-config.h>
+
 #include "quartzCommon.h"
 #include "quartzCursor.h"
 #include "darwin.h"
diff --git a/hw/darwin/quartz/quartzKeyboard.c b/hw/darwin/quartz/quartzKeyboard.c
index 79028ef..49c5bfd 100644
--- a/hw/darwin/quartz/quartzKeyboard.c
+++ b/hw/darwin/quartz/quartzKeyboard.c
@@ -3,7 +3,7 @@
 
    Code to build a keymap using the Carbon Keyboard Layout API.
 
-   Copyright (c) 2003-2007 Apple, Inc.
+   Copyright (c) 2003-2007 Apple Inc.
 
    Permission is hereby granted, free of charge, to any person
    obtaining a copy of this software and associated documentation files
@@ -31,9 +31,8 @@
    prior written authorization.
 */
 
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+#include <dix-config.h>
+
 #include "quartzCommon.h"
 
 #include <CoreServices/CoreServices.h>
diff --git a/hw/darwin/quartz/quartzPasteboard.c b/hw/darwin/quartz/quartzPasteboard.c
index a3536fc..2130197 100644
--- a/hw/darwin/quartz/quartzPasteboard.c
+++ b/hw/darwin/quartz/quartzPasteboard.c
@@ -30,9 +30,8 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+#include <dix-config.h>
+
 #include "quartzPasteboard.h"
 
 #include <X11/Xatom.h>
diff --git a/hw/darwin/quartz/quartzStartup.c b/hw/darwin/quartz/quartzStartup.c
index 3c8412f..6f45949 100644
--- a/hw/darwin/quartz/quartzStartup.c
+++ b/hw/darwin/quartz/quartzStartup.c
@@ -36,6 +36,7 @@
 #include "opaque.h"
 #include "micmap.h"
 #include <assert.h>
+
 char **envpGlobal;      // argcGlobal and argvGlobal
                         // are from dix/globals.c
 
@@ -99,9 +100,19 @@ void DarwinHandleGUI(
         }
     }
 
+
+    /* Initially I ran the X server on the main thread, and received
+       events on the second thread. But now we may be using Carbon,
+       that needs to run on the main thread. (Otherwise, when it's
+       prebound, it will initialize itself on the wrong thread)
+       
+       grr.. but doing that means that if the X thread gets scheduled
+       before the main thread when we're _not_ prebound, things fail,
+       so initialize by hand. */
+
     extern void _InitHLTB(void);
     
-    _InitHLTB();
+    _InitHLTB();    
     X11ControllerMain(argc, argv, server_thread, NULL);
     exit(0);
 }
diff --git a/hw/darwin/quartz/xpr/Makefile.am b/hw/darwin/quartz/xpr/Makefile.am
index 444ba5c..4fe6e23 100644
--- a/hw/darwin/quartz/xpr/Makefile.am
+++ b/hw/darwin/quartz/xpr/Makefile.am
@@ -1,15 +1,11 @@
 noinst_LIBRARIES = libxpr.a
-AM_CFLAGS =  $(XORG_CFLAGS) $(PIXMAN_CFLAGS)
+AM_CFLAGS =  $(XORG_CFLAGS) $(DIX_CFLAGS)
 AM_CPPFLAGS = $(XORG_INCS) \
 	   -DHAVE_XORG_CONFIG_H \
 	   -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../.. \
-	   -I$(top_srcdir)/fb \
-	   -I$(top_srcdir)/mi \
 	   -I$(top_srcdir)/miext \
-	   -I$(top_srcdir)/miext/damage \
 	   -I$(top_srcdir)/miext/rootless \
-	   -I$(top_srcdir)/miext/rootless/safeAlpha \
-	   -I$(top_srcdir)/render
+	   -I$(top_srcdir)/miext/rootless/safeAlpha
 
 libxpr_a_SOURCES = \
 	appledri.c \
@@ -32,4 +28,3 @@ EXTRA_DIST = \
 	x-list.h \
 	Xplugin.h \
 	xpr.h
-	
diff --git a/hw/darwin/quartz/xpr/appledri.c b/hw/darwin/quartz/xpr/appledri.c
index 9b2e7b0..45d1a7e 100644
--- a/hw/darwin/quartz/xpr/appledri.c
+++ b/hw/darwin/quartz/xpr/appledri.c
@@ -35,9 +35,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  */
 
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+#include <dix-config.h>
+
 #define NEED_REPLIES
 #define NEED_EVENTS
 #include <X11/X.h>
diff --git a/hw/darwin/quartz/xpr/dri.c b/hw/darwin/quartz/xpr/dri.c
index 70efca7..4ade249 100644
--- a/hw/darwin/quartz/xpr/dri.c
+++ b/hw/darwin/quartz/xpr/dri.c
@@ -34,9 +34,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  */
 
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+#include <dix-config.h>
+
 #ifdef XFree86LOADER
 #include "xf86.h"
 #include "xf86_ansic.h"
@@ -44,7 +43,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include <sys/time.h>
 #include <unistd.h>
 #endif
-#include <dix-config.h>
 
 #define NEED_REPLIES
 #define NEED_EVENTS
diff --git a/hw/darwin/quartz/xpr/x-hash.c b/hw/darwin/quartz/xpr/x-hash.c
index 62d1a99..d24e05c 100644
--- a/hw/darwin/quartz/xpr/x-hash.c
+++ b/hw/darwin/quartz/xpr/x-hash.c
@@ -27,9 +27,8 @@
    promote the sale, use or other dealings in this Software without
    prior written authorization. */
 
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+#include <dix-config.h>
+
 #include "x-hash.h"
 #include "x-list.h"
 #include <stdlib.h>
diff --git a/hw/darwin/quartz/xpr/x-hook.c b/hw/darwin/quartz/xpr/x-hook.c
index 84bf444..e38d0ed 100644
--- a/hw/darwin/quartz/xpr/x-hook.c
+++ b/hw/darwin/quartz/xpr/x-hook.c
@@ -27,9 +27,8 @@
    promote the sale, use or other dealings in this Software without
    prior written authorization. */
 
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+#include <dix-config.h>
+
 #include "x-hook.h"
 #include <stdlib.h>
 #include <assert.h>
diff --git a/hw/darwin/quartz/xpr/x-list.c b/hw/darwin/quartz/xpr/x-list.c
index 2e74ae8..356bb79 100644
--- a/hw/darwin/quartz/xpr/x-list.c
+++ b/hw/darwin/quartz/xpr/x-list.c
@@ -27,9 +27,8 @@
    promote the sale, use or other dealings in this Software without
    prior written authorization. */
 
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+#include <dix-config.h>
+
 #include "x-list.h"
 #include <stdlib.h>
 #include <assert.h>
diff --git a/hw/darwin/quartz/xpr/xprAppleWM.c b/hw/darwin/quartz/xpr/xprAppleWM.c
index 17d3600..f639b55 100644
--- a/hw/darwin/quartz/xpr/xprAppleWM.c
+++ b/hw/darwin/quartz/xpr/xprAppleWM.c
@@ -27,9 +27,8 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+#include <dix-config.h>
+
 #include "xpr.h"
 #include "quartz/applewmExt.h"
 #include "rootless.h"
diff --git a/hw/darwin/quartz/xpr/xprCursor.c b/hw/darwin/quartz/xpr/xprCursor.c
index e45bd1f..9892bcd 100644
--- a/hw/darwin/quartz/xpr/xprCursor.c
+++ b/hw/darwin/quartz/xpr/xprCursor.c
@@ -29,9 +29,8 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+#include <dix-config.h>
+
 #include "quartz/quartzCommon.h"
 #include "xpr.h"
 #include "darwin.h"
diff --git a/hw/darwin/quartz/xpr/xprFrame.c b/hw/darwin/quartz/xpr/xprFrame.c
index 54b2035..ddb6d2d 100644
--- a/hw/darwin/quartz/xpr/xprFrame.c
+++ b/hw/darwin/quartz/xpr/xprFrame.c
@@ -27,9 +27,8 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+#include <dix-config.h>
+
 #include "xpr.h"
 #include "rootlessCommon.h"
 #include "Xplugin.h"
diff --git a/hw/darwin/quartz/xpr/xprScreen.c b/hw/darwin/quartz/xpr/xprScreen.c
index c8e3005..b5f382e 100644
--- a/hw/darwin/quartz/xpr/xprScreen.c
+++ b/hw/darwin/quartz/xpr/xprScreen.c
@@ -27,9 +27,8 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+#include <dix-config.h>
+
 #include "quartz/quartzCommon.h"
 #include "quartz/quartz.h"
 #include "xpr.h"
@@ -317,8 +316,6 @@ static Bool
 xprSetupScreen(int index, ScreenPtr pScreen)
 {
     // Add alpha protecting replacements for fb screen functions
-    pScreen->PaintWindowBackground = SafeAlphaPaintWindow;
-    pScreen->PaintWindowBorder = SafeAlphaPaintWindow;
 
 #ifdef RENDER
     {
diff --git a/hw/darwin/utils/Makefile.am b/hw/darwin/utils/Makefile.am
index 76cb793..911e14d 100644
--- a/hw/darwin/utils/Makefile.am
+++ b/hw/darwin/utils/Makefile.am
@@ -8,6 +8,4 @@ man1_MANS = dumpkeymap.man
 
 EXTRA_DIST = \
 	     README.txt \
-	     event_status_driver.h \
 	     dumpkeymap.man
-
diff --git a/hw/darwin/utils/dumpkeymap.c b/hw/darwin/utils/dumpkeymap.c
index 6a8b8b1..0c8bdcd 100644
--- a/hw/darwin/utils/dumpkeymap.c
+++ b/hw/darwin/utils/dumpkeymap.c
@@ -143,7 +143,7 @@
 #include <string.h>
 #include <sys/stat.h>
 #if !defined(DUMPKEYMAP_FILE_ONLY)
-#include "event_status_driver.h"
+#include <IOKit/hidsystem/event_status_driver.h>
 #endif
 
 #define PROG_NAME "dumpkeymap"
diff --git a/hw/darwin/utils/event_status_driver.h b/hw/darwin/utils/event_status_driver.h
deleted file mode 100644
index 8948f33..0000000
--- a/hw/darwin/utils/event_status_driver.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
- * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- * 
- * @APPLE_LICENSE_HEADER_END@
- */
-/******************************************************************************
-	event_status_driver.h
-	API for the events status driver.
-	This file contains public API.
-	mpaque 11Oct91
-	
-	Copyright 1991 NeXT Computer, Inc.
-	
-	Modified:
-	
-******************************************************************************/
-
-#ifndef _DRIVERS_EVENT_STATUS_DRIVER_
-#define _DRIVERS_EVENT_STATUS_DRIVER_
-
-__BEGIN_DECLS
-
-#include <mach/port.h>
-#include <IOKit/hidsystem/IOLLEvent.h>
-#include <IOKit/hidsystem/IOHIDTypes.h>
-#include <AvailabilityMacros.h> 
-
-/*
- * Event System Handle:
- *
- * Information used by the system between calls to NXOpenEventSystem and
- * NXCloseEventSystem.  The application should not
- * access any of the elements of this structure.
- */
-typedef mach_port_t NXEventHandle;
-
-/* Open and Close */
-NXEventHandle NXOpenEventStatus(void);
-void NXCloseEventStatus(NXEventHandle handle);
-
-/* Status */
-extern NXEventSystemInfoType NXEventSystemInfo(NXEventHandle handle,
-				char *flavor,
-				int *evs_info,
-				unsigned int *evs_info_cnt);
-/* Keyboard */
-extern void NXSetKeyRepeatInterval(NXEventHandle handle, double seconds);
-extern double NXKeyRepeatInterval(NXEventHandle handle);
-extern void NXSetKeyRepeatThreshold(NXEventHandle handle, double threshold);
-extern double NXKeyRepeatThreshold(NXEventHandle handle);
-extern void NXResetKeyboard(NXEventHandle handle);
-
-/* Mouse */
-extern void NXSetClickTime(NXEventHandle handle, double seconds);
-extern double NXClickTime(NXEventHandle handle);
-extern void NXSetClickSpace(NXEventHandle handle, _NXSize_ *area);
-extern void NXGetClickSpace(NXEventHandle handle, _NXSize_ *area);
-extern void NXResetMouse(NXEventHandle handle);
-
-/* DEPRECATED API */
-
-/* NXIdleTime has been deprecated as this API does not take into account
-   events posted through the CG API set.  Instead, we strongly encourage 
-   developers to make use of the CGSSecondsSinceLastInputEvent API. */
-extern double NXIdleTime(NXEventHandle handle)
-AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4;
-
-/* These methods are NOT supported.   */
-extern NXKeyMapping *NXSetKeyMapping(NXEventHandle h, NXKeyMapping *keymap)
-AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4;
-
-extern int NXKeyMappingLength(NXEventHandle handle)
-AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4;
-
-extern NXKeyMapping *NXGetKeyMapping(NXEventHandle h, NXKeyMapping *keymap)
-AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4;
-
-/* These methods are NOT supported and will return NULL values.   */
-extern void NXSetMouseScaling(NXEventHandle handle, NXMouseScaling *scaling)
-AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4;
-
-extern void NXGetMouseScaling(NXEventHandle handle, NXMouseScaling *scaling)
-AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4;
-
-extern void NXSetAutoDimThreshold(NXEventHandle handle, double seconds)
-AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4;
-
-extern double NXAutoDimThreshold(NXEventHandle handle)
-AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4;
-
-extern double NXAutoDimTime(NXEventHandle handle)
-AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4;
-
-extern void NXSetAutoDimState(NXEventHandle handle, boolean_t dimmed)
-AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4;
-
-extern boolean_t NXAutoDimState(NXEventHandle handle)
-AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4;
-
-extern void NXSetAutoDimBrightness(NXEventHandle handle, double level)
-AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4;
-
-extern double NXAutoDimBrightness(NXEventHandle handle)
-AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4;
-
-extern void NXSetScreenBrightness(NXEventHandle handle, double level)
-AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4;
-
-extern double NXScreenBrightness(NXEventHandle handle)
-AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4;
-
-/* END DEPRECATED API */
-
-__END_DECLS
-
-#endif /*_DRIVERS_EVENT_STATUS_DRIVER_ */
-
commit fa5f25482c11ac6ae51e591a1cb7d372e0598a8a
Author: Jeremy Huddleston <jeremy at tifa.local>
Date:   Thu Nov 22 13:53:00 2007 -0800

    Rootless: Imported changes made in xorg-server-1.2-apple branch
    (cherry picked from commit a751bc12bee1d4d2ed35e3a0c64d9c8c9bf30a82)

diff --git a/miext/rootless/safeAlpha/safeAlphaPicture.c b/miext/rootless/safeAlpha/safeAlphaPicture.c
index 0ed2f3e..8f66315 100644
--- a/miext/rootless/safeAlpha/safeAlphaPicture.c
+++ b/miext/rootless/safeAlpha/safeAlphaPicture.c
@@ -46,6 +46,7 @@
 #include "fbpict.h"
 #include "safeAlpha.h"
 #include "rootlessCommon.h"
+# define mod(a,b)	((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b))
 
 /* Optimized version of fbCompositeSolidMask_nx8x8888 */
 void
@@ -133,68 +134,78 @@ SafeAlphaCompositeSolidMask_nx8x8888(
 
 void
 SafeAlphaComposite (CARD8           op,
-		    PicturePtr      pSrc,
-		    PicturePtr      pMask,
-		    PicturePtr      pDst,
-		    INT16           xSrc,
-		    INT16           ySrc,
-		    INT16           xMask,
-		    INT16           yMask,
-		    INT16           xDst,
-		    INT16           yDst,
-		    CARD16          width,
-		    CARD16          height)
+                    PicturePtr      pSrc,
+                    PicturePtr      pMask,
+                    PicturePtr      pDst,
+                    INT16           xSrc,
+                    INT16           ySrc,
+                    INT16           xMask,
+                    INT16           yMask,
+                    INT16           xDst,
+                    INT16           yDst,
+                    CARD16          width,
+                    CARD16          height)
 {
-    int oldDepth = pDst->pDrawable->depth;
-    int oldFormat = pDst->format;
+  if (!pSrc) {
+    ErrorF("SafeAlphaComposite: pSrc must not be null!\n");
+    return;
+  }
+
+  if (!pDst) {
+    ErrorF("SafeAlphaComposite: pDst must not be null!\n");
+    return;
+  }
+  
+  int oldDepth = pDst->pDrawable->depth;
+  int oldFormat = pDst->format;
     
-    /*
-     * We can use the more optimized fbpict code, but it sets bits above
-     * the depth to zero. Temporarily adjust destination depth if needed.
-     */
-    if (pDst->pDrawable->type == DRAWABLE_WINDOW
-	&& pDst->pDrawable->depth == 24
-	&& pDst->pDrawable->bitsPerPixel == 32)
+  /*
+   * We can use the more optimized fbpict code, but it sets bits above
+   * the depth to zero. Temporarily adjust destination depth if needed.
+   */
+  if (pDst->pDrawable->type == DRAWABLE_WINDOW
+        && pDst->pDrawable->depth == 24
+      && pDst->pDrawable->bitsPerPixel == 32)
     {
-	pDst->pDrawable->depth = 32;
+      pDst->pDrawable->depth = 32;
     }
     
-    /* For rootless preserve the alpha in x8r8g8b8 which really is
-     * a8r8g8b8
-     */
-    if (oldFormat == PICT_x8r8g8b8)
+  /* For rootless preserve the alpha in x8r8g8b8 which really is
+   * a8r8g8b8
+   */
+  if (oldFormat == PICT_x8r8g8b8)
     {
-        pDst->format = PICT_a8r8g8b8;
+      pDst->format = PICT_a8r8g8b8;
     }
     
-    if (pSrc->pDrawable && pMask->pDrawable &&
-	!pSrc->transform && !pMask->transform &&
-	!pSrc->alphaMap && !pMask->alphaMap &&
-	!pMask->repeat && !pMask->componentAlpha && !pDst->alphaMap &&
-	pMask->format == PICT_a8 &&
-	pSrc->repeatType == RepeatNormal && 
-	pSrc->pDrawable->width == 1 &&
-	pSrc->pDrawable->height == 1 &&
-	(pDst->format == PICT_a8r8g8b8 ||
-	 pDst->format == PICT_x8r8g8b8 ||
-	 pDst->format == PICT_a8b8g8r8 ||
-	 pDst->format == PICT_x8b8g8r8))
+  if (pSrc->pDrawable && pMask && pMask->pDrawable &&
+        !pSrc->transform && !pMask->transform &&
+        !pSrc->alphaMap && !pMask->alphaMap &&
+        !pMask->repeat && !pMask->componentAlpha && !pDst->alphaMap &&
+        pMask->format == PICT_a8 &&
+       pSrc->repeatType == RepeatNormal && 
+        pSrc->pDrawable->width == 1 &&
+        pSrc->pDrawable->height == 1 &&
+      (pDst->format == PICT_a8r8g8b8 ||
+         pDst->format == PICT_x8r8g8b8 ||
+         pDst->format == PICT_a8b8g8r8 ||
+       pDst->format == PICT_x8b8g8r8))
     {
-	fbWalkCompositeRegion (op, pSrc, pMask, pDst,
-			       xSrc, ySrc, xMask, yMask, xDst, yDst,
-			       width, height,
-			       TRUE /* srcRepeat */,
-			       FALSE /* maskRepeat */,
-			       SafeAlphaCompositeSolidMask_nx8x8888);
+      fbWalkCompositeRegion (op, pSrc, pMask, pDst,
+			     xSrc, ySrc, xMask, yMask, xDst, yDst,
+			     width, height,
+			     TRUE /* srcRepeat */,
+			     FALSE /* maskRepeat */,
+			     SafeAlphaCompositeSolidMask_nx8x8888);
     }
-    else
+  else
     {
-	fbComposite (op, pSrc, pMask, pDst,
-		     xSrc, ySrc, xMask, yMask, xDst, yDst, width, height);
+      fbComposite (op, pSrc, pMask, pDst,
+		   xSrc, ySrc, xMask, yMask, xDst, yDst, width, height);
     }
 
-    pDst->pDrawable->depth = oldDepth;
-    pDst->format = oldFormat;
+  pDst->pDrawable->depth = oldDepth;
+  pDst->format = oldFormat;
 }
 
 #endif /* RENDER */
commit d045981457062545619df31a7ce4de3e49d328fe
Author: Jeremy Huddleston <jeremy at tifa.local>
Date:   Thu Nov 22 13:55:03 2007 -0800

    Rootless: Added missing includes.
    (cherry picked from commit f6a4c10636268669c889c05bae52a2f8579e7b80)

diff --git a/miext/rootless/rootlessCommon.h b/miext/rootless/rootlessCommon.h
index d3f242e..62524b9 100644
--- a/miext/rootless/rootlessCommon.h
+++ b/miext/rootless/rootlessCommon.h
@@ -39,6 +39,10 @@
 #include "rootless.h"
 #include "fb.h"
 
+#ifdef SHAPE
+#include "scrnintstr.h"
+#endif /* SHAPE */
+
 #ifdef RENDER
 #include "picturestr.h"
 #endif
commit b436b1cfbb0d95fefb76374e2dd646dd64c0e4de
Author: Jeremy Huddleston <jeremy at tifa.local>
Date:   Thu Nov 22 12:21:59 2007 -0800

    Rootless: Pulled in changes from fb{Blt,Fill} into rl{Blt,Fill}
    (cherry picked from commit 4e18c626350c7c2e0fb540aa64a98957699f3abe)

diff --git a/miext/rootless/accel/rlBlt.c b/miext/rootless/accel/rlBlt.c
index 2cf72eb..b5fe740 100644
--- a/miext/rootless/accel/rlBlt.c
+++ b/miext/rootless/accel/rlBlt.c
@@ -32,10 +32,22 @@
 #endif
 
 #include <stddef.h> /* For NULL */
+#include <string.h>
 #include "fb.h"
 #include "rootlessCommon.h"
 #include "rlAccel.h"
 
+#define InitializeShifts(sx,dx,ls,rs) { \
+    if (sx != dx) { \
+	if (sx > dx) { \
+	    ls = sx - dx; \
+	    rs = FB_UNIT - ls; \
+	} else { \
+	    rs = dx - sx; \
+	    ls = FB_UNIT - rs; \
+	} \
+    } \
+}
 
 void
 rlBlt (FbBits   *srcLine,
@@ -74,6 +86,29 @@ rlBlt (FbBits   *srcLine,
 	return;
     }
 #endif
+
+    if (alu == GXcopy && pm == FB_ALLONES && !reverse &&
+            !(srcX & 7) && !(dstX & 7) && !(width & 7)) {
+        int i;
+        CARD8 *src = (CARD8 *) srcLine;
+        CARD8 *dst = (CARD8 *) dstLine;
+        
+        srcStride *= sizeof(FbBits);
+        dstStride *= sizeof(FbBits);
+        width >>= 3;
+        src += (srcX >> 3);
+        dst += (dstX >> 3);
+
+        if (!upsidedown)
+            for (i = 0; i < height; i++)
+                memcpy(dst + i * dstStride, src + i * srcStride, width);
+        else
+            for (i = height - 1; i >= 0; i--)
+                memcpy(dst + i * dstStride, src + i * srcStride, width);
+
+        return;
+    }
+
     FbInitializeMergeRop(alu, pm);
     destInvarient = FbDestInvarientMergeRop();
     if (upsidedown)
@@ -325,9 +360,12 @@ rlBlt (FbBits   *srcLine,
 		    bits1 = *src++;
 		if (startmask)
 		{
-		    bits = FbScrLeft(bits1, leftShift);
-		    bits1 = *src++;
-		    bits |= FbScrRight(bits1, rightShift);
+		    bits = FbScrLeft(bits1, leftShift); 
+		    if (FbScrLeft(startmask, rightShift))
+		    {
+			bits1 = *src++;
+			bits |= FbScrRight(bits1, rightShift);
+		    }
 		    FbDoLeftMaskByteMergeRop (dst, bits, startbyte, startmask);
 		    dst++;
 		}
diff --git a/miext/rootless/accel/rlFill.c b/miext/rootless/accel/rlFill.c
index 0d0d012..a80c776 100644
--- a/miext/rootless/accel/rlFill.c
+++ b/miext/rootless/accel/rlFill.c
@@ -89,7 +89,7 @@ rlFill (DrawablePtr pDrawable,
 		    dstBpp,
 		    
 		    (pGC->patOrg.x + pDrawable->x + dstXoff),
-		    pGC->patOrg.y + pDrawable->y + dstYoff - y);
+		    pGC->patOrg.y + pDrawable->y - y);
 	}
 	else
 	{
@@ -126,7 +126,7 @@ rlFill (DrawablePtr pDrawable,
 		       fgand, fgxor,
 		       bgand, bgxor,
 		       pGC->patOrg.x + pDrawable->x + dstXoff,
-		       pGC->patOrg.y + pDrawable->y + dstYoff - y);
+		       pGC->patOrg.y + pDrawable->y - y);
 	}
 	break;
     }
@@ -154,7 +154,7 @@ rlFill (DrawablePtr pDrawable,
 		pPriv->pm,
 		dstBpp,
 		(pGC->patOrg.x + pDrawable->x + dstXoff) * dstBpp,
-		pGC->patOrg.y + pDrawable->y + dstYoff - y);
+		pGC->patOrg.y + pDrawable->y - y);
 	break;
     }
     }
commit e261f829e423547b719a25f8773ee249c1f84adb
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Tue Nov 20 16:15:59 2007 -0800

    DIX: Remove remaining alloca calls

diff --git a/dix/dispatch.c b/dix/dispatch.c
index b4e8787..1cb0423 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -406,7 +406,7 @@ Dispatch(void)
     InitSelections();
     nClients = 0;
 
-    clientReady = (int *) ALLOCATE_LOCAL(sizeof(int) * MaxClients);
+    clientReady = (int *) xalloc(sizeof(int) * MaxClients);
     if (!clientReady)
 	return;
 
@@ -535,7 +535,7 @@ Dispatch(void)
     ddxBeforeReset ();
 #endif
     KillAllClients();
-    DEALLOCATE_LOCAL(clientReady);
+    xfree(clientReady);
     dispatchException &= ~DE_RESET;
 #ifdef XSERVER_DTRACE
     FreeRequestNames();
@@ -919,7 +919,7 @@ ProcQueryTree(ClientPtr client)
     {
 	int curChild = 0;
 
-	childIDs = (Window *) ALLOCATE_LOCAL(numChildren * sizeof(Window));
+	childIDs = (Window *) xalloc(numChildren * sizeof(Window));
 	if (!childIDs)
 	    return BadAlloc;
 	for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib)
@@ -934,7 +934,7 @@ ProcQueryTree(ClientPtr client)
     {
     	client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
 	WriteSwappedDataToClient(client, numChildren * sizeof(Window), childIDs);
-	DEALLOCATE_LOCAL(childIDs);
+	xfree(childIDs);
     }
 
     return(client->noClientException);
@@ -2619,7 +2619,7 @@ ProcListInstalledColormaps(ClientPtr client)
         return rc;
 
     preply = (xListInstalledColormapsReply *) 
-		ALLOCATE_LOCAL(sizeof(xListInstalledColormapsReply) +
+		xalloc(sizeof(xListInstalledColormapsReply) +
 		     pWin->drawable.pScreen->maxInstalledCmaps *
 		     sizeof(Colormap));
     if(!preply)
@@ -2634,7 +2634,7 @@ ProcListInstalledColormaps(ClientPtr client)
     WriteReplyToClient(client, sizeof (xListInstalledColormapsReply), preply);
     client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
     WriteSwappedDataToClient(client, nummaps * sizeof(Colormap), &preply[1]);
-    DEALLOCATE_LOCAL(preply);
+    xfree(preply);
     return(client->noClientException);
 }
 
@@ -2761,7 +2761,7 @@ ProcAllocColorCells (ClientPtr client)
 	}
 	nmasks = stuff->planes;
 	length = ((long)npixels + (long)nmasks) * sizeof(Pixel);
-	ppixels = (Pixel *)ALLOCATE_LOCAL(length);
+	ppixels = (Pixel *)xalloc(length);
 	if(!ppixels)
             return(BadAlloc);
 	pmasks = ppixels + npixels;
@@ -2769,7 +2769,7 @@ ProcAllocColorCells (ClientPtr client)
 	if( (retval = AllocColorCells(client->index, pcmp, npixels, nmasks, 
 				    (Bool)stuff->contiguous, ppixels, pmasks)) )
 	{
-	    DEALLOCATE_LOCAL(ppixels);
+	    xfree(ppixels);
             if (client->noClientException != Success)
                 return(client->noClientException);
 	    else
@@ -2788,7 +2788,7 @@ ProcAllocColorCells (ClientPtr client)
 	    client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
 	    WriteSwappedDataToClient(client, length, ppixels);
 	}
-	DEALLOCATE_LOCAL(ppixels);
+	xfree(ppixels);
         return (client->noClientException);        
     }
     else
@@ -2829,7 +2829,7 @@ ProcAllocColorPlanes(ClientPtr client)
 	acpr.sequenceNumber = client->sequence;
 	acpr.nPixels = npixels;
 	length = (long)npixels * sizeof(Pixel);
-	ppixels = (Pixel *)ALLOCATE_LOCAL(length);
+	ppixels = (Pixel *)xalloc(length);
 	if(!ppixels)
             return(BadAlloc);
 	if( (retval = AllocColorPlanes(client->index, pcmp, npixels,
@@ -2837,7 +2837,7 @@ ProcAllocColorPlanes(ClientPtr client)
 	    (Bool)stuff->contiguous, ppixels,
 	    &acpr.redMask, &acpr.greenMask, &acpr.blueMask)) )
 	{
-            DEALLOCATE_LOCAL(ppixels);
+            xfree(ppixels);
             if (client->noClientException != Success)
                 return(client->noClientException);
 	    else
@@ -2852,7 +2852,7 @@ ProcAllocColorPlanes(ClientPtr client)
 	    client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
 	    WriteSwappedDataToClient(client, length, ppixels);
 	}
-	DEALLOCATE_LOCAL(ppixels);
+	xfree(ppixels);
         return (client->noClientException);        
     }
     else
@@ -2981,12 +2981,12 @@ ProcQueryColors(ClientPtr client)
 	xQueryColorsReply	qcr;
 
 	count = ((client->req_len << 2) - sizeof(xQueryColorsReq)) >> 2;
-	prgbs = (xrgb *)ALLOCATE_LOCAL(count * sizeof(xrgb));
+	prgbs = (xrgb *)xalloc(count * sizeof(xrgb));
 	if(!prgbs && count)
             return(BadAlloc);
 	if( (retval = QueryColors(pcmp, count, (Pixel *)&stuff[1], prgbs)) )
 	{
-   	    if (prgbs) DEALLOCATE_LOCAL(prgbs);
+   	    if (prgbs) xfree(prgbs);
 	    if (client->noClientException != Success)
                 return(client->noClientException);
 	    else
@@ -3005,7 +3005,7 @@ ProcQueryColors(ClientPtr client)
 	    client->pSwapReplyFunc = (ReplySwapPtr) SQColorsExtend;
 	    WriteSwappedDataToClient(client, count * sizeof(xrgb), prgbs);
 	}
-	if (prgbs) DEALLOCATE_LOCAL(prgbs);
+	if (prgbs) xfree(prgbs);
 	return(client->noClientException);
 	
     }
commit 1b048cc5d1c5cb7b090dc115f0fe0c1d74924c11
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Tue Nov 20 16:02:02 2007 -0800

    Dix: Re-ebable ErrorF reporting of incorrect refcount in FreeFontPath

diff --git a/dix/dixfonts.c b/dix/dixfonts.c
index 355ef8a..c21b3ec 100644
--- a/dix/dixfonts.c
+++ b/dix/dixfonts.c
@@ -1628,9 +1628,9 @@ FreeFontPath(FontPathElementPtr *list, int n, Bool force)
 		    found++;
 	    }
 	    if (list[i]->refcount != found) {
-	      /*		ErrorF("FreeFontPath: FPE \"%.*s\" refcount is %d, should be %d; fixing.\n",
+		ErrorF("FreeFontPath: FPE \"%.*s\" refcount is %d, should be %d; fixing.\n",
 		       list[i]->name_length, list[i]->name,
-		       list[i]->refcount, found); */
+		       list[i]->refcount, found);
 		list[i]->refcount = found; /* ensure it will get freed */
 	    }
 	}
commit 738a229a719747cc1b048e4de88aeedf85e83677
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Tue Nov 20 06:59:11 2007 -0800

    Various cleanups to get Xquartz to compile.

diff --git a/GL/apple/Makefile.am b/GL/apple/Makefile.am
index 4220f7f..411dfdf 100644
--- a/GL/apple/Makefile.am
+++ b/GL/apple/Makefile.am
@@ -3,7 +3,9 @@ AM_CFLAGS = -I$(top_srcdir) \
 	 -I$(top_srcdir)/GL/include \
 	 -I$(top_srcdir)/GL/mesa/glapi \
 	 -I$(top_srcdir)/hw/darwin/quartz \
-	 -I$(top_srcdir)/hw/darwin/quartz/xpr
+	 -I$(top_srcdir)/hw/darwin/quartz/xpr \
+	 -I$(top_srcdir)/miext/damage \
+	 $(PIXMAN_CFLAGS)
 
 noinst_LIBRARIES = libCGLcore.a 
 libCGLcore_a_SOURCES = indirect.c \
diff --git a/configure.ac b/configure.ac
index 21f58e1..e73d12b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -70,13 +70,16 @@ AC_ARG_WITH(dtrace, AS_HELP_STRING([--with-dtrace=PATH],
 	     [Enable dtrace probes (default: enabled if dtrace found)]),
 	     [WDTRACE=$withval], [WDTRACE=auto])
 if test "x$WDTRACE" = "xyes" -o "x$WDTRACE" = "xauto" ; then
-	AC_PATH_PROG(DTRACE, [dtrace], [not_found], [$PATH:/usr/sbin])
-	if test "x$DTRACE" = "xnot_found" ; then
-		if test "x$WDTRACE" = "xyes" ; then
-			AC_MSG_FAILURE([dtrace requested but not found])
-		fi
-		WDTRACE="no"
-	fi
+	case $host_os in
+	        darwin*) WDTRACE="no" ;;
+		*) AC_PATH_PROG(DTRACE, [dtrace], [not_found], [$PATH:/usr/sbin])
+		   if test "x$DTRACE" = "xnot_found" ; then
+			if test "x$WDTRACE" = "xyes" ; then
+				AC_MSG_FAILURE([dtrace requested but not found])
+			fi
+		   	WDTRACE="no"
+		fi ;;
+	esac
 fi
 if test "x$WDTRACE" != "xno" ; then
   AC_DEFINE(XSERVER_DTRACE, 1, 
diff --git a/hw/darwin/Makefile.am b/hw/darwin/Makefile.am
index f1740e3..4a86fa3 100644
--- a/hw/darwin/Makefile.am
+++ b/hw/darwin/Makefile.am
@@ -1,5 +1,10 @@
-AM_CFLAGS = @XORG_CFLAGS@
-AM_CPPFLAGS = @XORG_INCS@ -I$(top_srcdir)/Xext -I$(top_srcdir)/miext/rootless -DUSE_NEW_CLUT -DBUILD_DATE=\"$(BUILD_DATE)\" -DHAVE_XORG_CONFIG_H -DXFree86Server -DINXQUARTZ
+AM_CFLAGS = $(XORG_CFLAGS) $(PIXMAN_CFLAGS)
+AM_CPPFLAGS = $(XORG_INCS) -DUSE_NEW_CLUT -DBUILD_DATE=\"$(BUILD_DATE)\" -DHAVE_XORG_CONFIG_H -DXFree86Server -DINXQUARTZ \
+	-I$(top_srcdir)/fb \
+	-I$(top_srcdir)/mi \
+	-I$(top_srcdir)/miext/rootless \
+	-I$(top_srcdir)/render \
+	-I$(top_srcdir)/Xext
 
 SUBDIRS = quartz utils
 
@@ -10,7 +15,7 @@ Xquartz_SOURCES = darwin.c \
 		  darwinEvents.c \
 		  darwinKeyboard.c \
 		  darwinXinput.c \
-		  $(top_srcdir)/fb/fbcmap.c \
+		  $(top_srcdir)/fb/fbcmap_mi.c \
 		  $(top_srcdir)/mi/miinitext.c
 
 #		We should probably add these once they're working, or are these obsolete and to be removed?
@@ -41,7 +46,7 @@ Xquartz_LDADD = ./quartz/libXquartz.a \
 		$(top_builddir)/miext/rootless/librootless.la \
 		$(top_builddir)/miext/rootless/safeAlpha/libsafeAlpha.la \
 		$(top_builddir)/miext/rootless/accel/librlAccel.la \
-		$(DARWIN_LIBS) $(XSERVER_LIBS) -lXplugin
+		$(DARWIN_LIBS) $(XSERVER_LIBS) $(PIXMAN_LIBS) -lXplugin
 
 Xquartz_LDFLAGS =  -XCClinker -Objc \
 		   -Wl,-u,_miDCInitialize \
diff --git a/hw/darwin/darwin.c b/hw/darwin/darwin.c
index c721ca1..80d879b 100644
--- a/hw/darwin/darwin.c
+++ b/hw/darwin/darwin.c
@@ -362,12 +362,10 @@ static int DarwinMouseProc(
             map[3] = 3;
             map[4] = 4;
             map[5] = 5;
-            InitPointerDeviceStruct( (DevicePtr)pPointer,
-                        map,
-                        5,   // numbuttons (4 & 5 are scroll wheel)
-                        miPointerGetMotionEvents,
-		        (PtrCtrlProcPtr)NoopDDA,
-                        0 );
+            InitPointerDeviceStruct((DevicePtr)pPointer, map, 5,
+                                    GetMotionHistory,
+                                    (PtrCtrlProcPtr)NoopDDA,
+                                    GetMotionHistorySize(), 2);
 #ifdef XINPUT
             InitValuatorAxisStruct( pPointer,
                                     0,     // X axis
diff --git a/hw/darwin/quartz/Makefile.am b/hw/darwin/quartz/Makefile.am
index 4c650e6..d90b2bf 100644
--- a/hw/darwin/quartz/Makefile.am
+++ b/hw/darwin/quartz/Makefile.am
@@ -1,8 +1,13 @@
 noinst_LIBRARIES = libXQuartz.a
 
-AM_CFLAGS = @XORG_CFLAGS@
-AM_OBJCFLAGS = @XORG_CFLAGS@
-AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir)/miext/rootless @XORG_INCS@ -DXBINDIR=\"${bindir}\" -DHAS_KL_API -DHAVE_XORG_CONFIG_H
+AM_CFLAGS = $(XORG_CFLAGS) $(PIXMAN_CFLAGS)
+AM_OBJCFLAGS = $(XORG_CFLAGS) $(PIXMAN_CFLAGS)
+AM_CPPFLAGS = $(XORG_INCS) -DXBINDIR=\"${bindir}\" -DHAS_KL_API -DHAVE_XORG_CONFIG_H \
+	-I$(srcdir) -I$(srcdir)/.. \
+	-I$(top_srcdir)/fb \
+	-I$(top_srcdir)/mi \
+	-I$(top_srcdir)/miext/rootless \
+	-I$(top_srcdir)/render
 
 SUBDIRS = cr fullscreen xpr
 
diff --git a/hw/darwin/quartz/cr/Makefile.am b/hw/darwin/quartz/cr/Makefile.am
index ff6043d..03f2e24 100644
--- a/hw/darwin/quartz/cr/Makefile.am
+++ b/hw/darwin/quartz/cr/Makefile.am
@@ -1,13 +1,15 @@
 noinst_LIBRARIES = libcr.a
-AM_CFLAGS =  @XORG_CFLAGS@
-AM_OBJCFLAGS =  @XORG_CFLAGS@
+AM_CFLAGS = $(XORG_CFLAGS)
+AM_OBJCFLAGS = $(XORG_CFLAGS)
 AM_CPPFLAGS = -DDEFER_NSWINDOW \
-	   @XORG_INCS@ \
+	   $(XORG_INCS) \
 	   -I../fullscreen \
 	   -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../.. \
+	   -I$(top_srcdir)/mi \
 	   -I$(top_srcdir)/miext/rootless \
 	   -I$(top_srcdir)/miext/rootless/safeAlpha \
-	   -I$(top_srcdir)/mi
+	   -I$(top_srcdir)/render \
+	   $(PIXMAN_CFLAGS)
 
 libcr_a_SOURCES = crAppleWM.m \
 	           crFrame.m \
@@ -18,4 +20,4 @@ libcr_a_SOURCES = crAppleWM.m \
 EXTRA_DIST = \
 	cr.h \
 	XView.h 
-	
+
diff --git a/hw/darwin/quartz/fullscreen/Makefile.am b/hw/darwin/quartz/fullscreen/Makefile.am
index 5e471ad..510c0c2 100644
--- a/hw/darwin/quartz/fullscreen/Makefile.am
+++ b/hw/darwin/quartz/fullscreen/Makefile.am
@@ -1,6 +1,9 @@
 noinst_LIBRARIES = libfullscreen.a
-AM_CFLAGS = @XORG_CFLAGS@
-AM_CPPFLAGS = @XORG_INCS@ -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../.. 
+AM_CFLAGS = $(XORG_CFLAGS) $(PIXMAN_CFLAGS)
+AM_CPPFLAGS = $(XORG_INCS) -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../.. \
+	-I$(top_srcdir)/miext/damage \
+	-I$(top_srcdir)/miext/shadow \
+	-I$(top_srcdir)/mi
 
 libfullscreen_a_SOURCES = fullscreen.c \
 			   quartzCursor.c
diff --git a/hw/darwin/quartz/quartzCocoa.m b/hw/darwin/quartz/quartzCocoa.m
index 46c61dc..bff3772 100644
--- a/hw/darwin/quartz/quartzCocoa.m
+++ b/hw/darwin/quartz/quartzCocoa.m
@@ -97,7 +97,7 @@ char *QuartzReadCocoaPasteboard(void)
         char *buffer;
 
         if (! string) return NULL;
-        buffer = (char *) [string lossyCString];
+        buffer = (char *) [string UTF8String];
         text = (char *) malloc(strlen(buffer)+1);
         if (text)
             strcpy(text, buffer);
diff --git a/hw/darwin/quartz/xpr/Makefile.am b/hw/darwin/quartz/xpr/Makefile.am
index 1f19fe9..444ba5c 100644
--- a/hw/darwin/quartz/xpr/Makefile.am
+++ b/hw/darwin/quartz/xpr/Makefile.am
@@ -1,11 +1,15 @@
 noinst_LIBRARIES = libxpr.a
-AM_CFLAGS =  @XORG_CFLAGS@
-AM_CPPFLAGS = @XORG_INCS@ \
+AM_CFLAGS =  $(XORG_CFLAGS) $(PIXMAN_CFLAGS)
+AM_CPPFLAGS = $(XORG_INCS) \
 	   -DHAVE_XORG_CONFIG_H \
 	   -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../.. \
+	   -I$(top_srcdir)/fb \
+	   -I$(top_srcdir)/mi \
+	   -I$(top_srcdir)/miext \
+	   -I$(top_srcdir)/miext/damage \
 	   -I$(top_srcdir)/miext/rootless \
 	   -I$(top_srcdir)/miext/rootless/safeAlpha \
-	   -I$(top_srcdir)/miext
+	   -I$(top_srcdir)/render
 
 libxpr_a_SOURCES = \
 	appledri.c \
commit 89c4aa9d4a872d658ba82b194a4355ba7c04e061
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Tue Nov 20 05:57:15 2007 -0800

    Force --disable-Xorg when on darwin

diff --git a/configure.ac b/configure.ac
index 493a430..21f58e1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -562,7 +562,7 @@ if test "x$SETUID" = "xauto" ; then
 	   	case $host_cpu in
 		    sparc)	SETUID="no"  ;;
 		    *)		SETUID="yes" ;;
-		esac ;;
+		esac
 	esac
 	if test "x$SETUID" = xyes; then
 		touch testfile
@@ -1205,6 +1205,7 @@ if test "x$XORG" = xauto; then
 	XORG="yes"
 	case $host_os in
 		cygwin*) XORG="no" ;;
+		darwin*) XORG="no" ;;
 	esac
 fi
 AC_MSG_RESULT([$XORG])
@@ -1407,10 +1408,14 @@ dnl has it in libc), or if libdl is needed to get it.
 		Free/Open/NetBSD, Solaris, and OS X. If you are interested in porting \
 	        Xorg to your platform, please email xorg at lists.freedesktop.org.])
 		;;
-               case $host_os in
-                 darwin*) ;;
-                 *) xorg_bus_ix86pci=yes ;;
-               esac
+	esac
+        
+	case $host_cpu in
+	  i*86)
+		case $host_os in
+                  darwin*) ;;
+                  *) xorg_bus_ix86pci=yes ;;
+		esac
 		;;
 	  powerpc*)
 		case $host_os in
@@ -2101,6 +2106,7 @@ hw/xfree86/os-support/misc/Makefile
 hw/xfree86/os-support/linux/Makefile
 hw/xfree86/os-support/lynxos/Makefile
 hw/xfree86/os-support/sco/Makefile
+hw/xfree86/os-support/solaris/Makefile
 hw/xfree86/os-support/sysv/Makefile
 hw/xfree86/os-support/usl/Makefile
 hw/xfree86/parser/Makefile
commit 7f91d756acf81b00e3b2b84a593845981b25b967
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Tue Nov 20 04:49:34 2007 -0800

    Darwin: Formatting Cleanup
    To better line up with xorg-server-1.2-apple branch

diff --git a/hw/darwin/README.apple b/hw/darwin/README.apple
deleted file mode 100644
index 229ab17..0000000
--- a/hw/darwin/README.apple
+++ /dev/null
@@ -1,35 +0,0 @@
-This directory contains a port of the XDarwin code to the modular X.org
-codebase to be compiled on Darwin/OS X; this would not have been possible
-without the help of Torrey Lyons and Peter O'Gorman, to whom I am
-grateful for their patches, time and moral support.
-
-The server builds 4 targets:
-
-* XDarwin: this server runs on Darwin systems without Quartz
-  (i.e. non-OS X); it has not been well-tested.
-
-* XDarwinApp: this builds XDarwin.app, which is a full X server using
-  Quartz.  It has loadable module support for AGL and CGL, and well as
-  fullscreen and rootless support.
-
-* Xquartz: this server runs on Quartz-based systems, and is meant to
-  work with X11.app
-
-* x11app: this builds a version of Apple's X11.app using patches by
-  Torrey Lyons; most, but not all, functionality of Apple's original
-  X11.app is present in this release.
-
-Known issues:
-
-* AGL and CGL support for 3D indirect acceleration does not work;
-  indirect.c has been rewritten, but not yet integrated into this source tree.
-
-* Fullscreen mode does not work; I don't know why.
-
-* Some features in X11.app are not yet implemented; these are marked
-  with #ifdef DARWIN_DDX_MISSING in the code.
-
-* The build system code could probably be cleaned up slightly.
-
-Any patches or code contributions would be most welcome and may be
-sent to me at bbyer at apple.com.
diff --git a/hw/darwin/apple/English.lproj/main.nib/.svn/entries b/hw/darwin/apple/English.lproj/main.nib/.svn/entries
deleted file mode 100644
index 95a15f2..0000000
--- a/hw/darwin/apple/English.lproj/main.nib/.svn/entries
+++ /dev/null
@@ -1,65 +0,0 @@
-8
-
-dir
-29110
-svn+ssh://src.apple.com/svn/BSD/X11server/trunk/darwin/apple/English.lproj/main.nib
-svn+ssh://src.apple.com/svn/BSD
-
-
-
-2007-02-03T03:06:20.842932Z
-28761
-bbyer
-
-
-svn:special svn:externals svn:needs-lock
-
-
-
-
-
-
-
-
-
-
-
-e92bca22-270c-0410-9cea-e3f1106b6a1c
-
-info.nib
-file
-
-
-
-
-2007-02-27T01:00:07.000000Z
-456347804c516786b1d1339ce2ef50a2
-2007-02-03T03:06:20.842932Z
-28761
-bbyer
-
-keyedobjects.nib
-file
-
-
-
-
-2007-02-27T01:00:07.000000Z
-eb3010372b09768c846df0d996cfdd8d
-2007-02-03T03:06:20.842932Z
-28761
-bbyer
-has-props
-
-classes.nib
-file
-
-
-
-
-2007-02-27T01:00:07.000000Z
-0ae2660c3afabbd5aa02fc34712c96e6
-2007-02-03T03:06:20.842932Z
-28761
-bbyer
-
diff --git a/hw/darwin/apple/English.lproj/main.nib/.svn/format b/hw/darwin/apple/English.lproj/main.nib/.svn/format
deleted file mode 100644
index 45a4fb7..0000000
--- a/hw/darwin/apple/English.lproj/main.nib/.svn/format
+++ /dev/null
@@ -1 +0,0 @@
-8
diff --git a/hw/darwin/apple/English.lproj/main.nib/.svn/prop-base/keyedobjects.nib.svn-base b/hw/darwin/apple/English.lproj/main.nib/.svn/prop-base/keyedobjects.nib.svn-base
deleted file mode 100644
index 5e9587e..0000000
--- a/hw/darwin/apple/English.lproj/main.nib/.svn/prop-base/keyedobjects.nib.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 24
-application/octet-stream
-END
diff --git a/hw/darwin/apple/English.lproj/main.nib/.svn/text-base/classes.nib.svn-base b/hw/darwin/apple/English.lproj/main.nib/.svn/text-base/classes.nib.svn-base
deleted file mode 100644
index a82159b..0000000
--- a/hw/darwin/apple/English.lproj/main.nib/.svn/text-base/classes.nib.svn-base
+++ /dev/null
@@ -1,318 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>IBClasses</key>
-	<array>
-		<dict>
-			<key>CLASS</key>
-			<string>IBLibraryObjectTemplate</string>
-			<key>LANGUAGE</key>
-			<string>ObjC</string>
-			<key>OUTLETS</key>
-			<dict>
-				<key>draggedView</key>
-				<string>NSView</string>
-				<key>representedObject</key>
-				<string>NSObject</string>
-			</dict>
-			<key>SUPERCLASS</key>
-			<string>NSView</string>
-		</dict>
-		<dict>
-			<key>CLASS</key>
-			<string>IBInspector</string>
-			<key>LANGUAGE</key>
-			<string>ObjC</string>
-			<key>OUTLETS</key>
-			<dict>
-				<key>inspectorView</key>
-				<string>NSView</string>
-			</dict>
-			<key>SUPERCLASS</key>
-			<string>NSObject</string>
-		</dict>
-		<dict>
-			<key>CLASS</key>
-			<string>NSDateFormatter</string>
-			<key>LANGUAGE</key>
-			<string>ObjC</string>
-			<key>SUPERCLASS</key>
-			<string>NSFormatter</string>
-		</dict>
-		<dict>
-			<key>ACTIONS</key>
-			<dict>
-				<key>apps_table_cancel</key>
-				<string>id</string>
-				<key>apps_table_delete</key>
-				<string>id</string>
-				<key>apps_table_done</key>
-				<string>id</string>
-				<key>apps_table_duplicate</key>
-				<string>id</string>
-				<key>apps_table_new</key>
-				<string>id</string>
-				<key>apps_table_show</key>
-				<string>id</string>
-				<key>bring_to_front</key>
-				<string>id</string>
-				<key>close_window</key>
-				<string>id</string>
-				<key>enable_fullscreen_changed</key>
-				<string>id</string>
-				<key>minimize_window</key>
-				<string>id</string>
-				<key>next_window</key>
-				<string>id</string>
-				<key>prefs_changed</key>
-				<string>id</string>
-				<key>prefs_show</key>
-				<string>id</string>
-				<key>previous_window</key>
-				<string>id</string>
-				<key>toggle_fullscreen</key>
-				<string>id</string>
-				<key>x11_help</key>
-				<string>id</string>
-				<key>zoom_window</key>
-				<string>id</string>
-			</dict>
-			<key>CLASS</key>
-			<string>X11Controller</string>
-			<key>LANGUAGE</key>
-			<string>ObjC</string>
-			<key>OUTLETS</key>
-			<dict>
-				<key>apps_separator</key>
-				<string>id</string>
-				<key>apps_table</key>
-				<string>id</string>
-				<key>depth</key>
-				<string>id</string>
-				<key>dock_apps_menu</key>
-				<string>id</string>
-				<key>dock_menu</key>
-				<string>id</string>
-				<key>dock_window_separator</key>
-				<string>id</string>
-				<key>enable_auth</key>
-				<string>id</string>
-				<key>enable_fullscreen</key>
-				<string>id</string>
-				<key>enable_keyequivs</key>
-				<string>id</string>
-				<key>enable_tcp</key>
-				<string>id</string>
-				<key>fake_buttons</key>
-				<string>id</string>
-				<key>prefs_panel</key>
-				<string>id</string>
-				<key>sync_keymap</key>
-				<string>id</string>
-				<key>toggle_fullscreen_item</key>
-				<string>id</string>
-				<key>use_sysbeep</key>
-				<string>id</string>
-				<key>window_separator</key>
-				<string>id</string>
-				<key>x11_about_item</key>
-				<string>id</string>
-			</dict>
-			<key>SUPERCLASS</key>
-			<string>NSObject</string>
-		</dict>
-		<dict>
-			<key>CLASS</key>
-			<string>NSNumberFormatter</string>
-			<key>LANGUAGE</key>
-			<string>ObjC</string>
-			<key>SUPERCLASS</key>
-			<string>NSFormatter</string>
-		</dict>
-		<dict>
-			<key>CLASS</key>
-			<string>NSFormatter</string>
-			<key>LANGUAGE</key>
-			<string>ObjC</string>
-			<key>SUPERCLASS</key>
-			<string>NSObject</string>
-		</dict>
-		<dict>
-			<key>ACTIONS</key>
-			<dict>
-				<key>alignCenter:</key>
-				<string>id</string>
-				<key>alignJustified:</key>
-				<string>id</string>
-				<key>alignLeft:</key>
-				<string>id</string>
-				<key>alignRight:</key>
-				<string>id</string>
-				<key>arrangeInFront:</key>
-				<string>id</string>
-				<key>centerSelectionInVisibleArea:</key>
-				<string>id</string>
-				<key>changeFont:</key>
-				<string>id</string>
-				<key>checkSpelling:</key>
-				<string>id</string>
-				<key>clear:</key>
-				<string>id</string>
-				<key>clearRecentDocuments:</key>
-				<string>id</string>
-				<key>complete:</key>
-				<string>id</string>
-				<key>copy:</key>
-				<string>id</string>
-				<key>copyFont:</key>
-				<string>id</string>
-				<key>copyRuler:</key>
-				<string>id</string>
-				<key>cut:</key>
-				<string>id</string>
-				<key>delete:</key>
-				<string>id</string>
-				<key>deminiaturize:</key>
-				<string>id</string>
-				<key>fax:</key>
-				<string>id</string>
-				<key>hide:</key>
-				<string>id</string>
-				<key>hideOtherApplications:</key>
-				<string>id</string>
-				<key>loosenKerning:</key>
-				<string>id</string>
-				<key>lowerBaseline:</key>
-				<string>id</string>
-				<key>makeKeyAndOrderFront:</key>
-				<string>id</string>
-				<key>miniaturize:</key>
-				<string>id</string>
-				<key>newDocument:</key>
-				<string>id</string>
-				<key>openDocument:</key>
-				<string>id</string>
-				<key>orderBack:</key>
-				<string>id</string>
-				<key>orderFront:</key>
-				<string>id</string>
-				<key>orderFrontColorPanel:</key>
-				<string>id</string>
-				<key>orderFrontHelpPanel:</key>
-				<string>id</string>
-				<key>orderOut:</key>
-				<string>id</string>
-				<key>outline:</key>
-				<string>id</string>
-				<key>paste:</key>
-				<string>id</string>
-				<key>pasteAsPlainText:</key>
-				<string>id</string>
-				<key>pasteAsRichText:</key>
-				<string>id</string>
-				<key>pasteFont:</key>
-				<string>id</string>
-				<key>pasteRuler:</key>
-				<string>id</string>
-				<key>pause:</key>
-				<string>id</string>
-				<key>performClose:</key>
-				<string>id</string>
-				<key>performFindPanelAction:</key>
-				<string>id</string>
-				<key>performMiniaturize:</key>
-				<string>id</string>
-				<key>performZoom:</key>
-				<string>id</string>
-				<key>play:</key>
-				<string>id</string>
-				<key>print:</key>
-				<string>id</string>
-				<key>printDocument:</key>
-				<string>id</string>
-				<key>raiseBaseline:</key>
-				<string>id</string>
-				<key>record:</key>
-				<string>id</string>
-				<key>redo:</key>
-				<string>id</string>
-				<key>resume:</key>
-				<string>id</string>
-				<key>revertDocumentToSaved:</key>
-				<string>id</string>
-				<key>run:</key>
-				<string>id</string>
-				<key>runPageLayout:</key>
-				<string>id</string>
-				<key>runToolbarCustomizationPalette:</key>
-				<string>id</string>
-				<key>saveAllDocuments:</key>
-				<string>id</string>
-				<key>saveDocument:</key>
-				<string>id</string>
-				<key>saveDocumentAs:</key>
-				<string>id</string>
-				<key>saveDocumentTo:</key>
-				<string>id</string>
-				<key>selectAll:</key>
-				<string>id</string>
-				<key>selectText:</key>
-				<string>id</string>
-				<key>showGuessPanel:</key>
-				<string>id</string>
-				<key>showHelp:</key>
-				<string>id</string>
-				<key>start:</key>
-				<string>id</string>
-				<key>startSpeaking:</key>
-				<string>id</string>
-				<key>stop:</key>
-				<string>id</string>
-				<key>stopSpeaking:</key>
-				<string>id</string>
-				<key>subscript:</key>
-				<string>id</string>
-				<key>superscript:</key>
-				<string>id</string>
-				<key>terminate:</key>
-				<string>id</string>
-				<key>tightenKerning:</key>
-				<string>id</string>
-				<key>toggleContinuousSpellChecking:</key>
-				<string>id</string>
-				<key>toggleRuler:</key>
-				<string>id</string>
-				<key>toggleToolbarShown:</key>
-				<string>id</string>
-				<key>turnOffKerning:</key>
-				<string>id</string>
-				<key>turnOffLigatures:</key>
-				<string>id</string>
-				<key>underline:</key>
-				<string>id</string>
-				<key>undo:</key>
-				<string>id</string>
-				<key>unhideAllApplications:</key>
-				<string>id</string>
-				<key>unscript:</key>
-				<string>id</string>
-				<key>useAllLigatures:</key>
-				<string>id</string>
-				<key>useStandardKerning:</key>
-				<string>id</string>
-				<key>useStandardLigatures:</key>
-				<string>id</string>
-			</dict>
-			<key>CLASS</key>
-			<string>FirstResponder</string>
-			<key>LANGUAGE</key>
-			<string>ObjC</string>
-			<key>SUPERCLASS</key>
-			<string>NSObject</string>
-		</dict>
-	</array>
-	<key>IBVersion</key>
-	<integer>1</integer>
-</dict>
-</plist>
diff --git a/hw/darwin/apple/English.lproj/main.nib/.svn/text-base/info.nib.svn-base b/hw/darwin/apple/English.lproj/main.nib/.svn/text-base/info.nib.svn-base
deleted file mode 100644
index 88bc626..0000000
--- a/hw/darwin/apple/English.lproj/main.nib/.svn/text-base/info.nib.svn-base
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>IBFramework Version</key>
-	<string>588</string>
-	<key>IBOpenObjects</key>
-	<array>
-		<integer>244</integer>
-		<integer>29</integer>
-		<integer>423</integer>
-	</array>
-	<key>IBSystem Version</key>
-	<string>9A356</string>
-	<key>targetFramework</key>
-	<string>IBCocoaFramework</string>
-</dict>
-</plist>
diff --git a/hw/darwin/apple/English.lproj/main.nib/.svn/text-base/keyedobjects.nib.svn-base b/hw/darwin/apple/English.lproj/main.nib/.svn/text-base/keyedobjects.nib.svn-base
deleted file mode 100644
index 8b31450..0000000
Binary files a/hw/darwin/apple/English.lproj/main.nib/.svn/text-base/keyedobjects.nib.svn-base and /dev/null differ
diff --git a/hw/darwin/apple/X11.icns b/hw/darwin/apple/X11.icns
index 4c47177..d770e61 100644
Binary files a/hw/darwin/apple/X11.icns and b/hw/darwin/apple/X11.icns differ
diff --git a/hw/darwin/darwin.h b/hw/darwin/darwin.h
index 392bb43..14443b9 100644
--- a/hw/darwin/darwin.h
+++ b/hw/darwin/darwin.h
@@ -58,10 +58,6 @@ Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr);
 void DarwinEQEnqueue(const xEvent *e);
 void DarwinEQPointerPost(xEvent *e);
 void DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX);
-void DarwinPokeEQ(void);
-void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int pointer_y);
-void DarwinSendKeyboardEvents(int ev_type, int keycode);
-void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y);
 
 // From darwinKeyboard.c
 int DarwinModifierNXKeyToNXKeycode(int key, int side);
diff --git a/hw/darwin/quartz/quartzCursor.c b/hw/darwin/quartz/quartzCursor.c
index c9d125f..a5483ee 100644
--- a/hw/darwin/quartz/quartzCursor.c
+++ b/hw/darwin/quartz/quartzCursor.c
@@ -91,9 +91,7 @@ static pthread_cond_t cursorCondition;
         /* Acquire lock and tell the main thread to change cursor */    \
         pthread_mutex_lock(&cursorMutex);                               \
         currentCursor = (CCrsrHandle) (cursorH);                        \
-#ifndef INXQUARTZ
         QuartzMessageMainThread(kQuartzCursorUpdate, NULL, 0);          \
-#endif
                                                                         \
         /* Wait for the main thread to change the cursor */             \
         pthread_cond_wait(&cursorCondition, &cursorMutex);              \
diff --git a/hw/darwin/quartz/xpr/dri.c b/hw/darwin/quartz/xpr/dri.c
index 13943fd..70efca7 100644
--- a/hw/darwin/quartz/xpr/dri.c
+++ b/hw/darwin/quartz/xpr/dri.c
@@ -33,9 +33,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *   Rickard E. (Rik) Faith <faith at valinux.com>
  *
  */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
 
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
diff --git a/hw/darwin/quartz/xpr/xprScreen.c b/hw/darwin/quartz/xpr/xprScreen.c
index 5b57124..c8e3005 100644
--- a/hw/darwin/quartz/xpr/xprScreen.c
+++ b/hw/darwin/quartz/xpr/xprScreen.c
@@ -111,7 +111,7 @@ eventHandler(unsigned int type, const void *arg,
 }
 
 /*
- * displayScreenBounds
+ * displayAtIndex
  *  Return the display ID for a particular display index.
  */
 static CGDirectDisplayID
commit 8c533443f802724641f063395fa14b4f5f166384
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Tue Nov 20 04:10:45 2007 -0800

    Darwin: Sync up darwinEvents.c to match what is in use in xorg-server-apple-1.2

diff --git a/hw/darwin/darwinEvents.c b/hw/darwin/darwinEvents.c
index ee08233..4201e0e 100644
--- a/hw/darwin/darwinEvents.c
+++ b/hw/darwin/darwinEvents.c
@@ -1,9 +1,9 @@
 /*
-Darwin event queue and event handling
-
-Copyright 2007 Apple Inc.
-Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
+ * Darwin event queue and event handling
+ */
+/*
 Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved.
+Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
 
 This file is based on mieq.c by Keith Packard,
 which contains the following copyright:
@@ -60,10 +60,6 @@ typedef struct _Event {
     ScreenPtr   pScreen;
 } EventRec, *EventPtr;
 
-int input_check_zero, input_check_flag;
-
-static int old_flags = 0;  // last known modifier state
-
 typedef struct _EventQueue {
     HWEventQueueType    head, tail; /* long for SetInputCheck */
     CARD32      lastEventTime;      /* to avoid time running backwards */
@@ -75,27 +71,8 @@ typedef struct _EventQueue {
 } EventQueueRec, *EventQueuePtr;
 
 static EventQueueRec darwinEventQueue;
-xEvent *darwinEvents;
-extern KeyClassPtr darwinKeyc;
-#define KeyPressed(k) (darwinKeyc->down[k >> 3] & (1 << (k & 7)))
-
-/*
- * DarwinPressModifierMask
- *  Press or release the given modifier key, specified by its mask.
- */
-static void DarwinPressModifierMask(
-    int pressed,				    
-    int mask)       // one of NX_*MASK constants
-{
-    int key = DarwinModifierNXMaskToNXKey(mask);
-
-    DEBUG_LOG("DarwinPressModifierMask(%p, %x, %d)\n", xe, mask, key);
-    if (key != -1) {
-        int keycode = DarwinModifierNXKeyToNXKeycode(key, 0);
-        if (keycode != 0)
-	  DarwinSendKeyboardEvents(pressed, keycode);
-    }
-}
+extern darwinKeyboardInfo keyInfo;
+#define KeyPressed(k) (((DeviceIntPtr)darwinEventQueue.pKbd)->key->down[k >> 3] & (1 << (k & 7)))
 
 #ifdef NX_DEVICELCTLKEYMASK
 #define CONTROL_MASK(flags) (flags & (NX_DEVICELCTLKEYMASK|NX_DEVICERCTLKEYMASK))
@@ -224,6 +201,7 @@ static void DarwinPressModifierMask(
  *  Send events to update the modifier state.
  */
 static void DarwinUpdateModifiers(
+    xEvent *xe,         // event template with time and mouse position set
     int pressed,        // KeyPress or KeyRelease
     unsigned int flags )         // modifier flags that have changed
 {
@@ -301,8 +279,8 @@ void DarwinReleaseModifiers(void) {
  *  simulate a button 2 press instead of Command-button 2.
  */
 static void DarwinSimulateMouseClick(
-    int pointer_x,
-    int pointer_y,
+    xEvent *xe,         // event template with time and
+                        // mouse position filled in
     int whichButton,    // mouse button to be pressed
     int modifierMask)   // modifiers used for the fake click
 {
@@ -311,27 +289,28 @@ static void DarwinSimulateMouseClick(
 	// for some reason, it's not enough to tell X we released the Command key -- 
 	// it has to be the *left* Command key.
 	if (modifierMask & NX_COMMANDMASK) modifierMask |=NX_DEVICELCMDKEYMASK ;
-    DarwinUpdateModifiers(KeyRelease, modifierMask);
+    DarwinUpdateModifiers(xe, KeyRelease, modifierMask);
 
     // push the mouse button
-    DarwinSendPointerEvents(ButtonPress, whichButton, pointer_x, pointer_y);
-    DarwinSendPointerEvents(ButtonRelease, whichButton, pointer_x, pointer_y);
-
-    // restore old modifiers
-    DarwinUpdateModifiers(KeyPress, modifierMask);
+    xe->u.u.type = ButtonPress;
+    xe->u.u.detail = whichButton;
+    (*darwinEventQueue.pPtr->processInputProc)
+            (xe, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
 }
 
 
-Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr) { 
-    darwinEvents = (xEvent *)malloc(sizeof(xEvent) * GetMaximumEventsNum());
-    mieqInit();
+Bool
+DarwinEQInit(
+    DevicePtr pKbd,
+    DevicePtr pPtr)
+{
     darwinEventQueue.head = darwinEventQueue.tail = 0;
     darwinEventQueue.lastEventTime = GetTimeInMillis ();
     darwinEventQueue.pKbd = pKbd;
     darwinEventQueue.pPtr = pPtr;
     darwinEventQueue.pEnqueueScreen = screenInfo.screens[0];
     darwinEventQueue.pDequeueScreen = darwinEventQueue.pEnqueueScreen;
-    SetInputCheck(&input_check_zero, &input_check_flag);
+    SetInputCheck (&darwinEventQueue.head, &darwinEventQueue.tail);
     return TRUE;
 }
 
@@ -342,10 +321,11 @@ Bool DarwinEQInit(DevicePtr pKbd, DevicePtr pPtr) {
  *    DarwinEQEnqueue    - called from event gathering thread
  *    ProcessInputEvents - called from X server thread
  *  DarwinEQEnqueue should never be called from more than one thread.
- * 
- * This should be deprecated in favor of miEQEnqueue -- BB
  */
-void DarwinEQEnqueue(const xEvent *e) {
+void
+DarwinEQEnqueue(
+    const xEvent *e)
+{
     HWEventQueueType oldtail, newtail;
     char byte = 0;
 
@@ -355,12 +335,13 @@ void DarwinEQEnqueue(const xEvent *e) {
     // This is difficult to do in a thread-safe way and rarely useful.
 
     newtail = oldtail + 1;
-    if (newtail == QUEUE_SIZE) newtail = 0;
+    if (newtail == QUEUE_SIZE)
+        newtail = 0;
     /* Toss events which come in late */
-    if (newtail == darwinEventQueue.head) return;
+    if (newtail == darwinEventQueue.head)
+        return;
 
     darwinEventQueue.events[oldtail].event = *e;
-
     /*
      * Make sure that event times don't go backwards - this
      * is "unnecessary", but very useful
@@ -377,7 +358,7 @@ void DarwinEQEnqueue(const xEvent *e) {
     darwinEventQueue.tail = newtail;
 
     // Signal there is an event ready to handle
-    DarwinPokeEQ();
+    write(darwinEventWriteFD, &byte, 1);
 }
 
 
@@ -385,13 +366,20 @@ void DarwinEQEnqueue(const xEvent *e) {
  * DarwinEQPointerPost
  *  Post a pointer event. Used by the mipointer.c routines.
  */
-void DarwinEQPointerPost(xEvent *e) {
+void
+DarwinEQPointerPost(
+    xEvent *e)
+{
     (*darwinEventQueue.pPtr->processInputProc)
             (e, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
 }
 
 
-void DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX) {
+void
+DarwinEQSwitchScreen(
+    ScreenPtr   pScreen,
+    Bool        fromDIX)
+{
     darwinEventQueue.pEnqueueScreen = pScreen;
     if (fromDIX)
         darwinEventQueue.pDequeueScreen = pScreen;
@@ -402,21 +390,21 @@ void DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX) {
  * ProcessInputEvents
  *  Read and process events from the event queue until it is empty.
  */
-void ProcessInputEvents(void) {
+void ProcessInputEvents(void)
+{
     EventRec *e;
     int     x, y;
     xEvent  xe;
     static int  old_flags = 0;  // last known modifier state
     // button number and modifier mask of currently pressed fake button
-    input_check_flag=0;
-
-    //    ErrorF("calling mieqProcessInputEvents\n");
-    mieqProcessInputEvents();
+    static int darwinFakeMouseButtonDown = 0;
+    static int darwinFakeMouseButtonMask = 0;
 
     // Empty the signaling pipe
     x = sizeof(xe);
-    while (x == sizeof(xe)) 
+    while (x == sizeof(xe)) {
         x = read(darwinEventReadFD, &xe, sizeof(xe));
+    }
 
     while (darwinEventQueue.head != darwinEventQueue.tail)
     {
@@ -432,16 +420,10 @@ void ProcessInputEvents(void) {
                 dixScreenOrigins[miPointerCurrentScreen()->myNum].x;
         xe.u.keyButtonPointer.rootY -= darwinMainScreenY +
                 dixScreenOrigins[miPointerCurrentScreen()->myNum].y;
-	
-	/*	ErrorF("old rootX = (%d,%d) darwinMainScreen = (%d,%d) dixScreenOrigins[%d]=(%d,%d)\n",
-	       xe.u.keyButtonPointer.rootX, xe.u.keyButtonPointer.rootY,
-	       darwinMainScreenX, darwinMainScreenY,
-	       miPointerCurrentScreen()->myNum,
-	       dixScreenOrigins[miPointerCurrentScreen()->myNum].x,
-	       dixScreenOrigins[miPointerCurrentScreen()->myNum].y); */
-
-	//Assumption - screen switching can only occur on motion events
 
+        /*
+         * Assumption - screen switching can only occur on motion events
+         */
         if (e->pScreen != darwinEventQueue.pDequeueScreen)
         {
             darwinEventQueue.pDequeueScreen = e->pScreen;
@@ -459,39 +441,164 @@ void ProcessInputEvents(void) {
                 darwinEventQueue.head = 0;
             else
                 ++darwinEventQueue.head;
-            switch (xe.u.u.type) {
+            switch (xe.u.u.type)
+            {
             case KeyPress:
+                if (old_flags == 0
+                    && darwinSyncKeymap && darwinKeymapFile == NULL)
+                {
+                    /* See if keymap has changed. */
+
+                    static unsigned int last_seed;
+                    unsigned int this_seed;
+
+                    this_seed = DarwinModeSystemKeymapSeed();
+                    if (this_seed != last_seed)
+                    {
+                        last_seed = this_seed;
+                        DarwinKeyboardReload(darwinKeyboard);
+                    }
+                }
+                /* fall through */
+
             case KeyRelease:
-	      ErrorF("Unexpected Keyboard event in DarwinProcessInputEvents\n");
-	      break;
+                xe.u.u.detail += MIN_KEYCODE;
+                (*darwinEventQueue.pKbd->processInputProc)
+                    (&xe, (DeviceIntPtr)darwinEventQueue.pKbd, 1);
+                break;
 
             case ButtonPress:
-	      ErrorF("Unexpected ButtonPress event in DarwinProcessInputEvents\n");
+                miPointerAbsoluteCursor(xe.u.keyButtonPointer.rootX,
+                                        xe.u.keyButtonPointer.rootY,
+                                        xe.u.keyButtonPointer.time);
+                if (darwinFakeButtons && xe.u.u.detail == 1) {
+                    // Mimic multi-button mouse with modifier-clicks
+                    // If both sets of modifiers are pressed,
+                    // button 2 is clicked.
+                    if ((old_flags & darwinFakeMouse2Mask) ==
+                        darwinFakeMouse2Mask)
+                    {
+                        DarwinSimulateMouseClick(&xe, 2, darwinFakeMouse2Mask);
+                        darwinFakeMouseButtonDown = 2;
+                        darwinFakeMouseButtonMask = darwinFakeMouse2Mask;
+                        break;
+                    }
+                    else if ((old_flags & darwinFakeMouse3Mask) ==
+                             darwinFakeMouse3Mask)
+                    {
+                        DarwinSimulateMouseClick(&xe, 3, darwinFakeMouse3Mask);
+                        darwinFakeMouseButtonDown = 3;
+                        darwinFakeMouseButtonMask = darwinFakeMouse3Mask;
+                        break;
+                    }
+                }
+                (*darwinEventQueue.pPtr->processInputProc)
+                        (&xe, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
                 break;
 
             case ButtonRelease:
-	      ErrorF("Unexpected ButtonRelease event in DarwinProcessInputEvents\n");
+                miPointerAbsoluteCursor(xe.u.keyButtonPointer.rootX,
+                                        xe.u.keyButtonPointer.rootY,
+                                        xe.u.keyButtonPointer.time);
+                if (darwinFakeButtons && xe.u.u.detail == 1 &&
+                    darwinFakeMouseButtonDown)
+                {
+                    // If last mousedown was a fake click, don't check for
+                    // mouse modifiers here. The user may have released the
+                    // modifiers before the mouse button.
+                    xe.u.u.detail = darwinFakeMouseButtonDown;
+                    darwinFakeMouseButtonDown = 0;
+                    (*darwinEventQueue.pPtr->processInputProc)
+                            (&xe, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
+
+                    // Bring modifiers back up to date
+                    DarwinUpdateModifiers(&xe, KeyPress,
+                            darwinFakeMouseButtonMask & old_flags);
+                    darwinFakeMouseButtonMask = 0;
+                } else {
+                    (*darwinEventQueue.pPtr->processInputProc)
+                            (&xe, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
+                }
                 break;
 
             case MotionNotify:
-	      ErrorF("Unexpected ButtonRelease event in DarwinProcessInputEvents\n");
+                miPointerAbsoluteCursor(xe.u.keyButtonPointer.rootX,
+                                        xe.u.keyButtonPointer.rootY,
+                                        xe.u.keyButtonPointer.time);
                 break;
 
             case kXDarwinUpdateModifiers:
-	      ErrorF("Unexpected ButtonRelease event in DarwinProcessInputEvents\n");
-	      break;
+            {
+                // Update modifier state.
+                // Any amount of modifiers may have changed.
+	      unsigned int flags = xe.u.clientMessage.u.l.longs0 & ~NX_NONCOALSESCEDMASK; // ignore that one
+		DEBUG_LOG("kxDarwinUpdateModifiers(%x, %x, %s)\n", old_flags, flags, decode_event_flags(flags));
+		//		DEBUG_LOG("Ignoring these flags: %x %s\n", flags & ~KEYBOARD_MASK, decode_event_flags(flags & ~KEYBOARD_MASK));
+		flags &= KEYBOARD_MASK;
+                if (old_flags & ~flags) DarwinUpdateModifiers(&xe, KeyRelease,
+							      old_flags & ~flags);
+                if (~old_flags & flags) DarwinUpdateModifiers(&xe, KeyPress,
+							      ~old_flags & flags);
+                old_flags = flags;
+                break;
+            }
 
             case kXDarwinUpdateButtons:
-	      ErrorF("Unexpected XDarwinScrollWheel event in DarwinProcessInputEvents\n");
-	      break;
+            {
+                long hwDelta = xe.u.clientMessage.u.l.longs0;
+                long hwButtons = xe.u.clientMessage.u.l.longs1;
+                int i;
+
+                for (i = 1; i < 5; i++) {
+                    if (hwDelta & (1 << i)) {
+                        // IOKit and X have different numbering for the
+                        // middle and right mouse buttons.
+                        if (i == 1) {
+                            xe.u.u.detail = 3;
+                        } else if (i == 2) {
+                            xe.u.u.detail = 2;
+                        } else {
+                            xe.u.u.detail = i + 1;
+                        }
+                        if (hwButtons & (1 << i)) {
+                            xe.u.u.type = ButtonPress;
+                        } else {
+                            xe.u.u.type = ButtonRelease;
+                        }
+                        (*darwinEventQueue.pPtr->processInputProc)
+                    (&xe, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
+                    }
+                }
+                break;
+            }
 
-            case kXDarwinScrollWheel: 
-	      ErrorF("Unexpected XDarwinScrollWheel event in DarwinProcessInputEvents\n");
-	      break;
+            case kXDarwinScrollWheel:
+            {
+                short count = xe.u.clientMessage.u.s.shorts0;
+
+                if (count > 0) {
+                    xe.u.u.detail = SCROLLWHEELUPFAKE;
+                } else {
+                    xe.u.u.detail = SCROLLWHEELDOWNFAKE;
+                    count = -count;
+                }
+
+                for (; count; --count) {
+                    xe.u.u.type = ButtonPress;
+                    (*darwinEventQueue.pPtr->processInputProc)
+                            (&xe, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
+                    xe.u.u.type = ButtonRelease;
+                    (*darwinEventQueue.pPtr->processInputProc)
+                            (&xe, (DeviceIntPtr)darwinEventQueue.pPtr, 1);
+                }
+                break;
+            }
 
-			case kXDarwinDeactivate:
-				DarwinReleaseModifiers();
-				// fall through
+	    case kXDarwinDeactivate:
+	      DEBUG_LOG("kxDarwinDeactivate\n");
+	      DarwinReleaseModifiers();
+	      old_flags=0;
+	      // fall through
             default:
                 // Check for mode specific event
                 DarwinModeProcessEvent(&xe);
@@ -499,96 +606,5 @@ void ProcessInputEvents(void) {
         }
     }
 
-    //    miPointerUpdate();
-}
-
-/* Sends a null byte down darwinEventWriteFD, which will cause the
-   Dispatch() event loop to check out event queue */
-void DarwinPokeEQ(void) {
-  char nullbyte=0;
-  input_check_flag++;
-  //  <daniels> bushing: oh, i ... er ... christ.
-  write(darwinEventWriteFD, &nullbyte, 1);
-}
-
-void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int pointer_y) {
-  static int darwinFakeMouseButtonDown = 0;
-  static int darwinFakeMouseButtonMask = 0;
-  int i, num_events;
-  int valuators[2] = {pointer_x, pointer_y};
-  if (ev_type == ButtonPress && darwinFakeButtons && ev_button == 1) {
-    // Mimic multi-button mouse with modifier-clicks
-    // If both sets of modifiers are pressed,
-    // button 2 is clicked.
-    if ((old_flags & darwinFakeMouse2Mask) == darwinFakeMouse2Mask) {
-      DarwinSimulateMouseClick(pointer_x, pointer_y, 2, darwinFakeMouse2Mask);
-      darwinFakeMouseButtonDown = 2;
-      darwinFakeMouseButtonMask = darwinFakeMouse2Mask;
-    } else if ((old_flags & darwinFakeMouse3Mask) == darwinFakeMouse3Mask) {
-      DarwinSimulateMouseClick(pointer_x, pointer_y, 3, darwinFakeMouse3Mask);
-      darwinFakeMouseButtonDown = 3;
-      darwinFakeMouseButtonMask = darwinFakeMouse3Mask;
-    }
-  }
-  if (ev_type == ButtonRelease && darwinFakeButtons && darwinFakeMouseButtonDown) {
-    // If last mousedown was a fake click, don't check for
-    // mouse modifiers here. The user may have released the
-    // modifiers before the mouse button.
-    ev_button = darwinFakeMouseButtonDown;
-    darwinFakeMouseButtonDown = 0;
-    // Bring modifiers back up to date
-    DarwinUpdateModifiers(KeyPress, darwinFakeMouseButtonMask & old_flags);
-    darwinFakeMouseButtonMask = 0;
-  } 
-
-  num_events = GetPointerEvents(darwinEvents, darwinPointer, ev_type, ev_button, 
-				POINTER_ABSOLUTE, 0, 2, valuators);
-      
-  for(i=0; i<num_events; i++) mieqEnqueue (darwinPointer,&darwinEvents[i]);
-  DarwinPokeEQ();
-}
-
-void DarwinSendKeyboardEvents(int ev_type, int keycode) {
-  int i, num_events;
-  if (old_flags == 0 && darwinSyncKeymap && darwinKeymapFile == NULL) {
-    /* See if keymap has changed. */
-
-    static unsigned int last_seed;
-    unsigned int this_seed;
-
-    this_seed = DarwinModeSystemKeymapSeed();
-    if (this_seed != last_seed) {
-      last_seed = this_seed;
-      DarwinKeyboardReload(darwinKeyboard);
-    }
-  }
-
-  num_events = GetKeyboardEvents(darwinEvents, darwinKeyboard, ev_type, keycode + MIN_KEYCODE);
-  for(i=0; i<num_events; i++) mieqEnqueue(darwinKeyboard,&darwinEvents[i]);
-  DarwinPokeEQ();
-}
-
-/* Send the appropriate number of button 4 / 5 clicks to emulate scroll wheel */
-void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y) {
-  int i;
-  int ev_button = count > 0.0f ? 4 : 5;
-  int valuators[2] = {pointer_x, pointer_y};
-
-  for (count = fabs(count); count > 0.0; count = count - 1.0f) {
-    int num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonPress, ev_button, 
-				      POINTER_ABSOLUTE, 0, 2, valuators);
-    for(i=0; i<num_events; i++) mieqEnqueue(darwinPointer,&darwinEvents[i]);
-    num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonRelease, ev_button, 
-				      POINTER_ABSOLUTE, 0, 2, valuators);
-    for(i=0; i<num_events; i++) mieqEnqueue(darwinPointer,&darwinEvents[i]);
-  }
-  DarwinPokeEQ();
-}
-
-/* Send the appropriate KeyPress/KeyRelease events to GetKeyboardEvents to
-   reflect changing modifier flags (alt, control, meta, etc) */
-void DarwinUpdateModKeys(int flags) {
-  DarwinUpdateModifiers(KeyRelease, old_flags & ~flags);
-  DarwinUpdateModifiers(KeyPress, ~old_flags & flags);
-  old_flags = flags;
+    miPointerUpdate();
 }
commit 837fd3bb99b74e7e2d02396acaf233f6b228c869
Author: Jeremy Huddleston <jeremy at tifa.local>
Date:   Mon Nov 19 19:16:19 2007 -0800

    Darwin: Fixed make dist
    Added/corrected missing EXTRA_DIST entries.

diff --git a/hw/darwin/Makefile.am b/hw/darwin/Makefile.am
index a77c006..f1740e3 100644
--- a/hw/darwin/Makefile.am
+++ b/hw/darwin/Makefile.am
@@ -78,14 +78,12 @@ clean-local: x11app-clean x11launcher-clean
 endif
 
 EXTRA_DIST = \
+	Xquartz.man \
 	darwinClut8.h \
 	darwin.h \
 	darwinKeyboard.h \
-	apple/X11Application.h \
-	apple/X11Controller.h \
 	apple/Info.plist \
 	apple/X11.icns \
-	apple/Xquartz.man \
 	apple/bundle-main.c \
 	apple/English.lproj/InfoPlist.strings \
 	apple/English.lproj/Localizable.strings \
diff --git a/hw/darwin/quartz/Makefile.am b/hw/darwin/quartz/Makefile.am
index 44b52e7..4c650e6 100644
--- a/hw/darwin/quartz/Makefile.am
+++ b/hw/darwin/quartz/Makefile.am
@@ -20,6 +20,8 @@ libXQuartz_a_SOURCES = \
 	          quartzStartup.c
 
 EXTRA_DIST = \
+	X11Application.h \
+	X11Controller.h \
 	applewmExt.h \
 	keysym2ucs.h \
 	pseudoramiX.h \
commit 0bd2b610c4e7df08e267459f300d41f4e3255ec9
Author: Jeremy Huddleston <jeremy at tifa.local>
Date:   Mon Nov 19 02:17:44 2007 -0800

    XDarwin dead code removal
    Removed unused code from the tree
    Moved some files to more appropriate locations

diff --git a/hw/darwin/Makefile.am b/hw/darwin/Makefile.am
index f82ed02..a77c006 100644
--- a/hw/darwin/Makefile.am
+++ b/hw/darwin/Makefile.am
@@ -4,7 +4,7 @@ AM_CPPFLAGS = @XORG_INCS@ -I$(top_srcdir)/Xext -I$(top_srcdir)/miext/rootless -D
 SUBDIRS = quartz utils
 
 bin_PROGRAMS = Xquartz
-man1_MANS = apple/Xquartz.man
+man1_MANS = Xquartz.man
 
 Xquartz_SOURCES = darwin.c \
 		  darwinEvents.c \
diff --git a/hw/darwin/XDarwin.man b/hw/darwin/XDarwin.man
deleted file mode 100644
index 143fb7c..0000000
--- a/hw/darwin/XDarwin.man
+++ /dev/null
@@ -1,204 +0,0 @@
-.\"
-.TH XDARWIN 1 __vendorversion__
-.SH NAME
-XDarwin \- X window system server for Darwin operating system
-.SH SYNOPSIS
-.B XDarwin
-[ options ] ...
-.SH DESCRIPTION
-#ifdef DARWIN_WITH_QUARTZ
-.I XDarwin
-is the X window server for Mac OS X and the Darwin operating system
-provided by the X.Org Foundation.
-.I XDarwin
-can run in three different modes. On Mac OS X,
-.I XDarwin
-runs in parallel with Aqua in full screen or rootless modes. These modes
-are called Quartz modes, named after the Quartz 2D compositing engine used
-by Aqua. XDarwin can also be run from the Darwin text console in IOKit mode.
-.PP
-When running from the console,
-.I XDarwin
-acts as the window server and uses IOKit services to access the display
-framebuffer, mouse and keyboard and to provide a layer of hardware
-abstraction. In console mode,
-.I XDarwin
-will normally be started by the \fIxdm(1)\fP display manager or by a script
-that runs the program \fIxinit(1)\fP.
-.PP
-When running with the Mac OS X Aqua GUI,
-.I XDarwin
-will normally be started by launching from the Finder, but it may also be
-started from the command line with the \fB\-quartz\fP, \fB\-fullscreen\fP, or
-\fB\-rootless\fP options. Note that the defaults for various command line
-options are set by the
-.I XDarwin
-application preferences in the Quartz modes.
-.PP
-In full screen Quartz mode, when the X Window System is active, it takes over
-the entire screen. CoreGraphics is used to capture and draw to the screen. The
-.I XDarwin
-application allows easy switching between the Mac OS X and X window
-desktops. More information is available in the Help menu of the
-.I XDarwin
-application.
-.PP
-In rootless mode, the X window system and Aqua share your display.  The root
-window of the X11 display is the size of the screen and contains all the
-other windows. The X11 root window is not displayed in rootless mode as Aqua
-handles the desktop background.
-#else
-.I XDarwin
-is the X window server for Mac OS X and the Darwin operating system
-provided by the X.Org Foundation. This version of
-.I XDarwin
-can only be started from the Darwin text console. The Mac OS X Aqua GUI, if
-present, must be shut down.
-.I XDarwin
-uses IOKit services to access the display
-framebuffer, mouse and keyboard and to provide a layer of hardware
-abstraction.
-.I XDarwin
-will normally be started by the \fIxdm(1)\fP display manager or by a script
-that runs the program \fIxinit(1)\fP.
-#endif
-.SH OPTIONS
-.PP
-In addition to the normal server options described in the \fIXserver(1)\fP
-manual page, \fIXDarwin\fP accepts the following command line switches:
-.TP 8
-.B \-fakebuttons
-Emulates a 3 button mouse using modifier keys. By default, the Command modifier
-is used to emulate button 2 and Option is used for button 3. Thus, clicking the
-first mouse button while holding down Command will act like clicking
-button 2. Holding down Option will simulate button 3.
-.TP 8
-.B \-nofakebuttons
-Do not emulate a 3 button mouse. This is the default.
-.TP 8
-.B "\-fakemouse2 \fImodifiers\fP"
-Change the modifier keys used to emulate the second mouse button. By default,
-Command is used to emulate the second button. Any combination of the following
-modifier names may be used: Shift, Option, Control, Command, Fn. For example,
-.B \-fakemouse2 """Option,Shift""
-will set holding Option, Shift and clicking on button one as equivalent to
-clicking the second mouse button.
-.TP 8
-.B "\-fakemouse3 \fImodifiers\fP"
-Change the modifier keys used to emulate the third mouse button. By default,
-Option is used to emulate the third button. Any combination of the following
-modifier names may be used: Shift, Option, Control, Command, Fn. For example,
-.B \-fakemouse3 """Control,Shift""
-will set holding Control, Shift and clicking on button one as equivalent to
-clicking the third mouse button.
-.TP 8
-.B "\-keymap \fIfile\fP"
-On startup \fIXDarwin\fP translates a Darwin keymapping into an X keymap.
-The default is to read this keymapping from USA.keymapping. With this option
-the keymapping will be read from \fIfile\fP instead. If the file's path is
-not specified, it will be searched for in Library/Keyboards/ underneath the
-following directories (in order): ~, /, /Network, /System.
-.TP 8
-.B \-nokeymap
-On startup \fIXDarwin\fP translates a Darwin keymapping into an X keymap.
-With this option XDarwin queries the kernel for the current keymapping
-instead of reading it from a file. This will often fail on newer kernels.
-#ifdef DARWIN_WITH_QUARTZ
-.TP 8
-.B "\-size \fIwidth\fP \fIheight\fP"
-Sets the screen resolution for the X server to use.
-Ignored in rootless mode.
-.TP 8
-.B "\-depth \fIdepth\fP"
-Specifies the color bit depth to use. Currently only 8, 15, and 24 color bits
-per pixel are supported.
-Ignored in rootless mode.
-.TP 8
-.B "\-refresh \fIrate\fP"
-Gives the refresh rate to use in Hz. For LCD displays this should be 0.
-Ignored in rootless mode.
-.TP 8
-.B \-fullscreen
-Run full screen in parallel with Mac OS X Aqua GUI.
-.TP 8
-.B \-rootless
-Run rootless inside Mac OS X Aqua GUI.
-.TP 8
-.B \-quartz
-Run in parallel with the Mac OS X Aqua GUI using the default mode.
-#else
-.TP 8
-.B "\-size \fIwidth\fP \fIheight\fP"
-Sets the screen resolution for the X server to use.
-.TP 8
-.B "\-depth \fIdepth\fP"
-Specifies the color bit depth to use. Currently only 8, 15, and 24 color bits
-per pixel are supported.
-.TP 8
-.B "\-refresh \fIrate\fP"
-Gives the refresh rate to use in Hz. For LCD displays this should be 0.
-#endif
-.TP 8
-.B \-showconfig
-Print out the server version and patchlevel.
-.TP 8
-.B \-version
-Same as \fB\-showconfig\fP.
-.SH "SEE ALSO"
-.PP
-X(__miscmansuffix__), Xorg(1), Xserver(1), xdm(1), xinit(1)
-.SH BUGS
-.I XDarwin
-and this man page still have many limitations. Some of the more obvious
-ones are:
-.br
-- The display mode cannot be changed once the X server has started.
-.br
-- A screen saver is not supported.
-.PP
-.SH AUTHORS
-XFree86 was originally ported to Mac OS X Server by John Carmack. Dave
-Zarzycki used this as the basis of his port of XFree86 4.0 to Darwin 1.0.
-Torrey T. Lyons improved and integrated this code into the XFree86
-Project's mainline for the 4.0.2 release.
-.PP
-The following members of the XonX Team contributed to the following
-releases (in alphabetical order):
-.TP 4
-XFree86 4.1.0:
-.br
-Rob Braun - Darwin x86 support
-.br
-Torrey T. Lyons - Project Lead
-.br
-Andreas Monitzer - Cocoa version of XDarwin front end
-.br
-Gregory Robert Parker - Original Quartz implementation
-.br
-Christoph Pfisterer - Dynamic shared X libraries
-.br
-Toshimitsu Tanaka - Japanese localization
-.TP 4
-XFree86 4.2.0:
-.br
-Rob Braun - Darwin x86 support
-.br
-Pablo Di Noto - Spanish localization
-.br
-Paul Edens - Dutch localization
-.br
-Kyunghwan Kim - Korean localization
-.br
-Mario Klebsch - Non-US keyboard support
-.br
-Torrey T. Lyons - Project Lead
-.br
-Andreas Monitzer - German localization
-.br
-Patrik Montgomery - Swedish localization
-.br
-Greg Parker - Rootless support
-.br
-Toshimitsu Tanaka - Japanese localization
-.br
-Olivier Verdier - French localization
diff --git a/hw/darwin/Xquartz.man b/hw/darwin/Xquartz.man
new file mode 100644
index 0000000..37a7f1a
--- /dev/null
+++ b/hw/darwin/Xquartz.man
@@ -0,0 +1,156 @@
+.TH XQUARTZ 1 __vendorversion__
+.SH NAME
+Xquartz \- X window system server for Quartz operating system
+.SH SYNOPSIS
+.B Xquartz
+[ options ] ...
+.SH DESCRIPTION
+.I Xquartz
+is the X window server for Mac OS X provided by Apple.
+.I Xquartz
+runs in parallel with Aqua in rootless mode. In rootless mode, the X
+window system and Mac OS X share your display.  The root window of the
+X11 display is the size of the screen and contains all the other
+windows. The X11 root window is not displayed in rootless mode as Mac
+OS X handles the desktop background.
+.SH OPTIONS
+.PP
+In addition to the normal server options described in the \fIXserver(1)\fP
+manual page, \fIXquartz\fP accepts the following command line switches:
+.TP 8
+.B \-fakebuttons
+Emulates a 3 button mouse using modifier keys. By default, the Command modifier
+is used to emulate button 2 and Option is used for button 3. Thus, clicking the
+first mouse button while holding down Command will act like clicking
+button 2. Holding down Option will simulate button 3.
+.TP 8
+.B \-nofakebuttons
+Do not emulate a 3 button mouse. This is the default.
+.TP 8
+.B "\-fakemouse2 \fImodifiers\fP"
+Change the modifier keys used to emulate the second mouse button. By default,
+Command is used to emulate the second button. Any combination of the following
+modifier names may be used: Shift, Option, Control, Command, Fn. For example,
+.B \-fakemouse2 """Option,Shift""
+will set holding Option, Shift and clicking on button one as equivalent to
+clicking the second mouse button.
+.TP 8
+.B "\-fakemouse3 \fImodifiers\fP"
+Change the modifier keys used to emulate the third mouse button. By default,
+Option is used to emulate the third button. Any combination of the following
+modifier names may be used: Shift, Option, Control, Command, Fn. For example,
+.B \-fakemouse3 """Control,Shift""
+will set holding Control, Shift and clicking on button one as equivalent to
+clicking the third mouse button.
+.TP 8
+.B "\-swapAltMeta"
+Swaps the meaning of the Alt and Meta modifier keys.
+.TP 8
+.B "\-keymap \fIfile\fP"
+On startup \fIXquartz\fP translates a Darwin keymapping into an X keymap.
+The default is to read this keymapping from USA.keymapping. With this option
+the keymapping will be read from \fIfile\fP instead. If the file's path is
+not specified, it will be searched for in Library/Keyboards/ underneath the
+following directories (in order): ~, /, /Network, /System.
+.TP 8
+.B \-nokeymap
+On startup \fIXquartz\fP translates a Darwin keymapping into an X keymap.
+With this option \fIXquartz\fP queries the kernel for the current keymapping
+instead of reading it from a file. This will often fail on newer kernels.
+.TP 8
+.B "\-depth \fIdepth\fP"
+Specifies the color bit depth to use. Currently only 15, and 24 color
+bits per pixel are supported. If not specified, defaults to the depth
+of the main display.
+.SH CUSTOMIZATION
+\fIXquartz\fP can also be customized using the defaults(1) command. The available options are:
+.TP 8
+.B defaults write com.apple.x11 enable_fake_buttons -boolean true
+Equivalent to the \fB-fakebuttons\fP command line option.
+.TP 8
+.B defaults write com.apple.x11 fake_button2 \fImodifiers\fP
+Equivalent to the \fB-fakemouse2\fP option.
+.TP 8
+.B defaults write com.apple.x11 fake_button3 \fImodifiers\fP
+Equivalent to the \fB-fakemouse3\fP option.
+.TP 8
+.B defaults write com.apple.x11 swap_alt_meta -boolean true
+Equivalent to the \fB-swapAltMeta\fP option.
+.TP 8
+.B defaults write com.apple.x11 keymap_file \fIfilename\fP
+Equivalent to the \fB-keymap\fP option.
+.TP 8
+.B defaults write com.apple.x11 no_quit_alert -boolean true
+Disables the alert dialog displayed when attempting to quit X11.
+.TP 8
+.B defaults write com.apple.x11 no_auth -boolean true
+Stops the X server requiring that clients authenticate themselves when
+connecting. See Xsecurity(__miscmansuffix__).
+.TP 8
+.B defaults write com.apple.x11 nolisten_tcp -boolean true
+Prevents the X server accepting remote connections.
+.TP 8
+.B defaults write com.apple.x11 xinit_kills_server -boolean false
+Stops the X server exiting when the xinitrc script terminates.
+.TP 8
+.B defaults write com.apple.x11 fullscreen_hotkeys -boolean false
+Allows system hotkeys to be handled while in X11 fullscreen mode.
+.TP 8
+.B defaults write com.apple.x11 enable_system_beep -boolean false
+Don't use the standard system beep effect for X11 alerts.
+.TP 8
+.B defaults write com.apple.x11 enable_key_equivalents -boolean false
+Disable menu keyboard equivalents while X11 windows are focused.
+.TP 8
+.B defaults write com.apple.x11 depth \fIdepth\fP
+Equivalent to the \fB-depth\fP option.
+.SH "SEE ALSO"
+.PP
+X(__miscmansuffix__), XFree86(1), Xserver(1), xdm(1), xinit(1)
+.PP
+.SH AUTHORS
+XFree86 was originally ported to Mac OS X Server by John Carmack. Dave
+Zarzycki used this as the basis of his port of XFree86 4.0 to Darwin 1.0.
+Torrey T. Lyons improved and integrated this code into the XFree86
+Project's mainline for the 4.0.2 release.
+.PP
+The following members of the XonX Team contributed to the following
+releases (in alphabetical order):
+.TP 4
+XFree86 4.1.0:
+.br
+Rob Braun - Darwin x86 support
+.br
+Torrey T. Lyons - Project Lead
+.br
+Andreas Monitzer - Cocoa version of XDarwin front end
+.br
+Gregory Robert Parker - Original Quartz implementation
+.br
+Christoph Pfisterer - Dynamic shared X libraries
+.br
+Toshimitsu Tanaka - Japanese localization
+.TP 4
+XFree86 4.2.0:
+.br
+Rob Braun - Darwin x86 support
+.br
+Pablo Di Noto - Spanish localization
+.br
+Paul Edens - Dutch localization
+.br
+Kyunghwan Kim - Korean localization
+.br
+Mario Klebsch - Non-US keyboard support
+.br
+Torrey T. Lyons - Project Lead
+.br
+Andreas Monitzer - German localization
+.br
+Patrik Montgomery - Swedish localization
+.br
+Greg Parker - Rootless support
+.br
+Toshimitsu Tanaka - Japanese localization
+.br
+Olivier Verdier - French localization
diff --git a/hw/darwin/apple/X11Application.h b/hw/darwin/apple/X11Application.h
deleted file mode 100644
index fb153e7..0000000
--- a/hw/darwin/apple/X11Application.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/* X11Application.h -- subclass of NSApplication to multiplex events
-   $Id: X11Application.h,v 1.26 2003/08/08 19:16:13 jharper Exp $
-
-   Copyright (c) 2002-2007 Apple Inc. 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 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 X11APPLICATION_H
-#define X11APPLICATION_H 1
-
-#if __OBJC__
-
-#import <Cocoa/Cocoa.h>
-#import "X11Controller.h"
-
- at interface X11Application : NSApplication {
-    X11Controller *_controller;
-
-    unsigned int _x_active :1;
-}
-
-- (void) set_controller:controller;
-- (void) set_window_menu:(NSArray *)list;
-
-- (int) prefs_get_integer:(NSString *)key default:(int)def;
-- (const char *) prefs_get_string:(NSString *)key default:(const char *)def;
-- (float) prefs_get_float:(NSString *)key default:(float)def;
-- (int) prefs_get_boolean:(NSString *)key default:(int)def;
-- (NSArray *) prefs_get_array:(NSString *)key;
-- (void) prefs_set_integer:(NSString *)key value:(int)value;
-- (void) prefs_set_float:(NSString *)key value:(float)value;
-- (void) prefs_set_boolean:(NSString *)key value:(int)value;
-- (void) prefs_set_array:(NSString *)key value:(NSArray *)value;
-- (void) prefs_set_string:(NSString *)key value:(NSString *)value;
-- (void) prefs_synchronize;
-
-- (BOOL) x_active;
-
- at end
-
-extern X11Application *X11App;
-
-#endif /* __OBJC__ */
-
-extern void X11ApplicationSetWindowMenu (int nitems, const char **items,
-					 const char *shortcuts);
-extern void X11ApplicationSetWindowMenuCheck (int idx);
-extern void X11ApplicationSetFrontProcess (void);
-extern void X11ApplicationSetCanQuit (int state);
-extern void X11ApplicationServerReady (void);
-extern void X11ApplicationShowHideMenubar (int state);
-
-extern void X11ApplicationMain (int argc, const char *argv[],
-				void (*server_thread) (void *),
-				void *server_arg);
-
-extern int X11EnableKeyEquivalents;
-extern int quartzHasRoot, quartzEnableRootless;
-
-#define APP_PREFS "org.x.X11"
-
-#define PREFS_APPSMENU		"apps_menu"
-#define PREFS_FAKEBUTTONS	"enable_fake_buttons"
-#define PREFS_SYSBEEP		"enable_system_beep"
-#define PREFS_KEYEQUIVS		"enable_key_equivalents"
-#define PREFS_KEYMAP_FILE	"keymap_file"
-#define PREFS_SYNC_KEYMAP	"sync_keymap"
-#define PREFS_DEPTH		"depth"
-#define PREFS_NO_AUTH		"no_auth"
-#define PREFS_NO_TCP		"nolisten_tcp"
-#define PREFS_DONE_XINIT_CHECK	"done_xinit_check"
-#define PREFS_NO_QUIT_ALERT	"no_quit_alert"
-#define PREFS_FAKE_BUTTON2	"fake_button2"
-#define PREFS_FAKE_BUTTON3	"fake_button3"
-#define PREFS_ROOTLESS		"rootless"
-#define PREFS_FULLSCREEN_HOTKEYS "fullscreen_hotkeys"
-#define PREFS_SWAP_ALT_META	"swap_alt_meta"
-#define PREFS_XP_OPTIONS	"xp_options"
-#define PREFS_ENABLE_STEREO	"enable_stereo"
-
-#endif /* X11APPLICATION_H */
diff --git a/hw/darwin/apple/X11Application.m b/hw/darwin/apple/X11Application.m
deleted file mode 100644
index ae6f4bc..0000000
--- a/hw/darwin/apple/X11Application.m
+++ /dev/null
@@ -1,1088 +0,0 @@
-/* X11Application.m -- subclass of NSApplication to multiplex events
- 
- Copyright (c) 2002-2007 Apple Inc. 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 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 "../quartz/quartzCommon.h"
-
-#import "X11Application.h"
-#include <Carbon/Carbon.h>
-
-/* ouch! */
-#define BOOL X_BOOL
-//# include "Xproto.h"
-# include "darwin.h"
-# include "../quartz/quartz.h"
-# define _APPLEWM_SERVER_
-# include "X11/extensions/applewm.h"
-//# include "X.h"
-# include "micmap.h"
-#undef BOOL
-
-#include <mach/mach.h>
-#include <unistd.h>
-#include <pthread.h>
-
-#include "rootlessCommon.h"
-
-WindowPtr xprGetXWindowFromAppKit(int windowNumber); // xpr/xprFrame.c
-
-#define DEFAULTS_FILE "/usr/X11/lib/X11/xserver/Xquartz.plist"
-
-int X11EnableKeyEquivalents = TRUE;
-int quartzHasRoot = FALSE, quartzEnableRootless = TRUE;
-
-extern int darwinFakeButtons;
-extern Bool enable_stereo; 
-
-X11Application *X11App;
-
-#define ALL_KEY_MASKS (NSShiftKeyMask | NSControlKeyMask \
-| NSAlternateKeyMask | NSCommandKeyMask)
-
- at implementation X11Application
-
-typedef struct message_struct message;
-struct message_struct {
-    mach_msg_header_t hdr;
-    SEL selector;
-    NSObject *arg;
-};
-
-static mach_port_t _port;
-
-static void send_nsevent (NSEventType type, NSEvent *e);
-
-/* Quartz mode initialization routine. This is often dynamically loaded
- but is statically linked into this X server. */
-extern Bool QuartzModeBundleInit(void);
-
-static void
-init_ports (void)
-{
-    kern_return_t r;
-    NSPort *p;
-	
-    if (_port != MACH_PORT_NULL)
-		return;
-	
-    r = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, &_port);
-    if (r != KERN_SUCCESS)
-		return;
-	
-    p = [NSMachPort portWithMachPort:_port];
-    [p setDelegate:NSApp];
-    [p scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
-}
-
-static void
-message_kit_thread (SEL selector, NSObject *arg)
-{
-    message msg;
-    kern_return_t r;
-	
-    msg.hdr.msgh_bits = MACH_MSGH_BITS (MACH_MSG_TYPE_MAKE_SEND, 0);
-    msg.hdr.msgh_size = sizeof (msg);
-    msg.hdr.msgh_remote_port = _port;
-    msg.hdr.msgh_local_port = MACH_PORT_NULL;
-    msg.hdr.msgh_reserved = 0;
-    msg.hdr.msgh_id = 0;
-	
-    msg.selector = selector;
-    msg.arg = [arg retain];
-	
-    r = mach_msg (&msg.hdr, MACH_SEND_MSG, msg.hdr.msgh_size,
-				  0, MACH_PORT_NULL, 0, MACH_PORT_NULL);
-    if (r != KERN_SUCCESS)
-		fprintf (stderr, "%s: mach_msg failed: %x\n", __FUNCTION__, r);
-}
-
-- (void) handleMachMessage:(void *)_msg
-{
-    message *msg = _msg;
-	
-    [self performSelector:msg->selector withObject:msg->arg];
-    [msg->arg release];
-}
-
-- (void) set_controller:obj
-{
-    if (_controller == nil)
-		_controller = [obj retain];
-}
-
-- (void) dealloc
-{
-    if (_controller != nil)
-		[_controller release];
-	
-    if (_port != MACH_PORT_NULL)
-		mach_port_deallocate (mach_task_self (), _port);
-	
-    [super dealloc];
-}
-
-- (void) orderFrontStandardAboutPanel: (id) sender
-{
-    NSMutableDictionary *dict;
-    NSDictionary *infoDict;
-    NSString *tem;
-	
-    dict = [NSMutableDictionary dictionaryWithCapacity:2];
-    infoDict = [[NSBundle mainBundle] infoDictionary];
-	
-    [dict setObject: NSLocalizedString (@"The X Window System", @"About panel")
-			 forKey:@"ApplicationName"];
-	
-    tem = [infoDict objectForKey:@"CFBundleShortVersionString"];
-	
-    [dict setObject:[NSString stringWithFormat:@"X11.app %@ - X.org X11R7.2",
-					 tem] forKey:@"ApplicationVersion"];
-	
-    [self orderFrontStandardAboutPanelWithOptions: dict];
-}
-
-- (void) activateX:(BOOL)state
-{
-    /* Create a TSM document that supports full Unicode input, and
-	 have it activated while X is active (unless using the old
-	 keymapping files) */
-    static TSMDocumentID x11_document;
-	
-    if (state)
-    {
-		QuartzMessageServerThread (kXDarwinActivate, 0);
-		
-		if (!_x_active)
-		{
-			if (x11_document == 0 && darwinKeymapFile == NULL)
-			{
-				OSType types[1];
-				types[0] = kUnicodeDocument;
-				NewTSMDocument (1, types, &x11_document, 0);
-			}
-			
-			if (x11_document != 0)
-				ActivateTSMDocument (x11_document);
-		}
-    }
-    else
-    {
-		QuartzMessageServerThread (kXDarwinDeactivate, 0);
-		
-		if (_x_active)
-		{
-			if (x11_document != 0)
-				DeactivateTSMDocument (x11_document);
-		}
-    }
-	
-    _x_active = state;
-}
-
-- (void) became_key:(NSWindow *)win
-{
-    [self activateX:NO];
-}
-
-- (void) sendEvent:(NSEvent *)e
-{
-  NSEventType type;
-  BOOL for_appkit, for_x;
-  
-  type = [e type];
-  
-  /* By default pass down the responder chain and to X. */
-  for_appkit = YES;
-  for_x = YES;
-  
-  switch (type) {
-  case NSLeftMouseDown: case NSRightMouseDown: case NSOtherMouseDown:
-  case NSLeftMouseUp: case NSRightMouseUp: case NSOtherMouseUp:
-    if ([e window] != nil) {
-      /* Pointer event has an (AppKit) window. Probably something for the kit. */
-      for_x = NO;
-      if (_x_active) [self activateX:NO];
-    } else if ([self modalWindow] == nil) {
-      /* Must be an X window. Tell appkit it doesn't have focus. */
-      WindowPtr pWin = xprGetXWindowFromAppKit([e windowNumber]);
-      if (pWin) RootlessReorderWindow(pWin);
-      for_appkit = NO;
-      
-      if ([self isActive]) {
-	[self deactivate];
-	
-	if (!_x_active && quartzProcs->IsX11Window([e window],
-						   [e windowNumber]))
-	  [self activateX:YES];
-      }
-    }
-    break;
-		
-    case NSKeyDown: case NSKeyUp:
-      if (_x_active) {
-	static int swallow_up;
-	
-	/* No kit window is focused, so send it to X. */
-	for_appkit = NO;
-	if (type == NSKeyDown) {
-	  /* Before that though, see if there are any global
-	     shortcuts bound to it. */
-	  
-	  if (X11EnableKeyEquivalents
-	      && [[self mainMenu] performKeyEquivalent:e]) {
-	    swallow_up = [e keyCode];
-	    for_x = NO;
-	  } else if (!quartzEnableRootless
-		     && ([e modifierFlags] & ALL_KEY_MASKS)
-		     == (NSCommandKeyMask | NSAlternateKeyMask)
-		     && ([e keyCode] == 0 /*a*/
-		      || [e keyCode] == 53 /*Esc*/)) {
-	    swallow_up = 0;
-	    for_x = NO;
-#ifdef DARWIN_DDX_MISSING
-	    QuartzMessageServerThread (kXDarwinToggleFullscreen, 0);
-#endif
-	  }
-	} else  {
-	  /* If we saw a key equivalent on the down, don't pass
-	     the up through to X. */
-	  
-	  if (swallow_up != 0 && [e keyCode] == swallow_up) {
-	    swallow_up = 0;
-	    for_x = NO;
-	  }
-	}
-      } else for_x = NO;
-      break;
-      
-  case NSFlagsChanged:
-    /* For the l33t X users who remap modifier keys to normal keysyms. */
-    if (!_x_active) for_x = NO;
-    break;
-    
-  case NSAppKitDefined:
-    switch ([e subtype]) {
-    case NSApplicationActivatedEventType:
-      for_x = NO;
-      if ([self modalWindow] == nil) {
-	for_appkit = NO;
-	
-	/* FIXME: hack to avoid having to pass the event to appkit,
-	   which would cause it to raise one of its windows. */
-	_appFlags._active = YES;
-	    
-	[self activateX:YES];
-	if ([e data2] & 0x10) X11ApplicationSetFrontProcess();
-      }
-      break;
-	
-      case 18: /* ApplicationDidReactivate */
-	if (quartzHasRoot) for_appkit = NO;
-	break;
-	
-    case NSApplicationDeactivatedEventType:
-      for_x = NO;
-      [self activateX:NO];
-      break;
-    }
-    break;
-    
-  default: break; /* for gcc */
-  }
-  
-  if (for_appkit) [super sendEvent:e];
-  
-  if (for_x) send_nsevent (type, e);
-}
-
-- (void) set_window_menu:(NSArray *)list
-{
-    [_controller set_window_menu:list];
-}
-
-- (void) set_window_menu_check:(NSNumber *)n
-{
-    [_controller set_window_menu_check:n];
-}
-
-- (void) set_apps_menu:(NSArray *)list
-{
-    [_controller set_apps_menu:list];
-}
-
-- (void) set_front_process:unused
-{
-    QuartzMessageServerThread(kXDarwinBringAllToFront, 0);
-}
-
-- (void) set_can_quit:(NSNumber *)state
-{
-    [_controller set_can_quit:[state boolValue]];
-}
-
-- (void) server_ready:unused
-{
-    [_controller server_ready];
-}
-
-- (void) show_hide_menubar:(NSNumber *)state
-{
-    if ([state boolValue])
-		ShowMenuBar ();
-    else
-		HideMenuBar ();
-}
-
-
-/* user preferences */
-
-/* Note that these functions only work for arrays whose elements
- can be toll-free-bridged between NS and CF worlds. */
-
-static const void *cfretain (CFAllocatorRef a, const void *b) {
-    return CFRetain (b);
-}
-
-static void cfrelease (CFAllocatorRef a, const void *b) {
-    CFRelease (b);
-}
-
-static CFMutableArrayRef
-nsarray_to_cfarray (NSArray *in)
-{
-    CFMutableArrayRef out;
-    CFArrayCallBacks cb;
-    NSObject *ns;
-    const CFTypeRef *cf;
-    int i, count;
-	
-    memset (&cb, 0, sizeof (cb));
-    cb.version = 0;
-    cb.retain = cfretain;
-    cb.release = cfrelease;
-	
-    count = [in count];
-    out = CFArrayCreateMutable (NULL, count, &cb);
-	
-    for (i = 0; i < count; i++)
-    {
-		ns = [in objectAtIndex:i];
-		
-		if ([ns isKindOfClass:[NSArray class]])
-			cf = (CFTypeRef) nsarray_to_cfarray ((NSArray *) ns);
-		else
-			cf = CFRetain ((CFTypeRef) ns);
-		
-		CFArrayAppendValue (out, cf);
-		CFRelease (cf);
-    }
-	
-    return out;
-}
-static NSMutableArray *
-cfarray_to_nsarray (CFArrayRef in)
-{
-    NSMutableArray *out;
-    const CFTypeRef *cf;
-    NSObject *ns;
-    int i, count;
-	
-    count = CFArrayGetCount (in);
-    out = [[NSMutableArray alloc] initWithCapacity:count];
-	
-    for (i = 0; i < count; i++)
-    {
-		cf = CFArrayGetValueAtIndex (in, i);
-		
-		if (CFGetTypeID (cf) == CFArrayGetTypeID ())
-			ns = cfarray_to_nsarray ((CFArrayRef) cf);
-		else
-			ns = [(id)cf retain];
-		
-		[out addObject:ns];
-		[ns release];
-    }
-	
-    return out;
-}
-
-- (CFPropertyListRef) prefs_get:(NSString *)key
-{
-    CFPropertyListRef value;
-	
-    value = CFPreferencesCopyAppValue ((CFStringRef) key, CFSTR (APP_PREFS));
-	
-    if (value == NULL)
-    {
-		static CFDictionaryRef defaults;
-		
-		if (defaults == NULL)
-		{
-			CFStringRef error = NULL;
-			CFDataRef data;
-			CFURLRef url;
-			SInt32 error_code;
-			
-			url = (CFURLCreateFromFileSystemRepresentation
-				   (NULL, (unsigned char *)DEFAULTS_FILE, strlen (DEFAULTS_FILE), false));
-			if (CFURLCreateDataAndPropertiesFromResource (NULL, url, &data,
-														  NULL, NULL,
-														  &error_code))
-			{
-				defaults = (CFPropertyListCreateFromXMLData
-							(NULL, data, kCFPropertyListMutableContainersAndLeaves, &error));
-				if (error != NULL)
-					CFRelease (error);
-				CFRelease (data);
-			}
-			CFRelease (url);
-			
-			if (defaults != NULL)
-			{
-				NSMutableArray *apps, *elt;
-				int count, i;
-				NSString *name, *nname;
-				
-				/* Localize the names in the default apps menu. */
-				
-				apps = [(NSDictionary *)defaults objectForKey:@PREFS_APPSMENU];
-				if (apps != nil)
-				{
-					count = [apps count];
-					for (i = 0; i < count; i++)
-					{
-						elt = [apps objectAtIndex:i];
-						if (elt != nil && [elt isKindOfClass:[NSArray class]])
-						{
-							name = [elt objectAtIndex:0];
-							if (name != nil)
-							{
-								nname = NSLocalizedString (name, nil);
-								if (nname != nil && nname != name)
-									[elt replaceObjectAtIndex:0 withObject:nname];
-							}
-						}
-					}
-				}
-			}
-		}
-		
-		if (defaults != NULL)
-			value = CFDictionaryGetValue (defaults, key);
-		
-		if (value != NULL)
-			CFRetain (value);
-    }
-	
-    return value;
-}
-
-- (int) prefs_get_integer:(NSString *)key default:(int)def
-{
-    CFPropertyListRef value;
-    int ret;
-	
-    value = [self prefs_get:key];
-	
-    if (value != NULL && CFGetTypeID (value) == CFNumberGetTypeID ())
-		CFNumberGetValue (value, kCFNumberIntType, &ret);
-    else if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ())
-		ret = CFStringGetIntValue (value);
-    else
-		ret = def;
-	
-    if (value != NULL)
-		CFRelease (value);
-	
-    return ret;
-}
-
-- (const char *) prefs_get_string:(NSString *)key default:(const char *)def
-{
-    CFPropertyListRef value;
-    const char *ret = NULL;
-	
-    value = [self prefs_get:key];
-	
-    if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ())
-    {
-		NSString *s = (NSString *) value;
-		
-		ret = [s UTF8String];
-    }
-	
-    if (value != NULL)
-		CFRelease (value);
-	
-    return ret != NULL ? ret : def;
-}
-
-- (float) prefs_get_float:(NSString *)key default:(float)def
-{
-    CFPropertyListRef value;
-    float ret = def;
-	
-    value = [self prefs_get:key];
-	
-    if (value != NULL
-		&& CFGetTypeID (value) == CFNumberGetTypeID ()
-		&& CFNumberIsFloatType (value))
-    {
-		CFNumberGetValue (value, kCFNumberFloatType, &ret);
-    }
-    else if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ())
-    {
-		ret = CFStringGetDoubleValue (value);
-    }
-	
-    if (value != NULL)
-		CFRelease (value);
-	
-    return ret;
-}
-
-- (int) prefs_get_boolean:(NSString *)key default:(int)def
-{
-    CFPropertyListRef value;
-    int ret = def;
-	
-    value = [self prefs_get:key];
-	
-    if (value != NULL)
-    {
-		if (CFGetTypeID (value) == CFNumberGetTypeID ())
-			CFNumberGetValue (value, kCFNumberIntType, &ret);
-		else if (CFGetTypeID (value) == CFBooleanGetTypeID ())
-			ret = CFBooleanGetValue (value);
-		else if (CFGetTypeID (value) == CFStringGetTypeID ())
-		{
-			const char *tem = [(NSString *) value UTF8String];
-			if (strcasecmp (tem, "true") == 0 || strcasecmp (tem, "yes") == 0)
-				ret = YES;
-			else
-				ret = NO;
-		}
-		
-		CFRelease (value);
-    }
-	
-    return ret;
-}
-
-- (NSArray *) prefs_get_array:(NSString *)key
-{
-    NSArray *ret = nil;
-    CFPropertyListRef value;
-	
-    value = [self prefs_get:key];
-	
-    if (value != NULL)
-    {
-		if (CFGetTypeID (value) == CFArrayGetTypeID ())
-			ret = [cfarray_to_nsarray (value) autorelease];
-		
-		CFRelease (value);
-    }
-	
-    return ret;
-}
-
-- (void) prefs_set_integer:(NSString *)key value:(int)value
-{
-    CFNumberRef x;
-	
-    x = CFNumberCreate (NULL, kCFNumberIntType, &value);
-	
-    CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) x, CFSTR (APP_PREFS),
-						   kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
-	
-    CFRelease (x);
-}
-
-- (void) prefs_set_float:(NSString *)key value:(float)value
-{
-    CFNumberRef x;
-	
-    x = CFNumberCreate (NULL, kCFNumberFloatType, &value);
-	
-    CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) x, CFSTR (APP_PREFS),
-						   kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
-	
-    CFRelease (x);
-}
-
-- (void) prefs_set_boolean:(NSString *)key value:(int)value
-{
-    CFPreferencesSetValue ((CFStringRef) key,
-						   (CFTypeRef) value ? kCFBooleanTrue
-						   : kCFBooleanFalse, CFSTR (APP_PREFS),
-						   kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
-	
-}
-
-- (void) prefs_set_array:(NSString *)key value:(NSArray *)value
-{
-    CFArrayRef cfarray;
-	
-    cfarray = nsarray_to_cfarray (value);
-    CFPreferencesSetValue ((CFStringRef) key,
-						   (CFTypeRef) cfarray,
-						   CFSTR (APP_PREFS),
-						   kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
-    CFRelease (cfarray);
-}
-
-- (void) prefs_set_string:(NSString *)key value:(NSString *)value
-{
-    CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) value,
-						   CFSTR (APP_PREFS), kCFPreferencesCurrentUser,
-						   kCFPreferencesAnyHost);
-}
-
-- (void) prefs_synchronize
-{
-    CFPreferencesAppSynchronize (kCFPreferencesCurrentApplication);
-}
-
-- (void) read_defaults
-{
-    const char *tem;
-	
-    quartzUseSysBeep = [self prefs_get_boolean:@PREFS_SYSBEEP
-                        default:quartzUseSysBeep];
-    quartzEnableRootless = [self prefs_get_boolean:@PREFS_ROOTLESS
-                        default:quartzEnableRootless];
-#ifdef DARWIN_DDX_MISSING
-    quartzFullscreenDisableHotkeys = ![self prefs_get_boolean:
-					      @PREFS_FULLSCREEN_HOTKEYS default:
-					      !quartzFullscreenDisableHotkeys];
-    quartzXpluginOptions = [self prefs_get_integer:@PREFS_XP_OPTIONS
-                            default:quartzXpluginOptions];
-#endif
-	
-    darwinSwapAltMeta = [self prefs_get_boolean:@PREFS_SWAP_ALT_META
-                         default:darwinSwapAltMeta];
-    darwinFakeButtons = [self prefs_get_boolean:@PREFS_FAKEBUTTONS
-                         default:darwinFakeButtons];
-    if (darwinFakeButtons) {
-      const char *fake2, *fake3;
-      
-      fake2 = [self prefs_get_string:@PREFS_FAKE_BUTTON2 default:NULL];
-      fake3 = [self prefs_get_string:@PREFS_FAKE_BUTTON3 default:NULL];
-      
-      if (fake2 != NULL) darwinFakeMouse2Mask = DarwinParseModifierList(fake2);
-      if (fake3 != NULL) darwinFakeMouse3Mask = DarwinParseModifierList(fake3);
-    }
-	
-    X11EnableKeyEquivalents = [self prefs_get_boolean:@PREFS_KEYEQUIVS
-                               default:X11EnableKeyEquivalents];
-	
-    darwinSyncKeymap = [self prefs_get_boolean:@PREFS_SYNC_KEYMAP
-                        default:darwinSyncKeymap];
-	
-    tem = [self prefs_get_string:@PREFS_KEYMAP_FILE default:NULL];
-    if (tem != NULL) darwinKeymapFile = strdup (tem);
-    else             darwinKeymapFile = NULL;
-	
-    darwinDesiredDepth = [self prefs_get_integer:@PREFS_DEPTH
-                          default:darwinDesiredDepth];
-	
-    enable_stereo = [self prefs_get_boolean:@PREFS_ENABLE_STEREO
-                     default:false];
-}
-
-/* This will end up at the end of the responder chain. */
-- (void) copy:sender
-{
-    QuartzMessageServerThread (kXDarwinPasteboardNotify, 1,
-			       AppleWMCopyToPasteboard);
-}
-
-- (BOOL) x_active
-{
-    return _x_active;
-}
-
- at end
-
-static NSArray *
-array_with_strings_and_numbers (int nitems, const char **items,
-								const char *numbers)
-{
-    NSMutableArray *array, *subarray;
-    NSString *string;
-    NSString *number;
-    int i;
-	
-    /* (Can't autorelease on the X server thread) */
-	
-    array = [[NSMutableArray alloc] initWithCapacity:nitems];
-	
-    for (i = 0; i < nitems; i++)
-    {
-		subarray = [[NSMutableArray alloc] initWithCapacity:2];
-		
-		string = [[NSString alloc] initWithUTF8String:items[i]];
-		[subarray addObject:string];
-		[string release];
-		
-		if (numbers[i] != 0)
-		{
-			number = [[NSString alloc] initWithFormat:@"%d", numbers[i]];
-			[subarray addObject:number];
-			[number release];
-		}
-		else
-			[subarray addObject:@""];
-		
-		[array addObject:subarray];
-		[subarray release];
-    }
-	
-    return array;
-}
-
-void
-X11ApplicationSetWindowMenu (int nitems, const char **items,
-							 const char *shortcuts)
-{
-    NSArray *array;
-    array = array_with_strings_and_numbers (nitems, items, shortcuts);
-	
-    /* Send the array of strings over to the appkit thread */
-	
-    message_kit_thread (@selector (set_window_menu:), array);
-    [array release];
-}
-
-void
-X11ApplicationSetWindowMenuCheck (int idx)
-{
-    NSNumber *n;
-	
-    n = [[NSNumber alloc] initWithInt:idx];
-	
-    message_kit_thread (@selector (set_window_menu_check:), n);
-	
-    [n release];
-}
-
-void
-X11ApplicationSetFrontProcess (void)
-{
-    message_kit_thread (@selector (set_front_process:), nil);
-}
-
-void
-X11ApplicationSetCanQuit (int state)
-{
-    NSNumber *n;
-	
-    n = [[NSNumber alloc] initWithBool:state];
-	
-    message_kit_thread (@selector (set_can_quit:), n);
-	
-    [n release];
-}
-
-void
-X11ApplicationServerReady (void)
-{
-    message_kit_thread (@selector (server_ready:), nil);
-}
-
-void
-X11ApplicationShowHideMenubar (int state)
-{
-    NSNumber *n;
-	
-    n = [[NSNumber alloc] initWithBool:state];
-	
-    message_kit_thread (@selector (show_hide_menubar:), n);
-	
-    [n release];
-}
-
-static void *
-create_thread (void *func, void *arg)
-{
-    pthread_attr_t attr;
-    pthread_t tid;
-	
-    pthread_attr_init (&attr);
-	
-    pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM);
-    pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
-	
-    pthread_create (&tid, &attr, func, arg);
-	
-    pthread_attr_destroy (&attr);
-	
-    return (void *) tid;
-}
-
-static void
-check_xinitrc (void)
-{
-    char *tem, buf[1024];
-    NSString *msg;
-	
-    if ([X11App prefs_get_boolean:@PREFS_DONE_XINIT_CHECK default:NO])
-		return;
-	
-    tem = getenv ("HOME");
-    if (tem == NULL)
-		goto done;
-	
-    snprintf (buf, sizeof (buf), "%s/.xinitrc", tem);
-    if (access (buf, F_OK) != 0)
-		goto done;
-	
-    /* FIXME: put localized strings into Resources/English.lproj */
-	
-    msg = NSLocalizedString (@"You have an existing ~/.xinitrc file.\n\n\
-Windows displayed by X11 applications may not have titlebars, or may look \
-different to windows displayed by native applications.\n\n\
-Would you like to move aside the existing file and use the standard X11 \
-environment?", @"Startup xinitrc dialog");
-	
-    if (NSRunAlertPanel (nil, msg, NSLocalizedString (@"Yes", @""),
-						 NSLocalizedString (@"No", @""), nil)
-		== NSAlertDefaultReturn)
-    {
-		char buf2[1024];
-		int i = -1;
-		
-		snprintf (buf2, sizeof (buf2), "%s.old", buf);
-		
-		for (i = 1; access (buf2, F_OK) == 0; i++)
-			snprintf (buf2, sizeof (buf2), "%s.old.%d", buf, i);
-		
-		rename (buf, buf2);
-    }
-    
-	done:
-    [X11App prefs_set_boolean:@PREFS_DONE_XINIT_CHECK value:YES];
-    [X11App prefs_synchronize];
-}
-
-void
-X11ApplicationMain (int argc, const char *argv[],
-		    void (*server_thread) (void *), void *server_arg)
-{
-  NSAutoreleasePool *pool;
-  
-#ifdef DEBUG
-  while (access ("/tmp/x11-block", F_OK) == 0) sleep (1);
-#endif
-  
-  pool = [[NSAutoreleasePool alloc] init];
-  X11App = (X11Application *) [X11Application sharedApplication];
-  init_ports ();
-  [NSApp read_defaults];
-  [NSBundle loadNibNamed:@"main" owner:NSApp];
-  [[NSNotificationCenter defaultCenter] addObserver:NSApp
-					selector:@selector (became_key:)
-					name:NSWindowDidBecomeKeyNotification object:nil];
-  check_xinitrc ();
-	
-  /*
-   * The xpr Quartz mode is statically linked into this server.
-   * Initialize all the Quartz functions.
-   */
-  QuartzModeBundleInit();
-  
-  /* Calculate the height of the menubar so we can avoid it. */
-  aquaMenuBarHeight = NSHeight([[NSScreen mainScreen] frame]) -
-    NSMaxY([[NSScreen mainScreen] visibleFrame]);
-  
-  if (!create_thread (server_thread, server_arg)) {
-    ErrorF("can't create secondary thread\n");
-    exit (1);
-  }
-  
-  [NSApp run];
-  
-  /* not reached */
-}
-
-
-/* event conversion */
-
-static inline unsigned short
-convert_flags (unsigned int nsflags)
-{
-    unsigned int xflags;
-	
-    if (nsflags == ~0) return 0xffff;
-	
-    xflags = 0;
-	
-    if (nsflags & NSAlphaShiftKeyMask)	xflags |= LockMask;
-    if (nsflags & NSShiftKeyMask)		xflags |= ShiftMask;
-    if (nsflags & NSControlKeyMask)		xflags |= ControlMask;
-    if (nsflags & NSAlternateKeyMask)	xflags |= Mod1Mask;
-    if (nsflags & NSCommandKeyMask)		xflags |= Mod2Mask;
-    /* FIXME: secondaryfn? */
-	
-    return xflags;
-}
-
-static void
-send_nsevent (NSEventType type, NSEvent *e)
-{
-  static unsigned int button_state = 0;
-  NSRect screen;
-  NSPoint location;
-  NSWindow *window;
-  int pointer_x, pointer_y;
-  xEvent xe;
-  
-  memset (&xe, 0, sizeof (xe));
-  
-  /* This field should be filled in for every event */
-  xe.u.keyButtonPointer.time = GetTimeInMillis();
-  
-  /* convert location to global top-left coordinates */
-  location = [e locationInWindow];
-  window = [e window];
-  screen = [[[NSScreen screens] objectAtIndex:0] frame];
-  
-  if (window != nil)	{
-    NSRect frame = [window frame];
-    pointer_x = location.x + frame.origin.x;
-    pointer_y = (((screen.origin.y + screen.size.height)
-		  - location.y) - frame.origin.y);
-  } else {
-    pointer_x = location.x;
-    pointer_y = (screen.origin.y + screen.size.height) - location.y;
-  }
-  
-  xe.u.keyButtonPointer.rootX = pointer_x;
-  xe.u.keyButtonPointer.rootY = pointer_y;
-  
-  switch (type) {
-    float count;
-    
-  case NSLeftMouseDown:
-    xe.u.u.type = ButtonPress;
-    xe.u.u.detail = 1;
-    goto do_press_event;
-    
-  case NSRightMouseDown:
-    xe.u.u.type = ButtonPress;
-    xe.u.u.detail = 3;
-    goto do_press_event;
-    
-  case NSOtherMouseDown:
-    xe.u.u.type = ButtonPress;
-    xe.u.u.detail = 2; /* FIXME? */
-    goto do_press_event;
-    
-  do_press_event:
-    if (!quartzProcs->IsX11Window([e window], [e windowNumber])) {
-      /* X server doesn't grok this window, drop the event.
-	 
-	 Note: theoretically this isn't necessary, but if I click
-	 on the menubar, we get sent a LeftMouseDown when the
-	 release happens, but no LeftMouseUp is ever seen! */
-      
-      break;
-    }
-    goto do_event;
-    
-  case NSLeftMouseUp:
-    xe.u.u.type = ButtonRelease;
-    xe.u.u.detail = 1;
-    goto do_release_event;
-    
-  case NSRightMouseUp:
-    xe.u.u.type = ButtonRelease;
-    xe.u.u.detail = 3;
-    goto do_release_event;
-    
-  case NSOtherMouseUp:
-    xe.u.u.type = ButtonRelease;
-    xe.u.u.detail = 2; /* FIXME? */
-    goto do_release_event;
-    
-  do_release_event:
-    if ((button_state & (1 << xe.u.u.detail)) == 0)
-      {
-	/* X didn't see the button press for this release, so skip it */
-	break;
-      }
-    goto do_event;
-    
-  case NSMouseMoved:
-  case NSLeftMouseDragged:
-  case NSRightMouseDragged:
-  case NSOtherMouseDragged:
-    xe.u.u.type = MotionNotify;
-    goto do_event;
-    
-  case NSKeyDown:
-    xe.u.u.type = KeyPress;
-    xe.u.u.detail = [e keyCode];
-    goto do_event;
-    
-  case NSKeyUp:
-    xe.u.u.type = KeyRelease;
-    xe.u.u.detail = [e keyCode];
-    goto do_event;
-    
-  case NSScrollWheel:
-    xe.u.keyButtonPointer.state = convert_flags ([e modifierFlags]);
-    count = [e deltaY];
-    xe.u.u.detail = count > 0.0f ? 4 : 5;
-    for (count = fabs(count); count > 0.0; count = count - 1.0f) {
-      xe.u.u.type = ButtonPress;
-      DarwinEQEnqueue(&xe);
-      xe.u.u.type = ButtonRelease;
-      DarwinEQEnqueue(&xe);
-    }
-    xe.u.u.type = 0;
-    break;
-    
-  case NSFlagsChanged:
-    xe.u.u.type = kXDarwinUpdateModifiers;
-    xe.u.clientMessage.u.l.longs0 = [e modifierFlags];
-    DarwinEQEnqueue (&xe);
-    break;
-    
-  do_event:
-    //	xe.u.keyButtonPointer.state = convert_flags ([e modifierFlags]);
-    DarwinEQEnqueue (&xe);
-    break;
-    
-  default: break; /* for gcc */
-  }
-  
-  if (xe.u.u.type == ButtonPress) button_state |= (1 << xe.u.u.detail);
-  else if (xe.u.u.type == ButtonRelease) button_state &= ~(1 << xe.u.u.detail);
-}
diff --git a/hw/darwin/apple/X11Controller.h b/hw/darwin/apple/X11Controller.h
deleted file mode 100644
index 954d0ab..0000000
--- a/hw/darwin/apple/X11Controller.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/* X11Controller.h -- connect the IB ui
-   $Id: X11Controller.h,v 1.21 2003/07/24 17:52:29 jharper Exp $
-
-   Copyright (c) 2002 Apple Computer, Inc. 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 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 X11CONTROLLER_H
-#define X11CONTROLLER_H 1
-
-#if __OBJC__
-
-#import <Cocoa/Cocoa.h>
-#include "../quartz/xpr/x-list.h"
-
- at interface X11Controller : NSObject
-{
-    NSPanel *prefs_panel;
-
-    NSButton *fake_buttons;
-    NSButton *enable_fullscreen;
-    NSButton *use_sysbeep;
-    NSButton *enable_keyequivs;
-    NSButton *sync_keymap;
-    NSButton *enable_auth;
-    NSButton *enable_tcp;
-    NSPopUpButton *depth;
-
-    NSMenuItem *x11_about_item;
-    NSMenuItem *window_separator;
-    NSMenuItem *dock_window_separator;
-    NSMenuItem *apps_separator;
-    NSMenuItem *toggle_fullscreen_item;
-    NSMenu *dock_apps_menu;
-    NSTableView *apps_table;
-
-    NSArray *apps;
-    NSMutableArray *table_apps;
-
-    NSMenu *dock_menu;
-
-    int checked_window_item;
-    x_list *pending_apps;
-
-    BOOL finished_launching;
-    BOOL can_quit;
-}
-
-- (void) set_window_menu:(NSArray *)list;
-- (void) set_window_menu_check:(NSNumber *)n;
-- (void) set_apps_menu:(NSArray *)list;
-- (void) set_can_quit:(BOOL)state;
-- (void) server_ready;
-
- at end
-
-#endif /* __OBJC__ */
-
-extern void X11ControllerMain (int argc, const char *argv[],
-			       void (*server_thread) (void *),
-			       void *server_arg);
-
-#endif /* X11CONTROLLER_H */
diff --git a/hw/darwin/apple/X11Controller.m b/hw/darwin/apple/X11Controller.m
deleted file mode 100644
index df90049..0000000
--- a/hw/darwin/apple/X11Controller.m
+++ /dev/null
@@ -1,748 +0,0 @@
-/* X11Controller.m -- connect the IB ui, also the NSApp delegate
-   $Id: X11Controller.m,v 1.40 2006/09/06 21:19:32 jharper Exp $
- 
-   Copyright (c) 2002-2007 Apple Inc. 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 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 DEFAULT_PATH "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11/bin"
-
-#include "../quartz/quartzCommon.h"
-
-#import "X11Controller.h"
-#import "X11Application.h"
-#import <Carbon/Carbon.h>
-
-/* ouch! */
-#define BOOL X_BOOL
-//# include "Xproto.h"
-#include "opaque.h"
-# include "darwin.h"
-# include "../quartz/quartz.h"
-# define _APPLEWM_SERVER_
-# include "X11/extensions/applewm.h"
-# include "../quartz/applewmExt.h"
-//# include "X.h"
-#undef BOOL
-
-#include <stdio.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-
- at implementation X11Controller
-
-- (void) awakeFromNib
-{
-  X11Application *xapp = NSApp;
-  NSArray *array;
-	
-  /* Point X11Application at ourself. */
-  [xapp set_controller:self];
-	
-  array = [xapp prefs_get_array:@PREFS_APPSMENU];
-  if (array != nil)
-    {
-      int count;
-		
-      /* convert from [TITLE1 COMMAND1 TITLE2 COMMAND2 ...]
-	 to [[TITLE1 COMMAND1] [TITLE2 COMMAND2] ...] format. */
-		
-      count = [array count];
-      if (count > 0
-	  && ![[array objectAtIndex:0] isKindOfClass:[NSArray class]])
-	{
-	  int i;
-	  NSMutableArray *copy, *sub;
-			
-	  copy = [NSMutableArray arrayWithCapacity:(count / 2)];
-			
-	  for (i = 0; i < count / 2; i++)
-	    {
-	      sub = [[NSMutableArray alloc] initWithCapacity:3];
-	      [sub addObject:[array objectAtIndex:i*2]];
-	      [sub addObject:[array objectAtIndex:i*2+1]];
-	      [sub addObject:@""];
-	      [copy addObject:sub];
-	      [sub release];
-	    }
-			
-	  array = copy;
-	}
-		
-      [self set_apps_menu:array];
-    }
-}
-
-- (void) item_selected:sender
-{
-  [NSApp activateIgnoringOtherApps:YES];
-	
-  QuartzMessageServerThread (kXDarwinControllerNotify, 2,
-			     AppleWMWindowMenuItem, [sender tag]);
-}
-
-- (void) remove_window_menu
-{
-  NSMenu *menu;
-  int first, count, i;
-	
-  /* Work backwards so we don't mess up the indices */
-  menu = [window_separator menu];
-  first = [menu indexOfItem:window_separator] + 1;
-  count = [menu numberOfItems];
-  for (i = count - 1; i >= first; i--)
-    [menu removeItemAtIndex:i];
-	
-  menu = [dock_window_separator menu];
-  count = [menu indexOfItem:dock_window_separator];
-  for (i = 0; i < count; i++)
-    [dock_menu removeItemAtIndex:0];
-}
-
-- (void) install_window_menu:(NSArray *)list
-{
-  NSMenu *menu;
-  NSMenuItem *item;
-  int first, count, i;
-	
-  menu = [window_separator menu];
-  first = [menu indexOfItem:window_separator] + 1;
-  count = [list count];
-  for (i = 0; i < count; i++)
-    {
-      NSString *name, *shortcut;
-		
-      name = [[list objectAtIndex:i] objectAtIndex:0];
-      shortcut = [[list objectAtIndex:i] objectAtIndex:1];
-		
-      item = (NSMenuItem *) [menu addItemWithTitle:name action:@selector
-				  (item_selected:) keyEquivalent:shortcut];
-      [item setTarget:self];
-      [item setTag:i];
-      [item setEnabled:YES];
-		
-      item = (NSMenuItem *) [dock_menu insertItemWithTitle:name
-				       action:@selector
-				       (item_selected:) keyEquivalent:shortcut
-				       atIndex:i];
-      [item setTarget:self];
-      [item setTag:i];
-      [item setEnabled:YES];
-    }
-	
-  if (checked_window_item >= 0 && checked_window_item < count)
-    {
-      item = (NSMenuItem *) [menu itemAtIndex:first + checked_window_item];
-      [item setState:NSOnState];
-      item = (NSMenuItem *) [dock_menu itemAtIndex:checked_window_item];
-      [item setState:NSOnState];
-    }
-}
-
-- (void) remove_apps_menu
-{
-  NSMenu *menu;
-  NSMenuItem *item;
-  int i;
-	
-  if (apps == nil || apps_separator == nil) return;
-	
-  menu = [apps_separator menu];
-	
-  if (menu != nil)
-    {
-      for (i = [menu numberOfItems] - 1; i >= 0; i--)
-	{
-	  item = (NSMenuItem *) [menu itemAtIndex:i];
-	  if ([item tag] != 0)
-	    [menu removeItemAtIndex:i];
-	}
-    }
-    
-  if (dock_apps_menu != nil)
-    {
-      for (i = [dock_apps_menu numberOfItems] - 1; i >= 0; i--)
-	{
-	  item = (NSMenuItem *) [dock_apps_menu itemAtIndex:i];
-	  if ([item tag] != 0)
-	    [dock_apps_menu removeItemAtIndex:i];
-	}
-    }
-    
-  [apps release];
-  apps = nil;
-}
-
-- (void) prepend_apps_item:(NSArray *)list index:(int)i menu:(NSMenu *)menu
-{
-  NSString *title, *shortcut = @"";
-  NSArray *group;
-  NSMenuItem *item;
-	
-  group = [list objectAtIndex:i];
-  title = [group objectAtIndex:0];
-  if ([group count] >= 3)
-    shortcut = [group objectAtIndex:2];
-	
-  if ([title length] != 0)
-    {
-      item = (NSMenuItem *) [menu insertItemWithTitle:title
-				  action:@selector (app_selected:)
-				  keyEquivalent:shortcut atIndex:0];
-      [item setTarget:self];
-      [item setEnabled:YES];
-    }
-  else
-    {
-      item = (NSMenuItem *) [NSMenuItem separatorItem];
-      [menu insertItem:item atIndex:0];
-    }
-	
-  [item setTag:i+1];			/* can't be zero, so add one */
-}
-
-- (void) install_apps_menu:(NSArray *)list
-{
-  NSMenu *menu;
-  int i, count;
-	
-  count = [list count];
-	
-  if (count == 0 || apps_separator == nil) return;
-	
-  menu = [apps_separator menu];
-	
-  for (i = count - 1; i >= 0; i--)
-    {
-      if (menu != nil)
-	[self prepend_apps_item:list index:i menu:menu];
-      if (dock_apps_menu != nil)
-	[self prepend_apps_item:list index:i menu:dock_apps_menu];
-    }
-	
-  apps = [list retain];
-}
-
-- (void) set_window_menu:(NSArray *)list
-{
-  [self remove_window_menu];
-  [self install_window_menu:list];
-	
-  QuartzMessageServerThread (kXDarwinControllerNotify, 1,
-			     AppleWMWindowMenuNotify);
-}
-
-- (void) set_window_menu_check:(NSNumber *)nn
-{
-  NSMenu *menu;
-  NSMenuItem *item;
-  int first, count;
-  int n = [nn intValue];
-
-  menu = [window_separator menu];
-  first = [menu indexOfItem:window_separator] + 1;
-  count = [menu numberOfItems] - first;
-	
-  if (checked_window_item >= 0 && checked_window_item < count)
-    {
-      item = (NSMenuItem *) [menu itemAtIndex:first + checked_window_item];
-      [item setState:NSOffState];
-      item = (NSMenuItem *) [dock_menu itemAtIndex:checked_window_item];
-      [item setState:NSOffState];
-    }
-  if (n >= 0 && n < count)
-    {
-      item = (NSMenuItem *) [menu itemAtIndex:first + n];
-      [item setState:NSOnState];
-      item = (NSMenuItem *) [dock_menu itemAtIndex:n];
-      [item setState:NSOnState];
-    }
-  checked_window_item = n;
-}
-
-- (void) set_apps_menu:(NSArray *)list
-{
-  [self remove_apps_menu];
-  [self install_apps_menu:list];
-}
-
-- (void) launch_client:(NSString *)filename
-{
-  const char *command = [filename UTF8String];
-  const char *argv[7];
-  int child1, child2 = 0;
-  int status;
-	
-  argv[0] = "/usr/bin/login";
-  argv[1] = "-fp";
-  argv[2] = getlogin();
-  argv[3] = "/bin/sh";
-  argv[4] = "-c";
-  argv[5] = command;
-  argv[6] = NULL;
-    
-  /* Do the fork-twice trick to avoid having to reap zombies */
-    
-  child1 = fork();
-    
-  switch (child1) {
-  case -1:                                /* error */
-    break;
-      
-  case 0:                                 /* child1 */
-    child2 = fork();
-      
-    switch (child2) {
-      int max_files, i;
-      char buf[1024], *temp;
-	
-    case -1:                            /* error */
-      _exit(1);
-	
-    case 0:                             /* child2 */
-      /* close all open files except for standard streams */
-      max_files = sysconf(_SC_OPEN_MAX);
-      for (i = 3; i < max_files; i++)	close(i);
-	
-      /* ensure stdin is on /dev/null */
-      close(0);
-      open("/dev/null", O_RDONLY);
-	
-      /* Setup environment */
-      temp = getenv("DISPLAY");
-      if (temp == NULL || temp[0] == 0) {
-	snprintf(buf, sizeof(buf), ":%s", display);
-	setenv("DISPLAY", buf, TRUE);
-      }
-	
-      temp = getenv("PATH");
-      if (temp == NULL || temp[0] == 0) 
-	setenv ("PATH", DEFAULT_PATH, TRUE);
-      else if (strnstr(temp, "/usr/X11/bin", sizeof(temp)) == NULL) {
-	snprintf(buf, sizeof(buf), "%s:/usr/X11/bin", temp);            
-	setenv("PATH", buf, TRUE);      
-      }
-      /* cd $HOME */
-      temp = getenv("HOME");
-      if (temp != NULL && temp[0]!=0) chdir(temp);
-	
-      execvp(argv[0], (char **const) argv);
-	
-      _exit(2);
-	
-    default:                            /* parent (child1) */
-      _exit(0);
-    }
-    break;
-      
-  default:                                /* parent */
-    waitpid(child1, &status, 0);
-  }
-}
-
-- (void) app_selected:sender
-{
-  int tag;
-  NSString *item;
-  
-  tag = [sender tag] - 1;
-  if (apps == nil || tag < 0 || tag >= [apps count])
-    return;
-  
-  item = [[apps objectAtIndex:tag] objectAtIndex:1];
-  
-  [self launch_client:item];
-}
-
-- (IBAction) apps_table_show:sender
-{
-  NSArray *columns;
-	
-  if (table_apps == nil) {
-    table_apps = [[NSMutableArray alloc] initWithCapacity:1];
-      
-    if (apps != nil)[table_apps addObjectsFromArray:apps];
-  }
-	
-  columns = [apps_table tableColumns];
-  [[columns objectAtIndex:0] setIdentifier:@"0"];
-  [[columns objectAtIndex:1] setIdentifier:@"1"];
-  [[columns objectAtIndex:2] setIdentifier:@"2"];
-	
-  [apps_table setDataSource:self];
-  [apps_table selectRow:0 byExtendingSelection:NO];
-	
-  [[apps_table window] makeKeyAndOrderFront:sender];
-}
-
-- (IBAction) apps_table_cancel:sender
-{
-  [[apps_table window] orderOut:sender];
-  [apps_table reloadData];
-	
-  [table_apps release];
-  table_apps = nil;
-}
-
-- (IBAction) apps_table_done:sender
-{
-  [apps_table deselectAll:sender];	/* flush edits? */
-	
-  [self remove_apps_menu];
-  [self install_apps_menu:table_apps];
-	
-  [NSApp prefs_set_array:@PREFS_APPSMENU value:table_apps];
-  [NSApp prefs_synchronize];
-	
-  [[apps_table window] orderOut:sender];
-	
-  [table_apps release];
-  table_apps = nil;
-}
-
-- (IBAction) apps_table_new:sender
-{
-  NSMutableArray *item;
-	
-  int row = [apps_table selectedRow], i;
-	
-  if (row < 0) row = 0;
-  else row = row + 1;
-	
-  i = row;
-  if (i > [table_apps count])
-    return;				/* avoid exceptions */
-	
-  [apps_table deselectAll:sender];
-	
-  item = [[NSMutableArray alloc] initWithCapacity:3];
-  [item addObject:@""];
-  [item addObject:@""];
-  [item addObject:@""];
-	
-  [table_apps insertObject:item atIndex:i];
-  [item release];
-	
-  [apps_table reloadData];
-  [apps_table selectRow:row byExtendingSelection:NO];
-}
-
-- (IBAction) apps_table_duplicate:sender
-{
-  int row = [apps_table selectedRow], i;
-  NSObject *item;
-	
-  if (row < 0) {
-    [self apps_table_new:sender];
-    return;
-  }
-	
-  i = row;
-  if (i > [table_apps count] - 1) return;				/* avoid exceptions */
-    
-  [apps_table deselectAll:sender];
-	
-  item = [[table_apps objectAtIndex:i] mutableCopy];
-  [table_apps insertObject:item atIndex:i];
-  [item release];
-	
-  [apps_table reloadData];
-  [apps_table selectRow:row+1 byExtendingSelection:NO];
-}
-
-- (IBAction) apps_table_delete:sender
-{
-  int row = [apps_table selectedRow];
-	
-  if (row >= 0)
-    {
-      int i = row;
-      
-      if (i > [table_apps count] - 1) return;			/* avoid exceptions */
-      
-      [apps_table deselectAll:sender];
-      
-      [table_apps removeObjectAtIndex:i];
-    }
-	
-  [apps_table reloadData];
-	
-  row = MIN (row, [table_apps count] - 1);
-  if (row >= 0)
-    [apps_table selectRow:row byExtendingSelection:NO];
-}
-
-- (int) numberOfRowsInTableView:(NSTableView *)tableView
-{
-  if (table_apps == nil) return 0;
-  
-  return [table_apps count];
-}
-
-- (id) tableView:(NSTableView *)tableView
-objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
-{
-  NSArray *item;
-  int col;
-	
-  if (table_apps == nil) return nil;
-	
-  col = [[tableColumn identifier] intValue];
-	
-  item = [table_apps objectAtIndex:row];
-  if ([item count] > col)
-    return [item objectAtIndex:col];
-  else
-    return @"";
-}
-
-- (void) tableView:(NSTableView *)tableView setObjectValue:(id)object
-    forTableColumn:(NSTableColumn *)tableColumn row:(int)row
-{
-  NSMutableArray *item;
-  int col;
-	
-  if (table_apps == nil) return;
-	
-  col = [[tableColumn identifier] intValue];
-	
-  item = [table_apps objectAtIndex:row];
-  [item replaceObjectAtIndex:col withObject:object];
-}
-
-- (void) hide_window:sender
-{
-  if ([X11App x_active])
-    QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMHideWindow);
-  else
-    NSBeep ();			/* FIXME: something here */
-}
-
-- (IBAction)bring_to_front:sender
-{
-  QuartzMessageServerThread(kXDarwinControllerNotify, 1, AppleWMBringAllToFront);
-}
-
-- (IBAction)close_window:sender
-{
-  if ([X11App x_active])
-    QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMCloseWindow);
-  else
-    [[NSApp keyWindow] performClose:sender];
-}
-
-- (IBAction)minimize_window:sender
-{
-  if ([X11App x_active])
-    QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMMinimizeWindow);
-  else
-    [[NSApp keyWindow] performMiniaturize:sender];
-}
-
-- (IBAction)zoom_window:sender
-{
-  if ([X11App x_active])
-    QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMZoomWindow);
-  else
-    [[NSApp keyWindow] performZoom:sender];
-}
-
-- (IBAction) next_window:sender
-{
-  QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMNextWindow);
-}
-
-- (IBAction) previous_window:sender
-{
-  QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMPreviousWindow);
-}
-
-- (IBAction) enable_fullscreen_changed:sender
-{
-  int value = ![enable_fullscreen intValue];
-	
-#ifdef DARWIN_DDX_MISSING
-  QuartzMessageServerThread (kXDarwinSetRootless, 1, value);
-#endif
-	
-  [NSApp prefs_set_boolean:@PREFS_ROOTLESS value:value];
-  [NSApp prefs_synchronize];
-}
-
-- (IBAction) toggle_fullscreen:sender
-{
-#ifdef DARWIN_DDX_MISSING
-  QuartzMessageServerThread (kXDarwinToggleFullscreen, 0);
-#endif
-}
-
-- (void) set_can_quit:(BOOL)state
-{
-  can_quit = state;
-}
-
-- (IBAction)prefs_changed:sender
-{
-  darwinFakeButtons = [fake_buttons intValue];
-  quartzUseSysBeep = [use_sysbeep intValue];
-  X11EnableKeyEquivalents = [enable_keyequivs intValue];
-  darwinSyncKeymap = [sync_keymap intValue];
-	
-  /* after adding prefs here, also add to [X11Application read_defaults]
-     and below */
-	
-  [NSApp prefs_set_boolean:@PREFS_FAKEBUTTONS value:darwinFakeButtons];
-  [NSApp prefs_set_boolean:@PREFS_SYSBEEP value:quartzUseSysBeep];
-  [NSApp prefs_set_boolean:@PREFS_KEYEQUIVS value:X11EnableKeyEquivalents];
-  [NSApp prefs_set_boolean:@PREFS_SYNC_KEYMAP value:darwinSyncKeymap];
-  [NSApp prefs_set_boolean:@PREFS_NO_AUTH value:![enable_auth intValue]];
-  [NSApp prefs_set_boolean:@PREFS_NO_TCP value:![enable_tcp intValue]];
-  [NSApp prefs_set_integer:@PREFS_DEPTH value:[depth selectedTag]];
-	
-  [NSApp prefs_synchronize];
-}
-
-- (IBAction) prefs_show:sender
-{
-  [fake_buttons setIntValue:darwinFakeButtons];
-  [use_sysbeep setIntValue:quartzUseSysBeep];
-  [enable_keyequivs setIntValue:X11EnableKeyEquivalents];
-  [sync_keymap setIntValue:darwinSyncKeymap];
-  [sync_keymap setEnabled:darwinKeymapFile == NULL];
-	
-  [enable_auth setIntValue:![NSApp prefs_get_boolean:@PREFS_NO_AUTH default:NO]];
-  [enable_tcp setIntValue:![NSApp prefs_get_boolean:@PREFS_NO_TCP default:NO]];
-  [depth selectItemAtIndex:[depth indexOfItemWithTag:[NSApp prefs_get_integer:@PREFS_DEPTH default:-1]]];
-	
-  [enable_fullscreen setIntValue:!quartzEnableRootless];
-	
-  [prefs_panel makeKeyAndOrderFront:sender];
-}
-
-- (IBAction) quit:sender
-{
-  QuartzMessageServerThread (kXDarwinQuit, 0);
-}
-
-- (IBAction) x11_help:sender
-{
-  AHLookupAnchor ((CFStringRef)NSLocalizedString(@"Mac Help", no comment), CFSTR ("mchlp2276"));
-}
-
-- (BOOL) validateMenuItem:(NSMenuItem *)item
-{
-  NSMenu *menu = [item menu];
-	
-  if (item == toggle_fullscreen_item)
-    return !quartzEnableRootless;
-  else if (menu == [window_separator menu] || menu == dock_menu
-	   || (menu == [x11_about_item menu] && [item tag] == 42))
-    return (AppleWMSelectedEvents () & AppleWMControllerNotifyMask) != 0;
-  else
-    return TRUE;
-}
-
-- (void) applicationDidHide:(NSNotification *)notify
-{
-  QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMHideAll);
-}
-
-- (void) applicationDidUnhide:(NSNotification *)notify
-{
-  QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMShowAll);
-}
-
-- (NSApplicationTerminateReply) applicationShouldTerminate:sender
-{
-  NSString *msg;
-	
-  if (can_quit || [X11App prefs_get_boolean:@PREFS_NO_QUIT_ALERT default:NO])
-    return NSTerminateNow;
-	
-  /* Make sure we're frontmost. */
-  [NSApp activateIgnoringOtherApps:YES];
-	
-  msg = NSLocalizedString (@"Are you sure you want to quit X11?\n\nIf you quit X11, any X11 applications you are running will stop immediately and you will lose any changes you have not saved.", @"Dialog when quitting");
-	
-  /* FIXME: safe to run the alert in here? Or should we return Later
-     and then run the alert on a timer? It seems to work here, so.. */
-	
-  return (NSRunAlertPanel (nil, msg, NSLocalizedString (@"Quit", @""),
-			   NSLocalizedString (@"Cancel", @""), nil)
-	  == NSAlertDefaultReturn) ? NSTerminateNow : NSTerminateCancel;
-}
-
-- (void) applicationWillTerminate:(NSNotification *)aNotification
-{
-  [X11App prefs_synchronize];
-	
-  /* shutdown the X server, it will exit () for us. */
-  QuartzMessageServerThread (kXDarwinQuit, 0);
-	
-  /* In case it doesn't, exit anyway after a while. */
-  while (sleep (10) != 0) ;
-  exit (1);
-}
-
-- (void) server_ready
-{
-  x_list *node;
-	
-  finished_launching = YES;
-	
-  for (node = pending_apps; node != NULL; node = node->next)
-    {
-      NSString *filename = node->data;
-      [self launch_client:filename];
-      [filename release];
-    }
-	
-  x_list_free (pending_apps);
-  pending_apps = NULL;
-}
-
-- (BOOL) application:(NSApplication *)app openFile:(NSString *)filename
-{
-  const char *name = [filename UTF8String];
-	
-  if (finished_launching)
-    [self launch_client:filename];
-  else if (name[0] != ':')		/* ignore display names */
-    pending_apps = x_list_prepend (pending_apps, [filename retain]);
-	
-  /* FIXME: report failures. */
-  return YES;
-}
-
- at end
-
-void X11ControllerMain (int argc, const char *argv[],
-			void (*server_thread) (void *), void *server_arg)
-{
-  X11ApplicationMain (argc, argv, server_thread, server_arg);
-}
diff --git a/hw/darwin/apple/Xquartz.man b/hw/darwin/apple/Xquartz.man
deleted file mode 100644
index 37a7f1a..0000000
--- a/hw/darwin/apple/Xquartz.man
+++ /dev/null
@@ -1,156 +0,0 @@
-.TH XQUARTZ 1 __vendorversion__
-.SH NAME
-Xquartz \- X window system server for Quartz operating system
-.SH SYNOPSIS
-.B Xquartz
-[ options ] ...
-.SH DESCRIPTION
-.I Xquartz
-is the X window server for Mac OS X provided by Apple.
-.I Xquartz
-runs in parallel with Aqua in rootless mode. In rootless mode, the X
-window system and Mac OS X share your display.  The root window of the
-X11 display is the size of the screen and contains all the other
-windows. The X11 root window is not displayed in rootless mode as Mac
-OS X handles the desktop background.
-.SH OPTIONS
-.PP
-In addition to the normal server options described in the \fIXserver(1)\fP
-manual page, \fIXquartz\fP accepts the following command line switches:
-.TP 8
-.B \-fakebuttons
-Emulates a 3 button mouse using modifier keys. By default, the Command modifier
-is used to emulate button 2 and Option is used for button 3. Thus, clicking the
-first mouse button while holding down Command will act like clicking
-button 2. Holding down Option will simulate button 3.
-.TP 8
-.B \-nofakebuttons
-Do not emulate a 3 button mouse. This is the default.
-.TP 8
-.B "\-fakemouse2 \fImodifiers\fP"
-Change the modifier keys used to emulate the second mouse button. By default,
-Command is used to emulate the second button. Any combination of the following
-modifier names may be used: Shift, Option, Control, Command, Fn. For example,
-.B \-fakemouse2 """Option,Shift""
-will set holding Option, Shift and clicking on button one as equivalent to
-clicking the second mouse button.
-.TP 8
-.B "\-fakemouse3 \fImodifiers\fP"
-Change the modifier keys used to emulate the third mouse button. By default,
-Option is used to emulate the third button. Any combination of the following
-modifier names may be used: Shift, Option, Control, Command, Fn. For example,
-.B \-fakemouse3 """Control,Shift""
-will set holding Control, Shift and clicking on button one as equivalent to
-clicking the third mouse button.
-.TP 8
-.B "\-swapAltMeta"
-Swaps the meaning of the Alt and Meta modifier keys.
-.TP 8
-.B "\-keymap \fIfile\fP"
-On startup \fIXquartz\fP translates a Darwin keymapping into an X keymap.
-The default is to read this keymapping from USA.keymapping. With this option
-the keymapping will be read from \fIfile\fP instead. If the file's path is
-not specified, it will be searched for in Library/Keyboards/ underneath the
-following directories (in order): ~, /, /Network, /System.
-.TP 8
-.B \-nokeymap
-On startup \fIXquartz\fP translates a Darwin keymapping into an X keymap.
-With this option \fIXquartz\fP queries the kernel for the current keymapping
-instead of reading it from a file. This will often fail on newer kernels.
-.TP 8
-.B "\-depth \fIdepth\fP"
-Specifies the color bit depth to use. Currently only 15, and 24 color
-bits per pixel are supported. If not specified, defaults to the depth
-of the main display.
-.SH CUSTOMIZATION
-\fIXquartz\fP can also be customized using the defaults(1) command. The available options are:
-.TP 8
-.B defaults write com.apple.x11 enable_fake_buttons -boolean true
-Equivalent to the \fB-fakebuttons\fP command line option.
-.TP 8
-.B defaults write com.apple.x11 fake_button2 \fImodifiers\fP
-Equivalent to the \fB-fakemouse2\fP option.
-.TP 8
-.B defaults write com.apple.x11 fake_button3 \fImodifiers\fP
-Equivalent to the \fB-fakemouse3\fP option.
-.TP 8
-.B defaults write com.apple.x11 swap_alt_meta -boolean true
-Equivalent to the \fB-swapAltMeta\fP option.
-.TP 8
-.B defaults write com.apple.x11 keymap_file \fIfilename\fP
-Equivalent to the \fB-keymap\fP option.
-.TP 8
-.B defaults write com.apple.x11 no_quit_alert -boolean true
-Disables the alert dialog displayed when attempting to quit X11.
-.TP 8
-.B defaults write com.apple.x11 no_auth -boolean true
-Stops the X server requiring that clients authenticate themselves when
-connecting. See Xsecurity(__miscmansuffix__).
-.TP 8
-.B defaults write com.apple.x11 nolisten_tcp -boolean true
-Prevents the X server accepting remote connections.
-.TP 8
-.B defaults write com.apple.x11 xinit_kills_server -boolean false
-Stops the X server exiting when the xinitrc script terminates.
-.TP 8
-.B defaults write com.apple.x11 fullscreen_hotkeys -boolean false
-Allows system hotkeys to be handled while in X11 fullscreen mode.
-.TP 8
-.B defaults write com.apple.x11 enable_system_beep -boolean false
-Don't use the standard system beep effect for X11 alerts.
-.TP 8
-.B defaults write com.apple.x11 enable_key_equivalents -boolean false
-Disable menu keyboard equivalents while X11 windows are focused.
-.TP 8
-.B defaults write com.apple.x11 depth \fIdepth\fP
-Equivalent to the \fB-depth\fP option.
-.SH "SEE ALSO"
-.PP
-X(__miscmansuffix__), XFree86(1), Xserver(1), xdm(1), xinit(1)
-.PP
-.SH AUTHORS
-XFree86 was originally ported to Mac OS X Server by John Carmack. Dave
-Zarzycki used this as the basis of his port of XFree86 4.0 to Darwin 1.0.
-Torrey T. Lyons improved and integrated this code into the XFree86
-Project's mainline for the 4.0.2 release.
-.PP
-The following members of the XonX Team contributed to the following
-releases (in alphabetical order):
-.TP 4
-XFree86 4.1.0:
-.br
-Rob Braun - Darwin x86 support
-.br
-Torrey T. Lyons - Project Lead
-.br
-Andreas Monitzer - Cocoa version of XDarwin front end
-.br
-Gregory Robert Parker - Original Quartz implementation
-.br
-Christoph Pfisterer - Dynamic shared X libraries
-.br
-Toshimitsu Tanaka - Japanese localization
-.TP 4
-XFree86 4.2.0:
-.br
-Rob Braun - Darwin x86 support
-.br
-Pablo Di Noto - Spanish localization
-.br
-Paul Edens - Dutch localization
-.br
-Kyunghwan Kim - Korean localization
-.br
-Mario Klebsch - Non-US keyboard support
-.br
-Torrey T. Lyons - Project Lead
-.br
-Andreas Monitzer - German localization
-.br
-Patrik Montgomery - Swedish localization
-.br
-Greg Parker - Rootless support
-.br
-Toshimitsu Tanaka - Japanese localization
-.br
-Olivier Verdier - French localization
diff --git a/hw/darwin/bundle/Dutch.lproj/Credits.rtf b/hw/darwin/bundle/Dutch.lproj/Credits.rtf
deleted file mode 100644
index 5858e59..0000000
--- a/hw/darwin/bundle/Dutch.lproj/Credits.rtf
+++ /dev/null
@@ -1,168 +0,0 @@
-{\rtf1\mac\ansicpg10000\cocoartf102
-{\fonttbl\f0\fswiss\fcharset77 Helvetica;\f1\fswiss\fcharset77 Helvetica-Bold;\f2\fswiss\fcharset77 Helvetica-Oblique;
-}
-{\colortbl;\red255\green255\blue255;}
-\vieww9000\viewh9000\viewkind0
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
-
-\f0\fs24 \cf0 This product includes software developed by The XFree86 Project, Inc  (http://www.xfree86.org/) and its contributors. The following people contributed to Darwin/Mac OS X support.\
-\
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-
-\f1\b \cf0 Contributors to Xorg Foundation Release:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Kaleb KEITHLEY\
-     
-\f2\i Working left and right Ctrl, Alt (Option), Meta (Command) and Shift keys.
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\f1\b \cf0 Contributors to XFree86 4.4:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 John Harper\
-     
-\f2\i Rootless acceleration and Apple-WM extension
-\f0\i0 \
-Torrey T. Lyons\
-     
-\f2\i Project Lead
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 Additional XonX Contributors to XFree86 4.3:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Fabr\'92cio Luis de Castro\
-     
-\f2\i Portuguese localization
-\f0\i0 \
-Michael Oland\
-     
-\f2\i New XDarwin icon
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 XonX Contributors to XFree86 4.2:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Rob Braun\
-     
-\f2\i Darwin x86 support
-\f0\i0 \
-Pablo Di Noto\
-
-\f2\i      Spanish localization
-\f0\i0 \
-Paul Edens\
-
-\f2\i      Dutch localization
-\f0\i0 \
-Kyunghwan Kim\
-
-\f2\i      Korean localization
-\f0\i0 \
-Mario Klebsch\
-     
-\f2\i Non-US keyboard support
-\f0\i0 \
-Torrey T. Lyons\
-     
-\f2\i Project Lead
-\f0\i0 \
-Andreas Monitzer\
-     
-\f2\i German localization
-\f0\i0 \
-Patrik Montgomery\
-
-\f2\i      Swedish localization
-\f0\i0 \
-Greg Parker\
-     
-\f2\i Rootless support
-\f0\i0 \
-Toshimitsu Tanaka\
-     
-\f2\i Japanese localization
-\f0\i0 \
-Olivier Verdier\
-
-\f2\i      French localization
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 Special Thanks:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Devin Poolman and Zero G Software, Inc.\
-
-\f2\i      Installer
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 XonX Team Members\
-Contributing to XFree86 4.1:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Rob Braun\
-     
-\f2\i Darwin x86 support
-\f0\i0 \
-Torrey T. Lyons\
-     
-\f2\i Project Lead
-\f0\i0 \
-Andreas Monitzer\
-     
-\f2\i Cocoa version of XDarwin front end
-\f0\i0 \
-Greg Parker\
-     
-\f2\i Original Quartz implementation
-\f0\i0 \
-Christoph Pfisterer\
-     
-\f2\i Dynamic shared libraries
-\f0\i0 \
-Toshimitsu Tanaka\
-     
-\f2\i Japanese localization
-\f0\i0 \
-\
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-
-\f1\b \cf0 Special Thanks:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Tiago Ribeiro\
-     
-\f2\i XDarwin icon
-\f0\i0 \
-\
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-
-\f1\b \cf0 History:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 John Carmack\
-     
-\f2\i Original XFree86 port to Mac OS X Server
-\f0\i0 \
-Dave Zarzycki\
-     
-\f2\i XFree86 4.0 port to Darwin 1.0
-\f0\i0 \
-Torrey T. Lyons\
-     
-\f2\i Integration into XFree86 Project for 4.0.2}
\ No newline at end of file
diff --git a/hw/darwin/bundle/Dutch.lproj/Localizable.strings b/hw/darwin/bundle/Dutch.lproj/Localizable.strings
deleted file mode 100644
index 4fe16b3..0000000
Binary files a/hw/darwin/bundle/Dutch.lproj/Localizable.strings and /dev/null differ
diff --git a/hw/darwin/bundle/Dutch.lproj/MainMenu.nib/classes.nib b/hw/darwin/bundle/Dutch.lproj/MainMenu.nib/classes.nib
deleted file mode 100644
index 77f345a..0000000
--- a/hw/darwin/bundle/Dutch.lproj/MainMenu.nib/classes.nib
+++ /dev/null
@@ -1,72 +0,0 @@
-{
-    IBClasses = (
-        {
-            ACTIONS = {showHelp = id; }; 
-            CLASS = FirstResponder; 
-            LANGUAGE = ObjC; 
-            SUPERCLASS = NSObject; 
-        }, 
-        {
-            ACTIONS = {close = id; pickFile = id; saveChanges = id; setKey = id; }; 
-            CLASS = Preferences; 
-            LANGUAGE = ObjC; 
-            OUTLETS = {
-                addToPathButton = id; 
-                addToPathField = id; 
-                button2ModifiersMatrix = id; 
-                button3ModifiersMatrix = id; 
-                depthButton = id; 
-                displayField = id; 
-                dockSwitchButton = id; 
-                fakeButton = id; 
-                keymapFileField = id; 
-                modeMatrix = id; 
-                modeWindowButton = id; 
-                mouseAccelChangeButton = id; 
-                startupHelpButton = id; 
-                switchKeyButton = id; 
-                systemBeepButton = id; 
-                useDefaultShellMatrix = id; 
-                useOtherShellField = id; 
-                useXineramaButton = id; 
-                window = id; 
-            }; 
-            SUPERCLASS = NSObject; 
-        }, 
-        {
-            CLASS = XApplication; 
-            LANGUAGE = ObjC; 
-            OUTLETS = {preferences = id; xserver = id; }; 
-            SUPERCLASS = NSApplication; 
-        }, 
-        {
-            ACTIONS = {
-                bringAllToFront = id; 
-                closeHelpAndShow = id; 
-                itemSelected = id; 
-                nextWindow = id; 
-                previousWindow = id; 
-                showAction = id; 
-                showSwitchPanel = id; 
-                startFullScreen = id; 
-                startRootless = id; 
-            }; 
-            CLASS = XServer; 
-            LANGUAGE = ObjC; 
-            OUTLETS = {
-                dockMenu = NSMenu; 
-                helpWindow = NSWindow; 
-                modeWindow = NSWindow; 
-                startFullScreenButton = NSButton; 
-                startRootlessButton = NSButton; 
-                startupHelpButton = NSButton; 
-                startupModeButton = NSButton; 
-                switchWindow = NSPanel; 
-                windowMenu = NSMenu; 
-                windowSeparator = NSMenuItem; 
-            }; 
-            SUPERCLASS = NSObject; 
-        }
-    ); 
-    IBVersion = 1; 
-}
\ No newline at end of file
diff --git a/hw/darwin/bundle/Dutch.lproj/MainMenu.nib/objects.nib b/hw/darwin/bundle/Dutch.lproj/MainMenu.nib/objects.nib
deleted file mode 100644
index 8e9224c..0000000
Binary files a/hw/darwin/bundle/Dutch.lproj/MainMenu.nib/objects.nib and /dev/null differ
diff --git a/hw/darwin/bundle/Dutch.lproj/Makefile.am b/hw/darwin/bundle/Dutch.lproj/Makefile.am
deleted file mode 100644
index 49a3ec5..0000000
--- a/hw/darwin/bundle/Dutch.lproj/Makefile.am
+++ /dev/null
@@ -1,39 +0,0 @@
-BINDIR = ${bindir}
-include $(top_srcdir)/cpprules.in
-XINITDIR = $(libdir)/X11/xinit
-XDEFS = \
-        -DX_VERSION="$(PLIST_VERSION_STRING)" \
-        -DX_PRE_RELEASE="$(PRE)" \
-        -DX_REL_DATE="$(XORG_DATE)" \
-        -DX_VENDOR_NAME="$(VENDOR_STRING)" \
-        -DX_VENDOR_LINK="$(PLIST_VENDOR_WEB)"
-
-resourcesdir = @APPLE_APPLICATIONS_DIR@/XDarwin.app/Contents/Resources
-
-Dutchlprojdir = $(resourcesdir)/Dutch.lproj
-
-Dutchlproj_DATA = \
-		    XDarwinHelp.html \
-		    InfoPlist.strings \
-		    Credits.rtf Localizable.strings Localizable.strings
-
-Dutchlprojnibdir = $(Dutchlprojdir)/MainMenu.nib
-Dutchlprojnib_DATA = \
-		       MainMenu.nib/classes.nib \
-		       MainMenu.nib/objects.nib
-
-InfoPlist.strings: $(srcdir)/../English.lproj/InfoPlist.strings.cpp
-	 $(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) | $(SED) -e's/__quote__/"/g' | iconv -t UTF-16 > $@
-
-XDarwinHelp.html: XDarwinHelp.html.cpp
-	$(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) > $@
-
-CLEANFILES = XDarwinHelp.html InfoPlist.strings 
-
-EXTRA_DIST = \
-	Credits.rtf Localizable.strings \
-	Localizable.strings \
-	MainMenu.nib/classes.nib \
-	MainMenu.nib/objects.nib \
-	XDarwinHelp.html.cpp
-
diff --git a/hw/darwin/bundle/Dutch.lproj/XDarwinHelp.html.cpp b/hw/darwin/bundle/Dutch.lproj/XDarwinHelp.html.cpp
deleted file mode 100644
index 4b8e6f5..0000000
--- a/hw/darwin/bundle/Dutch.lproj/XDarwinHelp.html.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-<html>
-<head>
-<title>XDarwin Help</title>
-</head>
-<body>
-<center>
-    <h1>XDarwin X Server for Mac OS X</h1>
-    X_VENDOR_NAME X_VERSION<br>
-    Release Date: X_REL_DATE
-</center>
-<h2>Inhoud</h2>
-<ol>
-    <li><A HREF="#notice">Belangrijke Informatie</A></li>
-    <li><A HREF="#usage">Gebruik</A></li>
-    <li><A HREF="#path">Instellen van het Path</A></li>
-    <li><A HREF="#prefs">Voorkeursinstellingen</A></li>
-    <li><A HREF="#license">Licentie</A></li>
-</ol>
-<center>
-    <h2><a NAME="notice">Belangrijke Informatie</a></h2>
-</center>
-<blockquote>
-#if X_PRE_RELEASE
-Dit is een pre-release van XDarwin, waarvoor geen ondersteuning beschikbaar is.  Rapporteren van bugs en aanleveren van patches kan op de <A HREF="http://sourceforge.net/projects/xonx/">XonX project pagina</A> bij SourceForge.  Kijk alvorens een bug te rapporteren in een pre-release eerst of een nieuwe versie beschikbaar is bij <A HREF="http://sourceforge.net/projects/xonx/">XonX</A> of de X_VENDOR_LINK.
-#else
-Als de server ouder is dan 6-12 maanden, of als uw hardware nieuwer is dan de bovenstaande datum, kijk dan of een nieuwe versie beschikbaar is voor u een probleem aanmeldt.  Rapporteren van bugs en aanleveren van patches kan op de <A HREF="http://sourceforge.net/projects/xonx/">XonX project pagina</A> bij SourceForge.
-#endif
-</blockquote>
-<blockquote>
-Deze software is beschikbaar gesteld onder de voorwaarden van de <A HREF="#license">MIT X11 / X Consortium Licentie</A> en is beschikbaar 'AS IS',zonder enige garantie. Lees s.v.p. de <A HREF="#license">Licentie</A> voor gebruik.</blockquote>
-
-<h2><a NAME="usage">Gebruik</a></h2>
-<p>XDarwin is een open-source X server van het <a HREF="http://www.x.org/">X Window Systeem</a>. This version of XDarwin was produced by the X_VENDOR_LINK.  XDarwin werkt op Mac OS X in schermvullende of rootless modus.</p>
-<p>Het X window systeem in schermvullende modus neemt het hele beeldscherm in beslag. U schakelt terug naar de Mac OS X desktop door de toesten Command-Option-A in te drukken. Deze toetsencombinatie kunt u veranderen in de Voorkeuren. Op de Mac OS X desktop klikt u op de XDarwin icoon in de Dock om weer naar het X window systeem te schakelen.  (In de Voorkeuren kunt er voor kiezen om een apart XDarwin schakelpaneel te gebruiken op de Mac OS X desktop.)</p>
-<p>In rootless modus verschijnen het X window systeem en Aqua (de Mac OS X desktop) tegelijk op het scherm. Het achtergrondscherm van X11, waarbinnen alle X11 vensters vallen, is net zo groot als het gehele scherm, maar het achtergrondscherm zelf is onzichtbaar.</p>
-
-<h3>Meerknopsmuis emulatie</h3>
-<p>Voor veel X11 programma's hebt u een 3-knops muis nodig.  Met een 1-knops muis kunt u een 3-knops muis nabootsen door een toets in te drukken terwijl u klikt met de muis.  Het instellen hiervan kan bij Voorkeuren, "Meerknopsmuis emulatie" in "Algemeen".  Emulatie is standaard ingeschakeld: ingedrukt houden van de "command" toets terwijl u klikt emuleert knop 2, ingedrukt houden van "option" emuleert knop 3.  Deze toetsen kunt u dus wijzigen in de Voorkeuren.  Let op: als u xmodmap gebruikt om de indeling van het toetsenbord te wijzigen, moet u toch de oorspronkelijke toetsen op het toetsenbord gebruiken voor deze functie.</p>
-
-<h2><a NAME="path">Instellen van het Path</a></h2>
-<p>Het path is de lijst van directories waarin gezocht wordt naar commando's.  De X11 commando's staan in de directory <code>/usr/X11R6/bin</code>, die dus aan uw path moet worden toegevoegd.  XDarwin doet dit automatisch voor u en kan extra directories toevoegen waarin u commando's hebt ge&iuml;nstalleerd.</p>
-
-<p>Ervaren gebruikers zullen het path al correct hebben ingesteld in de configuratiebestanden voor hun shell.  In dat geval kunt u XDarwin via de Voorkeuren vertellen het path niet te wijzigen.  XDarwin start de eerste X11 clients binnen de standaard login shell van de gebruiker (bij de Voorkeuren kunt u een afwijkende shell opgeven).  Het instellen van het path is afhankelijk van de shell.  Zie hiervoor de man pages voor de shell.</p>
-
-<p>Het kan handig zijn de manualpages voor X11 toe te voegen aan de lijst waarin gezocht wordt als u documentatie opvraagt.  De manualpages voor X11 staan in <code>/usr/X11R6/man</code> en de <code>MANPATH</code> environment variable bevat de lijst van directories waarin naar documentatie wordt gezocht.</p>
-
-<h2><a NAME="prefs">Voorkeursinstellingen</a></h2>
-<p>Een aantal instellingen kan worden gewijzigd door "Voorkeuren..." te kiezen in het "XDarwin" menu.  Wijzigingen van de instellingen genoemd onder "Start" gaan pas in als u XDarwin opnieuw hebt gestart.  Een wijziging van de overige instellingen is direct effectief.  Hier onder vindt u de verschillende mogelijkheden beschreven:</p>
-
-<h3>Algemeen</h3>
-<ul>
-    <li><b>Gebruik systeempiep voor X11:</b> Als u dit inschakelt wordt het Mac OS X  waarschuwingssignaal ook gebruikt door X11, anders gebruikt X11 een simpele pieptoon (dit is de standaardinstelling).</li>
-    <li><b>Wijzigen muis-versnelling door X11 mogelijk:</b> In een standaard X window systeem kan de window manager de muis-versnelling aanpassen.  Dit kan verwarrend zijn omdat de snelheid onder X11 dan verschillend kan zijn van de snelheid die u in Mac OS X bij Systeemvoorkeuren hebt ingesteld.  Om verwarring te voorkomen is de standaardinstelling dat X11 de versnelling niet kan wijzigen.</li>
-    <li><b>Meerknopsmuis emulatie:</b> Dit is hierboven beschreven bij <a HREF="#usage">Gebruik</a>.  Als emulatie is ingeschakeld moet u de gekozen toetsen ingedrukt houden terwijl u met de muis klikt om de tweede en derde muisknop na te bootsen.</li>
-</ul>
-
-<h3>Start</h3>
-<ul>
-    <li><b>Standaard modus:</b> Hier kiest u de standaard scherm-modus: schermvullend of rootless (hierboven beschreven bij <a HREF="#usage">Gebruik</a>).  U kunt ook kiezen tijdens het starten van XDarwin, zie de optie hieronder.</li>
-    <li><b>Kies scherm-modus tijdens start:</b> Dit is standaard ingeschakeld zodat u tijdens het starten van XDarwin kunt kiezen tussen schermvullend en rootless scherm-modus.  Als u dit uitschakelt start XDarwin in de standaard modus zonder u iets te vragen.</li>
-    <li><b>X11 scherm nummer:</b> Met X11 kunnen meerdere schermen worden aangestuurd door verschillende X servers op dezelfde computer.  Als u meerdere X servers tegelijk wilt gebruiken stelt u hier het scherm nummer in dat door XDarwin wordt gebruikt.</li>
-    <li><b>Xinerama multi-monitor ondersteuning mogelijk:</b> XDarwin ondersteunt het gebruik van meerdere monitoren met Xinerama, waarbij elke monitor wordt gezien als deel van &eacute;&eacute;n groot rechthoekig scherm.  U kunt Xinerama hier uitschakelen, maar XDarwin werkt op dit moment zonder Xinerama niet goed met meerdere monitoren.  Als u maar 1 monitor gebruikt is deze instelling automatisch uitgeschakeld.</li>
-    <li><b>Toetsenbordindeling-bestand:</b> Een toetsenbordindeling-bestand wordt bij het starten geladen en omgezet naar een X11 toetsenbordindeling.  Voor verschillende talen vindt u toetsenbordindelingen in de directory <code>/System/Library/Keyboards</code>.</li>
-    <li><b>Bij starten eerste X11 clients:</b> Als XDarwin start, wordt  <code>xinit</code> uitgevoerd om de X window manager en andere X clients te starten (zie "<code>man xinit</code>").  Voordat XDarwin <code>xinit</code> uitvoert voegt het de opgegeven directories toe aan het path.  Standaard wordt alleen <code>/usr/X11R6/bin</code> toegevoegd.  U kunt meerdere directories opgeven, gescheiden door een dubbelepunt.  X clients worden gestart met de standaard login shell van de gebruiker met gebruik van de configuratiebestanden voor die shell.  U kunt een afwijkende shell opgeven.</li>
-</ul>
-
-<h3>Schermvullend</h3>
-<ul>
-    <li><b>Toetscombinatie knop:</b> Klik op deze knop om de toetscombinatie te wijzigen waarmee u tussen de Mac OS X desktop en X11 schakelt.  Als toetscombinatie kunt u elke combinatie gebruiken van de shift, control, command en option toetsen samen met &eacute;&eacute;n normale toets.</li>
-    <li><b>Klikken op icoon in Dock schakelt naar X11:</b> Hiermee is een klik op de XDarwin icoon in de Dock voldoende om naar X11 te schakelen.  In sommige versies van Mac OS X verdwijnt soms de cursor als u deze mogelijkheid gebruikt en daarna terugkeert naar de Mac OS X desktop.</li>
-    <li><b>Toon help bij schermvullend starten:</b> Hiermee wordt een inleidend scherm getoond als XDarwin schermvullend start.</li>
-    <li><b>Kleurdiepte:</b> In de schermvullende modus kan X11 een andere kleurdiepte gebruiken dan Aqua (en de Mac OS X desktop).  Als u "Huidig" kiest, neemt XDarwin bij het starten de kleurdiepte over van Aqua.  U kunt ook kiezen voor 8, 15 of 24 bits.</li>
-</ul>
-
-<h2><a NAME="license">Licentie</a></h2>
-The main license for XDarwin is one based on the traditional MIT X11 / X Consortium License, which does not impose any conditions on modification or redistribution of source code or binaries other than requiring that copyright/license notices are left intact. For more information and additional copyright/licensing notices covering some sections of the code, please refer to the source code.
-<H3><A NAME="3"></A>X Consortium License</H3>
-<p>Copyright (C) 1996 X Consortium</p>
-<p>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:</p>
-<p>The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.</p>
-<p>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 X CONSORTIUM 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.</p>
-<p>Except as contained in this notice, the name of the X Consortium 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 X Consortium.</p>
-<p>X Window System is a trademark of X Consortium, Inc.</p>
-</body>
-</html>
-
diff --git a/hw/darwin/bundle/English.lproj/Credits.rtf b/hw/darwin/bundle/English.lproj/Credits.rtf
deleted file mode 100644
index 34408e7..0000000
--- a/hw/darwin/bundle/English.lproj/Credits.rtf
+++ /dev/null
@@ -1,168 +0,0 @@
-{\rtf1\mac\ansicpg10000\cocoartf102
-{\fonttbl\f0\fswiss\fcharset77 Helvetica;\f1\fswiss\fcharset77 Helvetica-Bold;\f2\fswiss\fcharset77 Helvetica-Oblique;
-}
-{\colortbl;\red255\green255\blue255;}
-\vieww5160\viewh6300\viewkind0
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
-
-\f0\fs24 \cf0 This product includes software developed by The XFree86 Project, Inc  (http://www.xfree86.org/) and its contributors. The following people contributed to Darwin/Mac OS X support.\
-\
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-
-\f1\b \cf0 Contributors to Xorg Foundation Release:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Kaleb KEITHLEY\
-     
-\f2\i Working left and right Ctrl, Alt (Option), Meta (Command) and Shift keys.
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\f1\b \cf0 Contributors to XFree86 4.4:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 John Harper\
-     
-\f2\i Rootless acceleration and Apple-WM extension
-\f0\i0 \
-Torrey T. Lyons\
-     
-\f2\i Project Lead
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 Additional XonX Contributors to XFree86 4.3:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Fabr\'92cio Luis de Castro\
-     
-\f2\i Portuguese localization
-\f0\i0 \
-Michael Oland\
-     
-\f2\i New XDarwin icon
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 XonX Contributors to XFree86 4.2:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Rob Braun\
-     
-\f2\i Darwin x86 support
-\f0\i0 \
-Pablo Di Noto\
-
-\f2\i      Spanish localization
-\f0\i0 \
-Paul Edens\
-
-\f2\i      Dutch localization
-\f0\i0 \
-Kyunghwan Kim\
-
-\f2\i      Korean localization
-\f0\i0 \
-Mario Klebsch\
-     
-\f2\i Non-US keyboard support
-\f0\i0 \
-Torrey T. Lyons\
-     
-\f2\i Project Lead
-\f0\i0 \
-Andreas Monitzer\
-     
-\f2\i German localization
-\f0\i0 \
-Patrik Montgomery\
-
-\f2\i      Swedish localization
-\f0\i0 \
-Greg Parker\
-     
-\f2\i Rootless support
-\f0\i0 \
-Toshimitsu Tanaka\
-     
-\f2\i Japanese localization
-\f0\i0 \
-Olivier Verdier\
-
-\f2\i      French localization
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 Special Thanks:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Devin Poolman and Zero G Software, Inc.\
-
-\f2\i      Installer
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 XonX Team Members\
-Contributing to XFree86 4.1:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Rob Braun\
-     
-\f2\i Darwin x86 support
-\f0\i0 \
-Torrey T. Lyons\
-     
-\f2\i Project Lead
-\f0\i0 \
-Andreas Monitzer\
-     
-\f2\i Cocoa version of XDarwin front end
-\f0\i0 \
-Greg Parker\
-     
-\f2\i Original Quartz implementation
-\f0\i0 \
-Christoph Pfisterer\
-     
-\f2\i Dynamic shared libraries
-\f0\i0 \
-Toshimitsu Tanaka\
-     
-\f2\i Japanese localization
-\f0\i0 \
-\
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-
-\f1\b \cf0 Special Thanks:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Tiago Ribeiro\
-     
-\f2\i XDarwin icon
-\f0\i0 \
-\
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-
-\f1\b \cf0 History:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 John Carmack\
-     
-\f2\i Original XFree86 port to Mac OS X Server
-\f0\i0 \
-Dave Zarzycki\
-     
-\f2\i XFree86 4.0 port to Darwin 1.0
-\f0\i0 \
-Torrey T. Lyons\
-     
-\f2\i Integration into XFree86 Project for 4.0.2}
\ No newline at end of file
diff --git a/hw/darwin/bundle/English.lproj/InfoPlist.strings.cpp b/hw/darwin/bundle/English.lproj/InfoPlist.strings.cpp
deleted file mode 100644
index 268b800..0000000
--- a/hw/darwin/bundle/English.lproj/InfoPlist.strings.cpp
+++ /dev/null
@@ -1,4 +0,0 @@
-/* English versions of the Info.plist keys; used by most localizations. */
-/* Most of these are set in the target application settings. */
-
-NSHumanReadableCopyright = __quote__ X_VENDOR_NAME X_VERSION __quote__;
diff --git a/hw/darwin/bundle/English.lproj/Localizable.strings b/hw/darwin/bundle/English.lproj/Localizable.strings
deleted file mode 100644
index f2e8e3c..0000000
Binary files a/hw/darwin/bundle/English.lproj/Localizable.strings and /dev/null differ
diff --git a/hw/darwin/bundle/English.lproj/MainMenu.nib/classes.nib b/hw/darwin/bundle/English.lproj/MainMenu.nib/classes.nib
deleted file mode 100644
index 77f345a..0000000
--- a/hw/darwin/bundle/English.lproj/MainMenu.nib/classes.nib
+++ /dev/null
@@ -1,72 +0,0 @@
-{
-    IBClasses = (
-        {
-            ACTIONS = {showHelp = id; }; 
-            CLASS = FirstResponder; 
-            LANGUAGE = ObjC; 
-            SUPERCLASS = NSObject; 
-        }, 
-        {
-            ACTIONS = {close = id; pickFile = id; saveChanges = id; setKey = id; }; 
-            CLASS = Preferences; 
-            LANGUAGE = ObjC; 
-            OUTLETS = {
-                addToPathButton = id; 
-                addToPathField = id; 
-                button2ModifiersMatrix = id; 
-                button3ModifiersMatrix = id; 
-                depthButton = id; 
-                displayField = id; 
-                dockSwitchButton = id; 
-                fakeButton = id; 
-                keymapFileField = id; 
-                modeMatrix = id; 
-                modeWindowButton = id; 
-                mouseAccelChangeButton = id; 
-                startupHelpButton = id; 
-                switchKeyButton = id; 
-                systemBeepButton = id; 
-                useDefaultShellMatrix = id; 
-                useOtherShellField = id; 
-                useXineramaButton = id; 
-                window = id; 
-            }; 
-            SUPERCLASS = NSObject; 
-        }, 
-        {
-            CLASS = XApplication; 
-            LANGUAGE = ObjC; 
-            OUTLETS = {preferences = id; xserver = id; }; 
-            SUPERCLASS = NSApplication; 
-        }, 
-        {
-            ACTIONS = {
-                bringAllToFront = id; 
-                closeHelpAndShow = id; 
-                itemSelected = id; 
-                nextWindow = id; 
-                previousWindow = id; 
-                showAction = id; 
-                showSwitchPanel = id; 
-                startFullScreen = id; 
-                startRootless = id; 
-            }; 
-            CLASS = XServer; 
-            LANGUAGE = ObjC; 
-            OUTLETS = {
-                dockMenu = NSMenu; 
-                helpWindow = NSWindow; 
-                modeWindow = NSWindow; 
-                startFullScreenButton = NSButton; 
-                startRootlessButton = NSButton; 
-                startupHelpButton = NSButton; 
-                startupModeButton = NSButton; 
-                switchWindow = NSPanel; 
-                windowMenu = NSMenu; 
-                windowSeparator = NSMenuItem; 
-            }; 
-            SUPERCLASS = NSObject; 
-        }
-    ); 
-    IBVersion = 1; 
-}
\ No newline at end of file
diff --git a/hw/darwin/bundle/English.lproj/MainMenu.nib/objects.nib b/hw/darwin/bundle/English.lproj/MainMenu.nib/objects.nib
deleted file mode 100644
index ebbfd83..0000000
Binary files a/hw/darwin/bundle/English.lproj/MainMenu.nib/objects.nib and /dev/null differ
diff --git a/hw/darwin/bundle/English.lproj/Makefile.am b/hw/darwin/bundle/English.lproj/Makefile.am
deleted file mode 100644
index 8d6f7e5..0000000
--- a/hw/darwin/bundle/English.lproj/Makefile.am
+++ /dev/null
@@ -1,39 +0,0 @@
-BINDIR = ${bindir}
-include $(top_srcdir)/cpprules.in
-XINITDIR = $(libdir)/X11/xinit
-XDEFS = \
-        -DX_VERSION="$(PLIST_VERSION_STRING)" \
-        -DX_PRE_RELEASE="$(PRE)" \
-        -DX_REL_DATE="$(XORG_DATE)" \
-        -DX_VENDOR_NAME="$(VENDOR_STRING)" \
-        -DX_VENDOR_LINK="$(PLIST_VENDOR_WEB)"
-
-resourcesdir = @APPLE_APPLICATIONS_DIR@/XDarwin.app/Contents/Resources
-
-Englishlprojdir = $(resourcesdir)/English.lproj
-Englishlproj_DATA = \
-		    XDarwinHelp.html \
-		    InfoPlist.strings \
-		    Credits.rtf Localizable.strings
-
-Englishlprojnibdir = $(Englishlprojdir)/MainMenu.nib
-Englishlprojnib_DATA = \
-		       MainMenu.nib/classes.nib \
-		       MainMenu.nib/objects.nib
-
-InfoPlist.strings: InfoPlist.strings.cpp
-	 $(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) | $(SED) -e's/__quote__/"/g' | iconv -t UTF-16 > $@
-
-XDarwinHelp.html: XDarwinHelp.html.cpp
-	$(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) > $@
-
-CLEANFILES = XDarwinHelp.html InfoPlist.strings 
-
-EXTRA_DIST = \
-	Credits.rtf Localizable.strings \
-	Localizable.strings \
-	MainMenu.nib/classes.nib \
-	MainMenu.nib/objects.nib \
-	XDarwinHelp.html.cpp \
-	InfoPlist.strings.cpp
-
diff --git a/hw/darwin/bundle/English.lproj/XDarwinHelp.html.cpp b/hw/darwin/bundle/English.lproj/XDarwinHelp.html.cpp
deleted file mode 100644
index db33670..0000000
--- a/hw/darwin/bundle/English.lproj/XDarwinHelp.html.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-<html>
-<head>
-<title>XDarwin Help</title>
-</head>
-<body>
-<center>
-    <h1>XDarwin X Server for Mac OS X</h1>
-    X_VENDOR_NAME X_VERSION<br>
-    Release Date: X_REL_DATE
-</center>
-<h2>Contents</h2>
-<ol>
-    <li><A HREF="#notice">Important Notice</A></li>
-    <li><A HREF="#usage">Usage</A></li>
-    <li><A HREF="#path">Setting Your Path</A></li>
-    <li><A HREF="#prefs">User Preferences</A></li>
-    <li><A HREF="#license">License</A></li>
-</ol>
-<center>
-    <h2><a NAME="notice">Important Notice</a></h2>
-</center>
-<blockquote>
-#if X_PRE_RELEASE
-This is a pre-release version of XDarwin, and is not supported in any way. Bugs may be reported and patches may be submitted to the <A HREF="http://sourceforge.net/projects/xonx/">XonX project page</A> at SourceForge.  Before reporting bugs in pre-release versions, please check the latest version from <A HREF="http://sourceforge.net/projects/xonx/">XonX</A> or the X_VENDOR_LINK.
-#else
-If the server is older than 6-12 months, or if your hardware is newer than the above date, look for a newer version before reporting problems. Bugs may be reported and patches may be submitted to the <A HREF="http://sourceforge.net/projects/xonx/">XonX project page</A> at SourceForge.
-#endif
-</blockquote>
-<blockquote>
-This software is distributed under the terms of the <A HREF="#license">MIT X11 / X Consortium License</A> and is provided AS IS, with no warranty. Please read the <A HREF="#license">License</A> before using.</blockquote>
-
-<h2><a NAME="usage">Usage</a></h2>
-<p>XDarwin is a freely redistributable open-source X server for the <a HREF="http://www.x.org/">X Window System</a>. This version of XDarwin was produced by the X_VENDOR_LINK. XDarwin runs on Mac OS X in full screen or rootless modes.</p>
-<p>In full screen mode, when the X window system is active, it takes over the entire screen. You can switch back to the Mac OS X desktop by holding down Command-Option-A. This key combination can be changed in the user preferences. From the Mac OS X desktop, click on the XDarwin icon in the Dock to switch back to the X window system.  (You can change this behavior in the user preferences so that you must click the XDarwin icon in the floating switch window instead.)</p>
-<p>In rootless mode, the X window system and Aqua share your display. The root window of the X11 display is the size of the screen and contains all the other windows. The X11 root window is not displayed in rootless mode as Aqua handles the desktop background.</p>
-<h3>Multi-Button Mouse Emulation</h3>
-<p>Many X11 applications rely on the use of a 3-button mouse. You can emulate a 3-button mouse with a single button by holding down various modifier keys while you click the mouse button. This is controlled by settings in the "Multi-Button Mouse Emulation" section of the "General" preferences. By default, emulation is on and holding down the command key and clicking the mouse button will simulate clicking the second mouse button. Holding down the option key and clicking will simulate the third button. You can change to any combination of modifiers to emulate buttons two and three in the preferences. Note, even if the modifiers keys are mapped to some other key with xmodmap, you still must use the actual keys specified in the preferences for multi-button mouse emulation.</p>
-
-<h2><a NAME="path">Setting Your Path</a></h2>
-<p>Your path is the list of directories to be searched for executable commands. The X11 commands are located in <code>/usr/X11R6/bin</code>, which needs to be added to your path. XDarwin does this for you by default and can also add additional directories where you have installed command line applications.</p>
-<p>More experienced users will have already set their path correctly using the initialization files for their shell. In this case, you can inform XDarwin not to modify your path in the preferences. XDarwin launches the initial X11 clients in the user's default login shell. (An alternate shell can also be specified in the preferences.) The way to set the path depends on the shell you are using. This is described in the man page documentation for the shell.</p>
-<p>In addition you may also want to add the X11 man pages to the list of pages to be searched when you are looking for documentation. The X11 man pages are located in <code>/usr/X11R6/man</code> and the <code>MANPATH</code> environment variable contains the list of directories to search.</p>
-
-<h2><a NAME="prefs">User Preferences</a></h2>
-<p>A number of options may be set from the user preferences, accessible from the "Preferences..." menu item in the "XDarwin" menu. The options listed as start up options will not take effect until you have restarted XDarwin. All other options take effect immediately. The various options are described below:</p>
-<h3>General</h3>
-<ul>
-    <li><b>Use System beep for X11:</b> When enabled the standard Mac OS X alert sound is used as the X11 bell. When disabled (default) a simple tone is used.</li>
-    <li><b>Allow X11 to change mouse acceleration:</b> In a standard X window system implementation, the window manager can change the mouse acceleration. This can lead to confusion as the mouse acceleration may be set to different values by the Mac OS X System Preferences and the X window manager. By default, X11 is not allowed to change the mouse acceleration to avoid this problem.</li>
-    <li><b>Multi-Button Mouse Emulation:</b> This is described above under <a HREF="#usage">Usage</a>. When emulation is enabled the selected modifiers must be held down when the mouse button is pushed to emulate the second or third mouse buttons.</li>
-</ul>
-<h3>Start Up</h3>
-<ul>
-    <li><b>Default Mode:</b> If the user does not indicate whether to run in full screen or rootless mode, the mode specified here will be used.</li>
-    <li><b>Show mode pick panel on startup:</b> By default, a panel is displayed when XDarwin is started to allow the user to choose between full screen or rootless mode. If this option is turned off, the default mode will be started automatically.</li>
-    <li><b>X11 Display number:</b> X11 allows there to be multiple displays managed by separate X servers on a single computer. The user may specify an integer display number for XDarwin to use if more than one X server is going to be run simultaneously.</li>
-    <li><b>Allow Xinerama multiple monitor support:</b> XDarwin supports multiple monitors with Xinerama, which treats all monitors as being part of one large rectangular screen. You can disable Xinerama with this option, but currently XDarwin does not handle multiple monitors correctly without it. If you only have a single monitor, Xinerama is automatically disabled.</li>
-    <li><b>Keymapping File:</b> A keymapping file is read at startup and translated to an X11 keymap. Keymapping files, available for a wide variety of languages, are found in <code>/System/Library/Keyboards</code>.</li>
-    <li><b>Starting First X11 Clients:</b> When XDarwin is started from the Finder, it will run <code>xinit</code> to launch the X window manager and other X clients. (See "<code>man xinit</code>" for more information.) Before XDarwin runs <code>xinit</code> it will add the specified directories to the user's path. By default only <code>/usr/X11R6/bin</code> is added. Additional directories may added, separated by a colon. The X clients are started in the user's default login shell so that the user's shell initialization files are read. If desired, an alternate shell may be specified.</li>
-</ul>
-<h3>Full Screen</h3>
-<ul>
-    <li><b>Key combination button:</b> Click this button and then press any number of modifiers followed by a standard key to change the key combination to switch between Aqua and X11.</li>
-    <li><b>Click on icon in Dock switches to X11:</b> Enable this to activate switching to X11 by clicking on the XDarwin icon in the Dock. On some versions of Mac OS X, switching by clicking in the Dock can cause the cursor to disappear on returning to Aqua.</li>
-    <li><b>Show help on startup:</b> This will show an introductory splash screen when XDarwin is started in full screen mode.</li>
-    <li><b>Color bit depth:</b> In full screen mode, the X11 display can use a different color bit depth than is used by Aqua. If "Current" is specified, the depth used by Aqua when XDarwin starts will be used. Otherwise 8, 15, or 24 bits may be specified.</li>
-</ul>
-
-<h2><a NAME="license">License</a></h2>
-The main license for XDarwin is based on the traditional MIT X11 / X Consortium License, which does not impose any conditions on modification or redistribution of source code or binaries other than requiring that copyright/license notices are left intact. For more information and additional copyright/licensing notices covering some sections of the code, please refer to the source code.
-<H3><A NAME="3"></A>X Consortium License</H3>
-<p>Copyright (C) 1996 X Consortium</p>
-<p>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:</p>
-<p>The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.</p>
-<p>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 X CONSORTIUM 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.</p>
-<p>Except as contained in this notice, the name of the X Consortium 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 X Consortium.</p>
-<p>X Window System is a trademark of X Consortium, Inc.</p>
-</body>
-</html>
diff --git a/hw/darwin/bundle/French.lproj/Credits.rtf b/hw/darwin/bundle/French.lproj/Credits.rtf
deleted file mode 100644
index 17e0a0d..0000000
--- a/hw/darwin/bundle/French.lproj/Credits.rtf
+++ /dev/null
@@ -1,166 +0,0 @@
-{\rtf1\mac\ansicpg10000\cocoartf102
-{\fonttbl\f0\fswiss\fcharset77 Helvetica;\f1\fswiss\fcharset77 Helvetica-Bold;\f2\fswiss\fcharset77 Helvetica-Oblique;
-}
-{\colortbl;\red255\green255\blue255;}
-\vieww5160\viewh4480\viewkind0
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
-
-\f0\fs24 \cf0 This product includes software developed by The XFree86 Project, Inc  (http://www.xfree86.org/) and its contributors. The following people contributed to Darwin/Mac OS X support.\
-\
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-
-\f1\b \cf0 Contributors to Xorg Foundation Release:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Kaleb KEITHLEY\
-     
-\f2\i Working left and right Ctrl, Alt (Option), Meta (Command) and Shift keys.
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\f1\b \cf0 Contributors to XFree86 4.4:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 John Harper\
-     
-\f2\i Rootless acceleration and Apple-WM extension
-\f0\i0 \
-Torrey T. Lyons\
-     
-\f2\i Project Lead
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 Additional XonX Contributors to XFree86 4.3:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Fabr\'92cio Luis de Castro\
-     
-\f2\i Portuguese localization
-\f0\i0 \
-Michael Oland\
-     
-\f2\i New XDarwin icon
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-
-\f1\b \cf0 \
-Participants \'88 XonX pour XFree86 4.2 :
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Rob Braun\
-     
-\f2\i Version pour Darwin x86 
-\f0\i0 \
-Pablo Di Noto\
-
-\f2\i      Traduction en espagnol
-\f0\i0 \
-Paul Edens\
-
-\f2\i      Traduction en allemand
-\f0\i0 \
-Kyunghwan Kim\
-
-\f2\i      Traduction en cor\'8een
-\f0\i0 \
-Mario Klebsch\
-     
-\f2\i Claviers non-US
-\f0\i0 \
-Torrey T. Lyons\
-     
-\f2\i Direction du projet
-\f0\i0 \
-Andreas Monitzer\
-     
-\f2\i Traduction en allemand
-\f0\i0 \
-Patrik Montgomery\
-
-\f2\i      Traduction en su\'8edois
-\f0\i0 \
-Greg Parker\
-     
-\f2\i Version \'c7 rootless \'c8
-\f0\i0 \
-Toshimitsu Tanaka\
-     
-\f2\i Traduction en japonais
-\f0\i0 \
-Olivier Verdier\
-
-\f2\i      Traduction en fran\'8dais
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 Remerciements :
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Devin Poolman et Zero G Software, Inc.\
-
-\f2\i      Installeur
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 Participants \'88 XonX pour XFree86 4.2 :
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Rob Braun\
-     
-\f2\i Version pour Darwin x86 
-\f0\i0 \
-Torrey T. Lyons\
-     
-\f2\i Direction du projet
-\f0\i0 \
-Andreas Monitzer\
-     
-\f2\i Version Cocoa de l'interface de XDarwin
-\f0\i0 \
-Greg Parker\
-     
-\f2\i Impl\'8ementation initiale sur Quartz
-\f0\i0 \
-Christoph Pfisterer\
-     
-\f2\i Librairies partag\'8ees dynamiquement
-\f0\i0 \
-Toshimitsu Tanaka\
-     
-\f2\i Traduction en japonais
-\f0\i0 \
-\
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-
-\f1\b \cf0 Remerciements :
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Tiago Ribeiro\
-     Ic\'99ne 
-\f2\i XDarwin
-\f0\i0 \
-\
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-
-\f1\b \cf0 Historique :
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 John Carmack\
-     
-\f2\i Premi\'8fre adaptation de XFree86 sur Mac OS X Server
-\f0\i0 \
-Dave Zarzycki\
-     
-\f2\i Adaptation de Free86 4.0 pour Darwin 1.0
-\f0\i0 \
-Torrey T. Lyons\
-     
-\f2\i Int\'8egration dans le projet XFree86 pour la version 4.0.2}
\ No newline at end of file
diff --git a/hw/darwin/bundle/French.lproj/Localizable.strings b/hw/darwin/bundle/French.lproj/Localizable.strings
deleted file mode 100644
index 21c4a99..0000000
Binary files a/hw/darwin/bundle/French.lproj/Localizable.strings and /dev/null differ
diff --git a/hw/darwin/bundle/French.lproj/MainMenu.nib/classes.nib b/hw/darwin/bundle/French.lproj/MainMenu.nib/classes.nib
deleted file mode 100644
index 77f345a..0000000
--- a/hw/darwin/bundle/French.lproj/MainMenu.nib/classes.nib
+++ /dev/null
@@ -1,72 +0,0 @@
-{
-    IBClasses = (
-        {
-            ACTIONS = {showHelp = id; }; 
-            CLASS = FirstResponder; 
-            LANGUAGE = ObjC; 
-            SUPERCLASS = NSObject; 
-        }, 
-        {
-            ACTIONS = {close = id; pickFile = id; saveChanges = id; setKey = id; }; 
-            CLASS = Preferences; 
-            LANGUAGE = ObjC; 
-            OUTLETS = {
-                addToPathButton = id; 
-                addToPathField = id; 
-                button2ModifiersMatrix = id; 
-                button3ModifiersMatrix = id; 
-                depthButton = id; 
-                displayField = id; 
-                dockSwitchButton = id; 
-                fakeButton = id; 
-                keymapFileField = id; 
-                modeMatrix = id; 
-                modeWindowButton = id; 
-                mouseAccelChangeButton = id; 
-                startupHelpButton = id; 
-                switchKeyButton = id; 
-                systemBeepButton = id; 
-                useDefaultShellMatrix = id; 
-                useOtherShellField = id; 
-                useXineramaButton = id; 
-                window = id; 
-            }; 
-            SUPERCLASS = NSObject; 
-        }, 
-        {
-            CLASS = XApplication; 
-            LANGUAGE = ObjC; 
-            OUTLETS = {preferences = id; xserver = id; }; 
-            SUPERCLASS = NSApplication; 
-        }, 
-        {
-            ACTIONS = {
-                bringAllToFront = id; 
-                closeHelpAndShow = id; 
-                itemSelected = id; 
-                nextWindow = id; 
-                previousWindow = id; 
-                showAction = id; 
-                showSwitchPanel = id; 
-                startFullScreen = id; 
-                startRootless = id; 
-            }; 
-            CLASS = XServer; 
-            LANGUAGE = ObjC; 
-            OUTLETS = {
-                dockMenu = NSMenu; 
-                helpWindow = NSWindow; 
-                modeWindow = NSWindow; 
-                startFullScreenButton = NSButton; 
-                startRootlessButton = NSButton; 
-                startupHelpButton = NSButton; 
-                startupModeButton = NSButton; 
-                switchWindow = NSPanel; 
-                windowMenu = NSMenu; 
-                windowSeparator = NSMenuItem; 
-            }; 
-            SUPERCLASS = NSObject; 
-        }
-    ); 
-    IBVersion = 1; 
-}
\ No newline at end of file
diff --git a/hw/darwin/bundle/French.lproj/MainMenu.nib/objects.nib b/hw/darwin/bundle/French.lproj/MainMenu.nib/objects.nib
deleted file mode 100644
index 109d5cc..0000000
Binary files a/hw/darwin/bundle/French.lproj/MainMenu.nib/objects.nib and /dev/null differ
diff --git a/hw/darwin/bundle/French.lproj/Makefile.am b/hw/darwin/bundle/French.lproj/Makefile.am
deleted file mode 100644
index 4dca934..0000000
--- a/hw/darwin/bundle/French.lproj/Makefile.am
+++ /dev/null
@@ -1,41 +0,0 @@
-BINDIR = ${bindir}
-include $(top_srcdir)/cpprules.in
-XINITDIR = $(libdir)/X11/xinit
-
-XDEFS = \
-        -DX_VERSION="$(PLIST_VERSION_STRING)" \
-        -DX_PRE_RELEASE="$(PRE)" \
-        -DX_REL_DATE="$(XORG_DATE)" \
-        -DX_VENDOR_NAME="$(VENDOR_STRING)" \
-        -DX_VENDOR_LINK="$(PLIST_VENDOR_WEB)"
-
-
-resourcesdir = @APPLE_APPLICATIONS_DIR@/XDarwin.app/Contents/Resources
-
-Frenchlprojdir = $(resourcesdir)/French.lproj
-
-Frenchlproj_DATA = \
-		    XDarwinHelp.html \
-		    InfoPlist.strings \
-		    Credits.rtf Localizable.strings
-
-Frenchlprojnibdir = $(Frenchlprojdir)/MainMenu.nib
-Frenchlprojnib_DATA = \
-		       MainMenu.nib/classes.nib \
-		       MainMenu.nib/objects.nib
-
-InfoPlist.strings: $(srcdir)/../English.lproj/InfoPlist.strings.cpp
-	 $(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) | $(SED) -e's/__quote__/"/g' | iconv -t UTF-16 > $@
-
-XDarwinHelp.html: XDarwinHelp.html.cpp
-	$(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) > $@
-
-CLEANFILES = XDarwinHelp.html InfoPlist.strings 
-
-EXTRA_DIST = \
-	Credits.rtf Localizable.strings \
-	Localizable.strings \
-	MainMenu.nib/classes.nib \
-	MainMenu.nib/objects.nib \
-	XDarwinHelp.html.cpp
-
diff --git a/hw/darwin/bundle/French.lproj/XDarwinHelp.html.cpp b/hw/darwin/bundle/French.lproj/XDarwinHelp.html.cpp
deleted file mode 100644
index 512416b..0000000
--- a/hw/darwin/bundle/French.lproj/XDarwinHelp.html.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-<html>
-<head><META HTTP-EQUIV="content-type" CONTENT="text/html; charset=iso-8859-1">
-<title>XDarwin Help</title>
-</head>
-<body>
-<center>
-    <h1>XDarwin X Server pour Mac OS X</h1>
-    X_VENDOR_NAME X_VERSION<br>
-    Date : X_REL_DATE
-</center>
-<h2>Sommaire</h2>
-<ol>
-    <li><A HREF="#notice">Avertissement</A></li>
-    <li><A HREF="#usage">Utilisation</A></li>
-    <li><A HREF="#path">Chemins d'accès</A></li>
-    <li><A HREF="#prefs">Préférences</A></li>
-    <li><A HREF="#license">Licence</A></li>
-</ol>
-<center>
-    <h2><a NAME="notice">Avertissement</a></h2>
-</center>
-<blockquote>
-#if PRE_RELEASE
-Ceci est une pré-version de XDarwin et ne fait par conséquent l'objet d'aucun support client. Les bogues peuvent être signalés et des patches peuvent être soumis sur la 
-<A HREF="http://sourceforge.net/projects/xonx/">page du projet XonX</A> chez SourceForge. Veuillez prendre connaissance de la dernière version sur <A HREF="http://sourceforge.net/projects/xonx/">XonX</A> ou le X_VENDOR_LINK avant de signaler un bogue d'une pré-version.
-#else
-Si le serveur date de plus de 6-12 mois ou si votre matériel est plus récent que la date indiquée ci-dessus, veuillez vous procurer une version plus récente avant de signaler toute anomalie. Les bogues peuvent être signalés et des patches peuvent être soumis sur la <A HREF="http://sourceforge.net/projects/xonx/">page du projet XonX</A> chez SourceForge.
-#endif
-</blockquote>
-<blockquote>
-Ce logiciel est distribué sous la 
-<A HREF="#license">Licence du Consortium X/X11 du MIT</A> et est fourni TEL QUEL, sans garanties. Veuillez prendre connaissance de la <A HREF="#license">Licence</A> avant toute utilisation.</blockquote>
-
-<h2><a NAME="usage">Utilisation</a></h2>
-<p>XDarwin est une X server libre et distribuable sans contrainte du <a HREF
-="http://www.x.org/">X Window System</a>. This version of XDarwin was produced by the X_VENDOR_LINK. XDarwin fonctionne sous Mac OS X en mode « rootless » ou plein écran.</p>
-<p>Lorsque le système X window est actif en mode plein écran, il prend en charge la totalité de l'écran. Il est possible de revenir sur le bureau de Mac OS X en appuyant sur Commande-Option-A. Cette combinaison de touches peut être modifiée dans les préférences. Pour revenir dans X window, cliquer sur l'icône de XDarwin dans le Dock de Mac OS X.  (Un réglage des préférences permet d'effectuer cette opération en cliquant dans une fenêtre flottante au lieu de l'icône du Dock)</p>
-<p>En mode « rootless », X window system et Aqua utilisent le même affichage. La fenêtre-mère de l'affichage X11 est de la taille de l'écran et contient toutes les autre fenêtres. En mode « rootless » cette fenêtre-mère n'est pas affichée car Aqua gère le fond d'écran.</p>
-<h3>Émulation de souris à plusieurs boutons</h3>
-<p>Le fonctionnement de la plupart des applications X11 repose sur l'utilisation d'une souris à 3 boutons. Il est possible d'émuler une souris à 3 boutons avec un seul bouton en appuyant sur des touches de modification. Ceci est réglé dans la section "Émulation de souris à plusieurs boutons" de l'onglet "Général" des préférences. L'émulation est activée par défaut. Dans ce cas, cliquer en appuyant simultanément sur la touche "commande" simulera le bouton du milieu. Cliquer en appuyant simultanément sur la touche "option" simulera le bouton de droite. Les préférences permettent de régler n'importe quelle combinaison de touches de modification pour émuler les boutons du milieu et de droite. Notez que même si les touches de modifications sont mises en correspondance avec d'autres touches par xmodmap, ce sont les touches originelles spécifiées dans les préférences qui assureront l'émulation d'une souris à plusieurs boutons.
-
-<h2><a NAME="path">Réglage du chemin d'accès</a></h2>
-<p>Le chemin d'accès est une liste de répertoires utilisés pour la recherche d'exécutables. Les commandes X11 sont situées dans <code>/usr/X11R6/bin</code>, qui doit être ajouté à votre chemin d'accès. XDarwin fait cela par défaut, et peut également ajouter d'autres répertoires dans lesquels vous auriez installé d'autre commandes unix.</p>
-<p>Les utilisateurs plus expérimentés auront déjà réglé leur chemin d'accès correctement par le biais des fichiers d'initialisation de leur shell. Dans ce cas, il est possible de demander à XDarwin de ne pas modifier le chemin d'accès initial. XDarwin lance les premiers clients X11 dans le shell d'ouverture de session par défaut. (Un shell de remplacement peut être spécifié dans les préférences.) La façon de régler le chemin d'accès dépend du shell utilisé. Ceci est documenté dans les pages "man" du shell.</p>
-<p>De plus, il est possible d'ajouter les pages "man" de X11 à la liste des pages recherchées pour la documentation "man". Les pages "man" X11 se trouvent dans <code>/usr/X11R6/man</code>  et la variable d'environnement <code>MANPATH</code> contient la liste des répertoires dans lesquels chercher.</p>
-
-
-<h2><a NAME="prefs">Préférences</a></h2>
-<p>Un certain nombre d'options peuvent être réglées dans les préférences. On accède aux préférences en choisissant "Préférences..." dans le menu "XDarwin". Les options décrites comme options de démarrage ne prendront pas effet avant le redémarrage de XDarwin. Les autres options prennent immédiatement effet. Les différentes options sont détaillées ci-après :</p>
-<h3>Général</h3>
-<ul>
-    <li><b>Utiliser le bip d'alerte Système dans X11 :</b> Cocher cette option pour que le son d'alerte standard de Mac OS X soit utilisé à la place du son d'alerte de X11. L'option n'est pas cochée ar défaut. Dans ce cas, un simple signal sonore est utilisé.</li>
-    <li><b>Autoriser X11 à changer la vitesse de la souris :</b> Dans une implémentation classique du sytème X window, le gestionnaire de fenêtres peut modifier la vitesse de la souris. Cela peut s'avérer déroutant puisque le réglage de la vitesse de la souris peut être différent dans les préférences de Mac OS X et dans le gestionnaire X window. Par défaut, X11 n'est pas autorisé à changer la vitesse de la souris.</li>
-    <li><b>Émulation de souris à plusieurs boutons :</b> Ceci est décrit ci-dessus à la rubrique <a HREF="#usage">Usage</a>. Lorsque l'émulation est activée, il suffit d'appuyer simultanément sur les touches modificatrices sélectionnées et sur le bouton de la souris afin d'émuler les boutons du milieu et de droite.</li>
-</ul>
-<h3>Démarrage</h3>
-<ul>
-    <li><b>Mode par défaut :</b> Le mode spécifié à cet endroit sera utilisé si l'utilisateur ne l'indique pas au démarrage.</li>
-    <li><b>Choix du mode d'affichage au démarrage</b> Par défaut, une fenêtre de dialogue est affichée au démarrage de XDarwin pour permettre à l'utilisateur de choisir entre le mode plein écran et le mode « rootless ». Si cette option est désactivée, le mode par défaut sera automatiquement utilisé.</li>
-    <li><b>Numéro d'affichage (Display)</b> X11 offre la possibilité de plusieurs serveurs X sur un ordinateur. L'utilisateur doit spécifier ici le numéro d'affichage utilisé par XDarwin dans le cas où plusieurs serveurs X seraient en service simultanément.</li>
-    <li><b>Autoriser la prise en charge Xinerama de plusieurs moniteurs :</b> XDarwin peut être utilisé avec plusieurs moniteur avec Xinerama, qui considère les différents moniteurs comme des parties d'un écran rectugulaire plus grand. Cette option permet de désactiver Xinerama mais XDarwin ne prend alors pour l'instant pas correctement en charge l'affichage sur plusieurs écrans. Si il n'y a qu'un seul moniteur, Xinerama est automatiquement désactivé.</li>
-    <li><b>Fichier clavier :</b> Un fichier de correspondance de clavier est lu au démarrage puis transformé en un fihcier de correspondance clavier pour X11. Les fichiers de correspondance clavier, disponibles pour de nombreuses langues, se trouvent dans <code>/System/Library/Keyboards</code>.</li>
-    <li><b>Démarrage des premiers clients X11 :</b> Lorsque XDarwin est démarré à partir du Finder, il lance <code>xinit</code> qui lance à son tour le gestionnaire X window ainsi que d'autres clients X. (Voir "<code>man xinit</code>" pour plus d'informations.) Avant de lancer <code>xinit</code>, XDarwin ajoute les répertoires ainsi spécifiés au chemin d'accès de l'utilisateur. Par défaut, seul <code>/usr/X11R6/bin</code> est ajouté. Il est possible d'ajouter d'autres répertoires en les séparants à l'aide de deux points (<code>:</code>). Les clients X sont démarrés à partir du shell par défaut de l'utilisateur. Ainsi, le fichier d'initialisation de shell de l'utilisateur est lu. Un autre shell peut éventuellement être spécifié.</li>
-</ul>
-<h3>Plein écran</h3>
-<ul>
-    <li><b>Combinaison de touches :</b> Appuyer sur ce bouton, puis appuyer sur une ou plusieurs touches modificatrices suivies d'une touche ordinaire. Cette combinaison de touche servira à commuter entre Aqua et X11.</li>
-    <li><b>Basculer dans X11 en cliquant sur l'icône du Dock :</b> Cette option permet de passer dans X11 en cliquant dans l'icône de XDarwin dans le Dock. Sur certaines versions de Mac OS X, la commutation en utilisant le Dock peut faire disparaître le curseur lors du retour dans Aqua.</li>
-    <li><b>Afficher l'aide du mode plein écran au démarrage :</b> Permet l'affichage d'une fenêtre d'introduction lorsque XDarwin est démarré en mode plein écran.</li>
-    <li><b>Profondeur de couleur :</b> En mode plein écran, l'affichage X11 peut utiliser une autre profondeur de couleur que celle employée par Aqua. Si "Actuelle" est choisi, XDarwin utilisera la même profondeur de couleur qu'Aqua. Les autres choix sont 8 (256 couleurs), 15 (milliers de couleurs) et 24 bits (millions de couleurs). </li>
-</ul>
-
-<h2><a NAME="license">Licence</a></h2>
-The main license for XDarwin is one based on the traditional MIT X11 / X Consortium License, which does not impose any conditions on modification or redistribution of source code or binaries other than requiring that copyright/license notices are left intact. For more information and additional copyright/licensing notices covering some sections of the code, please refer to the source code.
-<H3><A NAME="3"></A>X Consortium License</H3>
-<p>Copyright (C) 1996 X Consortium</p>
-<p>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:</p>
-<p>The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.</p>
-<p>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 X CONSORTIUM 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.</p>
-<p>Except as contained in this notice, the name of the X Consortium 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 X Consortium.</p>
-<p>X Window System is a trademark of X Consortium, Inc.</p>
-</body>
-</html>
-
diff --git a/hw/darwin/bundle/German.lproj/Credits.rtf b/hw/darwin/bundle/German.lproj/Credits.rtf
deleted file mode 100644
index 34408e7..0000000
--- a/hw/darwin/bundle/German.lproj/Credits.rtf
+++ /dev/null
@@ -1,168 +0,0 @@
-{\rtf1\mac\ansicpg10000\cocoartf102
-{\fonttbl\f0\fswiss\fcharset77 Helvetica;\f1\fswiss\fcharset77 Helvetica-Bold;\f2\fswiss\fcharset77 Helvetica-Oblique;
-}
-{\colortbl;\red255\green255\blue255;}
-\vieww5160\viewh6300\viewkind0
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
-
-\f0\fs24 \cf0 This product includes software developed by The XFree86 Project, Inc  (http://www.xfree86.org/) and its contributors. The following people contributed to Darwin/Mac OS X support.\
-\
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-
-\f1\b \cf0 Contributors to Xorg Foundation Release:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Kaleb KEITHLEY\
-     
-\f2\i Working left and right Ctrl, Alt (Option), Meta (Command) and Shift keys.
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\f1\b \cf0 Contributors to XFree86 4.4:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 John Harper\
-     
-\f2\i Rootless acceleration and Apple-WM extension
-\f0\i0 \
-Torrey T. Lyons\
-     
-\f2\i Project Lead
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 Additional XonX Contributors to XFree86 4.3:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Fabr\'92cio Luis de Castro\
-     
-\f2\i Portuguese localization
-\f0\i0 \
-Michael Oland\
-     
-\f2\i New XDarwin icon
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 XonX Contributors to XFree86 4.2:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Rob Braun\
-     
-\f2\i Darwin x86 support
-\f0\i0 \
-Pablo Di Noto\
-
-\f2\i      Spanish localization
-\f0\i0 \
-Paul Edens\
-
-\f2\i      Dutch localization
-\f0\i0 \
-Kyunghwan Kim\
-
-\f2\i      Korean localization
-\f0\i0 \
-Mario Klebsch\
-     
-\f2\i Non-US keyboard support
-\f0\i0 \
-Torrey T. Lyons\
-     
-\f2\i Project Lead
-\f0\i0 \
-Andreas Monitzer\
-     
-\f2\i German localization
-\f0\i0 \
-Patrik Montgomery\
-
-\f2\i      Swedish localization
-\f0\i0 \
-Greg Parker\
-     
-\f2\i Rootless support
-\f0\i0 \
-Toshimitsu Tanaka\
-     
-\f2\i Japanese localization
-\f0\i0 \
-Olivier Verdier\
-
-\f2\i      French localization
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 Special Thanks:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Devin Poolman and Zero G Software, Inc.\
-
-\f2\i      Installer
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 XonX Team Members\
-Contributing to XFree86 4.1:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Rob Braun\
-     
-\f2\i Darwin x86 support
-\f0\i0 \
-Torrey T. Lyons\
-     
-\f2\i Project Lead
-\f0\i0 \
-Andreas Monitzer\
-     
-\f2\i Cocoa version of XDarwin front end
-\f0\i0 \
-Greg Parker\
-     
-\f2\i Original Quartz implementation
-\f0\i0 \
-Christoph Pfisterer\
-     
-\f2\i Dynamic shared libraries
-\f0\i0 \
-Toshimitsu Tanaka\
-     
-\f2\i Japanese localization
-\f0\i0 \
-\
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-
-\f1\b \cf0 Special Thanks:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Tiago Ribeiro\
-     
-\f2\i XDarwin icon
-\f0\i0 \
-\
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-
-\f1\b \cf0 History:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 John Carmack\
-     
-\f2\i Original XFree86 port to Mac OS X Server
-\f0\i0 \
-Dave Zarzycki\
-     
-\f2\i XFree86 4.0 port to Darwin 1.0
-\f0\i0 \
-Torrey T. Lyons\
-     
-\f2\i Integration into XFree86 Project for 4.0.2}
\ No newline at end of file
diff --git a/hw/darwin/bundle/German.lproj/Localizable.strings b/hw/darwin/bundle/German.lproj/Localizable.strings
deleted file mode 100644
index 5db6306..0000000
Binary files a/hw/darwin/bundle/German.lproj/Localizable.strings and /dev/null differ
diff --git a/hw/darwin/bundle/German.lproj/MainMenu.nib/classes.nib b/hw/darwin/bundle/German.lproj/MainMenu.nib/classes.nib
deleted file mode 100644
index 77f345a..0000000
--- a/hw/darwin/bundle/German.lproj/MainMenu.nib/classes.nib
+++ /dev/null
@@ -1,72 +0,0 @@
-{
-    IBClasses = (
-        {
-            ACTIONS = {showHelp = id; }; 
-            CLASS = FirstResponder; 
-            LANGUAGE = ObjC; 
-            SUPERCLASS = NSObject; 
-        }, 
-        {
-            ACTIONS = {close = id; pickFile = id; saveChanges = id; setKey = id; }; 
-            CLASS = Preferences; 
-            LANGUAGE = ObjC; 
-            OUTLETS = {
-                addToPathButton = id; 
-                addToPathField = id; 
-                button2ModifiersMatrix = id; 
-                button3ModifiersMatrix = id; 
-                depthButton = id; 
-                displayField = id; 
-                dockSwitchButton = id; 
-                fakeButton = id; 
-                keymapFileField = id; 
-                modeMatrix = id; 
-                modeWindowButton = id; 
-                mouseAccelChangeButton = id; 
-                startupHelpButton = id; 
-                switchKeyButton = id; 
-                systemBeepButton = id; 
-                useDefaultShellMatrix = id; 
-                useOtherShellField = id; 
-                useXineramaButton = id; 
-                window = id; 
-            }; 
-            SUPERCLASS = NSObject; 
-        }, 
-        {
-            CLASS = XApplication; 
-            LANGUAGE = ObjC; 
-            OUTLETS = {preferences = id; xserver = id; }; 
-            SUPERCLASS = NSApplication; 
-        }, 
-        {
-            ACTIONS = {
-                bringAllToFront = id; 
-                closeHelpAndShow = id; 
-                itemSelected = id; 
-                nextWindow = id; 
-                previousWindow = id; 
-                showAction = id; 
-                showSwitchPanel = id; 
-                startFullScreen = id; 
-                startRootless = id; 
-            }; 
-            CLASS = XServer; 
-            LANGUAGE = ObjC; 
-            OUTLETS = {
-                dockMenu = NSMenu; 
-                helpWindow = NSWindow; 
-                modeWindow = NSWindow; 
-                startFullScreenButton = NSButton; 
-                startRootlessButton = NSButton; 
-                startupHelpButton = NSButton; 
-                startupModeButton = NSButton; 
-                switchWindow = NSPanel; 
-                windowMenu = NSMenu; 
-                windowSeparator = NSMenuItem; 
-            }; 
-            SUPERCLASS = NSObject; 
-        }
-    ); 
-    IBVersion = 1; 
-}
\ No newline at end of file
diff --git a/hw/darwin/bundle/German.lproj/MainMenu.nib/objects.nib b/hw/darwin/bundle/German.lproj/MainMenu.nib/objects.nib
deleted file mode 100644
index 28fff89..0000000
Binary files a/hw/darwin/bundle/German.lproj/MainMenu.nib/objects.nib and /dev/null differ
diff --git a/hw/darwin/bundle/German.lproj/Makefile.am b/hw/darwin/bundle/German.lproj/Makefile.am
deleted file mode 100644
index fcb5dd2..0000000
--- a/hw/darwin/bundle/German.lproj/Makefile.am
+++ /dev/null
@@ -1,39 +0,0 @@
-BINDIR = ${bindir}
-include $(top_srcdir)/cpprules.in
-XINITDIR = $(libdir)/X11/xinit
-XDEFS = \
-        -DX_VERSION="$(PLIST_VERSION_STRING)" \
-        -DX_PRE_RELEASE="$(PRE)" \
-        -DX_REL_DATE="$(XORG_DATE)" \
-        -DX_VENDOR_NAME="$(VENDOR_STRING)" \
-        -DX_VENDOR_LINK="$(PLIST_VENDOR_WEB)"
-
-resourcesdir = @APPLE_APPLICATIONS_DIR@/XDarwin.app/Contents/Resources
-
-Germanlprojdir = $(resourcesdir)/German.lproj
-
-Germanlproj_DATA = \
-		    XDarwinHelp.html \
-		    InfoPlist.strings \
-		    Credits.rtf Localizable.strings Localizable.strings
-
-Germanlprojnibdir = $(Germanlprojdir)/MainMenu.nib
-Germanlprojnib_DATA = \
-		       MainMenu.nib/classes.nib \
-		       MainMenu.nib/objects.nib
-
-InfoPlist.strings: $(srcdir)/../English.lproj/InfoPlist.strings.cpp
-	 $(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) | $(SED) -e's/__quote__/"/g' | iconv -t UTF-16 > $@
-
-XDarwinHelp.html: XDarwinHelp.html.cpp
-	$(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) > $@
-
-CLEANFILES = XDarwinHelp.html InfoPlist.strings 
-
-EXTRA_DIST = \
-	Credits.rtf Localizable.strings \
-	Localizable.strings \
-	MainMenu.nib/classes.nib \
-	MainMenu.nib/objects.nib \
-	XDarwinHelp.html.cpp
-
diff --git a/hw/darwin/bundle/German.lproj/XDarwinHelp.html.cpp b/hw/darwin/bundle/German.lproj/XDarwinHelp.html.cpp
deleted file mode 100644
index db33670..0000000
--- a/hw/darwin/bundle/German.lproj/XDarwinHelp.html.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-<html>
-<head>
-<title>XDarwin Help</title>
-</head>
-<body>
-<center>
-    <h1>XDarwin X Server for Mac OS X</h1>
-    X_VENDOR_NAME X_VERSION<br>
-    Release Date: X_REL_DATE
-</center>
-<h2>Contents</h2>
-<ol>
-    <li><A HREF="#notice">Important Notice</A></li>
-    <li><A HREF="#usage">Usage</A></li>
-    <li><A HREF="#path">Setting Your Path</A></li>
-    <li><A HREF="#prefs">User Preferences</A></li>
-    <li><A HREF="#license">License</A></li>
-</ol>
-<center>
-    <h2><a NAME="notice">Important Notice</a></h2>
-</center>
-<blockquote>
-#if X_PRE_RELEASE
-This is a pre-release version of XDarwin, and is not supported in any way. Bugs may be reported and patches may be submitted to the <A HREF="http://sourceforge.net/projects/xonx/">XonX project page</A> at SourceForge.  Before reporting bugs in pre-release versions, please check the latest version from <A HREF="http://sourceforge.net/projects/xonx/">XonX</A> or the X_VENDOR_LINK.
-#else
-If the server is older than 6-12 months, or if your hardware is newer than the above date, look for a newer version before reporting problems. Bugs may be reported and patches may be submitted to the <A HREF="http://sourceforge.net/projects/xonx/">XonX project page</A> at SourceForge.
-#endif
-</blockquote>
-<blockquote>
-This software is distributed under the terms of the <A HREF="#license">MIT X11 / X Consortium License</A> and is provided AS IS, with no warranty. Please read the <A HREF="#license">License</A> before using.</blockquote>
-
-<h2><a NAME="usage">Usage</a></h2>
-<p>XDarwin is a freely redistributable open-source X server for the <a HREF="http://www.x.org/">X Window System</a>. This version of XDarwin was produced by the X_VENDOR_LINK. XDarwin runs on Mac OS X in full screen or rootless modes.</p>
-<p>In full screen mode, when the X window system is active, it takes over the entire screen. You can switch back to the Mac OS X desktop by holding down Command-Option-A. This key combination can be changed in the user preferences. From the Mac OS X desktop, click on the XDarwin icon in the Dock to switch back to the X window system.  (You can change this behavior in the user preferences so that you must click the XDarwin icon in the floating switch window instead.)</p>
-<p>In rootless mode, the X window system and Aqua share your display. The root window of the X11 display is the size of the screen and contains all the other windows. The X11 root window is not displayed in rootless mode as Aqua handles the desktop background.</p>
-<h3>Multi-Button Mouse Emulation</h3>
-<p>Many X11 applications rely on the use of a 3-button mouse. You can emulate a 3-button mouse with a single button by holding down various modifier keys while you click the mouse button. This is controlled by settings in the "Multi-Button Mouse Emulation" section of the "General" preferences. By default, emulation is on and holding down the command key and clicking the mouse button will simulate clicking the second mouse button. Holding down the option key and clicking will simulate the third button. You can change to any combination of modifiers to emulate buttons two and three in the preferences. Note, even if the modifiers keys are mapped to some other key with xmodmap, you still must use the actual keys specified in the preferences for multi-button mouse emulation.</p>
-
-<h2><a NAME="path">Setting Your Path</a></h2>
-<p>Your path is the list of directories to be searched for executable commands. The X11 commands are located in <code>/usr/X11R6/bin</code>, which needs to be added to your path. XDarwin does this for you by default and can also add additional directories where you have installed command line applications.</p>
-<p>More experienced users will have already set their path correctly using the initialization files for their shell. In this case, you can inform XDarwin not to modify your path in the preferences. XDarwin launches the initial X11 clients in the user's default login shell. (An alternate shell can also be specified in the preferences.) The way to set the path depends on the shell you are using. This is described in the man page documentation for the shell.</p>
-<p>In addition you may also want to add the X11 man pages to the list of pages to be searched when you are looking for documentation. The X11 man pages are located in <code>/usr/X11R6/man</code> and the <code>MANPATH</code> environment variable contains the list of directories to search.</p>
-
-<h2><a NAME="prefs">User Preferences</a></h2>
-<p>A number of options may be set from the user preferences, accessible from the "Preferences..." menu item in the "XDarwin" menu. The options listed as start up options will not take effect until you have restarted XDarwin. All other options take effect immediately. The various options are described below:</p>
-<h3>General</h3>
-<ul>
-    <li><b>Use System beep for X11:</b> When enabled the standard Mac OS X alert sound is used as the X11 bell. When disabled (default) a simple tone is used.</li>
-    <li><b>Allow X11 to change mouse acceleration:</b> In a standard X window system implementation, the window manager can change the mouse acceleration. This can lead to confusion as the mouse acceleration may be set to different values by the Mac OS X System Preferences and the X window manager. By default, X11 is not allowed to change the mouse acceleration to avoid this problem.</li>
-    <li><b>Multi-Button Mouse Emulation:</b> This is described above under <a HREF="#usage">Usage</a>. When emulation is enabled the selected modifiers must be held down when the mouse button is pushed to emulate the second or third mouse buttons.</li>
-</ul>
-<h3>Start Up</h3>
-<ul>
-    <li><b>Default Mode:</b> If the user does not indicate whether to run in full screen or rootless mode, the mode specified here will be used.</li>
-    <li><b>Show mode pick panel on startup:</b> By default, a panel is displayed when XDarwin is started to allow the user to choose between full screen or rootless mode. If this option is turned off, the default mode will be started automatically.</li>
-    <li><b>X11 Display number:</b> X11 allows there to be multiple displays managed by separate X servers on a single computer. The user may specify an integer display number for XDarwin to use if more than one X server is going to be run simultaneously.</li>
-    <li><b>Allow Xinerama multiple monitor support:</b> XDarwin supports multiple monitors with Xinerama, which treats all monitors as being part of one large rectangular screen. You can disable Xinerama with this option, but currently XDarwin does not handle multiple monitors correctly without it. If you only have a single monitor, Xinerama is automatically disabled.</li>
-    <li><b>Keymapping File:</b> A keymapping file is read at startup and translated to an X11 keymap. Keymapping files, available for a wide variety of languages, are found in <code>/System/Library/Keyboards</code>.</li>
-    <li><b>Starting First X11 Clients:</b> When XDarwin is started from the Finder, it will run <code>xinit</code> to launch the X window manager and other X clients. (See "<code>man xinit</code>" for more information.) Before XDarwin runs <code>xinit</code> it will add the specified directories to the user's path. By default only <code>/usr/X11R6/bin</code> is added. Additional directories may added, separated by a colon. The X clients are started in the user's default login shell so that the user's shell initialization files are read. If desired, an alternate shell may be specified.</li>
-</ul>
-<h3>Full Screen</h3>
-<ul>
-    <li><b>Key combination button:</b> Click this button and then press any number of modifiers followed by a standard key to change the key combination to switch between Aqua and X11.</li>
-    <li><b>Click on icon in Dock switches to X11:</b> Enable this to activate switching to X11 by clicking on the XDarwin icon in the Dock. On some versions of Mac OS X, switching by clicking in the Dock can cause the cursor to disappear on returning to Aqua.</li>
-    <li><b>Show help on startup:</b> This will show an introductory splash screen when XDarwin is started in full screen mode.</li>
-    <li><b>Color bit depth:</b> In full screen mode, the X11 display can use a different color bit depth than is used by Aqua. If "Current" is specified, the depth used by Aqua when XDarwin starts will be used. Otherwise 8, 15, or 24 bits may be specified.</li>
-</ul>
-
-<h2><a NAME="license">License</a></h2>
-The main license for XDarwin is based on the traditional MIT X11 / X Consortium License, which does not impose any conditions on modification or redistribution of source code or binaries other than requiring that copyright/license notices are left intact. For more information and additional copyright/licensing notices covering some sections of the code, please refer to the source code.
-<H3><A NAME="3"></A>X Consortium License</H3>
-<p>Copyright (C) 1996 X Consortium</p>
-<p>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:</p>
-<p>The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.</p>
-<p>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 X CONSORTIUM 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.</p>
-<p>Except as contained in this notice, the name of the X Consortium 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 X Consortium.</p>
-<p>X Window System is a trademark of X Consortium, Inc.</p>
-</body>
-</html>
diff --git a/hw/darwin/bundle/Info.plist b/hw/darwin/bundle/Info.plist
deleted file mode 100644
index 7e17708..0000000
--- a/hw/darwin/bundle/Info.plist
+++ /dev/null
@@ -1,66 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>CFBundleDevelopmentRegion</key>
-	<string>English</string>
-	<key>CFBundleDocumentTypes</key>
-	<array>
-		<dict>
-			<key>CFBundleTypeExtensions</key>
-			<array>
-				<string>x11app</string>
-			</array>
-			<key>CFBundleTypeName</key>
-			<string>X11 Application</string>
-			<key>CFBundleTypeOSTypes</key>
-			<array>
-				<string>****</string>
-			</array>
-			<key>CFBundleTypeRole</key>
-			<string>Viewer</string>
-		</dict>
-		<dict>
-			<key>CFBundleTypeExtensions</key>
-			<array>
-				<string>tool</string>
-				<string>*</string>
-			</array>
-			<key>CFBundleTypeName</key>
-			<string>UNIX Application</string>
-			<key>CFBundleTypeOSTypes</key>
-			<array>
-				<string>****</string>
-			</array>
-			<key>CFBundleTypeRole</key>
-			<string>Viewer</string>
-		</dict>
-	</array>
-	<key>CFBundleExecutable</key>
-	<string>XDarwin</string>
-	<key>CFBundleGetInfoString</key>
-	<string>XDarwin 1.4.0, X.Org Foundation</string>
-	<key>CFBundleIconFile</key>
-	<string>XDarwin.icns</string>
-	<key>CFBundleIdentifier</key>
-	<string>org.x.X11</string>
-	<key>CFBundleInfoDictionaryVersion</key>
-	<string>6.0</string>
-	<key>CFBundleName</key>
-	<string>XDarwin</string>
-	<key>CFBundlePackageType</key>
-	<string>APPL</string>
-	<key>CFBundleShortVersionString</key>
-	<string>2.0.0</string>
-	<key>CFBundleSignature</key>
-	<string>????</string>
-	<key>CFBundleVersion</key>
-	<string></string>
-	<key>NSHelpFile</key>
-	<string>XDarwinHelp.html</string>
-	<key>NSMainNibFile</key>
-	<string>MainMenu</string>
-	<key>NSPrincipalClass</key>
-	<string>XApplication</string>
-</dict>
-</plist>
diff --git a/hw/darwin/bundle/Japanese.lproj/Credits.rtf b/hw/darwin/bundle/Japanese.lproj/Credits.rtf
deleted file mode 100644
index cf9eae2..0000000
--- a/hw/darwin/bundle/Japanese.lproj/Credits.rtf
+++ /dev/null
@@ -1,193 +0,0 @@
-{\rtf1\mac\ansicpg10001\cocoartf102
-{\fonttbl\f0\fnil\fcharset78 HiraKakuPro-W3;\f1\fswiss\fcharset77 Helvetica;\f2\fswiss\fcharset77 Helvetica-Bold;
-\f3\fswiss\fcharset77 Helvetica-Oblique;}
-{\colortbl;\red255\green255\blue255;}
-\vieww13980\viewh11160\viewkind0
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
-
-\f0\fs24 \cf0 \'82\'b1\'82\'cc\'90\'bb\'95\'69\'82\'cd 
-\f1 XFree86 
-\f0 \'83\'76\'83\'8d\'83\'57\'83\'46\'83\'4e\'83\'67
-\f1 (http://www.xfree86.org/)
-\f0 \'82\'a8\'82\'e6\'82\'d1\'82\'bb\'82\'cc\'8d\'76\'8c\'a3\'8e\'d2\'82\'c9\'82\'e6\'82\'c1\'82\'c4\'8a\'4a\'94\'ad\'82\'b3\'82\'ea\'82\'bd\'83\'5c\'83\'74\'83\'67\'83\'45\'83\'46\'83\'41\'82\'f0\'8a\'dc\'82\'f1\'82\'c5\'82\'a2\'82\'dc\'82\'b7\'81\'42\'8e\'9f\'82\'cc\'90\'6c\'81\'58\'82\'cd Darwin
-\f1 /Mac OS X 
-\f0 \'82\'cc\'83\'54\'83\'7c\'81\'5b\'83\'67\'82\'c9\'8d\'76\'8c\'a3\'82\'b5\'82\'dc\'82\'b5\'82\'bd\'81\'42
-\f1 \
-\
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-
-\f2\b \cf0 Contributors to Xorg Foundation Release:
-\f1\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Kaleb KEITHLEY\
-     
-\f0 \'8d\'b6\'89\'45\'82\'cc Ctrl,Alt(Option),Meta(Command) \'82\'a8\'82\'e6\'82\'d1 Shift \'83\'4c\'81\'5b\'82\'cc\'93\'ae\'8d\'ec
-\f1 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f2\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 Contributors to XFree86 4.4:
-\f1\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 John Harper
-\f3\i \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f0\i0 \cf0    \'83\'8b\'81\'5b\'83\'67\'83\'8c\'83\'58 \'83\'41\'83\'4e\'83\'5a\'83\'89\'83\'8c\'81\'5b\'83\'56\'83\'87\'83\'93 \'82\'a8\'82\'e6\'82\'d1 Apple-WM \'8a\'67\'92\'a3
-\f1 \
-Torrey T. Lyons\
-     
-\f0 \'83\'76\'83\'8d\'83\'57\'83\'46\'83\'4e\'83\'67 \'83\'8a\'81\'5b\'83\'5f\'81\'5b\
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f2\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 Additional XonX Contributors to XFree86 4.3:
-\f1\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Fabr\'92cio Luis de Castro\
-     
-\f0 \'83\'7c\'83\'8b\'83\'67\'83\'4b\'83\'8b\'8c\'ea\'83\'8d\'81\'5b\'83\'4a\'83\'89\'83\'43\'83\'59
-\f1 \
-Michael Oland\
-     
-\f0 \'90\'56\'82\'b5\'82\'a2 
-\f1 XDarwin 
-\f0 \'83\'41\'83\'43\'83\'52\'83\'93
-\f1 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f2\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 XonX Contributors to XFree86 4.2:
-\f1\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Rob Braun\
-     Darwin x86
-\f3\i  
-\f0\i0 \'83\'54\'83\'7c\'81\'5b\'83\'67
-\f1 \
-Pablo Di Noto\
-
-\f3\i      
-\f0\i0 \'83\'58\'83\'79\'83\'43\'83\'93\'8c\'ea\'83\'8d\'81\'5b\'83\'4a\'83\'89\'83\'43\'83\'59
-\f1 \
-Paul Edens\
-
-\f3\i      
-\f0\i0 \'83\'49\'83\'89\'83\'93\'83\'5f\'8c\'ea\'83\'8d\'81\'5b\'83\'4a\'83\'89\'83\'43\'83\'59
-\f1 \
-Kyunghwan Kim\
-
-\f3\i      
-\f0\i0 \'8a\'d8\'8d\'91\'8c\'ea\'83\'8d\'81\'5b\'83\'4a\'83\'89\'83\'43\'83\'59
-\f1 \
-Mario Klebsch\
-     
-\f0 \'94\'f1US\'83\'4c\'81\'5b\'83\'7b\'81\'5b\'83\'68 \'83\'54\'83\'7c\'81\'5b\'83\'67
-\f1 \
-Torrey T. Lyons\
-     
-\f0 \'83\'76\'83\'8d\'83\'57\'83\'46\'83\'4e\'83\'67 \'83\'8a\'81\'5b\'83\'5f\'81\'5b
-\f1 \
-Andreas Monitzer\
-     
-\f0 \'83\'68\'83\'43\'83\'63\'8c\'ea\'83\'8d\'81\'5b\'83\'4a\'83\'89\'83\'43\'83\'59
-\f1 \
-Patrik Montgomery\
-
-\f3\i      
-\f0\i0 \'83\'58\'83\'45\'83\'46\'81\'5b\'83\'66\'83\'93\'8c\'ea\'83\'8d\'81\'5b\'83\'4a\'83\'89\'83\'43\'83\'59
-\f1 \
-Greg Parker\
-     
-\f0 \'83\'8b\'81\'5b\'83\'67\'83\'8c\'83\'58 \'83\'54\'83\'7c\'81\'5b\'83\'67
-\f1 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f0 \cf0 \'93\'63\'92\'86 \'8f\'72\'8c\'f5
-\f1 \
-     
-\f0 \'93\'fa\'96\'7b\'8c\'ea\'83\'8d\'81\'5b\'83\'4a\'83\'89\'83\'43\'83\'59
-\f1 \
-Olivier Verdier\
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f3\i \cf0      
-\f0\i0 \'83\'74\'83\'89\'83\'93\'83\'58\'8c\'ea\'83\'8d\'81\'5b\'83\'4a\'83\'89\'83\'43\'83\'59
-\f1 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f2\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 Special Thanks:
-\f1\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Devin Poolman and Zero G Software, Inc.\
-
-\f3\i      
-\f0\i0 \'83\'43\'83\'93\'83\'58\'83\'67\'81\'5b\'83\'89
-\f1 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f2\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 XonX Team Members\
-Contributing to XFree86 4.1:
-\f1\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Rob Braun\
-     Darwin x86 
-\f0 \'83\'54\'83\'7c\'81\'5b\'83\'67
-\f1 \
-Torrey T. Lyons\
-     
-\f0 \'83\'76\'83\'8d\'83\'57\'83\'46\'83\'4e\'83\'67 \'83\'8a\'81\'5b\'83\'5f\'81\'5b
-\f1 \
-Andreas Monitzer\
-     Cocoa 
-\f0 \'94\'c5 XDarwin \'83\'74\'83\'8d\'83\'93\'83\'67\'83\'47\'83\'93\'83\'68
-\f1 \
-Greg Parker\
-     
-\f0 \'8d\'c5\'8f\'89\'82\'cc Quartz \'83\'43\'83\'93\'83\'76\'83\'8a\'83\'81\'83\'93\'83\'67
-\f1 \
-Christoph Pfisterer\
-     
-\f0 \'8b\'a4\'97\'4c\'83\'89\'83\'43\'83\'75\'83\'89\'83\'8a
-\f1 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f0 \cf0 \'93\'63\'92\'86 \'8f\'72\'8c\'f5
-\f1 \
-     
-\f0 \'93\'fa\'96\'7b\'8c\'ea\'83\'8d\'81\'5b\'83\'4a\'83\'89\'83\'43\'83\'59
-\f1 \
-\
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-
-\f2\b \cf0 Special Thanks:
-\f1\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Tiago Ribeiro\
-     XDarwin 
-\f0 \'83\'41\'83\'43\'83\'52\'83\'93
-\f1 \
-\
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-
-\f2\b \cf0 History:
-\f1\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 John Carmack\
-     
-\f0 XFree86 \'82\'cc Mac OS X Server \'82\'d6\'82\'cc\'8d\'c5\'8f\'89\'82\'cc\'88\'da\'90\'41
-\f1 \
-Dave Zarzycki\
-     XFree86 4.0 
-\f0 \'82\'f0 Darwin 1.0 \'82\'c9\'88\'da\'90\'41
-\f1 \
-Torrey T. Lyons\
-     XFree86 4.0.2 
-\f0 \'83\'76\'83\'8d\'83\'57\'83\'46\'83\'4e\'83\'67\'82\'d6\'82\'cc\'93\'9d\'8d\'87}
\ No newline at end of file
diff --git a/hw/darwin/bundle/Japanese.lproj/Localizable.strings b/hw/darwin/bundle/Japanese.lproj/Localizable.strings
deleted file mode 100644
index c5c26d6..0000000
Binary files a/hw/darwin/bundle/Japanese.lproj/Localizable.strings and /dev/null differ
diff --git a/hw/darwin/bundle/Japanese.lproj/MainMenu.nib/classes.nib b/hw/darwin/bundle/Japanese.lproj/MainMenu.nib/classes.nib
deleted file mode 100644
index 77f345a..0000000
--- a/hw/darwin/bundle/Japanese.lproj/MainMenu.nib/classes.nib
+++ /dev/null
@@ -1,72 +0,0 @@
-{
-    IBClasses = (
-        {
-            ACTIONS = {showHelp = id; }; 
-            CLASS = FirstResponder; 
-            LANGUAGE = ObjC; 
-            SUPERCLASS = NSObject; 
-        }, 
-        {
-            ACTIONS = {close = id; pickFile = id; saveChanges = id; setKey = id; }; 
-            CLASS = Preferences; 
-            LANGUAGE = ObjC; 
-            OUTLETS = {
-                addToPathButton = id; 
-                addToPathField = id; 
-                button2ModifiersMatrix = id; 
-                button3ModifiersMatrix = id; 
-                depthButton = id; 
-                displayField = id; 
-                dockSwitchButton = id; 
-                fakeButton = id; 
-                keymapFileField = id; 
-                modeMatrix = id; 
-                modeWindowButton = id; 
-                mouseAccelChangeButton = id; 
-                startupHelpButton = id; 
-                switchKeyButton = id; 
-                systemBeepButton = id; 
-                useDefaultShellMatrix = id; 
-                useOtherShellField = id; 
-                useXineramaButton = id; 
-                window = id; 
-            }; 
-            SUPERCLASS = NSObject; 
-        }, 
-        {
-            CLASS = XApplication; 
-            LANGUAGE = ObjC; 
-            OUTLETS = {preferences = id; xserver = id; }; 
-            SUPERCLASS = NSApplication; 
-        }, 
-        {
-            ACTIONS = {
-                bringAllToFront = id; 
-                closeHelpAndShow = id; 
-                itemSelected = id; 
-                nextWindow = id; 
-                previousWindow = id; 
-                showAction = id; 
-                showSwitchPanel = id; 
-                startFullScreen = id; 
-                startRootless = id; 
-            }; 
-            CLASS = XServer; 
-            LANGUAGE = ObjC; 
-            OUTLETS = {
-                dockMenu = NSMenu; 
-                helpWindow = NSWindow; 
-                modeWindow = NSWindow; 
-                startFullScreenButton = NSButton; 
-                startRootlessButton = NSButton; 
-                startupHelpButton = NSButton; 
-                startupModeButton = NSButton; 
-                switchWindow = NSPanel; 
-                windowMenu = NSMenu; 
-                windowSeparator = NSMenuItem; 
-            }; 
-            SUPERCLASS = NSObject; 
-        }
-    ); 
-    IBVersion = 1; 
-}
\ No newline at end of file
diff --git a/hw/darwin/bundle/Japanese.lproj/MainMenu.nib/objects.nib b/hw/darwin/bundle/Japanese.lproj/MainMenu.nib/objects.nib
deleted file mode 100644
index 3570027..0000000
Binary files a/hw/darwin/bundle/Japanese.lproj/MainMenu.nib/objects.nib and /dev/null differ
diff --git a/hw/darwin/bundle/Japanese.lproj/Makefile.am b/hw/darwin/bundle/Japanese.lproj/Makefile.am
deleted file mode 100644
index 8d891ed..0000000
--- a/hw/darwin/bundle/Japanese.lproj/Makefile.am
+++ /dev/null
@@ -1,40 +0,0 @@
-BINDIR = ${bindir}
-include $(top_srcdir)/cpprules.in
-XINITDIR = $(libdir)/X11/xinit
-XDEFS = \
-        -DX_VERSION="$(PLIST_VERSION_STRING)" \
-        -DX_PRE_RELEASE="$(PRE)" \
-        -DX_REL_DATE="$(XORG_DATE)" \
-        -DX_VENDOR_NAME="$(VENDOR_STRING)" \
-        -DX_VENDOR_LINK="$(PLIST_VENDOR_WEB)"
-
-
-resourcesdir = @APPLE_APPLICATIONS_DIR@/XDarwin.app/Contents/Resources
-
-Japaneselprojdir = $(resourcesdir)/Japanese.lproj
-
-Japaneselproj_DATA = \
-		    XDarwinHelp.html \
-		    InfoPlist.strings \
-		    Credits.rtf Localizable.strings
-
-Japaneselprojnibdir = $(Japaneselprojdir)/MainMenu.nib
-Japaneselprojnib_DATA = \
-		       MainMenu.nib/classes.nib \
-		       MainMenu.nib/objects.nib
-
-InfoPlist.strings: $(srcdir)/../English.lproj/InfoPlist.strings.cpp
-	 $(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) | $(SED) -e's/__quote__/"/g' | iconv -t UTF-16 > $@
-
-XDarwinHelp.html: XDarwinHelp.html.cpp
-	$(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) > $@
-
-CLEANFILES = XDarwinHelp.html InfoPlist.strings 
-
-EXTRA_DIST = \
-	Credits.rtf Localizable.strings \
-	Localizable.strings \
-	MainMenu.nib/classes.nib \
-	MainMenu.nib/objects.nib \
-	XDarwinHelp.html.cpp
-
diff --git a/hw/darwin/bundle/Japanese.lproj/XDarwinHelp.html.cpp b/hw/darwin/bundle/Japanese.lproj/XDarwinHelp.html.cpp
deleted file mode 100644
index 6653f5b..0000000
--- a/hw/darwin/bundle/Japanese.lproj/XDarwinHelp.html.cpp
+++ /dev/null
@@ -1,141 +0,0 @@
-<!-- $XFree86: xc/programs/Xserver/hw/darwin/bundle/Japanese.lproj/XDarwinHelp.html.cpp,v 1.4 2001/11/27 07:27:46 torrey Exp $ -->
-
-<html>
-<head>
-<META http-equiv="Content-Type" content="text/html; charset=EUC-JP">
-<title>
-XDarwin Help</title></head>
-<body>
-<center>
-    <h1>XDarwin X Server for Mac OS X</h1>
-    X_VENDOR_NAME X_VERSION<br>
-    Release Date: X_REL_DATE
-</center>
-<h2>Ìܼ¡</h2>
-<ol>
-    <li><A HREF="#notice">Ãí°Õ»ö¹à</A></li>
-    <li><A HREF="#usage">»ÈÍÑË¡</A></li>
-    <li><A HREF="#path">¥Ñ¥¹¤ÎÀßÄê</A></li>
-    <li><A HREF="#prefs">´Ä¶­ÀßÄê</A></li>
-    <li><A HREF="#license">¥é¥¤¥»¥ó¥¹</A></li>
-</ol>
-<center>
-        <h2><a NAME="notice">Ãí°Õ»ö¹à</a></h2>
-</center>
-<blockquote>
-#if X_PRE_RELEASE
-¤³¤ì¤Ï¡¤XDarwin ¤Î¥×¥ì¥ê¥ê¡¼¥¹¥Ð¡¼¥¸¥ç¥ó¤Ç¤¢¤ê¡¤¤¤¤«¤Ê¤ë¾ì¹ç¤Ë¤ª¤¤¤Æ¤â¥µ¥Ý¡¼¥È¤µ¤ì¤Þ¤»¤ó¡£ 
-¥Ð¥°¤ÎÊó¹ð¤ä¥Ñ¥Ã¥Á¤¬ SourceForge ¤Î <A HREF="http://sourceforge.net/projects/xonx/">XonX ¥×¥í¥¸¥§¥¯¥È¥Ú¡¼¥¸</A>¤ËÄó½Ð¤µ¤ì¤Æ¤¤¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£
-¥×¥ì¥ê¥ê¡¼¥¹¥Ð¡¼¥¸¥ç¥ó¤Î¥Ð¥°¤òÊó¹ð¤¹¤ëÁ°¤Ë¡¤<A HREF="http://sourceforge.net/projects/xonx/">XonX</A> ¥×¥í¥¸¥§¥¯¥È¥Ú¡¼¥¸¤Þ¤¿¤Ï X_VENDOR_LINK¤ÇºÇ¿·ÈǤΥÁ¥§¥Ã¥¯¤ò¤·¤Æ²¼¤µ¤¤¡£
-#else
-¤â¤·¡¤¥µ¡¼¥Ð¡¼¤¬ 6 -12 ¥ö·î°Ê¾åÁ°¤Î¤â¤Î¤«¡¤¤Þ¤¿¤Ï¤¢¤Ê¤¿¤Î¥Ï¡¼¥É¥¦¥§¥¢¤¬¾åµ­¤ÎÆüÉÕ¤è¤ê¤â¿·¤·¤¤¤â¤Î¤Ê¤é¤Ð¡¤ÌäÂê¤òÊó¹ð¤¹¤ëÁ°¤Ë¤è¤ê¿·¤·¤¤¥Ð¡¼¥¸¥ç¥ó¤òõ¤·¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£
-¥Ð¥°¤ÎÊó¹ð¤ä¥Ñ¥Ã¥Á¤¬ SourceForge ¤Î <A HREF="http://sourceforge.net/projects/xonx/">XonX ¥×¥í¥¸¥§¥¯¥È¥Ú¡¼¥¸</A>¤ËÄó½Ð¤µ¤ì¤Æ¤¤¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£
-#endif
-</blockquote>
-<blockquote>
-ËÜ¥½¥Õ¥È¥¦¥§¥¢¤Ï¡¤<A HREF="#license">MIT X11/X Consortium License</A> ¤Î¾ò·ï¤Ë´ð¤Å¤­¡¤ÌµÊݾڤǡ¤¡Ö¤½¤Î¤Þ¤Þ¡×¤Î·Á¤Ç¶¡µë¤µ¤ì¤Þ¤¹¡£
-¤´»ÈÍѤˤʤëÁ°¤Ë¡¤<A HREF="#license">¥é¥¤¥»¥ó¥¹¾ò·ï</A>¤ò¤ªÆɤ߲¼¤µ¤¤¡£
-</blockquote>
-
-<h2><a NAME="usage">»ÈÍÑË¡</a></h2>
-<p>XDarwin ¤Ï¡¤ºÆÇÛÉÛ²Äǽ¤Ê¥ª¡¼¥×¥ó¥½¡¼¥¹¤Î <a HREF="http://www.x.org/">X Window System</a> ¤Î¤¿¤á¤Î X ¥µ¡¼¥Ð¡¼¤Î¼ÂÁõ¤Ç¤¹¡£¤³¤Î¥Ð¡¼¥¸¥ç¥ó¤Î XDarwin ¤Ï X_VENDOR_LINK ¤Ë¤è¤Ã¤ÆºîÀ®¤µ¤ì¤Þ¤·¤¿¡£XDarwin ¤Ï¡¤Mac OS X ¾å¤Ç¥Õ¥ë¥¹¥¯¥ê¡¼¥ó¥â¡¼¥É¤Þ¤¿¤Ï¥ë¡¼¥È¥ì¥¹¥â¡¼¥É¤ÇÆ°ºî¤·¤Þ¤¹¡£</p>
-
-<p>¥Õ¥ë¥¹¥¯¥ê¡¼¥ó¥â¡¼¥É¤Ç¤Ï¡¤X Window System ¤¬¥¢¥¯¥Æ¥£¥Ö¤Ê»þ¡¤¤½¤ì¤ÏÁ´²èÌ̤òÀêÍ­¤·¤Þ¤¹¡£
-¤¢¤Ê¤¿¤Ï¡¤Command-Option-A ¥­¡¼¤ò²¡¤¹¤³¤È¤Ë¤è¤Ã¤Æ Mac OS X ¥Ç¥¹¥¯¥È¥Ã¥×¤ØÀÚ¤êÂؤ¨¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¤³¤Î¥­¡¼¤ÎÁȤ߹ç¤ï¤»¤Ï¡¤´Ä¶­ÀßÄê¤ÇÊѹ¹²Äǽ¤Ç¤¹¡£
-Mac OS X ¥Ç¥¹¥¯¥È¥Ã¥×¤«¤é X Window System ¤ØÀÚ¤êÂؤ¨¤ë¾ì¹ç¤Ï¡¤¥É¥Ã¥¯¤Ëɽ¼¨¤µ¤ì¤¿ XDarwin ¥¢¥¤¥³¥ó¤ò¥¯¥ê¥Ã¥¯¤·¤Æ²¼¤µ¤¤¡£
-¡Ê´Ä¶­ÀßÄê¤Ç¡¤¥Õ¥í¡¼¥Æ¥£¥ó¥°¡¦¥¦¥£¥ó¥É¥¦¤Ëɽ¼¨¤µ¤ì¤¿ XDarwin ¥¢¥¤¥³¥ó¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤è¤¦¤ËÊѹ¹¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¡Ë</p>
-
-<p>¥ë¡¼¥È¥ì¥¹¥â¡¼¥É¤Ç¤Ï¡¤X Window System ¤È Aqua ¤Ï²èÌ̤ò¶¦Í­¤·¤Þ¤¹¡£
-X11 ¤¬É½¼¨¤¹¤ë¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤Ï²èÌ̤Υµ¥¤¥º¤Ç¤¢¤ê¡¤Â¾¤ÎÁ´¤Æ¤Î¥¦¥£¥ó¥É¥¦¤ò´Þ¤ó¤Ç¤¤¤Þ¤¹¡£
-Aqua ¤¬¥Ç¥¹¥¯¥È¥Ã¥×¤ÎÇطʤòÀ©¸æ¤¹¤ë¤Î¤Ç¡¤X11 ¤Î¥ë¡¼¥È¥¦¥£¥ó¥É¥¦¤Ï¥ë¡¼¥È¥ì¥¹¥â¡¼¥É¤Ç¤Ïɽ¼¨¤µ¤ì¤Þ¤»¤ó¡£</p>
-
-<h3>Ê£¿ô¥Ü¥¿¥ó¥Þ¥¦¥¹¤Î¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó</h3>
-<p>¿¤¯¤Î X11 ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï¡¤3 ¥Ü¥¿¥ó¥Þ¥¦¥¹¤òɬÍפȤ·¤Þ¤¹¡£
-¤¢¤Ê¤¿¤Ï¥Þ¥¦¥¹¥Ü¥¿¥ó¤Î¥¯¥ê¥Ã¥¯¤ÈƱ»þ¤Ë¤¤¤¯¤Ä¤«¤Î½¤¾þ¥­¡¼¤ò²¡¤¹¤³¤È¤Ë¤è¤Ã¤Æ¡¤°ì¤Ä¤Î¥Ü¥¿¥ó¤Ç 3 ¥Ü¥¿¥ó¥Þ¥¦¥¹¤ò¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
-¤³¤ì¤Ï¡¤´Ä¶­ÀßÄê¤Î¡Ö°ìÈÌÀßÄê¡×¤Î¡ÖÊ£¿ô¥Ü¥¿¥ó¥Þ¥¦¥¹¤Î¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó¡×¥»¥¯¥·¥ç¥ó¤ÇÀßÄꤷ¤Þ¤¹¡£
-¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¤¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó¤ÏÍ­¸ú¤Ç¡¤¥³¥Þ¥ó¥É¥­¡¼¤ò²¡¤·¤Ê¤¬¤é¥Þ¥¦¥¹¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤³¤È¤ÏÂè 2 ¥Þ¥¦¥¹¥Ü¥¿¥ó¤Î¥¯¥ê¥Ã¥¯¤ËÁêÅö¤·¤Þ¤¹¡£
-¥ª¥×¥·¥ç¥ó¥­¡¼¤ò²¡¤·¤Ê¤¬¤é¥¯¥ê¥Ã¥¯¤¹¤ë¤³¤È¤ÏÂè 3 ¥Þ¥¦¥¹¥Ü¥¿¥ó¤Î¥¯¥ê¥Ã¥¯¤ËÁêÅö¤·¤Þ¤¹¡£
-¤¢¤Ê¤¿¤Ï¡¤´Ä¶­ÀßÄê¤Ç¥Ü¥¿¥ó 2 ¤È 3 ¤ò¥¨¥ß¥å¥ì¡¼¥È¤¹¤ë¤¿¤á¤Ë»ÈÍѤ¹¤ë½¤¾þ¥­¡¼¤ÎÁȹ礻¤òÊѹ¹¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
-Ãí¡§½¤¾þ¥­¡¼¤ò xmodmap ¤Ç¾¤Î¥­¡¼¤Ë³ä¤êÅö¤Æ¤Æ¤¤¤ë¾ì¹ç¤Ç¤â¡¤Ê£¿ô¥Ü¥¿¥ó¥Þ¥¦¥¹¤Î¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó¤Ç¤ÏËÜÍè¤Î¥³¥Þ¥ó¥É¥­¡¼¤ä¥ª¥×¥·¥ç¥ó¥­¡¼¤ò»È¤ï¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£</p>
-
-<h2><a NAME="path">¥Ñ¥¹¤ÎÀßÄê</a></h2>
-<p>¥Ñ¥¹¤Ï¡¤ ¼Â¹Ô²Äǽ¤Ê¥³¥Þ¥ó¥É¤ò¸¡º÷¤¹¤ë¥Ç¥£¥ì¥¯¥È¥ê¤Î¥ê¥¹¥È¤Ç¤¹¡£
-X11 ¥Ð¥¤¥Ê¥ê¤Ï¡¤<code>/usr/X11R6/bin</code> ¤ËÃÖ¤«¤ì¤Þ¤¹¡£¤¢¤Ê¤¿¤Ï¤½¤ì¤ò¥Ñ¥¹¤Ë²Ã¤¨¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£
-XDarwin ¤Ï¡¤¤³¤ì¤ò¥Ç¥Õ¥©¥ë¥È¤Ç¹Ô¤¤¤Þ¤¹¡£¤Þ¤¿¡¤¤¢¤Ê¤¿¤¬¥³¥Þ¥ó¥É¥é¥¤¥ó¡¦¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ò¥¤¥ó¥¹¥È¡¼¥ë¤·¤¿ÄɲäΥǥ£¥ì¥¯¥È¥ê¤ò²Ã¤¨¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£</p>
-
-<p>·Ð¸³Ë­¤«¤Ê¥æ¡¼¥¶¡¼¤Ï¡¤¤¹¤Ç¤Ë¼«¤é¤Î¥·¥§¥ë¤Î¤¿¤á¤Ë½é´ü²½¥Õ¥¡¥¤¥ë¤ò»ÈÍѤ·¤Æ¥Ñ¥¹¤òÀßÄꤷ¤Æ¤¤¤ë¤Ç¤·¤ç¤¦¡£
-¤³¤Î¾ì¹ç¡¤¤¢¤Ê¤¿¤Ï´Ä¶­ÀßÄê¤Ç XDarwin ¤¬¤¢¤Ê¤¿¤Î¥Ñ¥¹¤òÊѹ¹¤·¤Ê¤¤¤è¤¦¤ËÀßÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
-XDarwin ¤Ï¡¤¥æ¡¼¥¶¡¼¤Î¥Ç¥Õ¥©¥ë¥È¤Î¥í¥°¥¤¥ó¥·¥§¥ë¤ÇºÇ½é¤Î X11 ¥¯¥é¥¤¥¢¥ó¥È¤ò³«»Ï¤·¤Þ¤¹¡£
-¡Ê´Ä¶­ÀßÄê¤ÇÂå¤ï¤ê¤Î¥·¥§¥ë¤ò»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¡Ë
-¥Ñ¥¹¤òÀßÄꤹ¤ëÊýË¡¤Ï¡¤¤¢¤Ê¤¿¤¬»ÈÍѤ·¤Æ¤¤¤ë¥·¥§¥ë¤Ë°Í¸¤·¤Þ¤¹¡£
-¤³¤ì¤Ï¡¤¥·¥§¥ë¤Î¥Þ¥Ë¥å¥¢¥ë¥Ú¡¼¥¸¥É¥­¥å¥á¥ó¥È¤Ëµ­ºÜ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£
-
-<p>¤Þ¤¿¡¤¤¢¤Ê¤¿¤Ï¥É¥­¥å¥á¥ó¥È¤òõ¤·¤Æ¤¤¤ë»þ¡¤X11 ¤Î¥Þ¥Ë¥å¥¢¥ë¥Ú¡¼¥¸¤ò¸¡º÷¤µ¤ì¤ë¥Ú¡¼¥¸¤Î¥ê¥¹¥È¤ËÄɲä·¤¿¤¤¤È»×¤¦¤«¤â¤·¤ì¤Þ¤»¤ó¡£
-X11 ¤Î¥Þ¥Ë¥å¥¢¥ë¥Ú¡¼¥¸¤Ï <code>/usr/X11R6/man</code> ¤ËÃÖ¤«¤ì¤Þ¤¹¡£¤½¤·¤Æ <code>MANPATH</code> ´Ä¶­ÊÑ¿ô¤Ï¸¡º÷¤¹¤ë¥Ç¥£¥ì¥¯¥È¥ê¤Î¥ê¥¹¥È¤ò´Þ¤ó¤Ç¤¤¤Þ¤¹¡£</p>
-
-<h2><a NAME="prefs">´Ä¶­ÀßÄê</a></h2>
-<p>¡ÖXDarwin¡×¥á¥Ë¥å¡¼¤Î¡Ö´Ä¶­ÀßÄê...¡×¥á¥Ë¥å¡¼¹àÌܤ«¤é¥¢¥¯¥»¥¹¤Ç¤­¤ë´Ä¶­ÀßÄê¥Ñ¥Í¥ë¤Ç¡¤¤¤¤¯¤Ä¤«¤Î¥ª¥×¥·¥ç¥ó¤òÀßÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
-¡Öµ¯Æ°¥ª¥×¥·¥ç¥ó¡×¤ÎÆâÍƤϡ¤XDarwin ¤òºÆµ¯Æ°¤¹¤ë¤Þ¤ÇÍ­¸ú¤È¤Ê¤ê¤Þ¤»¤ó¡£
-¾¤ÎÁ´¤Æ¤Î¥ª¥×¥·¥ç¥ó¤ÎÆâÍƤϡ¤Ä¾¤Á¤ËÍ­¸ú¤È¤Ê¤ê¤Þ¤¹¡£
-°Ê²¼¡¤¤½¤ì¤¾¤ì¤Î¥ª¥×¥·¥ç¥ó¤Ë¤Ä¤¤¤ÆÀâÌÀ¤·¤Þ¤¹:</p>
-
-<h3>°ìÈÌÀßÄê</h3>
-<ul>
-    <li><b>X11 ¤Ç¥·¥¹¥Æ¥à¤Î¥Ó¡¼¥×²»¤ò»ÈÍѤ¹¤ë:</b> ¥ª¥ó¤Î¾ì¹ç¡¤Mac OS X ¤Î¥Ó¡¼¥×²»¤¬ X11 ¤Î¥Ù¥ë¤È¤·¤Æ»ÈÍѤµ¤ì¤Þ¤¹¡£¥ª¥Õ¤Î¾ì¹ç¡Ê¥Ç¥Õ¥©¥ë¥È¡Ë¡¤¥·¥ó¥×¥ë ¥È¡¼¥ó¤¬»È¤ï¤ì¤Þ¤¹¡£</li>
-    <li><b>X11 ¤Î¥Þ¥¦¥¹¥¢¥¯¥»¥é¥ì¡¼¥·¥ç¥ó¤òÍ­¸ú¤Ë¤¹¤ë:</b> ɸ½àŪ¤Ê X Window System ¤Î¼ÂÁõ¤Ç¤Ï¡¤¥¦¥£¥ó¥É¥¦¥Þ¥Í¡¼¥¸¥ã¡¼¤Ï¥Þ¥¦¥¹¤Î²Ã®ÅÙ¤òÊѹ¹¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
-    ¥Þ¥¦¥¹¤Î²Ã®ÅÙ¤Ë Mac OS X ¤Î¥·¥¹¥Æ¥à´Ä¶­ÀßÄê¤È X ¥¦¥£¥ó¥É¥¦¥Þ¥Í¡¼¥¸¥ã¡¼¤¬°Û¤Ê¤ëÃͤòÀßÄꤷ¤¿¾ì¹ç¡¤¤³¤ì¤Ïº®Íð¤ò¾·¤­¤Þ¤¹¡£
-    ¤³¤ÎÌäÂê¤òÈò¤±¤ë¤¿¤á¡¤¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï X11 ¤Î¥Þ¥¦¥¹¥¢¥¯¥»¥é¥ì¡¼¥·¥ç¥ó¤òÍ­¸ú¤È¤·¤Þ¤»¤ó¡£</li>
-    <li><b>Ê£¿ô¥Ü¥¿¥ó¥Þ¥¦¥¹¤Î¥¨¥ß¥å¥ì¡¼¥·¥ç¥ó:</b> <a HREF="#usage">»ÈÍÑË¡</a>¤ò»²¾È¤·¤Æ²¼¤µ¤¤¡£¥ª¥ó¤Î¾ì¹ç¡¤¥Þ¥¦¥¹¥Ü¥¿¥ó¤¬Âè 2 ¤Þ¤¿¤ÏÂè 3 ¤Î¥Þ¥¦¥¹¥Ü¥¿¥ó¤ò¥¨¥ß¥å¥ì¡¼¥È¤¹¤ë»þ¤Ë¡¤ÁªÂò¤·¤¿½¤¾þ¥­¡¼¤òƱ»þ¤Ë²¡¤·¤Þ¤¹¡£</li>
-</ul>
-
-<h3>µ¯Æ°¥ª¥×¥·¥ç¥ó</h3>
-<ul>
-    <li><b>²èÌ̥⡼¥É:</b> ¥æ¡¼¥¶¡¼¤¬¥Õ¥ë¥¹¥¯¥ê¡¼¥ó¥â¡¼¥É¤Þ¤¿¤Ï¥ë¡¼¥È¥ì¥¹¥â¡¼¥É¤Î¤É¤Á¤é¤ò»ÈÍѤ¹¤ë¤«¤ò»ØÄꤷ¤Ê¤¤¾ì¹ç¡¤¤³¤³¤Ç»ØÄꤵ¤ì¤¿¥â¡¼¥É¤¬»È¤ï¤ì¤Þ¤¹¡£</li>
-    <li><b>µ¯Æ°»þ¤Ë¥â¡¼¥ÉÁªÂò¥Ñ¥Í¥ë¤òɽ¼¨¤¹¤ë:</b> ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¤XDarwin ¤Îµ¯Æ°»þ¤Ë¥æ¡¼¥¶¡¼¤¬¥Õ¥ë¥¹¥¯¥ê¡¼¥ó¥â¡¼¥É¤Þ¤¿¤Ï¥ë¡¼¥È¥ì¥¹¥â¡¼¥É¤Î¤É¤Á¤é¤ò»ÈÍѤ¹¤ë¤«¤òÁªÂò¤¹¤ë¥Ñ¥Í¥ë¤òɽ¼¨¤·¤Þ¤¹¡£¤³¤Î¥ª¥×¥·¥ç¥ó¤¬¥ª¥Õ¤Î¾ì¹ç¡¤²èÌ̥⡼¥É¤Ç»ØÄꤷ¤¿¥â¡¼¥É¤Çµ¯Æ°¤·¤Þ¤¹¡£</li>
-    <li><b>X11 ¥Ç¥£¥¹¥×¥ì¥¤ÈÖ¹æ:</b> X11¤Ï¡¤°ì¤Ä¤Î¥³¥ó¥Ô¥å¡¼¥¿¾å¤ÇÊÌ¡¹¤Î X ¥µ¡¼¥Ð¡¼¤¬´ÉÍý¤¹¤ëÊ£¿ô¤Î¥Ç¥£¥¹¥×¥ì¥¤¤¬Â¸ºß¤¹¤ë¤³¤È¤òµö¤·¤Þ¤¹¡£Ê£¿ô¤Î X ¥µ¡¼¥Ð¡¼¤¬Æ±»þ¤Ë¼Â¹Ô¤·¤Æ¤¤¤ë»þ¡¤XDarwin ¤¬»ÈÍѤ¹¤ë¥Ç¥£¥¹¥×¥ì¥¤¤ÎÈÖ¹æ¤ò»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£</li>
-    <li><b>Xinerama ¥Þ¥ë¥Á¥â¥Ë¥¿¥µ¥Ý¡¼¥È¤òÍ­¸ú¤Ë¤¹¤ë:</b> XDarwin ¤Ï¡¤Xinerama ¥Þ¥ë¥Á¥â¥Ë¥¿¤ò¥µ¥Ý¡¼¥È¤·¤Þ¤¹¡£¤½¤ì¤ÏÁ´¤Æ¤Î¥â¥Ë¥¿¤ò°ì¤Ä¤ÎÂ礭¤Ê²èÌ̤ΰìÉô¤È¤ß¤Ê¤·¤Þ¤¹¡£¤¢¤Ê¤¿¤Ï¤³¤Î¥ª¥×¥·¥ç¥ó¤Ç Xinerama ¤ò̵¸ú¤Ë¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¤¿¤À¤·¡¤¸½ºß XDarwin ¤Ï¤½¤ì̵¤·¤ÇÀµ¤·¤¯Ê£¿ô¤Î¥â¥Ë¥¿¤ò°·¤¦¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó¡£¤â¤·¡¤¤¢¤Ê¤¿¤¬°ì¤Ä¤Î¥â¥Ë¥¿¤ò»È¤¦¤À¤±¤Ê¤é¤Ð¡¤Xinerama ¤Ï¼«Æ°Åª¤Ë̵¸ú¤È¤Ê¤ê¤Þ¤¹¡£</li>
-    <li><b>¥­¡¼¥Þ¥Ã¥Ô¥ó¥°¥Õ¥¡¥¤¥ë:</b> ¥­¡¼¥Þ¥Ã¥Ô¥ó¥°¥Õ¥¡¥¤¥ë¤Ïµ¯Æ°»þ¤ËÆɤ߹þ¤Þ¤ì¡¤X11 ¥­¡¼¥Þ¥Ã¥×¤ËÊÑ´¹¤µ¤ì¤Þ¤¹¡£Â¾¸À¸ì¤ËÂбþ¤·¤¿¥­¡¼¥Þ¥Ã¥Ô¥ó¥°¥Õ¥¡¥¤¥ë¤Ï <code>/System/Library/Keyboards</code> ¤Ë¤¢¤ê¤Þ¤¹¡£¡ÊÌõÃí¡§¥­¡¼¥Þ¥Ã¥Ô¥ó¥°¤Ç Japanese ¤òÁªÂò¤¹¤ë¤È¡¤°ìÉô¤Î¥­¡¼¤¬¸ú¤«¤Ê¤¤Åù¤ÎÉÔ¶ñ¹ç¤¬È¯À¸¤¹¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹¡£¤³¤Î¾ì¹ç¤Ï USA ¤òÁªÂò¤·¤¿¾å¤Ç ~/.Xmodmap ¤òŬÍѤ·¤Æ²¼¤µ¤¤¡£¡Ë</li>
-    <li><b>ºÇ½é¤Î X11 ¥¯¥é¥¤¥¢¥ó¥È¤Îµ¯Æ°:</b> XDarwin ¤¬ Finder¤«¤éµ¯Æ°¤¹¤ë»þ¡¤X ¥¦¥£¥ó¥É¥¦¥Þ¥Í¡¼¥¸¥ã¡¼¤È X ¥¯¥é¥¤¥¢¥ó¥È¤Îµ¯Æ°¤Ï <code>xinit</code> ¤ò¼Â¹Ô¤·¤Þ¤¹¡£¡Ê¾ÜºÙ¤Ï "<code>man xinit</code>" ¤ò»²¾È¤·¤Æ²¼¤µ¤¤¡£¡ËXDarwin ¤Ï <code>xinit</code> ¤ò¼Â¹Ô¤¹¤ëÁ°¤Ë¡¤»ØÄꤵ¤ì¤¿¥Ç¥£¥ì¥¯¥È¥ê¤ò¥æ¡¼¥¶¡¼¤Î¥Ñ¥¹¤ËÄɲä·¤Þ¤¹¡£¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï <code>/usr/X11R6/bin</code> ¤À¤±¤òÄɲä·¤Þ¤¹¡£Â¾¤Î¥Ç¥£¥ì¥¯¥È¥ê¤òÄɲä·¤¿¤¤¾ì¹ç¤Ï¡¤¥³¥í¥ó¤Ç¶èÀڤäƻØÄꤷ¤Þ¤¹¡£¥æ¡¼¥¶¡¼¤Î¥·¥§¥ë½é´ü²½¥Õ¥¡¥¤¥ë¤òÆɤ߹þ¤à¤¿¤á¤Ë¡¤X ¥¯¥é¥¤¥¢¥ó¥È¤Ï¥æ¡¼¥¶¡¼¤Î¥Ç¥Õ¥©¥ë¥È¥í¥°¥¤¥ó¥·¥§¥ë¤Çµ¯Æ°¤µ¤ì¤Þ¤¹¡£É¬ÍפǤ¢¤ì¤Ð¡¤Âå¤ï¤ê¤Î¥·¥§¥ë¤ò»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£</li>
-</ul>
-
-<h3>¥Õ¥ë¥¹¥¯¥ê¡¼¥ó</h3>
-<ul>
-    <li><b>¥­¡¼ÀßÄê¥Ü¥¿¥ó:</b> X11 ¤È Aqua ¤òÀÚ¤êÂؤ¨¤ë¤¿¤á¤Ë»ÈÍѤ¹¤ë¥Ü¥¿¥ó¤ÎÁȤ߹ç¤ï¤»¤ò»ØÄꤷ¤Þ¤¹¡£
-    ¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤·¤Æ¡¤Ç¤°Õ¤Î¿ô¤Î½¤¾þ¥­¡¼¤Ë³¤¤¤ÆÄ̾ï¤Î¥­¡¼¤ò²¡¤·¤Þ¤¹¡£</li>
-    <li><b>¥É¥Ã¥¯¤Î¥¢¥¤¥³¥ó¤Î¥¯¥ê¥Ã¥¯¤Ç X11 ¤ËÌá¤ë:</b> ¥ª¥ó¤Î¾ì¹ç¡¤¥É¥Ã¥¯¤Ëɽ¼¨¤µ¤ì¤¿ XDarwin ¥¢¥¤¥³¥ó¤Î¥¯¥ê¥Ã¥¯¤Ç X11 ¤Ø¤ÎÀڤ괹¤¨¤¬²Äǽ¤È¤Ê¤ê¤Þ¤¹¡£Mac OS X ¤Î¤¤¤¯¤Ä¤«¤Î¥Ð¡¼¥¸¥ç¥ó¤Ç¤Ï¡¤¥É¥Ã¥¯¤Î¥¢¥¤¥³¥ó¤Î¥¯¥ê¥Ã¥¯¤Ç Aqua ¤ËÌá¤Ã¤¿»þ¡¤¥«¡¼¥½¥ë¤¬¾Ã¼º¤¹¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹¡£</li>
-    <li><b>µ¯Æ°»þ¤Ë¥Ø¥ë¥×¤òɽ¼¨¤¹¤ë:</b> XDarwin ¤¬¥Õ¥ë¥¹¥¯¥ê¡¼¥ó¥â¡¼¥É¤Çµ¯Æ°¤¹¤ë»þ¡¤¥¹¥×¥é¥Ã¥·¥å¥¹¥¯¥ê¡¼¥ó¤òɽ¼¨¤·¤Þ¤¹¡£</li>
-    <li><b>¿§¿¼ÅÙ:</b> ¥Õ¥ë¥¹¥¯¥ê¡¼¥ó¥â¡¼¥É¤Ç¤Ï¡¤X11 ¥Ç¥£¥¹¥×¥ì¥¤¤¬ Aqua ¤È°Û¤Ê¤ë¿§¿¼ÅÙ¤ò»È¤¦¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¡ÖÊѹ¹¤Ê¤·¡×¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¡¤XDarwin ¤Ï Aqua ¤Ë¤è¤Ã¤Æ»ÈÍѤµ¤ì¤ë¿§¿¼ÅÙ¤ò»È¤¤¤Þ¤¹¡£¤³¤ì°Ê³°¤Ë 8¡¤15 ¤Þ¤¿¤Ï24 ¥Ó¥Ã¥È¤ò»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£</li>
-</ul>
-
-<h2>
-<a NAME="license">¥é¥¤¥»¥ó¥¹</a>
-</h2>
-XDarwin ¤Î¼çÍפʥ饤¥»¥ó¥¹¤ÏÅÁÅýŪ¤Ê MIT X11/X Consortium License ¤Ë´ð¤Å¤­¤Þ¤¹¡£
-¤½¤ì¤Ï½¤Àµ¤Þ¤¿¤ÏºÆÇÛÉÛ¤µ¤ì¤ë¥½¡¼¥¹¥³¡¼¥É¤Þ¤¿¤Ï¥Ð¥¤¥Ê¥ê¤Ë¡¤¤½¤ÎÃøºî¸¢/¥é¥¤¥»¥ó¥¹É½¼¨¤¬¤½¤Î¤Þ¤Þ»Ä¤µ¤ì¤ë¤³¤È¤òÍ׵᤹¤ë°Ê³°¤Î¾ò·ï¤ò¶¯À©¤·¤Þ¤»¤ó¡£
-¤è¤ê¿¤¯¤Î¾ðÊó¤È¡¤¥³¡¼¥É¤Î°ìÉô¤ò¥«¥Ð¡¼¤¹¤ëÄɲäÎÃøºî¸¢/¥é¥¤¥»¥ó¥¹É½¼¨¤Î¤¿¤á¤Ë¡¤¥½¡¼¥¹¥³¡¼¥É¤ò»²¾È¤·¤Æ²¼¤µ¤¤¡£
-<H3>
-<A NAME="3"></A>
-X  Consortium License</H3>
-<p>Copyright (C) 1996 X Consortium</p>
-<p>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:</p>
-<p>The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.</p>
-<p>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 X CONSORTIUM 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.</p>
-<p>Except as contained in this notice, the name of the X Consortium 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 X Consortium.</p>
-<p>X Window System is a trademark of X Consortium, Inc.</p>
-</body>
-</html>
diff --git a/hw/darwin/bundle/Makefile.am b/hw/darwin/bundle/Makefile.am
deleted file mode 100644
index f02be74..0000000
--- a/hw/darwin/bundle/Makefile.am
+++ /dev/null
@@ -1,39 +0,0 @@
-BINDIR = ${bindir}
-include $(top_srcdir)/cpprules.in
-XINITDIR = $(libdir)/X11/xinit
-XDEFS = \
-        -DX_VERSION="$(PLIST_VERSION_STRING)" \
-        -DX_PRE_RELEASE="$(PRE)" \
-        -DX_REL_DATE="$(XORG_DATE)" \
-        -DX_VENDOR_NAME="$(VENDOR_STRING)" \
-        -DX_VENDOR_LINK="$(PLIST_VENDOR_WEB)"
-
-SUBDIRS =  English.lproj Dutch.lproj French.lproj German.lproj Japanese.lproj \
-	ko.lproj Portuguese.lproj Spanish.lproj Swedish.lproj
-
-bin_SCRIPTS = startXClients
-
-startXClients: $(srcdir)/startXClients.cpp
-	$(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) -DXINITDIR=$(XINITDIR) -DXBINDIR=$(BINDIR)  $< | $(CPP_SED_MAGIC) > $@
-	-chmod 755 startXClients
-
-contentsdir = @APPLE_APPLICATIONS_DIR@/XDarwin.app/Contents
-resourcesdir = $(contentsdir)/Resources
-
-contents_DATA = Info.plist
-resources_DATA = XDarwin.icns startXClients
-
-install-data-hook:
-	chmod 755 $(DESTDIR)$(resourcesdir)/startXClients
-	echo "APPL????" > $(DESTDIR)$(contentsdir)/PkgInfo
-	touch $(DESTDIR)@APPLE_APPLICATIONS_DIR@/XDarwin.app
-
-uninstall-hook:
-	rm -rf $(DESTDIR)$(contentsdir)/PkgInfo
-
-CLEANFILES = startXClients
-
-EXTRA_DIST = \
-	XDarwin.icns \
-	startXClients.cpp \
-	Info.plist
diff --git a/hw/darwin/bundle/Portuguese.lproj/Credits.rtf b/hw/darwin/bundle/Portuguese.lproj/Credits.rtf
deleted file mode 100644
index 8dcddc2..0000000
--- a/hw/darwin/bundle/Portuguese.lproj/Credits.rtf
+++ /dev/null
@@ -1,171 +0,0 @@
-{\rtf1\mac\ansicpg10000\cocoartf102
-{\fonttbl\f0\fswiss\fcharset77 Helvetica;\f1\fswiss\fcharset77 Helvetica-Bold;\f2\fswiss\fcharset77 Helvetica-Oblique;
-}
-{\colortbl;\red255\green255\blue255;}
-\vieww5140\viewh4980\viewkind0
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
-
-\f0\fs24 \cf0 This product includes software developed by The XFree86 Project, Inc  (http://www.xfree86.org/) and its contributors. The following people contributed to Darwin/Mac OS X support.\
-\
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-
-\f1\b \cf0 Contributors to Xorg Foundation Release:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Kaleb KEITHLEY\
-     
-\f2\i Working left and right Ctrl, Alt (Option), Meta (Command) and Shift keys.
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\f1\b \cf0 Contributors to XFree86 4.4:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 John Harper\
-     
-\f2\i Rootless acceleration and Apple-WM extension
-\f0\i0 \
-Torrey T. Lyons\
-     
-\f2\i Project Lead
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 Contribuidores do XonX ao XFree86 4.3:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Fabr\'92cio Luis de Castro
-\f1\b \
-     
-\f2\i\b0 Localiza\'8d\'8bo para o Portugu\'90s\
-
-\f0\i0 Michael Oland\
-     
-\f2\i New XDarwin icon
-\f1\i0\b \
-\
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 Contribuidores do XonX ao XFree86 4.2:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Rob Braun\
-     
-\f2\i Suporte para o Darwin x86\
-
-\f0\i0 Pablo Di Noto\
-
-\f2\i      Localiza\'8d\'8bo para o Espanhol
-\f0\i0 \
-Paul Edens\
-
-\f2\i      Localiza\'8d\'8bo para o Holand\'90s
-\f0\i0 \
-Kyunghwan Kim\
-
-\f2\i      Localiza\'8d\'8bo para o Coreano
-\f0\i0 \
-Mario Klebsch\
-     
-\f2\i Suporte para teclados Non-US
-\f0\i0 \
-Torrey T. Lyons\
-     
-\f2\i L\'92der de Projeto
-\f0\i0 \
-Andreas Monitzer\
-     
-\f2\i Localiza\'8d\'8bo para o Alem\'8bo
-\f0\i0 \
-Patrik Montgomery\
-
-\f2\i      Localiza\'8d\'8bo para o Sueco
-\f0\i0 \
-Greg Parker\
-     
-\f2\i Suporte ao modo Compartilhado (Rootless)
-\f0\i0 \
-Toshimitsu Tanaka\
-     
-\f2\i Localiza\'8d\'8bo para o Japon\'90s
-\f0\i0 \
-Olivier Verdier\
-
-\f2\i      Localiza\'8d\'8bo para o Fran\'8d\'90s
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 Agradecimentos Especiais:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Devin Poolman and Zero G Software, Inc.\
-
-\f2\i      Instalador
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 Membros do Time XonX\
-Contribuindo com o XFree86 4.1:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Rob Braun\
-     
-\f2\i Suporte ao Darwin x86\
-
-\f0\i0 Torrey T. Lyons\
-    
-\f2\i  L\'92der de Projeto
-\f0\i0 \
-Andreas Monitzer\
-     
-\f2\i Vers\'8bo Cocoa da interface XDarwin
-\f0\i0 \
-Greg Parker\
-     
-\f2\i Implementa\'8d\'8bo Original
-\f0\i0  
-\f2\i ao Quartz \
-
-\f0\i0 Christoph Pfisterer\
-     
-\f2\i Bibliotecas Din\'89micas Compartilhadas
-\f0\i0 \
-Toshimitsu Tanaka\
-     
-\f2\i Localiza\'8d\'8bo para o Japon\'90s
-\f0\i0 \
-\
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-
-\f1\b \cf0 Agradecimento Especial:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Tiago Ribeiro\
-     
-\f2\i \'eacone do XDarwin
-\f0\i0 \
-\
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-
-\f1\b \cf0 Hist\'97rico:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 John Carmack\
-    
-\f2\i  Suporte Original do XFree86 no Mac OS X Server
-\f0\i0 \
-Dave Zarzycki\
-     
-\f2\i Suporte ao
-\f0\i0  
-\f2\i XFree86 4.0 no Darwin 1.0
-\f0\i0 \
-Torrey T. Lyons\
-     
-\f2\i Integra\'8d\'8bo dentro do Projeto XFree86 na vers\'8bo 4.0.2}
\ No newline at end of file
diff --git a/hw/darwin/bundle/Portuguese.lproj/Localizable.strings b/hw/darwin/bundle/Portuguese.lproj/Localizable.strings
deleted file mode 100644
index c79b282..0000000
Binary files a/hw/darwin/bundle/Portuguese.lproj/Localizable.strings and /dev/null differ
diff --git a/hw/darwin/bundle/Portuguese.lproj/MainMenu.nib/classes.nib b/hw/darwin/bundle/Portuguese.lproj/MainMenu.nib/classes.nib
deleted file mode 100644
index 77f345a..0000000
--- a/hw/darwin/bundle/Portuguese.lproj/MainMenu.nib/classes.nib
+++ /dev/null
@@ -1,72 +0,0 @@
-{
-    IBClasses = (
-        {
-            ACTIONS = {showHelp = id; }; 
-            CLASS = FirstResponder; 
-            LANGUAGE = ObjC; 
-            SUPERCLASS = NSObject; 
-        }, 
-        {
-            ACTIONS = {close = id; pickFile = id; saveChanges = id; setKey = id; }; 
-            CLASS = Preferences; 
-            LANGUAGE = ObjC; 
-            OUTLETS = {
-                addToPathButton = id; 
-                addToPathField = id; 
-                button2ModifiersMatrix = id; 
-                button3ModifiersMatrix = id; 
-                depthButton = id; 
-                displayField = id; 
-                dockSwitchButton = id; 
-                fakeButton = id; 
-                keymapFileField = id; 
-                modeMatrix = id; 
-                modeWindowButton = id; 
-                mouseAccelChangeButton = id; 
-                startupHelpButton = id; 
-                switchKeyButton = id; 
-                systemBeepButton = id; 
-                useDefaultShellMatrix = id; 
-                useOtherShellField = id; 
-                useXineramaButton = id; 
-                window = id; 
-            }; 
-            SUPERCLASS = NSObject; 
-        }, 
-        {
-            CLASS = XApplication; 
-            LANGUAGE = ObjC; 
-            OUTLETS = {preferences = id; xserver = id; }; 
-            SUPERCLASS = NSApplication; 
-        }, 
-        {
-            ACTIONS = {
-                bringAllToFront = id; 
-                closeHelpAndShow = id; 
-                itemSelected = id; 
-                nextWindow = id; 
-                previousWindow = id; 
-                showAction = id; 
-                showSwitchPanel = id; 
-                startFullScreen = id; 
-                startRootless = id; 
-            }; 
-            CLASS = XServer; 
-            LANGUAGE = ObjC; 
-            OUTLETS = {
-                dockMenu = NSMenu; 
-                helpWindow = NSWindow; 
-                modeWindow = NSWindow; 
-                startFullScreenButton = NSButton; 
-                startRootlessButton = NSButton; 
-                startupHelpButton = NSButton; 
-                startupModeButton = NSButton; 
-                switchWindow = NSPanel; 
-                windowMenu = NSMenu; 
-                windowSeparator = NSMenuItem; 
-            }; 
-            SUPERCLASS = NSObject; 
-        }
-    ); 
-    IBVersion = 1; 
-}
\ No newline at end of file
diff --git a/hw/darwin/bundle/Portuguese.lproj/MainMenu.nib/objects.nib b/hw/darwin/bundle/Portuguese.lproj/MainMenu.nib/objects.nib
deleted file mode 100644
index 9cb67cf..0000000
Binary files a/hw/darwin/bundle/Portuguese.lproj/MainMenu.nib/objects.nib and /dev/null differ
diff --git a/hw/darwin/bundle/Portuguese.lproj/Makefile.am b/hw/darwin/bundle/Portuguese.lproj/Makefile.am
deleted file mode 100644
index 540649c..0000000
--- a/hw/darwin/bundle/Portuguese.lproj/Makefile.am
+++ /dev/null
@@ -1,39 +0,0 @@
-BINDIR = ${bindir}
-include $(top_srcdir)/cpprules.in
-XINITDIR = $(libdir)/X11/xinit
-XDEFS = \
-        -DX_VERSION="$(PLIST_VERSION_STRING)" \
-        -DX_PRE_RELEASE="$(PRE)" \
-        -DX_REL_DATE="$(XORG_DATE)" \
-        -DX_VENDOR_NAME="$(VENDOR_STRING)" \
-        -DX_VENDOR_LINK="$(PLIST_VENDOR_WEB)"
-
-resourcesdir = @APPLE_APPLICATIONS_DIR@/XDarwin.app/Contents/Resources
-
-Portugueselprojdir = $(resourcesdir)/Portuguese.lproj
-
-Portugueselproj_DATA = \
-		    XDarwinHelp.html \
-		    InfoPlist.strings \
-		    Credits.rtf Localizable.strings
-
-Portugueselprojnibdir = $(Portugueselprojdir)/MainMenu.nib
-Portugueselprojnib_DATA = \
-		       MainMenu.nib/classes.nib \
-		       MainMenu.nib/objects.nib
-
-InfoPlist.strings: $(srcdir)/../English.lproj/InfoPlist.strings.cpp
-	 $(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) | $(SED) -e's/__quote__/"/g' | iconv -t UTF-16 > $@
-
-XDarwinHelp.html: XDarwinHelp.html.cpp
-	$(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) > $@
-
-CLEANFILES = XDarwinHelp.html InfoPlist.strings 
-
-EXTRA_DIST = \
-	Credits.rtf Localizable.strings \
-	Localizable.strings \
-	MainMenu.nib/classes.nib \
-	MainMenu.nib/objects.nib \
-	XDarwinHelp.html.cpp
-
diff --git a/hw/darwin/bundle/Portuguese.lproj/XDarwinHelp.html.cpp b/hw/darwin/bundle/Portuguese.lproj/XDarwinHelp.html.cpp
deleted file mode 100644
index 6800171..0000000
--- a/hw/darwin/bundle/Portuguese.lproj/XDarwinHelp.html.cpp
+++ /dev/null
@@ -1,209 +0,0 @@
-<head>
-<title>XDarwin Help</title>
-</head>
-
-<center>
-    
-  <h1>XDarwin X Server para Mac OS X</h1>
-    X_VENDOR_NAME X_VERSION<br>
-    Release Date: X_REL_DATE
-</center>
-<h2>&Iacute;ndice</h2>
-<ol>
-    <li><A HREF="#notice">Notas importantes</A></li>
-    <li><A HREF="#usage">Uso</A></li>
-    <li><A HREF="#path">Ajustando seu Path</A></li>
-    
-  <li><A HREF="#prefs">Prefer&ecirc;ncias do usu&aacute;rio</A></li>
-  <li><A HREF="#license">Licen&ccedil;a</A></li>
-</ol>
-<center>
-    <h2><a NAME="notice">Notas importantes</a></h2>
-</center>
-<blockquote>
-#if PRE_RELEASE
-  Essa &eacute; uma vers&atilde;o pr&eacute;-lancamento 
-  do XDarwin, e ela n&atilde;o &eacute; suportada de nenhuma forma. Bugs podem 
-  ser reportados e corre&ccedil;&otilde;es podem ser enviadas para <A HREF="http://sourceforge.net/projects/xonx/">P&aacute;gina 
-  do projeto XonX</A> no SourceForge. Antes de informar bugs em vers&otilde;es 
-  pr&eacute;-lancamento, por favor verifique a þltima vers&atilde;o em <A HREF="http://sourceforge.net/projects/xonx/">XonX</A> 
-  or X_VENDOR_LINK. 
-#else
-Se o servidor &eacute; mais velho que 6-12 semanas, ou seu hardware &eacute; 
-  mais novo que a data acima, procure por uma nova vers&atilde;o antes de informar 
-  problemas. Bugs podem ser reportados e corre&ccedil;&otilde;es podem ser enviadas 
-  para a <A HREF="http://sourceforge.net/projects/xonx/">P&aacute;gina do projeto 
-  XonX</A> na SourceForge.
-#endif
-</blockquote>
-<blockquote> Este software &eacute; distribu&iacute;do sob os termos da <a href="#license">licen&ccedil;a 
-  MIT X11 / X Consortium</a> e &eacute; provido, sem nenhuma garantia. Por favor 
-  leia a <a href="#license">Licen&ccedil;a</a> antes de come&ccedil;ar a usar 
-  o programa.</blockquote>
-
-<h2><a NAME="usage">Uso</a></h2>
-<p>O XDarwin &eacute; uma X server &quot;open-source&quot; livremente 
-  redistribu&iacute;da do <a HREF
-="http://www.x.org/">Sistema X Window</a>. This version of XDarwin was produced by the X_VENDOR_LINK.
-  XDarwin roda sobre Mac OS X no modo Tela Cheia ou no modo Compartilhado.</p>
-<p>No modo Tela Cheia, quando o sistema X window est&aacute; ativo, ele ocupa 
-  a tela toda. Voc&ecirc; pode voltar ao desktop do Mac OS X clicando Command-Option-A. 
-  Essa combina&ccedil;&atilde;o de teclas pode ser mudada nas prefer&ecirc;ncias. 
-  Pelo desktop Mac OS X, clique no &iacute;cone XDarwin no Dock para voltar ao 
-  sistema X window. (Voc&ecirc; pode mudar esse comportamento nas prefer&ecirc;ncias 
-  da&iacute; voc&ecirc; dever&aacute; clicar no &iacute;cone XDarwin na janela 
-  flutuante que aparecer&aacute;.)</p>
-<p>No modo Compartilhado, o sistema X window e Aqua dividem a mesma tela. A janela 
-  raiz da tela X11 est&aacute; do tamanho da tela (monitor) e cont&eacute;m todas 
-  as outras janelas. A janela raiz do X11 no modo compartilhado n&atilde;o &eacute; 
-  mostrada pois o Aqua controla o fundo de tela.</p>
-<h3>Emula&ccedil;&atilde;o de Mouse Multi-Bot&otilde;es</h3>
-<p>Muitas aplica&ccedil;&otilde;es X11 insistem em usar um mouse de 3 bot&otilde;es. 
-  Voc&ecirc; pode emular um mouse de 3 bot&otilde;es com um simples bot&atilde;o, 
-  mantendo pressionando teclas modificadoras enquanto voc&ecirc; clica no bot&atilde;o 
-  do mouse. Isto &eacute; controlado pela configura&ccedil;&atilde;o da &quot;Emula&ccedil;&atilde;o 
-  de Mouse Multi-Bot&otilde;es&quot; da prefer&ecirc;ncia &quot;Geral&quot;. Por 
-  padr&atilde;o, a emula&ccedil;&atilde;o est&aacute; habilitada e mantendo pressionada 
-  a tecla Command e clicando no bot&atilde;o do mouse ele simular&aacute; o clique 
-  no segundo bot&atilde;o do mouse. Mantendo pressionada a tecla Option e clicando 
-  no bot&atilde;o do mouse ele simular&aacute; o terceiro bot&atilde;o. Voc&ecirc; 
-  pode mudar a combina&ccedil;&atilde;o de teclas modificadoras para emular os 
-  bot&otilde;es dois e tr&ecirc;s nas prefer&ecirc;ncias. Nota, se a tecla modificadora 
-  foi mapeada para alguma outra tecla no xmodmap, voc&ecirc; ainda ter&aacute; 
-  que usar a tecla atual especificada nas prefer&ecirc;ncias para a emula&ccedil;&atilde;o 
-  do mouse multi-bot&otilde;es.</p>
-<h2><a NAME="path">Ajustando seu Path</a></h2>
-<p>Seu path &eacute; a lista de diret&oacute;rios a serem procurados por arquivos 
-  execut&aacute;veis. O comando X11 est&aacute; localizado em <code>/usr/X11R6/bin</code>, 
-  que precisa ser adicionado ao seu path. XDarwin faz isso para voc&ecirc; por 
-  padr&atilde;o e pode-se tamb&eacute;m adicionar diret&oacute;rios onde voc&ecirc; 
-  instalou aplica&ccedil;&otilde;es de linha de comando.</p>
-<p>Usu&aacute;rios experientes j&aacute; ter&atilde;o configurado corretamente 
-  seu path usando arquivos de inicializa&ccedil;&atilde;o de seu shell. Neste 
-  caso, voc&ecirc; pode informar o XDarwin para n&atilde;o modificar seu path 
-  nas prefer&ecirc;ncias. O XDarwin inicia o cliente inicial X11 no shell padr&atilde;o 
-  do usu&aacute;rio corrente. (Um shell alternativo pode ser tamb&eacute;m expecificado 
-  nas prefer&ecirc;ncias.) O modo para ajustar o path depende do shell que voc&ecirc; 
-  est&aacute; usando. Isto &eacute; descrito na man page do seu shell.</p>
-<p>Voc&ecirc; pode tamb&eacute;m querer adicionar as man pages do X11 para 
-  a lista de p&aacute;ginas a serem procuradas quando voc&ecirc; est&aacute; procurando 
-  por documenta&ccedil;&atilde;o. As man pages do X11 est&atilde;o localizadas 
-  em <code>/usr/X11R6/man</code> e a vari&aacute;vel de ambiente <code>MANPATH</code> 
-  cont&eacute;m a lista de diret&oacute;rios a buscar.</p>
-<h2><a NAME="prefs">Prefer&ecirc;ncias do Usu&aacute;rio</a></h2>
-<p>V&aacute;rias op&ccedil;&otilde;es podem ser ajustadas nas prefer&ecirc;ncias 
-  do usu&aacute;rio, acess&iacute;vel pelo item &quot;Prefer&ecirc;ncias...&quot; 
-  no menu &quot;XDarwin&quot;. As op&ccedil;&otilde;es listadas como op&ccedil;&otilde;es 
-  de inicializa&ccedil;&atilde;o, n&atilde;o ter&atilde;o efeito at&eacute; voc&ecirc; 
-  reiniciar o XDarwin. Todas as outras op&ccedil;&otilde;es ter&atilde;o efeito 
-  imediatamente. V&aacute;rias das op&ccedil;&otilde;es est&atilde;o descritas 
-  abaixo:</p>
-<h3>Geral</h3>
-<ul>
-  <li><b>Usar o Beep do Sistema para o X11: </b>Quando habilitado som de alerta 
-    padr&atilde;o do Mac OS X ser&aacute; usado como alerta no X11. Quando desabilitado 
-    (padr&atilde;o) um tom simples ser&aacute; usado.</li>
-  <li><b>Permitir o X11 mudar a acelera&ccedil;&atilde;o do mouse: </b>Por implementa&ccedil;&atilde;o 
-    padr&atilde;o no sistema X window, o gerenciador de janelas pode mudar a acelera&ccedil;&atilde;o 
-    do mouse. Isso pode gerar uma confus&atilde;o pois a acelera&ccedil;&atilde;o 
-    do mouse pode ser ajustada diferentemente nas prefer&ecirc;ncias do Mac OS 
-    X e nas prefer&ecirc;ncias do X window. Por padr&atilde;o, o X11 n&atilde;o 
-    est&aacute; habilitado a mudar a acelera&ccedil;&atilde;o do mouse para evitar 
-    este problema.</li>
-  <li><b>Emula&ccedil;&atilde;o de Mouse de Multi-Bot&otilde;es: </b>Esta op&ccedil;&atilde;o 
-    est&aacute; escrita acima em <a href="#usage">Uso</a>. Quando a emula&ccedil;&atilde;o 
-    est&aacute; habilitada as teclas modificadoras selecionadas tem que estar 
-    pressionadas quando o bot&atilde;o do mouse for pressionado, para emular o 
-    segundo e terceiro bot&otilde;es.</li>
-</ul>
-<h3>Inicial</h3>
-<ul>
-  <li><b>Modo Padr&atilde;o: </b>Se o usu&aacute;rio n&atilde;o indicar qual modo 
-    de exibi&ccedil;&atilde;o quer usar (Tela Cheia ou Compartilhado) o modo especificado 
-    aqui ser&aacute; usado .</li>
-  <li><b>Mostrar o painel de escolha na inicializa&ccedil;&atilde;o: </b> Por 
-    padr&atilde;o, uma painel &eacute; mostrado quando o XDarwin &eacute; 
-    iniciado para permitir que o usu&aacute;rio escolha ente o modo tela cheia 
-    ou modo compartilhado. Se esta op&ccedil;&atilde;o estiver desligada, o modo 
-    padr&atilde;o ser&aacute; inicializado automaticamente.</li>
-  <li><b>N&uacute;mero do Monitor X11: </b>O X11 permite ser administrado em multiplos 
-    monitores por servidores X separados num mesmo computador. O usu&aacute;rio 
-    pode indicar o n&uacute;mero do monitor para o XDarwin usar se mais de um 
-    servidor X se estiver rodando simultaneamente.</li>
-  <li><b>Habilitar suporte a m&uacute;ltiplos monitores pelo Xinerama: </b>o XDarwin 
-    suporta m&uacute;ltiplos monitores com o Xinerama, que trata todos os monitores 
-    como parte de uma grande e retangular tela. Voc&ecirc; pode desabilitar o 
-    Xinerama com est&aacute; op&ccedil;&atilde;o, mas normalmente o XDarwin n&atilde;o 
-    controla m&uacute;ltiplos monitores corretamente sem est&aacute; op&ccedil;&atilde;o. 
-    Se voc&ecirc; s&oacute; tiver um monotor, Xinerama &eacute; automaticamente 
-    desabilitado. </li>
-  <li><b>Arquivo de Mapa de Teclado: </b> O mapa de teclado &eacute; lido na inicializa&ccedil;&atilde;o 
-    e traduzido para um mapa de teclado X11. Arquivos de mapa de teclado, est&atilde;o 
-    dispon&iacute;veis numa grande variedade de l&iacute;nguas e s&atilde;o encontradas 
-    em <code>/System/Library/Keyboards</code>.</li>
-  <li><b>Iniciando Clientes X11 primeiro: </b>Quando o XDrawin &eacute; inicializado 
-    pelo Finder, ele ir&aacute; rodar o <code>xinit</code> para abrir o controlador 
-    X window e outros clientes X. (Veja o manual "<code>man xinit</code>" para 
-    mais informa&ccedil;&otilde;es.) Antes do XDarwin rodar o <code>xinit</code> 
-    ele ir&aacute; adicionar espec&iacute;ficos diret&oacute;rios a seu path. 
-    Por padr&atilde;o somente o <code>/usr/X11R6/bin</code> &eacute; adicionado. 
-    separado por um ponto-e-v&iacute;rgula. Os clientes X s&atilde;o inicializados 
-    no shell padr&atilde;o do usu&aacute;rio e os arquivos de inicializa&ccedil;&atilde;o 
-    do shell ser&atilde;o lidos. Se desejado, um shell alternativo pode ser especificado.</li>
-</ul>
-<h3>Tela Cheia</h3>
-<ul>
-  <li><b>Bot&atilde;o de Combina&ccedil;&atilde;o de Teclas: </b> Clique no bot&atilde;o 
-    e pressione qualquer quantidade de teclas modificadoras seguidas por uma tecla 
-    padr&atilde;o para modificar a combina&ccedil;&atilde;o quando se quer mudar 
-    entre o Aqua e X11.</li>
-  <li><b>Clique no &Iacute;cone no Dock para mudar para o X11: </b>Habilitando 
-    esta op&ccedil;&atilde;o voc&ecirc; ir&aacute; ativar a mudan&ccedil;a para 
-    o X11 clicando no &iacute;cone do XDarwin no Dock. Em algumas vers&otilde;es 
-    do Mac OS X, mudando pelo clique no Dock pode causar o desaparecimento do 
-    cursor quando retornar ao Aqua.</li>
-  <li><b>Mostrar a Ajuda na inicializa&ccedil;&atilde;o: </b>Isto ir&aacute; mostrar 
-    uma tela introdut&oacute;ria quando o XDarwin for inicializado no modo Tela 
-    Cheia. </li>
-  <li><b>Profundidade de Cores em bits: </b> No modo Tela Cheia, a tela do X11 
-    pode usar uma profundiadde de cor diferente da usada no Aqua. Se a op&ccedil;&atilde;o 
-    &quot;Atual&quot; est&aacute; especificada, a profundidade usada pelo Aqua 
-    quando o XDarwin iniciar ser&aacute; a mesma. Al&eacute;m das op&ccedil;&otilde;es 
-    8, 15 ou 24 bits que podem ser especificadas.</li>
-</ul>
-
-<h2><a NAME="license">Licen&ccedil;a</a></h2>
-<p>A licen&ccedil;a 
-  principal n&oacute;s por XDarwin baseada na licen&ccedil;a tradicional MIT X11 
-  / X Consortium, que n&atilde;o imp&otilde;e nenhuma condi&ccedil;&atilde;o sobre 
-  modifica&ccedil;&otilde;es ou redistribui&ccedil;&atilde;o do c&oacute;digo-fonte 
-  ou dos bin&aacute;rios desde que o copyright/licen&ccedil;a sejam mantidos intactos. 
-  Para mais informa&ccedil;&otilde;es e not&iacute;cias adicionais de copyright/licensing 
-  em algumas se&ccedil;&atilde;o do c&oacute;digo, por favor refer to the source code.</p>
-<H3><A NAME="3"></A>Licen&ccedil;a do X Consortium</H3>
-<p>Copyright (C) 1996 X Consortium</p>
-<p>Permiss&otilde;es s&atilde;o em virtude garantidas, livre de mudan&ccedil;as, 
-  para qualquer pessoa que possua uma c&oacute;pia deste software e aos arquivos 
-  de documenta&ccedil;&atilde;o associada (o &quot;Software&quot;), para lidar 
-  com o software sem restri&ccedil;&otilde;es, incluindo limita&ccedil;&otilde;es 
-  dos direitos de uso, c&oacute;pia, modifica&ccedil;&atilde;o, inclus&atilde;o, 
-  publica&ccedil;&atilde;o, distribui&ccedil;&atilde;o, sub licen&ccedil;a, e/ou 
-  venda de c&oacute;pias deste Software, e permitir pessoas to whom o Software 
-  &eacute; fornecido para ser desta forma, verifique as seguintes condi&ccedil;&otilde;es:</p>
-<p>O nota de copyright abaixo e a permiss&atilde;o dever&atilde;o ser inclu&iacute;das 
-  em todas as c&oacute;pias ou substanciais por&ccedil;&otilde;es do Software.</p>
-<p>O SOFTWARE 'E PROVIDO &quot;COMO TAL&quot;, SEM GARANTIAS DE NENHUM TIPO, EXPLICITA 
-  OU IMPLICITA, INCLUINDO MAS N&Atilde;O LIMITADO NOS AVISOS DE COM&Eacute;RCIO, 
-  TAMANHO OU PARA PROPOSTAS PARTICULARES E N&Atilde;O INFRA&Ccedil;&Atilde;O. 
-  EM NENHUM ACONTECIMENTO O X CONSORTIUM SER&Aacute; RESPONSAV&Eacute;L POR NENHUMA 
-  RECLAMA&Ccedil;&Atilde;O, DANOS OU OUTRAS RESPONSABILIDADES, SE NUMA A&Ccedil;&Atilde;O 
-  DE CONTRATO, OU OUTRA COISA, SURGINDO DE, FORA DE OU EM CONEX&Atilde;O COM O 
-  SOFTWARE OU O USO OU OUTRO MODO DE LIDAR COM O SOFTWARE.</p>
-<p>Exceto o contido nesta nota, o nome do X Consortium n&atilde;o pode ser usado 
-  em propagandas ou outra forma de promo&ccedil;&atilde;o de vendas, uso ou outro 
-  modo de lidar com este Software sem ter recebido uma autoriza&ccedil;&atilde;o 
-  escrita pelo X Consortium.</p>
-<p>O Sistema X Window &eacute; marca registrada do X Consortium, Inc.</p>
-</body>
-</html>
-
diff --git a/hw/darwin/bundle/Spanish.lproj/Credits.rtf b/hw/darwin/bundle/Spanish.lproj/Credits.rtf
deleted file mode 100644
index 34408e7..0000000
--- a/hw/darwin/bundle/Spanish.lproj/Credits.rtf
+++ /dev/null
@@ -1,168 +0,0 @@
-{\rtf1\mac\ansicpg10000\cocoartf102
-{\fonttbl\f0\fswiss\fcharset77 Helvetica;\f1\fswiss\fcharset77 Helvetica-Bold;\f2\fswiss\fcharset77 Helvetica-Oblique;
-}
-{\colortbl;\red255\green255\blue255;}
-\vieww5160\viewh6300\viewkind0
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
-
-\f0\fs24 \cf0 This product includes software developed by The XFree86 Project, Inc  (http://www.xfree86.org/) and its contributors. The following people contributed to Darwin/Mac OS X support.\
-\
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-
-\f1\b \cf0 Contributors to Xorg Foundation Release:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Kaleb KEITHLEY\
-     
-\f2\i Working left and right Ctrl, Alt (Option), Meta (Command) and Shift keys.
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\f1\b \cf0 Contributors to XFree86 4.4:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 John Harper\
-     
-\f2\i Rootless acceleration and Apple-WM extension
-\f0\i0 \
-Torrey T. Lyons\
-     
-\f2\i Project Lead
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 Additional XonX Contributors to XFree86 4.3:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Fabr\'92cio Luis de Castro\
-     
-\f2\i Portuguese localization
-\f0\i0 \
-Michael Oland\
-     
-\f2\i New XDarwin icon
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 XonX Contributors to XFree86 4.2:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Rob Braun\
-     
-\f2\i Darwin x86 support
-\f0\i0 \
-Pablo Di Noto\
-
-\f2\i      Spanish localization
-\f0\i0 \
-Paul Edens\
-
-\f2\i      Dutch localization
-\f0\i0 \
-Kyunghwan Kim\
-
-\f2\i      Korean localization
-\f0\i0 \
-Mario Klebsch\
-     
-\f2\i Non-US keyboard support
-\f0\i0 \
-Torrey T. Lyons\
-     
-\f2\i Project Lead
-\f0\i0 \
-Andreas Monitzer\
-     
-\f2\i German localization
-\f0\i0 \
-Patrik Montgomery\
-
-\f2\i      Swedish localization
-\f0\i0 \
-Greg Parker\
-     
-\f2\i Rootless support
-\f0\i0 \
-Toshimitsu Tanaka\
-     
-\f2\i Japanese localization
-\f0\i0 \
-Olivier Verdier\
-
-\f2\i      French localization
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 Special Thanks:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Devin Poolman and Zero G Software, Inc.\
-
-\f2\i      Installer
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 XonX Team Members\
-Contributing to XFree86 4.1:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Rob Braun\
-     
-\f2\i Darwin x86 support
-\f0\i0 \
-Torrey T. Lyons\
-     
-\f2\i Project Lead
-\f0\i0 \
-Andreas Monitzer\
-     
-\f2\i Cocoa version of XDarwin front end
-\f0\i0 \
-Greg Parker\
-     
-\f2\i Original Quartz implementation
-\f0\i0 \
-Christoph Pfisterer\
-     
-\f2\i Dynamic shared libraries
-\f0\i0 \
-Toshimitsu Tanaka\
-     
-\f2\i Japanese localization
-\f0\i0 \
-\
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-
-\f1\b \cf0 Special Thanks:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Tiago Ribeiro\
-     
-\f2\i XDarwin icon
-\f0\i0 \
-\
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-
-\f1\b \cf0 History:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 John Carmack\
-     
-\f2\i Original XFree86 port to Mac OS X Server
-\f0\i0 \
-Dave Zarzycki\
-     
-\f2\i XFree86 4.0 port to Darwin 1.0
-\f0\i0 \
-Torrey T. Lyons\
-     
-\f2\i Integration into XFree86 Project for 4.0.2}
\ No newline at end of file
diff --git a/hw/darwin/bundle/Spanish.lproj/Localizable.strings b/hw/darwin/bundle/Spanish.lproj/Localizable.strings
deleted file mode 100644
index 5bf813f..0000000
Binary files a/hw/darwin/bundle/Spanish.lproj/Localizable.strings and /dev/null differ
diff --git a/hw/darwin/bundle/Spanish.lproj/MainMenu.nib/classes.nib b/hw/darwin/bundle/Spanish.lproj/MainMenu.nib/classes.nib
deleted file mode 100644
index 77f345a..0000000
--- a/hw/darwin/bundle/Spanish.lproj/MainMenu.nib/classes.nib
+++ /dev/null
@@ -1,72 +0,0 @@
-{
-    IBClasses = (
-        {
-            ACTIONS = {showHelp = id; }; 
-            CLASS = FirstResponder; 
-            LANGUAGE = ObjC; 
-            SUPERCLASS = NSObject; 
-        }, 
-        {
-            ACTIONS = {close = id; pickFile = id; saveChanges = id; setKey = id; }; 
-            CLASS = Preferences; 
-            LANGUAGE = ObjC; 
-            OUTLETS = {
-                addToPathButton = id; 
-                addToPathField = id; 
-                button2ModifiersMatrix = id; 
-                button3ModifiersMatrix = id; 
-                depthButton = id; 
-                displayField = id; 
-                dockSwitchButton = id; 
-                fakeButton = id; 
-                keymapFileField = id; 
-                modeMatrix = id; 
-                modeWindowButton = id; 
-                mouseAccelChangeButton = id; 
-                startupHelpButton = id; 
-                switchKeyButton = id; 
-                systemBeepButton = id; 
-                useDefaultShellMatrix = id; 
-                useOtherShellField = id; 
-                useXineramaButton = id; 
-                window = id; 
-            }; 
-            SUPERCLASS = NSObject; 
-        }, 
-        {
-            CLASS = XApplication; 
-            LANGUAGE = ObjC; 
-            OUTLETS = {preferences = id; xserver = id; }; 
-            SUPERCLASS = NSApplication; 
-        }, 
-        {
-            ACTIONS = {
-                bringAllToFront = id; 
-                closeHelpAndShow = id; 
-                itemSelected = id; 
-                nextWindow = id; 
-                previousWindow = id; 
-                showAction = id; 
-                showSwitchPanel = id; 
-                startFullScreen = id; 
-                startRootless = id; 
-            }; 
-            CLASS = XServer; 
-            LANGUAGE = ObjC; 
-            OUTLETS = {
-                dockMenu = NSMenu; 
-                helpWindow = NSWindow; 
-                modeWindow = NSWindow; 
-                startFullScreenButton = NSButton; 
-                startRootlessButton = NSButton; 
-                startupHelpButton = NSButton; 
-                startupModeButton = NSButton; 
-                switchWindow = NSPanel; 
-                windowMenu = NSMenu; 
-                windowSeparator = NSMenuItem; 
-            }; 
-            SUPERCLASS = NSObject; 
-        }
-    ); 
-    IBVersion = 1; 
-}
\ No newline at end of file
diff --git a/hw/darwin/bundle/Spanish.lproj/MainMenu.nib/objects.nib b/hw/darwin/bundle/Spanish.lproj/MainMenu.nib/objects.nib
deleted file mode 100644
index 2df75ee..0000000
Binary files a/hw/darwin/bundle/Spanish.lproj/MainMenu.nib/objects.nib and /dev/null differ
diff --git a/hw/darwin/bundle/Spanish.lproj/Makefile.am b/hw/darwin/bundle/Spanish.lproj/Makefile.am
deleted file mode 100644
index 978ac35..0000000
--- a/hw/darwin/bundle/Spanish.lproj/Makefile.am
+++ /dev/null
@@ -1,39 +0,0 @@
-BINDIR = ${bindir}
-include $(top_srcdir)/cpprules.in
-XINITDIR = $(libdir)/X11/xinit
-XDEFS = \
-        -DX_VERSION="$(PLIST_VERSION_STRING)" \
-        -DX_PRE_RELEASE="$(PRE)" \
-        -DX_REL_DATE="$(XORG_DATE)" \
-        -DX_VENDOR_NAME="$(VENDOR_STRING)" \
-        -DX_VENDOR_LINK="$(PLIST_VENDOR_WEB)"
-
-resourcesdir = @APPLE_APPLICATIONS_DIR@/XDarwin.app/Contents/Resources
-
-Spanishlprojdir = $(resourcesdir)/Spanish.lproj
-
-Spanishlproj_DATA = \
-		    XDarwinHelp.html \
-		    InfoPlist.strings \
-		    Credits.rtf Localizable.strings
-
-Spanishlprojnibdir = $(Spanishlprojdir)/MainMenu.nib
-Spanishlprojnib_DATA = \
-		       MainMenu.nib/classes.nib \
-		       MainMenu.nib/objects.nib
-
-InfoPlist.strings: $(srcdir)/../English.lproj/InfoPlist.strings.cpp
-	 $(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) | $(SED) -e's/__quote__/"/g' | iconv -t UTF-16 > $@
-
-XDarwinHelp.html: XDarwinHelp.html.cpp
-	$(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) > $@
-
-CLEANFILES = XDarwinHelp.html InfoPlist.strings 
-
-EXTRA_DIST = \
-	Credits.rtf Localizable.strings \
-	Localizable.strings \
-	MainMenu.nib/classes.nib \
-	MainMenu.nib/objects.nib \
-	XDarwinHelp.html.cpp
-
diff --git a/hw/darwin/bundle/Spanish.lproj/XDarwinHelp.html.cpp b/hw/darwin/bundle/Spanish.lproj/XDarwinHelp.html.cpp
deleted file mode 100644
index a79e6f9..0000000
--- a/hw/darwin/bundle/Spanish.lproj/XDarwinHelp.html.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-<html>
-<head>
-<title>XDarwin Ayuda</title>
-</head>
-<body>
-<center>
-    <h1>XDarwin X Server for Mac OS X</h1>
-    X_VENDOR_NAME X_VERSION<br>
-    Fecha de release: X_REL_DATE
-</center>
-<h2>Contenido</h2>
-<ol>
-    <li><A HREF="#notice">Aviso Importante</A></li>
-    <li><A HREF="#usage">Modo de uso</A></li>
-    <li><A HREF="#path">Configurando su Path</A></li>
-    <li><A HREF="#prefs">Preferencias del Usuario</A></li>
-    <li><A HREF="#license">Licencia</A></li>
-</ol>
-<center>
-    <h2><a NAME="notice">Aviso Importante</a></h2>
-</center>
-<blockquote>
-#if PRE_RELEASE
-Esta es una versi&oacuten pre-release de XDarwin, y no tiene ning&uacuten soporte. Patches y reportes de error pueden ser enviados a la <A HREF="http://sourceforge.net/projects/xonx/">p&aacutegina del proyecto XonX</A> en SourceForge.  Antes de reportar errores en versiones pre-release, por favor verifique la ultima versi&oacuten en <A HREF="http://sourceforge.net/projects/xonx/">XonX</A> o bien el X_VENDOR_LINK.
-#else
-Si el server el m&aacutes antiguo que 6 a 12 meses, o si su hardware es posterior a la fecha indicada m&aacutes arriba, por favor verifique la &uacuteltima versi&oacuten antes de reportar problemas. Patches y reportes de error pueden ser enviados a la <A HREF="http://sourceforge.net/projects/xonx/">p&aacutegina del proyecto XonX</A> en SourceForge.
-#endif
-</blockquote>
-<blockquote>
-Este software es distribuido bajo los t&eacuterminos de la <A HREF="#license">Licencia MIT X11 / X Consortium</A> y es provisto sin garant&iacutea alguna y en el estado en que se encuentra. Por favor lea la <A HREF="#license">Licencia</A> antes de utilizarlo.</blockquote>
-
-<h2><a NAME="usage">Modo de uso</a></h2>
-<p>XDarwin es una X server open-source de distribuci&oacuten libre del <a HREF
-="http://www.x.org/">X Window System</a>. This version of XDarwin was produced by the X_VENDOR_LINK. XDarwin funciona en Mac OS X en modo pantalla completa o en modo rootless (integrado al escritorio).</p>
-<p>En modo pantalla completa, el X window system toma control total de la pantalla mientras esta activo. Presionando Command-Option-A  puede regresar al Escritorio de Mac OS X. Esta combinaci&oacuten de teclas puede cambiarse en las Preferencias de Usuario. Desde el Escritorio de Mac OS X, haga click en &iacutecono de XDarwin en el Dock para volver al X window system.  (Puede cambiar esta comportamiento en las Preferencias de Usuario y configurar que XDarwin vuelva al X window system haciendo click en la ventana flotante con el logo X.)</p>
-<p>En modo rootless, el X window system comparte la pantalla con Aqua. La ventana root de X11 es del tama&ntildeo de la pantalla y contiene a todas las dem&aacutes ventanas. La ventana root de X11 no se muestra en este modo, ya que Aqua maneja el fondo de pantalla.</p>
-<h3>Emulaci&oacuten de mouse multi-bot&oacuten</h3>
-<p>Muchas aplicaciones X11 requieren del uso de un mouse de 3 botones. Es posible emular un mouse de 3 botones con un mouse de solo un bot&oacuten presionando teclas modificadoras mientras hace click. Esto es controlado en de la seccion "Emulaci&oacuten mouse" dentro de la secci&oacuten "General" de las Preferencias del Usuario. Por defecto, la emulaci&oacuten est&aacute activa y utiliza la tecla Command para simular el 2do bot&oacuten y la tecla Option para simlar el 3er bot&oacuten. La conbinaci&oacuten para simular el 2do y 3er bot&oacuten pueden ser modificada por cualquier combinaci&oacuten de teclas modificadoras dentro de las Preferencias del Usuario. Tenga en cuenta que aunque las teclas modificadoras hayan sido mapeadas a otras teclas con xmodmap, las teclas configuradas en las Preferencias del Usuario seguir&aacuten siendo las utilizadas por la emulaci&oacuten de mouse multi-bot&oacuten.</p>
-
-<h2><a NAME="path">Configurando su Path</a></h2>
-<p>El path es la lista de directorios donde se buscar&aacuten los comandos ejecutables. Los comandos de X11 se encuentran en  <code>/usr/X11R6/bin</code>, y &eacuteste necesita estar dentro de su path. XDarwin hace &eacutesto autom&aacuteticamente por defecto, y puede adem&aacutes agregar directorios adicionales donde tenga otros comandos de l&iacutenea.</p>
-<p>Usuarios experimentados pueden tener su path correctamente configurado mediante los archivos de inicio de su interprete de comandos.  En este caso, puede informarle a XDarwin en las Preferencias de Usuario para que no modifique su path. XDarwin arrancar&aacute los clientes X11 iniciales usando el int&eacuterprete de comandos del usuario, seg&uacuten su configuraci&oacuten de login. Un int&eacuterprete de comandos alternativo puede ser especificado en las Preferencias del Usuario. La manera de configurar el path de su int&eacuterprete de comandos depende de cual est&aacute usando, y es generalmente descripta en las p&aacuteginas man del mismo.</p>
-<p>Adem&aacutes, Ud. puede agregar las p&aacuteginas man de X11 a la lista de p&aacuteginas que son consultadas. Estas est&aacuten ubicadas en <code>/usr/X11R6/man</code> y <code>MANPATH</code> es la variable de entorno que contiene los directorios que son consultados.</p>
-
-<h2><a NAME="prefs">Preferencias del Usuario</a></h2>
-<p>Ciertas opciones pueden definirse dentro de "Preferencias...", en el men&uacute de XDarwin. Las opciones dentro de de "Inicio" no surtir&aacuten efecto hasta que la aplicaci&oacuten se reinicie. Las restantes opciones surten efecto inmediatamente. Las diferentes opciones se describen a continuaci&oacuten:</p>
-<h3>General</h3>
-<ul>
-    <li><b>Usar beep del sistema en X11:</b> Cuando esta opci&oacuten est&aacute activa, el sonido de alerta est&aacutendar de Mac OS X se usar&aacute como alerta de X11. Cuando est&aacute desactivada, un simple tono es utilizado (esta es la opci&oacuten por defecto).</li>
-    <li><b>Permitir que X11 cambie la aceleraci&oacuten del mouse:</b> En una implementaci&oacuten est&aacutendard de X11, el window manager puede cambiar la aceleraci&oacuten del mouse. Esto puede llevar a una gran confusi&oacuten si la aceleraci&oacuten es diferente en XDarwin y en Mac OS X. Por defecto, no se le permite a X11 alterar la aceleraci&oacuten para evitar este inconveniente.</li>
-    <li><b>Emulaci&oacuten de mouse multi-bot&oacuten:</b> Esta opci&oacuten es descripta m&aacutes arriba bajo <a HREF="#usage">Modo de Uso</a>. Cuando esta emulaci&oacuten est&aacute activa los modificadores seleccionados deben ser presionados cuando se hace click para emular el bot&oacuten 2 o el bot&oacuten 3.</li>
-</ul>
-<h3>Inicio</h3>
-<ul>
-    <li><b>Modo inicial:</b> Si el usuario no indica si desea utilizar la Pantalla Completa o el modo Rootless, el modo especificado aqu&iacute ser&aacute el usado.</li>
-    <li><b>Mostrar panel de selecci&oacuten al inicio:</b> Por defecto, un di&aacutelogo permite al usuario elegir entre Pantalla Completa o Rootless al inicio. Si esta opci&oacuten esta desactivada, XDarwin arrancar&aacute utilizando el modo por defecto sin consultar al usuario.</li>
-    <li><b>N&uacutemero de display X11:</b> X11 permite que existan m&uacuteltiples pantallas manejadas por servidores X11 separados funcionando en una misma computadora. El usuario puede especificar aqui un n&uacutemero entero para indicar el n&uacutemero de pantalla (display) que XDarwin utilizar&aacute si m&aacutes de un servidor X funciona en forma simult&aacutenea.</li>
-    <li><b>Habilitar soporte Xinerama para m&uacuteltipes monitores:</b> XDarwin suporta m&uacuteltiple monitores con Xinerama, que maneja todos los monitores como si fueran parte de una gran pantalla rectangular. Puede deshabilitar Xinerama con esta opci&oacuten, pero XDarwin no maneja m&uacuteltiples monitores en forma correcta sin esta opci&oacuten habilitada. Si tiene solo un monitor, Xinerama es autom&aacuteticamente deshabilitado.</li>
-    <li><b>Archivo de mapa de teclado:</b> Un archivo de mapa de teclas es le&iacutedo al inicio y es traducido a un keymap X11 (un archivo est&aacutendard de X11 para especificar la funci&oacuten de cada tecla). Estos archivos, disponibles para una amplia variedad de lenguajes, pueden encontrarse en  <code>/System/Library/Keyboards</code>.</li>
-    <li><b>Al iniciar clientes X11:</b> Cuando XDarwin arranca desde el Finder, &eacuteste ejecutar&aacute <code>xinit</code> para a su vez arrancar el window manager y otros clientes. (Vea en "<code>man xinit</code>" para mayor informaci&oacuten). Antes de ejecutar <code>xinit</code> XDarwin agregar&aacute los directorios especificados al path del usuario. Por defecto, solo <code>/usr/X11R6/bin</code> es agregado. Otros directorios adicionales puede agregarse separados por dos puntos (:). Los clientes X son ejecutados con el int&eacuterprete de comandos del usuario, por lo que los archivos de inicio de &eacuteste son le&iacutedos. Si se desea, un int&eacuterprete de comandos diferente puede ser especificado.</li>
-</ul>
-<h3>Pantalla Completa</h3>
-<ul>
-    <li><b>Bot&oacuten para definir combinaci&oacuten de teclas:</b> Haga click en este bot&oacuten y luego presione cualquier combinaci&oacuten de modificadores seguidos de una tecla convencional para definir que combinaci&oacuten usar&aacute para intercambiar entre X11 y Aqua.</li>
-    <li><b>Click en el &iacutecono del Dock cambia a X11:</b> Habilite esta opci&oacuten para volver a X11 al hacer click en &iacutecono de XDarwin en el Dock. En algunas versiones de Mac OS X, al volver haciendo click en el Dock puede causar al desaparci&oacuten del cursor al volver a Aqua.</li>
-    <li><b>Mostrar ayuda al inicio:</b> Esta opci&oacuten habilitada har&aacute que una pantalla inicial de introducci&oacuten aparezca cuando XDarwin es arrancado en modo Pantalla Completa.</li>
-    <li><b>Profundidad de color (bits):</b> En modo Pantalla Completa, el display X11 puede utilizar una profundidad de color diferente de la utilizada por Aqua. Si se especifica "Actual", la misma profundidad de color que Aqua utiliza ser&aacute adoptada por X11. Al contrario, puede especificar 8, 15, o 24 bits.</li>
-</ul>
-
-<h2><a NAME="license">Licencia</a></h2>
-La licencia principal de XDarwin es basada en la Licencia MIT X11 tradicional, que no impone condiciones a la modificaci&oacuten o redistribuci&oacuten del c&oacutedigo fuente o de archivos binarios m&aacutes all&aacute de requerir que los mensajes de Licencia y Copyright se mantengan intactos. Para mayor informaci&oacuten y para mensajes adicionales de Licencia y Copyright que cubren algunas secciones del c&oacutedigo fuente, por favor consulte the source code.
-<H3><A NAME="3"></A>Licencia del X Consortium</H3>
-<p>Copyright (C) 1996 X Consortium</p>
-<p>Se otorga aqui permiso, libre de costo, a toda persona que obtenga una copia de este Software y los archivos de documentaci&oacuten asociados (el "Software"),
-para utilizar el Software sin restricciones, incluyendo sin l&iacutemites los derechos de usar, copiar, modificar, integrar con otros productos, publicar, distribuir, sub-licenciar y/o comercializar copias del Software, y de permitir a las personas que lo reciben para hacer lo propio, sujeto a las siguientes condiciones:</p>
-<p>El mensaje de Copyright indicado m&aacutes arriba y este permiso ser&aacute inclu&iacutedo en todas las copias o porciones sustanciales del Software.</p>
-<p>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 X CONSORTIUM 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.</p>
-<p>Excepto lo indicado en este mensaje, el nombre del X Consortium no ser&aacute utilizado en propaganda o como medio de promoci&oacuten para la venta, utilizaci&oacuten u otros manejos de este Software sin previa autorizaci&oacuten escrita del X Consortium.</p>
-<p>X Window System es una marca registrada de X Consortium, Inc.</p>
-<H3><A NAME="3"></A>X Consortium License (English)</H3>
-<p>Copyright (C) 1996 X Consortium</p>
-<p>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:</p>
-<p>The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.</p>
-<p>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 X CONSORTIUM 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.</p>
-<p>Except as contained in this notice, the name of the X Consortium 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 X Consortium.</p>
-<p>X Window System is a trademark of X Consortium, Inc.</p>
-</body>
-</html>
diff --git a/hw/darwin/bundle/Swedish.lproj/Credits.rtf b/hw/darwin/bundle/Swedish.lproj/Credits.rtf
deleted file mode 100644
index 34408e7..0000000
--- a/hw/darwin/bundle/Swedish.lproj/Credits.rtf
+++ /dev/null
@@ -1,168 +0,0 @@
-{\rtf1\mac\ansicpg10000\cocoartf102
-{\fonttbl\f0\fswiss\fcharset77 Helvetica;\f1\fswiss\fcharset77 Helvetica-Bold;\f2\fswiss\fcharset77 Helvetica-Oblique;
-}
-{\colortbl;\red255\green255\blue255;}
-\vieww5160\viewh6300\viewkind0
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
-
-\f0\fs24 \cf0 This product includes software developed by The XFree86 Project, Inc  (http://www.xfree86.org/) and its contributors. The following people contributed to Darwin/Mac OS X support.\
-\
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-
-\f1\b \cf0 Contributors to Xorg Foundation Release:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Kaleb KEITHLEY\
-     
-\f2\i Working left and right Ctrl, Alt (Option), Meta (Command) and Shift keys.
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\f1\b \cf0 Contributors to XFree86 4.4:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 John Harper\
-     
-\f2\i Rootless acceleration and Apple-WM extension
-\f0\i0 \
-Torrey T. Lyons\
-     
-\f2\i Project Lead
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 Additional XonX Contributors to XFree86 4.3:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Fabr\'92cio Luis de Castro\
-     
-\f2\i Portuguese localization
-\f0\i0 \
-Michael Oland\
-     
-\f2\i New XDarwin icon
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 XonX Contributors to XFree86 4.2:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Rob Braun\
-     
-\f2\i Darwin x86 support
-\f0\i0 \
-Pablo Di Noto\
-
-\f2\i      Spanish localization
-\f0\i0 \
-Paul Edens\
-
-\f2\i      Dutch localization
-\f0\i0 \
-Kyunghwan Kim\
-
-\f2\i      Korean localization
-\f0\i0 \
-Mario Klebsch\
-     
-\f2\i Non-US keyboard support
-\f0\i0 \
-Torrey T. Lyons\
-     
-\f2\i Project Lead
-\f0\i0 \
-Andreas Monitzer\
-     
-\f2\i German localization
-\f0\i0 \
-Patrik Montgomery\
-
-\f2\i      Swedish localization
-\f0\i0 \
-Greg Parker\
-     
-\f2\i Rootless support
-\f0\i0 \
-Toshimitsu Tanaka\
-     
-\f2\i Japanese localization
-\f0\i0 \
-Olivier Verdier\
-
-\f2\i      French localization
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 Special Thanks:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Devin Poolman and Zero G Software, Inc.\
-
-\f2\i      Installer
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 XonX Team Members\
-Contributing to XFree86 4.1:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Rob Braun\
-     
-\f2\i Darwin x86 support
-\f0\i0 \
-Torrey T. Lyons\
-     
-\f2\i Project Lead
-\f0\i0 \
-Andreas Monitzer\
-     
-\f2\i Cocoa version of XDarwin front end
-\f0\i0 \
-Greg Parker\
-     
-\f2\i Original Quartz implementation
-\f0\i0 \
-Christoph Pfisterer\
-     
-\f2\i Dynamic shared libraries
-\f0\i0 \
-Toshimitsu Tanaka\
-     
-\f2\i Japanese localization
-\f0\i0 \
-\
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-
-\f1\b \cf0 Special Thanks:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Tiago Ribeiro\
-     
-\f2\i XDarwin icon
-\f0\i0 \
-\
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-
-\f1\b \cf0 History:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 John Carmack\
-     
-\f2\i Original XFree86 port to Mac OS X Server
-\f0\i0 \
-Dave Zarzycki\
-     
-\f2\i XFree86 4.0 port to Darwin 1.0
-\f0\i0 \
-Torrey T. Lyons\
-     
-\f2\i Integration into XFree86 Project for 4.0.2}
\ No newline at end of file
diff --git a/hw/darwin/bundle/Swedish.lproj/Localizable.strings b/hw/darwin/bundle/Swedish.lproj/Localizable.strings
deleted file mode 100644
index 9709e54..0000000
Binary files a/hw/darwin/bundle/Swedish.lproj/Localizable.strings and /dev/null differ
diff --git a/hw/darwin/bundle/Swedish.lproj/MainMenu.nib/classes.nib b/hw/darwin/bundle/Swedish.lproj/MainMenu.nib/classes.nib
deleted file mode 100644
index 77f345a..0000000
--- a/hw/darwin/bundle/Swedish.lproj/MainMenu.nib/classes.nib
+++ /dev/null
@@ -1,72 +0,0 @@
-{
-    IBClasses = (
-        {
-            ACTIONS = {showHelp = id; }; 
-            CLASS = FirstResponder; 
-            LANGUAGE = ObjC; 
-            SUPERCLASS = NSObject; 
-        }, 
-        {
-            ACTIONS = {close = id; pickFile = id; saveChanges = id; setKey = id; }; 
-            CLASS = Preferences; 
-            LANGUAGE = ObjC; 
-            OUTLETS = {
-                addToPathButton = id; 
-                addToPathField = id; 
-                button2ModifiersMatrix = id; 
-                button3ModifiersMatrix = id; 
-                depthButton = id; 
-                displayField = id; 
-                dockSwitchButton = id; 
-                fakeButton = id; 
-                keymapFileField = id; 
-                modeMatrix = id; 
-                modeWindowButton = id; 
-                mouseAccelChangeButton = id; 
-                startupHelpButton = id; 
-                switchKeyButton = id; 
-                systemBeepButton = id; 
-                useDefaultShellMatrix = id; 
-                useOtherShellField = id; 
-                useXineramaButton = id; 
-                window = id; 
-            }; 
-            SUPERCLASS = NSObject; 
-        }, 
-        {
-            CLASS = XApplication; 
-            LANGUAGE = ObjC; 
-            OUTLETS = {preferences = id; xserver = id; }; 
-            SUPERCLASS = NSApplication; 
-        }, 
-        {
-            ACTIONS = {
-                bringAllToFront = id; 
-                closeHelpAndShow = id; 
-                itemSelected = id; 
-                nextWindow = id; 
-                previousWindow = id; 
-                showAction = id; 
-                showSwitchPanel = id; 
-                startFullScreen = id; 
-                startRootless = id; 
-            }; 
-            CLASS = XServer; 
-            LANGUAGE = ObjC; 
-            OUTLETS = {
-                dockMenu = NSMenu; 
-                helpWindow = NSWindow; 
-                modeWindow = NSWindow; 
-                startFullScreenButton = NSButton; 
-                startRootlessButton = NSButton; 
-                startupHelpButton = NSButton; 
-                startupModeButton = NSButton; 
-                switchWindow = NSPanel; 
-                windowMenu = NSMenu; 
-                windowSeparator = NSMenuItem; 
-            }; 
-            SUPERCLASS = NSObject; 
-        }
-    ); 
-    IBVersion = 1; 
-}
\ No newline at end of file
diff --git a/hw/darwin/bundle/Swedish.lproj/MainMenu.nib/objects.nib b/hw/darwin/bundle/Swedish.lproj/MainMenu.nib/objects.nib
deleted file mode 100644
index 3157d72..0000000
Binary files a/hw/darwin/bundle/Swedish.lproj/MainMenu.nib/objects.nib and /dev/null differ
diff --git a/hw/darwin/bundle/Swedish.lproj/Makefile.am b/hw/darwin/bundle/Swedish.lproj/Makefile.am
deleted file mode 100644
index 3cf542c..0000000
--- a/hw/darwin/bundle/Swedish.lproj/Makefile.am
+++ /dev/null
@@ -1,39 +0,0 @@
-BINDIR = ${bindir}
-include $(top_srcdir)/cpprules.in
-XINITDIR = $(libdir)/X11/xinit
-XDEFS = \
-        -DX_VERSION="$(PLIST_VERSION_STRING)" \
-        -DX_PRE_RELEASE="$(PRE)" \
-        -DX_REL_DATE="$(XORG_DATE)" \
-        -DX_VENDOR_NAME="$(VENDOR_STRING)" \
-        -DX_VENDOR_LINK="$(PLIST_VENDOR_WEB)"
-
-resourcesdir = @APPLE_APPLICATIONS_DIR@/XDarwin.app/Contents/Resources
-
-Swedishlprojdir = $(resourcesdir)/Swedish.lproj
-
-Swedishlproj_DATA = \
-		    XDarwinHelp.html \
-		    InfoPlist.strings \
-		    Credits.rtf Localizable.strings
-
-Swedishlprojnibdir = $(Swedishlprojdir)/MainMenu.nib
-Swedishlprojnib_DATA = \
-		       MainMenu.nib/classes.nib \
-		       MainMenu.nib/objects.nib
-
-InfoPlist.strings: $(srcdir)/../English.lproj/InfoPlist.strings.cpp
-	 $(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) | $(SED) -e's/__quote__/"/g' | iconv -t UTF-16 > $@
-
-XDarwinHelp.html: XDarwinHelp.html.cpp
-	$(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) > $@
-
-CLEANFILES = XDarwinHelp.html InfoPlist.strings 
-
-EXTRA_DIST = \
-	Credits.rtf Localizable.strings \
-	Localizable.strings \
-	MainMenu.nib/classes.nib \
-	MainMenu.nib/objects.nib \
-	XDarwinHelp.html.cpp
-
diff --git a/hw/darwin/bundle/Swedish.lproj/XDarwinHelp.html.cpp b/hw/darwin/bundle/Swedish.lproj/XDarwinHelp.html.cpp
deleted file mode 100644
index ab940ec..0000000
--- a/hw/darwin/bundle/Swedish.lproj/XDarwinHelp.html.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-<html>
-<head>
-<title>XDarwin Help</title>
-</head>
-<body>
-<center>
-    <h1>XDarwin X Server for Mac OS X</h1>
-    X_VENDOR_NAME X_VERSION<br>
-    F&auml;rdigst&auml;llt: X_REL_DATE
-</center>
-<h2>Inneh&aring;ll</h2>
-<ol>
-    <li><A HREF="#notice">Viktigt!</A></li>
-    <li><A HREF="#usage">Anv&auml;ndande</A></li>
-    <li><A HREF="#path">Att st&auml;lla in sin s&ouml;kv&auml;g</A></li>
-    <li><A HREF="#prefs">Inst&auml;llningar</A></li>
-    <li><A HREF="#license">Licens</A></li>
-</ol>
-<center>
-    <h2><a NAME="notice">Viktigt!</a></h2>
-</center>
-<blockquote>
-#if PRE_RELEASE
-Detta &auml;r en testversion av XDarwin, och du kan inte garranteras n&aring;gon som helst support f&ouml;r den. Buggar och fel kan rapporteras och f&ouml;rslag till fixar kan skickas till <A HREF="http://sourceforge.net/projects/xonx/">XonX-projektets sida</A> p&aring; SourceForge.  Innan du rapporterar buggar i testversioner, var god pr&ouml;va den senaste versionen fr&aring;n <A HREF="http://sourceforge.net/projects/xonx/">XonX</A> eller i X_VENDOR_LINK.
-#else
-Om servern &auml;r &auml;ldre &auml;n 6-12 m&aring;nader, eller om din h&aring;rdvara &auml;r nyare &auml;n datumet ovan, leta efter en nyare version innan du rapporterar fel. Buggar och fel kan rapporteras och f&ouml;rslag till fixar kan skickas till <A HREF="http://sourceforge.net/projects/xonx/">XonX-projektets sida</A> p&aring; SourceForge.
-#endif
-</blockquote>
-<blockquote>
-Denna programvara distrubueras i enlighet med <A HREF="#license">MIT X11 / X Consortium License</A> och tilhandh&aring;lls som den &auml;r, helt utan garantier. Var god l&auml;s igenom <A HREF="#license">licensdokumentet (engelska)</A> innan du anv&auml;nder programmet.</blockquote>
-
-<h2><a NAME="usage">Anv&auml;ndande</a></h2>
-<p>XDarwin &auml;r en fritt spridd X server av <a HREF
-="http://www.x.org/">X Window-systemet</a>. This version of XDarwin was produced by the X_VENDOR_LINK. XDarwin kan k&ouml;ras p&aring; Mac OS X i fullsk&auml;rmsl&auml;ge eller rotl&ouml;st l&auml;ge.</p>
-<p>I fullsk&auml;rmsl&auml;ge kommer X window-systemet att ta &ouml;ver hela sk&auml;rmen n&auml;r det &auml;r aktivt. Du kan byta tillbaka till Mac OS Xs skrivbord genom att trycka Kommando-Alt-A. Denna tangentkombination kan &auml;ndra i inst&auml;llningarna. N&auml;r du &auml;r p&aring; Mac OS Xs skrivbord kan du klicka p&aring; XDarwin-ikonen i dockan f&ouml;r att byta tillbaka till X Window-systemet. (Du kan f&ouml;r&auml;ndra detta beteende i inst&auml;llningarna s&aring; att du ist&auml;llet m&aring;ste klicka i det fltande bytesf&ouml;nstret ist&auml;llet.)</p>
-<p>I rotl&ouml;stl&auml;ge delar X11 och Aqua p&aring; din sk&auml;rm. Rotf&ouml;nstret p&aring; X11-sk&auml;rmen &auml;r av samma storlek som hela sk&auml;rmen och inneh&aring;ller alla andra f&ouml;nster - det fungerar som bakgrund. I rotl&ouml;stl&auml;ge visas inte detta rotf&ouml;nster, eftersom Aqua hanterar skrvbordbakgrunden.</p>
-
-<h3>Emulering av flerknapparsmus</h3>
-<p>M&aring;nga X11-program utnyttjar en treknapparsmus. Du kan emulera en treknapparsmus med en knapp genom att h&aring;lla ner olika knappar p&aring; tangentbordet medan du klickar med musens enda knapp. Denna funktion styrs av inst&auml;llningarna i  "Emulera flerknapparsmus" under fliken "Diverse" i inst&auml;llningarna. Grundinst&auml;llningen &auml;r att emulationen &auml;r aktiv  och att ett kommando-klick (H&aring;ll ner kommando och klicka) simulerar den andra musknappen. Den tredje musknappen f&aring;s genom att h&aring;lla ner alt och klicka. Du kan &auml;ndra detta till n&aring;gon annan kombination av de fem tangenterna kommando, alt, kontrol, skift och fn (Powerbook/iBook). Notera att om dessa knappar har flyttats med hj&auml;lp av kommandot xmodmap kommer denna f&ouml;r&auml;ndring inte att p&aring;verka vilka knappar som anv&auml;nds vid flerknappsemulationen.</p>
-
-<h2><a NAME="path">Att st&auml;lla in sin s&ouml;kv&auml;g</a></h2>
-<p>Din s&ouml;kv&auml;g &auml;r en lista av kataloger som s&ouml;ks igenom n&auml;r terminalen letar efter kommandon att exekvera. Kommandon som h&ouml;r till X11 ligger i <code>/usr/X11R6/bin</code>, en katalog som inte ligger i din s&ouml;kv&auml;g fr&aring;n b&ouml;rjan. XDarwin l&auml;gger till denna katalog &aring;t dig, och du kan ocks&aring; l&auml;gga till ytterligare kataloger i vilka du lagt program som skall k&ouml;ras fr&aring;n kommandoraden.</p>
-<p>Mer erfarna anv&auml;ndare har antagligen redan st&auml;llt in sin s&ouml;kv&auml;g i skalets inst&auml;llningsfiler. Om detta g&auml;ller dig  kan st&auml;lla in XDarwin s&aring; att din s&ouml;kv&auml;g inte modifieras. XDarwin startar de f&ouml;rsta X11-klienterna i anv&auml;ndarens inloggningsskal (Vill du anv&auml;nda ett alternativt skall, kan du specificera detta i inst&auml;llningarna). Hur du st&auml;ller in din s&ouml;kv&auml;g beror p&aring; vilket skal du anv&auml;nder. Exakt hur beskrivs i skalets man-sidor.</p>
-
-<p>Ut&ouml;ver detta kan du ocks&aring; vilja l&auml;gga till X11s man-sidor (dokumentation) till listan &auml;ver sidor som som skall s&ouml;kas n&auml;r du vill l&auml;sa efter dokumentationen. X11s man-sidor ligger i <code>/usr/X11R6/man</code> och listan &auml;ver kataloger att s&ouml;ka best&auml;mms av variabeln<code>MANPATH</code>.</p>
-
-<h2><a NAME="prefs">Inst&auml;llningar</a></h2>
-<p>I inst&auml;llningarna finns ett antal alternativ d&auml;r du kan p&aring;verka hur XDarwin beter sig i vissa fall. Inst&auml;llningarna kommer du till genom att v&auml;lja "Inst&auml;llningar..." i menyn "XDarwin". De alternativ som finns under fliken "Starta" tr&auml;der inte i kraft f&ouml;rr&auml;n du startat om programmet. Alla andra alternativ tr&auml;der i kraft omedelbart. De olika alternativen beskrivs nedan:</p>
-<h3>Diverse</h3>
-<ul>
-    <li><b>Anv&auml;nd Mac OS varningsljud i X11:</b> N&auml;r detta alternativ &auml;r valt anv&auml;nds Mac OS vanliga varningsljud &auml;r X11s varningsljud (bell). N&auml;r detta alternativ inte &auml;r valt (f&ouml;rvalt) anv&auml;nds en vanlig ton.</li>
-    <li><b>Till&aring;t X11 att &auml;ndra musens acceleration:</b> I ett vanligt X11-system kan f&ouml;nsterhanteraren &auml;ndra musens acceleration. Detta kan vara f&ouml;rvirrande eftersom musens acceleration kan vara olika i Mac OS Xs System Preferences och i f&ouml;nsterhanteraren i X11. F&ouml;rvalet &auml;r att X11 inte kan &auml;ndra musens acceleration f&ouml;r att p&aring; detta s&auml;tt undvika detta problem.</li>
-    <li><b>Emulera flerknapparsmus:</b> Detta beskrivs ovan under <a HREF="#usage">Anv&auml;ndande</a>. N&auml;r emulationen &auml;r aktiv m&aring;ste du h&aring;lla ner de valda knapparna f&ouml;r att emulera en andra eller tredje musknapp.</li>
-</ul>
-<h3>Starta</h3>
-<ul>
-    <li><b>F&ouml;rvalt l&auml;ge:</b> Om anv&auml;ndaren inte p&aring; annat s&auml;tt v&auml;ljer vilket l&auml;ge som skall anv&auml;ndas kommer alternativet h&auml;r att anv&auml;ndas.</li>
-    <li><b>Visa val av sk&auml;rml&auml;ge vid start:</b> F&ouml;rvalet &auml;r att visa ett f&ouml;nster n&auml;r XDarwin startar som l&aring;ter anv&auml;ndaren v&auml;lja mellan fullsk&auml;rmsl&auml;ge och rotl&ouml;st l&auml;ge. Om detta alternativ inte &auml;r aktivt kommer XDarwin automatiskt att startas i det l&auml;ge som valts ovan.</li>
-    <li><b>Sk&auml;rmnummer i X11:</b> X11 till&aring;ter att det finns flera sk&auml;rmar styrda av varsin X-server p&aring; en och samma dator. Anv&auml;ndaren kan ange vilket nummer XDarwin skall anv&auml;nda om mer &auml;n en X-server skall anv&auml;ndas samtidigt.</li>
-    <li><b>Aktivera Xinerama (st&ouml;d f&ouml;r flera sk&auml;rmar):</b> XDarwin st&ouml;djer flera sk&auml;rmar genom Xinerama, vilket hanterar alla skr&auml;mar som delar av en enda stor rektangul&auml;r sk&auml;rm. Du kan anv&auml;nda detta alternativ f&ouml;r att st&auml;nga av Xinerama, men f&ouml;r n&auml;rvarande kan inte XDarwin hantera flera sk&auml;rmar utan det. Om du bara har en sk&auml;rm kommer Xinerama automatiskt att deaktiveras.</li>
-    <li><b>Fil med tangentbordsupps&auml;ttning:</b> En fil som anger tangentbordsupps&auml;ttning l&auml;ses vid start och &ouml;vers&auml;tts till en tangentborsupps&auml;ttningsfil f&ouml;r X11. Filer med tangentbordsupps&auml;ttningar f&ouml;r ett stort antal spr&aring;k finns i <code>/System/Library/Keyboards</code>.</li>
-    <li><b>Startar f&ouml;rsta X11-klienterna:</b> N&auml;r X11 startas fr&aring;n Finder kommer det att exekvera filen <code>xinit</code> f&ouml;r att starta f&ouml;nsterhanteraren i X11 och andra program. (Se "<code>man xinit</code>" f&ouml;r mer information.) Innan XDarwin k&ouml;r xinit kommer det att l&auml;gga till katalogern h&auml;r till anv&auml;ndarens s&ouml;kv&auml;g. F&ouml;rvalet &auml;r att endast l&auml;gga till katalogen <code>/usr/X11R6/bin</code>. Ytterligare kataloger kan l&auml;ggas till - separera dem med kolon. X11-klienterna startas i anv&auml;ndarens inloggningsskal s&aring; att anv&auml;ndarens inst&auml;llningsfiler i skalet l&auml;ses. Om s&aring; &ouml;nskas kan de startas i ett annat skal.</li>
-</ul>
-<h3>Fullsk&auml;rm</h3>
-<ul>
-    <li><b>Tangentkombinationsknappen:</b> Tryck p&aring; denna knapp och en tangentkombination f&ouml;r att &auml;ndra den tangentkombination som anv&auml;nds f&ouml;r att byta mellan X11 och Aqua.</li>
-    <li><b>Klick p&aring; ikonen i dockan byter till X11:</b> Aktivera detta alternativ f&ouml;r att byta till X11 genom att klicka p&aring; ikonen i dockan. I vissa versioner av Mac OS X kommer ett bte p&aring; detta s&auml;tt att g&ouml;mma pekaren n&auml;r du &aring;terv&auml;nder till Aqua.</li>
-    <li><b>Visa fullsk&auml;rmshj&auml;lp vid start:</b> Detta kommer att visa en informationsruta n&auml;r XDarwin startas i fullsk&auml;rmsl&auml;ge.</li>
-    <li><b>F&auml;rgdjup:</b> I fullsk&auml;rmsl&auml;ge kan X11 anv&auml;nda ett annat f&auml;rgdjup &auml;n Aquas. Om du v&auml;jer "Nuvarande" kommer X11 att anv&auml;nda det f&auml;rgdjup som Aqua har just d&aring;.  Annars kan du v&auml;lja 8, 15, eller 24 bitare f&auml;rg.</li>
-</ul>
-
-<h2><a NAME="license">Licens (svenska)</a></h2>
-<p>Den huvudsakliga licens vi anv&auml;nder oss av &auml;r baserad p&aring; den traditionella MIT X11 / XConsortium-licensen, vilken inte p&aring; n&aring;got s&auml;tt begr&auml;nsar f&ouml;r&auml;ndringar eller vidarespridning av vare sig k&auml;llkod eller kompilerad programvara annat &auml;n genom att kr&auml;va att delarna som r&ouml;r copyright och licensiering l&auml;mnas intakta. F&ouml;r mer information och ytterligare copyright/licensieringsinfromation r&ouml;rande vissa speciella delar av koden, se the source code.</p>
-
-<h3>Licence (english)</h3>
-<p>The main license for XDarwin is based on the traditional MIT X11 / X Consortium License, which does not impose any conditions on modification or redistribution of source code or binaries other than requiring that copyright/license notices are left intact. For more information and additional copyright/licensing notices covering some sections of the code, please refer to the source code.</p>
-
-<H3><A NAME="3"></A>X Consortium License</H3>
-<p>Copyright (C) 1996 X Consortium</p>
-<p>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:</p>
-<p>The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.</p>
-<p>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 X CONSORTIUM 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.</p>
-<p>Except as contained in this notice, the name of the X Consortium 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 X Consortium.</p>
-<p>X Window System is a trademark of X Consortium, Inc.</p>
-</body>
-</html>
diff --git a/hw/darwin/bundle/XDarwin.icns b/hw/darwin/bundle/XDarwin.icns
deleted file mode 100644
index 9c56084..0000000
Binary files a/hw/darwin/bundle/XDarwin.icns and /dev/null differ
diff --git a/hw/darwin/bundle/ko.lproj/Credits.rtf b/hw/darwin/bundle/ko.lproj/Credits.rtf
deleted file mode 100644
index 34408e7..0000000
--- a/hw/darwin/bundle/ko.lproj/Credits.rtf
+++ /dev/null
@@ -1,168 +0,0 @@
-{\rtf1\mac\ansicpg10000\cocoartf102
-{\fonttbl\f0\fswiss\fcharset77 Helvetica;\f1\fswiss\fcharset77 Helvetica-Bold;\f2\fswiss\fcharset77 Helvetica-Oblique;
-}
-{\colortbl;\red255\green255\blue255;}
-\vieww5160\viewh6300\viewkind0
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
-
-\f0\fs24 \cf0 This product includes software developed by The XFree86 Project, Inc  (http://www.xfree86.org/) and its contributors. The following people contributed to Darwin/Mac OS X support.\
-\
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-
-\f1\b \cf0 Contributors to Xorg Foundation Release:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Kaleb KEITHLEY\
-     
-\f2\i Working left and right Ctrl, Alt (Option), Meta (Command) and Shift keys.
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\f1\b \cf0 Contributors to XFree86 4.4:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 John Harper\
-     
-\f2\i Rootless acceleration and Apple-WM extension
-\f0\i0 \
-Torrey T. Lyons\
-     
-\f2\i Project Lead
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 Additional XonX Contributors to XFree86 4.3:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Fabr\'92cio Luis de Castro\
-     
-\f2\i Portuguese localization
-\f0\i0 \
-Michael Oland\
-     
-\f2\i New XDarwin icon
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 XonX Contributors to XFree86 4.2:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Rob Braun\
-     
-\f2\i Darwin x86 support
-\f0\i0 \
-Pablo Di Noto\
-
-\f2\i      Spanish localization
-\f0\i0 \
-Paul Edens\
-
-\f2\i      Dutch localization
-\f0\i0 \
-Kyunghwan Kim\
-
-\f2\i      Korean localization
-\f0\i0 \
-Mario Klebsch\
-     
-\f2\i Non-US keyboard support
-\f0\i0 \
-Torrey T. Lyons\
-     
-\f2\i Project Lead
-\f0\i0 \
-Andreas Monitzer\
-     
-\f2\i German localization
-\f0\i0 \
-Patrik Montgomery\
-
-\f2\i      Swedish localization
-\f0\i0 \
-Greg Parker\
-     
-\f2\i Rootless support
-\f0\i0 \
-Toshimitsu Tanaka\
-     
-\f2\i Japanese localization
-\f0\i0 \
-Olivier Verdier\
-
-\f2\i      French localization
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 Special Thanks:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Devin Poolman and Zero G Software, Inc.\
-
-\f2\i      Installer
-\f0\i0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-
-\f1\b \cf0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-\cf0 XonX Team Members\
-Contributing to XFree86 4.1:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Rob Braun\
-     
-\f2\i Darwin x86 support
-\f0\i0 \
-Torrey T. Lyons\
-     
-\f2\i Project Lead
-\f0\i0 \
-Andreas Monitzer\
-     
-\f2\i Cocoa version of XDarwin front end
-\f0\i0 \
-Greg Parker\
-     
-\f2\i Original Quartz implementation
-\f0\i0 \
-Christoph Pfisterer\
-     
-\f2\i Dynamic shared libraries
-\f0\i0 \
-Toshimitsu Tanaka\
-     
-\f2\i Japanese localization
-\f0\i0 \
-\
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-
-\f1\b \cf0 Special Thanks:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 Tiago Ribeiro\
-     
-\f2\i XDarwin icon
-\f0\i0 \
-\
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
-
-\f1\b \cf0 History:
-\f0\b0 \
-\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
-\cf0 John Carmack\
-     
-\f2\i Original XFree86 port to Mac OS X Server
-\f0\i0 \
-Dave Zarzycki\
-     
-\f2\i XFree86 4.0 port to Darwin 1.0
-\f0\i0 \
-Torrey T. Lyons\
-     
-\f2\i Integration into XFree86 Project for 4.0.2}
\ No newline at end of file
diff --git a/hw/darwin/bundle/ko.lproj/Localizable.strings b/hw/darwin/bundle/ko.lproj/Localizable.strings
deleted file mode 100644
index fb8c77e..0000000
Binary files a/hw/darwin/bundle/ko.lproj/Localizable.strings and /dev/null differ
diff --git a/hw/darwin/bundle/ko.lproj/MainMenu.nib/classes.nib b/hw/darwin/bundle/ko.lproj/MainMenu.nib/classes.nib
deleted file mode 100644
index 77f345a..0000000
--- a/hw/darwin/bundle/ko.lproj/MainMenu.nib/classes.nib
+++ /dev/null
@@ -1,72 +0,0 @@
-{
-    IBClasses = (
-        {
-            ACTIONS = {showHelp = id; }; 
-            CLASS = FirstResponder; 
-            LANGUAGE = ObjC; 
-            SUPERCLASS = NSObject; 
-        }, 
-        {
-            ACTIONS = {close = id; pickFile = id; saveChanges = id; setKey = id; }; 
-            CLASS = Preferences; 
-            LANGUAGE = ObjC; 
-            OUTLETS = {
-                addToPathButton = id; 
-                addToPathField = id; 
-                button2ModifiersMatrix = id; 
-                button3ModifiersMatrix = id; 
-                depthButton = id; 
-                displayField = id; 
-                dockSwitchButton = id; 
-                fakeButton = id; 
-                keymapFileField = id; 
-                modeMatrix = id; 
-                modeWindowButton = id; 
-                mouseAccelChangeButton = id; 
-                startupHelpButton = id; 
-                switchKeyButton = id; 
-                systemBeepButton = id; 
-                useDefaultShellMatrix = id; 
-                useOtherShellField = id; 
-                useXineramaButton = id; 
-                window = id; 
-            }; 
-            SUPERCLASS = NSObject; 
-        }, 
-        {
-            CLASS = XApplication; 
-            LANGUAGE = ObjC; 
-            OUTLETS = {preferences = id; xserver = id; }; 
-            SUPERCLASS = NSApplication; 
-        }, 
-        {
-            ACTIONS = {
-                bringAllToFront = id; 
-                closeHelpAndShow = id; 
-                itemSelected = id; 
-                nextWindow = id; 
-                previousWindow = id; 
-                showAction = id; 
-                showSwitchPanel = id; 
-                startFullScreen = id; 
-                startRootless = id; 
-            }; 
-            CLASS = XServer; 
-            LANGUAGE = ObjC; 
-            OUTLETS = {
-                dockMenu = NSMenu; 
-                helpWindow = NSWindow; 
-                modeWindow = NSWindow; 
-                startFullScreenButton = NSButton; 
-                startRootlessButton = NSButton; 
-                startupHelpButton = NSButton; 
-                startupModeButton = NSButton; 
-                switchWindow = NSPanel; 
-                windowMenu = NSMenu; 
-                windowSeparator = NSMenuItem; 
-            }; 
-            SUPERCLASS = NSObject; 
-        }
-    ); 
-    IBVersion = 1; 
-}
\ No newline at end of file
diff --git a/hw/darwin/bundle/ko.lproj/MainMenu.nib/objects.nib b/hw/darwin/bundle/ko.lproj/MainMenu.nib/objects.nib
deleted file mode 100644
index 8f9b5e0..0000000
Binary files a/hw/darwin/bundle/ko.lproj/MainMenu.nib/objects.nib and /dev/null differ
diff --git a/hw/darwin/bundle/ko.lproj/Makefile.am b/hw/darwin/bundle/ko.lproj/Makefile.am
deleted file mode 100644
index a5462ff..0000000
--- a/hw/darwin/bundle/ko.lproj/Makefile.am
+++ /dev/null
@@ -1,40 +0,0 @@
-BINDIR = ${bindir}
-include $(top_srcdir)/cpprules.in
-XINITDIR = $(libdir)/X11/xinit
-XDEFS = \
-        -DX_VERSION="$(PLIST_VERSION_STRING)" \
-        -DX_PRE_RELEASE="$(PRE)" \
-        -DX_REL_DATE="$(XORG_DATE)" \
-        -DX_VENDOR_NAME="$(VENDOR_STRING)" \
-        -DX_VENDOR_LINK="$(PLIST_VENDOR_WEB)"
-
-
-resourcesdir = @APPLE_APPLICATIONS_DIR@/XDarwin.app/Contents/Resources
-
-kolprojdir = $(resourcesdir)/ko.lproj
-
-kolproj_DATA = \
-		    XDarwinHelp.html \
-		    InfoPlist.strings \
-		    Credits.rtf Localizable.strings
-
-kolprojnibdir = $(kolprojdir)/MainMenu.nib
-kolprojnib_DATA = \
-		       MainMenu.nib/classes.nib \
-		       MainMenu.nib/objects.nib
-
-InfoPlist.strings: $(srcdir)/../English.lproj/InfoPlist.strings.cpp
-	 $(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) | $(SED) -e's/__quote__/"/g' | iconv -t UTF-16 > $@
-
-XDarwinHelp.html: XDarwinHelp.html.cpp
-	$(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) > $@
-
-CLEANFILES = XDarwinHelp.html InfoPlist.strings 
-
-EXTRA_DIST = \
-	Credits.rtf Localizable.strings \
-	Localizable.strings \
-	MainMenu.nib/classes.nib \
-	MainMenu.nib/objects.nib \
-	XDarwinHelp.html.cpp
-
diff --git a/hw/darwin/bundle/ko.lproj/XDarwinHelp.html.cpp b/hw/darwin/bundle/ko.lproj/XDarwinHelp.html.cpp
deleted file mode 100644
index db33670..0000000
--- a/hw/darwin/bundle/ko.lproj/XDarwinHelp.html.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-<html>
-<head>
-<title>XDarwin Help</title>
-</head>
-<body>
-<center>
-    <h1>XDarwin X Server for Mac OS X</h1>
-    X_VENDOR_NAME X_VERSION<br>
-    Release Date: X_REL_DATE
-</center>
-<h2>Contents</h2>
-<ol>
-    <li><A HREF="#notice">Important Notice</A></li>
-    <li><A HREF="#usage">Usage</A></li>
-    <li><A HREF="#path">Setting Your Path</A></li>
-    <li><A HREF="#prefs">User Preferences</A></li>
-    <li><A HREF="#license">License</A></li>
-</ol>
-<center>
-    <h2><a NAME="notice">Important Notice</a></h2>
-</center>
-<blockquote>
-#if X_PRE_RELEASE
-This is a pre-release version of XDarwin, and is not supported in any way. Bugs may be reported and patches may be submitted to the <A HREF="http://sourceforge.net/projects/xonx/">XonX project page</A> at SourceForge.  Before reporting bugs in pre-release versions, please check the latest version from <A HREF="http://sourceforge.net/projects/xonx/">XonX</A> or the X_VENDOR_LINK.
-#else
-If the server is older than 6-12 months, or if your hardware is newer than the above date, look for a newer version before reporting problems. Bugs may be reported and patches may be submitted to the <A HREF="http://sourceforge.net/projects/xonx/">XonX project page</A> at SourceForge.
-#endif
-</blockquote>
-<blockquote>
-This software is distributed under the terms of the <A HREF="#license">MIT X11 / X Consortium License</A> and is provided AS IS, with no warranty. Please read the <A HREF="#license">License</A> before using.</blockquote>
-
-<h2><a NAME="usage">Usage</a></h2>
-<p>XDarwin is a freely redistributable open-source X server for the <a HREF="http://www.x.org/">X Window System</a>. This version of XDarwin was produced by the X_VENDOR_LINK. XDarwin runs on Mac OS X in full screen or rootless modes.</p>
-<p>In full screen mode, when the X window system is active, it takes over the entire screen. You can switch back to the Mac OS X desktop by holding down Command-Option-A. This key combination can be changed in the user preferences. From the Mac OS X desktop, click on the XDarwin icon in the Dock to switch back to the X window system.  (You can change this behavior in the user preferences so that you must click the XDarwin icon in the floating switch window instead.)</p>
-<p>In rootless mode, the X window system and Aqua share your display. The root window of the X11 display is the size of the screen and contains all the other windows. The X11 root window is not displayed in rootless mode as Aqua handles the desktop background.</p>
-<h3>Multi-Button Mouse Emulation</h3>
-<p>Many X11 applications rely on the use of a 3-button mouse. You can emulate a 3-button mouse with a single button by holding down various modifier keys while you click the mouse button. This is controlled by settings in the "Multi-Button Mouse Emulation" section of the "General" preferences. By default, emulation is on and holding down the command key and clicking the mouse button will simulate clicking the second mouse button. Holding down the option key and clicking will simulate the third button. You can change to any combination of modifiers to emulate buttons two and three in the preferences. Note, even if the modifiers keys are mapped to some other key with xmodmap, you still must use the actual keys specified in the preferences for multi-button mouse emulation.</p>
-
-<h2><a NAME="path">Setting Your Path</a></h2>
-<p>Your path is the list of directories to be searched for executable commands. The X11 commands are located in <code>/usr/X11R6/bin</code>, which needs to be added to your path. XDarwin does this for you by default and can also add additional directories where you have installed command line applications.</p>
-<p>More experienced users will have already set their path correctly using the initialization files for their shell. In this case, you can inform XDarwin not to modify your path in the preferences. XDarwin launches the initial X11 clients in the user's default login shell. (An alternate shell can also be specified in the preferences.) The way to set the path depends on the shell you are using. This is described in the man page documentation for the shell.</p>
-<p>In addition you may also want to add the X11 man pages to the list of pages to be searched when you are looking for documentation. The X11 man pages are located in <code>/usr/X11R6/man</code> and the <code>MANPATH</code> environment variable contains the list of directories to search.</p>
-
-<h2><a NAME="prefs">User Preferences</a></h2>
-<p>A number of options may be set from the user preferences, accessible from the "Preferences..." menu item in the "XDarwin" menu. The options listed as start up options will not take effect until you have restarted XDarwin. All other options take effect immediately. The various options are described below:</p>
-<h3>General</h3>
-<ul>
-    <li><b>Use System beep for X11:</b> When enabled the standard Mac OS X alert sound is used as the X11 bell. When disabled (default) a simple tone is used.</li>
-    <li><b>Allow X11 to change mouse acceleration:</b> In a standard X window system implementation, the window manager can change the mouse acceleration. This can lead to confusion as the mouse acceleration may be set to different values by the Mac OS X System Preferences and the X window manager. By default, X11 is not allowed to change the mouse acceleration to avoid this problem.</li>
-    <li><b>Multi-Button Mouse Emulation:</b> This is described above under <a HREF="#usage">Usage</a>. When emulation is enabled the selected modifiers must be held down when the mouse button is pushed to emulate the second or third mouse buttons.</li>
-</ul>
-<h3>Start Up</h3>
-<ul>
-    <li><b>Default Mode:</b> If the user does not indicate whether to run in full screen or rootless mode, the mode specified here will be used.</li>
-    <li><b>Show mode pick panel on startup:</b> By default, a panel is displayed when XDarwin is started to allow the user to choose between full screen or rootless mode. If this option is turned off, the default mode will be started automatically.</li>
-    <li><b>X11 Display number:</b> X11 allows there to be multiple displays managed by separate X servers on a single computer. The user may specify an integer display number for XDarwin to use if more than one X server is going to be run simultaneously.</li>
-    <li><b>Allow Xinerama multiple monitor support:</b> XDarwin supports multiple monitors with Xinerama, which treats all monitors as being part of one large rectangular screen. You can disable Xinerama with this option, but currently XDarwin does not handle multiple monitors correctly without it. If you only have a single monitor, Xinerama is automatically disabled.</li>
-    <li><b>Keymapping File:</b> A keymapping file is read at startup and translated to an X11 keymap. Keymapping files, available for a wide variety of languages, are found in <code>/System/Library/Keyboards</code>.</li>
-    <li><b>Starting First X11 Clients:</b> When XDarwin is started from the Finder, it will run <code>xinit</code> to launch the X window manager and other X clients. (See "<code>man xinit</code>" for more information.) Before XDarwin runs <code>xinit</code> it will add the specified directories to the user's path. By default only <code>/usr/X11R6/bin</code> is added. Additional directories may added, separated by a colon. The X clients are started in the user's default login shell so that the user's shell initialization files are read. If desired, an alternate shell may be specified.</li>
-</ul>
-<h3>Full Screen</h3>
-<ul>
-    <li><b>Key combination button:</b> Click this button and then press any number of modifiers followed by a standard key to change the key combination to switch between Aqua and X11.</li>
-    <li><b>Click on icon in Dock switches to X11:</b> Enable this to activate switching to X11 by clicking on the XDarwin icon in the Dock. On some versions of Mac OS X, switching by clicking in the Dock can cause the cursor to disappear on returning to Aqua.</li>
-    <li><b>Show help on startup:</b> This will show an introductory splash screen when XDarwin is started in full screen mode.</li>
-    <li><b>Color bit depth:</b> In full screen mode, the X11 display can use a different color bit depth than is used by Aqua. If "Current" is specified, the depth used by Aqua when XDarwin starts will be used. Otherwise 8, 15, or 24 bits may be specified.</li>
-</ul>
-
-<h2><a NAME="license">License</a></h2>
-The main license for XDarwin is based on the traditional MIT X11 / X Consortium License, which does not impose any conditions on modification or redistribution of source code or binaries other than requiring that copyright/license notices are left intact. For more information and additional copyright/licensing notices covering some sections of the code, please refer to the source code.
-<H3><A NAME="3"></A>X Consortium License</H3>
-<p>Copyright (C) 1996 X Consortium</p>
-<p>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:</p>
-<p>The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.</p>
-<p>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 X CONSORTIUM 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.</p>
-<p>Except as contained in this notice, the name of the X Consortium 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 X Consortium.</p>
-<p>X Window System is a trademark of X Consortium, Inc.</p>
-</body>
-</html>
diff --git a/hw/darwin/bundle/startXClients.cpp b/hw/darwin/bundle/startXClients.cpp
deleted file mode 100644
index f812dbf..0000000
--- a/hw/darwin/bundle/startXClients.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-XCOMM!/bin/sh
-
-XCOMM This script is used by XDarwin to start X clients when XDarwin is
-XCOMM launched from the Finder.
-
-userclientrc=$HOME/.xinitrc
-sysclientrc=XINITDIR/xinitrc
-clientargs=""
-
-if [ -f $userclientrc ]; then
-    clientargs=$userclientrc
-else if [ -f $sysclientrc ]; then
-    clientargs=$sysclientrc
-fi
-fi
-
-if [ "x$2" != "x" ]; then
-    PATH="$PATH:$2"
-    export PATH
-fi
-
-exec xinit $clientargs -- XBINDIR/XDarwinStartup "$1" -idle
diff --git a/hw/darwin/iokit/Makefile.am b/hw/darwin/iokit/Makefile.am
deleted file mode 100644
index 77227d7..0000000
--- a/hw/darwin/iokit/Makefile.am
+++ /dev/null
@@ -1,17 +0,0 @@
-noinst_LIBRARIES = libiokit.a
-
-AM_CFLAGS = @XORG_CFLAGS@
-INCLUDES = -I. -I.. -I$(srcdir) -I$(srcdir)/.. @XORG_INCS@
-AM_DEFS =
-if XQUARTZ
-AM_DEFS += -DDARWIN_WITH_QUARTZ -DXFree86Server
-XQUARTZ_SUBDIRS = bundle quartz
-endif
-DEFS = @DEFS@ $(AM_DEFS)
-
-libiokit_a_SOURCES = xfIOKit.c \
-	           xfIOKitCursor.c \
-	           xfIOKitStartup.c
-
-EXTRA_DIST = \
-	xfIOKit.h
diff --git a/hw/darwin/iokit/xfIOKit.c b/hw/darwin/iokit/xfIOKit.c
deleted file mode 100644
index 7f126c7..0000000
--- a/hw/darwin/iokit/xfIOKit.c
+++ /dev/null
@@ -1,774 +0,0 @@
-/**************************************************************
- *
- * IOKit support for the Darwin X Server
- *
- * HISTORY:
- * Original port to Mac OS X Server by John Carmack
- * Port to Darwin 1.0 by Dave Zarzycki
- * Significantly rewritten for XFree86 4.0.1 by Torrey Lyons
- *
- **************************************************************/
-/*
- * Copyright (c) 2001-2004 Torrey T. Lyons. 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
- * 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.
- */
-
-#if HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "os.h"
-#include "servermd.h"
-#include "inputstr.h"
-#include "scrnintstr.h"
-#include "mi.h"
-#include "mibstore.h"
-#include "mipointer.h"
-#include "micmap.h"
-#include "shadow.h"
-
-#include <sys/types.h>
-#include <sys/time.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <pthread.h>
-#include <assert.h>
-
-#include <mach/mach_interface.h>
-
-#define NO_CFPLUGIN
-#include <IOKit/IOKitLib.h>
-#include <IOKit/hidsystem/IOHIDShared.h>
-#include <IOKit/graphics/IOGraphicsLib.h>
-
-// Define this to work around bugs in the display drivers for
-// older PowerBook G3's. If the X server starts without this
-// #define, you don't need it.
-#undef OLD_POWERBOOK_G3
-
-#include "darwin.h"
-#include "xfIOKit.h"
-
-// Globals
-int             xfIOKitScreenIndex = 0;
-io_connect_t    xfIOKitInputConnect = 0;
-
-static pthread_t                inputThread;
-static EvGlobals *              evg;
-static mach_port_t              masterPort;
-static mach_port_t              notificationPort;
-static IONotificationPortRef    NotificationPortRef;
-static mach_port_t              pmNotificationPort;
-static io_iterator_t            fbIter;
-
-
-/*
- * XFIOKitStoreColors
- * This is a callback from X to change the hardware colormap
- * when using PsuedoColor.
- */
-static void XFIOKitStoreColors(
-    ColormapPtr     pmap,
-    int             numEntries,
-    xColorItem      *pdefs)
-{
-    kern_return_t   kr;
-    int             i;
-    IOColorEntry    *newColors;
-    ScreenPtr       pScreen = pmap->pScreen;
-    XFIOKitScreenPtr iokitScreen = XFIOKIT_SCREEN_PRIV(pScreen);
-
-    assert( newColors = (IOColorEntry *)
-                xalloc( numEntries*sizeof(IOColorEntry) ));
-
-    // Convert xColorItem values to IOColorEntry
-    // assume the colormap is PsuedoColor
-    // as we do not support DirectColor
-    for (i = 0; i < numEntries; i++) {
-        newColors[i].index = pdefs[i].pixel;
-        newColors[i].red =   pdefs[i].red;
-        newColors[i].green = pdefs[i].green;
-        newColors[i].blue =  pdefs[i].blue;
-    }
-
-    kr = IOFBSetCLUT( iokitScreen->fbService, 0, numEntries,
-                      kSetCLUTByValue, newColors );
-    kern_assert( kr );
-
-    xfree( newColors );
-}
-
-
-/*
- * DarwinModeBell
- *  FIXME
- */
-void DarwinModeBell(
-    int             loud,
-    DeviceIntPtr    pDevice,
-    pointer         ctrl,
-    int             fbclass)
-{
-}
-
-
-/*
- * DarwinModeGiveUp
- *  Closes the connections to IOKit services
- */
-void DarwinModeGiveUp( void )
-{
-    int i;
-
-    // we must close the HID System first
-    // because it is a client of the framebuffer
-    NXCloseEventStatus( darwinParamConnect );
-    IOServiceClose( xfIOKitInputConnect );
-    for (i = 0; i < screenInfo.numScreens; i++) {
-        XFIOKitScreenPtr iokitScreen =
-                            XFIOKIT_SCREEN_PRIV(screenInfo.screens[i]);
-        IOServiceClose( iokitScreen->fbService );
-    }
-}
-
-
-/*
- * ClearEvent
- *  Clear an event from the HID System event queue
- */
-static void ClearEvent(NXEvent * ep)
-{
-    static NXEvent nullEvent = {NX_NULLEVENT, {0, 0 }, 0, -1, 0 };
-
-    *ep = nullEvent;
-    ep->data.compound.subType = ep->data.compound.misc.L[0] =
-                                ep->data.compound.misc.L[1] = 0;
-}
-
-
-/*
- * XFIOKitHIDThread
- *  Read the HID System event queue, translate it to an X event,
- *  and queue it for processing.
- */
-static void *XFIOKitHIDThread(void *unused)
-{
-    for (;;) {
-        NXEQElement             *oldHead;
-        mach_msg_return_t       kr;
-        mach_msg_empty_rcv_t    msg;
-
-        kr = mach_msg((mach_msg_header_t*) &msg, MACH_RCV_MSG, 0,
-                      sizeof(msg), notificationPort, 0, MACH_PORT_NULL);
-        kern_assert(kr);
-
-        while (evg->LLEHead != evg->LLETail) {
-            NXEvent ev;
-            xEvent xe;
-
-            // Extract the next event from the kernel queue
-            oldHead = (NXEQElement*)&evg->lleq[evg->LLEHead];
-            ev_lock(&oldHead->sema);
-            ev = oldHead->event;
-            ClearEvent(&oldHead->event);
-            evg->LLEHead = oldHead->next;
-            ev_unlock(&oldHead->sema);
-
-            memset(&xe, 0, sizeof(xe));
-
-            // These fields should be filled in for every event
-            xe.u.keyButtonPointer.rootX = ev.location.x;
-            xe.u.keyButtonPointer.rootY = ev.location.y;
-            xe.u.keyButtonPointer.time = GetTimeInMillis();
-
-            switch( ev.type ) {
-                case NX_MOUSEMOVED:
-                    xe.u.u.type = MotionNotify;
-                    break;
-
-                case NX_LMOUSEDOWN:
-                    xe.u.u.type = ButtonPress;
-                    xe.u.u.detail = 1;
-                    break;
-
-                case NX_LMOUSEUP:
-                    xe.u.u.type = ButtonRelease;
-                    xe.u.u.detail = 1;
-                    break;
-
-                // A newer kernel generates multi-button events with
-                // NX_SYSDEFINED. Button 2 isn't handled correctly by
-                // older kernels anyway. Just let NX_SYSDEFINED events
-                // handle these.
-#if 0
-                case NX_RMOUSEDOWN:
-                    xe.u.u.type = ButtonPress;
-                    xe.u.u.detail = 2;
-                    break;
-
-                case NX_RMOUSEUP:
-                    xe.u.u.type = ButtonRelease;
-                    xe.u.u.detail = 2;
-                    break;
-#endif
-
-                case NX_KEYDOWN:
-                    xe.u.u.type = KeyPress;
-                    xe.u.u.detail = ev.data.key.keyCode;
-                    break;
-
-                case NX_KEYUP:
-                    xe.u.u.type = KeyRelease;
-                    xe.u.u.detail = ev.data.key.keyCode;
-                    break;
-
-                case NX_FLAGSCHANGED:
-                    xe.u.u.type = kXDarwinUpdateModifiers;
-                    xe.u.clientMessage.u.l.longs0 = ev.flags;
-                    break;
-
-                case NX_SYSDEFINED:
-                    if (ev.data.compound.subType == 7) {
-                        xe.u.u.type = kXDarwinUpdateButtons;
-                        xe.u.clientMessage.u.l.longs0 =
-                                        ev.data.compound.misc.L[0];
-                        xe.u.clientMessage.u.l.longs1 =
-                                        ev.data.compound.misc.L[1];
-                    } else {
-                        continue;
-                    }
-                    break;
-
-                case NX_SCROLLWHEELMOVED:
-                    xe.u.u.type = kXDarwinScrollWheel;
-                    xe.u.clientMessage.u.s.shorts0 =
-                                    ev.data.scrollWheel.deltaAxis1;
-                    break;
-
-                default:
-                    continue;
-            }
-
-            DarwinEQEnqueue(&xe);
-        }
-    }
-
-    return NULL;
-}
-
-
-/*
- * XFIOKitPMThread
- *  Handle power state notifications
- */
-static void *XFIOKitPMThread(void *arg)
-{
-    ScreenPtr pScreen = (ScreenPtr)arg;
-    XFIOKitScreenPtr iokitScreen = XFIOKIT_SCREEN_PRIV(pScreen);
-
-    for (;;) {
-        mach_msg_return_t       kr;
-        mach_msg_empty_rcv_t    msg;
-
-        kr = mach_msg((mach_msg_header_t*) &msg, MACH_RCV_MSG, 0,
-                      sizeof(msg), pmNotificationPort, 0, MACH_PORT_NULL);
-        kern_assert(kr);
-
-        // display is powering down
-        if (msg.header.msgh_id == 0) {
-            IOFBAcknowledgePM( iokitScreen->fbService );
-            xf86SetRootClip(pScreen, FALSE);
-        }
-        // display just woke up
-        else if (msg.header.msgh_id == 1) {
-            xf86SetRootClip(pScreen, TRUE);
-        }
-    }
-    return NULL;
-}
-
-
-/*
- * SetupFBandHID
- *  Setup an IOFramebuffer service and connect the HID system to it.
- */
-static Bool SetupFBandHID(
-    int                    index,
-    DarwinFramebufferPtr   dfb,
-    XFIOKitScreenPtr       iokitScreen)
-{
-    kern_return_t           kr;
-    io_service_t            service;
-    io_connect_t            fbService;
-    vm_address_t            vram;
-    vm_size_t               shmemSize;
-    int                     i;
-    UInt32                  numModes;
-    IODisplayModeInformation modeInfo;
-    IODisplayModeID         displayMode, *allModes;
-    IOIndex                 displayDepth;
-    IOFramebufferInformation fbInfo;
-    IOPixelInformation      pixelInfo;
-    StdFBShmem_t            *cshmem;
-
-    // find and open the IOFrameBuffer service
-    service = IOIteratorNext(fbIter);
-    if (service == 0)
-        return FALSE;
-
-    kr = IOServiceOpen( service, mach_task_self(),
-                        kIOFBServerConnectType, &iokitScreen->fbService );
-    IOObjectRelease( service );
-    if (kr != KERN_SUCCESS) {
-        ErrorF("Failed to connect as window server to screen %i.\n", index);
-        return FALSE;
-    }
-    fbService = iokitScreen->fbService;
-
-    // create the slice of shared memory containing cursor state data
-    kr = IOFBCreateSharedCursor( fbService,
-                                 kIOFBCurrentShmemVersion,
-                                 32, 32 );
-    if (kr != KERN_SUCCESS)
-        return FALSE;
-
-    // Register for power management events for the framebuffer's device
-    kr = IOCreateReceivePort(kOSNotificationMessageID, &pmNotificationPort);
-    kern_assert(kr);
-    kr = IOConnectSetNotificationPort( fbService, 0,
-                                       pmNotificationPort, 0 );
-    if (kr != KERN_SUCCESS) {
-        ErrorF("Power management registration failed.\n");
-    }
-
-    // SET THE SCREEN PARAMETERS
-    // get the current screen resolution, refresh rate and depth
-    kr = IOFBGetCurrentDisplayModeAndDepth( fbService,
-                                            &displayMode,
-                                            &displayDepth );
-    if (kr != KERN_SUCCESS)
-        return FALSE;
-
-    // use the current screen resolution if the user
-    // only wants to change the refresh rate
-    if (darwinDesiredRefresh != -1 && darwinDesiredWidth == 0) {
-        kr = IOFBGetDisplayModeInformation( fbService,
-                                            displayMode,
-                                            &modeInfo );
-        if (kr != KERN_SUCCESS)
-            return FALSE;
-        darwinDesiredWidth = modeInfo.nominalWidth;
-        darwinDesiredHeight = modeInfo.nominalHeight;
-    }
-
-    // use the current resolution and refresh rate
-    // if the user doesn't have a preference
-    if (darwinDesiredWidth == 0) {
-
-        // change the pixel depth if desired
-        if (darwinDesiredDepth != -1) {
-            kr = IOFBGetDisplayModeInformation( fbService,
-                                                displayMode,
-                                                &modeInfo );
-            if (kr != KERN_SUCCESS)
-                return FALSE;
-            if (modeInfo.maxDepthIndex < darwinDesiredDepth) {
-                ErrorF("Discarding screen %i:\n", index);
-                ErrorF("Current screen resolution does not support desired pixel depth.\n");
-                return FALSE;
-            }
-
-            displayDepth = darwinDesiredDepth;
-            kr = IOFBSetDisplayModeAndDepth( fbService, displayMode,
-                                             displayDepth );
-            if (kr != KERN_SUCCESS)
-                return FALSE;
-        }
-
-    // look for display mode with correct resolution and refresh rate
-    } else {
-
-        // get an array of all supported display modes
-        kr = IOFBGetDisplayModeCount( fbService, &numModes );
-        if (kr != KERN_SUCCESS)
-            return FALSE;
-        assert(allModes = (IODisplayModeID *)
-                xalloc( numModes * sizeof(IODisplayModeID) ));
-        kr = IOFBGetDisplayModes( fbService, numModes, allModes );
-        if (kr != KERN_SUCCESS)
-            return FALSE;
-
-        for (i = 0; i < numModes; i++) {
-            kr = IOFBGetDisplayModeInformation( fbService, allModes[i],
-                                                &modeInfo );
-            if (kr != KERN_SUCCESS)
-                return FALSE;
-
-            if (modeInfo.flags & kDisplayModeValidFlag &&
-                modeInfo.nominalWidth == darwinDesiredWidth &&
-                modeInfo.nominalHeight == darwinDesiredHeight) {
-
-                if (darwinDesiredDepth == -1)
-                    darwinDesiredDepth = modeInfo.maxDepthIndex;
-                if (modeInfo.maxDepthIndex < darwinDesiredDepth) {
-                    ErrorF("Discarding screen %i:\n", index);
-                    ErrorF("Desired screen resolution does not support desired pixel depth.\n");
-                    return FALSE;
-                }
-
-                if ((darwinDesiredRefresh == -1 ||
-                    (darwinDesiredRefresh << 16) == modeInfo.refreshRate)) {
-                    displayMode = allModes[i];
-                    displayDepth = darwinDesiredDepth;
-                    kr = IOFBSetDisplayModeAndDepth(fbService,
-                                                    displayMode,
-                                                    displayDepth);
-                    if (kr != KERN_SUCCESS)
-                        return FALSE;
-                    break;
-                }
-            }
-        }
-
-        xfree( allModes );
-        if (i >= numModes) {
-            ErrorF("Discarding screen %i:\n", index);
-            ErrorF("Desired screen resolution or refresh rate is not supported.\n");
-            return FALSE;
-        }
-    }
-
-    kr = IOFBGetPixelInformation( fbService, displayMode, displayDepth,
-                                  kIOFBSystemAperture, &pixelInfo );
-    if (kr != KERN_SUCCESS)
-        return FALSE;
-
-#ifdef __i386__
-    /* x86 in 8bit mode currently needs fixed color map... */
-    if (pixelInfo.bitsPerComponent == 8 &&
-        pixelInfo.componentCount == 1)
-    {
-        pixelInfo.pixelType = kIOFixedCLUTPixels;
-    }
-#endif
-
-#ifdef OLD_POWERBOOK_G3
-    if (pixelInfo.pixelType == kIOCLUTPixels)
-        pixelInfo.pixelType = kIOFixedCLUTPixels;
-#endif
-
-    kr = IOFBGetFramebufferInformationForAperture( fbService,
-                                                   kIOFBSystemAperture,
-                                                   &fbInfo );
-    if (kr != KERN_SUCCESS)
-        return FALSE;
-
-    // FIXME: 1x1 IOFramebuffers are sometimes used to indicate video
-    // outputs without a monitor connected to them. Since IOKit Xinerama
-    // does not really work, this often causes problems on PowerBooks.
-    // For now we explicitly check and ignore these screens.
-    if (fbInfo.activeWidth <= 1 || fbInfo.activeHeight <= 1) {
-        ErrorF("Discarding screen %i:\n", index);
-        ErrorF("Invalid width or height.\n");
-        return FALSE;
-    }
-
-    kr = IOConnectMapMemory( fbService, kIOFBCursorMemory,
-                             mach_task_self(), (vm_address_t *) &cshmem,
-                             &shmemSize, kIOMapAnywhere );
-    if (kr != KERN_SUCCESS)
-        return FALSE;
-    iokitScreen->cursorShmem = cshmem;
-
-    kr = IOConnectMapMemory( fbService, kIOFBSystemAperture,
-                             mach_task_self(), &vram, &shmemSize,
-                             kIOMapAnywhere );
-    if (kr != KERN_SUCCESS)
-        return FALSE;
-
-    iokitScreen->framebuffer = (void*)vram;
-    dfb->x = cshmem->screenBounds.minx;
-    dfb->y = cshmem->screenBounds.miny;
-    dfb->width = fbInfo.activeWidth;
-    dfb->height = fbInfo.activeHeight;
-    dfb->pitch = fbInfo.bytesPerRow;
-    dfb->bitsPerPixel = fbInfo.bitsPerPixel;
-    dfb->colorBitsPerPixel = pixelInfo.componentCount *
-                             pixelInfo.bitsPerComponent;
-    dfb->bitsPerComponent = pixelInfo.bitsPerComponent;
-
-    // allocate shadow framebuffer
-    iokitScreen->shadowPtr = xalloc(dfb->pitch * dfb->height);
-    dfb->framebuffer = iokitScreen->shadowPtr;
-
-    // Note: Darwin kIORGBDirectPixels = X TrueColor, not DirectColor
-    if (pixelInfo.pixelType == kIORGBDirectPixels) {
-        dfb->colorType = TrueColor;
-    } else if (pixelInfo.pixelType == kIOCLUTPixels) {
-        dfb->colorType = PseudoColor;
-    } else if (pixelInfo.pixelType == kIOFixedCLUTPixels) {
-        dfb->colorType = StaticColor;
-    }
-
-    // Inform the HID system that the framebuffer is also connected to it.
-    kr = IOConnectAddClient( xfIOKitInputConnect, fbService );
-    kern_assert( kr );
-
-    // We have to have added at least one screen
-    // before we can enable the cursor.
-    kr = IOHIDSetCursorEnable(xfIOKitInputConnect, TRUE);
-    kern_assert( kr );
-
-    return TRUE;
-}
-
-
-/*
- * DarwinModeAddScreen
- *  IOKit specific initialization for each screen.
- */
-Bool DarwinModeAddScreen(
-    int index,
-    ScreenPtr pScreen)
-{
-    DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen);
-    XFIOKitScreenPtr iokitScreen;
-
-    // allocate space for private per screen storage
-    iokitScreen = xalloc(sizeof(XFIOKitScreenRec));
-    XFIOKIT_SCREEN_PRIV(pScreen) = iokitScreen;
-
-    // setup hardware framebuffer
-    iokitScreen->fbService = 0;
-    if (! SetupFBandHID(index, dfb, iokitScreen)) {
-        if (iokitScreen->fbService) {
-            IOServiceClose(iokitScreen->fbService);
-        }
-        return FALSE;
-    }
-
-    return TRUE;
-}
-
-
-/*
- * XFIOKitShadowUpdate
- *  Update the damaged regions of the shadow framebuffer on the screen.
- */
-static void XFIOKitShadowUpdate(ScreenPtr pScreen,
-                                shadowBufPtr pBuf)
-{
-    DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen);
-    XFIOKitScreenPtr iokitScreen = XFIOKIT_SCREEN_PRIV(pScreen);
-    RegionPtr damage = &pBuf->damage;
-    int numBox = REGION_NUM_RECTS(damage);
-    BoxPtr pBox = REGION_RECTS(damage);
-    int pitch = dfb->pitch;
-    int bpp = dfb->bitsPerPixel/8;
-
-    // Loop through all the damaged boxes
-    while (numBox--) {
-        int width, height, offset;
-        unsigned char *src, *dst;
-
-        width = (pBox->x2 - pBox->x1) * bpp;
-        height = pBox->y2 - pBox->y1;
-        offset = (pBox->y1 * pitch) + (pBox->x1 * bpp);
-        src = iokitScreen->shadowPtr + offset;
-        dst = iokitScreen->framebuffer + offset;
-
-        while (height--) {
-            memcpy(dst, src, width);
-            dst += pitch;
-            src += pitch;
-        }
-
-        // Get the next box
-        pBox++;
-    }
-}
-
-
-/*
- * DarwinModeSetupScreen
- *  Finalize IOKit specific initialization of each screen.
- */
-Bool DarwinModeSetupScreen(
-    int index,
-    ScreenPtr pScreen)
-{
-    DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen);
-    pthread_t pmThread;
-
-    // initalize cursor support
-    if (! XFIOKitInitCursor(pScreen)) {
-        return FALSE;
-    }
-
-    // initialize shadow framebuffer support
-    if (! shadowInit(pScreen, XFIOKitShadowUpdate, NULL)) {
-        ErrorF("Failed to initalize shadow framebuffer for screen %i.\n",
-               index);
-        return FALSE;
-    }
-
-    // initialize colormap handling as needed
-    if (dfb->colorType == PseudoColor) {
-        pScreen->StoreColors = XFIOKitStoreColors;
-    }
-
-    // initialize power manager handling
-    pthread_create( &pmThread, NULL, XFIOKitPMThread,
-                    (void *) pScreen );
-
-    return TRUE;
-}
-
-
-/*
- * DarwinModeInitOutput
- *  One-time initialization of IOKit output support.
- */
-void DarwinModeInitOutput(
-    int argc,
-    char **argv)
-{
-    static unsigned long    generation = 0;
-    kern_return_t           kr;
-    io_iterator_t           iter;
-    io_service_t            service;
-    vm_address_t            shmem;
-    vm_size_t               shmemSize;
-
-    ErrorF("Display mode: IOKit\n");
-
-    // Allocate private storage for each screen's IOKit specific info
-    if (generation != serverGeneration) {
-        xfIOKitScreenIndex = AllocateScreenPrivateIndex();
-        generation = serverGeneration;
-    }
-
-    kr = IOMasterPort(bootstrap_port, &masterPort);
-    kern_assert( kr );
-
-    // Find and open the HID System Service
-    // Do this now to be sure the Mac OS X window server is not running.
-    kr = IOServiceGetMatchingServices( masterPort,
-                                       IOServiceMatching( kIOHIDSystemClass ),
-                                       &iter );
-    kern_assert( kr );
-
-    assert( service = IOIteratorNext( iter ) );
-
-    kr = IOServiceOpen( service, mach_task_self(), kIOHIDServerConnectType,
-                        &xfIOKitInputConnect );
-    if (kr != KERN_SUCCESS) {
-        ErrorF("Failed to connect to the HID System as the window server!\n");
-#ifdef DARWIN_WITH_QUARTZ
-        FatalError("Quit the Mac OS X window server or use the -quartz option.\n");
-#else
-        FatalError("Make sure you have quit the Mac OS X window server.\n");
-#endif
-    }
-
-    IOObjectRelease( service );
-    IOObjectRelease( iter );
-
-    // Setup the event queue in memory shared by the kernel and X server
-    kr = IOHIDCreateSharedMemory( xfIOKitInputConnect,
-                                  kIOHIDCurrentShmemVersion );
-    kern_assert( kr );
-
-    kr = IOConnectMapMemory( xfIOKitInputConnect, kIOHIDGlobalMemory,
-                             mach_task_self(), &shmem, &shmemSize,
-                             kIOMapAnywhere );
-    kern_assert( kr );
-
-    evg = (EvGlobals *)(shmem + ((EvOffsets *)shmem)->evGlobalsOffset);
-
-    assert(sizeof(EvGlobals) == evg->structSize);
-
-    NotificationPortRef = IONotificationPortCreate( masterPort );
-
-    notificationPort = IONotificationPortGetMachPort(NotificationPortRef);
-
-    kr = IOConnectSetNotificationPort( xfIOKitInputConnect,
-                                       kIOHIDEventNotification,
-                                       notificationPort, 0 );
-    kern_assert( kr );
-
-    evg->movedMask |= NX_MOUSEMOVEDMASK;
-
-    // find number of framebuffers
-    kr = IOServiceGetMatchingServices( masterPort,
-                        IOServiceMatching( IOFRAMEBUFFER_CONFORMSTO ),
-                        &fbIter );
-    kern_assert( kr );
-
-    darwinScreensFound = 0;
-    while ((service = IOIteratorNext(fbIter))) {
-        IOObjectRelease( service );
-        darwinScreensFound++;
-    }
-    IOIteratorReset(fbIter);
-}
-
-
-/*
- * DarwinModeInitInput
- *  One-time initialization of IOKit input support.
- */
-void DarwinModeInitInput(
-    int argc,
-    char **argv)
-{
-    kern_return_t           kr;
-    int                     fd[2];
-
-    kr = IOHIDSetEventsEnable(xfIOKitInputConnect, TRUE);
-    kern_assert( kr );
-
-    // Start event passing thread
-    assert( pipe(fd) == 0 );
-    darwinEventReadFD = fd[0];
-    darwinEventWriteFD = fd[1];
-    fcntl(darwinEventReadFD, F_SETFL, O_NONBLOCK);
-    pthread_create(&inputThread, NULL,
-                   XFIOKitHIDThread, NULL);
-
-}
-
-
-/*
- * DarwinModeProcessEvent
- *  Process IOKit specific events.
- */
-void DarwinModeProcessEvent(
-    xEvent *xe)
-{
-    // No mode specific events
-    ErrorF("Unknown X event caught: %d\n", xe->u.u.type);
-}
diff --git a/hw/darwin/iokit/xfIOKit.h b/hw/darwin/iokit/xfIOKit.h
deleted file mode 100644
index 27d27bc..0000000
--- a/hw/darwin/iokit/xfIOKit.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
-  xfIOKit.h
-
-  IOKit specific functions and definitions
-*/
-/*
- * Copyright (c) 2001-2002 Torrey T. Lyons. 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
- * 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 _XFIOKIT_H
-#define _XFIOKIT_H
-
-#include <pthread.h>
-#include <IOKit/graphics/IOFramebufferShared.h>
-#include <X11/Xproto.h>
-#include "screenint.h"
-#include "darwin.h"
-
-typedef struct {
-    io_connect_t        fbService;
-    StdFBShmem_t       *cursorShmem;
-    unsigned char      *framebuffer;
-    unsigned char      *shadowPtr;
-} XFIOKitScreenRec, *XFIOKitScreenPtr;
-
-#define XFIOKIT_SCREEN_PRIV(pScreen) \
-    ((XFIOKitScreenPtr)pScreen->devPrivates[xfIOKitScreenIndex].ptr)
-
-extern int xfIOKitScreenIndex; // index into pScreen.devPrivates
-extern io_connect_t xfIOKitInputConnect;
-
-Bool XFIOKitInitCursor(ScreenPtr pScreen);
-
-#endif	/* _XFIOKIT_H */
diff --git a/hw/darwin/iokit/xfIOKitCursor.c b/hw/darwin/iokit/xfIOKitCursor.c
deleted file mode 100644
index 8388513..0000000
--- a/hw/darwin/iokit/xfIOKitCursor.c
+++ /dev/null
@@ -1,737 +0,0 @@
-/**************************************************************
- *
- * Cursor support for Darwin X Server
- *
- * Three different cursor modes are possible:
- *  X (0)         - tracking via Darwin kernel,
- *                  display via X machine independent
- *  Kernel (1)    - tracking and display via Darwin kernel
- *                  (not currently supported)
- *  Hardware (2)  - tracking and display via hardware
- *
- * The X software cursor uses the Darwin software cursor
- * routines in IOFramebuffer.cpp to track the cursor, but
- * displays the cursor image using the X machine
- * independent display cursor routines in midispcur.c.
- *
- * The kernel cursor uses IOFramebuffer.cpp routines to
- * track and display the cursor. This gives better
- * performance as the display calls don't have to cross
- * the kernel boundary. Unfortunately, this mode has
- * synchronization issues with the user land X server
- * and isn't currently used.
- *
- * Hardware cursor support lets the hardware handle these
- * details.
- *
- * Kernel and hardware cursor mode only work for cursors
- * up to a certain size, currently 16x16 pixels. If a
- * bigger cursor is set, we fallback to X cursor mode.
- *
- * HISTORY:
- * 1.0 by Torrey T. Lyons, October 30, 2000
- *
- **************************************************************/
-/*
- * Copyright (c) 2001-2002 Torrey T. Lyons. 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
- * 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.
- */
-
-#if HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-#include "scrnintstr.h"
-#include "cursorstr.h"
-#include "mipointrst.h"
-#include "micmap.h"
-#define NO_CFPLUGIN
-#include <IOKit/graphics/IOGraphicsLib.h>
-#include <IOKit/hidsystem/IOHIDLib.h>
-#include "darwin.h"
-#include "xfIOKit.h"
-#include <assert.h>
-#define DUMP_DARWIN_CURSOR FALSE
-
-#define CURSOR_PRIV(pScreen) \
-    ((XFIOKitCursorScreenPtr)pScreen->devPrivates[darwinCursorScreenIndex].ptr)
-
-// The cursors format are documented in IOFramebufferShared.h.
-#define RGBto34WithGamma(red, green, blue)  \
-    (  0x000F                               \
-     | (((red) & 0xF) << 12)                \
-     | (((green) & 0xF) << 8)               \
-     | (((blue) & 0xF) << 4) )
-#define RGBto38WithGamma(red, green, blue)  \
-    (  0xFF << 24                           \
-     | (((red) & 0xFF) << 16)               \
-     | (((green) & 0xFF) << 8)              \
-     | (((blue) & 0xFF)) )
-#define HighBitOf32 0x80000000
-
-typedef struct {
-    Bool                    canHWCursor;
-    short                   cursorMode;
-    RecolorCursorProcPtr    RecolorCursor;
-    InstallColormapProcPtr  InstallColormap;
-    QueryBestSizeProcPtr    QueryBestSize;
-    miPointerSpriteFuncPtr  spriteFuncs;
-    ColormapPtr             pInstalledMap;
-} XFIOKitCursorScreenRec, *XFIOKitCursorScreenPtr;
-
-static int darwinCursorScreenIndex = -1;
-static unsigned long darwinCursorGeneration = 0;
-
-/*
-===========================================================================
-
- Pointer sprite functions
-
-===========================================================================
-*/
-
-/*
-    Realizing the Darwin hardware cursor (ie. converting from the
-    X representation to the IOKit representation) is complicated
-    by the fact that we have three different potential cursor
-    formats to go to, one for each bit depth (8, 15, or 24).
-    The IOKit formats are documented in IOFramebufferShared.h.
-    X cursors are represented as two pieces, a source and a mask.
-    The mask is a bitmap indicating which parts of the cursor are 
-    transparent and which parts are drawn.  The source is a bitmap
-    indicating which parts of the non-transparent portion of the the
-    cursor should be painted in the foreground color and which should
-    be painted in the background color. The bitmaps are given in
-    32-bit format with least significant byte and bit first.
-    (This is opposite PowerPC Darwin.)
-*/
-
-typedef struct {
-    unsigned char image[CURSORWIDTH*CURSORHEIGHT];
-    unsigned char mask[CURSORWIDTH*CURSORHEIGHT];
-} cursorPrivRec, *cursorPrivPtr;
-
-/*
- * XFIOKitRealizeCursor8
- * Convert the X cursor representation to an 8-bit depth
- * format for Darwin. This function assumes the maximum cursor
- * width is a multiple of 8.
- */
-static Bool
-XFIOKitRealizeCursor8(
-    ScreenPtr pScreen,
-    CursorPtr pCursor)
-{
-    cursorPrivPtr   newCursor;
-    unsigned char   *newSourceP, *newMaskP;
-    CARD32          *oldSourceP, *oldMaskP;
-    xColorItem      fgColor, bgColor;
-    int             index, x, y, rowPad;
-    int             cursorWidth, cursorHeight;
-    ColormapPtr     pmap;
-
-    // check cursor size just to be sure
-    cursorWidth = pCursor->bits->width;
-    cursorHeight = pCursor->bits->height;
-    if (cursorHeight > CURSORHEIGHT || cursorWidth > CURSORWIDTH)
-        return FALSE;
-
-    // get cursor colors in colormap
-    index = pScreen->myNum;
-    pmap = miInstalledMaps[index];
-    if (!pmap) return FALSE;
-
-    fgColor.red = pCursor->foreRed;
-    fgColor.green = pCursor->foreGreen;
-    fgColor.blue = pCursor->foreBlue;
-    FakeAllocColor(pmap, &fgColor);
-    bgColor.red = pCursor->backRed;
-    bgColor.green = pCursor->backGreen;
-    bgColor.blue = pCursor->backBlue;
-    FakeAllocColor(pmap, &bgColor);
-    FakeFreeColor(pmap, fgColor.pixel);
-    FakeFreeColor(pmap, bgColor.pixel);
-
-    // allocate memory for new cursor image
-    newCursor = xalloc( sizeof(cursorPrivRec) );
-    if (!newCursor)
-        return FALSE;
-    memset( newCursor->image, pScreen->blackPixel, CURSORWIDTH*CURSORHEIGHT );
-    memset( newCursor->mask, 0, CURSORWIDTH*CURSORHEIGHT );
-
-    // convert to 8-bit Darwin cursor format
-    oldSourceP = (CARD32 *) pCursor->bits->source;
-    oldMaskP = (CARD32 *) pCursor->bits->mask;
-    newSourceP = newCursor->image;
-    newMaskP = newCursor->mask;
-    rowPad = CURSORWIDTH - cursorWidth;
-
-    for (y = 0; y < cursorHeight; y++) {
-        for (x = 0; x < cursorWidth; x++) {
-            if (*oldSourceP & (HighBitOf32 >> x))
-                *newSourceP = fgColor.pixel;
-            else
-                *newSourceP = bgColor.pixel;
-            if (*oldMaskP & (HighBitOf32 >> x))
-                *newMaskP = 255;
-            else
-                *newSourceP = pScreen->blackPixel;
-            newSourceP++; newMaskP++;
-        }
-        oldSourceP++; oldMaskP++;
-        newSourceP += rowPad; newMaskP += rowPad;
-    }
-
-    // save the result
-    pCursor->devPriv[pScreen->myNum] = (pointer) newCursor;
-    return TRUE;
-}
-
-
-/*
- * XFIOKitRealizeCursor15
- * Convert the X cursor representation to an 15-bit depth
- * format for Darwin.
- */
-static Bool
-XFIOKitRealizeCursor15(
-    ScreenPtr       pScreen,
-    CursorPtr       pCursor)
-{
-    unsigned short  *newCursor;
-    unsigned short  fgPixel, bgPixel;
-    unsigned short  *newSourceP;
-    CARD32          *oldSourceP, *oldMaskP;
-    int             x, y, rowPad;
-    int             cursorWidth, cursorHeight;
-
-    // check cursor size just to be sure
-    cursorWidth = pCursor->bits->width;
-    cursorHeight = pCursor->bits->height;
-    if (cursorHeight > CURSORHEIGHT || cursorWidth > CURSORWIDTH)
-       return FALSE;
-
-    // allocate memory for new cursor image
-    newCursor = xalloc( CURSORWIDTH*CURSORHEIGHT*sizeof(short) );
-    if (!newCursor)
-        return FALSE;
-    memset( newCursor, 0, CURSORWIDTH*CURSORHEIGHT*sizeof(short) );
-
-    // calculate pixel values
-    fgPixel = RGBto34WithGamma( pCursor->foreRed, pCursor->foreGreen,
-                                pCursor->foreBlue );
-    bgPixel = RGBto34WithGamma( pCursor->backRed, pCursor->backGreen,
-                                pCursor->backBlue );
-
-    // convert to 15-bit Darwin cursor format
-    oldSourceP = (CARD32 *) pCursor->bits->source;
-    oldMaskP = (CARD32 *) pCursor->bits->mask;
-    newSourceP = newCursor;
-    rowPad = CURSORWIDTH - cursorWidth;
-
-    for (y = 0; y < cursorHeight; y++) {
-        for (x = 0; x < cursorWidth; x++) {
-            if (*oldMaskP & (HighBitOf32 >> x)) {
-                if (*oldSourceP & (HighBitOf32 >> x))
-                    *newSourceP = fgPixel;
-                else
-                    *newSourceP = bgPixel;
-            } else {
-                *newSourceP = 0;
-            }
-            newSourceP++;
-        }
-        oldSourceP++; oldMaskP++;
-        newSourceP += rowPad;
-    }
-
-#if DUMP_DARWIN_CURSOR
-    // Write out the cursor
-    ErrorF("Cursor: 0x%x\n", pCursor);
-    ErrorF("Width = %i, Height = %i, RowPad = %i\n", cursorWidth,
-            cursorHeight, rowPad);
-    for (y = 0; y < cursorHeight; y++) {
-        newSourceP = newCursor + y*CURSORWIDTH;
-        for (x = 0; x < cursorWidth; x++) {
-            if (*newSourceP == fgPixel)
-                ErrorF("x");
-            else if (*newSourceP == bgPixel)
-                ErrorF("o");
-            else
-                ErrorF(" ");
-            newSourceP++;
-        }
-        ErrorF("\n");
-    }
-#endif
-
-    // save the result
-    pCursor->devPriv[pScreen->myNum] = (pointer) newCursor;
-    return TRUE;
-}
-
-
-/*
- * XFIOKitRealizeCursor24
- * Convert the X cursor representation to an 24-bit depth
- * format for Darwin. This function assumes the maximum cursor
- * width is a multiple of 8.
- */
-static Bool
-XFIOKitRealizeCursor24(
-    ScreenPtr       pScreen,
-    CursorPtr       pCursor)
-{
-    unsigned int    *newCursor;
-    unsigned int    fgPixel, bgPixel;
-    unsigned int    *newSourceP;
-    CARD32          *oldSourceP, *oldMaskP;
-    int             x, y, rowPad;
-    int             cursorWidth, cursorHeight;
-
-    // check cursor size just to be sure
-    cursorWidth = pCursor->bits->width;
-    cursorHeight = pCursor->bits->height;
-    if (cursorHeight > CURSORHEIGHT || cursorWidth > CURSORWIDTH)
-       return FALSE;
-
-    // allocate memory for new cursor image
-    newCursor = xalloc( CURSORWIDTH*CURSORHEIGHT*sizeof(int) );
-    if (!newCursor)
-        return FALSE;
-    memset( newCursor, 0, CURSORWIDTH*CURSORHEIGHT*sizeof(int) );
-
-    // calculate pixel values
-    fgPixel = RGBto38WithGamma( pCursor->foreRed, pCursor->foreGreen,
-                                pCursor->foreBlue );
-    bgPixel = RGBto38WithGamma( pCursor->backRed, pCursor->backGreen,
-                                pCursor->backBlue );
-
-    // convert to 24-bit Darwin cursor format
-    oldSourceP = (CARD32 *) pCursor->bits->source;
-    oldMaskP = (CARD32 *) pCursor->bits->mask;
-    newSourceP = newCursor;
-    rowPad = CURSORWIDTH - cursorWidth;
-
-    for (y = 0; y < cursorHeight; y++) {
-        for (x = 0; x < cursorWidth; x++) {
-            if (*oldMaskP & (HighBitOf32 >> x)) {
-                if (*oldSourceP & (HighBitOf32 >> x))
-                    *newSourceP = fgPixel;
-                else
-                    *newSourceP = bgPixel;
-            } else {
-                *newSourceP = 0;
-            }
-            newSourceP++;
-        }
-        oldSourceP++; oldMaskP++;
-        newSourceP += rowPad;
-    }
-
-#if DUMP_DARWIN_CURSOR
-    // Write out the cursor
-    ErrorF("Cursor: 0x%x\n", pCursor);
-    ErrorF("Width = %i, Height = %i, RowPad = %i\n", cursorWidth,
-            cursorHeight, rowPad);
-    for (y = 0; y < cursorHeight; y++) {
-        newSourceP = newCursor + y*CURSORWIDTH;
-        for (x = 0; x < cursorWidth; x++) {
-            if (*newSourceP == fgPixel)
-                ErrorF("x");
-            else if (*newSourceP == bgPixel)
-                ErrorF("o");
-            else
-                ErrorF(" ");
-            newSourceP++;
-        }
-        ErrorF("\n");
-    }
-#endif
-
-    // save the result
-    pCursor->devPriv[pScreen->myNum] = (pointer) newCursor;
-    return TRUE;
-}
-
-
-/*
- * XFIOKitRealizeCursor
- * 
- */
-static Bool
-XFIOKitRealizeCursor(
-    ScreenPtr       pScreen,
-    CursorPtr       pCursor)
-{
-    Bool                        result;
-    XFIOKitCursorScreenPtr      ScreenPriv = CURSOR_PRIV(pScreen);
-    DarwinFramebufferPtr        dfb = SCREEN_PRIV(pScreen);
-
-    if ((pCursor->bits->height > CURSORHEIGHT) ||
-        (pCursor->bits->width > CURSORWIDTH) ||
-        // FIXME: this condition is not needed after kernel cursor works
-        !ScreenPriv->canHWCursor) {
-        result = (*ScreenPriv->spriteFuncs->RealizeCursor)(pScreen, pCursor);
-    } else if (dfb->bitsPerPixel == 8) {
-        result = XFIOKitRealizeCursor8(pScreen, pCursor);
-    } else if (dfb->bitsPerPixel == 16) {
-        result = XFIOKitRealizeCursor15(pScreen, pCursor);
-    } else {
-        result = XFIOKitRealizeCursor24(pScreen, pCursor);
-    }
-
-    return result;
-}
-
-
-/*
- * XFIOKitUnrealizeCursor
- * 
- */
-static Bool
-XFIOKitUnrealizeCursor(
-    ScreenPtr pScreen,
-    CursorPtr pCursor)
-{
-    Bool                        result;
-    XFIOKitCursorScreenPtr      ScreenPriv = CURSOR_PRIV(pScreen);
-
-    if ((pCursor->bits->height > CURSORHEIGHT) ||
-        (pCursor->bits->width > CURSORWIDTH) ||
-        // FIXME: this condition is not needed after kernel cursor works
-        !ScreenPriv->canHWCursor) {
-        result = (*ScreenPriv->spriteFuncs->UnrealizeCursor)(pScreen, pCursor);
-    } else {
-        xfree( pCursor->devPriv[pScreen->myNum] );
-        result = TRUE;
-    }
-
-    return result;
-}
-
-
-/*
- * XFIOKitSetCursor
- * Set the cursor sprite and position
- * Use hardware cursor if possible
- */
-static void
-XFIOKitSetCursor(
-    ScreenPtr       pScreen,
-    CursorPtr       pCursor,
-    int             x,
-    int             y)
-{
-    kern_return_t               kr;
-    DarwinFramebufferPtr        dfb = SCREEN_PRIV(pScreen);
-    XFIOKitScreenPtr            iokitScreen = XFIOKIT_SCREEN_PRIV(pScreen);
-    StdFBShmem_t                *cshmem = iokitScreen->cursorShmem;
-    XFIOKitCursorScreenPtr      ScreenPriv = CURSOR_PRIV(pScreen);
-
-    // are we supposed to remove the cursor?
-    if (!pCursor) {
-        if (ScreenPriv->cursorMode == 0)
-            (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, 0, x, y);
-        else {
-            if (!cshmem->cursorShow) {
-                cshmem->cursorShow++;
-                if (cshmem->hardwareCursorActive) {
-                    kr = IOFBSetCursorVisible(iokitScreen->fbService, FALSE);
-                    kern_assert( kr );
-                }
-            }
-        }
-        return;
-    } 
- 
-    // can we use the kernel or hardware cursor?
-    if ((pCursor->bits->height <= CURSORHEIGHT) &&
-        (pCursor->bits->width <= CURSORWIDTH) &&
-        // FIXME: condition not needed when kernel cursor works
-        ScreenPriv->canHWCursor) {
-
-        if (ScreenPriv->cursorMode == 0)    // remove the X cursor
-            (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, 0, x, y);
-        ScreenPriv->cursorMode = 1;         // kernel cursor
-
-        // change the cursor image in shared memory
-        if (dfb->bitsPerPixel == 8) {
-            cursorPrivPtr newCursor =
-                    (cursorPrivPtr) pCursor->devPriv[pScreen->myNum];
-            memcpy(cshmem->cursor.bw8.image[0], newCursor->image,
-                        CURSORWIDTH*CURSORHEIGHT);
-            memcpy(cshmem->cursor.bw8.mask[0], newCursor->mask,
-                        CURSORWIDTH*CURSORHEIGHT);
-        } else if (dfb->bitsPerPixel == 16) {
-            unsigned short *newCursor =
-                    (unsigned short *) pCursor->devPriv[pScreen->myNum];
-            memcpy(cshmem->cursor.rgb.image[0], newCursor,
-                        2*CURSORWIDTH*CURSORHEIGHT);
-        } else {
-            unsigned int *newCursor =
-                    (unsigned int *) pCursor->devPriv[pScreen->myNum];
-            memcpy(cshmem->cursor.rgb24.image[0], newCursor,
-                        4*CURSORWIDTH*CURSORHEIGHT);
-        }
-
-        // FIXME: We always use a full size cursor, even if the image
-        // is smaller because I couldn't get the padding to come out
-        // right otherwise.
-        cshmem->cursorSize[0].width = CURSORWIDTH;
-        cshmem->cursorSize[0].height = CURSORHEIGHT;
-        cshmem->hotSpot[0].x = pCursor->bits->xhot;
-        cshmem->hotSpot[0].y = pCursor->bits->yhot;
-
-        // try to use a hardware cursor
-        if (ScreenPriv->canHWCursor) {
-            kr = IOFBSetNewCursor(iokitScreen->fbService, 0, 0, 0);
-            // FIXME: this is a fatal error without the kernel cursor
-            kern_assert( kr );
-#if 0
-            if (kr != KERN_SUCCESS) {
-                ErrorF("Could not set new cursor with kernel return 0x%x.\n", kr);
-                ScreenPriv->canHWCursor = FALSE;
-            }
-#endif
-        }
-
-        // make the new cursor visible
-        if (cshmem->cursorShow)
-            cshmem->cursorShow--;
-
-        if (!cshmem->cursorShow && ScreenPriv->canHWCursor) {
-            kr = IOFBSetCursorVisible(iokitScreen->fbService, TRUE);
-            // FIXME: this is a fatal error without the kernel cursor
-            kern_assert( kr );
-#if 0
-            if (kr != KERN_SUCCESS) {
-                ErrorF("Couldn't set hardware cursor visible with kernel return 0x%x.\n", kr);
-                ScreenPriv->canHWCursor = FALSE;
-            } else
-#endif
-                ScreenPriv->cursorMode = 2;     // hardware cursor
-        }
-
-	return; 
-    }
-
-    // otherwise we use a software cursor
-    if (ScreenPriv->cursorMode) {
-        /* remove the kernel or hardware cursor */
-        XFIOKitSetCursor(pScreen, 0, x, y);
-    }
-
-    ScreenPriv->cursorMode = 0;
-    (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, pCursor, x, y);
-}
-
-
-/*
- * XFIOKitMoveCursor
- * Move the cursor. This is a noop for a kernel or hardware cursor.
- */
-static void
-XFIOKitMoveCursor(
-    ScreenPtr   pScreen,
-    int         x,
-    int         y)
-{
-    XFIOKitCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
-
-    // only the X cursor needs to be explicitly moved
-    if (!ScreenPriv->cursorMode)
-        (*ScreenPriv->spriteFuncs->MoveCursor)(pScreen, x, y);
-}
-
-static miPointerSpriteFuncRec darwinSpriteFuncsRec = {
-    XFIOKitRealizeCursor,
-    XFIOKitUnrealizeCursor,
-    XFIOKitSetCursor,
-    XFIOKitMoveCursor
-};
-
-
-/*
-===========================================================================
-
- Pointer screen functions
-
-===========================================================================
-*/
-
-/*
- * XFIOKitCursorOffScreen
- */
-static Bool XFIOKitCursorOffScreen(ScreenPtr *pScreen, int *x, int *y)
-{	return FALSE;
-}
-
-
-/*
- * XFIOKitCrossScreen
- */
-static void XFIOKitCrossScreen(ScreenPtr pScreen, Bool entering)
-{	return;
-}
-
-
-/*
- * XFIOKitWarpCursor
- * Change the cursor position without generating an event or motion history
- */
-static void
-XFIOKitWarpCursor(
-    ScreenPtr               pScreen,
-    int                     x,
-    int                     y)
-{
-    kern_return_t           kr;
-
-    kr = IOHIDSetMouseLocation( xfIOKitInputConnect, x, y );
-    if (kr != KERN_SUCCESS) {
-        ErrorF("Could not set cursor position with kernel return 0x%x.\n", kr);
-    }
-    miPointerWarpCursor(pScreen, x, y);
-}
-
-static miPointerScreenFuncRec darwinScreenFuncsRec = {
-  XFIOKitCursorOffScreen,
-  XFIOKitCrossScreen,
-  XFIOKitWarpCursor,
-  DarwinEQPointerPost,
-  DarwinEQSwitchScreen
-};
-
-
-/*
-===========================================================================
-
- Other screen functions
-
-===========================================================================
-*/
-
-/*
- * XFIOKitCursorQueryBestSize
- * Handle queries for best cursor size
- */
-static void
-XFIOKitCursorQueryBestSize(
-   int              class, 
-   unsigned short   *width,
-   unsigned short   *height,
-   ScreenPtr        pScreen)
-{
-    XFIOKitCursorScreenPtr ScreenPriv = CURSOR_PRIV(pScreen);
-
-    if (class == CursorShape) {
-        *width = CURSORWIDTH;
-        *height = CURSORHEIGHT;
-    } else
-        (*ScreenPriv->QueryBestSize)(class, width, height, pScreen);
-}
-
-
-/*
- * XFIOKitInitCursor
- * Initialize cursor support
- */
-Bool 
-XFIOKitInitCursor(
-    ScreenPtr	pScreen)
-{
-    XFIOKitScreenPtr        iokitScreen = XFIOKIT_SCREEN_PRIV(pScreen);
-    XFIOKitCursorScreenPtr  ScreenPriv;
-    miPointerScreenPtr	    PointPriv;
-    kern_return_t           kr;
-
-    // start with no cursor displayed
-    if (!iokitScreen->cursorShmem->cursorShow++) {
-        if (iokitScreen->cursorShmem->hardwareCursorActive) {
-            kr = IOFBSetCursorVisible(iokitScreen->fbService, FALSE);
-            kern_assert( kr );
-        }
-    }
-
-    // initialize software cursor handling (always needed as backup)
-    if (!miDCInitialize(pScreen, &darwinScreenFuncsRec)) {
-        return FALSE;
-    }
-
-    // allocate private storage for this screen's hardware cursor info
-    if (darwinCursorGeneration != serverGeneration) {
-        if ((darwinCursorScreenIndex = AllocateScreenPrivateIndex()) < 0)
-            return FALSE;
-        darwinCursorGeneration = serverGeneration; 	
-    }
-
-    ScreenPriv = xcalloc( 1, sizeof(XFIOKitCursorScreenRec) );
-    if (!ScreenPriv) return FALSE;
-
-    pScreen->devPrivates[darwinCursorScreenIndex].ptr = (pointer) ScreenPriv;
-
-    // check if a hardware cursor is supported
-    if (!iokitScreen->cursorShmem->hardwareCursorCapable) {
-        ScreenPriv->canHWCursor = FALSE;
-        ErrorF("Hardware cursor not supported.\n");
-    } else {
-        // we need to make sure that the hardware cursor really works
-        ScreenPriv->canHWCursor = TRUE;
-        kr = IOFBSetNewCursor(iokitScreen->fbService, 0, 0, 0);
-        if (kr != KERN_SUCCESS) {
-            ErrorF("Could not set hardware cursor with kernel return 0x%x.\n", kr);
-            ScreenPriv->canHWCursor = FALSE;
-        }
-        kr = IOFBSetCursorVisible(iokitScreen->fbService, TRUE);
-        if (kr != KERN_SUCCESS) {
-            ErrorF("Couldn't set hardware cursor visible with kernel return 0x%x.\n", kr);
-            ScreenPriv->canHWCursor = FALSE;
-        }
-        IOFBSetCursorVisible(iokitScreen->fbService, FALSE);
-    }
-
-    ScreenPriv->cursorMode = 0;
-    ScreenPriv->pInstalledMap = NULL;
-
-    // override some screen procedures
-    ScreenPriv->QueryBestSize = pScreen->QueryBestSize;
-    pScreen->QueryBestSize = XFIOKitCursorQueryBestSize;
-//    ScreenPriv->ConstrainCursor = pScreen->ConstrainCursor;
-//    pScreen->ConstrainCursor = XFIOKitConstrainCursor;
-
-    // initialize hardware cursor handling
-    PointPriv = (miPointerScreenPtr)
-                    pScreen->devPrivates[miPointerScreenIndex].ptr;
-
-    ScreenPriv->spriteFuncs = PointPriv->spriteFuncs;
-    PointPriv->spriteFuncs = &darwinSpriteFuncsRec; 
-
-    /* Other routines that might be overridden */
-/*
-    CursorLimitsProcPtr		CursorLimits;
-    RecolorCursorProcPtr	RecolorCursor;
-*/
-
-    return TRUE;
-}
diff --git a/hw/darwin/iokit/xfIOKitStartup.c b/hw/darwin/iokit/xfIOKitStartup.c
deleted file mode 100644
index 413d062..0000000
--- a/hw/darwin/iokit/xfIOKitStartup.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/**************************************************************
- *
- * Startup code for the IOKit Darwin X Server
- *
- **************************************************************/
-/*
- * Copyright (c) 2001-2004 Torrey T. Lyons. 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
- * 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.
- */
-
-#if HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "darwin.h"
-#include "darwinKeyboard.h"
-#include "micmap.h"
-
-void GlxExtensionInit(void);
-void GlxWrapInitVisuals(miInitVisualsProcPtr *procPtr);
-
-
-/*
- * DarwinHandleGUI
- *  This function is called first from main().
- *  It does nothing for the IOKit X server.
- */
-void DarwinHandleGUI(
-    int         argc,
-    char        *argv[],
-    char        *envp[] )
-{
-}
-
-
-/*
- * DarwinGlxExtensionInit
- *  Initialize the GLX extension.
- *  Mesa is linked into the IOKit mode X server so we just call directly.
- */
-void DarwinGlxExtensionInit(void)
-{
-#ifdef GLXEXT
-    	GlxExtensionInit();
-#endif
-}
-
-
-/*
- * DarwinGlxWrapInitVisuals
- */
-void DarwinGlxWrapInitVisuals(
-    miInitVisualsProcPtr *procPtr)
-{
-#ifdef GLXEXT
-    GlxWrapInitVisuals(procPtr);
-#endif
-}
-
-
-/*
- * DarwinModeProcessArgument
- *  Process IOKit specific command line arguments.
- */
-int DarwinModeProcessArgument(
-    int argc,
-    char *argv[],
-    int i)
-{
-#ifdef DARWIN_WITH_QUARTZ
-    // XDarwinStartup uses these arguments to indicate which X server
-    // should be started. Ignore them here.
-    if (!strcmp( argv[i], "-fullscreen" ) ||
-        !strcmp( argv[i], "-rootless" ) ||
-        !strcmp( argv[i], "-quartz" ))
-    {
-        return 1;
-    }
-#else
-    if (!strcmp( argv[i], "-fullscreen" ) ||
-        !strcmp( argv[i], "-rootless" ) ||
-        !strcmp( argv[i], "-quartz" ))
-    {
-        FatalError("Command line option %s is not available without Quartz "
-                   "support.\n", argv[i]);
-    }
-#endif
-
-    return 0;
-}
-
-
-/*
- * DarwinModeSystemKeymapSeed
- *  Changes to NXKeyMapping are not tracked.
- */
-unsigned int
-DarwinModeSystemKeymapSeed(void)
-{
-    return 0;
-}
-
-
-/*
- * DarwinModeReadSystemKeymap
- *  IOKit has no alternative to NXKeyMapping API.
- */
-Bool DarwinModeReadSystemKeymap(
-    darwinKeyboardInfo *info)
-{
-    return FALSE;
-}
diff --git a/hw/darwin/quartz/Makefile.am b/hw/darwin/quartz/Makefile.am
index 838af29..44b52e7 100644
--- a/hw/darwin/quartz/Makefile.am
+++ b/hw/darwin/quartz/Makefile.am
@@ -2,13 +2,13 @@ noinst_LIBRARIES = libXQuartz.a
 
 AM_CFLAGS = @XORG_CFLAGS@
 AM_OBJCFLAGS = @XORG_CFLAGS@
-AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../apple -I$(top_srcdir)/miext/rootless @XORG_INCS@ -DXBINDIR=\"${bindir}\" -DHAS_KL_API -DHAVE_XORG_CONFIG_H
+AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/.. -I$(top_srcdir)/miext/rootless @XORG_INCS@ -DXBINDIR=\"${bindir}\" -DHAS_KL_API -DHAVE_XORG_CONFIG_H
 
 SUBDIRS = cr fullscreen xpr
 
 libXQuartz_a_SOURCES = \
-		  ../apple/X11Application.m \
-		  ../apple/X11Controller.m \
+		  X11Application.m \
+		  X11Controller.m \
 	          applewm.c \
 	          keysym2ucs.c \
 	          pseudoramiX.c \
diff --git a/hw/darwin/quartz/Preferences.h b/hw/darwin/quartz/Preferences.h
deleted file mode 100644
index cf43758..0000000
--- a/hw/darwin/quartz/Preferences.h
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (c) 2002-2003 Torrey T. Lyons. 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 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.
- */
-
-#import <Cocoa/Cocoa.h>
-
- at interface Preferences : NSObject
-{
-    IBOutlet NSPanel *window;
-    IBOutlet id displayField;
-    IBOutlet id dockSwitchButton;
-    IBOutlet id fakeButton;
-    IBOutlet id button2ModifiersMatrix;
-    IBOutlet id button3ModifiersMatrix;
-    IBOutlet id switchKeyButton;
-    IBOutlet id keymapFileField;
-    IBOutlet id modeMatrix;
-    IBOutlet id modeWindowButton;
-    IBOutlet id startupHelpButton;
-    IBOutlet id systemBeepButton;
-    IBOutlet id mouseAccelChangeButton;
-    IBOutlet id useXineramaButton;
-    IBOutlet id addToPathButton;
-    IBOutlet id addToPathField;
-    IBOutlet id useDefaultShellMatrix;
-    IBOutlet id useOtherShellField;
-    IBOutlet id depthButton;
-
-    BOOL isGettingKeyCode;
-    int keyCode;
-    int modifiers;
-    NSMutableString *switchString;
-}
-
-- (IBAction)close:(id)sender;
-- (IBAction)pickFile:(id)sender;
-- (IBAction)saveChanges:(id)sender;
-- (IBAction)setKey:(id)sender;
-
-- (BOOL)sendEvent:(NSEvent *)anEvent;
-
-- (void)awakeFromNib;
-- (void)windowWillClose:(NSNotification *)aNotification;
-
-+ (void)setUseKeymapFile:(BOOL)newUseKeymapFile;
-+ (void)setKeymapFile:(NSString *)newFile;
-+ (void)setSwitchString:(NSString *)newString;
-+ (void)setKeyCode:(int)newKeyCode;
-+ (void)setModifiers:(int)newModifiers;
-+ (void)setDisplay:(int)newDisplay;
-+ (void)setDockSwitch:(BOOL)newDockSwitch;
-+ (void)setFakeButtons:(BOOL)newFakeButtons;
-+ (void)setButton2Mask:(int)newFakeMask;
-+ (void)setButton3Mask:(int)newFakeMask;
-+ (void)setMouseAccelChange:(BOOL)newMouseAccelChange;
-+ (void)setUseQDCursor:(int)newUseQDCursor;
-+ (void)setRootless:(BOOL)newRootless;
-+ (void)setUseAGL:(BOOL)newUseAGL;
-+ (void)setModeWindow:(BOOL)newModeWindow;
-+ (void)setStartupHelp:(BOOL)newStartupHelp;
-+ (void)setSystemBeep:(BOOL)newSystemBeep;
-+ (void)setEnableKeyEquivalents:(BOOL)newKeyEquivs;
-+ (void)setXinerama:(BOOL)newXinerama;
-+ (void)setAddToPath:(BOOL)newAddToPath;
-+ (void)setAddToPathString:(NSString *)newAddToPathString;
-+ (void)setUseDefaultShell:(BOOL)newUseDefaultShell;
-+ (void)setShellString:(NSString *)newShellString;
-+ (void)setDepth:(int)newDepth;
-+ (void)setDisplayModeBundles:(NSArray *)newBundles;
-+ (void)saveToDisk;
-
-+ (BOOL)useKeymapFile;
-+ (NSString *)keymapFile;
-+ (NSString *)switchString;
-+ (unsigned int)keyCode;
-+ (unsigned int)modifiers;
-+ (int)display;
-+ (BOOL)dockSwitch;
-+ (BOOL)fakeButtons;
-+ (int)button2Mask;
-+ (int)button3Mask;
-+ (BOOL)mouseAccelChange;
-+ (int)useQDCursor;
-+ (BOOL)rootless;
-+ (BOOL)useAGL;
-+ (BOOL)modeWindow;
-+ (BOOL)startupHelp;
-+ (BOOL)systemBeep;
-+ (BOOL)enableKeyEquivalents;
-+ (BOOL)xinerama;
-+ (BOOL)addToPath;
-+ (NSString *)addToPathString;
-+ (BOOL)useDefaultShell;
-+ (NSString *)shellString;
-+ (int)depth;
-+ (NSArray *)displayModeBundles;
-
- at end
-
-// Possible settings for useQDCursor
-enum {
-    qdCursor_Never,	// never use QuickDraw cursor
-    qdCursor_Not8Bit,	// don't try to use QuickDraw with 8-bit depth
-    qdCursor_Always	// always try to use QuickDraw cursor
-};
-
-// Possible settings for depth
-enum {
-    depth_Current,
-    depth_8Bit,
-    depth_15Bit,
-    depth_24Bit
-};
diff --git a/hw/darwin/quartz/Preferences.m b/hw/darwin/quartz/Preferences.m
deleted file mode 100644
index b5eeedd..0000000
--- a/hw/darwin/quartz/Preferences.m
+++ /dev/null
@@ -1,599 +0,0 @@
-//
-//  Preferences.m
-//
-//  This class keeps track of the user preferences.
-//
-/*
- * Copyright (c) 2002-2004 Torrey T. Lyons. 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 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.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-#import "quartzCommon.h"
-
-#define BOOL xBOOL
-#include "darwin.h"
-#undef BOOL
-
-#import "Preferences.h"
-
-#include <IOKit/hidsystem/IOLLEvent.h>	// for modifier masks
-
-// Macros to build the path name
-#ifndef XBINDIR
-#define XBINDIR /usr/X11/bin
-#endif
-#define STR(s) #s
-#define XSTRPATH(s) STR(s)
-
-// Keys for user defaults dictionary
-static NSString *X11EnableKeyEquivalentsKey = @"EnableKeyEquivalents";
-
-
- at implementation Preferences
-
-+ (void)initialize
-{
-    // Provide user defaults if needed
-    NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys:
-        [NSNumber numberWithInt:0], @"Display",
-        @"YES", @"FakeButtons",
-        [NSNumber numberWithInt:NX_COMMANDMASK], @"Button2Mask",
-        [NSNumber numberWithInt:NX_ALTERNATEMASK], @"Button3Mask",
-        NSLocalizedString(@"USA.keymapping",@""), @"KeymappingFile",
-        @"YES", @"UseKeymappingFile",
-        NSLocalizedString(@"Cmd-Opt-a",@""), @"SwitchString",
-        @"YES", @"UseRootlessMode",
-        @"YES", @"UseAGLforGLX",
-        @"YES", @"ShowModePickWindow",
-        @"YES", @"ShowStartupHelp",
-        [NSNumber numberWithInt:0], @"SwitchKeyCode",
-        [NSNumber numberWithInt:(NSCommandKeyMask | NSAlternateKeyMask)],
-        @"SwitchModifiers", @"NO", @"UseSystemBeep",
-        @"YES", X11EnableKeyEquivalentsKey,
-        @"YES", @"DockSwitch",
-        @"NO", @"AllowMouseAccelChange",
-        [NSNumber numberWithInt:qdCursor_Not8Bit], @"UseQDCursor",
-        @"YES", @"Xinerama",
-        @"YES", @"AddToPath",
-        [NSString stringWithCString:XSTRPATH(XBINDIR)], @"AddToPathString",
-        @"YES", @"UseDefaultShell",
-        @"/bin/tcsh", @"Shell",
-        [NSNumber numberWithInt:depth_Current], @"Depth",
-#ifdef BUILD_XPR
-        [NSArray arrayWithObjects:@"xpr.bundle", @"cr.bundle", nil],
-#else
-        [NSArray arrayWithObjects:@"cr.bundle", nil],
-#endif
-        @"DisplayModeBundles", nil];
-
-    [super initialize];
-    [[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
-}
-
-// Initialize internal state info of switch key button
-- (void)initSwitchKey
-{
-    keyCode = [Preferences keyCode];
-    modifiers = [Preferences modifiers];
-    [switchString setString:[Preferences switchString]];
-}
-
-- (id)init
-{
-    self = [super init];
-
-    isGettingKeyCode=NO;
-    switchString=[[NSMutableString alloc] init];
-    [self initSwitchKey];
-
-    return self;
-}
-
-// Set a modifiers checkbox matrix to match a modifier mask
-- (void)resetMatrix:(NSMatrix *)aMatrix withMask:(int)aMask
-{
-    [aMatrix setState:(aMask & NX_SHIFTMASK)       atRow:0 column:0];
-    [aMatrix setState:(aMask & NX_CONTROLMASK)     atRow:1 column:0];
-    [aMatrix setState:(aMask & NX_COMMANDMASK)     atRow:2 column:0];
-    [aMatrix setState:(aMask & NX_ALTERNATEMASK)   atRow:3 column:0];
-    [aMatrix setState:(aMask & NX_SECONDARYFNMASK) atRow:4 column:0];
-}
-
-// Generate a modifiers mask from a modifiers checkbox matrix
-- (int)getMaskFromMatrix:(NSMatrix *)aMatrix
-{
-    int theMask = 0;
-
-    if ([[aMatrix cellAtRow:0 column:0] state])
-        theMask |= NX_SHIFTMASK;
-    if ([[aMatrix cellAtRow:1 column:0] state])
-        theMask |= NX_CONTROLMASK;
-    if ([[aMatrix cellAtRow:2 column:0] state])
-        theMask |= NX_COMMANDMASK;
-    if ([[aMatrix cellAtRow:3 column:0] state])
-        theMask |= NX_ALTERNATEMASK;
-    if ([[aMatrix cellAtRow:4 column:0] state])
-        theMask |= NX_SECONDARYFNMASK;
-
-    return theMask;
-}
-
-// Set the window controls to the state in user defaults
-- (void)resetWindow
-{
-    if ([Preferences keymapFile] == nil)
-        [keymapFileField setStringValue:@" "];
-    else
-        [keymapFileField setStringValue:[Preferences keymapFile]];
-
-    if ([Preferences switchString] == nil)
-        [switchKeyButton setTitle:@"--"];
-    else
-        [switchKeyButton setTitle:[Preferences switchString]];
-
-    [displayField setIntValue:[Preferences display]];
-    [dockSwitchButton setIntValue:[Preferences dockSwitch]];
-    [fakeButton setIntValue:[Preferences fakeButtons]];
-    [self resetMatrix:button2ModifiersMatrix
-          withMask:[Preferences button2Mask]];
-    [self resetMatrix:button3ModifiersMatrix
-          withMask:[Preferences button3Mask]];
-    [modeMatrix setState:[Preferences rootless] atRow:0 column:1];
-    [startupHelpButton setIntValue:[Preferences startupHelp]];
-    [modeWindowButton setIntValue:[Preferences modeWindow]];
-    [systemBeepButton setIntValue:[Preferences systemBeep]];
-    [mouseAccelChangeButton setIntValue:[Preferences mouseAccelChange]];
-    [useXineramaButton setIntValue:[Preferences xinerama]];
-    [addToPathButton setIntValue:[Preferences addToPath]];
-    [addToPathField setStringValue:[Preferences addToPathString]];
-    [useDefaultShellMatrix setState:![Preferences useDefaultShell]
-                           atRow:1 column:0];
-    [useOtherShellField setStringValue:[Preferences shellString]];
-    [depthButton selectItemAtIndex:[Preferences depth]];
-}
-
-- (void)awakeFromNib
-{
-    [self resetWindow];
-}
-
-// Preference window delegate
-- (void)windowWillClose:(NSNotification *)aNotification
-{
-    [self resetWindow];
-    [self initSwitchKey];
-}
-
-// User cancelled the changes
-- (IBAction)close:(id)sender
-{
-    [window orderOut:nil];
-    [self resetWindow];  	// reset window controls
-    [self initSwitchKey];	// reset switch key state
-}
-
-// Pick keymapping file
-- (IBAction)pickFile:(id)sender
-{
-    int result;
-    NSArray *fileTypes = [NSArray arrayWithObject:@"keymapping"];
-    NSOpenPanel *oPanel = [NSOpenPanel openPanel];
-
-    [oPanel setAllowsMultipleSelection:NO];
-    result = [oPanel runModalForDirectory:@"/System/Library/Keyboards"
-                     file:nil types:fileTypes];
-    if (result == NSOKButton) {
-        [keymapFileField setStringValue:[oPanel filename]];
-    }
-}
-
-// User saved changes
-- (IBAction)saveChanges:(id)sender
-{
-    [Preferences setKeyCode:keyCode];
-    [Preferences setModifiers:modifiers];
-    [Preferences setSwitchString:switchString];
-    [Preferences setKeymapFile:[keymapFileField stringValue]];
-    [Preferences setUseKeymapFile:YES];
-    [Preferences setDisplay:[displayField intValue]];
-    [Preferences setDockSwitch:[dockSwitchButton intValue]];
-    [Preferences setFakeButtons:[fakeButton intValue]];
-    [Preferences setButton2Mask:
-                    [self getMaskFromMatrix:button2ModifiersMatrix]];
-    [Preferences setButton3Mask:
-                    [self getMaskFromMatrix:button3ModifiersMatrix]];
-    [Preferences setRootless:[[modeMatrix cellAtRow:0 column:1] state]];
-    [Preferences setModeWindow:[modeWindowButton intValue]];
-    [Preferences setStartupHelp:[startupHelpButton intValue]];
-    [Preferences setSystemBeep:[systemBeepButton intValue]];
-    [Preferences setMouseAccelChange:[mouseAccelChangeButton intValue]];
-    [Preferences setXinerama:[useXineramaButton intValue]];
-    [Preferences setAddToPath:[addToPathButton intValue]];
-    [Preferences setAddToPathString:[addToPathField stringValue]];
-    [Preferences setUseDefaultShell:
-                    [[useDefaultShellMatrix cellAtRow:0 column:0] state]];
-    [Preferences setShellString:[useOtherShellField stringValue]];
-    [Preferences setDepth:[depthButton indexOfSelectedItem]];
-    [Preferences saveToDisk];
-
-    [window orderOut:nil];
-}
-
-- (IBAction)setKey:(id)sender
-{
-    [switchKeyButton setTitle:NSLocalizedString(@"Press key",@"")];
-    isGettingKeyCode=YES;
-    [switchString setString:@""];
-}
-
-- (BOOL)sendEvent:(NSEvent *)anEvent
-{
-    if(isGettingKeyCode) {
-        if([anEvent type]==NSKeyDown) // wait for keyup
-            return YES;
-        if([anEvent type]!=NSKeyUp)
-            return NO;
-
-        if([anEvent modifierFlags] & NSCommandKeyMask)
-            [switchString appendString:@"Cmd-"];
-        if([anEvent modifierFlags] & NSControlKeyMask)
-            [switchString appendString:@"Ctrl-"];
-        if([anEvent modifierFlags] & NSAlternateKeyMask)
-            [switchString appendString:@"Opt-"];
-        if([anEvent modifierFlags] & NSNumericPadKeyMask) // doesn't work
-            [switchString appendString:@"Num-"];
-        if([anEvent modifierFlags] & NSHelpKeyMask)
-            [switchString appendString:@"Help-"];
-        if([anEvent modifierFlags] & NSFunctionKeyMask) // powerbooks only
-            [switchString appendString:@"Fn-"];
-        
-        [switchString appendString:[anEvent charactersIgnoringModifiers]];
-        [switchKeyButton setTitle:switchString];
-        
-        keyCode = [anEvent keyCode];
-        modifiers = [anEvent modifierFlags];
-        isGettingKeyCode=NO;
-        
-        return YES;
-    }
-    return NO;
-}
-
-+ (void)setKeymapFile:(NSString *)newFile
-{
-    [[NSUserDefaults standardUserDefaults] setObject:newFile
-            forKey:@"KeymappingFile"];
-}
-
-+ (void)setUseKeymapFile:(BOOL)newUseKeymapFile
-{
-    [[NSUserDefaults standardUserDefaults] setBool:newUseKeymapFile
-            forKey:@"UseKeymappingFile"];
-}
-
-+ (void)setSwitchString:(NSString *)newString
-{
-    [[NSUserDefaults standardUserDefaults] setObject:newString
-            forKey:@"SwitchString"];
-}
-
-+ (void)setKeyCode:(int)newKeyCode
-{
-    [[NSUserDefaults standardUserDefaults] setInteger:newKeyCode
-            forKey:@"SwitchKeyCode"];
-}
-
-+ (void)setModifiers:(int)newModifiers
-{
-    [[NSUserDefaults standardUserDefaults] setInteger:newModifiers
-            forKey:@"SwitchModifiers"];
-}
-
-+ (void)setDisplay:(int)newDisplay
-{
-    [[NSUserDefaults standardUserDefaults] setInteger:newDisplay
-            forKey:@"Display"];
-}
-
-+ (void)setDockSwitch:(BOOL)newDockSwitch
-{
-    [[NSUserDefaults standardUserDefaults] setBool:newDockSwitch
-            forKey:@"DockSwitch"];
-}
-
-+ (void)setFakeButtons:(BOOL)newFakeButtons
-{
-    [[NSUserDefaults standardUserDefaults] setBool:newFakeButtons
-            forKey:@"FakeButtons"];
-    // Update the setting used by the X server thread
-    darwinFakeButtons = newFakeButtons;
-}
-
-+ (void)setButton2Mask:(int)newFakeMask
-{
-    [[NSUserDefaults standardUserDefaults] setInteger:newFakeMask
-            forKey:@"Button2Mask"];
-    // Update the setting used by the X server thread
-    darwinFakeMouse2Mask = newFakeMask;
-}
-
-+ (void)setButton3Mask:(int)newFakeMask
-{
-    [[NSUserDefaults standardUserDefaults] setInteger:newFakeMask
-            forKey:@"Button3Mask"];
-    // Update the setting used by the X server thread
-    darwinFakeMouse3Mask = newFakeMask;
-}
-
-+ (void)setMouseAccelChange:(BOOL)newMouseAccelChange
-{
-    [[NSUserDefaults standardUserDefaults] setBool:newMouseAccelChange
-            forKey:@"AllowMouseAccelChange"];
-    // Update the setting used by the X server thread
-    darwinMouseAccelChange = newMouseAccelChange;
-}
-
-+ (void)setUseQDCursor:(int)newUseQDCursor
-{
-    [[NSUserDefaults standardUserDefaults] setInteger:newUseQDCursor
-            forKey:@"UseQDCursor"];
-}
-
-+ (void)setModeWindow:(BOOL)newModeWindow
-{
-    [[NSUserDefaults standardUserDefaults] setBool:newModeWindow
-            forKey:@"ShowModePickWindow"];
-}
-
-+ (void)setRootless:(BOOL)newRootless
-{
-    [[NSUserDefaults standardUserDefaults] setBool:newRootless
-            forKey:@"UseRootlessMode"];
-}
-
-+ (void)setUseAGL:(BOOL)newUseAGL
-{
-    [[NSUserDefaults standardUserDefaults] setBool:newUseAGL
-            forKey:@"UseAGLforGLX"];
-}
-
-+ (void)setStartupHelp:(BOOL)newStartupHelp
-{
-    [[NSUserDefaults standardUserDefaults] setBool:newStartupHelp
-            forKey:@"ShowStartupHelp"];
-}
-
-+ (void)setSystemBeep:(BOOL)newSystemBeep
-{
-    [[NSUserDefaults standardUserDefaults] setBool:newSystemBeep
-            forKey:@"UseSystemBeep"];
-    // Update the setting used by the X server thread
-    quartzUseSysBeep = newSystemBeep;
-}
-
-+ (void)setEnableKeyEquivalents:(BOOL)newKeyEquivs
-{
-    [[NSUserDefaults standardUserDefaults] setBool:newKeyEquivs
-            forKey:X11EnableKeyEquivalentsKey];
-    // Update the setting used by the X server thread
-    quartzEnableKeyEquivalents = newKeyEquivs;
-}
-
-+ (void)setXinerama:(BOOL)newXinerama
-{
-    [[NSUserDefaults standardUserDefaults] setBool:newXinerama
-            forKey:@"Xinerama"];
-}
-
-+ (void)setAddToPath:(BOOL)newAddToPath
-{
-    [[NSUserDefaults standardUserDefaults] setBool:newAddToPath
-            forKey:@"AddToPath"];
-}
-
-+ (void)setAddToPathString:(NSString *)newAddToPathString
-{
-    [[NSUserDefaults standardUserDefaults] setObject:newAddToPathString
-            forKey:@"AddToPathString"];
-}
-
-+ (void)setUseDefaultShell:(BOOL)newUseDefaultShell
-{
-    [[NSUserDefaults standardUserDefaults] setBool:newUseDefaultShell
-            forKey:@"UseDefaultShell"];
-}
-
-+ (void)setShellString:(NSString *)newShellString
-{
-    [[NSUserDefaults standardUserDefaults] setObject:newShellString
-            forKey:@"Shell"];
-}
-
-+ (void)setDepth:(int)newDepth
-{
-    [[NSUserDefaults standardUserDefaults] setInteger:newDepth
-            forKey:@"Depth"];
-}
-
-+ (void)setDisplayModeBundles:(NSArray *)newBundles
-{
-    [[NSUserDefaults standardUserDefaults] setObject:newBundles
-            forKey:@"DisplayModeBundles"];
-}
-
-+ (void)saveToDisk
-{
-    [[NSUserDefaults standardUserDefaults] synchronize];
-}
-
-+ (BOOL)useKeymapFile
-{
-    return [[NSUserDefaults standardUserDefaults]
-                boolForKey:@"UseKeymappingFile"];
-}
-
-+ (NSString *)keymapFile
-{
-    return [[NSUserDefaults standardUserDefaults]
-                stringForKey:@"KeymappingFile"];
-}
-
-+ (NSString *)switchString
-{
-    return [[NSUserDefaults standardUserDefaults]
-                stringForKey:@"SwitchString"];
-}
-
-+ (unsigned int)keyCode
-{
-    return [[NSUserDefaults standardUserDefaults]
-                integerForKey:@"SwitchKeyCode"];
-}
-
-+ (unsigned int)modifiers
-{
-    return [[NSUserDefaults standardUserDefaults]
-                integerForKey:@"SwitchModifiers"];
-}
-
-+ (int)display
-{
-    return [[NSUserDefaults standardUserDefaults]
-                integerForKey:@"Display"];
-}
-
-+ (BOOL)dockSwitch
-{
-    return [[NSUserDefaults standardUserDefaults] boolForKey:@"DockSwitch"];
-}
-
-+ (BOOL)fakeButtons
-{
-    return [[NSUserDefaults standardUserDefaults] boolForKey:@"FakeButtons"];
-}
-
-+ (int)button2Mask
-{
-    return [[NSUserDefaults standardUserDefaults]
-                integerForKey:@"Button2Mask"];
-}
-
-+ (int)button3Mask
-{
-    return [[NSUserDefaults standardUserDefaults]
-                integerForKey:@"Button3Mask"];
-}
-
-+ (BOOL)mouseAccelChange
-{
-    return [[NSUserDefaults standardUserDefaults]
-                boolForKey:@"AllowMouseAccelChange"];
-}
-
-+ (int)useQDCursor
-{
-    return [[NSUserDefaults standardUserDefaults]
-                integerForKey:@"UseQDCursor"];
-}
-
-+ (BOOL)rootless
-{
-    return [[NSUserDefaults standardUserDefaults]
-                boolForKey:@"UseRootlessMode"];
-}
-
-+ (BOOL)useAGL
-{
-    return [[NSUserDefaults standardUserDefaults]
-                boolForKey:@"UseAGLforGLX"];
-}
-
-+ (BOOL)modeWindow
-{
-    return [[NSUserDefaults standardUserDefaults]
-                boolForKey:@"ShowModePickWindow"];
-}
-
-+ (BOOL)startupHelp
-{
-    return [[NSUserDefaults standardUserDefaults]
-                boolForKey:@"ShowStartupHelp"];
-}
-
-+ (BOOL)systemBeep
-{
-    return [[NSUserDefaults standardUserDefaults] boolForKey:@"UseSystemBeep"];
-}
-
-+ (BOOL)enableKeyEquivalents
-{
-    return [[NSUserDefaults standardUserDefaults] boolForKey:X11EnableKeyEquivalentsKey];
-}
-
-+ (BOOL)xinerama
-{
-    return [[NSUserDefaults standardUserDefaults] boolForKey:@"Xinerama"];
-}
-
-+ (BOOL)addToPath
-{
-    return [[NSUserDefaults standardUserDefaults] boolForKey:@"AddToPath"];
-}
-
-+ (NSString *)addToPathString
-{
-    return [[NSUserDefaults standardUserDefaults]
-                stringForKey:@"AddToPathString"];
-}
-
-+ (BOOL)useDefaultShell
-{
-    return [[NSUserDefaults standardUserDefaults]
-                boolForKey:@"UseDefaultShell"];
-}
-
-+ (NSString *)shellString
-{
-    return [[NSUserDefaults standardUserDefaults]
-                stringForKey:@"Shell"];
-}
-
-+ (int)depth
-{
-    return [[NSUserDefaults standardUserDefaults]
-                integerForKey:@"Depth"];
-}
-
-+ (NSArray *)displayModeBundles
-{
-    return [[NSUserDefaults standardUserDefaults]
-                objectForKey:@"DisplayModeBundles"];
-}
-
- at end
diff --git a/hw/darwin/quartz/X11Application.h b/hw/darwin/quartz/X11Application.h
new file mode 100644
index 0000000..fb153e7
--- /dev/null
+++ b/hw/darwin/quartz/X11Application.h
@@ -0,0 +1,104 @@
+/* X11Application.h -- subclass of NSApplication to multiplex events
+   $Id: X11Application.h,v 1.26 2003/08/08 19:16:13 jharper Exp $
+
+   Copyright (c) 2002-2007 Apple Inc. 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 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 X11APPLICATION_H
+#define X11APPLICATION_H 1
+
+#if __OBJC__
+
+#import <Cocoa/Cocoa.h>
+#import "X11Controller.h"
+
+ at interface X11Application : NSApplication {
+    X11Controller *_controller;
+
+    unsigned int _x_active :1;
+}
+
+- (void) set_controller:controller;
+- (void) set_window_menu:(NSArray *)list;
+
+- (int) prefs_get_integer:(NSString *)key default:(int)def;
+- (const char *) prefs_get_string:(NSString *)key default:(const char *)def;
+- (float) prefs_get_float:(NSString *)key default:(float)def;
+- (int) prefs_get_boolean:(NSString *)key default:(int)def;
+- (NSArray *) prefs_get_array:(NSString *)key;
+- (void) prefs_set_integer:(NSString *)key value:(int)value;
+- (void) prefs_set_float:(NSString *)key value:(float)value;
+- (void) prefs_set_boolean:(NSString *)key value:(int)value;
+- (void) prefs_set_array:(NSString *)key value:(NSArray *)value;
+- (void) prefs_set_string:(NSString *)key value:(NSString *)value;
+- (void) prefs_synchronize;
+
+- (BOOL) x_active;
+
+ at end
+
+extern X11Application *X11App;
+
+#endif /* __OBJC__ */
+
+extern void X11ApplicationSetWindowMenu (int nitems, const char **items,
+					 const char *shortcuts);
+extern void X11ApplicationSetWindowMenuCheck (int idx);
+extern void X11ApplicationSetFrontProcess (void);
+extern void X11ApplicationSetCanQuit (int state);
+extern void X11ApplicationServerReady (void);
+extern void X11ApplicationShowHideMenubar (int state);
+
+extern void X11ApplicationMain (int argc, const char *argv[],
+				void (*server_thread) (void *),
+				void *server_arg);
+
+extern int X11EnableKeyEquivalents;
+extern int quartzHasRoot, quartzEnableRootless;
+
+#define APP_PREFS "org.x.X11"
+
+#define PREFS_APPSMENU		"apps_menu"
+#define PREFS_FAKEBUTTONS	"enable_fake_buttons"
+#define PREFS_SYSBEEP		"enable_system_beep"
+#define PREFS_KEYEQUIVS		"enable_key_equivalents"
+#define PREFS_KEYMAP_FILE	"keymap_file"
+#define PREFS_SYNC_KEYMAP	"sync_keymap"
+#define PREFS_DEPTH		"depth"
+#define PREFS_NO_AUTH		"no_auth"
+#define PREFS_NO_TCP		"nolisten_tcp"
+#define PREFS_DONE_XINIT_CHECK	"done_xinit_check"
+#define PREFS_NO_QUIT_ALERT	"no_quit_alert"
+#define PREFS_FAKE_BUTTON2	"fake_button2"
+#define PREFS_FAKE_BUTTON3	"fake_button3"
+#define PREFS_ROOTLESS		"rootless"
+#define PREFS_FULLSCREEN_HOTKEYS "fullscreen_hotkeys"
+#define PREFS_SWAP_ALT_META	"swap_alt_meta"
+#define PREFS_XP_OPTIONS	"xp_options"
+#define PREFS_ENABLE_STEREO	"enable_stereo"
+
+#endif /* X11APPLICATION_H */
diff --git a/hw/darwin/quartz/X11Application.m b/hw/darwin/quartz/X11Application.m
new file mode 100644
index 0000000..ae6f4bc
--- /dev/null
+++ b/hw/darwin/quartz/X11Application.m
@@ -0,0 +1,1088 @@
+/* X11Application.m -- subclass of NSApplication to multiplex events
+ 
+ Copyright (c) 2002-2007 Apple Inc. 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 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 "../quartz/quartzCommon.h"
+
+#import "X11Application.h"
+#include <Carbon/Carbon.h>
+
+/* ouch! */
+#define BOOL X_BOOL
+//# include "Xproto.h"
+# include "darwin.h"
+# include "../quartz/quartz.h"
+# define _APPLEWM_SERVER_
+# include "X11/extensions/applewm.h"
+//# include "X.h"
+# include "micmap.h"
+#undef BOOL
+
+#include <mach/mach.h>
+#include <unistd.h>
+#include <pthread.h>
+
+#include "rootlessCommon.h"
+
+WindowPtr xprGetXWindowFromAppKit(int windowNumber); // xpr/xprFrame.c
+
+#define DEFAULTS_FILE "/usr/X11/lib/X11/xserver/Xquartz.plist"
+
+int X11EnableKeyEquivalents = TRUE;
+int quartzHasRoot = FALSE, quartzEnableRootless = TRUE;
+
+extern int darwinFakeButtons;
+extern Bool enable_stereo; 
+
+X11Application *X11App;
+
+#define ALL_KEY_MASKS (NSShiftKeyMask | NSControlKeyMask \
+| NSAlternateKeyMask | NSCommandKeyMask)
+
+ at implementation X11Application
+
+typedef struct message_struct message;
+struct message_struct {
+    mach_msg_header_t hdr;
+    SEL selector;
+    NSObject *arg;
+};
+
+static mach_port_t _port;
+
+static void send_nsevent (NSEventType type, NSEvent *e);
+
+/* Quartz mode initialization routine. This is often dynamically loaded
+ but is statically linked into this X server. */
+extern Bool QuartzModeBundleInit(void);
+
+static void
+init_ports (void)
+{
+    kern_return_t r;
+    NSPort *p;
+	
+    if (_port != MACH_PORT_NULL)
+		return;
+	
+    r = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, &_port);
+    if (r != KERN_SUCCESS)
+		return;
+	
+    p = [NSMachPort portWithMachPort:_port];
+    [p setDelegate:NSApp];
+    [p scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
+}
+
+static void
+message_kit_thread (SEL selector, NSObject *arg)
+{
+    message msg;
+    kern_return_t r;
+	
+    msg.hdr.msgh_bits = MACH_MSGH_BITS (MACH_MSG_TYPE_MAKE_SEND, 0);
+    msg.hdr.msgh_size = sizeof (msg);
+    msg.hdr.msgh_remote_port = _port;
+    msg.hdr.msgh_local_port = MACH_PORT_NULL;
+    msg.hdr.msgh_reserved = 0;
+    msg.hdr.msgh_id = 0;
+	
+    msg.selector = selector;
+    msg.arg = [arg retain];
+	
+    r = mach_msg (&msg.hdr, MACH_SEND_MSG, msg.hdr.msgh_size,
+				  0, MACH_PORT_NULL, 0, MACH_PORT_NULL);
+    if (r != KERN_SUCCESS)
+		fprintf (stderr, "%s: mach_msg failed: %x\n", __FUNCTION__, r);
+}
+
+- (void) handleMachMessage:(void *)_msg
+{
+    message *msg = _msg;
+	
+    [self performSelector:msg->selector withObject:msg->arg];
+    [msg->arg release];
+}
+
+- (void) set_controller:obj
+{
+    if (_controller == nil)
+		_controller = [obj retain];
+}
+
+- (void) dealloc
+{
+    if (_controller != nil)
+		[_controller release];
+	
+    if (_port != MACH_PORT_NULL)
+		mach_port_deallocate (mach_task_self (), _port);
+	
+    [super dealloc];
+}
+
+- (void) orderFrontStandardAboutPanel: (id) sender
+{
+    NSMutableDictionary *dict;
+    NSDictionary *infoDict;
+    NSString *tem;
+	
+    dict = [NSMutableDictionary dictionaryWithCapacity:2];
+    infoDict = [[NSBundle mainBundle] infoDictionary];
+	
+    [dict setObject: NSLocalizedString (@"The X Window System", @"About panel")
+			 forKey:@"ApplicationName"];
+	
+    tem = [infoDict objectForKey:@"CFBundleShortVersionString"];
+	
+    [dict setObject:[NSString stringWithFormat:@"X11.app %@ - X.org X11R7.2",
+					 tem] forKey:@"ApplicationVersion"];
+	
+    [self orderFrontStandardAboutPanelWithOptions: dict];
+}
+
+- (void) activateX:(BOOL)state
+{
+    /* Create a TSM document that supports full Unicode input, and
+	 have it activated while X is active (unless using the old
+	 keymapping files) */
+    static TSMDocumentID x11_document;
+	
+    if (state)
+    {
+		QuartzMessageServerThread (kXDarwinActivate, 0);
+		
+		if (!_x_active)
+		{
+			if (x11_document == 0 && darwinKeymapFile == NULL)
+			{
+				OSType types[1];
+				types[0] = kUnicodeDocument;
+				NewTSMDocument (1, types, &x11_document, 0);
+			}
+			
+			if (x11_document != 0)
+				ActivateTSMDocument (x11_document);
+		}
+    }
+    else
+    {
+		QuartzMessageServerThread (kXDarwinDeactivate, 0);
+		
+		if (_x_active)
+		{
+			if (x11_document != 0)
+				DeactivateTSMDocument (x11_document);
+		}
+    }
+	
+    _x_active = state;
+}
+
+- (void) became_key:(NSWindow *)win
+{
+    [self activateX:NO];
+}
+
+- (void) sendEvent:(NSEvent *)e
+{
+  NSEventType type;
+  BOOL for_appkit, for_x;
+  
+  type = [e type];
+  
+  /* By default pass down the responder chain and to X. */
+  for_appkit = YES;
+  for_x = YES;
+  
+  switch (type) {
+  case NSLeftMouseDown: case NSRightMouseDown: case NSOtherMouseDown:
+  case NSLeftMouseUp: case NSRightMouseUp: case NSOtherMouseUp:
+    if ([e window] != nil) {
+      /* Pointer event has an (AppKit) window. Probably something for the kit. */
+      for_x = NO;
+      if (_x_active) [self activateX:NO];
+    } else if ([self modalWindow] == nil) {
+      /* Must be an X window. Tell appkit it doesn't have focus. */
+      WindowPtr pWin = xprGetXWindowFromAppKit([e windowNumber]);
+      if (pWin) RootlessReorderWindow(pWin);
+      for_appkit = NO;
+      
+      if ([self isActive]) {
+	[self deactivate];
+	
+	if (!_x_active && quartzProcs->IsX11Window([e window],
+						   [e windowNumber]))
+	  [self activateX:YES];
+      }
+    }
+    break;
+		
+    case NSKeyDown: case NSKeyUp:
+      if (_x_active) {
+	static int swallow_up;
+	
+	/* No kit window is focused, so send it to X. */
+	for_appkit = NO;
+	if (type == NSKeyDown) {
+	  /* Before that though, see if there are any global
+	     shortcuts bound to it. */
+	  
+	  if (X11EnableKeyEquivalents
+	      && [[self mainMenu] performKeyEquivalent:e]) {
+	    swallow_up = [e keyCode];
+	    for_x = NO;
+	  } else if (!quartzEnableRootless
+		     && ([e modifierFlags] & ALL_KEY_MASKS)
+		     == (NSCommandKeyMask | NSAlternateKeyMask)
+		     && ([e keyCode] == 0 /*a*/
+		      || [e keyCode] == 53 /*Esc*/)) {
+	    swallow_up = 0;
+	    for_x = NO;
+#ifdef DARWIN_DDX_MISSING
+	    QuartzMessageServerThread (kXDarwinToggleFullscreen, 0);
+#endif
+	  }
+	} else  {
+	  /* If we saw a key equivalent on the down, don't pass
+	     the up through to X. */
+	  
+	  if (swallow_up != 0 && [e keyCode] == swallow_up) {
+	    swallow_up = 0;
+	    for_x = NO;
+	  }
+	}
+      } else for_x = NO;
+      break;
+      
+  case NSFlagsChanged:
+    /* For the l33t X users who remap modifier keys to normal keysyms. */
+    if (!_x_active) for_x = NO;
+    break;
+    
+  case NSAppKitDefined:
+    switch ([e subtype]) {
+    case NSApplicationActivatedEventType:
+      for_x = NO;
+      if ([self modalWindow] == nil) {
+	for_appkit = NO;
+	
+	/* FIXME: hack to avoid having to pass the event to appkit,
+	   which would cause it to raise one of its windows. */
+	_appFlags._active = YES;
+	    
+	[self activateX:YES];
+	if ([e data2] & 0x10) X11ApplicationSetFrontProcess();
+      }
+      break;
+	
+      case 18: /* ApplicationDidReactivate */
+	if (quartzHasRoot) for_appkit = NO;
+	break;
+	
+    case NSApplicationDeactivatedEventType:
+      for_x = NO;
+      [self activateX:NO];
+      break;
+    }
+    break;
+    
+  default: break; /* for gcc */
+  }
+  
+  if (for_appkit) [super sendEvent:e];
+  
+  if (for_x) send_nsevent (type, e);
+}
+
+- (void) set_window_menu:(NSArray *)list
+{
+    [_controller set_window_menu:list];
+}
+
+- (void) set_window_menu_check:(NSNumber *)n
+{
+    [_controller set_window_menu_check:n];
+}
+
+- (void) set_apps_menu:(NSArray *)list
+{
+    [_controller set_apps_menu:list];
+}
+
+- (void) set_front_process:unused
+{
+    QuartzMessageServerThread(kXDarwinBringAllToFront, 0);
+}
+
+- (void) set_can_quit:(NSNumber *)state
+{
+    [_controller set_can_quit:[state boolValue]];
+}
+
+- (void) server_ready:unused
+{
+    [_controller server_ready];
+}
+
+- (void) show_hide_menubar:(NSNumber *)state
+{
+    if ([state boolValue])
+		ShowMenuBar ();
+    else
+		HideMenuBar ();
+}
+
+
+/* user preferences */
+
+/* Note that these functions only work for arrays whose elements
+ can be toll-free-bridged between NS and CF worlds. */
+
+static const void *cfretain (CFAllocatorRef a, const void *b) {
+    return CFRetain (b);
+}
+
+static void cfrelease (CFAllocatorRef a, const void *b) {
+    CFRelease (b);
+}
+
+static CFMutableArrayRef
+nsarray_to_cfarray (NSArray *in)
+{
+    CFMutableArrayRef out;
+    CFArrayCallBacks cb;
+    NSObject *ns;
+    const CFTypeRef *cf;
+    int i, count;
+	
+    memset (&cb, 0, sizeof (cb));
+    cb.version = 0;
+    cb.retain = cfretain;
+    cb.release = cfrelease;
+	
+    count = [in count];
+    out = CFArrayCreateMutable (NULL, count, &cb);
+	
+    for (i = 0; i < count; i++)
+    {
+		ns = [in objectAtIndex:i];
+		
+		if ([ns isKindOfClass:[NSArray class]])
+			cf = (CFTypeRef) nsarray_to_cfarray ((NSArray *) ns);
+		else
+			cf = CFRetain ((CFTypeRef) ns);
+		
+		CFArrayAppendValue (out, cf);
+		CFRelease (cf);
+    }
+	
+    return out;
+}
+static NSMutableArray *
+cfarray_to_nsarray (CFArrayRef in)
+{
+    NSMutableArray *out;
+    const CFTypeRef *cf;
+    NSObject *ns;
+    int i, count;
+	
+    count = CFArrayGetCount (in);
+    out = [[NSMutableArray alloc] initWithCapacity:count];
+	
+    for (i = 0; i < count; i++)
+    {
+		cf = CFArrayGetValueAtIndex (in, i);
+		
+		if (CFGetTypeID (cf) == CFArrayGetTypeID ())
+			ns = cfarray_to_nsarray ((CFArrayRef) cf);
+		else
+			ns = [(id)cf retain];
+		
+		[out addObject:ns];
+		[ns release];
+    }
+	
+    return out;
+}
+
+- (CFPropertyListRef) prefs_get:(NSString *)key
+{
+    CFPropertyListRef value;
+	
+    value = CFPreferencesCopyAppValue ((CFStringRef) key, CFSTR (APP_PREFS));
+	
+    if (value == NULL)
+    {
+		static CFDictionaryRef defaults;
+		
+		if (defaults == NULL)
+		{
+			CFStringRef error = NULL;
+			CFDataRef data;
+			CFURLRef url;
+			SInt32 error_code;
+			
+			url = (CFURLCreateFromFileSystemRepresentation
+				   (NULL, (unsigned char *)DEFAULTS_FILE, strlen (DEFAULTS_FILE), false));
+			if (CFURLCreateDataAndPropertiesFromResource (NULL, url, &data,
+														  NULL, NULL,
+														  &error_code))
+			{
+				defaults = (CFPropertyListCreateFromXMLData
+							(NULL, data, kCFPropertyListMutableContainersAndLeaves, &error));
+				if (error != NULL)
+					CFRelease (error);
+				CFRelease (data);
+			}
+			CFRelease (url);
+			
+			if (defaults != NULL)
+			{
+				NSMutableArray *apps, *elt;
+				int count, i;
+				NSString *name, *nname;
+				
+				/* Localize the names in the default apps menu. */
+				
+				apps = [(NSDictionary *)defaults objectForKey:@PREFS_APPSMENU];
+				if (apps != nil)
+				{
+					count = [apps count];
+					for (i = 0; i < count; i++)
+					{
+						elt = [apps objectAtIndex:i];
+						if (elt != nil && [elt isKindOfClass:[NSArray class]])
+						{
+							name = [elt objectAtIndex:0];
+							if (name != nil)
+							{
+								nname = NSLocalizedString (name, nil);
+								if (nname != nil && nname != name)
+									[elt replaceObjectAtIndex:0 withObject:nname];
+							}
+						}
+					}
+				}
+			}
+		}
+		
+		if (defaults != NULL)
+			value = CFDictionaryGetValue (defaults, key);
+		
+		if (value != NULL)
+			CFRetain (value);
+    }
+	
+    return value;
+}
+
+- (int) prefs_get_integer:(NSString *)key default:(int)def
+{
+    CFPropertyListRef value;
+    int ret;
+	
+    value = [self prefs_get:key];
+	
+    if (value != NULL && CFGetTypeID (value) == CFNumberGetTypeID ())
+		CFNumberGetValue (value, kCFNumberIntType, &ret);
+    else if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ())
+		ret = CFStringGetIntValue (value);
+    else
+		ret = def;
+	
+    if (value != NULL)
+		CFRelease (value);
+	
+    return ret;
+}
+
+- (const char *) prefs_get_string:(NSString *)key default:(const char *)def
+{
+    CFPropertyListRef value;
+    const char *ret = NULL;
+	
+    value = [self prefs_get:key];
+	
+    if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ())
+    {
+		NSString *s = (NSString *) value;
+		
+		ret = [s UTF8String];
+    }
+	
+    if (value != NULL)
+		CFRelease (value);
+	
+    return ret != NULL ? ret : def;
+}
+
+- (float) prefs_get_float:(NSString *)key default:(float)def
+{
+    CFPropertyListRef value;
+    float ret = def;
+	
+    value = [self prefs_get:key];
+	
+    if (value != NULL
+		&& CFGetTypeID (value) == CFNumberGetTypeID ()
+		&& CFNumberIsFloatType (value))
+    {
+		CFNumberGetValue (value, kCFNumberFloatType, &ret);
+    }
+    else if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ())
+    {
+		ret = CFStringGetDoubleValue (value);
+    }
+	
+    if (value != NULL)
+		CFRelease (value);
+	
+    return ret;
+}
+
+- (int) prefs_get_boolean:(NSString *)key default:(int)def
+{
+    CFPropertyListRef value;
+    int ret = def;
+	
+    value = [self prefs_get:key];
+	
+    if (value != NULL)
+    {
+		if (CFGetTypeID (value) == CFNumberGetTypeID ())
+			CFNumberGetValue (value, kCFNumberIntType, &ret);
+		else if (CFGetTypeID (value) == CFBooleanGetTypeID ())
+			ret = CFBooleanGetValue (value);
+		else if (CFGetTypeID (value) == CFStringGetTypeID ())
+		{
+			const char *tem = [(NSString *) value UTF8String];
+			if (strcasecmp (tem, "true") == 0 || strcasecmp (tem, "yes") == 0)
+				ret = YES;
+			else
+				ret = NO;
+		}
+		
+		CFRelease (value);
+    }
+	
+    return ret;
+}
+
+- (NSArray *) prefs_get_array:(NSString *)key
+{
+    NSArray *ret = nil;
+    CFPropertyListRef value;
+	
+    value = [self prefs_get:key];
+	
+    if (value != NULL)
+    {
+		if (CFGetTypeID (value) == CFArrayGetTypeID ())
+			ret = [cfarray_to_nsarray (value) autorelease];
+		
+		CFRelease (value);
+    }
+	
+    return ret;
+}
+
+- (void) prefs_set_integer:(NSString *)key value:(int)value
+{
+    CFNumberRef x;
+	
+    x = CFNumberCreate (NULL, kCFNumberIntType, &value);
+	
+    CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) x, CFSTR (APP_PREFS),
+						   kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+	
+    CFRelease (x);
+}
+
+- (void) prefs_set_float:(NSString *)key value:(float)value
+{
+    CFNumberRef x;
+	
+    x = CFNumberCreate (NULL, kCFNumberFloatType, &value);
+	
+    CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) x, CFSTR (APP_PREFS),
+						   kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+	
+    CFRelease (x);
+}
+
+- (void) prefs_set_boolean:(NSString *)key value:(int)value
+{
+    CFPreferencesSetValue ((CFStringRef) key,
+						   (CFTypeRef) value ? kCFBooleanTrue
+						   : kCFBooleanFalse, CFSTR (APP_PREFS),
+						   kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+	
+}
+
+- (void) prefs_set_array:(NSString *)key value:(NSArray *)value
+{
+    CFArrayRef cfarray;
+	
+    cfarray = nsarray_to_cfarray (value);
+    CFPreferencesSetValue ((CFStringRef) key,
+						   (CFTypeRef) cfarray,
+						   CFSTR (APP_PREFS),
+						   kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+    CFRelease (cfarray);
+}
+
+- (void) prefs_set_string:(NSString *)key value:(NSString *)value
+{
+    CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) value,
+						   CFSTR (APP_PREFS), kCFPreferencesCurrentUser,
+						   kCFPreferencesAnyHost);
+}
+
+- (void) prefs_synchronize
+{
+    CFPreferencesAppSynchronize (kCFPreferencesCurrentApplication);
+}
+
+- (void) read_defaults
+{
+    const char *tem;
+	
+    quartzUseSysBeep = [self prefs_get_boolean:@PREFS_SYSBEEP
+                        default:quartzUseSysBeep];
+    quartzEnableRootless = [self prefs_get_boolean:@PREFS_ROOTLESS
+                        default:quartzEnableRootless];
+#ifdef DARWIN_DDX_MISSING
+    quartzFullscreenDisableHotkeys = ![self prefs_get_boolean:
+					      @PREFS_FULLSCREEN_HOTKEYS default:
+					      !quartzFullscreenDisableHotkeys];
+    quartzXpluginOptions = [self prefs_get_integer:@PREFS_XP_OPTIONS
+                            default:quartzXpluginOptions];
+#endif
+	
+    darwinSwapAltMeta = [self prefs_get_boolean:@PREFS_SWAP_ALT_META
+                         default:darwinSwapAltMeta];
+    darwinFakeButtons = [self prefs_get_boolean:@PREFS_FAKEBUTTONS
+                         default:darwinFakeButtons];
+    if (darwinFakeButtons) {
+      const char *fake2, *fake3;
+      
+      fake2 = [self prefs_get_string:@PREFS_FAKE_BUTTON2 default:NULL];
+      fake3 = [self prefs_get_string:@PREFS_FAKE_BUTTON3 default:NULL];
+      
+      if (fake2 != NULL) darwinFakeMouse2Mask = DarwinParseModifierList(fake2);
+      if (fake3 != NULL) darwinFakeMouse3Mask = DarwinParseModifierList(fake3);
+    }
+	
+    X11EnableKeyEquivalents = [self prefs_get_boolean:@PREFS_KEYEQUIVS
+                               default:X11EnableKeyEquivalents];
+	
+    darwinSyncKeymap = [self prefs_get_boolean:@PREFS_SYNC_KEYMAP
+                        default:darwinSyncKeymap];
+	
+    tem = [self prefs_get_string:@PREFS_KEYMAP_FILE default:NULL];
+    if (tem != NULL) darwinKeymapFile = strdup (tem);
+    else             darwinKeymapFile = NULL;
+	
+    darwinDesiredDepth = [self prefs_get_integer:@PREFS_DEPTH
+                          default:darwinDesiredDepth];
+	
+    enable_stereo = [self prefs_get_boolean:@PREFS_ENABLE_STEREO
+                     default:false];
+}
+
+/* This will end up at the end of the responder chain. */
+- (void) copy:sender
+{
+    QuartzMessageServerThread (kXDarwinPasteboardNotify, 1,
+			       AppleWMCopyToPasteboard);
+}
+
+- (BOOL) x_active
+{
+    return _x_active;
+}
+
+ at end
+
+static NSArray *
+array_with_strings_and_numbers (int nitems, const char **items,
+								const char *numbers)
+{
+    NSMutableArray *array, *subarray;
+    NSString *string;
+    NSString *number;
+    int i;
+	
+    /* (Can't autorelease on the X server thread) */
+	
+    array = [[NSMutableArray alloc] initWithCapacity:nitems];
+	
+    for (i = 0; i < nitems; i++)
+    {
+		subarray = [[NSMutableArray alloc] initWithCapacity:2];
+		
+		string = [[NSString alloc] initWithUTF8String:items[i]];
+		[subarray addObject:string];
+		[string release];
+		
+		if (numbers[i] != 0)
+		{
+			number = [[NSString alloc] initWithFormat:@"%d", numbers[i]];
+			[subarray addObject:number];
+			[number release];
+		}
+		else
+			[subarray addObject:@""];
+		
+		[array addObject:subarray];
+		[subarray release];
+    }
+	
+    return array;
+}
+
+void
+X11ApplicationSetWindowMenu (int nitems, const char **items,
+							 const char *shortcuts)
+{
+    NSArray *array;
+    array = array_with_strings_and_numbers (nitems, items, shortcuts);
+	
+    /* Send the array of strings over to the appkit thread */
+	
+    message_kit_thread (@selector (set_window_menu:), array);
+    [array release];
+}
+
+void
+X11ApplicationSetWindowMenuCheck (int idx)
+{
+    NSNumber *n;
+	
+    n = [[NSNumber alloc] initWithInt:idx];
+	
+    message_kit_thread (@selector (set_window_menu_check:), n);
+	
+    [n release];
+}
+
+void
+X11ApplicationSetFrontProcess (void)
+{
+    message_kit_thread (@selector (set_front_process:), nil);
+}
+
+void
+X11ApplicationSetCanQuit (int state)
+{
+    NSNumber *n;
+	
+    n = [[NSNumber alloc] initWithBool:state];
+	
+    message_kit_thread (@selector (set_can_quit:), n);
+	
+    [n release];
+}
+
+void
+X11ApplicationServerReady (void)
+{
+    message_kit_thread (@selector (server_ready:), nil);
+}
+
+void
+X11ApplicationShowHideMenubar (int state)
+{
+    NSNumber *n;
+	
+    n = [[NSNumber alloc] initWithBool:state];
+	
+    message_kit_thread (@selector (show_hide_menubar:), n);
+	
+    [n release];
+}
+
+static void *
+create_thread (void *func, void *arg)
+{
+    pthread_attr_t attr;
+    pthread_t tid;
+	
+    pthread_attr_init (&attr);
+	
+    pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM);
+    pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
+	
+    pthread_create (&tid, &attr, func, arg);
+	
+    pthread_attr_destroy (&attr);
+	
+    return (void *) tid;
+}
+
+static void
+check_xinitrc (void)
+{
+    char *tem, buf[1024];
+    NSString *msg;
+	
+    if ([X11App prefs_get_boolean:@PREFS_DONE_XINIT_CHECK default:NO])
+		return;
+	
+    tem = getenv ("HOME");
+    if (tem == NULL)
+		goto done;
+	
+    snprintf (buf, sizeof (buf), "%s/.xinitrc", tem);
+    if (access (buf, F_OK) != 0)
+		goto done;
+	
+    /* FIXME: put localized strings into Resources/English.lproj */
+	
+    msg = NSLocalizedString (@"You have an existing ~/.xinitrc file.\n\n\
+Windows displayed by X11 applications may not have titlebars, or may look \
+different to windows displayed by native applications.\n\n\
+Would you like to move aside the existing file and use the standard X11 \
+environment?", @"Startup xinitrc dialog");
+	
+    if (NSRunAlertPanel (nil, msg, NSLocalizedString (@"Yes", @""),
+						 NSLocalizedString (@"No", @""), nil)
+		== NSAlertDefaultReturn)
+    {
+		char buf2[1024];
+		int i = -1;
+		
+		snprintf (buf2, sizeof (buf2), "%s.old", buf);
+		
+		for (i = 1; access (buf2, F_OK) == 0; i++)
+			snprintf (buf2, sizeof (buf2), "%s.old.%d", buf, i);
+		
+		rename (buf, buf2);
+    }
+    
+	done:
+    [X11App prefs_set_boolean:@PREFS_DONE_XINIT_CHECK value:YES];
+    [X11App prefs_synchronize];
+}
+
+void
+X11ApplicationMain (int argc, const char *argv[],
+		    void (*server_thread) (void *), void *server_arg)
+{
+  NSAutoreleasePool *pool;
+  
+#ifdef DEBUG
+  while (access ("/tmp/x11-block", F_OK) == 0) sleep (1);
+#endif
+  
+  pool = [[NSAutoreleasePool alloc] init];
+  X11App = (X11Application *) [X11Application sharedApplication];
+  init_ports ();
+  [NSApp read_defaults];
+  [NSBundle loadNibNamed:@"main" owner:NSApp];
+  [[NSNotificationCenter defaultCenter] addObserver:NSApp
+					selector:@selector (became_key:)
+					name:NSWindowDidBecomeKeyNotification object:nil];
+  check_xinitrc ();
+	
+  /*
+   * The xpr Quartz mode is statically linked into this server.
+   * Initialize all the Quartz functions.
+   */
+  QuartzModeBundleInit();
+  
+  /* Calculate the height of the menubar so we can avoid it. */
+  aquaMenuBarHeight = NSHeight([[NSScreen mainScreen] frame]) -
+    NSMaxY([[NSScreen mainScreen] visibleFrame]);
+  
+  if (!create_thread (server_thread, server_arg)) {
+    ErrorF("can't create secondary thread\n");
+    exit (1);
+  }
+  
+  [NSApp run];
+  
+  /* not reached */
+}
+
+
+/* event conversion */
+
+static inline unsigned short
+convert_flags (unsigned int nsflags)
+{
+    unsigned int xflags;
+	
+    if (nsflags == ~0) return 0xffff;
+	
+    xflags = 0;
+	
+    if (nsflags & NSAlphaShiftKeyMask)	xflags |= LockMask;
+    if (nsflags & NSShiftKeyMask)		xflags |= ShiftMask;
+    if (nsflags & NSControlKeyMask)		xflags |= ControlMask;
+    if (nsflags & NSAlternateKeyMask)	xflags |= Mod1Mask;
+    if (nsflags & NSCommandKeyMask)		xflags |= Mod2Mask;
+    /* FIXME: secondaryfn? */
+	
+    return xflags;
+}
+
+static void
+send_nsevent (NSEventType type, NSEvent *e)
+{
+  static unsigned int button_state = 0;
+  NSRect screen;
+  NSPoint location;
+  NSWindow *window;
+  int pointer_x, pointer_y;
+  xEvent xe;
+  
+  memset (&xe, 0, sizeof (xe));
+  
+  /* This field should be filled in for every event */
+  xe.u.keyButtonPointer.time = GetTimeInMillis();
+  
+  /* convert location to global top-left coordinates */
+  location = [e locationInWindow];
+  window = [e window];
+  screen = [[[NSScreen screens] objectAtIndex:0] frame];
+  
+  if (window != nil)	{
+    NSRect frame = [window frame];
+    pointer_x = location.x + frame.origin.x;
+    pointer_y = (((screen.origin.y + screen.size.height)
+		  - location.y) - frame.origin.y);
+  } else {
+    pointer_x = location.x;
+    pointer_y = (screen.origin.y + screen.size.height) - location.y;
+  }
+  
+  xe.u.keyButtonPointer.rootX = pointer_x;
+  xe.u.keyButtonPointer.rootY = pointer_y;
+  
+  switch (type) {
+    float count;
+    
+  case NSLeftMouseDown:
+    xe.u.u.type = ButtonPress;
+    xe.u.u.detail = 1;
+    goto do_press_event;
+    
+  case NSRightMouseDown:
+    xe.u.u.type = ButtonPress;
+    xe.u.u.detail = 3;
+    goto do_press_event;
+    
+  case NSOtherMouseDown:
+    xe.u.u.type = ButtonPress;
+    xe.u.u.detail = 2; /* FIXME? */
+    goto do_press_event;
+    
+  do_press_event:
+    if (!quartzProcs->IsX11Window([e window], [e windowNumber])) {
+      /* X server doesn't grok this window, drop the event.
+	 
+	 Note: theoretically this isn't necessary, but if I click
+	 on the menubar, we get sent a LeftMouseDown when the
+	 release happens, but no LeftMouseUp is ever seen! */
+      
+      break;
+    }
+    goto do_event;
+    
+  case NSLeftMouseUp:
+    xe.u.u.type = ButtonRelease;
+    xe.u.u.detail = 1;
+    goto do_release_event;
+    
+  case NSRightMouseUp:
+    xe.u.u.type = ButtonRelease;
+    xe.u.u.detail = 3;
+    goto do_release_event;
+    
+  case NSOtherMouseUp:
+    xe.u.u.type = ButtonRelease;
+    xe.u.u.detail = 2; /* FIXME? */
+    goto do_release_event;
+    
+  do_release_event:
+    if ((button_state & (1 << xe.u.u.detail)) == 0)
+      {
+	/* X didn't see the button press for this release, so skip it */
+	break;
+      }
+    goto do_event;
+    
+  case NSMouseMoved:
+  case NSLeftMouseDragged:
+  case NSRightMouseDragged:
+  case NSOtherMouseDragged:
+    xe.u.u.type = MotionNotify;
+    goto do_event;
+    
+  case NSKeyDown:
+    xe.u.u.type = KeyPress;
+    xe.u.u.detail = [e keyCode];
+    goto do_event;
+    
+  case NSKeyUp:
+    xe.u.u.type = KeyRelease;
+    xe.u.u.detail = [e keyCode];
+    goto do_event;
+    
+  case NSScrollWheel:
+    xe.u.keyButtonPointer.state = convert_flags ([e modifierFlags]);
+    count = [e deltaY];
+    xe.u.u.detail = count > 0.0f ? 4 : 5;
+    for (count = fabs(count); count > 0.0; count = count - 1.0f) {
+      xe.u.u.type = ButtonPress;
+      DarwinEQEnqueue(&xe);
+      xe.u.u.type = ButtonRelease;
+      DarwinEQEnqueue(&xe);
+    }
+    xe.u.u.type = 0;
+    break;
+    
+  case NSFlagsChanged:
+    xe.u.u.type = kXDarwinUpdateModifiers;
+    xe.u.clientMessage.u.l.longs0 = [e modifierFlags];
+    DarwinEQEnqueue (&xe);
+    break;
+    
+  do_event:
+    //	xe.u.keyButtonPointer.state = convert_flags ([e modifierFlags]);
+    DarwinEQEnqueue (&xe);
+    break;
+    
+  default: break; /* for gcc */
+  }
+  
+  if (xe.u.u.type == ButtonPress) button_state |= (1 << xe.u.u.detail);
+  else if (xe.u.u.type == ButtonRelease) button_state &= ~(1 << xe.u.u.detail);
+}
diff --git a/hw/darwin/quartz/X11Controller.h b/hw/darwin/quartz/X11Controller.h
new file mode 100644
index 0000000..954d0ab
--- /dev/null
+++ b/hw/darwin/quartz/X11Controller.h
@@ -0,0 +1,86 @@
+/* X11Controller.h -- connect the IB ui
+   $Id: X11Controller.h,v 1.21 2003/07/24 17:52:29 jharper Exp $
+
+   Copyright (c) 2002 Apple Computer, Inc. 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 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 X11CONTROLLER_H
+#define X11CONTROLLER_H 1
+
+#if __OBJC__
+
+#import <Cocoa/Cocoa.h>
+#include "../quartz/xpr/x-list.h"
+
+ at interface X11Controller : NSObject
+{
+    NSPanel *prefs_panel;
+
+    NSButton *fake_buttons;
+    NSButton *enable_fullscreen;
+    NSButton *use_sysbeep;
+    NSButton *enable_keyequivs;
+    NSButton *sync_keymap;
+    NSButton *enable_auth;
+    NSButton *enable_tcp;
+    NSPopUpButton *depth;
+
+    NSMenuItem *x11_about_item;
+    NSMenuItem *window_separator;
+    NSMenuItem *dock_window_separator;
+    NSMenuItem *apps_separator;
+    NSMenuItem *toggle_fullscreen_item;
+    NSMenu *dock_apps_menu;
+    NSTableView *apps_table;
+
+    NSArray *apps;
+    NSMutableArray *table_apps;
+
+    NSMenu *dock_menu;
+
+    int checked_window_item;
+    x_list *pending_apps;
+
+    BOOL finished_launching;
+    BOOL can_quit;
+}
+
+- (void) set_window_menu:(NSArray *)list;
+- (void) set_window_menu_check:(NSNumber *)n;
+- (void) set_apps_menu:(NSArray *)list;
+- (void) set_can_quit:(BOOL)state;
+- (void) server_ready;
+
+ at end
+
+#endif /* __OBJC__ */
+
+extern void X11ControllerMain (int argc, const char *argv[],
+			       void (*server_thread) (void *),
+			       void *server_arg);
+
+#endif /* X11CONTROLLER_H */
diff --git a/hw/darwin/quartz/X11Controller.m b/hw/darwin/quartz/X11Controller.m
new file mode 100644
index 0000000..df90049
--- /dev/null
+++ b/hw/darwin/quartz/X11Controller.m
@@ -0,0 +1,748 @@
+/* X11Controller.m -- connect the IB ui, also the NSApp delegate
+   $Id: X11Controller.m,v 1.40 2006/09/06 21:19:32 jharper Exp $
+ 
+   Copyright (c) 2002-2007 Apple Inc. 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 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 DEFAULT_PATH "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11/bin"
+
+#include "../quartz/quartzCommon.h"
+
+#import "X11Controller.h"
+#import "X11Application.h"
+#import <Carbon/Carbon.h>
+
+/* ouch! */
+#define BOOL X_BOOL
+//# include "Xproto.h"
+#include "opaque.h"
+# include "darwin.h"
+# include "../quartz/quartz.h"
+# define _APPLEWM_SERVER_
+# include "X11/extensions/applewm.h"
+# include "../quartz/applewmExt.h"
+//# include "X.h"
+#undef BOOL
+
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+ at implementation X11Controller
+
+- (void) awakeFromNib
+{
+  X11Application *xapp = NSApp;
+  NSArray *array;
+	
+  /* Point X11Application at ourself. */
+  [xapp set_controller:self];
+	
+  array = [xapp prefs_get_array:@PREFS_APPSMENU];
+  if (array != nil)
+    {
+      int count;
+		
+      /* convert from [TITLE1 COMMAND1 TITLE2 COMMAND2 ...]
+	 to [[TITLE1 COMMAND1] [TITLE2 COMMAND2] ...] format. */
+		
+      count = [array count];
+      if (count > 0
+	  && ![[array objectAtIndex:0] isKindOfClass:[NSArray class]])
+	{
+	  int i;
+	  NSMutableArray *copy, *sub;
+			
+	  copy = [NSMutableArray arrayWithCapacity:(count / 2)];
+			
+	  for (i = 0; i < count / 2; i++)
+	    {
+	      sub = [[NSMutableArray alloc] initWithCapacity:3];
+	      [sub addObject:[array objectAtIndex:i*2]];
+	      [sub addObject:[array objectAtIndex:i*2+1]];
+	      [sub addObject:@""];
+	      [copy addObject:sub];
+	      [sub release];
+	    }
+			
+	  array = copy;
+	}
+		
+      [self set_apps_menu:array];
+    }
+}
+
+- (void) item_selected:sender
+{
+  [NSApp activateIgnoringOtherApps:YES];
+	
+  QuartzMessageServerThread (kXDarwinControllerNotify, 2,
+			     AppleWMWindowMenuItem, [sender tag]);
+}
+
+- (void) remove_window_menu
+{
+  NSMenu *menu;
+  int first, count, i;
+	
+  /* Work backwards so we don't mess up the indices */
+  menu = [window_separator menu];
+  first = [menu indexOfItem:window_separator] + 1;
+  count = [menu numberOfItems];
+  for (i = count - 1; i >= first; i--)
+    [menu removeItemAtIndex:i];
+	
+  menu = [dock_window_separator menu];
+  count = [menu indexOfItem:dock_window_separator];
+  for (i = 0; i < count; i++)
+    [dock_menu removeItemAtIndex:0];
+}
+
+- (void) install_window_menu:(NSArray *)list
+{
+  NSMenu *menu;
+  NSMenuItem *item;
+  int first, count, i;
+	
+  menu = [window_separator menu];
+  first = [menu indexOfItem:window_separator] + 1;
+  count = [list count];
+  for (i = 0; i < count; i++)
+    {
+      NSString *name, *shortcut;
+		
+      name = [[list objectAtIndex:i] objectAtIndex:0];
+      shortcut = [[list objectAtIndex:i] objectAtIndex:1];
+		
+      item = (NSMenuItem *) [menu addItemWithTitle:name action:@selector
+				  (item_selected:) keyEquivalent:shortcut];
+      [item setTarget:self];
+      [item setTag:i];
+      [item setEnabled:YES];
+		
+      item = (NSMenuItem *) [dock_menu insertItemWithTitle:name
+				       action:@selector
+				       (item_selected:) keyEquivalent:shortcut
+				       atIndex:i];
+      [item setTarget:self];
+      [item setTag:i];
+      [item setEnabled:YES];
+    }
+	
+  if (checked_window_item >= 0 && checked_window_item < count)
+    {
+      item = (NSMenuItem *) [menu itemAtIndex:first + checked_window_item];
+      [item setState:NSOnState];
+      item = (NSMenuItem *) [dock_menu itemAtIndex:checked_window_item];
+      [item setState:NSOnState];
+    }
+}
+
+- (void) remove_apps_menu
+{
+  NSMenu *menu;
+  NSMenuItem *item;
+  int i;
+	
+  if (apps == nil || apps_separator == nil) return;
+	
+  menu = [apps_separator menu];
+	
+  if (menu != nil)
+    {
+      for (i = [menu numberOfItems] - 1; i >= 0; i--)
+	{
+	  item = (NSMenuItem *) [menu itemAtIndex:i];
+	  if ([item tag] != 0)
+	    [menu removeItemAtIndex:i];
+	}
+    }
+    
+  if (dock_apps_menu != nil)
+    {
+      for (i = [dock_apps_menu numberOfItems] - 1; i >= 0; i--)
+	{
+	  item = (NSMenuItem *) [dock_apps_menu itemAtIndex:i];
+	  if ([item tag] != 0)
+	    [dock_apps_menu removeItemAtIndex:i];
+	}
+    }
+    
+  [apps release];
+  apps = nil;
+}
+
+- (void) prepend_apps_item:(NSArray *)list index:(int)i menu:(NSMenu *)menu
+{
+  NSString *title, *shortcut = @"";
+  NSArray *group;
+  NSMenuItem *item;
+	
+  group = [list objectAtIndex:i];
+  title = [group objectAtIndex:0];
+  if ([group count] >= 3)
+    shortcut = [group objectAtIndex:2];
+	
+  if ([title length] != 0)
+    {
+      item = (NSMenuItem *) [menu insertItemWithTitle:title
+				  action:@selector (app_selected:)
+				  keyEquivalent:shortcut atIndex:0];
+      [item setTarget:self];
+      [item setEnabled:YES];
+    }
+  else
+    {
+      item = (NSMenuItem *) [NSMenuItem separatorItem];
+      [menu insertItem:item atIndex:0];
+    }
+	
+  [item setTag:i+1];			/* can't be zero, so add one */
+}
+
+- (void) install_apps_menu:(NSArray *)list
+{
+  NSMenu *menu;
+  int i, count;
+	
+  count = [list count];
+	
+  if (count == 0 || apps_separator == nil) return;
+	
+  menu = [apps_separator menu];
+	
+  for (i = count - 1; i >= 0; i--)
+    {
+      if (menu != nil)
+	[self prepend_apps_item:list index:i menu:menu];
+      if (dock_apps_menu != nil)
+	[self prepend_apps_item:list index:i menu:dock_apps_menu];
+    }
+	
+  apps = [list retain];
+}
+
+- (void) set_window_menu:(NSArray *)list
+{
+  [self remove_window_menu];
+  [self install_window_menu:list];
+	
+  QuartzMessageServerThread (kXDarwinControllerNotify, 1,
+			     AppleWMWindowMenuNotify);
+}
+
+- (void) set_window_menu_check:(NSNumber *)nn
+{
+  NSMenu *menu;
+  NSMenuItem *item;
+  int first, count;
+  int n = [nn intValue];
+
+  menu = [window_separator menu];
+  first = [menu indexOfItem:window_separator] + 1;
+  count = [menu numberOfItems] - first;
+	
+  if (checked_window_item >= 0 && checked_window_item < count)
+    {
+      item = (NSMenuItem *) [menu itemAtIndex:first + checked_window_item];
+      [item setState:NSOffState];
+      item = (NSMenuItem *) [dock_menu itemAtIndex:checked_window_item];
+      [item setState:NSOffState];
+    }
+  if (n >= 0 && n < count)
+    {
+      item = (NSMenuItem *) [menu itemAtIndex:first + n];
+      [item setState:NSOnState];
+      item = (NSMenuItem *) [dock_menu itemAtIndex:n];
+      [item setState:NSOnState];
+    }
+  checked_window_item = n;
+}
+
+- (void) set_apps_menu:(NSArray *)list
+{
+  [self remove_apps_menu];
+  [self install_apps_menu:list];
+}
+
+- (void) launch_client:(NSString *)filename
+{
+  const char *command = [filename UTF8String];
+  const char *argv[7];
+  int child1, child2 = 0;
+  int status;
+	
+  argv[0] = "/usr/bin/login";
+  argv[1] = "-fp";
+  argv[2] = getlogin();
+  argv[3] = "/bin/sh";
+  argv[4] = "-c";
+  argv[5] = command;
+  argv[6] = NULL;
+    
+  /* Do the fork-twice trick to avoid having to reap zombies */
+    
+  child1 = fork();
+    
+  switch (child1) {
+  case -1:                                /* error */
+    break;
+      
+  case 0:                                 /* child1 */
+    child2 = fork();
+      
+    switch (child2) {
+      int max_files, i;
+      char buf[1024], *temp;
+	
+    case -1:                            /* error */
+      _exit(1);
+	
+    case 0:                             /* child2 */
+      /* close all open files except for standard streams */
+      max_files = sysconf(_SC_OPEN_MAX);
+      for (i = 3; i < max_files; i++)	close(i);
+	
+      /* ensure stdin is on /dev/null */
+      close(0);
+      open("/dev/null", O_RDONLY);
+	
+      /* Setup environment */
+      temp = getenv("DISPLAY");
+      if (temp == NULL || temp[0] == 0) {
+	snprintf(buf, sizeof(buf), ":%s", display);
+	setenv("DISPLAY", buf, TRUE);
+      }
+	
+      temp = getenv("PATH");
+      if (temp == NULL || temp[0] == 0) 
+	setenv ("PATH", DEFAULT_PATH, TRUE);
+      else if (strnstr(temp, "/usr/X11/bin", sizeof(temp)) == NULL) {
+	snprintf(buf, sizeof(buf), "%s:/usr/X11/bin", temp);            
+	setenv("PATH", buf, TRUE);      
+      }
+      /* cd $HOME */
+      temp = getenv("HOME");
+      if (temp != NULL && temp[0]!=0) chdir(temp);
+	
+      execvp(argv[0], (char **const) argv);
+	
+      _exit(2);
+	
+    default:                            /* parent (child1) */
+      _exit(0);
+    }
+    break;
+      
+  default:                                /* parent */
+    waitpid(child1, &status, 0);
+  }
+}
+
+- (void) app_selected:sender
+{
+  int tag;
+  NSString *item;
+  
+  tag = [sender tag] - 1;
+  if (apps == nil || tag < 0 || tag >= [apps count])
+    return;
+  
+  item = [[apps objectAtIndex:tag] objectAtIndex:1];
+  
+  [self launch_client:item];
+}
+
+- (IBAction) apps_table_show:sender
+{
+  NSArray *columns;
+	
+  if (table_apps == nil) {
+    table_apps = [[NSMutableArray alloc] initWithCapacity:1];
+      
+    if (apps != nil)[table_apps addObjectsFromArray:apps];
+  }
+	
+  columns = [apps_table tableColumns];
+  [[columns objectAtIndex:0] setIdentifier:@"0"];
+  [[columns objectAtIndex:1] setIdentifier:@"1"];
+  [[columns objectAtIndex:2] setIdentifier:@"2"];
+	
+  [apps_table setDataSource:self];
+  [apps_table selectRow:0 byExtendingSelection:NO];
+	
+  [[apps_table window] makeKeyAndOrderFront:sender];
+}
+
+- (IBAction) apps_table_cancel:sender
+{
+  [[apps_table window] orderOut:sender];
+  [apps_table reloadData];
+	
+  [table_apps release];
+  table_apps = nil;
+}
+
+- (IBAction) apps_table_done:sender
+{
+  [apps_table deselectAll:sender];	/* flush edits? */
+	
+  [self remove_apps_menu];
+  [self install_apps_menu:table_apps];
+	
+  [NSApp prefs_set_array:@PREFS_APPSMENU value:table_apps];
+  [NSApp prefs_synchronize];
+	
+  [[apps_table window] orderOut:sender];
+	
+  [table_apps release];
+  table_apps = nil;
+}
+
+- (IBAction) apps_table_new:sender
+{
+  NSMutableArray *item;
+	
+  int row = [apps_table selectedRow], i;
+	
+  if (row < 0) row = 0;
+  else row = row + 1;
+	
+  i = row;
+  if (i > [table_apps count])
+    return;				/* avoid exceptions */
+	
+  [apps_table deselectAll:sender];
+	
+  item = [[NSMutableArray alloc] initWithCapacity:3];
+  [item addObject:@""];
+  [item addObject:@""];
+  [item addObject:@""];
+	
+  [table_apps insertObject:item atIndex:i];
+  [item release];
+	
+  [apps_table reloadData];
+  [apps_table selectRow:row byExtendingSelection:NO];
+}
+
+- (IBAction) apps_table_duplicate:sender
+{
+  int row = [apps_table selectedRow], i;
+  NSObject *item;
+	
+  if (row < 0) {
+    [self apps_table_new:sender];
+    return;
+  }
+	
+  i = row;
+  if (i > [table_apps count] - 1) return;				/* avoid exceptions */
+    
+  [apps_table deselectAll:sender];
+	
+  item = [[table_apps objectAtIndex:i] mutableCopy];
+  [table_apps insertObject:item atIndex:i];
+  [item release];
+	
+  [apps_table reloadData];
+  [apps_table selectRow:row+1 byExtendingSelection:NO];
+}
+
+- (IBAction) apps_table_delete:sender
+{
+  int row = [apps_table selectedRow];
+	
+  if (row >= 0)
+    {
+      int i = row;
+      
+      if (i > [table_apps count] - 1) return;			/* avoid exceptions */
+      
+      [apps_table deselectAll:sender];
+      
+      [table_apps removeObjectAtIndex:i];
+    }
+	
+  [apps_table reloadData];
+	
+  row = MIN (row, [table_apps count] - 1);
+  if (row >= 0)
+    [apps_table selectRow:row byExtendingSelection:NO];
+}
+
+- (int) numberOfRowsInTableView:(NSTableView *)tableView
+{
+  if (table_apps == nil) return 0;
+  
+  return [table_apps count];
+}
+
+- (id) tableView:(NSTableView *)tableView
+objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
+{
+  NSArray *item;
+  int col;
+	
+  if (table_apps == nil) return nil;
+	
+  col = [[tableColumn identifier] intValue];
+	
+  item = [table_apps objectAtIndex:row];
+  if ([item count] > col)
+    return [item objectAtIndex:col];
+  else
+    return @"";
+}
+
+- (void) tableView:(NSTableView *)tableView setObjectValue:(id)object
+    forTableColumn:(NSTableColumn *)tableColumn row:(int)row
+{
+  NSMutableArray *item;
+  int col;
+	
+  if (table_apps == nil) return;
+	
+  col = [[tableColumn identifier] intValue];
+	
+  item = [table_apps objectAtIndex:row];
+  [item replaceObjectAtIndex:col withObject:object];
+}
+
+- (void) hide_window:sender
+{
+  if ([X11App x_active])
+    QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMHideWindow);
+  else
+    NSBeep ();			/* FIXME: something here */
+}
+
+- (IBAction)bring_to_front:sender
+{
+  QuartzMessageServerThread(kXDarwinControllerNotify, 1, AppleWMBringAllToFront);
+}
+
+- (IBAction)close_window:sender
+{
+  if ([X11App x_active])
+    QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMCloseWindow);
+  else
+    [[NSApp keyWindow] performClose:sender];
+}
+
+- (IBAction)minimize_window:sender
+{
+  if ([X11App x_active])
+    QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMMinimizeWindow);
+  else
+    [[NSApp keyWindow] performMiniaturize:sender];
+}
+
+- (IBAction)zoom_window:sender
+{
+  if ([X11App x_active])
+    QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMZoomWindow);
+  else
+    [[NSApp keyWindow] performZoom:sender];
+}
+
+- (IBAction) next_window:sender
+{
+  QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMNextWindow);
+}
+
+- (IBAction) previous_window:sender
+{
+  QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMPreviousWindow);
+}
+
+- (IBAction) enable_fullscreen_changed:sender
+{
+  int value = ![enable_fullscreen intValue];
+	
+#ifdef DARWIN_DDX_MISSING
+  QuartzMessageServerThread (kXDarwinSetRootless, 1, value);
+#endif
+	
+  [NSApp prefs_set_boolean:@PREFS_ROOTLESS value:value];
+  [NSApp prefs_synchronize];
+}
+
+- (IBAction) toggle_fullscreen:sender
+{
+#ifdef DARWIN_DDX_MISSING
+  QuartzMessageServerThread (kXDarwinToggleFullscreen, 0);
+#endif
+}
+
+- (void) set_can_quit:(BOOL)state
+{
+  can_quit = state;
+}
+
+- (IBAction)prefs_changed:sender
+{
+  darwinFakeButtons = [fake_buttons intValue];
+  quartzUseSysBeep = [use_sysbeep intValue];
+  X11EnableKeyEquivalents = [enable_keyequivs intValue];
+  darwinSyncKeymap = [sync_keymap intValue];
+	
+  /* after adding prefs here, also add to [X11Application read_defaults]
+     and below */
+	
+  [NSApp prefs_set_boolean:@PREFS_FAKEBUTTONS value:darwinFakeButtons];
+  [NSApp prefs_set_boolean:@PREFS_SYSBEEP value:quartzUseSysBeep];
+  [NSApp prefs_set_boolean:@PREFS_KEYEQUIVS value:X11EnableKeyEquivalents];
+  [NSApp prefs_set_boolean:@PREFS_SYNC_KEYMAP value:darwinSyncKeymap];
+  [NSApp prefs_set_boolean:@PREFS_NO_AUTH value:![enable_auth intValue]];
+  [NSApp prefs_set_boolean:@PREFS_NO_TCP value:![enable_tcp intValue]];
+  [NSApp prefs_set_integer:@PREFS_DEPTH value:[depth selectedTag]];
+	
+  [NSApp prefs_synchronize];
+}
+
+- (IBAction) prefs_show:sender
+{
+  [fake_buttons setIntValue:darwinFakeButtons];
+  [use_sysbeep setIntValue:quartzUseSysBeep];
+  [enable_keyequivs setIntValue:X11EnableKeyEquivalents];
+  [sync_keymap setIntValue:darwinSyncKeymap];
+  [sync_keymap setEnabled:darwinKeymapFile == NULL];
+	
+  [enable_auth setIntValue:![NSApp prefs_get_boolean:@PREFS_NO_AUTH default:NO]];
+  [enable_tcp setIntValue:![NSApp prefs_get_boolean:@PREFS_NO_TCP default:NO]];
+  [depth selectItemAtIndex:[depth indexOfItemWithTag:[NSApp prefs_get_integer:@PREFS_DEPTH default:-1]]];
+	
+  [enable_fullscreen setIntValue:!quartzEnableRootless];
+	
+  [prefs_panel makeKeyAndOrderFront:sender];
+}
+
+- (IBAction) quit:sender
+{
+  QuartzMessageServerThread (kXDarwinQuit, 0);
+}
+
+- (IBAction) x11_help:sender
+{
+  AHLookupAnchor ((CFStringRef)NSLocalizedString(@"Mac Help", no comment), CFSTR ("mchlp2276"));
+}
+
+- (BOOL) validateMenuItem:(NSMenuItem *)item
+{
+  NSMenu *menu = [item menu];
+	
+  if (item == toggle_fullscreen_item)
+    return !quartzEnableRootless;
+  else if (menu == [window_separator menu] || menu == dock_menu
+	   || (menu == [x11_about_item menu] && [item tag] == 42))
+    return (AppleWMSelectedEvents () & AppleWMControllerNotifyMask) != 0;
+  else
+    return TRUE;
+}
+
+- (void) applicationDidHide:(NSNotification *)notify
+{
+  QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMHideAll);
+}
+
+- (void) applicationDidUnhide:(NSNotification *)notify
+{
+  QuartzMessageServerThread (kXDarwinControllerNotify, 1, AppleWMShowAll);
+}
+
+- (NSApplicationTerminateReply) applicationShouldTerminate:sender
+{
+  NSString *msg;
+	
+  if (can_quit || [X11App prefs_get_boolean:@PREFS_NO_QUIT_ALERT default:NO])
+    return NSTerminateNow;
+	
+  /* Make sure we're frontmost. */
+  [NSApp activateIgnoringOtherApps:YES];
+	
+  msg = NSLocalizedString (@"Are you sure you want to quit X11?\n\nIf you quit X11, any X11 applications you are running will stop immediately and you will lose any changes you have not saved.", @"Dialog when quitting");
+	
+  /* FIXME: safe to run the alert in here? Or should we return Later
+     and then run the alert on a timer? It seems to work here, so.. */
+	
+  return (NSRunAlertPanel (nil, msg, NSLocalizedString (@"Quit", @""),
+			   NSLocalizedString (@"Cancel", @""), nil)
+	  == NSAlertDefaultReturn) ? NSTerminateNow : NSTerminateCancel;
+}
+
+- (void) applicationWillTerminate:(NSNotification *)aNotification
+{
+  [X11App prefs_synchronize];
+	
+  /* shutdown the X server, it will exit () for us. */
+  QuartzMessageServerThread (kXDarwinQuit, 0);
+	
+  /* In case it doesn't, exit anyway after a while. */
+  while (sleep (10) != 0) ;
+  exit (1);
+}
+
+- (void) server_ready
+{
+  x_list *node;
+	
+  finished_launching = YES;
+	
+  for (node = pending_apps; node != NULL; node = node->next)
+    {
+      NSString *filename = node->data;
+      [self launch_client:filename];
+      [filename release];
+    }
+	
+  x_list_free (pending_apps);
+  pending_apps = NULL;
+}
+
+- (BOOL) application:(NSApplication *)app openFile:(NSString *)filename
+{
+  const char *name = [filename UTF8String];
+	
+  if (finished_launching)
+    [self launch_client:filename];
+  else if (name[0] != ':')		/* ignore display names */
+    pending_apps = x_list_prepend (pending_apps, [filename retain]);
+	
+  /* FIXME: report failures. */
+  return YES;
+}
+
+ at end
+
+void X11ControllerMain (int argc, const char *argv[],
+			void (*server_thread) (void *), void *server_arg)
+{
+  X11ApplicationMain (argc, argv, server_thread, server_arg);
+}
diff --git a/hw/darwin/quartz/XApplication.h b/hw/darwin/quartz/XApplication.h
deleted file mode 100644
index 2f2b223..0000000
--- a/hw/darwin/quartz/XApplication.h
+++ /dev/null
@@ -1,46 +0,0 @@
-//
-//  XApplication.h
-//
-//  Created by Andreas Monitzer on January 6, 2001.
-//
-/*
- * Copyright (c) 2001 Andreas Monitzer. 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 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.
- */
-
-#import <Cocoa/Cocoa.h>
-
-#import "XServer.h"
-#import "Preferences.h"
-
- at interface XApplication : NSApplication {
-    IBOutlet XServer *xserver;
-    IBOutlet Preferences *preferences;
-}
-
-- (void)sendEvent:(NSEvent *)anEvent;
-
- at end
diff --git a/hw/darwin/quartz/XApplication.m b/hw/darwin/quartz/XApplication.m
deleted file mode 100644
index de32d38..0000000
--- a/hw/darwin/quartz/XApplication.m
+++ /dev/null
@@ -1,46 +0,0 @@
-//
-//  XApplication.m
-//
-//  Created by Andreas Monitzer on January 6, 2001.
-//
-/*
- * Copyright (c) 2001 Andreas Monitzer. 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 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.
- */
-
-#import "XApplication.h"
-
-
- at implementation XApplication
-
-- (void)sendEvent:(NSEvent *)anEvent {
-    if (![xserver translateEvent:anEvent]) {
-        if (![preferences sendEvent:anEvent])
-            [super sendEvent:anEvent];
-    }
-}
-
- at end
diff --git a/hw/darwin/quartz/XDarwin.pbproj/project.pbxproj b/hw/darwin/quartz/XDarwin.pbproj/project.pbxproj
deleted file mode 100644
index 0ad8314..0000000
--- a/hw/darwin/quartz/XDarwin.pbproj/project.pbxproj
+++ /dev/null
@@ -1,2519 +0,0 @@
-// !$*UTF8*$!
-{
-	archiveVersion = 1;
-	classes = {
-	};
-	objectVersion = 39;
-	objects = {
-		01279092000747AA0A000002 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.objc;
-			path = XServer.m;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		0127909600074AF60A000002 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.objc;
-			path = XApplication.m;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		0127909800074B1A0A000002 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.h;
-			path = XApplication.h;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		015698ED003DF345CE6F79C2 = {
-			isa = PBXFileReference;
-			lastKnownFileType = image.icns;
-			path = XDarwin.icns;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		0157A37D002CF6D7CE6F79C2 = {
-			children = (
-				F533214601A4B45401000001,
-				0157A37E002CF6D7CE6F79C2,
-				F58D65DF018F79B101000001,
-				F533213D0193CBE001000001,
-				43B962E200617B93416877C2,
-				F5ACD263C5BE031F01000001,
-				F51BF62E02026E3501000001,
-				F5ACD25CC5B5E96601000001,
-				F587E16401924C6901000001,
-			);
-			isa = PBXVariantGroup;
-			name = Credits.rtf;
-			path = "";
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		0157A37E002CF6D7CE6F79C2 = {
-			isa = PBXFileReference;
-			lastKnownFileType = text.rtf;
-			name = English;
-			path = English.lproj/Credits.rtf;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		015EDCEA004203A8CE6F79C2 = {
-			isa = PBXFileReference;
-			lastKnownFileType = wrapper.framework;
-			name = IOKit.framework;
-			path = /System/Library/Frameworks/IOKit.framework;
-			refType = 0;
-			sourceTree = "<absolute>";
-		};
-		018F40F2003E1902CE6F79C2 = {
-			children = (
-				018F40F3003E1916CE6F79C2,
-				021D6BA9003E1BACCE6F79C2,
-				3E74E03600863F047F000001,
-				F5A94EF10314BAC70100011B,
-				018F40F6003E1974CE6F79C2,
-				6E5F5F0005537A1A008FEAD7,
-			);
-			isa = PBXGroup;
-			name = "X Server";
-			path = ..;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		018F40F3003E1916CE6F79C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = darwin.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		018F40F6003E1974CE6F79C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = darwinKeyboard.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		018F40F8003E1979CE6F79C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = quartz.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		018F40FA003E197ECE6F79C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.h;
-			path = quartz.h;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		018F40FC003E1983CE6F79C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = xfIOKit.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		018F40FE003E1988CE6F79C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.h;
-			path = xfIOKit.h;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		018F4100003E19E4CE6F79C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = xfIOKitCursor.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-//010
-//011
-//012
-//013
-//014
-//020
-//021
-//022
-//023
-//024
-		021D6BA9003E1BACCE6F79C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.h;
-			path = darwin.h;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		02A1FEA6006D34BE416877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = xfIOKitStartup.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		02A1FEA8006D38F0416877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = quartzStartup.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		02E03CA000348209CE6F79C2 = {
-			children = (
-				F533214701A4B48301000001,
-				02E03CA100348209CE6F79C2,
-				F58D65E0018F79C001000001,
-				F533213E0193CBF401000001,
-				43B962E300617B93416877C2,
-				F5ACD268C5BE046401000001,
-				F51BF62F02026E5C01000001,
-				F5ACD261C5B5EA2001000001,
-				F587E16501924C7401000001,
-			);
-			isa = PBXVariantGroup;
-			name = XDarwinHelp.html;
-			path = "";
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		02E03CA100348209CE6F79C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = text.html;
-			name = English;
-			path = English.lproj/XDarwinHelp.html;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-//020
-//021
-//022
-//023
-//024
-//030
-//031
-//032
-//033
-//034
-		0338412F0083BFE57F000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.h;
-			path = quartzCursor.h;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-//030
-//031
-//032
-//033
-//034
-//040
-//041
-//042
-//043
-//044
-		04329610000763920A000002 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.objc;
-			path = Preferences.m;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		04329611000763920A000002 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.h;
-			path = Preferences.h;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-//040
-//041
-//042
-//043
-//044
-//080
-//081
-//082
-//083
-//084
-		080E96DDFE201D6D7F000001 = {
-			children = (
-				04329610000763920A000002,
-				04329611000763920A000002,
-				0127909600074AF60A000002,
-				0127909800074B1A0A000002,
-				01279092000747AA0A000002,
-				1C4A3109004D8F24CE6F79C2,
-			);
-			isa = PBXGroup;
-			name = Classes;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		089C165CFE840E0CC02AAC07 = {
-			children = (
-				F533214301A4B3F001000001,
-				089C165DFE840E0CC02AAC07,
-				F58D65DD018F798F01000001,
-				F533213A0193CBA201000001,
-				43B962E100617B49416877C2,
-				F5ACD269C5BE049301000001,
-				F51BF62B02026DDA01000001,
-				F5ACD262C5B5EA4D01000001,
-				F587E16101924C2F01000001,
-			);
-			isa = PBXVariantGroup;
-			name = InfoPlist.strings;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		089C165DFE840E0CC02AAC07 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = text.plist.strings;
-			name = English;
-			path = English.lproj/InfoPlist.strings;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-//080
-//081
-//082
-//083
-//084
-//0A0
-//0A1
-//0A2
-//0A3
-//0A4
-		0A79E19E004499A1CE6F79C2 = {
-			explicitFileType = wrapper.application;
-			isa = PBXFileReference;
-			path = XDarwin.app;
-			refType = 3;
-			sourceTree = BUILT_PRODUCTS_DIR;
-		};
-		0A79E19F004499A1CE6F79C2 = {
-			buildPhases = (
-				0A79E1A0004499A1CE6F79C2,
-				0A79E1A1004499A1CE6F79C2,
-				0A79E1A2004499A1CE6F79C2,
-				0A79E1A3004499A1CE6F79C2,
-				0A79E1A4004499A1CE6F79C2,
-			);
-			buildSettings = {
-				INSTALL_PATH = /;
-				OTHER_CFLAGS = "";
-				OTHER_LDFLAGS = "";
-				OTHER_REZFLAGS = "";
-				PRODUCT_NAME = XDarwin;
-				SECTORDER_FLAGS = "";
-				WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas";
-				WRAPPER_EXTENSION = app;
-			};
-			dependencies = (
-				6EF065C903D4F0CA006877C2,
-				6EF065C703D4EE19006877C2,
-				6E11A986048BDFFB006877C2,
-				6E7904110500F33B00EEC080,
-			);
-			isa = PBXApplicationTarget;
-			name = XDarwin;
-			productInstallPath = /;
-			productName = XDarwin;
-			productReference = 0A79E19E004499A1CE6F79C2;
-			productSettingsXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
-<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
-<plist version=\"1.0\">
-<dict>
-	<key>CFBundleDevelopmentRegion</key>
-	<string>English</string>
-	<key>CFBundleDocumentTypes</key>
-	<array>
-		<dict>
-			<key>CFBundleTypeExtensions</key>
-			<array>
-				<string>x11app</string>
-			</array>
-			<key>CFBundleTypeName</key>
-			<string>X11 Application</string>
-			<key>CFBundleTypeOSTypes</key>
-			<array>
-				<string>****</string>
-			</array>
-			<key>CFBundleTypeRole</key>
-			<string>Viewer</string>
-		</dict>
-		<dict>
-			<key>CFBundleTypeExtensions</key>
-			<array>
-				<string>tool</string>
-				<string>*</string>
-			</array>
-			<key>CFBundleTypeName</key>
-			<string>UNIX Application</string>
-			<key>CFBundleTypeOSTypes</key>
-			<array>
-				<string>****</string>
-			</array>
-			<key>CFBundleTypeRole</key>
-			<string>Viewer</string>
-		</dict>
-	</array>
-	<key>CFBundleExecutable</key>
-	<string>XDarwin</string>
-	<key>CFBundleGetInfoString</key>
-	<string>XDarwin 1.4.0, X.Org Foundation</string>
-	<key>CFBundleIconFile</key>
-	<string>XDarwin.icns</string>
-	<key>CFBundleIdentifier</key>
-	<string>org.x.x11</string>
-	<key>CFBundleInfoDictionaryVersion</key>
-	<string>6.0</string>
-	<key>CFBundleName</key>
-	<string>XDarwin</string>
-	<key>CFBundlePackageType</key>
-	<string>APPL</string>
-	<key>CFBundleShortVersionString</key>
-	<string>XDarwin 1.4.0</string>
-	<key>CFBundleSignature</key>
-	<string>????</string>
-	<key>CFBundleVersion</key>
-	<string></string>
-	<key>NSHelpFile</key>
-	<string>XDarwinHelp.html</string>
-	<key>NSMainNibFile</key>
-	<string>MainMenu</string>
-	<key>NSPrincipalClass</key>
-	<string>XApplication</string>
-</dict>
-</plist>
-";
-		};
-		0A79E1A0004499A1CE6F79C2 = {
-			buildActionMask = 2147483647;
-			files = (
-			);
-			isa = PBXHeadersBuildPhase;
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-		0A79E1A1004499A1CE6F79C2 = {
-			buildActionMask = 2147483647;
-			files = (
-				0A79E1A600449EB2CE6F79C2,
-				0A79E1A700449EB2CE6F79C2,
-				0A79E1A800449EB2CE6F79C2,
-				0A79E1A900449EB2CE6F79C2,
-				0A79E1AA00449EB2CE6F79C2,
-				1220774500712D2D416877C2,
-				F54BF6ED017D506E01000001,
-			);
-			isa = PBXResourcesBuildPhase;
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-		0A79E1A2004499A1CE6F79C2 = {
-			buildActionMask = 2147483647;
-			files = (
-			);
-			isa = PBXSourcesBuildPhase;
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-		0A79E1A3004499A1CE6F79C2 = {
-			buildActionMask = 2147483647;
-			files = (
-			);
-			isa = PBXFrameworksBuildPhase;
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-		0A79E1A4004499A1CE6F79C2 = {
-			buildActionMask = 2147483647;
-			files = (
-			);
-			isa = PBXRezBuildPhase;
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-		0A79E1A600449EB2CE6F79C2 = {
-			fileRef = 29B97318FDCFA39411CA2CEA;
-			isa = PBXBuildFile;
-			settings = {
-			};
-		};
-		0A79E1A700449EB2CE6F79C2 = {
-			fileRef = 089C165CFE840E0CC02AAC07;
-			isa = PBXBuildFile;
-			settings = {
-			};
-		};
-		0A79E1A800449EB2CE6F79C2 = {
-			fileRef = 0157A37D002CF6D7CE6F79C2;
-			isa = PBXBuildFile;
-			settings = {
-			};
-		};
-		0A79E1A900449EB2CE6F79C2 = {
-			fileRef = 02E03CA000348209CE6F79C2;
-			isa = PBXBuildFile;
-			settings = {
-			};
-		};
-		0A79E1AA00449EB2CE6F79C2 = {
-			fileRef = 015698ED003DF345CE6F79C2;
-			isa = PBXBuildFile;
-			settings = {
-			};
-		};
-//0A0
-//0A1
-//0A2
-//0A3
-//0A4
-//100
-//101
-//102
-//103
-//104
-		1058C7A0FEA54F0111CA2CBB = {
-			children = (
-				F53321400193CCF001000001,
-				1BE4F84D0006C9890A000002,
-				1058C7A1FEA54F0111CA2CBB,
-				F53321410193CCF001000001,
-				015EDCEA004203A8CE6F79C2,
-			);
-			isa = PBXGroup;
-			name = "Linked Frameworks";
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		1058C7A1FEA54F0111CA2CBB = {
-			isa = PBXFileReference;
-			lastKnownFileType = wrapper.framework;
-			name = Cocoa.framework;
-			path = /System/Library/Frameworks/Cocoa.framework;
-			refType = 0;
-			sourceTree = "<absolute>";
-		};
-		1058C7A2FEA54F0111CA2CBB = {
-			children = (
-				29B97325FDCFA39411CA2CEA,
-				29B97324FDCFA39411CA2CEA,
-			);
-			isa = PBXGroup;
-			name = "Other Frameworks";
-			refType = 4;
-			sourceTree = "<group>";
-		};
-//100
-//101
-//102
-//103
-//104
-//120
-//121
-//122
-//123
-//124
-		1220774300712D2D416877C2 = {
-			children = (
-				F533214501A4B42501000001,
-				1220774400712D2D416877C2,
-				F58D65DE018F79A001000001,
-				F533213C0193CBC901000001,
-				1220774600712D75416877C2,
-				F5ACD266C5BE03C501000001,
-				F51BF62D02026E1C01000001,
-				F5ACD25FC5B5E9AA01000001,
-				F587E16301924C5E01000001,
-			);
-			isa = PBXVariantGroup;
-			name = Localizable.strings;
-			path = "";
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		1220774400712D2D416877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = text.plist.strings;
-			name = English;
-			path = English.lproj/Localizable.strings;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		1220774500712D2D416877C2 = {
-			fileRef = 1220774300712D2D416877C2;
-			isa = PBXBuildFile;
-			settings = {
-			};
-		};
-		1220774600712D75416877C2 = {
-			fileEncoding = 10;
-			isa = PBXFileReference;
-			lastKnownFileType = text.plist.strings;
-			name = Japanese;
-			path = Japanese.lproj/Localizable.strings;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-//120
-//121
-//122
-//123
-//124
-//170
-//171
-//172
-//173
-//174
-		170DFAFF00729A35416877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = XDarwinStartup.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		170DFB0000729C86416877C2 = {
-			children = (
-				018F40FC003E1983CE6F79C2,
-				018F40FE003E1988CE6F79C2,
-				018F4100003E19E4CE6F79C2,
-				02A1FEA6006D34BE416877C2,
-			);
-			isa = PBXGroup;
-			name = IOKit;
-			path = ../iokit;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-//170
-//171
-//172
-//173
-//174
-//190
-//191
-//192
-//193
-//194
-		19C28FACFE9D520D11CA2CBB = {
-			children = (
-				0A79E19E004499A1CE6F79C2,
-				6EF7C58703D3BC6D00000104,
-				6EF065C603D4EE19006877C2,
-				6E11A985048BDFEE006877C2,
-				6E7904100500F05600EEC080,
-			);
-			isa = PBXGroup;
-			name = Products;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-//190
-//191
-//192
-//193
-//194
-//1B0
-//1B1
-//1B2
-//1B3
-//1B4
-		1BD8DE4200B8A3567F000001 = {
-			children = (
-				F533214401A4B40F01000001,
-				1BD8DE4300B8A3567F000001,
-				F58D65DC018F794D01000001,
-				F533213B0193CBB401000001,
-				1BD8DE4700B8A3C77F000001,
-				F5ACD264C5BE035B01000001,
-				F51BF62C02026E0601000001,
-				F5ACD25DC5B5E97701000001,
-				F587E16201924C5301000001,
-			);
-			isa = PBXVariantGroup;
-			name = InfoPlist.strings.cpp;
-			path = "";
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		1BD8DE4300B8A3567F000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.cpp.cpp;
-			name = English;
-			path = English.lproj/InfoPlist.strings.cpp;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		1BD8DE4400B8A38E7F000001 = {
-			children = (
-				F533214801A4B4D701000001,
-				1BD8DE4500B8A38E7F000001,
-				F58D65E1018F79E001000001,
-				F533213F0193CC2501000001,
-				1BD8DE4800B8A4167F000001,
-				F5ACD267C5BE03FC01000001,
-				F51BF63002026E8D01000001,
-				F5ACD260C5B5E9DF01000001,
-				F587E16601924C9D01000001,
-			);
-			isa = PBXVariantGroup;
-			name = XDarwinHelp.html.cpp;
-			path = "";
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		1BD8DE4500B8A38E7F000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.cpp.cpp;
-			name = English;
-			path = English.lproj/XDarwinHelp.html.cpp;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		1BD8DE4700B8A3C77F000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.cpp.cpp;
-			name = Japanese;
-			path = Japanese.lproj/InfoPlist.strings.cpp;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		1BD8DE4800B8A4167F000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.cpp.cpp;
-			name = Japanese;
-			path = Japanese.lproj/XDarwinHelp.html.cpp;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		1BE4F84D0006C9890A000002 = {
-			isa = PBXFileReference;
-			lastKnownFileType = wrapper.framework;
-			name = Carbon.framework;
-			path = /System/Library/Frameworks/Carbon.framework;
-			refType = 0;
-			sourceTree = "<absolute>";
-		};
-//1B0
-//1B1
-//1B2
-//1B3
-//1B4
-//1C0
-//1C1
-//1C2
-//1C3
-//1C4
-		1C4A3109004D8F24CE6F79C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.h;
-			path = XServer.h;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-//1C0
-//1C1
-//1C2
-//1C3
-//1C4
-//230
-//231
-//232
-//233
-//234
-		237A34C10076E37E7F000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = quartzAudio.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		237A34C20076E37E7F000001 = {
-			buildSettings = {
-				COPY_PHASE_STRIP = NO;
-				GCC_DYNAMIC_NO_PIC = NO;
-				GCC_ENABLE_FIX_AND_CONTINUE = YES;
-				GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
-				GCC_OPTIMIZATION_LEVEL = 0;
-				OPTIMIZATION_CFLAGS = "-O0";
-				ZERO_LINK = YES;
-			};
-			isa = PBXBuildStyle;
-			name = Development;
-		};
-		237A34C30076E37E7F000001 = {
-			buildSettings = {
-				COPY_PHASE_STRIP = YES;
-				GCC_ENABLE_FIX_AND_CONTINUE = NO;
-				ZERO_LINK = NO;
-			};
-			isa = PBXBuildStyle;
-			name = Deployment;
-		};
-		237A34C40076F4F07F000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.h;
-			path = quartzAudio.h;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-//230
-//231
-//232
-//233
-//234
-//290
-//291
-//292
-//293
-//294
-		29B97313FDCFA39411CA2CEA = {
-			buildSettings = {
-			};
-			buildStyles = (
-				237A34C20076E37E7F000001,
-				237A34C30076E37E7F000001,
-			);
-			hasScannedForEncodings = 1;
-			isa = PBXProject;
-			knownRegions = (
-				English,
-				Japanese,
-				French,
-				German,
-				Swedish,
-				Dutch,
-				Spanish,
-				ko,
-				Portuguese,
-			);
-			mainGroup = 29B97314FDCFA39411CA2CEA;
-			projectDirPath = "";
-			targets = (
-				0A79E19F004499A1CE6F79C2,
-				6EF7C58603D3BC6D00000104,
-				6E11A984048BDFEE006877C2,
-				6EF065C503D4EE19006877C2,
-				6E79040F0500F05600EEC080,
-			);
-		};
-		29B97314FDCFA39411CA2CEA = {
-			children = (
-				080E96DDFE201D6D7F000001,
-				018F40F2003E1902CE6F79C2,
-				170DFB0000729C86416877C2,
-				43B962CE00617089416877C2,
-				F5614B3D025112D901000114,
-				6EC4A64C042A9597006877C2,
-				32FEE13C00E07C3E7F000001,
-				6EE1214104968658006877C2,
-				6EC4A66D042A97FC006877C2,
-				29B97315FDCFA39411CA2CEA,
-				29B97317FDCFA39411CA2CEA,
-				29B97323FDCFA39411CA2CEA,
-				19C28FACFE9D520D11CA2CBB,
-			);
-			isa = PBXGroup;
-			name = "Xmaster-Cocoa";
-			path = "";
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		29B97315FDCFA39411CA2CEA = {
-			children = (
-				170DFAFF00729A35416877C2,
-			);
-			isa = PBXGroup;
-			name = "Other Sources";
-			path = "";
-			refType = 2;
-			sourceTree = SOURCE_ROOT;
-		};
-		29B97317FDCFA39411CA2CEA = {
-			children = (
-				29B97318FDCFA39411CA2CEA,
-				089C165CFE840E0CC02AAC07,
-				1BD8DE4200B8A3567F000001,
-				1220774300712D2D416877C2,
-				0157A37D002CF6D7CE6F79C2,
-				02E03CA000348209CE6F79C2,
-				1BD8DE4400B8A38E7F000001,
-				015698ED003DF345CE6F79C2,
-				F54BF6EA017D500901000001,
-				F54BF6EC017D506E01000001,
-			);
-			isa = PBXGroup;
-			name = Resources;
-			path = ../bundle;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		29B97318FDCFA39411CA2CEA = {
-			children = (
-				F533214201A4B3CE01000001,
-				29B97319FDCFA39411CA2CEA,
-				F58D65DB018F793801000001,
-				F53321390193CB6A01000001,
-				43B962E000617B49416877C2,
-				F5ACD265C5BE038601000001,
-				F51BF62A02026DAF01000001,
-				F5ACD25EC5B5E98D01000001,
-				F587E16001924C1D01000001,
-			);
-			isa = PBXVariantGroup;
-			name = MainMenu.nib;
-			path = "";
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		29B97319FDCFA39411CA2CEA = {
-			isa = PBXFileReference;
-			lastKnownFileType = wrapper.nib;
-			name = English;
-			path = English.lproj/MainMenu.nib;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		29B97323FDCFA39411CA2CEA = {
-			children = (
-				1058C7A0FEA54F0111CA2CBB,
-				1058C7A2FEA54F0111CA2CBB,
-			);
-			isa = PBXGroup;
-			name = Frameworks;
-			path = "";
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		29B97324FDCFA39411CA2CEA = {
-			isa = PBXFileReference;
-			lastKnownFileType = wrapper.framework;
-			name = AppKit.framework;
-			path = /System/Library/Frameworks/AppKit.framework;
-			refType = 0;
-			sourceTree = "<absolute>";
-		};
-		29B97325FDCFA39411CA2CEA = {
-			isa = PBXFileReference;
-			lastKnownFileType = wrapper.framework;
-			name = Foundation.framework;
-			path = /System/Library/Frameworks/Foundation.framework;
-			refType = 0;
-			sourceTree = "<absolute>";
-		};
-//290
-//291
-//292
-//293
-//294
-//320
-//321
-//322
-//323
-//324
-		32FEE13C00E07C3E7F000001 = {
-			children = (
-				F5269C2D01D5BC3501000001,
-				F5269C2E01D5BC3501000001,
-			);
-			isa = PBXGroup;
-			name = "Old Cocoa Imp";
-			path = "";
-			refType = 4;
-			sourceTree = "<group>";
-		};
-//320
-//321
-//322
-//323
-//324
-//350
-//351
-//352
-//353
-//354
-		3576829A0077B8F17F000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = quartzCursor.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-//350
-//351
-//352
-//353
-//354
-//3E0
-//3E1
-//3E2
-//3E3
-//3E4
-		3E74E03600863F047F000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.h;
-			path = darwinClut8.h;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-//3E0
-//3E1
-//3E2
-//3E3
-//3E4
-//430
-//431
-//432
-//433
-//434
-		43B962CE00617089416877C2 = {
-			children = (
-				6EE9B21604E859C200CA7FEA,
-				6E97A0F505079F9100B8294C,
-				6E5F5F030553815A008FEAD7,
-				6E5F5F040553815A008FEAD7,
-				018F40F8003E1979CE6F79C2,
-				018F40FA003E197ECE6F79C2,
-				237A34C10076E37E7F000001,
-				237A34C40076F4F07F000001,
-				43B962CF00617089416877C2,
-				F5582948015DAD3B01000001,
-				6E5F5F0105537A5F008FEAD7,
-				43B962D000617089416877C2,
-				43B962D100617089416877C2,
-				02A1FEA8006D38F0416877C2,
-			);
-			isa = PBXGroup;
-			name = Quartz;
-			path = "";
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		43B962CF00617089416877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.objc;
-			path = quartzCocoa.m;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		43B962D000617089416877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = quartzPasteboard.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		43B962D100617089416877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.h;
-			path = quartzPasteboard.h;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		43B962E000617B49416877C2 = {
-			isa = PBXFileReference;
-			lastKnownFileType = wrapper.nib;
-			name = Japanese;
-			path = Japanese.lproj/MainMenu.nib;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		43B962E100617B49416877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = text.plist.strings;
-			name = Japanese;
-			path = Japanese.lproj/InfoPlist.strings;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		43B962E200617B93416877C2 = {
-			isa = PBXFileReference;
-			lastKnownFileType = text.rtf;
-			name = Japanese;
-			path = Japanese.lproj/Credits.rtf;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		43B962E300617B93416877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = text.html;
-			name = Japanese;
-			path = Japanese.lproj/XDarwinHelp.html;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-//430
-//431
-//432
-//433
-//434
-//6E0
-//6E1
-//6E2
-//6E3
-//6E4
-		6E11A97F048BDFEE006877C2 = {
-			buildActionMask = 2147483647;
-			files = (
-			);
-			isa = PBXHeadersBuildPhase;
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-		6E11A980048BDFEE006877C2 = {
-			buildActionMask = 2147483647;
-			files = (
-			);
-			isa = PBXResourcesBuildPhase;
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-		6E11A981048BDFEE006877C2 = {
-			buildActionMask = 2147483647;
-			files = (
-			);
-			isa = PBXSourcesBuildPhase;
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-		6E11A982048BDFEE006877C2 = {
-			buildActionMask = 2147483647;
-			files = (
-			);
-			isa = PBXFrameworksBuildPhase;
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-		6E11A983048BDFEE006877C2 = {
-			buildActionMask = 2147483647;
-			files = (
-			);
-			isa = PBXRezBuildPhase;
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-		6E11A984048BDFEE006877C2 = {
-			buildPhases = (
-				6E11A97F048BDFEE006877C2,
-				6E11A980048BDFEE006877C2,
-				6E11A981048BDFEE006877C2,
-				6E11A982048BDFEE006877C2,
-				6E11A983048BDFEE006877C2,
-			);
-			buildSettings = {
-				OTHER_CFLAGS = "";
-				OTHER_LDFLAGS = "";
-				OTHER_REZFLAGS = "";
-				PRODUCT_NAME = glxCGL;
-				SECTORDER_FLAGS = "";
-				WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas";
-				WRAPPER_EXTENSION = bundle;
-			};
-			dependencies = (
-			);
-			isa = PBXBundleTarget;
-			name = glxCGL;
-			productInstallPath = "$(USER_LIBRARY_DIR)/Bundles";
-			productName = glxCGL;
-			productReference = 6E11A985048BDFEE006877C2;
-			productSettingsXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
-<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
-<plist version=\"1.0\">
-<dict>
-	<key>CFBundleDevelopmentRegion</key>
-	<string>English</string>
-	<key>CFBundleExecutable</key>
-	<string>glxCGL</string>
-	<key>CFBundleGetInfoString</key>
-	<string></string>
-	<key>CFBundleIconFile</key>
-	<string></string>
-	<key>CFBundleIdentifier</key>
-	<string></string>
-	<key>CFBundleInfoDictionaryVersion</key>
-	<string>6.0</string>
-	<key>CFBundleName</key>
-	<string>GLX bundle using Apple's OpenGL</string>
-	<key>CFBundlePackageType</key>
-	<string>BNDL</string>
-	<key>CFBundleShortVersionString</key>
-	<string>0.1</string>
-	<key>CFBundleSignature</key>
-	<string>????</string>
-	<key>CFBundleVersion</key>
-	<string>0.1</string>
-</dict>
-</plist>
-";
-		};
-		6E11A985048BDFEE006877C2 = {
-			explicitFileType = wrapper.cfbundle;
-			isa = PBXFileReference;
-			path = glxCGL.bundle;
-			refType = 3;
-			sourceTree = BUILT_PRODUCTS_DIR;
-		};
-		6E11A986048BDFFB006877C2 = {
-			isa = PBXTargetDependency;
-			target = 6E11A984048BDFEE006877C2;
-			targetProxy = 6E4CAF650702464F001A7398;
-		};
-		6E4CAF630702464F001A7398 = {
-			containerPortal = 29B97313FDCFA39411CA2CEA;
-			isa = PBXContainerItemProxy;
-			proxyType = 1;
-			remoteGlobalIDString = 6EF7C58603D3BC6D00000104;
-			remoteInfo = glxAGL;
-		};
-		6E4CAF640702464F001A7398 = {
-			containerPortal = 29B97313FDCFA39411CA2CEA;
-			isa = PBXContainerItemProxy;
-			proxyType = 1;
-			remoteGlobalIDString = 6E79040F0500F05600EEC080;
-			remoteInfo = xpr;
-		};
-		6E4CAF650702464F001A7398 = {
-			containerPortal = 29B97313FDCFA39411CA2CEA;
-			isa = PBXContainerItemProxy;
-			proxyType = 1;
-			remoteGlobalIDString = 6E11A984048BDFEE006877C2;
-			remoteInfo = glxCGL;
-		};
-		6E4CAF660702464F001A7398 = {
-			containerPortal = 29B97313FDCFA39411CA2CEA;
-			isa = PBXContainerItemProxy;
-			proxyType = 1;
-			remoteGlobalIDString = 6EF065C503D4EE19006877C2;
-			remoteInfo = glxMesa;
-		};
-		6E5F5F0005537A1A008FEAD7 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.h;
-			path = darwinKeyboard.h;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6E5F5F0105537A5F008FEAD7 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = quartzKeyboard.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6E5F5F030553815A008FEAD7 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = keysym2ucs.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6E5F5F040553815A008FEAD7 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.h;
-			path = keysym2ucs.h;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6E6656EC048832CF006877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = "x-hook.c";
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6E6656ED048832CF006877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.h;
-			path = "x-hook.h";
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6E6656F0048832EC006877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = dri.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6E6656F1048832EC006877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.h;
-			path = dri.h;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6E6656F2048832EC006877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.h;
-			path = dristruct.h;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6E6656F3048832F9006877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = appledri.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6E79040104FD5ED900EEC080 = {
-			children = (
-				6E79040204FD5EDA00EEC080,
-				6E79040304FD5EDA00EEC080,
-				6E79040404FD5EDA00EEC080,
-			);
-			isa = PBXGroup;
-			name = "Safe Alpha";
-			path = safeAlpha;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6E79040204FD5EDA00EEC080 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.h;
-			path = safeAlpha.h;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6E79040304FD5EDA00EEC080 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = safeAlphaPicture.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6E79040404FD5EDA00EEC080 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = safeAlphaWindow.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6E79040A0500F05600EEC080 = {
-			buildActionMask = 2147483647;
-			files = (
-			);
-			isa = PBXHeadersBuildPhase;
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-		6E79040B0500F05600EEC080 = {
-			buildActionMask = 2147483647;
-			files = (
-			);
-			isa = PBXResourcesBuildPhase;
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-		6E79040C0500F05600EEC080 = {
-			buildActionMask = 2147483647;
-			files = (
-			);
-			isa = PBXSourcesBuildPhase;
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-		6E79040D0500F05600EEC080 = {
-			buildActionMask = 2147483647;
-			files = (
-			);
-			isa = PBXFrameworksBuildPhase;
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-		6E79040E0500F05600EEC080 = {
-			buildActionMask = 2147483647;
-			files = (
-			);
-			isa = PBXRezBuildPhase;
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-		6E79040F0500F05600EEC080 = {
-			buildPhases = (
-				6E79040A0500F05600EEC080,
-				6E79040B0500F05600EEC080,
-				6E79040C0500F05600EEC080,
-				6E79040D0500F05600EEC080,
-				6E79040E0500F05600EEC080,
-			);
-			buildSettings = {
-				OTHER_CFLAGS = "";
-				OTHER_LDFLAGS = "";
-				OTHER_REZFLAGS = "";
-				PRODUCT_NAME = xpr;
-				SECTORDER_FLAGS = "";
-				WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas";
-				WRAPPER_EXTENSION = bundle;
-			};
-			dependencies = (
-			);
-			isa = PBXBundleTarget;
-			name = xpr;
-			productInstallPath = "$(USER_LIBRARY_DIR)/Bundles";
-			productName = xpr;
-			productReference = 6E7904100500F05600EEC080;
-			productSettingsXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
-<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
-<plist version=\"1.0\">
-<dict>
-	<key>CFBundleDevelopmentRegion</key>
-	<string>English</string>
-	<key>CFBundleExecutable</key>
-	<string>xpr</string>
-	<key>CFBundleGetInfoString</key>
-	<string></string>
-	<key>CFBundleIconFile</key>
-	<string></string>
-	<key>CFBundleIdentifier</key>
-	<string></string>
-	<key>CFBundleInfoDictionaryVersion</key>
-	<string>6.0</string>
-	<key>CFBundleName</key>
-	<string>Xplugin rootless implementation</string>
-	<key>CFBundlePackageType</key>
-	<string>BNDL</string>
-	<key>CFBundleShortVersionString</key>
-	<string>0.1</string>
-	<key>CFBundleSignature</key>
-	<string>????</string>
-	<key>CFBundleVersion</key>
-	<string>0.1</string>
-</dict>
-</plist>
-";
-		};
-		6E7904100500F05600EEC080 = {
-			explicitFileType = wrapper.cfbundle;
-			isa = PBXFileReference;
-			path = xpr.bundle;
-			refType = 3;
-			sourceTree = BUILT_PRODUCTS_DIR;
-		};
-		6E7904110500F33B00EEC080 = {
-			isa = PBXTargetDependency;
-			target = 6E79040F0500F05600EEC080;
-			targetProxy = 6E4CAF640702464F001A7398;
-		};
-		6E97A0F2050798B100B8294C = {
-			fileEncoding = 4;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = xprAppleWM.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6E97A0F305079B6500B8294C = {
-			fileEncoding = 4;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.objc;
-			path = crAppleWM.m;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6E97A0F505079F9100B8294C = {
-			fileEncoding = 4;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.h;
-			path = applewmExt.h;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6EA0B3AF0544A9CC006877C2 = {
-			children = (
-				6EA0B3B00544A9CC006877C2,
-				6EA0B3B10544A9CC006877C2,
-				6EA0B3B20544A9CC006877C2,
-				6EA0B3B30544A9CC006877C2,
-				6EA0B3B40544A9CC006877C2,
-				6EA0B3B50544A9CC006877C2,
-				6EA0B3B60544A9CC006877C2,
-				6EA0B3B70544A9CC006877C2,
-			);
-			isa = PBXGroup;
-			name = Acceleration;
-			path = accel;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6EA0B3B00544A9CC006877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.h;
-			path = rlAccel.h;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6EA0B3B10544A9CC006877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = rlBlt.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6EA0B3B20544A9CC006877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = rlCopy.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6EA0B3B30544A9CC006877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = rlFill.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6EA0B3B40544A9CC006877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = rlFillRect.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6EA0B3B50544A9CC006877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = rlFillSpans.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6EA0B3B60544A9CC006877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = rlGlyph.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6EA0B3B70544A9CC006877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = rlSolid.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6EA8EEC80445E25C006877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.h;
-			path = rootlessConfig.h;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6EC4A64C042A9597006877C2 = {
-			children = (
-				6EC4A65D042A9654006877C2,
-				6EC4A65E042A9654006877C2,
-				6EC4A65F042A9654006877C2,
-				6EA8EEC80445E25C006877C2,
-				6EC4A661042A9654006877C2,
-				6EC4A662042A9654006877C2,
-				6EC4A660042A9654006877C2,
-				6EC4A663042A9654006877C2,
-				6EC4A664042A9654006877C2,
-				6EA0B3AF0544A9CC006877C2,
-				6E79040104FD5ED900EEC080,
-			);
-			isa = PBXGroup;
-			name = Rootless;
-			path = ../../../miext/rootless;
-			refType = 2;
-			sourceTree = SOURCE_ROOT;
-		};
-		6EC4A65D042A9654006877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.h;
-			path = rootless.h;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6EC4A65E042A9654006877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = rootlessCommon.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6EC4A65F042A9654006877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.h;
-			path = rootlessCommon.h;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6EC4A660042A9654006877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.h;
-			path = rootlessWindow.h;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6EC4A661042A9654006877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = rootlessScreen.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6EC4A662042A9654006877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = rootlessWindow.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6EC4A663042A9654006877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = rootlessGC.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6EC4A664042A9654006877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = rootlessValTree.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6EC4A66D042A97FC006877C2 = {
-			children = (
-				6EF471A004478DE0006877C2,
-				6E6656F3048832F9006877C2,
-				6E6656F0048832EC006877C2,
-				6E6656F1048832EC006877C2,
-				6E6656F2048832EC006877C2,
-				6ECF218404589E4D006877C2,
-				6E97A0F2050798B100B8294C,
-				6ECF218604589F40006877C2,
-				6EF4719E04478B08006877C2,
-				6EDDB2DF04508B2C006877C2,
-				6EF471A204479263006877C2,
-				6EF471A404479263006877C2,
-				6E6656EC048832CF006877C2,
-				6E6656ED048832CF006877C2,
-				6EF471A504479263006877C2,
-				6EF471A304479263006877C2,
-			);
-			isa = PBXGroup;
-			path = xpr;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6ECF218404589E4D006877C2 = {
-			fileEncoding = 4;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.h;
-			path = xpr.h;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6ECF218604589F40006877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = xprCursor.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6EDDB2DF04508B2C006877C2 = {
-			fileEncoding = 4;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = xprScreen.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6EE1214104968658006877C2 = {
-			children = (
-				6EE1214304968692006877C2,
-				6EE1214404968692006877C2,
-				6EE1214204968692006877C2,
-				6E97A0F305079B6500B8294C,
-				6EE1214504968692006877C2,
-				6EE1214604968692006877C2,
-			);
-			isa = PBXGroup;
-			path = cr;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6EE1214204968692006877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.h;
-			path = cr.h;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6EE1214304968692006877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.objc;
-			path = XView.m;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6EE1214404968692006877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.h;
-			path = XView.h;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6EE1214504968692006877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.objc;
-			path = crFrame.m;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6EE1214604968692006877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.objc;
-			path = crScreen.m;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6EE9B21604E859C200CA7FEA = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = applewm.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6EF065C003D4EE19006877C2 = {
-			buildActionMask = 2147483647;
-			files = (
-			);
-			isa = PBXHeadersBuildPhase;
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-		6EF065C103D4EE19006877C2 = {
-			buildActionMask = 2147483647;
-			files = (
-			);
-			isa = PBXResourcesBuildPhase;
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-		6EF065C203D4EE19006877C2 = {
-			buildActionMask = 2147483647;
-			files = (
-			);
-			isa = PBXSourcesBuildPhase;
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-		6EF065C303D4EE19006877C2 = {
-			buildActionMask = 2147483647;
-			files = (
-			);
-			isa = PBXFrameworksBuildPhase;
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-		6EF065C403D4EE19006877C2 = {
-			buildActionMask = 2147483647;
-			files = (
-			);
-			isa = PBXRezBuildPhase;
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-		6EF065C503D4EE19006877C2 = {
-			buildPhases = (
-				6EF065C003D4EE19006877C2,
-				6EF065C103D4EE19006877C2,
-				6EF065C203D4EE19006877C2,
-				6EF065C303D4EE19006877C2,
-				6EF065C403D4EE19006877C2,
-			);
-			buildSettings = {
-				OTHER_CFLAGS = "";
-				OTHER_LDFLAGS = "";
-				OTHER_REZFLAGS = "";
-				PRODUCT_NAME = glxMesa;
-				SECTORDER_FLAGS = "";
-				WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas";
-				WRAPPER_EXTENSION = bundle;
-			};
-			dependencies = (
-			);
-			isa = PBXBundleTarget;
-			name = glxMesa;
-			productInstallPath = "$(USER_LIBRARY_DIR)/Bundles";
-			productName = glxMesa;
-			productReference = 6EF065C603D4EE19006877C2;
-			productSettingsXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
-<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
-<plist version=\"1.0\">
-<dict>
-	<key>CFBundleDevelopmentRegion</key>
-	<string>English</string>
-	<key>CFBundleExecutable</key>
-	<string>glxMesa</string>
-	<key>CFBundleGetInfoString</key>
-	<string></string>
-	<key>CFBundleIconFile</key>
-	<string></string>
-	<key>CFBundleIdentifier</key>
-	<string></string>
-	<key>CFBundleInfoDictionaryVersion</key>
-	<string>6.0</string>
-	<key>CFBundleName</key>
-	<string>GLX bundle with Mesa</string>
-	<key>CFBundlePackageType</key>
-	<string>BNDL</string>
-	<key>CFBundleShortVersionString</key>
-	<string>0.1</string>
-	<key>CFBundleSignature</key>
-	<string>????</string>
-	<key>CFBundleVersion</key>
-	<string>0.1</string>
-</dict>
-</plist>
-";
-		};
-		6EF065C603D4EE19006877C2 = {
-			explicitFileType = wrapper.cfbundle;
-			isa = PBXFileReference;
-			path = glxMesa.bundle;
-			refType = 3;
-			sourceTree = BUILT_PRODUCTS_DIR;
-		};
-		6EF065C703D4EE19006877C2 = {
-			isa = PBXTargetDependency;
-			target = 6EF065C503D4EE19006877C2;
-			targetProxy = 6E4CAF660702464F001A7398;
-		};
-		6EF065C903D4F0CA006877C2 = {
-			isa = PBXTargetDependency;
-			target = 6EF7C58603D3BC6D00000104;
-			targetProxy = 6E4CAF630702464F001A7398;
-		};
-		6EF4719E04478B08006877C2 = {
-			fileEncoding = 4;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = xprFrame.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6EF471A004478DE0006877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.h;
-			path = Xplugin.h;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6EF471A204479263006877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = "x-hash.c";
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6EF471A304479263006877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.h;
-			path = "x-list.h";
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6EF471A404479263006877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.h;
-			path = "x-hash.h";
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6EF471A504479263006877C2 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = "x-list.c";
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		6EF7C58103D3BC6D00000104 = {
-			buildActionMask = 2147483647;
-			files = (
-			);
-			isa = PBXHeadersBuildPhase;
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-		6EF7C58203D3BC6D00000104 = {
-			buildActionMask = 2147483647;
-			files = (
-			);
-			isa = PBXResourcesBuildPhase;
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-		6EF7C58303D3BC6D00000104 = {
-			buildActionMask = 2147483647;
-			files = (
-			);
-			isa = PBXSourcesBuildPhase;
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-		6EF7C58403D3BC6D00000104 = {
-			buildActionMask = 2147483647;
-			files = (
-			);
-			isa = PBXFrameworksBuildPhase;
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-		6EF7C58503D3BC6D00000104 = {
-			buildActionMask = 2147483647;
-			files = (
-			);
-			isa = PBXRezBuildPhase;
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-		6EF7C58603D3BC6D00000104 = {
-			buildPhases = (
-				6EF7C58103D3BC6D00000104,
-				6EF7C58203D3BC6D00000104,
-				6EF7C58303D3BC6D00000104,
-				6EF7C58403D3BC6D00000104,
-				6EF7C58503D3BC6D00000104,
-			);
-			buildSettings = {
-				OTHER_CFLAGS = "";
-				OTHER_LDFLAGS = "";
-				OTHER_REZFLAGS = "";
-				PRODUCT_NAME = glxAGL;
-				SECTORDER_FLAGS = "";
-				WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas";
-				WRAPPER_EXTENSION = bundle;
-			};
-			dependencies = (
-			);
-			isa = PBXBundleTarget;
-			name = glxAGL;
-			productName = glxAGL;
-			productReference = 6EF7C58703D3BC6D00000104;
-			productSettingsXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
-<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
-<plist version=\"1.0\">
-<dict>
-	<key>CFBundleDevelopmentRegion</key>
-	<string>English</string>
-	<key>CFBundleExecutable</key>
-	<string>glxAGL</string>
-	<key>CFBundleGetInfoString</key>
-	<string></string>
-	<key>CFBundleIconFile</key>
-	<string></string>
-	<key>CFBundleIdentifier</key>
-	<string></string>
-	<key>CFBundleInfoDictionaryVersion</key>
-	<string>6.0</string>
-	<key>CFBundleName</key>
-	<string>GLX bundle using AGL framework</string>
-	<key>CFBundlePackageType</key>
-	<string>BNDL</string>
-	<key>CFBundleShortVersionString</key>
-	<string>0.1</string>
-	<key>CFBundleSignature</key>
-	<string>????</string>
-	<key>CFBundleVersion</key>
-	<string>0.1</string>
-</dict>
-</plist>
-";
-		};
-		6EF7C58703D3BC6D00000104 = {
-			explicitFileType = wrapper.cfbundle;
-			isa = PBXFileReference;
-			path = glxAGL.bundle;
-			refType = 3;
-			sourceTree = BUILT_PRODUCTS_DIR;
-		};
-//6E0
-//6E1
-//6E2
-//6E3
-//6E4
-//F50
-//F51
-//F52
-//F53
-//F54
-		F51BF62A02026DAF01000001 = {
-			isa = PBXFileReference;
-			lastKnownFileType = wrapper.nib;
-			name = Portuguese;
-			path = Portuguese.lproj/MainMenu.nib;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F51BF62B02026DDA01000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = text.plist.strings;
-			name = Portuguese;
-			path = Portuguese.lproj/InfoPlist.strings;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F51BF62C02026E0601000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.cpp.cpp;
-			name = Portuguese;
-			path = Portuguese.lproj/InfoPlist.strings.cpp;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F51BF62D02026E1C01000001 = {
-			fileEncoding = 10;
-			isa = PBXFileReference;
-			lastKnownFileType = text.plist.strings;
-			name = Portuguese;
-			path = Portuguese.lproj/Localizable.strings;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F51BF62E02026E3501000001 = {
-			isa = PBXFileReference;
-			lastKnownFileType = text.rtf;
-			name = Portuguese;
-			path = Portuguese.lproj/Credits.rtf;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F51BF62F02026E5C01000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = text.html;
-			name = Portuguese;
-			path = Portuguese.lproj/XDarwinHelp.html;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F51BF63002026E8D01000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.cpp.cpp;
-			name = Portuguese;
-			path = Portuguese.lproj/XDarwinHelp.html.cpp;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F5269C2D01D5BC3501000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = pseudoramiX.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F5269C2E01D5BC3501000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.h;
-			path = pseudoramiX.h;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F53321390193CB6A01000001 = {
-			isa = PBXFileReference;
-			lastKnownFileType = wrapper.nib;
-			name = German;
-			path = German.lproj/MainMenu.nib;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F533213A0193CBA201000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = text.plist.strings;
-			name = German;
-			path = German.lproj/InfoPlist.strings;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F533213B0193CBB401000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.cpp.cpp;
-			name = German;
-			path = German.lproj/InfoPlist.strings.cpp;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F533213C0193CBC901000001 = {
-			fileEncoding = 10;
-			isa = PBXFileReference;
-			lastKnownFileType = text.plist.strings;
-			name = German;
-			path = German.lproj/Localizable.strings;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F533213D0193CBE001000001 = {
-			isa = PBXFileReference;
-			lastKnownFileType = text.rtf;
-			name = German;
-			path = German.lproj/Credits.rtf;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F533213E0193CBF401000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = text.html;
-			name = German;
-			path = German.lproj/XDarwinHelp.html;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F533213F0193CC2501000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.cpp.cpp;
-			name = German;
-			path = German.lproj/XDarwinHelp.html.cpp;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F53321400193CCF001000001 = {
-			isa = PBXFileReference;
-			lastKnownFileType = wrapper.framework;
-			name = ApplicationServices.framework;
-			path = /System/Library/Frameworks/ApplicationServices.framework;
-			refType = 0;
-			sourceTree = "<absolute>";
-		};
-		F53321410193CCF001000001 = {
-			isa = PBXFileReference;
-			lastKnownFileType = wrapper.framework;
-			name = CoreAudio.framework;
-			path = /System/Library/Frameworks/CoreAudio.framework;
-			refType = 0;
-			sourceTree = "<absolute>";
-		};
-		F533214201A4B3CE01000001 = {
-			isa = PBXFileReference;
-			lastKnownFileType = wrapper.nib;
-			name = Dutch;
-			path = Dutch.lproj/MainMenu.nib;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F533214301A4B3F001000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = text.plist.strings;
-			name = Dutch;
-			path = Dutch.lproj/InfoPlist.strings;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F533214401A4B40F01000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.cpp.cpp;
-			name = Dutch;
-			path = Dutch.lproj/InfoPlist.strings.cpp;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F533214501A4B42501000001 = {
-			fileEncoding = 10;
-			isa = PBXFileReference;
-			lastKnownFileType = text.plist.strings;
-			name = Dutch;
-			path = Dutch.lproj/Localizable.strings;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F533214601A4B45401000001 = {
-			isa = PBXFileReference;
-			lastKnownFileType = text.rtf;
-			name = Dutch;
-			path = Dutch.lproj/Credits.rtf;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F533214701A4B48301000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = text.html;
-			name = Dutch;
-			path = Dutch.lproj/XDarwinHelp.html;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F533214801A4B4D701000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.cpp.cpp;
-			name = Dutch;
-			path = Dutch.lproj/XDarwinHelp.html.cpp;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F54BF6EA017D500901000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.cpp.cpp;
-			path = startXClients.cpp;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F54BF6EC017D506E01000001 = {
-			isa = PBXFileReference;
-			lastKnownFileType = text.script.sh;
-			path = startXClients;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F54BF6ED017D506E01000001 = {
-			fileRef = F54BF6EC017D506E01000001;
-			isa = PBXBuildFile;
-			settings = {
-			};
-		};
-		F5582948015DAD3B01000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.h;
-			path = quartzCommon.h;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F5614B3B0251124C01000114 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = fullscreen.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F5614B3D025112D901000114 = {
-			children = (
-				F5614B3B0251124C01000114,
-				3576829A0077B8F17F000001,
-				0338412F0083BFE57F000001,
-			);
-			isa = PBXGroup;
-			path = fullscreen;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F587E16001924C1D01000001 = {
-			isa = PBXFileReference;
-			lastKnownFileType = wrapper.nib;
-			name = Swedish;
-			path = Swedish.lproj/MainMenu.nib;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F587E16101924C2F01000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = text.plist.strings;
-			name = Swedish;
-			path = Swedish.lproj/InfoPlist.strings;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F587E16201924C5301000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.cpp.cpp;
-			name = Swedish;
-			path = Swedish.lproj/InfoPlist.strings.cpp;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F587E16301924C5E01000001 = {
-			fileEncoding = 10;
-			isa = PBXFileReference;
-			lastKnownFileType = text.plist.strings;
-			name = Swedish;
-			path = Swedish.lproj/Localizable.strings;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F587E16401924C6901000001 = {
-			isa = PBXFileReference;
-			lastKnownFileType = text.rtf;
-			name = Swedish;
-			path = Swedish.lproj/Credits.rtf;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F587E16501924C7401000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = text.html;
-			name = Swedish;
-			path = Swedish.lproj/XDarwinHelp.html;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F587E16601924C9D01000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.cpp.cpp;
-			name = Swedish;
-			path = Swedish.lproj/XDarwinHelp.html.cpp;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F58D65DB018F793801000001 = {
-			isa = PBXFileReference;
-			lastKnownFileType = wrapper.nib;
-			name = French;
-			path = French.lproj/MainMenu.nib;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F58D65DC018F794D01000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.cpp.cpp;
-			name = French;
-			path = French.lproj/InfoPlist.strings.cpp;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F58D65DD018F798F01000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = text.plist.strings;
-			name = French;
-			path = French.lproj/InfoPlist.strings;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F58D65DE018F79A001000001 = {
-			fileEncoding = 10;
-			isa = PBXFileReference;
-			lastKnownFileType = text.plist.strings;
-			name = French;
-			path = French.lproj/Localizable.strings;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F58D65DF018F79B101000001 = {
-			isa = PBXFileReference;
-			lastKnownFileType = text.rtf;
-			name = French;
-			path = French.lproj/Credits.rtf;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F58D65E0018F79C001000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = text.html;
-			name = French;
-			path = French.lproj/XDarwinHelp.html;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F58D65E1018F79E001000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.cpp.cpp;
-			name = French;
-			path = French.lproj/XDarwinHelp.html.cpp;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F5A94EF10314BAC70100011B = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.c.c;
-			path = darwinEvents.c;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F5ACD25CC5B5E96601000001 = {
-			isa = PBXFileReference;
-			lastKnownFileType = text.rtf;
-			name = Spanish;
-			path = Spanish.lproj/Credits.rtf;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F5ACD25DC5B5E97701000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.cpp.cpp;
-			name = Spanish;
-			path = Spanish.lproj/InfoPlist.strings.cpp;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F5ACD25EC5B5E98D01000001 = {
-			isa = PBXFileReference;
-			lastKnownFileType = wrapper.nib;
-			name = Spanish;
-			path = Spanish.lproj/MainMenu.nib;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F5ACD25FC5B5E9AA01000001 = {
-			fileEncoding = 10;
-			isa = PBXFileReference;
-			lastKnownFileType = text.plist.strings;
-			name = Spanish;
-			path = Spanish.lproj/Localizable.strings;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F5ACD260C5B5E9DF01000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.cpp.cpp;
-			name = Spanish;
-			path = Spanish.lproj/XDarwinHelp.html.cpp;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F5ACD261C5B5EA2001000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = text.html;
-			name = Spanish;
-			path = Spanish.lproj/XDarwinHelp.html;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F5ACD262C5B5EA4D01000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = text.plist.strings;
-			name = Spanish;
-			path = Spanish.lproj/InfoPlist.strings;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F5ACD263C5BE031F01000001 = {
-			isa = PBXFileReference;
-			lastKnownFileType = text.rtf;
-			name = ko;
-			path = ko.lproj/Credits.rtf;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F5ACD264C5BE035B01000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.cpp.cpp;
-			name = ko;
-			path = ko.lproj/InfoPlist.strings.cpp;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F5ACD265C5BE038601000001 = {
-			isa = PBXFileReference;
-			lastKnownFileType = wrapper.nib;
-			name = ko;
-			path = ko.lproj/MainMenu.nib;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F5ACD266C5BE03C501000001 = {
-			fileEncoding = 10;
-			isa = PBXFileReference;
-			lastKnownFileType = text.plist.strings;
-			name = ko;
-			path = ko.lproj/Localizable.strings;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F5ACD267C5BE03FC01000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = sourcecode.cpp.cpp;
-			name = ko;
-			path = ko.lproj/XDarwinHelp.html.cpp;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F5ACD268C5BE046401000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = text.html;
-			name = ko;
-			path = ko.lproj/XDarwinHelp.html;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-		F5ACD269C5BE049301000001 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			lastKnownFileType = text.plist.strings;
-			name = ko;
-			path = ko.lproj/InfoPlist.strings;
-			refType = 4;
-			sourceTree = "<group>";
-		};
-	};
-	rootObject = 29B97313FDCFA39411CA2CEA;
-}
diff --git a/hw/darwin/quartz/XDarwinStartup.c b/hw/darwin/quartz/XDarwinStartup.c
deleted file mode 100644
index 3ad4898..0000000
--- a/hw/darwin/quartz/XDarwinStartup.c
+++ /dev/null
@@ -1,166 +0,0 @@
-/**************************************************************
- *
- * Startup program for Darwin X servers
- *
- * This program selects the appropriate X server to launch:
- *  XDarwin         IOKit X server (default)
- *  XDarwinQuartz   A soft link to the Quartz X server
- *                  executable (-quartz etc. option)
- *
- * If told to idle, the program will simply pause and not
- * launch any X server. This is to support startx being
- * run by XDarwin.app.
- *
- **************************************************************/
-/*
- * Copyright (c) 2001-2002 Torrey T. Lyons. 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
- * TORREY T. LYONS 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 Torrey T. Lyons shall not
- * be used in advertising or otherwise to promote the sale, use or other
- * dealings in this Software without prior written authorization from
- * Torrey T. Lyons.
- */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <sys/syslimits.h>
-#include <ApplicationServices/ApplicationServices.h>
-
-// Macros to build the path name
-#ifndef XBINDIR
-#define XBINDIR /usr/X11/bin
-#endif
-#define STR(s) #s
-#define XSTRPATH(s) STR(s) "/"
-#define XPATH(file) XSTRPATH(XBINDIR) STR(file)
-
-int main(
-    int         argc,
-    char        *argv[] )
-{
-    int         i, j, quartzMode = -1;
-    char        **newargv;
-
-    // Check if we are going to run in Quartz mode or idle
-    // to support startx from the Quartz server. The last
-    // parameter in the list is the one used.
-    for (i = argc-1; i; i--) {
-        if (!strcmp(argv[i], "-idle")) {
-            pause();
-            return 0;
-
-        } else if (!strcmp(argv[i], "-quartz") ||
-                   !strcmp(argv[i], "-rootless") ||
-                   !strcmp(argv[i], "-fullscreen"))
-        {
-            quartzMode = 1;
-            break;
-
-        } else if (!strcmp(argv[i], "-iokit")) {
-            quartzMode = 0;
-            break;
-        }
-    }
-
-    if (quartzMode == -1) {
-#ifdef HAS_CG_MACH_PORT
-        // Check if the CoreGraphics window server is running.
-        // Mike Paquette says this is the fastest way to determine if it is running.
-        CFMachPortRef cgMachPortRef = CGWindowServerCFMachPort();
-        if (cgMachPortRef == NULL)
-            quartzMode = 0;
-        else
-            quartzMode = 1;
-#else
-        // On older systems we assume IOKit mode.
-        quartzMode = 0;
-#endif
-    }
-
-    if (quartzMode) {
-        // Launch the X server for the quartz modes
-
-        char quartzPath[PATH_MAX+1];
-        int pathLength;
-        OSStatus theStatus;
-        CFURLRef appURL;
-        CFStringRef appPath;
-        Boolean success;
-
-        // Build the new argument list
-        newargv = (char **) malloc((argc+2) * sizeof(char *));
-        for (j = argc; j; j--)
-            newargv[j] = argv[j];
-        newargv[argc] = "-nostartx";
-        newargv[argc+1] = NULL;
-
-        // Use the XDarwinQuartz soft link if it is valid
-        pathLength = readlink(XPATH(XDarwinQuartz), quartzPath, PATH_MAX);
-        if (pathLength != -1) {
-            quartzPath[pathLength] = '\0';
-            newargv[0] = quartzPath;
-            execv(newargv[0], newargv);
-        }
-
-        // Otherwise query LaunchServices for the location of the XDarwin application
-        theStatus = LSFindApplicationForInfo(kLSUnknownCreator,
-                                             CFSTR("org.x.x11"),
-                                             NULL, NULL, &appURL);
-        if (theStatus) {
-            fprintf(stderr, "Could not find the XDarwin application. (Error = 0x%lx)\n", theStatus);
-            fprintf(stderr, "Launch XDarwin once from the Finder.\n");
-            return theStatus;
-        }
-
-        appPath = CFURLCopyFileSystemPath (appURL, kCFURLPOSIXPathStyle);
-        success = CFStringGetCString(appPath, quartzPath, PATH_MAX, CFStringGetSystemEncoding());
-        if (! success) {
-            fprintf(stderr, "Could not find path to XDarwin application.\n");
-            return success;
-        }
-
-        // Launch the XDarwin application
-        strncat(quartzPath, "/Contents/MacOS/XDarwin", PATH_MAX);
-        newargv[0] = quartzPath;
-        execv(newargv[0], newargv);
-        fprintf(stderr, "Could not start XDarwin application at %s.\n", newargv[0]);
-        return errno;
-
-    } else {
-
-        // Build the new argument list
-        newargv = (char **) malloc((argc+1) * sizeof(char *));
-        for (j = argc; j; j--)
-            newargv[j] = argv[j];
-        newargv[0] = "XDarwin";
-        newargv[argc] = NULL;
-    
-        // Launch the IOKit X server
-        execvp(newargv[0], newargv);
-        fprintf(stderr, "Could not start XDarwin IOKit X server.\n");
-        return errno;
-    }
-}
diff --git a/hw/darwin/quartz/XDarwinStartup.man b/hw/darwin/quartz/XDarwinStartup.man
deleted file mode 100644
index 1ad3bbc..0000000
--- a/hw/darwin/quartz/XDarwinStartup.man
+++ /dev/null
@@ -1,74 +0,0 @@
-.TH XDarwinStartup 1
-.SH NAME
-XDarwinStartup - Startup program for the XDarwin X window server
-.SH SYNOPSIS
-.B XDarwinStartup
-[\fI-iokit\fP]
-[\fI-fullscreen\fP]
-[\fI-rootless\fP]
-[\fI-quartz\fP]
-[\fI-idle\fP]
-[\fIoptions\fP]
-.SH DESCRIPTION
-The \fIXDarwin(1)\fP X window server can be run in a variety of different
-modes and is actually two different executables. The IOKit X server,
-XDarwin, is used when running from the console. It is most commonly
-located in __XBinDir__. The Quartz X server, for running in parallel with
-Aqua, is a full-fledged Mac OS X application that can be started from
-the Finder. Its application bundle is XDarwin.app, which is typically
-located in /Applications.
-.I XDarwinStartup
-allows easy switching between these X servers and auto-detection of the
-appropriate one to use when launching from the command line.
-When run without any arguments,
-.I XDarwinStartup
-will start the Quartz X server if the Core Graphics window server
-is currently running. Otherwise it will start the IOKit X server.
-.PP
-To locate the Quartz X server,
-.I XDarwinStartup
-will try to read the soft link at __XBinDir__/XDarwinQuartz.
-This is typically a soft link to the executable of the XDarwin.app
-application. If this fails,
-.I XDarwinStartup
-will call Launch Services to locate XDarwin.app.
-.PP
-To start the IOKit X server,
-.I XDarwinStartup
-will run the XDarwin executable, which should be present in the
-user's path.
-.SH OPTIONS
-.I XDarwinStartup
-accepts and passes on all options to the X server it
-launches. In addition the following options have specific effects:
-.TP 8
-.B \-iokit
-Launch the IOKit X server.
-.TP 8
-.B \-fullscreen
-Launch the Quartz X server to run in full screen mode.
-.TP 8
-.B \-rootless
-Launch the Quartz X server to run in rootless mode.
-.TP 8
-.B \-quartz
-Launch the Quartz X server.
-.TP 8
-.B \-idle
-Pause and do nothing. This option is used by XDarwin.app when it is
-started from the Finder.
-.SH FILES
-.TP 30
-__XBinDir__/XDarwin
-IOKit mode X server
-.TP 30
-/Applications/XDarwin.app
-Quartz mode X server
-.TP 30
-__XBinDir__/XDarwinQuartz
-Soft link to Quartz mode X server executable
-.SH SEE ALSO 
-XDarwin(1)
-.SH BUGS
-The path to XDarwinQuartz should not be hard coded. 
-
diff --git a/hw/darwin/quartz/XServer.h b/hw/darwin/quartz/XServer.h
deleted file mode 100644
index 030ccb5..0000000
--- a/hw/darwin/quartz/XServer.h
+++ /dev/null
@@ -1,136 +0,0 @@
-//
-//  XServer.h
-//
-/*
- * Copyright (c) 2001 Andreas Monitzer. All Rights Reserved.
- * Copyright (c) 2002-2003 Torrey T. Lyons. 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 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 BOOL xBOOL
-#include <X11/Xproto.h>
-#undef BOOL
-
-#import <Cocoa/Cocoa.h>
-
- at interface XServer : NSObject {
-    // Server state
-    int serverState;
-    NSRecursiveLock *serverLock;
-    NSMutableArray *pendingClients;
-    BOOL serverVisible;
-    BOOL rootlessMenuBarVisible;
-    BOOL queueShowServer;
-    BOOL quitWithoutQuery;
-    BOOL pendingAppQuitReply;
-    UInt32 mouseState;
-    unsigned short swallowedKey;
-    BOOL sendServerEvents;
-    BOOL x11Active;
-
-    // Aqua interface
-    IBOutlet NSWindow *modeWindow;
-    IBOutlet NSButton *startupModeButton;
-    IBOutlet NSButton *startFullScreenButton;
-    IBOutlet NSButton *startRootlessButton;
-    IBOutlet NSWindow *helpWindow;
-    IBOutlet NSButton *startupHelpButton;
-    IBOutlet NSPanel *switchWindow;
-
-    // Menu elements setable by Apple-WM extension
-    IBOutlet NSMenu *windowMenu;
-    IBOutlet NSMenuItem *windowSeparator;
-    IBOutlet NSMenu *dockMenu;
-    int checkedWindowItem;
-}
-
-- (id)init;
-
-- (BOOL)translateEvent:(NSEvent *)anEvent;
-- (BOOL)getMousePosition:(xEvent *)xe fromEvent:(NSEvent *)anEvent;
-
-- (NSString *)makeSafePath:(NSString *)path;
-
-- (BOOL)loadDisplayBundle;
-- (void)startX;
-- (void)finishStartX;
-- (BOOL)startXClients;
-- (void)runClient:(NSString *)filename;
-- (void)run;
-- (void)toggle;
-- (void)showServer:(BOOL)show;
-- (void)forceShowServer:(BOOL)show;
-- (void)setRootClip:(BOOL)enable;
-- (void)readPasteboard;
-- (void)writePasteboard;
-- (void)quitServer;
-- (void)sendXEvent:(xEvent *)xe;
-- (void)sendShowHide:(BOOL)show;
-- (void)clientProcessDone:(int)clientStatus;
-- (void)activateX11:(BOOL)state;
-- (void)windowBecameKey:(NSNotification *)notification;
-- (void)setX11WindowList:(NSArray *)list;
-- (void)setX11WindowCheck:(NSNumber *)nn;
-
-// Aqua interface actions
-- (IBAction)startFullScreen:(id)sender;
-- (IBAction)startRootless:(id)sender;
-- (IBAction)closeHelpAndShow:(id)sender;
-- (IBAction)showSwitchPanel:(id)sender;
-- (IBAction)showAction:(id)sender;
-- (IBAction)itemSelected:(id)sender;
-- (IBAction)nextWindow:(id)sender;
-- (IBAction)previousWindow:(id)sender;
-- (IBAction)performClose:(id)sender;
-- (IBAction)performMiniaturize:(id)sender;
-- (IBAction)performZoom:(id)sender;
-- (IBAction)bringAllToFront:(id)sender;
-- (IBAction)copy:(id)sender;
-
-// NSApplication delegate
-- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender;
-- (void)applicationWillTerminate:(NSNotification *)aNotification;
-- (void)applicationDidFinishLaunching:(NSNotification *)aNotification;
-- (void)applicationDidHide:(NSNotification *)aNotification;
-- (void)applicationDidUnhide:(NSNotification *)aNotification;
-- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag;
-- (void)applicationWillResignActive:(NSNotification *)aNotification;
-- (void)applicationWillBecomeActive:(NSNotification *)aNotification;
-- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename;
-
-// NSPort delegate
-- (void)handlePortMessage:(NSPortMessage *)portMessage;
-
- at end
-
-// X server states
-enum {
-    server_NotStarted,
-    server_Starting,
-    server_Running,
-    server_Quitting,
-    server_Done
-};
diff --git a/hw/darwin/quartz/XServer.m b/hw/darwin/quartz/XServer.m
deleted file mode 100644
index 0587415..0000000
--- a/hw/darwin/quartz/XServer.m
+++ /dev/null
@@ -1,1539 +0,0 @@
-//
-//  XServer.m
-//
-//  This class handles the interaction between the Cocoa front-end
-//  and the Darwin X server thread.
-//
-//  Created by Andreas Monitzer on January 6, 2001.
-//
-/*
- * Copyright (c) 2001 Andreas Monitzer. All Rights Reserved.
- * Copyright (c) 2002-2005 Torrey T. Lyons. 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 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.
- */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-#include "quartzCommon.h"
-
-#define BOOL xBOOL
-#include "X11/X.h"
-#include "X11/Xproto.h"
-#include "os.h"
-#include "opaque.h"
-#include "darwin.h"
-#include "quartz.h"
-#define _APPLEWM_SERVER_
-#include "X11/extensions/applewm.h"
-#include "applewmExt.h"
-#undef BOOL
-
-#import "XServer.h"
-#import "Preferences.h"
-
-#include <unistd.h>
-#include <stdio.h>
-#include <sys/syslimits.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <pwd.h>
-#include <signal.h>
-#include <fcntl.h>
-
-// For power management notifications
-#import <mach/mach_port.h>
-#import <mach/mach_interface.h>
-#import <mach/mach_init.h>
-#import <IOKit/pwr_mgt/IOPMLib.h>
-#import <IOKit/IOMessage.h>
-
-// Types of shells
-enum {
-    shell_Unknown,
-    shell_Bourne,
-    shell_C
-};
-
-typedef struct {
-    char *name;
-    int type;
-} shellList_t;
-
-static shellList_t const shellList[] = {
-    { "csh",    shell_C },          // standard C shell
-    { "tcsh",   shell_C },          // ... needs no introduction
-    { "sh",     shell_Bourne },     // standard Bourne shell
-    { "zsh",    shell_Bourne },     // Z shell
-    { "bash",   shell_Bourne },     // GNU Bourne again shell
-    { NULL,     shell_Unknown }
-};
-
-extern int argcGlobal;
-extern char **argvGlobal;
-extern char **envpGlobal;
-extern int main(int argc, char *argv[], char *envp[]);
-extern void HideMenuBar(void);
-extern void ShowMenuBar(void);
-static void childDone(int sig);
-static void powerDidChange(void *x, io_service_t y, natural_t messageType,
-                           void *messageArgument);
-
-static NSPort *signalPort;
-static NSPort *returnPort;
-static NSPortMessage *signalMessage;
-static pid_t clientPID;
-static XServer *oneXServer;
-static NSRect aquaMenuBarBox;
-static io_connect_t root_port;
-
-
- at implementation XServer
-
-- (id)init
-{
-    self = [super init];
-    oneXServer = self;
-
-    serverState = server_NotStarted;
-    serverLock = [[NSRecursiveLock alloc] init];
-    pendingClients = nil;
-    clientPID = 0;
-    sendServerEvents = NO;
-    x11Active = YES;
-    serverVisible = NO;
-    rootlessMenuBarVisible = YES;
-    queueShowServer = YES;
-    quartzServerQuitting = NO;
-    pendingAppQuitReply = NO;
-    mouseState = 0;
-
-    // set up a port to safely send messages to main thread from server thread
-    signalPort = [[NSPort port] retain];
-    returnPort = [[NSPort port] retain];
-    signalMessage = [[NSPortMessage alloc] initWithSendPort:signalPort
-                    receivePort:returnPort components:nil];
-
-    // set up receiving end
-    [signalPort setDelegate:self];
-    [[NSRunLoop currentRunLoop] addPort:signalPort
-                                forMode:NSDefaultRunLoopMode];
-    [[NSRunLoop currentRunLoop] addPort:signalPort
-                                forMode:NSModalPanelRunLoopMode];
-
-    return self;
-}
-
-- (NSApplicationTerminateReply)
-        applicationShouldTerminate:(NSApplication *)sender
-{
-    // Quit if the X server is not running
-    if ([serverLock tryLock]) {
-        quartzServerQuitting = YES;
-        serverState = server_Done;
-        if (clientPID != 0)
-            kill(clientPID, SIGINT);
-        return NSTerminateNow;
-    }
-
-    // Hide the X server and stop sending it events
-    [self showServer:NO];
-    sendServerEvents = NO;
-
-    if (!quitWithoutQuery && (clientPID != 0 || !quartzStartClients)) {
-        int but;
-
-        but = NSRunAlertPanel(NSLocalizedString(@"Quit X server?",@""),
-                              NSLocalizedString(@"Quitting the X server will terminate any running X Window System programs.",@""),
-                              NSLocalizedString(@"Quit",@""),
-                              NSLocalizedString(@"Cancel",@""),
-                              nil);
-
-        switch (but) {
-            case NSAlertDefaultReturn:		// quit
-                break;
-            case NSAlertAlternateReturn:	// cancel
-                if (serverState == server_Running)
-                    sendServerEvents = YES;
-                return NSTerminateCancel;
-        }
-    }
-
-    quartzServerQuitting = YES;
-    if (clientPID != 0)
-        kill(clientPID, SIGINT);
-
-    // At this point the X server is either running or starting.
-    if (serverState == server_Starting) {
-        // Quit will be queued later when server is running
-        pendingAppQuitReply = YES;
-        return NSTerminateLater;
-    } else if (serverState == server_Running) {
-        [self quitServer];
-    }
-
-    return NSTerminateNow;
-}
-
-// Ensure that everything has quit cleanly
-- (void)applicationWillTerminate:(NSNotification *)aNotification
-{
-    // Make sure the client process has finished
-    if (clientPID != 0) {
-        NSLog(@"Waiting on client process...");
-        sleep(2);
-
-        // If the client process hasn't finished yet, kill it off
-        if (clientPID != 0) {
-            int clientStatus;
-            NSLog(@"Killing client process...");
-            killpg(clientPID, SIGKILL);
-            waitpid(clientPID, &clientStatus, 0);
-        }
-    }
-
-    // Wait until the X server thread quits
-    [serverLock lock];
-}
-
-// returns YES when event was handled
-- (BOOL)translateEvent:(NSEvent *)anEvent
-{
-    xEvent xe;
-    static BOOL mouse1Pressed = NO;
-    NSEventType type;
-    unsigned int flags;
-
-    if (!sendServerEvents) {
-        return NO;
-    }
-
-    type  = [anEvent type];
-    flags = [anEvent modifierFlags];
-
-    if (!quartzRootless) {
-        // Check for switch keypress
-        if ((type == NSKeyDown) && (![anEvent isARepeat]) &&
-            ([anEvent keyCode] == [Preferences keyCode]))
-        {
-            unsigned int switchFlags = [Preferences modifiers];
-
-            // Switch if all the switch modifiers are pressed, while none are
-            // pressed that should not be, except for caps lock.
-            if (((flags & switchFlags) == switchFlags) &&
-                ((flags & ~(switchFlags | NSAlphaShiftKeyMask)) == 0))
-            {
-                [self toggle];
-                return YES;
-            }
-        }
-
-        if (!serverVisible)
-            return NO;
-    }
-
-    memset(&xe, 0, sizeof(xe));
-
-    switch (type) {
-        case NSLeftMouseUp:
-            if (quartzRootless && !mouse1Pressed) {
-                // MouseUp after MouseDown in menu - ignore
-                return NO;
-            }
-            mouse1Pressed = NO;
-            [self getMousePosition:&xe fromEvent:anEvent];
-            xe.u.u.type = ButtonRelease;
-            xe.u.u.detail = 1;
-            break;
-
-        case NSLeftMouseDown:
-            if (quartzRootless) {
-                // Check that event is in X11 window
-                if (!quartzProcs->IsX11Window([anEvent window],
-                                              [anEvent windowNumber]))
-                {
-                    if (x11Active)
-                        [self activateX11:NO];
-                    return NO;
-                } else {
-                    if (!x11Active)
-                        [self activateX11:YES];
-                }
-            }
-            mouse1Pressed = YES;
-            [self getMousePosition:&xe fromEvent:anEvent];
-            xe.u.u.type = ButtonPress;
-            xe.u.u.detail = 1;
-            break;
-
-        case NSRightMouseUp:
-            [self getMousePosition:&xe fromEvent:anEvent];
-            xe.u.u.type = ButtonRelease;
-            xe.u.u.detail = 3;
-            break;
-
-        case NSRightMouseDown:
-            [self getMousePosition:&xe fromEvent:anEvent];
-            xe.u.u.type = ButtonPress;
-            xe.u.u.detail = 3;
-            break;
-
-        case NSOtherMouseUp:
-        {
-            int hwButton = [anEvent buttonNumber];
-
-            [self getMousePosition:&xe fromEvent:anEvent];
-            xe.u.u.type = ButtonRelease;
-            xe.u.u.detail = (hwButton == 2) ? hwButton : hwButton + 1;
-            break;
-        }
-
-        case NSOtherMouseDown:
-        {
-            int hwButton = [anEvent buttonNumber];
-
-            [self getMousePosition:&xe fromEvent:anEvent];
-            xe.u.u.type = ButtonPress;
-            xe.u.u.detail = (hwButton == 2) ? hwButton : hwButton + 1;
-            break;
-        }
-
-        case NSMouseMoved:
-        case NSLeftMouseDragged:
-        case NSRightMouseDragged:
-        case NSOtherMouseDragged:
-            [self getMousePosition:&xe fromEvent:anEvent];
-            xe.u.u.type = MotionNotify;
-            break;
-
-        case NSScrollWheel:
-            [self getMousePosition:&xe fromEvent:anEvent];
-            xe.u.u.type = kXDarwinScrollWheel;
-            xe.u.clientMessage.u.s.shorts0 = [anEvent deltaX] +
-                                             [anEvent deltaY];
-            break;
-
-        case NSKeyDown:
-        case NSKeyUp:
-            if (!x11Active) {
-                swallowedKey = 0;
-                return NO;
-            }
-
-            if (type == NSKeyDown) {
-                // If the mouse is not on the valid X display area,
-                // don't send the X server key events.
-                if (![self getMousePosition:&xe fromEvent:nil]) {
-                    swallowedKey = [anEvent keyCode];
-                    return NO;
-                }
-
-                // See if there are any global shortcuts for this key combo.
-                if (quartzEnableKeyEquivalents
-                    && [[NSApp mainMenu] performKeyEquivalent:anEvent])
-                {
-                    swallowedKey = [anEvent keyCode];
-                    return YES;
-                }
-            } else {
-                // If the down key event was a valid key combo,
-                // don't pass the up event to X11.
-                if (swallowedKey != 0 && [anEvent keyCode] == swallowedKey) {
-                    swallowedKey = 0;
-                    return NO;
-                }
-            }
-
-            xe.u.u.type = (type == NSKeyDown) ? KeyPress : KeyRelease;
-            xe.u.u.detail = [anEvent keyCode];
-            break;
-
-        case NSFlagsChanged:
-            if (!x11Active)
-                return NO;
-            xe.u.u.type = kXDarwinUpdateModifiers;
-            xe.u.clientMessage.u.l.longs0 = flags;
-            break;
-
-        default:
-            return NO;
-    }
-
-    [self sendXEvent:&xe];
-
-    // Rootless: Send first NSLeftMouseDown to Cocoa windows and views so
-    // window ordering can be suppressed.
-    // Don't pass further events - they (incorrectly?) bring the window
-    // forward no matter what.
-    if (quartzRootless  &&
-        (type == NSLeftMouseDown || type == NSLeftMouseUp) &&
-        [anEvent clickCount] == 1 && [anEvent window])
-    {
-        return NO;
-    }
-
-    return YES;
-}
-
-// Return mouse coordinates, inverting y coordinate.
-// The coordinates are extracted from an event or the current mouse position.
-// For rootless mode, the menu bar is treated as not part of the usable
-// X display area and the cursor position is adjusted accordingly.
-// Returns YES if the cursor is not in the menu bar.
-- (BOOL)getMousePosition:(xEvent *)xe fromEvent:(NSEvent *)anEvent
-{
-    NSPoint pt;
-
-    if (anEvent) {
-        NSWindow *eventWindow = [anEvent window];
-
-        if (eventWindow) {
-            pt = [anEvent locationInWindow];
-            pt.x += [eventWindow frame].origin.x;
-            pt.y += [eventWindow frame].origin.y;
-        } else {
-            pt = [NSEvent mouseLocation];
-        }
-    } else {
-        pt = [NSEvent mouseLocation];
-    }
-
-    xe->u.keyButtonPointer.rootX = (int)(pt.x);
-
-    if (quartzRootless && NSMouseInRect(pt, aquaMenuBarBox, NO)) {
-        // mouse in menu bar - tell X11 that it's just below instead
-        xe->u.keyButtonPointer.rootY = aquaMenuBarHeight;
-        return NO;
-    } else {
-        xe->u.keyButtonPointer.rootY =
-            NSHeight([[NSScreen mainScreen] frame]) - (int)(pt.y);
-        return YES;
-    }
-}
-
-
-// Make a safe path
-//
-// Return the path in single quotes in case there are problematic characters in it.
-// We still have to worry about there being single quotes in the path. So, replace
-// all instances of the ' character in the path with '\''.
-- (NSString *)makeSafePath:(NSString *)path
-{
-    NSMutableString *safePath = [NSMutableString stringWithString:path];
-    NSRange aRange = NSMakeRange(0, [safePath length]);
-
-    while (aRange.length) {
-        aRange = [safePath rangeOfString:@"'" options:0 range:aRange];
-        if (!aRange.length)
-            break;
-        [safePath replaceCharactersInRange:aRange
-                        withString:@"\'\\'\'"];
-        aRange.location += 4;
-        aRange.length = [safePath length] - aRange.location;
-    }
-
-    safePath = [NSMutableString stringWithFormat:@"'%@'", safePath];
-
-    return safePath;
-}
-
-
-- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
-{
-    // Block SIGPIPE
-    // SIGPIPE repeatably killed the (rootless) server when closing a
-    // dozen xterms in rapid succession. Those SIGPIPEs should have been
-    // sent to the X server thread, which ignores them, but somehow they
-    // ended up in this thread instead.
-    {
-        sigset_t set;
-        sigemptyset(&set);
-        sigaddset(&set, SIGPIPE);
-        // pthread_sigmask not implemented yet
-        // pthread_sigmask(SIG_BLOCK, &set, NULL);
-        sigprocmask(SIG_BLOCK, &set, NULL);
-    }
-
-    if (quartzRootless == -1) {
-        // The display mode was not set from the command line.
-        // Show mode pick panel?
-        if ([Preferences modeWindow]) {
-            if ([Preferences rootless])
-                [startRootlessButton setKeyEquivalent:@"\r"];
-            else
-                [startFullScreenButton setKeyEquivalent:@"\r"];
-            [modeWindow makeKeyAndOrderFront:nil];
-        } else {
-            // Otherwise use default mode
-            quartzRootless = [Preferences rootless];
-            [self startX];
-        }
-    } else {
-        [self startX];
-    }
-}
-
-
-// Load the appropriate display mode bundle
-- (BOOL)loadDisplayBundle
-{
-    if (quartzRootless) {
-        NSEnumerator *enumerator = [[Preferences displayModeBundles]
-                                            objectEnumerator];
-        NSString *bundleName;
-
-        while ((bundleName = [enumerator nextObject])) {
-            if (QuartzLoadDisplayBundle([bundleName cString]))
-                return YES;
-        }
-
-        return NO;
-    } else {
-        return QuartzLoadDisplayBundle("fullscreen.bundle");
-    }
-}
-
-
-// Start the X server thread and the client process
-- (void)startX
-{
-    NSDictionary *appDictionary;
-    NSString *appVersion;
-
-    [modeWindow close];
-
-    // Calculate the height of the menu bar so rootless mode can avoid it
-    if (quartzRootless) {
-        aquaMenuBarHeight = NSHeight([[NSScreen mainScreen] frame]) -
-                            NSMaxY([[NSScreen mainScreen] visibleFrame]) - 1;
-        aquaMenuBarBox =
-            NSMakeRect(0, NSMaxY([[NSScreen mainScreen] visibleFrame]) + 1,
-                       NSWidth([[NSScreen mainScreen] frame]),
-                       aquaMenuBarHeight);
-    }
-
-    // Write the XDarwin version to the console log
-    appDictionary = [[NSBundle mainBundle] infoDictionary];
-    appVersion = [appDictionary objectForKey:@"CFBundleShortVersionString"];
-    if (appVersion)
-        NSLog(@"\n%@", appVersion);
-    else
-        NSLog(@"No version");
-
-    if (![self loadDisplayBundle])
-        [NSApp terminate:nil];
-
-    if (quartzRootless) {
-        // We need to track whether the key window is an X11 window
-        [[NSNotificationCenter defaultCenter]
-                addObserver:self
-                selector:@selector(windowBecameKey:)
-                name:NSWindowDidBecomeKeyNotification
-                object:nil];
-
-        // Request notification of screen layout changes even when this
-        // is not the active application
-        [[NSDistributedNotificationCenter defaultCenter]
-                addObserver:self
-                selector:@selector(applicationDidChangeScreenParameters:)
-                name:NSApplicationDidChangeScreenParametersNotification
-                object:nil];
-    }
-
-    // Start the X server thread
-    serverState = server_Starting;
-    [NSThread detachNewThreadSelector:@selector(run) toTarget:self
-              withObject:nil];
-
-    // Start the X clients if started from GUI
-    if (quartzStartClients) {
-        [self startXClients];
-    }
-
-    if (quartzRootless) {
-        // There is no help window for rootless; just start
-        [helpWindow close];
-        helpWindow = nil;
-    } else {
-        IONotificationPortRef notify;
-        io_object_t anIterator;
-
-        // Register for system power notifications
-        root_port = IORegisterForSystemPower(0, &notify, powerDidChange,
-                                             &anIterator);
-        if (root_port) {
-            CFRunLoopAddSource([[NSRunLoop currentRunLoop] getCFRunLoop],
-                               IONotificationPortGetRunLoopSource(notify),
-                               kCFRunLoopDefaultMode);
-        } else {
-            NSLog(@"Failed to register for system power notifications.");
-        }
-        
-        // Show the X switch window if not using dock icon switching
-        if (![Preferences dockSwitch])
-            [switchWindow orderFront:nil];
-
-        if ([Preferences startupHelp]) {
-            // display the full screen mode help
-            [helpWindow makeKeyAndOrderFront:nil];
-            queueShowServer = NO;
-        } else {
-            // start running full screen and make sure X is visible
-            ShowMenuBar();
-            [self closeHelpAndShow:nil];
-        }
-    }
-}
-
-// Finish starting the X server thread
-// This includes anything that must be done after the X server is
-// ready to process events after the first or subsequent generations.
-- (void)finishStartX
-{
-    sendServerEvents = YES;
-    serverState = server_Running;
-
-    if (quartzRootless) {
-        [self forceShowServer:[NSApp isActive]];
-    } else {
-        [self forceShowServer:queueShowServer];
-    }
-
-    if (quartzServerQuitting) {
-        [self quitServer];
-        if (pendingAppQuitReply)
-            [NSApp replyToApplicationShouldTerminate:YES];
-        return;
-    }
-
-    if (pendingClients) {
-        NSEnumerator *enumerator = [pendingClients objectEnumerator];
-        NSString *filename;
-
-        while ((filename = [enumerator nextObject])) {
-            [self runClient:filename];
-        }
-
-        [pendingClients release];
-        pendingClients = nil;
-    }
-}
-
-// Start the first X clients in a separate process
-- (BOOL)startXClients
-{
-    struct passwd *passwdUser;
-    NSString *shellPath, *dashShellName, *commandStr, *startXPath;
-    NSString *safeStartXPath;
-    NSBundle *thisBundle;
-    const char *shellPathStr, *newargv[3], *shellNameStr;
-    int fd[2], outFD, length, shellType, i;
-
-    // Register to catch the signal when the client processs finishes
-    signal(SIGCHLD, childDone);
-
-    // Get user's password database entry
-    passwdUser = getpwuid(getuid());
-
-    // Find the shell to use
-    if ([Preferences useDefaultShell])
-        shellPath = [NSString stringWithCString:passwdUser->pw_shell];
-    else
-        shellPath = [Preferences shellString];
-
-    dashShellName = [NSString stringWithFormat:@"-%@",
-                            [shellPath lastPathComponent]];
-    shellPathStr = [shellPath cString];
-    shellNameStr = [[shellPath lastPathComponent] cString];
-
-    if (access(shellPathStr, X_OK)) {
-        NSLog(@"Shell %s is not valid!", shellPathStr);
-        return NO;
-    }
-
-    // Find the type of shell
-    for (i = 0; shellList[i].name; i++) {
-        if (!strcmp(shellNameStr, shellList[i].name))
-            break;
-    }
-    shellType = shellList[i].type;
-
-    newargv[0] = [dashShellName cString];
-    if (shellType == shell_Bourne) {
-        // Bourne shells need to be told they are interactive to make
-        // sure they read all their initialization files.
-        newargv[1] = "-i";
-        newargv[2] = NULL;
-    } else {
-        newargv[1] = NULL;
-    }
-
-    // Create a pipe to communicate with the X client process
-    NSAssert(pipe(fd) == 0, @"Could not create new pipe.");
-
-    // Open a file descriptor for writing to stdout and stderr
-    outFD = open("/dev/console", O_WRONLY, 0);
-    if (outFD == -1) {
-        outFD = open("/dev/null", O_WRONLY, 0);
-        NSAssert(outFD != -1, @"Could not open shell output.");
-    }
-
-    // Fork process to start X clients in user's default shell
-    // Sadly we can't use NSTask because we need to start a login shell.
-    // Login shells are started by passing "-" as the first character of
-    // argument 0. NSTask forces argument 0 to be the shell's name.
-    clientPID = vfork();
-    if (clientPID == 0) {
-
-        // Inside the new process:
-        if (fd[0] != STDIN_FILENO) {
-            dup2(fd[0], STDIN_FILENO);      // Take stdin from pipe
-            close(fd[0]);
-        }
-        close(fd[1]);                       // Close write end of pipe
-        if (outFD == STDOUT_FILENO) {       // Setup stdout and stderr
-            dup2(outFD, STDERR_FILENO);
-        } else if (outFD == STDERR_FILENO) {
-            dup2(outFD, STDOUT_FILENO);
-        } else {
-            dup2(outFD, STDERR_FILENO);
-            dup2(outFD, STDOUT_FILENO);
-            close(outFD);
-        }
-
-        // Setup environment
-        setenv("HOME", passwdUser->pw_dir, 1);
-        setenv("SHELL", shellPathStr, 1);
-        setenv("LOGNAME", passwdUser->pw_name, 1);
-        setenv("USER", passwdUser->pw_name, 1);
-        setenv("TERM", "unknown", 1);
-        if (chdir(passwdUser->pw_dir))	// Change to user's home dir
-            NSLog(@"Could not change to user's home directory.");
-
-        execv(shellPathStr, (char * const *)newargv);	// Start user's shell
-
-        NSLog(@"Could not start X client process with errno = %i.", errno);
-        _exit(127);
-    }
-
-    // In parent process:
-    close(fd[0]);	// Close read end of pipe
-    close(outFD);	// Close output file descriptor
-
-    thisBundle = [NSBundle bundleForClass:[self class]];
-    startXPath = [thisBundle pathForResource:@"startXClients" ofType:nil];
-    if (!startXPath) {
-        NSLog(@"Could not find startXClients in application bundle!");
-        return NO;
-    }
-
-    safeStartXPath = [self makeSafePath:startXPath];
-
-    if ([Preferences addToPath]) {
-        commandStr = [NSString stringWithFormat:@"%@ :%d %@\n",
-                        safeStartXPath, [Preferences display],
-                        [Preferences addToPathString]];
-    } else {
-        commandStr = [NSString stringWithFormat:@"%@ :%d\n",
-                        safeStartXPath, [Preferences display]];
-    }
-
-    length = [commandStr cStringLength];
-    if (write(fd[1], [commandStr cString], length) != length) {
-        NSLog(@"Write to X client process failed.");
-        return NO;
-    }
-
-    // Close the pipe so that shell will terminate when xinit quits
-    close(fd[1]);
-
-    return YES;
-}
-
-// Start the specified client in its own task
-// FIXME: This should be unified with startXClients
-- (void)runClient:(NSString *)filename
-{
-    const char *command = [[self makeSafePath:filename] UTF8String];
-    const char *shell;
-    const char *argv[5];
-    int child1, child2 = 0;
-    int status;
-
-    shell = getenv("SHELL");
-    if (shell == NULL)
-        shell = "/bin/bash";
-
-    /* At least [ba]sh, [t]csh and zsh all work with this syntax. We
-       need to use an interactive shell to force it to load the user's
-       environment. */
-
-    argv[0] = shell;
-    argv[1] = "-i";
-    argv[2] = "-c";
-    argv[3] = command;
-    argv[4] = NULL;
-
-    /* Do the fork-twice trick to avoid having to reap zombies */
-
-    child1 = fork();
-
-    switch (child1) {
-        case -1:                                /* error */
-            break;
-
-        case 0:                                 /* child1 */
-            child2 = fork();
-
-            switch (child2) {
-                int max_files, i;
-                char buf[1024], *tem;
-
-            case -1:                            /* error */
-                _exit(1);
-
-            case 0:                             /* child2 */
-                /* close all open files except for standard streams */
-                max_files = sysconf(_SC_OPEN_MAX);
-                for (i = 3; i < max_files; i++)
-                    close(i);
-
-                /* ensure stdin is on /dev/null */
-                close(0);
-                open("/dev/null", O_RDONLY);
-
-                /* cd $HOME */
-                tem = getenv("HOME");
-                if (tem != NULL)
-                    chdir(tem);
-
-                /* Setup environment */
-//              snprintf(buf, sizeof(buf), ":%s", display);
-//              setenv("DISPLAY", buf, TRUE);
-                tem = getenv("PATH");
-                if (tem != NULL && tem[0] != NULL)
-                    snprintf(buf, sizeof(buf), "%s:/usr/X11/bin", tem);
-                else
-                    snprintf(buf, sizeof(buf), "/bin:/usr/bin:/usr/X11/bin");
-                setenv("PATH", buf, TRUE);
-
-                execvp(argv[0], (char **const) argv);
-
-                _exit(2);
-
-            default:                            /* parent (child1) */
-                _exit(0);
-            }
-            break;
-
-        default:                                /* parent */
-            waitpid(child1, &status, 0);
-    }
-}
-
-// Run the X server thread
-- (void)run
-{
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
-    [serverLock lock];
-    main(argcGlobal, argvGlobal, envpGlobal);
-    serverVisible = NO;
-    [pool release];
-    [serverLock unlock];
-    QuartzMessageMainThread(kQuartzServerDied, nil, 0);
-}
-
-// Full screen mode was picked in the mode pick panel
-- (IBAction)startFullScreen:(id)sender
-{
-    [Preferences setModeWindow:[startupModeButton intValue]];
-    [Preferences saveToDisk];
-    quartzRootless = FALSE;
-    [self startX];
-}
-
-// Rootless mode was picked in the mode pick panel
-- (IBAction)startRootless:(id)sender
-{
-    [Preferences setModeWindow:[startupModeButton intValue]];
-    [Preferences saveToDisk];
-    quartzRootless = TRUE;
-    [self startX];
-}
-
-// Close the help splash screen and show the X server
-- (IBAction)closeHelpAndShow:(id)sender
-{
-    if (sender) {
-        int helpVal = [startupHelpButton intValue];
-        [Preferences setStartupHelp:helpVal];
-        [Preferences saveToDisk];
-    }
-    [helpWindow close];
-    helpWindow = nil;
-
-    [self forceShowServer:YES];
-    [NSApp activateIgnoringOtherApps:YES];
-}
-
-// Show the Aqua-X11 switch panel useful for fullscreen mode
-- (IBAction)showSwitchPanel:(id)sender
-{
-    [switchWindow orderFront:nil];
-}
-
-// Show the X server when sent message from GUI
-- (IBAction)showAction:(id)sender
-{
-    [self forceShowServer:YES];
-}
-
-// Show or hide the X server or menu bar in rootless mode
-- (void)toggle
-{
-    if (quartzRootless) {
-#if 0
-        // FIXME: Remove or add option to not dodge menubar
-        if (rootlessMenuBarVisible)
-            HideMenuBar();
-        else
-            ShowMenuBar();
-        rootlessMenuBarVisible = !rootlessMenuBarVisible;
-#endif
-    } else {
-        [self showServer:!serverVisible];
-    }
-}
-
-// Show or hide the X server on screen
-- (void)showServer:(BOOL)show
-{
-    // Do not show or hide multiple times in a row
-    if (serverVisible == show)
-        return;
-
-    if (sendServerEvents) {
-        [self sendShowHide:show];
-    } else if (serverState == server_Starting) {
-        queueShowServer = show;
-    }
-}
-
-// Show or hide the X server irregardless of the current state
-- (void)forceShowServer:(BOOL)show
-{
-    serverVisible = !show;
-    [self showServer:show];
-}
-
-// Tell the X server to show or hide itself.
-// This ignores the current X server visible state.
-//
-// In full screen mode, the order we do things is important and must be
-// preserved between the threads. X drawing operations have to be performed
-// in the X server thread. It appears that we have the additional
-// constraint that we must hide and show the menu bar in the main thread.
-//
-// To show the X server:
-//   1. Capture the displays. (Main thread)
-//   2. Hide the menu bar. (Must be in main thread)
-//   3. Send event to X server thread to redraw X screen.
-//   4. Redraw the X screen. (Must be in X server thread)
-//
-// To hide the X server:
-//   1. Send event to X server thread to stop drawing.
-//   2. Stop drawing to the X screen. (Must be in X server thread)
-//   3. Message main thread that drawing is stopped.
-//   4. If main thread still wants X server hidden:
-//     a. Release the displays. (Main thread)
-//     b. Unhide the menu bar. (Must be in main thread)
-//   Otherwise we have already queued an event to start drawing again.
-//
-- (void)sendShowHide:(BOOL)show
-{
-    xEvent xe;
-
-    [self getMousePosition:&xe fromEvent:nil];
-
-    if (show) {
-        if (!quartzRootless) {
-            quartzProcs->CaptureScreens();
-            HideMenuBar();
-        }
-        [self activateX11:YES];
-
-        // the mouse location will have moved; track it
-        xe.u.u.type = MotionNotify;
-        [self sendXEvent:&xe];
-
-        // inform the X server of the current modifier state
-        xe.u.u.type = kXDarwinUpdateModifiers;
-        xe.u.clientMessage.u.l.longs0 = [[NSApp currentEvent] modifierFlags];
-        [self sendXEvent:&xe];
-
-        // If there is no AppleWM-aware cut and paste manager, do what we can.
-        if ((AppleWMSelectedEvents() & AppleWMPasteboardNotifyMask) == 0) {
-            // put the pasteboard into the X cut buffer
-            [self readPasteboard];
-        }
-    } else {
-        // If there is no AppleWM-aware cut and paste manager, do what we can.
-        if ((AppleWMSelectedEvents() & AppleWMPasteboardNotifyMask) == 0) {
-            // put the X cut buffer on the pasteboard
-            [self writePasteboard];
-        }
-
-        [self activateX11:NO];
-    }
-
-    serverVisible = show;
-}
-
-// Enable or disable rendering to the X screen
-- (void)setRootClip:(BOOL)enable
-{
-    xEvent xe;
-
-    xe.u.u.type = kXDarwinSetRootClip;
-    xe.u.clientMessage.u.l.longs0 = enable;
-    [self sendXEvent:&xe];
-}
-
-// Tell the X server to read from the pasteboard into the X cut buffer
-- (void)readPasteboard
-{
-    xEvent xe;
-
-    xe.u.u.type = kXDarwinReadPasteboard;
-    [self sendXEvent:&xe];
-}
-
-// Tell the X server to write the X cut buffer into the pasteboard
-- (void)writePasteboard
-{
-    xEvent xe;
-
-    xe.u.u.type = kXDarwinWritePasteboard;
-    [self sendXEvent:&xe];
-}
-
-- (void)quitServer
-{
-    xEvent xe;
-
-    xe.u.u.type = kXDarwinQuit;
-    [self sendXEvent:&xe];
-
-    // Revert to the Mac OS X arrow cursor. The main thread sets the cursor
-    // and it won't be responding to future requests to change it.
-    [[NSCursor arrowCursor] set];
-
-    serverState = server_Quitting;
-}
-
-- (void)sendXEvent:(xEvent *)xe
-{
-    // This field should be filled in for every event
-    xe->u.keyButtonPointer.time = GetTimeInMillis();
-
-    DarwinEQEnqueue(xe);
-}
-
-// Handle messages from the X server thread
-- (void)handlePortMessage:(NSPortMessage *)portMessage
-{
-    unsigned msg = [portMessage msgid];
-
-    switch (msg) {
-        case kQuartzServerHidden:
-            // Make sure the X server wasn't queued to be shown again while
-            // the hide was pending.
-            if (!quartzRootless && !serverVisible) {
-                quartzProcs->ReleaseScreens();
-                ShowMenuBar();
-            }
-            break;
-
-        case kQuartzServerStarted:
-            [self finishStartX];
-            break;
-
-        case kQuartzServerDied:
-            sendServerEvents = NO;
-            serverState = server_Done;
-            if (!quartzServerQuitting) {
-                [NSApp terminate:nil];	// quit if we aren't already
-            }
-            break;
-
-        case kQuartzCursorUpdate:
-            if (quartzProcs->CursorUpdate)
-                quartzProcs->CursorUpdate();
-            break;
-
-        case kQuartzPostEvent:
-        {
-            const xEvent *xe = [[[portMessage components] lastObject] bytes];
-            DarwinEQEnqueue(xe);
-            break;
-        }
-
-        case kQuartzSetWindowMenu:
-        {
-            NSArray *list;
-            [[[portMessage components] lastObject] getBytes:&list];
-            [self setX11WindowList:list];
-            [list release];
-            break;
-        }
-
-        case kQuartzSetWindowMenuCheck:
-        {
-            int n;
-            [[[portMessage components] lastObject] getBytes:&n];
-            [self setX11WindowCheck:[NSNumber numberWithInt:n]];
-            break;
-        }
-
-        case kQuartzSetFrontProcess:
-            [NSApp activateIgnoringOtherApps:YES];
-            break;
-
-        case kQuartzSetCanQuit:
-        {
-            int n;
-            [[[portMessage components] lastObject] getBytes:&n];
-            quitWithoutQuery = (BOOL) n;
-            break;
-        }
-
-        default:
-            NSLog(@"Unknown message from server thread.");
-    }
-}
-
-// Quit the X server when the X client process finishes
-- (void)clientProcessDone:(int)clientStatus
-{
-    if (WIFEXITED(clientStatus)) {
-        int exitStatus = WEXITSTATUS(clientStatus);
-        if (exitStatus != 0)
-            NSLog(@"X client process terminated with status %i.", exitStatus);
-    } else {
-        NSLog(@"X client process terminated abnormally.");
-    }
-
-    if (!quartzServerQuitting) {
-        [NSApp terminate:nil];	// quit if we aren't already
-    }
-}
-
-// User selected an X11 window from a menu
-- (IBAction)itemSelected:(id)sender
-{
-    xEvent xe;
-
-    [NSApp activateIgnoringOtherApps:YES];
-
-    // Notify the client of the change through the X server thread
-    xe.u.u.type = kXDarwinControllerNotify;
-    xe.u.clientMessage.u.l.longs0 = AppleWMWindowMenuItem;
-    xe.u.clientMessage.u.l.longs1 = [sender tag];
-    [self sendXEvent:&xe];
-}
-
-// User selected Next from window menu
-- (IBAction)nextWindow:(id)sender
-{
-    QuartzMessageServerThread(kXDarwinControllerNotify, 1,
-                              AppleWMNextWindow);
-}
-
-// User selected Previous from window menu
-- (IBAction)previousWindow:(id)sender
-{
-    QuartzMessageServerThread(kXDarwinControllerNotify, 1,
-                              AppleWMPreviousWindow);
-}
-
-/*
- * The XPR implementation handles close, minimize, and zoom actions for X11
- * windows here, while CR handles these in the NSWindow class.
- */
-
-// Handle Close from window menu for X11 window in XPR implementation
-- (IBAction)performClose:(id)sender
-{
-    QuartzMessageServerThread(kXDarwinControllerNotify, 1,
-                              AppleWMCloseWindow);
-}
-
-// Handle Minimize from window menu for X11 window in XPR implementation
-- (IBAction)performMiniaturize:(id)sender
-{
-    QuartzMessageServerThread(kXDarwinControllerNotify, 1,
-                              AppleWMMinimizeWindow);
-}
-
-// Handle Zoom from window menu for X11 window in XPR implementation
-- (IBAction)performZoom:(id)sender
-{
-    QuartzMessageServerThread(kXDarwinControllerNotify, 1,
-                              AppleWMZoomWindow);
-}
-
-// Handle "Bring All to Front" from window menu
-- (IBAction)bringAllToFront:(id)sender
-{
-    if ((AppleWMSelectedEvents() & AppleWMControllerNotifyMask) != 0) {
-        QuartzMessageServerThread(kXDarwinControllerNotify, 1,
-                                  AppleWMBringAllToFront);
-    } else {
-        [NSApp arrangeInFront:nil];
-    }
-}
-
-// This ends up at the end of the responder chain.
-- (IBAction)copy:(id)sender
-{
-    QuartzMessageServerThread(kXDarwinPasteboardNotify, 1,
-                              AppleWMCopyToPasteboard);
-}
-
-// Set whether or not X11 is active and should receive all key events
-- (void)activateX11:(BOOL)state
-{
-    if (state) {
-        QuartzMessageServerThread(kXDarwinActivate, 0);
-    }
-    else {
-        QuartzMessageServerThread(kXDarwinDeactivate, 0);
-    }
-
-    x11Active = state;
-}
-
-// Some NSWindow became the key window
-- (void)windowBecameKey:(NSNotification *)notification
-{
-    NSWindow *window = [notification object];
-
-    if (quartzProcs->IsX11Window(window, [window windowNumber])) {
-        if (!x11Active)
-            [self activateX11:YES];
-    } else {
-        if (x11Active)
-            [self activateX11:NO];
-    }
-}
-
-// Set the Apple-WM specifiable part of the window menu
-- (void)setX11WindowList:(NSArray *)list
-{
-    NSMenuItem *item;
-    int first, count, i;
-    xEvent xe;
-
-    /* Work backwards so we don't mess up the indices */
-    first = [windowMenu indexOfItem:windowSeparator] + 1;
-    if (first > 0) {
-        count = [windowMenu numberOfItems];
-        for (i = count - 1; i >= first; i--)
-            [windowMenu removeItemAtIndex:i];
-    } else {
-        windowSeparator = (NSMenuItem *)[windowMenu addItemWithTitle:@""
-                                                    action:nil
-                                                    keyEquivalent:@""];
-    }
-
-    count = [dockMenu numberOfItems];
-    for (i = 0; i < count; i++)
-        [dockMenu removeItemAtIndex:0];
-
-    count = [list count];
-
-    for (i = 0; i < count; i++)
-    {
-        NSString *name, *shortcut;
-
-        name = [[list objectAtIndex:i] objectAtIndex:0];
-        shortcut = [[list objectAtIndex:i] objectAtIndex:1];
-
-        item = (NSMenuItem *)[windowMenu addItemWithTitle:name
-                                         action:@selector(itemSelected:)
-                                         keyEquivalent:shortcut];
-        [item setTarget:self];
-        [item setTag:i];
-        [item setEnabled:YES];
-
-        item = (NSMenuItem *)[dockMenu insertItemWithTitle:name
-                                       action:@selector(itemSelected:)
-                                       keyEquivalent:shortcut atIndex:i];
-        [item setTarget:self];
-        [item setTag:i];
-        [item setEnabled:YES];
-    }
-
-    if (checkedWindowItem >= 0 && checkedWindowItem < count)
-    {
-        item = (NSMenuItem *)[windowMenu itemAtIndex:first + checkedWindowItem];
-        [item setState:NSOnState];
-        item = (NSMenuItem *)[dockMenu itemAtIndex:checkedWindowItem];
-        [item setState:NSOnState];
-    }
-
-    // Notify the client of the change through the X server thread
-    xe.u.u.type = kXDarwinControllerNotify;
-    xe.u.clientMessage.u.l.longs0 = AppleWMWindowMenuNotify;
-    [self sendXEvent:&xe];
-}
-
-// Set the checked item on the Apple-WM specifiable window menu
-- (void)setX11WindowCheck:(NSNumber *)nn
-{
-    NSMenuItem *item;
-    int first, count;
-    int n = [nn intValue];
-
-    first = [windowMenu indexOfItem:windowSeparator] + 1;
-    count = [windowMenu numberOfItems] - first;
-
-    if (checkedWindowItem >= 0 && checkedWindowItem < count)
-    {
-        item = (NSMenuItem *)[windowMenu itemAtIndex:first + checkedWindowItem];
-        [item setState:NSOffState];
-        item = (NSMenuItem *)[dockMenu itemAtIndex:checkedWindowItem];
-        [item setState:NSOffState];
-    }
-    if (n >= 0 && n < count)
-    {
-        item = (NSMenuItem *)[windowMenu itemAtIndex:first + n];
-        [item setState:NSOnState];
-        item = (NSMenuItem *)[dockMenu itemAtIndex:n];
-        [item setState:NSOnState];
-    }
-    checkedWindowItem = n;
-}
-
-// Return whether or not a menu item should be enabled
-- (BOOL)validateMenuItem:(NSMenuItem *)item
-{
-    NSMenu *menu = [item menu];
-
-    if (menu == windowMenu && [item tag] == 30) {
-        // Mode switch panel is for fullscreen only
-        return !quartzRootless;
-    }
-    else if ((menu == windowMenu && [item tag] != 40) || menu == dockMenu) {
-        // The special window and dock menu items should not be active unless
-        // there is an AppleWM-aware window manager running.
-        return (AppleWMSelectedEvents() & AppleWMControllerNotifyMask) != 0;
-    }
-    else {
-        return TRUE;
-    }
-}
-
-/*
- * Application Delegate Methods
- */
-
-- (void)applicationDidChangeScreenParameters:(NSNotification *)aNotification
-{
-    if (quartzProcs->ScreenChanged)
-        quartzProcs->ScreenChanged();
-}
-
-- (void)applicationDidHide:(NSNotification *)aNotification
-{
-    if ((AppleWMSelectedEvents() & AppleWMControllerNotifyMask) != 0) {
-        QuartzMessageServerThread(kXDarwinControllerNotify, 1,
-                                  AppleWMHideAll);
-    } else {
-        if (quartzProcs->HideWindows)
-            quartzProcs->HideWindows(YES);
-    }
-}
-
-- (void)applicationDidUnhide:(NSNotification *)aNotification
-{
-    if ((AppleWMSelectedEvents() & AppleWMControllerNotifyMask) != 0) {
-        QuartzMessageServerThread(kXDarwinControllerNotify, 1,
-                                  AppleWMShowAll);
-    } else {
-        if (quartzProcs->HideWindows)
-            quartzProcs->HideWindows(NO);
-    }
-}
-
-// Called when the user clicks the application icon,
-// but not when Cmd-Tab is used.
-// Rootless: Don't switch until applicationWillBecomeActive.
-- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication
-            hasVisibleWindows:(BOOL)flag
-{
-    if ([Preferences dockSwitch] && !quartzRootless) {
-        [self showServer:YES];
-    }
-    return NO;
-}
-
-- (void)applicationWillResignActive:(NSNotification *)aNotification
-{
-    [self showServer:NO];
-}
-
-- (void)applicationWillBecomeActive:(NSNotification *)aNotification
-{
-    if (quartzRootless) {
-        [self showServer:YES];
-
-        // If there is no AppleWM-aware window manager, we can't allow
-        // interleaving of Aqua and X11 windows.
-        if ((AppleWMSelectedEvents() & AppleWMControllerNotifyMask) == 0) {
-            [NSApp arrangeInFront:nil];
-        }
-    }
-}
-
-// Called when the user opens a document type that we claim (ie. an X11 executable).
-- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
-{
-    if (serverState == server_Running) {
-        [self runClient:filename];
-        return YES;
-    }
-    else if (serverState == server_NotStarted || serverState == server_Starting) {
-        if ([filename UTF8String][0] != ':') {          // Ignore display names
-            if (!pendingClients) {
-                pendingClients = [[NSMutableArray alloc] initWithCapacity:1];
-            }
-            [pendingClients addObject:filename];
-            return YES;                 // Assume it will launch successfully
-        }
-        return NO;
-    }
-
-    // If the server is quitting or done,
-    // its too late to launch new clients this time.
-    return NO;
-}
-
- at end
-
-
-// Send a message to the main thread, which calls handlePortMessage in
-// response. Must only be called from the X server thread because
-// NSPort is not thread safe.
-void QuartzMessageMainThread(unsigned msg, void *data, unsigned length)
-{
-    if (length > 0) {
-        NSData *eventData = [NSData dataWithBytes:data length:length];
-        NSArray *eventArray = [NSArray arrayWithObject:eventData];
-        NSPortMessage *newMessage =
-                [[NSPortMessage alloc]
-                        initWithSendPort:signalPort
-                        receivePort:returnPort components:eventArray];
-        [newMessage setMsgid:msg];
-        [newMessage sendBeforeDate:[NSDate distantPast]];
-        [newMessage release];
-    } else {
-        [signalMessage setMsgid:msg];
-        [signalMessage sendBeforeDate:[NSDate distantPast]];
-    }
-}
-
-void
-QuartzSetWindowMenu(int nitems, const char **items,
-                    const char *shortcuts)
-{
-    NSMutableArray *array;
-    int i;
-
-    array = [[NSMutableArray alloc] initWithCapacity:nitems];
-
-    for (i = 0; i < nitems; i++) {
-        NSMutableArray *subarray = [NSMutableArray arrayWithCapacity:2];
-        NSString *string = [NSString stringWithUTF8String:items[i]];
-
-        [subarray addObject:string];
-
-        if (shortcuts[i] != 0) {
-            NSString *number = [NSString stringWithFormat:@"%d",
-                                         shortcuts[i]];
-            [subarray addObject:number];
-        } else
-            [subarray addObject:@""];
-
-        [array addObject:subarray];
-    }
-
-    /* Send the array of strings over to the main thread. */
-    /* Will be released in main thread. */
-    QuartzMessageMainThread(kQuartzSetWindowMenu, &array, sizeof(NSArray *));
-}
-
-// Handle SIGCHLD signals
-static void childDone(int sig)
-{
-    int clientStatus;
-
-    if (clientPID == 0)
-        return;
-
-    // Make sure it was the client task that finished
-    if (waitpid(clientPID, &clientStatus, WNOHANG) == clientPID) {
-        if (WIFSTOPPED(clientStatus))
-            return;
-        clientPID = 0;
-        [oneXServer clientProcessDone:clientStatus];
-    }
-}
-
-static void powerDidChange(
-    void *x,
-    io_service_t y,
-    natural_t messageType,
-    void *messageArgument)
-{
-    switch (messageType) {
-        case kIOMessageSystemWillSleep:
-            if (!quartzRootless) {
-                [oneXServer setRootClip:FALSE];
-            }
-            IOAllowPowerChange(root_port, (long)messageArgument);
-            break;
-        case kIOMessageCanSystemSleep:
-            IOAllowPowerChange(root_port, (long)messageArgument);
-            break;
-        case kIOMessageSystemHasPoweredOn:
-            if (!quartzRootless) {
-                [oneXServer setRootClip:TRUE];
-            }
-            break;
-    }
-
-}
commit 260ea615402a2cd953b45ebde19e668b16ede616
Author: Ben Byer <bbyer at bbyer.local>
Date:   Sun Nov 18 17:44:12 2007 -0800

    Added some DEBUG_LOG sauce to the XP_EVENT handling code

diff --git a/hw/darwin/quartz/xpr/xprScreen.c b/hw/darwin/quartz/xpr/xprScreen.c
index 4c147d5..5b57124 100644
--- a/hw/darwin/quartz/xpr/xprScreen.c
+++ b/hw/darwin/quartz/xpr/xprScreen.c
@@ -64,49 +64,49 @@ static void
 eventHandler(unsigned int type, const void *arg,
              unsigned int arg_size, void *data)
 {
-    switch (type)
-    {
+    switch (type) {
     case XP_EVENT_DISPLAY_CHANGED:
-      //      ErrorF("XP_EVENT_DISPLAY_MOVED\n");
-        QuartzMessageServerThread(kXDarwinDisplayChanged, 0);
-        break;
+      DEBUG_LOG("XP_EVENT_DISPLAY_CHANGED\n");
+      QuartzMessageServerThread(kXDarwinDisplayChanged, 0);
+      break;
 
     case XP_EVENT_WINDOW_STATE_CHANGED:
-      //      ErrorF("XP_EVENT_WINDOW_STATE_CHANGED\n");
-        if (arg_size >= sizeof(xp_window_state_event))
-        {
-            const xp_window_state_event *ws_arg = arg;
-
-            QuartzMessageServerThread(kXDarwinWindowState, 2,
-                                      ws_arg->id, ws_arg->state);
-        }
-        break;
+      DEBUG_LOG("XP_EVENT_WINDOW_STATE_CHANGED\n");
+      if (arg_size >= sizeof(xp_window_state_event)) {
+	const xp_window_state_event *ws_arg = arg;
+	
+	QuartzMessageServerThread(kXDarwinWindowState, 2,
+				  ws_arg->id, ws_arg->state);
+      }
+      break;
 
     case XP_EVENT_WINDOW_MOVED:
-      //      ErrorF("XP_EVENT_WINDOW_MOVED\n");
-        if (arg_size == sizeof(xp_window_id))
-        {
-            xp_window_id id = * (xp_window_id *) arg;
-	    WindowPtr pWin = xprGetXWindow(id);
-            QuartzMessageServerThread(kXDarwinWindowMoved, 1, pWin);
-        }
-        break;
-
+      DEBUG_LOG("XP_EVENT_WINDOW_MOVED\n");
+      if (arg_size == sizeof(xp_window_id))  {
+	xp_window_id id = * (xp_window_id *) arg;
+	WindowPtr pWin = xprGetXWindow(id);
+	QuartzMessageServerThread(kXDarwinWindowMoved, 1, pWin);
+      }
+      break;
+      
     case XP_EVENT_SURFACE_DESTROYED:
+      DEBUG_LOG("XP_EVENT_SURFACE_DESTROYED\n");
     case XP_EVENT_SURFACE_CHANGED:
-      //      ErrorF("XP_EVENT_SURFACE_MOVED\n");
-        if (arg_size == sizeof(xp_surface_id))
-        {
-            int kind;
-
-            if (type == XP_EVENT_SURFACE_DESTROYED)
-                kind = AppleDRISurfaceNotifyDestroyed;
-            else
-                kind = AppleDRISurfaceNotifyChanged;
-
-            DRISurfaceNotify(*(xp_surface_id *) arg, kind);
+      DEBUG_LOG("XP_EVENT_SURFACE_CHANGED\n");
+        if (arg_size == sizeof(xp_surface_id)) {
+	  int kind;
+	  
+	  if (type == XP_EVENT_SURFACE_DESTROYED)
+	    kind = AppleDRISurfaceNotifyDestroyed;
+	  else
+	    kind = AppleDRISurfaceNotifyChanged;
+	  
+	  DRISurfaceNotify(*(xp_surface_id *) arg, kind);
         }
         break;
+    default:
+      ErrorF("Unknown XP_EVENT type (%d) in xprScreen:eventHandler\n",
+	     type);
     }
 }
 
commit 1ffd8ba7a2356e204d49f72dfafc0b26a4f5885f
Author: Ben Byer <bbyer at bbyer.local>
Date:   Sun Nov 18 17:43:40 2007 -0800

    Disabled ALT_IS_MODE_SWITCH
    (just for joke, nothing more)

diff --git a/hw/darwin/darwinKeyboard.c b/hw/darwin/darwinKeyboard.c
index 2f537ca..47acb65 100644
--- a/hw/darwin/darwinKeyboard.c
+++ b/hw/darwin/darwinKeyboard.c
@@ -61,7 +61,7 @@
 #undef DUMP_DARWIN_KEYMAP
 
 /* Define this to use Alt for Mode_switch. */
-#define ALT_IS_MODE_SWITCH 1
+//#define ALT_IS_MODE_SWITCH 1
 
 #include <stdio.h>
 #include <stdlib.h>
commit db6404f9d0c828015e78bcd0be603b50c7aa18f6
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Sun Nov 18 03:03:39 2007 -0800

    Added --with-x11app-archs configure option
    This configure option's value is passed to xcodebuild in ARCHS, so we can easily choose architecture targets for X11.app

diff --git a/configure.ac b/configure.ac
index 7c07a93..493a430 100644
--- a/configure.ac
+++ b/configure.ac
@@ -525,6 +525,8 @@ AC_ARG_ENABLE(xvfb,    	      AS_HELP_STRING([--enable-xvfb], [Build Xvfb server
 AC_ARG_ENABLE(xnest,   	      AS_HELP_STRING([--enable-xnest], [Build Xnest server (default: no)]), [XNEST=$enableval], [XNEST=no])
 AC_ARG_ENABLE(xquartz,        AS_HELP_STRING([--enable-xquartz], [Build Xquartz server for OS-X (default: auto)]), [XQUARTZ=$enableval], [XQUARTZ=auto])
 AC_ARG_ENABLE(x11app,         AS_HELP_STRING([--enable-x11app], [Build Apple's X11.app for Xquartz (default: auto)]), [X11APP=$enableval], [X11APP=auto])
+AC_ARG_WITH(x11app-archs,     AS_HELP_STRING([--with-x11app-archs=ARCHS], [Architectures to build X11.app for, space delimeted (default: "ppc i386")]), [X11APP_ARCHS=$enableval], [X11APP_ARCHS="ppc i386"])
+AC_SUBST([X11APP_ARCHS])
 AC_ARG_ENABLE(xwin,    	      AS_HELP_STRING([--enable-xwin], [Build XWin server (default: auto)]), [XWIN=$enableval], [XWIN=auto])
 AC_ARG_ENABLE(xprint,         AS_HELP_STRING([--enable-xprint], [Build Xprint extension and server (default: no)]), [XPRINT=$enableval], [XPRINT=no])
 AC_ARG_ENABLE(xgl,            AS_HELP_STRING([--enable-xgl], [Build Xgl server (default: no)]), [XGL=$enableval], [XGL=no])
diff --git a/hw/darwin/Makefile.am b/hw/darwin/Makefile.am
index 0d3ee02..f82ed02 100644
--- a/hw/darwin/Makefile.am
+++ b/hw/darwin/Makefile.am
@@ -1,11 +1,11 @@
 AM_CFLAGS = @XORG_CFLAGS@
 AM_CPPFLAGS = @XORG_INCS@ -I$(top_srcdir)/Xext -I$(top_srcdir)/miext/rootless -DUSE_NEW_CLUT -DBUILD_DATE=\"$(BUILD_DATE)\" -DHAVE_XORG_CONFIG_H -DXFree86Server -DINXQUARTZ
-  
+
 SUBDIRS = quartz utils
-  
+
 bin_PROGRAMS = Xquartz
 man1_MANS = apple/Xquartz.man
-  
+
 Xquartz_SOURCES = darwin.c \
 		  darwinEvents.c \
 		  darwinKeyboard.c \
@@ -43,7 +43,6 @@ Xquartz_LDADD = ./quartz/libXquartz.a \
 		$(top_builddir)/miext/rootless/accel/librlAccel.la \
 		$(DARWIN_LIBS) $(XSERVER_LIBS) -lXplugin
 
-
 Xquartz_LDFLAGS =  -XCClinker -Objc \
 		   -Wl,-u,_miDCInitialize \
 		   -Wl,-framework,Carbon \
@@ -57,16 +56,16 @@ if X11APP
 bin_SCRIPTS = x11app x11launcher
 
 x11app:
-	cd apple && xcodebuild CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"
+	cd apple && xcodebuild CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" ARCHS="$(X11APP_ARCHS)"
 
 x11launcher:
-	cd launcher && xcodebuild CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"
+	cd launcher && xcodebuild CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" ARCHS="$(X11APP_ARCHS)"
 
 x11app-install:
-	cd apple && xcodebuild install DSTROOT=$(DESTDIR) INSTALL_PATH=$(prefix) DEPLOYMENT_LOCATION=YES SKIP_INSTALL=NO
+	cd apple && xcodebuild install DSTROOT=$(DESTDIR) INSTALL_PATH=$(prefix) DEPLOYMENT_LOCATION=YES SKIP_INSTALL=NO ARCHS="$(X11APP_ARCHS)"
 
 x11launcher-install:
-	cd launcher && xcodebuild install DSTROOT=$(DESTDIR) INSTALL_PATH=$(APPLE_APPLICATIONS_DIR) DEPLOYMENT_LOCATION=YES SKIP_INSTALL=NO
+	cd launcher && xcodebuild install DSTROOT=$(DESTDIR) INSTALL_PATH=$(APPLE_APPLICATIONS_DIR) DEPLOYMENT_LOCATION=YES SKIP_INSTALL=NO ARCHS="$(X11APP_ARCHS)"
 
 x11app-clean:
 	rm -rf apple/build
commit e220328bdf9d62a57c9178190616912c3265b55a
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Fri Nov 16 16:07:17 2007 -0800

    From Jeremy: In my previous patch, I "overfixed" hook.c.  This patch
    removes the changes I made to the searching for loop since those are
    extraneous due to the remove function call in the delete for loop.

diff --git a/hw/darwin/quartz/xpr/x-hook.c b/hw/darwin/quartz/xpr/x-hook.c
index 2d9a564..84bf444 100644
--- a/hw/darwin/quartz/xpr/x-hook.c
+++ b/hw/darwin/quartz/xpr/x-hook.c
@@ -50,19 +50,12 @@ X_PFX (hook_remove) (x_list *lst, x_hook_function *fun, void *data)
 {
     x_list *node, *cell;
     x_list *to_delete = NULL;
-    x_list *prev = NULL;
 
-    for (node = lst; node != NULL; prev = node, node = node->next)
+    for (node = lst; node != NULL; node = node->next)
     {
 	cell = node->data;
 	if (CELL_FUN (cell) == fun && CELL_DATA (cell) == data)
-        {
 	    to_delete = X_PFX (list_prepend) (to_delete, cell);
-            if(lst == node)
-                lst = node->next;
-            else
-                prev->next = node->next;
-        }
     }
 
     for (node = to_delete; node != NULL; node = node->next)
commit c50a40263b489654111dcdd9e38c6dd79d3a374c
Author: Ben Byer <bbyer at bbyer.local>
Date:   Fri Nov 16 05:36:51 2007 -0800

    More correctness fixes to fix compiler warnings.

diff --git a/hw/darwin/quartz/quartz.c b/hw/darwin/quartz/quartz.c
index 615ea8d..d1eb724 100644
--- a/hw/darwin/quartz/quartz.c
+++ b/hw/darwin/quartz/quartz.c
@@ -464,7 +464,7 @@ void DarwinModeProcessEvent(
 	  
         case kXDarwinWindowMoved:
 	  DEBUG_LOG("kXDarwinWindowMoved\n");
-            RootlessNativeWindowMoved (xe->u.clientMessage.u.l.longs0);
+	  RootlessNativeWindowMoved ((WindowPtr)xe->u.clientMessage.u.l.longs0);
 	    break;
 
         case kXDarwinToggleFullscreen:
diff --git a/hw/darwin/quartz/quartzCocoa.m b/hw/darwin/quartz/quartzCocoa.m
index c5e6e5c..46c61dc 100644
--- a/hw/darwin/quartz/quartzCocoa.m
+++ b/hw/darwin/quartz/quartzCocoa.m
@@ -123,9 +123,9 @@ int QuartzFSUseQDCursor(
  *  Clean out any autoreleased objects.
  */
 void QuartzBlockHandler(
-    void *blockData,
-    void *pTimeout,
-    void *pReadmask)
+    pointer blockData,
+    OSTimePtr pTimeout,
+    pointer pReadmask)
 {
     static NSAutoreleasePool *aPool = nil;
 
@@ -138,9 +138,9 @@ void QuartzBlockHandler(
  * QuartzWakeupHandler
  */
 void QuartzWakeupHandler(
-    void *blockData,
+    pointer blockData,
     int result,
-    void *pReadmask)
+    pointer pReadmask)
 {
     // nothing here
 }
diff --git a/hw/darwin/quartz/quartzCommon.h b/hw/darwin/quartz/quartzCommon.h
index f5dff66..f0d5a7a 100644
--- a/hw/darwin/quartz/quartzCommon.h
+++ b/hw/darwin/quartz/quartzCommon.h
@@ -46,6 +46,7 @@
 #undef Cursor
 #undef WindowPtr
 #undef Picture
+#include <X11/Xdefs.h>
 
 // Quartz specific per screen storage structure
 typedef struct {
@@ -87,8 +88,8 @@ void QuartzSetWindowMenu(int nitems, const char **items,
 void QuartzFSCapture(void);
 void QuartzFSRelease(void);
 int  QuartzFSUseQDCursor(int depth);
-void QuartzBlockHandler(void *blockData, void *pTimeout, void *pReadmask);
-void QuartzWakeupHandler(void *blockData, int result, void *pReadmask);
+void QuartzBlockHandler(pointer blockData, OSTimePtr pTimeout, pointer pReadmask);
+void QuartzWakeupHandler(pointer blockData, int result, pointer pReadmask);
 
 // Messages that can be sent to the main thread.
 enum {
diff --git a/hw/darwin/quartz/xpr/xprScreen.c b/hw/darwin/quartz/xpr/xprScreen.c
index ad23006..4c147d5 100644
--- a/hw/darwin/quartz/xpr/xprScreen.c
+++ b/hw/darwin/quartz/xpr/xprScreen.c
@@ -88,13 +88,7 @@ eventHandler(unsigned int type, const void *arg,
         {
             xp_window_id id = * (xp_window_id *) arg;
 	    WindowPtr pWin = xprGetXWindow(id);
-	    BoxRec box;
-	    xp_error retval  = xp_get_window_bounds(id, &box);
-	    if (retval != Success) {
-	      ErrorF("Unable to find new bounds for window\n");
-	      break;
-	    }
-            QuartzMessageServerThread(kXDarwinWindowMoved, 3, pWin, box.x1, box.y1);
+            QuartzMessageServerThread(kXDarwinWindowMoved, 1, pWin);
         }
         break;
 
commit cee516e1426ba19ee95935ac92fc00ba9048eb1e
Author: Ben Byer <bbyer at bbyer.local>
Date:   Fri Nov 16 05:04:54 2007 -0800

    From Jeremy Huddleston:
    1) Fixed a bug where XQUARTZ was #defined when auto but not when --enable-xquartz
    2) Cleaned up missing #includes and function prototypes.
    3) Fixed some invalid C syntax problems
    4) Removed a bunch of dead code
    5) Cleaned up code to prevent some warnings
    6) Bugfix in xpr/x-hook.c - looks like someone just forgot to finish writing code for hook_remove()... I only noticed it because gcc -Wall complained about reaching the end of a non-void function... lucky for us gcc is smarter than we are.

diff --git a/configure.ac b/configure.ac
index e40bf65..7c07a93 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1708,7 +1708,6 @@ if test "X$XQUARTZ" = Xauto; then
 		LDFLAGS=$save_LDFLAGS])
                 
 	if test "X$xorg_cv_Carbon_framework" = Xyes; then
-		AC_DEFINE([XQUARTZ],[1],[Have Quartz])
 		XQUARTZ=yes
 	else
 		XQUARTZ=no
@@ -1716,15 +1715,7 @@ if test "X$XQUARTZ" = Xauto; then
 fi
 
 if test "x$XQUARTZ" = xyes; then
-	if test "x$X11APP" = xauto; then
-		AC_MSG_CHECKING([whether to build X11.app])
-		if test "x$XQUARTZ" = xyes ; then
-			X11APP=yes
-		else
-			X11APP=no
-		fi
-		AC_MSG_RESULT([$X11APP])
-	fi
+	AC_DEFINE([XQUARTZ],[1],[Have Quartz])
 
 #	       glxAGL / glxCGL don't work yet
 #               AC_CACHE_CHECK([for AGL framework],xorg_cv_AGL_framework,[
@@ -1767,6 +1758,16 @@ if test "x$XQUARTZ" = xyes; then
                fi
 fi
 
+if test "x$X11APP" = xauto; then
+	AC_MSG_CHECKING([whether to build X11.app])
+	if test "x$XQUARTZ" = xyes ; then
+		X11APP=yes
+	else
+		X11APP=no
+	fi
+	AC_MSG_RESULT([$X11APP])
+fi
+
 if test "x$LAUNCHD" = xauto; then
 	# Do we want to have this default to on for Xquartz builds only or any time we have launchd (like Xnest or Xvfb on OS-X)
 	#AC_CHECK_PROG(LAUNCHD, [launchd], [yes], [no])
diff --git a/dix/main.c b/dix/main.c
index c322b0d..06f022b 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -260,11 +260,6 @@ main(int argc, char *argv[], char *envp[])
     /* Quartz support on Mac OS X requires that the Cocoa event loop be in
      * the main thread. This allows the X server main to be called again
      * from another thread. */
-
-    /* TODO: Put some runtime conditioning on this, so it doesn't get
-     * executed by Xvfb, Xnest, Xfake, Xephyr, etc when built at the same
-     * time as Xquartz
-     */
     DarwinHandleGUI(argc, argv, envp);
 #endif
 
diff --git a/hw/darwin/Makefile.am b/hw/darwin/Makefile.am
index e23a3d1..0d3ee02 100644
--- a/hw/darwin/Makefile.am
+++ b/hw/darwin/Makefile.am
@@ -1,5 +1,5 @@
 AM_CFLAGS = @XORG_CFLAGS@
-AM_CPPFLAGS = @XORG_INCS@ -I../../miext/rootless -DUSE_NEW_CLUT -DBUILD_DATE=\"$(BUILD_DATE)\" -DHAVE_XORG_CONFIG_H -DXFree86Server -DINXQUARTZ
+AM_CPPFLAGS = @XORG_INCS@ -I$(top_srcdir)/Xext -I$(top_srcdir)/miext/rootless -DUSE_NEW_CLUT -DBUILD_DATE=\"$(BUILD_DATE)\" -DHAVE_XORG_CONFIG_H -DXFree86Server -DINXQUARTZ
   
 SUBDIRS = quartz utils
   
diff --git a/hw/darwin/apple/X11Application.m b/hw/darwin/apple/X11Application.m
index f49429f..ae6f4bc 100644
--- a/hw/darwin/apple/X11Application.m
+++ b/hw/darwin/apple/X11Application.m
@@ -47,6 +47,10 @@
 #include <unistd.h>
 #include <pthread.h>
 
+#include "rootlessCommon.h"
+
+WindowPtr xprGetXWindowFromAppKit(int windowNumber); // xpr/xprFrame.c
+
 #define DEFAULTS_FILE "/usr/X11/lib/X11/xserver/Xquartz.plist"
 
 int X11EnableKeyEquivalents = TRUE;
@@ -577,7 +581,7 @@ cfarray_to_nsarray (CFArrayRef in)
 			ret = CFBooleanGetValue (value);
 		else if (CFGetTypeID (value) == CFStringGetTypeID ())
 		{
-			const char *tem = [(NSString *) value lossyCString];
+			const char *tem = [(NSString *) value UTF8String];
 			if (strcasecmp (tem, "true") == 0 || strcasecmp (tem, "yes") == 0)
 				ret = YES;
 			else
diff --git a/hw/darwin/darwin.c b/hw/darwin/darwin.c
index 789b0e2..c721ca1 100644
--- a/hw/darwin/darwin.c
+++ b/hw/darwin/darwin.c
@@ -69,6 +69,11 @@
 #include <IOKit/hidsystem/IOHIDLib.h>
 #include <IOKit/hidsystem/ev_keymap.h>
 
+#ifdef MITSHM
+#define _XSHM_SERVER_
+#include <X11/extensions/XShm.h>
+#endif
+
 #include "darwin.h"
 #include "darwinClut8.h"
 
@@ -186,7 +191,9 @@ static Bool DarwinAddScreen(
 
     // allocate space for private per screen storage
     dfb = xalloc(sizeof(DarwinFramebufferRec));
-    SCREEN_PRIV(pScreen) = dfb;
+
+    // SCREEN_PRIV(pScreen) = dfb;
+    pScreen->devPrivates[darwinScreenIndex].ptr = dfb;
 
     // setup hardware/mode specific details
     ret = DarwinModeAddScreen(foundIndex, pScreen);
@@ -342,7 +349,7 @@ static int DarwinMouseProc(
     DeviceIntPtr    pPointer,
     int             what )
 {
-    char map[6];
+    CARD8 map[6];
 
     switch (what) {
 
@@ -699,10 +706,30 @@ void ddxInitGlobals(void)
  */
 int ddxProcessArgument( int argc, char *argv[], int i )
 {
-    int numDone;
+    if ( !strcmp( argv[i], "-fullscreen" ) ) {
+        ErrorF( "Running full screen in parallel with Mac OS X Quartz window server.\n" );
+        return 1;
+    }
+
+    if ( !strcmp( argv[i], "-rootless" ) ) {
+        ErrorF( "Running rootless inside Mac OS X window server.\n" );
+        return 1;
+    }
 
-    if ((numDone = DarwinModeProcessArgument( argc, argv, i )))
-        return numDone;
+    if ( !strcmp( argv[i], "-quartz" ) ) {
+        ErrorF( "Running in parallel with Mac OS X Quartz window server.\n" );
+        return 1;
+    }
+
+    // The Mac OS X front end uses this argument, which we just ignore here.
+    if ( !strcmp( argv[i], "-nostartx" ) ) {
+        return 1;
+    }
+
+    // This command line arg is passed when launched from the Aqua GUI.
+    if ( !strncmp( argv[i], "-psn_", 5 ) ) {
+        return 1;
+    }
 
     if ( !strcmp( argv[i], "-fakebuttons" ) ) {
         darwinFakeButtons = TRUE;
diff --git a/hw/darwin/darwin.h b/hw/darwin/darwin.h
index 7e141fa..392bb43 100644
--- a/hw/darwin/darwin.h
+++ b/hw/darwin/darwin.h
@@ -76,7 +76,6 @@ Bool DarwinModeAddScreen(int index, ScreenPtr pScreen);
 Bool DarwinModeSetupScreen(int index, ScreenPtr pScreen);
 void DarwinModeInitOutput(int argc,char **argv);
 void DarwinModeInitInput(int argc, char **argv);
-int DarwinModeProcessArgument(int argc, char *argv[], int i);
 void DarwinModeProcessEvent(xEvent *xe);
 void DarwinModeGiveUp(void);
 void DarwinModeBell(int volume, DeviceIntPtr pDevice, pointer ctrl, int class);
diff --git a/hw/darwin/darwinEvents.c b/hw/darwin/darwinEvents.c
index 9d206d0..ee08233 100644
--- a/hw/darwin/darwinEvents.c
+++ b/hw/darwin/darwinEvents.c
@@ -257,7 +257,7 @@ static void DarwinUpdateModifiers(
 void DarwinReleaseModifiers(void) {
   KeySym *map = NULL;
   xEvent ke;
-  int i = 0, j = 0, nevents = 0; 
+  int i = 0; 
  
   DEBUG_LOG("DarwinReleaseModifiers(%p)\n", &keyInfo.keyMap);
   
diff --git a/hw/darwin/quartz/Makefile.am b/hw/darwin/quartz/Makefile.am
index 26bc8eb..838af29 100644
--- a/hw/darwin/quartz/Makefile.am
+++ b/hw/darwin/quartz/Makefile.am
@@ -2,7 +2,7 @@ noinst_LIBRARIES = libXQuartz.a
 
 AM_CFLAGS = @XORG_CFLAGS@
 AM_OBJCFLAGS = @XORG_CFLAGS@
-AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/.. @XORG_INCS@ -DXBINDIR=\"${bindir}\" -DHAS_KL_API -DHAVE_XORG_CONFIG_H
+AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../apple -I$(top_srcdir)/miext/rootless @XORG_INCS@ -DXBINDIR=\"${bindir}\" -DHAS_KL_API -DHAVE_XORG_CONFIG_H
 
 SUBDIRS = cr fullscreen xpr
 
diff --git a/hw/darwin/quartz/applewm.c b/hw/darwin/quartz/applewm.c
index 009eb87..2346303 100644
--- a/hw/darwin/quartz/applewm.c
+++ b/hw/darwin/quartz/applewm.c
@@ -47,6 +47,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define _APPLEWM_SERVER_
 #include "X11/extensions/applewmstr.h"
 #include "applewmExt.h"
+#include "X11Application.h"
 
 #define DEFINE_ATOM_HELPER(func,atom_name)                      \
 static Atom func (void) {                                       \
diff --git a/hw/darwin/quartz/quartz.c b/hw/darwin/quartz/quartz.c
index fcd78ae..615ea8d 100644
--- a/hw/darwin/quartz/quartz.c
+++ b/hw/darwin/quartz/quartz.c
@@ -40,11 +40,14 @@
 #include "X11/extensions/applewm.h"
 #include "applewmExt.h"
 
+#include "X11Application.h"
+
 // X headers
 #include "scrnintstr.h"
 #include "windowstr.h"
 #include "colormapst.h"
 #include "globals.h"
+#include "rootlessWindow.h"
 
 // System headers
 #include <sys/types.h>
@@ -111,7 +114,9 @@ Bool DarwinModeAddScreen(
 {
     // allocate space for private per screen Quartz specific storage
     QuartzScreenPtr displayInfo = xcalloc(sizeof(QuartzScreenRec), 1);
-    QUARTZ_PRIV(pScreen) = displayInfo;
+
+    // QUARTZ_PRIV(pScreen) = displayInfo;
+    pScreen->devPrivates[quartzScreenIndex].ptr = displayInfo;
 
     // do Quartz mode specific initialization
     return quartzProcs->AddScreen(index, pScreen);
diff --git a/hw/darwin/quartz/quartz.h b/hw/darwin/quartz/quartz.h
index 172f323..e74a108 100644
--- a/hw/darwin/quartz/quartz.h
+++ b/hw/darwin/quartz/quartz.h
@@ -124,6 +124,4 @@ typedef struct _QuartzModeProcs {
 extern QuartzModeProcsPtr quartzProcs;
 extern int quartzHasRoot, quartzEnableRootless;
 
-Bool QuartzLoadDisplayBundle(const char *dpyBundleName);
-
 #endif
diff --git a/hw/darwin/quartz/quartzStartup.c b/hw/darwin/quartz/quartzStartup.c
index 73a9f1a..3c8412f 100644
--- a/hw/darwin/quartz/quartzStartup.c
+++ b/hw/darwin/quartz/quartzStartup.c
@@ -40,14 +40,10 @@ char **envpGlobal;      // argcGlobal and argvGlobal
                         // are from dix/globals.c
 
 
-void X11ControllerMain(int argc, char *argv[],
-		       void (*server_thread) (void *), void *server_arg);
-void GlxExtensionInit(void);
-void GlxWrapInitVisuals(miInitVisualsProcPtr *procPtr);
+void X11ControllerMain(int argc, char *argv[], void (*server_thread) (void *), void *server_arg);
 
 static void server_thread (void *arg) {
   extern int main(int argc, char **argv, char **envp);
-  
   exit (main (argcGlobal, argvGlobal, envpGlobal));
 }
 
@@ -65,7 +61,7 @@ void DarwinHandleGUI(
     char        *envp[] )
 {
     static Bool been_here = FALSE;
-    int         main_exit, i;
+    int         i;
     int         fd[2];
 
     if (been_here) {
@@ -107,141 +103,5 @@ void DarwinHandleGUI(
     
     _InitHLTB();
     X11ControllerMain(argc, argv, server_thread, NULL);
-    exit(main_exit);
-}
-
-/*
- * QuartzLoadDisplayBundle
- *  Try to load the appropriate bundle containing the back end display code.
- */
-Bool QuartzLoadDisplayBundle(
-    const char *dpyBundleName)
-{
-    return TRUE;
-}
-
-#ifdef GLXEXT
-/*
- * LoadGlxBundle
- *  The Quartz mode X server needs to dynamically load the appropriate
- *  bundle before initializing GLX.
- */
-static void LoadGlxBundle(void)
-{
-    CFBundleRef mainBundle;
-    CFStringRef bundleName;
-    CFURLRef    bundleURL;
-    CFBundleRef glxBundle;
-
-    // Get the main bundle for the application
-    mainBundle = CFBundleGetMainBundle();
-
-    // Choose the bundle to load
-    ErrorF("Loading GLX bundle ");
-    if (/*quartzUseAGL*/0) {
-        bundleName = CFStringCreateWithCStringNoCopy(kCFAllocatorDefault,
-                                                     quartzOpenGLBundle,
-                                                     kCFStringEncodingASCII,
-                                                     kCFAllocatorNull);
-        ErrorF("%s (using Apple's OpenGL)\n", quartzOpenGLBundle);
-    } else {
-        bundleName = CFSTR("glxMesa.bundle");
-        CFRetain(bundleName);			// so we can release later
-        ErrorF("glxMesa.bundle (using Mesa)\n");
-    }
-
-    // Look for the appropriate GLX bundle in the main bundle by name
-    bundleURL = CFBundleCopyResourceURL(mainBundle, bundleName,
-                                        NULL, NULL);
-    if (!bundleURL) {
-        FatalError("Could not find GLX bundle.");
-    }
-
-    // Make a bundle instance using the URLRef
-    glxBundle = CFBundleCreate(kCFAllocatorDefault, bundleURL);
-
-    if (!CFBundleLoadExecutable(glxBundle)) {
-        FatalError("Could not load GLX bundle.");
-    }
-
-    // Find the GLX init functions
-    if (!GlxExtensionInit || !GlxWrapInitVisuals) {
-        FatalError("Could not initialize GLX bundle.");
-    }
-
-    // Release the CF objects
-    CFRelease(bundleName);
-    CFRelease(bundleURL);
-}
-# endif
-#else
-
-Bool QuartzLoadDisplayBundle(const char *dpyBundleName)
-{
-      return TRUE;
-  }
-
-/*
- * DarwinGlxExtensionInit
- *  Initialize the GLX extension.
- */
-void DarwinGlxPushProvider(void *impl)
-{
-    GlxPushProvider(impl);
-}
-
-/*
- * DarwinGlxExtensionInit
- *  Initialize the GLX extension.
- */
-void DarwinGlxExtensionInit(void)
-{
-    GlxExtensionInit();
-}
-
-
-/*
- * DarwinGlxWrapInitVisuals
- */
-void DarwinGlxWrapInitVisuals(
-    miInitVisualsProcPtr *procPtr)
-{
-    if (!GlxWrapInitVisuals)
-        LoadGlxBundle();
-    GlxWrapInitVisuals(procPtr);
-}
-#endif
-
-int DarwinModeProcessArgument( int argc, char *argv[], int i )
-{
-    // fullscreen: CoreGraphics full-screen mode
-    // rootless: Cocoa rootless mode
-    // quartz: Default, either fullscreen or rootless
-
-    if ( !strcmp( argv[i], "-fullscreen" ) ) {
-        ErrorF( "Running full screen in parallel with Mac OS X Quartz window server.\n" );
-        return 1;
-    }
-
-    if ( !strcmp( argv[i], "-rootless" ) ) {
-        ErrorF( "Running rootless inside Mac OS X window server.\n" );
-        return 1;
-    }
-
-    if ( !strcmp( argv[i], "-quartz" ) ) {
-        ErrorF( "Running in parallel with Mac OS X Quartz window server.\n" );
-        return 1;
-    }
-
-    // The Mac OS X front end uses this argument, which we just ignore here.
-    if ( !strcmp( argv[i], "-nostartx" ) ) {
-        return 1;
-    }
-
-    // This command line arg is passed when launched from the Aqua GUI.
-    if ( !strncmp( argv[i], "-psn_", 5 ) ) {
-        return 1;
-    }
-
-    return 0;
+    exit(0);
 }
diff --git a/hw/darwin/quartz/xpr/appledri.c b/hw/darwin/quartz/xpr/appledri.c
index ef68c86..9b2e7b0 100644
--- a/hw/darwin/quartz/xpr/appledri.c
+++ b/hw/darwin/quartz/xpr/appledri.c
@@ -175,7 +175,7 @@ ProcAppleDRIAuthConnection(
     rep.authenticated = 1;
 
     if (!DRIAuthConnection( screenInfo.screens[stuff->screen], stuff->magic)) {
-        ErrorF("Failed to authenticate %u\n", stuff->magic);
+        ErrorF("Failed to authenticate %u\n", (unsigned int)stuff->magic);
         rep.authenticated = 0;
     }
     WriteToClient(client, sizeof(xAppleDRIAuthConnectionReply), (char *)&rep);
diff --git a/hw/darwin/quartz/xpr/x-hook.c b/hw/darwin/quartz/xpr/x-hook.c
index 323e373..2d9a564 100644
--- a/hw/darwin/quartz/xpr/x-hook.c
+++ b/hw/darwin/quartz/xpr/x-hook.c
@@ -50,12 +50,19 @@ X_PFX (hook_remove) (x_list *lst, x_hook_function *fun, void *data)
 {
     x_list *node, *cell;
     x_list *to_delete = NULL;
+    x_list *prev = NULL;
 
-    for (node = lst; node != NULL; node = node->next)
+    for (node = lst; node != NULL; prev = node, node = node->next)
     {
 	cell = node->data;
 	if (CELL_FUN (cell) == fun && CELL_DATA (cell) == data)
+        {
 	    to_delete = X_PFX (list_prepend) (to_delete, cell);
+            if(lst == node)
+                lst = node->next;
+            else
+                prev->next = node->next;
+        }
     }
 
     for (node = to_delete; node != NULL; node = node->next)
@@ -66,6 +73,7 @@ X_PFX (hook_remove) (x_list *lst, x_hook_function *fun, void *data)
     }
 
     X_PFX (list_free) (to_delete);
+    return lst;
 }
 
 X_EXTERN void
diff --git a/hw/darwin/quartz/xpr/xprCursor.c b/hw/darwin/quartz/xpr/xprCursor.c
index 02260bd..e45bd1f 100644
--- a/hw/darwin/quartz/xpr/xprCursor.c
+++ b/hw/darwin/quartz/xpr/xprCursor.c
@@ -381,7 +381,8 @@ QuartzInitCursor(ScreenPtr pScreen)
     if (ScreenPriv == NULL)
         return FALSE;
 
-    CURSOR_PRIV(pScreen) = ScreenPriv;
+    /* CURSOR_PRIV(pScreen) = ScreenPriv; */
+    pScreen->devPrivates[darwinCursorScreenIndex].ptr = ScreenPriv;
 
     /* override some screen procedures */
     ScreenPriv->QueryBestSize = pScreen->QueryBestSize;
diff --git a/hw/darwin/quartz/xpr/xprScreen.c b/hw/darwin/quartz/xpr/xprScreen.c
index e31d78e..ad23006 100644
--- a/hw/darwin/quartz/xpr/xprScreen.c
+++ b/hw/darwin/quartz/xpr/xprScreen.c
@@ -42,6 +42,9 @@
 #include "Xplugin.h"
 #include "quartz/applewmExt.h"
 
+// From xprFrame.c
+WindowPtr xprGetXWindow(xp_window_id wid);
+
 #ifdef DAMAGE
 # include "damage.h"
 #endif
diff --git a/mi/miinitext.c b/mi/miinitext.c
index ea09302..02000ef 100644
--- a/mi/miinitext.c
+++ b/mi/miinitext.c
@@ -661,12 +661,8 @@ InitVisualWrap()
 {
     miResetInitVisuals();
 #ifdef GLXEXT
-#ifdef INXQUARTZ
-    DarwinGlxWrapInitVisuals(&miInitVisualsProc);
-#else
     GlxWrapInitVisuals(&miInitVisualsProc);
 #endif
-#endif
 }
 
 #else /* XFree86LOADER */
diff --git a/miext/rootless/rootlessWindow.h b/miext/rootless/rootlessWindow.h
index 093a2b3..ad876e5 100644
--- a/miext/rootless/rootlessWindow.h
+++ b/miext/rootless/rootlessWindow.h
@@ -36,6 +36,7 @@
 
 #include "rootlessCommon.h"
 
+#include <Xplugin.h>
 
 Bool RootlessCreateWindow(WindowPtr pWin);
 Bool RootlessDestroyWindow(WindowPtr pWin);
@@ -59,5 +60,7 @@ void RootlessPaintWindowBackground(WindowPtr pWin, RegionPtr pRegion,
 void RootlessPaintWindowBorder(WindowPtr pWin, RegionPtr pRegion,
                                int what);
 void RootlessChangeBorderWidth(WindowPtr pWin, unsigned int width);
+void RootlessNativeWindowMoved (WindowPtr pWin);
+void RootlessNativeWindowStateChanged (xp_window_id id, unsigned int state); 
 
 #endif
commit 41eabe5d4cc9c9ca91c34bca6c1550ffe3bacaa8
Author: Ben Byer <bbyer at bbyer.local>
Date:   Fri Nov 16 04:37:58 2007 -0800

    added a bunch of debugging code to help troubleshoot the stuck
    modifier key issue; much of it may be taken out later.
    Also, hopefully fixed a race condition that may have
    prevented ReleaseModifiers from working in some cases.

diff --git a/hw/darwin/darwinEvents.c b/hw/darwin/darwinEvents.c
index 03decd9..9d206d0 100644
--- a/hw/darwin/darwinEvents.c
+++ b/hw/darwin/darwinEvents.c
@@ -121,29 +121,131 @@ static void DarwinPressModifierMask(
 #define ALTERNATE_MASK(flags) (NX_ALTERNATEMASK)
 #endif /* NX_DEVICELALTKEYMASK */
 
+#define KEYBOARD_MASK (NX_COMMANDMASK | NX_CONTROLMASK | NX_ALTERNATEMASK | NX_SHIFTMASK | \
+                       NX_SECONDARYFNMASK | NX_ALPHASHIFTMASK | NX_NUMERICPADMASK | \
+                       NX_HELPMASK | NX_DEVICELCTLKEYMASK | NX_DEVICELSHIFTKEYMASK | \
+		       NX_DEVICERSHIFTKEYMASK | NX_DEVICELCMDKEYMASK | NX_DEVICERCMDKEYMASK | \
+		       NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK | NX_DEVICERCTLKEYMASK)
+                      
+char * decode_event_flags(unsigned int modifiers) {
+  char buf[1024];
+  buf[0]='\0';
+  if (modifiers & NX_DEVICELCTLKEYMASK)   strcat(buf, "NX_DEVICELCTLKEYMASK | ");
+  if (modifiers & NX_DEVICELSHIFTKEYMASK) strcat(buf, "NX_DEVICELSHIFTKEYMASK | ");
+  if (modifiers & NX_DEVICERSHIFTKEYMASK) strcat(buf, "NX_DEVICERSHIFTKEYMASK | ");
+  if (modifiers & NX_DEVICELCMDKEYMASK)   strcat(buf, "NX_DEVICELCMDKEYMASK | ");
+  if (modifiers & NX_DEVICERCMDKEYMASK)   strcat(buf, "NX_DEVICERCMDKEYMASK | ");
+  if (modifiers & NX_DEVICELALTKEYMASK)   strcat(buf, "NX_DEVICELALTKEYMASK | ");
+  if (modifiers & NX_DEVICERALTKEYMASK)   strcat(buf, "NX_DEVICERALTKEYMASK | ");
+  if (modifiers & NX_DEVICERCTLKEYMASK)   strcat(buf, "NX_DEVICERCTLKEYMASK | ");
+
+  if (modifiers & NX_ALPHASHIFTMASK)      strcat(buf, "NX_ALPHASHIFTMASK | ");
+  if (modifiers & NX_SHIFTMASK)           strcat(buf, "NX_SHIFTMASK | ");
+  if (modifiers & NX_CONTROLMASK)         strcat(buf, "NX_CONTROLMASK | ");
+  if (modifiers & NX_ALTERNATEMASK)       strcat(buf, "NX_ALTERNATEMASK | ");
+  if (modifiers & NX_COMMANDMASK)         strcat(buf, "NX_COMMANDMASK | ");
+  if (modifiers & NX_NUMERICPADMASK)      strcat(buf, "NX_NUMERICPADMASK | ");
+  if (modifiers & NX_HELPMASK)            strcat(buf, "NX_HELPMASK | ");
+  if (modifiers & NX_SECONDARYFNMASK)     strcat(buf, "NX_SECONDARYFNMASK | ");
+
+  if (modifiers & NX_STYLUSPROXIMITYMASK) strcat(buf, "NX_STYLUSPROXIMITYMASK | ");
+  if (modifiers & NX_NONCOALSESCEDMASK)   strcat(buf, "NX_NONCOALSESCEDMASK | ");
+  if (modifiers & NX_NULLEVENTMASK)       strcat(buf, "NX_NULLEVENTMASK | ");
+  //  if (modifiers & NX_LMOUSEDOWNMASK)      strcat(buf, "NX_LMOUSEDOWNMASK | ");
+  //  if (modifiers & NX_LMOUSEUPMASK)        strcat(buf, "NX_LMOUSEUPMASK | ");
+  //  if (modifiers & NX_RMOUSEDOWNMASK)      strcat(buf, "NX_RMOUSEDOWNMASK | ");
+  //  if (modifiers & NX_RMOUSEUPMASK)        strcat(buf, "NX_RMOUSEUPMASK | ");
+  //  if (modifiers & NX_OMOUSEDOWNMASK)      strcat(buf, "NX_OMOUSEDOWNMASK | ");
+  //  if (modifiers & NX_OMOUSEUPMASK)        strcat(buf, "NX_OMOUSEUPMASK | ");
+  //  if (modifiers & NX_MOUSEMOVEDMASK)      strcat(buf, "NX_MOUSEMOVEDMASK | ");
+  // if (modifiers & NX_LMOUSEDRAGGEDMASK)   strcat(buf, "NX_LMOUSEDRAGGEDMASK | ");
+  //if (modifiers & NX_RMOUSEDRAGGEDMASK)   strcat(buf, "NX_RMOUSEDRAGGEDMASK | ");
+  //if (modifiers & NX_OMOUSEDRAGGEDMASK)   strcat(buf, "NX_OMOUSEDRAGGEDMASK | ");
+  //if (modifiers & NX_MOUSEENTEREDMASK)    strcat(buf, "NX_MOUSEENTEREDMASK | ");
+  //if (modifiers & NX_MOUSEEXITEDMASK)     strcat(buf, "NX_MOUSEEXITEDMASK | ");
+  if (modifiers & NX_KEYDOWNMASK)         strcat(buf, "NX_KEYDOWNMASK | ");
+  if (modifiers & NX_KEYUPMASK)           strcat(buf, "NX_KEYUPMASK | ");
+  if (modifiers & NX_FLAGSCHANGEDMASK)    strcat(buf, "NX_FLAGSCHANGEDMASK | ");
+  if (modifiers & NX_KITDEFINEDMASK)      strcat(buf, "NX_KITDEFINEDMASK | ");
+  if (modifiers & NX_SYSDEFINEDMASK)      strcat(buf, "NX_SYSDEFINEDMASK | ");
+  if (modifiers & NX_APPDEFINEDMASK)      strcat(buf, "NX_APPDEFINEDMASK | ");
+  
+  if (strlen(buf) < 5) strcpy(buf, "(empty)");
+  else buf[strlen(buf)-3]='\0';
+  return strdup(buf);
+}
+
+char * get_keysym_name(int ks) {
+  switch(ks) {
+  case XK_Alt_L: return "XK_Alt_L";
+  case XK_Alt_R: return "XK_Alt_R";
+  case XK_Meta_L: return "XK_Meta_L";
+  case XK_Meta_R: return "XK_Meta_R";
+  case XK_Control_L: return "XK_Control_L";
+  case XK_Control_R: return "XK_Control_R";
+  case XK_Shift_L: return "XK_Shift_L";
+  case XK_Shift_R: return "XK_Shift_R";
+  case XK_Mode_switch: return "XK_Mode_switch";
+  case XK_Caps_Lock: return "XK_Caps_Lock";
+  }
+  return "???";
+}
+
+/*
+ * DarwinPressModifierMask
+ *  Press or release the given modifier key, specified by its mask.
+ */
+static void DarwinPressModifierMask(
+    xEvent *xe,     // must already have type, time and mouse location
+    int mask)       // one of NX_*MASK constants
+{
+  int key, keycode;
+  key = DarwinModifierNXMaskToNXKey(mask);
+  if (key == -1) {
+    ErrorF("DarwinPressModifierMask: can't find key for mask %x\n", mask);
+    return;
+  }
+  keycode = DarwinModifierNXKeyToNXKeycode(key, 0);    
+  if (keycode == 0) {
+    ErrorF("DarwinPressModifierMask: can't find keycode for mask %x\n", mask);
+    return;
+  }
+  
+  DEBUG_LOG("%x: %s %s\n", mask, xe->u.u.type==KeyPress?"pressing":"releasing",
+	    decode_event_flags(mask));
+  
+  xe->u.u.detail = keycode + MIN_KEYCODE;
+  (*darwinEventQueue.pKbd->processInputProc)(xe,
+           (DeviceIntPtr)darwinEventQueue.pKbd, 1);
+}
+
 /*
  * DarwinUpdateModifiers
  *  Send events to update the modifier state.
  */
 static void DarwinUpdateModifiers(
     int pressed,        // KeyPress or KeyRelease
-    int flags )         // modifier flags that have changed
+    unsigned int flags )         // modifier flags that have changed
 {
-    DEBUG_LOG("DarwinUpdateModifiers(%p, %d, %x)\n", xe, pressed, flags);
-    xe->u.u.type = pressed;
-    if (flags & NX_COMMANDMASK) DarwinPressModifierMask(xe, COMMAND_MASK(flags));
-    if (flags & NX_CONTROLMASK) DarwinPressModifierMask(xe, CONTROL_MASK(flags));
-    if (flags & NX_ALTERNATEMASK) DarwinPressModifierMask(xe, ALTERNATE_MASK(flags));
-    if (flags & NX_SHIFTMASK)  DarwinPressModifierMask(xe, SHIFT_MASK(flags));
-    if (flags & NX_SECONDARYFNMASK) DarwinPressModifierMask(xe, NX_SECONDARYFNMASK);
-    if (flags & NX_ALPHASHIFTMASK) {
-		// Alpha shift only sees KeyDown when enabled and KeyUp when disabled,
-		// but X11 wants to see a up/down pair to enable, and again to disable
-		xe->u.u.type = KeyPress;
-        DarwinPressModifierMask(xe, NX_ALPHASHIFTMASK);
-		xe->u.u.type = KeyRelease;
-        DarwinPressModifierMask(xe, NX_ALPHASHIFTMASK);
-    }
+  int i;
+  DEBUG_LOG("DarwinUpdateModifiers(%p, %d, %x, %s)\n", xe, pressed, flags, decode_event_flags(flags));
+  xe->u.u.type = pressed;
+  /* If we have "device specific" flags -- meaning, left or right -- then strip out the generic flag */
+  if (flags & (NX_DEVICELCTLKEYMASK | NX_DEVICERCTLKEYMASK)) flags &= ~NX_CONTROLMASK;
+  if (flags & (NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK)) flags &= ~NX_ALTERNATEMASK;
+  if (flags & (NX_DEVICELCMDKEYMASK | NX_DEVICERCMDKEYMASK)) flags &= ~NX_COMMANDMASK;
+  if (flags & (NX_DEVICELSHIFTKEYMASK | NX_DEVICERSHIFTKEYMASK)) flags &= ~NX_SHIFTMASK;
+  if (flags == NX_ALPHASHIFTMASK) {
+    // Alpha shift only sees KeyDown when enabled and KeyUp when disabled,
+    // but X11 wants to see a up/down pair to enable, and again to disable
+    xe->u.u.type = KeyPress;
+    DarwinPressModifierMask(xe, NX_ALPHASHIFTMASK);
+    xe->u.u.type = KeyRelease;
+    DarwinPressModifierMask(xe, NX_ALPHASHIFTMASK);
+    flags &= ~NX_ALPHASHIFTMASK;
+  }
+  for(i=0; i < (sizeof(flags)*8); i++) 
+    if (flags & (1 << i)) DarwinPressModifierMask(xe, flags & (1 << i));
 }
 
 /*
@@ -152,18 +254,16 @@ static void DarwinUpdateModifiers(
  * is deactivated (kXDarwinDeactivate) to prevent modifiers from getting stuck if they
  * are held down during a "context" switch -- otherwise, we would miss the KeyUp.
  */
-static void DarwinReleaseModifiers(void) {
+void DarwinReleaseModifiers(void) {
   KeySym *map = NULL;
   xEvent ke;
   int i = 0, j = 0, nevents = 0; 
  
-  DEBUG_LOG("DarwinReleaseModifiers(%p)\n", darwinKeyc);
-  if (!darwinKeyc) return;
-  map = darwinKeyc->curKeySyms.map;
+  DEBUG_LOG("DarwinReleaseModifiers(%p)\n", &keyInfo.keyMap);
   
-  for (i = darwinKeyc->curKeySyms.minKeyCode, map = darwinKeyc->curKeySyms.map;
-       i < darwinKeyc->curKeySyms.maxKeyCode;
-       i++, map += darwinKeyc->curKeySyms.mapWidth) {
+  for (i = MIN_KEYCODE, map =keyInfo.keyMap;
+       i < MAX_KEYCODE;
+       i++, map += GLYPHS_PER_KEY) {
     if (KeyPressed(i)) {
       switch (*map) {
 	/* Don't release the lock keys */
@@ -174,7 +274,7 @@ static void DarwinReleaseModifiers(void) {
       case XK_Kana_Lock:
 	break;
       default:
-	DEBUG_LOG("DarwinReleaseModifiers: releasing key %d\n", i);
+	DEBUG_LOG("DarwinReleaseModifiers: releasing key %d (%s)\n", i, get_keysym_name(*map));
 	  ke.u.keyButtonPointer.time = GetTimeInMillis();
 	  ke.u.keyButtonPointer.rootX = 0;
 	  ke.u.keyButtonPointer.rootY = 0;
diff --git a/hw/darwin/darwinKeyboard.c b/hw/darwin/darwinKeyboard.c
index ae842cd..2f537ca 100644
--- a/hw/darwin/darwinKeyboard.c
+++ b/hw/darwin/darwinKeyboard.c
@@ -217,10 +217,9 @@ static void DarwinChangeKeyboardControl( DeviceIntPtr device, KeybdCtrl *ctrl )
     // keyclick, bell volume / pitch, autorepead, LED's
 }
 
-static darwinKeyboardInfo keyInfo;
+darwinKeyboardInfo keyInfo;
 static FILE *fref = NULL;
 static char *inBuffer = NULL;
-KeyClassPtr darwinKeyc = NULL;
 
 //-----------------------------------------------------------------------------
 // Data Stream Object
@@ -817,7 +816,7 @@ void DarwinKeyboardInit(
     assert( darwinParamConnect = NXOpenEventStatus() );
 
     DarwinLoadKeyboardMapping(&keySyms);
-
+    //    DarwinKeyboardReload(pDev);
     /* Initialize the seed, so we don't reload the keymap unnecessarily
        (and possibly overwrite xinitrc changes) */
     DarwinModeSystemKeymapSeed();
@@ -836,7 +835,7 @@ InitModMap(register KeyClassPtr keyc)
     CARD8 keysPerModifier[8];
     CARD8 mask;
 
-    darwinKeyc = keyc;
+    //    darwinKeyc = keyc;
     if (keyc->modifierKeyMap != NULL)
         xfree (keyc->modifierKeyMap);
 
@@ -888,7 +887,7 @@ DarwinKeyboardReload(DeviceIntPtr pDev)
 
         memmove(pDev->key->modifierMap, keyInfo.modMap, MAP_LENGTH);
         InitModMap(pDev->key);
-    }
+    } else DEBUG_LOG("SetKeySymsMap=0\n");
 
     SendMappingNotify(MappingKeyboard, MIN_KEYCODE, NUM_KEYCODES, 0);
     SendMappingNotify(MappingModifier, 0, 0, 0);
@@ -938,6 +937,32 @@ int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide)
 }
 
 /*
+ * DarwinModifierNXMaskToNXKeyCode
+ *      Returns 0 if mask is not a known modifier mask.
+ */
+int DarwinModifierNXMaskToNXKeyCode(int mask)
+{
+  switch (mask) {
+  case NX_ALPHASHIFTMASK:       return XK_Caps_Lock;
+  case NX_SHIFTMASK: ErrorF("Warning: Received NX_SHIFTMASK, treating as NX_DEVICELSHIFTKEYMASK\n");
+  case NX_DEVICELSHIFTKEYMASK:  return NX_MODIFIERKEY_SHIFT; //XK_Shift_L;
+  case NX_DEVICERSHIFTKEYMASK:  return NX_MODIFIERKEY_RSHIFT; //XK_Shift_R;
+  case NX_CONTROLMASK: ErrorF("Warning: Received NX_CONTROLMASK, treating as NX_DEVICELCTLKEYMASK\n");
+  case NX_DEVICELCTLKEYMASK:    return XK_Control_L;
+  case NX_DEVICERCTLKEYMASK:    return XK_Control_R;
+  case NX_ALTERNATEMASK: ErrorF("Warning: Received NX_ALTERNATEMASK, treating as NX_DEVICELALTKEYMASK\n");
+  case NX_DEVICELALTKEYMASK:    return XK_Alt_L;
+  case NX_DEVICERALTKEYMASK:    return XK_Alt_R;
+  case NX_COMMANDMASK: ErrorF("Warning: Received NX_COMMANDMASK, treating as NX_DEVICELCMDKEYMASK\n");
+  case NX_DEVICELCMDKEYMASK:    return XK_Meta_L;
+  case NX_DEVICERCMDKEYMASK:    return XK_Meta_R;
+  case NX_NUMERICPADMASK:       return XK_Num_Lock;
+  case NX_HELPMASK:             return XK_Help;
+  case NX_SECONDARYFNMASK:      return XK_Control_L; // this seems very wrong, but is what the old code did
+    }
+}
+
+/*
  * DarwinModifierNXMaskToNXKey
  *      Returns -1 if mask is not a known modifier mask.
  */
@@ -972,6 +997,29 @@ int DarwinModifierNXMaskToNXKey(int mask)
     return -1;
 }
 
+char * DarwinModifierNXMaskTostring(int mask)
+{
+    switch (mask) {
+    case NX_ALPHASHIFTMASK: return "NX_ALPHASHIFTMASK";
+    case NX_SHIFTMASK: return "NX_SHIFTMASK";
+    case NX_DEVICELSHIFTKEYMASK: return "NX_DEVICELSHIFTKEYMASK";
+    case NX_DEVICERSHIFTKEYMASK: return "NX_DEVICERSHIFTKEYMASK";
+    case NX_CONTROLMASK: return "NX_CONTROLMASK";
+    case NX_DEVICELCTLKEYMASK: return "NX_DEVICELCTLKEYMASK";
+    case NX_DEVICERCTLKEYMASK: return "NX_DEVICERCTLKEYMASK";
+    case NX_ALTERNATEMASK: return "NX_ALTERNATEMASK";
+    case NX_DEVICELALTKEYMASK: return "NX_DEVICELALTKEYMASK";
+    case NX_DEVICERALTKEYMASK: return "NX_DEVICERALTKEYMASK";
+    case NX_COMMANDMASK: return "NX_COMMANDMASK";
+    case NX_DEVICELCMDKEYMASK: return "NX_DEVICELCMDKEYMASK";
+    case NX_DEVICERCMDKEYMASK: return "NX_DEVICERCMDKEYMASK";
+    case NX_NUMERICPADMASK: return "NX_NUMERICPADMASK";
+    case NX_HELPMASK: return "NX_HELPMASK";
+    case NX_SECONDARYFNMASK: return "NX_SECONDARYFNMASK";
+    }
+    return "unknown mask";
+}
+
 /*
  * DarwinModifierNXKeyToNXMask
  *      Returns 0 if key is not a known modifier key.
commit 6577916c444776d0fd6bafaca6be9d9e2addb101
Author: Ben Byer <bbyer at bbyer.local>
Date:   Thu Nov 15 02:41:07 2007 -0800

    a first stab at DEBUG_LOG

diff --git a/hw/darwin/apple/X11Controller.m b/hw/darwin/apple/X11Controller.m
index a6a75d0..df90049 100644
--- a/hw/darwin/apple/X11Controller.m
+++ b/hw/darwin/apple/X11Controller.m
@@ -54,8 +54,6 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 
-#define TRACE() fprintf (stderr, "%s\n", __FUNCTION__)
-
 @implementation X11Controller
 
 - (void) awakeFromNib
diff --git a/hw/darwin/darwin.c b/hw/darwin/darwin.c
index ada29c4..789b0e2 100644
--- a/hw/darwin/darwin.c
+++ b/hw/darwin/darwin.c
@@ -667,6 +667,7 @@ void OsVendorInit(void)
 	}
 #endif
     }
+    //    DEBUG_LOG("Xquartz started at %s\n", ctime(time(NULL)));
 
     // Find the full path to the keymapping file.
     if ( darwinKeymapFile ) {
diff --git a/hw/darwin/darwinEvents.c b/hw/darwin/darwinEvents.c
index f457902..03decd9 100644
--- a/hw/darwin/darwinEvents.c
+++ b/hw/darwin/darwinEvents.c
@@ -89,6 +89,7 @@ static void DarwinPressModifierMask(
 {
     int key = DarwinModifierNXMaskToNXKey(mask);
 
+    DEBUG_LOG("DarwinPressModifierMask(%p, %x, %d)\n", xe, mask, key);
     if (key != -1) {
         int keycode = DarwinModifierNXKeyToNXKeycode(key, 0);
         if (keycode != 0)
@@ -128,6 +129,7 @@ static void DarwinUpdateModifiers(
     int pressed,        // KeyPress or KeyRelease
     int flags )         // modifier flags that have changed
 {
+    DEBUG_LOG("DarwinUpdateModifiers(%p, %d, %x)\n", xe, pressed, flags);
     xe->u.u.type = pressed;
     if (flags & NX_COMMANDMASK) DarwinPressModifierMask(xe, COMMAND_MASK(flags));
     if (flags & NX_CONTROLMASK) DarwinPressModifierMask(xe, CONTROL_MASK(flags));
@@ -155,6 +157,7 @@ static void DarwinReleaseModifiers(void) {
   xEvent ke;
   int i = 0, j = 0, nevents = 0; 
  
+  DEBUG_LOG("DarwinReleaseModifiers(%p)\n", darwinKeyc);
   if (!darwinKeyc) return;
   map = darwinKeyc->curKeySyms.map;
   
@@ -171,6 +174,7 @@ static void DarwinReleaseModifiers(void) {
       case XK_Kana_Lock:
 	break;
       default:
+	DEBUG_LOG("DarwinReleaseModifiers: releasing key %d\n", i);
 	  ke.u.keyButtonPointer.time = GetTimeInMillis();
 	  ke.u.keyButtonPointer.rootX = 0;
 	  ke.u.keyButtonPointer.rootY = 0;
@@ -202,6 +206,7 @@ static void DarwinSimulateMouseClick(
     int whichButton,    // mouse button to be pressed
     int modifierMask)   // modifiers used for the fake click
 {
+  DEBUG_LOG("DarwinSimulateMouseClick(%p, %d, %x)\n", xe, whichButton, modifierMask);
     // first fool X into forgetting about the keys
 	// for some reason, it's not enough to tell X we released the Command key -- 
 	// it has to be the *left* Command key.
diff --git a/hw/darwin/quartz/quartz.c b/hw/darwin/quartz/quartz.c
index 7ba452c..fcd78ae 100644
--- a/hw/darwin/quartz/quartz.c
+++ b/hw/darwin/quartz/quartz.c
@@ -249,7 +249,7 @@ static void QuartzUpdateScreens(void)
     int x, y, width, height, sx, sy;
     xEvent e;
 
-    TRACE("QuartzUpdateScreens()\n");
+    DEBUG_LOG("QuartzUpdateScreens()\n");
     if (noPseudoramiXExtension || screenInfo.numScreens != 1)
     {
         /* FIXME: if not using Xinerama, we have multiple screens, and
@@ -414,7 +414,7 @@ void DarwinModeProcessEvent(
 {
     switch (xe->u.u.type) {
         case kXDarwinControllerNotify:
-	  TRACE("kXDarwinControllerNotify\n");
+	  DEBUG_LOG("kXDarwinControllerNotify\n");
             AppleWMSendEvent(AppleWMControllerNotify,
                              AppleWMControllerNotifyMask,
                              xe->u.clientMessage.u.l.longs0,
@@ -422,7 +422,7 @@ void DarwinModeProcessEvent(
             break;
 
         case kXDarwinPasteboardNotify:
-	  TRACE("kXDarwinPasteboardNotify\n");
+	  DEBUG_LOG("kXDarwinPasteboardNotify\n");
             AppleWMSendEvent(AppleWMPasteboardNotify,
                              AppleWMPasteboardNotifyMask,
                              xe->u.clientMessage.u.l.longs0,
@@ -430,7 +430,7 @@ void DarwinModeProcessEvent(
             break;
 
         case kXDarwinActivate:
-	  TRACE("kXDarwinActivate\n");
+	  DEBUG_LOG("kXDarwinActivate\n");
             QuartzShow(xe->u.keyButtonPointer.rootX,
                        xe->u.keyButtonPointer.rootY);
             AppleWMSendEvent(AppleWMActivationNotify,
@@ -439,7 +439,7 @@ void DarwinModeProcessEvent(
             break;
 
         case kXDarwinDeactivate:
-  	  TRACE("kXDarwinDeactivate\n");
+  	  DEBUG_LOG("kXDarwinDeactivate\n");
             AppleWMSendEvent(AppleWMActivationNotify,
                              AppleWMActivationNotifyMask,
                              AppleWMIsInactive, 0);
@@ -447,23 +447,23 @@ void DarwinModeProcessEvent(
             break;
 
         case kXDarwinDisplayChanged:
-	    TRACE("kXDarwinDisplayChanged\n");
+	    DEBUG_LOG("kXDarwinDisplayChanged\n");
             QuartzUpdateScreens();
             break;
 
         case kXDarwinWindowState:
-	  TRACE("kXDarwinWindowState\n");
+	  DEBUG_LOG("kXDarwinWindowState\n");
             RootlessNativeWindowStateChanged(xe->u.clientMessage.u.l.longs0,
 		  			     xe->u.clientMessage.u.l.longs1);
 	    break;
 	  
         case kXDarwinWindowMoved:
-	  TRACE("kXDarwinWindowMoved\n");
+	  DEBUG_LOG("kXDarwinWindowMoved\n");
             RootlessNativeWindowMoved (xe->u.clientMessage.u.l.longs0);
 	    break;
 
         case kXDarwinToggleFullscreen:
-	  TRACE("kXDarwinToggleFullscreen\n");
+	  DEBUG_LOG("kXDarwinToggleFullscreen\n");
 #ifdef DARWIN_DDX_MISSING
             if (quartzEnableRootless) QuartzSetFullscreen(!quartzHasRoot);
             else if (quartzHasRoot) QuartzHide();
@@ -499,7 +499,7 @@ void DarwinModeProcessEvent(
             break;
 
         case kXDarwinBringAllToFront:
-  	  TRACE("kXDarwinBringAllToFront\n");
+  	  DEBUG_LOG("kXDarwinBringAllToFront\n");
 	    RootlessOrderAllWindows();
             break;
 
diff --git a/hw/darwin/quartz/quartz.h b/hw/darwin/quartz/quartz.h
index febc51a..172f323 100644
--- a/hw/darwin/quartz/quartz.h
+++ b/hw/darwin/quartz/quartz.h
@@ -38,14 +38,6 @@
 #include "screenint.h"
 #include "window.h"
 
-//#define DEBUG 1
-
-#ifdef DEBUG
-#define TRACE(msg, args...) ErrorF("%s:%d: " msg, __FUNCTION__, __LINE__, ##args )
-#else
-#define TRACE(msg, args...) 
-#endif
-
 /*------------------------------------------
    Quartz display mode function types
   ------------------------------------------*/
commit 7696bcddd030c4a96757118e8f2be2878b13c5df
Author: Ben Byer <bbyer at bbyer.local>
Date:   Thu Nov 15 02:25:50 2007 -0800

    Added a lightweight debugging facility to support troubleshooting
    (for example) the stuck modifier key issue

diff --git a/hw/darwin/darwin.c b/hw/darwin/darwin.c
index f0c35f8..ada29c4 100644
--- a/hw/darwin/darwin.c
+++ b/hw/darwin/darwin.c
@@ -72,6 +72,10 @@
 #include "darwin.h"
 #include "darwinClut8.h"
 
+#ifdef ENABLE_DEBUG_LOG
+FILE *debug_log_fp = NULL;
+#endif
+
 /*
  * X server shared global variables
  */
@@ -648,6 +652,20 @@ void OsVendorInit(void)
 {
     if (serverGeneration == 1) {
         DarwinPrintBanner();
+#ifdef ENABLE_DEBUG_LOG
+	{
+	  char *home_dir=NULL, *log_file_path=NULL;
+	  home_dir = getenv("HOME");
+	  if (home_dir) asprintf(&log_file_path, "%s/%s", home_dir, DEBUG_LOG_NAME);
+	  if (log_file_path) {
+	    if (!access(log_file_path, F_OK)) {
+	      debug_log_fp = fopen(log_file_path, "a");
+	      if (debug_log_fp) ErrorF("Debug logging enabled to %s\n", log_file_path);
+	    }
+	    free(log_file_path);
+	  }
+	}
+#endif
     }
 
     // Find the full path to the keymapping file.
diff --git a/hw/darwin/darwin.h b/hw/darwin/darwin.h
index 51e1004..7e141fa 100644
--- a/hw/darwin/darwin.h
+++ b/hw/darwin/darwin.h
@@ -156,4 +156,14 @@ enum {
     kXDarwinWindowMoved       // window has moved on screen
 };
 
+#define ENABLE_DEBUG_LOG 1
+
+#ifdef ENABLE_DEBUG_LOG
+extern FILE *debug_log_fp;
+#define DEBUG_LOG_NAME "x11-debug.txt"
+#define DEBUG_LOG(msg, args...) if (debug_log_fp) fprintf(debug_log_fp, "%s:%d: " msg, __FUNCTION__, __LINE__, ##args )
+#else
+#define DEBUG_LOG(msg, args...) 
+#endif
+
 #endif  /* _DARWIN_H */
commit cad8133ccef5c9b0edc806cd4ae70ce6c3388f37
Author: Ben Byer <bbyer at bbyer.local>
Date:   Thu Nov 15 01:49:33 2007 -0800

    More XDarwin cleanup / dead code removal from Jeremy

diff --git a/configure.ac b/configure.ac
index 7f3ce25..e40bf65 100644
--- a/configure.ac
+++ b/configure.ac
@@ -95,11 +95,6 @@ AC_HEADER_DIRENT
 AC_HEADER_STDC
 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h])
 
-AC_CHECK_PROG(HAVE_LAUNCHD, [launchd], [yes], [])
-if test "x$HAVE_LAUNCHD" = xyes; then
-	AC_DEFINE(HAS_LAUNCHD, 1, [launchd support available])
-fi
-
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
 AC_C_BIGENDIAN([ENDIAN="X_BIG_ENDIAN"], [ENDIAN="X_LITTLE_ENDIAN"])
@@ -455,8 +450,11 @@ AC_ARG_WITH(serverconfig-path, AS_HELP_STRING([--with-serverconfig-path=PATH], [
 				[ SERVERCONFIG="${libdir}/xserver" ])
 APPLE_APPLICATIONS_DIR="/Applications/Utilities"
 AC_ARG_WITH(apple-applications-dir,AS_HELP_STRING([--with-apple-applications-dir=PATH], [Path to the Applications directory (default: /Applications/Utilities)]),
-                               [ APPLE_APPLICATIONS_DIR="${withval}" ].
-                               [ APPLE_APPLICATIONS_DIR="/Applications/Utilities" ])
+				[ APPLE_APPLICATIONS_DIR="${withval}" ].
+				[ APPLE_APPLICATIONS_DIR="/Applications/Utilities" ])
+
+AC_ARG_WITH(launchd,          AS_HELP_STRING([--with-launchd], [Build with support for Apple's launchd (default: auto)]), [LAUNCHD=$withval], [LAUNCHD=auto])
+
 AC_ARG_ENABLE(builddocs,      AS_HELP_STRING([--enable-builddocs], [Build docs (default: disabled)]),
                                 [BUILDDOCS=$enableval],
                                 [BUILDDOCS=no])
@@ -1710,7 +1708,7 @@ if test "X$XQUARTZ" = Xauto; then
 		LDFLAGS=$save_LDFLAGS])
                 
 	if test "X$xorg_cv_Carbon_framework" = Xyes; then
-		AC_DEFINE([DARWIN_WITH_QUARTZ],[1],[Have Quartz])
+		AC_DEFINE([XQUARTZ],[1],[Have Quartz])
 		XQUARTZ=yes
 	else
 		XQUARTZ=no
@@ -1746,7 +1744,7 @@ if test "x$XQUARTZ" = xyes; then
 	       AC_SUBST([DARWIN_LIBS])
                AC_CHECK_LIB([Xplugin],[xp_init],[:])
                AC_SUBST([APPLE_APPLICATIONS_DIR])
-               CFLAGS="${CFLAGS} -DHAVE_LAUNCHD -D__DARWIN__ -DDARWIN_WITH_QUARTZ -DROOTLESS_WORKAROUND"
+               CFLAGS="${CFLAGS} -D__DARWIN__ -DROOTLESS_WORKAROUND"
                PLIST_VERSION_STRING=$PACKAGE_VERSION
                AC_SUBST([PLIST_VERSION_STRING])
                PLIST_VENDOR_WEB=$VENDOR_WEB
@@ -1768,6 +1766,23 @@ if test "x$XQUARTZ" = xyes; then
                        DGA=no
                fi
 fi
+
+if test "x$LAUNCHD" = xauto; then
+	# Do we want to have this default to on for Xquartz builds only or any time we have launchd (like Xnest or Xvfb on OS-X)
+	#AC_CHECK_PROG(LAUNCHD, [launchd], [yes], [no])
+	AC_MSG_CHECKING([whether to support launchd])
+	if test "x$XQUARTZ" = xyes ; then
+		LAUNCHD=yes
+	else
+		LAUNCHD=no
+	fi
+	AC_MSG_RESULT([$LAUNCHD])
+fi
+
+if test "x$LAUNCHD" = xyes ; then
+	AC_DEFINE(HAVE_LAUNCHD, 1, [launchd support available])
+fi
+
 # Support for objc in autotools is minimal and not documented.
 OBJC='$(CC)'
 OBJCLD='$(CCLD)'
@@ -2124,17 +2139,6 @@ hw/xgl/glxext/module/Makefile
 hw/xnest/Makefile
 hw/xwin/Makefile
 hw/darwin/Makefile
-hw/darwin/bundle/Makefile
-hw/darwin/bundle/Dutch.lproj/Makefile
-hw/darwin/bundle/English.lproj/Makefile
-hw/darwin/bundle/French.lproj/Makefile
-hw/darwin/bundle/German.lproj/Makefile
-hw/darwin/bundle/Japanese.lproj/Makefile
-hw/darwin/bundle/Portuguese.lproj/Makefile
-hw/darwin/bundle/Spanish.lproj/Makefile
-hw/darwin/bundle/Swedish.lproj/Makefile
-hw/darwin/bundle/ko.lproj/Makefile
-hw/darwin/iokit/Makefile
 hw/darwin/quartz/Makefile
 hw/darwin/quartz/cr/Makefile
 hw/darwin/quartz/fullscreen/Makefile
diff --git a/dix/main.c b/dix/main.c
index 80d8900..c322b0d 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -256,10 +256,15 @@ main(int argc, char *argv[], char *envp[])
     PrinterInitGlobals();
 #endif
 
+#ifdef XQUARTZ
     /* Quartz support on Mac OS X requires that the Cocoa event loop be in
      * the main thread. This allows the X server main to be called again
      * from another thread. */
-#ifdef DARWIN_WITH_QUARTZ
+
+    /* TODO: Put some runtime conditioning on this, so it doesn't get
+     * executed by Xvfb, Xnest, Xfake, Xephyr, etc when built at the same
+     * time as Xquartz
+     */
     DarwinHandleGUI(argc, argv, envp);
 #endif
 
diff --git a/hw/darwin/Makefile.am b/hw/darwin/Makefile.am
index e83f04d..e23a3d1 100644
--- a/hw/darwin/Makefile.am
+++ b/hw/darwin/Makefile.am
@@ -1,5 +1,5 @@
 AM_CFLAGS = @XORG_CFLAGS@
-AM_CPPFLAGS = @XORG_INCS@ -I../../miext/rootless -DUSE_NEW_CLUT -DBUILD_DATE=\"$(BUILD_DATE)\" -DHAVE_XORG_CONFIG_H -DXFree86Server
+AM_CPPFLAGS = @XORG_INCS@ -I../../miext/rootless -DUSE_NEW_CLUT -DBUILD_DATE=\"$(BUILD_DATE)\" -DHAVE_XORG_CONFIG_H -DXFree86Server -DINXQUARTZ
   
 SUBDIRS = quartz utils
   
diff --git a/hw/darwin/darwin.c b/hw/darwin/darwin.c
index 52fd170..f0c35f8 100644
--- a/hw/darwin/darwin.c
+++ b/hw/darwin/darwin.c
@@ -836,14 +836,11 @@ void ddxUseMsg( void )
     ErrorF("-keymap <file> : read the keymapping from a file instead of the kernel.\n");
     ErrorF("-version : show the server version.\n");
     ErrorF("\n");
-#ifdef DARWIN_WITH_QUARTZ
-    ErrorF("Quartz modes:\n");
+    ErrorF("Quartz modes (Experimental / In Development):\n");
     ErrorF("-fullscreen : run full screen in parallel with Mac OS X window server.\n");
     ErrorF("-rootless : run rootless inside Mac OS X window server.\n");
-    ErrorF("-quartz : use default Mac OS X window server mode\n");
     ErrorF("\n");
     ErrorF("Options ignored in rootless mode:\n");
-#endif
     ErrorF("-size <height> <width> : use a screen resolution of <height> x <width>.\n");
     ErrorF("-depth <8,15,24> : use this bit depth.\n");
     ErrorF("-refresh <rate> : use a monitor refresh rate of <rate> Hz.\n");
diff --git a/hw/darwin/quartz/Makefile.am b/hw/darwin/quartz/Makefile.am
index 5a78bfb..26bc8eb 100644
--- a/hw/darwin/quartz/Makefile.am
+++ b/hw/darwin/quartz/Makefile.am
@@ -2,7 +2,7 @@ noinst_LIBRARIES = libXQuartz.a
 
 AM_CFLAGS = @XORG_CFLAGS@
 AM_OBJCFLAGS = @XORG_CFLAGS@
-AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/.. @XORG_INCS@ -DXBINDIR=\"${bindir}\" -DINXQUARTZ -DHAS_KL_API -DHAVE_XORG_CONFIG_H
+AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/.. @XORG_INCS@ -DXBINDIR=\"${bindir}\" -DHAS_KL_API -DHAVE_XORG_CONFIG_H
 
 SUBDIRS = cr fullscreen xpr
 
diff --git a/hw/darwin/quartz/applewm.c b/hw/darwin/quartz/applewm.c
index f064dba..009eb87 100644
--- a/hw/darwin/quartz/applewm.c
+++ b/hw/darwin/quartz/applewm.c
@@ -445,11 +445,7 @@ ProcAppleWMSetWindowMenu(
                 break;
         }
     }
-#ifdef INXQUARTZ
     X11ApplicationSetWindowMenu (nitems, items, shortcuts);
-#else
-    QuartzSetWindowMenu (nitems, items, shortcuts);
-#endif
     free(items);
     free(shortcuts);
 
@@ -464,12 +460,7 @@ ProcAppleWMSetWindowMenuCheck(
     REQUEST(xAppleWMSetWindowMenuCheckReq);
 
     REQUEST_SIZE_MATCH(xAppleWMSetWindowMenuCheckReq);
-#ifdef INXQUARTZ
     X11ApplicationSetWindowMenuCheck (stuff->index);
-#else
-    QuartzMessageMainThread(kQuartzSetWindowMenuCheck, &stuff->index,
-                            sizeof(stuff->index));
-#endif
     return (client->noClientException);
 }
 
@@ -480,11 +471,7 @@ ProcAppleWMSetFrontProcess(
 {
     REQUEST_SIZE_MATCH(xAppleWMSetFrontProcessReq);
 
-#ifdef INXQUARTZ
     X11ApplicationSetFrontProcess();
-#else
-    QuartzMessageMainThread(kQuartzSetFrontProcess, NULL, 0);
-#endif
     return (client->noClientException);
 }
 
@@ -524,12 +511,7 @@ ProcAppleWMSetCanQuit(
 
     REQUEST_SIZE_MATCH(xAppleWMSetCanQuitReq);
 
-#ifdef INXQUARTZ
     X11ApplicationSetCanQuit(stuff->state);
-#else
-    QuartzMessageMainThread(kQuartzSetCanQuit, &stuff->state,
-                            sizeof(stuff->state));
-#endif
     return (client->noClientException);
 }
 
diff --git a/hw/darwin/quartz/quartz.c b/hw/darwin/quartz/quartz.c
index c0666e6..7ba452c 100644
--- a/hw/darwin/quartz/quartz.c
+++ b/hw/darwin/quartz/quartz.c
@@ -185,12 +185,8 @@ void DarwinModeInitInput(
     int argc,
     char **argv )
 {
-#ifdef INXQUARTZ
     X11ApplicationSetCanQuit(1);
     X11ApplicationServerReady();
-#else
-    QuartzMessageMainThread(kQuartzServerStarted, NULL, 0);
-#endif
     // Do final display mode specific initialization before handling events
     if (quartzProcs->InitInput)
         quartzProcs->InitInput(argc, argv);
@@ -354,9 +350,6 @@ static void QuartzHide(void)
         }
     }
     quartzServerVisible = FALSE;
-#ifndef INXQUARTZ
-    QuartzMessageMainThread(kQuartzServerHidden, NULL, 0);
-#endif
 }
 
 
diff --git a/hw/darwin/quartz/quartzCocoa.m b/hw/darwin/quartz/quartzCocoa.m
index 2e7b86b..c5e6e5c 100644
--- a/hw/darwin/quartz/quartzCocoa.m
+++ b/hw/darwin/quartz/quartzCocoa.m
@@ -45,63 +45,12 @@
 
 #include <Cocoa/Cocoa.h>
 
-#ifndef INXQUARTZ
-#import "Preferences.h"
-#endif
 #include "pseudoramiX.h"
 
 extern void FatalError(const char *, ...);
 extern char *display;
 extern int noPanoramiXExtension;
 
-#ifndef INXQUARTZ
-/*
- * QuartzReadPreferences
- *  Read the user preferences from the Cocoa front end.
- */
-void QuartzReadPreferences(void)
-{
-    char *fileString;
-
-    darwinFakeButtons = [Preferences fakeButtons];
-    darwinFakeMouse2Mask = [Preferences button2Mask];
-    darwinFakeMouse3Mask = [Preferences button3Mask];
-    darwinMouseAccelChange = [Preferences mouseAccelChange];
-    quartzUseSysBeep = [Preferences systemBeep];
-    quartzEnableKeyEquivalents = [Preferences enableKeyEquivalents];
-
-    // quartzRootless has already been set
-    if (quartzRootless) {
-        // Use PseudoramiX instead of Xinerama
-        noPanoramiXExtension = TRUE;
-        noPseudoramiXExtension = ![Preferences xinerama];
-
-        quartzUseAGL = [Preferences useAGL];
-    } else {
-        noPanoramiXExtension = ![Preferences xinerama];
-        noPseudoramiXExtension = TRUE;
-
-        // Full screen can't use AGL for GLX
-        quartzUseAGL = FALSE;
-    }
-
-    if ([Preferences useKeymapFile]) {
-        fileString = (char *) [[Preferences keymapFile] lossyCString];
-        darwinKeymapFile = (char *) malloc(strlen(fileString)+1);
-        if (! darwinKeymapFile)
-            FatalError("malloc failed in QuartzReadPreferences()!\n");
-        strcpy(darwinKeymapFile, fileString);
-    }
-
-    display = (char *) malloc(8);
-    if (! display)
-        FatalError("malloc failed in QuartzReadPreferences()!\n");
-    snprintf(display, 8, "%i", [Preferences display]);
-
-    darwinDesiredDepth = [Preferences depth] - 1;
-}
-#endif
-
 /*
  * QuartzWriteCocoaPasteboard
  *  Write text to the Mac OS X pasteboard.
@@ -165,19 +114,6 @@ char *QuartzReadCocoaPasteboard(void)
 int QuartzFSUseQDCursor(
     int depth)  // screen depth
 {
-#ifndef INXQUARTZ
-    switch ([Preferences useQDCursor]) {
-        case qdCursor_Always:
-            return TRUE;
-        case qdCursor_Never:
-            return FALSE;
-        case qdCursor_Not8Bit:
-            if (depth > 8)
-                return TRUE;
-            else
-                return FALSE;
-    }
-#endif
     return TRUE;
 }
 
diff --git a/hw/darwin/quartz/quartzStartup.c b/hw/darwin/quartz/quartzStartup.c
index 1a040ff..73a9f1a 100644
--- a/hw/darwin/quartz/quartzStartup.c
+++ b/hw/darwin/quartz/quartzStartup.c
@@ -40,19 +40,6 @@ char **envpGlobal;      // argcGlobal and argvGlobal
                         // are from dix/globals.c
 
 
-#ifndef INXQUARTZ
-int NSApplicationMain(int argc, char *argv[]);
-
-// GLX bundle function pointers
-void * __DarwinglXMesaProvider = NULL;
-typedef void (*GlxPushProviderPtr)(void *);
-GlxPushProviderPtr GlxPushProvider = NULL;
-typedef void (*GlxExtensionInitPtr)(void); 
-typedef void (*GlxWrapInitVisualsPtr)(miInitVisualsProcPtr *);
-typedef Bool (*QuartzModeBundleInitPtr)(void);
-static GlxExtensionInitPtr GlxExtensionInit = NULL;
-static GlxWrapInitVisualsPtr GlxWrapInitVisuals = NULL;
-#else
 void X11ControllerMain(int argc, char *argv[],
 		       void (*server_thread) (void *), void *server_arg);
 void GlxExtensionInit(void);
@@ -63,7 +50,6 @@ static void server_thread (void *arg) {
   
   exit (main (argcGlobal, argvGlobal, envpGlobal));
 }
-#endif
 
 /*
  * DarwinHandleGUI
@@ -83,9 +69,6 @@ void DarwinHandleGUI(
     int         fd[2];
 
     if (been_here) {
-#ifndef INXQUARTZ      
-        QuartzReadPreferences();
-#endif
         return;
     }
     been_here = TRUE;
@@ -120,14 +103,10 @@ void DarwinHandleGUI(
         }
     }
 
-#ifndef INXQUARTZ
-    main_exit = NSApplicationMain(argc, argv);
-#else
     extern void _InitHLTB(void);
     
     _InitHLTB();
     X11ControllerMain(argc, argv, server_thread, NULL);
-#endif
     exit(main_exit);
 }
 
@@ -138,54 +117,6 @@ void DarwinHandleGUI(
 Bool QuartzLoadDisplayBundle(
     const char *dpyBundleName)
 {
-#ifndef INXQUARTZ
-    CFBundleRef mainBundle;
-    CFStringRef bundleName;
-    CFURLRef    bundleURL;
-    CFBundleRef dpyBundle;
-    QuartzModeBundleInitPtr bundleInit;
-
-    // Get the main bundle for the application
-    mainBundle = CFBundleGetMainBundle();
-
-    // Make CFString from bundle name
-    bundleName = CFStringCreateWithCStringNoCopy(kCFAllocatorDefault,
-                                                 dpyBundleName,
-                                                 kCFStringEncodingASCII,
-                                                 kCFAllocatorNull);
-
-    // Look for the appropriate bundle in the main bundle
-    bundleURL = CFBundleCopyResourceURL(mainBundle, bundleName,
-                                        NULL, NULL);
-    if (!bundleURL) {
-        ErrorF("Could not find display mode bundle %s.\n", dpyBundleName);
-        return FALSE;
-    }
-
-    // Make a bundle instance using the URLRef
-    dpyBundle = CFBundleCreate(kCFAllocatorDefault, bundleURL);
-
-    if (!CFBundleLoadExecutable(dpyBundle)) {
-        ErrorF("Could not load display mode bundle %s.\n", dpyBundleName);
-        return FALSE;
-    }
-
-    // Lookup the bundle initialization function
-    bundleInit = (void *)
-            CFBundleGetFunctionPointerForName(dpyBundle,
-                                              CFSTR("QuartzModeBundleInit"));
-    if (!bundleInit) {
-        ErrorF("Could not initialize display mode bundle %s.\n",
-               dpyBundleName);
-        return FALSE;
-    }
-    if (!bundleInit())
-        return FALSE;
-
-    // Release the CF objects
-    CFRelease(bundleName);
-    CFRelease(bundleURL);
-#endif
     return TRUE;
 }
 
@@ -234,20 +165,6 @@ static void LoadGlxBundle(void)
     }
 
     // Find the GLX init functions
-
-#ifndef INXQUARTZ
-    __DarwinglXMesaProvider = (void *) CFBundleGetDataPointerForName(
-			       glxBundle, CFSTR("__glXMesaProvider"));
-
-    GlxPushProvider = (void *) CFBundleGetFunctionPointerForName(
-                                glxBundle, CFSTR("GlxPushProvider"));
-
-    GlxExtensionInit = (void *) CFBundleGetFunctionPointerForName(
-                                glxBundle, CFSTR("GlxExtensionInit"));
-
-    GlxWrapInitVisuals = (void *) CFBundleGetFunctionPointerForName(
-                                glxBundle, CFSTR("GlxWrapInitVisuals"));
-#endif
     if (!GlxExtensionInit || !GlxWrapInitVisuals) {
         FatalError("Could not initialize GLX bundle.");
     }
@@ -270,10 +187,6 @@ Bool QuartzLoadDisplayBundle(const char *dpyBundleName)
  */
 void DarwinGlxPushProvider(void *impl)
 {
-#ifndef INXQUARTZ
-    if (!GlxExtensionInit)
-        LoadGlxBundle();
-#endif
     GlxPushProvider(impl);
 }
 
@@ -283,10 +196,6 @@ void DarwinGlxPushProvider(void *impl)
  */
 void DarwinGlxExtensionInit(void)
 {
-#ifndef INXQUARTZ
-    if (!GlxExtensionInit)
-        LoadGlxBundle();
-#endif
     GlxExtensionInit();
 }
 
@@ -297,10 +206,8 @@ void DarwinGlxExtensionInit(void)
 void DarwinGlxWrapInitVisuals(
     miInitVisualsProcPtr *procPtr)
 {
-#ifdef INXQUARTZ
     if (!GlxWrapInitVisuals)
         LoadGlxBundle();
-#endif
     GlxWrapInitVisuals(procPtr);
 }
 #endif
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index 837a5d5..819ba02 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -145,6 +145,9 @@
 /* Define to 1 if launchd is available. */
 #undef HAVE_LAUNCHD
 
+/* Have Quartz */
+#undef XQUARTZ
+
 /* Define to 1 if you have the `m' library (-lm). */
 #undef HAVE_LIBM
 
commit 5320f4fab0833b3bafb3c9b6e56c25638364b3cb
Author: Ben Byer <bbyer at bbyer.local>
Date:   Thu Nov 15 00:56:54 2007 -0800

    Patch to avert (some) damage / rootless crashes, courtesy of Ken Thomases

diff --git a/miext/rootless/rootless.h b/miext/rootless/rootless.h
index b4a5b2a..5224dca 100644
--- a/miext/rootless/rootless.h
+++ b/miext/rootless/rootless.h
@@ -66,7 +66,6 @@ typedef struct _RootlessWindowRec {
     int bytesPerRow;
 
     PixmapPtr pixmap;
-    PixmapPtr oldPixmap;
 
 #ifdef ROOTLESS_TRACK_DAMAGE
     RegionRec damage;
diff --git a/miext/rootless/rootlessCommon.c b/miext/rootless/rootlessCommon.c
index 03842e4..562f655 100644
--- a/miext/rootless/rootlessCommon.c
+++ b/miext/rootless/rootlessCommon.c
@@ -172,8 +172,24 @@ void RootlessStartDrawing(WindowPtr pWindow)
         winRec->is_drawing = TRUE;
     }
 
-    winRec->oldPixmap = pScreen->GetWindowPixmap(pWindow);
-    pScreen->SetWindowPixmap(pWindow, winRec->pixmap);
+    PixmapPtr curPixmap = pScreen->GetWindowPixmap(pWindow);
+    if (curPixmap == winRec->pixmap)
+    {
+        RL_DEBUG_MSG("Window %p already has winRec->pixmap %p; not pushing\n", pWindow, winRec->pixmap);
+    }
+    else
+    {
+        PixmapPtr oldPixmap = pWindow->devPrivates[rootlessWindowOldPixmapPrivateIndex].ptr;
+        if (oldPixmap != NULL)
+        {
+            if (oldPixmap == curPixmap)
+                RL_DEBUG_MSG("Window %p's curPixmap %p is the same as its oldPixmap; strange\n", pWindow, curPixmap);
+            else
+                RL_DEBUG_MSG("Window %p's existing oldPixmap %p being lost!\n", pWindow, oldPixmap);
+        }
+        pWindow->devPrivates[rootlessWindowOldPixmapPrivateIndex].ptr = curPixmap;
+        pScreen->SetWindowPixmap(pWindow, winRec->pixmap);
+    }
 }
 
 
@@ -182,6 +198,29 @@ void RootlessStartDrawing(WindowPtr pWindow)
  *  Stop drawing to a window's backing buffer. If flush is true,
  *  damaged regions are flushed to the screen.
  */
+static int RestorePreDrawingPixmapVisitor(WindowPtr pWindow, pointer data)
+{
+    RootlessWindowRec *winRec = (RootlessWindowRec*)data;
+    ScreenPtr pScreen = pWindow->drawable.pScreen;
+    PixmapPtr exPixmap = pScreen->GetWindowPixmap(pWindow);
+    PixmapPtr oldPixmap = pWindow->devPrivates[rootlessWindowOldPixmapPrivateIndex].ptr;
+    if (oldPixmap == NULL)
+    {
+        if (exPixmap == winRec->pixmap)
+            RL_DEBUG_MSG("Window %p appears to be in drawing mode (ex-pixmap %p equals winRec->pixmap, which is being freed) but has no oldPixmap!\n", pWindow, exPixmap);
+    }
+    else
+    {
+        if (exPixmap != winRec->pixmap)
+            RL_DEBUG_MSG("Window %p appears to be in drawing mode (oldPixmap %p) but ex-pixmap %p not winRec->pixmap %p!\n", pWindow, oldPixmap, exPixmap, winRec->pixmap);
+        if (oldPixmap == winRec->pixmap)
+            RL_DEBUG_MSG("Window %p's oldPixmap %p is winRec->pixmap, which has just been freed!\n", pWindow, oldPixmap);
+        pScreen->SetWindowPixmap(pWindow, oldPixmap);
+        pWindow->devPrivates[rootlessWindowOldPixmapPrivateIndex].ptr = NULL;
+    }
+    return WT_WALKCHILDREN;
+}
+
 void RootlessStopDrawing(WindowPtr pWindow, Bool flush)
 {
     ScreenPtr pScreen = pWindow->drawable.pScreen;
@@ -198,7 +237,7 @@ void RootlessStopDrawing(WindowPtr pWindow, Bool flush)
         SCREENREC(pScreen)->imp->StopDrawing(winRec->wid, flush);
 
         FreeScratchPixmapHeader(winRec->pixmap);
-        pScreen->SetWindowPixmap(pWindow, winRec->oldPixmap);
+        TraverseTree(top, RestorePreDrawingPixmapVisitor, (pointer)winRec);
         winRec->pixmap = NULL;
 
         winRec->is_drawing = FALSE;
diff --git a/miext/rootless/rootlessCommon.h b/miext/rootless/rootlessCommon.h
index b002214..d3f242e 100644
--- a/miext/rootless/rootlessCommon.h
+++ b/miext/rootless/rootlessCommon.h
@@ -56,6 +56,7 @@
 extern int rootlessGCPrivateIndex;
 extern int rootlessScreenPrivateIndex;
 extern int rootlessWindowPrivateIndex;
+extern int rootlessWindowOldPixmapPrivateIndex;
 
 
 // RootlessGCRec: private per-gc data
diff --git a/miext/rootless/rootlessScreen.c b/miext/rootless/rootlessScreen.c
index b314581..4af395e 100644
--- a/miext/rootless/rootlessScreen.c
+++ b/miext/rootless/rootlessScreen.c
@@ -65,6 +65,7 @@ extern Bool RootlessCreateGC(GCPtr pGC);
 int rootlessGCPrivateIndex = -1;
 int rootlessScreenPrivateIndex = -1;
 int rootlessWindowPrivateIndex = -1;
+int rootlessWindowOldPixmapPrivateIndex = -1;
 
 
 /*
@@ -618,6 +619,8 @@ RootlessAllocatePrivates(ScreenPtr pScreen)
         if (rootlessGCPrivateIndex == -1) return FALSE;
         rootlessWindowPrivateIndex = AllocateWindowPrivateIndex();
         if (rootlessWindowPrivateIndex == -1) return FALSE;
+        rootlessWindowOldPixmapPrivateIndex = AllocateWindowPrivateIndex();
+        if (rootlessWindowOldPixmapPrivateIndex == -1) return FALSE;
         rootlessGeneration = serverGeneration;
     }
 
@@ -627,6 +630,8 @@ RootlessAllocatePrivates(ScreenPtr pScreen)
         return FALSE;
     if (!AllocateWindowPrivate(pScreen, rootlessWindowPrivateIndex, 0))
         return FALSE;
+    if (!AllocateWindowPrivate(pScreen, rootlessWindowOldPixmapPrivateIndex, 0))
+        return FALSE;
 
     s = xalloc(sizeof(RootlessScreenRec));
     if (! s) return FALSE;
diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index cf32426..82f54d6 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -198,6 +198,7 @@ RootlessCreateWindow(WindowPtr pWin)
     RegionRec saveRoot;
 
     WINREC(pWin) = NULL;
+    pWin->devPrivates[rootlessWindowOldPixmapPrivateIndex].ptr = NULL;
 
     SCREEN_UNWRAP(pWin->drawable.pScreen, CreateWindow);
 
commit da6cfcb89b2cc1a7740f7a4e697ccceb029cf6c4
Author: Ben Byer <bbyer at bbyer.local>
Date:   Wed Nov 14 21:25:50 2007 -0800

    Build system patches to remove XDarwin from the build (since it doesn't
    work anyway), courtesy of Jeremy Huddleston

diff --git a/configure.ac b/configure.ac
index e06c8e3..7f3ce25 100644
--- a/configure.ac
+++ b/configure.ac
@@ -525,9 +525,8 @@ AC_ARG_ENABLE(xorg,    	      AS_HELP_STRING([--enable-xorg], [Build Xorg server
 AC_ARG_ENABLE(dmx,    	      AS_HELP_STRING([--enable-dmx], [Build DMX server (default: no)]), [DMX=$enableval], [DMX=no])
 AC_ARG_ENABLE(xvfb,    	      AS_HELP_STRING([--enable-xvfb], [Build Xvfb server (default: no)]), [XVFB=$enableval], [XVFB=no])
 AC_ARG_ENABLE(xnest,   	      AS_HELP_STRING([--enable-xnest], [Build Xnest server (default: no)]), [XNEST=$enableval], [XNEST=no])
-AC_ARG_ENABLE(xdarwin, 	      AS_HELP_STRING([--enable-xdarwin], [Build XDarwin server (default: auto)]), [XDARWIN=$enableval], [XDARWIN=auto])
-AC_ARG_ENABLE(xquartz,        AS_HELP_STRING([--disable-xquartz], [Build Xquartz server on Darwin (default: auto)]), [XQUARTZ=$enableval], [XQUARTZ=auto])
-AC_ARG_ENABLE(x11app,         AS_HELP_STRING([--enable-x11app], [Build Apple's X11.app wrapper for Xquartz (default: auto)]), [X11APP=$enableval], [X11APP=auto])
+AC_ARG_ENABLE(xquartz,        AS_HELP_STRING([--enable-xquartz], [Build Xquartz server for OS-X (default: auto)]), [XQUARTZ=$enableval], [XQUARTZ=auto])
+AC_ARG_ENABLE(x11app,         AS_HELP_STRING([--enable-x11app], [Build Apple's X11.app for Xquartz (default: auto)]), [X11APP=$enableval], [X11APP=auto])
 AC_ARG_ENABLE(xwin,    	      AS_HELP_STRING([--enable-xwin], [Build XWin server (default: auto)]), [XWIN=$enableval], [XWIN=auto])
 AC_ARG_ENABLE(xprint,         AS_HELP_STRING([--enable-xprint], [Build Xprint extension and server (default: no)]), [XPRINT=$enableval], [XPRINT=no])
 AC_ARG_ENABLE(xgl,            AS_HELP_STRING([--enable-xgl], [Build Xgl server (default: no)]), [XGL=$enableval], [XGL=no])
@@ -1701,33 +1700,24 @@ AM_CONDITIONAL(XWIN_RANDR, [test "x$XWIN" = xyes])
 AM_CONDITIONAL(XWIN_XV, [test "x$XWIN" = xyes && test "x$XV" = xyes])
 
 dnl Darwin / OS X DDX
-AC_MSG_CHECKING([whether to build XDarwin/Xquartz])
-if test "x$XDARWIN" = xauto; then
-	case $host_os in
-		darwin*) XDARWIN="yes" ;;
-		*) XDARWIN="no" ;;
-	esac
-fi
-AC_MSG_RESULT([$XDARWIN])
-
-if test "x$XDARWIN" = xyes; then
-	if test "X$XQUARTZ" = Xauto; then
-		AC_CACHE_CHECK([whether to build Xquartz],xorg_cv_Carbon_framework,[
-		 	save_LDFLAGS=$LDFLAGS
-			LDFLAGS="$LDFLAGS -framework Carbon"
-			AC_LINK_IFELSE([char FSFindFolder(); int main() { FSFindFolder(); return 0;}],
-				[xorg_cv_Carbon_framework=yes],
-				[xorg_cv_Carbon_framework=no])
-			LDFLAGS=$save_LDFLAGS])
-                 
-		if test "X$xorg_cv_Carbon_framework" = Xyes; then
-			AC_DEFINE([DARWIN_WITH_QUARTZ],[1],[Have Quartz])
-			XQUARTZ=yes
-		else
-			XQUARTZ=no
-		fi
+if test "X$XQUARTZ" = Xauto; then
+	AC_CACHE_CHECK([whether to build Xquartz],xorg_cv_Carbon_framework,[
+	 	save_LDFLAGS=$LDFLAGS
+		LDFLAGS="$LDFLAGS -framework Carbon"
+		AC_LINK_IFELSE([char FSFindFolder(); int main() { FSFindFolder(); return 0;}],
+			[xorg_cv_Carbon_framework=yes],
+			[xorg_cv_Carbon_framework=no])
+		LDFLAGS=$save_LDFLAGS])
+                
+	if test "X$xorg_cv_Carbon_framework" = Xyes; then
+		AC_DEFINE([DARWIN_WITH_QUARTZ],[1],[Have Quartz])
+		XQUARTZ=yes
+	else
+		XQUARTZ=no
 	fi
+fi
 
+if test "x$XQUARTZ" = xyes; then
 	if test "x$X11APP" = xauto; then
 		AC_MSG_CHECKING([whether to build X11.app])
 		if test "x$XQUARTZ" = xyes ; then
@@ -1791,7 +1781,6 @@ AC_SUBST([OBJCFLAGS])
 _AM_DEPENDENCIES([OBJC])
 AM_CONDITIONAL(HAVE_XPLUGIN, [test "x$ac_cv_lib_Xplugin_xp_init" = xyes])
 AM_CONDITIONAL(HAVE_AGL_FRAMEWORK, [test "x$xorg_cv_AGL_framework" = xyes])
-AM_CONDITIONAL(XDARWIN, [test "x$XDARWIN" = xyes])
 AM_CONDITIONAL(XQUARTZ, [test "x$XQUARTZ" = xyes])
 AM_CONDITIONAL(X11APP,[test "X$X11APP" = Xyes]) 
 
diff --git a/hw/Makefile.am b/hw/Makefile.am
index db76977..6a15820 100644
--- a/hw/Makefile.am
+++ b/hw/Makefile.am
@@ -22,7 +22,7 @@ if XPRINT
 XPRINT_SUBDIRS = xprint
 endif
 
-if XDARWIN
+if XQUARTZ
 DARWIN_SUBDIRS = darwin
 endif
 
diff --git a/hw/darwin/Makefile.am b/hw/darwin/Makefile.am
index 04d9965..e83f04d 100644
--- a/hw/darwin/Makefile.am
+++ b/hw/darwin/Makefile.am
@@ -1,98 +1,27 @@
-noinst_LIBRARIES = libdarwinShared.a
-libdarwin_XINPUT_SRCS = darwinXinput.c
-
 AM_CFLAGS = @XORG_CFLAGS@
-INCLUDES = @XORG_INCS@ -I../../miext/rootless
-
-DEFS = @DEFS@ -DUSE_NEW_CLUT -DXFree86Server -DBUILD_DATE=\"$(BUILD_DATE)\" 
-
-if XQUARTZ
-XQUARTZ_SUBDIRS = quartz
-endif
-
-SUBDIRS = \
-	  iokit \
-	  $(XQUARTZ_SUBDIRS) \
-	  utils
-
-DIST_SUBDIRS = \
-	  iokit \
-	  quartz \
-	  utils
-
-libdarwinShared_a_SOURCES = darwin.c \
-			  darwinEvents.c \
-			  darwinKeyboard.c \
-			  $(darwin_XINPUT_SRCS) 
-
-if XQUARTZ
+AM_CPPFLAGS = @XORG_INCS@ -I../../miext/rootless -DUSE_NEW_CLUT -DBUILD_DATE=\"$(BUILD_DATE)\" -DHAVE_XORG_CONFIG_H -DXFree86Server
+  
+SUBDIRS = quartz utils
+  
 bin_PROGRAMS = Xquartz
-else
-bin_PROGRAMS = XDarwin
-endif
-
-XDarwin_SOURCES = \
-                  $(top_srcdir)/fb/fbcmap.c \
-                  $(top_srcdir)/mi/miinitext.c \
-                  $(top_srcdir)/Xi/stubs.c
-
-Xquartz_SOURCES = \
-                  $(top_srcdir)/fb/fbcmap.c \
-                  $(top_srcdir)/mi/miinitext.c \
-                  $(top_srcdir)/Xi/stubs.c \
-                  apple/X11Application.m \
-                  apple/X11Controller.m \
-                  quartz/applewm.c \
-                  quartz/keysym2ucs.c \
-                  quartz/pseudoramiX.c \
-                  quartz/quartz.c \
-                  quartz/quartzAudio.c \
-                  quartz/quartzCocoa.m \
-                  quartz/quartzKeyboard.c \
-                  quartz/quartzPasteboard.c \
-                  quartz/quartzStartup.c \
-                  quartz/xpr/appledri.c \
-                  quartz/xpr/dri.c \
-                  quartz/xpr/xprAppleWM.c \
-                  quartz/xpr/xprCursor.c \
-                  quartz/xpr/xprFrame.c \
-                  quartz/xpr/xprScreen.c \
-                  quartz/xpr/x-hash.c \
-                  quartz/xpr/x-hook.c \
-                  quartz/xpr/x-list.c
-
-XDarwin_LDADD = \
+man1_MANS = apple/Xquartz.man
+  
+Xquartz_SOURCES = darwin.c \
+		  darwinEvents.c \
+		  darwinKeyboard.c \
+		  darwinXinput.c \
+		  $(top_srcdir)/fb/fbcmap.c \
+		  $(top_srcdir)/mi/miinitext.c
+
+#		We should probably add these once they're working, or are these obsolete and to be removed?
+#		./quartz/cr/libcr.a
+#		./quartz/fullscreen/libfullscreen.a
+
+Xquartz_LDADD = ./quartz/libXquartz.a \
+		./quartz/xpr/libxpr.a \
 		$(top_builddir)/dix/dixfonts.lo \
 		$(top_builddir)/dix/libdix.la \
 		$(top_builddir)/os/libos.la \
-		./libdarwinShared.a \
-		./iokit/libiokit.a \
-		$(top_builddir)/dix/libxpstubs.la \
-		$(top_builddir)/miext/shadow/libshadow.la \
-		$(top_builddir)/fb/libfb.la \
-		$(top_builddir)/composite/libcomposite.la \
-		$(top_builddir)/damageext/libdamageext.la \
-		$(top_builddir)/miext/damage/libdamage.la \
-		$(top_builddir)/xfixes/libxfixes.la \
-		$(top_builddir)/miext/cw/libcw.la \
-		$(top_builddir)/Xext/libXext.la \
-		$(top_builddir)/xkb/libxkb.la \
-		$(top_builddir)/xkb/libxkbstubs.la \
-		$(top_builddir)/Xi/libXi.la \
-		$(top_builddir)/dbe/libdbe.la \
-		$(top_builddir)/record/librecord.la \
-		$(top_builddir)/XTrap/libxtrap.la \
-		$(XGLX_LIBS) \
-		$(top_builddir)/miext/rootless/librootless.la \
-		$(top_builddir)/miext/rootless/safeAlpha/libsafeAlpha.la \
-		$(top_builddir)/miext/rootless/accel/librlAccel.la \
-		$(XSERVER_LIBS) -lXplugin
-
-Xquartz_LDADD = \
-		$(top_builddir)/dix/dixfonts.lo \
-		$(top_builddir)/dix/libdix.la \
-		$(top_builddir)/os/libos.la \
-		./libdarwinShared.a \
 		$(top_builddir)/dix/libxpstubs.la \
 		$(top_builddir)/miext/shadow/libshadow.la \
 		$(top_builddir)/fb/libfb.la \
@@ -114,33 +43,24 @@ Xquartz_LDADD = \
 		$(top_builddir)/miext/rootless/accel/librlAccel.la \
 		$(DARWIN_LIBS) $(XSERVER_LIBS) -lXplugin
 
-XDarwin_LDFLAGS =  \
-                 -XCClinker -Objc \
-                 -Wl,-u,_miDCInitialize \
-                 -Wl,-framework,IOKit
-
-Xquartz_LDFLAGS =  \
-                 -XCClinker -Objc \
-                 -Wl,-u,_miDCInitialize \
-                 -Wl,-framework,Carbon \
-	         -L/System/Library/Frameworks/OpenGL.framework/Libraries -lGL \
-                 -Wl,-framework,OpenGL \
-                 -Wl,-framework,Cocoa \
-                 -Wl,-framework,CoreAudio \
-                 -Wl,-framework,IOKit
 
-XDarwin_CFLAGS = -DINXDARWIN
-Xquartz_CFLAGS = -DINXQUARTZ -DHAS_CG_MACH_PORT -DHAS_KL_API  -DHAVE_XORG_CONFIG_H
-Xquartz_OBJCFLAGS = -DINXQUARTZ -DHAS_CG_MACH_PORT -DHAS_KL_API  -DHAVE_XORG_CONFIG_H
+Xquartz_LDFLAGS =  -XCClinker -Objc \
+		   -Wl,-u,_miDCInitialize \
+		   -Wl,-framework,Carbon \
+		   -L/System/Library/Frameworks/OpenGL.framework/Libraries -lGL \
+		   -Wl,-framework,OpenGL \
+		   -Wl,-framework,Cocoa \
+		   -Wl,-framework,CoreAudio \
+	  	   -Wl,-framework,IOKit
 
 if X11APP
 bin_SCRIPTS = x11app x11launcher
 
 x11app:
-	cd apple && xcodebuild CFLAGS="$(XSERVERCFLAGS_CFLAGS)" LDFLAGS="$(XSERVERCFLAGS_LIBS)"
+	cd apple && xcodebuild CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"
 
 x11launcher:
-	cd launcher && xcodebuild CFLAGS="$(XSERVERCFLAGS_CFLAGS)" LDFLAGS="$(XSERVERCFLAGS_LIBS)"
+	cd launcher && xcodebuild CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"
 
 x11app-install:
 	cd apple && xcodebuild install DSTROOT=$(DESTDIR) INSTALL_PATH=$(prefix) DEPLOYMENT_LOCATION=YES SKIP_INSTALL=NO
@@ -156,19 +76,12 @@ x11launcher-clean:
 
 install-data-hook: x11app-install x11launcher-install
 clean-local: x11app-clean x11launcher-clean
-
 endif
 
-man1_MANS = XDarwin.man
-
 EXTRA_DIST = \
-	darwin.c \
 	darwinClut8.h \
-	darwinEvents.c \
 	darwin.h \
-	darwinKeyboard.c \
 	darwinKeyboard.h \
-	darwinXinput.c \
 	apple/X11Application.h \
 	apple/X11Controller.h \
 	apple/Info.plist \
@@ -184,5 +97,4 @@ EXTRA_DIST = \
 	launcher/bundle-main.c \
 	launcher/Info.plist \
 	launcher/X11.icns \
-	launcher/X11.xcodeproj/project.pbxproj \
-	XDarwin.man
+	launcher/X11.xcodeproj/project.pbxproj
diff --git a/hw/darwin/quartz/Makefile.am b/hw/darwin/quartz/Makefile.am
index baa7d44..5a78bfb 100644
--- a/hw/darwin/quartz/Makefile.am
+++ b/hw/darwin/quartz/Makefile.am
@@ -2,41 +2,30 @@ noinst_LIBRARIES = libXQuartz.a
 
 AM_CFLAGS = @XORG_CFLAGS@
 AM_OBJCFLAGS = @XORG_CFLAGS@
+AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/.. @XORG_INCS@ -DXBINDIR=\"${bindir}\" -DINXQUARTZ -DHAS_KL_API -DHAVE_XORG_CONFIG_H
 
-INCLUDES = -I$(srcdir) -I$(srcdir)/.. @XORG_INCS@
-AM_DEFS = -DHAS_CG_MACH_PORT -DHAS_KL_API
-AM_DEFS += -DBUILD_XPR
-XPR = xpr
-
-DEFS = @DEFS@ $(AM_DEFS) -DXBINDIR=\"${bindir}\"
-SUBDIRS = cr fullscreen $(XPR)
+SUBDIRS = cr fullscreen xpr
 
 libXQuartz_a_SOURCES = \
-		  Preferences.m \
-	          XApplication.m \
-	          XServer.m \
+		  ../apple/X11Application.m \
+		  ../apple/X11Controller.m \
 	          applewm.c \
 	          keysym2ucs.c \
+	          pseudoramiX.c \
 	          quartz.c \
 	          quartzAudio.c \
 	          quartzCocoa.m \
-	          quartzPasteboard.c \
 	          quartzKeyboard.c \
-	          quartzStartup.c \
-	          pseudoramiX.c
+	          quartzPasteboard.c \
+	          quartzStartup.c
 
 EXTRA_DIST = \
 	applewmExt.h \
 	keysym2ucs.h \
-	Preferences.h \
 	pseudoramiX.h \
 	quartzAudio.h \
 	quartzCommon.h \
 	quartzCursor.c \
 	quartzCursor.h \
 	quartz.h \
-	quartzPasteboard.h \
-	XApplication.h \
-	XDarwin.pbproj/project.pbxproj \
-	XServer.h \
-	XDarwinStartup.man
+	quartzPasteboard.h
diff --git a/hw/darwin/quartz/cr/Makefile.am b/hw/darwin/quartz/cr/Makefile.am
index abfac99..ff6043d 100644
--- a/hw/darwin/quartz/cr/Makefile.am
+++ b/hw/darwin/quartz/cr/Makefile.am
@@ -1,8 +1,8 @@
 noinst_LIBRARIES = libcr.a
 AM_CFLAGS =  @XORG_CFLAGS@
 AM_OBJCFLAGS =  @XORG_CFLAGS@
-DEFS = @DEFS@ -DDEFER_NSWINDOW
-INCLUDES = @XORG_INCS@ \
+AM_CPPFLAGS = -DDEFER_NSWINDOW \
+	   @XORG_INCS@ \
 	   -I../fullscreen \
 	   -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../.. \
 	   -I$(top_srcdir)/miext/rootless \
diff --git a/hw/darwin/quartz/fullscreen/Makefile.am b/hw/darwin/quartz/fullscreen/Makefile.am
index 37c767c..5e471ad 100644
--- a/hw/darwin/quartz/fullscreen/Makefile.am
+++ b/hw/darwin/quartz/fullscreen/Makefile.am
@@ -1,6 +1,6 @@
 noinst_LIBRARIES = libfullscreen.a
 AM_CFLAGS = @XORG_CFLAGS@
-INCLUDES = @XORG_INCS@ -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../.. 
+AM_CPPFLAGS = @XORG_INCS@ -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../.. 
 
 libfullscreen_a_SOURCES = fullscreen.c \
 			   quartzCursor.c
diff --git a/hw/darwin/quartz/xpr/Makefile.am b/hw/darwin/quartz/xpr/Makefile.am
index 7ebcba7..1f19fe9 100644
--- a/hw/darwin/quartz/xpr/Makefile.am
+++ b/hw/darwin/quartz/xpr/Makefile.am
@@ -1,6 +1,7 @@
 noinst_LIBRARIES = libxpr.a
 AM_CFLAGS =  @XORG_CFLAGS@
-INCLUDES = @XORG_INCS@ \
+AM_CPPFLAGS = @XORG_INCS@ \
+	   -DHAVE_XORG_CONFIG_H \
 	   -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../.. \
 	   -I$(top_srcdir)/miext/rootless \
 	   -I$(top_srcdir)/miext/rootless/safeAlpha \
@@ -17,8 +18,6 @@ libxpr_a_SOURCES = \
         x-hook.c \
         x-list.c
 
-xprbundledir = @APPLE_APPLICATIONS_DIR@/Resources/xpr.bundle/Contents/MacOS
-
 EXTRA_DIST = \
 	dri.h \
 	dristruct.h \
diff --git a/mi/miinitext.c b/mi/miinitext.c
index 6522890..ea09302 100644
--- a/mi/miinitext.c
+++ b/mi/miinitext.c
@@ -338,18 +338,11 @@ extern void XFree86DGAExtensionInit(INITARGS);
 #endif
 #ifdef GLXEXT
 typedef struct __GLXprovider __GLXprovider;
-#if defined(__DARWIN__) && defined(INXDARWINAPP)
-extern __GLXprovider* __DarwinglXMesaProvider;
-extern void DarwinGlxPushProvider(__GLXprovider *impl);
-extern void DarwinGlxExtensionInit(INITARGS);
-extern void DarwinGlxWrapInitVisuals(miInitVisualsProcPtr *);
-#else
 extern __GLXprovider __glXMesaProvider;
 extern void GlxPushProvider(__GLXprovider *impl);
 extern void GlxExtensionInit(INITARGS);
 extern void GlxWrapInitVisuals(miInitVisualsProcPtr *);
 #endif
-#endif
 #ifdef XF86DRI
 extern void XFree86DRIExtensionInit(INITARGS);
 #endif
@@ -633,14 +626,9 @@ InitExtensions(argc, argv)
 #endif
 
 #ifdef GLXEXT
-#if defined(__DARWIN__) && defined(INXDARWINAPP)
-    DarwinGlxPushProvider(__DarwinglXMesaProvider);
-    if (!noGlxExtension) DarwinGlxExtensionInit();
-#else
     GlxPushProvider(&__glXMesaProvider);
     if (!noGlxExtension) GlxExtensionInit();
 #endif
-#endif
 #ifdef XFIXES
     /* must be before Render to layer DisplayCursor correctly */
     if (!noXFixesExtension) XFixesExtensionInit();
commit 835de9ceae0a5bfb6155d3e74c8ab53848bad8b1
Author: Ben Byer <bbyer at bbyer.local>
Date:   Wed Nov 14 04:26:25 2007 -0800

    Trying to add launchd detection to tell Xtrans
    to enable launchd support; fix me later.

diff --git a/configure.ac b/configure.ac
index 5b04416..e06c8e3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -96,6 +96,9 @@ AC_HEADER_STDC
 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h])
 
 AC_CHECK_PROG(HAVE_LAUNCHD, [launchd], [yes], [])
+if test "x$HAVE_LAUNCHD" = xyes; then
+	AC_DEFINE(HAS_LAUNCHD, 1, [launchd support available])
+fi
 
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
@@ -1753,7 +1756,7 @@ if test "x$XDARWIN" = xyes; then
 	       AC_SUBST([DARWIN_LIBS])
                AC_CHECK_LIB([Xplugin],[xp_init],[:])
                AC_SUBST([APPLE_APPLICATIONS_DIR])
-               CFLAGS="${CFLAGS} -D__DARWIN__ -DDARWIN_WITH_QUARTZ -DROOTLESS_WORKAROUND"
+               CFLAGS="${CFLAGS} -DHAVE_LAUNCHD -D__DARWIN__ -DDARWIN_WITH_QUARTZ -DROOTLESS_WORKAROUND"
                PLIST_VERSION_STRING=$PACKAGE_VERSION
                AC_SUBST([PLIST_VERSION_STRING])
                PLIST_VENDOR_WEB=$VENDOR_WEB
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index 69fab5e..837a5d5 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -142,6 +142,9 @@
 /* Define to 1 if you have version 2.2 (or newer) of the drm library */
 #undef HAVE_LIBDRM_2_2
 
+/* Define to 1 if launchd is available. */
+#undef HAVE_LAUNCHD
+
 /* Define to 1 if you have the `m' library (-lm). */
 #undef HAVE_LIBM
 
commit 96416bd595f9ac2816bc1b50ab6ada305e198813
Author: Ben Byer <bbyer at bbyer.local>
Date:   Tue Nov 13 01:08:02 2007 -0800

    fix missing -DXFree86Server; this needs to be defined when building
    fb/fbcmap.c or else you get the "sunglasses effect"

diff --git a/hw/darwin/Makefile.am b/hw/darwin/Makefile.am
index 1d64100..04d9965 100644
--- a/hw/darwin/Makefile.am
+++ b/hw/darwin/Makefile.am
@@ -1,11 +1,10 @@
 noinst_LIBRARIES = libdarwinShared.a
 libdarwin_XINPUT_SRCS = darwinXinput.c
 
-# -O2 inexplicably causes quartzKeyboard.o to break?!
 AM_CFLAGS = @XORG_CFLAGS@
 INCLUDES = @XORG_INCS@ -I../../miext/rootless
 
-DEFS = @DEFS@ -DUSE_NEW_CLUT
+DEFS = @DEFS@ -DUSE_NEW_CLUT -DXFree86Server -DBUILD_DATE=\"$(BUILD_DATE)\" 
 
 if XQUARTZ
 XQUARTZ_SUBDIRS = quartz
commit cfa99fa687fe35b3e5f67e57d84e8c75ee529adb
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Mon Nov 12 20:10:10 2007 -0800

    null pointer check

diff --git a/hw/darwin/darwinEvents.c b/hw/darwin/darwinEvents.c
index e859258..f457902 100644
--- a/hw/darwin/darwinEvents.c
+++ b/hw/darwin/darwinEvents.c
@@ -155,6 +155,7 @@ static void DarwinReleaseModifiers(void) {
   xEvent ke;
   int i = 0, j = 0, nevents = 0; 
  
+  if (!darwinKeyc) return;
   map = darwinKeyc->curKeySyms.map;
   
   for (i = darwinKeyc->curKeySyms.minKeyCode, map = darwinKeyc->curKeySyms.map;
commit 10ecb31cd131104e8e0b9255243fb74becbd8d4b
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Mon Nov 12 19:08:40 2007 -0800

    More build system fixes from Jeremy

diff --git a/hw/darwin/Makefile.am b/hw/darwin/Makefile.am
index af71e6a..1d64100 100644
--- a/hw/darwin/Makefile.am
+++ b/hw/darwin/Makefile.am
@@ -14,8 +14,12 @@ endif
 SUBDIRS = \
 	  iokit \
 	  $(XQUARTZ_SUBDIRS) \
-	  utils \
-	  .
+	  utils
+
+DIST_SUBDIRS = \
+	  iokit \
+	  quartz \
+	  utils
 
 libdarwinShared_a_SOURCES = darwin.c \
 			  darwinEvents.c \
@@ -139,18 +143,25 @@ x11app:
 x11launcher:
 	cd launcher && xcodebuild CFLAGS="$(XSERVERCFLAGS_CFLAGS)" LDFLAGS="$(XSERVERCFLAGS_LIBS)"
 
-x11app-install-hook:
-	cd apple && xcodebuild install DSTROOT=$(DESTDIR) INSTALL_PATH=$(prefixdir) DEPLOYMENT_LOCATION=YES SKIP_INSTALL=NO
+x11app-install:
+	cd apple && xcodebuild install DSTROOT=$(DESTDIR) INSTALL_PATH=$(prefix) DEPLOYMENT_LOCATION=YES SKIP_INSTALL=NO
+
+x11launcher-install:
 	cd launcher && xcodebuild install DSTROOT=$(DESTDIR) INSTALL_PATH=$(APPLE_APPLICATIONS_DIR) DEPLOYMENT_LOCATION=YES SKIP_INSTALL=NO
 
-HOOK_TARGETS = x11app-install-hook
+x11app-clean:
+	rm -rf apple/build
+
+x11launcher-clean:
+	rm -rf launcher/build
+
+install-data-hook: x11app-install x11launcher-install
+clean-local: x11app-clean x11launcher-clean
 
 endif
 
 man1_MANS = XDarwin.man
 
-install-data-hook: $(HOOK_TARGETS)
-
 EXTRA_DIST = \
 	darwin.c \
 	darwinClut8.h \
@@ -171,4 +182,8 @@ EXTRA_DIST = \
 	apple/English.lproj/main.nib/info.nib \
 	apple/English.lproj/main.nib/keyedobjects.nib \
 	apple/X11.xcodeproj/project.pbxproj \
+	launcher/bundle-main.c \
+	launcher/Info.plist \
+	launcher/X11.icns \
+	launcher/X11.xcodeproj/project.pbxproj \
 	XDarwin.man
diff --git a/hw/darwin/apple/X11.xcodeproj/project.pbxproj b/hw/darwin/apple/X11.xcodeproj/project.pbxproj
index a47e4d1..217f07e 100644
--- a/hw/darwin/apple/X11.xcodeproj/project.pbxproj
+++ b/hw/darwin/apple/X11.xcodeproj/project.pbxproj
@@ -207,38 +207,33 @@
 		527F24090B5D8FFC007840A7 /* Development */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				DSTROOT = "$(DSTROOT)";
-				SKIP_INSTALL = YES;
+				INSTALL_MODE_FLAG = "a+rX";
 			};
 			name = Development;
 		};
 		527F240A0B5D8FFC007840A7 /* Deployment */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				DSTROOT = "$(DSTROOT)";
-				SKIP_INSTALL = YES;
+				INSTALL_MODE_FLAG = "a+rX";
 			};
 			name = Deployment;
 		};
 		527F240B0B5D8FFC007840A7 /* Default */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				DSTROOT = "$(DSTROOT)";
-				SKIP_INSTALL = YES;
+				INSTALL_MODE_FLAG = "a+rX";
 			};
 			name = Default;
 		};
 		527F24230B5D938C007840A7 /* Development */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				ARCHS = "$(NATIVE_ARCH_32_BIT)";
 				COPY_PHASE_STRIP = NO;
-				DSTROOT = "$(DSTROOT)";
 				FRAMEWORK_SEARCH_PATHS = "";
 				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
 				HEADER_SEARCH_PATHS = /usr/X11/include;
 				INFOPLIST_FILE = Info.plist;
-				INSTALL_PATH = $DSTROOT/Applications/Utilties;
+				INSTALL_PATH = /usr/X11;
 				LIBRARY_SEARCH_PATHS = /usr/X11/lib;
 				OTHER_CFLAGS = "";
 				OTHER_LDFLAGS = (
@@ -262,12 +257,11 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				COPY_PHASE_STRIP = YES;
-				DSTROOT = "$(DSTROOT)";
 				FRAMEWORK_SEARCH_PATHS = "";
 				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
 				HEADER_SEARCH_PATHS = /usr/X11/include;
 				INFOPLIST_FILE = Info.plist;
-				INSTALL_PATH = $DSTROOT/Applications/Utilties;
+				INSTALL_PATH = /usr/X11;
 				LIBRARY_SEARCH_PATHS = /usr/X11/lib;
 				OTHER_CFLAGS = "";
 				OTHER_LDFLAGS = (
@@ -290,12 +284,11 @@
 		527F24250B5D938C007840A7 /* Default */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				DSTROOT = "$(DSTROOT)";
 				FRAMEWORK_SEARCH_PATHS = "";
 				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
 				HEADER_SEARCH_PATHS = /usr/X11/include;
 				INFOPLIST_FILE = Info.plist;
-				INSTALL_PATH = $DSTROOT/Applications/Utilties;
+				INSTALL_PATH = /usr/X11;
 				LIBRARY_SEARCH_PATHS = /usr/X11/lib;
 				OTHER_CFLAGS = "";
 				OTHER_LDFLAGS = (
diff --git a/hw/darwin/launcher/X11.xcodeproj/project.pbxproj b/hw/darwin/launcher/X11.xcodeproj/project.pbxproj
index f82552a..34b76da 100644
--- a/hw/darwin/launcher/X11.xcodeproj/project.pbxproj
+++ b/hw/darwin/launcher/X11.xcodeproj/project.pbxproj
@@ -164,33 +164,28 @@
 		527F24090B5D8FFC007840A7 /* Development */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				DSTROOT = "$(DSTROOT)";
-				SKIP_INSTALL = YES;
+				INSTALL_MODE_FLAG = "a+rX";
 			};
 			name = Development;
 		};
 		527F240A0B5D8FFC007840A7 /* Deployment */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				DSTROOT = "$(DSTROOT)";
-				SKIP_INSTALL = YES;
+				INSTALL_MODE_FLAG = "a+rX";
 			};
 			name = Deployment;
 		};
 		527F240B0B5D8FFC007840A7 /* Default */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				DSTROOT = "$(DSTROOT)";
-				SKIP_INSTALL = YES;
+				INSTALL_MODE_FLAG = "a+rX";
 			};
 			name = Default;
 		};
 		527F24230B5D938C007840A7 /* Development */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				ARCHS = "$(NATIVE_ARCH_32_BIT)";
 				COPY_PHASE_STRIP = NO;
-				DSTROOT = "$(DSTROOT)";
 				FRAMEWORK_SEARCH_PATHS = "";
 				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
 				HEADER_SEARCH_PATHS = /usr/X11/include;
@@ -219,12 +214,11 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				COPY_PHASE_STRIP = YES;
-				DSTROOT = "$(DSTROOT)";
 				FRAMEWORK_SEARCH_PATHS = "";
 				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
 				HEADER_SEARCH_PATHS = /usr/X11/include;
 				INFOPLIST_FILE = Info.plist;
-				INSTALL_PATH = $DSTROOT/Applications/Utilties;
+				INSTALL_PATH = /Applications/Utilties;
 				LIBRARY_SEARCH_PATHS = /usr/X11/lib;
 				OTHER_CFLAGS = "";
 				OTHER_LDFLAGS = "";
@@ -243,12 +237,11 @@
 		527F24250B5D938C007840A7 /* Default */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
-				DSTROOT = "$(DSTROOT)";
 				FRAMEWORK_SEARCH_PATHS = "";
 				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
 				HEADER_SEARCH_PATHS = /usr/X11/include;
 				INFOPLIST_FILE = Info.plist;
-				INSTALL_PATH = $DSTROOT/Applications/Utilties;
+				INSTALL_PATH = /Applications/Utilties;
 				LIBRARY_SEARCH_PATHS = /usr/X11/lib;
 				OTHER_CFLAGS = "";
 				OTHER_LDFLAGS = (
commit 1c8e5994c6260c8d6da1b761526c2f9245170aee
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Mon Nov 12 16:42:00 2007 -0800

    converted some debugging prints to TRACE() statements

diff --git a/hw/darwin/quartz/quartz.c b/hw/darwin/quartz/quartz.c
index 34f5e45..c0666e6 100644
--- a/hw/darwin/quartz/quartz.c
+++ b/hw/darwin/quartz/quartz.c
@@ -253,7 +253,7 @@ static void QuartzUpdateScreens(void)
     int x, y, width, height, sx, sy;
     xEvent e;
 
-    ErrorF("QuartzUpdateScreens()\n");
+    TRACE("QuartzUpdateScreens()\n");
     if (noPseudoramiXExtension || screenInfo.numScreens != 1)
     {
         /* FIXME: if not using Xinerama, we have multiple screens, and
@@ -421,6 +421,7 @@ void DarwinModeProcessEvent(
 {
     switch (xe->u.u.type) {
         case kXDarwinControllerNotify:
+	  TRACE("kXDarwinControllerNotify\n");
             AppleWMSendEvent(AppleWMControllerNotify,
                              AppleWMControllerNotifyMask,
                              xe->u.clientMessage.u.l.longs0,
@@ -428,6 +429,7 @@ void DarwinModeProcessEvent(
             break;
 
         case kXDarwinPasteboardNotify:
+	  TRACE("kXDarwinPasteboardNotify\n");
             AppleWMSendEvent(AppleWMPasteboardNotify,
                              AppleWMPasteboardNotifyMask,
                              xe->u.clientMessage.u.l.longs0,
@@ -435,7 +437,7 @@ void DarwinModeProcessEvent(
             break;
 
         case kXDarwinActivate:
-  //	  ErrorF("kXDarwinActivate\n");
+	  TRACE("kXDarwinActivate\n");
             QuartzShow(xe->u.keyButtonPointer.rootX,
                        xe->u.keyButtonPointer.rootY);
             AppleWMSendEvent(AppleWMActivationNotify,
@@ -444,7 +446,7 @@ void DarwinModeProcessEvent(
             break;
 
         case kXDarwinDeactivate:
-  //	  ErrorF("kXDarwinDeactivate\n");
+  	  TRACE("kXDarwinDeactivate\n");
             AppleWMSendEvent(AppleWMActivationNotify,
                              AppleWMActivationNotifyMask,
                              AppleWMIsInactive, 0);
@@ -452,22 +454,23 @@ void DarwinModeProcessEvent(
             break;
 
         case kXDarwinDisplayChanged:
-  //	  ErrorF("kXDarwinDisplayChanged\n");
+	    TRACE("kXDarwinDisplayChanged\n");
             QuartzUpdateScreens();
             break;
 
         case kXDarwinWindowState:
-  //	  ErrorF("kXDarwinWindowState\n");
+	  TRACE("kXDarwinWindowState\n");
             RootlessNativeWindowStateChanged(xe->u.clientMessage.u.l.longs0,
 		  			     xe->u.clientMessage.u.l.longs1);
 	    break;
 	  
         case kXDarwinWindowMoved:
-  //	  ErrorF("kXDarwinWindowMoved\n");
+	  TRACE("kXDarwinWindowMoved\n");
             RootlessNativeWindowMoved (xe->u.clientMessage.u.l.longs0);
 	    break;
 
         case kXDarwinToggleFullscreen:
+	  TRACE("kXDarwinToggleFullscreen\n");
 #ifdef DARWIN_DDX_MISSING
             if (quartzEnableRootless) QuartzSetFullscreen(!quartzHasRoot);
             else if (quartzHasRoot) QuartzHide();
@@ -503,7 +506,7 @@ void DarwinModeProcessEvent(
             break;
 
         case kXDarwinBringAllToFront:
-  //	  ErrorF("kXDarwinBringAllToFront\n");
+  	  TRACE("kXDarwinBringAllToFront\n");
 	    RootlessOrderAllWindows();
             break;
 
diff --git a/hw/darwin/quartz/quartz.h b/hw/darwin/quartz/quartz.h
index 172f323..febc51a 100644
--- a/hw/darwin/quartz/quartz.h
+++ b/hw/darwin/quartz/quartz.h
@@ -38,6 +38,14 @@
 #include "screenint.h"
 #include "window.h"
 
+//#define DEBUG 1
+
+#ifdef DEBUG
+#define TRACE(msg, args...) ErrorF("%s:%d: " msg, __FUNCTION__, __LINE__, ##args )
+#else
+#define TRACE(msg, args...) 
+#endif
+
 /*------------------------------------------
    Quartz display mode function types
   ------------------------------------------*/
commit 22bf25c1b412ac776113777e12fc9cbc6b8af58d
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Mon Nov 12 16:41:13 2007 -0800

    Fix for stuck modifier keys, attempt 2!

diff --git a/hw/darwin/darwinEvents.c b/hw/darwin/darwinEvents.c
index 0367672..e859258 100644
--- a/hw/darwin/darwinEvents.c
+++ b/hw/darwin/darwinEvents.c
@@ -41,7 +41,6 @@ in this Software without prior written authorization from The Open Group.
 #include   "mi.h"
 #include   "scrnintstr.h"
 #include   "mipointer.h"
-
 #include "darwin.h"
 #include "darwinKeyboard.h"
 
@@ -77,6 +76,8 @@ typedef struct _EventQueue {
 
 static EventQueueRec darwinEventQueue;
 xEvent *darwinEvents;
+extern KeyClassPtr darwinKeyc;
+#define KeyPressed(k) (darwinKeyc->down[k >> 3] & (1 << (k & 7)))
 
 /*
  * DarwinPressModifierMask
@@ -150,8 +151,37 @@ static void DarwinUpdateModifiers(
  * are held down during a "context" switch -- otherwise, we would miss the KeyUp.
  */
 static void DarwinReleaseModifiers(void) {
-	xEvent e;
-	DarwinUpdateModifiers(&e, KeyRelease, COMMAND_MASK(-1) | CONTROL_MASK(-1) | ALTERNATE_MASK(-1) | SHIFT_MASK(-1));
+  KeySym *map = NULL;
+  xEvent ke;
+  int i = 0, j = 0, nevents = 0; 
+ 
+  map = darwinKeyc->curKeySyms.map;
+  
+  for (i = darwinKeyc->curKeySyms.minKeyCode, map = darwinKeyc->curKeySyms.map;
+       i < darwinKeyc->curKeySyms.maxKeyCode;
+       i++, map += darwinKeyc->curKeySyms.mapWidth) {
+    if (KeyPressed(i)) {
+      switch (*map) {
+	/* Don't release the lock keys */
+      case XK_Caps_Lock:
+      case XK_Shift_Lock:
+      case XK_Num_Lock:
+      case XK_Scroll_Lock:
+      case XK_Kana_Lock:
+	break;
+      default:
+	  ke.u.keyButtonPointer.time = GetTimeInMillis();
+	  ke.u.keyButtonPointer.rootX = 0;
+	  ke.u.keyButtonPointer.rootY = 0;
+	  ke.u.u.type = KeyRelease;
+	  ke.u.u.detail = i;
+	  (*darwinEventQueue.pKbd->processInputProc)(&ke,
+		    (DeviceIntPtr)darwinEventQueue.pKbd, 1);
+	break;
+      }
+    }
+  }
+  ProcessInputEvents();
 }
 
 /*
diff --git a/hw/darwin/darwinKeyboard.c b/hw/darwin/darwinKeyboard.c
index 4e7a136..ae842cd 100644
--- a/hw/darwin/darwinKeyboard.c
+++ b/hw/darwin/darwinKeyboard.c
@@ -220,6 +220,7 @@ static void DarwinChangeKeyboardControl( DeviceIntPtr device, KeybdCtrl *ctrl )
 static darwinKeyboardInfo keyInfo;
 static FILE *fref = NULL;
 static char *inBuffer = NULL;
+KeyClassPtr darwinKeyc = NULL;
 
 //-----------------------------------------------------------------------------
 // Data Stream Object
@@ -835,6 +836,7 @@ InitModMap(register KeyClassPtr keyc)
     CARD8 keysPerModifier[8];
     CARD8 mask;
 
+    darwinKeyc = keyc;
     if (keyc->modifierKeyMap != NULL)
         xfree (keyc->modifierKeyMap);
 
commit 1bad9b87e56ceff12753c931612bce8d7a7c5d9d
Author: Ben Byer <bbyer at bbyer.local>
Date:   Mon Nov 12 00:44:11 2007 -0800

    And now we kill XDarwinApp -- credit, Jeremy Huddleston

diff --git a/configure.ac b/configure.ac
index 0935d15..5b04416 100644
--- a/configure.ac
+++ b/configure.ac
@@ -450,10 +450,10 @@ AC_ARG_WITH(rgb-path,         AS_HELP_STRING([--with-rgb-path=PATH], [Path to RG
 AC_ARG_WITH(serverconfig-path, AS_HELP_STRING([--with-serverconfig-path=PATH], [Path to server config (default: ${libdir}/xserver)]),
 				[ SERVERCONFIG="$withval" ],
 				[ SERVERCONFIG="${libdir}/xserver" ])
-APPLE_APPLICATIONS_DIR="${bindir}/Applications"
-AC_ARG_WITH(apple-applications-dir,AS_HELP_STRING([--with-apple-applications-dir=PATH], [Path to the Applications directory (default: ${bindir}/Applications)]),
+APPLE_APPLICATIONS_DIR="/Applications/Utilities"
+AC_ARG_WITH(apple-applications-dir,AS_HELP_STRING([--with-apple-applications-dir=PATH], [Path to the Applications directory (default: /Applications/Utilities)]),
                                [ APPLE_APPLICATIONS_DIR="${withval}" ].
-                               [ APPLE_APPLICATIONS_DIR="${bindir}/Applications" ])
+                               [ APPLE_APPLICATIONS_DIR="/Applications/Utilities" ])
 AC_ARG_ENABLE(builddocs,      AS_HELP_STRING([--enable-builddocs], [Build docs (default: disabled)]),
                                 [BUILDDOCS=$enableval],
                                 [BUILDDOCS=no])
@@ -523,9 +523,8 @@ AC_ARG_ENABLE(dmx,    	      AS_HELP_STRING([--enable-dmx], [Build DMX server (d
 AC_ARG_ENABLE(xvfb,    	      AS_HELP_STRING([--enable-xvfb], [Build Xvfb server (default: no)]), [XVFB=$enableval], [XVFB=no])
 AC_ARG_ENABLE(xnest,   	      AS_HELP_STRING([--enable-xnest], [Build Xnest server (default: no)]), [XNEST=$enableval], [XNEST=no])
 AC_ARG_ENABLE(xdarwin, 	      AS_HELP_STRING([--enable-xdarwin], [Build XDarwin server (default: auto)]), [XDARWIN=$enableval], [XDARWIN=auto])
-AC_ARG_ENABLE(xdarwinapp,     AS_HELP_STRING([--enable-xdarwinapp], [Build XDarwin.app server (default: no)]), [XDARWINAPP=$enableval], [XDARWINAPP=no])
 AC_ARG_ENABLE(xquartz,        AS_HELP_STRING([--disable-xquartz], [Build Xquartz server on Darwin (default: auto)]), [XQUARTZ=$enableval], [XQUARTZ=auto])
-AC_ARG_ENABLE(x11app,         AS_HELP_STRING([--enable-x11app], [Build Apple's X11.app wrapper for Xquartz (default: no)]), [X11APP=$enableval], [X11APP=no])
+AC_ARG_ENABLE(x11app,         AS_HELP_STRING([--enable-x11app], [Build Apple's X11.app wrapper for Xquartz (default: auto)]), [X11APP=$enableval], [X11APP=auto])
 AC_ARG_ENABLE(xwin,    	      AS_HELP_STRING([--enable-xwin], [Build XWin server (default: auto)]), [XWIN=$enableval], [XWIN=auto])
 AC_ARG_ENABLE(xprint,         AS_HELP_STRING([--enable-xprint], [Build Xprint extension and server (default: no)]), [XPRINT=$enableval], [XPRINT=no])
 AC_ARG_ENABLE(xgl,            AS_HELP_STRING([--enable-xgl], [Build Xgl server (default: no)]), [XGL=$enableval], [XGL=no])
@@ -1560,7 +1559,6 @@ AM_CONDITIONAL([LNXACPI], [test "x$linux_acpi" = xyes])
 AM_CONDITIONAL([SOLARIS_USL_CONSOLE], [test "x$solaris_usl_console" = xyes])
 AM_CONDITIONAL([SOLARIS_ASM_INLINE], [test "x$solaris_asm_inline" = xyes])
 AM_CONDITIONAL([BUILD_DARWIN],[test "X$build_darwin" = Xyes])
-AM_CONDITIONAL([XQUARTZ],[test "X$XQUARTZ" = Xyes])
 AM_CONDITIONAL([DGA], [test "x$DGA" = xyes])
 AM_CONDITIONAL([XF86MISC], [test "x$XF86MISC" = xyes])
 AM_CONDITIONAL([XF86VIDMODE], [test "x$XF86VIDMODE" = xyes])
@@ -1700,7 +1698,7 @@ AM_CONDITIONAL(XWIN_RANDR, [test "x$XWIN" = xyes])
 AM_CONDITIONAL(XWIN_XV, [test "x$XWIN" = xyes && test "x$XV" = xyes])
 
 dnl Darwin / OS X DDX
-AC_MSG_CHECKING([whether to build XDarwin (Mac OS X) DDX])
+AC_MSG_CHECKING([whether to build XDarwin/Xquartz])
 if test "x$XDARWIN" = xauto; then
 	case $host_os in
 		darwin*) XDARWIN="yes" ;;
@@ -1710,25 +1708,33 @@ fi
 AC_MSG_RESULT([$XDARWIN])
 
 if test "x$XDARWIN" = xyes; then
-        if test "X$XQUARTZ" = Xauto; then
-                 AC_CACHE_CHECK([for Carbon framework],xorg_cv_Carbon_framework,[
-                 save_LDFLAGS=$LDFLAGS
-                 LDFLAGS="$LDFLAGS -framework Carbon"
-                 AC_LINK_IFELSE([char FSFindFolder();
-int main() {
-FSFindFolder();
-return 0;}
-                 ],[xorg_cv_Carbon_framework=yes],
-                  [xorg_cv_Carbon_framework=no])
-                  LDFLAGS=$save_LDFLAGS])
-                 if test "X$xorg_cv_Carbon_framework" = Xyes; then
-                   AC_DEFINE([DARWIN_WITH_QUARTZ],[1],
-                         [Have Quartz])
-                   XQUARTZ=yes
-                 else
-                   XQUARTZ=no
-                 fi
-               fi
+	if test "X$XQUARTZ" = Xauto; then
+		AC_CACHE_CHECK([whether to build Xquartz],xorg_cv_Carbon_framework,[
+		 	save_LDFLAGS=$LDFLAGS
+			LDFLAGS="$LDFLAGS -framework Carbon"
+			AC_LINK_IFELSE([char FSFindFolder(); int main() { FSFindFolder(); return 0;}],
+				[xorg_cv_Carbon_framework=yes],
+				[xorg_cv_Carbon_framework=no])
+			LDFLAGS=$save_LDFLAGS])
+                 
+		if test "X$xorg_cv_Carbon_framework" = Xyes; then
+			AC_DEFINE([DARWIN_WITH_QUARTZ],[1],[Have Quartz])
+			XQUARTZ=yes
+		else
+			XQUARTZ=no
+		fi
+	fi
+
+	if test "x$X11APP" = xauto; then
+		AC_MSG_CHECKING([whether to build X11.app])
+		if test "x$XQUARTZ" = xyes ; then
+			X11APP=yes
+		else
+			X11APP=no
+		fi
+		AC_MSG_RESULT([$X11APP])
+	fi
+
 #	       glxAGL / glxCGL don't work yet
 #               AC_CACHE_CHECK([for AGL framework],xorg_cv_AGL_framework,[
 #               save_LDFLAGS=$LDFLAGS
@@ -1783,8 +1789,8 @@ _AM_DEPENDENCIES([OBJC])
 AM_CONDITIONAL(HAVE_XPLUGIN, [test "x$ac_cv_lib_Xplugin_xp_init" = xyes])
 AM_CONDITIONAL(HAVE_AGL_FRAMEWORK, [test "x$xorg_cv_AGL_framework" = xyes])
 AM_CONDITIONAL(XDARWIN, [test "x$XDARWIN" = xyes])
-AM_CONDITIONAL(XDARWINAPP, [test "x$XDARWINAPP" = xyes])
 AM_CONDITIONAL(XQUARTZ, [test "x$XQUARTZ" = xyes])
+AM_CONDITIONAL(X11APP,[test "X$X11APP" = Xyes]) 
 
 dnl kdrive DDX
 
diff --git a/hw/darwin/Makefile.am b/hw/darwin/Makefile.am
index 6f9318d..af71e6a 100644
--- a/hw/darwin/Makefile.am
+++ b/hw/darwin/Makefile.am
@@ -8,7 +8,7 @@ INCLUDES = @XORG_INCS@ -I../../miext/rootless
 DEFS = @DEFS@ -DUSE_NEW_CLUT
 
 if XQUARTZ
-XQUARTZ_SUBDIRS = bundle quartz
+XQUARTZ_SUBDIRS = quartz
 endif
 
 SUBDIRS = \
@@ -17,14 +17,17 @@ SUBDIRS = \
 	  utils \
 	  .
 
-darwinappdir = /Applications/Utilities/XDarwin.app
-
 libdarwinShared_a_SOURCES = darwin.c \
 			  darwinEvents.c \
 			  darwinKeyboard.c \
 			  $(darwin_XINPUT_SRCS) 
 
+if XQUARTZ
 bin_PROGRAMS = Xquartz
+else
+bin_PROGRAMS = XDarwin
+endif
+
 XDarwin_SOURCES = \
                   $(top_srcdir)/fb/fbcmap.c \
                   $(top_srcdir)/mi/miinitext.c \
@@ -127,185 +130,27 @@ XDarwin_CFLAGS = -DINXDARWIN
 Xquartz_CFLAGS = -DINXQUARTZ -DHAS_CG_MACH_PORT -DHAS_KL_API  -DHAVE_XORG_CONFIG_H
 Xquartz_OBJCFLAGS = -DINXQUARTZ -DHAS_CG_MACH_PORT -DHAS_KL_API  -DHAVE_XORG_CONFIG_H
 
-if XQUARTZ
-macosdir = $(darwinappdir)/Contents/MacOS
-
-DEFS += -DDARWIN_WITH_QUARTZ -DXFree86Server
-
-macos_PROGRAMS = 
-macos_SCRIPTS = x11app
+if X11APP
+bin_SCRIPTS = x11app x11launcher
 
 x11app:
-	cd apple && xcodebuild
+	cd apple && xcodebuild CFLAGS="$(XSERVERCFLAGS_CFLAGS)" LDFLAGS="$(XSERVERCFLAGS_LIBS)"
 
-XDarwinApp_SOURCES = \
-               	$(top_srcdir)/fb/fbcmap.c \
-               	$(top_srcdir)/mi/miinitext.c \
-		$(top_srcdir)/Xi/stubs.c 
-
-XDarwinApp_LDADD = \
-		$(top_builddir)/dix/dixfonts.lo \
-		$(top_builddir)/dix/libdix.la \
-		$(top_builddir)/os/libos.la \
-		./quartz/XApplication.o \
-		./libdarwinShared.a \
-		./quartz/libXQuartz.a \
-		$(top_builddir)/dix/libxpstubs.la \
-		 $(top_builddir)/miext/shadow/libshadow.la \
-		 $(top_builddir)/fb/libfb.la \
-		 $(top_builddir)/composite/libcomposite.la \
-		 $(top_builddir)/damageext/libdamageext.la \
-		 $(top_builddir)/miext/damage/libdamage.la \
-		 $(top_builddir)/xfixes/libxfixes.la \
-		 $(top_builddir)/miext/cw/libcw.la \
-		 $(top_builddir)/Xext/libXext.la \
-		 $(top_builddir)/xkb/libxkb.la \
-		 $(top_builddir)/xkb/libxkbstubs.la \
-		 $(top_builddir)/Xi/libXi.la \
-		 $(top_builddir)/dbe/libdbe.la \
-		 $(top_builddir)/record/librecord.la \
-		 $(top_builddir)/XTrap/libxtrap.la \
-		 $(XGLX_LIBS) \
-		 $(top_builddir)/miext/rootless/librootless.la \
-		 $(top_builddir)/miext/rootless/safeAlpha/libsafeAlpha.la \
-		 $(top_builddir)/miext/rootless/accel/librlAccel.la \
-		 @XORG_LIBS@ \
-		 -lXau -lXdmcp -lXfont -lfreetype \
-		 $(top_builddir)/fb/libfb.la 
-
-XDarwinApp_LDFLAGS =  \
-		 -XCClinker -Objc \
-		 -Wl,-u,_miDCInitialize \
-		 -Wl,-framework,Carbon \
-		 -Wl,-framework,ApplicationServices \
-		 -Wl,-framework,Cocoa \
-		 -Wl,-framework,CoreAudio \
-		 -Wl,-framework,IOKit
-
-HOOK_TARGETS = xquartz-install-hook
-
-
-crplugindir = $(darwinappdir)/Contents/Resources/cr.bundle/Contents/MacOS
-crplugin_LTLIBRARIES = 
-cr_la_SOURCES =
-cr_la_LIBADD = \
-		quartz/cr/crAppleWM.o \
-		quartz/cr/crFrame.o \
-		quartz/cr/crScreen.o \
-		quartz/fullscreen/quartzCursor.o \
-		quartz/cr/XView.o \
-		$(top_builddir)/miext/rootless/librootless.la \
-		$(top_builddir)/miext/rootless/safeAlpha/libsafeAlpha.la \
-		$(top_builddir)/miext/rootless/accel/librlAccel.la
-cr_la_LDFLAGS = -shrext '' -Wl,-framework,ApplicationServices \
-		-Wl,-framework,Cocoa \
-		-Wl,-framework,Carbon \
-		-XCClinker -ObjC \
-		-XCClinker -bundle_loader -XCClinker XDarwinApp \
-		-module -avoid-version -no-undefined
-cr_la_DEPENDENCIES = XDarwinApp	
-
-fullscreenplugindir = $(darwinappdir)/Contents/Resources/fullscreen.bundle/Contents/MacOS
-fullscreenplugin_LTLIBRARIES =
-fullscreen_la_SOURCES =
-fullscreen_la_LIBADD = \
-		quartz/fullscreen/fullscreen.o \
-		quartz/fullscreen/quartzCursor.o \
-		$(top_builddir)/miext/shadow/libshadow.la
-
-fullscreen_la_LDFLAGS = -shrext '' -Wl,-framework,ApplicationServices \
-		-XCClinker -bundle_loader -XCClinker XDarwinApp \
-		-module -avoid-version -no-undefined
-fullscreen_la_DEPENDENCIES = XDarwinApp	
-
-if GLX
-glxMesaplugindir = $(darwinappdir)/Contents/Resources/glxMesa.bundle/Contents/MacOS
-glxMesaplugin_LTLIBRARIES =
-glxMesa_la_SOURCES =
-glxMesa_la_LIBADD = \
-		$(top_builddir)/GL/glx/libglx.la \
-		$(top_builddir)/GL/mesa/libGLcore.la 
-glxMesa_la_LDFLAGS = -shrext '' \
-		-Wl,-framework,AGL \
-		-Wl,-framework,OpenGL \
-		-XCClinker -ObjC \
-		-XCClinker -bundle_loader -XCClinker XDarwinApp \
-		-module -avoid-version -no-undefined
-glxMesa_la_DEPENDENCIES = XDarwinApp	
-endif
-
-endif
-
-xprplugindir = $(darwinappdir)/Contents/Resources/xpr.bundle/Contents/MacOS
-xprplugin_LTLIBRARIES =
-xpr_la_SOURCES =
-xpr_la_LIBADD = \
-		quartz/xpr/appledri.o \
-		quartz/xpr/dri.o \
-		quartz/xpr/xprAppleWM.o \
-		quartz/xpr/xprCursor.o \
-		quartz/xpr/xprFrame.o \
-		quartz/xpr/xprScreen.o \
-		quartz/xpr/x-hash.o \
-		quartz/xpr/x-hook.o \
-		quartz/xpr/x-list.o \
-		$(top_builddir)/miext/rootless/librootless.la \
-		$(top_builddir)/miext/rootless/safeAlpha/libsafeAlpha.la \
-		$(top_builddir)/miext/rootless/accel/librlAccel.la
-xpr_la_LDFLAGS = -shrext '' -Wl,-framework,ApplicationServices \
-		-lXplugin \
-		-XCClinker -bundle_loader -XCClinker XDarwinApp \
-		-module -avoid-version -no-undefined
-xpr_la_DEPENDENCIES = XDarwinApp	
-
-
-if HAVE_AGL_FRAMEWORK
-glxCGLplugindir = $(darwinappdir)/Contents/Resources/glxCGL.bundle/Contents/MacOS
-glxCGLplugin_LTLIBRARIES =
-glxCGL_la_SOURCES =
-glxCGL_la_LIBADD = \
-		$(top_builddir)/GL/glx/glxext.o \
-		$(top_builddir)/GL/glx/libglx.a \
-		$(top_builddir)/GL/apple/libAGLcore.a
-glxCGL_la_LDFLAGS = -shrext '' -Wl,-framework,ApplicationServices \
-		-Wl,-framework,AGL \
-		-Wl,-framework,OpenGL \
-		-XCClinker -ObjC \
-		-XCClinker -bundle_loader -XCClinker XDarwinApp \
-		-module -avoid-version -no-undefined
-glxCGL_la_DEPENDENCIES = XDarwinApp	
-
-
-glxAGLplugindir = $(darwinappdir)/Contents/Resources/glxAGL.bundle/Contents/MacOS
-glxAGLplugin_LTLIBRARIES =
-glxAGL_la_SOURCES =
-glxAGL_la_LIBADD = \
-		$(top_builddir)/GL/glx/glxext.o \
-		$(top_builddir)/GL/glx/libglx.a \
-		$(top_builddir)/GL/apple/libAGLcore.a
-glxAGL_la_LDFLAGS = -shrext '' \
-		-Wl,-framework,AGL \
-		-Wl,-framework,OpenGL \
-		-XCClinker -ObjC \
-		-XCClinker -bundle_loader -XCClinker XDarwinApp \
-		-module -avoid-version -no-undefined
-glxAGL_la_DEPENDENCIES = XDarwinApp	
+x11launcher:
+	cd launcher && xcodebuild CFLAGS="$(XSERVERCFLAGS_CFLAGS)" LDFLAGS="$(XSERVERCFLAGS_LIBS)"
 
+x11app-install-hook:
+	cd apple && xcodebuild install DSTROOT=$(DESTDIR) INSTALL_PATH=$(prefixdir) DEPLOYMENT_LOCATION=YES SKIP_INSTALL=NO
+	cd launcher && xcodebuild install DSTROOT=$(DESTDIR) INSTALL_PATH=$(APPLE_APPLICATIONS_DIR) DEPLOYMENT_LOCATION=YES SKIP_INSTALL=NO
 
+HOOK_TARGETS = x11app-install-hook
 
 endif
 
 man1_MANS = XDarwin.man
 
-uninstall-hook:
-	rm -rf $(DESTDIR)$(macosdir)/XDarwin
-
 install-data-hook: $(HOOK_TARGETS)
 
-xquartz-install-hook:
-	cd apple && xcodebuild install DSTROOT=$(DESTDIR) INSTALL_PATH=/usr/X11 DEPLOYMENT_LOCATION=YES SKIP_INSTALL=NO
-	cd launcher && xcodebuild install DSTROOT=$(DESTDIR) INSTALL_PATH=/Applications/Utilities DEPLOYMENT_LOCATION=YES SKIP_INSTALL=NO
- 
 EXTRA_DIST = \
 	darwin.c \
 	darwinClut8.h \
diff --git a/hw/darwin/quartz/Makefile.am b/hw/darwin/quartz/Makefile.am
index 0d236be..baa7d44 100644
--- a/hw/darwin/quartz/Makefile.am
+++ b/hw/darwin/quartz/Makefile.am
@@ -25,20 +25,6 @@ libXQuartz_a_SOURCES = \
 	          quartzStartup.c \
 	          pseudoramiX.c
 
-bin_PROGRAMS = XDarwinStartup
-
-XDarwinStartup_SOURCES = XDarwinStartup.c
-XDarwinStartup_LDFLAGS = -Wl,-framework,CoreFoundation \
-			 -Wl,-framework,ApplicationServices
-XDarwinStartupCFLAGS = -DXBINDIR="${bindir}"
-XDARWINROOT = @APPLE_APPLICATIONS_DIR@
-BINDIR = $(bindir)
-install-exec-local:
-	-(cd $(DESTDIR)$(BINDIR); rm X; $(LN_S) XDarwinStartup X)
-
-man1_MANS = XDarwinStartup.man
-
-
 EXTRA_DIST = \
 	applewmExt.h \
 	keysym2ucs.h \
commit 49b2fb096510e02d3e22e9f2ccf1290c332d47ef
Author: Ben Byer <bbyer at bbyer.local>
Date:   Mon Nov 12 00:27:30 2007 -0800

    Patch to fix various issues with the launcher, courtesy of Jeremy Huddleston

diff --git a/hw/darwin/launcher/bundle-main.c b/hw/darwin/launcher/bundle-main.c
index 988c04f..ca62553 100644
--- a/hw/darwin/launcher/bundle-main.c
+++ b/hw/darwin/launcher/bundle-main.c
@@ -37,7 +37,7 @@
 
 int main (int argc, char **argv) {
   char *command = DEFAULT_APP;
-  const char *newargv[5];
+  const char *newargv[7];
   int child;
   
 
@@ -60,8 +60,10 @@ int main (int argc, char **argv) {
 	newargv[0] = "/usr/bin/login";
 	newargv[1] = "-fp";
 	newargv[2] = getlogin();
-	newargv[3] = command;
-	newargv[4] = NULL;
+	newargv[3] = "/bin/sh";
+	newargv[4] = "-c";
+	newargv[5] = command;
+	newargv[6] = NULL;
 
     child = fork();
 	
commit 53ecf39fbf6a987f38ddbe12802c3a96d4ae625a
Author: Ben Byer <bbyer at bbyer.local>
Date:   Sun Nov 11 04:30:34 2007 -0800

    These changes are necessary, yet not sufficient, to get 8-bit indexed
    color mode working in Xquartz.

diff --git a/miext/rootless/rootlessCommon.c b/miext/rootless/rootlessCommon.c
index 9cbb7fa..03842e4 100644
--- a/miext/rootless/rootlessCommon.c
+++ b/miext/rootless/rootlessCommon.c
@@ -37,6 +37,7 @@
 #include <limits.h> /* For CHAR_BIT */
 
 #include "rootlessCommon.h"
+#include "colormapst.h"
 
 unsigned int rootless_CopyBytes_threshold = 0;
 unsigned int rootless_FillBytes_threshold = 0;
@@ -98,6 +99,41 @@ IsFramedWindow(WindowPtr pWin)
     return (top && WINREC(top));
 }
 
+Bool
+RootlessResolveColormap (ScreenPtr pScreen, int first_color,
+                         int n_colors, uint32_t *colors)
+{
+  int last, i;
+  ColormapPtr map;
+
+  map = RootlessGetColormap (pScreen);
+  if (map == NULL || map->class != PseudoColor) return FALSE;
+
+  last = MIN (map->pVisual->ColormapEntries, first_color + n_colors);
+  for (i = MAX (0, first_color); i < last; i++) {
+    Entry *ent = map->red + i;
+    uint16_t red, green, blue;
+
+      if (!ent->refcnt)	continue;
+      if (ent->fShared) {
+	red = ent->co.shco.red->color;
+	green = ent->co.shco.green->color;
+	blue = ent->co.shco.blue->color;
+      } else {
+	red = ent->co.local.red;
+	green = ent->co.local.green;
+	blue = ent->co.local.blue;
+      }
+
+      colors[i - first_color] = (0xFF000000UL
+				 | ((uint32_t) red & 0xff00) << 8
+				 | (green & 0xff00)
+				 | (blue >> 8));
+    }
+
+  return TRUE;
+}
+
 
 /*
  * RootlessStartDrawing
diff --git a/miext/rootless/rootlessCommon.h b/miext/rootless/rootlessCommon.h
index 3bf6af0..b002214 100644
--- a/miext/rootless/rootlessCommon.h
+++ b/miext/rootless/rootlessCommon.h
@@ -32,6 +32,7 @@
 #include <dix-config.h>
 #endif
 
+#include <stdint.h>
 #ifndef _ROOTLESSCOMMON_H
 #define _ROOTLESSCOMMON_H
 
@@ -104,13 +105,20 @@ typedef struct _RootlessScreenRec {
     GlyphsProcPtr Glyphs;
 #endif
 
+    InstallColormapProcPtr InstallColormap;
+    UninstallColormapProcPtr UninstallColormap;
+    StoreColorsProcPtr StoreColors;
+
     void *pixmap_data;
     unsigned int pixmap_data_size;
 
+    ColormapPtr colormap;
+
     void *redisplay_timer;
     unsigned int redisplay_timer_set :1;
     unsigned int redisplay_queued :1;
     unsigned int redisplay_expired :1;
+    unsigned int colormap_changed :1;
 } RootlessScreenRec, *RootlessScreenPtr;
 
 
@@ -251,6 +259,16 @@ void RootlessRedisplayScreen(ScreenPtr pScreen);
 
 void RootlessQueueRedisplay(ScreenPtr pScreen);
 
+/* Return the colormap currently installed on the given screen. */
+ColormapPtr RootlessGetColormap (ScreenPtr pScreen);
+
+/* Convert colormap to ARGB. */
+Bool RootlessResolveColormap (ScreenPtr pScreen, int first_color,
+			      int n_colors, uint32_t *colors);
+
+void RootlessFlushWindowColormap (WindowPtr pWin);
+void RootlessFlushScreenColormaps (ScreenPtr pScreen);
+
 // Move a window to its proper location on the screen.
 void RootlessRepositionWindow(WindowPtr pWin);
 
diff --git a/miext/rootless/rootlessScreen.c b/miext/rootless/rootlessScreen.c
index 356fec7..b314581 100644
--- a/miext/rootless/rootlessScreen.c
+++ b/miext/rootless/rootlessScreen.c
@@ -42,6 +42,7 @@
 #include "propertyst.h"
 #include "mivalidate.h"
 #include "picturestr.h"
+#include "colormapst.h"
 
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -469,6 +470,67 @@ RootlessMarkOverlappedWindows(WindowPtr pWin, WindowPtr pFirst,
     return result;
 }
 
+ColormapPtr
+RootlessGetColormap (ScreenPtr pScreen)
+{
+  RootlessScreenRec *s = SCREENREC (pScreen);
+
+  return s->colormap;
+}
+
+static void
+RootlessInstallColormap (ColormapPtr pMap)
+{
+  ScreenPtr pScreen = pMap->pScreen;
+  RootlessScreenRec *s = SCREENREC (pScreen);
+
+  SCREEN_UNWRAP(pScreen, InstallColormap);
+
+  if (s->colormap != pMap) {
+    s->colormap = pMap;
+    s->colormap_changed = TRUE;
+    RootlessQueueRedisplay (pScreen);
+  }
+
+  pScreen->InstallColormap (pMap);
+
+  SCREEN_WRAP (pScreen, InstallColormap);
+}
+
+static void
+RootlessUninstallColormap (ColormapPtr pMap)
+{
+  ScreenPtr pScreen = pMap->pScreen;
+  RootlessScreenRec *s = SCREENREC (pScreen);
+
+  SCREEN_UNWRAP(pScreen, UninstallColormap);
+
+  if (s->colormap == pMap)
+    s->colormap = NULL;
+
+  pScreen->UninstallColormap (pMap);
+
+  SCREEN_WRAP(pScreen, UninstallColormap);
+}
+
+static void
+RootlessStoreColors (ColormapPtr pMap, int ndef, xColorItem *pdef)
+{
+  ScreenPtr pScreen = pMap->pScreen;
+  RootlessScreenRec *s = SCREENREC (pScreen);
+
+  SCREEN_UNWRAP(pScreen, StoreColors);
+
+  if (s->colormap == pMap && ndef > 0) {
+    s->colormap_changed = TRUE;
+    RootlessQueueRedisplay (pScreen);
+  }
+
+  pScreen->StoreColors (pMap, ndef, pdef);
+
+  SCREEN_WRAP(pScreen, StoreColors);
+}
+
 
 static CARD32
 RootlessRedisplayCallback(OsTimerPtr timer, CARD32 time, void *arg)
@@ -616,6 +678,9 @@ RootlessWrap(ScreenPtr pScreen)
     WRAP(MarkOverlappedWindows);
     WRAP(ValidateTree);
     WRAP(ChangeWindowAttributes);
+    WRAP(InstallColormap);
+    WRAP(UninstallColormap);
+    WRAP(StoreColors);
 
 #ifdef SHAPE
     WRAP(SetShape);
diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index 84aa91d..cf32426 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -447,6 +447,12 @@ RootlessInitializeFrame(WindowPtr pWin, RootlessWindowRec *winRec)
 }
 
 
+Bool
+RootlessColormapCallback (void *data, int first_color, int n_colors, uint32_t *colors)
+{
+  return RootlessResolveColormap (data, first_color, n_colors, colors);
+}
+
 /*
  * RootlessEnsureFrame
  *  Make sure the given window is framed. If the window doesn't have a
@@ -505,6 +511,9 @@ RootlessEnsureFrame(WindowPtr pWin)
         return NULL;
     }
 
+    if (pWin->drawable.depth == 8)
+      RootlessFlushWindowColormap(pWin);
+
 #ifdef SHAPE
     if (pShape != NULL)
         REGION_UNINIT(pScreen, &shape);
@@ -1458,6 +1467,25 @@ out:
 }
 
 
+void
+RootlessFlushWindowColormap (WindowPtr pWin)
+{
+  RootlessWindowRec *winRec = WINREC (pWin);
+  xp_window_changes wc;
+
+  if (winRec == NULL)
+    return;
+
+  RootlessStopDrawing (pWin, FALSE);
+
+  /* This is how we tell xp that the colormap may have changed. */
+
+  wc.colormap = RootlessColormapCallback;
+  wc.colormap_data = pWin->drawable.pScreen;
+
+  configure_window (winRec->wid, XP_COLORMAP, &wc);
+}
+
 /*
  * SetPixmapOfAncestors
  *  Set the Pixmaps on all ParentRelative windows up the ancestor chain.
commit ec0d30011c7d9d59976a3a024faf118761892622
Author: Ben Byer <bbyer at bbyer.local>
Date:   Sun Nov 11 04:30:00 2007 -0800

    Fixed the call to xp_init so that we now receive Motion notifications even
    if X is not the active application.
    fixes <rdar://problem/5167664> xeyes dead until window activation

diff --git a/hw/darwin/quartz/xpr/xprScreen.c b/hw/darwin/quartz/xpr/xprScreen.c
index 5cb928f..e31d78e 100644
--- a/hw/darwin/quartz/xpr/xprScreen.c
+++ b/hw/darwin/quartz/xpr/xprScreen.c
@@ -229,7 +229,7 @@ xprDisplayInit(void)
     else
         darwinScreensFound =  1;
 
-    if (xp_init(XP_IN_BACKGROUND | XP_NO_DEFERRED_UPDATES) != Success)
+    if (xp_init(XP_BACKGROUND_EVENTS | XP_NO_DEFERRED_UPDATES) != Success)
         FatalError("Could not initialize the Xplugin library.");
 
     xp_select_events(XP_EVENT_DISPLAY_CHANGED
commit 10a5178258f0e794b69494a6994509cae08ac8f0
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Fri Nov 9 15:44:30 2007 -0800

    Fix {/usr/X11,/Applications/Utilities}/X11.app install targets to properly respect
    $DESTDIR.  Credit to Jeremy Huddleston

diff --git a/hw/darwin/Makefile.am b/hw/darwin/Makefile.am
index bfde6f6..6f9318d 100644
--- a/hw/darwin/Makefile.am
+++ b/hw/darwin/Makefile.am
@@ -303,9 +303,9 @@ uninstall-hook:
 install-data-hook: $(HOOK_TARGETS)
 
 xquartz-install-hook:
-	cd apple && xcodebuild install
-	cd launcher && xcodebuild install
-
+	cd apple && xcodebuild install DSTROOT=$(DESTDIR) INSTALL_PATH=/usr/X11 DEPLOYMENT_LOCATION=YES SKIP_INSTALL=NO
+	cd launcher && xcodebuild install DSTROOT=$(DESTDIR) INSTALL_PATH=/Applications/Utilities DEPLOYMENT_LOCATION=YES SKIP_INSTALL=NO
+ 
 EXTRA_DIST = \
 	darwin.c \
 	darwinClut8.h \
commit c213749b19b80a2757b6a4898d7d073937f14439
Author: Ben Byer <bbyer at bbyer.local>
Date:   Fri Nov 9 03:40:37 2007 -0800

    fixes to allow Xvfb and Xephyr to be built if you build with --disable-xdarwin

diff --git a/configure.ac b/configure.ac
index 3b6d385..0935d15 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1868,7 +1868,7 @@ if test "$KDRIVE" = yes; then
     KDRIVE_OS_INC='-I$(top_srcdir)/hw/kdrive/linux'
     KDRIVE_INCS="$KDRIVE_PURE_INCS $KDRIVE_OS_INC"
     
-    KDRIVE_CFLAGS="$XSERVER_CFLAGS -DHAVE_KDRIVE_CONFIG_H $TSLIB_CFLAGS"
+    KDRIVE_CFLAGS="$XSERVER_CFLAGS -DHAVE_KDRIVE_CONFIG_H $TSLIB_CFLAGS -fno-common"
 
     KDRIVE_PURE_LIBS="$FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB $OS_LIB"
     KDRIVE_LIB='$(top_builddir)/hw/kdrive/src/libkdrive.a'
diff --git a/dix/main.c b/dix/main.c
index 31e291b..80d8900 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -259,7 +259,7 @@ main(int argc, char *argv[], char *envp[])
     /* Quartz support on Mac OS X requires that the Cocoa event loop be in
      * the main thread. This allows the X server main to be called again
      * from another thread. */
-#if defined(__DARWIN__) && defined(DARWIN_WITH_QUARTZ)
+#ifdef DARWIN_WITH_QUARTZ
     DarwinHandleGUI(argc, argv, envp);
 #endif
 
diff --git a/hw/Makefile.am b/hw/Makefile.am
index a1918ab..db76977 100644
--- a/hw/Makefile.am
+++ b/hw/Makefile.am
@@ -22,7 +22,9 @@ if XPRINT
 XPRINT_SUBDIRS = xprint
 endif
 
+if XDARWIN
 DARWIN_SUBDIRS = darwin
+endif
 
 SUBDIRS =			\
 	$(XORG_SUBDIRS)		\
diff --git a/mi/miinitext.c b/mi/miinitext.c
index fa76070..6522890 100644
--- a/mi/miinitext.c
+++ b/mi/miinitext.c
@@ -673,10 +673,10 @@ InitVisualWrap()
 {
     miResetInitVisuals();
 #ifdef GLXEXT
-#ifndef __DARWIN__
-    GlxWrapInitVisuals(&miInitVisualsProc);
-#else
+#ifdef INXQUARTZ
     DarwinGlxWrapInitVisuals(&miInitVisualsProc);
+#else
+    GlxWrapInitVisuals(&miInitVisualsProc);
 #endif
 #endif
 }
commit 906c3195c96c5db200ca069fca4a5c13835ed780
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Thu Nov 8 22:17:38 2007 -0800

    fix for spurious "Are you sure you want to quit?" message

diff --git a/hw/darwin/quartz/quartz.c b/hw/darwin/quartz/quartz.c
index a0eb4ed..34f5e45 100644
--- a/hw/darwin/quartz/quartz.c
+++ b/hw/darwin/quartz/quartz.c
@@ -186,6 +186,7 @@ void DarwinModeInitInput(
     char **argv )
 {
 #ifdef INXQUARTZ
+    X11ApplicationSetCanQuit(1);
     X11ApplicationServerReady();
 #else
     QuartzMessageMainThread(kQuartzServerStarted, NULL, 0);
commit d54bb8fafa08f080dba2ad9e61c46222294bf69a
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Thu Nov 8 22:12:41 2007 -0800

    Adding "fake RandR" support from old X11.app

diff --git a/hw/darwin/quartz/quartz.c b/hw/darwin/quartz/quartz.c
index eccb4ef..a0eb4ed 100644
--- a/hw/darwin/quartz/quartz.c
+++ b/hw/darwin/quartz/quartz.c
@@ -52,6 +52,8 @@
 #include <fcntl.h>
 #include <IOKit/pwr_mgt/IOPMLib.h>
 
+#define FAKE_RANDR 1
+
 // Shared global variables for Quartz modes
 int                     quartzEventWriteFD = -1;
 int                     quartzStartClients = 1;
@@ -67,6 +69,30 @@ int                     noPseudoramiXExtension = FALSE;
 QuartzModeProcsPtr      quartzProcs = NULL;
 const char             *quartzOpenGLBundle = NULL;
 
+#if defined(RANDR) && !defined(FAKE_RANDR)
+Bool DarwinModeRandRGetInfo (ScreenPtr pScreen, Rotation *rotations) {
+  return FALSE;
+}
+
+Bool DarwinModeRandRSetConfig (ScreenPtr           pScreen,
+			       Rotation            randr,
+			       int                 rate,
+			       RRScreenSizePtr     pSize) {
+  return FALSE;
+}
+
+Bool DarwinModeRandRInit (ScreenPtr pScreen) {
+  rrScrPrivPtr    pScrPriv;
+    
+  if (!RRScreenInit (pScreen)) return FALSE;
+
+  pScrPriv = rrGetScrPriv(pScreen);
+  pScrPriv->rrGetInfo = DarwinModeRandRGetInfo;
+  pScrPriv->rrSetConfig = DarwinModeRandRSetConfig;
+  return TRUE;
+}
+#endif
+
 /*
 ===========================================================================
 
@@ -170,6 +196,51 @@ void DarwinModeInitInput(
 }
 
 
+#ifdef FAKE_RANDR
+extern char	*ConnectionInfo;
+
+static int padlength[4] = {0, 3, 2, 1};
+
+static void
+RREditConnectionInfo (ScreenPtr pScreen)
+{
+    xConnSetup	    *connSetup;
+    char	    *vendor;
+    xPixmapFormat   *formats;
+    xWindowRoot	    *root;
+    xDepth	    *depth;
+    xVisualType	    *visual;
+    int		    screen = 0;
+    int		    d;
+
+    connSetup = (xConnSetup *) ConnectionInfo;
+    vendor = (char *) connSetup + sizeof (xConnSetup);
+    formats = (xPixmapFormat *) ((char *) vendor +
+				 connSetup->nbytesVendor +
+				 padlength[connSetup->nbytesVendor & 3]);
+    root = (xWindowRoot *) ((char *) formats +
+			    sizeof (xPixmapFormat) * screenInfo.numPixmapFormats);
+    while (screen != pScreen->myNum)
+    {
+	depth = (xDepth *) ((char *) root + 
+			    sizeof (xWindowRoot));
+	for (d = 0; d < root->nDepths; d++)
+	{
+	    visual = (xVisualType *) ((char *) depth +
+				      sizeof (xDepth));
+	    depth = (xDepth *) ((char *) visual +
+				depth->nVisuals * sizeof (xVisualType));
+	}
+	root = (xWindowRoot *) ((char *) depth);
+	screen++;
+    }
+    root->pixWidth = pScreen->width;
+    root->pixHeight = pScreen->height;
+    root->mmWidth = pScreen->mmWidth;
+    root->mmHeight = pScreen->mmHeight;
+}
+#endif
+
 /*
  * QuartzUpdateScreens
  *  Adjust for screen arrangement changes.
@@ -181,6 +252,7 @@ static void QuartzUpdateScreens(void)
     int x, y, width, height, sx, sy;
     xEvent e;
 
+    ErrorF("QuartzUpdateScreens()\n");
     if (noPseudoramiXExtension || screenInfo.numScreens != 1)
     {
         /* FIXME: if not using Xinerama, we have multiple screens, and
@@ -202,8 +274,11 @@ static void QuartzUpdateScreens(void)
     pScreen->mmHeight = pScreen->mmHeight * ((double) height / pScreen->height);
     pScreen->width = width;
     pScreen->height = height;
-
-    /* FIXME: should probably do something with RandR here. */
+    
+#ifndef FAKE_RANDR
+    if(!DarwinModeRandRInit(pScreen))
+      FatalError("Failed to init RandR extension.\n");
+#endif
 
     DarwinAdjustScreenOrigins(&screenInfo);
     quartzProcs->UpdateScreen(pScreen);
@@ -231,7 +306,9 @@ static void QuartzUpdateScreens(void)
     e.u.configureNotify.override = pRoot->overrideRedirect;
     DeliverEvents(pRoot, &e, 1, NullWindow);
 
-    /* FIXME: Should we use RREditConnectionInfo(pScreen)? */
+#ifdef FAKE_RANDR
+    RREditConnectionInfo(pScreen);
+#endif
 }
 
 
commit 654d1019f358321f52ffac00d1710c3c22f129d1
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Thu Nov 8 18:49:05 2007 -0800

    Patch to rootless code that should fix many crashes.  Credit to Ken Thomases
    at CodeWeavers for the patch.  From his description:
    
    Fix a display bug with the X server.  The Generic Rootless extension
    installs overrides for certain GC (graphics context) operations.  Within
    these overrides, they temporarily uninstall themselves, perform their work,
    and then reinstall themselves.  Except sometimes they would return early
    and wouldn't reinstall themselves when they should.  Now they do in all cases.
    
    Fix a bug in RootlessCopyWindow where early returns could leave the screen's
    dispatch table entry for CopyWindow unwrapped.  We think that this is
    another case (hopefully the last) of the rootless drawing bug.

diff --git a/miext/rootless/rootlessGC.c b/miext/rootless/rootlessGC.c
index b26f52c..7e0778e 100644
--- a/miext/rootless/rootlessGC.c
+++ b/miext/rootless/rootlessGC.c
@@ -413,10 +413,12 @@ static void RootlessCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
 #define GC_IS_ROOT(pDst) ((pDst)->type == DRAWABLE_WINDOW \
                             && IsRoot ((WindowPtr) (pDst)))
 
-#define GC_SKIP_ROOT(pDst)			\
+#define GC_SKIP_ROOT(pDst, pGC)			\
     do {					\
-        if (GC_IS_ROOT (pDst))			\
+        if (GC_IS_ROOT (pDst)) {		\
+            GCOP_WRAP(pGC);			\
             return;				\
+        }					\
     } while (0)
 
 
@@ -426,7 +428,7 @@ RootlessFillSpans(DrawablePtr dst, GCPtr pGC, int nInit,
 {
     GC_SAVE(pGC);
     GCOP_UNWRAP(pGC);
-    GC_SKIP_ROOT(dst);
+    GC_SKIP_ROOT(dst, pGC);
     RL_DEBUG_MSG("fill spans start ");
 
     if (nInit <= 0) {
@@ -482,7 +484,7 @@ RootlessSetSpans(DrawablePtr dst, GCPtr pGC, char *pSrc,
                  int nspans, int sorted)
 {
     GCOP_UNWRAP(pGC);
-    GC_SKIP_ROOT(dst);
+    GC_SKIP_ROOT(dst, pGC);
     RL_DEBUG_MSG("set spans start ");
 
     if (nspans <= 0) {
@@ -533,7 +535,7 @@ RootlessPutImage(DrawablePtr dst, GCPtr pGC,
     BoxRec box;
 
     GCOP_UNWRAP(pGC);
-    GC_SKIP_ROOT(dst);
+    GC_SKIP_ROOT(dst, pGC);
     RL_DEBUG_MSG("put image start ");
 
     RootlessStartDrawing((WindowPtr) dst);
@@ -565,7 +567,10 @@ RootlessCopyArea(DrawablePtr pSrc, DrawablePtr dst, GCPtr pGC,
     GCOP_UNWRAP(pGC);
 
     if (GC_IS_ROOT(dst) || GC_IS_ROOT(pSrc))
+    {
+        GCOP_WRAP(pGC);
         return NULL;			/* nothing exposed */
+    }
 
     RL_DEBUG_MSG("copy area start (src 0x%x, dst 0x%x)", pSrc, dst);
 
@@ -615,7 +620,10 @@ static RegionPtr RootlessCopyPlane(DrawablePtr pSrc, DrawablePtr dst,
     GCOP_UNWRAP(pGC);
 
     if (GC_IS_ROOT(dst) || GC_IS_ROOT(pSrc))
+    {
+        GCOP_WRAP(pGC);
         return NULL;			/* nothing exposed */
+    }
 
     RL_DEBUG_MSG("copy plane start ");
 
@@ -652,7 +660,7 @@ static void RootlessPolyPoint(DrawablePtr dst, GCPtr pGC,
                               int mode, int npt, DDXPointPtr pptInit)
 {
     GCOP_UNWRAP(pGC);
-    GC_SKIP_ROOT(dst);
+    GC_SKIP_ROOT(dst, pGC);
     RL_DEBUG_MSG("polypoint start ");
 
     RootlessStartDrawing((WindowPtr) dst);
@@ -746,7 +754,7 @@ static void RootlessPolylines(DrawablePtr dst, GCPtr pGC,
                               int mode, int npt, DDXPointPtr pptInit)
 {
     GCOP_UNWRAP(pGC);
-    GC_SKIP_ROOT(dst);
+    GC_SKIP_ROOT(dst, pGC);
     RL_DEBUG_MSG("poly lines start ");
 
     RootlessStartDrawing((WindowPtr) dst);
@@ -821,7 +829,7 @@ static void RootlessPolySegment(DrawablePtr dst, GCPtr pGC,
                                 int nseg, xSegment *pSeg)
 {
     GCOP_UNWRAP(pGC);
-    GC_SKIP_ROOT(dst);
+    GC_SKIP_ROOT(dst, pGC);
     RL_DEBUG_MSG("poly segment start (win 0x%x)", dst);
 
     RootlessStartDrawing((WindowPtr) dst);
@@ -892,7 +900,7 @@ static void RootlessPolyRectangle(DrawablePtr dst, GCPtr pGC,
                                   int nRects, xRectangle *pRects)
 {
     GCOP_UNWRAP(pGC);
-    GC_SKIP_ROOT(dst);
+    GC_SKIP_ROOT(dst, pGC);
     RL_DEBUG_MSG("poly rectangle start ");
 
     RootlessStartDrawing((WindowPtr) dst);
@@ -953,7 +961,7 @@ static void RootlessPolyRectangle(DrawablePtr dst, GCPtr pGC,
 static void RootlessPolyArc(DrawablePtr dst, GCPtr pGC, int narcs, xArc *parcs)
 {
     GCOP_UNWRAP(pGC);
-    GC_SKIP_ROOT(dst);
+    GC_SKIP_ROOT(dst, pGC);
     RL_DEBUG_MSG("poly arc start ");
 
     RootlessStartDrawing((WindowPtr) dst);
@@ -1009,7 +1017,7 @@ static void RootlessFillPolygon(DrawablePtr dst, GCPtr pGC,
 {
     GC_SAVE(pGC);
     GCOP_UNWRAP(pGC);
-    GC_SKIP_ROOT(dst);
+    GC_SKIP_ROOT(dst, pGC);
     RL_DEBUG_MSG("fill poly start (win 0x%x, fillStyle 0x%x)", dst,
                  pGC->fillStyle);
 
@@ -1083,7 +1091,7 @@ static void RootlessPolyFillRect(DrawablePtr dst, GCPtr pGC,
 {
     GC_SAVE(pGC);
     GCOP_UNWRAP(pGC);
-    GC_SKIP_ROOT(dst);
+    GC_SKIP_ROOT(dst, pGC);
     RL_DEBUG_MSG("fill rect start (win 0x%x, fillStyle 0x%x)", dst,
                  pGC->fillStyle);
 
@@ -1138,7 +1146,7 @@ static void RootlessPolyFillArc(DrawablePtr dst, GCPtr pGC,
 {
     GC_SAVE(pGC);
     GCOP_UNWRAP(pGC);
-    GC_SKIP_ROOT(dst);
+    GC_SKIP_ROOT(dst, pGC);
     RL_DEBUG_MSG("fill arc start ");
 
     if (narcsInit > 0) {
@@ -1193,7 +1201,7 @@ static void RootlessImageText8(DrawablePtr dst, GCPtr pGC,
 {
     GC_SAVE(pGC);
     GCOP_UNWRAP(pGC);
-    GC_SKIP_ROOT(dst);
+    GC_SKIP_ROOT(dst, pGC);
     RL_DEBUG_MSG("imagetext8 start ");
 
     if (count > 0) {
@@ -1247,7 +1255,10 @@ static int RootlessPolyText8(DrawablePtr dst, GCPtr pGC,
     GCOP_UNWRAP(pGC);
 
     if (GC_IS_ROOT(dst))
+    {
+        GCOP_WRAP(pGC);
         return 0;
+    }
 
     RL_DEBUG_MSG("polytext8 start ");
 
@@ -1285,7 +1296,7 @@ static void RootlessImageText16(DrawablePtr dst, GCPtr pGC,
 {
     GC_SAVE(pGC);
     GCOP_UNWRAP(pGC);
-    GC_SKIP_ROOT(dst);
+    GC_SKIP_ROOT(dst, pGC);
     RL_DEBUG_MSG("imagetext16 start ");
 
     if (count > 0) {
@@ -1339,7 +1350,10 @@ static int RootlessPolyText16(DrawablePtr dst, GCPtr pGC,
     GCOP_UNWRAP(pGC);
 
     if (GC_IS_ROOT(dst))
+    {
+        GCOP_WRAP(pGC);
         return 0;
+    }
 
     RL_DEBUG_MSG("polytext16 start ");
 
@@ -1378,7 +1392,7 @@ static void RootlessImageGlyphBlt(DrawablePtr dst, GCPtr pGC,
 {
     GC_SAVE(pGC);
     GCOP_UNWRAP(pGC);
-    GC_SKIP_ROOT(dst);
+    GC_SKIP_ROOT(dst, pGC);
     RL_DEBUG_MSG("imageglyph start ");
 
     if (nglyphInit > 0) {
@@ -1439,7 +1453,7 @@ static void RootlessPolyGlyphBlt(DrawablePtr dst, GCPtr pGC,
                                  CharInfoPtr *ppci, pointer pglyphBase)
 {
     GCOP_UNWRAP(pGC);
-    GC_SKIP_ROOT(dst);
+    GC_SKIP_ROOT(dst, pGC);
     RL_DEBUG_MSG("polyglyph start ");
 
     RootlessStartDrawing((WindowPtr) dst);
@@ -1485,7 +1499,7 @@ RootlessPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr dst,
     BoxRec box;
 
     GCOP_UNWRAP(pGC);
-    GC_SKIP_ROOT(dst);
+    GC_SKIP_ROOT(dst, pGC);
     RL_DEBUG_MSG("push pixels start ");
 
     RootlessStartDrawing((WindowPtr) dst);
diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index 1aa0b77..84aa91d 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -838,13 +838,13 @@ RootlessCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
         top = TopLevelParent(pWin);
         if (top == NULL) {
             RL_DEBUG_MSG("no parent\n");
-            return;
+            goto out;
         }
 
         winRec = WINREC(top);
         if (winRec == NULL) {
             RL_DEBUG_MSG("not framed\n");
-            return;
+            goto out;
         }
 
         /* Move region to window local coords */
@@ -867,6 +867,7 @@ RootlessCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
         RootlessDamageRegion(pWin, prgnSrc);
     }
 
+out:
     REGION_UNINIT(pScreen, &rgnDst);
     fbValidateDrawable(&pWin->drawable);
 
commit 7768c63675f26e7a323e7101687be7087bacd9ea
Author: Ben Byer <bbyer at bbyer.local>
Date:   Wed Nov 7 03:56:44 2007 -0800

    formatting fixes

diff --git a/hw/darwin/apple/X11Application.m b/hw/darwin/apple/X11Application.m
index ba81820..f49429f 100644
--- a/hw/darwin/apple/X11Application.m
+++ b/hw/darwin/apple/X11Application.m
@@ -889,50 +889,42 @@ environment?", @"Startup xinitrc dialog");
 
 void
 X11ApplicationMain (int argc, const char *argv[],
-					void (*server_thread) (void *), void *server_arg)
+		    void (*server_thread) (void *), void *server_arg)
 {
-    NSAutoreleasePool *pool;
-	
+  NSAutoreleasePool *pool;
+  
 #ifdef DEBUG
-    while (access ("/tmp/x11-block", F_OK) == 0)
-		sleep (1);
+  while (access ("/tmp/x11-block", F_OK) == 0) sleep (1);
 #endif
-	
-    pool = [[NSAutoreleasePool alloc] init];
-	
-    X11App = (X11Application *) [X11Application sharedApplication];
-	
-    init_ports ();
-	
-    [NSApp read_defaults];
-	
-    [NSBundle loadNibNamed:@"main" owner:NSApp];
-	
-    [[NSNotificationCenter defaultCenter] addObserver:NSApp
-											 selector:@selector (became_key:)
-												 name:NSWindowDidBecomeKeyNotification object:nil];
-	
-    check_xinitrc ();
-	
-    /*
-     * The xpr Quartz mode is statically linked into this server.
-     * Initialize all the Quartz functions.
-     */
-    QuartzModeBundleInit();
-	
-    /* Calculate the height of the menubar so we can avoid it. */
-    aquaMenuBarHeight = NSHeight([[NSScreen mainScreen] frame]) -
-      NSMaxY([[NSScreen mainScreen] visibleFrame]);
-	
-    if (!create_thread (server_thread, server_arg))
-    {
-		fprintf (stderr, "can't create secondary thread\n");
-		exit (1);
-    }
-	
-    [NSApp run];
-	
-    /* not reached */
+  
+  pool = [[NSAutoreleasePool alloc] init];
+  X11App = (X11Application *) [X11Application sharedApplication];
+  init_ports ();
+  [NSApp read_defaults];
+  [NSBundle loadNibNamed:@"main" owner:NSApp];
+  [[NSNotificationCenter defaultCenter] addObserver:NSApp
+					selector:@selector (became_key:)
+					name:NSWindowDidBecomeKeyNotification object:nil];
+  check_xinitrc ();
+	
+  /*
+   * The xpr Quartz mode is statically linked into this server.
+   * Initialize all the Quartz functions.
+   */
+  QuartzModeBundleInit();
+  
+  /* Calculate the height of the menubar so we can avoid it. */
+  aquaMenuBarHeight = NSHeight([[NSScreen mainScreen] frame]) -
+    NSMaxY([[NSScreen mainScreen] visibleFrame]);
+  
+  if (!create_thread (server_thread, server_arg)) {
+    ErrorF("can't create secondary thread\n");
+    exit (1);
+  }
+  
+  [NSApp run];
+  
+  /* not reached */
 }
 
 
commit 6efdc6ca7bad159c4ac07882bba429320d8734e2
Author: Ben Byer <bbyer at bbyer.local>
Date:   Wed Nov 7 03:55:08 2007 -0800

    Fix for off-by-one error in menu bar height calculation -- props to Nicholas Riley!

diff --git a/hw/darwin/apple/X11Application.m b/hw/darwin/apple/X11Application.m
index 1ba0ce9..ba81820 100644
--- a/hw/darwin/apple/X11Application.m
+++ b/hw/darwin/apple/X11Application.m
@@ -922,7 +922,7 @@ X11ApplicationMain (int argc, const char *argv[],
 	
     /* Calculate the height of the menubar so we can avoid it. */
     aquaMenuBarHeight = NSHeight([[NSScreen mainScreen] frame]) -
-	NSMaxY([[NSScreen mainScreen] visibleFrame]) - 1;
+      NSMaxY([[NSScreen mainScreen] visibleFrame]);
 	
     if (!create_thread (server_thread, server_arg))
     {
commit 5d0c594e1dae6b63121d66a20ec4c64f3f4f851d
Author: Ben Byer <bbyer at bbyer.local>
Date:   Wed Nov 7 03:10:52 2007 -0800

    Undo some last-minute breakage in xpr.h

diff --git a/hw/darwin/quartz/xpr/xpr.h b/hw/darwin/quartz/xpr/xpr.h
index 09e85f5..ddc6d0c 100644
--- a/hw/darwin/quartz/xpr/xpr.h
+++ b/hw/darwin/quartz/xpr/xpr.h
@@ -37,8 +37,6 @@ void AppleDRIExtensionInit(void);
 void xprAppleWMInit(void);
 Bool xprInit(ScreenPtr pScreen);
 Bool xprIsX11Window(void *nsWindow, int windowNumber);
-WindowPtr xprGetX11Window(xp_window_id wid);
-WindowPtr xprGetXWindowFromAppKit(int windowNumber);
 
 void xprHideWindows(Bool hide);
 
commit cd7ab5324115f97dc817a03b4c66bfeb15981f19
Author: Ben Byer <bbyer at bbyer.local>
Date:   Wed Nov 7 02:28:49 2007 -0800

    removed debugging output

diff --git a/hw/darwin/quartz/quartz.c b/hw/darwin/quartz/quartz.c
index 113a7d2..eccb4ef 100644
--- a/hw/darwin/quartz/quartz.c
+++ b/hw/darwin/quartz/quartz.c
@@ -357,7 +357,7 @@ void DarwinModeProcessEvent(
             break;
 
         case kXDarwinActivate:
-	  ErrorF("kXDarwinActivate\n");
+  //	  ErrorF("kXDarwinActivate\n");
             QuartzShow(xe->u.keyButtonPointer.rootX,
                        xe->u.keyButtonPointer.rootY);
             AppleWMSendEvent(AppleWMActivationNotify,
@@ -366,7 +366,7 @@ void DarwinModeProcessEvent(
             break;
 
         case kXDarwinDeactivate:
-	  ErrorF("kXDarwinDeactivate\n");
+  //	  ErrorF("kXDarwinDeactivate\n");
             AppleWMSendEvent(AppleWMActivationNotify,
                              AppleWMActivationNotifyMask,
                              AppleWMIsInactive, 0);
@@ -374,18 +374,18 @@ void DarwinModeProcessEvent(
             break;
 
         case kXDarwinDisplayChanged:
-	  ErrorF("kXDarwinDisplayChanged\n");
+  //	  ErrorF("kXDarwinDisplayChanged\n");
             QuartzUpdateScreens();
             break;
 
         case kXDarwinWindowState:
-	  ErrorF("kXDarwinWindowState\n");
+  //	  ErrorF("kXDarwinWindowState\n");
             RootlessNativeWindowStateChanged(xe->u.clientMessage.u.l.longs0,
 		  			     xe->u.clientMessage.u.l.longs1);
 	    break;
 	  
         case kXDarwinWindowMoved:
-	  ErrorF("kXDarwinWindowMoved\n");
+  //	  ErrorF("kXDarwinWindowMoved\n");
             RootlessNativeWindowMoved (xe->u.clientMessage.u.l.longs0);
 	    break;
 
@@ -395,7 +395,7 @@ void DarwinModeProcessEvent(
             else if (quartzHasRoot) QuartzHide();
             else QuartzShow();
 #else
-	    ErrorF("kXDarwinToggleFullscreen not implemented\n");
+    //	    ErrorF("kXDarwinToggleFullscreen not implemented\n");
 #endif
             break;
 
@@ -404,7 +404,7 @@ void DarwinModeProcessEvent(
             QuartzSetRootless(xe->u.clientMessage.u.l.longs0);
             if (!quartzEnableRootless && !quartzHasRoot) QuartzHide();
 #else
-	    ErrorF("kXDarwinSetRootless not implemented\n");
+    //	    ErrorF("kXDarwinSetRootless not implemented\n");
 #endif
             break;
 
@@ -425,7 +425,7 @@ void DarwinModeProcessEvent(
             break;
 
         case kXDarwinBringAllToFront:
-	  ErrorF("kXDarwinBringAllToFront\n");
+  //	  ErrorF("kXDarwinBringAllToFront\n");
 	    RootlessOrderAllWindows();
             break;
 
commit c536ddf6ae6f80d7d2c7b02cb203b50a457b11c4
Author: Ben Byer <bbyer at bbyer.local>
Date:   Wed Nov 7 02:22:39 2007 -0800

    Fixed focus problem (clicking on an X11 window that sits behind
    an Aqua window would not always bring it to the top of the stack.

diff --git a/hw/darwin/apple/X11Application.m b/hw/darwin/apple/X11Application.m
index db02516..1ba0ce9 100644
--- a/hw/darwin/apple/X11Application.m
+++ b/hw/darwin/apple/X11Application.m
@@ -225,6 +225,8 @@ message_kit_thread (SEL selector, NSObject *arg)
       if (_x_active) [self activateX:NO];
     } else if ([self modalWindow] == nil) {
       /* Must be an X window. Tell appkit it doesn't have focus. */
+      WindowPtr pWin = xprGetXWindowFromAppKit([e windowNumber]);
+      if (pWin) RootlessReorderWindow(pWin);
       for_appkit = NO;
       
       if ([self isActive]) {
diff --git a/hw/darwin/quartz/xpr/xpr.h b/hw/darwin/quartz/xpr/xpr.h
index 81bb912..09e85f5 100644
--- a/hw/darwin/quartz/xpr/xpr.h
+++ b/hw/darwin/quartz/xpr/xpr.h
@@ -37,6 +37,9 @@ void AppleDRIExtensionInit(void);
 void xprAppleWMInit(void);
 Bool xprInit(ScreenPtr pScreen);
 Bool xprIsX11Window(void *nsWindow, int windowNumber);
+WindowPtr xprGetX11Window(xp_window_id wid);
+WindowPtr xprGetXWindowFromAppKit(int windowNumber);
+
 void xprHideWindows(Bool hide);
 
 Bool QuartzInitCursor(ScreenPtr pScreen);
diff --git a/hw/darwin/quartz/xpr/xprFrame.c b/hw/darwin/quartz/xpr/xprFrame.c
index 53fbb31..54b2035 100644
--- a/hw/darwin/quartz/xpr/xprFrame.c
+++ b/hw/darwin/quartz/xpr/xprFrame.c
@@ -425,6 +425,37 @@ xprGetXWindow(xp_window_id wid)
     return winRec != NULL ? winRec->win : NULL;
 }
 
+/*
+ * Given the id of a physical window, try to find the top-level (or root)
+ * X window that it represents.
+ */
+WindowPtr
+xprGetXWindowFromAppKit(int windowNumber)
+{
+    RootlessWindowRec *winRec;
+    Bool ret;
+    xp_window_id wid;
+
+    if (window_hash == NULL)
+        return FALSE;
+
+    /* need to lock, since this function can be called by any thread */
+
+    pthread_mutex_lock(&window_hash_mutex);
+
+    if (xp_lookup_native_window(windowNumber, &wid))
+        ret = xprGetXWindow(wid) != NULL;
+    else
+        ret = FALSE;
+
+    pthread_mutex_unlock(&window_hash_mutex);
+
+    if (!ret) return NULL;
+    winRec = x_hash_table_lookup(window_hash, (void *) wid, NULL);
+
+    return winRec != NULL ? winRec->win : NULL;
+}
+
 
 /*
  * The windowNumber is an AppKit window number. Returns TRUE if xpr is
commit 36fca3bc35e4544575372c3f94e4f86270e3c9c7
Author: Ben Byer <bbyer at bbyer.local>
Date:   Wed Nov 7 01:56:37 2007 -0800

    formatting changes.

diff --git a/hw/darwin/apple/X11Application.m b/hw/darwin/apple/X11Application.m
index cc28b18..db02516 100644
--- a/hw/darwin/apple/X11Application.m
+++ b/hw/darwin/apple/X11Application.m
@@ -207,140 +207,111 @@ message_kit_thread (SEL selector, NSObject *arg)
 
 - (void) sendEvent:(NSEvent *)e
 {
-    NSEventType type;
-    BOOL for_appkit, for_x;
-	
-    type = [e type];
-	
-    /* By default pass down the responder chain and to X. */
-    for_appkit = YES;
-    for_x = YES;
-	
-    switch (type)
-    {
-    case NSLeftMouseDown: case NSRightMouseDown: case NSOtherMouseDown:
-    case NSLeftMouseUp: case NSRightMouseUp: case NSOtherMouseUp:
-		if ([e window] != nil)
-		{
-			/* Pointer event has a window. Probably something for the kit. */
-			
-			for_x = NO;
-			
-			if (_x_active)
-				[self activateX:NO];
-		}
-		else if ([self modalWindow] == nil)
-		{
-			/* Must be an X window. Tell appkit it doesn't have focus. */
-			
-			for_appkit = NO;
-			
-			if ([self isActive])
-			{
-				[self deactivate];
-				
-				if (!_x_active && quartzProcs->IsX11Window([e window],
-														   [e windowNumber]))
-				[self activateX:YES];
-			}
-		}
-		break;
+  NSEventType type;
+  BOOL for_appkit, for_x;
+  
+  type = [e type];
+  
+  /* By default pass down the responder chain and to X. */
+  for_appkit = YES;
+  for_x = YES;
+  
+  switch (type) {
+  case NSLeftMouseDown: case NSRightMouseDown: case NSOtherMouseDown:
+  case NSLeftMouseUp: case NSRightMouseUp: case NSOtherMouseUp:
+    if ([e window] != nil) {
+      /* Pointer event has an (AppKit) window. Probably something for the kit. */
+      for_x = NO;
+      if (_x_active) [self activateX:NO];
+    } else if ([self modalWindow] == nil) {
+      /* Must be an X window. Tell appkit it doesn't have focus. */
+      for_appkit = NO;
+      
+      if ([self isActive]) {
+	[self deactivate];
+	
+	if (!_x_active && quartzProcs->IsX11Window([e window],
+						   [e windowNumber]))
+	  [self activateX:YES];
+      }
+    }
+    break;
 		
     case NSKeyDown: case NSKeyUp:
-		if (_x_active)
-		{
-			static int swallow_up;
-			
-			/* No kit window is focused, so send it to X. */
-			
-			for_appkit = NO;
-			
-			if (type == NSKeyDown)
-			{
-				/* Before that though, see if there are any global
-				 shortcuts bound to it. */
-				
-				if (X11EnableKeyEquivalents
-					&& [[self mainMenu] performKeyEquivalent:e])
-				{
-					swallow_up = [e keyCode];
-					for_x = NO;
-				}
-				else if (!quartzEnableRootless
-						 && ([e modifierFlags] & ALL_KEY_MASKS)
-						 == (NSCommandKeyMask | NSAlternateKeyMask)
-						 && ([e keyCode] == 0 /*a*/
-							 || [e keyCode] == 53 /*Esc*/))
-				{
-					swallow_up = 0;
-					for_x = NO;
+      if (_x_active) {
+	static int swallow_up;
+	
+	/* No kit window is focused, so send it to X. */
+	for_appkit = NO;
+	if (type == NSKeyDown) {
+	  /* Before that though, see if there are any global
+	     shortcuts bound to it. */
+	  
+	  if (X11EnableKeyEquivalents
+	      && [[self mainMenu] performKeyEquivalent:e]) {
+	    swallow_up = [e keyCode];
+	    for_x = NO;
+	  } else if (!quartzEnableRootless
+		     && ([e modifierFlags] & ALL_KEY_MASKS)
+		     == (NSCommandKeyMask | NSAlternateKeyMask)
+		     && ([e keyCode] == 0 /*a*/
+		      || [e keyCode] == 53 /*Esc*/)) {
+	    swallow_up = 0;
+	    for_x = NO;
 #ifdef DARWIN_DDX_MISSING
-					QuartzMessageServerThread (kXDarwinToggleFullscreen, 0);
+	    QuartzMessageServerThread (kXDarwinToggleFullscreen, 0);
 #endif
-				}
-			}
-			else
-			{
-				/* If we saw a key equivalent on the down, don't pass
-				 the up through to X. */
-				
-				if (swallow_up != 0 && [e keyCode] == swallow_up)
-				{
-					swallow_up = 0;
-					for_x = NO;
-				}
-			}
-		}
-		else
-		{
-			for_x = NO;
-		}
-		break;
-		
-    case NSFlagsChanged:
-		/* For the l33t X users who remap modifier keys to normal keysyms. */
-		if (!_x_active)
-			for_x = NO;
-		break;
-		
-    case NSAppKitDefined:
-		switch ([e subtype])
-		{
-		case NSApplicationActivatedEventType:
-			for_x = NO;
-			if ([self modalWindow] == nil)
-			{
-				for_appkit = NO;
-				
-				/* FIXME: hack to avoid having to pass the event to appkit,
-				 which would cause it to raise one of its windows. */
-				_appFlags._active = YES;
-				
-				[self activateX:YES];
-				if ([e data2] & 0x10) X11ApplicationSetFrontProcess();
-			}
-			break;
-			
-		case 18: /* ApplicationDidReactivate */
-			if (quartzHasRoot)
-				for_appkit = NO;
-			break;
-			
-		case NSApplicationDeactivatedEventType:
-			for_x = NO;
-			[self activateX:NO];
-			break;
-		}
-		break;
-		
-    default: break; /* for gcc */
+	  }
+	} else  {
+	  /* If we saw a key equivalent on the down, don't pass
+	     the up through to X. */
+	  
+	  if (swallow_up != 0 && [e keyCode] == swallow_up) {
+	    swallow_up = 0;
+	    for_x = NO;
+	  }
+	}
+      } else for_x = NO;
+      break;
+      
+  case NSFlagsChanged:
+    /* For the l33t X users who remap modifier keys to normal keysyms. */
+    if (!_x_active) for_x = NO;
+    break;
+    
+  case NSAppKitDefined:
+    switch ([e subtype]) {
+    case NSApplicationActivatedEventType:
+      for_x = NO;
+      if ([self modalWindow] == nil) {
+	for_appkit = NO;
+	
+	/* FIXME: hack to avoid having to pass the event to appkit,
+	   which would cause it to raise one of its windows. */
+	_appFlags._active = YES;
+	    
+	[self activateX:YES];
+	if ([e data2] & 0x10) X11ApplicationSetFrontProcess();
+      }
+      break;
+	
+      case 18: /* ApplicationDidReactivate */
+	if (quartzHasRoot) for_appkit = NO;
+	break;
+	
+    case NSApplicationDeactivatedEventType:
+      for_x = NO;
+      [self activateX:NO];
+      break;
     }
-	
-    if (for_appkit)
-		[super sendEvent:e];
-	
-    if (for_x)
-		send_nsevent (type, e);
+    break;
+    
+  default: break; /* for gcc */
+  }
+  
+  if (for_appkit) [super sendEvent:e];
+  
+  if (for_x) send_nsevent (type, e);
 }
 
 - (void) set_window_menu:(NSArray *)list
@@ -697,57 +668,53 @@ cfarray_to_nsarray (CFArrayRef in)
     const char *tem;
 	
     quartzUseSysBeep = [self prefs_get_boolean:@PREFS_SYSBEEP
-									   default:quartzUseSysBeep];
+                        default:quartzUseSysBeep];
     quartzEnableRootless = [self prefs_get_boolean:@PREFS_ROOTLESS
-										   default:quartzEnableRootless];
+                        default:quartzEnableRootless];
 #ifdef DARWIN_DDX_MISSING
     quartzFullscreenDisableHotkeys = ![self prefs_get_boolean:
-									   @PREFS_FULLSCREEN_HOTKEYS default:
-									   !quartzFullscreenDisableHotkeys];
+					      @PREFS_FULLSCREEN_HOTKEYS default:
+					      !quartzFullscreenDisableHotkeys];
     quartzXpluginOptions = [self prefs_get_integer:@PREFS_XP_OPTIONS
-										   default:quartzXpluginOptions];
+                            default:quartzXpluginOptions];
 #endif
 	
     darwinSwapAltMeta = [self prefs_get_boolean:@PREFS_SWAP_ALT_META
-										default:darwinSwapAltMeta];
+                         default:darwinSwapAltMeta];
     darwinFakeButtons = [self prefs_get_boolean:@PREFS_FAKEBUTTONS
-										default:darwinFakeButtons];
-    if (darwinFakeButtons)
-    {
-        const char *fake2, *fake3;
-		
-        fake2 = [self prefs_get_string:@PREFS_FAKE_BUTTON2 default:NULL];
-        fake3 = [self prefs_get_string:@PREFS_FAKE_BUTTON3 default:NULL];
-		
-		if (fake2 != NULL) darwinFakeMouse2Mask = DarwinParseModifierList(fake2);
-		if (fake3 != NULL) darwinFakeMouse3Mask = DarwinParseModifierList(fake3);
-		
+                         default:darwinFakeButtons];
+    if (darwinFakeButtons) {
+      const char *fake2, *fake3;
+      
+      fake2 = [self prefs_get_string:@PREFS_FAKE_BUTTON2 default:NULL];
+      fake3 = [self prefs_get_string:@PREFS_FAKE_BUTTON3 default:NULL];
+      
+      if (fake2 != NULL) darwinFakeMouse2Mask = DarwinParseModifierList(fake2);
+      if (fake3 != NULL) darwinFakeMouse3Mask = DarwinParseModifierList(fake3);
     }
 	
     X11EnableKeyEquivalents = [self prefs_get_boolean:@PREFS_KEYEQUIVS
-											  default:X11EnableKeyEquivalents];
+                               default:X11EnableKeyEquivalents];
 	
     darwinSyncKeymap = [self prefs_get_boolean:@PREFS_SYNC_KEYMAP
-									   default:darwinSyncKeymap];
+                        default:darwinSyncKeymap];
 	
     tem = [self prefs_get_string:@PREFS_KEYMAP_FILE default:NULL];
-    if (tem != NULL)
-		darwinKeymapFile = strdup (tem);
-    else
-        darwinKeymapFile = NULL;
+    if (tem != NULL) darwinKeymapFile = strdup (tem);
+    else             darwinKeymapFile = NULL;
 	
     darwinDesiredDepth = [self prefs_get_integer:@PREFS_DEPTH
-										 default:darwinDesiredDepth];
+                          default:darwinDesiredDepth];
 	
     enable_stereo = [self prefs_get_boolean:@PREFS_ENABLE_STEREO
-									default:false];
+                     default:false];
 }
 
 /* This will end up at the end of the responder chain. */
 - (void) copy:sender
 {
     QuartzMessageServerThread (kXDarwinPasteboardNotify, 1,
-							   AppleWMCopyToPasteboard);
+			       AppleWMCopyToPasteboard);
 }
 
 - (BOOL) x_active
@@ -991,135 +958,133 @@ convert_flags (unsigned int nsflags)
 static void
 send_nsevent (NSEventType type, NSEvent *e)
 {
-    static unsigned int button_state = 0;
-    NSRect screen;
-    NSPoint location;
-    NSWindow *window;
-    int pointer_x, pointer_y;
-    xEvent xe;
-	
-    memset (&xe, 0, sizeof (xe));
-	
-    /* This field should be filled in for every event */
-    xe.u.keyButtonPointer.time = GetTimeInMillis();
-
-	/* convert location to global top-left coordinates */
-	location = [e locationInWindow];
-	window = [e window];
-	screen = [[[NSScreen screens] objectAtIndex:0] frame];
-		
-	if (window != nil)	{
-		NSRect frame = [window frame];
-		pointer_x = location.x + frame.origin.x;
-		pointer_y = (((screen.origin.y + screen.size.height)
-					  - location.y) - frame.origin.y);
-	} else {
-		pointer_x = location.x;
-		pointer_y = (screen.origin.y + screen.size.height) - location.y;
-	}
-		
-	xe.u.keyButtonPointer.rootX = pointer_x;
-	xe.u.keyButtonPointer.rootY = pointer_y;
-	
-	switch (type) {
-		float count;
-		
-    case NSLeftMouseDown:
-		xe.u.u.type = ButtonPress;
-		xe.u.u.detail = 1;
-		goto do_press_event;
-		
-    case NSRightMouseDown:
-		xe.u.u.type = ButtonPress;
-		xe.u.u.detail = 3;
-		goto do_press_event;
-		
-    case NSOtherMouseDown:
-		xe.u.u.type = ButtonPress;
-		xe.u.u.detail = 2; /* FIXME? */
-		goto do_press_event;
-		
-do_press_event:
-		if (!quartzProcs->IsX11Window([e window], [e windowNumber])) {
-			/* X server doesn't grok this window, drop the event.
-			 
-			 Note: theoretically this isn't necessary, but if I click
-			 on the menubar, we get sent a LeftMouseDown when the
-			 release happens, but no LeftMouseUp is ever seen! */
-			
-			break;
-		}
-		goto do_event;
-		
-    case NSLeftMouseUp:
-		xe.u.u.type = ButtonRelease;
-		xe.u.u.detail = 1;
-		goto do_release_event;
-		
-    case NSRightMouseUp:
-		xe.u.u.type = ButtonRelease;
-		xe.u.u.detail = 3;
-		goto do_release_event;
-		
-    case NSOtherMouseUp:
-		xe.u.u.type = ButtonRelease;
-		xe.u.u.detail = 2; /* FIXME? */
-		goto do_release_event;
-		
-do_release_event:
-		if ((button_state & (1 << xe.u.u.detail)) == 0)
-		{
-			/* X didn't see the button press for this release, so skip it */
-			break;
-		}
-		goto do_event;
-		
-    case NSMouseMoved:
-    case NSLeftMouseDragged:
-    case NSRightMouseDragged:
-    case NSOtherMouseDragged:
-		xe.u.u.type = MotionNotify;
-		goto do_event;
-		
-    case NSKeyDown:
-		xe.u.u.type = KeyPress;
-		xe.u.u.detail = [e keyCode];
-		goto do_event;
-		
-    case NSKeyUp:
-		xe.u.u.type = KeyRelease;
-		xe.u.u.detail = [e keyCode];
-		goto do_event;
-		
-    case NSScrollWheel:
-		xe.u.keyButtonPointer.state = convert_flags ([e modifierFlags]);
-		count = [e deltaY];
-		xe.u.u.detail = count > 0.0f ? 4 : 5;
-		for (count = fabs(count); count > 0.0; count = count - 1.0f) {
-			xe.u.u.type = ButtonPress;
-			DarwinEQEnqueue(&xe);
-			xe.u.u.type = ButtonRelease;
-			DarwinEQEnqueue(&xe);
-		}
-		xe.u.u.type = 0;
-		break;
-		
-    case NSFlagsChanged:
-        xe.u.u.type = kXDarwinUpdateModifiers;
-        xe.u.clientMessage.u.l.longs0 = [e modifierFlags];
-        DarwinEQEnqueue (&xe);
-        break;
-		
-do_event:
-		//	xe.u.keyButtonPointer.state = convert_flags ([e modifierFlags]);
-		DarwinEQEnqueue (&xe);
-		break;
-		
-    default: break; /* for gcc */
+  static unsigned int button_state = 0;
+  NSRect screen;
+  NSPoint location;
+  NSWindow *window;
+  int pointer_x, pointer_y;
+  xEvent xe;
+  
+  memset (&xe, 0, sizeof (xe));
+  
+  /* This field should be filled in for every event */
+  xe.u.keyButtonPointer.time = GetTimeInMillis();
+  
+  /* convert location to global top-left coordinates */
+  location = [e locationInWindow];
+  window = [e window];
+  screen = [[[NSScreen screens] objectAtIndex:0] frame];
+  
+  if (window != nil)	{
+    NSRect frame = [window frame];
+    pointer_x = location.x + frame.origin.x;
+    pointer_y = (((screen.origin.y + screen.size.height)
+		  - location.y) - frame.origin.y);
+  } else {
+    pointer_x = location.x;
+    pointer_y = (screen.origin.y + screen.size.height) - location.y;
+  }
+  
+  xe.u.keyButtonPointer.rootX = pointer_x;
+  xe.u.keyButtonPointer.rootY = pointer_y;
+  
+  switch (type) {
+    float count;
+    
+  case NSLeftMouseDown:
+    xe.u.u.type = ButtonPress;
+    xe.u.u.detail = 1;
+    goto do_press_event;
+    
+  case NSRightMouseDown:
+    xe.u.u.type = ButtonPress;
+    xe.u.u.detail = 3;
+    goto do_press_event;
+    
+  case NSOtherMouseDown:
+    xe.u.u.type = ButtonPress;
+    xe.u.u.detail = 2; /* FIXME? */
+    goto do_press_event;
+    
+  do_press_event:
+    if (!quartzProcs->IsX11Window([e window], [e windowNumber])) {
+      /* X server doesn't grok this window, drop the event.
+	 
+	 Note: theoretically this isn't necessary, but if I click
+	 on the menubar, we get sent a LeftMouseDown when the
+	 release happens, but no LeftMouseUp is ever seen! */
+      
+      break;
     }
-	
-    if (xe.u.u.type == ButtonPress)
-		button_state |= (1 << xe.u.u.detail);
-    else if (xe.u.u.type == ButtonRelease)
-		button_state &= ~(1 << xe.u.u.detail);
+    goto do_event;
+    
+  case NSLeftMouseUp:
+    xe.u.u.type = ButtonRelease;
+    xe.u.u.detail = 1;
+    goto do_release_event;
+    
+  case NSRightMouseUp:
+    xe.u.u.type = ButtonRelease;
+    xe.u.u.detail = 3;
+    goto do_release_event;
+    
+  case NSOtherMouseUp:
+    xe.u.u.type = ButtonRelease;
+    xe.u.u.detail = 2; /* FIXME? */
+    goto do_release_event;
+    
+  do_release_event:
+    if ((button_state & (1 << xe.u.u.detail)) == 0)
+      {
+	/* X didn't see the button press for this release, so skip it */
+	break;
+      }
+    goto do_event;
+    
+  case NSMouseMoved:
+  case NSLeftMouseDragged:
+  case NSRightMouseDragged:
+  case NSOtherMouseDragged:
+    xe.u.u.type = MotionNotify;
+    goto do_event;
+    
+  case NSKeyDown:
+    xe.u.u.type = KeyPress;
+    xe.u.u.detail = [e keyCode];
+    goto do_event;
+    
+  case NSKeyUp:
+    xe.u.u.type = KeyRelease;
+    xe.u.u.detail = [e keyCode];
+    goto do_event;
+    
+  case NSScrollWheel:
+    xe.u.keyButtonPointer.state = convert_flags ([e modifierFlags]);
+    count = [e deltaY];
+    xe.u.u.detail = count > 0.0f ? 4 : 5;
+    for (count = fabs(count); count > 0.0; count = count - 1.0f) {
+      xe.u.u.type = ButtonPress;
+      DarwinEQEnqueue(&xe);
+      xe.u.u.type = ButtonRelease;
+      DarwinEQEnqueue(&xe);
+    }
+    xe.u.u.type = 0;
+    break;
+    
+  case NSFlagsChanged:
+    xe.u.u.type = kXDarwinUpdateModifiers;
+    xe.u.clientMessage.u.l.longs0 = [e modifierFlags];
+    DarwinEQEnqueue (&xe);
+    break;
+    
+  do_event:
+    //	xe.u.keyButtonPointer.state = convert_flags ([e modifierFlags]);
+    DarwinEQEnqueue (&xe);
+    break;
+    
+  default: break; /* for gcc */
+  }
+  
+  if (xe.u.u.type == ButtonPress) button_state |= (1 << xe.u.u.detail);
+  else if (xe.u.u.type == ButtonRelease) button_state &= ~(1 << xe.u.u.detail);
 }
commit 9a0ee8b746ed44952330eed4fac629b8934a07bf
Author: Ben Byer <bbyer at bbyer.local>
Date:   Wed Nov 7 01:35:48 2007 -0800

    Fixed Spaces issue, correctly -- dragging an X window from one
    Space to another in Expose mode now works.

diff --git a/hw/darwin/darwin.h b/hw/darwin/darwin.h
index 5981864..51e1004 100644
--- a/hw/darwin/darwin.h
+++ b/hw/darwin/darwin.h
@@ -131,7 +131,6 @@ enum {
             = LASTEvent+1,    // (from X.h list of event names)
     kXDarwinUpdateButtons,    // update state of mouse buttons 2 and up
     kXDarwinScrollWheel,      // scroll wheel event
-
     /*
      * Quartz-specific events -- not used in IOKit mode
      */
@@ -142,6 +141,8 @@ enum {
     kXDarwinReadPasteboard,   // copy Mac OS X pasteboard into X cut buffer
     kXDarwinWritePasteboard,  // copy X cut buffer onto Mac OS X pasteboard
     kXDarwinBringAllToFront,  // bring all X windows to front
+    kXDarwinToggleFullscreen, // Enable/Disable fullscreen mode
+    kXDarwinSetRootless,      // Set rootless mode
     /*
      * AppleWM events
      */
diff --git a/hw/darwin/quartz/quartz.c b/hw/darwin/quartz/quartz.c
index a24aeb1..113a7d2 100644
--- a/hw/darwin/quartz/quartz.c
+++ b/hw/darwin/quartz/quartz.c
@@ -342,8 +342,22 @@ void DarwinModeProcessEvent(
     xEvent *xe)
 {
     switch (xe->u.u.type) {
+        case kXDarwinControllerNotify:
+            AppleWMSendEvent(AppleWMControllerNotify,
+                             AppleWMControllerNotifyMask,
+                             xe->u.clientMessage.u.l.longs0,
+                             xe->u.clientMessage.u.l.longs1);
+            break;
+
+        case kXDarwinPasteboardNotify:
+            AppleWMSendEvent(AppleWMPasteboardNotify,
+                             AppleWMPasteboardNotifyMask,
+                             xe->u.clientMessage.u.l.longs0,
+                             xe->u.clientMessage.u.l.longs1);
+            break;
 
         case kXDarwinActivate:
+	  ErrorF("kXDarwinActivate\n");
             QuartzShow(xe->u.keyButtonPointer.rootX,
                        xe->u.keyButtonPointer.rootY);
             AppleWMSendEvent(AppleWMActivationNotify,
@@ -352,12 +366,48 @@ void DarwinModeProcessEvent(
             break;
 
         case kXDarwinDeactivate:
+	  ErrorF("kXDarwinDeactivate\n");
             AppleWMSendEvent(AppleWMActivationNotify,
                              AppleWMActivationNotifyMask,
                              AppleWMIsInactive, 0);
             QuartzHide();
             break;
 
+        case kXDarwinDisplayChanged:
+	  ErrorF("kXDarwinDisplayChanged\n");
+            QuartzUpdateScreens();
+            break;
+
+        case kXDarwinWindowState:
+	  ErrorF("kXDarwinWindowState\n");
+            RootlessNativeWindowStateChanged(xe->u.clientMessage.u.l.longs0,
+		  			     xe->u.clientMessage.u.l.longs1);
+	    break;
+	  
+        case kXDarwinWindowMoved:
+	  ErrorF("kXDarwinWindowMoved\n");
+            RootlessNativeWindowMoved (xe->u.clientMessage.u.l.longs0);
+	    break;
+
+        case kXDarwinToggleFullscreen:
+#ifdef DARWIN_DDX_MISSING
+            if (quartzEnableRootless) QuartzSetFullscreen(!quartzHasRoot);
+            else if (quartzHasRoot) QuartzHide();
+            else QuartzShow();
+#else
+	    ErrorF("kXDarwinToggleFullscreen not implemented\n");
+#endif
+            break;
+
+        case kXDarwinSetRootless:
+#ifdef DARWIN_DDX_MISSING
+            QuartzSetRootless(xe->u.clientMessage.u.l.longs0);
+            if (!quartzEnableRootless && !quartzHasRoot) QuartzHide();
+#else
+	    ErrorF("kXDarwinSetRootless not implemented\n");
+#endif
+            break;
+
         case kXDarwinSetRootClip:
             QuartzSetRootClip((BOOL)xe->u.clientMessage.u.l.longs0);
             break;
@@ -374,46 +424,13 @@ void DarwinModeProcessEvent(
             QuartzWritePasteboard();
             break;
 
-        /*
-         * AppleWM events
-         */
-        case kXDarwinControllerNotify:
-            AppleWMSendEvent(AppleWMControllerNotify,
-                             AppleWMControllerNotifyMask,
-                             xe->u.clientMessage.u.l.longs0,
-                             xe->u.clientMessage.u.l.longs1);
-            break;
-
-        case kXDarwinPasteboardNotify:
-            AppleWMSendEvent(AppleWMPasteboardNotify,
-                             AppleWMPasteboardNotifyMask,
-                             xe->u.clientMessage.u.l.longs0,
-                             xe->u.clientMessage.u.l.longs1);
-            break;
-
-        case kXDarwinDisplayChanged:
-            QuartzUpdateScreens();
-            break;
-
         case kXDarwinBringAllToFront:
+	  ErrorF("kXDarwinBringAllToFront\n");
 	    RootlessOrderAllWindows();
             break;
 
-        case kXDarwinWindowState:
-	  ErrorF("kXDarwinWindowState\n");
-	  break;
-    case kXDarwinWindowMoved: {
-	  WindowPtr pWin = (WindowPtr)xe->u.clientMessage.u.l.longs0;
-	  short x = xe->u.clientMessage.u.l.longs1,
-	        y = xe->u.clientMessage.u.l.longs2;
-	  ErrorF("kXDarwinWindowMoved(%p, %hd, %hd)\n", pWin, x, y);
-	  RootlessMoveWindow(pWin, x, y, pWin->nextSib, VTMove);
-    }
-	  break;
-
         default:
-            ErrorF("Unknown application defined event type %d.\n",
-                   xe->u.u.type);
+            ErrorF("Unknown application defined event type %d.\n", xe->u.u.type);
     }
 }
 
diff --git a/hw/darwin/quartz/quartz.h b/hw/darwin/quartz/quartz.h
index fa7499d..172f323 100644
--- a/hw/darwin/quartz/quartz.h
+++ b/hw/darwin/quartz/quartz.h
@@ -122,6 +122,7 @@ typedef struct _QuartzModeProcs {
 } QuartzModeProcsRec, *QuartzModeProcsPtr;
 
 extern QuartzModeProcsPtr quartzProcs;
+extern int quartzHasRoot, quartzEnableRootless;
 
 Bool QuartzLoadDisplayBundle(const char *dpyBundleName);
 
diff --git a/miext/rootless/rootless.h b/miext/rootless/rootless.h
index d9fdb6a..b4a5b2a 100644
--- a/miext/rootless/rootless.h
+++ b/miext/rootless/rootless.h
@@ -74,6 +74,8 @@ typedef struct _RootlessWindowRec {
 
     unsigned int is_drawing :1;	// Currently drawing?
     unsigned int is_reorder_pending :1;
+    unsigned int is_offscreen :1;
+    unsigned int is_obscured :1;
 } RootlessWindowRec, *RootlessWindowPtr;
 
 
diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index 1e06d2c..1aa0b77 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -36,13 +36,23 @@
 #include <stddef.h> /* For NULL */
 #include <limits.h> /* For CHAR_BIT */
 #include <assert.h>
+#ifdef __APPLE__
+//#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include "mi.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include <Xplugin.h>
+//#include <X11/extensions/applewm.h>
+extern int darwinMainScreenX, darwinMainScreenY;
+#endif
+#include "fb.h"
+
+#define AppleWMNumWindowLevels 5
 
 #include "rootlessCommon.h"
 #include "rootlessWindow.h"
 
-#include "fb.h"
-
-
 #ifdef ROOTLESS_GLOBAL_COORDS
 #define SCREEN_TO_GLOBAL_X \
     (dixScreenOrigins[pScreen->myNum].x + rootlessGlobalOffsetX)
@@ -53,6 +63,127 @@
 #define SCREEN_TO_GLOBAL_Y 0
 #endif
 
+#define DEFINE_ATOM_HELPER(func,atom_name)                      \
+  static Atom func (void) {                                       \
+    static unsigned int generation;                             \
+    static Atom atom;                                           \
+    if (generation != serverGeneration) {                       \
+      generation = serverGeneration;                          \
+      atom = MakeAtom (atom_name, strlen (atom_name), TRUE);  \
+    }                                                           \
+    return atom;                                                \
+  }
+
+DEFINE_ATOM_HELPER (xa_native_screen_origin, "_NATIVE_SCREEN_ORIGIN")
+DEFINE_ATOM_HELPER (xa_native_window_id, "_NATIVE_WINDOW_ID")
+DEFINE_ATOM_HELPER (xa_apple_no_order_in, "_APPLE_NO_ORDER_IN")
+
+static Bool no_configure_window;
+static Bool windows_hidden;
+// TODO - abstract xp functions
+
+static const int normal_window_levels[AppleWMNumWindowLevels+1] = {
+  0, 3, 4, 5, LONG_MIN + 30, LONG_MIN + 29,
+};
+static const int rooted_window_levels[AppleWMNumWindowLevels+1] = {
+  202, 203, 204, 205, 201, 200
+};
+
+static inline int
+configure_window (xp_window_id id, unsigned int mask,
+                  const xp_window_changes *values)
+{
+  if (!no_configure_window)
+    return xp_configure_window (id, mask, values);
+  else
+    return XP_Success;
+}
+
+/*static inline unsigned long
+current_time_in_seconds (void)
+{
+  unsigned long t = 0;
+
+  t += currentTime.milliseconds / 1000;
+  t += currentTime.months * 4294967;
+
+  return t;
+  } */
+
+static inline Bool
+rootlessHasRoot (ScreenPtr pScreen)
+{
+  return WINREC (WindowTable[pScreen->myNum]) != NULL;
+}
+
+void
+RootlessNativeWindowStateChanged (xp_window_id id, unsigned int state)
+{
+  WindowPtr pWin;
+  RootlessWindowRec *winRec;
+
+  pWin = xprGetXWindow (id);
+  if (pWin == NULL) return;
+
+  winRec = WINREC (pWin);
+  if (winRec == NULL) return;
+
+  winRec->is_offscreen = ((state & XP_WINDOW_STATE_OFFSCREEN) != 0);
+  winRec->is_obscured = ((state & XP_WINDOW_STATE_OBSCURED) != 0);
+  //  pWin->rootlessUnhittable = winRec->is_offscreen;
+}
+
+void
+RootlessNativeWindowMoved (WindowPtr pWin)
+{
+  xp_box bounds;
+  int sx, sy;
+  XID vlist[2];
+  Mask mask;
+  ClientPtr client;
+  RootlessWindowRec *winRec = WINREC(pWin);
+
+  if (xp_get_window_bounds (winRec->wid, &bounds) != Success) return;
+
+  sx = dixScreenOrigins[pWin->drawable.pScreen->myNum].x + darwinMainScreenX;
+  sy = dixScreenOrigins[pWin->drawable.pScreen->myNum].y + darwinMainScreenY;
+
+  /* Fake up a ConfigureWindow packet to resize the window to the current bounds. */
+
+  vlist[0] = (INT16) bounds.x1 - sx;
+  vlist[1] = (INT16) bounds.y1 - sy;
+  mask = CWX | CWY;
+
+  /* pretend we're the owner of the window! */
+  client = LookupClient (pWin->drawable.id, NullClient);
+
+  /* Don't want to do anything to the physical window (avoids 
+     notification-response feedback loops) */
+
+  no_configure_window = TRUE;
+  ConfigureWindow (pWin, mask, vlist, client);
+  no_configure_window = FALSE;
+}
+
+/* Updates the _NATIVE_SCREEN_ORIGIN property on the given root window. */
+static void
+set_screen_origin (WindowPtr pWin)
+{
+  long data[2];
+
+  if (!IsRoot (pWin))
+    return;
+
+  /* FIXME: move this to an extension? */
+
+  data[0] = (dixScreenOrigins[pWin->drawable.pScreen->myNum].x
+	     + darwinMainScreenX);
+  data[1] = (dixScreenOrigins[pWin->drawable.pScreen->myNum].y
+	     + darwinMainScreenY);
+
+  ChangeWindowProperty (pWin, xa_native_screen_origin (), XA_INTEGER,
+			32, PropModeReplace, 2, data, TRUE);
+}
 
 /*
  * RootlessCreateWindow
@@ -567,7 +698,6 @@ RootlessRestackWindow(WindowPtr pWin, WindowPtr pOldNextSib)
     RL_DEBUG_MSG("restackwindow end\n");
 }
 
-
 /*
  * Specialized window copy procedures
  */
commit ed161d013c57cdff6b40a8dea5139c304f812e8b
Author: Ben Byer <bbyer at bbyer.local>
Date:   Tue Nov 6 23:19:03 2007 -0800

    Fixed glx/DarwinGlx symbol problems; other servers (such as xvfb and xnest)
    should now be buildable from this code if you pass e.g. --enable-xvfb
    to configure.

diff --git a/configure.ac b/configure.ac
index cb2b622..3b6d385 100644
--- a/configure.ac
+++ b/configure.ac
@@ -728,10 +728,7 @@ if test "x$GLX" = xyes && ! test "x$MESA_SOURCE" = x; then
 	PKG_CHECK_MODULES([GL], [glproto >= 1.4.8])
 	AC_SUBST(XLIB_CFLAGS)
 	AC_DEFINE(GLXEXT, 1, [Build GLX extension])
-    case $host_os in
-      darwin*) GLX_LIBS='$(top_builddir)/GL/apple/indirect.o $(top_builddir)/GL/glx/libglx.la' ;;
-	  *)       GLX_LIBS='$(top_builddir)/GL/glx/libglx.la $(top_builddir)/GL/mesa/libGLcore.la' ;;
-	esac
+	GLX_LIBS='$(top_builddir)/GL/glx/libglx.la $(top_builddir)/GL/mesa/libGLcore.la'
 	test -d GL || mkdir GL
 	case $host_os in
 	  solaris*) 	
@@ -1745,7 +1742,8 @@ return 0;}
 #               LDFLAGS=$save_LDFLAGS
 #               ])
                xorg_cv_AGL_framework=no
-	       DARWIN_LIBS="$MI_LIB $OS_LIB $DIX_LIB $FB_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB"
+	       DARWIN_GLX_LIBS='$(top_builddir)/GL/apple/indirect.o $(top_builddir)/GL/glx/libglx.la'
+	       DARWIN_LIBS="$MI_LIB $OS_LIB $DIX_LIB $FB_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB $DARWIN_GLX_LIBS"
 	       AC_SUBST([DARWIN_LIBS])
                AC_CHECK_LIB([Xplugin],[xp_init],[:])
                AC_SUBST([APPLE_APPLICATIONS_DIR])
diff --git a/mi/miinitext.c b/mi/miinitext.c
index 8c34d01..fa76070 100644
--- a/mi/miinitext.c
+++ b/mi/miinitext.c
@@ -338,7 +338,7 @@ extern void XFree86DGAExtensionInit(INITARGS);
 #endif
 #ifdef GLXEXT
 typedef struct __GLXprovider __GLXprovider;
-#if defined(__DARWIN__) && !defined(INXQUARTZ)
+#if defined(__DARWIN__) && defined(INXDARWINAPP)
 extern __GLXprovider* __DarwinglXMesaProvider;
 extern void DarwinGlxPushProvider(__GLXprovider *impl);
 extern void DarwinGlxExtensionInit(INITARGS);
@@ -633,7 +633,7 @@ InitExtensions(argc, argv)
 #endif
 
 #ifdef GLXEXT
-#if defined(__DARWIN__) && !defined(INXQUARTZ)
+#if defined(__DARWIN__) && defined(INXDARWINAPP)
     DarwinGlxPushProvider(__DarwinglXMesaProvider);
     if (!noGlxExtension) DarwinGlxExtensionInit();
 #else
commit d24c85e5070d5544a63305adf01a4fa14b5c7e2b
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Mon Nov 5 20:25:10 2007 -0800

    formatting cleanup

diff --git a/hw/darwin/quartz/quartzKeyboard.c b/hw/darwin/quartz/quartzKeyboard.c
index 10fca0e..79028ef 100644
--- a/hw/darwin/quartz/quartzKeyboard.c
+++ b/hw/darwin/quartz/quartzKeyboard.c
@@ -1,10 +1,9 @@
 /*
    quartzKeyboard.c
 
-   Code to build a keymap using the Carbon Keyboard Layout API,
-   which is supported on Mac OS X 10.2 and newer.
+   Code to build a keymap using the Carbon Keyboard Layout API.
 
-   Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+   Copyright (c) 2003-2007 Apple, Inc.
 
    Permission is hereby granted, free of charge, to any person
    obtaining a copy of this software and associated documentation files
@@ -152,22 +151,17 @@ unsigned int
 DarwinModeSystemKeymapSeed (void)
 {
     static unsigned int seed;
-
     static KeyboardLayoutRef last_key_layout;
     KeyboardLayoutRef key_layout;
 
     KLGetCurrentKeyboardLayout (&key_layout);
-
-    if (key_layout != last_key_layout)
-        seed++;
-
+    if (key_layout != last_key_layout) seed++;
     last_key_layout = key_layout;
 
     return seed;
 }
 
-//static inline UniChar
-UniChar
+static inline UniChar
 macroman2ucs (unsigned char c)
 {
     /* Precalculated table mapping MacRoman-128 to Unicode. Generated
@@ -193,10 +187,8 @@ macroman2ucs (unsigned char c)
         0xaf, 0x2d8, 0x2d9, 0x2da, 0xb8, 0x2dd, 0x2db, 0x2c7,
     };
 
-    if (c < 128)
-        return c;
-    else
-        return table[c - 128];
+    if (c < 128) return c;
+    else         return table[c - 128];
 }
 
 static KeySym
@@ -205,10 +197,7 @@ make_dead_key (KeySym in)
     int i;
 
     for (i = 0; i < sizeof (dead_keys) / sizeof (dead_keys[0]); i++)
-    {
-        if (dead_keys[i].normal == in)
-            return dead_keys[i].dead;
-    }
+        if (dead_keys[i].normal == in) return dead_keys[i].dead;
 
     return in;
 }
@@ -252,53 +241,39 @@ DarwinModeReadSystemKeymap (darwinKeyboardInfo *info)
        an X11 keysym (which may just the bit that says "this is
        Unicode" if it can't find the real symbol.) */
 
-    for (i = 0; i < num_keycodes; i++)
-    {
+    for (i = 0; i < num_keycodes; i++) {
         static const int mods[4] = {0, MOD_SHIFT, MOD_OPTION,
                                     MOD_OPTION | MOD_SHIFT};
 
         k = info->keyMap + i * GLYPHS_PER_KEY;
 
-        for (j = 0; j < 4; j++)
-        {
-            if (is_uchr)
-            {
+        for (j = 0; j < 4; j++) {
+            if (is_uchr)  {
                 UniChar s[8];
                 UniCharCount len;
-                UInt32 dead_key_state, extra_dead;
+                UInt32 dead_key_state = 0, extra_dead = 0;
 
-                dead_key_state = 0;
                 err = UCKeyTranslate (chr_data, i, kUCKeyActionDown,
                                       mods[j] >> 8, keyboard_type, 0,
                                       &dead_key_state, 8, &len, s);
-                if (err != noErr)
-                    continue;
+                if (err != noErr) continue;
 
-                if (len == 0 && dead_key_state != 0)
-                {
+                if (len == 0 && dead_key_state != 0) {
                     /* Found a dead key. Work out which one it is, but
                        remembering that it's dead. */
-
-                    extra_dead = 0;
                     err = UCKeyTranslate (chr_data, i, kUCKeyActionDown,
                                           mods[j] >> 8, keyboard_type,
                                           kUCKeyTranslateNoDeadKeysMask,
                                           &extra_dead, 8, &len, s);
-                    if (err != noErr)
-                        continue;
+                    if (err != noErr) continue;
                 }
 
-                if (len > 0 && s[0] != 0x0010)
-                {
+                if (len > 0 && s[0] != 0x0010) {
                     k[j] = ucs2keysym (s[0]);
-    
-                    if (dead_key_state != 0)
-                        k[j] = make_dead_key (k[j]);
+                    if (dead_key_state != 0) k[j] = make_dead_key (k[j]);
                 }
-            }
-            else
-            {
-                UInt32 c, state = 0;
+            } else { // kchr
+	      UInt32 c, state = 0, state2 = 0;
                 UInt16 code;
 
                 code = i | mods[j];
@@ -310,67 +285,50 @@ DarwinModeReadSystemKeymap (darwinKeyboardInfo *info)
                    us the actual dead character. */
 
                 if (state != 0)
-                {
-                    UInt32 state2 = 0;
                     c = KeyTranslate (chr_data, code | 128, &state2);
-                }
 
                 /* Characters seem to be in MacRoman encoding. */
 
-                if (c != 0 && c != 0x0010)
-                {
+                if (c != 0 && c != 0x0010) {
                     k[j] = ucs2keysym (macroman2ucs (c & 255));
 
-                    if (state != 0)
-                        k[j] = make_dead_key (k[j]);
+                    if (state != 0) k[j] = make_dead_key (k[j]);
                 }
             }
         }
-
-        if (k[3] == k[2])
-            k[3] = NoSymbol;
-        if (k[2] == k[1])
-            k[2] = NoSymbol;
-        if (k[1] == k[0])
-            k[1] = NoSymbol;
-        if (k[0] == k[2] && k[1] == k[3])
-            k[2] = k[3] = NoSymbol;
+	
+        if (k[3] == k[2]) k[3] = NoSymbol;
+        if (k[2] == k[1]) k[2] = NoSymbol;
+        if (k[1] == k[0]) k[1] = NoSymbol;
+        if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol;
     }
 
     /* Fix up some things that are normally missing.. */
 
-    if (HACK_MISSING)
-    {
-        for (i = 0; i < sizeof (known_keys) / sizeof (known_keys[0]); i++)
-        {
+    if (HACK_MISSING) {
+        for (i = 0; i < sizeof (known_keys) / sizeof (known_keys[0]); i++) {
             k = info->keyMap + known_keys[i].keycode * GLYPHS_PER_KEY;
 
-            if (k[0] == NoSymbol && k[1] == NoSymbol
+            if    (k[0] == NoSymbol && k[1] == NoSymbol
                 && k[2] == NoSymbol && k[3] == NoSymbol)
-            {
-                k[0] = known_keys[i].keysym;
-            }
+	      k[0] = known_keys[i].keysym;
         }
     }
 
     /* And some more things. We find the right symbols for the numeric
        keypad, but not the KP_ keysyms. So try to convert known keycodes. */
 
-    if (HACK_KEYPAD)
-    {
+    if (HACK_KEYPAD) {
         for (i = 0; i < sizeof (known_numeric_keys)
-                        / sizeof (known_numeric_keys[0]); i++)
-        {
+                        / sizeof (known_numeric_keys[0]); i++) {
             k = info->keyMap + known_numeric_keys[i].keycode * GLYPHS_PER_KEY;
 
             if (k[0] == known_numeric_keys[i].normal)
-            {
                 k[0] = known_numeric_keys[i].keypad;
-            }
         }
     }
-	if(currentKeyLayoutRef)	CFRelease(currentKeyLayoutRef);
-
+    if(currentKeyLayoutRef)	CFRelease(currentKeyLayoutRef);
+    
     return TRUE;
 }
 
commit e8af07211f3a25ac290bfea7da091ecf4f483f6f
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Mon Nov 5 20:01:34 2007 -0800

    Fixed logic error that prevent JIS (Japanese) keyboard layouts from
    being detected.

diff --git a/hw/darwin/quartz/quartzKeyboard.c b/hw/darwin/quartz/quartzKeyboard.c
index 60f73e5..10fca0e 100644
--- a/hw/darwin/quartz/quartzKeyboard.c
+++ b/hw/darwin/quartz/quartzKeyboard.c
@@ -225,36 +225,27 @@ DarwinModeReadSystemKeymap (darwinKeyboardInfo *info)
     KeySym *k;
 
     TISInputSourceRef currentKeyLayoutRef = TISCopyCurrentKeyboardLayoutInputSource();
-	if (currentKeyLayoutRef)
-	{
-		CFDataRef currentKeyLayoutDataRef = (CFDataRef )TISGetInputSourceProperty(currentKeyLayoutRef, kTISPropertyUnicodeKeyLayoutData);
-		if (currentKeyLayoutDataRef)
-			chr_data = CFDataGetBytePtr(currentKeyLayoutDataRef);
-	}
-	
-	if(chr_data == NULL) {
-		KLGetCurrentKeyboardLayout (&key_layout);
-		KLGetKeyboardLayoutProperty (key_layout, kKLuchrData, &chr_data);
-
-		if (chr_data != NULL)
-		{
-			is_uchr = 1;
-			keyboard_type = LMGetKbdType ();
-		}
-		else
-		{
-			KLGetKeyboardLayoutProperty (key_layout, kKLKCHRData, &chr_data);
-
-			if (chr_data == NULL)
-			{
-				ErrorF ( "Couldn't get uchr or kchr resource\n");
-				return FALSE;
-			}
-
-			is_uchr = 0;
-			num_keycodes = 128;
-		}    
-	}
+    keyboard_type = LMGetKbdType ();
+    if (currentKeyLayoutRef) {
+      CFDataRef currentKeyLayoutDataRef = (CFDataRef )TISGetInputSourceProperty(currentKeyLayoutRef, kTISPropertyUnicodeKeyLayoutData);
+      if (currentKeyLayoutDataRef) chr_data = CFDataGetBytePtr(currentKeyLayoutDataRef);
+    }
+    
+    if (chr_data == NULL) {
+      KLGetCurrentKeyboardLayout (&key_layout);
+      KLGetKeyboardLayoutProperty (key_layout, kKLuchrData, &chr_data);
+    }
+    
+    if (chr_data == NULL) {
+      KLGetKeyboardLayoutProperty (key_layout, kKLKCHRData, &chr_data);
+      is_uchr = 0;
+      num_keycodes = 128;
+    }
+    
+    if (chr_data == NULL) {
+      ErrorF ( "Couldn't get uchr or kchr resource\n");
+      return FALSE;
+    }
 
     /* Scan the keycode range for the Unicode character that each
        key produces in the four shift states. Then convert that to
commit 83ef367458f3020e8a44f0dff5b506adbe7c43c5
Author: Ben Byer <bbyer at bbyer.local>
Date:   Sun Nov 4 19:14:10 2007 -0800

    Disable deferred updates in xp_init to fix performance problems
    -- thanks to Eric Gouriou for pointing out the issue

diff --git a/hw/darwin/quartz/xpr/xprScreen.c b/hw/darwin/quartz/xpr/xprScreen.c
index 18f6696..5cb928f 100644
--- a/hw/darwin/quartz/xpr/xprScreen.c
+++ b/hw/darwin/quartz/xpr/xprScreen.c
@@ -46,6 +46,10 @@
 # include "damage.h"
 #endif
 
+/* 10.4's deferred update makes X slower.. have to live with the tearing
+   for now.. */
+#define XP_NO_DEFERRED_UPDATES 8
+
 // Name of GLX bundle for native OpenGL
 static const char *xprOpenGLBundle = "glxCGL.bundle";
 
@@ -225,7 +229,7 @@ xprDisplayInit(void)
     else
         darwinScreensFound =  1;
 
-    if (xp_init(XP_IN_BACKGROUND) != Success)
+    if (xp_init(XP_IN_BACKGROUND | XP_NO_DEFERRED_UPDATES) != Success)
         FatalError("Could not initialize the Xplugin library.");
 
     xp_select_events(XP_EVENT_DISPLAY_CHANGED
commit 907129f62b775d5e4b1e26060f8e8433ee9aa042
Author: Ben Byer <bbyer at bbyer.local>
Date:   Sat Nov 3 05:34:19 2007 -0700

    Initial support for Spaces -- if you use Expose to drag an X11
    window to another Space, it will work correctly (as opposed
    to just leaving a ghost window).  We accomplish this by listening
    for the notification from Xplugin that our window has been moved,
    and then we ask X11 to move the window to the new location.

diff --git a/hw/darwin/quartz/quartz.c b/hw/darwin/quartz/quartz.c
index 8670e57..a24aeb1 100644
--- a/hw/darwin/quartz/quartz.c
+++ b/hw/darwin/quartz/quartz.c
@@ -400,9 +400,16 @@ void DarwinModeProcessEvent(
             break;
 
         case kXDarwinWindowState:
-        case kXDarwinWindowMoved:
-            // FIXME: Not implemented yet
-            break;
+	  ErrorF("kXDarwinWindowState\n");
+	  break;
+    case kXDarwinWindowMoved: {
+	  WindowPtr pWin = (WindowPtr)xe->u.clientMessage.u.l.longs0;
+	  short x = xe->u.clientMessage.u.l.longs1,
+	        y = xe->u.clientMessage.u.l.longs2;
+	  ErrorF("kXDarwinWindowMoved(%p, %hd, %hd)\n", pWin, x, y);
+	  RootlessMoveWindow(pWin, x, y, pWin->nextSib, VTMove);
+    }
+	  break;
 
         default:
             ErrorF("Unknown application defined event type %d.\n",
diff --git a/hw/darwin/quartz/xpr/xprFrame.c b/hw/darwin/quartz/xpr/xprFrame.c
index 0e3b200..53fbb31 100644
--- a/hw/darwin/quartz/xpr/xprFrame.c
+++ b/hw/darwin/quartz/xpr/xprFrame.c
@@ -68,6 +68,7 @@ static inline xp_error
 xprConfigureWindow(xp_window_id id, unsigned int mask,
                    const xp_window_changes *values)
 {
+  //  ErrorF("xprConfigureWindow()\n");
     if (!no_configure_window)
         return xp_configure_window(id, mask, values);
     else
@@ -185,7 +186,7 @@ xprMoveFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY)
 
     wc.x = newX;
     wc.y = newY;
-
+    //    ErrorF("xprMoveFrame(%d, %p, %d, %d)\n", wid, pScreen, newX, newY);
     xprConfigureWindow((xp_window_id) wid, XP_ORIGIN, &wc);
 }
 
@@ -411,7 +412,7 @@ xprInit(ScreenPtr pScreen)
  * Given the id of a physical window, try to find the top-level (or root)
  * X window that it represents.
  */
-static WindowPtr
+WindowPtr
 xprGetXWindow(xp_window_id wid)
 {
     RootlessWindowRec *winRec;
diff --git a/hw/darwin/quartz/xpr/xprScreen.c b/hw/darwin/quartz/xpr/xprScreen.c
index 4e0bdc2..18f6696 100644
--- a/hw/darwin/quartz/xpr/xprScreen.c
+++ b/hw/darwin/quartz/xpr/xprScreen.c
@@ -60,10 +60,12 @@ eventHandler(unsigned int type, const void *arg,
     switch (type)
     {
     case XP_EVENT_DISPLAY_CHANGED:
+      //      ErrorF("XP_EVENT_DISPLAY_MOVED\n");
         QuartzMessageServerThread(kXDarwinDisplayChanged, 0);
         break;
 
     case XP_EVENT_WINDOW_STATE_CHANGED:
+      //      ErrorF("XP_EVENT_WINDOW_STATE_CHANGED\n");
         if (arg_size >= sizeof(xp_window_state_event))
         {
             const xp_window_state_event *ws_arg = arg;
@@ -74,16 +76,24 @@ eventHandler(unsigned int type, const void *arg,
         break;
 
     case XP_EVENT_WINDOW_MOVED:
+      //      ErrorF("XP_EVENT_WINDOW_MOVED\n");
         if (arg_size == sizeof(xp_window_id))
         {
             xp_window_id id = * (xp_window_id *) arg;
-
-            QuartzMessageServerThread(kXDarwinWindowMoved, 1, id);
+	    WindowPtr pWin = xprGetXWindow(id);
+	    BoxRec box;
+	    xp_error retval  = xp_get_window_bounds(id, &box);
+	    if (retval != Success) {
+	      ErrorF("Unable to find new bounds for window\n");
+	      break;
+	    }
+            QuartzMessageServerThread(kXDarwinWindowMoved, 3, pWin, box.x1, box.y1);
         }
         break;
 
     case XP_EVENT_SURFACE_DESTROYED:
     case XP_EVENT_SURFACE_CHANGED:
+      //      ErrorF("XP_EVENT_SURFACE_MOVED\n");
         if (arg_size == sizeof(xp_surface_id))
         {
             int kind;
commit 0ed01da098aae93116a85df6c80ce46e4976b91c
Author: Ben Byer <bbyer at bbyer.local>
Date:   Fri Nov 2 02:59:29 2007 -0700

    Fix for focus issue:
    <rdar://problem/5289578> X11 menu bar uncoupled from X11 application's windows
    Credit to William Mortensen for submitting the first community patch!

diff --git a/hw/darwin/apple/X11Application.m b/hw/darwin/apple/X11Application.m
index afd495b..cc28b18 100644
--- a/hw/darwin/apple/X11Application.m
+++ b/hw/darwin/apple/X11Application.m
@@ -360,10 +360,7 @@ message_kit_thread (SEL selector, NSObject *arg)
 
 - (void) set_front_process:unused
 {
-    [NSApp activateIgnoringOtherApps:YES];
-	
-    if ([self modalWindow] == nil)
-		[self activateX:YES];
+    QuartzMessageServerThread(kXDarwinBringAllToFront, 0);
 }
 
 - (void) set_can_quit:(NSNumber *)state
diff --git a/hw/darwin/darwin.h b/hw/darwin/darwin.h
index fc4a58a..5981864 100644
--- a/hw/darwin/darwin.h
+++ b/hw/darwin/darwin.h
@@ -141,6 +141,7 @@ enum {
     kXDarwinQuit,             // kill the X server and release the display
     kXDarwinReadPasteboard,   // copy Mac OS X pasteboard into X cut buffer
     kXDarwinWritePasteboard,  // copy X cut buffer onto Mac OS X pasteboard
+    kXDarwinBringAllToFront,  // bring all X windows to front
     /*
      * AppleWM events
      */
diff --git a/hw/darwin/quartz/quartz.c b/hw/darwin/quartz/quartz.c
index 422bd17..8670e57 100644
--- a/hw/darwin/quartz/quartz.c
+++ b/hw/darwin/quartz/quartz.c
@@ -395,6 +395,10 @@ void DarwinModeProcessEvent(
             QuartzUpdateScreens();
             break;
 
+        case kXDarwinBringAllToFront:
+	    RootlessOrderAllWindows();
+            break;
+
         case kXDarwinWindowState:
         case kXDarwinWindowMoved:
             // FIXME: Not implemented yet
diff --git a/miext/rootless/rootless.h b/miext/rootless/rootless.h
index f83defe..d9fdb6a 100644
--- a/miext/rootless/rootless.h
+++ b/miext/rootless/rootless.h
@@ -432,4 +432,8 @@ void RootlessUpdateScreenPixmap(ScreenPtr pScreen);
  */
 void RootlessRepositionWindows(ScreenPtr pScreen);
 
+/*
+ * Bring all windows to the front of the Aqua stack
+ */
+void RootlessOrderAllWindows (void);
 #endif /* _ROOTLESS_H */
diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index 30b7daa..1e06d2c 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -1468,3 +1468,29 @@ RootlessChangeBorderWidth(WindowPtr pWin, unsigned int width)
 
     RL_DEBUG_MSG("change border width end\n");
 }
+
+/*
+ * RootlessOrderAllWindows
+ * Brings all X11 windows to the top of the window stack
+ * (i.e in front of Aqua windows) -- called when X11.app is given focus
+ */
+void
+RootlessOrderAllWindows (void)
+{
+    int i;
+    WindowPtr pWin;
+    
+    RL_DEBUG_MSG("RootlessOrderAllWindows() ");
+    for (i = 0; i < screenInfo.numScreens; i++) {
+      if (screenInfo.screens[i] == NULL) continue;
+      pWin = WindowTable[i];
+      if (pWin == NULL) continue;
+      
+      for (pWin = pWin->firstChild; pWin != NULL; pWin = pWin->nextSib) {
+	if (!pWin->realized) continue;
+	if (RootlessEnsureFrame(pWin) == NULL) continue;
+	RootlessReorderWindow (pWin);
+      }
+    }
+    RL_DEBUG_MSG("RootlessOrderAllWindows() done");
+}
commit 23cdc7027ad2ffb72841205b567618b07df6e324
Author: Ben Byer <bbyer at bbyer.local>
Date:   Wed Oct 31 23:46:50 2007 -0700

    Swap modifier keys for buttons 2 and 3 -- now Option-click is the middle click

diff --git a/hw/darwin/darwin.c b/hw/darwin/darwin.c
index 5500a5f..52fd170 100644
--- a/hw/darwin/darwin.c
+++ b/hw/darwin/darwin.c
@@ -96,8 +96,8 @@ int                     darwinSyncKeymap = FALSE;
 int                     darwinSwapAltMeta = FALSE;
 
 // modifier masks for faking mouse buttons
-int                     darwinFakeMouse2Mask = NX_COMMANDMASK;
-int                     darwinFakeMouse3Mask = NX_ALTERNATEMASK;
+int                     darwinFakeMouse2Mask = NX_ALTERNATEMASK;
+int                     darwinFakeMouse3Mask = NX_COMMANDMASK;
 
 // devices
 DeviceIntPtr            darwinPointer = NULL;
commit c42059a8ad0cf28328bd101e7c412ed73dd1302c
Author: Ben Byer <bbyer at bbyer.local>
Date:   Wed Oct 31 23:45:58 2007 -0700

    default for is_uchr should be 1, not 0

diff --git a/hw/darwin/quartz/quartzKeyboard.c b/hw/darwin/quartz/quartzKeyboard.c
index 3ecee3a..60f73e5 100644
--- a/hw/darwin/quartz/quartzKeyboard.c
+++ b/hw/darwin/quartz/quartzKeyboard.c
@@ -220,7 +220,7 @@ DarwinModeReadSystemKeymap (darwinKeyboardInfo *info)
     const void *chr_data = NULL;
     int num_keycodes = NUM_KEYCODES;
     UInt32 keyboard_type = 0;
-    int is_uchr = 0, i, j;
+    int is_uchr = 1, i, j;
     OSStatus err;
     KeySym *k;
 
commit 94c71a14059a43c3c717903a0a6ae732aed63a54
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Wed Oct 31 16:19:46 2007 -0700

    fixed an uninitialized variable, which caused keyboard breakage on x86
    when building with optimization enabled.

diff --git a/hw/darwin/quartz/quartzKeyboard.c b/hw/darwin/quartz/quartzKeyboard.c
index f9c5963..3ecee3a 100644
--- a/hw/darwin/quartz/quartzKeyboard.c
+++ b/hw/darwin/quartz/quartzKeyboard.c
@@ -220,7 +220,7 @@ DarwinModeReadSystemKeymap (darwinKeyboardInfo *info)
     const void *chr_data = NULL;
     int num_keycodes = NUM_KEYCODES;
     UInt32 keyboard_type = 0;
-    int is_uchr, i, j;
+    int is_uchr = 0, i, j;
     OSStatus err;
     KeySym *k;
 
commit 6a14175622cf2810756ac913445548b62c59cd2b
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Wed Oct 31 16:17:06 2007 -0700

    add -DROOTLESS_WORKAROUND to CFLAGS

diff --git a/configure.ac b/configure.ac
index ecc0aad..cb2b622 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1749,7 +1749,7 @@ return 0;}
 	       AC_SUBST([DARWIN_LIBS])
                AC_CHECK_LIB([Xplugin],[xp_init],[:])
                AC_SUBST([APPLE_APPLICATIONS_DIR])
-               CFLAGS="${CFLAGS} -D__DARWIN__ -DDARWIN_WITH_QUARTZ"
+               CFLAGS="${CFLAGS} -D__DARWIN__ -DDARWIN_WITH_QUARTZ -DROOTLESS_WORKAROUND"
                PLIST_VERSION_STRING=$PACKAGE_VERSION
                AC_SUBST([PLIST_VERSION_STRING])
                PLIST_VENDOR_WEB=$VENDOR_WEB
commit ed15fe4f52a21aaa4437da73628570c45f5795b2
Author: Ben Byer <bbyer at bbyer.local>
Date:   Wed Oct 31 04:09:32 2007 -0700

    fixed bug that prevented customized Applications menu items
    with arguments from working

diff --git a/hw/darwin/apple/X11Controller.m b/hw/darwin/apple/X11Controller.m
index cc039b1..a6a75d0 100644
--- a/hw/darwin/apple/X11Controller.m
+++ b/hw/darwin/apple/X11Controller.m
@@ -296,15 +296,17 @@
 - (void) launch_client:(NSString *)filename
 {
   const char *command = [filename UTF8String];
-  const char *argv[5];
+  const char *argv[7];
   int child1, child2 = 0;
   int status;
 	
   argv[0] = "/usr/bin/login";
   argv[1] = "-fp";
   argv[2] = getlogin();
-  argv[3] = command;
-  argv[4] = NULL;
+  argv[3] = "/bin/sh";
+  argv[4] = "-c";
+  argv[5] = command;
+  argv[6] = NULL;
     
   /* Do the fork-twice trick to avoid having to reap zombies */
     
commit a1c8b66164032c38b44172c6313f33b1fde6875c
Author: Ben Byer <bbyer at bbyer.local>
Date:   Wed Oct 31 04:08:06 2007 -0700

    fix incorrectly formatted .xinitrc warning

diff --git a/hw/darwin/apple/X11Application.m b/hw/darwin/apple/X11Application.m
index a4adc05..afd495b 100644
--- a/hw/darwin/apple/X11Application.m
+++ b/hw/darwin/apple/X11Application.m
@@ -895,12 +895,11 @@ check_xinitrc (void)
 	
     /* FIXME: put localized strings into Resources/English.lproj */
 	
-    msg = NSLocalizedString (
-							 @"You have an existing ~/.xinitrc file.\n\n\
-							 Windows displayed by X11 applications may not have titlebars, or may look \
-							 different to windows displayed by native applications.\n\n\
-							 Would you like to move aside the existing file and use the standard X11 \
-							 environment?", @"Startup xinitrc dialog");
+    msg = NSLocalizedString (@"You have an existing ~/.xinitrc file.\n\n\
+Windows displayed by X11 applications may not have titlebars, or may look \
+different to windows displayed by native applications.\n\n\
+Would you like to move aside the existing file and use the standard X11 \
+environment?", @"Startup xinitrc dialog");
 	
     if (NSRunAlertPanel (nil, msg, NSLocalizedString (@"Yes", @""),
 						 NSLocalizedString (@"No", @""), nil)
commit 005b7d637a04809c45fa526a58d3e62f96665c0f
Author: Ben Byer <bbyer at bbyer.local>
Date:   Wed Oct 31 03:39:47 2007 -0700

    Trap Deactivate messages and release modifiers to avoid "stuck shift lock" (etc) bugs

diff --git a/hw/darwin/darwinEvents.c b/hw/darwin/darwinEvents.c
index 6f3ec89..0367672 100644
--- a/hw/darwin/darwinEvents.c
+++ b/hw/darwin/darwinEvents.c
@@ -143,6 +143,16 @@ static void DarwinUpdateModifiers(
     }
 }
 
+/*
+ * DarwinReleaseModifiers
+ * This hacky function releases all modifier keys.  It should be called when X11.app
+ * is deactivated (kXDarwinDeactivate) to prevent modifiers from getting stuck if they
+ * are held down during a "context" switch -- otherwise, we would miss the KeyUp.
+ */
+static void DarwinReleaseModifiers(void) {
+	xEvent e;
+	DarwinUpdateModifiers(&e, KeyRelease, COMMAND_MASK(-1) | CONTROL_MASK(-1) | ALTERNATE_MASK(-1) | SHIFT_MASK(-1));
+}
 
 /*
  * DarwinSimulateMouseClick
@@ -343,6 +353,9 @@ void ProcessInputEvents(void) {
 	      ErrorF("Unexpected XDarwinScrollWheel event in DarwinProcessInputEvents\n");
 	      break;
 
+			case kXDarwinDeactivate:
+				DarwinReleaseModifiers();
+				// fall through
             default:
                 // Check for mode specific event
                 DarwinModeProcessEvent(&xe);
commit 579a051457a1fe64be616fabdee4ed111ae39f52
Author: Ben Byer <bbyer at bbyer.local>
Date:   Wed Oct 31 03:22:18 2007 -0700

    Workaround for a bug where the holding down Command to make a "fake"
    button 2 click would actually result in a Command-2 chord.
    (I.e. it wasn't releasing Command before clicking the fake button.)

diff --git a/hw/darwin/darwinEvents.c b/hw/darwin/darwinEvents.c
index d3abcc5..6f3ec89 100644
--- a/hw/darwin/darwinEvents.c
+++ b/hw/darwin/darwinEvents.c
@@ -162,6 +162,9 @@ static void DarwinSimulateMouseClick(
     int modifierMask)   // modifiers used for the fake click
 {
     // first fool X into forgetting about the keys
+	// for some reason, it's not enough to tell X we released the Command key -- 
+	// it has to be the *left* Command key.
+	if (modifierMask & NX_COMMANDMASK) modifierMask |=NX_DEVICELCMDKEYMASK ;
     DarwinUpdateModifiers(KeyRelease, modifierMask);
 
     // push the mouse button
commit d01986d5a955f7a6973291d630e0ac379ef068b1
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Tue Oct 30 20:00:21 2007 -0700

    DIX Fix:  QueryFontReply packets can be too big to be allocated on the stack

diff --git a/dix/dispatch.c b/dix/dispatch.c
index c313796..b4e8787 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -1402,7 +1402,7 @@ ProcQueryFont(ClientPtr client)
 	rlength = sizeof(xQueryFontReply) +
 	             FONTINFONPROPS(FONTCHARSET(pFont)) * sizeof(xFontProp)  +
 		     nprotoxcistructs * sizeof(xCharInfo);
-	reply = (xQueryFontReply *)ALLOCATE_LOCAL(rlength);
+	reply = (xQueryFontReply *)xalloc(rlength);
 	if(!reply)
 	{
 	    return(BadAlloc);
@@ -1414,7 +1414,7 @@ ProcQueryFont(ClientPtr client)
 	QueryFont( pFont, reply, nprotoxcistructs);
 
         WriteReplyToClient(client, rlength, reply);
-	DEALLOCATE_LOCAL(reply);
+	xfree(reply);
 	return(client->noClientException);
     }
 }
@@ -2260,7 +2260,7 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
 		length += widthBytesLine;
 	    }
 	}
-	if(!(pBuf = (char *) ALLOCATE_LOCAL(length)))
+	if(!(pBuf = (char *)xalloc(length)))
 	    return (BadAlloc);
 	WriteReplyToClient(client, sizeof (xGetImageReply), &xgi);
     }
@@ -2362,7 +2362,7 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
     if (pVisibleRegion)
 	REGION_DESTROY(pDraw->pScreen, pVisibleRegion);
     if (!im_return)
-	DEALLOCATE_LOCAL(pBuf);
+	xfree(pBuf);
     return (client->noClientException);
 }
 
commit 65c67205fde68411582d3af1e7b700ffde7b1f53
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Tue Oct 30 19:05:02 2007 -0700

    Enable PseudoramiX extension by default, like on the old server

diff --git a/hw/darwin/quartz/quartz.c b/hw/darwin/quartz/quartz.c
index ac555ec..422bd17 100644
--- a/hw/darwin/quartz/quartz.c
+++ b/hw/darwin/quartz/quartz.c
@@ -63,7 +63,7 @@ int                     quartzServerVisible = TRUE;
 int                     quartzServerQuitting = FALSE;
 int                     quartzScreenIndex = 0;
 int                     aquaMenuBarHeight = 0;
-int                     noPseudoramiXExtension = TRUE;
+int                     noPseudoramiXExtension = FALSE;
 QuartzModeProcsPtr      quartzProcs = NULL;
 const char             *quartzOpenGLBundle = NULL;
 
commit 37679cadf85b22f66890ba0fe93947a104ce8415
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Mon Oct 29 18:11:10 2007 -0700

    make dist fixes

diff --git a/hw/darwin/Makefile.am b/hw/darwin/Makefile.am
index 9222f57..bfde6f6 100644
--- a/hw/darwin/Makefile.am
+++ b/hw/darwin/Makefile.am
@@ -314,4 +314,16 @@ EXTRA_DIST = \
 	darwinKeyboard.c \
 	darwinKeyboard.h \
 	darwinXinput.c \
+	apple/X11Application.h \
+	apple/X11Controller.h \
+	apple/Info.plist \
+	apple/X11.icns \
+	apple/Xquartz.man \
+	apple/bundle-main.c \
+	apple/English.lproj/InfoPlist.strings \
+	apple/English.lproj/Localizable.strings \
+	apple/English.lproj/main.nib/classes.nib \
+	apple/English.lproj/main.nib/info.nib \
+	apple/English.lproj/main.nib/keyedobjects.nib \
+	apple/X11.xcodeproj/project.pbxproj \
 	XDarwin.man
diff --git a/hw/darwin/bundle/Makefile.am b/hw/darwin/bundle/Makefile.am
index dee34fd..f02be74 100644
--- a/hw/darwin/bundle/Makefile.am
+++ b/hw/darwin/bundle/Makefile.am
@@ -35,4 +35,5 @@ CLEANFILES = startXClients
 
 EXTRA_DIST = \
 	XDarwin.icns \
+	startXClients.cpp \
 	Info.plist
diff --git a/hw/darwin/quartz/xpr/Makefile.am b/hw/darwin/quartz/xpr/Makefile.am
index 980c7a4..7ebcba7 100644
--- a/hw/darwin/quartz/xpr/Makefile.am
+++ b/hw/darwin/quartz/xpr/Makefile.am
@@ -22,6 +22,8 @@ xprbundledir = @APPLE_APPLICATIONS_DIR@/Resources/xpr.bundle/Contents/MacOS
 EXTRA_DIST = \
 	dri.h \
 	dristruct.h \
+	appledri.h \
+	appledristr.h \
 	x-hash.h \
 	x-hook.h \
 	x-list.h \
diff --git a/hw/darwin/utils/Makefile.am b/hw/darwin/utils/Makefile.am
index 92bf151..76cb793 100644
--- a/hw/darwin/utils/Makefile.am
+++ b/hw/darwin/utils/Makefile.am
@@ -8,5 +8,6 @@ man1_MANS = dumpkeymap.man
 
 EXTRA_DIST = \
 	     README.txt \
+	     event_status_driver.h \
 	     dumpkeymap.man
 
commit cfdf2fa2814e3d28f721794d5624fc236bdbcbf2
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Mon Oct 29 16:18:48 2007 -0700

    Added patch fix yellow-cursor problem which appears on some Intel Macs

diff --git a/hw/darwin/quartz/xpr/xprCursor.c b/hw/darwin/quartz/xpr/xprCursor.c
index 570ef0b..02260bd 100644
--- a/hw/darwin/quartz/xpr/xprCursor.c
+++ b/hw/darwin/quartz/xpr/xprCursor.c
@@ -83,8 +83,17 @@ load_cursor(CursorPtr src, int screen)
 #ifdef ARGB_CURSOR
     if (src->bits->argb != NULL)
     {
-        rowbytes = src->bits->width * sizeof(CARD32);
+#if BITMAP_BIT_ORDER == MSBFirst
+        rowbytes = src->bits->width * sizeof (CARD32);
         data = (uint32_t *) src->bits->argb;
+#else
+        const uint32_t *be_data=(uint32_t *) src->bits->argb;
+        unsigned i;
+        rowbytes = src->bits->width * sizeof (CARD32);
+        data=alloca (rowbytes * src->bits->height);
+        for(i=0;i<(src->bits->width*src->bits->height);i++)
+            data[i]=ntohl(be_data[i]);
+#endif
     }
     else
 #endif
commit a2a2bbfe84afe15374b73808a94cf2cb0ae68822
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Mon Oct 29 16:15:22 2007 -0700

    Some autoconf hacks to make 'make dist' work correctly

diff --git a/configure.ac b/configure.ac
index 1a9e274..ecc0aad 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2087,7 +2087,6 @@ hw/xfree86/os-support/misc/Makefile
 hw/xfree86/os-support/linux/Makefile
 hw/xfree86/os-support/lynxos/Makefile
 hw/xfree86/os-support/sco/Makefile
-hw/xfree86/os-support/solaris/Makefile
 hw/xfree86/os-support/sysv/Makefile
 hw/xfree86/os-support/usl/Makefile
 hw/xfree86/parser/Makefile
commit 616ba3c7d685bcc48b0f43eb1153f331ccd14d6e
Author: Ben Byer <bbyer at bbyer.local>
Date:   Mon Oct 29 00:07:29 2007 -0700

    finished committing downstream changes

diff --git a/GL/Makefile.am b/GL/Makefile.am
index df9f533..4e8337a 100644
--- a/GL/Makefile.am
+++ b/GL/Makefile.am
@@ -1,11 +1,4 @@
-# someone could get really crazy someday and add support for the SI...
-
-# xwin/darwin/xfree86 have their accel support under the DDX
-
-if BUILD_DARWIN
-DARWIN_SUBDIRS = apple
-endif
-SUBDIRS = glx mesa $(DARWIN_SUBDIRS)
+SUBDIRS = glx mesa apple
 
 WINDOWS_EXTRAS = \
 	windows/ChangeLog \
diff --git a/configure.ac b/configure.ac
index 282676b..1a9e274 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1749,7 +1749,7 @@ return 0;}
 	       AC_SUBST([DARWIN_LIBS])
                AC_CHECK_LIB([Xplugin],[xp_init],[:])
                AC_SUBST([APPLE_APPLICATIONS_DIR])
-               CFLAGS="${CFLAGS} -D__DARWIN__"
+               CFLAGS="${CFLAGS} -D__DARWIN__ -DDARWIN_WITH_QUARTZ"
                PLIST_VERSION_STRING=$PACKAGE_VERSION
                AC_SUBST([PLIST_VERSION_STRING])
                PLIST_VENDOR_WEB=$VENDOR_WEB
diff --git a/dix/dixfonts.c b/dix/dixfonts.c
index c21b3ec..355ef8a 100644
--- a/dix/dixfonts.c
+++ b/dix/dixfonts.c
@@ -1628,9 +1628,9 @@ FreeFontPath(FontPathElementPtr *list, int n, Bool force)
 		    found++;
 	    }
 	    if (list[i]->refcount != found) {
-		ErrorF("FreeFontPath: FPE \"%.*s\" refcount is %d, should be %d; fixing.\n",
+	      /*		ErrorF("FreeFontPath: FPE \"%.*s\" refcount is %d, should be %d; fixing.\n",
 		       list[i]->name_length, list[i]->name,
-		       list[i]->refcount, found);
+		       list[i]->refcount, found); */
 		list[i]->refcount = found; /* ensure it will get freed */
 	    }
 	}
diff --git a/hw/Makefile.am b/hw/Makefile.am
index 99df8e2..a1918ab 100644
--- a/hw/Makefile.am
+++ b/hw/Makefile.am
@@ -1,19 +1,3 @@
-if DMX
-if BUILD_DARWIN
-# Darwin does not need the dmx subdir
-else
-DMX_SUBDIRS = dmx
-endif
-endif
-
-if XORG
-if BUILD_DARWIN
-# Darwin does not need the xfree86 subdir
-else
-XORG_SUBDIRS = xfree86
-endif
-endif
-
 if XVFB
 XVFB_SUBDIRS = vfb
 endif
@@ -38,19 +22,17 @@ if XPRINT
 XPRINT_SUBDIRS = xprint
 endif
 
-if BUILD_DARWIN
 DARWIN_SUBDIRS = darwin
-endif
 
 SUBDIRS =			\
 	$(XORG_SUBDIRS)		\
 	$(XGL_SUBDIRS)		\
 	$(XWIN_SUBDIRS)		\
-	$(DARWIN_SUBDIRS)	\
 	$(XVFB_SUBDIRS)		\
 	$(XNEST_SUBDIRS)	\
 	$(DMX_SUBDIRS)          \
         $(KDRIVE_SUBDIRS)	\
+        $(DARWIN_SUBDIRS)	\
 	$(XPRINT_SUBDIRS)
 
 DIST_SUBDIRS = dmx xfree86 vfb xnest xwin darwin kdrive xgl xprint
diff --git a/hw/darwin/Makefile.am b/hw/darwin/Makefile.am
index aa4fbee..9222f57 100644
--- a/hw/darwin/Makefile.am
+++ b/hw/darwin/Makefile.am
@@ -1,6 +1,7 @@
 noinst_LIBRARIES = libdarwinShared.a
 libdarwin_XINPUT_SRCS = darwinXinput.c
 
+# -O2 inexplicably causes quartzKeyboard.o to break?!
 AM_CFLAGS = @XORG_CFLAGS@
 INCLUDES = @XORG_INCS@ -I../../miext/rootless
 
@@ -79,7 +80,7 @@ XDarwin_LDADD = \
 		$(top_builddir)/miext/rootless/librootless.la \
 		$(top_builddir)/miext/rootless/safeAlpha/libsafeAlpha.la \
 		$(top_builddir)/miext/rootless/accel/librlAccel.la \
-		$(XSERVER_LIBS)
+		$(XSERVER_LIBS) -lXplugin
 
 Xquartz_LDADD = \
 		$(top_builddir)/dix/dixfonts.lo \
@@ -105,7 +106,7 @@ Xquartz_LDADD = \
 		$(top_builddir)/miext/rootless/librootless.la \
 		$(top_builddir)/miext/rootless/safeAlpha/libsafeAlpha.la \
 		$(top_builddir)/miext/rootless/accel/librlAccel.la \
-		$(XSERVER_LIBS)
+		$(DARWIN_LIBS) $(XSERVER_LIBS) -lXplugin
 
 XDarwin_LDFLAGS =  \
                  -XCClinker -Objc \
diff --git a/hw/darwin/quartz/quartzKeyboard.c b/hw/darwin/quartz/quartzKeyboard.c
index b330793..f9c5963 100644
--- a/hw/darwin/quartz/quartzKeyboard.c
+++ b/hw/darwin/quartz/quartzKeyboard.c
@@ -166,7 +166,8 @@ DarwinModeSystemKeymapSeed (void)
     return seed;
 }
 
-static inline UniChar
+//static inline UniChar
+UniChar
 macroman2ucs (unsigned char c)
 {
     /* Precalculated table mapping MacRoman-128 to Unicode. Generated
commit b8e6c80c0d66d7cd580d7f8900a61a6bc65dad74
Author: Ben Byer <bbyer at bbyer.local>
Date:   Sun Oct 28 17:22:16 2007 -0700

    more patches, autoconf fixes...

diff --git a/configure.ac b/configure.ac
index e1e77f5..282676b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -95,6 +95,8 @@ AC_HEADER_DIRENT
 AC_HEADER_STDC
 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h])
 
+AC_CHECK_PROG(HAVE_LAUNCHD, [launchd], [yes], [])
+
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
 AC_C_BIGENDIAN([ENDIAN="X_BIG_ENDIAN"], [ENDIAN="X_LITTLE_ENDIAN"])
@@ -181,6 +183,7 @@ AC_CHECK_FUNC([getpeerucred],
 	AC_DEFINE(HAS_GETPEERUCRED, 1, [Have the 'getpeerucred' function.]))
 AC_CHECK_FUNC([strlcat], HAVE_STRLCAT=yes, HAVE_STRLCAT=no)
 AM_CONDITIONAL(NEED_STRLCAT, [test x$HAVE_STRLCAT = xno])	
+AC_CHECK_FUNC([strlcpy], AC_DEFINE(HAS_STRLCPY, 1, [Have the 'strlcpy' function]))
 
 AM_CONDITIONAL(NEED_VSNPRINTF, [test x$HAVE_VSNPRINTF = xno])
 
@@ -487,7 +490,6 @@ AC_ARG_ENABLE(xres,           AS_HELP_STRING([--disable-xres], [Build XRes exten
 AC_ARG_ENABLE(xtrap,          AS_HELP_STRING([--disable-xtrap], [Build XTrap extension (default: enabled)]), [XTRAP=$enableval], [XTRAP=yes])
 AC_ARG_ENABLE(record,         AS_HELP_STRING([--disable-record], [Build Record extension (default: enabled)]), [RECORD=$enableval], [RECORD=yes])
 AC_ARG_ENABLE(xv,             AS_HELP_STRING([--disable-xv], [Build Xv extension (default: enabled)]), [XV=$enableval], [XV=yes])
-AC_ARG_ENABLE(quartz,         AS_HELP_STRING([--enable-quartz], [Build with darwin quartz support (default: auto)]), [XQUARTZ=$enableval], [XQUARTZ=auto])
 AC_ARG_ENABLE(xvmc,           AS_HELP_STRING([--disable-xvmc], [Build XvMC extension (default: enabled)]), [XVMC=$enableval], [XVMC=yes])
 AC_ARG_ENABLE(dga,            AS_HELP_STRING([--disable-dga], [Build DGA extension (default: auto)]), [DGA=$enableval], [DGA=auto])
 AC_ARG_ENABLE(screensaver,    AS_HELP_STRING([--disable-screensaver], [Build ScreenSaver extension (default: enabled)]), [SCREENSAVER=$enableval], [SCREENSAVER=yes])
@@ -517,11 +519,15 @@ AC_ARG_ENABLE(xfree86-utils,     AS_HELP_STRING([--enable-xfree86-utils], [Build
 
 dnl DDXes.
 AC_ARG_ENABLE(xorg,    	      AS_HELP_STRING([--enable-xorg], [Build Xorg server (default: auto)]), [XORG=$enableval], [XORG=auto])
-AC_ARG_ENABLE(dmx,    	      AS_HELP_STRING([--enable-dmx], [Build DMX server (default: auto)]), [DMX=$enableval], [DMX=auto])
-AC_ARG_ENABLE(xvfb,    	      AS_HELP_STRING([--enable-xvfb], [Build Xvfb server (default: yes)]), [XVFB=$enableval], [XVFB=yes])
-AC_ARG_ENABLE(xnest,   	      AS_HELP_STRING([--enable-xnest], [Build Xnest server (default: auto)]), [XNEST=$enableval], [XNEST=auto])
+AC_ARG_ENABLE(dmx,    	      AS_HELP_STRING([--enable-dmx], [Build DMX server (default: no)]), [DMX=$enableval], [DMX=no])
+AC_ARG_ENABLE(xvfb,    	      AS_HELP_STRING([--enable-xvfb], [Build Xvfb server (default: no)]), [XVFB=$enableval], [XVFB=no])
+AC_ARG_ENABLE(xnest,   	      AS_HELP_STRING([--enable-xnest], [Build Xnest server (default: no)]), [XNEST=$enableval], [XNEST=no])
+AC_ARG_ENABLE(xdarwin, 	      AS_HELP_STRING([--enable-xdarwin], [Build XDarwin server (default: auto)]), [XDARWIN=$enableval], [XDARWIN=auto])
+AC_ARG_ENABLE(xdarwinapp,     AS_HELP_STRING([--enable-xdarwinapp], [Build XDarwin.app server (default: no)]), [XDARWINAPP=$enableval], [XDARWINAPP=no])
+AC_ARG_ENABLE(xquartz,        AS_HELP_STRING([--disable-xquartz], [Build Xquartz server on Darwin (default: auto)]), [XQUARTZ=$enableval], [XQUARTZ=auto])
+AC_ARG_ENABLE(x11app,         AS_HELP_STRING([--enable-x11app], [Build Apple's X11.app wrapper for Xquartz (default: no)]), [X11APP=$enableval], [X11APP=no])
 AC_ARG_ENABLE(xwin,    	      AS_HELP_STRING([--enable-xwin], [Build XWin server (default: auto)]), [XWIN=$enableval], [XWIN=auto])
-AC_ARG_ENABLE(xprint,         AS_HELP_STRING([--enable-xprint], [Build Xprint extension and server (default: auto)]), [XPRINT=$enableval], [XPRINT=auto])
+AC_ARG_ENABLE(xprint,         AS_HELP_STRING([--enable-xprint], [Build Xprint extension and server (default: no)]), [XPRINT=$enableval], [XPRINT=no])
 AC_ARG_ENABLE(xgl,            AS_HELP_STRING([--enable-xgl], [Build Xgl server (default: no)]), [XGL=$enableval], [XGL=no])
 AC_ARG_ENABLE(xglx,           AS_HELP_STRING([--enable-xglx], [Build Xglx xgl module (default: no)]), [XGLX=$enableval], [XGLX=no])
 AC_ARG_ENABLE(xegl,           AS_HELP_STRING([--enable-xegl], [Build Xegl xgl module (default: no)]), [XEGL=$enableval], [XEGL=no])
@@ -1283,61 +1289,6 @@ dnl has it in libc), or if libdl is needed to get it.
 		AC_CHECK_LIB([dl], [dlopen], XORG_LIBS="$XORG_LIBS -ldl"))
 
 	case $host_os in
-	  darwin*)
-		XORG_OS="Darwin"
-		build_darwin=yes
-	  	if test "X$XQUARTZ" = Xauto; then
-	    	  AC_CACHE_CHECK([for Carbon framework],xorg_cv_Carbon_framework,[
-	    	  save_LDFLAGS=$LDFLAGS
-	    	  LDFLAGS="$LDFLAGS -framework Carbon"
-	    	  AC_LINK_IFELSE([char FSFindFolder();
-int main() {
-FSFindFolder();
-return 0;}
-		  ],[xorg_cv_Carbon_framework=yes],
-		   [xorg_cv_Carbon_framework=no])
-	    	   LDFLAGS=$save_LDFLAGS])
-		  if test "X$xorg_cv_Carbon_framework" = Xyes; then
-		    AC_DEFINE([DARWIN_WITH_QUARTZ],[1],
-			  [Have Quartz])
-		    XQUARTZ=yes
-		  else
-		    XQUARTZ=no
-		  fi
-    	  	fi
-		AC_DEFINE(ROOTLESS,1,[Build Rootless code])
-		AC_CACHE_CHECK([for AGL framework],xorg_cv_AGL_framework,[
-	    	save_LDFLAGS=$LDFLAGS
-	    	LDFLAGS="$LDFLAGS -framework AGL"
-	    	AC_LINK_IFELSE([char aglEnable();
-int main() {
-aglEnable();
-return 0;}
-		],[xorg_cv_AGL_framework=yes],
-		[xorg_cv_AGL_framework=no])
-	    	LDFLAGS=$save_LDFLAGS
-		])	
-		AC_CHECK_LIB([Xplugin],[xp_init],[:])
-		AC_SUBST([APPLE_APPLICATIONS_DIR])
-		CFLAGS="${CFLAGS} -D__DARWIN__"
-		PLIST_VERSION_STRING=$VENDOR_VERSION_STRING
-		AC_SUBST([PLIST_VERSION_STRING])
-		PLIST_VENDOR_WEB=$VENDOR_WEB
-		AC_SUBST([PLIST_VENDOR_WEB])	
-		# Not sure that we should be disabling all these...
-	        if test "x$XF86MISC" = xyes; then
-	                AC_MSG_NOTICE([Disabling XF86Misc extension])
-	                XF86MISC=no
-	        fi
-		if test "x$XF86VIDMODE" = xyes; then
-			AC_MSG_NOTICE([Disabling XF86VidMode extension])
-			XF86VIDMODE=no
-		fi
-		if test "x$DGA" = xyes; then
-			AC_MSG_NOTICE([Disabling DGA extension])
-			DGA=no
-		fi
-	 	;;
 	  linux*)
 		if test "x$LNXAPM" = xyes; then
 			XORG_CFLAGS="$XORG_CFLAGS -DXF86PM"
@@ -1597,26 +1548,6 @@ return 0;}
 	AC_SUBST([extdir])
 	AC_SUBST([logdir])
 fi
-
-if test "x$XF86VIDMODE" = xyes; then
-	AC_DEFINE(XF86VIDMODE, 1, [Support XFree86 Video Mode extension])
-fi
-
-if test "x$XF86MISC" = xyes; then
-	AC_DEFINE(XF86MISC, 1, [Support XFree86 miscellaneous extensions])
-fi
-# Support for objc in autotools is minimal and not documented.
-OBJC='$(CC)'
-OBJCLD='$(CCLD)'
-OBJCLINK='$(LINK)'
-OBJCFLAGS='$(CFLAGS)'
-AC_SUBST([OBJC])
-AC_SUBST([OBJCCLD])
-AC_SUBST([OBJCLINK])
-AC_SUBST([OBJCFLAGS])
-# internal, undocumented automake func follows :(
-_AM_DEPENDENCIES([OBJC])
-
 AM_CONDITIONAL([XORG], [test "x$XORG" = xyes])
 AM_CONDITIONAL([XORG_BUS_LINUXPCI], [test "x$xorg_bus_linuxpci" = xyes])
 AM_CONDITIONAL([XORG_BUS_FREEBSDPCI], [test "x$xorg_bus_freebsdpci" = xyes])
@@ -1772,10 +1703,75 @@ AM_CONDITIONAL(XWIN_RANDR, [test "x$XWIN" = xyes])
 AM_CONDITIONAL(XWIN_XV, [test "x$XWIN" = xyes && test "x$XV" = xyes])
 
 dnl Darwin / OS X DDX
-AM_CONDITIONAL(HAVE_X_PLUGIN, [test "x$ac_cv_lib_Xplugin_xp_init" = xyes])
-AM_CONDITIONAL(HAVE_AGL_FRAMEWORK, [test "x$xorg_cv_AGL_framework" = xyes])
-# Support for objc in autotools is minimal and not
-# documented.
+AC_MSG_CHECKING([whether to build XDarwin (Mac OS X) DDX])
+if test "x$XDARWIN" = xauto; then
+	case $host_os in
+		darwin*) XDARWIN="yes" ;;
+		*) XDARWIN="no" ;;
+	esac
+fi
+AC_MSG_RESULT([$XDARWIN])
+
+if test "x$XDARWIN" = xyes; then
+        if test "X$XQUARTZ" = Xauto; then
+                 AC_CACHE_CHECK([for Carbon framework],xorg_cv_Carbon_framework,[
+                 save_LDFLAGS=$LDFLAGS
+                 LDFLAGS="$LDFLAGS -framework Carbon"
+                 AC_LINK_IFELSE([char FSFindFolder();
+int main() {
+FSFindFolder();
+return 0;}
+                 ],[xorg_cv_Carbon_framework=yes],
+                  [xorg_cv_Carbon_framework=no])
+                  LDFLAGS=$save_LDFLAGS])
+                 if test "X$xorg_cv_Carbon_framework" = Xyes; then
+                   AC_DEFINE([DARWIN_WITH_QUARTZ],[1],
+                         [Have Quartz])
+                   XQUARTZ=yes
+                 else
+                   XQUARTZ=no
+                 fi
+               fi
+#	       glxAGL / glxCGL don't work yet
+#               AC_CACHE_CHECK([for AGL framework],xorg_cv_AGL_framework,[
+#               save_LDFLAGS=$LDFLAGS
+#               LDFLAGS="$LDFLAGS -framework AGL"
+#               AC_LINK_IFELSE([char aglEnable();
+#int main() {
+#aglEnable();
+#return 0;}
+#               ],[xorg_cv_AGL_framework=yes],
+#               [xorg_cv_AGL_framework=no])
+#               LDFLAGS=$save_LDFLAGS
+#               ])
+               xorg_cv_AGL_framework=no
+	       DARWIN_LIBS="$MI_LIB $OS_LIB $DIX_LIB $FB_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB"
+	       AC_SUBST([DARWIN_LIBS])
+               AC_CHECK_LIB([Xplugin],[xp_init],[:])
+               AC_SUBST([APPLE_APPLICATIONS_DIR])
+               CFLAGS="${CFLAGS} -D__DARWIN__"
+               PLIST_VERSION_STRING=$PACKAGE_VERSION
+               AC_SUBST([PLIST_VERSION_STRING])
+               PLIST_VENDOR_WEB=$VENDOR_WEB
+               AC_SUBST([PLIST_VENDOR_WEB])
+               if test "x$XF86MISC" = xyes || test "x$XF86MISC" = xauto; then
+                       AC_MSG_NOTICE([Disabling XF86Misc extension])
+                       XF86MISC=no
+               fi
+               if test "x$XF86VIDMODE" = xyes || test "x$XF86VIDMODE" = xauto; then
+                       AC_MSG_NOTICE([Disabling XF86VidMode extension])
+                       XF86VIDMODE=no
+               fi
+               if test "x$XF86BIGFONT" = xyes || test "x$XF86BIGFONT" = xauto; then
+                       AC_MSG_NOTICE([Disabling XF86BigFont extension])
+                       XF86BIGFONT=no
+               fi
+               if test "x$DGA" = xyes || test "x$DGA" = xauto; then
+                       AC_MSG_NOTICE([Disabling DGA extension])
+                       DGA=no
+               fi
+fi
+# Support for objc in autotools is minimal and not documented.
 OBJC='$(CC)'
 OBJCLD='$(CCLD)'
 OBJCLINK='$(LINK)'
@@ -1786,6 +1782,11 @@ AC_SUBST([OBJCLINK])
 AC_SUBST([OBJCFLAGS])
 # internal, undocumented automake func follows :(
 _AM_DEPENDENCIES([OBJC])
+AM_CONDITIONAL(HAVE_XPLUGIN, [test "x$ac_cv_lib_Xplugin_xp_init" = xyes])
+AM_CONDITIONAL(HAVE_AGL_FRAMEWORK, [test "x$xorg_cv_AGL_framework" = xyes])
+AM_CONDITIONAL(XDARWIN, [test "x$XDARWIN" = xyes])
+AM_CONDITIONAL(XDARWINAPP, [test "x$XDARWINAPP" = xyes])
+AM_CONDITIONAL(XQUARTZ, [test "x$XQUARTZ" = xyes])
 
 dnl kdrive DDX
 
diff --git a/hw/darwin/Makefile.am b/hw/darwin/Makefile.am
index 54f3f33..aa4fbee 100644
--- a/hw/darwin/Makefile.am
+++ b/hw/darwin/Makefile.am
@@ -79,8 +79,7 @@ XDarwin_LDADD = \
 		$(top_builddir)/miext/rootless/librootless.la \
 		$(top_builddir)/miext/rootless/safeAlpha/libsafeAlpha.la \
 		$(top_builddir)/miext/rootless/accel/librlAccel.la \
-		@XORG_LIBS@ \
-		-lXau -lXdmcp -lXfont -lfreetype
+		$(XSERVER_LIBS)
 
 Xquartz_LDADD = \
 		$(top_builddir)/dix/dixfonts.lo \
@@ -90,6 +89,7 @@ Xquartz_LDADD = \
 		$(top_builddir)/dix/libxpstubs.la \
 		$(top_builddir)/miext/shadow/libshadow.la \
 		$(top_builddir)/fb/libfb.la \
+		$(top_builddir)/mi/libmi.la \
 		$(top_builddir)/composite/libcomposite.la \
 		$(top_builddir)/damageext/libdamageext.la \
 		$(top_builddir)/miext/damage/libdamage.la \
@@ -105,8 +105,7 @@ Xquartz_LDADD = \
 		$(top_builddir)/miext/rootless/librootless.la \
 		$(top_builddir)/miext/rootless/safeAlpha/libsafeAlpha.la \
 		$(top_builddir)/miext/rootless/accel/librlAccel.la \
-		@XORG_LIBS@ \
-		-lXau -lXdmcp -lXfont -lfreetype -lXplugin
+		$(XSERVER_LIBS)
 
 XDarwin_LDFLAGS =  \
                  -XCClinker -Objc \
@@ -258,6 +257,8 @@ xpr_la_LDFLAGS = -shrext '' -Wl,-framework,ApplicationServices \
 		-module -avoid-version -no-undefined
 xpr_la_DEPENDENCIES = XDarwinApp	
 
+
+if HAVE_AGL_FRAMEWORK
 glxCGLplugindir = $(darwinappdir)/Contents/Resources/glxCGL.bundle/Contents/MacOS
 glxCGLplugin_LTLIBRARIES =
 glxCGL_la_SOURCES =
@@ -289,6 +290,10 @@ glxAGL_la_LDFLAGS = -shrext '' \
 		-module -avoid-version -no-undefined
 glxAGL_la_DEPENDENCIES = XDarwinApp	
 
+
+
+endif
+
 man1_MANS = XDarwin.man
 
 uninstall-hook:
diff --git a/hw/darwin/apple/X11Application.m b/hw/darwin/apple/X11Application.m
index 9ae470e..a4adc05 100644
--- a/hw/darwin/apple/X11Application.m
+++ b/hw/darwin/apple/X11Application.m
@@ -43,8 +43,6 @@
 # include "micmap.h"
 #undef BOOL
 
-#include "xf86Version.h"
-
 #include <mach/mach.h>
 #include <unistd.h>
 #include <pthread.h>
diff --git a/hw/darwin/darwin.c b/hw/darwin/darwin.c
index c3b21c1..5500a5f 100644
--- a/hw/darwin/darwin.c
+++ b/hw/darwin/darwin.c
@@ -6,6 +6,7 @@
  **************************************************************/
 /*
  * Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
+ * Copyright (c) 2007 Apple Inc.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -30,9 +31,7 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+#include <dix-config.h>
 
 #include <X11/X.h>
 #include <X11/Xproto.h>
@@ -46,8 +45,6 @@
 #include "fb.h"			// fb framebuffer code
 #include "site.h"
 #include "globals.h"
-#include "xorgVersion.h"
-#include "xf86Date.h"
 #include "dix.h"
 
 #ifdef XINPUT
@@ -83,6 +80,7 @@ int                     darwinScreenIndex = 0;
 io_connect_t            darwinParamConnect = 0;
 int                     darwinEventReadFD = -1;
 int                     darwinEventWriteFD = -1;
+// int                     darwinMouseAccelChange = 1;
 int                     darwinFakeButtons = 0;
 
 // location of X11's (0,0) point in global screen coordinates
@@ -129,13 +127,21 @@ const int NUMFORMATS = sizeof(formats)/sizeof(formats[0]);
 #ifndef BUILD_DATE
 #define BUILD_DATE ""
 #endif
+#ifndef XORG_RELEASE
+#define XORG_RELEASE "?"
+#endif
+
+void DDXRingBell(int volume, int pitch, int duration) {
+  // FIXME -- make some noise, yo
+}
 
 void
-DarwinPrintBanner()
-{
+DarwinPrintBanner(void)
+{ 
+  // this should change depending on which specific server we are building
   ErrorF("X11.app starting:\n");
   ErrorF("Xquartz server based on X.org %s, built on %s\n", XORG_RELEASE, BUILD_DATE );
- }
+}
 
 
 /*
@@ -301,6 +307,29 @@ static Bool DarwinAddScreen(
  =============================================================================
 */
 
+#if 0
+/*
+ * DarwinChangePointerControl
+ *  Set mouse acceleration and thresholding
+ *  FIXME: We currently ignore the threshold in ctrl->threshold.
+ */
+static void DarwinChangePointerControl(
+    DeviceIntPtr    device,
+    PtrCtrl         *ctrl )
+{
+    kern_return_t   kr;
+    double          acceleration;
+
+    if (!darwinMouseAccelChange)
+        return;
+
+    acceleration = ctrl->num / ctrl->den;
+    kr = IOHIDSetMouseAcceleration( darwinParamConnect, acceleration );
+    if (kr != KERN_SUCCESS)
+        ErrorF( "Could not set mouse acceleration with kernel return = 0x%x.\n", kr );
+}
+#endif
+
 /*
  * DarwinMouseProc
  *  Handle the initialization, etc. of a mouse
@@ -549,8 +578,8 @@ DarwinAdjustScreenOrigins(ScreenInfo *pScreenInfo)
         for (i = 0; i < pScreenInfo->numScreens; i++) {
             dixScreenOrigins[i].x -= darwinMainScreenX;
             dixScreenOrigins[i].y -= darwinMainScreenY;
-	    /*            ErrorF("Screen %d placed at X11 coordinate (%d,%d).\n",
-			  i, dixScreenOrigins[i].x, dixScreenOrigins[i].y); */
+    /*            ErrorF("Screen %d placed at X11 coordinate (%d,%d).\n",
+		  i, dixScreenOrigins[i].x, dixScreenOrigins[i].y); */
         }
     }
 }
@@ -627,14 +656,10 @@ void OsVendorInit(void)
         if ( !tempStr ) {
             ErrorF("Could not find keymapping file %s.\n", darwinKeymapFile);
         } else {
-	  ErrorF("Using keymapping provided in %s.\n", tempStr);
+            ErrorF("Using keymapping provided in %s.\n", tempStr);
         }
         darwinKeymapFile = tempStr;
     }
-
-    if ( !darwinKeymapFile ) {
-      //        ErrorF("Reading keymap from the system.\n");
-    }
 }
 
 
@@ -832,7 +857,7 @@ void ddxUseMsg( void )
  */
 void ddxGiveUp( void )
 {
-    ErrorF( "Quitting Xquartz...\n" );
+    ErrorF( "Quitting XQuartz...\n" );
 
     DarwinModeGiveUp();
 }
@@ -855,7 +880,6 @@ void AbortDDX( void )
 }
 
 
-#ifdef DPMSExtension
 /*
  * DPMS extension stubs
  */
@@ -872,8 +896,6 @@ int DPMSGet(int *level)
 {
     return -1;
 }
-#endif
-
 
 #include "mivalidate.h" // for union _Validate used by windowstr.h
 #include "windowstr.h"  // for struct _Window
commit 120e83164003e39523bdd56c74416ed1db7e0e5a
Author: Ben Byer <bbyer at bbyer.local>
Date:   Sat Oct 27 23:33:51 2007 -0700

    More patches from downstream

diff --git a/GL/apple/Makefile.am b/GL/apple/Makefile.am
index 2b2d10c..4220f7f 100644
--- a/GL/apple/Makefile.am
+++ b/GL/apple/Makefile.am
@@ -1,15 +1,10 @@
 AM_CFLAGS = -I$(top_srcdir) \
-	 -I$(top_srcdir)/hw/darwin/quartz \
 	 -I$(top_srcdir)/GL/glx \
-	 -I$(top_srcdir)/hw/darwin/quartz/cr \
-	 -I$(top_srcdir)/GL/include
+	 -I$(top_srcdir)/GL/include \
+	 -I$(top_srcdir)/GL/mesa/glapi \
+	 -I$(top_srcdir)/hw/darwin/quartz \
+	 -I$(top_srcdir)/hw/darwin/quartz/xpr
 
-if HAVE_AGL_FRAMEWORK
-noinst_LIBRARIES = libAGLcore.a 
-libAGLcore_a_SOURCES = aglGlx.c \
-		       $(top_srcdir)/hw/darwin/quartz/xpr/x-list.c \
-		       $(top_srcdir)/hw/darwin/quartz/xpr/x-list.h \
-		       $(top_srcdir)/hw/darwin/quartz/xpr/x-hash.c \
-		       $(top_srcdir)/hw/darwin/quartz/xpr/x-hash.h \
+noinst_LIBRARIES = libCGLcore.a 
+libCGLcore_a_SOURCES = indirect.c \
 		       $(top_srcdir)/hw/dmx/glxProxy/compsize.c
-endif
diff --git a/GL/apple/aglGlx.c b/GL/apple/aglGlx.c
index 900a9a9..0bc9f61 100644
--- a/GL/apple/aglGlx.c
+++ b/GL/apple/aglGlx.c
@@ -1008,6 +1008,7 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
     return TRUE;
 }
 
+Bool enable_stereo = false;
 /* based on code in i830_dri.c
    This ends calling glAquaSetVisualConfigs to set the static
    numconfigs, etc. */
@@ -1022,16 +1023,18 @@ glAquaInitVisualConfigs(void)
     int i = 0;
 
     GLAQUA_DEBUG_MSG("glAquaInitVisualConfigs ");
-
+        
     /* count num configs:
+        2 stereo (on, off) (optional)
         2 Z buffer (0, 24 bit)
         2 AUX buffer (0, 2)
         2 buffers (single, double)
         2 stencil (0, 8 bit)
         2 accum (0, 64 bit)
-        = 32 configs */
+        = 64 configs with stereo, or 32 without */
 
-    lclNumConfigs = 2 * 2 * 2 * 2 * 2; /* 32 */
+    if (enable_stereo) lclNumConfigs = 2 * 2 * 2 * 2 * 2 * 2; /* 64 */
+    else               lclNumConfigs = 2 * 2 * 2 * 2 * 2; /* 32 */
 
     /* alloc */
     lclVisualConfigs = xcalloc(sizeof(__GLXvisualConfig), lclNumConfigs);
@@ -1040,54 +1043,55 @@ glAquaInitVisualConfigs(void)
     /* fill in configs */
     if (NULL != lclVisualConfigs) {
         i = 0; /* current buffer */
-        for (depth = 0; depth < 2; depth++) {
+        for (stereo = 0; stereo < (enable_stereo ? 2 : 1); stereo++) {
+	  for (depth = 0; depth < 2; depth++) {
             for (aux = 0; aux < 2; aux++) {
-                for (buffers = 0; buffers < 2; buffers++) {
-                    for (stencil = 0; stencil < 2; stencil++) {
-                        for (accum = 0; accum < 2; accum++) {
-                            lclVisualConfigs[i].vid = -1;
-                            lclVisualConfigs[i].class = -1;
-                            lclVisualConfigs[i].rgba = TRUE;
-                            lclVisualConfigs[i].redSize = -1;
-                            lclVisualConfigs[i].greenSize = -1;
-                            lclVisualConfigs[i].blueSize = -1;
-                            lclVisualConfigs[i].redMask = -1;
-                            lclVisualConfigs[i].greenMask = -1;
-                            lclVisualConfigs[i].blueMask = -1;
-                            lclVisualConfigs[i].alphaMask = 0;
-                            if (accum) {
-                                lclVisualConfigs[i].accumRedSize = 16;
-                                lclVisualConfigs[i].accumGreenSize = 16;
-                                lclVisualConfigs[i].accumBlueSize = 16;
-                                lclVisualConfigs[i].accumAlphaSize = 16;
-                            }
-                            else {
-                                lclVisualConfigs[i].accumRedSize = 0;
-                                lclVisualConfigs[i].accumGreenSize = 0;
-                                lclVisualConfigs[i].accumBlueSize = 0;
-                                lclVisualConfigs[i].accumAlphaSize = 0;
-                            }
-                            lclVisualConfigs[i].doubleBuffer = buffers ? TRUE : FALSE;
-                            lclVisualConfigs[i].stereo = FALSE;
-                            lclVisualConfigs[i].bufferSize = -1;
-
-                            lclVisualConfigs[i].depthSize = depth? 24 : 0;
-                            lclVisualConfigs[i].stencilSize = stencil ? 8 : 0;
-                            lclVisualConfigs[i].auxBuffers = aux ? 2 : 0;
-                            lclVisualConfigs[i].level = 0;
-                            lclVisualConfigs[i].visualRating = GLX_NONE_EXT;
-                            lclVisualConfigs[i].transparentPixel = 0;
-                            lclVisualConfigs[i].transparentRed = 0;
-                            lclVisualConfigs[i].transparentGreen = 0;
-                            lclVisualConfigs[i].transparentBlue = 0;
-                            lclVisualConfigs[i].transparentAlpha = 0;
-                            lclVisualConfigs[i].transparentIndex = 0;
-                            i++;
-                        }
-                    }
-                }
+	      for (buffers = 0; buffers < 2; buffers++) {
+		for (stencil = 0; stencil < 2; stencil++) {
+		  for (accum = 0; accum < 2; accum++) {
+		    lclVisualConfigs[i].vid = -1;
+		    lclVisualConfigs[i].class = -1;
+		    lclVisualConfigs[i].rgba = TRUE;
+		    lclVisualConfigs[i].redSize = -1;
+		    lclVisualConfigs[i].greenSize = -1;
+		    lclVisualConfigs[i].blueSize = -1;
+		    lclVisualConfigs[i].redMask = -1;
+		    lclVisualConfigs[i].greenMask = -1;
+		    lclVisualConfigs[i].blueMask = -1;
+		    lclVisualConfigs[i].alphaMask = 0;
+		    if (accum) {
+		      lclVisualConfigs[i].accumRedSize = 16;
+		      lclVisualConfigs[i].accumGreenSize = 16;
+		      lclVisualConfigs[i].accumBlueSize = 16;
+		      lclVisualConfigs[i].accumAlphaSize = 16;
+		    } else {
+		      lclVisualConfigs[i].accumRedSize = 0;
+		      lclVisualConfigs[i].accumGreenSize = 0;
+		      lclVisualConfigs[i].accumBlueSize = 0;
+		      lclVisualConfigs[i].accumAlphaSize = 0;
+		    }
+		    lclVisualConfigs[i].doubleBuffer = buffers ? TRUE : FALSE;
+		    lclVisualConfigs[i].stereo = stereo ? TRUE : FALSE;
+		    lclVisualConfigs[i].bufferSize = -1;
+		    
+		    lclVisualConfigs[i].depthSize = depth? 24 : 0;
+		    lclVisualConfigs[i].stencilSize = stencil ? 8 : 0;
+		    lclVisualConfigs[i].auxBuffers = aux ? 2 : 0;
+		    lclVisualConfigs[i].level = 0;
+		    lclVisualConfigs[i].visualRating = GLX_NONE_EXT;
+		    lclVisualConfigs[i].transparentPixel = 0;
+		    lclVisualConfigs[i].transparentRed = 0;
+		    lclVisualConfigs[i].transparentGreen = 0;
+		    lclVisualConfigs[i].transparentBlue = 0;
+		    lclVisualConfigs[i].transparentAlpha = 0;
+		    lclVisualConfigs[i].transparentIndex = 0;
+		    i++;
+		  }
+		}
+	      }
             }
-        }
+	  }
+	}
     }
     if (i != lclNumConfigs)
         GLAQUA_DEBUG_MSG("glAquaInitVisualConfigs failed to alloc visual configs");
@@ -1095,7 +1099,6 @@ glAquaInitVisualConfigs(void)
     GlxSetVisualConfigs(lclNumConfigs, lclVisualConfigs, lclVisualPrivates);
 }
 
-
 static void glAquaSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
                                    void **privates)
 {
diff --git a/GL/apple/indirect.c b/GL/apple/indirect.c
index ba54186..2729ab0 100644
--- a/GL/apple/indirect.c
+++ b/GL/apple/indirect.c
@@ -36,15 +36,30 @@
 #endif
 
 #include "dri.h"
-#include "quartz.h"
 
-//#include <CoreGraphics/CoreGraphics.h>
+#define GL_EXT_histogram 1
+#define GL_EXT_polygon_offset 1
+#define GL_SGIS_pixel_texture 1
+#define GL_SGIX_pixel_texture 1
+#define GL_EXT_multisample 1
+#define GL_SGIS_multisample 1
+#define GL_EXT_vertex_array 1
+#define GL_ARB_point_parameters 1
+#define GL_NV_vertex_array_range 1
+#define GL_MESA_resize_buffers 1
+#define GL_ARB_window_pos 1
+#define GL_EXT_cull_vertex 1
+#define GL_NV_vertex_program 1
+#define GL_APPLE_fence 1
+#define GL_IBM_multimode_draw_arrays 1
+#define GL_EXT_fragment_shader 1
+
 #include <OpenGL/OpenGL.h>
 #include <OpenGL/CGLContext.h>
 
 // X11 and X11's glx
 #include <GL/gl.h>
-#include <miscstruct.h>
+#include <GL/glxproto.h>
 #include <windowstr.h>
 #include <resource.h>
 #include <GL/glxint.h>
@@ -62,15 +77,17 @@
 #include "x-list.h"
 
 #include <dispatch.h>
-
+#define GLAPIENTRYP *
+typedef unsigned long long GLuint64EXT;
+typedef long long GLint64EXT;
+#include <Xplugin.h>
 #include "glcontextmodes.h"
 #include <glapi.h>
 #include <glapitable.h>
 
 // ggs: needed to call back to glx with visual configs
 extern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, void **configprivs);
-
-#define GLAQUA_DEBUG 1
+__GLXprovider * GlxGetMesaProvider (void);
 
 // Write debugging output, or not
 #ifdef GLAQUA_DEBUG
@@ -80,9 +97,13 @@ extern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, void *
 #endif
 
 static void setup_dispatch_table(void);
+GLuint __glFloorLog2(GLuint val);
+void warn_func(void * p1, char *format, ...);
 
 // some prototypes
 static __GLXscreen * __glXAquaScreenProbe(ScreenPtr pScreen);
+static __GLXdrawable * __glXAquaScreenCreateDrawable(__GLXscreen *screen, DrawablePtr pDraw, XID drawId, __GLcontextModes *modes);
+
 static Bool glAquaInitVisuals(VisualPtr *visualp, DepthPtr *depthp,
                               int *nvisualp, int *ndepthp,
                               int *rootDepthp, VisualID *defaultVisp,
@@ -90,16 +111,12 @@ static Bool glAquaInitVisuals(VisualPtr *visualp, DepthPtr *depthp,
 static void glAquaSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
                                    void **privates);
 
-static __GLinterface *glAquaCreateContext(__GLimports *imports,
-                                          __GLcontextModes *mode,
-                                          __GLinterface *shareGC);
 static void glAquaResetExtension(void);
 static void __glXAquaContextDestroy(__GLXcontext *baseContext);
 static int __glXAquaContextMakeCurrent(__GLXcontext *baseContext);
 static int __glXAquaContextLoseCurrent(__GLXcontext *baseContext);
 static int __glXAquaContextForceCurrent(__GLXcontext *baseContext);
 static int __glXAquaContextCopy(__GLXcontext *baseDst, __GLXcontext *baseSrc, unsigned long mask);
-static __GLXdrawable * __glXAquaContextCreateDrawable(__GLXcontext *context, DrawablePtr pDraw, XID drawId);
 
 static CGLPixelFormatObj makeFormat(__GLcontextModes *mode);
 
@@ -112,7 +129,7 @@ __GLXprovider __glXMesaProvider = {
 __GLXprovider *
 GlxGetMesaProvider (void)
 {
-  ErrorF("GlxGetMesaProvider\n");
+  GLAQUA_DEBUG_MSG("GlxGetMesaProvider\n");
   return &__glXMesaProvider;
 }
 
@@ -167,7 +184,7 @@ __glXAquaScreenCreateContext(__GLXscreen *screen,
   context->base.loseCurrent    = __glXAquaContextLoseCurrent;
   context->base.copy           = __glXAquaContextCopy;
   context->base.forceCurrent   = __glXAquaContextForceCurrent;
-  context->base.createDrawable = __glXAquaContextCreateDrawable;
+  //  context->base.createDrawable = __glXAquaContextCreateDrawable;
 
   context->pixelFormat = makeFormat(modes);
   if (!context->pixelFormat) {
@@ -259,7 +276,7 @@ static void surface_notify(void *_arg, void *data) {
     case AppleDRISurfaceNotifyDestroyed:
         if (surface_hash != NULL)
             x_hash_table_remove(surface_hash, (void *) arg->id);
-	        draw->base->pDraw = NULL;
+	        draw->base.pDraw = NULL;
 			draw->sid = 0;
         break;
 
@@ -324,6 +341,7 @@ static void attach(__GLXAquaContext *context, __GLXAquaDrawable *draw) {
     } 
 }
 
+#if 0     // unused
 static void unattach(__GLXAquaContext *context) {
 	x_list *lst;
 	GLAQUA_DEBUG_MSG("unattach\n");
@@ -345,12 +363,12 @@ static void unattach(__GLXAquaContext *context) {
         context->sid = 0;
     }
 }
+#endif
 
 static int __glXAquaContextMakeCurrent(__GLXcontext *baseContext) {
     CGLError gl_err;
     __GLXAquaContext *context = (__GLXAquaContext *) baseContext;
 	__GLXAquaDrawable *drawPriv = (__GLXAquaDrawable *) context->base.drawPriv;
-    __GLXAquaDrawable *readPriv = (__GLXAquaDrawable *) context->base.readPriv;
 
     GLAQUA_DEBUG_MSG("glAquaMakeCurrent (ctx 0x%p)\n", baseContext);
     
@@ -363,12 +381,6 @@ static int __glXAquaContextMakeCurrent(__GLXcontext *baseContext) {
     return gl_err == 0;
 }
 
-static GLboolean glAquaShareContext(__GLcontext *gc, __GLcontext *gcShare)
-{
-  GLAQUA_DEBUG_MSG("glAquaShareContext unimplemented\n");
-  return GL_TRUE;
-}
-
 static int __glXAquaContextCopy(__GLXcontext *baseDst, __GLXcontext *baseSrc, unsigned long mask)
 {
     CGLError gl_err;
@@ -405,12 +417,7 @@ static GLboolean __glXAquaDrawableResize(__GLXdrawable *base)  {
     return GL_TRUE;
 }
 
-static void glAquaNotifyDestroy(__GLcontext *gc) {
-    GLAQUA_DEBUG_MSG("unimplemented glAquaNotifyDestroy");
-}
-
 static GLboolean __glXAquaDrawableSwapBuffers(__GLXdrawable *base) {
-    __GLXAquaDrawable *glxPriv = (__GLXAquaDrawable *) base;
     CGLError gl_err;
 	__GLXAquaContext * drawableCtx;
 //    GLAQUA_DEBUG_MSG("glAquaDrawableSwapBuffers(%p)\n",base);
@@ -867,7 +874,7 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
     glAquaScreens[screenInfo.numScreens-1].num_vis = numNewVisuals;
     //    glAquaScreens[screenInfo.numScreens-1].priv = glXVisualPriv;
 
-    /* Set up depth's VisualIDs */
+    /* set up depth's VisualIDs */
     for (i = 0; i < ndepth; i++) {
         int numVids = 0;
         VisualID *pVids = NULL;
@@ -1027,7 +1034,7 @@ static Bool glAquaInitVisuals(VisualPtr *visualp, DepthPtr *depthp,
         glAquaInitVisualConfigs(); /* ensure the visual configs are setup */
 
     /*
-     * Setup the visuals supported by this particular screen.
+     * setup the visuals supported by this particular screen.
      */
     return init_visuals(nvisualp, visualp, defaultVisp,
                         *ndepthp, *depthp, *rootDepthp);
@@ -1109,7 +1116,7 @@ static void init_screen_visuals(__GLXAquaScreen *screen) {
                 pVis[j].blueMask  == modes->blueMask &&
                 !used[j]) {
 
-                    /* Set the VisualID */
+                    /* set the VisualID */
                     modes->visualID = pVis[j].vid;
 
                     /* Mark this visual used */
@@ -1143,8 +1150,9 @@ static __GLXscreen * __glXAquaScreenProbe(ScreenPtr pScreen) {
 
   __glXScreenInit(&screen->base, pScreen);
 
-  screen->base.destroy       = __glXAquaScreenDestroy;
-  screen->base.createContext = __glXAquaScreenCreateContext;
+  screen->base.destroy        = __glXAquaScreenDestroy;
+  screen->base.createContext  = __glXAquaScreenCreateContext;
+  screen->base.createDrawable = __glXAquaScreenCreateDrawable;
   screen->base.pScreen       = pScreen;
 
   init_screen_visuals(screen);
@@ -1163,20 +1171,20 @@ static void __glXAquaDrawableDestroy(__GLXdrawable *base) {
 }
 
 static __GLXdrawable *
-__glXAquaContextCreateDrawable(__GLXcontext *context,
-			       DrawablePtr pDraw,
-			       XID drawId)
-{
+__glXAquaScreenCreateDrawable(__GLXscreen *screen,
+			      DrawablePtr pDraw,
+			      XID drawId,
+			      __GLcontextModes *modes) {
   __GLXAquaDrawable *glxPriv;
-  __GLXscreen *pGlxScreen;
 
-  GLAQUA_DEBUG_MSG("glAquaContextCreateDrawable(%p,%p,%d)\n", context, pDraw, drawId);
-  if (glxPriv == NULL) return NULL;
+  GLAQUA_DEBUG_MSG("glAquaScreenCreateDrawable(%p,%p,%d,%p)\n", context, pDraw, drawId, modes);
+
   glxPriv = xalloc(sizeof *glxPriv);
+  if (glxPriv == NULL) return NULL;
 
   memset(glxPriv, 0, sizeof *glxPriv);
 
-  if (!__glXDrawableInit(&glxPriv->base, context, pDraw, drawId)) {
+  if (!__glXDrawableInit(&glxPriv->base, screen, pDraw, drawId, modes)) {
     xfree(glxPriv);
     return NULL;
   }
@@ -1184,17 +1192,9 @@ __glXAquaContextCreateDrawable(__GLXcontext *context,
   glxPriv->base.destroy       = __glXAquaDrawableDestroy;
   glxPriv->base.resize        = __glXAquaDrawableResize;
   glxPriv->base.swapBuffers   = __glXAquaDrawableSwapBuffers;
+  //  glxPriv->base.copySubBuffer = __glXAquaDrawableCopySubBuffer;
 
-  pGlxScreen = __glXActiveScreens[pDraw->pScreen->myNum];
-
-  if (glxPriv->base.type == DRAWABLE_WINDOW) {
-    VisualID vid = wVisual((WindowPtr)pDraw);
-
-    glxPriv->base.modes = _gl_context_modes_find_visual(pGlxScreen->modes, vid);
-  } else 
-    glxPriv->base.modes = glxPriv->base.pGlxPixmap->modes;
-
-    return &glxPriv->base;
+  return &glxPriv->base;
 }
 
 static void glAquaResetExtension(void)
@@ -1216,1238 +1216,723 @@ GLuint __glFloorLog2(GLuint val)
     return c;
 }
 
-static void setup_dispatch_table(void) {
-	struct _glapi_table *disp=_glapi_get_dispatch();
-
- SET_NewList(disp, glNewList);
- SET_EndList(disp, glEndList);
- SET_CallList(disp, glCallList);
- SET_CallLists(disp, glCallLists);
- SET_DeleteLists(disp, glDeleteLists);
- SET_GenLists(disp, glGenLists);
- SET_ListBase(disp, glListBase);
- SET_Begin(disp, glBegin);
- SET_Bitmap(disp, glBitmap);
- SET_Color3b(disp, glColor3b);
- SET_Color3bv(disp, glColor3bv);
- SET_Color3d(disp, glColor3d);
- SET_Color3dv(disp, glColor3dv);
- SET_Color3f(disp, glColor3f);
- SET_Color3fv(disp, glColor3fv);
- SET_Color3i(disp, glColor3i);
- SET_Color3iv(disp, glColor3iv);
- SET_Color3s(disp, glColor3s);
- SET_Color3sv(disp, glColor3sv);
- SET_Color3ub(disp, glColor3ub);
- SET_Color3ubv(disp, glColor3ubv);
- SET_Color3ui(disp, glColor3ui);
- SET_Color3uiv(disp, glColor3uiv);
- SET_Color3us(disp, glColor3us);
- SET_Color3usv(disp, glColor3usv);
- SET_Color4b(disp, glColor4b);
- SET_Color4bv(disp, glColor4bv);
- SET_Color4d(disp, glColor4d);
- SET_Color4dv(disp, glColor4dv);
- SET_Color4f(disp, glColor4f);
- SET_Color4fv(disp, glColor4fv);
- SET_Color4i(disp, glColor4i);
- SET_Color4iv(disp, glColor4iv);
- SET_Color4s(disp, glColor4s);
- SET_Color4sv(disp, glColor4sv);
- SET_Color4ub(disp, glColor4ub);
- SET_Color4ubv(disp, glColor4ubv);
- SET_Color4ui(disp, glColor4ui);
- SET_Color4uiv(disp, glColor4uiv);
- SET_Color4us(disp, glColor4us);
- SET_Color4usv(disp, glColor4usv);
- SET_EdgeFlag(disp, glEdgeFlag);
- SET_EdgeFlagv(disp, glEdgeFlagv);
- SET_End(disp, glEnd);
- SET_Indexd(disp, glIndexd);
- SET_Indexdv(disp, glIndexdv);
- SET_Indexf(disp, glIndexf);
- SET_Indexfv(disp, glIndexfv);
- SET_Indexi(disp, glIndexi);
- SET_Indexiv(disp, glIndexiv);
- SET_Indexs(disp, glIndexs);
- SET_Indexsv(disp, glIndexsv);
- SET_Normal3b(disp, glNormal3b);
- SET_Normal3bv(disp, glNormal3bv);
- SET_Normal3d(disp, glNormal3d);
- SET_Normal3dv(disp, glNormal3dv);
- SET_Normal3f(disp, glNormal3f);
- SET_Normal3fv(disp, glNormal3fv);
- SET_Normal3i(disp, glNormal3i);
- SET_Normal3iv(disp, glNormal3iv);
- SET_Normal3s(disp, glNormal3s);
- SET_Normal3sv(disp, glNormal3sv);
- SET_RasterPos2d(disp, glRasterPos2d);
- SET_RasterPos2dv(disp, glRasterPos2dv);
- SET_RasterPos2f(disp, glRasterPos2f);
- SET_RasterPos2fv(disp, glRasterPos2fv);
- SET_RasterPos2i(disp, glRasterPos2i);
- SET_RasterPos2iv(disp, glRasterPos2iv);
- SET_RasterPos2s(disp, glRasterPos2s);
- SET_RasterPos2sv(disp, glRasterPos2sv);
- SET_RasterPos3d(disp, glRasterPos3d);
- SET_RasterPos3dv(disp, glRasterPos3dv);
- SET_RasterPos3f(disp, glRasterPos3f);
- SET_RasterPos3fv(disp, glRasterPos3fv);
- SET_RasterPos3i(disp, glRasterPos3i);
- SET_RasterPos3iv(disp, glRasterPos3iv);
- SET_RasterPos3s(disp, glRasterPos3s);
- SET_RasterPos3sv(disp, glRasterPos3sv);
- SET_RasterPos4d(disp, glRasterPos4d);
- SET_RasterPos4dv(disp, glRasterPos4dv);
- SET_RasterPos4f(disp, glRasterPos4f);
- SET_RasterPos4fv(disp, glRasterPos4fv);
- SET_RasterPos4i(disp, glRasterPos4i);
- SET_RasterPos4iv(disp, glRasterPos4iv);
- SET_RasterPos4s(disp, glRasterPos4s);
- SET_RasterPos4sv(disp, glRasterPos4sv);
- SET_Rectd(disp, glRectd);
- SET_Rectdv(disp, glRectdv);
- SET_Rectf(disp, glRectf);
- SET_Rectfv(disp, glRectfv);
- SET_Recti(disp, glRecti);
- SET_Rectiv(disp, glRectiv);
- SET_Rects(disp, glRects);
- SET_Rectsv(disp, glRectsv);
- SET_TexCoord1d(disp, glTexCoord1d);
- SET_TexCoord1dv(disp, glTexCoord1dv);
- SET_TexCoord1f(disp, glTexCoord1f);
- SET_TexCoord1fv(disp, glTexCoord1fv);
- SET_TexCoord1i(disp, glTexCoord1i);
- SET_TexCoord1iv(disp, glTexCoord1iv);
- SET_TexCoord1s(disp, glTexCoord1s);
- SET_TexCoord1sv(disp, glTexCoord1sv);
- SET_TexCoord2d(disp, glTexCoord2d);
- SET_TexCoord2dv(disp, glTexCoord2dv);
- SET_TexCoord2f(disp, glTexCoord2f);
- SET_TexCoord2fv(disp, glTexCoord2fv);
- SET_TexCoord2i(disp, glTexCoord2i);
- SET_TexCoord2iv(disp, glTexCoord2iv);
- SET_TexCoord2s(disp, glTexCoord2s);
- SET_TexCoord2sv(disp, glTexCoord2sv);
- SET_TexCoord3d(disp, glTexCoord3d);
- SET_TexCoord3dv(disp, glTexCoord3dv);
- SET_TexCoord3f(disp, glTexCoord3f);
- SET_TexCoord3fv(disp, glTexCoord3fv);
- SET_TexCoord3i(disp, glTexCoord3i);
- SET_TexCoord3iv(disp, glTexCoord3iv);
- SET_TexCoord3s(disp, glTexCoord3s);
- SET_TexCoord3sv(disp, glTexCoord3sv);
- SET_TexCoord4d(disp, glTexCoord4d);
- SET_TexCoord4dv(disp, glTexCoord4dv);
- SET_TexCoord4f(disp, glTexCoord4f);
- SET_TexCoord4fv(disp, glTexCoord4fv);
- SET_TexCoord4i(disp, glTexCoord4i);
- SET_TexCoord4iv(disp, glTexCoord4iv);
- SET_TexCoord4s(disp, glTexCoord4s);
- SET_TexCoord4sv(disp, glTexCoord4sv);
- SET_Vertex2d(disp, glVertex2d);
- SET_Vertex2dv(disp, glVertex2dv);
- SET_Vertex2f(disp, glVertex2f);
- SET_Vertex2fv(disp, glVertex2fv);
- SET_Vertex2i(disp, glVertex2i);
- SET_Vertex2iv(disp, glVertex2iv);
- SET_Vertex2s(disp, glVertex2s);
- SET_Vertex2sv(disp, glVertex2sv);
- SET_Vertex3d(disp, glVertex3d);
- SET_Vertex3dv(disp, glVertex3dv);
- SET_Vertex3f(disp, glVertex3f);
- SET_Vertex3fv(disp, glVertex3fv);
- SET_Vertex3i(disp, glVertex3i);
- SET_Vertex3iv(disp, glVertex3iv);
- SET_Vertex3s(disp, glVertex3s);
- SET_Vertex3sv(disp, glVertex3sv);
- SET_Vertex4d(disp, glVertex4d);
- SET_Vertex4dv(disp, glVertex4dv);
- SET_Vertex4f(disp, glVertex4f);
- SET_Vertex4fv(disp, glVertex4fv);
- SET_Vertex4i(disp, glVertex4i);
- SET_Vertex4iv(disp, glVertex4iv);
- SET_Vertex4s(disp, glVertex4s);
- SET_Vertex4sv(disp, glVertex4sv);
- SET_ClipPlane(disp, glClipPlane);
- SET_ColorMaterial(disp, glColorMaterial);
- SET_CullFace(disp, glCullFace);
- SET_Fogf(disp, glFogf);
- SET_Fogfv(disp, glFogfv);
- SET_Fogi(disp, glFogi);
- SET_Fogiv(disp, glFogiv);
- SET_FrontFace(disp, glFrontFace);
- SET_Hint(disp, glHint);
- SET_Lightf(disp, glLightf);
- SET_Lightfv(disp, glLightfv);
- SET_Lighti(disp, glLighti);
- SET_Lightiv(disp, glLightiv);
- SET_LightModelf(disp, glLightModelf);
- SET_LightModelfv(disp, glLightModelfv);
- SET_LightModeli(disp, glLightModeli);
- SET_LightModeliv(disp, glLightModeliv);
- SET_LineStipple(disp, glLineStipple);
- SET_LineWidth(disp, glLineWidth);
- SET_Materialf(disp, glMaterialf);
- SET_Materialfv(disp, glMaterialfv);
- SET_Materiali(disp, glMateriali);
- SET_Materialiv(disp, glMaterialiv);
- SET_PointSize(disp, glPointSize);
- SET_PolygonMode(disp, glPolygonMode);
- SET_PolygonStipple(disp, glPolygonStipple);
- SET_Scissor(disp, glScissor);
- SET_ShadeModel(disp, glShadeModel);
- SET_TexParameterf(disp, glTexParameterf);
- SET_TexParameterfv(disp, glTexParameterfv);
- SET_TexParameteri(disp, glTexParameteri);
- SET_TexParameteriv(disp, glTexParameteriv);
- SET_TexImage1D(disp, glTexImage1D);
- SET_TexImage2D(disp, glTexImage2D);
- SET_TexEnvf(disp, glTexEnvf);
- SET_TexEnvfv(disp, glTexEnvfv);
- SET_TexEnvi(disp, glTexEnvi);
- SET_TexEnviv(disp, glTexEnviv);
- SET_TexGend(disp, glTexGend);
- SET_TexGendv(disp, glTexGendv);
- SET_TexGenf(disp, glTexGenf);
- SET_TexGenfv(disp, glTexGenfv);
- SET_TexGeni(disp, glTexGeni);
- SET_TexGeniv(disp, glTexGeniv);
- SET_FeedbackBuffer(disp, glFeedbackBuffer);
- SET_SelectBuffer(disp, glSelectBuffer);
- SET_RenderMode(disp, glRenderMode);
- SET_InitNames(disp, glInitNames);
- SET_LoadName(disp, glLoadName);
- SET_PassThrough(disp, glPassThrough);
- SET_PopName(disp, glPopName);
- SET_PushName(disp, glPushName);
- SET_DrawBuffer(disp, glDrawBuffer);
- SET_Clear(disp, glClear);
- SET_ClearAccum(disp, glClearAccum);
- SET_ClearIndex(disp, glClearIndex);
- SET_ClearColor(disp, glClearColor);
- SET_ClearStencil(disp, glClearStencil);
- SET_ClearDepth(disp, glClearDepth);
- SET_StencilMask(disp, glStencilMask);
- SET_ColorMask(disp, glColorMask);
- SET_DepthMask(disp, glDepthMask);
- SET_IndexMask(disp, glIndexMask);
- SET_Accum(disp, glAccum);
- SET_Disable(disp, glDisable);
- SET_Enable(disp, glEnable);
- SET_Finish(disp, glFinish);
- SET_Flush(disp, glFlush);
- SET_PopAttrib(disp, glPopAttrib);
- SET_PushAttrib(disp, glPushAttrib);
- SET_Map1d(disp, glMap1d);
- SET_Map1f(disp, glMap1f);
- SET_Map2d(disp, glMap2d);
- SET_Map2f(disp, glMap2f);
- SET_MapGrid1d(disp, glMapGrid1d);
- SET_MapGrid1f(disp, glMapGrid1f);
- SET_MapGrid2d(disp, glMapGrid2d);
- SET_MapGrid2f(disp, glMapGrid2f);
- SET_EvalCoord1d(disp, glEvalCoord1d);
- SET_EvalCoord1dv(disp, glEvalCoord1dv);
- SET_EvalCoord1f(disp, glEvalCoord1f);
- SET_EvalCoord1fv(disp, glEvalCoord1fv);
- SET_EvalCoord2d(disp, glEvalCoord2d);
- SET_EvalCoord2dv(disp, glEvalCoord2dv);
- SET_EvalCoord2f(disp, glEvalCoord2f);
- SET_EvalCoord2fv(disp, glEvalCoord2fv);
- SET_EvalMesh1(disp, glEvalMesh1);
- SET_EvalPoint1(disp, glEvalPoint1);
- SET_EvalMesh2(disp, glEvalMesh2);
- SET_EvalPoint2(disp, glEvalPoint2);
- SET_AlphaFunc(disp, glAlphaFunc);
- SET_BlendFunc(disp, glBlendFunc);
- SET_LogicOp(disp, glLogicOp);
- SET_StencilFunc(disp, glStencilFunc);
- SET_StencilOp(disp, glStencilOp);
- SET_DepthFunc(disp, glDepthFunc);
- SET_PixelZoom(disp, glPixelZoom);
- SET_PixelTransferf(disp, glPixelTransferf);
- SET_PixelTransferi(disp, glPixelTransferi);
- SET_PixelStoref(disp, glPixelStoref);
- SET_PixelStorei(disp, glPixelStorei);
- SET_PixelMapfv(disp, glPixelMapfv);
- SET_PixelMapuiv(disp, glPixelMapuiv);
- SET_PixelMapusv(disp, glPixelMapusv);
- SET_ReadBuffer(disp, glReadBuffer);
- SET_CopyPixels(disp, glCopyPixels);
- SET_ReadPixels(disp, glReadPixels);
- SET_DrawPixels(disp, glDrawPixels);
- SET_GetBooleanv(disp, glGetBooleanv);
- SET_GetClipPlane(disp, glGetClipPlane);
- SET_GetDoublev(disp, glGetDoublev);
- SET_GetError(disp, glGetError);
- SET_GetFloatv(disp, glGetFloatv);
- SET_GetIntegerv(disp, glGetIntegerv);
- SET_GetLightfv(disp, glGetLightfv);
- SET_GetLightiv(disp, glGetLightiv);
- SET_GetMapdv(disp, glGetMapdv);
- SET_GetMapfv(disp, glGetMapfv);
- SET_GetMapiv(disp, glGetMapiv);
- SET_GetMaterialfv(disp, glGetMaterialfv);
- SET_GetMaterialiv(disp, glGetMaterialiv);
- SET_GetPixelMapfv(disp, glGetPixelMapfv);
- SET_GetPixelMapuiv(disp, glGetPixelMapuiv);
- SET_GetPixelMapusv(disp, glGetPixelMapusv);
- SET_GetPolygonStipple(disp, glGetPolygonStipple);
- SET_GetString(disp, glGetString);
- SET_GetTexEnvfv(disp, glGetTexEnvfv);
- SET_GetTexEnviv(disp, glGetTexEnviv);
- SET_GetTexGendv(disp, glGetTexGendv);
- SET_GetTexGenfv(disp, glGetTexGenfv);
- SET_GetTexGeniv(disp, glGetTexGeniv);
- SET_GetTexImage(disp, glGetTexImage);
- SET_GetTexParameterfv(disp, glGetTexParameterfv);
- SET_GetTexParameteriv(disp, glGetTexParameteriv);
- SET_GetTexLevelParameterfv(disp, glGetTexLevelParameterfv);
- SET_GetTexLevelParameteriv(disp, glGetTexLevelParameteriv);
- SET_IsEnabled(disp, glIsEnabled);
- SET_IsList(disp, glIsList);
- SET_DepthRange(disp, glDepthRange);
- SET_Frustum(disp, glFrustum);
- SET_LoadIdentity(disp, glLoadIdentity);
- SET_LoadMatrixf(disp, glLoadMatrixf);
- SET_LoadMatrixd(disp, glLoadMatrixd);
- SET_MatrixMode(disp, glMatrixMode);
- SET_MultMatrixf(disp, glMultMatrixf);
- SET_MultMatrixd(disp, glMultMatrixd);
- SET_Ortho(disp, glOrtho);
- SET_PopMatrix(disp, glPopMatrix);
- SET_PushMatrix(disp, glPushMatrix);
- SET_Rotated(disp, glRotated);
- SET_Rotatef(disp, glRotatef);
- SET_Scaled(disp, glScaled);
- SET_Scalef(disp, glScalef);
- SET_Translated(disp, glTranslated);
- SET_Translatef(disp, glTranslatef);
- SET_Viewport(disp, glViewport);
- SET_ArrayElement(disp, glArrayElement);
- SET_BindTexture(disp, glBindTexture);
- SET_ColorPointer(disp, glColorPointer);
- SET_DisableClientState(disp, glDisableClientState);
- SET_DrawArrays(disp, glDrawArrays);
- SET_DrawElements(disp, glDrawElements);
- SET_EdgeFlagPointer(disp, glEdgeFlagPointer);
- SET_EnableClientState(disp, glEnableClientState);
- SET_IndexPointer(disp, glIndexPointer);
- SET_Indexub(disp, glIndexub);
- SET_Indexubv(disp, glIndexubv);
- SET_InterleavedArrays(disp, glInterleavedArrays);
- SET_NormalPointer(disp, glNormalPointer);
- SET_PolygonOffset(disp, glPolygonOffset);
- SET_TexCoordPointer(disp, glTexCoordPointer);
- SET_VertexPointer(disp, glVertexPointer);
- SET_AreTexturesResident(disp, glAreTexturesResident); 
- SET_CopyTexImage1D(disp, glCopyTexImage1D);
- SET_CopyTexImage2D(disp, glCopyTexImage2D);
- SET_CopyTexSubImage1D(disp, glCopyTexSubImage1D);
- SET_CopyTexSubImage2D(disp, glCopyTexSubImage2D);
- SET_DeleteTextures(disp, glDeleteTextures);
- SET_GenTextures(disp, glGenTextures);
- SET_GetPointerv(disp, glGetPointerv);
- SET_IsTexture(disp, glIsTexture);
- SET_PrioritizeTextures(disp, glPrioritizeTextures);
- SET_TexSubImage1D(disp, glTexSubImage1D);
- SET_TexSubImage2D(disp, glTexSubImage2D);
- SET_PopClientAttrib(disp, glPopClientAttrib);
- SET_PushClientAttrib(disp, glPushClientAttrib);
- SET_BlendColor(disp, glBlendColor);
- SET_BlendEquation(disp, glBlendEquation);
- SET_DrawRangeElements(disp, glDrawRangeElements);
- SET_ColorTable(disp, glColorTable);
- SET_ColorTableParameterfv(disp, glColorTableParameterfv);
- SET_ColorTableParameteriv(disp, glColorTableParameteriv);
- SET_CopyColorTable(disp, glCopyColorTable);
- SET_GetColorTable(disp, glGetColorTable);
- SET_GetColorTableParameterfv(disp, glGetColorTableParameterfv);
- SET_GetColorTableParameteriv(disp, glGetColorTableParameteriv);
- SET_ColorSubTable(disp, glColorSubTable);
- SET_CopyColorSubTable(disp, glCopyColorSubTable);
- SET_ConvolutionFilter1D(disp, glConvolutionFilter1D);
- SET_ConvolutionFilter2D(disp, glConvolutionFilter2D);
- SET_ConvolutionParameterf(disp, glConvolutionParameterf);
- SET_ConvolutionParameterfv(disp, glConvolutionParameterfv);
- SET_ConvolutionParameteri(disp, glConvolutionParameteri);
- SET_ConvolutionParameteriv(disp, glConvolutionParameteriv);
- SET_CopyConvolutionFilter1D(disp, glCopyConvolutionFilter1D);
- SET_CopyConvolutionFilter2D(disp, glCopyConvolutionFilter2D);
- SET_GetConvolutionFilter(disp, glGetConvolutionFilter);
- SET_GetConvolutionParameterfv(disp, glGetConvolutionParameterfv);
- SET_GetConvolutionParameteriv(disp, glGetConvolutionParameteriv);
- SET_GetSeparableFilter(disp, glGetSeparableFilter);
- SET_SeparableFilter2D(disp, glSeparableFilter2D);
- SET_GetHistogram(disp, glGetHistogram);
- SET_GetHistogramParameterfv(disp, glGetHistogramParameterfv);
- SET_GetHistogramParameteriv(disp, glGetHistogramParameteriv);
- SET_GetMinmax(disp, glGetMinmax);
- SET_GetMinmaxParameterfv(disp, glGetMinmaxParameterfv);
- SET_GetMinmaxParameteriv(disp, glGetMinmaxParameteriv);
- SET_Histogram(disp, glHistogram);
- SET_Minmax(disp, glMinmax);
- SET_ResetHistogram(disp, glResetHistogram);
- SET_ResetMinmax(disp, glResetMinmax);
- SET_TexImage3D(disp, glTexImage3D);
- SET_TexSubImage3D(disp, glTexSubImage3D);
- SET_CopyTexSubImage3D(disp, glCopyTexSubImage3D);
- SET_ActiveTextureARB(disp, glActiveTextureARB);
- SET_ClientActiveTextureARB(disp, glClientActiveTextureARB);
- SET_MultiTexCoord1dARB(disp, glMultiTexCoord1dARB);
- SET_MultiTexCoord1dvARB(disp, glMultiTexCoord1dvARB);
- SET_MultiTexCoord1fARB(disp, glMultiTexCoord1fARB);
- SET_MultiTexCoord1fvARB(disp, glMultiTexCoord1fvARB);
- SET_MultiTexCoord1iARB(disp, glMultiTexCoord1iARB);
- SET_MultiTexCoord1ivARB(disp, glMultiTexCoord1ivARB);
- SET_MultiTexCoord1sARB(disp, glMultiTexCoord1sARB);
- SET_MultiTexCoord1svARB(disp, glMultiTexCoord1svARB);
- SET_MultiTexCoord2dARB(disp, glMultiTexCoord2dARB);
- SET_MultiTexCoord2dvARB(disp, glMultiTexCoord2dvARB);
- SET_MultiTexCoord2fARB(disp, glMultiTexCoord2fARB);
- SET_MultiTexCoord2fvARB(disp, glMultiTexCoord2fvARB);
- SET_MultiTexCoord2iARB(disp, glMultiTexCoord2iARB);
- SET_MultiTexCoord2ivARB(disp, glMultiTexCoord2ivARB);
- SET_MultiTexCoord2sARB(disp, glMultiTexCoord2sARB);
- SET_MultiTexCoord2svARB(disp, glMultiTexCoord2svARB);
- SET_MultiTexCoord3dARB(disp, glMultiTexCoord3dARB);
- SET_MultiTexCoord3dvARB(disp, glMultiTexCoord3dvARB);
- SET_MultiTexCoord3fARB(disp, glMultiTexCoord3fARB);
- SET_MultiTexCoord3fvARB(disp, glMultiTexCoord3fvARB);
- SET_MultiTexCoord3iARB(disp, glMultiTexCoord3iARB);
- SET_MultiTexCoord3ivARB(disp, glMultiTexCoord3ivARB);
- SET_MultiTexCoord3sARB(disp, glMultiTexCoord3sARB);
- SET_MultiTexCoord3svARB(disp, glMultiTexCoord3svARB);
- SET_MultiTexCoord4dARB(disp, glMultiTexCoord4dARB);
- SET_MultiTexCoord4dvARB(disp, glMultiTexCoord4dvARB);
- SET_MultiTexCoord4fARB(disp, glMultiTexCoord4fARB);
- SET_MultiTexCoord4fvARB(disp, glMultiTexCoord4fvARB);
- SET_MultiTexCoord4iARB(disp, glMultiTexCoord4iARB);
- SET_MultiTexCoord4ivARB(disp, glMultiTexCoord4ivARB);
- SET_MultiTexCoord4sARB(disp, glMultiTexCoord4sARB);
- SET_MultiTexCoord4svARB(disp, glMultiTexCoord4svARB);
- SET_LoadTransposeMatrixfARB(disp, glLoadTransposeMatrixfARB);
- SET_LoadTransposeMatrixdARB(disp, glLoadTransposeMatrixdARB);
- SET_MultTransposeMatrixfARB(disp, glMultTransposeMatrixfARB);
- SET_MultTransposeMatrixdARB(disp, glMultTransposeMatrixdARB);
- SET_SampleCoverageARB(disp, glSampleCoverageARB);
- SET_DrawBuffersARB(disp, glDrawBuffersARB);
-/* SET_PolygonOffsetEXT(disp, glPolygonOffsetEXT);
- SET_GetTexFilterFuncSGIS(disp, glGetTexFilterFuncSGIS);
- SET_TexFilterFuncSGIS(disp, glTexFilterFuncSGIS);
- SET_GetHistogramEXT(disp, glGetHistogramEXT);
- SET_GetHistogramParameterfvEXT(disp, glGetHistogramParameterfvEXT);
- SET_GetHistogramParameterivEXT(disp, glGetHistogramParameterivEXT);
- SET_GetMinmaxEXT(disp, glGetMinmaxEXT);
- SET_GetMinmaxParameterfvEXT(disp, glGetMinmaxParameterfvEXT);
- SET_GetMinmaxParameterivEXT(disp, glGetMinmaxParameterivEXT);
- SET_GetConvolutionFilterEXT(disp, glGetConvolutionFilterEXT);
- SET_GetConvolutionParameterfvEXT(disp, glGetConvolutionParameterfvEXT);
- SET_GetConvolutionParameterivEXT(disp, glGetConvolutionParameterivEXT);
- SET_GetSeparableFilterEXT(disp, glGetSeparableFilterEXT);
- SET_GetColorTableSGI(disp, glGetColorTableSGI);
- SET_GetColorTableParameterfvSGI(disp, glGetColorTableParameterfvSGI);
- SET_GetColorTableParameterivSGI(disp, glGetColorTableParameterivSGI);
- SET_PixelTexGenSGIX(disp, glPixelTexGenSGIX);
- SET_PixelTexGenParameteriSGIS(disp, glPixelTexGenParameteriSGIS);
- SET_PixelTexGenParameterivSGIS(disp, glPixelTexGenParameterivSGIS);
- SET_PixelTexGenParameterfSGIS(disp, glPixelTexGenParameterfSGIS);
- SET_PixelTexGenParameterfvSGIS(disp, glPixelTexGenParameterfvSGIS);
- SET_GetPixelTexGenParameterivSGIS(disp, glGetPixelTexGenParameterivSGIS);
- SET_GetPixelTexGenParameterfvSGIS(disp, glGetPixelTexGenParameterfvSGIS);
- SET_TexImage4DSGIS(disp, glTexImage4DSGIS);
- SET_TexSubImage4DSGIS(disp, glTexSubImage4DSGIS); */
- SET_AreTexturesResidentEXT(disp, glAreTexturesResident);
- SET_GenTexturesEXT(disp, glGenTextures);
- SET_IsTextureEXT(disp, glIsTexture);
-/* SET_DetailTexFuncSGIS(disp, glDetailTexFuncSGIS);
- SET_GetDetailTexFuncSGIS(disp, glGetDetailTexFuncSGIS);
- SET_SharpenTexFuncSGIS(disp, glSharpenTexFuncSGIS);
- SET_GetSharpenTexFuncSGIS(disp, glGetSharpenTexFuncSGIS);
- SET_SampleMaskSGIS(disp, glSampleMaskSGIS);
- SET_SamplePatternSGIS(disp, glSamplePatternSGIS);
- SET_ColorPointerEXT(disp, glColorPointerEXT);
- SET_EdgeFlagPointerEXT(disp, glEdgeFlagPointerEXT);
- SET_IndexPointerEXT(disp, glIndexPointerEXT);
- SET_NormalPointerEXT(disp, glNormalPointerEXT);
- SET_TexCoordPointerEXT(disp, glTexCoordPointerEXT);
- SET_VertexPointerEXT(disp, glVertexPointerEXT);
- SET_SpriteParameterfSGIX(disp, glSpriteParameterfSGIX);
- SET_SpriteParameterfvSGIX(disp, glSpriteParameterfvSGIX);
- SET_SpriteParameteriSGIX(disp, glSpriteParameteriSGIX);
- SET_SpriteParameterivSGIX(disp, glSpriteParameterivSGIX);
- SET_PointParameterfEXT(disp, glPointParameterfEXT);
- SET_PointParameterfvEXT(disp, glPointParameterfvEXT);
- SET_GetInstrumentsSGIX(disp, glGetInstrumentsSGIX);
- SET_InstrumentsBufferSGIX(disp, glInstrumentsBufferSGIX);
- SET_PollInstrumentsSGIX(disp, glPollInstrumentsSGIX);
- SET_ReadInstrumentsSGIX(disp, glReadInstrumentsSGIX);
- SET_StartInstrumentsSGIX(disp, glStartInstrumentsSGIX);
- SET_StopInstrumentsSGIX(disp, glStopInstrumentsSGIX);
- SET_FrameZoomSGIX(disp, glFrameZoomSGIX);
- SET_TagSampleBufferSGIX(disp, glTagSampleBufferSGIX);
- SET_ReferencePlaneSGIX(disp, glReferencePlaneSGIX);
- SET_FlushRasterSGIX(disp, glFlushRasterSGIX);
- SET_GetListParameterfvSGIX(disp, glGetListParameterfvSGIX);
- SET_GetListParameterivSGIX(disp, glGetListParameterivSGIX);
- SET_ListParameterfSGIX(disp, glListParameterfSGIX);
- SET_ListParameterfvSGIX(disp, glListParameterfvSGIX);
- SET_ListParameteriSGIX(disp, glListParameteriSGIX);
- SET_ListParameterivSGIX(disp, glListParameterivSGIX);
- SET_FragmentColorMaterialSGIX(disp, glFragmentColorMaterialSGIX);
- SET_FragmentLightfSGIX(disp, glFragmentLightfSGIX);
- SET_FragmentLightfvSGIX(disp, glFragmentLightfvSGIX);
- SET_FragmentLightiSGIX(disp, glFragmentLightiSGIX);
- SET_FragmentLightivSGIX(disp, glFragmentLightivSGIX);
- SET_FragmentLightModelfSGIX(disp, glFragmentLightModelfSGIX);
- SET_FragmentLightModelfvSGIX(disp, glFragmentLightModelfvSGIX);
- SET_FragmentLightModeliSGIX(disp, glFragmentLightModeliSGIX);
- SET_FragmentLightModelivSGIX(disp, glFragmentLightModelivSGIX);
- SET_FragmentMaterialfSGIX(disp, glFragmentMaterialfSGIX);
- SET_FragmentMaterialfvSGIX(disp, glFragmentMaterialfvSGIX);
- SET_FragmentMaterialiSGIX(disp, glFragmentMaterialiSGIX);
- SET_FragmentMaterialivSGIX(disp, glFragmentMaterialivSGIX);
- SET_GetFragmentLightfvSGIX(disp, glGetFragmentLightfvSGIX);
- SET_GetFragmentLightivSGIX(disp, glGetFragmentLightivSGIX);
- SET_GetFragmentMaterialfvSGIX(disp, glGetFragmentMaterialfvSGIX);
- SET_GetFragmentMaterialivSGIX(disp, glGetFragmentMaterialivSGIX);
- SET_LightEnviSGIX(disp, glLightEnviSGIX); 
- SET_VertexWeightfEXT(disp, glVertexWeightfEXT);
- SET_VertexWeightfvEXT(disp, glVertexWeightfvEXT);
- SET_VertexWeightPointerEXT(disp, glVertexWeightPointerEXT);
- SET_FlushVertexArrayRangeNV(disp, glFlushVertexArrayRangeNV);
- SET_VertexArrayRangeNV(disp, glVertexArrayRangeNV);
- SET_CombinerParameterfvNV(disp, glCombinerParameterfvNV);
- SET_CombinerParameterfNV(disp, glCombinerParameterfNV);
- SET_CombinerParameterivNV(disp, glCombinerParameterivNV);
- SET_CombinerParameteriNV(disp, glCombinerParameteriNV);
- SET_CombinerInputNV(disp, glCombinerInputNV);
- SET_CombinerOutputNV(disp, glCombinerOutputNV);
- SET_FinalCombinerInputNV(disp, glFinalCombinerInputNV);
- SET_GetCombinerInputParameterfvNV(disp, glGetCombinerInputParameterfvNV);
- SET_GetCombinerInputParameterivNV(disp, glGetCombinerInputParameterivNV);
- SET_GetCombinerOutputParameterfvNV(disp, glGetCombinerOutputParameterfvNV);
- SET_GetCombinerOutputParameterivNV(disp, glGetCombinerOutputParameterivNV);
- SET_GetFinalCombinerInputParameterfvNV(disp, glGetFinalCombinerInputParameterfvNV);
- SET_GetFinalCombinerInputParameterivNV(disp, glGetFinalCombinerInputParameterivNV);
- SET_ResizeBuffersMESA(disp, glResizeBuffersMESA);
- SET_WindowPos2dMESA(disp, glWindowPos2dMESA);
- SET_WindowPos2dvMESA(disp, glWindowPos2dvMESA);
- SET_WindowPos2fMESA(disp, glWindowPos2fMESA);
- SET_WindowPos2fvMESA(disp, glWindowPos2fvMESA);
- SET_WindowPos2iMESA(disp, glWindowPos2iMESA);
- SET_WindowPos2ivMESA(disp, glWindowPos2ivMESA);
- SET_WindowPos2sMESA(disp, glWindowPos2sMESA);
- SET_WindowPos2svMESA(disp, glWindowPos2svMESA);
- SET_WindowPos3dMESA(disp, glWindowPos3dMESA);
- SET_WindowPos3dvMESA(disp, glWindowPos3dvMESA);
- SET_WindowPos3fMESA(disp, glWindowPos3fMESA);
- SET_WindowPos3fvMESA(disp, glWindowPos3fvMESA);
- SET_WindowPos3iMESA(disp, glWindowPos3iMESA);
- SET_WindowPos3ivMESA(disp, glWindowPos3ivMESA);
- SET_WindowPos3sMESA(disp, glWindowPos3sMESA);
- SET_WindowPos3svMESA(disp, glWindowPos3svMESA);
- SET_WindowPos4dMESA(disp, glWindowPos4dMESA);
- SET_WindowPos4dvMESA(disp, glWindowPos4dvMESA);
- SET_WindowPos4fMESA(disp, glWindowPos4fMESA);
- SET_WindowPos4fvMESA(disp, glWindowPos4fvMESA);
- SET_WindowPos4iMESA(disp, glWindowPos4iMESA);
- SET_WindowPos4ivMESA(disp, glWindowPos4ivMESA);
- SET_WindowPos4sMESA(disp, glWindowPos4sMESA);
- SET_WindowPos4svMESA(disp, glWindowPos4svMESA);
- SET_BlendFuncSeparateEXT(disp, glBlendFuncSeparateEXT);
- SET_IndexMaterialEXT(disp, glIndexMaterialEXT);
- SET_IndexFuncEXT(disp, glIndexFuncEXT);
- SET_LockArraysEXT(disp, glLockArraysEXT);
- SET_UnlockArraysEXT(disp, glUnlockArraysEXT);
- SET_CullParameterdvEXT(disp, glCullParameterdvEXT);
- SET_CullParameterfvEXT(disp, glCullParameterfvEXT);
- SET_HintPGI(disp, glHintPGI);
- SET_FogCoordfEXT(disp, glFogCoordfEXT);
- SET_FogCoordfvEXT(disp, glFogCoordfvEXT);
- SET_FogCoorddEXT(disp, glFogCoorddEXT);
- SET_FogCoorddvEXT(disp, glFogCoorddvEXT);
- SET_FogCoordPointerEXT(disp, glFogCoordPointerEXT);
- SET_GetColorTableEXT(disp, glGetColorTableEXT);
- SET_GetColorTableParameterivEXT(disp, glGetColorTableParameterivEXT);
- SET_GetColorTableParameterfvEXT(disp, glGetColorTableParameterfvEXT);
- SET_TbufferMask3DFX(disp, glTbufferMask3DFX);
- SET_CompressedTexImage3DARB(disp, glCompressedTexImage3DARB);
- SET_CompressedTexImage2DARB(disp, glCompressedTexImage2DARB);
- SET_CompressedTexImage1DARB(disp, glCompressedTexImage1DARB);
- SET_CompressedTexSubImage3DARB(disp, glCompressedTexSubImage3DARB);
- SET_CompressedTexSubImage2DARB(disp, glCompressedTexSubImage2DARB);
- SET_CompressedTexSubImage1DARB(disp, glCompressedTexSubImage1DARB);
- SET_GetCompressedTexImageARB(disp, glGetCompressedTexImageARB);
- SET_SecondaryColor3bEXT(disp, glSecondaryColor3bEXT);
- SET_SecondaryColor3bvEXT(disp, glSecondaryColor3bvEXT);
- SET_SecondaryColor3dEXT(disp, glSecondaryColor3dEXT);
- SET_SecondaryColor3dvEXT(disp, glSecondaryColor3dvEXT);
- SET_SecondaryColor3fEXT(disp, glSecondaryColor3fEXT);
- SET_SecondaryColor3fvEXT(disp, glSecondaryColor3fvEXT);
- SET_SecondaryColor3iEXT(disp, glSecondaryColor3iEXT);
- SET_SecondaryColor3ivEXT(disp, glSecondaryColor3ivEXT);
- SET_SecondaryColor3sEXT(disp, glSecondaryColor3sEXT);
- SET_SecondaryColor3svEXT(disp, glSecondaryColor3svEXT);
- SET_SecondaryColor3ubEXT(disp, glSecondaryColor3ubEXT);
- SET_SecondaryColor3ubvEXT(disp, glSecondaryColor3ubvEXT);
- SET_SecondaryColor3uiEXT(disp, glSecondaryColor3uiEXT);
- SET_SecondaryColor3uivEXT(disp, glSecondaryColor3uivEXT);
- SET_SecondaryColor3usEXT(disp, glSecondaryColor3usEXT);
- SET_SecondaryColor3usvEXT(disp, glSecondaryColor3usvEXT);
- SET_SecondaryColorPointerEXT(disp, glSecondaryColorPointerEXT);
- SET_AreProgramsResidentNV(disp, glAreProgramsResidentNV);
- SET_BindProgramNV(disp, glBindProgramNV);
- SET_DeleteProgramsNV(disp, glDeleteProgramsNV);
- SET_ExecuteProgramNV(disp, glExecuteProgramNV);
- SET_GenProgramsNV(disp, glGenProgramsNV);
- SET_GetProgramParameterdvNV(disp, glGetProgramParameterdvNV);
- SET_GetProgramParameterfvNV(disp, glGetProgramParameterfvNV);
- SET_GetProgramivNV(disp, glGetProgramivNV);
- SET_GetProgramStringNV(disp, glGetProgramStringNV);
- SET_GetTrackMatrixivNV(disp, glGetTrackMatrixivNV);
- SET_GetVertexAttribdvARB(disp, glGetVertexAttribdvARB);
- SET_GetVertexAttribfvARB(disp, glGetVertexAttribfvARB);
- SET_GetVertexAttribivARB(disp, glGetVertexAttribivARB);
- SET_GetVertexAttribPointervNV(disp, glGetVertexAttribPointervNV);
- SET_IsProgramNV(disp, glIsProgramNV);
- SET_LoadProgramNV(disp, glLoadProgramNV);
- SET_ProgramParameter4dNV(disp, glProgramParameter4dNV);
- SET_ProgramParameter4dvNV(disp, glProgramParameter4dvNV);
- SET_ProgramParameter4fNV(disp, glProgramParameter4fNV);
- SET_ProgramParameter4fvNV(disp, glProgramParameter4fvNV);
- SET_ProgramParameters4dvNV(disp, glProgramParameters4dvNV);
- SET_ProgramParameters4fvNV(disp, glProgramParameters4fvNV);
- SET_RequestResidentProgramsNV(disp, glRequestResidentProgramsNV);
- SET_TrackMatrixNV(disp, glTrackMatrixNV);
- SET_VertexAttribPointerNV(disp, glVertexAttribPointerNV);
- SET_VertexAttrib1dARB(disp, glVertexAttrib1dARB);
- SET_VertexAttrib1dvARB(disp, glVertexAttrib1dvARB);
- SET_VertexAttrib1fARB(disp, glVertexAttrib1fARB);
- SET_VertexAttrib1fvARB(disp, glVertexAttrib1fvARB);
- SET_VertexAttrib1sARB(disp, glVertexAttrib1sARB);
- SET_VertexAttrib1svARB(disp, glVertexAttrib1svARB);
- SET_VertexAttrib2dARB(disp, glVertexAttrib2dARB);
- SET_VertexAttrib2dvARB(disp, glVertexAttrib2dvARB);
- SET_VertexAttrib2fARB(disp, glVertexAttrib2fARB);
- SET_VertexAttrib2fvARB(disp, glVertexAttrib2fvARB);
- SET_VertexAttrib2sARB(disp, glVertexAttrib2sARB);
- SET_VertexAttrib2svARB(disp, glVertexAttrib2svARB);
- SET_VertexAttrib3dARB(disp, glVertexAttrib3dARB);
- SET_VertexAttrib3dvARB(disp, glVertexAttrib3dvARB);
- SET_VertexAttrib3fARB(disp, glVertexAttrib3fARB);
- SET_VertexAttrib3fvARB(disp, glVertexAttrib3fvARB);
- SET_VertexAttrib3sARB(disp, glVertexAttrib3sARB);
- SET_VertexAttrib3svARB(disp, glVertexAttrib3svARB);
- SET_VertexAttrib4dARB(disp, glVertexAttrib4dARB);
- SET_VertexAttrib4dvARB(disp, glVertexAttrib4dvARB);
- SET_VertexAttrib4fARB(disp, glVertexAttrib4fARB);
- SET_VertexAttrib4fvARB(disp, glVertexAttrib4fvARB);
- SET_VertexAttrib4sARB(disp, glVertexAttrib4sARB);
- SET_VertexAttrib4svARB(disp, glVertexAttrib4svARB);
- SET_VertexAttrib4NubARB(disp, glVertexAttrib4NubARB);
- SET_VertexAttrib4NubvARB(disp, glVertexAttrib4NubvARB);
- SET_VertexAttribs1dvNV(disp, glVertexAttribs1dvNV);
- SET_VertexAttribs1fvNV(disp, glVertexAttribs1fvNV);
- SET_VertexAttribs1svNV(disp, glVertexAttribs1svNV);
- SET_VertexAttribs2dvNV(disp, glVertexAttribs2dvNV);
- SET_VertexAttribs2fvNV(disp, glVertexAttribs2fvNV);
- SET_VertexAttribs2svNV(disp, glVertexAttribs2svNV);
- SET_VertexAttribs3dvNV(disp, glVertexAttribs3dvNV);
- SET_VertexAttribs3fvNV(disp, glVertexAttribs3fvNV);
- SET_VertexAttribs3svNV(disp, glVertexAttribs3svNV);
- SET_VertexAttribs4dvNV(disp, glVertexAttribs4dvNV);
- SET_VertexAttribs4fvNV(disp, glVertexAttribs4fvNV);
- SET_VertexAttribs4svNV(disp, glVertexAttribs4svNV);
- SET_VertexAttribs4ubvNV(disp, glVertexAttribs4ubvNV);
- SET_PointParameteriNV(disp, glPointParameteriNV);
- SET_PointParameterivNV(disp, glPointParameterivNV);
- SET_MultiDrawArraysEXT(disp, glMultiDrawArraysEXT);
- SET_MultiDrawElementsEXT(disp, glMultiDrawElementsEXT);
- SET_ActiveStencilFaceEXT(disp, glActiveStencilFaceEXT);
- SET_DeleteFencesNV(disp, glDeleteFencesNV);
- SET_GenFencesNV(disp, glGenFencesNV);
- SET_IsFenceNV(disp, glIsFenceNV);
- SET_TestFenceNV(disp, glTestFenceNV);
- SET_GetFenceivNV(disp, glGetFenceivNV);
- SET_FinishFenceNV(disp, glFinishFenceNV);
- SET_SetFenceNV(disp, glSetFenceNV);
- SET_VertexAttrib4bvARB(disp, glVertexAttrib4bvARB);
- SET_VertexAttrib4ivARB(disp, glVertexAttrib4ivARB);
- SET_VertexAttrib4ubvARB(disp, glVertexAttrib4ubvARB);
- SET_VertexAttrib4usvARB(disp, glVertexAttrib4usvARB);
- SET_VertexAttrib4uivARB(disp, glVertexAttrib4uivARB);
- SET_VertexAttrib4NbvARB(disp, glVertexAttrib4NbvARB);
- SET_VertexAttrib4NsvARB(disp, glVertexAttrib4NsvARB);
- SET_VertexAttrib4NivARB(disp, glVertexAttrib4NivARB);
- SET_VertexAttrib4NusvARB(disp, glVertexAttrib4NusvARB);
- SET_VertexAttrib4NuivARB(disp, glVertexAttrib4NuivARB);
- SET_VertexAttribPointerARB(disp, glVertexAttribPointerARB);
- SET_EnableVertexAttribArrayARB(disp, glEnableVertexAttribArrayARB);
- SET_DisableVertexAttribArrayARB(disp, glDisableVertexAttribArrayARB);
- SET_ProgramStringARB(disp, glProgramStringARB);
- SET_ProgramEnvParameter4dARB(disp, glProgramEnvParameter4dARB);
- SET_ProgramEnvParameter4dvARB(disp, glProgramEnvParameter4dvARB);
- SET_ProgramEnvParameter4fARB(disp, glProgramEnvParameter4fARB);
- SET_ProgramEnvParameter4fvARB(disp, glProgramEnvParameter4fvARB);
- SET_ProgramLocalParameter4dARB(disp, glProgramLocalParameter4dARB);
- SET_ProgramLocalParameter4dvARB(disp, glProgramLocalParameter4dvARB);
- SET_ProgramLocalParameter4fARB(disp, glProgramLocalParameter4fARB);
- SET_ProgramLocalParameter4fvARB(disp, glProgramLocalParameter4fvARB);
- SET_GetProgramEnvParameterdvARB(disp, glGetProgramEnvParameterdvARB);
- SET_GetProgramEnvParameterfvARB(disp, glGetProgramEnvParameterfvARB);
- SET_GetProgramLocalParameterdvARB(disp, glGetProgramLocalParameterdvARB);
- SET_GetProgramLocalParameterfvARB(disp, glGetProgramLocalParameterfvARB);
- SET_GetProgramivARB(disp, glGetProgramivARB);
- SET_GetProgramStringARB(disp, glGetProgramStringARB);
- SET_ProgramNamedParameter4fNV(disp, glProgramNamedParameter4fNV);
- SET_ProgramNamedParameter4dNV(disp, glProgramNamedParameter4dNV);
- SET_ProgramNamedParameter4fvNV(disp, glProgramNamedParameter4fvNV);
- SET_ProgramNamedParameter4dvNV(disp, glProgramNamedParameter4dvNV);
- SET_GetProgramNamedParameterfvNV(disp, glGetProgramNamedParameterfvNV);
- SET_GetProgramNamedParameterdvNV(disp, glGetProgramNamedParameterdvNV);
- SET_BindBufferARB(disp, glBindBufferARB);
- SET_BufferDataARB(disp, glBufferDataARB);
- SET_BufferSubDataARB(disp, glBufferSubDataARB);
- SET_DeleteBuffersARB(disp, glDeleteBuffersARB);
- SET_GenBuffersARB(disp, glGenBuffersARB);
- SET_GetBufferParameterivARB(disp, glGetBufferParameterivARB);
- SET_GetBufferPointervARB(disp, glGetBufferPointervARB);
- SET_GetBufferSubDataARB(disp, glGetBufferSubDataARB);
- SET_IsBufferARB(disp, glIsBufferARB);
- SET_MapBufferARB(disp, glMapBufferARB);
- SET_UnmapBufferARB(disp, glUnmapBufferARB);
- SET_DepthBoundsEXT(disp, glDepthBoundsEXT);
- SET_GenQueriesARB(disp, glGenQueriesARB);
- SET_DeleteQueriesARB(disp, glDeleteQueriesARB);
- SET_IsQueryARB(disp, glIsQueryARB);
- SET_BeginQueryARB(disp, glBeginQueryARB);
- SET_EndQueryARB(disp, glEndQueryARB);
- SET_GetQueryivARB(disp, glGetQueryivARB);
- SET_GetQueryObjectivARB(disp, glGetQueryObjectivARB);
- SET_GetQueryObjectuivARB(disp, glGetQueryObjectuivARB);
- SET_MultiModeDrawArraysIBM(disp, glMultiModeDrawArraysIBM);
- SET_MultiModeDrawElementsIBM(disp, glMultiModeDrawElementsIBM);
- SET_BlendEquationSeparateEXT(disp, glBlendEquationSeparateEXT);
- SET_DeleteObjectARB(disp, glDeleteObjectARB);
- SET_GetHandleARB(disp, glGetHandleARB);
- SET_DetachObjectARB(disp, glDetachObjectARB);
- SET_CreateShaderObjectARB(disp, glCreateShaderObjectARB);
- SET_ShaderSourceARB(disp, glShaderSourceARB);
- SET_CompileShaderARB(disp, glCompileShaderARB);
- SET_CreateProgramObjectARB(disp, glCreateProgramObjectARB);
- SET_AttachObjectARB(disp, glAttachObjectARB);
- SET_LinkProgramARB(disp, glLinkProgramARB);
- SET_UseProgramObjectARB(disp, glUseProgramObjectARB);
- SET_ValidateProgramARB(disp, glValidateProgramARB);
- SET_Uniform1fARB(disp, glUniform1fARB);
- SET_Uniform2fARB(disp, glUniform2fARB);
- SET_Uniform3fARB(disp, glUniform3fARB);
- SET_Uniform4fARB(disp, glUniform4fARB);
- SET_Uniform1iARB(disp, glUniform1iARB);
- SET_Uniform2iARB(disp, glUniform2iARB);
- SET_Uniform3iARB(disp, glUniform3iARB);
- SET_Uniform4iARB(disp, glUniform4iARB);
- SET_Uniform1fvARB(disp, glUniform1fvARB);
- SET_Uniform2fvARB(disp, glUniform2fvARB);
- SET_Uniform3fvARB(disp, glUniform3fvARB);
- SET_Uniform4fvARB(disp, glUniform4fvARB);
- SET_Uniform1ivARB(disp, glUniform1ivARB);
- SET_Uniform2ivARB(disp, glUniform2ivARB);
- SET_Uniform3ivARB(disp, glUniform3ivARB);
- SET_Uniform4ivARB(disp, glUniform4ivARB);
- SET_UniformMatrix2fvARB(disp, glUniformMatrix2fvARB);
- SET_UniformMatrix3fvARB(disp, glUniformMatrix3fvARB);
- SET_UniformMatrix4fvARB(disp, glUniformMatrix4fvARB);
- SET_GetObjectParameterfvARB(disp, glGetObjectParameterfvARB);
- SET_GetObjectParameterivARB(disp, glGetObjectParameterivARB);
- SET_GetInfoLogARB(disp, glGetInfoLogARB);
- SET_GetAttachedObjectsARB(disp, glGetAttachedObjectsARB);
- SET_GetUniformLocationARB(disp, glGetUniformLocationARB);
- SET_GetActiveUniformARB(disp, glGetActiveUniformARB);
- SET_GetUniformfvARB(disp, glGetUniformfvARB);
- SET_GetUniformivARB(disp, glGetUniformivARB);
- SET_GetShaderSourceARB(disp, glGetShaderSourceARB);
- SET_BindAttribLocationARB(disp, glBindAttribLocationARB);
- SET_GetActiveAttribARB(disp, glGetActiveAttribARB);
- SET_GetAttribLocationARB(disp, glGetAttribLocationARB);
- SET_GetVertexAttribdvNV(disp, glGetVertexAttribdvNV);
- SET_GetVertexAttribfvNV(disp, glGetVertexAttribfvNV);
- SET_GetVertexAttribivNV(disp, glGetVertexAttribivNV);
- SET_VertexAttrib1dNV(disp, glVertexAttrib1dNV);
- SET_VertexAttrib1dvNV(disp, glVertexAttrib1dvNV);
- SET_VertexAttrib1fNV(disp, glVertexAttrib1fNV);
- SET_VertexAttrib1fvNV(disp, glVertexAttrib1fvNV);
- SET_VertexAttrib1sNV(disp, glVertexAttrib1sNV);
- SET_VertexAttrib1svNV(disp, glVertexAttrib1svNV);
- SET_VertexAttrib2dNV(disp, glVertexAttrib2dNV);
- SET_VertexAttrib2dvNV(disp, glVertexAttrib2dvNV);
- SET_VertexAttrib2fNV(disp, glVertexAttrib2fNV);
- SET_VertexAttrib2fvNV(disp, glVertexAttrib2fvNV);
- SET_VertexAttrib2sNV(disp, glVertexAttrib2sNV);
- SET_VertexAttrib2svNV(disp, glVertexAttrib2svNV);
- SET_VertexAttrib3dNV(disp, glVertexAttrib3dNV);
- SET_VertexAttrib3dvNV(disp, glVertexAttrib3dvNV);
- SET_VertexAttrib3fNV(disp, glVertexAttrib3fNV);
- SET_VertexAttrib3fvNV(disp, glVertexAttrib3fvNV);
- SET_VertexAttrib3sNV(disp, glVertexAttrib3sNV);
- SET_VertexAttrib3svNV(disp, glVertexAttrib3svNV);
- SET_VertexAttrib4dNV(disp, glVertexAttrib4dNV);
- SET_VertexAttrib4dvNV(disp, glVertexAttrib4dvNV);
- SET_VertexAttrib4fNV(disp, glVertexAttrib4fNV);
- SET_VertexAttrib4fvNV(disp, glVertexAttrib4fvNV);
- SET_VertexAttrib4sNV(disp, glVertexAttrib4sNV);
- SET_VertexAttrib4svNV(disp, glVertexAttrib4svNV);
- SET_VertexAttrib4ubNV(disp, glVertexAttrib4ubNV);
- SET_VertexAttrib4ubvNV(disp, glVertexAttrib4ubvNV);
- SET_GenFragmentShadersATI(disp, glGenFragmentShadersATI);
- SET_BindFragmentShaderATI(disp, glBindFragmentShaderATI);
- SET_DeleteFragmentShaderATI(disp, glDeleteFragmentShaderATI);
- SET_BeginFragmentShaderATI(disp, glBeginFragmentShaderATI);
- SET_EndFragmentShaderATI(disp, glEndFragmentShaderATI);
- SET_PassTexCoordATI(disp, glPassTexCoordATI);
- SET_SampleMapATI(disp, glSampleMapATI);
- SET_ColorFragmentOp1ATI(disp, glColorFragmentOp1ATI);
- SET_ColorFragmentOp2ATI(disp, glColorFragmentOp2ATI);
- SET_ColorFragmentOp3ATI(disp, glColorFragmentOp3ATI);
- SET_AlphaFragmentOp1ATI(disp, glAlphaFragmentOp1ATI);
- SET_AlphaFragmentOp2ATI(disp, glAlphaFragmentOp2ATI);
- SET_AlphaFragmentOp3ATI(disp, glAlphaFragmentOp3ATI);
- SET_SetFragmentShaderConstantATI(disp, glSetFragmentShaderConstantATI);
- SET_IsRenderbufferEXT(disp, glIsRenderbufferEXT);
- SET_BindRenderbufferEXT(disp, glBindRenderbufferEXT);
- SET_DeleteRenderbuffersEXT(disp, glDeleteRenderbuffersEXT);
- SET_GenRenderbuffersEXT(disp, glGenRenderbuffersEXT);
- SET_RenderbufferStorageEXT(disp, glRenderbufferStorageEXT);
- SET_GetRenderbufferParameterivEXT(disp, glGetRenderbufferParameterivEXT);
- SET_IsFramebufferEXT(disp, glIsFramebufferEXT);
- SET_BindFramebufferEXT(disp, glBindFramebufferEXT);
- SET_DeleteFramebuffersEXT(disp, glDeleteFramebuffersEXT);
- SET_GenFramebuffersEXT(disp, glGenFramebuffersEXT);
- SET_CheckFramebufferStatusEXT(disp, glCheckFramebufferStatusEXT);
- SET_FramebufferTexture1DEXT(disp, glFramebufferTexture1DEXT);
- SET_FramebufferTexture2DEXT(disp, glFramebufferTexture2DEXT);
- SET_FramebufferTexture3DEXT(disp, glFramebufferTexture3DEXT);
- SET_FramebufferRenderbufferEXT(disp, glFramebufferRenderbufferEXT);
- SET_GetFramebufferAttachmentParameterivEXT(disp, glGetFramebufferAttachmentParameterivEXT);
- SET_GenerateMipmapEXT(disp, glGenerateMipmapEXT);
- SET_StencilFuncSeparate(disp, glStencilFuncSeparate);
- SET_StencilOpSeparate(disp, glStencilOpSeparate);
- SET_StencilMaskSeparate(disp, glStencilMaskSeparate);
- SET_GetQueryObjecti64vEXT(disp, glGetQueryObjecti64vEXT);
- SET_GetQueryObjectui64vEXT(disp, glGetQueryObjectui64vEXT);
- SET_BlitFramebufferEXT(disp, glBlitFramebufferEXT);
- SET_LoadTransposeMatrixfARB(disp, glLoadTransposeMatrixfARB);
- SET_LoadTransposeMatrixdARB(disp, glLoadTransposeMatrixdARB);
- SET_MultTransposeMatrixfARB(disp, glMultTransposeMatrixfARB);
- SET_MultTransposeMatrixdARB(disp, glMultTransposeMatrixdARB);
- SET_SampleCoverageARB(disp, glSampleCoverageARB);
- SET_DrawBuffersARB(disp, glDrawBuffersARB);
- SET_PolygonOffsetEXT(disp, glPolygonOffsetEXT);
- SET_GetTexFilterFuncSGIS(disp, glGetTexFilterFuncSGIS);
- SET_TexFilterFuncSGIS(disp, glTexFilterFuncSGIS);
- SET_GetHistogramEXT(disp, glGetHistogramEXT);
- SET_GetHistogramParameterfvEXT(disp, glGetHistogramParameterfvEXT);
- SET_GetHistogramParameterivEXT(disp, glGetHistogramParameterivEXT);
- SET_GetMinmaxEXT(disp, glGetMinmaxEXT);
- SET_GetMinmaxParameterfvEXT(disp, glGetMinmaxParameterfvEXT);
- SET_GetMinmaxParameterivEXT(disp, glGetMinmaxParameterivEXT);
- SET_GetConvolutionFilterEXT(disp, glGetConvolutionFilterEXT);
- SET_GetConvolutionParameterfvEXT(disp, glGetConvolutionParameterfvEXT);
- SET_GetConvolutionParameterivEXT(disp, glGetConvolutionParameterivEXT);
- SET_GetSeparableFilterEXT(disp, glGetSeparableFilterEXT);
- SET_GetColorTableSGI(disp, glGetColorTableSGI);
- SET_GetColorTableParameterfvSGI(disp, glGetColorTableParameterfvSGI);
- SET_GetColorTableParameterivSGI(disp, glGetColorTableParameterivSGI);
- SET_PixelTexGenSGIX(disp, glPixelTexGenSGIX);
- SET_PixelTexGenParameteriSGIS(disp, glPixelTexGenParameteriSGIS);
- SET_PixelTexGenParameterivSGIS(disp, glPixelTexGenParameterivSGIS);
- SET_PixelTexGenParameterfSGIS(disp, glPixelTexGenParameterfSGIS);
- SET_PixelTexGenParameterfvSGIS(disp, glPixelTexGenParameterfvSGIS);
- SET_GetPixelTexGenParameterivSGIS(disp, glGetPixelTexGenParameterivSGIS);
- SET_GetPixelTexGenParameterfvSGIS(disp, glGetPixelTexGenParameterfvSGIS);
- SET_TexImage4DSGIS(disp, glTexImage4DSGIS);
- SET_TexSubImage4DSGIS(disp, glTexSubImage4DSGIS);
- SET_AreTexturesResidentEXT(disp, glAreTexturesResidentEXT);
- SET_GenTexturesEXT(disp, glGenTexturesEXT);
- SET_IsTextureEXT(disp, glIsTextureEXT);
- SET_DetailTexFuncSGIS(disp, glDetailTexFuncSGIS);
- SET_GetDetailTexFuncSGIS(disp, glGetDetailTexFuncSGIS);
- SET_SharpenTexFuncSGIS(disp, glSharpenTexFuncSGIS);
- SET_GetSharpenTexFuncSGIS(disp, glGetSharpenTexFuncSGIS);
- SET_SampleMaskSGIS(disp, glSampleMaskSGIS);
- SET_SamplePatternSGIS(disp, glSamplePatternSGIS);
- SET_ColorPointerEXT(disp, glColorPointerEXT);
- SET_EdgeFlagPointerEXT(disp, glEdgeFlagPointerEXT);
- SET_IndexPointerEXT(disp, glIndexPointerEXT);
- SET_NormalPointerEXT(disp, glNormalPointerEXT);
- SET_TexCoordPointerEXT(disp, glTexCoordPointerEXT);
- SET_VertexPointerEXT(disp, glVertexPointerEXT);
- SET_SpriteParameterfSGIX(disp, glSpriteParameterfSGIX);
- SET_SpriteParameterfvSGIX(disp, glSpriteParameterfvSGIX);
- SET_SpriteParameteriSGIX(disp, glSpriteParameteriSGIX);
- SET_SpriteParameterivSGIX(disp, glSpriteParameterivSGIX);
- SET_PointParameterfEXT(disp, glPointParameterfEXT);
- SET_PointParameterfvEXT(disp, glPointParameterfvEXT);
- SET_GetInstrumentsSGIX(disp, glGetInstrumentsSGIX);
- SET_InstrumentsBufferSGIX(disp, glInstrumentsBufferSGIX);
- SET_PollInstrumentsSGIX(disp, glPollInstrumentsSGIX);
- SET_ReadInstrumentsSGIX(disp, glReadInstrumentsSGIX);
- SET_StartInstrumentsSGIX(disp, glStartInstrumentsSGIX);
- SET_StopInstrumentsSGIX(disp, glStopInstrumentsSGIX);
- SET_FrameZoomSGIX(disp, glFrameZoomSGIX);
- SET_TagSampleBufferSGIX(disp, glTagSampleBufferSGIX);
- SET_ReferencePlaneSGIX(disp, glReferencePlaneSGIX);
- SET_FlushRasterSGIX(disp, glFlushRasterSGIX);
- SET_GetListParameterfvSGIX(disp, glGetListParameterfvSGIX);
- SET_GetListParameterivSGIX(disp, glGetListParameterivSGIX);
- SET_ListParameterfSGIX(disp, glListParameterfSGIX);
- SET_ListParameterfvSGIX(disp, glListParameterfvSGIX);
- SET_ListParameteriSGIX(disp, glListParameteriSGIX);
- SET_ListParameterivSGIX(disp, glListParameterivSGIX);
- SET_FragmentColorMaterialSGIX(disp, glFragmentColorMaterialSGIX);
- SET_FragmentLightfSGIX(disp, glFragmentLightfSGIX);
- SET_FragmentLightfvSGIX(disp, glFragmentLightfvSGIX);
- SET_FragmentLightiSGIX(disp, glFragmentLightiSGIX);
- SET_FragmentLightivSGIX(disp, glFragmentLightivSGIX);
- SET_FragmentLightModelfSGIX(disp, glFragmentLightModelfSGIX);
- SET_FragmentLightModelfvSGIX(disp, glFragmentLightModelfvSGIX);
- SET_FragmentLightModeliSGIX(disp, glFragmentLightModeliSGIX);
- SET_FragmentLightModelivSGIX(disp, glFragmentLightModelivSGIX);
- SET_FragmentMaterialfSGIX(disp, glFragmentMaterialfSGIX);
- SET_FragmentMaterialfvSGIX(disp, glFragmentMaterialfvSGIX);
- SET_FragmentMaterialiSGIX(disp, glFragmentMaterialiSGIX);
- SET_FragmentMaterialivSGIX(disp, glFragmentMaterialivSGIX);
- SET_GetFragmentLightfvSGIX(disp, glGetFragmentLightfvSGIX);
- SET_GetFragmentLightivSGIX(disp, glGetFragmentLightivSGIX);
- SET_GetFragmentMaterialfvSGIX(disp, glGetFragmentMaterialfvSGIX);
- SET_GetFragmentMaterialivSGIX(disp, glGetFragmentMaterialivSGIX);
- SET_LightEnviSGIX(disp, glLightEnviSGIX);
- SET_VertexWeightfEXT(disp, glVertexWeightfEXT);
- SET_VertexWeightfvEXT(disp, glVertexWeightfvEXT);
- SET_VertexWeightPointerEXT(disp, glVertexWeightPointerEXT);
- SET_FlushVertexArrayRangeNV(disp, glFlushVertexArrayRangeNV);
- SET_VertexArrayRangeNV(disp, glVertexArrayRangeNV);
- SET_CombinerParameterfvNV(disp, glCombinerParameterfvNV);
- SET_CombinerParameterfNV(disp, glCombinerParameterfNV);
- SET_CombinerParameterivNV(disp, glCombinerParameterivNV);
- SET_CombinerParameteriNV(disp, glCombinerParameteriNV);
- SET_CombinerInputNV(disp, glCombinerInputNV);
- SET_CombinerOutputNV(disp, glCombinerOutputNV);
- SET_FinalCombinerInputNV(disp, glFinalCombinerInputNV);
- SET_GetCombinerInputParameterfvNV(disp, glGetCombinerInputParameterfvNV);
- SET_GetCombinerInputParameterivNV(disp, glGetCombinerInputParameterivNV);
- SET_GetCombinerOutputParameterfvNV(disp, glGetCombinerOutputParameterfvNV);
- SET_GetCombinerOutputParameterivNV(disp, glGetCombinerOutputParameterivNV);
- SET_GetFinalCombinerInputParameterfvNV(disp, glGetFinalCombinerInputParameterfvNV);
- SET_GetFinalCombinerInputParameterivNV(disp, glGetFinalCombinerInputParameterivNV);
- SET_ResizeBuffersMESA(disp, glResizeBuffersMESA);
- SET_WindowPos2dMESA(disp, glWindowPos2dMESA);
- SET_WindowPos2dvMESA(disp, glWindowPos2dvMESA);
- SET_WindowPos2fMESA(disp, glWindowPos2fMESA);
- SET_WindowPos2fvMESA(disp, glWindowPos2fvMESA);
- SET_WindowPos2iMESA(disp, glWindowPos2iMESA);
- SET_WindowPos2ivMESA(disp, glWindowPos2ivMESA);
- SET_WindowPos2sMESA(disp, glWindowPos2sMESA);
- SET_WindowPos2svMESA(disp, glWindowPos2svMESA);
- SET_WindowPos3dMESA(disp, glWindowPos3dMESA);
- SET_WindowPos3dvMESA(disp, glWindowPos3dvMESA);
- SET_WindowPos3fMESA(disp, glWindowPos3fMESA);
- SET_WindowPos3fvMESA(disp, glWindowPos3fvMESA);
- SET_WindowPos3iMESA(disp, glWindowPos3iMESA);
- SET_WindowPos3ivMESA(disp, glWindowPos3ivMESA);
- SET_WindowPos3sMESA(disp, glWindowPos3sMESA);
- SET_WindowPos3svMESA(disp, glWindowPos3svMESA);
- SET_WindowPos4dMESA(disp, glWindowPos4dMESA);
- SET_WindowPos4dvMESA(disp, glWindowPos4dvMESA);
- SET_WindowPos4fMESA(disp, glWindowPos4fMESA);
- SET_WindowPos4fvMESA(disp, glWindowPos4fvMESA);
- SET_WindowPos4iMESA(disp, glWindowPos4iMESA);
- SET_WindowPos4ivMESA(disp, glWindowPos4ivMESA);
- SET_WindowPos4sMESA(disp, glWindowPos4sMESA);
- SET_WindowPos4svMESA(disp, glWindowPos4svMESA);
- SET_BlendFuncSeparateEXT(disp, glBlendFuncSeparateEXT);
- SET_IndexMaterialEXT(disp, glIndexMaterialEXT);
- SET_IndexFuncEXT(disp, glIndexFuncEXT);
- SET_LockArraysEXT(disp, glLockArraysEXT);
- SET_UnlockArraysEXT(disp, glUnlockArraysEXT);
- SET_CullParameterdvEXT(disp, glCullParameterdvEXT);
- SET_CullParameterfvEXT(disp, glCullParameterfvEXT);
- SET_HintPGI(disp, glHintPGI);
- SET_FogCoordfEXT(disp, glFogCoordfEXT);
- SET_FogCoordfvEXT(disp, glFogCoordfvEXT);
- SET_FogCoorddEXT(disp, glFogCoorddEXT);
- SET_FogCoorddvEXT(disp, glFogCoorddvEXT);
- SET_FogCoordPointerEXT(disp, glFogCoordPointerEXT);
- SET_GetColorTableEXT(disp, glGetColorTableEXT);
- SET_GetColorTableParameterivEXT(disp, glGetColorTableParameterivEXT);
- SET_GetColorTableParameterfvEXT(disp, glGetColorTableParameterfvEXT);
- SET_TbufferMask3DFX(disp, glTbufferMask3DFX);
- SET_CompressedTexImage3DARB(disp, glCompressedTexImage3DARB);
- SET_CompressedTexImage2DARB(disp, glCompressedTexImage2DARB);
- SET_CompressedTexImage1DARB(disp, glCompressedTexImage1DARB);
- SET_CompressedTexSubImage3DARB(disp, glCompressedTexSubImage3DARB);
- SET_CompressedTexSubImage2DARB(disp, glCompressedTexSubImage2DARB);
- SET_CompressedTexSubImage1DARB(disp, glCompressedTexSubImage1DARB);
- SET_GetCompressedTexImageARB(disp, glGetCompressedTexImageARB);
- SET_SecondaryColor3bEXT(disp, glSecondaryColor3bEXT);
- SET_SecondaryColor3bvEXT(disp, glSecondaryColor3bvEXT);
- SET_SecondaryColor3dEXT(disp, glSecondaryColor3dEXT);
- SET_SecondaryColor3dvEXT(disp, glSecondaryColor3dvEXT);
- SET_SecondaryColor3fEXT(disp, glSecondaryColor3fEXT);
- SET_SecondaryColor3fvEXT(disp, glSecondaryColor3fvEXT);
- SET_SecondaryColor3iEXT(disp, glSecondaryColor3iEXT);
- SET_SecondaryColor3ivEXT(disp, glSecondaryColor3ivEXT);
- SET_SecondaryColor3sEXT(disp, glSecondaryColor3sEXT);
- SET_SecondaryColor3svEXT(disp, glSecondaryColor3svEXT);
- SET_SecondaryColor3ubEXT(disp, glSecondaryColor3ubEXT);
- SET_SecondaryColor3ubvEXT(disp, glSecondaryColor3ubvEXT);
- SET_SecondaryColor3uiEXT(disp, glSecondaryColor3uiEXT);
- SET_SecondaryColor3uivEXT(disp, glSecondaryColor3uivEXT);
- SET_SecondaryColor3usEXT(disp, glSecondaryColor3usEXT);
- SET_SecondaryColor3usvEXT(disp, glSecondaryColor3usvEXT);
- SET_SecondaryColorPointerEXT(disp, glSecondaryColorPointerEXT);
- SET_AreProgramsResidentNV(disp, glAreProgramsResidentNV);
- SET_BindProgramNV(disp, glBindProgramNV);
- SET_DeleteProgramsNV(disp, glDeleteProgramsNV);
- SET_ExecuteProgramNV(disp, glExecuteProgramNV);
- SET_GenProgramsNV(disp, glGenProgramsNV);
- SET_GetProgramParameterdvNV(disp, glGetProgramParameterdvNV);
- SET_GetProgramParameterfvNV(disp, glGetProgramParameterfvNV);
- SET_GetProgramivNV(disp, glGetProgramivNV);
- SET_GetProgramStringNV(disp, glGetProgramStringNV);
- SET_GetTrackMatrixivNV(disp, glGetTrackMatrixivNV);
- SET_GetVertexAttribdvARB(disp, glGetVertexAttribdvARB);
- SET_GetVertexAttribfvARB(disp, glGetVertexAttribfvARB);
- SET_GetVertexAttribivARB(disp, glGetVertexAttribivARB);
- SET_GetVertexAttribPointervNV(disp, glGetVertexAttribPointervNV);
- SET_IsProgramNV(disp, glIsProgramNV);
- SET_LoadProgramNV(disp, glLoadProgramNV);
- SET_ProgramParameter4dNV(disp, glProgramParameter4dNV);
- SET_ProgramParameter4dvNV(disp, glProgramParameter4dvNV);
- SET_ProgramParameter4fNV(disp, glProgramParameter4fNV);
- SET_ProgramParameter4fvNV(disp, glProgramParameter4fvNV);
- SET_ProgramParameters4dvNV(disp, glProgramParameters4dvNV);
- SET_ProgramParameters4fvNV(disp, glProgramParameters4fvNV);
- SET_RequestResidentProgramsNV(disp, glRequestResidentProgramsNV);
- SET_TrackMatrixNV(disp, glTrackMatrixNV);
- SET_VertexAttribPointerNV(disp, glVertexAttribPointerNV);
- SET_VertexAttrib1dARB(disp, glVertexAttrib1dARB);
- SET_VertexAttrib1dvARB(disp, glVertexAttrib1dvARB);
- SET_VertexAttrib1fARB(disp, glVertexAttrib1fARB);
- SET_VertexAttrib1fvARB(disp, glVertexAttrib1fvARB);
- SET_VertexAttrib1sARB(disp, glVertexAttrib1sARB);
- SET_VertexAttrib1svARB(disp, glVertexAttrib1svARB);
- SET_VertexAttrib2dARB(disp, glVertexAttrib2dARB);
- SET_VertexAttrib2dvARB(disp, glVertexAttrib2dvARB);
- SET_VertexAttrib2fARB(disp, glVertexAttrib2fARB);
- SET_VertexAttrib2fvARB(disp, glVertexAttrib2fvARB);
- SET_VertexAttrib2sARB(disp, glVertexAttrib2sARB);
- SET_VertexAttrib2svARB(disp, glVertexAttrib2svARB);
- SET_VertexAttrib3dARB(disp, glVertexAttrib3dARB);
- SET_VertexAttrib3dvARB(disp, glVertexAttrib3dvARB);
- SET_VertexAttrib3fARB(disp, glVertexAttrib3fARB);
- SET_VertexAttrib3fvARB(disp, glVertexAttrib3fvARB);
- SET_VertexAttrib3sARB(disp, glVertexAttrib3sARB);
- SET_VertexAttrib3svARB(disp, glVertexAttrib3svARB);
- SET_VertexAttrib4dARB(disp, glVertexAttrib4dARB);
- SET_VertexAttrib4dvARB(disp, glVertexAttrib4dvARB);
- SET_VertexAttrib4fARB(disp, glVertexAttrib4fARB);
- SET_VertexAttrib4fvARB(disp, glVertexAttrib4fvARB);
- SET_VertexAttrib4sARB(disp, glVertexAttrib4sARB);
- SET_VertexAttrib4svARB(disp, glVertexAttrib4svARB);
- SET_VertexAttrib4NubARB(disp, glVertexAttrib4NubARB);
- SET_VertexAttrib4NubvARB(disp, glVertexAttrib4NubvARB);
- SET_VertexAttribs1dvNV(disp, glVertexAttribs1dvNV);
- SET_VertexAttribs1fvNV(disp, glVertexAttribs1fvNV);
- SET_VertexAttribs1svNV(disp, glVertexAttribs1svNV);
- SET_VertexAttribs2dvNV(disp, glVertexAttribs2dvNV);
- SET_VertexAttribs2fvNV(disp, glVertexAttribs2fvNV);
- SET_VertexAttribs2svNV(disp, glVertexAttribs2svNV);
- SET_VertexAttribs3dvNV(disp, glVertexAttribs3dvNV);
- SET_VertexAttribs3fvNV(disp, glVertexAttribs3fvNV);
- SET_VertexAttribs3svNV(disp, glVertexAttribs3svNV);
- SET_VertexAttribs4dvNV(disp, glVertexAttribs4dvNV);
- SET_VertexAttribs4fvNV(disp, glVertexAttribs4fvNV);
- SET_VertexAttribs4svNV(disp, glVertexAttribs4svNV);
- SET_VertexAttribs4ubvNV(disp, glVertexAttribs4ubvNV);
- SET_PointParameteriNV(disp, glPointParameteriNV);
- SET_PointParameterivNV(disp, glPointParameterivNV);
- SET_MultiDrawArraysEXT(disp, glMultiDrawArraysEXT);
- SET_MultiDrawElementsEXT(disp, glMultiDrawElementsEXT);
- SET_ActiveStencilFaceEXT(disp, glActiveStencilFaceEXT);
- SET_DeleteFencesNV(disp, glDeleteFencesNV);
- SET_GenFencesNV(disp, glGenFencesNV);
- SET_IsFenceNV(disp, glIsFenceNV);
- SET_TestFenceNV(disp, glTestFenceNV);
- SET_GetFenceivNV(disp, glGetFenceivNV);
- SET_FinishFenceNV(disp, glFinishFenceNV);
- SET_SetFenceNV(disp, glSetFenceNV);
- SET_VertexAttrib4bvARB(disp, glVertexAttrib4bvARB);
- SET_VertexAttrib4ivARB(disp, glVertexAttrib4ivARB);
- SET_VertexAttrib4ubvARB(disp, glVertexAttrib4ubvARB);
- SET_VertexAttrib4usvARB(disp, glVertexAttrib4usvARB);
- SET_VertexAttrib4uivARB(disp, glVertexAttrib4uivARB);
- SET_VertexAttrib4NbvARB(disp, glVertexAttrib4NbvARB);
- SET_VertexAttrib4NsvARB(disp, glVertexAttrib4NsvARB);
- SET_VertexAttrib4NivARB(disp, glVertexAttrib4NivARB);
- SET_VertexAttrib4NusvARB(disp, glVertexAttrib4NusvARB);
- SET_VertexAttrib4NuivARB(disp, glVertexAttrib4NuivARB);
- SET_VertexAttribPointerARB(disp, glVertexAttribPointerARB);
- SET_EnableVertexAttribArrayARB(disp, glEnableVertexAttribArrayARB);
- SET_DisableVertexAttribArrayARB(disp, glDisableVertexAttribArrayARB);
- SET_ProgramStringARB(disp, glProgramStringARB);
- SET_ProgramEnvParameter4dARB(disp, glProgramEnvParameter4dARB);
- SET_ProgramEnvParameter4dvARB(disp, glProgramEnvParameter4dvARB);
- SET_ProgramEnvParameter4fARB(disp, glProgramEnvParameter4fARB);
- SET_ProgramEnvParameter4fvARB(disp, glProgramEnvParameter4fvARB);
- SET_ProgramLocalParameter4dARB(disp, glProgramLocalParameter4dARB);
- SET_ProgramLocalParameter4dvARB(disp, glProgramLocalParameter4dvARB);
- SET_ProgramLocalParameter4fARB(disp, glProgramLocalParameter4fARB);
- SET_ProgramLocalParameter4fvARB(disp, glProgramLocalParameter4fvARB);
- SET_GetProgramEnvParameterdvARB(disp, glGetProgramEnvParameterdvARB);
- SET_GetProgramEnvParameterfvARB(disp, glGetProgramEnvParameterfvARB);
- SET_GetProgramLocalParameterdvARB(disp, glGetProgramLocalParameterdvARB);
- SET_GetProgramLocalParameterfvARB(disp, glGetProgramLocalParameterfvARB);
- SET_GetProgramivARB(disp, glGetProgramivARB);
- SET_GetProgramStringARB(disp, glGetProgramStringARB);
- SET_ProgramNamedParameter4fNV(disp, glProgramNamedParameter4fNV);
- SET_ProgramNamedParameter4dNV(disp, glProgramNamedParameter4dNV);
- SET_ProgramNamedParameter4fvNV(disp, glProgramNamedParameter4fvNV);
- SET_ProgramNamedParameter4dvNV(disp, glProgramNamedParameter4dvNV);
- SET_GetProgramNamedParameterfvNV(disp, glGetProgramNamedParameterfvNV);
- SET_GetProgramNamedParameterdvNV(disp, glGetProgramNamedParameterdvNV);
- SET_BindBufferARB(disp, glBindBufferARB);
- SET_BufferDataARB(disp, glBufferDataARB);
- SET_BufferSubDataARB(disp, glBufferSubDataARB);
- SET_DeleteBuffersARB(disp, glDeleteBuffersARB);
- SET_GenBuffersARB(disp, glGenBuffersARB);
- SET_GetBufferParameterivARB(disp, glGetBufferParameterivARB);
- SET_GetBufferPointervARB(disp, glGetBufferPointervARB);
- SET_GetBufferSubDataARB(disp, glGetBufferSubDataARB);
- SET_IsBufferARB(disp, glIsBufferARB);
- SET_MapBufferARB(disp, glMapBufferARB);
- SET_UnmapBufferARB(disp, glUnmapBufferARB);
- SET_DepthBoundsEXT(disp, glDepthBoundsEXT);
- SET_GenQueriesARB(disp, glGenQueriesARB);
- SET_DeleteQueriesARB(disp, glDeleteQueriesARB);
- SET_IsQueryARB(disp, glIsQueryARB);
- SET_BeginQueryARB(disp, glBeginQueryARB);
- SET_EndQueryARB(disp, glEndQueryARB);
- SET_GetQueryivARB(disp, glGetQueryivARB);
- SET_GetQueryObjectivARB(disp, glGetQueryObjectivARB);
- SET_GetQueryObjectuivARB(disp, glGetQueryObjectuivARB);
- SET_MultiModeDrawArraysIBM(disp, glMultiModeDrawArraysIBM);
- SET_MultiModeDrawElementsIBM(disp, glMultiModeDrawElementsIBM);
- SET_BlendEquationSeparateEXT(disp, glBlendEquationSeparateEXT);
- SET_DeleteObjectARB(disp, glDeleteObjectARB);
- SET_GetHandleARB(disp, glGetHandleARB);
- SET_DetachObjectARB(disp, glDetachObjectARB);
- SET_CreateShaderObjectARB(disp, glCreateShaderObjectARB);
- SET_ShaderSourceARB(disp, glShaderSourceARB);
- SET_CompileShaderARB(disp, glCompileShaderARB);
- SET_CreateProgramObjectARB(disp, glCreateProgramObjectARB);
- SET_AttachObjectARB(disp, glAttachObjectARB);
- SET_LinkProgramARB(disp, glLinkProgramARB);
- SET_UseProgramObjectARB(disp, glUseProgramObjectARB);
- SET_ValidateProgramARB(disp, glValidateProgramARB);
- SET_Uniform1fARB(disp, glUniform1fARB);
- SET_Uniform2fARB(disp, glUniform2fARB);
- SET_Uniform3fARB(disp, glUniform3fARB);
- SET_Uniform4fARB(disp, glUniform4fARB);
- SET_Uniform1iARB(disp, glUniform1iARB);
- SET_Uniform2iARB(disp, glUniform2iARB);
- SET_Uniform3iARB(disp, glUniform3iARB);
- SET_Uniform4iARB(disp, glUniform4iARB);
- SET_Uniform1fvARB(disp, glUniform1fvARB);
- SET_Uniform2fvARB(disp, glUniform2fvARB);
- SET_Uniform3fvARB(disp, glUniform3fvARB);
- SET_Uniform4fvARB(disp, glUniform4fvARB);
- SET_Uniform1ivARB(disp, glUniform1ivARB);
- SET_Uniform2ivARB(disp, glUniform2ivARB);
- SET_Uniform3ivARB(disp, glUniform3ivARB);
- SET_Uniform4ivARB(disp, glUniform4ivARB);
- SET_UniformMatrix2fvARB(disp, glUniformMatrix2fvARB);
- SET_UniformMatrix3fvARB(disp, glUniformMatrix3fvARB);
- SET_UniformMatrix4fvARB(disp, glUniformMatrix4fvARB);
- SET_GetObjectParameterfvARB(disp, glGetObjectParameterfvARB);
- SET_GetObjectParameterivARB(disp, glGetObjectParameterivARB);
- SET_GetInfoLogARB(disp, glGetInfoLogARB);
- SET_GetAttachedObjectsARB(disp, glGetAttachedObjectsARB);
- SET_GetUniformLocationARB(disp, glGetUniformLocationARB);
- SET_GetActiveUniformARB(disp, glGetActiveUniformARB);
- SET_GetUniformfvARB(disp, glGetUniformfvARB);
- SET_GetUniformivARB(disp, glGetUniformivARB);
- SET_GetShaderSourceARB(disp, glGetShaderSourceARB);
- SET_BindAttribLocationARB(disp, glBindAttribLocationARB);
- SET_GetActiveAttribARB(disp, glGetActiveAttribARB);
- SET_GetAttribLocationARB(disp, glGetAttribLocationARB);
- SET_GetVertexAttribdvNV(disp, glGetVertexAttribdvNV);
- SET_GetVertexAttribfvNV(disp, glGetVertexAttribfvNV);
- SET_GetVertexAttribivNV(disp, glGetVertexAttribivNV);
- SET_VertexAttrib1dNV(disp, glVertexAttrib1dNV);
- SET_VertexAttrib1dvNV(disp, glVertexAttrib1dvNV);
- SET_VertexAttrib1fNV(disp, glVertexAttrib1fNV);
- SET_VertexAttrib1fvNV(disp, glVertexAttrib1fvNV);
- SET_VertexAttrib1sNV(disp, glVertexAttrib1sNV);
- SET_VertexAttrib1svNV(disp, glVertexAttrib1svNV);
- SET_VertexAttrib2dNV(disp, glVertexAttrib2dNV);
- SET_VertexAttrib2dvNV(disp, glVertexAttrib2dvNV);
- SET_VertexAttrib2fNV(disp, glVertexAttrib2fNV);
- SET_VertexAttrib2fvNV(disp, glVertexAttrib2fvNV);
- SET_VertexAttrib2sNV(disp, glVertexAttrib2sNV);
- SET_VertexAttrib2svNV(disp, glVertexAttrib2svNV);
- SET_VertexAttrib3dNV(disp, glVertexAttrib3dNV);
- SET_VertexAttrib3dvNV(disp, glVertexAttrib3dvNV);
- SET_VertexAttrib3fNV(disp, glVertexAttrib3fNV);
- SET_VertexAttrib3fvNV(disp, glVertexAttrib3fvNV);
- SET_VertexAttrib3sNV(disp, glVertexAttrib3sNV);
- SET_VertexAttrib3svNV(disp, glVertexAttrib3svNV);
- SET_VertexAttrib4dNV(disp, glVertexAttrib4dNV);
- SET_VertexAttrib4dvNV(disp, glVertexAttrib4dvNV);
- SET_VertexAttrib4fNV(disp, glVertexAttrib4fNV);
- SET_VertexAttrib4fvNV(disp, glVertexAttrib4fvNV);
- SET_VertexAttrib4sNV(disp, glVertexAttrib4sNV);
- SET_VertexAttrib4svNV(disp, glVertexAttrib4svNV);
- SET_VertexAttrib4ubNV(disp, glVertexAttrib4ubNV);
- SET_VertexAttrib4ubvNV(disp, glVertexAttrib4ubvNV);
- SET_GenFragmentShadersATI(disp, glGenFragmentShadersATI);
- SET_BindFragmentShaderATI(disp, glBindFragmentShaderATI);
- SET_DeleteFragmentShaderATI(disp, glDeleteFragmentShaderATI);
- SET_BeginFragmentShaderATI(disp, glBeginFragmentShaderATI);
- SET_EndFragmentShaderATI(disp, glEndFragmentShaderATI);
- SET_PassTexCoordATI(disp, glPassTexCoordATI);
- SET_SampleMapATI(disp, glSampleMapATI);
- SET_ColorFragmentOp1ATI(disp, glColorFragmentOp1ATI);
- SET_ColorFragmentOp2ATI(disp, glColorFragmentOp2ATI);
- SET_ColorFragmentOp3ATI(disp, glColorFragmentOp3ATI);
- SET_AlphaFragmentOp1ATI(disp, glAlphaFragmentOp1ATI);
- SET_AlphaFragmentOp2ATI(disp, glAlphaFragmentOp2ATI);
- SET_AlphaFragmentOp3ATI(disp, glAlphaFragmentOp3ATI);
- SET_SetFragmentShaderConstantATI(disp, glSetFragmentShaderConstantATI);
- SET_IsRenderbufferEXT(disp, glIsRenderbufferEXT);
- SET_BindRenderbufferEXT(disp, glBindRenderbufferEXT);
- SET_DeleteRenderbuffersEXT(disp, glDeleteRenderbuffersEXT);
- SET_GenRenderbuffersEXT(disp, glGenRenderbuffersEXT);
- SET_RenderbufferStorageEXT(disp, glRenderbufferStorageEXT);
- SET_GetRenderbufferParameterivEXT(disp, glGetRenderbufferParameterivEXT);
- SET_IsFramebufferEXT(disp, glIsFramebufferEXT);
- SET_BindFramebufferEXT(disp, glBindFramebufferEXT);
- SET_DeleteFramebuffersEXT(disp, glDeleteFramebuffersEXT);
- SET_GenFramebuffersEXT(disp, glGenFramebuffersEXT);
- SET_CheckFramebufferStatusEXT(disp, glCheckFramebufferStatusEXT);
- SET_FramebufferTexture1DEXT(disp, glFramebufferTexture1DEXT);
- SET_FramebufferTexture2DEXT(disp, glFramebufferTexture2DEXT);
- SET_FramebufferTexture3DEXT(disp, glFramebufferTexture3DEXT);
- SET_FramebufferRenderbufferEXT(disp, glFramebufferRenderbufferEXT);
- SET_GetFramebufferAttachmentParameterivEXT(disp, glGetFramebufferAttachmentParameterivEXT);
- SET_GenerateMipmapEXT(disp, glGenerateMipmapEXT);
- SET_StencilFuncSeparate(disp, glStencilFuncSeparate);
- SET_StencilOpSeparate(disp, glStencilOpSeparate);
- SET_StencilMaskSeparate(disp, glStencilMaskSeparate);
- SET_GetQueryObjecti64vEXT(disp, glGetQueryObjecti64vEXT);
- SET_GetQueryObjectui64vEXT(disp, glGetQueryObjectui64vEXT);
- SET_BlitFramebufferEXT(disp, glBlitFramebufferEXT); */
+void warn_func(void * p1, char *format, ...) {
+  va_list v;
+  va_start(v, format);
+  vfprintf(stderr, format, v);
+  va_end(v);
+}
 
+static void setup_dispatch_table(void) {
+  struct _glapi_table *disp=_glapi_get_dispatch();
+  _glapi_set_warning_func((_glapi_warning_func)warn_func);
+  _glapi_noop_enable_warnings(TRUE);
+
+  SET_Accum(disp, glAccum);
+  SET_ActiveStencilFaceEXT(disp, glActiveStencilFaceEXT);
+  SET_ActiveTextureARB(disp, glActiveTextureARB);
+//SET_AlphaFragmentOp1ATI(disp, glAlphaFragmentOp1EXT);   // <-- EXT -> ATI
+//SET_AlphaFragmentOp2ATI(disp, glAlphaFragmentOp2EXT);
+//SET_AlphaFragmentOp3ATI(disp, glAlphaFragmentOp3EXT);
+  SET_AlphaFunc(disp, glAlphaFunc);
+//SET_AreProgramsResidentNV(disp, glAreProgramsResidentNV);
+  SET_AreTexturesResident(disp, glAreTexturesResident); 
+  SET_ArrayElement(disp, glArrayElement);
+  SET_AttachObjectARB(disp, glAttachObjectARB);
+  SET_Begin(disp, glBegin);
+//SET_BeginFragmentShaderATI(disp, glBeginFragmentShaderEXT);   // <-- EXT -> ATI
+  SET_BeginQueryARB(disp, glBeginQueryARB);
+  SET_BindAttribLocationARB(disp, glBindAttribLocationARB);
+  SET_BindBufferARB(disp, glBindBufferARB);
+//SET_BindFragmentShaderATI(disp, glBindFragmentShaderEXT);     // <-- EXT -> ATI
+  SET_BindFramebufferEXT(disp, glBindFramebufferEXT);
+//SET_BindProgramNV(disp, glBindProgramNV);
+  SET_BindRenderbufferEXT(disp, glBindRenderbufferEXT);
+  SET_BindTexture(disp, glBindTexture);
+  SET_Bitmap(disp, glBitmap);
+  SET_BlendColor(disp, glBlendColor);
+  SET_BlendEquation(disp, glBlendEquation);
+  SET_BlendEquationSeparateEXT(disp, glBlendEquationSeparateEXT);
+  SET_BlendFunc(disp, glBlendFunc);
+  SET_BlendFuncSeparateEXT(disp, glBlendFuncSeparateEXT);
+  SET_BlitFramebufferEXT(disp, glBlitFramebufferEXT);
+  SET_BufferDataARB(disp, glBufferDataARB);
+  SET_BufferSubDataARB(disp, glBufferSubDataARB);
+  SET_CallList(disp, glCallList);
+  SET_CallLists(disp, glCallLists);
+  SET_CheckFramebufferStatusEXT(disp, glCheckFramebufferStatusEXT);
+  SET_Clear(disp, glClear);
+  SET_ClearAccum(disp, glClearAccum);
+  SET_ClearColor(disp, glClearColor);
+  SET_ClearDepth(disp, glClearDepth);
+  SET_ClearIndex(disp, glClearIndex);
+  SET_ClearStencil(disp, glClearStencil);
+  SET_ClientActiveTextureARB(disp, glClientActiveTextureARB);
+  SET_ClipPlane(disp, glClipPlane);
+  SET_Color3b(disp, glColor3b);
+  SET_Color3bv(disp, glColor3bv);
+  SET_Color3d(disp, glColor3d);
+  SET_Color3dv(disp, glColor3dv);
+  SET_Color3f(disp, glColor3f);
+  SET_Color3fv(disp, glColor3fv);
+  SET_Color3i(disp, glColor3i);
+  SET_Color3iv(disp, glColor3iv);
+  SET_Color3s(disp, glColor3s);
+  SET_Color3sv(disp, glColor3sv);
+  SET_Color3ub(disp, glColor3ub);
+  SET_Color3ubv(disp, glColor3ubv);
+  SET_Color3ui(disp, glColor3ui);
+  SET_Color3uiv(disp, glColor3uiv);
+  SET_Color3us(disp, glColor3us);
+  SET_Color3usv(disp, glColor3usv);
+  SET_Color4b(disp, glColor4b);
+  SET_Color4bv(disp, glColor4bv);
+  SET_Color4d(disp, glColor4d);
+  SET_Color4dv(disp, glColor4dv);
+  SET_Color4f(disp, glColor4f);
+  SET_Color4fv(disp, glColor4fv);
+  SET_Color4i(disp, glColor4i);
+  SET_Color4iv(disp, glColor4iv);
+  SET_Color4s(disp, glColor4s);
+  SET_Color4sv(disp, glColor4sv);
+  SET_Color4ub(disp, glColor4ub);
+  SET_Color4ubv(disp, glColor4ubv);
+  SET_Color4ui(disp, glColor4ui);
+  SET_Color4uiv(disp, glColor4uiv);
+  SET_Color4us(disp, glColor4us);
+  SET_Color4usv(disp, glColor4usv);
+//SET_ColorFragmentOp1ATI(disp, glColorFragmentOp1EXT);    // <-- EXT -> ATI
+//SET_ColorFragmentOp2ATI(disp, glColorFragmentOp2EXT);
+//SET_ColorFragmentOp3ATI(disp, glColorFragmentOp3EXT);
+  SET_ColorMask(disp, glColorMask);
+  SET_ColorMaterial(disp, glColorMaterial);
+  SET_ColorPointer(disp, glColorPointer);
+//SET_ColorPointerEXT(disp, glColorPointerEXT);
+  SET_ColorSubTable(disp, glColorSubTable);
+  SET_ColorTable(disp, glColorTable);
+  SET_ColorTableParameterfv(disp, glColorTableParameterfv);
+  SET_ColorTableParameteriv(disp, glColorTableParameteriv);
+  SET_CombinerInputNV(disp, glCombinerInputNV);
+  SET_CombinerOutputNV(disp, glCombinerOutputNV);
+  SET_CombinerParameterfNV(disp, glCombinerParameterfNV);
+  SET_CombinerParameterfvNV(disp, glCombinerParameterfvNV);
+  SET_CombinerParameteriNV(disp, glCombinerParameteriNV);
+  SET_CombinerParameterivNV(disp, glCombinerParameterivNV);
+  SET_CompileShaderARB(disp, glCompileShaderARB);
+  SET_CompressedTexImage1DARB(disp, glCompressedTexImage1DARB);
+  SET_CompressedTexImage2DARB(disp, glCompressedTexImage2DARB);
+  SET_CompressedTexImage3DARB(disp, glCompressedTexImage3DARB);
+  SET_CompressedTexSubImage1DARB(disp, glCompressedTexSubImage1DARB);
+  SET_CompressedTexSubImage2DARB(disp, glCompressedTexSubImage2DARB);
+  SET_CompressedTexSubImage3DARB(disp, glCompressedTexSubImage3DARB);
+  SET_ConvolutionFilter1D(disp, glConvolutionFilter1D);
+  SET_ConvolutionFilter2D(disp, glConvolutionFilter2D);
+  SET_ConvolutionParameterf(disp, glConvolutionParameterf);
+  SET_ConvolutionParameterfv(disp, glConvolutionParameterfv);
+  SET_ConvolutionParameteri(disp, glConvolutionParameteri);
+  SET_ConvolutionParameteriv(disp, glConvolutionParameteriv);
+  SET_CopyColorSubTable(disp, glCopyColorSubTable);
+  SET_CopyColorTable(disp, glCopyColorTable);
+  SET_CopyConvolutionFilter1D(disp, glCopyConvolutionFilter1D);
+  SET_CopyConvolutionFilter2D(disp, glCopyConvolutionFilter2D);
+  SET_CopyPixels(disp, glCopyPixels);
+  SET_CopyTexImage1D(disp, glCopyTexImage1D);
+  SET_CopyTexImage2D(disp, glCopyTexImage2D);
+  SET_CopyTexSubImage1D(disp, glCopyTexSubImage1D);
+  SET_CopyTexSubImage2D(disp, glCopyTexSubImage2D);
+  SET_CopyTexSubImage3D(disp, glCopyTexSubImage3D);
+  SET_CreateProgramObjectARB(disp, glCreateProgramObjectARB);
+  SET_CreateShaderObjectARB(disp, glCreateShaderObjectARB);
+  SET_CullFace(disp, glCullFace);
+//SET_CullParameterdvEXT(disp, glCullParameterdvEXT);
+//SET_CullParameterfvEXT(disp, glCullParameterfvEXT);
+  SET_DeleteBuffersARB(disp, glDeleteBuffersARB);
+  SET_DeleteFencesNV(disp, glDeleteFencesAPPLE);
+//SET_DeleteFragmentShaderATI(disp, glDeleteFragmentShaderEXT);      // <-- EXT -> ATI
+  SET_DeleteFramebuffersEXT(disp, glDeleteFramebuffersEXT);
+  SET_DeleteLists(disp, glDeleteLists);
+  SET_DeleteObjectARB(disp, glDeleteObjectARB);
+//SET_DeleteProgramsNV(disp, glDeleteProgramsNV);
+  SET_DeleteQueriesARB(disp, glDeleteQueriesARB);
+  SET_DeleteRenderbuffersEXT(disp, glDeleteRenderbuffersEXT);
+  SET_DeleteTextures(disp, glDeleteTextures);
+  SET_DepthBoundsEXT(disp, glDepthBoundsEXT);
+  SET_DepthFunc(disp, glDepthFunc);
+  SET_DepthMask(disp, glDepthMask);
+  SET_DepthRange(disp, glDepthRange);
+  SET_DetachObjectARB(disp, glDetachObjectARB);
+  SET_Disable(disp, glDisable);
+  SET_DisableClientState(disp, glDisableClientState);
+  SET_DisableVertexAttribArrayARB(disp, glDisableVertexAttribArrayARB);
+  SET_DrawArrays(disp, glDrawArrays);
+  SET_DrawBuffer(disp, glDrawBuffer);
+  SET_DrawBuffersARB(disp, glDrawBuffersARB);
+  SET_DrawElements(disp, glDrawElements);
+  SET_DrawPixels(disp, glDrawPixels);
+  SET_DrawRangeElements(disp, glDrawRangeElements);
+  SET_EdgeFlag(disp, glEdgeFlag);
+  SET_EdgeFlagPointer(disp, glEdgeFlagPointer);
+//SET_EdgeFlagPointerEXT(disp, glEdgeFlagPointerEXT);
+  SET_EdgeFlagv(disp, glEdgeFlagv);
+  SET_Enable(disp, glEnable);
+  SET_EnableClientState(disp, glEnableClientState);
+  SET_EnableVertexAttribArrayARB(disp, glEnableVertexAttribArrayARB);
+  SET_End(disp, glEnd);
+//SET_EndFragmentShaderATI(disp, glEndFragmentShaderEXT);        // <-- EXT -> ATI
+  SET_EndList(disp, glEndList);
+  SET_EndQueryARB(disp, glEndQueryARB);
+  SET_EvalCoord1d(disp, glEvalCoord1d);
+  SET_EvalCoord1dv(disp, glEvalCoord1dv);
+  SET_EvalCoord1f(disp, glEvalCoord1f);
+  SET_EvalCoord1fv(disp, glEvalCoord1fv);
+  SET_EvalCoord2d(disp, glEvalCoord2d);
+  SET_EvalCoord2dv(disp, glEvalCoord2dv);
+  SET_EvalCoord2f(disp, glEvalCoord2f);
+  SET_EvalCoord2fv(disp, glEvalCoord2fv);
+  SET_EvalMesh1(disp, glEvalMesh1);
+  SET_EvalMesh2(disp, glEvalMesh2);
+  SET_EvalPoint1(disp, glEvalPoint1);
+  SET_EvalPoint2(disp, glEvalPoint2);
+//SET_ExecuteProgramNV(disp, glExecuteProgramNV);
+  SET_FeedbackBuffer(disp, glFeedbackBuffer);
+  SET_FinalCombinerInputNV(disp, glFinalCombinerInputNV);
+  SET_Finish(disp, glFinish);
+  SET_FinishFenceNV(disp, glFinishFenceAPPLE);       // <-- APPLE -> NV
+  SET_Flush(disp, glFlush);
+//SET_FlushVertexArrayRangeNV(disp, glFlushVertexArrayRangeNV);
+  SET_FogCoordPointerEXT(disp, glFogCoordPointerEXT);
+  SET_FogCoorddEXT(disp, glFogCoorddEXT);
+  SET_FogCoorddvEXT(disp, glFogCoorddvEXT);
+  SET_FogCoordfEXT(disp, glFogCoordfEXT);
+  SET_FogCoordfvEXT(disp, glFogCoordfvEXT);
+  SET_Fogf(disp, glFogf);
+  SET_Fogfv(disp, glFogfv);
+  SET_Fogi(disp, glFogi);
+  SET_Fogiv(disp, glFogiv);
+  SET_FramebufferRenderbufferEXT(disp, glFramebufferRenderbufferEXT);
+  SET_FramebufferTexture1DEXT(disp, glFramebufferTexture1DEXT);
+  SET_FramebufferTexture2DEXT(disp, glFramebufferTexture2DEXT);
+  SET_FramebufferTexture3DEXT(disp, glFramebufferTexture3DEXT);
+  SET_FrontFace(disp, glFrontFace);
+  SET_Frustum(disp, glFrustum);
+  SET_GenBuffersARB(disp, glGenBuffersARB);
+  SET_GenFencesNV(disp, glGenFencesAPPLE);            // <-- APPLE -> NV
+//SET_GenFragmentShadersATI(disp, glGenFragmentShadersEXT);         // <-- EXT -> ATI
+  SET_GenFramebuffersEXT(disp, glGenFramebuffersEXT);
+  SET_GenLists(disp, glGenLists);
+//SET_GenProgramsNV(disp, glGenProgramsNV);
+  SET_GenQueriesARB(disp, glGenQueriesARB);
+  SET_GenRenderbuffersEXT(disp, glGenRenderbuffersEXT);
+  SET_GenTextures(disp, glGenTextures);
+  SET_GenerateMipmapEXT(disp, glGenerateMipmapEXT);
+  SET_GetActiveAttribARB(disp, glGetActiveAttribARB);
+  SET_GetActiveUniformARB(disp, glGetActiveUniformARB);
+  SET_GetAttachedObjectsARB(disp, glGetAttachedObjectsARB);
+  SET_GetAttribLocationARB(disp, glGetAttribLocationARB);
+  SET_GetBooleanv(disp, glGetBooleanv);
+  SET_GetBufferParameterivARB(disp, glGetBufferParameterivARB);
+  SET_GetBufferPointervARB(disp, glGetBufferPointervARB);
+  SET_GetBufferSubDataARB(disp, glGetBufferSubDataARB);
+  SET_GetClipPlane(disp, glGetClipPlane);
+  SET_GetColorTable(disp, glGetColorTable);
+  SET_GetColorTableParameterfv(disp, glGetColorTableParameterfv);
+  SET_GetColorTableParameteriv(disp, glGetColorTableParameteriv);
+  SET_GetCombinerInputParameterfvNV(disp, glGetCombinerInputParameterfvNV);
+  SET_GetCombinerInputParameterivNV(disp, glGetCombinerInputParameterivNV);
+  SET_GetCombinerOutputParameterfvNV(disp, glGetCombinerOutputParameterfvNV);
+  SET_GetCombinerOutputParameterivNV(disp, glGetCombinerOutputParameterivNV);
+  SET_GetCompressedTexImageARB(disp, glGetCompressedTexImageARB);
+  SET_GetConvolutionFilter(disp, glGetConvolutionFilter);
+  SET_GetConvolutionParameterfv(disp, glGetConvolutionParameterfv);
+  SET_GetConvolutionParameteriv(disp, glGetConvolutionParameteriv);
+  SET_GetDoublev(disp, glGetDoublev);
+  SET_GetError(disp, glGetError);
+//SET_GetFenceivNV(disp, glGetFenceivNV);
+  SET_GetFinalCombinerInputParameterfvNV(disp, glGetFinalCombinerInputParameterfvNV);
+  SET_GetFinalCombinerInputParameterivNV(disp, glGetFinalCombinerInputParameterivNV);
+  SET_GetFloatv(disp, glGetFloatv);
+  SET_GetFramebufferAttachmentParameterivEXT(disp, glGetFramebufferAttachmentParameterivEXT);
+  SET_GetHandleARB(disp, glGetHandleARB);
+  SET_GetHistogram(disp, glGetHistogram);
+  SET_GetHistogramParameterfv(disp, glGetHistogramParameterfv);
+  SET_GetHistogramParameteriv(disp, glGetHistogramParameteriv);
+  SET_GetInfoLogARB(disp, glGetInfoLogARB);
+  SET_GetIntegerv(disp, glGetIntegerv);
+  SET_GetLightfv(disp, glGetLightfv);
+  SET_GetLightiv(disp, glGetLightiv);
+  SET_GetMapdv(disp, glGetMapdv);
+  SET_GetMapfv(disp, glGetMapfv);
+  SET_GetMapiv(disp, glGetMapiv);
+  SET_GetMaterialfv(disp, glGetMaterialfv);
+  SET_GetMaterialiv(disp, glGetMaterialiv);
+  SET_GetMinmax(disp, glGetMinmax);
+  SET_GetMinmaxParameterfv(disp, glGetMinmaxParameterfv);
+  SET_GetMinmaxParameteriv(disp, glGetMinmaxParameteriv);
+  SET_GetObjectParameterfvARB(disp, glGetObjectParameterfvARB);
+  SET_GetObjectParameterivARB(disp, glGetObjectParameterivARB);
+  SET_GetPixelMapfv(disp, glGetPixelMapfv);
+  SET_GetPixelMapuiv(disp, glGetPixelMapuiv);
+  SET_GetPixelMapusv(disp, glGetPixelMapusv);
+//SET_GetPixelTexGenParameterfvSGIS(disp, glGetPixelTexGenParameterfvSGIS);
+//SET_GetPixelTexGenParameterivSGIS(disp, glGetPixelTexGenParameterivSGIS);
+  SET_GetPointerv(disp, glGetPointerv);
+  SET_GetPolygonStipple(disp, glGetPolygonStipple);
+  SET_GetProgramEnvParameterdvARB(disp, glGetProgramEnvParameterdvARB);
+  SET_GetProgramEnvParameterfvARB(disp, glGetProgramEnvParameterfvARB);
+  SET_GetProgramLocalParameterdvARB(disp, glGetProgramLocalParameterdvARB);
+  SET_GetProgramLocalParameterfvARB(disp, glGetProgramLocalParameterfvARB);
+//SET_GetProgramNamedParameterdvNV(disp, glGetProgramNamedParameterdvNV);
+//SET_GetProgramNamedParameterfvNV(disp, glGetProgramNamedParameterfvNV);
+//SET_GetProgramParameterdvNV(disp, glGetProgramParameterdvNV);
+//SET_GetProgramParameterfvNV(disp, glGetProgramParameterfvNV);
+  SET_GetProgramStringARB(disp, glGetProgramStringARB);
+//SET_GetProgramStringNV(disp, glGetProgramStringNV);
+  SET_GetProgramivARB(disp, glGetProgramivARB);
+//SET_GetProgramivNV(disp, glGetProgramivNV);
+//SET_GetQueryObjecti64vEXT(disp, glGetQueryObjecti64vEXT);
+  SET_GetQueryObjectivARB(disp, glGetQueryObjectivARB);
+//SET_GetQueryObjectui64vEXT(disp, glGetQueryObjectui64vEXT);
+  SET_GetQueryObjectuivARB(disp, glGetQueryObjectuivARB);
+  SET_GetQueryivARB(disp, glGetQueryivARB);
+  SET_GetRenderbufferParameterivEXT(disp, glGetRenderbufferParameterivEXT);
+  SET_GetSeparableFilter(disp, glGetSeparableFilter);
+  SET_GetShaderSourceARB(disp, glGetShaderSourceARB);
+  SET_GetString(disp, glGetString);
+  SET_GetTexEnvfv(disp, glGetTexEnvfv);
+  SET_GetTexEnviv(disp, glGetTexEnviv);
+  SET_GetTexGendv(disp, glGetTexGendv);
+  SET_GetTexGenfv(disp, glGetTexGenfv);
+  SET_GetTexGeniv(disp, glGetTexGeniv);
+  SET_GetTexImage(disp, glGetTexImage);
+  SET_GetTexLevelParameterfv(disp, glGetTexLevelParameterfv);
+  SET_GetTexLevelParameteriv(disp, glGetTexLevelParameteriv);
+  SET_GetTexParameterfv(disp, glGetTexParameterfv);
+  SET_GetTexParameteriv(disp, glGetTexParameteriv);
+//SET_GetTrackMatrixivNV(disp, glGetTrackMatrixivNV);
+  SET_GetUniformLocationARB(disp, glGetUniformLocationARB);
+  SET_GetUniformfvARB(disp, glGetUniformfvARB);
+  SET_GetUniformivARB(disp, glGetUniformivARB);
+//SET_GetVertexAttribPointervNV(disp, glGetVertexAttribPointervNV);
+  SET_GetVertexAttribdvARB(disp, glGetVertexAttribdvARB);
+//SET_GetVertexAttribdvNV(disp, glGetVertexAttribdvNV);
+  SET_GetVertexAttribfvARB(disp, glGetVertexAttribfvARB);
+//SET_GetVertexAttribfvNV(disp, glGetVertexAttribfvNV);
+  SET_GetVertexAttribivARB(disp, glGetVertexAttribivARB);
+//SET_GetVertexAttribivNV(disp, glGetVertexAttribivNV);
+  SET_Hint(disp, glHint);
+  SET_Histogram(disp, glHistogram);
+  SET_IndexMask(disp, glIndexMask);
+  SET_IndexPointer(disp, glIndexPointer);
+//SET_IndexPointerEXT(disp, glIndexPointerEXT);
+  SET_Indexd(disp, glIndexd);
+  SET_Indexdv(disp, glIndexdv);
+  SET_Indexf(disp, glIndexf);
+  SET_Indexfv(disp, glIndexfv);
+  SET_Indexi(disp, glIndexi);
+  SET_Indexiv(disp, glIndexiv);
+  SET_Indexs(disp, glIndexs);
+  SET_Indexsv(disp, glIndexsv);
+  SET_Indexub(disp, glIndexub);
+  SET_Indexubv(disp, glIndexubv);
+  SET_InitNames(disp, glInitNames);
+  SET_InterleavedArrays(disp, glInterleavedArrays);
+  SET_IsBufferARB(disp, glIsBufferARB);
+  SET_IsEnabled(disp, glIsEnabled);
+  SET_IsFenceNV(disp, glIsFenceAPPLE);           // <-- APPLE -> NV
+  SET_IsFramebufferEXT(disp, glIsFramebufferEXT);
+  SET_IsList(disp, glIsList);
+//SET_IsProgramNV(disp, glIsProgramNV);
+  SET_IsQueryARB(disp, glIsQueryARB);
+  SET_IsRenderbufferEXT(disp, glIsRenderbufferEXT);
+  SET_IsTexture(disp, glIsTexture);
+  SET_LightModelf(disp, glLightModelf);
+  SET_LightModelfv(disp, glLightModelfv);
+  SET_LightModeli(disp, glLightModeli);
+  SET_LightModeliv(disp, glLightModeliv);
+  SET_Lightf(disp, glLightf);
+  SET_Lightfv(disp, glLightfv);
+  SET_Lighti(disp, glLighti);
+  SET_Lightiv(disp, glLightiv);
+  SET_LineStipple(disp, glLineStipple);
+  SET_LineWidth(disp, glLineWidth);
+  SET_LinkProgramARB(disp, glLinkProgramARB);
+  SET_ListBase(disp, glListBase);
+  SET_LoadIdentity(disp, glLoadIdentity);
+  SET_LoadMatrixd(disp, glLoadMatrixd);
+  SET_LoadMatrixf(disp, glLoadMatrixf);
+  SET_LoadName(disp, glLoadName);
+//SET_LoadProgramNV(disp, glLoadProgramNV);
+  SET_LoadTransposeMatrixdARB(disp, glLoadTransposeMatrixdARB);
+  SET_LoadTransposeMatrixfARB(disp, glLoadTransposeMatrixfARB);
+  SET_LockArraysEXT(disp, glLockArraysEXT);
+  SET_LogicOp(disp, glLogicOp);
+  SET_Map1d(disp, glMap1d);
+  SET_Map1f(disp, glMap1f);
+  SET_Map2d(disp, glMap2d);
+  SET_Map2f(disp, glMap2f);
+  SET_MapBufferARB(disp, glMapBufferARB);
+  SET_MapGrid1d(disp, glMapGrid1d);
+  SET_MapGrid1f(disp, glMapGrid1f);
+  SET_MapGrid2d(disp, glMapGrid2d);
+  SET_MapGrid2f(disp, glMapGrid2f);
+  SET_Materialf(disp, glMaterialf);
+  SET_Materialfv(disp, glMaterialfv);
+  SET_Materiali(disp, glMateriali);
+  SET_Materialiv(disp, glMaterialiv);
+  SET_MatrixMode(disp, glMatrixMode);
+  SET_Minmax(disp, glMinmax);
+  SET_MultMatrixd(disp, glMultMatrixd);
+  SET_MultMatrixf(disp, glMultMatrixf);
+  SET_MultTransposeMatrixdARB(disp, glMultTransposeMatrixdARB);
+  SET_MultTransposeMatrixfARB(disp, glMultTransposeMatrixfARB);
+  SET_MultiDrawArraysEXT(disp, glMultiDrawArraysEXT);
+  SET_MultiDrawElementsEXT(disp, glMultiDrawElementsEXT);
+//SET_MultiModeDrawArraysIBM(disp, glMultiModeDrawArraysIBM);
+//SET_MultiModeDrawElementsIBM(disp, glMultiModeDrawElementsIBM);
+  SET_MultiTexCoord1dARB(disp, glMultiTexCoord1dARB);
+  SET_MultiTexCoord1dvARB(disp, glMultiTexCoord1dvARB);
+  SET_MultiTexCoord1fARB(disp, glMultiTexCoord1fARB);
+  SET_MultiTexCoord1fvARB(disp, glMultiTexCoord1fvARB);
+  SET_MultiTexCoord1iARB(disp, glMultiTexCoord1iARB);
+  SET_MultiTexCoord1ivARB(disp, glMultiTexCoord1ivARB);
+  SET_MultiTexCoord1sARB(disp, glMultiTexCoord1sARB);
+  SET_MultiTexCoord1svARB(disp, glMultiTexCoord1svARB);
+  SET_MultiTexCoord2dARB(disp, glMultiTexCoord2dARB);
+  SET_MultiTexCoord2dvARB(disp, glMultiTexCoord2dvARB);
+  SET_MultiTexCoord2fARB(disp, glMultiTexCoord2fARB);
+  SET_MultiTexCoord2fvARB(disp, glMultiTexCoord2fvARB);
+  SET_MultiTexCoord2iARB(disp, glMultiTexCoord2iARB);
+  SET_MultiTexCoord2ivARB(disp, glMultiTexCoord2ivARB);
+  SET_MultiTexCoord2sARB(disp, glMultiTexCoord2sARB);
+  SET_MultiTexCoord2svARB(disp, glMultiTexCoord2svARB);
+  SET_MultiTexCoord3dARB(disp, glMultiTexCoord3dARB);
+  SET_MultiTexCoord3dvARB(disp, glMultiTexCoord3dvARB);
+  SET_MultiTexCoord3fARB(disp, glMultiTexCoord3fARB);
+  SET_MultiTexCoord3fvARB(disp, glMultiTexCoord3fvARB);
+  SET_MultiTexCoord3iARB(disp, glMultiTexCoord3iARB);
+  SET_MultiTexCoord3ivARB(disp, glMultiTexCoord3ivARB);
+  SET_MultiTexCoord3sARB(disp, glMultiTexCoord3sARB);
+  SET_MultiTexCoord3svARB(disp, glMultiTexCoord3svARB);
+  SET_MultiTexCoord4dARB(disp, glMultiTexCoord4dARB);
+  SET_MultiTexCoord4dvARB(disp, glMultiTexCoord4dvARB);
+  SET_MultiTexCoord4fARB(disp, glMultiTexCoord4fARB);
+  SET_MultiTexCoord4fvARB(disp, glMultiTexCoord4fvARB);
+  SET_MultiTexCoord4iARB(disp, glMultiTexCoord4iARB);
+  SET_MultiTexCoord4ivARB(disp, glMultiTexCoord4ivARB);
+  SET_MultiTexCoord4sARB(disp, glMultiTexCoord4sARB);
+  SET_MultiTexCoord4svARB(disp, glMultiTexCoord4svARB);
+  SET_NewList(disp, glNewList);
+  SET_Normal3b(disp, glNormal3b);
+  SET_Normal3bv(disp, glNormal3bv);
+  SET_Normal3d(disp, glNormal3d);
+  SET_Normal3dv(disp, glNormal3dv);
+  SET_Normal3f(disp, glNormal3f);
+  SET_Normal3fv(disp, glNormal3fv);
+  SET_Normal3i(disp, glNormal3i);
+  SET_Normal3iv(disp, glNormal3iv);
+  SET_Normal3s(disp, glNormal3s);
+  SET_Normal3sv(disp, glNormal3sv);
+  SET_NormalPointer(disp, glNormalPointer);
+//SET_NormalPointerEXT(disp, glNormalPointerEXT);
+  SET_Ortho(disp, glOrtho);
+//SET_PassTexCoordATI(disp, glPassTexCoordEXT);         // <-- EXT -> ATI
+  SET_PassThrough(disp, glPassThrough);
+  SET_PixelMapfv(disp, glPixelMapfv);
+  SET_PixelMapuiv(disp, glPixelMapuiv);
+  SET_PixelMapusv(disp, glPixelMapusv);
+  SET_PixelStoref(disp, glPixelStoref);
+  SET_PixelStorei(disp, glPixelStorei);
+//SET_PixelTexGenParameterfSGIS(disp, glPixelTexGenParameterfSGIS);
+//SET_PixelTexGenParameterfvSGIS(disp, glPixelTexGenParameterfvSGIS);
+//SET_PixelTexGenParameteriSGIS(disp, glPixelTexGenParameteriSGIS);
+//SET_PixelTexGenParameterivSGIS(disp, glPixelTexGenParameterivSGIS);
+//  SET_PixelTexGenSGIX(disp, glPixelTexGenSGIX);
+  SET_PixelTransferf(disp, glPixelTransferf);
+  SET_PixelTransferi(disp, glPixelTransferi);
+  SET_PixelZoom(disp, glPixelZoom);
+  SET_PointParameterfEXT(disp, glPointParameterfARB);      // <-- ARB -> EXT
+  SET_PointParameterfvEXT(disp, glPointParameterfvARB);    // <-- ARB -> EXT
+  SET_PointParameteriNV(disp, glPointParameteriNV);
+  SET_PointParameterivNV(disp, glPointParameterivNV);
+  SET_PointSize(disp, glPointSize);
+  SET_PolygonMode(disp, glPolygonMode);
+  SET_PolygonOffset(disp, glPolygonOffset);
+//SET_PolygonOffsetEXT(disp, glPolygonOffsetEXT);
+  SET_PolygonStipple(disp, glPolygonStipple);
+  SET_PopAttrib(disp, glPopAttrib);
+  SET_PopClientAttrib(disp, glPopClientAttrib);
+  SET_PopMatrix(disp, glPopMatrix);
+  SET_PopName(disp, glPopName);
+  SET_PrioritizeTextures(disp, glPrioritizeTextures);
+  SET_ProgramEnvParameter4dARB(disp, glProgramEnvParameter4dARB);
+  SET_ProgramEnvParameter4dvARB(disp, glProgramEnvParameter4dvARB);
+  SET_ProgramEnvParameter4fARB(disp, glProgramEnvParameter4fARB);
+  SET_ProgramEnvParameter4fvARB(disp, glProgramEnvParameter4fvARB);
+  SET_ProgramLocalParameter4dARB(disp, glProgramLocalParameter4dARB);
+  SET_ProgramLocalParameter4dvARB(disp, glProgramLocalParameter4dvARB);
+  SET_ProgramLocalParameter4fARB(disp, glProgramLocalParameter4fARB);
+  SET_ProgramLocalParameter4fvARB(disp, glProgramLocalParameter4fvARB);
+//SET_ProgramNamedParameter4dNV(disp, glProgramNamedParameter4dNV);
+//SET_ProgramNamedParameter4dvNV(disp, glProgramNamedParameter4dvNV);
+//SET_ProgramNamedParameter4fNV(disp, glProgramNamedParameter4fNV);
+//SET_ProgramNamedParameter4fvNV(disp, glProgramNamedParameter4fvNV);
+//SET_ProgramParameter4dNV(disp, glProgramParameter4dNV);
+//SET_ProgramParameter4dvNV(disp, glProgramParameter4dvNV);
+//SET_ProgramParameter4fNV(disp, glProgramParameter4fNV);
+//SET_ProgramParameter4fvNV(disp, glProgramParameter4fvNV);
+//SET_ProgramParameters4dvNV(disp, glProgramParameters4dvNV);
+//SET_ProgramParameters4fvNV(disp, glProgramParameters4fvNV);
+  SET_ProgramStringARB(disp, glProgramStringARB);
+  SET_PushAttrib(disp, glPushAttrib);
+  SET_PushClientAttrib(disp, glPushClientAttrib);
+  SET_PushMatrix(disp, glPushMatrix);
+  SET_PushName(disp, glPushName);
+  SET_RasterPos2d(disp, glRasterPos2d);
+  SET_RasterPos2dv(disp, glRasterPos2dv);
+  SET_RasterPos2f(disp, glRasterPos2f);
+  SET_RasterPos2fv(disp, glRasterPos2fv);
+  SET_RasterPos2i(disp, glRasterPos2i);
+  SET_RasterPos2iv(disp, glRasterPos2iv);
+  SET_RasterPos2s(disp, glRasterPos2s);
+  SET_RasterPos2sv(disp, glRasterPos2sv);
+  SET_RasterPos3d(disp, glRasterPos3d);
+  SET_RasterPos3dv(disp, glRasterPos3dv);
+  SET_RasterPos3f(disp, glRasterPos3f);
+  SET_RasterPos3fv(disp, glRasterPos3fv);
+  SET_RasterPos3i(disp, glRasterPos3i);
+  SET_RasterPos3iv(disp, glRasterPos3iv);
+  SET_RasterPos3s(disp, glRasterPos3s);
+  SET_RasterPos3sv(disp, glRasterPos3sv);
+  SET_RasterPos4d(disp, glRasterPos4d);
+  SET_RasterPos4dv(disp, glRasterPos4dv);
+  SET_RasterPos4f(disp, glRasterPos4f);
+  SET_RasterPos4fv(disp, glRasterPos4fv);
+  SET_RasterPos4i(disp, glRasterPos4i);
+  SET_RasterPos4iv(disp, glRasterPos4iv);
+  SET_RasterPos4s(disp, glRasterPos4s);
+  SET_RasterPos4sv(disp, glRasterPos4sv);
+  SET_ReadBuffer(disp, glReadBuffer);
+  SET_ReadPixels(disp, glReadPixels);
+  SET_Rectd(disp, glRectd);
+  SET_Rectdv(disp, glRectdv);
+  SET_Rectf(disp, glRectf);
+  SET_Rectfv(disp, glRectfv);
+  SET_Recti(disp, glRecti);
+  SET_Rectiv(disp, glRectiv);
+  SET_Rects(disp, glRects);
+  SET_Rectsv(disp, glRectsv);
+  SET_RenderMode(disp, glRenderMode);
+  SET_RenderbufferStorageEXT(disp, glRenderbufferStorageEXT);
+//SET_RequestResidentProgramsNV(disp, glRequestResidentProgramsNV);
+  SET_ResetHistogram(disp, glResetHistogram);
+  SET_ResetMinmax(disp, glResetMinmax);
+//SET_ResizeBuffersMESA(disp, glResizeBuffersMESA);
+  SET_Rotated(disp, glRotated);
+  SET_Rotatef(disp, glRotatef);
+  SET_SampleCoverageARB(disp, glSampleCoverageARB);
+//SET_SampleMapATI(disp, glSampleMapEXT);       // <-- EXT -> ATI
+//SET_SampleMaskSGIS(disp, glSampleMaskSGIS);
+//SET_SamplePatternSGIS(disp, glSamplePatternSGIS);
+  SET_Scaled(disp, glScaled);
+  SET_Scalef(disp, glScalef);
+  SET_Scissor(disp, glScissor);
+  SET_SecondaryColor3bEXT(disp, glSecondaryColor3bEXT);
+  SET_SecondaryColor3bvEXT(disp, glSecondaryColor3bvEXT);
+  SET_SecondaryColor3dEXT(disp, glSecondaryColor3dEXT);
+  SET_SecondaryColor3dvEXT(disp, glSecondaryColor3dvEXT);
+  SET_SecondaryColor3fEXT(disp, glSecondaryColor3fEXT);
+  SET_SecondaryColor3fvEXT(disp, glSecondaryColor3fvEXT);
+  SET_SecondaryColor3iEXT(disp, glSecondaryColor3iEXT);
+  SET_SecondaryColor3ivEXT(disp, glSecondaryColor3ivEXT);
+  SET_SecondaryColor3sEXT(disp, glSecondaryColor3sEXT);
+  SET_SecondaryColor3svEXT(disp, glSecondaryColor3svEXT);
+  SET_SecondaryColor3ubEXT(disp, glSecondaryColor3ubEXT);
+  SET_SecondaryColor3ubvEXT(disp, glSecondaryColor3ubvEXT);
+  SET_SecondaryColor3uiEXT(disp, glSecondaryColor3uiEXT);
+  SET_SecondaryColor3uivEXT(disp, glSecondaryColor3uivEXT);
+  SET_SecondaryColor3usEXT(disp, glSecondaryColor3usEXT);
+  SET_SecondaryColor3usvEXT(disp, glSecondaryColor3usvEXT);
+  SET_SecondaryColorPointerEXT(disp, glSecondaryColorPointerEXT);
+  SET_SelectBuffer(disp, glSelectBuffer);
+  SET_SeparableFilter2D(disp, glSeparableFilter2D);
+  SET_SetFenceNV(disp, glSetFenceAPPLE);  // <-- APPLE -> NV
+//SET_SetFragmentShaderConstantATI(disp, glSetFragmentShaderConstantEXT);   // <-- EXT -> ATI
+  SET_ShadeModel(disp, glShadeModel);
+  SET_ShaderSourceARB(disp, glShaderSourceARB);
+  SET_StencilFunc(disp, glStencilFunc);
+  SET_StencilFuncSeparate(disp, glStencilFuncSeparate);
+  SET_StencilMask(disp, glStencilMask);
+  SET_StencilMaskSeparate(disp, glStencilMaskSeparate);
+  SET_StencilOp(disp, glStencilOp);
+  SET_StencilOpSeparate(disp, glStencilOpSeparate);
+  SET_TestFenceNV(disp, glTestFenceAPPLE); // <-- APPLE -> NV
+  SET_TexCoord1d(disp, glTexCoord1d);
+  SET_TexCoord1dv(disp, glTexCoord1dv);
+  SET_TexCoord1f(disp, glTexCoord1f);
+  SET_TexCoord1fv(disp, glTexCoord1fv);
+  SET_TexCoord1i(disp, glTexCoord1i);
+  SET_TexCoord1iv(disp, glTexCoord1iv);
+  SET_TexCoord1s(disp, glTexCoord1s);
+  SET_TexCoord1sv(disp, glTexCoord1sv);
+  SET_TexCoord2d(disp, glTexCoord2d);
+  SET_TexCoord2dv(disp, glTexCoord2dv);
+  SET_TexCoord2f(disp, glTexCoord2f);
+  SET_TexCoord2fv(disp, glTexCoord2fv);
+  SET_TexCoord2i(disp, glTexCoord2i);
+  SET_TexCoord2iv(disp, glTexCoord2iv);
+  SET_TexCoord2s(disp, glTexCoord2s);
+  SET_TexCoord2sv(disp, glTexCoord2sv);
+  SET_TexCoord3d(disp, glTexCoord3d);
+  SET_TexCoord3dv(disp, glTexCoord3dv);
+  SET_TexCoord3f(disp, glTexCoord3f);
+  SET_TexCoord3fv(disp, glTexCoord3fv);
+  SET_TexCoord3i(disp, glTexCoord3i);
+  SET_TexCoord3iv(disp, glTexCoord3iv);
+  SET_TexCoord3s(disp, glTexCoord3s);
+  SET_TexCoord3sv(disp, glTexCoord3sv);
+  SET_TexCoord4d(disp, glTexCoord4d);
+  SET_TexCoord4dv(disp, glTexCoord4dv);
+  SET_TexCoord4f(disp, glTexCoord4f);
+  SET_TexCoord4fv(disp, glTexCoord4fv);
+  SET_TexCoord4i(disp, glTexCoord4i);
+  SET_TexCoord4iv(disp, glTexCoord4iv);
+  SET_TexCoord4s(disp, glTexCoord4s);
+  SET_TexCoord4sv(disp, glTexCoord4sv);
+  SET_TexCoordPointer(disp, glTexCoordPointer);
+//SET_TexCoordPointerEXT(disp, glTexCoordPointerEXT);
+  SET_TexEnvf(disp, glTexEnvf);
+  SET_TexEnvfv(disp, glTexEnvfv);
+  SET_TexEnvi(disp, glTexEnvi);
+  SET_TexEnviv(disp, glTexEnviv);
+  SET_TexGend(disp, glTexGend);
+  SET_TexGendv(disp, glTexGendv);
+  SET_TexGenf(disp, glTexGenf);
+  SET_TexGenfv(disp, glTexGenfv);
+  SET_TexGeni(disp, glTexGeni);
+  SET_TexGeniv(disp, glTexGeniv);
+  SET_TexImage1D(disp, glTexImage1D);
+  SET_TexImage2D(disp, glTexImage2D);
+  SET_TexImage3D(disp, glTexImage3D);
+  SET_TexParameterf(disp, glTexParameterf);
+  SET_TexParameterfv(disp, glTexParameterfv);
+  SET_TexParameteri(disp, glTexParameteri);
+  SET_TexParameteriv(disp, glTexParameteriv);
+  SET_TexSubImage1D(disp, glTexSubImage1D);
+  SET_TexSubImage2D(disp, glTexSubImage2D);
+  SET_TexSubImage3D(disp, glTexSubImage3D);
+//SET_TrackMatrixNV(disp, glTrackMatrixNV);
+  SET_Translated(disp, glTranslated);
+  SET_Translatef(disp, glTranslatef);
+  SET_Uniform1fARB(disp, glUniform1fARB);
+  SET_Uniform1fvARB(disp, glUniform1fvARB);
+  SET_Uniform1iARB(disp, glUniform1iARB);
+  SET_Uniform1ivARB(disp, glUniform1ivARB);
+  SET_Uniform2fARB(disp, glUniform2fARB);
+  SET_Uniform2fvARB(disp, glUniform2fvARB);
+  SET_Uniform2iARB(disp, glUniform2iARB);
+  SET_Uniform2ivARB(disp, glUniform2ivARB);
+  SET_Uniform3fARB(disp, glUniform3fARB);
+  SET_Uniform3fvARB(disp, glUniform3fvARB);
+  SET_Uniform3iARB(disp, glUniform3iARB);
+  SET_Uniform3ivARB(disp, glUniform3ivARB);
+  SET_Uniform4fARB(disp, glUniform4fARB);
+  SET_Uniform4fvARB(disp, glUniform4fvARB);
+  SET_Uniform4iARB(disp, glUniform4iARB);
+  SET_Uniform4ivARB(disp, glUniform4ivARB);
+  SET_UniformMatrix2fvARB(disp, glUniformMatrix2fvARB);
+  SET_UniformMatrix3fvARB(disp, glUniformMatrix3fvARB);
+  SET_UniformMatrix4fvARB(disp, glUniformMatrix4fvARB);
+  SET_UnlockArraysEXT(disp, glUnlockArraysEXT);
+  SET_UnmapBufferARB(disp, glUnmapBufferARB);
+  SET_UseProgramObjectARB(disp, glUseProgramObjectARB);
+  SET_ValidateProgramARB(disp, glValidateProgramARB);
+  SET_Vertex2d(disp, glVertex2d);
+  SET_Vertex2dv(disp, glVertex2dv);
+  SET_Vertex2f(disp, glVertex2f);
+  SET_Vertex2fv(disp, glVertex2fv);
+  SET_Vertex2i(disp, glVertex2i);
+  SET_Vertex2iv(disp, glVertex2iv);
+  SET_Vertex2s(disp, glVertex2s);
+  SET_Vertex2sv(disp, glVertex2sv);
+  SET_Vertex3d(disp, glVertex3d);
+  SET_Vertex3dv(disp, glVertex3dv);
+  SET_Vertex3f(disp, glVertex3f);
+  SET_Vertex3fv(disp, glVertex3fv);
+  SET_Vertex3i(disp, glVertex3i);
+  SET_Vertex3iv(disp, glVertex3iv);
+  SET_Vertex3s(disp, glVertex3s);
+  SET_Vertex3sv(disp, glVertex3sv);
+  SET_Vertex4d(disp, glVertex4d);
+  SET_Vertex4dv(disp, glVertex4dv);
+  SET_Vertex4f(disp, glVertex4f);
+  SET_Vertex4fv(disp, glVertex4fv);
+  SET_Vertex4i(disp, glVertex4i);
+  SET_Vertex4iv(disp, glVertex4iv);
+  SET_Vertex4s(disp, glVertex4s);
+  SET_Vertex4sv(disp, glVertex4sv);
+//SET_VertexArrayRangeNV(disp, glVertexArrayRangeNV);
+  SET_VertexAttrib1dARB(disp, glVertexAttrib1dARB);
+  SET_VertexAttrib1dvARB(disp, glVertexAttrib1dvARB);
+  SET_VertexAttrib1fARB(disp, glVertexAttrib1fARB);
+  SET_VertexAttrib1fvARB(disp, glVertexAttrib1fvARB);
+  SET_VertexAttrib1sARB(disp, glVertexAttrib1sARB);
+  SET_VertexAttrib1svARB(disp, glVertexAttrib1svARB);
+  SET_VertexAttrib2dARB(disp, glVertexAttrib2dARB);
+  SET_VertexAttrib2dvARB(disp, glVertexAttrib2dvARB);
+  SET_VertexAttrib2fARB(disp, glVertexAttrib2fARB);
+  SET_VertexAttrib2fvARB(disp, glVertexAttrib2fvARB);
+  SET_VertexAttrib2sARB(disp, glVertexAttrib2sARB);
+  SET_VertexAttrib2svARB(disp, glVertexAttrib2svARB);
+  SET_VertexAttrib3dARB(disp, glVertexAttrib3dARB);
+  SET_VertexAttrib3dvARB(disp, glVertexAttrib3dvARB);
+  SET_VertexAttrib3fARB(disp, glVertexAttrib3fARB);
+  SET_VertexAttrib3fvARB(disp, glVertexAttrib3fvARB);
+  SET_VertexAttrib3sARB(disp, glVertexAttrib3sARB);
+  SET_VertexAttrib3svARB(disp, glVertexAttrib3svARB);
+  SET_VertexAttrib4NbvARB(disp, glVertexAttrib4NbvARB);
+  SET_VertexAttrib4NivARB(disp, glVertexAttrib4NivARB);
+  SET_VertexAttrib4NsvARB(disp, glVertexAttrib4NsvARB);
+  SET_VertexAttrib4NubARB(disp, glVertexAttrib4NubARB);
+  SET_VertexAttrib4NubvARB(disp, glVertexAttrib4NubvARB);
+  SET_VertexAttrib4NuivARB(disp, glVertexAttrib4NuivARB);
+  SET_VertexAttrib4NusvARB(disp, glVertexAttrib4NusvARB);
+  SET_VertexAttrib4bvARB(disp, glVertexAttrib4bvARB);
+  SET_VertexAttrib4dARB(disp, glVertexAttrib4dARB);
+  SET_VertexAttrib4dvARB(disp, glVertexAttrib4dvARB);
+  SET_VertexAttrib4fARB(disp, glVertexAttrib4fARB);
+  SET_VertexAttrib4fvARB(disp, glVertexAttrib4fvARB);
+  SET_VertexAttrib4ivARB(disp, glVertexAttrib4ivARB);
+  SET_VertexAttrib4sARB(disp, glVertexAttrib4sARB);
+  SET_VertexAttrib4svARB(disp, glVertexAttrib4svARB);
+  SET_VertexAttrib4ubvARB(disp, glVertexAttrib4ubvARB);
+  SET_VertexAttrib4uivARB(disp, glVertexAttrib4uivARB);
+  SET_VertexAttrib4usvARB(disp, glVertexAttrib4usvARB);
+  SET_VertexAttribPointerARB(disp, glVertexAttribPointerARB);
+  SET_VertexPointer(disp, glVertexPointer);
+//  SET_VertexPointerEXT(disp, glVertexPointerEXT);
+  SET_Viewport(disp, glViewport);
+  SET_WindowPos2dMESA(disp, glWindowPos2dARB);
+  SET_WindowPos2dvMESA(disp, glWindowPos2dvARB);
+  SET_WindowPos2fMESA(disp, glWindowPos2fARB);
+  SET_WindowPos2fvMESA(disp, glWindowPos2fvARB);
+  SET_WindowPos2iMESA(disp, glWindowPos2iARB);
+  SET_WindowPos2ivMESA(disp, glWindowPos2ivARB);
+  SET_WindowPos2sMESA(disp, glWindowPos2sARB);
+  SET_WindowPos2svMESA(disp, glWindowPos2svARB);
+  SET_WindowPos3dMESA(disp, glWindowPos3dARB);
+  SET_WindowPos3dvMESA(disp, glWindowPos3dvARB);
+  SET_WindowPos3fMESA(disp, glWindowPos3fARB);
+  SET_WindowPos3fvMESA(disp, glWindowPos3fvARB);
+  SET_WindowPos3iMESA(disp, glWindowPos3iARB);
+  SET_WindowPos3ivMESA(disp, glWindowPos3ivARB);
+  SET_WindowPos3sMESA(disp, glWindowPos3sARB);
+  SET_WindowPos3svMESA(disp, glWindowPos3svARB);
+//SET_WindowPos4dMESA(disp, glWindowPos4dMESA);
+//SET_WindowPos4dvMESA(disp, glWindowPos4dvMESA);
+//SET_WindowPos4fMESA(disp, glWindowPos4fMESA);
+//SET_WindowPos4fvMESA(disp, glWindowPos4fvMESA);
+//SET_WindowPos4iMESA(disp, glWindowPos4iMESA);
+//SET_WindowPos4ivMESA(disp, glWindowPos4ivMESA);
+//SET_WindowPos4sMESA(disp, glWindowPos4sMESA);
+//SET_WindowPos4svMESA(disp, glWindowPos4svMESA);
 }
diff --git a/configure.ac b/configure.ac
index d69ede7..e1e77f5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -517,11 +517,11 @@ AC_ARG_ENABLE(xfree86-utils,     AS_HELP_STRING([--enable-xfree86-utils], [Build
 
 dnl DDXes.
 AC_ARG_ENABLE(xorg,    	      AS_HELP_STRING([--enable-xorg], [Build Xorg server (default: auto)]), [XORG=$enableval], [XORG=auto])
-AC_ARG_ENABLE(dmx,    	      AS_HELP_STRING([--enable-dmx], [Build DMX server (default: no)]), [DMX=$enableval], [DMX=no])
-AC_ARG_ENABLE(xvfb,    	      AS_HELP_STRING([--enable-xvfb], [Build Xvfb server (default: no)]), [XVFB=$enableval], [XVFB=yes])
+AC_ARG_ENABLE(dmx,    	      AS_HELP_STRING([--enable-dmx], [Build DMX server (default: auto)]), [DMX=$enableval], [DMX=auto])
+AC_ARG_ENABLE(xvfb,    	      AS_HELP_STRING([--enable-xvfb], [Build Xvfb server (default: yes)]), [XVFB=$enableval], [XVFB=yes])
 AC_ARG_ENABLE(xnest,   	      AS_HELP_STRING([--enable-xnest], [Build Xnest server (default: auto)]), [XNEST=$enableval], [XNEST=auto])
 AC_ARG_ENABLE(xwin,    	      AS_HELP_STRING([--enable-xwin], [Build XWin server (default: auto)]), [XWIN=$enableval], [XWIN=auto])
-AC_ARG_ENABLE(xprint,         AS_HELP_STRING([--enable-xprint], [Build Xprint extension and server (default: no)]), [XPRINT=$enableval], [XPRINT=no])
+AC_ARG_ENABLE(xprint,         AS_HELP_STRING([--enable-xprint], [Build Xprint extension and server (default: auto)]), [XPRINT=$enableval], [XPRINT=auto])
 AC_ARG_ENABLE(xgl,            AS_HELP_STRING([--enable-xgl], [Build Xgl server (default: no)]), [XGL=$enableval], [XGL=no])
 AC_ARG_ENABLE(xglx,           AS_HELP_STRING([--enable-xglx], [Build Xglx xgl module (default: no)]), [XGLX=$enableval], [XGLX=no])
 AC_ARG_ENABLE(xegl,           AS_HELP_STRING([--enable-xegl], [Build Xegl xgl module (default: no)]), [XEGL=$enableval], [XEGL=no])
@@ -555,7 +555,7 @@ if test "x$SETUID" = "xauto" ; then
 	   	case $host_cpu in
 		    sparc)	SETUID="no"  ;;
 		    *)		SETUID="yes" ;;
-		esac
+		esac ;;
 	esac
 	if test "x$SETUID" = xyes; then
 		touch testfile
@@ -722,7 +722,10 @@ if test "x$GLX" = xyes && ! test "x$MESA_SOURCE" = x; then
 	PKG_CHECK_MODULES([GL], [glproto >= 1.4.8])
 	AC_SUBST(XLIB_CFLAGS)
 	AC_DEFINE(GLXEXT, 1, [Build GLX extension])
-	GLX_LIBS='$(top_builddir)/GL/glx/libglx.la $(top_builddir)/GL/mesa/libGLcore.la'
+    case $host_os in
+      darwin*) GLX_LIBS='$(top_builddir)/GL/apple/indirect.o $(top_builddir)/GL/glx/libglx.la' ;;
+	  *)       GLX_LIBS='$(top_builddir)/GL/glx/libglx.la $(top_builddir)/GL/mesa/libGLcore.la' ;;
+	esac
 	test -d GL || mkdir GL
 	case $host_os in
 	  solaris*) 	
@@ -967,7 +970,7 @@ AC_SUBST([VENDOR_NAME])
 AC_SUBST([VENDOR_NAME_SHORT])
 AC_SUBST([VENDOR_RELEASE])
 AC_SUBST([VENDOR_MAN_VERSION])
-
+AC_SUBST([XORG_DATE])
 AC_DEFINE(DDXOSINIT, 1, [Use OsVendorInit])
 AC_DEFINE(SERVER_LOCK, 1, [Use a lock to prevent multiple servers on a display])
 AC_DEFINE(SMART_SCHEDULE, 1, [Include time-based scheduler])
@@ -1280,64 +1283,61 @@ dnl has it in libc), or if libdl is needed to get it.
 		AC_CHECK_LIB([dl], [dlopen], XORG_LIBS="$XORG_LIBS -ldl"))
 
 	case $host_os in
-         darwin*)
-               XORG_OS="Darwin"
-               build_darwin=yes
-               if test "X$XQUARTZ" = Xauto; then
-                 AC_CACHE_CHECK([for Carbon framework],xorg_cv_Carbon_framework,[
-                 save_LDFLAGS=$LDFLAGS
-                 LDFLAGS="$LDFLAGS -framework Carbon"
-                 AC_LINK_IFELSE([char FSFindFolder();
+	  darwin*)
+		XORG_OS="Darwin"
+		build_darwin=yes
+	  	if test "X$XQUARTZ" = Xauto; then
+	    	  AC_CACHE_CHECK([for Carbon framework],xorg_cv_Carbon_framework,[
+	    	  save_LDFLAGS=$LDFLAGS
+	    	  LDFLAGS="$LDFLAGS -framework Carbon"
+	    	  AC_LINK_IFELSE([char FSFindFolder();
 int main() {
 FSFindFolder();
 return 0;}
-                 ],[xorg_cv_Carbon_framework=yes],
-                  [xorg_cv_Carbon_framework=no])
-                  LDFLAGS=$save_LDFLAGS])
-                 if test "X$xorg_cv_Carbon_framework" = Xyes; then
-                   AC_DEFINE([DARWIN_WITH_QUARTZ],[1],
-                         [Have Quartz])
-                   XQUARTZ=yes
-                 else
-                   XQUARTZ=no
-                 fi
-               fi
-#	       glxAGL / glxCGL don't work yet
-#               AC_CACHE_CHECK([for AGL framework],xorg_cv_AGL_framework,[
-#               save_LDFLAGS=$LDFLAGS
-#               LDFLAGS="$LDFLAGS -framework AGL"
-#               AC_LINK_IFELSE([char aglEnable();
-#int main() {
-#aglEnable();
-#return 0;}
-#               ],[xorg_cv_AGL_framework=yes],
-#               [xorg_cv_AGL_framework=no])
-#               LDFLAGS=$save_LDFLAGS
-#               ])
-               xorg_cv_AGL_framework=no
-	       DARWIN_LIBS="$FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB $OS_LIB"
-	       AC_SUBST([DARWIN_LIBS])
-               AC_CHECK_LIB([Xplugin],[xp_init],[:])
-               AC_SUBST([APPLE_APPLICATIONS_DIR])
-               CFLAGS="${CFLAGS} -D__DARWIN__"
-               PLIST_VERSION_STRING=$PACKAGE_VERSION
-               AC_SUBST([PLIST_VERSION_STRING])
-               PLIST_VENDOR_WEB=$VENDOR_WEB
-               AC_SUBST([PLIST_VENDOR_WEB])
-               # Not sure that we should be disabling all these...
-               if test "x$XF86MISC" = xyes || test "x$XF86MISC" = xauto; then
-                       AC_MSG_NOTICE([Disabling XF86Misc extension])
-                       XF86MISC=no
-               fi
-               if test "x$XF86VIDMODE" = xyes || test "x$XF86VIDMODE" = xauto; then
-                       AC_MSG_NOTICE([Disabling XF86VidMode extension])
-                       XF86VIDMODE=no
-               fi
-               if test "x$DGA" = xyes || test "x$DGA" = xauto; then
-                       AC_MSG_NOTICE([Disabling DGA extension])
-                       DGA=no
-               fi
-               ;;
+		  ],[xorg_cv_Carbon_framework=yes],
+		   [xorg_cv_Carbon_framework=no])
+	    	   LDFLAGS=$save_LDFLAGS])
+		  if test "X$xorg_cv_Carbon_framework" = Xyes; then
+		    AC_DEFINE([DARWIN_WITH_QUARTZ],[1],
+			  [Have Quartz])
+		    XQUARTZ=yes
+		  else
+		    XQUARTZ=no
+		  fi
+    	  	fi
+		AC_DEFINE(ROOTLESS,1,[Build Rootless code])
+		AC_CACHE_CHECK([for AGL framework],xorg_cv_AGL_framework,[
+	    	save_LDFLAGS=$LDFLAGS
+	    	LDFLAGS="$LDFLAGS -framework AGL"
+	    	AC_LINK_IFELSE([char aglEnable();
+int main() {
+aglEnable();
+return 0;}
+		],[xorg_cv_AGL_framework=yes],
+		[xorg_cv_AGL_framework=no])
+	    	LDFLAGS=$save_LDFLAGS
+		])	
+		AC_CHECK_LIB([Xplugin],[xp_init],[:])
+		AC_SUBST([APPLE_APPLICATIONS_DIR])
+		CFLAGS="${CFLAGS} -D__DARWIN__"
+		PLIST_VERSION_STRING=$VENDOR_VERSION_STRING
+		AC_SUBST([PLIST_VERSION_STRING])
+		PLIST_VENDOR_WEB=$VENDOR_WEB
+		AC_SUBST([PLIST_VENDOR_WEB])	
+		# Not sure that we should be disabling all these...
+	        if test "x$XF86MISC" = xyes; then
+	                AC_MSG_NOTICE([Disabling XF86Misc extension])
+	                XF86MISC=no
+	        fi
+		if test "x$XF86VIDMODE" = xyes; then
+			AC_MSG_NOTICE([Disabling XF86VidMode extension])
+			XF86VIDMODE=no
+		fi
+		if test "x$DGA" = xyes; then
+			AC_MSG_NOTICE([Disabling DGA extension])
+			DGA=no
+		fi
+	 	;;
 	  linux*)
 		if test "x$LNXAPM" = xyes; then
 			XORG_CFLAGS="$XORG_CFLAGS -DXF86PM"
@@ -1458,10 +1458,6 @@ return 0;}
 		Free/Open/NetBSD, Solaris, and OS X. If you are interested in porting \
 	        Xorg to your platform, please email xorg at lists.freedesktop.org.])
 		;;
-	esac
-
-	case $host_cpu in
-	  i*86)
                case $host_os in
                  darwin*) ;;
                  *) xorg_bus_ix86pci=yes ;;
@@ -1542,6 +1538,32 @@ return 0;}
 	fi
 	AC_SUBST(PERL)
 
+	# The Xorg binary needs to export symbols so that they can be used from modules
+	# Some platforms require extra flags to do this.   gcc should set these flags
+	# when -rdynamic is passed to it, other compilers/linkers may need to be added
+	# here.
+	if test "x$GCC" = "xyes"; then
+		GCC_WARNINGS1="-Wall -Wpointer-arith -Wstrict-prototypes"
+		GCC_WARNINGS2="-Wmissing-prototypes -Wmissing-declarations"
+		GCC_WARNINGS3="-Wnested-externs -fno-strict-aliasing"
+		GCC_WARNINGS="$GCC_WARNINGS1 $GCC_WARNINGS2 $GCC_WARNINGS3"
+		if test "x$WERROR" = "xyes"; then
+			GCC_WARNINGS="${GCC_WARNINGS} -Werror"
+		fi
+		XSERVER_CFLAGS="$GCC_WARNINGS $XSERVER_CFLAGS"
+		case $host_os in
+		  darwin*) ;; # Symbols are exported by default, no need
+		  # to do anything special. I think that the following
+		  # is wrong anyway when using libtool. Should be using
+		  # the libtool flag -export-dynamic?
+		  *)LD_EXPORT_SYMBOLS_FLAG="-rdynamic" ;;
+		esac
+	fi
+	case $host_os in
+		openbsd*)
+		LD_EXPORT_SYMBOLS_FLAG="-Wl,--export-dynamic"
+		;;
+	esac
 	AC_SUBST([XORG_CFLAGS])
 
 	dnl these only go in xorg-config.h
@@ -1575,6 +1597,26 @@ return 0;}
 	AC_SUBST([extdir])
 	AC_SUBST([logdir])
 fi
+
+if test "x$XF86VIDMODE" = xyes; then
+	AC_DEFINE(XF86VIDMODE, 1, [Support XFree86 Video Mode extension])
+fi
+
+if test "x$XF86MISC" = xyes; then
+	AC_DEFINE(XF86MISC, 1, [Support XFree86 miscellaneous extensions])
+fi
+# Support for objc in autotools is minimal and not documented.
+OBJC='$(CC)'
+OBJCLD='$(CCLD)'
+OBJCLINK='$(LINK)'
+OBJCFLAGS='$(CFLAGS)'
+AC_SUBST([OBJC])
+AC_SUBST([OBJCCLD])
+AC_SUBST([OBJCLINK])
+AC_SUBST([OBJCFLAGS])
+# internal, undocumented automake func follows :(
+_AM_DEPENDENCIES([OBJC])
+
 AM_CONDITIONAL([XORG], [test "x$XORG" = xyes])
 AM_CONDITIONAL([XORG_BUS_LINUXPCI], [test "x$xorg_bus_linuxpci" = xyes])
 AM_CONDITIONAL([XORG_BUS_FREEBSDPCI], [test "x$xorg_bus_freebsdpci" = xyes])
@@ -1661,7 +1703,6 @@ if test "x$XPRINT" = xyes; then
 fi
 AM_CONDITIONAL(XP_USE_FREETYPE, [test "x$XPRINT" = xyes && test "x$XP_USE_FREETYPE" = xyes])
 
-
 dnl XWin DDX
 
 AC_MSG_CHECKING([whether to build XWin DDX])
@@ -1888,6 +1929,10 @@ AC_DEFINE_DIR(XKM_OUTPUT_DIR, XKBOUTPUT, [Path to XKB output dir])
 
 AC_SUBST(XKB_COMPILED_DIR)
 
+AM_CONDITIONAL(DGA, [test "x$DGA" = xyes])
+if test "x$DGA" = xyes; then
+	AC_DEFINE(DGA, 1, [Support DGA extension])
+fi
 dnl and the rest of these are generic, so they're in config.h
 AC_DEFINE(XResExtension, 1, [Build XRes extension])
 
@@ -2095,6 +2140,9 @@ hw/darwin/bundle/Swedish.lproj/Makefile
 hw/darwin/bundle/ko.lproj/Makefile
 hw/darwin/iokit/Makefile
 hw/darwin/quartz/Makefile
+hw/darwin/quartz/cr/Makefile
+hw/darwin/quartz/fullscreen/Makefile
+hw/darwin/quartz/xpr/Makefile
 hw/darwin/utils/Makefile
 hw/kdrive/Makefile
 hw/kdrive/ati/Makefile
diff --git a/hw/darwin/Makefile.am b/hw/darwin/Makefile.am
index 560cc3a..54f3f33 100644
--- a/hw/darwin/Makefile.am
+++ b/hw/darwin/Makefile.am
@@ -235,7 +235,6 @@ glxMesa_la_DEPENDENCIES = XDarwinApp
 endif
 
 endif
-if HAVE_X_PLUGIN
 
 xprplugindir = $(darwinappdir)/Contents/Resources/xpr.bundle/Contents/MacOS
 xprplugin_LTLIBRARIES =
@@ -259,9 +258,6 @@ xpr_la_LDFLAGS = -shrext '' -Wl,-framework,ApplicationServices \
 		-module -avoid-version -no-undefined
 xpr_la_DEPENDENCIES = XDarwinApp	
 
-endif
-
-if HAVE_AGL_FRAMEWORK
 glxCGLplugindir = $(darwinappdir)/Contents/Resources/glxCGL.bundle/Contents/MacOS
 glxCGLplugin_LTLIBRARIES =
 glxCGL_la_SOURCES =
@@ -293,10 +289,6 @@ glxAGL_la_LDFLAGS = -shrext '' \
 		-module -avoid-version -no-undefined
 glxAGL_la_DEPENDENCIES = XDarwinApp	
 
-
-
-endif
-
 man1_MANS = XDarwin.man
 
 uninstall-hook:
diff --git a/hw/darwin/quartz/Makefile.am b/hw/darwin/quartz/Makefile.am
index bc6d4fc..0d236be 100644
--- a/hw/darwin/quartz/Makefile.am
+++ b/hw/darwin/quartz/Makefile.am
@@ -5,10 +5,9 @@ AM_OBJCFLAGS = @XORG_CFLAGS@
 
 INCLUDES = -I$(srcdir) -I$(srcdir)/.. @XORG_INCS@
 AM_DEFS = -DHAS_CG_MACH_PORT -DHAS_KL_API
-if HAVE_X_PLUGIN
 AM_DEFS += -DBUILD_XPR
 XPR = xpr
-endif
+
 DEFS = @DEFS@ $(AM_DEFS) -DXBINDIR=\"${bindir}\"
 SUBDIRS = cr fullscreen $(XPR)
 
diff --git a/mi/miinitext.c b/mi/miinitext.c
index 0fc6d15..8c34d01 100644
--- a/mi/miinitext.c
+++ b/mi/miinitext.c
@@ -338,7 +338,7 @@ extern void XFree86DGAExtensionInit(INITARGS);
 #endif
 #ifdef GLXEXT
 typedef struct __GLXprovider __GLXprovider;
-#ifdef INXDARWINAPP
+#if defined(__DARWIN__) && !defined(INXQUARTZ)
 extern __GLXprovider* __DarwinglXMesaProvider;
 extern void DarwinGlxPushProvider(__GLXprovider *impl);
 extern void DarwinGlxExtensionInit(INITARGS);
@@ -348,8 +348,8 @@ extern __GLXprovider __glXMesaProvider;
 extern void GlxPushProvider(__GLXprovider *impl);
 extern void GlxExtensionInit(INITARGS);
 extern void GlxWrapInitVisuals(miInitVisualsProcPtr *);
-#endif // INXDARWINAPP
-#endif // GLXEXT
+#endif
+#endif
 #ifdef XF86DRI
 extern void XFree86DRIExtensionInit(INITARGS);
 #endif
@@ -633,14 +633,14 @@ InitExtensions(argc, argv)
 #endif
 
 #ifdef GLXEXT
-#ifdef INXDARWINAPP
+#if defined(__DARWIN__) && !defined(INXQUARTZ)
     DarwinGlxPushProvider(__DarwinglXMesaProvider);
     if (!noGlxExtension) DarwinGlxExtensionInit();
 #else
     GlxPushProvider(&__glXMesaProvider);
     if (!noGlxExtension) GlxExtensionInit();
-#endif // INXDARWINAPP
-#endif // GLXEXT
+#endif
+#endif
 #ifdef XFIXES
     /* must be before Render to layer DisplayCursor correctly */
     if (!noXFixesExtension) XFixesExtensionInit();
diff --git a/os/connection.c b/os/connection.c
index d975f87..07e1eaa 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -74,6 +74,7 @@ SOFTWARE.
 #define TRANS_SERVER
 #define TRANS_REOPEN
 #include <X11/Xtrans/Xtrans.h>
+#include <X11/Xtrans/Xtransint.h>
 #include <errno.h>
 #include <signal.h>
 #include <stdio.h>
@@ -660,9 +661,15 @@ ClientAuthorized(ClientPtr client,
     XID	 		auth_id;
     char	 	*reason = NULL;
     XtransConnInfo	trans_conn;
-
+    struct sockaddr     *saddr;
     priv = (OsCommPtr)client->osPrivate;
     trans_conn = priv->trans_conn;
+    saddr = (struct sockaddr *) (trans_conn->addr);
+    
+    /* Allow any client to connect without authorization on a launchd socket,
+       because it is securely created -- this prevents a race condition on launch */
+    if (saddr->sa_len > 11 && saddr->sa_family == AF_UNIX &&
+	!strncmp(saddr->sa_data, "/tmp/launch", 11))  goto done;
 
     auth_id = CheckAuthorization (proto_n, auth_proto,
 				  string_n, auth_string, client, &reason);
@@ -719,6 +726,7 @@ ClientAuthorized(ClientPtr client,
 	}
     }
     priv->auth_id = auth_id;
+done:
     priv->conn_time = 0;
 
 #ifdef XDMCP
commit 2c4d1eeb412177e86104c9aa56e6101ebf8e2532
Author: Ben Byer <bbyer at bbyer.local>
Date:   Sat Oct 27 02:22:56 2007 -0700

    removed CVS Id tags

diff --git a/hw/darwin/XDarwin.man b/hw/darwin/XDarwin.man
index eb1b9dc..143fb7c 100644
--- a/hw/darwin/XDarwin.man
+++ b/hw/darwin/XDarwin.man
@@ -1,4 +1,3 @@
-.\" $XFree86: xc/programs/Xserver/hw/darwin/XDarwin.man,v 1.3 2001/09/23 23:02:37 torrey Exp $
 .\"
 .TH XDARWIN 1 __vendorversion__
 .SH NAME
diff --git a/hw/darwin/apple/Xquartz.man b/hw/darwin/apple/Xquartz.man
index edac30e..37a7f1a 100644
--- a/hw/darwin/apple/Xquartz.man
+++ b/hw/darwin/apple/Xquartz.man
@@ -1,5 +1,3 @@
-.\" $XFree86: xc/programs/Xserver/hw/darwin/XDarwin.man,v 1.4 2002/01/09 18:01:58 torrey Exp $
-.\"
 .TH XQUARTZ 1 __vendorversion__
 .SH NAME
 Xquartz \- X window system server for Quartz operating system
diff --git a/hw/darwin/bundle/Dutch.lproj/XDarwinHelp.html.cpp b/hw/darwin/bundle/Dutch.lproj/XDarwinHelp.html.cpp
index 1113b8a..4b8e6f5 100644
--- a/hw/darwin/bundle/Dutch.lproj/XDarwinHelp.html.cpp
+++ b/hw/darwin/bundle/Dutch.lproj/XDarwinHelp.html.cpp
@@ -1,5 +1,3 @@
-<!-- $XFree86: xc/programs/Xserver/hw/darwin/bundle/English.lproj/XDarwinHelp.html.cpp,v 1.2 2001/11/04 07:02:28 torrey Exp $ -->
-
 <html>
 <head>
 <title>XDarwin Help</title>
diff --git a/hw/darwin/bundle/English.lproj/InfoPlist.strings.cpp b/hw/darwin/bundle/English.lproj/InfoPlist.strings.cpp
index aeb2103..268b800 100644
--- a/hw/darwin/bundle/English.lproj/InfoPlist.strings.cpp
+++ b/hw/darwin/bundle/English.lproj/InfoPlist.strings.cpp
@@ -1,5 +1,4 @@
 /* English versions of the Info.plist keys; used by most localizations. */
 /* Most of these are set in the target application settings. */
-/* $XFree86: xc/programs/Xserver/hw/darwin/bundle/English.lproj/InfoPlist.strings.cpp,v 1.3 2002/07/17 01:24:55 torrey Exp $ */
 
 NSHumanReadableCopyright = __quote__ X_VENDOR_NAME X_VERSION __quote__;
diff --git a/hw/darwin/bundle/English.lproj/XDarwinHelp.html.cpp b/hw/darwin/bundle/English.lproj/XDarwinHelp.html.cpp
index 5996285..db33670 100644
--- a/hw/darwin/bundle/English.lproj/XDarwinHelp.html.cpp
+++ b/hw/darwin/bundle/English.lproj/XDarwinHelp.html.cpp
@@ -1,5 +1,3 @@
-<!-- $XFree86: xc/programs/Xserver/hw/darwin/bundle/English.lproj/XDarwinHelp.html.cpp,v 1.1 2001/05/21 01:42:17 torrey Exp $ -->
-
 <html>
 <head>
 <title>XDarwin Help</title>
diff --git a/hw/darwin/bundle/French.lproj/XDarwinHelp.html.cpp b/hw/darwin/bundle/French.lproj/XDarwinHelp.html.cpp
index 2a14793..512416b 100644
--- a/hw/darwin/bundle/French.lproj/XDarwinHelp.html.cpp
+++ b/hw/darwin/bundle/French.lproj/XDarwinHelp.html.cpp
@@ -1,5 +1,3 @@
-<!-- $XFree86: xc/programs/Xserver/hw/darwin/bundle/English.lproj/XDarwinHelp.html.cpp,v 1.2 2001/11/04 07:02:28 torrey Exp $ -->
-
 <html>
 <head><META HTTP-EQUIV="content-type" CONTENT="text/html; charset=iso-8859-1">
 <title>XDarwin Help</title>
diff --git a/hw/darwin/bundle/German.lproj/XDarwinHelp.html.cpp b/hw/darwin/bundle/German.lproj/XDarwinHelp.html.cpp
index 5996285..db33670 100644
--- a/hw/darwin/bundle/German.lproj/XDarwinHelp.html.cpp
+++ b/hw/darwin/bundle/German.lproj/XDarwinHelp.html.cpp
@@ -1,5 +1,3 @@
-<!-- $XFree86: xc/programs/Xserver/hw/darwin/bundle/English.lproj/XDarwinHelp.html.cpp,v 1.1 2001/05/21 01:42:17 torrey Exp $ -->
-
 <html>
 <head>
 <title>XDarwin Help</title>
diff --git a/hw/darwin/bundle/Portuguese.lproj/XDarwinHelp.html.cpp b/hw/darwin/bundle/Portuguese.lproj/XDarwinHelp.html.cpp
index 7ef1ba5..6800171 100644
--- a/hw/darwin/bundle/Portuguese.lproj/XDarwinHelp.html.cpp
+++ b/hw/darwin/bundle/Portuguese.lproj/XDarwinHelp.html.cpp
@@ -1,5 +1,3 @@
-<!-- $XFree86: xc/programs/Xserver/hw/darwin/bundle/English.lproj/XDarwinHelp.html.cpp,v 1.2 2001/11/04 07:02:28 torrey Exp $ --><html><body>
-
 <head>
 <title>XDarwin Help</title>
 </head>
diff --git a/hw/darwin/bundle/Spanish.lproj/XDarwinHelp.html.cpp b/hw/darwin/bundle/Spanish.lproj/XDarwinHelp.html.cpp
index 5cd2786..a79e6f9 100644
--- a/hw/darwin/bundle/Spanish.lproj/XDarwinHelp.html.cpp
+++ b/hw/darwin/bundle/Spanish.lproj/XDarwinHelp.html.cpp
@@ -1,5 +1,3 @@
-<!-- $XFree86: xc/programs/Xserver/hw/darwin/bundle/English.lproj/XDarwinHelp.html.cpp,v 1.2 2001/11/04 07:02:28 torrey Exp $ -->
-
 <html>
 <head>
 <title>XDarwin Ayuda</title>
diff --git a/hw/darwin/bundle/Swedish.lproj/XDarwinHelp.html.cpp b/hw/darwin/bundle/Swedish.lproj/XDarwinHelp.html.cpp
index 4210878..ab940ec 100644
--- a/hw/darwin/bundle/Swedish.lproj/XDarwinHelp.html.cpp
+++ b/hw/darwin/bundle/Swedish.lproj/XDarwinHelp.html.cpp
@@ -1,5 +1,3 @@
-<!-- $XFree86: xc/programs/Xserver/hw/darwin/bundle/English.lproj/XDarwinHelp.html.cpp,v 1.2 2001/11/04 07:02:28 torrey Exp $ -->
-
 <html>
 <head>
 <title>XDarwin Help</title>
diff --git a/hw/darwin/bundle/ko.lproj/XDarwinHelp.html.cpp b/hw/darwin/bundle/ko.lproj/XDarwinHelp.html.cpp
index 5996285..db33670 100644
--- a/hw/darwin/bundle/ko.lproj/XDarwinHelp.html.cpp
+++ b/hw/darwin/bundle/ko.lproj/XDarwinHelp.html.cpp
@@ -1,5 +1,3 @@
-<!-- $XFree86: xc/programs/Xserver/hw/darwin/bundle/English.lproj/XDarwinHelp.html.cpp,v 1.1 2001/05/21 01:42:17 torrey Exp $ -->
-
 <html>
 <head>
 <title>XDarwin Help</title>
diff --git a/hw/darwin/bundle/startXClients.cpp b/hw/darwin/bundle/startXClients.cpp
index 51cdb5c..f812dbf 100644
--- a/hw/darwin/bundle/startXClients.cpp
+++ b/hw/darwin/bundle/startXClients.cpp
@@ -2,8 +2,6 @@ XCOMM!/bin/sh
 
 XCOMM This script is used by XDarwin to start X clients when XDarwin is
 XCOMM launched from the Finder.
-XCOMM
-XCOMM $XFree86: $
 
 userclientrc=$HOME/.xinitrc
 sysclientrc=XINITDIR/xinitrc
diff --git a/hw/darwin/quartz/Preferences.m b/hw/darwin/quartz/Preferences.m
index eb78fd3..b5eeedd 100644
--- a/hw/darwin/quartz/Preferences.m
+++ b/hw/darwin/quartz/Preferences.m
@@ -30,7 +30,7 @@
  * sale, use or other dealings in this Software without prior written
  * authorization.
  */
-/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/Preferences.m,v 1.5 2004/06/08 22:58:10 torrey Exp $ */
+
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
diff --git a/hw/darwin/quartz/XApplication.m b/hw/darwin/quartz/XApplication.m
index e0ee8d9..de32d38 100644
--- a/hw/darwin/quartz/XApplication.m
+++ b/hw/darwin/quartz/XApplication.m
@@ -30,7 +30,6 @@
  * sale, use or other dealings in this Software without prior written
  * authorization.
  */
-/* $XFree86: $ */
 
 #import "XApplication.h"
 
diff --git a/hw/darwin/quartz/XDarwinStartup.man b/hw/darwin/quartz/XDarwinStartup.man
index 9bf7dfa..1ad3bbc 100644
--- a/hw/darwin/quartz/XDarwinStartup.man
+++ b/hw/darwin/quartz/XDarwinStartup.man
@@ -1,4 +1,3 @@
-.\" $XFree86: xc/programs/Xserver/hw/darwin/bundle/XDarwinStartup.man,v 1.1 2002/02/05 19:16:14 torrey Exp $
 .TH XDarwinStartup 1
 .SH NAME
 XDarwinStartup - Startup program for the XDarwin X window server
diff --git a/hw/darwin/quartz/cr/XView.m b/hw/darwin/quartz/cr/XView.m
index 8bcd1a7..488f88a 100644
--- a/hw/darwin/quartz/cr/XView.m
+++ b/hw/darwin/quartz/cr/XView.m
@@ -29,7 +29,7 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
-/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/cr/XView.m,v 1.1 2003/06/07 05:49:07 torrey Exp $ */
+
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
diff --git a/hw/darwin/quartz/cr/cr.h b/hw/darwin/quartz/cr/cr.h
index d6779ae..0ebad5d 100644
--- a/hw/darwin/quartz/cr/cr.h
+++ b/hw/darwin/quartz/cr/cr.h
@@ -1,7 +1,6 @@
 /*
  * Internal definitions of the Cocoa rootless implementation
- */
-/*
+ *
  * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
diff --git a/hw/darwin/quartz/cr/crAppleWM.m b/hw/darwin/quartz/cr/crAppleWM.m
index 259c2d8..da05fed 100644
--- a/hw/darwin/quartz/cr/crAppleWM.m
+++ b/hw/darwin/quartz/cr/crAppleWM.m
@@ -1,7 +1,6 @@
 /*
  * Cocoa rootless implementation functions for AppleWM extension
- */
-/*
+ *
  * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -26,7 +25,7 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
-/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/xprFrame.c,v 1.2 2003/06/30 01:45:13 torrey Exp $ */
+
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
diff --git a/hw/darwin/quartz/cr/crFrame.m b/hw/darwin/quartz/cr/crFrame.m
index 5f04ab2..f54afc9 100644
--- a/hw/darwin/quartz/cr/crFrame.m
+++ b/hw/darwin/quartz/cr/crFrame.m
@@ -1,7 +1,6 @@
 /*
  * Cocoa rootless implementation frame functions
- */
-/*
+ *
  * Copyright (c) 2001 Greg Parker. All Rights Reserved.
  * Copyright (c) 2002-2003 Torrey T. Lyons. All Rights Reserved.
  *
@@ -27,8 +26,7 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
-/* $XdotOrg: xserver/xorg/hw/darwin/quartz/cr/crFrame.m,v 1.3 2004/10/08 00:35:05 torrey Exp $ */
-/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/cr/crFrame.m,v 1.9 2004/03/19 02:05:29 torrey Exp $ */
+
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
diff --git a/hw/darwin/quartz/cr/crScreen.m b/hw/darwin/quartz/cr/crScreen.m
index c17f294..0e358ab 100644
--- a/hw/darwin/quartz/cr/crScreen.m
+++ b/hw/darwin/quartz/cr/crScreen.m
@@ -1,8 +1,6 @@
-/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/cr/crScreen.m,v 1.4 2004/08/12 20:24:36 torrey Exp $ */
 /*
  * Cocoa rootless implementation initialization
- */
-/*
+ *
  * Copyright (c) 2001 Greg Parker. All Rights Reserved.
  * Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved.
  *
@@ -28,7 +26,7 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
-/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/cr/crScreen.m,v 1.5 2003/11/12 20:21:52 torrey Exp $ */
+
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
diff --git a/hw/darwin/quartz/fullscreen/fullscreen.c b/hw/darwin/quartz/fullscreen/fullscreen.c
index 5e60ac6..ce3036f 100644
--- a/hw/darwin/quartz/fullscreen/fullscreen.c
+++ b/hw/darwin/quartz/fullscreen/fullscreen.c
@@ -25,8 +25,7 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
-/* $XdotOrg: xserver/xorg/hw/darwin/quartz/fullscreen/fullscreen.c,v 1.4 2005/07/01 22:43:08 daniels Exp $ */
-/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/fullscreen/fullscreen.c,v 1.3 2003/11/27 01:59:53 torrey Exp $ */
+
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
diff --git a/hw/darwin/quartz/fullscreen/quartzCursor.c b/hw/darwin/quartz/fullscreen/quartzCursor.c
index 60a4c4d..a5483ee 100644
--- a/hw/darwin/quartz/fullscreen/quartzCursor.c
+++ b/hw/darwin/quartz/fullscreen/quartzCursor.c
@@ -2,8 +2,6 @@
  *
  * Support for using the Quartz Window Manager cursor
  *
- **************************************************************/
-/*
  * Copyright (c) 2001-2003 Torrey T. Lyons and Greg Parker.
  *                 All Rights Reserved.
  *
@@ -29,7 +27,7 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
-/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzCursor.c,v 1.5 2003/01/23 00:34:26 torrey Exp $ */
+
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
diff --git a/hw/darwin/quartz/fullscreen/quartzCursor.h b/hw/darwin/quartz/fullscreen/quartzCursor.h
index efcc443..56a0209 100644
--- a/hw/darwin/quartz/fullscreen/quartzCursor.h
+++ b/hw/darwin/quartz/fullscreen/quartzCursor.h
@@ -2,8 +2,7 @@
  * quartzCursor.h
  *
  * External interface for Quartz hardware cursor
- */
-/*
+ *
  * Copyright (c) 2001 Torrey T. Lyons and Greg Parker.
  *                 All Rights Reserved.
  *
@@ -29,7 +28,6 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
-/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzCursor.h,v 1.1 2002/03/28 02:21:19 torrey Exp $ */
 
 #ifndef QUARTZCURSOR_H
 #define QUARTZCURSOR_H
diff --git a/hw/darwin/quartz/keysym2ucs.c b/hw/darwin/quartz/keysym2ucs.c
index 3be59df..8626ebc 100644
--- a/hw/darwin/quartz/keysym2ucs.c
+++ b/hw/darwin/quartz/keysym2ucs.c
@@ -1,4 +1,5 @@
-/*
+/* 
+ *
  * This module converts keysym values into the corresponding ISO 10646
  * (UCS, Unicode) values.
  *
diff --git a/hw/darwin/quartz/keysym2ucs.h b/hw/darwin/quartz/keysym2ucs.h
index f5b7a18..e167d6a 100644
--- a/hw/darwin/quartz/keysym2ucs.h
+++ b/hw/darwin/quartz/keysym2ucs.h
@@ -1,4 +1,4 @@
-/*
+/* 
  * This module converts keysym values into the corresponding ISO 10646
  * (UCS, Unicode) values.
  *
diff --git a/hw/darwin/quartz/pseudoramiX.c b/hw/darwin/quartz/pseudoramiX.c
index f02867c..e65be69 100644
--- a/hw/darwin/quartz/pseudoramiX.c
+++ b/hw/darwin/quartz/pseudoramiX.c
@@ -32,7 +32,6 @@ shall not be used in advertising or otherwise to promote the sale, use or other
 dealings in this Software without prior written authorization from Digital
 Equipment Corporation.
 ******************************************************************/
-/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/pseudoramiX.c,v 1.4 2004/07/02 01:30:33 torrey Exp $ */
 
 #include "pseudoramiX.h"
 #ifdef HAVE_XORG_CONFIG_H
diff --git a/hw/darwin/quartz/pseudoramiX.h b/hw/darwin/quartz/pseudoramiX.h
index c294336..df5010d 100644
--- a/hw/darwin/quartz/pseudoramiX.h
+++ b/hw/darwin/quartz/pseudoramiX.h
@@ -1,7 +1,6 @@
 /*
  * Minimal implementation of PanoramiX/Xinerama
  */
-/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/pseudoramiX.h,v 1.3 2004/07/02 01:30:33 torrey Exp $ */
 
 extern int noPseudoramiXExtension;
 
diff --git a/hw/darwin/quartz/quartz.c b/hw/darwin/quartz/quartz.c
index baeba8f..ac555ec 100644
--- a/hw/darwin/quartz/quartz.c
+++ b/hw/darwin/quartz/quartz.c
@@ -1,10 +1,7 @@
-/* $XdotOrg: xserver/xorg/hw/darwin/quartz/quartz.c,v 1.4 2005/07/01 22:43:07 daniels Exp $ */
-/**************************************************************
+/*
  *
  * Quartz-specific support for the Darwin X Server
  *
- **************************************************************/
-/*
  * Copyright (c) 2001-2004 Greg Parker and Torrey T. Lyons.
  *                 All Rights Reserved.
  *
@@ -30,7 +27,7 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
-/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartz.c,v 1.16 2004/07/02 01:30:33 torrey Exp $ */
+
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
diff --git a/hw/darwin/quartz/quartz.h b/hw/darwin/quartz/quartz.h
index c83579c..fa7499d 100644
--- a/hw/darwin/quartz/quartz.h
+++ b/hw/darwin/quartz/quartz.h
@@ -3,8 +3,7 @@
  *
  * External interface of the Quartz display modes seen by the generic, mode
  * independent parts of the Darwin X server.
- */
-/*
+ *
  * Copyright (c) 2001-2003 Greg Parker and Torrey T. Lyons.
  *                 All Rights Reserved.
  *
@@ -30,8 +29,6 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
-/* $XdotOrg: xserver/xorg/hw/darwin/quartz/quartz.h,v 1.4 2005/07/01 22:43:07 daniels Exp $ */
-/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartz.h,v 1.7 2003/11/12 20:21:51 torrey Exp $ */
 
 #ifndef _QUARTZ_H
 #define _QUARTZ_H
diff --git a/hw/darwin/quartz/quartzAudio.c b/hw/darwin/quartz/quartzAudio.c
index 03f9cca..1980cd2 100644
--- a/hw/darwin/quartz/quartzAudio.c
+++ b/hw/darwin/quartz/quartzAudio.c
@@ -35,7 +35,7 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
-/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzAudio.c,v 1.1 2002/03/28 02:21:18 torrey Exp $ */
+
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
diff --git a/hw/darwin/quartz/quartzAudio.h b/hw/darwin/quartz/quartzAudio.h
index e20c21a..c406bbc 100644
--- a/hw/darwin/quartz/quartzAudio.h
+++ b/hw/darwin/quartz/quartzAudio.h
@@ -28,7 +28,6 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
-/* $XFree86: xc/programs/Xserver/hw/darwin/bundle/quartzAudio.h,v 1.2 2001/04/01 20:45:43 tsi Exp $ */
 
 #ifndef _QUARTZAUDIO_H
 #define _QUARTZAUDIO_H
diff --git a/hw/darwin/quartz/quartzCocoa.m b/hw/darwin/quartz/quartzCocoa.m
index a9c89c0..2e7b86b 100644
--- a/hw/darwin/quartz/quartzCocoa.m
+++ b/hw/darwin/quartz/quartzCocoa.m
@@ -1,4 +1,3 @@
-/* $XdotOrg: xserver/xorg/hw/darwin/quartz/quartzCocoa.m,v 1.3 2004/07/30 19:12:17 torrey Exp $ */
 /**************************************************************
  *
  * Quartz-specific support for the Darwin X Server
@@ -7,8 +6,7 @@
  * This file is separate from the parts of Quartz support
  * that use X include files to avoid symbol collisions.
  *
- **************************************************************/
-/*
+ *
  * Copyright (c) 2001-2004 Torrey T. Lyons and Greg Parker.
  *                 All Rights Reserved.
  *
@@ -34,7 +32,7 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
-/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzCocoa.m,v 1.5 2004/06/08 22:58:10 torrey Exp $ */
+
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
diff --git a/hw/darwin/quartz/quartzCommon.h b/hw/darwin/quartz/quartzCommon.h
index 2fd79eb..f5dff66 100644
--- a/hw/darwin/quartz/quartzCommon.h
+++ b/hw/darwin/quartz/quartzCommon.h
@@ -1,4 +1,3 @@
-/* $XdotOrg: xserver/xorg/hw/darwin/quartz/quartzCommon.h,v 1.4 2005/07/01 22:43:07 daniels Exp $ */
 /*
  * quartzCommon.h
  *
@@ -32,7 +31,6 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
-/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzCommon.h,v 1.15 2004/06/08 22:58:10 torrey Exp $ */
 
 #ifndef _QUARTZCOMMON_H
 #define _QUARTZCOMMON_H
diff --git a/hw/darwin/quartz/quartzCursor.c b/hw/darwin/quartz/quartzCursor.c
index dd183db..c9d125f 100644
--- a/hw/darwin/quartz/quartzCursor.c
+++ b/hw/darwin/quartz/quartzCursor.c
@@ -2,8 +2,6 @@
  *
  * Support for using the Quartz Window Manager cursor
  *
- **************************************************************/
-/*
  * Copyright (c) 2001-2003 Torrey T. Lyons and Greg Parker.
  *                 All Rights Reserved.
  *
@@ -29,7 +27,6 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
-/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzCursor.c,v 1.4 2002/11/19 23:01:30 torrey Exp $ */
 
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
diff --git a/hw/darwin/quartz/quartzCursor.h b/hw/darwin/quartz/quartzCursor.h
index e847f8c..56a0209 100644
--- a/hw/darwin/quartz/quartzCursor.h
+++ b/hw/darwin/quartz/quartzCursor.h
@@ -2,8 +2,7 @@
  * quartzCursor.h
  *
  * External interface for Quartz hardware cursor
- */
-/*
+ *
  * Copyright (c) 2001 Torrey T. Lyons and Greg Parker.
  *                 All Rights Reserved.
  *
@@ -29,7 +28,6 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
-/* $XFree86: xc/programs/Xserver/hw/darwin/bundle/quartzCursor.h,v 1.2 2001/09/23 04:04:49 torrey Exp $ */
 
 #ifndef QUARTZCURSOR_H
 #define QUARTZCURSOR_H
diff --git a/hw/darwin/quartz/quartzKeyboard.c b/hw/darwin/quartz/quartzKeyboard.c
index 80e22aa..b330793 100644
--- a/hw/darwin/quartz/quartzKeyboard.c
+++ b/hw/darwin/quartz/quartzKeyboard.c
@@ -31,7 +31,6 @@
    promote the sale, use or other dealings in this Software without
    prior written authorization.
 */
-/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzKeyboard.c,v 1.1 2003/11/01 08:13:08 torrey Exp $ */
 
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
diff --git a/hw/darwin/quartz/quartzPasteboard.c b/hw/darwin/quartz/quartzPasteboard.c
index 7ae2e33..a3536fc 100644
--- a/hw/darwin/quartz/quartzPasteboard.c
+++ b/hw/darwin/quartz/quartzPasteboard.c
@@ -29,7 +29,6 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
-/* $XFree86: xc/programs/Xserver/hw/darwin/bundle/quartzPasteboard.c,v 1.3 2001/09/23 04:04:49 torrey Exp $ */
 
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
diff --git a/hw/darwin/quartz/quartzPasteboard.h b/hw/darwin/quartz/quartzPasteboard.h
index 296c52c..afcb6e5 100644
--- a/hw/darwin/quartz/quartzPasteboard.h
+++ b/hw/darwin/quartz/quartzPasteboard.h
@@ -29,7 +29,6 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
-/* $XFree86: xc/programs/Xserver/hw/darwin/bundle/quartzPasteboard.h,v 1.1 2001/03/15 22:24:27 torrey Exp $ */
 
 #ifndef _QUARTZPASTEBOARD_H
 #define _QUARTZPASTEBOARD_H
@@ -42,4 +41,4 @@ char * QuartzReadCocoaPasteboard(void);	// caller must free string
 void QuartzWritePasteboard();
 void QuartzWriteCocoaPasteboard(char *text);
 
-#endif	/* _QUARTZPASTEBOARD_H */
\ No newline at end of file
+#endif	/* _QUARTZPASTEBOARD_H */
diff --git a/hw/darwin/quartz/quartzStartup.c b/hw/darwin/quartz/quartzStartup.c
index 34176c5..1a040ff 100644
--- a/hw/darwin/quartz/quartzStartup.c
+++ b/hw/darwin/quartz/quartzStartup.c
@@ -2,8 +2,6 @@
  *
  * Startup code for the Quartz Darwin X Server
  *
- **************************************************************/
-/*
  * Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -28,7 +26,6 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
-/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzStartup.c,v 1.8 2003/11/05 00:15:00 torrey Exp $ */
 
 #include <fcntl.h>
 #include <unistd.h>
diff --git a/hw/darwin/quartz/xpr/Xplugin.h b/hw/darwin/quartz/xpr/Xplugin.h
index ff74e37..a10b1b8 100644
--- a/hw/darwin/quartz/xpr/Xplugin.h
+++ b/hw/darwin/quartz/xpr/Xplugin.h
@@ -29,7 +29,6 @@
 
    Note that these interfaces are provided solely for the use of the
    X11 server. Any other uses are unsupported and strongly discouraged. */
-/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/Xplugin.h,v 1.2 2003/05/02 00:08:49 torrey Exp $ */
 
 #ifndef XPLUGIN_H
 #define XPLUGIN_H 1
diff --git a/hw/darwin/quartz/xpr/appledri.c b/hw/darwin/quartz/xpr/appledri.c
index 159ee72..ef68c86 100644
--- a/hw/darwin/quartz/xpr/appledri.c
+++ b/hw/darwin/quartz/xpr/appledri.c
@@ -1,4 +1,3 @@
-/* $XFree86: xc/programs/Xserver/GL/dri/xf86dri.c,v 1.10 2000/12/07 20:26:14 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
diff --git a/hw/darwin/quartz/xpr/appledri.h b/hw/darwin/quartz/xpr/appledri.h
index 9c63037..c4e43be 100644
--- a/hw/darwin/quartz/xpr/appledri.h
+++ b/hw/darwin/quartz/xpr/appledri.h
@@ -1,4 +1,3 @@
-/* $XFree86: xc/lib/GL/dri/xf86dri.h,v 1.7 2000/12/07 20:26:02 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
diff --git a/hw/darwin/quartz/xpr/appledristr.h b/hw/darwin/quartz/xpr/appledristr.h
index 36a2e89..8649fd3 100644
--- a/hw/darwin/quartz/xpr/appledristr.h
+++ b/hw/darwin/quartz/xpr/appledristr.h
@@ -1,4 +1,3 @@
-/* $XFree86: xc/lib/GL/dri/xf86dristr.h,v 1.9 2001/03/21 16:01:08 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
diff --git a/hw/darwin/quartz/xpr/dri.c b/hw/darwin/quartz/xpr/dri.c
index acc152e..13943fd 100644
--- a/hw/darwin/quartz/xpr/dri.c
+++ b/hw/darwin/quartz/xpr/dri.c
@@ -1,4 +1,3 @@
-/* $XFree86: xc/programs/Xserver/GL/dri/dri.c,v 1.34 2001/12/10 19:07:19 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
diff --git a/hw/darwin/quartz/xpr/dri.h b/hw/darwin/quartz/xpr/dri.h
index f826167..cf2638a 100644
--- a/hw/darwin/quartz/xpr/dri.h
+++ b/hw/darwin/quartz/xpr/dri.h
@@ -1,4 +1,3 @@
-/* $XFree86: xc/programs/Xserver/GL/dri/dri.h,v 1.18 2001/03/21 16:21:40 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
diff --git a/hw/darwin/quartz/xpr/dristruct.h b/hw/darwin/quartz/xpr/dristruct.h
index 0df8f18..9a3d01c 100644
--- a/hw/darwin/quartz/xpr/dristruct.h
+++ b/hw/darwin/quartz/xpr/dristruct.h
@@ -1,4 +1,3 @@
-/* $XFree86: xc/programs/Xserver/GL/dri/dristruct.h,v 1.10 2001/03/21 16:21:40 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
diff --git a/hw/darwin/quartz/xpr/x-hash.c b/hw/darwin/quartz/xpr/x-hash.c
index 0491a5a..62d1a99 100644
--- a/hw/darwin/quartz/xpr/x-hash.c
+++ b/hw/darwin/quartz/xpr/x-hash.c
@@ -1,5 +1,4 @@
 /* x-hash.c - basic hash tables
-   $Id: x-hash.c,v 1.7 2003/07/17 05:25:44 jharper Exp $
 
    Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
 
@@ -27,7 +26,7 @@
    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. */
-/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/x-hash.c,v 1.1 2003/04/30 23:15:42 torrey Exp $ */
+
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
diff --git a/hw/darwin/quartz/xpr/x-hash.h b/hw/darwin/quartz/xpr/x-hash.h
index 599366e..3456dbe 100644
--- a/hw/darwin/quartz/xpr/x-hash.h
+++ b/hw/darwin/quartz/xpr/x-hash.h
@@ -26,7 +26,6 @@
    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. */
-/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/x-hash.h,v 1.1 2003/04/30 23:15:42 torrey Exp $ */
 
 #ifndef X_HASH_H
 #define X_HASH_H 1
diff --git a/hw/darwin/quartz/xpr/x-hook.c b/hw/darwin/quartz/xpr/x-hook.c
index 215cb15..323e373 100644
--- a/hw/darwin/quartz/xpr/x-hook.c
+++ b/hw/darwin/quartz/xpr/x-hook.c
@@ -26,7 +26,7 @@
    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. */
-/* $XFree86: $ */
+
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
diff --git a/hw/darwin/quartz/xpr/x-list.c b/hw/darwin/quartz/xpr/x-list.c
index c87045e..2e74ae8 100644
--- a/hw/darwin/quartz/xpr/x-list.c
+++ b/hw/darwin/quartz/xpr/x-list.c
@@ -1,5 +1,4 @@
 /* x-list.c
-   $Id: x-list.c,v 1.16 2003/07/18 00:52:19 jharper Exp $
 
    Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
 
@@ -27,7 +26,7 @@
    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. */
-/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/x-list.c,v 1.1 2003/04/30 23:15:42 torrey Exp $ */
+
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
diff --git a/hw/darwin/quartz/xpr/x-list.h b/hw/darwin/quartz/xpr/x-list.h
index 2b71070..04af024 100644
--- a/hw/darwin/quartz/xpr/x-list.h
+++ b/hw/darwin/quartz/xpr/x-list.h
@@ -1,5 +1,4 @@
 /* x-list.h -- simple list type
-   $Id: x-list.h,v 1.10 2003/07/18 00:52:19 jharper Exp $
 
    Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
 
@@ -27,7 +26,6 @@
    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. */
-/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/x-list.h,v 1.1 2003/04/30 23:15:42 torrey Exp $ */
 
 #ifndef X_LIST_H
 #define X_LIST_H 1
diff --git a/hw/darwin/quartz/xpr/xpr.h b/hw/darwin/quartz/xpr/xpr.h
index 5b02c6d..81bb912 100644
--- a/hw/darwin/quartz/xpr/xpr.h
+++ b/hw/darwin/quartz/xpr/xpr.h
@@ -1,7 +1,6 @@
 /*
  * Xplugin rootless implementation
- */
-/*
+ *
  * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -26,8 +25,6 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
-/* $XdotOrg: xserver/xorg/hw/darwin/quartz/xpr/xpr.h,v 1.3 2005/07/01 22:43:08 daniels Exp $ */
-/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/xpr.h,v 1.4 2003/11/12 20:21:52 torrey Exp $ */
 
 #ifndef XPR_H
 #define XPR_H
diff --git a/hw/darwin/quartz/xpr/xprAppleWM.c b/hw/darwin/quartz/xpr/xprAppleWM.c
index c528836..17d3600 100644
--- a/hw/darwin/quartz/xpr/xprAppleWM.c
+++ b/hw/darwin/quartz/xpr/xprAppleWM.c
@@ -1,7 +1,6 @@
 /*
  * Xplugin rootless implementation functions for AppleWM extension
- */
-/*
+ *
  * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
  * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
  *
@@ -27,7 +26,7 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
-/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/xprFrame.c,v 1.2 2003/06/30 01:45:13 torrey Exp $ */
+
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
diff --git a/hw/darwin/quartz/xpr/xprCursor.c b/hw/darwin/quartz/xpr/xprCursor.c
index 9f9abc2..570ef0b 100644
--- a/hw/darwin/quartz/xpr/xprCursor.c
+++ b/hw/darwin/quartz/xpr/xprCursor.c
@@ -2,8 +2,6 @@
  *
  * Xplugin cursor support
  *
- **************************************************************/
-/*
  * Copyright (c) 2001 Torrey T. Lyons and Greg Parker.
  * Copyright (c) 2002 Apple Computer, Inc.
  *                 All Rights Reserved.
@@ -30,7 +28,7 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
-/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/xprCursor.c,v 1.1 2003/04/30 23:15:42 torrey Exp $ */
+
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
diff --git a/hw/darwin/quartz/xpr/xprFrame.c b/hw/darwin/quartz/xpr/xprFrame.c
index b141e62..0e3b200 100644
--- a/hw/darwin/quartz/xpr/xprFrame.c
+++ b/hw/darwin/quartz/xpr/xprFrame.c
@@ -1,7 +1,6 @@
 /*
  * Xplugin rootless implementation frame functions
- */
-/*
+ *
  * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
  * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
  *
@@ -27,8 +26,7 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
-/* $XdotOrg: xserver/xorg/hw/darwin/quartz/xpr/xprFrame.c,v 1.5 2005/07/01 22:43:08 daniels Exp $ */
-/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/xprFrame.c,v 1.4 2003/11/12 20:21:52 torrey Exp $ */
+
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
diff --git a/hw/darwin/quartz/xpr/xprScreen.c b/hw/darwin/quartz/xpr/xprScreen.c
index 73fa6f6..4e0bdc2 100644
--- a/hw/darwin/quartz/xpr/xprScreen.c
+++ b/hw/darwin/quartz/xpr/xprScreen.c
@@ -1,8 +1,6 @@
-/* $XdotOrg: xserver/xorg/hw/darwin/quartz/xpr/xprScreen.c,v 1.6 2005/07/01 22:43:08 daniels Exp $ */
 /*
  * Xplugin rootless implementation screen functions
- */
-/*
+ *
  * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved.
  * Copyright (c) 2004 Torrey T. Lyons. All Rights Reserved.
  *
@@ -28,7 +26,7 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
-/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/xprScreen.c,v 1.11 2004/07/15 18:53:25 torrey Exp $ */
+
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
diff --git a/hw/darwin/utils/README.txt b/hw/darwin/utils/README.txt
index fb6d439..1dd6479 100644
--- a/hw/darwin/utils/README.txt
+++ b/hw/darwin/utils/README.txt
@@ -105,7 +105,3 @@ The implementation of dumpkeymap is based upon information gathered on
 September 3, 1997 by Eric Sunshine <sunshine at sunshineco.com> and Paul S.
 McCarthy <zarnuk at zarnuk.com> during an effort to reverse engineer the format
 of the NeXT .keymapping file.
-
-
-
-$XFree86: xc/programs/Xserver/hw/darwin/utils/README.txt,v 1.1 2000/12/01 19:47:39 dawes Exp $
diff --git a/hw/darwin/utils/dumpkeymap.c b/hw/darwin/utils/dumpkeymap.c
index c3e66e3..6a8b8b1 100644
--- a/hw/darwin/utils/dumpkeymap.c
+++ b/hw/darwin/utils/dumpkeymap.c
@@ -1,4 +1,3 @@
-// $XFree86: dumpkeymap.c,v 1.3 2000/12/05 21:18:34 dawes Exp $
 //=============================================================================
 //
 // Copyright (C) 1999,2000 by Eric Sunshine <sunshine at sunshineco.com>
diff --git a/hw/darwin/utils/dumpkeymap.man b/hw/darwin/utils/dumpkeymap.man
index 90a2cd0..02b09e6 100644
--- a/hw/darwin/utils/dumpkeymap.man
+++ b/hw/darwin/utils/dumpkeymap.man
@@ -30,8 +30,6 @@
 //
 //=============================================================================
 //
-// $XFree86$
-//
 ..
 .ig
 //-----------------------------------------------------------------------------
commit a1d901d6866e2d98d75e42ca3016859ef0082f95
Author: Ben Byer <bbyer at bbyer.local>
Date:   Sat Oct 27 01:38:31 2007 -0700

    merged the rest of Apple patches to xserver

diff --git a/hw/darwin/Makefile.am b/hw/darwin/Makefile.am
index b773910..560cc3a 100644
--- a/hw/darwin/Makefile.am
+++ b/hw/darwin/Makefile.am
@@ -1,8 +1,7 @@
 noinst_LIBRARIES = libdarwinShared.a
 libdarwin_XINPUT_SRCS = darwinXinput.c
 
-AM_CFLAGS = @XORG_CFLAGS@ @DIX_CFLAGS@
-AM_CPPFLAGS = @XORG_CFLAGS@ @DIX_CFLAGS@
+AM_CFLAGS = @XORG_CFLAGS@
 INCLUDES = @XORG_INCS@ -I../../miext/rootless
 
 DEFS = @DEFS@ -DUSE_NEW_CLUT
@@ -17,26 +16,25 @@ SUBDIRS = \
 	  utils \
 	  .
 
-darwinappdir = @APPLE_APPLICATIONS_DIR@/XDarwin.app
+darwinappdir = /Applications/Utilities/XDarwin.app
 
 libdarwinShared_a_SOURCES = darwin.c \
 			  darwinEvents.c \
 			  darwinKeyboard.c \
 			  $(darwin_XINPUT_SRCS) 
 
-bin_PROGRAMS = XDarwin Xquartz
+bin_PROGRAMS = Xquartz
 XDarwin_SOURCES = \
-                  $(top_srcdir)/fb/fbcmap_mi.c \
+                  $(top_srcdir)/fb/fbcmap.c \
                   $(top_srcdir)/mi/miinitext.c \
                   $(top_srcdir)/Xi/stubs.c
 
 Xquartz_SOURCES = \
-                  $(top_srcdir)/fb/fbcmap_mi.c \
+                  $(top_srcdir)/fb/fbcmap.c \
                   $(top_srcdir)/mi/miinitext.c \
                   $(top_srcdir)/Xi/stubs.c \
                   apple/X11Application.m \
                   apple/X11Controller.m \
-                  quartz/Preferences.m \
                   quartz/applewm.c \
                   quartz/keysym2ucs.c \
                   quartz/pseudoramiX.c \
@@ -59,31 +57,56 @@ Xquartz_SOURCES = \
 XDarwin_LDADD = \
 		$(top_builddir)/dix/dixfonts.lo \
 		$(top_builddir)/dix/libdix.la \
-		$(top_builddir)/config/libconfig.a \
+		$(top_builddir)/os/libos.la \
 		./libdarwinShared.a \
 		./iokit/libiokit.a \
+		$(top_builddir)/dix/libxpstubs.la \
 		$(top_builddir)/miext/shadow/libshadow.la \
+		$(top_builddir)/fb/libfb.la \
+		$(top_builddir)/composite/libcomposite.la \
+		$(top_builddir)/damageext/libdamageext.la \
+		$(top_builddir)/miext/damage/libdamage.la \
+		$(top_builddir)/xfixes/libxfixes.la \
 		$(top_builddir)/miext/cw/libcw.la \
-		$(DARWIN_LIBS) \
+		$(top_builddir)/Xext/libXext.la \
+		$(top_builddir)/xkb/libxkb.la \
+		$(top_builddir)/xkb/libxkbstubs.la \
+		$(top_builddir)/Xi/libXi.la \
+		$(top_builddir)/dbe/libdbe.la \
+		$(top_builddir)/record/librecord.la \
+		$(top_builddir)/XTrap/libxtrap.la \
+		$(XGLX_LIBS) \
 		$(top_builddir)/miext/rootless/librootless.la \
 		$(top_builddir)/miext/rootless/safeAlpha/libsafeAlpha.la \
 		$(top_builddir)/miext/rootless/accel/librlAccel.la \
 		@XORG_LIBS@ \
-		$(XSERVER_LIBS)
+		-lXau -lXdmcp -lXfont -lfreetype
 
 Xquartz_LDADD = \
 		$(top_builddir)/dix/dixfonts.lo \
 		$(top_builddir)/dix/libdix.la \
-		$(top_builddir)/config/libconfig.a \
+		$(top_builddir)/os/libos.la \
 		./libdarwinShared.a \
+		$(top_builddir)/dix/libxpstubs.la \
 		$(top_builddir)/miext/shadow/libshadow.la \
+		$(top_builddir)/fb/libfb.la \
+		$(top_builddir)/composite/libcomposite.la \
+		$(top_builddir)/damageext/libdamageext.la \
+		$(top_builddir)/miext/damage/libdamage.la \
+		$(top_builddir)/xfixes/libxfixes.la \
 		$(top_builddir)/miext/cw/libcw.la \
-		$(DARWIN_LIBS) \
+		$(top_builddir)/Xext/libXext.la \
+		$(top_builddir)/xkb/libxkb.la \
+		$(top_builddir)/xkb/libxkbstubs.la \
+		$(top_builddir)/Xi/libXi.la \
+		$(top_builddir)/dbe/libdbe.la \
+		$(top_builddir)/record/librecord.la \
+		$(top_builddir)/XTrap/libxtrap.la \
 		$(top_builddir)/miext/rootless/librootless.la \
 		$(top_builddir)/miext/rootless/safeAlpha/libsafeAlpha.la \
 		$(top_builddir)/miext/rootless/accel/librlAccel.la \
 		@XORG_LIBS@ \
-		$(XSERVER_LIBS) -lXplugin
+		-lXau -lXdmcp -lXfont -lfreetype -lXplugin
 
 XDarwin_LDFLAGS =  \
                  -XCClinker -Objc \
@@ -94,6 +117,7 @@ Xquartz_LDFLAGS =  \
                  -XCClinker -Objc \
                  -Wl,-u,_miDCInitialize \
                  -Wl,-framework,Carbon \
+	         -L/System/Library/Frameworks/OpenGL.framework/Libraries -lGL \
                  -Wl,-framework,OpenGL \
                  -Wl,-framework,Cocoa \
                  -Wl,-framework,CoreAudio \
@@ -101,39 +125,53 @@ Xquartz_LDFLAGS =  \
 
 XDarwin_CFLAGS = -DINXDARWIN
 Xquartz_CFLAGS = -DINXQUARTZ -DHAS_CG_MACH_PORT -DHAS_KL_API  -DHAVE_XORG_CONFIG_H
+Xquartz_OBJCFLAGS = -DINXQUARTZ -DHAS_CG_MACH_PORT -DHAS_KL_API  -DHAVE_XORG_CONFIG_H
 
 if XQUARTZ
 macosdir = $(darwinappdir)/Contents/MacOS
 
 DEFS += -DDARWIN_WITH_QUARTZ -DXFree86Server
 
-macos_PROGRAMS = XDarwinApp
+macos_PROGRAMS = 
 macos_SCRIPTS = x11app
 
 x11app:
-	cd apple && xcodebuild CFLAGS="$(XSERVERCFLAGS_CFLAGS)" LDFLAGS="$(XSERVERCFLAGS_LIBS)"
+	cd apple && xcodebuild
 
 XDarwinApp_SOURCES = \
-                $(top_srcdir)/fb/fbcmap_mi.c \
-                $(top_srcdir)/mi/miinitext.c \
+               	$(top_srcdir)/fb/fbcmap.c \
+               	$(top_srcdir)/mi/miinitext.c \
 		$(top_srcdir)/Xi/stubs.c 
 
 XDarwinApp_LDADD = \
 		$(top_builddir)/dix/dixfonts.lo \
 		$(top_builddir)/dix/libdix.la \
-		$(top_builddir)/config/libconfig.a \
 		$(top_builddir)/os/libos.la \
 		./quartz/XApplication.o \
 		./libdarwinShared.a \
 		./quartz/libXQuartz.a \
+		$(top_builddir)/dix/libxpstubs.la \
 		 $(top_builddir)/miext/shadow/libshadow.la \
+		 $(top_builddir)/fb/libfb.la \
+		 $(top_builddir)/composite/libcomposite.la \
+		 $(top_builddir)/damageext/libdamageext.la \
+		 $(top_builddir)/miext/damage/libdamage.la \
+		 $(top_builddir)/xfixes/libxfixes.la \
 		 $(top_builddir)/miext/cw/libcw.la \
-		 $(DARWIN_LIBS) \
+		 $(top_builddir)/Xext/libXext.la \
+		 $(top_builddir)/xkb/libxkb.la \
+		 $(top_builddir)/xkb/libxkbstubs.la \
+		 $(top_builddir)/Xi/libXi.la \
+		 $(top_builddir)/dbe/libdbe.la \
+		 $(top_builddir)/record/librecord.la \
+		 $(top_builddir)/XTrap/libxtrap.la \
+		 $(XGLX_LIBS) \
 		 $(top_builddir)/miext/rootless/librootless.la \
 		 $(top_builddir)/miext/rootless/safeAlpha/libsafeAlpha.la \
 		 $(top_builddir)/miext/rootless/accel/librlAccel.la \
 		 @XORG_LIBS@ \
-		 $(XSERVER_LIBS)
+		 -lXau -lXdmcp -lXfont -lfreetype \
+		 $(top_builddir)/fb/libfb.la 
 
 XDarwinApp_LDFLAGS =  \
 		 -XCClinker -Objc \
@@ -144,24 +182,21 @@ XDarwinApp_LDFLAGS =  \
 		 -Wl,-framework,CoreAudio \
 		 -Wl,-framework,IOKit
 
-XDarwinApp_CFLAGS = -DINXDARWINAPP
 HOOK_TARGETS = xquartz-install-hook
 
 
 crplugindir = $(darwinappdir)/Contents/Resources/cr.bundle/Contents/MacOS
-crplugin_LTLIBRARIES = cr.la
-cr_la_SOURCES = \
-		quartz/cr/crAppleWM.m \
-		quartz/cr/crFrame.m \
-		quartz/cr/crScreen.m \
-		quartz/fullscreen/quartzCursor.c \
-		quartz/cr/XView.m
-
+crplugin_LTLIBRARIES = 
+cr_la_SOURCES =
 cr_la_LIBADD = \
+		quartz/cr/crAppleWM.o \
+		quartz/cr/crFrame.o \
+		quartz/cr/crScreen.o \
+		quartz/fullscreen/quartzCursor.o \
+		quartz/cr/XView.o \
 		$(top_builddir)/miext/rootless/librootless.la \
 		$(top_builddir)/miext/rootless/safeAlpha/libsafeAlpha.la \
 		$(top_builddir)/miext/rootless/accel/librlAccel.la
-
 cr_la_LDFLAGS = -shrext '' -Wl,-framework,ApplicationServices \
 		-Wl,-framework,Cocoa \
 		-Wl,-framework,Carbon \
@@ -171,12 +206,11 @@ cr_la_LDFLAGS = -shrext '' -Wl,-framework,ApplicationServices \
 cr_la_DEPENDENCIES = XDarwinApp	
 
 fullscreenplugindir = $(darwinappdir)/Contents/Resources/fullscreen.bundle/Contents/MacOS
-fullscreenplugin_LTLIBRARIES = fullscreen.la
-fullscreen_la_SOURCES = \
-		quartz/fullscreen/fullscreen.c \
-		quartz/fullscreen/quartzCursor.c
-
+fullscreenplugin_LTLIBRARIES =
+fullscreen_la_SOURCES =
 fullscreen_la_LIBADD = \
+		quartz/fullscreen/fullscreen.o \
+		quartz/fullscreen/quartzCursor.o \
 		$(top_builddir)/miext/shadow/libshadow.la
 
 fullscreen_la_LDFLAGS = -shrext '' -Wl,-framework,ApplicationServices \
@@ -186,7 +220,7 @@ fullscreen_la_DEPENDENCIES = XDarwinApp
 
 if GLX
 glxMesaplugindir = $(darwinappdir)/Contents/Resources/glxMesa.bundle/Contents/MacOS
-glxMesaplugin_LTLIBRARIES = glxMesa.la
+glxMesaplugin_LTLIBRARIES =
 glxMesa_la_SOURCES =
 glxMesa_la_LIBADD = \
 		$(top_builddir)/GL/glx/libglx.la \
@@ -204,23 +238,21 @@ endif
 if HAVE_X_PLUGIN
 
 xprplugindir = $(darwinappdir)/Contents/Resources/xpr.bundle/Contents/MacOS
-xprplugin_LTLIBRARIES = xpr.la
-xpr_la_SOURCES = \
-		quartz/xpr/appledri.c \
-		quartz/xpr/dri.c \
-		quartz/xpr/xprAppleWM.c \
-		quartz/xpr/xprCursor.c \
-		quartz/xpr/xprFrame.c \
-		quartz/xpr/xprScreen.c \
-		quartz/xpr/x-hash.c \
-		quartz/xpr/x-hook.c \
-		quartz/xpr/x-list.c
-
+xprplugin_LTLIBRARIES =
+xpr_la_SOURCES =
 xpr_la_LIBADD = \
+		quartz/xpr/appledri.o \
+		quartz/xpr/dri.o \
+		quartz/xpr/xprAppleWM.o \
+		quartz/xpr/xprCursor.o \
+		quartz/xpr/xprFrame.o \
+		quartz/xpr/xprScreen.o \
+		quartz/xpr/x-hash.o \
+		quartz/xpr/x-hook.o \
+		quartz/xpr/x-list.o \
 		$(top_builddir)/miext/rootless/librootless.la \
 		$(top_builddir)/miext/rootless/safeAlpha/libsafeAlpha.la \
 		$(top_builddir)/miext/rootless/accel/librlAccel.la
-
 xpr_la_LDFLAGS = -shrext '' -Wl,-framework,ApplicationServices \
 		-lXplugin \
 		-XCClinker -bundle_loader -XCClinker XDarwinApp \
@@ -231,7 +263,7 @@ endif
 
 if HAVE_AGL_FRAMEWORK
 glxCGLplugindir = $(darwinappdir)/Contents/Resources/glxCGL.bundle/Contents/MacOS
-glxCGLplugin_LTLIBRARIES = glxCGL.la
+glxCGLplugin_LTLIBRARIES =
 glxCGL_la_SOURCES =
 glxCGL_la_LIBADD = \
 		$(top_builddir)/GL/glx/glxext.o \
@@ -247,7 +279,7 @@ glxCGL_la_DEPENDENCIES = XDarwinApp
 
 
 glxAGLplugindir = $(darwinappdir)/Contents/Resources/glxAGL.bundle/Contents/MacOS
-glxAGLplugin_LTLIBRARIES = glxAGL.la
+glxAGLplugin_LTLIBRARIES =
 glxAGL_la_SOURCES =
 glxAGL_la_LIBADD = \
 		$(top_builddir)/GL/glx/glxext.o \
@@ -273,8 +305,8 @@ uninstall-hook:
 install-data-hook: $(HOOK_TARGETS)
 
 xquartz-install-hook:
-	mv $(DESTDIR)$(macosdir)/XDarwinApp $(DESTDIR)$(macosdir)/XDarwin
 	cd apple && xcodebuild install
+	cd launcher && xcodebuild install
 
 EXTRA_DIST = \
 	darwin.c \
diff --git a/hw/darwin/darwin.c b/hw/darwin/darwin.c
index 7da8626..c3b21c1 100644
--- a/hw/darwin/darwin.c
+++ b/hw/darwin/darwin.c
@@ -83,7 +83,6 @@ int                     darwinScreenIndex = 0;
 io_connect_t            darwinParamConnect = 0;
 int                     darwinEventReadFD = -1;
 int                     darwinEventWriteFD = -1;
-int                     darwinMouseAccelChange = 1;
 int                     darwinFakeButtons = 0;
 
 // location of X11's (0,0) point in global screen coordinates
@@ -127,87 +126,16 @@ const int NUMFORMATS = sizeof(formats)/sizeof(formats[0]);
 #ifndef PRE_RELEASE
 #define PRE_RELEASE XORG_VERSION_SNAP
 #endif
+#ifndef BUILD_DATE
+#define BUILD_DATE ""
+#endif
 
 void
 DarwinPrintBanner()
 {
-#if PRE_RELEASE
-  ErrorF("\n"
-    "This is a pre-release version of the " XVENDORNAME " X11.\n"
-    "Portions of this release are based on XFree86 4.4RC2 and selected\n"
-    "files from XFree86 4.4RC3. It is not supported in any way.\n"
-    "Bugs may be filed in the bugzilla at http://bugs.freedesktop.org/.\n"
-    "Select the \"xorg\" product for bugs you find in this release.\n"
-    "Before reporting bugs in pre-release versions please check the\n"
-    "latest version in the " XVENDORNAME " \"monolithic tree\" CVS\n"
-    "repository hosted at http://www.freedesktop.org/Software/xorg/");
-#endif
-#if XORG_VERSION_SNAP > 0
-  ErrorF(".%d", XORG_VERSION_SNAP);
-#endif
-
-#if XORG_VERSION_SNAP >= 900
-  ErrorF(" (%d.%d.0 RC %d)", XORG_VERSION_MAJOR, XORG_VERSION_MINOR + 1,
-				XORG_VERSION_SNAP - 900);
-#endif
-
-#ifdef XORG_CUSTOM_VERSION
-  ErrorF(" (%s)", XF86_CUSTOM_VERSION);
-#endif
-  ErrorF("\nRelease Date: %s\n", XF86_DATE);
-  ErrorF("X Protocol Version %d, Revision %d, %s\n",
-         X_PROTOCOL, X_PROTOCOL_REVISION, XORG_RELEASE );
-  ErrorF("Build Operating System: %s %s\n", OSNAME, OSVENDOR);
-#ifdef HAS_UTSNAME
-  {
-    struct utsname name;
-
-    if (uname(&name) == 0) {
-      ErrorF("Current Operating System: %s %s %s %s %s\n",
-	name.sysname, name.nodename, name.release, name.version, name.machine);
-    }
-  }
-#endif
-#if defined(BUILD_DATE) && (BUILD_DATE > 19000000)
-  {
-    struct tm t;
-    char buf[100];
-
-    bzero(&t, sizeof(t));
-    bzero(buf, sizeof(buf));
-    t.tm_mday = BUILD_DATE % 100;
-    t.tm_mon = (BUILD_DATE / 100) % 100 - 1;
-    t.tm_year = BUILD_DATE / 10000 - 1900;
-    if (strftime(buf, sizeof(buf), "%d %B %Y", &t))
-       ErrorF("Build Date: %s\n", buf);
-  }
-#endif
-#if defined(CLOG_DATE) && (CLOG_DATE > 19000000)
-  {
-    struct tm t;
-    char buf[100];
-
-    bzero(&t, sizeof(t));
-    bzero(buf, sizeof(buf));
-    t.tm_mday = CLOG_DATE % 100;
-    t.tm_mon = (CLOG_DATE / 100) % 100 - 1;
-    t.tm_year = CLOG_DATE / 10000 - 1900;
-    if (strftime(buf, sizeof(buf), "%d %B %Y", &t))
-       ErrorF("Changelog Date: %s\n", buf);
-  }
-#endif
-#if defined(BUILDERSTRING)
-  ErrorF("%s \n",BUILDERSTRING);
-#endif
-  ErrorF("\tBefore reporting problems, check "__VENDORDWEBSUPPORT__"\n"
-	 "\tto make sure that you have the latest version.\n");
-}
-
-
-void DDXRingBell(int volume, int pitch, int duration)
-{
-  // FIXME -- make some noise, yo
-}
+  ErrorF("X11.app starting:\n");
+  ErrorF("Xquartz server based on X.org %s, built on %s\n", XORG_RELEASE, BUILD_DATE );
+ }
 
 
 /*
@@ -359,8 +287,8 @@ static Bool DarwinAddScreen(
     dixScreenOrigins[index].x = dfb->x;
     dixScreenOrigins[index].y = dfb->y;
 
-    ErrorF("Screen %d added: %dx%d @ (%d,%d)\n",
-            index, dfb->width, dfb->height, dfb->x, dfb->y);
+    /*    ErrorF("Screen %d added: %dx%d @ (%d,%d)\n",
+	  index, dfb->width, dfb->height, dfb->x, dfb->y); */
 
     return TRUE;
 }
@@ -374,28 +302,6 @@ static Bool DarwinAddScreen(
 */
 
 /*
- * DarwinChangePointerControl
- *  Set mouse acceleration and thresholding
- *  FIXME: We currently ignore the threshold in ctrl->threshold.
- */
-static void DarwinChangePointerControl(
-    DeviceIntPtr    device,
-    PtrCtrl         *ctrl )
-{
-    kern_return_t   kr;
-    double          acceleration;
-
-    if (!darwinMouseAccelChange)
-        return;
-
-    acceleration = ctrl->num / ctrl->den;
-    kr = IOHIDSetMouseAcceleration( darwinParamConnect, acceleration );
-    if (kr != KERN_SUCCESS)
-        ErrorF( "Could not set mouse acceleration with kernel return = 0x%x.\n", kr );
-}
-
-
-/*
  * DarwinMouseProc
  *  Handle the initialization, etc. of a mouse
  */
@@ -419,9 +325,9 @@ static int DarwinMouseProc(
             InitPointerDeviceStruct( (DevicePtr)pPointer,
                         map,
                         5,   // numbuttons (4 & 5 are scroll wheel)
-                        GetMotionHistory,
-                        DarwinChangePointerControl,
-                        GetMotionHistorySize(), 2 );
+                        miPointerGetMotionEvents,
+		        (PtrCtrlProcPtr)NoopDDA,
+                        0 );
 #ifdef XINPUT
             InitValuatorAxisStruct( pPointer,
                                     0,     // X axis
@@ -643,8 +549,8 @@ DarwinAdjustScreenOrigins(ScreenInfo *pScreenInfo)
         for (i = 0; i < pScreenInfo->numScreens; i++) {
             dixScreenOrigins[i].x -= darwinMainScreenX;
             dixScreenOrigins[i].y -= darwinMainScreenY;
-            ErrorF("Screen %d placed at X11 coordinate (%d,%d).\n",
-                   i, dixScreenOrigins[i].x, dixScreenOrigins[i].y);
+	    /*            ErrorF("Screen %d placed at X11 coordinate (%d,%d).\n",
+			  i, dixScreenOrigins[i].x, dixScreenOrigins[i].y); */
         }
     }
 }
@@ -721,13 +627,13 @@ void OsVendorInit(void)
         if ( !tempStr ) {
             ErrorF("Could not find keymapping file %s.\n", darwinKeymapFile);
         } else {
-            ErrorF("Using keymapping provided in %s.\n", tempStr);
+	  ErrorF("Using keymapping provided in %s.\n", tempStr);
         }
         darwinKeymapFile = tempStr;
     }
 
     if ( !darwinKeymapFile ) {
-        ErrorF("Reading keymap from the system.\n");
+      //        ErrorF("Reading keymap from the system.\n");
     }
 }
 
@@ -926,7 +832,7 @@ void ddxUseMsg( void )
  */
 void ddxGiveUp( void )
 {
-    ErrorF( "Quitting XDarwin...\n" );
+    ErrorF( "Quitting Xquartz...\n" );
 
     DarwinModeGiveUp();
 }
diff --git a/hw/darwin/darwinEvents.c b/hw/darwin/darwinEvents.c
index 3d7f268..d3abcc5 100644
--- a/hw/darwin/darwinEvents.c
+++ b/hw/darwin/darwinEvents.c
@@ -127,23 +127,19 @@ static void DarwinUpdateModifiers(
     int pressed,        // KeyPress or KeyRelease
     int flags )         // modifier flags that have changed
 {
+    xe->u.u.type = pressed;
+    if (flags & NX_COMMANDMASK) DarwinPressModifierMask(xe, COMMAND_MASK(flags));
+    if (flags & NX_CONTROLMASK) DarwinPressModifierMask(xe, CONTROL_MASK(flags));
+    if (flags & NX_ALTERNATEMASK) DarwinPressModifierMask(xe, ALTERNATE_MASK(flags));
+    if (flags & NX_SHIFTMASK)  DarwinPressModifierMask(xe, SHIFT_MASK(flags));
+    if (flags & NX_SECONDARYFNMASK) DarwinPressModifierMask(xe, NX_SECONDARYFNMASK);
     if (flags & NX_ALPHASHIFTMASK) {
-        DarwinPressModifierMask(pressed, NX_ALPHASHIFTMASK);
-    }
-    if (flags & NX_COMMANDMASK) {
-        DarwinPressModifierMask(pressed, COMMAND_MASK(flags));
-    }
-    if (flags & NX_CONTROLMASK) {
-        DarwinPressModifierMask(pressed, CONTROL_MASK(flags));
-    }
-    if (flags & NX_ALTERNATEMASK) {
-        DarwinPressModifierMask(pressed, ALTERNATE_MASK(flags));
-    }
-    if (flags & NX_SHIFTMASK) {
-        DarwinPressModifierMask(pressed, SHIFT_MASK(flags));
-    }
-    if (flags & NX_SECONDARYFNMASK) {
-        DarwinPressModifierMask(pressed, NX_SECONDARYFNMASK);
+		// Alpha shift only sees KeyDown when enabled and KeyUp when disabled,
+		// but X11 wants to see a up/down pair to enable, and again to disable
+		xe->u.u.type = KeyPress;
+        DarwinPressModifierMask(xe, NX_ALPHASHIFTMASK);
+		xe->u.u.type = KeyRelease;
+        DarwinPressModifierMask(xe, NX_ALPHASHIFTMASK);
     }
 }
 
diff --git a/hw/darwin/iokit/xfIOKit.c b/hw/darwin/iokit/xfIOKit.c
index c7ebd1c..7f126c7 100644
--- a/hw/darwin/iokit/xfIOKit.c
+++ b/hw/darwin/iokit/xfIOKit.c
@@ -63,7 +63,6 @@
 #include <IOKit/IOKitLib.h>
 #include <IOKit/hidsystem/IOHIDShared.h>
 #include <IOKit/graphics/IOGraphicsLib.h>
-#include <drivers/event_status_driver.h>
 
 // Define this to work around bugs in the display drivers for
 // older PowerBook G3's. If the X server starts without this
diff --git a/hw/darwin/iokit/xfIOKitStartup.c b/hw/darwin/iokit/xfIOKitStartup.c
index 07e8c21..413d062 100644
--- a/hw/darwin/iokit/xfIOKitStartup.c
+++ b/hw/darwin/iokit/xfIOKitStartup.c
@@ -29,7 +29,6 @@
  * use or other dealings in this Software without prior written authorization.
  */
 
-
 #if HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
diff --git a/hw/darwin/quartz/XDarwinStartup.c b/hw/darwin/quartz/XDarwinStartup.c
index 8041e32..3ad4898 100644
--- a/hw/darwin/quartz/XDarwinStartup.c
+++ b/hw/darwin/quartz/XDarwinStartup.c
@@ -38,6 +38,9 @@
  * dealings in this Software without prior written authorization from
  * Torrey T. Lyons.
  */
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
 
 #include <unistd.h>
 #include <stdio.h>
diff --git a/hw/darwin/quartz/XServer.m b/hw/darwin/quartz/XServer.m
index 32bfbf5..0587415 100644
--- a/hw/darwin/quartz/XServer.m
+++ b/hw/darwin/quartz/XServer.m
@@ -34,8 +34,6 @@
  * sale, use or other dealings in this Software without prior written
  * authorization.
  */
-/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/XServer.m,v 1.3 2004/07/30 19:12:17 torrey Exp $ */
-/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/XServer.m,v 1.19 2003/11/24 05:39:01 torrey Exp $ */
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
diff --git a/hw/darwin/quartz/applewm.c b/hw/darwin/quartz/applewm.c
index cc11cfa..f064dba 100644
--- a/hw/darwin/quartz/applewm.c
+++ b/hw/darwin/quartz/applewm.c
@@ -1,6 +1,6 @@
 /**************************************************************************
 
-Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved.
+Copyright (c) 2002-2007 Apple Inc. All Rights Reserved.
 Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved.
 
 Permission is hereby granted, free of charge, to any person obtaining a
@@ -445,13 +445,11 @@ ProcAppleWMSetWindowMenu(
                 break;
         }
     }
-
 #ifdef INXQUARTZ
     X11ApplicationSetWindowMenu (nitems, items, shortcuts);
 #else
     QuartzSetWindowMenu (nitems, items, shortcuts);
 #endif
-
     free(items);
     free(shortcuts);
 
@@ -467,7 +465,7 @@ ProcAppleWMSetWindowMenuCheck(
 
     REQUEST_SIZE_MATCH(xAppleWMSetWindowMenuCheckReq);
 #ifdef INXQUARTZ
-    X11ApplicationSetWindowMenuCheck(stuff->index);
+    X11ApplicationSetWindowMenuCheck (stuff->index);
 #else
     QuartzMessageMainThread(kQuartzSetWindowMenuCheck, &stuff->index,
                             sizeof(stuff->index));
@@ -481,6 +479,7 @@ ProcAppleWMSetFrontProcess(
 )
 {
     REQUEST_SIZE_MATCH(xAppleWMSetFrontProcessReq);
+
 #ifdef INXQUARTZ
     X11ApplicationSetFrontProcess();
 #else
@@ -524,13 +523,13 @@ ProcAppleWMSetCanQuit(
     REQUEST(xAppleWMSetCanQuitReq);
 
     REQUEST_SIZE_MATCH(xAppleWMSetCanQuitReq);
+
 #ifdef INXQUARTZ
     X11ApplicationSetCanQuit(stuff->state);
 #else
     QuartzMessageMainThread(kQuartzSetCanQuit, &stuff->state,
                             sizeof(stuff->state));
 #endif
-
     return (client->noClientException);
 }
 
diff --git a/hw/darwin/quartz/cr/crAppleWM.m b/hw/darwin/quartz/cr/crAppleWM.m
index 0741d4e..259c2d8 100644
--- a/hw/darwin/quartz/cr/crAppleWM.m
+++ b/hw/darwin/quartz/cr/crAppleWM.m
@@ -30,8 +30,8 @@
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
-#include "quartz/quartzCommon.h"
-#include "quartz/cr/cr.h"
+#include "quartzCommon.h"
+#include "cr.h"
 
 #undef BOOL
 #define BOOL xBOOL
@@ -39,7 +39,7 @@
 #include "X11/X.h"
 #define _APPLEWM_SERVER_
 #include "X11/extensions/applewm.h"
-#include "quartz/applewmExt.h"
+#include "applewmExt.h"
 #undef BOOL
 
 #define StdDocumentStyleMask (NSTitledWindowMask | \
diff --git a/hw/darwin/quartz/cr/crFrame.m b/hw/darwin/quartz/cr/crFrame.m
index 2b8e57d..5f04ab2 100644
--- a/hw/darwin/quartz/cr/crFrame.m
+++ b/hw/darwin/quartz/cr/crFrame.m
@@ -27,13 +27,13 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
-/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/cr/crFrame.m,v 1.2 2004/04/23 19:15:51 eich Exp $ */
+/* $XdotOrg: xserver/xorg/hw/darwin/quartz/cr/crFrame.m,v 1.3 2004/10/08 00:35:05 torrey Exp $ */
 /* $XFree86: xc/programs/Xserver/hw/darwin/quartz/cr/crFrame.m,v 1.9 2004/03/19 02:05:29 torrey Exp $ */
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
-#include "quartz/quartzCommon.h"
-#include "quartz/cr/cr.h"
+#include "quartzCommon.h"
+#include "cr.h"
 
 #undef BOOL
 #define BOOL xBOOL
diff --git a/hw/darwin/quartz/cr/crScreen.m b/hw/darwin/quartz/cr/crScreen.m
index 9dd130e..c17f294 100644
--- a/hw/darwin/quartz/cr/crScreen.m
+++ b/hw/darwin/quartz/cr/crScreen.m
@@ -32,8 +32,8 @@
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
-#include "quartz/quartzCommon.h"
-#include "quartz/cr/cr.h"
+#include "quartzCommon.h"
+#include "cr.h"
 
 #undef BOOL
 #define BOOL xBOOL
diff --git a/hw/darwin/quartz/fullscreen/fullscreen.c b/hw/darwin/quartz/fullscreen/fullscreen.c
index 02f6e89..5e60ac6 100644
--- a/hw/darwin/quartz/fullscreen/fullscreen.c
+++ b/hw/darwin/quartz/fullscreen/fullscreen.c
@@ -25,10 +25,12 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
+/* $XdotOrg: xserver/xorg/hw/darwin/quartz/fullscreen/fullscreen.c,v 1.4 2005/07/01 22:43:08 daniels Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/fullscreen/fullscreen.c,v 1.3 2003/11/27 01:59:53 torrey Exp $ */
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
-#include "quartz/quartzCommon.h"
+#include "quartzCommon.h"
 #include "darwin.h"
 #include "quartz/quartz.h"
 #include "quartz/quartzCursor.h"
diff --git a/hw/darwin/quartz/fullscreen/quartzCursor.c b/hw/darwin/quartz/fullscreen/quartzCursor.c
index 77fa008..60a4c4d 100644
--- a/hw/darwin/quartz/fullscreen/quartzCursor.c
+++ b/hw/darwin/quartz/fullscreen/quartzCursor.c
@@ -29,11 +29,12 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzCursor.c,v 1.5 2003/01/23 00:34:26 torrey Exp $ */
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
-#include "quartz/quartzCommon.h"
-#include "quartz/quartzCursor.h"
+#include "quartzCommon.h"
+#include "quartzCursor.h"
 #include "darwin.h"
 
 #include <pthread.h>
diff --git a/hw/darwin/quartz/fullscreen/quartzCursor.h b/hw/darwin/quartz/fullscreen/quartzCursor.h
index 57fac68..efcc443 100644
--- a/hw/darwin/quartz/fullscreen/quartzCursor.h
+++ b/hw/darwin/quartz/fullscreen/quartzCursor.h
@@ -29,6 +29,7 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzCursor.h,v 1.1 2002/03/28 02:21:19 torrey Exp $ */
 
 #ifndef QUARTZCURSOR_H
 #define QUARTZCURSOR_H
diff --git a/hw/darwin/quartz/pseudoramiX.c b/hw/darwin/quartz/pseudoramiX.c
index 7ba6d5a..f02867c 100644
--- a/hw/darwin/quartz/pseudoramiX.c
+++ b/hw/darwin/quartz/pseudoramiX.c
@@ -32,6 +32,7 @@ shall not be used in advertising or otherwise to promote the sale, use or other
 dealings in this Software without prior written authorization from Digital
 Equipment Corporation.
 ******************************************************************/
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/pseudoramiX.c,v 1.4 2004/07/02 01:30:33 torrey Exp $ */
 
 #include "pseudoramiX.h"
 #ifdef HAVE_XORG_CONFIG_H
@@ -43,6 +44,9 @@ Equipment Corporation.
 #include <X11/extensions/panoramiXproto.h>
 #include "globals.h"
 
+extern int noPseudoramiXExtension;
+extern int noPanoramiXExtension;
+
 extern int ProcPanoramiXQueryVersion (ClientPtr client);
 
 static void PseudoramiXResetProc(ExtensionEntry *extEntry);
diff --git a/hw/darwin/quartz/pseudoramiX.h b/hw/darwin/quartz/pseudoramiX.h
index df5010d..c294336 100644
--- a/hw/darwin/quartz/pseudoramiX.h
+++ b/hw/darwin/quartz/pseudoramiX.h
@@ -1,6 +1,7 @@
 /*
  * Minimal implementation of PanoramiX/Xinerama
  */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/pseudoramiX.h,v 1.3 2004/07/02 01:30:33 torrey Exp $ */
 
 extern int noPseudoramiXExtension;
 
diff --git a/hw/darwin/quartz/quartz.c b/hw/darwin/quartz/quartz.c
index 038b21e..baeba8f 100644
--- a/hw/darwin/quartz/quartz.c
+++ b/hw/darwin/quartz/quartz.c
@@ -1,3 +1,4 @@
+/* $XdotOrg: xserver/xorg/hw/darwin/quartz/quartz.c,v 1.4 2005/07/01 22:43:07 daniels Exp $ */
 /**************************************************************
  *
  * Quartz-specific support for the Darwin X Server
@@ -29,6 +30,7 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartz.c,v 1.16 2004/07/02 01:30:33 torrey Exp $ */
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
@@ -161,11 +163,10 @@ void DarwinModeInitInput(
     char **argv )
 {
 #ifdef INXQUARTZ
-  X11ApplicationServerReady();
+    X11ApplicationServerReady();
 #else
     QuartzMessageMainThread(kQuartzServerStarted, NULL, 0);
 #endif
-
     // Do final display mode specific initialization before handling events
     if (quartzProcs->InitInput)
         quartzProcs->InitInput(argc, argv);
diff --git a/hw/darwin/quartz/quartz.h b/hw/darwin/quartz/quartz.h
index f1b36b6..c83579c 100644
--- a/hw/darwin/quartz/quartz.h
+++ b/hw/darwin/quartz/quartz.h
@@ -30,6 +30,8 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
+/* $XdotOrg: xserver/xorg/hw/darwin/quartz/quartz.h,v 1.4 2005/07/01 22:43:07 daniels Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartz.h,v 1.7 2003/11/12 20:21:51 torrey Exp $ */
 
 #ifndef _QUARTZ_H
 #define _QUARTZ_H
diff --git a/hw/darwin/quartz/quartzAudio.c b/hw/darwin/quartz/quartzAudio.c
index 16b9c2b..03f9cca 100644
--- a/hw/darwin/quartz/quartzAudio.c
+++ b/hw/darwin/quartz/quartzAudio.c
@@ -35,6 +35,7 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzAudio.c,v 1.1 2002/03/28 02:21:18 torrey Exp $ */
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
diff --git a/hw/darwin/quartz/quartzAudio.h b/hw/darwin/quartz/quartzAudio.h
index c406bbc..e20c21a 100644
--- a/hw/darwin/quartz/quartzAudio.h
+++ b/hw/darwin/quartz/quartzAudio.h
@@ -28,6 +28,7 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
+/* $XFree86: xc/programs/Xserver/hw/darwin/bundle/quartzAudio.h,v 1.2 2001/04/01 20:45:43 tsi Exp $ */
 
 #ifndef _QUARTZAUDIO_H
 #define _QUARTZAUDIO_H
diff --git a/hw/darwin/quartz/quartzCocoa.m b/hw/darwin/quartz/quartzCocoa.m
index c54c18a..a9c89c0 100644
--- a/hw/darwin/quartz/quartzCocoa.m
+++ b/hw/darwin/quartz/quartzCocoa.m
@@ -1,4 +1,4 @@
-/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/quartzCocoa.m,v 1.2 2004/04/23 19:15:17 eich Exp $ */
+/* $XdotOrg: xserver/xorg/hw/darwin/quartz/quartzCocoa.m,v 1.3 2004/07/30 19:12:17 torrey Exp $ */
 /**************************************************************
  *
  * Quartz-specific support for the Darwin X Server
@@ -47,14 +47,16 @@
 
 #include <Cocoa/Cocoa.h>
 
+#ifndef INXQUARTZ
 #import "Preferences.h"
+#endif
 #include "pseudoramiX.h"
 
 extern void FatalError(const char *, ...);
 extern char *display;
 extern int noPanoramiXExtension;
 
-
+#ifndef INXQUARTZ
 /*
  * QuartzReadPreferences
  *  Read the user preferences from the Cocoa front end.
@@ -100,7 +102,7 @@ void QuartzReadPreferences(void)
 
     darwinDesiredDepth = [Preferences depth] - 1;
 }
-
+#endif
 
 /*
  * QuartzWriteCocoaPasteboard
@@ -165,6 +167,7 @@ char *QuartzReadCocoaPasteboard(void)
 int QuartzFSUseQDCursor(
     int depth)  // screen depth
 {
+#ifndef INXQUARTZ
     switch ([Preferences useQDCursor]) {
         case qdCursor_Always:
             return TRUE;
@@ -176,6 +179,7 @@ int QuartzFSUseQDCursor(
             else
                 return FALSE;
     }
+#endif
     return TRUE;
 }
 
diff --git a/hw/darwin/quartz/quartzCommon.h b/hw/darwin/quartz/quartzCommon.h
index f5dff66..2fd79eb 100644
--- a/hw/darwin/quartz/quartzCommon.h
+++ b/hw/darwin/quartz/quartzCommon.h
@@ -1,3 +1,4 @@
+/* $XdotOrg: xserver/xorg/hw/darwin/quartz/quartzCommon.h,v 1.4 2005/07/01 22:43:07 daniels Exp $ */
 /*
  * quartzCommon.h
  *
@@ -31,6 +32,7 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzCommon.h,v 1.15 2004/06/08 22:58:10 torrey Exp $ */
 
 #ifndef _QUARTZCOMMON_H
 #define _QUARTZCOMMON_H
diff --git a/hw/darwin/quartz/quartzCursor.c b/hw/darwin/quartz/quartzCursor.c
index 6ed6a76..dd183db 100644
--- a/hw/darwin/quartz/quartzCursor.c
+++ b/hw/darwin/quartz/quartzCursor.c
@@ -29,6 +29,7 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzCursor.c,v 1.4 2002/11/19 23:01:30 torrey Exp $ */
 
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
diff --git a/hw/darwin/quartz/quartzCursor.h b/hw/darwin/quartz/quartzCursor.h
index 57fac68..e847f8c 100644
--- a/hw/darwin/quartz/quartzCursor.h
+++ b/hw/darwin/quartz/quartzCursor.h
@@ -29,6 +29,7 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
+/* $XFree86: xc/programs/Xserver/hw/darwin/bundle/quartzCursor.h,v 1.2 2001/09/23 04:04:49 torrey Exp $ */
 
 #ifndef QUARTZCURSOR_H
 #define QUARTZCURSOR_H
diff --git a/hw/darwin/quartz/quartzKeyboard.c b/hw/darwin/quartz/quartzKeyboard.c
index bdd5416..80e22aa 100644
--- a/hw/darwin/quartz/quartzKeyboard.c
+++ b/hw/darwin/quartz/quartzKeyboard.c
@@ -31,6 +31,7 @@
    promote the sale, use or other dealings in this Software without
    prior written authorization.
 */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzKeyboard.c,v 1.1 2003/11/01 08:13:08 torrey Exp $ */
 
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
@@ -216,35 +217,44 @@ Bool
 DarwinModeReadSystemKeymap (darwinKeyboardInfo *info)
 {
     KeyboardLayoutRef key_layout;
-    const void *chr_data;
+    const void *chr_data = NULL;
     int num_keycodes = NUM_KEYCODES;
     UInt32 keyboard_type = 0;
     int is_uchr, i, j;
     OSStatus err;
     KeySym *k;
 
-    KLGetCurrentKeyboardLayout (&key_layout);
-    KLGetKeyboardLayoutProperty (key_layout, kKLuchrData, &chr_data);
-
-    if (chr_data != NULL)
-    {
-        is_uchr = 1;
-        keyboard_type = LMGetKbdType ();
-    }
-    else
-    {
-        KLGetKeyboardLayoutProperty (key_layout, kKLKCHRData, &chr_data);
-
-        if (chr_data == NULL)
-        {
-            ErrorF ( "Couldn't get uchr or kchr resource\n");
-            return FALSE;
-        }
-
-        is_uchr = 0;
-        num_keycodes = 128;
-    }    
-
+    TISInputSourceRef currentKeyLayoutRef = TISCopyCurrentKeyboardLayoutInputSource();
+	if (currentKeyLayoutRef)
+	{
+		CFDataRef currentKeyLayoutDataRef = (CFDataRef )TISGetInputSourceProperty(currentKeyLayoutRef, kTISPropertyUnicodeKeyLayoutData);
+		if (currentKeyLayoutDataRef)
+			chr_data = CFDataGetBytePtr(currentKeyLayoutDataRef);
+	}
+	
+	if(chr_data == NULL) {
+		KLGetCurrentKeyboardLayout (&key_layout);
+		KLGetKeyboardLayoutProperty (key_layout, kKLuchrData, &chr_data);
+
+		if (chr_data != NULL)
+		{
+			is_uchr = 1;
+			keyboard_type = LMGetKbdType ();
+		}
+		else
+		{
+			KLGetKeyboardLayoutProperty (key_layout, kKLKCHRData, &chr_data);
+
+			if (chr_data == NULL)
+			{
+				ErrorF ( "Couldn't get uchr or kchr resource\n");
+				return FALSE;
+			}
+
+			is_uchr = 0;
+			num_keycodes = 128;
+		}    
+	}
 
     /* Scan the keycode range for the Unicode character that each
        key produces in the four shift states. Then convert that to
@@ -368,6 +378,7 @@ DarwinModeReadSystemKeymap (darwinKeyboardInfo *info)
             }
         }
     }
+	if(currentKeyLayoutRef)	CFRelease(currentKeyLayoutRef);
 
     return TRUE;
 }
diff --git a/hw/darwin/quartz/quartzPasteboard.c b/hw/darwin/quartz/quartzPasteboard.c
index a3536fc..7ae2e33 100644
--- a/hw/darwin/quartz/quartzPasteboard.c
+++ b/hw/darwin/quartz/quartzPasteboard.c
@@ -29,6 +29,7 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
+/* $XFree86: xc/programs/Xserver/hw/darwin/bundle/quartzPasteboard.c,v 1.3 2001/09/23 04:04:49 torrey Exp $ */
 
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
diff --git a/hw/darwin/quartz/quartzPasteboard.h b/hw/darwin/quartz/quartzPasteboard.h
index afcb6e5..296c52c 100644
--- a/hw/darwin/quartz/quartzPasteboard.h
+++ b/hw/darwin/quartz/quartzPasteboard.h
@@ -29,6 +29,7 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
+/* $XFree86: xc/programs/Xserver/hw/darwin/bundle/quartzPasteboard.h,v 1.1 2001/03/15 22:24:27 torrey Exp $ */
 
 #ifndef _QUARTZPASTEBOARD_H
 #define _QUARTZPASTEBOARD_H
@@ -41,4 +42,4 @@ char * QuartzReadCocoaPasteboard(void);	// caller must free string
 void QuartzWritePasteboard();
 void QuartzWriteCocoaPasteboard(char *text);
 
-#endif	/* _QUARTZPASTEBOARD_H */
+#endif	/* _QUARTZPASTEBOARD_H */
\ No newline at end of file
diff --git a/hw/darwin/quartz/quartzStartup.c b/hw/darwin/quartz/quartzStartup.c
index 76392e4..34176c5 100644
--- a/hw/darwin/quartz/quartzStartup.c
+++ b/hw/darwin/quartz/quartzStartup.c
@@ -28,6 +28,7 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzStartup.c,v 1.8 2003/11/05 00:15:00 torrey Exp $ */
 
 #include <fcntl.h>
 #include <unistd.h>
@@ -38,35 +39,33 @@
 #include "opaque.h"
 #include "micmap.h"
 #include <assert.h>
-
 char **envpGlobal;      // argcGlobal and argvGlobal
                         // are from dix/globals.c
 
-#ifdef INXQUARTZ
-void X11ControllerMain(int argc, char *argv[], void (*server_thread) (void *), void *server_arg);
-# ifdef GLXEXT
-void GlxExtensionInit(void);
-void GlxWrapInitVisuals(miInitVisualsProcPtr *);
-# endif
 
-static void server_thread (void *arg) {
-  extern int main (int argc, char **argv, char **envp);
-  exit (main (argcGlobal, argvGlobal, envpGlobal));
-}
-#else
+#ifndef INXQUARTZ
 int NSApplicationMain(int argc, char *argv[]);
-typedef Bool (*QuartzModeBundleInitPtr)(void);
 
-# ifdef GLXEXT
 // GLX bundle function pointers
-typedef void (*GlxExtensionInitPtr)(void); 
-static GlxExtensionInitPtr GlxExtensionInit = NULL;
-typedef void (*GlxWrapInitVisualsPtr)(miInitVisualsProcPtr *);
-static GlxWrapInitVisualsPtr GlxWrapInitVisuals = NULL;
 void * __DarwinglXMesaProvider = NULL;
 typedef void (*GlxPushProviderPtr)(void *);
 GlxPushProviderPtr GlxPushProvider = NULL;
-# endif
+typedef void (*GlxExtensionInitPtr)(void); 
+typedef void (*GlxWrapInitVisualsPtr)(miInitVisualsProcPtr *);
+typedef Bool (*QuartzModeBundleInitPtr)(void);
+static GlxExtensionInitPtr GlxExtensionInit = NULL;
+static GlxWrapInitVisualsPtr GlxWrapInitVisuals = NULL;
+#else
+void X11ControllerMain(int argc, char *argv[],
+		       void (*server_thread) (void *), void *server_arg);
+void GlxExtensionInit(void);
+void GlxWrapInitVisuals(miInitVisualsProcPtr *procPtr);
+
+static void server_thread (void *arg) {
+  extern int main(int argc, char **argv, char **envp);
+  
+  exit (main (argcGlobal, argvGlobal, envpGlobal));
+}
 #endif
 
 /*
@@ -87,7 +86,7 @@ void DarwinHandleGUI(
     int         fd[2];
 
     if (been_here) {
-#ifdef INXDARWINAPP
+#ifndef INXQUARTZ      
         QuartzReadPreferences();
 #endif
         return;
@@ -124,27 +123,17 @@ void DarwinHandleGUI(
         }
     }
 
-#ifdef INXQUARTZ
-    /* Initially I ran the X server on the main thread, and received
-       events on the second thread. But now we may be using Carbon,
-       that needs to run on the main thread. (Otherwise, when it's
-       prebound, it will initialize itself on the wrong thread)
-       
-       grr.. but doing that means that if the X thread gets scheduled
-       before the main thread when we're _not_ prebound, things fail,
-       so initialize by hand. */
+#ifndef INXQUARTZ
+    main_exit = NSApplicationMain(argc, argv);
+#else
     extern void _InitHLTB(void);
     
     _InitHLTB();
-    
     X11ControllerMain(argc, argv, server_thread, NULL);
-#else
-    main_exit = NSApplicationMain(argc, argv);
 #endif
     exit(main_exit);
 }
 
-#ifndef INXQUARTZ
 /*
  * QuartzLoadDisplayBundle
  *  Try to load the appropriate bundle containing the back end display code.
@@ -152,6 +141,7 @@ void DarwinHandleGUI(
 Bool QuartzLoadDisplayBundle(
     const char *dpyBundleName)
 {
+#ifndef INXQUARTZ
     CFBundleRef mainBundle;
     CFStringRef bundleName;
     CFURLRef    bundleURL;
@@ -198,7 +188,7 @@ Bool QuartzLoadDisplayBundle(
     // Release the CF objects
     CFRelease(bundleName);
     CFRelease(bundleURL);
-
+#endif
     return TRUE;
 }
 
@@ -248,7 +238,7 @@ static void LoadGlxBundle(void)
 
     // Find the GLX init functions
 
-
+#ifndef INXQUARTZ
     __DarwinglXMesaProvider = (void *) CFBundleGetDataPointerForName(
 			       glxBundle, CFSTR("__glXMesaProvider"));
 
@@ -260,7 +250,7 @@ static void LoadGlxBundle(void)
 
     GlxWrapInitVisuals = (void *) CFBundleGetFunctionPointerForName(
                                 glxBundle, CFSTR("GlxWrapInitVisuals"));
-
+#endif
     if (!GlxExtensionInit || !GlxWrapInitVisuals) {
         FatalError("Could not initialize GLX bundle.");
     }
@@ -277,16 +267,16 @@ Bool QuartzLoadDisplayBundle(const char *dpyBundleName)
       return TRUE;
   }
 
-#endif
-
-#ifdef GLXEXT
+/*
+ * DarwinGlxExtensionInit
+ *  Initialize the GLX extension.
+ */
 void DarwinGlxPushProvider(void *impl)
 {
 #ifndef INXQUARTZ
     if (!GlxExtensionInit)
         LoadGlxBundle();
 #endif
-	
     GlxPushProvider(impl);
 }
 
@@ -310,7 +300,7 @@ void DarwinGlxExtensionInit(void)
 void DarwinGlxWrapInitVisuals(
     miInitVisualsProcPtr *procPtr)
 {
-#ifndef INXQUARTZ
+#ifdef INXQUARTZ
     if (!GlxWrapInitVisuals)
         LoadGlxBundle();
 #endif
diff --git a/hw/darwin/quartz/xpr/Xplugin.h b/hw/darwin/quartz/xpr/Xplugin.h
index a10b1b8..ff74e37 100644
--- a/hw/darwin/quartz/xpr/Xplugin.h
+++ b/hw/darwin/quartz/xpr/Xplugin.h
@@ -29,6 +29,7 @@
 
    Note that these interfaces are provided solely for the use of the
    X11 server. Any other uses are unsupported and strongly discouraged. */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/Xplugin.h,v 1.2 2003/05/02 00:08:49 torrey Exp $ */
 
 #ifndef XPLUGIN_H
 #define XPLUGIN_H 1
diff --git a/hw/darwin/quartz/xpr/appledri.c b/hw/darwin/quartz/xpr/appledri.c
index ef68c86..159ee72 100644
--- a/hw/darwin/quartz/xpr/appledri.c
+++ b/hw/darwin/quartz/xpr/appledri.c
@@ -1,3 +1,4 @@
+/* $XFree86: xc/programs/Xserver/GL/dri/xf86dri.c,v 1.10 2000/12/07 20:26:14 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
diff --git a/hw/darwin/quartz/xpr/dri.c b/hw/darwin/quartz/xpr/dri.c
index 08ee382..acc152e 100644
--- a/hw/darwin/quartz/xpr/dri.c
+++ b/hw/darwin/quartz/xpr/dri.c
@@ -1,3 +1,4 @@
+/* $XFree86: xc/programs/Xserver/GL/dri/dri.c,v 1.34 2001/12/10 19:07:19 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
@@ -37,8 +38,17 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include <xorg-config.h>
 #endif
 
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+#ifdef XFree86LOADER
+#include "xf86.h"
+#include "xf86_ansic.h"
+#else
 #include <sys/time.h>
 #include <unistd.h>
+#endif
+#include <dix-config.h>
 
 #define NEED_REPLIES
 #define NEED_EVENTS
@@ -237,7 +247,7 @@ DRIFinishScreenInit(ScreenPtr pScreen)
     pDRIPriv->wrap.ClipNotify = pScreen->ClipNotify;
     pScreen->ClipNotify = DRIClipNotify;
 
-    ErrorF("[DRI] screen %d installation complete\n", pScreen->myNum);
+    //    ErrorF("[DRI] screen %d installation complete\n", pScreen->myNum);
 
     return TRUE;
 }
diff --git a/hw/darwin/quartz/xpr/dri.h b/hw/darwin/quartz/xpr/dri.h
index cf2638a..f826167 100644
--- a/hw/darwin/quartz/xpr/dri.h
+++ b/hw/darwin/quartz/xpr/dri.h
@@ -1,3 +1,4 @@
+/* $XFree86: xc/programs/Xserver/GL/dri/dri.h,v 1.18 2001/03/21 16:21:40 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
diff --git a/hw/darwin/quartz/xpr/dristruct.h b/hw/darwin/quartz/xpr/dristruct.h
index 9a3d01c..0df8f18 100644
--- a/hw/darwin/quartz/xpr/dristruct.h
+++ b/hw/darwin/quartz/xpr/dristruct.h
@@ -1,3 +1,4 @@
+/* $XFree86: xc/programs/Xserver/GL/dri/dristruct.h,v 1.10 2001/03/21 16:21:40 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
diff --git a/hw/darwin/quartz/xpr/x-hash.c b/hw/darwin/quartz/xpr/x-hash.c
index 6bbeacf..0491a5a 100644
--- a/hw/darwin/quartz/xpr/x-hash.c
+++ b/hw/darwin/quartz/xpr/x-hash.c
@@ -1,4 +1,5 @@
 /* x-hash.c - basic hash tables
+   $Id: x-hash.c,v 1.7 2003/07/17 05:25:44 jharper Exp $
 
    Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
 
@@ -26,6 +27,7 @@
    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. */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/x-hash.c,v 1.1 2003/04/30 23:15:42 torrey Exp $ */
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
diff --git a/hw/darwin/quartz/xpr/x-hash.h b/hw/darwin/quartz/xpr/x-hash.h
index 3456dbe..599366e 100644
--- a/hw/darwin/quartz/xpr/x-hash.h
+++ b/hw/darwin/quartz/xpr/x-hash.h
@@ -26,6 +26,7 @@
    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. */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/x-hash.h,v 1.1 2003/04/30 23:15:42 torrey Exp $ */
 
 #ifndef X_HASH_H
 #define X_HASH_H 1
diff --git a/hw/darwin/quartz/xpr/x-hook.c b/hw/darwin/quartz/xpr/x-hook.c
index 42915db..215cb15 100644
--- a/hw/darwin/quartz/xpr/x-hook.c
+++ b/hw/darwin/quartz/xpr/x-hook.c
@@ -26,6 +26,7 @@
    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. */
+/* $XFree86: $ */
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
diff --git a/hw/darwin/quartz/xpr/x-list.c b/hw/darwin/quartz/xpr/x-list.c
index a5f835d..c87045e 100644
--- a/hw/darwin/quartz/xpr/x-list.c
+++ b/hw/darwin/quartz/xpr/x-list.c
@@ -1,4 +1,5 @@
 /* x-list.c
+   $Id: x-list.c,v 1.16 2003/07/18 00:52:19 jharper Exp $
 
    Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
 
@@ -26,6 +27,7 @@
    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. */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/x-list.c,v 1.1 2003/04/30 23:15:42 torrey Exp $ */
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
diff --git a/hw/darwin/quartz/xpr/x-list.h b/hw/darwin/quartz/xpr/x-list.h
index 04af024..2b71070 100644
--- a/hw/darwin/quartz/xpr/x-list.h
+++ b/hw/darwin/quartz/xpr/x-list.h
@@ -1,4 +1,5 @@
 /* x-list.h -- simple list type
+   $Id: x-list.h,v 1.10 2003/07/18 00:52:19 jharper Exp $
 
    Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
 
@@ -26,6 +27,7 @@
    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. */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/x-list.h,v 1.1 2003/04/30 23:15:42 torrey Exp $ */
 
 #ifndef X_LIST_H
 #define X_LIST_H 1
diff --git a/hw/darwin/quartz/xpr/xpr.h b/hw/darwin/quartz/xpr/xpr.h
index 73a88c0..5b02c6d 100644
--- a/hw/darwin/quartz/xpr/xpr.h
+++ b/hw/darwin/quartz/xpr/xpr.h
@@ -26,6 +26,8 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
+/* $XdotOrg: xserver/xorg/hw/darwin/quartz/xpr/xpr.h,v 1.3 2005/07/01 22:43:08 daniels Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/xpr.h,v 1.4 2003/11/12 20:21:52 torrey Exp $ */
 
 #ifndef XPR_H
 #define XPR_H
diff --git a/hw/darwin/quartz/xpr/xprAppleWM.c b/hw/darwin/quartz/xpr/xprAppleWM.c
index fdf404c..c528836 100644
--- a/hw/darwin/quartz/xpr/xprAppleWM.c
+++ b/hw/darwin/quartz/xpr/xprAppleWM.c
@@ -27,6 +27,7 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/xprFrame.c,v 1.2 2003/06/30 01:45:13 torrey Exp $ */
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
diff --git a/hw/darwin/quartz/xpr/xprCursor.c b/hw/darwin/quartz/xpr/xprCursor.c
index e7f23b7..9f9abc2 100644
--- a/hw/darwin/quartz/xpr/xprCursor.c
+++ b/hw/darwin/quartz/xpr/xprCursor.c
@@ -30,6 +30,7 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/xprCursor.c,v 1.1 2003/04/30 23:15:42 torrey Exp $ */
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
diff --git a/hw/darwin/quartz/xpr/xprFrame.c b/hw/darwin/quartz/xpr/xprFrame.c
index b71b2a6..b141e62 100644
--- a/hw/darwin/quartz/xpr/xprFrame.c
+++ b/hw/darwin/quartz/xpr/xprFrame.c
@@ -27,6 +27,8 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
+/* $XdotOrg: xserver/xorg/hw/darwin/quartz/xpr/xprFrame.c,v 1.5 2005/07/01 22:43:08 daniels Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/xprFrame.c,v 1.4 2003/11/12 20:21:52 torrey Exp $ */
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
diff --git a/hw/darwin/quartz/xpr/xprScreen.c b/hw/darwin/quartz/xpr/xprScreen.c
index 67a0737..73fa6f6 100644
--- a/hw/darwin/quartz/xpr/xprScreen.c
+++ b/hw/darwin/quartz/xpr/xprScreen.c
@@ -1,3 +1,4 @@
+/* $XdotOrg: xserver/xorg/hw/darwin/quartz/xpr/xprScreen.c,v 1.6 2005/07/01 22:43:08 daniels Exp $ */
 /*
  * Xplugin rootless implementation screen functions
  */
@@ -27,6 +28,7 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
+/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/xprScreen.c,v 1.11 2004/07/15 18:53:25 torrey Exp $ */
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
@@ -177,15 +179,15 @@ xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height)
 
         frame = displayScreenBounds(dpy);
 
-        ErrorF("PseudoramiX screen %d added: %dx%d @ (%d,%d).\n", i,
+	/*        ErrorF("PseudoramiX screen %d added: %dx%d @ (%d,%d).\n", i,
                (int)frame.size.width, (int)frame.size.height,
-               (int)frame.origin.x, (int)frame.origin.y);
+               (int)frame.origin.x, (int)frame.origin.y); */
 
         frame.origin.x -= unionRect.origin.x;
         frame.origin.y -= unionRect.origin.y;
 
-        ErrorF("PseudoramiX screen %d placed at X11 coordinate (%d,%d).\n",
-               i, (int)frame.origin.x, (int)frame.origin.y);
+	/*        ErrorF("PseudoramiX screen %d placed at X11 coordinate (%d,%d).\n",
+		  i, (int)frame.origin.x, (int)frame.origin.y); */
 
         PseudoramiXAddScreen(frame.origin.x, frame.origin.y,
                              frame.size.width, frame.size.height);
@@ -203,7 +205,7 @@ xprDisplayInit(void)
 {
     CGDisplayCount displayCount;
 
-    ErrorF("Display mode: Rootless Quartz -- Xplugin implementation\n");
+    //    ErrorF("Display mode: Rootless Quartz -- Xplugin implementation\n");
 
     CGGetActiveDisplayList(0, NULL, &displayCount);
 
diff --git a/hw/darwin/utils/dumpkeymap.c b/hw/darwin/utils/dumpkeymap.c
index d2eeca5..c3e66e3 100644
--- a/hw/darwin/utils/dumpkeymap.c
+++ b/hw/darwin/utils/dumpkeymap.c
@@ -1,3 +1,4 @@
+// $XFree86: dumpkeymap.c,v 1.3 2000/12/05 21:18:34 dawes Exp $
 //=============================================================================
 //
 // Copyright (C) 1999,2000 by Eric Sunshine <sunshine at sunshineco.com>
@@ -143,7 +144,7 @@
 #include <string.h>
 #include <sys/stat.h>
 #if !defined(DUMPKEYMAP_FILE_ONLY)
-#include <drivers/event_status_driver.h>
+#include "event_status_driver.h"
 #endif
 
 #define PROG_NAME "dumpkeymap"
commit e3f9867e86dc37ee02944e8c5fc64ff222fa2f06
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Fri Oct 26 15:40:35 2007 -0700

    added missing file from Apple version of 7.2

diff --git a/hw/darwin/apple/English.lproj/Localizable.strings b/hw/darwin/apple/English.lproj/Localizable.strings
new file mode 100644
index 0000000..c83b085
Binary files /dev/null and b/hw/darwin/apple/English.lproj/Localizable.strings differ
diff --git a/hw/darwin/apple/Info.plist b/hw/darwin/apple/Info.plist
index ae47e95..66f1f6b 100644
--- a/hw/darwin/apple/Info.plist
+++ b/hw/darwin/apple/Info.plist
@@ -4,42 +4,6 @@
 <dict>
 	<key>CFBundleDevelopmentRegion</key>
 	<string>English</string>
-	<key>CFBundleDocumentTypes</key>
-	<array>
-		<dict>
-			<key>CFBundleTypeExtensions</key>
-			<array>
-				<string>x11app</string>
-			</array>
-			<key>CFBundleTypeIconFile</key>
-			<string>X11.icns</string>
-			<key>CFBundleTypeName</key>
-			<string>X11 Application</string>
-			<key>CFBundleTypeOSTypes</key>
-			<array>
-				<string>****</string>
-			</array>
-			<key>CFBundleTypeRole</key>
-			<string>Viewer</string>
-			<key>LSIsAppleDefaultForType</key>
-			<true/>
-		</dict>
-		<dict>
-			<key>CFBundleTypeExtensions</key>
-			<array>
-				<string>tool</string>
-				<string>*</string>
-			</array>
-			<key>CFBundleTypeName</key>
-			<string>UNIX Application</string>
-			<key>CFBundleTypeOSTypes</key>
-			<array>
-				<string>****</string>
-			</array>
-			<key>CFBundleTypeRole</key>
-			<string>Viewer</string>
-		</dict>
-	</array>
 	<key>CFBundleExecutable</key>
 	<string>X11</string>
 	<key>CFBundleGetInfoString</key>
@@ -57,7 +21,7 @@
 	<key>CFBundleShortVersionString</key>
 	<string>2.0</string>
 	<key>CFBundleSignature</key>
-	<string>????</string>
+	<string>x11a</string>
 	<key>CSResourcesFileMapped</key>
 	<true/>
 	<key>NSHumanReadableCopyright</key>
diff --git a/hw/darwin/apple/X11.xcodeproj/project.pbxproj b/hw/darwin/apple/X11.xcodeproj/project.pbxproj
index 2fef99b..a47e4d1 100644
--- a/hw/darwin/apple/X11.xcodeproj/project.pbxproj
+++ b/hw/darwin/apple/X11.xcodeproj/project.pbxproj
@@ -14,6 +14,7 @@
 		527F241F0B5D938C007840A7 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50F4F0A7039D6ACA0E82C0CB /* CoreFoundation.framework */; };
 		527F24200B5D938C007840A7 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 570C5748047186C400ACF82F /* SystemConfiguration.framework */; };
 		527F24370B5D9D89007840A7 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 527F24260B5D938C007840A7 /* Info.plist */; };
+		52D9C0ED0BCDDF6B00CD2AFC /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 52D9C0EB0BCDDF6B00CD2AFC /* Localizable.strings */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
@@ -24,6 +25,7 @@
 		50F4F0A7039D6ACA0E82C0CB /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = "<absolute>"; };
 		527F24260B5D938C007840A7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = Info.plist; sourceTree = "<group>"; };
 		527F24270B5D938C007840A7 /* X11.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = X11.app; sourceTree = BUILT_PRODUCTS_DIR; };
+		52D9C0EC0BCDDF6B00CD2AFC /* English */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/Localizable.strings; sourceTree = "<group>"; };
 		570C5748047186C400ACF82F /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = /System/Library/Frameworks/SystemConfiguration.framework; sourceTree = "<absolute>"; };
 /* End PBXFileReference section */
 
@@ -71,6 +73,7 @@
 		20286C2CFDCF999611CA2CEA /* Resources */ = {
 			isa = PBXGroup;
 			children = (
+				52D9C0EB0BCDDF6B00CD2AFC /* Localizable.strings */,
 				50459C5F038587C60ECA21EC /* X11.icns */,
 				0867D6AAFE840B52C02AAC07 /* InfoPlist.strings */,
 				02345980000FD03B11CA0E72 /* main.nib */,
@@ -146,6 +149,7 @@
 				527F24190B5D938C007840A7 /* InfoPlist.strings in Resources */,
 				527F241A0B5D938C007840A7 /* main.nib in Resources */,
 				527F241B0B5D938C007840A7 /* X11.icns in Resources */,
+				52D9C0ED0BCDDF6B00CD2AFC /* Localizable.strings in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -189,6 +193,14 @@
 			name = InfoPlist.strings;
 			sourceTree = "<group>";
 		};
+		52D9C0EB0BCDDF6B00CD2AFC /* Localizable.strings */ = {
+			isa = PBXVariantGroup;
+			children = (
+				52D9C0EC0BCDDF6B00CD2AFC /* English */,
+			);
+			name = Localizable.strings;
+			sourceTree = "<group>";
+		};
 /* End PBXVariantGroup section */
 
 /* Begin XCBuildConfiguration section */
@@ -224,12 +236,16 @@
 				DSTROOT = "$(DSTROOT)";
 				FRAMEWORK_SEARCH_PATHS = "";
 				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
-				HEADER_SEARCH_PATHS = "";
+				HEADER_SEARCH_PATHS = /usr/X11/include;
 				INFOPLIST_FILE = Info.plist;
 				INSTALL_PATH = $DSTROOT/Applications/Utilties;
-				LIBRARY_SEARCH_PATHS = "";
-				OTHER_CFLAGS = "$(CFLAGS)";
-				OTHER_LDFLAGS = "$(LDFLAGS)";
+				LIBRARY_SEARCH_PATHS = /usr/X11/lib;
+				OTHER_CFLAGS = "";
+				OTHER_LDFLAGS = (
+					"-lXau",
+					"-lxcb",
+					"-lX11",
+				);
 				OTHER_REZFLAGS = "";
 				PRODUCT_NAME = X11;
 				SECTORDER_FLAGS = "";
@@ -249,12 +265,16 @@
 				DSTROOT = "$(DSTROOT)";
 				FRAMEWORK_SEARCH_PATHS = "";
 				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
-				HEADER_SEARCH_PATHS = "";
+				HEADER_SEARCH_PATHS = /usr/X11/include;
 				INFOPLIST_FILE = Info.plist;
 				INSTALL_PATH = $DSTROOT/Applications/Utilties;
-				LIBRARY_SEARCH_PATHS = "";
-				OTHER_CFLAGS = "$(CFLAGS)";
-				OTHER_LDFLAGS = "$(LDFLAGS)";
+				LIBRARY_SEARCH_PATHS = /usr/X11/lib;
+				OTHER_CFLAGS = "";
+				OTHER_LDFLAGS = (
+					"-lXau",
+					"-lxcb",
+					"-lX11",
+				);
 				OTHER_REZFLAGS = "";
 				PRODUCT_NAME = X11;
 				SECTORDER_FLAGS = "";
@@ -273,12 +293,16 @@
 				DSTROOT = "$(DSTROOT)";
 				FRAMEWORK_SEARCH_PATHS = "";
 				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
-				HEADER_SEARCH_PATHS = "";
+				HEADER_SEARCH_PATHS = /usr/X11/include;
 				INFOPLIST_FILE = Info.plist;
 				INSTALL_PATH = $DSTROOT/Applications/Utilties;
-				LIBRARY_SEARCH_PATHS = "";
-				OTHER_CFLAGS = "$(CFLAGS)";
-				OTHER_LDFLAGS = "$(LDFLAGS)";
+				LIBRARY_SEARCH_PATHS = /usr/X11/lib;
+				OTHER_CFLAGS = "";
+				OTHER_LDFLAGS = (
+					"-lXau",
+					"-lxcb",
+					"-lX11",
+				);
 				OTHER_REZFLAGS = "";
 				PRODUCT_NAME = X11;
 				SECTORDER_FLAGS = "";
diff --git a/hw/darwin/apple/X11Application.h b/hw/darwin/apple/X11Application.h
index 6b1d726..fb153e7 100644
--- a/hw/darwin/apple/X11Application.h
+++ b/hw/darwin/apple/X11Application.h
@@ -1,4 +1,5 @@
 /* X11Application.h -- subclass of NSApplication to multiplex events
+   $Id: X11Application.h,v 1.26 2003/08/08 19:16:13 jharper Exp $
 
    Copyright (c) 2002-2007 Apple Inc. All rights reserved.
 
@@ -79,7 +80,7 @@ extern void X11ApplicationMain (int argc, const char *argv[],
 extern int X11EnableKeyEquivalents;
 extern int quartzHasRoot, quartzEnableRootless;
 
-#define APP_PREFS "com.apple.x11"
+#define APP_PREFS "org.x.X11"
 
 #define PREFS_APPSMENU		"apps_menu"
 #define PREFS_FAKEBUTTONS	"enable_fake_buttons"
diff --git a/hw/darwin/apple/X11Application.m b/hw/darwin/apple/X11Application.m
index 57795f4..9ae470e 100644
--- a/hw/darwin/apple/X11Application.m
+++ b/hw/darwin/apple/X11Application.m
@@ -1,6 +1,6 @@
 /* X11Application.m -- subclass of NSApplication to multiplex events
  
- Copyright (c) 2002-2007 Apple Inc.
+ Copyright (c) 2002-2007 Apple Inc. All rights reserved.
  
  Permission is hereby granted, free of charge, to any person
  obtaining a copy of this software and associated documentation files
@@ -34,10 +34,12 @@
 
 /* ouch! */
 #define BOOL X_BOOL
+//# include "Xproto.h"
 # include "darwin.h"
 # include "../quartz/quartz.h"
 # define _APPLEWM_SERVER_
 # include "X11/extensions/applewm.h"
+//# include "X.h"
 # include "micmap.h"
 #undef BOOL
 
@@ -47,20 +49,18 @@
 #include <unistd.h>
 #include <pthread.h>
 
-#define DEFAULTS_FILE "/etc/X11/xserver/Xquartz.plist"
+#define DEFAULTS_FILE "/usr/X11/lib/X11/xserver/Xquartz.plist"
 
 int X11EnableKeyEquivalents = TRUE;
 int quartzHasRoot = FALSE, quartzEnableRootless = TRUE;
 
-extern int darwinFakeButtons, input_check_flag;
-// extern Bool enable_stereo; 
-Bool enable_stereo;  //<-- this needs to go back to being an extern once glxCGL is fixed
-
-extern xEvent *darwinEvents;
+extern int darwinFakeButtons;
+extern Bool enable_stereo; 
 
 X11Application *X11App;
 
-#define ALL_KEY_MASKS (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask)
+#define ALL_KEY_MASKS (NSShiftKeyMask | NSControlKeyMask \
+| NSAlternateKeyMask | NSCommandKeyMask)
 
 @implementation X11Application
 
@@ -79,21 +79,27 @@ static void send_nsevent (NSEventType type, NSEvent *e);
  but is statically linked into this X server. */
 extern Bool QuartzModeBundleInit(void);
 
-static void init_ports (void) {
+static void
+init_ports (void)
+{
     kern_return_t r;
     NSPort *p;
 	
-    if (_port != MACH_PORT_NULL) return;
+    if (_port != MACH_PORT_NULL)
+		return;
 	
     r = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, &_port);
-    if (r != KERN_SUCCESS) return;
+    if (r != KERN_SUCCESS)
+		return;
 	
     p = [NSMachPort portWithMachPort:_port];
     [p setDelegate:NSApp];
     [p scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
 }
 
-static void message_kit_thread (SEL selector, NSObject *arg) {
+static void
+message_kit_thread (SEL selector, NSObject *arg)
+{
     message msg;
     kern_return_t r;
 	
@@ -108,24 +114,29 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
     msg.arg = [arg retain];
 	
     r = mach_msg (&msg.hdr, MACH_SEND_MSG, msg.hdr.msgh_size,
-		  0, MACH_PORT_NULL, 0, MACH_PORT_NULL);
+				  0, MACH_PORT_NULL, 0, MACH_PORT_NULL);
     if (r != KERN_SUCCESS)
-		ErrorF("%s: mach_msg failed: %x\n", __FUNCTION__, r);
+		fprintf (stderr, "%s: mach_msg failed: %x\n", __FUNCTION__, r);
 }
 
-- (void) handleMachMessage:(void *)_msg {
+- (void) handleMachMessage:(void *)_msg
+{
     message *msg = _msg;
 	
     [self performSelector:msg->selector withObject:msg->arg];
     [msg->arg release];
 }
 
-- (void) set_controller:obj {
-    if (_controller == nil) _controller = [obj retain];
+- (void) set_controller:obj
+{
+    if (_controller == nil)
+		_controller = [obj retain];
 }
 
-- (void) dealloc {
-    if (_controller != nil) [_controller release];
+- (void) dealloc
+{
+    if (_controller != nil)
+		[_controller release];
 	
     if (_port != MACH_PORT_NULL)
 		mach_port_deallocate (mach_task_self (), _port);
@@ -133,7 +144,8 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
     [super dealloc];
 }
 
-- (void) orderFrontStandardAboutPanel: (id) sender {
+- (void) orderFrontStandardAboutPanel: (id) sender
+{
     NSMutableDictionary *dict;
     NSDictionary *infoDict;
     NSString *tem;
@@ -146,45 +158,57 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
 	
     tem = [infoDict objectForKey:@"CFBundleShortVersionString"];
 	
-    [dict setObject:[NSString stringWithFormat:@"X11.app %@ - X.org X11R7.3", tem] 
-	  forKey:@"ApplicationVersion"];
+    [dict setObject:[NSString stringWithFormat:@"X11.app %@ - X.org X11R7.2",
+					 tem] forKey:@"ApplicationVersion"];
 	
     [self orderFrontStandardAboutPanelWithOptions: dict];
 }
 
-- (void) activateX:(BOOL)state {
+- (void) activateX:(BOOL)state
+{
     /* Create a TSM document that supports full Unicode input, and
 	 have it activated while X is active (unless using the old
 	 keymapping files) */
     static TSMDocumentID x11_document;
 	
-    if (state) {
-      QuartzMessageServerThread (kXDarwinActivate, 0);
-      
-      if (!_x_active) {
-	if (x11_document == 0 && darwinKeymapFile == NULL) {
-	  OSType types[1];
-	  types[0] = kUnicodeDocument;
-	  NewTSMDocument (1, types, &x11_document, 0);
-	}
-	
-	if (x11_document != 0)	ActivateTSMDocument (x11_document);
-      }
-    } else {
-      QuartzMessageServerThread (kXDarwinDeactivate, 0);
-      
-      if (_x_active && x11_document != 0)
-	DeactivateTSMDocument (x11_document);
+    if (state)
+    {
+		QuartzMessageServerThread (kXDarwinActivate, 0);
+		
+		if (!_x_active)
+		{
+			if (x11_document == 0 && darwinKeymapFile == NULL)
+			{
+				OSType types[1];
+				types[0] = kUnicodeDocument;
+				NewTSMDocument (1, types, &x11_document, 0);
+			}
+			
+			if (x11_document != 0)
+				ActivateTSMDocument (x11_document);
+		}
     }
-    
+    else
+    {
+		QuartzMessageServerThread (kXDarwinDeactivate, 0);
+		
+		if (_x_active)
+		{
+			if (x11_document != 0)
+				DeactivateTSMDocument (x11_document);
+		}
+    }
+	
     _x_active = state;
 }
 
-- (void) became_key:(NSWindow *)win {
+- (void) became_key:(NSWindow *)win
+{
     [self activateX:NO];
 }
 
-- (void) sendEvent:(NSEvent *)e {
+- (void) sendEvent:(NSEvent *)e
+{
     NSEventType type;
     BOOL for_appkit, for_x;
 	
@@ -194,140 +218,172 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
     for_appkit = YES;
     for_x = YES;
 	
-    switch (type) {
+    switch (type)
+    {
     case NSLeftMouseDown: case NSRightMouseDown: case NSOtherMouseDown:
     case NSLeftMouseUp: case NSRightMouseUp: case NSOtherMouseUp:
-      if ([e window] != nil) {
-	/* Pointer event has a window. Probably something for the kit. */
-	
-	for_x = NO;
-	
-	if (_x_active) [self activateX:NO];
-      } else if ([self modalWindow] == nil) {
-	/* Must be an X window. Tell appkit it doesn't have focus. */
+		if ([e window] != nil)
+		{
+			/* Pointer event has a window. Probably something for the kit. */
 			
-	for_appkit = NO;
-	
-	if ([self isActive]) {
-	  [self deactivate];
-	  
-	  if (!_x_active && quartzProcs->IsX11Window([e window], [e windowNumber]))
-	    [self activateX:YES];
-	}
-      }
-      break;
-      
+			for_x = NO;
+			
+			if (_x_active)
+				[self activateX:NO];
+		}
+		else if ([self modalWindow] == nil)
+		{
+			/* Must be an X window. Tell appkit it doesn't have focus. */
+			
+			for_appkit = NO;
+			
+			if ([self isActive])
+			{
+				[self deactivate];
+				
+				if (!_x_active && quartzProcs->IsX11Window([e window],
+														   [e windowNumber]))
+				[self activateX:YES];
+			}
+		}
+		break;
+		
     case NSKeyDown: case NSKeyUp:
-      if (_x_active) {
-	static int swallow_up;
-	
-	/* No kit window is focused, so send it to X. */
-	
-	for_appkit = NO;
-	
-	if (type == NSKeyDown) {
-	  /* Before that though, see if there are any global
-	     shortcuts bound to it. */
-	  
-	  if (X11EnableKeyEquivalents
-	      && [[self mainMenu] performKeyEquivalent:e]) {
-	    swallow_up = [e keyCode];
-	    for_x = NO;
-	  } else if (!quartzEnableRootless
-		   && ([e modifierFlags] & ALL_KEY_MASKS)
-		   == (NSCommandKeyMask | NSAlternateKeyMask)
-		   && ([e keyCode] == 0 /*a*/
-		       || [e keyCode] == 53 /*Esc*/)) {
-	    swallow_up = 0;
-	    for_x = NO;
+		if (_x_active)
+		{
+			static int swallow_up;
+			
+			/* No kit window is focused, so send it to X. */
+			
+			for_appkit = NO;
+			
+			if (type == NSKeyDown)
+			{
+				/* Before that though, see if there are any global
+				 shortcuts bound to it. */
+				
+				if (X11EnableKeyEquivalents
+					&& [[self mainMenu] performKeyEquivalent:e])
+				{
+					swallow_up = [e keyCode];
+					for_x = NO;
+				}
+				else if (!quartzEnableRootless
+						 && ([e modifierFlags] & ALL_KEY_MASKS)
+						 == (NSCommandKeyMask | NSAlternateKeyMask)
+						 && ([e keyCode] == 0 /*a*/
+							 || [e keyCode] == 53 /*Esc*/))
+				{
+					swallow_up = 0;
+					for_x = NO;
 #ifdef DARWIN_DDX_MISSING
-	    QuartzMessageServerThread (kXDarwinToggleFullscreen, 0);
+					QuartzMessageServerThread (kXDarwinToggleFullscreen, 0);
 #endif
-	  }
-	} else {
-	  /* If we saw a key equivalent on the down, don't pass
-	     the up through to X. */
-	  
-	  if (swallow_up != 0 && [e keyCode] == swallow_up) {
-	    swallow_up = 0;
-	    for_x = NO;
-	  }
-	}
-      }
-      else for_x = NO;
-      break;
+				}
+			}
+			else
+			{
+				/* If we saw a key equivalent on the down, don't pass
+				 the up through to X. */
+				
+				if (swallow_up != 0 && [e keyCode] == swallow_up)
+				{
+					swallow_up = 0;
+					for_x = NO;
+				}
+			}
+		}
+		else
+		{
+			for_x = NO;
+		}
+		break;
 		
     case NSFlagsChanged:
-      /* For the l33t X users who remap modifier keys to normal keysyms. */
-      if (!_x_active)
-	for_x = NO;
-      break;
+		/* For the l33t X users who remap modifier keys to normal keysyms. */
+		if (!_x_active)
+			for_x = NO;
+		break;
 		
     case NSAppKitDefined:
-      switch ([e subtype]) {
-      case NSApplicationActivatedEventType:
-	for_x = NO;
-	if ([self modalWindow] == nil) {
-	  for_appkit = NO;
-	  
-	  /* FIXME: hack to avoid having to pass the event to appkit,
-	     which would cause it to raise one of its windows. */
-	  _appFlags._active = YES;
-	  
-	  [self activateX:YES];
-#ifdef DARWIN_DDX_MISSING
-	  if ([e data2] & 0x10) QuartzMessageServerThread (kXDarwinBringAllToFront, 0);
-#endif
-	}
-	break;
+		switch ([e subtype])
+		{
+		case NSApplicationActivatedEventType:
+			for_x = NO;
+			if ([self modalWindow] == nil)
+			{
+				for_appkit = NO;
+				
+				/* FIXME: hack to avoid having to pass the event to appkit,
+				 which would cause it to raise one of its windows. */
+				_appFlags._active = YES;
+				
+				[self activateX:YES];
+				if ([e data2] & 0x10) X11ApplicationSetFrontProcess();
+			}
+			break;
 			
-      case 18: /* ApplicationDidReactivate */
-	if (quartzHasRoot) for_appkit = NO;
-	break;
+		case 18: /* ApplicationDidReactivate */
+			if (quartzHasRoot)
+				for_appkit = NO;
+			break;
 			
-      case NSApplicationDeactivatedEventType:
-	for_x = NO;
-	[self activateX:NO];
-	break;
-      }
-      break;
-      
+		case NSApplicationDeactivatedEventType:
+			for_x = NO;
+			[self activateX:NO];
+			break;
+		}
+		break;
+		
     default: break; /* for gcc */
     }
 	
-    if (for_appkit) [super sendEvent:e];
-    if (for_x) send_nsevent (type, e);
+    if (for_appkit)
+		[super sendEvent:e];
+	
+    if (for_x)
+		send_nsevent (type, e);
 }
 
-- (void) set_window_menu:(NSArray *)list {
+- (void) set_window_menu:(NSArray *)list
+{
     [_controller set_window_menu:list];
 }
 
-- (void) set_window_menu_check:(NSNumber *)n {
+- (void) set_window_menu_check:(NSNumber *)n
+{
     [_controller set_window_menu_check:n];
 }
 
-- (void) set_apps_menu:(NSArray *)list {
+- (void) set_apps_menu:(NSArray *)list
+{
     [_controller set_apps_menu:list];
 }
 
-- (void) set_front_process:unused {
+- (void) set_front_process:unused
+{
     [NSApp activateIgnoringOtherApps:YES];
 	
-    if ([self modalWindow] == nil) [self activateX:YES];
+    if ([self modalWindow] == nil)
+		[self activateX:YES];
 }
 
-- (void) set_can_quit:(NSNumber *)state {
+- (void) set_can_quit:(NSNumber *)state
+{
     [_controller set_can_quit:[state boolValue]];
 }
 
-- (void) server_ready:unused {
+- (void) server_ready:unused
+{
     [_controller server_ready];
 }
 
-- (void) show_hide_menubar:(NSNumber *)state {
-    if ([state boolValue]) ShowMenuBar ();
-    else HideMenuBar ();
+- (void) show_hide_menubar:(NSNumber *)state
+{
+    if ([state boolValue])
+		ShowMenuBar ();
+    else
+		HideMenuBar ();
 }
 
 
@@ -344,7 +400,9 @@ static void cfrelease (CFAllocatorRef a, const void *b) {
     CFRelease (b);
 }
 
-static CFMutableArrayRef nsarray_to_cfarray (NSArray *in) {
+static CFMutableArrayRef
+nsarray_to_cfarray (NSArray *in)
+{
     CFMutableArrayRef out;
     CFArrayCallBacks cb;
     NSObject *ns;
@@ -359,22 +417,24 @@ static CFMutableArrayRef nsarray_to_cfarray (NSArray *in) {
     count = [in count];
     out = CFArrayCreateMutable (NULL, count, &cb);
 	
-    for (i = 0; i < count; i++) {
-      ns = [in objectAtIndex:i];
-      
-      if ([ns isKindOfClass:[NSArray class]])
-	cf = (CFTypeRef) nsarray_to_cfarray ((NSArray *) ns);
-      else
-	cf = CFRetain ((CFTypeRef) ns);
-      
-      CFArrayAppendValue (out, cf);
-      CFRelease (cf);
+    for (i = 0; i < count; i++)
+    {
+		ns = [in objectAtIndex:i];
+		
+		if ([ns isKindOfClass:[NSArray class]])
+			cf = (CFTypeRef) nsarray_to_cfarray ((NSArray *) ns);
+		else
+			cf = CFRetain ((CFTypeRef) ns);
+		
+		CFArrayAppendValue (out, cf);
+		CFRelease (cf);
     }
-    
+	
     return out;
 }
-
-static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
+static NSMutableArray *
+cfarray_to_nsarray (CFArrayRef in)
+{
     NSMutableArray *out;
     const CFTypeRef *cf;
     NSObject *ns;
@@ -383,277 +443,320 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
     count = CFArrayGetCount (in);
     out = [[NSMutableArray alloc] initWithCapacity:count];
 	
-    for (i = 0; i < count; i++) {
-      cf = CFArrayGetValueAtIndex (in, i);
+    for (i = 0; i < count; i++)
+    {
+		cf = CFArrayGetValueAtIndex (in, i);
+		
+		if (CFGetTypeID (cf) == CFArrayGetTypeID ())
+			ns = cfarray_to_nsarray ((CFArrayRef) cf);
+		else
+			ns = [(id)cf retain];
 		
-      if (CFGetTypeID (cf) == CFArrayGetTypeID ())
-	ns = cfarray_to_nsarray ((CFArrayRef) cf);
-      else
-	ns = [(id)cf retain];
-      
-      [out addObject:ns];
-      [ns release];
+		[out addObject:ns];
+		[ns release];
     }
-    
+	
     return out;
 }
 
-- (CFPropertyListRef) prefs_get:(NSString *)key {
+- (CFPropertyListRef) prefs_get:(NSString *)key
+{
     CFPropertyListRef value;
 	
     value = CFPreferencesCopyAppValue ((CFStringRef) key, CFSTR (APP_PREFS));
 	
-    if (value == NULL) {
-      static CFDictionaryRef defaults;
-      
-      if (defaults == NULL) {
-	CFStringRef error = NULL;
-	CFDataRef data;
-	CFURLRef url;
-	SInt32 error_code;
-	
-	url = (CFURLCreateFromFileSystemRepresentation
-	       (NULL, (unsigned char *)DEFAULTS_FILE, strlen (DEFAULTS_FILE), false));
-	if (CFURLCreateDataAndPropertiesFromResource (NULL, url, &data,
-						      NULL, NULL, &error_code)) {
-	  defaults = (CFPropertyListCreateFromXMLData
-		      (NULL, data, kCFPropertyListMutableContainersAndLeaves, &error));
-	  if (error != NULL) CFRelease (error);
-	  CFRelease (data);
-	}
-	CFRelease (url);
+    if (value == NULL)
+    {
+		static CFDictionaryRef defaults;
+		
+		if (defaults == NULL)
+		{
+			CFStringRef error = NULL;
+			CFDataRef data;
+			CFURLRef url;
+			SInt32 error_code;
 			
-	if (defaults != NULL) {
-	  NSMutableArray *apps, *elt;
-	  int count, i;
-	  NSString *name, *nname;
-	  
-	  /* Localize the names in the default apps menu. */
-	  
-	  apps = [(NSDictionary *)defaults objectForKey:@PREFS_APPSMENU];
-	  if (apps != nil) {
-	    count = [apps count];
-	    for (i = 0; i < count; i++)	{
-	      elt = [apps objectAtIndex:i];
-	      if (elt != nil && [elt isKindOfClass:[NSArray class]]) {
-		name = [elt objectAtIndex:0];
-		if (name != nil) {
-		  nname = NSLocalizedString (name, nil);
-		  if (nname != nil && nname != name)
-		    [elt replaceObjectAtIndex:0 withObject:nname];
+			url = (CFURLCreateFromFileSystemRepresentation
+				   (NULL, (unsigned char *)DEFAULTS_FILE, strlen (DEFAULTS_FILE), false));
+			if (CFURLCreateDataAndPropertiesFromResource (NULL, url, &data,
+														  NULL, NULL,
+														  &error_code))
+			{
+				defaults = (CFPropertyListCreateFromXMLData
+							(NULL, data, kCFPropertyListMutableContainersAndLeaves, &error));
+				if (error != NULL)
+					CFRelease (error);
+				CFRelease (data);
+			}
+			CFRelease (url);
+			
+			if (defaults != NULL)
+			{
+				NSMutableArray *apps, *elt;
+				int count, i;
+				NSString *name, *nname;
+				
+				/* Localize the names in the default apps menu. */
+				
+				apps = [(NSDictionary *)defaults objectForKey:@PREFS_APPSMENU];
+				if (apps != nil)
+				{
+					count = [apps count];
+					for (i = 0; i < count; i++)
+					{
+						elt = [apps objectAtIndex:i];
+						if (elt != nil && [elt isKindOfClass:[NSArray class]])
+						{
+							name = [elt objectAtIndex:0];
+							if (name != nil)
+							{
+								nname = NSLocalizedString (name, nil);
+								if (nname != nil && nname != name)
+									[elt replaceObjectAtIndex:0 withObject:nname];
+							}
+						}
+					}
+				}
+			}
 		}
-	      }
-	    }
-	  }
-	}
-      }
 		
-      if (defaults != NULL) value = CFDictionaryGetValue (defaults, key);
-      if (value != NULL) CFRetain (value);
+		if (defaults != NULL)
+			value = CFDictionaryGetValue (defaults, key);
+		
+		if (value != NULL)
+			CFRetain (value);
     }
 	
     return value;
 }
 
-- (int) prefs_get_integer:(NSString *)key default:(int)def {
-  CFPropertyListRef value;
-  int ret;
-  
-  value = [self prefs_get:key];
-  
-  if (value != NULL && CFGetTypeID (value) == CFNumberGetTypeID ())
-    CFNumberGetValue (value, kCFNumberIntType, &ret);
-  else if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ())
-    ret = CFStringGetIntValue (value);
-  else
-    ret = def;
-  
-  if (value != NULL) CFRelease (value);
-  
-  return ret;
-}
-
-- (const char *) prefs_get_string:(NSString *)key default:(const char *)def {
-  CFPropertyListRef value;
-  const char *ret = NULL;
-  
-  value = [self prefs_get:key];
-  
-  if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ()) {
-    NSString *s = (NSString *) value;
-    
-    ret = [s UTF8String];
-  }
-  
-  if (value != NULL) CFRelease (value);
-  
-  return ret != NULL ? ret : def;
-}
-
-- (float) prefs_get_float:(NSString *)key default:(float)def {
-  CFPropertyListRef value;
-  float ret = def;
-  
-  value = [self prefs_get:key];
-  
-  if (value != NULL
-      && CFGetTypeID (value) == CFNumberGetTypeID ()
-      && CFNumberIsFloatType (value)) 
-    CFNumberGetValue (value, kCFNumberFloatType, &ret);
-  else if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ())
-    ret = CFStringGetDoubleValue (value);
-	
-  if (value != NULL) CFRelease (value);
-  
-  return ret;
-}
-
-- (int) prefs_get_boolean:(NSString *)key default:(int)def {
-  CFPropertyListRef value;
-  int ret = def;
-  
-  value = [self prefs_get:key];
-  
-  if (value != NULL) {
-    if (CFGetTypeID (value) == CFNumberGetTypeID ())
-      CFNumberGetValue (value, kCFNumberIntType, &ret);
-    else if (CFGetTypeID (value) == CFBooleanGetTypeID ())
-      ret = CFBooleanGetValue (value);
-    else if (CFGetTypeID (value) == CFStringGetTypeID ()) {
-      const char *tem = [(NSString *) value lossyCString];
-      if (strcasecmp (tem, "true") == 0 || strcasecmp (tem, "yes") == 0)
-	ret = YES;
-      else
-	ret = NO;
+- (int) prefs_get_integer:(NSString *)key default:(int)def
+{
+    CFPropertyListRef value;
+    int ret;
+	
+    value = [self prefs_get:key];
+	
+    if (value != NULL && CFGetTypeID (value) == CFNumberGetTypeID ())
+		CFNumberGetValue (value, kCFNumberIntType, &ret);
+    else if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ())
+		ret = CFStringGetIntValue (value);
+    else
+		ret = def;
+	
+    if (value != NULL)
+		CFRelease (value);
+	
+    return ret;
+}
+
+- (const char *) prefs_get_string:(NSString *)key default:(const char *)def
+{
+    CFPropertyListRef value;
+    const char *ret = NULL;
+	
+    value = [self prefs_get:key];
+	
+    if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ())
+    {
+		NSString *s = (NSString *) value;
+		
+		ret = [s UTF8String];
     }
-    
-    CFRelease (value);
-  }
-  return ret;
-}
-
-- (NSArray *) prefs_get_array:(NSString *)key {
-  NSArray *ret = nil;
-  CFPropertyListRef value;
-  
-  value = [self prefs_get:key];
-  
-  if (value != NULL) {
-    if (CFGetTypeID (value) == CFArrayGetTypeID ())
-      ret = [cfarray_to_nsarray (value) autorelease];
-    
-    CFRelease (value);
-  }
-  
-  return ret;
+	
+    if (value != NULL)
+		CFRelease (value);
+	
+    return ret != NULL ? ret : def;
+}
+
+- (float) prefs_get_float:(NSString *)key default:(float)def
+{
+    CFPropertyListRef value;
+    float ret = def;
+	
+    value = [self prefs_get:key];
+	
+    if (value != NULL
+		&& CFGetTypeID (value) == CFNumberGetTypeID ()
+		&& CFNumberIsFloatType (value))
+    {
+		CFNumberGetValue (value, kCFNumberFloatType, &ret);
+    }
+    else if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ())
+    {
+		ret = CFStringGetDoubleValue (value);
+    }
+	
+    if (value != NULL)
+		CFRelease (value);
+	
+    return ret;
+}
+
+- (int) prefs_get_boolean:(NSString *)key default:(int)def
+{
+    CFPropertyListRef value;
+    int ret = def;
+	
+    value = [self prefs_get:key];
+	
+    if (value != NULL)
+    {
+		if (CFGetTypeID (value) == CFNumberGetTypeID ())
+			CFNumberGetValue (value, kCFNumberIntType, &ret);
+		else if (CFGetTypeID (value) == CFBooleanGetTypeID ())
+			ret = CFBooleanGetValue (value);
+		else if (CFGetTypeID (value) == CFStringGetTypeID ())
+		{
+			const char *tem = [(NSString *) value lossyCString];
+			if (strcasecmp (tem, "true") == 0 || strcasecmp (tem, "yes") == 0)
+				ret = YES;
+			else
+				ret = NO;
+		}
+		
+		CFRelease (value);
+    }
+	
+    return ret;
+}
+
+- (NSArray *) prefs_get_array:(NSString *)key
+{
+    NSArray *ret = nil;
+    CFPropertyListRef value;
+	
+    value = [self prefs_get:key];
+	
+    if (value != NULL)
+    {
+		if (CFGetTypeID (value) == CFArrayGetTypeID ())
+			ret = [cfarray_to_nsarray (value) autorelease];
+		
+		CFRelease (value);
+    }
+	
+    return ret;
 }
 
-- (void) prefs_set_integer:(NSString *)key value:(int)value {
+- (void) prefs_set_integer:(NSString *)key value:(int)value
+{
     CFNumberRef x;
 	
     x = CFNumberCreate (NULL, kCFNumberIntType, &value);
 	
     CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) x, CFSTR (APP_PREFS),
-			   kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+						   kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
 	
     CFRelease (x);
 }
 
-- (void) prefs_set_float:(NSString *)key value:(float)value {
+- (void) prefs_set_float:(NSString *)key value:(float)value
+{
     CFNumberRef x;
 	
     x = CFNumberCreate (NULL, kCFNumberFloatType, &value);
 	
     CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) x, CFSTR (APP_PREFS),
-			   kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+						   kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
 	
     CFRelease (x);
 }
 
-- (void) prefs_set_boolean:(NSString *)key value:(int)value {
-  CFPreferencesSetValue ((CFStringRef) key,
-			 (CFTypeRef) value ? kCFBooleanTrue
-			 : kCFBooleanFalse, CFSTR (APP_PREFS),
-			 kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
-  
+- (void) prefs_set_boolean:(NSString *)key value:(int)value
+{
+    CFPreferencesSetValue ((CFStringRef) key,
+						   (CFTypeRef) value ? kCFBooleanTrue
+						   : kCFBooleanFalse, CFSTR (APP_PREFS),
+						   kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+	
 }
 
-- (void) prefs_set_array:(NSString *)key value:(NSArray *)value {
-  CFArrayRef cfarray;
-  
-  cfarray = nsarray_to_cfarray (value);
-  CFPreferencesSetValue ((CFStringRef) key,
-			 (CFTypeRef) cfarray,
-			 CFSTR (APP_PREFS),
-			 kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
-  CFRelease (cfarray);
+- (void) prefs_set_array:(NSString *)key value:(NSArray *)value
+{
+    CFArrayRef cfarray;
+	
+    cfarray = nsarray_to_cfarray (value);
+    CFPreferencesSetValue ((CFStringRef) key,
+						   (CFTypeRef) cfarray,
+						   CFSTR (APP_PREFS),
+						   kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+    CFRelease (cfarray);
 }
 
-- (void) prefs_set_string:(NSString *)key value:(NSString *)value {
-  CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) value,
-			 CFSTR (APP_PREFS), kCFPreferencesCurrentUser,
-			 kCFPreferencesAnyHost);
+- (void) prefs_set_string:(NSString *)key value:(NSString *)value
+{
+    CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) value,
+						   CFSTR (APP_PREFS), kCFPreferencesCurrentUser,
+						   kCFPreferencesAnyHost);
 }
 
-- (void) prefs_synchronize {
+- (void) prefs_synchronize
+{
     CFPreferencesAppSynchronize (kCFPreferencesCurrentApplication);
 }
 
-- (void) read_defaults {
-  const char *tem;
-  
-  quartzUseSysBeep = [self prefs_get_boolean:@PREFS_SYSBEEP
-			   default:quartzUseSysBeep];
-  quartzEnableRootless = [self prefs_get_boolean:@PREFS_ROOTLESS
-			       default:quartzEnableRootless];
+- (void) read_defaults
+{
+    const char *tem;
+	
+    quartzUseSysBeep = [self prefs_get_boolean:@PREFS_SYSBEEP
+									   default:quartzUseSysBeep];
+    quartzEnableRootless = [self prefs_get_boolean:@PREFS_ROOTLESS
+										   default:quartzEnableRootless];
 #ifdef DARWIN_DDX_MISSING
-  quartzFullscreenDisableHotkeys = ![self prefs_get_boolean:
-					    @PREFS_FULLSCREEN_HOTKEYS default:
-					    !quartzFullscreenDisableHotkeys];
-  quartzXpluginOptions = [self prefs_get_integer:@PREFS_XP_OPTIONS
-			       default:quartzXpluginOptions];
+    quartzFullscreenDisableHotkeys = ![self prefs_get_boolean:
+									   @PREFS_FULLSCREEN_HOTKEYS default:
+									   !quartzFullscreenDisableHotkeys];
+    quartzXpluginOptions = [self prefs_get_integer:@PREFS_XP_OPTIONS
+										   default:quartzXpluginOptions];
 #endif
-  
-  darwinSwapAltMeta = [self prefs_get_boolean:@PREFS_SWAP_ALT_META
-			    default:darwinSwapAltMeta];
-  darwinFakeButtons = [self prefs_get_boolean:@PREFS_FAKEBUTTONS
-			    default:darwinFakeButtons];
-  if (darwinFakeButtons) {
-    const char *fake2, *fake3;
-    
-    fake2 = [self prefs_get_string:@PREFS_FAKE_BUTTON2 default:NULL];
-    fake3 = [self prefs_get_string:@PREFS_FAKE_BUTTON3 default:NULL];
-													      
-     if (fake2 != NULL) darwinFakeMouse2Mask = DarwinParseModifierList(fake2);
-     if (fake3 != NULL) darwinFakeMouse3Mask = DarwinParseModifierList(fake3);
+	
+    darwinSwapAltMeta = [self prefs_get_boolean:@PREFS_SWAP_ALT_META
+										default:darwinSwapAltMeta];
+    darwinFakeButtons = [self prefs_get_boolean:@PREFS_FAKEBUTTONS
+										default:darwinFakeButtons];
+    if (darwinFakeButtons)
+    {
+        const char *fake2, *fake3;
+		
+        fake2 = [self prefs_get_string:@PREFS_FAKE_BUTTON2 default:NULL];
+        fake3 = [self prefs_get_string:@PREFS_FAKE_BUTTON3 default:NULL];
+		
+		if (fake2 != NULL) darwinFakeMouse2Mask = DarwinParseModifierList(fake2);
+		if (fake3 != NULL) darwinFakeMouse3Mask = DarwinParseModifierList(fake3);
 		
-  }
+    }
 	
-  X11EnableKeyEquivalents = [self prefs_get_boolean:@PREFS_KEYEQUIVS
-				  default:X11EnableKeyEquivalents];
+    X11EnableKeyEquivalents = [self prefs_get_boolean:@PREFS_KEYEQUIVS
+											  default:X11EnableKeyEquivalents];
 	
-  darwinSyncKeymap = [self prefs_get_boolean:@PREFS_SYNC_KEYMAP
-			   default:darwinSyncKeymap];
+    darwinSyncKeymap = [self prefs_get_boolean:@PREFS_SYNC_KEYMAP
+									   default:darwinSyncKeymap];
 	
-  tem = [self prefs_get_string:@PREFS_KEYMAP_FILE default:NULL];
-
-  if (tem != NULL) darwinKeymapFile = strdup (tem);
-  else darwinKeymapFile = NULL;
+    tem = [self prefs_get_string:@PREFS_KEYMAP_FILE default:NULL];
+    if (tem != NULL)
+		darwinKeymapFile = strdup (tem);
+    else
+        darwinKeymapFile = NULL;
 	
-  darwinDesiredDepth = [self prefs_get_integer:@PREFS_DEPTH
-			     default:darwinDesiredDepth];
+    darwinDesiredDepth = [self prefs_get_integer:@PREFS_DEPTH
+										 default:darwinDesiredDepth];
 	
-  enable_stereo = [self prefs_get_boolean:@PREFS_ENABLE_STEREO
-			default:false];
+    enable_stereo = [self prefs_get_boolean:@PREFS_ENABLE_STEREO
+									default:false];
 }
 
 /* This will end up at the end of the responder chain. */
-- (void) copy:sender {
-  QuartzMessageServerThread (kXDarwinPasteboardNotify, 1,
-			     AppleWMCopyToPasteboard);
+- (void) copy:sender
+{
+    QuartzMessageServerThread (kXDarwinPasteboardNotify, 1,
+							   AppleWMCopyToPasteboard);
 }
 
-- (BOOL) x_active {
+- (BOOL) x_active
+{
     return _x_active;
 }
 
@@ -661,62 +764,75 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
 
 static NSArray *
 array_with_strings_and_numbers (int nitems, const char **items,
-				const char *numbers) {
-  NSMutableArray *array, *subarray;
-  NSString *string, *number;
-  int i;
-	
-  /* (Can't autorelease on the X server thread) */
-  
-  array = [[NSMutableArray alloc] initWithCapacity:nitems];
-  
-  for (i = 0; i < nitems; i++) {
-    subarray = [[NSMutableArray alloc] initWithCapacity:2];
-    
-    string = [[NSString alloc] initWithUTF8String:items[i]];
-    [subarray addObject:string];
-    [string release];
-    
-    if (numbers[i] != 0) {
-      number = [[NSString alloc] initWithFormat:@"%d", numbers[i]];
-      [subarray addObject:number];
-      [number release];
-    } else
-      [subarray addObject:@""];
-    
-    [array addObject:subarray];
-    [subarray release];
-  }
-  
-  return array;
-}
-
-void X11ApplicationSetWindowMenu (int nitems, const char **items,
-				  const char *shortcuts) {
-  NSArray *array;
-  array = array_with_strings_and_numbers (nitems, items, shortcuts);
-  
-  /* Send the array of strings over to the appkit thread */
-  
-  message_kit_thread (@selector (set_window_menu:), array);
-  [array release];
-}
-
-void X11ApplicationSetWindowMenuCheck (int idx) {
-  NSNumber *n;
-  
-  n = [[NSNumber alloc] initWithInt:idx];
-  
-  message_kit_thread (@selector (set_window_menu_check:), n);
-  
-  [n release];
-}
-
-void X11ApplicationSetFrontProcess (void) {
+								const char *numbers)
+{
+    NSMutableArray *array, *subarray;
+    NSString *string;
+    NSString *number;
+    int i;
+	
+    /* (Can't autorelease on the X server thread) */
+	
+    array = [[NSMutableArray alloc] initWithCapacity:nitems];
+	
+    for (i = 0; i < nitems; i++)
+    {
+		subarray = [[NSMutableArray alloc] initWithCapacity:2];
+		
+		string = [[NSString alloc] initWithUTF8String:items[i]];
+		[subarray addObject:string];
+		[string release];
+		
+		if (numbers[i] != 0)
+		{
+			number = [[NSString alloc] initWithFormat:@"%d", numbers[i]];
+			[subarray addObject:number];
+			[number release];
+		}
+		else
+			[subarray addObject:@""];
+		
+		[array addObject:subarray];
+		[subarray release];
+    }
+	
+    return array;
+}
+
+void
+X11ApplicationSetWindowMenu (int nitems, const char **items,
+							 const char *shortcuts)
+{
+    NSArray *array;
+    array = array_with_strings_and_numbers (nitems, items, shortcuts);
+	
+    /* Send the array of strings over to the appkit thread */
+	
+    message_kit_thread (@selector (set_window_menu:), array);
+    [array release];
+}
+
+void
+X11ApplicationSetWindowMenuCheck (int idx)
+{
+    NSNumber *n;
+	
+    n = [[NSNumber alloc] initWithInt:idx];
+	
+    message_kit_thread (@selector (set_window_menu_check:), n);
+	
+    [n release];
+}
+
+void
+X11ApplicationSetFrontProcess (void)
+{
     message_kit_thread (@selector (set_front_process:), nil);
 }
 
-void X11ApplicationSetCanQuit (int state) {
+void
+X11ApplicationSetCanQuit (int state)
+{
     NSNumber *n;
 	
     n = [[NSNumber alloc] initWithBool:state];
@@ -726,11 +842,15 @@ void X11ApplicationSetCanQuit (int state) {
     [n release];
 }
 
-void X11ApplicationServerReady (void) {
+void
+X11ApplicationServerReady (void)
+{
     message_kit_thread (@selector (server_ready:), nil);
 }
 
-void X11ApplicationShowHideMenubar (int state) {
+void
+X11ApplicationShowHideMenubar (int state)
+{
     NSNumber *n;
 	
     n = [[NSNumber alloc] initWithBool:state];
@@ -740,20 +860,27 @@ void X11ApplicationShowHideMenubar (int state) {
     [n release];
 }
 
-static void * create_thread (void *func, void *arg) {
+static void *
+create_thread (void *func, void *arg)
+{
     pthread_attr_t attr;
     pthread_t tid;
 	
     pthread_attr_init (&attr);
+	
     pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM);
     pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
+	
     pthread_create (&tid, &attr, func, arg);
+	
     pthread_attr_destroy (&attr);
 	
     return (void *) tid;
 }
 
-static void check_xinitrc (void) {
+static void
+check_xinitrc (void)
+{
     char *tem, buf[1024];
     NSString *msg;
 	
@@ -761,7 +888,8 @@ static void check_xinitrc (void) {
 		return;
 	
     tem = getenv ("HOME");
-    if (tem == NULL) goto done;
+    if (tem == NULL)
+		goto done;
 	
     snprintf (buf, sizeof (buf), "%s/.xinitrc", tem);
     if (access (buf, F_OK) != 0)
@@ -769,43 +897,48 @@ static void check_xinitrc (void) {
 	
     /* FIXME: put localized strings into Resources/English.lproj */
 	
-    msg = NSLocalizedString (@"You have an existing ~/.xinitrc file.\n\n\
-Windows displayed by X11 applications may not have titlebars, or may look \
-different to windows displayed by native applications.\n\n\
-Would you like to move aside the existing file and use the standard X11 \
-environment?", @"Startup xinitrc dialog");
+    msg = NSLocalizedString (
+							 @"You have an existing ~/.xinitrc file.\n\n\
+							 Windows displayed by X11 applications may not have titlebars, or may look \
+							 different to windows displayed by native applications.\n\n\
+							 Would you like to move aside the existing file and use the standard X11 \
+							 environment?", @"Startup xinitrc dialog");
 	
     if (NSRunAlertPanel (nil, msg, NSLocalizedString (@"Yes", @""),
-			 NSLocalizedString (@"No", @""), nil)
-	== NSAlertDefaultReturn) {
-      char buf2[1024];
-      int i = -1;
-      
-      snprintf (buf2, sizeof (buf2), "%s.old", buf);
-      
-      for (i = 1; access (buf2, F_OK) == 0; i++)
-	snprintf (buf2, sizeof (buf2), "%s.old.%d", buf, i);
-      
-      rename (buf, buf2);
+						 NSLocalizedString (@"No", @""), nil)
+		== NSAlertDefaultReturn)
+    {
+		char buf2[1024];
+		int i = -1;
+		
+		snprintf (buf2, sizeof (buf2), "%s.old", buf);
+		
+		for (i = 1; access (buf2, F_OK) == 0; i++)
+			snprintf (buf2, sizeof (buf2), "%s.old.%d", buf, i);
+		
+		rename (buf, buf2);
     }
     
- done:
+	done:
     [X11App prefs_set_boolean:@PREFS_DONE_XINIT_CHECK value:YES];
     [X11App prefs_synchronize];
 }
 
-void X11ApplicationMain (int argc, const char *argv[],
-			 void (*server_thread) (void *), void *server_arg) {
+void
+X11ApplicationMain (int argc, const char *argv[],
+					void (*server_thread) (void *), void *server_arg)
+{
     NSAutoreleasePool *pool;
 	
 #ifdef DEBUG
-    while (access ("/tmp/x11-block", F_OK) == 0) sleep (1);
+    while (access ("/tmp/x11-block", F_OK) == 0)
+		sleep (1);
 #endif
 	
     pool = [[NSAutoreleasePool alloc] init];
 	
     X11App = (X11Application *) [X11Application sharedApplication];
-
+	
     init_ports ();
 	
     [NSApp read_defaults];
@@ -813,8 +946,8 @@ void X11ApplicationMain (int argc, const char *argv[],
     [NSBundle loadNibNamed:@"main" owner:NSApp];
 	
     [[NSNotificationCenter defaultCenter] addObserver:NSApp
-					  selector:@selector (became_key:)
-					  name:NSWindowDidBecomeKeyNotification object:nil];
+											 selector:@selector (became_key:)
+												 name:NSWindowDidBecomeKeyNotification object:nil];
 	
     check_xinitrc ();
 	
@@ -826,101 +959,173 @@ void X11ApplicationMain (int argc, const char *argv[],
 	
     /* Calculate the height of the menubar so we can avoid it. */
     aquaMenuBarHeight = NSHeight([[NSScreen mainScreen] frame]) -
-      NSMaxY([[NSScreen mainScreen] visibleFrame]) - 1;
+	NSMaxY([[NSScreen mainScreen] visibleFrame]) - 1;
 	
-    if (!create_thread (server_thread, server_arg)) {
-      ErrorF("can't create secondary thread\n");
-      exit(1);
+    if (!create_thread (server_thread, server_arg))
+    {
+		fprintf (stderr, "can't create secondary thread\n");
+		exit (1);
     }
 	
     [NSApp run];
+	
+    /* not reached */
 }
 
 
 /* event conversion */
 
 static inline unsigned short
-convert_flags (unsigned int nsflags) {
-    unsigned int xflags = 0;
+convert_flags (unsigned int nsflags)
+{
+    unsigned int xflags;
 	
     if (nsflags == ~0) return 0xffff;
 	
+    xflags = 0;
+	
     if (nsflags & NSAlphaShiftKeyMask)	xflags |= LockMask;
-    if (nsflags & NSShiftKeyMask)	xflags |= ShiftMask;
-    if (nsflags & NSControlKeyMask)	xflags |= ControlMask;
+    if (nsflags & NSShiftKeyMask)		xflags |= ShiftMask;
+    if (nsflags & NSControlKeyMask)		xflags |= ControlMask;
     if (nsflags & NSAlternateKeyMask)	xflags |= Mod1Mask;
-    if (nsflags & NSCommandKeyMask)	xflags |= Mod2Mask;
+    if (nsflags & NSCommandKeyMask)		xflags |= Mod2Mask;
     /* FIXME: secondaryfn? */
 	
     return xflags;
 }
 
-
-// This code should probably be merged with that in XDarwin's XServer.m - BB
-static void send_nsevent (NSEventType type, NSEvent *e) {
-  //    static unsigned int button_state = 0;
+static void
+send_nsevent (NSEventType type, NSEvent *e)
+{
+    static unsigned int button_state = 0;
     NSRect screen;
     NSPoint location;
     NSWindow *window;
-    int pointer_x, pointer_y, ev_button, ev_type; 
-    //    int num_events=0, i=0, state;
+    int pointer_x, pointer_y;
     xEvent xe;
 	
-    /* convert location to global top-left coordinates */
-    location = [e locationInWindow];
-    window = [e window];
-    screen = [[[NSScreen screens] objectAtIndex:0] frame];
-		
-    if (window != nil)	{
-      NSRect frame = [window frame];
-      pointer_x = location.x + frame.origin.x;
-      pointer_y = (((screen.origin.y + screen.size.height)
-		    - location.y) - frame.origin.y);
-    } else {
-      pointer_x = location.x;
-      pointer_y = (screen.origin.y + screen.size.height) - location.y;
-    }
-    
-    pointer_y -= aquaMenuBarHeight;
-    //    state = convert_flags ([e modifierFlags]);
-    
-    switch (type) {
-    case NSLeftMouseDown:    ev_button=1; ev_type=ButtonPress; goto handle_mouse;
-    case NSOtherMouseDown:   ev_button=2; ev_type=ButtonPress; goto handle_mouse;
-    case NSRightMouseDown:   ev_button=3; ev_type=ButtonPress; goto handle_mouse;
-    case NSLeftMouseUp:      ev_button=1; ev_type=ButtonRelease; goto handle_mouse;
-    case NSOtherMouseUp:     ev_button=2; ev_type=ButtonRelease; goto handle_mouse;
-    case NSRightMouseUp:     ev_button=3; ev_type=ButtonRelease; goto handle_mouse;
-    case NSLeftMouseDragged:  ev_button=1; ev_type=MotionNotify; goto handle_mouse;
-    case NSOtherMouseDragged: ev_button=2; ev_type=MotionNotify; goto handle_mouse;
-    case NSRightMouseDragged: ev_button=3; ev_type=MotionNotify; goto handle_mouse;
-    case NSMouseMoved: ev_button=0; ev_type=MotionNotify; goto handle_mouse;
-    handle_mouse:
-      
-      /* I'm not sure the below code is necessary or useful (-bb)
-	if(ev_type==ButtonPress) {
-	if (!quartzProcs->IsX11Window([e window], [e windowNumber])) {
-	  fprintf(stderr, "Dropping event because it's not a window\n");
-	  break;
+    memset (&xe, 0, sizeof (xe));
+	
+    /* This field should be filled in for every event */
+    xe.u.keyButtonPointer.time = GetTimeInMillis();
+
+	/* convert location to global top-left coordinates */
+	location = [e locationInWindow];
+	window = [e window];
+	screen = [[[NSScreen screens] objectAtIndex:0] frame];
+		
+	if (window != nil)	{
+		NSRect frame = [window frame];
+		pointer_x = location.x + frame.origin.x;
+		pointer_y = (((screen.origin.y + screen.size.height)
+					  - location.y) - frame.origin.y);
+	} else {
+		pointer_x = location.x;
+		pointer_y = (screen.origin.y + screen.size.height) - location.y;
 	}
-	button_state |= (1 << ev_button);
-	DarwinSendPointerEvents(ev_type, ev_button, pointer_x, pointer_y);
-      } else if (ev_type==ButtonRelease && (button_state & (1 << ev_button)) == 0) break;
-      */
-      DarwinSendPointerEvents(ev_type, ev_button, pointer_x, pointer_y);
-      break;
-    case NSScrollWheel: 
-      DarwinSendScrollEvents([e deltaY], pointer_x, pointer_y);
-      break;
-      
-    case NSKeyDown:  // do we need to translate these keyCodes?
+		
+	xe.u.keyButtonPointer.rootX = pointer_x;
+	xe.u.keyButtonPointer.rootY = pointer_y;
+	
+	switch (type) {
+		float count;
+		
+    case NSLeftMouseDown:
+		xe.u.u.type = ButtonPress;
+		xe.u.u.detail = 1;
+		goto do_press_event;
+		
+    case NSRightMouseDown:
+		xe.u.u.type = ButtonPress;
+		xe.u.u.detail = 3;
+		goto do_press_event;
+		
+    case NSOtherMouseDown:
+		xe.u.u.type = ButtonPress;
+		xe.u.u.detail = 2; /* FIXME? */
+		goto do_press_event;
+		
+do_press_event:
+		if (!quartzProcs->IsX11Window([e window], [e windowNumber])) {
+			/* X server doesn't grok this window, drop the event.
+			 
+			 Note: theoretically this isn't necessary, but if I click
+			 on the menubar, we get sent a LeftMouseDown when the
+			 release happens, but no LeftMouseUp is ever seen! */
+			
+			break;
+		}
+		goto do_event;
+		
+    case NSLeftMouseUp:
+		xe.u.u.type = ButtonRelease;
+		xe.u.u.detail = 1;
+		goto do_release_event;
+		
+    case NSRightMouseUp:
+		xe.u.u.type = ButtonRelease;
+		xe.u.u.detail = 3;
+		goto do_release_event;
+		
+    case NSOtherMouseUp:
+		xe.u.u.type = ButtonRelease;
+		xe.u.u.detail = 2; /* FIXME? */
+		goto do_release_event;
+		
+do_release_event:
+		if ((button_state & (1 << xe.u.u.detail)) == 0)
+		{
+			/* X didn't see the button press for this release, so skip it */
+			break;
+		}
+		goto do_event;
+		
+    case NSMouseMoved:
+    case NSLeftMouseDragged:
+    case NSRightMouseDragged:
+    case NSOtherMouseDragged:
+		xe.u.u.type = MotionNotify;
+		goto do_event;
+		
+    case NSKeyDown:
+		xe.u.u.type = KeyPress;
+		xe.u.u.detail = [e keyCode];
+		goto do_event;
+		
     case NSKeyUp:
-      DarwinSendKeyboardEvents((type == NSKeyDown)?KeyPress:KeyRelease, [e keyCode]);
-      break;
-
+		xe.u.u.type = KeyRelease;
+		xe.u.u.detail = [e keyCode];
+		goto do_event;
+		
+    case NSScrollWheel:
+		xe.u.keyButtonPointer.state = convert_flags ([e modifierFlags]);
+		count = [e deltaY];
+		xe.u.u.detail = count > 0.0f ? 4 : 5;
+		for (count = fabs(count); count > 0.0; count = count - 1.0f) {
+			xe.u.u.type = ButtonPress;
+			DarwinEQEnqueue(&xe);
+			xe.u.u.type = ButtonRelease;
+			DarwinEQEnqueue(&xe);
+		}
+		xe.u.u.type = 0;
+		break;
+		
     case NSFlagsChanged:
-      DarwinUpdateModKeys([e modifierFlags]);
-      break;
+        xe.u.u.type = kXDarwinUpdateModifiers;
+        xe.u.clientMessage.u.l.longs0 = [e modifierFlags];
+        DarwinEQEnqueue (&xe);
+        break;
+		
+do_event:
+		//	xe.u.keyButtonPointer.state = convert_flags ([e modifierFlags]);
+		DarwinEQEnqueue (&xe);
+		break;
+		
     default: break; /* for gcc */
-    }	
+    }
+	
+    if (xe.u.u.type == ButtonPress)
+		button_state |= (1 << xe.u.u.detail);
+    else if (xe.u.u.type == ButtonRelease)
+		button_state &= ~(1 << xe.u.u.detail);
 }
diff --git a/hw/darwin/apple/X11Controller.h b/hw/darwin/apple/X11Controller.h
index 8d17fd9..954d0ab 100644
--- a/hw/darwin/apple/X11Controller.h
+++ b/hw/darwin/apple/X11Controller.h
@@ -1,4 +1,5 @@
 /* X11Controller.h -- connect the IB ui
+   $Id: X11Controller.h,v 1.21 2003/07/24 17:52:29 jharper Exp $
 
    Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
 
diff --git a/hw/darwin/apple/X11Controller.m b/hw/darwin/apple/X11Controller.m
index 3dc965b..cc039b1 100644
--- a/hw/darwin/apple/X11Controller.m
+++ b/hw/darwin/apple/X11Controller.m
@@ -296,17 +296,13 @@
 - (void) launch_client:(NSString *)filename
 {
   const char *command = [filename UTF8String];
-  const char *shell;
   const char *argv[5];
   int child1, child2 = 0;
   int status;
 	
-  shell = getenv("SHELL");
-  if (shell == NULL) shell = "/bin/bash";
-    
-  argv[0] = shell;
-  argv[1] = "-l";
-  argv[2] = "-c";
+  argv[0] = "/usr/bin/login";
+  argv[1] = "-fp";
+  argv[2] = getlogin();
   argv[3] = command;
   argv[4] = NULL;
     
@@ -655,7 +651,7 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
 
 - (IBAction) x11_help:sender
 {
-  AHLookupAnchor (CFSTR ("Mac Help"), CFSTR ("mchlp2276"));
+  AHLookupAnchor ((CFStringRef)NSLocalizedString(@"Mac Help", no comment), CFSTR ("mchlp2276"));
 }
 
 - (BOOL) validateMenuItem:(NSMenuItem *)item
diff --git a/hw/darwin/apple/bundle-main.c b/hw/darwin/apple/bundle-main.c
index ec7820d..34cbcba 100644
--- a/hw/darwin/apple/bundle-main.c
+++ b/hw/darwin/apple/bundle-main.c
@@ -70,14 +70,15 @@
 
 #include <X11/Xlib.h>
 #include <X11/Xauth.h>
+#include <xcb/xcb.h>
 
 #include <CoreFoundation/CoreFoundation.h>
 #include <SystemConfiguration/SystemConfiguration.h>
 
 #define X_SERVER "/usr/X11/bin/Xquartz"
 #define XTERM_PATH "/usr/X11/bin/xterm"
-#define WM_PATH "/usr/X11/bin/quartz-wm"
-#define DEFAULT_XINITRC "/etc/X11/xinit/xinitrc"
+#define WM_PATH "/usr/bin/quartz-wm"
+#define DEFAULT_XINITRC "/usr/X11/lib/X11/xinit/xinitrc"
 #define DEFAULT_PATH "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11/bin"
 
 /* what xinit does */
@@ -595,15 +596,15 @@ static Boolean
 display_exists_p (int number)
 {
     char buf[64];
-    void *conn;
+    xcb_connection_t *conn;
     char *fullname = NULL;
     int idisplay, iscreen;
     char *conn_auth_name, *conn_auth_data;
     int conn_auth_namelen, conn_auth_datalen;
-#ifdef USE_XTRANS_INTERNALS	
-    extern void *_X11TransConnectDisplay ();
-    extern void _XDisconnectDisplay ();
-#endif	
+    
+    //    extern void *_X11TransConnectDisplay ();
+    //    extern void _XDisconnectDisplay ();
+	
     /* Since connecting to the display waits for a few seconds if the
 	 display doesn't exist, check for trivial non-existence - if the
 	 socket in /tmp exists or not.. (note: if the socket exists, the
@@ -612,20 +613,22 @@ display_exists_p (int number)
     sprintf (buf, "/tmp/.X11-unix/X%d", number);
     if (access (buf, F_OK) != 0)
 		return FALSE;
-#ifdef USE_XTRANS_INTERNALS	
+	
     /* This is a private function that we shouldn't really be calling,
 	 but it's the best way to see if the server exists (without
 	 needing to hold the necessary authentication to use it) */
 	
     sprintf (buf, ":%d", number);
-    conn = _X11TransConnectDisplay (buf, &fullname, &idisplay, &iscreen,
+    /*    conn = _X11TransConnectDisplay (buf, &fullname, &idisplay, &iscreen,
 									&conn_auth_name, &conn_auth_namelen,
-									&conn_auth_data, &conn_auth_datalen);
+									&conn_auth_data, &conn_auth_datalen); */
+    conn = xcb_connect(buf, NULL);
+
     if (conn == NULL)
 		return FALSE;
 	
-    _XDisconnectDisplay (conn);
-#endif
+    //    _XDisconnectDisplay (conn);
+    xcb_disconnect(conn);
     return TRUE;
 }
 
diff --git a/hw/darwin/bundle/Dutch.lproj/Localizable.strings b/hw/darwin/bundle/Dutch.lproj/Localizable.strings
index 6abd910..4fe16b3 100644
Binary files a/hw/darwin/bundle/Dutch.lproj/Localizable.strings and b/hw/darwin/bundle/Dutch.lproj/Localizable.strings differ
diff --git a/hw/darwin/bundle/Dutch.lproj/Makefile.am b/hw/darwin/bundle/Dutch.lproj/Makefile.am
index a480cee..49a3ec5 100644
--- a/hw/darwin/bundle/Dutch.lproj/Makefile.am
+++ b/hw/darwin/bundle/Dutch.lproj/Makefile.am
@@ -15,13 +15,15 @@ Dutchlprojdir = $(resourcesdir)/Dutch.lproj
 Dutchlproj_DATA = \
 		    XDarwinHelp.html \
 		    InfoPlist.strings \
-		    Credits.rtf Localizable.strings
+		    Credits.rtf Localizable.strings Localizable.strings
 
 Dutchlprojnibdir = $(Dutchlprojdir)/MainMenu.nib
-Dutchlprojnib_DATA = MainMenu.nib/classes.nib MainMenu.nib/objects.nib
+Dutchlprojnib_DATA = \
+		       MainMenu.nib/classes.nib \
+		       MainMenu.nib/objects.nib
 
 InfoPlist.strings: $(srcdir)/../English.lproj/InfoPlist.strings.cpp
-	 $(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) | $(SED) -e's/__quote__/"/g' > $@
+	 $(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) | $(SED) -e's/__quote__/"/g' | iconv -t UTF-16 > $@
 
 XDarwinHelp.html: XDarwinHelp.html.cpp
 	$(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) > $@
@@ -30,6 +32,8 @@ CLEANFILES = XDarwinHelp.html InfoPlist.strings
 
 EXTRA_DIST = \
 	Credits.rtf Localizable.strings \
+	Localizable.strings \
 	MainMenu.nib/classes.nib \
 	MainMenu.nib/objects.nib \
 	XDarwinHelp.html.cpp
+
diff --git a/hw/darwin/bundle/English.lproj/Localizable.strings b/hw/darwin/bundle/English.lproj/Localizable.strings
index 2c25c1d..f2e8e3c 100644
Binary files a/hw/darwin/bundle/English.lproj/Localizable.strings and b/hw/darwin/bundle/English.lproj/Localizable.strings differ
diff --git a/hw/darwin/bundle/English.lproj/Makefile.am b/hw/darwin/bundle/English.lproj/Makefile.am
index 4558708..8d6f7e5 100644
--- a/hw/darwin/bundle/English.lproj/Makefile.am
+++ b/hw/darwin/bundle/English.lproj/Makefile.am
@@ -17,10 +17,12 @@ Englishlproj_DATA = \
 		    Credits.rtf Localizable.strings
 
 Englishlprojnibdir = $(Englishlprojdir)/MainMenu.nib
-Englishlprojnib_DATA = MainMenu.nib/classes.nib MainMenu.nib/objects.nib
+Englishlprojnib_DATA = \
+		       MainMenu.nib/classes.nib \
+		       MainMenu.nib/objects.nib
 
 InfoPlist.strings: InfoPlist.strings.cpp
-	 $(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) | $(SED) -e's/__quote__/"/g' > $@
+	 $(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) | $(SED) -e's/__quote__/"/g' | iconv -t UTF-16 > $@
 
 XDarwinHelp.html: XDarwinHelp.html.cpp
 	$(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) > $@
@@ -29,7 +31,9 @@ CLEANFILES = XDarwinHelp.html InfoPlist.strings
 
 EXTRA_DIST = \
 	Credits.rtf Localizable.strings \
+	Localizable.strings \
 	MainMenu.nib/classes.nib \
 	MainMenu.nib/objects.nib \
 	XDarwinHelp.html.cpp \
 	InfoPlist.strings.cpp
+
diff --git a/hw/darwin/bundle/French.lproj/Makefile.am b/hw/darwin/bundle/French.lproj/Makefile.am
index 656ba5c..4dca934 100644
--- a/hw/darwin/bundle/French.lproj/Makefile.am
+++ b/hw/darwin/bundle/French.lproj/Makefile.am
@@ -20,10 +20,12 @@ Frenchlproj_DATA = \
 		    Credits.rtf Localizable.strings
 
 Frenchlprojnibdir = $(Frenchlprojdir)/MainMenu.nib
-Frenchlprojnib_DATA = MainMenu.nib/classes.nib MainMenu.nib/objects.nib
+Frenchlprojnib_DATA = \
+		       MainMenu.nib/classes.nib \
+		       MainMenu.nib/objects.nib
 
 InfoPlist.strings: $(srcdir)/../English.lproj/InfoPlist.strings.cpp
-	 $(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) | $(SED) -e's/__quote__/"/g' > $@
+	 $(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) | $(SED) -e's/__quote__/"/g' | iconv -t UTF-16 > $@
 
 XDarwinHelp.html: XDarwinHelp.html.cpp
 	$(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) > $@
@@ -36,3 +38,4 @@ EXTRA_DIST = \
 	MainMenu.nib/classes.nib \
 	MainMenu.nib/objects.nib \
 	XDarwinHelp.html.cpp
+
diff --git a/hw/darwin/bundle/German.lproj/Makefile.am b/hw/darwin/bundle/German.lproj/Makefile.am
index 17af414..fcb5dd2 100644
--- a/hw/darwin/bundle/German.lproj/Makefile.am
+++ b/hw/darwin/bundle/German.lproj/Makefile.am
@@ -15,13 +15,15 @@ Germanlprojdir = $(resourcesdir)/German.lproj
 Germanlproj_DATA = \
 		    XDarwinHelp.html \
 		    InfoPlist.strings \
-		    Credits.rtf Localizable.strings
+		    Credits.rtf Localizable.strings Localizable.strings
 
 Germanlprojnibdir = $(Germanlprojdir)/MainMenu.nib
-Germanlprojnib_DATA =  MainMenu.nib/classes.nib MainMenu.nib/objects.nib
+Germanlprojnib_DATA = \
+		       MainMenu.nib/classes.nib \
+		       MainMenu.nib/objects.nib
 
 InfoPlist.strings: $(srcdir)/../English.lproj/InfoPlist.strings.cpp
-	 $(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) | $(SED) -e's/__quote__/"/g' > $@
+	 $(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) | $(SED) -e's/__quote__/"/g' | iconv -t UTF-16 > $@
 
 XDarwinHelp.html: XDarwinHelp.html.cpp
 	$(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) > $@
@@ -34,3 +36,4 @@ EXTRA_DIST = \
 	MainMenu.nib/classes.nib \
 	MainMenu.nib/objects.nib \
 	XDarwinHelp.html.cpp
+
diff --git a/hw/darwin/bundle/Info.plist b/hw/darwin/bundle/Info.plist
index bfef48d..7e17708 100644
--- a/hw/darwin/bundle/Info.plist
+++ b/hw/darwin/bundle/Info.plist
@@ -43,7 +43,7 @@
 	<key>CFBundleIconFile</key>
 	<string>XDarwin.icns</string>
 	<key>CFBundleIdentifier</key>
-	<string>org.x.XDarwin</string>
+	<string>org.x.X11</string>
 	<key>CFBundleInfoDictionaryVersion</key>
 	<string>6.0</string>
 	<key>CFBundleName</key>
@@ -51,7 +51,7 @@
 	<key>CFBundlePackageType</key>
 	<string>APPL</string>
 	<key>CFBundleShortVersionString</key>
-	<string>XDarwin 1.4.0</string>
+	<string>2.0.0</string>
 	<key>CFBundleSignature</key>
 	<string>????</string>
 	<key>CFBundleVersion</key>
diff --git a/hw/darwin/bundle/Japanese.lproj/Makefile.am b/hw/darwin/bundle/Japanese.lproj/Makefile.am
index 2cc5248..8d891ed 100644
--- a/hw/darwin/bundle/Japanese.lproj/Makefile.am
+++ b/hw/darwin/bundle/Japanese.lproj/Makefile.am
@@ -19,10 +19,12 @@ Japaneselproj_DATA = \
 		    Credits.rtf Localizable.strings
 
 Japaneselprojnibdir = $(Japaneselprojdir)/MainMenu.nib
-Japaneselprojnib_DATA = MainMenu.nib/classes.nib MainMenu.nib/objects.nib
+Japaneselprojnib_DATA = \
+		       MainMenu.nib/classes.nib \
+		       MainMenu.nib/objects.nib
 
 InfoPlist.strings: $(srcdir)/../English.lproj/InfoPlist.strings.cpp
-	 $(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) | $(SED) -e's/__quote__/"/g' > $@
+	 $(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) | $(SED) -e's/__quote__/"/g' | iconv -t UTF-16 > $@
 
 XDarwinHelp.html: XDarwinHelp.html.cpp
 	$(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) > $@
@@ -35,3 +37,4 @@ EXTRA_DIST = \
 	MainMenu.nib/classes.nib \
 	MainMenu.nib/objects.nib \
 	XDarwinHelp.html.cpp
+
diff --git a/hw/darwin/bundle/Portuguese.lproj/Makefile.am b/hw/darwin/bundle/Portuguese.lproj/Makefile.am
index 81ba2be..540649c 100644
--- a/hw/darwin/bundle/Portuguese.lproj/Makefile.am
+++ b/hw/darwin/bundle/Portuguese.lproj/Makefile.am
@@ -18,10 +18,12 @@ Portugueselproj_DATA = \
 		    Credits.rtf Localizable.strings
 
 Portugueselprojnibdir = $(Portugueselprojdir)/MainMenu.nib
-Portugueselprojnib_DATA = MainMenu.nib/classes.nib MainMenu.nib/objects.nib
+Portugueselprojnib_DATA = \
+		       MainMenu.nib/classes.nib \
+		       MainMenu.nib/objects.nib
 
 InfoPlist.strings: $(srcdir)/../English.lproj/InfoPlist.strings.cpp
-	 $(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) | $(SED) -e's/__quote__/"/g' > $@
+	 $(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) | $(SED) -e's/__quote__/"/g' | iconv -t UTF-16 > $@
 
 XDarwinHelp.html: XDarwinHelp.html.cpp
 	$(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) > $@
@@ -34,3 +36,4 @@ EXTRA_DIST = \
 	MainMenu.nib/classes.nib \
 	MainMenu.nib/objects.nib \
 	XDarwinHelp.html.cpp
+
diff --git a/hw/darwin/bundle/Spanish.lproj/Makefile.am b/hw/darwin/bundle/Spanish.lproj/Makefile.am
index 438d0c2..978ac35 100644
--- a/hw/darwin/bundle/Spanish.lproj/Makefile.am
+++ b/hw/darwin/bundle/Spanish.lproj/Makefile.am
@@ -18,10 +18,12 @@ Spanishlproj_DATA = \
 		    Credits.rtf Localizable.strings
 
 Spanishlprojnibdir = $(Spanishlprojdir)/MainMenu.nib
-Spanishlprojnib_DATA = MainMenu.nib/classes.nib MainMenu.nib/objects.nib
+Spanishlprojnib_DATA = \
+		       MainMenu.nib/classes.nib \
+		       MainMenu.nib/objects.nib
 
 InfoPlist.strings: $(srcdir)/../English.lproj/InfoPlist.strings.cpp
-	 $(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) | $(SED) -e's/__quote__/"/g' > $@
+	 $(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) | $(SED) -e's/__quote__/"/g' | iconv -t UTF-16 > $@
 
 XDarwinHelp.html: XDarwinHelp.html.cpp
 	$(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) > $@
@@ -34,3 +36,4 @@ EXTRA_DIST = \
 	MainMenu.nib/classes.nib \
 	MainMenu.nib/objects.nib \
 	XDarwinHelp.html.cpp
+
diff --git a/hw/darwin/bundle/Swedish.lproj/Makefile.am b/hw/darwin/bundle/Swedish.lproj/Makefile.am
index 19f35a6..3cf542c 100644
--- a/hw/darwin/bundle/Swedish.lproj/Makefile.am
+++ b/hw/darwin/bundle/Swedish.lproj/Makefile.am
@@ -18,10 +18,12 @@ Swedishlproj_DATA = \
 		    Credits.rtf Localizable.strings
 
 Swedishlprojnibdir = $(Swedishlprojdir)/MainMenu.nib
-Swedishlprojnib_DATA = MainMenu.nib/classes.nib MainMenu.nib/objects.nib
+Swedishlprojnib_DATA = \
+		       MainMenu.nib/classes.nib \
+		       MainMenu.nib/objects.nib
 
 InfoPlist.strings: $(srcdir)/../English.lproj/InfoPlist.strings.cpp
-	 $(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) | $(SED) -e's/__quote__/"/g' > $@
+	 $(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) | $(SED) -e's/__quote__/"/g' | iconv -t UTF-16 > $@
 
 XDarwinHelp.html: XDarwinHelp.html.cpp
 	$(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) > $@
@@ -34,3 +36,4 @@ EXTRA_DIST = \
 	MainMenu.nib/classes.nib \
 	MainMenu.nib/objects.nib \
 	XDarwinHelp.html.cpp
+
diff --git a/hw/darwin/bundle/ko.lproj/Makefile.am b/hw/darwin/bundle/ko.lproj/Makefile.am
index 56dd6b3..a5462ff 100644
--- a/hw/darwin/bundle/ko.lproj/Makefile.am
+++ b/hw/darwin/bundle/ko.lproj/Makefile.am
@@ -19,10 +19,12 @@ kolproj_DATA = \
 		    Credits.rtf Localizable.strings
 
 kolprojnibdir = $(kolprojdir)/MainMenu.nib
-kolprojnib_DATA = MainMenu.nib/classes.nib MainMenu.nib/objects.nib
+kolprojnib_DATA = \
+		       MainMenu.nib/classes.nib \
+		       MainMenu.nib/objects.nib
 
 InfoPlist.strings: $(srcdir)/../English.lproj/InfoPlist.strings.cpp
-	 $(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) | $(SED) -e's/__quote__/"/g' > $@
+	 $(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) | $(SED) -e's/__quote__/"/g' | iconv -t UTF-16 > $@
 
 XDarwinHelp.html: XDarwinHelp.html.cpp
 	$(RAWCPP) $(RAWCPPFLAGS) $(XDEFS) $(CPP_FILES_FLAGS) $< | $(CPP_SED_MAGIC) > $@
@@ -35,3 +37,4 @@ EXTRA_DIST = \
 	MainMenu.nib/classes.nib \
 	MainMenu.nib/objects.nib \
 	XDarwinHelp.html.cpp
+
diff --git a/hw/darwin/iokit/Makefile.am b/hw/darwin/iokit/Makefile.am
index 54464ae..77227d7 100644
--- a/hw/darwin/iokit/Makefile.am
+++ b/hw/darwin/iokit/Makefile.am
@@ -1,6 +1,6 @@
 noinst_LIBRARIES = libiokit.a
 
-AM_CFLAGS = @XORG_CFLAGS@ @DIX_CFLAGS@
+AM_CFLAGS = @XORG_CFLAGS@
 INCLUDES = -I. -I.. -I$(srcdir) -I$(srcdir)/.. @XORG_INCS@
 AM_DEFS =
 if XQUARTZ
diff --git a/hw/darwin/launcher/Info.plist b/hw/darwin/launcher/Info.plist
new file mode 100644
index 0000000..b5385b6
--- /dev/null
+++ b/hw/darwin/launcher/Info.plist
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>English</string>
+	<key>CFBundleExecutable</key>
+	<string>X11</string>
+	<key>CFBundleGetInfoString</key>
+	<string>2.0, Copyright © 2003-2007, Apple Inc.</string>
+	<key>CFBundleIconFile</key>
+	<string>X11.icns</string>
+	<key>CFBundleIdentifier</key>
+	<string>org.x.X11_launcher</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundleName</key>
+	<string>X11</string>
+	<key>CFBundlePackageType</key>
+	<string>APPL</string>
+	<key>CFBundleShortVersionString</key>
+	<string>2.0</string>
+	<key>CFBundleSignature</key>
+	<string>x11l</string>
+	<key>LSUIElement</key>
+	<string>1</string>
+	<key>NSHumanReadableCopyright</key>
+	<string>Copyright © 2007, Apple Inc.</string>
+</dict>
+</plist>
diff --git a/hw/darwin/launcher/X11.icns b/hw/darwin/launcher/X11.icns
new file mode 100644
index 0000000..d770e61
Binary files /dev/null and b/hw/darwin/launcher/X11.icns differ
diff --git a/hw/darwin/launcher/X11.xcodeproj/project.pbxproj b/hw/darwin/launcher/X11.xcodeproj/project.pbxproj
new file mode 100644
index 0000000..f82552a
--- /dev/null
+++ b/hw/darwin/launcher/X11.xcodeproj/project.pbxproj
@@ -0,0 +1,297 @@
+// !$*UTF8*$!
+{
+	archiveVersion = 1;
+	classes = {
+	};
+	objectVersion = 42;
+	objects = {
+
+/* Begin PBXBuildFile section */
+		527F241B0B5D938C007840A7 /* X11.icns in Resources */ = {isa = PBXBuildFile; fileRef = 50459C5F038587C60ECA21EC /* X11.icns */; };
+		527F241D0B5D938C007840A7 /* bundle-main.c in Sources */ = {isa = PBXBuildFile; fileRef = 50EE2AB703849F0B0ECA21EC /* bundle-main.c */; };
+		527F241F0B5D938C007840A7 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50F4F0A7039D6ACA0E82C0CB /* CoreFoundation.framework */; };
+		527F24370B5D9D89007840A7 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 527F24260B5D938C007840A7 /* Info.plist */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+		50459C5F038587C60ECA21EC /* X11.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = X11.icns; sourceTree = "<group>"; };
+		50EE2AB703849F0B0ECA21EC /* bundle-main.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = "bundle-main.c"; sourceTree = "<group>"; };
+		50F4F0A7039D6ACA0E82C0CB /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = "<absolute>"; };
+		527F24260B5D938C007840A7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = Info.plist; sourceTree = "<group>"; };
+		527F24270B5D938C007840A7 /* X11.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = X11.app; sourceTree = BUILT_PRODUCTS_DIR; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+		527F241E0B5D938C007840A7 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				527F241F0B5D938C007840A7 /* CoreFoundation.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+		195DF8CFFE9D517E11CA2CBB /* Products */ = {
+			isa = PBXGroup;
+			children = (
+				527F24270B5D938C007840A7 /* X11.app */,
+			);
+			name = Products;
+			sourceTree = "<group>";
+		};
+		20286C29FDCF999611CA2CEA /* X11 */ = {
+			isa = PBXGroup;
+			children = (
+				20286C2AFDCF999611CA2CEA /* Sources */,
+				20286C2CFDCF999611CA2CEA /* Resources */,
+				20286C32FDCF999611CA2CEA /* External Frameworks and Libraries */,
+				195DF8CFFE9D517E11CA2CBB /* Products */,
+				527F24260B5D938C007840A7 /* Info.plist */,
+			);
+			name = X11;
+			sourceTree = "<group>";
+		};
+		20286C2AFDCF999611CA2CEA /* Sources */ = {
+			isa = PBXGroup;
+			children = (
+				50EE2AB703849F0B0ECA21EC /* bundle-main.c */,
+			);
+			name = Sources;
+			sourceTree = "<group>";
+		};
+		20286C2CFDCF999611CA2CEA /* Resources */ = {
+			isa = PBXGroup;
+			children = (
+				50459C5F038587C60ECA21EC /* X11.icns */,
+			);
+			name = Resources;
+			sourceTree = "<group>";
+		};
+		20286C32FDCF999611CA2CEA /* External Frameworks and Libraries */ = {
+			isa = PBXGroup;
+			children = (
+				50F4F0A7039D6ACA0E82C0CB /* CoreFoundation.framework */,
+			);
+			name = "External Frameworks and Libraries";
+			sourceTree = "<group>";
+		};
+/* End PBXGroup section */
+
+/* Begin PBXHeadersBuildPhase section */
+		527F24170B5D938C007840A7 /* Headers */ = {
+			isa = PBXHeadersBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXHeadersBuildPhase section */
+
+/* Begin PBXNativeTarget section */
+		527F24160B5D938C007840A7 /* X11 */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = 527F24220B5D938C007840A7 /* Build configuration list for PBXNativeTarget "X11" */;
+			buildPhases = (
+				527F24170B5D938C007840A7 /* Headers */,
+				527F24180B5D938C007840A7 /* Resources */,
+				527F241C0B5D938C007840A7 /* Sources */,
+				527F241E0B5D938C007840A7 /* Frameworks */,
+				527F24210B5D938C007840A7 /* Rez */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = X11;
+			productName = X11;
+			productReference = 527F24270B5D938C007840A7 /* X11.app */;
+			productType = "com.apple.product-type.application";
+		};
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+		20286C28FDCF999611CA2CEA /* Project object */ = {
+			isa = PBXProject;
+			buildConfigurationList = 527F24080B5D8FFC007840A7 /* Build configuration list for PBXProject "X11" */;
+			compatibilityVersion = "Xcode 2.4";
+			hasScannedForEncodings = 1;
+			mainGroup = 20286C29FDCF999611CA2CEA /* X11 */;
+			projectDirPath = "";
+			projectRoot = "";
+			shouldCheckCompatibility = 1;
+			targets = (
+				527F24160B5D938C007840A7 /* X11 */,
+			);
+		};
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+		527F24180B5D938C007840A7 /* Resources */ = {
+			isa = PBXResourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				527F24370B5D9D89007840A7 /* Info.plist in Resources */,
+				527F241B0B5D938C007840A7 /* X11.icns in Resources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXRezBuildPhase section */
+		527F24210B5D938C007840A7 /* Rez */ = {
+			isa = PBXRezBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXRezBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+		527F241C0B5D938C007840A7 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				527F241D0B5D938C007840A7 /* bundle-main.c in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXSourcesBuildPhase section */
+
+/* Begin XCBuildConfiguration section */
+		527F24090B5D8FFC007840A7 /* Development */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				DSTROOT = "$(DSTROOT)";
+				SKIP_INSTALL = YES;
+			};
+			name = Development;
+		};
+		527F240A0B5D8FFC007840A7 /* Deployment */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				DSTROOT = "$(DSTROOT)";
+				SKIP_INSTALL = YES;
+			};
+			name = Deployment;
+		};
+		527F240B0B5D8FFC007840A7 /* Default */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				DSTROOT = "$(DSTROOT)";
+				SKIP_INSTALL = YES;
+			};
+			name = Default;
+		};
+		527F24230B5D938C007840A7 /* Development */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ARCHS = "$(NATIVE_ARCH_32_BIT)";
+				COPY_PHASE_STRIP = NO;
+				DSTROOT = "$(DSTROOT)";
+				FRAMEWORK_SEARCH_PATHS = "";
+				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+				HEADER_SEARCH_PATHS = /usr/X11/include;
+				INFOPLIST_FILE = Info.plist;
+				INSTALL_PATH = $DSTROOT/Applications/Utilties;
+				LIBRARY_SEARCH_PATHS = /usr/X11/lib;
+				OTHER_CFLAGS = "";
+				OTHER_LDFLAGS = (
+					"-lXau",
+					"-lxcb",
+					"-lX11",
+				);
+				OTHER_REZFLAGS = "";
+				PRODUCT_NAME = X11;
+				SECTORDER_FLAGS = "";
+				WARNING_CFLAGS = (
+					"-Wmost",
+					"-Wno-four-char-constants",
+					"-Wno-unknown-pragmas",
+				);
+				WRAPPER_EXTENSION = app;
+			};
+			name = Development;
+		};
+		527F24240B5D938C007840A7 /* Deployment */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				COPY_PHASE_STRIP = YES;
+				DSTROOT = "$(DSTROOT)";
+				FRAMEWORK_SEARCH_PATHS = "";
+				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+				HEADER_SEARCH_PATHS = /usr/X11/include;
+				INFOPLIST_FILE = Info.plist;
+				INSTALL_PATH = $DSTROOT/Applications/Utilties;
+				LIBRARY_SEARCH_PATHS = /usr/X11/lib;
+				OTHER_CFLAGS = "";
+				OTHER_LDFLAGS = "";
+				OTHER_REZFLAGS = "";
+				PRODUCT_NAME = X11;
+				SECTORDER_FLAGS = "";
+				WARNING_CFLAGS = (
+					"-Wmost",
+					"-Wno-four-char-constants",
+					"-Wno-unknown-pragmas",
+				);
+				WRAPPER_EXTENSION = app;
+			};
+			name = Deployment;
+		};
+		527F24250B5D938C007840A7 /* Default */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				DSTROOT = "$(DSTROOT)";
+				FRAMEWORK_SEARCH_PATHS = "";
+				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+				HEADER_SEARCH_PATHS = /usr/X11/include;
+				INFOPLIST_FILE = Info.plist;
+				INSTALL_PATH = $DSTROOT/Applications/Utilties;
+				LIBRARY_SEARCH_PATHS = /usr/X11/lib;
+				OTHER_CFLAGS = "";
+				OTHER_LDFLAGS = (
+					"-lXau",
+					"-lxcb",
+					"-lX11",
+				);
+				OTHER_REZFLAGS = "";
+				PRODUCT_NAME = X11;
+				SECTORDER_FLAGS = "";
+				WARNING_CFLAGS = (
+					"-Wmost",
+					"-Wno-four-char-constants",
+					"-Wno-unknown-pragmas",
+				);
+				WRAPPER_EXTENSION = app;
+			};
+			name = Default;
+		};
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+		527F24080B5D8FFC007840A7 /* Build configuration list for PBXProject "X11" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				527F24090B5D8FFC007840A7 /* Development */,
+				527F240A0B5D8FFC007840A7 /* Deployment */,
+				527F240B0B5D8FFC007840A7 /* Default */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Default;
+		};
+		527F24220B5D938C007840A7 /* Build configuration list for PBXNativeTarget "X11" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				527F24230B5D938C007840A7 /* Development */,
+				527F24240B5D938C007840A7 /* Deployment */,
+				527F24250B5D938C007840A7 /* Default */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Default;
+		};
+/* End XCConfigurationList section */
+	};
+	rootObject = 20286C28FDCF999611CA2CEA /* Project object */;
+}
diff --git a/hw/darwin/launcher/bundle-main.c b/hw/darwin/launcher/bundle-main.c
new file mode 100644
index 0000000..988c04f
--- /dev/null
+++ b/hw/darwin/launcher/bundle-main.c
@@ -0,0 +1,79 @@
+/* main.c -- X application launcher
+ 
+ Copyright (c) 2007 Apple Inc.
+ 
+ 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 <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+#include <CoreFoundation/CoreFoundation.h>
+
+#define DEFAULT_APP "/usr/X11/bin/xterm"
+
+int main (int argc, char **argv) {
+  char *command = DEFAULT_APP;
+  const char *newargv[5];
+  int child;
+  
+
+	CFPropertyListRef PlistRef = CFPreferencesCopyAppValue(CFSTR("app_to_run"),
+									kCFPreferencesCurrentApplication);
+	
+	if ((PlistRef == NULL) || (CFGetTypeID(PlistRef) != CFStringGetTypeID())) {
+		CFPreferencesSetAppValue(CFSTR("app_to_run"), CFSTR(DEFAULT_APP), 
+								 kCFPreferencesCurrentApplication);
+		CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
+	} else {
+		int len = CFStringGetLength((CFStringRef)PlistRef)+1;
+		command = (char *) malloc(len);
+		CFStringGetCString((CFStringRef)PlistRef, command, len,  kCFStringEncodingASCII);
+		fprintf(stderr, "command=%s\n", command);
+	}
+	
+	if (PlistRef) CFRelease(PlistRef);
+	
+	newargv[0] = "/usr/bin/login";
+	newargv[1] = "-fp";
+	newargv[2] = getlogin();
+	newargv[3] = command;
+	newargv[4] = NULL;
+
+    child = fork();
+	
+    switch (child) {
+    case -1:				/* error */
+      perror ("fork");
+      return EXIT_FAILURE;		
+    case 0:				    /* child */
+      execvp (newargv[0], (char **const) newargv);
+      perror ("Couldn't exec");
+      _exit (1);
+   }
+	
+    return 0;
+}
diff --git a/hw/darwin/quartz/Makefile.am b/hw/darwin/quartz/Makefile.am
index 993cdb0..bc6d4fc 100644
--- a/hw/darwin/quartz/Makefile.am
+++ b/hw/darwin/quartz/Makefile.am
@@ -1,14 +1,16 @@
 noinst_LIBRARIES = libXQuartz.a
 
-AM_CFLAGS = @XORG_CFLAGS@ @DIX_CFLAGS@
-AM_OBJCFLAGS = @XORG_CFLAGS@ @DIX_CFLAGS@
+AM_CFLAGS = @XORG_CFLAGS@
+AM_OBJCFLAGS = @XORG_CFLAGS@
 
 INCLUDES = -I$(srcdir) -I$(srcdir)/.. @XORG_INCS@
 AM_DEFS = -DHAS_CG_MACH_PORT -DHAS_KL_API
 if HAVE_X_PLUGIN
 AM_DEFS += -DBUILD_XPR
+XPR = xpr
 endif
 DEFS = @DEFS@ $(AM_DEFS) -DXBINDIR=\"${bindir}\"
+SUBDIRS = cr fullscreen $(XPR)
 
 libXQuartz_a_SOURCES = \
 		  Preferences.m \
@@ -37,6 +39,7 @@ install-exec-local:
 
 man1_MANS = XDarwinStartup.man
 
+
 EXTRA_DIST = \
 	applewmExt.h \
 	keysym2ucs.h \
diff --git a/hw/darwin/quartz/cr/Makefile.am b/hw/darwin/quartz/cr/Makefile.am
new file mode 100644
index 0000000..abfac99
--- /dev/null
+++ b/hw/darwin/quartz/cr/Makefile.am
@@ -0,0 +1,21 @@
+noinst_LIBRARIES = libcr.a
+AM_CFLAGS =  @XORG_CFLAGS@
+AM_OBJCFLAGS =  @XORG_CFLAGS@
+DEFS = @DEFS@ -DDEFER_NSWINDOW
+INCLUDES = @XORG_INCS@ \
+	   -I../fullscreen \
+	   -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../.. \
+	   -I$(top_srcdir)/miext/rootless \
+	   -I$(top_srcdir)/miext/rootless/safeAlpha \
+	   -I$(top_srcdir)/mi
+
+libcr_a_SOURCES = crAppleWM.m \
+	           crFrame.m \
+	           crScreen.m \
+	           ../fullscreen/quartzCursor.c \
+	           XView.m
+
+EXTRA_DIST = \
+	cr.h \
+	XView.h 
+	
diff --git a/hw/darwin/quartz/fullscreen/Makefile.am b/hw/darwin/quartz/fullscreen/Makefile.am
new file mode 100644
index 0000000..37c767c
--- /dev/null
+++ b/hw/darwin/quartz/fullscreen/Makefile.am
@@ -0,0 +1,9 @@
+noinst_LIBRARIES = libfullscreen.a
+AM_CFLAGS = @XORG_CFLAGS@
+INCLUDES = @XORG_INCS@ -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../.. 
+
+libfullscreen_a_SOURCES = fullscreen.c \
+			   quartzCursor.c
+
+EXTRA_DIST = \
+	quartzCursor.h
diff --git a/hw/darwin/quartz/xpr/Makefile.am b/hw/darwin/quartz/xpr/Makefile.am
new file mode 100644
index 0000000..980c7a4
--- /dev/null
+++ b/hw/darwin/quartz/xpr/Makefile.am
@@ -0,0 +1,30 @@
+noinst_LIBRARIES = libxpr.a
+AM_CFLAGS =  @XORG_CFLAGS@
+INCLUDES = @XORG_INCS@ \
+	   -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../.. \
+	   -I$(top_srcdir)/miext/rootless \
+	   -I$(top_srcdir)/miext/rootless/safeAlpha \
+	   -I$(top_srcdir)/miext
+
+libxpr_a_SOURCES = \
+	appledri.c \
+        dri.c \
+        xprAppleWM.c \
+        xprCursor.c \
+        xprFrame.c \
+        xprScreen.c \
+        x-hash.c \
+        x-hook.c \
+        x-list.c
+
+xprbundledir = @APPLE_APPLICATIONS_DIR@/Resources/xpr.bundle/Contents/MacOS
+
+EXTRA_DIST = \
+	dri.h \
+	dristruct.h \
+	x-hash.h \
+	x-hook.h \
+	x-list.h \
+	Xplugin.h \
+	xpr.h
+	
diff --git a/hw/darwin/quartz/xpr/appledri.h b/hw/darwin/quartz/xpr/appledri.h
index c4e43be..9c63037 100644
--- a/hw/darwin/quartz/xpr/appledri.h
+++ b/hw/darwin/quartz/xpr/appledri.h
@@ -1,3 +1,4 @@
+/* $XFree86: xc/lib/GL/dri/xf86dri.h,v 1.7 2000/12/07 20:26:02 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
diff --git a/hw/darwin/quartz/xpr/appledristr.h b/hw/darwin/quartz/xpr/appledristr.h
index 8649fd3..36a2e89 100644
--- a/hw/darwin/quartz/xpr/appledristr.h
+++ b/hw/darwin/quartz/xpr/appledristr.h
@@ -1,3 +1,4 @@
+/* $XFree86: xc/lib/GL/dri/xf86dristr.h,v 1.9 2001/03/21 16:01:08 dawes Exp $ */
 /**************************************************************************
 
 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
diff --git a/hw/darwin/utils/Makefile.am b/hw/darwin/utils/Makefile.am
index 11a2611..92bf151 100644
--- a/hw/darwin/utils/Makefile.am
+++ b/hw/darwin/utils/Makefile.am
@@ -7,5 +7,6 @@ dumpkeymap_LDFLAGS = -Wl,-framework,IOKit
 man1_MANS = dumpkeymap.man
 
 EXTRA_DIST = \
-            README.txt \
-            dumpkeymap.man
+	     README.txt \
+	     dumpkeymap.man
+
diff --git a/hw/darwin/utils/event_status_driver.h b/hw/darwin/utils/event_status_driver.h
new file mode 100644
index 0000000..8948f33
--- /dev/null
+++ b/hw/darwin/utils/event_status_driver.h
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * The contents of this file constitute Original Code as defined in and
+ * are subject to the Apple Public Source License Version 1.1 (the
+ * "License").  You may not use this file except in compliance with the
+ * License.  Please obtain a copy of the License at
+ * http://www.apple.com/publicsource and read it before using this file.
+ * 
+ * This Original Code and all software distributed under the License are
+ * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */
+/******************************************************************************
+	event_status_driver.h
+	API for the events status driver.
+	This file contains public API.
+	mpaque 11Oct91
+	
+	Copyright 1991 NeXT Computer, Inc.
+	
+	Modified:
+	
+******************************************************************************/
+
+#ifndef _DRIVERS_EVENT_STATUS_DRIVER_
+#define _DRIVERS_EVENT_STATUS_DRIVER_
+
+__BEGIN_DECLS
+
+#include <mach/port.h>
+#include <IOKit/hidsystem/IOLLEvent.h>
+#include <IOKit/hidsystem/IOHIDTypes.h>
+#include <AvailabilityMacros.h> 
+
+/*
+ * Event System Handle:
+ *
+ * Information used by the system between calls to NXOpenEventSystem and
+ * NXCloseEventSystem.  The application should not
+ * access any of the elements of this structure.
+ */
+typedef mach_port_t NXEventHandle;
+
+/* Open and Close */
+NXEventHandle NXOpenEventStatus(void);
+void NXCloseEventStatus(NXEventHandle handle);
+
+/* Status */
+extern NXEventSystemInfoType NXEventSystemInfo(NXEventHandle handle,
+				char *flavor,
+				int *evs_info,
+				unsigned int *evs_info_cnt);
+/* Keyboard */
+extern void NXSetKeyRepeatInterval(NXEventHandle handle, double seconds);
+extern double NXKeyRepeatInterval(NXEventHandle handle);
+extern void NXSetKeyRepeatThreshold(NXEventHandle handle, double threshold);
+extern double NXKeyRepeatThreshold(NXEventHandle handle);
+extern void NXResetKeyboard(NXEventHandle handle);
+
+/* Mouse */
+extern void NXSetClickTime(NXEventHandle handle, double seconds);
+extern double NXClickTime(NXEventHandle handle);
+extern void NXSetClickSpace(NXEventHandle handle, _NXSize_ *area);
+extern void NXGetClickSpace(NXEventHandle handle, _NXSize_ *area);
+extern void NXResetMouse(NXEventHandle handle);
+
+/* DEPRECATED API */
+
+/* NXIdleTime has been deprecated as this API does not take into account
+   events posted through the CG API set.  Instead, we strongly encourage 
+   developers to make use of the CGSSecondsSinceLastInputEvent API. */
+extern double NXIdleTime(NXEventHandle handle)
+AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4;
+
+/* These methods are NOT supported.   */
+extern NXKeyMapping *NXSetKeyMapping(NXEventHandle h, NXKeyMapping *keymap)
+AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4;
+
+extern int NXKeyMappingLength(NXEventHandle handle)
+AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4;
+
+extern NXKeyMapping *NXGetKeyMapping(NXEventHandle h, NXKeyMapping *keymap)
+AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4;
+
+/* These methods are NOT supported and will return NULL values.   */
+extern void NXSetMouseScaling(NXEventHandle handle, NXMouseScaling *scaling)
+AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4;
+
+extern void NXGetMouseScaling(NXEventHandle handle, NXMouseScaling *scaling)
+AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4;
+
+extern void NXSetAutoDimThreshold(NXEventHandle handle, double seconds)
+AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4;
+
+extern double NXAutoDimThreshold(NXEventHandle handle)
+AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4;
+
+extern double NXAutoDimTime(NXEventHandle handle)
+AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4;
+
+extern void NXSetAutoDimState(NXEventHandle handle, boolean_t dimmed)
+AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4;
+
+extern boolean_t NXAutoDimState(NXEventHandle handle)
+AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4;
+
+extern void NXSetAutoDimBrightness(NXEventHandle handle, double level)
+AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4;
+
+extern double NXAutoDimBrightness(NXEventHandle handle)
+AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4;
+
+extern void NXSetScreenBrightness(NXEventHandle handle, double level)
+AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4;
+
+extern double NXScreenBrightness(NXEventHandle handle)
+AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4;
+
+/* END DEPRECATED API */
+
+__END_DECLS
+
+#endif /*_DRIVERS_EVENT_STATUS_DRIVER_ */
+
commit 68ad49994fbdbaa7bb8fbdbd01895eeaea92378b
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Fri Oct 26 14:10:03 2007 -0700

    added Apple-specific defaults to configure.ac

diff --git a/configure.ac b/configure.ac
index dedc5f1..d69ede7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -509,7 +509,7 @@ AC_ARG_ENABLE(evi,            AS_HELP_STRING([--disable-evi], [Build Extended-Vi
 AC_ARG_ENABLE(multibuffer,    AS_HELP_STRING([--enable-multibuffer], [Build Multibuffer extension (default: disabled)]), [MULTIBUFFER=$enableval], [MULTIBUFFER=no])
 AC_ARG_ENABLE(fontcache,      AS_HELP_STRING([--enable-fontcache], [Build FontCache extension (default: disabled)]), [FONTCACHE=$enableval], [FONTCACHE=no])
 AC_ARG_ENABLE(dbe,            AS_HELP_STRING([--disable-dbe], [Build DBE extension (default: enabled)]), [DBE=$enableval], [DBE=yes])
-AC_ARG_ENABLE(xf86bigfont,    AS_HELP_STRING([--disable-xf86bigfont], [Build XF86 Big Font extension (default: enabled)]), [XF86BIGFONT=$enableval], [XF86BIGFONT=yes])
+AC_ARG_ENABLE(xf86bigfont,    AS_HELP_STRING([--enable-xf86bigfont], [Build XF86 Big Font extension (default: disabled)]), [XF86BIGFONT=$enableval], [XF86BIGFONT=no])
 AC_ARG_ENABLE(dpms,           AS_HELP_STRING([--disable-dpms], [Build DPMS extension (default: enabled)]), [DPMSExtension=$enableval], [DPMSExtension=yes])
 AC_ARG_ENABLE(config-dbus,    AS_HELP_STRING([--enable-config-dbus], [Build D-BUS API support (default: no)]), [CONFIG_DBUS_API=$enableval], [CONFIG_DBUS_API=no])
 AC_ARG_ENABLE(config-hal,     AS_HELP_STRING([--disable-config-hal], [Build HAL support (default: auto)]), [CONFIG_HAL=$enableval], [CONFIG_HAL=auto])
@@ -518,7 +518,7 @@ AC_ARG_ENABLE(xfree86-utils,     AS_HELP_STRING([--enable-xfree86-utils], [Build
 dnl DDXes.
 AC_ARG_ENABLE(xorg,    	      AS_HELP_STRING([--enable-xorg], [Build Xorg server (default: auto)]), [XORG=$enableval], [XORG=auto])
 AC_ARG_ENABLE(dmx,    	      AS_HELP_STRING([--enable-dmx], [Build DMX server (default: no)]), [DMX=$enableval], [DMX=no])
-AC_ARG_ENABLE(xvfb,    	      AS_HELP_STRING([--enable-xvfb], [Build Xvfb server (default: yes)]), [XVFB=$enableval], [XVFB=yes])
+AC_ARG_ENABLE(xvfb,    	      AS_HELP_STRING([--enable-xvfb], [Build Xvfb server (default: no)]), [XVFB=$enableval], [XVFB=yes])
 AC_ARG_ENABLE(xnest,   	      AS_HELP_STRING([--enable-xnest], [Build Xnest server (default: auto)]), [XNEST=$enableval], [XNEST=auto])
 AC_ARG_ENABLE(xwin,    	      AS_HELP_STRING([--enable-xwin], [Build XWin server (default: auto)]), [XWIN=$enableval], [XWIN=auto])
 AC_ARG_ENABLE(xprint,         AS_HELP_STRING([--enable-xprint], [Build Xprint extension and server (default: no)]), [XPRINT=$enableval], [XPRINT=no])
commit cbf775cde7bb737ddf71fa3aa5b08c859d516084
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Sat Nov 17 22:50:07 2007 +0100

    XKB: Generate correct key repeat events (bug #13114)
    
    Make sure we send the correct event for the type of device when we're
    sending key repeat events, which stops repeats being sent to incorrect
    windows.

diff --git a/xkb/xkbAccessX.c b/xkb/xkbAccessX.c
index 4c6e3d4..43b82e1 100644
--- a/xkb/xkbAccessX.c
+++ b/xkb/xkbAccessX.c
@@ -308,14 +308,19 @@ xkbControlsNotify	cn;
 static CARD32
 AccessXRepeatKeyExpire(OsTimerPtr timer,CARD32 now,pointer arg)
 {
-XkbSrvInfoPtr	xkbi= ((DeviceIntPtr)arg)->key->xkbInfo;
+DeviceIntPtr    dev = (DeviceIntPtr) arg;
+XkbSrvInfoPtr	xkbi = dev->key->xkbInfo;
 KeyCode		key;
+BOOL            is_core;
 
-    if (xkbi->repeatKey==0)
+    if (xkbi->repeatKey == 0)
 	return 0;
-    key= xkbi->repeatKey;
-    AccessXKeyboardEvent((DeviceIntPtr)arg,KeyRelease,key,True);
-    AccessXKeyboardEvent((DeviceIntPtr)arg,KeyPress,key,True);
+
+    is_core = (dev == inputInfo.keyboard);
+    key = xkbi->repeatKey;
+    AccessXKeyboardEvent(dev, is_core ? KeyRelease : DeviceKeyRelease, key,
+                         True);
+    AccessXKeyboardEvent(dev, is_core ? KeyPress : DeviceKeyPress, key, True);
     return xkbi->desc->ctrls->repeat_interval;
 }
 
commit 3e987ea670aadefeb3a6ad05d9a39dd7902985f9
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Thu Oct 18 17:44:14 2007 +0200

    EXA: Don't attempt to move in pixmaps that can't be accelerated.
    
    Fixes https://bugs.freedesktop.org/show_bug.cgi?id=12815 .
    
    (Related to commit 5d74416740de883b7ef0994afea4bbd4d3901be0 on master.)

diff --git a/exa/exa_migration.c b/exa/exa_migration.c
index 70d8e12..ff81041 100644
--- a/exa/exa_migration.c
+++ b/exa/exa_migration.c
@@ -319,6 +319,10 @@ exaMoveInPixmap (PixmapPtr pPixmap)
     if (pPixmap->drawable.bitsPerPixel < 8)
 	return;
 
+    if (pPixmap->drawable.width > pExaScr->info->maxX ||
+	pPixmap->drawable.height > pExaScr->info->maxY)
+	return;
+
     if (pExaPixmap->area == NULL) {
 	pExaPixmap->area =
 	    exaOffscreenAlloc (pScreen, pExaPixmap->fb_size,
commit 75b9dc907b332d64d074083cae0c6b099960f09b
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Thu Sep 27 13:08:41 2007 +0200

    EXA: Make sure tile offsets passed to drivers are never negative.
    
    Thanks to Björn Steinbrink for pointing out the problem on IRC.
    
    (cherry picked from commit 006f6525057970a74382132237b2131286ad147c with
     modifications.)

diff --git a/exa/exa_accel.c b/exa/exa_accel.c
index acc5dbe..aed4e42 100644
--- a/exa/exa_accel.c
+++ b/exa/exa_accel.c
@@ -1187,7 +1187,8 @@ exaFillRegionTiled (DrawablePtr	pDrawable,
 	    int dstY = pBox->y1;
 	    int tileY;
 
-	    tileY = (dstY - pDrawable->y - pPatOrg->y) % tileHeight;
+	    modulus(dstY - pDrawable->y - pPatOrg->y, tileHeight, tileY);
+
 	    while (height > 0) {
 		int width = pBox->x2 - pBox->x1;
 		int dstX = pBox->x1;
@@ -1198,7 +1199,8 @@ exaFillRegionTiled (DrawablePtr	pDrawable,
 		    h = height;
 		height -= h;
 
-		tileX = (dstX - pDrawable->x - pPatOrg->x) % tileWidth;
+		modulus(dstX - pDrawable->x - pPatOrg->x, tileWidth, tileX);
+
 		while (width > 0) {
 		    int w = tileWidth - tileX;
 		    if (w > width)
commit 732d586b0919e57ed836999f4117db3e776e2934
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Thu Sep 27 13:08:40 2007 +0200

    EXA: Punt on fallback case not handled correctly in exaFillRegionTiled.
    
    Fixes http://bugs.freedesktop.org/show_bug.cgi?id=12520 .
    
    (From master commit c7d6d1f5, modified to suit.)

diff --git a/exa/exa_accel.c b/exa/exa_accel.c
index cc383cc..acc5dbe 100644
--- a/exa/exa_accel.c
+++ b/exa/exa_accel.c
@@ -1223,7 +1223,8 @@ exaFillRegionTiled (DrawablePtr	pDrawable,
     }
 
 fallback:
-    if (alu != GXcopy || planemask != FB_ALLONES)
+    if (alu != GXcopy || planemask != FB_ALLONES || pPatOrg->x != 0 ||
+	pPatOrg->y != 0)
 	return FALSE;
     EXA_FALLBACK(("from %p to %p (%c,%c)\n", pTile, pDrawable,
 		  exaDrawableLocation(&pTile->drawable),
commit a3aed33244914b64d08630e19100c71ab81e1a81
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Nov 17 22:34:47 2007 +0100

    XKB: Don't ring the bell when we don't have a BellProc (bug #13246)
    (cherry picked from commit 55888552769ce6361174285b09dfb78ee22c170d)

diff --git a/xkb/xkbEvents.c b/xkb/xkbEvents.c
index e11b609..bf3e828 100644
--- a/xkb/xkbEvents.c
+++ b/xkb/xkbEvents.c
@@ -405,7 +405,8 @@ XID		winID = 0;
 
     if ((force||(xkbi->desc->ctrls->enabled_ctrls&XkbAudibleBellMask))&&
 							(!eventOnly)) {
-	(*kbd->kbdfeed->BellProc)(percent,kbd,(pointer)pCtrl,class);
+        if (kbd->kbdfeed->BellProc)
+            (*kbd->kbdfeed->BellProc)(percent,kbd,(pointer)pCtrl,class);
     }
     interest = kbd->xkb_interest;
     if ((!interest)||(force))
commit f3a5d67688a0f691ef23cb44b1fdda190b5b8bef
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Sep 23 12:43:31 2007 +0300

    GetKeyboardEvents: Reject out-of-range keycodes (bug #12528)
    
    We can only deal with keycodes between 8 and 255, so make sure that we never
    accept anything out of this range.
    (cherry picked from commit 0e800ca4651a947ccef239e6fe7bf64aab92257c)

diff --git a/dix/getevents.c b/dix/getevents.c
index f921a22..b70653d 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -409,6 +409,7 @@ GetKeyboardValuatorEvents(xEvent *events, DeviceIntPtr pDev, int type,
     if (!events)
         return 0;
 
+    /* DO NOT WANT */
     if (type != KeyPress && type != KeyRelease)
         return 0;
 
@@ -416,6 +417,9 @@ GetKeyboardValuatorEvents(xEvent *events, DeviceIntPtr pDev, int type,
         (pDev->coreEvents && !inputInfo.keyboard->key))
         return 0;
 
+    if (key_code < 8 || key_code > 255)
+        return 0;
+
     if (pDev->coreEvents)
         numEvents = 2;
     else
commit 35bf7c738a8286a382aeef38c0f035773b3ab96a
Author: Naoki Hamada <nao at tom-yam.or.jp>
Date:   Thu Oct 25 18:45:50 2007 +0300

    Input: Fix key down test (bug #12858)
    
    Fix the botched previous key_is_down test, which would give false positives.
    Also move key_autorepeats to a separate inline function.
    (cherry picked from commit 242f56f722243938e908d1957781ee53c2999783)

diff --git a/dix/getevents.c b/dix/getevents.c
index f92a021..f921a22 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -95,7 +95,14 @@ set_key_up(DeviceIntPtr pDev, int key_code)
 static Bool
 key_is_down(DeviceIntPtr pDev, int key_code)
 {
-    return pDev->key->postdown[key_code >> 3] >> (key_code & 7);
+    return !!(pDev->key->postdown[key_code >> 3] & (1 << (key_code & 7)));
+}
+
+static Bool
+key_autorepeats(DeviceIntPtr pDev, int key_code)
+{
+    return !!(pDev->kbdfeed->ctrl.autoRepeats[key_code >> 3] &
+              (1 << (key_code & 7)));
 }
 
 /**
@@ -440,10 +447,11 @@ GetKeyboardValuatorEvents(xEvent *events, DeviceIntPtr pDev, int type,
      * FIXME: In theory, if you're repeating with two keyboards in non-XKB,
      *        you could get unbalanced events here. */
     if (type == KeyPress && key_is_down(pDev, key_code)) {
+        /* If autorepeating is disabled either globally or just for that key,
+         * or we have a modifier, don't generate a repeat event. */
         if (!pDev->kbdfeed->ctrl.autoRepeat ||
-            pDev->key->modifierMap[key_code] ||
-            !(pDev->kbdfeed->ctrl.autoRepeats[key_code >> 3]
-                & (1 << (key_code & 7))))
+            !key_autorepeats(pDev, key_code) ||
+            pDev->key->modifierMap[key_code])
             return 0;
 
 #ifdef XKB
commit b3de1b9d375c98b72c88991ac2011e492254c61f
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Oct 26 09:12:15 2007 +0300

    XFree86 Misc/VidMode: Remove ridiculous debug ErrorFs
    
    When we're building with --enable-debug, don't emit an ErrorF every time a
    function gets called.
    (cherry picked from commit 6d59bb5709a99ab60b482bbf3393ebffda7f9407)

diff --git a/hw/xfree86/common/xf86MiscExt.c b/hw/xfree86/common/xf86MiscExt.c
index 655304e..c1b9c60 100644
--- a/hw/xfree86/common/xf86MiscExt.c
+++ b/hw/xfree86/common/xf86MiscExt.c
@@ -152,8 +152,6 @@ MiscExtGetMouseSettings(pointer *mouse, char **devname)
 {
     mseParamsPtr mseptr;
 
-    DEBUG_P("MiscExtGetMouseSettings");
-
     mseptr = MiscExtCreateStruct(MISC_POINTER);
     if (!mseptr)
 	return FALSE;
@@ -184,8 +182,6 @@ MiscExtGetMouseValue(pointer mouse, MiscExtMseValType valtype)
 {
     mseParamsPtr mse = mouse;
 
-    DEBUG_P("MiscExtGetMouseValue");
-
     switch (valtype) {
 	case MISC_MSE_PROTO:		return mse->type;
 	case MISC_MSE_BAUDRATE:		return mse->baudrate;
@@ -205,8 +201,6 @@ MiscExtSetMouseValue(pointer mouse, MiscExtMseValType valtype, int value)
 {
     mseParamsPtr mse = mouse;
 
-    DEBUG_P("MiscExtSetMouseValue");
-
     switch (valtype) {
 	case MISC_MSE_PROTO:
 	    mse->type = value;
@@ -251,8 +245,6 @@ MiscExtSetMouseDevice(pointer mouse, char* device)
 _X_EXPORT Bool
 MiscExtGetKbdSettings(pointer *kbd)
 {
-    DEBUG_P("MiscExtGetKbdSettings");
-
     return FALSE;
 }
 
@@ -290,8 +282,6 @@ MiscExtClientStateCallback(CallbackListPtr *callbacks,
 _X_EXPORT int
 MiscExtSetGrabKeysState(ClientPtr client, int state)
 {
-    DEBUG_P("MiscExtSetGrabKeysState");
-
     if (xf86Info.grabInfo.override == NULL ||
 	xf86Info.grabInfo.override == client) {
 	if (state == 0 && xf86Info.grabInfo.disabled == 0) {
@@ -318,8 +308,6 @@ MiscExtSetGrabKeysState(ClientPtr client, int state)
 _X_EXPORT pointer
 MiscExtCreateStruct(MiscExtStructType mse_or_kbd)
 {
-    DEBUG_P("MiscExtCreateStruct");
-    
     switch (mse_or_kbd) {
     case MISC_POINTER:
     {
@@ -348,8 +336,6 @@ MiscExtCreateStruct(MiscExtStructType mse_or_kbd)
 _X_EXPORT void
 MiscExtDestroyStruct(pointer structure, MiscExtStructType mse_or_kbd)
 {
-    DEBUG_P("MiscExtDestroyStruct");
-
     switch (mse_or_kbd) {
 	case MISC_POINTER:
 	case MISC_KEYBOARD:
@@ -410,8 +396,6 @@ MiscExtAuthorizeDevice(InputInfoPtr pInfo, char *device)
 _X_EXPORT MiscExtReturn
 MiscExtApply(pointer structure, MiscExtStructType mse_or_kbd)
 {
-    DEBUG_P("MiscExtApply");
-
     if (mse_or_kbd == MISC_POINTER) {
 	Bool protoChanged = FALSE;
 	int oldflags;
@@ -551,8 +535,6 @@ _X_EXPORT Bool
 MiscExtGetFilePaths(const char **configfile, const char **modulepath,
 		    const char **logfile)
 {
-    DEBUG_P("MiscExtGetFilePaths");
-
     *configfile = xf86ConfigFile;
     *modulepath = xf86ModulePath;
     *logfile    = xf86LogFile;
@@ -566,8 +548,6 @@ MiscExtPassMessage(int scrnIndex, const char *msgtype, const char *msgval,
 {
     ScrnInfoPtr pScr = xf86Screens[scrnIndex];
 
-    DEBUG_P("MiscExtPassMessage");
-
     if (*pScr->HandleMessage == NULL)
 	    return BadImplementation;
     return (*pScr->HandleMessage)(scrnIndex, msgtype, msgval, retstr);
diff --git a/hw/xfree86/common/xf86VidMode.c b/hw/xfree86/common/xf86VidMode.c
index fb91513..16a4d82 100644
--- a/hw/xfree86/common/xf86VidMode.c
+++ b/hw/xfree86/common/xf86VidMode.c
@@ -68,8 +68,6 @@ VidModeExtensionInit(ScreenPtr pScreen)
 #ifdef XF86VIDMODE
     VidModePtr pVidMode;
     
-    DEBUG_P("VidModeExtensionInit");
-
     if (!xf86GetVidModeEnabled()) {
 	DEBUG_P("!xf86GetVidModeEnabled()");
 	return FALSE;
@@ -109,8 +107,6 @@ VidModeClose(int i, ScreenPtr pScreen)
 {
     VidModePtr pVidMode = VMPTR(pScreen);
 
-    DEBUG_P("VidModeClose");
-
     /* This shouldn't happen */
     if (!pVidMode)
 	return FALSE;
@@ -132,8 +128,6 @@ VidModeAvailable(int scrnIndex)
     ScrnInfoPtr pScrn;
     VidModePtr pVidMode;
 
-    DEBUG_P("VidModeAvailable");
-
     if (VidModeIndex < 0) {
 	DEBUG_P("VidModeIndex < 0");
 	return FALSE;
@@ -159,8 +153,6 @@ VidModeGetCurrentModeline(int scrnIndex, pointer *mode, int *dotClock)
 {
     ScrnInfoPtr pScrn;
 
-    DEBUG_P("VidModeGetCurrentModeline");
-
     if (!VidModeAvailable(scrnIndex))
 	return FALSE;
 
@@ -176,8 +168,6 @@ VidModeGetDotClock(int scrnIndex, int Clock)
 {
     ScrnInfoPtr pScrn;
 
-    DEBUG_P("VidModeGetDotClock");
-
     if (!VidModeAvailable(scrnIndex))
 	return 0;
 
@@ -193,8 +183,6 @@ VidModeGetNumOfClocks(int scrnIndex, Bool *progClock)
 {
     ScrnInfoPtr pScrn;
 
-    DEBUG_P("VidModeGetNumOfClocks");
-
     if (!VidModeAvailable(scrnIndex))
 	return 0;
 
@@ -214,8 +202,6 @@ VidModeGetClocks(int scrnIndex, int *Clocks)
     ScrnInfoPtr pScrn;
     int i;
 
-    DEBUG_P("VidModeGetClocks");
-
     if (!VidModeAvailable(scrnIndex))
 	return FALSE;
 
@@ -237,8 +223,6 @@ VidModeGetFirstModeline(int scrnIndex, pointer *mode, int *dotClock)
     ScrnInfoPtr pScrn;
     VidModePtr pVidMode;
 
-    DEBUG_P("VidModeGetFirstModeline");
-
     if (!VidModeAvailable(scrnIndex))
 	return FALSE;
 
@@ -263,8 +247,6 @@ VidModeGetNextModeline(int scrnIndex, pointer *mode, int *dotClock)
     VidModePtr pVidMode;
     DisplayModePtr p;
 
-    DEBUG_P("VidModeGetNextModeline");
-
     if (!VidModeAvailable(scrnIndex))
 	return FALSE;
 
@@ -288,8 +270,6 @@ VidModeDeleteModeline(int scrnIndex, pointer mode)
 {
     ScrnInfoPtr pScrn;
 
-    DEBUG_P("VidModeDeleteModeline");
-
     if ((mode == NULL) || (!VidModeAvailable(scrnIndex)))
 	return FALSE;
 
@@ -303,8 +283,6 @@ VidModeZoomViewport(int scrnIndex, int zoom)
 {
     ScrnInfoPtr pScrn;
 
-    DEBUG_P("VidModeZoomViewPort");
-
     if (!VidModeAvailable(scrnIndex))
 	return FALSE;
 
@@ -318,8 +296,6 @@ VidModeSetViewPort(int scrnIndex, int x, int y)
 {
     ScrnInfoPtr pScrn;
 
-    DEBUG_P("VidModeSetViewPort");
-
     if (!VidModeAvailable(scrnIndex))
 	return FALSE;
 
@@ -341,8 +317,6 @@ VidModeGetViewPort(int scrnIndex, int *x, int *y)
 {
     ScrnInfoPtr pScrn;
 
-    DEBUG_P("VidModeGetViewPort");
-
     if (!VidModeAvailable(scrnIndex))
 	return FALSE;
 
@@ -359,8 +333,6 @@ VidModeSwitchMode(int scrnIndex, pointer mode)
     DisplayModePtr pTmpMode;
     Bool retval;
 
-    DEBUG_P("VidModeSwitchMode");
-
     if (!VidModeAvailable(scrnIndex))
 	return FALSE;
 
@@ -381,8 +353,6 @@ VidModeLockZoom(int scrnIndex, Bool lock)
 {
     ScrnInfoPtr pScrn;
 
-    DEBUG_P("VidModeLockZoom");
-
     if (!VidModeAvailable(scrnIndex))
 	return FALSE;
 
@@ -400,8 +370,6 @@ VidModeGetMonitor(int scrnIndex, pointer *monitor)
 {
     ScrnInfoPtr pScrn;
 
-    DEBUG_P("VidModeGetMonitor");
-
     if (!VidModeAvailable(scrnIndex))
 	return FALSE;
 
@@ -416,8 +384,6 @@ VidModeCheckModeForMonitor(int scrnIndex, pointer mode)
 {
     ScrnInfoPtr pScrn;
 
-    DEBUG_P("VidModeCheckModeForMonitor");
-
     if ((mode == NULL) || (!VidModeAvailable(scrnIndex)))
 	return MODE_ERROR;
 
@@ -431,8 +397,6 @@ VidModeCheckModeForDriver(int scrnIndex, pointer mode)
 {
     ScrnInfoPtr pScrn;
 
-    DEBUG_P("VidModeCheckModeForDriver");
-
     if ((mode == NULL) || (!VidModeAvailable(scrnIndex)))
 	return MODE_ERROR;
 
@@ -447,8 +411,6 @@ VidModeSetCrtcForMode(int scrnIndex, pointer mode)
     ScrnInfoPtr pScrn;
     DisplayModePtr ScreenModes;
     
-    DEBUG_P("VidModeSetCrtcForMode");
-
     if ((mode == NULL) || (!VidModeAvailable(scrnIndex)))
 	return;
 
@@ -467,8 +429,6 @@ VidModeAddModeline(int scrnIndex, pointer mode)
 {
     ScrnInfoPtr pScrn;
     
-    DEBUG_P("VidModeAddModeline");
-
     if ((mode == NULL) || (!VidModeAvailable(scrnIndex)))
 	return FALSE;
 
@@ -491,8 +451,6 @@ VidModeGetNumOfModes(int scrnIndex)
     pointer mode = NULL;
     int dotClock= 0, nummodes = 0;
   
-    DEBUG_P("VidModeGetNumOfModes");
-
     if (!VidModeGetFirstModeline(scrnIndex, &mode, &dotClock))
 	return nummodes;
 
@@ -509,8 +467,6 @@ VidModeSetGamma(int scrnIndex, float red, float green, float blue)
     ScrnInfoPtr pScrn;
     Gamma gamma;
 
-    DEBUG_P("VidModeSetGamma");
-
     if (!VidModeAvailable(scrnIndex))
 	return FALSE;
 
@@ -529,8 +485,6 @@ VidModeGetGamma(int scrnIndex, float *red, float *green, float *blue)
 {
     ScrnInfoPtr pScrn;
 
-    DEBUG_P("VidModeGetGamma");
-
     if (!VidModeAvailable(scrnIndex))
 	return FALSE;
 
commit 007e2239cf65535c4df3486e7b2cc42a4e86eb56
Author: Dodji Seketeli <dodji at seketeli.org>
Date:   Mon Nov 12 20:29:12 2007 +0100

    Xephyr: don't initialise the GLX extension

diff --git a/hw/kdrive/ephyr/ephyrinit.c b/hw/kdrive/ephyr/ephyrinit.c
index a76da03..c33892c 100644
--- a/hw/kdrive/ephyr/ephyrinit.c
+++ b/hw/kdrive/ephyr/ephyrinit.c
@@ -47,6 +47,7 @@ InitCard (char *name)
 void
 InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
 {
+  noGlxExtension=TRUE;
   KdInitOutput (pScreenInfo, argc, argv);
 }
 
commit 7f231de5e05a8755d76e18595c57baf2e239a4be
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Tue Nov 6 15:05:06 2007 +0000

    .gitignore: Ignore build directories
    
    Ignore directories people might use for building.
    (cherry picked from commit 36df34cffd0cfcfb250fb42596781b3d4e9871eb)

diff --git a/.gitignore b/.gitignore
index e4b3d31..887e4ad 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,6 +8,9 @@ Makefile.in
 *.a
 *.o
 *~
+.*.swp
+obj*
+build*
 aclocal.m4
 autom4te.cache
 compile
@@ -268,4 +271,3 @@ mfb/mfbteblack.c
 mfb/mfbtewhite.c
 mfb/mfbtileC.c
 mfb/mfbtileG.c
-.*.swp
commit 4c20d6104691b370f14216035b5ff07ad5633098
Author: Alan Coopersmith <alan.coopersmith at sun.com>
Date:   Fri Aug 17 15:29:16 2007 -0700

    Actually build Secure RPC authentication support (missed in modularization)
    (cherry picked from commit 23fbd5292d356067e85e1eec4eb4f743532b0503)

diff --git a/configure.ac b/configure.ac
index d9351ef..dedc5f1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -580,6 +580,7 @@ XTRANS_CONNECTION_FLAGS
 
 # Secure RPC detection macro from xtrans.m4
 XTRANS_SECURE_RPC_FLAGS
+AM_CONDITIONAL(SECURE_RPC, [test "x$SECURE_RPC" = xyes])
 
 AM_CONDITIONAL(INT10_VM86, [test "x$INT10" = xvm86])
 AM_CONDITIONAL(INT10_X86EMU, [test "x$INT10" = xx86emu])
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index ad97605..69fab5e 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -282,6 +282,9 @@
 /* Support MIT-SCREEN-SAVER extension */
 #undef SCREENSAVER
 
+/* Support Secure RPC ("SUN-DES-1") authentication for X11 clients */
+#undef SECURE_RPC
+
 /* Use a lock to prevent multiple servers on a display */
 #undef SERVER_LOCK
 
diff --git a/os/Makefile.am b/os/Makefile.am
index 53b2d7f..d2a9897 100644
--- a/os/Makefile.am
+++ b/os/Makefile.am
@@ -3,9 +3,9 @@ noinst_LTLIBRARIES = libos.la libcwrapper.la
 AM_CFLAGS = $(DIX_CFLAGS)
 
 # FIXME: Add support for these in configure.ac
-SECURERPC_SRCS = rpcauth.c
 INTERNALMALLOC_SRCS = xalloc.c
 
+SECURERPC_SRCS = rpcauth.c
 XCSECURITY_SRCS = secauth.c
 XDMCP_SRCS = xdmcp.c
 STRLCAT_SRCS = strlcat.c strlcpy.c
@@ -28,6 +28,10 @@ libos_la_SOURCES = 	\
 	xprintf.c	\
 	$(XORG_SRCS)
 
+if SECURE_RPC
+libos_la_SOURCES += $(SECURERPC_SRCS)
+endif
+
 if XCSECURITY
 libos_la_SOURCES += $(XCSECURITY_SRCS)
 endif
diff --git a/os/rpcauth.c b/os/rpcauth.c
index 603844a..3451ac1 100644
--- a/os/rpcauth.c
+++ b/os/rpcauth.c
@@ -39,7 +39,7 @@ from The Open Group.
 #ifdef SECURE_RPC
 
 #include <X11/X.h>
-#include "Xauth.h"
+#include <X11/Xauth.h>
 #include "misc.h"
 #include "os.h"
 #include "dixstruct.h"
@@ -135,7 +135,7 @@ CheckNetName (
 
 static char rpc_error[MAXNETNAMELEN+50];
 
-XID
+_X_HIDDEN XID
 SecureRPCCheck (unsigned short data_length, char *data, 
     ClientPtr client, char **reason)
 {
@@ -159,14 +159,14 @@ SecureRPCCheck (unsigned short data_length, char *data,
     return (XID) ~0L;
 }
     
-void
+_X_HIDDEN void
 SecureRPCInit (void)
 {
     if (rpc_id == ~0L)
 	AddAuthorization (9, "SUN-DES-1", 0, (char *) 0);
 }
 
-int
+_X_HIDDEN int
 SecureRPCAdd (unsigned short data_length, char *data, XID id)
 {
     if (data_length)
@@ -175,26 +175,26 @@ SecureRPCAdd (unsigned short data_length, char *data, XID id)
     return 1;
 }
 
-int
+_X_HIDDEN int
 SecureRPCReset (void)
 {
     rpc_id = (XID) ~0L;
     return 1;
 }
 
-XID
+_X_HIDDEN XID
 SecureRPCToID (unsigned short data_length, char *data)
 {
     return rpc_id;
 }
 
-int
+_X_HIDDEN int
 SecureRPCFromID (XID id, unsigned short *data_lenp, char **datap)
 {
     return 0;
 }
 
-int
+_X_HIDDEN int
 SecureRPCRemove (unsigned short data_length, char *data)
 {
     return 0;
commit f350c81a912cf5eab8d88a7800a828141945a2f0
Author: Matthias Hopf <mhopf at suse.de>
Date:   Wed Oct 24 20:31:51 2007 +0200

    Prefer configured DisplaySize to probed DDC data, if available.
    
    Based on patch by Hong Liu <hong.liu at intel.com>.
    (cherry picked from commit 48ca5961caee62f2980017a6bdc96a1b4c747727)

diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index 38435c9..7169f74 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -426,8 +426,18 @@ xf86RandR12CreateScreenResources (ScreenPtr pScreen)
 	    xf86OutputPtr   output = config->output[config->compat_output];
 	    xf86CrtcPtr	    crtc = output->crtc;
 
-	    if (crtc && crtc->mode.HDisplay &&
-		output->mm_width && output->mm_height)
+	    if (output->conf_monitor &&
+		(output->conf_monitor->mon_width  > 0 &&
+		 output->conf_monitor->mon_height > 0))
+	    {
+		/*
+		 * Prefer user configured DisplaySize
+		 */
+		mmWidth = output->conf_monitor->mon_width;
+		mmHeight = output->conf_monitor->mon_height;
+	    }
+	    else if (crtc && crtc->mode.HDisplay &&
+		     output->mm_width && output->mm_height)
 	    {
 		/*
 		 * If the output has a mode and a declared size, use that
commit c5501865703d5d4ee49e081b6075ab89a583deb6
Author: Keith Packard <keithp at koto.keithp.com>
Date:   Sun Aug 19 20:29:37 2007 -0700

    Screen size changing should leave FB alone when X is inactive.
    
    xf86RandR12ScreenSetSize must protect calls to EnableDisableFBAccess with
    suitable vtSema checks to avoid invoking driver code while the X server is
    inactive.
    (cherry picked from commit 265a633cf1fcbf497d6916d9e22403dffdde2e07)

diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index e46d8a0..38435c9 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -345,7 +345,7 @@ xf86RandR12ScreenSetSize (ScreenPtr	pScreen,
 	randrp->virtualX = pScrn->virtualX;
 	randrp->virtualY = pScrn->virtualY;
     }
-    if (pRoot)
+    if (pRoot && pScrn->vtSema)
 	(*pScrn->EnableDisableFBAccess) (pScreen->myNum, FALSE);
 
     /* Let the driver update virtualX and virtualY */
@@ -363,7 +363,7 @@ xf86RandR12ScreenSetSize (ScreenPtr	pScreen,
     xf86SetViewport (pScreen, 0, 0);
 
 finish:
-    if (pRoot)
+    if (pRoot && pScrn->vtSema)
 	(*pScrn->EnableDisableFBAccess) (pScreen->myNum, TRUE);
 #if RANDR_12_INTERFACE
     if (WindowTable[pScreen->myNum] && ret)
commit 9244b8e4a2274946b56d9cf6d43487e11c29f7d7
Author: Elvis Pranskevichus <el at prans.net>
Date:   Tue Nov 6 09:40:14 2007 +0000

    Config: D-Bus: Fix dbus_bus_request_name failure check
    
    The code in connect_hook incorrectly checks for dbus_bus_request_name failure.
    The dbus_bus_request_name error indicator is -1, not 0. This leads
    to subsequent assertion failure in libdbus.
    (cherry picked from commit ddce48ede036f3996f8e584b0012c396c5df42fb)

diff --git a/config/dbus.c b/config/dbus.c
index c867512..6fe0618 100644
--- a/config/dbus.c
+++ b/config/dbus.c
@@ -355,8 +355,8 @@ connect_hook(DBusConnection *connection, void *data)
 
     dbus_error_init(&error);
 
-    if (!dbus_bus_request_name(info->connection, info->busname,
-                               0, &error)) {
+    dbus_bus_request_name(info->connection, info->busname, 0, &error);
+    if (dbus_error_is_set(&error)) {
         ErrorF("[config/dbus] couldn't take over org.x.config: %s (%s)\n",
                error.name, error.message);
         goto err_start;
commit 0050d7e78d990fa945bd808554b0a86721262786
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Tue Nov 6 14:52:03 2007 +0000

    DIX: XKB: Set xkbInfo to NULL as well as freeing it (bug #10639)
    
    XkbRemoveResourceClient wants to access xkbInfo if it exists, so make
    sure we NULL it after freeing it.  It doesn't make much sense to move
    the RemoveResourceClient call first, as there's not much point in
    notifying clients while we're shutting the server down anyway.
    (cherry picked from commit 23023af1c5a33546a2027cad23a946a2882e9893)

diff --git a/dix/devices.c b/dix/devices.c
index e05444e..287d730 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -528,6 +528,7 @@ CloseDevice(DeviceIntPtr dev)
 	if (dev->key->xkbInfo)
 	    XkbFreeInfo(dev->key->xkbInfo);
 #endif
+        dev->key->xkbInfo = NULL;
 	xfree(dev->key->curKeySyms.map);
 	xfree(dev->key->modifierKeyMap);
 	xfree(dev->key);
commit 846745c58108856e5fc1b6d94c91a245cbc4f16f
Author: Markku Vire <markku.vire at movial.fi>
Date:   Thu Nov 1 22:43:04 2007 +0200

    Config: HAL: Touchpads are pointers too
    
    Treat touchpads -- not just mice -- as pointer devices.
    (cherry picked from commit 3f1b6765aadf665ede8253464da19a5878f16e56)

diff --git a/config/hal.c b/config/hal.c
index d7835e6..6bb449d 100644
--- a/config/hal.c
+++ b/config/hal.c
@@ -177,7 +177,8 @@ device_added(LibHalContext *hal_ctx, const char *udi)
         if (strcmp(props[i], "input.keys") == 0 ||
             strcmp(props[i], "input.keyboard") == 0)
             type |= TYPE_KEYS;
-        if (strcmp(props[i], "input.mouse") == 0)
+        if (strcmp(props[i], "input.mouse") == 0 ||
+            strcmp(props[i], "input.touchpad") == 0)
             type |= TYPE_POINTER;
     }
     libhal_free_string_array(props);
commit ab80b27250bb583e3a40bf92cfe5edc117e4bd58
Author: Mark Vytlacil <mrv at wi.rr.com>
Date:   Thu Nov 1 21:05:43 2007 +0200

    XFree86: Input: Save/restore errno around SIGIO (bug #10683)
    
    Make sure errno is saved and restored from the SIGIO handler, so errors
    from system calls in input handlers don't break the interrupted code.
    (cherry picked from commit 41c3069f7cf28155f8e6cfe0c10a12a1f5f76c7d)

diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index 91964c9..46fae08 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -510,12 +510,14 @@ static void
 xf86SigioReadInput(int fd,
 		   void *closure)
 {
+    int errno_save = errno;
     int sigstate = xf86BlockSIGIO();
     InputInfoPtr pInfo = (InputInfoPtr) closure;
 
     pInfo->read_input(pInfo);
 
     xf86UnblockSIGIO(sigstate);
+    errno = errno_save;
 }
 
 /*
commit ad05d5d035b32b05d304b2fc598f6fadeb077516
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Sep 23 17:17:03 2007 +0300

    Input: Generate XKB mapping changes for all core-sending devices (bug #12523)
    
    When we change the mapping on a core device, make sure we propagate this
    through to XKB for all extended devices as well.
    (cherry picked from commit 27ad5d74c20f01516a1bff73be283f8982fcf0fe)

diff --git a/Xi/exevents.c b/Xi/exevents.c
index fe297ab..377311e 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -73,6 +73,10 @@ SOFTWARE.
 #include "dixgrabs.h"	/* CreateGrab() */
 #include "scrnintstr.h"
 
+#ifdef XKB
+#include "xkbsrv.h"
+#endif
+
 #define WID(w) ((w) ? ((w)->drawable.id) : 0)
 #define AllModifiersMask ( \
 	ShiftMask | LockMask | ControlMask | Mod1Mask | Mod2Mask | \
@@ -942,7 +946,7 @@ SetModifierMapping(ClientPtr client, DeviceIntPtr dev, int len, int rlen,
 }
 
 void
-SendDeviceMappingNotify(CARD8 request,
+SendDeviceMappingNotify(ClientPtr client, CARD8 request,
 			KeyCode firstKeyCode, CARD8 count, DeviceIntPtr dev)
 {
     xEvent event;
@@ -957,6 +961,11 @@ SendDeviceMappingNotify(CARD8 request,
 	ev->count = count;
     }
 
+#ifdef XKB
+    if (request == MappingKeyboard || request == MappingModifier)
+        XkbApplyMappingChange(dev, request, firstKeyCode, count, client);
+#endif
+
     SendEventToAllWindows(dev, DeviceMappingNotifyMask, (xEvent *) ev, 1);
 }
 
@@ -992,7 +1001,7 @@ ChangeKeyMapping(ClientPtr client,
     keysyms.map = map;
     if (!SetKeySymsMap(&k->curKeySyms, &keysyms))
 	return BadAlloc;
-    SendDeviceMappingNotify(MappingKeyboard, firstKeyCode, keyCodes, dev);
+    SendDeviceMappingNotify(client, MappingKeyboard, firstKeyCode, keyCodes, dev);
     return client->noClientException;
 }
 
diff --git a/Xi/setbmap.c b/Xi/setbmap.c
index bdfa513..1f5970d 100644
--- a/Xi/setbmap.c
+++ b/Xi/setbmap.c
@@ -134,7 +134,7 @@ ProcXSetDeviceButtonMapping(ClientPtr client)
     }
 
     if (ret != MappingBusy)
-	SendDeviceMappingNotify(MappingPointer, 0, 0, dev);
+	SendDeviceMappingNotify(client, MappingPointer, 0, 0, dev);
     return Success;
 }
 
diff --git a/Xi/setmmap.c b/Xi/setmmap.c
index 0078499..e30213e 100644
--- a/Xi/setmmap.c
+++ b/Xi/setmmap.c
@@ -122,7 +122,7 @@ ProcXSetDeviceModifierMapping(ClientPtr client)
     if (ret == MappingSuccess || ret == MappingBusy || ret == MappingFailed) {
 	rep.success = ret;
 	if (ret == MappingSuccess)
-	    SendDeviceMappingNotify(MappingModifier, 0, 0, dev);
+	    SendDeviceMappingNotify(client, MappingModifier, 0, 0, dev);
 	WriteReplyToClient(client, sizeof(xSetDeviceModifierMappingReply),
 			   &rep);
     } else {
diff --git a/dix/devices.c b/dix/devices.c
index 9f3c576..e05444e 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -1208,10 +1208,9 @@ SendMappingNotify(unsigned request, unsigned firstKeyCode, unsigned count,
     }
 #ifdef XKB
     if (!noXkbExtension &&
-	((request == MappingKeyboard) || (request == MappingModifier))) {
-	XkbApplyMappingChange(inputInfo.keyboard,request,firstKeyCode,count,
-									client);
-    }
+	((request == MappingKeyboard) || (request == MappingModifier)))
+        XkbApplyMappingChange(inputInfo.keyboard, request, firstKeyCode, count,
+                              client);
 #endif
 
    /* 0 is the server client */
@@ -1359,6 +1358,7 @@ int
 ProcSetModifierMapping(ClientPtr client)
 {
     xSetModifierMappingReply rep;
+    DeviceIntPtr dev;
     REQUEST(xSetModifierMappingReq);
     
     REQUEST_AT_LEAST_SIZE(xSetModifierMappingReq);
@@ -1374,8 +1374,10 @@ ProcSetModifierMapping(ClientPtr client)
     rep.success = DoSetModifierMapping(client, (KeyCode *)&stuff[1],
                                        stuff->numKeyPerModifier);
 
-    /* FIXME: Send mapping notifies for all the extended devices as well. */
     SendMappingNotify(MappingModifier, 0, 0, client);
+    for (dev = inputInfo.devices; dev; dev = dev->next)
+        if (dev->key && dev->coreEvents)
+            SendDeviceMappingNotify(client, MappingModifier, 0, 0, dev);
     WriteReplyToClient(client, sizeof(xSetModifierMappingReply), &rep);
     return client->noClientException;
 }
@@ -1438,16 +1440,19 @@ ProcChangeKeyboardMapping(ClientPtr client)
     keysyms.maxKeyCode = stuff->firstKeyCode + stuff->keyCodes - 1;
     keysyms.mapWidth = stuff->keySymsPerKeyCode;
     keysyms.map = (KeySym *)&stuff[1];
-    for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
-        if ((pDev->coreEvents || pDev == inputInfo.keyboard) && pDev->key) {
+    for (pDev = inputInfo.devices; pDev; pDev = pDev->next)
+        if ((pDev->coreEvents || pDev == inputInfo.keyboard) && pDev->key)
             if (!SetKeySymsMap(&pDev->key->curKeySyms, &keysyms))
                 return BadAlloc;
-        }
-    }
 
-    /* FIXME: Send mapping notifies for all the extended devices as well. */
     SendMappingNotify(MappingKeyboard, stuff->firstKeyCode, stuff->keyCodes,
                       client);
+    for (pDev = inputInfo.devices; pDev; pDev = pDev->next)
+        if (pDev->key && pDev->coreEvents)
+            SendDeviceMappingNotify(client, MappingKeyboard,
+                                    stuff->firstKeyCode, stuff->keyCodes,
+                                    pDev);
+
     return client->noClientException;
 }
 
diff --git a/include/exevents.h b/include/exevents.h
index 9f15f50..0892f4d 100644
--- a/include/exevents.h
+++ b/include/exevents.h
@@ -131,6 +131,7 @@ extern int SetModifierMapping(
 	KeyClassPtr *          /* k */);
 
 extern void SendDeviceMappingNotify(
+        ClientPtr              /* client, */,
 	CARD8                  /* request, */,
 	KeyCode                /* firstKeyCode */,
 	CARD8                  /* count */,
commit 84040b655e3ea9188a6c9d6dafea429ffc4690de
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Thu Sep 6 18:57:00 2007 +0930

    xfree86: wrap keyboard devices for XKB.
    
    Call ProcessOtherEvents first, then for all keyboard devices let them be
    wrapped by XKB. This way all XI events will go through XKB.
    
    Note that the VCK is still not wrapped, so core events will bypass XKB.
    
    (cherry picked from commit d627061b48ae06d27b37be209d67a3f4f2388dd3)
    (cherry picked from commit 8ead41388e36e21eea6fa0408c847f174911eab0)

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index e45d44c..b939fb7 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -165,6 +165,11 @@ xf86ActivateDevice(LocalDevicePtr local)
         dev->coreEvents = local->flags & XI86_ALWAYS_CORE;
         RegisterOtherDevice(dev);
 
+#ifdef XKB
+        if (!noXkbExtension)
+            XkbSetExtension(dev, ProcessKeyboardEvent);
+#endif
+
         if (serverGeneration == 1) 
             xf86Msg(X_INFO, "XINPUT: Adding extended input device \"%s\" (type: %s)\n",
                     local->name, local->type_name);
commit e26e93c54e54ab4010dfdede47c3e56e4418bcbd
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Oct 27 21:32:47 2007 +0300

    XKB: Cope with all events in XkbProcessKeyboardEvent
    
    Cope with Xi and pointer events in the (now increasingly misnamed)
    XkbProcessKeyboardEvent.  If it's the wrong type, call through the wrapping
    chain to get out; else, process it.
    (cherry picked from commit e717cf08e99746761d74289c426bbd84176f4435)

diff --git a/xkb/xkbPrKeyEv.c b/xkb/xkbPrKeyEv.c
index ba3fcc0..3fec4f5 100644
--- a/xkb/xkbPrKeyEv.c
+++ b/xkb/xkbPrKeyEv.c
@@ -36,11 +36,11 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include <X11/keysym.h>
 #include "misc.h"
 #include "inputstr.h"
+#include "exevents.h"
 #include <xkbsrv.h>
 #include <ctype.h>
 #define EXTENSION_EVENT_BASE 64
 
-
 /***====================================================================***/
 
 void
@@ -115,12 +115,12 @@ int             xiEvent;
 		break;
 	    case XkbKB_Lock:
 		if ( xE->u.u.type == KeyRelease || 
-                        xE->u.u.type == DeviceKeyRelease)
+                        xE->u.u.type == DeviceKeyRelease) {
 		    return;
+                }
 		else {
 		    int	bit= 1<<(key&7);
-		    if ( keyc->down[key>>3]&bit )
-                    {
+		    if ( keyc->down[key>>3]&bit ) {
                         if (xiEvent)
                             xE->u.u.type = DeviceKeyRelease;
                         else
@@ -193,23 +193,42 @@ int             xiEvent;
 void
 ProcessKeyboardEvent(xEvent *xE,DeviceIntPtr keybd,int count)
 {
-KeyClassPtr	keyc = keybd->key;
-XkbSrvInfoPtr	xkbi;
 
-    xkbi= keyc->xkbInfo;
+    KeyClassPtr keyc = keybd->key;
+    XkbSrvInfoPtr xkbi = NULL;
+    ProcessInputProc backup_proc;
+    xkbDeviceInfoPtr xkb_priv = XKBDEVICEINFO(keybd);
+    int is_press = (xE->u.u.type == KeyPress || xE->u.u.type == DeviceKeyPress);
+    int is_release = (xE->u.u.type == KeyRelease ||
+                      xE->u.u.type == DeviceKeyRelease);
+
+    if (keyc)
+        xkbi = keyc->xkbInfo;
+
+    /* We're only interested in key events. */
+    if (!is_press && !is_release) {
+        UNWRAP_PROCESS_INPUT_PROC(keybd, xkb_priv, backup_proc);
+        keybd->public.processInputProc(xE, keybd, count);
+        COND_WRAP_PROCESS_INPUT_PROC(keybd, xkb_priv, backup_proc,
+                                     xkbUnwrapProc);
+        return;
+    }
 
-#ifdef DEBUG
-    if (xkbDebugFlags&0x8) {
-	int key= xE->u.u.detail;
-	ErrorF("PKE: Key %d %s\n",key,(xE->u.u.type==KeyPress?"down":"up"));
+    /* If AccessX filters are active, then pass it through to
+     * AccessXFilter{Press,Release}Event; else, punt to
+     * XkbProcessKeyboardEvent.
+     *
+     * If AXF[PK]E don't intercept anything (which they probably won't),
+     * they'll punt through XPKE anyway. */
+    if ((xkbi->desc->ctrls->enabled_ctrls & XkbAllFilteredEventsMask)) {
+        if (is_press)
+            AccessXFilterPressEvent(xE, keybd, count);
+        else if (is_release)
+            AccessXFilterReleaseEvent(xE, keybd, count);
     }
-#endif
-    if ((xkbi->desc->ctrls->enabled_ctrls&XkbAllFilteredEventsMask)==0)
-	XkbProcessKeyboardEvent(xE,keybd,count);
-    else if (xE->u.u.type==KeyPress || xE->u.u.type==DeviceKeyPress)
-	AccessXFilterPressEvent(xE,keybd,count);
-    else if (xE->u.u.type==KeyRelease || xE->u.u.type==DeviceKeyRelease)
-	AccessXFilterReleaseEvent(xE,keybd,count);
+    else {
+        XkbProcessKeyboardEvent(xE, keybd, count);
+    }
+    
     return;
 }
-
commit 37c690cfa4e9055209732ab5431fffb8886c7d67
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Oct 27 21:31:39 2007 +0300

    XKB: Don't update indicators on all devices, add missing include file
    
    Don't get XkbUpdateIndicators to update the indicators on all our devices: we
    already deal with that ourselves.
    Add exevents.h include to get more (proto)types.
    (cherry picked from commit 9db8846fa53d91193bbfe541b244e2326440011d)

diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
index e50dbfe..8ddbdba 100644
--- a/xkb/xkbActions.c
+++ b/xkb/xkbActions.c
@@ -36,6 +36,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include <X11/keysym.h>
 #include "misc.h"
 #include "inputstr.h"
+#include "exevents.h"
 #include <xkbsrv.h>
 #include "xkb.h"
 #include <ctype.h>
@@ -80,8 +81,7 @@ XkbSetExtension(DeviceIntPtr device, ProcessInputProc proc)
     xkbPrivPtr->unwrapProc = NULL;
 
     device->devPrivates[xkbDevicePrivateIndex].ptr = xkbPrivPtr;
-    WRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr,
-			    proc,xkbUnwrapProc);
+    WRAP_PROCESS_INPUT_PROC(device, xkbPrivPtr, proc, xkbUnwrapProc);
 }
 
 extern	void	ProcessOtherEvent(
@@ -400,7 +400,6 @@ _XkbFilterLockState(	XkbSrvInfoPtr	xkbi,
 			unsigned	keycode,
 			XkbAction *	pAction)
 {
-
     if (pAction&&(pAction->type==XkbSA_LockGroup)) {
 	if (pAction->group.flags&XkbSA_GroupAbsolute)
 	     xkbi->state.locked_group= XkbSAGroup(&pAction->group);
@@ -1287,8 +1286,9 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev);
         if (keyEvent)
 	    keyc->modifierMap[key] = realMods;
     }
-    else if (keyEvent)
+    else if (keyEvent) {
 	FixKeyState(xE,dev);
+    }
 
     xkbi->prev_state= oldState;
     XkbComputeDerivedState(xkbi);
@@ -1310,7 +1310,7 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev);
     if (changed) {
 	XkbEventCauseRec	cause;
 	XkbSetCauseKey(&cause,key,xE->u.u.type);
-	XkbUpdateIndicators(dev,changed,True,NULL,&cause);
+	XkbUpdateIndicators(dev,changed,False,NULL,&cause);
     }
     return;
 }
commit 1dce9c20283279eac4d6e5cafc4f73a333548c07
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Wed Sep 26 18:04:59 2007 +0930

    xkb: Unwrap properly in ProcessPointerEvent.
    
    Instead of hardcoding CoreProcessPointerEvent, actually try to unwrap properly
    and then call the unwrapped processInputProc. Seems to be a better idea,
    especially since it makes stuff actually work...
    (cherry picked from commit 8f9bf927e1beecf9b9ec8877131ec12c765e4d84)
    (cherry picked from commit ee3aa948eb8ed181d037294ed87df6ceec81684e)

diff --git a/xkb/xkbAccessX.c b/xkb/xkbAccessX.c
index 2954a0c..4c6e3d4 100644
--- a/xkb/xkbAccessX.c
+++ b/xkb/xkbAccessX.c
@@ -692,6 +692,8 @@ ProcessPointerEvent(	register xEvent  *	xE,
 DeviceIntPtr	dev = (DeviceIntPtr)LookupKeyboardDevice();
 XkbSrvInfoPtr	xkbi = dev->key->xkbInfo;
 unsigned 	changed = 0;
+ProcessInputProc backupproc;
+xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(mouse);
 
     xkbi->shiftKeyCount = 0;
     xkbi->lastPtrEventTime= xE->u.keyButtonPointer.time;
@@ -703,7 +705,26 @@ unsigned 	changed = 0;
 	xkbi->lockedPtrButtons&= ~(1<<(xE->u.u.detail&0x7));
 	changed |= XkbPointerButtonMask;
     }
-    CoreProcessPointerEvent(xE,mouse,count);
+
+    /* Guesswork. mostly. 
+     * xkb actuall goes through some effort to transparently wrap the
+     * processInputProcs (see XkbSetExtension). But we all love fun, so the
+     * previous XKB implementation just hardcoded the CPPE call here instead
+     * of unwrapping like anybody with any sense of decency would do. 
+     * I got no clue what the correct thing to do is, but my guess is that
+     * it's not hardcoding. I may be wrong. whatever it is, don't come whining
+     * to me. I just work here. 
+     *
+     * Anyway. here's the old call, if you don't like the wrapping, revert it.
+     *
+     * CoreProcessPointerEvent(xE,mouse,count);
+     *
+     *          see. it's still steaming. told you. (whot)
+     */
+    UNWRAP_PROCESS_INPUT_PROC(mouse, xkbPrivPtr, backupproc);
+    mouse->public.processInputProc(xE, mouse, count);
+    COND_WRAP_PROCESS_INPUT_PROC(mouse, xkbPrivPtr,
+				     backupproc, xkbUnwrapProc);
 
     xkbi->state.ptr_buttons = mouse->button->state;
     
commit 940cce1f4856a3ffc6fdba9c807c8238ed1acf8b
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Thu Sep 27 11:44:03 2007 +0930

    xkb: xkbHandleActions: let wrapping take care of event delivery.
    
    This is hopefully better than hardcodey calling CoreProcessPointerEvent.
    (cherry picked from commit 32d0440c7f6e604807cb14dd32349df6f22c903b)
    (cherry picked from commit d3588a0aee33fbd233082f881c0d37152c6d4d8b)

diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
index c62910f..e50dbfe 100644
--- a/xkb/xkbActions.c
+++ b/xkb/xkbActions.c
@@ -1148,7 +1148,6 @@ XkbAction	act;
 XkbFilterPtr	filter;
 Bool		keyEvent;
 Bool		pressEvent;
-Bool		xiEvent;
 ProcessInputProc backupproc;
     
 xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev);
@@ -1173,9 +1172,6 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev);
 		(xE->u.u.type==KeyRelease)||(xE->u.u.type==DeviceKeyRelease));
     pressEvent= (xE->u.u.type==KeyPress)||(xE->u.u.type==DeviceKeyPress)||
 		 (xE->u.u.type==ButtonPress)||(xE->u.u.type==DeviceButtonPress);
-    xiEvent= (xE->u.u.type==DeviceKeyPress)||(xE->u.u.type==DeviceKeyRelease)||
-	     (xE->u.u.type==DeviceButtonPress)||
-	     (xE->u.u.type==DeviceButtonRelease);
 
     if (pressEvent) {
 	if (keyEvent)	
@@ -1282,20 +1278,14 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev);
 	if (keyEvent) {
 	    realMods = keyc->modifierMap[key];
 	    keyc->modifierMap[key] = 0;
-	    UNWRAP_PROCESS_INPUT_PROC(dev,xkbPrivPtr, backupproc);
-	    dev->public.processInputProc(xE,dev,count);
-	    COND_WRAP_PROCESS_INPUT_PROC(dev, xkbPrivPtr,
-					 backupproc,xkbUnwrapProc);
-	    keyc->modifierMap[key] = realMods;
-	}
-	else 
-        {
-            if (xE->u.u.type & EXTENSION_EVENT_BASE)
-                ProcessOtherEvent(xE, dev, count);
-            else
-                CoreProcessPointerEvent(xE,dev,count);
-            
         }
+
+        UNWRAP_PROCESS_INPUT_PROC(dev,xkbPrivPtr, backupproc);
+        dev->public.processInputProc(xE,dev,count);
+        COND_WRAP_PROCESS_INPUT_PROC(dev, xkbPrivPtr,
+                                     backupproc,xkbUnwrapProc);
+        if (keyEvent)
+	    keyc->modifierMap[key] = realMods;
     }
     else if (keyEvent)
 	FixKeyState(xE,dev);
commit 5909fb3c406356505440af8d53785d9ee06ab9be
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Wed Sep 12 17:40:11 2007 +0930

    dix: don't compress motion events from different devices (EventEnqueue)
    
    (cherry picked from commit 8840829ab93c4eb62eb58753c015da5307133fe5)
    (cherry picked from commit 352c5a311200bf491153fe9ef16126c5877a57bb)

diff --git a/dix/events.c b/dix/events.c
index d2591de..5bd67e3 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -1098,9 +1098,10 @@ EnqueueEvent(xEvent *xE, DeviceIntPtr device, int count)
 #endif
 	sprite.hotPhys.x = XE_KBPTR.rootX;
 	sprite.hotPhys.y = XE_KBPTR.rootY;
-	/* do motion compression */
+	/* do motion compression, but not if from different devices */
 	if (tail &&
 	    (tail->event->u.u.type == MotionNotify) &&
+            (tail->device == device) &&
 	    (tail->pScreen == sprite.hotPhys.pScreen))
 	{
 	    tail->event->u.keyButtonPointer.rootX = sprite.hotPhys.x;
commit 600752bece350592f374470dd54b9e1cd2900d0b
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Thu Sep 6 18:52:02 2007 +0930

    dix: add XI event support to FixKeyState.
    
    FixKeyState needs to be able to handle XI events, otherwise we get "impossible
    keyboard events" on server zaps and other special key combos.
    (cherry picked from commit 5ee409794ee604fcf84886f70429fc2d6b1ff4f1)
    (cherry picked from commit 8d3d027062c105b50863dce43b8070ec560bc12e)

diff --git a/dix/events.c b/dix/events.c
index 7b4cab0..d2591de 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -3095,7 +3095,7 @@ drawable.id:0;
 #ifdef XKB
 /* This function is used to set the key pressed or key released state -
    this is only used when the pressing of keys does not cause 
-   CoreProcessKeyEvent to be called, as in for example Mouse Keys.
+   the device's processInputProc to be called, as in for example Mouse Keys.
 */
 void
 FixKeyState (xEvent *xE, DeviceIntPtr keybd)
@@ -3108,22 +3108,19 @@ FixKeyState (xEvent *xE, DeviceIntPtr keybd)
     kptr = &keyc->down[key >> 3];
     bit = 1 << (key & 7);
 
-    if (((xE->u.u.type==KeyPress)||(xE->u.u.type==KeyRelease))) {
+    if (((xE->u.u.type==KeyPress)||(xE->u.u.type==KeyRelease)||
+         (xE->u.u.type==DeviceKeyPress)||(xE->u.u.type==DeviceKeyRelease))
+            ) {
 	DebugF("FixKeyState: Key %d %s\n",key,
-			(xE->u.u.type==KeyPress?"down":"up"));
+               (((xE->u.u.type==KeyPress)||(xE->u.u.type==DeviceKeyPress))?"down":"up"));
     }
 
-    switch (xE->u.u.type)
-    {
-	case KeyPress: 
+    if (xE->u.u.type == KeyPress || xE->u.u.type == DeviceKeyPress)
 	    *kptr |= bit;
-	    break;
-	case KeyRelease: 
+    else if (xE->u.u.type == KeyRelease || xE->u.u.type == DeviceKeyRelease)
 	    *kptr &= ~bit;
-	    break;
-	default: 
-	    FatalError("Impossible keyboard event");
-    }
+    else
+        FatalError("Impossible keyboard event");
 }
 #endif
 
commit 15117d47bf883f3eefc57404f1dfc0c933ab054a
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Thu Sep 6 18:49:57 2007 +0930

    xkb: enable XI event processing for xkb.
    
    XI events can now take the same processing paths as core events, and should do
    the correct state changes etc.
    
    There's some cases where XKB will use KeyPress as type for an event to be
    delivered to the client. Stuck warnings in, not sure what the correct solution
    is yet.
    
    (cherry picked from commit 6334d4e7be18de5f237c12a6dc20f75aa23477d0 with some
     additional compile fixes and non-MPX adaptations)
    (cherry picked from commit 99e826e867c1c5520153c539ba07a884aec88d0c)

diff --git a/include/xkbsrv.h b/include/xkbsrv.h
index d78a68a..167dbec 100644
--- a/include/xkbsrv.h
+++ b/include/xkbsrv.h
@@ -314,8 +314,9 @@ extern CARD32	xkbDebugFlags;
 #define	_XkbErrCode3(a,b,c)	_XkbErrCode2(a,(((unsigned int)(b))<<16)|(c))
 #define	_XkbErrCode4(a,b,c,d) _XkbErrCode3(a,b,((((unsigned int)(c))<<8)|(d)))
 
-extern	int	DeviceKeyPress,DeviceKeyRelease;
+extern	int	DeviceKeyPress,DeviceKeyRelease,DeviceMotionNotify;
 extern	int	DeviceButtonPress,DeviceButtonRelease;
+extern	int	DeviceEnterNotify,DeviceLeaveNotify;
 
 #ifdef XINPUT
 #define	_XkbIsPressEvent(t)	(((t)==KeyPress)||((t)==DeviceKeyPress))
diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
index 2c7c2cd..c62910f 100644
--- a/xkb/xkbActions.c
+++ b/xkb/xkbActions.c
@@ -39,11 +39,12 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include <xkbsrv.h>
 #include "xkb.h"
 #include <ctype.h>
+#define EXTENSION_EVENT_BASE 64
 
 static unsigned int _xkbServerGeneration;
-static int xkbDevicePrivateIndex = -1;
+int xkbDevicePrivateIndex = -1;
 
-static void
+void
 xkbUnwrapProc(DeviceIntPtr device, DeviceHandleProc proc,
                    pointer data)
 {
@@ -83,13 +84,11 @@ XkbSetExtension(DeviceIntPtr device, ProcessInputProc proc)
 			    proc,xkbUnwrapProc);
 }
 
-#ifdef XINPUT
 extern	void	ProcessOtherEvent(
     xEvent *		/* xE */,
     DeviceIntPtr 	/* dev */,
     int 		/* count */
 );
-#endif
 
 /***====================================================================***/
 
@@ -673,6 +672,7 @@ _XkbFilterPointerBtn(	XkbSrvInfoPtr	xkbi,
 						&old,xkbi->desc->ctrls,
 						&cn,False)) {
 			cn.keycode = keycode;
+                        /* XXX: what about DeviceKeyPress? */
 			cn.eventType = KeyPress;
 			cn.requestMajor = 0;
 			cn.requestMinor = 0;
@@ -737,6 +737,7 @@ XkbEventCauseRec	cause;
 	    ctrls->enabled_ctrls|= change;
 	    if (XkbComputeControlsNotify(kbd,&old,ctrls,&cn,False)) {
 		cn.keycode = keycode;
+                /* XXX: what about DeviceKeyPress? */
 		cn.eventType = KeyPress;
 		cn.requestMajor = 0;
 		cn.requestMinor = 0;
@@ -878,6 +879,7 @@ ProcessInputProc backupproc;
 	filter->filter = _XkbFilterRedirectKey;
 	filter->upAction = *pAction;
 
+        /* XXX: what about DeviceKeyPress */
 	ev.u.u.type = KeyPress;
 	ev.u.u.detail = pAction->redirect.new_key;
 
@@ -905,6 +907,10 @@ ProcessInputProc backupproc;
 
 	realMods = xkbi->device->key->modifierMap[ev.u.u.detail];
 	xkbi->device->key->modifierMap[ev.u.u.detail] = 0;
+        /* XXX: Bad! Since the switch to XI devices xkbi->device will be the
+         * XI device. Sending a core event through ProcessOtherEvent will
+         * cause trouble. Somebody should fix this. 
+         */
 	UNWRAP_PROCESS_INPUT_PROC(xkbi->device,xkbPrivPtr, backupproc);
 	xkbi->device->public.processInputProc(&ev,xkbi->device,1);
 	COND_WRAP_PROCESS_INPUT_PROC(xkbi->device, xkbPrivPtr,
@@ -919,6 +925,7 @@ ProcessInputProc backupproc;
     }
     else if (filter->keycode==keycode) {
 
+        /* XXX: what about DeviceKeyRelease */
 	ev.u.u.type = KeyRelease;
 	ev.u.u.detail = filter->upAction.redirect.new_key;
 
@@ -946,6 +953,10 @@ ProcessInputProc backupproc;
 
 	realMods = xkbi->device->key->modifierMap[ev.u.u.detail];
 	xkbi->device->key->modifierMap[ev.u.u.detail] = 0;
+        /* XXX: Bad! Since the switch to XI devices xkbi->device will be the
+         * XI device. Sending a core event through ProcessOtherEvent will
+         * cause trouble. Somebody should fix this. 
+         */
 	UNWRAP_PROCESS_INPUT_PROC(xkbi->device,xkbPrivPtr, backupproc);
 	xkbi->device->public.processInputProc(&ev,xkbi->device,1);
 	COND_WRAP_PROCESS_INPUT_PROC(xkbi->device, xkbPrivPtr,
@@ -1009,7 +1020,6 @@ _XkbFilterXF86Private(	XkbSrvInfoPtr	xkbi,
     return 1;
 }
 
-#ifdef XINPUT
 
 static int
 _XkbFilterDeviceBtn(	XkbSrvInfoPtr	xkbi,
@@ -1081,7 +1091,6 @@ int		button;
     }
     return 0;
 }
-#endif
 
 static XkbFilterPtr
 _XkbNextFreeFilter(
@@ -1139,9 +1148,7 @@ XkbAction	act;
 XkbFilterPtr	filter;
 Bool		keyEvent;
 Bool		pressEvent;
-#ifdef XINPUT
 Bool		xiEvent;
-#endif
 ProcessInputProc backupproc;
     
 xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev);
@@ -1162,7 +1169,6 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev);
     xkbi->groupChange = 0;
 
     sendEvent = 1;
-#ifdef XINPUT
     keyEvent= ((xE->u.u.type==KeyPress)||(xE->u.u.type==DeviceKeyPress)||
 		(xE->u.u.type==KeyRelease)||(xE->u.u.type==DeviceKeyRelease));
     pressEvent= (xE->u.u.type==KeyPress)||(xE->u.u.type==DeviceKeyPress)||
@@ -1170,10 +1176,6 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev);
     xiEvent= (xE->u.u.type==DeviceKeyPress)||(xE->u.u.type==DeviceKeyRelease)||
 	     (xE->u.u.type==DeviceButtonPress)||
 	     (xE->u.u.type==DeviceButtonRelease);
-#else
-    keyEvent= (xE->u.u.type==KeyPress)||(xE->u.u.type==KeyRelease);
-    pressEvent= (xE->u.u.type==KeyPress)||(xE->u.u.type==ButtonPress);
-#endif
 
     if (pressEvent) {
 	if (keyEvent)	
@@ -1234,13 +1236,11 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev);
 		    filter = _XkbNextFreeFilter(xkbi);
 		    sendEvent= _XkbFilterRedirectKey(xkbi,filter,key,&act);
 		    break;
-#ifdef XINPUT
 		case XkbSA_DeviceBtn:
 		case XkbSA_LockDeviceBtn:
 		    filter = _XkbNextFreeFilter(xkbi);
 		    sendEvent= _XkbFilterDeviceBtn(xkbi,filter,key,&act);
 		    break;
-#endif
 		case XkbSA_XFree86Private:
 		    filter = _XkbNextFreeFilter(xkbi);
 		    sendEvent= _XkbFilterXF86Private(xkbi,filter,key,&act);
@@ -1279,11 +1279,6 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev);
     }
 
     if (sendEvent) {
-#ifdef XINPUT
-	if (xiEvent)
-	    ProcessOtherEvent(xE,dev,count);
-	else 
-#endif
 	if (keyEvent) {
 	    realMods = keyc->modifierMap[key];
 	    keyc->modifierMap[key] = 0;
@@ -1293,7 +1288,14 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev);
 					 backupproc,xkbUnwrapProc);
 	    keyc->modifierMap[key] = realMods;
 	}
-	else CoreProcessPointerEvent(xE,dev,count);
+	else 
+        {
+            if (xE->u.u.type & EXTENSION_EVENT_BASE)
+                ProcessOtherEvent(xE, dev, count);
+            else
+                CoreProcessPointerEvent(xE,dev,count);
+            
+        }
     }
     else if (keyEvent)
 	FixKeyState(xE,dev);
diff --git a/xkb/xkbEvents.c b/xkb/xkbEvents.c
index 11dc17a..e11b609 100644
--- a/xkb/xkbEvents.c
+++ b/xkb/xkbEvents.c
@@ -34,6 +34,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include <X11/Xproto.h>
 #include <X11/keysym.h>
 #include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
 #include "inputstr.h"
 #include "windowstr.h"
 #include <xkbsrv.h>
@@ -813,7 +814,9 @@ XkbSrvInfoPtr	xkbi;
     if ( pClient->xkbClientFlags & _XkbClientInitialized ) {
 #ifdef DEBUG
 	if ((xkbDebugFlags&0x10)&&
-		((xE[0].u.u.type==KeyPress)||(xE[0].u.u.type==KeyRelease))) {
+		((xE[0].u.u.type==KeyPress)||(xE[0].u.u.type==KeyRelease)||
+                 (xE[0].u.u.type==DeviceKeyPress)||
+                 (xE[0].u.u.type == DeviceKeyRelease))) {
 	    ErrorF("XKbFilterWriteEvents:\n");
 	    ErrorF("   Event state= 0x%04x\n",xE[0].u.keyButtonPointer.state);
 	    ErrorF("   XkbLastRepeatEvent!=xE (0x%p!=0x%p) %s\n",
@@ -832,7 +835,9 @@ XkbSrvInfoPtr	xkbi;
 	    return False;
 	}
 	if ((pXDev->grab != NullGrab) && pXDev->fromPassiveGrab &&
-	    ((xE[0].u.u.type==KeyPress)||(xE[0].u.u.type==KeyRelease))) {
+	    ((xE[0].u.u.type==KeyPress)||(xE[0].u.u.type==KeyRelease)||
+             (xE[0].u.u.type==DeviceKeyPress)||
+             (xE[0].u.u.type == DeviceKeyRelease))) {
 	    register unsigned state,flags;
 
 	    flags= pClient->xkbClientFlags;
@@ -877,10 +882,12 @@ XkbSrvInfoPtr	xkbi;
 	    type= xE[i].u.u.type;
 #ifdef DEBUG
 	    if ((xkbDebugFlags&0x4)&&
-		((xE[0].u.u.type==KeyPress)||(xE[0].u.u.type==KeyRelease))) {
+		((xE[i].u.u.type==KeyPress)||(xE[i].u.u.type==KeyRelease)||
+                 (xE[i].u.u.type==DeviceKeyPress)||
+                 (xE[i].u.u.type == DeviceKeyRelease))) {
 		XkbStatePtr s= &xkbi->state;
 		ErrorF("XKbFilterWriteEvents (non-XKB):\n");
-		ErrorF("event= 0x%04x\n",xE[0].u.keyButtonPointer.state);
+		ErrorF("event= 0x%04x\n",xE[i].u.keyButtonPointer.state);
 		ErrorF("lookup= 0x%02x, grab= 0x%02x\n",s->lookup_mods,
 							s->grab_mods);
 		ErrorF("compat lookup= 0x%02x, grab= 0x%02x\n",
@@ -900,9 +907,18 @@ XkbSrvInfoPtr	xkbi;
 		xE[i].u.keyButtonPointer.state= new;
 	    }
 	    else if ((type==EnterNotify)||(type==LeaveNotify)) {
-		xE->u.enterLeave.state&= 0x1F00;
-		xE->u.enterLeave.state|= xkbi->state.compat_grab_mods;
-	    }
+		xE[i].u.enterLeave.state&= 0x1F00;
+		xE[i].u.enterLeave.state|= xkbi->state.compat_grab_mods;
+	    } else if ((type>=DeviceKeyPress)&&(type<=DeviceMotionNotify)) {
+                CARD16  old, new;
+                deviceKeyButtonPointer *kbp = (deviceKeyButtonPointer*)&xE[i];
+                old= kbp->state&(~0x1F00);
+                new= kbp->state&0x1F00;
+		if (old==XkbStateFieldFromRec(&xkbi->state))
+		     new|= xkbi->state.compat_lookup_mods;
+		else new|= xkbi->state.compat_grab_mods;
+                kbp->state= new;
+            }
 	    button_mask = 1 << xE[i].u.u.detail;
 	    if (type == ButtonPress &&
 		((xE[i].u.keyButtonPointer.state >> 7) & button_mask) == button_mask &&
@@ -911,7 +927,14 @@ XkbSrvInfoPtr	xkbi;
 		ErrorF("Faking release of button %d\n", xE[i].u.u.detail);
 #endif
 		XkbDDXFakePointerButton(ButtonRelease, xE[i].u.u.detail);
-	    }
+	    } else if (type == DeviceButtonPress &&
+                    ((((deviceKeyButtonPointer*)&xE[i])->state >> 7) & button_mask) == button_mask &&
+                    (xkbi->lockedPtrButtons & button_mask) == button_mask) {
+#ifdef DEBUG
+		ErrorF("Faking release of button %d\n", ((deviceKeyButtonPointer*)&xE[i])->state);
+#endif
+		XkbDDXFakePointerButton(DeviceButtonRelease, ((deviceKeyButtonPointer*)&xE[i])->state);
+            }
 	}
     }
     return True;
diff --git a/xkb/xkbPrKeyEv.c b/xkb/xkbPrKeyEv.c
index 81124bc..ba3fcc0 100644
--- a/xkb/xkbPrKeyEv.c
+++ b/xkb/xkbPrKeyEv.c
@@ -38,6 +38,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "inputstr.h"
 #include <xkbsrv.h>
 #include <ctype.h>
+#define EXTENSION_EVENT_BASE 64
 
 
 /***====================================================================***/
@@ -50,9 +51,11 @@ XkbSrvInfoPtr	xkbi;
 int		key;
 XkbBehavior	behavior;
 unsigned        ndx;
+int             xiEvent;
 
     xkbi= keyc->xkbInfo;
     key= xE->u.u.detail;
+    xiEvent= (xE->u.u.type & EXTENSION_EVENT_BASE);
 #ifdef DEBUG
     if (xkbDebugFlags&0x8) {
 	ErrorF("XkbPKE: Key %d %s\n",key,(xE->u.u.type==KeyPress?"down":"up"));
@@ -69,45 +72,69 @@ unsigned        ndx;
     /* below XKB, such as a key that physically locks.   XKB does not   */
     /* do anything to implement the behavior, but it *does* report that */
     /* key is hardwired */
+
     if ((behavior.type&XkbKB_Permanent)==0) {
 	switch (behavior.type) {
 	    case XkbKB_Default:
-		if (( xE->u.u.type == KeyPress ) && 
+		if (( xE->u.u.type == KeyPress || 
+                            xE->u.u.type == DeviceKeyPress) && 
 		    (keyc->down[key>>3] & (1<<(key&7)))) {
 		    XkbLastRepeatEvent=	(pointer)xE;
-		    xE->u.u.type = KeyRelease;
+
+                    if (xiEvent)
+                        xE->u.u.type = DeviceKeyRelease;
+                    else
+                        xE->u.u.type = KeyRelease;
 		    XkbHandleActions(keybd,keybd,xE,count);
-		    xE->u.u.type = KeyPress;
+
+                    if (xiEvent)
+                        xE->u.u.type = DeviceKeyPress;
+                    else
+                        xE->u.u.type = KeyPress;
 		    XkbHandleActions(keybd,keybd,xE,count);
 		    XkbLastRepeatEvent= NULL;
 		    return;
 		}
-		else if ((xE->u.u.type==KeyRelease) &&
+		else if ((xE->u.u.type==KeyRelease || 
+                            xE->u.u.type == DeviceKeyRelease) &&
 			(!(keyc->down[key>>3]&(1<<(key&7))))) {
 		    XkbLastRepeatEvent=	(pointer)&xE;
-		    xE->u.u.type = KeyPress;
+                    if (xiEvent)
+                        xE->u.u.type = DeviceKeyPress;
+                    else
+                        xE->u.u.type = KeyPress;
 		    XkbHandleActions(keybd,keybd,xE,count);
-		    xE->u.u.type = KeyRelease;
+                    if (xiEvent)
+                        xE->u.u.type = DeviceKeyRelease;
+                    else
+                        xE->u.u.type = KeyRelease;
 		    XkbHandleActions(keybd,keybd,xE,count);
 		    XkbLastRepeatEvent= NULL;
 		    return;
 		}
 		break;
 	    case XkbKB_Lock:
-		if ( xE->u.u.type == KeyRelease )
+		if ( xE->u.u.type == KeyRelease || 
+                        xE->u.u.type == DeviceKeyRelease)
 		    return;
 		else {
 		    int	bit= 1<<(key&7);
 		    if ( keyc->down[key>>3]&bit )
-			xE->u.u.type= KeyRelease;
-		}
+                    {
+                        if (xiEvent)
+                            xE->u.u.type = DeviceKeyRelease;
+                        else
+                            xE->u.u.type= KeyRelease;
+                    }
+                }
 		break;
 	    case XkbKB_RadioGroup:
 		ndx= (behavior.data&(~XkbKB_RGAllowNone));
 		if ( ndx<xkbi->nRadioGroups ) {
 		    XkbRadioGroupPtr	rg;
 
-		    if ( xE->u.u.type == KeyRelease )
+		    if ( xE->u.u.type == KeyRelease ||
+                            xE->u.u.type == DeviceKeyRelease)
 		        return;
 
 		    rg = &xkbi->radioGroups[ndx];
@@ -121,10 +148,16 @@ unsigned        ndx;
 		    }
 		    if ( rg->currentDown!=0 ) {
 			int key = xE->u.u.detail;
-			xE->u.u.type= KeyRelease;
+                        if (xiEvent)
+                            xE->u.u.type = DeviceKeyRelease;
+                        else
+                            xE->u.u.type= KeyRelease;
 			xE->u.u.detail= rg->currentDown;
 		        XkbHandleActions(keybd,keybd,xE,count);
-		        xE->u.u.type= KeyPress;
+                        if (xiEvent)
+                            xE->u.u.type = DeviceKeyPress;
+                        else
+                            xE->u.u.type= KeyPress;
 		        xE->u.u.detail= key;
 		    }
 		    rg->currentDown= key;
@@ -173,9 +206,9 @@ XkbSrvInfoPtr	xkbi;
 #endif
     if ((xkbi->desc->ctrls->enabled_ctrls&XkbAllFilteredEventsMask)==0)
 	XkbProcessKeyboardEvent(xE,keybd,count);
-    else if (xE->u.u.type==KeyPress)
+    else if (xE->u.u.type==KeyPress || xE->u.u.type==DeviceKeyPress)
 	AccessXFilterPressEvent(xE,keybd,count);
-    else if (xE->u.u.type==KeyRelease)
+    else if (xE->u.u.type==KeyRelease || xE->u.u.type==DeviceKeyRelease)
 	AccessXFilterReleaseEvent(xE,keybd,count);
     return;
 }
commit 83e76fb3f7a89a237893c2b7df450d4f90eab52d
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Thu Jun 21 18:24:30 2007 +0930

    Save processInputProc before wrapping it and restore it later, instead of
    using a hardcoded ProcessKeyboardEvent. Otherwise we lose the ability to
    process DeviceKeyEvents after the first key press.
    
    This should be the correct fix now.
    (cherry picked from commit 4d5df14f2c4a3108a8c8adfcf4766c0d1a9daad2)
    (cherry picked from commit 91077bfc50d54be37c217e377c55b6bf886a2fab)

diff --git a/include/xkbsrv.h b/include/xkbsrv.h
index bb2316d..d78a68a 100644
--- a/include/xkbsrv.h
+++ b/include/xkbsrv.h
@@ -262,7 +262,8 @@ typedef struct
 	oldprocs->unwrapProc = device->unwrapProc; \
 	device->unwrapProc = unwrapproc;
 
-#define UNWRAP_PROCESS_INPUT_PROC(device, oldprocs) \
+#define UNWRAP_PROCESS_INPUT_PROC(device, oldprocs, backupproc) \
+        backupproc = device->public.processInputProc; \
 	device->public.processInputProc = oldprocs->processInputProc; \
 	device->public.realInputProc = oldprocs->realInputProc; \
 	device->unwrapProc = oldprocs->unwrapProc;
diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
index ef67d64..2c7c2cd 100644
--- a/xkb/xkbActions.c
+++ b/xkb/xkbActions.c
@@ -49,10 +49,11 @@ xkbUnwrapProc(DeviceIntPtr device, DeviceHandleProc proc,
 {
     xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(device);
     ProcessInputProc tmp = device->public.processInputProc;
+    ProcessInputProc dummy; /* unused, but neede for macro */
     if(xkbPrivPtr->unwrapProc)
 	xkbPrivPtr->unwrapProc = NULL;
 
-    UNWRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr);
+    UNWRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr, dummy);
     proc(device,data);
     WRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr,
 			    tmp,xkbUnwrapProc);
@@ -851,6 +852,7 @@ int		x,y;
 XkbStateRec	old;
 unsigned	mods,mask,oldCoreState = 0,oldCorePrevState = 0;
 xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(xkbi->device);
+ProcessInputProc backupproc;
 
     /* never actually used uninitialised, but gcc isn't smart enough
      * to work that out. */
@@ -903,10 +905,10 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(xkbi->device);
 
 	realMods = xkbi->device->key->modifierMap[ev.u.u.detail];
 	xkbi->device->key->modifierMap[ev.u.u.detail] = 0;
-	UNWRAP_PROCESS_INPUT_PROC(xkbi->device,xkbPrivPtr);
+	UNWRAP_PROCESS_INPUT_PROC(xkbi->device,xkbPrivPtr, backupproc);
 	xkbi->device->public.processInputProc(&ev,xkbi->device,1);
 	COND_WRAP_PROCESS_INPUT_PROC(xkbi->device, xkbPrivPtr,
-				     ProcessKeyboardEvent,xkbUnwrapProc);
+				     backupproc,xkbUnwrapProc);
 	xkbi->device->key->modifierMap[ev.u.u.detail] = realMods;
 	
 	if ( mask || mods ) {
@@ -944,10 +946,10 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(xkbi->device);
 
 	realMods = xkbi->device->key->modifierMap[ev.u.u.detail];
 	xkbi->device->key->modifierMap[ev.u.u.detail] = 0;
-	UNWRAP_PROCESS_INPUT_PROC(xkbi->device,xkbPrivPtr);
+	UNWRAP_PROCESS_INPUT_PROC(xkbi->device,xkbPrivPtr, backupproc);
 	xkbi->device->public.processInputProc(&ev,xkbi->device,1);
 	COND_WRAP_PROCESS_INPUT_PROC(xkbi->device, xkbPrivPtr,
-				     ProcessKeyboardEvent,xkbUnwrapProc);
+				     backupproc,xkbUnwrapProc);
 	xkbi->device->key->modifierMap[ev.u.u.detail] = realMods;
 
 	if ( mask || mods ) {
@@ -1140,6 +1142,7 @@ Bool		pressEvent;
 #ifdef XINPUT
 Bool		xiEvent;
 #endif
+ProcessInputProc backupproc;
     
 xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev);
 
@@ -1284,10 +1287,10 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev);
 	if (keyEvent) {
 	    realMods = keyc->modifierMap[key];
 	    keyc->modifierMap[key] = 0;
-	    UNWRAP_PROCESS_INPUT_PROC(dev,xkbPrivPtr);
+	    UNWRAP_PROCESS_INPUT_PROC(dev,xkbPrivPtr, backupproc);
 	    dev->public.processInputProc(xE,dev,count);
 	    COND_WRAP_PROCESS_INPUT_PROC(dev, xkbPrivPtr,
-					 ProcessKeyboardEvent,xkbUnwrapProc);
+					 backupproc,xkbUnwrapProc);
 	    keyc->modifierMap[key] = realMods;
 	}
 	else CoreProcessPointerEvent(xE,dev,count);
commit a53172827c69a88155a088843c9a3e8a7a7a0463
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Tue Sep 4 17:44:51 2007 +0930

    xkb: Store the action filters per device in the XkbSrvInfoRec.
    
    Using a global array for action filters is bad. If two keyboard hit a modifier
    at the same time, releaseing the first one will deactivate the filter and
    thus the second keyboard can never release the modifier again.
    (cherry picked from commit bfe6b4d2d9952a80f8dbc63eec974ef894e5c226)
    (cherry picked from commit 8b9481a113b56078191e2298bf590905978f6289)

diff --git a/include/xkbsrv.h b/include/xkbsrv.h
index e43e8fd..bb2316d 100644
--- a/include/xkbsrv.h
+++ b/include/xkbsrv.h
@@ -126,6 +126,24 @@ typedef struct	_XkbEventCause {
 #define	_BEEP_LED_CHANGE	14
 #define	_BEEP_BOUNCE_REJECT	15
 
+struct _XkbSrvInfo; /* definition see below */
+
+typedef struct _XkbFilter {
+	CARD16			  keycode;
+	CARD8			  what;
+	CARD8			  active;
+	CARD8			  filterOthers;
+	CARD32			  priv;
+	XkbAction		  upAction;
+	int			(*filter)(
+					struct _XkbSrvInfo* 	/* xkbi */,
+					struct _XkbFilter *	/* filter */,
+					unsigned		/* keycode */,
+					XkbAction *		/* action */
+				  );
+	struct _XkbFilter	 *next;
+} XkbFilterRec,*XkbFilterPtr;
+
 typedef struct _XkbSrvInfo {
 	XkbStateRec	 prev_state;
 	XkbStateRec	 state;
@@ -169,6 +187,9 @@ typedef struct _XkbSrvInfo {
 	OsTimerPtr	 bounceKeysTimer;
 	OsTimerPtr	 repeatKeyTimer;
 	OsTimerPtr	 krgTimer;
+
+	int		 szFilters;
+	XkbFilterPtr	 filters;
 } XkbSrvInfoRec, *XkbSrvInfoPtr;
 
 #define	XkbSLI_IsDefault	(1L<<0)
diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
index 2e0c89f..ef67d64 100644
--- a/xkb/xkbActions.c
+++ b/xkb/xkbActions.c
@@ -72,7 +72,7 @@ XkbSetExtension(DeviceIntPtr device, ProcessInputProc proc)
     if (!AllocateDevicePrivate(device, xkbDevicePrivateIndex))
 	return;
 
-    xkbPrivPtr = (xkbDeviceInfoPtr) xalloc(sizeof(xkbDeviceInfoRec));
+    xkbPrivPtr = (xkbDeviceInfoPtr) xcalloc(1, sizeof(xkbDeviceInfoRec));
     if (!xkbPrivPtr)
 	return;
     xkbPrivPtr->unwrapProc = NULL;
@@ -236,22 +236,6 @@ XkbAction fake;
 #define	SYNTHETIC_KEYCODE	1
 #define	BTN_ACT_FLAG		0x100
 
-typedef struct _XkbFilter {
-	CARD16			  keycode;
-	CARD8			  what;
-	CARD8			  active;
-	CARD8			  filterOthers;
-	CARD32			  priv;
-	XkbAction		  upAction;
-	int			(*filter)(
-					XkbSrvInfoPtr 		/* xkbi */,
-					struct _XkbFilter *	/* filter */,
-					unsigned		/* keycode */,
-					XkbAction *		/* action */
-				  );
-	struct _XkbFilter	 *next;
-} XkbFilterRec,*XkbFilterPtr;
-
 static int
 _XkbFilterSetState(	XkbSrvInfoPtr	xkbi,
 			XkbFilterPtr	filter,
@@ -1097,32 +1081,32 @@ int		button;
 }
 #endif
 
-static	int		szFilters = 0;
-static	XkbFilterPtr	filters = NULL;
-
 static XkbFilterPtr
 _XkbNextFreeFilter(
-	void
+	XkbSrvInfoPtr xkbi
 )
 {
 register int	i;
 
-    if (szFilters==0) {
-	szFilters = 4;
-	filters = _XkbTypedCalloc(szFilters,XkbFilterRec);
+    if (xkbi->szFilters==0) {
+	xkbi->szFilters = 4;
+	xkbi->filters = _XkbTypedCalloc(xkbi->szFilters,XkbFilterRec);
 	/* 6/21/93 (ef) -- XXX! deal with allocation failure */
     }
-    for (i=0;i<szFilters;i++) {
-	if (!filters[i].active) {
-	    filters[i].keycode = 0;
-	    return &filters[i];
+    for (i=0;i<xkbi->szFilters;i++) {
+	if (!xkbi->filters[i].active) {
+	    xkbi->filters[i].keycode = 0;
+	    return &xkbi->filters[i];
 	}
     }
-    szFilters*=2;
-    filters= _XkbTypedRealloc(filters,szFilters,XkbFilterRec);
+    xkbi->szFilters*=2;
+    xkbi->filters= _XkbTypedRealloc(xkbi->filters,
+                                    xkbi->szFilters,
+                                    XkbFilterRec);
     /* 6/21/93 (ef) -- XXX! deal with allocation failure */
-    bzero(&filters[szFilters/2],(szFilters/2)*sizeof(XkbFilterRec));
-    return &filters[szFilters/2];
+    bzero(&xkbi->filters[xkbi->szFilters/2],
+            (xkbi->szFilters/2)*sizeof(XkbFilterRec));
+    return &xkbi->filters[xkbi->szFilters/2];
 }
 
 static int
@@ -1131,9 +1115,10 @@ _XkbApplyFilters(XkbSrvInfoPtr xkbi,unsigned kc,XkbAction *pAction)
 register int	i,send;
 
     send= 1;
-    for (i=0;i<szFilters;i++) {
-	if ((filters[i].active)&&(filters[i].filter))
-	    send= ((*filters[i].filter)(xkbi,&filters[i],kc,pAction)&&send);
+    for (i=0;i<xkbi->szFilters;i++) {
+	if ((xkbi->filters[i].active)&&(xkbi->filters[i].filter))
+	    send= ((*xkbi->filters[i].filter)(xkbi,&xkbi->filters[i],kc,pAction) 
+                    && send);
     }
     return send;
 }
@@ -1161,6 +1146,8 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev);
     keyc= kbd->key;
     xkbi= keyc->xkbInfo;
     key= xE->u.u.detail;
+    /* The state may change, so if we're not in the middle of sending a state
+     * notify, prepare for it */
     if ((xkbi->flags&_XkbStateNotifyInProgress)==0) {
 	oldState= xkbi->state;
 	xkbi->flags|= _XkbStateNotifyInProgress;
@@ -1197,62 +1184,62 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev);
 	    switch (act.type) {
 		case XkbSA_SetMods:
 		case XkbSA_SetGroup:
-		    filter = _XkbNextFreeFilter();
+		    filter = _XkbNextFreeFilter(xkbi);
 		    sendEvent = _XkbFilterSetState(xkbi,filter,key,&act);
 		    break;
 		case XkbSA_LatchMods:
 		case XkbSA_LatchGroup:
-		    filter = _XkbNextFreeFilter();
+		    filter = _XkbNextFreeFilter(xkbi);
 		    sendEvent=_XkbFilterLatchState(xkbi,filter,key,&act);
 		    break;
 		case XkbSA_LockMods:
 		case XkbSA_LockGroup:
-		    filter = _XkbNextFreeFilter();
+		    filter = _XkbNextFreeFilter(xkbi);
 		    sendEvent=_XkbFilterLockState(xkbi,filter,key,&act);
 		    break;
 		case XkbSA_ISOLock:
-		    filter = _XkbNextFreeFilter();
+		    filter = _XkbNextFreeFilter(xkbi);
 		    sendEvent=_XkbFilterISOLock(xkbi,filter,key,&act);
 		    break;
 		case XkbSA_MovePtr:
-		    filter = _XkbNextFreeFilter();
+		    filter = _XkbNextFreeFilter(xkbi);
 		    sendEvent= _XkbFilterPointerMove(xkbi,filter,key,&act);
 		    break;
 		case XkbSA_PtrBtn:
 		case XkbSA_LockPtrBtn:
 		case XkbSA_SetPtrDflt:
-		    filter = _XkbNextFreeFilter();
+		    filter = _XkbNextFreeFilter(xkbi);
 		    sendEvent= _XkbFilterPointerBtn(xkbi,filter,key,&act);
 		    break;
 		case XkbSA_Terminate:
 		    sendEvent= XkbDDXTerminateServer(dev,key,&act);
 		    break;
 		case XkbSA_SwitchScreen:
-		    filter = _XkbNextFreeFilter();
+		    filter = _XkbNextFreeFilter(xkbi);
 		    sendEvent=_XkbFilterSwitchScreen(xkbi,filter,key,&act);
 		    break;
 		case XkbSA_SetControls:
 		case XkbSA_LockControls:
-		    filter = _XkbNextFreeFilter();
+		    filter = _XkbNextFreeFilter(xkbi);
 		    sendEvent=_XkbFilterControls(xkbi,filter,key,&act);
 		    break;
 		case XkbSA_ActionMessage:
-		    filter = _XkbNextFreeFilter();
+		    filter = _XkbNextFreeFilter(xkbi);
 		    sendEvent=_XkbFilterActionMessage(xkbi,filter,key,&act);
 		    break;
 		case XkbSA_RedirectKey:
-		    filter = _XkbNextFreeFilter();
+		    filter = _XkbNextFreeFilter(xkbi);
 		    sendEvent= _XkbFilterRedirectKey(xkbi,filter,key,&act);
 		    break;
 #ifdef XINPUT
 		case XkbSA_DeviceBtn:
 		case XkbSA_LockDeviceBtn:
-		    filter = _XkbNextFreeFilter();
+		    filter = _XkbNextFreeFilter(xkbi);
 		    sendEvent= _XkbFilterDeviceBtn(xkbi,filter,key,&act);
 		    break;
 #endif
 		case XkbSA_XFree86Private:
-		    filter = _XkbNextFreeFilter();
+		    filter = _XkbNextFreeFilter(xkbi);
 		    sendEvent= _XkbFilterXF86Private(xkbi,filter,key,&act);
 		    break;
 	    }
@@ -1352,7 +1339,7 @@ unsigned	clear;
 	act.type = XkbSA_LatchMods;
 	act.mods.flags = 0;
 	act.mods.mask  = mask&latches;
-	filter = _XkbNextFreeFilter();
+	filter = _XkbNextFreeFilter(xkbi);
 	_XkbFilterLatchState(xkbi,filter,SYNTHETIC_KEYCODE,&act);
 	_XkbFilterLatchState(xkbi,filter,SYNTHETIC_KEYCODE,(XkbAction *)NULL);
 	return Success;
@@ -1372,7 +1359,7 @@ XkbAction	act;
 	act.type = XkbSA_LatchGroup;
 	act.group.flags = 0;
 	XkbSASetGroup(&act.group,group);
-	filter = _XkbNextFreeFilter();
+	filter = _XkbNextFreeFilter(xkbi);
 	_XkbFilterLatchState(xkbi,filter,SYNTHETIC_KEYCODE,&act);
 	_XkbFilterLatchState(xkbi,filter,SYNTHETIC_KEYCODE,(XkbAction *)NULL);
 	return Success;
commit b76b1d51fe3053fa2a60b64de9ac93f50ef252f5
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Oct 27 21:33:52 2007 +0300

    XFree86: Remove ridiculous SIGIO debugging
    
    YOU PRESSED A KEY
    AND AGAIN
    YOU RELEASED A KEY
    AND AGAIN
    YOU PRESSED A KEY
    AND AGAIN
    
    ... not so much.
    (cherry picked from commit 493b83bd097372ae0023da9919da83af39e3fc1c)

diff --git a/hw/xfree86/os-support/shared/sigio.c b/hw/xfree86/os-support/shared/sigio.c
index f6c15c2..c97f503 100644
--- a/hw/xfree86/os-support/shared/sigio.c
+++ b/hw/xfree86/os-support/shared/sigio.c
@@ -243,9 +243,6 @@ xf86BlockSIGIO (void)
     sigaddset (&set, SIGIO);
     sigprocmask (SIG_BLOCK, &set, &old);
     ret = sigismember (&old, SIGIO);
-#ifdef DEBUG
-    ErrorF("%i = xf86BlockSIGIO()\n",ret);
-#endif
     return ret; 
 }
 
@@ -253,9 +250,6 @@ _X_EXPORT void
 xf86UnblockSIGIO (int wasset)
 {
     sigset_t	set;
-#ifdef DEBUG
-    ErrorF("xf86UnblockSIGIO(%i)\n",wasset);
-#endif
 
     if (!wasset)
     {
commit b600e7c123ce637359a75c43bf67b3462eadb37e
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Oct 27 21:35:31 2007 +0300

    XKB: Add more bits to xkbsrv.h
    
    Add the device private index, given we use that in a macro here, and also the
    prototype for xkbUnwrapProc, since that's also useful.
    (cherry picked from commit a3d48de5f2b7eacf3193c60f0fb461912201210b)

diff --git a/include/xkbsrv.h b/include/xkbsrv.h
index 5edee53..e43e8fd 100644
--- a/include/xkbsrv.h
+++ b/include/xkbsrv.h
@@ -246,8 +246,11 @@ typedef struct
 	device->public.realInputProc = oldprocs->realInputProc; \
 	device->unwrapProc = oldprocs->unwrapProc;
 
+extern int xkbDevicePrivateIndex;
 #define XKBDEVICEINFO(dev) ((xkbDeviceInfoPtr) (dev)->devPrivates[xkbDevicePrivateIndex].ptr)
 
+extern void xkbUnwrapProc(DeviceIntPtr, DeviceHandleProc, pointer);
+
 /***====================================================================***/
 
 
commit 63c6d9d622a10303f594a07bd86dda8e5f894ca7
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Oct 27 21:34:22 2007 +0300

    Xi: Include XI protocol header in exevents.h
    
    Make sure we have all the types we need to use this header.
    (cherry picked from commit e29e69960d67aa4b7a4d1551af509dbac193f438)

diff --git a/include/exevents.h b/include/exevents.h
index 69d4abc..9f15f50 100644
--- a/include/exevents.h
+++ b/include/exevents.h
@@ -30,6 +30,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #ifndef EXEVENTS_H
 #define EXEVENTS_H
 
+#include <X11/extensions/XIproto.h>
+
 extern void RegisterOtherDevice (
 	DeviceIntPtr           /* device */);
 
commit bd779f8cde1c71a0db8470b8c993504da7c1104e
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 28 15:46:26 2007 +0200

    configure.ac/XFree86: Only build XF86Misc and XF86VidMode when appropriate
    
    Don't build XF86Misc or XF86Vidmode in hw/xfree86/dixmod when it's been
    explicitly disabled in configure, or we don't have the proto modules
    installed.
    
    (cherry picked from commit df57ae1639ba4f1719883c5bf868394e4748a022)

diff --git a/configure.ac b/configure.ac
index 62fdd78..d9351ef 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1590,7 +1590,9 @@ AM_CONDITIONAL([SOLARIS_USL_CONSOLE], [test "x$solaris_usl_console" = xyes])
 AM_CONDITIONAL([SOLARIS_ASM_INLINE], [test "x$solaris_asm_inline" = xyes])
 AM_CONDITIONAL([BUILD_DARWIN],[test "X$build_darwin" = Xyes])
 AM_CONDITIONAL([XQUARTZ],[test "X$XQUARTZ" = Xyes])
-AM_CONDITIONAL(DGA, [test "x$DGA" = xyes])
+AM_CONDITIONAL([DGA], [test "x$DGA" = xyes])
+AM_CONDITIONAL([XF86MISC], [test "x$XF86MISC" = xyes])
+AM_CONDITIONAL([XF86VIDMODE], [test "x$XF86VIDMODE" = xyes])
 
 dnl legacy fb support
 test "x$MFB" = xauto && MFB="$XORG"
diff --git a/hw/xfree86/dixmods/extmod/Makefile.am b/hw/xfree86/dixmods/extmod/Makefile.am
index 9f6c408..f90e144 100644
--- a/hw/xfree86/dixmods/extmod/Makefile.am
+++ b/hw/xfree86/dixmods/extmod/Makefile.am
@@ -11,6 +11,14 @@ if XV
 XV_SRCS = xvmod.c xvmodproc.h
 endif
 
+if XF86MISC
+XF86MISC_SRCS = xf86misc.c xf86miscproc.h
+endif
+
+if XF86VIDMODE
+XF86VMODE_SRCS = xf86vmode.c vidmodeproc.h
+endif
+
 AM_CFLAGS = @DIX_CFLAGS@ @XORG_CFLAGS@
 INCLUDES = @XORG_INCS@ \
            -I$(top_srcdir)/afb \
@@ -24,9 +32,7 @@ libextmod_la_LDFLAGS = -avoid-version
 libextmod_la_SOURCES = modinit.c \
                        modinit.h \
                        $(DGA_SRCS) \
-                       xf86misc.c \
-                       xf86miscproc.h \
-                       xf86vmode.c \
-                       vidmodeproc.h \
+                       $(XF86MISC_SRCS) \
+                       $(XF86VMODE_SRCS) \
                        $(XV_SRCS)
 libextmod_la_LIBADD = $(top_builddir)/Xext/libXextmodule.la
commit 881e4fb518c7ed4c95882368356901c1ec4b6abf
Author: Aaron Plattner <aplattner at nvidia.com>
Date:   Thu Sep 20 14:00:33 2007 -0700

    Set noCompositeExtension to TRUE when failing to initialize the extension (e.g. when Xinerama is enabled).
    (cherry picked from commit 50fa8722d35c12e5f0322cebe25faf99c39d4f50)

diff --git a/composite/compext.c b/composite/compext.c
index 944f8d8..ece51d0 100644
--- a/composite/compext.c
+++ b/composite/compext.c
@@ -674,6 +674,9 @@ CompositeExtensionInit (void)
     ExtensionEntry  *extEntry;
     int		    s;
 
+    /* Assume initialization is going to fail */
+    noCompositeExtension = TRUE;
+
     for (s = 0; s < screenInfo.numScreens; s++) {
 	ScreenPtr pScreen = screenInfo.screens[s];
 	VisualPtr vis;
@@ -731,4 +734,7 @@ CompositeExtensionInit (void)
 	    return;
     miRegisterRedirectBorderClipProc (compSetRedirectBorderClip,
 				      compGetRedirectBorderClip);
+
+    /* Initialization succeeded */
+    noCompositeExtension = FALSE;
 }
commit ce55565ecd0411065878fa7c9983606d53663b7c
Author: Aaron Plattner <aplattner at nvidia.com>
Date:   Thu Sep 20 16:22:24 2007 -0700

    Don't segfault on shutdown if we never managed to connect to dbus.
    (cherry picked from commit 3a965fdadccea7beff09a28c9c0ef4b4975eae38)

diff --git a/config/dbus-core.c b/config/dbus-core.c
index 2888159..eab72a5 100644
--- a/config/dbus-core.c
+++ b/config/dbus-core.c
@@ -87,7 +87,8 @@ teardown(void)
         dbus_connection_unref(bus_info.connection);
 
     RemoveBlockAndWakeupHandlers(block_handler, wakeup_handler, &bus_info);
-    RemoveGeneralSocket(bus_info.fd);
+    if (bus_info.fd != -1)
+        RemoveGeneralSocket(bus_info.fd);
     bus_info.fd = -1;
     bus_info.connection = NULL;
 
commit eba45539af33f7d312bcfee954786fe38ab8f391
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Thu Aug 30 18:22:12 2007 +0930

    config: Use [config/dbus] consistently for error messages.
    (cherry picked from commit 3f42af8c0ef1e5379bc836f589e0cbee43c02ac5)

diff --git a/config/dbus.c b/config/dbus.c
index d437994..c867512 100644
--- a/config/dbus.c
+++ b/config/dbus.c
@@ -139,7 +139,7 @@ add_device(DBusMessage *message, DBusMessage *reply, DBusError *error)
             MALFORMED_MESSAGE();
         options->value = xstrdup(tmp);
         if (!options->value) {
-            ErrorF("[config] couldn't duplicate option!\n");
+            ErrorF("[config/dbus] couldn't duplicate option!\n");
             ret = BadAlloc;
             goto unwind;
         }
@@ -204,7 +204,7 @@ remove_device(DBusMessage *message, DBusMessage *reply, DBusError *error)
     dbus_message_iter_init_append(reply, &reply_iter);
 
     if (!dbus_message_iter_init(message, &iter)) {
-        ErrorF("[config] failed to init iterator\n");
+        ErrorF("[config/dbus] failed to init iterator\n");
         MALFORMED_MESSAGE();
     }
 
@@ -215,12 +215,12 @@ remove_device(DBusMessage *message, DBusMessage *reply, DBusError *error)
 
     dev = LookupDeviceIntRec(deviceid);
     if (!dev) {
-        DebugF("[config] bogus device id %d given\n", deviceid);
+        DebugF("[config/dbus] bogus device id %d given\n", deviceid);
         ret = BadMatch;
         goto unwind;
     }
 
-    DebugF("[config] removing device %s (id %d)\n", dev->name, deviceid);
+    DebugF("[config/dbus] removing device %s (id %d)\n", dev->name, deviceid);
 
     /* Call PIE here so we don't try to dereference a device that's
      * already been removed. */
commit c0da35bda136ed423f2963bd5c75ad0301ac7845
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Thu Aug 30 18:20:20 2007 +0930

    config: return BadValue to caller if add/remove doesn't have parameters.
    
    If message iterator cannot be created, the caller didn't supply any
    parameters. Return BadValue, instead of dying a horrible death while being
    stuck in an endless loop.
    (cherry picked from commit 0fcde83d94507eadd9f99d4e6a63584b221c989c)

diff --git a/config/dbus.c b/config/dbus.c
index c6f4af0..d437994 100644
--- a/config/dbus.c
+++ b/config/dbus.c
@@ -74,11 +74,12 @@ add_device(DBusMessage *message, DBusMessage *reply, DBusError *error)
     int ret, err;
     DeviceIntPtr dev = NULL;
 
+    dbus_message_iter_init_append(reply, &reply_iter);
+
     if (!dbus_message_iter_init(message, &iter)) {
         ErrorF("[config/dbus] couldn't initialise iterator\n");
-        return BadAlloc;
+        MALFORMED_MESSAGE();
     }
-    dbus_message_iter_init_append(reply, &reply_iter);
 
     options = xcalloc(sizeof(*options), 1);
     if (!options) {
@@ -200,11 +201,12 @@ remove_device(DBusMessage *message, DBusMessage *reply, DBusError *error)
     DeviceIntPtr dev;
     DBusMessageIter iter, reply_iter;
 
+    dbus_message_iter_init_append(reply, &reply_iter);
+
     if (!dbus_message_iter_init(message, &iter)) {
         ErrorF("[config] failed to init iterator\n");
-        return BadAlloc;
+        MALFORMED_MESSAGE();
     }
-    dbus_message_iter_init_append(reply, &reply_iter);
 
     if (!dbus_message_get_args(message, error, DBUS_TYPE_UINT32,
                                &deviceid, DBUS_TYPE_INVALID)) {
commit 99dd8b9414d1eb7aabc682be0b9cfd7a27eb2a6b
Author: Eric Anholt <eric at anholt.net>
Date:   Thu Sep 6 01:42:43 2007 -0700

    Bump version to 1.4.0.

diff --git a/configure.ac b/configure.ac
index 59b4fd2..62fdd78 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,7 +26,7 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ(2.57)
-AC_INIT([xorg-server], 1.3.99.2, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+AC_INIT([xorg-server], 1.4, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([dist-bzip2 foreign])
 AM_MAINTAINER_MODE
commit f73fd98a8636c0df3133a8b9428f3f23ecc788b4
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Sep 5 17:46:23 2007 -0700

    Fix key repeats during VT switch.
    
    Add keyc->postdown, which represents the key state as of the last mieqEnqueue
    call, and use it when we need to know the posted state, instead of the
    processed state (keyc->down).  Add small functions to getevents.c to query and
    modify key state in postdown and use them all through, eliminating previously
    broken uses.
    (cherry picked from commit 81c28ffd2b13a83770eadcfd7829d35d319d637f)

diff --git a/dix/devices.c b/dix/devices.c
index 923bc0d..9f3c576 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -868,6 +868,7 @@ InitKeyClassDeviceStruct(DeviceIntPtr dev, KeySymsPtr pKeySyms, CARD8 pModifiers
     else
 	bzero((char *)keyc->modifierMap, MAP_LENGTH);
     bzero((char *)keyc->down, DOWN_LENGTH);
+    bzero((char *)keyc->postdown, DOWN_LENGTH);
     for (i = 0; i < 8; i++)
 	keyc->modifierKeyCount[i] = 0;
     if (!SetKeySymsMap(&keyc->curKeySyms, pKeySyms) || !InitModMap(keyc))
diff --git a/dix/getevents.c b/dix/getevents.c
index 162fa45..f92a021 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -80,6 +80,23 @@ GetMotionHistorySize(void)
     return MOTION_HISTORY_SIZE;
 }
 
+static void
+set_key_down(DeviceIntPtr pDev, int key_code)
+{
+    pDev->key->postdown[key_code >> 3] |= (1 << (key_code & 7));
+}
+
+static void
+set_key_up(DeviceIntPtr pDev, int key_code)
+{
+    pDev->key->postdown[key_code >> 3] &= ~(1 << (key_code & 7));
+}
+
+static Bool
+key_is_down(DeviceIntPtr pDev, int key_code)
+{
+    return pDev->key->postdown[key_code >> 3] >> (key_code & 7);
+}
 
 /**
  * Allocate the motion history buffer.
@@ -414,17 +431,15 @@ GetKeyboardValuatorEvents(xEvent *events, DeviceIntPtr pDev, int type,
             case XK_Shift_Lock:
                 if (type == KeyRelease)
                     return 0;
-                else if (type == KeyPress &&
-                         (pDev->key->down[key_code >> 3] & (key_code & 7)) & 1)
-                        type = KeyRelease;
+                else if (type == KeyPress && key_is_down(pDev, key_code))
+                    type = KeyRelease;
         }
     }
 
     /* Handle core repeating, via press/release/press/release.
      * FIXME: In theory, if you're repeating with two keyboards in non-XKB,
      *        you could get unbalanced events here. */
-    if (type == KeyPress &&
-        (((pDev->key->down[key_code >> 3] & (key_code & 7))) & 1)) {
+    if (type == KeyPress && key_is_down(pDev, key_code)) {
         if (!pDev->kbdfeed->ctrl.autoRepeat ||
             pDev->key->modifierMap[key_code] ||
             !(pDev->kbdfeed->ctrl.autoRepeats[key_code >> 3]
@@ -449,6 +464,10 @@ GetKeyboardValuatorEvents(xEvent *events, DeviceIntPtr pDev, int type,
         events->u.keyButtonPointer.time = ms;
         events->u.u.type = type;
         events->u.u.detail = key_code;
+        if (type == KeyPress)
+	    set_key_down(inputInfo.keyboard, key_code);
+        else if (type == KeyRelease)
+	    set_key_up(inputInfo.keyboard, key_code);
         events++;
     }
 
@@ -456,10 +475,14 @@ GetKeyboardValuatorEvents(xEvent *events, DeviceIntPtr pDev, int type,
     kbp->time = ms;
     kbp->deviceid = pDev->id;
     kbp->detail = key_code;
-    if (type == KeyPress)
+    if (type == KeyPress) {
         kbp->type = DeviceKeyPress;
-    else if (type == KeyRelease)
+	set_key_down(pDev, key_code);
+    }
+    else if (type == KeyRelease) {
         kbp->type = DeviceKeyRelease;
+	set_key_up(pDev, key_code);
+    }
 
     events++;
     if (num_valuators) {
diff --git a/hw/xfree86/common/atKeynames.h b/hw/xfree86/common/atKeynames.h
index f31f533..85f13ac 100644
--- a/hw/xfree86/common/atKeynames.h
+++ b/hw/xfree86/common/atKeynames.h
@@ -66,7 +66,7 @@
 #define KanaMask	Mod4Mask
 #define ScrollLockMask	Mod5Mask
 
-#define KeyPressed(k) (keyc->down[k >> 3] & (1 << (k & 7)))
+#define KeyPressed(k) (keyc->postdown[k >> 3] & (1 << (k & 7)))
 #define ModifierDown(k) ((keyc->state & (k)) == (k))
 
 /*
diff --git a/include/inputstr.h b/include/inputstr.h
index 3398949..d0cc858 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -122,6 +122,7 @@ typedef struct _GrabRec {
 
 typedef struct _KeyClassRec {
     CARD8		down[DOWN_LENGTH];
+    CARD8		postdown[DOWN_LENGTH];
     KeyCode 		*modifierKeyMap;
     KeySymsRec		curKeySyms;
     int			modifierKeyCount[8];
commit 3c5fe1ec377688ab2edc6137b74a7c04b3bc2e7e
Author: Keith Packard <keithp at koto.keithp.com>
Date:   Wed Sep 5 14:19:19 2007 -0700

    Deliver correct event when releasing keys on VT switch.
    
    In commit 41bb9fce47f6366cc3f7d45790f7883f74289b5a, the event delivery loop
    for Xinput enabled keyboards was changed and accidentally used the wrong
    index variable, causing random events to be delivered when returning from VT
    switch.
    
    In addition, in commit aeba855b07832354f59678e20cc29a085e42bd99,
    SIGIO was blocked during delivery of these events, but not for the entire
    period the xf86Events array was being used. Block SIGIO for the whole loop
    to avoid other event delivery from trashing the key release events.
    (cherry picked from commit aa7ed1f5f35cd043bc38d985500aa0a32e857e84)
    (cherry picked from commit accd71bda6f958ea6892ad3a10879232d345774c)

diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index dd9c34e..91964c9 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -811,9 +811,11 @@ xf86ReleaseKeys(DeviceIntPtr pDev)
                     (*pDev->public.processInputProc) (&ke, pDev, 1);
                 }
                 else {
+		    int sigstate = xf86BlockSIGIO ();
                     nevents = GetKeyboardEvents(xf86Events, pDev, KeyRelease, i);
                     for (j = 0; j < nevents; j++)
-                        EqEnqueue(pDev, xf86Events + i);
+                        mieqEnqueue(pDev, xf86Events + j);
+		    xf86UnblockSIGIO(sigstate);
                 }
                 break;
             }
commit 70ed110538413e96cefbf0a1c276b52dc62c5aae
Author: Eric Anholt <eric at anholt.net>
Date:   Wed Sep 5 13:30:02 2007 -0700

    Fix server version reporting to be the server package version.
    
    Previously, the server version reported by xdpyinfo and Xorg -version would
    bear some vague resemblance to a X.Org katamari version, but in the presence
    of modularization (and client-server relationships with different katamari
    versions on each side) those numbers don't really make sense.  Instead, just
    report the package version.
    
    When branching a stable branch, master's version should be immediately updated
    to the endpoint of the stable branch plus a snapshot of 1 (for example,
    1.4.0.1 after server-1.4-branch).  The stable branch should then be changed to
    RC0 at that time (1.3.99.0, for example).
    
    This scheme was partially attempted for server 1.3, but lacked the appropriate
    master updates, thus why it had to be revisited now.  While here, we can also
    remove a lot of versioning complexity since everything is based on the package
    version.
    
    (cherry picked from commit 47300ed2be59d0ba7ea9345b954bf3104877c095)

diff --git a/configure.ac b/configure.ac
index 60f34c3..59b4fd2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,8 +26,6 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ(2.57)
-dnl This is the not the Xorg version number, it's the server version number.
-dnl Yes, that's weird.
 AC_INIT([xorg-server], 1.3.99.2, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([dist-bzip2 foreign])
@@ -371,14 +369,22 @@ case $host_os in
 esac
 AM_CONDITIONAL(KDRIVE_HW, test "x$KDRIVE_HW" = xyes)
 
-DEFAULT_VENDOR_NAME="The X.Org Foundation"
-DEFAULT_VENDOR_NAME_SHORT="X.Org"
-DEFAULT_VERSION_MAJOR=7
-DEFAULT_VERSION_MINOR=2
-DEFAULT_VERSION_PATCH=0
-DEFAULT_VERSION_SNAP=0
-DEFAULT_RELEASE_DATE="21 December 2005"
-DEFAULT_VENDOR_WEB="http://wiki.x.org"
+XORG_RELEASE_VERSION
+dnl augment XORG_RELEASE_VERSION for our snapshot number and to expose the
+dnl major number
+PVMAJOR=`echo $PACKAGE_VERSION | cut -d . -f 1`
+PVS=`echo $PACKAGE_VERSION | cut -d . -f 4`
+if test "x$PVS" = "x"; then
+	PVS="0"
+fi
+
+VENDOR_RELEASE="((($PVMAJOR) * 10000000) + (($PVM) * 100000) + (($PVP) * 1000) + $PVS)"
+VENDOR_MAN_VERSION="Version ${PACKAGE_VERSION}"
+
+VENDOR_NAME="The X.Org Foundation"
+VENDOR_NAME_SHORT="X.Org"
+RELEASE_DATE="5 September 2007"
+VENDOR_WEB="http://wiki.x.org"
 
 m4_ifdef([AS_HELP_STRING], , [m4_define([AS_HELP_STRING], m4_defn([AC_HELP_STRING]))])
 
@@ -394,36 +400,13 @@ AC_ARG_WITH(int10,           AS_HELP_STRING([--with-int10=BACKEND], [int10 backe
 				[INT10="$DEFAULT_INT10"])
 AC_ARG_WITH(vendor-name,     AS_HELP_STRING([--with-vendor-name=VENDOR],
 				  [Vendor string reported by the server]),
-			     	[ VENDOR_STRING="$withval" ],
-			     	[ VENDOR_STRING="$DEFAULT_VENDOR_NAME" ])
+				[ VENDOR_NAME="$withval" ], [])
 AC_ARG_WITH(vendor-name-short, AS_HELP_STRING([--with-vendor-name-short=VENDOR],
 				  [Short version of vendor string reported by the server]),
-			     	[ VENDOR_STRING_SHORT="$withval" ],
-			     	[ VENDOR_STRING_SHORT="$DEFAULT_VENDOR_NAME_SHORT" ])
-AC_ARG_WITH(release-major,   AS_HELP_STRING([--with-release-major=MAJOR],
-				  [Release major number reported by the server]),
-				[ VERSION_MAJOR="$withval" ],
-				[ VERSION_MAJOR="$DEFAULT_VERSION_MAJOR" ])
-AC_ARG_WITH(release-minor,   AS_HELP_STRING([--with-release-minor=MINOR],
-				  [Release minor number reported by the server]),
-				[ VERSION_MINOR="$withval" ],
-				[ VERSION_MINOR="$DEFAULT_VERSION_MINOR" ])
-AC_ARG_WITH(release-patch,   AS_HELP_STRING([--with-release-patch=PATCH],
-				  [Release patch number reported by the server]),
-				[ VERSION_PATCH="$withval" ],
-				[ VERSION_PATCH="$DEFAULT_VERSION_PATCH" ])
-AC_ARG_WITH(release-snap,    AS_HELP_STRING([--with-release-snap=SNAP],
-				  [Release snap number reported by the server]),
-				[ VERSION_SNAP="$withval" ],
-				[ VERSION_SNAP="$DEFAULT_VERSION_SNAP" ])
-AC_ARG_WITH(release-date,    AS_HELP_STRING([--with-release-date=DATE],
-				  [Release date reported by the server]),
-				[ RELEASE_DATE="$withval" ],
-				[ RELEASE_DATE="$DEFAULT_RELEASE_DATE" ])
+				[ VENDOR_NAME_SHORT="$withval" ], [])
 AC_ARG_WITH(vendor-web,      AS_HELP_STRING([--with-vendor-web=URL],
 				  [Vendor web address reported by the server]),
-				[ VENDOR_WEB="$withval" ],
-				[ VENDOR_WEB="$DEFAULT_VENDOR_WEB" ])
+				[ VENDOR_WEB="$withval" ], [])
 AC_ARG_WITH(module-dir,      AS_HELP_STRING([--with-module-dir=DIR],
 				  [Directory where modules are installed (default: $libdir/xorg/modules)]),
 				[ moduledir="$withval" ],
@@ -960,29 +943,13 @@ if test "x$USE_RGB_BUILTIN" = xyes; then
 	AC_DEFINE(USE_RGB_BUILTIN, 1, [Use built-in RGB color database])
 fi
 
-VENDOR_RELEASE="((($VERSION_MAJOR) * 10000000) + (($VERSION_MINOR) * 100000) + (($VERSION_PATCH) * 1000) + $VERSION_SNAP)"
-
-if test $VERSION_SNAP = "0"; then
-	if test $VERSION_PATCH = "0"; then
-		VENDOR_VERSION_STRING="${VERSION_MAJOR}.${VERSION_MINOR}"
-	else
-		VENDOR_VERSION_STRING="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"
-	fi
-else
-	VENDOR_VERSION_STRING="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_SNAP}"
-fi
-
-VENDOR_RELEASE_STRING="Release ${VENDOR_VERSION_STRING}"
-VENDOR_MAN_VERSION="Version ${VENDOR_VERSION_STRING}"
-
 AC_DEFINE_DIR(COMPILEDDEFAULTFONTPATH, FONTPATH, [Default font path])
 AC_DEFINE_DIR(RGB_DB, RGBPATH, [Default RGB path])
 AC_DEFINE_DIR(SERVERCONFIGdir, SERVERCONFIG, [Server config path])
 AC_DEFINE_DIR(BASE_FONT_PATH, FONTDIR, [Default base font path])
 AC_DEFINE_DIR(DRI_DRIVER_PATH, DRI_DRIVER_PATH, [Default DRI driver path])
-AC_DEFINE_UNQUOTED(XVENDORNAME, ["$VENDOR_STRING"], [Vendor name])
-AC_DEFINE_UNQUOTED(XVENDORNAMESHORT, ["$VENDOR_STRING_SHORT"], [Short vendor name])
-AC_DEFINE_UNQUOTED(XORG_RELEASE, ["$VENDOR_RELEASE_STRING"], [Vendor release])
+AC_DEFINE_UNQUOTED(XVENDORNAME, ["$VENDOR_NAME"], [Vendor name])
+AC_DEFINE_UNQUOTED(XVENDORNAMESHORT, ["$VENDOR_NAME_SHORT"], [Short vendor name])
 AC_DEFINE_UNQUOTED(XORG_DATE, ["$RELEASE_DATE"], [Vendor release])
 AC_DEFINE_UNQUOTED(XORG_MAN_VERSION, ["$VENDOR_MAN_VERSION"], [Vendor man version])
 AC_DEFINE_UNQUOTED(BUILDERADDR, ["$BUILDERADDR"], [Builder address])
@@ -995,8 +962,8 @@ AC_DEFINE_UNQUOTED(OSNAME, ["$OSNAME"], [Operating System Name])
 AC_DEFINE_UNQUOTED(OSVENDOR, ["$OSVENDOR"], [Operating System Vendor])
 AC_DEFINE_UNQUOTED(BUILDERSTRING, ["$BUILDERSTRING"], [Builder string])
 
-AC_SUBST([VENDOR_STRING])
-AC_SUBST([VENDOR_STRING_SHORT])
+AC_SUBST([VENDOR_NAME])
+AC_SUBST([VENDOR_NAME_SHORT])
 AC_SUBST([VENDOR_RELEASE])
 AC_SUBST([VENDOR_MAN_VERSION])
 
@@ -1352,7 +1319,7 @@ return 0;}
                AC_CHECK_LIB([Xplugin],[xp_init],[:])
                AC_SUBST([APPLE_APPLICATIONS_DIR])
                CFLAGS="${CFLAGS} -D__DARWIN__"
-               PLIST_VERSION_STRING=$VENDOR_VERSION_STRING
+               PLIST_VERSION_STRING=$PACKAGE_VERSION
                AC_SUBST([PLIST_VERSION_STRING])
                PLIST_VENDOR_WEB=$VENDOR_WEB
                AC_SUBST([PLIST_VENDOR_WEB])
@@ -1997,9 +1964,6 @@ AC_SUBST([libdir exec_prefix prefix])
 # Man page sections - used in config utils & generating man pages
 XORG_MANPAGE_SECTIONS
 
-# XORG in this case refers to the roll-up releases, not the Xorg DDX.
-XORG_RELEASE_VERSION
-
 AC_OUTPUT([
 Makefile
 GL/Makefile
diff --git a/dix/Makefile.am b/dix/Makefile.am
index 3c92a4a..28c2d8b 100644
--- a/dix/Makefile.am
+++ b/dix/Makefile.am
@@ -1,7 +1,7 @@
 noinst_LTLIBRARIES = libdix.la libxpstubs.la
 
 AM_CFLAGS = $(DIX_CFLAGS) \
-	-DVENDOR_STRING=\""@VENDOR_STRING@"\" \
+	-DVENDOR_NAME=\""@VENDOR_NAME@"\" \
 	-DVENDOR_RELEASE="@VENDOR_RELEASE@"
 
 libdix_la_SOURCES = 	\
diff --git a/dix/main.c b/dix/main.c
index 9fe822b..31e291b 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -509,7 +509,7 @@ main(int argc, char *argv[], char *envp[])
 }
 
 static int  VendorRelease = VENDOR_RELEASE;
-static char *VendorString = VENDOR_STRING;
+static char *VendorString = VENDOR_NAME;
 
 void
 SetVendorRelease(int release)
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index bf7dac6..0c9cbd4 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -1603,7 +1603,7 @@ xf86PrintBanner()
     "latest version in the X.Org Foundation git repository.\n"
     "See http://wiki.x.org/wiki/GitPage for git access instructions.\n");
 #endif
-  ErrorF("\nX Window System Version %d.%d.%d",
+  ErrorF("\nX.Org X Server %d.%d.%d",
 	 XORG_VERSION_MAJOR,
 	 XORG_VERSION_MINOR,
 	 XORG_VERSION_PATCH);
@@ -1637,8 +1637,8 @@ xf86PrintBanner()
 #define XORG_DATE XF86_DATE
 #endif
   ErrorF("\nRelease Date: %s\n", XORG_DATE);
-  ErrorF("X Protocol Version %d, Revision %d, %s\n",
-         X_PROTOCOL, X_PROTOCOL_REVISION, XORG_RELEASE );
+  ErrorF("X Protocol Version %d, Revision %d\n",
+         X_PROTOCOL, X_PROTOCOL_REVISION);
   ErrorF("Build Operating System: %s %s\n", OSNAME, OSVENDOR);
 #ifdef HAS_UTSNAME
   {
commit b328d553723ecf8f893783e91ec00ee6054acb74
Author: Alan Hourihane <alanh at fairlite.demon.co.uk>
Date:   Thu Aug 30 21:57:41 2007 +0100

    Allow yres_virtual to be greater for some kernel fbdev drivers.
    
    (temporary fix for older fbdev drivers)
    (cherry picked from commit 87495fc7064d5e0a7575a0713b6895a4172df0fa)

diff --git a/hw/xfree86/fbdevhw/fbdevhw.c b/hw/xfree86/fbdevhw/fbdevhw.c
index a573b8f..b7eabb2 100644
--- a/hw/xfree86/fbdevhw/fbdevhw.c
+++ b/hw/xfree86/fbdevhw/fbdevhw.c
@@ -239,7 +239,7 @@ static Bool
 fbdev_modes_equal(struct fb_var_screeninfo *set, struct fb_var_screeninfo *req)
 {
 	return (set->xres_virtual >= req->xres_virtual &&
-		set->yres_virtual == req->yres_virtual &&
+		set->yres_virtual >= req->yres_virtual &&
 		set->bits_per_pixel == req->bits_per_pixel &&
 		set->red.length == req->red.length &&
 		set->green.length == req->green.length &&
commit b69e6165136ff76ba4649bb9d11906fef27b78bc
Author: Keith Packard <keithp at koto.keithp.com>
Date:   Sat Sep 1 21:14:22 2007 -0700

    [COMPOSITE] Composite used for pixmap population on redirect. (Bug #7447)
    
    compNewPixmap copies bits from the parent window to the redirected child
    pixmap to populate the pixmap with reasonable data. It cannot always use
    CopyArea as that only works across matching depths. Use Composite when
    the depths do not match.
    (cherry picked from commit f98dfec79dadb70fa7bba84e7335f92b3a73dc02)

diff --git a/composite/compalloc.c b/composite/compalloc.c
index f555411..006e808 100644
--- a/composite/compalloc.c
+++ b/composite/compalloc.c
@@ -461,7 +461,6 @@ compNewPixmap (WindowPtr pWin, int x, int y, int w, int h)
     ScreenPtr	    pScreen = pWin->drawable.pScreen;
     WindowPtr	    pParent = pWin->parent;
     PixmapPtr	    pPixmap;
-    GCPtr	    pGC;
 
     pPixmap = (*pScreen->CreatePixmap) (pScreen, w, h, pWin->drawable.depth);
 
@@ -471,25 +470,63 @@ compNewPixmap (WindowPtr pWin, int x, int y, int w, int h)
     pPixmap->screen_x = x;
     pPixmap->screen_y = y;
     
-    pGC = GetScratchGC (pWin->drawable.depth, pScreen);
-    
-    /*
-     * Copy bits from the parent into the new pixmap so that it will
-     * have "reasonable" contents in case for background None areas.
-     */
-    if (pGC)
+    if (pParent->drawable.depth == pWin->drawable.depth)
     {
-	XID val = IncludeInferiors;
+	GCPtr	pGC = GetScratchGC (pWin->drawable.depth, pScreen);
 	
-	ValidateGC(&pPixmap->drawable, pGC);
-	dixChangeGC (serverClient, pGC, GCSubwindowMode, &val, NULL);
-	(*pGC->ops->CopyArea) (&pParent->drawable,
-			       &pPixmap->drawable,
-			       pGC,
-			       x - pParent->drawable.x,
-			       y - pParent->drawable.y,
-			       w, h, 0, 0);
-	FreeScratchGC (pGC);
+	/*
+	 * Copy bits from the parent into the new pixmap so that it will
+	 * have "reasonable" contents in case for background None areas.
+	 */
+	if (pGC)
+	{
+	    XID val = IncludeInferiors;
+	    
+	    ValidateGC(&pPixmap->drawable, pGC);
+	    dixChangeGC (serverClient, pGC, GCSubwindowMode, &val, NULL);
+	    (*pGC->ops->CopyArea) (&pParent->drawable,
+				   &pPixmap->drawable,
+				   pGC,
+				   x - pParent->drawable.x,
+				   y - pParent->drawable.y,
+				   w, h, 0, 0);
+	    FreeScratchGC (pGC);
+	}
+    }
+    else
+    {
+	PictFormatPtr	pSrcFormat = compWindowFormat (pParent);
+	PictFormatPtr	pDstFormat = compWindowFormat (pWin);
+	XID		inferiors = IncludeInferiors;
+	int		error;
+
+	PicturePtr	pSrcPicture = CreatePicture (None,
+						     &pParent->drawable,
+						     pSrcFormat,
+						     CPSubwindowMode,
+						     &inferiors,
+						     serverClient, &error);
+						    
+	PicturePtr	pDstPicture = CreatePicture (None,
+						     &pPixmap->drawable,
+						     pDstFormat,
+						     0, 0,
+						     serverClient, &error);
+
+	if (pSrcPicture && pDstPicture)
+	{
+	    CompositePicture (PictOpSrc,
+			      pSrcPicture,
+			      NULL,
+			      pDstPicture,
+			      x - pParent->drawable.x,
+			      y - pParent->drawable.y,
+			      0, 0, 0, 0, w, h);
+	}
+	if (pSrcPicture)
+	    FreePicture (pSrcPicture, 0);
+	if (pDstPicture)
+	    FreePicture (pDstPicture, 0);
     }
     return pPixmap;
 }
diff --git a/composite/compint.h b/composite/compint.h
index 2c4d5c0..a5ed24e 100644
--- a/composite/compint.h
+++ b/composite/compint.h
@@ -232,6 +232,9 @@ compCheckTree (ScreenPtr pScreen);
 #define compCheckTree(s)
 #endif
 
+PictFormatPtr
+compWindowFormat (WindowPtr pWin);
+
 void
 compSetPixmap (WindowPtr pWin, PixmapPtr pPixmap);
 
diff --git a/composite/compwindow.c b/composite/compwindow.c
index a4c4e6f..bfd2946 100644
--- a/composite/compwindow.c
+++ b/composite/compwindow.c
@@ -685,7 +685,7 @@ compGetWindowVisual (WindowPtr pWin)
     return 0;
 }
 
-static PictFormatPtr
+PictFormatPtr
 compWindowFormat (WindowPtr pWin)
 {
     ScreenPtr	pScreen = pWin->drawable.pScreen;
commit 87f98178417718d8720566a2df04857a682a2d15
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri Aug 31 22:11:13 2007 -0700

    [RANDR] Don't mark Xinerama as active if no crtcs are enabled. (bug #11504).
    
    Clients expect any Xinerama-enabled screen to report at least one
    monitor, but with RandR, there may not be any enabled crtcs. In this case,
    tell the client that Xinerama is not active.
    (cherry picked from commit 1afdf8b0a92437dffe84fa98b6083b3d8fd55e27)

diff --git a/randr/rrxinerama.c b/randr/rrxinerama.c
index 2a57e4e..896f61f 100644
--- a/randr/rrxinerama.c
+++ b/randr/rrxinerama.c
@@ -148,12 +148,6 @@ ProcRRXineramaGetState(ClientPtr client)
 }
 
 static Bool
-RRXineramaScreenActive (ScreenPtr pScreen)
-{
-    return rrGetScrPriv(pScreen) != NULL;
-}
-
-static Bool
 RRXineramaCrtcActive (RRCrtcPtr crtc)
 {
     return crtc->mode != NULL && crtc->numOutputs > 0;
@@ -165,7 +159,7 @@ RRXineramaScreenCount (ScreenPtr pScreen)
     int	i, n;
     
     n = 0;
-    if (RRXineramaScreenActive (pScreen))
+    if (rrGetScrPriv (pScreen))
     {
 	rrScrPriv(pScreen);
 	for (i = 0; i < pScrPriv->numCrtcs; i++)
@@ -175,6 +169,12 @@ RRXineramaScreenCount (ScreenPtr pScreen)
     return n;
 }
 
+static Bool
+RRXineramaScreenActive (ScreenPtr pScreen)
+{
+    return RRXineramaScreenCount (pScreen) > 0;
+}
+
 int
 ProcRRXineramaGetScreenCount(ClientPtr client)
 {
commit 61460cf095a655d8711b79225080a8c2808dbbc4
Author: Marius Gedminas <mgedmin at b4net.lt>
Date:   Fri Aug 31 21:36:37 2007 -0700

    [RANDR] Compare only milliseconds of config time. (Bug #6502)
    
    The timestamp transferred in the X protocol is a 32-bit number of
    milliseconds.
    
    The timestamp stored in the server is a structure that contains two fields:
    months (!) and milliseconds.
    
    When the server passes the config timestamp to the client, it discards the
    months part and sends only the milliseconds part.
    
    When the server receives the config timestamp from the client, it tries to
    guess the "months" part by looking at the current time and then maybe adding
    or
    subtracting one.  The guess is wrong after the server has been running long
    enough (several hours).
    
    I have added two ErrorF calls around the 'if' statement that returns
    RRSetConfigInvalidConfigTimestamp in randr/randr.c and my Xorg.0.log has
    this:
    
      randr request got good config time: 0:-2103495671
    
    for the first few successful xrandr calls, and
    
      randr request failed with RRSetConfigInvalidConfigTime: client passed
      1:-2103495671, server has 0:-2103495671
    
    when it fails.  The server has been running for 8 and a half hours.
    
    The obvious fix would be to ignore the months field and only compare the
    milliseconds.
    (cherry picked from commit 0dc2bb6101704d0fd25f36e2c3df79687f119f5b)

diff --git a/randr/rrscreen.c b/randr/rrscreen.c
index 8798b42..811a557 100644
--- a/randr/rrscreen.c
+++ b/randr/rrscreen.c
@@ -766,7 +766,6 @@ ProcRRSetScreenConfig (ClientPtr client)
     pScrPriv = rrGetScrPriv(pScreen);
     
     time = ClientTimeToServerTime(stuff->timestamp);
-    configTime = ClientTimeToServerTime(stuff->configTimestamp);
     
     if (!pScrPriv)
     {
@@ -788,11 +787,15 @@ ProcRRSetScreenConfig (ClientPtr client)
     crtc = output->crtc;
 
     /*
-     * if the client's config timestamp is not the same as the last config
+     * If the client's config timestamp is not the same as the last config
      * timestamp, then the config information isn't up-to-date and
-     * can't even be validated
+     * can't even be validated.
+     *
+     * Note that the client only knows about the milliseconds part of the
+     * timestamp, so using CompareTimeStamps here would cause randr to suddenly
+     * stop working after several hours have passed (freedesktop bug #6502).
      */
-    if (CompareTimeStamps (configTime, pScrPriv->lastConfigTime) != 0)
+    if (stuff->configTimestamp != pScrPriv->lastConfigTime.milliseconds)
     {
 	rep.status = RRSetConfigInvalidConfigTime;
 	goto sendReply;
commit ec56c5e958248ea0161dda885fa59752b20f5d7c
Author: Eric Anholt <eric at anholt.net>
Date:   Fri Aug 31 20:02:52 2007 -0700

    Bump version to 1.3.99.2.

diff --git a/configure.ac b/configure.ac
index da90ede..60f34c3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,7 +28,7 @@ dnl Process this file with autoconf to create configure.
 AC_PREREQ(2.57)
 dnl This is the not the Xorg version number, it's the server version number.
 dnl Yes, that's weird.
-AC_INIT([xorg-server], 1.3.99.1, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+AC_INIT([xorg-server], 1.3.99.2, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([dist-bzip2 foreign])
 AM_MAINTAINER_MODE
commit 5efc4bd7d0e2020242127d8ed83efb8d2d76a151
Author: Eric Anholt <eric at anholt.net>
Date:   Fri Aug 31 18:27:41 2007 -0700

    Remove backend.[ch] from neomagic to fix distcheck.
    (cherry picked from commit 917e3bb83a48da7618fce463cf6283be36cd9084)

diff --git a/hw/kdrive/neomagic/Makefile.am b/hw/kdrive/neomagic/Makefile.am
index 4686547..95f0e1e 100644
--- a/hw/kdrive/neomagic/Makefile.am
+++ b/hw/kdrive/neomagic/Makefile.am
@@ -19,8 +19,6 @@ bin_PROGRAMS = Xneomagic
 noinst_LIBRARIES = libneomagic.a
 
 libneomagic_a_SOURCES =         \
-	backend.h                   \
-	backend.c                   \
 	neomagic.c                  \
 	neomagic.h                  \
 	neo_draw.c
commit 1a125b521434da7ba3a41b6398c7f094867908e0
Author: Eric Anholt <eric at anholt.net>
Date:   Fri Aug 31 15:16:01 2007 -0700

    Bug #7364: Require renderproto 0.9.3 on 64-bit, and fix build with it.
    
    (cherry picked from commit 07630d897ef37cad8b79d073d9edc891d5a7bddd)

diff --git a/configure.ac b/configure.ac
index ad6ae4b..da90ede 100644
--- a/configure.ac
+++ b/configure.ac
@@ -628,7 +628,13 @@ PKG_CHECK_MODULES(PIXMAN, $PIXMAN)
 AC_SUBST(PIXMAN_CFLAGS)
 
 dnl Core modules for most extensions, et al.
-REQUIRED_MODULES="[randrproto >= 1.2] renderproto [fixesproto >= 4.0] [damageproto >= 1.1] xcmiscproto xextproto [xproto >= 7.0.9] xtrans [scrnsaverproto >= 1.1] bigreqsproto resourceproto fontsproto [inputproto >= 1.4.2] [kbproto >= 1.0.3]"
+# Require updated renderproto for ABI sanity if we're 64-bit.
+if test "$ac_cv_sizeof_unsigned_long" = 8; then
+	RENDERPROTO="[renderproto >= 0.9.3]"
+else
+	RENDERPROTO="renderproto"
+fi
+REQUIRED_MODULES="[randrproto >= 1.2] $RENDERPROTO [fixesproto >= 4.0] [damageproto >= 1.1] xcmiscproto xextproto [xproto >= 7.0.9] xtrans [scrnsaverproto >= 1.1] bigreqsproto resourceproto fontsproto [inputproto >= 1.4.2] [kbproto >= 1.0.3]"
 REQUIRED_LIBS="xfont xau fontenc $PIXMAN"
 
 dnl HAVE_DBUS is true if we actually have the D-Bus library, whereas
diff --git a/render/picturestr.h b/render/picturestr.h
index 01572ec..aabce84 100644
--- a/render/picturestr.h
+++ b/render/picturestr.h
@@ -24,8 +24,8 @@
 #ifndef _PICTURESTR_H_
 #define _PICTURESTR_H_
 
-#include "glyphstr.h"
 #include "scrnintstr.h"
+#include "glyphstr.h"
 #include "resource.h"
 
 typedef struct _DirectFormat {
commit f499c2ea0a90a69713daef8f9497463229384964
Author: Eric Anholt <eric at anholt.net>
Date:   Fri Aug 31 13:00:23 2007 -0700

    Bug #7186: Fix an excessive request size limitation that broke big-requests.
    
    MAXBUFSIZE appears to be a leftover of some previous time.  Instead, just
    use maxBigRequestSize when bigreqs are available (limiting buffers to ~16MB).
    When bigreqs are not available, needed won't be larger than the maximum
    size of a non-bigreqs request (256kB).
    (cherry picked from commit ca82d4bddf235c9b68d51d68636bab40eafb9889)

diff --git a/os/io.c b/os/io.c
index 835af54..9de75ee 100644
--- a/os/io.c
+++ b/os/io.c
@@ -304,12 +304,14 @@ ReadRequestFromClient(ClientPtr client)
 	 */
 
 	oci->lenLastReq = 0;
-	if (needed > MAXBUFSIZE)
+#ifdef BIGREQS
+	if (needed > maxBigRequestSize << 2)
 	{
 	    /* request is too big for us to handle */
 	    YieldControlDeath();
 	    return -1;
 	}
+#endif
 	if ((gotnow == 0) ||
 	    ((oci->bufptr - oci->buffer + needed) > oci->size))
 	{
diff --git a/os/osdep.h b/os/osdep.h
index 965436d..2d455aa 100644
--- a/os/osdep.h
+++ b/os/osdep.h
@@ -55,9 +55,6 @@ SOFTWARE.
 #define BOTIMEOUT 200 /* in milliseconds */
 #define BUFSIZE 4096
 #define BUFWATERMARK 8192
-#ifndef MAXBUFSIZE
-#define MAXBUFSIZE (1 << 22)
-#endif
 
 #include <X11/Xdmcp.h>
 
commit 3e9ecdcb132bb223febc396626211aa2681e4c79
Author: Matthieu Herrb <matthieu at bluenote.herrb.com>
Date:   Thu Aug 23 22:11:56 2007 +0200

    Remove an extra cast.
    
    Thou should not apply patches manually without testing.
    (cherry picked from commit a66c0f1dca2958835ff65a5b50579e3304ed316a)

diff --git a/dix/getevents.c b/dix/getevents.c
index 52b74bd..162fa45 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -250,7 +250,7 @@ acceleratePointer(DeviceIntPtr pDev, int first_valuator, int num_valuators,
             }
         }
         else {
-		mult = pow((float)((float)dx * (float)dx + (float)dy * (float)dy),
+		mult = pow((float)dx * (float)dx + (float)dy * (float)dy,
                        ((float)(pDev->ptrfeed->ctrl.num) /
                         (float)(pDev->ptrfeed->ctrl.den) - 1.0) /
                        2.0) / 2.0;
commit a964d541283e93b1096150275ba2d95594bf77ea
Author: Otto Moerbeek <otto at openbsd.org>
Date:   Thu Aug 23 21:59:25 2007 +0200

    A high resolution device that's moving fast can potentially generate
    an int overflow, making dx*dx+dy*dy negative. Now pow(negative,
    non-integer) yields NaN, so you loose.  Use fp math to avoid that.
    (cherry picked from commit 12d27cf33c6d963eae77795c0d247175907162a5)

diff --git a/dix/getevents.c b/dix/getevents.c
index 2a10038..52b74bd 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -250,7 +250,7 @@ acceleratePointer(DeviceIntPtr pDev, int first_valuator, int num_valuators,
             }
         }
         else {
-            mult = pow((float)(dx * dx + dy * dy),
+		mult = pow((float)((float)dx * (float)dx + (float)dy * (float)dy),
                        ((float)(pDev->ptrfeed->ctrl.num) /
                         (float)(pDev->ptrfeed->ctrl.den) - 1.0) /
                        2.0) / 2.0;
commit bcd6708895e5c2fda423bb13fe42b078ef293b13
Author: Egbert Eich <eich at freedesktop.org>
Date:   Thu Aug 30 12:50:21 2007 +0200

    Fixing a misleading comment which could suggest a GPL violation.
    
    The author of the int10 code looked at the VBIOS POSTing code
    in DOSEMU to get some initial idea on how to POST a VBIOS.
    To give credit to the DOSEMU Team for this inspiration a comment
    was added to the code which could suggest that code from the
    GPLed DOSEMU was directly incorporated into this code.
    This patch should clearify the situation.
    (cherry picked from commit 1d11e4bc4ccb169fb23fc18583f0b648f0a6a4e0)

diff --git a/hw/xfree86/int10/helper_exec.c b/hw/xfree86/int10/helper_exec.c
index a41965d..a12a9a0 100644
--- a/hw/xfree86/int10/helper_exec.c
+++ b/hw/xfree86/int10/helper_exec.c
@@ -3,8 +3,8 @@
  *   execute BIOS int 10h calls in x86 real mode environment
  *                 Copyright 1999 Egbert Eich
  *
- *   Part of this is based on code taken from DOSEMU
- *   (C) Copyright 1992, ..., 1999 the "DOSEMU-Development-Team"
+ *   Part of this code was inspired  by the VBIOS POSTing code in DOSEMU
+ *   developed by the "DOSEMU-Development-Team"
  */
 
 /*
commit ed001ed363d11aff3df9a7de2f72075e0b2cfb7b
Author: Eric Anholt <eric at anholt.net>
Date:   Wed Aug 29 15:54:32 2007 -0700

    Bug #9629: Remove badly-licensed neomagic kdrive files.
    
    Licensing issues of these files include:
    - They claim to be licensed under the GPL, yet we haven't allowed that in the
      xserver repository in the past.
    - They refer the user to the top of the tree for GPL license text, yet it isn't
      there.
    - They claim to be derived from the (MIT-licensed) ati kdrive code, yet don't
      follow the licensing terms of those files.
    (cherry picked from commit 87295b66a972a2bd194a79af6aa4f715018fcded)

diff --git a/hw/kdrive/Makefile.am b/hw/kdrive/Makefile.am
index 267d772..5803644 100644
--- a/hw/kdrive/Makefile.am
+++ b/hw/kdrive/Makefile.am
@@ -1,5 +1,5 @@
 if KDRIVEVESA
-VESA_SUBDIRS = vesa ati chips epson i810 mach64 mga neomagic nvidia pm2 r128 \
+VESA_SUBDIRS = vesa ati chips epson i810 mach64 mga nvidia pm2 r128 \
                smi via
 endif
 
diff --git a/hw/kdrive/neomagic/backend.c b/hw/kdrive/neomagic/backend.c
deleted file mode 100644
index 12fbf03..0000000
--- a/hw/kdrive/neomagic/backend.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Generic card driving functions.
- * Essentially, cascades calls to fbdev and vesa to initialize cards that
- * do not have hardware-specific routines yet. Copied from the ati driver.
- *
- * Copyright (c) 2004 Brent Cook <busterb at mail.utexas.edu>
- *
- * This code is licensed under the GPL.  See the file COPYING in the root
- * directory of the sources for details.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "backend.h"
-
-Bool
-backendInitialize(KdCardInfo *card, BackendInfo *backend)
-{
-    Bool success = FALSE;
-
-#ifdef KDRIVEVESA
-    if (!success && vesaInitialize(card, &backend->priv.vesa)) {
-        success = TRUE;
-        backend->type = VESA;
-        backend->cardfini = vesaCardFini;
-        backend->scrfini = vesaScreenFini;
-        backend->initScreen = vesaInitScreen;
-        backend->finishInitScreen = vesaFinishInitScreen;
-        backend->createRes = vesaCreateResources;
-        backend->preserve = vesaPreserve;
-        backend->restore = vesaRestore;
-        backend->dpms = vesaDPMS;
-        backend->enable = vesaEnable;
-        backend->disable = vesaDisable;
-        backend->getColors = vesaGetColors;
-        backend->putColors = vesaPutColors;
-    }
-#endif
-#ifdef KDRIVEFBDEV
-    if (!success && fbdevInitialize(card, &backend->priv.fbdev)) {
-        success = TRUE;
-        backend->type = FBDEV;
-        backend->cardfini = fbdevCardFini;
-        backend->scrfini = fbdevScreenFini;
-        backend->initScreen = fbdevInitScreen;
-        backend->finishInitScreen = fbdevFinishInitScreen;
-        backend->createRes = fbdevCreateResources;
-        backend->preserve = fbdevPreserve;
-        backend->restore = fbdevRestore;
-        backend->dpms = fbdevDPMS;
-        backend->enable = fbdevEnable;
-        backend->disable = fbdevDisable;
-        backend->getColors = fbdevGetColors;
-        backend->putColors = fbdevPutColors;
-    }
-#endif
-    return success;
-}
-
-Bool
-backendScreenInitialize(KdScreenInfo *screen, BackendScreen *backendScreen,
-                        BackendInfo *backendCard)
-{
-    Bool success = FALSE;
-
-#ifdef KDRIVEFBDEV
-    if (backendCard->type == FBDEV) {
-        screen->card->driver = &backendCard->priv.fbdev;
-        success = fbdevScreenInitialize(screen, &backendScreen->fbdev);
-        screen->memory_size = backendCard->priv.fbdev.fix.smem_len;
-        screen->off_screen_base = backendCard->priv.fbdev.var.yres_virtual
-                                * screen->fb[0].byteStride;
-    }
-#endif
-#ifdef KDRIVEVESA
-    if (backendCard->type == VESA) {
-		screen->card->driver = &backendCard->priv.vesa;
-        if (screen->fb[0].depth == 0) {
-            screen->fb[0].depth = 16;
-        }
-        success = vesaScreenInitialize(screen, &backendScreen->vesa);
-    }
-#endif
-    return success;
-}
diff --git a/hw/kdrive/neomagic/backend.h b/hw/kdrive/neomagic/backend.h
deleted file mode 100644
index 33eae26..0000000
--- a/hw/kdrive/neomagic/backend.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Generic card driving functions.
- * Essentially, cascades calls to fbdev and vesa to initialize cards that
- * do not have hardware-specific routines yet. Copied from the ati driver.
- *
- * Copyright (c) 2004 Brent Cook <busterb at mail.utexas.edu>
- *
- * This code is licensed under the GPL.  See the file COPYING in the root
- * directory of the sources for details.
- */
-
-#ifndef _BACKEND_H_
-#define _BACKEND_H_
-#include "kdrive.h"
-
-#ifdef KDRIVEFBDEV
-#include <fbdev.h>
-#endif
-#ifdef KDRIVEVESA
-#include <vesa.h>
-#endif
-
-typedef enum _BackendType {VESA, FBDEV} BackendType;
-
-typedef struct _BackendInfo {
-    // backend info
-    BackendType type;
-
-    // backend internal structures
-    union {
-#ifdef KDRIVEFBDEV
-        FbdevPriv fbdev;
-#endif
-#ifdef KDRIVEVESA
-        VesaCardPrivRec vesa;
-#endif
-    } priv;
-
-    // pointers to helper functions for this backend
-    void (*cardfini)(KdCardInfo *);
-    void (*scrfini)(KdScreenInfo *);
-    Bool (*initScreen)(ScreenPtr);
-    Bool (*finishInitScreen)(ScreenPtr pScreen);
-    Bool (*createRes)(ScreenPtr);
-    void (*preserve)(KdCardInfo *);
-    void (*restore)(KdCardInfo *);
-    Bool (*dpms)(ScreenPtr, int);
-    Bool (*enable)(ScreenPtr);
-    void (*disable)(ScreenPtr);
-    void (*getColors)(ScreenPtr, int, int, xColorItem *);
-    void (*putColors)(ScreenPtr, int, int, xColorItem *);
-} BackendInfo;
-
-typedef union _BackendScreen {
-#ifdef KDRIVEFBDEV
-    FbdevScrPriv fbdev;
-#endif
-#ifdef KDRIVEVESA
-    VesaScreenPrivRec vesa;
-#endif
-} BackendScreen;
-
-Bool
-backendInitialize(KdCardInfo *card, BackendInfo *backend);
-
-Bool
-backendScreenInitialize(KdScreenInfo *screen, BackendScreen *backendScreen,
-                        BackendInfo *backendCard);
-
-#endif
commit 5182fbf302beae93ea5b71a40a23528ee83fa1cc
Author: Alex Deucher <alex at botch2.(none)>
Date:   Wed Aug 22 19:26:34 2007 -0400

    Add _X_EXPORT to exported functions in hw/xfree86/modes/*
    
    Also add missing exports to hw/xfree86/loader/xf86sym.c
    (cherry picked from commit 81f8b652d99ee0f7116c1e34aed0e585d23a91fb)

diff --git a/hw/xfree86/loader/xf86sym.c b/hw/xfree86/loader/xf86sym.c
index 185eb80..23f8208 100644
--- a/hw/xfree86/loader/xf86sym.c
+++ b/hw/xfree86/loader/xf86sym.c
@@ -1153,9 +1153,12 @@ _X_HIDDEN void *xfree86LookupTab[] = {
     SYMFUNC(xf86CrtcCreate)
     SYMFUNC(xf86CrtcDestroy)
     SYMFUNC(xf86CrtcInUse)
+    SYMFUNC(xf86CrtcSetScreenSubpixelOrder)
+    SYMFUNC(xf86RotateCloseScreen)
     SYMFUNC(xf86CrtcRotate)
     SYMFUNC(xf86CrtcSetMode)
     SYMFUNC(xf86CrtcSetSizeRange)
+    SYMFUNC(xf86CrtcScreenInit)
     SYMFUNC(xf86CVTMode)
     SYMFUNC(xf86DisableUnusedFunctions)
     SYMFUNC(xf86DPMSSet)
@@ -1168,18 +1171,25 @@ _X_HIDDEN void *xfree86LookupTab[] = {
     SYMFUNC(xf86ModesAdd)
     SYMFUNC(xf86ModesEqual)
     SYMFUNC(xf86ModeVRefresh)
+    SYMFUNC(xf86ModeWidth)
+    SYMFUNC(xf86ModeHeight)
     SYMFUNC(xf86OutputCreate)
     SYMFUNC(xf86OutputDestroy)
     SYMFUNC(xf86OutputGetEDID)
+    SYMFUNC(xf86ConnectorGetName)
     SYMFUNC(xf86OutputGetEDIDModes)
     SYMFUNC(xf86OutputRename)
+    SYMFUNC(xf86OutputUseScreenMonitor)
     SYMFUNC(xf86OutputSetEDID)
+    SYMFUNC(xf86OutputFindClosestMode)
     SYMFUNC(xf86PrintModeline)
     SYMFUNC(xf86ProbeOutputModes)
     SYMFUNC(xf86PruneInvalidModes)
     SYMFUNC(xf86SetModeCrtc)
     SYMFUNC(xf86SetModeDefaultName)
     SYMFUNC(xf86SetScrnInfoModes)
+    SYMFUNC(xf86SetDesiredModes)
+    SYMFUNC(xf86SetSingleMode)
     SYMFUNC(xf86ValidateModesClocks)
     SYMFUNC(xf86ValidateModesFlags)
     SYMFUNC(xf86ValidateModesSize)
@@ -1197,6 +1207,7 @@ _X_HIDDEN void *xfree86LookupTab[] = {
     SYMFUNC(xf86RandR12PreInit)
     SYMFUNC(xf86RandR12SetConfig)
     SYMFUNC(xf86RandR12SetRotations)
+    SYMFUNC(xf86RandR12TellChanged)
 #endif
     SYMFUNC(xf86_cursors_init)
     SYMFUNC(xf86_reload_cursors)
diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 5a6fc3a..d375da8 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -53,7 +53,7 @@
 
 int xf86CrtcConfigPrivateIndex = -1;
 
-void
+_X_EXPORT void
 xf86CrtcConfigInit (ScrnInfoPtr scrn,
 		    const xf86CrtcConfigFuncsRec *funcs)
 {
@@ -68,7 +68,7 @@ xf86CrtcConfigInit (ScrnInfoPtr scrn,
     scrn->privates[xf86CrtcConfigPrivateIndex].ptr = config;
 }
  
-void
+_X_EXPORT void
 xf86CrtcSetSizeRange (ScrnInfoPtr scrn,
 		      int minWidth, int minHeight,
 		      int maxWidth, int maxHeight)
@@ -84,7 +84,7 @@ xf86CrtcSetSizeRange (ScrnInfoPtr scrn,
 /*
  * Crtc functions
  */
-xf86CrtcPtr
+_X_EXPORT xf86CrtcPtr
 xf86CrtcCreate (ScrnInfoPtr		scrn,
 		const xf86CrtcFuncsRec	*funcs)
 {
@@ -116,7 +116,7 @@ xf86CrtcCreate (ScrnInfoPtr		scrn,
     return crtc;
 }
 
-void
+_X_EXPORT void
 xf86CrtcDestroy (xf86CrtcPtr crtc)
 {
     xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
@@ -140,7 +140,7 @@ xf86CrtcDestroy (xf86CrtcPtr crtc)
  * Return whether any outputs are connected to the specified pipe
  */
 
-Bool
+_X_EXPORT Bool
 xf86CrtcInUse (xf86CrtcPtr crtc)
 {
     ScrnInfoPtr		pScrn = crtc->scrn;
@@ -153,7 +153,7 @@ xf86CrtcInUse (xf86CrtcPtr crtc)
     return FALSE;
 }
 
-void
+_X_EXPORT void
 xf86CrtcSetScreenSubpixelOrder (ScreenPtr pScreen)
 {
 #ifdef RENDER
@@ -221,7 +221,7 @@ xf86CrtcSetScreenSubpixelOrder (ScreenPtr pScreen)
 /**
  * Sets the given video mode on the given crtc
  */
-Bool
+_X_EXPORT Bool
 xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation,
 		 int x, int y)
 {
@@ -492,7 +492,7 @@ xf86OutputInitialRotation (xf86OutputPtr output)
     return RR_Rotate_0;
 }
 
-xf86OutputPtr
+_X_EXPORT xf86OutputPtr
 xf86OutputCreate (ScrnInfoPtr		    scrn,
 		  const xf86OutputFuncsRec  *funcs,
 		  const char		    *name)
@@ -552,7 +552,7 @@ xf86OutputCreate (ScrnInfoPtr		    scrn,
     return output;
 }
 
-Bool
+_X_EXPORT Bool
 xf86OutputRename (xf86OutputPtr output, const char *name)
 {
     int	    len = strlen(name) + 1;
@@ -571,7 +571,7 @@ xf86OutputRename (xf86OutputPtr output, const char *name)
     return TRUE;
 }
 
-void
+_X_EXPORT void
 xf86OutputUseScreenMonitor (xf86OutputPtr output, Bool use_screen_monitor)
 {
     if (use_screen_monitor != output->use_screen_monitor)
@@ -581,7 +581,7 @@ xf86OutputUseScreenMonitor (xf86OutputPtr output, Bool use_screen_monitor)
     }
 }
 
-void
+_X_EXPORT void
 xf86OutputDestroy (xf86OutputPtr output)
 {
     ScrnInfoPtr		scrn = output->scrn;
@@ -657,7 +657,7 @@ xf86CrtcCloseScreen (int index, ScreenPtr screen)
 /*
  * Called at ScreenInit time to set up
  */
-Bool
+_X_EXPORT Bool
 xf86CrtcScreenInit (ScreenPtr screen)
 {
     ScrnInfoPtr		scrn = xf86Screens[screen->myNum];
@@ -1214,7 +1214,7 @@ xf86SortModes (DisplayModePtr input)
     return output;
 }
 
-void
+_X_EXPORT void
 xf86ProbeOutputModes (ScrnInfoPtr scrn, int maxX, int maxY)
 {
     xf86CrtcConfigPtr	config = XF86_CRTC_CONFIG_PTR(scrn);
@@ -1455,10 +1455,10 @@ xf86ProbeOutputModes (ScrnInfoPtr scrn, int maxX, int maxY)
  */
 
 /* XXX where does this function belong? Here? */
-void
+_X_EXPORT void
 xf86RandR12GetOriginalVirtualSize(ScrnInfoPtr scrn, int *x, int *y);
 
-void
+_X_EXPORT void
 xf86SetScrnInfoModes (ScrnInfoPtr scrn)
 {
     xf86CrtcConfigPtr	config = XF86_CRTC_CONFIG_PTR(scrn);
@@ -1526,7 +1526,7 @@ xf86SetScrnInfoModes (ScrnInfoPtr scrn)
  * accordingly.
  */
 
-Bool
+_X_EXPORT Bool
 xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
 {
     xf86CrtcConfigPtr	config = XF86_CRTC_CONFIG_PTR(scrn);
@@ -1730,7 +1730,7 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
  * modes (used in EnterVT functions, or at server startup)
  */
 
-Bool
+_X_EXPORT Bool
 xf86SetDesiredModes (ScrnInfoPtr scrn)
 {
     xf86CrtcConfigPtr   config = XF86_CRTC_CONFIG_PTR(scrn);
@@ -1810,7 +1810,7 @@ xf86SetDesiredModes (ScrnInfoPtr scrn)
  * - Closer in refresh rate to the requested mode.
  */
 
-DisplayModePtr
+_X_EXPORT DisplayModePtr
 xf86OutputFindClosestMode (xf86OutputPtr output, DisplayModePtr desired)
 {
     DisplayModePtr	best = NULL, scan = NULL;
@@ -1873,7 +1873,7 @@ xf86OutputFindClosestMode (xf86OutputPtr output, DisplayModePtr desired)
  * mode across all outputs that are currently active.
  */
 
-Bool
+_X_EXPORT Bool
 xf86SetSingleMode (ScrnInfoPtr pScrn, DisplayModePtr desired, Rotation rotation)
 {
     xf86CrtcConfigPtr	config = XF86_CRTC_CONFIG_PTR(pScrn);
@@ -1945,7 +1945,7 @@ xf86SetSingleMode (ScrnInfoPtr pScrn, DisplayModePtr desired, Rotation rotation)
  * If the new mode is off, it will turn off outputs and then CRTCs.
  * Otherwise, it will affect CRTCs before outputs.
  */
-void
+_X_EXPORT void
 xf86DPMSSet(ScrnInfoPtr scrn, int mode, int flags)
 {
     xf86CrtcConfigPtr	config = XF86_CRTC_CONFIG_PTR(scrn);
@@ -1983,7 +1983,7 @@ xf86DPMSSet(ScrnInfoPtr scrn, int mode, int flags)
  * Even for monitors with no DPMS support, by the definition of our DPMS hooks,
  * the outputs will still get disabled (blanked).
  */
-Bool
+_X_EXPORT Bool
 xf86SaveScreen(ScreenPtr pScreen, int mode)
 {
     ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
@@ -1999,7 +1999,7 @@ xf86SaveScreen(ScreenPtr pScreen, int mode)
 /**
  * Disable all inactive crtcs and outputs
  */
-void
+_X_EXPORT void
 xf86DisableUnusedFunctions(ScrnInfoPtr pScrn)
 {
     xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
@@ -2053,7 +2053,7 @@ xf86OutputSetEDIDProperty (xf86OutputPtr output, void *data, int data_len)
 /**
  * Set the EDID information for the specified output
  */
-void
+_X_EXPORT void
 xf86OutputSetEDID (xf86OutputPtr output, xf86MonPtr edid_mon)
 {
     ScrnInfoPtr		scrn = output->scrn;
@@ -2119,7 +2119,7 @@ xf86OutputSetEDID (xf86OutputPtr output, xf86MonPtr edid_mon)
  * Return the list of modes supported by the EDID information
  * stored in 'output'
  */
-DisplayModePtr
+_X_EXPORT DisplayModePtr
 xf86OutputGetEDIDModes (xf86OutputPtr output)
 {
     ScrnInfoPtr	scrn = output->scrn;
@@ -2130,7 +2130,7 @@ xf86OutputGetEDIDModes (xf86OutputPtr output)
     return xf86DDCGetModes(scrn->scrnIndex, edid_mon);
 }
 
-xf86MonPtr
+_X_EXPORT xf86MonPtr
 xf86OutputGetEDID (xf86OutputPtr output, I2CBusPtr pDDCBus)
 {
     ScrnInfoPtr	scrn = output->scrn;
@@ -2141,7 +2141,7 @@ xf86OutputGetEDID (xf86OutputPtr output, I2CBusPtr pDDCBus)
 static char *_xf86ConnectorNames[] = { "None", "VGA", "DVI-I", "DVI-D",
 				      "DVI-A", "Composite", "S-Video",
 				      "Component", "LFP", "Proprietary" };
-char *
+_X_EXPORT char *
 xf86ConnectorGetName(xf86ConnectorType connector)
 {
     return _xf86ConnectorNames[connector];
@@ -2223,7 +2223,7 @@ xf86_covering_crtc(ScrnInfoPtr pScrn,
  * clip video to that
  */
 
-Bool
+_X_EXPORT Bool
 xf86_crtc_clip_video_helper(ScrnInfoPtr pScrn,
 			    xf86CrtcPtr *crtc_ret,
 			    xf86CrtcPtr desired_crtc,
diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c
index 92b90a9..b510164 100644
--- a/hw/xfree86/modes/xf86Cursors.c
+++ b/hw/xfree86/modes/xf86Cursors.c
@@ -256,7 +256,7 @@ xf86_crtc_hide_cursor (xf86CrtcPtr crtc)
     }
 }
 
-void
+_X_EXPORT void
 xf86_hide_cursors (ScrnInfoPtr scrn)
 {
     xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
@@ -282,7 +282,7 @@ xf86_crtc_show_cursor (xf86CrtcPtr crtc)
     }
 }
 
-void
+_X_EXPORT void
 xf86_show_cursors (ScrnInfoPtr scrn)
 {
     xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
@@ -528,7 +528,7 @@ xf86_load_cursor_argb (ScrnInfoPtr scrn, CursorPtr cursor)
     }
 }
 
-Bool
+_X_EXPORT Bool
 xf86_cursors_init (ScreenPtr screen, int max_width, int max_height, int flags)
 {
     ScrnInfoPtr		scrn = xf86Screens[screen->myNum];
@@ -579,7 +579,7 @@ xf86_cursors_init (ScreenPtr screen, int max_width, int max_height, int flags)
  * Reloads cursor images as needed, then adjusts cursor positions
  */
 
-void
+_X_EXPORT void
 xf86_reload_cursors (ScreenPtr screen)
 {
     ScrnInfoPtr		scrn;
@@ -622,7 +622,7 @@ xf86_reload_cursors (ScreenPtr screen)
 /**
  * Clean up CRTC-based cursor code
  */
-void
+_X_EXPORT void
 xf86_cursors_fini (ScreenPtr screen)
 {
     ScrnInfoPtr		scrn = xf86Screens[screen->myNum];
diff --git a/hw/xfree86/modes/xf86DiDGA.c b/hw/xfree86/modes/xf86DiDGA.c
index 0964cef..f40d0ab 100644
--- a/hw/xfree86/modes/xf86DiDGA.c
+++ b/hw/xfree86/modes/xf86DiDGA.c
@@ -255,7 +255,7 @@ static DGAFunctionRec xf86_dga_funcs = {
    NULL
 };
 
-Bool
+_X_EXPORT Bool
 xf86DiDGAReInit (ScreenPtr pScreen)
 {
     ScrnInfoPtr		scrn = xf86Screens[pScreen->myNum];
@@ -267,7 +267,7 @@ xf86DiDGAReInit (ScreenPtr pScreen)
     return DGAReInitModes (pScreen, xf86_config->dga_modes, xf86_config->dga_nmode);
 }
 
-Bool
+_X_EXPORT Bool
 xf86DiDGAInit (ScreenPtr pScreen, unsigned long dga_address)
 {
     ScrnInfoPtr		scrn = xf86Screens[pScreen->myNum];
diff --git a/hw/xfree86/modes/xf86EdidModes.c b/hw/xfree86/modes/xf86EdidModes.c
index 908593b..8b5e69d 100644
--- a/hw/xfree86/modes/xf86EdidModes.c
+++ b/hw/xfree86/modes/xf86EdidModes.c
@@ -303,7 +303,7 @@ DDCGuessRangesFromModes(int scrnIndex, MonPtr Monitor, DisplayModePtr Modes)
     }
 }
 
-DisplayModePtr
+_X_EXPORT DisplayModePtr
 xf86DDCGetModes(int scrnIndex, xf86MonPtr DDC)
 {
     int preferred, i;
@@ -389,7 +389,7 @@ xf86DDCGetModes(int scrnIndex, xf86MonPtr DDC)
 /*
  * Fill out MonPtr with xf86MonPtr information.
  */
-void
+_X_EXPORT void
 xf86DDCMonitorSet(int scrnIndex, MonPtr Monitor, xf86MonPtr DDC)
 {
     DisplayModePtr Modes = NULL, Mode;
diff --git a/hw/xfree86/modes/xf86Modes.c b/hw/xfree86/modes/xf86Modes.c
index ea9f85b..f49c292 100644
--- a/hw/xfree86/modes/xf86Modes.c
+++ b/hw/xfree86/modes/xf86Modes.c
@@ -49,7 +49,7 @@ extern XF86ConfigPtr xf86configptr;
  *
  * Exact copy of xf86Mode.c's.
  */
-double
+_X_EXPORT double
 xf86ModeHSync(DisplayModePtr mode)
 {
     double hsync = 0.0;
@@ -67,7 +67,7 @@ xf86ModeHSync(DisplayModePtr mode)
  *
  * Exact copy of xf86Mode.c's.
  */
-double
+_X_EXPORT double
 xf86ModeVRefresh(DisplayModePtr mode)
 {
     double refresh = 0.0;
@@ -86,7 +86,7 @@ xf86ModeVRefresh(DisplayModePtr mode)
     return refresh;
 }
 
-int
+_X_EXPORT int
 xf86ModeWidth (DisplayModePtr mode, Rotation rotation)
 {
     switch (rotation & 0xf) {
@@ -101,7 +101,7 @@ xf86ModeWidth (DisplayModePtr mode, Rotation rotation)
     }
 }
 
-int
+_X_EXPORT int
 xf86ModeHeight (DisplayModePtr mode, Rotation rotation)
 {
     switch (rotation & 0xf) {
@@ -117,7 +117,7 @@ xf86ModeHeight (DisplayModePtr mode, Rotation rotation)
 }
 
 /** Sets a default mode name of <width>x<height> on a mode. */
-void
+_X_EXPORT void
 xf86SetModeDefaultName(DisplayModePtr mode)
 {
     if (mode->name != NULL)
@@ -134,7 +134,7 @@ xf86SetModeDefaultName(DisplayModePtr mode)
  *
  * Exact copy of xf86Mode.c's.
  */
-void
+_X_EXPORT void
 xf86SetModeCrtc(DisplayModePtr p, int adjustFlags)
 {
     if ((p == NULL) || ((p->type & M_T_CRTC_C) == M_T_BUILTIN))
@@ -185,7 +185,7 @@ xf86SetModeCrtc(DisplayModePtr p, int adjustFlags)
 /**
  * Allocates and returns a copy of pMode, including pointers within pMode.
  */
-DisplayModePtr
+_X_EXPORT DisplayModePtr
 xf86DuplicateMode(DisplayModePtr pMode)
 {
     DisplayModePtr pNew;
@@ -209,7 +209,7 @@ xf86DuplicateMode(DisplayModePtr pMode)
  *
  * \param modeList doubly-linked mode list
  */
-DisplayModePtr
+_X_EXPORT DisplayModePtr
 xf86DuplicateModes(ScrnInfoPtr pScrn, DisplayModePtr modeList)
 {
     DisplayModePtr first = NULL, last = NULL;
@@ -243,7 +243,7 @@ xf86DuplicateModes(ScrnInfoPtr pScrn, DisplayModePtr modeList)
  *
  * This isn't in xf86Modes.c, but it might deserve to be there.
  */
-Bool
+_X_EXPORT Bool
 xf86ModesEqual(DisplayModePtr pMode1, DisplayModePtr pMode2)
 {
      if (pMode1->Clock == pMode2->Clock &&
@@ -279,7 +279,7 @@ add(char **p, char *new)
  *
  * Convenient VRefresh printing was added, though, compared to xf86Mode.c
  */
-void
+_X_EXPORT void
 xf86PrintModeline(int scrnIndex,DisplayModePtr mode)
 {
     char tmp[256];
@@ -327,7 +327,7 @@ xf86PrintModeline(int scrnIndex,DisplayModePtr mode)
  *
  * This is not in xf86Modes.c, but would be part of the proposed new API.
  */
-void
+_X_EXPORT void
 xf86ValidateModesFlags(ScrnInfoPtr pScrn, DisplayModePtr modeList,
 			    int flags)
 {
@@ -348,7 +348,7 @@ xf86ValidateModesFlags(ScrnInfoPtr pScrn, DisplayModePtr modeList,
  *
  * This is not in xf86Modes.c, but would be part of the proposed new API.
  */
-void
+_X_EXPORT void
 xf86ValidateModesSize(ScrnInfoPtr pScrn, DisplayModePtr modeList,
 			  int maxX, int maxY, int maxPitch)
 {
@@ -377,7 +377,7 @@ xf86ValidateModesSize(ScrnInfoPtr pScrn, DisplayModePtr modeList,
  *
  * This is not in xf86Modes.c, but would be part of the proposed new API.
  */
-void
+_X_EXPORT void
 xf86ValidateModesSync(ScrnInfoPtr pScrn, DisplayModePtr modeList,
 			  MonPtr mon)
 {
@@ -424,7 +424,7 @@ xf86ValidateModesSync(ScrnInfoPtr pScrn, DisplayModePtr modeList,
  *
  * This is not in xf86Modes.c, but would be part of the proposed new API.
  */
-void
+_X_EXPORT void
 xf86ValidateModesClocks(ScrnInfoPtr pScrn, DisplayModePtr modeList,
 			    int *min, int *max, int n_ranges)
 {
@@ -458,7 +458,7 @@ xf86ValidateModesClocks(ScrnInfoPtr pScrn, DisplayModePtr modeList,
  *
  * This is not in xf86Modes.c, but would be part of the proposed new API.
  */
-void
+_X_EXPORT void
 xf86ValidateModesUserConfig(ScrnInfoPtr pScrn, DisplayModePtr modeList)
 {
     DisplayModePtr mode;
@@ -492,7 +492,7 @@ xf86ValidateModesUserConfig(ScrnInfoPtr pScrn, DisplayModePtr modeList)
  *
  * This is not in xf86Modes.c, but would be part of the proposed new API.
  */
-void
+_X_EXPORT void
 xf86PruneInvalidModes(ScrnInfoPtr pScrn, DisplayModePtr *modeList,
 			  Bool verbose)
 {
@@ -526,7 +526,7 @@ xf86PruneInvalidModes(ScrnInfoPtr pScrn, DisplayModePtr *modeList,
  *
  * \param modes doubly-linked mode list.
  */
-DisplayModePtr
+_X_EXPORT DisplayModePtr
 xf86ModesAdd(DisplayModePtr modes, DisplayModePtr new)
 {
     if (modes == NULL)
@@ -592,7 +592,7 @@ xf86GetConfigModes (XF86ConfModeLinePtr conf_mode)
 /**
  * Build a mode list from a monitor configuration
  */
-DisplayModePtr
+_X_EXPORT DisplayModePtr
 xf86GetMonitorModes (ScrnInfoPtr pScrn, XF86ConfMonitorPtr conf_monitor)
 {
     DisplayModePtr	    modes = NULL;
@@ -624,7 +624,7 @@ xf86GetMonitorModes (ScrnInfoPtr pScrn, XF86ConfMonitorPtr conf_monitor)
 /**
  * Build a mode list containing all of the default modes
  */
-DisplayModePtr
+_X_EXPORT DisplayModePtr
 xf86GetDefaultModes (Bool interlaceAllowed, Bool doubleScanAllowed)
 {
     DisplayModePtr  head = NULL, prev = NULL, mode;
diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index 9d74e53..e46d8a0 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -244,7 +244,7 @@ xf86RandR12SetMode (ScreenPtr	    pScreen,
     return ret;
 }
 
-Bool
+_X_EXPORT Bool
 xf86RandR12SetConfig (ScreenPtr		pScreen,
 		    Rotation		rotation,
 		    int			rate,
@@ -372,7 +372,7 @@ finish:
     return ret;
 }
 
-Rotation
+_X_EXPORT Rotation
 xf86RandR12GetRotation(ScreenPtr pScreen)
 {
     XF86RandRInfoPtr	    randrp = XF86RANDRINFO(pScreen);
@@ -380,7 +380,7 @@ xf86RandR12GetRotation(ScreenPtr pScreen)
     return randrp->rotation;
 }
 
-Bool
+_X_EXPORT Bool
 xf86RandR12CreateScreenResources (ScreenPtr pScreen)
 {
     ScrnInfoPtr		pScrn = xf86Screens[pScreen->myNum];
@@ -470,7 +470,7 @@ xf86RandR12CreateScreenResources (ScreenPtr pScreen)
 }
 
 
-Bool
+_X_EXPORT Bool
 xf86RandR12Init (ScreenPtr pScreen)
 {
     rrScrPrivPtr	rp;
@@ -520,7 +520,7 @@ xf86RandR12Init (ScreenPtr pScreen)
     return TRUE;
 }
 
-void
+_X_EXPORT void
 xf86RandR12SetRotations (ScreenPtr pScreen, Rotation rotations)
 {
     XF86RandRInfoPtr	randrp = XF86RANDRINFO(pScreen);
@@ -538,7 +538,7 @@ xf86RandR12SetRotations (ScreenPtr pScreen, Rotation rotations)
     randrp->supported_rotations = rotations;
 }
 
-void
+_X_EXPORT void
 xf86RandR12GetOriginalVirtualSize(ScrnInfoPtr pScrn, int *x, int *y)
 {
     ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex];
@@ -1072,7 +1072,7 @@ xf86RandR12CreateScreenResources12 (ScreenPtr pScreen)
  * to DGA, VidMode or hot key. Tell RandR
  */
 
-void
+_X_EXPORT void
 xf86RandR12TellChanged (ScreenPtr pScreen)
 {
     ScrnInfoPtr		pScrn = xf86Screens[pScreen->myNum];
@@ -1122,7 +1122,7 @@ xf86RandR12Init12 (ScreenPtr pScreen)
 
 #endif
 
-Bool
+_X_EXPORT Bool
 xf86RandR12PreInit (ScrnInfoPtr pScrn)
 {
     return TRUE;
diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c
index 4016b97..380478f 100644
--- a/hw/xfree86/modes/xf86Rotate.c
+++ b/hw/xfree86/modes/xf86Rotate.c
@@ -478,7 +478,7 @@ xf86RotateDestroy (xf86CrtcPtr crtc)
     }
 }
 
-void
+_X_EXPORT void
 xf86RotateCloseScreen (ScreenPtr screen)
 {
     ScrnInfoPtr		scrn = xf86Screens[screen->myNum];
@@ -489,7 +489,7 @@ xf86RotateCloseScreen (ScreenPtr screen)
 	xf86RotateDestroy (xf86_config->crtc[c]);
 }
 
-Bool
+_X_EXPORT Bool
 xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation)
 {
     ScrnInfoPtr		pScrn = crtc->scrn;
commit 37954c019afd92edbe4aaa9d6deb6efaad7bf088
Author: Brian Paul <brian.paul at tungstengraphics.com>
Date:   Thu Aug 23 19:38:53 2007 +0200

    glx: fix crash when freeing visuals
    
    Don't set screen->num_vis to a value greater than the actual number of visuals.
    
    X.Org Bug #10809 <http://bugs.freedesktop.org/show_bug.cgi?id=10809>
    (cherry picked from commit ff089e6cae634ac3eb509abd448a250bcbb17275)

diff --git a/GL/glx/glxglcore.c b/GL/glx/glxglcore.c
index df9be07..679d55c 100644
--- a/GL/glx/glxglcore.c
+++ b/GL/glx/glxglcore.c
@@ -296,7 +296,7 @@ static void init_screen_visuals(__GLXMESAscreen *screen)
     __GLcontextModes *modes;
     XMesaVisual *pXMesaVisual;
     int *used;
-    int i, j, size;
+    int num_vis, j, size;
 
     /* Alloc space for the list of XMesa visuals */
     size = screen->base.numVisuals * sizeof(XMesaVisual);
@@ -312,7 +312,7 @@ static void init_screen_visuals(__GLXMESAscreen *screen)
     used = (int *) xalloc(pScreen->numVisuals * sizeof(int));
     memset(used, 0, pScreen->numVisuals * sizeof(int));
 
-    i = 0;
+    num_vis = 0;
     for ( modes = screen->base.modes; modes != NULL; modes = modes->next ) {
 	const int vis_class = _gl_convert_to_x_visual_type( modes->visualType );
 	const int nplanes = (modes->rgbBits - modes->alphaBits);
@@ -327,7 +327,8 @@ static void init_screen_visuals(__GLXMESAscreen *screen)
 		!used[j]) {
 
 		/* Create the XMesa visual */
-		pXMesaVisual[i] =
+                assert(num_vis < screen->base.numVisuals);
+		pXMesaVisual[num_vis] =
 		    XMesaCreateVisual(pScreen,
 				      &pVis[j],
 				      modes->rgbMode,
@@ -364,13 +365,15 @@ static void init_screen_visuals(__GLXMESAscreen *screen)
 	    FatalError( "Matching visual found, but visualID still -1!\n" );
 	}
 
-	i++;
+	num_vis++;
     }
 
     xfree(used);
 
-    screen->num_vis = pScreen->numVisuals;
+    screen->num_vis = num_vis;
     screen->xm_vis = pXMesaVisual;
+
+    assert(screen->num_vis <= screen->base.numVisuals);
 }
 
 static __GLXscreen *
commit d34b66402c9205aae38316c5855f3b492a7612c2
Author: Dave Airlie <airlied at redhat.com>
Date:   Thu Aug 23 16:22:03 2007 +1000

    randr: fixup crtc and output destroy
    
    if you are moving pointers, you want to move the pointers not just a byte
    (cherry picked from commit 76bf3cd7b8c6189b6b08518cde00c8bd991bdfb7)

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 08306bc..5a6fc3a 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -128,7 +128,7 @@ xf86CrtcDestroy (xf86CrtcPtr crtc)
 	{
 	    memmove (&xf86_config->crtc[c],
 		     &xf86_config->crtc[c+1],
-		     xf86_config->num_crtc - (c + 1));
+		     ((xf86_config->num_crtc - (c + 1)) * sizeof(void*)));
 	    xf86_config->num_crtc--;
 	    break;
 	}
@@ -596,7 +596,7 @@ xf86OutputDestroy (xf86OutputPtr output)
 	{
 	    memmove (&xf86_config->output[o],
 		     &xf86_config->output[o+1],
-		     xf86_config->num_output - (o + 1));
+		     ((xf86_config->num_output - (o + 1)) * sizeof(void*)));
 	    xf86_config->num_output--;
 	    break;
 	}
commit efac9c9c2e7cfa974fb0e7737832f0e34d156f65
Author: Keith Packard <keithp at koto.keithp.com>
Date:   Sun Aug 19 20:28:05 2007 -0700

    Ref count cursors used in hw/xfree86/modes code.
    
    The multi-crtc cursor code in hw/xfree86/modes holds a reference to the
    current cursor. This reference must be correctly ref counted so the cursor
    is not freed out from underneath this code.
    (cherry picked from commit 7dc8531548cc9573e28bb04363dcbb3af5864c9a)

diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c
index 396bf30..92b90a9 100644
--- a/hw/xfree86/modes/xf86Cursors.c
+++ b/hw/xfree86/modes/xf86Cursors.c
@@ -447,7 +447,10 @@ xf86_use_hw_cursor (ScreenPtr screen, CursorPtr cursor)
     xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
     xf86CursorInfoPtr	cursor_info = xf86_config->cursor_info;
 
+    if (xf86_config->cursor)
+	FreeCursor (xf86_config->cursor, None);
     xf86_config->cursor = cursor;
+    ++cursor->refcnt;
     
     if (cursor->bits->width > cursor_info->MaxWidth ||
 	cursor->bits->height> cursor_info->MaxHeight)
@@ -463,7 +466,10 @@ xf86_use_hw_cursor_argb (ScreenPtr screen, CursorPtr cursor)
     xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
     xf86CursorInfoPtr	cursor_info = xf86_config->cursor_info;
     
+    if (xf86_config->cursor)
+	FreeCursor (xf86_config->cursor, None);
     xf86_config->cursor = cursor;
+    ++cursor->refcnt;
     
     /* Make sure ARGB support is available */
     if ((cursor_info->Flags & HARDWARE_CURSOR_ARGB) == 0)
@@ -632,4 +638,9 @@ xf86_cursors_fini (ScreenPtr screen)
 	xfree (xf86_config->cursor_image);
 	xf86_config->cursor_image = NULL;
     }
+    if (xf86_config->cursor)
+    {
+	FreeCursor (xf86_config->cursor, None);
+	xf86_config->cursor = NULL;
+    }
 }
commit 248b220b3e2bf8d999241543b69be3022a728b3a
Author: Alex Deucher <alex at botch2.com>
Date:   Tue Aug 21 00:37:33 2007 -0400

    add xf86_crtc_clip_video_helper to xf86sym.c
    (cherry picked from commit 1f6ddae003ec65d6bc567831bf32bf75dfefdd6c)

diff --git a/hw/xfree86/loader/xf86sym.c b/hw/xfree86/loader/xf86sym.c
index 8a2768d..185eb80 100644
--- a/hw/xfree86/loader/xf86sym.c
+++ b/hw/xfree86/loader/xf86sym.c
@@ -1203,6 +1203,7 @@ _X_HIDDEN void *xfree86LookupTab[] = {
     SYMFUNC(xf86_show_cursors)
     SYMFUNC(xf86_hide_cursors)
     SYMFUNC(xf86_cursors_fini)
+    SYMFUNC(xf86_crtc_clip_video_helper)
 
     SYMFUNC(xf86DoEDID_DDC1)
     SYMFUNC(xf86DoEDID_DDC2)
commit 242c05e326646cbe1ab6ced54504456fee327bce
Author: Alex Deucher <alex at botch2.com>
Date:   Mon Aug 20 19:46:38 2007 -0400

    move intel crtc xv clipping helper to the xserver
    
    The code is generic and can be used by any overlay-based card when
    adding randr 1.2 support.  Tested on radeon.
    (cherry picked from commit 53c04351c462d2ae307684e50d5960debe1ee557)

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 170c921..08306bc 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -45,6 +45,8 @@
 #include "picturestr.h"
 #endif
 
+#include "xf86xv.h"
+
 /*
  * Initialize xf86CrtcConfig structure
  */
@@ -2144,3 +2146,119 @@ xf86ConnectorGetName(xf86ConnectorType connector)
 {
     return _xf86ConnectorNames[connector];
 }
+
+static void
+x86_crtc_box_intersect(BoxPtr dest, BoxPtr a, BoxPtr b)
+{
+    dest->x1 = a->x1 > b->x1 ? a->x1 : b->x1;
+    dest->x2 = a->x2 < b->x2 ? a->x2 : b->x2;
+    dest->y1 = a->y1 > b->y1 ? a->y1 : b->y1;
+    dest->y2 = a->y2 < b->y2 ? a->y2 : b->y2;
+
+    if (dest->x1 >= dest->x2 || dest->y1 >= dest->y2)
+	dest->x1 = dest->x2 = dest->y1 = dest->y2 = 0;
+}
+
+static void
+x86_crtc_box(xf86CrtcPtr crtc, BoxPtr crtc_box)
+{
+    if (crtc->enabled) {
+	crtc_box->x1 = crtc->x;
+	crtc_box->x2 = crtc->x + xf86ModeWidth(&crtc->mode, crtc->rotation);
+	crtc_box->y1 = crtc->y;
+	crtc_box->y2 = crtc->y + xf86ModeHeight(&crtc->mode, crtc->rotation);
+    } else
+	crtc_box->x1 = crtc_box->x2 = crtc_box->y1 = crtc_box->y2 = 0;
+}
+
+static int
+xf86_crtc_box_area(BoxPtr box)
+{
+    return (int) (box->x2 - box->x1) * (int) (box->y2 - box->y1);
+}
+
+/*
+ * Return the crtc covering 'box'. If two crtcs cover a portion of
+ * 'box', then prefer 'desired'. If 'desired' is NULL, then prefer the crtc
+ * with greater coverage
+ */
+
+static xf86CrtcPtr
+xf86_covering_crtc(ScrnInfoPtr pScrn,
+		   BoxPtr      box,
+		   xf86CrtcPtr desired,
+		   BoxPtr      crtc_box_ret)
+{
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+    xf86CrtcPtr		crtc, best_crtc;
+    int			coverage, best_coverage;
+    int			c;
+    BoxRec		crtc_box, cover_box;
+
+    best_crtc = NULL;
+    best_coverage = 0;
+    crtc_box_ret->x1 = 0;
+    crtc_box_ret->x2 = 0;
+    crtc_box_ret->y1 = 0;
+    crtc_box_ret->y2 = 0;
+    for (c = 0; c < xf86_config->num_crtc; c++) {
+	crtc = xf86_config->crtc[c];
+	x86_crtc_box(crtc, &crtc_box);
+	x86_crtc_box_intersect(&cover_box, &crtc_box, box);
+	coverage = xf86_crtc_box_area(&cover_box);
+	if (coverage && crtc == desired) {
+	    *crtc_box_ret = crtc_box;
+	    return crtc;
+	} else if (coverage > best_coverage) {
+	    *crtc_box_ret = crtc_box;
+	    best_crtc = crtc;
+	    best_coverage = coverage;
+	}
+    }
+    return best_crtc;
+}
+
+/*
+ * For overlay video, compute the relevant CRTC and
+ * clip video to that
+ */
+
+Bool
+xf86_crtc_clip_video_helper(ScrnInfoPtr pScrn,
+			    xf86CrtcPtr *crtc_ret,
+			    xf86CrtcPtr desired_crtc,
+			    BoxPtr      dst,
+			    INT32	*xa,
+			    INT32	*xb,
+			    INT32	*ya,
+			    INT32	*yb,
+			    RegionPtr   reg,
+			    INT32	width,
+			    INT32	height)
+{
+    Bool	ret;
+    RegionRec	crtc_region_local;
+    RegionPtr	crtc_region = reg;
+    
+    if (crtc_ret) {
+	BoxRec		crtc_box;
+	xf86CrtcPtr	crtc = xf86_covering_crtc(pScrn, dst,
+						  desired_crtc,
+						  &crtc_box);
+
+	if (crtc) {
+	    REGION_INIT (pScreen, &crtc_region_local, &crtc_box, 1);
+	    crtc_region = &crtc_region_local;
+	    REGION_INTERSECT (pScreen, crtc_region, crtc_region, reg);
+	}
+	*crtc_ret = crtc;
+    }
+
+    ret = xf86XVClipVideoHelper(dst, xa, xb, ya, yb, 
+				crtc_region, width, height);
+
+    if (crtc_region != reg)
+	REGION_UNINIT (pScreen, &crtc_region_local);
+
+    return ret;
+}
diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h
index a4e8ea3..9693e12 100644
--- a/hw/xfree86/modes/xf86Crtc.h
+++ b/hw/xfree86/modes/xf86Crtc.h
@@ -765,5 +765,24 @@ xf86_hide_cursors (ScrnInfoPtr scrn);
  */
 void
 xf86_cursors_fini (ScreenPtr screen);
+
+/*
+ * For overlay video, compute the relevant CRTC and
+ * clip video to that.
+ * wraps xf86XVClipVideoHelper()
+ */
+
+Bool
+xf86_crtc_clip_video_helper(ScrnInfoPtr pScrn,
+			    xf86CrtcPtr *crtc_ret,
+			    xf86CrtcPtr desired_crtc,
+			    BoxPtr      dst,
+			    INT32	*xa,
+			    INT32	*xb,
+			    INT32	*ya,
+			    INT32	*yb,
+			    RegionPtr   reg,
+			    INT32	width,
+			    INT32	height);
     
 #endif /* _XF86CRTC_H_ */
commit dd33e936b39d1c5229353d3f25c47e3b87de8498
Author: Fredrik Höglund <fredrik at kde.org>
Date:   Sat Aug 18 19:02:18 2007 +0200

    EXA: Fix a couple of logic errors in exaGetPixmapFirstPixel.
    
    The fb pointer would be left uninitialized when exaPixmapIsOffscreen
    returned false. When it returned true and the pixmap was damaged,
    fb would be initialized from the pixmap's devPrivate.ptr before the
    exaDoMigration and exaPrepareAccess calls, at which point
    devPrivate.ptr would still be pointing at offscreen memory.
    (cherry picked from commit 3c448b0eb67337b56641e09a6d168aad6745e3ef)

diff --git a/exa/exa_unaccel.c b/exa/exa_unaccel.c
index b67ea63..a94648b 100644
--- a/exa/exa_unaccel.c
+++ b/exa/exa_unaccel.c
@@ -382,19 +382,19 @@ exaGetPixmapFirstPixel (PixmapPtr pPixmap)
     ExaMigrationRec pixmaps[1];
     ExaPixmapPriv (pPixmap);
 
+    fb = pExaPixmap->sys_ptr;
+
     /* Try to avoid framebuffer readbacks */
-    if (exaPixmapIsOffscreen(pPixmap)) {
-	if (!miPointInRegion(DamageRegion(pExaPixmap->pDamage), 0, 0,  &box)) {
-	    fb = pExaPixmap->sys_ptr;
-	} else {
-	    need_finish = TRUE;
-	    fb = pPixmap->devPrivate.ptr;
-	    pixmaps[0].as_dst = FALSE;
-	    pixmaps[0].as_src = TRUE;
-	    pixmaps[0].pPix = pPixmap;
-	    exaDoMigration (pixmaps, 1, FALSE);
-	    exaPrepareAccess(&pPixmap->drawable, EXA_PREPARE_SRC);
-	}
+    if (exaPixmapIsOffscreen(pPixmap) &&
+        miPointInRegion(DamageRegion(pExaPixmap->pDamage), 0, 0,  &box))
+    {
+	need_finish = TRUE;
+	pixmaps[0].as_dst = FALSE;
+	pixmaps[0].as_src = TRUE;
+	pixmaps[0].pPix = pPixmap;
+	exaDoMigration (pixmaps, 1, FALSE);
+	exaPrepareAccess(&pPixmap->drawable, EXA_PREPARE_SRC);
+	fb = pPixmap->devPrivate.ptr;
     }
 
     switch (pPixmap->drawable.bitsPerPixel) {
commit ec126e29e4a270577bba6337ed6f4ec8dbce46f9
Author: Søren Sandmann Pedersen <sandmann at redhat.com>
Date:   Tue Aug 21 14:26:14 2007 -0400

    Require pixman 0.9.5; Use pixman_image_set_source_clipping() to fix
    bug 11620 (reported by Jens Stroebel.
    (cherry picked from commit 53941c8e68014619d3ded7f8bc0f07d9a38bb9b1)

diff --git a/configure.ac b/configure.ac
index 41cc103..ad6ae4b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -623,7 +623,7 @@ XEXT_INC='-I$(top_srcdir)/Xext'
 XEXT_LIB='$(top_builddir)/Xext/libXext.la'
 XEXTXORG_LIB='$(top_builddir)/Xext/libXextbuiltin.la'
 
-PIXMAN="[pixman-1 >= 0.9.4]"
+PIXMAN="[pixman-1 >= 0.9.5]"
 PKG_CHECK_MODULES(PIXMAN, $PIXMAN)
 AC_SUBST(PIXMAN_CFLAGS)
 
diff --git a/fb/fbpict.c b/fb/fbpict.c
index 8a146dd..85b5171 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -397,6 +397,7 @@ set_image_properties (pixman_image_t *image, PicturePtr pict)
     }
     
     pixman_image_set_filter (image, filter, (pixman_fixed_t *)pict->filter_params, pict->filter_nparams);
+    pixman_image_set_source_clipping (image, TRUE);
 }
 
 pixman_image_t *
commit 71ddf917d7449b721582c910c5026faa457597fe
Author: Aaron Plattner <aplattner at nvidia.com>
Date:   Thu Aug 16 17:43:29 2007 -0700

    stride is in FbBits-sized chunks, but xoff is not.
    
    Fixes corruption problems with composite rendering to redirected windows in
    depth 16.
    (cherry picked from commit 6a32a96d8df184c3ace4847beb48fdcb846d2286)

diff --git a/fb/fbpict.c b/fb/fbpict.c
index 4d1ad0b..8a146dd 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -291,9 +291,9 @@ create_bits_picture (PicturePtr pict,
     pixman_image_t *image;
     
     fbGetDrawable (pict->pDrawable, bits, stride, bpp, xoff, yoff);
-    
-    bits += yoff * stride + xoff;
-    
+
+    bits = (CARD8*)bits + yoff * stride * sizeof(FbBits) + xoff * (bpp / 8);
+
     image = pixman_image_create_bits (
 	pict->format,
 	pict->pDrawable->width, pict->pDrawable->height,
commit 7cc53ae10adb7f8bb59f904b1362b7391b327f83
Author: Aaron Plattner <aplattner at nvidia.com>
Date:   Thu Aug 16 14:57:18 2007 -0700

    Bug #12015: Use the right offsets in the dst arguments of pixman_blt.
    (cherry picked from commit 32666d77227fcd2c066de16bf3c07366f92b0457)

diff --git a/fb/fbcopy.c b/fb/fbcopy.c
index 3ad01bf..68f403f 100644
--- a/fb/fbcopy.c
+++ b/fb/fbcopy.c
@@ -64,8 +64,8 @@ fbCopyNtoN (DrawablePtr	pSrcDrawable,
 	    if (!pixman_blt ((uint32_t *)src, (uint32_t *)dst, srcStride, dstStride, srcBpp, dstBpp,
 			     (pbox->x1 + dx + srcXoff),
 			     (pbox->y1 + dy + srcYoff),
-			     (pbox->x1 + srcXoff),
-			     (pbox->y1 + srcYoff),
+			     (pbox->x1 + dstXoff),
+			     (pbox->y1 + dstYoff),
 			     (pbox->x2 - pbox->x1),
 			     (pbox->y2 - pbox->y1)))
 		goto fallback;
commit 2bf6cb3074d9c0dcd706e8e083747c6d84b70e30
Author: Julien Cristau <jcristau at debian.org>
Date:   Tue Aug 21 18:17:35 2007 +0200

    config: fix default xkb model (pc105, not keyboard)
    (cherry picked from commit 6ef4ecd82670c37a354243166750d76a97959c8b)

diff --git a/config/x11-input.fdi b/config/x11-input.fdi
index 7f516ca..c390706 100644
--- a/config/x11-input.fdi
+++ b/config/x11-input.fdi
@@ -16,7 +16,7 @@
       <!-- If we're using Linux, we use evdev by default (falling back to
            keyboard otherwise). -->
       <merge key="input.x11_driver" type="string">keyboard</merge>
-      <merge key="input.xkb.model" type="string">keyboard</merge>
+      <merge key="input.xkb.model" type="string">pc105</merge>
       <match key="/org/freedesktop/Hal/devices/computer:system.kernel.name"
              string="Linux">
         <merge key="input.x11_driver" type="string">evdev</merge>
commit fd4dc5a98e600b267ee22a3fb47c093c3e1b26d6
Author: Julien Cristau <jcristau at debian.org>
Date:   Mon Aug 20 12:57:06 2007 +0200

    xfree86: Fix build on Linux/alpha.
    
    A bunch of CFLAGS had gone missing, so the build failed with errors like:
    ../../../../../hw/xfree86/os-support/linux/lnx_ev56.c:7:19: error: input.h: No such file or directory
    ../../../../../hw/xfree86/os-support/linux/lnx_ev56.c:8:24: error: scrnintstr.h: No such file or directory
    (cherry picked from commit a1fe36b772f7edc162ea97368f86588c0fb77148)

diff --git a/hw/xfree86/os-support/linux/Makefile.am b/hw/xfree86/os-support/linux/Makefile.am
index 10f2440..5bb252b 100644
--- a/hw/xfree86/os-support/linux/Makefile.am
+++ b/hw/xfree86/os-support/linux/Makefile.am
@@ -11,7 +11,7 @@ PLATFORM_PCI_SUPPORT = \
        $(srcdir)/lnx_axp.c \
        $(srcdir)/../shared/xf86Axp.c
 
-liblinuxev56_la_CFLAGS = -mcpu=ev56
+liblinuxev56_la_CFLAGS = $(AM_CFLAGS) -mcpu=ev56
 
 liblinuxev56_la_SOURCES = lnx_ev56.c
 endif
commit 9a747b0b81d0bd9eea7d02601703df266d6c5eca
Author: Fredrik Höglund <fredrik at kde.org>
Date:   Wed Aug 15 19:19:11 2007 +0200

    EXA: Wrap Trapezoids to prevent excessive migration of the alpha pixmap.
    
    miTrapezoids creates an alpha pixmap and initializes the contents
    using PolyFillRect, which causes the pixmap to be moved in for
    acceleration. The subsequent call to RasterizeTrapezoid won't be
    accelerated by EXA, which causing the pixmap to be moved back out
    again.
    
    By wrapping Trapezoids and using ExaCheckPolyFillRect instead of
    PolyFillRect to initialize the pixmap, we avoid this roundtrip.
    (cherry picked from commit daee59b1703ac07c2def9e9fecc479e59b93f761)

diff --git a/exa/exa.c b/exa/exa.c
index 8e22b89..aa42b92 100644
--- a/exa/exa.c
+++ b/exa/exa.c
@@ -526,6 +526,7 @@ exaCloseScreen(int i, ScreenPtr pScreen)
     if (ps) {
 	ps->Composite = pExaScr->SavedComposite;
 	ps->Glyphs = pExaScr->SavedGlyphs;
+	ps->Trapezoids = pExaScr->SavedTrapezoids;
     }
 #endif
 
@@ -684,6 +685,9 @@ exaDriverInit (ScreenPtr		pScreen,
 
 	pExaScr->SavedGlyphs = ps->Glyphs;
 	ps->Glyphs = exaGlyphs;
+
+	pExaScr->SavedTrapezoids = ps->Trapezoids;
+	ps->Trapezoids = exaTrapezoids;
     }
 #endif
 
diff --git a/exa/exa_priv.h b/exa/exa_priv.h
index a6d98cd..bab8aa2 100644
--- a/exa/exa_priv.h
+++ b/exa/exa_priv.h
@@ -108,6 +108,7 @@ typedef struct {
     RasterizeTrapezoidProcPtr	 SavedRasterizeTrapezoid;
     AddTrianglesProcPtr		 SavedAddTriangles;
     GlyphsProcPtr                SavedGlyphs;
+    TrapezoidsProcPtr            SavedTrapezoids;
 #endif
     Bool			 swappedOut;
     enum ExaMigrationHeuristic	 migration;
@@ -393,6 +394,11 @@ exaComposite(CARD8	op,
 	     CARD16	height);
 
 void
+exaTrapezoids (CARD8 op, PicturePtr pSrc, PicturePtr pDst,
+               PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc,
+               int ntrap, xTrapezoid *traps);
+
+void
 exaRasterizeTrapezoid (PicturePtr pPicture, xTrapezoid  *trap,
 		       int x_off, int y_off);
 
diff --git a/exa/exa_render.c b/exa/exa_render.c
index 5e7c67f..2dd3fc1 100644
--- a/exa/exa_render.c
+++ b/exa/exa_render.c
@@ -749,6 +749,132 @@ done:
 }
 #endif
 
+/**
+ * Same as miCreateAlphaPicture, except it uses ExaCheckPolyFillRect instead
+ * of PolyFillRect to initialize the pixmap after creating it, to prevent
+ * the pixmap from being migrated.
+ *
+ * See the comments about exaTrapezoids.
+ */
+static PicturePtr
+exaCreateAlphaPicture (ScreenPtr     pScreen,
+                       PicturePtr    pDst,
+                       PictFormatPtr pPictFormat,
+                       CARD16        width,
+                       CARD16        height)
+{
+    PixmapPtr	    pPixmap;
+    PicturePtr	    pPicture;
+    GCPtr	    pGC;
+    int		    error;
+    xRectangle	    rect;
+
+    if (width > 32767 || height > 32767)
+	return 0;
+
+    if (!pPictFormat)
+    {
+	if (pDst->polyEdge == PolyEdgeSharp)
+	    pPictFormat = PictureMatchFormat (pScreen, 1, PICT_a1);
+	else
+	    pPictFormat = PictureMatchFormat (pScreen, 8, PICT_a8);
+	if (!pPictFormat)
+	    return 0;
+    }
+
+    pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height,
+					pPictFormat->depth);
+    if (!pPixmap)
+	return 0;
+    pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
+    if (!pGC)
+    {
+	(*pScreen->DestroyPixmap) (pPixmap);
+	return 0;
+    }
+    ValidateGC (&pPixmap->drawable, pGC);
+    rect.x = 0;
+    rect.y = 0;
+    rect.width = width;
+    rect.height = height;
+    ExaCheckPolyFillRect (&pPixmap->drawable, pGC, 1, &rect);
+    exaPixmapDirty (pPixmap, 0, 0, width, height);
+    FreeScratchGC (pGC);
+    pPicture = CreatePicture (0, &pPixmap->drawable, pPictFormat,
+			      0, 0, serverClient, &error);
+    (*pScreen->DestroyPixmap) (pPixmap);
+    return pPicture;
+}
+
+/**
+ * exaTrapezoids is essentially a copy of miTrapezoids that uses
+ * exaCreateAlphaPicture instead of miCreateAlphaPicture.
+ *
+ * The problem with miCreateAlphaPicture is that it calls PolyFillRect
+ * to initialize the contents after creating the pixmap, which
+ * causes the pixmap to be moved in for acceleration. The subsequent
+ * call to RasterizeTrapezoid won't be accelerated however, which
+ * forces the pixmap to be moved out again.
+ *
+ * exaCreateAlphaPicture avoids this roundtrip by using ExaCheckPolyFillRect
+ * to initialize the contents.
+ */
+void
+exaTrapezoids (CARD8 op, PicturePtr pSrc, PicturePtr pDst,
+               PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc,
+               int ntrap, xTrapezoid *traps)
+{
+    ScreenPtr		pScreen = pDst->pDrawable->pScreen;
+    PictureScreenPtr    ps = GetPictureScreen(pScreen);
+
+    /*
+     * Check for solid alpha add
+     */
+    if (op == PictOpAdd && miIsSolidAlpha (pSrc))
+    {
+	for (; ntrap; ntrap--, traps++)
+	    (*ps->RasterizeTrapezoid) (pDst, traps, 0, 0);
+    }
+    else if (maskFormat)
+    {
+	PicturePtr	pPicture;
+	BoxRec		bounds;
+	INT16		xDst, yDst;
+	INT16		xRel, yRel;
+
+	xDst = traps[0].left.p1.x >> 16;
+	yDst = traps[0].left.p1.y >> 16;
+
+	miTrapezoidBounds (ntrap, traps, &bounds);
+	if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2)
+	    return;
+	pPicture = exaCreateAlphaPicture (pScreen, pDst, maskFormat,
+	                                  bounds.x2 - bounds.x1,
+	                                  bounds.y2 - bounds.y1);
+	if (!pPicture)
+	    return;
+	for (; ntrap; ntrap--, traps++)
+	    (*ps->RasterizeTrapezoid) (pPicture, traps,
+				       -bounds.x1, -bounds.y1);
+	xRel = bounds.x1 + xSrc - xDst;
+	yRel = bounds.y1 + ySrc - yDst;
+	CompositePicture (op, pSrc, pPicture, pDst,
+			  xRel, yRel, 0, 0, bounds.x1, bounds.y1,
+			  bounds.x2 - bounds.x1,
+			  bounds.y2 - bounds.y1);
+	FreePicture (pPicture, 0);
+    }
+    else
+    {
+	if (pDst->polyEdge == PolyEdgeSharp)
+	    maskFormat = PictureMatchFormat (pScreen, 1, PICT_a1);
+	else
+	    maskFormat = PictureMatchFormat (pScreen, 8, PICT_a8);
+	for (; ntrap; ntrap--, traps++)
+	    exaTrapezoids (op, pSrc, pDst, maskFormat, xSrc, ySrc, 1, traps);
+    }
+}
+
 #define NeedsComponent(f) (PICT_FORMAT_A(f) != 0 && PICT_FORMAT_RGB(f) != 0)
 
 /**
commit d37edeff997219b1944a15cc0c9d7db64868ea70
Author: Dave Jones <davej at redhat.com>
Date:   Thu Aug 16 09:46:27 2007 +0200

    Kdrive: fix nasty thinko in TslibEnable()

diff --git a/hw/kdrive/linux/tslib.c b/hw/kdrive/linux/tslib.c
index 41b74fa..371aece 100644
--- a/hw/kdrive/linux/tslib.c
+++ b/hw/kdrive/linux/tslib.c
@@ -118,7 +118,7 @@ TslibEnable (KdPointerInfo *pi)
     private->fd = ts_fd(private->tsDev);
     if (!private->tsDev || ts_config(private->tsDev) || private->fd < 0) {
         ErrorF("[tslib/TslibEnable] failed to open %s\n", pi->path);
-        if (private->fd > 0);
+        if (private->fd >= 0)
             close(private->fd);
         return BadAlloc;
     }


More information about the xorg-commit mailing list