[Xquartz-changes] xserver: Branch 'server-1.12-apple' - 21 commits

Jeremy Huddleston jeremyhu at freedesktop.org
Fri Nov 18 11:31:31 PST 2011


Rebased ref, commits from common ancestor:
commit c4eebd633339587d733f60ac3a9e2e4310e12a66
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 eaa21ad..e65a1c0 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -2049,11 +2049,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 57c93fd..127e5c7 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);
     if (pMask)
 	miCompositeSourceValidate (pMask);
     
-    src = image_from_pict (pSrc, FALSE, &src_xoff, &src_yoff);
-    mask = image_from_pict (pMask, FALSE, &msk_xoff, &msk_yoff);
-    dest = image_from_pict (pDst, TRUE, &dst_xoff, &dst_yoff);
+    src = image_from_pict (pSrc, TRUE);
+    mask = image_from_pict (pMask, TRUE);
+    dest = image_from_pict (pDst, TRUE);
 
     if (src && dest && !(pMask && !mask))
     {
 	pixman_image_composite (op, src, mask, dest,
-				xSrc + src_xoff, ySrc + src_yoff,
-				xMask + msk_xoff, yMask + msk_yoff,
-				xDst + dst_xoff, yDst + dst_yoff,
+				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 (
 	(pixman_format_code_t)pict->format,
-	pixmap->drawable.width, pixmap->drawable.height,
+	pict->pDrawable->width, pict->pDrawable->height,
 	(uint32_t *)bits, stride * sizeof (FbStride));
 
     if (!image)
@@ -189,55 +184,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)
@@ -267,8 +240,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);
@@ -301,7 +273,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;
 
@@ -310,7 +283,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)
     {
@@ -331,19 +304,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 0b5a638..fbe2647 100644
--- a/fb/fbtrap.c
+++ b/fb/fbtrap.c
@@ -39,12 +39,11 @@ fbAddTraps (PicturePtr	pPicture,
 	    xTrap	*traps)
 {
     pixman_image_t *image;
-    int dst_xoff, dst_yoff;
 
-    if (!(image = image_from_pict (pPicture, FALSE, &dst_xoff, &dst_yoff)))
+    if (!(image = image_from_pict (pPicture, FALSE)))
 	return;
     
-    pixman_add_traps (image, x_off + dst_xoff, y_off + dst_yoff,
+    pixman_add_traps (image, x_off, y_off,
 		      ntrap, (pixman_trap_t *)traps);
 
     free_pixman_pict (pPicture, image);
@@ -57,14 +56,13 @@ fbRasterizeTrapezoid (PicturePtr    pPicture,
 		      int	    y_off)
 {
     pixman_image_t *image;
-    int	dst_xoff, dst_yoff;
 
-    if (!(image = image_from_pict (pPicture, FALSE, &dst_xoff, &dst_yoff)))
+    if (!(image = image_from_pict (pPicture, FALSE)))
 	return;
 
     pixman_rasterize_trapezoid (image, (pixman_trapezoid_t *)trap,
-				x_off + dst_xoff,
-				y_off + dst_yoff);
+				x_off,
+				y_off);
 
     free_pixman_pict (pPicture, image);
 }
@@ -77,13 +75,12 @@ fbAddTriangles (PicturePtr  pPicture,
 		xTriangle *tris)
 {
     pixman_image_t *image;
-    int dst_xoff, dst_yoff;
 
-    if (!(image = image_from_pict (pPicture, FALSE, &dst_xoff, &dst_yoff)))
+    if (!(image = image_from_pict (pPicture, FALSE)))
 	return;
     
     pixman_add_triangles (image,
-			  dst_xoff + x_off, dst_yoff + y_off,
+			  x_off, y_off,
 			  ntri, (pixman_triangle_t *)tris);
 
     free_pixman_pict (pPicture, image);
@@ -110,13 +107,11 @@ fbShapes (CompositeShapesFunc	composite,
 	  const uint8_t *	shapes)
 {
     pixman_image_t *src, *dst;
-    int src_xoff, src_yoff;
-    int dst_xoff, dst_yoff;
 
     miCompositeSourceValidate (pSrc);
 
-    src = image_from_pict (pSrc, FALSE, &src_xoff, &src_yoff);
-    dst = image_from_pict (pDst, TRUE, &dst_xoff, &dst_yoff);
+    src = image_from_pict (pSrc, FALSE);
+    dst = image_from_pict (pDst, TRUE);
 
     if (src && dst)
     {
@@ -136,10 +131,10 @@ fbShapes (CompositeShapesFunc	composite,
 	    for (i = 0; i < nshapes; ++i)
 	    {
 		composite (op, src, dst, format,
-			   xSrc + src_xoff,
-			   ySrc + src_yoff,
-			   dst_xoff,
-			   dst_yoff,
+			   xSrc,
+			   ySrc,
+			   0,
+			   0,
 			   1, shapes + i * shape_size);
 	    }
 	}
@@ -162,10 +157,10 @@ fbShapes (CompositeShapesFunc	composite,
 	    }
 	    
 	    composite (op, src, dst, format,
-		       xSrc + src_xoff,
-		       ySrc + src_yoff,
-		       dst_xoff,
-		       dst_yoff,
+		       xSrc,
+		       ySrc,
+		       0,
+		       0,
 		       nshapes, shapes);
 	}
 
commit dd202b7510b8313123fbe7e43556138ae2df181b
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 0f1ebe5..dcbfe1c 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;
 
@@ -591,6 +605,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;
 	
@@ -599,6 +625,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;
@@ -661,6 +693,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 328074890eeb111950e984c6f618311983600b20
Author: dtakahashi42 <dtakahashi42 at gmail.com>
Date:   Fri Nov 18 11:30:22 2011 -0800

    rootless: Fix a server crash when choosing a color with the gimp color wheel
    
    https://trac.macports.org/ticket/30927
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/miext/rootless/rootlessScreen.c b/miext/rootless/rootlessScreen.c
index 0801e72..c855706 100644
--- a/miext/rootless/rootlessScreen.c
+++ b/miext/rootless/rootlessScreen.c
@@ -247,8 +247,8 @@ RootlessComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
     WindowPtr srcWin, dstWin, maskWin = NULL;
 
     if (pMask) {                        // pMask can be NULL
-        maskWin = (pMask->pDrawable->type == DRAWABLE_WINDOW) ?
-                  (WindowPtr)pMask->pDrawable :  NULL;
+        maskWin = (pMask->pDrawable && pMask->pDrawable->type == DRAWABLE_WINDOW) ?
+                  (WindowPtr)pMask->pDrawable : NULL;
     }
     srcWin  = (pSrc->pDrawable && pSrc->pDrawable->type  == DRAWABLE_WINDOW) ?
               (WindowPtr)pSrc->pDrawable  :  NULL;
commit 58864146fbdf1820d04825838691e84784ef91bc
Author: Ross Burton <ross at linux.intel.com>
Date:   Wed Sep 28 11:46:02 2011 +0100

    edid: Add quirk for Acer Aspire One 110
    
    At least one revision of the AAO reports a 190x110mm maximum size but a
    451x113mm mode.
    
    X.Org Bug 41141 <https://bugs.freedesktop.org/show_bug.cgi?id=41141>
    
    Signed-off-by: Ross Burton <ross at linux.intel.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/hw/xfree86/modes/xf86EdidModes.c b/hw/xfree86/modes/xf86EdidModes.c
index 9ff2f0d..86065f8 100644
--- a/hw/xfree86/modes/xf86EdidModes.c
+++ b/hw/xfree86/modes/xf86EdidModes.c
@@ -165,6 +165,11 @@ static Bool quirk_detailed_use_maximum_size (int scrnIndex, xf86MonPtr DDC)
 	DDC->vendor.prod_id == 6400)
 	return TRUE;
 
+    /* Bug #41141: Acer Aspire One */
+    if (memcmp (DDC->vendor.name, "LGD", 4) == 0 &&
+	DDC->vendor.prod_id == 0x7f01)
+	return TRUE;
+
     return FALSE;
 }
 
commit 34b0e4eee911f8b09a3682a7f1b4c8598ef48b8d
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Aug 25 16:04:04 2011 +0100

    dri2: Register the DRI2DrawableType after server regeneration
    
    The Resource database is reset upon regeneration and so the dri2 module
    needs to re-register its RESTYPE for the drawable or else it will
    clobber the next unsuspecting user of the database. Fortunately, DRI2 is
    loaded late in the initialisation sequence and was last up until
    xf86-video-intel started using the Resource database to track
    outstanding swaps...
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
    Tested-by: Paulo Zanoni <paulo.r.zanoni at intel.com>

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index dd56f9c..0d613be 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -1235,14 +1235,24 @@ DRI2CloseScreen(ScreenPtr pScreen)
 }
 
 extern ExtensionModule dri2ExtensionModule;
+extern Bool DRI2ModuleSetup(void);
+
+/* Called by InitExtensions() */
+Bool
+DRI2ModuleSetup(void)
+{
+    dri2DrawableRes = CreateNewResourceType(DRI2DrawableGone, "DRI2Drawable");
+    if (!dri2DrawableRes)
+	return FALSE;
+
+    return TRUE;
+}
 
 static pointer
 DRI2Setup(pointer module, pointer opts, int *errmaj, int *errmin)
 {
     static Bool setupDone = FALSE;
 
-    dri2DrawableRes = CreateNewResourceType(DRI2DrawableGone, "DRI2Drawable");
-
     if (!setupDone)
     {
 	setupDone = TRUE;
diff --git a/hw/xfree86/dri2/dri2ext.c b/hw/xfree86/dri2/dri2ext.c
index 934abf6..e612cf0 100644
--- a/hw/xfree86/dri2/dri2ext.c
+++ b/hw/xfree86/dri2/dri2ext.c
@@ -50,6 +50,7 @@
 #include "xf86Module.h"
 
 static ExtensionEntry	*dri2Extension;
+extern Bool DRI2ModuleSetup(void);
 
 static Bool
 validDrawable(ClientPtr client, XID drawable, Mask access_mode,
@@ -634,6 +635,8 @@ DRI2ExtensionInit(void)
 				 StandardMinorOpcode);
 
     DRI2EventBase = dri2Extension->eventBase;
+
+    DRI2ModuleSetup();
 }
 
 extern Bool noDRI2Extension;
commit bfa1a0dd190ed88020d60eba3bb04681c8e83a68
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Jan 24 11:17:03 2011 +0000

    DRI2: Avoid a NULL pointer dereference
    
    Bugzilla:  https://bugs.freedesktop.org/show_bug.cgi?id=41211
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index a97508d..dd56f9c 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -816,7 +816,8 @@ DRI2WaitSwap(ClientPtr client, DrawablePtr pDrawable)
     /* If we're currently waiting for a swap on this drawable, reset
      * the request and suspend the client.  We only support one
      * blocked client per drawable. */
-    if ((pPriv->swapsPending) &&
+    if (pPriv &&
+	pPriv->swapsPending &&
 	pPriv->blockedClient == NULL) {
 	ResetCurrentRequest(client);
 	client->sequence--;
commit eeb21a133b982f71de739baf62e53c8a68f5d495
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Jan 24 11:17:03 2011 +0000

    VidMode: prevent crash with no modes
    
    Bugzilla:  https://bugs.freedesktop.org/show_bug.cgi?id=17431
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/hw/xfree86/common/xf86VidMode.c b/hw/xfree86/common/xf86VidMode.c
index 4dd454d..2ae5484 100644
--- a/hw/xfree86/common/xf86VidMode.c
+++ b/hw/xfree86/common/xf86VidMode.c
@@ -221,6 +221,9 @@ VidModeGetFirstModeline(int scrnIndex, pointer *mode, int *dotClock)
 	return FALSE;
 
     pScrn = xf86Screens[scrnIndex];
+    if (pScrn->modes == NULL)
+	    return FALSE;
+
     pVidMode = VMPTR(pScrn->pScreen);
     pVidMode->First = pScrn->modes;
     pVidMode->Next =  pVidMode->First->next;
commit c1bb8f43b9290c2b18a9f0ac59773ff8f1eb974f
Author: Rami Ylimäki <rami.ylimaki at vincit.fi>
Date:   Tue Oct 4 12:25:26 2011 +0300

    record: Prevent out of bounds access when recording a reply.
    
    Any pad bytes in replies are written to the client from a zeroed
    array. However, record extension tries to incorrectly access the pad
    bytes from the end of reply data.
    
    Signed-off-by: Rami Ylimäki <rami.ylimaki at vincit.fi>
    Reviewed-by: Erkki Seppälä <erkki.seppala at vincit.fi>

diff --git a/include/os.h b/include/os.h
index b489211..823fe5d 100644
--- a/include/os.h
+++ b/include/os.h
@@ -451,9 +451,10 @@ extern _X_EXPORT CallbackListPtr ReplyCallback;
 typedef struct {
     ClientPtr client;
     const void *replyData;
-    unsigned long dataLenBytes;
+    unsigned long dataLenBytes; /* actual bytes from replyData + pad bytes */
     unsigned long bytesRemaining;
     Bool startOfReply;
+    unsigned long padBytes;     /* pad bytes from zeroed array */
 } ReplyInfoRec;
 
 /* stuff for FlushCallback */
diff --git a/os/io.c b/os/io.c
index 068f5f0..955bf8b 100644
--- a/os/io.c
+++ b/os/io.c
@@ -809,6 +809,7 @@ WriteToClient (ClientPtr who, int count, const void *__buf)
 	replyinfo.client = who;
 	replyinfo.replyData = buf;
 	replyinfo.dataLenBytes = count + padBytes;
+	replyinfo.padBytes = padBytes;
 	if (who->replyBytesRemaining)
 	{ /* still sending data of an earlier reply */
 	    who->replyBytesRemaining -= count + padBytes;
diff --git a/record/record.c b/record/record.c
index 68311ac..db77b64 100644
--- a/record/record.c
+++ b/record/record.c
@@ -269,8 +269,9 @@ RecordFlushReplyBuffer(
  *	  device events and EndOfData, pClient is NULL.
  *	category is the category of the protocol element, as defined
  *	  by the RECORD spec.
- *	data is a pointer to the protocol data, and datalen is its length
- *	  in bytes.
+ *	data is a pointer to the protocol data, and datalen - padlen
+ *	  is its length in bytes.
+ *	padlen is the number of pad bytes from a zeroed array.
  *	futurelen is the number of bytes that will be sent in subsequent
  *	  calls to this function to complete this protocol element.  
  *	  In those subsequent calls, futurelen will be -1 to indicate
@@ -290,7 +291,7 @@ RecordFlushReplyBuffer(
  */
 static void
 RecordAProtocolElement(RecordContextPtr pContext, ClientPtr pClient,
-		       int category, pointer data, int datalen, int futurelen)
+		       int category, pointer data, int datalen, int padlen, int futurelen)
 {
     CARD32 elemHeaderData[2];
     int numElemHeaders = 0;
@@ -398,15 +399,20 @@ RecordAProtocolElement(RecordContextPtr pContext, ClientPtr pClient,
 	}
 	if (datalen)
 	{
+	    static char padBuffer[3]; /* as in FlushClient */
 	    memcpy(pContext->replyBuffer + pContext->numBufBytes,
-		   data, datalen);
-	    pContext->numBufBytes += datalen;
+		   data, datalen - padlen);
+	    pContext->numBufBytes += datalen - padlen;
+	    memcpy(pContext->replyBuffer + pContext->numBufBytes,
+		   padBuffer, padlen);
+	    pContext->numBufBytes += padlen;
 	}
     }
     else
+    {
 	RecordFlushReplyBuffer(pContext, (pointer)elemHeaderData,
-			       numElemHeaders, (pointer)data, datalen);
-
+			       numElemHeaders, (pointer)data, datalen - padlen);
+    }
 } /* RecordAProtocolElement */
 
 
@@ -483,19 +489,19 @@ RecordABigRequest(RecordContextPtr pContext, ClientPtr client, xReq *stuff)
     /* record the request header */
     bytesLeft = client->req_len << 2;
     RecordAProtocolElement(pContext, client, XRecordFromClient,
-			   (pointer)stuff, SIZEOF(xReq), bytesLeft);
+			   (pointer)stuff, SIZEOF(xReq), 0, bytesLeft);
 
     /* reinsert the extended length field that was squished out */
     bigLength = client->req_len + bytes_to_int32(sizeof(bigLength));
     if (client->swapped)
 	swapl(&bigLength);
     RecordAProtocolElement(pContext, client, XRecordFromClient,
-		(pointer)&bigLength, sizeof(bigLength), /* continuation */ -1);
+               (pointer)&bigLength, sizeof(bigLength), 0, /* continuation */ -1);
     bytesLeft -= sizeof(bigLength);
 
     /* record the rest of the request after the length */
     RecordAProtocolElement(pContext, client, XRecordFromClient,
-		(pointer)(stuff + 1), bytesLeft, /* continuation */ -1);
+               (pointer)(stuff + 1), bytesLeft, 0, /* continuation */ -1);
 } /* RecordABigRequest */
 
 
@@ -542,7 +548,7 @@ RecordARequest(ClientPtr client)
 		    RecordABigRequest(pContext, client, stuff);
 		else
 		    RecordAProtocolElement(pContext, client, XRecordFromClient,
-				(pointer)stuff, client->req_len << 2, 0);
+				(pointer)stuff, client->req_len << 2, 0, 0);
 	    }
 	    else /* extension, check minor opcode */
 	    {
@@ -566,7 +572,7 @@ RecordARequest(ClientPtr client)
 			else
 			    RecordAProtocolElement(pContext, client, 
 					XRecordFromClient, (pointer)stuff,
-					client->req_len << 2, 0);
+					client->req_len << 2, 0, 0);
 			break;
 		    }			    
 		} /* end for each minor op info */
@@ -619,7 +625,8 @@ RecordAReply(CallbackListPtr *pcbl, pointer nulldata, pointer calldata)
 	    if (pContext->continuedReply)
 	    {
 		RecordAProtocolElement(pContext, client, XRecordFromServer,
-		   (pointer)pri->replyData, pri->dataLenBytes, /* continuation */ -1);
+		   (pointer)pri->replyData, pri->dataLenBytes,
+			    pri->padBytes, /* continuation */ -1);
 		if (!pri->bytesRemaining)
 		    pContext->continuedReply = 0;
 	    }
@@ -629,7 +636,7 @@ RecordAReply(CallbackListPtr *pcbl, pointer nulldata, pointer calldata)
 		if (majorop <= 127)
 		{ /* core reply */
 		    RecordAProtocolElement(pContext, client, XRecordFromServer,
-		       (pointer)pri->replyData, pri->dataLenBytes, pri->bytesRemaining);
+		       (pointer)pri->replyData, pri->dataLenBytes, 0, pri->bytesRemaining);
 		    if (pri->bytesRemaining)
 			pContext->continuedReply = 1;
 		}
@@ -651,7 +658,7 @@ RecordAReply(CallbackListPtr *pcbl, pointer nulldata, pointer calldata)
 			{
 			    RecordAProtocolElement(pContext, client, 
 				XRecordFromServer, (pointer)pri->replyData,
-				pri->dataLenBytes, pri->bytesRemaining);
+				pri->dataLenBytes, 0, pri->bytesRemaining);
 			    if (pri->bytesRemaining)
 				pContext->continuedReply = 1;
 			    break;
@@ -723,7 +730,7 @@ RecordADeliveredEventOrError(CallbackListPtr *pcbl, pointer nulldata, pointer ca
 			
 		    }
 		    RecordAProtocolElement(pContext, pClient,
-			XRecordFromServer, pEvToRecord, SIZEOF(xEvent), 0);
+			XRecordFromServer, pEvToRecord, SIZEOF(xEvent), 0, 0);
 		}
 	    } /* end for each event */
 	} /* end this client is on this context */
@@ -774,7 +781,7 @@ RecordSendProtocolEvents(RecordClientsAndProtocolPtr pRCAP,
 	    }
 
 	    RecordAProtocolElement(pContext, NULL,
-		    XRecordFromServer,  pEvToRecord, SIZEOF(xEvent), 0);
+		    XRecordFromServer,  pEvToRecord, SIZEOF(xEvent), 0, 0);
 	    /* make sure device events get flushed in the absence
 	     * of other client activity
 	     */
@@ -2415,7 +2422,7 @@ ProcRecordEnableContext(ClientPtr client)
     assert(numEnabledContexts > 0);
 
     /* send StartOfData */
-    RecordAProtocolElement(pContext, NULL, XRecordStartOfData, NULL, 0, 0);
+    RecordAProtocolElement(pContext, NULL, XRecordStartOfData, NULL, 0, 0, 0);
     RecordFlushReplyBuffer(pContext, NULL, 0, NULL, 0);
     return Success;
 } /* ProcRecordEnableContext */
@@ -2446,7 +2453,7 @@ RecordDisableContext(RecordContextPtr pContext)
     if (!pContext->pRecordingClient) return;
     if (!pContext->pRecordingClient->clientGone)
     {
-	RecordAProtocolElement(pContext, NULL, XRecordEndOfData, NULL, 0, 0);
+	RecordAProtocolElement(pContext, NULL, XRecordEndOfData, NULL, 0, 0, 0);
 	RecordFlushReplyBuffer(pContext, NULL, 0, NULL, 0);
 	/* Re-enable request processing on this connection. */
 	AttendClient(pContext->pRecordingClient);
@@ -2761,7 +2768,7 @@ RecordConnectionSetupInfo(RecordContextPtr pContext, NewClientInfoRec *pci)
 	SwapConnSetupPrefix(pci->prefix, (xConnSetupPrefix*)pConnSetup);
 	SwapConnSetupInfo((char*)pci->setup, (char*)(pConnSetup + prefixsize));
 	RecordAProtocolElement(pContext, pci->client, XRecordClientStarted,
-			       (pointer)pConnSetup, prefixsize + restsize, 0);
+			       (pointer)pConnSetup, prefixsize + restsize, 0, 0);
 	free(pConnSetup);
     }
     else
@@ -2770,9 +2777,9 @@ RecordConnectionSetupInfo(RecordContextPtr pContext, NewClientInfoRec *pci)
 	 * data in two pieces
 	 */
 	RecordAProtocolElement(pContext, pci->client, XRecordClientStarted,
-			(pointer)pci->prefix, prefixsize, restsize);
+			(pointer)pci->prefix, prefixsize, 0, restsize);
 	RecordAProtocolElement(pContext, pci->client, XRecordClientStarted,
-			(pointer)pci->setup, restsize, /* continuation */ -1);
+			(pointer)pci->setup, restsize, 0, /* continuation */ -1);
     }
 } /* RecordConnectionSetupInfo */
 
@@ -2849,7 +2856,7 @@ RecordAClientStateChange(CallbackListPtr *pcbl, pointer nulldata, pointer callda
 	    {
 		if (pContext->pRecordingClient && pRCAP->clientDied)
 		    RecordAProtocolElement(pContext, pClient,
-					   XRecordClientDied, NULL, 0, 0);
+					   XRecordClientDied, NULL, 0, 0, 0);
 		RecordDeleteClientFromRCAP(pRCAP, pos);
 	    }
 	}
commit 1f5baa924a5907978f564372265d9830ac72a077
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sun Oct 30 20:26:42 2011 -0700

    xfree86: Deprecate the use of xf86PciInfo.h
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Tormod Volden <debian.tormod at gmail.com>

diff --git a/hw/xfree86/common/xf86PciInfo.h b/hw/xfree86/common/xf86PciInfo.h
index 356c7db..e2d7862 100644
--- a/hw/xfree86/common/xf86PciInfo.h
+++ b/hw/xfree86/common/xf86PciInfo.h
@@ -47,6 +47,8 @@
 #ifndef _XF86_PCIINFO_H
 #define _XF86_PCIINFO_H
 
+#warning "xf86PciInfo.h is deprecated.  For greater compatibility, drivers should include necessary PCI IDs locally rather than relying on this file from xorg-server."
+
 /* PCI Pseudo Vendor */
 #define PCI_VENDOR_GENERIC		0x00FF
 
diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c
index bc09bd2..87dc025 100644
--- a/hw/xfree86/common/xf86pciBus.c
+++ b/hw/xfree86/common/xf86pciBus.c
@@ -49,6 +49,7 @@
 #define XF86_OS_PRIVS
 #include "xf86_OSproc.h"
 
+#define PCI_VENDOR_GENERIC		0x00FF
 
 /* Bus-specific globals */
 Bool pciSlotClaimed = FALSE;
diff --git a/hw/xfree86/doc/ddxDesign.xml b/hw/xfree86/doc/ddxDesign.xml
index 0d5e952..c406cd7 100644
--- a/hw/xfree86/doc/ddxDesign.xml
+++ b/hw/xfree86/doc/ddxDesign.xml
@@ -3553,13 +3553,6 @@ The following include files are typically required by video drivers:
 	  </para>
 
 	  <para>
-  Drivers that need to access PCI vendor/device definitions need this:
-	    <literallayout><filename>
-    "xf86PciInfo.h"
-	      </filename></literallayout>
-	  </para>
-
-	  <para>
   Drivers that need to access the PCI config space need this:
 	    <literallayout><filename>
     "xf86Pci.h"
diff --git a/hw/xfree86/fbdevhw/fbdevhw.c b/hw/xfree86/fbdevhw/fbdevhw.c
index dee731b..30a2a91 100644
--- a/hw/xfree86/fbdevhw/fbdevhw.c
+++ b/hw/xfree86/fbdevhw/fbdevhw.c
@@ -9,7 +9,6 @@
 #include "xf86_OSproc.h"
 
 /* pci stuff */
-#include "xf86PciInfo.h"
 #include "xf86Pci.h"
 
 #include "xf86cmap.h"
diff --git a/hw/xfree86/os-support/bus/Pci.h b/hw/xfree86/os-support/bus/Pci.h
index 88560ec..5709bd8 100644
--- a/hw/xfree86/os-support/bus/Pci.h
+++ b/hw/xfree86/os-support/bus/Pci.h
@@ -108,7 +108,6 @@
 #define _PCI_H 1
 
 #include "xf86Pci.h"
-#include "xf86PciInfo.h"
 
 /*
  * Global Definitions
diff --git a/hw/xfree86/sdksyms.sh b/hw/xfree86/sdksyms.sh
index b8e7023..4a4e1f6 100755
--- a/hw/xfree86/sdksyms.sh
+++ b/hw/xfree86/sdksyms.sh
@@ -121,7 +121,6 @@ cat > sdksyms.c << EOF
 #include "xf86Module.h"
 #include "xf86Opt.h"
 #ifdef XSERVER_LIBPCIACCESS
- #include "xf86PciInfo.h"
  #include "xf86VGAarbiter.h"
 #endif
 #include "xf86Priv.h"
commit eb3377ffb8a7baa26c9831e56ed782d48b28fa71
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Tue Nov 1 14:59:15 2011 -0700

    xfree86: Fix powerpc build with -Werror=int-to-pointer-cast -Werror=pointer-to-int-cast
    
    memType is a uint64_t on powerpc. Using memType only really makes
    sense for *physical* addresses, which can be 64-bit for 32-bit
    systems running on 64-bit hardware.
    
    However, unmapVidMem() only deals with *virtual* addresses, which
    are guaranteed to fit into an uintptr_t.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    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 e711784..0d91f7a 100644
--- a/hw/xfree86/os-support/linux/lnx_video.c
+++ b/hw/xfree86/os-support/linux/lnx_video.c
@@ -465,11 +465,11 @@ mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
 static void
 unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
 {
-    memType alignOff = (memType)Base 
-	- ((memType)Base & ~(getpagesize() - 1));
+    uintptr_t alignOff = (uintptr_t)Base
+	- ((uintptr_t)Base & ~(getpagesize() - 1));
 
-    DebugF("alignment offset: %lx\n",alignOff);
-    munmap((caddr_t)((memType)Base - alignOff), (Size + alignOff));
+    DebugF("alignment offset: %lx\n", (unsigned long)alignOff);
+    munmap((void *)((uintptr_t)Base - alignOff), (Size + alignOff));
 }
 
 
commit a551f126cc4af7a476d9c8fd0cb309d5aa600d54
Author: Pierre-Loup A. Griffais <pgriffais at nvidia.com>
Date:   Fri Nov 4 23:26:25 2011 -0700

    xfree86: Fix RandR rotation across server generations
    
    245cb8e94fd1599 fixed xf86RotateDestroy() to actually run its teardown
    code, causing the Damage object to properly be re-allocated after a
    server regeneration. However the block that does that still thinks the
    Rotate layer BlockHandler is wrapped from the last generation, meaning
    the shadow pixmap is never re-allocated and the Damage object is never
    re-registered, causing a blank screen, and potentially a driver crash
    on the next teardown after the server asks it to free a 0x0 Pixmap.
    
    Signed-off-by: Pierre-Loup A. Griffais <pgriffais at nvidia.com>
    Reviewed-by: Aaron Plattner <aplattner at nvidia.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index aac33d3..9532151 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -807,6 +807,9 @@ xf86CrtcScreenInit (ScreenPtr screen)
 
     config->CloseScreen = screen->CloseScreen;
     screen->CloseScreen = xf86CrtcCloseScreen;
+
+    /* This might still be marked wrapped from a previous generation */
+    config->BlockHandler = NULL;
     
 #ifdef XFreeXDGA
     _xf86_di_dga_init_internal(screen);
commit bfa2a1857a1efda7f171f10e855d200ca0dbcc1a
Merge: f0d50cc e7cb8f8
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Nov 14 09:07:06 2011 -0800

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

commit e7cb8f802adf6fc22e7a930c0dfc5c1076781c96
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed Nov 9 15:31:57 2011 +1000

    Xext: remove unused variable 'n'
    
    xselinux_ext.c: In function 'SELinuxSendItemsToClient':
    xselinux_ext.c:340:16: warning: unused variable 'n' [-Wunused-variable]
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Julien Cristau <jcristau at debian.org>

diff --git a/Xext/xselinux_ext.c b/Xext/xselinux_ext.c
index 641368a..a18a367 100644
--- a/Xext/xselinux_ext.c
+++ b/Xext/xselinux_ext.c
@@ -337,7 +337,7 @@ static int
 SELinuxSendItemsToClient(ClientPtr client, SELinuxListItemRec *items,
 			 int size, int count)
 {
-    int rc, k, n, pos = 0;
+    int rc, k, pos = 0;
     SELinuxListItemsReply rep;
     CARD32 *buf;
 
commit bb4aa1f263ad38c175bfda3b7e6c325260ce3f28
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed Nov 9 15:31:10 2011 +1000

    Xext: don't swap CARD8 in SProcSELinuxQueryVersion
    
    xselinux_ext.c: In function 'SELinuxSendItemsToClient':
    xselinux_ext.c:340:16: warning: unused variable 'n' [-Wunused-variable]
    xselinux_ext.c: In function 'SProcSELinuxQueryVersion':
    xselinux_ext.c:532:62: error: call to 'wrong_size' declared with attribute
    error: wrong sized variable passed to swap
    xselinux_ext.c:533:62: error: call to 'wrong_size' declared with attribute
    error: wrong sized variable passed to swap
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Julien Cristau <jcristau at debian.org>

diff --git a/Xext/xselinux_ext.c b/Xext/xselinux_ext.c
index 56f2d1f..641368a 100644
--- a/Xext/xselinux_ext.c
+++ b/Xext/xselinux_ext.c
@@ -526,11 +526,6 @@ ProcSELinuxDispatch(ClientPtr client)
 static int
 SProcSELinuxQueryVersion(ClientPtr client)
 {
-    REQUEST(SELinuxQueryVersionReq);
-
-    REQUEST_SIZE_MATCH(SELinuxQueryVersionReq);
-    swaps(&stuff->client_major);
-    swaps(&stuff->client_minor);
     return ProcSELinuxQueryVersion(client);
 }
 
commit 35ec24cf245e5ef676e98a0bf7c77296a3f1ff63
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon Aug 1 14:14:02 2011 +1000

    input: replace remaining GetPairedDevice() with GetMaster()
    
    Wherever it's obvious which device we need (keyboard or pointer), use
    GetMaster() instead of GetPairedDevice(). It is more reliable in actually
    getting the device type we want.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/Xi/exevents.c b/Xi/exevents.c
index edf2c39..53db036 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -104,7 +104,7 @@ int
 XIShouldNotify(ClientPtr client, DeviceIntPtr dev)
 {
     DeviceIntPtr current_ptr = PickPointer(client);
-    DeviceIntPtr current_kbd = GetPairedDevice(current_ptr);
+    DeviceIntPtr current_kbd = GetMaster(current_ptr, KEYBOARD_OR_FLOAT);
 
     if (dev == current_kbd || dev == current_ptr)
         return 1;
@@ -903,13 +903,13 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
 
     if (IsPointerDevice(device))
     {
-        kbd = GetPairedDevice(device);
+        kbd = GetMaster(device, KEYBOARD_OR_FLOAT);
         mouse = device;
         if (!kbd->key) /* can happen with floating SDs */
             kbd = NULL;
     } else
     {
-        mouse = GetPairedDevice(device);
+        mouse = GetMaster(device, POINTER_OR_FLOAT);
         kbd = device;
         if (!mouse->valuator || !mouse->button) /* may be float. SDs */
             mouse = NULL;
diff --git a/Xi/xiquerypointer.c b/Xi/xiquerypointer.c
index 9e05eff..d01a813 100644
--- a/Xi/xiquerypointer.c
+++ b/Xi/xiquerypointer.c
@@ -109,7 +109,7 @@ ProcXIQueryPointer(ClientPtr client)
         MaybeStopHint(pDev, client);
 
     if (IsMaster(pDev))
-        kbd = GetPairedDevice(pDev);
+        kbd = GetMaster(pDev, MASTER_KEYBOARD);
     else
         kbd = (pDev->key) ? pDev : NULL;
 
diff --git a/dix/enterleave.c b/dix/enterleave.c
index b1ee3fb..a39e640 100644
--- a/dix/enterleave.c
+++ b/dix/enterleave.c
@@ -766,7 +766,7 @@ CoreFocusOutNotifyPointerEvents(DeviceIntPtr dev,
 {
     WindowPtr P, stopAt;
 
-    P = PointerWin(GetPairedDevice(dev));
+    P = PointerWin(GetMaster(dev, POINTER_OR_FLOAT));
 
     if (!P)
         return;
@@ -821,7 +821,7 @@ CoreFocusInNotifyPointerEvents(DeviceIntPtr dev,
 {
     WindowPtr P;
 
-    P = PointerWin(GetPairedDevice(dev));
+    P = PointerWin(GetMaster(dev, POINTER_OR_FLOAT));
 
     if (!P || P == exclude || (pwin_parent != P && !IsParent(pwin_parent, P)))
         return;
@@ -1087,7 +1087,7 @@ CoreFocusPointerRootNoneSwitch(DeviceIntPtr dev,
     for (i = 0; i < nscreens; i++)
     {
         root = screenInfo.screens[i]->root;
-        if (!HasOtherPointer(root, GetPairedDevice(dev)) && !FirstFocusChild(root))
+        if (!HasOtherPointer(root, GetMaster(dev, POINTER_OR_FLOAT)) && !FirstFocusChild(root))
         {
             /* If pointer was on PointerRootWin and changes to NoneWin, and
              * the pointer paired with dev is below the current root window,
@@ -1095,7 +1095,7 @@ CoreFocusPointerRootNoneSwitch(DeviceIntPtr dev,
             if (dev->focus && dev->focus->win == PointerRootWin &&
                 B != PointerRootWin)
             {
-                WindowPtr ptrwin = PointerWin(GetPairedDevice(dev));
+                WindowPtr ptrwin = PointerWin(GetMaster(dev, POINTER_OR_FLOAT));
                 if (ptrwin && IsParent(root, ptrwin))
                     CoreFocusOutNotifyPointerEvents(dev, root, None, mode, TRUE);
             }
@@ -1187,7 +1187,7 @@ CoreFocusFromPointerRootOrNone(DeviceIntPtr dev,
             if (dev->focus && dev->focus->win == PointerRootWin &&
                 B != PointerRootWin)
             {
-                WindowPtr ptrwin = PointerWin(GetPairedDevice(dev));
+                WindowPtr ptrwin = PointerWin(GetMaster(dev, POINTER_OR_FLOAT));
                 if (ptrwin)
                     CoreFocusOutNotifyPointerEvents(dev, root, None, mode, TRUE);
             }
diff --git a/dix/events.c b/dix/events.c
index f87d2bb..5e0dc5f 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -3698,10 +3698,7 @@ CheckPassiveGrabsOnWindow(
 	gdev= grab->modifierDevice;
         if (grab->grabtype == GRABTYPE_CORE)
         {
-            if (IsPointerDevice(device))
-                gdev = GetPairedDevice(device);
-            else
-                gdev = device;
+            gdev = GetMaster(device, KEYBOARD_OR_FLOAT);
         } else if (grab->grabtype == GRABTYPE_XI2)
         {
             /* if the device is an attached slave device, gdev must be the
@@ -4000,8 +3997,7 @@ DeliverFocusedEvent(DeviceIntPtr keybd, InternalEvent *event, WindowPtr window)
     }
 
     /* just deliver it to the focus window */
-    ptr = GetPairedDevice(keybd);
-
+    ptr = GetMaster(keybd, POINTER_OR_FLOAT);
 
     rc = EventToXI2(event, &xi2);
     if (rc == Success)
@@ -4501,7 +4497,7 @@ CoreEnterLeaveEvent(
     GrabPtr	        grab = mouse->deviceGrab.grab;
     Mask		mask;
 
-    keybd = GetPairedDevice(mouse);
+    keybd = GetMaster(mouse, KEYBOARD_OR_FLOAT);
 
     if ((pWin == mouse->valuator->motionHintWindow) &&
 	(detail != NotifyInferior))
@@ -4719,10 +4715,7 @@ SetInputFocus(
     }
     time = ClientTimeToServerTime(ctime);
 
-    if (IsKeyboardDevice(dev))
-        keybd = dev;
-    else
-        keybd = GetPairedDevice(dev);
+    keybd = GetMaster(dev, KEYBOARD_OR_FLOAT);
 
     if ((focusID == None) || (focusID == PointerRoot))
 	focusWin = (WindowPtr)(long)focusID;
@@ -5197,7 +5190,7 @@ ProcQueryPointer(ClientPtr client)
     if (rc != Success && rc != BadAccess)
 	return rc;
 
-    keyboard = GetPairedDevice(mouse);
+    keyboard = GetMaster(mouse, MASTER_KEYBOARD);
 
     pSprite = mouse->spriteInfo->sprite;
     if (mouse->valuator->motionHintWindow)
@@ -5321,7 +5314,7 @@ ProcSendEvent(ClientPtr client)
     WindowPtr pWin;
     WindowPtr effectiveFocus = NullWindow; /* only set if dest==InputFocus */
     DeviceIntPtr dev = PickPointer(client);
-    DeviceIntPtr keybd = GetPairedDevice(dev);
+    DeviceIntPtr keybd = GetMaster(dev, MASTER_KEYBOARD);
     SpritePtr pSprite = dev->spriteInfo->sprite;
     REQUEST(xSendEventReq);
 
@@ -5594,7 +5587,7 @@ ProcGrabButton(ClientPtr client)
     }
 
     ptr = PickPointer(client);
-    modifierDevice = GetPairedDevice(ptr);
+    modifierDevice = GetMaster(ptr, MASTER_KEYBOARD);
     if (stuff->pointerMode == GrabModeSync ||
 	stuff->keyboardMode == GrabModeSync)
 	access_mode |= DixFreezeAccess;
@@ -5651,7 +5644,7 @@ ProcUngrabButton(ClientPtr client)
     tempGrab.window = pWin;
     tempGrab.modifiersDetail.exact = stuff->modifiers;
     tempGrab.modifiersDetail.pMask = NULL;
-    tempGrab.modifierDevice = GetPairedDevice(ptr);
+    tempGrab.modifierDevice = GetMaster(ptr, MASTER_KEYBOARD);
     tempGrab.type = ButtonPress;
     tempGrab.detail.exact = stuff->button;
     tempGrab.grabtype = GRABTYPE_CORE;
diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c
index 74eb739..46e3005 100644
--- a/hw/xfree86/common/xf86DGA.c
+++ b/hw/xfree86/common/xf86DGA.c
@@ -1016,7 +1016,7 @@ DGAProcessKeyboardEvent (ScreenPtr pScreen, DGAEvent *event, DeviceIntPtr keybd)
 {
     KeyClassPtr	    keyc = keybd->key;
     DGAScreenPtr    pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
-    DeviceIntPtr    pointer = GetPairedDevice(keybd);
+    DeviceIntPtr    pointer = GetMaster(keybd, POINTER_OR_FLOAT);
     DeviceEvent     ev;
 
     memset(&ev, 0, sizeof(ev));
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index c3ffc27..7feb48c 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -1275,7 +1275,7 @@ xf86PostKeyEventM(DeviceIntPtr	device,
     DeviceIntPtr pointer;
 
     /* Some pointers send key events, paired device is wrong then. */
-    pointer = IsPointerDevice(device) ? device : GetPairedDevice(device);
+    pointer = GetMaster(device, POINTER_OR_FLOAT);
     if (miPointerGetScreen(pointer)) {
         int index = miPointerGetScreen(pointer)->myNum;
 
diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
index 000002a..1e94d26 100644
--- a/xkb/xkbActions.c
+++ b/xkb/xkbActions.c
@@ -1203,7 +1203,7 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev);
 	if (keyEvent)
             tmpdev = dev;
         else
-            tmpdev = GetPairedDevice(dev);
+            tmpdev = GetMaster(dev, POINTER_OR_FLOAT);
 
         UNWRAP_PROCESS_INPUT_PROC(tmpdev,xkbPrivPtr, backupproc);
         dev->public.processInputProc((InternalEvent*)event, tmpdev);
commit fc16917ad6f0d2722bfb5c5eeca955dd3bc4125a
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Fri Apr 15 13:32:10 2011 +1000

    include: export GetProximityEvents and QueueProximityEvents
    
    This is mainly needed for consistency with GetPointerEvents and friend.
    No-one seems to actually need this function from outside the usual DDXs.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/include/input.h b/include/input.h
index 5dd5c1b..9ef726f 100644
--- a/include/input.h
+++ b/include/input.h
@@ -463,13 +463,13 @@ extern _X_EXPORT void QueueKeyboardEvents(
     int key_code,
     const ValuatorMask *mask);
 
-extern int GetProximityEvents(
+extern _X_EXPORT int GetProximityEvents(
     InternalEvent *events,
     DeviceIntPtr pDev,
     int type,
     const ValuatorMask *mask);
 
-extern void QueueProximityEvents(
+extern _X_EXPORT void QueueProximityEvents(
     DeviceIntPtr pDev,
     int type,
     const ValuatorMask *mask);
commit 11840595a1be9f2df7390bcc708cc176e60d3ef2
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Nov 3 08:58:58 2011 +1000

    dix: Don't let a driver without a ProximityClassRec post events
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/dix/getevents.c b/dix/getevents.c
index df47b2b..8798f64 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -1546,7 +1546,7 @@ GetProximityEvents(InternalEvent *events, DeviceIntPtr pDev, int type, const Val
     /* Sanity checks. */
     if ((type != ProximityIn && type != ProximityOut) || !mask_in)
         return 0;
-    if (!pDev->valuator)
+    if (!pDev->valuator || !pDev->proximity)
         return 0;
 
     valuator_mask_copy(&mask, mask_in);
commit 22715e465b415b3351b83b8279a4f44157f63199
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Oct 27 11:03:39 2011 +1000

    Xi: allow passive keygrabs on the XIAll(Master)Devices fake devices
    
    They don't have a KeyClassRec, but we must still allow passive grabs on
    them.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Tested-by: Bastien Nocera <hadess at hadess.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/Xi/exevents.c b/Xi/exevents.c
index 053c76f..edf2c39 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1495,7 +1495,7 @@ GrabKey(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device,
     rc = CheckGrabValues(client, param);
     if (rc != Success)
         return rc;
-    if (k == NULL)
+    if ((dev->id != XIAllDevices && dev->id != XIAllMasterDevices) && k == NULL)
 	return BadMatch;
     if (grabtype == GRABTYPE_XI)
     {
commit f0d50cc6651dce3a8a3cd3fb84210aa92b139763
Author: Derek Buitenhuis <derek.buitenhuis at gmail.com>
Date:   Sun Nov 6 12:20:51 2011 -0500

    Fix vesa's VBE PanelID interpretation
    
    xserver's VESA driver's VBE (Vesa BIOS Extensions) code
    includes a PanelID probe, which can get a monitor's native
    resolution. From this, using CVT formulas, it derives
    horizontal sync rate and a vertical refresh rate ranges.
    
    It however, only derives the upper bounds of the ranges, and
    the lower bounds cannot de derived. By default, they are set
    to hardcoded constants which represent the lowest supported
    resolution: 640x480. The constants in vbe.c however, were
    not actually derived from forulas, but carried over from
    other code from the bad old days, and are not relevant
    to flat panel displays. This caused, for example, EEEPC701's
    panel, with a native resolution of 800x480, to end up with
    a upper bound of the horizontal sync rate that was lower
    than the hardcoded lower bound, which of course broke things.
    
    These numbers have been rederived using both my own CVT tool
    based on xf86CVTMode(), and using the provided 'cvt' tool
    that comes with xserver.
    
    Signed-off-by: Derek Buitenhuis <derek.buitenhuis at gmail.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/vbe/vbe.c b/hw/xfree86/vbe/vbe.c
index 04132d9..06a6284 100644
--- a/hw/xfree86/vbe/vbe.c
+++ b/hw/xfree86/vbe/vbe.c
@@ -1036,13 +1036,16 @@ VBEInterpretPanelID(int scrnIndex, struct vbePanelID *data)
     mode = xf86CVTMode(data->hsize, data->vsize, PANEL_HZ, 1, 0);
 
     pScrn->monitor->nHsync = 1;
-    pScrn->monitor->hsync[0].lo = 31.5;
+    pScrn->monitor->hsync[0].lo = 29.37;
     pScrn->monitor->hsync[0].hi = (float)mode->Clock / (float)mode->HTotal;
     pScrn->monitor->nVrefresh = 1;
     pScrn->monitor->vrefresh[0].lo = 56.0;
     pScrn->monitor->vrefresh[0].hi =
 	(float)mode->Clock*1000.0 / (float)mode->HTotal / (float)mode->VTotal;
 
+    if (pScrn->monitor->vrefresh[0].hi < 59.47)
+	pScrn->monitor->vrefresh[0].hi = 59.47;
+
     free(mode);
 }
 
commit c643c2b7bf480f5c27ff8606bda087f8bff3b154
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Tue Nov 1 12:17:50 2011 +1000

    xfree86: duplicate name and driver from pInfo for NewInputDeviceRequest
    
    xorg.conf devices had the name and driver set in the DDX's InputInfoPtr list
    but not in the option list for those devices. That information was lost when
    passing the options into NewInputDeviceRequest. NIDR then refused to start
    the devices.
    
    Introduced in xorg-server-1.11.0-250-ge4cd24e
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Tested-by: James Cloos <cloos at jhcloos.com>

diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index a0fdf29..c1e48ee 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -827,6 +827,8 @@ InitInput(int argc, char **argv)
 
     /* Initialize all configured input devices */
     for (pInfo = xf86ConfigLayout.inputs; pInfo && *pInfo; pInfo++) {
+        (*pInfo)->options = xf86AddNewOption((*pInfo)->options, "driver", (*pInfo)->driver);
+        (*pInfo)->options = xf86AddNewOption((*pInfo)->options, "identifier", (*pInfo)->name);
         /* If one fails, the others will too */
         if (NewInputDeviceRequest((*pInfo)->options, NULL, &dev) == BadAlloc)
             break;
commit 9cc44b955b27de33348d6a20bebc9704930ee18e
Author: Rui Matos <tiagomatos at gmail.com>
Date:   Tue Nov 1 21:32:36 2011 +0000

    randr: Make the RRConstrainCursorHarder logic the same as miPointerSetPosition
    
    The constraining logic in RRConstrainCursorHarder allows the cursor to reach
    crtc positions of x = width and y = height while the constraining code in
    miPointerSetPosition only allows it to reach x = width - 1 and y = height - 1
    for the analogous screen case.
    
    This patch makes the former's logic equivalent to the latter's which allows
    applications to benefit from Fitts's law. E.g. a maximized application
    adjacent to a crtc border wouldn't get pointer events if the user moved the
    pointer all the way until it's contained.
    
    Signed-off-by: Rui Matos <tiagomatos at gmail.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index e6a38ae..13dd7da 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -1459,7 +1459,7 @@ RRConstrainCursorHarder(DeviceIntPtr pDev, ScreenPtr pScreen, int mode, int *x,
 
        crtc_bounds(crtc, &left, &right, &top, &bottom);
 
-       if ((*x >= left) && (*x <= right) && (*y >= top) && (*y <= bottom))
+       if ((*x >= left) && (*x < right) && (*y >= top) && (*y < bottom))
            return;
     }
 
@@ -1475,24 +1475,15 @@ RRConstrainCursorHarder(DeviceIntPtr pDev, ScreenPtr pScreen, int mode, int *x,
        crtc_bounds(crtc, &left, &right, &top, &bottom);
        miPointerGetPosition(pDev, &nx, &ny);
 
-       if ((nx >= left) && (nx <= right) && (ny >= top) && (ny <= bottom)) {
-           if ((*x <= left) || (*x >= right)) {
-               int dx = *x - nx;
-
-               if (dx > 0)
-                   *x = right;
-               else if (dx < 0)
-                   *x = left;
-           }
-
-           if ((*y <= top) || (*y >= bottom)) {
-               int dy = *y - ny;
-
-               if (dy > 0)
-                   *y = bottom;
-               else if (dy < 0)
-                   *y = top;
-           }
+       if ((nx >= left) && (nx < right) && (ny >= top) && (ny < bottom)) {
+           if (*x < left)
+               *x = left;
+           if (*x >= right)
+               *x = right - 1;
+           if (*y < top)
+               *y = top;
+           if (*y >= bottom)
+               *y = bottom - 1;
 
            return;
        }


More information about the Xquartz-changes mailing list