[Xquartz-changes] xserver: Branch 'server-1.16-apple' - 72 commits

Jeremy Huddleston jeremyhu at freedesktop.org
Mon Aug 18 13:06:21 PDT 2014


Rebased ref, commits from common ancestor:
commit 73ed5a39e3a6955834abe13a347dd70c5248a347
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Sun Jun 1 04:29:19 2014 -0700

    XQuartz: Advertise GLX_ARB_create_context and GLX_ARB_create_context_profile
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>

diff --git a/hw/xquartz/GL/indirect.c b/hw/xquartz/GL/indirect.c
index 19b7d86..d8f836d 100644
--- a/hw/xquartz/GL/indirect.c
+++ b/hw/xquartz/GL/indirect.c
@@ -52,6 +52,7 @@
 
 #include "visualConfigs.h"
 #include "dri.h"
+#include "extension_string.h"
 
 #include "darwin.h"
 #define GLAQUA_DEBUG_MSG(msg, args ...) ASL_LOG(ASL_LEVEL_DEBUG, "GLXAqua", \
@@ -111,6 +112,10 @@ typedef struct __GLXAquaDrawable __GLXAquaDrawable;
  */
 struct __GLXAquaScreen {
     __GLXscreen base;
+
+    /* Supported GLX extensions */
+    unsigned char glx_enable_bits[__GLX_EXT_BYTES];
+
     int index;
     int num_vis;
 };
@@ -541,13 +546,36 @@ __glXAquaScreenProbe(ScreenPtr pScreen)
 
     screen->base.GLXmajor = 1;
     screen->base.GLXminor = 4;
-    screen->base.GLXextensions = strdup("GLX_SGIX_fbconfig "
-                                        "GLX_SGIS_multisample "
-                                        "GLX_ARB_multisample "
-                                        "GLX_EXT_visual_info "
-                                        "GLX_EXT_import_context ");
 
-    /*We may be able to add more GLXextensions at a later time. */
+    memset(screen->glx_enable_bits, 0, __GLX_EXT_BYTES);
+
+    __glXEnableExtension(screen->glx_enable_bits, "GLX_EXT_visual_info");
+    __glXEnableExtension(screen->glx_enable_bits, "GLX_EXT_visual_rating");
+    __glXEnableExtension(screen->glx_enable_bits, "GLX_EXT_import_context");
+    __glXEnableExtension(screen->glx_enable_bits, "GLX_OML_swap_method");
+    __glXEnableExtension(screen->glx_enable_bits, "GLX_SGIX_fbconfig");
+
+    __glXEnableExtension(screen->glx_enable_bits, "GLX_SGIS_multisample");
+    __glXEnableExtension(screen->glx_enable_bits, "GLX_ARB_multisample");
+
+    __glXEnableExtension(screen->glx_enable_bits, "GLX_ARB_create_context");
+    __glXEnableExtension(screen->glx_enable_bits, "GLX_ARB_create_context_profile");
+
+    // Generate the GLX extensions string (overrides that set by __glXScreenInit())
+    {
+        unsigned int buffer_size =
+            __glXGetExtensionString(screen->glx_enable_bits, NULL);
+        if (buffer_size > 0) {
+            free(screen->base.GLXextensions);
+
+            screen->base.GLXextensions = xnfalloc(buffer_size);
+            __glXGetExtensionString(screen->glx_enable_bits,
+                                    screen->base.GLXextensions);
+        }
+    }
+
+    // Override the GL extensions string set by __glXScreenInit()
+    //screen->base.GLextensions = strdup(glGetString(GL_EXTENSIONS));
 
     return &screen->base;
 }
commit 923740dfc55b0b7e3495cbbd0a6a6a8fe86189fd
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Sat May 31 13:14:20 2014 -0700

    fb: Revert fb changes that broke XQuartz
    
        http://bugs.freedesktop.org/show_bug.cgi?id=26124
    
    Revert "Use new pixman_glyph_cache_t API that will be in pixman 0.28.0"
    Revert "fb: Fix origin of source picture in fbGlyphs"
    Revert "fb: Publish fbGlyphs and fbUnrealizeGlyph"
    
    This reverts commit 9cbcb5bd6a5360a128d15b77a02d8d3351f74366.
    This reverts commit 983e30361f49a67252d0b5d82630e70724d69dbf.
    This reverts commit 3c2c59eed3c68c0e5a93c38cf01eedad015e3157.

diff --git a/fb/fb.h b/fb/fb.h
index f584154..25a7eff 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -1310,9 +1310,6 @@ extern _X_EXPORT void
 extern _X_EXPORT Bool
  fbPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats);
 
-extern _X_EXPORT void
-fbDestroyGlyphCache(void);
-
 /*
  * fbpixmap.c
  */
diff --git a/fb/fbpict.c b/fb/fbpict.c
index e7a3811..276ff06 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -65,152 +65,6 @@ fbComposite(CARD8 op,
     free_pixman_pict(pDst, dest);
 }
 
-static pixman_glyph_cache_t *glyphCache;
-
-void
-fbDestroyGlyphCache(void)
-{
-    if (glyphCache)
-    {
-	pixman_glyph_cache_destroy (glyphCache);
-	glyphCache = NULL;
-    }
-}
-
-void
-fbUnrealizeGlyph(ScreenPtr pScreen,
-		 GlyphPtr pGlyph)
-{
-    if (glyphCache)
-	pixman_glyph_cache_remove (glyphCache, pGlyph, NULL);
-}
-
-void
-fbGlyphs(CARD8 op,
-	 PicturePtr pSrc,
-	 PicturePtr pDst,
-	 PictFormatPtr maskFormat,
-	 INT16 xSrc,
-	 INT16 ySrc, int nlist,
-	 GlyphListPtr list,
-	 GlyphPtr *glyphs)
-{
-#define N_STACK_GLYPHS 512
-    ScreenPtr pScreen = pDst->pDrawable->pScreen;
-    pixman_glyph_t stack_glyphs[N_STACK_GLYPHS];
-    pixman_glyph_t *pglyphs = stack_glyphs;
-    pixman_image_t *srcImage, *dstImage;
-    int srcXoff, srcYoff, dstXoff, dstYoff;
-    GlyphPtr glyph;
-    int n_glyphs;
-    int x, y;
-    int i, n;
-    int xDst = list->xOff, yDst = list->yOff;
-
-    miCompositeSourceValidate(pSrc);
-    
-    n_glyphs = 0;
-    for (i = 0; i < nlist; ++i)
-	n_glyphs += list[i].len;
-
-    if (!glyphCache)
-	glyphCache = pixman_glyph_cache_create();
-
-    pixman_glyph_cache_freeze (glyphCache);
-    
-    if (n_glyphs > N_STACK_GLYPHS) {
-	if (!(pglyphs = malloc (n_glyphs * sizeof (pixman_glyph_t))))
-	    goto out;
-    }
-    
-    i = 0;
-    x = y = 0;
-    while (nlist--) {
-        x += list->xOff;
-        y += list->yOff;
-        n = list->len;
-        while (n--) {
-	    const void *g;
-
-            glyph = *glyphs++;
-
-	    if (!(g = pixman_glyph_cache_lookup (glyphCache, glyph, NULL))) {
-		pixman_image_t *glyphImage;
-		PicturePtr pPicture;
-		int xoff, yoff;
-
-		pPicture = GetGlyphPicture(glyph, pScreen);
-		if (!pPicture) {
-		    n_glyphs--;
-		    goto next;
-		}
-
-		if (!(glyphImage = image_from_pict(pPicture, FALSE, &xoff, &yoff)))
-		    goto out;
-
-		g = pixman_glyph_cache_insert(glyphCache, glyph, NULL,
-					      glyph->info.x,
-					      glyph->info.y,
-					      glyphImage);
-
-		free_pixman_pict(pPicture, glyphImage);
-
-		if (!g)
-		    goto out;
-	    }
-
-	    pglyphs[i].x = x;
-	    pglyphs[i].y = y;
-	    pglyphs[i].glyph = g;
-	    i++;
-
-	next:
-            x += glyph->info.xOff;
-            y += glyph->info.yOff;
-	}
-	list++;
-    }
-
-    if (!(srcImage = image_from_pict(pSrc, FALSE, &srcXoff, &srcYoff)))
-	goto out;
-
-    if (!(dstImage = image_from_pict(pDst, TRUE, &dstXoff, &dstYoff)))
-	goto out_free_src;
-
-    if (maskFormat) {
-	pixman_format_code_t format;
-	pixman_box32_t extents;
-
-	format = maskFormat->format | (maskFormat->depth << 24);
-
-	pixman_glyph_get_extents(glyphCache, n_glyphs, pglyphs, &extents);
-
-	pixman_composite_glyphs(op, srcImage, dstImage, format,
-				xSrc + srcXoff + extents.x1 - xDst, ySrc + srcYoff + extents.y1 - yDst,
-				extents.x1, extents.y1,
-				extents.x1 + dstXoff, extents.y1 + dstYoff,
-				extents.x2 - extents.x1,
-				extents.y2 - extents.y1,
-				glyphCache, n_glyphs, pglyphs);
-    }
-    else {
-	pixman_composite_glyphs_no_mask(op, srcImage, dstImage,
-					xSrc + srcXoff - xDst, ySrc + srcYoff - yDst,
-					dstXoff, dstYoff,
-					glyphCache, n_glyphs, pglyphs);
-    }
-
-    free_pixman_pict(pDst, dstImage);
-
-out_free_src:
-    free_pixman_pict(pSrc, srcImage);
-
-out:
-    pixman_glyph_cache_thaw(glyphCache);
-    if (pglyphs != stack_glyphs)
-	free(pglyphs);
-}
-
 static pixman_image_t *
 create_solid_fill_image(PicturePtr pict)
 {
@@ -469,8 +323,7 @@ fbPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats)
         return FALSE;
     ps = GetPictureScreen(pScreen);
     ps->Composite = fbComposite;
-    ps->Glyphs = fbGlyphs;
-    ps->UnrealizeGlyph = fbUnrealizeGlyph;
+    ps->Glyphs = miGlyphs;
     ps->CompositeRects = miCompositeRects;
     ps->RasterizeTrapezoid = fbRasterizeTrapezoid;
     ps->AddTraps = fbAddTraps;
diff --git a/fb/fbpict.h b/fb/fbpict.h
index 8b0f59f..110f32d 100644
--- a/fb/fbpict.h
+++ b/fb/fbpict.h
@@ -65,24 +65,11 @@ fbTrapezoids(CARD8 op,
              INT16 xSrc, INT16 ySrc, int ntrap, xTrapezoid * traps);
 
 extern _X_EXPORT void
+
 fbTriangles(CARD8 op,
             PicturePtr pSrc,
             PicturePtr pDst,
             PictFormatPtr maskFormat,
             INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris);
 
-extern _X_EXPORT void
-fbUnrealizeGlyph(ScreenPtr pScreen,
-		 GlyphPtr pGlyph);
-
-extern _X_EXPORT void
-fbGlyphs(CARD8 op,
-	 PicturePtr pSrc,
-	 PicturePtr pDst,
-	 PictFormatPtr maskFormat,
-	 INT16 xSrc,
-	 INT16 ySrc, int nlist,
-	 GlyphListPtr list,
-	 GlyphPtr *glyphs);
-
 #endif                          /* _FBPICT_H_ */
diff --git a/fb/fbscreen.c b/fb/fbscreen.c
index 0d4d87f..e6ff1bd 100644
--- a/fb/fbscreen.c
+++ b/fb/fbscreen.c
@@ -32,7 +32,6 @@ fbCloseScreen(ScreenPtr pScreen)
     int d;
     DepthPtr depths = pScreen->allowedDepths;
 
-    fbDestroyGlyphCache();
     for (d = 0; d < pScreen->numDepths; d++)
         free(depths[d].vids);
     free(depths);
commit 0c3bf02ba1982bcfce8cef13bd0afa11c49fe796
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 9057767..f584154 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -1652,8 +1652,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 65eb2a4..e7a3811 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);
@@ -289,20 +284,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)
@@ -329,57 +326,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) {
@@ -407,10 +378,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);
@@ -444,8 +413,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;
 
@@ -453,7 +421,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;
@@ -471,19 +439,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 29c3bb27a56a6120b583a0ff4e36b4ae8b13c002
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Sat Nov 2 11:00:23 2013 -0700

    Use old miTrapezoids and miTriangles routines
    
    Reverts commits:
        788ccb9a8bcf6a4fb4054c507111eec3338fb969
        566f1931ee2916269e164e114bffaf2da1d039d1
    
    http://xquartz.macosforge.org/trac/ticket/525
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>

diff --git a/fb/fbpict.c b/fb/fbpict.c
index 21baf89..65eb2a4 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -507,10 +507,8 @@ fbPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats)
     ps->UnrealizeGlyph = fbUnrealizeGlyph;
     ps->CompositeRects = miCompositeRects;
     ps->RasterizeTrapezoid = fbRasterizeTrapezoid;
-    ps->Trapezoids = fbTrapezoids;
     ps->AddTraps = fbAddTraps;
     ps->AddTriangles = fbAddTriangles;
-    ps->Triangles = fbTriangles;
 
     return TRUE;
 }
diff --git a/render/mipict.c b/render/mipict.c
index 3959fc4..2bb1a1d 100644
--- a/render/mipict.c
+++ b/render/mipict.c
@@ -595,8 +595,8 @@ miPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats)
     ps->Composite = 0;          /* requires DDX support */
     ps->Glyphs = miGlyphs;
     ps->CompositeRects = miCompositeRects;
-    ps->Trapezoids = 0;
-    ps->Triangles = 0;
+    ps->Trapezoids = miTrapezoids;
+    ps->Triangles = miTriangles;
 
     ps->RasterizeTrapezoid = 0; /* requires DDX support */
     ps->AddTraps = 0;           /* requires DDX support */
diff --git a/render/mipict.h b/render/mipict.h
index a16dd31..ee90b58 100644
--- a/render/mipict.h
+++ b/render/mipict.h
@@ -122,6 +122,16 @@ miCompositeRects(CARD8 op,
                  xRenderColor * color, int nRect, xRectangle *rects);
 
 extern _X_EXPORT void
+miTriangles (CARD8	    op,
+	     PicturePtr	    pSrc,
+	     PicturePtr	    pDst,
+	     PictFormatPtr  maskFormat,
+	     INT16	    xSrc,
+	     INT16	    ySrc,
+	     int	    ntri,
+	     xTriangle	    *tris);
+
+extern _X_EXPORT void
 
 miTriStrip(CARD8 op,
            PicturePtr pSrc,
@@ -137,10 +147,27 @@ miTriFan(CARD8 op,
          PictFormatPtr maskFormat,
          INT16 xSrc, INT16 ySrc, int npoints, xPointFixed * points);
 
+extern _X_EXPORT PicturePtr
+miCreateAlphaPicture (ScreenPtr	    pScreen, 
+		      PicturePtr    pDst,
+		      PictFormatPtr pPictFormat,
+		      CARD16	    width,
+		      CARD16	    height);
+
 extern _X_EXPORT void
  miTrapezoidBounds(int ntrap, xTrapezoid * traps, BoxPtr box);
 
 extern _X_EXPORT void
+miTrapezoids (CARD8        op,
+             PicturePtr    pSrc,
+             PicturePtr    pDst,
+             PictFormatPtr maskFormat,
+             INT16         xSrc,
+             INT16         ySrc,
+             int           ntrap,
+             xTrapezoid    *traps);
+
+extern _X_EXPORT void
  miPointFixedBounds(int npoint, xPointFixed * points, BoxPtr bounds);
 
 extern _X_EXPORT void
diff --git a/render/mitrap.c b/render/mitrap.c
index 17b6dcd..71c1857 100644
--- a/render/mitrap.c
+++ b/render/mitrap.c
@@ -34,6 +34,55 @@
 #include "picturestr.h"
 #include "mipict.h"
 
+PicturePtr
+miCreateAlphaPicture (ScreenPtr	    pScreen, 
+		      PicturePtr    pDst,
+		      PictFormatPtr pPictFormat,
+		      CARD16	    width,
+		      CARD16	    height)
+{
+    PixmapPtr	    pPixmap;
+    PicturePtr	    pPicture;
+    GCPtr	    pGC;
+    int		    error;
+    xRectangle	    rect;
+
+    if (width > 32767 || height > 32767)
+	return 0;
+
+    if (!pPictFormat)
+    {
+	if (pDst->polyEdge == PolyEdgeSharp)
+	    pPictFormat = PictureMatchFormat (pScreen, 1, PICT_a1);
+	else
+	    pPictFormat = PictureMatchFormat (pScreen, 8, PICT_a8);
+	if (!pPictFormat)
+	    return 0;
+    }
+
+    pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, 
+					pPictFormat->depth, 0);
+    if (!pPixmap)
+	return 0;
+    pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
+    if (!pGC)
+    {
+	(*pScreen->DestroyPixmap) (pPixmap);
+	return 0;
+    }
+    ValidateGC (&pPixmap->drawable, pGC);
+    rect.x = 0;
+    rect.y = 0;
+    rect.width = width;
+    rect.height = height;
+    (*pGC->ops->PolyFillRect)(&pPixmap->drawable, pGC, 1, &rect);
+    FreeScratchGC (pGC);
+    pPicture = CreatePicture (0, &pPixmap->drawable, pPictFormat,
+			      0, 0, serverClient, &error);
+    (*pScreen->DestroyPixmap) (pPixmap);
+    return pPicture;
+}
+
 static xFixed
 miLineFixedX(xLineFixed * l, xFixed y, Bool ceil)
 {
@@ -79,3 +128,65 @@ miTrapezoidBounds(int ntrap, xTrapezoid * traps, BoxPtr box)
             box->x2 = x2;
     }
 }
+
+
+void
+miTrapezoids (CARD8        op,
+             PicturePtr    pSrc,
+             PicturePtr    pDst,
+             PictFormatPtr maskFormat,
+             INT16         xSrc,
+             INT16         ySrc,
+             int           ntrap,
+             xTrapezoid    *traps)
+{
+    ScreenPtr          pScreen = pDst->pDrawable->pScreen;
+    PictureScreenPtr    ps = GetPictureScreen(pScreen);
+
+    /*
+     * Check for solid alpha add
+     */
+    if (op == PictOpAdd && miIsSolidAlpha (pSrc))
+    {
+       for (; ntrap; ntrap--, traps++)
+           (*ps->RasterizeTrapezoid) (pDst, traps, 0, 0);
+    } 
+    else if (maskFormat)
+    {
+       PicturePtr      pPicture;
+       BoxRec          bounds;
+       INT16           xDst, yDst;
+       INT16           xRel, yRel;
+       
+       xDst = traps[0].left.p1.x >> 16;
+       yDst = traps[0].left.p1.y >> 16;
+
+       miTrapezoidBounds (ntrap, traps, &bounds);
+       if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2)
+           return;
+       pPicture = miCreateAlphaPicture (pScreen, pDst, maskFormat,
+                                        bounds.x2 - bounds.x1,
+                                        bounds.y2 - bounds.y1);
+       if (!pPicture)
+           return;
+       for (; ntrap; ntrap--, traps++)
+           (*ps->RasterizeTrapezoid) (pPicture, traps, 
+                                      -bounds.x1, -bounds.y1);
+       xRel = bounds.x1 + xSrc - xDst;
+       yRel = bounds.y1 + ySrc - yDst;
+       CompositePicture (op, pSrc, pPicture, pDst,
+                         xRel, yRel, 0, 0, bounds.x1, bounds.y1,
+                         bounds.x2 - bounds.x1,
+                         bounds.y2 - bounds.y1);
+       FreePicture (pPicture, 0);
+    }
+    else
+    {
+       if (pDst->polyEdge == PolyEdgeSharp)
+           maskFormat = PictureMatchFormat (pScreen, 1, PICT_a1);
+       else
+           maskFormat = PictureMatchFormat (pScreen, 8, PICT_a8);
+       for (; ntrap; ntrap--, traps++)
+           miTrapezoids (op, pSrc, pDst, maskFormat, xSrc, ySrc, 1, traps);
+    }
+}
diff --git a/render/mitri.c b/render/mitri.c
index 922f22a..bdca9ca 100644
--- a/render/mitri.c
+++ b/render/mitri.c
@@ -65,3 +65,64 @@ miTriangleBounds(int ntri, xTriangle * tris, BoxPtr bounds)
 {
     miPointFixedBounds(ntri * 3, (xPointFixed *) tris, bounds);
 }
+
+
+void
+miTriangles (CARD8	    op,
+	     PicturePtr	    pSrc,
+	     PicturePtr	    pDst,
+	     PictFormatPtr  maskFormat,
+	     INT16	    xSrc,
+	     INT16	    ySrc,
+	     int	    ntri,
+	     xTriangle	    *tris)
+{
+    ScreenPtr		pScreen = pDst->pDrawable->pScreen;
+    PictureScreenPtr    ps = GetPictureScreen(pScreen);
+    
+    /*
+     * Check for solid alpha add
+     */
+    if (op == PictOpAdd && miIsSolidAlpha (pSrc))
+    {
+	(*ps->AddTriangles) (pDst, 0, 0, ntri, tris);
+    }
+    else if (maskFormat)
+    {
+	BoxRec		bounds;
+	PicturePtr	pPicture;
+	INT16		xDst, yDst;
+	INT16		xRel, yRel;
+	
+	xDst = tris[0].p1.x >> 16;
+	yDst = tris[0].p1.y >> 16;
+
+	miTriangleBounds (ntri, tris, &bounds);
+	if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1)
+	    return;
+	pPicture = miCreateAlphaPicture (pScreen, pDst, maskFormat,
+					 bounds.x2 - bounds.x1,
+					 bounds.y2 - bounds.y1);
+	if (!pPicture)
+	    return;
+	(*ps->AddTriangles) (pPicture, -bounds.x1, -bounds.y1, ntri, tris);
+	
+	xRel = bounds.x1 + xSrc - xDst;
+	yRel = bounds.y1 + ySrc - yDst;
+	CompositePicture (op, pSrc, pPicture, pDst,
+			  xRel, yRel, 0, 0, bounds.x1, bounds.y1,
+			  bounds.x2 - bounds.x1, bounds.y2 - bounds.y1);
+	FreePicture (pPicture, 0);
+    }
+    else
+    {
+	if (pDst->polyEdge == PolyEdgeSharp)
+	    maskFormat = PictureMatchFormat (pScreen, 1, PICT_a1);
+	else
+	    maskFormat = PictureMatchFormat (pScreen, 8, PICT_a8);
+	
+	for (; ntri; ntri--, tris++)
+	    miTriangles (op, pSrc, pDst, maskFormat, xSrc, ySrc, 1, tris);
+    }
+}
+
commit 1b47538d15f803b3ae45feb0d092b991118940bb
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 198c433..ad1621d 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 fcc77206683e2e13d8287598599fa2a2bffe336c
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 c5992c3..71b6769 100644
--- a/hw/xfree86/Makefile.am
+++ b/hw/xfree86/Makefile.am
@@ -48,8 +48,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 = $(XORG_INCS) -I$(srcdir)/parser -I$(top_srcdir)/miext/cw \
+AM_CPPFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@ $(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 -I$(top_srcdir)/dri3
 
@@ -135,7 +134,7 @@ CLEANFILES = sdksyms.c sdksyms.dep Xorg.sh
 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) $(AM_CPPFLAGS)
+	$(AM_V_GEN)CPP='$(CPP)' AWK='$(AWK)' $(SHELL) $(srcdir)/sdksyms.sh $(top_srcdir) $(CPPFLAGS) $(AM_CPPFLAGS)
 
 SDKSYMS_DEP = sdksyms.dep
 -include $(SDKSYMS_DEP)
commit af2e9e3bb173885106f041f89b9f39b57fe3550a
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Mon Aug 11 13:15:24 2014 -0700

    XQuartz: Better support turning off "Displays have separate Spaces" on OS X Mavericks
    
    http://xquartz.macosforge.org/trac/ticket/1876
    
    Follow-up to: 1c10b37380d228b35db8a8616a6312ac54f5e59b
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
    (cherry picked from commit ab32ee35890be51137b56525826ffe219b63eb88)

diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c
index 7aa1ae1..d0a525f 100644
--- a/hw/xquartz/xpr/xprScreen.c
+++ b/hw/xquartz/xpr/xprScreen.c
@@ -169,14 +169,25 @@ displayScreenBounds(CGDirectDisplayID id)
               (int)frame.size.width, (int)frame.size.height,
               (int)frame.origin.x, (int)frame.origin.y);
 
-    /* Remove menubar to help standard X11 window managers.
-     * On Mavericks and later, the menu bar is on all displays.
-     */
-    if (XQuartzIsRootless
+    Boolean spacePerDisplay = false;
 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1090
-        && (NSAppKitVersionNumber >= 1265 || (frame.origin.x == 0 && frame.origin.y == 0))
+    if (NSAppKitVersionNumber >= 1265)
 #endif
-        ) {
+    {
+        Boolean ok;
+        (void)CFPreferencesAppSynchronize(CFSTR("com.apple.spaces"));
+        spacePerDisplay = ! CFPreferencesGetAppBooleanValue(CFSTR("spans-displays"),
+                                                            CFSTR("com.apple.spaces"),
+                                                            &ok);
+        if (!ok)
+            spacePerDisplay = true;
+    }
+
+    /* Remove menubar to help standard X11 window managers.
+     * On Mavericks and later, the menu bar is on all displays when spans-displays is false or unset.
+     */
+    if (XQuartzIsRootless &&
+        (spacePerDisplay || (frame.origin.x == 0 && frame.origin.y == 0))) {
         frame.origin.y += aquaMenuBarHeight;
         frame.size.height -= aquaMenuBarHeight;
     }
commit b7a24467f738bfd9437e8de02ed5e44409054185
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Wed Jul 23 11:53:33 2014 -0700

    ListenOnOpenFD: Remove Resets since this is intended to be for hotplugging connections
    
    pharris says that the resets should not be done in the hotplugging case.
    
    This may fix a crash reported against XQuartz:
    http://xquartz.macosforge.org/trac/ticket/869
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
    Reviewed-by: Peter Harris <pharris at opentext.com>
    (cherry picked from commit dfbc6a1a78ff3192baae6f7f2af98b6e51422f75)

diff --git a/os/connection.c b/os/connection.c
index 40d9ff3..f915e12 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -1307,13 +1307,6 @@ ListenOnOpenFD(int fd, int noxauth)
 
     /* Increment the count */
     ListenTransCount++;
-
-    /* This *might* not be needed... /shrug */
-    ResetAuthorization();
-    ResetHosts(display);
-#ifdef XDMCP
-    XdmcpReset();
-#endif
 }
 
 /* based on TRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status) */
commit a793483e38bfb8af19877f69e873c1776de18d1f
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Sat Jul 19 17:08:09 2014 -0700

    mieq: Fix a crash regression in mieqProcessDeviceEvent
    
    (lldb) bt
    * thread #6: tid = 0x92d4eb, 0x00000001001dee94 X11.bin`mieqProcessDeviceEvent(dev=0x0000000000000000, event=0x0000000100298bb0,
    screen=0x0000000000000000) + 36 at mieq.c:519, stop reason = EXC_BAD_ACCESS (code=1, address=0x44)
      * frame #0: 0x00000001001dee94 X11.bin`mieqProcessDeviceEvent(dev=0x0000000000000000, event=0x0000000100298bb0, screen=0x0000000000000000) + 36 at
    mieq.c:519
        frame #1: 0x00000001001df3eb X11.bin`mieqProcessInputEvents + 555 at mieq.c:631
        frame #2: 0x0000000100017674 X11.bin`ProcessInputEvents + 20 at darwinEvents.c:422
        frame #3: 0x0000000100175eaa X11.bin`Dispatch + 154 at dispatch.c:357
        frame #4: 0x0000000100181b4a X11.bin`dix_main(argc=4, argv=0x00007fff5fbff750, envp=0x00007fff5fbff650) + 1594 at main.c:296
        frame #5: 0x000000010001ba80 X11.bin`server_thread(arg=0x0000000101208220) + 64 at quartzStartup.c:66
        frame #6: 0x00007fff89bb9899 libsystem_pthread.dylib`_pthread_body + 138
        frame #7: 0x00007fff89bb972a libsystem_pthread.dylib`_pthread_start + 137
        frame #8: 0x00007fff89bbdfc9 libsystem_pthread.dylib`thread_start + 13
    
    Regression from: 9fb08310b51b46736f3ca8dbc04efdf502420403
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    (cherry picked from commit 1faa76670572e3478965fd2cd9ab60ab2d865e3a)

diff --git a/mi/mieq.c b/mi/mieq.c
index 872ff93..8907a6e 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -516,7 +516,7 @@ mieqProcessDeviceEvent(DeviceIntPtr dev, InternalEvent *event, ScreenPtr screen)
     verify_internal_event(event);
 
     /* refuse events from disabled devices */
-    if (!dev->enabled)
+    if (dev && !dev->enabled)
         return;
 
     /* Custom event handler */
commit 3c0431b8911241552a15a43e4279c50658b50a18
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Jul 16 16:03:23 2014 -0700

    glamor: Fix temp picture coordinates in glamor_composite_clipped_region
    
    To understand this patch, let's start at the protocol interface where
    the relationship between the coordinate spaces is documented:
    
            static Bool
            _glamor_composite(CARD8 op,
                              PicturePtr source,
                              PicturePtr mask,
                              PicturePtr dest,
                              INT16 x_source,
                              INT16 y_source,
                              INT16 x_mask,
                              INT16 y_mask,
                              INT16 x_dest, INT16 y_dest,
                              CARD16 width, CARD16 height, Bool fallback)
    
    The coordinates are passed to this function directly off the wire and
    are all relative to their respective drawables. For Windows, this means
    that they are relative to the upper left corner of the window, in
    whatever pixmap that window is getting drawn to.
    
    _glamor_composite calls miComputeCompositeRegion to construct a clipped
    region to actually render to. In reality, miComputeCompositeRegion clips
    only to the destination these days; source clip region based clipping
    would have to respect the transform, which isn't really possible. The
    returned region is relative to the screen in which dest lives; offset by
    dest->drawable.x and dest->drawable.y.
    
    What is important to realize here is that, because of clipping, the
    composite region may not have the same position within the destination
    drawable as x_dest, y_dest. The protocol coordinates now exist solely to
    'pin' the three objects together.
    
            extents->x1,y1		Screen origin of clipped operation
            width,height            Extents of the clipped operation
            x_dest,y_dest		Unclipped destination-relative operation coordinate
            x_source,y_source	Unclipped source-relative operation coordinate
            x_mask,y_mask		Unclipped mask-relative operation coordinate
    
    One thing we want to know is what the offset is from the original
    operation origin to the clipped origin
    
            Destination drawable relative coordinates of the clipped operation:
    
                   x_dest_clipped = extents->x1 - dest->drawable.x
                   y_dest_clipped = extents->y1 - dest->drawable.y
    
            Offset from the original operation origin:
    
                    x_off_clipped = x_dest_clipped - x_dest
                    y_off_clipped = y_dest_clipped - y_dest
    
            Source drawable relative coordinates of the clipped operation:
    
                    x_source_clipped = x_source + x_off_clipped;
                    y_source_clipped = y_source + y_off_clipped;
    
            Mask drawable relative coordinates of the clipped operation:
    
                    x_mask_clipped = x_source + x_off_clipped;
                    y_mask_clipped = y_source + y_off_clipped;
    
    This is where the original code fails -- it doesn't subtract the
    destination drawable location when computing the distance that the
    operation has been moved by clipping. Here's what it does when
    constructing a temporary source picture:
    
            temp_src =
                glamor_convert_gradient_picture(screen, source,
                                                extent->x1 + x_source - x_dest,
                                                extent->y1 + y_source - y_dest,
                                                width, height);
            ...
            x_temp_src = -extent->x1 + x_dest;
            y_temp_src = -extent->y1 + y_dest;
    
    glamor_convert_gradient_picture needs source drawable relative
    coordinates, but that is not what it's getting; it's getting
    screen-relative coordinates for the destination, adjusted by the
    distance between the provided source and destination operation
    coordinates. We want x_source_clipped and y_source_clipped:
    
            x_source_clipped = x_source + x_off_clipped
                             = x_source + x_dest_clipped - x_dest
                             = x_source + extents->x1 - dest->drawable.x - x_dest
    
    x_temp_src/y_temp_src are supposed to be the coordinates of the original
    operation translated to the temporary picture:
    
            x_temp_src = x_source - x_source_clipped;
            y_temp_src = y_source - y_source_clipped;
    
    Note that x_source_clipped/y_source_clipped will never be less than
    x_source/y_source because all we're doing is clipping. This means that
    x_temp_src/y_temp_src will always be non-positive; the original source
    coordinate can never be strictly *inside* the temporary image or we
    could have made the temporary image smaller.
    
            x_temp_src = x_source - x_source_clipped
                       = x_source - (x_source + x_off_clipped)
                       = -x_off_clipped
                       = x_dest - x_dest_clipped
                       = x_dest - (extents->x1 - dest->drawable.x)
    
    Again, this is off by the destination origin within the screen
    coordinate space.
    
    The code should look like:
    
            temp_src =
                glamor_convert_gradient_picture(screen, source,
                                                extent->x1 + x_source - x_dest - dest->pDrawable->x,
                                                extent->y1 + y_source - y_dest - dest->pDrawable->y,
                                                width, height);
    
            x_temp_src = -extent->x1 + x_dest + dest->pDrawable->x;
            y_temp_src = -extent->y1 + y_dest + dest->pDrawable->y;
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Markus Wick <markus at selfnet.de>
    (cherry picked from commit 55f5bfb578e934319d1308cbb56c900c5ac7cfa7)
    Signed-off-by: Julien Cristau <jcristau at debian.org>

diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c
index 14ab738..e5d5d2c 100644
--- a/glamor/glamor_render.c
+++ b/glamor/glamor_render.c
@@ -1450,8 +1450,8 @@ glamor_composite_clipped_region(CARD8 op,
                     || source_pixmap->drawable.height != height)))) {
         temp_src =
             glamor_convert_gradient_picture(screen, source,
-                                            extent->x1 + x_source - x_dest,
-                                            extent->y1 + y_source - y_dest,
+                                            extent->x1 + x_source - x_dest - dest->pDrawable->x,
+                                            extent->y1 + y_source - y_dest - dest->pDrawable->y,
                                             width, height);
         if (!temp_src) {
             temp_src = source;
@@ -1459,8 +1459,8 @@ glamor_composite_clipped_region(CARD8 op,
         }
         temp_src_priv =
             glamor_get_pixmap_private((PixmapPtr) (temp_src->pDrawable));
-        x_temp_src = -extent->x1 + x_dest;
-        y_temp_src = -extent->y1 + y_dest;
+        x_temp_src = -extent->x1 + x_dest + dest->pDrawable->x;
+        y_temp_src = -extent->y1 + y_dest + dest->pDrawable->y;
     }
 
     if (mask
@@ -1474,8 +1474,8 @@ glamor_composite_clipped_region(CARD8 op,
          * to do reduce one convertion. */
         temp_mask =
             glamor_convert_gradient_picture(screen, mask,
-                                            extent->x1 + x_mask - x_dest,
-                                            extent->y1 + y_mask - y_dest,
+                                            extent->x1 + x_mask - x_dest - dest->pDrawable->x,
+                                            extent->y1 + y_mask - y_dest - dest->pDrawable->y,
                                             width, height);
         if (!temp_mask) {
             temp_mask = mask;
@@ -1483,8 +1483,8 @@ glamor_composite_clipped_region(CARD8 op,
         }
         temp_mask_priv =
             glamor_get_pixmap_private((PixmapPtr) (temp_mask->pDrawable));
-        x_temp_mask = -extent->x1 + x_dest;
-        y_temp_mask = -extent->y1 + y_dest;
+        x_temp_mask = -extent->x1 + x_dest + dest->pDrawable->x;
+        y_temp_mask = -extent->y1 + y_dest + dest->pDrawable->y;
     }
     /* Do two-pass PictOpOver componentAlpha, until we enable
      * dual source color blending.
commit 8b36e1ec8dd9f53e9f4e10422c2100844e9e549c
Author: Keith Packard <keithp at keithp.com>
Date:   Thu Jul 17 00:03:33 2014 -0700

    Update to version 1.16.0
    
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/configure.ac b/configure.ac
index c214638..1c327fd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,9 +26,9 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ(2.60)
-AC_INIT([xorg-server], 1.15.99.904, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
-RELEASE_DATE="2014-07-07"
-RELEASE_NAME="Netarts Bay Oysters"
+AC_INIT([xorg-server], 1.16.0, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+RELEASE_DATE="2014-07-16"
+RELEASE_NAME="Marionberry Pie"
 AC_CONFIG_SRCDIR([Makefile.am])
 AC_CONFIG_MACRO_DIR([m4])
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
commit 4dbb641bb2d4037f107b58b31e80963dc8b72c0e
Author: Hans de Goede <hdegoede at redhat.com>
Date:   Mon Jul 14 14:01:47 2014 +0200

    config_odev_add_attribute*: Check for right attribute type
    
    Don't allow setting string attributes to integers and vice versa.
    
    Signed-off-by: Hans de Goede <hdegoede at redhat.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/config/config.c b/config/config.c
index 5514516..a26d835 100644
--- a/config/config.c
+++ b/config/config.c
@@ -172,12 +172,38 @@ config_odev_find_or_add_attribute(struct OdevAttributes *attribs, int attrib)
     return oa;
 }
 
+static int config_odev_get_attribute_type(int attrib)
+{
+    switch (attrib) {
+    case ODEV_ATTRIB_PATH:
+    case ODEV_ATTRIB_SYSPATH:
+    case ODEV_ATTRIB_BUSID:
+        return ODEV_ATTRIB_STRING;
+    case ODEV_ATTRIB_FD:
+    case ODEV_ATTRIB_MAJOR:
+    case ODEV_ATTRIB_MINOR:
+        return ODEV_ATTRIB_INT;
+    case ODEV_ATTRIB_DRIVER:
+        return ODEV_ATTRIB_STRING;
+    default:
+        LogMessage(X_ERROR, "Error %s called for unknown attribute %d\n",
+                   __func__, attrib);
+        return ODEV_ATTRIB_UNKNOWN;
+    }
+}
+
 Bool
 config_odev_add_attribute(struct OdevAttributes *attribs, int attrib,
                           const char *attrib_name)
 {
     struct OdevAttribute *oa;
 
+    if (config_odev_get_attribute_type(attrib) != ODEV_ATTRIB_STRING) {
+        LogMessage(X_ERROR, "Error %s called for non string attrib %d\n",
+                   __func__, attrib);
+        return FALSE;
+    }
+
     oa = config_odev_find_or_add_attribute(attribs, attrib);
     free(oa->attrib_name);
     oa->attrib_name = XNFstrdup(attrib_name);
@@ -191,6 +217,12 @@ config_odev_add_int_attribute(struct OdevAttributes *attribs, int attrib,
 {
     struct OdevAttribute *oa;
 
+    if (config_odev_get_attribute_type(attrib) != ODEV_ATTRIB_INT) {
+        LogMessage(X_ERROR, "Error %s called for non integer attrib %d\n",
+                   __func__, attrib);
+        return FALSE;
+    }
+
     oa = config_odev_find_or_add_attribute(attribs, attrib);
     oa->attrib_value = attrib_value;
     oa->attrib_type = ODEV_ATTRIB_INT;
diff --git a/include/hotplug.h b/include/hotplug.h
index b2c0d78..4c2fa97 100644
--- a/include/hotplug.h
+++ b/include/hotplug.h
@@ -32,7 +32,7 @@ extern _X_EXPORT void config_pre_init(void);
 extern _X_EXPORT void config_init(void);
 extern _X_EXPORT void config_fini(void);
 
-enum { ODEV_ATTRIB_STRING, ODEV_ATTRIB_INT };
+enum { ODEV_ATTRIB_UNKNOWN = -1, ODEV_ATTRIB_STRING = 0, ODEV_ATTRIB_INT };
 
 struct OdevAttribute {
     struct xorg_list member;
commit 25eca7ce35973577c8d85704c270f7fb53e6732e
Author: Hans de Goede <hdegoede at redhat.com>
Date:   Mon Jul 14 14:01:46 2014 +0200

    Fix ODEV_ATTRIB_DRIVER overlapping with ODEV_ATTRIB_FD
    
    Looks like the value of ODEV_ATTRIB_DRIVER was not updated when the patch
    adding it got rebased on top of a newer server version.
    
    This fixes the xserver crashing when systemd-logind integration is used.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1118540
    
    Signed-off-by: Hans de Goede <hdegoede at redhat.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/include/hotplug.h b/include/hotplug.h
index c4268a0..b2c0d78 100644
--- a/include/hotplug.h
+++ b/include/hotplug.h
@@ -88,7 +88,7 @@ config_odev_free_attributes(struct OdevAttributes *attribs);
 /* Minor number of the device node pointed to by ODEV_ATTRIB_PATH */
 #define ODEV_ATTRIB_MINOR 6
 /* kernel driver name */
-#define ODEV_ATTRIB_DRIVER 4
+#define ODEV_ATTRIB_DRIVER 7
 
 typedef void (*config_odev_probe_proc_ptr)(struct OdevAttributes *attribs);
 void config_odev_probe(config_odev_probe_proc_ptr probe_callback);
commit 9a19bf06b5b409fa0d5b5932e29cd4c5545052c5
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon Jul 14 15:05:58 2014 +1000

    Revert "dix: fix up coordinate scaling when external monitors are present"
    
    This reverts commit d90b5f83010248be65b2039b0b2d0b9e6a4e93cf.
    
    Reverting for two reasons:
    * the scaling does not work on devices that don't advertise resolution, and
      the default resolution used (100 units/mm) is higher than most devices,
      resulting in a significant slowdown of the touchpads.
    * the scaling is still affected by resolution changing. The patch worked
      before acceleration but since it maps into resolution-dependent dx/dy
      coordinates the acceleration may distort the movement after the fact. So the
      same input data generates different movements depending on the resolution.
      This can't easily be fixed for all affected devices as synaptics has its own
      velocity calculation method whereas wacom doesn't. So anything in the server
      won't work for both at the same time.
    
    Revert this for now, until a more integrated solution can be implemented.

diff --git a/dix/getevents.c b/dix/getevents.c
index d68fa96..ffa89fa 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -770,65 +770,27 @@ add_to_scroll_valuator(DeviceIntPtr dev, ValuatorMask *mask, int valuator, doubl
 }
 
 
-/* FIXME: relative events from devices with absolute axis ranges is
-   fundamentally broken. We map the device coordinate range into the screen
-   range, but don't really account for device resolution in that.
-
-   what we do here is a hack to make touchpads usable. for a given relative
-   motion vector in device coordinates:
-   1. calculate physical movement on the device in metres
-   2. calculate pixel vector that is the same physical movement on the
-      screen (times some magic number to provide sensible base speed)
-   3. calculate what percentage this vector is of the current screen
-      width/height
-   4. calculate equivalent vector in % on the device's min/max axis range
-   5. Use that device vector as the actual motion vector
-
-   e.g. 10/50mm on the device, 10/50mm on the screen are 30/100 pixels,
-   30/100 pixels are 1/3% of the width, 1/3% of the device is a vector of
-   20/80 -> use 20/80 as dx/dy.
-
-   dx/dy is then applied to the current position in device coordinates,
-   mapped to screen coordinates and thus the movement on the screen reflects
-   the motion direction on the device.
- */
 static void
 scale_for_device_resolution(DeviceIntPtr dev, ValuatorMask *mask)
 {
-    double x, y;
+    double y;
     ValuatorClassPtr v = dev->valuator;
     int xrange = v->axes[0].max_value - v->axes[0].min_value + 1;
     int yrange = v->axes[1].max_value - v->axes[1].min_value + 1;
 
-    /* Assume 100 units/m for devices without resolution */
-    int xres = 100000, yres = 100000;
-
-    /* If we have multiple screens with different dpi, it gets complicated:
-       we have to map which screen we're on and then take the dpi of that
-       screen to be somewhat accurate.  */
-    const ScreenPtr s = screenInfo.screens[0];
-    const double screen_res = 1000.0 * s->width/s->mmWidth; /* units/m */
+    double screen_ratio = 1.0 * screenInfo.width/screenInfo.height;
+    double device_ratio = 1.0 * xrange/yrange;
+    double resolution_ratio = 1.0;
+    double ratio;
 
-    /* some magic multiplier, so unaccelerated movement of x mm on the
-       device reflects x * magic mm on the screen */
-    const double magic = 4;
+    if (!valuator_mask_fetch_double(mask, 1, &y))
+        return;
 
-    if (v->axes[0].resolution != 0 && v->axes[1].resolution != 0) {
-        xres = v->axes[0].resolution;
-        yres = v->axes[1].resolution;
-    }
+    if (v->axes[0].resolution != 0 && v->axes[1].resolution != 0)
+        resolution_ratio = 1.0 * v->axes[0].resolution/v->axes[1].resolution;
 
-    if (valuator_mask_isset(mask, 0)) {
-        x = valuator_mask_get_double(mask, 0);
-        x = magic * x/xres * screen_res/screenInfo.width * xrange;
-        valuator_mask_set_double(mask, 0, x);
-    }
-
-    if (valuator_mask_isset(mask, 1)) {
-        y = valuator_mask_get_double(mask, 1);
-        y = magic * y/yres * screen_res/screenInfo.height * yrange;
-        valuator_mask_set_double(mask, 1, y);
-    }
+    ratio = device_ratio/resolution_ratio/screen_ratio;
+    valuator_mask_set_double(mask, 1, y / ratio);
 }
 
 /**
@@ -842,6 +804,15 @@ moveRelative(DeviceIntPtr dev, int flags, ValuatorMask *mask)
 {
     int i;
     Bool clip_xy = IsMaster(dev) || !IsFloating(dev);
+    ValuatorClassPtr v = dev->valuator;
+
+    /* for abs devices in relative mode, we've just scaled wrong, since we
+       mapped the device's shape into the screen shape. Undo this. */
+    if ((flags & POINTER_ABSOLUTE) == 0 && v && v->numAxes > 1 &&
+        v->axes[0].min_value < v->axes[0].max_value &&
+        v->axes[1].min_value < v->axes[1].max_value) {
+        scale_for_device_resolution(dev, mask);
+    }
 
     /* calc other axes, clip, drop back into valuators */
     for (i = 0; i < valuator_mask_size(mask); i++) {
@@ -1470,21 +1441,10 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type,
             set_raw_valuators(raw, &mask, raw->valuators.data);
     }
     else {
-        ValuatorClassPtr v = pDev->valuator;
-
         transformRelative(pDev, &mask);
 
-        /* for abs devices in relative mode, we've just scaled wrong, since we
-           mapped the device's shape into the screen shape. Undo this. */
-        if (v && v->numAxes > 1 &&
-            v->axes[0].min_value < v->axes[0].max_value &&
-            v->axes[1].min_value < v->axes[1].max_value) {
-            scale_for_device_resolution(pDev, &mask);
-        }
-
         if (flags & POINTER_ACCELERATE)
             accelPointer(pDev, &mask, ms);
-
         if ((flags & POINTER_NORAW) == 0 && raw)
             set_raw_valuators(raw, &mask, raw->valuators.data);
 
commit acc0b5edd1dc560b5c39dc44872b46581ec23903
Author: Aaron Plattner <aplattner at nvidia.com>
Date:   Fri Jul 11 15:56:35 2014 -0700

    xfree86: Only support one sysconfigdir
    
    When the X server is compiled with --prefix set to something other than /usr,
    then it ends up with a nonstandard sysconfigdir in its .pc file.  This causes
    various other components to install their xorg.conf.d snippets there.
    
    However, the X server first looks for /usr/share/X11/xorg.conf.d before looking
    in sysconfigdir.  That means that if the system administrator installed anything
    that created that path, the user's custom sysconfigdir is not searched.
    
    Rather than doing that, just look in the configured sysconfdir and nowhere else.
    
    Signed-off-by: Aaron Plattner <aplattner at nvidia.com>
    Reviewed-by: Julien Cristau <jcristau at debian.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 481674d..779ba6f 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -103,7 +103,7 @@
 					"/etc/X11/%X," "%C/X11/%X"
 #endif
 #ifndef SYS_CONFIGDIRPATH
-#define SYS_CONFIGDIRPATH	"/usr/share/X11/%X," "%D/X11/%X"
+#define SYS_CONFIGDIRPATH	"%D/X11/%X"
 #endif
 #ifndef PROJECTROOT
 #define PROJECTROOT	"/usr/X11R6"
commit 578b9283bcc129d0a35fabe2637c7622085ef1e8
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Jul 10 10:39:50 2014 +1000

    xfree86: don't force the screensaver off on DPMS unblank, merely suggest it
    
    Commit 41d4beb2616ceb3f1a1b8694733e85bae70de59a added symmetry to the
    screensaver/DPMS invocations so that one (en|dis)ables the other. Having
    dependencies between DPMS and the screensaver is subject to further arguments,
    but in this particular case using SCREENSAVER_FORCER is detrimental.
    SCREENSAVER_FORCER(ScreenSaverReset) resets the idle time for all
    devices on DPMS unblank.
    
    It prevents at least one use-case that GNOME tries to implement:
    GNOME displays a notification before suspending. If the display is
    currently blanked, GNOME lights it up to display the message. With the
    original patch in place DPMS unblank also resets the device idle times, thus
    restarting the timeout ad infinitum.
    
    Switch this to a more suggestive SCREENSAVER_OFF(ScreenSaverReset). This keeps
    the symmetry in blanking mode (DPMS and screensaver turn each other on/off as
    expected) but does not reset the idle time on the devices.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=731241
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Hans de Goede <hdegoede at redhat.com>
    Reviewed-By: Egbert Eich <eich at freedesktop.org>

diff --git a/hw/xfree86/common/xf86DPMS.c b/hw/xfree86/common/xf86DPMS.c
index 14d1f45..2b5a3ed 100644
--- a/hw/xfree86/common/xf86DPMS.c
+++ b/hw/xfree86/common/xf86DPMS.c
@@ -166,7 +166,7 @@ DPMSSet(ClientPtr client, int level)
                 return rc;
         }
     } else if (!xf86IsUnblank(screenIsSaved)) {
-        rc = dixSaveScreens(client, SCREEN_SAVER_FORCER, ScreenSaverReset);
+        rc = dixSaveScreens(client, SCREEN_SAVER_OFF, ScreenSaverReset);
         if (rc != Success)
             return rc;
     }
commit daa1a9d22db8e83d1933d8403acf72626199ee2a
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon Jul 7 08:27:44 2014 +1000

    os: prevent negative array index access (#80890)
    
    If an empty string is provided to LogMessageVerbSigSafe, the length of the
    printed string is 0.
    
    Read-only access only and the only effect it had was adding a linebreak or not.
    
    X.Org Bug 80890 <http://bugs.freedesktop.org/show_bug.cgi?id=80890>
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/os/log.c b/os/log.c
index a368569..2a721b9 100644
--- a/os/log.c
+++ b/os/log.c
@@ -697,7 +697,7 @@ LogVMessageVerbSigSafe(MessageType type, int verb, const char *format, va_list a
     if (sizeof(buf) - len == 1)
         buf[len - 1] = '\n';
 
-    newline = (buf[len - 1] == '\n');
+    newline = (len > 0 && buf[len - 1] == '\n');
     LogSWrite(verb, buf, len, newline);
 }
 
commit 9de3cc8daa4c6e877d30a0e8ccfe0cc159f1dbe3
Merge: 9308eaf a549987
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Jul 7 16:53:07 2014 -0700

    Merge remote-tracking branch 'jturney/master'

commit 9308eafb7d303739b81634ed2ee0da88554fd429
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Jul 7 16:28:26 2014 -0700

    Update to version 1.15.99.904
    
    One more RC to get the non-PCI patches tested before release
    
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/configure.ac b/configure.ac
index 2daa6be..c214638 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,9 +26,9 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ(2.60)
-AC_INIT([xorg-server], 1.15.99.903, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
-RELEASE_DATE="2014-06-04"
-RELEASE_NAME="Strawberry Shortcake"
+AC_INIT([xorg-server], 1.15.99.904, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+RELEASE_DATE="2014-07-07"
+RELEASE_NAME="Netarts Bay Oysters"
 AC_CONFIG_SRCDIR([Makefile.am])
 AC_CONFIG_MACRO_DIR([m4])
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
commit b6cc489838dca0bcec7e9dbb4663b871e8cb7bc8
Author: Thierry Reding <treding at nvidia.com>
Date:   Thu Feb 13 21:09:49 2014 +0100

    xfree86: Make error message more readable
    
    While at it also replace a tab by four spaces for consistency.
    
    Reviewed-by: Aaron Plattner <aplattner at nvidia.com>
    Tested-By: Aaron Plattner <aplattner at nvidia.com>
    Signed-off-by: Thierry Reding <treding at nvidia.com>
    Reviewed-by: Rob Clark <robdclark at gmail.com>
    Tested-by: Rob Clark <robdclark at gmail.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/os-support/linux/lnx_platform.c b/hw/xfree86/os-support/linux/lnx_platform.c
index 0aaedab..d660761 100644
--- a/hw/xfree86/os-support/linux/lnx_platform.c
+++ b/hw/xfree86/os-support/linux/lnx_platform.c
@@ -58,8 +58,9 @@ get_drm_info(struct OdevAttributes *attribs, char *path, int delayed_index)
 
     err = drmSetInterfaceVersion(fd, &sv);
     if (err) {
-        ErrorF("setversion 1.4 failed: %s\n", strerror(-err));
-	goto out;
+        xf86Msg(X_ERROR, "%s: failed to set DRM interface version 1.4: %s\n",
+                path, strerror(-err));
+        goto out;
     }
 
     /* for a delayed probe we've already added the device */
commit eeefecd9df88920d4dca4100a84a135f7f53dd82
Author: Thierry Reding <treding at nvidia.com>
Date:   Thu Feb 13 13:54:23 2014 +0100

    xfree86: Support driver loading via OutputClass
    
    Use the OutputClass configuration to determine what drivers to autoload
    for a given device.
    
    Reviewed-by: Aaron Plattner <aplattner at nvidia.com>
    Tested-By: Aaron Plattner <aplattner at nvidia.com>
    Signed-off-by: Thierry Reding <treding at nvidia.com>
    Tested-by: Rob Clark <robdclark at gmail.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c
index 672e2e5..eb1a3fb 100644
--- a/hw/xfree86/common/xf86platformBus.c
+++ b/hw/xfree86/common/xf86platformBus.c
@@ -47,6 +47,7 @@
 #include "xf86Bus.h"
 #include "Pci.h"
 #include "xf86platformBus.h"
+#include "xf86Config.h"
 
 #include "randrstr.h"
 int platformSlotClaimed;
@@ -199,6 +200,81 @@ xf86_check_platform_slot(const struct xf86_platform_device *pd)
     return TRUE;
 }
 
+static Bool
+MatchToken(const char *value, struct xorg_list *patterns,
+           int (*compare)(const char *, const char *))
+{
+    const xf86MatchGroup *group;
+
+    /* If there are no patterns, accept the match */
+    if (xorg_list_is_empty(patterns))
+        return TRUE;
+
+    /* If there are patterns but no attribute, reject the match */
+    if (!value)
+        return FALSE;
+
+    /*
+     * Otherwise, iterate the list of patterns ensuring each entry has a
+     * match. Each list entry is a separate Match line of the same type.
+     */
+    xorg_list_for_each_entry(group, patterns, entry) {
+        Bool match = FALSE;
+        char *const *cur;
+
+        for (cur = group->values; *cur; cur++) {
+            if ((*compare)(value, *cur) == 0) {
+                match = TRUE;
+                break;
+            }
+        }
+
+        if (!match)
+            return FALSE;
+    }
+
+    /* All the entries in the list matched the attribute */
+    return TRUE;
+}
+
+static Bool
+OutputClassMatches(const XF86ConfOutputClassPtr oclass, int index)
+{
+    char *driver = xf86_get_platform_attrib(index, ODEV_ATTRIB_DRIVER);
+
+    if (!MatchToken(driver, &oclass->match_driver, strcmp))
+        return FALSE;
+
+    return TRUE;
+}
+
+static int
+xf86OutputClassDriverList(int index, char *matches[], int nmatches)
+{
+    XF86ConfOutputClassPtr cl;
+    int i = 0;
+
+    if (nmatches == 0)
+        return 0;
+
+    for (cl = xf86configptr->conf_outputclass_lst; cl; cl = cl->list.next) {
+        if (OutputClassMatches(cl, index)) {
+            char *path = xf86_get_platform_attrib(index, ODEV_ATTRIB_PATH);
+
+            xf86Msg(X_INFO, "Applying OutputClass \"%s\" to %s\n",
+                    cl->identifier, path);
+            xf86Msg(X_NONE, "\tloading driver: %s\n", cl->driver);
+
+            matches[i++] = xstrdup(cl->driver);
+        }
+
+        if (i >= nmatches)
+            break;
+    }
+
+    return i;
+}
+
 /**
  *  @return The numbers of found devices that match with the current system
  *  drivers.
@@ -218,6 +294,8 @@ xf86PlatformMatchDriver(char *matches[], int nmatches)
             else if (!xf86IsPrimaryPlatform(&xf86_platform_devices[i]) && (pass == 0))
                 continue;
 
+            j += xf86OutputClassDriverList(i, &matches[j], nmatches - j);
+
             info = xf86_platform_devices[i].pdev;
 #ifdef __linux__
             if (info)
commit a270bb18baa6e3b45fa4a105a8d2be51ac5270bc
Author: Thierry Reding <treding at nvidia.com>
Date:   Thu Feb 13 13:42:05 2014 +0100

    xfree86: Introduce OutputClass configuration
    
    The OutputClass section provides a way to match output devices to a set
    of given attributes and configure them. For now, only matching by kernel
    driver name is supported. This can be used to determine what DDX module
    to load for non-PCI output devices. DDX modules can ship an xorg.conf.d
    snippet (e.g. in /usr/share/X11/xorg.conf.d) that looks like this:
    
    	Section "OutputClass"
    	    Identifer "NVIDIA Tegra open-source driver"
    	    MatchDriver "tegra"
    	    Driver "opentegra"
    	EndSection
    
    This will cause any device that's driven by the kernel driver named
    "tegra" to use the "opentegra" DDX module.
    
    See the OUTPUTCLASS section in xorg.conf(5) for more details.
    
    Reviewed-by: Aaron Plattner <aplattner at nvidia.com>
    Tested-By: Aaron Plattner <aplattner at nvidia.com>
    Signed-off-by: Thierry Reding <treding at nvidia.com>
    Tested-by: Rob Clark <robdclark at gmail.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/man/xorg.conf.man b/hw/xfree86/man/xorg.conf.man
index cadd87b..bc33df1 100644
--- a/hw/xfree86/man/xorg.conf.man
+++ b/hw/xfree86/man/xorg.conf.man
@@ -171,6 +171,7 @@ The section names are:
 .BR "Extensions     " "Extension enabling"
 .BR "InputDevice    " "Input device description"
 .BR "InputClass     " "Input class description"
+.BR "OutputClass    " "Output class description"
 .BR "Device         " "Graphics device description"
 .BR "VideoAdaptor   " "Xv video adaptor description"
 .BR "Monitor        " "Monitor description"
@@ -1190,6 +1191,82 @@ entries.
 This optional entry specifies that the device should be ignored entirely,
 and not added to the server. This can be useful when the device is handled
 by another program and no X events should be generated.
+.SH "OUTPUTCLASS SECTION"
+The config file may have multiple
+.B OutputClass
+sections.
+These sections are optional and are used to provide configuration for a
+class of output devices as they are automatically added.
+An output device can match more than one
+.B OutputClass
+section.
+Each class can override settings from a previous class, so it is best to
+arrange the sections with the most generic matches first.
+.PP
+.B OutputClass
+sections have the following format:
+.PP
+.RS 4
+.nf
+.B  "Section \*qOutputClass\*q"
+.BI "    Identifier  \*q" name \*q
+.I  "    entries"
+.I  "    ..."
+.B  "EndSection"
+.fi
+.RE
+.PP
+The
+.B Identifier
+entry is required in all
+.B OutputClass
+sections.
+All other entries are optional.
+.PP
+The
+.B Identifier
+entry specifies the unique name for this output class.
+The
+.B Driver
+entry specifies the name of the driver to use for this output device.
+After all classes have been examined, the
+.RI \*q outputdriver \*q
+module from the first
+.B Driver
+entry will be enabled when using the loadable server.
+.PP
+When an output device is automatically added, its characteristics are
+checked against all
+.B OutputClass
+sections.
+Each section can contain optional entries to narrow the match of the class.
+If none of the optional entries appear, the
+.B OutputClass
+section is generic and will match any output device.
+If more than one of these entries appear, they all must match for the
+configuration to apply.
+.PP
+The following list of tokens can be matched against attributes of the device.
+An entry can be constructed to match attributes from different devices by
+separating arguments with a '|' character.
+.PP
+For example:
+.PP
+.RS 4
+.nf
+.B  "Section \*qOutputClass\*q"
+.B  "    Identifier   \*qMy Class\*q"
+.B  "    # kernel driver must be either foo or bar
+.B  "    MatchDriver \*qfoo|bar\*q
+.I  "    ..."
+.B  "EndSection"
+.fi
+.RE
+.TP 7
+.BI "MatchDriver \*q" matchdriver \*q
+Check the case-sensitive string
+.RI \*q matchdriver \*q
+against the kernel driver of the device.
 .SH "DEVICE SECTION"
 The config file may have multiple
 .B Device
diff --git a/hw/xfree86/parser/Makefile.am b/hw/xfree86/parser/Makefile.am
index 3bf62e8..4d0bb4f 100644
--- a/hw/xfree86/parser/Makefile.am
+++ b/hw/xfree86/parser/Makefile.am
@@ -14,6 +14,7 @@ INTERNAL_SOURCES= \
 	Flags.c \
 	Input.c \
 	InputClass.c \
+	OutputClass.c \
 	Layout.c \
 	Module.c \
 	Video.c \
diff --git a/hw/xfree86/parser/OutputClass.c b/hw/xfree86/parser/OutputClass.c
new file mode 100644
index 0000000..7e9a8ac
--- /dev/null
+++ b/hw/xfree86/parser/OutputClass.c
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 2014 NVIDIA Corporation. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "os.h"
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+
+static
+xf86ConfigSymTabRec OutputClassTab[] = {
+    {ENDSECTION, "endsection"},
+    {IDENTIFIER, "identifier"},
+    {DRIVER, "driver"},
+    {MATCH_DRIVER, "matchdriver"},
+    {-1, ""},
+};
+
+#define CLEANUP xf86freeOutputClassList
+
+#define TOKEN_SEP "|"
+
+static void
+add_group_entry(struct xorg_list *head, char **values)
+{
+    xf86MatchGroup *group;
+
+    group = malloc(sizeof(*group));
+    if (group) {
+        group->values = values;
+        xorg_list_add(&group->entry, head);
+    }
+}
+
+XF86ConfOutputClassPtr
+xf86parseOutputClassSection(void)
+{
+    int has_ident = FALSE;
+    int token;
+
+    parsePrologue(XF86ConfOutputClassPtr, XF86ConfOutputClassRec)
+
+    /* Initialize MatchGroup lists */
+    xorg_list_init(&ptr->match_driver);
+
+    while ((token = xf86getToken(OutputClassTab)) != ENDSECTION) {
+        switch (token) {
+        case COMMENT:
+            ptr->comment = xf86addComment(ptr->comment, xf86_lex_val.str);
+            break;
+        case IDENTIFIER:
+            if (xf86getSubToken(&(ptr->comment)) != STRING)
+                Error(QUOTE_MSG, "Identifier");
+            if (has_ident == TRUE)
+                Error(MULTIPLE_MSG, "Identifier");
+            ptr->identifier = xf86_lex_val.str;
+            has_ident = TRUE;
+            break;
+        case DRIVER:
+            if (xf86getSubToken(&(ptr->comment)) != STRING)
+                Error(QUOTE_MSG, "Driver");
+            else
+                ptr->driver = xf86_lex_val.str;
+            break;
+        case MATCH_DRIVER:
+            if (xf86getSubToken(&(ptr->comment)) != STRING)
+                Error(QUOTE_MSG, "MatchDriver");
+            add_group_entry(&ptr->match_driver,
+                            xstrtokenize(xf86_lex_val.str, TOKEN_SEP));
+            free(xf86_lex_val.str);
+            break;
+        case EOF_TOKEN:
+            Error(UNEXPECTED_EOF_MSG);
+            break;
+        default:
+            Error(INVALID_KEYWORD_MSG, xf86tokenString());
+            break;
+        }
+    }
+
+    if (!has_ident)
+        Error(NO_IDENT_MSG);
+
+#ifdef DEBUG
+    printf("OutputClass section parsed\n");
+#endif
+
+    return ptr;
+}
+void
+xf86printOutputClassSection(FILE * cf, XF86ConfOutputClassPtr ptr)
+{
+    const xf86MatchGroup *group;
+    char *const *cur;
+
+    while (ptr) {
+        fprintf(cf, "Section \"OutputClass\"\n");
+        if (ptr->comment)
+            fprintf(cf, "%s", ptr->comment);
+        if (ptr->identifier)
+            fprintf(cf, "\tIdentifier      \"%s\"\n", ptr->identifier);
+        if (ptr->driver)
+            fprintf(cf, "\tDriver          \"%s\"\n", ptr->driver);
+
+        xorg_list_for_each_entry(group, &ptr->match_driver, entry) {
+            fprintf(cf, "\tMatchDriver     \"");
+            for (cur = group->values; *cur; cur++)
+                fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
+                        *cur);
+            fprintf(cf, "\"\n");
+        }
+
+        fprintf(cf, "EndSection\n\n");
+        ptr = ptr->list.next;
+    }
+}
+
+void
+xf86freeOutputClassList(XF86ConfOutputClassPtr ptr)
+{
+    XF86ConfOutputClassPtr prev;
+
+    while (ptr) {
+        xf86MatchGroup *group, *next;
+        char **list;
+
+        TestFree(ptr->identifier);
+        TestFree(ptr->comment);
+        TestFree(ptr->driver);
+
+        xorg_list_for_each_entry_safe(group, next, &ptr->match_driver, entry) {
+            xorg_list_del(&group->entry);
+            for (list = group->values; *list; list++)
+                free(*list);
+            free(group);
+        }
+
+        prev = ptr;
+        ptr = ptr->list.next;
+        free(prev);
+    }
+}
diff --git a/hw/xfree86/parser/configProcs.h b/hw/xfree86/parser/configProcs.h
index 60509dc..774e2a2 100644
--- a/hw/xfree86/parser/configProcs.h
+++ b/hw/xfree86/parser/configProcs.h
@@ -57,6 +57,11 @@ XF86ConfInputClassPtr xf86parseInputClassSection(void);
 void xf86printInputClassSection(FILE * f, XF86ConfInputClassPtr ptr);
 void xf86freeInputClassList(XF86ConfInputClassPtr ptr);
 
+/* OutputClass.c */
+XF86ConfOutputClassPtr xf86parseOutputClassSection(void);
+void xf86printOutputClassSection(FILE * f, XF86ConfOutputClassPtr ptr);
+void xf86freeOutputClassList(XF86ConfOutputClassPtr ptr);
+
 /* Layout.c */
 XF86ConfLayoutPtr xf86parseLayoutSection(void);
 void xf86printLayoutSection(FILE * cf, XF86ConfLayoutPtr ptr);
diff --git a/hw/xfree86/parser/read.c b/hw/xfree86/parser/read.c
index 2478b07..22f6e6a 100644
--- a/hw/xfree86/parser/read.c
+++ b/hw/xfree86/parser/read.c
@@ -165,6 +165,12 @@ xf86readConfigFile(void)
                 HANDLE_LIST(conf_inputclass_lst,
                             xf86parseInputClassSection, XF86ConfInputClassPtr);
             }
+            else if (xf86nameCompare(xf86_lex_val.str, "outputclass") == 0) {
+                free(xf86_lex_val.str);
+                xf86_lex_val.str = NULL;
+                HANDLE_LIST(conf_outputclass_lst, xf86parseOutputClassSection,
+                            XF86ConfOutputClassPtr);
+            }
             else if (xf86nameCompare(xf86_lex_val.str, "module") == 0) {
                 free(xf86_lex_val.str);
                 xf86_lex_val.str = NULL;
diff --git a/hw/xfree86/parser/write.c b/hw/xfree86/parser/write.c
index 26739b9..472b27b 100644
--- a/hw/xfree86/parser/write.c
+++ b/hw/xfree86/parser/write.c
@@ -114,6 +114,8 @@ doWriteConfigFile(const char *filename, XF86ConfigPtr cptr)
 
     xf86printInputClassSection(cf, cptr->conf_inputclass_lst);
 
+    xf86printOutputClassSection(cf, cptr->conf_outputclass_lst);
+
     xf86printVideoAdaptorSection(cf, cptr->conf_videoadaptor_lst);
 
     xf86printModesSection(cf, cptr->conf_modes_lst);
diff --git a/hw/xfree86/parser/xf86Parser.h b/hw/xfree86/parser/xf86Parser.h
index c95423a..3fa5b71 100644
--- a/hw/xfree86/parser/xf86Parser.h
+++ b/hw/xfree86/parser/xf86Parser.h
@@ -327,6 +327,14 @@ typedef struct {
     char *comment;
 } XF86ConfInputClassRec, *XF86ConfInputClassPtr;
 
+typedef struct {
+    GenericListRec list;
+    char *identifier;
+    char *driver;
+    struct xorg_list match_driver;
+    char *comment;
+} XF86ConfOutputClassRec, *XF86ConfOutputClassPtr;
+
 /* Values for adj_where */
 #define CONF_ADJ_OBSOLETE	-1
 #define CONF_ADJ_ABSOLUTE	0
@@ -411,6 +419,7 @@ typedef struct {
     XF86ConfScreenPtr conf_screen_lst;
     XF86ConfInputPtr conf_input_lst;
     XF86ConfInputClassPtr conf_inputclass_lst;
+    XF86ConfOutputClassPtr conf_outputclass_lst;
     XF86ConfLayoutPtr conf_layout_lst;
     XF86ConfVendorPtr conf_vendor_lst;
     XF86ConfDRIPtr conf_dri;
commit 856bb80cea695106a8f6767d00918b38795b51c6
Author: Thierry Reding <treding at nvidia.com>
Date:   Wed Feb 12 16:43:29 2014 +0100

    xfree86: Store kernel driver name in platform device attribute
    
    When opening a DRM device, query the version and store the driver name
    as a new attribute for future reference.
    
    Reviewed-by: Aaron Plattner <aplattner at nvidia.com>
    Tested-By: Aaron Plattner <aplattner at nvidia.com>
    Signed-off-by: Thierry Reding <treding at nvidia.com>
    Reviewed-by: Rob Clark <robdclark at gmail.com>
    Tested-by: Rob Clark <robdclark at gmail.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/os-support/linux/lnx_platform.c b/hw/xfree86/os-support/linux/lnx_platform.c
index 308275a..0aaedab 100644
--- a/hw/xfree86/os-support/linux/lnx_platform.c
+++ b/hw/xfree86/os-support/linux/lnx_platform.c
@@ -24,6 +24,7 @@ static Bool
 get_drm_info(struct OdevAttributes *attribs, char *path, int delayed_index)
 {
     drmSetVersion sv;
+    drmVersionPtr v;
     char *buf;
     int major, minor, fd;
     int err = 0;
@@ -74,6 +75,17 @@ get_drm_info(struct OdevAttributes *attribs, char *path, int delayed_index)
     xf86_add_platform_device_attrib(delayed_index,
                                     ODEV_ATTRIB_BUSID, buf);
     drmFreeBusid(buf);
+
+    v = drmGetVersion(fd);
+    if (!v) {
+        xf86Msg(X_ERROR, "%s: failed to query DRM version\n", path);
+        goto out;
+    }
+
+    xf86_add_platform_device_attrib(delayed_index, ODEV_ATTRIB_DRIVER,
+                                    v->name);
+    drmFreeVersion(v);
+
 out:
     if (!server_fd)
         close(fd);
diff --git a/include/hotplug.h b/include/hotplug.h
index cefc164..c4268a0 100644
--- a/include/hotplug.h
+++ b/include/hotplug.h
@@ -87,6 +87,8 @@ config_odev_free_attributes(struct OdevAttributes *attribs);
 #define ODEV_ATTRIB_MAJOR 5
 /* Minor number of the device node pointed to by ODEV_ATTRIB_PATH */
 #define ODEV_ATTRIB_MINOR 6
+/* kernel driver name */
+#define ODEV_ATTRIB_DRIVER 4
 
 typedef void (*config_odev_probe_proc_ptr)(struct OdevAttributes *attribs);
 void config_odev_probe(config_odev_probe_proc_ptr probe_callback);
commit 5a4e15c3f6fb8d674879e54458328e9f595d9451
Author: Thierry Reding <treding at nvidia.com>
Date:   Fri Feb 14 15:45:33 2014 +0100

    xfree86: Make driver matching consistent
    
    Most of the driver enumeration functions take an array and a maximum
    number of entries that they are allowed to fill in. Upon success, they
    return the number of entries filled in. This allows them to be easily
    used to consecutively.
    
    One exception is the xf86MatchDriverFromFiles() function, which doesn't
    return a value, so callers have to manually search the array for the
    first empty entry.
    
    This commit modifies the xf86MatchDriverFromFiles() to behave the same
    way as others, which makes it easier to deal with.
    
    Reviewed-by: Aaron Plattner <aplattner at nvidia.com>
    Tested-By: Aaron Plattner <aplattner at nvidia.com>
    Tested-by: Rob Clark <robdclark at gmail.com>  (on arm / platform device)
    Signed-off-by: Thierry Reding <treding at nvidia.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/common/xf86AutoConfig.c b/hw/xfree86/common/xf86AutoConfig.c
index 4eb86de..2b53b90 100644
--- a/hw/xfree86/common/xf86AutoConfig.c
+++ b/hw/xfree86/common/xf86AutoConfig.c
@@ -265,7 +265,7 @@ listPossibleVideoDrivers(char *matches[], int nmatches)
 #endif
 #ifdef XSERVER_LIBPCIACCESS
     if (i < (nmatches - 1))
-        i = xf86PciMatchDriver(matches, nmatches);
+        i += xf86PciMatchDriver(&matches[i], nmatches - i);
 #endif
 
 #if defined(__linux__)
diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c
index 0f76a03..c06b040 100644
--- a/hw/xfree86/common/xf86pciBus.c
+++ b/hw/xfree86/common/xf86pciBus.c
@@ -1320,8 +1320,9 @@ xchomp(char *line)
  * don't export their PCI ID's properly. If distros don't end up using this
  * feature it can and should be removed because the symbol-based resolution
  * scheme should be the primary one */
-void
-xf86MatchDriverFromFiles(char **matches, uint16_t match_vendor, uint16_t match_chip)
+int
+xf86MatchDriverFromFiles(uint16_t match_vendor, uint16_t match_chip,
+                         char *matches[], int nmatches)
 {
     DIR *idsdir;
     FILE *fp;
@@ -1331,11 +1332,11 @@ xf86MatchDriverFromFiles(char **matches, uint16_t match_vendor, uint16_t match_c
     ssize_t read;
     char path_name[256], vendor_str[5], chip_str[5];
     uint16_t vendor, chip;
-    int i, j;
+    int i = 0, j;
 
     idsdir = opendir(PCI_TXT_IDS_PATH);
     if (!idsdir)
-        return;
+        return 0;
 
     xf86Msg(X_INFO,
             "Scanning %s directory for additional PCI ID's supported by the drivers\n",
@@ -1386,10 +1387,6 @@ xf86MatchDriverFromFiles(char **matches, uint16_t match_vendor, uint16_t match_c
                         }
                     }
                     if (vendor == match_vendor && chip == match_chip) {
-                        i = 0;
-                        while (matches[i]) {
-                            i++;
-                        }
                         matches[i] =
                             (char *) malloc(sizeof(char) *
                                             strlen(direntry->d_name) - 3);
@@ -1412,6 +1409,7 @@ xf86MatchDriverFromFiles(char **matches, uint16_t match_vendor, uint16_t match_c
                         }
                         xf86Msg(X_INFO, "Matched %s from file name %s\n",
                                 matches[i], direntry->d_name);
+                        i++;
                     }
                 }
                 else {
@@ -1425,6 +1423,7 @@ xf86MatchDriverFromFiles(char **matches, uint16_t match_vendor, uint16_t match_c
  end:
     free(line);
     closedir(idsdir);
+    return i;
 }
 #endif                          /* __linux__ */
 
@@ -1435,7 +1434,7 @@ xf86MatchDriverFromFiles(char **matches, uint16_t match_vendor, uint16_t match_c
 int
 xf86PciMatchDriver(char *matches[], int nmatches)
 {
-    int i;
+    int i = 0;
     struct pci_device *info = NULL;
     struct pci_device_iterator *iter;
 
@@ -1450,13 +1449,10 @@ xf86PciMatchDriver(char *matches[], int nmatches)
     pci_iterator_destroy(iter);
 #ifdef __linux__
     if (info)
-        xf86MatchDriverFromFiles(matches, info->vendor_id, info->device_id);
+        i += xf86MatchDriverFromFiles(info->vendor_id, info->device_id,
+                                      matches, nmatches);
 #endif
 
-    for (i = 0; (i < nmatches) && (matches[i]); i++) {
-        /* find end of matches list */
-    }
-
     if ((info != NULL) && (i < nmatches)) {
         i += xf86VideoPtrToDriverList(info, &(matches[i]), nmatches - i);
     }
diff --git a/hw/xfree86/common/xf86pciBus.h b/hw/xfree86/common/xf86pciBus.h
index b497a7f..45b5a0f 100644
--- a/hw/xfree86/common/xf86pciBus.h
+++ b/hw/xfree86/common/xf86pciBus.h
@@ -47,8 +47,9 @@ void xf86PciConfigureNewDev(void *busData, struct pci_device *pVideo,
                                  ((x)->func == (y)->func) &&            \
                                  ((x)->dev == (y)->dev))
 
-void
-xf86MatchDriverFromFiles(char **matches, uint16_t match_vendor, uint16_t match_chip);
+int
+xf86MatchDriverFromFiles(uint16_t match_vendor, uint16_t match_chip,
+                         char *matches[], int nmatches);
 int
 xf86VideoPtrToDriverList(struct pci_device *dev,
                          char *returnList[], int returnListMax);
diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c
index dd118a2..672e2e5 100644
--- a/hw/xfree86/common/xf86platformBus.c
+++ b/hw/xfree86/common/xf86platformBus.c
@@ -221,13 +221,10 @@ xf86PlatformMatchDriver(char *matches[], int nmatches)
             info = xf86_platform_devices[i].pdev;
 #ifdef __linux__
             if (info)
-                xf86MatchDriverFromFiles(matches, info->vendor_id, info->device_id);
+                j += xf86MatchDriverFromFiles(info->vendor_id, info->device_id,
+                                              &matches[j], nmatches - j);
 #endif
 
-            for (j = 0; (j < nmatches) && (matches[j]); j++) {
-                /* find end of matches list */
-            }
-
             if ((info != NULL) && (j < nmatches)) {
                 j += xf86VideoPtrToDriverList(info, &(matches[j]), nmatches - j);
             }
commit a61ca6f006d70343c88fe45206fae0669d1e8971
Author: Tomasz Borowik <timon37 at gmail.com>
Date:   Thu Jul 3 13:04:44 2014 -0700

    glamor: Fix stack corruption in glamor_init
    
    glGet on GL_MAX_VIEWPORT_DIMS returns two values
    
    Reviewed-by: Markus Wick <markus at selfnet.de>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/glamor/glamor.c b/glamor/glamor.c
index c398807..3588903 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -316,7 +316,7 @@ glamor_init(ScreenPtr screen, unsigned int flags)
 {
     glamor_screen_private *glamor_priv;
     int gl_version;
-    int max_viewport_size;
+    int max_viewport_size[2];
 
 #ifdef RENDER
     PictureScreenPtr ps = GetPictureScreenIfSet(screen);
@@ -408,8 +408,9 @@ glamor_init(ScreenPtr screen, unsigned int flags)
     glamor_priv->has_buffer_storage =
         epoxy_has_gl_extension("GL_ARB_buffer_storage");
     glGetIntegerv(GL_MAX_TEXTURE_SIZE, &glamor_priv->max_fbo_size);
-    glGetIntegerv(GL_MAX_VIEWPORT_DIMS, &max_viewport_size);
-    glamor_priv->max_fbo_size = MIN(glamor_priv->max_fbo_size, max_viewport_size);
+    glGetIntegerv(GL_MAX_VIEWPORT_DIMS, max_viewport_size);
+    glamor_priv->max_fbo_size = MIN(glamor_priv->max_fbo_size, max_viewport_size[0]);
+    glamor_priv->max_fbo_size = MIN(glamor_priv->max_fbo_size, max_viewport_size[1]);
 #ifdef MAX_FBO_SIZE
     glamor_priv->max_fbo_size = MAX_FBO_SIZE;
 #endif
commit 10d2805dbc6b96a159b8c5acedcd53f34df362bf
Author: Keith Packard <keithp at keithp.com>
Date:   Thu Jun 26 14:12:24 2014 -0700

    fb: Don't free NULL pixmap in fbCloseScreen. Bug #80313
    
    We fixed fbCloseScreen to use the FreePixmap function so that the
    private counts would be updated correctly during CloseScreen. Xvfb
    calls FreePixmap and sets devPrivate to NULL before fbCloseScreen is
    called; not checking devPrivate before calling would result in a NULL
    pointer dereference.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Julien Cristau <jcristau at debian.org>

diff --git a/fb/fbscreen.c b/fb/fbscreen.c
index 1f91089..0d4d87f 100644
--- a/fb/fbscreen.c
+++ b/fb/fbscreen.c
@@ -37,7 +37,8 @@ fbCloseScreen(ScreenPtr pScreen)
         free(depths[d].vids);
     free(depths);
     free(pScreen->visuals);
-    FreePixmap((PixmapPtr)pScreen->devPrivate);
+    if (pScreen->devPrivate)
+        FreePixmap((PixmapPtr)pScreen->devPrivate);
     return TRUE;
 }
 
commit a5499870e2f88822f52b1b54cad0db69856597c0
Author: Yaakov Selkowitz <yselkowitz at users.sourceforge.net>
Date:   Sun Apr 6 04:47:15 2014 -0500

    hw/xwin: link dynamically and export symbols
    
    With my patch to fix shared libXfont to work correctly on Cygwin/Win32,
    there is no need for -static anymore.  But, XWin.exe must export its
    symbols in order for them to override libXfont's stubs.
    
    Signed-off-by: Yaakov Selkowitz <yselkowitz at users.sourceforge.net>
    Reviewed-by: Jon TURNEY <jon.turney at dronecode.org.uk>

diff --git a/hw/xwin/Makefile.am b/hw/xwin/Makefile.am
index cf42cfd..4ee9632 100644
--- a/hw/xwin/Makefile.am
+++ b/hw/xwin/Makefile.am
@@ -155,7 +155,7 @@ XWIN_LIBS += 	$(top_builddir)/pseudoramiX/libPseudoramiX.la \
                 $(top_builddir)/Xi/libXistubs.la
 XWin_DEPENDENCIES = $(MULTIWINDOWEXTWM_LIBS) $(XWIN_GLX_LIBS) $(XWIN_LIBS) $(XSERVER_LIBS)
 XWin_LDADD = $(MULTIWINDOW_LIBS) $(MULTIWINDOWEXTWM_LIBS) $(XWIN_GLX_LIBS) $(XWIN_GLX_LINK_FLAGS) $(XWIN_LIBS) $(MAIN_LIB) $(XSERVER_LIBS) $(XSERVER_SYS_LIBS) $(XWIN_SYS_LIBS)
-XWin_LDFLAGS = -mwindows -static -Wl,--disable-stdcall-fixup
+XWin_LDFLAGS = -mwindows -Wl,--disable-stdcall-fixup $(LD_EXPORT_SYMBOLS_FLAG)
 
 
 .rc.o:
commit a3b44ad8db1fa2f3b81c1ff9498f31c5323edd37
Author: Thierry Reding <treding at nvidia.com>
Date:   Wed Jun 25 16:03:29 2014 +0200

    exa: Fix a warning when enabling DEBUG_TRACE_FALL
    
    The format string wants a picture and a character, but the argument list
    contains only a character, causing GCC to complain. Add the missing
    argument.
    
    Signed-off-by: Thierry Reding <treding at nvidia.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/exa/exa_unaccel.c b/exa/exa_unaccel.c
index 58262e0..b0c6344 100644
--- a/exa/exa_unaccel.c
+++ b/exa/exa_unaccel.c
@@ -685,7 +685,7 @@ ExaCheckAddTraps(PicturePtr pPicture,
 
     EXA_PRE_FALLBACK(pScreen);
 
-    EXA_FALLBACK(("to pict %p (%c)\n",
+    EXA_FALLBACK(("to pict %p (%c)\n", pPicture,
                   exaDrawableLocation(pPicture->pDrawable)));
     exaPrepareAccess(pPicture->pDrawable, EXA_PREPARE_DEST);
     swap(pExaScr, ps, AddTraps);
commit 2f113d68f6c1572576bc57ecca12e44cc9e438eb
Author: Kristian Høgsberg <krh at bitplanet.net>
Date:   Mon Jun 16 11:34:55 2014 -0700

    xwayland: Add glamor and DRI3 support
    
    Reviewed-by: Axel Davy <axel.davy at ens.fr>
    Signed-off-by: Kristian Høgsberg <krh at bitplanet.net>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/configure.ac b/configure.ac
index dabebb9..2daa6be 100644
--- a/configure.ac
+++ b/configure.ac
@@ -810,7 +810,7 @@ LIBDMX="dmx >= 1.0.99.1"
 LIBDRI="dri >= 7.8.0"
 LIBDRM="libdrm >= 2.3.0"
 LIBEGL="egl"
-LIBGBM="gbm >= 9"
+LIBGBM="gbm >= 10.2.0"
 LIBGL="gl >= 7.1.0"
 LIBXEXT="xext >= 1.0.99.4"
 LIBXFONT="xfont >= 1.4.2"
@@ -2459,6 +2459,10 @@ if test "x$XWAYLAND" = xyes; then
 	XWAYLAND_SYS_LIBS="$XWAYLANDMODULES_LIBS $GLX_SYS_LIBS"
 	AC_SUBST([XWAYLAND_LIBS])
 	AC_SUBST([XWAYLAND_SYS_LIBS])
+
+	WAYLAND_PREFIX=`$PKG_CONFIG --variable=prefix wayland-client`
+	AC_PATH_PROG([WAYLAND_SCANNER], [wayland-scanner],,
+		     [${WAYLAND_PREFIX}/bin$PATH_SEPARATOR$PATH])
 fi
 
 
diff --git a/hw/xwayland/Makefile.am b/hw/xwayland/Makefile.am
index 36e6127..dc16b8b 100644
--- a/hw/xwayland/Makefile.am
+++ b/hw/xwayland/Makefile.am
@@ -1,10 +1,13 @@
 bin_PROGRAMS = Xwayland
 
 Xwayland_CFLAGS =				\
+	-I$(top_srcdir)/glamor			\
 	-I$(top_srcdir)/dri3			\
 	-DHAVE_DIX_CONFIG_H			\
 	$(XWAYLANDMODULES_CFLAGS)		\
-	$(DIX_CFLAGS)
+	$(DIX_CFLAGS)				\
+	$(GLAMOR_CFLAGS)			\
+	$(GBM_CFLAGS)
 
 Xwayland_SOURCES =				\
 	xwayland.c				\
@@ -19,6 +22,7 @@ Xwayland_SOURCES =				\
 	$(top_srcdir)/mi/miinitext.c
 
 Xwayland_LDADD =				\
+	$(glamor_lib)				\
 	$(XWAYLAND_LIBS)			\
 	$(XWAYLAND_SYS_LIBS)			\
 	$(XSERVER_SYS_LIBS)
@@ -26,5 +30,30 @@ Xwayland_DEPENDENCIES = $(XWAYLAND_LIBS)
 Xwayland_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
 
 
+if GLAMOR_EGL
+Xwayland_SOURCES += xwayland-glamor.c
+
+nodist_Xwayland_SOURCES =			\
+	drm-client-protocol.h			\
+	drm-protocol.c
+
+CLEANFILES = $(nodist_Xwayland_SOURCES)
+
+EXTRA_DIST = drm.xml
+
+xwayland-glamor.c : $(nodist_Xwayland_SOURCES)
+
+glamor_lib = $(top_builddir)/glamor/libglamor.la
+
+Xwayland_LDADD += $(GLAMOR_LIBS) $(GBM_LIBS) -lEGL -lGL
+endif
+
+
 relink:
 	$(AM_V_at)rm -f Xwayland$(EXEEXT) && $(MAKE) Xwayland$(EXEEXT)
+
+%-protocol.c : %.xml
+	$(AM_V_GEN)$(WAYLAND_SCANNER) code < $< > $@
+
+%-client-protocol.h : %.xml
+	$(AM_V_GEN)$(WAYLAND_SCANNER) client-header < $< > $@
diff --git a/hw/xwayland/drm.xml b/hw/xwayland/drm.xml
new file mode 100644
index 0000000..8a3ad69
--- /dev/null
+++ b/hw/xwayland/drm.xml
@@ -0,0 +1,182 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<protocol name="drm">
+
+  <copyright>
+    Copyright © 2008-2011 Kristian Høgsberg
+    Copyright © 2010-2011 Intel Corporation
+
+    Permission to use, copy, modify, distribute, and sell this
+    software and its documentation for any purpose is hereby granted
+    without fee, provided that\n the above copyright notice appear in
+    all copies and that both that copyright notice and this permission
+    notice appear in supporting documentation, and that the name of
+    the copyright holders not be used in advertising or publicity
+    pertaining to distribution of the software without specific,
+    written prior permission.  The copyright holders make no
+    representations about the suitability of this software for any
+    purpose.  It is provided "as is" without express or implied
+    warranty.
+
+    THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+    SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+    FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+    SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+    WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+    AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+    ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+    THIS SOFTWARE.
+  </copyright>
+
+  <!-- drm support. This object is created by the server and published
+       using the display's global event. -->
+  <interface name="wl_drm" version="2">
+    <enum name="error">
+      <entry name="authenticate_fail" value="0"/>
+      <entry name="invalid_format" value="1"/>
+      <entry name="invalid_name" value="2"/>
+    </enum>
+
+    <enum name="format">
+      <!-- The drm format codes match the #defines in drm_fourcc.h.
+           The formats actually supported by the compositor will be
+           reported by the format event. -->
+      <entry name="c8" value="0x20203843"/>
+      <entry name="rgb332" value="0x38424752"/>
+      <entry name="bgr233" value="0x38524742"/>
+      <entry name="xrgb4444" value="0x32315258"/>
+      <entry name="xbgr4444" value="0x32314258"/>
+      <entry name="rgbx4444" value="0x32315852"/>
+      <entry name="bgrx4444" value="0x32315842"/>
+      <entry name="argb4444" value="0x32315241"/>
+      <entry name="abgr4444" value="0x32314241"/>
+      <entry name="rgba4444" value="0x32314152"/>
+      <entry name="bgra4444" value="0x32314142"/>
+      <entry name="xrgb1555" value="0x35315258"/>
+      <entry name="xbgr1555" value="0x35314258"/>
+      <entry name="rgbx5551" value="0x35315852"/>
+      <entry name="bgrx5551" value="0x35315842"/>
+      <entry name="argb1555" value="0x35315241"/>
+      <entry name="abgr1555" value="0x35314241"/>
+      <entry name="rgba5551" value="0x35314152"/>
+      <entry name="bgra5551" value="0x35314142"/>
+      <entry name="rgb565" value="0x36314752"/>
+      <entry name="bgr565" value="0x36314742"/>
+      <entry name="rgb888" value="0x34324752"/>
+      <entry name="bgr888" value="0x34324742"/>
+      <entry name="xrgb8888" value="0x34325258"/>
+      <entry name="xbgr8888" value="0x34324258"/>
+      <entry name="rgbx8888" value="0x34325852"/>
+      <entry name="bgrx8888" value="0x34325842"/>
+      <entry name="argb8888" value="0x34325241"/>
+      <entry name="abgr8888" value="0x34324241"/>
+      <entry name="rgba8888" value="0x34324152"/>
+      <entry name="bgra8888" value="0x34324142"/>
+      <entry name="xrgb2101010" value="0x30335258"/>
+      <entry name="xbgr2101010" value="0x30334258"/>
+      <entry name="rgbx1010102" value="0x30335852"/>
+      <entry name="bgrx1010102" value="0x30335842"/>
+      <entry name="argb2101010" value="0x30335241"/>
+      <entry name="abgr2101010" value="0x30334241"/>
+      <entry name="rgba1010102" value="0x30334152"/>
+      <entry name="bgra1010102" value="0x30334142"/>
+      <entry name="yuyv" value="0x56595559"/>
+      <entry name="yvyu" value="0x55595659"/>
+      <entry name="uyvy" value="0x59565955"/>
+      <entry name="vyuy" value="0x59555956"/>
+      <entry name="ayuv" value="0x56555941"/>
+      <entry name="nv12" value="0x3231564e"/>
+      <entry name="nv21" value="0x3132564e"/>
+      <entry name="nv16" value="0x3631564e"/>
+      <entry name="nv61" value="0x3136564e"/>
+      <entry name="yuv410" value="0x39565559"/>
+      <entry name="yvu410" value="0x39555659"/>
+      <entry name="yuv411" value="0x31315559"/>
+      <entry name="yvu411" value="0x31315659"/>
+      <entry name="yuv420" value="0x32315559"/>
+      <entry name="yvu420" value="0x32315659"/>
+      <entry name="yuv422" value="0x36315559"/>
+      <entry name="yvu422" value="0x36315659"/>
+      <entry name="yuv444" value="0x34325559"/>
+      <entry name="yvu444" value="0x34325659"/>
+    </enum>
+
+    <!-- Call this request with the magic received from drmGetMagic().
+         It will be passed on to the drmAuthMagic() or
+         DRIAuthConnection() call.  This authentication must be
+         completed before create_buffer could be used. -->
+    <request name="authenticate">
+      <arg name="id" type="uint"/>
+    </request>
+
+    <!-- Create a wayland buffer for the named DRM buffer.  The DRM
+         surface must have a name using the flink ioctl -->
+    <request name="create_buffer">
+      <arg name="id" type="new_id" interface="wl_buffer"/>
+      <arg name="name" type="uint"/>
+      <arg name="width" type="int"/>
+      <arg name="height" type="int"/>
+      <arg name="stride" type="uint"/>
+      <arg name="format" type="uint"/>
+    </request>
+
+    <!-- Create a wayland buffer for the named DRM buffer.  The DRM
+         surface must have a name using the flink ioctl -->
+    <request name="create_planar_buffer">
+      <arg name="id" type="new_id" interface="wl_buffer"/>
+      <arg name="name" type="uint"/>
+      <arg name="width" type="int"/>
+      <arg name="height" type="int"/>
+      <arg name="format" type="uint"/>
+      <arg name="offset0" type="int"/>
+      <arg name="stride0" type="int"/>
+      <arg name="offset1" type="int"/>
+      <arg name="stride1" type="int"/>
+      <arg name="offset2" type="int"/>
+      <arg name="stride2" type="int"/>
+    </request>
+
+    <!-- Create a wayland buffer for the prime fd.  Use for regular and planar
+         buffers.  Pass 0 for offset and stride for unused planes. -->
+    <request name="create_prime_buffer" since="2">
+      <arg name="id" type="new_id" interface="wl_buffer"/>
+      <arg name="name" type="fd"/>
+      <arg name="width" type="int"/>
+      <arg name="height" type="int"/>
+      <arg name="format" type="uint"/>
+      <arg name="offset0" type="int"/>
+      <arg name="stride0" type="int"/>
+      <arg name="offset1" type="int"/>
+      <arg name="stride1" type="int"/>
+      <arg name="offset2" type="int"/>
+      <arg name="stride2" type="int"/>
+    </request>
+
+    <!-- Notification of the path of the drm device which is used by
+         the server.  The client should use this device for creating
+         local buffers.  Only buffers created from this device should
+         be be passed to the server using this drm object's
+         create_buffer request. -->
+    <event name="device">
+      <arg name="name" type="string"/>
+    </event>
+
+    <event name="format">
+      <arg name="format" type="uint"/>
+    </event>
+
+    <!-- Raised if the authenticate request succeeded -->
+    <event name="authenticated"/>
+
+    <enum name="capability" since="2">
+      <description summary="wl_drm capability bitmask">
+        Bitmask of capabilities.
+      </description>
+      <entry name="prime" value="1" summary="wl_drm prime available"/>
+    </enum>
+
+    <event name="capabilities">
+      <arg name="value" type="uint"/>
+    </event>
+  </interface>
+
+</protocol>
diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
new file mode 100644
index 0000000..4be883f
--- /dev/null
+++ b/hw/xwayland/xwayland-glamor.c
@@ -0,0 +1,570 @@
+/*
+ * Copyright © 2011-2014 Intel Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of the
+ * copyright holders not be used in advertising or publicity
+ * pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no
+ * representations about the suitability of this software for any
+ * purpose.  It is provided "as is" without express or implied
+ * warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#include "xwayland.h"
+
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <xf86drm.h>
+
+#define MESA_EGL_NO_X11_HEADERS
+#include <gbm.h>
+#include <epoxy/egl.h>
+#include <epoxy/gl.h>
+
+#include <glamor.h>
+#include <glamor_context.h>
+#include <dri3.h>
+#include "drm-client-protocol.h"
+
+struct xwl_pixmap {
+    struct wl_buffer *buffer;
+    struct gbm_bo *bo;
+    void *image;
+    unsigned int texture;
+};
+
+static void
+xwl_glamor_egl_make_current(struct glamor_context *glamor_ctx)
+{
+    eglMakeCurrent(glamor_ctx->display, EGL_NO_SURFACE,
+                   EGL_NO_SURFACE, EGL_NO_CONTEXT);
+    if (!eglMakeCurrent(glamor_ctx->display,
+                        EGL_NO_SURFACE, EGL_NO_SURFACE,
+                        glamor_ctx->ctx))
+        FatalError("Failed to make EGL context current\n");
+}
+
+static uint32_t
+drm_format_for_depth(int depth)
+{
+    switch (depth) {
+    case 15:
+        return WL_DRM_FORMAT_XRGB1555;
+    case 16:
+        return WL_DRM_FORMAT_RGB565;
+    case 24:
+        return WL_DRM_FORMAT_XRGB8888;
+    default:
+        ErrorF("unexpected depth: %d\n", depth);
+    case 32:
+        return WL_DRM_FORMAT_ARGB8888;
+    }
+}
+
+static uint32_t
+gbm_format_for_depth(int depth)
+{
+    switch (depth) {
+    case 16:
+        return GBM_FORMAT_RGB565;
+    case 24:
+        return GBM_FORMAT_XRGB8888;
+    default:
+        ErrorF("unexpected depth: %d\n", depth);
+    case 32:
+        return GBM_FORMAT_ARGB8888;
+    }
+}
+
+void
+glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx)
+{
+    struct xwl_screen *xwl_screen = xwl_screen_get(screen);
+
+    glamor_ctx->ctx = xwl_screen->egl_context;
+    glamor_ctx->display = xwl_screen->egl_display;
+
+    glamor_ctx->make_current = xwl_glamor_egl_make_current;
+
+    xwl_screen->glamor_ctx = glamor_ctx;
+}
+
+static PixmapPtr
+xwl_glamor_create_pixmap_for_bo(ScreenPtr screen, struct gbm_bo *bo, int depth)
+{
+    PixmapPtr pixmap;
+    struct xwl_pixmap *xwl_pixmap;
+    struct xwl_screen *xwl_screen = xwl_screen_get(screen);
+
+    xwl_pixmap = malloc(sizeof *xwl_pixmap);
+    if (xwl_pixmap == NULL)
+        return NULL;
+
+    pixmap = glamor_create_pixmap(screen,
+                                  gbm_bo_get_width(bo),
+                                  gbm_bo_get_height(bo),
+                                  depth,
+                                  GLAMOR_CREATE_PIXMAP_NO_TEXTURE);
+    if (pixmap == NULL) {
+        free(xwl_pixmap);
+        return NULL;
+    }
+
+    if (lastGLContext != xwl_screen->glamor_ctx) {
+        lastGLContext = xwl_screen->glamor_ctx;
+        xwl_glamor_egl_make_current(xwl_screen->glamor_ctx);
+    }
+
+    xwl_pixmap->bo = bo;
+    xwl_pixmap->buffer = NULL;
+    xwl_pixmap->image = eglCreateImageKHR(xwl_screen->egl_display,
+                                          xwl_screen->egl_context,
+                                          EGL_NATIVE_PIXMAP_KHR,
+                                          xwl_pixmap->bo, NULL);
+
+    glGenTextures(1, &xwl_pixmap->texture);
+    glBindTexture(GL_TEXTURE_2D, xwl_pixmap->texture);
+    glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, xwl_pixmap->image);
+    glBindTexture(GL_TEXTURE_2D, 0);
+
+    xwl_pixmap_set_private(pixmap, xwl_pixmap);
+
+    glamor_set_pixmap_texture(pixmap, xwl_pixmap->texture);
+    glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM);
+
+    return pixmap;
+}
+
+struct wl_buffer *
+xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap)
+{
+    struct xwl_screen *xwl_screen = xwl_screen_get(pixmap->drawable.pScreen);
+    struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(pixmap);
+    int prime_fd;
+
+    if (xwl_pixmap->buffer)
+        return xwl_pixmap->buffer;
+
+    prime_fd = gbm_bo_get_fd(xwl_pixmap->bo);
+    if (prime_fd == -1)
+        return NULL;
+
+    xwl_pixmap->buffer =
+        wl_drm_create_prime_buffer(xwl_screen->drm, prime_fd,
+                                   pixmap->drawable.width,
+                                   pixmap->drawable.height,
+                                   drm_format_for_depth(pixmap->drawable.depth),
+                                   0, gbm_bo_get_stride(xwl_pixmap->bo),
+                                   0, 0,
+                                   0, 0);
+
+    close(prime_fd);
+
+    return xwl_pixmap->buffer;
+}
+
+static PixmapPtr
+xwl_glamor_create_pixmap(ScreenPtr screen,
+                         int width, int height, int depth, unsigned int hint)
+{
+    struct xwl_screen *xwl_screen = xwl_screen_get(screen);
+    struct gbm_bo *bo;
+
+    if (width > 0 && height > 0 && depth >= 15 &&
+        (hint == 0 ||
+         hint == CREATE_PIXMAP_USAGE_BACKING_PIXMAP ||
+         hint == CREATE_PIXMAP_USAGE_SHARED)) {
+        bo = gbm_bo_create(xwl_screen->gbm, width, height,
+                           gbm_format_for_depth(depth),
+                           GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
+
+        if (bo)
+            return xwl_glamor_create_pixmap_for_bo(screen, bo, depth);
+    }
+
+    return glamor_create_pixmap(screen, width, height, depth, hint);
+}
+
+static Bool
+xwl_glamor_destroy_pixmap(PixmapPtr pixmap)
+{
+    struct xwl_screen *xwl_screen = xwl_screen_get(pixmap->drawable.pScreen);
+    struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(pixmap);
+
+    if (xwl_pixmap && pixmap->refcnt == 1) {
+        if (xwl_pixmap->buffer)
+            wl_buffer_destroy(xwl_pixmap->buffer);
+
+        eglDestroyImageKHR(xwl_screen->egl_display, xwl_pixmap->image);
+        gbm_bo_destroy(xwl_pixmap->bo);
+        free(xwl_pixmap);
+    }
+
+    return glamor_destroy_pixmap(pixmap);
+}
+
+static Bool
+xwl_glamor_create_screen_resources(ScreenPtr screen)
+{
+    struct xwl_screen *xwl_screen = xwl_screen_get(screen);
+    int ret;
+
+    screen->CreateScreenResources = xwl_screen->CreateScreenResources;
+    ret = (*screen->CreateScreenResources) (screen);
+    xwl_screen->CreateScreenResources = screen->CreateScreenResources;
+    screen->CreateScreenResources = xwl_glamor_create_screen_resources;
+
+    if (!ret)
+        return ret;
+
+    if (xwl_screen->rootless)
+        screen->devPrivate =
+            fbCreatePixmap(screen, 0, 0, screen->rootDepth, 0);
+    else {
+        screen->devPrivate =
+            xwl_glamor_create_pixmap(screen, screen->width, screen->height,
+                                     screen->rootDepth,
+                                     CREATE_PIXMAP_USAGE_BACKING_PIXMAP);
+        if (screen->devPrivate)
+            glamor_set_screen_pixmap(screen->devPrivate, NULL);
+    }
+
+    return screen->devPrivate != NULL;
+}
+
+static char
+is_fd_render_node(int fd)
+{
+    struct stat render;
+
+    if (fstat(fd, &render))
+        return 0;
+    if (!S_ISCHR(render.st_mode))
+        return 0;
+    if (render.st_rdev & 0x80)
+        return 1;
+
+    return 0;
+}
+
+static void
+xwl_drm_init_egl(struct xwl_screen *xwl_screen)
+{
+    EGLint major, minor;
+    const char *version;
+
+    if (xwl_screen->egl_display)
+        return;
+
+    xwl_screen->expecting_event--;
+
+    xwl_screen->gbm = gbm_create_device(xwl_screen->drm_fd);
+    if (xwl_screen->gbm == NULL) {
+        ErrorF("couldn't get display device\n");
+        return;
+    }
+
+    xwl_screen->egl_display = eglGetDisplay(xwl_screen->gbm);
+    if (xwl_screen->egl_display == EGL_NO_DISPLAY) {
+        ErrorF("eglGetDisplay() failed\n");
+        return;
+    }
+
+    eglBindAPI(EGL_OPENGL_API);
+    if (!eglInitialize(xwl_screen->egl_display, &major, &minor)) {
+        ErrorF("eglInitialize() failed\n");
+        return;
+    }
+
+    version = eglQueryString(xwl_screen->egl_display, EGL_VERSION);
+    ErrorF("glamor: EGL version %s:\n", version);
+
+    xwl_screen->egl_context = eglCreateContext(xwl_screen->egl_display,
+                                               NULL, EGL_NO_CONTEXT, NULL);
+    if (xwl_screen->egl_context == EGL_NO_CONTEXT) {
+        ErrorF("Failed to create EGL context\n");
+        return;
+    }
+
+    if (!eglMakeCurrent(xwl_screen->egl_display,
+                        EGL_NO_SURFACE, EGL_NO_SURFACE,
+                        xwl_screen->egl_context)) {
+        ErrorF("Failed to make EGL context current\n");
+        return;
+    }
+
+    if (!epoxy_has_gl_extension("GL_OES_EGL_image")) {
+        ErrorF("GL_OES_EGL_image no available");
+        return;
+    }
+
+    return;
+}
+
+static void
+xwl_drm_handle_device(void *data, struct wl_drm *drm, const char *device)
+{
+   struct xwl_screen *xwl_screen = data;
+   drm_magic_t magic;
+
+   xwl_screen->device_name = strdup(device);
+   if (!xwl_screen->device_name)
+      return;
+
+   xwl_screen->drm_fd = open(xwl_screen->device_name, O_RDWR | O_CLOEXEC);
+   if (xwl_screen->drm_fd == -1) {
+       ErrorF("wayland-egl: could not open %s (%s)",
+	      xwl_screen->device_name, strerror(errno));
+       return;
+   }
+
+   if (is_fd_render_node(xwl_screen->drm_fd)) {
+       xwl_screen->fd_render_node = 1;
+       xwl_drm_init_egl(xwl_screen);
+   } else {
+       drmGetMagic(xwl_screen->drm_fd, &magic);
+       wl_drm_authenticate(xwl_screen->drm, magic);
+   }
+}
+
+static void
+xwl_drm_handle_format(void *data, struct wl_drm *drm, uint32_t format)
+{
+   struct xwl_screen *xwl_screen = data;
+
+   switch (format) {
+   case WL_DRM_FORMAT_ARGB8888:
+      xwl_screen->formats |= XWL_FORMAT_ARGB8888;
+      break;
+   case WL_DRM_FORMAT_XRGB8888:
+      xwl_screen->formats |= XWL_FORMAT_XRGB8888;
+      break;
+   case WL_DRM_FORMAT_RGB565:
+      xwl_screen->formats |= XWL_FORMAT_RGB565;
+      break;
+   }
+}
+
+static void
+xwl_drm_handle_authenticated(void *data, struct wl_drm *drm)
+{
+    struct xwl_screen *xwl_screen = data;
+
+    if (!xwl_screen->egl_display)
+        xwl_drm_init_egl(xwl_screen);
+}
+
+static void
+xwl_drm_handle_capabilities(void *data, struct wl_drm *drm, uint32_t value)
+{
+   struct xwl_screen *xwl_screen = data;
+
+   xwl_screen->capabilities = value;
+}
+
+static const struct wl_drm_listener xwl_drm_listener = {
+    xwl_drm_handle_device,
+    xwl_drm_handle_format,
+    xwl_drm_handle_authenticated,
+    xwl_drm_handle_capabilities
+};
+
+Bool
+xwl_screen_init_glamor(struct xwl_screen *xwl_screen,
+                       uint32_t id, uint32_t version)
+{
+    if (version < 2)
+        return FALSE;
+
+    xwl_screen->drm =
+        wl_registry_bind(xwl_screen->registry, id, &wl_drm_interface, 2);
+    wl_drm_add_listener(xwl_screen->drm, &xwl_drm_listener, xwl_screen);
+    xwl_screen->expecting_event++;
+
+    return TRUE;
+}
+
+void
+glamor_egl_destroy_textured_pixmap(PixmapPtr pixmap)
+{
+    glamor_destroy_textured_pixmap(pixmap);
+}
+
+int
+glamor_egl_dri3_fd_name_from_tex(ScreenPtr screen,
+                                 PixmapPtr pixmap,
+                                 unsigned int tex,
+                                 Bool want_name, CARD16 *stride, CARD32 *size)
+{
+    return 0;
+}
+
+unsigned int
+glamor_egl_create_argb8888_based_texture(ScreenPtr screen, int w, int h)
+{
+    return 0;
+}
+
+struct xwl_auth_state {
+    int fd;
+    ClientPtr client;
+};
+
+static void
+sync_callback(void *data, struct wl_callback *callback, uint32_t serial)
+{
+    struct xwl_auth_state *state = data;
+
+    dri3_send_open_reply(state->client, state->fd);
+    AttendClient(state->client);
+    free(state);
+    wl_callback_destroy(callback);
+}
+
+static const struct wl_callback_listener sync_listener = {
+   sync_callback
+};
+
+static int
+xwl_dri3_open_client(ClientPtr client,
+                     ScreenPtr screen,
+                     RRProviderPtr provider,
+                     int *pfd)
+{
+    struct xwl_screen *xwl_screen = xwl_screen_get(screen);
+    struct xwl_auth_state *state;
+    struct wl_callback *callback;
+    drm_magic_t magic;
+    int fd;
+
+    fd = open(xwl_screen->device_name, O_RDWR | O_CLOEXEC);
+    if (fd < 0)
+        return BadAlloc;
+    if (xwl_screen->fd_render_node) {
+        *pfd = fd;
+        return Success;
+    }
+
+    state = malloc(sizeof *state);
+    if (state == NULL) {
+        close(fd);
+        return BadAlloc;
+    }
+
+    state->client = client;
+    state->fd = fd;
+
+    if (drmGetMagic(state->fd, &magic) < 0) {
+        close(state->fd);
+        free(state);
+        return BadMatch;
+    }
+
+    wl_drm_authenticate(xwl_screen->drm, magic);
+    callback = wl_display_sync(xwl_screen->display);
+    wl_callback_add_listener(callback, &sync_listener, state);
+
+    IgnoreClient(client);
+
+    return Success;
+}
+
+static PixmapPtr
+xwl_dri3_pixmap_from_fd(ScreenPtr screen, int fd,
+                        CARD16 width, CARD16 height, CARD16 stride,
+                        CARD8 depth, CARD8 bpp)
+{
+    struct xwl_screen *xwl_screen = xwl_screen_get(screen);
+    struct gbm_import_fd_data data;
+    struct gbm_bo *bo;
+    PixmapPtr pixmap;
+
+    if (width == 0 || height == 0 ||
+        depth < 15 || bpp != BitsPerPixel(depth) || stride < width * bpp / 8)
+        return NULL;
+
+    data.fd = fd;
+    data.width = width;
+    data.height = height;
+    data.stride = stride;
+    data.format = gbm_format_for_depth(depth);
+    bo = gbm_bo_import(xwl_screen->gbm, GBM_BO_IMPORT_FD, &data,
+                       GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
+    if (bo == NULL)
+        return NULL;
+
+    pixmap = xwl_glamor_create_pixmap_for_bo(screen, bo, depth);
+    if (pixmap == NULL) {
+        gbm_bo_destroy(bo);
+        return NULL;
+    }
+
+    return pixmap;
+}
+
+static int
+xwl_dri3_fd_from_pixmap(ScreenPtr screen, PixmapPtr pixmap,
+                        CARD16 *stride, CARD32 *size)
+{
+    struct xwl_pixmap *xwl_pixmap;
+
+    xwl_pixmap = xwl_pixmap_get(pixmap);
+
+    *stride = gbm_bo_get_stride(xwl_pixmap->bo);
+    *size = pixmap->drawable.width * *stride;
+
+    return gbm_bo_get_fd(xwl_pixmap->bo);
+}
+
+static dri3_screen_info_rec xwl_dri3_info = {
+    .version = 1,
+    .open = NULL,
+    .pixmap_from_fd = xwl_dri3_pixmap_from_fd,
+    .fd_from_pixmap = xwl_dri3_fd_from_pixmap,
+    .open_client = xwl_dri3_open_client,
+};
+
+Bool
+xwl_glamor_init(struct xwl_screen *xwl_screen)
+{
+    ScreenPtr screen = xwl_screen->screen;
+
+    if (xwl_screen->egl_context == EGL_NO_CONTEXT) {
+        ErrorF("Disabling glamor and dri3, EGL setup failed\n");
+        return FALSE;
+    }
+
+    if (!glamor_init(xwl_screen->screen,
+                     GLAMOR_INVERTED_Y_AXIS |
+                     GLAMOR_USE_EGL_SCREEN |
+                     GLAMOR_USE_SCREEN |
+                     GLAMOR_USE_PICTURE_SCREEN)) {
+        ErrorF("Failed to initialize glamor\n");
+        return FALSE;
+    }
+
+    if (!dri3_screen_init(xwl_screen->screen, &xwl_dri3_info)) {
+        ErrorF("Failed to initialize dri3\n");
+        return FALSE;
+    }
+
+    xwl_screen->CreateScreenResources = screen->CreateScreenResources;
+    screen->CreateScreenResources = xwl_glamor_create_screen_resources;
+    screen->CreatePixmap = xwl_glamor_create_pixmap;
+    screen->DestroyPixmap = xwl_glamor_destroy_pixmap;
+
+    return TRUE;
+}
diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c
index b966e50..17b7bf7 100644
--- a/hw/xwayland/xwayland.c
+++ b/hw/xwayland/xwayland.c
@@ -337,7 +337,13 @@ xwl_screen_post_damage(struct xwl_screen *xwl_screen)
 
         pixmap = (*xwl_screen->screen->GetWindowPixmap) (xwl_window->window);
 
-        buffer = xwl_shm_pixmap_get_wl_buffer(pixmap);
+#if GLAMOR_HAS_GBM
+        if (xwl_screen->glamor)
+            buffer = xwl_glamor_pixmap_get_wl_buffer(pixmap);
+#endif
+        if (!xwl_screen->glamor)
+            buffer = xwl_shm_pixmap_get_wl_buffer(pixmap);
+
         wl_surface_attach(xwl_window->surface, buffer, 0, 0);
         for (i = 0; i < count; i++) {
             box = &RegionRects(region)[i];
@@ -373,6 +379,12 @@ registry_global(void *data, struct wl_registry *registry, uint32_t id,
         xwl_output_create(xwl_screen, id);
         xwl_screen->expecting_event++;
     }
+#ifdef GLAMOR_HAS_GBM
+    else if (xwl_screen->glamor &&
+             strcmp(interface, "wl_drm") == 0 && version >= 2) {
+        xwl_screen_init_glamor(xwl_screen, id, version);
+    }
+#endif
 }
 
 static void
@@ -495,6 +507,10 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
     dixSetPrivate(&pScreen->devPrivates, &xwl_screen_private_key, xwl_screen);
     xwl_screen->screen = pScreen;
 
+#ifdef GLAMOR_HAS_GBM
+    xwl_screen->glamor = 1;
+#endif
+
     for (i = 1; i < argc; i++) {
         if (strcmp(argv[i], "-rootless") == 0) {
             xwl_screen->rootless = 1;
@@ -514,6 +530,9 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
                 atoi(argv[i + 1]);
             i++;
         }
+        else if (strcmp(argv[i], "-shm") == 0) {
+            xwl_screen->glamor = 0;
+        }
     }
 
     if (xwl_screen->listen_fd_count > 0) {
@@ -591,10 +610,19 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
     if (!xwl_screen_init_cursor(xwl_screen))
         return FALSE;
 
-    xwl_screen->CreateScreenResources = pScreen->CreateScreenResources;
-    pScreen->CreateScreenResources = xwl_shm_create_screen_resources;
-    pScreen->CreatePixmap = xwl_shm_create_pixmap;
-    pScreen->DestroyPixmap = xwl_shm_destroy_pixmap;
+#ifdef GLAMOR_HAS_GBM
+    if (xwl_screen->glamor && !xwl_glamor_init(xwl_screen)) {
+        ErrorF("Failed to initialize glamor, falling back to sw\n");
+        xwl_screen->glamor = 0;
+    }
+#endif
+
+    if (!xwl_screen->glamor) {
+        xwl_screen->CreateScreenResources = pScreen->CreateScreenResources;
+        pScreen->CreateScreenResources = xwl_shm_create_screen_resources;
+        pScreen->CreatePixmap = xwl_shm_create_pixmap;
+        pScreen->DestroyPixmap = xwl_shm_destroy_pixmap;
+    }
 
     xwl_screen->RealizeWindow = pScreen->RealizeWindow;
     pScreen->RealizeWindow = xwl_realize_window;
diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h
index 8157e71..fc68550 100644
--- a/hw/xwayland/xwayland.h
+++ b/hw/xwayland/xwayland.h
@@ -55,6 +55,7 @@ struct xwl_screen {
     int listen_fds[5];
     int listen_fd_count;
     int rootless;
+    int glamor;
 
     CreateScreenResourcesProcPtr CreateScreenResources;
     CloseScreenProcPtr CloseScreen;
@@ -83,6 +84,16 @@ struct xwl_screen {
 #define XWL_FORMAT_RGB565   (1 << 2)
 
     int prepare_read;
+
+    char *device_name;
+    int drm_fd;
+    int fd_render_node;
+    struct wl_drm *drm;
+    uint32_t formats;
+    uint32_t capabilities;
+    void *egl_display, *egl_context;
+    struct gbm_device *gbm;
+    struct glamor_context *glamor_ctx;
 };
 
 struct xwl_window {
@@ -161,4 +172,10 @@ Bool xwl_shm_destroy_pixmap(PixmapPtr pixmap);
 struct wl_buffer *xwl_shm_pixmap_get_wl_buffer(PixmapPtr pixmap);
 
 
+Bool xwl_glamor_init(struct xwl_screen *xwl_screen);
+
+Bool xwl_screen_init_glamor(struct xwl_screen *xwl_screen,
+                         uint32_t id, uint32_t version);
+struct wl_buffer *xwl_glamor_pixmap_get_wl_buffer(PixmapPtr pixmap);
+
 #endif
commit fd16555c2fc606fc43236050deba558c20e184e8
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Tue Jun 24 16:09:19 2014 +0900

    Revert "glamor: Fix coordinates handling for composite source/mask pictures"
    
    This reverts commit 4e9aabb6fc15d8052934f20c6a07801c197ec36a.
    
    It broke kwin decorations with XRender compositing.
    
    Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
    Reviewed-by: Eric Anholt <eric at anholt.net>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c
index 5a7a238..14ab738 100644
--- a/glamor/glamor_render.c
+++ b/glamor/glamor_render.c
@@ -1450,8 +1450,8 @@ glamor_composite_clipped_region(CARD8 op,
                     || source_pixmap->drawable.height != height)))) {
         temp_src =
             glamor_convert_gradient_picture(screen, source,
-                                            x_source,
-                                            y_source,
+                                            extent->x1 + x_source - x_dest,
+                                            extent->y1 + y_source - y_dest,
                                             width, height);
         if (!temp_src) {
             temp_src = source;
@@ -1459,8 +1459,8 @@ glamor_composite_clipped_region(CARD8 op,
         }
         temp_src_priv =
             glamor_get_pixmap_private((PixmapPtr) (temp_src->pDrawable));
-        x_temp_src = 0;
-        y_temp_src = 0;
+        x_temp_src = -extent->x1 + x_dest;
+        y_temp_src = -extent->y1 + y_dest;
     }
 
     if (mask
@@ -1474,8 +1474,8 @@ glamor_composite_clipped_region(CARD8 op,
          * to do reduce one convertion. */
         temp_mask =
             glamor_convert_gradient_picture(screen, mask,
-                                            x_mask,
-                                            y_mask,
+                                            extent->x1 + x_mask - x_dest,
+                                            extent->y1 + y_mask - y_dest,
                                             width, height);
         if (!temp_mask) {
             temp_mask = mask;
@@ -1483,8 +1483,8 @@ glamor_composite_clipped_region(CARD8 op,
         }
         temp_mask_priv =
             glamor_get_pixmap_private((PixmapPtr) (temp_mask->pDrawable));
-        x_temp_mask = 0;
-        y_temp_mask = 0;
+        x_temp_mask = -extent->x1 + x_dest;
+        y_temp_mask = -extent->y1 + y_dest;
     }
     /* Do two-pass PictOpOver componentAlpha, until we enable
      * dual source color blending.
commit 18744907d0766b1b57be12df5adafd0f93221006
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Jun 10 07:45:05 2014 +0100

    dri2: Invalidate DRI2Buffers upon SetWindowPixmap updates
    
    When transitioning to a redirected or unredirected Window, the Composite
    layer modifies the Window's Pixmap. However, the DRI2Buffer for the
    Drawable is still pointing to the backing bo of the old Pixmap with the
    result that rendering goes astray.
    
    This now also effects DRI2 Drawables that are touched by PresentPixmap.
    
    v2: Fixup the function name after rebasing
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
    Cc: Reinis Danne <reinis.danne at gmail.com>
    Reviewed-by: Dave Airlie <airlied at redhat.com>
    Cc: Keith Packard <keithp at keithp.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 5705baa..6459f11 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -130,6 +130,7 @@ typedef struct _DRI2Screen {
     HandleExposuresProcPtr HandleExposures;
 
     ConfigNotifyProcPtr ConfigNotify;
+    SetWindowPixmapProcPtr SetWindowPixmap;
     DRI2CreateBuffer2ProcPtr CreateBuffer2;
     DRI2DestroyBuffer2ProcPtr DestroyBuffer2;
     DRI2CopyRegion2ProcPtr CopyRegion2;
@@ -1378,6 +1379,21 @@ DRI2ConfigNotify(WindowPtr pWin, int x, int y, int w, int h, int bw,
     return Success;
 }
 
+static void
+DRI2SetWindowPixmap(WindowPtr pWin, PixmapPtr pPix)
+{
+    DrawablePtr pDraw = (DrawablePtr) pWin;
+    ScreenPtr pScreen = pDraw->pScreen;
+    DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
+
+    pScreen->SetWindowPixmap = ds->SetWindowPixmap;
+    (*pScreen->SetWindowPixmap) (pWin, pPix);
+    ds->SetWindowPixmap = pScreen->SetWindowPixmap;
+    pScreen->SetWindowPixmap = DRI2SetWindowPixmap;
+
+    DRI2InvalidateDrawableAll(pDraw);
+}
+
 #define MAX_PRIME DRI2DriverPrimeMask
 static int
 get_prime_id(void)
@@ -1524,6 +1540,9 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
     ds->ConfigNotify = pScreen->ConfigNotify;
     pScreen->ConfigNotify = DRI2ConfigNotify;
 
+    ds->SetWindowPixmap = pScreen->SetWindowPixmap;
+    pScreen->SetWindowPixmap = DRI2SetWindowPixmap;
+
     xf86DrvMsg(pScreen->myNum, X_INFO, "[DRI2] Setup complete\n");
     for (i = 0; i < sizeof(driverTypeNames) / sizeof(driverTypeNames[0]); i++) {
         if (i < ds->numDrivers && ds->driverNames[i]) {
@@ -1548,6 +1567,7 @@ DRI2CloseScreen(ScreenPtr pScreen)
     DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
 
     pScreen->ConfigNotify = ds->ConfigNotify;
+    pScreen->SetWindowPixmap = ds->SetWindowPixmap;
 
     if (ds->prime_id)
         prime_id_allocate_bitmask &= ~(1 << ds->prime_id);
commit 4d92fab39c4225e89f2d157a1f559cb0618a6eaa
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Jun 18 11:14:43 2014 +0100

    dri2: Use the PrimeScreen when creating/reusing buffers
    
    This fixes a segfault when we attempt to call ds->ReuseBufferNotify()
    passing a Prime DRI2BufferPtr to the master backend.
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=80001
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
    Reviewed-by: Dave Airlie <airlied at redhat.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 6dd7796..5705baa 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -415,18 +415,14 @@ DRI2DrawableGone(void *p, XID id)
 }
 
 static DRI2BufferPtr
-create_buffer(DrawablePtr pDraw,
+create_buffer(DRI2ScreenPtr ds, DrawablePtr pDraw,
               unsigned int attachment, unsigned int format)
 {
-    ScreenPtr primeScreen;
-    DRI2DrawablePtr pPriv;
-    DRI2ScreenPtr ds;
     DRI2BufferPtr buffer;
-    pPriv = DRI2GetDrawable(pDraw);
-    primeScreen = GetScreenPrime(pDraw->pScreen, pPriv->prime_id);
-    ds = DRI2GetScreenPrime(pDraw->pScreen, pPriv->prime_id);
     if (ds->CreateBuffer2)
-        buffer = (*ds->CreateBuffer2)(primeScreen, pDraw, attachment, format);
+        buffer = (*ds->CreateBuffer2)(GetScreenPrime(pDraw->pScreen,
+                                                     DRI2GetDrawable(pDraw)->prime_id),
+                                      pDraw, attachment, format);
     else
         buffer = (*ds->CreateBuffer)(pDraw, attachment, format);
     return buffer;
@@ -475,7 +471,7 @@ allocate_or_reuse_buffer(DrawablePtr pDraw, DRI2ScreenPtr ds,
     if ((old_buf < 0)
         || attachment == DRI2BufferFrontLeft
         || !dimensions_match || (pPriv->buffers[old_buf]->format != format)) {
-        *buffer = create_buffer (pDraw, attachment, format);
+        *buffer = create_buffer(ds, pDraw, attachment, format);
         return TRUE;
 
     }
@@ -538,7 +534,7 @@ do_get_buffers(DrawablePtr pDraw, int *width, int *height,
         return NULL;
     }
 
-    ds = DRI2GetScreen(pDraw->pScreen);
+    ds = DRI2GetScreenPrime(pDraw->pScreen, pPriv->prime_id);
 
     dimensions_match = (pDraw->width == pPriv->width)
         && (pDraw->height == pPriv->height);
commit 0d9ad781807022d78239327ed508758a3f88b090
Author: Eric Anholt <eric at anholt.net>
Date:   Mon Jun 16 08:06:53 2014 +0100

    glamor: Fix GLES2 non-VBO temporary memory allocation.
    
    We'd get a request for like 16 bytes, claim to have allocated
    GLAMOR_VBO_SIZE, and then not reallocate when something a request
    bigger than 16 came along.  The intent was to always allocate at least
    GLAMOR_VBO_SIZE.
    
    Fixes segfaults with Xephyr -glamor_gles2 and running gnome-terminal.
    
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/glamor/glamor_vbo.c b/glamor/glamor_vbo.c
index c678559..e906101 100644
--- a/glamor/glamor_vbo.c
+++ b/glamor/glamor_vbo.c
@@ -119,7 +119,7 @@ glamor_get_vbo_space(ScreenPtr screen, unsigned size, char **vbo_offset)
         if (glamor_priv->vbo_size < size) {
             glamor_priv->vbo_size = MAX(GLAMOR_VBO_SIZE, size);
             free(glamor_priv->vb);
-            glamor_priv->vb = XNFalloc(size);
+            glamor_priv->vb = XNFalloc(glamor_priv->vbo_size);
         }
         *vbo_offset = NULL;
         /* We point to the start of glamor_priv->vb every time, and
commit 736bed2aaf4bb672b6c7b33146fe84700baf22bd
Merge: ce581ac d90b5f8
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Jun 23 14:18:03 2014 -0700

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

commit ce581ac3fa80c4c52d87bd54fa92bc566b7d6adc
Author: Axel Davy <axel.davy at ens.fr>
Date:   Wed Jun 18 22:22:09 2014 -0400

    present: fix bad logic in cancelling scheduled operations.
    
    If we present several pixmaps in advance for different msc, the later one
    shouldn't cancel the previous ones.
    
    This reverts a change made by commit
    e6f5d9d7b7efdacea0f22f1808efca849bcede4c
    
    Without this fix, vblank_mode=0 glxgears doesn't update
    with the present fallback.
    
    Signed-off-by: Axel Davy <axel.davy at ens.fr>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/present/present.c b/present/present.c
index 271c251..3aea0d7 100644
--- a/present/present.c
+++ b/present/present.c
@@ -771,7 +771,7 @@ present_pixmap(WindowPtr window,
             if (!vblank->queued)
                 continue;
 
-            if (vblank->crtc != target_crtc || vblank->target_msc > target_msc)
+            if (vblank->crtc != target_crtc || vblank->target_msc != target_msc)
                 continue;
 
             DebugPresent(("\tx %lld %p %8lld: %08lx -> %08lx (crtc %p)\n",
commit adb7bc3386559dfee34b359dadcbb6796bc416e7
Author: Dinar Valeev <dvaleev at suse.com>
Date:   Mon Feb 24 11:36:54 2014 +0100

    arch: Fix image and bitmap byte order for ppc64le
    
    So far PPC was big endian for sure. For ppc64le this is no longer
    true.
    
    Signed-off-by: Egbert Eich <eich at freedesktop.org>
    Reviewed-by: Mark Kettenis <kettenis at openbsd.org>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/include/servermd.h b/include/servermd.h
index 081123b..e413314 100644
--- a/include/servermd.h
+++ b/include/servermd.h
@@ -114,8 +114,13 @@ SOFTWARE.
 
 #if defined(__powerpc__) || defined(__ppc__) || defined(__ppc64__)
 
-#define IMAGE_BYTE_ORDER        MSBFirst
-#define BITMAP_BIT_ORDER        MSBFirst
+#if defined(__LITTLE_ENDIAN__)
+#define IMAGE_BYTE_ORDER      LSBFirst
+#define BITMAP_BIT_ORDER      LSBFirst
+#else
+#define IMAGE_BYTE_ORDER      MSBFirst
+#define BITMAP_BIT_ORDER      MSBFirst
+#endif
 #define GLYPHPADBYTES           4
 
 #endif                          /* PowerPC */
commit ea47341792cf06eda5bbdf0aca48aacc024a5be0
Merge: 334faab a11bbd8
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Jun 23 13:50:54 2014 -0700

    Merge remote-tracking branch 'anholt/glamor-fixes'

commit 334faabe682a422075ba214501c7554dd5ee5563
Author: Frank Binns <frank.binns at imgtec.com>
Date:   Tue Jun 10 13:43:31 2014 +0100

    present: restore screen pixmap when aborting a flip
    
    If a 2D application is started on top of a fullscreen 3D application, which
    is flipping, then we need to stop flipping and restore the root window, and
    possibly the flip window, to using the screen pixmap. Normally this would
    be done as part of an unflip. However, in the case that there is a pending
    flip there is no mechanism to abort so the unflip is deferred until the
    pending flip completes. This provides a window of opportunity for the 2D
    application to draw to the wrong pixmap.
    
    Restore the screen pixmap at the point a pending flip is marked as aborted,
    thus avoiding this issue.
    
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Frank Binns <frank.binns at imgtec.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/present/present.c b/present/present.c
index 165860a..271c251 100644
--- a/present/present.c
+++ b/present/present.c
@@ -383,6 +383,24 @@ present_set_tree_pixmap(WindowPtr window, PixmapPtr pixmap)
 }
 
 static void
+present_set_abort_flip(ScreenPtr screen)
+{
+    present_screen_priv_ptr screen_priv = present_screen_priv(screen);
+
+    /* Switch back to using the screen pixmap now to avoid
+     * 2D applications drawing to the wrong pixmap.
+     */
+
+    if (screen_priv->flip_window)
+        present_set_tree_pixmap(screen_priv->flip_window,
+                                  (*screen->GetScreenPixmap)(screen));
+
+    present_set_tree_pixmap(screen->root, (*screen->GetScreenPixmap)(screen));
+
+    screen_priv->flip_pending->abort_flip = TRUE;
+}
+
+static void
 present_unflip(ScreenPtr screen)
 {
     present_screen_priv_ptr screen_priv = present_screen_priv(screen);
@@ -511,7 +529,7 @@ present_check_flip_window (WindowPtr window)
         if (flip_pending->window == window) {
             if (!present_check_flip(flip_pending->crtc, window, flip_pending->pixmap,
                                     flip_pending->sync_flip, NULL, 0, 0))
-                flip_pending->abort_flip = TRUE;
+                present_set_abort_flip(screen);
         }
     } else {
         /*
@@ -634,7 +652,7 @@ present_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc)
             /* Check pending flip
              */
             if (window == screen_priv->flip_pending->window)
-                screen_priv->flip_pending->abort_flip = TRUE;
+                present_set_abort_flip(screen);
         } else if (!screen_priv->unflip_event_id) {
 
             /* Check current flip
@@ -916,7 +934,7 @@ present_flip_destroy(ScreenPtr screen)
 
     /* Do the actual cleanup once the flip has been performed by the hardware */
     if (screen_priv->flip_pending)
-        screen_priv->flip_pending->abort_flip = TRUE;
+        present_set_abort_flip(screen);
 }
 
 void
commit d90b5f83010248be65b2039b0b2d0b9e6a4e93cf
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Fri May 30 09:56:37 2014 +1000

    dix: fix up coordinate scaling when external monitors are present
    
    The goal of all this is to get an x/y motion reflecting the motion
    on the device, i.e. a circle on the device is a circle on the screen.
    
    This is currently done by scaling the y coordinate depending on the screen
    ratio vs device ratio. Depending on that ratio the movement on the y axis may
    be accelerated (ratio < 1) or slowed (ratio > 1). This leads to the weird
    effect that changing the screen ratio by plugging a new monitor changes the
    speed of the touchpad.
    
    Use a different algorithm: calculate the physical movement on the device, map
    that to the same-ish distance on the screen, then convert that back into a
    device-specific vector. This way we get the same mapping regardless of the
    current screen dimensions.
    
    Since the pointer accel code doesn't take device resolution into account, make
    sure we apply our crazy mapping before we accelerate. This way we accelerate
    resolution-independent.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Hans de Goede <hdegoede at redhat.com>

diff --git a/dix/getevents.c b/dix/getevents.c
index ffa89fa..d68fa96 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -770,27 +770,65 @@ add_to_scroll_valuator(DeviceIntPtr dev, ValuatorMask *mask, int valuator, doubl
 }
 
 
+/* FIXME: relative events from devices with absolute axis ranges is
+   fundamentally broken. We map the device coordinate range into the screen
+   range, but don't really account for device resolution in that.
+
+   what we do here is a hack to make touchpads usable. for a given relative
+   motion vector in device coordinates:
+   1. calculate physical movement on the device in metres
+   2. calculate pixel vector that is the same physical movement on the
+      screen (times some magic number to provide sensible base speed)
+   3. calculate what percentage this vector is of the current screen
+      width/height
+   4. calculate equivalent vector in % on the device's min/max axis range
+   5. Use that device vector as the actual motion vector
+
+   e.g. 10/50mm on the device, 10/50mm on the screen are 30/100 pixels,
+   30/100 pixels are 1/3% of the width, 1/3% of the device is a vector of
+   20/80 -> use 20/80 as dx/dy.
+
+   dx/dy is then applied to the current position in device coordinates,
+   mapped to screen coordinates and thus the movement on the screen reflects
+   the motion direction on the device.
+ */
 static void
 scale_for_device_resolution(DeviceIntPtr dev, ValuatorMask *mask)
 {
-    double y;
+    double x, y;
     ValuatorClassPtr v = dev->valuator;
     int xrange = v->axes[0].max_value - v->axes[0].min_value + 1;
     int yrange = v->axes[1].max_value - v->axes[1].min_value + 1;
 
-    double screen_ratio = 1.0 * screenInfo.width/screenInfo.height;
-    double device_ratio = 1.0 * xrange/yrange;
-    double resolution_ratio = 1.0;
-    double ratio;
+    /* Assume 100 units/m for devices without resolution */
+    int xres = 100000, yres = 100000;
 
-    if (!valuator_mask_fetch_double(mask, 1, &y))
-        return;
+    /* If we have multiple screens with different dpi, it gets complicated:
+       we have to map which screen we're on and then take the dpi of that
+       screen to be somewhat accurate.  */
+    const ScreenPtr s = screenInfo.screens[0];
+    const double screen_res = 1000.0 * s->width/s->mmWidth; /* units/m */
 
-    if (v->axes[0].resolution != 0 && v->axes[1].resolution != 0)
-        resolution_ratio = 1.0 * v->axes[0].resolution/v->axes[1].resolution;
+    /* some magic multiplier, so unaccelerated movement of x mm on the
+       device reflects x * magic mm on the screen */
+    const double magic = 4;
 
-    ratio = device_ratio/resolution_ratio/screen_ratio;
-    valuator_mask_set_double(mask, 1, y / ratio);
+    if (v->axes[0].resolution != 0 && v->axes[1].resolution != 0) {
+        xres = v->axes[0].resolution;
+        yres = v->axes[1].resolution;
+    }
+
+    if (valuator_mask_isset(mask, 0)) {
+        x = valuator_mask_get_double(mask, 0);
+        x = magic * x/xres * screen_res/screenInfo.width * xrange;
+        valuator_mask_set_double(mask, 0, x);
+    }
+
+    if (valuator_mask_isset(mask, 1)) {
+        y = valuator_mask_get_double(mask, 1);
+        y = magic * y/yres * screen_res/screenInfo.height * yrange;
+        valuator_mask_set_double(mask, 1, y);
+    }
 }
 
 /**
@@ -804,15 +842,6 @@ moveRelative(DeviceIntPtr dev, int flags, ValuatorMask *mask)
 {
     int i;
     Bool clip_xy = IsMaster(dev) || !IsFloating(dev);
-    ValuatorClassPtr v = dev->valuator;
-
-    /* for abs devices in relative mode, we've just scaled wrong, since we
-       mapped the device's shape into the screen shape. Undo this. */
-    if ((flags & POINTER_ABSOLUTE) == 0 && v && v->numAxes > 1 &&
-        v->axes[0].min_value < v->axes[0].max_value &&
-        v->axes[1].min_value < v->axes[1].max_value) {
-        scale_for_device_resolution(dev, mask);
-    }
 
     /* calc other axes, clip, drop back into valuators */
     for (i = 0; i < valuator_mask_size(mask); i++) {
@@ -1441,10 +1470,21 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type,
             set_raw_valuators(raw, &mask, raw->valuators.data);
     }
     else {
+        ValuatorClassPtr v = pDev->valuator;
+
         transformRelative(pDev, &mask);
 
+        /* for abs devices in relative mode, we've just scaled wrong, since we
+           mapped the device's shape into the screen shape. Undo this. */
+        if (v && v->numAxes > 1 &&
+            v->axes[0].min_value < v->axes[0].max_value &&
+            v->axes[1].min_value < v->axes[1].max_value) {
+            scale_for_device_resolution(pDev, &mask);
+        }
+
         if (flags & POINTER_ACCELERATE)
             accelPointer(pDev, &mask, ms);
+
         if ((flags & POINTER_NORAW) == 0 && raw)
             set_raw_valuators(raw, &mask, raw->valuators.data);
 
commit 382ff4a306b97b0ddcdac03ce8611b026ca5323b
Author: Keith Packard <keithp at keithp.com>
Date:   Tue Jun 17 15:50:48 2014 -0700

    present: Remove executing vblank from window list. Bug# 79709.
    
    Once the vblank is actually getting executed, it's lifetime is no
    longer tied to the window, and so it shouldn't be controlled by window
    destruction. In particular, if the vblank is queued for flip, it will
    get stored in the flip_pending field, and will be correctly destroyed
    when the flip completes.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/present/present.c b/present/present.c
index 1bf3a58..165860a 100644
--- a/present/present.c
+++ b/present/present.c
@@ -578,6 +578,7 @@ present_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc)
     }
 
     xorg_list_del(&vblank->event_queue);
+    xorg_list_del(&vblank->window_list);
     vblank->queued = FALSE;
 
     if (vblank->pixmap && vblank->window) {
commit a11bbd875f3f90a3d02d727778cb1d3524cf59fd
Author: Eric Anholt <eric at anholt.net>
Date:   Fri May 30 10:39:30 2014 -0700

    glamor: Don't leak a prepare_access_gc() in putimage fallbacks.
    
    It turns out putimage doesn't use the GC tile or stipple anyway, so
    there's no need to do this.
    
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/glamor/glamor_image.c b/glamor/glamor_image.c
index 4791d08..b38b412 100644
--- a/glamor/glamor_image.c
+++ b/glamor/glamor_image.c
@@ -88,8 +88,7 @@ static void
 glamor_put_image_bail(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
                       int w, int h, int leftPad, int format, char *bits)
 {
-    if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW) &&
-        glamor_prepare_access_gc(gc))
+    if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW))
         fbPutImage(drawable, gc, depth, x, y, w, h, leftPad, format, bits);
     glamor_finish_access(drawable);
 }
commit 8da1e4e2bf28c3610cdbe1770a57be89578d37f5
Author: Markus Wick <markus at selfnet.de>
Date:   Wed May 14 23:08:18 2014 +0200

    glamor: Choose max fbo size by texture + viewport size
    
    The max size of renderbuffers and texture often match by accident, but
    as we always use textures, we should check for the right flag.  Also
    check for viewport size as this may be lower and we want to render to
    almost every pixmap.
    
    Signed-off-by: Markus Wick <markus at selfnet.de>
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Eric Anholt <eric at anholt.net>

diff --git a/glamor/glamor.c b/glamor/glamor.c
index 08f6ba1..c398807 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -316,6 +316,7 @@ glamor_init(ScreenPtr screen, unsigned int flags)
 {
     glamor_screen_private *glamor_priv;
     int gl_version;
+    int max_viewport_size;
 
 #ifdef RENDER
     PictureScreenPtr ps = GetPictureScreenIfSet(screen);
@@ -406,7 +407,9 @@ glamor_init(ScreenPtr screen, unsigned int flags)
         epoxy_has_gl_extension("GL_ARB_map_buffer_range");
     glamor_priv->has_buffer_storage =
         epoxy_has_gl_extension("GL_ARB_buffer_storage");
-    glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &glamor_priv->max_fbo_size);
+    glGetIntegerv(GL_MAX_TEXTURE_SIZE, &glamor_priv->max_fbo_size);
+    glGetIntegerv(GL_MAX_VIEWPORT_DIMS, &max_viewport_size);
+    glamor_priv->max_fbo_size = MIN(glamor_priv->max_fbo_size, max_viewport_size);
 #ifdef MAX_FBO_SIZE
     glamor_priv->max_fbo_size = MAX_FBO_SIZE;
 #endif
commit 3778fab34bc00334edec4f845d0c6d43440f265a
Author: Markus Wick <markus at selfnet.de>
Date:   Wed May 14 23:08:17 2014 +0200

    glamor: Fix no-mipmap allocations
    
    With GL_TEXTURE_MIN_FILTER, we configure not to use mipmaps, but
    there's no real way until GL_ARB_texture_storage to dictate whether
    memory should be allocated for mipmap levels or not.
    
    GL_TEXTURE_MAX_LEVEL is a stronger hint to the driver than the
    filtering that we really don't want mipmap allocations.  Stops VARM
    wasting warnings from the nvidia driver.
    
    Signed-off-by: Markus Wick <markus at selfnet.de>
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/glamor/glamor_fbo.c b/glamor/glamor_fbo.c
index 5521683..090dfd8 100644
--- a/glamor/glamor_fbo.c
+++ b/glamor/glamor_fbo.c
@@ -347,6 +347,7 @@ _glamor_create_tex(glamor_screen_private *glamor_priv,
         glamor_make_current(glamor_priv);
         glGenTextures(1, &tex);
         glBindTexture(GL_TEXTURE_2D, tex);
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
         glTexImage2D(GL_TEXTURE_2D, 0, format, w, h, 0,
diff --git a/glamor/glamor_font.c b/glamor/glamor_font.c
index f747d59..57c607d 100644
--- a/glamor/glamor_font.c
+++ b/glamor/glamor_font.c
@@ -95,6 +95,7 @@ glamor_font_get(ScreenPtr screen, FontPtr font)
     glActiveTexture(GL_TEXTURE0);
     glBindTexture(GL_TEXTURE_2D, glamor_font->texture_id);
 
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
 
diff --git a/glamor/glamor_pixmap.c b/glamor/glamor_pixmap.c
index 54b414b..789d377 100644
--- a/glamor/glamor_pixmap.c
+++ b/glamor/glamor_pixmap.c
@@ -717,6 +717,7 @@ __glamor_upload_pixmap_to_texture(PixmapPtr pixmap, unsigned int *tex,
     }
 
     glBindTexture(GL_TEXTURE_2D, *tex);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
     glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
commit 1095c262502332bc570a9b288b01da51c1fa10ec
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Fri Jun 6 17:54:22 2014 -0700

    config: show default path in help for --with-xkb-bin-directory
    
    Now shows:
      --with-xkb-bin-directory=DIR
                              Directory containing xkbcomp program (default:
                              ${bindir})
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/configure.ac b/configure.ac
index 0a6e772..dabebb9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1424,7 +1424,7 @@ AC_DEFINE(SHAPE, 1, [Support SHAPE extension])
 
 AC_DEFINE_DIR(XKB_BASE_DIRECTORY, XKBPATH, [Path to XKB data])
 AC_ARG_WITH(xkb-bin-directory,
-				AS_HELP_STRING([--with-xkb-bin-directory=DIR], [Directory containing xkbcomp program]),
+				AS_HELP_STRING([--with-xkb-bin-directory=DIR], [Directory containing xkbcomp program (default: ${bindir})]),
 				[XKB_BIN_DIRECTORY="$withval"],
 				[XKB_BIN_DIRECTORY="$bindir"])
 
commit e27a839bf0488d5b1cc2e2a887f2ea0e3d790790
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Thu Jun 5 20:38:44 2014 -0700

    mi: Build fix: mieqProcessDeviceEvent returns void
    
    mieq.c:520:9: error: void function 'mieqProcessDeviceEvent' should not return a value [-Wreturn-type,Semantic Issue]
            return 0;
            ^      ~
    1 error generated.
    
    Regression-from: 9fb08310b51b46736f3ca8dbc04efdf502420403
    Found-by: Tinderbox
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/mi/mieq.c b/mi/mieq.c
index 0e27405..872ff93 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -517,7 +517,7 @@ mieqProcessDeviceEvent(DeviceIntPtr dev, InternalEvent *event, ScreenPtr screen)
 
     /* refuse events from disabled devices */
     if (!dev->enabled)
-        return 0;
+        return;
 
     /* Custom event handler */
     handler = miEventQueue.handlers[event->any.type];
commit 08820f03768e904f1746ef93ca01660330dc5406
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Jun 4 22:28:57 2014 -0700

    Update to version 1.15.99.903
    
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/configure.ac b/configure.ac
index e3d991d..0a6e772 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,9 +26,9 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ(2.60)
-AC_INIT([xorg-server], 1.15.99.902, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
-RELEASE_DATE="2014-04-08"
-RELEASE_NAME="Glacier Blue"
+AC_INIT([xorg-server], 1.15.99.903, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+RELEASE_DATE="2014-06-04"
+RELEASE_NAME="Strawberry Shortcake"
 AC_CONFIG_SRCDIR([Makefile.am])
 AC_CONFIG_MACRO_DIR([m4])
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
commit 9fb08310b51b46736f3ca8dbc04efdf502420403
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed May 21 10:07:31 2014 +1000

    mi: don't process events from disabled devices (#77884)
    
    Once a device is disabled, it doesn't have a sprite pointer anymore. If an
    event is still in the queue and processed after DisableDevice finished, a
    dereference causes a crash. Example backtrace (crash forced by injecting an
    event at the right time):
    
    (EE) 0: /opt/xorg/bin/Xorg (OsSigHandler+0x3c) [0x48d334]
    (EE) 1: /lib64/libpthread.so.0 (__restore_rt+0x0) [0x37fcc0f74f]
    (EE) 2: /opt/xorg/bin/Xorg (mieqMoveToNewScreen+0x38) [0x609240]
    (EE) 3: /opt/xorg/bin/Xorg (mieqProcessDeviceEvent+0xd4) [0x609389]
    (EE) 4: /opt/xorg/bin/Xorg (mieqProcessInputEvents+0x206) [0x609720]
    (EE) 5: /opt/xorg/bin/Xorg (ProcessInputEvents+0xd) [0x4aeb58]
    (EE) 6: /opt/xorg/bin/Xorg (xf86VTSwitch+0x1a6) [0x4af457]
    (EE) 7: /opt/xorg/bin/Xorg (xf86Wakeup+0x2bf) [0x4af0a7]
    (EE) 8: /opt/xorg/bin/Xorg (WakeupHandler+0x83) [0x4445cb]
    (EE) 9: /opt/xorg/bin/Xorg (WaitForSomething+0x3fe) [0x491bf6]
    (EE) 10: /opt/xorg/bin/Xorg (Dispatch+0x97) [0x435748]
    (EE) 11: /opt/xorg/bin/Xorg (dix_main+0x61d) [0x4438a9]
    (EE) 12: /opt/xorg/bin/Xorg (main+0x28) [0x49ba28]
    (EE) 13: /lib64/libc.so.6 (__libc_start_main+0xf5) [0x37fc821d65]
    (EE) 14: /opt/xorg/bin/Xorg (_start+0x29) [0x425e69]
    (EE) 15: ? (?+0x29) [0x29]
    
    xf86VTSwitch() calls ProcessInputEvents() before disabling a device, and
    DisableDevice() calls mieqProcessInputEvents() again when flushing touches and
    button events. Between that and disabling the device (which causes new events
    to be refused) there is a window where events may be triggered and enqueued.
    On the next call to PIE that event is processed on a now defunct device,
    causing the crash.
    
    The simplest fix to this is to discard events from disabled devices. We flush
    the queue often enough before disabling that when we get here, we really don't
    care about the events from this device.
    
    X.Org Bug 77884 <http://bugs.freedesktop.org/show_bug.cgi?id=77884>
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reported-by: Maarten Lankhorst <maarten.lankhorst at canonical.com>
    Tested-by: Maarten Lankhorst <maarten.lankhorst at canonical.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/mi/mieq.c b/mi/mieq.c
index 36aa213..0e27405 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -515,6 +515,10 @@ mieqProcessDeviceEvent(DeviceIntPtr dev, InternalEvent *event, ScreenPtr screen)
 
     verify_internal_event(event);
 
+    /* refuse events from disabled devices */
+    if (!dev->enabled)
+        return 0;
+
     /* Custom event handler */
     handler = miEventQueue.handlers[event->any.type];
 
diff --git a/test/input.c b/test/input.c
index 9b5db89..a4615c9 100644
--- a/test/input.c
+++ b/test/input.c
@@ -1712,6 +1712,18 @@ mieq_test_event_handler(int screenNum, InternalEvent *ie, DeviceIntPtr dev)
 static void
 _mieq_test_generate_events(uint32_t start, uint32_t count)
 {
+    static DeviceIntRec dev;
+    static SpriteInfoRec spriteInfo;
+    static SpriteRec sprite;
+
+    memset(&dev, 0, sizeof(dev));
+    memset(&spriteInfo, 0, sizeof(spriteInfo));
+    memset(&sprite, 0, sizeof(sprite));
+    dev.spriteInfo = &spriteInfo;
+    spriteInfo.sprite = &sprite;
+
+    dev.enabled = 1;
+
     count += start;
     while (start < count) {
         RawDeviceEvent e = { 0 };
@@ -1721,7 +1733,7 @@ _mieq_test_generate_events(uint32_t start, uint32_t count)
         e.time = GetTimeInMillis();
         e.flags = start;
 
-        mieqEnqueue(NULL, (InternalEvent *) &e);
+        mieqEnqueue(&dev, (InternalEvent *) &e);
 
         start++;
     }
commit e6f5d9d7b7efdacea0f22f1808efca849bcede4c
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Jan 27 11:23:58 2014 -0800

    present: Queue flips for later execution
    
    When a flip (or unflip) is pending and a flip request comes in, leave
    it queued until the pending flip completes and then execute it.
    
    This fixes a bug where an application submitting back-to-back
    present_pixmap requests for sequential frames would alternate between
    flipping and copying as the pending flip would cause the new
    present_pixmap request to not use a flip.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
    Tested-by: Frank Binns <frank.binns at imgtec.com>

diff --git a/present/present.c b/present/present.c
index 73d5f69..1bf3a58 100644
--- a/present/present.c
+++ b/present/present.c
@@ -42,6 +42,9 @@ static struct xorg_list present_flip_queue;
 #define DebugPresent(x)
 #endif
 
+static void
+present_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc);
+
 /*
  * Copies the update region from a pixmap to the target drawable
  */
@@ -78,6 +81,20 @@ present_copy_region(DrawablePtr drawable,
     FreeScratchGC(gc);
 }
 
+static inline PixmapPtr
+present_flip_pending_pixmap(ScreenPtr screen)
+{
+    present_screen_priv_ptr     screen_priv = present_screen_priv(screen);
+
+    if (!screen_priv)
+        return NULL;
+
+    if (!screen_priv->flip_pending)
+        return NULL;
+        
+    return screen_priv->flip_pending->pixmap;
+}
+
 static Bool
 present_check_flip(RRCrtcPtr    crtc,
                    WindowPtr    window,
@@ -88,6 +105,7 @@ present_check_flip(RRCrtcPtr    crtc,
                    int16_t      y_off)
 {
     ScreenPtr                   screen = window->drawable.pScreen;
+    PixmapPtr                   window_pixmap;
     WindowPtr                   root = screen->root;
     present_screen_priv_ptr     screen_priv = present_screen_priv(screen);
 
@@ -104,19 +122,11 @@ present_check_flip(RRCrtcPtr    crtc,
     if (!screen_priv->info->flip)
         return FALSE;
 
-    /* Can't pend a flip while unflipping */
-    if (screen_priv->unflip_event_id) {
-        return FALSE;
-    }
-
-    /* Can't have two pending flips at the same time */
-    if (screen_priv->flip_pending) {
-        return FALSE;
-    }
-
     /* Make sure the window hasn't been redirected with Composite */
-    if (screen->GetWindowPixmap(window) != screen->GetScreenPixmap(screen) &&
-        screen->GetWindowPixmap(window) != screen_priv->flip_pixmap)
+    window_pixmap = screen->GetWindowPixmap(window);
+    if (window_pixmap != screen->GetScreenPixmap(screen) &&
+        window_pixmap != screen_priv->flip_pixmap &&
+        window_pixmap != present_flip_pending_pixmap(screen))
         return FALSE;
 
     /* Check for full-screen window */
@@ -147,6 +157,7 @@ present_check_flip(RRCrtcPtr    crtc,
     /* Ask the driver for permission */
     if (screen_priv->info->check_flip) {
         if (!(*screen_priv->info->check_flip) (crtc, window, pixmap, sync_flip)) {
+            DebugPresent(("\td %08lx -> %08lx\n", window->drawable.id, pixmap ? pixmap->drawable.id : 0));
             return FALSE;
         }
     }
@@ -188,8 +199,10 @@ present_pixmap_idle(PixmapPtr pixmap, WindowPtr window, CARD32 serial, struct pr
 {
     if (present_fence)
         present_fence_set_triggered(present_fence);
-    if (window)
+    if (window) {
+        DebugPresent(("\ti %08lx\n", pixmap ? pixmap->drawable.id : 0));
         present_send_idle_notify(window, serial, pixmap, present_fence);
+    }
 }
 
 RRCrtcPtr
@@ -227,9 +240,8 @@ present_query_capabilities(RRCrtcPtr crtc)
 }
 
 static int
-present_get_ust_msc(WindowPtr window, RRCrtcPtr crtc, uint64_t *ust, uint64_t *msc)
+present_get_ust_msc(ScreenPtr screen, RRCrtcPtr crtc, uint64_t *ust, uint64_t *msc)
 {
-    ScreenPtr                   screen = window->drawable.pScreen;
     present_screen_priv_ptr     screen_priv = present_screen_priv(screen);
 
     if (crtc == NULL)
@@ -283,7 +295,7 @@ present_window_to_crtc_msc(WindowPtr window, RRCrtcPtr crtc, uint64_t window_msc
          * we'll just use whatever previous MSC we'd seen from this CRTC
          */
 
-        if (present_get_ust_msc(window, window_priv->crtc, &old_ust, &old_msc) != Success)
+        if (present_get_ust_msc(window->drawable.pScreen, window_priv->crtc, &old_ust, &old_msc) != Success)
             old_msc = window_priv->msc;
 
         window_priv->msc_offset += new_msc - old_msc;
@@ -293,6 +305,34 @@ present_window_to_crtc_msc(WindowPtr window, RRCrtcPtr crtc, uint64_t window_msc
     return window_msc + window_priv->msc_offset;
 }
 
+/*
+ * When the wait fence or previous flip is completed, it's time
+ * to re-try the request
+ */
+static void
+present_re_execute(present_vblank_ptr vblank)
+{
+    uint64_t            ust = 0, crtc_msc = 0;
+
+    if (vblank->crtc)
+        (void) present_get_ust_msc(vblank->screen, vblank->crtc, &ust, &crtc_msc);
+
+    present_execute(vblank, ust, crtc_msc);
+}
+
+static void
+present_flip_try_ready(ScreenPtr screen)
+{
+    present_vblank_ptr  vblank, tmp;
+
+    xorg_list_for_each_entry_safe(vblank, tmp, &present_exec_queue, event_queue) {
+        if (vblank->flip_ready) {
+            present_re_execute(vblank);
+            return;
+        }
+    }
+}
+
 static void
 present_flip_idle(ScreenPtr screen)
 {
@@ -369,16 +409,14 @@ present_unflip(ScreenPtr screen)
 }
 
 static void
-present_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc);
-
-static void
 present_flip_notify(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc)
 {
     ScreenPtr                   screen = vblank->screen;
     present_screen_priv_ptr     screen_priv = present_screen_priv(screen);
 
-    DebugPresent(("\tn %p %8lld: %08lx -> %08lx\n", vblank, vblank->target_msc,
-           vblank->pixmap ? vblank->pixmap->drawable.id : 0,
+    DebugPresent(("\tn %lld %p %8lld: %08lx -> %08lx\n",
+                  vblank->event_id, vblank, vblank->target_msc,
+                  vblank->pixmap ? vblank->pixmap->drawable.id : 0,
                   vblank->window->drawable.id));
 
     assert (vblank == screen_priv->flip_pending);
@@ -404,6 +442,8 @@ present_flip_notify(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc)
 
     present_vblank_notify(vblank, PresentCompleteKindPixmap, PresentCompleteModeFlip, ust, crtc_msc);
     present_vblank_destroy(vblank);
+
+    present_flip_try_ready(screen);
 }
 
 void
@@ -436,6 +476,7 @@ present_event_notify(uint64_t event_id, uint64_t ust, uint64_t msc)
             DebugPresent(("\tun %lld\n", event_id));
             screen_priv->unflip_event_id = 0;
             present_flip_idle(screen);
+            present_flip_try_ready(screen);
             return;
         }
     }
@@ -498,15 +539,7 @@ static void
 present_wait_fence_triggered(void *param)
 {
     present_vblank_ptr  vblank = param;
-    WindowPtr           window = vblank->window;
-    uint64_t            ust = 0, crtc_msc = 0;
-
-    if (window) {
-        present_window_priv_ptr     window_priv = present_get_window_priv(window, TRUE);
-        if (window_priv)
-            (void) present_get_ust_msc(window, window_priv->crtc, &ust, &crtc_msc);
-    }
-    present_execute(vblank, ust, crtc_msc);
+    present_re_execute(vblank);
 }
 
 /*
@@ -534,14 +567,27 @@ present_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc)
         }
     }
 
+    if (vblank->flip && vblank->pixmap && vblank->window) {
+        if (screen_priv->flip_pending || screen_priv->unflip_event_id) {
+            DebugPresent(("\tr %lld %p (pending %p unflip %lld)\n",
+                          vblank->event_id, vblank,
+                          screen_priv->flip_pending, screen_priv->unflip_event_id));
+            vblank->flip_ready = TRUE;
+            return;
+        }
+    }
+
     xorg_list_del(&vblank->event_queue);
     vblank->queued = FALSE;
 
     if (vblank->pixmap && vblank->window) {
 
-        if (vblank->flip && screen_priv->flip_pending == NULL && !screen_priv->unflip_event_id) {
+        if (vblank->flip) {
+
+            DebugPresent(("\tf %lld %p %8lld: %08lx -> %08lx\n",
+                          vblank->event_id, vblank, crtc_msc,
+                          vblank->pixmap->drawable.id, vblank->window->drawable.id));
 
-            DebugPresent(("\tf %p %8lld: %08lx -> %08lx\n", vblank, crtc_msc, vblank->pixmap->drawable.id, vblank->window->drawable.id));
             /* Prepare to flip by placing it in the flip queue and
              * and sticking it into the flip_pending field
              */
@@ -644,7 +690,7 @@ present_pixmap(WindowPtr window,
     uint64_t                    target_msc;
     uint64_t                    crtc_msc;
     int                         ret;
-    present_vblank_ptr          vblank;
+    present_vblank_ptr          vblank, tmp;
     ScreenPtr                   screen = window->drawable.pScreen;
     present_window_priv_ptr     window_priv = present_get_window_priv(window, TRUE);
     present_screen_priv_ptr     screen_priv = present_screen_priv(screen);
@@ -664,7 +710,7 @@ present_pixmap(WindowPtr window,
             target_crtc = present_get_crtc(window);
     }
 
-    present_get_ust_msc(window, target_crtc, &ust, &crtc_msc);
+    present_get_ust_msc(screen, target_crtc, &ust, &crtc_msc);
 
     target_msc = present_window_to_crtc_msc(window, target_crtc, window_msc, crtc_msc);
 
@@ -698,7 +744,7 @@ present_pixmap(WindowPtr window,
      */
 
     if (!update) {
-        xorg_list_for_each_entry(vblank, &window_priv->vblank, window_list) {
+        xorg_list_for_each_entry_safe(vblank, tmp, &window_priv->vblank, window_list) {
 
             if (!vblank->pixmap)
                 continue;
@@ -706,11 +752,11 @@ present_pixmap(WindowPtr window,
             if (!vblank->queued)
                 continue;
 
-            if (vblank->crtc != target_crtc || vblank->target_msc != target_msc)
+            if (vblank->crtc != target_crtc || vblank->target_msc > target_msc)
                 continue;
 
             DebugPresent(("\tx %lld %p %8lld: %08lx -> %08lx (crtc %p)\n",
-                          vblank->event_id, vblank, target_msc,
+                          vblank->event_id, vblank, vblank->target_msc,
                           vblank->pixmap->drawable.id, vblank->window->drawable.id,
                           vblank->crtc));
 
@@ -720,6 +766,9 @@ present_pixmap(WindowPtr window,
 
             vblank->pixmap = NULL;
             vblank->idle_fence = NULL;
+            vblank->flip = FALSE;
+            if (vblank->flip_ready)
+                present_re_execute(vblank);
         }
     }
 
@@ -875,7 +924,8 @@ present_vblank_destroy(present_vblank_ptr vblank)
     /* Remove vblank from window and screen lists */
     xorg_list_del(&vblank->window_list);
 
-    DebugPresent(("\td %p %8lld: %08lx -> %08lx\n", vblank, vblank->target_msc,
+    DebugPresent(("\td %lld %p %8lld: %08lx -> %08lx\n",
+                  vblank->event_id, vblank, vblank->target_msc,
                   vblank->pixmap ? vblank->pixmap->drawable.id : 0,
                   vblank->window->drawable.id));
 
diff --git a/present/present_priv.h b/present/present_priv.h
index 8d3e007..d8569a2 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -71,6 +71,7 @@ struct present_vblank {
     int                 num_notifies;
     Bool                queued;         /* on present_exec_queue */
     Bool                flip;           /* planning on using flip */
+    Bool                flip_ready;     /* wants to flip, but waiting for previous flip or unflip */
     Bool                sync_flip;      /* do flip synchronous to vblank */
     Bool                abort_flip;     /* aborting this flip */
 };
commit 2f5cf9ff9a0f713b7e038636484c77f113a5f10a
Author: Frank Binns <frank.binns at imgtec.com>
Date:   Thu Apr 24 11:37:48 2014 +0100

    xfixes: disable cursor on X server reset
    
    The initial state of the cursor is set to disabled but this was
    never be re-disabled during X server reset. This meant any
    application run after an X server reset would have the cursor
    displayed even if it hadn't requested this to be the case.
    
    Signed-off-by: Frank Binns <frank.binns at imgtec.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/xfixes/cursor.c b/xfixes/cursor.c
index 2c4b57c..31a408f 100644
--- a/xfixes/cursor.c
+++ b/xfixes/cursor.c
@@ -1056,6 +1056,8 @@ XFixesCursorInit(void)
 
     if (party_like_its_1989)
         CursorVisible = EnableCursor;
+    else
+        CursorVisible = FALSE;
 
     if (!dixRegisterPrivateKey(&CursorScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
         return FALSE;
commit b92d86a982504af2605042c19ef796d135074ee1
Author: Brendan King <brendan.king at imgtec.com>
Date:   Thu Apr 24 11:37:47 2014 +0100

    dix: fix pixmap leak on server reset
    
    The server is leaking a pixmap (created by CreateDefaultStipple()) on
    reset. The leak is caused by some X Server graphics contexts not being
    freed on reset by the machine independent cursor code in the server,
    which in turn is caused by the cursor cleanup code
    (miSpriteDeviceCursorCleanup()) not being called.
    
    Ensures the DeviceCursorCleanup() function is called when the associated
    input device is closed on server reset.
    
    Signed-off-by: Frank Binns <frank.binns at imgtec.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/dix/devices.c b/dix/devices.c
index 73f60f4..7f079ff 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -946,8 +946,9 @@ CloseDevice(DeviceIntPtr dev)
     if (dev->inited)
         (void) (*dev->deviceProc) (dev, DEVICE_CLOSE);
 
-    /* free sprite memory */
-    if (IsMaster(dev) && dev->spriteInfo->sprite)
+    FreeSprite(dev);
+
+    if (IsMaster(dev))
         screen->DeviceCursorCleanup(dev, screen);
 
     /* free acceleration info */
@@ -968,8 +969,6 @@ CloseDevice(DeviceIntPtr dev)
         free(classes);
     }
 
-    FreeSprite(dev);
-
     /* a client may have the device set as client pointer */
     for (j = 0; j < currentMaxClients; j++) {
         if (clients[j] && clients[j]->clientPtr == dev) {
commit a99c061aafd4aaa5728c776dca7d0a1789ac739a
Author: Brendan King <brendan.king at imgtec.com>
Date:   Thu Apr 24 11:37:46 2014 +0100

    dix: reference the cursor just once in InitializeSprite()
    
    The new current cursor was being referenced twice, resulting in a
    memory leak when the current server generation ended.
    
    Signed-off-by: Frank Binns <frank.binns at imgtec.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/dix/events.c b/dix/events.c
index 7e7a1c9..b8c67fd 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -3237,7 +3237,7 @@ InitializeSprite(DeviceIntPtr pDev, WindowPtr pWin)
     pCursor = RefCursor(pCursor);
     if (pSprite->current)
         FreeCursor(pSprite->current, None);
-    pSprite->current = RefCursor(pCursor);
+    pSprite->current = pCursor;
 
     if (pScreen) {
         (*pScreen->RealizeCursor) (pDev, pScreen, pSprite->current);
commit 444a1f7a8802999e27ecf5f6eb598df2206f7277
Author: Brendan King <brendan.king at imgtec.com>
Date:   Thu Apr 24 11:37:45 2014 +0100

    fb: fix screen pixmap leak on server reset
    
    Call FreePixmap() instead of free() to destroy the screen pixmap in
    fbCloseScreen().
    
    Signed-off-by: Frank Binns <frank.binns at imgtec.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/fb/fbscreen.c b/fb/fbscreen.c
index b2b9739..1f91089 100644
--- a/fb/fbscreen.c
+++ b/fb/fbscreen.c
@@ -37,7 +37,7 @@ fbCloseScreen(ScreenPtr pScreen)
         free(depths[d].vids);
     free(depths);
     free(pScreen->visuals);
-    free(pScreen->devPrivate);
+    FreePixmap((PixmapPtr)pScreen->devPrivate);
     return TRUE;
 }
 
commit 7ca458493aa2f0aa091c989ea0768611e0730bf5
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed May 28 08:14:00 2014 +0100

    xfree86: Report Present as a built-in module
    
    This is so that drivers can do a runtime check that Present is available,
    similar to existing runtime checks performed by the drivers for DRI.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c
index f92ad8d..e1f649a 100644
--- a/hw/xfree86/loader/loadmod.c
+++ b/hw/xfree86/loader/loadmod.c
@@ -841,6 +841,9 @@ static const char *compiled_in_modules[] = {
 #if DRI3
     "dri3",
 #endif
+#if PRESENT
+    "present",
+#endif
     NULL
 };
 
commit 746be5a03ebbda4ab411ca3efb2ed95f99e9ea46
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed May 28 08:13:59 2014 +0100

    xfree86: Report DRI3 as a built-in module
    
    This is so that drivers can do a runtime check that DRI3 is available,
    similar to existing runtime checks performed by the drivers for DRI and
    DRI2.
    
    v2: Only add DRI3 to the list if the module was actually built into the
    server (Mark Kettenis).
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
    Cc: Mark Kettenis <mark.kettenis at xs4all.nl>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c
index 092bf57..f92ad8d 100644
--- a/hw/xfree86/loader/loadmod.c
+++ b/hw/xfree86/loader/loadmod.c
@@ -838,6 +838,9 @@ static const char *compiled_in_modules[] = {
     "extmod",
     "dri",
     "dri2",
+#if DRI3
+    "dri3",
+#endif
     NULL
 };
 
commit b5526141f78df15bc5df2497bc4b4a17f1a6368d
Merge: dc8d068 a205ec3
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Jun 2 13:08:23 2014 -0700

    Merge remote-tracking branch 'jturney/master'

commit dc8d0688471695ec5a8db5fef93fbcfc064891d5
Author: Max Filippov <jcmvbkbc at gmail.com>
Date:   Mon Jun 2 01:17:31 2014 +0400

    xtensa: add support for xtensa architecture
    
    Signed-off-by: Max Filippov <jcmvbkbc at gmail.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/common/compiler.h b/hw/xfree86/common/compiler.h
index 0319de0..1bd8def 100644
--- a/hw/xfree86/common/compiler.h
+++ b/hw/xfree86/common/compiler.h
@@ -1352,7 +1352,10 @@ stl_u(unsigned long val, unsigned int *p)
 #else                           /* ix86 */
 
 #if !defined(__SUNPRO_C)
-#if !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__s390__) && !defined(__m32r__) && !defined(__aarch64__) && !defined(__arc__)
+#if !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && \
+    !defined(__sh__) && !defined(__hppa__) && !defined(__s390__) && \
+    !defined(__m32r__) && !defined(__aarch64__) && !defined(__arc__) && \
+    !defined(__xtensa__)
 #ifdef GCCUSESGAS
 
 /*
diff --git a/hw/xfree86/os-support/linux/lnx_video.c b/hw/xfree86/os-support/linux/lnx_video.c
index 40765fc..652f963 100644
--- a/hw/xfree86/os-support/linux/lnx_video.c
+++ b/hw/xfree86/os-support/linux/lnx_video.c
@@ -60,7 +60,8 @@ static Bool ExtendedEnabled = FALSE;
       !defined(__nds32__) && \
       !defined(__arm__) && \
       !defined(__aarch64__) && \
-      !defined(__arc__)
+      !defined(__arc__) && \
+      !defined(__xtensa__)
 
 /*
  * Due to conflicts with "compiler.h", don't rely on <sys/io.h> to declare
diff --git a/include/servermd.h b/include/servermd.h
index 2d1ccb1..081123b 100644
--- a/include/servermd.h
+++ b/include/servermd.h
@@ -313,6 +313,20 @@ SOFTWARE.
 
 #endif                          /* ARC */
 
+#ifdef __xtensa__
+
+#ifdef __XTENSA_EL__
+#define IMAGE_BYTE_ORDER        LSBFirst
+#define BITMAP_BIT_ORDER        LSBFirst
+#endif
+#ifdef __XTENSA_EB__
+#define IMAGE_BYTE_ORDER        MSBFirst
+#define BITMAP_BIT_ORDER        MSBFirst
+#endif
+#define GLYPHPADBYTES           4
+
+#endif                          /* __xtensa__ */
+
 /* size of buffer to use with GetImage, measured in bytes. There's obviously
  * a trade-off between the amount of heap used and the number of times the
  * ddx routine has to be called.
commit a6ffdc69c4ac45bc39924159c7fab5f02f720f1f
Merge: 63c48de 1c10b37
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Jun 2 11:30:24 2014 -0700

    Merge remote-tracking branch 'jeremyhu/master'

commit 63c48de63becdee680e90cb2363984c2f8f77fd1
Author: Søren Sandmann <soren.sandmann at gmail.com>
Date:   Fri May 30 16:50:35 2014 -0400

    xfree86: Add "modesetting" to list of fallback drivers
    
    To make X -configure work properly, the output of fixup_video_driver_list()
    should be in order of preference. Otherwise, the config file may use
    the incorrect driver for some devices.
    
    In particular, the drivers that work for all (or many) devices need to be
    last in the list. Since the modesetting driver works for many devices,
    it needs to be considered a fallback driver.
    
    Signed-off-by: Søren Sandmann <ssp at redhat.com>
    Acked-by: Daniel Stone <daniels at collabora.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 2adef44..481674d 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -519,7 +519,7 @@ xf86InputDriverlistFromConfig(void)
 static void
 fixup_video_driver_list(const char **drivers)
 {
-    static const char *fallback[4] = { "fbdev", "vesa", "wsfb", NULL };
+    static const char *fallback[5] = { "modesetting", "fbdev", "vesa", "wsfb", NULL };
     const char **end, **drv;
     const char *x;
     int i;
commit ab47ec9636b21a7f542d2e8612834915e7c8cc64
Merge: 0df871c cfaf2ab
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Jun 2 11:22:48 2014 -0700

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

commit 0df871cf34ee5f1a85586206027de9b02fb364ec
Author: Robert Ancell <robert.ancell at canonical.com>
Date:   Thu May 22 10:43:52 2014 +1200

    Fix overflow checking extension versions
    
    The easiest way to check for the version of an extension is to send the maximum
    possible version numbers in the QueryVersion request. The X server overflows on
    these as it assumes you will send a reasonable version number.
    
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/include/misc.h b/include/misc.h
index 17de710..9c2f573 100644
--- a/include/misc.h
+++ b/include/misc.h
@@ -259,15 +259,19 @@ extern void FormatDouble(double dbl, char *string);
  * or a value greater than 0
  */
 static inline int
-version_compare(uint16_t a_major, uint16_t a_minor,
-                uint16_t b_major, uint16_t b_minor)
+version_compare(uint32_t a_major, uint32_t a_minor,
+                uint32_t b_major, uint32_t b_minor)
 {
-    int a, b;
+    if (a_major > b_major)
+        return 1;
+    if (a_major < b_major)
+        return -1;
+    if (a_minor > b_minor)
+        return 1;
+    if (a_minor < b_minor)
+        return -1;
 
-    a = a_major << 16 | a_minor;
-    b = b_major << 16 | b_minor;
-
-    return (a - b);
+    return 0;
 }
 
 /* some macros to help swap requests, replies, and events */
commit 4cbd3fabaa41e89579530bceb01b9239fa2afdb7
Author: Adam Jackson <ajax at redhat.com>
Date:   Wed May 21 09:22:49 2014 -0400

    configure: Require sufficiently new wayland-client for xwayland ddx
    
    The explicit release requests were added in 1.3.0, don't try to build
    against older.
    
    Signed-off-by: Adam Jackson <ajax at redhat.com>
    Reviewed-by: Jasper St. Pierre <jstpierre at mecheye.net>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/configure.ac b/configure.ac
index e5387bf..e3d991d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2442,7 +2442,7 @@ AM_CONDITIONAL(XFAKESERVER, [test "x$KDRIVE" = xyes && test "x$XFAKE" = xyes])
 
 dnl Xwayland DDX
 
-PKG_CHECK_MODULES(XWAYLANDMODULES, [wayland-client libdrm epoxy], [have_xwayland=yes], [have_xwayland=no])
+PKG_CHECK_MODULES(XWAYLANDMODULES, [wayland-client >= 1.3.0 libdrm epoxy], [have_xwayland=yes], [have_xwayland=no])
 AC_MSG_CHECKING([whether to build Xwayland DDX])
 if test "x$XWAYLAND" = xauto; then
    XWAYLAND="$have_xwayland"
commit a205ec3ab77c6765d44f77c526a832345fef77b0
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Sat Apr 5 15:15:46 2014 +0100

    configure: Restore DEFAULT_LOGDIR to xwin-config.h, it is used
    
    Commit f37a46913489397d8628ffe578c8d4ed50b6ca72 removed this from
    xwin-config.h.in for some reason, but it is used.
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/include/xwin-config.h.in b/include/xwin-config.h.in
index a5e6b17..176c019 100644
--- a/include/xwin-config.h.in
+++ b/include/xwin-config.h.in
@@ -26,5 +26,8 @@
 /* Vendor web address for support */
 #undef __VENDORDWEBSUPPORT__
 
+/* Default log location */
+#undef DEFAULT_LOGDIR
+
 /* Whether we should re-locate the root to where the executable lives */
 #undef RELOCATE_PROJECTROOT
commit aaaa41345674a1c76a70836394cb5e57f82e9a26
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Sun Apr 27 20:55:51 2014 +0100

    hw/xwin: Update for __glXLastContext -> lastGLContext
    
    Update for __glXLastContext -> lastGLContext.
    
    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/glx/indirect.c b/hw/xwin/glx/indirect.c
index 6906114..9bfaac0 100644
--- a/hw/xwin/glx/indirect.c
+++ b/hw/xwin/glx/indirect.c
@@ -929,17 +929,6 @@ glxWinDrawableDestroy(__GLXdrawable * base)
 {
     __GLXWinDrawable *glxPriv = (__GLXWinDrawable *) base;
 
-    if (glxPriv->drawContext &&
-        (__glXLastContext == &((glxPriv->drawContext)->base))) {
-        // if this context is current and has unflushed commands, say we have flushed them
-        // (don't actually flush them, the window is going away anyhow, and an implict flush occurs
-        // on the next context change)
-        // (GLX core considers it an error when we try to select a new current context if the old one
-        // has unflushed commands, but the window has disappeared..)
-        __glXLastContext->hasUnflushedCommands = FALSE;
-        __glXLastContext = NULL;
-    }
-
     if (glxPriv->hPbuffer)
         if (!wglDestroyPbufferARBWrapper(glxPriv->hPbuffer)) {
             ErrorF("wglDestroyPbufferARB failed: %s\n", glxWinErrorMessage());
@@ -1542,7 +1531,7 @@ glxWinContextLoseCurrent(__GLXcontext * base)
        An error seems to be reported if we try to make no context current
        if there is already no current context, so avoid doing that...
      */
-    if (__glXLastContext != NULL) {
+    if (wglGetCurrentContext() != NULL) {
         ret = wglMakeCurrent(NULL, NULL);       /* We don't need a DC when setting no current context */
         if (!ret)
             ErrorF("glxWinContextLoseCurrent error: %s\n",
commit 1c10b37380d228b35db8a8616a6312ac54f5e59b
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Sat May 31 17:45:02 2014 -0700

    XQuartz: Update logic to account for title bar on every display in Mavericks
    
    <rdar://problem/14205847>
    http://xquartz.macosforge.org/trac/ticket/832
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>

diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c
index e376019..7aa1ae1 100644
--- a/hw/xquartz/xpr/xprScreen.c
+++ b/hw/xquartz/xpr/xprScreen.c
@@ -54,6 +54,11 @@
 #include "damage.h"
 #endif
 
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1090
+// From NSApplication.h
+extern const double NSAppKitVersionNumber;
+#endif
+
 /* 10.4's deferred update makes X slower.. have to live with the tearing
  * for now.. */
 #define XP_NO_DEFERRED_UPDATES 8
@@ -164,9 +169,14 @@ displayScreenBounds(CGDirectDisplayID id)
               (int)frame.size.width, (int)frame.size.height,
               (int)frame.origin.x, (int)frame.origin.y);
 
-    /* Remove menubar to help standard X11 window managers. */
-    if (XQuartzIsRootless &&
-        frame.origin.x == 0 && frame.origin.y == 0) {
+    /* Remove menubar to help standard X11 window managers.
+     * On Mavericks and later, the menu bar is on all displays.
+     */
+    if (XQuartzIsRootless
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1090
+        && (NSAppKitVersionNumber >= 1265 || (frame.origin.x == 0 && frame.origin.y == 0))
+#endif
+        ) {
         frame.origin.y += aquaMenuBarHeight;
         frame.size.height -= aquaMenuBarHeight;
     }
commit ad0ff649c68b18c4b95b078c2d1d1e7de71a7c6f
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Sat May 31 17:22:51 2014 -0700

    XQuartz: Dead code removal (ENABLE_DEBUG_LOG)
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>

diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index e0983d6..29c6438 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -704,22 +704,6 @@ OsVendorInit(void)
         free(lf);
 
         DarwinPrintBanner();
-#ifdef ENABLE_DEBUG_LOG
-        {
-            char *home_dir = NULL, *log_file_path = NULL;
-            home_dir = getenv("HOME");
-            if (home_dir) asprintf(&log_file_path, "%s/%s", home_dir,
-                                   DEBUG_LOG_NAME);
-            if (log_file_path) {
-                if (!access(log_file_path, F_OK)) {
-                    debug_log_fp = fopen(log_file_path, "a");
-                    if (debug_log_fp) ErrorF("Debug logging enabled to %s\n",
-                                             log_file_path);
-                }
-                free(log_file_path);
-            }
-        }
-#endif
     }
 }
 
commit e281288d5afedb154f52c31f70a350a013ecfb06
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Sat May 31 13:04:43 2014 -0700

    XQuartz: Bump to 2.7.7
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>

diff --git a/hw/xquartz/bundle/Info.plist.cpp b/hw/xquartz/bundle/Info.plist.cpp
index 5fbb0ad..a0d9050 100644
--- a/hw/xquartz/bundle/Info.plist.cpp
+++ b/hw/xquartz/bundle/Info.plist.cpp
@@ -19,9 +19,9 @@
 	<key>CFBundlePackageType</key>
 		<string>APPL</string>
 	<key>CFBundleShortVersionString</key>
-		<string>2.7.6</string>
+		<string>2.7.7</string>
 	<key>CFBundleVersion</key>
-		<string>2.7.6</string>
+		<string>2.7.7</string>
 	<key>CFBundleSignature</key>
 		<string>x11a</string>
 	<key>CSResourcesFileMapped</key>
commit cfaf2abbac3f01e57d00845d8908bf01559263f9
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Sat May 24 20:05:53 2014 +1000

    man: drop specific mention of DontZap in -retro (#71113)
    
    DontZap off is the default anyway, don't mention it specifically to avoid
    confusion
    
    X.Org Bug 71113 <http://bugs.freedesktop.org/show_bug.cgi?id=71113>
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/man/Xserver.man b/man/Xserver.man
index b103551..7a74e85 100644
--- a/man/Xserver.man
+++ b/man/Xserver.man
@@ -223,9 +223,8 @@ turns on auto-repeat.
 .B -retro
 starts the stipple with the classic stipple and cursor visible.  The default
 is to start with a black root window, and to suppress display of the cursor
-until the first time an application calls XDefineCursor().  For the Xorg
-server, this also sets the default for the DontZap option to FALSE.  For
-kdrive servers, this implies -zap.
+until the first time an application calls XDefineCursor(). For kdrive
+servers, this implies -zap.
 .TP 8
 .B \-s \fIminutes\fP
 sets screen-saver timeout time in minutes.
commit e48a132b6d187f355abd7021be47edde972e7091
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Sat May 24 20:02:56 2014 +1000

    xfree86: fix wrong DontZap documentation (#71113)
    
    X.Org Bug 71113 <http://bugs.freedesktop.org/show_bug.cgi?id=71113>
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/xfree86/xorgconf.cpp b/hw/xfree86/xorgconf.cpp
index cd6d4a9..a903438 100644
--- a/hw/xfree86/xorgconf.cpp
+++ b/hw/xfree86/xorgconf.cpp
@@ -97,7 +97,7 @@ Section "ServerFlags"
 # Uncomment this to disable the <Ctrl><Alt><BS> server abort sequence
 # This allows clients to receive this key event.
 
-#    Option	"DontZap"	"false"
+#    Option	"DontZap"	"true"
 
 # Uncomment this to disable the <Ctrl><Alt><KP_+>/<KP_-> mode switching
 # sequences.  This allows clients to receive these key events.
commit 548fc937b22d4dfe7f96e0bd77522261603a2c2f
Author: Robert Ancell <robert.ancell at canonical.com>
Date:   Thu May 22 10:43:52 2014 +1200

    Fix overflow checking extension versions
    
    The easiest way to check for the version of an extension is to send the maximum
    possible version numbers in the QueryVersion request. The X server overflows on
    these as it assumes you will send a reasonable version number.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/include/misc.h b/include/misc.h
index 17de710..9c2f573 100644
--- a/include/misc.h
+++ b/include/misc.h
@@ -259,15 +259,19 @@ extern void FormatDouble(double dbl, char *string);
  * or a value greater than 0
  */
 static inline int
-version_compare(uint16_t a_major, uint16_t a_minor,
-                uint16_t b_major, uint16_t b_minor)
+version_compare(uint32_t a_major, uint32_t a_minor,
+                uint32_t b_major, uint32_t b_minor)
 {
-    int a, b;
+    if (a_major > b_major)
+        return 1;
+    if (a_major < b_major)
+        return -1;
+    if (a_minor > b_minor)
+        return 1;
+    if (a_minor < b_minor)
+        return -1;
 
-    a = a_major << 16 | a_minor;
-    b = b_major << 16 | b_minor;
-
-    return (a - b);
+    return 0;
 }
 
 /* some macros to help swap requests, replies, and events */
commit d7a2df0a7499864cb005b098b79c1bdf884f6600
Author: Steven McDonald <steven at steven-mcdonald.id.au>
Date:   Sun May 18 13:42:08 2014 +0200

    Xi: block SIGIOs while copying device classes around
    
    I've been seeing sporadic (anywhere from once every few days to 3-4
    times a day) crashes and freezes in X. The problematic behaviour isn't
    always the same, but I chose a particular incident to debug, and found
    that X was segfaulting in updateMotionHistory, on line 575 of
    dix/getevents.c.
    
    After some further investigation, I found that the bug was being
    triggered when a SIGIO was received in DeepCopyPointerClasses, between
    the AllocValuatorClass call (line 540) and updating the to->valuator
    pointer (line 545). AllocValuatorClass calls realloc() on to->valuator,
    so between these lines, it's not guaranteed to point to allocated
    memory.
    
    It seems the SIGIO handler is calling updateMotionHistory, which is
    reading the memory pointed to by to->valuator and getting a wrong value
    for last_motion, which updates buff to point to wildly the wrong place
    and thus generates a segfault when a memcpy() is done into buff.
    
    I am attaching a patch which I've been running on that machine for the
    past three days, and haven't yet observed any more crashing or freezing
    behaviour. The patch simply calls OsBlockSIGIO while
    DeepCopyDeviceClasses is in progress, as the state of the X server's
    device data structures is not guaranteed to be in a consistent state
    during that time.
    
    Debian bug#744303 <https://bugs.debian.org/744303>
    
    Signed-off-by: Julien Cristau <jcristau at debian.org>
    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/exevents.c b/Xi/exevents.c
index 02530bd..b0bc47e 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -661,6 +661,8 @@ void
 DeepCopyDeviceClasses(DeviceIntPtr from, DeviceIntPtr to,
                       DeviceChangedEvent *dce)
 {
+    OsBlockSIGIO();
+
     /* generic feedback classes, not tied to pointer and/or keyboard */
     DeepCopyFeedbackClasses(from, to);
 
@@ -668,6 +670,8 @@ DeepCopyDeviceClasses(DeviceIntPtr from, DeviceIntPtr to,
         DeepCopyKeyboardClasses(from, to);
     if ((dce->flags & DEVCHANGE_POINTER_EVENT))
         DeepCopyPointerClasses(from, to);
+
+    OsReleaseSIGIO();
 }
 
 /**
commit d3a3ee7a0e5cbd3fcaba77d2d5664e1524eda11c
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu May 8 09:39:36 2014 +1000

    os: automatically switch to sigsafe logging when needed
    
    If we're smart enough to warn, we should be smart enough to just pass it
    through to the right function. Worst case we lose some formatting specifiers
    which pnprintf will complain about anyway. And in most cases it won't matter.
    
    This requires renaming pnprintf to vpnprintf and changing the size_t to int to
    be compatible with Xvscnprintf. pnprintf is internal only, the others are
    exported API so we can't change them as easily.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/os/log.c b/os/log.c
index a0f2a81..a368569 100644
--- a/os/log.c
+++ b/os/log.c
@@ -342,7 +342,7 @@ out:
  * which directives you use.
  */
 static int
-pnprintf(char *string, size_t size, const char *f, va_list args)
+vpnprintf(char *string, int size_in, const char *f, va_list args)
 {
     int f_idx = 0;
     int s_idx = 0;
@@ -353,6 +353,7 @@ pnprintf(char *string, size_t size, const char *f, va_list args)
     int i;
     uint64_t ui;
     int64_t si;
+    size_t size = size_in;
 
     for (; f_idx < f_len && s_idx < size - 1; f_idx++) {
         int length_modifier = 0;
@@ -484,6 +485,19 @@ pnprintf(char *string, size_t size, const char *f, va_list args)
     return s_idx;
 }
 
+static int
+pnprintf(char *string, int size, const char *f, ...)
+{
+    int rc;
+    va_list args;
+
+    va_start(args, f);
+    rc = vpnprintf(string, size, f, args);
+    va_end(args);
+
+    return rc;
+}
+
 /* This function does the actual log message writes. It must be signal safe.
  * When attempting to call non-signal-safe functions, guard them with a check
  * of the inSignalContext global variable. */
@@ -597,7 +611,6 @@ LogMessageTypeVerbString(MessageType type, int verb)
 void
 LogVMessageVerb(MessageType type, int verb, const char *format, va_list args)
 {
-    static unsigned int warned;
     const char *type_str;
     char buf[1024];
     const size_t size = sizeof(buf);
@@ -605,17 +618,8 @@ LogVMessageVerb(MessageType type, int verb, const char *format, va_list args)
     size_t len = 0;
 
     if (inSignalContext) {
-        if (warned < 3) {
-            BUG_WARN_MSG(inSignalContext,
-                         "Warning: attempting to log data in a signal unsafe "
-                         "manner while in signal context.\nPlease update to check "
-                         "inSignalContext and/or use LogMessageVerbSigSafe() or "
-                         "ErrorFSigSafe().\nThe offending log format message is:\n"
-                         "%s\n", format);
-            warned++;
-            if (warned == 3)
-                LogMessageVerbSigSafe(X_WARNING, -1, "Warned %u times about sigsafe logging. Will be quiet now.\n", warned);
-        }
+        LogVMessageVerbSigSafe(type, verb, format, args);
+        return;
     }
 
     type_str = LogMessageTypeVerbString(type, verb);
@@ -687,7 +691,7 @@ LogVMessageVerbSigSafe(MessageType type, int verb, const char *format, va_list a
         LogSWrite(verb, " ", 1, FALSE);
     }
 
-    len = pnprintf(buf, sizeof(buf), format, args);
+    len = vpnprintf(buf, sizeof(buf), format, args);
 
     /* Force '\n' at end of truncated line */
     if (sizeof(buf) - len == 1)
@@ -701,40 +705,37 @@ void
 LogVHdrMessageVerb(MessageType type, int verb, const char *msg_format,
                    va_list msg_args, const char *hdr_format, va_list hdr_args)
 {
-    static unsigned int warned;
     const char *type_str;
     char buf[1024];
     const size_t size = sizeof(buf);
     Bool newline;
     size_t len = 0;
-
-    if (inSignalContext) {
-        if (warned < 3) {
-            BUG_WARN_MSG(inSignalContext,
-                         "Warning: attempting to log data in a signal unsafe "
-                         "manner while in signal context.\nPlease update to check "
-                         "inSignalContext and/or use LogMessageVerbSigSafe().\nThe "
-                         "offending header and log message formats are:\n%s %s\n",
-                         hdr_format, msg_format);
-            warned++;
-            if (warned == 3)
-                LogMessageVerbSigSafe(X_WARNING, -1, "Warned %u times about sigsafe logging. Will be quiet now.\n", warned);
-        }
-    }
+    int (*vprintf_func)(char *, int, const char* _X_RESTRICT_KYWD f, va_list args)
+            _X_ATTRIBUTE_PRINTF(3, 0);
+    int (*printf_func)(char *, int, const char* _X_RESTRICT_KYWD f, ...)
+            _X_ATTRIBUTE_PRINTF(3, 4);
 
     type_str = LogMessageTypeVerbString(type, verb);
     if (!type_str)
         return;
 
+    if (inSignalContext) {
+        vprintf_func = vpnprintf;
+        printf_func = pnprintf;
+    } else {
+        vprintf_func = Xvscnprintf;
+        printf_func = Xscnprintf;
+    }
+
     /* if type_str is not "", prepend it and ' ', to message */
     if (type_str[0] != '\0')
-        len += Xscnprintf(&buf[len], size - len, "%s ", type_str);
+        len += printf_func(&buf[len], size - len, "%s ", type_str);
 
     if (hdr_format && size - len > 1)
-        len += Xvscnprintf(&buf[len], size - len, hdr_format, hdr_args);
+        len += vprintf_func(&buf[len], size - len, hdr_format, hdr_args);
 
     if (msg_format && size - len > 1)
-        len += Xvscnprintf(&buf[len], size - len, msg_format, msg_args);
+        len += vprintf_func(&buf[len], size - len, msg_format, msg_args);
 
     /* Force '\n' at end of truncated line */
     if (size - len == 1)
commit d5587cf3acb7ad6f81e1c095f1b88f8fb25ee953
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed May 14 10:32:30 2014 +1000

    config: revert quirk for the Evoluent Vertical Mouse
    
    This quick makes the mouse behaviour more obvious (LMR buttons generate LMR
    events) but goes against the manufacturer's intended defaults:
    
        Top button - left click.
        Wheel button - .middle click (e.g., for pan and rotate in CAD programs).
        Middle button - right click.
        Bottom button - back.
        Thumb button - forward.
    
    from http://www.evoluent.com/vm3.html
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/config/10-quirks.conf b/config/10-quirks.conf
index c9b823c..47907d8 100644
--- a/config/10-quirks.conf
+++ b/config/10-quirks.conf
@@ -19,22 +19,6 @@ Section "InputClass"
         Option "IgnoreRelativeAxes" "off"
 EndSection
 
-# https://bugzilla.redhat.com/show_bug.cgi?id=612140
-# please make Evoluent VerticalMouse 3 work out of the box
-# Button mapping on this mouse is quirky
-Section "InputClass"
-	Identifier "Evoluent VerticalMouse 3"
-        MatchProduct "Evoluent VerticalMouse 3"
-        # Sets following configuration:
-        # top button:    left
-        # middle button: middle
-        # bottom button: right
-        # wheel click:   middle
-        # thumb button:  8 (back)
-	Option "ButtonMapping" "1 2 2 4 5 6 7 3 8"
-EndSection
-
-
 # https://bugs.freedesktop.org/show_bug.cgi?id=55867
 # Bug 55867 - Doesn't know how to tag XI_TRACKBALL
 Section "InputClass"


More information about the Xquartz-changes mailing list