[Xquartz-changes] xserver: Branch 'server-1.13-apple' - 48 commits

Jeremy Huddleston jeremyhu at freedesktop.org
Wed Aug 15 10:21:14 PDT 2012


Rebased ref, commits from common ancestor:
commit b5249c4c4a1f64b67c11c2b3594ba1de92f2e64f
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Fri Feb 12 19:48:52 2010 -0800

    fb: Revert fb changes that broke XQuartz
    
    http://bugs.freedesktop.org/show_bug.cgi?id=26124
    
    Revert "Fix source pictures getting random transforms after 2d6a8f668342a5190cdf43b5."
    Revert "fb: Adjust transform or composite coordinates for pixman operations"
    
    http://bugs.freedesktop.org/26124
    
    This reverts commit a72c65e9176c51de95db2fdbf4c5d946a4911695.
    This reverts commit a6bd5d2e482a5aa84acb3d4932e2a166d8670ef1.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/fb/fb.h b/fb/fb.h
index 40a7e38..52d0b0a 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -1684,8 +1684,7 @@ fbFillRegionSolid(DrawablePtr pDrawable,
                   RegionPtr pRegion, FbBits and, FbBits xor);
 
 extern _X_EXPORT pixman_image_t *image_from_pict(PicturePtr pict,
-                                                 Bool has_clip,
-                                                 int *xoff, int *yoff);
+                                                 Bool has_clip);
 
 extern _X_EXPORT void free_pixman_pict(PicturePtr, pixman_image_t *);
 
diff --git a/fb/fbpict.c b/fb/fbpict.c
index 097a1a6..dc0ca3c 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -46,23 +46,18 @@ fbComposite(CARD8 op,
             INT16 yMask, INT16 xDst, INT16 yDst, CARD16 width, CARD16 height)
 {
     pixman_image_t *src, *mask, *dest;
-    int src_xoff, src_yoff;
-    int msk_xoff, msk_yoff;
-    int dst_xoff, dst_yoff;
-
     miCompositeSourceValidate(pSrc);
     if (pMask)
         miCompositeSourceValidate(pMask);
 
-    src = image_from_pict(pSrc, FALSE, &src_xoff, &src_yoff);
-    mask = image_from_pict(pMask, FALSE, &msk_xoff, &msk_yoff);
-    dest = image_from_pict(pDst, TRUE, &dst_xoff, &dst_yoff);
+    src = image_from_pict(pSrc, TRUE);
+    mask = image_from_pict(pMask, TRUE);
+    dest = image_from_pict(pDst, TRUE);
 
     if (src && dest && !(pMask && !mask)) {
         pixman_image_composite(op, src, mask, dest,
-                               xSrc + src_xoff, ySrc + src_yoff,
-                               xMask + msk_xoff, yMask + msk_yoff,
-                               xDst + dst_xoff, yDst + dst_yoff, width, height);
+                               xSrc, ySrc, xMask, yMask, xDst, yDst,
+                               width, height);
     }
 
     free_pixman_pict(pSrc, src);
@@ -143,20 +138,22 @@ create_conical_gradient_image(PictGradient * gradient)
 }
 
 static pixman_image_t *
-create_bits_picture(PicturePtr pict, Bool has_clip, int *xoff, int *yoff)
+create_bits_picture(PicturePtr pict, Bool has_clip)
 {
-    PixmapPtr pixmap;
     FbBits *bits;
     FbStride stride;
-    int bpp;
+    int bpp, xoff, yoff;
     pixman_image_t *image;
 
-    fbGetDrawablePixmap(pict->pDrawable, pixmap, *xoff, *yoff);
-    fbGetPixmapBitsData(pixmap, bits, stride, bpp);
+    fbGetDrawable (pict->pDrawable, bits, stride, bpp, xoff, yoff);
+
+    bits = (FbBits*)((CARD8*)bits +
+                     (pict->pDrawable->y + yoff) * stride * sizeof(FbBits) +
+                     (pict->pDrawable->x + xoff) * (bpp / 8));
 
     image = pixman_image_create_bits((pixman_format_code_t) pict->format,
-                                     pixmap->drawable.width,
-                                     pixmap->drawable.height, (uint32_t *) bits,
+                                     pict->pDrawable->width,
+                                     pict->pDrawable->height, (uint32_t *) bits,
                                      stride * sizeof(FbStride));
 
     if (!image)
@@ -183,57 +180,31 @@ create_bits_picture(PicturePtr pict, Bool has_clip, int *xoff, int *yoff)
         if (pict->clientClipType != CT_NONE)
             pixman_image_set_has_client_clip(image, TRUE);
 
-        if (*xoff || *yoff)
-            pixman_region_translate(pict->pCompositeClip, *xoff, *yoff);
+        pixman_region_translate (pict->pCompositeClip, - pict->pDrawable->x, - pict->pDrawable->y);
 
         pixman_image_set_clip_region(image, pict->pCompositeClip);
 
-        if (*xoff || *yoff)
-            pixman_region_translate(pict->pCompositeClip, -*xoff, -*yoff);
+        pixman_region_translate (pict->pCompositeClip, pict->pDrawable->x, pict->pDrawable->y);
     }
 
     /* Indexed table */
     if (pict->pFormat->index.devPrivate)
         pixman_image_set_indexed(image, pict->pFormat->index.devPrivate);
 
-    /* Add in drawable origin to position within the image */
-    *xoff += pict->pDrawable->x;
-    *yoff += pict->pDrawable->y;
-
     return image;
 }
 
 static pixman_image_t *image_from_pict_internal(PicturePtr pict, Bool has_clip,
-                                                int *xoff, int *yoff,
                                                 Bool is_alpha_map);
 
 static void
-set_image_properties(pixman_image_t * image, PicturePtr pict, Bool has_clip,
-                     int *xoff, int *yoff, Bool is_alpha_map)
+set_image_properties(pixman_image_t * image, PicturePtr pict, Bool is_alpha_map)
 {
     pixman_repeat_t repeat;
     pixman_filter_t filter;
 
     if (pict->transform) {
-        /* For source images, adjust the transform to account
-         * for the drawable offset within the pixman image,
-         * then set the offset to 0 as it will be used
-         * to compute positions within the transformed image.
-         */
-        if (!has_clip) {
-            struct pixman_transform adjusted;
-
-            adjusted = *pict->transform;
-            pixman_transform_translate(&adjusted,
-                                       NULL,
-                                       pixman_int_to_fixed(*xoff),
-                                       pixman_int_to_fixed(*yoff));
-            pixman_image_set_transform(image, &adjusted);
-            *xoff = 0;
-            *yoff = 0;
-        }
-        else
-            pixman_image_set_transform(image, pict->transform);
+        pixman_image_set_transform(image, pict->transform);
     }
 
     switch (pict->repeatType) {
@@ -261,10 +232,8 @@ set_image_properties(pixman_image_t * image, PicturePtr pict, Bool has_clip,
      * as the alpha map for this operation
      */
     if (pict->alphaMap && !is_alpha_map) {
-        int alpha_xoff, alpha_yoff;
         pixman_image_t *alpha_map =
-            image_from_pict_internal(pict->alphaMap, FALSE, &alpha_xoff,
-                                     &alpha_yoff, TRUE);
+            image_from_pict_internal(pict->alphaMap, TRUE, TRUE);
 
         pixman_image_set_alpha_map(image, alpha_map, pict->alphaOrigin.x,
                                    pict->alphaOrigin.y);
@@ -298,8 +267,7 @@ set_image_properties(pixman_image_t * image, PicturePtr pict, Bool has_clip,
 }
 
 static pixman_image_t *
-image_from_pict_internal(PicturePtr pict, Bool has_clip, int *xoff, int *yoff,
-                         Bool is_alpha_map)
+image_from_pict_internal(PicturePtr pict, Bool has_clip, Bool is_alpha_map)
 {
     pixman_image_t *image = NULL;
 
@@ -307,7 +275,7 @@ image_from_pict_internal(PicturePtr pict, Bool has_clip, int *xoff, int *yoff,
         return NULL;
 
     if (pict->pDrawable) {
-        image = create_bits_picture(pict, has_clip, xoff, yoff);
+        image = create_bits_picture(pict, has_clip);
     }
     else if (pict->pSourcePict) {
         SourcePict *sp = pict->pSourcePict;
@@ -325,19 +293,17 @@ image_from_pict_internal(PicturePtr pict, Bool has_clip, int *xoff, int *yoff,
             else if (sp->type == SourcePictTypeConical)
                 image = create_conical_gradient_image(gradient);
         }
-        *xoff = *yoff = 0;
     }
 
     if (image)
-        set_image_properties(image, pict, has_clip, xoff, yoff, is_alpha_map);
-
+        set_image_properties (image, pict, is_alpha_map);
     return image;
 }
 
 pixman_image_t *
-image_from_pict(PicturePtr pict, Bool has_clip, int *xoff, int *yoff)
+image_from_pict (PicturePtr pict, Bool has_clip)
 {
-    return image_from_pict_internal(pict, has_clip, xoff, yoff, FALSE);
+    return image_from_pict_internal (pict, has_clip, FALSE);
 }
 
 void
diff --git a/fb/fbtrap.c b/fb/fbtrap.c
index bf82f8f..0145ce9 100644
--- a/fb/fbtrap.c
+++ b/fb/fbtrap.c
@@ -36,13 +36,12 @@ fbAddTraps(PicturePtr pPicture,
            INT16 x_off, INT16 y_off, int ntrap, xTrap * traps)
 {
     pixman_image_t *image;
-    int dst_xoff, dst_yoff;
 
-    if (!(image = image_from_pict(pPicture, FALSE, &dst_xoff, &dst_yoff)))
-        return;
-
-    pixman_add_traps(image, x_off + dst_xoff, y_off + dst_yoff,
-                     ntrap, (pixman_trap_t *) traps);
+    if (!(image = image_from_pict (pPicture, FALSE)))
+	return;
+    
+    pixman_add_traps(image, x_off, y_off,
+                     ntrap, (pixman_trap_t *)traps);
 
     free_pixman_pict(pPicture, image);
 }
@@ -52,13 +51,12 @@ fbRasterizeTrapezoid(PicturePtr pPicture,
                      xTrapezoid * trap, int x_off, int y_off)
 {
     pixman_image_t *image;
-    int dst_xoff, dst_yoff;
 
-    if (!(image = image_from_pict(pPicture, FALSE, &dst_xoff, &dst_yoff)))
+    if (!(image = image_from_pict (pPicture, FALSE)))
         return;
 
-    pixman_rasterize_trapezoid(image, (pixman_trapezoid_t *) trap,
-                               x_off + dst_xoff, y_off + dst_yoff);
+    pixman_rasterize_trapezoid(image, (pixman_trapezoid_t *)trap,
+                               x_off, y_off);
 
     free_pixman_pict(pPicture, image);
 }
@@ -68,14 +66,12 @@ fbAddTriangles(PicturePtr pPicture,
                INT16 x_off, INT16 y_off, int ntri, xTriangle * tris)
 {
     pixman_image_t *image;
-    int dst_xoff, dst_yoff;
 
-    if (!(image = image_from_pict(pPicture, FALSE, &dst_xoff, &dst_yoff)))
+    if (!(image = image_from_pict (pPicture, FALSE)))
         return;
-
-    pixman_add_triangles(image,
-                         dst_xoff + x_off, dst_yoff + y_off,
-                         ntri, (pixman_triangle_t *) tris);
+    
+    pixman_add_triangles(image, x_off, y_off, ntri,
+                         (pixman_triangle_t *)tris);
 
     free_pixman_pict(pPicture, image);
 }
@@ -98,13 +94,11 @@ fbShapes(CompositeShapesFunc composite,
          int16_t ySrc, int nshapes, int shape_size, const uint8_t * shapes)
 {
     pixman_image_t *src, *dst;
-    int src_xoff, src_yoff;
-    int dst_xoff, dst_yoff;
 
     miCompositeSourceValidate(pSrc);
 
-    src = image_from_pict(pSrc, FALSE, &src_xoff, &src_yoff);
-    dst = image_from_pict(pDst, TRUE, &dst_xoff, &dst_yoff);
+    src = image_from_pict(pSrc, FALSE);
+    dst = image_from_pict(pDst, TRUE);
 
     if (src && dst) {
         pixman_format_code_t format;
@@ -121,9 +115,8 @@ fbShapes(CompositeShapesFunc composite,
 
             for (i = 0; i < nshapes; ++i) {
                 composite(op, src, dst, format,
-                          xSrc + src_xoff,
-                          ySrc + src_yoff,
-                          dst_xoff, dst_yoff, 1, shapes + i * shape_size);
+                          xSrc, ySrc, 0, 0, 
+                          1, shapes + i * shape_size);
             }
         }
         else {
@@ -143,8 +136,8 @@ fbShapes(CompositeShapesFunc composite,
             }
 
             composite(op, src, dst, format,
-                      xSrc + src_xoff,
-                      ySrc + src_yoff, dst_xoff, dst_yoff, nshapes, shapes);
+                      xSrc, ySrc, 0, 0,
+                      nshapes, shapes);
         }
 
         DamageRegionProcessPending(pDst->pDrawable);
commit 5330dc8bd2c717e0f3dd67b5d92d6237d468c729
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Fri Apr 30 13:08:25 2010 -0700

    Workaround the GC clipping problem in miPaintWindow and add some debugging output.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/mi/miexpose.c b/mi/miexpose.c
index 8b7c93f..3e972f7 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -489,7 +489,8 @@ void RootlessSetPixmapOfAncestors(WindowPtr pWin);
 void RootlessStartDrawing(WindowPtr pWin);
 void RootlessDamageRegion(WindowPtr pWin, RegionPtr prgn);
 Bool IsFramedWindow(WindowPtr pWin);
-#endif
+#include "../fb/fb.h"
+#endif 
 
 void
 miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
@@ -518,23 +519,37 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
     Bool solid = TRUE;
     DrawablePtr drawable = &pWin->drawable;
 
+#ifdef XQUARTZ_CLIP_DEBUG
+    ErrorF("START %d BS %d (pR = %ld)\n", what, pWin->backgroundState, ParentRelative);
+    ErrorF("      Rgn: %d %d %d %d\n", prgn->extents.x1, prgn->extents.y1,
+	                               prgn->extents.x2 - prgn->extents.x1,
+	                               prgn->extents.y2 - prgn->extents.y1);
+    ErrorF("      Win: %d %d (%d %d) %d %d\n", pWin->origin.x, pWin->origin.y,
+	                                       pWin->winSize.extents.x1, pWin->winSize.extents.y1,
+	                                       pWin->winSize.extents.x2 - pWin->winSize.extents.x1,
+					       pWin->winSize.extents.y2 - pWin->winSize.extents.y1);
+    ErrorF("     Draw: %d %d %d %d\n", pWin->drawable.x, pWin->drawable.y,
+				       pWin->drawable.width, pWin->drawable.height);
+#endif
+
 #ifdef ROOTLESS
     if (!drawable || drawable->type == UNDRAWABLE_WINDOW)
         return;
+#endif
+    
+    if (what == PW_BACKGROUND)
+    {
+#ifdef ROOTLESS
+        if(IsFramedWindow(pWin)) {
+            RootlessStartDrawing(pWin);
+            RootlessDamageRegion(pWin, prgn);
 
-    if (IsFramedWindow(pWin)) {
-        RootlessStartDrawing(pWin);
-        RootlessDamageRegion(pWin, prgn);
-
-        if (pWin->backgroundState == ParentRelative) {
-            if ((what == PW_BACKGROUND) ||
-                (what == PW_BORDER && !pWin->borderIsPixel))
+            if(pWin->backgroundState == ParentRelative) {
                 RootlessSetPixmapOfAncestors(pWin);
+            }
         }
-    }
 #endif
 
-    if (what == PW_BACKGROUND) {
         while (pWin->backgroundState == ParentRelative)
             pWin = pWin->parent;
 
@@ -559,6 +574,18 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
     else {
         PixmapPtr pixmap;
 
+#ifdef ROOTLESS
+	if(IsFramedWindow(pWin)) {
+	    RootlessStartDrawing(pWin);
+	    RootlessDamageRegion(pWin, prgn);
+	    
+	    if(!pWin->borderIsPixel &&
+		pWin->backgroundState == ParentRelative) {
+		RootlessSetPixmapOfAncestors(pWin);
+	    }
+	}
+#endif
+
         tile_x_off = drawable->x;
         tile_y_off = drawable->y;
 
@@ -567,6 +594,12 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
             return;
         pixmap = (*pScreen->GetWindowPixmap) ((WindowPtr) drawable);
         drawable = &pixmap->drawable;
+
+#ifdef XQUARTZ_CLIP_DEBUG
+        ErrorF("     Draw: %d %d %d %d\n",
+               drawable->x, drawable->y, drawable->width, drawable->height);    
+#endif
+	
 #ifdef COMPOSITE
         draw_x_off = pixmap->screen_x;
         draw_y_off = pixmap->screen_y;
@@ -629,6 +662,57 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
     ChangeGC(NullClient, pGC, gcmask, gcval);
     ValidateGC(drawable, pGC);
 
+#ifdef XQUARTZ_CLIP_DEBUG
+    ErrorF("       GC: %d %d %d %d\n",
+	   pGC->pCompositeClip->extents.x1, pGC->pCompositeClip->extents.y1,
+	   pGC->pCompositeClip->extents.x2 - pGC->pCompositeClip->extents.x1,
+	   pGC->pCompositeClip->extents.y2 - pGC->pCompositeClip->extents.y1);
+#endif
+    
+#ifdef XQUARTZ
+    /* Looks like our clipping isn't set right for some reason:
+     * http://xquartz.macosforge.org/trac/ticket/290
+     */
+    if(what == PW_BORDER) {
+
+#if 0
+	if(solid) {
+#if 1
+	    fbFillRegionSolid(&pWin->drawable,
+			      prgn,
+			      0,
+			      fbReplicatePixel(fill.pixel,
+					       pWin->drawable.bitsPerPixel));
+#else
+	    fbFillRegionSolid(drawable,
+			      prgn,
+			      0,
+			      fbReplicatePixel(fill.pixel,
+					       drawable->bitsPerPixel));
+#endif
+	    return;
+	}
+#endif
+    
+	pGC->pCompositeClip->extents.x1 += prgn->extents.x1;
+	pGC->pCompositeClip->extents.y1 += prgn->extents.y1;
+	pGC->pCompositeClip->extents.x2 += prgn->extents.x1;
+	pGC->pCompositeClip->extents.y2 += prgn->extents.y1;
+	
+	if(pGC->pCompositeClip->extents.x2 > drawable->pScreen->width)
+	    pGC->pCompositeClip->extents.x2 = drawable->pScreen->width;
+	if(pGC->pCompositeClip->extents.y2 > drawable->pScreen->height)
+	    pGC->pCompositeClip->extents.y2 = drawable->pScreen->height;
+    }
+#endif
+
+#ifdef XQUARTZ_CLIP_DEBUG
+    ErrorF("       GC: %d %d %d %d\n",
+	   pGC->pCompositeClip->extents.x1, pGC->pCompositeClip->extents.y1,
+	   pGC->pCompositeClip->extents.x2 - pGC->pCompositeClip->extents.x1,
+	   pGC->pCompositeClip->extents.y2 - pGC->pCompositeClip->extents.y1);    
+#endif
+
     numRects = RegionNumRects(prgn);
     pbox = RegionRects(prgn);
     for (i = numRects; --i >= 0; pbox++, prect++) {
commit 3386da6417cba4ec06277846bf973583816ba7cc
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Fri Jan 13 12:00:57 2012 -0800

    sdksyms.sh: Use CPPFLAGS, not CFLAGS
    
    CFLAGS can include flags which are not useful to the preprocessor
    or can even cause it to fail.  This fixes a build issue on darwin
    when building for more than one architecture.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/Makefile.am b/hw/xfree86/Makefile.am
index c3899b5..4f48b85 100644
--- a/hw/xfree86/Makefile.am
+++ b/hw/xfree86/Makefile.am
@@ -38,7 +38,7 @@ DIST_SUBDIRS = common ddc i2c x86emu int10 fbdevhw os-support \
 bin_PROGRAMS = Xorg
 nodist_Xorg_SOURCES = sdksyms.c
 
-AM_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@
+AM_CPPFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@
 INCLUDES = $(XORG_INCS) -I$(srcdir)/parser -I$(top_srcdir)/miext/cw \
 	-I$(srcdir)/ddc -I$(srcdir)/i2c -I$(srcdir)/modes -I$(srcdir)/ramdac \
 	-I$(srcdir)/dri -I$(srcdir)/dri2
@@ -115,7 +115,7 @@ CLEANFILES = sdksyms.c sdksyms.dep
 EXTRA_DIST += sdksyms.sh
 
 sdksyms.dep sdksyms.c: sdksyms.sh
-	$(AM_V_GEN)CPP='$(CPP)' AWK='$(AWK)' $(SHELL) $(srcdir)/sdksyms.sh $(top_srcdir) $(CFLAGS) $(AM_CFLAGS) $(INCLUDES)
+	$(AM_V_GEN)CPP='$(CPP)' AWK='$(AWK)' $(SHELL) $(srcdir)/sdksyms.sh $(top_srcdir) $(CPPFLAGS) $(AM_CPPFLAGS) $(INCLUDES)
 
 SDKSYMS_DEP = sdksyms.dep
 include $(SDKSYMS_DEP)
commit c0540b4c8db676d18a9a09828f1590b0b16f9ebc
Author: Keith Packard <keithp at keithp.com>
Date:   Tue Aug 7 17:49:48 2012 -0700

    Kludge -- Call RandR screen before cleaning up xf86 crtcs
    
    The core RandR screen cleanup now involves cleaning up any GPU screen
    associations, and those call down into DDX to clean up the driver. If
    the pointers from the xf86 structures back to the core randr
    structures are set to NULL at that point, bad things happen.
    
    This patch "knows" that the core RandR close screen is underneath the
    xf86 randr close screen function, and so makes sure it gets called
    first.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Dave Airlie <airlied at redhat.com>

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 154f684..1947c5b 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -726,6 +726,12 @@ xf86CrtcCloseScreen(ScreenPtr screen)
 
     xf86RotateCloseScreen(screen);
 
+    xf86RandR12CloseScreen(screen);
+
+    free(config->name);
+
+    screen->CloseScreen(screen);
+
     for (o = 0; o < config->num_output; o++) {
         xf86OutputPtr output = config->output[o];
 
@@ -749,10 +755,7 @@ xf86CrtcCloseScreen(ScreenPtr screen)
         else if (screen->current_master)
             DetachUnboundGPU(screen);
     }
-    xf86RandR12CloseScreen(screen);
-
-    free(config->name);
-    return screen->CloseScreen(screen);
+    return TRUE;
 }
 
 /*
commit 288b87e42cbb5db34cda848143655e84af8455da
Author: Keith Packard <keithp at keithp.com>
Date:   Tue Aug 7 17:49:47 2012 -0700

    Close GPU screens before core screens
    
    This should make cleaning up the GPU screens easier as the core
    screens they are associated with will still be around.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Dave Airlie <airlied at redhat.com>

diff --git a/dix/main.c b/dix/main.c
index 42f517d..fb935c9 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -331,6 +331,15 @@ main(int argc, char *argv[], char *envp[])
 
         CloseDownEvents();
 
+        for (i = screenInfo.numGPUScreens - 1; i >= 0; i--) {
+            ScreenPtr pScreen = screenInfo.gpuscreens[i];
+            FreeScratchPixmapsForScreen(pScreen);
+            (*pScreen->CloseScreen) (pScreen);
+            dixFreePrivates(pScreen->devPrivates, PRIVATE_SCREEN);
+            free(pScreen);
+            screenInfo.numGPUScreens = i;
+        }
+
         for (i = screenInfo.numScreens - 1; i >= 0; i--) {
             FreeScratchPixmapsForScreen(screenInfo.screens[i]);
             FreeGCperDepth(i);
@@ -342,15 +351,6 @@ main(int argc, char *argv[], char *envp[])
             screenInfo.numScreens = i;
         }
 
-        for (i = screenInfo.numGPUScreens - 1; i >= 0; i--) {
-            ScreenPtr pScreen = screenInfo.gpuscreens[i];
-            FreeScratchPixmapsForScreen(pScreen);
-            (*pScreen->CloseScreen) (pScreen);
-            dixFreePrivates(pScreen->devPrivates, PRIVATE_SCREEN);
-            free(pScreen);
-            screenInfo.numGPUScreens = i;
-        }
-
         ReleaseClientIds(serverClient);
         dixFreePrivates(serverClient->devPrivates, PRIVATE_CLIENT);
         serverClient->devPrivates = NULL;
commit 19772670e3041fe1c7f5bbf32fa039a6d8245ccb
Author: Keith Packard <keithp at keithp.com>
Date:   Tue Aug 7 17:49:46 2012 -0700

    Only free Render filter names on last screen close
    
    Hotplugging screens causes the render filter names to get freed while
    still in use; wait for the last core screen to be closed before
    freeing them. That only happens at server reset, when we want them to
    be freed.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Dave Airlie <airlied at redhat.com>

diff --git a/render/filter.c b/render/filter.c
index 8c401ee..019ea7f 100644
--- a/render/filter.c
+++ b/render/filter.c
@@ -273,7 +273,10 @@ PictureResetFilters(ScreenPtr pScreen)
 
     free(ps->filters);
     free(ps->filterAliases);
-    PictureFreeFilterIds();
+
+    /* Free the filters when the last screen is closed */
+    if (pScreen->myNum == 0)
+        PictureFreeFilterIds();
 }
 
 int
commit 863d528a9f76d0e8f122aebf19f8564a4c67a938
Author: Simon Schubert <2 at 0x2c.org>
Date:   Sun Aug 12 09:40:16 2012 -0700

    fb: reorder Bresenham error correction to avoid overshoot.
    
    When fbBresSolid draws a line, it can happen that after the last
    pixel, the Bresenham error term overflows, and fbBresSolid paints
    another pixel before adjusting the error term.
    
    However, if this happens on the last pixel (len=0), this extra pixel
    might overshoot the boundary, and, in rare cases, lead to a segfault.
    
    Fix this issue by adjusting for the Bresenham error term before
    drawing the main pixel, not after.
    
    Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=24274
    Signed-off-by: Simon Schubert <2 at 0x2c.or>
    Tested-by: Mitch Davis <mjd+freedesktop.org at afork.com>
    Signed-off-by: Matt Turner <mattst88 at gmail.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/fb/fbseg.c b/fb/fbseg.c
index 0e4e0a9..1848387 100644
--- a/fb/fbseg.c
+++ b/fb/fbseg.c
@@ -65,6 +65,12 @@ fbBresSolid(DrawablePtr pDrawable,
     if (axis == X_AXIS) {
         bits = 0;
         while (len--) {
+            if (e >= 0) {
+                WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, bits));
+                bits = 0;
+                dst += dstStride;
+                e += e3;
+            }
             bits |= mask;
             mask = fbBresShiftMask(mask, signdx, dstBpp);
             if (!mask) {
@@ -74,21 +80,12 @@ fbBresSolid(DrawablePtr pDrawable,
                 mask = mask0;
             }
             e += e1;
-            if (e >= 0) {
-                WRITE(dst, FbDoMaskRRop(READ(dst), and, xor, bits));
-                bits = 0;
-                dst += dstStride;
-                e += e3;
-            }
         }
         if (bits)
             WRITE(dst, FbDoMaskRRop(READ(dst), and, xor, bits));
     }
     else {
         while (len--) {
-            WRITE(dst, FbDoMaskRRop(READ(dst), and, xor, mask));
-            dst += dstStride;
-            e += e1;
             if (e >= 0) {
                 e += e3;
                 mask = fbBresShiftMask(mask, signdx, dstBpp);
@@ -97,6 +94,9 @@ fbBresSolid(DrawablePtr pDrawable,
                     mask = mask0;
                 }
             }
+            WRITE(dst, FbDoMaskRRop(READ(dst), and, xor, mask));
+            dst += dstStride;
+            e += e1;
         }
     }
 
commit c22c936b35cee60609041ccb7ee52c00b0634d7b
Author: Keith Packard <keithp at keithp.com>
Date:   Tue Aug 7 16:04:25 2012 -0700

    Release 1.12.99.904
    
    Closing the non-critical bug window for 1.13
    
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/configure.ac b/configure.ac
index d13df38..e126355 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,8 +26,9 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ(2.60)
-AC_INIT([xorg-server], 1.12.99.903, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
-RELEASE_DATE="2012-07-25"
+AC_INIT([xorg-server], 1.12.99.904, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+RELEASE_DATE="2012-08-07"
+RELEASE_NAME="Sweating Aardvark"
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
 AM_MAINTAINER_MODE
commit f94ec283efc922106e7ea1d85771950c66ee8f3b
Author: Keith Packard <keithp at keithp.com>
Date:   Tue Aug 7 16:18:21 2012 -0700

    Distribute include/glx_extinit.h
    
    This changed should have been in aad428b8e21c77397c623b78706eb64b1fea77c9
    
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/include/Makefile.am b/include/Makefile.am
index 972f403..33116f2 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -26,6 +26,7 @@ sdk_HEADERS =		\
 	gc.h		\
 	gcstruct.h	\
 	globals.h	\
+	glx_extinit.h	\
 	input.h		\
 	inputstr.h	\
 	list.h		\
commit 9ca67de8feab59fcf7d6e3fdec8d8a7cfbb21651
Author: Julien Cristau <jcristau at debian.org>
Date:   Sat Jul 14 16:07:51 2012 +0200

    Bump glproto requirement to 1.4.16
    
    Signed-off-by: Julien Cristau <jcristau at debian.org>
    Reviewed-by: Dave Airlie <airlied at redhat.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/configure.ac b/configure.ac
index dc79e48..d13df38 100644
--- a/configure.ac
+++ b/configure.ac
@@ -776,7 +776,7 @@ DRI2PROTO="dri2proto >= 2.8"
 XINERAMAPROTO="xineramaproto"
 BIGFONTPROTO="xf86bigfontproto >= 1.2.0"
 DGAPROTO="xf86dgaproto >= 2.0.99.1"
-GLPROTO="glproto >= 1.4.15"
+GLPROTO="glproto >= 1.4.16"
 DMXPROTO="dmxproto >= 2.2.99.1"
 VIDMODEPROTO="xf86vidmodeproto >= 2.2.99.1"
 WINDOWSWMPROTO="windowswmproto"
commit 02f94b2d446f6700f791f318c551ac835af8445a
Merge: 360fa77 7f09126
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Aug 6 16:52:12 2012 -0700

    Merge remote-tracking branch 'whot/for-keith'

commit 360fa7736b214cae3ccd39feb4dc87b9e7e9734c
Merge: 2100e72 ac09a4a
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Aug 6 16:42:34 2012 -0700

    Merge remote-tracking branch 'airlied/for-keithp'

commit 2100e72388a3dc174093d80c9723f021b4614d17
Merge: 4a6f42d c37c650
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Aug 6 16:40:54 2012 -0700

    Merge remote-tracking branch 'alanc/master'

commit 7f09126e068015db54c56bb982b8f91065375700
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Fri Aug 3 15:36:34 2012 +1000

    os: don't unconditionally unblock SIGIO in OsReleaseSignals()
    
    Calling OsReleaseSignal() inside the signal handler releases SIGIO, causing
    the signal handler to be called again from within the handler.
    
    Practical use-case: when synaptics calls TimerSet in the signal handler,
    this causes the signals to be released, eventually hanging the server.
    
    Regression introduced in 08962951de.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/os/utils.c b/os/utils.c
index cdf5fd8..947f867 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -1186,6 +1186,7 @@ OsBlockSignals(void)
 
 #ifdef SIG_BLOCK
 static sig_atomic_t sigio_blocked;
+static sigset_t PreviousSigIOMask;
 #endif
 
 /**
@@ -1198,13 +1199,13 @@ OsBlockSIGIO(void)
 #ifdef SIGIO
 #ifdef SIG_BLOCK
     if (sigio_blocked++ == 0) {
-        sigset_t set, old;
+        sigset_t set;
         int ret;
 
         sigemptyset(&set);
         sigaddset(&set, SIGIO);
-        sigprocmask(SIG_BLOCK, &set, &old);
-        ret = sigismember(&old, SIGIO);
+        sigprocmask(SIG_BLOCK, &set, &PreviousSigIOMask);
+        ret = sigismember(&PreviousSigIOMask, SIGIO);
         return ret;
     } else
         return 1;
@@ -1218,11 +1219,7 @@ OsReleaseSIGIO(void)
 #ifdef SIGIO
 #ifdef SIG_BLOCK
     if (--sigio_blocked == 0) {
-        sigset_t set;
-
-        sigemptyset(&set);
-        sigaddset(&set, SIGIO);
-        sigprocmask(SIG_UNBLOCK, &set, NULL);
+        sigprocmask(SIG_SETMASK, &PreviousSigIOMask, 0);
     } else if (sigio_blocked < 0) {
         BUG_WARN(sigio_blocked < 0);
         sigio_blocked = 0;
diff --git a/test/os.c b/test/os.c
index 1460a34..8f1107d 100644
--- a/test/os.c
+++ b/test/os.c
@@ -28,6 +28,21 @@
 #include <signal.h>
 #include "os.h"
 
+static int last_signal = 0;
+static int expect_signal = 0;
+
+static void sighandler(int signal)
+{
+    assert(expect_signal);
+    expect_signal = 0;
+    if (!last_signal)
+        raise(signal);
+    OsBlockSignals();
+    OsReleaseSignals();
+    last_signal = 1;
+    expect_signal = 1;
+}
+
 static int
 sig_is_blocked(int sig)
 {
@@ -118,7 +133,27 @@ static void block_sigio_test(void)
     assert(sig_is_blocked(SIGIO));
     OsReleaseSignals();
     assert(!sig_is_blocked(SIGIO));
+#endif
+}
 
+static void block_sigio_test_nested(void)
+{
+#ifdef SIG_BLOCK
+    /* Check for bug releasing SIGIO during SIGIO signal handling.
+       test case:
+           raise signal
+           → in signal handler:
+                raise signal
+                OsBlockSignals()
+                OsReleaseSignals()
+                tail guard
+       tail guard must be hit.
+     */
+    sighandler_t old_handler;
+    old_handler = signal(SIGIO, sighandler);
+    expect_signal = 1;
+    assert(raise(SIGIO) == 0);
+    assert(signal(SIGIO, old_handler) == sighandler);
 #endif
 }
 
@@ -126,5 +161,6 @@ int
 main(int argc, char **argv)
 {
     block_sigio_test();
+    block_sigio_test_nested();
     return 0;
 }
commit cb306a8f174bec9ded95191b91797f59250e6808
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Tue Jul 31 16:09:38 2012 +1000

    dix: make sure the mask is set for emulated scroll events (#52508)
    
    If a device has smooth scrolling axes, but submits scroll button events, we
    convert those to motion events and update the valuators. For legacy button
    events, the valuator mask is likely unset though, causing
    add_to_scroll_valuator() to return early, leaving us with an empty mask.
    That again skipped the rest of the code and no events were generated.
    
    Fix it by making sure that the scroll valuator in the mask is at least
    initialized to 0.
    
    Broke evdev wheel emulation, introduced by
    54476b5e4461ff523e935961affabcf0de12c556.
    
    X.Org Bug 52508 <http://bugs.freedesktop.org/show_bug.cgi?id=52508>
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Chase Douglas <chase.douglas at canonical.com>

diff --git a/dix/getevents.c b/dix/getevents.c
index 27c2e04..b3bb162 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -1625,6 +1625,8 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type,
 
         if (adj != 0.0 && axis != -1) {
             adj *= pDev->valuator->axes[axis].scroll.increment;
+            if (!valuator_mask_isset(&mask, axis))
+                valuator_mask_set(&mask, axis, 0);
             add_to_scroll_valuator(pDev, &mask, axis, adj);
             type = MotionNotify;
             buttons = 0;
commit 4a6f42dda00ba3b5616f8a86f0d4c9a652c7d9d4
Author: Adam Jackson <ajax at redhat.com>
Date:   Mon Jul 23 16:34:28 2012 -0400

    sync: Fix logic error from b55bf248581dc66321b24b29f199f6dc8d02db1b
    
    That commit adds two hunks, and I _think_ they're backwards.  It adds
    code to modify bracket_greater on NegativeTransition triggers, and
    bracket_less on PositiveTransition triggers.  That breaks symmetry with
    the surrounding code; the code as of this commit could probably be
    simplified further.
    
    I can't keep the sync trigger rules in my head for more than about five
    minutes at a time, so I'm sending this on for more eyes.  RHEL 6.3's
    xserver is shipping with b55bf248 reverted:
    
        https://bugzilla.redhat.com/show_bug.cgi?id=748704#c33
    
    And there appear to be some upstream reports of the same issue:
    
        https://bugzilla.gnome.org/show_bug.cgi?id=658955
    
    So I'd like to get this sorted out.
    
    Signed-off-by: Adam Jackson <ajax at redhat.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/Xext/sync.c b/Xext/sync.c
index b8f094d..4d11992 100644
--- a/Xext/sync.c
+++ b/Xext/sync.c
@@ -1038,15 +1038,15 @@ SyncComputeBracketValues(SyncCounter * pCounter)
                 pnewltval = &psci->bracket_less;
             }
             else if (XSyncValueEqual(pCounter->value, pTrigger->test_value) &&
-                     XSyncValueLessThan(pTrigger->test_value,
-                                        psci->bracket_greater)) {
+                     XSyncValueGreaterThan(pTrigger->test_value,
+                                           psci->bracket_less)) {
                 /*
                  * The value is exactly equal to our threshold.  We want one
-                 * more event in the positive direction to ensure we pick up
-                 * when the value *exceeds* this threshold.
+                 * more event in the negative direction to ensure we pick up
+                 * when the value is less than this threshold.
                  */
-                psci->bracket_greater = pTrigger->test_value;
-                pnewgtval = &psci->bracket_greater;
+                psci->bracket_less = pTrigger->test_value;
+                pnewltval = &psci->bracket_less;
             }
         }
         else if (pTrigger->test_type == XSyncPositiveTransition &&
@@ -1058,15 +1058,15 @@ SyncComputeBracketValues(SyncCounter * pCounter)
                 pnewgtval = &psci->bracket_greater;
             }
             else if (XSyncValueEqual(pCounter->value, pTrigger->test_value) &&
-                     XSyncValueGreaterThan(pTrigger->test_value,
-                                           psci->bracket_less)) {
+                     XSyncValueLessThan(pTrigger->test_value,
+                                        psci->bracket_greater)) {
                 /*
                  * The value is exactly equal to our threshold.  We want one
-                 * more event in the negative direction to ensure we pick up
-                 * when the value is less than this threshold.
+                 * more event in the positive direction to ensure we pick up
+                 * when the value *exceeds* this threshold.
                  */
-                psci->bracket_less = pTrigger->test_value;
-                pnewltval = &psci->bracket_less;
+                psci->bracket_greater = pTrigger->test_value;
+                pnewgtval = &psci->bracket_greater;
             }
         }
     }                           /* end for each trigger */
commit 454d0e3a1bb14d7f2579ccb5e513cec5686160e7
Author: Dave Airlie <airlied at redhat.com>
Date:   Thu Jul 26 12:56:51 2012 +1000

    randr: fix xinerama output for output slaves
    
    This fixes the xinerama geometry when output slaves are enabled.
    
    Tested with xdpyinfo -ext XINERAMA before after slave added.
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/randr/rrxinerama.c b/randr/rrxinerama.c
index 87d6a73..76d728c 100644
--- a/randr/rrxinerama.c
+++ b/randr/rrxinerama.c
@@ -157,6 +157,7 @@ static int
 RRXineramaScreenCount(ScreenPtr pScreen)
 {
     int i, n;
+    ScreenPtr slave;
 
     n = 0;
     if (rrGetScrPriv(pScreen)) {
@@ -165,6 +166,15 @@ RRXineramaScreenCount(ScreenPtr pScreen)
             if (RRXineramaCrtcActive(pScrPriv->crtcs[i]))
                 n++;
     }
+
+    xorg_list_for_each_entry(slave, &pScreen->output_slave_list, output_head) {
+        rrScrPrivPtr pSlavePriv;
+        pSlavePriv = rrGetScrPriv(slave);
+        for (i = 0; i < pSlavePriv->numCrtcs; i++)
+            if (RRXineramaCrtcActive(pSlavePriv->crtcs[i]))
+                n++;
+    }
+
     return n;
 }
 
@@ -308,6 +318,7 @@ ProcRRXineramaQueryScreens(ClientPtr client)
     xXineramaQueryScreensReply rep;
     ScreenPtr pScreen = screenInfo.screens[RR_XINERAMA_SCREEN];
     int n = 0;
+    int i;
 
     REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
 
@@ -330,8 +341,8 @@ ProcRRXineramaQueryScreens(ClientPtr client)
     WriteToClient(client, sizeof(xXineramaQueryScreensReply), &rep);
 
     if (n) {
+        ScreenPtr slave;
         rrScrPriv(pScreen);
-        int i;
         int has_primary = 0;
 
         if (pScrPriv->primaryOutput && pScrPriv->primaryOutput->crtc) {
@@ -347,6 +358,13 @@ ProcRRXineramaQueryScreens(ClientPtr client)
             }
             RRXineramaWriteCrtc(client, pScrPriv->crtcs[i]);
         }
+
+        xorg_list_for_each_entry(slave, &pScreen->output_slave_list, output_head) {
+            rrScrPrivPtr pSlavePriv;
+            pSlavePriv = rrGetScrPriv(slave);
+            for (i = 0; i < pSlavePriv->numCrtcs; i++)
+                RRXineramaWriteCrtc(client, pSlavePriv->crtcs[i]);
+        }
     }
 
     return Success;
commit ac09a4a091a43188241365152e1244fd8fd93ee7
Author: Dave Airlie <airlied at redhat.com>
Date:   Fri Aug 3 16:43:22 2012 +1000

    dri2: fix master pixmap free and reset pointer
    
    These are two minor changes, one to reset the pointer to NULL,
    after freeing the pixmaps, one to make sure we use the right API for
    the master pixmap, though I doubt it'll ever really matter.
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index d60d8ba..23f589c 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -816,8 +816,9 @@ DrawablePtr DRI2UpdatePrime(DrawablePtr pDraw, DRI2BufferPtr pDest)
         if (pPriv->prime_slave_pixmap->master_pixmap == mpix)
             return &pPriv->prime_slave_pixmap->drawable;
         else {
-            (*master->DestroyPixmap)(pPriv->prime_slave_pixmap->master_pixmap);
+            (*pPriv->prime_slave_pixmap->master_pixmap->drawable.pScreen->DestroyPixmap)(pPriv->prime_slave_pixmap->master_pixmap);
             (*slave->DestroyPixmap)(pPriv->prime_slave_pixmap);
+            pPriv->prime_slave_pixmap = NULL;
         }
     }
 
commit 64623ef90db649e89345f71871affe7a9606f6ea
Author: Dave Airlie <airlied at redhat.com>
Date:   Fri Aug 3 16:42:44 2012 +1000

    dri2: free slave pixmap on app exit
    
    When the drawable disappears we need to free the prime master/slave combos.
    
    This fixes a leak after a prime app is run.
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 63feed5..d60d8ba 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -409,6 +409,11 @@ DRI2DrawableGone(pointer p, XID id)
         dixSetPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey, NULL);
     }
 
+    if (pPriv->prime_slave_pixmap) {
+        (*pPriv->prime_slave_pixmap->master_pixmap->drawable.pScreen->DestroyPixmap)(pPriv->prime_slave_pixmap->master_pixmap);
+        (*pPriv->prime_slave_pixmap->drawable.pScreen->DestroyPixmap)(pPriv->prime_slave_pixmap);
+    }
+
     if (pPriv->buffers != NULL) {
         for (i = 0; i < pPriv->bufferCount; i++)
             destroy_buffer(pDraw, pPriv->buffers[i], pPriv->prime_id);
commit 1a465fef9bc21142eecca3999f0761a3c0501a09
Author: Dave Airlie <airlied at redhat.com>
Date:   Fri Aug 3 16:41:45 2012 +1000

    pixmap: have slave pixmap take a reference on master pixmap
    
    Since the free routines free the master pixmap then the slave, we should
    be taking a reference when we bind them together.
    
    Fixes a use-after-free when resizing a primed gears.
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/dix/pixmap.c b/dix/pixmap.c
index 9163e99..2418812 100644
--- a/dix/pixmap.c
+++ b/dix/pixmap.c
@@ -148,6 +148,10 @@ PixmapPtr PixmapShareToSlave(PixmapPtr pixmap, ScreenPtr slave)
                               pixmap->drawable.height, depth, 0,
                               pixmap->devKind, NULL);
 
+    /* have the slave pixmap take a reference on the master pixmap
+       later we destroy them both at the same time */
+    pixmap->refcnt++;
+
     spix->master_pixmap = pixmap;
 
     ret = slave->SetSharedPixmapBacking(spix, handle);
commit c37c65052f674cd58894ad0b9ec22928a62c624e
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Mon Jul 16 21:12:06 2012 -0700

    Make indentation of dix/tables.c much more consistent and readable
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Acked-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/dix/tables.c b/dix/tables.c
index 705ef0d..686cddd 100644
--- a/dix/tables.c
+++ b/dix/tables.c
@@ -58,364 +58,529 @@ SOFTWARE.
 #include "swaprep.h"
 #include "swapreq.h"
 
-int (*InitialVector[3]) (ClientPtr      /* client */
-    ) = {
-0, ProcInitialConnection, ProcEstablishConnection};
+int (*InitialVector[3]) (ClientPtr /* client */) = {
+    0,
+    ProcInitialConnection,
+    ProcEstablishConnection
+};
 
-int (*ProcVector[256]) (ClientPtr       /* client */
-    ) = {
-    ProcBadRequest, ProcCreateWindow, ProcChangeWindowAttributes, ProcGetWindowAttributes, ProcDestroyWindow, ProcDestroySubwindows,    /* 5 */
-        ProcChangeSaveSet, ProcReparentWindow, ProcMapWindow, ProcMapSubwindows, ProcUnmapWindow,       /* 10 */
-        ProcUnmapSubwindows, ProcConfigureWindow, ProcCirculateWindow, ProcGetGeometry, ProcQueryTree,  /* 15 */
-        ProcInternAtom, ProcGetAtomName, ProcChangeProperty, ProcDeleteProperty, ProcGetProperty,       /* 20 */
-        ProcListProperties, ProcSetSelectionOwner, ProcGetSelectionOwner, ProcConvertSelection, ProcSendEvent,  /* 25 */
-        ProcGrabPointer, ProcUngrabPointer, ProcGrabButton, ProcUngrabButton, ProcChangeActivePointerGrab,      /* 30 */
-        ProcGrabKeyboard, ProcUngrabKeyboard, ProcGrabKey, ProcUngrabKey, ProcAllowEvents,      /* 35 */
-        ProcGrabServer, ProcUngrabServer, ProcQueryPointer, ProcGetMotionEvents, ProcTranslateCoords,   /* 40 */
-        ProcWarpPointer, ProcSetInputFocus, ProcGetInputFocus, ProcQueryKeymap, ProcOpenFont,   /* 45 */
-        ProcCloseFont, ProcQueryFont, ProcQueryTextExtents, ProcListFonts, ProcListFontsWithInfo,       /* 50 */
-        ProcSetFontPath, ProcGetFontPath, ProcCreatePixmap, ProcFreePixmap, ProcCreateGC,       /* 55 */
-        ProcChangeGC, ProcCopyGC, ProcSetDashes, ProcSetClipRectangles, ProcFreeGC,     /* 60 */
-        ProcClearToBackground, ProcCopyArea, ProcCopyPlane, ProcPolyPoint, ProcPolyLine,        /* 65 */
-        ProcPolySegment, ProcPolyRectangle, ProcPolyArc, ProcFillPoly, ProcPolyFillRectangle,   /* 70 */
-        ProcPolyFillArc, ProcPutImage, ProcGetImage, ProcPolyText, ProcPolyText,        /* 75 */
-        ProcImageText8, ProcImageText16, ProcCreateColormap, ProcFreeColormap, ProcCopyColormapAndFree, /* 80 */
-        ProcInstallColormap, ProcUninstallColormap, ProcListInstalledColormaps, ProcAllocColor, ProcAllocNamedColor,    /* 85 */
-        ProcAllocColorCells, ProcAllocColorPlanes, ProcFreeColors, ProcStoreColors, ProcStoreNamedColor,        /* 90 */
-        ProcQueryColors, ProcLookupColor, ProcCreateCursor, ProcCreateGlyphCursor, ProcFreeCursor,      /* 95 */
-        ProcRecolorCursor, ProcQueryBestSize, ProcQueryExtension, ProcListExtensions, ProcChangeKeyboardMapping,        /* 100 */
-        ProcGetKeyboardMapping, ProcChangeKeyboardControl, ProcGetKeyboardControl, ProcBell, ProcChangePointerControl,  /* 105 */
-        ProcGetPointerControl, ProcSetScreenSaver, ProcGetScreenSaver, ProcChangeHosts, ProcListHosts,  /* 110 */
-        ProcChangeAccessControl, ProcChangeCloseDownMode, ProcKillClient, ProcRotateProperties, ProcForceScreenSaver,   /* 115 */
-        ProcSetPointerMapping, ProcGetPointerMapping, ProcSetModifierMapping, ProcGetModifierMapping, ProcBadRequest,   /* 120 */
-        ProcBadRequest, ProcBadRequest, ProcBadRequest, ProcBadRequest, ProcBadRequest, /* 125 */
-ProcBadRequest,
-        ProcNoOperation,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest, ProcBadRequest, ProcBadRequest, ProcBadRequest};
+int (*ProcVector[256]) (ClientPtr /* client */) = {
+    ProcBadRequest,
+    ProcCreateWindow,
+    ProcChangeWindowAttributes,
+    ProcGetWindowAttributes,
+    ProcDestroyWindow,
+    ProcDestroySubwindows,              /* 5 */
+    ProcChangeSaveSet,
+    ProcReparentWindow,
+    ProcMapWindow,
+    ProcMapSubwindows,
+    ProcUnmapWindow,                    /* 10 */
+    ProcUnmapSubwindows,
+    ProcConfigureWindow,
+    ProcCirculateWindow,
+    ProcGetGeometry,
+    ProcQueryTree,                      /* 15 */
+    ProcInternAtom,
+    ProcGetAtomName,
+    ProcChangeProperty,
+    ProcDeleteProperty,
+    ProcGetProperty,                    /* 20 */
+    ProcListProperties,
+    ProcSetSelectionOwner,
+    ProcGetSelectionOwner,
+    ProcConvertSelection,
+    ProcSendEvent,                      /* 25 */
+    ProcGrabPointer,
+    ProcUngrabPointer,
+    ProcGrabButton,
+    ProcUngrabButton,
+    ProcChangeActivePointerGrab,        /* 30 */
+    ProcGrabKeyboard,
+    ProcUngrabKeyboard,
+    ProcGrabKey,
+    ProcUngrabKey,
+    ProcAllowEvents,                    /* 35 */
+    ProcGrabServer,
+    ProcUngrabServer,
+    ProcQueryPointer,
+    ProcGetMotionEvents,
+    ProcTranslateCoords,                /* 40 */
+    ProcWarpPointer,
+    ProcSetInputFocus,
+    ProcGetInputFocus,
+    ProcQueryKeymap,
+    ProcOpenFont,                       /* 45 */
+    ProcCloseFont,
+    ProcQueryFont,
+    ProcQueryTextExtents,
+    ProcListFonts,
+    ProcListFontsWithInfo,              /* 50 */
+    ProcSetFontPath,
+    ProcGetFontPath,
+    ProcCreatePixmap,
+    ProcFreePixmap,
+    ProcCreateGC,                       /* 55 */
+    ProcChangeGC,
+    ProcCopyGC,
+    ProcSetDashes,
+    ProcSetClipRectangles,
+    ProcFreeGC,                         /* 60 */
+    ProcClearToBackground,
+    ProcCopyArea,
+    ProcCopyPlane,
+    ProcPolyPoint,
+    ProcPolyLine,                       /* 65 */
+    ProcPolySegment,
+    ProcPolyRectangle,
+    ProcPolyArc,
+    ProcFillPoly,
+    ProcPolyFillRectangle,              /* 70 */
+    ProcPolyFillArc,
+    ProcPutImage,
+    ProcGetImage,
+    ProcPolyText,
+    ProcPolyText,                       /* 75 */
+    ProcImageText8,
+    ProcImageText16,
+    ProcCreateColormap,
+    ProcFreeColormap,
+    ProcCopyColormapAndFree,            /* 80 */
+    ProcInstallColormap,
+    ProcUninstallColormap,
+    ProcListInstalledColormaps,
+    ProcAllocColor,
+    ProcAllocNamedColor,                /* 85 */
+    ProcAllocColorCells,
+    ProcAllocColorPlanes,
+    ProcFreeColors,
+    ProcStoreColors,
+    ProcStoreNamedColor,                /* 90 */
+    ProcQueryColors,
+    ProcLookupColor,
+    ProcCreateCursor,
+    ProcCreateGlyphCursor,
+    ProcFreeCursor,                     /* 95 */
+    ProcRecolorCursor,
+    ProcQueryBestSize,
+    ProcQueryExtension,
+    ProcListExtensions,
+    ProcChangeKeyboardMapping,          /* 100 */
+    ProcGetKeyboardMapping,
+    ProcChangeKeyboardControl,
+    ProcGetKeyboardControl,
+    ProcBell,
+    ProcChangePointerControl,           /* 105 */
+    ProcGetPointerControl,
+    ProcSetScreenSaver,
+    ProcGetScreenSaver,
+    ProcChangeHosts,
+    ProcListHosts,                      /* 110 */
+    ProcChangeAccessControl,
+    ProcChangeCloseDownMode,
+    ProcKillClient,
+    ProcRotateProperties,
+    ProcForceScreenSaver,               /* 115 */
+    ProcSetPointerMapping,
+    ProcGetPointerMapping,
+    ProcSetModifierMapping,
+    ProcGetModifierMapping,
+    ProcBadRequest,                     /* 120 */
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,                     /* 125 */
+    ProcBadRequest,
+    ProcNoOperation,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest
+};
 
-int (*SwappedProcVector[256]) (ClientPtr        /* client */
-    ) = {
-    ProcBadRequest, SProcCreateWindow, SProcChangeWindowAttributes, SProcResourceReq,   /* GetWindowAttributes */
-        SProcResourceReq,       /* DestroyWindow */
-        SProcResourceReq,       /* 5 DestroySubwindows */
-        SProcResourceReq,       /* SProcChangeSaveSet, */
-        SProcReparentWindow, SProcResourceReq,  /* MapWindow */
-        SProcResourceReq,       /* MapSubwindows */
-        SProcResourceReq,       /* 10 UnmapWindow */
-        SProcResourceReq,       /* UnmapSubwindows */
-        SProcConfigureWindow, SProcResourceReq, /* SProcCirculateWindow, */
-        SProcResourceReq,       /* GetGeometry */
-        SProcResourceReq,       /* 15 QueryTree */
-        SProcInternAtom, SProcResourceReq,      /* SProcGetAtomName, */
-        SProcChangeProperty, SProcDeleteProperty, SProcGetProperty,     /* 20 */
-        SProcResourceReq,       /* SProcListProperties, */
-        SProcSetSelectionOwner, SProcResourceReq,       /* SProcGetSelectionOwner, */
-        SProcConvertSelection, SProcSendEvent,  /* 25 */
-        SProcGrabPointer, SProcResourceReq,     /* SProcUngrabPointer, */
-        SProcGrabButton, SProcUngrabButton, SProcChangeActivePointerGrab,       /* 30 */
-        SProcGrabKeyboard, SProcResourceReq,    /* SProcUngrabKeyboard, */
-        SProcGrabKey, SProcUngrabKey, SProcResourceReq, /* 35 SProcAllowEvents, */
-        SProcSimpleReq,         /* SProcGrabServer, */
-        SProcSimpleReq,         /* SProcUngrabServer, */
-        SProcResourceReq,       /* SProcQueryPointer, */
-        SProcGetMotionEvents, SProcTranslateCoords,     /*40 */
-        SProcWarpPointer, SProcSetInputFocus, SProcSimpleReq,   /* SProcGetInputFocus, */
-        SProcSimpleReq,         /* QueryKeymap, */
-        SProcOpenFont,          /* 45 */
-        SProcResourceReq,       /* SProcCloseFont, */
-        SProcResourceReq,       /* SProcQueryFont, */
-        SProcResourceReq,       /* SProcQueryTextExtents,  */
-        SProcListFonts, SProcListFontsWithInfo, /* 50 */
-        SProcSetFontPath, SProcSimpleReq,       /* GetFontPath, */
-        SProcCreatePixmap, SProcResourceReq,    /* SProcFreePixmap, */
-        SProcCreateGC,          /* 55 */
-        SProcChangeGC, SProcCopyGC, SProcSetDashes, SProcSetClipRectangles, SProcResourceReq,   /* 60 SProcFreeGC, */
-        SProcClearToBackground, SProcCopyArea, SProcCopyPlane, SProcPoly,       /* PolyPoint, */
-        SProcPoly,              /* 65 PolyLine */
-        SProcPoly,              /* PolySegment, */
-        SProcPoly,              /* PolyRectangle, */
-        SProcPoly,              /* PolyArc, */
-        SProcFillPoly, SProcPoly,       /* 70 PolyFillRectangle */
-        SProcPoly,              /* PolyFillArc, */
-        SProcPutImage, SProcGetImage, SProcPolyText, SProcPolyText,     /* 75 */
-        SProcImageText, SProcImageText, SProcCreateColormap, SProcResourceReq,  /* SProcFreeColormap, */
-        SProcCopyColormapAndFree,       /* 80 */
-        SProcResourceReq,       /* SProcInstallColormap, */
-        SProcResourceReq,       /* SProcUninstallColormap, */
-        SProcResourceReq,       /* SProcListInstalledColormaps, */
-        SProcAllocColor, SProcAllocNamedColor,  /* 85 */
-        SProcAllocColorCells, SProcAllocColorPlanes, SProcFreeColors, SProcStoreColors, SProcStoreNamedColor,   /* 90 */
-        SProcQueryColors, SProcLookupColor, SProcCreateCursor, SProcCreateGlyphCursor, SProcResourceReq,        /* 95 SProcFreeCursor, */
-        SProcRecolorCursor, SProcQueryBestSize, SProcQueryExtension, SProcSimpleReq,    /* ListExtensions, */
-        SProcChangeKeyboardMapping,     /* 100 */
-        SProcSimpleReq,         /* GetKeyboardMapping, */
-        SProcChangeKeyboardControl, SProcSimpleReq,     /* GetKeyboardControl, */
-        SProcSimpleReq,         /* Bell, */
-        SProcChangePointerControl,      /* 105 */
-        SProcSimpleReq,         /* GetPointerControl, */
-        SProcSetScreenSaver, SProcSimpleReq,    /* GetScreenSaver, */
-        SProcChangeHosts, SProcSimpleReq,       /* 110 ListHosts, */
-        SProcSimpleReq,         /* SProcChangeAccessControl, */
-        SProcSimpleReq,         /* SProcChangeCloseDownMode, */
-        SProcResourceReq,       /* SProcKillClient, */
-        SProcRotateProperties, SProcSimpleReq,  /* 115 ForceScreenSaver */
-        SProcSimpleReq,         /* SetPointerMapping, */
-        SProcSimpleReq,         /* GetPointerMapping, */
-        SProcSimpleReq,         /* SetModifierMapping, */
-        SProcSimpleReq,         /* GetModifierMapping, */
-        ProcBadRequest,         /* 120 */
-        ProcBadRequest, ProcBadRequest, ProcBadRequest, ProcBadRequest, ProcBadRequest, /* 125 */
-ProcBadRequest,
-        SProcNoOperation,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest,
-        ProcBadRequest, ProcBadRequest, ProcBadRequest, ProcBadRequest};
+int (*SwappedProcVector[256]) (ClientPtr /* client */) = {
+    ProcBadRequest,
+    SProcCreateWindow,
+    SProcChangeWindowAttributes,
+    SProcResourceReq,                   /* GetWindowAttributes */
+    SProcResourceReq,                   /* DestroyWindow */
+    SProcResourceReq,                   /* 5 DestroySubwindows */
+    SProcResourceReq,                   /* SProcChangeSaveSet, */
+    SProcReparentWindow,
+    SProcResourceReq,                   /* MapWindow */
+    SProcResourceReq,                   /* MapSubwindows */
+    SProcResourceReq,                   /* 10 UnmapWindow */
+    SProcResourceReq,                   /* UnmapSubwindows */
+    SProcConfigureWindow,
+    SProcResourceReq,                   /* SProcCirculateWindow, */
+    SProcResourceReq,                   /* GetGeometry */
+    SProcResourceReq,                   /* 15 QueryTree */
+    SProcInternAtom,
+    SProcResourceReq,                   /* SProcGetAtomName, */
+    SProcChangeProperty,
+    SProcDeleteProperty,
+    SProcGetProperty,                   /* 20 */
+    SProcResourceReq,                   /* SProcListProperties, */
+    SProcSetSelectionOwner,
+    SProcResourceReq,                   /* SProcGetSelectionOwner, */
+    SProcConvertSelection,
+    SProcSendEvent,                     /* 25 */
+    SProcGrabPointer,
+    SProcResourceReq,                   /* SProcUngrabPointer, */
+    SProcGrabButton,
+    SProcUngrabButton,
+    SProcChangeActivePointerGrab,       /* 30 */
+    SProcGrabKeyboard,
+    SProcResourceReq,                   /* SProcUngrabKeyboard, */
+    SProcGrabKey,
+    SProcUngrabKey,
+    SProcResourceReq,                   /* 35 SProcAllowEvents, */
+    SProcSimpleReq,                     /* SProcGrabServer, */
+    SProcSimpleReq,                     /* SProcUngrabServer, */
+    SProcResourceReq,                   /* SProcQueryPointer, */
+    SProcGetMotionEvents,
+    SProcTranslateCoords,               /*40 */
+    SProcWarpPointer,
+    SProcSetInputFocus,
+    SProcSimpleReq,                     /* SProcGetInputFocus, */
+    SProcSimpleReq,                     /* QueryKeymap, */
+    SProcOpenFont,                      /* 45 */
+    SProcResourceReq,                   /* SProcCloseFont, */
+    SProcResourceReq,                   /* SProcQueryFont, */
+    SProcResourceReq,                   /* SProcQueryTextExtents,  */
+    SProcListFonts,
+    SProcListFontsWithInfo,             /* 50 */
+    SProcSetFontPath,
+    SProcSimpleReq,                     /* GetFontPath, */
+    SProcCreatePixmap,
+    SProcResourceReq,                   /* SProcFreePixmap, */
+    SProcCreateGC,                      /* 55 */
+    SProcChangeGC,
+    SProcCopyGC,
+    SProcSetDashes,
+    SProcSetClipRectangles,
+    SProcResourceReq,                   /* 60 SProcFreeGC, */
+    SProcClearToBackground,
+    SProcCopyArea,
+    SProcCopyPlane,
+    SProcPoly,                          /* PolyPoint, */
+    SProcPoly,                          /* 65 PolyLine */
+    SProcPoly,                          /* PolySegment, */
+    SProcPoly,                          /* PolyRectangle, */
+    SProcPoly,                          /* PolyArc, */
+    SProcFillPoly,
+    SProcPoly,                          /* 70 PolyFillRectangle */
+    SProcPoly,                          /* PolyFillArc, */
+    SProcPutImage,
+    SProcGetImage,
+    SProcPolyText,
+    SProcPolyText,                      /* 75 */
+    SProcImageText,
+    SProcImageText,
+    SProcCreateColormap,
+    SProcResourceReq,                   /* SProcFreeColormap, */
+    SProcCopyColormapAndFree,           /* 80 */
+    SProcResourceReq,                   /* SProcInstallColormap, */
+    SProcResourceReq,                   /* SProcUninstallColormap, */
+    SProcResourceReq,                   /* SProcListInstalledColormaps, */
+    SProcAllocColor,
+    SProcAllocNamedColor,               /* 85 */
+    SProcAllocColorCells,
+    SProcAllocColorPlanes,
+    SProcFreeColors,
+    SProcStoreColors,
+    SProcStoreNamedColor,               /* 90 */
+    SProcQueryColors,
+    SProcLookupColor,
+    SProcCreateCursor,
+    SProcCreateGlyphCursor,
+    SProcResourceReq,                   /* 95 SProcFreeCursor, */
+    SProcRecolorCursor,
+    SProcQueryBestSize,
+    SProcQueryExtension,
+    SProcSimpleReq,                     /* ListExtensions, */
+    SProcChangeKeyboardMapping,         /* 100 */
+    SProcSimpleReq,                     /* GetKeyboardMapping, */
+    SProcChangeKeyboardControl,
+    SProcSimpleReq,                     /* GetKeyboardControl, */
+    SProcSimpleReq,                     /* Bell, */
+    SProcChangePointerControl,          /* 105 */
+    SProcSimpleReq,                     /* GetPointerControl, */
+    SProcSetScreenSaver,
+    SProcSimpleReq,                     /* GetScreenSaver, */
+    SProcChangeHosts,
+    SProcSimpleReq,                     /* 110 ListHosts, */
+    SProcSimpleReq,                     /* SProcChangeAccessControl, */
+    SProcSimpleReq,                     /* SProcChangeCloseDownMode, */
+    SProcResourceReq,                   /* SProcKillClient, */
+    SProcRotateProperties,
+    SProcSimpleReq,                     /* 115 ForceScreenSaver */
+    SProcSimpleReq,                     /* SetPointerMapping, */
+    SProcSimpleReq,                     /* GetPointerMapping, */
+    SProcSimpleReq,                     /* SetModifierMapping, */
+    SProcSimpleReq,                     /* GetModifierMapping, */
+    ProcBadRequest,                     /* 120 */
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,                     /* 125 */
+    ProcBadRequest,
+    SProcNoOperation,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest,
+    ProcBadRequest
+};
 
 EventSwapPtr EventSwapVector[MAXEVENTS] = {
     (EventSwapPtr) SErrorEvent,
@@ -423,32 +588,32 @@ EventSwapPtr EventSwapVector[MAXEVENTS] = {
     SKeyButtonPtrEvent,
     SKeyButtonPtrEvent,
     SKeyButtonPtrEvent,
-    SKeyButtonPtrEvent,         /* 5 */
+    SKeyButtonPtrEvent,                         /* 5 */
     SKeyButtonPtrEvent,
     SEnterLeaveEvent,
     SEnterLeaveEvent,
     SFocusEvent,
-    SFocusEvent,                /* 10 */
+    SFocusEvent,                                /* 10 */
     SKeymapNotifyEvent,
     SExposeEvent,
     SGraphicsExposureEvent,
     SNoExposureEvent,
-    SVisibilityEvent,           /* 15 */
+    SVisibilityEvent,                           /* 15 */
     SCreateNotifyEvent,
     SDestroyNotifyEvent,
     SUnmapNotifyEvent,
     SMapNotifyEvent,
-    SMapRequestEvent,           /* 20 */
+    SMapRequestEvent,                           /* 20 */
     SReparentEvent,
     SConfigureNotifyEvent,
     SConfigureRequestEvent,
     SGravityEvent,
-    SResizeRequestEvent,        /* 25 */
+    SResizeRequestEvent,                        /* 25 */
     SCirculateEvent,
     SCirculateEvent,
     SPropertyEvent,
     SSelectionClearEvent,
-    SSelectionRequestEvent,     /* 30 */
+    SSelectionRequestEvent,                     /* 30 */
     SSelectionNotifyEvent,
     SColormapEvent,
     SClientMessageEvent,
@@ -554,37 +719,37 @@ ReplySwapPtr ReplySwapVector[256] = {
     ReplyNotSwappd,
     (ReplySwapPtr) SGetWindowAttributesReply,
     ReplyNotSwappd,
-    ReplyNotSwappd,             /* 5 */
+    ReplyNotSwappd,                             /* 5 */
     ReplyNotSwappd,
     ReplyNotSwappd,
     ReplyNotSwappd,
     ReplyNotSwappd,
-    ReplyNotSwappd,             /* 10 */
+    ReplyNotSwappd,                             /* 10 */
     ReplyNotSwappd,
     ReplyNotSwappd,
     ReplyNotSwappd,
     (ReplySwapPtr) SGetGeometryReply,
-    (ReplySwapPtr) SQueryTreeReply,     /* 15 */
+    (ReplySwapPtr) SQueryTreeReply,             /* 15 */
     (ReplySwapPtr) SInternAtomReply,
     (ReplySwapPtr) SGetAtomNameReply,
     ReplyNotSwappd,
     ReplyNotSwappd,
-    (ReplySwapPtr) SGetPropertyReply,   /* 20 */
+    (ReplySwapPtr) SGetPropertyReply,           /* 20 */
     (ReplySwapPtr) SListPropertiesReply,
     ReplyNotSwappd,
     (ReplySwapPtr) SGetSelectionOwnerReply,
     ReplyNotSwappd,
-    ReplyNotSwappd,             /* 25 */
-    (ReplySwapPtr) SGenericReply,       /* SGrabPointerReply, */
+    ReplyNotSwappd,                             /* 25 */
+    (ReplySwapPtr) SGenericReply,               /* SGrabPointerReply, */
     ReplyNotSwappd,
     ReplyNotSwappd,
     ReplyNotSwappd,
-    ReplyNotSwappd,             /* 30 */
-    (ReplySwapPtr) SGenericReply,       /* SGrabKeyboardReply, */
+    ReplyNotSwappd,                             /* 30 */
+    (ReplySwapPtr) SGenericReply,               /* SGrabKeyboardReply, */
     ReplyNotSwappd,
     ReplyNotSwappd,
     ReplyNotSwappd,
-    ReplyNotSwappd,             /* 35 */
+    ReplyNotSwappd,                             /* 35 */
     ReplyNotSwappd,
     ReplyNotSwappd,
     (ReplySwapPtr) SQueryPointerReply,
@@ -594,7 +759,7 @@ ReplySwapPtr ReplySwapVector[256] = {
     ReplyNotSwappd,
     (ReplySwapPtr) SGetInputFocusReply,
     (ReplySwapPtr) SQueryKeymapReply,
-    ReplyNotSwappd,             /* 45 */
+    ReplyNotSwappd,                             /* 45 */
     ReplyNotSwappd,
     (ReplySwapPtr) SQueryFontReply,
     (ReplySwapPtr) SQueryTextExtentsReply,
@@ -604,32 +769,32 @@ ReplySwapPtr ReplySwapVector[256] = {
     (ReplySwapPtr) SGetFontPathReply,
     ReplyNotSwappd,
     ReplyNotSwappd,
-    ReplyNotSwappd,             /* 55 */
+    ReplyNotSwappd,                             /* 55 */
     ReplyNotSwappd,
     ReplyNotSwappd,
     ReplyNotSwappd,
     ReplyNotSwappd,
-    ReplyNotSwappd,             /* 60 */
+    ReplyNotSwappd,                             /* 60 */
     ReplyNotSwappd,
     ReplyNotSwappd,
     ReplyNotSwappd,
     ReplyNotSwappd,
-    ReplyNotSwappd,             /* 65 */
+    ReplyNotSwappd,                             /* 65 */
     ReplyNotSwappd,
     ReplyNotSwappd,
     ReplyNotSwappd,
     ReplyNotSwappd,
-    ReplyNotSwappd,             /* 70 */
+    ReplyNotSwappd,                             /* 70 */
     ReplyNotSwappd,
     ReplyNotSwappd,
     (ReplySwapPtr) SGetImageReply,
     ReplyNotSwappd,
-    ReplyNotSwappd,             /* 75 */
+    ReplyNotSwappd,                             /* 75 */
     ReplyNotSwappd,
     ReplyNotSwappd,
     ReplyNotSwappd,
     ReplyNotSwappd,
-    ReplyNotSwappd,             /* 80 */
+    ReplyNotSwappd,                             /* 80 */
     ReplyNotSwappd,
     ReplyNotSwappd,
     (ReplySwapPtr) SListInstalledColormapsReply,
@@ -639,44 +804,44 @@ ReplySwapPtr ReplySwapVector[256] = {
     (ReplySwapPtr) SAllocColorPlanesReply,
     ReplyNotSwappd,
     ReplyNotSwappd,
-    ReplyNotSwappd,             /* 90 */
+    ReplyNotSwappd,                             /* 90 */
     (ReplySwapPtr) SQueryColorsReply,
     (ReplySwapPtr) SLookupColorReply,
     ReplyNotSwappd,
     ReplyNotSwappd,
-    ReplyNotSwappd,             /* 95 */
+    ReplyNotSwappd,                             /* 95 */
     ReplyNotSwappd,
     (ReplySwapPtr) SQueryBestSizeReply,
-    (ReplySwapPtr) SGenericReply,       /* SQueryExtensionReply, */
+    (ReplySwapPtr) SGenericReply,               /* SQueryExtensionReply, */
     (ReplySwapPtr) SListExtensionsReply,
-    ReplyNotSwappd,             /* 100 */
+    ReplyNotSwappd,                             /* 100 */
     (ReplySwapPtr) SGetKeyboardMappingReply,
     ReplyNotSwappd,
     (ReplySwapPtr) SGetKeyboardControlReply,
     ReplyNotSwappd,
-    ReplyNotSwappd,             /* 105 */
+    ReplyNotSwappd,                             /* 105 */
     (ReplySwapPtr) SGetPointerControlReply,
     ReplyNotSwappd,
     (ReplySwapPtr) SGetScreenSaverReply,
     ReplyNotSwappd,
-    (ReplySwapPtr) SListHostsReply,     /* 110 */
+    (ReplySwapPtr) SListHostsReply,             /* 110 */
     ReplyNotSwappd,
     ReplyNotSwappd,
     ReplyNotSwappd,
     ReplyNotSwappd,
-    ReplyNotSwappd,             /* 115 */
-    (ReplySwapPtr) SGenericReply,       /* SetPointerMapping */
+    ReplyNotSwappd,                             /* 115 */
+    (ReplySwapPtr) SGenericReply,               /* SetPointerMapping */
     (ReplySwapPtr) SGetPointerMappingReply,
-    (ReplySwapPtr) SGenericReply,       /* SetModifierMapping */
+    (ReplySwapPtr) SGenericReply,               /* SetModifierMapping */
     (ReplySwapPtr) SGetModifierMappingReply,    /* 119 */
-    ReplyNotSwappd,             /* 120 */
-    ReplyNotSwappd,             /* 121 */
-    ReplyNotSwappd,             /* 122 */
-    ReplyNotSwappd,             /* 123 */
-    ReplyNotSwappd,             /* 124 */
-    ReplyNotSwappd,             /* 125 */
-    ReplyNotSwappd,             /* 126 */
-    ReplyNotSwappd,             /* NoOperation */
+    ReplyNotSwappd,                             /* 120 */
+    ReplyNotSwappd,                             /* 121 */
+    ReplyNotSwappd,                             /* 122 */
+    ReplyNotSwappd,                             /* 123 */
+    ReplyNotSwappd,                             /* 124 */
+    ReplyNotSwappd,                             /* 125 */
+    ReplyNotSwappd,                             /* 126 */
+    ReplyNotSwappd,                             /* NoOperation */
     ReplyNotSwappd,
     ReplyNotSwappd,
     ReplyNotSwappd,
commit 9f7ef7f7f0566f6319d8328ce0a1e6d0fa866720
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Mon Jul 16 20:53:00 2012 -0700

    Fix up formatting of initializers for arrays of structs
    
    The indenter seems to have gotten confused by initializing arrays of
    structs with the struct defined inline - for predefined structs it did
    a better job, so match that.
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/Xi/extinit.c b/Xi/extinit.c
index eac2586..7e30755 100644
--- a/Xi/extinit.c
+++ b/Xi/extinit.c
@@ -158,25 +158,25 @@ static struct dev_type {
     Atom type;
     const char *name;
 } dev_type[] = {
-    {
-    0, XI_KEYBOARD}, {
-    0, XI_MOUSE}, {
-    0, XI_TABLET}, {
-    0, XI_TOUCHSCREEN}, {
-    0, XI_TOUCHPAD}, {
-    0, XI_BARCODE}, {
-    0, XI_BUTTONBOX}, {
-    0, XI_KNOB_BOX}, {
-    0, XI_ONE_KNOB}, {
-    0, XI_NINE_KNOB}, {
-    0, XI_TRACKBALL}, {
-    0, XI_QUADRATURE}, {
-    0, XI_ID_MODULE}, {
-    0, XI_SPACEBALL}, {
-    0, XI_DATAGLOVE}, {
-    0, XI_EYETRACKER}, {
-    0, XI_CURSORKEYS}, {
-0, XI_FOOTMOUSE}};
+    {0, XI_KEYBOARD},
+    {0, XI_MOUSE},
+    {0, XI_TABLET},
+    {0, XI_TOUCHSCREEN},
+    {0, XI_TOUCHPAD},
+    {0, XI_BARCODE},
+    {0, XI_BUTTONBOX},
+    {0, XI_KNOB_BOX},
+    {0, XI_ONE_KNOB},
+    {0, XI_NINE_KNOB},
+    {0, XI_TRACKBALL},
+    {0, XI_QUADRATURE},
+    {0, XI_ID_MODULE},
+    {0, XI_SPACEBALL},
+    {0, XI_DATAGLOVE},
+    {0, XI_EYETRACKER},
+    {0, XI_CURSORKEYS},
+    {0, XI_FOOTMOUSE}
+};
 
 CARD8 event_base[numInputClasses];
 XExtEventInfo EventInfo[32];
diff --git a/Xi/xiproperty.c b/Xi/xiproperty.c
index 4beedcf..43351bc 100644
--- a/Xi/xiproperty.c
+++ b/Xi/xiproperty.c
@@ -49,132 +49,131 @@ static struct dev_properties {
     Atom type;
     const char *name;
 } dev_properties[] = {
-    {
-    0, XI_PROP_ENABLED}, {
-    0, XI_PROP_XTEST_DEVICE}, {
-    0, XATOM_FLOAT}, {
-    0, ACCEL_PROP_PROFILE_NUMBER}, {
-    0, ACCEL_PROP_CONSTANT_DECELERATION}, {
-    0, ACCEL_PROP_ADAPTIVE_DECELERATION}, {
-    0, ACCEL_PROP_VELOCITY_SCALING}, {
-    0, AXIS_LABEL_PROP}, {
-    0, AXIS_LABEL_PROP_REL_X}, {
-    0, AXIS_LABEL_PROP_REL_Y}, {
-    0, AXIS_LABEL_PROP_REL_Z}, {
-    0, AXIS_LABEL_PROP_REL_RX}, {
-    0, AXIS_LABEL_PROP_REL_RY}, {
-    0, AXIS_LABEL_PROP_REL_RZ}, {
-    0, AXIS_LABEL_PROP_REL_HWHEEL}, {
-    0, AXIS_LABEL_PROP_REL_DIAL}, {
-    0, AXIS_LABEL_PROP_REL_WHEEL}, {
-    0, AXIS_LABEL_PROP_REL_MISC}, {
-    0, AXIS_LABEL_PROP_REL_VSCROLL}, {
-    0, AXIS_LABEL_PROP_REL_HSCROLL}, {
-    0, AXIS_LABEL_PROP_ABS_X}, {
-    0, AXIS_LABEL_PROP_ABS_Y}, {
-    0, AXIS_LABEL_PROP_ABS_Z}, {
-    0, AXIS_LABEL_PROP_ABS_RX}, {
-    0, AXIS_LABEL_PROP_ABS_RY}, {
-    0, AXIS_LABEL_PROP_ABS_RZ}, {
-    0, AXIS_LABEL_PROP_ABS_THROTTLE}, {
-    0, AXIS_LABEL_PROP_ABS_RUDDER}, {
-    0, AXIS_LABEL_PROP_ABS_WHEEL}, {
-    0, AXIS_LABEL_PROP_ABS_GAS}, {
-    0, AXIS_LABEL_PROP_ABS_BRAKE}, {
-    0, AXIS_LABEL_PROP_ABS_HAT0X}, {
-    0, AXIS_LABEL_PROP_ABS_HAT0Y}, {
-    0, AXIS_LABEL_PROP_ABS_HAT1X}, {
-    0, AXIS_LABEL_PROP_ABS_HAT1Y}, {
-    0, AXIS_LABEL_PROP_ABS_HAT2X}, {
-    0, AXIS_LABEL_PROP_ABS_HAT2Y}, {
-    0, AXIS_LABEL_PROP_ABS_HAT3X}, {
-    0, AXIS_LABEL_PROP_ABS_HAT3Y}, {
-    0, AXIS_LABEL_PROP_ABS_PRESSURE}, {
-    0, AXIS_LABEL_PROP_ABS_DISTANCE}, {
-    0, AXIS_LABEL_PROP_ABS_TILT_X}, {
-    0, AXIS_LABEL_PROP_ABS_TILT_Y}, {
-    0, AXIS_LABEL_PROP_ABS_TOOL_WIDTH}, {
-    0, AXIS_LABEL_PROP_ABS_VOLUME}, {
-    0, AXIS_LABEL_PROP_ABS_MT_TOUCH_MAJOR}, {
-    0, AXIS_LABEL_PROP_ABS_MT_TOUCH_MINOR}, {
-    0, AXIS_LABEL_PROP_ABS_MT_WIDTH_MAJOR}, {
-    0, AXIS_LABEL_PROP_ABS_MT_WIDTH_MINOR}, {
-    0, AXIS_LABEL_PROP_ABS_MT_ORIENTATION}, {
-    0, AXIS_LABEL_PROP_ABS_MT_POSITION_X}, {
-    0, AXIS_LABEL_PROP_ABS_MT_POSITION_Y}, {
-    0, AXIS_LABEL_PROP_ABS_MT_TOOL_TYPE}, {
-    0, AXIS_LABEL_PROP_ABS_MT_BLOB_ID}, {
-    0, AXIS_LABEL_PROP_ABS_MT_TRACKING_ID}, {
-    0, AXIS_LABEL_PROP_ABS_MT_PRESSURE}, {
-    0, AXIS_LABEL_PROP_ABS_MISC}, {
-    0, BTN_LABEL_PROP}, {
-    0, BTN_LABEL_PROP_BTN_UNKNOWN}, {
-    0, BTN_LABEL_PROP_BTN_WHEEL_UP}, {
-    0, BTN_LABEL_PROP_BTN_WHEEL_DOWN}, {
-    0, BTN_LABEL_PROP_BTN_HWHEEL_LEFT}, {
-    0, BTN_LABEL_PROP_BTN_HWHEEL_RIGHT}, {
-    0, BTN_LABEL_PROP_BTN_0}, {
-    0, BTN_LABEL_PROP_BTN_1}, {
-    0, BTN_LABEL_PROP_BTN_2}, {
-    0, BTN_LABEL_PROP_BTN_3}, {
-    0, BTN_LABEL_PROP_BTN_4}, {
-    0, BTN_LABEL_PROP_BTN_5}, {
-    0, BTN_LABEL_PROP_BTN_6}, {
-    0, BTN_LABEL_PROP_BTN_7}, {
-    0, BTN_LABEL_PROP_BTN_8}, {
-    0, BTN_LABEL_PROP_BTN_9}, {
-    0, BTN_LABEL_PROP_BTN_LEFT}, {
-    0, BTN_LABEL_PROP_BTN_RIGHT}, {
-    0, BTN_LABEL_PROP_BTN_MIDDLE}, {
-    0, BTN_LABEL_PROP_BTN_SIDE}, {
-    0, BTN_LABEL_PROP_BTN_EXTRA}, {
-    0, BTN_LABEL_PROP_BTN_FORWARD}, {
-    0, BTN_LABEL_PROP_BTN_BACK}, {
-    0, BTN_LABEL_PROP_BTN_TASK}, {
-    0, BTN_LABEL_PROP_BTN_TRIGGER}, {
-    0, BTN_LABEL_PROP_BTN_THUMB}, {
-    0, BTN_LABEL_PROP_BTN_THUMB2}, {
-    0, BTN_LABEL_PROP_BTN_TOP}, {
-    0, BTN_LABEL_PROP_BTN_TOP2}, {
-    0, BTN_LABEL_PROP_BTN_PINKIE}, {
-    0, BTN_LABEL_PROP_BTN_BASE}, {
-    0, BTN_LABEL_PROP_BTN_BASE2}, {
-    0, BTN_LABEL_PROP_BTN_BASE3}, {
-    0, BTN_LABEL_PROP_BTN_BASE4}, {
-    0, BTN_LABEL_PROP_BTN_BASE5}, {
-    0, BTN_LABEL_PROP_BTN_BASE6}, {
-    0, BTN_LABEL_PROP_BTN_DEAD}, {
-    0, BTN_LABEL_PROP_BTN_A}, {
-    0, BTN_LABEL_PROP_BTN_B}, {
-    0, BTN_LABEL_PROP_BTN_C}, {
-    0, BTN_LABEL_PROP_BTN_X}, {
-    0, BTN_LABEL_PROP_BTN_Y}, {
-    0, BTN_LABEL_PROP_BTN_Z}, {
-    0, BTN_LABEL_PROP_BTN_TL}, {
-    0, BTN_LABEL_PROP_BTN_TR}, {
-    0, BTN_LABEL_PROP_BTN_TL2}, {
-    0, BTN_LABEL_PROP_BTN_TR2}, {
-    0, BTN_LABEL_PROP_BTN_SELECT}, {
-    0, BTN_LABEL_PROP_BTN_START}, {
-    0, BTN_LABEL_PROP_BTN_MODE}, {
-    0, BTN_LABEL_PROP_BTN_THUMBL}, {
-    0, BTN_LABEL_PROP_BTN_THUMBR}, {
-    0, BTN_LABEL_PROP_BTN_TOOL_PEN}, {
-    0, BTN_LABEL_PROP_BTN_TOOL_RUBBER}, {
-    0, BTN_LABEL_PROP_BTN_TOOL_BRUSH}, {
-    0, BTN_LABEL_PROP_BTN_TOOL_PENCIL}, {
-    0, BTN_LABEL_PROP_BTN_TOOL_AIRBRUSH}, {
-    0, BTN_LABEL_PROP_BTN_TOOL_FINGER}, {
-    0, BTN_LABEL_PROP_BTN_TOOL_MOUSE}, {
-    0, BTN_LABEL_PROP_BTN_TOOL_LENS}, {
-    0, BTN_LABEL_PROP_BTN_TOUCH}, {
-    0, BTN_LABEL_PROP_BTN_STYLUS}, {
-    0, BTN_LABEL_PROP_BTN_STYLUS2}, {
-    0, BTN_LABEL_PROP_BTN_TOOL_DOUBLETAP}, {
-    0, BTN_LABEL_PROP_BTN_TOOL_TRIPLETAP}, {
-    0, BTN_LABEL_PROP_BTN_GEAR_DOWN}, {
-    0, BTN_LABEL_PROP_BTN_GEAR_UP}, {
-    0, XI_PROP_TRANSFORM}
+    {0, XI_PROP_ENABLED},
+    {0, XI_PROP_XTEST_DEVICE},
+    {0, XATOM_FLOAT},
+    {0, ACCEL_PROP_PROFILE_NUMBER},
+    {0, ACCEL_PROP_CONSTANT_DECELERATION},
+    {0, ACCEL_PROP_ADAPTIVE_DECELERATION},
+    {0, ACCEL_PROP_VELOCITY_SCALING},
+    {0, AXIS_LABEL_PROP},
+    {0, AXIS_LABEL_PROP_REL_X},
+    {0, AXIS_LABEL_PROP_REL_Y},
+    {0, AXIS_LABEL_PROP_REL_Z},
+    {0, AXIS_LABEL_PROP_REL_RX},
+    {0, AXIS_LABEL_PROP_REL_RY},
+    {0, AXIS_LABEL_PROP_REL_RZ},
+    {0, AXIS_LABEL_PROP_REL_HWHEEL},
+    {0, AXIS_LABEL_PROP_REL_DIAL},
+    {0, AXIS_LABEL_PROP_REL_WHEEL},
+    {0, AXIS_LABEL_PROP_REL_MISC},
+    {0, AXIS_LABEL_PROP_REL_VSCROLL},
+    {0, AXIS_LABEL_PROP_REL_HSCROLL},
+    {0, AXIS_LABEL_PROP_ABS_X},
+    {0, AXIS_LABEL_PROP_ABS_Y},
+    {0, AXIS_LABEL_PROP_ABS_Z},
+    {0, AXIS_LABEL_PROP_ABS_RX},
+    {0, AXIS_LABEL_PROP_ABS_RY},
+    {0, AXIS_LABEL_PROP_ABS_RZ},
+    {0, AXIS_LABEL_PROP_ABS_THROTTLE},
+    {0, AXIS_LABEL_PROP_ABS_RUDDER},
+    {0, AXIS_LABEL_PROP_ABS_WHEEL},
+    {0, AXIS_LABEL_PROP_ABS_GAS},
+    {0, AXIS_LABEL_PROP_ABS_BRAKE},
+    {0, AXIS_LABEL_PROP_ABS_HAT0X},
+    {0, AXIS_LABEL_PROP_ABS_HAT0Y},
+    {0, AXIS_LABEL_PROP_ABS_HAT1X},
+    {0, AXIS_LABEL_PROP_ABS_HAT1Y},
+    {0, AXIS_LABEL_PROP_ABS_HAT2X},
+    {0, AXIS_LABEL_PROP_ABS_HAT2Y},
+    {0, AXIS_LABEL_PROP_ABS_HAT3X},
+    {0, AXIS_LABEL_PROP_ABS_HAT3Y},
+    {0, AXIS_LABEL_PROP_ABS_PRESSURE},
+    {0, AXIS_LABEL_PROP_ABS_DISTANCE},
+    {0, AXIS_LABEL_PROP_ABS_TILT_X},
+    {0, AXIS_LABEL_PROP_ABS_TILT_Y},
+    {0, AXIS_LABEL_PROP_ABS_TOOL_WIDTH},
+    {0, AXIS_LABEL_PROP_ABS_VOLUME},
+    {0, AXIS_LABEL_PROP_ABS_MT_TOUCH_MAJOR},
+    {0, AXIS_LABEL_PROP_ABS_MT_TOUCH_MINOR},
+    {0, AXIS_LABEL_PROP_ABS_MT_WIDTH_MAJOR},
+    {0, AXIS_LABEL_PROP_ABS_MT_WIDTH_MINOR},
+    {0, AXIS_LABEL_PROP_ABS_MT_ORIENTATION},
+    {0, AXIS_LABEL_PROP_ABS_MT_POSITION_X},
+    {0, AXIS_LABEL_PROP_ABS_MT_POSITION_Y},
+    {0, AXIS_LABEL_PROP_ABS_MT_TOOL_TYPE},
+    {0, AXIS_LABEL_PROP_ABS_MT_BLOB_ID},
+    {0, AXIS_LABEL_PROP_ABS_MT_TRACKING_ID},
+    {0, AXIS_LABEL_PROP_ABS_MT_PRESSURE},
+    {0, AXIS_LABEL_PROP_ABS_MISC},
+    {0, BTN_LABEL_PROP},
+    {0, BTN_LABEL_PROP_BTN_UNKNOWN},
+    {0, BTN_LABEL_PROP_BTN_WHEEL_UP},
+    {0, BTN_LABEL_PROP_BTN_WHEEL_DOWN},
+    {0, BTN_LABEL_PROP_BTN_HWHEEL_LEFT},
+    {0, BTN_LABEL_PROP_BTN_HWHEEL_RIGHT},
+    {0, BTN_LABEL_PROP_BTN_0},
+    {0, BTN_LABEL_PROP_BTN_1},
+    {0, BTN_LABEL_PROP_BTN_2},
+    {0, BTN_LABEL_PROP_BTN_3},
+    {0, BTN_LABEL_PROP_BTN_4},
+    {0, BTN_LABEL_PROP_BTN_5},
+    {0, BTN_LABEL_PROP_BTN_6},
+    {0, BTN_LABEL_PROP_BTN_7},
+    {0, BTN_LABEL_PROP_BTN_8},
+    {0, BTN_LABEL_PROP_BTN_9},
+    {0, BTN_LABEL_PROP_BTN_LEFT},
+    {0, BTN_LABEL_PROP_BTN_RIGHT},
+    {0, BTN_LABEL_PROP_BTN_MIDDLE},
+    {0, BTN_LABEL_PROP_BTN_SIDE},
+    {0, BTN_LABEL_PROP_BTN_EXTRA},
+    {0, BTN_LABEL_PROP_BTN_FORWARD},
+    {0, BTN_LABEL_PROP_BTN_BACK},
+    {0, BTN_LABEL_PROP_BTN_TASK},
+    {0, BTN_LABEL_PROP_BTN_TRIGGER},
+    {0, BTN_LABEL_PROP_BTN_THUMB},
+    {0, BTN_LABEL_PROP_BTN_THUMB2},
+    {0, BTN_LABEL_PROP_BTN_TOP},
+    {0, BTN_LABEL_PROP_BTN_TOP2},
+    {0, BTN_LABEL_PROP_BTN_PINKIE},
+    {0, BTN_LABEL_PROP_BTN_BASE},
+    {0, BTN_LABEL_PROP_BTN_BASE2},
+    {0, BTN_LABEL_PROP_BTN_BASE3},
+    {0, BTN_LABEL_PROP_BTN_BASE4},
+    {0, BTN_LABEL_PROP_BTN_BASE5},
+    {0, BTN_LABEL_PROP_BTN_BASE6},
+    {0, BTN_LABEL_PROP_BTN_DEAD},
+    {0, BTN_LABEL_PROP_BTN_A},
+    {0, BTN_LABEL_PROP_BTN_B},
+    {0, BTN_LABEL_PROP_BTN_C},
+    {0, BTN_LABEL_PROP_BTN_X},
+    {0, BTN_LABEL_PROP_BTN_Y},
+    {0, BTN_LABEL_PROP_BTN_Z},
+    {0, BTN_LABEL_PROP_BTN_TL},
+    {0, BTN_LABEL_PROP_BTN_TR},
+    {0, BTN_LABEL_PROP_BTN_TL2},
+    {0, BTN_LABEL_PROP_BTN_TR2},
+    {0, BTN_LABEL_PROP_BTN_SELECT},
+    {0, BTN_LABEL_PROP_BTN_START},
+    {0, BTN_LABEL_PROP_BTN_MODE},
+    {0, BTN_LABEL_PROP_BTN_THUMBL},
+    {0, BTN_LABEL_PROP_BTN_THUMBR},
+    {0, BTN_LABEL_PROP_BTN_TOOL_PEN},
+    {0, BTN_LABEL_PROP_BTN_TOOL_RUBBER},
+    {0, BTN_LABEL_PROP_BTN_TOOL_BRUSH},
+    {0, BTN_LABEL_PROP_BTN_TOOL_PENCIL},
+    {0, BTN_LABEL_PROP_BTN_TOOL_AIRBRUSH},
+    {0, BTN_LABEL_PROP_BTN_TOOL_FINGER},
+    {0, BTN_LABEL_PROP_BTN_TOOL_MOUSE},
+    {0, BTN_LABEL_PROP_BTN_TOOL_LENS},
+    {0, BTN_LABEL_PROP_BTN_TOUCH},
+    {0, BTN_LABEL_PROP_BTN_STYLUS},
+    {0, BTN_LABEL_PROP_BTN_STYLUS2},
+    {0, BTN_LABEL_PROP_BTN_TOOL_DOUBLETAP},
+    {0, BTN_LABEL_PROP_BTN_TOOL_TRIPLETAP},
+    {0, BTN_LABEL_PROP_BTN_GEAR_DOWN},
+    {0, BTN_LABEL_PROP_BTN_GEAR_UP},
+    {0, XI_PROP_TRANSFORM}
 };
 
 static long XIPropHandlerID = 1;
diff --git a/config/wscons.c b/config/wscons.c
index 7a5e8cc..fb114bd 100644
--- a/config/wscons.c
+++ b/config/wscons.c
@@ -53,8 +53,10 @@ struct nameint {
     int val;
     char *name;
 } kbdenc[] = {
-    KB_OVRENC, KB_ENCTAB, {
-0}};
+    KB_OVRENC,
+    KB_ENCTAB,
+    {0}
+};
 
 struct nameint kbdvar[] = {
     {KB_NODEAD | KB_SG, "de_nodeadkeys"},
diff --git a/dix/gc.c b/dix/gc.c
index 60f54ec..f46e0dd 100644
--- a/dix/gc.c
+++ b/dix/gc.c
@@ -419,11 +419,11 @@ static const struct {
     RESTYPE type;
     Mask access_mode;
 } xidfields[] = {
-    {
-    GCTile, RT_PIXMAP, DixReadAccess}, {
-    GCStipple, RT_PIXMAP, DixReadAccess}, {
-    GCFont, RT_FONT, DixUseAccess}, {
-GCClipMask, RT_PIXMAP, DixReadAccess},};
+    {GCTile, RT_PIXMAP, DixReadAccess},
+    {GCStipple, RT_PIXMAP, DixReadAccess},
+    {GCFont, RT_FONT, DixUseAccess},
+    {GCClipMask, RT_PIXMAP, DixReadAccess},
+};
 
 int
 ChangeGCXIDs(ClientPtr client, GC * pGC, BITS32 mask, CARD32 *pC32)
diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index 4247d7b..e6520d0 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -415,23 +415,22 @@ ephyrRandRGetInfo(ScreenPtr pScreen, Rotation * rotations)
     struct {
         int width, height;
     } sizes[] = {
-        {
-        1600, 1200}, {
-        1400, 1050}, {
-        1280, 960}, {
-        1280, 1024}, {
-        1152, 864}, {
-        1024, 768}, {
-        832, 624}, {
-        800, 600}, {
-        720, 400}, {
-        480, 640}, {
-        640, 480}, {
-        640, 400}, {
-        320, 240}, {
-        240, 320}, {
-        160, 160}, {
-        0, 0}
+        {1600, 1200},
+        {1400, 1050},
+        {1280, 960},
+        {1280, 1024},
+        {1152, 864},
+        {1024, 768},
+        {832, 624},
+        {800, 600},
+        {720, 400},
+        {480, 640},
+        {640, 480},
+        {640, 400},
+        {320, 240},
+        {240, 320},
+        {160, 160},
+        {0, 0}
     };
 
     EPHYR_LOG("mark");
diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c
index a3b9434..7d9bf9d 100644
--- a/hw/kdrive/src/kdrive.c
+++ b/hw/kdrive/src/kdrive.c
@@ -730,22 +730,22 @@ KdSetSubpixelOrder(ScreenPtr pScreen, Rotation randr)
         int subpixel_order;
         Rotation direction;
     } orders[] = {
-        {
-        SubPixelHorizontalRGB, RR_Rotate_0}, {
-        SubPixelHorizontalBGR, RR_Rotate_180}, {
-        SubPixelVerticalRGB, RR_Rotate_270}, {
-    SubPixelVerticalBGR, RR_Rotate_90},};
+        {SubPixelHorizontalRGB, RR_Rotate_0},
+        {SubPixelHorizontalBGR, RR_Rotate_180},
+        {SubPixelVerticalRGB, RR_Rotate_270},
+        {SubPixelVerticalBGR, RR_Rotate_90},
+    };
 
     static struct {
         int bit;
         int normal;
         int reflect;
     } reflects[] = {
-        {
-        RR_Reflect_X, SubPixelHorizontalRGB, SubPixelHorizontalBGR}, {
-        RR_Reflect_X, SubPixelHorizontalBGR, SubPixelHorizontalRGB}, {
-        RR_Reflect_Y, SubPixelVerticalRGB, SubPixelVerticalBGR}, {
-    RR_Reflect_Y, SubPixelVerticalRGB, SubPixelVerticalRGB},};
+        {RR_Reflect_X, SubPixelHorizontalRGB, SubPixelHorizontalBGR},
+        {RR_Reflect_X, SubPixelHorizontalBGR, SubPixelHorizontalRGB},
+        {RR_Reflect_Y, SubPixelVerticalRGB, SubPixelVerticalBGR},
+        {RR_Reflect_Y, SubPixelVerticalRGB, SubPixelVerticalRGB},
+    };
 
     /* map subpixel to direction */
     for (i = 0; i < 4; i++)
diff --git a/hw/xfree86/loader/loader.c b/hw/xfree86/loader/loader.c
index 5fbea38..64c69bb 100644
--- a/hw/xfree86/loader/loader.c
+++ b/hw/xfree86/loader/loader.c
@@ -195,13 +195,12 @@ LoaderGetABIVersion(const char *abiclass)
         const char *name;
         int version;
     } classes[] = {
-        {
-        ABI_CLASS_ANSIC, LoaderVersionInfo.ansicVersion}, {
-        ABI_CLASS_VIDEODRV, LoaderVersionInfo.videodrvVersion}, {
-        ABI_CLASS_XINPUT, LoaderVersionInfo.xinputVersion}, {
-        ABI_CLASS_EXTENSION, LoaderVersionInfo.extensionVersion}, {
-        ABI_CLASS_FONT, LoaderVersionInfo.fontVersion}, {
-        NULL, 0}
+        {ABI_CLASS_ANSIC, LoaderVersionInfo.ansicVersion},
+        {ABI_CLASS_VIDEODRV, LoaderVersionInfo.videodrvVersion},
+        {ABI_CLASS_XINPUT, LoaderVersionInfo.xinputVersion},
+        {ABI_CLASS_EXTENSION, LoaderVersionInfo.extensionVersion},
+        {ABI_CLASS_FONT, LoaderVersionInfo.fontVersion},
+        {NULL, 0}
     };
     int i;
 
diff --git a/hw/xfree86/modes/xf86DisplayIDModes.c b/hw/xfree86/modes/xf86DisplayIDModes.c
index 781c806..bead126 100644
--- a/hw/xfree86/modes/xf86DisplayIDModes.c
+++ b/hw/xfree86/modes/xf86DisplayIDModes.c
@@ -184,105 +184,96 @@ static const struct did_dmt {
     short w, h, r, f;
 } did_dmt[] = {
     /* byte 3 */
-    {
-    640, 350, 85, 0}, {
-    640, 400, 85, 0}, {
-    720, 400, 85, 0}, {
-    640, 480, 60, 0}, {
-    640, 480, 72, 0}, {
-    640, 480, 75, 0}, {
-    640, 480, 85, 0}, {
-    800, 600, 56, 0},
+    {640, 350, 85, 0},
+    {640, 400, 85, 0},
+    {720, 400, 85, 0},
+    {640, 480, 60, 0},
+    {640, 480, 72, 0},
+    {640, 480, 75, 0},
+    {640, 480, 85, 0},
+    {800, 600, 56, 0},
         /* byte 4 */
-    {
-    800, 600, 60, 0}, {
-    800, 600, 72, 0}, {
-    800, 600, 75, 0}, {
-    800, 600, 85, 0}, {
-    800, 600, 120, RB}, {
-    848, 480, 60, 0}, {
-    1024, 768, 43, INT}, {
-    1024, 768, 60, 0},
+    {800, 600, 60, 0},
+    {800, 600, 72, 0},
+    {800, 600, 75, 0},
+    {800, 600, 85, 0},
+    {800, 600, 120, RB},
+    {848, 480, 60, 0},
+    {1024, 768, 43, INT},
+    {1024, 768, 60, 0},
         /* byte 5 */
-    {
-    1024, 768, 70, 0}, {
-    1024, 768, 75, 0}, {
-    1024, 768, 85, 0}, {
-    1024, 768, 120, RB}, {
-    1152, 864, 75, 0}, {
-    1280, 768, 60, RB}, {
-    1280, 768, 60, 0}, {
-    1280, 768, 75, 0},
+    {1024, 768, 70, 0},
+    {1024, 768, 75, 0},
+    {1024, 768, 85, 0},
+    {1024, 768, 120, RB},
+    {1152, 864, 75, 0},
+    {1280, 768, 60, RB},
+    {1280, 768, 60, 0},
+    {1280, 768, 75, 0},
         /* byte 6 */
-    {
-    1280, 768, 85, 0}, {
-    1280, 768, 120, RB}, {
-    1280, 800, 60, RB}, {
-    1280, 800, 60, 0}, {
-    1280, 800, 75, 0}, {
-    1280, 800, 85, 0}, {
-    1280, 800, 120, RB}, {
-    1280, 960, 60, 0},
+    {1280, 768, 85, 0},
+    {1280, 768, 120, RB},
+    {1280, 800, 60, RB},
+    {1280, 800, 60, 0},
+    {1280, 800, 75, 0},
+    {1280, 800, 85, 0},
+    {1280, 800, 120, RB},
+    {1280, 960, 60, 0},
         /* byte 7 */
-    {
-    1280, 960, 85, 0}, {
-    1280, 960, 120, RB}, {
-    1280, 1024, 60, 0}, {
-    1280, 1024, 75, 0}, {
-    1280, 1024, 85, 0}, {
-    1280, 1024, 120, RB}, {
-    1360, 768, 60, 0}, {
-    1360, 768, 120, RB},
+    {1280, 960, 85, 0},
+    {1280, 960, 120, RB},
+    {1280, 1024, 60, 0},
+    {1280, 1024, 75, 0},
+    {1280, 1024, 85, 0},
+    {1280, 1024, 120, RB},
+    {1360, 768, 60, 0},
+    {1360, 768, 120, RB},
         /* byte 8 */
-    {
-    1400, 1050, 60, RB}, {
-    1400, 1050, 60, 0}, {
-    1400, 1050, 75, 0}, {
-    1400, 1050, 85, 0}, {
-    1400, 1050, 120, RB}, {
-    1440, 900, 60, RB}, {
-    1440, 900, 60, 0}, {
-    1440, 900, 75, 0},
+    {1400, 1050, 60, RB},
+    {1400, 1050, 60, 0},
+    {1400, 1050, 75, 0},
+    {1400, 1050, 85, 0},
+    {1400, 1050, 120, RB},
+    {1440, 900, 60, RB},
+    {1440, 900, 60, 0},
+    {1440, 900, 75, 0},
         /* byte 9 */
-    {
-    1440, 900, 85, 0}, {
-    1440, 900, 120, RB}, {
-    1600, 1200, 60, 0}, {
-    1600, 1200, 65, 0}, {
-    1600, 1200, 70, 0}, {
-    1600, 1200, 75, 0}, {
-    1600, 1200, 85, 0}, {
-    1600, 1200, 120, RB},
+    {1440, 900, 85, 0},
+    {1440, 900, 120, RB},
+    {1600, 1200, 60, 0},
+    {1600, 1200, 65, 0},
+    {1600, 1200, 70, 0},
+    {1600, 1200, 75, 0},
+    {1600, 1200, 85, 0},
+    {1600, 1200, 120, RB},
         /* byte a */
-    {
-    1680, 1050, 60, RB}, {
-    1680, 1050, 60, 0}, {
-    1680, 1050, 75, 0}, {
-    1680, 1050, 85, 0}, {
-    1680, 1050, 120, RB}, {
-    1792, 1344, 60, 0}, {
-    1792, 1344, 75, 0}, {
-    1792, 1344, 120, RB},
+    {1680, 1050, 60, RB},
+    {1680, 1050, 60, 0},
+    {1680, 1050, 75, 0},
+    {1680, 1050, 85, 0},
+    {1680, 1050, 120, RB},
+    {1792, 1344, 60, 0},
+    {1792, 1344, 75, 0},
+    {1792, 1344, 120, RB},
         /* byte b */
-    {
-    1856, 1392, 60, 0}, {
-    1856, 1392, 75, 0}, {
-    1856, 1392, 120, RB}, {
-    1920, 1200, 60, RB}, {
-    1920, 1200, 60, 0}, {
-    1920, 1200, 75, 0}, {
-    1920, 1200, 85, 0}, {
-    1920, 1200, 120, RB},
+    {1856, 1392, 60, 0},
+    {1856, 1392, 75, 0},
+    {1856, 1392, 120, RB},
+    {1920, 1200, 60, RB},
+    {1920, 1200, 60, 0},
+    {1920, 1200, 75, 0},
+    {1920, 1200, 85, 0},
+    {1920, 1200, 120, RB},
         /* byte c */
-    {
-    1920, 1440, 60, 0}, {
-    1920, 1440, 75, 0}, {
-    1920, 1440, 120, RB}, {
-    2560, 1600, 60, RB}, {
-    2560, 1600, 60, 0}, {
-    2560, 1600, 75, 0}, {
-    2560, 1600, 85, 0}, {
-2560, 1600, 120, RB},};
+    {1920, 1440, 60, 0},
+    {1920, 1440, 75, 0},
+    {1920, 1440, 120, RB},
+    {2560, 1600, 60, RB},
+    {2560, 1600, 60, 0},
+    {2560, 1600, 75, 0},
+    {2560, 1600, 85, 0},
+    {2560, 1600, 120, RB},
+};
 
 static void
 didVesaTiming(int scrn, unsigned char *x, MonPtr mon)
diff --git a/hw/xfree86/modes/xf86EdidModes.c b/hw/xfree86/modes/xf86EdidModes.c
index 258ada5..4ee862d 100644
--- a/hw/xfree86/modes/xf86EdidModes.c
+++ b/hw/xfree86/modes/xf86EdidModes.c
@@ -513,14 +513,14 @@ DDCModeDoInterlaceQuirks(DisplayModePtr mode)
     static const struct {
         int w, h;
     } cea_interlaced[] = {
-        {
-        1920, 1080}, {
-        720, 480}, {
-        1440, 480}, {
-        2880, 480}, {
-        720, 576}, {
-        1440, 576}, {
-    2880, 576},};
+        {1920, 1080},
+        {720, 480},
+        {1440, 480},
+        {2880, 480},
+        {720, 576},
+        {1440, 576},
+        {2880, 576},
+    };
     static const int n_modes =
         sizeof(cea_interlaced) / sizeof(cea_interlaced[0]);
     int i;
@@ -668,68 +668,62 @@ static const struct {
     short r;
     short rb;
 } EstIIIModes[] = {
-    /* byte 6 */
-    {
-    640, 350, 85, 0}, {
-    640, 400, 85, 0}, {
-    720, 400, 85, 0}, {
-    640, 480, 85, 0}, {
-    848, 480, 60, 0}, {
-    800, 600, 85, 0}, {
-    1024, 768, 85, 0}, {
-    1152, 864, 75, 0},
+        /* byte 6 */
+    {640, 350, 85, 0},
+    {640, 400, 85, 0},
+    {720, 400, 85, 0},
+    {640, 480, 85, 0},
+    {848, 480, 60, 0},
+    {800, 600, 85, 0},
+    {1024, 768, 85, 0},
+    {1152, 864, 75, 0},
         /* byte 7 */
-    {
-    1280, 768, 60, 1}, {
-    1280, 768, 60, 0}, {
-    1280, 768, 75, 0}, {
-    1280, 768, 85, 0}, {
-    1280, 960, 60, 0}, {
-    1280, 960, 85, 0}, {
-    1280, 1024, 60, 0}, {
-    1280, 1024, 85, 0},
+    {1280, 768, 60, 1},
+    {1280, 768, 60, 0},
+    {1280, 768, 75, 0},
+    {1280, 768, 85, 0},
+    {1280, 960, 60, 0},
+    {1280, 960, 85, 0},
+    {1280, 1024, 60, 0},
+    {1280, 1024, 85, 0},
         /* byte 8 */
-    {
-    1360, 768, 60, 0}, {
-    1440, 900, 60, 1}, {
-    1440, 900, 60, 0}, {
-    1440, 900, 75, 0}, {
-    1440, 900, 85, 0}, {
-    1400, 1050, 60, 1}, {
-    1400, 1050, 60, 0}, {
-    1400, 1050, 75, 0},
+    {1360, 768, 60, 0},
+    {1440, 900, 60, 1},
+    {1440, 900, 60, 0},
+    {1440, 900, 75, 0},
+    {1440, 900, 85, 0},
+    {1400, 1050, 60, 1},
+    {1400, 1050, 60, 0},
+    {1400, 1050, 75, 0},
         /* byte 9 */
-    {
-    1400, 1050, 85, 0}, {
-    1680, 1050, 60, 1}, {
-    1680, 1050, 60, 0}, {
-    1680, 1050, 75, 0}, {
-    1680, 1050, 85, 0}, {
-    1600, 1200, 60, 0}, {
-    1600, 1200, 65, 0}, {
-    1600, 1200, 70, 0},
+    {1400, 1050, 85, 0},
+    {1680, 1050, 60, 1},
+    {1680, 1050, 60, 0},
+    {1680, 1050, 75, 0},
+    {1680, 1050, 85, 0},
+    {1600, 1200, 60, 0},
+    {1600, 1200, 65, 0},
+    {1600, 1200, 70, 0},
         /* byte 10 */
-    {
-    1600, 1200, 75, 0}, {
-    1600, 1200, 85, 0}, {
-    1792, 1344, 60, 0}, {
-    1792, 1344, 85, 0}, {
-    1856, 1392, 60, 0}, {
-    1856, 1392, 75, 0}, {
-    1920, 1200, 60, 1}, {
-    1920, 1200, 60, 0},
+    {1600, 1200, 75, 0},
+    {1600, 1200, 85, 0},
+    {1792, 1344, 60, 0},
+    {1792, 1344, 85, 0},
+    {1856, 1392, 60, 0},
+    {1856, 1392, 75, 0},
+    {1920, 1200, 60, 1},
+    {1920, 1200, 60, 0},
         /* byte 11 */
-    {
-    1920, 1200, 75, 0}, {
-    1920, 1200, 85, 0}, {
-    1920, 1440, 60, 0}, {
-    1920, 1440, 75, 0},
+    {1920, 1200, 75, 0},
+    {1920, 1200, 85, 0},
+    {1920, 1440, 60, 0},
+    {1920, 1440, 75, 0},
         /* fill up last byte */
-    {
-    0,0,0,0}, {
-    0,0,0,0}, {
-    0,0,0,0}, {
-    0,0,0,0}, };
+    {0,0,0,0},
+    {0,0,0,0},
+    {0,0,0,0},
+    {0,0,0,0},
+};
 
 static DisplayModePtr
 DDCModesFromEstIII(unsigned char *est)
diff --git a/hw/xfree86/os-support/bsd/bsd_apm.c b/hw/xfree86/os-support/bsd/bsd_apm.c
index a8a4164..b1938cf 100644
--- a/hw/xfree86/os-support/bsd/bsd_apm.c
+++ b/hw/xfree86/os-support/bsd/bsd_apm.c
@@ -21,21 +21,19 @@ static struct {
     u_int apmBsd;
     pmEvent xf86;
 } bsdToXF86Array[] = {
-    {
-    APM_STANDBY_REQ, XF86_APM_SYS_STANDBY}, {
-    APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND}, {
-    APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME}, {
-    APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME}, {
-    APM_BATTERY_LOW, XF86_APM_LOW_BATTERY}, {
-    APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE}, {
-    APM_UPDATE_TIME, XF86_APM_UPDATE_TIME}, {
-    APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND}, {
-    APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY}, {
-    APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND}, {
-    APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME},
+    {APM_STANDBY_REQ, XF86_APM_SYS_STANDBY},
+    {APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND},
+    {APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME},
+    {APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME},
+    {APM_BATTERY_LOW, XF86_APM_LOW_BATTERY},
+    {APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE},
+    {APM_UPDATE_TIME, XF86_APM_UPDATE_TIME},
+    {APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND},
+    {APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY},
+    {APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND},
+    {APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME},
 #ifdef APM_CAPABILITY_CHANGE
-    {
-    APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED},
+    {APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED},
 #endif
 };
 
diff --git a/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c b/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c
index 10251f3..2294385 100644
--- a/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c
+++ b/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c
@@ -54,21 +54,19 @@ static struct {
     u_int apmBsd;
     pmEvent xf86;
 } bsdToXF86Array[] = {
-    {
-    APM_STANDBY_REQ, XF86_APM_SYS_STANDBY}, {
-    APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND}, {
-    APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME}, {
-    APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME}, {
-    APM_BATTERY_LOW, XF86_APM_LOW_BATTERY}, {
-    APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE}, {
-    APM_UPDATE_TIME, XF86_APM_UPDATE_TIME}, {
-    APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND}, {
-    APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY}, {
-    APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND}, {
-    APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME},
+    {APM_STANDBY_REQ, XF86_APM_SYS_STANDBY},
+    {APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND},
+    {APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME},
+    {APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME},
+    {APM_BATTERY_LOW, XF86_APM_LOW_BATTERY},
+    {APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE},
+    {APM_UPDATE_TIME, XF86_APM_UPDATE_TIME},
+    {APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND},
+    {APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY},
+    {APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND},
+    {APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME},
 #ifdef APM_CAPABILITY_CHANGE
-    {
-    APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED},
+    {APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED},
 #endif
 };
 
diff --git a/hw/xfree86/os-support/bus/Sbus.c b/hw/xfree86/os-support/bus/Sbus.c
index b75308a..8260007 100644
--- a/hw/xfree86/os-support/bus/Sbus.c
+++ b/hw/xfree86/os-support/bus/Sbus.c
@@ -403,16 +403,16 @@ sparcPromAssignNodes(void)
             int devId;
             char *prefix;
         } procFbPrefixes[] = {
-            {
-            SBUS_DEVICE_BW2, "BWtwo"}, {
-            SBUS_DEVICE_CG14, "CGfourteen"}, {
-            SBUS_DEVICE_CG6, "CGsix"}, {
-            SBUS_DEVICE_CG3, "CGthree"}, {
-            SBUS_DEVICE_FFB, "Creator"}, {
-            SBUS_DEVICE_FFB, "Elite 3D"}, {
-            SBUS_DEVICE_LEO, "Leo"}, {
-            SBUS_DEVICE_TCX, "TCX"}, {
-        0, NULL},};
+            {SBUS_DEVICE_BW2, "BWtwo"},
+            {SBUS_DEVICE_CG14, "CGfourteen"},
+            {SBUS_DEVICE_CG6, "CGsix"},
+            {SBUS_DEVICE_CG3, "CGthree"},
+            {SBUS_DEVICE_FFB, "Creator"},
+            {SBUS_DEVICE_FFB, "Elite 3D"},
+            {SBUS_DEVICE_LEO, "Leo"},
+            {SBUS_DEVICE_TCX, "TCX"},
+            {0, NULL},
+        };
 
         while (fscanf(f, "%d %63s\n", &fbNum, buffer) == 2) {
             for (i = 0; procFbPrefixes[i].devId; i++)
diff --git a/hw/xfree86/os-support/linux/lnx_apm.c b/hw/xfree86/os-support/linux/lnx_apm.c
index a37331e..3879340 100644
--- a/hw/xfree86/os-support/linux/lnx_apm.c
+++ b/hw/xfree86/os-support/linux/lnx_apm.c
@@ -42,26 +42,23 @@ static struct {
     apm_event_t apmLinux;
     pmEvent xf86;
 } LinuxToXF86[] = {
-    {
-    APM_SYS_STANDBY, XF86_APM_SYS_STANDBY}, {
-    APM_SYS_SUSPEND, XF86_APM_SYS_SUSPEND}, {
-    APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME}, {
-    APM_CRITICAL_RESUME, XF86_APM_CRITICAL_RESUME}, {
-    APM_LOW_BATTERY, XF86_APM_LOW_BATTERY}, {
-    APM_POWER_STATUS_CHANGE, XF86_APM_POWER_STATUS_CHANGE}, {
-    APM_UPDATE_TIME, XF86_APM_UPDATE_TIME}, {
-    APM_CRITICAL_SUSPEND, XF86_APM_CRITICAL_SUSPEND}, {
-    APM_USER_STANDBY, XF86_APM_USER_STANDBY}, {
-    APM_USER_SUSPEND, XF86_APM_USER_SUSPEND}, {
-    APM_STANDBY_RESUME, XF86_APM_STANDBY_RESUME},
+    {APM_SYS_STANDBY, XF86_APM_SYS_STANDBY},
+    {APM_SYS_SUSPEND, XF86_APM_SYS_SUSPEND},
+    {APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME},
+    {APM_CRITICAL_RESUME, XF86_APM_CRITICAL_RESUME},
+    {APM_LOW_BATTERY, XF86_APM_LOW_BATTERY},
+    {APM_POWER_STATUS_CHANGE, XF86_APM_POWER_STATUS_CHANGE},
+    {APM_UPDATE_TIME, XF86_APM_UPDATE_TIME},
+    {APM_CRITICAL_SUSPEND, XF86_APM_CRITICAL_SUSPEND},
+    {APM_USER_STANDBY, XF86_APM_USER_STANDBY},
+    {APM_USER_SUSPEND, XF86_APM_USER_SUSPEND},
+    {APM_STANDBY_RESUME, XF86_APM_STANDBY_RESUME},
 #if defined(APM_CAPABILITY_CHANGED)
-    {
-    APM_CAPABILITY_CHANGED, XF86_CAPABILITY_CHANGED},
+    {APM_CAPABILITY_CHANGED, XF86_CAPABILITY_CHANGED},
 #endif
 #if 0
-    {
-    APM_STANDBY_FAILED, XF86_APM_STANDBY_FAILED}, {
-    APM_SUSPEND_FAILED, XF86_APM_SUSPEND_FAILED}
+    {APM_STANDBY_FAILED, XF86_APM_STANDBY_FAILED},
+    {APM_SUSPEND_FAILED, XF86_APM_SUSPEND_FAILED}
 #endif
 };
 
diff --git a/hw/xfree86/os-support/solaris/sun_apm.c b/hw/xfree86/os-support/solaris/sun_apm.c
index 4ff6464..b6a1432 100644
--- a/hw/xfree86/os-support/solaris/sun_apm.c
+++ b/hw/xfree86/os-support/solaris/sun_apm.c
@@ -97,21 +97,19 @@ static struct {
     u_int apmBsd;
     pmEvent xf86;
 } sunToXF86Array[] = {
-    {
-    APM_STANDBY_REQ, XF86_APM_SYS_STANDBY}, {
-    APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND}, {
-    APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME}, {
-    APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME}, {
-    APM_BATTERY_LOW, XF86_APM_LOW_BATTERY}, {
-    APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE}, {
-    APM_UPDATE_TIME, XF86_APM_UPDATE_TIME}, {
-    APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND}, {
-    APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY}, {
-    APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND}, {
-    APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME},
+    {APM_STANDBY_REQ, XF86_APM_SYS_STANDBY},
+    {APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND},
+    {APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME},
+    {APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME},
+    {APM_BATTERY_LOW, XF86_APM_LOW_BATTERY},
+    {APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE},
+    {APM_UPDATE_TIME, XF86_APM_UPDATE_TIME},
+    {APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND},
+    {APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY},
+    {APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND},
+    {APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME},
 #ifdef APM_CAPABILITY_CHANGE
-    {
-    APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED},
+    {APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED},
 #endif
 };
 
commit c7b7abfaa068042e396d19538215402cfbb4f1e4
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Sat Jul 14 11:21:15 2012 -0700

    RRModeCreate: plug memory leak of newModes if AddResource fails
    
    Reported by parfait 1.0:
    
    Error: Memory leak (CWE 401)
       Memory leak of pointer 'newModes' allocated with realloc(((char*)modes), ((num_modes + 1) * 8))
            at line 93 of randr/rrmode.c in function 'RRModeCreate'.
              pointer allocated at line 82 with realloc(((char*)modes), ((num_modes + 1) * 8)).
    Error: Memory leak (CWE 401)
       Memory leak of pointer 'newModes' allocated with malloc(8)
            at line 93 of randr/rrmode.c in function 'RRModeCreate'.
              pointer allocated at line 84 with malloc(8).
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/randr/rrmode.c b/randr/rrmode.c
index 56e5977..f5d3f9e 100644
--- a/randr/rrmode.c
+++ b/randr/rrmode.c
@@ -89,8 +89,10 @@ RRModeCreate(xRRModeInfo * modeInfo, const char *name, ScreenPtr userScreen)
     }
 
     mode->mode.id = FakeClientID(0);
-    if (!AddResource(mode->mode.id, RRModeType, (pointer) mode))
+    if (!AddResource(mode->mode.id, RRModeType, (pointer) mode)) {
+        free(newModes);
         return NULL;
+    }
     modes = newModes;
     modes[num_modes++] = mode;
 
commit 1eb7be863353be2cf3e83738253eb60c5fe49d19
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Sat Jul 14 09:29:52 2012 -0700

    rrproperty.c: free newly allocated prop in more error paths
    
    Reported by parfait 1.0:
    
    Error: Memory leak (CWE 401)
       Memory leak of pointer 'prop' allocated with RRCreateOutputProperty(property)
            at line 220 of randr/rrproperty.c in function 'RRChangeOutputProperty'.
              'prop' allocated at line 154 with RRCreateOutputProperty(property).
              prop leaks when pending != 0 at line 160.
    Error: Memory leak (CWE 401)
       Memory leak of pointer 'prop' allocated with RRCreateOutputProperty(property)
            at line 346 of randr/rrproperty.c in function 'RRConfigureOutputProperty'.
              'prop' allocated at line 334 with RRCreateOutputProperty(property).
            at line 350 of randr/rrproperty.c in function 'RRConfigureOutputProperty'.
              'prop' allocated at line 334 with RRCreateOutputProperty(property).
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/randr/rrproperty.c b/randr/rrproperty.c
index 7f09092..67b5467 100644
--- a/randr/rrproperty.c
+++ b/randr/rrproperty.c
@@ -217,6 +217,8 @@ RRChangeOutputProperty(RROutputPtr output, Atom property, Atom type,
             !pScrPriv->rrOutputSetProperty(output->pScreen, output,
                                            prop->propertyName, &new_value)) {
             free(new_value.data);
+            if (add)
+                RRDestroyOutputProperty(prop);
             return BadValue;
         }
         free(prop_value->data);
@@ -342,12 +344,18 @@ RRConfigureOutputProperty(RROutputPtr output, Atom property,
     /*
      * ranges must have even number of values
      */
-    if (range && (num_values & 1))
+    if (range && (num_values & 1)) {
+        if (add)
+            RRDestroyOutputProperty(prop);
         return BadMatch;
+    }
 
     new_values = malloc(num_values * sizeof(INT32));
-    if (!new_values && num_values)
+    if (!new_values && num_values) {
+        if (add)
+            RRDestroyOutputProperty(prop);
         return BadAlloc;
+    }
     if (num_values)
         memcpy(new_values, values, num_values * sizeof(INT32));
 
commit 42e655de4d95cb108aec50efec6bbdb709bb13d7
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Tue Jul 10 23:29:53 2012 -0700

    rrproviderproperty.c: free newly allocated prop in more error paths
    
    Reported by parfait 1.0:
    
    Error: Memory leak (CWE 401)
       Memory leak of pointer 'prop' allocated with RRCreateProviderProperty(property)
            at line 221 of randr/rrproviderproperty.c in function 'RRChangeProviderProperty'.
              'prop' allocated at line 155 with RRCreateProviderProperty(property).
              prop leaks when pending != 0 at line 161.
    
    Error: Memory leak (CWE 401)
       Memory leak of pointer 'prop' allocated with RRCreateProviderProperty(property)
            at line 345 of randr/rrproviderproperty.c in function 'RRConfigureProviderProperty'.
              'prop' allocated at line 333 with RRCreateProviderProperty(property).
            at line 349 of randr/rrproviderproperty.c in function 'RRConfigureProviderProperty'.
              'prop' allocated at line 333 with RRCreateProviderProperty(property).
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/randr/rrproviderproperty.c b/randr/rrproviderproperty.c
index e0a814f..ab601da 100644
--- a/randr/rrproviderproperty.c
+++ b/randr/rrproviderproperty.c
@@ -216,6 +216,8 @@ RRChangeProviderProperty(RRProviderPtr provider, Atom property, Atom type,
         if (pending && pScrPriv->rrProviderSetProperty &&
             !pScrPriv->rrProviderSetProperty(provider->pScreen, provider,
                                            prop->propertyName, &new_value)) {
+            if (add)
+                RRDestroyProviderProperty(prop);
             free(new_value.data);
             return BadValue;
         }
@@ -342,12 +344,18 @@ RRConfigureProviderProperty(RRProviderPtr provider, Atom property,
     /*
      * ranges must have even number of values
      */
-    if (range && (num_values & 1))
+    if (range && (num_values & 1)) {
+        if (add)
+            RRDestroyProviderProperty(prop);
         return BadMatch;
+    }
 
     new_values = malloc(num_values * sizeof(INT32));
-    if (!new_values && num_values)
+    if (!new_values && num_values) {
+        if (add)
+            RRDestroyProviderProperty(prop);
         return BadAlloc;
+    }
     if (num_values)
         memcpy(new_values, values, num_values * sizeof(INT32));
 
commit 94b514d5e4b376d05e106eb3853da511256e8545
Merge: 7d87545 7328900
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Aug 6 15:13:17 2012 -0700

    Merge remote-tracking branch 'whot/for-keith'

commit 7d87545ba7395ade507cca7bdca7052b26ed18d8
Merge: ad707a7 988d7ac
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Aug 6 15:11:13 2012 -0700

    Merge remote-tracking branch 'jturney/master'

commit ad707a7dcc65c30e030c7600b54f734090e56a91
Merge: 5a51cb8 884f51e
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Aug 6 15:08:01 2012 -0700

    Merge remote-tracking branch 'jeremyhu/master'

commit 5a51cb86f39a6809305c403beea54c3625e36259
Author: Keith Packard <keithp at keithp.com>
Date:   Tue Jul 10 23:09:47 2012 -0700

    xfree86: When xf86CrtcCloseScreen is called, the randr CRTCs are gone
    
    The RandR CRTC structures are freed when their resource IDs are
    destroyed during server shut down, which is before the screen is
    closed. Calling back into RandR with stale pointers just segfaults the
    server.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Dave Airlie <airlied at redhat.com>
    Tested-by: Knut Petersen <knut_petersen at t-online.de>

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index dfce1d1..154f684 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -734,9 +734,6 @@ xf86CrtcCloseScreen(ScreenPtr screen)
     for (c = 0; c < config->num_crtc; c++) {
         xf86CrtcPtr crtc = config->crtc[c];
 
-        if (crtc->randr_crtc->scanout_pixmap)
-            RRCrtcDetachScanoutPixmap(crtc->randr_crtc);
-
         crtc->randr_crtc = NULL;
     }
     /* detach any providers */
commit 1bf81af4a6be1113bcc3b940ab264d5c9e0f0c5d
Author: Rui Matos <tiagomatos at gmail.com>
Date:   Mon Jul 30 14:32:12 2012 -0400

    xf86RandR12: Don't call ConstrainCursorHarder() if panning is enabled
    
    Panning is at odds with CRTC cursor confinement. This disables CRTC cursor
    confinement as long as panning is enabled.
    
    Fixes regression introduced in 56c90e29f04727c903bd0f084d23bf44eb1a0a11.
    
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Rui Matos <tiagomatos at gmail.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index 4be0ea3..3530abf 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -60,6 +60,9 @@ typedef struct _xf86RandR12Info {
      * See https://bugs.freedesktop.org/show_bug.cgi?id=21554
      */
     xf86EnterVTProc *orig_EnterVT;
+
+    Bool                         panning;
+    ConstrainCursorHarderProcPtr orig_ConstrainCursorHarder;
 } XF86RandRInfoRec, *XF86RandRInfoPtr;
 
 #ifdef RANDR_12_INTERFACE
@@ -665,6 +668,10 @@ xf86RandR12SetConfig(ScreenPtr pScreen,
     return TRUE;
 }
 
+#define PANNING_ENABLED(crtc)                                           \
+    ((crtc)->panningTotalArea.x2 > (crtc)->panningTotalArea.x1 ||       \
+     (crtc)->panningTotalArea.y2 > (crtc)->panningTotalArea.y1)
+
 static Bool
 xf86RandR12ScreenSetSize(ScreenPtr pScreen,
                          CARD16 width,
@@ -676,6 +683,7 @@ xf86RandR12ScreenSetSize(ScreenPtr pScreen,
     WindowPtr pRoot = pScreen->root;
     PixmapPtr pScrnPix;
     Bool ret = FALSE;
+    Bool panning = FALSE;
     int c;
 
     if (xf86RandR12Key) {
@@ -696,8 +704,7 @@ xf86RandR12ScreenSetSize(ScreenPtr pScreen,
     for (c = 0; c < config->num_crtc; c++) {
         xf86CrtcPtr crtc = config->crtc[c];
 
-        if (crtc->panningTotalArea.x2 > crtc->panningTotalArea.x1 ||
-            crtc->panningTotalArea.y2 > crtc->panningTotalArea.y1) {
+	if (PANNING_ENABLED (crtc)) {
             if (crtc->panningTotalArea.x2 > crtc->panningTrackingArea.x1)
                 crtc->panningTotalArea.x2 += width - pScreen->width;
             if (crtc->panningTotalArea.y2 > crtc->panningTrackingArea.y1)
@@ -708,6 +715,7 @@ xf86RandR12ScreenSetSize(ScreenPtr pScreen,
                 crtc->panningTrackingArea.y2 += height - pScreen->height;
             xf86RandR13VerifyPanningArea(crtc, width, height);
             xf86RandR13Pan(crtc, randrp->pointerX, randrp->pointerY);
+	    panning = TRUE;
         }
     }
 
@@ -903,6 +911,7 @@ xf86RandR12CloseScreen(ScreenPtr pScreen)
     randrp = XF86RANDRINFO(pScreen);
 #if RANDR_12_INTERFACE
     xf86ScreenToScrn(pScreen)->EnterVT = randrp->orig_EnterVT;
+    pScreen->ConstrainCursorHarder = randrp->orig_ConstrainCursorHarder;
 #endif
 
     free(randrp);
@@ -1216,6 +1225,7 @@ xf86RandR12CrtcSet(ScreenPtr pScreen,
             }
             xf86RandR13VerifyPanningArea(crtc, pScreen->width, pScreen->height);
             xf86RandR13Pan(crtc, randrp->pointerX, randrp->pointerY);
+            randrp->panning = PANNING_ENABLED (crtc);
             /*
              * Save the last successful setting for EnterVT
              */
@@ -1650,6 +1660,7 @@ xf86RandR13SetPanning(ScreenPtr pScreen,
     BoxRec oldTotalArea;
     BoxRec oldTrackingArea;
     INT16 oldBorder[4];
+    Bool oldPanning = randrp->panning;
 
     if (crtc->version < 2)
         return FALSE;
@@ -1667,6 +1678,7 @@ xf86RandR13SetPanning(ScreenPtr pScreen,
 
     if (xf86RandR13VerifyPanningArea(crtc, pScreen->width, pScreen->height)) {
         xf86RandR13Pan(crtc, randrp->pointerX, randrp->pointerY);
+        randrp->panning = PANNING_ENABLED (crtc);
         return TRUE;
     }
     else {
@@ -1674,6 +1686,7 @@ xf86RandR13SetPanning(ScreenPtr pScreen,
         memcpy(&crtc->panningTotalArea, &oldTotalArea, sizeof(BoxRec));
         memcpy(&crtc->panningTrackingArea, &oldTrackingArea, sizeof(BoxRec));
         memcpy(crtc->panningBorder, oldBorder, 4 * sizeof(INT16));
+        randrp->panning = oldPanning;
         return FALSE;
     }
 }
@@ -1762,8 +1775,6 @@ xf86RandR14ProviderSetOutputSource(ScreenPtr pScreen,
                                    RRProviderPtr provider,
                                    RRProviderPtr source_provider)
 {
-
-
     if (!source_provider) {
         if (provider->output_source) {
             ScreenPtr cmScreen = pScreen->current_master;
@@ -1859,6 +1870,21 @@ xf86CrtcSetScanoutPixmap(RRCrtcPtr randr_crtc, PixmapPtr pixmap)
     return crtc->funcs->set_scanout_pixmap(crtc, pixmap);
 }
 
+static void
+xf86RandR13ConstrainCursorHarder(DeviceIntPtr dev, ScreenPtr screen, int mode, int *x, int *y)
+{
+    XF86RandRInfoPtr randrp = XF86RANDRINFO(screen);
+
+    if (randrp->panning)
+        return;
+
+    if (randrp->orig_ConstrainCursorHarder) {
+        screen->ConstrainCursorHarder = randrp->orig_ConstrainCursorHarder;
+        screen->ConstrainCursorHarder(dev, screen, mode, x, y);
+        screen->ConstrainCursorHarder = xf86RandR13ConstrainCursorHarder;
+    }
+}
+
 static Bool
 xf86RandR12Init12(ScreenPtr pScreen)
 {
@@ -1895,6 +1921,10 @@ xf86RandR12Init12(ScreenPtr pScreen)
     randrp->orig_EnterVT = pScrn->EnterVT;
     pScrn->EnterVT = xf86RandR12EnterVT;
 
+    randrp->panning = FALSE;
+    randrp->orig_ConstrainCursorHarder = pScreen->ConstrainCursorHarder;
+    pScreen->ConstrainCursorHarder = xf86RandR13ConstrainCursorHarder;
+
     if (!xf86RandR12CreateObjects12(pScreen))
         return FALSE;
 
commit ff56f88616aa63797384c2c484b2bd0f194df96a
Author: Adam Jackson <ajax at redhat.com>
Date:   Mon Jul 30 14:32:11 2012 -0400

    randr: Fix up yet another corner case in preferred mode selection
    
    Let's say - purely for the sake of argument, mind you - that you had a
    server GPU with anemic memory bandwidth, and you walked up to it and
    plugged in a monitor that was 1920x1080 because that's what happened to
    be on the crash cart.  Say the memory bandwidth is such that anything
    larger than 1280x1024 gets filtered away.  Now you're in trouble,
    because the established timings section includes a 720x400 mode because
    that's what DOS 80x25 is, and that happens to just about match the
    physical aspect ratio.
    
    Instead let's reuse the logic from the existing aspect-match path: pick
    the larger mode of either the physical aspect ratio or 4:3.
    
    Reviewed-by: Julien Cristau <jcristau at debian.org>
    Signed-off-by: Adam Jackson <ajax at redhat.com>
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 2628409..dfce1d1 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -2073,12 +2073,13 @@ xf86TargetPreferred(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
 
     /*
      * If there's no preferred mode, but only one monitor, pick the
-     * biggest mode for its aspect ratio, assuming one exists.
+     * biggest mode for its aspect ratio or 4:3, assuming one exists.
      */
     if (!ret)
         do {
             int i = 0;
             float aspect = 0.0;
+            DisplayModePtr a = NULL, b = NULL;
 
             /* count the number of enabled outputs */
             for (i = 0, p = -1; nextEnabledOutput(config, enabled, &p); i++);
@@ -2092,8 +2093,11 @@ xf86TargetPreferred(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
                 aspect = (float) config->output[p]->mm_width /
                     (float) config->output[p]->mm_height;
 
+            a = bestModeForAspect(config, enabled, 4.0/3.0);
             if (aspect)
-                preferred_match[p] = bestModeForAspect(config, enabled, aspect);
+                b = bestModeForAspect(config, enabled, aspect);
+
+            preferred_match[p] = biggestMode(a, b);
 
             if (preferred_match[p])
                 ret = TRUE;
commit 531785dd746d64ef7f473a83ca73bb20e74b6fca
Author: Dave Airlie <airlied at redhat.com>
Date:   Mon Jul 30 14:32:10 2012 -0400

    kinput: allocate enough space for null character.
    
    This code wasn't allocating enough space and was assigning the NULL
    one past the end.
    
    Pointed out by coverity.
    
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Dave Airlie <airlied at redhat.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index b1068bb..d35dcf8 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -1034,7 +1034,7 @@ KdGetOptions(InputOption **options, char *string)
 
     if (strchr(string, '=')) {
         tam_key = (strchr(string, '=') - string);
-        key = strndup(string, tam_key);
+        key = strndup(string, tam_key + 1);
         if (!key)
             goto out;
 
commit 8843aed82e7d69422e7763a35832a2be8f26723f
Author: Vic Lee <llyzs at 163.com>
Date:   Mon Jul 30 14:32:09 2012 -0400

    ephyr: Resize screen automatically when parent window is resized
    
    Bugzilla: https://bugs.freedesktop.org/25804
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Vic Lee <llyzs at 163.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index a5225dc..4247d7b 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -558,6 +558,8 @@ ephyrRandRSetConfig(ScreenPtr pScreen,
     if (wasEnabled)
         KdEnableScreen(pScreen);
 
+    RRScreenSizeNotify(pScreen);
+
     return TRUE;
 
  bail4:
@@ -590,6 +592,43 @@ ephyrRandRInit(ScreenPtr pScreen)
     pScrPriv->rrSetConfig = ephyrRandRSetConfig;
     return TRUE;
 }
+
+static Bool
+ephyrResizeScreen (ScreenPtr           pScreen,
+                  int                  newwidth,
+                  int                  newheight)
+{
+    KdScreenPriv(pScreen);
+    KdScreenInfo *screen = pScreenPriv->screen;
+    RRScreenSize size = {0};
+    Bool ret;
+    int t;
+
+    if (screen->randr & (RR_Rotate_90|RR_Rotate_270)) {
+        t = newwidth;
+        newwidth = newheight;
+        newheight = t;
+    }
+
+    if (newwidth == screen->width && newheight == screen->height) {
+        return FALSE;
+    }
+
+    size.width = newwidth;
+    size.height = newheight;
+
+    ret = ephyrRandRSetConfig (pScreen, screen->randr, 0, &size);
+    if (ret) {
+        RROutputPtr output;
+
+        output = RRFirstOutput(pScreen);
+        if (!output)
+            return FALSE;
+        RROutputSetModes(output, NULL, 0, 0);
+    }
+
+    return ret;
+}
 #endif
 
 Bool
@@ -930,6 +969,14 @@ ephyrPoll(void)
             break;
 #endif                          /* XF86DRI */
 
+#ifdef RANDR
+        case EPHYR_EV_CONFIGURE:
+            ephyrResizeScreen(screenInfo.screens[ev.data.configure.screen],
+                              ev.data.configure.width,
+                              ev.data.configure.height);
+            break;
+#endif /* RANDR */
+
         default:
             break;
         }
diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index e13910b..02729d6 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -348,7 +348,8 @@ hostx_init(void)
         | PointerMotionMask
         | KeyPressMask
         | KeyReleaseMask
-        | ExposureMask;
+        | ExposureMask
+        | StructureNotifyMask;
 
     EPHYR_DBG("mark");
 
@@ -696,12 +697,14 @@ hostx_screen_init(EphyrScreenInfo screen,
     XResizeWindow(HostX.dpy, host_screen->win, width, height);
 
     /* Ask the WM to keep our size static */
-    size_hints = XAllocSizeHints();
-    size_hints->max_width = size_hints->min_width = width;
-    size_hints->max_height = size_hints->min_height = height;
-    size_hints->flags = PMinSize | PMaxSize;
-    XSetWMNormalHints(HostX.dpy, host_screen->win, size_hints);
-    XFree(size_hints);
+    if (host_screen->win_pre_existing == None) {
+        size_hints = XAllocSizeHints();
+        size_hints->max_width = size_hints->min_width = width;
+        size_hints->max_height = size_hints->min_height = height;
+        size_hints->flags = PMinSize | PMaxSize;
+        XSetWMNormalHints(HostX.dpy, host_screen->win, size_hints);
+        XFree(size_hints);
+    }
 
     XMapWindow(HostX.dpy, host_screen->win);
 
@@ -1004,6 +1007,22 @@ hostx_get_event(EphyrHostXEvent * ev)
             ev->data.key_up.scancode = xev.xkey.keycode;
             return 1;
 
+        case ConfigureNotify:
+        {
+            struct EphyrHostScreen *host_screen =
+                host_screen_from_window(xev.xconfigure.window);
+
+            if (host_screen && host_screen->win_pre_existing != None) {
+                ev->type = EPHYR_EV_CONFIGURE;
+                ev->data.configure.width = xev.xconfigure.width;
+                ev->data.configure.height = xev.xconfigure.height;
+                ev->data.configure.window = xev.xconfigure.window;
+                ev->data.configure.screen = host_screen->mynum;
+                return 1;
+            }
+
+            return 0;
+        }
         default:
             break;
 
diff --git a/hw/kdrive/ephyr/hostx.h b/hw/kdrive/ephyr/hostx.h
index d621711..31c4053 100644
--- a/hw/kdrive/ephyr/hostx.h
+++ b/hw/kdrive/ephyr/hostx.h
@@ -47,7 +47,8 @@ typedef enum EphyrHostXEventType {
     EPHYR_EV_MOUSE_RELEASE,
     EPHYR_EV_KEY_PRESS,
     EPHYR_EV_KEY_RELEASE,
-    EPHYR_EV_EXPOSE
+    EPHYR_EV_EXPOSE,
+    EPHYR_EV_CONFIGURE,
 } EphyrHostXEventType;
 
 /* I can't believe it's not a KeySymsRec. */
@@ -89,6 +90,13 @@ struct EphyrHostXEvent {
             int window;
         } expose;
 
+        struct configure {
+            int width;
+            int height;
+            int screen;
+            int window;
+        } configure;
+
     } data;
 
     int key_state;
commit b46bbafae6d0a8b3f2f7853d5c1475fc223b1ed6
Author: Adam Jackson <ajax at redhat.com>
Date:   Mon Jul 30 14:32:08 2012 -0400

    ephyr: Fix up some bizarre formatting
    
    Signed-off-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index 6988f16..e13910b 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -345,7 +345,10 @@ hostx_init(void)
     attr.event_mask =
         ButtonPressMask
         | ButtonReleaseMask
-        | PointerMotionMask | KeyPressMask | KeyReleaseMask | ExposureMask;
+        | PointerMotionMask
+        | KeyPressMask
+        | KeyReleaseMask
+        | ExposureMask;
 
     EPHYR_DBG("mark");
 
commit 7328900042b9c1312aed48753fd6054e64613e4c
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Mon Jul 30 23:37:06 2012 -0700

    XIChangeDeviceProperty: free newly allocated prop when SetProperty fails
    
    Reported by parfait 1.0:
    
    Error: Memory leak (CWE 401)
       Memory leak of pointer 'prop' allocated with XICreateDeviceProperty(property)
            at line 774 of Xi/xiproperty.c in function 'XIChangeDeviceProperty'.
              'prop' allocated at line 700 with XICreateDeviceProperty(property).
              prop leaks when handler != NULL at line 768
                  and handler->SetProperty != NULL at line 769
                  and checkonly != 0 at line 772
                  and rc != 0 at line 772.
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/Xi/xiproperty.c b/Xi/xiproperty.c
index ca73104..4beedcf 100644
--- a/Xi/xiproperty.c
+++ b/Xi/xiproperty.c
@@ -771,6 +771,8 @@ XIChangeDeviceProperty(DeviceIntPtr dev, Atom property, Atom type,
                                                   &new_value, checkonly);
                         if (checkonly && rc != Success) {
                             free(new_value.data);
+                            if (add)
+                                XIDestroyDeviceProperty(prop);
                             return rc;
                         }
                     }
commit 4dbbcdf64563cb95f83c04b2442cb7e868384264
Author: Daniel d'Andrada <daniel.dandrada at canonical.com>
Date:   Thu Jul 26 17:31:57 2012 -0300

    Do sent TouchEnd to listeners that don't own an accepted touch
    
    When the owner of a touch accepts it, the other listeners must
    receive a TouchEnd.
    
    Even though there's code implementing the logic above in
    ProcessTouchOwnershipEvent(), DeliverTouchEndEvent() was refusing to send
    those TouchEnd events in this situatuation.
    
    Signed-off-by: Daniel d'Andrada <daniel.dandrada at canonical.com>
    Reviewed-by: Chase Douglas <chase.douglas at canonical.com>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/Xi/exevents.c b/Xi/exevents.c
index 9f6ec84..494d07e 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1888,6 +1888,12 @@ DeliverTouchEndEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent *ev,
         if (normal_end)
             listener->state = LISTENER_HAS_END;
     }
+    else if (ev->device_event.flags & TOUCH_ACCEPT) {
+        /* Touch has been accepted by its owner, which is not this listener */
+        if (listener->state != LISTENER_HAS_END)
+            rc = DeliverOneTouchEvent(client, dev, ti, grab, win, ev);
+        listener->state = LISTENER_HAS_END;
+    }
 
  out:
     return rc;
commit 02d91ccb0955252153206061a44340f051077624
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Jun 21 15:42:17 2012 +1000

    test: always add DIX_LIB and OS_LIB on XORG builds
    
    With --disable-xorg, We also disabled a bunch of tests because of their
    perceived reliance on a DDX. The cause was libtool missing some object files
    that never ended up in libxservertest.la. Only the xfree86 test has a true
    dependency on XORG.
    
    DIX_LIB was pointing to dix.O (instead of libdix.la) when
    DTRACE_SPECIAL_OBJECTS was defined. libdix.la should be part of XSERVER_LIBS
    but dix.O is not a recognised libtool object, so it got skipped for
    libxservertest.a. Only in the XORG case would we add DIX_LIB and OS_LIB
    manually, thus forcing linkage with the dtrace-generated objects.
    
    Fixing this by packaging up the dtrace-generated files as part of
    libdix.la/libos.la doesn't work for Solaris (and possible others), so simply
    always force linkage against the DIX_LIB/OS_LIB in the case of dtrace objects.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Tested-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/test/Makefile.am b/test/Makefile.am
index aa018c9..34f53fc 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -23,11 +23,9 @@ INCLUDES += -I$(top_srcdir)/hw/xfree86/parser \
 endif
 TEST_LDADD=libxservertest.la $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS) $(GLX_SYS_LIBS)
 
-if XORG
 if SPECIAL_DTRACE_OBJECTS
 TEST_LDADD += $(OS_LIB) $(DIX_LIB)
 endif
-endif
 
 xkb_LDADD=$(TEST_LDADD)
 input_LDADD=$(TEST_LDADD)
commit 988d7ace19a009991a4528e783d1a94c2444c66a
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Thu Jul 5 09:38:44 2012 +0100

    glx: Do not report the GLX_INTEL_swap_event extension for indirect swrast
    
    Commit 84956ca4 bogusly adds GLX_INTEL_swap_event to the extensions reported
    by swrast.
    
    "DRI2 supports this now - and already enables it explicitly - but drisw does
    not and should not. Otherwise toolkits like clutter will only ever SwapBuffers
    once and wait forever for an event that's not coming."
    
    (A similar bug for direct swrast is already fixed in mesa commit 25620eb1)
    
    (Note that this may be papering over the cracks somewhat, as if we do report
    GLX_INTEL_swap_event, some clutter apps fail with GLXBadDrawable calling
    GLXChangeDrawableAttributes to change the setting of GLX_BUFFER_SWAP_COMPLETE_INTEL_MASK
    in the GLX_EVENT_MASK, apparently after the drawable is destroyed, which suggests
    a bug with GLXDrawable lifetimes)
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>

diff --git a/glx/glxscreens.c b/glx/glxscreens.c
index 386987e..037b037 100644
--- a/glx/glxscreens.c
+++ b/glx/glxscreens.c
@@ -174,7 +174,7 @@ static char GLXServerExtensions[] =
     "GLX_SGIS_multisample "
 #endif
     "GLX_SGIX_fbconfig "
-    "GLX_SGIX_pbuffer " "GLX_MESA_copy_sub_buffer " "GLX_INTEL_swap_event";
+    "GLX_SGIX_pbuffer " "GLX_MESA_copy_sub_buffer ";
 
 static Bool
 glxCloseScreen(ScreenPtr pScreen)
commit fd3d45c137bb849aa9030d732ea9277292e01d3d
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Thu Jul 5 09:34:24 2012 +0100

    glx: Don't note GLX_INTEL_swap_event as being required by GLX 1.4, it isn't.
    
    Don't note GLX_INTEL_swap_event as being required by GLX 1.4, it isn't.
    (This data is not currently used in the server)
    
    (A similar change is made in mesa commit d3f7597bc9f6d5)
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>

diff --git a/glx/extension_string.c b/glx/extension_string.c
index ee9864e..544ca1f 100644
--- a/glx/extension_string.c
+++ b/glx/extension_string.c
@@ -87,7 +87,7 @@ static const struct extension_info known_glx_extensions[] = {
     { GLX(SGIX_fbconfig),               VER(1,3), Y, },
     { GLX(SGIX_pbuffer),                VER(1,3), Y, },
     { GLX(SGIX_visual_select_group),    VER(0,0), Y, },
-    { GLX(INTEL_swap_event),            VER(1,4), N, },
+    { GLX(INTEL_swap_event),            VER(0,0), N, },
     { NULL }
     /* *INDENT-ON* */
 };
commit a8464dfa28dea78201e3e4398eb3bcb745e10087
Author: Colin Harrison <colin.harrison at virgin.net>
Date:   Sun Jul 22 13:15:02 2012 +0100

    os: Fix TMP fall-back in Win32TempDir()
    
    Fix Win32TempDir() in the case where we fell back to checking the TMP
    environment variable. It looks like this has been wrong since forever.
    
    Signed-off-by: Colin Harrison <colin.harrison at virgin.net>
    Reviewed-by: Jon TURNEY <jon.turney at dronecode.org.uk>

diff --git a/os/utils.c b/os/utils.c
index d902523..cdf5fd8 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -1583,7 +1583,7 @@ Win32TempDir()
     if (getenv("TEMP") != NULL)
         return getenv("TEMP");
     else if (getenv("TMP") != NULL)
-        return getenv("TEMP");
+        return getenv("TMP");
     else
         return "/tmp";
 }
commit f6e7b82acadfca8239edc0f7e72cd0f3f9cfc2c4
Author: Marc Haesen <marha at users.sourceforge.net>
Date:   Sat Jul 21 21:18:44 2012 +0100

    hw/xwin: Fixes to pixelFormat <-> fbConfig conversion in WGL mode
    
    Fix FIXME in fbConfigToPixelFormat() to correctly populate RGBA-mask shift
    parameters.  Also request colourindex pixelFormats correctly.
    
    Now that they are requested correctly, don't skip colorindex visuals when
    converting pixelFormats to fbConfigs.
    
    Populate transparent colour information when converting pixelFormat from
    DescribePixelFormats() to a fbConfig.
    
    Signed-off-by: Marc Haesen <marha at users.sourceforge.net>
    Reviewed-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/glx/indirect.c b/hw/xwin/glx/indirect.c
index 3f34146..97b6045 100644
--- a/hw/xwin/glx/indirect.c
+++ b/hw/xwin/glx/indirect.c
@@ -1626,6 +1626,18 @@ glxWinCreateContext(__GLXscreen * screen,
  */
 
 static int
+GetShift(int Mask)
+{
+    int Shift = 0;
+
+    while ((Mask &1) == 0) {
+        Shift++;
+        Mask >>=1;
+    }
+    return Shift;
+}
+
+static int
 fbConfigToPixelFormat(__GLXconfig * mode, PIXELFORMATDESCRIPTOR * pfdret,
                       int drawableTypeOverride)
 {
@@ -1661,16 +1673,26 @@ fbConfigToPixelFormat(__GLXconfig * mode, PIXELFORMATDESCRIPTOR * pfdret,
         pfd.dwFlags |= PFD_DOUBLEBUFFER;
     }
 
-    pfd.iPixelType = PFD_TYPE_RGBA;
     pfd.cColorBits = mode->redBits + mode->greenBits + mode->blueBits;
     pfd.cRedBits = mode->redBits;
-    pfd.cRedShift = 0;          /* FIXME */
+    pfd.cRedShift = GetShift(mode->redMask);
     pfd.cGreenBits = mode->greenBits;
-    pfd.cGreenShift = 0;        /* FIXME  */
+    pfd.cGreenShift = GetShift(mode->greenMask);
     pfd.cBlueBits = mode->blueBits;
-    pfd.cBlueShift = 0;         /* FIXME */
+    pfd.cBlueShift = GetShift(mode->blueMask);
     pfd.cAlphaBits = mode->alphaBits;
-    pfd.cAlphaShift = 0;        /* FIXME */
+    pfd.cAlphaShift = GetShift(mode->alphaMask);
+
+    if (mode->visualType == GLX_TRUE_COLOR) {
+        pfd.iPixelType = PFD_TYPE_RGBA;
+        pfd.dwVisibleMask =
+            (pfd.cRedBits << pfd.cRedShift) | (pfd.cGreenBits << pfd.cGreenShift) |
+            (pfd.cBlueBits << pfd.cBlueShift) | (pfd.cAlphaBits << pfd.cAlphaShift);
+    }
+    else {
+        pfd.iPixelType = PFD_TYPE_COLORINDEX;
+        pfd.dwVisibleMask = mode->transparentIndex;
+    }
 
     pfd.cAccumBits =
         mode->accumRedBits + mode->accumGreenBits + mode->accumBlueBits +
@@ -1910,25 +1932,27 @@ glxWinCreateConfigs(HDC hdc, glxWinScreen * screen)
         /* EXT_visual_info / GLX 1.2 */
         if (pfd.iPixelType == PFD_TYPE_COLORINDEX) {
             c->base.visualType = GLX_STATIC_COLOR;
-
-            if (!getenv("GLWIN_ENABLE_COLORINDEX_FBCONFIGS")) {
-                GLWIN_DEBUG_MSG
-                    ("pixelFormat %d is PFD_TYPE_COLORINDEX, skipping", i + 1);
-                continue;
-            }
+            c->base.transparentRed = GLX_NONE;
+            c->base.transparentGreen = GLX_NONE;
+            c->base.transparentBlue = GLX_NONE;
+            c->base.transparentAlpha = GLX_NONE;
+            c->base.transparentIndex = pfd.dwVisibleMask;
+            c->base.transparentPixel = GLX_TRANSPARENT_INDEX;
         }
         else {
             c->base.visualType = GLX_TRUE_COLOR;
+            c->base.transparentRed =
+                (pfd.dwVisibleMask & c->base.redMask) >> pfd.cRedShift;
+            c->base.transparentGreen =
+                (pfd.dwVisibleMask & c->base.greenMask) >> pfd.cGreenShift;
+            c->base.transparentBlue =
+                (pfd.dwVisibleMask & c->base.blueMask) >> pfd.cBlueShift;
+            c->base.transparentAlpha =
+                (pfd.dwVisibleMask & c->base.alphaMask) >> pfd.cAlphaShift;
+            c->base.transparentIndex = GLX_NONE;
+            c->base.transparentPixel = GLX_TRANSPARENT_RGB;
         }
 
-        // pfd.dwVisibleMask; ???
-        c->base.transparentPixel = GLX_NONE;
-        c->base.transparentRed = GLX_NONE;
-        c->base.transparentGreen = GLX_NONE;
-        c->base.transparentBlue = GLX_NONE;
-        c->base.transparentAlpha = GLX_NONE;
-        c->base.transparentIndex = GLX_NONE;
-
         /* ARB_multisample / SGIS_multisample */
         c->base.sampleBuffers = 0;
         c->base.samples = 0;
@@ -2180,14 +2204,6 @@ glxWinCreateConfigsExt(HDC hdc, glxWinScreen * screen)
             c->base.indexBits = ATTR_VALUE(WGL_COLOR_BITS_ARB, 0);
             c->base.rgbBits = 0;
             c->base.visualType = GLX_STATIC_COLOR;
-
-            if (!getenv("GLWIN_ENABLE_COLORINDEX_FBCONFIGS")) {
-                GLWIN_DEBUG_MSG
-                    ("pixelFormat %d is WGL_TYPE_COLORINDEX_ARB, skipping",
-                     i + 1);
-                continue;
-            }
-
             break;
 
         case WGL_TYPE_RGBA_FLOAT_ARB:
commit 45c432871d6a244e9e558a6a4e7c36e90764135e
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Sat Jul 21 14:13:37 2012 +0100

    hw/xwin: Introduce winProcessXEventsTimeout() to the concept of fractions of a second
    
    Oh this is terrible.
    
    Currently we only compute the select timeout in whole seconds.  This means if we
    have less than 1 second remaining, we select with a timeout of 0 (i.e. poll)
    which causes the task to spin, burning 100% CPU for the remaining timeout (and
    possibly preventing the process we are waiting for from running :S)
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/winclipboardwndproc.c b/hw/xwin/winclipboardwndproc.c
index cbe6599..e19f678 100644
--- a/hw/xwin/winclipboardwndproc.c
+++ b/hw/xwin/winclipboardwndproc.c
@@ -74,10 +74,10 @@ winProcessXEventsTimeout(HWND hwnd, int iWindow, Display * pDisplay,
     int iConnNumber;
     struct timeval tv;
     int iReturn;
-    DWORD dwStopTime = (GetTickCount() / 1000) + iTimeoutSec;
+    DWORD dwStopTime = GetTickCount() + iTimeoutSec * 1000;
 
-    /* We need to ensure that all pending events are processed */
-    XSync(pDisplay, FALSE);
+    winDebug("winProcessXEventsTimeout () - pumping X events for %d seconds\n",
+             iTimeoutSec);
 
     /* Get our connection number */
     iConnNumber = ConnectionNumber(pDisplay);
@@ -85,17 +85,24 @@ winProcessXEventsTimeout(HWND hwnd, int iWindow, Display * pDisplay,
     /* Loop for X events */
     while (1) {
         fd_set fdsRead;
+        long remainingTime;
+
+        /* We need to ensure that all pending events are processed */
+        XSync(pDisplay, FALSE);
 
         /* Setup the file descriptor set */
         FD_ZERO(&fdsRead);
         FD_SET(iConnNumber, &fdsRead);
 
         /* Adjust timeout */
-        tv.tv_sec = dwStopTime - (GetTickCount() / 1000);
-        tv.tv_usec = 0;
+        remainingTime = dwStopTime - GetTickCount();
+        tv.tv_sec = remainingTime / 1000;
+        tv.tv_usec = (remainingTime % 1000) * 1000;
+        winDebug("winProcessXEventsTimeout () - %d milliseconds left\n",
+                 remainingTime);
 
         /* Break out if no time left */
-        if (tv.tv_sec < 0)
+        if (remainingTime <= 0)
             return WIN_XEVENTS_SUCCESS;
 
         /* Wait for an X event */
@@ -103,7 +110,7 @@ winProcessXEventsTimeout(HWND hwnd, int iWindow, Display * pDisplay,
                          &fdsRead,      /* Read mask */
                          NULL,  /* No write mask */
                          NULL,  /* No exception mask */
-                         &tv);  /* No timeout */
+                         &tv);  /* Timeout */
         if (iReturn < 0) {
             ErrorF("winProcessXEventsTimeout - Call to select () failed: %d.  "
                    "Bailing.\n", iReturn);
@@ -116,11 +123,19 @@ winProcessXEventsTimeout(HWND hwnd, int iWindow, Display * pDisplay,
             /* Exit when we see that server is shutting down */
             iReturn = winClipboardFlushXEvents(hwnd,
                                                iWindow, pDisplay, fUseUnicode);
+
+            winDebug
+                ("winProcessXEventsTimeout () - winClipboardFlushXEvents returned %d\n",
+                 iReturn);
+
             if (WIN_XEVENTS_NOTIFY == iReturn) {
                 /* Bail out if notify processed */
                 return iReturn;
             }
         }
+        else {
+            winDebug("winProcessXEventsTimeout - Spurious wake\n");
+        }
     }
 
     return WIN_XEVENTS_SUCCESS;
commit 23cd4d0174194e10721d2e465fd1a1c52f001520
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Sat Jul 21 12:33:05 2012 +0100

    hw/xwin: Fix winUpdateWindowPosition() not to assume WS_EX_APPWINDOW style
    
    Also improve it's debug output a bit
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c
index 82c32aa..ffb7c2d 100644
--- a/hw/xwin/winmultiwindowwm.c
+++ b/hw/xwin/winmultiwindowwm.c
@@ -1743,13 +1743,11 @@ winUpdateWindowPosition(HWND hWnd, Bool reshape, HWND * zstyle)
     /* Setup a rectangle with the X window position and size */
     SetRect(&rcNew, iX, iY, iX + iWidth, iY + iHeight);
 
-#if 0
-    ErrorF("winUpdateWindowPosition - (%d, %d)-(%d, %d)\n",
-           rcNew.left, rcNew.top, rcNew.right, rcNew.bottom);
-#endif
+    winDebug("winUpdateWindowPosition - drawable extent (%d, %d)-(%d, %d)\n",
+             rcNew.left, rcNew.top, rcNew.right, rcNew.bottom);
 
     AdjustWindowRectEx(&rcNew, GetWindowLongPtr(hWnd, GWL_STYLE), FALSE,
-                       WS_EX_APPWINDOW);
+                       GetWindowLongPtr(hWnd, GWL_EXSTYLE));
 
     /* Don't allow window decoration to disappear off to top-left as a result of this adjustment */
     if (rcNew.left < GetSystemMetrics(SM_XVIRTUALSCREEN)) {
@@ -1764,10 +1762,8 @@ winUpdateWindowPosition(HWND hWnd, Bool reshape, HWND * zstyle)
         rcNew.bottom += iDy;
     }
 
-#if 0
-    ErrorF("winUpdateWindowPosition - (%d, %d)-(%d, %d)\n",
-           rcNew.left, rcNew.top, rcNew.right, rcNew.bottom);
-#endif
+    winDebug("winUpdateWindowPosition - Window extent (%d, %d)-(%d, %d)\n",
+             rcNew.left, rcNew.top, rcNew.right, rcNew.bottom);
 
     /* Position the Windows window */
     SetWindowPos(hWnd, *zstyle, rcNew.left, rcNew.top,
commit 527cf13135cfd279733060e0028bbfbe02be5167
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Sat Jul 21 14:09:16 2012 +0100

    hw/xwin: Make winOverrideIcon() thread-safe for icon data access
    
    winOverrideIcon() is called from the internal WM client thread.
    
    Accessing server-internal data structures to get icon data or window hints is
    not safe, as there is no lock to ensure we do not collide with these data
    structures being updated in the server thread.
    
    Rewrite so the internal client thread uses X client calls to obtain this data
    safely
    
    We used to also set the icon inside the server when the window was initially
    created.  For simplicity, we simply send a message to the internal WM to update
    the icon when the window is created (rather than writing different icon update
    code which can work in the server thread for that one case...)
    
    extwm mode used to do the icon update in the server. I'm not sure that actually
    made much sense.  Let's assume the external WM client can do it instead...
    
    v2
    Make sure that WM_WM_ICON_EVENT does nothing for override-redirect windows
    
    v3
    Reinstate check that native window actually has expected properties for an X
    window before trying to update it's icon; some auxiliary windows owned by the
    XWin process don't, which would cause a crash
    
    v4
    Various fixes to pixmap icon conversion:
    - remove left-over malloc in winScaleXimageToWindowsIcon causing a memory leak
    - don't recalculate DDBitmap stride in winScaleXimageToWindowsIcon, when we already have worked it out
    - properly check that XGetWindowProperty(NET_WM_ICON) returned some data
    - don't try to retrieve WM_HINTS icon_mask if it isn't set
    - restore accidentally dropped calculation of effBpp, stride, maskStride of output DDBitmap
    - make sure imageMask is zero-initalized before we use it to mask the DDBitmap
    
    v5
    Remove a left-over unused variable
    
    v6
    Avoid XDestroyImage(NULL) crash if XGetImage failed for icon_pixmap
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/win.h b/hw/xwin/win.h
index 38d6bde..89e2a38 100644
--- a/hw/xwin/win.h
+++ b/hw/xwin/win.h
@@ -1174,15 +1174,6 @@ Bool
 void
  winSetShapeRootless(WindowPtr pWindow, int kind);
 
-/*
- * winmultiwindowicons.c - Used by both multi-window and Win32Rootless
- */
-
-HICON winXIconToHICON(WindowPtr pWin, int iconSize);
-
-void
- winSelectIcons(WindowPtr pWin, HICON * pIcon, HICON * pSmallIcon);
-
 #ifdef XWIN_MULTIWINDOW
 /*
  * winmultiwindowshape.c
diff --git a/hw/xwin/winmultiwindowicons.c b/hw/xwin/winmultiwindowicons.c
index df59f60..b8357e7 100644
--- a/hw/xwin/winmultiwindowicons.c
+++ b/hw/xwin/winmultiwindowicons.c
@@ -31,75 +31,65 @@
 #ifdef HAVE_XWIN_CONFIG_H
 #include <xwin-config.h>
 #endif
-#include "win.h"
-#include "dixevents.h"
-#include "winmultiwindowclass.h"
-#include "winprefs.h"
 
-#include "propertyst.h"
-#include "windowstr.h"
+#ifndef WINVER
+#define WINVER 0x0500
+#endif
+
+#include <X11/Xwindows.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
 
+#include "winresource.h"
+#include "winprefs.h"
+#include "winmsg.h"
+#include "winmultiwindowicons.h"
+#include "winglobals.h"
 /*
- * Prototypes for local functions
+ * global variables
  */
-
-static void
-
-winScaleXBitmapToWindows(int iconSize, int effBPP,
-                         PixmapPtr pixmap, unsigned char *image);
+extern HINSTANCE g_hInstance;
 
 /*
- * Scale an X icon bitmap into a Windoze icon bitmap
+ * Scale an X icon ZPixmap into a Windoze icon bitmap
  */
 
 static void
-winScaleXBitmapToWindows(int iconSize,
-                         int effBPP, PixmapPtr pixmap, unsigned char *image)
+winScaleXImageToWindowsIcon(int iconSize,
+                            int effBPP,
+                            int stride, XImage * pixmap, unsigned char *image)
 {
     int row, column, effXBPP, effXDepth;
     unsigned char *outPtr;
-    char *iconData = 0;
-    int stride, xStride;
+    unsigned char *iconData = 0;
+    int xStride;
     float factX, factY;
     int posX, posY;
     unsigned char *ptr;
     unsigned int zero;
     unsigned int color;
 
-    effXBPP = BitsPerPixel(pixmap->drawable.depth);
-    effXDepth = pixmap->drawable.depth;
-
-    if (pixmap->drawable.bitsPerPixel == 15)
+    effXBPP = pixmap->bits_per_pixel;
+    if (pixmap->bits_per_pixel == 15)
         effXBPP = 16;
 
-    if (pixmap->drawable.depth == 15)
+    effXDepth = pixmap->depth;
+    if (pixmap->depth == 15)
         effXDepth = 16;
 
-    /* Need 16-bit aligned rows for DDBitmaps */
-    stride = ((iconSize * effBPP + 15) & (~15)) / 8;
-    xStride = PixmapBytePad(pixmap->drawable.width, pixmap->drawable.depth);
+    xStride = pixmap->bytes_per_line;
     if (stride == 0 || xStride == 0) {
         ErrorF("winScaleXBitmapToWindows - stride or xStride is zero.  "
                "Bailing.\n");
         return;
     }
 
-    /* Allocate memory for icon data */
-    iconData = malloc(xStride * pixmap->drawable.height);
-    if (!iconData) {
-        ErrorF("winScaleXBitmapToWindows - malloc failed for iconData.  "
-               "Bailing.\n");
-        return;
-    }
-
     /* Get icon data */
-    miGetImage((DrawablePtr) &(pixmap->drawable), 0, 0,
-               pixmap->drawable.width, pixmap->drawable.height,
-               ZPixmap, 0xffffffff, iconData);
+    iconData = (unsigned char *) pixmap->data;
 
     /* Keep aspect ratio */
-    factX = ((float) pixmap->drawable.width) / ((float) iconSize);
-    factY = ((float) pixmap->drawable.height) / ((float) iconSize);
+    factX = ((float) pixmap->width) / ((float) iconSize);
+    factY = ((float) pixmap->height) / ((float) iconSize);
     if (factX > factY)
         factY = factX;
     else
@@ -119,8 +109,7 @@ winScaleXBitmapToWindows(int iconSize,
                 ptr += posX / 8;
 
                 /* Out of X icon bounds, leave space blank */
-                if (posX >= pixmap->drawable.width
-                    || posY >= pixmap->drawable.height)
+                if (posX >= pixmap->width || posY >= pixmap->height)
                     ptr = (unsigned char *) &zero;
 
                 if ((*ptr) & (1 << (posX & 7)))
@@ -162,8 +151,7 @@ winScaleXBitmapToWindows(int iconSize,
                 ptr += posX * (effXBPP / 8);
 
                 /* Out of X icon bounds, leave space blank */
-                if (posX >= pixmap->drawable.width
-                    || posY >= pixmap->drawable.height)
+                if (posX >= pixmap->width || posY >= pixmap->height)
                     ptr = (unsigned char *) &zero;
                 color = (((*ptr) << 16)
                          + ((*(ptr + 1)) << 8)
@@ -203,8 +191,7 @@ winScaleXBitmapToWindows(int iconSize,
                 ptr += posX * (effXBPP / 8);
 
                 /* Out of X icon bounds, leave space blank */
-                if (posX >= pixmap->drawable.width
-                    || posY >= pixmap->drawable.height)
+                if (posX >= pixmap->width || posY >= pixmap->height)
                     ptr = (unsigned char *) &zero;
                 color = ((*ptr) << 8) + (*(ptr + 1));
                 switch (effBPP) {
@@ -238,7 +225,6 @@ winScaleXBitmapToWindows(int iconSize,
             }                   /* end if effxbpp==16) */
         }                       /* end for column */
     }                           /* end for row */
-    free(iconData);
 }
 
 static HICON
@@ -250,7 +236,7 @@ NetWMToWinIconAlpha(uint32_t * icon)
     HICON result;
     HDC hdc = GetDC(NULL);
     uint32_t *DIB_pixels;
-    ICONINFO ii = { TRUE };
+    ICONINFO ii;
     BITMAPV4HEADER bmh = { sizeof(bmh) };
 
     /* Define an ARGB pixel format used for Color+Alpha icons */
@@ -264,6 +250,9 @@ NetWMToWinIconAlpha(uint32_t * icon)
     bmh.bV4GreenMask = 0x0000FF00;
     bmh.bV4BlueMask = 0x000000FF;
 
+    ii.fIcon = TRUE;
+    ii.xHotspot = 0;            /* ignored */
+    ii.yHotspot = 0;            /* ignored */
     ii.hbmColor = CreateDIBSection(hdc, (BITMAPINFO *) & bmh,
                                    DIB_RGB_COLORS, (void **) &DIB_pixels, NULL,
                                    0);
@@ -291,12 +280,15 @@ NetWMToWinIconThreshold(uint32_t * icon)
     uint32_t *pixels = &icon[2];
     int row, col;
     HICON result;
-    ICONINFO ii = { TRUE };
+    ICONINFO ii;
 
     HDC hdc = GetDC(NULL);
     HDC xorDC = CreateCompatibleDC(hdc);
     HDC andDC = CreateCompatibleDC(hdc);
 
+    ii.fIcon = TRUE;
+    ii.xHotspot = 0;            /* ignored */
+    ii.yHotspot = 0;            /* ignored */
     ii.hbmColor = CreateCompatibleBitmap(hdc, width, height);
     ii.hbmMask = CreateCompatibleBitmap(hdc, width, height);
     ReleaseDC(NULL, hdc);
@@ -365,202 +357,220 @@ NetWMToWinIcon(int bpp, uint32_t * icon)
         return NetWMToWinIconThreshold(icon);
 }
 
-static pointer
-GetWindowProp(WindowPtr pWin, Atom name, long int *size_return)
-{
-    struct _Window *pwin;
-    struct _Property *prop;
-
-    if (!pWin || !name) {
-        ErrorF("GetWindowProp - pWin or name was NULL\n");
-        return 0;
-    }
-    pwin = (struct _Window *) pWin;
-    if (!pwin->optional)
-        return NULL;
-    for (prop = (struct _Property *) pwin->optional->userProps;
-         prop; prop = prop->next) {
-        if (prop->propertyName == name) {
-            *size_return = prop->size;
-            return prop->data;
-        }
-    }
-    return NULL;
-}
-
 /*
  * Attempt to create a custom icon from the WM_HINTS bitmaps
  */
 
-HICON
-winXIconToHICON(WindowPtr pWin, int iconSize)
+static
+ HICON
+winXIconToHICON(Display * pDisplay, Window id, int iconSize)
 {
-    unsigned char *mask, *image, *imageMask;
+    unsigned char *mask, *image = NULL, *imageMask;
     unsigned char *dst, *src;
-    PixmapPtr iconPtr;
-    PixmapPtr maskPtr;
-    int planes, bpp, effBPP, stride, maskStride, i;
+    int planes, bpp, i;
     int biggest_size = 0;
     HDC hDC;
     ICONINFO ii;
-    WinXWMHints hints;
+    XWMHints *hints;
     HICON hIcon = NULL;
     uint32_t *biggest_icon = NULL;
 
-    /* Try to get _NET_WM_ICON icons first */
     static Atom _XA_NET_WM_ICON;
     static int generation;
     uint32_t *icon, *icon_data = NULL;
-    long int size = 0;
+    unsigned long int size;
+    unsigned long int type;
+    int format;
+    unsigned long int left;
 
     hDC = GetDC(GetDesktopWindow());
     planes = GetDeviceCaps(hDC, PLANES);
     bpp = GetDeviceCaps(hDC, BITSPIXEL);
     ReleaseDC(GetDesktopWindow(), hDC);
 
+    /* Always prefer _NET_WM_ICON icons */
     if (generation != serverGeneration) {
         generation = serverGeneration;
-        _XA_NET_WM_ICON = MakeAtom("_NET_WM_ICON", 12, TRUE);
+        _XA_NET_WM_ICON = XInternAtom(pDisplay, "_NET_WM_ICON", FALSE);
     }
 
-    if (_XA_NET_WM_ICON)
-        icon_data = GetWindowProp(pWin, _XA_NET_WM_ICON, &size);
-    if (icon_data) {
-        for (icon = icon_data;
-             icon < &icon_data[size] && *icon;
+    if ((XGetWindowProperty(pDisplay, id, _XA_NET_WM_ICON,
+                            0, MAXINT, FALSE,
+                            AnyPropertyType, &type, &format, &size, &left,
+                            (unsigned char **) &icon_data) == Success) &&
+        (icon_data != NULL)) {
+        for (icon = icon_data; icon < &icon_data[size] && *icon;
              icon = &icon[icon[0] * icon[1] + 2]) {
-            if (icon[0] == iconSize && icon[1] == iconSize)
-                return NetWMToWinIcon(bpp, icon);
-            /* Find the biggest icon and let Windows scale the size */
+            /* Find an exact match to the size we require...  */
+            if (icon[0] == iconSize && icon[1] == iconSize) {
+                winDebug("winXIconToHICON: found %lu x %lu NetIcon\n", icon[0],
+                         icon[1]);
+                hIcon = NetWMToWinIcon(bpp, icon);
+                break;
+            }
+            /* Otherwise, find the biggest icon and let Windows scale the size */
             else if (biggest_size < icon[0]) {
                 biggest_icon = icon;
                 biggest_size = icon[0];
             }
         }
-        if (biggest_icon)
-            return NetWMToWinIcon(bpp, biggest_icon);
-    }
-    winDebug("winXIconToHICON - pWin %x: no suitable NetIcon\n", (int) pWin,
-             iconSize);
 
-    winMultiWindowGetWMHints(pWin, &hints);
-    if (!hints.icon_pixmap)
-        return NULL;
+        if (!hIcon && biggest_icon) {
+            winDebug
+                ("winXIconToHICON: selected %lu x %lu NetIcon for scaling to %u x %u\n",
+                 biggest_icon[0], biggest_icon[1], iconSize, iconSize);
+
+            hIcon = NetWMToWinIcon(bpp, biggest_icon);
+        }
 
-    dixLookupResourceByType((pointer) &iconPtr, hints.icon_pixmap, RT_PIXMAP,
-                            NullClient, DixUnknownAccess);
+        XFree(icon_data);
+    }
 
-    if (!iconPtr)
-        return NULL;
+    if (!hIcon) {
+        winDebug("winXIconToHICON: no suitable NetIcon\n");
+
+        hints = XGetWMHints(pDisplay, id);
+        if (hints) {
+            winDebug("winXIconToHICON: id 0x%x icon_pixmap hint %x\n", id,
+                     hints->icon_pixmap);
+
+            if (hints->icon_pixmap) {
+                Window root;
+                int x, y;
+                unsigned int width, height, border_width, depth;
+                XImage *xImageIcon;
+                XImage *xImageMask = NULL;
+
+                XGetGeometry(pDisplay, hints->icon_pixmap, &root, &x, &y,
+                             &width, &height, &border_width, &depth);
+
+                xImageIcon =
+                    XGetImage(pDisplay, hints->icon_pixmap, 0, 0, width, height,
+                              0xFFFFFFFF, ZPixmap);
+                winDebug("winXIconToHICON: id 0x%x icon Ximage 0x%x\n", id,
+                         xImageIcon);
+
+                if (hints->icon_mask)
+                    xImageMask =
+                        XGetImage(pDisplay, hints->icon_mask, 0, 0, width,
+                                  height, 0xFFFFFFFF, ZPixmap);
+
+                if (xImageIcon) {
+                    int effBPP, stride, maskStride;
+
+                    /* 15 BPP is really 16BPP as far as we care */
+                    if (bpp == 15)
+                        effBPP = 16;
+                    else
+                        effBPP = bpp;
 
-    /* 15 BPP is really 16BPP as far as we care */
-    if (bpp == 15)
-        effBPP = 16;
-    else
-        effBPP = bpp;
+                    /* Need 16-bit aligned rows for DDBitmaps */
+                    stride = ((iconSize * effBPP + 15) & (~15)) / 8;
 
-    /* Need 16-bit aligned rows for DDBitmaps */
-    stride = ((iconSize * effBPP + 15) & (~15)) / 8;
+                    /* Mask is 1-bit deep */
+                    maskStride = ((iconSize * 1 + 15) & (~15)) / 8;
 
-    /* Mask is 1-bit deep */
-    maskStride = ((iconSize * 1 + 15) & (~15)) / 8;
+                    image = malloc(stride * iconSize);
+                    imageMask = malloc(stride * iconSize);
+                    mask = malloc(maskStride * iconSize);
 
-    image = malloc(stride * iconSize);
-    imageMask = malloc(stride * iconSize);
-    /* Default to a completely black mask */
-    mask = calloc(maskStride, iconSize);
+                    /* Default to a completely black mask */
+                    memset(imageMask, 0, stride * iconSize);
+                    memset(mask, 0, maskStride * iconSize);
 
-    winScaleXBitmapToWindows(iconSize, effBPP, iconPtr, image);
-    dixLookupResourceByType((pointer) &maskPtr, hints.icon_mask, RT_PIXMAP,
-                            NullClient, DixUnknownAccess);
+                    winScaleXImageToWindowsIcon(iconSize, effBPP, stride,
+                                                xImageIcon, image);
 
-    if (maskPtr) {
-        winScaleXBitmapToWindows(iconSize, 1, maskPtr, mask);
+                    if (xImageMask) {
+                        winScaleXImageToWindowsIcon(iconSize, 1, maskStride,
+                                                    xImageMask, mask);
+                        winScaleXImageToWindowsIcon(iconSize, effBPP, stride,
+                                                    xImageMask, imageMask);
+                    }
 
-        winScaleXBitmapToWindows(iconSize, effBPP, maskPtr, imageMask);
+                    /* Now we need to set all bits of the icon which are not masked */
+                    /* on to 0 because Color is really an XOR, not an OR function */
+                    dst = image;
+                    src = imageMask;
 
-        /* Now we need to set all bits of the icon which are not masked */
-        /* on to 0 because Color is really an XOR, not an OR function */
-        dst = image;
-        src = imageMask;
+                    for (i = 0; i < (stride * iconSize); i++)
+                        if ((*(src++)))
+                            *(dst++) = 0;
+                        else
+                            dst++;
 
-        for (i = 0; i < (stride * iconSize); i++)
-            if ((*(src++)))
-                *(dst++) = 0;
-            else
-                dst++;
-    }
+                    ii.fIcon = TRUE;
+                    ii.xHotspot = 0;    /* ignored */
+                    ii.yHotspot = 0;    /* ignored */
 
-    ii.fIcon = TRUE;
-    ii.xHotspot = 0;            /* ignored */
-    ii.yHotspot = 0;            /* ignored */
+                    /* Create Win32 mask from pixmap shape */
+                    ii.hbmMask =
+                        CreateBitmap(iconSize, iconSize, planes, 1, mask);
 
-    /* Create Win32 mask from pixmap shape */
-    ii.hbmMask = CreateBitmap(iconSize, iconSize, planes, 1, mask);
+                    /* Create Win32 bitmap from pixmap */
+                    ii.hbmColor =
+                        CreateBitmap(iconSize, iconSize, planes, bpp, image);
 
-    /* Create Win32 bitmap from pixmap */
-    ii.hbmColor = CreateBitmap(iconSize, iconSize, planes, bpp, image);
+                    /* Merge Win32 mask and bitmap into icon */
+                    hIcon = CreateIconIndirect(&ii);
 
-    /* Merge Win32 mask and bitmap into icon */
-    hIcon = CreateIconIndirect(&ii);
+                    /* Release Win32 mask and bitmap */
+                    DeleteObject(ii.hbmMask);
+                    DeleteObject(ii.hbmColor);
 
-    /* Release Win32 mask and bitmap */
-    DeleteObject(ii.hbmMask);
-    DeleteObject(ii.hbmColor);
+                    /* Free X mask and bitmap */
+                    free(mask);
+                    free(image);
+                    free(imageMask);
 
-    /* Free X mask and bitmap */
-    free(mask);
-    free(image);
-    free(imageMask);
+                    if (xImageMask)
+                        XDestroyImage(xImageMask);
 
+                    XDestroyImage(xImageIcon);
+                }
+            }
+            XFree(hints);
+        }
+    }
     return hIcon;
 }
 
 /*
- * Change the Windows window icon 
+ * Change the Windows window icon
  */
 
 #ifdef XWIN_MULTIWINDOW
 void
-winUpdateIcon(Window id)
+winUpdateIcon(HWND hWnd, Display * pDisplay, Window id, HICON hIconNew)
 {
-    WindowPtr pWin;
     HICON hIcon, hIconSmall = NULL, hIconOld;
 
-    dixLookupResourceByType((pointer) &pWin, id, RT_WINDOW, NullClient,
-                            DixUnknownAccess);
-    if (pWin) {
-        winWindowPriv(pWin);
-        if (pWinPriv->hWnd) {
-            hIcon = winOverrideIcon((unsigned long) pWin);
-            if (!hIcon) {
-                hIcon = winXIconToHICON(pWin, GetSystemMetrics(SM_CXICON));
-                if (!hIcon) {
-                    hIcon = g_hIconX;
-                    hIconSmall = g_hSmallIconX;
-                }
-                else {
-                    /* Leave undefined if not found */
-                    hIconSmall =
-                        winXIconToHICON(pWin, GetSystemMetrics(SM_CXSMICON));
-                }
-            }
+    /* Start with the icon from preferences, if any */
+    hIcon = hIconNew;
+    hIconSmall = hIconNew;
 
-            /* Set the large icon */
-            hIconOld = (HICON) SendMessage(pWinPriv->hWnd,
-                                           WM_SETICON, ICON_BIG,
-                                           (LPARAM) hIcon);
+    /* If we still need an icon, try and get the icon from WM_HINTS */
+    if (!hIcon)
+        hIcon = winXIconToHICON(pDisplay, id, GetSystemMetrics(SM_CXICON));
+    if (!hIconSmall)
+        hIconSmall =
+            winXIconToHICON(pDisplay, id, GetSystemMetrics(SM_CXSMICON));
 
-            /* Delete the icon if its not the default */
-            winDestroyIcon(hIconOld);
-
-            /* Same for the small icon */
-            hIconOld = (HICON) SendMessage(pWinPriv->hWnd,
-                                           WM_SETICON, ICON_SMALL,
-                                           (LPARAM) hIconSmall);
-            winDestroyIcon(hIconOld);
-        }
+    /* If we got the small, but not the large one swap them */
+    if (!hIcon && hIconSmall) {
+        hIcon = hIconSmall;
+        hIconSmall = NULL;
     }
+
+    /* Set the large icon */
+    hIconOld = (HICON) SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM) hIcon);
+    /* Delete the old icon if its not the default */
+    winDestroyIcon(hIconOld);
+
+    /* Same for the small icon */
+    hIconOld =
+        (HICON) SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM) hIconSmall);
+    winDestroyIcon(hIconOld);
 }
 
 void
@@ -591,37 +601,21 @@ winInitGlobalIcons(void)
 }
 
 void
-winSelectIcons(WindowPtr pWin, HICON * pIcon, HICON * pSmallIcon)
+winSelectIcons(HICON * pIcon, HICON * pSmallIcon)
 {
     HICON hIcon, hSmallIcon;
 
     winInitGlobalIcons();
 
-    /* Try and get the icon from WM_HINTS */
-    hIcon = winXIconToHICON(pWin, GetSystemMetrics(SM_CXICON));
-    hSmallIcon = winXIconToHICON(pWin, GetSystemMetrics(SM_CXSMICON));
-
-    /* If we got the small, but not the large one swap them */
-    if (!hIcon && hSmallIcon) {
-        hIcon = hSmallIcon;
-        hSmallIcon = NULL;
-    }
-
-    /* Use default X icon if no icon loaded from WM_HINTS */
-    if (!hIcon) {
-        hIcon = g_hIconX;
-        hSmallIcon = g_hSmallIconX;
-    }
+    /* Use default X icon */
+    hIcon = g_hIconX;
+    hSmallIcon = g_hSmallIconX;
 
     if (pIcon)
         *pIcon = hIcon;
-    else
-        winDestroyIcon(hIcon);
 
     if (pSmallIcon)
         *pSmallIcon = hSmallIcon;
-    else
-        winDestroyIcon(hSmallIcon);
 }
 
 void
diff --git a/hw/xwin/winmultiwindowicons.h b/hw/xwin/winmultiwindowicons.h
new file mode 100644
index 0000000..bf7f6ed
--- /dev/null
+++ b/hw/xwin/winmultiwindowicons.h
@@ -0,0 +1,42 @@
+/*
+ * File: winmultiwindowicons.h
+ * Purpose: interface for multiwindow mode icon functions
+ *
+ * Copyright (c) Jon TURNEY 2012
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef WINMULTIWINDOWICONS_H
+#define WINMULTIWINDOWICONS_H
+
+void
+ winUpdateIcon(HWND hWnd, Display * pDisplay, Window id, HICON hIconNew);
+
+void
+ winInitGlobalIcons(void);
+
+void
+ winDestroyIcon(HICON hIcon);
+
+void
+ winSelectIcons(HICON * pIcon, HICON * pSmallIcon);
+
+#endif                          /* WINMULTIWINDOWICONS_H */
diff --git a/hw/xwin/winmultiwindowwindow.c b/hw/xwin/winmultiwindowwindow.c
index 0093fcb..c0c7db2 100644
--- a/hw/xwin/winmultiwindowwindow.c
+++ b/hw/xwin/winmultiwindowwindow.c
@@ -63,6 +63,11 @@ winInitMultiWindowClass(void)
     WNDCLASSEX wcx;
 
     if (atomXWinClass == 0) {
+        HICON hIcon, hIconSmall;
+
+        /* Load the default icons */
+        winSelectIcons(&hIcon, &hIconSmall);
+
         /* Setup our window class */
         wcx.cbSize = sizeof(WNDCLASSEX);
         wcx.style = CS_HREDRAW | CS_VREDRAW | (g_fNativeGl ? CS_OWNDC : 0);
@@ -70,12 +75,12 @@ winInitMultiWindowClass(void)
         wcx.cbClsExtra = 0;
         wcx.cbWndExtra = 0;
         wcx.hInstance = g_hInstance;
-        wcx.hIcon = g_hIconX;
+        wcx.hIcon = hIcon;
         wcx.hCursor = 0;
         wcx.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
         wcx.lpszMenuName = NULL;
         wcx.lpszClassName = WINDOW_CLASS_X;
-        wcx.hIconSm = g_hSmallIconX;
+        wcx.hIconSm = hIconSmall;
 
 #if CYGMULTIWINDOW_DEBUG
         ErrorF("winCreateWindowsWindow - Creating class: %s\n", WINDOW_CLASS_X);
@@ -479,8 +484,6 @@ winCreateWindowsWindow(WindowPtr pWin)
     HWND hFore = NULL;
 
     winWindowPriv(pWin);
-    HICON hIcon;
-    HICON hIconSmall;
     winPrivScreenPtr pScreenPriv = pWinPriv->pScreenPriv;
     WinXSizeHints hints;
     WindowPtr pDaddy;
@@ -574,13 +577,6 @@ winCreateWindowsWindow(WindowPtr pWin)
     }
     pWinPriv->hWnd = hWnd;
 
-    /* Set application or .XWinrc defined Icons */
-    winSelectIcons(pWin, &hIcon, &hIconSmall);
-    if (hIcon)
-        SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM) hIcon);
-    if (hIconSmall)
-        SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM) hIconSmall);
-
     /* Change style back to popup, already placed... */
     SetWindowLongPtr(hWnd, GWL_STYLE,
                      WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c
index b7909cc..82c32aa 100644
--- a/hw/xwin/winmultiwindowwm.c
+++ b/hw/xwin/winmultiwindowwm.c
@@ -553,7 +553,6 @@ UpdateName(WMInfoPtr pWMInfo, Window iWindow)
 
             /* Set the Windows window name */
             SetWindowTextW(hWnd, pwszWideWindowName);
-            winUpdateIcon(iWindow);
 
             free(pwszWideWindowName);
             free(pszWindowName);
@@ -561,6 +560,46 @@ UpdateName(WMInfoPtr pWMInfo, Window iWindow)
     }
 }
 
+/*
+ * Updates the icon of a HWND according to its X icon properties
+ */
+
+static void
+UpdateIcon(WMInfoPtr pWMInfo, Window iWindow)
+{
+    HWND hWnd;
+    HICON hIconNew = NULL;
+    XWindowAttributes attr;
+
+    hWnd = getHwnd(pWMInfo, iWindow);
+    if (!hWnd)
+        return;
+
+    /* If window isn't override-redirect */
+    XGetWindowAttributes(pWMInfo->pDisplay, iWindow, &attr);
+    if (!attr.override_redirect) {
+        XClassHint class_hint = { 0, 0 };
+        char *window_name = 0;
+
+        if (XGetClassHint(pWMInfo->pDisplay, iWindow, &class_hint)) {
+            XFetchName(pWMInfo->pDisplay, iWindow, &window_name);
+
+            hIconNew =
+                (HICON) winOverrideIcon(class_hint.res_name,
+                                        class_hint.res_class, window_name);
+
+            if (class_hint.res_name)
+                XFree(class_hint.res_name);
+            if (class_hint.res_class)
+                XFree(class_hint.res_class);
+            if (window_name)
+                XFree(window_name);
+        }
+    }
+
+    winUpdateIcon(hWnd, pWMInfo->pDisplay, iWindow, hIconNew);
+}
+
 #if 0
 /*
  * Fix up any differences between the X11 and Win32 window stacks
@@ -684,7 +723,7 @@ winMultiWindowWMProc(void *pArg)
                             PropModeReplace,
                             (unsigned char *) &(pNode->msg.hwndWindow), 1);
             UpdateName(pWMInfo, pNode->msg.iWindow);
-            winUpdateIcon(pNode->msg.iWindow);
+            UpdateIcon(pWMInfo, pNode->msg.iWindow);
             break;
 
         case WM_WM_MAP2:
@@ -707,7 +746,7 @@ winMultiWindowWMProc(void *pArg)
                             PropModeReplace,
                             (unsigned char *) &(pNode->msg.hwndWindow), 1);
             UpdateName(pWMInfo, pNode->msg.iWindow);
-            winUpdateIcon(pNode->msg.iWindow);
+            UpdateIcon(pWMInfo, pNode->msg.iWindow);
             {
                 HWND zstyle = HWND_NOTOPMOST;
 
@@ -770,7 +809,7 @@ winMultiWindowWMProc(void *pArg)
             break;
 
         case WM_WM_ICON_EVENT:
-            winUpdateIcon(pNode->msg.iWindow);
+            UpdateIcon(pWMInfo, pNode->msg.iWindow);
             break;
 
         case WM_WM_CHANGE_STATE:
diff --git a/hw/xwin/winprefs.c b/hw/xwin/winprefs.c
index 86a7882..faa97c3 100644
--- a/hw/xwin/winprefs.c
+++ b/hw/xwin/winprefs.c
@@ -148,7 +148,6 @@ static wBOOL CALLBACK
 ReloadEnumWindowsProc(HWND hwnd, LPARAM lParam)
 {
     HICON hicon;
-    Window wid;
 
     if (!hwnd) {
         ErrorF("ReloadEnumWindowsProc: hwnd==NULL!\n");
@@ -173,10 +172,23 @@ ReloadEnumWindowsProc(HWND hwnd, LPARAM lParam)
         /* This window is now clean of our taint (but with undefined icons) */
     }
     else {
-        /* winUpdateIcon() will set the icon default, dynamic, or from xwinrc */
-        wid = (Window) GetProp(hwnd, WIN_WID_PROP);
-        if (wid)
-            winUpdateIcon(wid);
+        /* Send a message to WM thread telling it re-evaluate the icon for this window */
+        {
+            winWMMessageRec wmMsg;
+
+            WindowPtr pWin = GetProp(hwnd, WIN_WINDOW_PROP);
+
+            if (pWin) {
+                winPrivWinPtr pWinPriv = winGetWindowPriv(pWin);
+                winPrivScreenPtr s_pScreenPriv = pWinPriv->pScreenPriv;
+
+                wmMsg.msg = WM_WM_ICON_EVENT;
+                wmMsg.hwndWindow = hwnd;
+                wmMsg.iWindow = (Window) GetProp(hwnd, WIN_WID_PROP);
+
+                winSendMessageToWM(s_pScreenPriv->pWMInfo, &wmMsg);
+            }
+        }
 
         /* Update the system menu for this window */
         SetupSysMenu((unsigned long) hwnd);
@@ -577,31 +589,15 @@ LoadImageComma(char *fname, int sx, int sy, int flags)
  * ICONS{} section in the prefs file, and load the icon from a file
  */
 HICON
-winOverrideIcon(unsigned long longWin)
+winOverrideIcon(char *res_name, char *res_class, char *wmName)
 {
-    WindowPtr pWin = (WindowPtr) longWin;
-    char *res_name, *res_class;
     int i;
     HICON hicon;
-    char *wmName;
-
-    if (pWin == NULL)
-        return 0;
-
-    /* If we can't find the class, we can't override from default! */
-    if (!winMultiWindowGetClassHint(pWin, &res_name, &res_class))
-        return 0;
-
-    winMultiWindowGetWMName(pWin, &wmName);
 
     for (i = 0; i < pref.iconItems; i++) {
-        if (!strcmp(pref.icon[i].match, res_name) ||
-            !strcmp(pref.icon[i].match, res_class) ||
+        if ((res_name && !strcmp(pref.icon[i].match, res_name)) ||
+            (res_class && !strcmp(pref.icon[i].match, res_class)) ||
             (wmName && strstr(wmName, pref.icon[i].match))) {
-            free(res_name);
-            free(res_class);
-            free(wmName);
-
             if (pref.icon[i].hicon)
                 return pref.icon[i].hicon;
 
@@ -616,10 +612,6 @@ winOverrideIcon(unsigned long longWin)
     }
 
     /* Didn't find the icon, fail gracefully */
-    free(res_name);
-    free(res_class);
-    free(wmName);
-
     return 0;
 }
 
diff --git a/hw/xwin/winprefs.h b/hw/xwin/winprefs.h
index fcce8d8..5de5719 100644
--- a/hw/xwin/winprefs.h
+++ b/hw/xwin/winprefs.h
@@ -164,7 +164,7 @@ Bool
 int
  winIconIsOverride(unsigned hiconIn);
 
-HICON winOverrideIcon(unsigned long longpWin);
+HICON winOverrideIcon(char *res_name, char *res_class, char *wmName);
 
 unsigned long
  winOverrideStyle(char *res_name, char *res_class, char *wmName);
diff --git a/hw/xwin/winwin32rootless.c b/hw/xwin/winwin32rootless.c
index cef49b5..5bf7102 100644
--- a/hw/xwin/winwin32rootless.c
+++ b/hw/xwin/winwin32rootless.c
@@ -231,7 +231,7 @@ winMWExtWMCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
     // Store the implementation private frame ID
     pFrame->wid = (RootlessFrameID) pRLWinPriv;
 
-    winSelectIcons(pFrame->win, &hIcon, &hIconSmall);
+    winSelectIcons(&hIcon, &hIconSmall);
 
     /* Set standard class name prefix so we can identify window easily */
     strncpy(pszClass, WINDOW_CLASS_X, sizeof(pszClass));
diff --git a/hw/xwin/winwin32rootlesswindow.c b/hw/xwin/winwin32rootlesswindow.c
index bfba1bf..f2d68cb 100644
--- a/hw/xwin/winwin32rootlesswindow.c
+++ b/hw/xwin/winwin32rootlesswindow.c
@@ -147,39 +147,8 @@ winMWExtWMMoveResizeXWindow(WindowPtr pWin, int x, int y, int w, int h)
 }
 
 /*
- * winMWExtWMUpdateIcon
- * Change the Windows window icon
- */
-
-void
-winMWExtWMUpdateIcon(Window id)
-{
-    WindowPtr pWin;
-    HICON hIcon, hiconOld;
-
-    dixLookupResourceByType((pointer) &pWin, id, RT_WINDOW, NullClient,
-                            DixUnknownAccess);
-    hIcon = winOverrideIcon((unsigned long) pWin);
-
-    if (!hIcon)
-        hIcon = winXIconToHICON(pWin, GetSystemMetrics(SM_CXICON));
 
-    if (hIcon) {
-        win32RootlessWindowPtr pRLWinPriv
-            = (win32RootlessWindowPtr) RootlessFrameForWindow(pWin, FALSE);
 
-        if (pRLWinPriv->hWnd) {
-
-            hiconOld = (HICON) SendMessage(pRLWinPriv->hWnd,
-                                           WM_SETICON, ICON_BIG,
-                                           (LPARAM) hIcon);
-            winDestroyIcon(hiconOld);
-        }
-        hIcon = NULL;
-    }
-}
-
-/*
  * winMWExtWMDecorateWindow - Update window style. Called by EnumWindows.
  */
 
diff --git a/hw/xwin/winwindow.h b/hw/xwin/winwindow.h
index 9f2ab45..a5919ee 100644
--- a/hw/xwin/winwindow.h
+++ b/hw/xwin/winwindow.h
@@ -157,18 +157,5 @@ void
 void
  winMinimizeWindow(Window id);
 
-/*
- * winmultiwindowicons.c
- */
-
-void
- winUpdateIcon(Window id);
-
-void
- winInitGlobalIcons(void);
-
-void
- winDestroyIcon(HICON hIcon);
-
 #endif                          /* XWIN_MULTIWINDOW */
 #endif
diff --git a/hw/xwin/winwindowswm.c b/hw/xwin/winwindowswm.c
index 77c997a..5d513a8 100644
--- a/hw/xwin/winwindowswm.c
+++ b/hw/xwin/winwindowswm.c
@@ -439,8 +439,6 @@ ProcWindowsWMFrameDraw(ClientPtr client)
 
     ShowWindow(pRLWinPriv->hWnd, nCmdShow);
 
-    winMWExtWMUpdateIcon(pWin->drawable.id);
-
     if (wBoundingShape(pWin) != NULL) {
         /* wBoundingShape is relative to *inner* origin of window.
            Translate by borderWidth to get the outside-relative position. */
commit 2677d89823b851fea31036f51589985bb86864b7
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Sun Jul 22 17:38:55 2012 +0100

    hw/xwin: Also update icon when _NET_WM_ICON property changes
    
    _NET_WM_ICON property is also considered to decide on the window icon, so also
    send a WM_WM_ICON_EVENT message to the WM if the PropertyNotify event is for
    _NET_WM_ICON property
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c
index c30efa9..b7909cc 100644
--- a/hw/xwin/winmultiwindowwm.c
+++ b/hw/xwin/winmultiwindowwm.c
@@ -821,6 +821,7 @@ winMultiWindowXMsgProc(void *pArg)
     Atom atmWmName;
     Atom atmWmHints;
     Atom atmWmChange;
+    Atom atmNetWmIcon;
     int iReturn;
     XIconSize *xis;
 
@@ -946,6 +947,7 @@ winMultiWindowXMsgProc(void *pArg)
     atmWmName = XInternAtom(pProcArg->pDisplay, "WM_NAME", False);
     atmWmHints = XInternAtom(pProcArg->pDisplay, "WM_HINTS", False);
     atmWmChange = XInternAtom(pProcArg->pDisplay, "WM_CHANGE_STATE", False);
+    atmNetWmIcon = XInternAtom(pProcArg->pDisplay, "_NET_WM_ICON", False);
 
     /*
        iiimxcf had a bug until 2009-04-27, assuming that the
@@ -1073,25 +1075,25 @@ winMultiWindowXMsgProc(void *pArg)
                            True, StructureNotifyMask, &event_send);
             }
         }
-        else if (event.type == PropertyNotify
-                 && event.xproperty.atom == atmWmName) {
-            memset(&msg, 0, sizeof(msg));
-
-            msg.msg = WM_WM_NAME_EVENT;
-            msg.iWindow = event.xproperty.window;
+        else if (event.type == PropertyNotify) {
+            if (event.xproperty.atom == atmWmName) {
+                memset(&msg, 0, sizeof(msg));
 
-            /* Other fields ignored */
-            winSendMessageToWM(pProcArg->pWMInfo, &msg);
-        }
-        else if (event.type == PropertyNotify
-                 && event.xproperty.atom == atmWmHints) {
-            memset(&msg, 0, sizeof(msg));
+                msg.msg = WM_WM_NAME_EVENT;
+                msg.iWindow = event.xproperty.window;
 
-            msg.msg = WM_WM_ICON_EVENT;
-            msg.iWindow = event.xproperty.window;
-
-            /* Other fields ignored */
-            winSendMessageToWM(pProcArg->pWMInfo, &msg);
+                /* Other fields ignored */
+                winSendMessageToWM(pProcArg->pWMInfo, &msg);
+            }
+            else if ((event.xproperty.atom == atmWmHints) ||
+                     (event.xproperty.atom == atmNetWmIcon)) {
+                memset(&msg, 0, sizeof(msg));
+                msg.msg = WM_WM_ICON_EVENT;
+                msg.iWindow = event.xproperty.window;
+
+                /* Other fields ignored */
+                winSendMessageToWM(pProcArg->pWMInfo, &msg);
+            }
         }
         else if (event.type == ClientMessage
                  && event.xclient.message_type == atmWmChange
commit a07541f1ffc28c57a762beefb96c7bf0ac40b0a4
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Sun Jul 22 16:15:12 2012 +0100

    hw/xwin: Rename WM_WM_HINTS_EVENT to WM_WM_ICON_EVENT
    
    WM_WM_HINTS_EVENT only updates the icon, so rename it to WM_WM_ICON_EVENT
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c
index 754b530..c30efa9 100644
--- a/hw/xwin/winmultiwindowwm.c
+++ b/hw/xwin/winmultiwindowwm.c
@@ -769,7 +769,7 @@ winMultiWindowWMProc(void *pArg)
             UpdateName(pWMInfo, pNode->msg.iWindow);
             break;
 
-        case WM_WM_HINTS_EVENT:
+        case WM_WM_ICON_EVENT:
             winUpdateIcon(pNode->msg.iWindow);
             break;
 
@@ -1087,7 +1087,7 @@ winMultiWindowXMsgProc(void *pArg)
                  && event.xproperty.atom == atmWmHints) {
             memset(&msg, 0, sizeof(msg));
 
-            msg.msg = WM_WM_HINTS_EVENT;
+            msg.msg = WM_WM_ICON_EVENT;
             msg.iWindow = event.xproperty.window;
 
             /* Other fields ignored */
diff --git a/hw/xwin/winwindow.h b/hw/xwin/winwindow.h
index c357f8d..9f2ab45 100644
--- a/hw/xwin/winwindow.h
+++ b/hw/xwin/winwindow.h
@@ -115,7 +115,7 @@ typedef struct _winWMMessageRec {
 #define		WM_WM_KILL		(WM_USER + 7)
 #define		WM_WM_ACTIVATE		(WM_USER + 8)
 #define		WM_WM_NAME_EVENT	(WM_USER + 9)
-#define		WM_WM_HINTS_EVENT	(WM_USER + 10)
+#define		WM_WM_ICON_EVENT	(WM_USER + 10)
 #define		WM_WM_CHANGE_STATE	(WM_USER + 11)
 #define		WM_WM_MAP2		(WM_USER + 12)
 #define		WM_WM_MAP3		(WM_USER + 13)
commit 2a47c91eb382d1ff0fb009a39efa7dc9c6fd5112
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Fri Jul 20 13:51:35 2012 +0100

    hw/xwin: Refactor Xutf8TextPropertyToString() from GetWindowName() as a separate utility function
    
    Simplify GetWindowName() by moving UTF-8 to wchar conversion out to it's call
    site.  This allows us to do extra processing on the window name in future.
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c
index 76b4683..754b530 100644
--- a/hw/xwin/winmultiwindowwm.c
+++ b/hw/xwin/winmultiwindowwm.c
@@ -151,7 +151,7 @@ static Bool
  InitQueue(WMMsgQueuePtr pQueue);
 
 static void
- GetWindowName(Display * pDpy, Window iWin, wchar_t ** ppName);
+ GetWindowName(Display * pDpy, Window iWin, char **ppWindowName);
 
 static int
  SendXMessage(Display * pDisplay, Window iWin, Atom atmType, long nData);
@@ -399,38 +399,19 @@ InitQueue(WMMsgQueuePtr pQueue)
     return TRUE;
 }
 
-/*
- * GetWindowName - Retrieve the title of an X Window
- */
-
-static void
-GetWindowName(Display * pDisplay, Window iWin, wchar_t ** ppName)
+static
+char *
+Xutf8TextPropertyToString(Display * pDisplay, XTextProperty * xtp)
 {
-    int nResult, nNum;
+    int nNum;
     char **ppList;
     char *pszReturnData;
-    int iLen, i;
-    XTextProperty xtpName;
-
-#if CYGMULTIWINDOW_DEBUG
-    ErrorF("GetWindowName\n");
-#endif
 
-    /* Intialize ppName to NULL */
-    *ppName = NULL;
+    if (Xutf8TextPropertyToTextList(pDisplay, xtp, &ppList, &nNum) >= Success &&
+        nNum > 0 && *ppList) {
+        int i;
+        int iLen = 0;
 
-    /* Try to get --- */
-    nResult = XGetWMName(pDisplay, iWin, &xtpName);
-    if (!nResult || !xtpName.value || !xtpName.nitems) {
-#if CYGMULTIWINDOW_DEBUG
-        ErrorF("GetWindowName - XGetWMName failed.  No name.\n");
-#endif
-        return;
-    }
-
-    if (Xutf8TextPropertyToTextList(pDisplay, &xtpName, &ppList, &nNum) >=
-        Success && nNum > 0 && *ppList) {
-        iLen = 0;
         for (i = 0; i < nNum; i++)
             iLen += strlen(ppList[i]);
         pszReturnData = (char *) malloc(iLen + 1);
@@ -444,15 +425,40 @@ GetWindowName(Display * pDisplay, Window iWin, wchar_t ** ppName)
         pszReturnData = (char *) malloc(1);
         pszReturnData[0] = '\0';
     }
-    iLen = MultiByteToWideChar(CP_UTF8, 0, pszReturnData, -1, NULL, 0);
-    *ppName = (wchar_t *) malloc(sizeof(wchar_t) * (iLen + 1));
-    MultiByteToWideChar(CP_UTF8, 0, pszReturnData, -1, *ppName, iLen);
-    XFree(xtpName.value);
-    free(pszReturnData);
 
+    return pszReturnData;
+}
+
+/*
+ * GetWindowName - Retrieve the title of an X Window
+ */
+
+static void
+GetWindowName(Display * pDisplay, Window iWin, char **ppWindowName)
+{
+    int nResult;
+    XTextProperty xtpWindowName;
+    char *pszWindowName;
+
+#if CYGMULTIWINDOW_DEBUG
+    ErrorF("GetWindowName\n");
+#endif
+
+    /* Intialize ppWindowName to NULL */
+    *ppWindowName = NULL;
+
+    /* Try to get window name */
+    nResult = XGetWMName(pDisplay, iWin, &xtpWindowName);
+    if (!nResult || !xtpWindowName.value || !xtpWindowName.nitems) {
 #if CYGMULTIWINDOW_DEBUG
-    ErrorF("GetWindowName - Returning\n");
+        ErrorF("GetWindowName - XGetWMName failed.  No name.\n");
 #endif
+        return;
+    }
+
+    pszWindowName = Xutf8TextPropertyToString(pDisplay, &xtpWindowName);
+    XFree(xtpWindowName.value);
+    *ppWindowName = pszWindowName;
 }
 
 /*
@@ -528,17 +534,30 @@ UpdateName(WMInfoPtr pWMInfo, Window iWindow)
     if (!hWnd)
         return;
 
-    /* Set the Windows window name */
-    GetWindowName(pWMInfo->pDisplay, iWindow, &pszName);
-    if (pszName) {
-        /* Get the window attributes */
-        XGetWindowAttributes(pWMInfo->pDisplay, iWindow, &attr);
-        if (!attr.override_redirect) {
-            SetWindowTextW(hWnd, pszName);
+    /* If window isn't override-redirect */
+    XGetWindowAttributes(pWMInfo->pDisplay, iWindow, &attr);
+    if (!attr.override_redirect) {
+        char *pszWindowName;
+
+        /* Get the X windows window name */
+        GetWindowName(pWMInfo->pDisplay, iWindow, &pszWindowName);
+
+        if (pszWindowName) {
+            /* Convert from UTF-8 to wide char */
+            int iLen =
+                MultiByteToWideChar(CP_UTF8, 0, pszWindowName, -1, NULL, 0);
+            wchar_t *pwszWideWindowName =
+                (wchar_t *) malloc(sizeof(wchar_t) * (iLen + 1));
+            MultiByteToWideChar(CP_UTF8, 0, pszWindowName, -1,
+                                pwszWideWindowName, iLen);
+
+            /* Set the Windows window name */
+            SetWindowTextW(hWnd, pwszWideWindowName);
             winUpdateIcon(iWindow);
-        }
 
-        free(pszName);
+            free(pwszWideWindowName);
+            free(pszWindowName);
+        }
     }
 }
 
commit aad428b8e21c77397c623b78706eb64b1fea77c9
Author: Dave Airlie <airlied at redhat.com>
Date:   Thu Jul 26 09:54:08 2012 +1000

    glx: drop GLX_LIBS from X server and workaround sdksyms.
    
    We've had reports of two copies of the GLX bits, one in the server
    and one in libglx.so causing problems, I didn't understand why the
    X server needed a copy so drop it, however then we have to fix a missing
    GlxExtensionInit that comes from sdksyms, so work around it by moving
    that one declaration into a header that sdksyms doesn't scan.
    
    Thanks to Jon Turney for debugging the actual problem.
    (copyright header from extinit.h that seems most appropriate put on top).
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=52402
    Tested-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>
    Tested-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Signed-off-by: Dave Airlie <airlied at redhat.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/configure.ac b/configure.ac
index 12fb28e..dc79e48 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1600,7 +1600,7 @@ if test "x$XORG" = xyes; then
 	XORG_OSINCS='-I$(top_srcdir)/hw/xfree86/os-support -I$(top_srcdir)/hw/xfree86/os-support/bus -I$(top_srcdir)/os'
 	XORG_INCS="$XORG_DDXINCS $XORG_OSINCS"
 	XORG_CFLAGS="$XORGSERVER_CFLAGS -DHAVE_XORG_CONFIG_H"
-	XORG_LIBS="$COMPOSITE_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $RECORD_LIB $GLX_LIBS $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $MIEXT_SYNC_LIB $MIEXT_DAMAGE_LIB $XI_LIB $XKB_LIB"
+	XORG_LIBS="$COMPOSITE_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $RECORD_LIB $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $MIEXT_SYNC_LIB $MIEXT_DAMAGE_LIB $XI_LIB $XKB_LIB"
 
 	dnl ==================================================================
 	dnl symbol visibility
diff --git a/glx/glxext.c b/glx/glxext.c
index 70f0df8..bc7fe82 100644
--- a/glx/glxext.c
+++ b/glx/glxext.c
@@ -40,6 +40,7 @@
 #include "privates.h"
 #include <os.h>
 #include "extinit.h"
+#include "glx_extinit.h"
 #include "unpack.h"
 #include "glxutil.h"
 #include "glxext.h"
diff --git a/hw/dmx/glxProxy/glxext.c b/hw/dmx/glxProxy/glxext.c
index 8122221..e72a040 100644
--- a/hw/dmx/glxProxy/glxext.c
+++ b/hw/dmx/glxProxy/glxext.c
@@ -45,6 +45,7 @@
 #include "micmap.h"
 #include "glxswap.h"
 #include "extinit.h"
+#include "glx_extinit.h"
 
 /*
 ** Forward declarations.
diff --git a/hw/xfree86/dixmods/glxmodule.c b/hw/xfree86/dixmods/glxmodule.c
index 5a9e845..c0c6114 100644
--- a/hw/xfree86/dixmods/glxmodule.c
+++ b/hw/xfree86/dixmods/glxmodule.c
@@ -43,6 +43,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "globals.h"
 #include "glxserver.h"
 #include "extinit.h"
+#include "glx_extinit.h"
 
 static MODULESETUPPROTO(glxSetup);
 
diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c
index 538b2e1..37cd8b3 100644
--- a/hw/xwin/InitOutput.c
+++ b/hw/xwin/InitOutput.c
@@ -55,6 +55,7 @@ typedef WINAPI HRESULT(*SHGETFOLDERPATHPROC) (HWND hwndOwner,
                                               DWORD dwFlags, LPTSTR pszPath);
 #endif
 
+#include "glx_extinit.h"
 /*
  * References to external symbols
  */
diff --git a/include/extinit.h b/include/extinit.h
index 6c5337f..7f4718f 100644
--- a/include/extinit.h
+++ b/include/extinit.h
@@ -83,7 +83,6 @@ extern void GEExtensionInit(void);
 
 #ifdef GLXEXT
 extern _X_EXPORT Bool noGlxExtension;
-extern void GlxExtensionInit(void);
 #endif
 
 #ifdef PANORAMIX
diff --git a/include/glx_extinit.h b/include/glx_extinit.h
new file mode 100644
index 0000000..ad4741d
--- /dev/null
+++ b/include/glx_extinit.h
@@ -0,0 +1,34 @@
+/*
+ * 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
+ * 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, FIT-
+ * NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall not
+ * be used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from the XFree86 Project.
+ */
+
+#ifndef GLX_EXT_INIT_H
+#define GLX_EXT_INIT_H
+
+/* this is separate due to sdksyms pulling in extinit.h */
+#ifdef GLXEXT
+extern void GlxExtensionInit(void);
+#endif
+
+#endif


More information about the Xquartz-changes mailing list