xserver: Branch 'server-1.8-branch' - 17 commits

Peter Hutterer whot at kemper.freedesktop.org
Mon May 17 23:34:00 PDT 2010


 Xext/sync.c                           |   19 ++++++++-----------
 Xi/extinit.c                          |    1 +
 Xi/xiproperty.c                       |    9 +++++++++
 Xi/xiproperty.h                       |    3 +++
 dix/devices.c                         |    2 ++
 dix/events.c                          |   20 +++++++++++++++-----
 hw/dmx/dmxextension.c                 |    2 +-
 hw/xfree86/common/xf86DGA.c           |    4 +++-
 hw/xfree86/modes/xf86Cursors.c        |    2 +-
 hw/xfree86/ramdac/xf86Cursor.c        |    2 ++
 hw/xquartz/X11Application.m           |   28 ++++++++++++++++++++--------
 hw/xquartz/mach-startup/bundle-main.c |    5 +++++
 include/eventstr.h                    |    4 ++--
 mi/miarc.c                            |    2 +-
 mi/mipolypnt.c                        |    5 +++--
 os/access.c                           |    9 ++++-----
 os/log.c                              |    7 +++++++
 render/render.c                       |    7 +++++++
 test/xi2/protocol-common.c            |    1 +
 xfixes/cursor.c                       |   23 ++++++++++++-----------
 20 files changed, 107 insertions(+), 48 deletions(-)

New commits:
commit 0d9d1e114322878fb50503f69b308b25a812dfb1
Merge: 4b7ff07... 7be5527...
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Tue May 18 14:46:42 2010 +1000

    Merge branch 'server-1.8-branch' of git://people.freedesktop.org/~jeremyhu/xserver into server-1.8-branch

commit 4b7ff07db28ea5302a1965496d1fd71a9d99780e
Author: Keith Packard <keithp at keithp.com>
Date:   Mon May 10 11:46:25 2010 -0700

    Check pixmap allocation return value when creating glyphs
    
    The driver may decide that the pixmap is too large or something and
    fail to allocate a pixmap; not checking would lead to a segfault.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    (cherry picked from commit 87ea5760f86eb60840e6e2c10012915952df5377)

diff --git a/render/render.c b/render/render.c
index 2d9e47a..afe4c92 100644
--- a/render/render.c
+++ b/render/render.c
@@ -1159,6 +1159,12 @@ ProcRenderAddGlyphs (ClientPtr client)
 						   width, height, depth,
 						   CREATE_PIXMAP_USAGE_GLYPH_PICTURE);
 
+		if (!pDstPix)
+		{
+		    err = BadAlloc;
+		    goto bail;
+		}
+
 		GlyphPicture (glyph)[screen] = pDst =
 			CreatePicture (0, &pDstPix->drawable,
 				       glyphSet->format,
@@ -1168,6 +1174,7 @@ ProcRenderAddGlyphs (ClientPtr client)
 		/* The picture takes a reference to the pixmap, so we
 		   drop ours. */
 		(pScreen->DestroyPixmap) (pDstPix);
+		pDstPix = NULL;
 
 		if (! pDst)
 		{
commit e789c860a682454fc86032e88b618f255409c33a
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Thu Apr 29 18:45:34 2010 -0700

    Fix compiler issues with getifaddrs() call on OpenSolaris
    
    OpenSolaris recently added support for the getifaddrs() API.
    
    Building with that uncovered two compiler issues (one warning, one error)
    in the code that was now being built for the first time in our builds:
    
    "access.c", line 768: warning: argument #1 is incompatible with prototype:
            prototype: pointer to struct sockaddr {unsigned short sa_family, array[14] of char sa_data} : "access.c", line 213
            argument : pointer to struct sockaddr_storage {unsigned short ss_family, array[6] of char _ss_pad1, double _ss_align, array[240] of char _ss_pad2}
    
    "access.c", line 838: assignment type mismatch:
            struct sockaddr {unsigned short sa_family, array[14] of char sa_data} "=" struct sockaddr_storage {unsigned short ss_family, array[6] of char _ss_pad1, double _ss_align, array[240] of char _ss_pad2}
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    (cherry picked from commit e42a29d269fadc11e065c63ee369e3165196f2d7)

diff --git a/os/access.c b/os/access.c
index 74c340a..3572da0 100644
--- a/os/access.c
+++ b/os/access.c
@@ -765,7 +765,8 @@ DefineSelf (int fd)
 	    continue;
 #endif /* DNETCONN */
 	len = sizeof(*(ifr->ifa_addr));
-	family = ConvertAddr(ifr->ifa_addr, &len, (pointer *)&addr);
+	family = ConvertAddr((struct sockaddr *) ifr->ifa_addr, &len,
+			     (pointer *)&addr);
 	if (family == -1 || family == FamilyLocal) 
 	    continue;
 #if defined(IPv6) && defined(AF_INET6)
@@ -789,7 +790,6 @@ DefineSelf (int fd)
 	}
 #ifdef XDMCP
 	{
-	    struct sockaddr broad_addr;
 	    /*
 	     * If this isn't an Internet Address, don't register it.
 	     */
@@ -835,11 +835,10 @@ DefineSelf (int fd)
 	    if ((ifr->ifa_flags & IFF_BROADCAST) &&
 		(ifr->ifa_flags & IFF_UP) &&
                 ifr->ifa_broadaddr)
-		broad_addr = *ifr->ifa_broadaddr;
+		XdmcpRegisterBroadcastAddress(
+		    (struct sockaddr_in *) ifr->ifa_broadaddr);
 	    else
 		continue;
-	    XdmcpRegisterBroadcastAddress((struct sockaddr_in *)
-					  &broad_addr);
 	}
 #endif /* XDMCP */
 		
commit 3b6d2b0026f5c37eaeb50441eb2392b9cde962e8
Author: Jamey Sharp <jamey at minilop.net>
Date:   Fri May 14 10:36:13 2010 -0700

    test/xi2: Initialize predefined atoms before XInputExtensionInit.
    
    XInputExtensionInit calls MakeAtom, which doesn't work without the atoms
    table initialized.
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Cc: Peter Hutterer <peter.hutterer at who-t.net>
    Tested-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>
    (cherry picked from commit c6613cfc26e76b296e620640bf33e756eb4ae178)

diff --git a/test/xi2/protocol-common.c b/test/xi2/protocol-common.c
index 2dff1ad..8638fd9 100644
--- a/test/xi2/protocol-common.c
+++ b/test/xi2/protocol-common.c
@@ -153,6 +153,7 @@ void init_simple(void)
     screen.SetCursorPosition = set_cursor_pos;
 
     dixResetPrivates();
+    InitAtoms();
     XInputExtensionInit();
     init_window(&root, NULL, ROOT_WINDOW_ID);
     init_window(&window, &root, CLIENT_WINDOW_ID);
commit 3a3edb2c3d63a3849a95c7911612b57c9af6a341
Author: Cyril Brulebois <kibi at debian.org>
Date:   Mon Mar 1 02:11:36 2010 +0100

    Fix null pointer dereference in xf86_reload_cursors().
    
    Upon resume, X may try to dereference a null pointer, which has been
    reported in Debian bug #507916 (http://bugs.debian.org/507916).
    
    Jim Paris came up with a patch which solves the problem for him. Here's
    a (hopefully) fixed version of his patch (without the typo).
    
    Cc: Jim Paris <jim at jtan.com>
    Signed-off-by: Cyril Brulebois <kibi at debian.org>
    Reviewed-By: Matthias Hopf <mhopf at suse.de>
    Signed-off-by: Keith Packard <keithp at keithp.com>
    (cherry picked from commit fa6c7012572093a82c9389682977efff85590719)

diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c
index e2e174e..4162999 100644
--- a/hw/xfree86/modes/xf86Cursors.c
+++ b/hw/xfree86/modes/xf86Cursors.c
@@ -611,7 +611,7 @@ xf86_reload_cursors (ScreenPtr screen)
     cursor_screen_priv = dixLookupPrivate(&screen->devPrivates,
 					  xf86CursorScreenKey);
     /* return if HW cursor is inactive, to avoid displaying two cursors */
-    if (!cursor_screen_priv->isUp)
+    if (!cursor_screen_priv || !cursor_screen_priv->isUp)
 	return;
 
     scrn = xf86Screens[screen->myNum];
commit 6bb86db2eb6e27e06bd2270429a76008af2dcd94
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Fri Apr 16 16:35:22 2010 +1000

    xfree86: dga needs to use the master keyboard state (#27573)
    
    GetPairedDevice() may not always return the keyboard, resulting in a
    null-pointer dereference when accessing the XKB state.
    For floating devices, the GetMaster() returns the device itself.
    
    X.Org Bug 27573 <http://bugs.freedesktop.org/show_bug.cgi?id=27573>
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>
    Tested-by: Ben Hutchings <ben at decadent.org.uk>
    (cherry picked from commit 10de9e8ee37265a35ceeceb2007d711da70d4f2d)

diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c
index 804fd37..5d8addb 100644
--- a/hw/xfree86/common/xf86DGA.c
+++ b/hw/xfree86/common/xf86DGA.c
@@ -1088,13 +1088,15 @@ DGAProcessPointerEvent (ScreenPtr pScreen, DGAEvent *event, DeviceIntPtr mouse)
     ButtonClassPtr  butc = mouse->button;
     DGAScreenPtr    pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
     DeviceEvent     ev;
+    DeviceIntPtr    master = GetMaster(mouse, MASTER_KEYBOARD);
 
     memset(&ev, 0, sizeof(ev));
     ev.header = ET_Internal;
     ev.length = sizeof(ev);
     ev.type = event->subtype;
     ev.corestate  = butc->state;
-    ev.corestate |= XkbStateFieldFromRec(&GetPairedDevice(mouse)->key->xkbInfo->state);
+    if (master && master->key)
+        ev.corestate |= XkbStateFieldFromRec(&master->key->xkbInfo->state);
 
     UpdateDeviceState(mouse, &ev);
 
commit fd562d11d6cbde2b227e524ae2a9ce4e347b944b
Author: David James <davidjames at google.com>
Date:   Mon May 10 14:00:49 2010 -0700

    Fix wrong bracket values when startOver = FALSE.
    
    Currently, SyncComputeBracketValues reuses old values of bracket_greater
    and bracket_less when startOver = FALSE. This can result in incorrect bracket
    values. To fix this issue, the startOver parameter is removed, and we do not
    reuse old values of bracket_greater and bracket_less.
    
    X.Org Bug 27023 <http://bugs.freedesktop.org/show_bug.cgi?id=27023>
    
    Signed-off-by: David James <davidjames at google.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>
    (cherry picked from commit 758b8614477b53dc3de2b884fec5ccaf8a736432)

diff --git a/Xext/sync.c b/Xext/sync.c
index ce65314..2015fc1 100644
--- a/Xext/sync.c
+++ b/Xext/sync.c
@@ -94,7 +94,7 @@ static SyncCounter **SysCounterList = NULL;
 #define XSyncCAAllTrigger \
     (XSyncCACounter | XSyncCAValueType | XSyncCAValue | XSyncCATestType)
 
-static void SyncComputeBracketValues(SyncCounter *, Bool);
+static void SyncComputeBracketValues(SyncCounter *);
 
 static void SyncInitServerTime(void);
 
@@ -167,7 +167,7 @@ SyncDeleteTriggerFromCounter(SyncTrigger *pTrigger)
     }
 
     if (IsSystemCounter(pTrigger->pCounter))
-	SyncComputeBracketValues(pTrigger->pCounter, /*startOver*/ TRUE);
+	SyncComputeBracketValues(pTrigger->pCounter);
 }
 
 
@@ -194,7 +194,7 @@ SyncAddTriggerToCounter(SyncTrigger *pTrigger)
     pTrigger->pCounter->pTriglist = pCur;
 
     if (IsSystemCounter(pTrigger->pCounter))
-	SyncComputeBracketValues(pTrigger->pCounter, /*startOver*/ TRUE);
+	SyncComputeBracketValues(pTrigger->pCounter);
 
     return Success;
 }
@@ -351,7 +351,7 @@ SyncInitTrigger(ClientPtr client, SyncTrigger *pTrigger, XSyncCounter counter,
     }
     else if (IsSystemCounter(pCounter))
     {
-	SyncComputeBracketValues(pCounter, /*startOver*/ TRUE);
+	SyncComputeBracketValues(pCounter);
     }
 
     return Success;
@@ -646,7 +646,7 @@ SyncChangeCounter(SyncCounter *pCounter, CARD64 newval)
 
     if (IsSystemCounter(pCounter))
     {
-	SyncComputeBracketValues(pCounter, /* startOver */ FALSE);
+	SyncComputeBracketValues(pCounter);
     }
 }
 
@@ -913,7 +913,7 @@ SyncDestroySystemCounter(pointer pSysCounter)
 }
 
 static void
-SyncComputeBracketValues(SyncCounter *pCounter, Bool startOver)
+SyncComputeBracketValues(SyncCounter *pCounter)
 {
     SyncTriggerList *pCur;
     SyncTrigger *pTrigger;
@@ -930,11 +930,8 @@ SyncComputeBracketValues(SyncCounter *pCounter, Bool startOver)
     if (ct == XSyncCounterNeverChanges)
 	return;
 
-    if (startOver)
-    {
-	XSyncMaxValue(&psci->bracket_greater);
-	XSyncMinValue(&psci->bracket_less);
-    }
+    XSyncMaxValue(&psci->bracket_greater);
+    XSyncMinValue(&psci->bracket_less);
 
     for (pCur = pCounter->pTriglist; pCur; pCur = pCur->next)
     {
commit 4bcc0448b42b06ec133886ccb4f029b57b6f2b3e
Author: Jamey Sharp <jamey at minilop.net>
Date:   Sat May 8 09:41:46 2010 -0700

    miPolyPoint bugfix: Check memory allocation before changing the GC.
    
    miPolyPoint ought to leave the GC unchanged even if it fails. ajax says:
    
    > We have a new winner for the oldest-bug competition!  It's actually
    > been like that since X11R1:
    >
    > -rw-r--r--. 1 ajax ajax 2817 1987-09-12 01:20 ddx/mi/mipolypnt.c
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    (cherry picked from commit 4080cd42fde8b4c693eab7557581af2622479109)

diff --git a/mi/mipolypnt.c b/mi/mipolypnt.c
index 5d6243a..12771ee 100644
--- a/mi/mipolypnt.c
+++ b/mi/mipolypnt.c
@@ -73,6 +73,9 @@ miPolyPoint(
     int			i;
     xPoint 		*ppt;
 
+    if(!(pwidthInit = xalloc(npt * sizeof(int))))
+	return;
+
     /* make pointlist origin relative */
     if (mode == CoordModePrevious)
     {
@@ -107,8 +110,6 @@ miPolyPoint(
 	DoChangeGC(pGC, GCFillStyle, &fsNew, 0);
 	ValidateGC(pDrawable, pGC);
     }
-    if(!(pwidthInit = xalloc(npt * sizeof(int))))
-	return;
     pwidth = pwidthInit;
     for(i = 0; i < npt; i++)
 	*pwidth++ = 1;
commit c1e6e7ea968f86f61fd1bfdf4764c57be2a93605
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Apr 26 17:22:12 2010 -0700

    dmxBERestoreRenderGlyph was passing wrong value to free
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Matt Turner <mattst88 at gmail.com>
    (cherry picked from commit c0799779dffeef8cef228bdc57aa6c8b323e7485)

diff --git a/hw/dmx/dmxextension.c b/hw/dmx/dmxextension.c
index 2266041..1a52e80 100644
--- a/hw/dmx/dmxextension.c
+++ b/hw/dmx/dmxextension.c
@@ -1160,7 +1160,7 @@ static void dmxBERestoreRenderGlyph(pointer value, XID id, pointer n)
 		     len_images);
 
     /* Clean up */
-    free(len_images);
+    free(images);
     free(gids);
     free(glyphs);    
 }
commit de3275537db09065510ca2a697cbbe184da9f207
Author: Matthias Hopf <mhopf at suse.de>
Date:   Fri May 7 18:46:30 2010 +0200

    Fix mod() definition.
    
    Presumably no implications, especially security-wise.
    
    Signed-off-by: Matthias Hopf <mhopf at suse.de>
    Reviewed-by: Matt Turner <mattst88 at gmail.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>
    (cherry picked from commit e2e2747f40c4b9e23dba38ea656d4c082e83a794)

diff --git a/mi/miarc.c b/mi/miarc.c
index 5fd1a67..ddcbff7 100644
--- a/mi/miarc.c
+++ b/mi/miarc.c
@@ -1524,7 +1524,7 @@ miRoundCap(
 
 # define Dsin(d)	((d) == 0.0 ? 0.0 : ((d) == 90.0 ? 1.0 : sin(d*M_PI/180.0)))
 # define Dcos(d)	((d) == 0.0 ? 1.0 : ((d) == 90.0 ? 0.0 : cos(d*M_PI/180.0)))
-# define mod(a,b)	((a) >= 0 ? (a) % (b) : (b) - (-a) % (b))
+# define mod(a,b)	((a) >= 0 ? (a) % (b) : (b) - (-(a)) % (b))
 
 static double
 miDcos (double a)
commit 80547b14a85e4c44631e8b2dc3cd67ccfda7fb43
Author: Chris Humbert <freedesktop at mahadri.com>
Date:   Fri May 7 17:02:43 2010 +1000

    dix: make DeviceEvent coordinates signed for Xinerama. #24986
    
    With Xinerama enabled, event coordinates are relative to Screen 0, so
    they can be negative.  The new DeviceEvent's coordinates are of type
    uint16_t, making screens above and to the left of Screen 0 unusable.
    
    X.Org Bug 24986 <https://bugs.freedesktop.org/show_bug.cgi?id=24986>
    
    Signed-off-by: Chris Humbert <freedesktop at mahadri.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Keith Packard <keithp at keithp.com>
    (cherry picked from commit 21ed660f30a3f96c787ab00a16499e0fb034b2ad)

diff --git a/include/eventstr.h b/include/eventstr.h
index 79685c1..433227e 100644
--- a/include/eventstr.h
+++ b/include/eventstr.h
@@ -91,9 +91,9 @@ struct _DeviceEvent
         uint32_t button;  /**< Button number */
         uint32_t key;     /**< Key code */
     } detail;
-    uint16_t root_x;      /**< Pos relative to root window in integral data */
+    int16_t root_x;       /**< Pos relative to root window in integral data */
     float root_x_frac;    /**< Pos relative to root window in frac part */
-    uint16_t root_y;      /**< Pos relative to root window in integral part */
+    int16_t root_y;       /**< Pos relative to root window in integral part */
     float root_y_frac;    /**< Pos relative to root window in frac part */
     uint8_t    buttons[(MAX_BUTTONS + 7)/8]; /**< Button mask */
     struct {
commit 331e9720b5c05e43b8343d5c71d821dee0463c3e
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Fri May 7 16:22:12 2010 +1000

    Xi: reset the known properties at the end of the server generation.
    
    Properties allocated through XIGetKnownProperty() aren't reset on the second
    server generation but keep the old value. As a result, wrong Atoms are
    supplied to the driver, resulting in potential data corruption or weird
    error message.
    
    Reproducible by running "xlsatom | grep FLOAT" twice on a plain X server.
    The second X server generation won't have the FLOAT atom defined anymore,
    despite the users of this atom not noticing any errors.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Julien Cristau <jcristau at debian.org>
    Signed-off-by: Keith Packard <keithp at keithp.com>
    (cherry picked from commit 9802839d35aaf788790f1d0e8300db4693a70096)

diff --git a/Xi/extinit.c b/Xi/extinit.c
index b7910cd..37f9856 100644
--- a/Xi/extinit.c
+++ b/Xi/extinit.c
@@ -1122,6 +1122,7 @@ RestoreExtensionEvents(void)
 static void
 IResetProc(ExtensionEntry * unused)
 {
+    XIResetProperties();
 
     ReplySwapVector[IReqCode] = ReplyNotSwappd;
     EventSwapVector[DeviceValuator] = NotImplemented;
diff --git a/Xi/xiproperty.c b/Xi/xiproperty.c
index be07831..8b80637 100644
--- a/Xi/xiproperty.c
+++ b/Xi/xiproperty.c
@@ -403,6 +403,15 @@ XIGetKnownProperty(char *name)
     return 0;
 }
 
+void
+XIResetProperties(void)
+{
+    int i;
+
+    for (i = 0; i < (sizeof(dev_properties)/sizeof(struct dev_properties)); i++)
+        dev_properties[i].type = None;
+}
+
 /**
  * Convert the given property's value(s) into @nelem_return integer values and
  * store them in @buf_return. If @nelem_return is larger than the number of
diff --git a/Xi/xiproperty.h b/Xi/xiproperty.h
index 69b41fa..d8b8863 100644
--- a/Xi/xiproperty.h
+++ b/Xi/xiproperty.h
@@ -62,4 +62,7 @@ void SRepXIListProperties(ClientPtr client, int size,
                           xXIListPropertiesReply *rep);
 void SRepXIGetProperty(ClientPtr client, int size,
                        xXIGetPropertyReply *rep);
+
+void XIResetProperties(void);
+
 #endif /* XIPROPERTY_H */
commit dee99e6925c8e51263398bd2c8fb70289dae748c
Author: Keith Packard <keithp at keithp.com>
Date:   Fri Apr 30 16:10:32 2010 -0700

    Make sure XFixes invisible cursor gets freed on server reset
    
    This uses the same hack that dix uses for the rootCursor -- allocate
    a resource ID for the invisible cursor so that it gets freed at reset
    time. This also allows us to unconditionally create it during
    extension initialization; necessary as the privates layout may well be
    different on subsequent generations.
    
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>
    (cherry picked from commit a3f5d30ba61e70b3de8b48754dea32715ba93c40)
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/xfixes/cursor.c b/xfixes/cursor.c
index 1471a58..2aba0ce 100644
--- a/xfixes/cursor.c
+++ b/xfixes/cursor.c
@@ -1054,11 +1054,15 @@ createInvisibleCursor (void)
     cm.xhot = 0;
     cm.yhot = 0;
 
-    AllocARGBCursor(psrcbits, pmaskbits,
-		NULL, &cm,
-		0, 0, 0,
-		0, 0, 0,
-		&pCursor, serverClient, (XID)0);
+    if (AllocARGBCursor(psrcbits, pmaskbits,
+			NULL, &cm,
+			0, 0, 0,
+			0, 0, 0,
+			&pCursor, serverClient, (XID)0) != Success)
+	return NullCursor;
+
+    if (!AddResource(FakeClientID(0), RT_CURSOR, (pointer) pCursor))
+	return NullCursor;
 
     return pCursor;
 }
@@ -1091,12 +1095,9 @@ XFixesCursorInit (void)
     CursorWindowType = CreateNewResourceType(CursorFreeWindow,
 					     "XFixesCursorWindow");
 
-    if (pInvisibleCursor == NULL) {
-	pInvisibleCursor = createInvisibleCursor();
-	if (pInvisibleCursor == NULL) {
-	    return BadAlloc;
-	}
-    }
+    pInvisibleCursor = createInvisibleCursor();
+    if (pInvisibleCursor == NULL)
+	return BadAlloc;
 
     return CursorClientType && CursorHideCountType && CursorWindowType;
 }
commit ede10681c4f9d835fa8af115e349e2fd9feeb697
Author: Keith Packard <keithp at keithp.com>
Date:   Fri Apr 30 12:18:09 2010 -0700

    Fix cursor ref counting mistakes with sprites and xf86Cursor.c
    
    A few cursor value assignments weren't getting correctly ref counted,
    causing leaks of cursor objects.
    
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>
    (cherry picked from commit cdeb2c23f80ced961fe205125547e16905885534)

diff --git a/dix/devices.c b/dix/devices.c
index 6119dce..32e067b 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -857,6 +857,8 @@ CloseDevice(DeviceIntPtr dev)
     }
 
     if (DevHasCursor(dev) && dev->spriteInfo->sprite) {
+	if (dev->spriteInfo->sprite->current)
+	    FreeCursor(dev->spriteInfo->sprite->current, None);
         xfree(dev->spriteInfo->sprite->spriteTrace);
         xfree(dev->spriteInfo->sprite);
     }
diff --git a/dix/events.c b/dix/events.c
index 6d0137d..5de1505 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -2943,6 +2943,7 @@ InitializeSprite(DeviceIntPtr pDev, WindowPtr pWin)
 {
     SpritePtr pSprite;
     ScreenPtr pScreen;
+    CursorPtr pCursor;
 
     if (!pDev->spriteInfo->sprite)
     {
@@ -2986,8 +2987,7 @@ InitializeSprite(DeviceIntPtr pDev, WindowPtr pWin)
 
     if (pWin)
     {
-        pSprite->current = wCursor(pWin);
-        pSprite->current->refcnt++;
+	pCursor = wCursor(pWin);
 	pSprite->spriteTrace = (WindowPtr *)xcalloc(1, 32*sizeof(WindowPtr));
 	if (!pSprite->spriteTrace)
 	    FatalError("Failed to allocate spriteTrace");
@@ -3000,13 +3000,18 @@ InitializeSprite(DeviceIntPtr pDev, WindowPtr pWin)
 	pSprite->pDequeueScreen = pSprite->pEnqueueScreen;
 
     } else {
-        pSprite->current = NullCursor;
+        pCursor = NullCursor;
 	pSprite->spriteTrace = NULL;
 	pSprite->spriteTraceSize = 0;
 	pSprite->spriteTraceGood = 0;
 	pSprite->pEnqueueScreen = screenInfo.screens[0];
 	pSprite->pDequeueScreen = pSprite->pEnqueueScreen;
     }
+    if (pCursor)
+	pCursor->refcnt++;
+    if (pSprite->current)
+	FreeCursor(pSprite->current, None);
+    pSprite->current = pCursor;
 
     if (pScreen)
     {
@@ -3059,6 +3064,7 @@ UpdateSpriteForScreen(DeviceIntPtr pDev, ScreenPtr pScreen)
 {
     SpritePtr pSprite = NULL;
     WindowPtr win = NULL;
+    CursorPtr pCursor;
     if (!pScreen)
         return ;
 
@@ -3074,8 +3080,12 @@ UpdateSpriteForScreen(DeviceIntPtr pDev, ScreenPtr pScreen)
     pSprite->hotLimits.x2 = pScreen->width;
     pSprite->hotLimits.y2 = pScreen->height;
     pSprite->win = win;
-    pSprite->current = wCursor (win);
-    pSprite->current->refcnt++;
+    pCursor = wCursor(win);
+    if (pCursor)
+	pCursor->refcnt++;
+    if (pSprite->current)
+	FreeCursor(pSprite->current, 0);
+    pSprite->current = pCursor;
     pSprite->spriteTraceGood = 1;
     pSprite->spriteTrace[0] = win;
     (*pScreen->CursorLimits) (pDev,
diff --git a/hw/xfree86/ramdac/xf86Cursor.c b/hw/xfree86/ramdac/xf86Cursor.c
index f5f0873..346e994 100644
--- a/hw/xfree86/ramdac/xf86Cursor.c
+++ b/hw/xfree86/ramdac/xf86Cursor.c
@@ -312,6 +312,8 @@ xf86CursorSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs,
             xf86SetCursor(pScreen, NullCursor, x, y);
             ScreenPriv->isUp = FALSE;
         }
+	if (ScreenPriv->CurrentCursor)
+	    FreeCursor(ScreenPriv->CurrentCursor, None);
         ScreenPriv->CurrentCursor = NullCursor;
         return;
     }
commit 7be55271d090d9c837ee7e1c43c09c76961a7173
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sun May 16 10:14:02 2010 -0700

    XQuartz: Fix a build failure on Tiger
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    (cherry picked from commit 37f0b45dbe4ea52bc127720207c7157b2b803ac0)

diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index 42aa757..63a185f 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -75,7 +75,12 @@ extern int noPanoramiXExtension;
 
 static char __crashreporter_info_buff__[4096] = {0};
 static const char *__crashreporter_info__ = &__crashreporter_info_buff__[0];
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
+// This is actually a toolchain requirement, but I'm not sure the correct check,
+// but it should be fine to just only include it for Leopard and later.  This line
+// just tells the linker to never strip this symbol (such as for space optimization)
 asm (".desc ___crashreporter_info__, 0x10");
+#endif
 
 static const char *__crashreporter_info__base = "X.Org X Server " XSERVER_VERSION " Build Date: " BUILD_DATE;
 
diff --git a/os/log.c b/os/log.c
index 3773315..185bf61 100644
--- a/os/log.c
+++ b/os/log.c
@@ -118,10 +118,17 @@ static int bufferSize = 0, bufferUnused = 0, bufferPos = 0;
 static Bool needBuffer = TRUE;
 
 #ifdef __APPLE__
+#include <AvailabilityMacros.h>
+
 static char __crashreporter_info_buff__[4096] = {0};
 static const char *__crashreporter_info__ = &__crashreporter_info_buff__[0];
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
+// This is actually a toolchain requirement, but I'm not sure the correct check,        
+// but it should be fine to just only include it for Leopard and later.  This line
+// just tells the linker to never strip this symbol (such as for space optimization)
 asm (".desc ___crashreporter_info__, 0x10");
 #endif
+#endif
 
 /* Prefix strings for log messages. */
 #ifndef X_UNKNOWN_STRING
commit d415f36b8e40d7df94da8910f370fb28004046cf
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sun May 16 10:03:13 2010 -0700

    XQuartz: Don't use deltaXY for determining pointer location on scroll events
    
    <rdar://problem/7989690>
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Edward Moy <emoy at apple.com>
    (cherry picked from commit ecfeabec8d0dcfe286fb893047f1fe1a7ea9f8f5)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index ed9fb32..805ed99 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -1030,23 +1030,32 @@ static inline int ensure_flag(int flags, int device_independent, int device_depe
     if(isMouseOrTabletEvent) {
         static NSPoint lastpt;
         NSWindow *window = [e window];
-        NSRect screen = [[[NSScreen screens] objectAtIndex:0] frame];;
-
+        NSRect screen = [[[NSScreen screens] objectAtIndex:0] frame];
+	    BOOL hasUntrustedPointerDelta;
+        
+        // NSEvents for tablets are not consistent wrt deltaXY between events, so we cannot rely on that
+        // Thus tablets will be subject to the warp-pointer bug worked around by the delta, but tablets
+        // are not normally used in cases where that bug would present itself, so this is a fair tradeoff
+        // <rdar://problem/7111003> deltaX and deltaY are incorrect for NSMouseMoved, NSTabletPointEventSubtype
+        // http://xquartz.macosforge.org/trac/ticket/288
+        hasUntrustedPointerDelta = isTabletEvent;
+        
+        // The deltaXY for middle click events also appear erroneous after fast user switching
+        // <rdar://problem/7979468> deltaX and deltaY are incorrect for NSOtherMouseDown and NSOtherMouseUp after FUS
+        // http://xquartz.macosforge.org/trac/ticket/389
+        hasUntrustedPointerDelta = hasUntrustedPointerDelta || [e type] == NSOtherMouseDown || [e type] == NSOtherMouseUp;
+
+        // The deltaXY for scroll events correspond to the scroll delta, not the pointer delta
+        // <rdar://problem/7989690> deltaXY for wheel events are being sent as mouse movement
+        hasUntrustedPointerDelta = hasUntrustedPointerDelta || [e type] == NSScrollWheel;
+        
         if (window != nil)	{
             NSRect frame = [window frame];
             location = [e locationInWindow];
             location.x += frame.origin.x;
             location.y += frame.origin.y;
             lastpt = location;
-        } else if(isTabletEvent || [e type] == NSOtherMouseDown || [e type] == NSOtherMouseUp) {
-            // NSEvents for tablets are not consistent wrt deltaXY between events, so we cannot rely on that
-            // Thus tablets will be subject to the warp-pointer bug worked around by the delta, but tablets
-            // are not normally used in cases where that bug would present itself, so this is a fair tradeoff
-            // <rdar://problem/7111003> deltaX and deltaY are incorrect for NSMouseMoved, NSTabletPointEventSubtype
-            // http://xquartz.macosforge.org/trac/ticket/288
-            // The deltaXY for middle click events also appear erroneous after fast user switching
-            // <rdar://problem/7979468> deltaX and deltaY are incorrect for NSOtherMouseDown and NSOtherMouseUp after FUS
-            // http://xquartz.macosforge.org/trac/ticket/389
+        } else if(hasUntrustedPointerDelta) {
             location = [e locationInWindow];
             lastpt = location;
         } else {
commit aad87519b8bd6983a28d537eec4fb15570da73b5
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sat May 15 10:53:09 2010 -0700

    XQuartz: Don't trust deltaXY for middle mouse clicks.
    
    The middle mouse clicks return erroneous values after returning from
    Fast User Switching.
    
    <rdar://problem/7979468>
    http://xquartz.macosforge.org/trac/ticket/389
    
    Signed-off-by: Martin Otte <otte at duke.edu>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Edward Moy <emoy at apple.com>
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    (cherry picked from commit a911292c85f7069d2caabcb677ed716a04227526)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index c9a0d66..ed9fb32 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -1038,12 +1038,15 @@ static inline int ensure_flag(int flags, int device_independent, int device_depe
             location.x += frame.origin.x;
             location.y += frame.origin.y;
             lastpt = location;
-        } else if(isTabletEvent) {
+        } else if(isTabletEvent || [e type] == NSOtherMouseDown || [e type] == NSOtherMouseUp) {
             // NSEvents for tablets are not consistent wrt deltaXY between events, so we cannot rely on that
             // Thus tablets will be subject to the warp-pointer bug worked around by the delta, but tablets
             // are not normally used in cases where that bug would present itself, so this is a fair tradeoff
             // <rdar://problem/7111003> deltaX and deltaY are incorrect for NSMouseMoved, NSTabletPointEventSubtype
             // http://xquartz.macosforge.org/trac/ticket/288
+            // The deltaXY for middle click events also appear erroneous after fast user switching
+            // <rdar://problem/7979468> deltaX and deltaY are incorrect for NSOtherMouseDown and NSOtherMouseUp after FUS
+            // http://xquartz.macosforge.org/trac/ticket/389
             location = [e locationInWindow];
             lastpt = location;
         } else {


More information about the xorg-commit mailing list