[Xquartz-changes] xserver: Branch 'server-1.11-apple' - 10 commits

Jeremy Huddleston jeremyhu at freedesktop.org
Sat May 14 19:14:31 PDT 2011


Rebased ref, commits from common ancestor:
commit 07169f79b7065f2cd66c6c69aff23fdcf612bef0
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 3466ab026c9cae38fac58f90f924a2252e79d237
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 a474073..a54362d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -86,6 +86,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 3caeda8c36b8c48e7eafd080c22157457cc09043
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sat May 14 16:48:53 2011 -0700

    mi: Fix compilation warnings
    
    mibitblt.c:654:13: warning: declaration shadows a local variable [-Wshadow,Semantic Issue]
                xPoint pt;
                       ^
    mibitblt.c:644:18: note: previous declaration is here
        DDXPointRec         pt = {0, 0};
                            ^
    1 warning generated.
    
    mispans.c:452:12: warning: declaration shadows a local variable [-Wshadow,Semantic Issue]
                                int i;
                                    ^
    mispans.c:376:14: note: previous declaration is here
        int                 i;
                            ^
    mispans.c:486:10: warning: declaration shadows a local variable [-Wshadow,Semantic Issue]
                int i;
                    ^
    mispans.c:376:14: note: previous declaration is here
        int                 i;
                            ^
    2 warnings generated.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/mi/mibitblt.c b/mi/mibitblt.c
index 49e17bd..47bebd8 100644
--- a/mi/mibitblt.c
+++ b/mi/mibitblt.c
@@ -651,7 +651,6 @@ miGetImage( DrawablePtr pDraw, int sx, int sy, int w, int h,
 	if ( (((1<<depth)-1)&planeMask) != (1<<depth)-1 )
 	{
 	    ChangeGCVal gcv;
-	    xPoint pt;
 
 	    pGC = GetScratchGC(depth, pDraw->pScreen);
 	    if (!pGC)
diff --git a/mi/mispans.c b/mi/mispans.c
index 21ba4da..c2308a2 100644
--- a/mi/mispans.c
+++ b/mi/mispans.c
@@ -449,12 +449,12 @@ void miFillUniqueSpanGroup(DrawablePtr pDraw, GCPtr pGC, SpanGroup *spanGroup)
 			    ysizes[index] * sizeof(int));
 			if (!newpoints || !newwidths)
 			{
-			    int	i;
+			    int	k;
 
-			    for (i = 0; i < ylength; i++)
+			    for (k = 0; k < ylength; k++)
 			    {
-				free(yspans[i].points);
-				free(yspans[i].widths);
+				free(yspans[k].points);
+				free(yspans[k].widths);
 			    }
 			    free(yspans);
 			    free(ysizes);
@@ -483,12 +483,12 @@ void miFillUniqueSpanGroup(DrawablePtr pDraw, GCPtr pGC, SpanGroup *spanGroup)
 	widths = malloc(count * sizeof(int));
 	if (!points || !widths)
 	{
-	    int	i;
+	    int	j;
 
-	    for (i = 0; i < ylength; i++)
+	    for (j = 0; j < ylength; j++)
 	    {
-		free(yspans[i].points);
-		free(yspans[i].widths);
+		free(yspans[j].points);
+		free(yspans[j].widths);
 	    }
 	    free(yspans);
 	    free(ysizes);
commit 8681670e5cf7bb1cd2d2e01cfe763f349836cbba
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sat May 14 16:41:59 2011 -0700

    fb: Fix compilation warnings
    
    fbbltone.c:795:6: warning: declaration shadows a local variable [-Wshadow,Semantic Issue]
            int w = 24;
                ^
    fbbltone.c:777:10: note: previous declaration is here
        int         w;
                    ^
    1 warning generated.
    
    fbblt.c:80:16: warning: declaration shadows a local variable [-Wshadow,Semantic Issue]
            CARD8 *src = (CARD8 *) srcLine;
                   ^
    fbblt.c:61:14: note: previous declaration is here
        FbBits  *src, *dst;
                 ^
    fbblt.c:81:16: warning: declaration shadows a local variable [-Wshadow,Semantic Issue]
            CARD8 *dst = (CARD8 *) dstLine;
                   ^
    fbblt.c:61:20: note: previous declaration is here
        FbBits  *src, *dst;
                       ^
    2 warnings generated.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/fb/fbblt.c b/fb/fbblt.c
index a040298..6cee526 100644
--- a/fb/fbblt.c
+++ b/fb/fbblt.c
@@ -77,21 +77,21 @@ fbBlt (FbBits   *srcLine,
     if (alu == GXcopy && pm == FB_ALLONES && !reverse &&
             !(srcX & 7) && !(dstX & 7) && !(width & 7)) {
         int i;
-        CARD8 *src = (CARD8 *) srcLine;
-        CARD8 *dst = (CARD8 *) dstLine;
+        CARD8 *srcb = (CARD8 *) srcLine;
+        CARD8 *dstb = (CARD8 *) dstLine;
         
         srcStride *= sizeof(FbBits);
         dstStride *= sizeof(FbBits);
         width >>= 3;
-        src += (srcX >> 3);
-        dst += (dstX >> 3);
+        srcb += (srcX >> 3);
+        dstb += (dstX >> 3);
 
         if (!upsidedown)
             for (i = 0; i < height; i++)
-                MEMCPY_WRAPPED(dst + i * dstStride, src + i * srcStride, width);
+                MEMCPY_WRAPPED(dstb + i * dstStride, srcb + i * srcStride, width);
         else
             for (i = height - 1; i >= 0; i--)
-                MEMCPY_WRAPPED(dst + i * dstStride, src + i * srcStride, width);
+                MEMCPY_WRAPPED(dstb + i * dstStride, srcb + i * srcStride, width);
 
         return;
     }
diff --git a/fb/fbbltone.c b/fb/fbbltone.c
index 0a91575..8ce65c5 100644
--- a/fb/fbbltone.c
+++ b/fb/fbbltone.c
@@ -792,12 +792,12 @@ fbBltPlane (FbBits	    *src,
     pm = fbReplicatePixel (planeMask, srcBpp);
     if (srcBpp == 24)
     {
-	int w = 24;
+	int wi = 24;
 
 	rot0 = FbFirst24Rot (srcX);
-	if (srcX + w > FB_UNIT)
-	    w = FB_UNIT - srcX;
-	srcMaskFirst = FbRot24(pm,rot0) & FbBitsMask(srcX,w);
+	if (srcX + wi > FB_UNIT)
+	    wi = FB_UNIT - srcX;
+	srcMaskFirst = FbRot24(pm,rot0) & FbBitsMask(srcX,wi);
     }
     else
     {
commit 4434f0d70dc4b016825956b126888a953fd34380
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sat May 14 16:31:17 2011 -0700

    dix: Fix compilation warnings
    
    cursor.c:155:6: warning: declaration shadows a local variable [-Wshadow,Semantic Issue]
            int n = bits->width * bits->height;
                ^
    cursor.c:146:9: note: previous declaration is here
        int n = BitmapBytePad(bits->width) * bits->height;
            ^
    1 warning generated.
    
    dispatch.c:1629:5: warning: declaration shadows a local variable [-Wshadow,Semantic Issue]
        VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pDst, DixWriteAccess);
        ^
    In file included from dispatch.c:112:
    In file included from ../include/windowstr.h:52:
    In file included from ../include/pixmapstr.h:53:
    In file included from ../include/privates.h:145:
    ../include/dix.h:91:6: note: instantiated from:
            int rc = dixLookupDrawable(&(pDraw), drawID, client, M_ANY, mode);\
                ^
    dispatch.c:1625:9: note: previous declaration is here
        int rc;
            ^
    dispatch.c:1670:5: warning: declaration shadows a local variable [-Wshadow,Semantic Issue]
        VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pdstDraw, DixWriteAccess);
        ^
    In file included from dispatch.c:112:
    In file included from ../include/windowstr.h:52:
    In file included from ../include/pixmapstr.h:53:
    In file included from ../include/privates.h:145:
    ../include/dix.h:91:6: note: instantiated from:
            int rc = dixLookupDrawable(&(pDraw), drawID, client, M_ANY, mode);\
                ^
    dispatch.c:1666:9: note: previous declaration is here
        int rc;
            ^
    2 warnings generated.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/dix/cursor.c b/dix/cursor.c
index c191c1e..e967b01 100644
--- a/dix/cursor.c
+++ b/dix/cursor.c
@@ -152,7 +152,7 @@ CheckForEmptyMask(CursorBitsPtr bits)
     if (bits->argb)
     {
 	CARD32 *argb = bits->argb;
-	int n = bits->width * bits->height;
+	n = bits->width * bits->height;
 	while (n--)
 	    if (*argb++ & 0xff000000) return;
     }
diff --git a/dix/dispatch.c b/dix/dispatch.c
index 192c8c3..ea67132 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -1622,14 +1622,13 @@ ProcCopyArea(ClientPtr client)
     GC *pGC;
     REQUEST(xCopyAreaReq);
     RegionPtr pRgn;
-    int rc;
 
     REQUEST_SIZE_MATCH(xCopyAreaReq);
 
     VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pDst, DixWriteAccess); 
     if (stuff->dstDrawable != stuff->srcDrawable)
     {
-	rc = dixLookupDrawable(&pSrc, stuff->srcDrawable, client, 0,
+	int rc = dixLookupDrawable(&pSrc, stuff->srcDrawable, client, 0,
 				 DixReadAccess);
 	if (rc != Success)
 	    return rc;
@@ -1663,14 +1662,13 @@ ProcCopyPlane(ClientPtr client)
     GC *pGC;
     REQUEST(xCopyPlaneReq);
     RegionPtr pRgn;
-    int rc;
 
     REQUEST_SIZE_MATCH(xCopyPlaneReq);
 
     VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pdstDraw, DixWriteAccess);
     if (stuff->dstDrawable != stuff->srcDrawable)
     {
-	rc = dixLookupDrawable(&psrcDraw, stuff->srcDrawable, client, 0,
+	int rc = dixLookupDrawable(&psrcDraw, stuff->srcDrawable, client, 0,
 			       DixReadAccess);
 	if (rc != Success)
 	    return rc;
commit 6c6f25eb38e441bc5063909559e364ec3b047dc3
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sat May 14 16:29:09 2011 -0700

    input: Fix format string for verify_internal_event
    
    inpututils.c:577:25: warning: conversion specifies type 'unsigned short' but the argument has type 'unsigned char' [-Wformat,Format String Issue]
                ErrorF("%02hx ", *data);
                        ~~~~^    ~~~~~
                        %02hhx
    1 warning generated.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/dix/inpututils.c b/dix/inpututils.c
index aeace6e..49e1758 100644
--- a/dix/inpututils.c
+++ b/dix/inpututils.c
@@ -574,7 +574,7 @@ void verify_internal_event(const InternalEvent *ev)
 
         for (i = 0; i < sizeof(xEvent); i++, data++)
         {
-            ErrorF("%02hx ", *data);
+            ErrorF("%02hhx ", *data);
 
             if ((i % 8) == 7)
                 ErrorF("\n");
commit 02fb9569a9b91a5c04c631f3ce8a65ee9ea84340
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sat May 14 12:23:44 2011 -0700

    input: Don't implicitly define verify_internal_event
    
    Fixes regression introduced by 56901998020b6f443cbaa5eb303100d979e81b22
    
    mieq.c:159:5: error: implicit declaration of function 'verify_internal_event' is invalid in C99 [-Wimplicit-function-declaration,Semantic Issue]
        verify_internal_event(e);
        ^
    1 error generated.
    
    Also includes some other warning cleanups in events.c we're there.
    
    events.c:2198:24: warning: equality comparison with extraneous parentheses [-Wparentheses,Semantic Issue]
            else if ((type == MotionNotify))
                      ~~~~~^~~~~~~~~~~~~~~
    events.c:2198:24: note: remove extraneous parentheses around the comparison to silence this warning [Semantic Issue]
            else if ((type == MotionNotify))
                     ~     ^              ~
    events.c:2198:24: note: use '=' to turn this equality comparison into an assignment [Semantic Issue]
            else if ((type == MotionNotify))
                           ^~
                           =
    events.c:2487:5: error: implicit declaration of function 'verify_internal_event' is invalid in C99 [-Wimplicit-function-declaration,Semantic Issue]
        verify_internal_event(event);
        ^
    events.c:5909:22: warning: declaration shadows a local variable [-Wshadow,Semantic Issue]
            DeviceIntPtr it = inputInfo.devices;
                         ^
    events.c:5893:18: note: previous declaration is here
        DeviceIntPtr it = inputInfo.devices;
                     ^
    3 warnings and 1 error generated.
    
    events.c:2836:27: warning: incompatible pointer types passing 'DeviceEvent *' (aka 'struct _DeviceEvent *') to parameter of type
          'const InternalEvent *' (aka 'const union _InternalEvent *')
        verify_internal_event(ev);
                              ^~
    ../include/inpututils.h:40:56: note: passing argument to parameter 'ev' here
    extern void verify_internal_event(const InternalEvent *ev);
                                                           ^
    1 warning generated.
    
    Found-by: yuffie tinderbox (-Werror=implicit)
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/dix/events.c b/dix/events.c
index 14f6f90..b60c299 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -112,6 +112,7 @@ Equipment Corporation.
 #include <X11/Xproto.h>
 #include "windowstr.h"
 #include "inputstr.h"
+#include "inpututils.h"
 #include "scrnintstr.h"
 #include "cursorstr.h"
 
@@ -2195,7 +2196,7 @@ DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent
          */
         if (!grab && ActivateImplicitGrab(pDev, client, pWin, pEvents, deliveryMask))
             /* grab activated */;
-        else if ((type == MotionNotify))
+        else if (type == MotionNotify)
             pDev->valuator->motionHintWindow = pWin;
         else if (type == DeviceMotionNotify || type == DeviceButtonPress)
                 CheckDeviceGrabAndHintWindow (pWin, type,
@@ -2832,7 +2833,7 @@ CheckMotion(DeviceEvent *ev, DeviceIntPtr pDev)
     WindowPtr prevSpriteWin, newSpriteWin;
     SpritePtr pSprite = pDev->spriteInfo->sprite;
 
-    verify_internal_event(ev);
+    verify_internal_event((InternalEvent *)ev);
 
     prevSpriteWin = pSprite->win;
 
@@ -5906,7 +5907,7 @@ PickPointer(ClientPtr client)
 
     if (!client->clientPtr)
     {
-        DeviceIntPtr it = inputInfo.devices;
+        it = inputInfo.devices;
         while (it)
         {
             if (IsMaster(it) && it->spriteInfo->spriteOwner)
diff --git a/mi/mieq.c b/mi/mieq.c
index 031b11a..fc3738a 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -43,6 +43,7 @@ in this Software without prior written authorization from The Open Group.
 # include   "windowstr.h"
 # include   "pixmapstr.h"
 # include   "inputstr.h"
+# include   "inpututils.h"
 # include   "mi.h"
 # include   "mipointer.h"
 # include   "scrnintstr.h"
commit 84e04966949a65eb8a203903b488205919e82fb4
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>

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 df3b1b8b044959224a3104d5cdd866aeaaa37b0e
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>

diff --git a/dix/main.c b/dix/main.c
index 31e2d48..bc958b8 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -121,9 +121,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[]);
 
@@ -277,18 +277,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 9055bad..a8c3a60 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 dbdb6d0..29ce83b 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 236ffcc..031b11a 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
commit 71d727de48712e516e4a2d79ba5aefefb24dd1ac
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sat May 14 14:09:45 2011 -0700

    XQuartz: Fix an array-index-out-of-bounds crasher
    
    Found-by: GuardMalloc
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/hw/xquartz/console_redirect.c b/hw/xquartz/console_redirect.c
index cdd2b89..70a819e 100644
--- a/hw/xquartz/console_redirect.c
+++ b/hw/xquartz/console_redirect.c
@@ -116,7 +116,7 @@ static inline int _read_redirect(int fd, int flush) {
                 *s='\0';
                 asl_log(aslr->asl, aslr->msg, aslr->level, "%s", p);
             } else if(aslr->buf != p) {
-                memmove(aslr->buf, p, BUF_SIZE);
+                memmove(aslr->buf, p, BUF_SIZE - (p - aslr->buf));
                 aslr->w = aslr->buf + (s - p);
                 break;
             } else if(nbytes == BUF_SIZE - 1) {


More information about the Xquartz-changes mailing list