xserver: Branch 'server-1.7-branch' - 19 commits

Peter Hutterer whot at kemper.freedesktop.org
Thu Mar 4 16:18:34 PST 2010


 Xext/xselinux.c                          |  131 +++++++++----------------------
 Xext/xselinux.h                          |    8 -
 Xi/exevents.c                            |   13 +--
 Xi/setmode.c                             |   10 ++
 configure.ac                             |   18 +---
 dix/devices.c                            |    8 -
 dix/events.c                             |   83 +------------------
 dix/getevents.c                          |    7 +
 hw/xfree86/common/xf86VGAarbiter.c       |   65 ---------------
 hw/xfree86/common/xf86cmap.c             |    9 --
 hw/xfree86/modes/xf86Crtc.c              |   14 +--
 hw/xfree86/modes/xf86Crtc.h              |   26 ++++++
 hw/xfree86/modes/xf86RandR12.c           |   14 ++-
 hw/xfree86/os-support/solaris/sun_bell.c |    5 -
 hw/xquartz/GL/indirect.c                 |    2 
 hw/xquartz/GL/visualConfigs.c            |    3 
 hw/xquartz/X11Application.m              |   18 ++--
 hw/xquartz/mach-startup/bundle-main.c    |   30 +++++--
 hw/xquartz/mach-startup/stub.c           |    7 -
 hw/xquartz/pbproxy/x-selection.h         |    9 --
 hw/xquartz/quartzAudio.c                 |   35 ++++----
 hw/xquartz/quartzKeyboard.c              |    2 
 include/dix-config.h.in                  |    2 
 include/dix.h                            |    6 -
 include/eventconvert.h                   |    6 -
 record/record.c                          |  123 ++++++++++++++++-------------
 26 files changed, 262 insertions(+), 392 deletions(-)

New commits:
commit 1242e494c8abc25d51fa0f8120ba353ffcf7be08
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Fri Mar 5 09:27:13 2010 +1000

    xserver 1.7.5.901
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/configure.ac b/configure.ac
index 0726bd2..08e444e 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.7.5, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
-RELEASE_DATE="2010-02-16"
+AC_INIT([xorg-server], 1.7.5.901, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+RELEASE_DATE="2010-03-05"
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([dist-bzip2 foreign])
 AM_MAINTAINER_MODE
commit d023b78c739672894d6b8196d91129845614e369
Author: Keith Packard <keithp at keithp.com>
Date:   Thu Feb 25 11:37:05 2010 -0800

    Allow for missing or disabled compat_output
    
    When the compat output is missing (I don't think this is actually
    possible), or is disabled (and hence has no crtc), we would like to
    avoid dereferencing NULL pointers. This patch creates inline functions
    to extract the current compat output, crtc or associated RandR crtc
    structure, carefully checking for NULL pointers everywhere.
    
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>
    (cherry picked from commit de86a3a3448f0a55c1cd99aee9ea80070a589877)

diff --git a/hw/xfree86/common/xf86cmap.c b/hw/xfree86/common/xf86cmap.c
index edd5ae9..f60d96e 100644
--- a/hw/xfree86/common/xf86cmap.c
+++ b/hw/xfree86/common/xf86cmap.c
@@ -1001,8 +1001,7 @@ xf86ChangeGammaRamp(
     CMapLinkPtr pLink;
 
     if (xf86_crtc_supports_gamma(pScrn)) {
-	xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
-	RRCrtcPtr crtc = config->output[config->compat_output]->crtc->randr_crtc;
+	RRCrtcPtr crtc = xf86CompatRRCrtc(pScrn);
 
 	if (crtc) {
 	    if (crtc->gammaSize != size)
@@ -1076,8 +1075,7 @@ xf86GetGammaRampSize(ScreenPtr pScreen)
     CMapScreenPtr pScreenPriv;
 
     if (xf86_crtc_supports_gamma(pScrn)) {
-	xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
-	RRCrtcPtr crtc = config->output[config->compat_output]->crtc->randr_crtc;
+	RRCrtcPtr crtc = xf86CompatRRCrtc(pScrn);
 
 	if (crtc)
 	    return crtc->gammaSize;
@@ -1106,8 +1104,7 @@ xf86GetGammaRamp(
     int shift, sigbits;
 
     if (xf86_crtc_supports_gamma(pScrn)) {
-	xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
-	RRCrtcPtr crtc = config->output[config->compat_output]->crtc->randr_crtc;
+	RRCrtcPtr crtc = xf86CompatRRCrtc(pScrn);
 
 	if (crtc) {
 	    if (crtc->gammaSize < size)
diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 9370640..334fad4 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -2571,8 +2571,8 @@ xf86SetDesiredModes (ScrnInfoPtr scrn)
 	if (!crtc->enabled)
 	    continue;
 
-	if (config->output[config->compat_output]->crtc == crtc)
-	    output = config->output[config->compat_output];
+	if (xf86CompatOutput(scrn) && xf86CompatCrtc(scrn) == crtc)
+	    output = xf86CompatOutput(scrn);
 	else
 	{
 	    for (o = 0; o < config->num_output; o++)
@@ -2692,14 +2692,16 @@ xf86SetSingleMode (ScrnInfoPtr pScrn, DisplayModePtr desired, Rotation rotation)
 {
     xf86CrtcConfigPtr	config = XF86_CRTC_CONFIG_PTR(pScrn);
     Bool		ok = TRUE;
-    xf86OutputPtr	compat_output = config->output[config->compat_output];
-    DisplayModePtr	compat_mode;
+    xf86OutputPtr	compat_output;
+    DisplayModePtr	compat_mode = NULL;
     int			c;
 
     /*
      * Let the compat output drive the final mode selection
      */
-    compat_mode = xf86OutputFindClosestMode (compat_output, desired);
+    compat_output = xf86CompatOutput(pScrn);
+    if (compat_output)
+	compat_mode = xf86OutputFindClosestMode (compat_output, desired);
     if (compat_mode)
 	desired = compat_mode;
     
@@ -2894,7 +2896,7 @@ xf86OutputSetEDID (xf86OutputPtr output, xf86MonPtr edid_mon)
     }
 
     /* Set the DDC properties for the 'compat' output */
-    if (output == config->output[config->compat_output])
+    if (output == xf86CompatOutput(scrn))
         xf86SetDDCproperties(scrn, edid_mon);
 
 #ifdef RANDR_12_INTERFACE
diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h
index 9baa956..68a968c 100644
--- a/hw/xfree86/modes/xf86Crtc.h
+++ b/hw/xfree86/modes/xf86Crtc.h
@@ -689,6 +689,32 @@ extern _X_EXPORT int xf86CrtcConfigPrivateIndex;
 
 #define XF86_CRTC_CONFIG_PTR(p)	((xf86CrtcConfigPtr) ((p)->privates[xf86CrtcConfigPrivateIndex].ptr))
 
+static _X_INLINE xf86OutputPtr
+xf86CompatOutput(ScrnInfoPtr pScrn)
+{
+    xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+    return config->output[config->compat_output];
+}
+
+static _X_INLINE xf86CrtcPtr
+xf86CompatCrtc(ScrnInfoPtr pScrn)
+{
+    xf86OutputPtr compat_output = xf86CompatOutput(pScrn);
+    if (!compat_output)
+	return NULL;
+    return compat_output->crtc;
+}
+
+static _X_INLINE RRCrtcPtr
+xf86CompatRRCrtc(ScrnInfoPtr pScrn)
+{
+    xf86CrtcPtr	compat_crtc = xf86CompatCrtc(pScrn);
+    if (!compat_crtc)
+	return NULL;
+    return compat_crtc->randr_crtc;
+}
+
+
 /*
  * Initialize xf86CrtcConfig structure
  */
diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index 1fc63c4..7ba09b6 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -805,9 +805,10 @@ xf86RandR12CreateScreenResources (ScreenPtr pScreen)
 	}
 	else
 	{
-	    xf86OutputPtr   output = config->output[config->compat_output];
+	    xf86OutputPtr   output = xf86CompatOutput(pScrn);
 
-	    if (output->conf_monitor &&
+	    if (output &&
+		output->conf_monitor &&
 		(output->conf_monitor->mon_width  > 0 &&
 		 output->conf_monitor->mon_height > 0))
 	    {
@@ -1719,10 +1720,13 @@ xf86RandR12ChangeGamma(int scrnIndex, Gamma gamma)
 {
     CARD16 *points, *red, *green, *blue;
     ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-    xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
-    RRCrtcPtr crtc = config->output[config->compat_output]->crtc->randr_crtc;
-    int size = max(0, crtc->gammaSize);
+    RRCrtcPtr crtc = xf86CompatRRCrtc(pScrn);
+    int size;
 
+    if (!crtc)
+	return Success;
+
+    size = max(0, crtc->gammaSize);
     if (!size)
 	return Success;
 
commit 7def5cdf7dce0ace34e0befb3a9730e1bd607b61
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Mar 4 15:42:47 2010 +1000

    configure: move SELINUX_LIBS to XSERVER_SYS_LIBS
    
    All ddxs require linking against selinux if enabled.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Dan Nicholson <dbn.lists at gmail.com>
    Reviewed-by: Eamon Walsh <ewalsh at tycho.nsa.gov>
    Signed-off-by: Keith Packard <keithp at keithp.com>
    (cherry picked from commit 1c2abec479cfbac9aeadc121af0825d368317658)
    
    Conflicts:
    
    	configure.ac

diff --git a/configure.ac b/configure.ac
index 562111c..0726bd2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1326,7 +1326,7 @@ PKG_CHECK_MODULES([XSERVERLIBS], [$REQUIRED_LIBS])
 #
 XSERVER_CFLAGS="${XSERVERCFLAGS_CFLAGS} ${SHA1_CFLAGS}"
 XSERVER_LIBS="$DIX_LIB $CONFIG_LIB $MI_LIB $OS_LIB"
-XSERVER_SYS_LIBS="${XSERVERLIBS_LIBS} ${SYS_LIBS} ${LIBS} ${SHA1_LIB}"
+XSERVER_SYS_LIBS="${XSERVERLIBS_LIBS} ${SYS_LIBS} ${LIBS} ${SHA1_LIB} ${SELINUX_LIBS}"
 AC_SUBST([XSERVER_LIBS])
 AC_SUBST([XSERVER_SYS_LIBS])
 
@@ -1479,7 +1479,7 @@ if test "x$XORG" = xyes; then
 	AC_CHECK_FUNCS([pci_device_vgaarb_init])
 	LIBS=$SAVE_LIBS
 	CFLAGS=$SAVE_CFLAGS
-	XORG_SYS_LIBS="$XORG_SYS_LIBS $PCIACCESS_LIBS $DLOPEN_LIBS $GLX_SYS_LIBS $SELINUX_LIBS"
+	XORG_SYS_LIBS="$XORG_SYS_LIBS $PCIACCESS_LIBS $DLOPEN_LIBS $GLX_SYS_LIBS"
 	XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS"
 
 	case $host_os in
commit 402668251135b63b7329722397fe7885e065f27c
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Mar 4 15:41:53 2010 +1000

    configure: move libselinux requirement up to the common section.
    
    Let's have all version-specific requirements in one block.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Dan Nicholson <dbn.lists at gmail.com>
    Reviewed-by: Eamon Walsh <ewalsh at tycho.nsa.gov>
    Signed-off-by: Keith Packard <keithp at keithp.com>
    (cherry picked from commit cab99b947c66a42dbf8a906bdb02e23aa7cab519)
    
    Conflicts:
    
    	configure.ac

diff --git a/configure.ac b/configure.ac
index 558de87..562111c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -759,6 +759,7 @@ LIBXI="xi >= 1.2.99.1"
 LIBXTST="xtst >= 1.0.99.2"
 LIBPCIACCESS="pciaccess >= 0.8.0"
 LIBGLIB="glib-2.0 >= 2.16"
+LIBSELINUX="libselinux >= 2.0.86"
 
 dnl HAVE_DBUS is true if we actually have the D-Bus library, whereas
 dnl CONFIG_DBUS_API is true if we want to enable the D-Bus config
@@ -1014,7 +1015,7 @@ if test "x$XSELINUX" = xyes; then
 	fi
 	AC_CHECK_HEADERS([libaudit.h], [], AC_MSG_ERROR([SELinux extension requires audit system headers]))
 	AC_CHECK_LIB(audit, audit_open, [], AC_MSG_ERROR([SELinux extension requires audit system library]))
-	PKG_CHECK_MODULES([SELINUX], [libselinux >= 2.0.86])
+	PKG_CHECK_MODULES([SELINUX], $LIBSELINUX)
 	SELINUX_LIBS="$SELINUX_LIBS -laudit"
 	AC_DEFINE(XSELINUX, 1, [Build SELinux extension])
 fi
commit 351d11fd466fae731df860a6ff4cf50ad565f43f
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Feb 25 12:49:21 2010 +1000

    dix: Use DeliverGrabbedEvent for implicit passive grabs (#25400)
    
    A client requesting a GrabModeSync button grab, owner-events true, with only
    the ButtonRelease mask set would never receive the press event even if the
    grab window had the ButtonPress mask set.
    
    The protocol requires that if owner-events is true, then the delivery mask
    is the combination of the grab mask + the window event mask.
    
    DeliverGrabbedEvents does this already for us, checking first the delivery
    based on owner_events and then based on the grab mask. AFAICT, the device
    cannot enter the states FREEZE_BOTH_NEXT_EVENT or FREEZE_NEXT_EVENT that
    would be handled by DGE in any possible path here.
    
    Bonus point - CheckPassiveGrabsOnWindows suddenly becomes a lot lesss
    complicated.
    
    X.Org Bug 25400 <http://bugs.freedesktop.org/show_bug.cgi?id=25400>
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>
    (cherry picked from commit cf72b5437d2d620521279077a29c5df6d0fbb576)
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/events.c b/dix/events.c
index 02079be..c6aa4ab 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -3462,7 +3462,6 @@ CheckPassiveGrabsOnWindow(
     {
 	DeviceIntPtr	gdev;
 	XkbSrvInfoPtr	xkbi = NULL;
-	Mask		mask = 0;
 
 	gdev= grab->modifierDevice;
         if (grab->grabtype == GRABTYPE_CORE)
@@ -3515,10 +3514,6 @@ CheckPassiveGrabsOnWindow(
 	     (grab->confineTo->realized &&
 				BorderSizeNotEmpty(device, grab->confineTo))))
 	{
-            int rc, count = 0;
-            xEvent *xE = NULL;
-            xEvent core;
-
             event->corestate &= 0x1f00;
             event->corestate |= tempGrab.modifiersDetail.exact & (~0x1f00);
             grabinfo = &device->deviceGrab;
@@ -3565,62 +3560,8 @@ CheckPassiveGrabsOnWindow(
             }
 
 
-            if (match & CORE_MATCH)
-            {
-                rc = EventToCore((InternalEvent*)event, &core);
-                if (rc != Success)
-                {
-                    if (rc != BadMatch)
-                        ErrorF("[dix] %s: core conversion failed in CPGFW "
-                                "(%d, %d).\n", device->name, event->type, rc);
-                    continue;
-                }
-                xE = &core;
-                count = 1;
-                mask = grab->eventMask;
-            } else if (match & XI2_MATCH)
-            {
-                rc = EventToXI2((InternalEvent*)event, &xE);
-                if (rc != Success)
-                {
-                    if (rc != BadMatch)
-                        ErrorF("[dix] %s: XI2 conversion failed in CPGFW "
-                                "(%d, %d).\n", device->name, event->type, rc);
-                    continue;
-                }
-                count = 1;
-
-                /* FIXME: EventToXI2 returns NULL for enter events, so
-                 * dereferencing the event is bad. Internal event types are
-                 * aligned with core events, so the else clause is valid.
-                 * long-term we should use internal events for enter/focus
-                 * as well */
-                if (xE)
-                    mask = grab->xi2mask[device->id][((xGenericEvent*)xE)->evtype/8];
-                else if (event->type == XI_Enter || event->type == XI_FocusIn)
-                    mask = grab->xi2mask[device->id][event->type/8];
-            } else
-            {
-                rc = EventToXI((InternalEvent*)event, &xE, &count);
-                if (rc != Success)
-                {
-                    if (rc != BadMatch)
-                        ErrorF("[dix] %s: XI conversion failed in CPGFW "
-                                "(%d, %d).\n", device->name, event->type, rc);
-                    continue;
-                }
-                mask = grab->eventMask;
-            }
-
 	    (*grabinfo->ActivateGrab)(device, grab, currentTime, TRUE);
-
-            if (xE)
-            {
-                FixUpEventFromWindow(device, xE, grab->window, None, TRUE);
-
-                TryClientEvents(rClient(grab), device, xE, count, mask,
-                                       GetEventFilter(device, xE), grab);
-            }
+            DeliverGrabbedEvent((InternalEvent*)event, device, FALSE);
 
 	    if (grabinfo->sync.state == FROZEN_NO_EVENT)
 	    {
@@ -3630,8 +3571,6 @@ CheckPassiveGrabsOnWindow(
 		grabinfo->sync.state = FROZEN_WITH_EVENT;
             }
 
-            if (match & (XI_MATCH | XI2_MATCH))
-                xfree(xE); /* on core match xE == &core */
 	    return TRUE;
 	}
     }
commit 8f743f17ed0076d10d6c60fe8bdf3f54d3432ae5
Author: Alan Coopersmith <alan.coopersmith at sun.com>
Date:   Mon Feb 15 17:42:11 2010 -0800

    Solaris xf86OSRingBell() off-by-one error in filling iov[] array
    
    When generating sound buffers for /dev/audio bells, insert waveform
    for beep *or* silence, but not both, so we don't write one entry past
    the end of the iov buffer when the final bit of soundwave ends up in
    the final entry allocated in the iov array.
    
    Fixes OpenSolaris bug 6894890:
     http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6894890
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at sun.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Acked-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/os-support/solaris/sun_bell.c b/hw/xfree86/os-support/solaris/sun_bell.c
index 7f146ea..05d1749 100644
--- a/hw/xfree86/os-support/solaris/sun_bell.c
+++ b/hw/xfree86/os-support/solaris/sun_bell.c
@@ -126,14 +126,15 @@ xf86OSRingBell(int loudness, int pitch, int duration)
     iovcnt = 0;
 
     for (cnt = 0; cnt <= repeats; cnt++) {
-        iov[iovcnt].iov_base = (char *) samples;
-        iov[iovcnt++].iov_len = sizeof(samples);
         if (cnt == repeats) {
             /* Insert a bit of silence so that multiple beeps are distinct and
              * not compressed into a single tone.
              */
             iov[iovcnt].iov_base = (char *) silence;
             iov[iovcnt++].iov_len = sizeof(silence);
+        } else {
+            iov[iovcnt].iov_base = (char *) samples;
+            iov[iovcnt++].iov_len = sizeof(samples);
         }
         if ((iovcnt >= IOV_MAX) || (cnt == repeats)) {
             written = writev(audioFD, iov, iovcnt);
commit d35e08b6db911c404d7baf680dab30e8a6831bc4
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Feb 18 16:00:15 2010 +1000

    dix: remove now-erroneous comment about frozen slave devices.
    
    A direct grab on a slave device through XI2 detaches it, regardless of
    whether the grab is sync or async. So this comment doesn't apply to XI2
    anyway.
    
    For XI1, aside from your life being miserable already, it doesn't matter as
    XI1 does not have a concept of attachment. You can freeze a device and if
    you don't freeze _all_ other devices at the same time, the master device can
    still happily send events to the client.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Acked-by: Adam Jackson <ajax at redhat.com>
    (cherry picked from commit c0d941913199ed251fceab62fcf65437f6f9bd31)
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/events.c b/dix/events.c
index 4423c16..02079be 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -1414,11 +1414,6 @@ CheckGrabForSyncs(DeviceIntPtr thisDev, Bool thisMode, Bool otherMode)
 	    thisDev->deviceGrab.sync.other = NullGrab;
     }
 
-    /*
-        XXX: Direct slave grab won't freeze the paired master device.
-        The correct thing to do would be to freeze all SDs attached to the
-        paired master device.
-     */
     if (IsMaster(thisDev))
     {
         dev = GetPairedDevice(thisDev);
commit 11c27f261efc5b7a8594ad2de7bed4339f2a62ce
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon Feb 15 16:32:16 2010 +1000

    dix: try to ring the bell even if the current device doesn't have one. (#24503)
    
    Evdev devices do not have the bell proc set, but XTEST devices do. By
    exiting early, the bell only rings if the last keyboard used was the XTEST
    keyboard and hence the bell proc is still set on the master but not if an
    evdev keyboard was used last.
    
    The better approach here is to try to ring the bell on all devices attached
    to this master device in case one or more actually do produce an audible
    sound. That's also XKB's behaviour if XkbUseCoreKbd is specified as device
    identifier.
    
    X.Org Bug 24503 <http://bugs.freedesktop.org/show_bug.cgi?id=24503>
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    (cherry picked from commit 758f6971750ed507e64eee817d720a77181439f2)
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/devices.c b/dix/devices.c
index ef199b7..87b6dc7 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -2019,14 +2019,6 @@ ProcBell(ClientPtr client)
 	return BadValue;
     }
 
-    /* Seems like no keyboard actually has the BellProc set. Returning
-     * BadDevice (previous code) will make apps crash badly. The man pages
-     * doesn't say anything about a BadDevice being returned either.
-     * So just quietly do nothing and pretend everything has worked.
-     */
-    if (!keybd->kbdfeed->BellProc)
-        return Success;
-
     newpercent = (base * stuff->percent) / 100;
     if (stuff->percent < 0)
         newpercent = base + newpercent;
commit 1f96c0371845d5904b7d4c8fe71ee545b649faca
Author: Eamon Walsh <ewalsh at tycho.nsa.gov>
Date:   Wed Feb 3 15:40:47 2010 -0500

    xselinux: Bump extension minor version.
    
    Changes introduced in this version:
    	- 3 window-related requests now handle pixmaps also.
    
    Signed-off-by: Eamon Walsh <ewalsh at tycho.nsa.gov>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    (cherry picked from commit db4f676f25c6d8e58263d5151942be730592d444)

diff --git a/Xext/xselinux.h b/Xext/xselinux.h
index 6fa66d3..69c2437 100644
--- a/Xext/xselinux.h
+++ b/Xext/xselinux.h
@@ -25,7 +25,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 /* Extension info */
 #define SELINUX_EXTENSION_NAME		"SELinux"
 #define SELINUX_MAJOR_VERSION		1
-#define SELINUX_MINOR_VERSION		0
+#define SELINUX_MINOR_VERSION		1
 #define SELinuxNumberEvents		0
 #define SELinuxNumberErrors		0
 
commit dd9573d4086ca24c59a99a0a2019bf20c61b0f64
Author: Eamon Walsh <ewalsh at tycho.nsa.gov>
Date:   Wed Feb 3 15:38:57 2010 -0500

    xselinux: Rename window-related requests that now support pixmaps.
    
    Renamed requests:
    	SetWindowCreateContext -> SetDrawableCreateContext
    	GetWindowCreateContext -> GetDrawableCreateContext
    	GetWindowContext -> GetDrawableContext
    
    Signed-off-by: Eamon Walsh <ewalsh at tycho.nsa.gov>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/Xext/xselinux.c b/Xext/xselinux.c
index a1c1b83..b6bf67c 100644
--- a/Xext/xselinux.c
+++ b/Xext/xselinux.c
@@ -1355,7 +1355,7 @@ ProcSELinuxGetDeviceContext(ClientPtr client)
 }
 
 static int
-ProcSELinuxGetWindowContext(ClientPtr client)
+ProcSELinuxGetDrawableContext(ClientPtr client)
 {
     DrawablePtr pDraw;
     PrivateRec **privatePtr;
@@ -1620,12 +1620,12 @@ ProcSELinuxDispatch(ClientPtr client)
 	return ProcSELinuxSetDeviceContext(client);
     case X_SELinuxGetDeviceContext:
 	return ProcSELinuxGetDeviceContext(client);
-    case X_SELinuxSetWindowCreateContext:
+    case X_SELinuxSetDrawableCreateContext:
 	return ProcSELinuxSetCreateContext(client, CTX_WIN);
-    case X_SELinuxGetWindowCreateContext:
+    case X_SELinuxGetDrawableCreateContext:
 	return ProcSELinuxGetCreateContext(client, CTX_WIN);
-    case X_SELinuxGetWindowContext:
-	return ProcSELinuxGetWindowContext(client);
+    case X_SELinuxGetDrawableContext:
+	return ProcSELinuxGetDrawableContext(client);
     case X_SELinuxSetPropertyCreateContext:
 	return ProcSELinuxSetCreateContext(client, CTX_PRP);
     case X_SELinuxGetPropertyCreateContext:
@@ -1708,14 +1708,14 @@ SProcSELinuxGetDeviceContext(ClientPtr client)
 }
 
 static int
-SProcSELinuxGetWindowContext(ClientPtr client)
+SProcSELinuxGetDrawableContext(ClientPtr client)
 {
     REQUEST(SELinuxGetContextReq);
     int n;
 
     REQUEST_SIZE_MATCH(SELinuxGetContextReq);
     swapl(&stuff->id, n);
-    return ProcSELinuxGetWindowContext(client);
+    return ProcSELinuxGetDrawableContext(client);
 }
 
 static int
@@ -1782,12 +1782,12 @@ SProcSELinuxDispatch(ClientPtr client)
 	return SProcSELinuxSetDeviceContext(client);
     case X_SELinuxGetDeviceContext:
 	return SProcSELinuxGetDeviceContext(client);
-    case X_SELinuxSetWindowCreateContext:
+    case X_SELinuxSetDrawableCreateContext:
 	return SProcSELinuxSetCreateContext(client, CTX_WIN);
-    case X_SELinuxGetWindowCreateContext:
+    case X_SELinuxGetDrawableCreateContext:
 	return ProcSELinuxGetCreateContext(client, CTX_WIN);
-    case X_SELinuxGetWindowContext:
-	return SProcSELinuxGetWindowContext(client);
+    case X_SELinuxGetDrawableContext:
+	return SProcSELinuxGetDrawableContext(client);
     case X_SELinuxSetPropertyCreateContext:
 	return SProcSELinuxSetCreateContext(client, CTX_PRP);
     case X_SELinuxGetPropertyCreateContext:
diff --git a/Xext/xselinux.h b/Xext/xselinux.h
index fef207a..6fa66d3 100644
--- a/Xext/xselinux.h
+++ b/Xext/xselinux.h
@@ -35,9 +35,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define X_SELinuxGetDeviceCreateContext		2
 #define X_SELinuxSetDeviceContext		3
 #define X_SELinuxGetDeviceContext		4
-#define X_SELinuxSetWindowCreateContext		5
-#define X_SELinuxGetWindowCreateContext		6
-#define X_SELinuxGetWindowContext		7
+#define X_SELinuxSetDrawableCreateContext	5
+#define X_SELinuxGetDrawableCreateContext	6
+#define X_SELinuxGetDrawableContext		7
 #define X_SELinuxSetPropertyCreateContext	8
 #define X_SELinuxGetPropertyCreateContext	9
 #define X_SELinuxSetPropertyUseContext		10
commit 7cec236a03917841131941ce97bd1dfd4a027327
Author: Eamon Walsh <ewalsh at tycho.nsa.gov>
Date:   Wed Feb 3 15:08:40 2010 -0500

    xselinux: Allow GetWindowContext to be used for pixmaps as well.
    
    Signed-off-by: Eamon Walsh <ewalsh at tycho.nsa.gov>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/Xext/xselinux.c b/Xext/xselinux.c
index 4382c21..a1c1b83 100644
--- a/Xext/xselinux.c
+++ b/Xext/xselinux.c
@@ -1357,18 +1357,26 @@ ProcSELinuxGetDeviceContext(ClientPtr client)
 static int
 ProcSELinuxGetWindowContext(ClientPtr client)
 {
-    WindowPtr pWin;
+    DrawablePtr pDraw;
+    PrivateRec **privatePtr;
     SELinuxObjectRec *obj;
     int rc;
 
     REQUEST(SELinuxGetContextReq);
     REQUEST_SIZE_MATCH(SELinuxGetContextReq);
 
-    rc = dixLookupWindow(&pWin, stuff->id, client, DixGetAttrAccess);
+    rc = dixLookupDrawable(&pDraw, stuff->id, client,
+			   M_WINDOW | M_DRAWABLE_PIXMAP,
+			   DixGetAttrAccess);
     if (rc != Success)
 	return rc;
 
-    obj = dixLookupPrivate(&pWin->devPrivates, objectKey);
+    if (pDraw->type == M_DRAWABLE_PIXMAP)
+	privatePtr = &((PixmapPtr)pDraw)->devPrivates;
+    else
+	privatePtr = &((WindowPtr)pDraw)->devPrivates;
+
+    obj = dixLookupPrivate(privatePtr, objectKey);
     return SELinuxSendContextReply(client, obj->sid);
 }
 
commit 1b6f498b84de7f79de735b004b8e16b9a31d228c
Author: Eamon Walsh <ewalsh at tycho.nsa.gov>
Date:   Wed Jan 6 12:52:51 2010 -0500

    xselinux: Remove reference counting calls for SID objects.
    
    Starting with libselinux 2.0.86, SID objects are no longer
    reference counted and the sidput() and sidget() calls are no-ops.
    
    Signed-off-by: Eamon Walsh <ewalsh at tycho.nsa.gov>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/Xext/xselinux.c b/Xext/xselinux.c
index 60a18d1..4382c21 100644
--- a/Xext/xselinux.c
+++ b/Xext/xselinux.c
@@ -112,9 +112,6 @@ typedef struct {
 /* labeling handle */
 static struct selabel_handle *label_hnd;
 
-/* whether AVC is active */
-static int avc_active;
-
 /* atoms for window label properties */
 static Atom atom_ctx;
 static Atom atom_client_ctx;
@@ -238,20 +235,17 @@ SELinuxSelectionToSID(Atom selection, SELinuxSubjectRec *subj,
 
     /* Check for an override context next */
     if (subj->sel_use_sid) {
-	sidget(tsid = subj->sel_use_sid);
+	tsid = subj->sel_use_sid;
 	goto out;
     }
 
-    sidget(tsid = obj->sid);
+    tsid = obj->sid;
 
     /* Polyinstantiate if necessary to obtain the final SID */
-    if (obj->poly) {
-	sidput(tsid);
-	if (avc_compute_member(subj->sid, obj->sid,
-			       SECCLASS_X_SELECTION, &tsid) < 0) {
-	    ErrorF("SELinux: a compute_member call failed!\n");
-	    return BadValue;
-	}
+    if (obj->poly && avc_compute_member(subj->sid, obj->sid,
+					SECCLASS_X_SELECTION, &tsid) < 0) {
+	ErrorF("SELinux: a compute_member call failed!\n");
+	return BadValue;
     }
 out:
     *sid_rtn = tsid;
@@ -278,7 +272,7 @@ SELinuxPropertyToSID(Atom property, SELinuxSubjectRec *subj,
 
     /* Check for an override context next */
     if (subj->prp_use_sid) {
-	sidget(tsid = subj->prp_use_sid);
+	tsid = subj->prp_use_sid;
 	goto out;
     }
 
@@ -295,10 +289,8 @@ SELinuxPropertyToSID(Atom property, SELinuxSubjectRec *subj,
 	if (avc_compute_member(subj->sid, tsid2,
 			       SECCLASS_X_PROPERTY, &tsid) < 0) {
 	    ErrorF("SELinux: a compute_member call failed!\n");
-	    sidput(tsid2);
 	    return BadValue;
 	}
-	sidput(tsid2);
     }
 out:
     *sid_rtn = tsid;
@@ -438,9 +430,7 @@ SELinuxLabelClient(ClientPtr client)
     security_context_t ctx;
 
     subj = dixLookupPrivate(&client->devPrivates, subjectKey);
-    sidput(subj->sid);
     obj = dixLookupPrivate(&client->devPrivates, objectKey);
-    sidput(obj->sid);
 
     /* Try to get a context from the socket */
     if (fd < 0 || getpeercon_raw(fd, &ctx) < 0) {
@@ -484,7 +474,7 @@ finish:
 	FatalError("SELinux: client %d: context_to_sid_raw(%s) failed\n",
 		   client->index, ctx);
 
-    sidget(obj->sid = subj->sid);
+    obj->sid = subj->sid;
     freecon(ctx);
 }
 
@@ -505,7 +495,6 @@ SELinuxLabelInitial(void)
     subj = dixLookupPrivate(&serverClient->devPrivates, subjectKey);
     obj = dixLookupPrivate(&serverClient->devPrivates, objectKey);
     subj->privileged = 1;
-    sidput(subj->sid);
 
     /* Use the context of the X server process for the serverClient */
     if (getcon_raw(&ctx) < 0)
@@ -515,7 +504,7 @@ SELinuxLabelInitial(void)
     if (avc_context_to_sid_raw(ctx, &subj->sid) < 0)
 	FatalError("SELinux: serverClient: context_to_sid(%s) failed\n", ctx);
 
-    sidget(obj->sid = subj->sid);
+    obj->sid = subj->sid;
     freecon(ctx);
 
     srec.client = serverClient;
@@ -545,7 +534,7 @@ SELinuxLabelResource(XaceResourceAccessRec *rec, SELinuxSubjectRec *subj,
 
     /* Check for a create context */
     if (rec->rtype & RC_DRAWABLE && subj->win_create_sid) {
-	sidget(obj->sid = subj->win_create_sid);
+	obj->sid = subj->win_create_sid;
 	return Success;
     }
 
@@ -673,17 +662,14 @@ SELinuxDevice(CallbackListPtr *pcbl, pointer unused, pointer calldata)
 	SELinuxSubjectRec *dsubj;
 	dsubj = dixLookupPrivate(&rec->dev->devPrivates, subjectKey);
 
-	sidput(dsubj->sid);
-	sidput(obj->sid);
-
 	if (subj->dev_create_sid) {
 	    /* Label the device with the create context */
-	    sidget(obj->sid = subj->dev_create_sid);
-	    sidget(dsubj->sid = subj->dev_create_sid);
+	    obj->sid = subj->dev_create_sid;
+	    dsubj->sid = subj->dev_create_sid;
 	} else {
 	    /* Label the device directly with the process SID */
-	    sidget(obj->sid = subj->sid);
-	    sidget(dsubj->sid = subj->sid);
+	    obj->sid = subj->sid;
+	    dsubj->sid = subj->sid;
 	}
     }
 
@@ -807,8 +793,6 @@ SELinuxExtension(CallbackListPtr *pcbl, pointer unused, pointer calldata)
 	    return;
 	}
 
-	sidput(obj->sid);
-
 	/* Perform a transition to obtain the final SID */
 	if (avc_compute_create(serv->sid, sid, SECCLASS_X_EXTENSION,
 			       &obj->sid) < 0) {
@@ -846,7 +830,6 @@ SELinuxSelection(CallbackListPtr *pcbl, pointer unused, pointer calldata)
 
     /* If this is a new object that needs labeling, do it now */
     if (access_mode & DixCreateAccess) {
-	sidput(obj->sid);
 	rc = SELinuxSelectionToSID(name, subj, &obj->sid, &obj->poly);
 	if (rc != Success)
 	    obj->sid = unlabeled_sid;
@@ -864,7 +847,6 @@ SELinuxSelection(CallbackListPtr *pcbl, pointer unused, pointer calldata)
 		break;
 	    obj = dixLookupPrivate(&pSel->devPrivates, objectKey);
 	}
-	sidput(tsid);
 	
 	if (pSel)
 	    *rec->ppSel = pSel;
@@ -883,11 +865,10 @@ SELinuxSelection(CallbackListPtr *pcbl, pointer unused, pointer calldata)
     /* Label the content (advisory only) */
     if (access_mode & DixSetAttrAccess) {
 	data = dixLookupPrivate(&pSel->devPrivates, dataKey);
-	sidput(data->sid);
 	if (subj->sel_create_sid)
-	    sidget(data->sid = subj->sel_create_sid);
+	    data->sid = subj->sel_create_sid;
 	else
-	    sidget(data->sid = obj->sid);
+	    data->sid = obj->sid;
     }
 }
 
@@ -912,7 +893,6 @@ SELinuxProperty(CallbackListPtr *pcbl, pointer unused, pointer calldata)
 
     /* If this is a new object that needs labeling, do it now */
     if (rec->access_mode & DixCreateAccess) {
-	sidput(obj->sid);
 	rc = SELinuxPropertyToSID(name, subj, &obj->sid, &obj->poly);
 	if (rc != Success) {
 	    rec->status = rc;
@@ -931,7 +911,6 @@ SELinuxProperty(CallbackListPtr *pcbl, pointer unused, pointer calldata)
 		break;
 	    obj = dixLookupPrivate(&pProp->devPrivates, objectKey);
 	}
-	sidput(tsid);
 
 	if (pProp)
 	    *rec->ppProp = pProp;
@@ -950,11 +929,10 @@ SELinuxProperty(CallbackListPtr *pcbl, pointer unused, pointer calldata)
     /* Label the content (advisory only) */
     if (rec->access_mode & DixWriteAccess) {
 	data = dixLookupPrivate(&pProp->devPrivates, dataKey);
-	sidput(data->sid);
 	if (subj->prp_create_sid)
-	    sidget(data->sid = subj->prp_create_sid);
+	    data->sid = subj->prp_create_sid;
 	else
-	    sidget(data->sid = obj->sid);
+	    data->sid = obj->sid;
     }
 }
 
@@ -1031,8 +1009,6 @@ SELinuxScreen(CallbackListPtr *pcbl, pointer is_saver, pointer calldata)
 
     /* If this is a new object that needs labeling, do it now */
     if (access_mode & DixCreateAccess) {
-	sidput(obj->sid);
-
 	/* Perform a transition to obtain the final SID */
 	if (avc_compute_create(subj->sid, subj->sid, SECCLASS_X_SCREEN,
 			       &obj->sid) < 0) {
@@ -1164,7 +1140,6 @@ SELinuxSubjectInit(CallbackListPtr *pcbl, pointer unused, pointer calldata)
     PrivateCallbackRec *rec = calldata;
     SELinuxSubjectRec *subj = *rec->value;
 
-    sidget(unlabeled_sid);
     subj->sid = unlabeled_sid;
 
     avc_entry_ref_init(&subj->aeref);
@@ -1177,14 +1152,6 @@ SELinuxSubjectFree(CallbackListPtr *pcbl, pointer unused, pointer calldata)
     SELinuxSubjectRec *subj = *rec->value;
 
     xfree(subj->command);
-
-    if (avc_active) {
-	sidput(subj->sid);
-	sidput(subj->dev_create_sid);
-	sidput(subj->win_create_sid);
-	sidput(subj->sel_create_sid);
-	sidput(subj->prp_create_sid);
-    }
 }
 
 static void
@@ -1193,20 +1160,9 @@ SELinuxObjectInit(CallbackListPtr *pcbl, pointer unused, pointer calldata)
     PrivateCallbackRec *rec = calldata;
     SELinuxObjectRec *obj = *rec->value;
 
-    sidget(unlabeled_sid);
     obj->sid = unlabeled_sid;
 }
 
-static void
-SELinuxObjectFree(CallbackListPtr *pcbl, pointer unused, pointer calldata)
-{
-    PrivateCallbackRec *rec = calldata;
-    SELinuxObjectRec *obj = *rec->value;
-
-    if (avc_active)
-	sidput(obj->sid);
-}
-
 
 /*
  * Extension Dispatch
@@ -1310,7 +1266,6 @@ ProcSELinuxSetCreateContext(ClientPtr client, unsigned offset)
 
     ptr = dixLookupPrivate(privPtr, subjectKey);
     pSid = (security_id_t *)(ptr + offset);
-    sidput(*pSid);
     *pSid = NULL;
 
     rc = Success;
@@ -1371,11 +1326,9 @@ ProcSELinuxSetDeviceContext(ClientPtr client)
     }
 
     subj = dixLookupPrivate(&dev->devPrivates, subjectKey);
-    sidput(subj->sid);
     subj->sid = sid;
     obj = dixLookupPrivate(&dev->devPrivates, objectKey);
-    sidput(obj->sid);
-    sidget(obj->sid = sid);
+    obj->sid = sid;
 
     rc = Success;
 out:
@@ -1912,7 +1865,6 @@ SELinuxResetProc(ExtensionEntry *extEntry)
     RemoveGeneralSocket(netlink_fd);
 
     avc_destroy();
-    avc_active = 0;
 
     /* Free local state */
     xfree(knownAtoms);
@@ -1981,7 +1933,6 @@ SELinuxExtensionInit(INITARGS)
 
     if (avc_open(&avc_option, 1) < 0)
 	FatalError("SELinux: Couldn't initialize SELinux userspace AVC\n");
-    avc_active = 1;
 
     label_hnd = selabel_open(SELABEL_CTX_X, &selabel_option, 1);
     if (!label_hnd)
@@ -2021,9 +1972,7 @@ SELinuxExtensionInit(INITARGS)
     ret &= dixRegisterPrivateInitFunc(subjectKey, SELinuxSubjectInit, NULL);
     ret &= dixRegisterPrivateDeleteFunc(subjectKey, SELinuxSubjectFree, NULL);
     ret &= dixRegisterPrivateInitFunc(objectKey, SELinuxObjectInit, NULL);
-    ret &= dixRegisterPrivateDeleteFunc(objectKey, SELinuxObjectFree, NULL);
     ret &= dixRegisterPrivateInitFunc(dataKey, SELinuxObjectInit, NULL);
-    ret &= dixRegisterPrivateDeleteFunc(dataKey, SELinuxObjectFree, NULL);
 
     ret &= AddCallback(&ClientStateCallback, SELinuxClientState, NULL);
     ret &= AddCallback(&ResourceStateCallback, SELinuxResourceState, NULL);
commit c030ec32b6418e6258b380c0e29971be882a84d4
Author: Eamon Walsh <ewalsh at tycho.nsa.gov>
Date:   Wed Oct 21 19:28:26 2009 -0400

    libselinux now has a pkgconfig file.  Use it.
    
    Also remove HAVE_NETLINK_AVC_ACQUIRE_FD tests, because we now
    require a version of libselinux that has it.
    
    Signed-off-by: Eamon Walsh <ewalsh at tycho.nsa.gov>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/Xext/xselinux.c b/Xext/xselinux.c
index a047a00..60a18d1 100644
--- a/Xext/xselinux.c
+++ b/Xext/xselinux.c
@@ -1862,7 +1862,6 @@ SProcSELinuxDispatch(ClientPtr client)
     }
 }
 
-#ifdef HAVE_AVC_NETLINK_ACQUIRE_FD
 static int netlink_fd;
 
 static void
@@ -1876,7 +1875,6 @@ SELinuxWakeupHandler(void *data, int err, void *read_mask)
     if (FD_ISSET(netlink_fd, (fd_set *)read_mask))
         avc_netlink_check_nb();
 }
-#endif
 
 
 /*
@@ -1908,12 +1906,10 @@ SELinuxResetProc(ExtensionEntry *extEntry)
     label_hnd = NULL;
 
     audit_close(audit_fd);
-#ifdef HAVE_AVC_NETLINK_ACQUIRE_FD
     avc_netlink_release_fd();
     RemoveBlockAndWakeupHandlers(SELinuxBlockHandler, SELinuxWakeupHandler,
                                  NULL);
     RemoveGeneralSocket(netlink_fd);
-#endif
 
     avc_destroy();
     avc_active = 0;
@@ -2016,12 +2012,10 @@ SELinuxExtensionInit(INITARGS)
     if (atom_client_ctx == BAD_RESOURCE)
 	FatalError("SELinux: Failed to create atom\n");
 
-#ifdef HAVE_AVC_NETLINK_ACQUIRE_FD
     netlink_fd = avc_netlink_acquire_fd();
     AddGeneralSocket(netlink_fd);
     RegisterBlockAndWakeupHandlers(SELinuxBlockHandler, SELinuxWakeupHandler,
                                    NULL);
-#endif
 
     /* Register callbacks */
     ret &= dixRegisterPrivateInitFunc(subjectKey, SELinuxSubjectInit, NULL);
diff --git a/configure.ac b/configure.ac
index 8cb9048..558de87 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1012,16 +1012,11 @@ if test "x$XSELINUX" = xyes; then
 	if test "x$XACE" != xyes; then
 		AC_MSG_ERROR([cannot build SELinux extension without X-ACE])
 	fi
-	AC_CHECK_HEADERS([selinux/selinux.h selinux/avc.h], [], AC_MSG_ERROR([SELinux include files not found]))
-	AC_CHECK_LIB(selinux, avc_init, [], AC_MSG_ERROR([SELinux library not found])) 
 	AC_CHECK_HEADERS([libaudit.h], [], AC_MSG_ERROR([SELinux extension requires audit system headers]))
 	AC_CHECK_LIB(audit, audit_open, [], AC_MSG_ERROR([SELinux extension requires audit system library]))
-        AC_CHECK_DECL(avc_netlink_acquire_fd,
-                      [AC_DEFINE(HAVE_AVC_NETLINK_ACQUIRE_FD, 1, "Have avc_netlink_acquire_fd")],
-                      [],
-                      [#include <selinux/avc.h>])
+	PKG_CHECK_MODULES([SELINUX], [libselinux >= 2.0.86])
+	SELINUX_LIBS="$SELINUX_LIBS -laudit"
 	AC_DEFINE(XSELINUX, 1, [Build SELinux extension])
-	SELINUX_LIB="-lselinux -laudit"
 fi
 
 AM_CONDITIONAL(XCSECURITY, [test "x$XCSECURITY" = xyes])
@@ -1483,7 +1478,7 @@ if test "x$XORG" = xyes; then
 	AC_CHECK_FUNCS([pci_device_vgaarb_init])
 	LIBS=$SAVE_LIBS
 	CFLAGS=$SAVE_CFLAGS
-	XORG_SYS_LIBS="$XORG_SYS_LIBS $PCIACCESS_LIBS $DLOPEN_LIBS $GLX_SYS_LIBS $SELINUX_LIB"
+	XORG_SYS_LIBS="$XORG_SYS_LIBS $PCIACCESS_LIBS $DLOPEN_LIBS $GLX_SYS_LIBS $SELINUX_LIBS"
 	XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS"
 
 	case $host_os in
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index 798d9e7..6e450b6 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -431,6 +431,4 @@
 #include "dix-config-apple-verbatim.h"
 #endif
 
-#undef HAVE_AVC_NETLINK_ACQUIRE_FD
-
 #endif /* _DIX_CONFIG_H_ */
commit c8dd981c7f67d26850fad8c8a01f5de9850aa454
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Feb 18 15:49:09 2010 +1000

    Xi: assume BadMode for non-BadMatch errors returned from SetDeviceMode.
    
    The XI protocol spec only allows for two errors on the SetDeviceMode
    requests: BadMatch or BadMode. BadMode however is a dynamically assigned
    extension error and the driver doesn't have access to the actual error
    number. Hence, if a SetDeviceMode driver returns an error other than
    BadMatch, assume BadMode.
    
    The two exceptions are BadAlloc and BadImplementations, pass these on to the
    client (any request is allowed to return either of those).
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Dan Nicholson <dbn.lists at gmail.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>
    (cherry picked from commit e40ba5798c367bec584f6437b23d2c5f801fd013)
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/Xi/setmode.c b/Xi/setmode.c
index 51e5767..ce2ad47 100644
--- a/Xi/setmode.c
+++ b/Xi/setmode.c
@@ -112,7 +112,17 @@ ProcXSetDeviceMode(ClientPtr client)
     if (rep.status == Success)
 	dev->valuator->mode = stuff->mode;
     else if (rep.status != AlreadyGrabbed)
+    {
+	switch(rep.status) {
+	    case BadMatch:
+	    case BadImplementation:
+	    case BadAlloc:
+		break;
+	    default:
+		rep.status = BadMode;
+	}
 	return rep.status;
+    }
 
     WriteReplyToClient(client, sizeof(xSetDeviceModeReply), &rep);
     return Success;
commit 5ac8298469cd4d5e56ef7fc41af4878b88706b28
Author: Chris Dekter <cdekter at gmail.com>
Date:   Thu Feb 11 16:34:09 2010 +1000

    Re-enable RECORD extension.
    
    RECORD was disabled during the switch to internal events. This patch
    modifies the record callback to work with internal events instead of
    xEvents. The InternalEvents are converted to core/Xi events as needed.
    
    Since record is a loadable extension, the EventTo* calls must be externed.
    
    Signed-off-by: Chris Dekter <cdekter at gmail.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    (cherry picked from commit 122fc0e7a0712df4ec2bd9ca6773f90bcd2095cf)
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/Xi/exevents.c b/Xi/exevents.c
index ee32ba8..a63b65b 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1051,16 +1051,19 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
             break;
     }
 
-#if 0
-    /* FIXME: I'm broken. Please fix me. Thanks */
     if (DeviceEventCallback) {
 	DeviceEventInfoRec eventinfo;
+	SpritePtr pSprite = device->spriteInfo->sprite;
 
-	eventinfo.events = (xEventPtr) xE;
-	eventinfo.count = count;
+	/* see comment in EnqueueEvents regarding the next three lines */
+	if (ev->any.type == ET_Motion)
+	    ev->device_event.root = WindowTable[pSprite->hotPhys.pScreen->myNum]->drawable.id;
+
+	eventinfo.device = device;
+	eventinfo.event = ev;
 	CallCallbacks(&DeviceEventCallback, (pointer) & eventinfo);
     }
-#endif
+
     grab = device->deviceGrab.grab;
 
     switch(event->type)
diff --git a/dix/events.c b/dix/events.c
index e24e0c5..4423c16 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -1131,11 +1131,10 @@ EnqueueEvent(InternalEvent *ev, DeviceIntPtr device)
         event->type == ET_KeyRelease)
 	AccessXCancelRepeatKey(device->key->xkbInfo, event->detail.key);
 
-#if 0
-        /* FIXME: I'm broken now. Please fix me. */
     if (DeviceEventCallback)
     {
 	DeviceEventInfoRec eventinfo;
+
 	/*  The RECORD spec says that the root window field of motion events
 	 *  must be valid.  At this point, it hasn't been filled in yet, so
 	 *  we do it here.  The long expression below is necessary to get
@@ -1145,14 +1144,14 @@ EnqueueEvent(InternalEvent *ev, DeviceIntPtr device)
 	 *  the data that GetCurrentRootWindow relies on hasn't been
 	 *  updated yet.
 	 */
-	if (xE->u.u.type == DeviceMotionNotify)
-	    XE_KBPTR.root =
-		WindowTable[pSprite->hotPhys.pScreen->myNum]->drawable.id;
-	eventinfo.events = xE;
-	eventinfo.count = nevents;
+	if (ev->any.type == ET_Motion)
+	    ev->device_event.root = WindowTable[pSprite->hotPhys.pScreen->myNum]->drawable.id;
+
+	eventinfo.event = ev;
+	eventinfo.device = device;
 	CallCallbacks(&DeviceEventCallback, (pointer)&eventinfo);
     }
-#endif
+
     if (event->type == ET_Motion)
     {
 #ifdef PANORAMIX
diff --git a/include/dix.h b/include/dix.h
index 9fd2ed8..8bd52b6 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -581,8 +581,8 @@ typedef struct {
 extern _X_EXPORT CallbackListPtr DeviceEventCallback;
 
 typedef struct {
-    xEventPtr events;
-    int count;
+    InternalEvent *event;
+    DeviceIntPtr device;
 } DeviceEventInfoRec;
 
 extern int XItoCoreType(int xi_type);
@@ -590,7 +590,7 @@ extern Bool DevHasCursor(DeviceIntPtr pDev);
 extern Bool _X_EXPORT IsPointerDevice( DeviceIntPtr dev);
 extern Bool _X_EXPORT IsKeyboardDevice(DeviceIntPtr dev);
 extern Bool IsPointerEvent(InternalEvent *event);
-extern Bool IsMaster(DeviceIntPtr dev);
+extern _X_EXPORT Bool IsMaster(DeviceIntPtr dev);
 
 extern _X_HIDDEN void CopyKeyClass(DeviceIntPtr device, DeviceIntPtr master);
 extern _X_HIDDEN int CorePointerProc(DeviceIntPtr dev, int what);
diff --git a/include/eventconvert.h b/include/eventconvert.h
index 277a6c4..b1196a0 100644
--- a/include/eventconvert.h
+++ b/include/eventconvert.h
@@ -30,9 +30,9 @@
 
 #define FP1616(integral, frac) ((integral) * (1 << 16) + (frac) * (1 << 16))
 
-_X_INTERNAL int EventToCore(InternalEvent *event, xEvent *core);
-_X_INTERNAL int EventToXI(InternalEvent *ev, xEvent **xi, int *count);
-_X_INTERNAL int EventToXI2(InternalEvent *ev, xEvent **xi);
+_X_EXPORT int EventToCore(InternalEvent *event, xEvent *core);
+_X_EXPORT int EventToXI(InternalEvent *ev, xEvent **xi, int *count);
+_X_EXPORT int EventToXI2(InternalEvent *ev, xEvent **xi);
 _X_INTERNAL int GetCoreType(InternalEvent* ev);
 _X_INTERNAL int GetXIType(InternalEvent* ev);
 _X_INTERNAL int GetXI2Type(InternalEvent* ev);
diff --git a/record/record.c b/record/record.c
index b94b4ae..f092e34 100644
--- a/record/record.c
+++ b/record/record.c
@@ -42,6 +42,8 @@ and Jim Haggerty of Metheus.
 #include "set.h"
 #include "swaprep.h"
 #include "inputstr.h"
+#include "eventconvert.h"
+
 
 #include <stdio.h>
 #include <assert.h>
@@ -139,7 +141,8 @@ static int RecordDeleteContext(
     XID /*id*/
 );
 
-
+void RecordExtensionInit(void);
+
 /***************************************************************************/
 
 /* client private stuff */
@@ -727,6 +730,59 @@ RecordADeliveredEventOrError(CallbackListPtr *pcbl, pointer nulldata, pointer ca
 } /* RecordADeliveredEventOrError */
 
 
+static void
+RecordSendProtocolEvents(RecordClientsAndProtocolPtr pRCAP,
+			RecordContextPtr pContext,
+			xEvent* pev, int count)
+{
+    int ev; /* event index */
+
+    for (ev = 0; ev < count; ev++, pev++)
+    {
+	if (RecordIsMemberOfSet(pRCAP->pDeviceEventSet,
+		    pev->u.u.type & 0177))
+	{
+	    xEvent swappedEvent;
+	    xEvent *pEvToRecord = pev;
+#ifdef PANORAMIX
+	    xEvent shiftedEvent;
+
+	    if (!noPanoramiXExtension &&
+		    (pev->u.u.type == MotionNotify ||
+		     pev->u.u.type == ButtonPress ||
+		     pev->u.u.type == ButtonRelease ||
+		     pev->u.u.type == KeyPress ||
+		     pev->u.u.type == KeyRelease)) {
+		int scr = XineramaGetCursorScreen(inputInfo.pointer);
+		memcpy(&shiftedEvent, pev, sizeof(xEvent));
+		shiftedEvent.u.keyButtonPointer.rootX +=
+		    panoramiXdataPtr[scr].x -
+		    panoramiXdataPtr[0].x;
+		shiftedEvent.u.keyButtonPointer.rootY +=
+		    panoramiXdataPtr[scr].y -
+		    panoramiXdataPtr[0].y;
+		pEvToRecord = &shiftedEvent;
+	    }
+#endif /* PANORAMIX */
+
+	    if (pContext->pRecordingClient->swapped)
+	    {
+		(*EventSwapVector[pEvToRecord->u.u.type & 0177])
+		    (pEvToRecord, &swappedEvent);
+		pEvToRecord = &swappedEvent;
+	    }
+
+	    RecordAProtocolElement(pContext, NULL,
+		    XRecordFromServer,  pEvToRecord, SIZEOF(xEvent), 0);
+	    /* make sure device events get flushed in the absence
+	     * of other client activity
+	     */
+	    SetCriticalOutputPending();
+	}
+    } /* end for each event */
+
+} /* RecordADeviceEvent */
+
 /* RecordADeviceEvent
  *
  * Arguments:
@@ -756,55 +812,24 @@ RecordADeviceEvent(CallbackListPtr *pcbl, pointer nulldata, pointer calldata)
 	{
 	    if (pRCAP->pDeviceEventSet)
 	    {
-		int ev; /* event index */
-		xEvent *pev = pei->events;
-		for (ev = 0; ev < pei->count; ev++, pev++)
-		{
-		    if (RecordIsMemberOfSet(pRCAP->pDeviceEventSet,
-					    pev->u.u.type & 0177))
-		    {
-		        xEvent swappedEvent;
-		        xEvent *pEvToRecord = pev;
-#ifdef PANORAMIX
-		        xEvent shiftedEvent;
-
-			if (!noPanoramiXExtension &&
-			    (pev->u.u.type == MotionNotify ||
-			     pev->u.u.type == ButtonPress ||
-			     pev->u.u.type == ButtonRelease ||
-			     pev->u.u.type == KeyPress ||
-			     pev->u.u.type == KeyRelease)) {
-				int scr = XineramaGetCursorScreen(inputInfo.pointer);
-				memcpy(&shiftedEvent, pev, sizeof(xEvent));
-				shiftedEvent.u.keyButtonPointer.rootX +=
-				    panoramiXdataPtr[scr].x - 
-					panoramiXdataPtr[0].x;
-				shiftedEvent.u.keyButtonPointer.rootY +=
-				    panoramiXdataPtr[scr].y -
-					panoramiXdataPtr[0].y;
-				pEvToRecord = &shiftedEvent;
-			}
-#endif /* PANORAMIX */
+		int count;
+		xEvent *xi_events = NULL;
 
-			if (pContext->pRecordingClient->swapped)
-			{
-			    (*EventSwapVector[pEvToRecord->u.u.type & 0177])
-				(pEvToRecord, &swappedEvent);
-			    pEvToRecord = &swappedEvent;
-			}
+		/* TODO check return values */
+		if (IsMaster(pei->device))
+		{
+		    xEvent xE;
+		    EventToCore(pei->event, &xE);
+		    RecordSendProtocolEvents(pRCAP, pContext, &xE, 1);
+		}
 
-			RecordAProtocolElement(pContext, NULL,
-			   XRecordFromServer,  pEvToRecord, SIZEOF(xEvent), 0);
-			/* make sure device events get flushed in the absence
-			 * of other client activity
-			 */
-			SetCriticalOutputPending();
-		    }
-		} /* end for each event */
+		EventToXI(pei->event, &xi_events, &count);
+		RecordSendProtocolEvents(pRCAP, pContext, xi_events, count);
+		xfree(xi_events);
 	    } /* end this RCAP selects device events */
 	} /* end for each RCAP on this context */
     } /* end for each enabled context */
-} /* RecordADeviceEvent */
+}
 
 
 /* RecordFlushAllContexts
@@ -2866,13 +2891,6 @@ RecordCloseDown(ExtensionEntry *extEntry)
 void 
 RecordExtensionInit(void)
 {
-    /* FIXME Record is currently broken. Dont initialize it so that clients
-     * that require it can bail out correctly rather than waiting for stuff
-     * that'll never happen */
-    ErrorF("record: RECORD extension enabled at configure time.\n");
-    ErrorF("record: This extension is known to be broken, disabling extension now..\n");
-    ErrorF("record: http://bugs.freedesktop.org/show_bug.cgi?id=20500\n");
-#if 0
     ExtensionEntry *extentry;
 
     RTContext = CreateNewResourceType(RecordDeleteContext);
@@ -2895,6 +2913,5 @@ RecordExtensionInit(void)
     }
     RecordErrorBase = extentry->errorBase;
 
-#endif
 } /* RecordExtensionInit */
 
commit d1732a637e479f20a0edd1426c99d1c6f2027049
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Mon Jan 18 14:31:12 2010 +0200

    xfree86: vgaarb: remove useless debug
    
    This is RAC's remnant. Any sane person would use a more wise method of
    debugging instead.
    
    X.Org Bug 26074 <http://bugs.freedesktop.org/show_bug.cgi?id=26074>
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>
    (cherry picked from commit 5e81078cf56aabbf6551d96d312c7840ba9370ae)
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/xfree86/common/xf86VGAarbiter.c b/hw/xfree86/common/xf86VGAarbiter.c
index b240998..cd45cd1 100644
--- a/hw/xfree86/common/xf86VGAarbiter.c
+++ b/hw/xfree86/common/xf86VGAarbiter.c
@@ -38,14 +38,6 @@
 #include "xf86Priv.h"
 #include "pciaccess.h"
 
-#ifdef DEBUG
-#error "no, really, you dont want to do this"
-#define DPRINT_S(x,y) ErrorF(x ": %i\n",y);
-#define DPRINT(x) ErrorF(x "\n");
-#else
-#define DPRINT_S(x,y)
-#define DPRINT(x)
-#endif
 
 static GCFuncs VGAarbiterGCFuncs = {
     VGAarbiterValidateGC, VGAarbiterChangeGC, VGAarbiterCopyGC,
@@ -187,8 +179,6 @@ xf86VGAarbiterWrapFunctions(void)
         pScrn = xf86Screens[pScreen->myNum];
         PointPriv = dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
 
-        DPRINT_S("VGAarbiterWrapFunctions",pScreen->myNum);
-
         if (!dixRequestPrivate(VGAarbiterGCKey, sizeof(VGAarbiterGCRec)))
             return FALSE;
 
@@ -244,7 +234,6 @@ VGAarbiterCloseScreen (int i, ScreenPtr pScreen)
     PictureScreenPtr    ps = GetPictureScreenIfSet(pScreen);
 #endif
 
-    DPRINT_S("VGAarbiterCloseScreen",pScreen->myNum);
     UNWRAP_SCREEN(CreateGC);
     UNWRAP_SCREEN(CloseScreen);
     UNWRAP_SCREEN(GetImage);
@@ -311,7 +300,6 @@ VGAarbiterGetImage (
     )
 {
     ScreenPtr pScreen = pDrawable->pScreen;
-    DPRINT_S("VGAarbiterGetImage",pScreen->myNum);
     SCREEN_PROLOG(GetImage);
 //    if (xf86Screens[pScreen->myNum]->vtSema) {
     VGAGet();
@@ -334,7 +322,6 @@ VGAarbiterGetSpans (
 {
     ScreenPtr       pScreen = pDrawable->pScreen;
 
-    DPRINT_S("VGAarbiterGetSpans",pScreen->myNum);
     SCREEN_PROLOG (GetSpans);
     VGAGet();
     (*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
@@ -348,7 +335,6 @@ VGAarbiterSourceValidate (
     int x, int y, int width, int height )
 {
     ScreenPtr   pScreen = pDrawable->pScreen;
-    DPRINT_S("VGAarbiterSourceValidate",pScreen->myNum);
     SCREEN_PROLOG (SourceValidate);
     VGAGet();
     if (pScreen->SourceValidate)
@@ -365,7 +351,6 @@ VGAarbiterCopyWindow(
 {
     ScreenPtr pScreen = pWin->drawable.pScreen;
 
-    DPRINT_S("VGAarbiterCopyWindow",pScreen->myNum);
     SCREEN_PROLOG (CopyWindow);
     VGAGet();
     (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc);
@@ -382,7 +367,6 @@ VGAarbiterClearToBackground (
 {
     ScreenPtr pScreen = pWin->drawable.pScreen;
 
-    DPRINT_S("VGAarbiterClearToBackground",pScreen->myNum);
     SCREEN_PROLOG ( ClearToBackground);
     VGAGet();
     (*pScreen->ClearToBackground) (pWin, x, y, w, h, generateExposures);
@@ -395,7 +379,6 @@ VGAarbiterCreatePixmap(ScreenPtr pScreen, int w, int h, int depth, unsigned usag
 {
     PixmapPtr pPix;
 
-    DPRINT_S("VGAarbiterCreatePixmap",pScreen->myNum);
     SCREEN_PROLOG ( CreatePixmap);
     VGAGet();
     pPix = (*pScreen->CreatePixmap) (pScreen, w, h, depth, usage_hint);
@@ -410,7 +393,6 @@ VGAarbiterSaveScreen(ScreenPtr pScreen, Bool unblank)
 {
     Bool val;
 
-    DPRINT_S("VGAarbiterSaveScreen",pScreen->myNum);
     SCREEN_PROLOG (SaveScreen);
     VGAGet();
     val = (*pScreen->SaveScreen) (pScreen, unblank);
@@ -428,7 +410,6 @@ VGAarbiterStoreColors (
 {
     ScreenPtr pScreen = pmap->pScreen;
 
-    DPRINT_S("VGAarbiterStoreColors",pScreen->myNum);
     SCREEN_PROLOG (StoreColors);
     VGAGet();
     (*pScreen->StoreColors) (pmap,ndef,pdefs);
@@ -444,7 +425,6 @@ VGAarbiterRecolorCursor (
     Bool displayed
     )
 {
-    DPRINT_S("VGAarbiterRecolorCursor",pScreen->myNum);
     SCREEN_PROLOG (RecolorCursor);
     VGAGet();
     (*pScreen->RecolorCursor) (pDev, pScreen, pCurs, displayed);
@@ -461,7 +441,6 @@ VGAarbiterRealizeCursor (
 {
     Bool val;
 
-    DPRINT_S("VGAarbiterRealizeCursor",pScreen->myNum);
     SCREEN_PROLOG (RealizeCursor);
     VGAGet();
     val = (*pScreen->RealizeCursor) (pDev, pScreen,pCursor);
@@ -479,7 +458,6 @@ VGAarbiterUnrealizeCursor (
 {
     Bool val;
 
-    DPRINT_S("VGAarbiterUnrealizeCursor",pScreen->myNum);
     SCREEN_PROLOG (UnrealizeCursor);
     VGAGet();
     val = (*pScreen->UnrealizeCursor) (pDev, pScreen, pCursor);
@@ -497,7 +475,6 @@ VGAarbiterDisplayCursor (
 {
     Bool val;
 
-    DPRINT_S("VGAarbiterDisplayCursor",pScreen->myNum);
     SCREEN_PROLOG (DisplayCursor);
     VGAGet();
     val = (*pScreen->DisplayCursor) (pDev, pScreen, pCursor);
@@ -515,7 +492,6 @@ VGAarbiterSetCursorPosition (
 {
     Bool val;
 
-    DPRINT_S("VGAarbiterSetCursorPosition",pScreen->myNum);
     SCREEN_PROLOG (SetCursorPosition);
     VGAGet();
     val = (*pScreen->SetCursorPosition) (pDev, pScreen, x, y, generateEvent);
@@ -531,7 +507,6 @@ VGAarbiterAdjustFrame(int index, int x, int y, int flags)
     VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate(
         &pScreen->devPrivates, VGAarbiterScreenKey);
 
-    DPRINT_S("VGAarbiterAdjustFrame",index);
     VGAGet();
     (*pScreenPriv->AdjustFrame)(index, x, y, flags);
     VGAPut();
@@ -545,7 +520,6 @@ VGAarbiterSwitchMode(int index, DisplayModePtr mode, int flags)
     VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate(
         &pScreen->devPrivates, VGAarbiterScreenKey);
 
-    DPRINT_S("VGAarbiterSwitchMode",index);
     VGAGet();
     val = (*pScreenPriv->SwitchMode)(index, mode, flags);
     VGAPut();
@@ -560,7 +534,6 @@ VGAarbiterEnterVT(int index, int flags)
     VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate(
         &pScreen->devPrivates, VGAarbiterScreenKey);
 
-    DPRINT_S("VGAarbiterEnterVT",index);
     VGAGet();
     val = (*pScreenPriv->EnterVT)(index, flags);
     VGAPut();
@@ -574,8 +547,6 @@ VGAarbiterLeaveVT(int index, int flags)
     VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate(
         &pScreen->devPrivates, VGAarbiterScreenKey);
 
-    DPRINT_S("VGAarbiterLeaveVT",index);
-
     VGAGet();
     (*pScreenPriv->LeaveVT)(index, flags);
     VGAPut();
@@ -588,8 +559,6 @@ VGAarbiterFreeScreen(int index, int flags)
     VGAarbiterScreenPtr pScreenPriv = (VGAarbiterScreenPtr)dixLookupPrivate(
         &pScreen->devPrivates, VGAarbiterScreenKey);
 
-    DPRINT_S("VGAarbiterFreeScreen",index);
-
     VGAGet();
     (*pScreenPriv->FreeScreen)(index, flags);
     VGAPut();
@@ -602,7 +571,6 @@ VGAarbiterCreateGC(GCPtr pGC)
     VGAarbiterGCPtr pGCPriv = (VGAarbiterGCPtr)dixLookupPrivate(&pGC->devPrivates, VGAarbiterGCKey);
     Bool         ret;
 
-    DPRINT_S("VGAarbiterCreateGC",pScreen->myNum);
     SCREEN_PROLOG(CreateGC);
     VGAGet();
     ret = (*pScreen->CreateGC)(pGC);
@@ -621,7 +589,6 @@ VGAarbiterValidateGC(
    DrawablePtr   pDraw )
 {
     GC_UNWRAP(pGC);
-    DPRINT("VGAarbiterValidateGC");
     (*pGC->funcs->ValidateGC)(pGC, changes, pDraw);
     GC_WRAP(pGC);
 }
@@ -631,7 +598,6 @@ static void
 VGAarbiterDestroyGC(GCPtr pGC)
 {
     GC_UNWRAP (pGC);
-    DPRINT("VGAarbiterDestroyGC");
     (*pGC->funcs->DestroyGC)(pGC);
     GC_WRAP (pGC);
 }
@@ -642,7 +608,6 @@ VGAarbiterChangeGC (
     unsigned long   mask)
 {
     GC_UNWRAP (pGC);
-    DPRINT("VGAarbiterChangeGC");
     (*pGC->funcs->ChangeGC) (pGC, mask);
     GC_WRAP (pGC);
 }
@@ -654,7 +619,6 @@ VGAarbiterCopyGC (
     GCPtr       pGCDst)
 {
     GC_UNWRAP (pGCDst);
-    DPRINT("VGAarbiterCopyGC");
     (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst);
     GC_WRAP (pGCDst);
 }
@@ -667,7 +631,6 @@ VGAarbiterChangeClip (
     int     nrects )
 {
     GC_UNWRAP (pGC);
-    DPRINT("VGAarbiterChangeClip");
     (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects);
     GC_WRAP (pGC);
 }
@@ -676,7 +639,6 @@ static void
 VGAarbiterCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
 {
     GC_UNWRAP (pgcDst);
-    DPRINT("VGAarbiterCopyClip");
     (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc);
     GC_WRAP (pgcDst);
 }
@@ -685,7 +647,6 @@ static void
 VGAarbiterDestroyClip(GCPtr pGC)
 {
     GC_UNWRAP (pGC);
-    DPRINT("VGAarbiterDestroyClip");
     (* pGC->funcs->DestroyClip)(pGC);
     GC_WRAP (pGC);
 }
@@ -701,7 +662,6 @@ VGAarbiterFillSpans(
     int fSorted )
 {
     GC_UNWRAP(pGC);
-    DPRINT("VGAarbiterFillSpans");
     VGAGet_GC();
     (*pGC->ops->FillSpans)(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted);
     VGAPut_GC();
@@ -719,7 +679,6 @@ VGAarbiterSetSpans(
     int         fSorted )
 {
     GC_UNWRAP(pGC);
-    DPRINT("VGAarbiterSetSpans");
     VGAGet_GC();
     (*pGC->ops->SetSpans)(pDraw, pGC, pcharsrc, ppt, pwidth, nspans, fSorted);
     VGAPut_GC();
@@ -737,7 +696,6 @@ VGAarbiterPutImage(
     char    *pImage )
 {
     GC_UNWRAP(pGC);
-    DPRINT("VGAarbiterPutImage");
     VGAGet_GC();
     (*pGC->ops->PutImage)(pDraw, pGC, depth, x, y, w, h,
               leftPad, format, pImage);
@@ -757,7 +715,6 @@ VGAarbiterCopyArea(
     RegionPtr ret;
 
     GC_UNWRAP(pGC);
-    DPRINT("VGAarbiterCopyArea");
     VGAGet_GC();
     ret = (*pGC->ops->CopyArea)(pSrc, pDst,
                 pGC, srcx, srcy, width, height, dstx, dsty);
@@ -779,7 +736,6 @@ VGAarbiterCopyPlane(
     RegionPtr ret;
 
     GC_UNWRAP(pGC);
-    DPRINT("VGAarbiterCopyPlane");
     VGAGet_GC();
     ret = (*pGC->ops->CopyPlane)(pSrc, pDst, pGC, srcx, srcy,
                  width, height, dstx, dsty, bitPlane);
@@ -797,7 +753,6 @@ VGAarbiterPolyPoint(
     xPoint *pptInit )
 {
     GC_UNWRAP(pGC);
-    DPRINT("VGAarbiterPolyPoint");
     VGAGet_GC();
     (*pGC->ops->PolyPoint)(pDraw, pGC, mode, npt, pptInit);
     VGAPut_GC();
@@ -814,7 +769,6 @@ VGAarbiterPolylines(
     DDXPointPtr pptInit )
 {
     GC_UNWRAP(pGC);
-    DPRINT("VGAarbiterPolylines");
     VGAGet_GC();
     (*pGC->ops->Polylines)(pDraw, pGC, mode, npt, pptInit);
     VGAPut_GC();
@@ -829,7 +783,6 @@ VGAarbiterPolySegment(
     xSegment    *pSeg )
 {
     GC_UNWRAP(pGC);
-    DPRINT("VGAarbiterPolySegment");
     VGAGet_GC();
     (*pGC->ops->PolySegment)(pDraw, pGC, nseg, pSeg);
     VGAPut_GC();
@@ -844,7 +797,6 @@ VGAarbiterPolyRectangle(
     xRectangle  *pRectsInit )
 {
     GC_UNWRAP(pGC);
-    DPRINT("VGAarbiterPolyRectangle");
     VGAGet_GC();
     (*pGC->ops->PolyRectangle)(pDraw, pGC, nRectsInit, pRectsInit);
     VGAPut_GC();
@@ -859,7 +811,6 @@ VGAarbiterPolyArc(
     xArc    *parcs )
 {
     GC_UNWRAP(pGC);
-    DPRINT("VGAarbiterPolyArc");
     VGAGet_GC();
     (*pGC->ops->PolyArc)(pDraw, pGC, narcs, parcs);
     VGAPut_GC();
@@ -876,7 +827,6 @@ VGAarbiterFillPolygon(
     DDXPointPtr ptsIn )
 {
     GC_UNWRAP(pGC);
-    DPRINT("VGAarbiterFillPolygon");
     VGAGet_GC();
     (*pGC->ops->FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn);
     VGAPut_GC();
@@ -891,7 +841,6 @@ VGAarbiterPolyFillRect(
     xRectangle  *prectInit)
 {
     GC_UNWRAP(pGC);
-    DPRINT("VGAarbiterPolyFillRect");
     VGAGet_GC();
     (*pGC->ops->PolyFillRect)(pDraw, pGC, nrectFill, prectInit);
     VGAPut_GC();
@@ -906,7 +855,6 @@ VGAarbiterPolyFillArc(
     xArc    *parcs )
 {
     GC_UNWRAP(pGC);
-    DPRINT("VGAarbiterPolyFillArc");
     VGAGet_GC();
     (*pGC->ops->PolyFillArc)(pDraw, pGC, narcs, parcs);
     VGAPut_GC();
@@ -925,7 +873,6 @@ VGAarbiterPolyText8(
     int ret;
 
     GC_UNWRAP(pGC);
-    DPRINT("VGAarbiterPolyText8");
     VGAGet_GC();
     ret = (*pGC->ops->PolyText8)(pDraw, pGC, x, y, count, chars);
     VGAPut_GC();
@@ -945,7 +892,6 @@ VGAarbiterPolyText16(
     int ret;
 
     GC_UNWRAP(pGC);
-    DPRINT("VGAarbiterPolyText16");
     VGAGet_GC();
     ret = (*pGC->ops->PolyText16)(pDraw, pGC, x, y, count, chars);
     VGAPut_GC();
@@ -963,7 +909,6 @@ VGAarbiterImageText8(
     char    *chars )
 {
     GC_UNWRAP(pGC);
-    DPRINT("VGAarbiterImageText8");
     VGAGet_GC();
     (*pGC->ops->ImageText8)(pDraw, pGC, x, y, count, chars);
     VGAPut_GC();
@@ -980,7 +925,6 @@ VGAarbiterImageText16(
     unsigned short *chars )
 {
     GC_UNWRAP(pGC);
-    DPRINT("VGAarbiterImageText16");
     VGAGet_GC();
     (*pGC->ops->ImageText16)(pDraw, pGC, x, y, count, chars);
     VGAPut_GC();
@@ -998,7 +942,6 @@ VGAarbiterImageGlyphBlt(
     pointer pglyphBase )
 {
     GC_UNWRAP(pGC);
-    DPRINT("VGAarbiterImageGlyphBlt");
     VGAGet_GC();
     (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, xInit, yInit,
                    nglyph, ppci, pglyphBase);
@@ -1016,7 +959,6 @@ VGAarbiterPolyGlyphBlt(
     pointer pglyphBase )
 {
     GC_UNWRAP(pGC);
-    DPRINT("VGAarbiterPolyGlyphBlt");
     VGAGet_GC();
     (*pGC->ops->PolyGlyphBlt)(pDraw, pGC, xInit, yInit,
                   nglyph, ppci, pglyphBase);
@@ -1032,7 +974,6 @@ VGAarbiterPushPixels(
     int dx, int dy, int xOrg, int yOrg )
 {
     GC_UNWRAP(pGC);
-    DPRINT("VGAarbiterPushPixels");
     VGAGet_GC();
     (*pGC->ops->PushPixels)(pGC, pBitMap, pDraw, dx, dy, xOrg, yOrg);
     VGAPut_GC();
@@ -1046,7 +987,6 @@ VGAarbiterSpriteRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pC
 {
     Bool val;
     SPRITE_PROLOG;
-    DPRINT_S("VGAarbiterSpriteRealizeCursor",pScreen->myNum);
     VGAGet();
     val = PointPriv->spriteFuncs->RealizeCursor(pDev, pScreen, pCur);
     VGAPut();
@@ -1059,7 +999,6 @@ VGAarbiterSpriteUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr
 {
     Bool val;
     SPRITE_PROLOG;
-    DPRINT_S("VGAarbiterSpriteUnrealizeCursor",pScreen->myNum);
     VGAGet();
     val = PointPriv->spriteFuncs->UnrealizeCursor(pDev, pScreen, pCur);
     VGAPut();
@@ -1071,7 +1010,6 @@ static void
 VGAarbiterSpriteSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCur, int x, int y)
 {
     SPRITE_PROLOG;
-    DPRINT_S("VGAarbiterSpriteSetCursor",pScreen->myNum);
     VGAGet();
     PointPriv->spriteFuncs->SetCursor(pDev, pScreen, pCur, x, y);
     VGAPut();
@@ -1082,7 +1020,6 @@ static void
 VGAarbiterSpriteMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
 {
     SPRITE_PROLOG;
-    DPRINT_S("VGAarbiterSpriteMoveCursor",pScreen->myNum);
     VGAGet();
     PointPriv->spriteFuncs->MoveCursor(pDev, pScreen, x, y);
     VGAPut();
@@ -1094,7 +1031,6 @@ VGAarbiterDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
 {
     Bool val;
     SPRITE_PROLOG;
-    DPRINT_S("VGAarbiterDeviceCursorInitialize",pScreen->myNum);
     VGAGet();
     val = PointPriv->spriteFuncs->DeviceCursorInitialize(pDev, pScreen);
     VGAPut();
@@ -1106,7 +1042,6 @@ static void
 VGAarbiterDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen)
 {
     SPRITE_PROLOG;
-    DPRINT_S("VGAarbiterDeviceCursorCleanup",pScreen->myNum);
     VGAGet();
     PointPriv->spriteFuncs->DeviceCursorCleanup(pDev, pScreen);
     VGAPut();
commit dd0217fc93c1d374d7d51f1b0270e7575fd48320
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Tue Jan 5 13:15:25 2010 +1000

    dix: don't update the slave coordinates from the VCK.
    
    A keyboard event from a device with both valuators and keys will be posted
    through the VCK. In this case, do not update the slave device coordinates
    from the VCK - they're always 0/0. Leave them as-is, for the next pointer
    event will continue where it left.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>
    (cherry picked from commit 6f265d55a61f9be323583b8acacae783be72bda9)
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/getevents.c b/dix/getevents.c
index 18c6302..82bb77b 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -630,9 +630,12 @@ updateFromMaster(EventListPtr events, DeviceIntPtr dev, int type, int *num_event
     if (master && master->last.slave != dev)
     {
         CreateClassesChangedEvent(events, master, dev, type);
-        updateSlaveDeviceCoords(master, dev);
+        if (IsPointerDevice(master))
+        {
+            updateSlaveDeviceCoords(master, dev);
+            master->last.numValuators = dev->last.numValuators;
+        }
         master->last.slave = dev;
-        master->last.numValuators = dev->last.numValuators;
         (*num_events)++;
         events++;
     }
commit 8dda9ba67ab530612cdc27c540a88a1465a82173
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Mon Feb 15 16:46:21 2010 -0800

    XQuartz: Fix a possible buffer overrun in quartzAudio
    
    Also dropped deprecated API while there
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    (cherry picked from commit 4e8bf12b13690afa6d9fee0e339d3819ef16fb3f)

diff --git a/hw/xquartz/quartzAudio.c b/hw/xquartz/quartzAudio.c
index e4b49fc..708202b 100644
--- a/hw/xquartz/quartzAudio.c
+++ b/hw/xquartz/quartzAudio.c
@@ -62,7 +62,6 @@ typedef struct QuartzAudioRec {
     UInt32 curFrame;
     UInt32 remainingFrames;
     UInt32 totalFrames;
-    UInt32 bytesPerFrame;
     double sampleRate;
     UInt32 fadeLength;
 
@@ -117,9 +116,9 @@ static void QuartzFillBuffer(
     unsigned int bufferFrameCount;
     float multiplier, v;
     int i;
-
+    
     buffer = (float *)audiobuffer->mData;
-    bufferFrameCount = audiobuffer->mDataByteSize / data->bytesPerFrame;
+    bufferFrameCount = audiobuffer->mDataByteSize / (sizeof(float) * audiobuffer->mNumberChannels);
 
     frameCount = min(bufferFrameCount, data->remainingFrames);
 
@@ -141,7 +140,7 @@ static void QuartzFillBuffer(
         data->prevFrame = 0;
 
         // adjust for space eaten by prev fade
-        buffer += audiobuffer->mNumberChannels*frame;
+        b += audiobuffer->mNumberChannels*frame;
         bufferFrameCount -= frame;
         frameCount = min(bufferFrameCount, data->remainingFrames);
     }
@@ -204,7 +203,8 @@ QuartzAudioIOProc(
     if (wasPlaying  &&  !data->playing) {
         OSStatus err;
         err = AudioDeviceStop(inDevice, QuartzAudioIOProc);
-        fprintf(stderr, "Error stopping audio device: %ld\n", (long int)err);
+        if(err != noErr)
+            fprintf(stderr, "Error stopping audio device: %ld\n", (long int)err);
     }
     pthread_mutex_unlock(&data->lock);
     return 0;
@@ -263,16 +263,17 @@ void QuartzAudioInit(void)
     UInt32 propertySize;
     OSStatus status;
     AudioDeviceID outputDevice;
-    AudioStreamBasicDescription outputStreamDescription;
     double sampleRate;
-
+    AudioObjectPropertyAddress devicePropertyAddress = { kAudioHardwarePropertyDefaultOutputDevice, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
+    AudioObjectPropertyAddress sampleRatePropertyAddress = { kAudioDevicePropertyNominalSampleRate, kAudioDevicePropertyScopeOutput, kAudioObjectPropertyElementMaster };
+    
     // Get the default output device
     propertySize = sizeof(outputDevice);
-    status = AudioHardwareGetProperty(
-                    kAudioHardwarePropertyDefaultOutputDevice, 
-                    &propertySize, &outputDevice);
+    status = AudioObjectGetPropertyData(kAudioObjectSystemObject, &devicePropertyAddress,
+                                        0, NULL,
+                                        &propertySize, &outputDevice);
     if (status) {
-        ErrorF("QuartzAudioInit: AudioHardwareGetProperty returned %ld\n",
+        ErrorF("QuartzAudioInit: AudioObjectGetPropertyData(output device) returned %ld\n",
                (long)status);
         return;
     }
@@ -282,23 +283,22 @@ void QuartzAudioInit(void)
     }
 
     // Get the basic device description
-    propertySize = sizeof(outputStreamDescription);
-    status = AudioDeviceGetProperty(outputDevice, 0, FALSE, 
-                                    kAudioDevicePropertyStreamFormat, 
-                                    &propertySize, &outputStreamDescription);
+    sampleRate = 0.;
+    propertySize = sizeof(sampleRate);
+    status = AudioObjectGetPropertyData(outputDevice, &sampleRatePropertyAddress,
+                                        0, NULL,
+                                        &propertySize, &sampleRate);
     if (status) {
-        ErrorF("QuartzAudioInit: GetProperty(stream format) returned %ld\n",
+        ErrorF("QuartzAudioInit: AudioObjectGetPropertyData(sample rate) returned %ld\n",
                (long)status);
         return;
     }
-    sampleRate = outputStreamDescription.mSampleRate;
 
     // Fill in the playback data
     data.frequency = 0;
     data.amplitude = 0;
     data.curFrame = 0;
     data.remainingFrames = 0; 
-    data.bytesPerFrame = outputStreamDescription.mBytesPerFrame;
     data.sampleRate = sampleRate;
     // data.bufferByteCount = bufferByteCount;
     data.playing = FALSE;
commit 4d8ad88b5747789b0c35bccab1088114470984cd
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Wed Feb 10 17:56:30 2010 -0800

    XQuartz: clang static analysis fixes
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    (cherry picked from commit 4127e8e5be5c366eb752bbb8d7f0ff5b519e641b)

diff --git a/hw/xquartz/GL/indirect.c b/hw/xquartz/GL/indirect.c
index 1762825..44380ff 100644
--- a/hw/xquartz/GL/indirect.c
+++ b/hw/xquartz/GL/indirect.c
@@ -548,7 +548,7 @@ static CGLPixelFormatObj makeFormat(__GLXconfig *conf) {
        attr[i++] = conf->samples;
     }
      
-    attr[i++] = 0;
+    attr[i + 1] = 0;
 
     error = CGLChoosePixelFormat(attr, &fobj, &formats);
     if(error) {
diff --git a/hw/xquartz/GL/visualConfigs.c b/hw/xquartz/GL/visualConfigs.c
index f926778..bef27f0 100644
--- a/hw/xquartz/GL/visualConfigs.c
+++ b/hw/xquartz/GL/visualConfigs.c
@@ -62,7 +62,7 @@ __GLXconfig *__glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
     int numConfigs = 0;
     __GLXconfig *visualConfigs, *c;
     struct glCapabilities caps;
-    struct glCapabilitiesConfig *conf = NULL;
+    struct glCapabilitiesConfig *conf;
     int stereo, depth, aux, buffers, stencil, accum, color, msample;
     
     if(getGlCapabilities(&caps)) {
@@ -94,7 +94,6 @@ __GLXconfig *__glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
      */
     
     assert(NULL != caps.configurations);
-    conf = caps.configurations;
     
     numConfigs = 0;
     
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index f3c8a30..3faa1cb 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -482,7 +482,7 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
 	return out;
 }
 
-- (CFPropertyListRef) prefs_get:(NSString *)key {
+- (CFPropertyListRef) prefs_get_copy:(NSString *)key {
     CFPropertyListRef value;
 	
     value = CFPreferencesCopyAppValue ((CFStringRef) key, app_prefs_domain_cfstr);
@@ -543,7 +543,7 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
   CFPropertyListRef value;
   int ret;
   
-  value = [self prefs_get:key];
+  value = [self prefs_get_copy:key];
   
   if (value != NULL && CFGetTypeID (value) == CFNumberGetTypeID ())
     CFNumberGetValue (value, kCFNumberIntType, &ret);
@@ -561,7 +561,7 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
   CFPropertyListRef value;
   const char *ret = NULL;
   
-  value = [self prefs_get:key];
+  value = [self prefs_get_copy:key];
   
   if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ()) {
     NSString *s = (NSString *) value;
@@ -578,12 +578,13 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
     CFPropertyListRef value;
     NSURL *ret = NULL;
     
-    value = [self prefs_get:key];
+    value = [self prefs_get_copy:key];
     
     if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ()) {
         NSString *s = (NSString *) value;
 
         ret = [NSURL URLWithString:s];
+        [ret retain];
     }
     
     if (value != NULL) CFRelease (value);
@@ -595,7 +596,7 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
   CFPropertyListRef value;
   float ret = def;
   
-  value = [self prefs_get:key];
+  value = [self prefs_get_copy:key];
   
   if (value != NULL
       && CFGetTypeID (value) == CFNumberGetTypeID ()
@@ -613,7 +614,7 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
   CFPropertyListRef value;
   int ret = def;
   
-  value = [self prefs_get:key];
+  value = [self prefs_get_copy:key];
   
   if (value != NULL) {
     if (CFGetTypeID (value) == CFNumberGetTypeID ())
@@ -637,7 +638,7 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
   NSArray *ret = nil;
   CFPropertyListRef value;
   
-  value = [self prefs_get:key];
+  value = [self prefs_get_copy:key];
   
   if (value != NULL) {
     if (CFGetTypeID (value) == CFArrayGetTypeID ())
@@ -757,7 +758,7 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
     NSURL *url =  [self prefs_copy_url:@PREFS_UPDATE_FEED default:nil];
     if(url) {
         [[SUUpdater sharedUpdater] setFeedURL:url];
-        CFRelease(url);
+        [url release];
     }
 #endif
 }
@@ -970,6 +971,7 @@ void X11ApplicationMain (int argc, char **argv, char **envp) {
 //    [[SUUpdater sharedUpdater] checkForUpdates:X11App];
 #endif
 
+    [pool release];
     [NSApp run];
     /* not reached */
 }
diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index 0366f3b..4872ff5 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -641,30 +641,46 @@ static int execute(const char *command) {
 static char *command_from_prefs(const char *key, const char *default_value) {
     char *command = NULL;
     
-    CFStringRef cfKey = CFStringCreateWithCString(NULL, key, kCFStringEncodingASCII);
-    CFPropertyListRef PlistRef = CFPreferencesCopyAppValue(cfKey, kCFPreferencesCurrentApplication);
+    CFStringRef cfKey;
+    CFPropertyListRef PlistRef;
+
+    if(!key)
+        return NULL;
+
+    cfKey = CFStringCreateWithCString(NULL, key, kCFStringEncodingASCII);
+
+    if(!cfKey)
+        return NULL;
+
+    PlistRef = CFPreferencesCopyAppValue(cfKey, kCFPreferencesCurrentApplication);
     
     if ((PlistRef == NULL) || (CFGetTypeID(PlistRef) != CFStringGetTypeID())) {
         CFStringRef cfDefaultValue = CFStringCreateWithCString(NULL, default_value, kCFStringEncodingASCII);
         int len = strlen(default_value) + 1;
 
+        if(!cfDefaultValue)
+            goto command_from_prefs_out;
+
         CFPreferencesSetAppValue(cfKey, cfDefaultValue, kCFPreferencesCurrentApplication);
         CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
+        CFRelease(cfDefaultValue);
         
         command = (char *)malloc(len * sizeof(char));
         if(!command)
-            return NULL;
+            goto command_from_prefs_out;
         strcpy(command, default_value);
     } else {
         int len = CFStringGetLength((CFStringRef)PlistRef) + 1;
         command = (char *)malloc(len * sizeof(char));
         if(!command)
-            return NULL;
+            goto command_from_prefs_out;
         CFStringGetCString((CFStringRef)PlistRef, command, len,  kCFStringEncodingASCII);
-	}
-    
+    }
+
+command_from_prefs_out:
     if (PlistRef)
         CFRelease(PlistRef);
-    
+    if(cfKey)
+        CFRelease(cfKey);
     return command;
 }
diff --git a/hw/xquartz/mach-startup/stub.c b/hw/xquartz/mach-startup/stub.c
index af1c59e..8b1c832 100644
--- a/hw/xquartz/mach-startup/stub.c
+++ b/hw/xquartz/mach-startup/stub.c
@@ -73,7 +73,6 @@ static void set_x11_path(void) {
 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
 
     CFURLRef appURL = NULL;
-    CFBundleRef bundle = NULL;
     OSStatus osstatus = LSFindApplicationForInfo(kLSUnknownCreator, CFSTR(kX11AppBundleId), nil, nil, &appURL);
 
     switch (osstatus) {
@@ -84,12 +83,6 @@ static void set_x11_path(void) {
                 exit(1);
             }
 
-            bundle = CFBundleCreate(NULL, appURL);
-            if(!bundle) {
-                fprintf(stderr, "Xquartz: Null value returned from CFBundleCreate().\n");
-                exit(2);                
-            }
-
             if (!CFURLGetFileSystemRepresentation(appURL, true, (unsigned char *)x11_path, sizeof(x11_path))) {
                 fprintf(stderr, "Xquartz: Error resolving URL for %s\n", kX11AppBundleId);
                 exit(3);
diff --git a/hw/xquartz/pbproxy/x-selection.h b/hw/xquartz/pbproxy/x-selection.h
index fc903d0..614c8b0 100644
--- a/hw/xquartz/pbproxy/x-selection.h
+++ b/hw/xquartz/pbproxy/x-selection.h
@@ -58,15 +58,6 @@ struct atom_list {
     /* The unmapped window we use for fetching selections. */
     Window _selection_window;
 
-    /* Last time we declared anything on the pasteboard. */
-    int _my_last_change;
-
-    /* Name of the selection we're proxying onto the pasteboard. */
-    Atom _proxied_selection;
-
-    /* When true, we're expecting a SelectionNotify event. */
-    unsigned int _pending_notify :1;
- 
     Atom request_atom;
     
     struct {
diff --git a/hw/xquartz/quartzAudio.c b/hw/xquartz/quartzAudio.c
index af63d18..e4b49fc 100644
--- a/hw/xquartz/quartzAudio.c
+++ b/hw/xquartz/quartzAudio.c
@@ -204,6 +204,7 @@ QuartzAudioIOProc(
     if (wasPlaying  &&  !data->playing) {
         OSStatus err;
         err = AudioDeviceStop(inDevice, QuartzAudioIOProc);
+        fprintf(stderr, "Error stopping audio device: %ld\n", (long int)err);
     }
     pthread_mutex_unlock(&data->lock);
     return 0;
diff --git a/hw/xquartz/quartzKeyboard.c b/hw/xquartz/quartzKeyboard.c
index 96b5fa5..3b4eac3 100644
--- a/hw/xquartz/quartzKeyboard.c
+++ b/hw/xquartz/quartzKeyboard.c
@@ -368,7 +368,7 @@ void DarwinKeyboardReloadHandler(void) {
     KeySymsRec keySyms;
     CFIndex initialKeyRepeatValue, keyRepeatValue;
     BOOL ok;
-    DeviceIntPtr pDev = darwinKeyboard;
+    DeviceIntPtr pDev;
     const char *xmodmap = PROJECTROOT "/bin/xmodmap";
     const char *sysmodmap = PROJECTROOT "/lib/X11/xinit/.Xmodmap";
     const char *homedir = getenv("HOME");


More information about the xorg-commit mailing list