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

Jeremy Huddleston jeremyhu at freedesktop.org
Thu Nov 3 02:18:05 PDT 2011


Rebased ref, commits from common ancestor:
commit 36f31115cded1cbbbd14e2dcc9ee2309b25735e8
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 1f6bbac853f8f89d3d2b22a20cafdf20cb7496fa
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 8f0f92335ce1641c5e449eb0e150e10cd6212341
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>

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..5c297d6 100644
--- a/hw/xfree86/common/xf86pciBus.c
+++ b/hw/xfree86/common/xf86pciBus.c
@@ -49,6 +49,9 @@
 #define XF86_OS_PRIVS
 #include "xf86_OSproc.h"
 
+#ifndef PCI_VENDOR_GENERIC
+#define PCI_VENDOR_GENERIC		0x00FF
+#endif
 
 /* 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 74de6ac9d4c14c59361df5b9319227d5398ed906
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 548c6fe044068ffba9b5306dc6b11f2ba22782a4
Merge: 3881b0b ffe8ec8
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Nov 2 21:35:31 2011 -0700

    Merge remote-tracking branch 'jturney/master'

commit 3881b0bf1ce11a62473650bdf6ee01a1762f6f91
Author: Gaetan Nadon <memsize at videotron.ca>
Date:   Tue Nov 1 07:17:07 2011 -0400

    mi: remove deprecated miPointerAbsoluteCursor from design doc
    
    Function was removed from the code by commit f5409aa026
    
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
    Signed-off-by: Gaetan Nadon <memsize at videotron.ca>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/dmx/doc/dmx.xml b/hw/dmx/doc/dmx.xml
index ce472c2..845eec9 100644
--- a/hw/dmx/doc/dmx.xml
+++ b/hw/dmx/doc/dmx.xml
@@ -967,17 +967,10 @@ event queue.  It is simply passed the event to be queued.
 </para>
 
 <para>The cursor position should be updated when motion events are
-enqueued, by calling either miPointerAbsoluteCursor() or
-miPointerDeltaCursor():
+enqueued by calling miPointerDeltaCursor():
 
 <variablelist>
 <varlistentry>
-<term>miPointerAbsoluteCursor()</term>
-<listitem>
-<para>This MI function is used to move the
-cursor to the absolute coordinates provided.
-</para></listitem></varlistentry>
-<varlistentry>
 <term>miPointerDeltaCursor()</term>
 <listitem>
 <para>This MI function is used to move the cursor
commit d91aa0e6601bdf3e2cfa57b3412ab14ac486edc4
Merge: 8df3a9c 401150d
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Nov 2 21:20:07 2011 -0700

    Merge remote-tracking branch 'whot/two-screen-coordinates'

commit 8df3a9ca5abbd56eb2013fa65250d21a8f18865b
Merge: 8329afa ef89548
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Nov 2 21:18:16 2011 -0700

    Merge remote-tracking branch 'koba/reviewed'

commit ffe8ec86db2655b2c83e5ae61521898140c855ac
Author: Colin Harrison <colin.harrison at virgin.net>
Date:   Sat Oct 8 15:05:22 2011 +0100

    hw/xwin: Fix a typo in ddraw.h
    
    Fix a (fortunately benign) typo in ddraw.h
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>

diff --git a/hw/xwin/ddraw.h b/hw/xwin/ddraw.h
index 2eb7c26..9d87b2b 100644
--- a/hw/xwin/ddraw.h
+++ b/hw/xwin/ddraw.h
@@ -1449,7 +1449,7 @@ DECLARE_INTERFACE_(IDirectDraw4,IUnknown)
 #define IDirectDraw4_GetAvailableVidMem(p,a,b,c) ICOM_CALL_(GetAvailableVidMem,p,(p,a,b,c))
 /*** IDirectDraw4 methods ***/
 #define IDirectDraw4_GetSurfaceFromDC(p,a,b)    ICOM_CALL_(GetSurfaceFromDC,p,(p,a,b))
-#define IDirectDraw4_RestoreAllSurfaces(pc)     ICOM_CALL_(RestoreAllSurfaces,p,(p))
+#define IDirectDraw4_RestoreAllSurfaces(p)      ICOM_CALL_(RestoreAllSurfaces,p,(p))
 #define IDirectDraw4_TestCooperativeLevel(p)    ICOM_CALL_(TestCooperativeLevel,p,(p))
 #define IDirectDraw4_GetDeviceIdentifier(p,a,b) ICOM_CALL_(GetDeviceIdentifier,p,(p,a,b))
 
commit 48fda3c52b41157313b7fd56d9f3fa3ad4166ed7
Author: Yaakov Selkowitz <yselkowitz at users.sourceforge.net>
Date:   Thu Feb 18 20:37:00 2010 -0600

    hw/xwin: Revert "Fix bug #5735, Serious flaw in CygwinX clipboard"
    
    This commit wreaks havoc with other programs which manage the clipboard,
    such as MS Office Clipboard or Win32 VNC viewers:
    
    http://sourceware.org/bugzilla/show_bug.cgi?id=9910
    
    This reverts commit 70ddd0f39d5118db72a1a4e473cbfb502f1ed9ec.
    
    Signed-off-by: Yaakov Selkowitz <yselkowitz at users.sourceforge.net>
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/winclipboardwndproc.c b/hw/xwin/winclipboardwndproc.c
index 9394b04..03da7f4 100644
--- a/hw/xwin/winclipboardwndproc.c
+++ b/hw/xwin/winclipboardwndproc.c
@@ -56,8 +56,6 @@ extern void		*g_pClipboardDisplay;
 extern Window		g_iClipboardWindow;
 extern Atom		g_atomLastOwnedSelection;
 
-/* BPS - g_hwndClipboard needed for X app->Windows paste fix */
-extern HWND		g_hwndClipboard;
 
 /* 
  * Local function prototypes
@@ -143,12 +141,6 @@ winProcessXEventsTimeout (HWND hwnd, int iWindow, Display *pDisplay,
  * Process a given Windows message
  */
 
-/* BPS - Define our own message, which we'll post to ourselves to facilitate
- * resetting the delayed rendering mechanism after each paste from X app to
- * Windows app. TODO - Perhaps move to win.h with the other WM_USER messages.
- */
-#define WM_USER_PASTE_COMPLETE		(WM_USER + 1003)
-
 LRESULT CALLBACK
 winClipboardWindowProc (HWND hwnd, UINT message, 
 			WPARAM wParam, LPARAM lParam)
@@ -343,6 +335,8 @@ winClipboardWindowProc (HWND hwnd, UINT message,
 	     * previous XSetSelectionOwner messages.
 	     */
 	    XSync (pDisplay, FALSE);
+
+            winDebug("winClipboardWindowProc - XSync done.\n");
 	    
 	    /* Release PRIMARY selection if owned */
 	    iReturn = XGetSelectionOwner (pDisplay, XA_PRIMARY);
@@ -540,13 +534,6 @@ winClipboardWindowProc (HWND hwnd, UINT message,
             ErrorF("winClipboardWindowProc - timed out waiting for WIN_XEVENTS_NOTIFY\n");
 	  }
 
-	/* BPS - Post ourselves a user message whose handler will reset the
-	 * delayed rendering mechanism after the paste is complete. This is
-	 * necessary because calling SetClipboardData() with a NULL argument
-	 * here will cause the data we just put on the clipboard to be lost!
-	 */
-	PostMessage(g_hwndClipboard, WM_USER_PASTE_COMPLETE, 0, 0);
-
 	/* Special handling for WM_RENDERALLFORMATS */
 	if (message == WM_RENDERALLFORMATS)
 	  {
@@ -564,37 +551,6 @@ winClipboardWindowProc (HWND hwnd, UINT message,
 	winDebug ("winClipboardWindowProc - WM_RENDER*FORMAT - Returning.\n");
 	return 0;
       }
-    /* BPS - This WM_USER message is posted by us. It gives us the opportunity
-     * to reset the delayed rendering mechanism after each and every paste
-     * from an X app to a Windows app. Without such a mechanism, subsequent
-     * changes of selection in the X app owning the selection are not
-     * reflected in pastes into Windows apps, since Windows won't send us the
-     * WM_RENDERFORMAT message unless someone has set changed data (or NULL)
-     * on the clipboard. */
-    case WM_USER_PASTE_COMPLETE:
-      {
-	if (hwnd != GetClipboardOwner ())
-	  /* In case we've lost the selection since posting the message */
-	  return 0;
-	winDebug ("winClipboardWindowProc - WM_USER_PASTE_COMPLETE\n");
-
-	/* Set up for another delayed rendering callback */
-	OpenClipboard (g_hwndClipboard);
-
-	/* Take ownership of the Windows clipboard */
-	EmptyClipboard ();
-
-	/* Advertise Unicode if we support it */
-	if (g_fUnicodeSupport)
-	  SetClipboardData (CF_UNICODETEXT, NULL);
-
-	/* Always advertise regular text */
-	SetClipboardData (CF_TEXT, NULL);
-
-	/* Release the clipboard */
-	CloseClipboard ();
-      }
-      return 0;
     }
 
   /* Let Windows perform default processing for unhandled messages */
commit 3ead1d810b0e157078db39712e02ea6dc85216d8
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Sun Jul 3 19:10:52 2011 +0100

    hw/xwin: Stop pretending we work on NT4
    
    We already link directly to some functions not available in NT4, so stop
    pretending we will work on NT4 and link directly to EnumDisplayMonitors()
    and SHGetFolderPath()
    
    Also remove mentions of NT4 & Win95 from error messages
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c
index 67961b7..7704392 100644
--- a/hw/xwin/InitOutput.c
+++ b/hw/xwin/InitOutput.c
@@ -588,34 +588,17 @@ winFixupPaths (void)
     }
     if (getenv("HOME") == NULL)
     {
-        HMODULE shfolder;
-        SHGETFOLDERPATHPROC shgetfolderpath = NULL;
         char buffer[MAX_PATH + 5];
         strncpy(buffer, "HOME=", 5);
 
-        /* Try to load SHGetFolderPath from shfolder.dll and shell32.dll */
-        
-        shfolder = LoadLibrary("shfolder.dll");
-        /* fallback to shell32.dll */
-        if (shfolder == NULL)
-            shfolder = LoadLibrary("shell32.dll");
-
-        /* resolve SHGetFolderPath */
-        if (shfolder != NULL)
-            shgetfolderpath = (SHGETFOLDERPATHPROC)GetProcAddress(shfolder, "SHGetFolderPathA");
-
         /* query appdata directory */
-        if (shgetfolderpath &&
-                shgetfolderpath(NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE, NULL, 0, 
-                    buffer + 5) == 0)
-        { 
+        if (SHGetFolderPathA(NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE, NULL, 0, buffer + 5) == 0)
+        {
             putenv(buffer);
         } else
         {
             winMsg (X_ERROR, "Can not determine HOME directory\n");
-        } 
-        if (shfolder != NULL)
-            FreeLibrary(shfolder);
+        }
     }
     if (!g_fLogFileChanged) {
         static char buffer[MAX_PATH];
@@ -825,10 +808,10 @@ winUseMsg (void)
 	  "\theight and initial position for that screen. Additionally\n"
 	  "\ta monitor number can be specified to start the server on,\n"
 	  "\tat which point, all coordinates become relative to that\n"
-      "\tmonitor (Not for Windows NT4 and 95). Examples:\n"
-      "\t -screen 0 800x600+100+100 at 2 ; 2nd monitor offset 100,100 size 800x600\n"
-      "\t -screen 0 1024x768 at 3        ; 3rd monitor size 1024x768\n"
-      "\t -screen 0 @1 ; on 1st monitor using its full resolution (the default)\n");
+	  "\tmonitor. Examples:\n"
+	  "\t -screen 0 800x600+100+100 at 2 ; 2nd monitor offset 100,100 size 800x600\n"
+	  "\t -screen 0 1024x768 at 3        ; 3rd monitor size 1024x768\n"
+	  "\t -screen 0 @1 ; on 1st monitor using its full resolution (the default)\n");
 
   ErrorF ("-silent-dup-error\n"
 	  "\tIf another instance of " EXECUTABLE_NAME " with the same display number is running\n"
diff --git a/hw/xwin/winmonitors.c b/hw/xwin/winmonitors.c
index a9d46f9..967ae6d 100644
--- a/hw/xwin/winmonitors.c
+++ b/hw/xwin/winmonitors.c
@@ -53,30 +53,8 @@ wBOOL CALLBACK getMonitorInfo(HMONITOR hMonitor, HDC hdc, LPRECT rect, LPARAM _d
   return TRUE;
 }
 
-typedef WINAPI wBOOL (*ENUMDISPLAYMONITORSPROC)(HDC,LPCRECT,MONITORENUMPROC,LPARAM);
-ENUMDISPLAYMONITORSPROC _EnumDisplayMonitors;
-
-wBOOL CALLBACK getMonitorInfo(HMONITOR hMonitor, HDC hdc, LPRECT rect, LPARAM _data);
-
 Bool QueryMonitor(int index, struct GetMonitorInfoData *data)
 {
-    /* Load EnumDisplayMonitors from DLL */
-    HMODULE user32;
-    FARPROC func;
-    user32 = LoadLibrary("user32.dll");
-    if (user32 == NULL)
-    {
-        winW32Error(2, "Could not open user32.dll");
-        return FALSE;
-    }
-    func = GetProcAddress(user32, "EnumDisplayMonitors");
-    if (func == NULL)
-    {
-        winW32Error(2, "Could not resolve EnumDisplayMonitors: ");
-        return FALSE;
-    }
-    _EnumDisplayMonitors = (ENUMDISPLAYMONITORSPROC)func;
-
     /* prepare data */
     if (data == NULL)
         return FALSE;
@@ -84,9 +62,5 @@ Bool QueryMonitor(int index, struct GetMonitorInfoData *data)
     data->requestedMonitor = index;
 
     /* query information */
-    _EnumDisplayMonitors(NULL, NULL, getMonitorInfo, (LPARAM) data);
-
-    /* cleanup */
-    FreeLibrary(user32);
-    return TRUE;
+    return EnumDisplayMonitors(NULL, NULL, getMonitorInfo, (LPARAM) data);
 }
diff --git a/hw/xwin/winprocarg.c b/hw/xwin/winprocarg.c
index 0c24b08..2b6949e 100644
--- a/hw/xwin/winprocarg.c
+++ b/hw/xwin/winprocarg.c
@@ -326,8 +326,7 @@ ddxProcessArgument (int argc, char *argv[], int i)
         struct GetMonitorInfoData data;
         if (!QueryMonitor(iMonitor, &data))
         {
-            ErrorF ("ddxProcessArgument - screen - "
-                    "Querying monitors is not supported on NT4 and Win95\n");
+            ErrorF ("ddxProcessArgument - screen - Querying monitors failed\n");
         } else if (data.bMonitorSpecifiedExists == TRUE) 
         {
 		  winErrorFVerb(2, "ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", iMonitor);
@@ -383,8 +382,7 @@ ddxProcessArgument (int argc, char *argv[], int i)
           struct GetMonitorInfoData data;
           if (!QueryMonitor(iMonitor, &data))
           {
-              ErrorF ("ddxProcessArgument - screen - "
-                      "Querying monitors is not supported on NT4 and Win95\n");
+              ErrorF ("ddxProcessArgument - screen - Querying monitors failed\n");
           } else if (data.bMonitorSpecifiedExists == TRUE) 
           {
 			g_ScreenInfo[nScreenNum].iMonitor = iMonitor;
@@ -411,8 +409,7 @@ ddxProcessArgument (int argc, char *argv[], int i)
         struct GetMonitorInfoData data;
         if (!QueryMonitor(iMonitor, &data))
         {
-		  ErrorF ("ddxProcessArgument - screen - "
-                  "Querying monitors is not supported on NT4 and Win95\n");
+		  ErrorF ("ddxProcessArgument - screen - Querying monitors failed\n");
         } else if (data.bMonitorSpecifiedExists == TRUE) 
         {
 		  winErrorFVerb (2, "ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", iMonitor);
commit f6529a05a2f087cb57a7fe84f226fef3780728d0
Author: Colin Harrison <colin.harrison at virgin.net>
Date:   Sat Oct 8 14:39:07 2011 +0100

    Xming: Always remove temporary file used when invoking xkbcomp on Win32
    
    When built for native Win32, pipe() & fork() aren't available, so we
    use a tempoary file and system() to invoke xkbcomp
    
    Ensure the temporary file is always removed. It was only being removed
    on most errors, not on success :S
    
    Also fix a couple of warnings which occur when built with WIN32 defined
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Jon TURNEY <jon.turney at dronecode.org.uk>

diff --git a/xkb/ddxList.c b/xkb/ddxList.c
index 7de8efc..e599f91 100644
--- a/xkb/ddxList.c
+++ b/xkb/ddxList.c
@@ -44,7 +44,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 #ifdef WIN32
 /* from ddxLoad.c */
-extern const char* Win32TempDir();
+extern const char* Win32TempDir(void);
 extern int Win32System(const char *cmdline);
 #undef System
 #define System Win32System
@@ -126,10 +126,11 @@ XkbDDXListComponent(	DeviceIntPtr 		dev,
 char 	*file,*map,*tmp,*buf=NULL;
 FILE 	*in;
 Status	status;
-int	rval;
 Bool	haveDir;
 #ifdef WIN32
 char	tmpname[PATH_MAX];
+#else
+int	rval;
 #endif
 
     if ((list->pattern[what]==NULL)||(list->pattern[what][0]=='\0'))
@@ -223,6 +224,9 @@ char	tmpname[PATH_MAX];
     buf = malloc(PATH_MAX * sizeof(char));
     if (!buf) {
         fclose(in);
+#ifdef WIN32
+        unlink(tmpname);
+#endif
         return BadAlloc;
     }
     while ((status==Success)&&((tmp=fgets(buf,PATH_MAX,in))!=NULL)) {
diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c
index e102035..219d39c 100644
--- a/xkb/ddxLoad.c
+++ b/xkb/ddxLoad.c
@@ -267,6 +267,9 @@ XkbDDXCompileKeymapByNames(	XkbDescPtr		xkb,
 		nameRtrn[nameRtrnLen-1]= '\0';
 	    }
             free(buf);
+#ifdef WIN32
+	    unlink(tmpname);
+#endif
 	    return TRUE;
 	}
 	else
commit ee1985386700288af1a8b1789dcad0d7d9c97393
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Sat Apr 16 23:28:45 2011 +0100

    hw/xwin: Link directly to TrackMouseEvent()
    
    TrackMouseEvent has existed in user32 since at least NT4, so
    don't bother with jumping through all the ancient compatibility hoops
    of finding if _TrackMouseEvent() exists in comctl32 so it can check
    if TrackMouseEvent() exists in user32 to see if it needs to emulate
    it...
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c
index 4fe5053..67961b7 100644
--- a/hw/xwin/InitOutput.c
+++ b/hw/xwin/InitOutput.c
@@ -70,12 +70,6 @@ extern HWND			g_hwndClipboard;
 extern Bool			g_fClipboard;
 #endif
 
-
-/*
-  module handle for dynamically loaded comctl32 library
-*/
-static HMODULE g_hmodCommonControls = NULL;
-
 /*
  * Function prototypes
  */
@@ -235,14 +229,6 @@ ddxGiveUp (enum ExitCode error)
    * we are guaranteed to not need the DirectDraw functions.
    */
   winReleaseDDProcAddresses();
-
-  /* Unload our TrackMouseEvent function pointer */
-  if (g_hmodCommonControls != NULL)
-    {
-      FreeLibrary (g_hmodCommonControls);
-      g_hmodCommonControls = NULL;
-      g_fpTrackMouseEvent = (FARPROC) (void (*)(void))NoopDDA;
-    }
   
   /* Free concatenated command line */
   free(g_pszCommandLine);
@@ -979,27 +965,6 @@ InitOutput (ScreenInfo *screenInfo, int argc, char *argv[])
   /* Detect supported engines */
   winDetectSupportedEngines ();
 
-  /* Load common controls library */
-  g_hmodCommonControls = LoadLibraryEx ("comctl32.dll", NULL, 0);
-
-  /* Load TrackMouseEvent function pointer */  
-  g_fpTrackMouseEvent = GetProcAddress (g_hmodCommonControls,
-					 "_TrackMouseEvent");
-  if (g_fpTrackMouseEvent == NULL)
-    {
-      winErrorFVerb (1, "InitOutput - Could not get pointer to function\n"
-	      "\t_TrackMouseEvent in comctl32.dll.  Try installing\n"
-	      "\tInternet Explorer 3.0 or greater if you have not\n"
-	      "\talready.\n");
-
-      /* Free the library since we won't need it */
-      FreeLibrary (g_hmodCommonControls);
-      g_hmodCommonControls = NULL;
-
-      /* Set function pointer to point to no operation function */
-      g_fpTrackMouseEvent = (FARPROC) (void (*)(void))NoopDDA;
-    }
-
   /* Store the instance handle */
   g_hInstance = GetModuleHandle (NULL);
 
diff --git a/hw/xwin/win.h b/hw/xwin/win.h
index 445bcab..e2e946f 100644
--- a/hw/xwin/win.h
+++ b/hw/xwin/win.h
@@ -673,7 +673,6 @@ extern DeviceIntPtr             g_pwinKeyboard;
 
 extern FARPROC			g_fpDirectDrawCreate;
 extern FARPROC			g_fpDirectDrawCreateClipper;
-extern FARPROC			g_fpTrackMouseEvent;
 
 
 /*
diff --git a/hw/xwin/winglobals.c b/hw/xwin/winglobals.c
index 2909f37..631f12e 100644
--- a/hw/xwin/winglobals.c
+++ b/hw/xwin/winglobals.c
@@ -78,13 +78,6 @@ Bool		g_fSoftwareCursor = FALSE;
 Bool		g_fSilentDupError = FALSE;
 Bool            g_fNativeGl = FALSE;
 
-/*
- * Global variables for dynamically loaded libraries and
- * their function pointers
- */
-
-FARPROC		g_fpTrackMouseEvent = (FARPROC) (void (*)(void))NoopDDA;
-
 
 #ifdef XWIN_CLIPBOARD
 /*
diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c
index fb1938b..3d23e97 100644
--- a/hw/xwin/winmultiwindowwndproc.c
+++ b/hw/xwin/winmultiwindowwndproc.c
@@ -549,8 +549,8 @@ winTopLevelWindowProc (HWND hwnd, UINT message,
 	  tme.hwndTrack = hwnd;
 
 	  /* Call the tracking function */
-	  if (!(*g_fpTrackMouseEvent) (&tme))
-	    ErrorF ("winTopLevelWindowProc - _TrackMouseEvent failed\n");
+	  if (!TrackMouseEvent(&tme))
+	    ErrorF ("winTopLevelWindowProc - TrackMouseEvent failed\n");
 
 	  /* Flag that we are tracking now */
 	  s_fTracking = TRUE;
diff --git a/hw/xwin/winwin32rootlesswndproc.c b/hw/xwin/winwin32rootlesswndproc.c
index 21506df..c60a76c 100644
--- a/hw/xwin/winwin32rootlesswndproc.c
+++ b/hw/xwin/winwin32rootlesswndproc.c
@@ -547,8 +547,8 @@ winMWExtWMWindowProc (HWND hwnd, UINT message,
 	  tme.hwndTrack = hwnd;
 
 	  /* Call the tracking function */
-	  if (!(*g_fpTrackMouseEvent) (&tme))
-	    ErrorF ("winMWExtWMWindowProc - _TrackMouseEvent failed\n");
+	  if (!TrackMouseEvent(&tme))
+	    ErrorF ("winMWExtWMWindowProc - TrackMouseEvent failed\n");
 
 	  /* Flag that we are tracking now */
 	  s_fTracking = TRUE;
diff --git a/hw/xwin/winwndproc.c b/hw/xwin/winwndproc.c
index bccd6f9..a89857a 100644
--- a/hw/xwin/winwndproc.c
+++ b/hw/xwin/winwndproc.c
@@ -776,8 +776,8 @@ winWindowProc (HWND hwnd, UINT message,
 	  tme.hwndTrack = hwnd;
 
 	  /* Call the tracking function */
-	  if (!(*g_fpTrackMouseEvent) (&tme))
-	    ErrorF ("winWindowProc - _TrackMouseEvent failed\n");
+	  if (!TrackMouseEvent(&tme))
+	    ErrorF ("winWindowProc - TrackMouseEvent failed\n");
 
 	  /* Flag that we are tracking now */
 	  s_fTracking = TRUE;
commit e2e6fab1efa6895256ac0ed4d5b054a88ad18077
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Tue Mar 23 04:45:37 2010 -0500

    Cygwin/X: Make default DPI match native DPI
    
    Make the default DPI match the current Windows DPI setting. If that
    setting can't be retrieved, change the fallback DPI value from 75 dpi
    to 96 dpi.
    
    Mark the application as dpiAware in the manifest, which prevents
    dpi virtualization for high (>96) dpi values on Vista and later.
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Signed-off-by: Yaakov Selkowitz <yselkowitz at users.sourceforge.net>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/XWin.exe.manifest b/hw/xwin/XWin.exe.manifest
index 221150d..a0d4d7d 100755
--- a/hw/xwin/XWin.exe.manifest
+++ b/hw/xwin/XWin.exe.manifest
@@ -13,4 +13,9 @@
 	     />
 	   </dependentAssembly>
 	</dependency>
+	<asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
+	   <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
+	     <dpiAware>true</dpiAware>
+	   </asmv3:windowsSettings>
+	</asmv3:application>
 </assembly>
diff --git a/hw/xwin/win.h b/hw/xwin/win.h
index 9bee9b6..445bcab 100644
--- a/hw/xwin/win.h
+++ b/hw/xwin/win.h
@@ -64,7 +64,7 @@
 #define WIN_DEFAULT_BLACKPIXEL			0
 #define WIN_DEFAULT_LINEBIAS			0
 #define WIN_DEFAULT_E3B_TIME			50 /* milliseconds */
-#define WIN_DEFAULT_DPI				75
+#define WIN_DEFAULT_DPI				96
 #define WIN_DEFAULT_REFRESH			0
 #define WIN_DEFAULT_WIN_KILL			TRUE
 #define WIN_DEFAULT_UNIX_KILL			FALSE
diff --git a/hw/xwin/winprocarg.c b/hw/xwin/winprocarg.c
index ddfe1f5..0c24b08 100644
--- a/hw/xwin/winprocarg.c
+++ b/hw/xwin/winprocarg.c
@@ -88,12 +88,27 @@ winInitializeScreenDefaults(void)
   dwWidth = GetSystemMetrics (SM_CXSCREEN);
   dwHeight = GetSystemMetrics (SM_CYSCREEN);
 
-  winErrorFVerb (2, "winInitializeScreenDefaults - w %d h %d\n",
-	  (int) dwWidth, (int) dwHeight);
+  winErrorFVerb(2, "winInitializeScreenDefaults - primary monitor w %d h %d\n", (int) dwWidth, (int) dwHeight);
 
-  /* Set a default DPI, if no parameter was passed */
+  /* Set a default DPI, if no '-dpi' option was used */
   if (monitorResolution == 0)
-    monitorResolution = WIN_DEFAULT_DPI;
+    {
+      HDC hdc = GetDC(NULL);
+      if (hdc)
+        {
+          int dpiX = GetDeviceCaps(hdc, LOGPIXELSX);
+          int dpiY = GetDeviceCaps(hdc, LOGPIXELSY);
+
+          winErrorFVerb(2, "winInitializeDefaultScreens - native DPI x %d y %d\n", dpiX, dpiY);
+          monitorResolution = dpiY;
+          ReleaseDC(NULL, hdc);
+        }
+      else
+        {
+          winErrorFVerb(1, "winInitializeDefaultScreens - Failed to retrieve native DPI, falling back to default of %d DPI\n", WIN_DEFAULT_DPI);
+          monitorResolution = WIN_DEFAULT_DPI;
+        }
+    }
 
   defaultScreenInfo.iMonitor = 1;
   defaultScreenInfo.dwWidth  = dwWidth;
commit 8329afa59dd5ea3adf7adebdb2111a9bccbb126b
Author: Aaron Plattner <aplattner at nvidia.com>
Date:   Mon Oct 31 15:01:12 2011 -0700

    dix: Reinstate GetImage window size check
    
    Commit 587c3a2d1961834558193e8e14e8e381a077a253 fixed DoGetImage to
    check windows against their backing drawables, rather than against the
    screen dimensions, to prevent reading outside the bounds of redirected
    windows' backing pixmaps (see bug #22804).  Unfortunately, while
    making that change I also removed the check that the rectangle is
    contained within the bounds of the source window, which is a violation
    of the specification:
    
        If the drawable is a window, the window must be viewable, and it
        must be the case that, if there were no inferiors or overlapping
        windows, the specified rectangle of the window would be fully
        visible on the screen *and wholly contained within the outside
        edges of the window* (or a Match error results). Note that the
        borders of the window can be included and read with this request.
    
        (emphasis mine)
    
    Reinstate the window dimension check, to return BadMatch if the
    GetImage request falls outside the bounds of the window.
    
    Fixes X Test Suite test XGetImage-15:
    
        400|0 15 1 11:05:41|IC Start
        200|0 15 11:05:41|TP Start
        520|0 15 00005146 1 1|VSW5TESTSUITE PURPOSE 15
        520|0 15 00005146 1 2|Assertion XGetImage-15.(A)
        520|0 15 00005146 1 3|When the drawable is a window and the window is viewable
        520|0 15 00005146 1 4|and it is not the case that given there were no inferiors or
        520|0 15 00005146 1 5|overlapping windows the specified rectangle of the window
        520|0 15 00005146 1 6|would be fully visible on the screen and wholly contained
        520|0 15 00005146 1 7|within the outside edges of the window, then a BadMatch
        520|0 15 00005146 1 8|error occurs.
        520|0 15 00005146 1 9|METH: Create window which is not fully visible on the screen.
        520|0 15 00005146 1 10|METH: Call XMapWindow to make sure the window is viewable.
        520|0 15 00005146 1 11|METH: Call XGetImage with rectangle extending beyond edge of screen.
        520|0 15 00005146 1 12|METH: Verify XGetImage return value is null.
        520|0 15 00005146 1 13|METH: Verify that BadMatch error occurred.
        520|0 15 00005146 1 14|METH: Create window which is fully visible on the screen.
        520|0 15 00005146 1 15|METH: Call XMapWindow to make sure the window is viewable.
        520|0 15 00005146 1 16|METH: Call XGetImage with rectangle extending beyond edge of window.
        520|0 15 00005146 1 17|METH: Verify XGetImage return value is null.
        520|0 15 00005146 1 18|METH: Verify that BadMatch error occurred.
        520|0 15 00005146 1 19|REPORT: Got Success, Expecting BadMatch
        520|0 15 00005146 1 20|REPORT: Null image not returned.
        220|0 15 1 11:05:41|FAIL
    
    Signed-off-by: Aaron Plattner <aplattner at nvidia.com>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/dix/dispatch.c b/dix/dispatch.c
index 43cb4d1..2b6cb82 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -2029,6 +2029,14 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
 	if (!pWin->viewable)
 	    return BadMatch;
 
+	/* If the drawable is a window, the rectangle must be contained within
+	 * its bounds (including the border). */
+	if (x < -wBorderWidth(pWin) ||
+	    x + width > wBorderWidth(pWin) + (int)pDraw->width ||
+	    y < -wBorderWidth(pWin) ||
+	    y + height > wBorderWidth(pWin) + (int)pDraw->height)
+	    return BadMatch;
+
 	relx += pDraw->x;
 	rely += pDraw->y;
 
commit ef895484c8a43d447d9d3ea7d4226936cc5f92cc
Author: Alexandr Shadchin <Alexandr.Shadchin at gmail.com>
Date:   Tue Oct 4 10:46:00 2011 +0600

    bsd: alpha_video: Remove unused variables
    
    Signed-off-by: Alexandr Shadchin <Alexandr.Shadchin at gmail.com>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/hw/xfree86/os-support/bsd/alpha_video.c b/hw/xfree86/os-support/bsd/alpha_video.c
index ed1adca..882fb3b 100644
--- a/hw/xfree86/os-support/bsd/alpha_video.c
+++ b/hw/xfree86/os-support/bsd/alpha_video.c
@@ -58,8 +58,6 @@ extern unsigned long dense_base(void);
 static int axpSystem = -1;
 static unsigned long hae_thresh;
 static unsigned long hae_mask;
-static unsigned long bus_base;
-static unsigned long sparse_size;
 
 static unsigned long
 memory_base(void)
@@ -290,7 +288,6 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
                 axpSystem = bsdGetAXP(); 
 	    hae_thresh = xf86AXPParams[axpSystem].hae_thresh;
             hae_mask = xf86AXPParams[axpSystem].hae_mask;
-            sparse_size = xf86AXPParams[axpSystem].size;
 #endif /* __NetBSD__ */
 	}
 	pVidMem->initialised = TRUE;
commit fea7c7a8c070ec17ec03e4cb193834b6ca72fb72
Author: Alexandr Shadchin <Alexandr.Shadchin at gmail.com>
Date:   Mon Oct 3 23:03:31 2011 +0600

    bsd: alpha_video: Simplify #include
    
    Signed-off-by: Alexandr Shadchin <Alexandr.Shadchin at gmail.com>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/hw/xfree86/os-support/bsd/alpha_video.c b/hw/xfree86/os-support/bsd/alpha_video.c
index 1a3736b..ed1adca 100644
--- a/hw/xfree86/os-support/bsd/alpha_video.c
+++ b/hw/xfree86/os-support/bsd/alpha_video.c
@@ -33,12 +33,10 @@
 
 #include <sys/param.h>
 #ifndef __NetBSD__
-#  include <sys/sysctl.h>
-#  if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
-#      include <machine/sysarch.h>
-#   endif
-# else
-#  include <machine/sysarch.h>
+#include <sys/sysctl.h>
+#endif
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
+#include <machine/sysarch.h>
 #endif
 
 #include "xf86Axp.h"
commit 93a3a28f2c1e95ea7fae6cf1c2fb50b30eae9c33
Author: Alexandr Shadchin <Alexandr.Shadchin at gmail.com>
Date:   Tue Oct 4 00:45:09 2011 +0600

    bsd: alpha_video: Function sethae() need only for FreeBSD
    
    Return value sethae() is becoming void because no caller used it. Also old
    msb_set static checked by each caller is replaced by the p.hae static checked
    in sethae() when it's called.
    
    Signed-off-by: Alexandr Shadchin <Alexandr.Shadchin at gmail.com>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/hw/xfree86/os-support/bsd/alpha_video.c b/hw/xfree86/os-support/bsd/alpha_video.c
index c47f7bf..1a3736b 100644
--- a/hw/xfree86/os-support/bsd/alpha_video.c
+++ b/hw/xfree86/os-support/bsd/alpha_video.c
@@ -435,7 +435,6 @@ xf86DisableIO()
 
 #define vuip    volatile unsigned int *
 
-static unsigned long msb_set = 0;
 static pointer memSBase = 0;
 static pointer memBase = 0;
 
@@ -473,29 +472,25 @@ writeSparse32(int Value, pointer Base, register unsigned long Offset);
 
 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 extern int sysarch(int, void *);
-#endif
 
 struct parms {
 	u_int64_t hae;
 };
 
-#ifndef __NetBSD__
-static int
+static void
 sethae(u_int64_t hae)
 {
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 #ifndef ALPHA_SETHAE
 #define ALPHA_SETHAE 0
 #endif
-	struct parms p;
-	p.hae = hae;
-	return (sysarch(ALPHA_SETHAE, (char *)&p));
-#endif
-#ifdef __OpenBSD__
-	return -1;
-#endif
+	static struct parms p;
+
+	if (p.hae != hae) {
+		p.hae = hae;
+		sysarch(ALPHA_SETHAE, (char *)&p);
+	}
 }
-#endif /* __NetBSD__ */
+#endif
 
 static pointer
 mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
@@ -550,12 +545,9 @@ readSparse8(pointer Base, register unsigned long Offset)
       if (Offset >= (hae_thresh)) {
         msb = Offset & hae_mask;
         Offset -= msb;
-	if (msb_set != msb) {
-#ifndef __NetBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 	sethae(msb);
 #endif
-	msb_set = msb;
-	}
       }
     result = *(vuip) ((unsigned long)memSBase + (Offset << 5));
     result >>= shift;
@@ -574,12 +566,9 @@ readSparse16(pointer Base, register unsigned long Offset)
     if (Offset >= (hae_thresh)) {
         msb = Offset & hae_mask;
         Offset -= msb;
-      if (msb_set != msb) {
-#ifndef __NetBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 	sethae(msb);
 #endif
-	msb_set = msb;
-      }
     }
     result = *(vuip)((unsigned long)memSBase+(Offset<<5)+(1<<(5-2)));
     result >>= shift;
@@ -604,12 +593,9 @@ writeSparse8(int Value, pointer Base, register unsigned long Offset)
     if (Offset >= (hae_thresh)) {
       msb = Offset & hae_mask;
       Offset -= msb;
-      if (msb_set != msb) {
-#ifndef __NetBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 	sethae(msb);
 #endif
-	msb_set = msb;
-      }
     }
     *(vuip) ((unsigned long)memSBase + (Offset << 5)) = b * 0x01010101;
 }
@@ -625,12 +611,9 @@ writeSparse16(int Value, pointer Base, register unsigned long Offset)
     if (Offset >= (hae_thresh)) {
       msb = Offset & hae_mask;
       Offset -= msb;
-      if (msb_set != msb) {
-#ifndef __NetBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 	sethae(msb);
 #endif
-	msb_set = msb;
-      }
     }
     *(vuip)((unsigned long)memSBase+(Offset<<5)+(1<<(5-2))) =
       w * 0x00010001;
@@ -655,12 +638,9 @@ writeSparseNB8(int Value, pointer Base, register unsigned long Offset)
     if (Offset >= (hae_thresh)) {
       msb = Offset & hae_mask;
       Offset -= msb;
-      if (msb_set != msb) {
-#ifndef __NetBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 	sethae(msb);
 #endif
-	msb_set = msb;
-      }
     }
     *(vuip) ((unsigned long)memSBase + (Offset << 5)) = b * 0x01010101;
 }
@@ -675,12 +655,9 @@ writeSparseNB16(int Value, pointer Base, register unsigned long Offset)
     if (Offset >= (hae_thresh)) {
       msb = Offset & hae_mask ;
       Offset -= msb;
-      if (msb_set != msb) {
-#ifndef __NetBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 	sethae(msb);
 #endif
-	msb_set = msb;
-      }
     }
     *(vuip)((unsigned long)memSBase+(Offset<<5)+(1<<(5-2))) =
       w * 0x00010001;
commit 05b41e2dc60a0aefc685a33260e5d8e09580908b
Author: Alexandr Shadchin <Alexandr.Shadchin at gmail.com>
Date:   Tue Oct 4 17:20:13 2011 +0600

    Move check definition MAP_FAILED in xf86_OSlib.h
    
    Also remove odd definition MAP_FAILED.
    
    Signed-off-by: Alexandr Shadchin <Alexandr.Shadchin at gmail.com>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/hw/xfree86/os-support/bsd/alpha_video.c b/hw/xfree86/os-support/bsd/alpha_video.c
index ee5c86a..c47f7bf 100644
--- a/hw/xfree86/os-support/bsd/alpha_video.c
+++ b/hw/xfree86/os-support/bsd/alpha_video.c
@@ -52,10 +52,6 @@
 #define MAP_FLAGS (MAP_FILE | MAP_SHARED)
 #endif
 
-#ifndef MAP_FAILED
-#define MAP_FAILED ((caddr_t)-1)
-#endif
-
 axpDevice bsdGetAXP(void);
 
 #ifndef __NetBSD__
diff --git a/hw/xfree86/os-support/bsd/arm_video.c b/hw/xfree86/os-support/bsd/arm_video.c
index ffc42a8..1de6c87 100644
--- a/hw/xfree86/os-support/bsd/arm_video.c
+++ b/hw/xfree86/os-support/bsd/arm_video.c
@@ -97,11 +97,6 @@ struct memAccess ioMemInfo = { CONSOLE_GET_IO_INFO, NULL, NULL,
 #define MAP_FLAGS (MAP_FILE | MAP_SHARED)
 #endif
 
-#ifndef MAP_FAILED
-#define MAP_FAILED ((caddr_t)-1)
-#endif
-
-
 #define BUS_BASE	0L
 #define BUS_BASE_BWX	0L
 
diff --git a/hw/xfree86/os-support/bsd/i386_video.c b/hw/xfree86/os-support/bsd/i386_video.c
index d16e4a8..35e00fc 100644
--- a/hw/xfree86/os-support/bsd/i386_video.c
+++ b/hw/xfree86/os-support/bsd/i386_video.c
@@ -64,10 +64,6 @@
 #define MAP_FLAGS (MAP_FILE | MAP_SHARED)
 #endif
 
-#ifndef MAP_FAILED
-#define MAP_FAILED ((caddr_t)-1)
-#endif
-
 #ifdef __OpenBSD__
 #define SYSCTL_MSG "\tCheck that you have set 'machdep.allowaperture=1'\n"\
 		   "\tin /etc/sysctl.conf and reboot your machine\n" \
diff --git a/hw/xfree86/os-support/bsd/ppc_video.c b/hw/xfree86/os-support/bsd/ppc_video.c
index 920a002..e5d832e 100644
--- a/hw/xfree86/os-support/bsd/ppc_video.c
+++ b/hw/xfree86/os-support/bsd/ppc_video.c
@@ -36,11 +36,6 @@
 
 #include "bus/Pci.h"
 
-#ifndef MAP_FAILED
-#define MAP_FAILED ((caddr_t)-1)
-#endif
-
-
 /***************************************************************************/
 /* Video Memory Mapping section                                            */
 /***************************************************************************/
diff --git a/hw/xfree86/os-support/bsd/sparc64_video.c b/hw/xfree86/os-support/bsd/sparc64_video.c
index a2a30c9..960c850 100644
--- a/hw/xfree86/os-support/bsd/sparc64_video.c
+++ b/hw/xfree86/os-support/bsd/sparc64_video.c
@@ -34,10 +34,6 @@
 #include "xf86_OSlib.h"
 #include "xf86OSpriv.h"
 
-#ifndef MAP_FAILED
-#define MAP_FAILED ((caddr_t)-1)
-#endif
-
 /***************************************************************************/
 /* Video Memory Mapping section                                            */
 /***************************************************************************/
diff --git a/hw/xfree86/os-support/linux/lnx_video.c b/hw/xfree86/os-support/linux/lnx_video.c
index 3d45511..e711784 100644
--- a/hw/xfree86/os-support/linux/lnx_video.c
+++ b/hw/xfree86/os-support/linux/lnx_video.c
@@ -46,10 +46,6 @@
 #include <asm/mtrr.h>
 #endif
 
-#ifndef MAP_FAILED
-#define MAP_FAILED ((void *)-1)
-#endif
-
 static Bool ExtendedEnabled = FALSE;
 
 #ifdef __ia64__
diff --git a/hw/xfree86/os-support/shared/bios_mmap.c b/hw/xfree86/os-support/shared/bios_mmap.c
index 33a8df0..b7b35d9 100644
--- a/hw/xfree86/os-support/shared/bios_mmap.c
+++ b/hw/xfree86/os-support/shared/bios_mmap.c
@@ -31,10 +31,6 @@
 #include "xf86Priv.h"
 #include "xf86_OSlib.h"
 
-#ifndef MAP_FAILED
-#define MAP_FAILED ((void *)-1)
-#endif
-
 /*
  * Read BIOS via mmap()ing DEV_MEM
  */
diff --git a/hw/xfree86/os-support/xf86_OSlib.h b/hw/xfree86/os-support/xf86_OSlib.h
index 34b8669..0a5861f 100644
--- a/hw/xfree86/os-support/xf86_OSlib.h
+++ b/hw/xfree86/os-support/xf86_OSlib.h
@@ -363,6 +363,10 @@
 #define DEV_MEM "/dev/mem"
 #endif
 
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
+
 #define SYSCALL(call) while(((call) == -1) && (errno == EINTR))
 
 #define XF86_OS_PRIVS
commit af56e502f5ddf1d2d495b633734cadcb023b7c36
Author: Alexandr Shadchin <Alexandr.Shadchin at gmail.com>
Date:   Tue Oct 4 16:49:22 2011 +0600

    Remove odd definition DEV_MEM
    
    DEV_MEM defined in xf86_OSlib.h
    
    Signed-off-by: Alexandr Shadchin <Alexandr.Shadchin at gmail.com>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/hw/xfree86/os-support/bsd/alpha_video.c b/hw/xfree86/os-support/bsd/alpha_video.c
index 15eb2a4..ee5c86a 100644
--- a/hw/xfree86/os-support/bsd/alpha_video.c
+++ b/hw/xfree86/os-support/bsd/alpha_video.c
@@ -197,7 +197,6 @@ static int  devMemFd = -1;
 #ifdef HAS_APERTURE_DRV
 #define DEV_APERTURE "/dev/xf86"
 #endif
-#define DEV_MEM "/dev/mem"
 
 static pointer mapVidMem(int, unsigned long, unsigned long, int);
 static void unmapVidMem(int, pointer, unsigned long);
diff --git a/hw/xfree86/os-support/bsd/arm_video.c b/hw/xfree86/os-support/bsd/arm_video.c
index eb631a7..ffc42a8 100644
--- a/hw/xfree86/os-support/bsd/arm_video.c
+++ b/hw/xfree86/os-support/bsd/arm_video.c
@@ -113,8 +113,6 @@ struct memAccess ioMemInfo = { CONSOLE_GET_IO_INFO, NULL, NULL,
 static Bool useDevMem = FALSE;
 static int  devMemFd = -1;
 
-#define DEV_MEM "/dev/mem"
-
 static pointer mapVidMem(int, unsigned long, unsigned long, int);
 static void unmapVidMem(int, pointer, unsigned long);
 
diff --git a/hw/xfree86/os-support/bsd/i386_video.c b/hw/xfree86/os-support/bsd/i386_video.c
index 20dbde8..d16e4a8 100644
--- a/hw/xfree86/os-support/bsd/i386_video.c
+++ b/hw/xfree86/os-support/bsd/i386_video.c
@@ -88,7 +88,6 @@ static int  devMemFd = -1;
 #ifdef HAS_APERTURE_DRV
 #define DEV_APERTURE "/dev/xf86"
 #endif
-#define DEV_MEM "/dev/mem"
 
 static pointer mapVidMem(int, unsigned long, unsigned long, int);
 static void unmapVidMem(int, pointer, unsigned long);
diff --git a/hw/xfree86/os-support/bsd/ppc_video.c b/hw/xfree86/os-support/bsd/ppc_video.c
index aeaf183..920a002 100644
--- a/hw/xfree86/os-support/bsd/ppc_video.c
+++ b/hw/xfree86/os-support/bsd/ppc_video.c
@@ -45,9 +45,7 @@
 /* Video Memory Mapping section                                            */
 /***************************************************************************/
 
-#ifndef __OpenBSD__
-#define DEV_MEM "/dev/mem"
-#else
+#ifdef __OpenBSD__
 #define DEV_MEM "/dev/xf86"
 #endif
 
commit 0481e9d3d1e0dbc05099184128de5cd6f13445f7
Author: Alexandr Shadchin <Alexandr.Shadchin at gmail.com>
Date:   Tue Oct 4 15:09:45 2011 +0600

    Remove BSDi support
    
    Signed-off-by: Alexandr Shadchin <Alexandr.Shadchin at gmail.com>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/hw/xfree86/os-support/xf86_OSlib.h b/hw/xfree86/os-support/xf86_OSlib.h
index 2a4d079..34b8669 100644
--- a/hw/xfree86/os-support/xf86_OSlib.h
+++ b/hw/xfree86/os-support/xf86_OSlib.h
@@ -230,20 +230,13 @@
 # include <sys/mman.h>
 # include <sys/stat.h>
 
-# if defined(__bsdi__)
-#  include <sys/param.h>
-# if (_BSDI_VERSION < 199510)
-#  include <i386/isa/vgaioctl.h>
-# endif
-# endif /* __bsdi__ */
-
 #endif /* CSRG_BASED */
 
 /**************************************************************************/
 /* Kernel of *BSD                                                         */
 /**************************************************************************/
 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
- defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__)
+ defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
 
 # include <sys/param.h>
 # if defined(__FreeBSD_version) && !defined(__FreeBSD_kernel_version)
@@ -252,12 +245,6 @@
 
 # if !defined(LINKKIT)
   /* Don't need this stuff for the Link Kit */
-#  if defined(__bsdi__)
-#   include <i386/isa/pcconsioctl.h>
-#   define CONSOLE_X_MODE_ON PCCONIOCRAW
-#   define CONSOLE_X_MODE_OFF PCCONIOCCOOK
-#   define CONSOLE_X_BELL PCCONIOCBEEP
-#  else /* __bsdi__ */
 #   ifdef SYSCONS_SUPPORT
 #    define COMPAT_SYSCONS
 #    if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
@@ -328,7 +315,6 @@
 #ifndef CONSOLE_GET_MEM_INFO 
 #    define CONSOLE_GET_MEM_INFO            _IOR('t',159,struct map_info)
 #endif
-#  endif /* __bsdi__ */
 # endif /* !LINKKIT */
 
 #if defined(USE_I386_IOPL) || defined(USE_AMD64_IOPL)
@@ -337,8 +323,7 @@
 
 # define CLEARDTR_SUPPORT
 
-#endif
-/* __FreeBSD_kernel__ || __NetBSD__ || __OpenBSD__ || __bsdi__ */
+#endif /* __FreeBSD__ || __NetBSD__ || __OpenBSD__ || __DragonFly__ */
 
 /**************************************************************************/
 /* IRIX                                                                   */
commit 8838a86fd325cb7f262a582d22ccdaa8a8f1a534
Author: Alexandr Shadchin <Alexandr.Shadchin at gmail.com>
Date:   Tue Oct 4 14:57:20 2011 +0600

    Remove unused VT_SYSREQ_DEFAULT
    
    Signed-off-by: Alexandr Shadchin <Alexandr.Shadchin at gmail.com>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/hw/xfree86/os-support/xf86_OSlib.h b/hw/xfree86/os-support/xf86_OSlib.h
index 1d59060..2a4d079 100644
--- a/hw/xfree86/os-support/xf86_OSlib.h
+++ b/hw/xfree86/os-support/xf86_OSlib.h
@@ -378,10 +378,6 @@
 #define DEV_MEM "/dev/mem"
 #endif
 
-#ifndef VT_SYSREQ_DEFAULT
-#define VT_SYSREQ_DEFAULT FALSE
-#endif
-
 #define SYSCALL(call) while(((call) == -1) && (errno == EINTR))
 
 #define XF86_OS_PRIVS
commit 401150d7dcad08be7c1f07e076f810cd61e2105c
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Tue Oct 4 11:41:17 2011 +1000

    input: change pointer screen crossing behaviour for multiple ScreenRecs
    
    miPointerSetPosition traditionally took coordinates on a per-screen basis,
    triggering a screen switch when these went out-of-bounds. For absolute
    devices, this prevented screen crossing in the negative x/y direction.
    
    This patch changes the event generation patch to handle screen coordinates
    in a desktop range (i.e. all screens together). Screen switches are
    triggered when these coordinates are not on the current screen.
    
    This unifies the pointer behaviour of single ScreenRec multihead and
    multiple ScreenRecs multihead in that the cursor by default moves about the
    whole screen rather than be confined to one single screen. The
    transformation matrix may then be used to actually confine the cursor to the
    screen again.
    
    Note: fill_pointer_events has to deal with several different coordinate
    systems. Make sure you read the comment before trying to understand the code.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/devices.c b/dix/devices.c
index 64557aa..7879405 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -612,6 +612,7 @@ CorePointerProc(DeviceIntPtr pDev, int what)
     int i = 0;
     Atom btn_labels[NBUTTONS] = {0};
     Atom axes_labels[NAXES] = {0};
+    ScreenPtr scr = screenInfo.screens[0];
 
     switch (what) {
     case DEVICE_INIT:
@@ -638,10 +639,11 @@ CorePointerProc(DeviceIntPtr pDev, int what)
                    pDev->name);
             return BadAlloc; /* IPDS only fails on allocs */
         }
-        pDev->valuator->axisVal[0] = screenInfo.screens[0]->width / 2;
-        pDev->last.valuators[0] = pDev->valuator->axisVal[0];
-        pDev->valuator->axisVal[1] = screenInfo.screens[0]->height / 2;
-        pDev->last.valuators[1] = pDev->valuator->axisVal[1];
+        /* axisVal is per-screen, last.valuators is desktop-wide */
+        pDev->valuator->axisVal[0] = scr->width / 2;
+        pDev->last.valuators[0] = pDev->valuator->axisVal[0] + scr->x;
+        pDev->valuator->axisVal[1] = scr->height / 2;
+        pDev->last.valuators[1] = pDev->valuator->axisVal[1] + scr->y;
         break;
 
     case DEVICE_CLOSE:
diff --git a/dix/getevents.c b/dix/getevents.c
index 548cc8b..cd6260b 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -295,7 +295,7 @@ updateSlaveDeviceCoords(DeviceIntPtr master, DeviceIntPtr pDev)
     int i;
     DeviceIntPtr lastSlave;
 
-    /* master->last.valuators[0]/[1] is in screen coords and the actual
+    /* master->last.valuators[0]/[1] is in desktop-wide coords and the actual
      * position of the pointer */
     pDev->last.valuators[0] = master->last.valuators[0];
     pDev->last.valuators[1] = master->last.valuators[1];
@@ -757,8 +757,8 @@ accelPointer(DeviceIntPtr dev, ValuatorMask* valuators, CARD32 ms)
  * device's coordinate range.
  *
  * @param dev The device to scale for.
- * @param[in, out] mask The mask in sceen coordinates, modified in place to
- * contain device coordinate range.
+ * @param[in, out] mask The mask in desktop coordinates, modified in place
+ * to contain device coordinate range.
  */
 static void
 scale_from_screen(DeviceIntPtr dev, ValuatorMask *mask)
@@ -768,14 +768,16 @@ scale_from_screen(DeviceIntPtr dev, ValuatorMask *mask)
 
     if (valuator_mask_isset(mask, 0))
     {
-        scaled = rescaleValuatorAxis(valuator_mask_get_double(mask, 0),
+        scaled = valuator_mask_get_double(mask, 0) + scr->x;
+        scaled = rescaleValuatorAxis(scaled,
                                      NULL, dev->valuator->axes + 0,
                                      0, scr->width);
         valuator_mask_set_double(mask, 0, scaled);
     }
     if (valuator_mask_isset(mask, 1))
     {
-        scaled = rescaleValuatorAxis(valuator_mask_get_double(mask, 1),
+        scaled = valuator_mask_get_double(mask, 1) + scr->y;
+        scaled = rescaleValuatorAxis(scaled,
                                      NULL, dev->valuator->axes + 1,
                                      0, scr->height);
         valuator_mask_set_double(mask, 1, scaled);
@@ -793,16 +795,21 @@ scale_from_screen(DeviceIntPtr dev, ValuatorMask *mask)
  *
  * The coordinates provided are always absolute. The parameter mode
  * specifies whether it was relative or absolute movement that landed us at
- * those coordinates.
+ * those coordinates. see fill_pointer_events for information on coordinate
+ * systems.
  *
  * @param dev The device to be moved.
  * @param mode Movement mode (Absolute or Relative)
- * @param mask Mask of axis values for this event
- * @param screenx Screen x coordinate the sprite is on after the update.
- * @param screeny Screen y coordinate the sprite is on after the update.
+ * @param[in,out] mask Mask of axis values for this event, returns the
+ * per-screen device coordinates after confinement
+ * @param[out] devx x desktop-wide coordinate in device coordinate system
+ * @param[out] devy y desktop-wide coordinate in device coordinate system
+ * @param[out] screenx x coordinate in desktop coordinate system
+ * @param[out] screeny y coordinate in desktop coordinate system
  */
 static ScreenPtr
 positionSprite(DeviceIntPtr dev, int mode, ValuatorMask *mask,
+               double *devx, double *devy,
                double *screenx, double *screeny)
 {
     double x, y;
@@ -821,16 +828,20 @@ positionSprite(DeviceIntPtr dev, int mode, ValuatorMask *mask,
     else
         y = dev->last.valuators[1];
 
-    /* scale x&y to screen */
+    /* scale x&y to desktop coordinates */
     *screenx = rescaleValuatorAxis(x, dev->valuator->axes + 0, NULL,
-                                   0, scr->width);
+                                   screenInfo.x, screenInfo.width);
     *screeny = rescaleValuatorAxis(y, dev->valuator->axes + 1, NULL,
-                                   0, scr->height);
+                                   screenInfo.y, screenInfo.height);
 
     tmpx = *screenx;
     tmpy = *screeny;
+    *devx = x;
+    *devy = y;
+
     /* miPointerSetPosition takes care of crossing screens for us, as well as
-     * clipping to the current screen. */
+     * clipping to the current screen. Coordinates returned are in desktop
+     * coord system */
     scr = miPointerSetPosition(dev, mode, screenx, screeny);
 
     /* If we were constrained, rescale x/y from the screen coordinates so
@@ -838,17 +849,24 @@ positionSprite(DeviceIntPtr dev, int mode, ValuatorMask *mask,
      * crossing this doesn't matter much, the coords would be 0 or max.
      */
     if (tmpx != *screenx)
-        x = rescaleValuatorAxis(*screenx, NULL, dev->valuator->axes + 0,
-                                0, scr->width);
-    if (tmpy != *screeny)
-        y = rescaleValuatorAxis(*screeny, NULL, dev->valuator->axes + 1,
-                                0, scr->height);
+        *devx = rescaleValuatorAxis(*screenx, NULL, dev->valuator->axes + 0,
+                                    screenInfo.x, screenInfo.width);
 
+    if (tmpy != *screeny)
+        *devy = rescaleValuatorAxis(*screeny, NULL, dev->valuator->axes + 1,
+                                    screenInfo.y, screenInfo.height);
 
-    if (valuator_mask_isset(mask, 0))
+    /* Recalculate the per-screen device coordinates */
+    if (valuator_mask_isset(mask, 0)) {
+        x = rescaleValuatorAxis(*screenx - scr->x, NULL, dev->valuator->axes + 0,
+                                0, scr->width);
         valuator_mask_set_double(mask, 0, x);
-    if (valuator_mask_isset(mask, 1))
+    }
+    if (valuator_mask_isset(mask, 1)) {
+        y = rescaleValuatorAxis(*screeny - scr->y, NULL, dev->valuator->axes + 1,
+                                0, scr->height);
         valuator_mask_set_double(mask, 1, y);
+    }
 
     return scr;
 }
@@ -1105,6 +1123,38 @@ QueuePointerEvents(DeviceIntPtr device, int type,
  *
  * Should not be called by anyone other than GetPointerEvents.
  *
+ * We use several different coordinate systems and need to switch between
+ * the three in fill_pointer_events, positionSprite and
+ * miPointerSetPosition. "desktop" refers to the width/height of all
+ * screenInfo.screens[n]->width/height added up. "screen" is ScreenRec, not
+ * output.
+ *
+ * Coordinate systems:
+ * - relative events have a mask_in in relative coordinates, mapped to
+ *   pixels. These events are mapped to the current position±delta.
+ * - absolute events have a mask_in in absolute device coordinates in
+ *   device-specific range. This range is mapped to the desktop.
+ * - POINTER_SCREEN absolute events (x86WarpCursor) are in screen-relative
+ *   screen coordinate range.
+ * - rootx/rooty in events must be be relative to the current screen's
+ *   origin (screen coordinate system)
+ * - XI2 valuators must be relative to the current screen's origin. On
+ *   the protocol the device min/max range maps to the current screen.
+ *
+ * For screen switching we need to get the desktop coordinates for each
+ * event, then map that to the respective position on each screen and
+ * position the cursor there.
+ * The device's last.valuator[] stores the last position in desktop-wide
+ * coordinates (in device range for slave devices, desktop range for master
+ * devices).
+ *
+ * screen-relative device coordinates requires scaling: A device coordinate
+ * x/y of range [n..m] that maps to positions Sx/Sy on Screen S must be
+ * rescaled to match Sx/Sy for [n..m]. In the simplest example, x of (m/2-1)
+ * is the last coordinate on the first screen and must be rescaled for the
+ * event to be m. XI2 clients that do their own coordinate mapping would
+ * otherwise interpret the position of the device elsewere to the cursor.
+ *
  * @return the number of events written into events.
  */
 static int
@@ -1115,8 +1165,10 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type,
     int num_events = 1, i;
     DeviceEvent *event;
     RawDeviceEvent *raw;
-    double screenx = 0.0, screeny = 0.0;
+    double screenx = 0.0, screeny = 0.0; /* desktop coordinate system */
+    double devx = 0.0, devy = 0.0; /* desktop-wide in device coords */
     ValuatorMask mask;
+    ScreenPtr scr;
 
     switch (type)
     {
@@ -1155,6 +1207,8 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type,
         set_raw_valuators(raw, &mask, raw->valuators.data_raw);
     }
 
+    /* valuators are in driver-native format (rel or abs) */
+
     if (flags & POINTER_ABSOLUTE)
     {
         if (flags & POINTER_SCREEN) /* valuators are in screen coords */
@@ -1168,22 +1222,34 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type,
         moveRelative(pDev, &mask);
     }
 
+    /* valuators are in device coordinate system in absolute coordinates */
+
     if ((flags & POINTER_NORAW) == 0)
         set_raw_valuators(raw, &mask, raw->valuators.data);
 
-    positionSprite(pDev, (flags & POINTER_ABSOLUTE) ? Absolute : Relative,
-                   &mask, &screenx, &screeny);
+    scr = positionSprite(pDev, (flags & POINTER_ABSOLUTE) ? Absolute : Relative,
+                         &mask, &devx, &devy, &screenx, &screeny);
+
+    /* screenx, screeny are in desktop coordinates,
+       mask is in device coordinates per-screen (the event data)
+       devx/devy is in device coordinate desktop-wide */
     updateHistory(pDev, &mask, ms);
 
     clipValuators(pDev, &mask);
 
-    for (i = 0; i < valuator_mask_size(&mask); i++)
+    /* store desktop-wide in last.valuators */
+    if (valuator_mask_isset(&mask, 0))
+        pDev->last.valuators[0] = devx;
+    if (valuator_mask_isset(&mask, 1))
+        pDev->last.valuators[1] = devy;
+
+    for (i = 2; i < valuator_mask_size(&mask); i++)
     {
         if (valuator_mask_isset(&mask, i))
             pDev->last.valuators[i] = valuator_mask_get_double(&mask, i);
     }
 
-    /* Update the MD's co-ordinates, which are always in screen space. */
+    /* Update the MD's co-ordinates, which are always in desktop space. */
     if (!IsMaster(pDev) || !IsFloating(pDev)) {
         DeviceIntPtr master = GetMaster(pDev, MASTER_POINTER);
         master->last.valuators[0] = screenx;
@@ -1209,8 +1275,8 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type,
         event->detail.button = buttons;
     }
 
-    /* root_x and root_y must be in screen co-ordinates */
-    event_set_root_coordinates(event, screenx, screeny);
+    /* root_x and root_y must be in per-screen co-ordinates */
+    event_set_root_coordinates(event, screenx - scr->x, screeny - scr->y);
 
     if (flags & POINTER_EMULATED) {
         raw->flags = XIPointerEmulated;
diff --git a/include/inputstr.h b/include/inputstr.h
index 9d4108e..1238f93 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -534,8 +534,9 @@ typedef struct _DeviceIntRec {
     DeviceIntPtr        lastSlave;  /* last slave device used */
 
     /* last valuator values recorded, not posted to client;
-     * for slave devices, valuators is in device coordinates
-     * for master devices, valuators is in screen coordinates
+     * for slave devices, valuators is in device coordinates, mapped to the
+     * desktop
+     * for master devices, valuators is in desktop coordinates.
      * see dix/getevents.c
      * remainder supports acceleration
      */
diff --git a/mi/mipointer.c b/mi/mipointer.c
index 55e4081..998c86c 100644
--- a/mi/mipointer.c
+++ b/mi/mipointer.c
@@ -569,8 +569,8 @@ miPointerMoveNoEvent (DeviceIntPtr pDev, ScreenPtr pScreen,
  *
  * @param pDev The device to move
  * @param mode Movement mode (Absolute or Relative)
- * @param[in,out] screenx The x coordinate in screen coordinates
- * @param[in,out] screeny The y coordinate in screen coordinates
+ * @param[in,out] screenx The x coordinate in desktop coordinates
+ * @param[in,out] screeny The y coordinate in desktop coordinates
  */
 ScreenPtr
 miPointerSetPosition(DeviceIntPtr pDev, int mode, double *screenx, double *screeny)
@@ -579,6 +579,7 @@ miPointerSetPosition(DeviceIntPtr pDev, int mode, double *screenx, double *scree
     ScreenPtr		pScreen;
     ScreenPtr		newScreen;
     int			x, y;
+    Bool		switch_screen = FALSE;
 
     miPointerPtr        pPointer; 
 
@@ -593,7 +594,14 @@ miPointerSetPosition(DeviceIntPtr pDev, int mode, double *screenx, double *scree
     x = trunc(*screenx);
     y = trunc(*screeny);
 
-    if (x < 0 || x >= pScreen->width || y < 0 || y >= pScreen->height)
+    switch_screen = !point_on_screen(pScreen, x, y);
+
+    /* Switch to per-screen coordinates for CursorOffScreen and
+     * Pointer->limits */
+    x -= pScreen->x;
+    y -= pScreen->y;
+
+    if (switch_screen)
     {
 	pScreenPriv = GetScreenPrivate (pScreen);
 	if (!pPointer->confined)
@@ -628,6 +636,10 @@ miPointerSetPosition(DeviceIntPtr pDev, int mode, double *screenx, double *scree
             pPointer->pScreen != pScreen)
         miPointerMoveNoEvent(pDev, pScreen, x, y);
 
+    /* Convert to desktop coordinates again */
+    x += pScreen->x;
+    y += pScreen->y;
+
     /* In the event we actually change screen or we get confined, we just
      * drop the float component on the floor
      * FIXME: only drop remainder for ConstrainCursorHarder, not for screen
commit 6bd0eff40fae1e5d8fed28751851eb5b932d131b
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed Oct 12 15:53:57 2011 +1000

    dix: extend rescaleValuatorAxis to take a minimum default
    
    Allow rescaling to non-zero based axis ranges as default (for when screen
    offsets are non-zero). Currently unused.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/getevents.c b/dix/getevents.c
index 874189f..548cc8b 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -257,10 +257,10 @@ CreateClassesChangedEvent(InternalEvent* event,
  */
 static double
 rescaleValuatorAxis(double coord, AxisInfoPtr from, AxisInfoPtr to,
-                    double defmax)
+                    double defmin, double defmax)
 {
-    double fmin = 0.0, fmax = defmax;
-    double tmin = 0.0, tmax = defmax;
+    double fmin = defmin, fmax = defmax;
+    double tmin = defmin, tmax = defmax;
 
     if (from && from->min_value < from->max_value) {
         fmin = from->min_value;
@@ -309,14 +309,14 @@ updateSlaveDeviceCoords(DeviceIntPtr master, DeviceIntPtr pDev)
         pDev->last.valuators[0] = rescaleValuatorAxis(pDev->last.valuators[0],
                                                       NULL,
                                                       pDev->valuator->axes + 0,
-                                                      scr->width);
+                                                      0, scr->width);
     }
     if(pDev->valuator->numAxes > 1)
     {
         pDev->last.valuators[1] = rescaleValuatorAxis(pDev->last.valuators[1],
                                                       NULL,
                                                       pDev->valuator->axes + 1,
-                                                      scr->height);
+                                                      0, scr->height);
     }
 
     /* calculate the other axis as well based on info from the old
@@ -333,7 +333,7 @@ updateSlaveDeviceCoords(DeviceIntPtr master, DeviceIntPtr pDev)
             {
                 double val = pDev->last.valuators[i];
                 val = rescaleValuatorAxis(val, lastSlave->valuator->axes + i,
-                                          pDev->valuator->axes + i, 0);
+                                          pDev->valuator->axes + i, 0, 0);
                 pDev->last.valuators[i] = val;
             }
         }
@@ -445,7 +445,7 @@ GetMotionHistory(DeviceIntPtr pDev, xTimecoord **buff, unsigned long start,
                 /* scale to screen coords */
                 to = &core_axis;
                 to->max_value = pScreen->width;
-                coord = rescaleValuatorAxis(coord, &from, to, pScreen->width);
+                coord = rescaleValuatorAxis(coord, &from, to, 0, pScreen->width);
 
                 memcpy(corebuf, &coord, sizeof(INT16));
                 corebuf++;
@@ -456,7 +456,7 @@ GetMotionHistory(DeviceIntPtr pDev, xTimecoord **buff, unsigned long start,
                 memcpy(&coord, icbuf++, sizeof(INT32));
 
                 to->max_value = pScreen->height;
-                coord = rescaleValuatorAxis(coord, &from, to, pScreen->height);
+                coord = rescaleValuatorAxis(coord, &from, to, 0, pScreen->height);
                 memcpy(corebuf, &coord, sizeof(INT16));
 
             } else if (IsMaster(pDev))
@@ -484,7 +484,7 @@ GetMotionHistory(DeviceIntPtr pDev, xTimecoord **buff, unsigned long start,
                         from.max_value = pScreen->height;
 
                     /* scale from stored range into current range */
-                    coord = rescaleValuatorAxis(coord, &from, to, 0);
+                    coord = rescaleValuatorAxis(coord, &from, to, 0, 0);
                     memcpy(ocbuf, &coord, sizeof(INT32));
                     ocbuf++;
                 }
@@ -770,14 +770,14 @@ scale_from_screen(DeviceIntPtr dev, ValuatorMask *mask)
     {
         scaled = rescaleValuatorAxis(valuator_mask_get_double(mask, 0),
                                      NULL, dev->valuator->axes + 0,
-                                     scr->width);
+                                     0, scr->width);
         valuator_mask_set_double(mask, 0, scaled);
     }
     if (valuator_mask_isset(mask, 1))
     {
         scaled = rescaleValuatorAxis(valuator_mask_get_double(mask, 1),
                                      NULL, dev->valuator->axes + 1,
-                                     scr->height);
+                                     0, scr->height);
         valuator_mask_set_double(mask, 1, scaled);
     }
 }
@@ -823,9 +823,9 @@ positionSprite(DeviceIntPtr dev, int mode, ValuatorMask *mask,
 
     /* scale x&y to screen */
     *screenx = rescaleValuatorAxis(x, dev->valuator->axes + 0, NULL,
-                                   scr->width);
+                                   0, scr->width);
     *screeny = rescaleValuatorAxis(y, dev->valuator->axes + 1, NULL,
-                                   scr->height);
+                                   0, scr->height);
 
     tmpx = *screenx;
     tmpy = *screeny;
@@ -839,10 +839,10 @@ positionSprite(DeviceIntPtr dev, int mode, ValuatorMask *mask,
      */
     if (tmpx != *screenx)
         x = rescaleValuatorAxis(*screenx, NULL, dev->valuator->axes + 0,
-                                scr->width);
+                                0, scr->width);
     if (tmpy != *screeny)
         y = rescaleValuatorAxis(*screeny, NULL, dev->valuator->axes + 1,
-                                scr->height);
+                                0, scr->height);
 
 
     if (valuator_mask_isset(mask, 0))
commit 8bebb4b4896d8b6ba3309b5b28fce883bb9f8a96
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed Sep 7 14:04:10 2011 +1000

    Store desktop dimensions in screenInfo.
    
    For Zaphod mode screen crossing handling we need to know the size of all
    screens together (i.e. the whole desktop size). Store that in the screenInfo to
    have it readily available in events.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/dispatch.c b/dix/dispatch.c
index 43cb4d1..4a4481a 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -3898,6 +3898,8 @@ AddScreen(
 	return -1;
     }
 
+    update_desktop_dimensions();
+
     dixRegisterScreenPrivateKey(&cursorScreenDevPriv, pScreen, PRIVATE_CURSOR, 0);
 
     return i;
diff --git a/dix/inpututils.c b/dix/inpututils.c
index eeae2a7..8a83444 100644
--- a/dix/inpututils.c
+++ b/dix/inpututils.c
@@ -628,6 +628,30 @@ point_on_screen(ScreenPtr pScreen, int x, int y)
 }
 
 /**
+ * Update desktop dimensions on the screenInfo struct.
+ */
+void
+update_desktop_dimensions(void)
+{
+    int i;
+    int x1 = INT_MAX, y1 = INT_MAX; /* top-left */
+    int x2 = INT_MIN, y2 = INT_MIN; /* bottom-right */
+
+    for (i = 0; i < screenInfo.numScreens; i++) {
+        ScreenPtr screen = screenInfo.screens[i];
+        x1 = min(x1, screen->x);
+        y1 = min(y1, screen->y);
+        x2 = max(x2, screen->x + screen->width);
+        y2 = max(y2, screen->y + screen->height);
+    }
+
+    screenInfo.x = x1;
+    screenInfo.y = y1;
+    screenInfo.width = x2 - x1;
+    screenInfo.height = y2 - y1;
+}
+
+/*
  * Delete the element with the key from the list, freeing all memory
  * associated with the element..
  */
diff --git a/hw/xfree86/common/xf86Cursor.c b/hw/xfree86/common/xf86Cursor.c
index 929f047..6f5d726 100644
--- a/hw/xfree86/common/xf86Cursor.c
+++ b/hw/xfree86/common/xf86Cursor.c
@@ -838,6 +838,8 @@ xf86InitOrigins(void)
 		FillOutEdge(pLayout->down, pScreen->width);
 	}
     }
+
+    update_desktop_dimensions();
 }
 
 void
diff --git a/hw/xfree86/common/xf86RandR.c b/hw/xfree86/common/xf86RandR.c
index 4663d03..d0e4784 100644
--- a/hw/xfree86/common/xf86RandR.c
+++ b/hw/xfree86/common/xf86RandR.c
@@ -313,6 +313,9 @@ xf86RandRSetConfig (ScreenPtr		pScreen,
 	return FALSE;
     }
 
+
+    update_desktop_dimensions();
+
     /*
      * Move the cursor back where it belongs; SwitchMode repositions it
      * FIXME: duplicated code, see modes/xf86RandR12.c
diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index cb20d1c..d5031a2 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -736,6 +736,8 @@ xf86RandR12ScreenSetSize (ScreenPtr	pScreen,
     xf86SetViewport (pScreen, 0, 0);
 
 finish:
+    update_desktop_dimensions();
+
     if (pRoot && pScrn->vtSema)
 	(*pScrn->EnableDisableFBAccess) (pScreen->myNum, TRUE);
 #if RANDR_12_INTERFACE
diff --git a/include/input.h b/include/input.h
index b7de5ca..2544996 100644
--- a/include/input.h
+++ b/include/input.h
@@ -609,5 +609,6 @@ extern _X_EXPORT void input_option_set_key(InputOption *opt, const char* key);
 extern _X_EXPORT void input_option_set_value(InputOption *opt, const char* value);
 
 extern _X_HIDDEN Bool point_on_screen(ScreenPtr pScreen, int x, int y);
+extern _X_HIDDEN void update_desktop_dimensions(void);
 
 #endif /* INPUT_H */
diff --git a/include/scrnintstr.h b/include/scrnintstr.h
index a9357e8..132a671 100644
--- a/include/scrnintstr.h
+++ b/include/scrnintstr.h
@@ -561,6 +561,10 @@ typedef struct _ScreenInfo {
 		formats[MAXFORMATS];
     int		numScreens;
     ScreenPtr	screens[MAXSCREENS];
+    int         x;      /* origin */
+    int         y;      /* origin */
+    int		width;  /* total width of all screens together */
+    int		height; /* total height of all screens together */
 } ScreenInfo;
 
 extern _X_EXPORT ScreenInfo screenInfo;
diff --git a/test/misc.c b/test/misc.c
index 3d3b1a1..d98449b 100644
--- a/test/misc.c
+++ b/test/misc.c
@@ -27,6 +27,9 @@
 
 #include <stdint.h>
 #include "misc.h"
+#include "scrnintstr.h"
+
+ScreenInfo screenInfo;
 
 static void dix_version_compare(void)
 {
@@ -54,9 +57,110 @@ static void dix_version_compare(void)
     assert(rc < 0);
 }
 
+static void dix_update_desktop_dimensions(void)
+{
+    int i;
+    int x, y, w, h;
+    int w2, h2;
+    ScreenRec screens[MAXSCREENS];
+
+    for (i = 0; i < MAXSCREENS; i++)
+        screenInfo.screens[i] = &screens[i];
+
+    x = 0;
+    y = 0;
+    w = 10;
+    h = 5;
+    w2 = 35;
+    h2 = 25;
+
+#define assert_dimensions(_x, _y, _w, _h) \
+    update_desktop_dimensions();          \
+    printf("%d %d %d %d\n", screenInfo.x, screenInfo.y, screenInfo.width, screenInfo.height); \
+    assert(screenInfo.x == _x);           \
+    assert(screenInfo.y == _y);           \
+    assert(screenInfo.width == _w);       \
+    assert(screenInfo.height == _h);
+
+#define set_screen(idx, _x, _y, _w, _h)   \
+    screenInfo.screens[idx]->x = _x;      \
+    screenInfo.screens[idx]->y = _y;      \
+    screenInfo.screens[idx]->width = _w;  \
+    screenInfo.screens[idx]->height = _h; \
+
+    printf("Testing\n");
+
+    /* single screen */
+    screenInfo.numScreens = 1;
+    set_screen(0, x, y, w, h);
+    assert_dimensions(x, y, w, h);
+
+    /* dualhead rightof */
+    screenInfo.numScreens = 2;
+    set_screen(1, w, 0, w2, h2);
+    assert_dimensions(x, y, w + w2, h2);
+
+    /* dualhead belowof */
+    screenInfo.numScreens = 2;
+    set_screen(1, 0, h, w2, h2);
+    assert_dimensions(x, y, w2, h + h2);
+
+    /* triplehead L shape */
+    screenInfo.numScreens = 3;
+    set_screen(1, 0, h, w2, h2);
+    set_screen(2, w2, h2, w, h);
+    assert_dimensions(x, y, w + w2, h + h2);
+
+    /* quadhead 2x2 */
+    screenInfo.numScreens = 4;
+    set_screen(1, 0, h, w, h);
+    set_screen(2, w, h, w, h2);
+    set_screen(3, w, 0, w2, h);
+    assert_dimensions(x, y, w + w2, h + h2);
+
+    /* quadhead horiz line */
+    screenInfo.numScreens = 4;
+    set_screen(1, w, 0, w, h);
+    set_screen(2, 2 * w, 0, w, h);
+    set_screen(3, 3 * w, 0, w, h);
+    assert_dimensions(x, y, 4 * w, h);
+
+    /* quadhead vert line */
+    screenInfo.numScreens = 4;
+    set_screen(1, 0, h, w, h);
+    set_screen(2, 0, 2 * h, w, h);
+    set_screen(3, 0, 3 * h, w, h);
+    assert_dimensions(x, y, w, 4 * h);
+
+
+    /* x overlap */
+    screenInfo.numScreens = 2;
+    set_screen(0, 0, 0, w2, h2);
+    set_screen(1, w, 0, w2, h2);
+    assert_dimensions(x, y, w2 + w, h2);
+
+    /* y overlap */
+    screenInfo.numScreens = 2;
+    set_screen(0, 0, 0, w2, h2);
+    set_screen(1, 0, h, w2, h2);
+    assert_dimensions(x, y, w2, h2 + h);
+
+    /* negative origin */
+    screenInfo.numScreens = 1;
+    set_screen(0, -w2, -h2, w, h);
+    assert_dimensions(-w2, -h2, w, h);
+
+    /* dualhead negative origin, overlap */
+    screenInfo.numScreens = 2;
+    set_screen(0, -w2, -h2, w2, h2);
+    set_screen(1, -w, -h, w, h);
+    assert_dimensions(-w2, -h2, w2, h2);
+}
+
 int main(int argc, char** argv)
 {
     dix_version_compare();
+    dix_update_desktop_dimensions();
 
     return 0;
 }
commit 9cbfa4739a51e4cc6b8094833928bf8678f63876
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Tue Sep 6 15:55:19 2011 +1000

    xfree86: remove xf86XInputSetScreen
    
    Keeping track of which screen the pointer within the input driver is
    obsolete now. To bind to a screen, use the transformation matrix instead.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index ea1f927..ad18339 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -1345,25 +1345,6 @@ xf86ScaleAxis(int	Cx,
     return X;
 }
 
-/*
- * This function checks the given screen against the current screen and
- * makes changes if appropriate. It should be called from an XInput driver's
- * ReadInput function before any events are posted, if the device is screen
- * specific like a touch screen.
- */
-void
-xf86XInputSetScreen(InputInfoPtr	pInfo,
-		    int			screen_number,
-		    int			x,
-		    int			y)
-{
-    if (miPointerGetScreen(pInfo->dev) !=
-          screenInfo.screens[screen_number]) {
-	miPointerSetScreen(pInfo->dev, screen_number, x, y);
-    }
-}
-
-
 Bool
 xf86InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval, int maxval,
 			   int resolution, int min_res, int max_res, int mode)
diff --git a/hw/xfree86/common/xf86Xinput.h b/hw/xfree86/common/xf86Xinput.h
index 189f7ab..909fb57 100644
--- a/hw/xfree86/common/xf86Xinput.h
+++ b/hw/xfree86/common/xf86Xinput.h
@@ -143,7 +143,6 @@ extern _X_EXPORT void xf86PostKeyboardEvent(DeviceIntPtr device, unsigned int ke
                            int is_down);
 extern _X_EXPORT InputInfoPtr xf86FirstLocalDevice(void);
 extern _X_EXPORT int xf86ScaleAxis(int Cx, int to_max, int to_min, int from_max, int from_min);
-extern _X_EXPORT void xf86XInputSetScreen(InputInfoPtr pInfo, int screen_number, int x, int y);
 extern _X_EXPORT void xf86ProcessCommonOptions(InputInfoPtr pInfo, XF86OptionPtr options);
 extern _X_EXPORT Bool xf86InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval,
 				int maxval, int resolution, int min_res,


More information about the Xquartz-changes mailing list