xserver: Branch 'glucose-2' - 56 commits

Alan Hourihane alanh at kemper.freedesktop.org
Mon Nov 19 11:56:09 PST 2007


 .gitignore                         |    4 
 COPYING                            |  200 +--------
 GL/glx/indirect_dispatch.c         |   25 -
 GL/glx/indirect_dispatch.h         |    4 
 GL/glx/indirect_dispatch_swap.c    |   25 -
 GL/glx/indirect_size_get.c         |    4 
 GL/glx/indirect_table.c            |    2 
 Xext/xace.c                        |   47 --
 Xext/xace.h                        |    9 
 afb/afbpixmap.c                    |    1 
 cfb/cfbpixmap.c                    |    1 
 config/dbus.c                      |    4 
 configure.ac                       |   29 +
 dix/atom.c                         |    2 
 dix/devices.c                      |    1 
 dix/dispatch.c                     |    8 
 dix/events.c                       |    4 
 dix/getevents.c                    |    4 
 doc/c-extensions                   |    1 
 exa/exa.c                          |    1 
 exa/exa_migration.c                |   33 +
 exa/exa_priv.h                     |    1 
 fb/fb.h                            |    3 
 fb/fb24_32.c                       |    2 
 fb/fbpixmap.c                      |    7 
 hw/darwin/apple/X11Application.m   |  334 +++++++--------
 hw/darwin/darwin.h                 |    3 
 hw/darwin/quartz/quartz.c          |   87 ++-
 hw/darwin/quartz/quartz.h          |    1 
 hw/darwin/quartz/quartzKeyboard.c  |  154 ++----
 hw/darwin/quartz/xpr/xpr.h         |    1 
 hw/darwin/quartz/xpr/xprFrame.c    |   34 +
 hw/darwin/quartz/xpr/xprScreen.c   |    2 
 hw/dmx/dmxpixmap.c                 |    1 
 hw/kdrive/ephyr/Makefile.am        |   62 +-
 hw/kdrive/ephyr/ephyr.c            |    6 
 hw/kdrive/src/kdrive.c             |    5 
 hw/xfree86/common/xf86AutoConfig.c |   22 
 hw/xfree86/common/xf86Bus.c        |   23 -
 hw/xfree86/common/xf86Bus.h        |    1 
 hw/xfree86/common/xf86Config.c     |   20 
 hw/xfree86/common/xf86Configure.c  |   29 -
 hw/xfree86/common/xf86Helper.c     |    3 
 hw/xfree86/common/xf86Init.c       |    4 
 hw/xfree86/common/xf86Priv.h       |    2 
 hw/xfree86/exa/exa.man.pre         |    6 
 hw/xfree86/exa/examodule.c         |    8 
 hw/xfree86/modes/xf86Crtc.c        |    7 
 hw/xfree86/modes/xf86RandR12.c     |    6 
 hw/xfree86/parser/cpconfig.c       |    2 
 hw/xfree86/parser/scan.c           |    9 
 hw/xfree86/utils/xorgcfg/config.h  |    1 
 hw/xfree86/xf4bpp/ppcPixmap.c      |    1 
 hw/xnest/Makefile.am               |    3 
 hw/xnest/Pixmap.c                  |    1 
 hw/xwin/winconfig.c                |    1 
 hw/xwin/winpixmap.c                |    1 
 include/dix-config.h.in            |    3 
 include/dix.h                      |   13 
 include/pixmapstr.h                |    1 
 include/scrnintstr.h               |    2 
 include/xorg-server.h.in           |    6 
 mfb/mfbpixmap.c                    |    1 
 mi/miinitext.c                     |    2 
 mi/mipushpxl.c                     |   19 
 miext/rootless/rootless.h          |    2 
 miext/rootless/rootlessGC.c        |   50 +-
 miext/rootless/rootlessWindow.c    |  143 ++++++
 os/Makefile.am                     |    3 
 os/auth.c                          |   16 
 os/utils.c                         |    8 
 os/xalloc.c                        |  816 -------------------------------------
 randr/rrcrtc.c                     |    5 
 randr/rrmode.c                     |    2 
 render/render.c                    |    2 
 xgl/xglpixmap.c                    |    1 
 xkb/xkbEvents.c                    |    3 
 xorg-server.pc.in                  |    6 
 78 files changed, 772 insertions(+), 1594 deletions(-)

New commits:
commit 959f81a34d22cf1880c06b099c6251f54d7398d2
Merge: f3f704b... ea9c63e...
Author: Alan Hourihane <alanh at tungstengraphics.com>
Date:   Mon Nov 19 19:56:00 2007 +0000

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into glucose-2

diff --cc xgl/xglpixmap.c
index bb8e3ea,0000000..8cb9ba5
mode 100644,000000..100644
--- a/xgl/xglpixmap.c
+++ b/xgl/xglpixmap.c
@@@ -1,748 -1,0 +1,749 @@@
 +/*
 + * Copyright © 2004 David Reveman
 + *
 + * Permission to use, copy, modify, distribute, and sell this software
 + * and its documentation for any purpose is hereby granted without
 + * fee, provided that the above copyright notice appear in all copies
 + * and that both that copyright notice and this permission notice
 + * appear in supporting documentation, and that the name of
 + * David Reveman not be used in advertising or publicity pertaining to
 + * distribution of the software without specific, written prior permission.
 + * David Reveman makes no representations about the suitability of this
 + * software for any purpose. It is provided "as is" without express or
 + * implied warranty.
 + *
 + * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
 + * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
 + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 + *
 + * Author: David Reveman <davidr at novell.com>
 + */
 +
 +#include "xgl.h"
 +#include "fb.h"
 +
 +static glitz_buffer_hint_t xglPixmapUsageHints[] = {
 +    (glitz_buffer_hint_t) 0,	    /* reserved for system memory */
 +    GLITZ_BUFFER_HINT_STREAM_DRAW,
 +    GLITZ_BUFFER_HINT_STREAM_READ,
 +    GLITZ_BUFFER_HINT_STREAM_COPY,
 +    GLITZ_BUFFER_HINT_STATIC_DRAW,
 +    GLITZ_BUFFER_HINT_STATIC_READ,
 +    GLITZ_BUFFER_HINT_STATIC_COPY,
 +    GLITZ_BUFFER_HINT_DYNAMIC_DRAW,
 +    GLITZ_BUFFER_HINT_DYNAMIC_READ,
 +    GLITZ_BUFFER_HINT_DYNAMIC_COPY
 +};
 +
 +#define NUM_XGL_PIXMAP_USAGE_HINTS				     \
 +    (sizeof (xglPixmapUsageHints) / sizeof (xglPixmapUsageHints[0]))
 +
 +#define XGL_PIXMAP_USAGE_HINT(hint) (xglPixmapUsageHints[hint])
 +
 +static void
 +xglPixmapDamageReport (DamagePtr pDamage,
 +		       RegionPtr pRegion,
 +		       void	 *closure)
 +{
 +    PixmapPtr pPixmap = (PixmapPtr) closure;
 +    BoxPtr    pExt;
 +
 +    XGL_PIXMAP_PRIV (pPixmap);
 +
 +    pExt = REGION_EXTENTS (pPixmap->drawable.pScreen, pRegion);
 +
 +    if (BOX_NOTEMPTY (&pPixmapPriv->damageBox))
 +    {
 +	if (pExt->x1 < pPixmapPriv->damageBox.x1)
 +	    pPixmapPriv->damageBox.x1 = pExt->x1;
 +
 +	if (pExt->y1 < pPixmapPriv->damageBox.y1)
 +	    pPixmapPriv->damageBox.y1 = pExt->y1;
 +
 +	if (pExt->x2 > pPixmapPriv->damageBox.x2)
 +	    pPixmapPriv->damageBox.x2 = pExt->x2;
 +
 +	if (pExt->y2 > pPixmapPriv->damageBox.y2)
 +	    pPixmapPriv->damageBox.y2 = pExt->y2;
 +    }
 +    else
 +	pPixmapPriv->damageBox = *pExt;
 +}
 +
 +
 +Bool
 +xglPixmapCreateDamage (PixmapPtr pPixmap)
 +{
 +    XGL_PIXMAP_PRIV (pPixmap);
 +
 +    pPixmapPriv->pDamage =
 +	DamageCreate (xglPixmapDamageReport, (DamageDestroyFunc) 0,
 +		      DamageReportRawRegion, TRUE,
 +		      pPixmap->drawable.pScreen,
 +		      (void *) pPixmap);
 +    if (!pPixmapPriv->pDamage)
 +	return FALSE;
 +
 +    DamageRegister (&pPixmap->drawable, pPixmapPriv->pDamage);
 +
 +    return TRUE;
 +}
 +
 +void
 +xglSetPixmapVisual (PixmapPtr    pPixmap,
 +		    xglVisualPtr pVisual)
 +{
 +    xglVisualPtr pOldVisual;
 +
 +    XGL_PIXMAP_PRIV (pPixmap);
 +
 +    pOldVisual = pPixmapPriv->pVisual;
 +    if (pOldVisual && pVisual)
 +    {
 +	glitz_surface_t *surface;
 +
 +	if (pOldVisual->vid != pVisual->vid)
 +	{
 +	    surface = pPixmapPriv->surface;
 +	    if (surface)
 +	    {
 +		glitz_drawable_t *drawable;
 +
 +		drawable = glitz_surface_get_attached_drawable (surface);
 +		if (drawable)
 +		{
 +		    if (pOldVisual->format.drawable->id !=
 +			pVisual->format.drawable->id)
 +		    {
 +			glitz_surface_detach (pPixmapPriv->surface);
 +			pPixmapPriv->target = xglPixmapTargetOut;
 +		    }
 +		}
 +
 +		if (pOldVisual->format.surface->id != pVisual->format.surface->id)
 +		{
 +		    xglSyncBits (&pPixmap->drawable, NULL);
 +		    glitz_surface_destroy (pPixmapPriv->surface);
 +		    pPixmapPriv->surface = 0;
 +		}
 +	    }
 +	}
 +    }
 +    else if (pOldVisual)
 +    {
 +	if (pPixmapPriv->surface)
 +	{
 +	    xglSyncBits (&pPixmap->drawable, NULL);
 +	    glitz_surface_destroy (pPixmapPriv->surface);
 +	    pPixmapPriv->surface = 0;
 +	}
 +	pPixmapPriv->target = xglPixmapTargetNo;
 +    }
 +
 +    pPixmapPriv->pVisual = pVisual;
 +
 +    if (pPixmapPriv->pVisual && pPixmapPriv->pVisual->format.surface)
 +    {
 +	if (!pPixmapPriv->pDamage)
 +	{
 +	    if (!xglPixmapCreateDamage (pPixmap))
 +		FatalError (XGL_SW_FAILURE_STRING);
 +	}
 +    }
 +}
 +
 +Bool
 +xglPixmapSurfaceInit (PixmapPtr	    pPixmap,
 +		      unsigned long features,
 +		      int	    width,
 +		      int	    height)
 +{
 +    BoxRec box;
 +
 +    XGL_PIXMAP_PRIV (pPixmap);
 +
 +    pPixmapPriv->surface = NULL;
 +    pPixmapPriv->drawable = NULL;
 +    pPixmapPriv->acceleratedTile = FALSE;
 +    pPixmapPriv->pictureMask = ~0;
 +    pPixmapPriv->target = xglPixmapTargetNo;
 +
 +    box.x1 = 0;
 +    box.y1 = 0;
 +    box.x2 = width;
 +    box.y2 = height;
 +
 +    REGION_INIT (pScreen, &pPixmapPriv->bitRegion, &box, 1);
 +
 +    pPixmapPriv->pVisual = xglFindVisualWithDepth (pPixmap->drawable.pScreen,
 +						   pPixmap->drawable.depth);
 +    if (pPixmapPriv->pVisual)
 +    {
 +	XGL_SCREEN_PRIV (pPixmap->drawable.pScreen);
 +
 +	/* general pixmap acceleration */
 +	if (pPixmapPriv->pVisual->format.drawable &&
 +	    pScreenPriv->accel.pixmap.enabled &&
 +	    xglCheckPixmapSize (pPixmap, &pScreenPriv->accel.pixmap.size))
 +	    pPixmapPriv->target = xglPixmapTargetOut;
 +    }
 +
 +    if (pPixmapPriv->pVisual && pPixmapPriv->pVisual->format.surface)
 +    {
 +	if (!pPixmapPriv->pDamage)
 +	{
 +	    if (!xglPixmapCreateDamage (pPixmap))
 +		FatalError (XGL_SW_FAILURE_STRING);
 +	}
 +
 +	if (width && height)
 +	{
 +	    if (width == 1 && height == 1)
 +	    {
 +		pPixmapPriv->acceleratedTile = TRUE;
 +	    }
 +	    else if (features & GLITZ_FEATURE_TEXTURE_BORDER_CLAMP_MASK)
 +	    {
 +		if ((features & GLITZ_FEATURE_TEXTURE_NON_POWER_OF_TWO_MASK) ||
 +		    (POWER_OF_TWO (width) && POWER_OF_TWO (height)))
 +		    pPixmapPriv->acceleratedTile = TRUE;
 +	    }
 +	}
 +    }
 +
 +    return TRUE;
 +}
 +
 +PixmapPtr
 +xglCreatePixmap (ScreenPtr  pScreen,
 +		 int	    width,
 +		 int	    height,
 +		 int	    depth,
 +		 unsigned   usage_hint)
 +{
 +    xglPixmapPtr pPixmapPriv;
 +    PixmapPtr	 pPixmap;
 +
 +    XGL_SCREEN_PRIV (pScreen);
 +
 +    pPixmap = AllocatePixmap (pScreen, 0);
 +    if (!pPixmap)
 +	return NullPixmap;
 +
 +    pPixmap->drawable.type = DRAWABLE_PIXMAP;
 +    pPixmap->drawable.class = 0;
 +    pPixmap->drawable.pScreen = pScreen;
 +    pPixmap->drawable.depth = depth;
 +    pPixmap->drawable.bitsPerPixel = BitsPerPixel (depth);
 +    pPixmap->drawable.id = 0;
 +    pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
 +    pPixmap->drawable.x = 0;
 +    pPixmap->drawable.y = 0;
 +    pPixmap->drawable.width = width;
 +    pPixmap->drawable.height = height;
 +
 +#ifdef COMPOSITE
 +    pPixmap->screen_x = 0;
 +    pPixmap->screen_y = 0;
 +#endif
 +
 +    pPixmap->devKind = 0;
 +    pPixmap->refcnt = 1;
 +    pPixmap->devPrivate.ptr = 0;
++    pPixmap->usage_hint = usage_hint;
 +
 +    pPixmapPriv = XGL_GET_PIXMAP_PRIV (pPixmap);
 +
 +    pPixmapPriv->pVisual = NULL;
 +    pPixmapPriv->pDamage = NULL;
 +
 +    if (!xglPixmapSurfaceInit (pPixmap, pScreenPriv->features, width, height))
 +	return NullPixmap;
 +
 +    pPixmapPriv->buffer = NULL;
 +    pPixmapPriv->bits = (pointer) 0;
 +    pPixmapPriv->stride = 0;
 +    pPixmapPriv->pGeometry = NULL;
 +    pPixmapPriv->allBits = TRUE;
 +
 +    pPixmapPriv->damageBox = miEmptyBox;
 +
 +    return pPixmap;
 +}
 +
 +void
 +xglFiniPixmap (PixmapPtr pPixmap)
 +{
 +    XGL_PIXMAP_PRIV (pPixmap);
 +
 +    if (pPixmap->devPrivate.ptr)
 +    {
 +	if (pPixmapPriv->buffer)
 +	    glitz_buffer_unmap (pPixmapPriv->buffer);
 +    }
 +
 +    if (pPixmapPriv->pGeometry)
 +	GEOMETRY_UNINIT (pPixmapPriv->pGeometry);
 +
 +    if (pPixmapPriv->buffer)
 +	glitz_buffer_destroy (pPixmapPriv->buffer);
 +
 +    if (pPixmapPriv->bits)
 +	xfree (pPixmapPriv->bits);
 +
 +    REGION_UNINIT (pPixmap->drawable.pScreen, &pPixmapPriv->bitRegion);
 +
 +    if (pPixmapPriv->drawable)
 +	glitz_drawable_destroy (pPixmapPriv->drawable);
 +
 +    if (pPixmapPriv->surface) {
 +    	/* leaving because texture destruction can occur and flush primitives */
 +        xglLeaveServer();
 +	glitz_surface_destroy (pPixmapPriv->surface);
 +        xglEnterServer();
 +    }
 +}
 +
 +Bool
 +xglDestroyPixmap (PixmapPtr pPixmap)
 +{
 +    if (--pPixmap->refcnt)
 +	return TRUE;
 +
 +    xglFiniPixmap (pPixmap);
 +
 +    xfree (pPixmap);
 +
 +    return TRUE;
 +}
 +
 +Bool
 +xglModifyPixmapHeader (PixmapPtr pPixmap,
 +		       int	 width,
 +		       int	 height,
 +		       int	 depth,
 +		       int	 bitsPerPixel,
 +		       int	 devKind,
 +		       pointer	 pPixData)
 +{
 +    xglScreenPtr pScreenPriv;
 +    xglPixmapPtr pPixmapPriv;
 +    int		 oldWidth, oldHeight;
 +
 +    if (!pPixmap)
 +	return FALSE;
 +
 +    pScreenPriv = XGL_GET_SCREEN_PRIV (pPixmap->drawable.pScreen);
 +    pPixmapPriv = XGL_GET_PIXMAP_PRIV (pPixmap);
 +
 +    oldWidth  = pPixmap->drawable.width;
 +    oldHeight = pPixmap->drawable.height;
 +
 +    if ((width > 0) && (height > 0) && (depth > 0) && (bitsPerPixel > 0) &&
 +	(devKind > 0) && pPixData)
 +    {
 +	pPixmap->drawable.depth = depth;
 +	pPixmap->drawable.bitsPerPixel = bitsPerPixel;
 +	pPixmap->drawable.id = 0;
 +	pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
 +	pPixmap->drawable.x = 0;
 +	pPixmap->drawable.y = 0;
 +	pPixmap->drawable.width = width;
 +	pPixmap->drawable.height = height;
 +	pPixmapPriv->stride = devKind;
 +	pPixmap->refcnt = 1;
 +    }
 +    else
 +    {
 +	if (width > 0)
 +	    pPixmap->drawable.width = width;
 +
 +	if (height > 0)
 +	    pPixmap->drawable.height = height;
 +
 +	if (depth > 0)
 +	    pPixmap->drawable.depth = depth;
 +
 +	if (bitsPerPixel > 0)
 +	    pPixmap->drawable.bitsPerPixel = bitsPerPixel;
 +	else if ((bitsPerPixel < 0) && (depth > 0))
 +	    pPixmap->drawable.bitsPerPixel = BitsPerPixel (depth);
 +
 +	if (devKind > 0)
 +	    pPixmapPriv->stride = devKind;
 +	else if ((devKind < 0) && ((width > 0) || (depth > 0)))
 +	    pPixmapPriv->stride = PixmapBytePad (pPixmap->drawable.width,
 +						 pPixmap->drawable.depth);
 +    }
 +
 +    if (pPixmap->drawable.width  != oldWidth ||
 +	pPixmap->drawable.height != oldHeight)
 +    {
 +	pPixmapPriv->pVisual = NULL;
 +	pPixmapPriv->target  = xglPixmapTargetNo;
 +
 +	if (pPixmapPriv->drawable)
 +	    glitz_drawable_destroy (pPixmapPriv->drawable);
 +
 +	if (pPixmapPriv->surface)
 +	    glitz_surface_destroy (pPixmapPriv->surface);
 +
 +	REGION_UNINIT (pPixmap->drawable.pScreen, &pPixmapPriv->bitRegion);
 +
 +	if (!xglPixmapSurfaceInit (pPixmap,
 +				   pScreenPriv->features,
 +				   pPixmap->drawable.width,
 +				   pPixmap->drawable.height))
 +	    return FALSE;
 +    }
 +
 +    if (pPixData)
 +    {
 +	BoxRec box;
 +
 +	if (pPixmap->devPrivate.ptr)
 +	{
 +	    if (pPixmapPriv->buffer)
 +		glitz_buffer_unmap (pPixmapPriv->buffer);
 +
 +	    pPixmap->devPrivate.ptr = 0;
 +	}
 +
 +	if (pPixmapPriv->pGeometry)
 +	{
 +	    GEOMETRY_UNINIT (pPixmapPriv->pGeometry);
 +	    pPixmapPriv->pGeometry = NULL;
 +	}
 +
 +	if (pPixmapPriv->buffer)
 +	    glitz_buffer_destroy (pPixmapPriv->buffer);
 +
 +	if (pPixmapPriv->bits)
 +	    xfree (pPixmapPriv->bits);
 +
 +	pPixmapPriv->bits = (pointer) 0;
 +	pPixmapPriv->buffer = glitz_buffer_create_for_data (pPixData);
 +	if (!pPixmapPriv->buffer)
 +	    return FALSE;
 +
 +	pPixmapPriv->allBits = TRUE;
 +
 +	box.x1 = 0;
 +	box.y1 = 0;
 +	box.x2 = pPixmap->drawable.width;
 +	box.y2 = pPixmap->drawable.height;
 +
 +	REGION_UNINIT (pPixmap->drawable.pScreen, &pPixmapPriv->bitRegion);
 +	REGION_INIT (pPixmap->drawable.pScreen, &pPixmapPriv->bitRegion,
 +		     &box, 1);
 +
 +	if (pPixmapPriv->pDamage)
 +	{
 +	    RegionPtr pRegion;
 +
 +	    pRegion = DamageRegion (pPixmapPriv->pDamage);
 +
 +	    REGION_UNINIT (pPixmap->drawable.pScreen, pRegion);
 +	    REGION_INIT (pPixmap->drawable.pScreen, pRegion, NullBox, 0);
 +	    REGION_SUBTRACT (pPixmap->drawable.pScreen, pRegion,
 +			     &pPixmapPriv->bitRegion, pRegion);
 +
 +	}
 +    }
 +
 +    /*
 +     * Screen pixmap
 +     */
 +    if (!pScreenPriv->pScreenPixmap || pScreenPriv->pScreenPixmap == pPixmap)
 +    {
 +	if (!pPixmapPriv->drawable)
 +	{
 +	    glitz_drawable_reference (pScreenPriv->drawable);
 +	    pPixmapPriv->drawable = pScreenPriv->drawable;
 +	}
 +
 +	if (!pPixmapPriv->surface)
 +	{
 +	    glitz_surface_reference (pScreenPriv->surface);
 +	    pPixmapPriv->surface = pScreenPriv->surface;
 +	}
 +
 +	pPixmapPriv->pVisual = pScreenPriv->rootVisual;
 +	pPixmapPriv->target  = xglPixmapTargetIn;
 +
 +	if (!pScreenPriv->pScreenPixmap)
 +	    pScreenPriv->pScreenPixmap = pPixmap;
 +    }
 +
 +    return TRUE;
 +}
 +
 +RegionPtr
 +xglPixmapToRegion (PixmapPtr pPixmap)
 +{
 +    ScreenPtr pScreen = pPixmap->drawable.pScreen;
 +    RegionPtr pRegion;
 +
 +    XGL_SCREEN_PRIV (pScreen);
 +
 +    if (!xglSyncBits (&pPixmap->drawable, NullBox))
 +	FatalError (XGL_SW_FAILURE_STRING);
 +
 +    XGL_SCREEN_UNWRAP (BitmapToRegion);
 +    pRegion = (*pScreen->BitmapToRegion) (pPixmap);
 +    XGL_SCREEN_WRAP (BitmapToRegion, xglPixmapToRegion);
 +
 +    return pRegion;
 +}
 +
 +xglGeometryPtr
 +xglPixmapToGeometry (PixmapPtr pPixmap,
 +		     int       xOff,
 +		     int       yOff)
 +{
 +    XGL_PIXMAP_PRIV (pPixmap);
 +
 +    if (pPixmap->devPrivate.ptr)
 +	xglUnmapPixmapBits (pPixmap);
 +
 +    if (!pPixmapPriv->pGeometry)
 +    {
 +	xglGeometryPtr pGeometry;
 +
 +	if (!pPixmapPriv->buffer)
 +	{
 +	    if (!xglAllocatePixmapBits (pPixmap,
 +					XGL_PIXMAP_USAGE_HINT_DEFAULT))
 +		return NULL;
 +	}
 +
 +	pGeometry = xalloc (sizeof (xglGeometryRec));
 +	if (!pGeometry)
 +	    return NULL;
 +
 +	GEOMETRY_INIT (pPixmap->drawable.pScreen, pGeometry,
 +		       GLITZ_GEOMETRY_TYPE_BITMAP,
 +		       GEOMETRY_USAGE_DYNAMIC, 0);
 +
 +	GEOMETRY_SET_BUFFER (pGeometry, pPixmapPriv->buffer);
 +
 +	if (pPixmapPriv->stride < 0)
 +	{
 +	    pGeometry->f.bitmap.bytes_per_line = -pPixmapPriv->stride;
 +	    pGeometry->f.bitmap.scanline_order =
 +		GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP;
 +	}
 +	else
 +	{
 +	    pGeometry->f.bitmap.bytes_per_line = pPixmapPriv->stride;
 +	    pGeometry->f.bitmap.scanline_order =
 +		GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN;
 +	}
 +
 +	pGeometry->f.bitmap.pad = ((1 + FB_MASK) >> FB_SHIFT) *
 +	    sizeof (FbBits);
 +	pGeometry->width = pPixmap->drawable.width;
 +	pGeometry->count = pPixmap->drawable.height;
 +
 +	pPixmapPriv->pGeometry = pGeometry;
 +    }
 +
 +    pPixmapPriv->pGeometry->xOff = xOff << 16;
 +    pPixmapPriv->pGeometry->yOff = yOff << 16;
 +
 +    return pPixmapPriv->pGeometry;
 +}
 +
 +Bool
 +xglCreatePixmapSurface (PixmapPtr pPixmap)
 +{
 +    XGL_PIXMAP_PRIV (pPixmap);
 +
 +    if (!pPixmapPriv->surface)
 +    {
 +	XGL_SCREEN_PRIV (pPixmap->drawable.pScreen);
 +
 +	if (!pPixmapPriv->pVisual || !pPixmapPriv->pVisual->format.surface)
 +	    return FALSE;
 +
 +	xglLeaveServer();
 +	pPixmapPriv->surface =
 +	    glitz_surface_create (pScreenPriv->drawable,
 +				  pPixmapPriv->pVisual->format.surface,
 +				  pPixmap->drawable.width,
 +				  pPixmap->drawable.height,
 +				  0, NULL);
 +	xglEnterServer();
 +	if (!pPixmapPriv->surface)
 +	{
 +	    pPixmapPriv->pVisual = NULL;
 +	    pPixmapPriv->target  = xglPixmapTargetNo;
 +
 +	    return FALSE;
 +	}
 +    }
 +
 +    return TRUE;
 +}
 +
 +Bool
 +xglAllocatePixmapBits (PixmapPtr pPixmap, int hint)
 +{
 +    int width, height, bpp, stride;
 +
 +    XGL_PIXMAP_PRIV (pPixmap);
 +    XGL_SCREEN_PRIV (pPixmap->drawable.pScreen);
 +
 +    width  = pPixmap->drawable.width;
 +    height = pPixmap->drawable.height;
 +    bpp    = pPixmap->drawable.bitsPerPixel;
 +
 +    stride = ((width * bpp + FB_MASK) >> FB_SHIFT) * (int) sizeof (FbBits);
 +
 +    if (stride)
 +    {
 +	glitz_buffer_t *buffer;
 +
 +	if ((pScreenPriv->pboMask & bpp) && hint)
 +	{
 +	    buffer = glitz_pixel_buffer_create (pScreenPriv->drawable,
 +						NULL, height * stride,
 +						XGL_PIXMAP_USAGE_HINT (hint));
 +	}
 +	else
 +	{
 +	    pPixmapPriv->bits = xalloc (height * stride);
 +	    if (!pPixmapPriv->bits)
 +		return FALSE;
 +
 +	    buffer = glitz_buffer_create_for_data (pPixmapPriv->bits);
 +	}
 +
 +	if (!buffer)
 +	{
 +	    if (pPixmapPriv->bits)
 +		xfree (pPixmapPriv->bits);
 +	    pPixmapPriv->bits = NULL;
 +	    return FALSE;
 +	}
 +	pPixmapPriv->buffer = buffer;
 +    }
 +
 +    if (pScreenPriv->yInverted)
 +	pPixmapPriv->stride = stride;
 +    else
 +	pPixmapPriv->stride = -stride;
 +
 +    return TRUE;
 +}
 +
 +Bool
 +xglMapPixmapBits (PixmapPtr pPixmap)
 +{
 +    if (!pPixmap->devPrivate.ptr)
 +    {
 +	CARD8 *bits;
 +
 +	XGL_PIXMAP_PRIV (pPixmap);
 +
 +	if (!pPixmapPriv->buffer)
 +	    if (!xglAllocatePixmapBits (pPixmap,
 +					XGL_PIXMAP_USAGE_HINT_DEFAULT))
 +		return FALSE;
 +
 +	bits = glitz_buffer_map (pPixmapPriv->buffer,
 +				 GLITZ_BUFFER_ACCESS_READ_WRITE);
 +	if (!bits)
 +	    return FALSE;
 +
 +	pPixmap->devKind = pPixmapPriv->stride;
 +	if (pPixmapPriv->stride < 0)
 +	{
 +	    pPixmap->devPrivate.ptr = bits +
 +		(pPixmap->drawable.height - 1) * -pPixmapPriv->stride;
 +	}
 +	else
 +	{
 +	    pPixmap->devPrivate.ptr = bits;
 +	}
 +    }
 +
 +    return TRUE;
 +}
 +
 +Bool
 +xglUnmapPixmapBits (PixmapPtr pPixmap)
 +{
 +    XGL_PIXMAP_PRIV (pPixmap);
 +
 +    pPixmap->devKind = 0;
 +    pPixmap->devPrivate.ptr = 0;
 +
 +    if (pPixmapPriv->buffer)
 +	if (glitz_buffer_unmap (pPixmapPriv->buffer))
 +	    return FALSE;
 +
 +    return TRUE;
 +}
 +
 +Bool
 +xglCheckPixmapSize (PixmapPtr		 pPixmap,
 +		    xglSizeConstraintPtr pSize)
 +{
 +    if (pPixmap->drawable.width  < pSize->minWidth ||
 +	pPixmap->drawable.height < pSize->minHeight)
 +	return FALSE;
 +
 +    if (pPixmap->drawable.width  > pSize->aboveWidth ||
 +	pPixmap->drawable.height > pSize->aboveHeight)
 +	return TRUE;
 +
 +    return FALSE;
 +}
 +
 +void
 +xglEnablePixmapAccel (PixmapPtr	      pPixmap,
 +		      xglAccelInfoPtr pAccel)
 +{
 +    XGL_SCREEN_PRIV (pPixmap->drawable.pScreen);
 +    XGL_PIXMAP_PRIV (pPixmap);
 +
 +    if (pAccel->enabled && xglCheckPixmapSize (pPixmap, &pAccel->size))
 +    {
 +	xglVisualPtr v;
 +
 +	if (pAccel->pbuffer)
 +	{
 +	    for (v = pScreenPriv->pVisual; v; v = v->next)
 +	    {
 +		if (v->pPixel->depth != pPixmap->drawable.depth)
 +		    continue;
 +
 +		if (v->format.drawable && v->pbuffer)
 +		    break;
 +	    }
 +	}
 +	else
 +	{
 +	    for (v = pScreenPriv->pVisual; v; v = v->next)
 +	    {
 +		if (v->pPixel->depth != pPixmap->drawable.depth)
 +		    continue;
 +
 +		if (v->format.drawable && !v->pbuffer)
 +		    break;
 +	    }
 +	}
 +
 +	if (v)
 +	{
 +	    xglSetPixmapVisual (pPixmap, v);
 +	    if (!pPixmapPriv->target)
 +		pPixmapPriv->target = xglPixmapTargetOut;
 +	}
 +    }
 +}
commit ea9c63e93b9bb731796e8a8de2d127e6cc720076
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Mon Nov 19 15:53:49 2007 +0100

    DEFAULT_DPI was undefined here.

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index dc49861..653042c 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -36,6 +36,7 @@
 #include "xf86DDC.h"
 #include "xf86Crtc.h"
 #include "xf86Modes.h"
+#include "xf86Priv.h"
 #include "xf86RandR12.h"
 #include "X11/extensions/render.h"
 #define DPMS_SERVER
commit db9ae863536fff80b5463d99e71dc47ae587980d
Author: Adam Jackson <ajax at aspartame.nwnk.net>
Date:   Sun Nov 18 11:57:01 2007 -0500

    Bump DEFAULT_DPI to 96.
    
    75 is just nonsense.

diff --git a/hw/xfree86/common/xf86Priv.h b/hw/xfree86/common/xf86Priv.h
index 3da102f..4723f5a 100644
--- a/hw/xfree86/common/xf86Priv.h
+++ b/hw/xfree86/common/xf86Priv.h
@@ -120,7 +120,7 @@ extern RootWinPropPtr *xf86RegisteredPropertiesTable;
 #define DEFAULT_LOG_VERBOSE	3
 #endif
 #ifndef DEFAULT_DPI
-#define DEFAULT_DPI		75
+#define DEFAULT_DPI		96
 #endif
 
 #define DEFAULT_UNRESOLVED	TRUE
commit ee2d4626dca6e0d4fc6f524e5de4bdefa2ed43df
Author: Tormod Volden <bugzi06.fdo.tormod at xoxy.net>
Date:   Sun Nov 18 11:56:31 2007 -0500

    Bug #12932: Use DEFAULT_DPI in randr1.2 instead of hardcoded 96.

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index bb416fd..dc49861 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -704,9 +704,9 @@ xf86DefaultMode (xf86OutputPtr output, int width, int height)
     
     mm_height = output->mm_height;
     if (!mm_height)
-	mm_height = 203;	/* 768 pixels at 96dpi */
+	mm_height = (768 * 25.4) / DEFAULT_DPI;
     /*
-     * Pick a mode closest to 96dpi 
+     * Pick a mode closest to DEFAULT_DPI
      */
     for (mode = output->probed_modes; mode; mode = mode->next)
     {
@@ -721,7 +721,7 @@ xf86DefaultMode (xf86OutputPtr output, int width, int height)
 	
 	/* yes, use VDisplay here, not xf86ModeHeight */
 	dpi = (mode->VDisplay * 254) / (mm_height * 10);
-	diff = dpi - 96;
+	diff = dpi - DEFAULT_DPI;
 	diff = diff < 0 ? -diff : diff;
 	if (target_mode == NULL || (preferred > target_preferred) ||
 	    (preferred == target_preferred && diff < target_diff))
diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index fe21717..c1a06b2 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -450,10 +450,10 @@ xf86RandR12CreateScreenResources (ScreenPtr pScreen)
 	    else
 	    {
 		/*
-		 * Otherwise, just set the screen to 96dpi
+		 * Otherwise, just set the screen to DEFAULT_DPI
 		 */
-		mmWidth = width * 25.4 / 96;
-		mmHeight = height * 25.4 / 96;
+		mmWidth = width * 25.4 / DEFAULT_DPI;
+		mmHeight = height * 25.4 / DEFAULT_DPI;
 	    }
 	}
 	xf86DrvMsg(pScrn->scrnIndex, X_INFO,
commit a46c30c3be33ffb304a885503c8aaa78396ed3d9
Author: Jernej Azarija <azi.stdout at gmail.com>
Date:   Sun Nov 18 11:44:36 2007 -0500

    Bug #12531: RRModesForScreen can fail to allocate.

diff --git a/randr/rrmode.c b/randr/rrmode.c
index 1117581..f060d22 100644
--- a/randr/rrmode.c
+++ b/randr/rrmode.c
@@ -165,6 +165,8 @@ RRModesForScreen (ScreenPtr pScreen, int *num_ret)
     int		num_screen_modes = 0;
 
     screen_modes = xalloc ((num_modes ? num_modes : 1) * sizeof (RRModePtr));
+    if (!screen_modes)
+	return NULL;
     
     /*
      * Add modes from all outputs
commit fac7e7e4e1809e865b9b3cf5b7eb69ba9d3a3759
Author: Adam Jackson <ajax at aspartame.nwnk.net>
Date:   Sun Nov 18 11:39:26 2007 -0500

    Document the requirement for interleaved code and declarations.

diff --git a/doc/c-extensions b/doc/c-extensions
index db2ba7d..e1b222b 100644
--- a/doc/c-extensions
+++ b/doc/c-extensions
@@ -30,3 +30,4 @@ The server will not build if your toolchain does not support these extensions.
                           struct foo bar = { .baz = quux, .brian = "dog" };
     * variadic macros: macros with a variable number of arguments, e.g.:
                        #define DebugF(x, ...) /**/
+    * interleaved code and declarations: { foo = TRUE; int bar; do_stuff(); }
commit d15339a92c4d689d2ab8a86e4f10107f3e45eff8
Author: Adam Jackson <ajax at aspartame.nwnk.net>
Date:   Sat Nov 17 22:12:10 2007 -0500

    Bug #9725: Don't look in root's $HOME for config files, that's just confusing.

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index e74c590..f58e2a7 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -93,7 +93,6 @@ extern DeviceAssocRec mouse_assoc;
 			"/etc/X11/%R," "%P/etc/X11/%R," \
 			"%E," "%F," \
 			"/etc/X11/%F," "%P/etc/X11/%F," \
-			"%D/%X," \
 			"/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \
 			"%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
 			"%P/etc/X11/%X," \
diff --git a/hw/xfree86/parser/cpconfig.c b/hw/xfree86/parser/cpconfig.c
index 46a5a8b..0347f7d 100644
--- a/hw/xfree86/parser/cpconfig.c
+++ b/hw/xfree86/parser/cpconfig.c
@@ -62,7 +62,7 @@ xrealloc (void *p, int size)
 #endif
 
 #define CONFPATH "%A,%R,/etc/X11/%R,%P/etc/X11/%R,%E,%F,/etc/X11/%F," \
-		 "%P/etc/X11/%F,%D/%X,/etc/X11/%X,/etc/%X,%P/etc/X11/%X.%H," \
+		 "%P/etc/X11/%F,/etc/X11/%X,/etc/%X,%P/etc/X11/%X.%H," \
 		 "%P/etc/X11/%X,%P/lib/X11/%X.%H,%P/lib/X11/%X"
 
 int
diff --git a/hw/xfree86/parser/scan.c b/hw/xfree86/parser/scan.c
index e7989d1..36061c8 100644
--- a/hw/xfree86/parser/scan.c
+++ b/hw/xfree86/parser/scan.c
@@ -558,7 +558,6 @@ xf86pathIsSafe(const char *path)
  *    %E    config file environment ($XORGCONFIG) as an absolute path
  *    %F    config file environment ($XORGCONFIG) as a relative path
  *    %G    config file environment ($XORGCONFIG) as a safe path
- *    %D    $HOME
  *    %P    projroot
  *    %M    major version number
  *    %%    %
@@ -703,14 +702,6 @@ DoSubstitution(const char *template, const char *cmdline, const char *projroot,
 				} else
 					BAIL_OUT;
 				break;
-			case 'D':
-				if (!home)
-					home = getenv("HOME");
-				if (home && xf86pathIsAbsolute(home))
-					APPEND_STR(home);
-				else
-					BAIL_OUT;
-				break;
 			case 'P':
 				if (projroot && xf86pathIsAbsolute(projroot))
 					APPEND_STR(projroot);
diff --git a/hw/xfree86/utils/xorgcfg/config.h b/hw/xfree86/utils/xorgcfg/config.h
index b5baba4..ea12e88 100644
--- a/hw/xfree86/utils/xorgcfg/config.h
+++ b/hw/xfree86/utils/xorgcfg/config.h
@@ -101,7 +101,6 @@ extern int config_mode;
 			"/etc/X11/%R," "%P/etc/X11/%R," \
 			"%E," "%F," \
 			"/etc/X11/%F," "%P/etc/X11/%F," \
-			"%D/%X," \
 			"/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \
 			"%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
 			"%P/etc/X11/%X," \
diff --git a/hw/xwin/winconfig.c b/hw/xwin/winconfig.c
index a68ead2..38966bf 100644
--- a/hw/xwin/winconfig.c
+++ b/hw/xwin/winconfig.c
@@ -49,7 +49,6 @@
                     "/etc/X11/%R," "%P/etc/X11/%R," \
                     "%E," "%F," \
                     "/etc/X11/%F," "%P/etc/X11/%F," \
-                    "%D/%X," \
                     "/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \
                     "%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
                     "%P/etc/X11/%X," \
commit 748cfbc820f8cdeb544c54a6db495fecf2e2457b
Author: Adam Jackson <ajax at aspartame.nwnk.net>
Date:   Sat Nov 17 21:23:05 2007 -0500

    Disinfect mi/ of mfb.

diff --git a/mi/mipushpxl.c b/mi/mipushpxl.c
index 3695f30..6fc57db 100644
--- a/mi/mipushpxl.c
+++ b/mi/mipushpxl.c
@@ -53,11 +53,26 @@ SOFTWARE.
 #include "scrnintstr.h"
 #include "pixmapstr.h"
 #include "regionstr.h"
-#include "../mfb/maskbits.h"
 #include "mi.h"
+#include "servermd.h"
 
 #define NPT 128
 
+/* These were stolen from mfb.  They don't really belong here. */
+#define LONG2CHARSSAMEORDER(x) ((MiBits)(x))
+#define LONG2CHARSDIFFORDER( x ) ( ( ( ( x ) & (MiBits)0x000000FF ) << 0x18 ) \
+                        | ( ( ( x ) & (MiBits)0x0000FF00 ) << 0x08 ) \
+                        | ( ( ( x ) & (MiBits)0x00FF0000 ) >> 0x08 ) \
+                        | ( ( ( x ) & (MiBits)0xFF000000 ) >> 0x18 ) )
+
+
+#define PGSZB	4
+#define PPW	(PGSZB<<3) /* assuming 8 bits per byte */
+#define PGSZ	PPW
+#define PLST	(PPW-1)
+#define PIM	PLST
+#define PWSH	5
+
 /* miPushPixels -- squeegees the fill style of pGC through pBitMap
  * into pDrawable.  pBitMap is a stencil (dx by dy of it is used, it may
  * be bigger) which is placed on the drawable at xOrg, yOrg.  Where a 1 bit
@@ -94,7 +109,7 @@ miPushPixels(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg)
     DDXPointRec	pt[NPT], ptThisLine;
     int		width[NPT];
 #if 1
-    PixelType	startmask;
+    MiBits	startmask;
     if (screenInfo.bitmapBitOrder == IMAGE_BYTE_ORDER)
       if (screenInfo.bitmapBitOrder == LSBFirst)
         startmask = (MiBits)(-1) ^
commit a969db091cab16a448f82782e85b3dd19c81627a
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)

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 c89b543198d5ec56ff025bdd6bb7229523478e58
Author: Ben Skeggs <skeggsb at gmail.com>
Date:   Sat Nov 17 18:20:49 2007 +1000

    exa: set driverPriv to NULL before it might get used later with garbage

diff --git a/exa/exa.c b/exa/exa.c
index 1f85d8e..4ed1a1a 100644
--- a/exa/exa.c
+++ b/exa/exa.c
@@ -257,6 +257,7 @@ exaCreatePixmap(ScreenPtr pScreen, int w, int h, int depth,
         return NULL;
 
     pExaPixmap = ExaGetPixmapPriv(pPixmap);
+    pExaPixmap->driverPriv = NULL;
 
     bpp = pPixmap->drawable.bitsPerPixel;
 
commit 514ba4ca727f0b1076bc67500617722203d34daa
Author: Adam Jackson <ajax at aspartame.nwnk.net>
Date:   Fri Nov 16 19:53:11 2007 -0500

    Bug #1612: Use a stronger PRNG.
    
    Currently just reads from /dev/urandom, and only on Linux.

diff --git a/configure.ac b/configure.ac
index 35b7f0f..7d43216 100644
--- a/configure.ac
+++ b/configure.ac
@@ -175,6 +175,12 @@ fi
 AC_CHECK_FUNC([dlopen], [],
 	AC_CHECK_LIB([dl], [dlopen], DLOPEN_LIBS="-ldl"))
 
+case $host_os in
+    linux*)
+	AC_DEFINE(HAVE_URANDOM, 1, [Has /dev/urandom]) ;;
+    *) ;;
+esac
+
 dnl Checks for library functions.
 AC_FUNC_VPRINTF
 AC_CHECK_FUNCS([geteuid getuid link memmove memset mkstemp strchr strrchr \
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index d105e51..d033387 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -240,6 +240,9 @@
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
+/* Have /dev/urandom */
+#undef HAVE_URANDOM
+
 /* Define to 1 if you have the `vprintf' function. */
 #undef HAVE_VPRINTF
 
diff --git a/os/auth.c b/os/auth.c
index b2a145f..fa3ba79 100644
--- a/os/auth.c
+++ b/os/auth.c
@@ -325,6 +325,20 @@ GenerateAuthorization(
     return -1;
 }
 
+#ifdef HAVE_URANDOM
+
+void
+GenerateRandomData (int len, char *buf)
+{
+    int fd;
+
+    fd = open("/dev/urandom", O_RDONLY);
+    read(fd, buf, len);
+    close(fd);
+}
+
+#else /* !HAVE_URANDOM */
+
 /* A random number generator that is more unpredictable
    than that shipped with some systems.
    This code is taken from the C standard. */
@@ -362,4 +376,6 @@ GenerateRandomData (int len, char *buf)
     /* XXX add getrusage, popen("ps -ale") */
 }
 
+#endif /* HAVE_URANDOM */
+
 #endif /* XCSECURITY */
commit 20fd4783247b1b93d9675dc36768dd1ed59ba2d3
Author: Adam Jackson <ajax at redhat.com>
Date:   Thu Nov 15 17:01:33 2007 -0500

    Small static cleanups on dix/

diff --git a/dix/atom.c b/dix/atom.c
index 6ae3e31..c968c1e 100644
--- a/dix/atom.c
+++ b/dix/atom.c
@@ -209,5 +209,3 @@ InitAtoms(void)
     if (lastAtom != XA_LAST_PREDEFINED)
 	AtomError ();
 }
-
-    
diff --git a/dix/dispatch.c b/dix/dispatch.c
index 8c76eb1..c356aed 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -249,7 +249,7 @@ UpdateCurrentTimeIf(void)
 	currentTime = systime;
 }
 
-void
+static void
 InitSelections(void)
 {
     if (CurrentSelections)
@@ -3836,7 +3836,7 @@ ProcInitialConnection(ClientPtr client)
     return (client->noClientException);
 }
 
-int
+static int
 SendConnSetup(ClientPtr client, char *reason)
 {
     xWindowRoot *root;
diff --git a/dix/events.c b/dix/events.c
index 12c299a..85f42b3 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -1184,7 +1184,7 @@ FreezeThaw(DeviceIntPtr dev, Bool frozen)
 	dev->public.processInputProc = dev->public.realInputProc;
 }
 
-void
+static void
 ComputeFreezes(void)
 {
     DeviceIntPtr replayDev = syncEvents.replayDev;
@@ -1268,7 +1268,7 @@ ScreenRestructured (ScreenPtr pScreen)
 }
 #endif
 
-void
+static void
 CheckGrabForSyncs(DeviceIntPtr thisDev, Bool thisMode, Bool otherMode)
 {
     GrabPtr grab = thisDev->grab;
diff --git a/include/dix.h b/include/dix.h
index 6a67d14..c987548 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -158,8 +158,6 @@ extern void UpdateCurrentTime(void);
 
 extern void UpdateCurrentTimeIf(void);
 
-extern void InitSelections(void);
-
 extern void FlushClientCaches(XID /*id*/);
 
 extern int dixDestroyPixmap(
@@ -187,10 +185,6 @@ extern void DeleteWindowFromAnySelections(
 extern void MarkClientException(
     ClientPtr /*client*/);
 
-extern int SendConnSetup(
-    ClientPtr /*client*/,
-    char* /*reason*/);
-
 #if defined(DDXBEFORERESET)
 extern void ddxBeforeReset (void);
 #endif
@@ -362,13 +356,6 @@ extern void EnqueueEvent(
     DeviceIntPtr /* device */,
     int	/* count */);
 
-extern void ComputeFreezes(void);
-
-extern void CheckGrabForSyncs(
-    DeviceIntPtr /* dev */,
-    Bool /* thisMode */,
-    Bool /* otherMode */);
-
 extern void ActivatePointerGrab(
     DeviceIntPtr /* mouse */,
     GrabPtr /* grab */,
commit 70e50fa51f05663f289eeeea4521e737e8e24bca
Author: Adam Jackson <ajax at redhat.com>
Date:   Thu Nov 15 17:00:37 2007 -0500

    Allocate RRCrtcRecs with calloc.

diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index 43cfb29..4a7275b 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -72,7 +72,7 @@ RRCrtcCreate (ScreenPtr pScreen, void *devPrivate)
 	return FALSE;
     pScrPriv->crtcs = crtcs;
     
-    crtc = xalloc (sizeof (RRCrtcRec));
+    crtc = xcalloc (1, sizeof (RRCrtcRec));
     if (!crtc)
 	return NULL;
     crtc->id = FakeClientID (0);
commit 8d0cd1cd2c57ee5a2fc4d577d8182d66369f0617
Author: Aaron Plattner <aplattner at nvidia.com>
Date:   Thu Nov 15 12:16:36 2007 -0800

    Fix a really dumb typo.

diff --git a/include/scrnintstr.h b/include/scrnintstr.h
index 383ee80..bad0e51 100644
--- a/include/scrnintstr.h
+++ b/include/scrnintstr.h
@@ -202,7 +202,7 @@ typedef    void (* ClipNotifyProcPtr)(
 /* pixmap will be the backing pixmap for a redirected window */
 #define CREATE_PIXMAP_USAGE_BACKING_PIXMAP              2
 /* pixmap will contain a glyph */
-#define CREATE_PIMXAP_USAGE_GLYPH_PICTURE               3
+#define CREATE_PIXMAP_USAGE_GLYPH_PICTURE               3
 
 typedef    PixmapPtr (* CreatePixmapProcPtr)(
 	ScreenPtr /*pScreen*/,
diff --git a/render/render.c b/render/render.c
index 3a9d24a..ca6e62f 100644
--- a/render/render.c
+++ b/render/render.c
@@ -1203,7 +1203,7 @@ ProcRenderAddGlyphs (ClientPtr client)
 
 		pDstPix = (pScreen->CreatePixmap) (pScreen,
 						   width, height, depth,
-						   CREATE_PIMXAP_USAGE_GLYPH_PICTURE);
+						   CREATE_PIXMAP_USAGE_GLYPH_PICTURE);
 
 		GlyphPicture (glyph)[screen] = pDst =
 			CreatePicture (0, &pDstPix->drawable,
commit f797c96845a3fab37cda6839ebecf9ac5401fd6e
Author: Aaron Plattner <aplattner at nvidia.com>
Date:   Thu Nov 15 12:12:02 2007 -0800

    Save pixmap allocation hints into the PixmapRec.

diff --git a/afb/afbpixmap.c b/afb/afbpixmap.c
index d15d861..c619618 100644
--- a/afb/afbpixmap.c
+++ b/afb/afbpixmap.c
@@ -105,6 +105,7 @@ afbCreatePixmap(pScreen, width, height, depth, usage_hint)
 	pPixmap->refcnt = 1;
 	pPixmap->devPrivate.ptr =  datasize ?
 				(pointer)((char *)pPixmap + pScreen->totalPixmapSize) : NULL;
+	pPixmap->usage_hint = usage_hint;
 	return(pPixmap);
 }
 
diff --git a/cfb/cfbpixmap.c b/cfb/cfbpixmap.c
index a7be7cc..f5a9a41 100644
--- a/cfb/cfbpixmap.c
+++ b/cfb/cfbpixmap.c
@@ -99,6 +99,7 @@ cfbCreatePixmap (pScreen, width, height, depth, usage_hint)
     pPixmap->refcnt = 1;
     pPixmap->devPrivate.ptr = datasize ?
 		(pointer)((char *)pPixmap + pScreen->totalPixmapSize) : NULL;
+    pPixmap->usage_hint = usage_hint;
     return pPixmap;
 }
 
diff --git a/fb/fb.h b/fb/fb.h
index 380e2e1..5c01c56 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -1621,7 +1621,8 @@ fbPictureInit (ScreenPtr pScreen,
  */
 
 PixmapPtr
-fbCreatePixmapBpp (ScreenPtr pScreen, int width, int height, int depth, int bpp);
+fbCreatePixmapBpp (ScreenPtr pScreen, int width, int height, int depth, int bpp,
+		   unsigned usage_hint);
 
 PixmapPtr
 fbCreatePixmap (ScreenPtr pScreen, int width, int height, int depth,
diff --git a/fb/fb24_32.c b/fb/fb24_32.c
index 00b739b..a03726b 100644
--- a/fb/fb24_32.c
+++ b/fb/fb24_32.c
@@ -548,7 +548,7 @@ fb24_32ReformatTile(PixmapPtr pOldTile, int bitsPerPixel)
 				  pOldTile->drawable.width,
 				  pOldTile->drawable.height,
 				  pOldTile->drawable.depth,
-				  bitsPerPixel);
+				  bitsPerPixel, 0);
     if (!pNewTile)
 	return 0;
     fbGetDrawable (&pOldTile->drawable, 
diff --git a/fb/fbpixmap.c b/fb/fbpixmap.c
index cddab3e..b9c93ea 100644
--- a/fb/fbpixmap.c
+++ b/fb/fbpixmap.c
@@ -29,7 +29,8 @@
 #include "fb.h"
 
 PixmapPtr
-fbCreatePixmapBpp (ScreenPtr pScreen, int width, int height, int depth, int bpp)
+fbCreatePixmapBpp (ScreenPtr pScreen, int width, int height, int depth, int bpp,
+		   unsigned usage_hint)
 {
     PixmapPtr	pPixmap;
     size_t	datasize;
@@ -76,6 +77,8 @@ fbCreatePixmapBpp (ScreenPtr pScreen, int width, int height, int depth, int bpp)
     pPixmap->screen_y = 0;
 #endif
 
+    pPixmap->usage_hint = usage_hint;
+
     return pPixmap;
 }
 
@@ -89,7 +92,7 @@ fbCreatePixmap (ScreenPtr pScreen, int width, int height, int depth,
     if (bpp == 32 && depth <= 24)
 	bpp = fbGetScreenPrivate(pScreen)->pix32bpp;
 #endif
-    return fbCreatePixmapBpp (pScreen, width, height, depth, bpp);
+    return fbCreatePixmapBpp (pScreen, width, height, depth, bpp, usage_hint);
 }
 
 Bool
diff --git a/hw/dmx/dmxpixmap.c b/hw/dmx/dmxpixmap.c
index acc08c3..29162f9 100644
--- a/hw/dmx/dmxpixmap.c
+++ b/hw/dmx/dmxpixmap.c
@@ -116,6 +116,7 @@ PixmapPtr dmxCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
     pPixmap->drawable.height = height;
     pPixmap->devKind = PixmapBytePad(width, bpp);
     pPixmap->refcnt = 1;
+    pPixmap->usage_hint = usage_hint;
 
     pPixPriv = DMX_GET_PIXMAP_PRIV(pPixmap);
     pPixPriv->pixmap = (Pixmap)0;
diff --git a/hw/xfree86/xf4bpp/ppcPixmap.c b/hw/xfree86/xf4bpp/ppcPixmap.c
index 241217b..73524c3 100644
--- a/hw/xfree86/xf4bpp/ppcPixmap.c
+++ b/hw/xfree86/xf4bpp/ppcPixmap.c
@@ -123,6 +123,7 @@ xf4bppCreatePixmap( pScreen, width, height, depth, usage_hint )
     pPixmap->devPrivate.ptr = (pointer) (((CARD8*)pPixmap)
 					 + pScreen->totalPixmapSize);
     bzero( (char *) pPixmap->devPrivate.ptr, size ) ;
+    pPixmap->usage_hint = usage_hint;
     return pPixmap ;
 }
 
diff --git a/hw/xgl/xglpixmap.c b/hw/xgl/xglpixmap.c
index 8c54d64..fe2a7b1 100644
--- a/hw/xgl/xglpixmap.c
+++ b/hw/xgl/xglpixmap.c
@@ -254,6 +254,7 @@ xglCreatePixmap (ScreenPtr  pScreen,
     pPixmap->devKind = 0;
     pPixmap->refcnt = 1;
     pPixmap->devPrivate.ptr = 0;
+    pPixmap->usage_hint = usage_hint;
 
     pPixmapPriv = XGL_GET_PIXMAP_PRIV (pPixmap);
 
diff --git a/hw/xnest/Pixmap.c b/hw/xnest/Pixmap.c
index 1f42001..9229752 100644
--- a/hw/xnest/Pixmap.c
+++ b/hw/xnest/Pixmap.c
@@ -58,6 +58,7 @@ xnestCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
   pPixmap->devKind = PixmapBytePad(width, depth);
   pPixmap->devPrivates[xnestPixmapPrivateIndex].ptr =
       (pointer)((char *)pPixmap + pScreen->totalPixmapSize);
+  pPixmap->usage_hint = usage_hint;
   if (width && height)
       xnestPixmapPriv(pPixmap)->pixmap = 
 	  XCreatePixmap(xnestDisplay, 
diff --git a/hw/xwin/winpixmap.c b/hw/xwin/winpixmap.c
index 994eeb8..07020ee 100644
--- a/hw/xwin/winpixmap.c
+++ b/hw/xwin/winpixmap.c
@@ -98,6 +98,7 @@ winCreatePixmapNativeGDI (ScreenPtr pScreen,
   pPixmap->devKind = 0;
   pPixmap->refcnt = 1;
   pPixmap->devPrivate.ptr = NULL;
+  pPixmap->usage_hint = usage_hint;
 
   /* Pixmap privates are allocated by AllocatePixmap */
   pPixmapPriv = winGetPixmapPriv (pPixmap);
diff --git a/include/pixmapstr.h b/include/pixmapstr.h
index 4594882..dc03cf2 100644
--- a/include/pixmapstr.h
+++ b/include/pixmapstr.h
@@ -90,6 +90,7 @@ typedef struct _Pixmap {
     short		screen_x;
     short		screen_y;
 #endif
+    unsigned		usage_hint; /* see CREATE_PIXMAP_USAGE_* */
 } PixmapRec;
 
 #endif /* PIXMAPSTRUCT_H */
diff --git a/mfb/mfbpixmap.c b/mfb/mfbpixmap.c
index 438e9ab..3773985 100644
--- a/mfb/mfbpixmap.c
+++ b/mfb/mfbpixmap.c
@@ -104,6 +104,7 @@ mfbCreatePixmap (pScreen, width, height, depth, usage_hint)
     pPixmap->refcnt = 1;
     pPixmap->devPrivate.ptr =  datasize ?
 		(pointer)((char *)pPixmap + pScreen->totalPixmapSize) : NULL;
+    pPixmap->usage_hint = usage_hint;
     return pPixmap;
 }
 
commit 6bc50de02108f822977fc7545da81fce95ea7ff4
Author: Adam Jackson <ajax at redhat.com>
Date:   Thu Nov 15 15:03:58 2007 -0500

    Simplify system resource range setup.
    
    osRes only existed to get copied into Acc.  Waste of effort.

diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c
index 3dc08f8..599f7a4 100644
--- a/hw/xfree86/common/xf86Bus.c
+++ b/hw/xfree86/common/xf86Bus.c
@@ -75,7 +75,6 @@ static resPtr AccReducers = NULL;
 
 /* resource lists */
 resPtr Acc = NULL;
-resPtr osRes = NULL;
 
 /* predefined special resources */
 _X_EXPORT resRange resVgaExclusive[] = {_VGA_EXCLUSIVE, _END};
@@ -1357,28 +1356,12 @@ xf86AddRangesToList(resPtr list, resRange *pRange, int entityIndex)
 void
 xf86ResourceBrokerInit(void)
 {
-#if 0
-    resPtr resPci;
-#endif
-
-    osRes = NULL;
+    Acc = NULL;
 
     /* Get the ranges used exclusively by the system */
-    osRes = xf86AccResFromOS(osRes);
-    xf86MsgVerb(X_INFO, 3, "OS-reported resource ranges:\n");
-    xf86PrintResList(3, osRes);
-
-    /* Bus dep initialization */
-#if 0
-    resPci = ResourceBrokerInitPci(&osRes);
-    Acc = xf86JoinResLists(xf86DupResList(osRes), resPci);
-#else
-    Acc = xf86DupResList( osRes );
-#endif
-    
-    xf86MsgVerb(X_INFO, 3, "All system resource ranges:\n");
+    Acc = xf86AccResFromOS(Acc);
+    xf86MsgVerb(X_INFO, 3, "System resource ranges:\n");
     xf86PrintResList(3, Acc);
-
 }
 
 #define MEM_ALIGN (1024 * 1024)
diff --git a/hw/xfree86/common/xf86Bus.h b/hw/xfree86/common/xf86Bus.h
index 5ea5cc8..489ee34 100644
--- a/hw/xfree86/common/xf86Bus.h
+++ b/hw/xfree86/common/xf86Bus.h
@@ -132,7 +132,6 @@ extern int xf86NumEntities;
 extern xf86AccessRec AccessNULL;
 extern BusRec primaryBus;
 extern resPtr Acc;
-extern resPtr osRes;
 extern resPtr ResRange;
 extern BusAccPtr xf86BusAccInfo;
 
commit e1ff14a9246e12d42ce8ca5afbe3b957333a5620
Author: Adam Jackson <ajax at redhat.com>
Date:   Thu Nov 15 14:45:49 2007 -0500

    Delete some dead code in X -configure.

diff --git a/hw/xfree86/common/xf86Configure.c b/hw/xfree86/common/xf86Configure.c
index 0cf445c..536f897 100644
--- a/hw/xfree86/common/xf86Configure.c
+++ b/hw/xfree86/common/xf86Configure.c
@@ -372,9 +372,6 @@ configureDeviceSection (int screennum)
     char identifier[16];
     OptionInfoPtr p;
     int i = 0;
-#ifdef DO_FBDEV_PROBE
-    Bool foundFBDEV = FALSE;
-#endif
     parsePrologue (XF86ConfDevicePtr, XF86ConfDeviceRec)
 
     /* Move device info to parser structure */
@@ -443,32 +440,6 @@ configureDeviceSection (int screennum)
     	}
     }
 
-#ifdef DO_FBDEV_PROBE
-    /* Crude mechanism to auto-detect fbdev (os dependent) */
-    /* Skip it for now. Options list it anyway, and we can't
-     * determine which screen/driver this belongs too anyway. */
-    {
-	int fd;
-
-	fd = open("/dev/fb0", 0);
-	if (fd != -1) {
-	    foundFBDEV = TRUE;
-	    close(fd);
-	}
-    }
-
-    if (foundFBDEV) {
-	XF86OptionPtr fbdev;
-
-    	fbdev = xf86confmalloc(sizeof(XF86OptionRec));
-    	memset((XF86OptionPtr)fbdev,0,sizeof(XF86OptionRec));
-    	fbdev->opt_name = "UseFBDev";
-	fbdev->opt_val = "ON";
-	ptr->dev_option_lst = (XF86OptionPtr)xf86addListItem(
-					(glp)ptr->dev_option_lst, (glp)fbdev);
-    }
-#endif
-
     return ptr;
 }
 
commit 01cfba75229f4b9bf1e4fe80814931acdacde14c
Author: Adam Jackson <ajax at redhat.com>
Date:   Thu Nov 15 14:27:03 2007 -0500

    Nuke the debugging allocator.
    
    This has never been hooked up in the modular build, and can not possibly
    have built since before 6.7.  Clearly no one's using it.

diff --git a/os/Makefile.am b/os/Makefile.am
index d2a9897..8ed12e4 100644
--- a/os/Makefile.am
+++ b/os/Makefile.am
@@ -2,9 +2,6 @@ noinst_LTLIBRARIES = libos.la libcwrapper.la
 
 AM_CFLAGS = $(DIX_CFLAGS)
 
-# FIXME: Add support for these in configure.ac
-INTERNALMALLOC_SRCS = xalloc.c
-
 SECURERPC_SRCS = rpcauth.c
 XCSECURITY_SRCS = secauth.c
 XDMCP_SRCS = xdmcp.c
diff --git a/os/xalloc.c b/os/xalloc.c
deleted file mode 100644
index e5f3946..0000000
--- a/os/xalloc.c
+++ /dev/null
@@ -1,816 +0,0 @@
-#define FATALERRORS 1
-/*
-Copyright (C) 1995 Pascal Haible.  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
-PASCAL HAIBLE 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 Pascal Haible shall
-not be used in advertising or otherwise to promote the sale, use or other
-dealings in this Software without prior written authorization from
-Pascal Haible.
-*/
-
-
-/* Only used if INTERNAL_MALLOC is defined
- * - otherwise xalloc() in utils.c is used
- */
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#ifdef INTERNAL_MALLOC
-
-#include <stdlib.h>	/* for malloc() etc. */
-
-#include <X11/Xos.h>
-#include "misc.h"
-#include <X11/X.h>
-
-#ifdef XALLOC_LOG
-#include <stdio.h>
-#endif
-
-extern Bool Must_have_memory;
-
-/*
- ***** New malloc approach for the X server *****
- * Pascal Haible 1995
- *
- * Some statistics about memory allocation of the X server
- * The test session included several clients of different size, including
- * xv, emacs and xpaint with a new canvas of 3000x2000, zoom 5.
- * All clients were running together.
- * A protocolling version of Xalloc recorded 318917 allocating actions
- * (191573 Xalloc, 85942 XNFalloc, 41438 Xrealloc, 279727 Xfree).
- * Results grouped by size, excluding the next lower size
- * (i.e. size=32 means 16<size<=32):
- *
- *    size   nr of alloc   max nr of blocks allocated together
- *       8	1114		287
- *      16	17341		4104
- *      32	147352		2068
- *      64	59053		2518
- *     128	46882		1230
- *     256	20544		1217
- *     512	6808		117
- *    1024	8254		171
- *    2048	4841		287
- *    4096	2429		84
- *    8192	3364		85
- *   16384	573		22
- *   32768	49		7
- *   65536	45		5
- *  131072	48		2
- *  262144	209		2
- *  524288	7		4
- * 1048576	2		1
- * 8388608	2		2
- *
- * The most used sizes:
- * count size
- * 24	136267
- * 40	37055
- * 72	17278
- * 56	13504
- * 80	9372
- * 16	8966
- * 32	8411
- * 136	8399
- * 104	7690
- * 12	7630
- * 120	5512
- * 88	4634
- * 152	3062
- * 52	2881
- * 48	2736
- * 156	1569
- * 168	1487
- * 160	1483
- * 28	1446
- * 1608	1379
- * 184	1305
- * 552	1270
- * 64	934
- * 320	891
- * 8	754
- *
- * Conclusions: more than the half of all allocations are <= 32 bytes.
- * But of these about 150,000 blocks, only a maximum of about 6,000 are
- * allocated together (including memory leaks..).
- * On the other side, only 935 of the 191573 or 0.5% were larger than 8kB
- * (362 or 0.2% larger than 16k).
- *
- * What makes the server really grow is the fragmentation of the heap,
- * and the fact that it can't shrink.
- * To cure this, we do the following:
- * - large blocks (>=11k) are mmapped on xalloc, and unmapped on xfree,
- *   so we don't need any free lists etc.
- *   As this needs 2 system calls, we only do this for the quite
- *   infrequent large (>=11k) blocks.
- * - instead of reinventing the wheel, we use system malloc for medium
- *   sized blocks (>256, <11k).
- * - for small blocks (<=256) we use an other approach:
- *   As we need many small blocks, and most ones for a short time,
- *   we don't go through the system malloc:
- *   for each fixed sizes a seperate list of free blocks is kept.
- *   to KISS (Keep it Small and Simple), we don't free them
- *   (not freeing a block of 32 bytes won't be worse than having fragmented
- *   a larger area on allocation).
- *   This way, we (almost) allways have a fitting free block right at hand,
- *   and don't have to walk any lists.
- */
-
-/*
- * structure layout of a allocated block
- * unsigned long	size:
- *				rounded up netto size for small and medium blocks
- *				brutto size == mmap'ed area for large blocks
- * unsigned long	DEBUG ? MAGIC : unused
- * ....			data
- * ( unsigned long	MAGIC2 ) only if SIZE_TAIL defined
- *
- */
- 
-/* use otherwise unused long in the header to store a magic */
-/* shouldn't this be removed for production release ? */
-#define XALLOC_DEBUG
-
-#ifdef XALLOC_DEBUG
-/* Xfree fills the memory with a certain pattern (currently 0xF0) */
-/* this should really be removed for production release! */
-#define XFREE_ERASES
-#endif
-
-/* this must be a multiple of SIZE_STEPS below */
-#define MAX_SMALL 264		/* quite many blocks of 264 */
-
-#define MIN_LARGE (11*1024)
-/* worst case is 25% loss with a page size of 4k */
-
-/* SIZE_STEPS defines the granularity of size of small blocks -
- * this makes blocks align to that, too! */
-#define SIZE_STEPS		(sizeof(double))
-#define SIZE_HEADER		(2*sizeof(long)) /* = sizeof(double) for 32bit */
-#ifdef XALLOC_DEBUG
-#if defined(__sparc__)
-#define SIZE_TAIL		(2*sizeof(long)) /* = sizeof(double) for 32bit */
-#else
-#define SIZE_TAIL		(sizeof(long))
-#endif
-#endif
-
-#undef TAIL_SIZE
-#ifdef SIZE_TAIL
-#define TAIL_SIZE		SIZE_TAIL
-#else
-#define TAIL_SIZE		0
-#endif
-
-#if defined (_LP64) || \
-    defined(__alpha__) || defined(__alpha) || \
-    defined(__ia64__) || defined(ia64) || \
-    defined(__sparc64__) || \
-    defined(__s390x__) || \
-    defined(__amd64__) || defined(amd64) || \
-    defined(__powerpc64__) || \
-    (defined(sgi) && _MIPS_SZLONG == 64))
-#define MAGIC			0x1404196414071968
-#define MAGIC_FREE              0x1506196615061966
-#define MAGIC2			0x2515207525182079
-#else
-#define MAGIC			0x14071968
-#define MAGIC_FREE              0x15061966
-#define MAGIC2			0x25182079
-#endif
-
-/* To get some statistics about memory allocation */
-
-#ifdef XALLOC_LOG
-#define XALLOC_LOG_FILE "/tmp/Xalloc.log"	/* unsecure... */
-#define LOG_BODY(_body)					\
-		{ FILE *f;				\
-		  f = fopen(XALLOC_LOG_FILE, "a");	\
-		  if (NULL!=f) {			\
-			_body;				\
-			fclose(f);			\
-		  }					\
-		}
-#if defined(linux) && defined(__i386__)
-#define LOG_ALLOC(_fun, _size, _ret)						\
-	{	unsigned long *from;						\
-		__asm__("movl %%ebp,%0" : /*OUT*/ "=r" (from) : /*IN*/ );	\
-		LOG_BODY(fprintf(f, "%s\t%i\t%p\t[%lu]\n", _fun, _size, _ret, *(from+1))) \
-	}
-#else
-#define LOG_ALLOC(_fun, _size, _ret)				\
-	LOG_BODY(fprintf(f, "%s\t%i\t%p\n", _fun, _size, _ret))
-#endif
-#define LOG_REALLOC(_fun, _ptr, _size, _ret)			\
-	LOG_BODY(fprintf(f, "%s\t%p\t%i\t%p\n", _fun, _ptr, _size, _ret))
-#define LOG_FREE(_fun, _ptr)					\
-	LOG_BODY(fprintf(f, "%s\t%p\n", _fun, _ptr))
-#else
-#define LOG_ALLOC(_fun, _size, _ret)
-#define LOG_REALLOC(_fun, _ptr, _size, _ret)
-#define LOG_FREE(_fun, _ptr)
-#endif /* XALLOC_LOG */
-
-static unsigned long *free_lists[MAX_SMALL/SIZE_STEPS];
-
-/*
- * systems that support it should define HAS_MMAP_ANON or MMAP_DEV_ZERO
- * and include the appropriate header files for
- * mmap(), munmap(), PROT_READ, PROT_WRITE, MAP_PRIVATE,
- * PAGE_SIZE or _SC_PAGESIZE (and MAP_ANON for HAS_MMAP_ANON).
- *
- * systems that don't support MAP_ANON fall through to the 2 fold behaviour
- */
-
-#if defined(linux)
-#define HAS_MMAP_ANON
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <asm/page.h>	/* PAGE_SIZE */
-#define HAS_SC_PAGESIZE	/* _SC_PAGESIZE may be an enum for Linux */
-#define HAS_GETPAGESIZE
-#endif /* linux */
-
-#if defined(__GNU__)
-#define HAS_MMAP_ANON
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <mach/vm_param.h>     /* PAGE_SIZE */
-#define HAS_SC_PAGESIZE
-#define HAS_GETPAGESIZE
-#endif /* __GNU__ */
-
-#if defined(CSRG_BASED)
-#define HAS_MMAP_ANON
-#define HAS_GETPAGESIZE
-#include <sys/types.h>
-#include <sys/mman.h>
-#endif /* CSRG_BASED */
-
-#if defined(DGUX)
-#define HAS_GETPAGESIZE
-#define MMAP_DEV_ZERO
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <unistd.h>
-#endif /* DGUX */
-
-#if defined(SVR4) && !defined(DGUX)
-#define MMAP_DEV_ZERO
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <unistd.h>
-#endif /* SVR4 && !DGUX */
-
-#if defined(sun) && !defined(SVR4) /* SunOS */
-#define MMAP_DEV_ZERO	/* doesn't SunOS have MAP_ANON ?? */
-#define HAS_GETPAGESIZE
-#include <sys/types.h>
-#include <sys/mman.h>
-#endif /* sun && !SVR4 */
-
-#ifdef XNO_SYSCONF
-#undef _SC_PAGESIZE
-#endif
-
-#if defined(HAS_MMAP_ANON) || defined (MMAP_DEV_ZERO)
-static int pagesize;
-#endif
-
-#ifdef MMAP_DEV_ZERO
-static int devzerofd = -1;
-#include <errno.h>
-#endif
-
-/*
- * empty trap function for gdb. Breakpoint here
- * to find who tries to free a free area
- */
-void XfreeTrap(void)
-{
-}
-
-_X_EXPORT void *
-Xalloc (unsigned long amount)
-{
-    register unsigned long *ptr;
-    int indx;
-
-    /* sanity checks */
-
-    /* zero size requested */
-    if (amount == 0) {
-	LOG_ALLOC("Xalloc=0", amount, 0);
-	return NULL;
-    }
-    /* negative size (or size > 2GB) - what do we do? */
-    if ((long)amount < 0) {
-	/* Diagnostic */
-#ifdef FATALERRORS
- 	FatalError("Xalloc: Xalloc(<0)\n");
-#else
- 	ErrorF("Xalloc warning: Xalloc(<0) ignored..\n");
-#endif
- 	LOG_ALLOC("Xalloc<0", amount, 0);
-	return NULL;
-    }
-
-    /* alignment check */
-#if defined(__alpha__) || defined(__alpha) || \
-    defined(__sparc__) || \
-    defined(__mips__) || \
-    defined(__powerpc__) || \
-    defined(__arm32__) || \
-    defined(__ia64__) || defined(ia64) || \
-    defined(__s390x__) || defined(__s390__)
-    amount = (amount + (sizeof(long)-1)) & ~(sizeof(long)-1);
-#endif
-
-    if (amount <= MAX_SMALL) {
-	/*
-	 * small block
-	 */
-	/* pick a ready to use small chunk */
-	indx = (amount-1) / SIZE_STEPS;
-	ptr = free_lists[indx];
-	if (NULL == ptr) {
-		/* list empty - get 20 or 40 more */
-		/* amount = size rounded up */
-		amount = (indx+1) * SIZE_STEPS;
-		ptr = (unsigned long *)calloc(1,(amount+SIZE_HEADER+TAIL_SIZE)
-						* (amount<100 ? 40 : 20));
-		if (NULL!=ptr) {
-			int i;
-			unsigned long *p1, *p2;
-			p1 = 0;
-			p2 = (unsigned long *)((char *)ptr + SIZE_HEADER);
-			for (i=0; i<(amount<100 ? 40 : 20); i++) {
-				p1 = p2;
-				p1[-2] = amount;
-#ifdef XALLOC_DEBUG
-				p1[-1] = MAGIC_FREE;
-#endif /* XALLOC_DEBUG */
-#ifdef SIZE_TAIL
-				*(unsigned long *)((unsigned char *)p1 + amount) = MAGIC2;
-#endif /* SIZE_TAIL */
-				p2 = (unsigned long *)((char *)p1 + SIZE_HEADER + amount + TAIL_SIZE);
-				*(unsigned long **)p1 = p2;
-			}
-			/* last one has no next one */
-			*(unsigned long **)p1 = NULL;
-			/* put the second in the list */
-			free_lists[indx] = (unsigned long *)((char *)ptr + SIZE_HEADER + amount + TAIL_SIZE + SIZE_HEADER);
-			/* take the fist one */
-			ptr = (unsigned long *)((char *)ptr + SIZE_HEADER);
-			LOG_ALLOC("Xalloc-S", amount, ptr);
-			ptr[-1] = MAGIC;
-			return (void *)ptr;
-		} /* else fall through to 'Out of memory' */
-	} else {
-		/* take that piece of mem out of the list */
-		free_lists[indx] = *((unsigned long **)ptr);
-		/* already has size (and evtl. magic) filled in */
-#ifdef XALLOC_DEBUG
-		ptr[-1] = MAGIC;
-#endif /* XALLOC_DEBUG */
-		LOG_ALLOC("Xalloc-S", amount, ptr);
-		return (void *)ptr;
-	}
-
-#if defined(HAS_MMAP_ANON) || defined(MMAP_DEV_ZERO)
-    } else if (amount >= MIN_LARGE) {
-	/*
-	 * large block
-	 */
-	/* mmapped malloc */
-	/* round up amount */
-	amount += SIZE_HEADER + TAIL_SIZE;
-	/* round up brutto amount to a multiple of the page size */
-	amount = (amount + pagesize-1) & ~(pagesize-1);
-#ifdef MMAP_DEV_ZERO
-	ptr = (unsigned long *)mmap((caddr_t)0,
-					(size_t)amount,
-					PROT_READ | PROT_WRITE,
-					MAP_PRIVATE,
-					devzerofd,
-					(off_t)0);
-#else
-	ptr = (unsigned long *)mmap((caddr_t)0,
-					(size_t)amount,
-					PROT_READ | PROT_WRITE,
-					MAP_ANON | MAP_PRIVATE,
-					-1,
-					(off_t)0);
-#endif
-	if (-1!=(long)ptr) {
-		ptr[0] = amount - SIZE_HEADER - TAIL_SIZE;
-#ifdef XALLOC_DEBUG
-		ptr[1] = MAGIC;
-#endif /* XALLOC_DEBUG */
-#ifdef SIZE_TAIL
-		((unsigned long *)((char *)ptr + amount - TAIL_SIZE))[0] = MAGIC2;
-#endif /* SIZE_TAIL */
-		ptr = (unsigned long *)((char *)ptr + SIZE_HEADER);
-		LOG_ALLOC("Xalloc-L", amount, ptr);
-		return (void *)ptr;
-	} /* else fall through to 'Out of memory' */
-#endif /* HAS_MMAP_ANON || MMAP_DEV_ZERO */
-    } else {
-	/*
-	 * medium sized block
-	 */
-	/* 'normal' malloc() */
-	ptr=(unsigned long *)calloc(1,amount+SIZE_HEADER+TAIL_SIZE);
-	if (ptr != (unsigned long *)NULL) {
-		ptr[0] = amount;
-#ifdef XALLOC_DEBUG
-		ptr[1] = MAGIC;
-#endif /* XALLOC_DEBUG */
-#ifdef SIZE_TAIL
-		*(unsigned long *)((char *)ptr + amount + SIZE_HEADER) = MAGIC2;
-#endif /* SIZE_TAIL */
-		ptr = (unsigned long *)((char *)ptr + SIZE_HEADER);
-		LOG_ALLOC("Xalloc-M", amount, ptr);
-		return (void *)ptr;
-	}
-    }
-    if (Must_have_memory)
-	FatalError("Out of memory");
-    LOG_ALLOC("Xalloc-oom", amount, 0);
-    return NULL;
-}
-
-/*****************
- * XNFalloc 
- * "no failure" realloc, alternate interface to Xalloc w/o Must_have_memory
- *****************/
-
-_X_EXPORT pointer
-XNFalloc (unsigned long amount)
-{
-    register pointer ptr;
-
-    /* zero size requested */
-    if (amount == 0) {
-	LOG_ALLOC("XNFalloc=0", amount, 0);
-	return NULL;
-    }
-    /* negative size (or size > 2GB) - what do we do? */
-    if ((long)amount < 0) {
-	/* Diagnostic */
-#ifdef FATALERRORS
-	FatalError("Xalloc: XNFalloc(<0)\n");
-#else
-	ErrorF("Xalloc warning: XNFalloc(<0) ignored..\n");
-#endif
- 	LOG_ALLOC("XNFalloc<0", amount, 0);
-	return (unsigned long *)NULL;
-    }
-    ptr = Xalloc(amount);
-    if (!ptr)
-    {
-        FatalError("Out of memory");
-    }
-    return ptr;
-}
-
-/*****************
- * Xcalloc
- *****************/
-
-_X_EXPORT pointer
-Xcalloc (unsigned long amount)
-{
-    pointer ret;
-
-    ret = Xalloc (amount);
-    if (ret != 0
-#if defined(HAS_MMAP_ANON) || defined(MMAP_DEV_ZERO)
-	    && (amount < MIN_LARGE)	/* mmaped anonymous mem is already cleared */
-#endif
-       )
-	bzero ((char *) ret, (int) amount);
-    return ret;
-}
-
-/*****************
- * XNFcalloc
- *****************/
-_X_EXPORT void *
-XNFcalloc (unsigned long amount)
-{
-    pointer ret;
-
-    ret = XNFalloc (amount);
-    if (ret != 0
-#if defined(HAS_MMAP_ANON) || defined(MMAP_DEV_ZERO)
-	    && (amount < MIN_LARGE)	/* mmaped anonymous mem is already cleared */
-#endif
-       )
-	bzero ((char *) ret, (int) amount);
-    return ret;
-}
-
-/*****************
- * Xrealloc
- *****************/
-
-_X_EXPORT void *
-Xrealloc (pointer ptr, unsigned long amount)
-{
-    register unsigned long *new_ptr;
-
-    /* zero size requested */
-    if (amount == 0) {
-	if (ptr)
-		Xfree(ptr);
-	LOG_REALLOC("Xrealloc=0", ptr, amount, 0);
-	return NULL;
-    }
-    /* negative size (or size > 2GB) - what do we do? */
-    if ((long)amount < 0) {
-	/* Diagnostic */
-#ifdef FATALERRORS
-	FatalError("Xalloc: Xrealloc(<0)\n");
-#else
-	ErrorF("Xalloc warning: Xrealloc(<0) ignored..\n");
-#endif
-	if (ptr)
-		Xfree(ptr);	/* ?? */
-	LOG_REALLOC("Xrealloc<0", ptr, amount, 0);
-	return NULL;
-    }
-
-    new_ptr = Xalloc(amount);
-    if ( (new_ptr) && (ptr) ) {
-	unsigned long old_size;
-	old_size = ((unsigned long *)ptr)[-2];
-#ifdef XALLOC_DEBUG
-	if (MAGIC != ((unsigned long *)ptr)[-1]) {
-	    if (MAGIC_FREE == ((unsigned long *)ptr)[-1]) {
-#ifdef FATALERRORS
-		XfreeTrap();
-		FatalError("Xalloc error: range already freed in Xrealloc() :-(\n");
-#else
-		ErrorF("Xalloc error: range already freed in Xrealloc() :-(\a\n");
-		sleep(5);
-		XfreeTrap();
-#endif
-		LOG_REALLOC("Xalloc error: ranged already freed in Xrealloc() :-(",
-			ptr, amount, 0);
-		return NULL;
-	    }
-#ifdef FATALERRORS
-	    XfreeTrap();
-		FatalError("Xalloc error: header corrupt in Xrealloc() :-(\n");
-#else
-		ErrorF("Xalloc error: header corrupt in Xrealloc() :-(\n");
-		XfreeTrap();
-#endif
-		LOG_REALLOC("Xalloc error: header corrupt in Xrealloc() :-(",
-			ptr, amount, 0);
-		return NULL;
-	}
-#endif /* XALLOC_DEBUG */
-	/* copy min(old size, new size) */
-	memcpy((char *)new_ptr, (char *)ptr, (amount < old_size ? amount : old_size));
-    }
-    if (ptr)
-	Xfree(ptr);
-    if (new_ptr) {
-	LOG_REALLOC("Xrealloc", ptr, amount, new_ptr);
-	return (void *)new_ptr;
-    }
-    if (Must_have_memory)
-	FatalError("Out of memory");
-    LOG_REALLOC("Xrealloc", ptr, amount, 0);
-    return NULL;
-}
-                    
-/*****************
- * XNFrealloc 
- * "no failure" realloc, alternate interface to Xrealloc w/o Must_have_memory
- *****************/
-
-_X_EXPORT void *
-XNFrealloc (pointer ptr, unsigned long amount)
-{
-    if (( ptr = (pointer)Xrealloc( ptr, amount ) ) == NULL)
-    {
-        FatalError( "Out of memory" );
-    }
-    return ptr;
-}
-
-/*****************
- *  Xfree
- *    calls free 
- *****************/    
-
-_X_EXPORT void
-Xfree(pointer ptr)
-{
-    unsigned long size;
-    unsigned long *pheader;
-
-    /* free(NULL) IS valid :-(  - and widely used throughout the server.. */
-    if (!ptr)
-	return;
-
-    pheader = (unsigned long *)((char *)ptr - SIZE_HEADER);
-#ifdef XALLOC_DEBUG
-    if (MAGIC != pheader[1]) {
-	/* Diagnostic */
-	if (MAGIC_FREE == pheader[1]) {
-#ifdef FATALERRORS
-	    XfreeTrap();
-	    FatalError("Xalloc error: range already freed in Xrealloc() :-(\n");
-#else
-	    ErrorF("Xalloc error: range already freed in Xrealloc() :-(\a\n");
-	    sleep(5);
-	    XfreeTrap();
-#endif
-	    LOG_FREE("Xalloc error: ranged already freed in Xrealloc() :-(", ptr);
-	    return;
-	}
-#ifdef FATALERRORS
-	XfreeTrap();
-	FatalError("Xalloc error: Header corrupt in Xfree() :-(\n");
-#else
-	ErrorF("Xalloc error: Header corrupt in Xfree() :-(\n");
-	XfreeTrap();
-#endif
-	LOG_FREE("Xalloc error:  Header corrupt in Xfree() :-(", ptr);
-	return;
-    }
-#endif /* XALLOC_DEBUG */
-
-    size = pheader[0];
-    if (size <= MAX_SMALL) {
-	int indx;
-	/*
-	 * small block
-	 */
-#ifdef SIZE_TAIL
-	if (MAGIC2 != *(unsigned long *)((char *)ptr + size)) {
-		/* Diagnostic */
-#ifdef FATALERRORS
-	    	XfreeTrap();
-		FatalError("Xalloc error: Tail corrupt in Xfree() for small block (adr=0x%x, val=0x%x)\n",(char *)ptr + size,*(unsigned long *)((char *)ptr + size));
-#else
-		ErrorF("Xalloc error: Tail corrupt in Xfree() for small block (adr=0x%x, val=0x%x)\n",(char *)ptr + size,*(unsigned long *)((char *)ptr + size));
-		XfreeTrap();
-#endif
-		LOG_FREE("Xalloc error: Tail corrupt in Xfree() for small block", ptr);
-		return;
-	}
-#endif /* SIZE_TAIL */
-
-#ifdef XFREE_ERASES
-	memset(ptr,0xF0,size);
-#endif /* XFREE_ERASES */
-#ifdef XALLOC_DEBUG
-	pheader[1] = MAGIC_FREE;
-#endif
-	/* put this small block at the head of the list */
-	indx = (size-1) / SIZE_STEPS;
-	*(unsigned long **)(ptr) = free_lists[indx];
-	free_lists[indx] = (unsigned long *)ptr;
-	LOG_FREE("Xfree", ptr);
-	return;
-
-#if defined(HAS_MMAP_ANON) || defined(MMAP_DEV_ZERO)
-    } else if (size >= MIN_LARGE) {
-	/*
-	 * large block
-	 */
-#ifdef SIZE_TAIL
-	if (MAGIC2 != ((unsigned long *)((char *)ptr + size))[0]) {
-		/* Diagnostic */
-#ifdef FATALERRORS
-	    XfreeTrap();
-		FatalError("Xalloc error: Tail corrupt in Xfree() for big block (adr=0x%x, val=0x%x)\n",(char *)ptr+size,((unsigned long *)((char *)ptr + size))[0]);
-#else
-		ErrorF("Xalloc error: Tail corrupt in Xfree() for big block (adr=0x%x, val=0x%x)\n",(char *)ptr+size,((unsigned long *)((char *)ptr + size))[0]);
-		XfreeTrap();
-#endif
-		LOG_FREE("Xalloc error: Tail corrupt in Xfree() for big block", ptr);
-		return;
-	}
-	size += SIZE_TAIL;
-#endif /* SIZE_TAIL */
-
-	LOG_FREE("Xfree", ptr);
-	size += SIZE_HEADER;
-	munmap((caddr_t)pheader, (size_t)size);
-	/* no need to clear - mem is inaccessible after munmap.. */
-#endif /* HAS_MMAP_ANON */
-
-    } else {
-	/*
-	 * medium sized block
-	 */
-#ifdef SIZE_TAIL
-	if (MAGIC2 != *(unsigned long *)((char *)ptr + size)) {
-		/* Diagnostic */
-#ifdef FATALERRORS
-	    XfreeTrap();
-		FatalError("Xalloc error: Tail corrupt in Xfree() for medium block (adr=0x%x, val=0x%x)\n",(char *)ptr + size,*(unsigned long *)((char *)ptr + size));
-#else
-		ErrorF("Xalloc error: Tail corrupt in Xfree() for medium block (adr=0x%x, val=0x%x)\n",(char *)ptr + size,*(unsigned long *)((char *)ptr + size));
-		XfreeTrap();
-#endif
-		LOG_FREE("Xalloc error: Tail corrupt in Xfree() for medium block", ptr);
-		return;
-	}
-#endif /* SIZE_TAIL */
-
-#ifdef XFREE_ERASES
-	memset(pheader,0xF0,size+SIZE_HEADER);
-#endif /* XFREE_ERASES */
-#ifdef XALLOC_DEBUG
-	pheader[1] = MAGIC_FREE;
-#endif
-
-	LOG_FREE("Xfree", ptr);
-	free((char *)pheader);
-    }
-}
-
-void
-OsInitAllocator (void)
-{
-    static Bool beenhere = FALSE;
-
-    if (beenhere)
-	return;
-    beenhere = TRUE;
-
-#if defined(HAS_MMAP_ANON) || defined (MMAP_DEV_ZERO)
-    pagesize = -1;
-#if defined(_SC_PAGESIZE) || defined(HAS_SC_PAGESIZE)
-    pagesize = sysconf(_SC_PAGESIZE);
-#endif
-#ifdef _SC_PAGE_SIZE
-    if (pagesize == -1)
-	pagesize = sysconf(_SC_PAGE_SIZE);
-#endif
-#ifdef HAS_GETPAGESIZE
-    if (pagesize == -1)
-	pagesize = getpagesize();
-#endif
-#ifdef PAGE_SIZE
-    if (pagesize == -1)
-	pagesize = PAGE_SIZE;
-#endif
-    if (pagesize == -1)
-	FatalError("OsInitAllocator: Cannot determine page size\n");
-#endif
-
-    /* set up linked lists of free blocks */
-    bzero ((char *) free_lists, MAX_SMALL/SIZE_STEPS*sizeof(unsigned long *));
-
-#ifdef MMAP_DEV_ZERO
-    /* open /dev/zero on systems that have mmap, but not MAP_ANON */
-    if (devzerofd < 0) {
-	if ((devzerofd = open("/dev/zero", O_RDWR, 0)) < 0)
-	    FatalError("OsInitAllocator: Cannot open /dev/zero (errno=%d)\n",
-			errno);
-    }
-#endif
-
-#ifdef XALLOC_LOG
-    /* reset the log file to zero length */
-    {
-	FILE *f;
-	f = fopen(XALLOC_LOG_FILE, "w");
-	if (NULL!=f)
-		fclose(f);
-    }
-#endif
-}
-
-#else /* !INTERNAL_MALLOC */
-/* This is to avoid an empty .o */
-static int no_internal_xalloc;
-#endif /* INTERNAL_MALLOC */
commit c67b9c5fc33002b13a2360929a37f24169710f64
Author: Adam Jackson <ajax at redhat.com>
Date:   Thu Nov 15 14:24:36 2007 -0500

    Clean up some garbage in driver enumeration.

diff --git a/configure.ac b/configure.ac
index 8a1f88c..35b7f0f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1518,8 +1518,6 @@ dnl has it in libc), or if libdl is needed to get it.
 	AC_DEFINE(NEED_XF86_PROTOTYPES, 1, [Need XFree86 helper functions])
 	AC_DEFINE(__XSERVERNAME__, "Xorg", [Name of X server])
 	AC_DEFINE(WITH_VGAHW, 1, [Building vgahw module])
-	AC_DEFINE(DRIVERS, {}, [Built-in output drivers (none)])
-	AC_DEFINE(IDRIVERS, {}, [Built-in input drivers (none)])
 	AC_DEFINE_DIR(__XCONFIGFILE__, XF86CONFIGFILE, [Name of configuration file])
 	AC_DEFINE_DIR(XF86CONFIGFILE, XF86CONFIGFILE, [Name of configuration file])
 	AC_DEFINE_DIR(DEFAULT_MODULE_PATH, moduledir, [Default module search path])
diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 6380274..e74c590 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -538,14 +538,8 @@ fixup_video_driver_list(char **drivers)
     }
 }
 
-
-/*
- * Generate a compiled-in list of driver names.  This is used to produce a
- * consistent probe order.  For the loader server, we also look for vendor-
- * provided modules, pre-pending them to our own list.
- */
 static char **
-GenerateDriverlist(char * dirname, char * drivernames)
+GenerateDriverlist(char * dirname)
 {
     char **ret;
     const char *subdirs[] = { dirname, NULL };
@@ -559,20 +553,13 @@ GenerateDriverlist(char * dirname, char * drivernames)
     return ret;
 }
 
-
 char **
 xf86DriverlistFromCompile(void)
 {
     static char **driverlist = NULL;
-    static Bool generated = FALSE;
-
-    /* This string is modified in-place */
-    static char drivernames[] = DRIVERS;
 
-    if (!generated) {
-        generated = TRUE;
-        driverlist = GenerateDriverlist("drivers", drivernames);
-    }
+    if (!driverlist)
+        driverlist = GenerateDriverlist("drivers");
 
     return driverlist;
 }
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index 1ef7973..d37875c 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -1492,9 +1492,6 @@ xf86PrintChipsets(const char *drvname, const char *drvmsg, SymTabPtr chips)
 }
 
 
-#define MAXDRIVERS 64	/* A >hack<, to be sure ... */
-
-
 _X_EXPORT int
 xf86MatchDevice(const char *drivername, GDevPtr **sectlist)
 {
diff --git a/include/xorg-server.h.in b/include/xorg-server.h.in
index 2a0a5f5..f382131 100644
--- a/include/xorg-server.h.in
+++ b/include/xorg-server.h.in
@@ -31,9 +31,6 @@
 /* Build DPMS extension */
 #undef DPMSExtension
 
-/* Built-in output drivers */
-#undef DRIVERS
-
 /* Build GLX extension */
 #undef GLXEXT
 
@@ -46,9 +43,6 @@
 /* Support SHM */
 #undef HAS_SHM
 
-/* Built-in input drivers */
-#undef IDRIVERS
-
 /* Support IPv6 for TCP connections */
 #undef IPv6
 
commit 0706e5e790060fbf046cfaff295b78806b7841c6
Author: Adam Jackson <ajax at redhat.com>
Date:   Thu Nov 15 14:15:09 2007 -0500

    Eliminate some redundancy in autoconfiguration.
    
    We already synthesize Monitor and Module sections for you, no need to
    specify them explicitly in the fake config buffer.

diff --git a/hw/xfree86/common/xf86AutoConfig.c b/hw/xfree86/common/xf86AutoConfig.c
index c5998bf..c6e1972 100644
--- a/hw/xfree86/common/xf86AutoConfig.c
+++ b/hw/xfree86/common/xf86AutoConfig.c
@@ -43,16 +43,6 @@
 
 /* Sections for the default built-in configuration. */
 
-#define BUILTIN_MODULE_SECTION \
-	"Section \"Module\"\n" \
-	"\tLoad\t\"extmod\"\n" \
-	"\tLoad\t\"dbe\"\n" \
-	"\tLoad\t\"glx\"\n" \
-	"\tLoad\t\"freetype\"\n" \
-	"\tLoad\t\"record\"\n" \
-	"\tLoad\t\"dri\"\n" \
-	"EndSection\n\n"
-
 #define BUILTIN_DEVICE_NAME \
 	"\"Builtin Default %s Device %d\""
 
@@ -68,14 +58,6 @@
 	BUILTIN_DEVICE_SECTION_PRE \
 	BUILTIN_DEVICE_SECTION_POST
 
-#define BUILTIN_MONITOR_NAME \
-	"\"Builtin Default Monitor\""
-
-#define BUILTIN_MONITOR_SECTION \
-	"Section \"Monitor\"\n" \
-	"\tIdentifier\t" BUILTIN_MONITOR_NAME "\n" \
-	"EndSection\n\n"
-
 #define BUILTIN_SCREEN_NAME \
 	"\"Builtin Default %s Screen %d\""
 
@@ -83,7 +65,6 @@
 	"Section \"Screen\"\n" \
 	"\tIdentifier\t" BUILTIN_SCREEN_NAME "\n" \
 	"\tDevice\t" BUILTIN_DEVICE_NAME "\n" \
-	"\tMonitor\t" BUILTIN_MONITOR_NAME "\n" \
 	"EndSection\n\n"
 
 #define BUILTIN_LAYOUT_SECTION_PRE \
@@ -220,9 +201,6 @@ xf86AutoConfig(void)
 
     driver = chooseVideoDriver();
 
-    AppendToConfig(BUILTIN_MODULE_SECTION);
-    AppendToConfig(BUILTIN_MONITOR_SECTION);
-
     if (driver) {
 	snprintf(buf, sizeof(buf), BUILTIN_DEVICE_SECTION_PRE,
 		 driver, 0, driver);
commit 2c01a49bf0a407bd5510bb9ceb4ef86a2cc36be9
Author: Adam Jackson <ajax at redhat.com>
Date:   Thu Nov 15 13:32:59 2007 -0500

    Don't sleep(1) at exit on any platform.

diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index d4f01d3..b5ee21d 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -1307,10 +1307,6 @@ AbortDDX()
   /*
    * try to restore the original video state
    */
-#if defined(HAS_USL_VTS) && !defined(linux)
-  /* Need the sleep when starting X from within another X session */
-  sleep(1);
-#endif
 #ifdef DPMSExtension /* Turn screens back on */
   if (DPMSPowerLevel != DPMSModeOn)
       DPMSSet(DPMSModeOn);
commit 4c9cc82fc4461d180ae2c2fbe50e7f98b0777f91
Author: Tiago Vignatti <vignatti at c3sl.ufpr.br>
Date:   Thu Nov 15 01:46:11 2007 -0200

    For some reason "-nozap" appeared twice. Weird.

diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c
index 8c4342e..5376f19 100644
--- a/hw/kdrive/src/kdrive.c
+++ b/hw/kdrive/src/kdrive.c
@@ -632,11 +632,6 @@ KdProcessArgument (int argc, char **argv, int i)
 	kdDontZap = TRUE;
 	return 1;
     }
-    if (!strcmp (argv[i], "-nozap"))
-    {
-	kdDontZap = TRUE;
-	return 1;
-    }
     if (!strcmp (argv[i], "-3button"))
     {
 	kdEmulateMiddleButton = FALSE;
commit 3dde66f96b9b8431381871cf85266da3ec57a0d4
Author: Adam Jackson <ajax at redhat.com>
Date:   Wed Nov 14 15:10:59 2007 -0500

    Start 1.4.99

diff --git a/configure.ac b/configure.ac
index 1df8874..8a1f88c 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.1, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+AC_INIT([xorg-server], 1.4.99.1, [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 c3897ca7099fc007b4134a8fabd4c707f99f2ac7
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri Nov 9 13:55:32 2007 -0500

    Add -pogo option for init/teardown performance testing.

diff --git a/os/utils.c b/os/utils.c
index ae96a41..d46a756 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -933,6 +933,10 @@ ProcessCommandLine(int argc, char *argv[])
 	    else
 		UseMsg();
 	}
+	else if (strcmp(argv[i], "-pogo") == 0)
+	{
+	    dispatchException = DE_TERMINATE;
+	}
 	else if ( strcmp( argv[i], "-pn") == 0)
 	    PartialNetwork = TRUE;
 	else if ( strcmp( argv[i], "-nopn") == 0)
commit cecac794451b793871f297b91a11d3b52eeb6d1b
Author: Adam Jackson <ajax at redhat.com>
Date:   Thu Nov 8 17:25:36 2007 -0500

    Don't sleep(1) at server exit.

diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index bf577e6..d4f01d3 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -1307,7 +1307,7 @@ AbortDDX()
   /*
    * try to restore the original video state
    */
-#ifdef HAS_USL_VTS
+#if defined(HAS_USL_VTS) && !defined(linux)
   /* Need the sleep when starting X from within another X session */
   sleep(1);
 #endif
commit f7dd0c72b8f861f4d5443a43d1013e3fe3db43ca
Author: Matthias Hopf <mhopf at suse.de>
Date:   Mon Nov 12 15:11:03 2007 +0100

    Only clear crtc of output if it is the one we're actually working on.
    
    Upon recreation of the RandR internal data structures in RRCrtcNotify() the
    crtc of an output could be NULLed if the crtc was shared (cloned) between two
    outputs and one of them got another crtc assigned.

diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index db5007e..43cfb29 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -150,7 +150,8 @@ RRCrtcNotify (RRCrtcPtr	    crtc,
 		break;
 	if (i == numOutputs)
 	{
-	    crtc->outputs[j]->crtc = NULL;
+	    if (crtc->outputs[j]->crtc == crtc)
+		crtc->outputs[j]->crtc = NULL;
 	    RROutputChanged (crtc->outputs[j], FALSE);
 	    RRCrtcChanged (crtc, FALSE);
 	}
commit f48087b6c33c1f84bf2cfc0744b1c38697321c07
Author: Kristian Høgsberg <krh at temari.boston.redhat.com>
Date:   Fri Nov 9 05:49:26 2007 -0500

    Regenerate GLX dispatch code for recent gl_API.xml changes (#12935).

diff --git a/GL/glx/indirect_dispatch.c b/GL/glx/indirect_dispatch.c
index 00a9f96..2afd3eb 100644
--- a/GL/glx/indirect_dispatch.c
+++ b/GL/glx/indirect_dispatch.c
@@ -5169,31 +5169,6 @@ void __glXDisp_LoadProgramNV(GLbyte * pc)
     ) );
 }
 
-void __glXDisp_ProgramParameter4dvNV(GLbyte * pc)
-{
-#ifdef __GLX_ALIGN64
-    if ((unsigned long)(pc) & 7) {
-        (void) memmove(pc-4, pc, 40);
-        pc -= 4;
-    }
-#endif
-
-    CALL_ProgramParameter4dvNV( GET_DISPATCH(), (
-        *(GLenum   *)(pc +  0),
-        *(GLuint   *)(pc +  4),
-         (const GLdouble *)(pc +  8)
-    ) );
-}
-
-void __glXDisp_ProgramParameter4fvNV(GLbyte * pc)
-{
-    CALL_ProgramParameter4fvNV( GET_DISPATCH(), (
-        *(GLenum   *)(pc +  0),
-        *(GLuint   *)(pc +  4),
-         (const GLfloat *)(pc +  8)
-    ) );
-}
-
 void __glXDisp_ProgramParameters4dvNV(GLbyte * pc)
 {
     const GLuint num = *(GLuint   *)(pc +  8);
diff --git a/GL/glx/indirect_dispatch.h b/GL/glx/indirect_dispatch.h
index bb39638..e81c382 100644
--- a/GL/glx/indirect_dispatch.h
+++ b/GL/glx/indirect_dispatch.h
@@ -149,8 +149,6 @@ extern HIDDEN int __glXDisp_GetProgramNamedParameterfvNV(struct __GLXclientState
 extern HIDDEN int __glXDispSwap_GetProgramNamedParameterfvNV(struct __GLXclientStateRec *, GLbyte *);
 extern HIDDEN void __glXDisp_PointParameterfEXT(GLbyte * pc);
 extern HIDDEN void __glXDispSwap_PointParameterfEXT(GLbyte * pc);
-extern HIDDEN void __glXDisp_ProgramParameter4dvNV(GLbyte * pc);
-extern HIDDEN void __glXDispSwap_ProgramParameter4dvNV(GLbyte * pc);
 extern HIDDEN void __glXDisp_TexCoord2sv(GLbyte * pc);
 extern HIDDEN void __glXDispSwap_TexCoord2sv(GLbyte * pc);
 extern HIDDEN void __glXDisp_Vertex4dv(GLbyte * pc);
@@ -425,8 +423,6 @@ extern HIDDEN void __glXDisp_FramebufferTexture1DEXT(GLbyte * pc);
 extern HIDDEN void __glXDispSwap_FramebufferTexture1DEXT(GLbyte * pc);
 extern HIDDEN int __glXDisp_GetDrawableAttributes(struct __GLXclientStateRec *, GLbyte *);
 extern HIDDEN int __glXDispSwap_GetDrawableAttributes(struct __GLXclientStateRec *, GLbyte *);
-extern HIDDEN void __glXDisp_ProgramParameter4fvNV(GLbyte * pc);
-extern HIDDEN void __glXDispSwap_ProgramParameter4fvNV(GLbyte * pc);
 extern HIDDEN void __glXDisp_RasterPos2sv(GLbyte * pc);
 extern HIDDEN void __glXDispSwap_RasterPos2sv(GLbyte * pc);
 extern HIDDEN void __glXDisp_Color4ubv(GLbyte * pc);
diff --git a/GL/glx/indirect_dispatch_swap.c b/GL/glx/indirect_dispatch_swap.c
index c0bb71c..f137cbe 100644
--- a/GL/glx/indirect_dispatch_swap.c
+++ b/GL/glx/indirect_dispatch_swap.c
@@ -5325,31 +5325,6 @@ void __glXDispSwap_LoadProgramNV(GLbyte * pc)
     ) );
 }
 
-void __glXDispSwap_ProgramParameter4dvNV(GLbyte * pc)
-{
-#ifdef __GLX_ALIGN64
-    if ((unsigned long)(pc) & 7) {
-        (void) memmove(pc-4, pc, 40);
-        pc -= 4;
-    }
-#endif
-
-    CALL_ProgramParameter4dvNV( GET_DISPATCH(), (
-         (GLenum  )bswap_ENUM   ( pc +  0 ),
-         (GLuint  )bswap_CARD32 ( pc +  4 ),
-         (const GLdouble *)bswap_64_array( (uint64_t *) (pc +  8), 4 )
-    ) );
-}
-
-void __glXDispSwap_ProgramParameter4fvNV(GLbyte * pc)
-{
-    CALL_ProgramParameter4fvNV( GET_DISPATCH(), (
-         (GLenum  )bswap_ENUM   ( pc +  0 ),
-         (GLuint  )bswap_CARD32 ( pc +  4 ),
-         (const GLfloat *)bswap_32_array( (uint32_t *) (pc +  8), 4 )
-    ) );
-}
-
 void __glXDispSwap_ProgramParameters4dvNV(GLbyte * pc)
 {
     const GLuint num =  (GLuint  )bswap_CARD32 ( pc +  8 );
diff --git a/GL/glx/indirect_size_get.c b/GL/glx/indirect_size_get.c
index 9285714..f64fb7e 100644
--- a/GL/glx/indirect_size_get.c
+++ b/GL/glx/indirect_size_get.c
@@ -652,6 +652,10 @@ __glGetBooleanv_size(GLenum e)
     case GL_WEIGHT_ARRAY_SIZE_ARB:
     case GL_WEIGHT_ARRAY_ARB:
     case GL_PACK_INVERT_MESA:
+    case GL_STENCIL_BACK_FUNC_ATI:
+    case GL_STENCIL_BACK_FAIL_ATI:
+    case GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI:
+    case GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI:
     case GL_FRAGMENT_PROGRAM_ARB:
     case GL_MAX_DRAW_BUFFERS_ARB:
 /*      case GL_MAX_DRAW_BUFFERS_ATI:*/
diff --git a/GL/glx/indirect_table.c b/GL/glx/indirect_table.c
index 3da1f43..cb32026 100644
--- a/GL/glx/indirect_table.c
+++ b/GL/glx/indirect_table.c
@@ -644,7 +644,7 @@ static const void *Render_function_table[400][2] = {
     /* [ 301] =  4181 */ {__glXDisp_ExecuteProgramNV, __glXDispSwap_ExecuteProgramNV},
     /* [ 302] =  4182 */ {__glXDisp_RequestResidentProgramsNV, __glXDispSwap_RequestResidentProgramsNV},
     /* [ 303] =  4183 */ {__glXDisp_LoadProgramNV, __glXDispSwap_LoadProgramNV},
-    /* [ 304] =  4184 */ {__glXDisp_ProgramParameter4fvNV, __glXDispSwap_ProgramParameter4fvNV},
+    /* [ 304] =  4184 */ {__glXDisp_ProgramEnvParameter4fvARB, __glXDispSwap_ProgramEnvParameter4fvARB},
     /* [ 305] =  4185 */ {__glXDisp_ProgramEnvParameter4dvARB, __glXDispSwap_ProgramEnvParameter4dvARB},
     /* [ 306] =  4186 */ {__glXDisp_ProgramParameters4fvNV, __glXDispSwap_ProgramParameters4fvNV},
     /* [ 307] =  4187 */ {__glXDisp_ProgramParameters4dvNV, __glXDispSwap_ProgramParameters4dvNV},
commit f2a3728868376a3646832d4af3a29549ce0b8f5d
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 eb736b7..89c02f8 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -836,13 +836,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 */
@@ -865,6 +865,7 @@ RootlessCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
         RootlessDamageRegion(pWin, prgnSrc);
     }
 
+out:
     REGION_UNINIT(pScreen, &rgnDst);
     fbValidateDrawable(&pWin->drawable);
 
commit 338c1aedbdf3964e542947140f7c50d58542cf12
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 38675a3..461ca39 100644
--- a/hw/darwin/apple/X11Application.m
+++ b/hw/darwin/apple/X11Application.m
@@ -789,44 +789,40 @@ environment?", @"Startup xinitrc dialog");
 
 void X11ApplicationMain (int argc, const char *argv[],
 			 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)) {
-      ErrorF("can't create secondary thread\n");
-      exit(1);
-    }
-	
-    [NSApp run];
+  
+  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 bd269d0d783d418ef99363478fdf849fd89eed76
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 84e295b..38675a3 100644
--- a/hw/darwin/apple/X11Application.m
+++ b/hw/darwin/apple/X11Application.m
@@ -819,7 +819,7 @@ 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]);
 	
     if (!create_thread (server_thread, server_arg)) {
       ErrorF("can't create secondary thread\n");
commit b4d14484056e6f4a7374fc1acf3f223be4bd116f
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 46baac7..bd8e63e 100644
--- a/hw/darwin/quartz/xpr/xpr.h
+++ b/hw/darwin/quartz/xpr/xpr.h
@@ -38,8 +38,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 05d5b9baa05a4ba14a4383d8a981bc327d99290c
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 29f54de..762a84b 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 9a8abcfa6d6d0cdc17be02a3443a7e116eb07d07
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 0a080db..84e295b 100644
--- a/hw/darwin/apple/X11Application.m
+++ b/hw/darwin/apple/X11Application.m
@@ -201,6 +201,8 @@ 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/darwin/quartz/xpr/xpr.h b/hw/darwin/quartz/xpr/xpr.h
index 73a88c0..46baac7 100644
--- a/hw/darwin/quartz/xpr/xpr.h
+++ b/hw/darwin/quartz/xpr/xpr.h
@@ -38,6 +38,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 aa38845..ddb6d2d 100644
--- a/hw/darwin/quartz/xpr/xprFrame.c
+++ b/hw/darwin/quartz/xpr/xprFrame.c
@@ -424,6 +424,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 b34d2ffc38002f7c4980c138f57e9a828cd79c37
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 6b235ad..0a080db 100644
--- a/hw/darwin/apple/X11Application.m
+++ b/hw/darwin/apple/X11Application.m
@@ -183,116 +183,111 @@ static void 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;
+  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 ([self isActive]) {
-	  [self deactivate];
-	  
-	  if (!_x_active && quartzProcs->IsX11Window([e window], [e windowNumber]))
-	    [self activateX:YES];
-	}
+	if (!_x_active && quartzProcs->IsX11Window([e window],
+						   [e windowNumber]))
+	  [self activateX:YES];
       }
-      break;
+    }
+    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
+  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;
+		    || [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();
+      } 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;
 	}
-	break;
-			
-      case 18: /* ApplicationDidReactivate */
-	if (quartzHasRoot) for_appkit = NO;
-	break;
-			
-      case NSApplicationDeactivatedEventType:
-	for_x = NO;
-	[self activateX:NO];
-	break;
+      }
+    } 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;
       
-    default: break; /* for gcc */
+    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 {
@@ -596,52 +591,51 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
     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);
-		
-  }
 	
-  X11EnableKeyEquivalents = [self prefs_get_boolean:@PREFS_KEYEQUIVS
-				  default:X11EnableKeyEquivalents];
+    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];
+    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. */
commit 50dac9b2cb3b40810fb79253adc0265a838a497b
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 70ce57e..e633858 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 25061a8..29f54de 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 4a3c0f6..eb736b7 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
@@ -565,7 +696,6 @@ RootlessRestackWindow(WindowPtr pWin, WindowPtr pOldNextSib)
     RL_DEBUG_MSG("restackwindow end\n");
 }
 
-
 /*
  * Specialized window copy procedures
  */
commit ce7cfbe261b7fd4fcd09d1a4a61344d1555a71f2
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Thu Nov 8 20:10:51 2007 -0800

    Fixed check to refer to DarwinApp, not all Darwin targets

diff --git a/mi/miinitext.c b/mi/miinitext.c
index b40e8bd..6fa180b 100644
--- a/mi/miinitext.c
+++ b/mi/miinitext.c
@@ -672,7 +672,7 @@ InitVisualWrap()
 {
     miResetInitVisuals();
 #ifdef GLXEXT
-#ifdef __DARWIN__
+#ifdef INXDARWINAPP
     DarwinGlxWrapInitVisuals(&miInitVisualsProc);
 #endif
 #endif
commit d68bd5510437c1fd3850e020f7cd90901fae8e1b
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Thu Nov 8 20:08:49 2007 -0800

    fixing GLX in Xquartz

diff --git a/configure.ac b/configure.ac
index cd78dc4..1df8874 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1746,7 +1746,8 @@ return 0;}
 #               LDFLAGS=$save_LDFLAGS
 #               ])
                xorg_cv_AGL_framework=no
-	       DARWIN_LIBS="$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="$FB_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $DARWIN_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])
commit a6ac9002956767fefa37aac95513e21ac5246d15
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 40b5e92..b40d81e 100644
--- a/hw/darwin/quartz/quartzKeyboard.c
+++ b/hw/darwin/quartz/quartzKeyboard.c
@@ -1,8 +1,7 @@
 /*
    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, 2007 Apple Inc.
 
@@ -150,15 +149,11 @@ 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;
@@ -190,10 +185,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
@@ -202,10 +195,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;
 }
@@ -249,53 +239,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];
@@ -307,67 +283,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 67e96be13cdb45be31db121ce216295cd9496d20
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 b580a8e..40b5e92 100644
--- a/hw/darwin/quartz/quartzKeyboard.c
+++ b/hw/darwin/quartz/quartzKeyboard.c
@@ -222,36 +222,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 154fb6417e5d0bae5191984beac5ce045ce754bb
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/xpr/xprFrame.c b/hw/darwin/quartz/xpr/xprFrame.c
index c395f07..aa38845 100644
--- a/hw/darwin/quartz/xpr/xprFrame.c
+++ b/hw/darwin/quartz/xpr/xprFrame.c
@@ -67,6 +67,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
@@ -184,7 +185,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);
 }
 
commit 169f83e366f678ac5441ad21beb84c9b8c65d28e
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 709e6e8..886ef34 100644
--- a/hw/darwin/quartz/xpr/xprScreen.c
+++ b/hw/darwin/quartz/xpr/xprScreen.c
@@ -228,7 +228,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 476a9d85f819f454a6901ccb7eb028d1c563c341
Author: Dodji Seketeli <dodji at openedhand.com>
Date:   Thu Nov 8 09:11:05 2007 +0100

    Xephyr: do not AM_CONDITIONAL inside a shell if branch

diff --git a/configure.ac b/configure.ac
index 1b45801..cd78dc4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1861,7 +1861,6 @@ if test "$KDRIVE" = yes; then
     if test x$XEPHYR_DRI = xyes ; then
         AC_DEFINE(XEPHYR_DRI,1,[enable DRI extension in xephyr])
     fi
-    AM_CONDITIONAL(XEPHYR_HAS_DRI, [test x$XEPHYR_DRI = xyes])
 
     # Xephyr needs nanosleep() which is in librt on Solaris
     AC_CHECK_FUNC([nanosleep], [],
@@ -1919,6 +1918,7 @@ AM_CONDITIONAL(KDRIVEFBDEV, [test "x$XFBDEV" = xyes])
 AM_CONDITIONAL(XSDLSERVER, [test x"$XSDL" = xyes])
 AM_CONDITIONAL(XEPHYR, [test "x$KDRIVE" = xyes && test "x$XEPHYR" = xyes])
 AM_CONDITIONAL(BUILD_KDRIVEFBDEVLIB, [test "x$KDRIVE" = xyes && test "x$KDRIVEFBDEVLIB" = xyes])
+AM_CONDITIONAL(XEPHYR_HAS_DRI, [test x$XEPHYR_DRI = xyes])
 AM_CONDITIONAL(XFAKESERVER, [test "x$KDRIVE" = xyes && test "x$XFAKE" = xyes])
 
 dnl these only go in xkb-config.h (which is shared by the Xorg and Xnest servers)
commit 0e9ef65fa583bf2393dd0fda82df6f092387b425
Author: Keith Packard <keithp at koto.keithp.com>
Date:   Wed Nov 7 16:33:10 2007 -0800

    Don't frob timers unless SmartSchedule is running

diff --git a/os/utils.c b/os/utils.c
index 3228146..ae96a41 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -1520,6 +1520,8 @@ SmartScheduleStopTimer (void)
 #ifdef SMART_SCHEDULE_POSSIBLE
     struct itimerval	timer;
     
+    if (SmartScheduleDisable)
+	return;
     timer.it_interval.tv_sec = 0;
     timer.it_interval.tv_usec = 0;
     timer.it_value.tv_sec = 0;
@@ -1534,6 +1536,8 @@ SmartScheduleStartTimer (void)
 #ifdef SMART_SCHEDULE_POSSIBLE
     struct itimerval	timer;
     
+    if (SmartScheduleDisable)
+	return;
     timer.it_interval.tv_sec = 0;
     timer.it_interval.tv_usec = SmartScheduleInterval * 1000;
     timer.it_value.tv_sec = 0;
commit e94ab0b502160376d1956345196f7e1c7e2e886f
Merge: 26e1fc7... 9bee1c6...
Author: Dodji Seketeli <dodji at openedhand.com>
Date:   Wed Nov 7 19:04:24 2007 +0100

    sync with 'master'

commit 9bee1c6912817f65bbb8cf4078f0ad016d9d51cb
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Wed Nov 7 18:56:45 2007 +0100

    EXA: Disable problematic optimization of dest pixmap migration by default.
    
    Also add some code comments about these optimizations.

diff --git a/exa/exa_migration.c b/exa/exa_migration.c
index d69526b..d3646b0 100644
--- a/exa/exa_migration.c
+++ b/exa/exa_migration.c
@@ -153,22 +153,39 @@ exaCopyDirty(ExaMigrationPtr migrate, RegionPtr pValidDst, RegionPtr pValidSrc,
     REGION_SUBTRACT(pScreen, &CopyReg, pValidSrc, pValidDst);
 
     if (migrate->as_dst) {
-	RegionPtr pending_damage = DamagePendingRegion(pExaPixmap->pDamage);
+	ExaScreenPriv (pPixmap->drawable.pScreen);
 
-	if (REGION_NIL(pending_damage)) {
-	    static Bool firsttime = TRUE;
+	/* XXX: The pending damage region will be marked as damaged after the
+	 * operation, so it should serve as an upper bound for the region that
+	 * needs to be synchronized for the operation. Unfortunately, this
+	 * causes corruption in some cases, e.g. when starting compiz. See
+	 * https://bugs.freedesktop.org/show_bug.cgi?id=12916 .
+	 */
+	if (pExaScr->optimize_migration) {
+	    RegionPtr pending_damage = DamagePendingRegion(pExaPixmap->pDamage);
+
+	    if (REGION_NIL(pending_damage)) {
+		static Bool firsttime = TRUE;
 
-	    if (firsttime) {
-		ErrorF("%s: Pending damage region empty!\n", __func__);
-		firsttime = FALSE;
+		if (firsttime) {
+		    ErrorF("%s: Pending damage region empty!\n", __func__);
+		    firsttime = FALSE;
+		}
 	    }
-	}
 
-	REGION_INTERSECT(pScreen, &CopyReg, &CopyReg, pending_damage);
+	    REGION_INTERSECT(pScreen, &CopyReg, &CopyReg, pending_damage);
+	}
 
+	/* The caller may provide a region to be subtracted from the calculated
+	 * dirty region. This is to avoid migration of bits that don't
+	 * contribute to the result of the operation.
+	 */
 	if (migrate->pReg)
 	    REGION_SUBTRACT(pScreen, &CopyReg, &CopyReg, migrate->pReg);
     } else {
+	/* The caller may restrict the region to be migrated for source pixmaps
+	 * to what's relevant for the operation.
+	 */
 	if (migrate->pReg)
 	    REGION_INTERSECT(pScreen, &CopyReg, &CopyReg, migrate->pReg);
     }
diff --git a/exa/exa_priv.h b/exa/exa_priv.h
index a695363..7656a02 100644
--- a/exa/exa_priv.h
+++ b/exa/exa_priv.h
@@ -119,6 +119,7 @@ typedef struct {
     enum ExaMigrationHeuristic	 migration;
     Bool			 checkDirtyCorrectness;
     unsigned			 disableFbCount;
+    Bool			 optimize_migration;
 } ExaScreenPrivRec, *ExaScreenPrivPtr;
 
 /*
diff --git a/hw/xfree86/exa/exa.man.pre b/hw/xfree86/exa/exa.man.pre
index 31e1cfe..14859bc 100644
--- a/hw/xfree86/exa/exa.man.pre
+++ b/hw/xfree86/exa/exa.man.pre
@@ -31,6 +31,12 @@ Disables acceleration of downloading of pixmap data from the framebuffer.
 Not usable with drivers which rely on DownloadFromScreen succeeding.
 Default: No.
 .TP
+.BI "Option \*qEXAOptimizeMigration\*q \*q" boolean \*q
+Enables an additional optimization for migration of destination pixmaps. This
+may improve performance in some cases (e.g. when switching virtual desktops with
+no compositing manager) but causes corruption in others (e.g. when starting
+compiz). Default: No.
+.TP
 .BI "Option \*qMigrationHeuristic\*q \*q" anystr \*q
 Chooses an alternate pixmap migration heuristic, for debugging purposes.  The
 default is intended to be the best performing one for general use, though others
diff --git a/hw/xfree86/exa/examodule.c b/hw/xfree86/exa/examodule.c
index 4dce58f..ceead82 100644
--- a/hw/xfree86/exa/examodule.c
+++ b/hw/xfree86/exa/examodule.c
@@ -50,6 +50,7 @@ typedef enum {
     EXAOPT_NO_COMPOSITE,
     EXAOPT_NO_UTS,
     EXAOPT_NO_DFS,
+    EXAOPT_OPTIMIZE_MIGRATION
 } EXAOpts;
 
 static const OptionInfoRec EXAOptions[] = {
@@ -61,6 +62,8 @@ static const OptionInfoRec EXAOptions[] = {
 				OPTV_BOOLEAN,	{0}, FALSE },
     { EXAOPT_NO_DFS,			"EXANoDownloadFromScreen",
 				OPTV_BOOLEAN,	{0}, FALSE },
+    { EXAOPT_OPTIMIZE_MIGRATION,	"EXAOptimizeMigration",
+				OPTV_BOOLEAN,	{0}, FALSE },
     { -1,				NULL,
 				OPTV_NONE,	{0}, FALSE }
 };
@@ -144,6 +147,11 @@ exaDDXDriverInit(ScreenPtr pScreen)
 			    heuristicName);
 	    }
 	}
+
+	pExaScr->optimize_migration =
+	    xf86ReturnOptValBool(pScreenPriv->options,
+				 EXAOPT_OPTIMIZE_MIGRATION,
+				 FALSE);
     }
 
     if (xf86IsOptionSet(pScreenPriv->options, EXAOPT_NO_COMPOSITE)) {
commit 26e1fc7b42de850d69fba89703ffddd36480b997
Author: Dodji Seketeli <dodji at openedhand.com>
Date:   Wed Nov 7 18:48:23 2007 +0100

    Xephyr: don't use Xv or GL when those are disabled.

diff --git a/configure.ac b/configure.ac
index df70ae9..1b45801 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1855,10 +1855,13 @@ if test "$KDRIVE" = yes; then
     XEPHYR_DRI=no
     if test x$XEPHYR = xyes -a x$DRI = xyes; then
         XEPHYR_DRI=yes
+        XEPHYR_DRI_LIBS=-lGL
+        AC_SUBST(XEPHYR_DRI_LIBS)
     fi
     if test x$XEPHYR_DRI = xyes ; then
         AC_DEFINE(XEPHYR_DRI,1,[enable DRI extension in xephyr])
     fi
+    AM_CONDITIONAL(XEPHYR_HAS_DRI, [test x$XEPHYR_DRI = xyes])
 
     # Xephyr needs nanosleep() which is in librt on Solaris
     AC_CHECK_FUNC([nanosleep], [],
diff --git a/hw/kdrive/ephyr/Makefile.am b/hw/kdrive/ephyr/Makefile.am
index 604e22e..d025c20 100644
--- a/hw/kdrive/ephyr/Makefile.am
+++ b/hw/kdrive/ephyr/Makefile.am
@@ -3,47 +3,65 @@ INCLUDES = 					\
 	@KDRIVE_CFLAGS@				\
 	-I$(srcdir)/../../../exa
 
-noinst_LIBRARIES = libxephyr-hostx.a libxephyr-hostxv.a libxephyr.a
+if XV
+    LIBXEPHYR_HOSTXV=libxephyr-hostxv.a
+else
+    LIBXEPHYR_HOSTXV=
+endif
 
-bin_PROGRAMS = Xephyr
+if XEPHYR_HAS_DRI
+    LIBXEPHYR_HOSTDRI=libxephyr-hostdri.a
+else
+    LIBXEPHYR_HOSTDRI=
+endif
+
+noinst_LIBRARIES = libxephyr-hostx.a $(LIBXEPHYR_HOSTXV) $(LIBXEPHYR_HOSTDRI) libxephyr.a
 
+bin_PROGRAMS = Xephyr
 
 libxephyr_hostx_a_SOURCES =                             \
 	hostx.c                                         \
 	hostx.h
 
-libxephyr_hostx_a_INCLUDES = @XEPHYR_INCS@
+libxephyr_hostxv_a_INCLUDES = @XEPHYR_INCS@
 
+if XV
 libxephyr_hostxv_a_SOURCES=				\
 	ephyrhostvideo.c \
 	ephyrhostvideo.h
+endif
+
+if XEPHYR_HAS_DRI
+
+libxephyr_hostdri_a_SOURCES= \
+ephyrdriext.c	\
+ephyrdri.c	\
+ephyrdri.h	\
+XF86dri.c	\
+ephyrglxext.c	\
+ephyrglxext.h	\
+ephyrhostglx.c	\
+ephyrhostglx.h	
+
+libxephyr_hostdri_a_CFLAGS= \
+-I$(top_srcdir)		\
+ at LIBDRM_CFLAGS@ 	\
+ at DRIPROTO_CFLAGS@
+
+endif
 
 libxephyr_a_SOURCES =	\
 	ephyr.c		\
 	ephyr_draw.c	\
 	ephyrvideo.c	\
-	XF86dri.c	\
-	ephyrdriext.c	\
-	ephyrdri.c	\
-	ephyrdri.h	\
-	ephyrglxext.c	\
-	ephyrglxext.h	\
-	ephyrhostglx.c	\
-	ephyrhostglx.h	\
-	ephyrhostproxy.c \
-	ephyrhostproxy.h \
-	ephyrhostproxy.c \
-	ephyrproxyext.c	\
-	ephyrproxyext.h	\
 	os.c		\
 	hostx.h         \
 	ephyr.h		\
 	ephyrlog.h
 
 libxephyr_a_CFLAGS = \
- at LIBDRM_CFLAGS@ \
 -I$(top_srcdir) \
- at DRIPROTO_CFLAGS@
+ at LIBDRM_CFLAGS@
 
 Xephyr_SOURCES = \
 	ephyrinit.c
@@ -51,17 +69,19 @@ Xephyr_SOURCES = \
 Xephyr_LDADD = 						\
 	libxephyr.a					\
 	libxephyr-hostx.a			        \
-	libxephyr-hostxv.a			        \
+	$(LIBXEPHYR_HOSTXV)				\
+	$(LIBXEPHYR_HOSTDRI)				\
 	../../../exa/libexa.la				\
 	@KDRIVE_LIBS@					\
         @XEPHYR_LIBS@ 					\
 	@LIBDRM_LIBS@					\
-	-lGL
+	@XEPHYR_DRI_LIBS@
 
 Xephyr_DEPENDENCIES =	\
 	libxephyr.a					\
 	libxephyr-hostx.a			        \
-	libxephyr-hostxv.a			        \
+	$(LIBXEPHYR_HOSTXV)				\
+	$(LIBXEPHYR_HOSTDRI)				\
 	@KDRIVE_LOCAL_LIBS@
 
 relink:
diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index 52f5dcf..282b528 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -36,7 +36,6 @@
 #include "ephyrdri.h"
 #include "ephyrdriext.h"
 #include "ephyrglxext.h"
-#include "ephyrproxyext.h"
 #endif /*XEPHYR_DRI*/
 
 extern int KdTsPhyScreen;
@@ -640,7 +639,6 @@ ephyrInitScreen (ScreenPtr pScreen)
   if (!ephyrNoDRI) {
     ephyrDRIExtensionInit (pScreen) ;
     ephyrHijackGLXExtension () ;
-    ephyrProxyExtensionInit ("ATIFGLRXDRI") ;
   }
 #endif
 
commit 950f9995d11aff2c51139b34fb27eba594f2bd20
Author: Dodji Seketeli <dodji at openedhand.com>
Date:   Wed Nov 7 18:43:16 2007 +0100

    Xnest: fix lib dependancy to make libtool happy
    
            This fixes an undefined symbol error happening when compiling
            the server with the --disable-xv configure switch.
            Basically, xnest was linking against
            @XSERVER_LIBS@ and @XNEST_LIBS@ and the order of the libraries
            given to the linker at the end of the process was bogus.
    
            * configure.ac: make XNEST_LIBS contain the $XSERVER_LIBS re-ordered
              in such a way that the linker finds the symbols of all the libs contained
              in $XNEST_LIBS.
            * hw/xnest/Makefile.am: don't link against @XSERVER_LIBS@ anymore because
              XNEST_LIBS contains the right thing.

diff --git a/configure.ac b/configure.ac
index a09a5c2..df70ae9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1219,7 +1219,7 @@ AC_MSG_RESULT([$XNEST])
 AM_CONDITIONAL(XNEST, [test "x$XNEST" = xyes])
 
 if test "x$XNEST" = xyes; then
-	XNEST_LIBS="$CONFIG_LIB $FB_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 $CWRAP_LIB"
+	XNEST_LIBS="$FB_LIB $FIXES_LIB $MI_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 $CWRAP_LIB $DIX_LIB $OS_LIB $CONFIG_LIB"
 	XNEST_SYS_LIBS="$XNESTMODULES_LIBS"
 	AC_SUBST([XNEST_LIBS])
 	AC_SUBST([XNEST_SYS_LIBS])
diff --git a/hw/xnest/Makefile.am b/hw/xnest/Makefile.am
index 92f840c..8601b29 100644
--- a/hw/xnest/Makefile.am
+++ b/hw/xnest/Makefile.am
@@ -50,8 +50,7 @@ libfbcmap_a_CFLAGS = $(AM_CFLAGS)
 
 XNEST_LIBS = \
         @XNEST_LIBS@ \
-	libfbcmap.a \
-	$(XSERVER_LIBS)
+	libfbcmap.a
 
 Xnest_SOURCES = $(SRCS)
 
commit e717409bae355df9a617a226f12fbb8c54ae77e5
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Tue Nov 6 21:36:13 2007 +0000

    DIX/getevents: Document GetMaximumEventsNum() a little better
    
    Note that the number returned by GMEN can _never_ change, and be a little more
    explicit about the figure for repeats.

diff --git a/dix/getevents.c b/dix/getevents.c
index ffcdf17..3754c72 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -207,11 +207,13 @@ updateMotionHistory(DeviceIntPtr pDev, CARD32 ms, int first_valuator,
  *
  * Should be used in DIX as:
  * xEvent *events = xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+ *
+ * This MUST be absolutely constant, from init until exit.
  */
 _X_EXPORT int
 GetMaximumEventsNum(void) {
     /* Two base events -- core and device, plus valuator events.  Multiply
-     * by two if we're doing key repeats. */
+     * by two if we're doing non-XKB key repeats. */
     int ret = 2 + MAX_VALUATOR_EVENTS;
 
 #ifdef XKB
commit 66fe554a59bb7de37354b618945cd5f30d78250d
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Tue Nov 6 18:57:09 2007 +0000

    COPYING: Collapse 'canonical license' into one statement
    
    For a few of us, the license statement is identical, and the only variant is
    the copyright.  For these, aggregate the copyrights, and only list the license
    once.  Put this at the top, and note that this is more or less our agreed
    canonical license.

diff --git a/COPYING b/COPYING
index 097ef98..2b464e0 100644
--- a/COPYING
+++ b/COPYING
@@ -1,3 +1,45 @@
+The following is the 'standard copyright' agreed upon by most contributors,
+and is currently the canonical license, though a modification is currently
+under discussion.  Copyright holders of new code should use this license
+statement where possible, and append their name to this list.  Please sort
+by surname for people, and by the full name for other entities (e.g.
+Juliusz Chroboczek sorts before Intel Corporation sorts before Daniel
+Stone).
+
+Copyright © 2000-2001 Juliusz Chroboczek
+Copyright © 2006-2007 Intel Corporation
+Copyright © 2006 Nokia Corporation
+Copyright © 1999 Keith Packard
+Copyright © 2005-2007 Daniel Stone
+Copyright © 2006 Luc Verhaegen
+
+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 (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 NONINFRINGEMENT.  IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS 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.
+
+
+
+
+The following licenses are 'legacy': usually MIT/X11 licenses with the name
+of the copyright holder(s) in the license statement, but also some BSD-like
+licenses.
+
+
 Copyright (C) 1994-2003 The XFree86 Project, Inc.  All Rights Reserved.
 
 Permission is hereby granted, free of charge, to any person obtaining a copy of
@@ -1058,27 +1100,6 @@ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 PERFORMANCE OF THIS SOFTWARE.
 
 
-Copyright © 2003-2005 Keith Packard, Daniel Stone
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation, and that the names of Keith Packard and Daniel Stone not be
-used in advertising or publicity pertaining to distribution of the software
-without specific, written prior permission.  Keith Packard and Daniel Stone
-make no representations about the suitability of this software for any
-purpose.  It is provided "as is" without express or implied warranty.
-
-KEITH PACKARD AND DANIEL STONE DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
-IN NO EVENT SHALL KEITH PACKARD OR DANIEL STONE 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.
-
-
 Copyright © 1999 Keith Packard
 Copyright © 2000 Compaq Computer Corporation
 Copyright © 2002 MontaVista Software Inc.
@@ -2357,54 +2378,6 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 SOFTWARE.
 
 
-Copyright (c) 1999 by Keith Packard
-Copyright © 2006 Intel Corporation
-Copyright 2006 Luc Verhaegen.
-
-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 (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 NONINFRINGEMENT.  IN NO EVENT SHALL
-THE AUTHORS OR COPYRIGHT HOLDERS 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.
-
-
-Copyright (c) 2000-2001 by Juliusz Chroboczek
-Copyright (c) 1999 by Keith Packard
-
-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 AUTHORS OR COPYRIGHT HOLDERS
-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.
-
-
 Copyright 1990, 1991 by Thomas Roell, Dinkelscherben, Germany
 Copyright 1992 by David Dawes <dawes at XFree86.org>
 Copyright 1992 by Jim Tsillas <jtsilla at damon.ccs.northeastern.edu>
@@ -2622,92 +2595,3 @@ FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
 THE AUTHORS 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.
-
-
-Copyright © 2006 Daniel Stone
-
-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 (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 NONINFRINGEMENT.  IN NO EVENT SHALL
-THE AUTHORS OR COPYRIGHT HOLDERS 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.
-
-
-Copyright © 2006-2007 Daniel Stone
-
-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 (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 NONINFRINGEMENT.  IN NO EVENT SHALL
-THE AUTHORS OR COPYRIGHT HOLDERS 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.
-
-
-Copyright © 2007 Daniel Stone
-
-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 (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 NONINFRINGEMENT.  IN NO EVENT SHALL
-THE AUTHORS OR COPYRIGHT HOLDERS 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.
-
-
-Copyright © 1999 Keith Packard
-Copyright © 2006 Nokia Corporation
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation, and that the name of the authors not be used in
-advertising or publicity pertaining to distribution of the software without
-specific, written prior permission.  The authors make no
-representations about the suitability of this software for any purpose.  It
-is provided "as is" without express or implied warranty.
-
-THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
-INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
-EVENT SHALL THE AUTHORS 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.
-
commit fda832772b3e630037bf1b822534996154a50861
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.

diff --git a/.gitignore b/.gitignore
index 27132c0..6abca3b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,6 +8,9 @@ Makefile.in
 *.a
 *.o
 *~
+.*.swp
+obj*
+build*
 aclocal.m4
 autom4te.cache
 compile
@@ -298,4 +301,3 @@ mfb/mfbteblack.c
 mfb/mfbtewhite.c
 mfb/mfbtileC.c
 mfb/mfbtileG.c
-.*.swp
commit 512bac25ec0e980968b93a2ebe88bd89bf99b697
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.

diff --git a/dix/devices.c b/dix/devices.c
index 9798b97..3855c2b 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 d7c5e8bfc1aecbd23a4cbb2eab08656587aac2e8
Author: Eamon Walsh <ewalsh at tycho.nsa.gov>
Date:   Tue Nov 6 16:26:09 2007 -0500

    Modified performance patches from Arjan van de Ven <arjan at infradead.org>
    
    Subject: [PATCH] fix some performance gaps in Xace
    
    The XaceHook function is used in several hotpaths.
    The problem with it (performance wise) is twofold:
     * The XaceHook function has a big switch() statement for the hook number in it
     * The XaceHook function uses varargs to reassemble the final dispatch arguments again
    
    Both are expensive operations... for something that is known at compile time
    
    This patch turns the hotpath XaceHook call into a direct call to avoid
    the switch and varargs; this gives me over 10% performance gain
    on the x11perf benchmark.

diff --git a/Xext/xace.c b/Xext/xace.c
index 00c3b8f..b4e0eee 100644
--- a/Xext/xace.c
+++ b/Xext/xace.c
@@ -44,6 +44,22 @@ static int (*SwappedUntrustedProcVector[256])(
     ClientPtr /*client*/
 );
 
+/* Special-cased hook functions.  Called by Xserver.
+ */
+void XaceHookAuditBegin(ClientPtr ptr)
+{
+    XaceAuditRec rec = { ptr, 0 };
+    /* call callbacks, there is no return value. */
+    CallCallbacks(&XaceHooks[XACE_AUDIT_BEGIN], &rec);
+}
+
+void XaceHookAuditEnd(ClientPtr ptr, int result)
+{
+    XaceAuditRec rec = { ptr, result };
+    /* call callbacks, there is no return value. */
+    CallCallbacks(&XaceHooks[XACE_AUDIT_END], &rec);
+}
+
 /* Entry point for hook functions.  Called by Xserver.
  */
 int XaceHook(int hook, ...)
@@ -60,15 +76,6 @@ int XaceHook(int hook, ...)
      */
     switch (hook)
     {
-	case XACE_CORE_DISPATCH: {
-	    XaceCoreDispatchRec rec = {
-		va_arg(ap, ClientPtr),
-		TRUE	/* default allow */
-	    };
-	    calldata = &rec;
-	    prv = &rec.rval;
-	    break;
-	}
 	case XACE_RESOURCE_ACCESS: {
 	    XaceResourceAccessRec rec = {
 		va_arg(ap, ClientPtr),
@@ -190,22 +197,6 @@ int XaceHook(int hook, ...)
 	    calldata = &rec;
 	    break;
 	}
-	case XACE_AUDIT_BEGIN: {
-	    XaceAuditRec rec = {
-		va_arg(ap, ClientPtr),
-		0
-	    };
-	    calldata = &rec;
-	    break;
-	}
-	case XACE_AUDIT_END: {
-	    XaceAuditRec rec = {
-		va_arg(ap, ClientPtr),
-		va_arg(ap, int)
-	    };
-	    calldata = &rec;
-	    break;
-	}
 	default: {
 	    va_end(ap);
 	    return 0;	/* unimplemented hook number */
@@ -271,11 +262,15 @@ XaceCatchDispatchProc(ClientPtr client)
 {
     REQUEST(xReq);
     int major = stuff->reqType;
+    XaceCoreDispatchRec rec = { client, TRUE /* default allow */ };
 
     if (!ProcVector[major])
 	return (BadRequest);
 
-    if (!XaceHook(XACE_CORE_DISPATCH, client))
+    /* call callbacks and return result, if any. */
+    CallCallbacks(&XaceHooks[XACE_CORE_DISPATCH], &rec);
+
+    if (!rec.rval)
 	return (BadAccess);
 
     return client->swapped ? 
diff --git a/Xext/xace.h b/Xext/xace.h
index 4143cd4..273635c 100644
--- a/Xext/xace.h
+++ b/Xext/xace.h
@@ -68,6 +68,11 @@ extern int XaceHook(
     ... /*appropriate args for hook*/
     ); 
 
+/* Special-cased hook functions
+ */
+extern void XaceHookAuditEnd(ClientPtr ptr, int result);
+extern void XaceHookAuditBegin(ClientPtr ptr);
+
 /* Register a callback for a given hook.
  */
 #define XaceRegisterCallback(hook,callback,data) \
@@ -98,9 +103,13 @@ extern void XaceCensorImage(
 
 #ifdef __GNUC__
 #define XaceHook(args...) XaceAllowOperation
+#define XaceHookAuditEnd(args...) { ; }
+#define XaceHookAuditBegin(args...) { ; }
 #define XaceCensorImage(args...) { ; }
 #else
 #define XaceHook(...) XaceAllowOperation
+#define XaceHookAuditEnd(...) { ; }
+#define XaceHookAuditBegin(...) { ; }
 #define XaceCensorImage(...) { ; }
 #endif
 
diff --git a/dix/dispatch.c b/dix/dispatch.c
index 5c4f8e4..8c76eb1 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -498,9 +498,9 @@ Dispatch(void)
 		if (result > (maxBigRequestSize << 2))
 		    result = BadLength;
 		else {
-		    XaceHook(XACE_AUDIT_BEGIN, client);
+		    XaceHookAuditBegin(client);
 		    result = (* client->requestVector[MAJOROP])(client);
-		    XaceHook(XACE_AUDIT_END, client, result);
+		    XaceHookAuditEnd(client, result);
 		}
 #ifdef XSERVER_DTRACE
 		XSERVER_REQUEST_DONE(GetRequestName(MAJOROP), MAJOROP,
commit aaa50b64113b122aaebd46e3b78e3fb7a8d70500
Merge: 868e303... ddce48e...
Author: Dodji Seketeli <dodji at openedhand.com>
Date:   Tue Nov 6 16:25:40 2007 +0100

    resync with 'master'

commit 868e303630d8b84070c2f1fd8d6da2cef045b029
Author: Dodji Seketeli <dodji at openedhand.com>
Date:   Tue Nov 6 16:24:46 2007 +0100

    Xephyr: fix a crash when using xrandr twice
    
            * hw/kdrive/ephyr/ephyr.c:
              (ephyrScreenFini): don't forget to
              free shadowfb data (if necessary) upon server is reset.

diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index f46a89d..52f5dcf 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -719,6 +719,10 @@ ephyrRestore (KdCardInfo *card)
 void
 ephyrScreenFini (KdScreenInfo *screen)
 {
+    EphyrScrPriv  *scrpriv = screen->driver;
+    if (scrpriv->shadow) {
+        KdShadowFbFree (screen, 0);
+    }
     xfree(screen->driver);
     screen->driver = NULL;
 }
commit ddce48ede036f3996f8e584b0012c396c5df42fb
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.

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 58332894c061ae96d6a457f65266660f5f65e88b
Author: Adam Jackson <ajax at redhat.com>
Date:   Mon Nov 5 17:17:25 2007 -0500

    Export the server ABI versions from xorg-server.pc

diff --git a/configure.ac b/configure.ac
index 10f580f..a09a5c2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1536,6 +1536,17 @@ dnl has it in libc), or if libdl is needed to get it.
 	AC_SUBST([sdkdir])
 	AC_SUBST([extdir])
 	AC_SUBST([logdir])
+
+	# stuff the ABI versions into the pc file too
+	extract_abi() {
+	    grep ^.define.*${1}_VERSION ${srcdir}/hw/xfree86/common/xf86Module.h | tr '(),' '  .' | awk '{ print $4$5 }'
+	}
+	abi_ansic=`extract_abi ANSIC`
+	abi_videodrv=`extract_abi VIDEODRV`
+	abi_xinput=`extract_abi XINPUT`
+	abi_extension=`extract_abi EXTENSION`
+	abi_font=`extract_abi FONT`
+	AC_SUBST([abi_ansic abi_videodrv abi_xinput abi_extension abi_font])
 fi
 AM_CONDITIONAL([XORG], [test "x$XORG" = xyes])
 AM_CONDITIONAL([XORG_BUS_LINUXPCI], [test "x$xorg_bus_linuxpci" = xyes])
diff --git a/xorg-server.pc.in b/xorg-server.pc.in
index c1cdb7d..53b4ed2 100644
--- a/xorg-server.pc.in
+++ b/xorg-server.pc.in
@@ -5,6 +5,12 @@ includedir=@includedir@
 moduledir=@moduledir@
 sdkdir=@sdkdir@
 
+abi_ansic=@abi_ansic@
+abi_videodrv=@abi_videodrv@
+abi_xinput=@abi_xinput@
+abi_extension=@abi_extension@
+abi_font=@abi_font@
+
 Name: xorg-server
 Description: Modular X.Org X Server
 Version: @PACKAGE_VERSION@


More information about the xorg-commit mailing list