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

Jeremy Huddleston jeremyhu at freedesktop.org
Thu Mar 3 18:17:16 PST 2011


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

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

diff --git a/configure.ac b/configure.ac
index 0a06391..b9516b3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -80,6 +80,12 @@ XORG_PROG_RAWCPP
 # easier overrides at build time.
 XSERVER_CFLAGS='$(CWARNFLAGS)'
 
+dnl Explicitly add -fno-strict-aliasing since this option should disappear
+dnl from util-macros CWARNFLAGS
+if  test "x$GCC" = xyes ; then
+    XSERVER_CFLAGS="$XSERVER_CFLAGS -fno-strict-aliasing"
+fi
+
 dnl Check for dtrace program (needed to build Xserver dtrace probes)
 dnl Also checks for <sys/sdt.h>, since some Linux distros have an 
 dnl ISDN trace program named dtrace
commit d1570a3ceb7211d0d21e75bd2c52bc27411b4f77
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Fri Feb 12 19:48:52 2010 -0800

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

diff --git a/fb/fb.h b/fb/fb.h
index 021a940..0b248e1 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -2079,11 +2079,8 @@ fbFillRegionSolid (DrawablePtr	pDrawable,
 		   FbBits	xor);
 
 extern _X_EXPORT pixman_image_t *
-image_from_pict (PicturePtr	pict,
-		 Bool		has_clip,
-		 int		*xoff,
-		 int		*yoff);
-
+image_from_pict (PicturePtr pict,
+		 Bool       has_clip);
 extern _X_EXPORT void free_pixman_pict (PicturePtr, pixman_image_t *);
 
 #endif /* _FB_H_ */
diff --git a/fb/fbpict.c b/fb/fbpict.c
index 7636040..af1920b 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -50,24 +50,19 @@ fbComposite (CARD8      op,
 	     CARD16     height)
 {
     pixman_image_t *src, *mask, *dest;
-    int src_xoff, src_yoff;
-    int msk_xoff, msk_yoff;
-    int dst_xoff, dst_yoff;
     
     miCompositeSourceValidate (pSrc, xSrc - xDst, ySrc - yDst, width, height);
     if (pMask)
 	miCompositeSourceValidate (pMask, xMask - xDst, yMask - yDst, width, height);
     
-    src = image_from_pict (pSrc, FALSE, &src_xoff, &src_yoff);
-    mask = image_from_pict (pMask, FALSE, &msk_xoff, &msk_yoff);
-    dest = image_from_pict (pDst, TRUE, &dst_xoff, &dst_yoff);
+    src = image_from_pict (pSrc, TRUE);
+    mask = image_from_pict (pMask, TRUE);
+    dest = image_from_pict (pDst, TRUE);
 
     if (src && dest && !(pMask && !mask))
     {
 	pixman_image_composite (op, src, mask, dest,
-				xSrc + src_xoff, ySrc + src_yoff,
-				xMask + msk_xoff, yMask + msk_yoff,
-				xDst + dst_xoff, yDst + dst_yoff,
+				xSrc, ySrc, xMask, yMask, xDst, yDst,
 				width, height);
     }
 
@@ -146,22 +141,22 @@ create_conical_gradient_image (PictGradient *gradient)
 
 static pixman_image_t *
 create_bits_picture (PicturePtr pict,
-		     Bool       has_clip,
-		     int	*xoff,
-		     int	*yoff)
+		     Bool       has_clip)
 {
-    PixmapPtr pixmap;
     FbBits *bits;
     FbStride stride;
-    int bpp;
+    int bpp, xoff, yoff;
     pixman_image_t *image;
     
-    fbGetDrawablePixmap (pict->pDrawable, pixmap, *xoff, *yoff);
-    fbGetPixmapBitsData(pixmap, bits, stride, bpp);
+    fbGetDrawable (pict->pDrawable, bits, stride, bpp, xoff, yoff);
+
+    bits = (FbBits*)((CARD8*)bits +
+		     (pict->pDrawable->y + yoff) * stride * sizeof(FbBits) +
+		     (pict->pDrawable->x + xoff) * (bpp / 8));
 
     image = pixman_image_create_bits (
 	pict->format,
-	pixmap->drawable.width, pixmap->drawable.height,
+	pict->pDrawable->width, pict->pDrawable->height,
 	(uint32_t *)bits, stride * sizeof (FbStride));
     
     
@@ -187,55 +182,33 @@ create_bits_picture (PicturePtr pict,
 	if (pict->clientClipType != CT_NONE)
 	    pixman_image_set_has_client_clip (image, TRUE);
 
-	if (*xoff || *yoff)
-	    pixman_region_translate (pict->pCompositeClip, *xoff, *yoff);
+	pixman_region_translate (pict->pCompositeClip, - pict->pDrawable->x, - pict->pDrawable->y);
 
 	pixman_image_set_clip_region (image, pict->pCompositeClip);
 
-	if (*xoff || *yoff)
-	    pixman_region_translate (pict->pCompositeClip, -*xoff, -*yoff);
+	pixman_region_translate (pict->pCompositeClip, pict->pDrawable->x, pict->pDrawable->y);
     }
     
     /* Indexed table */
     if (pict->pFormat->index.devPrivate)
 	pixman_image_set_indexed (image, pict->pFormat->index.devPrivate);
 
-    /* Add in drawable origin to position within the image */
-    *xoff += pict->pDrawable->x;
-    *yoff += pict->pDrawable->y;
-
     return image;
 }
 
 static pixman_image_t *
-image_from_pict_internal (PicturePtr pict, Bool has_clip, int *xoff, int *yoff, Bool is_alpha_map);
+image_from_pict_internal (PicturePtr pict, Bool has_clip, Bool is_alpha_map);
 
 static void
-set_image_properties (pixman_image_t *image, PicturePtr pict, Bool has_clip, int *xoff, int *yoff, Bool is_alpha_map)
+set_image_properties (pixman_image_t *image, PicturePtr pict, Bool is_alpha_map)
 {
     pixman_repeat_t repeat;
     pixman_filter_t filter;
     
     if (pict->transform)
     {
-	/* For source images, adjust the transform to account
-	 * for the drawable offset within the pixman image,
-	 * then set the offset to 0 as it will be used
-	 * to compute positions within the transformed image.
-	 */
-	if (!has_clip) {
-	    struct pixman_transform	adjusted;
-
-	    adjusted = *pict->transform;
-	    pixman_transform_translate(&adjusted,
-				       NULL,
-				       pixman_int_to_fixed(*xoff),
-				       pixman_int_to_fixed(*yoff));
-	    pixman_image_set_transform (image, &adjusted);
-	    *xoff = 0;
-	    *yoff = 0;
-	} else
-	    pixman_image_set_transform (image, pict->transform);
+	pixman_image_set_transform (
+	    image, (pixman_transform_t *)pict->transform);
     }
     
     switch (pict->repeatType)
@@ -265,8 +238,7 @@ set_image_properties (pixman_image_t *image, PicturePtr pict, Bool has_clip, int
      */
     if (pict->alphaMap && !is_alpha_map)
     {
-	int alpha_xoff, alpha_yoff;
-	pixman_image_t *alpha_map = image_from_pict_internal (pict->alphaMap, FALSE, &alpha_xoff, &alpha_yoff, TRUE);
+	pixman_image_t *alpha_map = image_from_pict_internal (pict->alphaMap, TRUE, TRUE);
 	
 	pixman_image_set_alpha_map (
 	    image, alpha_map, pict->alphaOrigin.x, pict->alphaOrigin.y);
@@ -299,7 +271,8 @@ set_image_properties (pixman_image_t *image, PicturePtr pict, Bool has_clip, int
 }
 
 static pixman_image_t *
-image_from_pict_internal (PicturePtr pict, Bool has_clip, int *xoff, int *yoff, Bool is_alpha_map)
+image_from_pict_internal (PicturePtr pict,
+		 Bool has_clip, Bool is_alpha_map)
 {
     pixman_image_t *image = NULL;
 
@@ -308,7 +281,7 @@ image_from_pict_internal (PicturePtr pict, Bool has_clip, int *xoff, int *yoff,
 
     if (pict->pDrawable)
     {
-	image = create_bits_picture (pict, has_clip, xoff, yoff);
+	image = create_bits_picture (pict, has_clip);
     }
     else if (pict->pSourcePict)
     {
@@ -329,19 +302,18 @@ image_from_pict_internal (PicturePtr pict, Bool has_clip, int *xoff, int *yoff,
 	    else if (sp->type == SourcePictTypeConical)
 		image = create_conical_gradient_image (gradient);
 	}
-	*xoff = *yoff = 0;
     }
     
     if (image)
-	set_image_properties (image, pict, has_clip, xoff, yoff, is_alpha_map);
+	set_image_properties (image, pict, is_alpha_map);
     
     return image;
 }
 
 pixman_image_t *
-image_from_pict (PicturePtr pict, Bool has_clip, int *xoff, int *yoff)
+image_from_pict (PicturePtr pict, Bool has_clip)
 {
-    return image_from_pict_internal (pict, has_clip, xoff, yoff, FALSE);
+    return image_from_pict_internal (pict, has_clip, FALSE);
 }
 
 void
diff --git a/fb/fbtrap.c b/fb/fbtrap.c
index c309ceb..40cffd9 100644
--- a/fb/fbtrap.c
+++ b/fb/fbtrap.c
@@ -37,8 +37,7 @@ fbAddTraps (PicturePtr	pPicture,
 	    int		ntrap,
 	    xTrap	*traps)
 {
-    int image_xoff, image_yoff;
-    pixman_image_t *image = image_from_pict (pPicture, FALSE, &image_xoff, &image_yoff);
+    pixman_image_t *image = image_from_pict (pPicture, FALSE);
 
     if (!image)
 	return;
@@ -54,8 +53,7 @@ fbRasterizeTrapezoid (PicturePtr    pPicture,
 		      int	    x_off,
 		      int	    y_off)
 {
-    int	mask_xoff, mask_yoff;
-    pixman_image_t *image = image_from_pict (pPicture, FALSE, &mask_xoff, &mask_yoff);
+    pixman_image_t *image = image_from_pict (pPicture, FALSE);
 
     if (!image)
 	return;
commit 9495cebc4acab8b66a60bf4cf8863f59a6cfe34f
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Fri Apr 30 13:08:25 2010 -0700

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

diff --git a/mi/miexpose.c b/mi/miexpose.c
index 94258b8..4f25c23 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -521,6 +521,7 @@ void RootlessSetPixmapOfAncestors(WindowPtr pWin);
 void RootlessStartDrawing(WindowPtr pWin);
 void RootlessDamageRegion(WindowPtr pWin, RegionPtr prgn);
 Bool IsFramedWindow(WindowPtr pWin);
+#include "../fb/fb.h"
 #endif 
 
 void
@@ -548,24 +549,37 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
     Bool	solid = TRUE;
     DrawablePtr	drawable = &pWin->drawable;
 
+#ifdef XQUARTZ_CLIP_DEBUG
+    ErrorF("START %d BS %d (pR = %ld)\n", what, pWin->backgroundState, ParentRelative);
+    ErrorF("      Rgn: %d %d %d %d\n", prgn->extents.x1, prgn->extents.y1,
+	                               prgn->extents.x2 - prgn->extents.x1,
+	                               prgn->extents.y2 - prgn->extents.y1);
+    ErrorF("      Win: %d %d (%d %d) %d %d\n", pWin->origin.x, pWin->origin.y,
+	                                       pWin->winSize.extents.x1, pWin->winSize.extents.y1,
+	                                       pWin->winSize.extents.x2 - pWin->winSize.extents.x1,
+					       pWin->winSize.extents.y2 - pWin->winSize.extents.y1);
+    ErrorF("     Draw: %d %d %d %d\n", pWin->drawable.x, pWin->drawable.y,
+				       pWin->drawable.width, pWin->drawable.height);
+#endif
+
 #ifdef ROOTLESS
     if(!drawable || drawable->type == UNDRAWABLE_WINDOW)
 	return;
-
-    if(IsFramedWindow(pWin)) {
-        RootlessStartDrawing(pWin);
-        RootlessDamageRegion(pWin, prgn);
-    
-        if(pWin->backgroundState == ParentRelative) {
-            if((what == PW_BACKGROUND) || 
-               (what == PW_BORDER && !pWin->borderIsPixel))
-                RootlessSetPixmapOfAncestors(pWin);
-        }
-    }
 #endif
     
     if (what == PW_BACKGROUND)
     {
+#ifdef ROOTLESS
+	if(IsFramedWindow(pWin)) {
+	    RootlessStartDrawing(pWin);
+	    RootlessDamageRegion(pWin, prgn);
+
+	    if(pWin->backgroundState == ParentRelative) {
+		RootlessSetPixmapOfAncestors(pWin);
+	    }
+	}
+#endif
+
 	while (pWin->backgroundState == ParentRelative)
 	    pWin = pWin->parent;
 
@@ -587,6 +601,18 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
     {
 	PixmapPtr   pixmap;
 
+#ifdef ROOTLESS
+	if(IsFramedWindow(pWin)) {
+	    RootlessStartDrawing(pWin);
+	    RootlessDamageRegion(pWin, prgn);
+	    
+	    if(!pWin->borderIsPixel &&
+		pWin->backgroundState == ParentRelative) {
+		RootlessSetPixmapOfAncestors(pWin);
+	    }
+	}
+#endif
+
 	tile_x_off = drawable->x;
 	tile_y_off = drawable->y;
 	
@@ -595,6 +621,12 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
 	    return;
 	pixmap = (*pScreen->GetWindowPixmap) ((WindowPtr) drawable);
 	drawable = &pixmap->drawable;
+
+#ifdef XQUARTZ_CLIP_DEBUG
+	ErrorF("     Draw: %d %d %d %d\n",
+	       drawable->x, drawable->y, drawable->width, drawable->height);    
+#endif
+	
 #ifdef COMPOSITE
 	draw_x_off = pixmap->screen_x;
 	draw_y_off = pixmap->screen_y;
@@ -657,6 +689,57 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
     ChangeGC (NullClient, pGC, gcmask, gcval);
     ValidateGC (drawable, pGC);
 
+#ifdef XQUARTZ_CLIP_DEBUG
+    ErrorF("       GC: %d %d %d %d\n",
+	   pGC->pCompositeClip->extents.x1, pGC->pCompositeClip->extents.y1,
+	   pGC->pCompositeClip->extents.x2 - pGC->pCompositeClip->extents.x1,
+	   pGC->pCompositeClip->extents.y2 - pGC->pCompositeClip->extents.y1);
+#endif
+    
+#ifdef XQUARTZ
+    /* Looks like our clipping isn't set right for some reason:
+     * http://xquartz.macosforge.org/trac/ticket/290
+     */
+    if(what == PW_BORDER) {
+
+#if 0
+	if(solid) {
+#if 1
+	    fbFillRegionSolid(&pWin->drawable,
+			      prgn,
+			      0,
+			      fbReplicatePixel(fill.pixel,
+					       pWin->drawable.bitsPerPixel));
+#else
+	    fbFillRegionSolid(drawable,
+			      prgn,
+			      0,
+			      fbReplicatePixel(fill.pixel,
+					       drawable->bitsPerPixel));
+#endif
+	    return;
+	}
+#endif
+    
+	pGC->pCompositeClip->extents.x1 += prgn->extents.x1;
+	pGC->pCompositeClip->extents.y1 += prgn->extents.y1;
+	pGC->pCompositeClip->extents.x2 += prgn->extents.x1;
+	pGC->pCompositeClip->extents.y2 += prgn->extents.y1;
+	
+	if(pGC->pCompositeClip->extents.x2 > drawable->pScreen->width)
+	    pGC->pCompositeClip->extents.x2 = drawable->pScreen->width;
+	if(pGC->pCompositeClip->extents.y2 > drawable->pScreen->height)
+	    pGC->pCompositeClip->extents.y2 = drawable->pScreen->height;
+    }
+#endif
+
+#ifdef XQUARTZ_CLIP_DEBUG
+    ErrorF("       GC: %d %d %d %d\n",
+	   pGC->pCompositeClip->extents.x1, pGC->pCompositeClip->extents.y1,
+	   pGC->pCompositeClip->extents.x2 - pGC->pCompositeClip->extents.x1,
+	   pGC->pCompositeClip->extents.y2 - pGC->pCompositeClip->extents.y1);    
+#endif
+
     numRects = RegionNumRects(prgn);
     pbox = RegionRects(prgn);
     for (i= numRects; --i >= 0; pbox++, prect++)
commit 35503964af4e6d3359e93f8d7c084dedee513385
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Tue Mar 1 20:02:46 2011 -0800

    XQuartz: pbproxy: Protect against possible collision between Cocoa and X11 Cursor types
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    (cherry picked from commit 69a9171dbbafd6a7db702d48770d28fb54717545)

diff --git a/hw/xquartz/pbproxy/x-selection.h b/hw/xquartz/pbproxy/x-selection.h
index 614c8b0..d4a39e5 100644
--- a/hw/xquartz/pbproxy/x-selection.h
+++ b/hw/xquartz/pbproxy/x-selection.h
@@ -33,7 +33,9 @@
 
 #include "pbproxy.h"
 
+#define  Cursor X_Cursor
 #include <X11/extensions/Xfixes.h>
+#undef Cursor
 
 #include <AppKit/NSPasteboard.h>
 
commit 14cb04f989132f2c2fc44cfdaceb17a5dfe63d1d
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sun Feb 27 16:18:27 2011 -0800

    XQuartz: Don't use deprecated CoreGraphics API on SL and Lion
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    (cherry picked from commit 0343aed1f082baf4bfbd730c1c3582f1410b8741)

diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c
index 6e6d06e..972278b 100644
--- a/hw/xquartz/xpr/xprScreen.c
+++ b/hw/xquartz/xpr/xprScreen.c
@@ -299,9 +299,34 @@ xprAddScreen(int index, ScreenPtr pScreen)
     DEBUG_LOG("index=%d depth=%d\n", index, depth);
     
     if(depth == -1) {
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
         depth = CGDisplaySamplesPerPixel(kCGDirectMainDisplay) * CGDisplayBitsPerSample(kCGDirectMainDisplay);
+#else
+        CGDisplayModeRef modeRef;
+        CFStringRef encStrRef;
+        
+        modeRef = CGDisplayCopyDisplayMode(kCGDirectMainDisplay);
+        if(!modeRef)
+            goto have_depth;
+
+        encStrRef = CGDisplayModeCopyPixelEncoding(modeRef);
+        CFRelease(modeRef);
+        if(!encStrRef)
+            goto have_depth;
+        
+        if(CFStringCompare(encStrRef, CFSTR(IO32BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
+            depth = 24;
+        } else if(CFStringCompare(encStrRef, CFSTR(IO16BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
+            depth = 15;
+        } else if(CFStringCompare(encStrRef, CFSTR(IO8BitIndexedPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
+            depth = 8;
+        }
+
+        CFRelease(encStrRef);
+#endif
     }
     
+have_depth:
     switch(depth) {
         case 8: // pseudo-working
             dfb->visuals = PseudoColorMask;
@@ -326,7 +351,7 @@ xprAddScreen(int index, ScreenPtr pScreen)
 //        case 24:
         default:
             if(depth != 24)
-                ErrorF("Unsupported color depth requested.  Defaulting to 24bit. (depth=%d darwinDesiredDepth=%d CGDisplaySamplesPerPixel=%d CGDisplayBitsPerSample=%d)\n",  darwinDesiredDepth, depth, (int)CGDisplaySamplesPerPixel(kCGDirectMainDisplay), (int)CGDisplayBitsPerSample(kCGDirectMainDisplay));
+                ErrorF("Unsupported color depth requested.  Defaulting to 24bit. (depth=%d darwinDesiredDepth=%d)\n", depth, darwinDesiredDepth);
             dfb->visuals = TrueColorMask; //LARGE_VISUALS;
             dfb->preferredCVC = TrueColor;
             dfb->depth = 24;
commit edcf115800fef79d956c8e3d3e3c46a30cf77538
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sun Feb 27 15:49:10 2011 -0800

    Revert "rootless: Remove ROOTLESS_WORKAROUND"
    
    Christof Wolf has reported a regression that seems to be caused by
    this change, so reverting the change in the 1.9 branch.  We'll
    investigate a proper fix in master for 1.10.
    
    This reverts commit c89f0521044083a11d538ebfeaabee6fc7fb9a03.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    (cherry picked from commit de32d4dcf57c10fc100c1b33630127947a8c8460)

diff --git a/configure.ac b/configure.ac
index 85d5c98..0a06391 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1923,7 +1923,7 @@ if test "x$XQUARTZ" = xyes; then
 
 	AC_CHECK_LIB([Xplugin],[xp_init],[:])
 
-	CFLAGS="${CFLAGS} -DROOTLESS_SAFEALPHA -DNO_ALLOCA"
+	CFLAGS="${CFLAGS} -DROOTLESS_WORKAROUND -DROOTLESS_SAFEALPHA -DNO_ALLOCA"
 
 	PKG_CHECK_MODULES(XPBPROXY, $APPLEWMPROTO $LIBAPPLEWM xfixes x11)
 
diff --git a/miext/damage/damage.c b/miext/damage/damage.c
index 566995c..0fe1fb6 100644
--- a/miext/damage/damage.c
+++ b/miext/damage/damage.c
@@ -89,7 +89,11 @@ getDrawableDamageRef (DrawablePtr pDrawable)
 	ScreenPtr   pScreen = pDrawable->pScreen;
 
 	pPixmap = 0;
-	if (pScreen->GetWindowPixmap)
+	if (pScreen->GetWindowPixmap
+#ifdef ROOTLESS_WORKAROUND
+	    && ((WindowPtr)pDrawable)->viewable
+#endif
+	    )
 	    pPixmap = (*pScreen->GetWindowPixmap) ((WindowPtr)pDrawable);
 
 	if (!pPixmap)
commit 436deac7bc6517f1943af3efa7420e94596958ab
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Tue Feb 8 11:38:35 2011 -0800

    XQuartz: RandR: Add RandR modes for the primary display in multi-monitor configs
    
    We now support using RandR to set the resolution of the primary display (and
    place a shielding window on other displays) in multi-monitor configurations.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    (cherry picked from commit 8cf3348e90846f5b04236479042228fb98ac8f70)

diff --git a/hw/xquartz/quartzRandR.c b/hw/xquartz/quartzRandR.c
index ede7969..05641a6 100644
--- a/hw/xquartz/quartzRandR.c
+++ b/hw/xquartz/quartzRandR.c
@@ -413,16 +413,6 @@ static Bool QuartzRandRGetInfo (ScreenPtr pScreen, Rotation *rotations) {
     if (pQuartzScreen->displayCount == 0)
         return FALSE;
 
-    if (pQuartzScreen->displayCount > 1) {
-        /* RandR operations are not well-defined for an X11 screen spanning
-           multiple CG displays. Create two entries for the current virtual
-           resolution including/excluding the menu bar. */
-
-        QuartzRandRRegisterMode(pScreen, &pQuartzScreen->rootlessMode);
-        QuartzRandRRegisterMode(pScreen, &pQuartzScreen->fullscreenMode);
-        return TRUE;
-    }
-
     return QuartzRandREnumerateModes(pScreen, QuartzRandRRegisterModeCallback, NULL);
 }
 
diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c
index cba358f..6e6d06e 100644
--- a/hw/xquartz/xpr/xprScreen.c
+++ b/hw/xquartz/xpr/xprScreen.c
@@ -196,6 +196,13 @@ xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height, ScreenPtr pScr
         return;
     }
 
+    /* If the displays are captured, we are in a RandR game mode
+     * on the primary display, so we only want to include the first
+     * display.  The others are covered by the shield window.
+     */
+    if (CGDisplayIsCaptured(kCGDirectMainDisplay))
+        displayCount = 1;
+
     displayList = malloc(displayCount * sizeof(CGDirectDisplayID));
     if(!displayList)
         FatalError("Unable to allocate memory for list of displays.\n");
commit c78d39316183d35549bc57a834042a90e24491fb
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Tue Feb 8 12:26:35 2011 -0800

    XQuartz: RandR: Provide an alert box when entering a RandR mode for the first time.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    (cherry picked from commit 968652983f8e6ae6889b48e15f4098ff6ad4a15a)

diff --git a/hw/xquartz/X11Application.h b/hw/xquartz/X11Application.h
index b3ad19b..256ff18 100644
--- a/hw/xquartz/X11Application.h
+++ b/hw/xquartz/X11Application.h
@@ -73,6 +73,8 @@ void X11ApplicationServerReady (void);
 void X11ApplicationShowHideMenubar (int state);
 void X11ApplicationLaunchClient (const char *cmd);
 
+Bool X11ApplicationCanEnterRandR (void);
+
 void X11ApplicationMain(int argc, char **argv, char **envp);
 
 #define PREFS_APPSMENU              "apps_menu"
@@ -86,6 +88,7 @@ void X11ApplicationMain(int argc, char **argv, char **envp);
 #define PREFS_NO_TCP                "nolisten_tcp"
 #define PREFS_DONE_XINIT_CHECK      "done_xinit_check"
 #define PREFS_NO_QUIT_ALERT         "no_quit_alert"
+#define PREFS_NO_RANDR_ALERT        "no_randr_alert"
 #define PREFS_OPTION_SENDS_ALT      "option_sends_alt"
 #define PREFS_FAKE_BUTTON2          "fake_button2"
 #define PREFS_FAKE_BUTTON3          "fake_button3"
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index b855c83..3521517 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -883,6 +883,35 @@ void X11ApplicationLaunchClient (const char *cmd) {
     [string release];
 }
 
+/* This is a special function in that it is run from the *SERVER* thread and
+ * not the AppKit thread.  We want to block entering a screen-capturing RandR
+ * mode until we notify the user about how to get out if the X11 client crashes.
+ */
+Bool X11ApplicationCanEnterRandR(void) {
+    NSString *title, *msg;
+    
+    if([X11App prefs_get_boolean:@PREFS_NO_RANDR_ALERT default:NO] || XQuartzShieldingWindowLevel != 0)
+        return TRUE;
+    
+    title = NSLocalizedString(@"Enter RandR mode?", @"Dialog title when switching to RandR");
+    msg = NSLocalizedString(@"An application has requested X11 to change the resolution of your display.  X11 will restore the display to its previous state when the requesting application requests to return to the previous state.  Alternatively, you can use the ⌥⌘A key sequence to force X11 to return to the previous state.",
+                            @"Dialog when switching to RandR");
+
+    if(!XQuartzIsRootless)
+        QuartzShowFullscreen(FALSE);
+    
+    switch(NSRunAlertPanel(title, msg, NSLocalizedString(@"Allow", @""), NSLocalizedString (@"Cancel", @""), NSLocalizedString (@"Always Allow", @""))) {
+        case NSAlertOtherReturn:
+            [X11App prefs_set_boolean:@PREFS_NO_RANDR_ALERT value:YES];
+            [X11App prefs_synchronize];
+        case NSAlertDefaultReturn:
+            return YES;
+
+        default:
+            return NO;
+    }
+}
+
 static void check_xinitrc (void) {
     char *tem, buf[1024];
     NSString *msg;
diff --git a/hw/xquartz/bundle/Resources/English.lproj/Localizable.strings b/hw/xquartz/bundle/Resources/English.lproj/Localizable.strings
index 0341502..bf2089c 100644
Binary files a/hw/xquartz/bundle/Resources/English.lproj/Localizable.strings and b/hw/xquartz/bundle/Resources/English.lproj/Localizable.strings differ
diff --git a/hw/xquartz/quartzRandR.c b/hw/xquartz/quartzRandR.c
index 57e9755..ede7969 100644
--- a/hw/xquartz/quartzRandR.c
+++ b/hw/xquartz/quartzRandR.c
@@ -40,6 +40,8 @@
 #include "quartz.h"
 #include "darwin.h"
 
+#include "X11Application.h"
+
 #include <AvailabilityMacros.h>
 
 #include <X11/extensions/randr.h>
@@ -349,6 +351,8 @@ static Bool QuartzRandRSetMode(ScreenPtr pScreen, QuartzModeInfoPtr pMode, BOOL
     Bool captureDisplay = (pMode->refresh != FAKE_REFRESH_FULLSCREEN && pMode->refresh != FAKE_REFRESH_ROOTLESS);
 
     if(XQuartzShieldingWindowLevel == 0 && captureDisplay) {
+        if(!X11ApplicationCanEnterRandR())
+            return FALSE;
         CGCaptureAllDisplays();
         XQuartzShieldingWindowLevel = CGShieldingWindowLevel(); // 2147483630
         DEBUG_LOG("Display captured.  ShieldWindowID: %u, Shield level: %d\n",
commit b16bba0865862f86c70d98a85b4d2b625239eff8
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Tue Feb 8 11:37:52 2011 -0800

    XQuartz: RandR: Capture the display when switching modes with RandR
    
    This will prevent native windows from resizing as we change resolutions.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    (cherry picked from commit 13578b852b7631f99cf1fd5e2e5469edc5aae369)

diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index 222a5ea..11e5a74 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -82,6 +82,8 @@ Bool XQuartzIsRootless = TRUE;
 Bool XQuartzServerVisible = FALSE;
 Bool XQuartzFullscreenMenu = FALSE;
 
+int32_t XQuartzShieldingWindowLevel = 0;
+
 /*
 ===========================================================================
 
diff --git a/hw/xquartz/quartz.h b/hw/xquartz/quartz.h
index b83391d..67a7919 100644
--- a/hw/xquartz/quartz.h
+++ b/hw/xquartz/quartz.h
@@ -124,6 +124,8 @@ extern Bool XQuartzFullscreenMenu;   /* Show the menu bar (autohide) while in FS
 extern Bool XQuartzFullscreenDisableHotkeys;
 extern Bool XQuartzOptionSendsAlt;   /* Alt or Mode_switch? */
 
+extern int32_t XQuartzShieldingWindowLevel; /* CGShieldingWindowLevel() or 0 */
+
 Bool QuartzAddScreen(int index, ScreenPtr pScreen);
 Bool QuartzSetupScreen(int index, ScreenPtr pScreen);
 void QuartzInitOutput(int argc,char **argv);
diff --git a/hw/xquartz/quartzRandR.c b/hw/xquartz/quartzRandR.c
index 296f9b6..57e9755 100644
--- a/hw/xquartz/quartzRandR.c
+++ b/hw/xquartz/quartzRandR.c
@@ -346,6 +346,14 @@ static int QuartzRandRRegisterModeCallback (ScreenPtr pScreen,
 static Bool QuartzRandRSetMode(ScreenPtr pScreen, QuartzModeInfoPtr pMode, BOOL doRegister) {
     QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
     CGDirectDisplayID screenId = pQuartzScreen->displayIDs[0];
+    Bool captureDisplay = (pMode->refresh != FAKE_REFRESH_FULLSCREEN && pMode->refresh != FAKE_REFRESH_ROOTLESS);
+
+    if(XQuartzShieldingWindowLevel == 0 && captureDisplay) {
+        CGCaptureAllDisplays();
+        XQuartzShieldingWindowLevel = CGShieldingWindowLevel(); // 2147483630
+        DEBUG_LOG("Display captured.  ShieldWindowID: %u, Shield level: %d\n",
+                  CGShieldingWindowID(screenId), XQuartzShieldingWindowLevel);
+    }
 
     if (pQuartzScreen->currentMode.ref && CFEqual(pMode->ref, pQuartzScreen->currentMode.ref)) {
         DEBUG_LOG("Requested RandR resolution matches current CG mode\n");
@@ -369,6 +377,11 @@ static Bool QuartzRandRSetMode(ScreenPtr pScreen, QuartzModeInfoPtr pMode, BOOL
     pQuartzScreen->currentMode = *pMode;
     CFRetain(pQuartzScreen->currentMode.ref);
     
+    if(XQuartzShieldingWindowLevel != 0 && !captureDisplay) {
+        CGReleaseAllDisplays();
+        XQuartzShieldingWindowLevel = 0;
+    }
+
     return TRUE;
 }
 
diff --git a/hw/xquartz/xpr/xprAppleWM.c b/hw/xquartz/xpr/xprAppleWM.c
index 1a3d427..21e6f98 100644
--- a/hw/xquartz/xpr/xprAppleWM.c
+++ b/hw/xquartz/xpr/xprAppleWM.c
@@ -69,6 +69,8 @@ static int xprSetWindowLevel(
     
     if(XQuartzIsRootless)
         wc.window_level = normal_window_levels[level];
+    else if(XQuartzShieldingWindowLevel)
+        wc.window_level = XQuartzShieldingWindowLevel + 1;
     else
         wc.window_level = rooted_window_levels[level];
     
diff --git a/hw/xquartz/xpr/xprFrame.c b/hw/xquartz/xpr/xprFrame.c
index 8ee3a28..15598e9 100644
--- a/hw/xquartz/xpr/xprFrame.c
+++ b/hw/xquartz/xpr/xprFrame.c
@@ -173,6 +173,8 @@ xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
 
     if(XQuartzIsRootless)
         wc.window_level = normal_window_levels[pFrame->level];
+    else if(XQuartzShieldingWindowLevel)
+        wc.window_level = XQuartzShieldingWindowLevel + 1;
     else
         wc.window_level = rooted_window_levels[pFrame->level];
     mask |= XP_WINDOW_LEVEL;
@@ -287,6 +289,8 @@ static void xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid) {
         if(winRec) {
             if(XQuartzIsRootless)
                 wc.window_level = normal_window_levels[winRec->level];
+            else if(XQuartzShieldingWindowLevel)
+                wc.window_level = XQuartzShieldingWindowLevel + 1;
             else
                 wc.window_level = rooted_window_levels[winRec->level];
             mask |= XP_WINDOW_LEVEL;


More information about the Xquartz-changes mailing list