[Xquartz-changes] xserver: Branch 'server-1.10-apple' - 54 commits

Jeremy Huddleston jeremyhu at freedesktop.org
Thu Jan 13 16:10:29 PST 2011


Rebased ref, commits from common ancestor:
commit 149ff17795c18e1ec094d5aba4d1cf55a1546d4a
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sat Oct 30 14:55:06 2010 -0700

    configure.ac: Add -fno-strict-aliasing to CFLAGS
    
    This should address https://bugs.freedesktop.org/show_bug.cgi?id=31238
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/configure.ac b/configure.ac
index 1ceffe7..640248b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -80,6 +80,12 @@ XORG_PROG_RAWCPP
 # easier overrides at build time.
 XSERVER_CFLAGS='$(CWARNFLAGS)'
 
+dnl Explicitly add -fno-strict-aliasing since this option should disappear
+dnl from util-macros CWARNFLAGS
+if  test "x$GCC" = xyes ; then
+    XSERVER_CFLAGS="$XSERVER_CFLAGS -fno-strict-aliasing"
+fi
+
 dnl Check for dtrace program (needed to build Xserver dtrace probes)
 dnl Also checks for <sys/sdt.h>, since some Linux distros have an 
 dnl ISDN trace program named dtrace
commit 6362165a736b4ca77f085c80ac5b8bab0e28e56f
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 021a940..0b248e1 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -2079,11 +2079,8 @@ fbFillRegionSolid (DrawablePtr	pDrawable,
 		   FbBits	xor);
 
 extern _X_EXPORT pixman_image_t *
-image_from_pict (PicturePtr	pict,
-		 Bool		has_clip,
-		 int		*xoff,
-		 int		*yoff);
-
+image_from_pict (PicturePtr pict,
+		 Bool       has_clip);
 extern _X_EXPORT void free_pixman_pict (PicturePtr, pixman_image_t *);
 
 #endif /* _FB_H_ */
diff --git a/fb/fbpict.c b/fb/fbpict.c
index 7636040..af1920b 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -50,24 +50,19 @@ fbComposite (CARD8      op,
 	     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, xSrc - xDst, ySrc - yDst, width, height);
     if (pMask)
 	miCompositeSourceValidate (pMask, xMask - xDst, yMask - yDst, width, height);
     
-    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,
+				xSrc, ySrc, xMask, yMask, xDst, yDst,
 				width, height);
     }
 
@@ -146,22 +141,22 @@ create_conical_gradient_image (PictGradient *gradient)
 
 static pixman_image_t *
 create_bits_picture (PicturePtr pict,
-		     Bool       has_clip,
-		     int	*xoff,
-		     int	*yoff)
+		     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 (
 	pict->format,
-	pixmap->drawable.width, pixmap->drawable.height,
+	pict->pDrawable->width, pict->pDrawable->height,
 	(uint32_t *)bits, stride * sizeof (FbStride));
     
     
@@ -187,55 +182,33 @@ create_bits_picture (PicturePtr pict,
 	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);
+image_from_pict_internal (PicturePtr pict, Bool has_clip, 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, (pixman_transform_t *)pict->transform);
     }
     
     switch (pict->repeatType)
@@ -265,8 +238,7 @@ set_image_properties (pixman_image_t *image, PicturePtr pict, Bool has_clip, int
      */
     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);
+	pixman_image_t *alpha_map = image_from_pict_internal (pict->alphaMap, TRUE, TRUE);
 	
 	pixman_image_set_alpha_map (
 	    image, alpha_map, pict->alphaOrigin.x, pict->alphaOrigin.y);
@@ -299,7 +271,8 @@ set_image_properties (pixman_image_t *image, PicturePtr pict, Bool has_clip, int
 }
 
 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;
 
@@ -308,7 +281,7 @@ image_from_pict_internal (PicturePtr pict, Bool has_clip, int *xoff, int *yoff,
 
     if (pict->pDrawable)
     {
-	image = create_bits_picture (pict, has_clip, xoff, yoff);
+	image = create_bits_picture (pict, has_clip);
     }
     else if (pict->pSourcePict)
     {
@@ -329,19 +302,18 @@ 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 c309ceb..40cffd9 100644
--- a/fb/fbtrap.c
+++ b/fb/fbtrap.c
@@ -37,8 +37,7 @@ fbAddTraps (PicturePtr	pPicture,
 	    int		ntrap,
 	    xTrap	*traps)
 {
-    int image_xoff, image_yoff;
-    pixman_image_t *image = image_from_pict (pPicture, FALSE, &image_xoff, &image_yoff);
+    pixman_image_t *image = image_from_pict (pPicture, FALSE);
 
     if (!image)
 	return;
@@ -54,8 +53,7 @@ fbRasterizeTrapezoid (PicturePtr    pPicture,
 		      int	    x_off,
 		      int	    y_off)
 {
-    int	mask_xoff, mask_yoff;
-    pixman_image_t *image = image_from_pict (pPicture, FALSE, &mask_xoff, &mask_yoff);
+    pixman_image_t *image = image_from_pict (pPicture, FALSE);
 
     if (!image)
 	return;
commit d91cfe12592eb4b7a1e956a50c3ef3aace16abd5
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 94258b8..4f25c23 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -521,6 +521,7 @@ void RootlessSetPixmapOfAncestors(WindowPtr pWin);
 void RootlessStartDrawing(WindowPtr pWin);
 void RootlessDamageRegion(WindowPtr pWin, RegionPtr prgn);
 Bool IsFramedWindow(WindowPtr pWin);
+#include "../fb/fb.h"
 #endif 
 
 void
@@ -548,24 +549,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;
-
-    if(IsFramedWindow(pWin)) {
-        RootlessStartDrawing(pWin);
-        RootlessDamageRegion(pWin, prgn);
-    
-        if(pWin->backgroundState == ParentRelative) {
-            if((what == PW_BACKGROUND) || 
-               (what == PW_BORDER && !pWin->borderIsPixel))
-                RootlessSetPixmapOfAncestors(pWin);
-        }
-    }
 #endif
     
     if (what == PW_BACKGROUND)
     {
+#ifdef ROOTLESS
+	if(IsFramedWindow(pWin)) {
+	    RootlessStartDrawing(pWin);
+	    RootlessDamageRegion(pWin, prgn);
+
+	    if(pWin->backgroundState == ParentRelative) {
+		RootlessSetPixmapOfAncestors(pWin);
+	    }
+	}
+#endif
+
 	while (pWin->backgroundState == ParentRelative)
 	    pWin = pWin->parent;
 
@@ -587,6 +601,18 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
     {
 	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;
 	
@@ -595,6 +621,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;
@@ -657,6 +689,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 5afcf77a920823858d64baed2d47c92ded2fa735
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Thu Jan 13 16:08:46 2011 -0800

    XQuartz: Bump version string to 2.6.1
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/hw/xquartz/bundle/Info.plist.cpp b/hw/xquartz/bundle/Info.plist.cpp
index eb193bf..2e568ff 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.6.0</string>
+		<string>2.6.1</string>
 	<key>CFBundleVersion</key>
-		<string>2.6.0</string>
+		<string>2.6.1</string>
 	<key>CFBundleSignature</key>
 		<string>x11a</string>
 	<key>CSResourcesFileMapped</key>
commit 037e6ff2be328fed39eb74931e464b5804f602ad
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Thu Jan 13 16:08:29 2011 -0800

    XQuartz: Update copyright dates in bundle's plist
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/hw/xquartz/bundle/Info.plist.cpp b/hw/xquartz/bundle/Info.plist.cpp
index 85b439a..eb193bf 100644
--- a/hw/xquartz/bundle/Info.plist.cpp
+++ b/hw/xquartz/bundle/Info.plist.cpp
@@ -35,9 +35,9 @@
                 <string>http://xquartz.macosforge.org/downloads/sparkle/release.xml</string>
 #endif
 	<key>NSHumanReadableCopyright</key>
-		<string>© 2003-2010 Apple Inc.
+		<string>© 2003-2011 Apple Inc.
 © 2003 XFree86 Project, Inc.
-© 2003-2010 X.org Foundation, Inc.
+© 2003-2011 X.org Foundation, Inc.
 </string>
 	<key>NSMainNibFile</key>
 		<string>main</string>
commit 6358a60065eef167d4e5f4afd981ff26deeba80d
Author: Michel Dänzer <daenzer at vmware.com>
Date:   Thu Jan 6 09:55:41 2011 +0100

    EXA: Pad size of system memory copy for 1x1 pixmaps (bug #32803).
    
    Fixes https://bugs.freedesktop.org/show_bug.cgi?id=32803 .
    
    Signed-off-by: Michel Dänzer <daenzer at vmware.com>
    Reviewed-by: Dave Airlie <airlied at redhat.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/exa/exa_mixed.c b/exa/exa_mixed.c
index ef20eb5..606f1e1 100644
--- a/exa/exa_mixed.c
+++ b/exa/exa_mixed.c
@@ -98,7 +98,7 @@ exaCreatePixmap_mixed(ScreenPtr pScreen, int w, int h, int depth,
 	pExaPixmap->use_gpu_copy = FALSE;
 
 	if (w == 1 && h == 1) {
-	    pExaPixmap->sys_ptr = malloc((pPixmap->drawable.bitsPerPixel + 7) / 8);
+	    pExaPixmap->sys_ptr = malloc(paddedWidth);
 
 	    /* Set up damage tracking */
 	    pExaPixmap->pDamage = DamageCreate(exaDamageReport_mixed, NULL,
commit f3480286aeb3009623d8d4b0202eadda0049552d
Author: Ville Syrjälä <ville.syrjala at nokia.com>
Date:   Wed Jan 5 20:41:09 2011 +0200

    composite: Support updating an arbitrary subtree
    
    Rename compUpdateWindow to compPaintWindowToParent and split the child
    walk to compPaintChildrenToWindow. Calling compPaintChildrenToWindow
    allows an arbitrary subtree to be updated, instead of having to update
    all the windows. This will be used to make sure all the descendants are
    copied to the parent when the parent window contents need to be accessed
    in IncludeInferios sub-window mode.
    
    WindowRec has a new member 'damagedDescendants' that is used to keep
    track of which subtrees need updating. When a window is damaged,
    'damagedDescendants' will be set for all the ancestors, and when a
    subtree is updated, the tree walk can be stopped early if no damaged
    descendants are present.
    
    CompScreenRec no longer needs the 'damaged' member since the root
    window's 'damagedDescendants' provides the same information.
    
    Signed-off-by: Ville Syrjälä <ville.syrjala at nokia.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/composite/compalloc.c b/composite/compalloc.c
index b2e3f71..e4064f6 100644
--- a/composite/compalloc.c
+++ b/composite/compalloc.c
@@ -47,11 +47,11 @@
 
 #include "compint.h"
 
-void
+static void
 compScreenUpdate (ScreenPtr pScreen)
 {
     compCheckTree (pScreen);
-    compWindowUpdate (pScreen->root);
+    compPaintChildrenToWindow (pScreen->root);
 }
 
 static void
@@ -84,6 +84,15 @@ compReportDamage (DamagePtr pDamage, RegionPtr pRegion, void *closure)
         pScreen->BlockHandler = compBlockHandler;
     }
     cw->damaged = TRUE;
+
+    /* Mark the ancestors */
+    pWin = pWin->parent;
+    while (pWin) {
+	if (pWin->damagedDescendants)
+	    break;
+	pWin->damagedDescendants = TRUE;
+	pWin = pWin->parent;
+    }
 }
 
 static void
diff --git a/composite/compinit.c b/composite/compinit.c
index 74689be..90ee66c 100644
--- a/composite/compinit.c
+++ b/composite/compinit.c
@@ -145,7 +145,7 @@ compGetImage (DrawablePtr pDrawable,
 
     pScreen->GetImage = cs->GetImage;
     if (pDrawable->type == DRAWABLE_WINDOW)
-	compScreenUpdate (pScreen);
+	compPaintChildrenToWindow ((WindowPtr) pDrawable);
     (*pScreen->GetImage) (pDrawable, sx, sy, w, h, format, planemask, pdstLine);
     cs->GetImage = pScreen->GetImage;
     pScreen->GetImage = compGetImage;
@@ -161,7 +161,7 @@ static void compSourceValidate(DrawablePtr pDrawable,
 
     pScreen->SourceValidate = cs->SourceValidate;
     if (pDrawable->type == DRAWABLE_WINDOW && subWindowMode == IncludeInferiors)
-	compScreenUpdate (pScreen);
+	compPaintChildrenToWindow ((WindowPtr) pDrawable);
     if (pScreen->SourceValidate)
 	(*pScreen->SourceValidate) (pDrawable, x, y, width, height,
 				    subWindowMode);
diff --git a/composite/compint.h b/composite/compint.h
index 681f651..57e0b5d 100644
--- a/composite/compint.h
+++ b/composite/compint.h
@@ -315,10 +315,7 @@ void
 compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
 
 void
-compWindowUpdate (WindowPtr pWin);
-
-void
-compScreenUpdate (ScreenPtr pScreen);
+compPaintChildrenToWindow (WindowPtr pWin);
 
 WindowPtr
 CompositeRealChildHead (WindowPtr pWin);
diff --git a/composite/compwindow.c b/composite/compwindow.c
index 22d2374..2440f18 100644
--- a/composite/compwindow.c
+++ b/composite/compwindow.c
@@ -720,13 +720,11 @@ compWindowUpdateAutomatic (WindowPtr pWin)
     DamageEmpty (cw->damage);
 }
 
-void
-compWindowUpdate (WindowPtr pWin)
+static void
+compPaintWindowToParent (WindowPtr pWin)
 {
-    WindowPtr	pChild;
+    compPaintChildrenToWindow (pWin);
 
-    for (pChild = pWin->lastChild; pChild; pChild = pChild->prevSib)
-	compWindowUpdate (pChild);
     if (pWin->redirectDraw != RedirectDrawNone)
     {
 	CompWindowPtr	cw = GetCompWindow(pWin);
@@ -739,6 +737,20 @@ compWindowUpdate (WindowPtr pWin)
     }
 }
 
+void
+compPaintChildrenToWindow (WindowPtr pWin)
+{
+    WindowPtr pChild;
+
+    if (!pWin->damagedDescendants)
+	return;
+
+    for (pChild = pWin->lastChild; pChild; pChild = pChild->prevSib)
+	compPaintWindowToParent (pChild);
+
+    pWin->damagedDescendants = FALSE;
+}
+
 WindowPtr
 CompositeRealChildHead (WindowPtr pWin)
 {
diff --git a/dix/window.c b/dix/window.c
index d140dda..9be7064 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -298,6 +298,10 @@ SetWindowToDefaults(WindowPtr pWin)
 #ifdef ROOTLESS
     pWin->rootlessUnhittable = FALSE;
 #endif
+
+#ifdef COMPOSITE
+    pWin->damagedDescendants = FALSE;
+#endif
 }
 
 static void
diff --git a/include/windowstr.h b/include/windowstr.h
index 0b66ebb..4a7a0f4 100644
--- a/include/windowstr.h
+++ b/include/windowstr.h
@@ -167,6 +167,9 @@ typedef struct _Window {
 #ifdef ROOTLESS
     unsigned		rootlessUnhittable:1;	/* doesn't hit-test */
 #endif
+#ifdef COMPOSITE
+    unsigned		damagedDescendants:1;	/* some descendants are damaged */
+#endif
 } WindowRec;
 
 /*
commit b89e6dbdfbb50e3b5bc7fcb7eccc397c467c92f8
Author: Ville Syrjälä <ville.syrjala at nokia.com>
Date:   Wed Jan 5 20:41:08 2011 +0200

    composite: Add SourceValidate wrapper
    
    When SourceValidate is performed on a window with IncludeInferiors
    sub-window mode, force an immediate update of all the automatically
    redirected windows, so that the current window contents will be up
    to date.
    
    Signed-off-by: Ville Syrjälä <ville.syrjala at nokia.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/composite/compinit.c b/composite/compinit.c
index e1a7656..74689be 100644
--- a/composite/compinit.c
+++ b/composite/compinit.c
@@ -78,6 +78,7 @@ compCloseScreen (int index, ScreenPtr pScreen)
     pScreen->PositionWindow = cs->PositionWindow;
 
     pScreen->GetImage = cs->GetImage;
+    pScreen->SourceValidate = cs->SourceValidate;
 
     free(cs);
     dixSetPrivate(&pScreen->devPrivates, CompScreenPrivateKey, NULL);
@@ -150,6 +151,24 @@ compGetImage (DrawablePtr pDrawable,
     pScreen->GetImage = compGetImage;
 }
 
+static void compSourceValidate(DrawablePtr pDrawable,
+			       int x, int y,
+			       int width, int height,
+			       unsigned int subWindowMode)
+{
+    ScreenPtr pScreen = pDrawable->pScreen;
+    CompScreenPtr cs = GetCompScreen (pScreen);
+
+    pScreen->SourceValidate = cs->SourceValidate;
+    if (pDrawable->type == DRAWABLE_WINDOW && subWindowMode == IncludeInferiors)
+	compScreenUpdate (pScreen);
+    if (pScreen->SourceValidate)
+	(*pScreen->SourceValidate) (pDrawable, x, y, width, height,
+				    subWindowMode);
+    cs->SourceValidate = pScreen->SourceValidate;
+    pScreen->SourceValidate = compSourceValidate;
+}
+
 /*
  * Add alternate visuals -- always expose an ARGB32 and RGB24 visual
  */
@@ -385,6 +404,9 @@ compScreenInit (ScreenPtr pScreen)
     cs->GetImage = pScreen->GetImage;
     pScreen->GetImage = compGetImage;
 
+    cs->SourceValidate = pScreen->SourceValidate;
+    pScreen->SourceValidate = compSourceValidate;
+
     dixSetPrivate(&pScreen->devPrivates, CompScreenPrivateKey, cs);
 
     RegisterRealChildHeadProc(CompositeRealChildHead);
diff --git a/composite/compint.h b/composite/compint.h
index c188bf1..681f651 100644
--- a/composite/compint.h
+++ b/composite/compint.h
@@ -160,6 +160,7 @@ typedef struct _CompScreen {
     CompOverlayClientPtr        pOverlayClients;
     
     GetImageProcPtr		GetImage;
+    SourceValidateProcPtr	SourceValidate;
 } CompScreenRec, *CompScreenPtr;
 
 extern DevPrivateKeyRec CompScreenPrivateKeyRec;
commit 84154954db54696d4661eb8d0a6014cdbff3c91f
Author: Ville Syrjälä <ville.syrjala at nokia.com>
Date:   Wed Jan 5 20:41:07 2011 +0200

    composite: Add GetImage wrapper
    
    When GetImage is performed on a window, force an immediate update of
    all the automatically redirected windows, so that the current window
    contents will be up to date.
    
    Signed-off-by: Ville Syrjälä <ville.syrjala at nokia.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/composite/compalloc.c b/composite/compalloc.c
index 86a6f8e..b2e3f71 100644
--- a/composite/compalloc.c
+++ b/composite/compalloc.c
@@ -47,7 +47,7 @@
 
 #include "compint.h"
 
-static void
+void
 compScreenUpdate (ScreenPtr pScreen)
 {
     compCheckTree (pScreen);
diff --git a/composite/compinit.c b/composite/compinit.c
index 276ed75..e1a7656 100644
--- a/composite/compinit.c
+++ b/composite/compinit.c
@@ -77,6 +77,8 @@ compCloseScreen (int index, ScreenPtr pScreen)
     pScreen->CopyWindow = cs->CopyWindow;
     pScreen->PositionWindow = cs->PositionWindow;
 
+    pScreen->GetImage = cs->GetImage;
+
     free(cs);
     dixSetPrivate(&pScreen->devPrivates, CompScreenPrivateKey, NULL);
     ret = (*pScreen->CloseScreen) (index, pScreen);
@@ -129,6 +131,25 @@ compChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
     return ret;
 }
 
+static void
+compGetImage (DrawablePtr pDrawable,
+	      int sx, int sy,
+	      int w, int h,
+	      unsigned int format,
+	      unsigned long planemask,
+	      char *pdstLine)
+{
+    ScreenPtr pScreen = pDrawable->pScreen;
+    CompScreenPtr cs = GetCompScreen (pScreen);
+
+    pScreen->GetImage = cs->GetImage;
+    if (pDrawable->type == DRAWABLE_WINDOW)
+	compScreenUpdate (pScreen);
+    (*pScreen->GetImage) (pDrawable, sx, sy, w, h, format, planemask, pdstLine);
+    cs->GetImage = pScreen->GetImage;
+    pScreen->GetImage = compGetImage;
+}
+
 /*
  * Add alternate visuals -- always expose an ARGB32 and RGB24 visual
  */
@@ -361,6 +382,9 @@ compScreenInit (ScreenPtr pScreen)
     cs->CloseScreen = pScreen->CloseScreen;
     pScreen->CloseScreen = compCloseScreen;
 
+    cs->GetImage = pScreen->GetImage;
+    pScreen->GetImage = compGetImage;
+
     dixSetPrivate(&pScreen->devPrivates, CompScreenPrivateKey, cs);
 
     RegisterRealChildHeadProc(CompositeRealChildHead);
diff --git a/composite/compint.h b/composite/compint.h
index 4b058e7..c188bf1 100644
--- a/composite/compint.h
+++ b/composite/compint.h
@@ -159,6 +159,7 @@ typedef struct _CompScreen {
     Window			overlayWid;
     CompOverlayClientPtr        pOverlayClients;
     
+    GetImageProcPtr		GetImage;
 } CompScreenRec, *CompScreenPtr;
 
 extern DevPrivateKeyRec CompScreenPrivateKeyRec;
@@ -315,6 +316,9 @@ compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
 void
 compWindowUpdate (WindowPtr pWin);
 
+void
+compScreenUpdate (ScreenPtr pScreen);
+
 WindowPtr
 CompositeRealChildHead (WindowPtr pWin);
 
commit a5dc3531e14589ac473cea482944d2d67517aabd
Author: Ville Syrjälä <ville.syrjala at nokia.com>
Date:   Wed Jan 5 20:41:06 2011 +0200

    Revert "composite: Convert compWindowUpdate to use TraverseTree"
    
    TraverseTree visits the parent before the children. When performing
    the automatic redirection updates, the children must be visited before
    the parent.
    
    If there are automatically redirected windows on multiple levels of the
    tree, updating the parents before the children would cause the parent
    updates to use stale data for areas covered by the children. Also
    updating the damaged children would re-damage the parent, which would
    cause additional walks over the tree.
    
    In the worst case with an unbroken chain of automatically redirected
    subwindows, all of which are damaged, only the leaf window would be
    properly updated on the first round. Then it's parent would be properly
    updated on the second round, and so on. And on every round all of the
    ancestor windows would be updated as well, but with stale data.
    So with N damaged windows you would end up with (N^2+N)/2 updates,
    instead of the expected N.
    
    This reverts commit 648c8871c92727d7b6b16859f27f12266a06a16e.
    
    Signed-off-by: Ville Syrjälä <ville.syrjala at nokia.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/composite/compwindow.c b/composite/compwindow.c
index bbd5756..22d2374 100644
--- a/composite/compwindow.c
+++ b/composite/compwindow.c
@@ -653,9 +653,10 @@ compWindowFormat (WindowPtr pWin)
 }
 
 static void
-compWindowUpdateAutomatic (WindowPtr pWin, ScreenPtr pScreen)
+compWindowUpdateAutomatic (WindowPtr pWin)
 {
     CompWindowPtr   cw = GetCompWindow (pWin);
+    ScreenPtr	    pScreen = pWin->drawable.pScreen;
     WindowPtr	    pParent = pWin->parent;
     PixmapPtr	    pSrcPixmap = (*pScreen->GetWindowPixmap) (pWin);
     PictFormatPtr   pSrcFormat = compWindowFormat (pWin);
@@ -678,7 +679,8 @@ compWindowUpdateAutomatic (WindowPtr pWin, ScreenPtr pScreen)
     /*
      * First move the region from window to screen coordinates
      */
-    RegionTranslate(pRegion, pWin->drawable.x, pWin->drawable.y);
+    RegionTranslate(pRegion,
+		      pWin->drawable.x, pWin->drawable.y);
 
     /*
      * Clip against the "real" border clip
@@ -688,7 +690,8 @@ compWindowUpdateAutomatic (WindowPtr pWin, ScreenPtr pScreen)
     /*
      * Now translate from screen to dest coordinates
      */
-    RegionTranslate(pRegion, -pParent->drawable.x, -pParent->drawable.y);
+    RegionTranslate(pRegion,
+		      -pParent->drawable.x, -pParent->drawable.y);
 
     /*
      * Clip the picture
@@ -717,26 +720,23 @@ compWindowUpdateAutomatic (WindowPtr pWin, ScreenPtr pScreen)
     DamageEmpty (cw->damage);
 }
 
-static int
-compWindowUpdateVisit(WindowPtr pWin, void *data)
+void
+compWindowUpdate (WindowPtr pWin)
 {
+    WindowPtr	pChild;
+
+    for (pChild = pWin->lastChild; pChild; pChild = pChild->prevSib)
+	compWindowUpdate (pChild);
     if (pWin->redirectDraw != RedirectDrawNone)
     {
-	CompWindowPtr cw = GetCompWindow(pWin);
+	CompWindowPtr	cw = GetCompWindow(pWin);
+
 	if (cw->damaged)
 	{
-	    compWindowUpdateAutomatic(pWin, data);
+	    compWindowUpdateAutomatic (pWin);
 	    cw->damaged = FALSE;
 	}
     }
-
-    return WT_WALKCHILDREN;
-}
-
-void
-compWindowUpdate (WindowPtr pWin)
-{
-    TraverseTree(pWin, compWindowUpdateVisit, pWin->drawable.pScreen);
 }
 
 WindowPtr
commit 0998574699502e6ab14fd8899c2e42961d4df7d0
Author: Ville Syrjälä <ville.syrjala at nokia.com>
Date:   Wed Jan 5 20:41:05 2011 +0200

    Call SourceValidate even if src == dst
    
    The extra SourceValidate calls from damageCopyArea and damageCopyPlane
    can be removed.
    
    Signed-off-by: Ville Syrjälä <ville.syrjala at nokia.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/doc/xml/Xserver-spec.xml b/doc/xml/Xserver-spec.xml
index f7b2296..7d7f915 100644
--- a/doc/xml/Xserver-spec.xml
+++ b/doc/xml/Xserver-spec.xml
@@ -2958,8 +2958,7 @@ The sample server implementation is in Xserver/fb/fbscreen.c.</para>
 
 </programlisting></blockquote>
 SourceValidate should be called by CopyArea/CopyPlane primitives when
-the source drawable is not the same as the destination, and the
-SourceValidate function pointer in the screen is non-null.  If you know that
+the SourceValidate function pointer in the screen is non-null.  If you know that
 you will never need SourceValidate, you can avoid this check.  Currently,
 SourceValidate is used by the mi software cursor code to remove the cursor
 from the screen when the source rectangle overlaps the cursor position.
diff --git a/hw/xfree86/xaa/xaaBitBlt.c b/hw/xfree86/xaa/xaaBitBlt.c
index dfe51ea..049dbfb 100644
--- a/hw/xfree86/xaa/xaaBitBlt.c
+++ b/hw/xfree86/xaa/xaaBitBlt.c
@@ -54,8 +54,7 @@ XAABitBlt(
     origDest.x = dstx;
     origDest.y = dsty;
 
-    if((pSrcDrawable != pDstDrawable) && 
-			pSrcDrawable->pScreen->SourceValidate) {
+    if (pSrcDrawable->pScreen->SourceValidate) {
 	(*pSrcDrawable->pScreen->SourceValidate) (
 			pSrcDrawable, srcx, srcy, width, height,
 			pGC->subWindowMode);
diff --git a/mi/micopy.c b/mi/micopy.c
index 50e2667..652c620 100644
--- a/mi/micopy.c
+++ b/mi/micopy.c
@@ -183,8 +183,7 @@ miDoCopy (DrawablePtr	pSrcDrawable,
 	return NULL;
     }
 
-    if ((pSrcDrawable != pDstDrawable) &&
-	pSrcDrawable->pScreen->SourceValidate)
+    if (pSrcDrawable->pScreen->SourceValidate)
     {
 	(*pSrcDrawable->pScreen->SourceValidate) (pSrcDrawable, xIn, yIn, widthSrc, heightSrc,
 						  pGC->subWindowMode);
diff --git a/miext/damage/damage.c b/miext/damage/damage.c
index d0e0fe4..566995c 100644
--- a/miext/damage/damage.c
+++ b/miext/damage/damage.c
@@ -891,17 +891,6 @@ damageCopyArea(DrawablePtr   pSrc,
     RegionPtr ret;
     DAMAGE_GC_OP_PROLOGUE(pGC, pDst);
     
-    /* The driver will only call SourceValidate() when pSrc != pDst,
-     * but the software sprite (misprite.c) always need to know when a
-     * drawable is copied so it can remove the sprite. See #1030. */
-    if ((pSrc == pDst) && pSrc->pScreen->SourceValidate &&
-	pSrc->type == DRAWABLE_WINDOW &&
-	((WindowPtr)pSrc)->viewable)
-    {
-	(*pSrc->pScreen->SourceValidate) (pSrc, srcx, srcy, width, height,
-					  pGC->subWindowMode);
-    }
-    
     if (checkGCDamage (pDst, pGC))
     {
 	BoxRec box;
@@ -938,17 +927,6 @@ damageCopyPlane(DrawablePtr	pSrc,
     RegionPtr ret;
     DAMAGE_GC_OP_PROLOGUE(pGC, pDst);
 
-    /* The driver will only call SourceValidate() when pSrc != pDst,
-     * but the software sprite (misprite.c) always need to know when a
-     * drawable is copied so it can remove the sprite. See #1030. */
-    if ((pSrc == pDst) && pSrc->pScreen->SourceValidate &&
-	pSrc->type == DRAWABLE_WINDOW &&
-	((WindowPtr)pSrc)->viewable)
-    {
-	(*pSrc->pScreen->SourceValidate) (pSrc, srcx, srcy, width, height,
-					  pGC->subWindowMode);
-    }
-
     if (checkGCDamage (pDst, pGC))
     {
 	BoxRec box;
commit e41e907b3c19908f5316346fa587ced3115478cd
Author: Ville Syrjälä <ville.syrjala at nokia.com>
Date:   Wed Jan 5 20:41:04 2011 +0200

    Add subWindowMode parameter to SourceValidate
    
    Pass the subWindowMode from the GC/source Picture to SourceValidate.
    
    Signed-off-by: Ville Syrjälä <ville.syrjala at nokia.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/doc/xml/Xserver-spec.xml b/doc/xml/Xserver-spec.xml
index a2aec2f..f7b2296 100644
--- a/doc/xml/Xserver-spec.xml
+++ b/doc/xml/Xserver-spec.xml
@@ -2954,6 +2954,7 @@ The sample server implementation is in Xserver/fb/fbscreen.c.</para>
 	pScreen->SourceValidate(pDrawable, x, y, width, height)
 		DrawablePtr pDrawable;
 		int x, y, width, height;
+		unsigned int subWindowMode;
 
 </programlisting></blockquote>
 SourceValidate should be called by CopyArea/CopyPlane primitives when
@@ -2963,7 +2964,8 @@ you will never need SourceValidate, you can avoid this check.  Currently,
 SourceValidate is used by the mi software cursor code to remove the cursor
 from the screen when the source rectangle overlaps the cursor position.
 x,y,width,height describe the source rectangle (source relative, that is)
-for the copy operation.</para>
+for the copy operation.  subWindowMode comes from the GC or source Picture.
+</para>
 <para>
 <blockquote><programlisting>
 
diff --git a/exa/exa_unaccel.c b/exa/exa_unaccel.c
index d3c405f..bd533c4 100644
--- a/exa/exa_unaccel.c
+++ b/exa/exa_unaccel.c
@@ -438,7 +438,8 @@ ExaSrcValidate(DrawablePtr pDrawable,
 	       int x,
 	       int y,
 	       int width,
-	       int height)
+	       int height,
+	       unsigned int subWindowMode)
 {
     ScreenPtr pScreen = pDrawable->pScreen;
     ExaScreenPriv(pScreen);
@@ -464,7 +465,7 @@ ExaSrcValidate(DrawablePtr pDrawable,
 
     if (pExaScr->SavedSourceValidate) {
         swap(pExaScr, pScreen, SourceValidate);
-        pScreen->SourceValidate(pDrawable, x, y, width, height);
+        pScreen->SourceValidate(pDrawable, x, y, width, height, subWindowMode);
         swap(pExaScr, pScreen, SourceValidate);
     }
 }
diff --git a/hw/xfree86/common/xf86VGAarbiter.c b/hw/xfree86/common/xf86VGAarbiter.c
index e518f45..215e845 100644
--- a/hw/xfree86/common/xf86VGAarbiter.c
+++ b/hw/xfree86/common/xf86VGAarbiter.c
@@ -325,13 +325,14 @@ VGAarbiterGetSpans (
 static void
 VGAarbiterSourceValidate (
     DrawablePtr pDrawable,
-    int x, int y, int width, int height )
+    int x, int y, int width, int height,
+    unsigned int subWindowMode )
 {
     ScreenPtr   pScreen = pDrawable->pScreen;
     SCREEN_PROLOG (SourceValidate);
     VGAGet(pScreen);
     if (pScreen->SourceValidate)
-    (*pScreen->SourceValidate) (pDrawable, x, y, width, height);
+    (*pScreen->SourceValidate) (pDrawable, x, y, width, height, subWindowMode);
     VGAPut();
     SCREEN_EPILOG (SourceValidate, VGAarbiterSourceValidate);
 }
diff --git a/hw/xfree86/common/xf86VGAarbiterPriv.h b/hw/xfree86/common/xf86VGAarbiterPriv.h
index 2920fb5..848e45d 100644
--- a/hw/xfree86/common/xf86VGAarbiterPriv.h
+++ b/hw/xfree86/common/xf86VGAarbiterPriv.h
@@ -149,7 +149,7 @@ static void VGAarbiterGetImage (DrawablePtr pDrawable, int sx, int sy, int w,
 static void VGAarbiterGetSpans (DrawablePtr pDrawable, int wMax, DDXPointPtr
     ppt, int *pwidth, int nspans, char  *pdstStart);
 static void VGAarbiterSourceValidate (DrawablePtr pDrawable, int x, int y,
-    int width, int height);
+    int width, int height, unsigned int subWindowMode);
 static void VGAarbiterCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg,
     RegionPtr prgnSrc);
 static void VGAarbiterClearToBackground (WindowPtr pWin, int x, int y, int w,
diff --git a/hw/xfree86/xaa/xaaBitBlt.c b/hw/xfree86/xaa/xaaBitBlt.c
index 5148ed4..dfe51ea 100644
--- a/hw/xfree86/xaa/xaaBitBlt.c
+++ b/hw/xfree86/xaa/xaaBitBlt.c
@@ -57,7 +57,8 @@ XAABitBlt(
     if((pSrcDrawable != pDstDrawable) && 
 			pSrcDrawable->pScreen->SourceValidate) {
 	(*pSrcDrawable->pScreen->SourceValidate) (
-			pSrcDrawable, srcx, srcy, width, height);
+			pSrcDrawable, srcx, srcy, width, height,
+			pGC->subWindowMode);
     }
 
     srcx += pSrcDrawable->x;
diff --git a/include/scrnintstr.h b/include/scrnintstr.h
index 00d014c..9952325 100644
--- a/include/scrnintstr.h
+++ b/include/scrnintstr.h
@@ -135,7 +135,8 @@ typedef    void (* SourceValidateProcPtr)(
 	int /*x*/,
 	int /*y*/,
 	int /*width*/,
-	int /*height*/);
+	int /*height*/,
+	unsigned int /*subWindowMode*/);
 
 typedef    Bool (* CreateWindowProcPtr)(
 	WindowPtr /*pWindow*/);
diff --git a/mi/micopy.c b/mi/micopy.c
index 027c461..50e2667 100644
--- a/mi/micopy.c
+++ b/mi/micopy.c
@@ -186,7 +186,8 @@ miDoCopy (DrawablePtr	pSrcDrawable,
     if ((pSrcDrawable != pDstDrawable) &&
 	pSrcDrawable->pScreen->SourceValidate)
     {
-	(*pSrcDrawable->pScreen->SourceValidate) (pSrcDrawable, xIn, yIn, widthSrc, heightSrc);
+	(*pSrcDrawable->pScreen->SourceValidate) (pSrcDrawable, xIn, yIn, widthSrc, heightSrc,
+						  pGC->subWindowMode);
     }
 
     /* Compute source clip region */
diff --git a/mi/misprite.c b/mi/misprite.c
index c25c093..770951e 100644
--- a/mi/misprite.c
+++ b/mi/misprite.c
@@ -198,7 +198,8 @@ static void	    miSpriteGetSpans(DrawablePtr pDrawable, int wMax,
 				     DDXPointPtr ppt, int *pwidth, int nspans,
 				     char *pdstStart);
 static void	    miSpriteSourceValidate(DrawablePtr pDrawable, int x, int y,
-					   int width, int height);
+					   int width, int height,
+					   unsigned int subWindowMode);
 static void	    miSpriteCopyWindow (WindowPtr pWindow,
 					DDXPointRec ptOldOrg,
 					RegionPtr prgnSrc);
@@ -489,7 +490,7 @@ miSpriteGetSpans (DrawablePtr pDrawable, int wMax, DDXPointPtr ppt,
 
 static void
 miSpriteSourceValidate (DrawablePtr pDrawable, int x, int y, int width,
-                        int height)
+                        int height, unsigned int subWindowMode)
 {
     ScreenPtr		    pScreen = pDrawable->pScreen;
     DeviceIntPtr            pDev;
@@ -517,7 +518,7 @@ miSpriteSourceValidate (DrawablePtr pDrawable, int x, int y, int width,
     }
 
     if (pScreen->SourceValidate)
-	(*pScreen->SourceValidate) (pDrawable, x, y, width, height);
+	(*pScreen->SourceValidate) (pDrawable, x, y, width, height, subWindowMode);
 
     SCREEN_EPILOGUE (pPriv, pScreen, SourceValidate);
 }
diff --git a/miext/damage/damage.c b/miext/damage/damage.c
index 21cbb78..d0e0fe4 100644
--- a/miext/damage/damage.c
+++ b/miext/damage/damage.c
@@ -898,7 +898,8 @@ damageCopyArea(DrawablePtr   pSrc,
 	pSrc->type == DRAWABLE_WINDOW &&
 	((WindowPtr)pSrc)->viewable)
     {
-	(*pSrc->pScreen->SourceValidate) (pSrc, srcx, srcy, width, height);
+	(*pSrc->pScreen->SourceValidate) (pSrc, srcx, srcy, width, height,
+					  pGC->subWindowMode);
     }
     
     if (checkGCDamage (pDst, pGC))
@@ -944,7 +945,8 @@ damageCopyPlane(DrawablePtr	pSrc,
 	pSrc->type == DRAWABLE_WINDOW &&
 	((WindowPtr)pSrc)->viewable)
     {
-        (*pSrc->pScreen->SourceValidate) (pSrc, srcx, srcy, width, height);
+	(*pSrc->pScreen->SourceValidate) (pSrc, srcx, srcy, width, height,
+					  pGC->subWindowMode);
     }
 
     if (checkGCDamage (pDst, pGC))
diff --git a/miext/rootless/rootlessScreen.c b/miext/rootless/rootlessScreen.c
index 61d2f5d..510d6fd 100644
--- a/miext/rootless/rootlessScreen.c
+++ b/miext/rootless/rootlessScreen.c
@@ -223,7 +223,8 @@ out:
  *  here and leave StopDrawing for the block handler.
  */
 static void
-RootlessSourceValidate(DrawablePtr pDrawable, int x, int y, int w, int h)
+RootlessSourceValidate(DrawablePtr pDrawable, int x, int y, int w, int h,
+                       unsigned int subWindowMode)
 {
     SCREEN_UNWRAP(pDrawable->pScreen, SourceValidate);
     if (pDrawable->type == DRAWABLE_WINDOW) {
@@ -231,7 +232,7 @@ RootlessSourceValidate(DrawablePtr pDrawable, int x, int y, int w, int h)
         RootlessStartDrawing(pWin);
     }
     if (pDrawable->pScreen->SourceValidate) {
-        pDrawable->pScreen->SourceValidate(pDrawable, x, y, w, h);
+        pDrawable->pScreen->SourceValidate(pDrawable, x, y, w, h, subWindowMode);
     }
     SCREEN_WRAP(pDrawable->pScreen, SourceValidate);
 }
diff --git a/render/mipict.c b/render/mipict.c
index b5b8970..de5eea6 100644
--- a/render/mipict.c
+++ b/render/mipict.c
@@ -386,7 +386,8 @@ miCompositeSourceValidate (PicturePtr	pPicture,
 	}
         x += pPicture->pDrawable->x;
         y += pPicture->pDrawable->y;
-	(*pScreen->SourceValidate) (pDrawable, x, y, width, height);
+	(*pScreen->SourceValidate) (pDrawable, x, y, width, height,
+				    pPicture->subWindowMode);
     }
 }
 
commit 0dede200c9ac7adbe8b8c16efacc3edc1f183cd9
Merge: 7714357... 2e78145...
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Jan 5 08:51:46 2011 -0800

    Merge remote branch 'vsyrjala/misc_fixes'

commit 7714357f506782973d25e270f85140b42507ed35
Merge: 02e18c9... b01dd9d...
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Jan 5 08:43:18 2011 -0800

    Merge remote branch 'whot/for-keith'

commit 02e18c9fb58c33d340af4573551fb9c7c59e0f43
Author: James Jones <jajones at nvidia.com>
Date:   Mon Dec 20 11:05:57 2010 -0800

    X Sync Cleanups
    
    Various cleanups identified during review of the
    X Sync Fence Object patches.
    
    -Correctly handle failure of AddResource()
    
    -Don't assert when data structures are corrupt.  Instead,
     use a new helper function to check for counter sync
     objects when they're expected, and warn if the type is
     wrong.
    
    -Use the default switch label rather than reimplementing
     it.
    
    -Re-introduce cast of result of dixAllocateObjectWithPrivate()
     to kill an incompatible pointer type warning.
    
    -Remove comments claiming protocol updates are needed.  One
     wasn't true and the other was addressed with a xextproto
     change.
    
    -Return BadFence, not BadCounter from XSyncAwaitFence()
    
    Signed-off-by: James Jones <jajones at nvidia.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/Xext/sync.c b/Xext/sync.c
index d495116..36dd278 100644
--- a/Xext/sync.c
+++ b/Xext/sync.c
@@ -90,6 +90,16 @@ static RESTYPE  RTAlarmClient;
 static RESTYPE  RTFence;
 static int SyncNumSystemCounters = 0;
 static SyncCounter **SysCounterList = NULL;
+static int SyncNumInvalidCounterWarnings = 0;
+#define MAX_INVALID_COUNTER_WARNINGS	   5
+
+static const char *WARN_INVALID_COUNTER_COMPARE =
+"Warning: Non-counter XSync object using Counter-only\n"
+"         comparison.  Result will never be true.\n";
+
+static const char *WARN_INVALID_COUNTER_ALARM =
+"Warning: Non-counter XSync object used in alarm.  This is\n"
+"         the result of a programming error in the X server.\n";
 
 #define IsSystemCounter(pCounter) \
     (pCounter && (pCounter->sync.client == NULL))
@@ -104,6 +114,22 @@ static void SyncInitServerTime(void);
 
 static void SyncInitIdleTime(void);
 
+static Bool
+SyncCheckWarnIsCounter(const SyncObject* pSync, const char *warning)
+{
+    if (pSync && (SYNC_COUNTER != pSync->type))
+    {
+	if (SyncNumInvalidCounterWarnings++ < MAX_INVALID_COUNTER_WARNINGS)
+	{
+	    ErrorF("%s", warning);
+	    ErrorF("         Counter type: %d\n", pSync->type);
+	}
+
+	return FALSE;
+    }
+
+    return TRUE;
+}
 
 /*  Each counter maintains a simple linked list of triggers that are
  *  interested in the counter.  The two functions below are used to
@@ -212,7 +238,11 @@ SyncCheckTriggerPositiveComparison(SyncTrigger *pTrigger, CARD64 oldval)
 {
     SyncCounter *pCounter;
 
-    assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type));
+    /* Non-counter sync objects should never get here because they
+     * never trigger this comparison. */
+    if (!SyncCheckWarnIsCounter(pTrigger->pSync, WARN_INVALID_COUNTER_COMPARE))
+	return FALSE;
+
     pCounter = (SyncCounter *)pTrigger->pSync;
 
     return (pCounter == NULL ||
@@ -224,7 +254,11 @@ SyncCheckTriggerNegativeComparison(SyncTrigger *pTrigger,  CARD64 oldval)
 {
     SyncCounter *pCounter;
 
-    assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type));
+    /* Non-counter sync objects should never get here because they
+     * never trigger this comparison. */
+    if (!SyncCheckWarnIsCounter(pTrigger->pSync, WARN_INVALID_COUNTER_COMPARE))
+	return FALSE;
+
     pCounter = (SyncCounter *)pTrigger->pSync;
 
     return (pCounter == NULL ||
@@ -236,7 +270,11 @@ SyncCheckTriggerPositiveTransition(SyncTrigger *pTrigger, CARD64 oldval)
 {
     SyncCounter *pCounter;
 
-    assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type));
+    /* Non-counter sync objects should never get here because they
+     * never trigger this comparison. */
+    if (!SyncCheckWarnIsCounter(pTrigger->pSync, WARN_INVALID_COUNTER_COMPARE))
+	return FALSE;
+
     pCounter = (SyncCounter *)pTrigger->pSync;
 
     return (pCounter == NULL ||
@@ -249,7 +287,11 @@ SyncCheckTriggerNegativeTransition(SyncTrigger *pTrigger, CARD64 oldval)
 {
     SyncCounter *pCounter;
 
-    assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type));
+    /* Non-counter sync objects should never get here because they
+     * never trigger this comparison. */
+    if (!SyncCheckWarnIsCounter(pTrigger->pSync, WARN_INVALID_COUNTER_COMPARE))
+	return FALSE;
+
     pCounter = (SyncCounter *)pTrigger->pSync;
 
     return (pCounter == NULL ||
@@ -326,14 +368,6 @@ SyncInitTrigger(ClientPtr client, SyncTrigger *pTrigger, XID syncObject,
 	}
 	else
 	{
-	    if (pTrigger->test_type != XSyncPositiveTransition &&
-		pTrigger->test_type != XSyncNegativeTransition &&
-		pTrigger->test_type != XSyncPositiveComparison &&
-		pTrigger->test_type != XSyncNegativeComparison)
-	    {
-		client->errorValue = pTrigger->test_type;
-		return BadValue;
-	    }
 	    /* select appropriate CheckTrigger function */
 
 	    switch (pTrigger->test_type)
@@ -350,6 +384,9 @@ SyncInitTrigger(ClientPtr client, SyncTrigger *pTrigger, XID syncObject,
 	    case XSyncNegativeComparison:
 		pTrigger->CheckTrigger = SyncCheckTriggerNegativeComparison;
 		break;
+	    default:
+		client->errorValue = pTrigger->test_type;
+		return BadValue;
 	    }
 	}
     }
@@ -402,7 +439,8 @@ SyncSendAlarmNotifyEvents(SyncAlarm *pAlarm)
     SyncTrigger *pTrigger = &pAlarm->trigger;
     SyncCounter *pCounter;
 
-    assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type));
+    if (!SyncCheckWarnIsCounter(pTrigger->pSync, WARN_INVALID_COUNTER_ALARM))
+	return;
 
     pCounter = (SyncCounter *)pTrigger->pSync;
 
@@ -507,7 +545,9 @@ SyncAlarmTriggerFired(SyncTrigger *pTrigger)
     SyncCounter *pCounter;
     CARD64 new_test_value;
 
-    assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type));
+    if (!SyncCheckWarnIsCounter(pTrigger->pSync, WARN_INVALID_COUNTER_ALARM))
+	return;
+
     pCounter = (SyncCounter *)pTrigger->pSync;
 
     /* no need to check alarm unless it's active */
@@ -534,7 +574,10 @@ SyncAlarmTriggerFired(SyncTrigger *pTrigger)
 	SyncTrigger *paTrigger = &pAlarm->trigger;
 	SyncCounter *paCounter;
 
-	assert(!paTrigger->pSync || (SYNC_COUNTER == paTrigger->pSync->type));
+	if (!SyncCheckWarnIsCounter(paTrigger->pSync,
+				    WARN_INVALID_COUNTER_ALARM))
+	    return;
+
 	paCounter = (SyncCounter *)pTrigger->pSync;
 
 	/* "The alarm is updated by repeatedly adding delta to the
@@ -758,17 +801,15 @@ SyncEventSelectForAlarm(SyncAlarm *pAlarm, ClientPtr client, Bool wantevents)
      */
 
     pClients->delete_id = FakeClientID(client->index);
-    if (!AddResource(pClients->delete_id, RTAlarmClient, pAlarm))
-    {
-	free(pClients);
-	return BadAlloc;
-    }
 
     /* link it into list after we know all the allocations succeed */
-
     pClients->next = pAlarm->pEventClients;
     pAlarm->pEventClients = pClients;
     pClients->client = client;
+
+    if (!AddResource(pClients->delete_id, RTAlarmClient, pAlarm))
+	return BadAlloc;
+
     return Success;
 }
 
@@ -877,17 +918,14 @@ static SyncObject *
 SyncCreate(ClientPtr client, XID id, unsigned char type)
 {
     SyncObject *pSync;
-    RESTYPE resType;
 
     switch (type) {
     case SYNC_COUNTER:
-	resType = RTCounter;
 	pSync = malloc(sizeof(SyncCounter));
 	break;
     case SYNC_FENCE:
-	resType = RTFence;
-	pSync = dixAllocateObjectWithPrivates(SyncFence,
-					      PRIVATE_SYNC_FENCE);
+	pSync = (SyncObject*)dixAllocateObjectWithPrivates(SyncFence,
+							   PRIVATE_SYNC_FENCE);
 	break;
     default:
 	return NULL;
@@ -896,19 +934,6 @@ SyncCreate(ClientPtr client, XID id, unsigned char type)
     if (!pSync)
 	return NULL;
 
-    if (!AddResource(id, resType, (pointer) pSync))
-    {
-	switch (type) {
-	case SYNC_FENCE:
-	    dixFreeObjectWithPrivates((SyncFence *)pSync, PRIVATE_SYNC_FENCE);
-	    break;
-	default:
-	    free(pSync);
-	}
-
-	return NULL;
-    }
-
     pSync->client = client;
     pSync->id = id;
     pSync->pTriglist = NULL;
@@ -931,6 +956,10 @@ SyncCreateCounter(ClientPtr client, XSyncCounter id, CARD64 initialvalue)
 
     pCounter->value = initialvalue;
     pCounter->pSysCounterInfo = NULL;
+
+    if (!AddResource(id, RTCounter, (pointer) pCounter))
+	return NULL;
+
     return pCounter;
 }
 
@@ -1541,15 +1570,12 @@ SyncAwaitPrologue(ClientPtr client, int items)
     /* first item is the header, remainder are real wait conditions */
 
     pAwaitUnion->header.delete_id = FakeClientID(client->index);
-    if (!AddResource(pAwaitUnion->header.delete_id, RTAwait, pAwaitUnion))
-    {
-	free(pAwaitUnion);
-	return NULL;
-    }
-
     pAwaitUnion->header.client = client;
     pAwaitUnion->header.num_waitconditions = 0;
 
+    if (!AddResource(pAwaitUnion->header.delete_id, RTAwait, pAwaitUnion))
+	return NULL;
+
     return pAwaitUnion;
 }
 
@@ -1776,10 +1802,7 @@ ProcSyncCreateAlarm(ClientPtr client)
     }
 
     if (!AddResource(stuff->id, RTAlarm, pAlarm))
-    {
-	free(pAlarm);
 	return BadAlloc;
-    }
 
     /*  see if alarm already triggered.  NULL counter will not trigger
      *  in CreateAlarm and sets alarm state to Inactive.
@@ -1793,7 +1816,13 @@ ProcSyncCreateAlarm(ClientPtr client)
     {
 	SyncCounter *pCounter;
 
-	assert(SYNC_COUNTER == pTrigger->pSync->type);
+	if (!SyncCheckWarnIsCounter(pTrigger->pSync,
+				    WARN_INVALID_COUNTER_ALARM))
+	{
+	    FreeResource(stuff->id, RT_NONE);
+	    return BadAlloc;
+	}
+
 	pCounter = (SyncCounter *)pTrigger->pSync;
 
 	if ((*pTrigger->CheckTrigger)(pTrigger, pCounter->value))
@@ -1832,11 +1861,9 @@ ProcSyncChangeAlarm(ClientPtr client)
 					    (CARD32 *)&stuff[1])) != Success)
 	return status;
 
-    if (pAlarm->trigger.pSync)
-    {
-	assert(SYNC_COUNTER == pAlarm->trigger.pSync->type);
+    if (SyncCheckWarnIsCounter(pAlarm->trigger.pSync,
+			       WARN_INVALID_COUNTER_ALARM))
 	pCounter = (SyncCounter *)pAlarm->trigger.pSync;
-    }
 
     /*  see if alarm already triggered.  NULL counter WILL trigger
      *  in ChangeAlarm.
@@ -1950,6 +1977,9 @@ ProcSyncCreateFence(ClientPtr client)
 
     miSyncInitFence(pDraw->pScreen, pFence, stuff->initially_triggered);
 
+    if (!AddResource(stuff->fid, RTFence, (pointer) pFence))
+	return BadAlloc;
+
     return client->noClientException;
 }
 
@@ -2092,7 +2122,7 @@ ProcSyncAwaitFence(ClientPtr client)
     }
     if (items == 0)
     {
-	client->errorValue = items; /* XXX protocol change */
+	client->errorValue = items;
 	return BadValue;
     }
 
@@ -2106,14 +2136,14 @@ ProcSyncAwaitFence(ClientPtr client)
     pAwait = &(pAwaitUnion+1)->await; /* skip over header */
     for (i = 0; i < items; i++, pProtocolFences++, pAwait++)
     {
-	if (*pProtocolFences == None) /* XXX protocol change */
+	if (*pProtocolFences == None)
 	{
 	    /*  this should take care of removing any triggers created by
 	     *  this request that have already been registered on sync objects
 	     */
 	    FreeResource(pAwaitUnion->header.delete_id, RT_NONE);
 	    client->errorValue = *pProtocolFences;
-	    return SyncErrorBase + XSyncBadCounter;
+	    return SyncErrorBase + XSyncBadFence;
 	}
 
 	pAwait->trigger.pSync = NULL;
commit 86ca434a1ab766c1519ee7146b48dbfead843524
Author: Zhao Yakui <yakui.zhao at intel.com>
Date:   Tue Jan 4 14:08:16 2011 -0500

    edid: Fix incorrect timings for VIC61
    
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Anssi Hannula <anssi.hannula at iki.fi>
    Signed-off-by: Zhao Yakui <yakui.zhao at intel.com>

diff --git a/hw/xfree86/modes/xf86EdidModes.c b/hw/xfree86/modes/xf86EdidModes.c
index d9ece7a..9ff2f0d 100644
--- a/hw/xfree86/modes/xf86EdidModes.c
+++ b/hw/xfree86/modes/xf86EdidModes.c
@@ -959,7 +959,7 @@ static const DisplayModeRec CEAVideoModes[CEA_VIDEO_MODES_NUM] = {
     { MODEPREFIX,   108000, 1440, 1478, 1602, 1716, 0,  480,  488,  494,  525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 58:1440x480i at 240 */
     { MODEPREFIX,   108000, 1440, 1478, 1602, 1716, 0,  480,  488,  494,  525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 59:1440x480i at 240 */
     { MODEPREFIX,    59400, 1280, 3040, 3080, 3300, 0,  720,  725,  730,  750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 60: 1280x720 at 24Hz */
-    { MODEPREFIX,    74250, 3700, 3740, 1430, 3960, 0,  720,  725,  730,  750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 61: 1280x720 at 25Hz */
+    { MODEPREFIX,    74250, 1280, 3700, 3740, 3960, 0,  720,  725,  730,  750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 61: 1280x720 at 25Hz */
     { MODEPREFIX,    74250, 1280, 3040, 3080, 3300, 0,  720,  725,  730,  750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 62: 1280x720 at 30Hz */
     { MODEPREFIX,   297000, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 63: 1920x1080 at 120Hz */
     { MODEPREFIX,   297000, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 64:1920x1080 at 100Hz */
commit bb18f277156c08be028a6e12d8987fb1593e9168
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri Dec 10 14:24:02 2010 -0500

    x86emu: Fix more mis-decoding of the data prefix
    
    cc2c73ddcb4370a7c3ad439cda4da825156c26c9's three-cent titanium tax
    doesn't go too far enough.  Fix the rest of the call and jmp
    instructions to handle the data prefix correctly.
    
    Reference: Intel 64 and IA-32 Architectures Software Developer's Manual
    Volume 2A: Instruction Set Reference, A-M
    
    http://www.intel.com/Assets/PDF/manual/253666.pdf
    
    Reviewed-by: Julien Cristau <jcristau at debian.org>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/x86emu/ops.c b/hw/xfree86/x86emu/ops.c
index c6b2f0a..5d3cac1 100644
--- a/hw/xfree86/x86emu/ops.c
+++ b/hw/xfree86/x86emu/ops.c
@@ -7065,15 +7065,20 @@ Handles opcode 0x9a
 ****************************************************************************/
 static void x86emuOp_call_far_IMM(u8 X86EMU_UNUSED(op1))
 {
-    u16 farseg, faroff;
+    u32 farseg, faroff;
 
     START_OF_INSTR();
-	DECODE_PRINTF("CALL\t");
+    DECODE_PRINTF("CALL\t");
+    if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+	faroff = fetch_long_imm();
+	farseg = fetch_word_imm();
+    } else {
 	faroff = fetch_word_imm();
 	farseg = fetch_word_imm();
-	DECODE_PRINTF2("%04x:", farseg);
-	DECODE_PRINTF2("%04x\n", faroff);
-	CALL_TRACE(M.x86.saved_cs, M.x86.saved_ip, farseg, faroff, "FAR ");
+    }
+    DECODE_PRINTF2("%04x:", farseg);
+    DECODE_PRINTF2("%04x\n", faroff);
+    CALL_TRACE(M.x86.saved_cs, M.x86.saved_ip, farseg, faroff, "FAR ");
 
     /* XXX
      * 
@@ -7084,8 +7089,12 @@ static void x86emuOp_call_far_IMM(u8 X86EMU_UNUSED(op1))
     TRACE_AND_STEP();
     push_word(M.x86.R_CS);
     M.x86.R_CS = farseg;
-    push_word(M.x86.R_IP);
-    M.x86.R_IP = faroff;
+    if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+	push_long(M.x86.R_EIP);
+    } else {
+	push_word(M.x86.R_IP);
+    }
+    M.x86.R_EIP = faroff & 0xffff;
     DECODE_CLEAR_SEGOVR();
     END_OF_INSTR();
 }
@@ -9670,17 +9679,30 @@ Handles opcode 0xe8
 ****************************************************************************/
 static void x86emuOp_call_near_IMM(u8 X86EMU_UNUSED(op1))
 {
-    s16 ip;
+    s16 ip16;
+    s32 ip32;
 
     START_OF_INSTR();
-	DECODE_PRINTF("CALL\t");
-	ip = (s16) fetch_word_imm();
-	ip += (s16) M.x86.R_IP;    /* CHECK SIGN */
-	DECODE_PRINTF2("%04x\n", (u16)ip);
-	CALL_TRACE(M.x86.saved_cs, M.x86.saved_ip, M.x86.R_CS, ip, "");
+    DECODE_PRINTF("CALL\t");
+    if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+	ip32 = (s32) fetch_long_imm();
+	ip32 += (s16) M.x86.R_IP;    /* CHECK SIGN */
+	DECODE_PRINTF2("%04x\n", (u16)ip32);
+	CALL_TRACE(M.x86.saved_cs, M.x86.saved_ip, M.x86.R_CS, ip32, "");
+    } else {
+	ip16 = (s16) fetch_word_imm();
+	ip16 += (s16) M.x86.R_IP;    /* CHECK SIGN */
+	DECODE_PRINTF2("%04x\n", (u16)ip16);
+	CALL_TRACE(M.x86.saved_cs, M.x86.saved_ip, M.x86.R_CS, ip16, "");
+    }
     TRACE_AND_STEP();
-    push_word(M.x86.R_IP);
-    M.x86.R_IP = ip;
+    if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+	push_long(M.x86.R_EIP);
+	M.x86.R_EIP = ip32 & 0xffff;
+    } else {
+	push_word(M.x86.R_IP);
+	M.x86.R_EIP = ip16;
+    }
     DECODE_CLEAR_SEGOVR();
     END_OF_INSTR();
 }
@@ -9718,16 +9740,21 @@ Handles opcode 0xea
 ****************************************************************************/
 static void x86emuOp_jump_far_IMM(u8 X86EMU_UNUSED(op1))
 {
-    u16 cs, ip;
+    u16 cs;
+    u32 ip;
 
     START_OF_INSTR();
     DECODE_PRINTF("JMP\tFAR ");
-    ip = fetch_word_imm();
+    if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+	ip = fetch_long_imm();
+    } else {
+	ip = fetch_word_imm();
+    }
     cs = fetch_word_imm();
     DECODE_PRINTF2("%04x:", cs);
     DECODE_PRINTF2("%04x\n", ip);
     TRACE_AND_STEP();
-    M.x86.R_IP = ip;
+    M.x86.R_EIP = ip & 0xffff;
     M.x86.R_CS = cs;
     DECODE_CLEAR_SEGOVR();
     END_OF_INSTR();
commit 261d0d16af797bb52d4c778e220296d7f2b28e14
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Thu Dec 30 16:08:48 2010 -0800

    Fix asprintf typo in commit d2c42b10
    
    Reported-by: Jerome Carretero <cJ at zougloub.eu>
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Cyril Brulebois <kibi at debian.org>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/hw/xfree86/dixmods/extmod/modinit.c b/hw/xfree86/dixmods/extmod/modinit.c
index 168795d..a415e5f 100644
--- a/hw/xfree86/dixmods/extmod/modinit.c
+++ b/hw/xfree86/dixmods/extmod/modinit.c
@@ -146,7 +146,7 @@ extmodSetup(pointer module, pointer opts, int *errmaj, int *errmin)
     for (i = 0; extensionModules[i].name != NULL; i++) {
 	if (opts) {
 	    char *s;
-	    if (Xasprinf(&s, "omit%s", extensionModules[i].name) != -1) {
+	    if (asprintf(&s, "omit%s", extensionModules[i].name) != -1) {
 		pointer o;
 		o = xf86FindOption(opts, s);
 		free(s);
commit c6afe64bad7a27ff8828de499d56776c113df60f
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Dec 31 03:15:27 2010 +0000

    XFree86: Linux: AGP: Fix void-pointer-arithmetic warning
    
    Cast it to a char *, mimicking the return immediately below it.
    
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>
    Reviewed-by: Mark Kettenis <kettenis at openbsd.org>

diff --git a/hw/xfree86/os-support/linux/lnx_video.c b/hw/xfree86/os-support/linux/lnx_video.c
index 39c728d..3d45511 100644
--- a/hw/xfree86/os-support/linux/lnx_video.c
+++ b/hw/xfree86/os-support/linux/lnx_video.c
@@ -461,7 +461,7 @@ mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
 		   " (0x%08lx,0x%lx) (%s)\n", Base, Size,
 		   strerror(errno));
     }
-    DebugF("base: %lx aligned base: %lx\n",base, base + alignOff);
+    DebugF("base: %lx aligned base: %lx\n",base, (char *)base + alignOff);
     return (char *)base + alignOff;
 }
 #endif /* !(__sparc__) */
commit 2d67ada3c4079a11c52024a9c3d4138becca5171
Author: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
Date:   Thu Dec 30 19:19:43 2010 +0200

    os: always check if client is local when connection is accepted
    
    LocalClient is used for all DRI2 requests that makes it frequently
    called function. Querying if connection is local or not takes 10-15us
    (on ARM) depending on malloc speed.
    
    Signed-off-by: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/os/access.c b/os/access.c
index 494986e..eb1a21d 100644
--- a/os/access.c
+++ b/os/access.c
@@ -1028,20 +1028,19 @@ ResetHosts (char *display)
 }
 
 /* Is client on the local host */
-Bool LocalClient(ClientPtr client)
+Bool
+ComputeLocalClient(ClientPtr client)
 {
     int    		alen, family, notused;
     Xtransaddr		*from = NULL;
     pointer		addr;
     register HOST	*host;
+    OsCommPtr           oc = (OsCommPtr) client->osPrivate;
 
-    if (!client->osPrivate)
-        return FALSE;
-    if (!((OsCommPtr)client->osPrivate)->trans_conn)
+    if (!oc->trans_conn)
         return FALSE;
 
-    if (!_XSERVTransGetPeerAddr (((OsCommPtr)client->osPrivate)->trans_conn,
-	&notused, &alen, &from))
+    if (!_XSERVTransGetPeerAddr (oc->trans_conn, &notused, &alen, &from))
     {
 	family = ConvertAddr ((struct sockaddr *) from,
 	    &alen, (pointer *)&addr);
@@ -1067,6 +1066,13 @@ Bool LocalClient(ClientPtr client)
     return FALSE;
 }
 
+Bool LocalClient(ClientPtr client)
+{
+    if (!client->osPrivate)
+        return FALSE;
+    return ((OsCommPtr)client->osPrivate)->local_client;
+}
+
 /*
  * Return the uid and gid of a connected local client
  * 
diff --git a/os/connection.c b/os/connection.c
index 5452ae1..5580fab 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -746,6 +746,7 @@ AllocNewConnection (XtransConnInfo trans_conn, int fd, CARD32 conn_time)
 	free(oc);
 	return NullClient;
     }
+    oc->local_client = ComputeLocalClient(client);
 #if !defined(WIN32)
     ConnectionTranslation[fd] = client->index;
 #else
diff --git a/os/osdep.h b/os/osdep.h
index 3c0e78f..087e36d 100644
--- a/os/osdep.h
+++ b/os/osdep.h
@@ -172,6 +172,7 @@ typedef struct _osComm {
     XID	auth_id;		/* authorization id */
     CARD32 conn_time;		/* timestamp if not established, else 0  */
     struct _XtransConnInfo *trans_conn; /* transport connection object */
+    Bool local_client;
 } OsCommRec, *OsCommPtr;
 
 extern int FlushClient(
@@ -217,6 +218,9 @@ typedef long int fd_mask;
 #define ffs mffs
 extern int mffs(fd_mask);
 
+/* in access.c */
+extern Bool ComputeLocalClient(ClientPtr client);
+
 /* in auth.c */
 extern void GenerateRandomData (int len, char *buf);
 
commit 617b7d22115ccaaaa7ec69c99885054d33a3bc37
Author: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
Date:   Thu Dec 30 19:19:42 2010 +0200

    os: Fix a memory leak
    
    Signed-off-by: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/os/access.c b/os/access.c
index d43fdf8..494986e 100644
--- a/os/access.c
+++ b/os/access.c
@@ -1057,8 +1057,10 @@ Bool LocalClient(ClientPtr client)
 	}
 	for (host = selfhosts; host; host = host->next)
 	{
-	    if (addrEqual (family, addr, alen, host))
+	    if (addrEqual (family, addr, alen, host)) {
+		free(from);
 		return TRUE;
+	    }
 	}
 	free(from);
     }
commit 3e1455505addc7e52178fa04399aef2a8522c921
Author: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
Date:   Thu Dec 30 19:19:41 2010 +0200

    udev: Fix removing of the wake up handler
    
    RemoveBlockAndWakeupHandlers requires caller to pass same block data
    parameter as for RegisterBlockAndWakeupHandlers.
    
    Signed-off-by: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/config/udev.c b/config/udev.c
index e401894..ab27c98 100644
--- a/config/udev.c
+++ b/config/udev.c
@@ -314,7 +314,7 @@ config_udev_fini(void)
     udev = udev_monitor_get_udev(udev_monitor);
 
     RemoveGeneralSocket(udev_monitor_get_fd(udev_monitor));
-    RemoveBlockAndWakeupHandlers(block_handler, wakeup_handler, udev_monitor);
+    RemoveBlockAndWakeupHandlers(block_handler, wakeup_handler, NULL);
     udev_monitor_unref(udev_monitor);
     udev_monitor = NULL;
     udev_unref(udev);
commit 13ac3deedb532b39f41dcd45d70f9eb4a85c1f58
Author: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
Date:   Thu Dec 30 19:19:40 2010 +0200

    mi: Only register sprite block handler when needed
    
    miSpriteBlockHandler takes about 10us in arm each time BlockHandlers are
    called. To eliminate that overhead from xserver side only register the
    BlockHandler when there actually is any cursor down.
    
    Signed-off-by: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/mi/misprite.c b/mi/misprite.c
index 1a76d20..c25c093 100644
--- a/mi/misprite.c
+++ b/mi/misprite.c
@@ -256,6 +256,15 @@ static void miSpriteRestoreCursor(DeviceIntPtr pDev,
                                  ScreenPtr pScreen);
 
 static void
+miSpriteRegisterBlockHandler(ScreenPtr pScreen, miSpriteScreenPtr pScreenPriv)
+{
+    if (!pScreenPriv->BlockHandler) {
+        pScreenPriv->BlockHandler = pScreen->BlockHandler;
+        pScreen->BlockHandler = miSpriteBlockHandler;
+    }
+}
+
+static void
 miSpriteReportDamage (DamagePtr pDamage, RegionPtr pRegion, void *closure)
 {
     ScreenPtr		    pScreen = closure;
@@ -332,7 +341,7 @@ miSpriteInitialize (ScreenPtr               pScreen,
     pScreenPriv->InstallColormap = pScreen->InstallColormap;
     pScreenPriv->StoreColors = pScreen->StoreColors;
 
-    pScreenPriv->BlockHandler = pScreen->BlockHandler;
+    pScreenPriv->BlockHandler = NULL;
 
     pScreenPriv->DeviceCursorInitialize = pScreen->DeviceCursorInitialize;
     pScreenPriv->DeviceCursorCleanup = pScreen->DeviceCursorCleanup;
@@ -359,8 +368,6 @@ miSpriteInitialize (ScreenPtr               pScreen,
     pScreen->InstallColormap = miSpriteInstallColormap;
     pScreen->StoreColors = miSpriteStoreColors;
 
-    pScreen->BlockHandler = miSpriteBlockHandler;
-
     return TRUE;
 }
 
@@ -382,7 +389,6 @@ miSpriteCloseScreen (int i, ScreenPtr pScreen)
     pScreen->GetImage = pScreenPriv->GetImage;
     pScreen->GetSpans = pScreenPriv->GetSpans;
     pScreen->SourceValidate = pScreenPriv->SourceValidate;
-    pScreen->BlockHandler = pScreenPriv->BlockHandler;
     pScreen->InstallColormap = pScreenPriv->InstallColormap;
     pScreen->StoreColors = pScreenPriv->StoreColors;
 
@@ -555,12 +561,7 @@ miSpriteBlockHandler (int i, pointer blockData, pointer pTimeout,
     miSpriteScreenPtr	pPriv = GetSpriteScreen(pScreen);
     DeviceIntPtr            pDev;
     miCursorInfoPtr         pCursorInfo;
-
-    SCREEN_PROLOGUE(pPriv, pScreen, BlockHandler);
-
-    (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask);
-
-    SCREEN_EPILOGUE(pPriv, pScreen, BlockHandler);
+    Bool                WorkToDo = FALSE;
 
     for(pDev = inputInfo.devices; pDev; pDev = pDev->next)
     {
@@ -587,9 +588,20 @@ miSpriteBlockHandler (int i, pointer blockData, pointer pTimeout,
             {
                 SPRITE_DEBUG (("BlockHandler restore\n"));
                 miSpriteRestoreCursor (pDev, pScreen);
+                if (!pCursorInfo->isUp)
+                    WorkToDo = TRUE;
             }
         }
     }
+
+    SCREEN_PROLOGUE(pPriv, pScreen, BlockHandler);
+
+    (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask);
+
+    if (WorkToDo)
+        SCREEN_EPILOGUE(pPriv, pScreen, BlockHandler);
+    else
+        pPriv->BlockHandler = NULL;
 }
 
 static void
@@ -798,6 +810,8 @@ miSpriteSetCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
     if (!pPointer->shouldBeUp)
 	pScreenPriv->numberOfCursors++;
     pPointer->shouldBeUp = TRUE;
+    if (!pPointer->isUp)
+	miSpriteRegisterBlockHandler(pScreen, pScreenPriv);
     if (pPointer->x == x &&
 	pPointer->y == y &&
 	pPointer->pCursor == pCursor &&
@@ -898,6 +912,7 @@ miSpriteRemoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen)
     pCursorInfo = MISPRITE(pDev);
 
     miSpriteIsDown(pCursorInfo);
+    miSpriteRegisterBlockHandler(pScreen, pScreenPriv);
     pCursorInfo->pCacheWin = NullWindow;
     miSpriteDisableDamage(pScreen, pScreenPriv);
     if (!miDCRestoreUnderCursor(pDev,
commit 4f6e3b0f378d7306dbd8c00ef9a7df81e24e5769
Author: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
Date:   Thu Dec 30 19:19:39 2010 +0200

    mi: Register sprite damage handler only when required
    
    There is no need to have damage handler registered when there isn't any
    pointer in the screen. This avoids some overhead from damage handling
    which takes tens of microseconds on arm.
    
    Signed-off-by: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/mi/misprite.c b/mi/misprite.c
index a269705..1a76d20 100644
--- a/mi/misprite.c
+++ b/mi/misprite.c
@@ -96,6 +96,7 @@ typedef struct {
     VisualPtr	    pVisual;
     DamagePtr	    pDamage;		/* damage tracking structure */
     Bool            damageRegistered;
+    int             numberOfCursors;
 } miSpriteScreenRec, *miSpriteScreenPtr;
 
 #define SOURCE_COLOR	0
@@ -345,6 +346,7 @@ miSpriteInitialize (ScreenPtr               pScreen,
     pScreenPriv->colors[MASK_COLOR].green = 0;
     pScreenPriv->colors[MASK_COLOR].blue = 0;
     pScreenPriv->damageRegistered = 0;
+    pScreenPriv->numberOfCursors = 0;
 
     dixSetPrivate(&pScreen->devPrivates, miSpriteScreenKey, pScreenPriv);
 
@@ -772,21 +774,29 @@ static void
 miSpriteSetCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
                    CursorPtr pCursor, int x, int y)
 {
-    miCursorInfoPtr pPointer;
+    miCursorInfoPtr     pPointer;
+    miSpriteScreenPtr   pScreenPriv;
 
     if (!IsMaster(pDev) && !pDev->u.master)
         return;
 
     pPointer = MISPRITE(pDev);
+    pScreenPriv = GetSpriteScreen(pScreen);
 
     if (!pCursor)
     {
+	if (pPointer->shouldBeUp)
+	    --pScreenPriv->numberOfCursors;
     	pPointer->shouldBeUp = FALSE;
     	if (pPointer->isUp)
 	    miSpriteRemoveCursor (pDev, pScreen);
+	if (pScreenPriv->numberOfCursors == 0)
+	    miSpriteDisableDamage(pScreen, pScreenPriv);
 	pPointer->pCursor = 0;
 	return;
     }
+    if (!pPointer->shouldBeUp)
+	pScreenPriv->numberOfCursors++;
     pPointer->shouldBeUp = TRUE;
     if (pPointer->x == x &&
 	pPointer->y == y &&
commit bf48082f30818b96bc623834be3022600371d4fc
Author: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
Date:   Thu Dec 30 19:19:38 2010 +0200

    mi: Fix the debug message
    
    Signed-off-by: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/mi/misprite.c b/mi/misprite.c
index e5dbf1d..a269705 100644
--- a/mi/misprite.c
+++ b/mi/misprite.c
@@ -569,7 +569,7 @@ miSpriteBlockHandler (int i, pointer blockData, pointer pTimeout,
                     && pCursorInfo->pScreen == pScreen
                     && pCursorInfo->shouldBeUp)
             {
-                SPRITE_DEBUG (("BlockHandler restore\n"));
+                SPRITE_DEBUG (("BlockHandler save"));
                 miSpriteSaveUnderCursor (pDev, pScreen);
             }
         }
commit 8fb43b8bf9fcbe015d4e98c7e09889184d136a1e
Author: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
Date:   Thu Dec 30 19:19:37 2010 +0200

    mi: Fix wrapping for sprite screen
    
    SCREEN_EPILOGUE should read the current function pointer from screen
    after calling wrapped function in case the pointer changes.
    
    Passing pPriv to macros instead of asking dix each time makes sense when
    both macros need same pointer.
    
    Signed-off-by: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/mi/misprite.c b/mi/misprite.c
index d1cf2bb..e5dbf1d 100644
--- a/mi/misprite.c
+++ b/mi/misprite.c
@@ -216,11 +216,10 @@ static Bool         miSpriteDeviceCursorInitialize(DeviceIntPtr pDev,
 static void         miSpriteDeviceCursorCleanup(DeviceIntPtr pDev,
                                                 ScreenPtr pScreen);
 
-#define SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = \
-   ((miSpriteScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, \
-					miSpriteScreenKey))->field)
-#define SCREEN_EPILOGUE(pScreen, field)\
-    ((pScreen)->field = miSprite##field)
+#define SCREEN_PROLOGUE(pPriv, pScreen, field) ((pScreen)->field = \
+   (pPriv)->field)
+#define SCREEN_EPILOGUE(pPriv, pScreen, field)\
+    ((pPriv)->field = (pScreen)->field, (pScreen)->field = miSprite##field)
 
 /*
  * pointer-sprite method table
@@ -397,11 +396,12 @@ miSpriteGetImage (DrawablePtr pDrawable, int sx, int sy, int w, int h,
                   unsigned int format, unsigned long planemask,
                   char *pdstLine)
 {
-    ScreenPtr	    pScreen = pDrawable->pScreen;
-    DeviceIntPtr    pDev;
-    miCursorInfoPtr pCursorInfo;
+    ScreenPtr           pScreen = pDrawable->pScreen;
+    DeviceIntPtr        pDev;
+    miCursorInfoPtr     pCursorInfo;
+    miSpriteScreenPtr   pPriv = GetSpriteScreen(pScreen);
 
-    SCREEN_PROLOGUE (pScreen, GetImage);
+    SCREEN_PROLOGUE (pPriv, pScreen, GetImage);
 
     if (pDrawable->type == DRAWABLE_WINDOW)
     {
@@ -424,7 +424,7 @@ miSpriteGetImage (DrawablePtr pDrawable, int sx, int sy, int w, int h,
     (*pScreen->GetImage) (pDrawable, sx, sy, w, h,
 			  format, planemask, pdstLine);
 
-    SCREEN_EPILOGUE (pScreen, GetImage);
+    SCREEN_EPILOGUE (pPriv, pScreen, GetImage);
 }
 
 static void
@@ -434,8 +434,9 @@ miSpriteGetSpans (DrawablePtr pDrawable, int wMax, DDXPointPtr ppt,
     ScreenPtr		    pScreen = pDrawable->pScreen;
     DeviceIntPtr            pDev;
     miCursorInfoPtr         pCursorInfo;
+    miSpriteScreenPtr       pPriv = GetSpriteScreen(pScreen);
 
-    SCREEN_PROLOGUE (pScreen, GetSpans);
+    SCREEN_PROLOGUE (pPriv, pScreen, GetSpans);
 
     if (pDrawable->type == DRAWABLE_WINDOW)
     {
@@ -475,7 +476,7 @@ miSpriteGetSpans (DrawablePtr pDrawable, int wMax, DDXPointPtr ppt,
 
     (*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
 
-    SCREEN_EPILOGUE (pScreen, GetSpans);
+    SCREEN_EPILOGUE (pPriv, pScreen, GetSpans);
 }
 
 static void
@@ -485,8 +486,9 @@ miSpriteSourceValidate (DrawablePtr pDrawable, int x, int y, int width,
     ScreenPtr		    pScreen = pDrawable->pScreen;
     DeviceIntPtr            pDev;
     miCursorInfoPtr         pCursorInfo;
+    miSpriteScreenPtr       pPriv = GetSpriteScreen(pScreen);
 
-    SCREEN_PROLOGUE (pScreen, SourceValidate);
+    SCREEN_PROLOGUE (pPriv, pScreen, SourceValidate);
 
     if (pDrawable->type == DRAWABLE_WINDOW)
     {
@@ -509,7 +511,7 @@ miSpriteSourceValidate (DrawablePtr pDrawable, int x, int y, int width,
     if (pScreen->SourceValidate)
 	(*pScreen->SourceValidate) (pDrawable, x, y, width, height);
 
-    SCREEN_EPILOGUE (pScreen, SourceValidate);
+    SCREEN_EPILOGUE (pPriv, pScreen, SourceValidate);
 }
 
 static void
@@ -518,8 +520,9 @@ miSpriteCopyWindow (WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
     ScreenPtr	pScreen = pWindow->drawable.pScreen;
     DeviceIntPtr            pDev;
     miCursorInfoPtr         pCursorInfo;
+    miSpriteScreenPtr       pPriv = GetSpriteScreen(pScreen);
 
-    SCREEN_PROLOGUE (pScreen, CopyWindow);
+    SCREEN_PROLOGUE (pPriv, pScreen, CopyWindow);
 
     for(pDev = inputInfo.devices; pDev; pDev = pDev->next)
     {
@@ -539,7 +542,7 @@ miSpriteCopyWindow (WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
     }
 
     (*pScreen->CopyWindow) (pWindow, ptOldOrg, prgnSrc);
-    SCREEN_EPILOGUE (pScreen, CopyWindow);
+    SCREEN_EPILOGUE (pPriv, pScreen, CopyWindow);
 }
 
 static void
@@ -551,11 +554,11 @@ miSpriteBlockHandler (int i, pointer blockData, pointer pTimeout,
     DeviceIntPtr            pDev;
     miCursorInfoPtr         pCursorInfo;
 
-    SCREEN_PROLOGUE(pScreen, BlockHandler);
+    SCREEN_PROLOGUE(pPriv, pScreen, BlockHandler);
 
     (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask);
 
-    SCREEN_EPILOGUE(pScreen, BlockHandler);
+    SCREEN_EPILOGUE(pPriv, pScreen, BlockHandler);
 
     for(pDev = inputInfo.devices; pDev; pDev = pDev->next)
     {
@@ -593,11 +596,11 @@ miSpriteInstallColormap (ColormapPtr pMap)
     ScreenPtr		pScreen = pMap->pScreen;
     miSpriteScreenPtr	pPriv = GetSpriteScreen(pScreen);
 
-    SCREEN_PROLOGUE(pScreen, InstallColormap);
+    SCREEN_PROLOGUE(pPriv, pScreen, InstallColormap);
 
     (*pScreen->InstallColormap) (pMap);
 
-    SCREEN_EPILOGUE(pScreen, InstallColormap);
+    SCREEN_EPILOGUE(pPriv, pScreen, InstallColormap);
 
     /* InstallColormap can be called before devices are initialized. */
     pPriv->pInstalledMap = pMap;
@@ -630,11 +633,11 @@ miSpriteStoreColors (ColormapPtr pMap, int ndef, xColorItem *pdef)
     DeviceIntPtr        pDev;
     miCursorInfoPtr     pCursorInfo;
 
-    SCREEN_PROLOGUE(pScreen, StoreColors);
+    SCREEN_PROLOGUE(pPriv, pScreen, StoreColors);
 
     (*pScreen->StoreColors) (pMap, ndef, pdef);
 
-    SCREEN_EPILOGUE(pScreen, StoreColors);
+    SCREEN_EPILOGUE(pPriv, pScreen, StoreColors);
 
     if (pPriv->pColormap == pMap)
     {
commit 4be2a6d1b33fac7ceb50ad1de249a1acd5a46ab0
Author: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
Date:   Thu Dec 30 19:19:36 2010 +0200

    mi: Add GetSpriteScreen macro to hide dixLookupPrivate
    
    Signed-off-by: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/mi/misprite.c b/mi/misprite.c
index 38a6b93..d1cf2bb 100644
--- a/mi/misprite.c
+++ b/mi/misprite.c
@@ -184,6 +184,8 @@ miSpriteIsDown(miCursorInfoPtr pDevCursor)
 
 static DevPrivateKeyRec miSpriteScreenKeyRec;
 #define miSpriteScreenKey (&miSpriteScreenKeyRec)
+#define GetSpriteScreen(pScreen) \
+	(dixLookupPrivate(&(pScreen)->devPrivates, miSpriteScreenKey))
 static DevPrivateKeyRec miSpriteDevPrivatesKeyRec;
 #define miSpriteDevPrivatesKey (&miSpriteDevPrivatesKeyRec)
 
@@ -373,9 +375,8 @@ miSpriteInitialize (ScreenPtr               pScreen,
 static Bool
 miSpriteCloseScreen (int i, ScreenPtr pScreen)
 {
-    miSpriteScreenPtr   pScreenPriv;
+    miSpriteScreenPtr   pScreenPriv = GetSpriteScreen(pScreen);
 
-    pScreenPriv = dixLookupPrivate(&pScreen->devPrivates, miSpriteScreenKey);
     pScreen->CloseScreen = pScreenPriv->CloseScreen;
     pScreen->GetImage = pScreenPriv->GetImage;
     pScreen->GetSpans = pScreenPriv->GetSpans;
@@ -546,11 +547,10 @@ miSpriteBlockHandler (int i, pointer blockData, pointer pTimeout,
                       pointer pReadmask)
 {
     ScreenPtr		pScreen = screenInfo.screens[i];
-    miSpriteScreenPtr	pPriv;
+    miSpriteScreenPtr	pPriv = GetSpriteScreen(pScreen);
     DeviceIntPtr            pDev;
     miCursorInfoPtr         pCursorInfo;
 
-    pPriv = dixLookupPrivate(&pScreen->devPrivates, miSpriteScreenKey);
     SCREEN_PROLOGUE(pScreen, BlockHandler);
 
     (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask);
@@ -591,9 +591,8 @@ static void
 miSpriteInstallColormap (ColormapPtr pMap)
 {
     ScreenPtr		pScreen = pMap->pScreen;
-    miSpriteScreenPtr	pPriv;
+    miSpriteScreenPtr	pPriv = GetSpriteScreen(pScreen);
 
-    pPriv = dixLookupPrivate(&pScreen->devPrivates, miSpriteScreenKey);
     SCREEN_PROLOGUE(pScreen, InstallColormap);
 
     (*pScreen->InstallColormap) (pMap);
@@ -624,14 +623,13 @@ static void
 miSpriteStoreColors (ColormapPtr pMap, int ndef, xColorItem *pdef)
 {
     ScreenPtr		pScreen = pMap->pScreen;
-    miSpriteScreenPtr	pPriv;
+    miSpriteScreenPtr	pPriv = GetSpriteScreen(pScreen);
     int			i;
     int			updated;
     VisualPtr		pVisual;
     DeviceIntPtr        pDev;
     miCursorInfoPtr     pCursorInfo;
 
-    pPriv = dixLookupPrivate(&pScreen->devPrivates, miSpriteScreenKey);
     SCREEN_PROLOGUE(pScreen, StoreColors);
 
     (*pScreen->StoreColors) (pMap, ndef, pdef);
@@ -706,8 +704,7 @@ miSpriteStoreColors (ColormapPtr pMap, int ndef, xColorItem *pdef)
 static void
 miSpriteFindColors (miCursorInfoPtr pDevCursor, ScreenPtr pScreen)
 {
-    miSpriteScreenPtr   pScreenPriv =
-	dixLookupPrivate(&pScreen->devPrivates, miSpriteScreenKey);
+    miSpriteScreenPtr	pScreenPriv = GetSpriteScreen(pScreen);
     CursorPtr		pCursor;
     xColorItem		*sourceColor, *maskColor;
 
@@ -884,7 +881,7 @@ miSpriteRemoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen)
         return;
 
     DamageDrawInternal (pScreen, TRUE);
-    pScreenPriv = dixLookupPrivate(&pScreen->devPrivates, miSpriteScreenKey);
+    pScreenPriv = GetSpriteScreen(pScreen);
     pCursorInfo = MISPRITE(pDev);
 
     miSpriteIsDown(pCursorInfo);
@@ -922,7 +919,7 @@ miSpriteSaveUnderCursor(DeviceIntPtr pDev, ScreenPtr pScreen)
         return;
 
     DamageDrawInternal (pScreen, TRUE);
-    pScreenPriv = dixLookupPrivate(&pScreen->devPrivates, miSpriteScreenKey);
+    pScreenPriv = GetSpriteScreen(pScreen);
     pCursorInfo = MISPRITE(pDev);
 
     miSpriteComputeSaved (pDev, pScreen);
@@ -963,7 +960,7 @@ miSpriteRestoreCursor (DeviceIntPtr pDev, ScreenPtr pScreen)
         return;
 
     DamageDrawInternal (pScreen, TRUE);
-    pScreenPriv = dixLookupPrivate(&pScreen->devPrivates, miSpriteScreenKey);
+    pScreenPriv = GetSpriteScreen(pScreen);
     pCursorInfo = MISPRITE(pDev);
 
     miSpriteComputeSaved (pDev, pScreen);
commit ed8db09b4bff5c4a8d8056808368650e1876547b
Author: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
Date:   Thu Dec 30 19:19:35 2010 +0200

    composite: Remove unnecessary variable.
    
    We know that there is damage if the dynamic block handler is registered.
    
    Signed-off-by: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/composite/compalloc.c b/composite/compalloc.c
index e628c45..86a6f8e 100644
--- a/composite/compalloc.c
+++ b/composite/compalloc.c
@@ -50,14 +50,8 @@
 static void
 compScreenUpdate (ScreenPtr pScreen)
 {
-    CompScreenPtr   cs = GetCompScreen (pScreen);
-
     compCheckTree (pScreen);
-    if (cs->damaged)
-    {
-	compWindowUpdate (pScreen->root);
-	cs->damaged = FALSE;
-    }
+    compWindowUpdate (pScreen->root);
 }
 
 static void
@@ -85,11 +79,9 @@ compReportDamage (DamagePtr pDamage, RegionPtr pRegion, void *closure)
     CompScreenPtr   cs = GetCompScreen (pScreen);
     CompWindowPtr   cw = GetCompWindow (pWin);
 
-    if (!cs->damaged) {
+    if (!cs->BlockHandler) {
         cs->BlockHandler = pScreen->BlockHandler;
         pScreen->BlockHandler = compBlockHandler;
-
-        cs->damaged = TRUE;
     }
     cw->damaged = TRUE;
 }
diff --git a/composite/compinit.c b/composite/compinit.c
index 885cc73..276ed75 100644
--- a/composite/compinit.c
+++ b/composite/compinit.c
@@ -301,7 +301,6 @@ compScreenInit (ScreenPtr pScreen)
     if (!cs)
 	return FALSE;
 
-    cs->damaged = FALSE;
     cs->overlayWid = FakeClientID(0);
     cs->pOverlayWin = NULL;
     cs->pOverlayClients = NULL;
diff --git a/composite/compint.h b/composite/compint.h
index 9ba5dd0..4b058e7 100644
--- a/composite/compint.h
+++ b/composite/compint.h
@@ -152,7 +152,6 @@ typedef struct _CompScreen {
 
     ScreenBlockHandlerProcPtr	BlockHandler;
     CloseScreenProcPtr		CloseScreen;
-    Bool			damaged;
     int				numAlternateVisuals;
     VisualID			*alternateVisuals;
 
commit c038b8b28e5c436cd31bea7a3bef2c8c9d818b58
Author: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
Date:   Thu Dec 30 19:19:34 2010 +0200

    composite: Only register the block handler when it is required
    
    Even calling block handler that doesn't do much is costly in arm. It
    takes a few microseconds each time which adds up to relative high CPU
    time because it is done 500+ times per second.
    
    Simple optimization is to register the block handler only when it is
    required.
    
    Signed-off-by: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/composite/compalloc.c b/composite/compalloc.c
index 93571ee..e628c45 100644
--- a/composite/compalloc.c
+++ b/composite/compalloc.c
@@ -48,6 +48,36 @@
 #include "compint.h"
 
 static void
+compScreenUpdate (ScreenPtr pScreen)
+{
+    CompScreenPtr   cs = GetCompScreen (pScreen);
+
+    compCheckTree (pScreen);
+    if (cs->damaged)
+    {
+	compWindowUpdate (pScreen->root);
+	cs->damaged = FALSE;
+    }
+}
+
+static void
+compBlockHandler (int	    i,
+		  pointer   blockData,
+		  pointer   pTimeout,
+		  pointer   pReadmask)
+{
+    ScreenPtr	    pScreen = screenInfo.screens[i];
+    CompScreenPtr   cs = GetCompScreen (pScreen);
+
+    pScreen->BlockHandler = cs->BlockHandler;
+    compScreenUpdate (pScreen);
+    (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask);
+
+    /* Next damage will restore the block handler */
+    cs->BlockHandler = NULL;
+}
+
+static void
 compReportDamage (DamagePtr pDamage, RegionPtr pRegion, void *closure)
 {
     WindowPtr	    pWin = (WindowPtr) closure;
@@ -55,7 +85,12 @@ compReportDamage (DamagePtr pDamage, RegionPtr pRegion, void *closure)
     CompScreenPtr   cs = GetCompScreen (pScreen);
     CompWindowPtr   cw = GetCompWindow (pWin);
 
-    cs->damaged = TRUE;
+    if (!cs->damaged) {
+        cs->BlockHandler = pScreen->BlockHandler;
+        pScreen->BlockHandler = compBlockHandler;
+
+        cs->damaged = TRUE;
+    }
     cw->damaged = TRUE;
 }
 
diff --git a/composite/compinit.c b/composite/compinit.c
index 159f7c2..885cc73 100644
--- a/composite/compinit.c
+++ b/composite/compinit.c
@@ -61,7 +61,6 @@ compCloseScreen (int index, ScreenPtr pScreen)
     free(cs->alternateVisuals);
 
     pScreen->CloseScreen = cs->CloseScreen;
-    pScreen->BlockHandler = cs->BlockHandler;
     pScreen->InstallColormap = cs->InstallColormap;
     pScreen->ChangeWindowAttributes = cs->ChangeWindowAttributes;
     pScreen->ReparentWindow = cs->ReparentWindow;
@@ -130,35 +129,6 @@ compChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
     return ret;
 }
 
-static void
-compScreenUpdate (ScreenPtr pScreen)
-{
-    CompScreenPtr   cs = GetCompScreen (pScreen);
-
-    compCheckTree (pScreen);
-    if (cs->damaged)
-    {
-	compWindowUpdate (pScreen->root);
-	cs->damaged = FALSE;
-    }
-}
-
-static void
-compBlockHandler (int	    i,
-		  pointer   blockData,
-		  pointer   pTimeout,
-		  pointer   pReadmask)
-{
-    ScreenPtr	    pScreen = screenInfo.screens[i];
-    CompScreenPtr   cs = GetCompScreen (pScreen);
-
-    pScreen->BlockHandler = cs->BlockHandler;
-    compScreenUpdate (pScreen);
-    (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask);
-    cs->BlockHandler = pScreen->BlockHandler;
-    pScreen->BlockHandler = compBlockHandler;
-}
-
 /*
  * Add alternate visuals -- always expose an ARGB32 and RGB24 visual
  */
@@ -387,8 +357,7 @@ compScreenInit (ScreenPtr pScreen)
     cs->ChangeWindowAttributes = pScreen->ChangeWindowAttributes;
     pScreen->ChangeWindowAttributes = compChangeWindowAttributes;
 
-    cs->BlockHandler = pScreen->BlockHandler;
-    pScreen->BlockHandler = compBlockHandler;
+    cs->BlockHandler = NULL;
 
     cs->CloseScreen = pScreen->CloseScreen;
     pScreen->CloseScreen = compCloseScreen;
commit 6d0e9e5d6e1b847961ab52a11aae96981a1cf1c0
Author: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
Date:   Thu Dec 30 19:19:33 2010 +0200

    render: Enable animated cursor block handler only when needed
    
    Calling BlockHandlers takes some time for each iteration in main loop
    which adds up quickly over multiple request. To reduce the round-trip
    costs to xserver BlockHandlers should be registered only when required.
    
    AnimCurScreenBlockHandler is the first victim for this optimization.
    
    Signed-off-by: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/render/animcur.c b/render/animcur.c
index 1a8ca43..31cbab9 100644
--- a/render/animcur.c
+++ b/render/animcur.c
@@ -95,8 +95,6 @@ AnimCurCloseScreen (int index, ScreenPtr pScreen)
     Bool                ret;
 
     Unwrap(as, pScreen, CloseScreen);
-    
-    Unwrap(as, pScreen, BlockHandler);
 
     Unwrap(as, pScreen, CursorLimits);
     Unwrap(as, pScreen, DisplayCursor);
@@ -196,7 +194,10 @@ AnimCurScreenBlockHandler (int screenNum,
 
     Unwrap (as, pScreen, BlockHandler);
     (*pScreen->BlockHandler) (screenNum, blockData, pTimeout, pReadmask);
-    Wrap (as, pScreen, BlockHandler, AnimCurScreenBlockHandler);
+    if (activeDevice)
+        Wrap (as, pScreen, BlockHandler, AnimCurScreenBlockHandler);
+    else
+        as->BlockHandler = NULL;
 }
 
 static Bool
@@ -222,6 +223,9 @@ AnimCurDisplayCursor (DeviceIntPtr pDev,
 		pDev->spriteInfo->anim.time = GetTimeInMillis () + ac->elts[0].delay;
 		pDev->spriteInfo->anim.pCursor = pCursor;
 		pDev->spriteInfo->anim.pScreen = pScreen;
+
+		if (!as->BlockHandler)
+		    Wrap(as, pScreen, BlockHandler, AnimCurScreenBlockHandler);
 	    }
 	}
 	else
@@ -248,8 +252,12 @@ AnimCurSetCursorPosition (DeviceIntPtr pDev,
     Bool		ret;
     
     Unwrap (as, pScreen, SetCursorPosition);
-    if (pDev->spriteInfo->anim.pCursor)
+    if (pDev->spriteInfo->anim.pCursor) {
 	pDev->spriteInfo->anim.pScreen = pScreen;
+
+	if (!as->BlockHandler)
+	    Wrap(as, pScreen, BlockHandler, AnimCurScreenBlockHandler);
+    }
     ret = (*pScreen->SetCursorPosition) (pDev, pScreen, x, y, generateEvent);
     Wrap (as, pScreen, SetCursorPosition, AnimCurSetCursorPosition);
     return ret;
@@ -334,7 +342,7 @@ AnimCurInit (ScreenPtr pScreen)
 	return FALSE;
     Wrap(as, pScreen, CloseScreen, AnimCurCloseScreen);
 
-    Wrap(as, pScreen, BlockHandler, AnimCurScreenBlockHandler);
+    as->BlockHandler = NULL;
 
     Wrap(as, pScreen, CursorLimits, AnimCurCursorLimits);
     Wrap(as, pScreen, DisplayCursor, AnimCurDisplayCursor);
commit aa8cea953dc66bcf4cb4d08f2681f9e6cb1bc8c5
Author: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
Date:   Thu Dec 30 19:19:32 2010 +0200

    render: Don't filter 0 return from GetTimeInMillis
    
    In animate cursor block handler code assumes GetTimeInMillis returns
    always nonzero value. This isn't true when time wraps around.
    
    To prevent any problems in case GetTimeInMillis would return zero use
    activeDevice variable to track if we have received time.
    
    Signed-off-by: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/render/animcur.c b/render/animcur.c
index 2160f50..1a8ca43 100644
--- a/render/animcur.c
+++ b/render/animcur.c
@@ -150,6 +150,7 @@ AnimCurScreenBlockHandler (int screenNum,
     ScreenPtr		pScreen = screenInfo.screens[screenNum];
     AnimCurScreenPtr    as = GetAnimCurScreen(pScreen);
     DeviceIntPtr        dev;
+    Bool                activeDevice = FALSE;
     CARD32              now = 0, 
                         soonest = ~0; /* earliest time to wakeup again */
 
@@ -157,7 +158,10 @@ AnimCurScreenBlockHandler (int screenNum,
     {
 	if (IsPointerDevice(dev) && pScreen == dev->spriteInfo->anim.pScreen)
 	{
-	    if (!now) now = GetTimeInMillis (); 
+	    if (!activeDevice) {
+                now = GetTimeInMillis ();
+                activeDevice = TRUE;
+            }
 
 	    if ((INT32) (now - dev->spriteInfo->anim.time) >= 0)
 	    {
@@ -187,7 +191,7 @@ AnimCurScreenBlockHandler (int screenNum,
 	}
     }
 
-    if (now)
+    if (activeDevice)
         AdjustWaitForDelay (pTimeout, soonest - now);
 
     Unwrap (as, pScreen, BlockHandler);
commit 91beeee05f88eed10ab0fd97dc625e96cb7763ba
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Tue Oct 13 16:27:30 2009 +1100

    DIX: Reset window properties when freeing them
    
    This enables us to reliably inspect properties when destroying windows.
    
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>
    Reviewed-by: Fernando Carrijo <fcarrijo at freedesktop.org>

diff --git a/dix/property.c b/dix/property.c
index 1d4332a..a1ae530 100644
--- a/dix/property.c
+++ b/dix/property.c
@@ -424,6 +424,9 @@ DeleteAllWindowProperties(WindowPtr pWin)
 	dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY);
 	pProp = pNextProp;
     }
+
+    if (pWin->optional)
+        pWin->optional->userProps = NULL;
 }
 
 static int
commit 36ebdd361616eedbe4919deae2a4e6f6606ae6b4
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Oct 19 11:59:24 2010 -0400

    linux: warning fix
    
    lnx_agp.c: In function ‘xf86DeallocateGARTMemory’:
    lnx_agp.c:267: warning: cast to pointer from integer of different size
    
    Signed-off-by: Adam Jackson <ajax at redhat.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/hw/xfree86/os-support/linux/lnx_agp.c b/hw/xfree86/os-support/linux/lnx_agp.c
index c65f1e3..a5f0411 100644
--- a/hw/xfree86/os-support/linux/lnx_agp.c
+++ b/hw/xfree86/os-support/linux/lnx_agp.c
@@ -264,7 +264,7 @@ xf86DeallocateGARTMemory(int screenNum, int key)
 	}
 
 #ifdef __linux__
-	if (ioctl(gartFd, AGPIOC_DEALLOCATE, (int *)key) != 0) {
+	if (ioctl(gartFd, AGPIOC_DEALLOCATE, (int *)(uintptr_t)key) != 0) {
 #else
 	if (ioctl(gartFd, AGPIOC_DEALLOCATE, &key) != 0) {
 #endif
commit 63ccaec2c39f4b5742383472c951ee2cd35c9e14
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Oct 19 11:59:23 2010 -0400

    glx: warning fixes
    
    render2.c: In function ‘__glXDisp_Map2d’:
    render2.c:127: warning: ‘u1’ may be used uninitialized in this function
    render2.c: In function ‘__glXDisp_Map1d’:
    render2.c:90: warning: ‘u1’ may be used uninitialized in this function
    
    Remove unnecessary test, and change memcpy to memmove as all users were
    doing overlapping copies.
    
    Signed-off-by: Adam Jackson <ajax at redhat.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/glx/unpack.h b/glx/unpack.h
index a4e6d7e..738e79d 100644
--- a/glx/unpack.h
+++ b/glx/unpack.h
@@ -47,7 +47,7 @@
 ** Fetch a double from potentially unaligned memory.
 */
 #ifdef __GLX_ALIGN64
-#define __GLX_MEM_COPY(dst,src,n)	if (src != NULL && dst != NULL) memcpy(dst,src,n)
+#define __GLX_MEM_COPY(dst,src,n)	memmove(dst,src,n)
 #define __GLX_GET_DOUBLE(dst,src)	__GLX_MEM_COPY(&dst,src,8)
 #else
 #define __GLX_GET_DOUBLE(dst,src)	(dst) = *((GLdouble*)(src))
diff --git a/hw/dmx/glxProxy/unpack.h b/hw/dmx/glxProxy/unpack.h
index f34b6fd..f4a9572 100644
--- a/hw/dmx/glxProxy/unpack.h
+++ b/hw/dmx/glxProxy/unpack.h
@@ -43,7 +43,7 @@
 ** Fetch a double from potentially unaligned memory.
 */
 #ifdef __GLX_ALIGN64
-#define __GLX_MEM_COPY(dst,src,n)	memcpy(dst,src,n)
+#define __GLX_MEM_COPY(dst,src,n)	memmove(dst,src,n)
 #define __GLX_GET_DOUBLE(dst,src)	__GLX_MEM_COPY(&dst,src,8)
 #else
 #define __GLX_GET_DOUBLE(dst,src)	(dst) = *((GLdouble*)(src))
commit d057e265c862f90e9b6fddff89f40cb82b2a59b1
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Oct 19 11:59:22 2010 -0400

    xcmisc: warning fix
    
    xcmisc.c:202: warning: no previous prototype for ‘XCMiscExtensionInit’
    
    Signed-off-by: Adam Jackson <ajax at redhat.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/hw/xfree86/dixmods/extmod/modinit.h b/hw/xfree86/dixmods/extmod/modinit.h
index 1154e46..5bbbb88 100644
--- a/hw/xfree86/dixmods/extmod/modinit.h
+++ b/hw/xfree86/dixmods/extmod/modinit.h
@@ -18,6 +18,10 @@ extern void XTestExtensionInit(INITARGS);
 extern void XTestExtension1Init(INITARGS);
 #endif
 
+#if 1
+extern void XCMiscExtensionInit(INITARGS);
+#endif
+
 #ifdef SCREENSAVER
 extern void ScreenSaverExtensionInit (INITARGS);
 #include <X11/extensions/saver.h>
commit 67e0bcba4307de5a330e027f4504c9aed4987e5a
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Oct 19 11:59:21 2010 -0400

    dri1: warning fix
    
    dri.c: In function ‘DRIScreenInit’:
    dri.c:434: warning: cast from pointer to integer of different size
    
    Signed-off-by: Adam Jackson <ajax at redhat.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c
index 1d83630..3c64ae4 100644
--- a/hw/xfree86/dri/dri.c
+++ b/hw/xfree86/dri/dri.c
@@ -431,7 +431,7 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD)
     if (!pDRIPriv->pDriverInfo->dontMapFrameBuffer)
     {
 	if (drmAddMap( pDRIPriv->drmFD,
-		       (drm_handle_t)pDRIPriv->pDriverInfo->frameBufferPhysicalAddress,
+		       (uintptr_t)pDRIPriv->pDriverInfo->frameBufferPhysicalAddress,
 		       pDRIPriv->pDriverInfo->frameBufferSize,
 		       DRM_FRAME_BUFFER,
 		       0,
commit a298d044f965e5ba91f178c6b599c1df26a958ba
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Oct 19 11:59:20 2010 -0400

    loader: warning fix
    
    loadmod.c: In function ‘FreeSubdirs’:
    loadmod.c:377: warning: passing argument 1 of ‘free’ discards qualifiers
    from pointer target type
    /usr/include/stdlib.h:488: note: expected ‘void *’ but argument is of
    type ‘const char *’
    
    Signed-off-by: Adam Jackson <ajax at redhat.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c
index 3b3511c..eaa99e8 100644
--- a/hw/xfree86/loader/loadmod.c
+++ b/hw/xfree86/loader/loadmod.c
@@ -374,7 +374,7 @@ FreeSubdirs(const char **subdirs)
 
     if (subdirs) {
 	for (s = subdirs; *s; s++)
-	    free(*s);
+	    free((char *)*s);
 	free(subdirs);
     }
 }
commit ee0b1b564413327c73bb8cdbabb76667ca4a744c
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Oct 19 11:59:18 2010 -0400

    config: warning fixes
    
    xf86AutoConfig.c: In function ‘FreeList’:
    xf86AutoConfig.c:123: warning: passing argument 1 of ‘free’ discards
    qualifiers from pointer target type
    /usr/include/stdlib.h:488: note: expected ‘void *’ but argument is of
    type ‘const char *’
    
    Signed-off-by: Adam Jackson <ajax at redhat.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/hw/xfree86/common/xf86AutoConfig.c b/hw/xfree86/common/xf86AutoConfig.c
index eb61f87..5c6e721 100644
--- a/hw/xfree86/common/xf86AutoConfig.c
+++ b/hw/xfree86/common/xf86AutoConfig.c
@@ -120,7 +120,7 @@ FreeList(const char ***list, int *lines)
     int i;
 
     for (i = 0; i < *lines; i++) {
-	free((*list)[i]);
+	free((char *)((*list)[i]));
     }
     free(*list);
     *list = NULL;
commit 32c85ad4b8fe27fed0c494f69c39e3902ce57b1b
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Tue Dec 28 12:40:31 2010 +0000

    GLX: DRI2: Fix mismatched-types warning
    
    All the DRI extension types have a base extension type as their first
    member to avoid exactly these types of warning.
    
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>
    Reviewed-by: Mark Kettenis <kettenis at openbsd.org>
    Reviewed-by: Cyril Brulebois <kibi at debian.org>

diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index 1111183..8d21c93 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -594,7 +594,7 @@ static const __DRIextension *loader_extensions[] = {
     &systemTimeExtension.base,
     &loaderExtension.base,
 #ifdef __DRI_USE_INVALIDATE
-    &dri2UseInvalidate,
+    &dri2UseInvalidate.base,
 #endif
     NULL
 };
commit 22796cfa4805cc9551e1b3fa1d3e2e1bfae5bad1
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Tue Dec 28 12:29:53 2010 +0000

    udev: Add strdups to kill const warnings
    
    InputAttributes wants non-const members, and while it appears safe to
    cast it, just leave it be for the moment.
    
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>
    Reviewed-by: Dan Nicholson <dbn.lists at gmail.com>

diff --git a/config/udev.c b/config/udev.c
index 496bfbf..e401894 100644
--- a/config/udev.c
+++ b/config/udev.c
@@ -94,6 +94,7 @@ device_added(struct udev_device *udev_device)
     if (parent) {
         const char *ppath = udev_device_get_devnode(parent);
         const char *product = udev_device_get_property_value(parent, "PRODUCT");
+        const char *pnp_id = udev_device_get_sysattr_value(parent, "id");
         unsigned int usb_vendor, usb_model;
 
         name = udev_device_get_sysattr_value(parent, "name");
@@ -103,8 +104,9 @@ device_added(struct udev_device *udev_device)
             LOG_PROPERTY(ppath, "NAME", name);
         }
 
-        attrs.pnp_id = udev_device_get_sysattr_value(parent, "id");
-        LOG_SYSATTR(ppath, "id", attrs.pnp_id);
+        if (pnp_id)
+            attrs.pnp_id = strdup(pnp_id);
+        LOG_SYSATTR(ppath, "id", pnp_id);
 
         /* construct USB ID in lowercase hex - "0000:ffff" */
         if (product && sscanf(product, "%*x/%4x/%4x/%*x", &usb_vendor, &usb_model) == 2) {
@@ -118,12 +120,13 @@ device_added(struct udev_device *udev_device)
     if (!name)
         name = "(unnamed)";
     else
-        attrs.product = name;
+        attrs.product = strdup(name);
     add_option(&options, "name", name);
 
     add_option(&options, "path", path);
     add_option(&options, "device", path);
-    attrs.device = path;
+    if (path)
+        attrs.device = strdup(path);
 
     tags_prop = udev_device_get_property_value(udev_device, "ID_INPUT.tags");
     LOG_PROPERTY(path, "ID_INPUT.tags", tags_prop);
@@ -162,7 +165,7 @@ device_added(struct udev_device *udev_device)
                 add_option(&options, "xkb_options", value);
         } else if (!strcmp(key, "ID_VENDOR")) {
             LOG_PROPERTY(path, key, value);
-            attrs.vendor = value;
+            attrs.vendor = strdup(value);
         } else if (!strcmp(key, "ID_INPUT_KEY")) {
             LOG_PROPERTY(path, key, value);
             attrs.flags |= ATTR_KEYBOARD;
@@ -202,6 +205,10 @@ device_added(struct udev_device *udev_device)
     }
 
     free(attrs.usb_id);
+    free(attrs.pnp_id);
+    free(attrs.product);
+    free(attrs.device);
+    free(attrs.vendor);
     if (attrs.tags) {
         char **tag = attrs.tags;
         while (*tag) {
commit 03f2eb1e156796afb70118d7f7f60ac61beed026
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Dec 17 17:13:34 2010 +0000

    Input: Set client error value for invalid mask bits
    
    When we send BadValue back to the client for having invalid mask bits,
    at least tell them what the (first) invalid bit was.
    
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/Xi/xigrabdev.c b/Xi/xigrabdev.c
index 24ededc..0adc878 100644
--- a/Xi/xigrabdev.c
+++ b/Xi/xigrabdev.c
@@ -79,7 +79,7 @@ ProcXIGrabDevice(ClientPtr client)
     if (!IsMaster(dev))
         stuff->paired_device_mode = GrabModeAsync;
 
-    if (XICheckInvalidMaskBits((unsigned char*)&stuff[1],
+    if (XICheckInvalidMaskBits(client, (unsigned char*)&stuff[1],
                                stuff->mask_len * 4) != Success)
         return BadValue;
 
diff --git a/Xi/xipassivegrab.c b/Xi/xipassivegrab.c
index 2966145..e99b6e5 100644
--- a/Xi/xipassivegrab.c
+++ b/Xi/xipassivegrab.c
@@ -118,7 +118,7 @@ ProcXIPassiveGrabDevice(ClientPtr client)
         return BadValue;
     }
 
-    if (XICheckInvalidMaskBits((unsigned char*)&stuff[1],
+    if (XICheckInvalidMaskBits(client, (unsigned char*)&stuff[1],
                                stuff->mask_len * 4) != Success)
         return BadValue;
 
diff --git a/Xi/xiselectev.c b/Xi/xiselectev.c
index 7aa3f0a..22fbaf5 100644
--- a/Xi/xiselectev.c
+++ b/Xi/xiselectev.c
@@ -42,14 +42,19 @@
  *
  * @return BadValue if at least one invalid bit is set or Success otherwise.
  */
-int XICheckInvalidMaskBits(unsigned char *mask, int len)
+int XICheckInvalidMaskBits(ClientPtr client, unsigned char *mask, int len)
 {
     if (len >= XIMaskLen(XI2LASTEVENT))
     {
         int i;
         for (i = XI2LASTEVENT + 1; i < len * 8; i++)
+        {
             if (BitIsOn(mask, i))
+            {
+                client->errorValue = i;
                 return BadValue;
+            }
+        }
     }
 
     return Success;
@@ -126,7 +131,10 @@ ProcXISelectEvents(ClientPtr client)
         {
             unsigned char *bits = (unsigned char*)&evmask[1];
             if (BitIsOn(bits, XI_HierarchyChanged))
+            {
+                client->errorValue = XI_HierarchyChanged;
                 return BadValue;
+            }
         }
 
         /* Raw events may only be selected on root windows */
@@ -138,10 +146,13 @@ ProcXISelectEvents(ClientPtr client)
                 BitIsOn(bits, XI_RawButtonPress) ||
                 BitIsOn(bits, XI_RawButtonRelease) ||
                 BitIsOn(bits, XI_RawMotion))
+            {
+                client->errorValue = XI_RawKeyPress;
                 return BadValue;
+            }
         }
 
-        if (XICheckInvalidMaskBits((unsigned char*)&evmask[1],
+        if (XICheckInvalidMaskBits(client, (unsigned char*)&evmask[1],
                                    evmask->mask_len * 4) != Success)
             return BadValue;
 
diff --git a/include/exevents.h b/include/exevents.h
index bfee385..dc59430 100644
--- a/include/exevents.h
+++ b/include/exevents.h
@@ -307,6 +307,6 @@ XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client,
                            unsigned int len, unsigned char* mask);
 
 extern int
-XICheckInvalidMaskBits(unsigned char *mask, int len);
+XICheckInvalidMaskBits(ClientPtr client, unsigned char *mask, int len);
 
 #endif /* EXEVENTS_H */
commit 47818287983b04625661b08ae362e0966cddf3e1
Author: Chase Douglas <chase.douglas at canonical.com>
Date:   Fri Dec 17 17:13:30 2010 +0000

    Make EventIsDeliverable non-static
    
    Will be used outside dix/events.c in proceeding XI 2.1 MT changes.
    
    Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/events.c b/dix/events.c
index 4e2dd89..f280f9d 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -2290,17 +2290,6 @@ FixUpEventFromWindow(
 }
 
 /**
- * Return masks for EventIsDeliverable.
- * @defgroup EventIsDeliverable return flags
- * @{
- */
-#define XI_MASK                 (1 << 0) /**< XI mask set on window */
-#define CORE_MASK               (1 << 1) /**< Core mask set on window */
-#define DONT_PROPAGATE_MASK     (1 << 2) /**< DontPropagate mask set on window */
-#define XI2_MASK                (1 << 3) /**< XI2 mask set on window */
-/* @} */
-
-/**
  * Check if a given event is deliverable at all on a given window.
  *
  * This function only checks if any client wants it, not for a specific
@@ -2313,7 +2302,7 @@ FixUpEventFromWindow(
  * @return Bitmask of ::XI2_MASK, ::XI_MASK, ::CORE_MASK, and
  * ::DONT_PROPAGATE_MASK.
  */
-static int
+int
 EventIsDeliverable(DeviceIntPtr dev, InternalEvent* event, WindowPtr win)
 {
     int rc = 0;
diff --git a/include/input.h b/include/input.h
index fef69a1..9f3227f 100644
--- a/include/input.h
+++ b/include/input.h
@@ -532,6 +532,18 @@ void FixUpEventFromWindow(DeviceIntPtr pDev,
                           WindowPtr pWin,
                           Window child,
                           Bool calcChild);
+extern int EventIsDeliverable(DeviceIntPtr dev, InternalEvent* event,
+                              WindowPtr win);
+/**
+ * Return masks for EventIsDeliverable.
+ * @defgroup EventIsDeliverable return flags
+ * @{
+ */
+#define XI_MASK                 (1 << 0) /**< XI mask set on window */
+#define CORE_MASK               (1 << 1) /**< Core mask set on window */
+#define DONT_PROPAGATE_MASK     (1 << 2) /**< DontPropagate mask set on window */
+#define XI2_MASK                (1 << 3) /**< XI2 mask set on window */
+/* @} */
 
 /* Implemented by the DDX. */
 extern _X_EXPORT int NewInputDeviceRequest(
commit f7d8ade3c5ac44faf7f3ea0d846e35f75b31c9ec
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Dec 17 17:13:26 2010 +0000

    Resources: Move rClient to resource.h
    
    The definition of rClient was duplicated across three source files, so
    move it to resource.h.
    
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/Xext/geext.c b/Xext/geext.c
index 8319c92..b37c1a0 100644
--- a/Xext/geext.c
+++ b/Xext/geext.c
@@ -33,8 +33,6 @@
 #include "geext.h"
 #include "protocol-versions.h"
 
-#define rClient(obj) (clients[CLIENT_ID((obj)->resource)])
-
 DevPrivateKeyRec GEClientPrivateKeyRec;
 
 int RT_GECLIENT  = 0;
diff --git a/Xext/security.c b/Xext/security.c
index 7eb95de..8673880 100644
--- a/Xext/security.c
+++ b/Xext/security.c
@@ -154,8 +154,6 @@ SecurityLookupRequestName(ClientPtr client)
 }
 
 
-#define rClient(obj) (clients[CLIENT_ID((obj)->resource)])
-
 /* SecurityDeleteAuthorization
  *
  * Arguments:
diff --git a/dix/events.c b/dix/events.c
index ac07923..4e2dd89 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -195,8 +195,6 @@ typedef const char *string;
 #define XE_KBPTR (xE->u.keyButtonPointer)
 
 
-#define rClient(obj) (clients[CLIENT_ID((obj)->resource)])
-
 CallbackListPtr EventCallback;
 CallbackListPtr DeviceEventCallback;
 
diff --git a/include/resource.h b/include/resource.h
index 0c5a59d..080061f 100644
--- a/include/resource.h
+++ b/include/resource.h
@@ -121,6 +121,8 @@ typedef unsigned long RESTYPE;
 
 #define BAD_RESOURCE 0xe0000000
 
+#define rClient(obj) (clients[CLIENT_ID((obj)->resource)])
+
 /* Resource state callback */
 extern _X_EXPORT CallbackListPtr ResourceStateCallback;
 
commit 05e437c2ce230b588362f012c06ead5c6d89c006
Author: Chase Douglas <chase.douglas at canonical.com>
Date:   Fri Dec 17 17:13:27 2010 +0000

    Export all valuator_mask_* functions
    
    Input drivers may use valuator masks for internal state. Having all the
    valuator_mask_* functions available will help.
    
    Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>
    
    Bump ABI_XINPUT_VERSION minor.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h
index af7b778..609819b 100644
--- a/hw/xfree86/common/xf86Module.h
+++ b/hw/xfree86/common/xf86Module.h
@@ -83,7 +83,7 @@ typedef enum {
  */
 #define ABI_ANSIC_VERSION	SET_ABI_VERSION(0, 4)
 #define ABI_VIDEODRV_VERSION	SET_ABI_VERSION(9, 0)
-#define ABI_XINPUT_VERSION	SET_ABI_VERSION(12, 0)
+#define ABI_XINPUT_VERSION	SET_ABI_VERSION(12, 1)
 #define ABI_EXTENSION_VERSION	SET_ABI_VERSION(5, 0)
 #define ABI_FONT_VERSION	SET_ABI_VERSION(0, 6)
 
diff --git a/include/input.h b/include/input.h
index 8feac28..fef69a1 100644
--- a/include/input.h
+++ b/include/input.h
@@ -554,7 +554,6 @@ extern _X_HIDDEN void valuator_set_mode(DeviceIntPtr dev, int axis, int mode);
    xfixes/cursor.c uses it to determine if the cursor is enabled */
 extern Bool EnableCursor;
 
-/* For server-internal functions, see inpututil.h */
 extern _X_EXPORT ValuatorMask  *valuator_mask_new(int num_valuators);
 extern _X_EXPORT void valuator_mask_set_range(ValuatorMask *mask,
                                        int first_valuator, int num_valuators,
@@ -563,5 +562,12 @@ extern _X_EXPORT void valuator_mask_set(ValuatorMask *mask,
                                         int valuator,
                                         int data);
 extern _X_EXPORT void valuator_mask_zero(ValuatorMask *mask);
+extern _X_EXPORT int valuator_mask_size(const ValuatorMask *mask);
+extern _X_EXPORT int valuator_mask_isset(const ValuatorMask *mask, int bit);
+extern _X_EXPORT void valuator_mask_unset(ValuatorMask *mask, int bit);
+extern _X_EXPORT int valuator_mask_num_valuators(const ValuatorMask *mask);
+extern _X_EXPORT void valuator_mask_copy(ValuatorMask *dest,
+                                         const ValuatorMask *src);
+extern _X_EXPORT int valuator_mask_get(const ValuatorMask *mask, int valnum);
 
 #endif /* INPUT_H */
diff --git a/include/inpututils.h b/include/inpututils.h
index 54b5764..b8ca6ab 100644
--- a/include/inpututils.h
+++ b/include/inpututils.h
@@ -37,12 +37,4 @@ struct _ValuatorMask {
     int         valuators[MAX_VALUATORS]; /* valuator data */
 };
 
-/* server-internal */
-extern _X_HIDDEN int valuator_mask_size(const ValuatorMask *mask);
-extern _X_HIDDEN int valuator_mask_isset(const ValuatorMask *mask, int bit);
-extern _X_HIDDEN void valuator_mask_unset(ValuatorMask *mask, int bit);
-extern _X_HIDDEN int valuator_mask_num_valuators(const ValuatorMask *mask);
-extern _X_HIDDEN void valuator_mask_copy(ValuatorMask *dest, const ValuatorMask *src);
-extern _X_HIDDEN int valuator_mask_get(const ValuatorMask *mask, int valnum);
-
 #endif
commit 2e781457d43ec4bf0d633257ac6852cde3b00541
Author: Ville Syrjälä <ville.syrjala at nokia.com>
Date:   Thu Dec 16 18:22:13 2010 +0200

    xfree86/modes: Take rotation into account when checking mode size
    
    Assume that a mode can be used in either landscape or portrait
    orientation. I suppose the correct thing to do would be to
    collect all the supported rotations from the CRTCs that can be used
    with a specific output, but that information doesn't seem to be
    readily available when these checks are done. So just assume that
    either orientation is fine.
    
    Signed-off-by: Ville Syrjälä <ville.syrjala at nokia.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/modes/xf86Modes.c b/hw/xfree86/modes/xf86Modes.c
index 75584cf..c2dc3dc 100644
--- a/hw/xfree86/modes/xf86Modes.c
+++ b/hw/xfree86/modes/xf86Modes.c
@@ -355,15 +355,32 @@ xf86ValidateModesSize(ScrnInfoPtr pScrn, DisplayModePtr modeList,
 {
     DisplayModePtr mode;
 
-    for (mode = modeList; mode != NULL; mode = mode->next) {
-	if (maxPitch > 0 && mode->HDisplay > maxPitch)
-	    mode->status = MODE_BAD_WIDTH;
-
-	if (maxX > 0 && mode->HDisplay > maxX)
-	    mode->status = MODE_VIRTUAL_X;
+    if (maxPitch <= 0)
+	    maxPitch = MAXINT;
+    if (maxX <= 0)
+	    maxX = MAXINT;
+    if (maxY <= 0)
+	    maxY = MAXINT;
 
-	if (maxY > 0 && mode->VDisplay > maxY)
-	    mode->status = MODE_VIRTUAL_Y;
+    for (mode = modeList; mode != NULL; mode = mode->next) {
+	if ((xf86ModeWidth(mode, RR_Rotate_0) > maxPitch ||
+	     xf86ModeWidth(mode, RR_Rotate_0) > maxX ||
+	     xf86ModeHeight(mode, RR_Rotate_0) > maxY) &&
+	    (xf86ModeWidth(mode, RR_Rotate_90) > maxPitch ||
+	     xf86ModeWidth(mode, RR_Rotate_90) > maxX ||
+	     xf86ModeHeight(mode, RR_Rotate_90) > maxY)) {
+	    if (xf86ModeWidth(mode, RR_Rotate_0) > maxPitch ||
+		xf86ModeWidth(mode, RR_Rotate_90) > maxPitch)
+		mode->status = MODE_BAD_WIDTH;
+
+	    if (xf86ModeWidth(mode, RR_Rotate_0) > maxX ||
+		xf86ModeWidth(mode, RR_Rotate_90) > maxX)
+		mode->status = MODE_VIRTUAL_X;
+
+	    if (xf86ModeHeight(mode, RR_Rotate_0) > maxY ||
+		xf86ModeHeight(mode, RR_Rotate_90) > maxY)
+		mode->status = MODE_VIRTUAL_Y;
+	}
 
 	if (mode->next == modeList)
 	    break;
commit 0ce25fd7904c792924c3e0ee6fc21a5f1bec1a68
Author: Ville Syrjälä <ville.syrjala at nokia.com>
Date:   Fri Dec 3 17:42:16 2010 +0200

    dri2: Don't page flip when the window size doesn't match the pixmap size
    
    If the drawable size doesn't match the pixmap size page flipping should
    not be allowed.
    
    If the window is larger than the pixmap, page flipping might need to
    reposition the CRTC somewhere in the middle of the pixmap. I didn't
    spot any code that would handle that at least in the intel driver.
    
    Also the root pixmap could then move to some negative screen
    coordinates. Not sure if all bits of code could handle that. Perhaps
    when composite is enabled screen_x/y would make it work, but without
    composite there's no way that it would work AFAICS.
    
    Signed-off-by: Ville Syrjälä <ville.syrjala at nokia.com>
    Reviewed-by: Alex Deucher <alexdeucher at gmail.com>

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index e4693d9..39996f9 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -640,6 +640,17 @@ DRI2CanFlip(DrawablePtr pDraw)
     if (!RegionEqual(&pWin->clipList, &pRoot->winSize))
 	return FALSE;
 
+    /* Does the window match the pixmap exactly? */
+    if (pDraw->x != 0 ||
+	pDraw->y != 0 ||
+#ifdef COMPOSITE
+	pDraw->x != pWinPixmap->screen_x ||
+	pDraw->y != pWinPixmap->screen_y ||
+#endif
+	pDraw->width != pWinPixmap->drawable.width ||
+	pDraw->height != pWinPixmap->drawable.height)
+	return FALSE;
+
     return TRUE;
 }
 
commit efcb63d0ce43f96d0ac02b6f4a480dfd2374fc84
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Dec 23 13:33:00 2010 +0000

    Render: Fix 'comparing between distinct pointer types' warning
    
    Add the appropriate casts so that gcc shuts up, even if it doesn't
    matter.
    
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>
    Reviewed-by: Tiago Vignatti <tiago.vignatti at nokia.com>

diff --git a/render/render.c b/render/render.c
index 0bbbae8..7029558 100644
--- a/render/render.c
+++ b/render/render.c
@@ -1084,8 +1084,10 @@ ProcRenderAddGlyphs (ClientPtr client)
     remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs;
 
     /* protect against bad nglyphs */
-    if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) ||
-        bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) {
+    if (gi < ((xGlyphInfo *)stuff) ||
+        gi > ((xGlyphInfo *)((CARD32 *)stuff + client->req_len)) ||
+        bits < ((CARD8 *)stuff) ||
+        bits > ((CARD8 *)((CARD32 *)stuff + client->req_len))) {
         err = BadLength;
         goto bail;
     }
commit 469d5bf8b75038631c27edbb0f9cdf7d737fa233
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Dec 17 16:48:45 2010 +0000

    mi: Sync: Don't free managed screen private
    
    misync allocates space for its screen private with
    dixRegisterPrivateKey, which means it doesn't have to free it at
    CloseScreen time; doing so will, in fact, result in a crash.
    
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>
    Reviewed-by: James Jones <jajones at nvidia.com>
    Acked-by: Tiago Vignatti <tiago.vignatti at nokia.com>

diff --git a/miext/sync/misync.c b/miext/sync/misync.c
index bcc68a2..50226d9 100644
--- a/miext/sync/misync.c
+++ b/miext/sync/misync.c
@@ -167,7 +167,6 @@ SyncCloseScreen (int i, ScreenPtr pScreen)
     SyncScreenPrivPtr pScreenPriv = SYNC_SCREEN_PRIV(pScreen);
 
     pScreen->CloseScreen = pScreenPriv->CloseScreen;
-    free(pScreenPriv);
 
     return (*pScreen->CloseScreen) (i, pScreen);
 }
commit 44adb31bfece29260a9bbd9075c9212ebf00d24d
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Aug 27 20:36:37 2010 +1000

    GetTimeInMillis: Use CLOCK_MONOTONIC_COARSE where available
    
    On some systems, using CLOCK_MONOTONIC forces a readback of HPET or some
    similarly expensive timer.  CLOCK_MONOTONIC_COARSE can alleviate this,
    at the cost of negligibly-reduced resolution, so prefer that where we
    can.
    
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>
    Reviewed-by: Julien Cristau <jcristau at debian.org>
    Reviewed-by: Tiago Vignatti <tiago.vignatti at nokia.com>

diff --git a/os/utils.c b/os/utils.c
index afdff0c..18fd911 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -427,7 +427,21 @@ GetTimeInMillis(void)
 
 #ifdef MONOTONIC_CLOCK
     struct timespec tp;
-    if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
+    static clockid_t clockid;
+    if (!clockid) {
+#ifdef CLOCK_MONOTONIC_COARSE
+        if (clock_getres(CLOCK_MONOTONIC_COARSE, &tp) == 0 &&
+            (tp.tv_nsec / 1000) <= 1000 &&
+            clock_gettime(CLOCK_MONOTONIC_COARSE, &tp) == 0)
+            clockid = CLOCK_MONOTONIC_COARSE;
+        else
+#endif
+        if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
+            clockid = CLOCK_MONOTONIC;
+        else
+            clockid = ~0L;
+    }
+    if (clockid != ~0L && clock_gettime(clockid, &tp) == 0)
         return (tp.tv_sec * 1000) + (tp.tv_nsec / 1000000L);
 #endif
 
commit b01dd9d33651999b0390bf8ed412b84f6929a13e
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Dec 17 17:13:34 2010 +0000

    Input: Set client error value for invalid mask bits
    
    When we send BadValue back to the client for having invalid mask bits,
    at least tell them what the (first) invalid bit was.
    
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/Xi/xigrabdev.c b/Xi/xigrabdev.c
index 24ededc..0adc878 100644
--- a/Xi/xigrabdev.c
+++ b/Xi/xigrabdev.c
@@ -79,7 +79,7 @@ ProcXIGrabDevice(ClientPtr client)
     if (!IsMaster(dev))
         stuff->paired_device_mode = GrabModeAsync;
 
-    if (XICheckInvalidMaskBits((unsigned char*)&stuff[1],
+    if (XICheckInvalidMaskBits(client, (unsigned char*)&stuff[1],
                                stuff->mask_len * 4) != Success)
         return BadValue;
 
diff --git a/Xi/xipassivegrab.c b/Xi/xipassivegrab.c
index 2966145..e99b6e5 100644
--- a/Xi/xipassivegrab.c
+++ b/Xi/xipassivegrab.c
@@ -118,7 +118,7 @@ ProcXIPassiveGrabDevice(ClientPtr client)
         return BadValue;
     }
 
-    if (XICheckInvalidMaskBits((unsigned char*)&stuff[1],
+    if (XICheckInvalidMaskBits(client, (unsigned char*)&stuff[1],
                                stuff->mask_len * 4) != Success)
         return BadValue;
 
diff --git a/Xi/xiselectev.c b/Xi/xiselectev.c
index 7aa3f0a..22fbaf5 100644
--- a/Xi/xiselectev.c
+++ b/Xi/xiselectev.c
@@ -42,14 +42,19 @@
  *
  * @return BadValue if at least one invalid bit is set or Success otherwise.
  */
-int XICheckInvalidMaskBits(unsigned char *mask, int len)
+int XICheckInvalidMaskBits(ClientPtr client, unsigned char *mask, int len)
 {
     if (len >= XIMaskLen(XI2LASTEVENT))
     {
         int i;
         for (i = XI2LASTEVENT + 1; i < len * 8; i++)
+        {
             if (BitIsOn(mask, i))
+            {
+                client->errorValue = i;
                 return BadValue;
+            }
+        }
     }
 
     return Success;
@@ -126,7 +131,10 @@ ProcXISelectEvents(ClientPtr client)
         {
             unsigned char *bits = (unsigned char*)&evmask[1];
             if (BitIsOn(bits, XI_HierarchyChanged))
+            {
+                client->errorValue = XI_HierarchyChanged;
                 return BadValue;
+            }
         }
 
         /* Raw events may only be selected on root windows */
@@ -138,10 +146,13 @@ ProcXISelectEvents(ClientPtr client)
                 BitIsOn(bits, XI_RawButtonPress) ||
                 BitIsOn(bits, XI_RawButtonRelease) ||
                 BitIsOn(bits, XI_RawMotion))
+            {
+                client->errorValue = XI_RawKeyPress;
                 return BadValue;
+            }
         }
 
-        if (XICheckInvalidMaskBits((unsigned char*)&evmask[1],
+        if (XICheckInvalidMaskBits(client, (unsigned char*)&evmask[1],
                                    evmask->mask_len * 4) != Success)
             return BadValue;
 
diff --git a/include/exevents.h b/include/exevents.h
index bfee385..dc59430 100644
--- a/include/exevents.h
+++ b/include/exevents.h
@@ -307,6 +307,6 @@ XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client,
                            unsigned int len, unsigned char* mask);
 
 extern int
-XICheckInvalidMaskBits(unsigned char *mask, int len);
+XICheckInvalidMaskBits(ClientPtr client, unsigned char *mask, int len);
 
 #endif /* EXEVENTS_H */
commit 495e0142a77152c4cde5c88cdba4103ddc94df2c
Author: Chase Douglas <chase.douglas at canonical.com>
Date:   Fri Dec 17 17:13:30 2010 +0000

    Make EventIsDeliverable non-static
    
    Will be used outside dix/events.c in proceeding XI 2.1 MT changes.
    
    Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/events.c b/dix/events.c
index 4e2dd89..f280f9d 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -2290,17 +2290,6 @@ FixUpEventFromWindow(
 }
 
 /**
- * Return masks for EventIsDeliverable.
- * @defgroup EventIsDeliverable return flags
- * @{
- */
-#define XI_MASK                 (1 << 0) /**< XI mask set on window */
-#define CORE_MASK               (1 << 1) /**< Core mask set on window */
-#define DONT_PROPAGATE_MASK     (1 << 2) /**< DontPropagate mask set on window */
-#define XI2_MASK                (1 << 3) /**< XI2 mask set on window */
-/* @} */
-
-/**
  * Check if a given event is deliverable at all on a given window.
  *
  * This function only checks if any client wants it, not for a specific
@@ -2313,7 +2302,7 @@ FixUpEventFromWindow(
  * @return Bitmask of ::XI2_MASK, ::XI_MASK, ::CORE_MASK, and
  * ::DONT_PROPAGATE_MASK.
  */
-static int
+int
 EventIsDeliverable(DeviceIntPtr dev, InternalEvent* event, WindowPtr win)
 {
     int rc = 0;
diff --git a/include/input.h b/include/input.h
index fef69a1..9f3227f 100644
--- a/include/input.h
+++ b/include/input.h
@@ -532,6 +532,18 @@ void FixUpEventFromWindow(DeviceIntPtr pDev,
                           WindowPtr pWin,
                           Window child,
                           Bool calcChild);
+extern int EventIsDeliverable(DeviceIntPtr dev, InternalEvent* event,
+                              WindowPtr win);
+/**
+ * Return masks for EventIsDeliverable.
+ * @defgroup EventIsDeliverable return flags
+ * @{
+ */
+#define XI_MASK                 (1 << 0) /**< XI mask set on window */
+#define CORE_MASK               (1 << 1) /**< Core mask set on window */
+#define DONT_PROPAGATE_MASK     (1 << 2) /**< DontPropagate mask set on window */
+#define XI2_MASK                (1 << 3) /**< XI2 mask set on window */
+/* @} */
 
 /* Implemented by the DDX. */
 extern _X_EXPORT int NewInputDeviceRequest(
commit 4fbe67beb56e5600c1df789c08725c45b9bef0d4
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Dec 17 17:13:26 2010 +0000

    Resources: Move rClient to resource.h
    
    The definition of rClient was duplicated across three source files, so
    move it to resource.h.
    
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/Xext/geext.c b/Xext/geext.c
index 8319c92..b37c1a0 100644
--- a/Xext/geext.c
+++ b/Xext/geext.c
@@ -33,8 +33,6 @@
 #include "geext.h"
 #include "protocol-versions.h"
 
-#define rClient(obj) (clients[CLIENT_ID((obj)->resource)])
-
 DevPrivateKeyRec GEClientPrivateKeyRec;
 
 int RT_GECLIENT  = 0;
diff --git a/Xext/security.c b/Xext/security.c
index 7eb95de..8673880 100644
--- a/Xext/security.c
+++ b/Xext/security.c
@@ -154,8 +154,6 @@ SecurityLookupRequestName(ClientPtr client)
 }
 
 
-#define rClient(obj) (clients[CLIENT_ID((obj)->resource)])
-
 /* SecurityDeleteAuthorization
  *
  * Arguments:
diff --git a/dix/events.c b/dix/events.c
index ac07923..4e2dd89 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -195,8 +195,6 @@ typedef const char *string;
 #define XE_KBPTR (xE->u.keyButtonPointer)
 
 
-#define rClient(obj) (clients[CLIENT_ID((obj)->resource)])
-
 CallbackListPtr EventCallback;
 CallbackListPtr DeviceEventCallback;
 
diff --git a/include/resource.h b/include/resource.h
index 0c5a59d..080061f 100644
--- a/include/resource.h
+++ b/include/resource.h
@@ -121,6 +121,8 @@ typedef unsigned long RESTYPE;
 
 #define BAD_RESOURCE 0xe0000000
 
+#define rClient(obj) (clients[CLIENT_ID((obj)->resource)])
+
 /* Resource state callback */
 extern _X_EXPORT CallbackListPtr ResourceStateCallback;
 
commit 871c1e17e527857cd86b5e517d9a18e5041f00fd
Author: Chase Douglas <chase.douglas at canonical.com>
Date:   Fri Dec 17 17:13:27 2010 +0000

    Export all valuator_mask_* functions
    
    Input drivers may use valuator masks for internal state. Having all the
    valuator_mask_* functions available will help.
    
    Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>
    
    Bump ABI_XINPUT_VERSION minor.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h
index af7b778..609819b 100644
--- a/hw/xfree86/common/xf86Module.h
+++ b/hw/xfree86/common/xf86Module.h
@@ -83,7 +83,7 @@ typedef enum {
  */
 #define ABI_ANSIC_VERSION	SET_ABI_VERSION(0, 4)
 #define ABI_VIDEODRV_VERSION	SET_ABI_VERSION(9, 0)
-#define ABI_XINPUT_VERSION	SET_ABI_VERSION(12, 0)
+#define ABI_XINPUT_VERSION	SET_ABI_VERSION(12, 1)
 #define ABI_EXTENSION_VERSION	SET_ABI_VERSION(5, 0)
 #define ABI_FONT_VERSION	SET_ABI_VERSION(0, 6)
 
diff --git a/include/input.h b/include/input.h
index 8feac28..fef69a1 100644
--- a/include/input.h
+++ b/include/input.h
@@ -554,7 +554,6 @@ extern _X_HIDDEN void valuator_set_mode(DeviceIntPtr dev, int axis, int mode);
    xfixes/cursor.c uses it to determine if the cursor is enabled */
 extern Bool EnableCursor;
 
-/* For server-internal functions, see inpututil.h */
 extern _X_EXPORT ValuatorMask  *valuator_mask_new(int num_valuators);
 extern _X_EXPORT void valuator_mask_set_range(ValuatorMask *mask,
                                        int first_valuator, int num_valuators,
@@ -563,5 +562,12 @@ extern _X_EXPORT void valuator_mask_set(ValuatorMask *mask,
                                         int valuator,
                                         int data);
 extern _X_EXPORT void valuator_mask_zero(ValuatorMask *mask);
+extern _X_EXPORT int valuator_mask_size(const ValuatorMask *mask);
+extern _X_EXPORT int valuator_mask_isset(const ValuatorMask *mask, int bit);
+extern _X_EXPORT void valuator_mask_unset(ValuatorMask *mask, int bit);
+extern _X_EXPORT int valuator_mask_num_valuators(const ValuatorMask *mask);
+extern _X_EXPORT void valuator_mask_copy(ValuatorMask *dest,
+                                         const ValuatorMask *src);
+extern _X_EXPORT int valuator_mask_get(const ValuatorMask *mask, int valnum);
 
 #endif /* INPUT_H */
diff --git a/include/inpututils.h b/include/inpututils.h
index 54b5764..b8ca6ab 100644
--- a/include/inpututils.h
+++ b/include/inpututils.h
@@ -37,12 +37,4 @@ struct _ValuatorMask {
     int         valuators[MAX_VALUATORS]; /* valuator data */
 };
 
-/* server-internal */
-extern _X_HIDDEN int valuator_mask_size(const ValuatorMask *mask);
-extern _X_HIDDEN int valuator_mask_isset(const ValuatorMask *mask, int bit);
-extern _X_HIDDEN void valuator_mask_unset(ValuatorMask *mask, int bit);
-extern _X_HIDDEN int valuator_mask_num_valuators(const ValuatorMask *mask);
-extern _X_HIDDEN void valuator_mask_copy(ValuatorMask *dest, const ValuatorMask *src);
-extern _X_HIDDEN int valuator_mask_get(const ValuatorMask *mask, int valnum);
-
 #endif
commit e06fa804009798ea95efa8babaabb0228dfdfe65
Author: Michel Dänzer <daenzer at vmware.com>
Date:   Wed Dec 22 11:45:36 2010 +0100

    EXA: Fix crash with fill using 1x1 tile of depth < 8 (bug #24703).
    
    Fixes http://bugs.freedesktop.org/show_bug.cgi?id=24703 .
    
    Signed-off-by: Michel Dänzer <daenzer at vmware.com>
    Reviewed-by: Dave Airlie <airlied at redhat.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/exa/exa_accel.c b/exa/exa_accel.c
index 6c677c7..b4c0f83 100644
--- a/exa/exa_accel.c
+++ b/exa/exa_accel.c
@@ -1057,6 +1057,8 @@ exaFillRegionSolid (DrawablePtr	pDrawable, RegionPtr pRegion, Pixel pixel,
 		*(CARD16*)pExaPixmap->sys_ptr = pixel;
 		break;
 	    case 8:
+	    case 4:
+	    case 1:
 		*(CARD8*)pExaPixmap->sys_ptr = pixel;
 	    }
 
diff --git a/exa/exa_unaccel.c b/exa/exa_unaccel.c
index a078cc1..d3c405f 100644
--- a/exa/exa_unaccel.c
+++ b/exa/exa_unaccel.c
@@ -748,6 +748,8 @@ exaGetPixmapFirstPixel (PixmapPtr pPixmap)
 	    return pixel;
 	}
     case 8:
+    case 4:
+    case 1:
 	{
 	    CARD8 pixel;
 


More information about the Xquartz-changes mailing list