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

Jeremy Huddleston jeremyhu at freedesktop.org
Sat May 28 12:17:12 PDT 2011


Rebased ref, commits from common ancestor:
commit 7a31564ff5a536614f72aac4883ef8c660491e2d
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 c540464ac868677943f0227f4854836a747bdc70
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 adb1aab9beb164cde3c515a60a9ef65bf935ce7b
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 3a2120c..a87a516 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 398114c1489fbfc9fe487de38ff4a4176755eee6
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sun May 22 10:18:36 2011 -0700

    XQuartz: Don't crash if CG increases our display resolution
    
    miPaintWindow would cause fbFill() to overwrite pScreen's pixmap which was
    sized for the old resolution.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    (cherry picked from commit 1fb501ad1521cfedaa5cf3052d45a924ef1866cf)

diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index 7de7138..226cb2f 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -239,8 +239,6 @@ void QuartzUpdateScreens(void) {
     AppleWMSetScreenOrigin(pRoot);
     pScreen->ResizeWindow(pRoot, x - sx, y - sy, width, height, NULL);
 
-    miPaintWindow(pRoot, &pRoot->borderClip,  PW_BACKGROUND);
-
     /* <rdar://problem/7770779> pointer events are clipped to old display region after display reconfiguration
      * http://xquartz.macosforge.org/trac/ticket/346
      */
@@ -268,6 +266,9 @@ void QuartzUpdateScreens(void) {
 
     quartzProcs->UpdateScreen(pScreen);
 
+    /* miPaintWindow needs to be called after RootlessUpdateScreenPixmap (from xprUpdateScreen) */
+    miPaintWindow(pRoot, &pRoot->borderClip,  PW_BACKGROUND);
+
     /* Tell RandR about the new size, so new connections get the correct info */
     RRScreenSizeNotify(pScreen);
 }
commit dc6efd99887c90bb14e066e46b69ca5ba19b6a09
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sun May 22 09:32:57 2011 -0700

    XQuartz: RandR: Don't crash if X11 is launched while there are no attached displays
    
    If CG reports no displays when launching, we could crash in RandR.  Instead, just
    provide a fake 800x600 display until we are notified about displays being attached.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    (cherry picked from commit 60af79e35ee8546a99d15a1358aac3deabfa22be)

diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index 11e5a74..7de7138 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -464,11 +464,15 @@ void QuartzSpaceChanged(uint32_t space_id) {
 void QuartzCopyDisplayIDs(ScreenPtr pScreen,
                           int displayCount, CGDirectDisplayID *displayIDs) {
     QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
-    int size = displayCount * sizeof(CGDirectDisplayID);
 
     free(pQuartzScreen->displayIDs);
-    pQuartzScreen->displayIDs = malloc(size);
-    memcpy(pQuartzScreen->displayIDs, displayIDs, size);
+    if(displayCount) {
+        size_t size = displayCount * sizeof(CGDirectDisplayID);
+        pQuartzScreen->displayIDs = malloc(size);
+        memcpy(pQuartzScreen->displayIDs, displayIDs, size);
+    } else {
+       pQuartzScreen->displayIDs = NULL;
+    }
     pQuartzScreen->displayCount = displayCount;
 }
 
diff --git a/hw/xquartz/quartzRandR.c b/hw/xquartz/quartzRandR.c
index d452b02..98b382d 100644
--- a/hw/xquartz/quartzRandR.c
+++ b/hw/xquartz/quartzRandR.c
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2001-2004 Greg Parker and Torrey T. Lyons,
  *               2010      Jan Hauffa.
- *               2010      Apple Inc.
+ *               2010-2011 Apple Inc.
  *                 All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -124,44 +124,48 @@ static Bool QuartzRandRSetCGMode (CGDirectDisplayID screenId,
 static Bool QuartzRandREnumerateModes (ScreenPtr pScreen,
                                        QuartzModeCallback callback,
                                        void *data) {
-    CFDictionaryRef curModeRef, modeRef;
-    long curBpp;
-    CFArrayRef modes;
-    QuartzModeInfo modeInfo;
-    int i;
-    BOOL retval = FALSE;
+    Bool retval = FALSE;
     QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
-    CGDirectDisplayID screenId = pQuartzScreen->displayIDs[0];
 
-    curModeRef = CGDisplayCurrentMode(screenId);
-    if (!curModeRef)
-        return FALSE;
-    curBpp = getDictLong(curModeRef, kCGDisplayBitsPerPixel);
+    /* Just an 800x600 fallback if we have no attached heads */
+    if(pQuartzScreen->displayIDs) {
+        CFDictionaryRef curModeRef, modeRef;
+        long curBpp;
+        CFArrayRef modes;
+        QuartzModeInfo modeInfo;
+        int i;
+        CGDirectDisplayID screenId = pQuartzScreen->displayIDs[0];
+
+        curModeRef = CGDisplayCurrentMode(screenId);
+        if (!curModeRef)
+            return FALSE;
+        curBpp = getDictLong(curModeRef, kCGDisplayBitsPerPixel);
 
-    modes = CGDisplayAvailableModes(screenId);
-    if (!modes)
-        return FALSE;
-    for (i = 0; i < CFArrayGetCount(modes); i++) {
-        int cb;
-        modeRef = (CFDictionaryRef) CFArrayGetValueAtIndex(modes, i);
-
-        /* Skip modes that are not usable on the current display or have a
-           different pixel encoding than the current mode. */
-        if (((unsigned long) getDictLong(modeRef, kCGDisplayIOFlags) &
-             kDisplayModeUsableFlags) != kDisplayModeUsableFlags)
-            continue;
-        if (getDictLong(modeRef, kCGDisplayBitsPerPixel) != curBpp)
-            continue;
-
-        QuartzRandRGetModeInfo(modeRef, &modeInfo);
-        modeInfo.ref = (void *)modeRef;
-        cb = callback(pScreen, &modeInfo, data);
-        if (cb == CALLBACK_CONTINUE)
-            retval = TRUE;
-        else if (cb == CALLBACK_SUCCESS)
-            return TRUE;
-        else if (cb == CALLBACK_ERROR)
+        modes = CGDisplayAvailableModes(screenId);
+        if (!modes)
             return FALSE;
+        for (i = 0; i < CFArrayGetCount(modes); i++) {
+            int cb;
+            modeRef = (CFDictionaryRef) CFArrayGetValueAtIndex(modes, i);
+
+            /* Skip modes that are not usable on the current display or have a
+               different pixel encoding than the current mode. */
+            if (((unsigned long) getDictLong(modeRef, kCGDisplayIOFlags) &
+                 kDisplayModeUsableFlags) != kDisplayModeUsableFlags)
+                continue;
+            if (getDictLong(modeRef, kCGDisplayBitsPerPixel) != curBpp)
+                continue;
+
+            QuartzRandRGetModeInfo(modeRef, &modeInfo);
+            modeInfo.ref = (void *)modeRef;
+            cb = callback(pScreen, &modeInfo, data);
+            if (cb == CALLBACK_CONTINUE)
+                retval = TRUE;
+            else if (cb == CALLBACK_SUCCESS)
+                return TRUE;
+            else if (cb == CALLBACK_ERROR)
+                return FALSE;
+        }
     }
 
     switch(callback(pScreen, &pQuartzScreen->rootlessMode, data)) {
@@ -225,61 +229,64 @@ static Bool QuartzRandRSetCGMode (CGDirectDisplayID screenId,
 static Bool QuartzRandREnumerateModes (ScreenPtr pScreen,
                                        QuartzModeCallback callback,
                                        void *data) {
-    CGDisplayModeRef curModeRef, modeRef;
-    CFStringRef curPixelEnc, pixelEnc;
-    CFComparisonResult pixelEncEqual;
-    CFArrayRef modes;
-    QuartzModeInfo modeInfo;
-    int i;
     Bool retval = FALSE;
-
     QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
-    CGDirectDisplayID screenId = pQuartzScreen->displayIDs[0];
 
-    curModeRef = CGDisplayCopyDisplayMode(screenId);
-    if (!curModeRef)
-        return FALSE;
-    curPixelEnc = CGDisplayModeCopyPixelEncoding(curModeRef);
-    CGDisplayModeRelease(curModeRef);
+    /* Just an 800x600 fallback if we have no attached heads */
+    if(pQuartzScreen->displayIDs) {
+        CGDisplayModeRef curModeRef, modeRef;
+        CFStringRef curPixelEnc, pixelEnc;
+        CFComparisonResult pixelEncEqual;
+        CFArrayRef modes;
+        QuartzModeInfo modeInfo;
+        int i;
+        CGDirectDisplayID screenId = pQuartzScreen->displayIDs[0];
+
+        curModeRef = CGDisplayCopyDisplayMode(screenId);
+        if (!curModeRef)
+            return FALSE;
+        curPixelEnc = CGDisplayModeCopyPixelEncoding(curModeRef);
+        CGDisplayModeRelease(curModeRef);
 
-    modes = CGDisplayCopyAllDisplayModes(screenId, NULL);
-    if (!modes) {
-        CFRelease(curPixelEnc);
-        return FALSE;
-    }
-    for (i = 0; i < CFArrayGetCount(modes); i++) {
-        int cb;
-        modeRef = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
-
-        /* Skip modes that are not usable on the current display or have a
-           different pixel encoding than the current mode. */
-        if ((CGDisplayModeGetIOFlags(modeRef) & kDisplayModeUsableFlags) !=
-            kDisplayModeUsableFlags)
-            continue;
-        pixelEnc = CGDisplayModeCopyPixelEncoding(modeRef);
-        pixelEncEqual = CFStringCompare(pixelEnc, curPixelEnc, 0);
-        CFRelease(pixelEnc);
-        if (pixelEncEqual != kCFCompareEqualTo)
-            continue;
-
-        QuartzRandRGetModeInfo(modeRef, &modeInfo);
-        modeInfo.ref = modeRef;
-        cb = callback(pScreen, &modeInfo, data);
-        if (cb == CALLBACK_CONTINUE) {
-            retval = TRUE;
-        } else if (cb == CALLBACK_SUCCESS) {
-            CFRelease(modes);
-            CFRelease(curPixelEnc);
-            return TRUE;
-        } else if (cb == CALLBACK_ERROR) {
-            CFRelease(modes);
+        modes = CGDisplayCopyAllDisplayModes(screenId, NULL);
+        if (!modes) {
             CFRelease(curPixelEnc);
             return FALSE;
         }
-    }
+        for (i = 0; i < CFArrayGetCount(modes); i++) {
+            int cb;
+            modeRef = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
+
+            /* Skip modes that are not usable on the current display or have a
+               different pixel encoding than the current mode. */
+            if ((CGDisplayModeGetIOFlags(modeRef) & kDisplayModeUsableFlags) !=
+                kDisplayModeUsableFlags)
+                continue;
+            pixelEnc = CGDisplayModeCopyPixelEncoding(modeRef);
+            pixelEncEqual = CFStringCompare(pixelEnc, curPixelEnc, 0);
+            CFRelease(pixelEnc);
+            if (pixelEncEqual != kCFCompareEqualTo)
+                continue;
+
+            QuartzRandRGetModeInfo(modeRef, &modeInfo);
+            modeInfo.ref = modeRef;
+            cb = callback(pScreen, &modeInfo, data);
+            if (cb == CALLBACK_CONTINUE) {
+                retval = TRUE;
+            } else if (cb == CALLBACK_SUCCESS) {
+                CFRelease(modes);
+                CFRelease(curPixelEnc);
+                return TRUE;
+            } else if (cb == CALLBACK_ERROR) {
+                CFRelease(modes);
+                CFRelease(curPixelEnc);
+                return FALSE;
+            }
+        }
 
-    CFRelease(modes);
-    CFRelease(curPixelEnc);
+        CFRelease(modes);
+        CFRelease(curPixelEnc);
+    }
 
     switch(callback(pScreen, &pQuartzScreen->rootlessMode, data)) {
         case CALLBACK_SUCCESS:
@@ -347,9 +354,13 @@ 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);
+    CGDirectDisplayID screenId;
 
+    if(pQuartzScreen->displayIDs == NULL)
+        return FALSE;
+
+    screenId = pQuartzScreen->displayIDs[0];
     if(XQuartzShieldingWindowLevel == 0 && captureDisplay) {
         if(!X11ApplicationCanEnterRandR())
             return FALSE;
@@ -379,7 +390,8 @@ static Bool QuartzRandRSetMode(ScreenPtr pScreen, QuartzModeInfoPtr pMode, BOOL
     if(pQuartzScreen->currentMode.ref)
         CFRelease(pQuartzScreen->currentMode.ref);
     pQuartzScreen->currentMode = *pMode;
-    CFRetain(pQuartzScreen->currentMode.ref);
+    if(pQuartzScreen->currentMode.ref)
+        CFRetain(pQuartzScreen->currentMode.ref);
     
     if(XQuartzShieldingWindowLevel != 0 && !captureDisplay) {
         CGReleaseAllDisplays();
@@ -406,13 +418,8 @@ static int QuartzRandRSetModeCallback (ScreenPtr pScreen,
 }
 
 static Bool QuartzRandRGetInfo (ScreenPtr pScreen, Rotation *rotations) {
-    QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
-
     *rotations = RR_Rotate_0;  /* TODO: support rotation */
 
-    if (pQuartzScreen->displayCount == 0)
-        return FALSE;
-
     return QuartzRandREnumerateModes(pScreen, QuartzRandRRegisterModeCallback, NULL);
 }
 
@@ -427,9 +434,6 @@ static Bool QuartzRandRSetConfig (ScreenPtr           pScreen,
     reqMode.height = pSize->height;
     reqMode.refresh = rate;
 
-    if (pQuartzScreen->displayCount == 0)
-        return FALSE;
-
     /* Do not switch modes if requested mode is equal to current mode. */
     if (QuartzRandRModesEqual(&reqMode, &pQuartzScreen->currentMode))
         return TRUE;
@@ -446,9 +450,16 @@ static Bool _QuartzRandRUpdateFakeModes (ScreenPtr pScreen) {
     QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
     QuartzModeInfo activeMode;
 
-    if (!QuartzRandRCopyCurrentModeInfo(pQuartzScreen->displayIDs[0], &activeMode)) {
-        ErrorF("Unable to determine current display mode.\n");
-        return FALSE;
+    if(pQuartzScreen->displayCount > 0) {
+        if(!QuartzRandRCopyCurrentModeInfo(pQuartzScreen->displayIDs[0], &activeMode)) {
+            ErrorF("Unable to determine current display mode.\n");
+            return FALSE;
+        }
+    } else {
+        memset(&activeMode, 0, sizeof(activeMode));
+        activeMode.width = 800;
+        activeMode.height = 600;
+        activeMode.refresh = 60;
     }
 
     if(pQuartzScreen->fullscreenMode.ref)
@@ -456,7 +467,7 @@ static Bool _QuartzRandRUpdateFakeModes (ScreenPtr pScreen) {
     if(pQuartzScreen->currentMode.ref)
         CFRelease(pQuartzScreen->currentMode.ref);
 
-    if (pQuartzScreen->displayCount > 1) {
+    if(pQuartzScreen->displayCount > 1) {
         activeMode.width = pScreen->width;
         activeMode.height = pScreen->height;
         if(XQuartzIsRootless)
@@ -479,7 +490,8 @@ static Bool _QuartzRandRUpdateFakeModes (ScreenPtr pScreen) {
     /* This extra retain is for currentMode's copy.
      * fullscreen and rootless share a retain.
      */
-    CFRetain(pQuartzScreen->currentMode.ref);
+    if(pQuartzScreen->currentMode.ref)
+        CFRetain(pQuartzScreen->currentMode.ref);
     
     DEBUG_LOG("rootlessMode: %d x %d\n", (int)pQuartzScreen->rootlessMode.width, (int)pQuartzScreen->rootlessMode.height);
     DEBUG_LOG("fullscreenMode: %d x %d\n", (int)pQuartzScreen->fullscreenMode.width, (int)pQuartzScreen->fullscreenMode.height);
diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c
index 972278b..3684ad5 100644
--- a/hw/xquartz/xpr/xprScreen.c
+++ b/hw/xquartz/xpr/xprScreen.c
@@ -193,6 +193,7 @@ xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height, ScreenPtr pScr
         *width = 800;
         *height = 600;
         PseudoramiXAddScreen(*x, *y, *width, *height);
+        QuartzCopyDisplayIDs(pScreen, 0, NULL);
         return;
     }
 
commit 1a665a8abd0ce1dbc50a1d889f11d5b74c78539e
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Fri May 20 22:59:27 2011 -0700

    configure.ac: Bump version to 1.10.1.902 (1.10.2 RC2)
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/configure.ac b/configure.ac
index 5f85383..3a2120c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,8 +26,8 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ(2.57)
-AC_INIT([xorg-server], 1.10.1.901, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
-RELEASE_DATE="2011-05-06"
+AC_INIT([xorg-server], 1.10.1.902, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+RELEASE_DATE="2011-05-20"
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
 AM_MAINTAINER_MODE
commit 52e27b446a69b4b196d7e59d4e92aaa073c83dae
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Mon May 16 21:07:13 2011 -0700

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

diff --git a/hw/xquartz/bundle/Info.plist.cpp b/hw/xquartz/bundle/Info.plist.cpp
index 4ecf8e4..8873118 100644
--- a/hw/xquartz/bundle/Info.plist.cpp
+++ b/hw/xquartz/bundle/Info.plist.cpp
@@ -19,9 +19,9 @@
 	<key>CFBundlePackageType</key>
 		<string>APPL</string>
 	<key>CFBundleShortVersionString</key>
-		<string>2.6.2</string>
+		<string>2.6.3</string>
 	<key>CFBundleVersion</key>
-		<string>2.6.2</string>
+		<string>2.6.3</string>
 	<key>CFBundleSignature</key>
 		<string>x11a</string>
 	<key>CSResourcesFileMapped</key>
commit b4cb37d7255746f2ddf0ceb3334fc698cd818410
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sat May 14 18:33:57 2011 -0700

    XQuartz: RandR: Avoid over-releasing if we are unable to determine the current display mode.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    (cherry picked from commit 384eb45b944a4386eae74a5503423c13b5f2a659)

diff --git a/hw/xquartz/quartzRandR.c b/hw/xquartz/quartzRandR.c
index 05641a6..d452b02 100644
--- a/hw/xquartz/quartzRandR.c
+++ b/hw/xquartz/quartzRandR.c
@@ -444,26 +444,29 @@ static Bool QuartzRandRSetConfig (ScreenPtr           pScreen,
 
 static Bool _QuartzRandRUpdateFakeModes (ScreenPtr pScreen) {
     QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
+    QuartzModeInfo activeMode;
+
+    if (!QuartzRandRCopyCurrentModeInfo(pQuartzScreen->displayIDs[0], &activeMode)) {
+        ErrorF("Unable to determine current display mode.\n");
+        return FALSE;
+    }
 
     if(pQuartzScreen->fullscreenMode.ref)
         CFRelease(pQuartzScreen->fullscreenMode.ref);
     if(pQuartzScreen->currentMode.ref)
         CFRelease(pQuartzScreen->currentMode.ref);
-        
-    if (!QuartzRandRCopyCurrentModeInfo(pQuartzScreen->displayIDs[0],
-                                        &pQuartzScreen->fullscreenMode))
-        return FALSE;
 
     if (pQuartzScreen->displayCount > 1) {
-        pQuartzScreen->fullscreenMode.width = pScreen->width;
-        pQuartzScreen->fullscreenMode.height = pScreen->height;
+        activeMode.width = pScreen->width;
+        activeMode.height = pScreen->height;
         if(XQuartzIsRootless)
-            pQuartzScreen->fullscreenMode.height += aquaMenuBarHeight;
+            activeMode.height += aquaMenuBarHeight;
     }
 
+    pQuartzScreen->fullscreenMode = activeMode; 
     pQuartzScreen->fullscreenMode.refresh = FAKE_REFRESH_FULLSCREEN;
 
-    pQuartzScreen->rootlessMode = pQuartzScreen->fullscreenMode;
+    pQuartzScreen->rootlessMode = activeMode;
     pQuartzScreen->rootlessMode.refresh = FAKE_REFRESH_ROOTLESS;
     pQuartzScreen->rootlessMode.height -= aquaMenuBarHeight;
 
commit 69e3527e257af2aae82449bf0e0e7846ccd1ce0c
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sat May 14 16:11:32 2011 -0700

    XQuartz: Don't call mieqEnqueue during server shutdown
    
    Found-by: GuardMalloc
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    (cherry picked from commit 25191648b8db87735a99243697f73036255c1eb6)

diff --git a/dix/main.c b/dix/main.c
index 692bec1..e20ffd6 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -120,9 +120,9 @@ extern void Dispatch(void);
 #ifdef XQUARTZ
 #include <pthread.h>
 
-BOOL serverInitComplete = FALSE;
-pthread_mutex_t serverInitCompleteMutex = PTHREAD_MUTEX_INITIALIZER;
-pthread_cond_t serverInitCompleteCond = PTHREAD_COND_INITIALIZER;
+BOOL serverRunning = FALSE;
+pthread_mutex_t serverRunningMutex = PTHREAD_MUTEX_INITIALIZER;
+pthread_cond_t serverRunningCond = PTHREAD_COND_INITIALIZER;
 
 int dix_main(int argc, char *argv[], char *envp[]);
 
@@ -275,18 +275,25 @@ int main(int argc, char *argv[], char *envp[])
 	}
 
 #ifdef XQUARTZ
-    /* Let the other threads know the server is done with its init */
-    pthread_mutex_lock(&serverInitCompleteMutex);
-    serverInitComplete = TRUE;
-    pthread_cond_broadcast(&serverInitCompleteCond);
-    pthread_mutex_unlock(&serverInitCompleteMutex);
+	/* Let the other threads know the server is done with its init */
+	pthread_mutex_lock(&serverRunningMutex);
+	serverRunning = TRUE;
+	pthread_cond_broadcast(&serverRunningCond);
+	pthread_mutex_unlock(&serverRunningMutex);
 #endif
         
 	NotifyParentProcess();
 
 	Dispatch();
 
-        UndisplayDevices();
+#ifdef XQUARTZ
+	/* Let the other threads know the server is no longer running */
+	pthread_mutex_lock(&serverRunningMutex);
+	serverRunning = FALSE;
+	pthread_mutex_unlock(&serverRunningMutex);
+#endif
+
+	UndisplayDevices();
 
 	/* Now free up whatever must be freed */
 	if (screenIsSaved == SCREEN_SAVER_ON)
diff --git a/hw/xquartz/pbproxy/app-main.m b/hw/xquartz/pbproxy/app-main.m
index b00e90a..0e85101 100644
--- a/hw/xquartz/pbproxy/app-main.m
+++ b/hw/xquartz/pbproxy/app-main.m
@@ -39,9 +39,9 @@ CFStringRef app_prefs_domain_cfstr;
 
 /* Stubs */
 char *display = NULL;
-BOOL serverInitComplete = YES;
-pthread_mutex_t serverInitCompleteMutex = PTHREAD_MUTEX_INITIALIZER;
-pthread_cond_t serverInitCompleteCond = PTHREAD_COND_INITIALIZER;
+BOOL serverRunning = YES;
+pthread_mutex_t serverRunningMutex = PTHREAD_MUTEX_INITIALIZER;
+pthread_cond_t serverRunningCond = PTHREAD_COND_INITIALIZER;
 
 static void signal_handler (int sig) {
     switch(sig) {
diff --git a/hw/xquartz/pbproxy/main.m b/hw/xquartz/pbproxy/main.m
index bb06465..f300c37 100644
--- a/hw/xquartz/pbproxy/main.m
+++ b/hw/xquartz/pbproxy/main.m
@@ -47,17 +47,17 @@ BOOL xpbproxy_is_standalone = NO;
 
 x_selection *_selection_object;
 
-extern BOOL serverInitComplete;
-extern pthread_mutex_t serverInitCompleteMutex;
-extern pthread_cond_t serverInitCompleteCond;
+extern BOOL serverRunning;
+extern pthread_mutex_t serverRunningMutex;
+extern pthread_cond_t serverRunningCond;
 
 static inline void wait_for_server_init(void) {
     /* If the server hasn't finished initializing, wait for it... */
-    if(!serverInitComplete) {
-        pthread_mutex_lock(&serverInitCompleteMutex);
-        while(!serverInitComplete)
-            pthread_cond_wait(&serverInitCompleteCond, &serverInitCompleteMutex);
-        pthread_mutex_unlock(&serverInitCompleteMutex);
+    if(!serverRunning) {
+        pthread_mutex_lock(&serverRunningMutex);
+        while(!serverRunning)
+            pthread_cond_wait(&serverRunningCond, &serverRunningMutex);
+        pthread_mutex_unlock(&serverRunningMutex);
     }
 }
 
diff --git a/mi/mieq.c b/mi/mieq.c
index 01da52a..cd1e47f 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -83,17 +83,17 @@ static EventQueueRec miEventQueue;
 #include  <pthread.h>
 static pthread_mutex_t miEventQueueMutex = PTHREAD_MUTEX_INITIALIZER;
 
-extern BOOL serverInitComplete;
-extern pthread_mutex_t serverInitCompleteMutex;
-extern pthread_cond_t serverInitCompleteCond;
+extern BOOL serverRunning;
+extern pthread_mutex_t serverRunningMutex;
+extern pthread_cond_t serverRunningCond;
 
 static inline void wait_for_server_init(void) {
     /* If the server hasn't finished initializing, wait for it... */
-    if(!serverInitComplete) {
-        pthread_mutex_lock(&serverInitCompleteMutex);
-        while(!serverInitComplete)
-            pthread_cond_wait(&serverInitCompleteCond, &serverInitCompleteMutex);
-        pthread_mutex_unlock(&serverInitCompleteMutex);
+    if(!serverRunning) {
+        pthread_mutex_lock(&serverRunningMutex);
+        while(!serverRunning)
+            pthread_cond_wait(&serverRunningCond, &serverRunningMutex);
+        pthread_mutex_unlock(&serverRunningMutex);
     }
 }
 #endif


More information about the Xquartz-changes mailing list